@carbon/ibm-products 1.2.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/css/index-full-carbon.css +662 -313
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +2 -2
  4. package/css/index-without-carbon-released-only.css +156 -81
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css +2 -2
  7. package/css/index-without-carbon.css +393 -81
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +2 -2
  10. package/css/index.css +615 -81
  11. package/css/index.css.map +1 -1
  12. package/css/index.min.css +2 -2
  13. package/es/components/APIKeyModal/APIKeyModal.js +25 -29
  14. package/es/components/ActionBar/ActionBar.js +4 -1
  15. package/es/components/ActionSet/ActionSet.js +22 -10
  16. package/es/components/ActionSet/actions.js +25 -17
  17. package/es/components/AddSelect/AddSelect.js +157 -0
  18. package/es/components/AddSelect/index.js +7 -0
  19. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +19 -15
  20. package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
  21. package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
  22. package/es/components/CreateFullPage/CreateFullPage.js +102 -258
  23. package/es/components/CreateFullPage/CreateFullPageStep.js +65 -13
  24. package/es/components/CreateFullPage/index.js +1 -2
  25. package/es/components/CreateInfluencer/CreateInfluencer.js +40 -220
  26. package/es/components/CreateTearsheet/CreateTearsheet.js +95 -146
  27. package/es/components/CreateTearsheet/CreateTearsheetStep.js +70 -20
  28. package/es/components/CreateTearsheet/index.js +0 -1
  29. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +87 -28
  30. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  31. package/es/components/ExportModal/ExportModal.js +41 -12
  32. package/es/components/ImportModal/ImportModal.js +2 -1
  33. package/es/components/InlineEdit/InlineEdit.js +224 -0
  34. package/es/components/InlineEdit/index.js +7 -0
  35. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  36. package/es/components/MultiAddSelect/index.js +1 -0
  37. package/es/components/OptionsTile/OptionsTile.js +36 -15
  38. package/es/components/PageHeader/PageHeader.js +54 -33
  39. package/es/components/PageHeader/PageHeaderTitle.js +78 -7
  40. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  41. package/es/components/RemoveModal/RemoveModal.js +4 -2
  42. package/es/components/SidePanel/SidePanel.js +1 -1
  43. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  44. package/es/components/SingleAddSelect/index.js +1 -0
  45. package/es/components/TagSet/TagSet.js +4 -1
  46. package/es/components/Tearsheet/Tearsheet.js +1 -1
  47. package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
  48. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  49. package/es/components/Toolbar/Toolbar.js +69 -8
  50. package/es/components/index.js +5 -1
  51. package/es/global/js/hooks/index.js +1 -0
  52. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  53. package/es/global/js/hooks/useCreateComponentStepChange.js +69 -79
  54. package/es/global/js/hooks/useResetCreateComponent.js +7 -4
  55. package/es/global/js/hooks/useRetrieveStepData.js +51 -0
  56. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  57. package/es/global/js/package-settings.js +5 -1
  58. package/es/global/js/utils/lastIndexInArray.js +26 -0
  59. package/es/global/js/utils/story-helper.js +1 -1
  60. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  61. package/lib/components/ActionBar/ActionBar.js +4 -1
  62. package/lib/components/ActionSet/ActionSet.js +22 -10
  63. package/lib/components/ActionSet/actions.js +25 -17
  64. package/lib/components/AddSelect/AddSelect.js +178 -0
  65. package/lib/components/AddSelect/index.js +13 -0
  66. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +18 -14
  67. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
  68. package/lib/components/CancelableTextEdit/index.js +13 -0
  69. package/lib/components/CreateFullPage/CreateFullPage.js +102 -258
  70. package/lib/components/CreateFullPage/CreateFullPageStep.js +68 -13
  71. package/lib/components/CreateFullPage/index.js +1 -9
  72. package/lib/components/CreateInfluencer/CreateInfluencer.js +38 -231
  73. package/lib/components/CreateTearsheet/CreateTearsheet.js +97 -148
  74. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +72 -19
  75. package/lib/components/CreateTearsheet/index.js +0 -8
  76. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +86 -34
  77. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  78. package/lib/components/ExportModal/ExportModal.js +38 -11
  79. package/lib/components/ImportModal/ImportModal.js +2 -1
  80. package/lib/components/InlineEdit/InlineEdit.js +242 -0
  81. package/lib/components/InlineEdit/index.js +13 -0
  82. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  83. package/lib/components/MultiAddSelect/index.js +13 -0
  84. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  85. package/lib/components/PageHeader/PageHeader.js +54 -33
  86. package/lib/components/PageHeader/PageHeaderTitle.js +87 -9
  87. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  88. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  89. package/lib/components/SidePanel/SidePanel.js +1 -1
  90. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  91. package/lib/components/SingleAddSelect/index.js +13 -0
  92. package/lib/components/TagSet/TagSet.js +4 -1
  93. package/lib/components/Tearsheet/Tearsheet.js +1 -1
  94. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
  95. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  96. package/lib/components/Toolbar/Toolbar.js +69 -6
  97. package/lib/components/index.js +33 -1
  98. package/lib/global/js/hooks/index.js +8 -0
  99. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  100. package/lib/global/js/hooks/useCreateComponentStepChange.js +69 -79
  101. package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
  102. package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
  103. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  104. package/lib/global/js/package-settings.js +5 -1
  105. package/lib/global/js/utils/lastIndexInArray.js +35 -0
  106. package/lib/global/js/utils/story-helper.js +1 -1
  107. package/package.json +22 -22
  108. package/scss/components/AddSelect/_add-select.scss +84 -0
  109. package/scss/components/AddSelect/_index.scss +10 -0
  110. package/scss/components/AddSelect/_storybook-styles.scss +6 -0
  111. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  112. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +211 -0
  113. package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
  114. package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
  115. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  116. package/scss/components/CreateTearsheet/_create-tearsheet.scss +4 -8
  117. package/scss/components/InlineEdit/_index.scss +8 -0
  118. package/scss/components/InlineEdit/_inline-edit.scss +44 -0
  119. package/scss/components/InlineEdit/_storybook-styles.scss +15 -0
  120. package/scss/components/MultiAddSelect/_index.scss +1 -0
  121. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  122. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  123. package/scss/components/PageHeader/_page-header.scss +14 -4
  124. package/scss/components/SingleAddSelect/_index.scss +1 -0
  125. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  126. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  127. package/scss/components/StatusIcon/_status-icon.scss +2 -0
  128. package/scss/components/_index.scss +4 -0
  129. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  130. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  131. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  132. package/es/global/js/utils/hasValidType.js +0 -94
  133. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  134. package/lib/components/CreateFullPage/constants.js +0 -16
  135. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  136. package/lib/components/CreateTearsheet/constants.js +0 -17
  137. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  138. package/lib/global/js/utils/hasValidType.js +0 -110
@@ -0,0 +1,44 @@
1
+ //
2
+ // Copyright IBM Corp. 2022, 2022
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ // Standard imports.
9
+ @import '../../global/styles/project-settings';
10
+ @import '../../global/styles/mixins';
11
+
12
+ // Other Carbon settings.
13
+ // TODO: @import 'carbon-components/scss/globals/grid/grid'; if needed
14
+
15
+ // InlineEdit uses the following Carbon components:
16
+ // TODO: @import(s) of Carbon component styles used by InlineEdit
17
+
18
+ // InlineEdit uses the following Carbon for IBM Products components:
19
+ // TODO: @import(s) of IBM Products component styles used by InlineEdit
20
+
21
+ // Define all component styles in a mixin which is then exported using
22
+ // the Carbon import-once mechanism.
23
+ @mixin inline-edit {
24
+ // The block part of our conventional BEM class names (blockClass__E--M).
25
+ $block-class: #{$pkg-prefix}--inline-edit;
26
+
27
+ .#{$block-class} {
28
+ display: inline-flex;
29
+ align-content: center;
30
+ }
31
+
32
+ .#{$block-class} .#{$block-class}__value {
33
+ display: flex;
34
+ align-items: center;
35
+ }
36
+
37
+ .#{$block-class} .#{$block-class}__button {
38
+ margin-left: $spacing-03;
39
+ }
40
+ }
41
+
42
+ @include exports('inline-edit') {
43
+ @include inline-edit;
44
+ }
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright IBM Corp. 2022, 2022
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @import './index';
9
+
10
+ // TODO: add any additional styles used by InlineEdit.stories.js
11
+
12
+ // Uncomment next line (which must appear last) to test in storybook
13
+ // that the SCSS styles for this component are sufficiently specific
14
+ // to override Carbon whichever order the styles get loaded in.
15
+ //@import 'carbon-components/css/carbon-components.min';
@@ -0,0 +1 @@
1
+ @import './multi-add-select';
@@ -0,0 +1 @@
1
+ @import '../AddSelect/add-select';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright IBM Corp. 2021
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
@@ -144,7 +144,7 @@ $right-section-alt-width: 100% - $left-section-alt-width;
144
144
 
145
145
  .#{$block-class}__breadcrumb-row:not(.#{$block-class}__breadcrumb-row--has-action-bar) {
146
146
  // lifts up page title when there is no action bar
147
- margin-bottom: calc(-1 * #{$spacing-03});
147
+ min-height: $spacing-07;
148
148
  }
149
149
 
150
150
  .#{$block-class}__breadcrumb-row--container {
@@ -189,7 +189,7 @@ $right-section-alt-width: 100% - $left-section-alt-width;
189
189
  transition: all $duration--moderate-01 ease-out;
190
190
  }
191
191
 
192
- .#{$block-class}__breadcrumb-row--next-to-tabs::after,
192
+ .#{$block-class}__breadcrumb-row--next-to-tabs:not(.#{$block-class}__has-page-actions-without-action-bar)::after,
193
193
  .#{$block-class}__breadcrumb-row--has-action-bar::after {
194
194
  /* creates a full width box shadow without causing scroll */
195
195
  box-shadow: 25vw 1px 0 0 $ui-03, -25vw 1px 0 0 $ui-03;
@@ -408,7 +408,6 @@ $right-section-alt-width: 100% - $left-section-alt-width;
408
408
  }
409
409
 
410
410
  .#{$block-class}__title-column {
411
- overflow: hidden; /* required for ellipsis in title */
412
411
  min-height: 40px;
413
412
  flex: 0 0 100%;
414
413
 
@@ -421,11 +420,22 @@ $right-section-alt-width: 100% - $left-section-alt-width;
421
420
  .#{$block-class}__title {
422
421
  @include carbon--type-style('productive-heading-04');
423
422
 
424
- overflow: hidden;
423
+ overflow-x: hidden;
425
424
  text-overflow: ellipsis;
426
425
  white-space: nowrap;
427
426
  }
428
427
 
428
+ .#{$block-class}__title .#{$pkg-prefix}--inline-edit__value {
429
+ // The heading text sits 2px pixels lower in the inline edit which is aligned center
430
+ // stylelint-disable-next-line carbon/layout-token-use
431
+ transform: translateY(-2px);
432
+ }
433
+
434
+ .#{$block-class}__title--editable {
435
+ display: flex;
436
+ overflow: visible;
437
+ }
438
+
429
439
  .#{$block-class}__title-skeleton {
430
440
  height: $spacing-07;
431
441
  }
@@ -0,0 +1 @@
1
+ @import './single-add-select';
@@ -0,0 +1 @@
1
+ @import '../AddSelect/add-select';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright IBM Corp. 2021
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
@@ -111,6 +111,8 @@ $block-class: #{$pkg-prefix}--status-icon;
111
111
  @each $theme in $themes {
112
112
  @each $icon in $icons {
113
113
  @each $theme-key in $themes {
114
+ .#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger
115
+ .#{$block-class}--#{$theme}.#{$block-class}--#{$theme-key}-#{$icon},
114
116
  .#{$block-class}--#{$theme}.#{$block-class}--#{$theme-key}-#{$icon} {
115
117
  @if $icon == in-progress {
116
118
  @media (prefers-reduced-motion: reduce) {
@@ -27,12 +27,14 @@
27
27
  @import './ImportModal/index';
28
28
  @import './LoadingBar/index';
29
29
  @import './ModifiedTabs/index';
30
+ @import './MultiAddSelect/index';
30
31
  @import './NotificationsPanel/index';
31
32
  @import './PageHeader/index';
32
33
  @import './ProductiveCard/index';
33
34
  @import './RemoveModal/index';
34
35
  @import './Saving/index';
35
36
  @import './SidePanel/index';
37
+ @import './SingleAddSelect/index';
36
38
  @import './StatusIcon/index';
37
39
  @import './TagSet/index';
38
40
  @import './Tearsheet/index';
@@ -41,3 +43,5 @@
41
43
  @import './UserProfileImage/index';
42
44
  @import './EditSidePanel/index';
43
45
  @import './OptionsTile/index';
46
+ @import './CancelableTextEdit/index';
47
+ @import './InlineEdit/index';
@@ -1,53 +0,0 @@
1
- //
2
- // Copyright IBM Corp. 2021, 2021
3
- //
4
- // This source code is licensed under the Apache-2.0 license found in the
5
- // LICENSE file in the root directory of this source tree.
6
- //
7
- import React, { forwardRef } from 'react';
8
- import PropTypes from 'prop-types';
9
- import cx from 'classnames';
10
- import { pkg } from '../../settings';
11
- import { CREATE_FULL_PAGE_SECTION } from './constants';
12
- var blockClass = "".concat(pkg.prefix, "--create-full-page__section");
13
- export var CreateFullPageSection = /*#__PURE__*/forwardRef( // currently, we are not supporting the use of FullPageSections -- this may be a future feature
14
-
15
- /* istanbul ignore next */
16
- function (_ref, ref) {
17
- var children = _ref.children,
18
- className = _ref.className,
19
- id = _ref.id;
20
- return /*#__PURE__*/React.createElement("div", {
21
- className: cx(blockClass, className),
22
- ref: ref,
23
- id: id
24
- }, children);
25
- });
26
- CreateFullPageSection.propTypes = {
27
- /**
28
- * Content that shows in the CreateFullPage step
29
- */
30
- children: PropTypes.node,
31
-
32
- /**
33
- * Sets an optional className to be added to the CreateFullPage step
34
- */
35
- className: PropTypes.string,
36
-
37
- /**
38
- * Sets the id of the CreateTearsheetSection outermost element
39
- */
40
- id: PropTypes.string.isRequired,
41
-
42
- /**
43
- * Sets the title text for a CreateFullPage step
44
- */
45
- title: PropTypes.node.isRequired
46
- }; // Default values for component props. Default values are not required for
47
- // props that are required, nor for props where the component can apply
48
- // 'undefined' values reasonably. Default values should be provided when the
49
- // component needs to make a choice or assumption when a prop is not supplied.
50
-
51
- CreateFullPageSection.defaultProps = {
52
- type: CREATE_FULL_PAGE_SECTION
53
- };
@@ -1,83 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2021, 2021
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import React, { forwardRef } from 'react';
8
- import PropTypes from 'prop-types';
9
- import cx from 'classnames';
10
- import { Column, Row } from 'carbon-components-react';
11
- import { pkg } from '../../settings';
12
- import { CREATE_TEARSHEET_SECTION } from './constants';
13
- var componentName = 'CreateTearsheetSection';
14
- var blockClass = "".concat(pkg.prefix, "--tearsheet-create__section");
15
- export var CreateTearsheetSection = /*#__PURE__*/forwardRef(function (_ref, ref) {
16
- var id = _ref.id,
17
- children = _ref.children,
18
- className = _ref.className,
19
- subtitle = _ref.subtitle,
20
- description = _ref.description,
21
- title = _ref.title,
22
- isViewingAllStepsTogether = _ref.isViewingAllStepsTogether;
23
- return /*#__PURE__*/React.createElement("div", {
24
- className: cx(blockClass, className),
25
- ref: ref,
26
- id: id
27
- }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
28
- xlg: 12,
29
- lg: 12,
30
- md: 8,
31
- sm: 8
32
- }, isViewingAllStepsTogether && /*#__PURE__*/React.createElement("h4", {
33
- className: "".concat(blockClass, "--title")
34
- }, title), isViewingAllStepsTogether && subtitle && /*#__PURE__*/React.createElement("h6", {
35
- className: "".concat(blockClass, "--subtitle")
36
- }, subtitle), isViewingAllStepsTogether && description && /*#__PURE__*/React.createElement("p", {
37
- className: "".concat(blockClass, "--description")
38
- }, description))), children);
39
- });
40
- CreateTearsheetSection.displayName = componentName;
41
- CreateTearsheetSection.propTypes = {
42
- /**
43
- * Content that shows in the tearsheet step
44
- */
45
- children: PropTypes.node,
46
-
47
- /**
48
- * Sets an optional className to be added to the tearsheet step
49
- */
50
- className: PropTypes.string,
51
-
52
- /**
53
- * Sets an optional description on the section component
54
- */
55
- description: PropTypes.string,
56
-
57
- /**
58
- * Sets the id of the CreateTearsheetSection outermost element
59
- */
60
- id: PropTypes.string.isRequired,
61
-
62
- /**
63
- * The is an internal prop set in CreateTearsheet so the section knows when to render it's title
64
- */
65
- isViewingAllStepsTogether: PropTypes.bool,
66
-
67
- /**
68
- * Sets an optional subtitle on the section component
69
- */
70
- subtitle: PropTypes.string,
71
-
72
- /**
73
- * Sets the title text for a tearsheet step
74
- */
75
- title: PropTypes.node.isRequired
76
- }; // Default values for component props. Default values are not required for
77
- // props that are required, nor for props where the component can apply
78
- // 'undefined' values reasonably. Default values should be provided when the
79
- // component needs to make a choice or assumption when a prop is not supplied.
80
-
81
- CreateTearsheetSection.defaultProps = {
82
- type: CREATE_TEARSHEET_SECTION
83
- };
@@ -1,327 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
-
5
- /* eslint-disable react/prop-types */
6
-
7
- /**
8
- * Copyright IBM Corp. 2021, 2021
9
- *
10
- * This source code is licensed under the Apache-2.0 license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- */
13
- import React, { useState } from 'react';
14
- import { Button, Column, Dropdown, FormGroup, InlineNotification, RadioButtonGroup, RadioButton, Row, TextInput, Toggle } from 'carbon-components-react';
15
- import cx from 'classnames';
16
- import { pkg } from '../../../settings';
17
- import { CreateTearsheet } from '../CreateTearsheet';
18
- import { CreateTearsheetStep } from '../CreateTearsheetStep';
19
- import { CreateTearsheetDivider } from '../CreateTearsheetDivider';
20
- var blockClass = "".concat(pkg.prefix, "--tearsheet-create-multi-step");
21
- var componentBlockClass = "".concat(pkg.prefix, "--tearsheet-create");
22
- export var MultiStepWithSectionsTearsheet = function MultiStepWithSectionsTearsheet(_ref) {
23
- var backButtonText = _ref.backButtonText,
24
- cancelButtonText = _ref.cancelButtonText,
25
- className = _ref.className,
26
- description = _ref.description,
27
- influencerWidth = _ref.influencerWidth,
28
- label = _ref.label,
29
- nextButtonText = _ref.nextButtonText,
30
- submitButtonText = _ref.submitButtonText,
31
- title = _ref.title;
32
-
33
- var _useState = useState(750),
34
- _useState2 = _slicedToArray(_useState, 1),
35
- simulatedDelay = _useState2[0];
36
-
37
- var _useState3 = useState(false),
38
- _useState4 = _slicedToArray(_useState3, 2),
39
- open = _useState4[0],
40
- setOpen = _useState4[1];
41
-
42
- var _useState5 = useState(false),
43
- _useState6 = _slicedToArray(_useState5, 2),
44
- shouldReject = _useState6[0],
45
- setShouldReject = _useState6[1];
46
-
47
- var _useState7 = useState(false),
48
- _useState8 = _slicedToArray(_useState7, 2),
49
- hasSubmitError = _useState8[0],
50
- setHasSubmitError = _useState8[1];
51
-
52
- var _useState9 = useState(''),
53
- _useState10 = _slicedToArray(_useState9, 2),
54
- stepOneTextInputValue = _useState10[0],
55
- setStepOneTextInputValue = _useState10[1];
56
-
57
- var _useState11 = useState(''),
58
- _useState12 = _slicedToArray(_useState11, 2),
59
- topicDescriptionValue = _useState12[0],
60
- setTopicDescriptionValue = _useState12[1];
61
-
62
- var _useState13 = useState(''),
63
- _useState14 = _slicedToArray(_useState13, 2),
64
- topicVersionValue = _useState14[0],
65
- setTopicVersionValue = _useState14[1];
66
-
67
- var _useState15 = useState(''),
68
- _useState16 = _slicedToArray(_useState15, 2),
69
- topicMetaData = _useState16[0],
70
- setTopicMetaData = _useState16[1];
71
-
72
- var _useState17 = useState('one-day'),
73
- _useState18 = _slicedToArray(_useState17, 2),
74
- stepThreeTextInputValue = _useState18[0],
75
- setStepThreeTextInputValue = _useState18[1];
76
-
77
- var _useState19 = useState(false),
78
- _useState20 = _slicedToArray(_useState19, 2),
79
- isInvalid = _useState20[0],
80
- setIsInvalid = _useState20[1];
81
-
82
- var _useState21 = useState([]),
83
- _useState22 = _slicedToArray(_useState21, 2),
84
- allTopicOwners = _useState22[0],
85
- setAllTopicOwners = _useState22[1];
86
-
87
- var _useState23 = useState(null),
88
- _useState24 = _slicedToArray(_useState23, 2),
89
- selectedTopicOwner = _useState24[0],
90
- setSelectedTopicOwner = _useState24[1];
91
-
92
- var _useState25 = useState(false),
93
- _useState26 = _slicedToArray(_useState25, 2),
94
- apiFailed = _useState26[0],
95
- setApiFailed = _useState26[1];
96
-
97
- var clearCreateData = function clearCreateData() {
98
- setStepOneTextInputValue('');
99
- setTopicDescriptionValue('');
100
- setTopicVersionValue('');
101
- setStepThreeTextInputValue('one-day');
102
- setHasSubmitError(false);
103
- setIsInvalid(false);
104
- setOpen(false);
105
- setAllTopicOwners([]);
106
- setSelectedTopicOwner(null);
107
- setApiFailed(false);
108
- };
109
-
110
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("style", null, ".".concat(blockClass, " { opacity: 0 }"), ";"), /*#__PURE__*/React.createElement(Button, {
111
- onClick: function onClick() {
112
- return setOpen(!open);
113
- }
114
- }, open ? 'Close CreateTearsheet' : 'Open CreateTearsheet'), /*#__PURE__*/React.createElement(CreateTearsheet, {
115
- influencerWidth: influencerWidth,
116
- label: label,
117
- className: cx(blockClass, className),
118
- submitButtonText: submitButtonText,
119
- cancelButtonText: cancelButtonText,
120
- backButtonText: backButtonText,
121
- nextButtonText: nextButtonText,
122
- description: description,
123
- title: title,
124
- open: open,
125
- onClose: clearCreateData,
126
- onRequestSubmit: function onRequestSubmit() {
127
- return new Promise(function (resolve) {
128
- setTimeout(function () {
129
- clearCreateData();
130
- resolve();
131
- }, simulatedDelay);
132
- });
133
- }
134
- }, /*#__PURE__*/React.createElement(CreateTearsheetStep, {
135
- onMount: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
136
- var data, json;
137
- return _regeneratorRuntime.wrap(function _callee$(_context) {
138
- while (1) {
139
- switch (_context.prev = _context.next) {
140
- case 0:
141
- _context.prev = 0;
142
- _context.next = 3;
143
- return fetch('https://randomuser.me/api/?results=5');
144
-
145
- case 3:
146
- data = _context.sent;
147
- _context.next = 6;
148
- return data.json();
149
-
150
- case 6:
151
- json = _context.sent;
152
-
153
- if (data.ok) {
154
- _context.next = 9;
155
- break;
156
- }
157
-
158
- throw new Error('received non 200 response');
159
-
160
- case 9:
161
- setAllTopicOwners(json.results);
162
- _context.next = 16;
163
- break;
164
-
165
- case 12:
166
- _context.prev = 12;
167
- _context.t0 = _context["catch"](0);
168
- console.warn("CreateTearsheet [storybook example]: API request failed.");
169
- setApiFailed(true);
170
-
171
- case 16:
172
- case "end":
173
- return _context.stop();
174
- }
175
- }
176
- }, _callee, null, [[0, 12]]);
177
- })),
178
- onNext: function onNext() {
179
- return new Promise(function (resolve, reject) {
180
- setTimeout(function () {
181
- // Example usage of how to prevent the next step if some kind
182
- // of error occurred during the `onNext` handler.
183
- if (shouldReject) {
184
- setHasSubmitError(true);
185
- reject();
186
- }
187
-
188
- setIsInvalid(false);
189
- resolve();
190
- }, simulatedDelay);
191
- });
192
- },
193
- title: "Topic name",
194
- fieldsetLegendText: "Topic name information",
195
- disableSubmit: !stepOneTextInputValue,
196
- subtitle: "This is the unique name used to recognize your topic",
197
- description: "It will also be used by your producers and consumers as part of the connection information, so make it something easy to recognize."
198
- }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
199
- xlg: 8,
200
- lg: 8,
201
- md: 8,
202
- sm: 8
203
- }, /*#__PURE__*/React.createElement(TextInput, {
204
- labelText: "Topic name",
205
- id: "tearsheet-multi-step-story-text-input-multi-step-1",
206
- value: stepOneTextInputValue,
207
- placeholder: "Enter topic name",
208
- onChange: function onChange(event) {
209
- if (event.target.value.length) {
210
- setIsInvalid(false);
211
- }
212
-
213
- setStepOneTextInputValue(event.target.value);
214
- },
215
- invalid: isInvalid,
216
- invalidText: "This is a required field",
217
- onBlur: function onBlur() {
218
- if (!stepOneTextInputValue.length) {
219
- setIsInvalid(true);
220
- }
221
- }
222
- }), /*#__PURE__*/React.createElement(TextInput, {
223
- labelText: "Topic description (optional)",
224
- id: "tearsheet-multi-step-story-text-input-multi-step-1-input-2",
225
- value: topicDescriptionValue,
226
- placeholder: "Enter topic description",
227
- onChange: function onChange(event) {
228
- return setTopicDescriptionValue(event.target.value);
229
- }
230
- }), /*#__PURE__*/React.createElement(TextInput, {
231
- labelText: "Topic version (optional)",
232
- id: "tearsheet-multi-step-story-text-input-multi-step-1-input-3",
233
- value: topicVersionValue,
234
- placeholder: "Enter topic version",
235
- onChange: function onChange(event) {
236
- return setTopicVersionValue(event.target.value);
237
- }
238
- }), /*#__PURE__*/React.createElement(Dropdown, {
239
- ariaLabel: "Topic owner dropdown",
240
- className: "bx--form-item",
241
- id: "create-tearsheet-topic-owner",
242
- items: allTopicOwners,
243
- itemToString: function itemToString(item) {
244
- return item ? item.email : '';
245
- },
246
- label: "Select a topic owner",
247
- onChange: function onChange(_ref3) {
248
- var selectedItem = _ref3.selectedItem;
249
- return setSelectedTopicOwner(selectedItem);
250
- },
251
- selectedItem: selectedTopicOwner,
252
- titleText: "Topic owner (optional)",
253
- warn: apiFailed,
254
- warnText: "API request failed."
255
- }), hasSubmitError && /*#__PURE__*/React.createElement(InlineNotification, {
256
- kind: "error",
257
- title: "Error",
258
- subtitle: "Resolve errors to continue",
259
- onClose: function onClose() {
260
- return setHasSubmitError(false);
261
- }
262
- }), /*#__PURE__*/React.createElement(Toggle, {
263
- className: "".concat(blockClass, "__error--toggle"),
264
- id: "simulated-error-toggle",
265
- size: "sm",
266
- labelText: "Simulate error",
267
- onToggle: function onToggle(event) {
268
- return setShouldReject(event);
269
- }
270
- }))), /*#__PURE__*/React.createElement(CreateTearsheetDivider, null), /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
271
- xlg: 8,
272
- lg: 8,
273
- md: 8,
274
- sm: 8
275
- }, /*#__PURE__*/React.createElement("h4", {
276
- className: "".concat(componentBlockClass, "__step--title")
277
- }, "Meta data"), /*#__PURE__*/React.createElement(FormGroup, {
278
- className: "".concat(pkg.prefix, "--tearsheet-create__step--fieldset"),
279
- legendText: "Enter any topic meta data here"
280
- }, /*#__PURE__*/React.createElement(TextInput, {
281
- labelText: "Topic meta data (optional)",
282
- id: "tearsheet-multi-step-story-text-input-multi-step-1-input-4",
283
- value: topicMetaData,
284
- placeholder: "Enter topic meta data",
285
- onChange: function onChange(event) {
286
- return setTopicMetaData(event.target.value);
287
- }
288
- }))))), /*#__PURE__*/React.createElement(CreateTearsheetStep, {
289
- title: "Message retention",
290
- fieldsetLegendText: "Message retention scheduling",
291
- disableSubmit: !stepThreeTextInputValue,
292
- onNext: function onNext() {
293
- return Promise.resolve();
294
- },
295
- subtitle: "This is how long messages are retained before they are deleted.",
296
- description: "If your messages are not read by a consumer within this time, they will be missed."
297
- }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
298
- xlg: 8,
299
- lg: 8,
300
- md: 8,
301
- sm: 8
302
- }, /*#__PURE__*/React.createElement(RadioButtonGroup, {
303
- legendText: "Message retention",
304
- name: "radio-button-group",
305
- defaultSelected: stepThreeTextInputValue,
306
- onChange: function onChange(value) {
307
- return setStepThreeTextInputValue(value);
308
- },
309
- orientation: "vertical"
310
- }, /*#__PURE__*/React.createElement(RadioButton, {
311
- labelText: "A day",
312
- value: "one-day",
313
- id: "one-day"
314
- }), /*#__PURE__*/React.createElement(RadioButton, {
315
- labelText: "A week",
316
- value: "one-week",
317
- id: "one-week"
318
- }), /*#__PURE__*/React.createElement(RadioButton, {
319
- labelText: "A month",
320
- value: "one-month",
321
- id: "one-month"
322
- }), /*#__PURE__*/React.createElement(RadioButton, {
323
- labelText: "Custom",
324
- value: "custom",
325
- id: "custom"
326
- })))))));
327
- };