@enact/core 3.4.9-experimental-3 → 3.4.9-experimental-7

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 (113) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/{build/dispatcher → dispatcher}/dispatcher.d.ts +0 -0
  3. package/dispatcher/dispatcher.js +76 -57
  4. package/dispatcher/listeners.js +31 -19
  5. package/dispatcher/tests/dispatcher-specs.js +75 -100
  6. package/{build/handle → handle}/handle.d.ts +0 -0
  7. package/handle/handle.js +260 -212
  8. package/handle/tests/handle-specs.js +476 -601
  9. package/{build/hoc → hoc}/hoc.d.ts +0 -0
  10. package/hoc/hoc.js +47 -33
  11. package/hoc/tests/hoc-specs.js +85 -126
  12. package/{build/index.d.ts → index.d.ts} +0 -0
  13. package/index.js +1 -0
  14. package/{build/internal → internal}/ApiDecorator/ApiDecorator.d.ts +0 -0
  15. package/internal/ApiDecorator/ApiDecorator.js +107 -61
  16. package/internal/ApiDecorator/tests/ApiDecorator-specs.js +106 -97
  17. package/{build/internal → internal}/Registry/Registry.d.ts +0 -0
  18. package/internal/Registry/Registry.js +68 -51
  19. package/internal/Registry/tests/Registry-specs.js +201 -143
  20. package/{build/internal → internal}/deprecate/deprecate.d.ts +0 -0
  21. package/internal/deprecate/deprecate.js +85 -60
  22. package/{build/internal → internal}/prop-types/prop-types.d.ts +0 -0
  23. package/internal/prop-types/prop-types.js +68 -61
  24. package/{build/keymap → keymap}/index.d.ts +0 -0
  25. package/keymap/index.js +27 -15
  26. package/keymap/keymap.js +67 -52
  27. package/keymap/tests/keymap-specs.js +75 -104
  28. package/kind/computed.js +29 -16
  29. package/{build/kind → kind}/kind.d.ts +0 -0
  30. package/kind/kind.js +150 -114
  31. package/kind/styles.js +62 -47
  32. package/kind/tests/computed-specs.js +87 -86
  33. package/kind/tests/kind-specs.js +216 -214
  34. package/kind/tests/styles-specs.js +170 -223
  35. package/kind/util.js +15 -7
  36. package/package.json +1 -1
  37. package/{build/platform → platform}/platform.d.ts +0 -0
  38. package/platform/platform.js +263 -169
  39. package/platform/tests/platform-specs.js +92 -90
  40. package/{build/snapshot → snapshot}/snapshot.d.ts +0 -0
  41. package/snapshot/snapshot.js +34 -27
  42. package/useChainRefs/tests/useChainRefs-specs.js +46 -30
  43. package/{build/useChainRefs → useChainRefs}/useChainRefs.d.ts +0 -0
  44. package/useChainRefs/useChainRefs.js +49 -29
  45. package/useClass/tests/useClass-specs.js +51 -46
  46. package/{build/useClass → useClass}/useClass.d.ts +0 -0
  47. package/useClass/useClass.js +27 -9
  48. package/useHandlers/Handlers.js +55 -30
  49. package/useHandlers/tests/useHandlers-specs.js +79 -95
  50. package/{build/useHandlers → useHandlers}/useHandlers.d.ts +0 -0
  51. package/useHandlers/useHandlers.js +18 -11
  52. package/util/Job.js +203 -241
  53. package/util/tests/Job-specs.js +216 -204
  54. package/util/tests/util-specs.js +123 -146
  55. package/{build/util → util}/util.d.ts +0 -0
  56. package/util/util.js +146 -103
  57. package/build/CHANGELOG.md +0 -699
  58. package/build/README.md +0 -33
  59. package/build/dispatcher/dispatcher.js +0 -160
  60. package/build/dispatcher/listeners.js +0 -37
  61. package/build/dispatcher/package.json +0 -3
  62. package/build/dispatcher/tests/dispatcher-specs.js +0 -75
  63. package/build/handle/handle.js +0 -846
  64. package/build/handle/package.json +0 -3
  65. package/build/handle/tests/handle-specs.js +0 -476
  66. package/build/hoc/hoc.js +0 -102
  67. package/build/hoc/package.json +0 -3
  68. package/build/hoc/tests/hoc-specs.js +0 -90
  69. package/build/index.js +0 -2
  70. package/build/internal/ApiDecorator/ApiDecorator.js +0 -143
  71. package/build/internal/ApiDecorator/package.json +0 -3
  72. package/build/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -106
  73. package/build/internal/Registry/Registry.js +0 -76
  74. package/build/internal/Registry/package.json +0 -3
  75. package/build/internal/Registry/tests/Registry-specs.js +0 -201
  76. package/build/internal/deprecate/deprecate.js +0 -116
  77. package/build/internal/deprecate/package.json +0 -3
  78. package/build/internal/prop-types/package.json +0 -3
  79. package/build/internal/prop-types/prop-types.js +0 -90
  80. package/build/keymap/index.js +0 -54
  81. package/build/keymap/keymap.js +0 -201
  82. package/build/keymap/package.json +0 -3
  83. package/build/keymap/tests/keymap-specs.js +0 -75
  84. package/build/kind/computed.js +0 -60
  85. package/build/kind/kind.js +0 -266
  86. package/build/kind/package.json +0 -3
  87. package/build/kind/styles.js +0 -105
  88. package/build/kind/tests/computed-specs.js +0 -87
  89. package/build/kind/tests/kind-specs.js +0 -216
  90. package/build/kind/tests/styles-specs.js +0 -170
  91. package/build/kind/util.js +0 -17
  92. package/build/package-lock.json +0 -206
  93. package/build/package.json +0 -38
  94. package/build/platform/package.json +0 -3
  95. package/build/platform/platform.js +0 -306
  96. package/build/platform/tests/platform-specs.js +0 -92
  97. package/build/snapshot/package.json +0 -3
  98. package/build/snapshot/snapshot.js +0 -89
  99. package/build/useChainRefs/package.json +0 -3
  100. package/build/useChainRefs/tests/useChainRefs-specs.js +0 -57
  101. package/build/useChainRefs/useChainRefs.js +0 -78
  102. package/build/useClass/package.json +0 -3
  103. package/build/useClass/tests/useClass-specs.js +0 -51
  104. package/build/useClass/useClass.js +0 -59
  105. package/build/useHandlers/Handlers.js +0 -55
  106. package/build/useHandlers/package.json +0 -3
  107. package/build/useHandlers/tests/useHandlers-specs.js +0 -84
  108. package/build/useHandlers/useHandlers.js +0 -36
  109. package/build/util/Job.js +0 -211
  110. package/build/util/package.json +0 -3
  111. package/build/util/tests/Job-specs.js +0 -216
  112. package/build/util/tests/util-specs.js +0 -123
  113. package/build/util/util.js +0 -322
@@ -1,143 +1,201 @@
1
- import React from 'react';
2
- import {mount} from 'enzyme';
3
- import Registry from '../Registry';
4
-
5
- const SomeContext = React.createContext();
6
-
7
- describe('Registry', () => {
8
- class NotifiesTree extends React.Component {
9
- static contextType = SomeContext;
10
-
11
- componentDidMount () {
12
- this.registry.parent = this.context;
13
- }
14
-
15
- registry = Registry.create();
16
-
17
- handleClick = () => {
18
- this.registry.notify({});
19
- };
20
-
21
- render () {
22
- return (
23
- <SomeContext.Provider value={this.registry.register}>
24
- <button {...this.props} onClick={this.handleClick}>Notify!</button>
25
- {this.props.children}
26
- </SomeContext.Provider>
27
- );
28
- }
29
- }
30
-
31
- class HandlesNotification extends React.Component {
32
- static contextType = SomeContext;
33
-
34
- state = {
35
- number: 0
36
- };
37
-
38
- componentDidMount () {
39
- if (this.context && typeof this.context === 'function') {
40
- this.registry = this.context(this.handleResize);
41
- }
42
- }
43
-
44
- componentWillUnmount () {
45
- if (this.registry) {
46
- this.registry.unregister();
47
- }
48
- }
49
-
50
- handleResize = () => {
51
- this.setState((prevState) => {
52
- const number = prevState.number + 1;
53
-
54
- return ({
55
- number
56
- });
57
- });
58
- };
59
-
60
- render () {
61
- return <div {...this.props}>{this.state.number}</div>;
62
- }
63
- }
64
-
65
- test('should increment child on click', () => {
66
- const RegistryApp = mount(
67
- <NotifiesTree id="a-btn">
68
- <HandlesNotification id="a" />
69
- </NotifiesTree>
70
- );
71
-
72
- RegistryApp.find('button#a-btn').simulate('click');
73
-
74
- const expected = '1';
75
- const actual = RegistryApp.find('div#a').text();
76
-
77
- expect(expected).toBe(actual);
78
- });
79
-
80
- test('should increment both children on top click', () => {
81
- const RegistryApp = mount(
82
- <NotifiesTree id="a-btn">
83
- <HandlesNotification id="a" />
84
- <NotifiesTree id="b-btn">
85
- <HandlesNotification id="b" />
86
- </NotifiesTree>
87
- </NotifiesTree>
88
- );
89
-
90
- RegistryApp.find('button#a-btn').simulate('click');
91
-
92
- const expected = '1';
93
- const actualA = RegistryApp.find('div#a').text();
94
- const actualB = RegistryApp.find('div#b').text();
95
-
96
- expect(expected).toBe(actualA);
97
- expect(expected).toBe(actualB);
98
- });
99
-
100
- test('should increment the deepest child when we click child button', () => {
101
- const RegistryApp = mount(
102
- <NotifiesTree id="a-btn">
103
- <HandlesNotification id="a" />
104
- <NotifiesTree id="b-btn">
105
- <HandlesNotification id="b" />
106
- </NotifiesTree>
107
- </NotifiesTree>
108
- );
109
-
110
- RegistryApp.find('button#b-btn').simulate('click');
111
-
112
- const expectedA = '0';
113
- const expectedB = '1';
114
- const actualA = RegistryApp.find('div#a').text();
115
- const actualB = RegistryApp.find('div#b').text();
116
-
117
- expect(expectedA).toBe(actualA);
118
- expect(expectedB).toBe(actualB);
119
- });
120
-
121
- test('should support removing children without error', () => {
122
- const RegistryApp = mount(
123
- <NotifiesTree id="a-btn">
124
- <HandlesNotification id="a" />
125
- <HandlesNotification id="b" />
126
- </NotifiesTree>
127
- );
128
-
129
- RegistryApp.find('button#a-btn').simulate('click');
130
-
131
- // changing children should be safe and not throw errors when notifying instances
132
- RegistryApp.setProps({
133
- children: <HandlesNotification id="c" />
134
- });
135
-
136
- RegistryApp.find('button#a-btn').simulate('click');
137
-
138
- const expectedC = '1';
139
- const actualC = RegistryApp.find('div#c').text();
140
-
141
- expect(expectedC).toBe(actualC);
142
- });
143
- });
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _enzyme = require("enzyme");
6
+
7
+ var _Registry = _interopRequireDefault(require("../Registry"));
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+
13
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14
+
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16
+
17
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
18
+
19
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+
21
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22
+
23
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
24
+
25
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
+
27
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
28
+
29
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+
31
+ var SomeContext = /*#__PURE__*/_react["default"].createContext();
32
+
33
+ describe('Registry', function () {
34
+ var NotifiesTree = /*#__PURE__*/function (_React$Component) {
35
+ _inherits(NotifiesTree, _React$Component);
36
+
37
+ var _super = _createSuper(NotifiesTree);
38
+
39
+ function NotifiesTree() {
40
+ var _this;
41
+
42
+ _classCallCheck(this, NotifiesTree);
43
+
44
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
45
+ args[_key] = arguments[_key];
46
+ }
47
+
48
+ _this = _super.call.apply(_super, [this].concat(args));
49
+ _this.registry = _Registry["default"].create();
50
+
51
+ _this.handleClick = function () {
52
+ _this.registry.notify({});
53
+ };
54
+
55
+ return _this;
56
+ }
57
+
58
+ _createClass(NotifiesTree, [{
59
+ key: "componentDidMount",
60
+ value: function componentDidMount() {
61
+ this.registry.parent = this.context;
62
+ }
63
+ }, {
64
+ key: "render",
65
+ value: function render() {
66
+ return /*#__PURE__*/_react["default"].createElement(SomeContext.Provider, {
67
+ value: this.registry.register
68
+ }, /*#__PURE__*/_react["default"].createElement("button", Object.assign({}, this.props, {
69
+ onClick: this.handleClick
70
+ }), "Notify!"), this.props.children);
71
+ }
72
+ }]);
73
+
74
+ return NotifiesTree;
75
+ }(_react["default"].Component);
76
+
77
+ NotifiesTree.contextType = SomeContext;
78
+
79
+ var HandlesNotification = /*#__PURE__*/function (_React$Component2) {
80
+ _inherits(HandlesNotification, _React$Component2);
81
+
82
+ var _super2 = _createSuper(HandlesNotification);
83
+
84
+ function HandlesNotification() {
85
+ var _this2;
86
+
87
+ _classCallCheck(this, HandlesNotification);
88
+
89
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
90
+ args[_key2] = arguments[_key2];
91
+ }
92
+
93
+ _this2 = _super2.call.apply(_super2, [this].concat(args));
94
+ _this2.state = {
95
+ number: 0
96
+ };
97
+
98
+ _this2.handleResize = function () {
99
+ _this2.setState(function (prevState) {
100
+ var number = prevState.number + 1;
101
+ return {
102
+ number: number
103
+ };
104
+ });
105
+ };
106
+
107
+ return _this2;
108
+ }
109
+
110
+ _createClass(HandlesNotification, [{
111
+ key: "componentDidMount",
112
+ value: function componentDidMount() {
113
+ if (this.context && typeof this.context === 'function') {
114
+ this.registry = this.context(this.handleResize);
115
+ }
116
+ }
117
+ }, {
118
+ key: "componentWillUnmount",
119
+ value: function componentWillUnmount() {
120
+ if (this.registry) {
121
+ this.registry.unregister();
122
+ }
123
+ }
124
+ }, {
125
+ key: "render",
126
+ value: function render() {
127
+ return /*#__PURE__*/_react["default"].createElement("div", this.props, this.state.number);
128
+ }
129
+ }]);
130
+
131
+ return HandlesNotification;
132
+ }(_react["default"].Component);
133
+
134
+ HandlesNotification.contextType = SomeContext;
135
+ test('should increment child on click', function () {
136
+ var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
137
+ id: "a-btn"
138
+ }, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
139
+ id: "a"
140
+ })));
141
+ RegistryApp.find('button#a-btn').simulate('click');
142
+ var expected = '1';
143
+ var actual = RegistryApp.find('div#a').text();
144
+ expect(expected).toBe(actual);
145
+ });
146
+ test('should increment both children on top click', function () {
147
+ var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
148
+ id: "a-btn"
149
+ }, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
150
+ id: "a"
151
+ }), /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
152
+ id: "b-btn"
153
+ }, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
154
+ id: "b"
155
+ }))));
156
+ RegistryApp.find('button#a-btn').simulate('click');
157
+ var expected = '1';
158
+ var actualA = RegistryApp.find('div#a').text();
159
+ var actualB = RegistryApp.find('div#b').text();
160
+ expect(expected).toBe(actualA);
161
+ expect(expected).toBe(actualB);
162
+ });
163
+ test('should increment the deepest child when we click child button', function () {
164
+ var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
165
+ id: "a-btn"
166
+ }, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
167
+ id: "a"
168
+ }), /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
169
+ id: "b-btn"
170
+ }, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
171
+ id: "b"
172
+ }))));
173
+ RegistryApp.find('button#b-btn').simulate('click');
174
+ var expectedA = '0';
175
+ var expectedB = '1';
176
+ var actualA = RegistryApp.find('div#a').text();
177
+ var actualB = RegistryApp.find('div#b').text();
178
+ expect(expectedA).toBe(actualA);
179
+ expect(expectedB).toBe(actualB);
180
+ });
181
+ test('should support removing children without error', function () {
182
+ var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
183
+ id: "a-btn"
184
+ }, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
185
+ id: "a"
186
+ }), /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
187
+ id: "b"
188
+ })));
189
+ RegistryApp.find('button#a-btn').simulate('click'); // changing children should be safe and not throw errors when notifying instances
190
+
191
+ RegistryApp.setProps({
192
+ children: /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
193
+ id: "c"
194
+ })
195
+ });
196
+ RegistryApp.find('button#a-btn').simulate('click');
197
+ var expectedC = '1';
198
+ var actualC = RegistryApp.find('div#c').text();
199
+ expect(expectedC).toBe(actualC);
200
+ });
201
+ });
@@ -1,48 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deprecate = exports["default"] = void 0;
7
+
1
8
  /**
2
9
  * Provides the `deprecate` method
3
10
  *
4
11
  * @module core/internal/deprecate
5
12
  * @private
6
13
  */
7
-
8
14
  // Utility method to format deprecate message
9
- const formatMsg = ({message, name, until, replacedBy, since}) => {
10
- let msg = 'DEPRECATED:';
11
-
12
- if (name) {
13
- msg += ` ${name}`;
14
- }
15
- if (since) {
16
- msg += ` since ${since}`;
17
- }
18
- if (until) {
19
- if (name || since) {
20
- msg += '.';
21
- }
22
- msg += ` Will be removed in ${until}`;
23
- }
24
- if (replacedBy) {
25
- if (name || since || until) {
26
- msg += '.';
27
- }
28
- msg += ` Replaced by ${replacedBy}`;
29
- }
30
- if (name || since || until || replacedBy) {
31
- msg += '.';
32
- }
33
- if (message) {
34
- msg += ` ${message}.`;
35
- }
36
- return msg;
37
- };
15
+ var formatMsg = function formatMsg(_ref) {
16
+ var message = _ref.message,
17
+ name = _ref.name,
18
+ until = _ref.until,
19
+ replacedBy = _ref.replacedBy,
20
+ since = _ref.since;
21
+ var msg = 'DEPRECATED:';
38
22
 
39
- // Utility method for console warning
40
- const warn = (msg) => {
41
- if (typeof console !== 'undefined') {
42
- console.warn(msg); // eslint-disable-line no-console
43
- }
44
- };
23
+ if (name) {
24
+ msg += " ".concat(name);
25
+ }
26
+
27
+ if (since) {
28
+ msg += " since ".concat(since);
29
+ }
30
+
31
+ if (until) {
32
+ if (name || since) {
33
+ msg += '.';
34
+ }
35
+
36
+ msg += " Will be removed in ".concat(until);
37
+ }
38
+
39
+ if (replacedBy) {
40
+ if (name || since || until) {
41
+ msg += '.';
42
+ }
43
+
44
+ msg += " Replaced by ".concat(replacedBy);
45
+ }
45
46
 
47
+ if (name || since || until || replacedBy) {
48
+ msg += '.';
49
+ }
50
+
51
+ if (message) {
52
+ msg += " ".concat(message, ".");
53
+ }
54
+
55
+ return msg;
56
+ }; // Utility method for console warning
57
+
58
+
59
+ var warn = function warn(msg) {
60
+ if (typeof console !== 'undefined') {
61
+ console.warn(msg); // eslint-disable-line no-console
62
+ }
63
+ };
46
64
  /**
47
65
  * Marks a function, component or property (via `propTypes`) as deprecated. Deprecated items will
48
66
  * log a message on first invocation. Can also be used 'stand-alone' to issue a deprecation warning.
@@ -63,29 +81,36 @@ const warn = (msg) => {
63
81
  * @memberof core/internal/deprecate
64
82
  * @private
65
83
  */
66
- const deprecate = function (thing, config) {
67
- if (__DEV__) {
68
- if (!config) { // If no config, config only invocation, just log message
69
- const msg = formatMsg(thing);
70
- warn(msg);
71
- return thing;
72
- } else {
73
- let displayed, msg;
74
- return (...args) => {
75
- if (!displayed || config.alwaysWarn) {
76
- if (!msg) {
77
- msg = formatMsg(config);
78
- }
79
- warn(msg);
80
- displayed = true;
81
- }
82
- return thing(...args);
83
- };
84
- }
85
- } else {
86
- return thing;
87
- }
84
+
85
+
86
+ var deprecate = function deprecate(thing, config) {
87
+ if (process.env.NODE_ENV !== "production") {
88
+ if (!config) {
89
+ // If no config, config only invocation, just log message
90
+ var msg = formatMsg(thing);
91
+ warn(msg);
92
+ return thing;
93
+ } else {
94
+ var displayed, _msg;
95
+
96
+ return function () {
97
+ if (!displayed || config.alwaysWarn) {
98
+ if (!_msg) {
99
+ _msg = formatMsg(config);
100
+ }
101
+
102
+ warn(_msg);
103
+ displayed = true;
104
+ }
105
+
106
+ return thing.apply(void 0, arguments);
107
+ };
108
+ }
109
+ } else {
110
+ return thing;
111
+ }
88
112
  };
89
113
 
90
- export default deprecate;
91
- export {deprecate};
114
+ exports.deprecate = deprecate;
115
+ var _default = deprecate;
116
+ exports["default"] = _default;
@@ -1,83 +1,90 @@
1
- import PropTypes from 'prop-types';
1
+ "use strict";
2
2
 
3
- import {isRenderable} from '../../util';
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _util = require("../../util");
11
+
12
+ var _deprecate = _interopRequireDefault(require("../deprecate"));
4
13
 
5
- import deprecate from '../deprecate';
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
15
 
7
- const isRequired = (fn) => {
8
- fn.isRequired = function (props, key, componentName, location, propFullName, ...rest) {
9
- const propValue = props[key];
10
- if (typeof propValue === 'undefined') {
11
- return new Error(
12
- `'${propFullName}' is required for '${componentName}' but was undefined.`
13
- );
14
- }
16
+ var isRequired = function isRequired(fn) {
17
+ fn.isRequired = function (props, key, componentName, location, propFullName) {
18
+ var propValue = props[key];
15
19
 
16
- return fn(propValue, key, componentName, location, propFullName, ...rest);
17
- };
20
+ if (typeof propValue === 'undefined') {
21
+ return new Error("'".concat(propFullName, "' is required for '").concat(componentName, "' but was undefined."));
22
+ }
18
23
 
19
- return fn;
24
+ for (var _len = arguments.length, rest = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
25
+ rest[_key - 5] = arguments[_key];
26
+ }
27
+
28
+ return fn.apply(void 0, [propValue, key, componentName, location, propFullName].concat(rest));
29
+ };
30
+
31
+ return fn;
20
32
  };
21
33
 
22
- const renderable = isRequired(function (props, key, componentName) {
23
- const propValue = props[key];
24
- if (propValue && !isRenderable(propValue)) {
25
- return new Error(
26
- `Invalid prop '${key}' supplied to '${componentName}'. ` +
27
- `Expected a renderable value but received '${typeof propValue}' instead.`
28
- );
29
- }
30
- });
34
+ var renderable = isRequired(function (props, key, componentName) {
35
+ var propValue = props[key];
31
36
 
32
- const component = isRequired(function (props, key, componentName) {
33
- const propValue = props[key];
34
- if (propValue && (typeof propValue === 'string' || !isRenderable(propValue))) {
35
- return new Error(
36
- `Invalid prop '${key}' supplied to '${componentName}'. ` +
37
- `Expected a function but received '${typeof propValue}' instead.`
38
- );
39
- }
37
+ if (propValue && !(0, _util.isRenderable)(propValue)) {
38
+ return new Error("Invalid prop '".concat(key, "' supplied to '").concat(componentName, "'. ") + "Expected a renderable value but received '".concat(typeof propValue, "' instead."));
39
+ }
40
40
  });
41
+ var component = isRequired(function (props, key, componentName) {
42
+ var propValue = props[key];
41
43
 
42
- const renderableOverride = PropTypes.oneOfType([
43
- PropTypes.element,
44
- renderable
45
- ]);
44
+ if (propValue && (typeof propValue === 'string' || !(0, _util.isRenderable)(propValue))) {
45
+ return new Error("Invalid prop '".concat(key, "' supplied to '").concat(componentName, "'. ") + "Expected a function but received '".concat(typeof propValue, "' instead."));
46
+ }
47
+ });
46
48
 
47
- const componentOverride = PropTypes.oneOfType([
48
- PropTypes.element,
49
- component
50
- ]);
49
+ var renderableOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, renderable]);
51
50
 
52
- const ref = PropTypes.oneOfType([PropTypes.shape({
53
- current: PropTypes.any
54
- }), PropTypes.func]);
51
+ var componentOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, component]);
55
52
 
53
+ var ref = _propTypes["default"].oneOfType([_propTypes["default"].shape({
54
+ current: _propTypes["default"].any
55
+ }), _propTypes["default"].func]);
56
56
  /*
57
57
  * Wrap a prop type validator with a deprecation warning when the prop has a non-null value
58
58
  *
59
59
  * @param {Function} base Prop type validator
60
60
  * @param {Object} config deprecatioon configuration
61
61
  */
62
- const deprecated = (base, config) => {
63
- // Wrap in a no-op so deprecate only warns once
64
- const warn = deprecate(() => true, config);
65
- return (props, key, ...rest) => {
66
- // Warn on a non-null value for the prop
67
- if (props[key] != null) warn();
68
-
69
- // Pass on to the prop type validator
70
- return base(props, key, ...rest);
71
- };
72
- };
73
62
 
74
- const EnactPropTypes = {
75
- component,
76
- componentOverride,
77
- ref,
78
- deprecated,
79
- renderable,
80
- renderableOverride
63
+
64
+ var deprecated = function deprecated(base, config) {
65
+ // Wrap in a no-op so deprecate only warns once
66
+ var warn = (0, _deprecate["default"])(function () {
67
+ return true;
68
+ }, config);
69
+ return function (props, key) {
70
+ // Warn on a non-null value for the prop
71
+ if (props[key] != null) warn(); // Pass on to the prop type validator
72
+
73
+ for (var _len2 = arguments.length, rest = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
74
+ rest[_key2 - 2] = arguments[_key2];
75
+ }
76
+
77
+ return base.apply(void 0, [props, key].concat(rest));
78
+ };
81
79
  };
82
80
 
83
- export default EnactPropTypes;
81
+ var EnactPropTypes = {
82
+ component: component,
83
+ componentOverride: componentOverride,
84
+ ref: ref,
85
+ deprecated: deprecated,
86
+ renderable: renderable,
87
+ renderableOverride: renderableOverride
88
+ };
89
+ var _default = EnactPropTypes;
90
+ exports["default"] = _default;