carbon-react 13.10.0 → 13.12.1
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/CHANGELOG.md +21 -0
- package/cypress/features/accessibility/accessibility.feature +2 -1
- package/cypress/features/build/build.feature +1 -0
- package/cypress/features/regression/test/popoverContainer.feature +65 -0
- package/cypress/locators/popover-container/index.js +18 -0
- package/cypress/locators/popover-container/locators.js +6 -0
- package/cypress/support/step-definitions/popover-container-steps.js +88 -0
- package/lib/__deprecated__/components/dropdown-filter-ajax/dropdown-filter-ajax.stories.js +1 -4
- package/lib/__spec_helper__/index.js +1 -1
- package/lib/components/button/button-types.style.js +2 -3
- package/lib/components/button/button.component.js +16 -1
- package/lib/components/button/button.stories.js +4 -1
- package/lib/components/button/button.stories.mdx +4 -4
- package/lib/components/button/button.style.js +3 -2
- package/lib/components/button/documentation/info.js +1 -1
- package/lib/components/icon-button/icon-button.component.js +4 -3
- package/lib/components/icon-button/icon-button.style.js +1 -1
- package/lib/components/message/message.style.js +1 -1
- package/lib/components/popover-container/index.js +15 -0
- package/lib/components/popover-container/popover-container.component.js +120 -0
- package/lib/components/popover-container/popover-container.d.ts +17 -0
- package/lib/components/popover-container/popover-container.stories.js +73 -0
- package/lib/components/popover-container/popover-container.stories.mdx +104 -0
- package/lib/components/popover-container/popover-container.style.js +142 -0
- package/lib/components/table-ajax/table-ajax.stories.js +0 -3
- package/lib/style/themes/base/base-theme.config.js +3 -0
- package/lib/utils/helpers/events/events.js +11 -0
- package/lib/utils/helpers/options-helper/options-helper.js +1 -1
- package/package.json +10 -12
- package/.storybook/utils/xhr/data/countries.js +0 -195
- package/.storybook/utils/xhr/xhr-mock.js +0 -56
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
### [13.12.1](https://github.com/Sage/carbon/compare/v13.12.0...v13.12.1) (2022-07-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update react and react-dom to v17 ([b0a5ff2](https://github.com/Sage/carbon/commit/b0a5ff23b3cd62243baef20e4f6837f56bd7fd97))
|
|
7
|
+
|
|
8
|
+
## [13.12.0](https://github.com/Sage/carbon/compare/v13.11.0...v13.12.0) (2020-03-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **button:** add destructive prop ([cef3676](https://github.com/Sage/carbon/commit/cef3676d754722ba171eaa1dc1f79e447b61b6d2))
|
|
14
|
+
|
|
15
|
+
## [13.11.0](https://github.com/Sage/carbon/compare/v13.10.0...v13.11.0) (2020-03-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **popover-container:** add new component ([871b56d](https://github.com/Sage/carbon/commit/871b56d1c82890d39ae1c489316d1304708d41b4))
|
|
21
|
+
|
|
1
22
|
## [13.10.0](https://github.com/Sage/carbon/compare/v13.9.1...v13.10.0) (2020-03-11)
|
|
2
23
|
|
|
3
24
|
|
|
@@ -192,6 +192,7 @@ Feature: Build tests
|
|
|
192
192
|
| Flat Table | flat-table |
|
|
193
193
|
| Search | search |
|
|
194
194
|
| Button Toggle Group | button-toggle-group |
|
|
195
|
+
| Popover Container | popover-container |
|
|
195
196
|
|
|
196
197
|
@build
|
|
197
198
|
Scenario: Component Draggable basic default page and verify data-element
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Feature: Popover container component
|
|
2
|
+
I want to change Popover container component properties
|
|
3
|
+
|
|
4
|
+
Background: Open Popover container component page
|
|
5
|
+
Given I open basic Test "Popover container" component page
|
|
6
|
+
And I open popover container
|
|
7
|
+
|
|
8
|
+
@positive
|
|
9
|
+
Scenario: Popover container is opened
|
|
10
|
+
# commented because of BDD default scenario Given - When - Then
|
|
11
|
+
# When I open popover container
|
|
12
|
+
Then Popover container is visible
|
|
13
|
+
|
|
14
|
+
@positive
|
|
15
|
+
Scenario Outline: Change Popover container component title to <title>
|
|
16
|
+
When I set title to "<title>"
|
|
17
|
+
Then Popover title on preview is set to "<title>"
|
|
18
|
+
Examples:
|
|
19
|
+
| title |
|
|
20
|
+
| Sample text |
|
|
21
|
+
| 1234567890 |
|
|
22
|
+
| áéíóú¿¡üñ |
|
|
23
|
+
| !@#$%^*()_+-=~[];:.,?{} |
|
|
24
|
+
| ÄÖÜßäöüß |
|
|
25
|
+
| <> |
|
|
26
|
+
|
|
27
|
+
@positive
|
|
28
|
+
Scenario: Popover container component iconType to add
|
|
29
|
+
When I select iconType to "add"
|
|
30
|
+
Then icon on preview is "add"
|
|
31
|
+
|
|
32
|
+
@positive
|
|
33
|
+
Scenario Outline: Popover container component position to <position>
|
|
34
|
+
When I select position to "<position>"
|
|
35
|
+
Then Popover component opened the "<position>" side
|
|
36
|
+
Examples:
|
|
37
|
+
| position |
|
|
38
|
+
| left |
|
|
39
|
+
| right |
|
|
40
|
+
|
|
41
|
+
@positive
|
|
42
|
+
Scenario: Popover container is closed
|
|
43
|
+
When I click popover close icon
|
|
44
|
+
Then Popover container is not visible
|
|
45
|
+
|
|
46
|
+
@positive
|
|
47
|
+
Scenario Outline: Open Popover container is opened using <key> key
|
|
48
|
+
Given I click popover close icon
|
|
49
|
+
When I click onto popover setting icon using "<key>" key
|
|
50
|
+
Then Popover container is visible
|
|
51
|
+
Examples:
|
|
52
|
+
| key |
|
|
53
|
+
| Enter |
|
|
54
|
+
| Space |
|
|
55
|
+
|
|
56
|
+
@positive
|
|
57
|
+
Scenario Outline: Open Popover container is closed using <key> key
|
|
58
|
+
Given I click popover close icon
|
|
59
|
+
And I click onto popover setting icon using "<key>" key
|
|
60
|
+
When I press onto closeIcon using "<key>" key
|
|
61
|
+
Then Popover container is not visible
|
|
62
|
+
Examples:
|
|
63
|
+
| key |
|
|
64
|
+
| Enter |
|
|
65
|
+
| Space |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
POPOVER_CONTAINER_DATA_COMPONENT,
|
|
3
|
+
POPOVER_CONTAINER_CONTENT,
|
|
4
|
+
POPOVER_CONTAINER_TITLE,
|
|
5
|
+
POPOVER_SETTINGS_ICON,
|
|
6
|
+
POPOVER_CLOSE_ICON,
|
|
7
|
+
} from './locators';
|
|
8
|
+
|
|
9
|
+
// component preview locators
|
|
10
|
+
export const popoverContainerDataComponent = () => cy.iFrame(POPOVER_CONTAINER_DATA_COMPONENT);
|
|
11
|
+
export const popoverContainerContent = () => cy.iFrame(POPOVER_CONTAINER_CONTENT);
|
|
12
|
+
export const popoverContainerTitle = () => cy.iFrame(POPOVER_CONTAINER_TITLE);
|
|
13
|
+
export const popoverContainerContentFirstInnerElement = () => popoverContainerContent().children()
|
|
14
|
+
.find('div');
|
|
15
|
+
export const popoverContainerContentSecondInnerElement = () => popoverContainerContent().children()
|
|
16
|
+
.find('button');
|
|
17
|
+
export const popoverSettingsIcon = () => cy.iFrame(POPOVER_SETTINGS_ICON);
|
|
18
|
+
export const popoverCloseIcon = () => cy.iFrame(POPOVER_CLOSE_ICON);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// component preview locators
|
|
2
|
+
export const POPOVER_CONTAINER_DATA_COMPONENT = '[data-component="popover-container"]';
|
|
3
|
+
export const POPOVER_CONTAINER_CONTENT = '[data-element="popover-container-content"]';
|
|
4
|
+
export const POPOVER_CONTAINER_TITLE = '[data-element="popover-container-title"]';
|
|
5
|
+
export const POPOVER_SETTINGS_ICON = '[data-element="settings"]';
|
|
6
|
+
export const POPOVER_CLOSE_ICON = '[data-element="popover-container-close-icon"]';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
popoverContainerDataComponent,
|
|
3
|
+
popoverContainerContent,
|
|
4
|
+
popoverContainerTitle,
|
|
5
|
+
popoverContainerContentFirstInnerElement,
|
|
6
|
+
popoverContainerContentSecondInnerElement,
|
|
7
|
+
popoverSettingsIcon,
|
|
8
|
+
popoverCloseIcon,
|
|
9
|
+
} from '../../locators/popover-container';
|
|
10
|
+
|
|
11
|
+
When('I open popover container', () => {
|
|
12
|
+
popoverContainerDataComponent().click();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
Then('Popover container is visible', () => {
|
|
16
|
+
popoverContainerDataComponent().should('exist');
|
|
17
|
+
popoverSettingsIcon().should('exist');
|
|
18
|
+
popoverContainerContent().should('be.visible');
|
|
19
|
+
popoverContainerContent().children().children().should('have.length', 2);
|
|
20
|
+
popoverContainerContent().should('have.css', 'background', 'rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box')
|
|
21
|
+
.and('have.css', 'box-shadow', 'rgba(0, 20, 29, 0.2) 0px 5px 5px 0px, rgba(0, 20, 29, 0.1) 0px 10px 10px 0px')
|
|
22
|
+
.and('have.css', 'padding', '16px 24px')
|
|
23
|
+
.and('have.css', 'min-width', '300px')
|
|
24
|
+
.and('have.css', 'position', 'absolute')
|
|
25
|
+
.and('have.css', 'top', '0px')
|
|
26
|
+
.and('have.css', 'opacity', '1')
|
|
27
|
+
.and('have.css', 'transform', 'matrix(1, 0, 0, 1, 0, 0)')
|
|
28
|
+
.and('have.css', 'transition', 'all 0.3s cubic-bezier(0.25, 0.25, 0, 1.5) 0s');
|
|
29
|
+
popoverContainerContentFirstInnerElement().should('have.attr', 'data-element', 'popover-container-title').and('be.visible')
|
|
30
|
+
.and('have.css', 'font-size', '16px')
|
|
31
|
+
.and('have.css', 'font-weight', '700');
|
|
32
|
+
popoverContainerContentSecondInnerElement().should('have.attr', 'data-element', 'popover-container-close-icon')
|
|
33
|
+
.and('be.visible')
|
|
34
|
+
.and('have.css', 'position', 'absolute')
|
|
35
|
+
.and('have.css', 'margin-right', '0px')
|
|
36
|
+
.and('have.css', 'background', 'rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box')
|
|
37
|
+
.and('have.css', 'border', '0px none rgba(0, 0, 0, 0.9)')
|
|
38
|
+
.and('have.css', 'padding', '0px');
|
|
39
|
+
popoverContainerContentSecondInnerElement().children().should('have.attr', 'data-element', 'close').and('be.visible')
|
|
40
|
+
.and('have.css', 'color', 'rgba(0, 0, 0, 0.9)')
|
|
41
|
+
.and('have.css', 'position', 'relative');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
Then('Popover title on preview is set to {string}', (title) => {
|
|
45
|
+
popoverContainerTitle().should('have.text', title);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
Then('Popover component opened the {string} side', (side) => {
|
|
49
|
+
if (side === 'left') {
|
|
50
|
+
popoverContainerDataComponent().parent().should('have.attr', 'style').should('contain', 'margin-left', '400px');
|
|
51
|
+
popoverContainerContent().should('have.css', 'right', '0px');
|
|
52
|
+
} else {
|
|
53
|
+
popoverContainerDataComponent().parent().should('not.have.attr', 'style');
|
|
54
|
+
popoverContainerContent().should('have.css', 'left', '0px');
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
Then('Popover container is not visible', () => {
|
|
59
|
+
popoverContainerContent().should('not.exist');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
When('I click onto popover setting icon using {string} key', (key) => {
|
|
63
|
+
switch (key) {
|
|
64
|
+
case 'Enter':
|
|
65
|
+
popoverSettingsIcon().trigger('keydown', { keyCode: 13, which: 13 });
|
|
66
|
+
break;
|
|
67
|
+
case 'Space':
|
|
68
|
+
popoverSettingsIcon().trigger('keydown', { keyCode: 32, which: 32 });
|
|
69
|
+
break;
|
|
70
|
+
default: throw new Error('Use Space or Enter key');
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
Then('I press onto closeIcon using {string} key', (key) => {
|
|
75
|
+
switch (key) {
|
|
76
|
+
case 'Enter':
|
|
77
|
+
popoverCloseIcon().trigger('keydown', { keyCode: 13, which: 13 });
|
|
78
|
+
break;
|
|
79
|
+
case 'Space':
|
|
80
|
+
popoverCloseIcon().trigger('keydown', { keyCode: 32, which: 32 });
|
|
81
|
+
break;
|
|
82
|
+
default: throw new Error('Use Space or Enter key');
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
When('I click popover close icon', () => {
|
|
87
|
+
popoverCloseIcon().click();
|
|
88
|
+
});
|
|
@@ -24,8 +24,6 @@ var _Info = _interopRequireDefault(require("./documentation/Info"));
|
|
|
24
24
|
|
|
25
25
|
var _dropdownFilterAjax = _interopRequireDefault(require("./dropdown-filter-ajax"));
|
|
26
26
|
|
|
27
|
-
var _xhrMock = require("../../../../.storybook/utils/xhr/xhr-mock");
|
|
28
|
-
|
|
29
27
|
var _docgenInfo = _interopRequireDefault(require("../../../utils/helpers/docgen-info"));
|
|
30
28
|
|
|
31
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -36,8 +34,7 @@ _dropdownFilterAjax.default.__docgenInfo = (0, _docgenInfo.default)(require('./d
|
|
|
36
34
|
var store = new _storybookState.Store({
|
|
37
35
|
value: '',
|
|
38
36
|
visibleValue: ''
|
|
39
|
-
});
|
|
40
|
-
(0, _xhrMock.enableMock)(); // Shared Props
|
|
37
|
+
}); // Shared Props
|
|
41
38
|
|
|
42
39
|
var onChange = function onChange(evt) {
|
|
43
40
|
store.set({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _enzyme = _interopRequireDefault(require("enzyme"));
|
|
4
4
|
|
|
5
|
-
var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-
|
|
5
|
+
var _enzymeAdapterReact = _interopRequireDefault(require("@wojtekmaj/enzyme-adapter-react-17"));
|
|
6
6
|
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
8
|
|
|
@@ -16,14 +16,13 @@ function makeColors(color) {
|
|
|
16
16
|
return "\n color: ".concat(color, ";\n ").concat(_icon.default, " {\n color: ").concat(color, ";\n }\n ");
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
var _default = function _default(_ref, isDisabled) {
|
|
19
|
+
var _default = function _default(_ref, isDisabled, destructive) {
|
|
20
20
|
var colors = _ref.colors,
|
|
21
21
|
disabled = _ref.disabled;
|
|
22
22
|
return {
|
|
23
|
-
primary: "\n background: ".concat(colors.primary, ";\n border-color: transparent;\n color: ").concat(colors.white, ";\n &:hover {\n background: ").concat(colors.secondary, ";\n }\n\n ").concat(isDisabled ? "\n
|
|
23
|
+
primary: "\n background: ".concat(colors.primary, ";\n border-color: transparent;\n color: ").concat(colors.white, ";\n &:hover {\n background: ").concat(colors.secondary, ";\n }\n\n ").concat(isDisabled ? "\n background: ".concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n &:hover {\n background: ").concat(disabled.button, ";\n border-color: ").concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n }\n ") : '', "\n\n ").concat(destructive ? "background: ".concat(colors.error, ";\n border-color: transparent;\n color: ").concat(colors.white, ";\n &:hover {\n background: ").concat(colors.destructive.hover, ";\n }\n\n ").concat(isDisabled ? "\n background: ".concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n &:hover {\n background: ").concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n }\n ") : '') : '', "\n "),
|
|
24
24
|
secondary: "\n background: transparent;\n border-color: ".concat(colors.primary, ";\n color: ").concat(colors.primary, ";\n &:hover {\n background: ").concat(colors.secondary, ";\n border-color: ").concat(colors.secondary, ";\n ").concat(makeColors(colors.white), "\n }\n\n ").concat(isDisabled ? "\n border-color: ".concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n &:hover {\n background: transparent\n border-color: ").concat(disabled.button, ";\n ").concat(makeColors(disabled.text), "\n }\n ") : '', "\n "),
|
|
25
25
|
tertiary: "\n background: transparent;\n border-color: transparent;\n color: ".concat(colors.primary, ";\n &:hover {\n ").concat(makeColors(colors.secondary), "\n }\n\n ").concat(isDisabled ? "\n color: ".concat(disabled.text, ";\n &:hover {\n ").concat(makeColors(disabled.text), "\n }\n ") : '', "\n "),
|
|
26
|
-
destructive: "\n background: ".concat(colors.error, ";\n border-color: transparent;\n color: ").concat(colors.white, ";\n &:hover {\n background: ").concat(colors.destructive.hover, ";\n }\n\n ").concat(isDisabled ? "\n background: ".concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n &:hover {\n background: ").concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n }\n ") : '', "\n "),
|
|
27
26
|
darkBackground: "\n background: ".concat(colors.white, ";\n border-color: transparent;\n color: ").concat(colors.primary, ";\n &:hover {\n background: ").concat(colors.secondary, ";\n ").concat(makeColors(colors.white), "\n }\n\n ").concat(isDisabled ? "\n background: ".concat(disabled.button, ";\n color: ").concat(disabled.text, ";\n &:hover {\n background: ").concat(disabled.button, ";\n ").concat(makeColors(disabled.text), "\n }\n ") : '', "\n ")
|
|
28
27
|
};
|
|
29
28
|
};
|
|
@@ -51,6 +51,8 @@ var _tags = _interopRequireDefault(require("../../utils/helpers/tags"));
|
|
|
51
51
|
|
|
52
52
|
var _optionsHelper = _interopRequireDefault(require("../../utils/helpers/options-helper"));
|
|
53
53
|
|
|
54
|
+
var _logger = _interopRequireDefault(require("../../utils/logger"));
|
|
55
|
+
|
|
54
56
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
55
57
|
|
|
56
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -86,8 +88,17 @@ var Button = function Button(props) {
|
|
|
86
88
|
buttonType = props.buttonType,
|
|
87
89
|
rest = _objectWithoutProperties(props, ["as", "buttonType"]);
|
|
88
90
|
|
|
91
|
+
var IS_USING_DEPRECATED_TYPE_DESTRUCTIVE = buttonType === 'destructive';
|
|
92
|
+
|
|
93
|
+
if (IS_USING_DEPRECATED_TYPE_DESTRUCTIVE) {
|
|
94
|
+
_logger.default.deprecate('buttonType="destructive" has been deprecated. See https://github.com/Sage/carbon/releases for details.');
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
var propsWithoutAs = _objectSpread({}, rest, {
|
|
90
98
|
buttonType: buttonType || as
|
|
99
|
+
}, IS_USING_DEPRECATED_TYPE_DESTRUCTIVE && {
|
|
100
|
+
buttonType: 'primary',
|
|
101
|
+
destructive: true
|
|
91
102
|
});
|
|
92
103
|
|
|
93
104
|
if (subtext.length > 0 && size !== 'large') {
|
|
@@ -166,7 +177,7 @@ function renderChildren(_ref) {
|
|
|
166
177
|
}
|
|
167
178
|
|
|
168
179
|
Button.propTypes = {
|
|
169
|
-
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "
|
|
180
|
+
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "darkBackground" */
|
|
170
181
|
buttonType: _propTypes.default.oneOf(_optionsHelper.default.buttonTypes),
|
|
171
182
|
|
|
172
183
|
/** The text the button displays */
|
|
@@ -175,6 +186,9 @@ Button.propTypes = {
|
|
|
175
186
|
/** Apply disabled state to the button */
|
|
176
187
|
disabled: _propTypes.default.bool,
|
|
177
188
|
|
|
189
|
+
/** Apply destructive style to the button */
|
|
190
|
+
destructive: _propTypes.default.bool,
|
|
191
|
+
|
|
178
192
|
/** Defines an Icon position within the button: "before" | "after" */
|
|
179
193
|
iconPosition: _propTypes.default.oneOf(_toConsumableArray(_optionsHelper.default.buttonIconPositions)),
|
|
180
194
|
|
|
@@ -207,6 +221,7 @@ Button.defaultProps = {
|
|
|
207
221
|
as: 'secondary',
|
|
208
222
|
size: 'medium',
|
|
209
223
|
disabled: false,
|
|
224
|
+
destructive: false,
|
|
210
225
|
iconPosition: 'before',
|
|
211
226
|
theme: 'blue',
|
|
212
227
|
subtext: ''
|
|
@@ -80,7 +80,8 @@ var getIconKnobs = function getIconKnobs() {
|
|
|
80
80
|
var getKnobs = function getKnobs(isClassic) {
|
|
81
81
|
var size = (0, _addonKnobs.select)('size', _optionsHelper.default.sizesRestricted, _.default.defaultProps.size);
|
|
82
82
|
var classicProps = {},
|
|
83
|
-
buttonType
|
|
83
|
+
buttonType,
|
|
84
|
+
destructive;
|
|
84
85
|
|
|
85
86
|
if (isClassic) {
|
|
86
87
|
classicProps = {
|
|
@@ -91,11 +92,13 @@ var getKnobs = function getKnobs(isClassic) {
|
|
|
91
92
|
};
|
|
92
93
|
} else {
|
|
93
94
|
buttonType = (0, _addonKnobs.select)('buttonType', _optionsHelper.default.buttonTypes, _.default.defaultProps.as);
|
|
95
|
+
destructive = (0, _addonKnobs.boolean)('destructive', false);
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
return _objectSpread({
|
|
97
99
|
buttonType: buttonType,
|
|
98
100
|
children: (0, _addonKnobs.text)('children', 'Example Button'),
|
|
101
|
+
destructive: destructive,
|
|
99
102
|
disabled: (0, _addonKnobs.boolean)('disabled', _.default.defaultProps.disabled),
|
|
100
103
|
onClick: function onClick(ev) {
|
|
101
104
|
return (0, _addonActions.action)('click')(ev);
|
|
@@ -21,9 +21,9 @@ Primary buttons can be destructive.
|
|
|
21
21
|
<Preview>
|
|
22
22
|
<Story name="primary/destructive" parameters={{ info: { disable: true }}} >
|
|
23
23
|
<>
|
|
24
|
-
<Button buttonType="
|
|
25
|
-
<Button buttonType="destructive
|
|
26
|
-
<Button buttonType="
|
|
24
|
+
<Button buttonType="primary" destructive size="small">Small</Button>
|
|
25
|
+
<Button buttonType="primary" destructive >Medium</Button>
|
|
26
|
+
<Button buttonType="primary" destructive size="large">Large</Button>
|
|
27
27
|
</>
|
|
28
28
|
</Story>
|
|
29
29
|
</Preview>
|
|
@@ -44,7 +44,7 @@ Primary buttons can have an icon positioned before or after the text.
|
|
|
44
44
|
<Story name="primary/icon" parameters={{ info: { disable: true }}} >
|
|
45
45
|
<>
|
|
46
46
|
<Button buttonType="primary" iconType="print">Medium</Button>
|
|
47
|
-
<Button buttonType="
|
|
47
|
+
<Button buttonType="primary" destructive iconType="delete" iconPosition="after">Medium</Button>
|
|
48
48
|
<Button buttonType="primary" disabled iconType="print" iconPosition="after">Medium</Button>
|
|
49
49
|
</>
|
|
50
50
|
</Story>
|
|
@@ -141,8 +141,9 @@ function stylingForType(_ref4) {
|
|
|
141
141
|
var disabled = _ref4.disabled,
|
|
142
142
|
buttonType = _ref4.buttonType,
|
|
143
143
|
theme = _ref4.theme,
|
|
144
|
-
size = _ref4.size
|
|
145
|
-
|
|
144
|
+
size = _ref4.size,
|
|
145
|
+
destructive = _ref4.destructive;
|
|
146
|
+
return (0, _styledComponents.css)(_templateObject4(), theme.colors.focus, (0, _buttonTypes.default)(theme, disabled, destructive)[buttonType], (0, _buttonSizes.default)(theme)[size]);
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
function isClassicButton(_ref5) {
|
|
@@ -11,7 +11,7 @@ var _storybookInfo = require("../../../../.storybook/style/storybook-info.styles
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
var Info = _react.default.createElement("div", null, _react.default.createElement("p", null, "A Button component."), _react.default.createElement(_storybookInfo.StoryHeader, null, "How to use the Button component:"), _react.default.createElement("p", null, 'Button is rendered as one of "primary", "secondary", "tertiary", "
|
|
14
|
+
var Info = _react.default.createElement("div", null, _react.default.createElement("p", null, "A Button component."), _react.default.createElement(_storybookInfo.StoryHeader, null, "How to use the Button component:"), _react.default.createElement("p", null, 'Button is rendered as one of "primary", "secondary", "tertiary", "darkBacground"'), _react.default.createElement("p", null, "In your file"), _react.default.createElement(_storybookInfo.StoryCode, {
|
|
15
15
|
padded: true
|
|
16
16
|
}, 'import Button from "carbon-react/lib/components/button";'), _react.default.createElement("p", null, "To render a Button:"), _react.default.createElement(_storybookInfo.StoryCode, {
|
|
17
17
|
padded: true
|
|
@@ -29,7 +29,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
29
29
|
|
|
30
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
31
|
|
|
32
|
-
var IconButton = function
|
|
32
|
+
var IconButton = _react.default.forwardRef(function (_ref, ref) {
|
|
33
33
|
var onAction = _ref.onAction,
|
|
34
34
|
children = _ref.children,
|
|
35
35
|
rest = _objectWithoutProperties(_ref, ["onAction", "children"]);
|
|
@@ -49,9 +49,10 @@ var IconButton = function IconButton(_ref) {
|
|
|
49
49
|
|
|
50
50
|
return _react.default.createElement(_iconButton.default, _extends({}, rest, {
|
|
51
51
|
onKeyDown: onKeyDown,
|
|
52
|
-
onClick: handleOnAction
|
|
52
|
+
onClick: handleOnAction,
|
|
53
|
+
ref: ref
|
|
53
54
|
}), children);
|
|
54
|
-
};
|
|
55
|
+
});
|
|
55
56
|
|
|
56
57
|
IconButton.propTypes = {
|
|
57
58
|
/** Children prop is restricted to one Icon Component */
|
|
@@ -34,7 +34,7 @@ function _templateObject2() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function _templateObject() {
|
|
37
|
-
var data = _taggedTemplateLiteral(["\n background: transparent;\n border: none;\n padding: 0;\n\n ", "\n\n &:hover {\n cursor: pointer;\n }\n\n ", " {\n position: relative;\n\n &:focus {\n border: none;\n }\n }\n\n
|
|
37
|
+
var data = _taggedTemplateLiteral(["\n background: transparent;\n border: none;\n padding: 0;\n\n ", "\n\n &:hover {\n cursor: pointer;\n }\n\n ", " {\n position: relative;\n\n &:focus {\n border: none;\n }\n }\n\n ", ";\n"]);
|
|
38
38
|
|
|
39
39
|
_templateObject = function _templateObject() {
|
|
40
40
|
return data;
|
|
@@ -26,7 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
26
26
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
27
27
|
|
|
28
28
|
function _templateObject2() {
|
|
29
|
-
var data = _taggedTemplateLiteral(["\n
|
|
29
|
+
var data = _taggedTemplateLiteral(["\n border: none;\n background: transparent;\n "]);
|
|
30
30
|
|
|
31
31
|
_templateObject2 = function _templateObject2() {
|
|
32
32
|
return data;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _settingsPopover.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _settingsPopover = _interopRequireDefault(require("./settings-popover.component"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.symbol.description");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.symbol.iterator");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.array.iterator");
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/es.object.get-own-property-descriptor");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.object.to-string");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.string.iterator");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/web.dom-collections.iterator");
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(exports, "__esModule", {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
exports.default = void 0;
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
25
|
+
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
+
|
|
28
|
+
var _reactTransitionGroup = require("react-transition-group");
|
|
29
|
+
|
|
30
|
+
var _popoverContainer = require("./popover-container.style");
|
|
31
|
+
|
|
32
|
+
var _icon = _interopRequireDefault(require("../icon"));
|
|
33
|
+
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
+
|
|
36
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
37
|
+
|
|
38
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
39
|
+
|
|
40
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
41
|
+
|
|
42
|
+
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
43
|
+
|
|
44
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
|
+
|
|
46
|
+
var PopoverContainer = function PopoverContainer(_ref) {
|
|
47
|
+
var children = _ref.children,
|
|
48
|
+
iconType = _ref.iconType,
|
|
49
|
+
title = _ref.title,
|
|
50
|
+
position = _ref.position;
|
|
51
|
+
|
|
52
|
+
var _useState = (0, _react.useState)(false),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
isOpen = _useState2[0],
|
|
55
|
+
setOpen = _useState2[1];
|
|
56
|
+
|
|
57
|
+
var iconRef = (0, _react.useRef)();
|
|
58
|
+
var closeIconRef = (0, _react.useRef)();
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
if (isOpen) closeIconRef.current.focus();
|
|
61
|
+
}, [isOpen]);
|
|
62
|
+
|
|
63
|
+
var handleOpen = function handleOpen() {
|
|
64
|
+
setOpen(true);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var handleClose = function handleClose() {
|
|
68
|
+
setOpen(false);
|
|
69
|
+
iconRef.current.focus();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return _react.default.createElement(_popoverContainer.PopoverContainerWrapperStyle, {
|
|
73
|
+
"data-component": "popover-container"
|
|
74
|
+
}, _react.default.createElement(_popoverContainer.PopoverContainerIcon, {
|
|
75
|
+
ref: iconRef,
|
|
76
|
+
"data-element": "popover-container-icon",
|
|
77
|
+
tabIndex: isOpen ? -1 : 0,
|
|
78
|
+
onAction: handleOpen
|
|
79
|
+
}, _react.default.createElement(_icon.default, {
|
|
80
|
+
type: iconType
|
|
81
|
+
})), _react.default.createElement(_reactTransitionGroup.Transition, {
|
|
82
|
+
in: isOpen,
|
|
83
|
+
timeout: {
|
|
84
|
+
exit: 300
|
|
85
|
+
},
|
|
86
|
+
appear: true,
|
|
87
|
+
mountOnEnter: true,
|
|
88
|
+
unmountOnExit: true
|
|
89
|
+
}, function (state) {
|
|
90
|
+
return _react.default.createElement(_popoverContainer.PopoverContainerContentStyle, {
|
|
91
|
+
"data-element": "popover-container-content",
|
|
92
|
+
animationState: state,
|
|
93
|
+
position: position
|
|
94
|
+
}, _react.default.createElement(_popoverContainer.PopoverContainerHeaderStyle, null, _react.default.createElement(_popoverContainer.PopoverContainerTitle, {
|
|
95
|
+
"data-element": "popover-container-title"
|
|
96
|
+
}, title), _react.default.createElement(_popoverContainer.PopoverContainerCloseIcon, {
|
|
97
|
+
"data-element": "popover-container-close-icon",
|
|
98
|
+
type: "close",
|
|
99
|
+
tabIndex: "0",
|
|
100
|
+
onAction: handleClose,
|
|
101
|
+
ref: closeIconRef
|
|
102
|
+
}, _react.default.createElement(_icon.default, {
|
|
103
|
+
type: "close"
|
|
104
|
+
}))), children);
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
PopoverContainer.propTypes = {
|
|
109
|
+
/** Sets the popover container dialog header name */
|
|
110
|
+
title: _propTypes.default.string.isRequired,
|
|
111
|
+
|
|
112
|
+
/** Sets the icon that opens dialog */
|
|
113
|
+
iconType: _propTypes.default.string.isRequired,
|
|
114
|
+
|
|
115
|
+
/** Sets rendering position of dialog */
|
|
116
|
+
position: _propTypes.default.oneOf(['left', 'right']),
|
|
117
|
+
children: _propTypes.default.node
|
|
118
|
+
};
|
|
119
|
+
var _default = PopoverContainer;
|
|
120
|
+
exports.default = _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { AlignBinaryType } from '../../utils/helpers/options-helper/options-helper';
|
|
4
|
+
|
|
5
|
+
export interface PopoverContainerProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** Sets rendering position of dialog */
|
|
8
|
+
position?: AlignBinaryType;
|
|
9
|
+
/** Sets the popover container dialog header name */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Sets the icon that opens dialog */
|
|
12
|
+
iconType: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const PopoverContainer: React.FunctionComponent<PopoverContainerProps>;
|
|
16
|
+
|
|
17
|
+
export default PopoverContainer;
|