Skip to content

Commit

Permalink
4.7.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
enact-bot committed Apr 25, 2023
2 parents c79f4ec + cc0cd79 commit a23b67d
Show file tree
Hide file tree
Showing 48 changed files with 38,001 additions and 11,097 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,21 @@ The following is a curated list of changes in the Enact project, newest changes
### Fixed

- `spotlight` to show the focus effect when pointer mode is changed to `false` while an app is loading
## [4.7.0] - 2023-04-25

### Deprecated

- `windowsPhone` platform in `core/platform.platforms` to be removed in 5.0.0

### Added

- `ui/Layout.Cell` prop `grow` to expand its size to the container

### Fixed

- `i18n` resource loader to override strings where the original strings file does not exist
- `spotlight` to show the focus effect when pointer mode is changed to `false` while an app is loading
- `ui/ViewManager` to set index prop properly when reverseTransition prop is given

## [4.6.2] - 2023-03-09

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/adding-automated-ui-tests.md
Expand Up @@ -145,7 +145,7 @@ It will start to run all the existing Screenshot test cases in Sandstone.
If you run the tests of specific component(s), run the following command:

```bash
npm run test-ui -- --component <pattern>
npm run test-ss -- --component <pattern>
```

Check out [here](https://github.com/enactjs/ui-test-utils/blob/master/README.md#filtering-screenshot-by-component) for more options.
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
@@ -1,6 +1,6 @@
{
"lerna": "4.0.0",
"version": "4.6.2",
"version": "4.7.0",
"command": {
"bootstrap": {
"ci": false,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "enact",
"version": "4.6.2",
"version": "4.7.0",
"description": "Monorepo for all Enact front end libraries.",
"private": true,
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion packages/core/CHANGELOG.md
Expand Up @@ -5,6 +5,11 @@ The following is a curated list of changes in the Enact core module, newest chan
## [4.5.3] - 2023-04-06

No significant changes.
## [4.7.0] - 2023-04-25

### Deprecated

- `windowsPhone` platform in `core/platform.platforms` to be removed in 5.0.0

## [4.6.2] - 2023-03-09

Expand All @@ -18,7 +23,7 @@ No significant changes.

### Fixed

- `core/dispatcher` to set the default target for event listeners properly when built with the snapshot option
- `core/dispatcher` to set the default target for event listeners properly when built with the snapshot option

## [4.0.12] - 2022-09-16

Expand Down
49 changes: 23 additions & 26 deletions packages/core/handle/handle.js
Expand Up @@ -796,39 +796,36 @@ const forwardCustom = handle.forwardCustom = (name, adapter) => handle(
* @private
*/
const forwardCustomWithPrevent = handle.forwardCustomWithPrevent = named((name, adapter) => {
let prevented = false;

const adapterWithPrevent = (ev, ...args) => {
let customEventPayload = adapter ? adapter(ev, ...args) : null;
let existingPreventDefault = null;
return (ev, ...args) => {
let prevented = false;

// Handle either no adapter or a non-object return from the adapter
if (!customEventPayload || typeof customEventPayload !== 'object') {
customEventPayload = {};
}
const adapterWithPrevent = () => {
let customEventPayload = adapter ? adapter(ev, ...args) : null;
let existingPreventDefault = null;

if (typeof customEventPayload.preventDefault === 'function') {
existingPreventDefault = customEventPayload.preventDefault;
} else if (typeof ev.preventDefault === 'function') {
existingPreventDefault = ev.preventDefault.bind(ev);
}
// Handle either no adapter or a non-object return from the adapter
if (!customEventPayload || typeof customEventPayload !== 'object') {
customEventPayload = {};
}

customEventPayload.preventDefault = () => {
prevented = true;
if (typeof existingPreventDefault === 'function') {
existingPreventDefault();
if (typeof customEventPayload.preventDefault === 'function') {
existingPreventDefault = customEventPayload.preventDefault;
} else if (typeof ev?.preventDefault === 'function') {
existingPreventDefault = ev.preventDefault.bind(ev);
}

customEventPayload.preventDefault = () => {
prevented = true;
if (typeof existingPreventDefault === 'function') {
existingPreventDefault(ev);
}
};

return customEventPayload;
};

return customEventPayload;
return forwardCustom(name, adapterWithPrevent)(ev, ...args) && !prevented;
};

return (
handle(
forwardCustom(name, adapterWithPrevent),
() => (!prevented)
)
);
}, 'forwardCustomWithPrevent');

/**
Expand Down
103 changes: 103 additions & 0 deletions packages/core/handle/tests/handle-specs.js
Expand Up @@ -7,6 +7,7 @@ import {
forProp,
forward,
forwardCustom,
forwardCustomWithPrevent,
forwardWithPrevent,
handle,
oneOf,
Expand Down Expand Up @@ -567,4 +568,106 @@ describe('handle', () => {
expect(actual).toEqual(expected);
});
});

describe('#forwardCustomWithPrevent', () => {
test('should pass an object with `type` and `preventDefault` when no adapter is provided', () => {
const handler = jest.fn();

forwardCustomWithPrevent('onCustomEvent')(null, {onCustomEvent: handler});

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
type: 'onCustomEvent',
preventDefault: expect.any(Function)
}));
});

test('should add `type` and `preventDefault` to object returned by adapter', () => {
const handler = jest.fn();
const adapter = () => ({index: 0});
forwardCustomWithPrevent('onCustomEvent', adapter)(null, {onCustomEvent: handler});

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
type: 'onCustomEvent',
preventDefault: expect.any(Function),
index: 0
}));
});

test('should create an event payload if the adapter returns nothing', () => {
const handler = jest.fn();
const adapter = () => null;
forwardCustomWithPrevent('onCustomEvent', adapter)(null, {onCustomEvent: handler});

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
type: 'onCustomEvent',
preventDefault: expect.any(Function)
}));
});

test('should pass an object with `preventDefault` and `stopPropagation` when event has them', () => {
const ev = {
preventDefault: jest.fn(),
stopPropagation: () => {}
};
const handler = jest.fn();
const adapter = () => null;
forwardCustomWithPrevent('onCustomEvent', adapter)(ev, {onCustomEvent: handler});

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
type: 'onCustomEvent',
preventDefault: expect.any(Function),
stopPropagation: expect.any(Function)
}));

actual.preventDefault();

expect(ev.preventDefault).toHaveBeenCalled();
});

test('should pass event, props, and context args to adapter', () => {
const adapter = jest.fn();
const args = [
1, // ev,
2, // props,
3 // context
];
forwardCustomWithPrevent('onCustomEvent', adapter)(...args);

const expected = args;
const actual = adapter.mock.calls[0];

expect(actual).toEqual(expected);
});

test('should call the next handler when `preventDefault` from provided props hasn\'t been called', () => {
const event = 'onMyClick';
const handler = jest.fn();

const callback = handle(forwardCustomWithPrevent(event), handler);

callback();
expect(handler).toHaveBeenCalledTimes(1);
});

test('should not call the next handler when `preventDefault` from provided props has been called', () => {
const event = 'onMyClick';
const handler = jest.fn();

const callback = handle(forwardCustomWithPrevent(event), handler);

// should stop chain when `preventDefault()` has been called
callback({}, {
'onMyClick': (ev) => ev.preventDefault()
});
expect(handler).not.toHaveBeenCalled();
});
});
});
28 changes: 15 additions & 13 deletions packages/core/kind/kind.js
Expand Up @@ -47,23 +47,25 @@ const NoContext = createContext(null);
*
* @typedef {Object} StylesBlock
* @memberof core/kind
* @property {Object.<string, string>} css
* @property {String} [className]
* @property {Boolean|String|String[]} [publicClassNames]
* @property {Object.<string, string>} css The CSS of the component
* @property {String} [className] The className of the component
* @property {Boolean|String|String[]} [publicClassNames] Specifies which class names are overridable.
* If this value is `true`, all of the class names of the component CSS will become public.
*/

/**
* @typedef {Object} KindConfig
* @memberof core/kind
* @property {String} [name]
* @property {Boolean} [functional]
* @property {Object.<string, Function>} [propTypes]
* @property {Object.<string, any>} [defaultProps]
* @property {Object} [contextType]
* @property {StylesBlock} [styles]
* @property {Object.<string, HandlerFunction>} [handlers]
* @property {Object.<string, ComputedPropFunction>} [computed]
* @property {RenderFunction} render
* @property {String} [name] The name of the component
* @property {Boolean} [functional] Boolean controlling whether the returned component should be a functional component
* @property {Object.<string, Function>} [propTypes] Specifies expected props
* @property {Object.<string, any>} [defaultProps] Sets the default props
* @property {Object} [contextType] Specifies context type
* @property {StylesBlock} [styles] Configures styles with the static className to merge with user className
* @property {Object.<string, HandlerFunction>} [handlers] Adds event handlers that are cached between calls to prevent recreating each call.
* Any handlers are added to the props passed to `render()`. See {@link core/handle.handle}.
* @property {Object.<string, ComputedPropFunction>} [computed] Adds some computed properties, these are added to props passed to `render()`
* @property {RenderFunction} render The render function
*/

/**
Expand All @@ -74,7 +76,7 @@ const NoContext = createContext(null);
* import css from './Button.module.less';
* const Button = kind({
* name: 'Button',
* // Return a functional component suitable for use with React hooks
* // Return a functional component
* functional: true,
* // expect color and onClick properties but neither required
* propTypes: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@enact/core",
"version": "4.6.2",
"version": "4.7.0",
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",
"repository": {
"type": "git",
Expand Down
9 changes: 9 additions & 0 deletions packages/core/platform/platform.js
Expand Up @@ -9,6 +9,8 @@

import uniq from 'ramda/src/uniq';

import deprecate from '../internal/deprecate';

const hasGesture = () => {
return Boolean(
('ongesturestart' in window) ||
Expand Down Expand Up @@ -145,6 +147,13 @@ const parseUserAgent = (userAgent) => {
}
}

if (plat.platformName === 'windowsPhone') {
deprecate({
name: 'Windows Phone platform',
until: '5.0.0'
});
}

return plat;
};

Expand Down
11 changes: 11 additions & 0 deletions packages/core/platform/tests/platform-specs.js
Expand Up @@ -104,6 +104,17 @@ describe('platform', () => {
});
});

describe('parseUserAgent for Windows Phone', () => {
const windowsPhone = 'Mozilla/5.0 (Windows Phone 8.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4103.84 Mobile Safari/537.36';

test('should return platformName `windowsPhone`', () => {
const expected = {platformName: 'windowsPhone'};
const actual = parseUserAgent(windowsPhone);

expect(actual).toMatchObject(expected);
});
});

describe('parseUserAgent for User-Agent Reduction', () => {
const testVersion = '113';
const uaGenerator = (unifiedPlatform, deviceCompatibility = '', majorVersion = testVersion) => (
Expand Down
5 changes: 5 additions & 0 deletions packages/i18n/CHANGELOG.md
Expand Up @@ -5,6 +5,11 @@ The following is a curated list of changes in the Enact i18n module, newest chan
## [4.5.3] - 2023-04-06

No significant changes.
## [4.7.0] - 2023-04-25

### Fixed

- `i18n` resource loader to override strings where the original strings file does not exist

## [4.6.2] - 2023-03-09

Expand Down
8 changes: 4 additions & 4 deletions packages/i18n/package.json
@@ -1,7 +1,7 @@
{
"name": "@enact/i18n",
"main": "./src/index.js",
"version": "4.6.2",
"version": "4.7.0",
"description": "Internationalization support for Enact using iLib",
"repository": {
"type": "git",
Expand Down Expand Up @@ -47,18 +47,18 @@
]
},
"dependencies": {
"@enact/core": "^4.6.2",
"@enact/core": "^4.7.0",
"prop-types": "^15.8.1",
"ramda": "^0.28.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"xhr": "^2.6.0"
},
"peerDependencies": {
"ilib": "^14.15.1 || ^14.15.1-webos1"
"ilib": "^14.17.0 || ^14.17.0-webos1"
},
"devDependencies": {
"@enact/ui-test-utils": "^1.0.1",
"@enact/ui-test-utils": "^1.0.2",
"ilib": "^14.17.0"
}
}

0 comments on commit a23b67d

Please sign in to comment.