@rfkit/charts 1.8.0 → 1.8.2
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/EventBus/tools.d.ts +2 -2
- package/index.js +34 -16
- package/package.json +1 -1
- package/utils/subscription.d.ts +3 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { TopRightBottomLeft } from '../../types';
|
|
2
|
-
import { type CSMCallback } from '../../utils/subscription';
|
|
2
|
+
import { type ConsumableCSMCallback, type CSMCallback } from '../../utils/subscription';
|
|
3
3
|
import { type EventPositionSource } from './position';
|
|
4
4
|
export declare function getEID(id: string): string;
|
|
5
5
|
export declare const createMoveEventManager: (id: string, name?: string, func?: CSMCallback) => (...args: any[]) => void;
|
|
6
6
|
export declare const createMouseDownEventManager: (id: string, name?: string, func?: CSMCallback) => (...args: any[]) => void;
|
|
7
|
-
export declare const createDoubleClickEventManager: (id: string, name?: string, func?:
|
|
7
|
+
export declare const createDoubleClickEventManager: (id: string, name?: string, func?: ConsumableCSMCallback) => (...args: any[]) => void;
|
|
8
8
|
export declare const createMouseUpEventManager: (id: string, name?: string, func?: CSMCallback) => (...args: any[]) => void;
|
|
9
9
|
export declare const createMouseLeaveEventManager: (id: string, name?: string, func?: CSMCallback) => (...args: any[]) => void;
|
|
10
10
|
export declare const createMouseEnterEventManager: (id: string, name?: string, func?: CSMCallback) => (...args: any[]) => void;
|
package/index.js
CHANGED
|
@@ -4235,6 +4235,19 @@ function subscription_createSubscriptionManager(id, name, func, owner) {
|
|
|
4235
4235
|
for(const key in funcs)funcs[key](...args);
|
|
4236
4236
|
};
|
|
4237
4237
|
}
|
|
4238
|
+
function createConsumableSubscriptionManager(id, getPriority, name, func, owner) {
|
|
4239
|
+
if ('function' == typeof func && name) return subscription_createSubscriptionManager(id, name, func, owner);
|
|
4240
|
+
return (...args)=>{
|
|
4241
|
+
const funcs = subscription_subscriptions[id];
|
|
4242
|
+
if (!funcs) return false;
|
|
4243
|
+
const subscriberNames = Object.keys(funcs).sort((left, right)=>getPriority(right) - getPriority(left));
|
|
4244
|
+
for (const subscriberName of subscriberNames){
|
|
4245
|
+
const handled = funcs[subscriberName](...args);
|
|
4246
|
+
if (true === handled) return true;
|
|
4247
|
+
}
|
|
4248
|
+
return false;
|
|
4249
|
+
};
|
|
4250
|
+
}
|
|
4238
4251
|
const getPublishSubscriptionKey = (globalID)=>`PUB_SUB-${globalID}`;
|
|
4239
4252
|
const getModuleSubscriptionKey = (globalID, moduleName)=>`passThrough-${globalID}-${moduleName}`;
|
|
4240
4253
|
const getDatabaseStorageKey = (globalID)=>`withDatabase-${globalID}`;
|
|
@@ -21101,7 +21114,7 @@ function generateRecursiveId(id, func) {
|
|
|
21101
21114
|
}
|
|
21102
21115
|
const createMoveEventManager = (id, name, func)=>subscription_createSubscriptionManager(`${generateRecursiveId(id, func)}-createMoveEventManager`, name, func, id);
|
|
21103
21116
|
const createMouseDownEventManager = (id, name, func)=>subscription_createSubscriptionManager(`${generateRecursiveId(id, func)}-createMouseDownEventManager`, name, func, id);
|
|
21104
|
-
const createDoubleClickEventManager = (id, name, func)=>
|
|
21117
|
+
const createDoubleClickEventManager = (id, name, func)=>createConsumableSubscriptionManager(`${generateRecursiveId(id, func)}-createDoubleClickEventManager`, getEventPriority, name, func, id);
|
|
21105
21118
|
const createMouseUpEventManager = (id, name, func)=>subscription_createSubscriptionManager(`${generateRecursiveId(id, func)}-mouse-up`, name, func, id);
|
|
21106
21119
|
const createMouseLeaveEventManager = (id, name, func)=>subscription_createSubscriptionManager(`${generateRecursiveId(id, func)}-mouse-leave`, name, func, id);
|
|
21107
21120
|
const createMouseEnterEventManager = (id, name, func)=>subscription_createSubscriptionManager(`${generateRecursiveId(id, func)}-mouse-enter`, name, func, id);
|
|
@@ -21122,6 +21135,7 @@ const EVENT_PRIORITY_LEVELS = {
|
|
|
21122
21135
|
[constants_ToolType.Stripe]: 4,
|
|
21123
21136
|
[constants_ToolType.FrequencyTagLine]: 5
|
|
21124
21137
|
};
|
|
21138
|
+
const getEventPriority = (name)=>EVENT_PRIORITY_LEVELS[name] ?? 0;
|
|
21125
21139
|
const CURSOR_STYLE_MAP = {
|
|
21126
21140
|
[constants_ToolType.Markers]: 'all-scroll',
|
|
21127
21141
|
[constants_ToolType.Stripe]: 'col-resize',
|
|
@@ -22409,10 +22423,11 @@ function useEventBusCallback(id) {
|
|
|
22409
22423
|
const { state: { segments, axisX: { frequencyFormat }, eventBus: { onDoubleClick } } } = useStore_useStore();
|
|
22410
22424
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
22411
22425
|
const cleanupDoubleClick = createDoubleClickEventManager(id, useEventBusCallback_COMPONENT_KEY, (_, e)=>{
|
|
22412
|
-
if (!compareEventPriority(id, useEventBusCallback_COMPONENT_KEY)) return;
|
|
22426
|
+
if (!compareEventPriority(id, useEventBusCallback_COMPONENT_KEY)) return false;
|
|
22413
22427
|
const { left } = e;
|
|
22414
22428
|
const frequency = frequencyFormat?.(left) ?? '';
|
|
22415
22429
|
onDoubleClick(frequency, e);
|
|
22430
|
+
return true;
|
|
22416
22431
|
});
|
|
22417
22432
|
const cleanupMouseUp = createMouseUpEventManager(id, useEventBusCallback_COMPONENT_KEY, ()=>{
|
|
22418
22433
|
resetEventLevel(id, useEventBusCallback_COMPONENT_KEY);
|
|
@@ -26254,7 +26269,7 @@ const AXIS_LINE_WIDTH = LINE_WIDTH_BASE;
|
|
|
26254
26269
|
function useCanvasAxisY(options) {
|
|
26255
26270
|
const { ranging } = options;
|
|
26256
26271
|
const axisY = useStore_useSelector((state)=>state.axisY);
|
|
26257
|
-
const { range: axisYRange, disabled, placement } = axisY;
|
|
26272
|
+
const { range: axisYRange, disabled, placement, show } = axisY;
|
|
26258
26273
|
const inside = 'inside' === placement;
|
|
26259
26274
|
const canvasRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
26260
26275
|
const containerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
@@ -26300,7 +26315,9 @@ function useCanvasAxisY(options) {
|
|
|
26300
26315
|
});
|
|
26301
26316
|
resizeObserver.observe(container);
|
|
26302
26317
|
return ()=>resizeObserver.disconnect();
|
|
26303
|
-
}, [
|
|
26318
|
+
}, [
|
|
26319
|
+
show
|
|
26320
|
+
]);
|
|
26304
26321
|
const formatTickLabel = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((value1, formatStrategy)=>{
|
|
26305
26322
|
if (formatStrategy.useScientific) return value1.toExponential(1);
|
|
26306
26323
|
if (formatStrategy.useKFormat) {
|
|
@@ -26450,9 +26467,10 @@ function useCanvasAxisY(options) {
|
|
|
26450
26467
|
clampTickPosition
|
|
26451
26468
|
]);
|
|
26452
26469
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
26453
|
-
drawAxis();
|
|
26470
|
+
if (false !== show) drawAxis();
|
|
26454
26471
|
}, [
|
|
26455
|
-
drawAxis
|
|
26472
|
+
drawAxis,
|
|
26473
|
+
show
|
|
26456
26474
|
]);
|
|
26457
26475
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>subscribeChartsThemeChange(()=>{
|
|
26458
26476
|
drawAxis();
|
|
@@ -28353,16 +28371,16 @@ const useMarkerEvents = (props)=>{
|
|
|
28353
28371
|
if (marker?.id) onToggleSelect(marker.id);
|
|
28354
28372
|
});
|
|
28355
28373
|
const cleanupDoubleClick = createDoubleClickEventManager(id, useMarkerEvents_COMPONENT_KEY, (_, e)=>{
|
|
28356
|
-
if (!isShow || !compareEventPriority(id, useMarkerEvents_COMPONENT_KEY)) return;
|
|
28357
|
-
if (void 0
|
|
28358
|
-
|
|
28359
|
-
|
|
28360
|
-
|
|
28361
|
-
|
|
28362
|
-
|
|
28363
|
-
|
|
28364
|
-
|
|
28365
|
-
|
|
28374
|
+
if (!isShow || !compareEventPriority(id, useMarkerEvents_COMPONENT_KEY)) return false;
|
|
28375
|
+
if (void 0 === e.left) return false;
|
|
28376
|
+
const nearbyMarker = checkHover({
|
|
28377
|
+
left: e.left
|
|
28378
|
+
});
|
|
28379
|
+
if (nearbyMarker && 'object' == typeof nearbyMarker && nearbyMarker.id) onDeleteMarker(nearbyMarker.id);
|
|
28380
|
+
else onCreateMarker({
|
|
28381
|
+
left: e.left
|
|
28382
|
+
});
|
|
28383
|
+
return true;
|
|
28366
28384
|
});
|
|
28367
28385
|
return ()=>{
|
|
28368
28386
|
cleanupMove?.();
|
package/package.json
CHANGED
package/utils/subscription.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare function openData<T = unknown>(key: string, data: T | undefined,
|
|
|
23
23
|
* Note: Using any[] for callback args since this is a generic pub/sub system
|
|
24
24
|
* that can be called with various argument types across the codebase.
|
|
25
25
|
*/
|
|
26
|
-
export type CSMCallback = (...args: any[]) =>
|
|
26
|
+
export type CSMCallback<Return = void> = (...args: any[]) => Return;
|
|
27
27
|
interface Subscription {
|
|
28
28
|
[key: string]: CSMCallback;
|
|
29
29
|
}
|
|
@@ -31,6 +31,8 @@ interface ChartSubscriptions {
|
|
|
31
31
|
[id: string]: Subscription;
|
|
32
32
|
}
|
|
33
33
|
export declare function createSubscriptionManager(id: string, name?: string, func?: CSMCallback, owner?: string): (...args: any[]) => void;
|
|
34
|
+
export type ConsumableCSMCallback = CSMCallback<boolean | undefined>;
|
|
35
|
+
export declare function createConsumableSubscriptionManager(id: string, getPriority: (name: string) => number, name?: string, func?: ConsumableCSMCallback, owner?: string): (...args: any[]) => void;
|
|
34
36
|
export declare const getPublishSubscriptionKey: (globalID: string) => string;
|
|
35
37
|
export declare const getModuleSubscriptionKey: (globalID: string, moduleName: string) => string;
|
|
36
38
|
export declare const getDatabaseStorageKey: (globalID: string) => string;
|