@pingux/astro 1.1.0-alpha.1 → 1.1.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -0
  3. package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +1 -1
  4. package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +1 -1
  5. package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +33 -1
  6. package/lib/cjs/components/AccordionItem/AccordionItem.js +5 -4
  7. package/lib/cjs/components/Button/Button.js +1 -2
  8. package/lib/cjs/components/Button/Button.stories.js +2 -1
  9. package/lib/cjs/components/Button/Button.test.js +2 -1
  10. package/lib/cjs/components/CodeView/CodeView.js +165 -0
  11. package/lib/cjs/components/CodeView/CodeView.stories.js +93 -0
  12. package/lib/cjs/components/CodeView/CodeView.test.js +211 -0
  13. package/lib/cjs/components/CodeView/index.js +18 -0
  14. package/lib/cjs/components/ColorField/ColorField.js +1 -0
  15. package/lib/cjs/components/ComboBoxField/ComboBoxField.js +7 -0
  16. package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +25 -1
  17. package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +44 -0
  18. package/lib/cjs/components/CopyText/CopyText.js +34 -11
  19. package/lib/cjs/components/FileInputField/FileItem.js +2 -1
  20. package/lib/cjs/components/IconButton/IconButton.js +1 -1
  21. package/lib/cjs/components/IconButton/IconButton.stories.js +8 -17
  22. package/lib/cjs/components/IconButton/IconButton.test.js +4 -5
  23. package/lib/cjs/components/ImageUploadField/ImagePreviewButton.js +2 -1
  24. package/lib/cjs/components/List/List.js +3 -0
  25. package/lib/cjs/components/List/List.stories.js +7 -2
  26. package/lib/cjs/components/ListBox/ListBox.js +3 -6
  27. package/lib/cjs/components/ListBox/ListBox.test.js +2 -0
  28. package/lib/cjs/components/ListBox/Option.js +6 -0
  29. package/lib/cjs/components/Messages/Message.js +2 -2
  30. package/lib/cjs/components/MultivaluesField/MultivaluesField.js +2 -1
  31. package/lib/cjs/components/NavBar/NavBar.js +38 -0
  32. package/lib/cjs/components/NavBar/NavBar.stories.js +679 -0
  33. package/lib/cjs/components/NavBar/NavBar.test.js +116 -0
  34. package/lib/cjs/components/NavBar/index.js +18 -0
  35. package/lib/cjs/components/NavBarSection/NavBarItemBody.js +56 -0
  36. package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +47 -0
  37. package/lib/cjs/components/NavBarSection/NavBarSection.js +82 -0
  38. package/lib/cjs/components/NavBarSection/index.js +18 -0
  39. package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +15 -14
  40. package/lib/cjs/components/PopoverContainer/PopoverContainer.test.js +15 -0
  41. package/lib/cjs/components/Separator/Separator.js +1 -1
  42. package/lib/cjs/components/TextArea/TextArea.js +5 -1
  43. package/lib/cjs/components/TooltipTrigger/TooltipTrigger.js +10 -5
  44. package/lib/cjs/index.js +84 -30
  45. package/lib/cjs/styles/variants/accordion.js +34 -3
  46. package/lib/cjs/styles/variants/boxes.js +24 -1
  47. package/lib/cjs/styles/variants/buttons.js +39 -1
  48. package/lib/cjs/styles/variants/codeView.js +80 -0
  49. package/lib/cjs/styles/variants/link.js +1 -1
  50. package/lib/cjs/styles/variants/separator.js +46 -3
  51. package/lib/cjs/styles/variants/text.js +15 -0
  52. package/lib/cjs/styles/variants/variants.js +3 -0
  53. package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +23 -1
  54. package/lib/components/AccordionGridItem/AccordionGridItemBody.js +1 -1
  55. package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +1 -1
  56. package/lib/components/AccordionGroup/AccordionGroup.test.js +30 -1
  57. package/lib/components/AccordionItem/AccordionItem.js +6 -5
  58. package/lib/components/Button/Button.js +2 -3
  59. package/lib/components/Button/Button.stories.js +2 -1
  60. package/lib/components/Button/Button.test.js +2 -1
  61. package/lib/components/CodeView/CodeView.js +130 -0
  62. package/lib/components/CodeView/CodeView.stories.js +67 -0
  63. package/lib/components/CodeView/CodeView.test.js +171 -0
  64. package/lib/components/CodeView/index.js +1 -0
  65. package/lib/components/ColorField/ColorField.js +1 -0
  66. package/lib/components/ComboBoxField/ComboBoxField.js +7 -0
  67. package/lib/components/ComboBoxField/ComboBoxField.stories.js +21 -0
  68. package/lib/components/ComboBoxField/ComboBoxField.test.js +35 -0
  69. package/lib/components/CopyText/CopyText.js +35 -11
  70. package/lib/components/FileInputField/FileItem.js +2 -1
  71. package/lib/components/IconButton/IconButton.js +1 -1
  72. package/lib/components/IconButton/IconButton.stories.js +7 -13
  73. package/lib/components/IconButton/IconButton.test.js +4 -5
  74. package/lib/components/ImageUploadField/ImagePreviewButton.js +2 -1
  75. package/lib/components/List/List.js +2 -0
  76. package/lib/components/List/List.stories.js +6 -2
  77. package/lib/components/ListBox/ListBox.js +3 -5
  78. package/lib/components/ListBox/ListBox.test.js +2 -0
  79. package/lib/components/ListBox/Option.js +6 -0
  80. package/lib/components/Messages/Message.js +2 -2
  81. package/lib/components/MultivaluesField/MultivaluesField.js +2 -1
  82. package/lib/components/NavBar/NavBar.js +24 -0
  83. package/lib/components/NavBar/NavBar.stories.js +650 -0
  84. package/lib/components/NavBar/NavBar.test.js +92 -0
  85. package/lib/components/NavBar/index.js +1 -0
  86. package/lib/components/NavBarSection/NavBarItemBody.js +37 -0
  87. package/lib/components/NavBarSection/NavBarItemHeader.js +31 -0
  88. package/lib/components/NavBarSection/NavBarSection.js +65 -0
  89. package/lib/components/NavBarSection/index.js +1 -0
  90. package/lib/components/OverlayPanel/OverlayPanel.stories.js +7 -5
  91. package/lib/components/PopoverContainer/PopoverContainer.test.js +16 -1
  92. package/lib/components/Separator/Separator.js +1 -1
  93. package/lib/components/TextArea/TextArea.js +5 -1
  94. package/lib/components/TooltipTrigger/TooltipTrigger.js +10 -5
  95. package/lib/index.js +5 -0
  96. package/lib/styles/variants/accordion.js +34 -3
  97. package/lib/styles/variants/boxes.js +24 -1
  98. package/lib/styles/variants/buttons.js +39 -1
  99. package/lib/styles/variants/codeView.js +68 -0
  100. package/lib/styles/variants/link.js +1 -1
  101. package/lib/styles/variants/separator.js +33 -1
  102. package/lib/styles/variants/text.js +15 -0
  103. package/lib/styles/variants/variants.js +2 -0
  104. package/package.json +3 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,127 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.1.0-alpha.12](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.11...@pingux/astro@1.1.0-alpha.12) (2022-01-31)
7
+
8
+
9
+ ### Features
10
+
11
+ * [UIP-5067] CodeView component ([c4e104c](https://gitlab.corp.pingidentity.com/ux/pingux/commit/c4e104c3638c8f6231b5f3c14cd65a1a62bb6591))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.1.0-alpha.11](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.10...@pingux/astro@1.1.0-alpha.11) (2022-01-28)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * [UIP-5177] Icon Button Color Update ([05b8a95](https://gitlab.corp.pingidentity.com/ux/pingux/commit/05b8a95e3fae60e7f655cf2812dfd2104496b1c5))
23
+
24
+
25
+
26
+
27
+
28
+ # [1.1.0-alpha.10](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.9...@pingux/astro@1.1.0-alpha.10) (2022-01-28)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * [UIP-5180] File Upload Field Update Document Icon Color ([debaf91](https://gitlab.corp.pingidentity.com/ux/pingux/commit/debaf9100401c822c37fdd16be1a1b1704096f10))
34
+
35
+
36
+
37
+
38
+
39
+ # [1.1.0-alpha.9](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.8...@pingux/astro@1.1.0-alpha.9) (2022-01-24)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * [UIP-5111] Deprecate List Component ([3cd9b69](https://gitlab.corp.pingidentity.com/ux/pingux/commit/3cd9b699c48ac43e34d9cfd61b07f33b4b7d4fc4))
45
+
46
+
47
+
48
+
49
+
50
+ # [1.1.0-alpha.8](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.7...@pingux/astro@1.1.0-alpha.8) (2022-01-24)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * [UIP-4995] TextArea Safari resize issue ([33c8af3](https://gitlab.corp.pingidentity.com/ux/pingux/commit/33c8af35fbe82820427b87bdd9ab0744039a6c18))
56
+
57
+
58
+
59
+
60
+
61
+ # [1.1.0-alpha.7](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.6...@pingux/astro@1.1.0-alpha.7) (2022-01-21)
62
+
63
+
64
+ ### Bug Fixes
65
+
66
+ * [UIP-5109] AccordionGroup OverlayPanel Compatibility Fix ([6a78b76](https://gitlab.corp.pingidentity.com/ux/pingux/commit/6a78b76a3c3ab7b9ac78a7dcd6ca74a6449d63c2))
67
+
68
+
69
+
70
+
71
+
72
+ # [1.1.0-alpha.6](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.5...@pingux/astro@1.1.0-alpha.6) (2022-01-21)
73
+
74
+
75
+ ### Bug Fixes
76
+
77
+ * [UIP-5070] Icons for warning and error messages are reversed ([36f0d6e](https://gitlab.corp.pingidentity.com/ux/pingux/commit/36f0d6e1b65662b3c64aa1599012a2967b59e56d))
78
+
79
+
80
+
81
+
82
+
83
+ # [1.1.0-alpha.5](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.4...@pingux/astro@1.1.0-alpha.5) (2022-01-21)
84
+
85
+
86
+ ### Bug Fixes
87
+
88
+ * [UIP-5030] Components shouldn't have a default aria-label ([8927951](https://gitlab.corp.pingidentity.com/ux/pingux/commit/8927951339ef49faa03f5654d9e8f357b136430a))
89
+
90
+
91
+
92
+
93
+
94
+ # [1.1.0-alpha.4](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.3...@pingux/astro@1.1.0-alpha.4) (2022-01-21)
95
+
96
+
97
+ ### Bug Fixes
98
+
99
+ * [UIP-4992] Fix SelectField Warnings ([dab3f92](https://gitlab.corp.pingidentity.com/ux/pingux/commit/dab3f9254c5d7b1b124ed24616e4ef68f53af7d0))
100
+
101
+
102
+
103
+
104
+
105
+ # [1.1.0-alpha.3](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.2...@pingux/astro@1.1.0-alpha.3) (2022-01-20)
106
+
107
+
108
+ ### Bug Fixes
109
+
110
+ * [UIP-5007] ComboBoxField controlled custom input throws an exception ([9651c98](https://gitlab.corp.pingidentity.com/ux/pingux/commit/9651c98da3b3ac158c84f378303a2d331db78cce))
111
+
112
+
113
+
114
+
115
+
116
+ # [1.1.0-alpha.2](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.1...@pingux/astro@1.1.0-alpha.2) (2022-01-19)
117
+
118
+
119
+ ### Bug Fixes
120
+
121
+ * [UIP-5039] IconButton Square Variant ([2fecfac](https://gitlab.corp.pingidentity.com/ux/pingux/commit/2fecfac9d39974eb5dc773d210c3a830d1bd9e2a))
122
+
123
+
124
+
125
+
126
+
6
127
  # [1.1.0-alpha.1](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.1.0-alpha.0...@pingux/astro@1.1.0-alpha.1) (2022-01-19)
7
128
 
8
129
 
@@ -39,6 +39,22 @@ var getComponent = function getComponent() {
39
39
  }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Header Button"), (0, _react2.jsx)(_index.Link, null, "Second Header Button")), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Body Button"), (0, _react2.jsx)(_index.Link, null, "Second Body Button")))));
40
40
  };
41
41
 
42
+ var getComponentInOverlayPanel = function getComponentInOverlayPanel() {
43
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
44
+ return (0, _testWrapper.render)((0, _react2.jsx)(_index.OverlayPanel, {
45
+ isOpen: true
46
+ }, (0, _react2.jsx)(_AccordionGridGroup["default"], (0, _extends2["default"])({}, defaultProps, props), (0, _react2.jsx)(_collections.Item, {
47
+ key: "first",
48
+ textValue: "Duplicate"
49
+ }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Header Button"), (0, _react2.jsx)(_index.Link, null, "Second Header Button")), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Body Button"), (0, _react2.jsx)(_index.Link, null, "Second Body Button"))), (0, _react2.jsx)(_collections.Item, {
50
+ key: "second",
51
+ textValue: "Duplicate"
52
+ }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Header Button"), (0, _react2.jsx)(_index.Link, null, "Second Header Button")), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Body Button"), (0, _react2.jsx)(_index.Link, null, "Second Body Button"))), (0, _react2.jsx)(_collections.Item, {
53
+ key: "third",
54
+ textValue: "Duplicate"
55
+ }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Header Button"), (0, _react2.jsx)(_index.Link, null, "Second Header Button")), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Link, null, "Body Button"), (0, _react2.jsx)(_index.Link, null, "Second Body Button"))))));
56
+ };
57
+
42
58
  (0, _testAxe["default"])(getComponent, {
43
59
  // landmark-unique rule conflicts with react-aria role definition
44
60
  rules: {
@@ -230,4 +246,12 @@ test('default expanded keys expands an accordion item', function () {
230
246
 
231
247
  var selectedRow = row[0];
232
248
  expect(selectedRow).toHaveAttribute('aria-selected', 'true');
249
+ });
250
+ test('items do not automatically expand if wrapped in an open OverlayPanel', function () {
251
+ getComponentInOverlayPanel();
252
+
253
+ var row = _testWrapper.screen.getAllByRole('row');
254
+
255
+ var selectedRow = row[0];
256
+ expect(selectedRow).not.toHaveAttribute('aria-selected', 'true');
233
257
  });
@@ -77,7 +77,7 @@ var AccordionGridItemBody = /*#__PURE__*/(0, _react.forwardRef)(function (props,
77
77
  }, mergedProps, {
78
78
  isSelected: isSelected,
79
79
  className: classNames,
80
- "aria-label": ariaLabel || 'Grid Cell'
80
+ "aria-label": ariaLabel
81
81
  }), children);
82
82
  });
83
83
  AccordionGridItemBody.propTypes = {
@@ -106,7 +106,7 @@ var AccordionGridItemHeader = /*#__PURE__*/(0, _react.forwardRef)(function (prop
106
106
  isSelected: isSelected,
107
107
  className: classNames
108
108
  }, others, {
109
- "aria-label": ariaLabel || 'Grid Cell'
109
+ "aria-label": ariaLabel
110
110
  }), (0, _react2.jsx)(_Box["default"], {
111
111
  isRow: true
112
112
  }, children, (0, _react2.jsx)(_Box["default"], {
@@ -20,6 +20,8 @@ var _Text = _interopRequireDefault(require("../Text"));
20
20
 
21
21
  var _AccordionGroup = _interopRequireDefault(require("../AccordionGroup"));
22
22
 
23
+ var _index = require("../../index");
24
+
23
25
  var _react2 = require("@emotion/react");
24
26
 
25
27
  var testId = 'test-accordion';
@@ -30,6 +32,28 @@ var defaultProps = {
30
32
  var getComponent = function getComponent() {
31
33
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32
34
  return (0, _testWrapper.render)((0, _react2.jsx)(_AccordionGroup["default"], (0, _extends2["default"])({}, defaultProps, props), (0, _react2.jsx)(_collections.Item, {
35
+ key: "first",
36
+ textValue: "Duplicate",
37
+ "data-id": "first",
38
+ label: "Accordion item"
39
+ }, (0, _react2.jsx)(_Text["default"], null, "Render me!")), (0, _react2.jsx)(_collections.Item, {
40
+ key: "second",
41
+ textValue: "Duplicate",
42
+ "data-id": "second",
43
+ label: "Accordion item"
44
+ }, (0, _react2.jsx)(_Text["default"], null, "Render me!")), (0, _react2.jsx)(_collections.Item, {
45
+ key: "third",
46
+ textValue: "Duplicate",
47
+ "data-id": "third",
48
+ label: "Accordion item"
49
+ }, (0, _react2.jsx)(_Text["default"], null, "Render me!"))));
50
+ };
51
+
52
+ var getComponentInOverlayPanel = function getComponentInOverlayPanel() {
53
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
+ return (0, _testWrapper.render)((0, _react2.jsx)(_index.OverlayPanel, {
55
+ isOpen: true
56
+ }, (0, _react2.jsx)(_AccordionGroup["default"], (0, _extends2["default"])({}, defaultProps, props), (0, _react2.jsx)(_collections.Item, {
33
57
  key: "first",
34
58
  textValue: "Duplicate",
35
59
  "data-id": "first"
@@ -41,7 +65,7 @@ var getComponent = function getComponent() {
41
65
  key: "third",
42
66
  textValue: "Duplicate",
43
67
  "data-id": "third"
44
- }, (0, _react2.jsx)(_Text["default"], null, "Render me!"))));
68
+ }, (0, _react2.jsx)(_Text["default"], null, "Render me!")))));
45
69
  }; // Need to be added to each test file to test accessibility using axe.
46
70
 
47
71
 
@@ -264,4 +288,12 @@ test('Item accepts a data-id and the data-id can be found in the DOM', function
264
288
  var selectedItem = buttons[0];
265
289
  var parentElement = selectedItem.parentElement;
266
290
  expect(parentElement).toHaveAttribute('data-id', 'first');
291
+ });
292
+ test('items do not automatically expand if wrapped in an open OverlayPanel', function () {
293
+ getComponentInOverlayPanel();
294
+
295
+ var buttons = _testWrapper.screen.getAllByRole('button');
296
+
297
+ var selectedItem = buttons[0];
298
+ expect(selectedItem).not.toHaveAttribute('aria-expanded', 'true');
267
299
  });
@@ -100,12 +100,11 @@ var AccordionItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
100
100
  buttonClasses = _useStatusClasses2.classNames;
101
101
 
102
102
  var ariaLabel = props['aria-label'] || item.props.label;
103
- (0, _hooks.useAriaLabelWarning)('AccordionItem', ariaLabel);
104
103
  return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
105
104
  variant: "accordion.accordion",
106
105
  className: itemClasses
107
106
  }, others, containerProps), (0, _react2.jsx)(_themeUi.Button, (0, _extends2["default"])({
108
- "aria-label": ariaLabel || 'Accordion',
107
+ "aria-label": ariaLabel,
109
108
  ref: buttonRef,
110
109
  sx: {
111
110
  display: 'flex',
@@ -122,9 +121,11 @@ var AccordionItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
122
121
  ml: "5px"
123
122
  }, (0, _react2.jsx)(_index.Icon, {
124
123
  icon: isOpen ? _MenuUpIcon["default"] : _MenuDownIcon["default"]
125
- }))), (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
124
+ }))), isOpen && (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
126
125
  variant: "accordion.accordionBody"
127
- }, accordionRegionProps, regionProps), item.rendered));
126
+ }, accordionRegionProps, regionProps, {
127
+ className: itemClasses
128
+ }), item.rendered));
128
129
  });
129
130
  AccordionItem.propTypes = {
130
131
  'aria-label': _propTypes["default"].string,
@@ -103,9 +103,8 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
103
103
  classNames = _useStatusClasses.classNames;
104
104
 
105
105
  var ariaLabel = props['aria-label'];
106
- (0, _hooks.useAriaLabelWarning)('Button', ariaLabel);
107
106
  return (0, _react2.jsx)(_themeUi.Button, (0, _extends2["default"])({
108
- "aria-label": ariaLabel || 'Button',
107
+ "aria-label": ariaLabel,
109
108
  ref: buttonRef,
110
109
  className: classNames,
111
110
  role: "button",
@@ -93,7 +93,8 @@ exports.TextIconButton = TextIconButton;
93
93
  var TextButton = function TextButton() {
94
94
  return (0, _react2.jsx)(_["default"], {
95
95
  mb: "sm",
96
- variant: "text"
96
+ variant: "text",
97
+ "aria-label": "Add option"
97
98
  }, (0, _react2.jsx)(_Text["default"], {
98
99
  variant: "label",
99
100
  color: "active"
@@ -18,7 +18,8 @@ var _react2 = require("@emotion/react");
18
18
 
19
19
  var testId = 'test-button';
20
20
  var defaultProps = {
21
- 'data-testid': testId
21
+ 'data-testid': testId,
22
+ 'aria-label': 'Test button'
22
23
  };
23
24
 
24
25
  var getComponent = function getComponent() {
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
8
+
9
+ _Object$defineProperty2(exports, "__esModule", {
10
+ value: true
11
+ });
12
+
13
+ exports["default"] = void 0;
14
+
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
16
+
17
+ var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-properties"));
18
+
19
+ var _getOwnPropertyDescriptors = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors"));
20
+
21
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
22
+
23
+ var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor"));
24
+
25
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
26
+
27
+ var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
28
+
29
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
30
+
31
+ var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
32
+
33
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
34
+
35
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
36
+
37
+ var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
38
+
39
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
40
+
41
+ var _react = _interopRequireWildcard(require("react"));
42
+
43
+ var _propTypes = _interopRequireDefault(require("prop-types"));
44
+
45
+ var _focus = require("@react-aria/focus");
46
+
47
+ var _interactions = require("@react-aria/interactions");
48
+
49
+ var _utils = require("@react-aria/utils");
50
+
51
+ var _prismReactRenderer = _interopRequireWildcard(require("prism-react-renderer"));
52
+
53
+ var _hooks = require("../../hooks");
54
+
55
+ var _ = require("../..");
56
+
57
+ var _react2 = require("@emotion/react");
58
+
59
+ function ownKeys(object, enumerableOnly) { var keys = (0, _keys["default"])(object); if (_getOwnPropertySymbols["default"]) { var symbols = (0, _getOwnPropertySymbols["default"])(object); if (enumerableOnly) symbols = (0, _filter["default"])(symbols).call(symbols, function (sym) { return (0, _getOwnPropertyDescriptor["default"])(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
60
+
61
+ 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; }
62
+
63
+ /**
64
+ * A text block that shows syntax highlighting code sample.
65
+ * Built on top of the [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer).
66
+ *
67
+ * A list of all supported languages that can be passed to `language` prop is [here](https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js).
68
+ */
69
+ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
70
+ var children = props.children,
71
+ outerClassName = props.className,
72
+ hasLineNumbers = props.hasLineNumbers,
73
+ hasNoCopyButton = props.hasNoCopyButton,
74
+ language = props.language,
75
+ others = (0, _objectWithoutProperties2["default"])(props, ["children", "className", "hasLineNumbers", "hasNoCopyButton", "language"]);
76
+
77
+ var _useFocusRing = (0, _focus.useFocusRing)(),
78
+ isFocusVisible = _useFocusRing.isFocusVisible,
79
+ focusProps = _useFocusRing.focusProps;
80
+
81
+ var _useHover = (0, _interactions.useHover)(props),
82
+ hoverProps = _useHover.hoverProps,
83
+ isHovered = _useHover.isHovered;
84
+
85
+ var _useStatusClasses = (0, _hooks.useStatusClasses)(outerClassName, {
86
+ isFocused: isFocusVisible,
87
+ isHovered: isHovered,
88
+ hasLineNumbers: hasLineNumbers,
89
+ hasNoCopyButton: hasNoCopyButton
90
+ }),
91
+ classNames = _useStatusClasses.classNames; // Get the width for the line number element depending on the total amount of lines
92
+
93
+
94
+ var getLineNoWidth = function getLineNoWidth(tokens) {
95
+ return tokens.length.toString().length * 12;
96
+ };
97
+
98
+ var content = (0, _react2.jsx)(_prismReactRenderer["default"], (0, _extends2["default"])({}, _prismReactRenderer.defaultProps, {
99
+ theme: undefined,
100
+ code: (children === null || children === void 0 ? void 0 : (0, _trim["default"])(children).call(children)) || '',
101
+ language: language
102
+ }), function (_ref) {
103
+ var className = _ref.className,
104
+ style = _ref.style,
105
+ tokens = _ref.tokens,
106
+ getLineProps = _ref.getLineProps,
107
+ getTokenProps = _ref.getTokenProps;
108
+ return (0, _react2.jsx)(_.Box, {
109
+ as: "pre",
110
+ className: className,
111
+ style: style
112
+ }, (0, _map["default"])(tokens).call(tokens, function (line, i) {
113
+ return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
114
+ isRow: true
115
+ }, getLineProps({
116
+ line: line,
117
+ key: i
118
+ })), hasLineNumbers && (0, _react2.jsx)(_.Box, {
119
+ as: "span",
120
+ variant: "codeView.lineNo",
121
+ sx: {
122
+ minWidth: getLineNoWidth(tokens)
123
+ }
124
+ }, i + 1), (0, _map["default"])(line).call(line, function (token, key) {
125
+ return (0, _react2.jsx)("span", getTokenProps({
126
+ token: token,
127
+ key: key
128
+ }));
129
+ }));
130
+ }));
131
+ });
132
+
133
+ if (hasNoCopyButton) {
134
+ return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
135
+ ref: ref,
136
+ variant: "codeView.wrapper",
137
+ tabIndex: 0,
138
+ className: classNames
139
+ }, (0, _utils.mergeProps)(focusProps, hoverProps, others)), content);
140
+ }
141
+
142
+ return (0, _react2.jsx)(_.CopyText, {
143
+ mode: "nonClickableContent",
144
+ textToCopy: children,
145
+ tooltipProps: {
146
+ offset: 15
147
+ },
148
+ wrapperProps: _objectSpread({
149
+ className: classNames,
150
+ variant: 'codeView.wrapper'
151
+ }, others)
152
+ }, content);
153
+ });
154
+ CodeView.propTypes = {
155
+ hasLineNumbers: _propTypes["default"].bool,
156
+ hasNoCopyButton: _propTypes["default"].bool,
157
+ language: _propTypes["default"].string
158
+ };
159
+ CodeView.defaultProps = {
160
+ language: 'json',
161
+ hasLineNumbers: false,
162
+ hasNoCopyButton: false
163
+ };
164
+ var _default = CodeView;
165
+ exports["default"] = _default;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.WithCustomSize = exports.WithLineNumbers = exports.Default = exports["default"] = void 0;
12
+
13
+ var _react = _interopRequireDefault(require("react"));
14
+
15
+ var _CodeView = _interopRequireDefault(require("./CodeView"));
16
+
17
+ var _ = require("../..");
18
+
19
+ var _react2 = require("@emotion/react");
20
+
21
+ var code = "{\n \"_links\": {\n \"self\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\"\n },\n \"password\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.set\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.reset\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.check\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.recover\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"account.sendVerificationCode\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\"\n },\n \"linkedAccounts\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/linkedAccounts\"\n }\n },\n \"id\": \"5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\",\n \"environment\": {\n \"id\": \"94e3268d-847d-47aa-a45e-1ef8dd8f4df0\"\n },\n \"account\": {\n \"canAuthenticate\": true,\n \"status\": \"OK\"\n },\n \"createdAt\": \"2021-09-03T15:01:43.555Z\",\n \"email\": \"allegraweldon@pingidentity.com\",\n \"enabled\": true,\n \"identityProvider\": {\n \"type\": \"PING_ONE\"\n },\n \"lifecycle\": {\n \"status\": \"ACCOUNT_OK\"\n },\n \"mfaEnabled\": false,\n \"population\": {\n \"id\": \"c1adbc29-f188-4ea6-a015-49bddd74bc84\"\n },\n \"updatedAt\": \"2021-09-03T15:01:43.555Z\",\n \"username\": \"allegraweldon@pingidentity.com\",\n \"verifyStatus\": \"NOT_INITIATED\"\n}";
22
+ var _default = {
23
+ title: 'CodeView',
24
+ component: _CodeView["default"],
25
+ argTypes: {
26
+ children: {
27
+ defaultValue: code,
28
+ table: {
29
+ type: {}
30
+ },
31
+ control: {
32
+ type: 'text'
33
+ }
34
+ }
35
+ },
36
+ parameters: {
37
+ a11y: {
38
+ config: {
39
+ rules: [
40
+ /* Turned off since rule conflicts with the way how `prism-react-renderer` works
41
+ * and design specs */
42
+ {
43
+ id: 'scrollable-region-focusable',
44
+ enabled: false,
45
+ selector: '.prism-code'
46
+ }]
47
+ }
48
+ }
49
+ }
50
+ };
51
+ exports["default"] = _default;
52
+
53
+ var Default = function Default(args) {
54
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_.Text, {
55
+ sx: {
56
+ fontWeight: 2
57
+ }
58
+ }, "JSON"), (0, _react2.jsx)(_CodeView["default"], args));
59
+ };
60
+
61
+ exports.Default = Default;
62
+
63
+ var WithLineNumbers = function WithLineNumbers() {
64
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_.Text, {
65
+ sx: {
66
+ fontWeight: 2
67
+ }
68
+ }, "JSON"), (0, _react2.jsx)(_CodeView["default"], {
69
+ hasLineNumbers: true
70
+ }, code));
71
+ };
72
+
73
+ exports.WithLineNumbers = WithLineNumbers;
74
+ WithLineNumbers.story = {
75
+ parameters: {
76
+ docs: {
77
+ storyDescription: 'Please note that with adding line numbers, line wrapping does not work.'
78
+ }
79
+ }
80
+ };
81
+
82
+ var WithCustomSize = function WithCustomSize() {
83
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_CodeView["default"], {
84
+ language: "javascript",
85
+ sx: {
86
+ width: '100%',
87
+ height: 300
88
+ },
89
+ hasNoCopyButton: true
90
+ }, "\nexport const ChipWithIcon = () => (\n <>\n <Chip label=\"Chip with Icon Button\" bg=\"navy\">\n <IconButton aria-label=\"Clear Chip with Icon Button\" variant=\"inverted\">\n <Icon icon={Clear} ml=\"xs\" size=\"14px\" />\n </IconButton>\n </Chip>\n\n <div style={{ padding: '5px' }} />\n\n <Chip label=\"Chip with Icon Button\">\n <IconButton aria-label=\"Clear Chip with Icon Button\" variant=\"inverted\">\n <Icon icon={Earth} ml=\"xs\" size=\"14px\" />\n </IconButton>\n </Chip>\n\n <div style={{ padding: '5px' }} />\n\n <Chip label=\"Chip with Icon\" bg=\"green\">\n <Icon icon={ContentCopy} ml=\"xs\" size=\"14px\" color=\"white\" />\n </Chip>\n </>\n);\n "));
91
+ };
92
+
93
+ exports.WithCustomSize = WithCustomSize;