hyperscript-rxjs 1.3.17 → 1.3.19
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/hyperscript-rxjs.d.ts +11 -27
- package/dist/hyperscript-rxjs.js +64 -55
- package/package.json +1 -1
@@ -1,5 +1,4 @@
|
|
1
1
|
import { BehaviorSubject } from 'rxjs';
|
2
|
-
import { HyperscriptExtensions as HyperscriptExtensions_2 } from './HyperscriptExtensions.d.ts';
|
3
2
|
import { Observable } from 'rxjs';
|
4
3
|
import { Observer as Observer_2 } from 'rxjs';
|
5
4
|
import { Subject } from 'rxjs';
|
@@ -120,9 +119,6 @@ export declare function caption(props?: {
|
|
120
119
|
[_: string]: any;
|
121
120
|
}, ...childNodes: any[]): HyperscriptExtensions<HTMLElement>;
|
122
121
|
|
123
|
-
/**
|
124
|
-
* @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLInputElement>} HyperscriptInputElement
|
125
|
-
*/
|
126
122
|
/**
|
127
123
|
* 创建一个支持 RxJS 的复选框组件。
|
128
124
|
*
|
@@ -697,9 +693,6 @@ export declare function hr(props?: {
|
|
697
693
|
[_: string]: any;
|
698
694
|
}, ...childNodes: any[]): HyperscriptExtensions<HTMLHRElement>;
|
699
695
|
|
700
|
-
/**
|
701
|
-
* @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLElement>} HyperscriptElement
|
702
|
-
*/
|
703
696
|
/**
|
704
697
|
* Creates an HTML element with extended event handling capabilities
|
705
698
|
* @public
|
@@ -710,22 +703,20 @@ export declare function hr(props?: {
|
|
710
703
|
*/
|
711
704
|
export declare function hyperscript(elemName: string, ...args: any[]): HyperscriptElement;
|
712
705
|
|
713
|
-
export declare type HyperscriptElement =
|
706
|
+
export declare type HyperscriptElement = HyperscriptExtensions<HTMLElement>;
|
714
707
|
|
715
|
-
export declare type HyperscriptExtensions<T extends HTMLElement> =
|
716
|
-
|
717
|
-
declare type HyperscriptExtensions_3<T extends HTMLElement> =
|
708
|
+
export declare type HyperscriptExtensions<T extends HTMLElement> =
|
718
709
|
T & {
|
719
710
|
|
720
711
|
pipeEvent(
|
721
712
|
event: string,
|
722
713
|
subscriber: (input$: Observable<Event>) => Subscription
|
723
|
-
):
|
714
|
+
): HyperscriptExtensions<T>;
|
724
715
|
|
725
716
|
subscribeEvent(
|
726
717
|
event: string,
|
727
718
|
observer: ((value: Event) => void) | Partial<Observer_2<Event>>
|
728
|
-
):
|
719
|
+
): HyperscriptExtensions<T>;
|
729
720
|
|
730
721
|
unsubscribe(): void;
|
731
722
|
|
@@ -733,15 +724,11 @@ T & {
|
|
733
724
|
|
734
725
|
};
|
735
726
|
|
736
|
-
export declare type HyperscriptInputElement =
|
737
|
-
|
738
|
-
declare type HyperscriptInputElement_2 = HyperscriptExtensions_3<HTMLInputElement>;
|
739
|
-
|
740
|
-
export declare type HyperscriptSelectElement = HyperscriptExtensions_2<HTMLSelectElement>;
|
727
|
+
export declare type HyperscriptInputElement = HyperscriptExtensions<HTMLInputElement>;
|
741
728
|
|
742
|
-
declare type
|
729
|
+
export declare type HyperscriptSelectElement = HyperscriptExtensions<HTMLSelectElement>;
|
743
730
|
|
744
|
-
declare type HyperscriptTextAreaElement =
|
731
|
+
export declare type HyperscriptTextAreaElement = HyperscriptExtensions<HTMLTextAreaElement>;
|
745
732
|
|
746
733
|
export declare function i(props?: {
|
747
734
|
[_: string]: any;
|
@@ -853,9 +840,6 @@ export declare function meter(props?: {
|
|
853
840
|
[_: string]: any;
|
854
841
|
}, ...childNodes: any[]): HyperscriptExtensions<HTMLMeterElement>;
|
855
842
|
|
856
|
-
/**
|
857
|
-
* @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptExtensions<HTMLSelectElement>} HyperscriptSelectElement
|
858
|
-
*/
|
859
843
|
/**
|
860
844
|
* 创建一个支持多选功能的 <select> 元素,并绑定选项的选中状态。必须手动添加控件更新BehaviorSubject的事件。
|
861
845
|
*
|
@@ -911,7 +895,7 @@ export declare function normalizeChildNodes(childNodes: any[]): Node[];
|
|
911
895
|
export declare function numberbox(props: {
|
912
896
|
number: BehaviorSubject<number>;
|
913
897
|
[key: string]: any;
|
914
|
-
}):
|
898
|
+
}): HyperscriptInputElement;
|
915
899
|
|
916
900
|
/**
|
917
901
|
* ObservableArray 是一个可观察的数组,支持 insertBefore、removeChild、replaceChild 操作,
|
@@ -1082,7 +1066,7 @@ export declare function queryStringify(data: Object): string;
|
|
1082
1066
|
export declare function radio(props: {
|
1083
1067
|
checked: BehaviorSubject<boolean>;
|
1084
1068
|
[key: string]: any;
|
1085
|
-
}):
|
1069
|
+
}): HyperscriptInputElement;
|
1086
1070
|
|
1087
1071
|
/**
|
1088
1072
|
* 创建一个从 0 到 length-1 的数字数组。
|
@@ -1147,7 +1131,7 @@ export declare function select(props: {
|
|
1147
1131
|
selectedIndex?: BehaviorSubject<number>;
|
1148
1132
|
value?: BehaviorSubject<string>;
|
1149
1133
|
[key: string]: any;
|
1150
|
-
}, ...options: HTMLOptionElement[]):
|
1134
|
+
}, ...options: HTMLOptionElement[]): HyperscriptSelectElement;
|
1151
1135
|
|
1152
1136
|
/**
|
1153
1137
|
*
|
@@ -1316,7 +1300,7 @@ export declare function textarea(props: {
|
|
1316
1300
|
export declare function textbox(props: {
|
1317
1301
|
value: BehaviorSubject<string>;
|
1318
1302
|
[key: string]: any;
|
1319
|
-
}):
|
1303
|
+
}): HyperscriptInputElement;
|
1320
1304
|
|
1321
1305
|
/**
|
1322
1306
|
* @typedef {Text & {subscription?: Subscription, unsubscribe?: ()=>void}} ObservableTextNode
|
package/dist/hyperscript-rxjs.js
CHANGED
@@ -1,21 +1,28 @@
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
3
|
-
module.exports = factory(require("rxjs"));
|
3
|
+
module.exports = factory(require("rxjs"), require("rxjs/operators"));
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
5
|
-
define(["rxjs"], factory);
|
6
|
-
else
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
})(
|
5
|
+
define(["rxjs", "rxjs/operators"], factory);
|
6
|
+
else if(typeof exports === 'object')
|
7
|
+
exports["hyperscriptRxjs"] = factory(require("rxjs"), require("rxjs/operators"));
|
8
|
+
else
|
9
|
+
root["hyperscriptRxjs"] = factory(root[undefined], root["rxjs"]);
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE__313__, __WEBPACK_EXTERNAL_MODULE__506__) => {
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
12
12
|
/******/ "use strict";
|
13
13
|
/******/ var __webpack_modules__ = ({
|
14
14
|
|
15
|
-
/***/
|
15
|
+
/***/ 313:
|
16
16
|
/***/ ((module) => {
|
17
17
|
|
18
|
-
module.exports =
|
18
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__313__;
|
19
|
+
|
20
|
+
/***/ }),
|
21
|
+
|
22
|
+
/***/ 506:
|
23
|
+
/***/ ((module) => {
|
24
|
+
|
25
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__506__;
|
19
26
|
|
20
27
|
/***/ })
|
21
28
|
|
@@ -1035,8 +1042,10 @@ const types = ["undefined",
|
|
1035
1042
|
|
1036
1043
|
|
1037
1044
|
|
1038
|
-
// EXTERNAL MODULE: external "rxjs"
|
1039
|
-
var
|
1045
|
+
// EXTERNAL MODULE: external {"commonjs":"rxjs","commonjs2":"rxjs","amd":"rxjs"}
|
1046
|
+
var external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_ = __webpack_require__(313);
|
1047
|
+
// EXTERNAL MODULE: external {"commonjs":"rxjs/operators","commonjs2":"rxjs/operators","amd":"rxjs/operators","root":"rxjs"}
|
1048
|
+
var operators_root_rxjs_ = __webpack_require__(506);
|
1040
1049
|
;// ./src/object/pluckProperty.js
|
1041
1050
|
/**
|
1042
1051
|
* 获取对象的嵌套属性
|
@@ -1430,7 +1439,7 @@ class Deep {
|
|
1430
1439
|
*/
|
1431
1440
|
combineLatest() {
|
1432
1441
|
let values = this.getValues();
|
1433
|
-
return (0,
|
1442
|
+
return (0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.combineLatest)(values).pipe((0,operators_root_rxjs_.map)(values => this.replaceValue(values)));
|
1434
1443
|
}
|
1435
1444
|
|
1436
1445
|
/**
|
@@ -1440,7 +1449,7 @@ class Deep {
|
|
1440
1449
|
* @returns {Observable<[(string|number)[], U]>}
|
1441
1450
|
*/
|
1442
1451
|
merge() {
|
1443
|
-
return (0,
|
1452
|
+
return (0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.from)(this.entries).pipe((0,operators_root_rxjs_.mergeMap)(([keyPath, value$]) => value$.pipe((0,operators_root_rxjs_.map)(
|
1444
1453
|
/**
|
1445
1454
|
* @returns {[(string|number)[], U]}
|
1446
1455
|
*/
|
@@ -1467,7 +1476,7 @@ class Deep {
|
|
1467
1476
|
* @returns {Deep<BehaviorSubject<T>>}
|
1468
1477
|
*/
|
1469
1478
|
static fromBehaviorSubject(obj) {
|
1470
|
-
return Deep.fromObject(obj, v => (0,
|
1479
|
+
return Deep.fromObject(obj, v => (0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(v) || v instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.Subscription).filter(([k, v]) => v instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject);
|
1471
1480
|
}
|
1472
1481
|
|
1473
1482
|
/**
|
@@ -1476,7 +1485,7 @@ class Deep {
|
|
1476
1485
|
* @returns
|
1477
1486
|
*/
|
1478
1487
|
static fromObservable(obj) {
|
1479
|
-
return Deep.fromObject(obj, v => (0,
|
1488
|
+
return Deep.fromObject(obj, v => (0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(v) || v instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.Subscription).filter(([k, v]) => (0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(v));
|
1480
1489
|
}
|
1481
1490
|
}
|
1482
1491
|
;// ./src/deep/0.js
|
@@ -1494,7 +1503,7 @@ class Deep {
|
|
1494
1503
|
*
|
1495
1504
|
*/
|
1496
1505
|
function isRxType(obj) {
|
1497
|
-
return typeof obj === 'object' && obj && ((0,
|
1506
|
+
return typeof obj === 'object' && obj && ((0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(obj) || obj instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.Subscription);
|
1498
1507
|
}
|
1499
1508
|
;// ./src/deep-rxjs/ObservableArray.js
|
1500
1509
|
|
@@ -1522,25 +1531,25 @@ class ObservableArray extends Array {
|
|
1522
1531
|
* 变化通知的 Subject。
|
1523
1532
|
* @type {Subject<any[]>}
|
1524
1533
|
*/
|
1525
|
-
this.action$ = new
|
1534
|
+
this.action$ = new external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.Subject();
|
1526
1535
|
|
1527
1536
|
/**
|
1528
1537
|
* 插入元素事件流,发出 [item, index]。
|
1529
1538
|
* @type {import('rxjs').Observable<[T, number]>}
|
1530
1539
|
*/
|
1531
|
-
this.insertBefore$ = this.action$.pipe((0,
|
1540
|
+
this.insertBefore$ = this.action$.pipe((0,operators_root_rxjs_.filter)(([action]) => action === 'insertBefore'), (0,operators_root_rxjs_.map)(([_, item, index]) => [item, index]));
|
1532
1541
|
|
1533
1542
|
/**
|
1534
1543
|
* 删除元素事件流,发出 index。
|
1535
1544
|
* @type {import('rxjs').Observable<number>}
|
1536
1545
|
*/
|
1537
|
-
this.removeChild$ = this.action$.pipe((0,
|
1546
|
+
this.removeChild$ = this.action$.pipe((0,operators_root_rxjs_.filter)(([action]) => action === 'removeChild'), (0,operators_root_rxjs_.map)(([_, index]) => index));
|
1538
1547
|
|
1539
1548
|
/**
|
1540
1549
|
* 替换元素事件流,发出 [item, index]。
|
1541
1550
|
* @type {import('rxjs').Observable<[T, number]>}
|
1542
1551
|
*/
|
1543
|
-
this.replaceChild$ = this.action$.pipe((0,
|
1552
|
+
this.replaceChild$ = this.action$.pipe((0,operators_root_rxjs_.filter)(([action]) => action === 'replaceChild'), (0,operators_root_rxjs_.map)(([_, item, index]) => [item, index]));
|
1544
1553
|
}
|
1545
1554
|
|
1546
1555
|
/**
|
@@ -1685,7 +1694,7 @@ const attachSubscriptionToNode = (elem, subscription) => {
|
|
1685
1694
|
if (!(elem instanceof Node)) {
|
1686
1695
|
throw new Error('Valid DOM node required');
|
1687
1696
|
}
|
1688
|
-
if (!(subscription instanceof
|
1697
|
+
if (!(subscription instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.Subscription)) {
|
1689
1698
|
throw new Error('Valid RxJS subscription required');
|
1690
1699
|
}
|
1691
1700
|
|
@@ -1728,7 +1737,7 @@ function pipeEvent(elem) {
|
|
1728
1737
|
if (typeof subscriber !== 'function') {
|
1729
1738
|
throw new Error('参数 "subscriber" 必须是一个函数。');
|
1730
1739
|
}
|
1731
|
-
let event$ = (0,
|
1740
|
+
let event$ = (0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.fromEvent)(elem, event); // 创建事件流 Observable
|
1732
1741
|
|
1733
1742
|
try {
|
1734
1743
|
let subscription = subscriber(event$); // 订阅事件流并处理
|
@@ -1781,7 +1790,7 @@ function subscribeEvent(elem) {
|
|
1781
1790
|
}
|
1782
1791
|
|
1783
1792
|
// 创建事件流 Observable
|
1784
|
-
let event$ = (0,
|
1793
|
+
let event$ = (0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.fromEvent)(elem, event);
|
1785
1794
|
|
1786
1795
|
// 订阅事件流
|
1787
1796
|
let subscription;
|
@@ -1910,7 +1919,7 @@ function splitObjectByObservable(obj) {
|
|
1910
1919
|
let value = obj[key];
|
1911
1920
|
|
1912
1921
|
// 根据值的类型分类
|
1913
|
-
if ((0,
|
1922
|
+
if ((0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(value)) {
|
1914
1923
|
observables[key] = value; // 如果是 Observable,存入 observables
|
1915
1924
|
} else {
|
1916
1925
|
scalars[key] = value; // 否则存入 scalars
|
@@ -2055,12 +2064,12 @@ function subscribeProp(element, key, value$) {
|
|
2055
2064
|
if (typeof key !== 'string') {
|
2056
2065
|
throw new Error('参数 "key" 必须是一个字符串。');
|
2057
2066
|
}
|
2058
|
-
if (!(0,
|
2067
|
+
if (!(0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(value$)) {
|
2059
2068
|
throw new Error('参数 "value$" 必须是一个有效的 Observable。');
|
2060
2069
|
}
|
2061
2070
|
|
2062
2071
|
// 创建订阅,将 BehaviorSubject 的值动态设置为元素的属性
|
2063
|
-
const subscription = value$.pipe((0,
|
2072
|
+
const subscription = value$.pipe((0,operators_root_rxjs_.startWith)(0)).subscribe({
|
2064
2073
|
next: value => {
|
2065
2074
|
setProp(element, key, value);
|
2066
2075
|
},
|
@@ -2182,7 +2191,7 @@ function hyperscript(elemName, ...args) {
|
|
2182
2191
|
return subscribeEvent(element)(event, observer);
|
2183
2192
|
},
|
2184
2193
|
unsubscribe() {
|
2185
|
-
if ('subscription' in element && element.subscription instanceof
|
2194
|
+
if ('subscription' in element && element.subscription instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.Subscription) {
|
2186
2195
|
element.subscription.unsubscribe(); // 取消订阅
|
2187
2196
|
delete element.subscription; // 删除属性
|
2188
2197
|
}
|
@@ -3057,7 +3066,7 @@ function bindTabIndex(tabRoot, tabIndex$) {
|
|
3057
3066
|
});
|
3058
3067
|
|
3059
3068
|
// 监听导航按钮的点击事件,更新 tabIndex
|
3060
|
-
navs.pipeEvent('click', click$ => click$.pipe((0,
|
3069
|
+
navs.pipeEvent('click', click$ => click$.pipe((0,operators_root_rxjs_.map)(e => Array.from(navs.childNodes).map(e => (/** @type {HTMLElement} */e.firstChild)).indexOf(/** @type {HTMLElement} */e.target)), (0,operators_root_rxjs_.filter)(i => i > -1) // 过滤无效索引
|
3061
3070
|
).subscribe(tabIndex$));
|
3062
3071
|
}
|
3063
3072
|
;// ./src/hyperscript-rxjs/tabControls/tabControl.js
|
@@ -3131,7 +3140,7 @@ function checkbox_checkbox(props) {
|
|
3131
3140
|
});
|
3132
3141
|
|
3133
3142
|
// 如果传入了 checked 属性
|
3134
|
-
if (props.checked && props.checked instanceof
|
3143
|
+
if (props.checked && props.checked instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) {
|
3135
3144
|
// 监听复选框的 input 事件,并将选中状态推送到 Observable/Subject
|
3136
3145
|
let subscriber =
|
3137
3146
|
/**
|
@@ -3139,7 +3148,7 @@ function checkbox_checkbox(props) {
|
|
3139
3148
|
* @param {Observable<Event>} input$
|
3140
3149
|
* @returns
|
3141
3150
|
*/
|
3142
|
-
input$ => input$.pipe((0,
|
3151
|
+
input$ => input$.pipe((0,operators_root_rxjs_.map)(e => /** @type {HTMLInputElement} */e.target.checked) // 提取复选框的选中状态
|
3143
3152
|
).subscribe(props.checked); // 推送选中状态到 Observable/Subject
|
3144
3153
|
|
3145
3154
|
elem.pipeEvent('input', subscriber); // 绑定事件处理器
|
@@ -3191,7 +3200,7 @@ function collapse(hidden$, ...elements) {
|
|
3191
3200
|
function choice(chosen$, possibilities) {
|
3192
3201
|
// 遍历 possibilities,将每个可能性绑定到 collapse
|
3193
3202
|
const elems = Object.entries(possibilities).map(([key, possibility]) => {
|
3194
|
-
const hidden$ = chosen$.pipe((0,
|
3203
|
+
const hidden$ = chosen$.pipe((0,operators_root_rxjs_.map)(selectedKey => selectedKey !== key) // 如果当前选中的键不是当前可能性,则隐藏
|
3195
3204
|
);
|
3196
3205
|
return collapse(hidden$, possibility); // 绑定 hidden 属性
|
3197
3206
|
}).reduce((acc, cur) => [...acc, ...cur], []); // 扁平化数组
|
@@ -3218,7 +3227,7 @@ function choice(chosen$, possibilities) {
|
|
3218
3227
|
*/
|
3219
3228
|
function flip(yinHidden$, yin, yang) {
|
3220
3229
|
// 创建一个 Observable,用于控制 yangElement 的隐藏状态
|
3221
|
-
const yangHidden$ = yinHidden$.pipe((0,
|
3230
|
+
const yangHidden$ = yinHidden$.pipe((0,operators_root_rxjs_.map)(isHidden => !isHidden));
|
3222
3231
|
|
3223
3232
|
// 阴阳交叉
|
3224
3233
|
return [...collapse(yangHidden$, yin), ...collapse(yinHidden$, yang)];
|
@@ -3297,7 +3306,7 @@ function multiselect(props, ...options) {
|
|
3297
3306
|
|
3298
3307
|
/**
|
3299
3308
|
* @internal
|
3300
|
-
* @typedef {import("./
|
3309
|
+
* @typedef {import("./HyperscriptExtensions.js").HyperscriptInputElement} HyperscriptInputElement
|
3301
3310
|
*/
|
3302
3311
|
|
3303
3312
|
/**
|
@@ -3323,8 +3332,8 @@ function numberbox(props) {
|
|
3323
3332
|
...rest,
|
3324
3333
|
type: 'text'
|
3325
3334
|
});
|
3326
|
-
if (number && number instanceof
|
3327
|
-
let value = number.pipe((0,
|
3335
|
+
if (number && number instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) {
|
3336
|
+
let value = number.pipe((0,operators_root_rxjs_.map)(n => String(n)));
|
3328
3337
|
subscribeProp(elem, 'value', value);
|
3329
3338
|
let subscriber =
|
3330
3339
|
/**
|
@@ -3332,7 +3341,7 @@ function numberbox(props) {
|
|
3332
3341
|
* @param {Observable<Event>} blur$
|
3333
3342
|
* @returns
|
3334
3343
|
*/
|
3335
|
-
blur$ => blur$.pipe((0,
|
3344
|
+
blur$ => blur$.pipe((0,operators_root_rxjs_.map)(e => Number(/** @type {HTMLInputElement} */
|
3336
3345
|
e.target.value))).subscribe(newValue => {
|
3337
3346
|
if (Number.isNaN(newValue)) {
|
3338
3347
|
elem.select();
|
@@ -3365,7 +3374,7 @@ function numberbox(props) {
|
|
3365
3374
|
|
3366
3375
|
/**
|
3367
3376
|
* @internal
|
3368
|
-
* @typedef {import("./
|
3377
|
+
* @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptInputElement} HyperscriptInputElement
|
3369
3378
|
*/
|
3370
3379
|
|
3371
3380
|
/**
|
@@ -3383,14 +3392,14 @@ function radio_radio(props) {
|
|
3383
3392
|
...props,
|
3384
3393
|
type: 'radio'
|
3385
3394
|
});
|
3386
|
-
if (props.checked && props.checked instanceof
|
3395
|
+
if (props.checked && props.checked instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) {
|
3387
3396
|
const subscriber =
|
3388
3397
|
/**
|
3389
3398
|
*
|
3390
3399
|
* @param {Observable<Event>} input$
|
3391
3400
|
* @returns
|
3392
3401
|
*/
|
3393
|
-
input$ => input$.pipe((0,
|
3402
|
+
input$ => input$.pipe((0,operators_root_rxjs_.map)(e => /** @type {HTMLInputElement} */
|
3394
3403
|
e.target.checked)).subscribe(props.checked);
|
3395
3404
|
elem.pipeEvent('input', subscriber);
|
3396
3405
|
|
@@ -3413,7 +3422,7 @@ function radio_radio(props) {
|
|
3413
3422
|
|
3414
3423
|
/**
|
3415
3424
|
* @internal
|
3416
|
-
* @typedef {import("./
|
3425
|
+
* @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptSelectElement} HyperscriptSelectElement
|
3417
3426
|
*/
|
3418
3427
|
|
3419
3428
|
/**
|
@@ -3441,10 +3450,10 @@ function select_select(props, ...options) {
|
|
3441
3450
|
} = props;
|
3442
3451
|
|
3443
3452
|
// 确保至少有一个是 BehaviorSubject
|
3444
|
-
if (elem.options.length > 0 && !(selectedIndex instanceof
|
3453
|
+
if (elem.options.length > 0 && !(selectedIndex instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) && !(value instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject)) {
|
3445
3454
|
throw new Error('`select` requires at least one of `selectedIndex` or `value` to be a BehaviorSubject.');
|
3446
3455
|
}
|
3447
|
-
if (selectedIndex && selectedIndex instanceof
|
3456
|
+
if (selectedIndex && selectedIndex instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) {
|
3448
3457
|
selectedIndex.subscribe(i => {
|
3449
3458
|
/** @type {HTMLOptionElement} */
|
3450
3459
|
elem[i].selected = true;
|
@@ -3453,14 +3462,14 @@ function select_select(props, ...options) {
|
|
3453
3462
|
/**
|
3454
3463
|
* @param {Observable<Event>} input$
|
3455
3464
|
*/
|
3456
|
-
input$ => input$.pipe((0,
|
3465
|
+
input$ => input$.pipe((0,operators_root_rxjs_.map)(e => /** @type {HTMLSelectElement} */
|
3457
3466
|
e.target.selectedIndex)).subscribe(selectedIndex);
|
3458
3467
|
elem.pipeEvent('input', subscriber);
|
3459
3468
|
// let event$ = fromEvent(elem, 'input');
|
3460
3469
|
// let subscription = subscriber(event$);
|
3461
3470
|
// attachSubscriptionToNode(elem, subscription);
|
3462
3471
|
}
|
3463
|
-
if (value && value instanceof
|
3472
|
+
if (value && value instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) {
|
3464
3473
|
value.subscribe(value => {
|
3465
3474
|
Array.from(elem.getElementsByTagName('option')).filter(opt => opt.value === value).forEach(opt => {
|
3466
3475
|
opt.selected = true;
|
@@ -3471,7 +3480,7 @@ function select_select(props, ...options) {
|
|
3471
3480
|
* @param {Observable<Event>} input$
|
3472
3481
|
*/
|
3473
3482
|
|
3474
|
-
input$ => input$.pipe((0,
|
3483
|
+
input$ => input$.pipe((0,operators_root_rxjs_.map)(e => /** @type {HTMLSelectElement} */
|
3475
3484
|
e.target.value)).subscribe(value);
|
3476
3485
|
elem.pipeEvent('input', subscriber);
|
3477
3486
|
// let event$ = fromEvent(elem, 'input');
|
@@ -3504,7 +3513,7 @@ function textarea_textarea(props) {
|
|
3504
3513
|
const {
|
3505
3514
|
value
|
3506
3515
|
} = props;
|
3507
|
-
if (!(value instanceof
|
3516
|
+
if (!(value instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject)) {
|
3508
3517
|
throw new Error('`value` must be an instance of BehaviorSubject.');
|
3509
3518
|
}
|
3510
3519
|
|
@@ -3518,7 +3527,7 @@ function textarea_textarea(props) {
|
|
3518
3527
|
* @param {Observable<Event>} input$
|
3519
3528
|
* @returns
|
3520
3529
|
*/
|
3521
|
-
input$ => input$.pipe((0,
|
3530
|
+
input$ => input$.pipe((0,operators_root_rxjs_.map)(e => /** @type {HTMLTextAreaElement} */e.target.value)).subscribe(value);
|
3522
3531
|
elem.pipeEvent('input', subscriber);
|
3523
3532
|
return elem;
|
3524
3533
|
}
|
@@ -3529,7 +3538,7 @@ function textarea_textarea(props) {
|
|
3529
3538
|
|
3530
3539
|
/**
|
3531
3540
|
* @internal
|
3532
|
-
* @typedef {import("./
|
3541
|
+
* @typedef {import("./HyperscriptExtensions.d.ts").HyperscriptInputElement} HyperscriptInputElement
|
3533
3542
|
*/
|
3534
3543
|
|
3535
3544
|
/**
|
@@ -3546,7 +3555,7 @@ function textbox(props) {
|
|
3546
3555
|
const {
|
3547
3556
|
value
|
3548
3557
|
} = props;
|
3549
|
-
if (!(value instanceof
|
3558
|
+
if (!(value instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject)) {
|
3550
3559
|
throw new Error('`value` must be an instance of BehaviorSubject.');
|
3551
3560
|
}
|
3552
3561
|
|
@@ -3562,7 +3571,7 @@ function textbox(props) {
|
|
3562
3571
|
* @param {Observable<Event>} input$
|
3563
3572
|
* @returns
|
3564
3573
|
*/
|
3565
|
-
input$ => input$.pipe((0,
|
3574
|
+
input$ => input$.pipe((0,operators_root_rxjs_.map)(e => /** @type {HTMLInputElement} */e.target.value)).subscribe(value);
|
3566
3575
|
elem.pipeEvent('input', subscriber);
|
3567
3576
|
return elem;
|
3568
3577
|
}
|
@@ -3588,11 +3597,11 @@ function textbox(props) {
|
|
3588
3597
|
*/
|
3589
3598
|
function textNode(text) {
|
3590
3599
|
// 如果传入的是 Observable
|
3591
|
-
if ((0,
|
3600
|
+
if ((0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(text)) {
|
3592
3601
|
const node = document.createTextNode("");
|
3593
3602
|
|
3594
3603
|
// 创建订阅并更新文本节点
|
3595
|
-
const subscription = text.pipe((0,
|
3604
|
+
const subscription = text.pipe((0,operators_root_rxjs_.map)(d => String(d))).subscribe({
|
3596
3605
|
next(t) {
|
3597
3606
|
node.nodeValue = t;
|
3598
3607
|
},
|
@@ -3701,7 +3710,7 @@ const isEmptyObject = obj => {
|
|
3701
3710
|
*/
|
3702
3711
|
function nestedCombineLatest(model) {
|
3703
3712
|
let deep = Deep.fromObservable(model);
|
3704
|
-
return deep.combineLatest().pipe((0,
|
3713
|
+
return deep.combineLatest().pipe((0,operators_root_rxjs_.map)(deep => deep.toObject()));
|
3705
3714
|
}
|
3706
3715
|
;// ./src/object/nestedMerge.js
|
3707
3716
|
|
@@ -3749,7 +3758,7 @@ function pickBehaviorSubject(model) {
|
|
3749
3758
|
* @throws {Error} 当遇到不符合要求的数据结构时抛出错误
|
3750
3759
|
*/
|
3751
3760
|
function loop(value, key, parent) {
|
3752
|
-
if ((0,
|
3761
|
+
if ((0,external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.isObservable)(value) && value instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) {
|
3753
3762
|
return [[key, value.value]]; //保存葉節點
|
3754
3763
|
} else if (value === null || typeof value !== 'object' || isRxType(value)) {
|
3755
3764
|
return [];
|
@@ -3817,7 +3826,7 @@ function restore(model, src) {
|
|
3817
3826
|
* @param {any} src - Corresponding source value
|
3818
3827
|
*/
|
3819
3828
|
function restore_loop(o, src) {
|
3820
|
-
if (o instanceof
|
3829
|
+
if (o instanceof external_commonjs_rxjs_commonjs2_rxjs_amd_rxjs_.BehaviorSubject) {
|
3821
3830
|
// Input value
|
3822
3831
|
o.next(src);
|
3823
3832
|
} else if (o === null || typeof o !== 'object' || isRxType(o)) {
|
package/package.json
CHANGED