@codacy/ui-components 0.49.4 → 0.50.0

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.
@@ -2,3 +2,4 @@
2
2
  export declare const CheckIcon: () => JSX.Element;
3
3
  export declare const MinusIcon: () => JSX.Element;
4
4
  export declare const CloseIcon: () => JSX.Element;
5
+ export declare const DangerIcon: () => JSX.Element;
@@ -33,4 +33,23 @@ export var CloseIcon = function CloseIcon() {
33
33
  d: "M368 368L144 144M368 144L144 368",
34
34
  className: "ionicon-fill-none ionicon-stroke-width"
35
35
  }));
36
+ };
37
+ export var DangerIcon = function DangerIcon() {
38
+ return /*#__PURE__*/React.createElement("svg", {
39
+ xmlns: "http://www.w3.org/2000/svg",
40
+ className: "ionicon",
41
+ viewBox: "0 0 512 512"
42
+ }, /*#__PURE__*/React.createElement("path", {
43
+ d: "M85.57 446.25h340.86a32 32 0 0028.17-47.17L284.18 82.58c-12.09-22.44-44.27-22.44-56.36 0L57.4 399.08a32 32 0 0028.17 47.17z",
44
+ "stroke-linecap": "round",
45
+ "stroke-linejoin": "round",
46
+ className: "ionicon-fill-none ionicon-stroke-width"
47
+ }), /*#__PURE__*/React.createElement("path", {
48
+ d: "M250.26 195.39l5.74 122 5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 5.95z",
49
+ "stroke-linecap": "round",
50
+ "stroke-linejoin": "round",
51
+ className: "ionicon-fill-none ionicon-stroke-width"
52
+ }), /*#__PURE__*/React.createElement("path", {
53
+ d: "M256 397.25a20 20 0 1120-20 20 20 0 01-20 20z"
54
+ }));
36
55
  };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ConfirmationModalProps } from './types';
3
+ import { DialogStateReturn } from 'reakit/ts/Dialog';
4
+ export declare const ConfirmationModal: React.FC<ConfirmationModalProps & DialogStateReturn>;
@@ -0,0 +1,44 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import React, { useCallback, useRef } from 'react';
3
+ import { Modal } from '.';
4
+ import { Button, ButtonGroup, IconAndText, Subheader } from '..';
5
+ export var ConfirmationModal = function ConfirmationModal(_ref) {
6
+ var title = _ref.title,
7
+ confirmText = _ref.confirmText,
8
+ onConfirm = _ref.onConfirm,
9
+ _ref$cancelText = _ref.cancelText,
10
+ cancelText = _ref$cancelText === void 0 ? 'Cancel' : _ref$cancelText,
11
+ onCancel = _ref.onCancel,
12
+ _ref$variant = _ref.variant,
13
+ variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
14
+ icon = _ref.icon,
15
+ children = _ref.children,
16
+ dialog = _objectWithoutProperties(_ref, ["title", "confirmText", "onConfirm", "cancelText", "onCancel", "variant", "icon", "children"]);
17
+
18
+ var cancelRef = useRef(null);
19
+ var handleCancel = useCallback(function () {
20
+ if (onCancel) onCancel();
21
+ dialog.hide();
22
+ }, [onCancel, dialog]);
23
+ return /*#__PURE__*/React.createElement(Modal, Object.assign({
24
+ focusRef: cancelRef
25
+ }, dialog), /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(Subheader, null, icon ? /*#__PURE__*/React.createElement(IconAndText, {
26
+ icon: icon,
27
+ iconProps: {
28
+ color: "icon-".concat(variant)
29
+ }
30
+ }, title) : /*#__PURE__*/React.createElement(React.Fragment, null, title))), /*#__PURE__*/React.createElement(Modal.Body, {
31
+ mt: 4
32
+ }, children), /*#__PURE__*/React.createElement(Modal.Footer, null, /*#__PURE__*/React.createElement(ButtonGroup, {
33
+ mt: 5
34
+ }, /*#__PURE__*/React.createElement(Button, {
35
+ variant: "primary",
36
+ color: variant,
37
+ onClick: onConfirm
38
+ }, confirmText), /*#__PURE__*/React.createElement(Button, {
39
+ variant: "link",
40
+ color: "subtle",
41
+ onClick: handleCancel,
42
+ ref: cancelRef
43
+ }, cancelText))));
44
+ };
@@ -40,3 +40,12 @@ export interface ModalProps extends ModalHeaderProps {
40
40
  /** Vertical positioning */
41
41
  vPos?: 'top' | 'center';
42
42
  }
43
+ export interface ConfirmationModalProps extends Omit<ModalProps, 'title' | 'description' | 'headerImg' | 'focusRef'> {
44
+ title: string;
45
+ confirmText: string;
46
+ onConfirm: () => void;
47
+ cancelText?: string;
48
+ onCancel?: () => void;
49
+ variant?: 'primary' | 'danger';
50
+ icon?: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/ui-components",
3
- "version": "0.49.4",
3
+ "version": "0.50.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -62,11 +62,11 @@
62
62
  "@types/react": "^16.9.56",
63
63
  "@types/react-dom": "^16.9.9",
64
64
  "@types/react-select": "3.0.13",
65
+ "@types/resize-observer-browser": "^0.1.6",
65
66
  "@types/styled-system": "^5.1.10",
66
67
  "@types/styled-system__should-forward-prop": "^5.1.2",
67
68
  "@typescript-eslint/eslint-plugin": "^2.34.0",
68
69
  "@typescript-eslint/parser": "^2.34.0",
69
- "@types/resize-observer-browser": "^0.1.6",
70
70
  "babel-eslint": "^10.1.0",
71
71
  "babel-loader": "^8.2.1",
72
72
  "babel-plugin-emotion": "^10.0.33",
@@ -93,11 +93,11 @@
93
93
  "react": "^17.0.1",
94
94
  "react-docgen-typescript-loader": "^3.7.2",
95
95
  "react-dom": "^17.0.1",
96
+ "react-toastify": "^8.0.2",
97
+ "reakit": "1.1.1",
96
98
  "rimraf": "^3.0.2",
97
99
  "typeface-clear-sans": "0.0.44",
98
- "typescript": "^3.8.3",
99
- "reakit": "1.1.1",
100
- "react-toastify": "^8.0.2"
100
+ "typescript": "^3.8.3"
101
101
  },
102
102
  "peerDependencies": {
103
103
  "@emotion/styled": "10.x",