@nordicsemiconductor/pc-nrfconnect-shared 60.0.0-pre1 → 60.0.0-pre2

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 (232) hide show
  1. package/dist/bootstrap.css +8951 -0
  2. package/dist/index.css +1451 -0
  3. package/dist/index.js +122119 -0
  4. package/{src/Logo/nordic-logo-blue-icon-only.png → dist/nordic-logo-blue-icon-only-H7BABN6D.png} +0 -0
  5. package/{src/Logo/nordic-logo-gray-icon-only.png → dist/nordic-logo-gray-icon-only-GATOTR3L.png} +0 -0
  6. package/package.json +12 -3
  7. package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts +1 -2
  8. package/.github/ISSUE_TEMPLATE/custom.md +0 -10
  9. package/.husky/pre-push +0 -3
  10. package/.renovaterc.json +0 -10
  11. package/Changelog.md +0 -2973
  12. package/azure-pipelines.yml +0 -34
  13. package/config/eslintrc.js +0 -190
  14. package/config/jest.config.js +0 -41
  15. package/config/prettier.config.js +0 -13
  16. package/config/tsconfig.json +0 -15
  17. package/fw/bootloader/graviton_bootloader_v1.0.1-[nRF5_SDK_15.0.1-1.alpha_f76d012].zip +0 -0
  18. package/jest.config.js +0 -7
  19. package/main/index.ts +0 -32
  20. package/mocks/deviceLibMock.ts +0 -21
  21. package/mocks/electronMock.ts +0 -15
  22. package/mocks/electronStoreMock.ts +0 -19
  23. package/mocks/emptyMock.ts +0 -7
  24. package/mocks/fileMock.ts +0 -13
  25. package/mocks/gaMock.ts +0 -9
  26. package/mocks/mockTests.test.ts +0 -15
  27. package/mocks/packageJsonMock.ts +0 -10
  28. package/mocks/remoteMock.ts +0 -17
  29. package/scripts/esbuild-bootstrap.js +0 -15
  30. package/scripts/esbuild-renderer.js +0 -131
  31. package/scripts/installHusky.ts +0 -17
  32. package/scripts/prepare-shared-release.ts +0 -122
  33. package/scripts/release-shared.test.ts +0 -132
  34. package/scripts/release-shared.ts +0 -207
  35. package/src/About/About.tsx +0 -25
  36. package/src/About/AboutButton.tsx +0 -28
  37. package/src/About/ApplicationCard.tsx +0 -83
  38. package/src/About/DeviceCard.tsx +0 -74
  39. package/src/About/DocumentationCard.tsx +0 -18
  40. package/src/About/DocumentationSection.tsx +0 -24
  41. package/src/About/Section.tsx +0 -21
  42. package/src/About/ShortcutButton.tsx +0 -41
  43. package/src/About/SupportCard.tsx +0 -97
  44. package/src/About/about.scss +0 -40
  45. package/src/About/documentationSlice.ts +0 -41
  46. package/src/About/section.scss +0 -15
  47. package/src/About/shortcutSlice.ts +0 -52
  48. package/src/Alert/Alert.module.scss +0 -29
  49. package/src/Alert/Alert.tsx +0 -37
  50. package/src/App/App.test.tsx +0 -47
  51. package/src/App/App.tsx +0 -227
  52. package/src/App/ConnectedToStore.tsx +0 -19
  53. package/src/App/VisibilityBar.tsx +0 -103
  54. package/src/App/app.scss +0 -83
  55. package/src/App/appLayout.ts +0 -95
  56. package/src/App/shared.scss +0 -49
  57. package/src/App/visibility-bar.scss +0 -55
  58. package/src/Button/Button.tsx +0 -66
  59. package/src/Button/button.module.scss +0 -154
  60. package/src/Card/Card.tsx +0 -26
  61. package/src/Card/card.module.scss +0 -28
  62. package/src/Device/BrokenDeviceDialog/BrokenDeviceDialog.tsx +0 -58
  63. package/src/Device/BrokenDeviceDialog/broken-device-dialog.scss +0 -18
  64. package/src/Device/BrokenDeviceDialog/brokenDeviceDialogSlice.tsx +0 -48
  65. package/src/Device/DeviceSelector/BasicDeviceInfo.tsx +0 -115
  66. package/src/Device/DeviceSelector/DeviceIcon.tsx +0 -27
  67. package/src/Device/DeviceSelector/DeviceList/AnimatedList.tsx +0 -62
  68. package/src/Device/DeviceSelector/DeviceList/BrokenDevice.tsx +0 -34
  69. package/src/Device/DeviceSelector/DeviceList/Device.tsx +0 -84
  70. package/src/Device/DeviceSelector/DeviceList/DeviceList.tsx +0 -113
  71. package/src/Device/DeviceSelector/DeviceList/EditDeviceButtons.tsx +0 -28
  72. package/src/Device/DeviceSelector/DeviceList/MoreDeviceInfo.tsx +0 -65
  73. package/src/Device/DeviceSelector/DeviceList/RenameDevice.tsx +0 -22
  74. package/src/Device/DeviceSelector/DeviceList/broken-device.scss +0 -32
  75. package/src/Device/DeviceSelector/DeviceList/device-list.scss +0 -64
  76. package/src/Device/DeviceSelector/DeviceList/device.scss +0 -28
  77. package/src/Device/DeviceSelector/DeviceList/edit-device-buttons.scss +0 -31
  78. package/src/Device/DeviceSelector/DeviceList/more-device-info.scss +0 -33
  79. package/src/Device/DeviceSelector/DeviceList/rename-device.scss +0 -13
  80. package/src/Device/DeviceSelector/DeviceSelector.test.tsx +0 -342
  81. package/src/Device/DeviceSelector/DeviceSelector.tsx +0 -173
  82. package/src/Device/DeviceSelector/Favorite.tsx +0 -49
  83. package/src/Device/DeviceSelector/SelectDevice.tsx +0 -36
  84. package/src/Device/DeviceSelector/SelectedDevice.tsx +0 -65
  85. package/src/Device/DeviceSelector/arrow-down.svg +0 -1
  86. package/src/Device/DeviceSelector/basic-device-info.scss +0 -62
  87. package/src/Device/DeviceSelector/device-icon.scss +0 -27
  88. package/src/Device/DeviceSelector/favorite.scss +0 -17
  89. package/src/Device/DeviceSelector/select-device.scss +0 -38
  90. package/src/Device/DeviceSelector/selected-device.scss +0 -57
  91. package/src/Device/DeviceSetup/DeviceSetupView.tsx +0 -102
  92. package/src/Device/deviceAutoSelectSlice.ts +0 -144
  93. package/src/Device/deviceInfo/deviceInfo.ts +0 -254
  94. package/src/Device/deviceInfo/nRF51-Series-logo.svg +0 -1
  95. package/src/Device/deviceInfo/nRF52-Series-logo.svg +0 -1
  96. package/src/Device/deviceInfo/nRF53-Series-logo.svg +0 -1
  97. package/src/Device/deviceInfo/nRF70-Series_no-background_RGB.svg +0 -36
  98. package/src/Device/deviceInfo/nRF91-Series-logo.svg +0 -1
  99. package/src/Device/deviceInfo/ppk-logo.svg +0 -1
  100. package/src/Device/deviceInfo/unknown-logo.svg +0 -30
  101. package/src/Device/deviceInfo/unknown-nordic-logo.svg +0 -25
  102. package/src/Device/deviceLibWrapper.test.ts +0 -97
  103. package/src/Device/deviceLibWrapper.ts +0 -133
  104. package/src/Device/deviceLister.test.ts +0 -89
  105. package/src/Device/deviceLister.ts +0 -396
  106. package/src/Device/deviceSetup.ts +0 -264
  107. package/src/Device/deviceSetupSlice.ts +0 -94
  108. package/src/Device/deviceSlice.ts +0 -248
  109. package/src/Device/dfu-cc.ts +0 -162
  110. package/src/Device/initPacket.ts +0 -402
  111. package/src/Device/jprogOperations.ts +0 -206
  112. package/src/Device/sdfuOperations.ts +0 -601
  113. package/src/Dialog/Dialog.test.tsx +0 -134
  114. package/src/Dialog/Dialog.tsx +0 -236
  115. package/src/Dialog/dialog.scss +0 -60
  116. package/src/Dropdown/Dropdown.module.scss +0 -83
  117. package/src/Dropdown/Dropdown.test.tsx +0 -62
  118. package/src/Dropdown/Dropdown.tsx +0 -106
  119. package/src/ErrorBoundary/ErrorBoundary.test.tsx +0 -105
  120. package/src/ErrorBoundary/ErrorBoundary.tsx +0 -186
  121. package/src/ErrorBoundary/bug.svg +0 -1
  122. package/src/ErrorBoundary/error-boundary.scss +0 -102
  123. package/src/ErrorDialog/ErrorDialog.test.tsx +0 -70
  124. package/src/ErrorDialog/ErrorDialog.tsx +0 -94
  125. package/src/ErrorDialog/error.scss +0 -14
  126. package/src/ErrorDialog/errorDialogSlice.test.ts +0 -64
  127. package/src/ErrorDialog/errorDialogSlice.ts +0 -80
  128. package/src/FactoryReset/FactoryResetButton.test.tsx +0 -46
  129. package/src/FactoryReset/FactoryResetButton.tsx +0 -81
  130. package/src/InlineInput/InlineInput.tsx +0 -170
  131. package/src/InlineInput/NumberInlineInput.tsx +0 -107
  132. package/src/InlineInput/inline-input.scss +0 -38
  133. package/src/InlineInput/number-inline-input.scss +0 -15
  134. package/src/Log/LogEntry.tsx +0 -62
  135. package/src/Log/LogViewer.tsx +0 -54
  136. package/src/Log/log-entry.scss +0 -30
  137. package/src/Log/log-viewer.scss +0 -24
  138. package/src/Log/logSlice.ts +0 -73
  139. package/src/Log/syncLogToStore.ts +0 -36
  140. package/src/Logo/Logo.tsx +0 -48
  141. package/src/Logo/logo.scss +0 -11
  142. package/src/Main/Main.tsx +0 -13
  143. package/src/Main/main.scss +0 -13
  144. package/src/MasonryLayout/MasonryLayout.tsx +0 -234
  145. package/src/MasonryLayout/masonryLayout.module.scss +0 -46
  146. package/src/NavBar/NavBar.tsx +0 -22
  147. package/src/NavBar/NavMenu.test.tsx +0 -41
  148. package/src/NavBar/NavMenu.tsx +0 -53
  149. package/src/NavBar/NavMenuItem.tsx +0 -41
  150. package/src/NavBar/nav-bar.scss +0 -26
  151. package/src/NavBar/nav-menu-item.scss +0 -34
  152. package/src/OpenApp/openApp.ts +0 -18
  153. package/src/Panes/FeedbackPane.tsx +0 -149
  154. package/src/PseudoButton/PseudoButton.tsx +0 -56
  155. package/src/PseudoButton/pseudo-button.scss +0 -11
  156. package/src/SerialPort/ConflictingSettingsDialog.tsx +0 -242
  157. package/src/SerialPort/SerialPort.test.ts +0 -54
  158. package/src/SerialPort/SerialPort.ts +0 -202
  159. package/src/Shortcuts/Shortcut-item.scss +0 -33
  160. package/src/Shortcuts/Shortcut-modal.scss +0 -20
  161. package/src/Shortcuts/ShortcutItem.tsx +0 -48
  162. package/src/Shortcuts/ShortcutModal.tsx +0 -67
  163. package/src/SidePanel/Group.tsx +0 -106
  164. package/src/SidePanel/SidePanel.tsx +0 -19
  165. package/src/SidePanel/group.scss +0 -42
  166. package/src/SidePanel/sidepanel.scss +0 -20
  167. package/src/Slider/Bar.tsx +0 -24
  168. package/src/Slider/Factor.test.ts +0 -48
  169. package/src/Slider/Handle.tsx +0 -121
  170. package/src/Slider/Slider.test.tsx +0 -25
  171. package/src/Slider/Slider.tsx +0 -91
  172. package/src/Slider/Ticks.tsx +0 -54
  173. package/src/Slider/__snapshots__/Slider.test.tsx.snap +0 -50
  174. package/src/Slider/bar.scss +0 -24
  175. package/src/Slider/factor.ts +0 -24
  176. package/src/Slider/handle.scss +0 -32
  177. package/src/Slider/percentage.ts +0 -67
  178. package/src/Slider/range.ts +0 -92
  179. package/src/Slider/slider.scss +0 -14
  180. package/src/Slider/ticks.scss +0 -28
  181. package/src/Slider/variables.scss +0 -16
  182. package/src/StartStopButton/StartStopButton.tsx +0 -60
  183. package/src/StartStopButton/play-circle.svg +0 -1
  184. package/src/StartStopButton/start-stop-button.scss +0 -47
  185. package/src/StartStopButton/stop-circle.svg +0 -1
  186. package/src/StateSelector/StateSelector.tsx +0 -64
  187. package/src/StateSelector/state-selector.scss +0 -38
  188. package/src/Stepper/Stepper.tsx +0 -139
  189. package/src/Stepper/stepper.scss +0 -127
  190. package/src/Toggle/Toggle.tsx +0 -120
  191. package/src/Toggle/toggle.scss +0 -109
  192. package/src/bootstrap.scss +0 -14
  193. package/src/index.ts +0 -146
  194. package/src/logging/appTransport.test.ts +0 -78
  195. package/src/logging/appTransport.ts +0 -41
  196. package/src/logging/describeError.test.ts +0 -38
  197. package/src/logging/describeError.ts +0 -56
  198. package/src/logging/index.ts +0 -103
  199. package/src/logging/logBuffer.test.ts +0 -41
  200. package/src/logging/logBuffer.ts +0 -24
  201. package/src/logging/sendInitialLogMessages.ts +0 -64
  202. package/src/store.ts +0 -60
  203. package/src/svg.d.ts +0 -15
  204. package/src/utils/AppTypes.ts +0 -60
  205. package/src/utils/appDirs.ts +0 -78
  206. package/src/utils/bleChannels.ts +0 -16
  207. package/src/utils/classNames.test.ts +0 -29
  208. package/src/utils/classNames.ts +0 -25
  209. package/src/utils/colors.scss +0 -46
  210. package/src/utils/colors.ts +0 -38
  211. package/src/utils/describeVersion.ts +0 -21
  212. package/src/utils/environment.ts +0 -6
  213. package/src/utils/logLibVersions.ts +0 -103
  214. package/src/utils/open.ts +0 -46
  215. package/src/utils/packageJson.ts +0 -60
  216. package/src/utils/persistentStore.ts +0 -144
  217. package/src/utils/systemReport.ts +0 -160
  218. package/src/utils/truncateMiddle.test.ts +0 -21
  219. package/src/utils/truncateMiddle.ts +0 -20
  220. package/src/utils/usageData.ts +0 -189
  221. package/src/utils/useHotKey.ts +0 -62
  222. package/src/utils/useStopwatch.test.tsx +0 -311
  223. package/src/utils/useStopwatch.ts +0 -140
  224. package/src/variables.scss +0 -820
  225. package/styles.scss +0 -88
  226. package/test/dispatchTo.ts +0 -23
  227. package/test/index.ts +0 -7
  228. package/test/jestResolver.js +0 -28
  229. package/test/setupTests.ts +0 -27
  230. package/test/testUtil.ts +0 -20
  231. package/test/testrenderer.tsx +0 -39
  232. /package/{src/Logo/nordic-logo-white-icon-only.png → dist/nordic-logo-white-icon-only-XIZBW537.png} +0 -0
@@ -1,24 +0,0 @@
1
- /*
2
- * Copyright (c) 2021 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- @import "../variables";
8
-
9
- .core19-log {
10
- position: relative;
11
- overflow: auto;
12
- height: $log-viewer-height;
13
-
14
- scroll-snap-type: y mandatory;
15
-
16
- > div {
17
- display: table;
18
- min-width: 100%;
19
-
20
- scroll-snap-align: start;
21
- }
22
-
23
- @include scrollbars($gray-900);
24
- }
@@ -1,73 +0,0 @@
1
- /*
2
- * Copyright (c) 2021 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import { createSlice, PayloadAction } from '@reduxjs/toolkit';
8
- import { LogEntry } from 'winston';
9
-
10
- import type { RootState } from '../store';
11
- import { getIsLoggingVerbose } from '../utils/persistentStore';
12
-
13
- const MAX_ENTRIES = 1000;
14
-
15
- export interface Log {
16
- autoScroll: boolean;
17
- logEntries: LogEntry[];
18
- isLoggingVerbose: boolean;
19
- }
20
-
21
- const initialState: Log = {
22
- autoScroll: true,
23
- logEntries: [],
24
- isLoggingVerbose: getIsLoggingVerbose(),
25
- };
26
-
27
- const infoEntry = () => ({
28
- id: -1,
29
- level: 'info',
30
- timestamp: new Date().toISOString(),
31
- message:
32
- 'The log in this view has been shortened. Open the log file to see the full content.',
33
- });
34
-
35
- const limitedToMaxSize = (entries: LogEntry[]) =>
36
- entries.length <= MAX_ENTRIES
37
- ? entries
38
- : [infoEntry(), ...entries.slice(-MAX_ENTRIES)];
39
-
40
- export const autoScroll = (state: RootState) => state.log.autoScroll;
41
- export const logEntries = (state: RootState) => state.log.logEntries;
42
- let isLoggingVerboseLocal = initialState.isLoggingVerbose;
43
- export const isLoggingVerbose = () => isLoggingVerboseLocal;
44
- export const isLoggingVerboseSelector = (state: RootState) =>
45
- state.log.isLoggingVerbose;
46
-
47
- const slice = createSlice({
48
- name: 'log',
49
- initialState,
50
- reducers: {
51
- addEntries: (state, action: PayloadAction<LogEntry[]>) => {
52
- state.logEntries = limitedToMaxSize([
53
- ...state.logEntries,
54
- ...action.payload,
55
- ]);
56
- },
57
- clear: state => {
58
- state.logEntries = [];
59
- },
60
- toggleAutoScroll: state => {
61
- state.autoScroll = !state.autoScroll;
62
- },
63
- toggleIsLoggingVerbose: state => {
64
- state.isLoggingVerbose = !state.isLoggingVerbose;
65
- isLoggingVerboseLocal = state.isLoggingVerbose;
66
- },
67
- },
68
- });
69
-
70
- export const {
71
- reducer,
72
- actions: { addEntries, clear, toggleAutoScroll, toggleIsLoggingVerbose },
73
- } = slice;
@@ -1,36 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import logger from '../logging';
8
- import { AppDispatch } from '../store';
9
- import { addEntries } from './logSlice';
10
-
11
- const addLogEntriesToStore = (dispatch: AppDispatch) => () => {
12
- const entries = logger.getAndClearEntries();
13
- if (entries.length > 0) {
14
- dispatch(addEntries(entries));
15
- }
16
- };
17
-
18
- /**
19
- * Starts syncing to new log entries from the application's log buffer.
20
- * Incoming entries are added to the state, so that they can be displayed
21
- * in the UI.
22
- *
23
- * @param {function} dispatch The redux dispatch function.
24
- * @returns {function(*)} Function that stops the listener.
25
- */
26
- export default (dispatch: AppDispatch) => {
27
- const LOG_UPDATE_INTERVAL = 400;
28
- const logListener = setInterval(
29
- addLogEntriesToStore(dispatch),
30
- LOG_UPDATE_INTERVAL
31
- );
32
-
33
- return () => {
34
- clearInterval(logListener);
35
- };
36
- };
package/src/Logo/Logo.tsx DELETED
@@ -1,48 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import React, { FC } from 'react';
8
- import { useSelector } from 'react-redux';
9
-
10
- import { deviceIsSelected as deviceIsSelectedSelector } from '../Device/deviceSlice';
11
- import { openUrl } from '../utils/open';
12
- import logoConnected from './nordic-logo-blue-icon-only.png';
13
- import logoDisconnected from './nordic-logo-gray-icon-only.png';
14
- import logoUniform from './nordic-logo-white-icon-only.png';
15
-
16
- import './logo.scss';
17
-
18
- const goToNRFConnectWebsite = () =>
19
- openUrl('http://www.nordicsemi.com/nRFConnect');
20
-
21
- const LogoImage: FC<{ src: string }> = ({ src }) => (
22
- <img
23
- className="core19-logo"
24
- src={src}
25
- alt="Nordic Semiconductor logo"
26
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
27
- role="link"
28
- onClick={goToNRFConnectWebsite}
29
- onKeyPress={() => {}}
30
- tabIndex={0}
31
- />
32
- );
33
-
34
- const DynamicLogo = () => {
35
- const deviceIsSelected = useSelector(deviceIsSelectedSelector);
36
-
37
- return (
38
- <LogoImage src={deviceIsSelected ? logoConnected : logoDisconnected} />
39
- );
40
- };
41
-
42
- const StaticLogo = () => <LogoImage src={logoUniform} />;
43
-
44
- const Logo: FC<{ changeWithDeviceState?: boolean }> = ({
45
- changeWithDeviceState = false,
46
- }) => (changeWithDeviceState ? <DynamicLogo /> : <StaticLogo />);
47
-
48
- export default Logo;
@@ -1,11 +0,0 @@
1
- /*
2
- * Copyright (c) 2021 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- .core19-logo {
8
- margin-right: 19px;
9
- margin-left: auto;
10
- cursor: pointer;
11
- }
package/src/Main/Main.tsx DELETED
@@ -1,13 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import React, { ReactNode } from 'react';
8
-
9
- import './main.scss';
10
-
11
- export default ({ children }: { children?: ReactNode }) => (
12
- <div className="core19-main-view">{children}</div>
13
- );
@@ -1,13 +0,0 @@
1
- /*
2
- * Copyright (c) 2021 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- @import "../variables";
8
-
9
- .core19-main-view {
10
- padding: 0.6em 1em;
11
- background-color: $white;
12
- height: 100%;
13
- }
@@ -1,234 +0,0 @@
1
- /*
2
- * Copyright (c) 2022 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
- import React, { PropsWithChildren, useEffect, useRef, useState } from 'react';
7
-
8
- import classNames from '../utils/classNames';
9
-
10
- import styles from './masonryLayout.module.scss';
11
-
12
- interface MasonryLayoutProperties {
13
- minWidth: number;
14
- className?: string;
15
- }
16
-
17
- interface WrappedChildrenProperties {
18
- hiddenChildren: boolean[];
19
- width: number;
20
- columns: number;
21
- minWidth: number;
22
- orders: number[];
23
- }
24
-
25
- const WrappedChildren = ({
26
- children,
27
- hiddenChildren,
28
- width,
29
- columns,
30
- minWidth,
31
- orders,
32
- }: PropsWithChildren<WrappedChildrenProperties>) => (
33
- <>
34
- {React.Children.map(children, (child, i) => (
35
- <div
36
- data-hidden={hiddenChildren[i] === true ? 'true' : 'false'}
37
- style={{
38
- width: `${width / columns}px`,
39
- minWidth,
40
- order: `${orders[i] ?? 1}`,
41
- pageBreakBefore: `${i < columns ? 'always' : 'auto'}`,
42
- }}
43
- >
44
- {child}
45
- </div>
46
- ))}
47
- </>
48
- );
49
-
50
- interface FillersProperties {
51
- maxHeight: number;
52
- columns: number;
53
- width: number;
54
- columnHeights: number[];
55
- }
56
-
57
- const Fillers = ({
58
- maxHeight,
59
- columns,
60
- width,
61
- columnHeights,
62
- }: FillersProperties) => (
63
- <>
64
- {columnHeights.map((h, i) =>
65
- h !== maxHeight ? (
66
- <div
67
- data-filler="true"
68
- key={`filler_${i + 0}`}
69
- style={{
70
- height: `${maxHeight - h}px`,
71
- order: `${i + 1}`,
72
- width: `${width / columns}px`,
73
- }}
74
- />
75
- ) : null
76
- )}
77
- </>
78
- );
79
-
80
- /**
81
- * Builds a masonry layout around all depth 1 child components.
82
- * Note: only depth 1 children are considered for the layout.
83
- * This also applies for React.Fragment wrapped components.
84
- * @param {number} minWidth minimum width of every item in this layout.
85
- * @returns {React.FC<MasonryLayoutProperties>} React Component.
86
- */
87
- export default ({
88
- children,
89
- minWidth,
90
- className,
91
- }: PropsWithChildren<MasonryLayoutProperties>) => {
92
- const [width, setWidth] = useState(-1);
93
- const [maxHeight, setMaxHeight] = useState(0);
94
- const [columns, setColumns] = useState(-1);
95
- const [orders, setOrders] = useState<number[]>([]);
96
- const [hiddenChildren, setHiddenChildren] = useState<boolean[]>([]);
97
- const [columnHeights, setColumnHeights] = useState<number[]>([]);
98
-
99
- const masonryLayoutRef = useRef<HTMLDivElement>(null);
100
-
101
- useEffect(() => {
102
- if (masonryLayoutRef.current === null) return;
103
-
104
- const generateMetaData = (col: number) => {
105
- let child = masonryLayoutRef.current?.firstElementChild;
106
- const heightMatrix: number[][] = [];
107
- const zeroHeightChildren: boolean[] = [];
108
-
109
- let i = 0;
110
- while (child) {
111
- if (child instanceof HTMLElement) {
112
- if (!child.hasAttribute('data-filler')) {
113
- const rowIndex = Math.floor(i / col);
114
-
115
- if (heightMatrix[rowIndex] === undefined) {
116
- heightMatrix[rowIndex] = [];
117
- }
118
-
119
- const row = heightMatrix[rowIndex];
120
- const columnIndex = i % col;
121
-
122
- i += 1;
123
- if (
124
- child.offsetHeight <=
125
- Number.parseInt(styles.margin, 10)
126
- ) {
127
- row[columnIndex] = 0;
128
- zeroHeightChildren.push(true);
129
- } else {
130
- row[columnIndex] = child.offsetHeight + 1;
131
- zeroHeightChildren.push(false);
132
- }
133
- }
134
-
135
- child = child.nextElementSibling;
136
- }
137
- }
138
-
139
- return { heightMatrix, hiddenChildren: zeroHeightChildren };
140
- };
141
-
142
- const calcData = (col: number) => {
143
- const metaData = generateMetaData(col);
144
- const heights: number[] = Array(col).fill(0);
145
- const newOrder: number[] = [];
146
-
147
- metaData.heightMatrix.forEach(row => {
148
- row.forEach(itemHeight => {
149
- const smallest =
150
- heights.findIndex(h => h === Math.min(...heights)) ?? 0;
151
- heights[smallest] += itemHeight;
152
- newOrder.push(smallest + 1);
153
- });
154
- });
155
-
156
- return {
157
- maxHeight: Math.max(
158
- ...heights,
159
- masonryLayoutRef.current?.scrollHeight ?? 0
160
- ),
161
- order: newOrder,
162
- columnHeights: heights,
163
- columns: Math.min(
164
- metaData.hiddenChildren.filter(v => !v).length,
165
- col
166
- ),
167
- maxColums: col,
168
- hiddenChildren: metaData.hiddenChildren,
169
- };
170
- };
171
-
172
- const action = () => {
173
- const noOfColumns = Math.floor(
174
- current.clientWidth /
175
- (minWidth + Number.parseInt(styles.margin, 10))
176
- );
177
-
178
- if (current.clientWidth !== width) {
179
- setWidth(current.clientWidth);
180
- }
181
-
182
- const data = calcData(noOfColumns);
183
- if (data) {
184
- setOrders(data.order);
185
- setColumnHeights(data.columnHeights);
186
- setMaxHeight(data.maxHeight);
187
- setHiddenChildren(data.hiddenChildren);
188
- setColumns(data.columns);
189
- }
190
- };
191
-
192
- const current = masonryLayoutRef.current;
193
-
194
- const observer = new ResizeObserver(action);
195
- observer.observe(masonryLayoutRef.current);
196
- const mutationObserver = new MutationObserver(action);
197
- mutationObserver.observe(masonryLayoutRef.current, {
198
- childList: true,
199
- subtree: true,
200
- attributes: true,
201
- });
202
-
203
- return () => {
204
- current && observer.unobserve(current);
205
- current && mutationObserver.disconnect();
206
- };
207
- }, [columns, maxHeight, minWidth, width]);
208
-
209
- return (
210
- <div className={styles.masonryLayoutOut}>
211
- <div
212
- ref={masonryLayoutRef}
213
- className={classNames(styles.masonryLayout, className)}
214
- style={{ maxHeight: `${maxHeight}px` }}
215
- >
216
- <WrappedChildren
217
- hiddenChildren={hiddenChildren}
218
- width={width}
219
- columns={columns}
220
- minWidth={minWidth}
221
- orders={orders}
222
- >
223
- {children}
224
- </WrappedChildren>
225
- <Fillers
226
- maxHeight={maxHeight}
227
- columns={columns}
228
- width={width}
229
- columnHeights={columnHeights}
230
- />
231
- </div>
232
- </div>
233
- );
234
- };
@@ -1,46 +0,0 @@
1
- /*
2
- * Copyright (c) 2023 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- $margin: 8px; //px unit dependency in dropdown.tsx
8
-
9
- :export {
10
- margin: $margin;
11
- }
12
-
13
- .masonryLayoutOut {
14
- overflow-x: hidden;
15
-
16
- .masonryLayout {
17
- display: flex;
18
- flex-flow: column wrap;
19
- align-content: stretch;
20
- height: fit-content;
21
- width: calc(100% + $margin);
22
- position: relative;
23
- right: 4px;
24
- overflow: hidden;
25
-
26
- > div {
27
- border-bottom: $margin solid transparent;
28
- border-left: calc($margin / 2) solid transparent;
29
- border-right: calc($margin / 2) solid transparent;
30
- border-color: transparent;
31
- background-clip: padding-box;
32
- }
33
-
34
- > div[data-filler='true'] {
35
- border: none !important;
36
- padding: 0 !important;
37
- margin: 0 !important;
38
- }
39
-
40
- > div[data-hidden='true'] {
41
- border-bottom: 0 !important;
42
- border-left: 0 !important;
43
- border-right: 0 !important;
44
- }
45
- }
46
- }
@@ -1,22 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import React, { ReactNode } from 'react';
8
-
9
- import Logo from '../Logo/Logo';
10
- import NavMenu from './NavMenu';
11
-
12
- import './nav-bar.scss';
13
-
14
- export default ({ deviceSelect }: { deviceSelect?: ReactNode }) => (
15
- <div className="core19-nav-bar">
16
- {deviceSelect && (
17
- <div className="core19-nav-bar-device-selector">{deviceSelect}</div>
18
- )}
19
- <NavMenu />
20
- <Logo changeWithDeviceState />
21
- </div>
22
- );
@@ -1,41 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import React from 'react';
8
- import { screen } from '@testing-library/react';
9
-
10
- import render from '../../test/testrenderer';
11
- import { setPanes } from '../App/appLayout';
12
- import NavMenu from './NavMenu';
13
-
14
- const aPane = {
15
- name: 'an menu item',
16
- Main: () => <div>A pane</div>,
17
- };
18
- const anotherPane = {
19
- name: 'another menu item',
20
- Main: () => <div>Another pane</div>,
21
- };
22
-
23
- expect.extend({
24
- toBeHighlighted(element) {
25
- const pass = element.classList.contains('selected');
26
- const not = pass ? 'not ' : '';
27
- const message = () =>
28
- `Expected the element to ${not}contain a class 'selected' to signify that ` +
29
- `it is ${not}highlighted. It actually contained: ${element.className}`;
30
- return { pass, message };
31
- },
32
- });
33
-
34
- describe('NavMenu', () => {
35
- it('displays multiple items', () => {
36
- render(<NavMenu />, [setPanes([aPane, anotherPane])]);
37
-
38
- expect(screen.getByText('an menu item')).toBeInTheDocument();
39
- expect(screen.getByText('another menu item')).toBeInTheDocument();
40
- });
41
- });
@@ -1,53 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import React from 'react';
8
- import { useDispatch, useSelector } from 'react-redux';
9
-
10
- import {
11
- currentPane as currentPaneSelector,
12
- paneNames as paneNamesSelector,
13
- switchToNextPane,
14
- switchToPreviousPane,
15
- } from '../App/appLayout';
16
- import useHotKey from '../utils/useHotKey';
17
- import NavMenuItem from './NavMenuItem';
18
-
19
- const NavMenu = () => {
20
- const currentPane = useSelector(currentPaneSelector);
21
- const paneNames = useSelector(paneNamesSelector);
22
- const dispatch = useDispatch();
23
-
24
- useHotKey({
25
- hotKey: 'ctrl+tab',
26
- title: 'Switch pane right',
27
- isGlobal: true,
28
- action: () => dispatch(switchToNextPane()),
29
- });
30
-
31
- useHotKey({
32
- hotKey: 'ctrl+shift+tab',
33
- title: 'Switch pane left',
34
- isGlobal: true,
35
- action: () => dispatch(switchToPreviousPane()),
36
- });
37
-
38
- return (
39
- <div data-testid="nav-menu">
40
- {paneNames.map((name, index: number) => (
41
- <NavMenuItem
42
- key={name}
43
- index={index}
44
- isFirst={index === 0}
45
- isSelected={currentPane === index}
46
- label={name}
47
- />
48
- ))}
49
- </div>
50
- );
51
- };
52
-
53
- export default NavMenu;
@@ -1,41 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import React, { FC } from 'react';
8
- import { useDispatch } from 'react-redux';
9
-
10
- import { setCurrentPane } from '../App/appLayout';
11
- import Button from '../Button/Button';
12
- import classNames from '../utils/classNames';
13
-
14
- import './nav-menu-item.scss';
15
-
16
- interface Props {
17
- index: number;
18
- isFirst: boolean;
19
- isSelected: boolean;
20
- label: string;
21
- }
22
-
23
- const NavMenuItem: FC<Props> = ({ index, isFirst, isSelected, label }) => {
24
- const dispatch = useDispatch();
25
-
26
- return (
27
- <Button
28
- variant="custom"
29
- className={classNames(
30
- 'core19-nav-menu-item',
31
- isSelected && 'selected',
32
- isFirst && 'first'
33
- )}
34
- onClick={() => dispatch(setCurrentPane(index))}
35
- >
36
- {label}
37
- </Button>
38
- );
39
- };
40
-
41
- export default NavMenuItem;
@@ -1,26 +0,0 @@
1
- /*
2
- * Copyright (c) 2021 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- @import "../variables";
8
-
9
- .core19-nav-bar {
10
- width: 100%;
11
- height: $nav-bar-height;
12
-
13
- background-color: $white;
14
-
15
- display: flex;
16
- flex: none;
17
- flex-direction: row;
18
- align-items: center;
19
-
20
- z-index: 100;
21
-
22
- .core19-nav-bar-device-selector {
23
- width: $side-panel-width;
24
- align-self: start;
25
- }
26
- }