@pingux/astro 1.2.0-alpha.1 → 1.2.0-alpha.5
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/Button/Button.stories.js +43 -2
- package/lib/cjs/components/Button/Button.test.js +26 -0
- package/lib/cjs/components/CopyText/CopyButton.js +9 -2
- package/lib/cjs/components/Messages/Messages.reducer.js +2 -1
- package/lib/cjs/components/Messages/Messages.stories.js +10 -10
- package/lib/cjs/components/Messages/Messages.test.js +15 -1
- package/lib/cjs/components/Messages/index.js +21 -2
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +3 -1
- package/lib/cjs/components/TextField/TextField.stories.js +79 -2
- package/lib/cjs/styles/variants/buttons.js +55 -2
- package/lib/cjs/styles/variants/text.js +14 -0
- package/lib/components/Button/Button.stories.js +36 -0
- package/lib/components/Button/Button.test.js +20 -0
- package/lib/components/CopyText/CopyButton.js +7 -2
- package/lib/components/Messages/Messages.reducer.js +1 -1
- package/lib/components/Messages/Messages.stories.js +1 -1
- package/lib/components/Messages/Messages.test.js +11 -1
- package/lib/components/Messages/index.js +2 -1
- package/lib/components/MultivaluesField/MultivaluesField.js +3 -1
- package/lib/components/TextField/TextField.stories.js +72 -0
- package/lib/styles/variants/buttons.js +55 -2
- package/lib/styles/variants/text.js +14 -0
- package/package.json +1 -1
@@ -8,12 +8,18 @@ _Object$defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
9
9
|
});
|
10
10
|
|
11
|
-
exports.InlineButton = exports.TextButton = exports.TextIconButton = exports.Disabled = exports.Default = exports["default"] = void 0;
|
11
|
+
exports.ColorBlockButton = exports.InlineButton = exports.TextButton = exports.TextIconButton = exports.Disabled = exports.Default = exports["default"] = void 0;
|
12
|
+
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
14
|
+
|
15
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
12
16
|
|
13
17
|
var _react = _interopRequireDefault(require("react"));
|
14
18
|
|
15
19
|
var _AddCircleIcon = _interopRequireDefault(require("mdi-react/AddCircleIcon"));
|
16
20
|
|
21
|
+
var _CreateIcon = _interopRequireDefault(require("mdi-react/CreateIcon"));
|
22
|
+
|
17
23
|
var _Box = _interopRequireDefault(require("../Box"));
|
18
24
|
|
19
25
|
var _ = _interopRequireDefault(require("."));
|
@@ -56,6 +62,13 @@ var _default = {
|
|
56
62
|
type: 'text'
|
57
63
|
}
|
58
64
|
}
|
65
|
+
},
|
66
|
+
parameters: {
|
67
|
+
docs: {
|
68
|
+
source: {
|
69
|
+
type: 'code'
|
70
|
+
}
|
71
|
+
}
|
59
72
|
}
|
60
73
|
};
|
61
74
|
exports["default"] = _default;
|
@@ -110,4 +123,32 @@ var InlineButton = function InlineButton() {
|
|
110
123
|
}, "Inline");
|
111
124
|
};
|
112
125
|
|
113
|
-
exports.InlineButton = InlineButton;
|
126
|
+
exports.InlineButton = InlineButton;
|
127
|
+
|
128
|
+
var ColorBlockButton = function ColorBlockButton(args) {
|
129
|
+
// Change `isConfigured` property in storybook controls
|
130
|
+
var isConfigured = args.isConfigured,
|
131
|
+
props = (0, _objectWithoutProperties2["default"])(args, ["isConfigured"]);
|
132
|
+
return (0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, props, {
|
133
|
+
variant: "colorBlock",
|
134
|
+
className: isConfigured ? 'is-configured' : ''
|
135
|
+
}), (0, _react2.jsx)(_Box["default"], null, (0, _react2.jsx)(_Text["default"], {
|
136
|
+
variant: "buttonTitle"
|
137
|
+
}, "Title"), (0, _react2.jsx)(_Text["default"], {
|
138
|
+
variant: "buttonSubtitle"
|
139
|
+
}, "Info")), (0, _react2.jsx)(_Icon["default"], {
|
140
|
+
icon: _CreateIcon["default"]
|
141
|
+
}));
|
142
|
+
};
|
143
|
+
|
144
|
+
exports.ColorBlockButton = ColorBlockButton;
|
145
|
+
ColorBlockButton.story = {
|
146
|
+
argTypes: {
|
147
|
+
isConfigured: {
|
148
|
+
control: {
|
149
|
+
type: 'boolean'
|
150
|
+
},
|
151
|
+
defaultValue: false
|
152
|
+
}
|
153
|
+
}
|
154
|
+
};
|
@@ -122,4 +122,30 @@ test('button renders children when not loading', function () {
|
|
122
122
|
expect(childWrapper).toBeInTheDocument();
|
123
123
|
expect(childWrapper).toBeVisible();
|
124
124
|
expect(_testWrapper.screen.queryByRole('progressbar')).not.toBeInTheDocument();
|
125
|
+
});
|
126
|
+
test('color block button renders in default state', function () {
|
127
|
+
getComponent({
|
128
|
+
variant: 'colorBlock'
|
129
|
+
});
|
130
|
+
|
131
|
+
var button = _testWrapper.screen.getByRole('button');
|
132
|
+
|
133
|
+
expect(button).toBeInTheDocument();
|
134
|
+
expect(button).not.toHaveClass('is-configured');
|
135
|
+
|
136
|
+
_userEvent["default"].tab();
|
137
|
+
|
138
|
+
expect(button).toHaveClass('is-focused');
|
139
|
+
expect(button).toHaveFocus();
|
140
|
+
});
|
141
|
+
test('color block button renders in configured state', function () {
|
142
|
+
getComponent({
|
143
|
+
variant: 'colorBlock',
|
144
|
+
className: 'is-configured'
|
145
|
+
});
|
146
|
+
|
147
|
+
var button = _testWrapper.screen.getByRole('button');
|
148
|
+
|
149
|
+
expect(button).toBeInTheDocument();
|
150
|
+
expect(button).toHaveClass('is-configured');
|
125
151
|
});
|
@@ -18,6 +18,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
18
18
|
|
19
19
|
var _ContentCopyIcon = _interopRequireDefault(require("mdi-react/ContentCopyIcon"));
|
20
20
|
|
21
|
+
var _lodash = require("lodash");
|
22
|
+
|
23
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
24
|
+
|
21
25
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
22
26
|
|
23
27
|
var _IconButton = _interopRequireDefault(require("../IconButton"));
|
@@ -29,10 +33,13 @@ var CopyButton = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
29
33
|
ref: ref,
|
30
34
|
"aria-label": "copy",
|
31
35
|
variant: "buttons.copy"
|
32
|
-
}, props), (0, _react2.jsx)(_Icon["default"], {
|
36
|
+
}, (0, _lodash.omit)(props, 'iconProps')), (0, _react2.jsx)(_Icon["default"], (0, _extends2["default"])({
|
33
37
|
icon: _ContentCopyIcon["default"],
|
34
38
|
size: 15
|
35
|
-
}));
|
39
|
+
}, props === null || props === void 0 ? void 0 : props.iconProps)));
|
36
40
|
});
|
41
|
+
CopyButton.propTypes = {
|
42
|
+
iconProps: _propTypes["default"].shape({})
|
43
|
+
};
|
37
44
|
var _default = CopyButton;
|
38
45
|
exports["default"] = _default;
|
@@ -8,7 +8,7 @@ _Object$defineProperty2(exports, "__esModule", {
|
|
8
8
|
value: true
|
9
9
|
});
|
10
10
|
|
11
|
-
exports["default"] = exports.multiMessagesReducer = void 0;
|
11
|
+
exports["default"] = exports.multiMessagesReducer = exports.messagesReducer = void 0;
|
12
12
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
14
14
|
|
@@ -35,6 +35,7 @@ function ownKeys(object, enumerableOnly) { var keys = (0, _keys["default"])(obje
|
|
35
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; (0, _forEach["default"])(_context = ownKeys(Object(source), true)).call(_context, function (key) { (0, _defineProperty3["default"])(target, key, source[key]); }); } else if (_getOwnPropertyDescriptors["default"]) { (0, _defineProperties["default"])(target, (0, _getOwnPropertyDescriptors["default"])(source)); } else { var _context2; (0, _forEach["default"])(_context2 = ownKeys(Object(source))).call(_context2, function (key) { (0, _defineProperty2["default"])(target, key, (0, _getOwnPropertyDescriptor["default"])(source, key)); }); } } return target; }
|
36
36
|
|
37
37
|
var messagesReducer = _utils.messagesReducer;
|
38
|
+
exports.messagesReducer = messagesReducer;
|
38
39
|
var multiMessagesReducer = _utils.multiMessagesReducer;
|
39
40
|
exports.multiMessagesReducer = multiMessagesReducer;
|
40
41
|
|
@@ -52,7 +52,7 @@ var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/s
|
|
52
52
|
|
53
53
|
var _ = require("../..");
|
54
54
|
|
55
|
-
var
|
55
|
+
var _index = require("./index");
|
56
56
|
|
57
57
|
var _react2 = require("@emotion/react");
|
58
58
|
|
@@ -233,21 +233,21 @@ var UseReducer = function UseReducer() {
|
|
233
233
|
// showErrorMessage: makeShowMessage('error', -1),
|
234
234
|
// showWarningMessage: makeShowMessage('warning', -1),
|
235
235
|
// };
|
236
|
-
var _useReducer = (0, _react.useReducer)(
|
236
|
+
var _useReducer = (0, _react.useReducer)(_index.messagesReducerStory),
|
237
237
|
_useReducer2 = (0, _slicedToArray2["default"])(_useReducer, 2),
|
238
238
|
items = _useReducer2[0],
|
239
239
|
dispatch = _useReducer2[1];
|
240
240
|
|
241
241
|
var showAMessage = function showAMessage() {
|
242
|
-
var actionFn = [
|
242
|
+
var actionFn = [_index.messagesReducerStory.actions.showSuccessMessage, _index.messagesReducerStory.actions.showErrorMessage, _index.messagesReducerStory.actions.showWarningMessage][Math.floor(Math.random() * 3)];
|
243
243
|
var message = messageText[Math.floor(Math.random() * 6)];
|
244
244
|
actionFn(message)(dispatch);
|
245
245
|
};
|
246
246
|
|
247
247
|
var removeMessage = function removeMessage(key) {
|
248
|
-
dispatch(
|
248
|
+
dispatch(_index.messagesReducerStory.actions.hideMessage(key));
|
249
249
|
(0, _setTimeout2["default"])(function () {
|
250
|
-
return dispatch(
|
250
|
+
return dispatch(_index.messagesReducerStory.actions.removeMessage(key));
|
251
251
|
}, 200);
|
252
252
|
};
|
253
253
|
|
@@ -256,7 +256,7 @@ var UseReducer = function UseReducer() {
|
|
256
256
|
}, "Add Message"), (items === null || items === void 0 ? void 0 : items.length) > 0 && (0, _react2.jsx)(_.Button, {
|
257
257
|
mt: "md",
|
258
258
|
onPress: function onPress() {
|
259
|
-
return dispatch(
|
259
|
+
return dispatch(_index.messagesReducerStory.actions.clearMessages());
|
260
260
|
}
|
261
261
|
}, "Clear messages"), (0, _react2.jsx)(_.Messages, {
|
262
262
|
items: items,
|
@@ -269,7 +269,7 @@ var UseReducer = function UseReducer() {
|
|
269
269
|
exports.UseReducer = UseReducer;
|
270
270
|
|
271
271
|
var UseReducerWithMultipleContainers = function UseReducerWithMultipleContainers() {
|
272
|
-
var _useReducer3 = (0, _react.useReducer)(
|
272
|
+
var _useReducer3 = (0, _react.useReducer)(_index.multiMessagesReducerStory, {
|
273
273
|
'container-one': [],
|
274
274
|
'container-two': []
|
275
275
|
}),
|
@@ -278,15 +278,15 @@ var UseReducerWithMultipleContainers = function UseReducerWithMultipleContainers
|
|
278
278
|
dispatch = _useReducer4[1];
|
279
279
|
|
280
280
|
var showAMessage = function showAMessage(container) {
|
281
|
-
var actionFn = [
|
281
|
+
var actionFn = [_index.multiMessagesReducerStory.actions.showSuccessMessage, _index.multiMessagesReducerStory.actions.showCriticalMessage, _index.multiMessagesReducerStory.actions.showWarningMessage][Math.floor(Math.random() * 3)];
|
282
282
|
var message = messageText[Math.floor(Math.random() * 6)];
|
283
283
|
actionFn(container, message)(dispatch);
|
284
284
|
};
|
285
285
|
|
286
286
|
var removeMessage = function removeMessage(key, container) {
|
287
|
-
dispatch(
|
287
|
+
dispatch(_index.multiMessagesReducerStory.actions.hideMessage(container, key));
|
288
288
|
(0, _setTimeout2["default"])(function () {
|
289
|
-
return dispatch(
|
289
|
+
return dispatch(_index.multiMessagesReducerStory.actions.removeMessage(container, key));
|
290
290
|
}, 200);
|
291
291
|
};
|
292
292
|
|
@@ -26,7 +26,7 @@ var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
|
|
26
26
|
|
27
27
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
28
28
|
|
29
|
-
var _ =
|
29
|
+
var _ = _interopRequireWildcard(require("."));
|
30
30
|
|
31
31
|
var _Button = _interopRequireDefault(require("../Button"));
|
32
32
|
|
@@ -211,4 +211,18 @@ describe('announcements', function () {
|
|
211
211
|
expect(messages.childElementCount).toBe(1);
|
212
212
|
expect(_liveAnnouncer.announce).toHaveBeenCalledWith('New message 1', 'polite');
|
213
213
|
});
|
214
|
+
});
|
215
|
+
test('should render messages with messagesReducerStory', function () {
|
216
|
+
getComponent();
|
217
|
+
|
218
|
+
_.messagesReducerStory.actions.showSuccessMessage();
|
219
|
+
|
220
|
+
expect(_testWrapper.screen.getByTestId(testId)).toBeInTheDocument();
|
221
|
+
});
|
222
|
+
test('should render messages with multiMessagesReducerStory', function () {
|
223
|
+
getComponent();
|
224
|
+
|
225
|
+
_.multiMessagesReducerStory.actions.showSuccessMessage();
|
226
|
+
|
227
|
+
expect(_testWrapper.screen.getByTestId(testId)).toBeInTheDocument();
|
214
228
|
});
|
@@ -14,7 +14,10 @@ _Object$defineProperty(exports, "__esModule", {
|
|
14
14
|
value: true
|
15
15
|
});
|
16
16
|
|
17
|
-
var _exportNames = {
|
17
|
+
var _exportNames = {
|
18
|
+
messagesReducerStory: true,
|
19
|
+
multiMessagesReducerStory: true
|
20
|
+
};
|
18
21
|
|
19
22
|
_Object$defineProperty(exports, "default", {
|
20
23
|
enumerable: true,
|
@@ -23,6 +26,20 @@ _Object$defineProperty(exports, "default", {
|
|
23
26
|
}
|
24
27
|
});
|
25
28
|
|
29
|
+
_Object$defineProperty(exports, "messagesReducerStory", {
|
30
|
+
enumerable: true,
|
31
|
+
get: function get() {
|
32
|
+
return _Messages2.messagesReducer;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
_Object$defineProperty(exports, "multiMessagesReducerStory", {
|
37
|
+
enumerable: true,
|
38
|
+
get: function get() {
|
39
|
+
return _Messages2.multiMessagesReducer;
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
26
43
|
var _Messages = _interopRequireDefault(require("./Messages"));
|
27
44
|
|
28
45
|
var _utils = require("./utils");
|
@@ -37,4 +54,6 @@ _forEachInstanceProperty(_context = _Object$keys(_utils)).call(_context, functio
|
|
37
54
|
return _utils[key];
|
38
55
|
}
|
39
56
|
});
|
40
|
-
});
|
57
|
+
});
|
58
|
+
|
59
|
+
var _Messages2 = require("./Messages.reducer");
|
@@ -10,7 +10,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
10
10
|
value: true
|
11
11
|
});
|
12
12
|
|
13
|
-
exports.MaxLength = exports.WithoutStatusIndicator = exports.WithHelpHint = exports.Warning = exports.Success = exports.Error = exports.DynamicRequired = exports.Required = exports.ReadOnly = exports.Disabled = exports.Password = exports.Controlled = exports.LeftLabel = exports.FloatLabel = exports.SmallVariant = exports.Default = exports["default"] = void 0;
|
13
|
+
exports.WithSlots = exports.MaxLength = exports.WithoutStatusIndicator = exports.WithHelpHint = exports.Warning = exports.Success = exports.Error = exports.DynamicRequired = exports.Required = exports.ReadOnly = exports.Disabled = exports.Password = exports.Controlled = exports.LeftLabel = exports.FloatLabel = exports.SmallVariant = exports.Default = exports["default"] = void 0;
|
14
14
|
|
15
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
16
16
|
|
@@ -32,6 +32,10 @@ var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/s
|
|
32
32
|
|
33
33
|
var _Box = _interopRequireDefault(require("../Box"));
|
34
34
|
|
35
|
+
var _useCopyToClipboard = _interopRequireDefault(require("../../hooks/useCopyToClipboard"));
|
36
|
+
|
37
|
+
var _CopyButton = _interopRequireDefault(require("../CopyText/CopyButton"));
|
38
|
+
|
35
39
|
var _react2 = require("@emotion/react");
|
36
40
|
|
37
41
|
var _default = {
|
@@ -259,4 +263,77 @@ var MaxLength = function MaxLength() {
|
|
259
263
|
});
|
260
264
|
};
|
261
265
|
|
262
|
-
exports.MaxLength = MaxLength;
|
266
|
+
exports.MaxLength = MaxLength;
|
267
|
+
|
268
|
+
var WithSlots = function WithSlots() {
|
269
|
+
var _useState5 = (0, _react.useState)("[{ 'type': 'work', 'streetAddress': 'San Antonio MI 47096' },{ 'type': 'home', 'streetAddress': 'Santa Rosa MN 98804' }]"),
|
270
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
271
|
+
addressesValue = _useState6[0],
|
272
|
+
setAddressesValue = _useState6[1];
|
273
|
+
|
274
|
+
var _useState7 = (0, _react.useState)("[{ 'status': 'inactive', 'subject': 'example@pingidentity.com' },{ 'status': 'active', 'subject': 'john@pingidentity.com' }]"),
|
275
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
276
|
+
jsonValue = _useState8[0],
|
277
|
+
setJsonValue = _useState8[1];
|
278
|
+
|
279
|
+
var copyAddressesToClipboard = (0, _useCopyToClipboard["default"])(addressesValue);
|
280
|
+
var copyJsonToClipboard = (0, _useCopyToClipboard["default"])(jsonValue);
|
281
|
+
var buttonSx = {
|
282
|
+
position: 'absolute',
|
283
|
+
right: 0,
|
284
|
+
top: '5px'
|
285
|
+
};
|
286
|
+
var containerSx = {
|
287
|
+
sx: {
|
288
|
+
'& input': {
|
289
|
+
paddingRight: '40px'
|
290
|
+
}
|
291
|
+
}
|
292
|
+
};
|
293
|
+
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_["default"], {
|
294
|
+
label: "Multiple Addresses",
|
295
|
+
labelMode: "float",
|
296
|
+
onChange: function onChange(e) {
|
297
|
+
return setAddressesValue(e.target.value);
|
298
|
+
},
|
299
|
+
value: addressesValue,
|
300
|
+
containerProps: containerSx,
|
301
|
+
slots: {
|
302
|
+
inContainer: (0, _react2.jsx)(_CopyButton["default"], {
|
303
|
+
onPress: copyAddressesToClipboard,
|
304
|
+
sx: buttonSx,
|
305
|
+
iconProps: {
|
306
|
+
sx: {
|
307
|
+
path: {
|
308
|
+
fill: 'active'
|
309
|
+
}
|
310
|
+
}
|
311
|
+
}
|
312
|
+
})
|
313
|
+
},
|
314
|
+
mb: 30
|
315
|
+
}), (0, _react2.jsx)(_["default"], {
|
316
|
+
label: "Example JSON",
|
317
|
+
labelMode: "float",
|
318
|
+
onChange: function onChange(e) {
|
319
|
+
return setJsonValue(e.target.value);
|
320
|
+
},
|
321
|
+
value: jsonValue,
|
322
|
+
containerProps: containerSx,
|
323
|
+
slots: {
|
324
|
+
inContainer: (0, _react2.jsx)(_CopyButton["default"], {
|
325
|
+
onPress: copyJsonToClipboard,
|
326
|
+
sx: buttonSx,
|
327
|
+
iconProps: {
|
328
|
+
sx: {
|
329
|
+
path: {
|
330
|
+
fill: 'active'
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
})
|
335
|
+
}
|
336
|
+
}));
|
337
|
+
};
|
338
|
+
|
339
|
+
exports.WithSlots = WithSlots;
|
@@ -376,7 +376,7 @@ var chipDeleteButton = {
|
|
376
376
|
borderRadius: '50%',
|
377
377
|
cursor: 'pointer',
|
378
378
|
height: 14,
|
379
|
-
|
379
|
+
mx: '3px !important',
|
380
380
|
p: 0,
|
381
381
|
width: 14,
|
382
382
|
'&.is-focused, &.is-hovered': {
|
@@ -556,6 +556,58 @@ var tooltipInline = _objectSpread(_objectSpread({}, text), {}, {
|
|
556
556
|
}
|
557
557
|
});
|
558
558
|
|
559
|
+
var colorBlock = {
|
560
|
+
bg: 'neutral.95',
|
561
|
+
border: '1px solid',
|
562
|
+
borderColor: 'neutral.90',
|
563
|
+
borderRadius: 10,
|
564
|
+
outline: 'none',
|
565
|
+
cursor: 'pointer',
|
566
|
+
width: 150,
|
567
|
+
minHeight: 40,
|
568
|
+
p: '5px 15px',
|
569
|
+
display: 'flex',
|
570
|
+
justifyContent: 'space-between',
|
571
|
+
alignItems: 'center',
|
572
|
+
'&.is-hovered': {
|
573
|
+
bg: 'neutral.80'
|
574
|
+
},
|
575
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
576
|
+
'&.is-pressed': {
|
577
|
+
bg: 'neutral.60',
|
578
|
+
borderColor: 'neutral.60'
|
579
|
+
},
|
580
|
+
'& span': {
|
581
|
+
color: 'text.primary',
|
582
|
+
textAlign: 'left'
|
583
|
+
},
|
584
|
+
'&>div': {
|
585
|
+
alignItems: 'baseline'
|
586
|
+
},
|
587
|
+
'&>svg': {
|
588
|
+
color: 'text.secondary',
|
589
|
+
fill: 'text.secondary'
|
590
|
+
},
|
591
|
+
'&.is-configured': {
|
592
|
+
bg: 'active',
|
593
|
+
borderColor: 'active',
|
594
|
+
'& span': {
|
595
|
+
color: 'white'
|
596
|
+
},
|
597
|
+
'&>svg': {
|
598
|
+
color: 'white',
|
599
|
+
fill: 'white'
|
600
|
+
}
|
601
|
+
},
|
602
|
+
'&.is-configured.is-hovered': {
|
603
|
+
bg: 'accent.40',
|
604
|
+
borderColor: 'accent.40'
|
605
|
+
},
|
606
|
+
'&.is-configured.is-pressed': {
|
607
|
+
bg: 'accent.20',
|
608
|
+
borderColor: 'accent.20'
|
609
|
+
}
|
610
|
+
};
|
559
611
|
var _default = {
|
560
612
|
accordionHeader: accordionHeader,
|
561
613
|
chipDeleteButton: chipDeleteButton,
|
@@ -595,6 +647,7 @@ var _default = {
|
|
595
647
|
invertedSquare: invertedSquare,
|
596
648
|
tooltipChip: tooltipChip,
|
597
649
|
tooltipIconButton: tooltipIconButton,
|
598
|
-
tooltipInline: tooltipInline
|
650
|
+
tooltipInline: tooltipInline,
|
651
|
+
colorBlock: colorBlock
|
599
652
|
};
|
600
653
|
exports["default"] = _default;
|
@@ -178,6 +178,20 @@ var text = {
|
|
178
178
|
color: 'accent.30',
|
179
179
|
fontFamily: 'standard'
|
180
180
|
}),
|
181
|
+
buttonTitle: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
182
|
+
fontSize: 'xs',
|
183
|
+
fontWeight: 0,
|
184
|
+
color: 'text.primary',
|
185
|
+
fontFamily: 'standard',
|
186
|
+
lineHeight: '13px'
|
187
|
+
}),
|
188
|
+
buttonSubtitle: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
189
|
+
fontSize: 'sm',
|
190
|
+
fontWeight: 3,
|
191
|
+
color: 'text.primary',
|
192
|
+
fontFamily: 'standard',
|
193
|
+
lineHeight: '16px'
|
194
|
+
}),
|
181
195
|
capsLabel: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
182
196
|
color: 'text.secondary',
|
183
197
|
textTransform: 'uppercase',
|
@@ -1,5 +1,8 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
1
3
|
import React from 'react';
|
2
4
|
import AddCircleIcon from 'mdi-react/AddCircleIcon';
|
5
|
+
import CreateIcon from 'mdi-react/CreateIcon';
|
3
6
|
import Box from '../Box';
|
4
7
|
import Button from '.';
|
5
8
|
import Icon from '../Icon';
|
@@ -36,6 +39,13 @@ export default {
|
|
36
39
|
type: 'text'
|
37
40
|
}
|
38
41
|
}
|
42
|
+
},
|
43
|
+
parameters: {
|
44
|
+
docs: {
|
45
|
+
source: {
|
46
|
+
type: 'code'
|
47
|
+
}
|
48
|
+
}
|
39
49
|
}
|
40
50
|
};
|
41
51
|
export var Default = function Default(args) {
|
@@ -74,4 +84,30 @@ export var InlineButton = function InlineButton() {
|
|
74
84
|
mb: "sm",
|
75
85
|
variant: "inline"
|
76
86
|
}, "Inline");
|
87
|
+
};
|
88
|
+
export var ColorBlockButton = function ColorBlockButton(args) {
|
89
|
+
// Change `isConfigured` property in storybook controls
|
90
|
+
var isConfigured = args.isConfigured,
|
91
|
+
props = _objectWithoutProperties(args, ["isConfigured"]);
|
92
|
+
|
93
|
+
return ___EmotionJSX(Button, _extends({}, props, {
|
94
|
+
variant: "colorBlock",
|
95
|
+
className: isConfigured ? 'is-configured' : ''
|
96
|
+
}), ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
|
97
|
+
variant: "buttonTitle"
|
98
|
+
}, "Title"), ___EmotionJSX(Text, {
|
99
|
+
variant: "buttonSubtitle"
|
100
|
+
}, "Info")), ___EmotionJSX(Icon, {
|
101
|
+
icon: CreateIcon
|
102
|
+
}));
|
103
|
+
};
|
104
|
+
ColorBlockButton.story = {
|
105
|
+
argTypes: {
|
106
|
+
isConfigured: {
|
107
|
+
control: {
|
108
|
+
type: 'boolean'
|
109
|
+
},
|
110
|
+
defaultValue: false
|
111
|
+
}
|
112
|
+
}
|
77
113
|
};
|
@@ -89,4 +89,24 @@ test('button renders children when not loading', function () {
|
|
89
89
|
expect(childWrapper).toBeInTheDocument();
|
90
90
|
expect(childWrapper).toBeVisible();
|
91
91
|
expect(screen.queryByRole('progressbar')).not.toBeInTheDocument();
|
92
|
+
});
|
93
|
+
test('color block button renders in default state', function () {
|
94
|
+
getComponent({
|
95
|
+
variant: 'colorBlock'
|
96
|
+
});
|
97
|
+
var button = screen.getByRole('button');
|
98
|
+
expect(button).toBeInTheDocument();
|
99
|
+
expect(button).not.toHaveClass('is-configured');
|
100
|
+
userEvent.tab();
|
101
|
+
expect(button).toHaveClass('is-focused');
|
102
|
+
expect(button).toHaveFocus();
|
103
|
+
});
|
104
|
+
test('color block button renders in configured state', function () {
|
105
|
+
getComponent({
|
106
|
+
variant: 'colorBlock',
|
107
|
+
className: 'is-configured'
|
108
|
+
});
|
109
|
+
var button = screen.getByRole('button');
|
110
|
+
expect(button).toBeInTheDocument();
|
111
|
+
expect(button).toHaveClass('is-configured');
|
92
112
|
});
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React, { forwardRef } from 'react';
|
3
3
|
import ContentCopy from 'mdi-react/ContentCopyIcon';
|
4
|
+
import { omit } from 'lodash';
|
5
|
+
import PropTypes from 'prop-types';
|
4
6
|
import Icon from '../Icon';
|
5
7
|
import IconButton from '../IconButton';
|
6
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -9,9 +11,12 @@ var CopyButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
9
11
|
ref: ref,
|
10
12
|
"aria-label": "copy",
|
11
13
|
variant: "buttons.copy"
|
12
|
-
}, props), ___EmotionJSX(Icon, {
|
14
|
+
}, omit(props, 'iconProps')), ___EmotionJSX(Icon, _extends({
|
13
15
|
icon: ContentCopy,
|
14
16
|
size: 15
|
15
|
-
}));
|
17
|
+
}, props === null || props === void 0 ? void 0 : props.iconProps)));
|
16
18
|
});
|
19
|
+
CopyButton.propTypes = {
|
20
|
+
iconProps: PropTypes.shape({})
|
21
|
+
};
|
17
22
|
export default CopyButton;
|
@@ -13,7 +13,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
13
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
14
14
|
|
15
15
|
import { messagesReducer as messagesReducerCore, multiMessagesReducer as multiMessagesReducerCore } from './utils';
|
16
|
-
var messagesReducer = messagesReducerCore;
|
16
|
+
export var messagesReducer = messagesReducerCore;
|
17
17
|
export var multiMessagesReducer = multiMessagesReducerCore;
|
18
18
|
|
19
19
|
var makeShowMessage = function makeShowMessage(status, timeout) {
|
@@ -23,7 +23,7 @@ import { Item } from '@react-stately/collections';
|
|
23
23
|
import AccountIcon from 'mdi-react/AccountIcon';
|
24
24
|
import statuses from '../../utils/devUtils/constants/statuses';
|
25
25
|
import { Box, Button, Messages } from '../..';
|
26
|
-
import messagesReducer,
|
26
|
+
import { messagesReducerStory as messagesReducer, multiMessagesReducerStory as multiMessagesReducer } from './index';
|
27
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
28
28
|
export default {
|
29
29
|
title: 'Messages',
|
@@ -9,7 +9,7 @@ import { Item } from '@react-stately/collections';
|
|
9
9
|
import userEvent from '@testing-library/user-event';
|
10
10
|
import axeTest from '../../utils/testUtils/testAxe';
|
11
11
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
12
|
-
import Messages from '.';
|
12
|
+
import Messages, { messagesReducerStory, multiMessagesReducerStory } from '.';
|
13
13
|
import Button from '../Button';
|
14
14
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
15
|
jest.mock('@react-aria/live-announcer');
|
@@ -173,4 +173,14 @@ describe('announcements', function () {
|
|
173
173
|
expect(messages.childElementCount).toBe(1);
|
174
174
|
expect(announce).toHaveBeenCalledWith('New message 1', 'polite');
|
175
175
|
});
|
176
|
+
});
|
177
|
+
test('should render messages with messagesReducerStory', function () {
|
178
|
+
getComponent();
|
179
|
+
messagesReducerStory.actions.showSuccessMessage();
|
180
|
+
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
181
|
+
});
|
182
|
+
test('should render messages with multiMessagesReducerStory', function () {
|
183
|
+
getComponent();
|
184
|
+
multiMessagesReducerStory.actions.showSuccessMessage();
|
185
|
+
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
176
186
|
});
|
@@ -8,6 +8,8 @@ import TextField from '.';
|
|
8
8
|
import { modes as labelModes } from '../Label/constants';
|
9
9
|
import statuses from '../../utils/devUtils/constants/statuses.js';
|
10
10
|
import Box from '../Box';
|
11
|
+
import useCopyToClipboard from '../../hooks/useCopyToClipboard';
|
12
|
+
import CopyButton from '../CopyText/CopyButton';
|
11
13
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
14
|
export default {
|
13
15
|
title: 'Form/TextField',
|
@@ -186,4 +188,74 @@ export var MaxLength = function MaxLength() {
|
|
186
188
|
label: "Example label",
|
187
189
|
maxLength: 9
|
188
190
|
});
|
191
|
+
};
|
192
|
+
export var WithSlots = function WithSlots() {
|
193
|
+
var _useState5 = useState("[{ 'type': 'work', 'streetAddress': 'San Antonio MI 47096' },{ 'type': 'home', 'streetAddress': 'Santa Rosa MN 98804' }]"),
|
194
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
195
|
+
addressesValue = _useState6[0],
|
196
|
+
setAddressesValue = _useState6[1];
|
197
|
+
|
198
|
+
var _useState7 = useState("[{ 'status': 'inactive', 'subject': 'example@pingidentity.com' },{ 'status': 'active', 'subject': 'john@pingidentity.com' }]"),
|
199
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
200
|
+
jsonValue = _useState8[0],
|
201
|
+
setJsonValue = _useState8[1];
|
202
|
+
|
203
|
+
var copyAddressesToClipboard = useCopyToClipboard(addressesValue);
|
204
|
+
var copyJsonToClipboard = useCopyToClipboard(jsonValue);
|
205
|
+
var buttonSx = {
|
206
|
+
position: 'absolute',
|
207
|
+
right: 0,
|
208
|
+
top: '5px'
|
209
|
+
};
|
210
|
+
var containerSx = {
|
211
|
+
sx: {
|
212
|
+
'& input': {
|
213
|
+
paddingRight: '40px'
|
214
|
+
}
|
215
|
+
}
|
216
|
+
};
|
217
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(TextField, {
|
218
|
+
label: "Multiple Addresses",
|
219
|
+
labelMode: "float",
|
220
|
+
onChange: function onChange(e) {
|
221
|
+
return setAddressesValue(e.target.value);
|
222
|
+
},
|
223
|
+
value: addressesValue,
|
224
|
+
containerProps: containerSx,
|
225
|
+
slots: {
|
226
|
+
inContainer: ___EmotionJSX(CopyButton, {
|
227
|
+
onPress: copyAddressesToClipboard,
|
228
|
+
sx: buttonSx,
|
229
|
+
iconProps: {
|
230
|
+
sx: {
|
231
|
+
path: {
|
232
|
+
fill: 'active'
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
})
|
237
|
+
},
|
238
|
+
mb: 30
|
239
|
+
}), ___EmotionJSX(TextField, {
|
240
|
+
label: "Example JSON",
|
241
|
+
labelMode: "float",
|
242
|
+
onChange: function onChange(e) {
|
243
|
+
return setJsonValue(e.target.value);
|
244
|
+
},
|
245
|
+
value: jsonValue,
|
246
|
+
containerProps: containerSx,
|
247
|
+
slots: {
|
248
|
+
inContainer: ___EmotionJSX(CopyButton, {
|
249
|
+
onPress: copyJsonToClipboard,
|
250
|
+
sx: buttonSx,
|
251
|
+
iconProps: {
|
252
|
+
sx: {
|
253
|
+
path: {
|
254
|
+
fill: 'active'
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
})
|
259
|
+
}
|
260
|
+
}));
|
189
261
|
};
|
@@ -354,7 +354,7 @@ var chipDeleteButton = {
|
|
354
354
|
borderRadius: '50%',
|
355
355
|
cursor: 'pointer',
|
356
356
|
height: 14,
|
357
|
-
|
357
|
+
mx: '3px !important',
|
358
358
|
p: 0,
|
359
359
|
width: 14,
|
360
360
|
'&.is-focused, &.is-hovered': {
|
@@ -534,6 +534,58 @@ var tooltipInline = _objectSpread(_objectSpread({}, text), {}, {
|
|
534
534
|
}
|
535
535
|
});
|
536
536
|
|
537
|
+
var colorBlock = {
|
538
|
+
bg: 'neutral.95',
|
539
|
+
border: '1px solid',
|
540
|
+
borderColor: 'neutral.90',
|
541
|
+
borderRadius: 10,
|
542
|
+
outline: 'none',
|
543
|
+
cursor: 'pointer',
|
544
|
+
width: 150,
|
545
|
+
minHeight: 40,
|
546
|
+
p: '5px 15px',
|
547
|
+
display: 'flex',
|
548
|
+
justifyContent: 'space-between',
|
549
|
+
alignItems: 'center',
|
550
|
+
'&.is-hovered': {
|
551
|
+
bg: 'neutral.80'
|
552
|
+
},
|
553
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
554
|
+
'&.is-pressed': {
|
555
|
+
bg: 'neutral.60',
|
556
|
+
borderColor: 'neutral.60'
|
557
|
+
},
|
558
|
+
'& span': {
|
559
|
+
color: 'text.primary',
|
560
|
+
textAlign: 'left'
|
561
|
+
},
|
562
|
+
'&>div': {
|
563
|
+
alignItems: 'baseline'
|
564
|
+
},
|
565
|
+
'&>svg': {
|
566
|
+
color: 'text.secondary',
|
567
|
+
fill: 'text.secondary'
|
568
|
+
},
|
569
|
+
'&.is-configured': {
|
570
|
+
bg: 'active',
|
571
|
+
borderColor: 'active',
|
572
|
+
'& span': {
|
573
|
+
color: 'white'
|
574
|
+
},
|
575
|
+
'&>svg': {
|
576
|
+
color: 'white',
|
577
|
+
fill: 'white'
|
578
|
+
}
|
579
|
+
},
|
580
|
+
'&.is-configured.is-hovered': {
|
581
|
+
bg: 'accent.40',
|
582
|
+
borderColor: 'accent.40'
|
583
|
+
},
|
584
|
+
'&.is-configured.is-pressed': {
|
585
|
+
bg: 'accent.20',
|
586
|
+
borderColor: 'accent.20'
|
587
|
+
}
|
588
|
+
};
|
537
589
|
export default {
|
538
590
|
accordionHeader: accordionHeader,
|
539
591
|
chipDeleteButton: chipDeleteButton,
|
@@ -573,5 +625,6 @@ export default {
|
|
573
625
|
invertedSquare: invertedSquare,
|
574
626
|
tooltipChip: tooltipChip,
|
575
627
|
tooltipIconButton: tooltipIconButton,
|
576
|
-
tooltipInline: tooltipInline
|
628
|
+
tooltipInline: tooltipInline,
|
629
|
+
colorBlock: colorBlock
|
577
630
|
};
|
@@ -158,6 +158,20 @@ export var text = {
|
|
158
158
|
color: 'accent.30',
|
159
159
|
fontFamily: 'standard'
|
160
160
|
}),
|
161
|
+
buttonTitle: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
162
|
+
fontSize: 'xs',
|
163
|
+
fontWeight: 0,
|
164
|
+
color: 'text.primary',
|
165
|
+
fontFamily: 'standard',
|
166
|
+
lineHeight: '13px'
|
167
|
+
}),
|
168
|
+
buttonSubtitle: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
169
|
+
fontSize: 'sm',
|
170
|
+
fontWeight: 3,
|
171
|
+
color: 'text.primary',
|
172
|
+
fontFamily: 'standard',
|
173
|
+
lineHeight: '16px'
|
174
|
+
}),
|
161
175
|
capsLabel: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
162
176
|
color: 'text.secondary',
|
163
177
|
textTransform: 'uppercase',
|