@enact/core 4.5.0-rc.2 → 4.5.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact core module, newest changes on the top.
4
4
 
5
+ ## [4.5.2] - 2022-08-17
6
+
7
+ No significant changes.
8
+
9
+ ## [4.5.1] - 2022-08-03
10
+
11
+ No significant changes.
12
+
13
+ ## [4.5.0] - 2022-07-19
14
+
15
+ No significant changes.
16
+
5
17
  ## [4.5.0-rc.2] - 2022-07-06
6
18
 
7
19
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/core",
3
- "version": "4.5.0-rc.2",
3
+ "version": "4.5.2",
4
4
  "description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,9 +29,9 @@
29
29
  "invariant": "^2.2.4",
30
30
  "prop-types": "^15.8.1",
31
31
  "ramda": "^0.28.0",
32
- "react": "^18.0.0",
33
- "react-dom": "^18.0.0",
34
- "react-is": "^18.0.0",
32
+ "react": "^18.2.0",
33
+ "react-dom": "^18.2.0",
34
+ "react-is": "^18.2.0",
35
35
  "warning": "^4.0.3"
36
36
  }
37
37
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "usePublicClassNames.js"
3
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ var _react = require("@testing-library/react");
4
+
5
+ var _usePublicClassNames = _interopRequireDefault(require("../usePublicClassNames"));
6
+
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
+
9
+ describe('usePublicClassNames', function () {
10
+ var componentCss = {
11
+ test: 'test-class',
12
+ a: 'a-class',
13
+ b: 'b-class'
14
+ };
15
+ var customCss = {
16
+ test: 'test-class-custom',
17
+ a: 'a-class-custom',
18
+ b: 'b-class-custom',
19
+ myClass: 'my-class'
20
+ };
21
+ test('should return `componentCss` if `customCss` is undefined', function () {
22
+ var testComponentCss = {
23
+ test: 'test-class'
24
+ };
25
+
26
+ var _renderHook = (0, _react.renderHook)(function () {
27
+ return (0, _usePublicClassNames["default"])({
28
+ componentCss: testComponentCss,
29
+ customCss: null,
30
+ publicClassNames: true
31
+ });
32
+ }),
33
+ result = _renderHook.result;
34
+
35
+ expect(result.current).toEqual(testComponentCss);
36
+ });
37
+ test('should return a merged css has all keys from `componentCss` and merged values when `publicClassNames` is true', function () {
38
+ var _renderHook2 = (0, _react.renderHook)(function () {
39
+ return (0, _usePublicClassNames["default"])({
40
+ componentCss: componentCss,
41
+ customCss: customCss,
42
+ publicClassNames: true
43
+ });
44
+ }),
45
+ result = _renderHook2.result;
46
+
47
+ var expected = {
48
+ test: 'test-class test-class-custom',
49
+ a: 'a-class a-class-custom',
50
+ b: 'b-class b-class-custom'
51
+ };
52
+ expect(result.current.test).toBe(expected.test);
53
+ expect(result.current.a).toBe(expected.a);
54
+ expect(result.current.b).toBe(expected.b);
55
+ });
56
+ test('should return a merged css has the keys from `publicClassNames` array and merged values when `publicClassNames` is an array of strings', function () {
57
+ var _renderHook3 = (0, _react.renderHook)(function () {
58
+ return (0, _usePublicClassNames["default"])({
59
+ componentCss: componentCss,
60
+ customCss: customCss,
61
+ publicClassNames: ['a', 'b']
62
+ });
63
+ }),
64
+ result = _renderHook3.result;
65
+
66
+ var expected = {
67
+ a: 'a-class a-class-custom',
68
+ b: 'b-class b-class-custom'
69
+ };
70
+ expect(result.current.a).toBe(expected.a);
71
+ expect(result.current.b).toBe(expected.b);
72
+ });
73
+ });
File without changes
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ exports.usePublicClassNames = usePublicClassNames;
8
+
9
+ var _util = require("../util");
10
+
11
+ /**
12
+ * A hook for supporting `publicClassNames` to functional components.
13
+ * It returns merged CSS of given two CSS objects according to `publicClassNames` option.
14
+ *
15
+ * @param {Object.<string, string>} [componentCss] The CSS of the component
16
+ * @param {Object.<string, string>} [customCss] The supplied collection of CSS class names to the
17
+ * corresponding internal elements and states of the component
18
+ * @param {Boolean|String|String[]} [publicClassNames] The keys of public class names of the component
19
+ * If this value is `true`, all of the keys from the component
20
+ * CSS will become public class names.
21
+ * @returns {Object} A merged CSS
22
+ * @private
23
+ */
24
+ function usePublicClassNames(_ref) {
25
+ var componentCss = _ref.componentCss,
26
+ customCss = _ref.customCss,
27
+ publicClassNames = _ref.publicClassNames;
28
+ var allowedClassNames = publicClassNames;
29
+ var mergedCss = componentCss;
30
+
31
+ if (!componentCss || !customCss) {
32
+ return mergedCss;
33
+ }
34
+
35
+ if (allowedClassNames === true) {
36
+ allowedClassNames = Object.keys(componentCss);
37
+ } else if (typeof allowedClassNames === 'string') {
38
+ allowedClassNames = allowedClassNames.split(/\s+/);
39
+ } // if the config includes a css map, merge them together now
40
+
41
+
42
+ if (allowedClassNames) {
43
+ mergedCss = (0, _util.mergeClassNameMaps)(componentCss, customCss, allowedClassNames);
44
+ }
45
+
46
+ return mergedCss;
47
+ }
48
+
49
+ var _default = usePublicClassNames;
50
+ exports["default"] = _default;