@balena/ui-shared-components 14.0.4-build-material-7-ea405b56507f5c0bab908e32767032593ec57de9-1 → 14.0.4-build-drop-some-lodash-for-native-alternatives-2262746e9e370b6af606616f09e32c1ca2a3232d-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/DownloadImageDialog/ApplicationInstructions.js +1 -2
- package/dist/components/DownloadImageDialog/index.js +6 -8
- package/dist/components/DownloadImageDialog/version.js +1 -2
- package/dist/components/DropDownButton/index.js +6 -7
- package/dist/components/Form/FieldTemplates/ObjectFieldTemplate.js +2 -2
- package/dist/components/Form/Widgets/FileWidget.js +2 -3
- package/dist/components/RJST/DataTypes/object.js +18 -9
- package/dist/components/RJST/Filters/utils.js +3 -3
- package/dist/components/RJST/Lenses/index.js +1 -2
- package/dist/components/RJST/components/Filters/FiltersDialog.js +1 -3
- package/dist/components/RJST/components/Table/useTagActions.js +1 -2
- package/dist/components/RJST/components/Widget/Formats/TxtWidget.js +1 -2
- package/dist/components/RJST/components/Widget/index.js +5 -2
- package/dist/components/RJST/models/helpers.js +1 -2
- package/dist/components/RJST/utils.js +3 -2
- package/dist/components/TagManagementDialog/AddTagForm.js +3 -8
- package/dist/components/TagManagementDialog/index.js +3 -2
- package/dist/components/TagManagementDialog/tag-management-service.js +5 -5
- package/dist/theme.js +1 -1
- package/package.json +12 -14
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import has from 'lodash/has';
|
|
3
2
|
import { interpolateMustache } from './utils';
|
|
4
3
|
import { Box, List, Tab, Tabs, Typography } from '@mui/material';
|
|
5
4
|
import { memo, useEffect, useState } from 'react';
|
|
@@ -55,7 +54,7 @@ export const ApplicationInstructions = memo(function ApplicationInstructions({ d
|
|
|
55
54
|
}) }) }) })), _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
55
|
});
|
|
57
56
|
const InstructionsItem = ({ node, index }) => {
|
|
58
|
-
const hasChildren =
|
|
57
|
+
const hasChildren = node != null && Object.hasOwnProperty.call(node, 'children');
|
|
59
58
|
let text = null;
|
|
60
59
|
if (typeof node === 'string') {
|
|
61
60
|
text = node;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Avatar, DialogActions, DialogContent, Divider, Grid, Stack, Typography, } from '@mui/material';
|
|
2
|
+
import { Avatar, DialogActions, DialogContent, Divider, Grid2 as Grid, Stack, Typography, } from '@mui/material';
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { FALLBACK_LOGO_UNKNOWN_DEVICE, isUrlAccessible, stripVersionBuild, } from './utils';
|
|
5
5
|
import { ImageForm } from './ImageForm';
|
|
@@ -7,9 +7,7 @@ import { ApplicationInstructions } from './ApplicationInstructions';
|
|
|
7
7
|
import { DropDownButton } from '../DropDownButton';
|
|
8
8
|
import pickBy from 'lodash/pickBy';
|
|
9
9
|
import debounce from 'lodash/debounce';
|
|
10
|
-
import isEmpty from 'lodash/isEmpty';
|
|
11
10
|
import { OsTypesEnum } from './models';
|
|
12
|
-
import uniq from 'lodash/uniq';
|
|
13
11
|
import { enqueueSnackbar } from 'notistack';
|
|
14
12
|
import { DialogWithCloseButton } from '../DialogWithCloseButton';
|
|
15
13
|
import { Callout } from '../Callout';
|
|
@@ -25,12 +23,12 @@ export var ActionType;
|
|
|
25
23
|
ActionType["downloadConfigFile"] = "download_config_file";
|
|
26
24
|
})(ActionType || (ActionType = {}));
|
|
27
25
|
const getUniqueOsTypes = (osVersions, deviceTypeSlug) => {
|
|
28
|
-
if (
|
|
26
|
+
if (Object.keys(osVersions).length === 0 ||
|
|
29
27
|
!deviceTypeSlug ||
|
|
30
|
-
|
|
28
|
+
osVersions[deviceTypeSlug].length === 0) {
|
|
31
29
|
return [];
|
|
32
30
|
}
|
|
33
|
-
return
|
|
31
|
+
return Array.from(new Set(osVersions[deviceTypeSlug].map((x) => x.osType)));
|
|
34
32
|
};
|
|
35
33
|
const generateImageUrl = (model, downloadUrl) => {
|
|
36
34
|
// TODO check if possible to edit Etcher to avoid a double encode on the version.
|
|
@@ -96,7 +94,7 @@ export const DownloadImageDialog = ({ open, applicationId, releaseId, compatible
|
|
|
96
94
|
[initialDeviceType.slug]: osTypes.includes(OsTypesEnum.ESR),
|
|
97
95
|
}
|
|
98
96
|
: {});
|
|
99
|
-
const [isFetching, setIsFetching] = useState(
|
|
97
|
+
const [isFetching, setIsFetching] = useState(Object.keys(osVersions).length === 0);
|
|
100
98
|
const [downloadSize, setDownloadSize] = useState(null);
|
|
101
99
|
const [isValidatingUrl, setIsValidatingUrl] = useState(false);
|
|
102
100
|
const defaultDisplayName = useMemo(() => { var _a, _b; return (_b = (_a = formModel.deviceType) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '-'; }, [(_a = formModel.deviceType) === null || _a === void 0 ? void 0 : _a.name]);
|
|
@@ -259,7 +257,7 @@ export const DownloadImageDialog = ({ open, applicationId, releaseId, compatible
|
|
|
259
257
|
sm: 12,
|
|
260
258
|
md: 6,
|
|
261
259
|
lg: 7,
|
|
262
|
-
}, children: isFetching ? (_jsx(Spinner, {})) : (_jsxs(_Fragment, { children: [
|
|
260
|
+
}, children: isFetching ? (_jsx(Spinner, {})) : (_jsxs(_Fragment, { children: [Object.keys(osVersions).length === 0 && (_jsx(Callout, { severity: "warning", children: "No OS versions available for download" })), !!osType && !!compatibleDeviceTypes && (_jsx(ImageForm, { applicationId: applicationId, releaseId: releaseId, compatibleDeviceTypes: compatibleDeviceTypes, osVersions: osVersions, isInitialDefault: isInitialDefault, hasEsrVersions: deviceTypeHasEsr[formModel.deviceType.slug], formElement: formElement, downloadUrl: downloadUrl, authToken: authToken, osType: osType, osTypes: osTypes, model: formModel, onSelectedOsTypeChange: setOsTypeCallback, onChange: handleChange }))] })) }), _jsxs(Grid, { pb: 0, size: {
|
|
263
261
|
xs: 12,
|
|
264
262
|
sm: 12,
|
|
265
263
|
md: 6,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import uniq from 'lodash/uniq';
|
|
2
1
|
import partition from 'lodash/partition';
|
|
3
2
|
export const transformVersions = (versions) => {
|
|
4
3
|
const optsByVersion = {};
|
|
@@ -32,7 +31,7 @@ export const getPreferredVersionOpts = (versionOpts) => {
|
|
|
32
31
|
return major && parseInt(major, 10) > LEGACY_OS_VERSION_MAJOR;
|
|
33
32
|
});
|
|
34
33
|
const opts = supportedVersions.length ? supportedVersions : legacyVersions;
|
|
35
|
-
const lines =
|
|
34
|
+
const lines = Array.from(new Set(opts.map((option) => option.line)));
|
|
36
35
|
const hasMultipleLines = lines.length > 1;
|
|
37
36
|
if (hasMultipleLines) {
|
|
38
37
|
const preferredMultilineOpts = {};
|
|
@@ -5,7 +5,6 @@ import { Button, ButtonGroup, MenuItem, Menu } from '@mui/material';
|
|
|
5
5
|
import { ButtonWithTracking } from '../ButtonWithTracking';
|
|
6
6
|
import { useAnalyticsContext } from '../../contexts/AnalyticsContext';
|
|
7
7
|
import groupBy from 'lodash/groupBy';
|
|
8
|
-
import flatMap from 'lodash/flatMap';
|
|
9
8
|
import { Tooltip } from '../Tooltip';
|
|
10
9
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
10
|
import { faCaretDown, faCaretUp, faChevronDown, faChevronUp, } from '@fortawesome/free-solid-svg-icons';
|
|
@@ -26,12 +25,12 @@ export const DropDownButton = (_a) => {
|
|
|
26
25
|
return items;
|
|
27
26
|
}
|
|
28
27
|
const grouped = groupBy(items, (item) => item[groupByProp]);
|
|
29
|
-
const
|
|
30
|
-
const lastKey =
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const entries = Object.entries(grouped);
|
|
29
|
+
const lastKey = entries[entries.length - 1][0];
|
|
30
|
+
return entries
|
|
31
|
+
.flatMap(([key, value]) => value.map((v, index) => key !== lastKey && index === value.length - 1
|
|
32
|
+
? Object.assign(Object.assign({}, v), { divider: true }) : v))
|
|
33
|
+
.filter(Boolean);
|
|
35
34
|
}, [items, groupByProp]);
|
|
36
35
|
const handleClick = (event) => {
|
|
37
36
|
var _a, _b, _c;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import Grid from '@mui/material/Grid';
|
|
3
3
|
import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
|
|
4
4
|
export const ObjectFieldTemplate = (props) => {
|
|
5
5
|
var _a, _b;
|
|
@@ -11,7 +11,7 @@ export const ObjectFieldTemplate = (props) => {
|
|
|
11
11
|
return (_jsxs(_Fragment, { children: [title && (_jsx(TitleFieldTemplate, { id: titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })), description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), _jsxs(Grid, Object.assign({ container: true, spacing: 2, style: { marginTop: '10px' } }, ((_b = (_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:grid']) === null || _a === void 0 ? void 0 : _a.container) !== null && _b !== void 0 ? _b : {}), { children: [properties.map((element, index) => {
|
|
12
12
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
13
13
|
return element.hidden ? (element.content) : (_jsx(Grid, Object.assign({ item: true, xs: 12, sx: { marginBottom: '10px' } }, ((_g = (_e = (_c = (_b = (_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[element.name]) === null || _a === void 0 ? void 0 : _a['ui:grid']) === null || _b === void 0 ? void 0 : _b.item) !== null && _c !== void 0 ? _c : (_d = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:grid']) === null || _d === void 0 ? void 0 : _d[element.name]) !== null && _e !== void 0 ? _e : (_f = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:grid']) === null || _f === void 0 ? void 0 : _f.item) !== null && _g !== void 0 ? _g : {}), { children: element.content }), index));
|
|
14
|
-
}), canExpand(schema, uiSchema, formData) && (_jsx(Grid, { container: true, justifyContent: "flex-end", children: _jsx(Grid, { children: _jsx(AddButton, { className: "object-property-expand", onClick: onAddClick(schema),
|
|
14
|
+
}), canExpand(schema, uiSchema, formData) && (_jsx(Grid, { container: true, justifyContent: "flex-end", children: _jsx(Grid, { item: true, children: _jsx(AddButton, { className: "object-property-expand", onClick: onAddClick(schema),
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- If `disabled` is false, we still want to disable the button if `readonly` is true
|
|
16
16
|
disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }) }) }))] }))] }));
|
|
17
17
|
};
|
|
@@ -7,7 +7,6 @@ import { IconButtonWithTracking, Tooltip } from '../../..';
|
|
|
7
7
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
8
8
|
import { faCircleExclamation, faFile, faFileImage, faTrash, faUpload, } from '@fortawesome/free-solid-svg-icons';
|
|
9
9
|
import { useRandomUUID } from '../../../hooks/useRandomUUID';
|
|
10
|
-
import uniq from 'lodash/uniq';
|
|
11
10
|
import { token } from '../../../utils/token';
|
|
12
11
|
const restingStyle = {
|
|
13
12
|
borderColor: token('color.border'),
|
|
@@ -164,11 +163,11 @@ export const FileWidget = ({ onChange, multiple, schema, uiSchema, }) => {
|
|
|
164
163
|
: // TODO: icon sizes need to be properly added to the design tokens
|
|
165
164
|
{ fontSize: '48px' }))), _jsxs(Typography, { variant: "bodyLg", children: ["Drag and drop or", ' ', _jsxs(Typography, { className: "browse-files-text", variant: "bodyLg", component: Link, children: ["browse ", browseResourceName ? `${browseResourceName} ` : '', "files"] })] })] }), !!descriptiveText && (_jsx(Typography, { color: token('color.text.subtle'), component: "p", children: descriptiveText }))] })), _jsxs(Stack, { gap: 2, children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", gap: 3, children: [_jsx(Typography, { color: token('color.text.subtle'), children: accept == null
|
|
166
165
|
? ''
|
|
167
|
-
: `Supported formats: ${
|
|
166
|
+
: `Supported formats: ${Array.from(new Set(Object.values(accept)
|
|
168
167
|
// The values of accept are arrays of file types, take them and flatten them
|
|
169
168
|
.flat()
|
|
170
169
|
// Remove the dot from the file type and capitalize it
|
|
171
|
-
.map((fileType) => fileType.slice(1).toUpperCase())).join(', ')}` }), maxSize != null && (_jsxs(Typography, { color: token('color.text.subtle'), align: "right", children: ["Maximum size: ", fileSizeToReadable(maxSize)] }))] }), hideUploadedFiles && !!errorFiles.length && (_jsx(Stack, { color: token('color.text.danger'), gap: 1, children: errorFiles
|
|
170
|
+
.map((fileType) => fileType.slice(1).toUpperCase()))).join(', ')}` }), maxSize != null && (_jsxs(Typography, { color: token('color.text.subtle'), align: "right", children: ["Maximum size: ", fileSizeToReadable(maxSize)] }))] }), hideUploadedFiles && !!errorFiles.length && (_jsx(Stack, { color: token('color.text.danger'), gap: 1, children: errorFiles
|
|
172
171
|
.flatMap((errorFile) => errorFile.errors)
|
|
173
172
|
.map((error) => getErrorMessage(error.code, error.message, maxSize !== null && maxSize !== void 0 ? maxSize : Infinity)) })), !hideUploadedFiles && (_jsxs(Stack, { gap: 1, children: [files.map((file, index) => (_createElement(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", gap: 2, bgcolor: token('color.bg'), p: 3, borderRadius: token('shape.borderRadius.md') }, (mobile && { flexWrap: 'wrap' }), { key: file.name }),
|
|
174
173
|
_jsxs(Stack, Object.assign({ direction: "row" }, (mobile && { justifyContent: 'space-between' }), { gap: 2, alignItems: "center", width: "100%", children: [_jsxs(Stack, { direction: "row", gap: 2, alignItems: "center", maxWidth: "45%", children: [_jsx(FontAwesomeIcon, { icon: getFileTypeIcon(file.type) }), _jsx(Typography, Object.assign({}, (mobile
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import find from 'lodash/find';
|
|
2
1
|
import { getDataTypeSchema, regexEscape } from './utils';
|
|
3
2
|
import { FULL_TEXT_SLUG, createModelFilter, } from '../components/Filters/SchemaSieve';
|
|
4
3
|
import { isJSONSchema, getRefSchema } from '../schemaOps';
|
|
5
|
-
import findKey from 'lodash/findKey';
|
|
6
4
|
import pick from 'lodash/pick';
|
|
7
5
|
import mapValues from 'lodash/mapValues';
|
|
6
|
+
const findValueByDescription = (obj, description) => {
|
|
7
|
+
return Object.values(obj !== null && obj !== void 0 ? obj : {}).find((property) => typeof property === 'object' &&
|
|
8
|
+
'description' in property &&
|
|
9
|
+
property.description === description);
|
|
10
|
+
};
|
|
11
|
+
const findKeyByDescription = (obj, description) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = Object.entries(obj !== null && obj !== void 0 ? obj : {}).find(([, value]) => typeof value === 'object' &&
|
|
14
|
+
'description' in value &&
|
|
15
|
+
value.description === description)) === null || _a === void 0 ? void 0 : _a[0];
|
|
16
|
+
};
|
|
8
17
|
const getKeyLabel = (schema) => {
|
|
9
18
|
var _a;
|
|
10
|
-
const s =
|
|
19
|
+
const s = findValueByDescription(schema.properties, 'key');
|
|
11
20
|
return (_a = s === null || s === void 0 ? void 0 : s.title) !== null && _a !== void 0 ? _a : 'key';
|
|
12
21
|
};
|
|
13
22
|
const getValueLabel = (schema) => {
|
|
14
23
|
var _a;
|
|
15
|
-
const s =
|
|
24
|
+
const s = findValueByDescription(schema.properties, 'value');
|
|
16
25
|
return (_a = s === null || s === void 0 ? void 0 : s.title) !== null && _a !== void 0 ? _a : 'value';
|
|
17
26
|
};
|
|
18
|
-
export const isKeyValueObj = (schema) => !!
|
|
19
|
-
!!
|
|
27
|
+
export const isKeyValueObj = (schema) => !!findValueByDescription(schema.properties, 'key') ||
|
|
28
|
+
!!findValueByDescription(schema.properties, 'value');
|
|
20
29
|
export const operators = (s) => {
|
|
21
30
|
return Object.assign({ is: 'is', is_not: 'is not' }, (!isKeyValueObj(s)
|
|
22
31
|
? {
|
|
@@ -73,7 +82,7 @@ const getValueForOperation = (operator, schema, value) => {
|
|
|
73
82
|
? 'value'
|
|
74
83
|
: null;
|
|
75
84
|
const schemaProperty = schemaField
|
|
76
|
-
?
|
|
85
|
+
? findKeyByDescription(schema.properties, schemaField)
|
|
77
86
|
: null;
|
|
78
87
|
// Return the appropriate value format based on the operation type
|
|
79
88
|
return schemaProperty
|
|
@@ -141,8 +150,8 @@ export const createFilter = (field, operator, value, schema) => {
|
|
|
141
150
|
}
|
|
142
151
|
// TODO: this case does not cover complex objects for FULL_TEXT_SLUG
|
|
143
152
|
if (operator === FULL_TEXT_SLUG && schema.properties) {
|
|
144
|
-
const schemaKey =
|
|
145
|
-
const schemaValue =
|
|
153
|
+
const schemaKey = findKeyByDescription(schema.properties, 'key');
|
|
154
|
+
const schemaValue = findKeyByDescription(schema.properties, 'value');
|
|
146
155
|
const properties = [schemaKey, schemaValue]
|
|
147
156
|
.map((key) => key
|
|
148
157
|
? {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { convertRefSchemeToSchemaPath, getRefSchemeTitle, getRefSchemePrefix, isJSONSchema, parseDescription, parseDescriptionProperty, } from '../schemaOps';
|
|
2
|
-
import isEmpty from 'lodash/isEmpty';
|
|
3
2
|
import get from 'lodash/get';
|
|
4
3
|
const X_FOREIGN_KEY_SCHEMA_SEPARATOR = '___ref_scheme_separator_';
|
|
5
4
|
export const removeFieldsWithNoFilter = (schema) => {
|
|
6
5
|
const processProperties = (properties, parentXNoFilterSet) => {
|
|
6
|
+
var _a;
|
|
7
7
|
if (!properties) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
@@ -40,10 +40,10 @@ export const removeFieldsWithNoFilter = (schema) => {
|
|
|
40
40
|
newValue.items = Object.assign(Object.assign({}, value.items), { properties: processProperties(value.items.properties, xNoFilterSet) });
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
const hasEmptyProperties = newValue.properties &&
|
|
43
|
+
const hasEmptyProperties = newValue.properties && Object.keys(newValue.properties).length === 0;
|
|
44
44
|
const hasEmptyItemsProperties = isJSONSchema(newValue.items) &&
|
|
45
45
|
'properties' in newValue.items &&
|
|
46
|
-
|
|
46
|
+
Object.keys((_a = newValue.items.properties) !== null && _a !== void 0 ? _a : {}).length === 0;
|
|
47
47
|
if (hasEmptyProperties || hasEmptyItemsProperties) {
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as types from './types';
|
|
2
|
-
import uniq from 'lodash/uniq';
|
|
3
2
|
const lenses = Object.values(types);
|
|
4
3
|
// Returns an array of lenses that can be used to render `data`.
|
|
5
4
|
export const getLenses = (data, customLenses) => {
|
|
@@ -8,7 +7,7 @@ export const getLenses = (data, customLenses) => {
|
|
|
8
7
|
}
|
|
9
8
|
const concatenatedLenses = lenses.concat(customLenses !== null && customLenses !== void 0 ? customLenses : []);
|
|
10
9
|
const slugs = concatenatedLenses.map((lens) => lens.slug);
|
|
11
|
-
if (slugs.length >
|
|
10
|
+
if (slugs.length > new Set(slugs).size) {
|
|
12
11
|
throw new Error('Lenses must have unique slugs');
|
|
13
12
|
}
|
|
14
13
|
return concatenatedLenses;
|
|
@@ -33,9 +33,7 @@ const ArrayFieldTemplate = ({ items, canAdd, onAddClick, }) => {
|
|
|
33
33
|
'.MuiGrid-root > .form-group.field.field-object > .MuiFormControl-root > .MuiGrid-root.MuiGrid-container.MuiGrid-spacing-xs-2': {
|
|
34
34
|
marginTop: '-8px!important',
|
|
35
35
|
},
|
|
36
|
-
}, children: [element.children, _jsx(Box, { display: "flex", width: "50px", alignItems: "center", justifyContent: "center", children: index !== 0 && (_jsx(IconButton, { "aria-label": t('actions.remove_filter'),
|
|
37
|
-
// @ts-expect-error The typing of the current version of @rjsf/utils does not show that `onDropIndexClick` exists, even though it does
|
|
38
|
-
onClick: element.onDropIndexClick(element.index), sx: { mt: 2 }, children: _jsx(FontAwesomeIcon, { icon: faTimes }) })) })] }), _jsx(Box, { display: "flex", my: 2, children: canAdd && index === items.length - 1 && (_jsx(Button, { "aria-label": t('aria_labels.add_filter_in_or'), variant: "text", color: "primary", onClick: onAddClick, startIcon: _jsx(FontAwesomeIcon, { icon: faPlus }), children: t('actions.add_alternative') })) })] }, element.key));
|
|
36
|
+
}, children: [element.children, _jsx(Box, { display: "flex", width: "50px", alignItems: "center", justifyContent: "center", children: index !== 0 && (_jsx(IconButton, { "aria-label": t('actions.remove_filter'), onClick: element.onDropIndexClick(element.index), sx: { mt: 2 }, children: _jsx(FontAwesomeIcon, { icon: faTimes }) })) })] }), _jsx(Box, { display: "flex", my: 2, children: canAdd && index === items.length - 1 && (_jsx(Button, { "aria-label": t('aria_labels.add_filter_in_or'), variant: "text", color: "primary", onClick: onAddClick, startIcon: _jsx(FontAwesomeIcon, { icon: faPlus }), children: t('actions.add_alternative') })) })] }, element.key));
|
|
39
37
|
}) }));
|
|
40
38
|
};
|
|
41
39
|
const widgets = {
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
4
4
|
import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';
|
|
5
|
-
import uniq from 'lodash/uniq';
|
|
6
5
|
import { useQuery } from '@tanstack/react-query';
|
|
7
6
|
import { Stack } from '@mui/material';
|
|
8
7
|
export function useTagActions(rjstContext, data) {
|
|
@@ -20,7 +19,7 @@ export function useTagActions(rjstContext, data) {
|
|
|
20
19
|
const tagKey = Object.keys(d).find((key) => key.endsWith('_tag'));
|
|
21
20
|
return tagKey ? d[tagKey] : [];
|
|
22
21
|
});
|
|
23
|
-
return (_b =
|
|
22
|
+
return (_b = Array.from(new Set(tags.map((tag) => tag.tag_key)))) !== null && _b !== void 0 ? _b : null;
|
|
24
23
|
},
|
|
25
24
|
});
|
|
26
25
|
const actions = useMemo(() => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import invokeMap from 'lodash/invokeMap';
|
|
4
|
-
import isArray from 'lodash/isArray';
|
|
5
4
|
import { UiOption, JsonTypes, widgetFactory, formatTimestamp } from '../utils';
|
|
6
5
|
import { Truncate } from '../../../../Truncate';
|
|
7
6
|
import { Typography } from '@mui/material';
|
|
@@ -36,7 +35,7 @@ const TxtWidget = widgetFactory('Txt', [
|
|
|
36
35
|
variant: UiOption.string,
|
|
37
36
|
})(({ value, schema, uiSchema }) => {
|
|
38
37
|
var _a;
|
|
39
|
-
let displayValue = isArray(value)
|
|
38
|
+
let displayValue = Array.isArray(value)
|
|
40
39
|
? getArrayValue(value, uiSchema)
|
|
41
40
|
: value === null || value === void 0 ? void 0 : value.toString();
|
|
42
41
|
if (DATE_TIME_FORMATS.includes((_a = schema === null || schema === void 0 ? void 0 : schema.format) !== null && _a !== void 0 ? _a : '')) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import castArray from 'lodash/castArray';
|
|
3
2
|
import { JsonTypes } from './utils';
|
|
4
3
|
import { typeWidgets } from './Formats';
|
|
5
4
|
import { getSchemaFormat, getSubSchemaFromRefScheme } from '../../schemaOps';
|
|
@@ -38,7 +37,11 @@ export const Widget = ({ value, resource, schema = {}, extraFormats, uiSchema, }
|
|
|
38
37
|
}
|
|
39
38
|
const processedValue = getValue(value, schema, uiSchema);
|
|
40
39
|
const subSchema = getSubSchemaFromRefScheme(schema);
|
|
41
|
-
const types = (subSchema === null || subSchema === void 0 ? void 0 : subSchema.type) != null
|
|
40
|
+
const types = (subSchema === null || subSchema === void 0 ? void 0 : subSchema.type) != null
|
|
41
|
+
? Array.isArray(subSchema.type)
|
|
42
|
+
? subSchema.type
|
|
43
|
+
: [subSchema.type]
|
|
44
|
+
: [];
|
|
42
45
|
if (processedValue == null && !types.includes(JsonTypes.null)) {
|
|
43
46
|
return null;
|
|
44
47
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty';
|
|
2
1
|
import { rjstJsonSchemaPick } from '../schemaOps';
|
|
3
2
|
export const rjstDefaultPermissions = {
|
|
4
3
|
read: [],
|
|
@@ -10,7 +9,7 @@ export const rjstRunTransformers = (data, transformers, context) => {
|
|
|
10
9
|
if (!data) {
|
|
11
10
|
return data;
|
|
12
11
|
}
|
|
13
|
-
if (!transformers ||
|
|
12
|
+
if (!transformers || Object.keys(transformers).length === 0) {
|
|
14
13
|
return data;
|
|
15
14
|
}
|
|
16
15
|
const transformEntry = (entry) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getPropertyScheme } from './schemaOps';
|
|
2
|
-
import castArray from 'lodash/castArray';
|
|
3
2
|
import get from 'lodash/get';
|
|
4
3
|
import { JsonTypes } from './components/Widget/utils';
|
|
5
4
|
export const DEFAULT_ITEMS_PER_PAGE = 50;
|
|
@@ -119,7 +118,9 @@ const sortFn = (a, b, ref) => {
|
|
|
119
118
|
return diff(aa, bb);
|
|
120
119
|
};
|
|
121
120
|
export const getSortingFunction = (schemaKey, schemaValue) => {
|
|
122
|
-
const types =
|
|
121
|
+
const types = Array.isArray(schemaValue.type)
|
|
122
|
+
? schemaValue.type
|
|
123
|
+
: [schemaValue.type];
|
|
123
124
|
const refScheme = getPropertyScheme(schemaValue);
|
|
124
125
|
const splitRefScheme = (refScheme === null || refScheme === void 0 ? void 0 : refScheme[0]) ? splitPath(refScheme[0]) : null;
|
|
125
126
|
if (types.includes(JsonTypes.string)) {
|
|
@@ -1,8 +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 find from 'lodash/find';
|
|
4
|
-
import startsWith from 'lodash/startsWith';
|
|
5
|
-
import isEmpty from 'lodash/isEmpty';
|
|
6
3
|
import { Button, Stack, TextField, Typography } from '@mui/material';
|
|
7
4
|
import { Callout } from '../Callout';
|
|
8
5
|
import { useTranslation } from '../../hooks/useTranslations';
|
|
@@ -13,7 +10,7 @@ const RESERVED_NAMESPACES = ['io.resin.', 'io.balena.'];
|
|
|
13
10
|
const newTagValidationRules = (t, key, existingTags) => {
|
|
14
11
|
return [
|
|
15
12
|
{
|
|
16
|
-
test: () => !key
|
|
13
|
+
test: () => !key,
|
|
17
14
|
message: t('fields_errors.tag_name_cannot_be_empty'),
|
|
18
15
|
},
|
|
19
16
|
{
|
|
@@ -21,7 +18,7 @@ const newTagValidationRules = (t, key, existingTags) => {
|
|
|
21
18
|
message: t('fields_errors.tag_names_cannot_contain_whitespace'),
|
|
22
19
|
},
|
|
23
20
|
{
|
|
24
|
-
test: () => RESERVED_NAMESPACES.some((reserved) => startsWith(
|
|
21
|
+
test: () => RESERVED_NAMESPACES.some((reserved) => key.startsWith(reserved)),
|
|
25
22
|
message: t(`fields_errors.some_tag_keys_are_reserved`, {
|
|
26
23
|
namespace: RESERVED_NAMESPACES.join(', '),
|
|
27
24
|
}),
|
|
@@ -53,9 +50,7 @@ export const AddTagForm = ({ itemType, existingTags, overridableTags = [], addTa
|
|
|
53
50
|
return hasErrors;
|
|
54
51
|
};
|
|
55
52
|
const checkTagOverwrites = async () => {
|
|
56
|
-
const overridableTag = find(
|
|
57
|
-
tag_key: tagKey,
|
|
58
|
-
});
|
|
53
|
+
const overridableTag = overridableTags.find((tag) => tag.tag_key === tagKey);
|
|
59
54
|
if (!overridableTag) {
|
|
60
55
|
return true;
|
|
61
56
|
}
|
|
@@ -5,7 +5,6 @@ import { faUndo } from '@fortawesome/free-solid-svg-icons/faUndo';
|
|
|
5
5
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
6
6
|
import { AddTagForm } from './AddTagForm';
|
|
7
7
|
import sortBy from 'lodash/sortBy';
|
|
8
|
-
import toString from 'lodash/toString';
|
|
9
8
|
import { faPencilAlt } from '@fortawesome/free-solid-svg-icons/faPencilAlt';
|
|
10
9
|
import { getResourceTagSubmitInfo, groupResourcesByTags, } from './tag-management-service';
|
|
11
10
|
import partition from 'lodash/partition';
|
|
@@ -188,7 +187,9 @@ export const TagManagementDialog = ({ items, itemType, titleField, tagField, can
|
|
|
188
187
|
const getItemTitle = (item) => {
|
|
189
188
|
const title = typeof titleField === 'function'
|
|
190
189
|
? titleField(item)
|
|
191
|
-
:
|
|
190
|
+
: item[titleField] == null
|
|
191
|
+
? ''
|
|
192
|
+
: String(item[titleField]);
|
|
192
193
|
return title || `(${t('no_data.no_name_set')})`;
|
|
193
194
|
};
|
|
194
195
|
return (_jsxs(DialogWithCloseButton, { open: true, title: _jsxs(Stack, { children: [_jsxs(Typography, { variant: "h3", mt: 0, mb: 10, children: [items.length > 1 && _jsxs("span", { children: [t('labels.shared'), " "] }), t('labels.tags')] }), _jsx(CollectionSummary, { items: items.map(getItemTitle).sort(), itemsType: t('resource.' + itemType, { count: items.length }), maxVisibleItemCount: 10 })] }), children: [_jsxs(DialogContent, { children: [_jsx(AddTagForm, { itemType: itemType, existingTags: tags, overridableTags: partialTags, addTag: addTag, t: t }), _jsxs(Table, { children: [_jsxs(TableHead, { children: [_jsx(TableCell, {}), _jsx(TableCell, { children: t('labels.tag_name') }), _jsx(TableCell, { children: t('labels.value') }), _jsx(TableCell, {})] }), _jsx(TableBody, { children: !tags.length ? (_jsxs(TableRow, { children: [_jsx(TableCell, {}), _jsx(TableCell, { children: t(`errors.no_tags_for_selected_itemtype`, {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import keys from 'lodash/keys';
|
|
2
|
-
import flatMap from 'lodash/flatMap';
|
|
3
|
-
import map from 'lodash/map';
|
|
4
2
|
import groupBy from 'lodash/groupBy';
|
|
5
3
|
export const TAGS_COLUMN_KEY = 'Tags';
|
|
6
4
|
export const getTagKeyValueComposite = (tagKey, value) => `${tagKey}: ${value}`;
|
|
7
5
|
export const getResourceTags = (item, tagField) => { var _a; return ((_a = (tagField in item ? item[tagField] : null)) !== null && _a !== void 0 ? _a : []); };
|
|
8
6
|
export const groupResourcesByTags = (items, tagField) => {
|
|
9
|
-
const resourceTagInfos = flatMap(
|
|
7
|
+
const resourceTagInfos = items.flatMap((item) => {
|
|
10
8
|
const tags = getResourceTags(item, tagField);
|
|
11
9
|
return tags.map((tag) => ({
|
|
12
10
|
tag_key_value: getTagKeyValueComposite(tag.tag_key, tag.value),
|
|
@@ -16,13 +14,15 @@ export const groupResourcesByTags = (items, tagField) => {
|
|
|
16
14
|
}));
|
|
17
15
|
});
|
|
18
16
|
const tagsByTagKeyValue = groupBy(resourceTagInfos, 'tag_key_value');
|
|
19
|
-
const tagsWithItems =
|
|
17
|
+
const tagsWithItems = keys(tagsByTagKeyValue)
|
|
18
|
+
.sort()
|
|
19
|
+
.map((tagKeyValue) => {
|
|
20
20
|
const tags = tagsByTagKeyValue[tagKeyValue];
|
|
21
21
|
const firstTag = tags[0];
|
|
22
22
|
return {
|
|
23
23
|
tag_key: firstTag.tag_key,
|
|
24
24
|
value: firstTag.value,
|
|
25
|
-
items: map(
|
|
25
|
+
items: tags.map((tag) => tag.item),
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
28
|
return tagsWithItems;
|
package/dist/theme.js
CHANGED
|
@@ -1077,7 +1077,7 @@ export const theme = createTheme({
|
|
|
1077
1077
|
},
|
|
1078
1078
|
},
|
|
1079
1079
|
},
|
|
1080
|
-
|
|
1080
|
+
MuiGrid2: {
|
|
1081
1081
|
// We should only apply this spacing to Grid components with `container`
|
|
1082
1082
|
// But MUI does not currently support that for defaultProps
|
|
1083
1083
|
// See: https://github.com/mui/material-ui/issues/34812
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/ui-shared-components",
|
|
3
|
-
"version": "14.0.4-build-
|
|
3
|
+
"version": "14.0.4-build-drop-some-lodash-for-native-alternatives-2262746e9e370b6af606616f09e32c1ca2a3232d-1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"@emotion/styled": "^11.10.6",
|
|
18
18
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
|
19
19
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
20
|
-
"@mui/lab": "
|
|
21
|
-
"@mui/material": "^
|
|
22
|
-
"@mui/styled-engine-sc": "^
|
|
23
|
-
"@mui/x-data-grid": "^7.
|
|
20
|
+
"@mui/lab": "6.0.0-beta.24",
|
|
21
|
+
"@mui/material": "^6.3.1",
|
|
22
|
+
"@mui/styled-engine-sc": "^6.3.1",
|
|
23
|
+
"@mui/x-data-grid": "^7.23.5",
|
|
24
24
|
"@react-google-maps/api": "^2.18.1",
|
|
25
|
-
"@rjsf/core": "
|
|
26
|
-
"@rjsf/mui": "
|
|
27
|
-
"@rjsf/utils": "
|
|
28
|
-
"@rjsf/validator-ajv8": "
|
|
25
|
+
"@rjsf/core": "^5.24.1",
|
|
26
|
+
"@rjsf/mui": "^5.24.1",
|
|
27
|
+
"@rjsf/utils": "^5.24.1",
|
|
28
|
+
"@rjsf/validator-ajv8": "^5.24.1",
|
|
29
29
|
"@tanstack/react-query": "^5.64.2",
|
|
30
30
|
"@types/jest": "^29.5.14",
|
|
31
31
|
"ajv": "^8.17.1",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"react-dom": "^18.2.0",
|
|
44
44
|
"react-dropzone": "^14.2.3",
|
|
45
45
|
"react-helmet": "^6.1.0",
|
|
46
|
-
"react-is": "^18.2.0",
|
|
47
46
|
"react-markdown": "^10.0.0",
|
|
48
47
|
"react-router-dom": "^6.28.0",
|
|
49
48
|
"remark-breaks": "^4.0.0",
|
|
@@ -55,7 +54,7 @@
|
|
|
55
54
|
"zxcvbn": "^4.4.2"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@balena/lint": "^9.3.
|
|
57
|
+
"@balena/lint": "^9.3.7",
|
|
59
58
|
"@storybook/addon-docs": "^9.0.0",
|
|
60
59
|
"@storybook/addon-links": "^9.0.0",
|
|
61
60
|
"@storybook/addon-onboarding": "^9.0.0",
|
|
@@ -133,10 +132,9 @@
|
|
|
133
132
|
},
|
|
134
133
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
135
134
|
"versionist": {
|
|
136
|
-
"publishedAt": "2025-09-
|
|
135
|
+
"publishedAt": "2025-09-23T16:12:40.232Z"
|
|
137
136
|
},
|
|
138
137
|
"overrides": {
|
|
139
|
-
"storybook": "$storybook"
|
|
140
|
-
"react-is": "^18.2.0"
|
|
138
|
+
"storybook": "$storybook"
|
|
141
139
|
}
|
|
142
140
|
}
|