@ringcentral/juno 2.40.0 → 2.41.0
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/components/Downshift/SuggestionList/SuggestionList.d.ts +3 -3
- package/components/Downshift/utils/useDownshift.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +20 -2
- package/components/Virtuoso/index.d.ts +1 -1
- package/components/Virtuoso/index.js +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.d.ts +5 -0
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.js +217 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.d.ts +7696 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.js +317 -0
- package/components/Virtuoso/react-virtuoso/{Grid.d.ts → VirtuosoGrid.d.ts} +170 -72
- package/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +199 -0
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +119 -65
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/components/Virtuoso/react-virtuoso/comparators.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.d.ts +194 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.d.ts +274 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.d.ts +125 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +2 -0
- package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +3 -2
- package/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +80 -43
- package/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +57 -31
- package/components/Virtuoso/react-virtuoso/gridSystem.js +173 -86
- package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +76 -67
- package/components/Virtuoso/react-virtuoso/groupedListSystem.js +12 -12
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +6 -3
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +36 -17
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +3 -2
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.d.ts +2 -0
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +5 -0
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +36 -51
- package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useSize.js +13 -13
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +17 -15
- package/components/Virtuoso/react-virtuoso/index.d.ts +7 -1
- package/components/Virtuoso/react-virtuoso/index.js +8 -1
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +304 -68
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +9 -31
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +127 -109
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +38 -22
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/components/Virtuoso/react-virtuoso/interfaces.d.ts +150 -51
- package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +109 -59
- package/components/Virtuoso/react-virtuoso/listStateSystem.js +100 -52
- package/components/Virtuoso/react-virtuoso/listSystem.d.ts +1691 -693
- package/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/components/Virtuoso/react-virtuoso/react-urx/index.d.ts +110 -0
- package/components/Virtuoso/react-virtuoso/react-urx/index.js +200 -0
- package/components/Virtuoso/react-virtuoso/react-urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.d.ts +4 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.js +8 -0
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +144 -78
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +33 -21
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +12 -7
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +19 -11
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +7 -6
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +15 -27
- package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +20 -11
- package/components/Virtuoso/react-virtuoso/sizeSystem.js +182 -52
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +8 -5
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.d.ts +318 -0
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.js +41 -0
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +518 -467
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +115 -63
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +139 -73
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +74 -31
- package/components/Virtuoso/react-virtuoso/urx/actions.d.ts +127 -0
- package/components/Virtuoso/react-virtuoso/urx/actions.js +98 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.d.ts +8 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.js +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.d.ts +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.js +9 -0
- package/components/Virtuoso/react-virtuoso/urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.d.ts +220 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.js +279 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.d.ts +143 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.js +227 -0
- package/components/Virtuoso/react-virtuoso/urx/system.d.ts +148 -0
- package/components/Virtuoso/react-virtuoso/urx/system.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.d.ts +71 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.d.ts +57 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.js +102 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/context.d.ts +13 -0
- package/components/Virtuoso/react-virtuoso/utils/context.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.js +11 -0
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +6 -4
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/components/Virtuoso/utils/isOutOfRange.d.ts +1 -1
- package/components/Virtuoso/utils/useHighlightScroll.d.ts +2 -2
- package/es6/components/Tooltip/Tooltip.js +21 -3
- package/es6/components/Virtuoso/index.js +1 -1
- package/es6/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/es6/components/Virtuoso/react-virtuoso/{Table.js → TableVirtuoso.js} +73 -52
- package/es6/components/Virtuoso/react-virtuoso/{List.js → Virtuoso.js} +85 -161
- package/es6/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +198 -0
- package/es6/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/es6/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +173 -87
- package/es6/components/Virtuoso/react-virtuoso/groupedListSystem.js +13 -13
- package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +35 -16
- package/es6/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +2 -2
- package/es6/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +2 -0
- package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +35 -50
- package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +11 -12
- package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +15 -14
- package/es6/components/Virtuoso/react-virtuoso/index.js +4 -1
- package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +11 -33
- package/es6/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +101 -54
- package/es6/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/es6/components/Virtuoso/react-virtuoso/react-urx/index.js +197 -0
- package/es6/components/Virtuoso/react-virtuoso/recalcSystem.js +5 -0
- package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +34 -22
- package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +16 -28
- package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +180 -53
- package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/es6/components/Virtuoso/react-virtuoso/stateLoadSystem.js +39 -0
- package/es6/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/es6/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +75 -32
- package/es6/components/Virtuoso/react-virtuoso/urx/actions.js +90 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/constants.js +4 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/index.js +6 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/pipe.js +266 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/streams.js +220 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/system.js +102 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/transformers.js +101 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/utils.js +88 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/context.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/skipFrames.js +8 -0
- package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/es6/foundation/hooks/useForkRef/useForkRef.js +2 -1
- package/foundation/hooks/useForkRef/useForkRef.d.ts +2 -1
- package/foundation/hooks/useForkRef/useForkRef.js +1 -0
- package/package.json +2 -2
- package/components/Virtuoso/Virtuoso.d.ts +0 -1
- package/components/Virtuoso/Virtuoso.js +0 -4
- package/components/Virtuoso/react-virtuoso/Grid.js +0 -168
- package/components/Virtuoso/react-virtuoso/List.d.ts +0 -6749
- package/components/Virtuoso/react-virtuoso/List.js +0 -393
- package/components/Virtuoso/react-virtuoso/Table.d.ts +0 -6515
- package/components/Virtuoso/react-virtuoso/Table.js +0 -196
- package/components/Virtuoso/react-virtuoso/components.d.ts +0 -505
- package/components/Virtuoso/react-virtuoso/components.js +0 -9
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.d.ts +0 -1
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -11
- package/es6/components/Virtuoso/Virtuoso.js +0 -1
- package/es6/components/Virtuoso/react-virtuoso/Grid.js +0 -166
- package/es6/components/Virtuoso/react-virtuoso/components.js +0 -7
- package/es6/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -8
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
3
|
+
/**
|
|
4
|
+
* Streams are the basic building blocks of a reactive system. Think of them as the system permanent "data tubes".
|
|
5
|
+
*
|
|
6
|
+
* A stream acts as both an [[Emitter]] and [[Publisher]]. Each stream can have multiple {@link Subscription | Subscriptions}.
|
|
7
|
+
*
|
|
8
|
+
* urx streams are either **stateless** or **stateful**.
|
|
9
|
+
* Stateless streams emit data to existing subscriptions when published, without keeping track of it.
|
|
10
|
+
* Stateful streams remember the last published value and immediately publish it to new subscriptions.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { stream, statefulStream, publish, subscribe } from "@virtuoso.dev/urx";
|
|
14
|
+
*
|
|
15
|
+
* // foo is a stateless stream
|
|
16
|
+
* const foo = stream<number>();
|
|
17
|
+
*
|
|
18
|
+
* publish(foo, 42);
|
|
19
|
+
* // this subsription will not be called...
|
|
20
|
+
* subscribe(foo, (value) => console.log(value));
|
|
21
|
+
* // it will only catch published values after it
|
|
22
|
+
* publish(foo, 43);
|
|
23
|
+
*
|
|
24
|
+
* // stateful streams always start with an initial value
|
|
25
|
+
* const bar = statefulStream(42);
|
|
26
|
+
*
|
|
27
|
+
* // subscribing to a stateful stream
|
|
28
|
+
* // immediately calls the subscription with the current value
|
|
29
|
+
* subscribe(bar, (value) => console.log(value));
|
|
30
|
+
*
|
|
31
|
+
* // subsequent publishing works just like stateless streams
|
|
32
|
+
* publish(bar, 43);
|
|
33
|
+
* ```
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
import { subscribe, connect } from './actions';
|
|
37
|
+
import { RESET, PUBLISH, SUBSCRIBE, VALUE } from './constants';
|
|
38
|
+
import { tap, noop } from './utils';
|
|
39
|
+
/**
|
|
40
|
+
* Constructs a new stateless stream.
|
|
41
|
+
* ```ts
|
|
42
|
+
* const foo = stream<number>();
|
|
43
|
+
* ```
|
|
44
|
+
* @typeParam T the type of values to publish in the stream.
|
|
45
|
+
* @returns a [[Stream]]
|
|
46
|
+
*/
|
|
47
|
+
export function stream() {
|
|
48
|
+
var subscriptions = [];
|
|
49
|
+
return (function (action, arg) {
|
|
50
|
+
switch (action) {
|
|
51
|
+
case RESET:
|
|
52
|
+
subscriptions.splice(0, subscriptions.length);
|
|
53
|
+
return;
|
|
54
|
+
case SUBSCRIBE:
|
|
55
|
+
subscriptions.push(arg);
|
|
56
|
+
return function () {
|
|
57
|
+
var indexOf = subscriptions.indexOf(arg);
|
|
58
|
+
if (indexOf > -1) {
|
|
59
|
+
subscriptions.splice(indexOf, 1);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
case PUBLISH:
|
|
63
|
+
subscriptions.slice().forEach(function (subscription) {
|
|
64
|
+
subscription(arg);
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error("unrecognized action " + action);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Constructs a new stateful stream.
|
|
74
|
+
* ```ts
|
|
75
|
+
* const foo = statefulStream(42);
|
|
76
|
+
* ```
|
|
77
|
+
* @param initial the initial value in the stream.
|
|
78
|
+
* @typeParam T the type of values to publish in the stream. If omitted, the function infers it from the initial value.
|
|
79
|
+
* @returns a [[StatefulStream]]
|
|
80
|
+
*/
|
|
81
|
+
export function statefulStream(initial) {
|
|
82
|
+
var value = initial;
|
|
83
|
+
var innerSubject = stream();
|
|
84
|
+
return (function (action, arg) {
|
|
85
|
+
switch (action) {
|
|
86
|
+
case SUBSCRIBE:
|
|
87
|
+
var subscription = arg;
|
|
88
|
+
subscription(value);
|
|
89
|
+
break;
|
|
90
|
+
case PUBLISH:
|
|
91
|
+
value = arg;
|
|
92
|
+
break;
|
|
93
|
+
case VALUE:
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
return innerSubject(action, arg);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Event handlers are special emitters which can have **at most one active subscription**.
|
|
101
|
+
* Subscribing to an event handler unsubscribes the previous subscription, if present.
|
|
102
|
+
* ```ts
|
|
103
|
+
* const foo = stream<number>();
|
|
104
|
+
* const fooEvent = eventHandler(foo);
|
|
105
|
+
*
|
|
106
|
+
* // will be called once with 42
|
|
107
|
+
* subscribe(fooEvent, (value) => console.log(`Sub 1 ${value}`));
|
|
108
|
+
* publish(foo, 42);
|
|
109
|
+
*
|
|
110
|
+
* // unsubscribes sub 1
|
|
111
|
+
* subscribe(fooEvent, (value) => console.log(`Sub 2 ${value}`));
|
|
112
|
+
* publish(foo, 43);
|
|
113
|
+
* ```
|
|
114
|
+
* @param emitter the source emitter.
|
|
115
|
+
* @returns the single-subscription emitter.
|
|
116
|
+
*/
|
|
117
|
+
export function eventHandler(emitter) {
|
|
118
|
+
var unsub;
|
|
119
|
+
var currentSubscription;
|
|
120
|
+
var cleanup = function () { return unsub && unsub(); };
|
|
121
|
+
return function (action, subscription) {
|
|
122
|
+
switch (action) {
|
|
123
|
+
case SUBSCRIBE:
|
|
124
|
+
if (subscription) {
|
|
125
|
+
if (currentSubscription === subscription) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
cleanup();
|
|
129
|
+
currentSubscription = subscription;
|
|
130
|
+
unsub = subscribe(emitter, subscription);
|
|
131
|
+
return unsub;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
cleanup();
|
|
135
|
+
return noop;
|
|
136
|
+
}
|
|
137
|
+
case RESET:
|
|
138
|
+
cleanup();
|
|
139
|
+
currentSubscription = null;
|
|
140
|
+
return;
|
|
141
|
+
default:
|
|
142
|
+
throw new Error("unrecognized action " + action);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Creates and connects a "junction" stream to the specified emitter. Often used with [[pipe]], to avoid the multiple evaluation of operator sets.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* const foo = stream<number>();
|
|
151
|
+
*
|
|
152
|
+
* const fooX2 = pipe(
|
|
153
|
+
* foo,
|
|
154
|
+
* map((value) => {
|
|
155
|
+
* console.log(`multiplying ${value}`);
|
|
156
|
+
* return value * 2;
|
|
157
|
+
* })
|
|
158
|
+
* );
|
|
159
|
+
*
|
|
160
|
+
* subscribe(fooX2, (value) => console.log(value));
|
|
161
|
+
* subscribe(fooX2, (value) => console.log(value));
|
|
162
|
+
*
|
|
163
|
+
* publish(foo, 42); // executes the map operator twice for each subscription.
|
|
164
|
+
*
|
|
165
|
+
* const sharedFooX2 = streamFromEmitter(pipe(
|
|
166
|
+
* foo,
|
|
167
|
+
* map((value) => {
|
|
168
|
+
* console.log(`shared multiplying ${value}`);
|
|
169
|
+
* return value * 2;
|
|
170
|
+
* })
|
|
171
|
+
* ));
|
|
172
|
+
*
|
|
173
|
+
* subscribe(sharedFooX2, (value) => console.log(value));
|
|
174
|
+
* subscribe(sharedFooX2, (value) => console.log(value));
|
|
175
|
+
*
|
|
176
|
+
* publish(foo, 42);
|
|
177
|
+
*```
|
|
178
|
+
* @returns the resulting stream.
|
|
179
|
+
*/
|
|
180
|
+
export function streamFromEmitter(emitter) {
|
|
181
|
+
return tap(stream(), function (stream) { return connect(emitter, stream); });
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Creates and connects a "junction" stateful stream to the specified emitter. Often used with [[pipe]], to avoid the multiple evaluation of operator sets.
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* const foo = stream<number>();
|
|
188
|
+
*
|
|
189
|
+
* const fooX2 = pipe(
|
|
190
|
+
* foo,
|
|
191
|
+
* map((value) => {
|
|
192
|
+
* console.log(`multiplying ${value}`);
|
|
193
|
+
* return value * 2;
|
|
194
|
+
* })
|
|
195
|
+
* );
|
|
196
|
+
*
|
|
197
|
+
* subscribe(fooX2, (value) => console.log(value));
|
|
198
|
+
* subscribe(fooX2, (value) => console.log(value));
|
|
199
|
+
*
|
|
200
|
+
* publish(foo, 42); // executes the map operator twice for each subscription.
|
|
201
|
+
*
|
|
202
|
+
* const sharedFooX2 = statefulStreamFromEmitter(pipe(
|
|
203
|
+
* foo,
|
|
204
|
+
* map((value) => {
|
|
205
|
+
* console.log(`shared multiplying ${value}`);
|
|
206
|
+
* return value * 2;
|
|
207
|
+
* })
|
|
208
|
+
* ), 42);
|
|
209
|
+
*
|
|
210
|
+
* subscribe(sharedFooX2, (value) => console.log(value));
|
|
211
|
+
* subscribe(sharedFooX2, (value) => console.log(value));
|
|
212
|
+
*
|
|
213
|
+
* publish(foo, 42);
|
|
214
|
+
*```
|
|
215
|
+
* @param initial the initial value in the stream.
|
|
216
|
+
* @returns the resulting stateful stream.
|
|
217
|
+
*/
|
|
218
|
+
export function statefulStreamFromEmitter(emitter, initial) {
|
|
219
|
+
return tap(statefulStream(initial), function (stream) { return connect(emitter, stream); });
|
|
220
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `system` defines a specification of a system - its constructor, dependencies and if it should act as a singleton in a system dependency tree.
|
|
3
|
+
* When called, system returns a [[SystemSpec]], which is then initialized along with its dependencies by passing it to [[init]].
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* @import { subscribe, publish, system, init, tup, connect, map, pipe } from 'urx'
|
|
7
|
+
*
|
|
8
|
+
* // a simple system with two streams
|
|
9
|
+
* const sys1 = system(() => {
|
|
10
|
+
* const a = stream<number>()
|
|
11
|
+
* const b = stream<number>()
|
|
12
|
+
*
|
|
13
|
+
* connect(pipe(a, map(value => value * 2)), b)
|
|
14
|
+
* return { a, b }
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* // a second system which depends on the streams from the first one
|
|
18
|
+
* const sys2 = system(([ {a, b} ]) => {
|
|
19
|
+
* const c = stream<number>()
|
|
20
|
+
* connect(pipe(b, map(value => value * 2)), c)
|
|
21
|
+
* // re-export the `a` stream, keep `b` internal
|
|
22
|
+
* return { a, c }
|
|
23
|
+
* }, tup(sys1))
|
|
24
|
+
*
|
|
25
|
+
* // init will recursively initialize sys2 dependencies, in this case sys1
|
|
26
|
+
* const { a, c } = init(sys2)
|
|
27
|
+
* subscribe(c, c => console.log(`Value multiplied by 4`, c))
|
|
28
|
+
* publish(a, 2)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* #### Singletons in Dependency Tree
|
|
32
|
+
*
|
|
33
|
+
* By default, systems will be initialized only once if encountered multiple times in the dependency tree.
|
|
34
|
+
* In the below dependency system tree, systems `b` and `c` will receive the same stream instances from system `a` when system `d` is initialized.
|
|
35
|
+
* ```txt
|
|
36
|
+
* a
|
|
37
|
+
* / \
|
|
38
|
+
* b c
|
|
39
|
+
* \ /
|
|
40
|
+
* d
|
|
41
|
+
* ```
|
|
42
|
+
* If `a` gets `{singleton: false}` as a last argument, `init` creates two separate instances - one for `b` and one for `c`.
|
|
43
|
+
*
|
|
44
|
+
* @param constructor the system constructor function. Initialize and connect the streams in its body.
|
|
45
|
+
*
|
|
46
|
+
* @param dependencies the system dependencies, which the constructor will receive as arguments.
|
|
47
|
+
* Use the [[tup]] utility **For TypeScript type inference to work correctly**.
|
|
48
|
+
* ```ts
|
|
49
|
+
* const sys3 = system(() => { ... }, tup(sys2, sys1))
|
|
50
|
+
* ```
|
|
51
|
+
* @param __namedParameters Options
|
|
52
|
+
* @param singleton determines if the system will act as a singleton in a system dependency tree. `true` by default.
|
|
53
|
+
*/
|
|
54
|
+
export function system(constructor, dependencies, _a) {
|
|
55
|
+
if (dependencies === void 0) { dependencies = []; }
|
|
56
|
+
var singleton = (_a === void 0 ? { singleton: true } : _a).singleton;
|
|
57
|
+
return {
|
|
58
|
+
id: id(),
|
|
59
|
+
constructor: constructor,
|
|
60
|
+
dependencies: dependencies,
|
|
61
|
+
singleton: singleton,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** @internal */
|
|
65
|
+
var id = function () { return Symbol(); };
|
|
66
|
+
/**
|
|
67
|
+
* Initializes a [[SystemSpec]] by recursively initializing its dependencies.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* // a simple system with two streams
|
|
71
|
+
* const sys1 = system(() => {
|
|
72
|
+
* const a = stream<number>()
|
|
73
|
+
* const b = stream<number>()
|
|
74
|
+
*
|
|
75
|
+
* connect(pipe(a, map(value => value * 2)), b)
|
|
76
|
+
* return { a, b }
|
|
77
|
+
* })
|
|
78
|
+
*
|
|
79
|
+
* const { a, b } = init(sys1)
|
|
80
|
+
* subscribe(b, b => console.log(b))
|
|
81
|
+
* publish(a, 2)
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @returns the [[System]] constructed by the spec constructor.
|
|
85
|
+
* @param systemSpec the system spec to initialize.
|
|
86
|
+
*/
|
|
87
|
+
export function init(systemSpec) {
|
|
88
|
+
var singletons = new Map();
|
|
89
|
+
var _init = function (_a) {
|
|
90
|
+
var id = _a.id, constructor = _a.constructor, dependencies = _a.dependencies, singleton = _a.singleton;
|
|
91
|
+
if (singleton && singletons.has(id)) {
|
|
92
|
+
return singletons.get(id);
|
|
93
|
+
}
|
|
94
|
+
var system = constructor(dependencies.map(function (e) { return _init(e); }));
|
|
95
|
+
if (singleton) {
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
97
|
+
singletons.set(id, system);
|
|
98
|
+
}
|
|
99
|
+
return system;
|
|
100
|
+
};
|
|
101
|
+
return _init(systemSpec);
|
|
102
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { __read, __spread } from "tslib";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
5
|
+
/**
|
|
6
|
+
* Transformers change and combine streams, similar to operators.
|
|
7
|
+
* urx comes with two combinators - [[combineLatest]] and [[merge]], and one convenience filter - [[duc]].
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import { publish, reset, subscribe } from './actions';
|
|
12
|
+
import { RESET, SUBSCRIBE } from './constants';
|
|
13
|
+
import { defaultComparator, distinctUntilChanged, pipe } from './pipe';
|
|
14
|
+
import { stream } from './streams';
|
|
15
|
+
import { joinProc } from './utils';
|
|
16
|
+
/**
|
|
17
|
+
* Merges one or more emitters from the same type into a new Emitter which emits values from any of the source emitters.
|
|
18
|
+
* ```ts
|
|
19
|
+
* const foo = stream<number>()
|
|
20
|
+
* const bar = stream<number>()
|
|
21
|
+
*
|
|
22
|
+
* subscribe(merge(foo, bar), (value) => console.log(value)) // 42, 43
|
|
23
|
+
*
|
|
24
|
+
* publish(foo, 42)
|
|
25
|
+
* publish(bar, 43)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function merge() {
|
|
29
|
+
var sources = [];
|
|
30
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
|
+
sources[_i] = arguments[_i];
|
|
32
|
+
}
|
|
33
|
+
return function (action, subscription) {
|
|
34
|
+
switch (action) {
|
|
35
|
+
case SUBSCRIBE:
|
|
36
|
+
return joinProc.apply(void 0, __spread(sources.map(function (source) { return subscribe(source, subscription); })));
|
|
37
|
+
case RESET:
|
|
38
|
+
// do nothing, we are stateless
|
|
39
|
+
return;
|
|
40
|
+
default:
|
|
41
|
+
throw new Error("unrecognized action " + action);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A convenience wrapper that emits only the distinct values from the passed Emitter. Wraps [[pipe]] and [[distinctUntilChanged]].
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* const foo = stream<number>()
|
|
50
|
+
*
|
|
51
|
+
* // this line...
|
|
52
|
+
* const a = duc(foo)
|
|
53
|
+
*
|
|
54
|
+
* // is equivalent to this
|
|
55
|
+
* const b = pipe(distinctUntilChanged(foo))
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param source The source emitter.
|
|
59
|
+
* @param comparator optional custom comparison function for the two values.
|
|
60
|
+
*
|
|
61
|
+
* @typeParam T the type of the value emitted by the source.
|
|
62
|
+
*
|
|
63
|
+
* @returns the resulting emitter.
|
|
64
|
+
*/
|
|
65
|
+
export function duc(source, comparator) {
|
|
66
|
+
if (comparator === void 0) { comparator = defaultComparator; }
|
|
67
|
+
return pipe(source, distinctUntilChanged(comparator));
|
|
68
|
+
}
|
|
69
|
+
export function combineLatest() {
|
|
70
|
+
var emitters = [];
|
|
71
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
72
|
+
emitters[_i] = arguments[_i];
|
|
73
|
+
}
|
|
74
|
+
var innerSubject = stream();
|
|
75
|
+
var values = new Array(emitters.length);
|
|
76
|
+
var called = 0;
|
|
77
|
+
var allCalled = Math.pow(2, emitters.length) - 1;
|
|
78
|
+
emitters.forEach(function (source, index) {
|
|
79
|
+
var bit = Math.pow(2, index);
|
|
80
|
+
subscribe(source, function (value) {
|
|
81
|
+
values[index] = value;
|
|
82
|
+
called = called | bit;
|
|
83
|
+
if (called === allCalled) {
|
|
84
|
+
publish(innerSubject, values);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
return function (action, subscription) {
|
|
89
|
+
switch (action) {
|
|
90
|
+
case SUBSCRIBE:
|
|
91
|
+
if (called === allCalled) {
|
|
92
|
+
subscription(values);
|
|
93
|
+
}
|
|
94
|
+
return subscribe(innerSubject, subscription);
|
|
95
|
+
case RESET:
|
|
96
|
+
return reset(innerSubject);
|
|
97
|
+
default:
|
|
98
|
+
throw new Error("unrecognized action " + action);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utils includes
|
|
3
|
+
* - a handful of functional utilities inspired by or taken from the [Ramda library](https://ramdajs.com/);
|
|
4
|
+
* - TypeScript crutches - the [[tup]] function.
|
|
5
|
+
*
|
|
6
|
+
* Use these for your convenience - they are here so that urx is zero-dependency package.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Performs left to right composition of two functions.
|
|
12
|
+
*/
|
|
13
|
+
export function compose(a, b) {
|
|
14
|
+
return function (arg) { return a(b(arg)); };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Takes a value and applies a function to it.
|
|
18
|
+
*/
|
|
19
|
+
export function thrush(arg, proc) {
|
|
20
|
+
return proc(arg);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Takes a 2 argument function and partially applies the first argument.
|
|
24
|
+
*/
|
|
25
|
+
export function curry2to1(proc, arg1) {
|
|
26
|
+
return function (arg2) { return proc(arg1, arg2); };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Takes a 1 argument function and returns a function which when called, executes it with the provided argument.
|
|
30
|
+
*/
|
|
31
|
+
export function curry1to0(proc, arg) {
|
|
32
|
+
return function () { return proc(arg); };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns a function which extracts the property from from the passed object.
|
|
36
|
+
*/
|
|
37
|
+
export function prop(property) {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
39
|
+
return function (object) { return object[property]; };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Calls callback with the first argument, and returns it.
|
|
43
|
+
*/
|
|
44
|
+
export function tap(arg, proc) {
|
|
45
|
+
proc(arg);
|
|
46
|
+
return arg;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Utility function to help typescript figure out that what we pass is a tuple and not a generic array.
|
|
50
|
+
* Taken from (this StackOverflow tread)[https://stackoverflow.com/questions/49729550/implicitly-create-a-tuple-in-typescript/52445008#52445008]
|
|
51
|
+
*/
|
|
52
|
+
export function tup() {
|
|
53
|
+
var args = [];
|
|
54
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
55
|
+
args[_i] = arguments[_i];
|
|
56
|
+
}
|
|
57
|
+
return args;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Calls the passed function.
|
|
61
|
+
*/
|
|
62
|
+
export function call(proc) {
|
|
63
|
+
proc();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* returns a function which when called always returns the passed value
|
|
67
|
+
*/
|
|
68
|
+
export function always(value) {
|
|
69
|
+
return function () { return value; };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* returns a function which calls all passed functions in the passed order.
|
|
73
|
+
* joinProc does not pass arguments or collect return values.
|
|
74
|
+
*/
|
|
75
|
+
export function joinProc() {
|
|
76
|
+
var procs = [];
|
|
77
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
78
|
+
procs[_i] = arguments[_i];
|
|
79
|
+
}
|
|
80
|
+
return function () {
|
|
81
|
+
procs.map(call);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function isDefined(arg) {
|
|
85
|
+
return arg !== undefined;
|
|
86
|
+
}
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
88
|
+
export function noop() { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read } from "tslib";
|
|
2
|
-
import * as u from '
|
|
2
|
+
import * as u from './urx';
|
|
3
3
|
import { domIOSystem } from './domIOSystem';
|
|
4
4
|
export var windowScrollerSystem = u.system(function (_a) {
|
|
5
5
|
var _b = __read(_a, 1), _c = _b[0], scrollTo = _c.scrollTo, scrollContainerState = _c.scrollContainerState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
|
|
1
|
+
import { useForkRef as MuiUseForkRef, setRef as MuiSetRef, } from '@material-ui/core/utils';
|
|
2
2
|
/**
|
|
3
3
|
* That method will give you ability fork same value `ref object` or `method`
|
|
4
4
|
* Example:
|
|
@@ -17,3 +17,4 @@ import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export var useForkRef = MuiUseForkRef;
|
|
20
|
+
export var setRef = MuiSetRef;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
|
|
1
|
+
import { useForkRef as MuiUseForkRef, setRef as MuiSetRef } from '@material-ui/core/utils';
|
|
2
2
|
/**
|
|
3
3
|
* That method will give you ability fork same value `ref object` or `method`
|
|
4
4
|
* Example:
|
|
@@ -17,3 +17,4 @@ import { useForkRef as MuiUseForkRef } from '@material-ui/core/utils';
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export declare const useForkRef: typeof MuiUseForkRef;
|
|
20
|
+
export declare const setRef: typeof MuiSetRef;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ringcentral/juno",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.41.0",
|
|
4
4
|
"author": "RingCentral",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"focus-visible": "^5.1.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
29
|
"react-beautiful-dnd": "^13.0.0",
|
|
30
|
-
"react-virtuoso": "^
|
|
30
|
+
"react-virtuoso": "^4.6.2",
|
|
31
31
|
"resize-observer-polyfill": "^1.5.1",
|
|
32
32
|
"typeface-lato": "^0.0.75",
|
|
33
33
|
"type-fest": "^2.12.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './react-virtuoso';
|