@5even7/dlc-ui 0.2.2 → 0.2.3

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  > **发版规则**:默认每次发布只递增补丁号(0.x.y → 0.x.(y+1),即 +0.01);除非手动明确指定新版本号,否则不升次版本。
4
4
 
5
+ ## 0.2.3 - 2026-08-08
6
+
7
+ - 修复:Vue wrapper 重建组件(如 showValue 开关)后插槽内容丢失的问题(插槽容器改为整体搬入文字区/颜色区)。
8
+ - 修复:进度条点击后无法直接使用键盘方向键的问题(拖动开始时自动聚焦)。
9
+ - 修复:胶囊 `textRatio=0` 时文字区仍因最小宽度 164px 占位的问题,现 0 即完全隐藏。
10
+ - 新增 Progress `readonly` 属性:与 disabled 行为一致但不置灰(`aria-readonly`)。
11
+
5
12
  ## 0.2.2 - 2026-08-08
6
13
 
7
14
  - 修复:Progress 的 `setLabel()` 对 const 变量重新赋值,导致打包产物被 esbuild 拒绝、文档站无法构建的问题;label 热更新恢复正常。
package/README.md CHANGED
@@ -157,7 +157,7 @@ export default {
157
157
 
158
158
  胶囊专属:`seed`、`speed`、`mouseColor`(颜色随鼠标旋涡,默认 `true`,关闭不影响 click/悬浮/长按等事件)。
159
159
 
160
- 进度条专属:`value`、`min`、`max`(value 的合法区间,默认 0~100;**水线归一化到 [min, max]**,键盘 ±2% 与 PageUp/PageDown ±10% 都是“范围的百分比”,右侧数字仍显示原始 value)、`draggable`、`keyboard`、`disabled`(true 时同时禁用拖动/键盘、tabindex=-1、aria-disabled、视觉置灰)、`edgeStyle`(`flow/tide`)、`valueSuffix`(右侧数字后缀,默认 `%`)、`showValue`(是否显示右侧百分比数字,默认 `true`,`false` 只隐藏数字、不影响无障碍信息)。
160
+ 进度条专属:`value`、`min`、`max`(value 的合法区间,默认 0~100;**水线归一化到 [min, max]**,键盘 ±2% 与 PageUp/PageDown ±10% 都是“范围的百分比”,右侧数字仍显示原始 value)、`draggable`、`keyboard`(点击组件会自动聚焦,之后即可用方向键/PageUp/PageDown/Home/End)、`disabled`(禁用交互并置灰)、`readonly`(禁用交互但不置灰)、`edgeStyle`(`flow/tide`)、`valueSuffix`(右侧数字后缀,默认 `%`)、`showValue`(是否显示右侧百分比数字,默认 `true`,`false` 只隐藏数字、不影响无障碍信息)。
161
161
 
162
162
  插槽内容属性(H5/工厂):`text`、`colorContent`,支持 HTML 字符串或 DOM 节点(数组);Vue 组件请用默认插槽 / `#color` 插槽。**注意:字符串走 innerHTML,不要传入不可信/用户直接输入的内容(XSS 风险)。**
163
163
 
@@ -181,7 +181,7 @@ dlc-color 背景层(`createColorBackground(host, options)`):`preset`、`co
181
181
  ## 属性 vs cssVars 边界
182
182
 
183
183
  - **内容(文字/图片/按钮)**:只归插槽管,组件不施加任何样式;
184
- - **文字区宽度**:只归 `textRatio` 属性管(唯一入口,写入 `--hj-text-width`);
184
+ - **文字区宽度**:只归 `textRatio` 属性管(唯一入口,写入 `--hj-text-width`;`0` 即隐藏文字区);
185
185
  - **区域外观(背景/内边距/圆角/左侧距)**:只归 cssVars 管;
186
186
  - **星云颜料**:只归 `colors` 属性管(与 `#color` 插槽无关,前者改画布颜料,后者放你的覆盖内容);
187
187
  - 旧的 `--hj-copy-*`、`--hj-progress-copy-*` 变量保留为**兼容别名**,只兜底不优先。
package/dist/capsule.cjs CHANGED
@@ -1174,6 +1174,8 @@ function createCapsule(container) {
1174
1174
  }
1175
1175
  if (merged.textRatio !== undefined) {
1176
1176
  root.style.setProperty('--hj-text-width', "".concat(merged.textRatio, "%"));
1177
+ var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1178
+ 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');
1177
1179
  }
1178
1180
  renderer.resize();
1179
1181
  };
@@ -1297,6 +1299,8 @@ function createCapsule(container) {
1297
1299
  dirty.textRatio = true;
1298
1300
  merged.textRatio = value;
1299
1301
  root.style.setProperty('--hj-text-width', "".concat(value, "%"));
1302
+ var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1303
+ 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');
1300
1304
  return this;
1301
1305
  },
1302
1306
  setCssVars: function setCssVars(vars) {
package/dist/capsule.mjs CHANGED
@@ -962,6 +962,10 @@ function createCapsule(container, options = {}) {
962
962
  for (const name of Object.keys(vars)) root.style.setProperty(name, vars[name]);
963
963
  if (merged.textRatio !== undefined) {
964
964
  root.style.setProperty('--hj-text-width', `${merged.textRatio}%`);
965
+ const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
966
+ if (merged.textRatio === 0) root.style.setProperty('--hj-text-min-width', '0');
967
+ else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
968
+ else root.style.removeProperty('--hj-text-min-width');
965
969
  }
966
970
  renderer.resize();
967
971
  };
@@ -1060,6 +1064,10 @@ function createCapsule(container, options = {}) {
1060
1064
  dirty.textRatio = true;
1061
1065
  merged.textRatio = value;
1062
1066
  root.style.setProperty('--hj-text-width', `${value}%`);
1067
+ const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1068
+ if (value === 0) root.style.setProperty('--hj-text-min-width', '0');
1069
+ else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
1070
+ else root.style.removeProperty('--hj-text-min-width');
1063
1071
  return this;
1064
1072
  },
1065
1073
  setCssVars(vars) {
package/dist/index.cjs CHANGED
@@ -442,6 +442,7 @@ var DEFAULTS = {
442
442
  draggable: true,
443
443
  keyboard: true,
444
444
  disabled: false,
445
+ readonly: false,
445
446
  valueSuffix: '%',
446
447
  edgeStyle: 'flow',
447
448
  quality: 'auto',
@@ -1220,6 +1221,8 @@ function createCapsule(container) {
1220
1221
  }
1221
1222
  if (merged.textRatio !== undefined) {
1222
1223
  root.style.setProperty('--hj-text-width', "".concat(merged.textRatio, "%"));
1224
+ var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1225
+ 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');
1223
1226
  }
1224
1227
  renderer.resize();
1225
1228
  };
@@ -1343,6 +1346,8 @@ function createCapsule(container) {
1343
1346
  dirty.textRatio = true;
1344
1347
  merged.textRatio = value;
1345
1348
  root.style.setProperty('--hj-text-width', "".concat(value, "%"));
1349
+ var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1350
+ 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');
1346
1351
  return this;
1347
1352
  },
1348
1353
  setCssVars: function setCssVars(vars) {
@@ -2274,6 +2279,14 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
2274
2279
  value: function beginDrag(event) {
2275
2280
  if (event.button !== undefined && event.button !== 0) return;
2276
2281
  event.preventDefault();
2282
+ // preventDefault 会吞掉点击聚焦,主动聚焦让键盘方向键立即可用。
2283
+ try {
2284
+ this.root.focus({
2285
+ preventScroll: true
2286
+ });
2287
+ } catch (_unused) {
2288
+ this.root.focus();
2289
+ }
2277
2290
  this.dragging = true;
2278
2291
  this.pendingPointer = null;
2279
2292
  this._dragRaf = 0;
@@ -2281,7 +2294,7 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
2281
2294
  try {
2282
2295
  var _this$root$setPointer, _this$root;
2283
2296
  (_this$root$setPointer = (_this$root = this.root).setPointerCapture) === null || _this$root$setPointer === void 0 || _this$root$setPointer.call(_this$root, event.pointerId);
2284
- } catch (_unused) {}
2297
+ } catch (_unused2) {}
2285
2298
  this.emitter.emit('dragstart', {
2286
2299
  value: this.value
2287
2300
  });
@@ -2321,7 +2334,7 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
2321
2334
  if ((event === null || event === void 0 ? void 0 : event.pointerId) !== undefined && (_this$root$hasPointer = (_this$root2 = this.root).hasPointerCapture) !== null && _this$root$hasPointer !== void 0 && _this$root$hasPointer.call(_this$root2, event.pointerId)) {
2322
2335
  this.root.releasePointerCapture(event.pointerId);
2323
2336
  }
2324
- } catch (_unused2) {}
2337
+ } catch (_unused3) {}
2325
2338
  this.emitter.emit('dragend', {
2326
2339
  value: this.value
2327
2340
  });
@@ -2442,8 +2455,10 @@ function createProgressCapsule(container) {
2442
2455
  // Vue 的裸布尔属性(<ProgressCapsule disabled />)会传成空字符串,
2443
2456
  // 这里统一按 true 处理。
2444
2457
  var disabled = merged.disabled === true || merged.disabled === '' || merged.disabled === 'true';
2445
- var effectiveDraggable = disabled ? false : merged.draggable !== false;
2446
- var effectiveKeyboard = disabled ? false : merged.keyboard !== false;
2458
+ var readonly = merged.readonly === true || merged.readonly === '' || merged.readonly === 'true';
2459
+ var locked = disabled || readonly;
2460
+ var effectiveDraggable = locked ? false : merged.draggable !== false;
2461
+ var effectiveKeyboard = locked ? false : merged.keyboard !== false;
2447
2462
  var dirty = {
2448
2463
  preset: false,
2449
2464
  colors: false,
@@ -2461,6 +2476,10 @@ function createProgressCapsule(container) {
2461
2476
  root.setAttribute('aria-disabled', 'true');
2462
2477
  root.classList.add('is-disabled');
2463
2478
  }
2479
+ if (readonly) {
2480
+ root.setAttribute('aria-readonly', 'true');
2481
+ root.classList.add('is-readonly');
2482
+ }
2464
2483
  root.setAttribute('aria-valuemin', String((_merged$min = merged.min) !== null && _merged$min !== void 0 ? _merged$min : 0));
2465
2484
  root.setAttribute('aria-valuemax', String((_merged$max = merged.max) !== null && _merged$max !== void 0 ? _merged$max : 100));
2466
2485
  root.setAttribute('aria-valuenow', String(preset.initialProgress));
package/dist/index.mjs CHANGED
@@ -201,6 +201,7 @@ const DEFAULTS = {
201
201
  draggable: true,
202
202
  keyboard: true,
203
203
  disabled: false,
204
+ readonly: false,
204
205
  valueSuffix: '%',
205
206
  edgeStyle: 'flow',
206
207
  quality: 'auto',
@@ -1053,6 +1054,10 @@ function createCapsule(container, options = {}) {
1053
1054
  for (const name of Object.keys(vars)) root.style.setProperty(name, vars[name]);
1054
1055
  if (merged.textRatio !== undefined) {
1055
1056
  root.style.setProperty('--hj-text-width', `${merged.textRatio}%`);
1057
+ const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1058
+ if (merged.textRatio === 0) root.style.setProperty('--hj-text-min-width', '0');
1059
+ else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
1060
+ else root.style.removeProperty('--hj-text-min-width');
1056
1061
  }
1057
1062
  renderer.resize();
1058
1063
  };
@@ -1151,6 +1156,10 @@ function createCapsule(container, options = {}) {
1151
1156
  dirty.textRatio = true;
1152
1157
  merged.textRatio = value;
1153
1158
  root.style.setProperty('--hj-text-width', `${value}%`);
1159
+ const userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1160
+ if (value === 0) root.style.setProperty('--hj-text-min-width', '0');
1161
+ else if (userMinWidth) root.style.setProperty('--hj-text-min-width', userMinWidth);
1162
+ else root.style.removeProperty('--hj-text-min-width');
1154
1163
  return this;
1155
1164
  },
1156
1165
  setCssVars(vars) {
@@ -2260,6 +2269,8 @@ class ProgressCapsuleController {
2260
2269
  beginDrag(event) {
2261
2270
  if (event.button !== undefined && event.button !== 0) return;
2262
2271
  event.preventDefault();
2272
+ // preventDefault 会吞掉点击聚焦,主动聚焦让键盘方向键立即可用。
2273
+ try { this.root.focus({ preventScroll: true }); } catch { this.root.focus(); }
2263
2274
  this.dragging = true;
2264
2275
  this.pendingPointer = null;
2265
2276
  this._dragRaf = 0;
@@ -2399,8 +2410,10 @@ function createProgressCapsule(container, options = {}) {
2399
2410
  // Vue 的裸布尔属性(<ProgressCapsule disabled />)会传成空字符串,
2400
2411
  // 这里统一按 true 处理。
2401
2412
  const disabled = merged.disabled === true || merged.disabled === '' || merged.disabled === 'true';
2402
- const effectiveDraggable = disabled ? false : merged.draggable !== false;
2403
- const effectiveKeyboard = disabled ? false : merged.keyboard !== false;
2413
+ const readonly = merged.readonly === true || merged.readonly === '' || merged.readonly === 'true';
2414
+ const locked = disabled || readonly;
2415
+ const effectiveDraggable = locked ? false : merged.draggable !== false;
2416
+ const effectiveKeyboard = locked ? false : merged.keyboard !== false;
2404
2417
  const dirty = {
2405
2418
  preset: false,
2406
2419
  colors: false,
@@ -2419,6 +2432,10 @@ function createProgressCapsule(container, options = {}) {
2419
2432
  root.setAttribute('aria-disabled', 'true');
2420
2433
  root.classList.add('is-disabled');
2421
2434
  }
2435
+ if (readonly) {
2436
+ root.setAttribute('aria-readonly', 'true');
2437
+ root.classList.add('is-readonly');
2438
+ }
2422
2439
  root.setAttribute('aria-valuemin', String(merged.min ?? 0));
2423
2440
  root.setAttribute('aria-valuemax', String(merged.max ?? 100));
2424
2441
  root.setAttribute('aria-valuenow', String(preset.initialProgress));
package/dist/index.umd.js CHANGED
@@ -446,6 +446,7 @@
446
446
  draggable: true,
447
447
  keyboard: true,
448
448
  disabled: false,
449
+ readonly: false,
449
450
  valueSuffix: '%',
450
451
  edgeStyle: 'flow',
451
452
  quality: 'auto',
@@ -1224,6 +1225,8 @@
1224
1225
  }
1225
1226
  if (merged.textRatio !== undefined) {
1226
1227
  root.style.setProperty('--hj-text-width', "".concat(merged.textRatio, "%"));
1228
+ var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1229
+ 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');
1227
1230
  }
1228
1231
  renderer.resize();
1229
1232
  };
@@ -1347,6 +1350,8 @@
1347
1350
  dirty.textRatio = true;
1348
1351
  merged.textRatio = value;
1349
1352
  root.style.setProperty('--hj-text-width', "".concat(value, "%"));
1353
+ var userMinWidth = merged.cssVars && merged.cssVars['--hj-text-min-width'];
1354
+ 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');
1350
1355
  return this;
1351
1356
  },
1352
1357
  setCssVars: function setCssVars(vars) {
@@ -2278,6 +2283,14 @@
2278
2283
  value: function beginDrag(event) {
2279
2284
  if (event.button !== undefined && event.button !== 0) return;
2280
2285
  event.preventDefault();
2286
+ // preventDefault 会吞掉点击聚焦,主动聚焦让键盘方向键立即可用。
2287
+ try {
2288
+ this.root.focus({
2289
+ preventScroll: true
2290
+ });
2291
+ } catch (_unused) {
2292
+ this.root.focus();
2293
+ }
2281
2294
  this.dragging = true;
2282
2295
  this.pendingPointer = null;
2283
2296
  this._dragRaf = 0;
@@ -2285,7 +2298,7 @@
2285
2298
  try {
2286
2299
  var _this$root$setPointer, _this$root;
2287
2300
  (_this$root$setPointer = (_this$root = this.root).setPointerCapture) === null || _this$root$setPointer === void 0 || _this$root$setPointer.call(_this$root, event.pointerId);
2288
- } catch (_unused) {}
2301
+ } catch (_unused2) {}
2289
2302
  this.emitter.emit('dragstart', {
2290
2303
  value: this.value
2291
2304
  });
@@ -2325,7 +2338,7 @@
2325
2338
  if ((event === null || event === void 0 ? void 0 : event.pointerId) !== undefined && (_this$root$hasPointer = (_this$root2 = this.root).hasPointerCapture) !== null && _this$root$hasPointer !== void 0 && _this$root$hasPointer.call(_this$root2, event.pointerId)) {
2326
2339
  this.root.releasePointerCapture(event.pointerId);
2327
2340
  }
2328
- } catch (_unused2) {}
2341
+ } catch (_unused3) {}
2329
2342
  this.emitter.emit('dragend', {
2330
2343
  value: this.value
2331
2344
  });
@@ -2446,8 +2459,10 @@
2446
2459
  // Vue 的裸布尔属性(<ProgressCapsule disabled />)会传成空字符串,
2447
2460
  // 这里统一按 true 处理。
2448
2461
  var disabled = merged.disabled === true || merged.disabled === '' || merged.disabled === 'true';
2449
- var effectiveDraggable = disabled ? false : merged.draggable !== false;
2450
- var effectiveKeyboard = disabled ? false : merged.keyboard !== false;
2462
+ var readonly = merged.readonly === true || merged.readonly === '' || merged.readonly === 'true';
2463
+ var locked = disabled || readonly;
2464
+ var effectiveDraggable = locked ? false : merged.draggable !== false;
2465
+ var effectiveKeyboard = locked ? false : merged.keyboard !== false;
2451
2466
  var dirty = {
2452
2467
  preset: false,
2453
2468
  colors: false,
@@ -2465,6 +2480,10 @@
2465
2480
  root.setAttribute('aria-disabled', 'true');
2466
2481
  root.classList.add('is-disabled');
2467
2482
  }
2483
+ if (readonly) {
2484
+ root.setAttribute('aria-readonly', 'true');
2485
+ root.classList.add('is-readonly');
2486
+ }
2468
2487
  root.setAttribute('aria-valuemin', String((_merged$min = merged.min) !== null && _merged$min !== void 0 ? _merged$min : 0));
2469
2488
  root.setAttribute('aria-valuemax', String((_merged$max = merged.max) !== null && _merged$max !== void 0 ? _merged$max : 100));
2470
2489
  root.setAttribute('aria-valuenow', String(preset.initialProgress));