@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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
> **发版规则**:默认每次发布只递增补丁号(0.x.y → 0.x.(y+1),即 +0.01);除非手动明确指定新版本号,否则不升次版本。
|
|
4
4
|
|
|
5
|
+
## 0.2.7 - 2026-08-09
|
|
6
|
+
|
|
7
|
+
- 修复:0.2.6 发布包未包含 mouseColor / showValue 热切换(watch 仍走重建),本轮真正启用 `setMouseColor()` / `setShowValue()`,开关不再重建组件、不丢插槽内容。
|
|
8
|
+
- 组件更名:`CosmicCapsule → dlc-capsule`、`ProgressCapsule → dlc-progress`、`ColorBackground → dlc-color`(旧名保留为兼容别名,标记 deprecated)。
|
|
9
|
+
|
|
10
|
+
## 0.2.6 - 2026-08-09
|
|
11
|
+
|
|
12
|
+
- 修复:Vue wrapper 重建组件时因“插槽容器搬移”导致组件树损坏(子组件丢失、mouseColor 开关无效)的问题;插槽改回搬子节点。
|
|
13
|
+
- 胶囊 `mouseColor` 改为热切换(新增控制器 `setMouseColor()`,不再重建组件);进度条 `showValue` 改为热切换(新增 `setShowValue()`,数字元素始终存在、按需隐藏)。
|
|
14
|
+
|
|
5
15
|
## 0.2.5 - 2026-08-08
|
|
6
16
|
|
|
7
17
|
- 修复:胶囊 `textRatio` 小于 164px(历史 `--hj-copy-min-width` 默认)时文字区不跟随缩小的 bug;现在 `textRatio` 是文字区宽度的唯一权威值,0~100 全范围生效。
|
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ background.pause();
|
|
|
109
109
|
|
|
110
110
|
```vue
|
|
111
111
|
<script setup>
|
|
112
|
-
import {
|
|
112
|
+
import { DlcCapsule, DlcProgress, DlcColor } from '@5even7/dlc-ui/vue3';
|
|
113
113
|
import '@5even7/dlc-ui/style.css';
|
|
114
114
|
|
|
115
115
|
function onProgressChange({ value }) {
|
|
@@ -118,35 +118,35 @@ function onProgressChange({ value }) {
|
|
|
118
118
|
</script>
|
|
119
119
|
|
|
120
120
|
<template>
|
|
121
|
-
<
|
|
121
|
+
<dlc-capsule preset="沧溟" width="100%" height="160" :text-ratio="45" @click="...">
|
|
122
122
|
<span class="cap-code">NC-02</span>
|
|
123
123
|
<span class="cap-name">沧溟</span>
|
|
124
124
|
<template #color><span class="cap-chip">DLC</span></template>
|
|
125
|
-
</
|
|
125
|
+
</dlc-capsule>
|
|
126
126
|
|
|
127
|
-
<
|
|
127
|
+
<dlc-progress preset="汐潮" :width="454" :height="104" @change="onProgressChange">
|
|
128
128
|
<span class="prog-name">画境观屿</span>
|
|
129
|
-
</
|
|
129
|
+
</dlc-progress>
|
|
130
130
|
|
|
131
|
-
<
|
|
131
|
+
<dlc-color preset="沧溟" style="height: 200px">
|
|
132
132
|
这段内容显示在星云背景上方
|
|
133
|
-
</
|
|
133
|
+
</dlc-color>
|
|
134
134
|
</template>
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
## Vue2
|
|
138
138
|
|
|
139
139
|
```js
|
|
140
|
-
import {
|
|
140
|
+
import { DlcCapsule, DlcProgress } from '@5even7/dlc-ui/vue2';
|
|
141
141
|
import '@5even7/dlc-ui/style.css';
|
|
142
142
|
|
|
143
143
|
export default {
|
|
144
|
-
components: {
|
|
144
|
+
components: { DlcCapsule, DlcProgress },
|
|
145
145
|
template: `
|
|
146
|
-
<
|
|
146
|
+
<dlc-progress preset="汐潮" :width="454" :height="104" @change="onChange">
|
|
147
147
|
<span class="prog-name">画境观屿</span>
|
|
148
148
|
<template v-slot:color><span>自定义颜色区内容</span></template>
|
|
149
|
-
</
|
|
149
|
+
</dlc-progress>
|
|
150
150
|
`
|
|
151
151
|
};
|
|
152
152
|
```
|
|
@@ -161,7 +161,7 @@ export default {
|
|
|
161
161
|
|
|
162
162
|
插槽内容属性(H5/工厂):`text`、`colorContent`,支持 HTML 字符串或 DOM 节点(数组);Vue 组件请用默认插槽 / `#color` 插槽。**注意:字符串走 innerHTML,不要传入不可信/用户直接输入的内容(XSS 风险)。**
|
|
163
163
|
|
|
164
|
-
dlc-color 背景层(`createColorBackground(host, options)`):`preset`、`colors`、`seed`、`speed`、`quality`、`renderer`、`mouseColor`、`respectReducedMotion`、`opacity`(0~1)、`fallbackColor`(预置底色 / 十六进制色 / false)。控制器支持 `setPreset / setColors / setSeed / setSpeed / setQuality / setOpacity / setFallbackColor / setMouseColor / randomize / pause / resume / dispose` 和 `ready / presetchange / error` 事件。Vue 里可用官方组件 `
|
|
164
|
+
dlc-color 背景层(`createColorBackground(host, options)`):`preset`、`colors`、`seed`、`speed`、`quality`、`renderer`、`mouseColor`、`respectReducedMotion`、`opacity`(0~1)、`fallbackColor`(预置底色 / 十六进制色 / false)。控制器支持 `setPreset / setColors / setSeed / setSpeed / setQuality / setOpacity / setFallbackColor / setMouseColor / randomize / pause / resume / dispose` 和 `ready / presetchange / error` 事件。Vue 里可用官方组件 `dlc-color`(从 `@5even7/dlc-ui/vue2` 或 `/vue3` 导入),它的默认插槽内容会显示在背景层上方。
|
|
165
165
|
|
|
166
166
|
胶囊控制器额外支持 `setSeed(seed)` / `setSpeed(speed)` / `setText(content)` / `setColorContent(content)` / `setTextRatio(ratio)` / `setCssVars(vars)` / `setLabel(label)` 热更新;进度控制器额外支持 `setEdgeStyle('flow' | 'tide')` / `setValueSuffix(suffix)` 和同样的插槽热更新方法。`setPreset` 只接受文学名称字符串(如 `'汐潮'`)。Vue 组件实例也暴露 `setText` / `setColorContent` / `setTextRatio` / `setCssVars` / `setLabel`(进度另有 `setValueSuffix`),与 H5 控制器对称。
|
|
167
167
|
|
|
@@ -221,10 +221,7 @@ createProgressCapsule(el, {
|
|
|
221
221
|
| `--hj-font` / `--hj-mono` | 字体令牌(可被插槽内容引用) | Inter / 等宽栈 |
|
|
222
222
|
| `--hj-shadow` | 根节点阴影 | 柔和阴影 |
|
|
223
223
|
| `--hj-value-right` | 进度数字右侧距离(仅进度条) | `30px` |
|
|
224
|
-
| `--dlc-color-
|
|
225
|
-
| `--dlc-color-bg` | 色层兜底背景(dlc-color) | 预置底色 |
|
|
226
|
-
| `--dlc-color-layer-z` | 色层 z-index(dlc-color) | `-1` |
|
|
227
|
-
| `--dlc-color-content-z` | 宿主内容参考 z-index(dlc-color,由用户使用) | `1` |
|
|
224
|
+
| `--dlc-color-layer-z` | 色层 z-index(dlc-color,宿主 CSS 可覆盖) | `-1` |
|
|
228
225
|
|
|
229
226
|
兼容别名(deprecated,只兜底):`--hj-copy-width`、`--hj-copy-min-width`、`--hj-copy-pad-x`、`--hj-copy-left`、`--hj-copy-max-width`、`--hj-progress-copy-pad`、`--hj-progress-copy-bg`。
|
|
230
227
|
|
package/dist/capsule.cjs
CHANGED
|
@@ -1328,6 +1328,11 @@ function createCapsule(container) {
|
|
|
1328
1328
|
updateAria();
|
|
1329
1329
|
return this;
|
|
1330
1330
|
},
|
|
1331
|
+
setMouseColor: function setMouseColor(value) {
|
|
1332
|
+
merged.mouseColor = value !== false;
|
|
1333
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1334
|
+
return this;
|
|
1335
|
+
},
|
|
1331
1336
|
setSize: function setSize(width, height) {
|
|
1332
1337
|
if (width !== undefined) {
|
|
1333
1338
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
package/dist/capsule.mjs
CHANGED
|
@@ -1090,6 +1090,11 @@ function createCapsule(container, options = {}) {
|
|
|
1090
1090
|
updateAria();
|
|
1091
1091
|
return this;
|
|
1092
1092
|
},
|
|
1093
|
+
setMouseColor(value) {
|
|
1094
|
+
merged.mouseColor = value !== false;
|
|
1095
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1096
|
+
return this;
|
|
1097
|
+
},
|
|
1093
1098
|
setSize(width, height) {
|
|
1094
1099
|
if (width !== undefined) {
|
|
1095
1100
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
package/dist/index.cjs
CHANGED
|
@@ -1374,6 +1374,11 @@ function createCapsule(container) {
|
|
|
1374
1374
|
updateAria();
|
|
1375
1375
|
return this;
|
|
1376
1376
|
},
|
|
1377
|
+
setMouseColor: function setMouseColor(value) {
|
|
1378
|
+
merged.mouseColor = value !== false;
|
|
1379
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1380
|
+
return this;
|
|
1381
|
+
},
|
|
1377
1382
|
setSize: function setSize(width, height) {
|
|
1378
1383
|
if (width !== undefined) {
|
|
1379
1384
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
|
@@ -2006,6 +2011,12 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
|
|
|
2006
2011
|
this.root.setAttribute('aria-valuetext', "".concat(rounded).concat(this.valueSuffix));
|
|
2007
2012
|
return this;
|
|
2008
2013
|
}
|
|
2014
|
+
}, {
|
|
2015
|
+
key: "setShowValue",
|
|
2016
|
+
value: function setShowValue(show) {
|
|
2017
|
+
if (this.valueElement) this.valueElement.hidden = show === false;
|
|
2018
|
+
return this;
|
|
2019
|
+
}
|
|
2009
2020
|
}, {
|
|
2010
2021
|
key: "resizeCanvas",
|
|
2011
2022
|
value: function resizeCanvas() {
|
|
@@ -2530,15 +2541,14 @@ function createProgressCapsule(container) {
|
|
|
2530
2541
|
visualLayer.className = 'hj-progress-visual';
|
|
2531
2542
|
fillContent(textLayer, options.text);
|
|
2532
2543
|
fillContent(visualLayer, options.colorContent);
|
|
2533
|
-
var valueElement =
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
}
|
|
2544
|
+
var valueElement = document.createElement('div');
|
|
2545
|
+
valueElement.className = 'hj-progress-value';
|
|
2546
|
+
valueElement.setAttribute('aria-hidden', 'true');
|
|
2547
|
+
valueElement.hidden = merged.showValue === false;
|
|
2538
2548
|
root.appendChild(canvas);
|
|
2539
2549
|
root.appendChild(textLayer);
|
|
2540
2550
|
root.appendChild(visualLayer);
|
|
2541
|
-
|
|
2551
|
+
root.appendChild(valueElement);
|
|
2542
2552
|
container.appendChild(root);
|
|
2543
2553
|
var emitter = createEmitter();
|
|
2544
2554
|
var paused = merged.respectReducedMotion && prefersReducedMotion$1();
|
|
@@ -2711,6 +2721,10 @@ function createProgressCapsule(container) {
|
|
|
2711
2721
|
controller.setValueSuffix(suffix);
|
|
2712
2722
|
return this;
|
|
2713
2723
|
},
|
|
2724
|
+
setShowValue: function setShowValue(show) {
|
|
2725
|
+
controller.setShowValue(show);
|
|
2726
|
+
return this;
|
|
2727
|
+
},
|
|
2714
2728
|
setColors: function setColors(colors) {
|
|
2715
2729
|
var next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
|
|
2716
2730
|
if (next.length !== 4 || next.some(function (color) {
|
package/dist/index.mjs
CHANGED
|
@@ -1181,6 +1181,11 @@ function createCapsule(container, options = {}) {
|
|
|
1181
1181
|
updateAria();
|
|
1182
1182
|
return this;
|
|
1183
1183
|
},
|
|
1184
|
+
setMouseColor(value) {
|
|
1185
|
+
merged.mouseColor = value !== false;
|
|
1186
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1187
|
+
return this;
|
|
1188
|
+
},
|
|
1184
1189
|
setSize(width, height) {
|
|
1185
1190
|
if (width !== undefined) {
|
|
1186
1191
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
|
@@ -1980,6 +1985,11 @@ class ProgressCapsuleController {
|
|
|
1980
1985
|
this.root.setAttribute('aria-valuetext', `${rounded}${this.valueSuffix}`);
|
|
1981
1986
|
return this;
|
|
1982
1987
|
}
|
|
1988
|
+
|
|
1989
|
+
setShowValue(show) {
|
|
1990
|
+
if (this.valueElement) this.valueElement.hidden = show === false;
|
|
1991
|
+
return this;
|
|
1992
|
+
}
|
|
1983
1993
|
|
|
1984
1994
|
resizeCanvas() {
|
|
1985
1995
|
const bounds = this.root.getBoundingClientRect();
|
|
@@ -2474,16 +2484,15 @@ function createProgressCapsule(container, options = {}) {
|
|
|
2474
2484
|
fillContent(textLayer, options.text);
|
|
2475
2485
|
fillContent(visualLayer, options.colorContent);
|
|
2476
2486
|
|
|
2477
|
-
const valueElement =
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
}
|
|
2487
|
+
const valueElement = document.createElement('div');
|
|
2488
|
+
valueElement.className = 'hj-progress-value';
|
|
2489
|
+
valueElement.setAttribute('aria-hidden', 'true');
|
|
2490
|
+
valueElement.hidden = merged.showValue === false;
|
|
2482
2491
|
|
|
2483
2492
|
root.appendChild(canvas);
|
|
2484
2493
|
root.appendChild(textLayer);
|
|
2485
2494
|
root.appendChild(visualLayer);
|
|
2486
|
-
|
|
2495
|
+
root.appendChild(valueElement);
|
|
2487
2496
|
container.appendChild(root);
|
|
2488
2497
|
|
|
2489
2498
|
const emitter = createEmitter();
|
|
@@ -2639,6 +2648,10 @@ function createProgressCapsule(container, options = {}) {
|
|
|
2639
2648
|
controller.setValueSuffix(suffix);
|
|
2640
2649
|
return this;
|
|
2641
2650
|
},
|
|
2651
|
+
setShowValue(show) {
|
|
2652
|
+
controller.setShowValue(show);
|
|
2653
|
+
return this;
|
|
2654
|
+
},
|
|
2642
2655
|
setColors(colors) {
|
|
2643
2656
|
const next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
|
|
2644
2657
|
if (next.length !== 4 || next.some((color) => !color)) return this;
|
package/dist/index.umd.js
CHANGED
|
@@ -1378,6 +1378,11 @@
|
|
|
1378
1378
|
updateAria();
|
|
1379
1379
|
return this;
|
|
1380
1380
|
},
|
|
1381
|
+
setMouseColor: function setMouseColor(value) {
|
|
1382
|
+
merged.mouseColor = value !== false;
|
|
1383
|
+
if (typeof renderer.setMouseColor === 'function') renderer.setMouseColor(merged.mouseColor);
|
|
1384
|
+
return this;
|
|
1385
|
+
},
|
|
1381
1386
|
setSize: function setSize(width, height) {
|
|
1382
1387
|
if (width !== undefined) {
|
|
1383
1388
|
parseSize(width); // 非法尺寸直接抛错前先校验,避免污染内部状态
|
|
@@ -2010,6 +2015,12 @@
|
|
|
2010
2015
|
this.root.setAttribute('aria-valuetext', "".concat(rounded).concat(this.valueSuffix));
|
|
2011
2016
|
return this;
|
|
2012
2017
|
}
|
|
2018
|
+
}, {
|
|
2019
|
+
key: "setShowValue",
|
|
2020
|
+
value: function setShowValue(show) {
|
|
2021
|
+
if (this.valueElement) this.valueElement.hidden = show === false;
|
|
2022
|
+
return this;
|
|
2023
|
+
}
|
|
2013
2024
|
}, {
|
|
2014
2025
|
key: "resizeCanvas",
|
|
2015
2026
|
value: function resizeCanvas() {
|
|
@@ -2534,15 +2545,14 @@
|
|
|
2534
2545
|
visualLayer.className = 'hj-progress-visual';
|
|
2535
2546
|
fillContent(textLayer, options.text);
|
|
2536
2547
|
fillContent(visualLayer, options.colorContent);
|
|
2537
|
-
var valueElement =
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
}
|
|
2548
|
+
var valueElement = document.createElement('div');
|
|
2549
|
+
valueElement.className = 'hj-progress-value';
|
|
2550
|
+
valueElement.setAttribute('aria-hidden', 'true');
|
|
2551
|
+
valueElement.hidden = merged.showValue === false;
|
|
2542
2552
|
root.appendChild(canvas);
|
|
2543
2553
|
root.appendChild(textLayer);
|
|
2544
2554
|
root.appendChild(visualLayer);
|
|
2545
|
-
|
|
2555
|
+
root.appendChild(valueElement);
|
|
2546
2556
|
container.appendChild(root);
|
|
2547
2557
|
var emitter = createEmitter();
|
|
2548
2558
|
var paused = merged.respectReducedMotion && prefersReducedMotion$1();
|
|
@@ -2715,6 +2725,10 @@
|
|
|
2715
2725
|
controller.setValueSuffix(suffix);
|
|
2716
2726
|
return this;
|
|
2717
2727
|
},
|
|
2728
|
+
setShowValue: function setShowValue(show) {
|
|
2729
|
+
controller.setShowValue(show);
|
|
2730
|
+
return this;
|
|
2731
|
+
},
|
|
2718
2732
|
setColors: function setColors(colors) {
|
|
2719
2733
|
var next = Array.isArray(colors) ? colors.map(normalizeColor) : [];
|
|
2720
2734
|
if (next.length !== 4 || next.some(function (color) {
|