@pingux/astro 2.54.0-alpha.2 → 2.54.0-alpha.4
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/lib/cjs/components/ArrayField/ArrayField.js +1 -2
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +3 -2
- package/lib/cjs/components/Button/Button.js +2 -4
- package/lib/cjs/components/CheckboxField/CheckboxField.js +2 -4
- package/lib/cjs/components/ColorField/ColorField.js +2 -4
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +2 -4
- package/lib/cjs/components/DatePicker/DatePicker.js +2 -4
- package/lib/cjs/components/FileInputField/FileInputField.js +2 -4
- package/lib/cjs/components/HelpHint/HelpHint.stories.js +7 -7
- package/lib/cjs/components/IconButton/IconButton.js +2 -4
- package/lib/cjs/components/IconButton/IconButton.styles.d.ts +1 -72
- package/lib/cjs/components/ImageUploadField/ImageUploadField.js +2 -4
- package/lib/cjs/components/Input/Input.js +6 -7
- package/lib/cjs/components/LinkSelectField/LinkSelectField.js +2 -4
- package/lib/cjs/components/ListViewItem/ListViewItem.js +2 -4
- package/lib/cjs/components/Messages/Message.js +46 -16
- package/lib/cjs/components/Messages/Messages.js +15 -2
- package/lib/cjs/components/Messages/Messages.reducer.js +51 -0
- package/lib/cjs/components/Messages/Messages.stories.js +16 -96
- package/lib/cjs/components/Messages/Messages.test.js +9 -9
- package/lib/cjs/components/Messages/index.js +3 -2
- package/lib/cjs/components/Messages/utils/messagesReducer.js +15 -29
- package/lib/cjs/components/Messages/utils/multiMessagesReducer.js +14 -20
- package/lib/cjs/components/Messages/utils/tests/messagesReducer.test.js +3 -4
- package/lib/cjs/components/Messages/utils/tests/multiMessagesReducer.test.js +2 -3
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +3 -2
- package/lib/cjs/components/NumberField/NumberField.js +1 -2
- package/lib/cjs/components/PasswordField/PasswordField.js +2 -4
- package/lib/cjs/components/RadioGroupField/RadioGroupField.js +2 -4
- package/lib/cjs/components/SearchField/SearchField.js +2 -4
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +1 -2
- package/lib/cjs/components/SwitchField/SwitchField.js +3 -5
- package/lib/cjs/components/Tab/Tab.js +1 -2
- package/lib/cjs/components/TextAreaField/TextAreaField.js +2 -4
- package/lib/cjs/components/TextField/TextField.js +2 -4
- package/lib/cjs/components/TimeZonePicker/TimeZonePicker.js +1 -2
- package/lib/cjs/types/index.d.ts +0 -1
- package/lib/cjs/types/index.js +14 -25
- package/lib/cjs/types/item.d.ts +0 -2
- package/lib/components/ArrayField/ArrayField.js +1 -2
- package/lib/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.test.js +3 -2
- package/lib/components/Button/Button.js +2 -4
- package/lib/components/CheckboxField/CheckboxField.js +2 -4
- package/lib/components/ColorField/ColorField.js +2 -4
- package/lib/components/ComboBoxField/ComboBoxField.js +2 -4
- package/lib/components/DatePicker/DatePicker.js +2 -4
- package/lib/components/FileInputField/FileInputField.js +2 -4
- package/lib/components/HelpHint/HelpHint.stories.js +7 -7
- package/lib/components/IconButton/IconButton.js +2 -4
- package/lib/components/ImageUploadField/ImageUploadField.js +2 -4
- package/lib/components/Input/Input.js +5 -6
- package/lib/components/LinkSelectField/LinkSelectField.js +2 -4
- package/lib/components/ListViewItem/ListViewItem.js +2 -4
- package/lib/components/Messages/Message.js +46 -14
- package/lib/components/Messages/Messages.js +15 -2
- package/lib/components/Messages/Messages.reducer.js +41 -0
- package/lib/components/Messages/Messages.stories.js +15 -95
- package/lib/components/Messages/Messages.test.js +9 -9
- package/lib/components/Messages/index.js +1 -1
- package/lib/components/Messages/utils/messagesReducer.js +13 -27
- package/lib/components/Messages/utils/multiMessagesReducer.js +10 -20
- package/lib/components/Messages/utils/tests/messagesReducer.test.js +3 -4
- package/lib/components/Messages/utils/tests/multiMessagesReducer.test.js +8 -9
- package/lib/components/MultivaluesField/MultivaluesField.js +4 -3
- package/lib/components/NumberField/NumberField.js +1 -2
- package/lib/components/PasswordField/PasswordField.js +2 -4
- package/lib/components/RadioGroupField/RadioGroupField.js +2 -4
- package/lib/components/SearchField/SearchField.js +2 -4
- package/lib/components/SelectFieldBase/SelectFieldBase.js +1 -2
- package/lib/components/SwitchField/SwitchField.js +3 -5
- package/lib/components/Tab/Tab.js +1 -2
- package/lib/components/TextAreaField/TextAreaField.js +2 -4
- package/lib/components/TextField/TextField.js +2 -4
- package/lib/components/TimeZonePicker/TimeZonePicker.js +1 -2
- package/lib/types/index.js +0 -1
- package/package.json +1 -1
- package/lib/cjs/components/Messages/Message.d.ts +0 -9
- package/lib/cjs/components/Messages/Message.styles.d.ts +0 -151
- package/lib/cjs/components/Messages/Messages.d.ts +0 -4
- package/lib/cjs/components/Messages/Messages.stories.d.ts +0 -128
- package/lib/cjs/components/Messages/Messages.test.d.ts +0 -1
- package/lib/cjs/components/Messages/index.d.ts +0 -3
- package/lib/cjs/components/Messages/utils/index.d.ts +0 -2
- package/lib/cjs/components/Messages/utils/messagesReducer.d.ts +0 -107
- package/lib/cjs/components/Messages/utils/multiMessagesReducer.d.ts +0 -83
- package/lib/cjs/components/Messages/utils/tests/messagesReducer.test.d.ts +0 -1
- package/lib/cjs/components/Messages/utils/tests/multiMessagesReducer.test.d.ts +0 -1
- package/lib/cjs/types/messages.d.ts +0 -43
- package/lib/cjs/types/messages.js +0 -6
- package/lib/cjs/utils/devUtils/constants/pendoID.d.ts +0 -3
- package/lib/cjs/utils/devUtils/constants/pendoID.js +0 -13
- package/lib/types/messages.js +0 -1
- package/lib/utils/devUtils/constants/pendoID.js +0 -5
@@ -21,7 +21,7 @@ import AccountIcon from '@pingux/mdi-react/AccountIcon';
|
|
21
21
|
import { withDesign } from 'storybook-addon-designs';
|
22
22
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
23
23
|
import { Box, Button, Messages } from '../../index';
|
24
|
-
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
|
24
|
+
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.ts';
|
25
25
|
import statuses from '../../utils/devUtils/constants/statuses';
|
26
26
|
import { messagesReducerStory as messagesReducer, multiMessagesReducerStory as multiMessagesReducer } from './index';
|
27
27
|
import MessagesReadme from './Messages.mdx';
|
@@ -60,15 +60,15 @@ var messages = [{
|
|
60
60
|
}, {
|
61
61
|
key: 'message2',
|
62
62
|
text: loremText,
|
63
|
-
status:
|
63
|
+
status: 'success'
|
64
64
|
}, {
|
65
65
|
key: 'message3',
|
66
66
|
text: loremText,
|
67
|
-
status:
|
67
|
+
status: 'warning'
|
68
68
|
}, {
|
69
69
|
key: 'message4',
|
70
70
|
text: loremText,
|
71
|
-
status:
|
71
|
+
status: 'error'
|
72
72
|
}];
|
73
73
|
export var Default = function Default(args) {
|
74
74
|
return ___EmotionJSX(Messages, args, ___EmotionJSX(Item, {
|
@@ -77,7 +77,7 @@ export var Default = function Default(args) {
|
|
77
77
|
}, loremText), ___EmotionJSX(Item, {
|
78
78
|
key: "message2",
|
79
79
|
"data-id": "message2",
|
80
|
-
status:
|
80
|
+
status: "success"
|
81
81
|
}, loremText));
|
82
82
|
};
|
83
83
|
Default.parameters = {
|
@@ -87,25 +87,17 @@ Default.parameters = {
|
|
87
87
|
}
|
88
88
|
};
|
89
89
|
export var DefaultDynamic = function DefaultDynamic(args) {
|
90
|
-
return
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
DefaultDynamic.parameters = {
|
99
|
-
a11y: {
|
100
|
-
config: {
|
101
|
-
rules: [{
|
102
|
-
id: 'color-contrast',
|
103
|
-
enabled: false
|
104
|
-
}]
|
105
|
-
}
|
106
|
-
}
|
90
|
+
return (
|
91
|
+
// messages = [{...}]
|
92
|
+
___EmotionJSX(Messages, _extends({}, args, {
|
93
|
+
items: messages
|
94
|
+
}), function (item) {
|
95
|
+
return ___EmotionJSX(Item, item, item.text);
|
96
|
+
})
|
97
|
+
);
|
107
98
|
};
|
108
99
|
export var Controlled = function Controlled(args) {
|
100
|
+
// messages = [{...}]
|
109
101
|
var _useState = useState([]),
|
110
102
|
_useState2 = _slicedToArray(_useState, 2),
|
111
103
|
items = _useState2[0],
|
@@ -132,18 +124,6 @@ export var Controlled = function Controlled(args) {
|
|
132
124
|
return ___EmotionJSX(Item, item, item.text);
|
133
125
|
});
|
134
126
|
};
|
135
|
-
|
136
|
-
// Added to bypass color contrast in safari
|
137
|
-
Controlled.parameters = {
|
138
|
-
a11y: {
|
139
|
-
config: {
|
140
|
-
rules: [{
|
141
|
-
id: 'color-contrast',
|
142
|
-
enabled: false
|
143
|
-
}]
|
144
|
-
}
|
145
|
-
}
|
146
|
-
};
|
147
127
|
export var ControlledWithButton = function ControlledWithButton(args) {
|
148
128
|
var _useState3 = useState([]),
|
149
129
|
_useState4 = _slicedToArray(_useState3, 2),
|
@@ -178,18 +158,6 @@ export var ControlledWithButton = function ControlledWithButton(args) {
|
|
178
158
|
return ___EmotionJSX(Item, item, item.text);
|
179
159
|
}));
|
180
160
|
};
|
181
|
-
|
182
|
-
// Added to bypass color contrast in safari
|
183
|
-
ControlledWithButton.parameters = {
|
184
|
-
a11y: {
|
185
|
-
config: {
|
186
|
-
rules: [{
|
187
|
-
id: 'color-contrast',
|
188
|
-
enabled: false
|
189
|
-
}]
|
190
|
-
}
|
191
|
-
}
|
192
|
-
};
|
193
161
|
export var WithCustomColorsAndIcons = function WithCustomColorsAndIcons(args) {
|
194
162
|
return ___EmotionJSX(Messages, args, ___EmotionJSX(Item, {
|
195
163
|
bg: "accent.99",
|
@@ -197,18 +165,6 @@ export var WithCustomColorsAndIcons = function WithCustomColorsAndIcons(args) {
|
|
197
165
|
icon: AccountIcon
|
198
166
|
}, loremText));
|
199
167
|
};
|
200
|
-
|
201
|
-
// Added to bypass color contrast in safari
|
202
|
-
WithCustomColorsAndIcons.parameters = {
|
203
|
-
a11y: {
|
204
|
-
config: {
|
205
|
-
rules: [{
|
206
|
-
id: 'color-contrast',
|
207
|
-
enabled: false
|
208
|
-
}]
|
209
|
-
}
|
210
|
-
}
|
211
|
-
};
|
212
168
|
export var UseReducer = function UseReducer() {
|
213
169
|
// import { messagesReducer as messagesReducerCore } from '@pingux/astro';
|
214
170
|
// const messagesReducer = messagesReducerCore;
|
@@ -223,7 +179,7 @@ export var UseReducer = function UseReducer() {
|
|
223
179
|
// showWarningMessage: makeShowMessage('warning', -1),
|
224
180
|
// };
|
225
181
|
|
226
|
-
var _useReducer = useReducer(messagesReducer
|
182
|
+
var _useReducer = useReducer(messagesReducer),
|
227
183
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
228
184
|
items = _useReducer2[0],
|
229
185
|
dispatch = _useReducer2[1];
|
@@ -251,18 +207,6 @@ export var UseReducer = function UseReducer() {
|
|
251
207
|
return ___EmotionJSX(Item, item, item.text);
|
252
208
|
}));
|
253
209
|
};
|
254
|
-
|
255
|
-
// Added to bypass color contrast in safari
|
256
|
-
UseReducer.parameters = {
|
257
|
-
a11y: {
|
258
|
-
config: {
|
259
|
-
rules: [{
|
260
|
-
id: 'color-contrast',
|
261
|
-
enabled: false
|
262
|
-
}]
|
263
|
-
}
|
264
|
-
}
|
265
|
-
};
|
266
210
|
export var UseReducerWithMultipleContainers = function UseReducerWithMultipleContainers() {
|
267
211
|
var _useReducer3 = useReducer(multiMessagesReducer, {
|
268
212
|
'container-one': [],
|
@@ -314,18 +258,6 @@ export var UseReducerWithMultipleContainers = function UseReducerWithMultipleCon
|
|
314
258
|
return ___EmotionJSX(Item, item, item.text);
|
315
259
|
}));
|
316
260
|
};
|
317
|
-
|
318
|
-
// Added to bypass color contrast in safari
|
319
|
-
UseReducerWithMultipleContainers.parameters = {
|
320
|
-
a11y: {
|
321
|
-
config: {
|
322
|
-
rules: [{
|
323
|
-
id: 'color-contrast',
|
324
|
-
enabled: false
|
325
|
-
}]
|
326
|
-
}
|
327
|
-
}
|
328
|
-
};
|
329
261
|
export var WithTextStyling = function WithTextStyling(args) {
|
330
262
|
var items = [{
|
331
263
|
key: 'message1',
|
@@ -348,16 +280,4 @@ export var WithTextStyling = function WithTextStyling(args) {
|
|
348
280
|
}), function (item) {
|
349
281
|
return ___EmotionJSX(Item, item, item.node || item.text);
|
350
282
|
});
|
351
|
-
};
|
352
|
-
|
353
|
-
// Added to bypass color contrast in safari
|
354
|
-
WithTextStyling.parameters = {
|
355
|
-
a11y: {
|
356
|
-
config: {
|
357
|
-
rules: [{
|
358
|
-
id: 'color-contrast',
|
359
|
-
enabled: false
|
360
|
-
}]
|
361
|
-
}
|
362
|
-
}
|
363
283
|
};
|
@@ -6,7 +6,6 @@ import { act } from 'react-dom/test-utils';
|
|
6
6
|
import { Item } from 'react-stately';
|
7
7
|
import AccountIcon from '@pingux/mdi-react/AccountIcon';
|
8
8
|
import userEvent from '@testing-library/user-event';
|
9
|
-
import statuses from '../../utils/devUtils/constants/statuses';
|
10
9
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
11
10
|
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
12
11
|
import { ARIA_STATUSES } from './Message';
|
@@ -28,7 +27,7 @@ var items = [{
|
|
28
27
|
}, {
|
29
28
|
key: 'message2',
|
30
29
|
text: 'Form saved successfully',
|
31
|
-
status:
|
30
|
+
status: 'success'
|
32
31
|
}];
|
33
32
|
var getComponent = function getComponent() {
|
34
33
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -39,7 +38,7 @@ var getComponent = function getComponent() {
|
|
39
38
|
}, "Here is a very neutral thing"), ___EmotionJSX(Item, {
|
40
39
|
key: "message2",
|
41
40
|
"data-id": "message2",
|
42
|
-
status:
|
41
|
+
status: "success"
|
43
42
|
}, "Form saved successfully")));
|
44
43
|
};
|
45
44
|
var getWithDynamicList = function getWithDynamicList() {
|
@@ -99,15 +98,16 @@ test('`onClose` get as first arg key of message', function () {
|
|
99
98
|
expect(onClose).toHaveBeenCalledWith('message1');
|
100
99
|
});
|
101
100
|
test('click on close button removes message after delay', function () {
|
102
|
-
|
101
|
+
act(function () {
|
102
|
+
global.setTimeout = jest.fn(function (cb) {
|
103
|
+
return cb();
|
104
|
+
});
|
105
|
+
});
|
103
106
|
getComponent();
|
104
107
|
var messages = screen.getByTestId(testId);
|
105
108
|
expect(messages.childElementCount).toBe(2);
|
106
109
|
var buttons = screen.getAllByRole('button');
|
107
110
|
userEvent.click(buttons[0]);
|
108
|
-
act(function () {
|
109
|
-
jest.runAllTimers();
|
110
|
-
});
|
111
111
|
expect(messages.childElementCount).toBe(1);
|
112
112
|
});
|
113
113
|
test('Item accepts a data-id and the data-id can be found in the DOM', function () {
|
@@ -138,12 +138,12 @@ test('messages without a status do not have an aria-label announcing the status'
|
|
138
138
|
});
|
139
139
|
test('should render messages with messagesReducerStory', function () {
|
140
140
|
getComponent();
|
141
|
-
messagesReducerStory.actions.showSuccessMessage(
|
141
|
+
messagesReducerStory.actions.showSuccessMessage();
|
142
142
|
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
143
143
|
});
|
144
144
|
test('should render messages with multiMessagesReducerStory', function () {
|
145
145
|
getComponent();
|
146
|
-
multiMessagesReducerStory.actions.showSuccessMessage(
|
146
|
+
multiMessagesReducerStory.actions.showSuccessMessage();
|
147
147
|
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
148
148
|
});
|
149
149
|
test('should render a custom icon', function () {
|
@@ -1,3 +1,3 @@
|
|
1
1
|
export { default } from './Messages';
|
2
|
-
export { messagesReducer as messagesReducerStory, multiMessagesReducer as multiMessagesReducerStory } from './
|
2
|
+
export { messagesReducer as messagesReducerStory, multiMessagesReducer as multiMessagesReducerStory } from './Messages.reducer';
|
3
3
|
export * from './utils';
|
@@ -13,7 +13,6 @@ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
15
|
import { v4 as uuid } from 'uuid';
|
16
|
-
import statuses from '../../../utils/devUtils/constants/statuses';
|
17
16
|
|
18
17
|
/**
|
19
18
|
* A set of message util functions.
|
@@ -22,14 +21,9 @@ export var messagesActions = {
|
|
22
21
|
ADD_MESSAGE: 'ADD_MESSAGE',
|
23
22
|
HIDE_MESSAGE: 'HIDE_MESSAGE',
|
24
23
|
REMOVE_MESSAGE: 'REMOVE_MESSAGE',
|
25
|
-
CLEAR_MESSAGES: 'CLEAR_MESSAGES'
|
26
|
-
SHOW_SUCCESS_MESSAGE: 'SHOW_SUCCESS_MESSAGE',
|
27
|
-
SHOW_ERROR_MESSAGE: 'SHOW_ERROR_MESSAGE',
|
28
|
-
SHOW_WARNING_MESSAGE: 'SHOW_WARNING_MESSAGE',
|
29
|
-
MULTI_SHOW_SUCCESS_MESSAGE: 'MULTI_SHOW_SUCCESS_MESSAGE',
|
30
|
-
MULTI_SHOW_CRITICAL_MESSAGE: 'MULTI_SHOW_CRITICAL_MESSAGE',
|
31
|
-
MULTI_SHOW_WARNING_MESSAGE: 'MULTI_SHOW_WARNING_MESSAGE'
|
24
|
+
CLEAR_MESSAGES: 'CLEAR_MESSAGES'
|
32
25
|
};
|
26
|
+
|
33
27
|
/**
|
34
28
|
* Create an action to add a message
|
35
29
|
* The message object to be added
|
@@ -90,25 +84,20 @@ export var clearMessages = function clearMessages() {
|
|
90
84
|
};
|
91
85
|
};
|
92
86
|
|
93
|
-
// eslint-disable-next-line max-len
|
94
|
-
var makeShowMessage = function makeShowMessage(status, timeout) {
|
95
|
-
return function (text) {
|
96
|
-
return messagesReducer.actions.showMessage({
|
97
|
-
text: text,
|
98
|
-
status: status
|
99
|
-
}, timeout);
|
100
|
-
};
|
101
|
-
};
|
102
|
-
|
103
87
|
/** Reducer to store a list of messages */
|
104
|
-
var messagesReducer = function messagesReducer(
|
88
|
+
var messagesReducer = function messagesReducer() {
|
105
89
|
var _context;
|
106
|
-
|
90
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
91
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
92
|
+
type = _ref.type,
|
93
|
+
message = _ref.message,
|
94
|
+
key = _ref.key;
|
95
|
+
switch (type) {
|
107
96
|
case messagesActions.ADD_MESSAGE:
|
108
|
-
return _concatInstanceProperty(_context = []).call(_context, state, [_objectSpread({},
|
97
|
+
return _concatInstanceProperty(_context = []).call(_context, state, [_objectSpread({}, message)]);
|
109
98
|
case messagesActions.HIDE_MESSAGE:
|
110
99
|
return _mapInstanceProperty(state).call(state, function (search) {
|
111
|
-
if (search.key ===
|
100
|
+
if (search.key === key) {
|
112
101
|
return _objectSpread(_objectSpread({}, search), {}, {
|
113
102
|
isHidden: true
|
114
103
|
});
|
@@ -117,7 +106,7 @@ var messagesReducer = function messagesReducer(state, action) {
|
|
117
106
|
});
|
118
107
|
case messagesActions.REMOVE_MESSAGE:
|
119
108
|
return _filterInstanceProperty(state).call(state, function (search) {
|
120
|
-
return
|
109
|
+
return key !== search.key;
|
121
110
|
});
|
122
111
|
case messagesActions.CLEAR_MESSAGES:
|
123
112
|
return [];
|
@@ -130,9 +119,6 @@ messagesReducer.actions = {
|
|
130
119
|
hideMessage: hideMessage,
|
131
120
|
removeMessage: removeMessage,
|
132
121
|
showMessage: showMessage,
|
133
|
-
clearMessages: clearMessages
|
134
|
-
showSuccessMessage: makeShowMessage(statuses.SUCCESS, 3000),
|
135
|
-
showErrorMessage: makeShowMessage(statuses.ERROR, -1),
|
136
|
-
showWarningMessage: makeShowMessage(statuses.WARNING, -1)
|
122
|
+
clearMessages: clearMessages
|
137
123
|
};
|
138
124
|
export default messagesReducer;
|
@@ -13,8 +13,7 @@ import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
15
|
import { v4 as uuid } from 'uuid';
|
16
|
-
import
|
17
|
-
import messagesReducer from './messagesReducer';
|
16
|
+
import messagesReducer, { addMessage as addMessageSingle, clearMessages as clearMessagesSingle, hideMessage as hideMessageSingle, removeMessage as removeMessageSingle } from './messagesReducer';
|
18
17
|
export var withContainer = function withContainer(container, action) {
|
19
18
|
return _objectSpread({
|
20
19
|
container: container
|
@@ -32,22 +31,22 @@ export var createMultiple = function createMultiple(actionCreator) {
|
|
32
31
|
/**
|
33
32
|
* Create an action to add a message
|
34
33
|
*/
|
35
|
-
export var addMessage = createMultiple(
|
34
|
+
export var addMessage = createMultiple(addMessageSingle);
|
36
35
|
|
37
36
|
/**
|
38
37
|
* Create an action to hide a message by key
|
39
38
|
*/
|
40
|
-
export var hideMessage = createMultiple(
|
39
|
+
export var hideMessage = createMultiple(hideMessageSingle);
|
41
40
|
|
42
41
|
/**
|
43
42
|
* Create an action to remove a message
|
44
43
|
*/
|
45
|
-
export var removeMessage = createMultiple(
|
44
|
+
export var removeMessage = createMultiple(removeMessageSingle);
|
46
45
|
|
47
46
|
/**
|
48
47
|
* Create an action to clear all messages
|
49
48
|
*/
|
50
|
-
export var clearMessages = createMultiple(
|
49
|
+
export var clearMessages = createMultiple(clearMessagesSingle);
|
51
50
|
|
52
51
|
/**
|
53
52
|
* Create an action to add a message and then remove it if there's a timeout
|
@@ -70,16 +69,10 @@ export var showMessage = function showMessage(container, messageArg) {
|
|
70
69
|
return message;
|
71
70
|
};
|
72
71
|
};
|
73
|
-
var
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
status: status
|
78
|
-
}, timeout);
|
79
|
-
};
|
80
|
-
};
|
81
|
-
var multiMessagesReducer = function multiMessagesReducer(state, _ref) {
|
82
|
-
var container = _ref.container,
|
72
|
+
var multiMessagesReducer = function multiMessagesReducer() {
|
73
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
74
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
75
|
+
container = _ref.container,
|
83
76
|
action = _objectWithoutProperties(_ref, _excluded);
|
84
77
|
return container ? _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, container, messagesReducer(state[container], action))) : state;
|
85
78
|
};
|
@@ -88,9 +81,6 @@ multiMessagesReducer.actions = {
|
|
88
81
|
addMessage: addMessage,
|
89
82
|
hideMessage: hideMessage,
|
90
83
|
clearMessages: clearMessages,
|
91
|
-
showMessage: showMessage
|
92
|
-
showSuccessMessage: makeMultiShowMessage(statuses.SUCCESS, 3000),
|
93
|
-
showCriticalMessage: makeMultiShowMessage(statuses.ERROR, -1),
|
94
|
-
showWarningMessage: makeMultiShowMessage(statuses.WARNING, -1)
|
84
|
+
showMessage: showMessage
|
95
85
|
};
|
96
86
|
export default multiMessagesReducer;
|
@@ -43,7 +43,7 @@ var getComponent = function getComponent() {
|
|
43
43
|
return renderFn(___EmotionJSX(TestComponent, props));
|
44
44
|
};
|
45
45
|
test('should create an empty state', function () {
|
46
|
-
var state = messagesReducer(
|
46
|
+
var state = messagesReducer();
|
47
47
|
expect(state.length).toBe(0);
|
48
48
|
});
|
49
49
|
test('should add a new message', function () {
|
@@ -67,12 +67,11 @@ test('should clear all messages', function () {
|
|
67
67
|
expect(state.length).toBe(0);
|
68
68
|
});
|
69
69
|
test('should show and hide a message', function () {
|
70
|
-
var _screen$queryByTestId, _screen$queryByTestId2;
|
71
70
|
jest.useFakeTimers();
|
72
71
|
getComponent();
|
73
|
-
expect(
|
72
|
+
expect(screen.queryByTestId(testId).children.length).toBe(1);
|
74
73
|
act(function () {
|
75
74
|
jest.runAllTimers();
|
76
75
|
});
|
77
|
-
expect(
|
76
|
+
expect(screen.queryByTestId(testId).children.length).toBe(0);
|
78
77
|
});
|
@@ -3,7 +3,7 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
|
|
3
3
|
import React, { useEffect, useReducer } from 'react';
|
4
4
|
import { act } from 'react-dom/test-utils';
|
5
5
|
import { render, screen } from '../../../../utils/testUtils/testWrapper';
|
6
|
-
import
|
6
|
+
import messagesReducer, { addMessage, clearMessages, hideMessage, removeMessage, showMessage } from '../multiMessagesReducer';
|
7
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
8
|
var testId = 'test-messages';
|
9
9
|
var messages = [{
|
@@ -18,7 +18,7 @@ var messages = [{
|
|
18
18
|
}];
|
19
19
|
var TestComponent = function TestComponent() {
|
20
20
|
var _context;
|
21
|
-
var _useReducer = useReducer(
|
21
|
+
var _useReducer = useReducer(messagesReducer, {
|
22
22
|
container: []
|
23
23
|
}),
|
24
24
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
@@ -46,7 +46,7 @@ var getComponent = function getComponent() {
|
|
46
46
|
return renderFn(___EmotionJSX(TestComponent, props));
|
47
47
|
};
|
48
48
|
test('should add a new message', function () {
|
49
|
-
var state =
|
49
|
+
var state = messagesReducer({
|
50
50
|
'container-one': messages
|
51
51
|
}, addMessage('container-one', {
|
52
52
|
key: 4,
|
@@ -55,31 +55,30 @@ test('should add a new message', function () {
|
|
55
55
|
expect(state['container-one'].length).toBe(4);
|
56
56
|
});
|
57
57
|
test('should hide a message by key', function () {
|
58
|
-
var state =
|
58
|
+
var state = messagesReducer({
|
59
59
|
'container-one': messages
|
60
60
|
}, hideMessage('container-one', 2));
|
61
61
|
expect(state['container-one'].length).toBe(3);
|
62
62
|
expect(state['container-one'][1].isHidden).toBe(true);
|
63
63
|
});
|
64
64
|
test('should remove a message by key', function () {
|
65
|
-
var state =
|
65
|
+
var state = messagesReducer({
|
66
66
|
'container-one': messages
|
67
67
|
}, removeMessage('container-one', 2));
|
68
68
|
expect(state['container-one'].length).toBe(2);
|
69
69
|
});
|
70
70
|
test('should clear all messages', function () {
|
71
|
-
var state =
|
71
|
+
var state = messagesReducer({
|
72
72
|
'container-one': messages
|
73
73
|
}, clearMessages('container-one'));
|
74
74
|
expect(state['container-one'].length).toBe(0);
|
75
75
|
});
|
76
76
|
test('should show and hide a message', function () {
|
77
|
-
var _screen$queryByTestId, _screen$queryByTestId2;
|
78
77
|
jest.useFakeTimers();
|
79
78
|
getComponent();
|
80
|
-
expect(
|
79
|
+
expect(screen.queryByTestId(testId).children.length).toBe(1);
|
81
80
|
act(function () {
|
82
81
|
jest.runAllTimers();
|
83
82
|
});
|
84
|
-
expect(
|
83
|
+
expect(screen.queryByTestId(testId).children.length).toBe(0);
|
85
84
|
});
|
@@ -32,9 +32,8 @@ import PropTypes from 'prop-types';
|
|
32
32
|
import { Badge, Box, Icon, IconButton, PopoverContainer, ScrollBox, Text, TextField } from '../..';
|
33
33
|
import { MultivaluesContext } from '../../context/MultivaluesContext';
|
34
34
|
import { usePropWarning } from '../../hooks';
|
35
|
-
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
36
35
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
37
|
-
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
36
|
+
import { ariaAttributesBasePropTypes, getAriaAttributeProps } from '../../utils/docUtils/ariaAttributes';
|
38
37
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
39
38
|
import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
|
40
39
|
import ListBox from '../ListBox';
|
@@ -71,6 +70,8 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
71
70
|
scrollBoxProps = props.scrollBoxProps,
|
72
71
|
status = props.status,
|
73
72
|
others = _objectWithoutProperties(props, _excluded);
|
73
|
+
var _getAriaAttributeProp = getAriaAttributeProps(others),
|
74
|
+
ariaProps = _getAriaAttributeProp.ariaProps;
|
74
75
|
var hasCustomValue = mode === 'non-restrictive';
|
75
76
|
usePropWarning(props, 'disabled', 'isDisabled');
|
76
77
|
var _useState = useState([]),
|
@@ -486,7 +487,7 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
486
487
|
value: filterString,
|
487
488
|
helperText: helperText,
|
488
489
|
"aria-invalid": status === 'error' && true
|
489
|
-
},
|
490
|
+
}, ariaProps, inputProps)), ___EmotionJSX(PopoverContainer, {
|
490
491
|
hasNoArrow: true,
|
491
492
|
isNonModal: true,
|
492
493
|
isOpen: !state.collection.size ? false : isOpen,
|
@@ -21,7 +21,6 @@ import PropTypes from 'prop-types';
|
|
21
21
|
import { v4 as uuid } from 'uuid';
|
22
22
|
import { Box, FieldHelperText, Icon, IconButton, Input, Label } from '../..';
|
23
23
|
import { useField, usePropWarning } from '../../hooks';
|
24
|
-
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
25
24
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
26
25
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
27
26
|
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
@@ -100,7 +99,7 @@ var NumberField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
100
99
|
// extract numeric value in case input value use units like '4 inches' or 'USD 45.00'
|
101
100
|
// aria-valuenow accept only number value type
|
102
101
|
var inputPropsNumericValue = typeof inputPropsValue === 'string' ? inputPropsValue.match(/[-]{0,1}[\d]*[.]{0,1}[\d]+/g)[0] : inputPropsValue;
|
103
|
-
return ___EmotionJSX(Box,
|
102
|
+
return ___EmotionJSX(Box, fieldContainerProps, ___EmotionJSX(Label, updatedLabelProps), ___EmotionJSX(Box, _extends({
|
104
103
|
variant: "forms.numberField.noDefaultArrows"
|
105
104
|
}, groupProps), ___EmotionJSX(Box, _extends({
|
106
105
|
variant: "forms.numberField.arrowsWrapper"
|
@@ -26,13 +26,11 @@ import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
26
26
|
import PropTypes from 'prop-types';
|
27
27
|
import { Box, FieldHelperText, Icon, IconButton, Input, Label, PopoverContainer, RequirementsList } from '../..';
|
28
28
|
import { useDebounce, useField, useProgressiveState, usePropWarning, useStatusClasses } from '../../hooks';
|
29
|
-
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
30
29
|
import statuses from '../../utils/devUtils/constants/statuses';
|
31
30
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
32
31
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
33
32
|
import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
|
34
33
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
35
|
-
var displayName = 'PasswordField';
|
36
34
|
var ARIA_LABELS_FOR_SHOW_PASSWORD_TOGGLE = {
|
37
35
|
HIDE: 'hide password',
|
38
36
|
SHOW: 'show password'
|
@@ -155,7 +153,7 @@ var PasswordField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
155
153
|
};
|
156
154
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Box, _extends({
|
157
155
|
variant: "forms.input.fieldContainer"
|
158
|
-
},
|
156
|
+
}, fieldContainerProps), ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
|
159
157
|
variant: "forms.input.fieldControlWrapper",
|
160
158
|
isRow: true
|
161
159
|
}, fieldControlWrapperProps, {
|
@@ -284,5 +282,5 @@ PasswordField.defaultProps = _objectSpread({
|
|
284
282
|
requirements: [],
|
285
283
|
type: 'password'
|
286
284
|
}, statusDefaultProp);
|
287
|
-
PasswordField.displayName =
|
285
|
+
PasswordField.displayName = 'PasswordField';
|
288
286
|
export default PasswordField;
|
@@ -18,13 +18,11 @@ import { v4 as uuid } from 'uuid';
|
|
18
18
|
import { Box, FieldHelperText, Label } from '../..';
|
19
19
|
import { usePropWarning, useStatusClasses } from '../../hooks';
|
20
20
|
import ORIENTATION from '../../utils/devUtils/constants/orientation';
|
21
|
-
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
22
21
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
23
22
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
24
23
|
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
25
24
|
import { RadioContext } from '../RadioField';
|
26
25
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
|
-
var displayName = 'RadioGroupField';
|
28
26
|
var RadioGroupField = /*#__PURE__*/forwardRef(function (props, ref) {
|
29
27
|
var children = props.children,
|
30
28
|
className = props.className,
|
@@ -53,7 +51,7 @@ var RadioGroupField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
53
51
|
return ___EmotionJSX(Box, _extends({
|
54
52
|
ref: ref,
|
55
53
|
className: classNames
|
56
|
-
},
|
54
|
+
}, unhandledAriaProps, radioGroupProps), ___EmotionJSX(Label, _extends({
|
57
55
|
isDisabled: isDisabled,
|
58
56
|
hintText: hintText,
|
59
57
|
isRequired: isRequired,
|
@@ -104,5 +102,5 @@ RadioGroupField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
|
104
102
|
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
105
103
|
id: PropTypes.string
|
106
104
|
}, statusPropTypes), ariaAttributesBasePropTypes), inputFieldAttributesBasePropTypes);
|
107
|
-
RadioGroupField.displayName =
|
105
|
+
RadioGroupField.displayName = 'RadioGroupField';
|
108
106
|
export default RadioGroupField;
|
@@ -18,11 +18,9 @@ import SearchIcon from '@pingux/mdi-react/SearchIcon';
|
|
18
18
|
import PropTypes from 'prop-types';
|
19
19
|
import { Box, Icon, IconButton, Input, Label } from '../..';
|
20
20
|
import { useField, usePropWarning } from '../../hooks';
|
21
|
-
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
22
21
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
23
22
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
24
23
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
|
-
var displayName = 'SearchField';
|
26
24
|
var SearchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
27
25
|
var autocomplete = props.autocomplete,
|
28
26
|
hasAutoFocus = props.hasAutoFocus,
|
@@ -62,7 +60,7 @@ var SearchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
62
60
|
state.setValue('');
|
63
61
|
}
|
64
62
|
};
|
65
|
-
return ___EmotionJSX(Box,
|
63
|
+
return ___EmotionJSX(Box, fieldContainerProps, label && ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
|
66
64
|
variant: "forms.search.wrapper"
|
67
65
|
}, fieldControlWrapperProps), ___EmotionJSX(Input, _extends({
|
68
66
|
variant: "forms.input.search",
|
@@ -259,5 +257,5 @@ SearchField.defaultProps = {
|
|
259
257
|
hasNoClearButton: false,
|
260
258
|
icon: SearchIcon
|
261
259
|
};
|
262
|
-
SearchField.displayName =
|
260
|
+
SearchField.displayName = 'SearchField';
|
263
261
|
export default SearchField;
|
@@ -19,7 +19,6 @@ import MenuDown from '@pingux/mdi-react/MenuDownIcon';
|
|
19
19
|
import PropTypes from 'prop-types';
|
20
20
|
import { v4 as uuid } from 'uuid';
|
21
21
|
import { modes } from '../../utils/devUtils/constants/labelModes';
|
22
|
-
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
23
22
|
import { ariaAttributesBasePropTypes, getAriaAttributeProps } from '../../utils/docUtils/ariaAttributes';
|
24
23
|
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
25
24
|
import Box from '../Box';
|
@@ -97,7 +96,7 @@ var SelectFieldBase = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
97
96
|
return ___EmotionJSX(Box, _extends({
|
98
97
|
ref: ref,
|
99
98
|
variant: "forms.input.fieldContainer"
|
100
|
-
},
|
99
|
+
}, fieldContainerProps, {
|
101
100
|
sx: _objectSpread(_objectSpread({}, columnStyleProps === null || columnStyleProps === void 0 ? void 0 : columnStyleProps.sx), fieldContainerProps === null || fieldContainerProps === void 0 ? void 0 : fieldContainerProps.sx)
|
102
101
|
}), ___EmotionJSX(Label, fieldLabelProps, label), ___EmotionJSX(HiddenSelect, {
|
103
102
|
state: state,
|