@balena/ui-shared-components 13.0.0-build-rename-and-require-widget-extracontext-e171aab42694be794a4f90dd4cac672b0d41c56e-1 → 13.0.0-build-rename-and-require-widget-extracontext-37df890fe262ef54dc0d361d32b076c7eeccd84b-1
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/components/RJST/components/Widget/Formats/BooleanAsIconWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/CodeWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/DisabledTextWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/DurationWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/DurationWidget.js +1 -1
- package/dist/components/RJST/components/Widget/Formats/ElapsedTimeWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/ElapsedTimeWidget.js +4 -5
- package/dist/components/RJST/components/Widget/Formats/HashWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/PercentageWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/PlaceholderTextWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/TemperatureWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/TxtWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/Formats/TxtWidget.js +10 -2
- package/dist/components/RJST/components/Widget/Formats/WrapWidget.d.ts +1 -1
- package/dist/components/RJST/components/Widget/utils.d.ts +9 -5
- package/dist/components/RJST/components/Widget/utils.js +22 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const BooleanAsIconWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const BooleanAsIconWidget: import("../utils").Widget<object, object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CodeWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const CodeWidget: import("../utils").Widget<object, object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const DisabledTextWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const DisabledTextWidget: import("../utils").Widget<object, object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const DurationWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const DurationWidget: import("../utils").Widget<object, object>;
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { intervalToDuration } from 'date-fns';
|
|
4
4
|
import { JsonTypes, widgetFactory } from '../utils';
|
|
5
5
|
import { Typography } from '@mui/material';
|
|
6
|
-
export const DurationWidget = widgetFactory('Duration', [JsonTypes.object])(({ value
|
|
6
|
+
export const DurationWidget = widgetFactory('Duration', [JsonTypes.object])(({ value }) => {
|
|
7
7
|
const duration = React.useMemo(() => {
|
|
8
8
|
var _a, _b, _c;
|
|
9
9
|
if (!value.start || !value.end) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ElapsedTimeWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const ElapsedTimeWidget: import("../utils").Widget<object, object>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { JsonTypes, widgetFactory, formatTimestamp, timeSince } from '../utils';
|
|
2
|
+
import { UiOption, JsonTypes, widgetFactory, formatTimestamp, timeSince, } from '../utils';
|
|
3
3
|
import { Material, Tooltip } from '../../../../..';
|
|
4
4
|
const { Typography } = Material;
|
|
5
|
-
export const ElapsedTimeWidget = widgetFactory('ElapsedTime', [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
])(({ value }) => {
|
|
5
|
+
export const ElapsedTimeWidget = widgetFactory('ElapsedTime', [JsonTypes.string, JsonTypes.number], {
|
|
6
|
+
dtFormat: UiOption.string,
|
|
7
|
+
})(({ value }) => {
|
|
9
8
|
if (!value) {
|
|
10
9
|
return null;
|
|
11
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HashWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const HashWidget: import("../utils").Widget<object, object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PercentageWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const PercentageWidget: import("../utils").Widget<object, object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PlaceholderTextWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const PlaceholderTextWidget: import("../utils").Widget<object, object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const TemperatureWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const TemperatureWidget: import("../utils").Widget<object, object>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const TxtWidget: import("../utils").Widget<object>;
|
|
1
|
+
declare const TxtWidget: import("../utils").Widget<object, object>;
|
|
2
2
|
export default TxtWidget;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import invokeMap from 'lodash/invokeMap';
|
|
4
4
|
import isArray from 'lodash/isArray';
|
|
5
|
-
import { JsonTypes, widgetFactory, formatTimestamp } from '../utils';
|
|
5
|
+
import { UiOption, JsonTypes, widgetFactory, formatTimestamp } from '../utils';
|
|
6
6
|
import { Truncate } from '../../../../Truncate';
|
|
7
7
|
import { Typography } from '@mui/material';
|
|
8
8
|
const getArrayValue = (value, uiSchema) => {
|
|
@@ -26,7 +26,15 @@ const TxtWidget = widgetFactory('Txt', [
|
|
|
26
26
|
JsonTypes.number,
|
|
27
27
|
JsonTypes.boolean,
|
|
28
28
|
JsonTypes.array,
|
|
29
|
-
]
|
|
29
|
+
], {
|
|
30
|
+
dtFormat: UiOption.string,
|
|
31
|
+
align: Object.assign(Object.assign({}, UiOption.string), { enum: ['inherit', 'left', 'center', 'right', 'justify'] }),
|
|
32
|
+
gutterBottom: UiOption.bolean,
|
|
33
|
+
noWrap: UiOption.boolean,
|
|
34
|
+
paragraph: UiOption.boolean,
|
|
35
|
+
sx: UiOption.object,
|
|
36
|
+
variant: UiOption.string,
|
|
37
|
+
})(({ value, schema, uiSchema }) => {
|
|
30
38
|
var _a;
|
|
31
39
|
let displayValue = isArray(value)
|
|
32
40
|
? getArrayValue(value, uiSchema)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const WrapWidget: import("../utils").Widget<object>;
|
|
1
|
+
export declare const WrapWidget: import("../utils").Widget<object, object>;
|
|
@@ -21,11 +21,11 @@ export interface WidgetProps<T extends object = object> {
|
|
|
21
21
|
uiSchema?: UiSchema;
|
|
22
22
|
resource: T;
|
|
23
23
|
}
|
|
24
|
-
export interface Widget<T extends object = object> {
|
|
25
|
-
uiOptions?:
|
|
24
|
+
export interface Widget<T extends object = object, ExtraProps = object> {
|
|
25
|
+
uiOptions?: UiOptions;
|
|
26
26
|
supportedTypes?: string[];
|
|
27
27
|
displayName: string;
|
|
28
|
-
(props: WidgetProps<T>): JSX.Element | null;
|
|
28
|
+
(props: WidgetProps<T> & ExtraProps): JSX.Element | null;
|
|
29
29
|
}
|
|
30
30
|
export declare const JsonTypes: {
|
|
31
31
|
readonly array: "array";
|
|
@@ -45,9 +45,13 @@ export interface JsonTypesTypeMap {
|
|
|
45
45
|
boolean: boolean;
|
|
46
46
|
null: null;
|
|
47
47
|
}
|
|
48
|
-
export
|
|
48
|
+
export type UiOptions = {
|
|
49
|
+
[key: string]: JSONSchema;
|
|
50
|
+
};
|
|
51
|
+
export declare const UiOption: UiOptions;
|
|
52
|
+
export declare const widgetFactory: <ST extends Array<keyof JsonTypesTypeMap>>(displayName: string, supportedTypes: ST, uiOptions?: Widget["uiOptions"]) => <T extends object, ExtraProps extends object = object, V extends WidgetProps["value"] | null = JsonTypesTypeMap[ST[number]]>(widgetFn: (props: Overwrite<WidgetProps<T>, {
|
|
49
53
|
value: V;
|
|
50
|
-
}>) => JSX.Element | null) => Widget<T>;
|
|
54
|
+
}> & ExtraProps) => JSX.Element | null) => Widget<T, ExtraProps>;
|
|
51
55
|
export declare const formatTimestamp: (timestamp: string | number, uiSchema?: UiSchema) => string;
|
|
52
56
|
export declare const truncateHash: (str: string, maxLength?: number) => string;
|
|
53
57
|
export declare const timeSince: (timestamp: string | number, suffix?: boolean) => string;
|
|
@@ -12,14 +12,35 @@ export const JsonTypes = {
|
|
|
12
12
|
boolean: 'boolean',
|
|
13
13
|
null: 'null',
|
|
14
14
|
};
|
|
15
|
+
// Convenience object for common UI option schemas
|
|
16
|
+
export const UiOption = {
|
|
17
|
+
string: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
},
|
|
20
|
+
boolean: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
},
|
|
23
|
+
number: {
|
|
24
|
+
type: 'number',
|
|
25
|
+
},
|
|
26
|
+
integer: {
|
|
27
|
+
type: 'integer',
|
|
28
|
+
},
|
|
29
|
+
object: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
15
33
|
// TODO: Replace the HOF with a plain function once TS supports optional generic types
|
|
16
34
|
// See: https://github.com/microsoft/TypeScript/issues/14400
|
|
17
35
|
// TODO: convert the fn args to an object once we bump TS
|
|
18
|
-
export const widgetFactory = (displayName, supportedTypes
|
|
36
|
+
export const widgetFactory = (displayName, supportedTypes,
|
|
37
|
+
// TODO: Implement a way to pass these from RJST to widgets. Likely by adding a uiSchema property or something
|
|
38
|
+
uiOptions = {}) => {
|
|
19
39
|
return (widgetFn) => {
|
|
20
40
|
const widget = widgetFn;
|
|
21
41
|
Object.assign(widget, {
|
|
22
42
|
displayName,
|
|
43
|
+
uiOptions,
|
|
23
44
|
supportedTypes,
|
|
24
45
|
});
|
|
25
46
|
return widget;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/ui-shared-components",
|
|
3
|
-
"version": "13.0.0-build-rename-and-require-widget-extracontext-
|
|
3
|
+
"version": "13.0.0-build-rename-and-require-widget-extracontext-37df890fe262ef54dc0d361d32b076c7eeccd84b-1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"ajv": "^8.17.1",
|
|
33
33
|
"ajv-formats": "^3.0.1",
|
|
34
34
|
"ajv-keywords": "^5.1.0",
|
|
35
|
-
"analytics-client": "^3.
|
|
35
|
+
"analytics-client": "^3.1.0",
|
|
36
36
|
"color": "^5.0.0",
|
|
37
37
|
"color-hash": "^2.0.2",
|
|
38
38
|
"date-fns": "^4.1.0",
|
|
@@ -138,6 +138,6 @@
|
|
|
138
138
|
},
|
|
139
139
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
140
140
|
"versionist": {
|
|
141
|
-
"publishedAt": "2025-05-
|
|
141
|
+
"publishedAt": "2025-05-15T18:17:53.484Z"
|
|
142
142
|
}
|
|
143
143
|
}
|