@availity/feedback 0.0.0-t325224b2 → 1.0.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.
package/README.md CHANGED
@@ -1,76 +1,25 @@
1
1
  # @availity/feedback
2
2
 
3
- > Availity feedback with simley faces react component.
3
+ > Availity feedback with smiley faces react component.
4
4
 
5
- ## Installation
5
+ [![Version](https://img.shields.io/npm/v/@availity/feedback.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/feedback)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/@availity/feedback.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/feedback)
7
+ [![Dependecy Status](https://img.shields.io/librariesio/release/npm/@availity/feedback?style=for-the-badge)](https://github.com/Availity/availity-react/blob/master/packages/feedback/package.json)
6
8
 
7
- ```bash
8
- npm install @availity/feedback --save
9
- ```
9
+ ## Installation
10
10
 
11
- ### Usage
11
+ ### NPM
12
12
 
13
- ```javascript
14
- import React from 'react';
15
- import Feedback from '@availity/feedback';
16
- // ...
17
- <Feedback>
18
- {/* ... */}
19
- </Feedback>
20
- // ...
13
+ ```bash
14
+ npm install @availity/feedback
21
15
  ```
22
16
 
23
- #### Feedback (Default export)
24
- A component which does awesome things!
25
-
26
- ##### Props
27
-
28
- - **`appName`**: String. Required. The name of the application this feedback is for. It is used in the API request to indicate where the feedback came from.
29
- - **`formProps`**: Object. Optional. Props which will be passed to the underlying `FeedbackForm`. See the props for `FeedbackForm` below.
30
- - **`children`**: Text. Optional. The text which displays on the button. Default: `"Give Feedback"`
31
- - **`color`**: String. Optional. The color of the button. Default: `"light"`
32
- - **`outline`**: Boolean. Optional. Indicates if the button should use the "outline" styles or not. Default: `false`
33
- - **`prompt`**: String. Optional. Text which prompts/asks the user to provide feedback. Default: `"Tell us what you think about ${appName}."`
34
- - **`onFeedbackSent`**: Function. Optional. Callback for when the feedback is submitted. It will be called with the feedback object.
17
+ ### Yarn
35
18
 
36
- ##### Usage
37
-
38
- ```javascript
39
- import React from 'react';
40
- import Feedback from '@availity/feedback';
41
- // ...
42
- <Feedback
43
- appName="Payer Space"
44
- prompt="Please provide some feedback"
45
- color="primary"
46
- >
47
- Provide Feedback
48
- </Feedback>
49
- // ...
19
+ ```bash
20
+ yarn add @availity/feedback
50
21
  ```
51
22
 
52
- #### FeedbackForm
53
-
54
- This is the underlying form which is exposed in case you need to gather feedback inline.
55
-
56
- ##### Props
57
-
58
- - **`name`**: String. Required. The name of the application this feedback is for. It is used in the API request to indicate where the feedback came from.
59
- - **`formProps`**: Object. Optional. Props which will be passed to the underlying `FeedbackForm`. See the props for `FeedbackForm` below.
60
- - **`faceOptions`**: Array of Objects containing **`icon`** and **`description`**. Optional. Allows you to override the smiley face options which appear. Default: Smiley Face, Meh Face, and Frowny Face.
61
- - **`aboutOptions`**: Array of Objects containing **`value`** and **`label`**. Optional. Allows a dropdown displaying the options provided to let the uer indicate what the feedback is about.
62
- - **`prompt`**: String. Optional. Text which prompts/asks the user to provide feedback. Default: `"Tell us what you think about ${appName}."`
63
- - **`onFeedbackSent`**: Function. Optional. Callback for when the feedback is submitted. It will be called with the feedback object.
64
-
65
- ##### Usage
23
+ ## Documentation
66
24
 
67
- ```javascript
68
- import React from 'react';
69
- import { FeedbackForm } from '@availity/feedback';
70
- // ...
71
- <FeedbackForm
72
- name={text('Application Name', 'Payer Space')}
73
- prompt={text('Prompt')}
74
- />
75
- // ...
76
- ```
25
+ Check out more documentation at [availity.github.io](https://availity.github.io/availity-react/components/feedback/index)
package/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import Feedback from './Feedback';
2
- import FeedbackForm from './FeedbackForm';
3
-
4
- export default Feedback;
5
-
6
- export { FeedbackForm };
1
+ export { default } from './src/Feedback';
2
+ export { default as FeedbackForm } from './src/FeedbackForm';
3
+ export { default as FeedbackModal } from './src/FeedbackModal';
package/index.js CHANGED
@@ -1,6 +1,3 @@
1
- import Feedback from './Feedback';
2
- import FeedbackForm from './FeedbackForm';
3
-
4
- export default Feedback;
5
-
6
- export { FeedbackForm };
1
+ export { default } from './src/Feedback';
2
+ export { default as FeedbackForm } from './src/FeedbackForm';
3
+ export { default as FeedbackModal } from './src/FeedbackModal';
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ const global = require('../../jest/global-config');
2
+
3
+ module.exports = {
4
+ ...global,
5
+ displayName: 'feedback',
6
+ coverageDirectory: '../../coverage/feedback',
7
+ };
package/package.json CHANGED
@@ -1,41 +1,56 @@
1
1
  {
2
2
  "name": "@availity/feedback",
3
- "version": "0.0.0-t325224b2",
4
- "author": "Evan Sharp <evan.sharp@availity.com>",
5
- "description": "Availity feedback with simley faces react component.",
6
- "main": "index.js",
3
+ "version": "1.0.0",
4
+ "description": "Availity feedback with smiley faces react component.",
7
5
  "keywords": [
8
6
  "react",
9
- "availity"
7
+ "availity",
8
+ "feedback"
10
9
  ],
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/Availity/availity-react.git"
14
- },
10
+ "homepage": "https://availity.github.io/availity-react/components/feedback/index",
15
11
  "bugs": {
16
12
  "url": "https://github.com/Availity/availity-react/issues"
17
13
  },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/Availity/availity-react.git",
17
+ "directory": "packages/feedback"
18
+ },
18
19
  "license": "MIT",
19
- "publishConfig": {
20
- "access": "public"
20
+ "author": "Evan Sharp <evan.sharp@availity.com>",
21
+ "main": "index.js",
22
+ "types": "index.d.ts",
23
+ "scripts": {
24
+ "publish": "yarn npm publish --tolerate-republish --access public",
25
+ "publish:canary": "yarn npm publish --access public --tag canary"
21
26
  },
22
27
  "dependencies": {
23
- "prop-types": "^15.5.8"
28
+ "@availity/block-ui": "^1.0.0",
29
+ "@availity/form": "1.0.0",
30
+ "@availity/hooks": "1.0.0",
31
+ "@availity/icon": "0.1.0",
32
+ "@availity/native-form": "^6.0.0",
33
+ "@availity/select": "1.0.0",
34
+ "prop-types": "^15.8.1"
24
35
  },
25
36
  "devDependencies": {
26
- "@availity/api-axios": "^2.0.0",
27
- "@availity/api-core": "^2.0.0",
28
- "@availity/localstorage-core": "^1.4.0",
29
- "axios": "^0.18.0",
30
- "react": "^16.3.0",
31
- "react-dom": "^16.3.2",
32
- "react-testing-library": "^5.4.4",
33
- "reactstrap": "^6.0.0"
37
+ "@availity/api-axios": "^9.0.0",
38
+ "@availity/yup": "^6.0.0",
39
+ "axios": "^1.7.4",
40
+ "formik": "^2.4.6",
41
+ "react": "^18.3.1",
42
+ "react-dom": "^18.3.1",
43
+ "reactstrap": "^8.10.1"
34
44
  },
35
45
  "peerDependencies": {
36
- "@availity/api-axios": "^2.0.0",
37
- "react": "^16.3.0",
38
- "reactstrap": "^5.0.0 || ^6.0.0"
46
+ "@availity/api-axios": "^8.0.0",
47
+ "@availity/yup": "^5.1.0",
48
+ "axios": "^1.7.4",
49
+ "formik": "^2.0.1",
50
+ "react": ">=16.3.0",
51
+ "reactstrap": "^8.0.0"
39
52
  },
40
- "gitHead": "ca7f4108bea3ef671aada738d15a8628c495dd1d"
41
- }
53
+ "publishConfig": {
54
+ "access": "public"
55
+ }
56
+ }
package/project.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@availity/feedback",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "projectType": "library",
5
+ "targets": {
6
+ "test": {
7
+ "executor": "@nx/jest:jest",
8
+ "outputs": ["{workspaceRoot}/coverage/feedback"],
9
+ "options": {
10
+ "jestConfig": "packages/feedback/jest.config.js"
11
+ }
12
+ },
13
+ "version": {
14
+ "executor": "@jscutlery/semver:version",
15
+ "options": {
16
+ "preset": "angular",
17
+ "commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
18
+ "tagPrefix": "@availity/{projectName}@",
19
+ "baseBranch": "master",
20
+ "trackDeps": true
21
+ }
22
+ },
23
+ "lint": {
24
+ "executor": "@nx/eslint:lint",
25
+ "options": {
26
+ "eslintConfig": ".eslintrc.yaml",
27
+ "silent": false,
28
+ "fix": false,
29
+ "cache": true,
30
+ "cacheLocation": "./node_modules/.cache/feedback/.eslintcache",
31
+ "maxWarnings": -1,
32
+ "quiet": false,
33
+ "noEslintrc": false,
34
+ "hasTypeAwareRules": true,
35
+ "cacheStrategy": "metadata"
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,25 @@
1
+ import { DropdownProps } from 'reactstrap';
2
+
3
+ export interface AnalyticsType {
4
+ [key: string]: any;
5
+ info: (data: any) => Promise<void>;
6
+ }
7
+
8
+ export interface FeedbackProps extends DropdownProps {
9
+ appName?: string;
10
+ modal?: boolean;
11
+ zIndex?: number | string;
12
+ outline?: boolean;
13
+ color?: string;
14
+ analytics?: AnalyticsType;
15
+ formProps?: { [key: string]: any };
16
+ prompt?: React.ReactType;
17
+ onFeedbackSent?: (feedback?: { [key: string]: any }) => void;
18
+ onModalOpenChange?: (isOpen: boolean) => void;
19
+ showSupport?: boolean;
20
+ supportZIndex?: number | string;
21
+ }
22
+
23
+ declare const Feedback: React.FC<FeedbackProps>;
24
+
25
+ export default Feedback;
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Dropdown, DropdownToggle } from 'reactstrap';
4
+ import { avLogMessagesApiV2 } from '@availity/api-axios';
5
+ import { useToggle } from '@availity/hooks';
6
+
7
+ import FeedbackDropdown from './FeedbackDropdown';
8
+ import FeedbackModal from './FeedbackModal';
9
+
10
+ const Feedback = ({
11
+ appName,
12
+ modal = false,
13
+ zIndex,
14
+ supportZIndex,
15
+ children,
16
+ analytics = avLogMessagesApiV2,
17
+ className,
18
+ outline,
19
+ color = 'secondary',
20
+ formProps,
21
+ prompt,
22
+ onFeedbackSent,
23
+ showSupport = false,
24
+ onModalOpenChange,
25
+ ...props
26
+ }) => {
27
+ const [feedbackIsOpen, feedbackToggle] = useToggle(false);
28
+
29
+ const handleFeedbackToggle = () => {
30
+ feedbackToggle();
31
+
32
+ if (onModalOpenChange) onModalOpenChange(!feedbackIsOpen);
33
+ };
34
+
35
+ return (
36
+ <Dropdown
37
+ isOpen={feedbackIsOpen && !modal}
38
+ toggle={handleFeedbackToggle}
39
+ className={`${className} hidden-print`}
40
+ {...props}
41
+ >
42
+ <DropdownToggle color={color} outline={outline}>
43
+ {children || (showSupport ? 'Feedback & Support' : 'Give Feedback')}
44
+ </DropdownToggle>
45
+ {modal ? (
46
+ <FeedbackModal
47
+ onFeedbackSent={onFeedbackSent}
48
+ prompt={prompt}
49
+ isOpen={feedbackIsOpen}
50
+ zIndex={zIndex}
51
+ toggle={handleFeedbackToggle}
52
+ name={appName}
53
+ analytics={analytics}
54
+ showSupport={showSupport}
55
+ supportZIndex={supportZIndex}
56
+ feedbackToggle={feedbackToggle}
57
+ {...formProps}
58
+ />
59
+ ) : (
60
+ <FeedbackDropdown
61
+ onFeedbackSent={onFeedbackSent}
62
+ feedbackToggle={feedbackToggle}
63
+ prompt={prompt}
64
+ analytics={analytics}
65
+ toggle={handleFeedbackToggle}
66
+ name={appName}
67
+ showSupport={showSupport}
68
+ supportZIndex={supportZIndex}
69
+ modal={modal}
70
+ {...formProps}
71
+ />
72
+ )}
73
+ </Dropdown>
74
+ );
75
+ };
76
+
77
+ Feedback.propTypes = {
78
+ analytics: PropTypes.shape({
79
+ info: PropTypes.func.isRequired,
80
+ }),
81
+ /** The name of the application this feedback is for. It is used in the API request to indicate where the feedback came from. */
82
+ appName: PropTypes.string,
83
+ /** Whether to open the FeedbackForm in a modal */
84
+ modal: PropTypes.bool,
85
+ /** Allows for overriding the z-indexvalue from react-strap Modalcomponent. */
86
+ zIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
87
+ /** Allows for overriding the z-index value from reactstrap Support Modal component. */
88
+ supportZIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
89
+ /** The text to display on the submit button. */
90
+ children: PropTypes.node,
91
+ className: PropTypes.string,
92
+ /** Indicates if the button should use the "outline" styles or not. */
93
+ outline: PropTypes.bool,
94
+ /** The color of the button. Default: "light". */
95
+ color: PropTypes.string,
96
+ /** Props to be spread to the underlying FeedbackForm. See the FeedbackForm Props. */
97
+ formProps: PropTypes.object,
98
+ /** Text that prompts the user to provider feedback. Default: "Tell us what you think about ${appName}.". */
99
+ prompt: PropTypes.string,
100
+ /** Callback for when the feedback is submitted. It is called with the feedback object. */
101
+ onFeedbackSent: PropTypes.func,
102
+ onModalOpenChange: PropTypes.func,
103
+ /** Toggle whether or not to show the "Open a Support ticket" link in the FeedbackForm */
104
+ showSupport: PropTypes.bool,
105
+ };
106
+
107
+ export default Feedback;
@@ -2,7 +2,7 @@ export interface FeedbackButtonProps {
2
2
  onClick?: Function;
3
3
  icon?: string;
4
4
  active?: string;
5
- children?: Node;
5
+ children?: React.ReactType;
6
6
  }
7
7
 
8
8
  declare const FeedbackButton: React.ComponentType<FeedbackButtonProps>;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { PropTypes } from 'prop-types';
3
+ import { Button } from 'reactstrap';
4
+ import Icon from '@availity/icon';
5
+
6
+ const btnStyles = { fontSize: '1.4em', padding: '.2em .4em' };
7
+ const iconStyles = { margin: '0px' };
8
+
9
+ const FeedbackButton = ({ onClick, icon, active, children, iconSize = '', ...rest }) => (
10
+ <Button
11
+ style={btnStyles}
12
+ color={active === icon ? 'primary' : 'light'}
13
+ aria-pressed={active === icon}
14
+ onClick={() => {
15
+ onClick(icon);
16
+ }}
17
+ onKeyDown={({ keyCode }) => keyCode === 13 && onClick(icon)}
18
+ {...rest}
19
+ >
20
+ <Icon data-testid="feedback-icon" name={icon} size={iconSize} style={iconStyles} />
21
+ <span className="sr-only">{children}</span>
22
+ </Button>
23
+ );
24
+
25
+ FeedbackButton.propTypes = {
26
+ onClick: PropTypes.func.isRequired,
27
+ icon: PropTypes.string,
28
+ active: PropTypes.string,
29
+ children: PropTypes.node,
30
+ iconSize: PropTypes.string,
31
+ };
32
+
33
+ export default FeedbackButton;
@@ -5,10 +5,10 @@ export interface FeedbackProps {
5
5
  color?: string;
6
6
  outline?: boolean;
7
7
  formProps?: object;
8
- children?: Node;
8
+ children?: React.ReactType;
9
9
  onFeedbackSent: Function;
10
10
  }
11
11
 
12
12
  declare const Feedback: React.StatelessComponent<FeedbackProps>;
13
13
 
14
- export default Feedback;
14
+ export default Feedback;
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { DropdownMenu } from 'reactstrap';
4
+
5
+ import FeedbackForm from './FeedbackForm';
6
+ import SupportModal from './SupportModal';
7
+ import SupportDropdown from './SupportDropdown';
8
+
9
+ const dropdownStyles = { width: '550px', maxWidth: '90vw', padding: 0 };
10
+
11
+ const FeedbackDropdown = ({
12
+ prompt,
13
+ toggle,
14
+ onFeedbackSent,
15
+ showSupport,
16
+ supportToggle,
17
+ supportZIndex,
18
+ modal,
19
+ feedbackToggle,
20
+ ...formProps
21
+ }) => {
22
+ const [supportIsActive, setSupportIsActive] = React.useState(false);
23
+
24
+ let support = null;
25
+ if (supportIsActive) {
26
+ support = modal ? (
27
+ <SupportModal
28
+ toggle={supportToggle}
29
+ isOpen={supportIsActive}
30
+ setSupportIsActive={setSupportIsActive}
31
+ supportZIndex={supportZIndex}
32
+ feedbackToggle={feedbackToggle}
33
+ />
34
+ ) : (
35
+ <SupportDropdown toggle={supportToggle} setSupportIsActive={setSupportIsActive} feedbackToggle={feedbackToggle} />
36
+ );
37
+ }
38
+
39
+ const toRender = support || (
40
+ <FeedbackForm
41
+ onFeedbackSent={onFeedbackSent}
42
+ prompt={prompt}
43
+ onClose={toggle}
44
+ showSupport={showSupport}
45
+ setSupportIsActive={setSupportIsActive}
46
+ modal={modal}
47
+ {...formProps}
48
+ />
49
+ );
50
+
51
+ return (
52
+ <DropdownMenu right style={dropdownStyles} role="dialog" aria-labelledby="feedback-form-header" aria-modal="false">
53
+ {toRender}
54
+ </DropdownMenu>
55
+ );
56
+ };
57
+
58
+ FeedbackDropdown.propTypes = {
59
+ prompt: PropTypes.string,
60
+ toggle: PropTypes.func,
61
+ onFeedbackSent: PropTypes.func,
62
+ showSupport: PropTypes.bool,
63
+ supportToggle: PropTypes.func,
64
+ supportZIndex: PropTypes.string,
65
+ modal: PropTypes.bool,
66
+ feedbackToggle: PropTypes.func,
67
+ };
68
+
69
+ export default FeedbackDropdown;
@@ -0,0 +1,31 @@
1
+ import { ModalHeaderProps } from 'reactstrap';
2
+ import { AnalyticsType } from './Feedback';
3
+
4
+ type FaceOption = {
5
+ icon?: string;
6
+ description?: string;
7
+ };
8
+
9
+ type AboutOption = {
10
+ icon?: string;
11
+ label?: React.ReactNode;
12
+ };
13
+
14
+ export interface FeedbackFormProps {
15
+ name: string;
16
+ onFeedbackSent?: (feedback?: { [key: string]: any }) => void;
17
+ faceOptions?: FaceOption[];
18
+ aboutOptions?: AboutOption[];
19
+ aboutLabel?: string;
20
+ analytics?: AnalyticsType;
21
+ prompt?: string;
22
+ staticFields?: object;
23
+ modalHeaderProps?: ModalHeaderProps;
24
+ showSupport: boolean;
25
+ setSupportIsActive: Function;
26
+ autoFocusFeedbackButton?: boolean;
27
+ }
28
+
29
+ declare const FeedbackForm: React.FC<FeedbackFormProps>;
30
+
31
+ export default FeedbackForm;