@sap-ux/control-property-editor 0.8.1 → 1.0.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 (80) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/app.css +1 -1
  3. package/dist/app.css.map +3 -3
  4. package/dist/app.js +54 -85
  5. package/dist/app.js.map +4 -4
  6. package/dist/tsconfig.tsbuildinfo +1 -1
  7. package/{esbuild.js → esbuild.mjs} +7 -10
  8. package/{eslint.config.js → eslint.config.mjs} +4 -2
  9. package/jest.config.mjs +39 -0
  10. package/package.json +8 -6
  11. package/src/App.tsx +8 -8
  12. package/src/actions.ts +1 -1
  13. package/src/components/ChangeIndicator.tsx +1 -1
  14. package/src/components/ThemeSelectorCallout.tsx +3 -3
  15. package/src/components/index.ts +3 -3
  16. package/src/i18n.ts +1 -1
  17. package/src/index.tsx +5 -5
  18. package/src/middleware.ts +2 -2
  19. package/src/panels/LeftPanel.tsx +2 -2
  20. package/src/panels/RightPanel.tsx +4 -4
  21. package/src/panels/changes/ChangeStack.tsx +10 -10
  22. package/src/panels/changes/ChangeStackHeader.tsx +1 -1
  23. package/src/panels/changes/ChangesPanel.tsx +9 -9
  24. package/src/panels/changes/ControlChange.tsx +1 -1
  25. package/src/panels/changes/DisplayAsIcon.tsx +2 -2
  26. package/src/panels/changes/GenericChange.tsx +3 -3
  27. package/src/panels/changes/GenericGroup.tsx +1 -1
  28. package/src/panels/changes/UnknownChange.tsx +1 -1
  29. package/src/panels/changes/index.tsx +2 -2
  30. package/src/panels/changes/utils.ts +1 -1
  31. package/src/panels/index.ts +2 -2
  32. package/src/panels/info-center/InfoCenter.tsx +4 -4
  33. package/src/panels/info-center/InfoMessageItem.tsx +2 -2
  34. package/src/panels/info-center/index.ts +1 -1
  35. package/src/panels/outline/Funnel.tsx +4 -4
  36. package/src/panels/outline/OutlinePanel.tsx +3 -3
  37. package/src/panels/outline/Tree.tsx +6 -6
  38. package/src/panels/outline/index.ts +1 -1
  39. package/src/panels/outline/utils.ts +2 -2
  40. package/src/panels/properties/Clipboard.tsx +1 -1
  41. package/src/panels/properties/DropdownEditor.tsx +4 -4
  42. package/src/panels/properties/Funnel.tsx +4 -4
  43. package/src/panels/properties/HeaderField.tsx +3 -3
  44. package/src/panels/properties/IconValueHelp.tsx +3 -3
  45. package/src/panels/properties/InputTypeSelector.tsx +2 -2
  46. package/src/panels/properties/InputTypeToggle.tsx +5 -5
  47. package/src/panels/properties/InputTypeWrapper.tsx +8 -8
  48. package/src/panels/properties/PropertiesList.tsx +14 -14
  49. package/src/panels/properties/PropertyDocumentation.tsx +2 -2
  50. package/src/panels/properties/StringEditor.tsx +6 -6
  51. package/src/panels/properties/index.ts +1 -1
  52. package/src/panels/properties/propertyValuesCache.ts +1 -1
  53. package/src/panels/properties/types.ts +1 -1
  54. package/src/panels/quick-actions/NestedQuickAction.tsx +2 -2
  55. package/src/panels/quick-actions/QuickActionList.tsx +4 -4
  56. package/src/panels/quick-actions/SimpleQuickAction.tsx +1 -1
  57. package/src/panels/quick-actions/index.ts +1 -1
  58. package/src/slice.ts +1 -1
  59. package/src/store.ts +3 -3
  60. package/src/toolbar/DeviceSelector.tsx +3 -3
  61. package/src/toolbar/DeviceToggle.tsx +3 -3
  62. package/src/toolbar/ModeSwitcher.tsx +1 -1
  63. package/src/toolbar/ToolBar.tsx +6 -6
  64. package/src/toolbar/UndoRedoSaveActions.tsx +4 -4
  65. package/src/toolbar/ViewChanger.tsx +2 -2
  66. package/src/toolbar/index.ts +1 -1
  67. package/src/use-theme.ts +1 -1
  68. package/src/ws-middleware.ts +3 -3
  69. package/test/unit/App.test.tsx +3 -1
  70. package/test/unit/appIndex.test.ts +37 -19
  71. package/test/unit/middleware.test.ts +39 -73
  72. package/test/unit/panels/changes/ChangesPanel.test.tsx +3 -15
  73. package/test/unit/panels/changes/FileChange.test.tsx +2 -10
  74. package/test/unit/panels/properties/DropdownEditor.test.tsx +0 -2
  75. package/test/unit/panels/properties/InputTypeToggle.test.tsx +8 -9
  76. package/test/unit/setup.ts +18 -2
  77. package/test/utils/utils.tsx +2 -0
  78. package/tsconfig.eslint.json +2 -1
  79. package/tsconfig.json +4 -5
  80. package/jest.config.js +0 -21
@@ -24,15 +24,15 @@ import {
24
24
  STRING_VALUE_TYPE
25
25
  } from '@sap-ux-private/control-property-editor-common';
26
26
 
27
- import { IconName } from '../../icons';
28
- import { ChangeIndicator } from '../../components/ChangeIndicator';
27
+ import { IconName } from '../../icons.js';
28
+ import { ChangeIndicator } from '../../components/ChangeIndicator.js';
29
29
 
30
- import type { CacheValue } from './propertyValuesCache';
31
- import type { InputTypeToggleOptionProps, InputTypeWrapperProps } from './types';
32
- import { InputType, isExpression } from './types';
33
- import { PropertyDocumentation } from './PropertyDocumentation';
34
- import { defaultFontSize } from './constants';
35
- import { InputTypeSelector } from './InputTypeSelector';
30
+ import type { CacheValue } from './propertyValuesCache.js';
31
+ import type { InputTypeToggleOptionProps, InputTypeWrapperProps } from './types.js';
32
+ import { InputType, isExpression } from './types.js';
33
+ import { PropertyDocumentation } from './PropertyDocumentation.js';
34
+ import { defaultFontSize } from './constants.js';
35
+ import { InputTypeSelector } from './InputTypeSelector.js';
36
36
  import { useTranslation } from 'react-i18next';
37
37
 
38
38
  export const getDefaultInputType = (editor: string, type: string, value: CacheValue): InputType => {
@@ -7,24 +7,24 @@ import {
7
7
  DROPDOWN_EDITOR_TYPE,
8
8
  INPUT_EDITOR_TYPE
9
9
  } from '@sap-ux-private/control-property-editor-common';
10
- import { Separator } from '../../components/Separator';
11
- import type { RootState } from '../../store';
12
- import { DropdownEditor } from './DropdownEditor';
13
- import { HeaderField } from './HeaderField';
14
- import { getDefaultInputType, getInputTypeToggleOptions, InputTypeWrapper } from './InputTypeWrapper';
15
- import { setCachedValue } from './propertyValuesCache';
16
- import { StringEditor } from './StringEditor';
17
- import type { InputTypeWrapperProps } from './types';
18
- import { isExpression } from './types';
19
- import { sectionHeaderFontSize } from './constants';
10
+ import { Separator } from '../../components/Separator.js';
11
+ import type { RootState } from '../../store.js';
12
+ import { DropdownEditor } from './DropdownEditor.js';
13
+ import { HeaderField } from './HeaderField.js';
14
+ import { getDefaultInputType, getInputTypeToggleOptions, InputTypeWrapper } from './InputTypeWrapper.js';
15
+ import { setCachedValue } from './propertyValuesCache.js';
16
+ import { StringEditor } from './StringEditor.js';
17
+ import type { InputTypeWrapperProps } from './types.js';
18
+ import { isExpression } from './types.js';
19
+ import { sectionHeaderFontSize } from './constants.js';
20
20
  import { useSelector } from 'react-redux';
21
21
  import { UISearchBox } from '@sap-ux/ui-components';
22
- import { NoControlSelected } from './NoControlSelected';
22
+ import { NoControlSelected } from './NoControlSelected.js';
23
23
  import { Label } from '@fluentui/react';
24
24
  import './Properties.scss';
25
- import { Funnel } from './Funnel';
26
- import type { ControlChangeStats, FilterOptions } from '../../slice';
27
- import { FilterName } from '../../slice';
25
+ import { Funnel } from './Funnel.js';
26
+ import type { ControlChangeStats, FilterOptions } from '../../slice.js';
27
+ import { FilterName } from '../../slice.js';
28
28
 
29
29
  /**
30
30
  * React element for all properties including id & type and property editors.
@@ -7,8 +7,8 @@ import { Text, Stack } from '@fluentui/react';
7
7
  import { UIIcon, UIIconButton, UiIcons } from '@sap-ux/ui-components';
8
8
 
9
9
  import type { Control, SavedGenericChange, PendingGenericChange } from '@sap-ux-private/control-property-editor-common';
10
- import { Separator } from '../../components';
11
- import type { RootState } from '../../store';
10
+ import { Separator } from '../../components/index.js';
11
+ import type { RootState } from '../../store.js';
12
12
 
13
13
  import styles from './PropertyDocumentation.module.scss';
14
14
 
@@ -5,18 +5,18 @@ import { useDispatch, useSelector } from 'react-redux';
5
5
  import type { UITextInputProps } from '@sap-ux/ui-components';
6
6
  import { UITextInput } from '@sap-ux/ui-components';
7
7
 
8
- import { changeProperty } from '../../slice';
8
+ import { changeProperty } from '../../slice.js';
9
9
 
10
- import type { PropertyInputProps } from './types';
11
- import { isExpression, InputType } from './types';
12
- import { setCachedValue } from './propertyValuesCache';
10
+ import type { PropertyInputProps } from './types.js';
11
+ import { isExpression, InputType } from './types.js';
12
+ import { setCachedValue } from './propertyValuesCache.js';
13
13
 
14
14
  import './Properties.scss';
15
15
  import { reportTelemetry, FLOAT_VALUE_TYPE, INTEGER_VALUE_TYPE } from '@sap-ux-private/control-property-editor-common';
16
16
  import './SapUiIcon.scss';
17
- import { IconValueHelp } from './IconValueHelp';
17
+ import { IconValueHelp } from './IconValueHelp.js';
18
18
  import type { IconDetails } from '@sap-ux-private/control-property-editor-common';
19
- import type { RootState } from '../../store';
19
+ import type { RootState } from '../../store.js';
20
20
 
21
21
  /**
22
22
  * React element for string editor in property panel.
@@ -1 +1 @@
1
- export { PropertiesList } from './PropertiesList';
1
+ export { PropertiesList } from './PropertiesList.js';
@@ -1,4 +1,4 @@
1
- import { InputType, isExpression } from './types';
1
+ import { InputType, isExpression } from './types.js';
2
2
 
3
3
  export type CacheValue = string | boolean | number;
4
4
 
@@ -7,7 +7,7 @@ import type {
7
7
  INPUT_EDITOR_TYPE
8
8
  } from '@sap-ux-private/control-property-editor-common';
9
9
 
10
- import type { PropertyChangeStats } from '../../slice';
10
+ import type { PropertyChangeStats } from '../../slice.js';
11
11
 
12
12
  export interface PropertyInputProps<T extends ControlProperty = ControlProperty> {
13
13
  controlId: string;
@@ -7,8 +7,8 @@ import { UIDirectionalHint, UIIcon, UILink, UIContextualMenu, UIContextualMenuLa
7
7
 
8
8
  import type { NestedQuickAction, NestedQuickActionChild } from '@sap-ux-private/control-property-editor-common';
9
9
  import { executeQuickAction } from '@sap-ux-private/control-property-editor-common';
10
- import { IconName } from '../../icons';
11
- import type { RootState } from '../../store';
10
+ import { IconName } from '../../icons.js';
11
+ import type { RootState } from '../../store.js';
12
12
 
13
13
  export interface NestedQuickActionListItemProps {
14
14
  action: Readonly<NestedQuickAction>;
@@ -7,11 +7,11 @@ import { useSelector } from 'react-redux';
7
7
  import type { QuickActionGroup } from '@sap-ux-private/control-property-editor-common';
8
8
  import { NESTED_QUICK_ACTION_KIND, SIMPLE_QUICK_ACTION_KIND } from '@sap-ux-private/control-property-editor-common';
9
9
 
10
- import type { RootState } from '../../store';
11
- import { sectionHeaderFontSize } from '../properties/constants';
10
+ import type { RootState } from '../../store.js';
11
+ import { sectionHeaderFontSize } from '../properties/constants.js';
12
12
 
13
- import { SimpleQuickActionListItem } from './SimpleQuickAction';
14
- import { NestedQuickActionListItem } from './NestedQuickAction';
13
+ import { SimpleQuickActionListItem } from './SimpleQuickAction.js';
14
+ import { NestedQuickActionListItem } from './NestedQuickAction.js';
15
15
 
16
16
  import './QuickAction.scss';
17
17
 
@@ -7,7 +7,7 @@ import { UILink } from '@sap-ux/ui-components';
7
7
  import type { SimpleQuickAction } from '@sap-ux-private/control-property-editor-common';
8
8
  import { executeQuickAction } from '@sap-ux-private/control-property-editor-common';
9
9
 
10
- import type { RootState } from '../../store';
10
+ import type { RootState } from '../../store.js';
11
11
 
12
12
  export interface SimpleQuickActionListItemProps {
13
13
  action: Readonly<SimpleQuickAction>;
@@ -1 +1 @@
1
- export { QuickActionList } from './QuickActionList';
1
+ export { QuickActionList } from './QuickActionList.js';
package/src/slice.ts CHANGED
@@ -45,7 +45,7 @@ import {
45
45
  GENERIC_CHANGE_KIND,
46
46
  toggleAppPreviewVisibility
47
47
  } from '@sap-ux-private/control-property-editor-common';
48
- import { DeviceType } from './devices';
48
+ import { DeviceType } from './devices.js';
49
49
 
50
50
  export interface SliceState {
51
51
  deviceType: DeviceType;
package/src/store.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { configureStore, compose, applyMiddleware } from '@reduxjs/toolkit';
2
2
  import { useDispatch } from 'react-redux';
3
- import { communicationMiddleware } from './middleware';
4
- import reducer from './slice';
5
- import { webSocketMiddleware } from './ws-middleware';
3
+ import { communicationMiddleware } from './middleware.js';
4
+ import reducer from './slice.js';
5
+ import { webSocketMiddleware } from './ws-middleware.js';
6
6
 
7
7
  declare let window: Window & { __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: <R>(data: R) => R };
8
8
  const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?? compose;
@@ -2,10 +2,10 @@ import type { ReactElement } from 'react';
2
2
  import React from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
 
5
- import { DeviceType } from '../devices';
5
+ import { DeviceType } from '../devices.js';
6
6
 
7
- import type { DeviceToggleProps } from './DeviceToggle';
8
- import { DeviceToggle } from './DeviceToggle';
7
+ import type { DeviceToggleProps } from './DeviceToggle.js';
8
+ import { DeviceToggle } from './DeviceToggle.js';
9
9
 
10
10
  /**
11
11
  * React element for Device Selector.
@@ -4,9 +4,9 @@ import { useDispatch, useSelector } from 'react-redux';
4
4
  import type { AnyAction } from 'redux';
5
5
  import { UIIconButton } from '@sap-ux/ui-components';
6
6
 
7
- import type { DeviceType } from '../devices';
8
- import { changeDeviceType } from '../slice';
9
- import type { RootState } from '../store';
7
+ import type { DeviceType } from '../devices.js';
8
+ import { changeDeviceType } from '../slice.js';
9
+ import type { RootState } from '../store.js';
10
10
 
11
11
  export interface DeviceToggleProps {
12
12
  deviceType: DeviceType;
@@ -6,7 +6,7 @@ import { useDispatch, useSelector } from 'react-redux';
6
6
  import { setAppMode } from '@sap-ux-private/control-property-editor-common';
7
7
  import { UIDefaultButton, UILabel } from '@sap-ux/ui-components';
8
8
 
9
- import type { RootState } from '../store';
9
+ import type { RootState } from '../store.js';
10
10
 
11
11
  import './ModeSwitcher.scss';
12
12
 
@@ -6,13 +6,13 @@ import { useSelector } from 'react-redux';
6
6
  import { UIFocusZone, UILabel, UIToolbar, UIToolbarColumn } from '@sap-ux/ui-components';
7
7
  import type { Scenario } from '@sap-ux-private/control-property-editor-common';
8
8
 
9
- import type { RootState } from '../store';
10
- import { Separator, ThemeSelectorCallout } from '../components';
9
+ import type { RootState } from '../store.js';
10
+ import { Separator, ThemeSelectorCallout } from '../components/index.js';
11
11
 
12
- import { ViewChanger } from './ViewChanger';
13
- import { DeviceSelector } from './DeviceSelector';
14
- import { ModeSwitcher } from './ModeSwitcher';
15
- import { UndoRedoSaveActions } from './UndoRedoSaveActions';
12
+ import { ViewChanger } from './ViewChanger.js';
13
+ import { DeviceSelector } from './DeviceSelector.js';
14
+ import { ModeSwitcher } from './ModeSwitcher.js';
15
+ import { UndoRedoSaveActions } from './UndoRedoSaveActions.js';
16
16
 
17
17
  import './ToolBar.scss';
18
18
 
@@ -6,10 +6,10 @@ import { useTranslation } from 'react-i18next';
6
6
  import { redo, reloadApplication, save, undo } from '@sap-ux-private/control-property-editor-common';
7
7
  import { UIIconButton, UiIcons } from '@sap-ux/ui-components';
8
8
 
9
- import type { ChangesSlice } from '../slice';
10
- import type { RootState } from '../store';
11
- import { Separator } from '../components';
12
- import { IconName } from '../icons';
9
+ import type { ChangesSlice } from '../slice.js';
10
+ import type { RootState } from '../store.js';
11
+ import { Separator } from '../components/index.js';
12
+ import { IconName } from '../icons.js';
13
13
 
14
14
  /**
15
15
  * React element for Undo, Redo and Save.
@@ -6,8 +6,8 @@ import { useDispatch, useSelector } from 'react-redux';
6
6
  import type { UIComboBoxOption, UIComboBoxRef } from '@sap-ux/ui-components';
7
7
  import { UIComboBox, UIIconButton, UiIcons } from '@sap-ux/ui-components';
8
8
 
9
- import type { RootState } from '../store';
10
- import { changePreviewScale, changePreviewScaleMode } from '../slice';
9
+ import type { RootState } from '../store.js';
10
+ import { changePreviewScale, changePreviewScaleMode } from '../slice.js';
11
11
 
12
12
  import styles from './ViewChanger.module.scss';
13
13
 
@@ -1 +1 @@
1
- export * from './ToolBar';
1
+ export * from './ToolBar.js';
package/src/use-theme.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import { useEffect } from 'react';
3
- import { useLocalStorage } from './use-local-storage';
3
+ import { useLocalStorage } from './use-local-storage.js';
4
4
 
5
5
  export type ThemeName = 'dark modern' | 'light modern' | 'high contrast black';
6
6
  /**
@@ -1,9 +1,9 @@
1
1
  import type { AnyAction, Dispatch } from 'redux';
2
2
  import type { Middleware, MiddlewareAPI } from '@reduxjs/toolkit';
3
3
 
4
- import type { Action } from './actions';
5
- import type reducer from './slice';
6
- import { fileChanged, initializeLivereload } from './slice';
4
+ import type { Action } from './actions.js';
5
+ import type reducer from './slice.js';
6
+ import { fileChanged, initializeLivereload } from './slice.js';
7
7
  import { externalFileChange } from '@sap-ux-private/control-property-editor-common';
8
8
 
9
9
  /**
@@ -1,6 +1,8 @@
1
+ import { jest } from '@jest/globals';
1
2
  import React from 'react';
2
3
  import { fireEvent, screen } from '@testing-library/react';
3
- import { act } from 'react-dom/test-utils';
4
+ import reactDomTestUtils from 'react-dom/test-utils';
5
+ const { act } = reactDomTestUtils;
4
6
 
5
7
  import { render, mockDomEventListener } from './utils';
6
8
 
@@ -1,19 +1,37 @@
1
- import { start } from '../../src/index';
2
- import * as i18n from '../../src/i18n';
3
- import * as icons from '../../src/icons';
4
- import * as initIcon from '@sap-ux/ui-components/dist/components/Icons'; // bug in TS 4.6 https://github.com/microsoft/TypeScript/issues/43081
5
- import * as initTheme from '@sap-ux/ui-components/dist/theme';
6
- import ReactDOM from 'react-dom';
7
- import { store } from '../../src/store';
8
- import { initializeLivereload, setFeatureToggles, setProjectScenario } from '../../src/slice';
1
+ import { jest } from '@jest/globals';
2
+ import * as actualUiComponents from '@sap-ux/ui-components';
3
+
4
+ const mockInitI18n = jest.fn();
5
+ const mockRegisterAppIcons = jest.fn();
6
+ const mockInitIcons = jest.fn();
7
+ const mockInitTheme = jest.fn();
8
+ const mockReactDOMRender = jest.fn();
9
+
10
+ jest.unstable_mockModule('../../src/i18n', () => ({
11
+ initI18n: mockInitI18n
12
+ }));
13
+
14
+ jest.unstable_mockModule('../../src/icons', () => ({
15
+ registerAppIcons: mockRegisterAppIcons,
16
+ IconName: {}
17
+ }));
18
+
19
+ jest.unstable_mockModule('@sap-ux/ui-components', () => ({
20
+ ...actualUiComponents,
21
+ initIcons: mockInitIcons,
22
+ initTheme: mockInitTheme
23
+ }));
24
+
25
+ jest.unstable_mockModule('react-dom', () => ({
26
+ default: { render: mockReactDOMRender },
27
+ render: mockReactDOMRender
28
+ }));
29
+
30
+ const { start } = await import('../../src/index');
31
+ const { store } = await import('../../src/store');
32
+ const { initializeLivereload, setFeatureToggles, setProjectScenario } = await import('../../src/slice');
9
33
 
10
34
  describe('index', () => {
11
- const i18nSpy = jest.spyOn(i18n, 'initI18n');
12
- const iconsSpy = jest.spyOn(icons, 'registerAppIcons');
13
- // ts-ignore
14
- const initIconSpy = jest.spyOn(initIcon, 'initIcons');
15
- const initThemeSpy = jest.spyOn(initTheme, 'initTheme');
16
- const reactSpy = jest.spyOn(ReactDOM, 'render').mockReturnValue();
17
35
  const dispatchSpy = jest.spyOn(store, 'dispatch');
18
36
 
19
37
  test('start', () => {
@@ -26,11 +44,11 @@ describe('index', () => {
26
44
  }
27
45
  ];
28
46
  start({ previewUrl, rootElementId, livereloadPort: 8080, scenario: 'APP_VARIANT', features });
29
- expect(i18nSpy).toHaveBeenCalledTimes(1);
30
- expect(iconsSpy).toHaveBeenCalledTimes(1);
31
- expect(initIconSpy).toHaveBeenCalledTimes(1);
32
- expect(initThemeSpy).toHaveBeenCalledTimes(1);
33
- expect(reactSpy).toHaveBeenCalledTimes(1);
47
+ expect(mockInitI18n).toHaveBeenCalledTimes(1);
48
+ expect(mockRegisterAppIcons).toHaveBeenCalledTimes(1);
49
+ expect(mockInitIcons).toHaveBeenCalledTimes(1);
50
+ expect(mockInitTheme).toHaveBeenCalledTimes(1);
51
+ expect(mockReactDOMRender).toHaveBeenCalledTimes(1);
34
52
  expect(dispatchSpy).toHaveBeenCalledTimes(3);
35
53
  expect(dispatchSpy).toHaveBeenNthCalledWith(1, setFeatureToggles(features));
36
54
  expect(dispatchSpy).toHaveBeenNthCalledWith(2, setProjectScenario('APP_VARIANT'));