@atlaskit/contextual-survey 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +258 -0
- package/LICENSE +13 -0
- package/README.md +13 -0
- package/build/tsconfig.json +17 -0
- package/constants/package.json +7 -0
- package/dist/cjs/components/ContextualSurvey.js +274 -0
- package/dist/cjs/components/FeedbackAcknowledgement.js +26 -0
- package/dist/cjs/components/FeedbackScoreButtons.js +60 -0
- package/dist/cjs/components/SignUpPrompt.js +84 -0
- package/dist/cjs/components/SignUpSuccess.js +29 -0
- package/dist/cjs/components/SuccessContainer.js +35 -0
- package/dist/cjs/components/SurveyContainer.js +48 -0
- package/dist/cjs/components/SurveyForm.js +159 -0
- package/dist/cjs/components/SurveyMarshal.js +67 -0
- package/dist/cjs/components/useEscapeToDismiss.js +78 -0
- package/dist/cjs/constants.js +15 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/components/ContextualSurvey.js +178 -0
- package/dist/es2019/components/FeedbackAcknowledgement.js +12 -0
- package/dist/es2019/components/FeedbackScoreButtons.js +69 -0
- package/dist/es2019/components/SignUpPrompt.js +46 -0
- package/dist/es2019/components/SignUpSuccess.js +12 -0
- package/dist/es2019/components/SuccessContainer.js +22 -0
- package/dist/es2019/components/SurveyContainer.js +37 -0
- package/dist/es2019/components/SurveyForm.js +121 -0
- package/dist/es2019/components/SurveyMarshal.js +62 -0
- package/dist/es2019/components/useEscapeToDismiss.js +69 -0
- package/dist/es2019/constants.js +4 -0
- package/dist/es2019/index.js +2 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/components/ContextualSurvey.js +244 -0
- package/dist/esm/components/FeedbackAcknowledgement.js +13 -0
- package/dist/esm/components/FeedbackScoreButtons.js +44 -0
- package/dist/esm/components/SignUpPrompt.js +66 -0
- package/dist/esm/components/SignUpSuccess.js +16 -0
- package/dist/esm/components/SuccessContainer.js +21 -0
- package/dist/esm/components/SurveyContainer.js +30 -0
- package/dist/esm/components/SurveyForm.js +132 -0
- package/dist/esm/components/SurveyMarshal.js +55 -0
- package/dist/esm/components/useEscapeToDismiss.js +68 -0
- package/dist/esm/constants.js +4 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/components/ContextualSurvey.d.ts +39 -0
- package/dist/types/components/FeedbackAcknowledgement.d.ts +2 -0
- package/dist/types/components/FeedbackScoreButtons.d.ts +6 -0
- package/dist/types/components/SignUpPrompt.d.ts +5 -0
- package/dist/types/components/SignUpSuccess.d.ts +4 -0
- package/dist/types/components/SuccessContainer.d.ts +6 -0
- package/dist/types/components/SurveyContainer.d.ts +7 -0
- package/dist/types/components/SurveyForm.d.ts +11 -0
- package/dist/types/components/SurveyMarshal.d.ts +13 -0
- package/dist/types/components/useEscapeToDismiss.d.ts +6 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/types.d.ts +5 -0
- package/docs/0-intro.tsx +115 -0
- package/package.json +58 -0
- package/tsconfig.json +16 -0
- package/types/package.json +7 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FormValues } from '../types';
|
|
2
|
+
export declare enum DismissTrigger {
|
|
3
|
+
AutoDismiss = "AUTO_DISMISS",
|
|
4
|
+
Manual = "MANUAL",
|
|
5
|
+
Finished = "FINISHED",
|
|
6
|
+
Unmount = "UNMOUNT"
|
|
7
|
+
}
|
|
8
|
+
export declare type OnDismissArgs = {
|
|
9
|
+
trigger: DismissTrigger;
|
|
10
|
+
};
|
|
11
|
+
interface Props {
|
|
12
|
+
/** Optional statement, to be used in conjunction with the question for the survey
|
|
13
|
+
* Example: "How strongly do you agree or disagree with this statement"
|
|
14
|
+
*/
|
|
15
|
+
statement?: string;
|
|
16
|
+
/** Question used for the survey
|
|
17
|
+
* Example: "It is easy to find what I am looking for in Jira"
|
|
18
|
+
*/
|
|
19
|
+
question: string;
|
|
20
|
+
/** Accessible label text for the survey text area */
|
|
21
|
+
textLabel?: string;
|
|
22
|
+
/** Text placeholder for the survey text area
|
|
23
|
+
* Example: "Tell us why"
|
|
24
|
+
*/
|
|
25
|
+
textPlaceholder?: string;
|
|
26
|
+
/** Callback that is triggered when the survey should be dismissed */
|
|
27
|
+
onDismiss: (args: OnDismissArgs) => void;
|
|
28
|
+
/** Gets whether user has already signed up to the Atlassian Research Group list.
|
|
29
|
+
* If `true` is returned then the user will not be prompted to sign up to the Research Group.
|
|
30
|
+
*/
|
|
31
|
+
getUserHasAnsweredMailingList: () => Promise<boolean>;
|
|
32
|
+
/** Callback that is triggered when the survey is submitted, it will get the survey data as a parameter */
|
|
33
|
+
onSubmit: (formValues: FormValues) => Promise<void>;
|
|
34
|
+
/** Callback that is triggered when the user clicks 'Yes' or 'No' to sign up to the Atlassian Research Group */
|
|
35
|
+
onMailingListAnswer: (answer: boolean) => Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export declare const AUTO_DISAPPEAR_DURATION: number;
|
|
38
|
+
declare const _default: ({ question, statement, onDismiss, onSubmit, onMailingListAnswer, getUserHasAnsweredMailingList, textLabel, textPlaceholder, }: Props) => JSX.Element;
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OnSubmitHandler } from '@atlaskit/form';
|
|
2
|
+
import { FormValues } from '../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
question: string;
|
|
5
|
+
statement?: string;
|
|
6
|
+
textPlaceholder: string;
|
|
7
|
+
textLabel: string;
|
|
8
|
+
onSubmit: OnSubmitHandler<FormValues>;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: ({ question, statement, textPlaceholder, textLabel, onSubmit, }: Props) => JSX.Element;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
/** Whether the form should be rendered */
|
|
5
|
+
shouldShow: boolean;
|
|
6
|
+
/** A function that returns Node to be rendered (`<ContextualSurvey/>`)
|
|
7
|
+
* Using a function as child so that the child node does
|
|
8
|
+
* not need to be evaluated if it is not mounted
|
|
9
|
+
*/
|
|
10
|
+
children: () => ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export default function SurveyMarshal(props: Props): JSX.Element;
|
|
13
|
+
export {};
|
package/docs/0-intro.tsx
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AtlassianInternalWarning,
|
|
5
|
+
code,
|
|
6
|
+
DevPreviewWarning,
|
|
7
|
+
Example,
|
|
8
|
+
md,
|
|
9
|
+
Props,
|
|
10
|
+
} from '@atlaskit/docs';
|
|
11
|
+
|
|
12
|
+
const BasicExample = require('../examples/00-usage').default;
|
|
13
|
+
|
|
14
|
+
export default md`
|
|
15
|
+
${(
|
|
16
|
+
<>
|
|
17
|
+
<div style={{ marginBottom: '0.5rem' }}>
|
|
18
|
+
<AtlassianInternalWarning />
|
|
19
|
+
</div>
|
|
20
|
+
<div style={{ marginTop: '0.5rem' }}>
|
|
21
|
+
<DevPreviewWarning />
|
|
22
|
+
</div>
|
|
23
|
+
</>
|
|
24
|
+
)}
|
|
25
|
+
|
|
26
|
+
This component is used to ask for feedback from the user, without affecting their usage of the page. It is styled similar to a \`flag\`.
|
|
27
|
+
|
|
28
|
+
The user flow for this component is:
|
|
29
|
+
|
|
30
|
+
#### Phase 1: Feedback
|
|
31
|
+
|
|
32
|
+
- Choosing a feedback score
|
|
33
|
+
- **(Optional)** Writing extra feedback in a \`textarea\`
|
|
34
|
+
- **(Optional)** User selects if they can be contacted about their feedback.
|
|
35
|
+
This is automatically set to \`true\` on the first change event for the \`textarea\`. It is set to \`false\` by default.
|
|
36
|
+
|
|
37
|
+
#### Phase 2 (Optional): Atlassian Research Signup
|
|
38
|
+
|
|
39
|
+
This phase will be entered when:
|
|
40
|
+
|
|
41
|
+
1. The user has selected they want to be contacted about their feedback
|
|
42
|
+
2. \`getUserHasAnsweredMailingList()\` has resolved to \`false\`
|
|
43
|
+
|
|
44
|
+
If this phase is not entered then a thank you message is displayed.
|
|
45
|
+
|
|
46
|
+
In this phase a prompt is opened which asks the user if they want to join the **Atlassian Research Group**.
|
|
47
|
+
|
|
48
|
+
After \`onMailingListAnswer()\` has resolved:
|
|
49
|
+
|
|
50
|
+
- If the user selected **yes** a thank you message is displayed
|
|
51
|
+
- If the user selected **no** the survey is closed.
|
|
52
|
+
|
|
53
|
+
#### Dismissing
|
|
54
|
+
|
|
55
|
+
\`onDismiss\` will be called when the survey is finished. This can happen when:
|
|
56
|
+
|
|
57
|
+
- The user explicitly closes the survey
|
|
58
|
+
- The user finishes the survey. The survey will be auto dismissed after a small delay
|
|
59
|
+
- The \`<SurveyComponent/>\` is unmounted
|
|
60
|
+
|
|
61
|
+
\`onDismiss\` will only ever be called once
|
|
62
|
+
|
|
63
|
+
\`onDismiss\` is called with arguments: \`{ trigger: DismissTrigger }\`. This can be used to distinguish between different rationales for dismissing
|
|
64
|
+
|
|
65
|
+
${code`
|
|
66
|
+
// Types
|
|
67
|
+
|
|
68
|
+
export enum DismissTrigger {
|
|
69
|
+
AutoDismiss = 'AUTO_DISMISS',
|
|
70
|
+
Manual = 'MANUAL',
|
|
71
|
+
Finished = 'FINISHED',
|
|
72
|
+
Unmount = 'UNMOUNT',
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type OnDismissArgs = { trigger: DismissTrigger };
|
|
76
|
+
|
|
77
|
+
onDismiss: (args: OnDismissArgs) => void;
|
|
78
|
+
|
|
79
|
+
// These types are exported publicly for you to use
|
|
80
|
+
|
|
81
|
+
import {DismissTrigger, OnDismissArgs} from '@atlaskit/contextual-survey';
|
|
82
|
+
`}
|
|
83
|
+
|
|
84
|
+
#### Responsibilities
|
|
85
|
+
|
|
86
|
+
- \`<SurveyMarshal/>\`: Responsible for placement and animation for the survey.
|
|
87
|
+
- \`<ContextualSurvey/>\`: Renders the survey questions
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
${code`import { ContextualSurvey, SurveyMarshal } from '@atlaskit/avatar';`}
|
|
92
|
+
|
|
93
|
+
${(
|
|
94
|
+
<Example
|
|
95
|
+
packageName="@atlaskit/contextual-survey"
|
|
96
|
+
Component={() => <BasicExample height="500px" />}
|
|
97
|
+
title="Basic example"
|
|
98
|
+
source={require('!!raw-loader!../examples/00-usage')}
|
|
99
|
+
/>
|
|
100
|
+
)}
|
|
101
|
+
|
|
102
|
+
${(
|
|
103
|
+
<Props
|
|
104
|
+
heading="Contextual Survey Props"
|
|
105
|
+
props={require('!!extract-react-types-loader!../src/components/ContextualSurvey')}
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
|
|
109
|
+
${(
|
|
110
|
+
<Props
|
|
111
|
+
heading="Survey Marshal Props"
|
|
112
|
+
props={require('!!extract-react-types-loader!../src/components/SurveyMarshal')}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
`;
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/contextual-survey",
|
|
3
|
+
"version": "2.0.11",
|
|
4
|
+
"description": "A React component used to ask the user for feedback",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"registry": "https://registry.npmjs.org/"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
9
|
+
"author": "Atlassian Pty Ltd",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"main": "dist/cjs/index.js",
|
|
12
|
+
"module": "dist/esm/index.js",
|
|
13
|
+
"module:es2019": "dist/es2019/index.js",
|
|
14
|
+
"types": "dist/types/index.d.ts",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"atlaskit:src": "src/index.ts",
|
|
17
|
+
"atlassian": {
|
|
18
|
+
"team": "Personalization",
|
|
19
|
+
"deprecatedAutoEntryPoints": true,
|
|
20
|
+
"releaseModel": "continuous",
|
|
21
|
+
"website": {
|
|
22
|
+
"name": "Contextual Survey"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@atlaskit/button": "^16.0.0",
|
|
27
|
+
"@atlaskit/checkbox": "^12.1.0",
|
|
28
|
+
"@atlaskit/form": "^8.4.0",
|
|
29
|
+
"@atlaskit/icon": "^21.9.0",
|
|
30
|
+
"@atlaskit/textarea": "^4.0.0",
|
|
31
|
+
"@atlaskit/theme": "^12.0.0",
|
|
32
|
+
"@atlaskit/tooltip": "^17.5.0",
|
|
33
|
+
"@babel/runtime": "^7.0.0",
|
|
34
|
+
"@emotion/core": "^10.0.9",
|
|
35
|
+
"react-transition-group": "^4.4.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^16.8.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@atlaskit/checkbox": "^12.1.0",
|
|
42
|
+
"@atlaskit/docs": "*",
|
|
43
|
+
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
44
|
+
"@testing-library/react": "^8.0.1",
|
|
45
|
+
"typescript": "3.9.6"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"atlaskit",
|
|
49
|
+
"react",
|
|
50
|
+
"ui"
|
|
51
|
+
],
|
|
52
|
+
"techstack": {
|
|
53
|
+
"@atlassian/frontend": {
|
|
54
|
+
"import-structure": "atlassian-conventions"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
58
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"./src/**/*.ts",
|
|
5
|
+
"./src/**/*.tsx",
|
|
6
|
+
"./docs/**/*.ts",
|
|
7
|
+
"./docs/**/*.tsx",
|
|
8
|
+
"./examples/**/*.ts",
|
|
9
|
+
"./examples/**/*.tsx",
|
|
10
|
+
"./example-helpers/**/*.ts",
|
|
11
|
+
"./example-helpers/**/*.tsx"
|
|
12
|
+
],
|
|
13
|
+
"compilerOptions": {
|
|
14
|
+
"baseUrl": "./"
|
|
15
|
+
}
|
|
16
|
+
}
|