@balena/ui-shared-components 13.0.0-build-rename-and-require-widget-extracontext-37df890fe262ef54dc0d361d32b076c7eeccd84b-1 → 13.0.0-build-rename-and-require-widget-extracontext-f5f43f330fdd0a74e4e59dfb3cc4fc251bb0ee98-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.
@@ -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, useMemo, useState } from 'react';
5
+ import { memo, useEffect, useState } from 'react';
6
6
  import { MUILinkWithTracking } from '../MUILinkWithTracking';
7
7
  import { OrderedListItem } from '../OrderedListItem';
8
8
  import { Markdown } from '../Markdown';
@@ -19,50 +19,38 @@ export const getUserOs = () => {
19
19
  }
20
20
  return 'Unknown';
21
21
  };
22
- const dtJsonTocontractOsKeyMap = {
23
- windows: 'Windows',
24
- osx: 'MacOS',
25
- linux: 'Linux',
26
- };
27
22
  export const ApplicationInstructions = memo(function ApplicationInstructions({ deviceType, templateData, }) {
28
23
  var _a;
29
24
  const [currentOs, setCurrentOs] = useState(getUserOs());
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);
25
+ const hasOsSpecificInstructions = !Array.isArray(deviceType.instructions);
45
26
  const normalizedOs = currentOs === 'Unknown' ? 'Linux' : currentOs;
46
27
  useEffect(() => {
47
- if (hasOsSpecificInstructions && instructions) {
48
- const oses = Object.keys(instructions);
28
+ if (hasOsSpecificInstructions && deviceType.instructions) {
29
+ const oses = Object.keys(deviceType.instructions);
49
30
  if (!oses.includes(currentOs) && oses.length > 0) {
50
31
  setCurrentOs(oses[0]);
51
32
  }
52
33
  }
53
- }, [currentOs, setCurrentOs, instructions, hasOsSpecificInstructions]);
54
- if (!deviceType || !instructions) {
34
+ }, [
35
+ currentOs,
36
+ setCurrentOs,
37
+ deviceType.instructions,
38
+ hasOsSpecificInstructions,
39
+ ]);
40
+ if (!deviceType.instructions) {
55
41
  return (_jsx(Typography, { variant: "body1", children: "Instructions for this device type are not currently available. Please try again later." }));
56
42
  }
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"')));
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"')));
58
46
  const finalInstructions = [
59
47
  'Use the form on the left to configure and download balenaOS for your new device.',
60
48
  ...interpolatedInstructions,
61
49
  'Your device should appear in your application dashboard within a few minutes. Have fun!',
62
50
  ];
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) => {
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) => {
64
52
  setCurrentOs(value !== null && value !== void 0 ? value : 'Unknown');
65
- }, "aria-label": "os tabs", children: Object.keys(instructions).map((os) => {
53
+ }, "aria-label": "os tabs", children: Object.keys(deviceType.instructions).map((os) => {
66
54
  return _jsx(Tab, { label: os, value: os }, os);
67
55
  }) }) }) })), _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" }), "."] }) })] }));
68
56
  });
@@ -29,40 +29,11 @@ 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
- }
38
32
  export type OsSpecificContractInstructions = Record<'Linux' | 'MacOS' | 'Windows', string[]>;
39
33
  export interface DeviceTypeDownloadAlert {
40
34
  type: string;
41
35
  message: string;
42
36
  }
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
- }
66
37
  export interface DeviceType {
67
38
  slug: string;
68
39
  name: string;
@@ -70,7 +41,5 @@ export interface DeviceType {
70
41
  contract?: Record<string, any> | null;
71
42
  /** @deprecated */
72
43
  imageDownloadAlerts?: DeviceTypeDownloadAlert[];
73
- instructions?: string[] | OsSpecificDeviceTypeJsonInstructions | OsSpecificContractInstructions;
74
- /** @deprecated */
75
- options?: DeviceTypeOptions[];
44
+ instructions?: string[] | OsSpecificContractInstructions;
76
45
  }
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-37df890fe262ef54dc0d361d32b076c7eeccd84b-1",
3
+ "version": "13.0.0-build-rename-and-require-widget-extracontext-f5f43f330fdd0a74e4e59dfb3cc4fc251bb0ee98-1",
4
4
  "main": "./dist/index.js",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -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-15T18:17:53.484Z"
141
+ "publishedAt": "2025-05-16T14:08:37.697Z"
142
142
  }
143
143
  }