@balena/ui-shared-components 13.0.0-build-rename-and-require-widget-extracontext-78dd3d5eba302d57a47d7ebb0fbdd8793e82d77d-1 → 13.0.0-build-upgrade-storybook-9-438bc209db8ac0658743037813f035cdb3e395a8-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.
Files changed (26) hide show
  1. package/dist/components/DownloadImageDialog/ApplicationInstructions.js +28 -16
  2. package/dist/components/DownloadImageDialog/models.d.ts +32 -1
  3. package/dist/components/RJST/components/Widget/Formats/BooleanAsIconWidget.js +1 -1
  4. package/dist/components/RJST/components/Widget/Formats/CodeWidget.js +1 -1
  5. package/dist/components/RJST/components/Widget/Formats/DisabledTextWidget.js +1 -1
  6. package/dist/components/RJST/components/Widget/Formats/DurationWidget.d.ts +6 -1
  7. package/dist/components/RJST/components/Widget/Formats/DurationWidget.js +1 -1
  8. package/dist/components/RJST/components/Widget/Formats/ElapsedTimeWidget.js +2 -2
  9. package/dist/components/RJST/components/Widget/Formats/HashWidget.js +1 -1
  10. package/dist/components/RJST/components/Widget/Formats/PercentageWidget.js +1 -1
  11. package/dist/components/RJST/components/Widget/Formats/PlaceholderTextWidget.js +1 -1
  12. package/dist/components/RJST/components/Widget/Formats/TemperatureWidget.js +1 -1
  13. package/dist/components/RJST/components/Widget/Formats/TxtWidget.js +9 -9
  14. package/dist/components/RJST/components/Widget/Formats/WrapWidget.js +1 -1
  15. package/dist/components/RJST/components/Widget/index.d.ts +1 -1
  16. package/dist/components/RJST/components/Widget/index.js +2 -2
  17. package/dist/components/RJST/components/Widget/utils.d.ts +2 -2
  18. package/dist/components/RJST/components/Widget/utils.js +1 -3
  19. package/dist/components/RJST/index.d.ts +2 -2
  20. package/dist/components/RJST/index.js +3 -3
  21. package/dist/components/RJST/models/helpers.d.ts +5 -1
  22. package/dist/components/RJST/models/helpers.js +16 -1
  23. package/dist/components/TagManagementDialog/AddTagForm.js +3 -2
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +1 -1
  26. package/package.json +14 -14
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import has from 'lodash/has';
3
3
  import { interpolateMustache } from './utils';
4
4
  import { Box, List, Tab, Tabs, Typography } from '@mui/material';
5
- import { memo, useEffect, useState } from 'react';
5
+ import { memo, useEffect, useMemo, useState } from 'react';
6
6
  import { MUILinkWithTracking } from '../MUILinkWithTracking';
7
7
  import { OrderedListItem } from '../OrderedListItem';
8
8
  import { Markdown } from '../Markdown';
@@ -19,38 +19,50 @@ export const getUserOs = () => {
19
19
  }
20
20
  return 'Unknown';
21
21
  };
22
+ const dtJsonTocontractOsKeyMap = {
23
+ windows: 'Windows',
24
+ osx: 'MacOS',
25
+ linux: 'Linux',
26
+ };
22
27
  export const ApplicationInstructions = memo(function ApplicationInstructions({ deviceType, templateData, }) {
23
28
  var _a;
24
29
  const [currentOs, setCurrentOs] = useState(getUserOs());
25
- const hasOsSpecificInstructions = !Array.isArray(deviceType.instructions);
30
+ const instructions = useMemo(() => {
31
+ if ((deviceType === null || deviceType === void 0 ? void 0 : deviceType.instructions) == null ||
32
+ Array.isArray(deviceType.instructions) ||
33
+ typeof deviceType.instructions !== 'object') {
34
+ return deviceType === null || deviceType === void 0 ? void 0 : deviceType.instructions;
35
+ }
36
+ const instructionsByOs = deviceType.instructions;
37
+ return Object.fromEntries(Object.entries(instructionsByOs).map(([key, value]) => {
38
+ const normalizedKey = key in dtJsonTocontractOsKeyMap
39
+ ? dtJsonTocontractOsKeyMap[key]
40
+ : key;
41
+ return [normalizedKey, value];
42
+ }));
43
+ }, [deviceType === null || deviceType === void 0 ? void 0 : deviceType.instructions]);
44
+ const hasOsSpecificInstructions = !Array.isArray(instructions);
26
45
  const normalizedOs = currentOs === 'Unknown' ? 'Linux' : currentOs;
27
46
  useEffect(() => {
28
- if (hasOsSpecificInstructions && deviceType.instructions) {
29
- const oses = Object.keys(deviceType.instructions);
47
+ if (hasOsSpecificInstructions && instructions) {
48
+ const oses = Object.keys(instructions);
30
49
  if (!oses.includes(currentOs) && oses.length > 0) {
31
50
  setCurrentOs(oses[0]);
32
51
  }
33
52
  }
34
- }, [
35
- currentOs,
36
- setCurrentOs,
37
- deviceType.instructions,
38
- hasOsSpecificInstructions,
39
- ]);
40
- if (!deviceType.instructions) {
53
+ }, [currentOs, setCurrentOs, instructions, hasOsSpecificInstructions]);
54
+ if (!deviceType || !instructions) {
41
55
  return (_jsx(Typography, { variant: "body1", children: "Instructions for this device type are not currently available. Please try again later." }));
42
56
  }
43
- const interpolatedInstructions = (_a = (hasOsSpecificInstructions
44
- ? deviceType.instructions[normalizedOs]
45
- : deviceType.instructions)) === null || _a === void 0 ? void 0 : _a.map((instruction) => interpolateMustache(templateData, instruction.replace(/<a/, '<a target="_blank"')));
57
+ const interpolatedInstructions = (_a = (hasOsSpecificInstructions ? instructions[normalizedOs] : instructions)) === null || _a === void 0 ? void 0 : _a.map((instruction) => interpolateMustache(templateData, instruction.replace(/<a/, '<a target="_blank"')));
46
58
  const finalInstructions = [
47
59
  'Use the form on the left to configure and download balenaOS for your new device.',
48
60
  ...interpolatedInstructions,
49
61
  'Your device should appear in your application dashboard within a few minutes. Have fun!',
50
62
  ];
51
- return (_jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "flex-start", children: [_jsx(Typography, { variant: "h5", children: "Instructions" }), hasOsSpecificInstructions && (_jsx(Box, { mb: 3, children: _jsx(Box, { sx: { borderBottom: 1, borderColor: 'divider' }, children: _jsx(Tabs, { value: Object.keys(deviceType.instructions).find((key) => key === currentOs), onChange: (_event, value) => {
63
+ return (_jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "flex-start", children: [_jsx(Typography, { variant: "h5", children: "Instructions" }), hasOsSpecificInstructions && (_jsx(Box, { mb: 3, children: _jsx(Box, { sx: { borderBottom: 1, borderColor: 'divider' }, children: _jsx(Tabs, { value: Object.keys(instructions).find((key) => key === currentOs), onChange: (_event, value) => {
52
64
  setCurrentOs(value !== null && value !== void 0 ? value : 'Unknown');
53
- }, "aria-label": "os tabs", children: Object.keys(deviceType.instructions).map((os) => {
65
+ }, "aria-label": "os tabs", children: Object.keys(instructions).map((os) => {
54
66
  return _jsx(Tab, { label: os, value: os }, os);
55
67
  }) }) }) })), _jsx(InstructionsList, { instructions: finalInstructions }), _jsx(Box, { mt: 2, children: _jsxs(Typography, { children: ["For more details please refer to our", ' ', _jsx(MUILinkWithTracking, { href: `https://www.balena.io/docs/learn/getting-started/${deviceType.slug}/nodejs/`, children: "Getting Started Guide" }), "."] }) })] }));
56
68
  });
@@ -29,11 +29,40 @@ export interface OsVersion {
29
29
  export interface OsVersionsByDeviceType {
30
30
  [deviceTypeSlug: string]: OsVersion[];
31
31
  }
32
+ /** @deprecated the legacy device-type.json format */
33
+ export interface OsSpecificDeviceTypeJsonInstructions {
34
+ linux: string[];
35
+ osx: string[];
36
+ windows: string[];
37
+ }
32
38
  export type OsSpecificContractInstructions = Record<'Linux' | 'MacOS' | 'Windows', string[]>;
33
39
  export interface DeviceTypeDownloadAlert {
34
40
  type: string;
35
41
  message: string;
36
42
  }
43
+ /** @deprecated */
44
+ export interface DeviceTypeOptions {
45
+ options: DeviceTypeOptionsGroup[];
46
+ collapsed: boolean;
47
+ isCollapsible: boolean;
48
+ isGroup: boolean;
49
+ message: string;
50
+ name: string;
51
+ }
52
+ /** @deprecated */
53
+ export interface DeviceTypeOptionsGroup {
54
+ default: number | string;
55
+ message: string;
56
+ name: string;
57
+ type: string;
58
+ min?: number;
59
+ max?: number;
60
+ docs?: string;
61
+ hidden?: boolean;
62
+ when?: Dictionary<number | string | boolean>;
63
+ choices?: string[] | number[];
64
+ choicesLabels?: Dictionary<string>;
65
+ }
37
66
  export interface DeviceType {
38
67
  slug: string;
39
68
  name: string;
@@ -41,5 +70,7 @@ export interface DeviceType {
41
70
  contract?: Record<string, any> | null;
42
71
  /** @deprecated */
43
72
  imageDownloadAlerts?: DeviceTypeDownloadAlert[];
44
- instructions?: string[] | OsSpecificContractInstructions;
73
+ instructions?: string[] | OsSpecificDeviceTypeJsonInstructions | OsSpecificContractInstructions;
74
+ /** @deprecated */
75
+ options?: DeviceTypeOptions[];
45
76
  }
@@ -4,7 +4,7 @@ import { faTimesCircle } from '@fortawesome/free-solid-svg-icons/faTimesCircle';
4
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
5
  import { JsonTypes, widgetFactory } from '../utils';
6
6
  import { Box, Typography } from '@mui/material';
7
- export const BooleanAsIconWidget = widgetFactory('BooleanAsIcon', [
7
+ export const BooleanAsIconWidget = widgetFactory('BooleanAsIcon', {}, [
8
8
  JsonTypes.boolean,
9
9
  JsonTypes.number,
10
10
  JsonTypes.null,
@@ -3,6 +3,6 @@ import { Tooltip } from '@mui/material';
3
3
  import { Copy } from '../../../../Copy';
4
4
  import { JsonTypes, widgetFactory } from '../utils';
5
5
  import { Code } from '../../../../Code';
6
- export const CodeWidget = widgetFactory('Code', [JsonTypes.string])(({ value, }) => {
6
+ export const CodeWidget = widgetFactory('Code', {}, [JsonTypes.string])(({ value, }) => {
7
7
  return (_jsx(Copy, { copy: value, children: _jsx(Tooltip, { title: value, children: _jsx(Code, { noWrap: true, children: value }) }) }));
8
8
  });
@@ -3,7 +3,7 @@ import { Tooltip, Typography } from '@mui/material';
3
3
  import { useTranslation } from '../../../../../hooks/useTranslations';
4
4
  import { JsonTypes, widgetFactory } from '../utils';
5
5
  import { token } from '../../../../../utils/token';
6
- export const DisabledTextWidget = widgetFactory('DisabledText', [
6
+ export const DisabledTextWidget = widgetFactory('DisabledText', {}, [
7
7
  JsonTypes.string,
8
8
  JsonTypes.number,
9
9
  JsonTypes.null,
@@ -1 +1,6 @@
1
- export declare const DurationWidget: import("../utils").Widget<object, object>;
1
+ export declare const DurationWidget: import("../utils").Widget<object, {
2
+ value: {
3
+ start?: number | Date | null;
4
+ end?: number | Date | null;
5
+ };
6
+ }>;
@@ -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) {
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
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', [JsonTypes.string, JsonTypes.number], {
5
+ export const ElapsedTimeWidget = widgetFactory('ElapsedTime', {
6
6
  dtFormat: UiOption.string,
7
- })(({ value }) => {
7
+ }, [JsonTypes.string, JsonTypes.number])(({ value }) => {
8
8
  if (!value) {
9
9
  return null;
10
10
  }
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Code } from '@mui/icons-material';
3
3
  import { Copy } from '../../../../Copy';
4
4
  import { JsonTypes, truncateHash, widgetFactory } from '../utils';
5
- export const HashWidget = widgetFactory('Hash', [JsonTypes.string])(({ value, }) => {
5
+ export const HashWidget = widgetFactory('Hash', {}, [JsonTypes.string])(({ value, }) => {
6
6
  return (_jsx(Copy, { copy: value, children: _jsx(Code, { children: truncateHash(value) }) }));
7
7
  });
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { JsonTypes, widgetFactory } from '../utils';
3
- export const PercentageWidget = widgetFactory('Percentage', [
3
+ export const PercentageWidget = widgetFactory('Percentage', {}, [
4
4
  JsonTypes.string,
5
5
  JsonTypes.number,
6
6
  ])(({ value }) => {
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Typography } from '@mui/material';
3
3
  import { JsonTypes, widgetFactory } from '../utils';
4
4
  import { token } from '../../../../../utils/token';
5
- export const PlaceholderTextWidget = widgetFactory('PlaceholderText', [
5
+ export const PlaceholderTextWidget = widgetFactory('PlaceholderText', {}, [
6
6
  JsonTypes.string,
7
7
  JsonTypes.number,
8
8
  JsonTypes.null,
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { JsonTypes, widgetFactory } from '../utils';
3
- export const TemperatureWidget = widgetFactory('Temperature', [
3
+ export const TemperatureWidget = widgetFactory('Temperature', {}, [
4
4
  JsonTypes.number,
5
5
  ])(({ value }) => {
6
6
  return _jsx(_Fragment, { children: value ? `~${value}°C` : '-' });
@@ -19,14 +19,7 @@ const getArrayValue = (value, uiSchema) => {
19
19
  return arrayString;
20
20
  };
21
21
  const DATE_TIME_FORMATS = ['date-time', 'date', 'time'];
22
- const TxtWidget = widgetFactory('Txt', [
23
- JsonTypes.string,
24
- JsonTypes.null,
25
- JsonTypes.integer,
26
- JsonTypes.number,
27
- JsonTypes.boolean,
28
- JsonTypes.array,
29
- ], {
22
+ const TxtWidget = widgetFactory('Txt', {
30
23
  dtFormat: UiOption.string,
31
24
  align: Object.assign(Object.assign({}, UiOption.string), { enum: ['inherit', 'left', 'center', 'right', 'justify'] }),
32
25
  gutterBottom: UiOption.bolean,
@@ -34,7 +27,14 @@ const TxtWidget = widgetFactory('Txt', [
34
27
  paragraph: UiOption.boolean,
35
28
  sx: UiOption.object,
36
29
  variant: UiOption.string,
37
- })(({ value, schema, uiSchema }) => {
30
+ }, [
31
+ JsonTypes.string,
32
+ JsonTypes.null,
33
+ JsonTypes.integer,
34
+ JsonTypes.number,
35
+ JsonTypes.boolean,
36
+ JsonTypes.array,
37
+ ])(({ value, schema, uiSchema }) => {
38
38
  var _a;
39
39
  let displayValue = isArray(value)
40
40
  ? getArrayValue(value, uiSchema)
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Typography } from '@mui/material';
3
3
  import { JsonTypes, widgetFactory } from '../utils';
4
- export const WrapWidget = widgetFactory('Wrap', [JsonTypes.string])(({ value, }) => {
4
+ export const WrapWidget = widgetFactory('Wrap', {}, [JsonTypes.string])(({ value, }) => {
5
5
  return (_jsx(Typography, { sx: { maxWidth: '475px', whitespace: 'normal' }, children: value }));
6
6
  });
@@ -1,2 +1,2 @@
1
1
  import type { WidgetProps } from './utils';
2
- export declare const Widget: ({ value, resource, schema, extraFormats, uiSchema, }: WidgetProps) => import("react/jsx-runtime").JSX.Element | null;
2
+ export declare const Widget: ({ value, extraContext, schema, extraFormats, uiSchema, }: WidgetProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -31,7 +31,7 @@ const getWidget = (value, format, uiSchemaWidget, extraFormats) => {
31
31
  });
32
32
  return (_b = (_a = extraFormat === null || extraFormat === void 0 ? void 0 : extraFormat.widget) !== null && _a !== void 0 ? _a : typeWidgets[valueType]) !== null && _b !== void 0 ? _b : typeWidgets.default;
33
33
  };
34
- export const Widget = ({ value, resource, schema = {}, extraFormats, uiSchema, }) => {
34
+ export const Widget = ({ value, extraContext, schema = {}, extraFormats, uiSchema, }) => {
35
35
  const format = getSchemaFormat(schema);
36
36
  if (!format) {
37
37
  return _jsx(_Fragment, { children: value });
@@ -43,5 +43,5 @@ export const Widget = ({ value, resource, schema = {}, extraFormats, uiSchema, }
43
43
  return null;
44
44
  }
45
45
  const WidgetComponent = getWidget(processedValue, format, undefined, extraFormats);
46
- return (_jsx(WidgetComponent, { resource: resource, value: processedValue !== null && processedValue !== void 0 ? processedValue : null, schema: schema }));
46
+ return (_jsx(WidgetComponent, { extraContext: extraContext, value: processedValue !== null && processedValue !== void 0 ? processedValue : null, schema: schema }));
47
47
  };
@@ -19,7 +19,7 @@ export interface WidgetProps<T extends object = object> {
19
19
  schema: JSONSchema | undefined;
20
20
  extraFormats?: Format[];
21
21
  uiSchema?: UiSchema;
22
- resource: T;
22
+ extraContext?: T;
23
23
  }
24
24
  export interface Widget<T extends object = object, ExtraProps = object> {
25
25
  uiOptions?: UiOptions;
@@ -49,7 +49,7 @@ export type UiOptions = {
49
49
  [key: string]: JSONSchema;
50
50
  };
51
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>, {
52
+ export declare const widgetFactory: <ST extends Array<keyof JsonTypesTypeMap>>(displayName: string, uiOptions: Widget["uiOptions"], supportedTypes: ST) => <T extends object, ExtraProps extends object = object, V extends WidgetProps["value"] | null = JsonTypesTypeMap[ST[number]]>(widgetFn: (props: Overwrite<WidgetProps<T>, {
53
53
  value: V;
54
54
  }> & ExtraProps) => JSX.Element | null) => Widget<T, ExtraProps>;
55
55
  export declare const formatTimestamp: (timestamp: string | number, uiSchema?: UiSchema) => string;
@@ -33,9 +33,7 @@ export const UiOption = {
33
33
  // TODO: Replace the HOF with a plain function once TS supports optional generic types
34
34
  // See: https://github.com/microsoft/TypeScript/issues/14400
35
35
  // TODO: convert the fn args to an object once we bump TS
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 = {}) => {
36
+ export const widgetFactory = (displayName, uiOptions, supportedTypes) => {
39
37
  return (widgetFn) => {
40
38
  const widget = widgetFn;
41
39
  Object.assign(widget, {
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { RJSTSdk, RJSTAction, RJSTModel, RJSTBaseResource, RJSTRawModel } from './schemaOps';
3
3
  import { rjstJsonSchemaPick, rjstAddToSchema, generateSchemaFromRefScheme, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty } from './schemaOps';
4
4
  import type { JSONSchema7 as JSONSchema } from 'json-schema';
5
- import { rjstDefaultPermissions, rjstGetModelForCollection, rjstRunTransformers } from './models/helpers';
5
+ import { rjstDefaultPermissions, rjstGetModelForCollection, rjstGetModelForCollection2, rjstRunTransformers } from './models/helpers';
6
6
  import { rjstGetDisabledReason } from './utils';
7
7
  import type { LensTemplate } from './Lenses';
8
8
  import type { BoxProps } from '@mui/material';
@@ -58,4 +58,4 @@ export interface RJSTProps<T> extends Omit<BoxProps, 'onChange'> {
58
58
  persistFilters?: boolean;
59
59
  }
60
60
  export declare const RJST: <T extends RJSTBaseResource<T>>({ model: modelRaw, data, formats, actions, sdk, customSort, refresh, getBaseUrl, onEntityClick, onChange, pagination, customLenses, loading, rowKey, noDataInfo, persistFilters, ...boxProps }: RJSTProps<T>) => import("react/jsx-runtime").JSX.Element;
61
- export { rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstAddToSchema, type RJSTAction, type RJSTBaseResource, type RJSTRawModel, type RJSTModel, rjstJsonSchemaPick, rjstGetDisabledReason, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, };
61
+ export { rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstGetModelForCollection2, rjstAddToSchema, type RJSTAction, type RJSTBaseResource, type RJSTRawModel, type RJSTModel, rjstJsonSchemaPick, rjstGetDisabledReason, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, };
@@ -8,7 +8,7 @@ import { Filters } from './Filters/Filters';
8
8
  import { Tags } from './Actions/Tags';
9
9
  import { Update } from './Actions/Update';
10
10
  import { Create } from './Actions/Create';
11
- import { rjstDefaultPermissions, rjstGetModelForCollection, rjstRunTransformers, } from './models/helpers';
11
+ import { rjstDefaultPermissions, rjstGetModelForCollection, rjstGetModelForCollection2, rjstRunTransformers, } from './models/helpers';
12
12
  import { rjstGetDisabledReason, getFromLocalStorage, getTagsDisabledReason, setToLocalStorage, getSortingFunction, DEFAULT_ITEMS_PER_PAGE, } from './utils';
13
13
  import { getLenses } from './Lenses';
14
14
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -278,7 +278,7 @@ export const RJST = (_a) => {
278
278
  setSelected: $setSelected,
279
279
  })] }) }) })));
280
280
  };
281
- export { rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstAddToSchema, rjstJsonSchemaPick, rjstGetDisabledReason, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, };
281
+ export { rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstGetModelForCollection2, rjstAddToSchema, rjstJsonSchemaPick, rjstGetDisabledReason, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, };
282
282
  const getTitleAndLabel = (t, jsonSchema, propertyKey, refScheme) => {
283
283
  var _a, _b, _c;
284
284
  const subSchema = getSubSchemaFromRefScheme(jsonSchema, refScheme);
@@ -378,7 +378,7 @@ const getColumnsFromSchema = ({ t, schema, idField, isServerSide, customSort, pr
378
378
  ? fieldCustomSort
379
379
  : getSortingFunction(key, val), render: (fieldVal, entry) => {
380
380
  const calculatedField = rjstAdaptRefScheme(fieldVal, val);
381
- return (_jsx(Widget, { extraFormats: [...(formats !== null && formats !== void 0 ? formats : []), ...defaultFormats], schema: widgetSchema, value: calculatedField, resource: entry }));
381
+ return (_jsx(Widget, { extraFormats: [...(formats !== null && formats !== void 0 ? formats : []), ...defaultFormats], schema: widgetSchema, value: calculatedField, extraContext: entry }));
382
382
  } });
383
383
  });
384
384
  };
@@ -9,5 +9,9 @@ export declare const rjstDefaultPermissions: {
9
9
  delete: boolean;
10
10
  };
11
11
  export declare const rjstRunTransformers: <T extends Dictionary<any>, TResult extends T, TContext = null>(data: T | undefined, transformers: Transformers<T, Omit<TResult, keyof T>, TContext>, context?: TContext) => TResult | undefined;
12
- export declare const rjstGetModelForCollection: <T>(model: RJSTRawModel<T>, permissions: Permissions<T>) => RJSTModel<T>;
12
+ /** @deprecated This function will be removed in the next major. Use rjstGetModelForCollection2 instead */
13
+ export declare const rjstGetModelForCollection: <T>(model: RJSTRawModel<T>, context?: {
14
+ accessRole?: string | null;
15
+ }) => RJSTModel<T>;
16
+ export declare const rjstGetModelForCollection2: <T>(model: RJSTRawModel<T>, permissions: Permissions<T>) => RJSTModel<T>;
13
17
  export {};
@@ -28,8 +28,23 @@ export const rjstRunTransformers = (data, transformers, context) => {
28
28
  }
29
29
  return mutatedData;
30
30
  };
31
+ // TODO: Drop me in the next major
32
+ /** @deprecated This function will be removed in the next major. Use rjstGetModelForCollection2 instead */
31
33
  // This transformation would happen elsewhere, and it wouldn't be part of RJST
32
- export const rjstGetModelForCollection = (model, permissions) => {
34
+ export const rjstGetModelForCollection = (model, context) => {
35
+ const accessRole = context === null || context === void 0 ? void 0 : context.accessRole;
36
+ const schema = model.priorities
37
+ ? rjstJsonSchemaPick(model.schema, [
38
+ ...model.priorities.primary,
39
+ ...model.priorities.secondary,
40
+ ...model.priorities.tertiary,
41
+ ])
42
+ : model.schema;
43
+ return Object.assign(Object.assign({}, model), { permissions: (accessRole != null && model.permissions[accessRole]) ||
44
+ model.permissions['default'], schema });
45
+ };
46
+ // This transformation would happen elsewhere, and it wouldn't be part of RJST
47
+ export const rjstGetModelForCollection2 = (model, permissions) => {
33
48
  const schema = model.priorities
34
49
  ? rjstJsonSchemaPick(model.schema, [
35
50
  ...model.priorities.primary,
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import * as uuid from 'uuid';
4
3
  import find from 'lodash/find';
5
4
  import startsWith from 'lodash/startsWith';
6
5
  import isEmpty from 'lodash/isEmpty';
@@ -9,6 +8,7 @@ import { Callout } from '../Callout';
9
8
  import { useTranslation } from '../../hooks/useTranslations';
10
9
  import { stopKeyDownEvent, withPreventDefault, } from '../../utils/eventHandling';
11
10
  import { SimpleConfirmationDialog, } from '../SimpleConfirmationDialog';
11
+ import { useRandomUUID } from '../../hooks/useRandomUUID';
12
12
  const RESERVED_NAMESPACES = ['io.resin.', 'io.balena.'];
13
13
  const newTagValidationRules = (t, key, existingTags) => {
14
14
  return [
@@ -42,7 +42,8 @@ export const AddTagForm = ({ itemType, existingTags, overridableTags = [], addTa
42
42
  const [confirmationDialogOptions, setConfirmationDialogOptions] = React.useState();
43
43
  const tagKeyInput = React.useRef(null);
44
44
  const valueInput = React.useRef(null);
45
- const formUuid = `add-tag-form-${uuid.v1()}`;
45
+ const formId = useRandomUUID();
46
+ const formUuid = `add-tag-form-${formId}`;
46
47
  const checkNewTagValidity = (key) => {
47
48
  const failedRule = newTagValidationRules(t, key, existingTags).find((rule) => rule.test());
48
49
  const hasErrors = !!failedRule;
package/dist/index.d.ts CHANGED
@@ -74,7 +74,7 @@ export { SettingsCard, SettingsCardItem } from './components/SettingsCard';
74
74
  export { Tag, type TagProps, type TagItem } from './components/Tag';
75
75
  export { TagManagementDialog, type TagManagementDialogProps, } from './components/TagManagementDialog';
76
76
  export { AnalyticsContextProvider, useAnalyticsContext, AnalyticsStoreActions, } from './contexts/AnalyticsContext';
77
- export { RJST, type RJSTProps, rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstAddToSchema, type RJSTAction, type RJSTBaseResource, type RJSTRawModel, type RJSTModel, rjstJsonSchemaPick, rjstGetDisabledReason, type NoDataInfo, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, } from './components/RJST';
77
+ export { RJST, type RJSTProps, rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstGetModelForCollection2, rjstAddToSchema, type RJSTAction, type RJSTBaseResource, type RJSTRawModel, type RJSTModel, rjstJsonSchemaPick, rjstGetDisabledReason, type NoDataInfo, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, } from './components/RJST';
78
78
  export { removeFieldsWithNoFilter, modifySchemaWithRefSchemes, removeRefSchemeSeparatorsFromFilters, } from './components/RJST/Filters/utils';
79
79
  export type { PineFilterObject } from './components/RJST/oData/jsonToOData';
80
80
  export { type FormData, FULL_TEXT_SLUG, ajvFilter, getPropertySchema, parseFilterDescription, createModelFilter, createFilter, createFullTextSearchFilter, convertSchemaToDefaultValue, } from './components/RJST/components/Filters/SchemaSieve';
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ export { SettingsCard, SettingsCardItem } from './components/SettingsCard';
39
39
  export { Tag } from './components/Tag';
40
40
  export { TagManagementDialog, } from './components/TagManagementDialog';
41
41
  export { AnalyticsContextProvider, useAnalyticsContext, AnalyticsStoreActions, } from './contexts/AnalyticsContext';
42
- export { RJST, rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstAddToSchema, rjstJsonSchemaPick, rjstGetDisabledReason, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, } from './components/RJST';
42
+ export { RJST, rjstRunTransformers, rjstDefaultPermissions, rjstGetModelForCollection, rjstGetModelForCollection2, rjstAddToSchema, rjstJsonSchemaPick, rjstGetDisabledReason, getPropertyScheme, getSubSchemaFromRefScheme, parseDescription, parseDescriptionProperty, generateSchemaFromRefScheme, } from './components/RJST';
43
43
  export { removeFieldsWithNoFilter, modifySchemaWithRefSchemes, removeRefSchemeSeparatorsFromFilters, } from './components/RJST/Filters/utils';
44
44
  export { FULL_TEXT_SLUG, ajvFilter, getPropertySchema, parseFilterDescription, createModelFilter, createFilter, createFullTextSearchFilter, convertSchemaToDefaultValue, } from './components/RJST/components/Filters/SchemaSieve';
45
45
  export { Filters, } from './components/RJST/components/Filters';
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-78dd3d5eba302d57a47d7ebb0fbdd8793e82d77d-1",
3
+ "version": "13.0.0-build-upgrade-storybook-9-438bc209db8ac0658743037813f035cdb3e395a8-1",
4
4
  "main": "./dist/index.js",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -55,17 +55,11 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@balena/lint": "^9.3.0",
58
- "@storybook/addon-essentials": "^8.6.12",
59
- "@storybook/addon-interactions": "^8.6.12",
60
- "@storybook/addon-links": "^8.6.12",
61
- "@storybook/addon-onboarding": "^8.6.12",
58
+ "@storybook/addon-docs": "^9.0.0",
59
+ "@storybook/addon-links": "^9.0.0",
60
+ "@storybook/addon-onboarding": "^9.0.0",
62
61
  "@storybook/addon-webpack5-compiler-swc": "^3.0.0",
63
- "@storybook/blocks": "^8.6.12",
64
- "@storybook/manager-api": "^8.6.12",
65
- "@storybook/react": "^8.6.12",
66
- "@storybook/react-webpack5": "^8.6.12",
67
- "@storybook/test": "^8.6.12",
68
- "@storybook/theming": "^8.6.12",
62
+ "@storybook/react-webpack5": "^9.0.0",
69
63
  "@types/color": "^4.2.0",
70
64
  "@types/color-hash": "^2.0.0",
71
65
  "@types/lodash": "^4.17.14",
@@ -75,11 +69,11 @@
75
69
  "@types/react-dom": "^18.0.11",
76
70
  "@types/react-helmet": "^6.1.6",
77
71
  "@types/zxcvbn": "^4.4.4",
78
- "eslint-plugin-storybook": "^0.12.0",
72
+ "eslint-plugin-storybook": "^9.0.0",
79
73
  "husky": "^9.0.0",
80
74
  "lint-staged": "^15.0.0",
81
75
  "prop-types": "^15.8.1",
82
- "storybook": "^8.6.12",
76
+ "storybook": "^9.0.0",
83
77
  "ts-loader": "^9.5.1",
84
78
  "webpack": "^5.88.2"
85
79
  },
@@ -95,6 +89,9 @@
95
89
  "build-storybook": "storybook build --docs",
96
90
  "deploy-docs": "npm ci && storybook build --docs && mv storybook-static build"
97
91
  },
92
+ "engines": {
93
+ "node": "^22.0.0"
94
+ },
98
95
  "eslintConfig": {
99
96
  "extends": [
100
97
  "react-app",
@@ -138,6 +135,9 @@
138
135
  },
139
136
  "homepage": "https://github.com/balena-io/ui-shared-components#readme",
140
137
  "versionist": {
141
- "publishedAt": "2025-05-27T11:50:14.169Z"
138
+ "publishedAt": "2025-05-29T12:37:00.772Z"
139
+ },
140
+ "overrides": {
141
+ "storybook": "$storybook"
142
142
  }
143
143
  }