@codacy/ui-components 0.49.4 → 0.50.4

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
+ };
@@ -1 +1,2 @@
1
1
  export * from './Modal';
2
+ export * from './ConfirmationModal';
@@ -1 +1,2 @@
1
- export * from './Modal';
1
+ export * from './Modal';
2
+ export * from './ConfirmationModal';
@@ -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
+ }
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { SelectProps } from './types';
3
- declare const StyledSelect: React.FC<SelectProps>;
4
- export { StyledSelect as Select };
3
+ /** @deprecated Use Dropdown + SelectTrigger instead */
4
+ export declare const Select: React.FC<SelectProps>;
@@ -1,70 +1,41 @@
1
- import React from 'react';
2
- import Select, { components } from 'react-select';
3
- import { Labeled, Icon } from '../';
4
- import { InputWrapper, InputErrorMessage } from '../Input/styles';
5
- import { customStyles } from './style';
6
- import { ChevronDownIcon } from '../Icons';
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import React, { useCallback } from 'react';
3
+ import { Dropdown, DropdownItem, SelectTrigger } from '../';
7
4
 
8
- var CaretDownIcon = function CaretDownIcon() {
9
- return /*#__PURE__*/React.createElement(Icon, {
10
- icon: ChevronDownIcon,
11
- size: "md"
12
- });
13
- };
14
-
15
- var DropdownIndicator = function DropdownIndicator(props) {
16
- return /*#__PURE__*/React.createElement(components.DropdownIndicator, props, /*#__PURE__*/React.createElement(CaretDownIcon, null));
17
- };
18
-
19
- var StyledSelect = function StyledSelect(_ref) {
5
+ /** @deprecated Use Dropdown + SelectTrigger instead */
6
+ export var Select = function Select(_ref) {
20
7
  var options = _ref.options,
21
- placeholder = _ref.placeholder,
22
- _ref$isSearchable = _ref.isSearchable,
23
- isSearchable = _ref$isSearchable === void 0 ? false : _ref$isSearchable,
24
- name = _ref.name,
25
8
  id = _ref.id,
26
- label = _ref.label,
27
- _ref$required = _ref.required,
28
- required = _ref$required === void 0 ? false : _ref$required,
29
- size = _ref.size,
30
- _ref$hasError = _ref.hasError,
31
- hasError = _ref$hasError === void 0 ? false : _ref$hasError,
32
- errorMessage = _ref.errorMessage,
33
- inputId = _ref.inputId,
34
9
  value = _ref.value,
35
- _onChange = _ref.onChange;
36
- var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Select, {
10
+ _onChange = _ref.onChange,
11
+ onOpen = _ref.onOpen,
12
+ onClose = _ref.onClose,
13
+ portal = _ref.portal,
14
+ inputProps = _objectWithoutProperties(_ref, ["options", "id", "value", "onChange", "onOpen", "onClose", "portal"]);
15
+
16
+ var dropdownProps = {
17
+ onOpen: onOpen,
18
+ onClose: onClose,
19
+ portal: portal
20
+ };
21
+ var getLabel = useCallback(function (val) {
22
+ var value = val ? val : undefined;
23
+ return value ? value.label : '';
24
+ }, []);
25
+ return /*#__PURE__*/React.createElement(Dropdown, Object.assign({
37
26
  id: id,
38
- inputId: inputId,
39
- components: {
40
- DropdownIndicator: DropdownIndicator
41
- },
42
- options: options,
43
- styles: customStyles(hasError),
44
- placeholder: placeholder,
45
- isSearchable: isSearchable,
46
- name: name,
47
- maxMenuHeight: 230,
48
- onChange: function onChange(value) {
49
- return _onChange(value);
27
+ size: inputProps.size,
28
+ trigger: /*#__PURE__*/React.createElement(SelectTrigger, Object.assign({
29
+ id: id ? "".concat(id, "-input") : undefined,
30
+ caption: getLabel
31
+ }, inputProps)),
32
+ onChange: function onChange(val) {
33
+ return _onChange(val);
50
34
  },
51
- value: value
52
- }), hasError && /*#__PURE__*/React.createElement(InputErrorMessage, {
53
- id: "error-".concat(id)
54
- }, errorMessage));
55
-
56
- if (!!label) {
57
- return /*#__PURE__*/React.createElement(Labeled, {
58
- forId: id,
59
- label: label,
60
- required: required,
61
- size: size
62
- }, content);
63
- }
64
-
65
- return /*#__PURE__*/React.createElement(InputWrapper, {
66
- size: size
67
- }, content);
68
- };
69
-
70
- export { StyledSelect as Select };
35
+ initialValue: value
36
+ }, dropdownProps), options.map(function (option) {
37
+ return /*#__PURE__*/React.createElement(DropdownItem, {
38
+ value: option
39
+ }, option.label);
40
+ }));
41
+ };
@@ -1,20 +1,14 @@
1
- import { Size } from '../theme';
1
+ import { DropdownProps } from '../Dropdown/Dropdown.types';
2
+ import { SelectTriggerProps } from '../Dropdown/Triggers/types';
2
3
  export declare type SelectOption = {
3
4
  value: string;
4
5
  label: string;
5
6
  };
6
- export interface SelectProps {
7
+ export interface SelectProps extends Pick<DropdownProps, 'onClose' | 'onOpen' | 'portal'>, Omit<SelectTriggerProps, 'value' | 'onChange' | 'caption'> {
7
8
  id?: string;
8
9
  inputId?: string;
9
10
  options: Array<SelectOption>;
10
- placeholder: string;
11
- isSearchable?: boolean;
12
11
  name: string;
13
- label?: string;
14
- required?: boolean;
15
- size?: Size;
16
- hasError?: boolean;
17
- errorMessage?: string | null;
18
12
  value?: SelectOption;
19
13
  onChange: (value: SelectOption) => void;
20
14
  }
@@ -141,9 +141,9 @@ var VirtualRow = function VirtualRow(_ref8) {
141
141
  props = _objectWithoutProperties(_ref8, ["children", "index", "height"]);
142
142
 
143
143
  var scrollCtx = useContext(ScrollableContentContext);
144
- var top = (index + 1) *
144
+ var top = (index + 1
145
145
  /* +1 to acknowledge the header row */
146
- height;
146
+ ) * height;
147
147
  var threshold = height / 2;
148
148
  var inViewport = top >= scrollCtx.scroll - threshold && top <= scrollCtx.scroll + scrollCtx.height + threshold;
149
149
  return /*#__PURE__*/React.createElement(StyledTableRow, Object.assign({}, props, {
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.4",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -28,29 +28,26 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.12.5",
31
- "@emotion/core": "^10.1.1",
32
- "@emotion/styled-base": "^10.0.31",
33
- "@pathofdev/react-tag-input": "github:inesgomas/react-tag-input#9820d2ae045d9398fbd3ba9021f675b127003237",
34
- "@popperjs/core": "^2.5.4",
31
+ "@pathofdev/react-tag-input": "github:inesgomas/react-tag-input",
35
32
  "@styled-system/should-forward-prop": "^5.1.5",
36
33
  "autosize": "^4.0.2",
37
34
  "emotion-theming": "10.x",
38
- "lodash": "^4.17.20",
39
35
  "md5": "^2.3.0",
40
36
  "polished": "^3.6.7",
41
37
  "query-string": "^6.13.7",
42
38
  "react-popper": "^2.2.4",
43
- "react-select": "3.1.0",
44
- "react-spring": "^8.0.27",
45
39
  "styled-system": "^5.1.5"
46
40
  },
47
41
  "devDependencies": {
48
42
  "@babel/cli": "^7.12.1",
49
43
  "@babel/core": "^7.12.3",
50
- "@emotion/styled": "10.x",
51
- "@storybook/addon-docs": "^6.3.8",
44
+ "@emotion/core": "^10.3.0",
45
+ "@emotion/styled": "^10.3.0",
46
+ "@emotion/styled-base": "^10.3.0",
47
+ "@popperjs/core": "^2.5.4",
48
+ "@storybook/addon-docs": "^6.4.9",
52
49
  "@storybook/addons": "^6.3.8",
53
- "@storybook/react": "^6.3.8",
50
+ "@storybook/react": "^6.4.9",
54
51
  "@testing-library/dom": "^6.16.0",
55
52
  "@testing-library/jest-dom": "^5.11.6",
56
53
  "@testing-library/react": "^10.4.9",
@@ -61,25 +58,24 @@
61
58
  "@types/md5": "^2.2.1",
62
59
  "@types/react": "^16.9.56",
63
60
  "@types/react-dom": "^16.9.9",
64
- "@types/react-select": "3.0.13",
61
+ "@types/resize-observer-browser": "^0.1.6",
65
62
  "@types/styled-system": "^5.1.10",
66
63
  "@types/styled-system__should-forward-prop": "^5.1.2",
67
64
  "@typescript-eslint/eslint-plugin": "^2.34.0",
68
65
  "@typescript-eslint/parser": "^2.34.0",
69
- "@types/resize-observer-browser": "^0.1.6",
70
66
  "babel-eslint": "^10.1.0",
71
67
  "babel-loader": "^8.2.1",
72
68
  "babel-plugin-emotion": "^10.0.33",
73
69
  "babel-preset-react-app": "^9.1.2",
74
70
  "copy-to-clipboard": "^3.3.1",
75
- "depcheck": "^0.9.2",
71
+ "depcheck": "^1.4.2",
76
72
  "eslint": "^6.8.0",
77
73
  "eslint-config-prettier": "^6.15.0",
78
74
  "eslint-config-react-app": "^5.2.1",
79
75
  "eslint-plugin-flowtype": "^3.13.0",
80
76
  "eslint-plugin-import": "^2.22.1",
81
77
  "eslint-plugin-jsx-a11y": "^6.4.1",
82
- "eslint-plugin-mdx": "^1.8.2",
78
+ "eslint-plugin-mdx": "^1.16.0",
83
79
  "eslint-plugin-prettier": "^3.1.4",
84
80
  "eslint-plugin-react": "^7.21.5",
85
81
  "eslint-plugin-react-hooks": "^1.7.0",
@@ -89,23 +85,28 @@
89
85
  "jest-environment-jsdom-fourteen": "1.0.1",
90
86
  "jest-watch-typeahead": "^0.4.2",
91
87
  "lint-staged": "^9.5.0",
88
+ "lodash": "^4.17.20",
92
89
  "prettier": "^1.19.1",
93
90
  "react": "^17.0.1",
94
91
  "react-docgen-typescript-loader": "^3.7.2",
95
92
  "react-dom": "^17.0.1",
93
+ "react-toastify": "^8.0.2",
94
+ "reakit": "^1.3.11",
96
95
  "rimraf": "^3.0.2",
97
96
  "typeface-clear-sans": "0.0.44",
98
- "typescript": "^3.8.3",
99
- "reakit": "1.1.1",
100
- "react-toastify": "^8.0.2"
97
+ "typescript": "^3.8.3"
101
98
  },
102
99
  "peerDependencies": {
103
- "@emotion/styled": "10.x",
104
- "react": ">=16.13",
105
- "react-dom": ">=16.13",
106
- "typeface-clear-sans": "0.0.44",
107
- "reakit": "1.1.1",
108
- "react-toastify": "^8.0.2"
100
+ "@emotion/core": "^10.3.0",
101
+ "@emotion/styled": "^10.3.0",
102
+ "@emotion/styled-base": "^10.3.0",
103
+ "@popperjs/core": "^2.5.4",
104
+ "lodash": "^4.17.20",
105
+ "react": "^16.8.0 || ^17.0.0",
106
+ "react-dom": "^16.8.0 || ^17.0.0",
107
+ "react-toastify": "^8.0.2",
108
+ "reakit": "^1.3.11",
109
+ "typeface-clear-sans": "0.0.44"
109
110
  },
110
111
  "husky": {
111
112
  "hooks": {
@@ -1,2 +0,0 @@
1
- import { Styles } from 'react-select';
2
- export declare function customStyles(hasError: boolean): Partial<Styles>;
@@ -1,76 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { theme } from '../';
3
- import { rgba } from 'polished';
4
- export function customStyles(hasError) {
5
- return {
6
- option: function option(provided, state) {
7
- return _objectSpread(_objectSpread({}, provided), {}, {
8
- backgroundColor: state.isSelected ? theme.colors['background-info'] : theme.colors['background-primary'],
9
- color: theme.colors['text-secondary'],
10
- fontSize: theme.fontSizes[2],
11
- padding: "".concat(theme.space[1], " ").concat(theme.space[3]),
12
- cursor: 'pointer',
13
- ':hover': {
14
- backgroundColor: !!!state.isSelected && theme.colors['background-secondary']
15
- },
16
- ':active, :focus': {
17
- backgroundColor: theme.colors['background-info']
18
- }
19
- });
20
- },
21
- control: function control(provided, state) {
22
- return _objectSpread(_objectSpread({}, provided), {}, {
23
- height: '2rem',
24
- minHeight: '2rem',
25
- borderColor: state.menuIsOpen ? theme.colors['control-active-border'] : hasError ? theme.colors['control-invalid-border'] : theme.colors['control-border'],
26
- ':hover': {
27
- borderColor: hasError && !state.menuIsOpen ? theme.colors['control-invalid-border'] : theme.colors['control-active-border']
28
- },
29
- cursor: 'pointer',
30
- boxShadow: 'none'
31
- });
32
- },
33
- menu: function menu(provided) {
34
- return _objectSpread(_objectSpread({}, provided), {}, {
35
- border: theme.borderSize[0] + ' solid ' + theme.colors['brand-primary'],
36
- boxShadow: '0 3px 6px ' + rgba(theme.colors['brand-primary'], 0.3),
37
- marginTop: theme.space[1]
38
- });
39
- },
40
- indicatorSeparator: function indicatorSeparator() {
41
- return {
42
- display: 'none'
43
- };
44
- },
45
- placeholder: function placeholder(provided, state) {
46
- return _objectSpread(_objectSpread({}, provided), {}, {
47
- overflow: 'hidden',
48
- position: 'absolute',
49
- textOverflow: 'ellipsis',
50
- whiteSpace: 'nowrap',
51
- maxWidth: "calc(100% - ".concat(theme.space[3], ")"),
52
- color: state.isFocused || state.isSelected ? theme.colors['text-secondary'] : theme.colors['text-placeholder']
53
- });
54
- },
55
- valueContainer: function valueContainer(provided) {
56
- return _objectSpread(_objectSpread({}, provided), {}, {
57
- fontSize: theme.fontSizes[2],
58
- padding: "0px ".concat(theme.space[3])
59
- });
60
- },
61
- menuList: function menuList(provided) {
62
- return _objectSpread(_objectSpread({}, provided), {}, {
63
- borderRadius: '0.25rem'
64
- });
65
- },
66
- dropdownIndicator: function dropdownIndicator(provided, state) {
67
- return _objectSpread(_objectSpread({}, provided), {}, {
68
- '&, :hover': {
69
- color: theme.colors['brand-primary']
70
- },
71
- transform: state.selectProps.menuIsOpen ? 'rotate(180deg)' : 'rotate(0deg)',
72
- padding: "".concat(theme.space[1], " ").concat(theme.space[3])
73
- });
74
- }
75
- };
76
- }