linear-react-components-ui 0.4.77-beta.26 → 0.4.77-beta.28
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/.eslintrc.json +3 -76
- package/.husky/pre-commit +4 -0
- package/.vscode/settings.json +2 -2
- package/jest.config.js +3 -3
- package/lib/alerts/AlertContainer.js +19 -14
- package/lib/alerts/AlertProvider.js +9 -4
- package/lib/alerts/BaseAlert.js +8 -5
- package/lib/alerts/Message.js +40 -31
- package/lib/alerts/alert.spec.js +55 -32
- package/lib/alerts/helpers.js +5 -2
- package/lib/alerts/withAlert.js +2 -2
- package/lib/assets/styles/commons.scss +10 -0
- package/lib/assets/styles/dropdown.scss +36 -2
- package/lib/assets/styles/effects.scss +11 -0
- package/lib/assets/styles/list.scss +8 -0
- package/lib/assets/styles/table.scss +2 -7
- package/lib/avatar/avatar.spec.js +74 -42
- package/lib/avatar/index.js +58 -13
- package/lib/badge/badge.spec.js +52 -30
- package/lib/badge/index.js +22 -6
- package/lib/buttons/ActivateButton.js +3 -3
- package/lib/buttons/AddButton.js +1 -1
- package/lib/buttons/Button.js +11 -19
- package/lib/buttons/ButtonGroups.js +5 -0
- package/lib/buttons/CancelButton.js +3 -16
- package/lib/buttons/DangerButton.js +19 -14
- package/lib/buttons/DefaultButton.js +127 -65
- package/lib/buttons/DestroyButton.js +3 -12
- package/lib/buttons/EditButton.js +3 -3
- package/lib/buttons/InactivateButton.js +3 -3
- package/lib/buttons/InfoButton.js +19 -14
- package/lib/buttons/PrimaryButton.js +19 -14
- package/lib/buttons/RestoreButton.js +3 -3
- package/lib/buttons/SaveButton.js +2 -15
- package/lib/buttons/SpinnerLoading.js +41 -41
- package/lib/buttons/SuccessButton.js +18 -13
- package/lib/buttons/WarningButton.js +18 -13
- package/lib/buttons/button_container/index.js +18 -5
- package/lib/buttons/buttons.spec.js +210 -136
- package/lib/buttons/index.js +28 -28
- package/lib/buttons/split_button/index.js +30 -13
- package/lib/calendar/DangerCalendar.js +2 -11
- package/lib/calendar/InfoCalendar.js +2 -11
- package/lib/calendar/PrimaryCalendar.js +2 -11
- package/lib/calendar/SuccessCalendar.js +2 -11
- package/lib/calendar/WarningCalendar.js +2 -11
- package/lib/calendar/base/Day.js +8 -2
- package/lib/calendar/base/Month.js +5 -0
- package/lib/calendar/base/Week.js +6 -0
- package/lib/calendar/base/helpers.js +9 -9
- package/lib/calendar/base/index.js +36 -33
- package/lib/calendar/calendar.spec.js +63 -32
- package/lib/calendar/index.js +10 -10
- package/lib/checkbox/Label.js +12 -2
- package/lib/checkbox/checkbox.spec.js +78 -37
- package/lib/checkbox/index.js +79 -42
- package/lib/dialog/Alert.js +8 -3
- package/lib/dialog/Custom.js +25 -17
- package/lib/dialog/Error.js +6 -1
- package/lib/dialog/Information.js +6 -1
- package/lib/dialog/Question.js +17 -6
- package/lib/dialog/Warning.js +6 -1
- package/lib/dialog/base/Content.js +9 -0
- package/lib/dialog/base/Footer.js +8 -2
- package/lib/dialog/base/Header.js +22 -8
- package/lib/dialog/base/index.js +28 -6
- package/lib/dialog/dialog.spec.js +153 -79
- package/lib/dialog/form/index.js +32 -22
- package/lib/dialog/index.js +6 -6
- package/lib/drawer/Content.js +10 -1
- package/lib/drawer/Drawer.js +50 -29
- package/lib/drawer/Drawer.spec.js +95 -52
- package/lib/drawer/Header.js +31 -12
- package/lib/drawer/helpers.js +1 -1
- package/lib/drawer/index.js +4 -4
- package/lib/dropdown/Popup.js +16 -32
- package/lib/dropdown/dropdown.spec.js +58 -34
- package/lib/dropdown/helper.js +2 -2
- package/lib/dropdown/withDropdown.js +43 -18
- package/lib/fieldset/fieldset.spec.js +123 -77
- package/lib/fieldset/index.js +43 -12
- package/lib/form/Field.js +41 -14
- package/lib/form/FieldArray.js +50 -20
- package/lib/form/FieldNumber.js +44 -12
- package/lib/form/FieldPeriod.js +41 -19
- package/lib/form/form.spec.js +90 -48
- package/lib/form/helpers.js +16 -10
- package/lib/form/index.js +92 -57
- package/lib/form/withFieldHOC.js +120 -40
- package/lib/form/withFormSecurity.js +38 -17
- package/lib/gridlayout/GridCol.js +18 -3
- package/lib/gridlayout/GridRow.js +24 -4
- package/lib/gridlayout/gridLayout.spec.js +70 -43
- package/lib/icons/helper.js +571 -560
- package/lib/icons/icons.spec.js +36 -20
- package/lib/icons/index.js +40 -23
- package/lib/index.js +12 -12
- package/lib/inputs/base/InputTextBase.js +149 -40
- package/lib/inputs/base/base.spec.js +289 -174
- package/lib/inputs/base/helpers.js +4 -4
- package/lib/inputs/color/color_input.spec.js +67 -33
- package/lib/inputs/color/index.js +29 -31
- package/lib/inputs/date/Dialog.js +8 -1
- package/lib/inputs/date/Dropdown.js +70 -18
- package/lib/inputs/date/date.spec.js +156 -75
- package/lib/inputs/date/helpers.js +1 -1
- package/lib/inputs/date/index.js +411 -255
- package/lib/inputs/inputHOC.js +96 -44
- package/lib/inputs/mask/BaseMask.js +45 -16
- package/lib/inputs/mask/Cnpj.js +19 -12
- package/lib/inputs/mask/Cpf.js +22 -14
- package/lib/inputs/mask/Phone.js +9 -1
- package/lib/inputs/mask/ZipCode.js +1 -1
- package/lib/inputs/mask/helpers.js +36 -21
- package/lib/inputs/mask/imaskHOC.js +255 -186
- package/lib/inputs/mask/index.js +4 -4
- package/lib/inputs/mask/input_mask.spec.js +290 -177
- package/lib/inputs/multiSelect/ActionButtons.js +14 -2
- package/lib/inputs/multiSelect/Dropdown.js +70 -43
- package/lib/inputs/multiSelect/index.js +80 -64
- package/lib/inputs/number/BaseNumber.js +62 -27
- package/lib/inputs/number/Currency.js +14 -4
- package/lib/inputs/number/format_number.js +1 -1
- package/lib/inputs/number/index.js +15 -9
- package/lib/inputs/number/numberfield.spec.js +83 -42
- package/lib/inputs/period/Dialog.js +8 -1
- package/lib/inputs/period/Dropdown.js +70 -16
- package/lib/inputs/period/PeriodList.js +19 -6
- package/lib/inputs/period/helper.js +71 -30
- package/lib/inputs/period/index.js +160 -112
- package/lib/inputs/search/index.js +261 -129
- package/lib/inputs/search/search_input.spec.js +86 -46
- package/lib/inputs/select/ActionButtons.js +20 -14
- package/lib/inputs/select/Dropdown.js +63 -30
- package/lib/inputs/select/helper.js +16 -18
- package/lib/inputs/select/index.js +13 -14
- package/lib/inputs/select/multiple/Selecteds.js +13 -5
- package/lib/inputs/select/multiple/index.js +414 -289
- package/lib/inputs/select/select.spec.js +182 -127
- package/lib/inputs/select/simple/index.js +462 -305
- package/lib/inputs/select/types.d.ts +4 -0
- package/lib/inputs/text/index.js +0 -1
- package/lib/inputs/text/textfield.spec.js +83 -42
- package/lib/inputs/textarea/index.js +15 -5
- package/lib/inputs/textarea/textarea.spec.js +27 -14
- package/lib/internals/constants.js +1 -1
- package/lib/internals/withTooltip.js +34 -26
- package/lib/labelMessages/index.js +45 -27
- package/lib/labelMessages/labelMessages.spec.js +61 -28
- package/lib/labels/DangerLabel.js +4 -13
- package/lib/labels/DefaultLabel.js +57 -25
- package/lib/labels/InfoLabel.js +4 -13
- package/lib/labels/PrimaryLabel.js +4 -13
- package/lib/labels/SuccessLabel.js +4 -13
- package/lib/labels/WarningLabel.js +4 -13
- package/lib/labels/index.js +10 -10
- package/lib/labels/label.spec.js +68 -41
- package/lib/labels/label_container/index.js +12 -2
- package/lib/list/Header.js +13 -0
- package/lib/list/Item.js +65 -27
- package/lib/list/helpers.js +2 -2
- package/lib/list/index.js +51 -31
- package/lib/list/list.spec.js +358 -211
- package/lib/menus/float/MenuItem.js +42 -10
- package/lib/menus/float/SubMenuContainer.js +95 -0
- package/lib/menus/float/float-menu.spec.js +61 -27
- package/lib/menus/float/helpers.js +1 -1
- package/lib/menus/float/index.js +39 -9
- package/lib/menus/sidenav/ExpandMenu.js +13 -1
- package/lib/menus/sidenav/MenuLink.js +14 -0
- package/lib/menus/sidenav/NavMenuGroup.js +12 -1
- package/lib/menus/sidenav/NavMenuItem.js +45 -19
- package/lib/menus/sidenav/NavSubMenuItem.js +15 -4
- package/lib/menus/sidenav/helpers.js +3 -3
- package/lib/menus/sidenav/index.js +60 -30
- package/lib/menus/sidenav/popup_menu_search/EmptyList.js +11 -2
- package/lib/menus/sidenav/popup_menu_search/index.js +11 -14
- package/lib/menus/sidenav/sidenav.spec.js +78 -29
- package/lib/panel/Content.js +18 -6
- package/lib/panel/DangerPanel.js +1 -1
- package/lib/panel/Default.js +45 -18
- package/lib/panel/Header.js +29 -7
- package/lib/panel/InfoPanel.js +1 -1
- package/lib/panel/PrimaryPanel.js +1 -1
- package/lib/panel/SuccessPanel.js +1 -1
- package/lib/panel/ToolBar.js +5 -0
- package/lib/panel/WarningPanel.js +1 -1
- package/lib/panel/helpers.js +3 -7
- package/lib/panel/index.js +14 -14
- package/lib/panel/panel.spec.js +106 -69
- package/lib/permissionValidations.js +12 -14
- package/lib/popover/PopoverText.js +5 -0
- package/lib/popover/PopoverTitle.js +5 -0
- package/lib/popover/index.js +40 -26
- package/lib/popover/popover.spec.js +70 -40
- package/lib/progress/Bar.js +47 -37
- package/lib/progress/index.js +18 -8
- package/lib/progress/progress.spec.js +48 -32
- package/lib/radio/index.js +46 -22
- package/lib/radio/radio.spec.js +68 -41
- package/lib/skeleton/SkeletonContainer.js +13 -0
- package/lib/skeleton/index.js +26 -7
- package/lib/spinner/SpinnerLoading.js +12 -4
- package/lib/spinner/index.js +29 -24
- package/lib/spinner/spinner.spec.js +65 -43
- package/lib/split/Split.js +62 -45
- package/lib/split/SplitSide.js +21 -1
- package/lib/split/helpers.js +1 -1
- package/lib/split/split.spec.js +76 -51
- package/lib/table/Body.js +16 -9
- package/lib/table/Header.js +19 -40
- package/lib/table/HeaderColumn.js +20 -6
- package/lib/table/Row.js +28 -7
- package/lib/table/RowColumn.js +30 -12
- package/lib/table/helpers.js +3 -3
- package/lib/table/index.js +53 -15
- package/lib/table/table.spec.js +149 -94
- package/lib/tabs/DropdownItems.js +53 -39
- package/lib/tabs/Menu.js +20 -16
- package/lib/tabs/MenuItems.js +39 -25
- package/lib/tabs/Panel.js +51 -18
- package/lib/tabs/index.js +75 -81
- package/lib/tabs/tabHelpers.js +8 -10
- package/lib/tabs/tabs.spec.js +158 -95
- package/lib/toolbar/ButtonBar.js +13 -32
- package/lib/toolbar/LabelBar.js +18 -31
- package/lib/toolbar/ToolBarGroup.js +12 -6
- package/lib/toolbar/helpers.js +1 -1
- package/lib/toolbar/index.js +33 -25
- package/lib/toolbar/toolbar.spec.js +182 -134
- package/lib/tooltip/index.js +34 -25
- package/lib/tooltip/tooltip.spec.js +51 -24
- package/lib/treeview/Header.js +12 -0
- package/lib/treeview/Node.js +387 -261
- package/lib/treeview/constants.js +2 -1
- package/lib/treeview/index.js +548 -363
- package/lib/treeview/treeview.spec.js +86 -49
- package/lib/treeview_old/Node.js +6 -6
- package/lib/uitour/helpers.js +1 -1
- package/lib/uitour/index.js +32 -15
- package/lib/uitour/uitour.spec.js +77 -55
- package/package.json +16 -40
- package/.husky/pre-push +0 -4
- package/babel.config.json +0 -11
- package/dist/main.js +0 -14
- package/lib/assets/styles/treetable.scss +0 -100
- package/lib/treetable/Body.js +0 -46
- package/lib/treetable/Header.js +0 -27
- package/lib/treetable/Row.js +0 -261
- package/lib/treetable/helpers.js +0 -41
- package/lib/treetable/index.js +0 -24
- package/lib/treetable/types.d.js +0 -5
- package/tsconfig.json +0 -32
- package/tsup.config.ts +0 -10
package/.eslintrc.json
CHANGED
|
@@ -6,94 +6,21 @@
|
|
|
6
6
|
},
|
|
7
7
|
"parser": "babel-eslint",
|
|
8
8
|
"rules": {
|
|
9
|
-
"indent": "off",
|
|
10
|
-
"no-undef": "off",
|
|
11
|
-
"radix": "off",
|
|
12
9
|
"prefer-destructuring": ["error", {"object": true, "array": false}],
|
|
13
10
|
"react/forbid-prop-types": ["error", { "forbid": ["array"] }],
|
|
14
11
|
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
15
12
|
"react/jsx-closing-bracket-location": ["error", "after-props"],
|
|
16
|
-
"react/no-unused-prop-types": [0],
|
|
13
|
+
"react/no-unused-prop-types": ["0"],
|
|
17
14
|
"jsx-a11y/anchor-is-valid": [ "error", {
|
|
18
15
|
"components": [ "Link" ],
|
|
19
16
|
"specialLink": [ "hrefLeft", "hrefRight" ],
|
|
20
17
|
"aspects": ["preferButton" ]
|
|
21
18
|
}],
|
|
22
|
-
"jsx-a11y/no-autofocus": [0],
|
|
19
|
+
"jsx-a11y/no-autofocus": ["0"],
|
|
23
20
|
"object-curly-newline": [0],
|
|
24
|
-
"jsx-a11y/label-has-for": [0]
|
|
25
|
-
"import/extensions": [
|
|
26
|
-
"error",
|
|
27
|
-
"ignorePackages",
|
|
28
|
-
{
|
|
29
|
-
"ts": "never",
|
|
30
|
-
"tsx": "never",
|
|
31
|
-
"js": "never",
|
|
32
|
-
"jsx": "never"
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
"settings": {
|
|
37
|
-
"import/resolver": {
|
|
38
|
-
"node": {
|
|
39
|
-
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
21
|
+
"jsx-a11y/label-has-for": [0]
|
|
42
22
|
},
|
|
43
23
|
"plugins": [
|
|
44
|
-
"react",
|
|
45
24
|
"class-property"
|
|
46
|
-
],
|
|
47
|
-
"overrides": [
|
|
48
|
-
{
|
|
49
|
-
"files": ["**/*.ts", "**/*.tsx"],
|
|
50
|
-
"env": {
|
|
51
|
-
"browser": true,
|
|
52
|
-
"jest": true
|
|
53
|
-
},
|
|
54
|
-
"extends": [
|
|
55
|
-
"eslint:recommended",
|
|
56
|
-
"airbnb",
|
|
57
|
-
"airbnb-typescript/base",
|
|
58
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
59
|
-
"plugin:@typescript-eslint/recommended"
|
|
60
|
-
],
|
|
61
|
-
"parser": "@typescript-eslint/parser",
|
|
62
|
-
"parserOptions": {
|
|
63
|
-
"ecmaFeatures": { "jsx": true },
|
|
64
|
-
"ecmaVersion": 2021,
|
|
65
|
-
"sourceType": "module",
|
|
66
|
-
"project": ["./tsconfig.json", "./images.d.ts"]
|
|
67
|
-
},
|
|
68
|
-
"plugins": ["react", "@typescript-eslint", "class-property"],
|
|
69
|
-
"rules": {
|
|
70
|
-
"react/jsx-indent": "off",
|
|
71
|
-
"react/jsx-uses-react": "off",
|
|
72
|
-
"react/react-in-jsx-scope": "off",
|
|
73
|
-
"@typescript-eslint/indent": ["error", 2],
|
|
74
|
-
"import/prefer-default-export": [0],
|
|
75
|
-
"react/jsx-filename-extension": [1, { "extensions": [".ts", ".tsx"] }],
|
|
76
|
-
"prefer-destructuring": ["error", {"object": true, "array": false}],
|
|
77
|
-
"react/forbid-prop-types": ["error", { "forbid": ["array"] }],
|
|
78
|
-
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
79
|
-
"react/jsx-closing-bracket-location": ["error", "after-props"],
|
|
80
|
-
"react/no-unused-prop-types": [0],
|
|
81
|
-
"jsx-a11y/heading-has-content": "off",
|
|
82
|
-
"jsx-a11y/anchor-has-content": "off",
|
|
83
|
-
"jsx-a11y/anchor-is-valid": [ "error", {
|
|
84
|
-
"components": [ "Link" ],
|
|
85
|
-
"specialLink": [ "hrefLeft", "hrefRight" ],
|
|
86
|
-
"aspects": ["preferButton" ]
|
|
87
|
-
}],
|
|
88
|
-
"jsx-a11y/no-autofocus": [0],
|
|
89
|
-
"object-curly-newline": [0],
|
|
90
|
-
"jsx-a11y/label-has-for": [0]
|
|
91
|
-
},
|
|
92
|
-
"settings": {
|
|
93
|
-
"import/resolver": {
|
|
94
|
-
"typescript": {}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
25
|
]
|
|
99
26
|
}
|
package/.vscode/settings.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files.exclude": {
|
|
3
|
-
|
|
3
|
+
"config": true,
|
|
4
4
|
"coverage": true,
|
|
5
5
|
"node_modules": true,
|
|
6
6
|
"scripts": true,
|
|
7
7
|
"yarn.lock": true,
|
|
8
8
|
".eslintrc.js": true,
|
|
9
|
-
|
|
9
|
+
".gitignore": true,
|
|
10
10
|
},
|
|
11
11
|
"editor.codeActionsOnSave": {
|
|
12
12
|
"source.fixAll.eslint": true
|
package/jest.config.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
roots: ['<rootDir>'],
|
|
3
3
|
transform: {
|
|
4
|
-
'\\.(js|jsx
|
|
4
|
+
'\\.(js|jsx)?$': 'babel-jest',
|
|
5
5
|
},
|
|
6
6
|
testMatch: [
|
|
7
|
-
'<rootDir>/src/**/?(*.)(spec|test).{js,jsx,
|
|
7
|
+
'<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}',
|
|
8
8
|
],
|
|
9
|
-
moduleFileExtensions: ['js', 'jsx', '
|
|
9
|
+
moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
|
|
10
10
|
testPathIgnorePatterns: ['/node_modules/', '/public/'],
|
|
11
11
|
setupFilesAfterEnv: [
|
|
12
12
|
'@testing-library/jest-dom/extend-expect',
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
function _extends() { _extends = Object.assign
|
|
8
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
9
9
|
|
|
10
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
11
|
|
|
12
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
13
13
|
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps);
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
15
15
|
|
|
16
16
|
var AlertContainer = /*#__PURE__*/function () {
|
|
17
17
|
function AlertContainer(pushAlert) {
|
|
@@ -19,17 +19,13 @@ var AlertContainer = /*#__PURE__*/function () {
|
|
|
19
19
|
|
|
20
20
|
_classCallCheck(this, AlertContainer);
|
|
21
21
|
|
|
22
|
-
Object.defineProperty(this, "pushAlert", {
|
|
23
|
-
configurable: true,
|
|
24
|
-
enumerable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: void 0
|
|
27
|
-
});
|
|
28
22
|
Object.defineProperty(this, "info", {
|
|
29
23
|
configurable: true,
|
|
30
24
|
enumerable: true,
|
|
31
25
|
writable: true,
|
|
32
|
-
value: function value(message
|
|
26
|
+
value: function value(message) {
|
|
27
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
|
|
33
29
|
var messageConfig = _extends({}, options, {
|
|
34
30
|
customClass: '-info',
|
|
35
31
|
message: message,
|
|
@@ -44,7 +40,9 @@ var AlertContainer = /*#__PURE__*/function () {
|
|
|
44
40
|
configurable: true,
|
|
45
41
|
enumerable: true,
|
|
46
42
|
writable: true,
|
|
47
|
-
value: function value(message
|
|
43
|
+
value: function value(message) {
|
|
44
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45
|
+
|
|
48
46
|
var messageConfig = _extends({}, options, {
|
|
49
47
|
customClass: '-danger',
|
|
50
48
|
message: message,
|
|
@@ -59,7 +57,9 @@ var AlertContainer = /*#__PURE__*/function () {
|
|
|
59
57
|
configurable: true,
|
|
60
58
|
enumerable: true,
|
|
61
59
|
writable: true,
|
|
62
|
-
value: function value(message
|
|
60
|
+
value: function value(message) {
|
|
61
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
62
|
+
|
|
63
63
|
var messageConfig = _extends({}, options, {
|
|
64
64
|
customClass: '-warning',
|
|
65
65
|
message: message,
|
|
@@ -74,7 +74,9 @@ var AlertContainer = /*#__PURE__*/function () {
|
|
|
74
74
|
configurable: true,
|
|
75
75
|
enumerable: true,
|
|
76
76
|
writable: true,
|
|
77
|
-
value: function value(message
|
|
77
|
+
value: function value(message) {
|
|
78
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
79
|
+
|
|
78
80
|
var messageConfig = _extends({}, options, {
|
|
79
81
|
customClass: '-success',
|
|
80
82
|
message: message,
|
|
@@ -89,7 +91,9 @@ var AlertContainer = /*#__PURE__*/function () {
|
|
|
89
91
|
configurable: true,
|
|
90
92
|
enumerable: true,
|
|
91
93
|
writable: true,
|
|
92
|
-
value: function value(message
|
|
94
|
+
value: function value(message) {
|
|
95
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
96
|
+
|
|
93
97
|
var messageConfig = _extends({}, options, {
|
|
94
98
|
message: message
|
|
95
99
|
});
|
|
@@ -102,7 +106,8 @@ var AlertContainer = /*#__PURE__*/function () {
|
|
|
102
106
|
|
|
103
107
|
_createClass(AlertContainer, [{
|
|
104
108
|
key: "default",
|
|
105
|
-
value: function _default(
|
|
109
|
+
value: function _default() {
|
|
110
|
+
var messageConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
106
111
|
var message = messageConfig.message,
|
|
107
112
|
options = messageConfig.options;
|
|
108
113
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -11,6 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
13
|
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
14
16
|
var _BaseAlert = _interopRequireDefault(require("./BaseAlert"));
|
|
15
17
|
|
|
16
18
|
var _AlertContainer = _interopRequireDefault(require("./AlertContainer"));
|
|
@@ -25,7 +27,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
27
|
|
|
26
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
29
|
|
|
28
|
-
function _extends() { _extends = Object.assign
|
|
30
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
29
31
|
|
|
30
32
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
31
33
|
|
|
@@ -35,7 +37,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
35
37
|
|
|
36
38
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
37
39
|
|
|
38
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr
|
|
40
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
|
|
39
41
|
|
|
40
42
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
43
|
|
|
@@ -105,12 +107,15 @@ var AlertProvider = function AlertProvider(props) {
|
|
|
105
107
|
});
|
|
106
108
|
|
|
107
109
|
return /*#__PURE__*/_react.default.createElement(_helpers.default.Provider, {
|
|
108
|
-
value:
|
|
110
|
+
value: contextValues
|
|
109
111
|
}, /*#__PURE__*/_react.default.createElement(_BaseAlert.default, null, elements), children);
|
|
110
112
|
};
|
|
111
113
|
|
|
112
114
|
return _react.Children.only(renderBaseContainer());
|
|
113
115
|
};
|
|
114
116
|
|
|
117
|
+
AlertProvider.propTypes = {
|
|
118
|
+
children: _propTypes.default.object.isRequired
|
|
119
|
+
};
|
|
115
120
|
var _default = AlertProvider;
|
|
116
121
|
exports.default = _default;
|
package/lib/alerts/BaseAlert.js
CHANGED
|
@@ -9,6 +9,8 @@ var _react = require("react");
|
|
|
9
9
|
|
|
10
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
11
|
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
12
14
|
require("../assets/styles/alerts.scss");
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -21,7 +23,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
21
23
|
|
|
22
24
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
25
|
|
|
24
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr
|
|
26
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
|
|
25
27
|
|
|
26
28
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
29
|
|
|
@@ -42,16 +44,17 @@ var BaseAlert = function BaseAlert(_ref) {
|
|
|
42
44
|
alertComponentEl.className = 'alert-component';
|
|
43
45
|
body.appendChild(alertComponentEl);
|
|
44
46
|
alertComponentEl.appendChild(messageContainerEl);
|
|
45
|
-
} else
|
|
46
|
-
alert.appendChild(messageContainerEl);
|
|
47
|
-
}
|
|
47
|
+
} else alert.appendChild(messageContainerEl);
|
|
48
48
|
|
|
49
49
|
return function () {
|
|
50
|
-
alert
|
|
50
|
+
if (alert !== null) alert.removeChild(messageContainerEl);
|
|
51
51
|
};
|
|
52
52
|
}, []);
|
|
53
53
|
return /*#__PURE__*/_reactDom.default.createPortal(children, messageContainerEl);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
BaseAlert.propTypes = {
|
|
57
|
+
children: _propTypes.default.arrayOf(_propTypes.default.object).isRequired
|
|
58
|
+
};
|
|
56
59
|
var _default = BaseAlert;
|
|
57
60
|
exports.default = _default;
|
package/lib/alerts/Message.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -9,7 +9,9 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _icons = _interopRequireDefault(require("./../icons"));
|
|
13
15
|
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
17
|
|
|
@@ -37,40 +39,25 @@ var getIcon = function getIcon(icon, iconName, color) {
|
|
|
37
39
|
return null;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
|
-
var Message = function Message(
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_ref2$iconName = _ref2.iconName,
|
|
51
|
-
iconName = _ref2$iconName === void 0 ? '' : _ref2$iconName,
|
|
52
|
-
_ref2$timeout = _ref2.timeout,
|
|
53
|
-
timeout = _ref2$timeout === void 0 ? 3000 : _ref2$timeout,
|
|
54
|
-
_ref2$customClass = _ref2.customClass,
|
|
55
|
-
customClass = _ref2$customClass === void 0 ? '' : _ref2$customClass,
|
|
56
|
-
_ref2$closeButton = _ref2.closeButton,
|
|
57
|
-
closeButton = _ref2$closeButton === void 0 ? false : _ref2$closeButton,
|
|
58
|
-
_ref2$className = _ref2.className,
|
|
59
|
-
className = _ref2$className === void 0 ? 'message' : _ref2$className,
|
|
60
|
-
_ref2$position = _ref2.position,
|
|
61
|
-
position = _ref2$position === void 0 ? 'centerTop' : _ref2$position;
|
|
42
|
+
var Message = function Message(props) {
|
|
43
|
+
var handleClose = props.handleClose,
|
|
44
|
+
icon = props.icon,
|
|
45
|
+
iconName = props.iconName,
|
|
46
|
+
color = props.color,
|
|
47
|
+
message = props.message,
|
|
48
|
+
closeButton = props.closeButton,
|
|
49
|
+
timeout = props.timeout,
|
|
50
|
+
id = props.id,
|
|
51
|
+
position = props.position;
|
|
62
52
|
(0, _react.useEffect)(function () {
|
|
63
53
|
if (timeout > 0) {
|
|
64
54
|
setTimeout(function () {
|
|
65
|
-
handleClose(id, position);
|
|
55
|
+
return handleClose(id, position);
|
|
66
56
|
}, timeout);
|
|
67
57
|
}
|
|
68
58
|
}, []);
|
|
69
59
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
70
|
-
className: getClass(
|
|
71
|
-
className: className,
|
|
72
|
-
customClass: customClass
|
|
73
|
-
})
|
|
60
|
+
className: getClass(props)
|
|
74
61
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
75
62
|
className: "-icon"
|
|
76
63
|
}, (icon || iconName || color) && getIcon(icon, iconName, color)), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -80,13 +67,35 @@ var Message = function Message(_ref2) {
|
|
|
80
67
|
}, closeButton || timeout === 0 ? /*#__PURE__*/_react.default.createElement("span", {
|
|
81
68
|
className: "close-button",
|
|
82
69
|
role: "button",
|
|
83
|
-
onKeyPress:
|
|
84
|
-
tabIndex: -1,
|
|
70
|
+
onKeyPress: null,
|
|
71
|
+
tabIndex: "-1",
|
|
85
72
|
onClick: function onClick() {
|
|
86
73
|
return handleClose !== undefined ? handleClose(id, position) : null;
|
|
87
74
|
}
|
|
88
75
|
}, "x") : null));
|
|
89
76
|
};
|
|
90
77
|
|
|
78
|
+
Message.defaultProps = {
|
|
79
|
+
className: 'message',
|
|
80
|
+
closeButton: false,
|
|
81
|
+
color: '',
|
|
82
|
+
customClass: '',
|
|
83
|
+
icon: null,
|
|
84
|
+
iconName: '',
|
|
85
|
+
timeout: 3000
|
|
86
|
+
};
|
|
87
|
+
Message.propTypes = {
|
|
88
|
+
className: _propTypes.default.string,
|
|
89
|
+
closeButton: _propTypes.default.bool,
|
|
90
|
+
color: _propTypes.default.string,
|
|
91
|
+
customClass: _propTypes.default.string,
|
|
92
|
+
icon: _propTypes.default.instanceOf(Object),
|
|
93
|
+
iconName: _propTypes.default.string,
|
|
94
|
+
id: _propTypes.default.number.isRequired,
|
|
95
|
+
handleClose: _propTypes.default.func.isRequired,
|
|
96
|
+
message: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object, _propTypes.default.element]).isRequired,
|
|
97
|
+
position: _propTypes.default.string.isRequired,
|
|
98
|
+
timeout: _propTypes.default.number
|
|
99
|
+
};
|
|
91
100
|
var _default = Message;
|
|
92
101
|
exports.default = _default;
|
package/lib/alerts/alert.spec.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
5
|
require("babel-polyfill");
|
|
6
|
+
|
|
6
7
|
require("@testing-library/jest-dom");
|
|
8
|
+
|
|
7
9
|
var _react2 = require("@testing-library/react");
|
|
10
|
+
|
|
8
11
|
var _Message = _interopRequireDefault(require("./Message"));
|
|
12
|
+
|
|
9
13
|
var _icons = _interopRequireDefault(require("../icons"));
|
|
14
|
+
|
|
10
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
16
|
+
|
|
12
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
18
|
+
|
|
13
19
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
14
|
-
|
|
20
|
+
|
|
21
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
22
|
+
|
|
15
23
|
var mockAlert = function mockAlert(props) {
|
|
16
24
|
return /*#__PURE__*/_react.default.createElement(_Message.default, _extends({
|
|
17
25
|
id: 3,
|
|
@@ -22,20 +30,23 @@ var mockAlert = function mockAlert(props) {
|
|
|
22
30
|
timeout: 500
|
|
23
31
|
}, props));
|
|
24
32
|
};
|
|
33
|
+
|
|
25
34
|
describe('Alert', function () {
|
|
26
35
|
describe('Message', function () {
|
|
27
36
|
it('should render correctly', function () {
|
|
28
37
|
var mockHandleClose = jest.fn();
|
|
38
|
+
|
|
29
39
|
var _render = (0, _react2.render)(mockAlert({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
handleClose: mockHandleClose
|
|
41
|
+
})),
|
|
42
|
+
container = _render.container;
|
|
43
|
+
|
|
33
44
|
expect(container.firstChild).toBeTruthy();
|
|
34
45
|
expect(container.firstChild).toHaveTextContent('Alerta');
|
|
35
46
|
});
|
|
36
|
-
it('should close with timeout 500ms', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
47
|
+
it('should close with timeout 500ms', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
37
48
|
var mockHandleClose;
|
|
38
|
-
return
|
|
49
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
39
50
|
while (1) {
|
|
40
51
|
switch (_context.prev = _context.next) {
|
|
41
52
|
case 0:
|
|
@@ -47,6 +58,7 @@ describe('Alert', function () {
|
|
|
47
58
|
return (0, _react2.waitFor)(function () {
|
|
48
59
|
return expect(mockHandleClose).toBeCalledTimes(1);
|
|
49
60
|
});
|
|
61
|
+
|
|
50
62
|
case 4:
|
|
51
63
|
case "end":
|
|
52
64
|
return _context.stop();
|
|
@@ -56,52 +68,63 @@ describe('Alert', function () {
|
|
|
56
68
|
})));
|
|
57
69
|
it('should apply custom class', function () {
|
|
58
70
|
var mockHandleClose = jest.fn();
|
|
71
|
+
|
|
59
72
|
var _render2 = (0, _react2.render)(mockAlert({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
73
|
+
handleClose: mockHandleClose
|
|
74
|
+
})),
|
|
75
|
+
container = _render2.container;
|
|
76
|
+
|
|
63
77
|
expect(container.firstChild).toHaveClass('mock-alert');
|
|
64
78
|
});
|
|
65
79
|
it('should render icon', function () {
|
|
66
80
|
var mockHandleClose = jest.fn();
|
|
81
|
+
|
|
67
82
|
var _render3 = (0, _react2.render)(mockAlert({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
handleClose: mockHandleClose,
|
|
84
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
85
|
+
name: "user"
|
|
86
|
+
})
|
|
87
|
+
})),
|
|
88
|
+
container = _render3.container,
|
|
89
|
+
getByTestId = _render3.getByTestId;
|
|
90
|
+
|
|
75
91
|
expect(container.querySelector('.-icon')).toContainElement(getByTestId('icon'));
|
|
76
92
|
});
|
|
77
93
|
it('should render icon by iconName', function () {
|
|
78
94
|
var mockHandleClose = jest.fn();
|
|
95
|
+
|
|
79
96
|
var _render4 = (0, _react2.render)(mockAlert({
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
handleClose: mockHandleClose,
|
|
98
|
+
iconName: 'user'
|
|
99
|
+
})),
|
|
100
|
+
container = _render4.container,
|
|
101
|
+
getByTestId = _render4.getByTestId;
|
|
102
|
+
|
|
85
103
|
expect(container.querySelector('.-icon')).toContainElement(getByTestId('icon'));
|
|
86
104
|
});
|
|
87
105
|
it('should change icon color', function () {
|
|
88
106
|
var mockHandleClose = jest.fn();
|
|
107
|
+
|
|
89
108
|
var _render5 = (0, _react2.render)(mockAlert({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
handleClose: mockHandleClose,
|
|
110
|
+
iconName: 'user',
|
|
111
|
+
color: 'red'
|
|
112
|
+
})),
|
|
113
|
+
getByTestId = _render5.getByTestId;
|
|
114
|
+
|
|
95
115
|
expect(getByTestId('icon')).toHaveAttribute('fill', 'red');
|
|
96
116
|
});
|
|
97
117
|
it('should fire event on click', function () {
|
|
98
118
|
var mockHandleClose = jest.fn();
|
|
119
|
+
|
|
99
120
|
var _render6 = (0, _react2.render)(mockAlert({
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
handleClose: mockHandleClose
|
|
122
|
+
})),
|
|
123
|
+
container = _render6.container,
|
|
124
|
+
getByRole = _render6.getByRole;
|
|
125
|
+
|
|
104
126
|
_react2.fireEvent.click(getByRole('button'));
|
|
127
|
+
|
|
105
128
|
expect(container.querySelector('.close')).toBeInTheDocument();
|
|
106
129
|
expect(container.querySelector('.close-button')).toBeInTheDocument();
|
|
107
130
|
expect(mockHandleClose).toBeCalledTimes(1);
|
package/lib/alerts/helpers.js
CHANGED
|
@@ -5,8 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react = require("react");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var AlertProviderContext = /*#__PURE__*/_react.default.createContext();
|
|
9
13
|
|
|
10
|
-
var AlertProviderContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
11
14
|
var _default = AlertProviderContext;
|
|
12
15
|
exports.default = _default;
|
package/lib/alerts/withAlert.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
|
-
function _extends() { _extends = Object.assign
|
|
20
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
21
|
|
|
22
22
|
var withAlert = function withAlert(WrapperComponent) {
|
|
23
23
|
var GetAlert = function GetAlert(props) {
|