@perses-dev/core 0.7.0 → 0.8.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/dist/cjs/model/time.js +28 -5
- package/dist/cjs/utils/event.js +30 -0
- package/dist/cjs/utils/index.js +2 -1
- package/dist/cjs/utils/panel-refs.js +1 -1
- package/dist/model/dashboard.d.ts +1 -1
- package/dist/model/dashboard.d.ts.map +1 -1
- package/dist/model/time.d.ts +10 -2
- package/dist/model/time.d.ts.map +1 -1
- package/dist/model/time.js +1 -1
- package/dist/model/variables.d.ts +36 -18
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/utils/event.d.ts +8 -0
- package/dist/utils/event.d.ts.map +1 -0
- package/dist/utils/event.js +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/panel-refs.d.ts +4 -1
- package/dist/utils/panel-refs.d.ts.map +1 -1
- package/dist/utils/panel-refs.js +1 -1
- package/package.json +3 -3
package/dist/cjs/model/time.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2022 The Perses Authors
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
5
5
|
// You may obtain a copy of the License at
|
|
@@ -12,15 +12,22 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getSuggestedStepMs = exports.isDurationString = exports.parseDurationString = exports.toAbsoluteTimeRange = exports.
|
|
15
|
+
exports.getDefaultTimeRange = exports.getSuggestedStepMs = exports.isDurationString = exports.parseDurationString = exports.toAbsoluteTimeRange = exports.isAbsoluteTimeRange = exports.isRelativeTimeRange = void 0;
|
|
16
16
|
const date_fns_1 = require("date-fns");
|
|
17
17
|
/**
|
|
18
|
-
* Determine whether a given time range is relative
|
|
18
|
+
* Determine whether a given time range is relative
|
|
19
19
|
*/
|
|
20
|
-
function
|
|
20
|
+
function isRelativeTimeRange(timeRange) {
|
|
21
21
|
return timeRange.pastDuration !== undefined;
|
|
22
22
|
}
|
|
23
|
-
exports.
|
|
23
|
+
exports.isRelativeTimeRange = isRelativeTimeRange;
|
|
24
|
+
/**
|
|
25
|
+
* Determine whether a given time range is absolute
|
|
26
|
+
*/
|
|
27
|
+
function isAbsoluteTimeRange(timeRange) {
|
|
28
|
+
return timeRange.start !== undefined && timeRange.end !== undefined;
|
|
29
|
+
}
|
|
30
|
+
exports.isAbsoluteTimeRange = isAbsoluteTimeRange;
|
|
24
31
|
/**
|
|
25
32
|
* Returns an absolute time range from a RelativeTimeRange.
|
|
26
33
|
*/
|
|
@@ -74,3 +81,19 @@ function getSuggestedStepMs(timeRange, width) {
|
|
|
74
81
|
return Math.floor(queryRangeMs / width);
|
|
75
82
|
}
|
|
76
83
|
exports.getSuggestedStepMs = getSuggestedStepMs;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the default time range taking into account URL params
|
|
86
|
+
*/
|
|
87
|
+
function getDefaultTimeRange(dashboardDuration, queryString) {
|
|
88
|
+
const startParam = queryString.get('start');
|
|
89
|
+
const endParam = queryString.get('end');
|
|
90
|
+
if (startParam === null) {
|
|
91
|
+
// use relative time range from dashboard definition if start param is empty
|
|
92
|
+
return { pastDuration: dashboardDuration };
|
|
93
|
+
}
|
|
94
|
+
// convert query param format to RelativeTimeRange or AbsoluteTimeRange
|
|
95
|
+
return isDurationString(startParam)
|
|
96
|
+
? { pastDuration: startParam }
|
|
97
|
+
: { start: new Date(Number(startParam)), end: new Date(Number(endParam)) };
|
|
98
|
+
}
|
|
99
|
+
exports.getDefaultTimeRange = getDefaultTimeRange;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useEvent = void 0;
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
/**
|
|
18
|
+
* A (temporary) userland implementation of `useEvent` from this React RFC: https://github.com/reactjs/rfcs/pull/220.
|
|
19
|
+
*
|
|
20
|
+
* Typically useful for getting a stable reference to an "event" function (i.e. one that isn't called during render
|
|
21
|
+
* but is called later in a useEffect or event handler) that accesses state or props.
|
|
22
|
+
*/
|
|
23
|
+
function useEvent(handler) {
|
|
24
|
+
const handlerRef = (0, react_1.useRef)(handler);
|
|
25
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
26
|
+
handlerRef.current = handler;
|
|
27
|
+
});
|
|
28
|
+
return (0, react_1.useCallback)((...args) => handlerRef.current(...args), []);
|
|
29
|
+
}
|
|
30
|
+
exports.useEvent = useEvent;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2022 The Perses Authors
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
5
5
|
// You may obtain a copy of the License at
|
|
@@ -26,6 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
__exportStar(require("./event"), exports);
|
|
29
30
|
__exportStar(require("./fetch"), exports);
|
|
30
31
|
__exportStar(require("./memo"), exports);
|
|
31
32
|
__exportStar(require("./panel-refs"), exports);
|
|
@@ -23,6 +23,6 @@ function resolvePanelRef(spec, panelRef) {
|
|
|
23
23
|
if (panelDefinition === undefined) {
|
|
24
24
|
throw new Error(`Could not resolve panels reference ${panelRef.$ref}`);
|
|
25
25
|
}
|
|
26
|
-
return panelDefinition;
|
|
26
|
+
return { panelDefinition, panelsKey };
|
|
27
27
|
}
|
|
28
28
|
exports.resolvePanelRef = resolvePanelRef;
|
|
@@ -16,7 +16,7 @@ export interface DashboardResource {
|
|
|
16
16
|
export interface DashboardSpec {
|
|
17
17
|
datasource: DatasourceSelector;
|
|
18
18
|
duration: DurationString;
|
|
19
|
-
variables:
|
|
19
|
+
variables: VariableDefinition[];
|
|
20
20
|
layouts: LayoutDefinition[];
|
|
21
21
|
panels: Record<string, PanelDefinition>;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/model/dashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/model/dashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACzC"}
|
package/dist/model/time.d.ts
CHANGED
|
@@ -11,9 +11,13 @@ export interface RelativeTimeRange {
|
|
|
11
11
|
}
|
|
12
12
|
export declare type TimeRangeValue = AbsoluteTimeRange | RelativeTimeRange;
|
|
13
13
|
/**
|
|
14
|
-
* Determine whether a given time range is relative
|
|
14
|
+
* Determine whether a given time range is relative
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function isRelativeTimeRange(timeRange: TimeRangeValue): timeRange is RelativeTimeRange;
|
|
17
|
+
/**
|
|
18
|
+
* Determine whether a given time range is absolute
|
|
19
|
+
*/
|
|
20
|
+
export declare function isAbsoluteTimeRange(timeRange: TimeRangeValue): timeRange is AbsoluteTimeRange;
|
|
17
21
|
/**
|
|
18
22
|
* Returns an absolute time range from a RelativeTimeRange.
|
|
19
23
|
*/
|
|
@@ -39,5 +43,9 @@ export declare function isDurationString(maybeDuration: string): maybeDuration i
|
|
|
39
43
|
* Gets a suggested step/interval size for a time range based on the width of a visual component.
|
|
40
44
|
*/
|
|
41
45
|
export declare function getSuggestedStepMs(timeRange: AbsoluteTimeRange, width: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* Gets the default time range taking into account URL params
|
|
48
|
+
*/
|
|
49
|
+
export declare function getDefaultTimeRange(dashboardDuration: DurationString, queryString: URLSearchParams): TimeRangeValue;
|
|
42
50
|
export {};
|
|
43
51
|
//# sourceMappingURL=time.d.ts.map
|
package/dist/model/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAO,MAAM,UAAU,CAAC;AAEzC,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,oBAAY,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,iBAAiB;IAEhC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,oBAAY,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAEnE;;GAEG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAO,MAAM,UAAU,CAAC;AAEzC,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,oBAAY,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,iBAAiB;IAEhC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,oBAAY,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAEnE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,cAAc,GAAG,SAAS,IAAI,iBAAiB,CAE7F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,cAAc,GAAG,SAAS,IAAI,iBAAiB,CAE7F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,CAOnF;AAED,aAAK,0BAA0B,GAAG,GAAG,MAAM,IAAI,CAAC;AAChD,aAAK,qBAAqB,GAAG,GAAG,MAAM,GAAG,CAAC;AAC1C,aAAK,qBAAqB,GAAG,GAAG,MAAM,GAAG,CAAC;AAC1C,aAAK,mBAAmB,GAAG,GAAG,MAAM,GAAG,CAAC;AACxC,aAAK,kBAAkB,GAAG,GAAG,MAAM,GAAG,CAAC;AACvC,aAAK,mBAAmB,GAAG,GAAG,MAAM,GAAG,CAAC;AACxC,aAAK,mBAAmB,GAAG,GAAG,MAAM,GAAG,CAAC;AAExC,oBAAY,cAAc,GAAG,OAAO,CAClC,GAAG,mBAAmB,GAAG,EAAE,GAAG,mBAAmB,GAAG,EAAE,GAAG,kBAAkB,GAAG,EAAE,GAAG,mBAAmB,GAAG,EAAE,GACvG,qBAAqB,GACrB,EAAE,GAAG,qBAAqB,GAAG,EAAE,GAAG,0BAA0B,GAAG,EAAE,EAAE,EACvE,EAAE,CACH,CAAC;AAIF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,QAAQ,CAepE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,IAAI,cAAc,CAGvF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,UAK7E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,GAAG,cAAc,CAanH"}
|
package/dist/model/time.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sub}from"date-fns";export function
|
|
1
|
+
import{sub}from"date-fns";export function isRelativeTimeRange(t){return void 0!==t.pastDuration}export function isAbsoluteTimeRange(t){return void 0!==t.start&&void 0!==t.end}export function toAbsoluteTimeRange(t){var n;const e=null!==(n=t.end)&&void 0!==n?n:new Date;return{start:sub(e,parseDurationString(t.pastDuration)),end:e}}const DURATION_REGEX=/^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;export function parseDurationString(t){var n,e,r,o,s,a,i;const u=DURATION_REGEX.exec(t);if(null===u)throw new Error(`Invalid duration string '${t}'`);return{years:parseInt(null!==(n=u[1])&&void 0!==n?n:"0"),months:0,weeks:parseInt(null!==(e=u[2])&&void 0!==e?e:"0"),days:parseInt(null!==(r=u[3])&&void 0!==r?r:"0"),hours:parseInt(null!==(o=u[4])&&void 0!==o?o:"0"),minutes:parseInt(null!==(s=u[5])&&void 0!==s?s:"0"),seconds:parseInt(null!==(a=u[6])&&void 0!==a?a:"0")+parseInt(null!==(i=u[7])&&void 0!==i?i:"0")/1e3}}export function isDurationString(t){return""!==t&&DURATION_REGEX.test(t)}export function getSuggestedStepMs(t,n){const e=t.end.valueOf()-t.start.valueOf();return Math.floor(e/n)}export function getDefaultTimeRange(t,n){const e=n.get("start"),r=n.get("end");return null===e?{pastDuration:t}:isDurationString(e)?{pastDuration:e}:{start:new Date(Number(e)),end:new Date(Number(r))}}
|
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
import { Definition, JsonObject } from './definitions';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
hide?: boolean;
|
|
2
|
+
export declare const DEFAULT_ALL_VALUE: "$__all";
|
|
3
|
+
export declare type VariableName = string;
|
|
4
|
+
export declare type VariableState = {
|
|
5
|
+
value: VariableValue;
|
|
6
|
+
options?: VariableOption[];
|
|
7
|
+
loading: boolean;
|
|
8
|
+
error?: Error;
|
|
9
|
+
};
|
|
10
|
+
export declare type VariableOption = {
|
|
12
11
|
label: string;
|
|
13
|
-
|
|
14
|
-
export declare type VariableSelectionOptions = SingleSelectOptions | MultiSelectOptions;
|
|
15
|
-
export declare type SingleSelectOptions = {
|
|
16
|
-
default_value: string;
|
|
12
|
+
value: string;
|
|
17
13
|
};
|
|
18
|
-
export declare type
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
export declare type VariableStateMap = Record<VariableName, VariableState>;
|
|
15
|
+
export declare type VariableValue = string | string[] | null;
|
|
16
|
+
export interface Variable<Kind extends string, Options extends JsonObject = JsonObject> extends Definition<Options> {
|
|
17
|
+
kind: Kind;
|
|
18
|
+
name: VariableName;
|
|
19
|
+
display?: {
|
|
20
|
+
label?: string;
|
|
21
|
+
hidden?: boolean;
|
|
22
|
+
};
|
|
23
|
+
defaultValue?: VariableValue;
|
|
24
|
+
options: Options;
|
|
25
|
+
}
|
|
26
|
+
export interface TextVariableOptions extends JsonObject {
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
export declare type TextVariableDefinition = Variable<'TextVariable', TextVariableOptions>;
|
|
30
|
+
export declare type ListVariableOptions<Options extends JsonObject> = {
|
|
31
|
+
allowMultiple?: boolean;
|
|
32
|
+
allowAllValue?: boolean;
|
|
33
|
+
customAllValue?: string;
|
|
34
|
+
optionsLoader: {
|
|
35
|
+
kind: string;
|
|
36
|
+
options: Options;
|
|
37
|
+
};
|
|
21
38
|
};
|
|
22
|
-
export declare
|
|
39
|
+
export declare type ListVariableDefinition<Options extends JsonObject = JsonObject> = Variable<'ListVariable', ListVariableOptions<Options>>;
|
|
40
|
+
export declare type VariableDefinition = TextVariableDefinition | ListVariableDefinition;
|
|
23
41
|
//# sourceMappingURL=variables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEvD,eAAO,MAAM,iBAAiB,UAAoB,CAAC;AAEnD,oBAAY,YAAY,GAAG,MAAM,CAAC;AAElC,oBAAY,aAAa,GAAG;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,oBAAY,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,oBAAY,gBAAgB,GAAG,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAEnE,oBAAY,aAAa,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;AAErD,MAAM,WAAW,QAAQ,CAAC,IAAI,SAAS,MAAM,EAAE,OAAO,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,UAAU,CAAC,OAAO,CAAC;IACjH,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,sBAAsB,GAAG,QAAQ,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;AAEnF,oBAAY,mBAAmB,CAAC,OAAO,SAAS,UAAU,IAAI;IAC5D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,oBAAY,sBAAsB,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI,QAAQ,CACpF,cAAc,EACd,mBAAmB,CAAC,OAAO,CAAC,CAC7B,CAAC;AAGF,oBAAY,kBAAkB,GAAG,sBAAsB,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A (temporary) userland implementation of `useEvent` from this React RFC: https://github.com/reactjs/rfcs/pull/220.
|
|
3
|
+
*
|
|
4
|
+
* Typically useful for getting a stable reference to an "event" function (i.e. one that isn't called during render
|
|
5
|
+
* but is called later in a useEffect or event handler) that accesses state or props.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useEvent<T extends unknown[], U>(handler: (...args: T) => U): (...args: T) => U;
|
|
8
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/utils/event.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAO9F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef,useLayoutEffect,useCallback}from"react";export function useEvent(e){const t=useRef(e);return useLayoutEffect((()=>{t.current=e})),useCallback(((...e)=>t.current(...e)),[])}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./fetch";export*from"./memo";export*from"./panel-refs";
|
|
1
|
+
export*from"./event";export*from"./fetch";export*from"./memo";export*from"./panel-refs";
|
|
@@ -3,5 +3,8 @@ import { DashboardSpec, PanelRef } from '../model';
|
|
|
3
3
|
* Resolve a PanelRef (JSON reference) against the provided DashboardSpec to
|
|
4
4
|
* a PanelDefinition.
|
|
5
5
|
*/
|
|
6
|
-
export declare function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef):
|
|
6
|
+
export declare function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef): {
|
|
7
|
+
panelDefinition: import("../model").PanelDefinition<import("../model").JsonObject>;
|
|
8
|
+
panelsKey: string;
|
|
9
|
+
};
|
|
7
10
|
//# sourceMappingURL=panel-refs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-refs.d.ts","sourceRoot":"","sources":["../../src/utils/panel-refs.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ
|
|
1
|
+
{"version":3,"file":"panel-refs.d.ts","sourceRoot":"","sources":["../../src/utils/panel-refs.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ;;;EAOtE"}
|
package/dist/utils/panel-refs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function resolvePanelRef(e,
|
|
1
|
+
export function resolvePanelRef(e,n){const r=n.$ref.substring(14),o=e.panels[r];if(void 0===o)throw new Error(`Could not resolve panels reference ${n.$ref}`);return{panelDefinition:o,panelsKey:r}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Core functionality consumed by both the Perses UI and plugins",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"lodash-es": "^4.17.21"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react
|
|
31
|
-
"react": "^17.0.2"
|
|
30
|
+
"react": "^17.0.2 || ^18.0.0",
|
|
31
|
+
"react-dom": "^17.0.2 || ^18.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/lodash-es": "^4.17.6"
|