tiny-essentials 1.21.4 → 1.21.5
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/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/libs/TinyHtml.cjs +176 -0
- package/dist/v1/libs/TinyHtml.d.mts +98 -0
- package/dist/v1/libs/TinyHtml.mjs +164 -0
- package/docs/v1/libs/TinyHtml.md +83 -0
- package/package.json +1 -1
|
@@ -3873,6 +3873,182 @@ class TinyHtml {
|
|
|
3873
3873
|
return TinyHtml.id(this);
|
|
3874
3874
|
}
|
|
3875
3875
|
|
|
3876
|
+
/**
|
|
3877
|
+
* Returns the BigInt content of the element.
|
|
3878
|
+
* @param {TinyElement} el - Target element.
|
|
3879
|
+
* @returns {bigint|null} The BigInt content or null if none.
|
|
3880
|
+
*/
|
|
3881
|
+
static toBigInt(el) {
|
|
3882
|
+
const elem = TinyHtml._preElem(el, 'toBigInt');
|
|
3883
|
+
const txt = elem.textContent?.trim();
|
|
3884
|
+
let value = null;
|
|
3885
|
+
try {
|
|
3886
|
+
value = BigInt(txt ?? '');
|
|
3887
|
+
} catch {
|
|
3888
|
+
value = null;
|
|
3889
|
+
}
|
|
3890
|
+
return value;
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
/**
|
|
3894
|
+
* Returns the BigInt content of the element.
|
|
3895
|
+
* @returns {bigint|null}
|
|
3896
|
+
*/
|
|
3897
|
+
toBigInt() {
|
|
3898
|
+
return TinyHtml.toBigInt(this);
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
/**
|
|
3902
|
+
* Set BigInt content of elements.
|
|
3903
|
+
* @param {TinyElement|TinyElement[]} el
|
|
3904
|
+
* @param {bigint} value
|
|
3905
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3906
|
+
*/
|
|
3907
|
+
static setBigInt(el, value) {
|
|
3908
|
+
if (typeof value !== 'bigint') throw new Error('Value is not a valid BigInt.');
|
|
3909
|
+
TinyHtml._preElems(el, 'setBigInt').forEach((el) => (el.textContent = value.toString()));
|
|
3910
|
+
return el;
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
/**
|
|
3914
|
+
* Set BigInt content of the element.
|
|
3915
|
+
* @param {bigint} value
|
|
3916
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3917
|
+
*/
|
|
3918
|
+
setBigInt(value) {
|
|
3919
|
+
return TinyHtml.setBigInt(this, value);
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
/**
|
|
3923
|
+
* Returns the Date content of the element.
|
|
3924
|
+
* @param {TinyElement} el - Target element.
|
|
3925
|
+
* @returns {Date|null} The Date content or null if invalid.
|
|
3926
|
+
*/
|
|
3927
|
+
static toDate(el) {
|
|
3928
|
+
const elem = TinyHtml._preElem(el, 'toDate');
|
|
3929
|
+
const txt = elem.textContent?.trim();
|
|
3930
|
+
if (!txt) return null;
|
|
3931
|
+
const d = new Date(txt);
|
|
3932
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
/**
|
|
3936
|
+
* Returns the Date content of the element.
|
|
3937
|
+
* @returns {Date|null}
|
|
3938
|
+
*/
|
|
3939
|
+
toDate() {
|
|
3940
|
+
return TinyHtml.toDate(this);
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
/**
|
|
3944
|
+
* Set Date content of elements.
|
|
3945
|
+
* @param {TinyElement|TinyElement[]} el
|
|
3946
|
+
* @param {Date} value
|
|
3947
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3948
|
+
*/
|
|
3949
|
+
static setDate(el, value) {
|
|
3950
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime()))
|
|
3951
|
+
throw new Error('Value is not a valid Date.');
|
|
3952
|
+
TinyHtml._preElems(el, 'setDate').forEach((el) => (el.textContent = value.toISOString()));
|
|
3953
|
+
return el;
|
|
3954
|
+
}
|
|
3955
|
+
|
|
3956
|
+
/**
|
|
3957
|
+
* Set Date content of the element.
|
|
3958
|
+
* @param {Date} value
|
|
3959
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3960
|
+
*/
|
|
3961
|
+
setDate(value) {
|
|
3962
|
+
return TinyHtml.setDate(this, value);
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
/**
|
|
3966
|
+
* Returns the JSON content of the element.
|
|
3967
|
+
* @param {TinyElement} el - Target element.
|
|
3968
|
+
* @returns {any|null} The parsed JSON content or null if invalid.
|
|
3969
|
+
*/
|
|
3970
|
+
static toJson(el) {
|
|
3971
|
+
const elem = TinyHtml._preElem(el, 'toJson');
|
|
3972
|
+
const txt = elem.textContent?.trim();
|
|
3973
|
+
if (!txt) return null;
|
|
3974
|
+
try {
|
|
3975
|
+
return JSON.parse(txt);
|
|
3976
|
+
} catch {
|
|
3977
|
+
return null;
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
/**
|
|
3982
|
+
* Returns the JSON content of the element.
|
|
3983
|
+
* @returns {any|null}
|
|
3984
|
+
*/
|
|
3985
|
+
toJson() {
|
|
3986
|
+
return TinyHtml.toJson(this);
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
/**
|
|
3990
|
+
* Set JSON content of elements.
|
|
3991
|
+
* @param {TinyElement|TinyElement[]} el
|
|
3992
|
+
* @param {any} value
|
|
3993
|
+
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3994
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3995
|
+
*/
|
|
3996
|
+
static setJson(el, value, space) {
|
|
3997
|
+
TinyHtml._preElems(el, 'setJson').forEach(
|
|
3998
|
+
(el) => (el.textContent = JSON.stringify(value, null, space)),
|
|
3999
|
+
);
|
|
4000
|
+
return el;
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
/**
|
|
4004
|
+
* Set JSON content of the element.
|
|
4005
|
+
* @param {any} value
|
|
4006
|
+
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
4007
|
+
* @returns {TinyElement|TinyElement[]}
|
|
4008
|
+
*/
|
|
4009
|
+
setJson(value, space) {
|
|
4010
|
+
return TinyHtml.setJson(this, value, space);
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
/**
|
|
4014
|
+
* Returns the number content of the element.
|
|
4015
|
+
* @param {TinyElement} el - Target element.
|
|
4016
|
+
* @returns {number|null} The text content or null if none.
|
|
4017
|
+
*/
|
|
4018
|
+
static toNumber(el) {
|
|
4019
|
+
const elem = TinyHtml._preElem(el, 'toNumber');
|
|
4020
|
+
return typeof elem.textContent === 'string' ? parseFloat(elem.textContent.trim()) : null;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
/**
|
|
4024
|
+
* Returns the number content of the element.
|
|
4025
|
+
* @returns {number|null} The text content or null if none.
|
|
4026
|
+
*/
|
|
4027
|
+
toNumber() {
|
|
4028
|
+
return TinyHtml.toNumber(this);
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
/**
|
|
4032
|
+
* Set number content of elements.
|
|
4033
|
+
* @param {TinyElement|TinyElement[]} el
|
|
4034
|
+
* @param {number} value
|
|
4035
|
+
* @returns {TinyElement|TinyElement[]}
|
|
4036
|
+
*/
|
|
4037
|
+
static setNumber(el, value) {
|
|
4038
|
+
if (typeof value !== 'number') throw new Error('Value is not a valid number.');
|
|
4039
|
+
TinyHtml._preElems(el, 'setNumber').forEach((el) => (el.textContent = value.toString()));
|
|
4040
|
+
return el;
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
/**
|
|
4044
|
+
* Set number content of the element.
|
|
4045
|
+
* @param {number} value
|
|
4046
|
+
* @returns {TinyElement|TinyElement[]}
|
|
4047
|
+
*/
|
|
4048
|
+
setNumber(value) {
|
|
4049
|
+
return TinyHtml.setNumber(this, value);
|
|
4050
|
+
}
|
|
4051
|
+
|
|
3876
4052
|
/**
|
|
3877
4053
|
* Returns the text content of the element.
|
|
3878
4054
|
* @param {TinyElement} el - Target element.
|
|
@@ -1481,6 +1481,59 @@ declare class TinyHtml {
|
|
|
1481
1481
|
* @returns {string} The element's ID.
|
|
1482
1482
|
*/
|
|
1483
1483
|
static id(el: TinyElement): string;
|
|
1484
|
+
/**
|
|
1485
|
+
* Returns the BigInt content of the element.
|
|
1486
|
+
* @param {TinyElement} el - Target element.
|
|
1487
|
+
* @returns {bigint|null} The BigInt content or null if none.
|
|
1488
|
+
*/
|
|
1489
|
+
static toBigInt(el: TinyElement): bigint | null;
|
|
1490
|
+
/**
|
|
1491
|
+
* Set BigInt content of elements.
|
|
1492
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1493
|
+
* @param {bigint} value
|
|
1494
|
+
* @returns {TinyElement|TinyElement[]}
|
|
1495
|
+
*/
|
|
1496
|
+
static setBigInt(el: TinyElement | TinyElement[], value: bigint): TinyElement | TinyElement[];
|
|
1497
|
+
/**
|
|
1498
|
+
* Returns the Date content of the element.
|
|
1499
|
+
* @param {TinyElement} el - Target element.
|
|
1500
|
+
* @returns {Date|null} The Date content or null if invalid.
|
|
1501
|
+
*/
|
|
1502
|
+
static toDate(el: TinyElement): Date | null;
|
|
1503
|
+
/**
|
|
1504
|
+
* Set Date content of elements.
|
|
1505
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1506
|
+
* @param {Date} value
|
|
1507
|
+
* @returns {TinyElement|TinyElement[]}
|
|
1508
|
+
*/
|
|
1509
|
+
static setDate(el: TinyElement | TinyElement[], value: Date): TinyElement | TinyElement[];
|
|
1510
|
+
/**
|
|
1511
|
+
* Returns the JSON content of the element.
|
|
1512
|
+
* @param {TinyElement} el - Target element.
|
|
1513
|
+
* @returns {any|null} The parsed JSON content or null if invalid.
|
|
1514
|
+
*/
|
|
1515
|
+
static toJson(el: TinyElement): any | null;
|
|
1516
|
+
/**
|
|
1517
|
+
* Set JSON content of elements.
|
|
1518
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1519
|
+
* @param {any} value
|
|
1520
|
+
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
1521
|
+
* @returns {TinyElement|TinyElement[]}
|
|
1522
|
+
*/
|
|
1523
|
+
static setJson(el: TinyElement | TinyElement[], value: any, space?: number | string): TinyElement | TinyElement[];
|
|
1524
|
+
/**
|
|
1525
|
+
* Returns the number content of the element.
|
|
1526
|
+
* @param {TinyElement} el - Target element.
|
|
1527
|
+
* @returns {number|null} The text content or null if none.
|
|
1528
|
+
*/
|
|
1529
|
+
static toNumber(el: TinyElement): number | null;
|
|
1530
|
+
/**
|
|
1531
|
+
* Set number content of elements.
|
|
1532
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1533
|
+
* @param {number} value
|
|
1534
|
+
* @returns {TinyElement|TinyElement[]}
|
|
1535
|
+
*/
|
|
1536
|
+
static setNumber(el: TinyElement | TinyElement[], value: number): TinyElement | TinyElement[];
|
|
1484
1537
|
/**
|
|
1485
1538
|
* Returns the text content of the element.
|
|
1486
1539
|
* @param {TinyElement} el - Target element.
|
|
@@ -2629,6 +2682,51 @@ declare class TinyHtml {
|
|
|
2629
2682
|
* @returns {string} The element's ID.
|
|
2630
2683
|
*/
|
|
2631
2684
|
id(): string;
|
|
2685
|
+
/**
|
|
2686
|
+
* Returns the BigInt content of the element.
|
|
2687
|
+
* @returns {bigint|null}
|
|
2688
|
+
*/
|
|
2689
|
+
toBigInt(): bigint | null;
|
|
2690
|
+
/**
|
|
2691
|
+
* Set BigInt content of the element.
|
|
2692
|
+
* @param {bigint} value
|
|
2693
|
+
* @returns {TinyElement|TinyElement[]}
|
|
2694
|
+
*/
|
|
2695
|
+
setBigInt(value: bigint): TinyElement | TinyElement[];
|
|
2696
|
+
/**
|
|
2697
|
+
* Returns the Date content of the element.
|
|
2698
|
+
* @returns {Date|null}
|
|
2699
|
+
*/
|
|
2700
|
+
toDate(): Date | null;
|
|
2701
|
+
/**
|
|
2702
|
+
* Set Date content of the element.
|
|
2703
|
+
* @param {Date} value
|
|
2704
|
+
* @returns {TinyElement|TinyElement[]}
|
|
2705
|
+
*/
|
|
2706
|
+
setDate(value: Date): TinyElement | TinyElement[];
|
|
2707
|
+
/**
|
|
2708
|
+
* Returns the JSON content of the element.
|
|
2709
|
+
* @returns {any|null}
|
|
2710
|
+
*/
|
|
2711
|
+
toJson(): any | null;
|
|
2712
|
+
/**
|
|
2713
|
+
* Set JSON content of the element.
|
|
2714
|
+
* @param {any} value
|
|
2715
|
+
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
2716
|
+
* @returns {TinyElement|TinyElement[]}
|
|
2717
|
+
*/
|
|
2718
|
+
setJson(value: any, space?: number | string): TinyElement | TinyElement[];
|
|
2719
|
+
/**
|
|
2720
|
+
* Returns the number content of the element.
|
|
2721
|
+
* @returns {number|null} The text content or null if none.
|
|
2722
|
+
*/
|
|
2723
|
+
toNumber(): number | null;
|
|
2724
|
+
/**
|
|
2725
|
+
* Set number content of the element.
|
|
2726
|
+
* @param {number} value
|
|
2727
|
+
* @returns {TinyElement|TinyElement[]}
|
|
2728
|
+
*/
|
|
2729
|
+
setNumber(value: number): TinyElement | TinyElement[];
|
|
2632
2730
|
/**
|
|
2633
2731
|
* Returns the text content of the element.
|
|
2634
2732
|
* @returns {string|null} The text content or null if none.
|
|
@@ -3466,6 +3466,170 @@ class TinyHtml {
|
|
|
3466
3466
|
id() {
|
|
3467
3467
|
return TinyHtml.id(this);
|
|
3468
3468
|
}
|
|
3469
|
+
/**
|
|
3470
|
+
* Returns the BigInt content of the element.
|
|
3471
|
+
* @param {TinyElement} el - Target element.
|
|
3472
|
+
* @returns {bigint|null} The BigInt content or null if none.
|
|
3473
|
+
*/
|
|
3474
|
+
static toBigInt(el) {
|
|
3475
|
+
const elem = TinyHtml._preElem(el, 'toBigInt');
|
|
3476
|
+
const txt = elem.textContent?.trim();
|
|
3477
|
+
let value = null;
|
|
3478
|
+
try {
|
|
3479
|
+
value = BigInt(txt ?? '');
|
|
3480
|
+
}
|
|
3481
|
+
catch {
|
|
3482
|
+
value = null;
|
|
3483
|
+
}
|
|
3484
|
+
return value;
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* Returns the BigInt content of the element.
|
|
3488
|
+
* @returns {bigint|null}
|
|
3489
|
+
*/
|
|
3490
|
+
toBigInt() {
|
|
3491
|
+
return TinyHtml.toBigInt(this);
|
|
3492
|
+
}
|
|
3493
|
+
/**
|
|
3494
|
+
* Set BigInt content of elements.
|
|
3495
|
+
* @param {TinyElement|TinyElement[]} el
|
|
3496
|
+
* @param {bigint} value
|
|
3497
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3498
|
+
*/
|
|
3499
|
+
static setBigInt(el, value) {
|
|
3500
|
+
if (typeof value !== 'bigint')
|
|
3501
|
+
throw new Error('Value is not a valid BigInt.');
|
|
3502
|
+
TinyHtml._preElems(el, 'setBigInt').forEach((el) => (el.textContent = value.toString()));
|
|
3503
|
+
return el;
|
|
3504
|
+
}
|
|
3505
|
+
/**
|
|
3506
|
+
* Set BigInt content of the element.
|
|
3507
|
+
* @param {bigint} value
|
|
3508
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3509
|
+
*/
|
|
3510
|
+
setBigInt(value) {
|
|
3511
|
+
return TinyHtml.setBigInt(this, value);
|
|
3512
|
+
}
|
|
3513
|
+
/**
|
|
3514
|
+
* Returns the Date content of the element.
|
|
3515
|
+
* @param {TinyElement} el - Target element.
|
|
3516
|
+
* @returns {Date|null} The Date content or null if invalid.
|
|
3517
|
+
*/
|
|
3518
|
+
static toDate(el) {
|
|
3519
|
+
const elem = TinyHtml._preElem(el, 'toDate');
|
|
3520
|
+
const txt = elem.textContent?.trim();
|
|
3521
|
+
if (!txt)
|
|
3522
|
+
return null;
|
|
3523
|
+
const d = new Date(txt);
|
|
3524
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
3525
|
+
}
|
|
3526
|
+
/**
|
|
3527
|
+
* Returns the Date content of the element.
|
|
3528
|
+
* @returns {Date|null}
|
|
3529
|
+
*/
|
|
3530
|
+
toDate() {
|
|
3531
|
+
return TinyHtml.toDate(this);
|
|
3532
|
+
}
|
|
3533
|
+
/**
|
|
3534
|
+
* Set Date content of elements.
|
|
3535
|
+
* @param {TinyElement|TinyElement[]} el
|
|
3536
|
+
* @param {Date} value
|
|
3537
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3538
|
+
*/
|
|
3539
|
+
static setDate(el, value) {
|
|
3540
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime()))
|
|
3541
|
+
throw new Error('Value is not a valid Date.');
|
|
3542
|
+
TinyHtml._preElems(el, 'setDate').forEach((el) => (el.textContent = value.toISOString()));
|
|
3543
|
+
return el;
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* Set Date content of the element.
|
|
3547
|
+
* @param {Date} value
|
|
3548
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3549
|
+
*/
|
|
3550
|
+
setDate(value) {
|
|
3551
|
+
return TinyHtml.setDate(this, value);
|
|
3552
|
+
}
|
|
3553
|
+
/**
|
|
3554
|
+
* Returns the JSON content of the element.
|
|
3555
|
+
* @param {TinyElement} el - Target element.
|
|
3556
|
+
* @returns {any|null} The parsed JSON content or null if invalid.
|
|
3557
|
+
*/
|
|
3558
|
+
static toJson(el) {
|
|
3559
|
+
const elem = TinyHtml._preElem(el, 'toJson');
|
|
3560
|
+
const txt = elem.textContent?.trim();
|
|
3561
|
+
if (!txt)
|
|
3562
|
+
return null;
|
|
3563
|
+
try {
|
|
3564
|
+
return JSON.parse(txt);
|
|
3565
|
+
}
|
|
3566
|
+
catch {
|
|
3567
|
+
return null;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
/**
|
|
3571
|
+
* Returns the JSON content of the element.
|
|
3572
|
+
* @returns {any|null}
|
|
3573
|
+
*/
|
|
3574
|
+
toJson() {
|
|
3575
|
+
return TinyHtml.toJson(this);
|
|
3576
|
+
}
|
|
3577
|
+
/**
|
|
3578
|
+
* Set JSON content of elements.
|
|
3579
|
+
* @param {TinyElement|TinyElement[]} el
|
|
3580
|
+
* @param {any} value
|
|
3581
|
+
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3582
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3583
|
+
*/
|
|
3584
|
+
static setJson(el, value, space) {
|
|
3585
|
+
TinyHtml._preElems(el, 'setJson').forEach((el) => (el.textContent = JSON.stringify(value, null, space)));
|
|
3586
|
+
return el;
|
|
3587
|
+
}
|
|
3588
|
+
/**
|
|
3589
|
+
* Set JSON content of the element.
|
|
3590
|
+
* @param {any} value
|
|
3591
|
+
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3592
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3593
|
+
*/
|
|
3594
|
+
setJson(value, space) {
|
|
3595
|
+
return TinyHtml.setJson(this, value, space);
|
|
3596
|
+
}
|
|
3597
|
+
/**
|
|
3598
|
+
* Returns the number content of the element.
|
|
3599
|
+
* @param {TinyElement} el - Target element.
|
|
3600
|
+
* @returns {number|null} The text content or null if none.
|
|
3601
|
+
*/
|
|
3602
|
+
static toNumber(el) {
|
|
3603
|
+
const elem = TinyHtml._preElem(el, 'toNumber');
|
|
3604
|
+
return typeof elem.textContent === 'string' ? parseFloat(elem.textContent.trim()) : null;
|
|
3605
|
+
}
|
|
3606
|
+
/**
|
|
3607
|
+
* Returns the number content of the element.
|
|
3608
|
+
* @returns {number|null} The text content or null if none.
|
|
3609
|
+
*/
|
|
3610
|
+
toNumber() {
|
|
3611
|
+
return TinyHtml.toNumber(this);
|
|
3612
|
+
}
|
|
3613
|
+
/**
|
|
3614
|
+
* Set number content of elements.
|
|
3615
|
+
* @param {TinyElement|TinyElement[]} el
|
|
3616
|
+
* @param {number} value
|
|
3617
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3618
|
+
*/
|
|
3619
|
+
static setNumber(el, value) {
|
|
3620
|
+
if (typeof value !== 'number')
|
|
3621
|
+
throw new Error('Value is not a valid number.');
|
|
3622
|
+
TinyHtml._preElems(el, 'setNumber').forEach((el) => (el.textContent = value.toString()));
|
|
3623
|
+
return el;
|
|
3624
|
+
}
|
|
3625
|
+
/**
|
|
3626
|
+
* Set number content of the element.
|
|
3627
|
+
* @param {number} value
|
|
3628
|
+
* @returns {TinyElement|TinyElement[]}
|
|
3629
|
+
*/
|
|
3630
|
+
setNumber(value) {
|
|
3631
|
+
return TinyHtml.setNumber(this, value);
|
|
3632
|
+
}
|
|
3469
3633
|
/**
|
|
3470
3634
|
* Returns the text content of the element.
|
|
3471
3635
|
* @param {TinyElement} el - Target element.
|
package/docs/v1/libs/TinyHtml.md
CHANGED
|
@@ -1328,6 +1328,89 @@ element.id(); // → "my-element-id"
|
|
|
1328
1328
|
|
|
1329
1329
|
---
|
|
1330
1330
|
|
|
1331
|
+
### 📝 `.toBigInt()` / `TinyHtml.toBigInt(el)`
|
|
1332
|
+
|
|
1333
|
+
Gets the **BigInt** content of the element (returns `null` if invalid or empty).
|
|
1334
|
+
|
|
1335
|
+
```js
|
|
1336
|
+
element.toBigInt(); // → 123n
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1339
|
+
---
|
|
1340
|
+
|
|
1341
|
+
### ✍️ `.setBigInt(value)` / `TinyHtml.setBigInt(el, value)`
|
|
1342
|
+
|
|
1343
|
+
Sets the **BigInt** content of one or more elements. Throws if `value` is not a BigInt.
|
|
1344
|
+
|
|
1345
|
+
```js
|
|
1346
|
+
element.setBigInt(456n);
|
|
1347
|
+
```
|
|
1348
|
+
|
|
1349
|
+
---
|
|
1350
|
+
|
|
1351
|
+
### 📝 `.toDate()` / `TinyHtml.toDate(el)`
|
|
1352
|
+
|
|
1353
|
+
Gets the **Date** content of the element (returns `null` if invalid).
|
|
1354
|
+
|
|
1355
|
+
```js
|
|
1356
|
+
element.toDate(); // → 2025-08-31T00:00:00.000Z
|
|
1357
|
+
```
|
|
1358
|
+
|
|
1359
|
+
---
|
|
1360
|
+
|
|
1361
|
+
### ✍️ `.setDate(value)` / `TinyHtml.setDate(el, value)`
|
|
1362
|
+
|
|
1363
|
+
Sets the **Date** content of one or more elements. Throws if `value` is not a valid `Date`.
|
|
1364
|
+
|
|
1365
|
+
```js
|
|
1366
|
+
element.setDate(new Date("2025-08-31T00:00:00Z"));
|
|
1367
|
+
```
|
|
1368
|
+
|
|
1369
|
+
---
|
|
1370
|
+
|
|
1371
|
+
### 📝 `.toJson()` / `TinyHtml.toJson(el)`
|
|
1372
|
+
|
|
1373
|
+
Gets the **JSON** content of the element (returns `null` if invalid or empty).
|
|
1374
|
+
|
|
1375
|
+
```js
|
|
1376
|
+
element.toJson(); // → { a: 1, b: 2 }
|
|
1377
|
+
```
|
|
1378
|
+
|
|
1379
|
+
---
|
|
1380
|
+
|
|
1381
|
+
### ✍️ `.setJson(value, space)` / `TinyHtml.setJson(el, value, space)`
|
|
1382
|
+
|
|
1383
|
+
Sets the **JSON** content of one or more elements.
|
|
1384
|
+
`space` is optional and can be a number or string for indentation.
|
|
1385
|
+
|
|
1386
|
+
```js
|
|
1387
|
+
element.setJson({ a: 1, b: 2 }); // minified
|
|
1388
|
+
element.setJson({ a: 1, b: 2 }, 2); // 2-space indentation
|
|
1389
|
+
element.setJson({ a: 1, b: 2 }, "\t"); // tab indentation
|
|
1390
|
+
```
|
|
1391
|
+
|
|
1392
|
+
---
|
|
1393
|
+
|
|
1394
|
+
### 📝 `.toNumber()` / `TinyHtml.toNumber(el)`
|
|
1395
|
+
|
|
1396
|
+
Gets the **number** content of the element (returns `null` if invalid or empty).
|
|
1397
|
+
|
|
1398
|
+
```js
|
|
1399
|
+
element.toNumber(); // → 42
|
|
1400
|
+
```
|
|
1401
|
+
|
|
1402
|
+
---
|
|
1403
|
+
|
|
1404
|
+
### ✍️ `.setNumber(value)` / `TinyHtml.setNumber(el, value)`
|
|
1405
|
+
|
|
1406
|
+
Sets the **number** content of one or more elements. Throws if `value` is not a number.
|
|
1407
|
+
|
|
1408
|
+
```js
|
|
1409
|
+
element.setNumber(99);
|
|
1410
|
+
```
|
|
1411
|
+
|
|
1412
|
+
---
|
|
1413
|
+
|
|
1331
1414
|
### 📝 `.text()` / `TinyHtml.text(el)`
|
|
1332
1415
|
|
|
1333
1416
|
Gets the text content of the element (returns `null` if none).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.5",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|