@balena/ui-shared-components 14.0.4-build-drop-some-lodash-for-native-alternatives-2262746e9e370b6af606616f09e32c1ca2a3232d-1 → 14.0.4-build-drop-some-lodash-for-native-alternatives-2a3088132113a3386a2f3ebdc5a452727d0d746c-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/index.js +2 -1
- package/dist/components/DownloadImageDialog/version.js +2 -1
- package/dist/components/DropDownButton/index.js +2 -1
- package/dist/components/Form/Widgets/FileWidget.js +3 -2
- package/dist/components/RJST/components/Table/useTagActions.js +2 -1
- package/dist/components/RJST/components/Widget/index.js +2 -5
- package/dist/components/RJST/utils.js +2 -3
- package/dist/components/TagManagementDialog/index.js +2 -3
- package/dist/components/TagManagementDialog/tag-management-service.js +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/arrays.d.ts +2 -0
- package/dist/utils/arrays.js +6 -0
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@ import { DropDownButton } from '../DropDownButton';
|
|
|
8
8
|
import pickBy from 'lodash/pickBy';
|
|
9
9
|
import debounce from 'lodash/debounce';
|
|
10
10
|
import { OsTypesEnum } from './models';
|
|
11
|
+
import { uniq } from '../../utils/arrays';
|
|
11
12
|
import { enqueueSnackbar } from 'notistack';
|
|
12
13
|
import { DialogWithCloseButton } from '../DialogWithCloseButton';
|
|
13
14
|
import { Callout } from '../Callout';
|
|
@@ -28,7 +29,7 @@ const getUniqueOsTypes = (osVersions, deviceTypeSlug) => {
|
|
|
28
29
|
osVersions[deviceTypeSlug].length === 0) {
|
|
29
30
|
return [];
|
|
30
31
|
}
|
|
31
|
-
return
|
|
32
|
+
return uniq(osVersions[deviceTypeSlug].map((x) => x.osType));
|
|
32
33
|
};
|
|
33
34
|
const generateImageUrl = (model, downloadUrl) => {
|
|
34
35
|
// TODO check if possible to edit Etcher to avoid a double encode on the version.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { uniq } from '../../utils/arrays';
|
|
1
2
|
import partition from 'lodash/partition';
|
|
2
3
|
export const transformVersions = (versions) => {
|
|
3
4
|
const optsByVersion = {};
|
|
@@ -31,7 +32,7 @@ export const getPreferredVersionOpts = (versionOpts) => {
|
|
|
31
32
|
return major && parseInt(major, 10) > LEGACY_OS_VERSION_MAJOR;
|
|
32
33
|
});
|
|
33
34
|
const opts = supportedVersions.length ? supportedVersions : legacyVersions;
|
|
34
|
-
const lines =
|
|
35
|
+
const lines = uniq(opts.map((option) => option.line));
|
|
35
36
|
const hasMultipleLines = lines.length > 1;
|
|
36
37
|
if (hasMultipleLines) {
|
|
37
38
|
const preferredMultilineOpts = {};
|
|
@@ -21,12 +21,13 @@ export const DropDownButton = (_a) => {
|
|
|
21
21
|
// const items = [{...menuItem, section: 'test1'}, {...menuItem, section: 'test2'}];
|
|
22
22
|
// <Dropdown groupByProp='section' .../>
|
|
23
23
|
const memoizedItems = useMemo(() => {
|
|
24
|
+
var _a;
|
|
24
25
|
if (!groupByProp) {
|
|
25
26
|
return items;
|
|
26
27
|
}
|
|
27
28
|
const grouped = groupBy(items, (item) => item[groupByProp]);
|
|
28
29
|
const entries = Object.entries(grouped);
|
|
29
|
-
const lastKey = entries
|
|
30
|
+
const lastKey = (_a = entries.at(-1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
30
31
|
return entries
|
|
31
32
|
.flatMap(([key, value]) => value.map((v, index) => key !== lastKey && index === value.length - 1
|
|
32
33
|
? Object.assign(Object.assign({}, v), { divider: true }) : v))
|
|
@@ -7,6 +7,7 @@ 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 '../../../utils/arrays';
|
|
10
11
|
import { token } from '../../../utils/token';
|
|
11
12
|
const restingStyle = {
|
|
12
13
|
borderColor: token('color.border'),
|
|
@@ -163,11 +164,11 @@ export const FileWidget = ({ onChange, multiple, schema, uiSchema, }) => {
|
|
|
163
164
|
: // TODO: icon sizes need to be properly added to the design tokens
|
|
164
165
|
{ 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
|
|
165
166
|
? ''
|
|
166
|
-
: `Supported formats: ${
|
|
167
|
+
: `Supported formats: ${uniq(Object.values(accept)
|
|
167
168
|
// The values of accept are arrays of file types, take them and flatten them
|
|
168
169
|
.flat()
|
|
169
170
|
// Remove the dot from the file type and capitalize it
|
|
170
|
-
.map((fileType) => fileType.slice(1).toUpperCase()))
|
|
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
|
|
171
172
|
.flatMap((errorFile) => errorFile.errors)
|
|
172
173
|
.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 }),
|
|
173
174
|
_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
|
|
@@ -2,6 +2,7 @@ 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 '../../../../utils/arrays';
|
|
5
6
|
import { useQuery } from '@tanstack/react-query';
|
|
6
7
|
import { Stack } from '@mui/material';
|
|
7
8
|
export function useTagActions(rjstContext, data) {
|
|
@@ -19,7 +20,7 @@ export function useTagActions(rjstContext, data) {
|
|
|
19
20
|
const tagKey = Object.keys(d).find((key) => key.endsWith('_tag'));
|
|
20
21
|
return tagKey ? d[tagKey] : [];
|
|
21
22
|
});
|
|
22
|
-
return (_b =
|
|
23
|
+
return (_b = uniq(tags.map((tag) => tag.tag_key))) !== null && _b !== void 0 ? _b : null;
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
const actions = useMemo(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { toArray } from '../../../../utils/arrays';
|
|
2
3
|
import { JsonTypes } from './utils';
|
|
3
4
|
import { typeWidgets } from './Formats';
|
|
4
5
|
import { getSchemaFormat, getSubSchemaFromRefScheme } from '../../schemaOps';
|
|
@@ -37,11 +38,7 @@ export const Widget = ({ value, resource, schema = {}, extraFormats, uiSchema, }
|
|
|
37
38
|
}
|
|
38
39
|
const processedValue = getValue(value, schema, uiSchema);
|
|
39
40
|
const subSchema = getSubSchemaFromRefScheme(schema);
|
|
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
|
-
: [];
|
|
41
|
+
const types = (subSchema === null || subSchema === void 0 ? void 0 : subSchema.type) != null ? toArray(subSchema.type) : [];
|
|
45
42
|
if (processedValue == null && !types.includes(JsonTypes.null)) {
|
|
46
43
|
return null;
|
|
47
44
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getPropertyScheme } from './schemaOps';
|
|
2
|
+
import { toArray } from '../../utils/arrays';
|
|
2
3
|
import get from 'lodash/get';
|
|
3
4
|
import { JsonTypes } from './components/Widget/utils';
|
|
4
5
|
export const DEFAULT_ITEMS_PER_PAGE = 50;
|
|
@@ -118,9 +119,7 @@ const sortFn = (a, b, ref) => {
|
|
|
118
119
|
return diff(aa, bb);
|
|
119
120
|
};
|
|
120
121
|
export const getSortingFunction = (schemaKey, schemaValue) => {
|
|
121
|
-
const types =
|
|
122
|
-
? schemaValue.type
|
|
123
|
-
: [schemaValue.type];
|
|
122
|
+
const types = toArray(schemaValue.type);
|
|
124
123
|
const refScheme = getPropertyScheme(schemaValue);
|
|
125
124
|
const splitRefScheme = (refScheme === null || refScheme === void 0 ? void 0 : refScheme[0]) ? splitPath(refScheme[0]) : null;
|
|
126
125
|
if (types.includes(JsonTypes.string)) {
|
|
@@ -185,11 +185,10 @@ export const TagManagementDialog = ({ items, itemType, titleField, tagField, can
|
|
|
185
185
|
setTags(tags.slice());
|
|
186
186
|
};
|
|
187
187
|
const getItemTitle = (item) => {
|
|
188
|
+
var _a;
|
|
188
189
|
const title = typeof titleField === 'function'
|
|
189
190
|
? titleField(item)
|
|
190
|
-
: item[titleField]
|
|
191
|
-
? ''
|
|
192
|
-
: String(item[titleField]);
|
|
191
|
+
: `${(_a = item[titleField]) !== null && _a !== void 0 ? _a : ''}`;
|
|
193
192
|
return title || `(${t('no_data.no_name_set')})`;
|
|
194
193
|
};
|
|
195
194
|
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,4 +1,3 @@
|
|
|
1
|
-
import keys from 'lodash/keys';
|
|
2
1
|
import groupBy from 'lodash/groupBy';
|
|
3
2
|
export const TAGS_COLUMN_KEY = 'Tags';
|
|
4
3
|
export const getTagKeyValueComposite = (tagKey, value) => `${tagKey}: ${value}`;
|
|
@@ -14,7 +13,7 @@ export const groupResourcesByTags = (items, tagField) => {
|
|
|
14
13
|
}));
|
|
15
14
|
});
|
|
16
15
|
const tagsByTagKeyValue = groupBy(resourceTagInfos, 'tag_key_value');
|
|
17
|
-
const tagsWithItems = keys(tagsByTagKeyValue)
|
|
16
|
+
const tagsWithItems = Object.keys(tagsByTagKeyValue)
|
|
18
17
|
.sort()
|
|
19
18
|
.map((tagKeyValue) => {
|
|
20
19
|
const tags = tagsByTagKeyValue[tagKeyValue];
|
package/dist/index.d.ts
CHANGED
|
@@ -92,5 +92,6 @@ export * as MaterialDataGrid from '@mui/x-data-grid';
|
|
|
92
92
|
export { enqueueSnackbar, closeSnackbar } from 'notistack';
|
|
93
93
|
export { useRandomUUID } from './hooks/useRandomUUID';
|
|
94
94
|
export { token } from './utils/token';
|
|
95
|
+
export { uniq, toArray } from './utils/arrays';
|
|
95
96
|
export * as designTokens from '@balena/design-tokens';
|
|
96
97
|
export * as ReactQuery from '@tanstack/react-query';
|
package/dist/index.js
CHANGED
|
@@ -53,5 +53,6 @@ export * as MaterialDataGrid from '@mui/x-data-grid';
|
|
|
53
53
|
export { enqueueSnackbar, closeSnackbar } from 'notistack';
|
|
54
54
|
export { useRandomUUID } from './hooks/useRandomUUID';
|
|
55
55
|
export { token } from './utils/token';
|
|
56
|
+
export { uniq, toArray } from './utils/arrays';
|
|
56
57
|
export * as designTokens from '@balena/design-tokens';
|
|
57
58
|
export * as ReactQuery from '@tanstack/react-query';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/ui-shared-components",
|
|
3
|
-
"version": "14.0.4-build-drop-some-lodash-for-native-alternatives-
|
|
3
|
+
"version": "14.0.4-build-drop-some-lodash-for-native-alternatives-2a3088132113a3386a2f3ebdc5a452727d0d746c-1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
},
|
|
133
133
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
134
134
|
"versionist": {
|
|
135
|
-
"publishedAt": "2025-09-
|
|
135
|
+
"publishedAt": "2025-09-24T13:08:27.501Z"
|
|
136
136
|
},
|
|
137
137
|
"overrides": {
|
|
138
138
|
"storybook": "$storybook"
|