@5even7/dlc-ui 0.2.1 → 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 +38 -27
- package/README.md +277 -277
- package/dist/capsule.cjs +4 -0
- package/dist/capsule.mjs +8 -0
- package/dist/index.cjs +24 -8
- package/dist/index.mjs +20 -3
- package/dist/index.umd.js +24 -8
- package/dist/index.umd.min.js +1 -1
- package/dist/progress.cjs +20 -8
- package/dist/progress.mjs +12 -3
- package/dist/vue2.cjs +38 -20
- package/dist/vue2.mjs +32 -10
- package/dist/vue3.cjs +38 -20
- package/dist/vue3.mjs +32 -10
- package/package.json +1 -1
- package/styles/base.css +12 -4
- package/styles/progress.css +4 -0
- package/types/index.d.ts +2 -1
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
|
@@ -148,9 +148,6 @@ function _objectSpread2(e) {
|
|
|
148
148
|
}
|
|
149
149
|
return e;
|
|
150
150
|
}
|
|
151
|
-
function _readOnlyError(r) {
|
|
152
|
-
throw new TypeError('"' + r + '" is read-only');
|
|
153
|
-
}
|
|
154
151
|
function _slicedToArray(r, e) {
|
|
155
152
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
156
153
|
}
|
|
@@ -445,6 +442,7 @@ var DEFAULTS = {
|
|
|
445
442
|
draggable: true,
|
|
446
443
|
keyboard: true,
|
|
447
444
|
disabled: false,
|
|
445
|
+
readonly: false,
|
|
448
446
|
valueSuffix: '%',
|
|
449
447
|
edgeStyle: 'flow',
|
|
450
448
|
quality: 'auto',
|
|
@@ -1223,6 +1221,8 @@ function createCapsule(container) {
|
|
|
1223
1221
|
}
|
|
1224
1222
|
if (merged.textRatio !== undefined) {
|
|
1225
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');
|
|
1226
1226
|
}
|
|
1227
1227
|
renderer.resize();
|
|
1228
1228
|
};
|
|
@@ -1346,6 +1346,8 @@ function createCapsule(container) {
|
|
|
1346
1346
|
dirty.textRatio = true;
|
|
1347
1347
|
merged.textRatio = value;
|
|
1348
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');
|
|
1349
1351
|
return this;
|
|
1350
1352
|
},
|
|
1351
1353
|
setCssVars: function setCssVars(vars) {
|
|
@@ -2277,6 +2279,14 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
|
|
|
2277
2279
|
value: function beginDrag(event) {
|
|
2278
2280
|
if (event.button !== undefined && event.button !== 0) return;
|
|
2279
2281
|
event.preventDefault();
|
|
2282
|
+
// preventDefault 会吞掉点击聚焦,主动聚焦让键盘方向键立即可用。
|
|
2283
|
+
try {
|
|
2284
|
+
this.root.focus({
|
|
2285
|
+
preventScroll: true
|
|
2286
|
+
});
|
|
2287
|
+
} catch (_unused) {
|
|
2288
|
+
this.root.focus();
|
|
2289
|
+
}
|
|
2280
2290
|
this.dragging = true;
|
|
2281
2291
|
this.pendingPointer = null;
|
|
2282
2292
|
this._dragRaf = 0;
|
|
@@ -2284,7 +2294,7 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
|
|
|
2284
2294
|
try {
|
|
2285
2295
|
var _this$root$setPointer, _this$root;
|
|
2286
2296
|
(_this$root$setPointer = (_this$root = this.root).setPointerCapture) === null || _this$root$setPointer === void 0 || _this$root$setPointer.call(_this$root, event.pointerId);
|
|
2287
|
-
} catch (
|
|
2297
|
+
} catch (_unused2) {}
|
|
2288
2298
|
this.emitter.emit('dragstart', {
|
|
2289
2299
|
value: this.value
|
|
2290
2300
|
});
|
|
@@ -2324,7 +2334,7 @@ var ProgressCapsuleController = /*#__PURE__*/function () {
|
|
|
2324
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)) {
|
|
2325
2335
|
this.root.releasePointerCapture(event.pointerId);
|
|
2326
2336
|
}
|
|
2327
|
-
} catch (
|
|
2337
|
+
} catch (_unused3) {}
|
|
2328
2338
|
this.emitter.emit('dragend', {
|
|
2329
2339
|
value: this.value
|
|
2330
2340
|
});
|
|
@@ -2445,8 +2455,10 @@ function createProgressCapsule(container) {
|
|
|
2445
2455
|
// Vue 的裸布尔属性(<ProgressCapsule disabled />)会传成空字符串,
|
|
2446
2456
|
// 这里统一按 true 处理。
|
|
2447
2457
|
var disabled = merged.disabled === true || merged.disabled === '' || merged.disabled === 'true';
|
|
2448
|
-
var
|
|
2449
|
-
var
|
|
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;
|
|
2450
2462
|
var dirty = {
|
|
2451
2463
|
preset: false,
|
|
2452
2464
|
colors: false,
|
|
@@ -2464,6 +2476,10 @@ function createProgressCapsule(container) {
|
|
|
2464
2476
|
root.setAttribute('aria-disabled', 'true');
|
|
2465
2477
|
root.classList.add('is-disabled');
|
|
2466
2478
|
}
|
|
2479
|
+
if (readonly) {
|
|
2480
|
+
root.setAttribute('aria-readonly', 'true');
|
|
2481
|
+
root.classList.add('is-readonly');
|
|
2482
|
+
}
|
|
2467
2483
|
root.setAttribute('aria-valuemin', String((_merged$min = merged.min) !== null && _merged$min !== void 0 ? _merged$min : 0));
|
|
2468
2484
|
root.setAttribute('aria-valuemax', String((_merged$max = merged.max) !== null && _merged$max !== void 0 ? _merged$max : 100));
|
|
2469
2485
|
root.setAttribute('aria-valuenow', String(preset.initialProgress));
|
|
@@ -2683,7 +2699,7 @@ function createProgressCapsule(container) {
|
|
|
2683
2699
|
return this;
|
|
2684
2700
|
},
|
|
2685
2701
|
setLabel: function setLabel(label) {
|
|
2686
|
-
|
|
2702
|
+
customLabel = typeof label === 'string' && label ? label : null;
|
|
2687
2703
|
updateAria();
|
|
2688
2704
|
return this;
|
|
2689
2705
|
},
|
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;
|
|
@@ -2395,12 +2406,14 @@ function createProgressCapsule(container, options = {}) {
|
|
|
2395
2406
|
if (normalizedColors.every(Boolean)) preset.colors = normalizedColors;
|
|
2396
2407
|
preset.edgeStyle = merged.edgeStyle;
|
|
2397
2408
|
const copy = COPY;
|
|
2398
|
-
|
|
2409
|
+
let customLabel = typeof options.label === 'string' && options.label ? options.label : null;
|
|
2399
2410
|
// Vue 的裸布尔属性(<ProgressCapsule disabled />)会传成空字符串,
|
|
2400
2411
|
// 这里统一按 true 处理。
|
|
2401
2412
|
const disabled = merged.disabled === true || merged.disabled === '' || merged.disabled === 'true';
|
|
2402
|
-
const
|
|
2403
|
-
const
|
|
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
|
@@ -152,9 +152,6 @@
|
|
|
152
152
|
}
|
|
153
153
|
return e;
|
|
154
154
|
}
|
|
155
|
-
function _readOnlyError(r) {
|
|
156
|
-
throw new TypeError('"' + r + '" is read-only');
|
|
157
|
-
}
|
|
158
155
|
function _slicedToArray(r, e) {
|
|
159
156
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
160
157
|
}
|
|
@@ -449,6 +446,7 @@
|
|
|
449
446
|
draggable: true,
|
|
450
447
|
keyboard: true,
|
|
451
448
|
disabled: false,
|
|
449
|
+
readonly: false,
|
|
452
450
|
valueSuffix: '%',
|
|
453
451
|
edgeStyle: 'flow',
|
|
454
452
|
quality: 'auto',
|
|
@@ -1227,6 +1225,8 @@
|
|
|
1227
1225
|
}
|
|
1228
1226
|
if (merged.textRatio !== undefined) {
|
|
1229
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');
|
|
1230
1230
|
}
|
|
1231
1231
|
renderer.resize();
|
|
1232
1232
|
};
|
|
@@ -1350,6 +1350,8 @@
|
|
|
1350
1350
|
dirty.textRatio = true;
|
|
1351
1351
|
merged.textRatio = value;
|
|
1352
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');
|
|
1353
1355
|
return this;
|
|
1354
1356
|
},
|
|
1355
1357
|
setCssVars: function setCssVars(vars) {
|
|
@@ -2281,6 +2283,14 @@
|
|
|
2281
2283
|
value: function beginDrag(event) {
|
|
2282
2284
|
if (event.button !== undefined && event.button !== 0) return;
|
|
2283
2285
|
event.preventDefault();
|
|
2286
|
+
// preventDefault 会吞掉点击聚焦,主动聚焦让键盘方向键立即可用。
|
|
2287
|
+
try {
|
|
2288
|
+
this.root.focus({
|
|
2289
|
+
preventScroll: true
|
|
2290
|
+
});
|
|
2291
|
+
} catch (_unused) {
|
|
2292
|
+
this.root.focus();
|
|
2293
|
+
}
|
|
2284
2294
|
this.dragging = true;
|
|
2285
2295
|
this.pendingPointer = null;
|
|
2286
2296
|
this._dragRaf = 0;
|
|
@@ -2288,7 +2298,7 @@
|
|
|
2288
2298
|
try {
|
|
2289
2299
|
var _this$root$setPointer, _this$root;
|
|
2290
2300
|
(_this$root$setPointer = (_this$root = this.root).setPointerCapture) === null || _this$root$setPointer === void 0 || _this$root$setPointer.call(_this$root, event.pointerId);
|
|
2291
|
-
} catch (
|
|
2301
|
+
} catch (_unused2) {}
|
|
2292
2302
|
this.emitter.emit('dragstart', {
|
|
2293
2303
|
value: this.value
|
|
2294
2304
|
});
|
|
@@ -2328,7 +2338,7 @@
|
|
|
2328
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)) {
|
|
2329
2339
|
this.root.releasePointerCapture(event.pointerId);
|
|
2330
2340
|
}
|
|
2331
|
-
} catch (
|
|
2341
|
+
} catch (_unused3) {}
|
|
2332
2342
|
this.emitter.emit('dragend', {
|
|
2333
2343
|
value: this.value
|
|
2334
2344
|
});
|
|
@@ -2449,8 +2459,10 @@
|
|
|
2449
2459
|
// Vue 的裸布尔属性(<ProgressCapsule disabled />)会传成空字符串,
|
|
2450
2460
|
// 这里统一按 true 处理。
|
|
2451
2461
|
var disabled = merged.disabled === true || merged.disabled === '' || merged.disabled === 'true';
|
|
2452
|
-
var
|
|
2453
|
-
var
|
|
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;
|
|
2454
2466
|
var dirty = {
|
|
2455
2467
|
preset: false,
|
|
2456
2468
|
colors: false,
|
|
@@ -2468,6 +2480,10 @@
|
|
|
2468
2480
|
root.setAttribute('aria-disabled', 'true');
|
|
2469
2481
|
root.classList.add('is-disabled');
|
|
2470
2482
|
}
|
|
2483
|
+
if (readonly) {
|
|
2484
|
+
root.setAttribute('aria-readonly', 'true');
|
|
2485
|
+
root.classList.add('is-readonly');
|
|
2486
|
+
}
|
|
2471
2487
|
root.setAttribute('aria-valuemin', String((_merged$min = merged.min) !== null && _merged$min !== void 0 ? _merged$min : 0));
|
|
2472
2488
|
root.setAttribute('aria-valuemax', String((_merged$max = merged.max) !== null && _merged$max !== void 0 ? _merged$max : 100));
|
|
2473
2489
|
root.setAttribute('aria-valuenow', String(preset.initialProgress));
|
|
@@ -2687,7 +2703,7 @@
|
|
|
2687
2703
|
return this;
|
|
2688
2704
|
},
|
|
2689
2705
|
setLabel: function setLabel(label) {
|
|
2690
|
-
|
|
2706
|
+
customLabel = typeof label === 'string' && label ? label : null;
|
|
2691
2707
|
updateAria();
|
|
2692
2708
|
return this;
|
|
2693
2709
|
},
|