@pingux/astro 2.54.0-alpha.4 → 2.55.0-alpha.0
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 +2 -1
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +2 -3
- package/lib/cjs/components/Button/Button.js +4 -2
- package/lib/cjs/components/CheckboxField/CheckboxField.js +4 -2
- package/lib/cjs/components/ColorField/ColorField.js +4 -2
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +4 -2
- package/lib/cjs/components/DatePicker/DatePicker.js +4 -2
- package/lib/cjs/components/FileInputField/FileInputField.js +4 -2
- package/lib/cjs/components/HelpHint/HelpHint.stories.js +7 -7
- package/lib/cjs/components/IconButton/IconButton.js +4 -2
- package/lib/cjs/components/IconButton/IconButton.styles.d.ts +72 -1
- package/lib/cjs/components/ImageUploadField/ImageUploadField.js +4 -2
- package/lib/cjs/components/Input/Input.js +7 -6
- package/lib/cjs/components/LinkSelectField/LinkSelectField.js +4 -2
- package/lib/cjs/components/ListViewItem/ListViewItem.js +4 -2
- package/lib/cjs/components/Messages/Message.d.ts +9 -0
- package/lib/cjs/components/Messages/Message.js +16 -46
- package/lib/cjs/components/Messages/Message.styles.d.ts +151 -0
- package/lib/cjs/components/Messages/Messages.d.ts +4 -0
- package/lib/cjs/components/Messages/Messages.js +2 -15
- package/lib/cjs/components/Messages/Messages.stories.d.ts +128 -0
- package/lib/cjs/components/Messages/Messages.stories.js +96 -16
- package/lib/cjs/components/Messages/Messages.test.d.ts +1 -0
- package/lib/cjs/components/Messages/Messages.test.js +9 -9
- package/lib/cjs/components/Messages/index.d.ts +3 -0
- package/lib/cjs/components/Messages/index.js +2 -3
- package/lib/cjs/components/Messages/utils/index.d.ts +2 -0
- package/lib/cjs/components/Messages/utils/messagesReducer.d.ts +107 -0
- package/lib/cjs/components/Messages/utils/messagesReducer.js +29 -15
- package/lib/cjs/components/Messages/utils/multiMessagesReducer.d.ts +83 -0
- package/lib/cjs/components/Messages/utils/multiMessagesReducer.js +20 -14
- package/lib/cjs/components/Messages/utils/tests/messagesReducer.test.d.ts +1 -0
- package/lib/cjs/components/Messages/utils/tests/messagesReducer.test.js +4 -3
- package/lib/cjs/components/Messages/utils/tests/multiMessagesReducer.test.d.ts +1 -0
- package/lib/cjs/components/Messages/utils/tests/multiMessagesReducer.test.js +3 -2
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +2 -3
- package/lib/cjs/components/NumberField/NumberField.js +2 -1
- package/lib/cjs/components/PasswordField/PasswordField.js +4 -2
- package/lib/cjs/components/RadioGroupField/RadioGroupField.js +4 -2
- package/lib/cjs/components/SearchField/SearchField.js +4 -2
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +2 -1
- package/lib/cjs/components/SwitchField/SwitchField.js +5 -3
- package/lib/cjs/components/Tab/Tab.js +2 -1
- package/lib/cjs/components/TextAreaField/TextAreaField.js +4 -2
- package/lib/cjs/components/TextField/TextField.js +4 -2
- package/lib/cjs/components/TimeZonePicker/TimeZonePicker.js +2 -1
- package/lib/cjs/recipes/ListAndPanel.stories.js +315 -115
- package/lib/cjs/recipes/PanelContent.stories.js +26 -168
- package/lib/cjs/recipes/items.js +152 -2
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +25 -14
- package/lib/cjs/types/item.d.ts +2 -0
- package/lib/cjs/types/messages.d.ts +43 -0
- package/lib/cjs/types/messages.js +6 -0
- package/lib/cjs/utils/devUtils/constants/pendoID.d.ts +3 -0
- package/lib/cjs/utils/devUtils/constants/pendoID.js +13 -0
- package/lib/components/ArrayField/ArrayField.js +2 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.test.js +2 -3
- package/lib/components/Button/Button.js +4 -2
- package/lib/components/CheckboxField/CheckboxField.js +4 -2
- package/lib/components/ColorField/ColorField.js +4 -2
- package/lib/components/ComboBoxField/ComboBoxField.js +4 -2
- package/lib/components/DatePicker/DatePicker.js +4 -2
- package/lib/components/FileInputField/FileInputField.js +4 -2
- package/lib/components/HelpHint/HelpHint.stories.js +7 -7
- package/lib/components/IconButton/IconButton.js +4 -2
- package/lib/components/ImageUploadField/ImageUploadField.js +4 -2
- package/lib/components/Input/Input.js +6 -5
- package/lib/components/LinkSelectField/LinkSelectField.js +4 -2
- package/lib/components/ListViewItem/ListViewItem.js +4 -2
- package/lib/components/Messages/Message.js +14 -46
- package/lib/components/Messages/Messages.js +2 -15
- package/lib/components/Messages/Messages.stories.js +95 -15
- package/lib/components/Messages/Messages.test.js +9 -9
- package/lib/components/Messages/index.js +1 -1
- package/lib/components/Messages/utils/messagesReducer.js +27 -13
- package/lib/components/Messages/utils/multiMessagesReducer.js +20 -10
- package/lib/components/Messages/utils/tests/messagesReducer.test.js +4 -3
- package/lib/components/Messages/utils/tests/multiMessagesReducer.test.js +9 -8
- package/lib/components/MultivaluesField/MultivaluesField.js +3 -4
- package/lib/components/NumberField/NumberField.js +2 -1
- package/lib/components/PasswordField/PasswordField.js +4 -2
- package/lib/components/RadioGroupField/RadioGroupField.js +4 -2
- package/lib/components/SearchField/SearchField.js +4 -2
- package/lib/components/SelectFieldBase/SelectFieldBase.js +2 -1
- package/lib/components/SwitchField/SwitchField.js +5 -3
- package/lib/components/Tab/Tab.js +2 -1
- package/lib/components/TextAreaField/TextAreaField.js +4 -2
- package/lib/components/TextField/TextField.js +4 -2
- package/lib/components/TimeZonePicker/TimeZonePicker.js +2 -1
- package/lib/recipes/ListAndPanel.stories.js +315 -115
- package/lib/recipes/PanelContent.stories.js +16 -158
- package/lib/recipes/items.js +148 -1
- package/lib/types/index.js +1 -0
- package/lib/types/messages.js +1 -0
- package/lib/utils/devUtils/constants/pendoID.js +5 -0
- package/package.json +1 -1
- package/lib/cjs/components/Messages/Messages.reducer.js +0 -51
- package/lib/components/Messages/Messages.reducer.js +0 -41
@@ -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';
|
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: statuses.SUCCESS
|
64
64
|
}, {
|
65
65
|
key: 'message3',
|
66
66
|
text: loremText,
|
67
|
-
status:
|
67
|
+
status: statuses.WARNING
|
68
68
|
}, {
|
69
69
|
key: 'message4',
|
70
70
|
text: loremText,
|
71
|
-
status:
|
71
|
+
status: statuses.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: statuses.SUCCESS
|
81
81
|
}, loremText));
|
82
82
|
};
|
83
83
|
Default.parameters = {
|
@@ -87,17 +87,25 @@ Default.parameters = {
|
|
87
87
|
}
|
88
88
|
};
|
89
89
|
export var DefaultDynamic = function DefaultDynamic(args) {
|
90
|
-
return (
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
return ___EmotionJSX(Messages, _extends({}, args, {
|
91
|
+
items: messages
|
92
|
+
}), function (item) {
|
93
|
+
return ___EmotionJSX(Item, item, item.text);
|
94
|
+
});
|
95
|
+
};
|
96
|
+
|
97
|
+
// Added to bypass color contrast in safari
|
98
|
+
DefaultDynamic.parameters = {
|
99
|
+
a11y: {
|
100
|
+
config: {
|
101
|
+
rules: [{
|
102
|
+
id: 'color-contrast',
|
103
|
+
enabled: false
|
104
|
+
}]
|
105
|
+
}
|
106
|
+
}
|
98
107
|
};
|
99
108
|
export var Controlled = function Controlled(args) {
|
100
|
-
// messages = [{...}]
|
101
109
|
var _useState = useState([]),
|
102
110
|
_useState2 = _slicedToArray(_useState, 2),
|
103
111
|
items = _useState2[0],
|
@@ -124,6 +132,18 @@ export var Controlled = function Controlled(args) {
|
|
124
132
|
return ___EmotionJSX(Item, item, item.text);
|
125
133
|
});
|
126
134
|
};
|
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
|
+
};
|
127
147
|
export var ControlledWithButton = function ControlledWithButton(args) {
|
128
148
|
var _useState3 = useState([]),
|
129
149
|
_useState4 = _slicedToArray(_useState3, 2),
|
@@ -158,6 +178,18 @@ export var ControlledWithButton = function ControlledWithButton(args) {
|
|
158
178
|
return ___EmotionJSX(Item, item, item.text);
|
159
179
|
}));
|
160
180
|
};
|
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
|
+
};
|
161
193
|
export var WithCustomColorsAndIcons = function WithCustomColorsAndIcons(args) {
|
162
194
|
return ___EmotionJSX(Messages, args, ___EmotionJSX(Item, {
|
163
195
|
bg: "accent.99",
|
@@ -165,6 +197,18 @@ export var WithCustomColorsAndIcons = function WithCustomColorsAndIcons(args) {
|
|
165
197
|
icon: AccountIcon
|
166
198
|
}, loremText));
|
167
199
|
};
|
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
|
+
};
|
168
212
|
export var UseReducer = function UseReducer() {
|
169
213
|
// import { messagesReducer as messagesReducerCore } from '@pingux/astro';
|
170
214
|
// const messagesReducer = messagesReducerCore;
|
@@ -179,7 +223,7 @@ export var UseReducer = function UseReducer() {
|
|
179
223
|
// showWarningMessage: makeShowMessage('warning', -1),
|
180
224
|
// };
|
181
225
|
|
182
|
-
var _useReducer = useReducer(messagesReducer),
|
226
|
+
var _useReducer = useReducer(messagesReducer, []),
|
183
227
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
184
228
|
items = _useReducer2[0],
|
185
229
|
dispatch = _useReducer2[1];
|
@@ -207,6 +251,18 @@ export var UseReducer = function UseReducer() {
|
|
207
251
|
return ___EmotionJSX(Item, item, item.text);
|
208
252
|
}));
|
209
253
|
};
|
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
|
+
};
|
210
266
|
export var UseReducerWithMultipleContainers = function UseReducerWithMultipleContainers() {
|
211
267
|
var _useReducer3 = useReducer(multiMessagesReducer, {
|
212
268
|
'container-one': [],
|
@@ -258,6 +314,18 @@ export var UseReducerWithMultipleContainers = function UseReducerWithMultipleCon
|
|
258
314
|
return ___EmotionJSX(Item, item, item.text);
|
259
315
|
}));
|
260
316
|
};
|
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
|
+
};
|
261
329
|
export var WithTextStyling = function WithTextStyling(args) {
|
262
330
|
var items = [{
|
263
331
|
key: 'message1',
|
@@ -280,4 +348,16 @@ export var WithTextStyling = function WithTextStyling(args) {
|
|
280
348
|
}), function (item) {
|
281
349
|
return ___EmotionJSX(Item, item, item.node || item.text);
|
282
350
|
});
|
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
|
+
}
|
283
363
|
};
|
@@ -6,6 +6,7 @@ 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';
|
9
10
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
10
11
|
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
11
12
|
import { ARIA_STATUSES } from './Message';
|
@@ -27,7 +28,7 @@ var items = [{
|
|
27
28
|
}, {
|
28
29
|
key: 'message2',
|
29
30
|
text: 'Form saved successfully',
|
30
|
-
status:
|
31
|
+
status: statuses.SUCCESS
|
31
32
|
}];
|
32
33
|
var getComponent = function getComponent() {
|
33
34
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -38,7 +39,7 @@ var getComponent = function getComponent() {
|
|
38
39
|
}, "Here is a very neutral thing"), ___EmotionJSX(Item, {
|
39
40
|
key: "message2",
|
40
41
|
"data-id": "message2",
|
41
|
-
status:
|
42
|
+
status: statuses.SUCCESS
|
42
43
|
}, "Form saved successfully")));
|
43
44
|
};
|
44
45
|
var getWithDynamicList = function getWithDynamicList() {
|
@@ -98,16 +99,15 @@ test('`onClose` get as first arg key of message', function () {
|
|
98
99
|
expect(onClose).toHaveBeenCalledWith('message1');
|
99
100
|
});
|
100
101
|
test('click on close button removes message after delay', function () {
|
101
|
-
|
102
|
-
global.setTimeout = jest.fn(function (cb) {
|
103
|
-
return cb();
|
104
|
-
});
|
105
|
-
});
|
102
|
+
jest.useFakeTimers();
|
106
103
|
getComponent();
|
107
104
|
var messages = screen.getByTestId(testId);
|
108
105
|
expect(messages.childElementCount).toBe(2);
|
109
106
|
var buttons = screen.getAllByRole('button');
|
110
107
|
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('Some');
|
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('some', 'container-one');
|
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 './utils';
|
3
3
|
export * from './utils';
|
@@ -13,6 +13,7 @@ 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';
|
16
17
|
|
17
18
|
/**
|
18
19
|
* A set of message util functions.
|
@@ -21,9 +22,14 @@ export var messagesActions = {
|
|
21
22
|
ADD_MESSAGE: 'ADD_MESSAGE',
|
22
23
|
HIDE_MESSAGE: 'HIDE_MESSAGE',
|
23
24
|
REMOVE_MESSAGE: 'REMOVE_MESSAGE',
|
24
|
-
CLEAR_MESSAGES: 'CLEAR_MESSAGES'
|
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'
|
25
32
|
};
|
26
|
-
|
27
33
|
/**
|
28
34
|
* Create an action to add a message
|
29
35
|
* The message object to be added
|
@@ -84,20 +90,25 @@ export var clearMessages = function clearMessages() {
|
|
84
90
|
};
|
85
91
|
};
|
86
92
|
|
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
|
+
|
87
103
|
/** Reducer to store a list of messages */
|
88
|
-
var messagesReducer = function messagesReducer() {
|
104
|
+
var messagesReducer = function messagesReducer(state, action) {
|
89
105
|
var _context;
|
90
|
-
|
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) {
|
106
|
+
switch (action.type) {
|
96
107
|
case messagesActions.ADD_MESSAGE:
|
97
|
-
return _concatInstanceProperty(_context = []).call(_context, state, [_objectSpread({}, message)]);
|
108
|
+
return _concatInstanceProperty(_context = []).call(_context, state, [_objectSpread({}, action.message)]);
|
98
109
|
case messagesActions.HIDE_MESSAGE:
|
99
110
|
return _mapInstanceProperty(state).call(state, function (search) {
|
100
|
-
if (search.key === key) {
|
111
|
+
if (search.key === action.key) {
|
101
112
|
return _objectSpread(_objectSpread({}, search), {}, {
|
102
113
|
isHidden: true
|
103
114
|
});
|
@@ -106,7 +117,7 @@ var messagesReducer = function messagesReducer() {
|
|
106
117
|
});
|
107
118
|
case messagesActions.REMOVE_MESSAGE:
|
108
119
|
return _filterInstanceProperty(state).call(state, function (search) {
|
109
|
-
return key !== search.key;
|
120
|
+
return action.key !== search.key;
|
110
121
|
});
|
111
122
|
case messagesActions.CLEAR_MESSAGES:
|
112
123
|
return [];
|
@@ -119,6 +130,9 @@ messagesReducer.actions = {
|
|
119
130
|
hideMessage: hideMessage,
|
120
131
|
removeMessage: removeMessage,
|
121
132
|
showMessage: showMessage,
|
122
|
-
clearMessages: clearMessages
|
133
|
+
clearMessages: clearMessages,
|
134
|
+
showSuccessMessage: makeShowMessage(statuses.SUCCESS, 3000),
|
135
|
+
showErrorMessage: makeShowMessage(statuses.ERROR, -1),
|
136
|
+
showWarningMessage: makeShowMessage(statuses.WARNING, -1)
|
123
137
|
};
|
124
138
|
export default messagesReducer;
|
@@ -13,7 +13,8 @@ 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
|
16
|
+
import statuses from '../../../utils/devUtils/constants/statuses';
|
17
|
+
import messagesReducer from './messagesReducer';
|
17
18
|
export var withContainer = function withContainer(container, action) {
|
18
19
|
return _objectSpread({
|
19
20
|
container: container
|
@@ -31,22 +32,22 @@ export var createMultiple = function createMultiple(actionCreator) {
|
|
31
32
|
/**
|
32
33
|
* Create an action to add a message
|
33
34
|
*/
|
34
|
-
export var addMessage = createMultiple(
|
35
|
+
export var addMessage = createMultiple(messagesReducer.actions.addMessage);
|
35
36
|
|
36
37
|
/**
|
37
38
|
* Create an action to hide a message by key
|
38
39
|
*/
|
39
|
-
export var hideMessage = createMultiple(
|
40
|
+
export var hideMessage = createMultiple(messagesReducer.actions.hideMessage);
|
40
41
|
|
41
42
|
/**
|
42
43
|
* Create an action to remove a message
|
43
44
|
*/
|
44
|
-
export var removeMessage = createMultiple(
|
45
|
+
export var removeMessage = createMultiple(messagesReducer.actions.removeMessage);
|
45
46
|
|
46
47
|
/**
|
47
48
|
* Create an action to clear all messages
|
48
49
|
*/
|
49
|
-
export var clearMessages = createMultiple(
|
50
|
+
export var clearMessages = createMultiple(messagesReducer.actions.clearMessages);
|
50
51
|
|
51
52
|
/**
|
52
53
|
* Create an action to add a message and then remove it if there's a timeout
|
@@ -69,10 +70,16 @@ export var showMessage = function showMessage(container, messageArg) {
|
|
69
70
|
return message;
|
70
71
|
};
|
71
72
|
};
|
72
|
-
var
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
var makeMultiShowMessage = function makeMultiShowMessage(status, timeout) {
|
74
|
+
return function (container, text) {
|
75
|
+
return multiMessagesReducer.actions.showMessage(container, {
|
76
|
+
text: text,
|
77
|
+
status: status
|
78
|
+
}, timeout);
|
79
|
+
};
|
80
|
+
};
|
81
|
+
var multiMessagesReducer = function multiMessagesReducer(state, _ref) {
|
82
|
+
var container = _ref.container,
|
76
83
|
action = _objectWithoutProperties(_ref, _excluded);
|
77
84
|
return container ? _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, container, messagesReducer(state[container], action))) : state;
|
78
85
|
};
|
@@ -81,6 +88,9 @@ multiMessagesReducer.actions = {
|
|
81
88
|
addMessage: addMessage,
|
82
89
|
hideMessage: hideMessage,
|
83
90
|
clearMessages: clearMessages,
|
84
|
-
showMessage: showMessage
|
91
|
+
showMessage: showMessage,
|
92
|
+
showSuccessMessage: makeMultiShowMessage(statuses.SUCCESS, 3000),
|
93
|
+
showCriticalMessage: makeMultiShowMessage(statuses.ERROR, -1),
|
94
|
+
showWarningMessage: makeMultiShowMessage(statuses.WARNING, -1)
|
85
95
|
};
|
86
96
|
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,11 +67,12 @@ 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;
|
70
71
|
jest.useFakeTimers();
|
71
72
|
getComponent();
|
72
|
-
expect(screen.queryByTestId(testId).children.length).toBe(1);
|
73
|
+
expect((_screen$queryByTestId = screen.queryByTestId(testId)) === null || _screen$queryByTestId === void 0 ? void 0 : _screen$queryByTestId.children.length).toBe(1);
|
73
74
|
act(function () {
|
74
75
|
jest.runAllTimers();
|
75
76
|
});
|
76
|
-
expect(screen.queryByTestId(testId).children.length).toBe(0);
|
77
|
+
expect((_screen$queryByTestId2 = screen.queryByTestId(testId)) === null || _screen$queryByTestId2 === void 0 ? void 0 : _screen$queryByTestId2.children.length).toBe(0);
|
77
78
|
});
|
@@ -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 multiMessagesReducer, { 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(multiMessagesReducer, {
|
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 = multiMessagesReducer({
|
50
50
|
'container-one': messages
|
51
51
|
}, addMessage('container-one', {
|
52
52
|
key: 4,
|
@@ -55,30 +55,31 @@ 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 = multiMessagesReducer({
|
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 = multiMessagesReducer({
|
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 = multiMessagesReducer({
|
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;
|
77
78
|
jest.useFakeTimers();
|
78
79
|
getComponent();
|
79
|
-
expect(screen.queryByTestId(testId).children.length).toBe(1);
|
80
|
+
expect((_screen$queryByTestId = screen.queryByTestId(testId)) === null || _screen$queryByTestId === void 0 ? void 0 : _screen$queryByTestId.children.length).toBe(1);
|
80
81
|
act(function () {
|
81
82
|
jest.runAllTimers();
|
82
83
|
});
|
83
|
-
expect(screen.queryByTestId(testId).children.length).toBe(0);
|
84
|
+
expect((_screen$queryByTestId2 = screen.queryByTestId(testId)) === null || _screen$queryByTestId2 === void 0 ? void 0 : _screen$queryByTestId2.children.length).toBe(0);
|
84
85
|
});
|
@@ -32,8 +32,9 @@ 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';
|
35
36
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
36
|
-
import { ariaAttributesBasePropTypes
|
37
|
+
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
37
38
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
38
39
|
import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
|
39
40
|
import ListBox from '../ListBox';
|
@@ -70,8 +71,6 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
71
|
scrollBoxProps = props.scrollBoxProps,
|
71
72
|
status = props.status,
|
72
73
|
others = _objectWithoutProperties(props, _excluded);
|
73
|
-
var _getAriaAttributeProp = getAriaAttributeProps(others),
|
74
|
-
ariaProps = _getAriaAttributeProp.ariaProps;
|
75
74
|
var hasCustomValue = mode === 'non-restrictive';
|
76
75
|
usePropWarning(props, 'disabled', 'isDisabled');
|
77
76
|
var _useState = useState([]),
|
@@ -487,7 +486,7 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
487
486
|
value: filterString,
|
488
487
|
helperText: helperText,
|
489
488
|
"aria-invalid": status === 'error' && true
|
490
|
-
},
|
489
|
+
}, getPendoID('MultivaluesField'), others, inputProps)), ___EmotionJSX(PopoverContainer, {
|
491
490
|
hasNoArrow: true,
|
492
491
|
isNonModal: true,
|
493
492
|
isOpen: !state.collection.size ? false : isOpen,
|
@@ -21,6 +21,7 @@ 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';
|
24
25
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
25
26
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
26
27
|
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
@@ -99,7 +100,7 @@ var NumberField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
99
100
|
// extract numeric value in case input value use units like '4 inches' or 'USD 45.00'
|
100
101
|
// aria-valuenow accept only number value type
|
101
102
|
var inputPropsNumericValue = typeof inputPropsValue === 'string' ? inputPropsValue.match(/[-]{0,1}[\d]*[.]{0,1}[\d]+/g)[0] : inputPropsValue;
|
102
|
-
return ___EmotionJSX(Box, fieldContainerProps, ___EmotionJSX(Label, updatedLabelProps), ___EmotionJSX(Box, _extends({
|
103
|
+
return ___EmotionJSX(Box, _extends({}, getPendoID('NumberField'), fieldContainerProps), ___EmotionJSX(Label, updatedLabelProps), ___EmotionJSX(Box, _extends({
|
103
104
|
variant: "forms.numberField.noDefaultArrows"
|
104
105
|
}, groupProps), ___EmotionJSX(Box, _extends({
|
105
106
|
variant: "forms.numberField.arrowsWrapper"
|
@@ -26,11 +26,13 @@ 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';
|
29
30
|
import statuses from '../../utils/devUtils/constants/statuses';
|
30
31
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
31
32
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
32
33
|
import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
|
33
34
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
35
|
+
var displayName = 'PasswordField';
|
34
36
|
var ARIA_LABELS_FOR_SHOW_PASSWORD_TOGGLE = {
|
35
37
|
HIDE: 'hide password',
|
36
38
|
SHOW: 'show password'
|
@@ -153,7 +155,7 @@ var PasswordField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
153
155
|
};
|
154
156
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Box, _extends({
|
155
157
|
variant: "forms.input.fieldContainer"
|
156
|
-
}, fieldContainerProps), ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
|
158
|
+
}, getPendoID(displayName), fieldContainerProps), ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
|
157
159
|
variant: "forms.input.fieldControlWrapper",
|
158
160
|
isRow: true
|
159
161
|
}, fieldControlWrapperProps, {
|
@@ -282,5 +284,5 @@ PasswordField.defaultProps = _objectSpread({
|
|
282
284
|
requirements: [],
|
283
285
|
type: 'password'
|
284
286
|
}, statusDefaultProp);
|
285
|
-
PasswordField.displayName =
|
287
|
+
PasswordField.displayName = displayName;
|
286
288
|
export default PasswordField;
|
@@ -18,11 +18,13 @@ 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';
|
21
22
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
22
23
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
23
24
|
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
24
25
|
import { RadioContext } from '../RadioField';
|
25
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
|
+
var displayName = 'RadioGroupField';
|
26
28
|
var RadioGroupField = /*#__PURE__*/forwardRef(function (props, ref) {
|
27
29
|
var children = props.children,
|
28
30
|
className = props.className,
|
@@ -51,7 +53,7 @@ var RadioGroupField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
51
53
|
return ___EmotionJSX(Box, _extends({
|
52
54
|
ref: ref,
|
53
55
|
className: classNames
|
54
|
-
}, unhandledAriaProps, radioGroupProps), ___EmotionJSX(Label, _extends({
|
56
|
+
}, getPendoID(displayName), unhandledAriaProps, radioGroupProps), ___EmotionJSX(Label, _extends({
|
55
57
|
isDisabled: isDisabled,
|
56
58
|
hintText: hintText,
|
57
59
|
isRequired: isRequired,
|
@@ -102,5 +104,5 @@ RadioGroupField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
|
102
104
|
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
103
105
|
id: PropTypes.string
|
104
106
|
}, statusPropTypes), ariaAttributesBasePropTypes), inputFieldAttributesBasePropTypes);
|
105
|
-
RadioGroupField.displayName =
|
107
|
+
RadioGroupField.displayName = displayName;
|
106
108
|
export default RadioGroupField;
|
@@ -18,9 +18,11 @@ 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';
|
21
22
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
22
23
|
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
23
24
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
|
+
var displayName = 'SearchField';
|
24
26
|
var SearchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
25
27
|
var autocomplete = props.autocomplete,
|
26
28
|
hasAutoFocus = props.hasAutoFocus,
|
@@ -60,7 +62,7 @@ var SearchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
60
62
|
state.setValue('');
|
61
63
|
}
|
62
64
|
};
|
63
|
-
return ___EmotionJSX(Box, fieldContainerProps, label && ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
|
65
|
+
return ___EmotionJSX(Box, _extends({}, getPendoID(displayName), fieldContainerProps), label && ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
|
64
66
|
variant: "forms.search.wrapper"
|
65
67
|
}, fieldControlWrapperProps), ___EmotionJSX(Input, _extends({
|
66
68
|
variant: "forms.input.search",
|
@@ -257,5 +259,5 @@ SearchField.defaultProps = {
|
|
257
259
|
hasNoClearButton: false,
|
258
260
|
icon: SearchIcon
|
259
261
|
};
|
260
|
-
SearchField.displayName =
|
262
|
+
SearchField.displayName = displayName;
|
261
263
|
export default SearchField;
|
@@ -19,6 +19,7 @@ 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';
|
22
23
|
import { ariaAttributesBasePropTypes, getAriaAttributeProps } from '../../utils/docUtils/ariaAttributes';
|
23
24
|
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
24
25
|
import Box from '../Box';
|
@@ -96,7 +97,7 @@ var SelectFieldBase = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
96
97
|
return ___EmotionJSX(Box, _extends({
|
97
98
|
ref: ref,
|
98
99
|
variant: "forms.input.fieldContainer"
|
99
|
-
}, fieldContainerProps, {
|
100
|
+
}, getPendoID('SelectField'), fieldContainerProps, {
|
100
101
|
sx: _objectSpread(_objectSpread({}, columnStyleProps === null || columnStyleProps === void 0 ? void 0 : columnStyleProps.sx), fieldContainerProps === null || fieldContainerProps === void 0 ? void 0 : fieldContainerProps.sx)
|
101
102
|
}), ___EmotionJSX(Label, fieldLabelProps, label), ___EmotionJSX(HiddenSelect, {
|
102
103
|
state: state,
|