@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +258 -0
  2. package/LICENSE +13 -0
  3. package/README.md +13 -0
  4. package/build/tsconfig.json +17 -0
  5. package/constants/package.json +7 -0
  6. package/dist/cjs/components/ContextualSurvey.js +274 -0
  7. package/dist/cjs/components/FeedbackAcknowledgement.js +26 -0
  8. package/dist/cjs/components/FeedbackScoreButtons.js +60 -0
  9. package/dist/cjs/components/SignUpPrompt.js +84 -0
  10. package/dist/cjs/components/SignUpSuccess.js +29 -0
  11. package/dist/cjs/components/SuccessContainer.js +35 -0
  12. package/dist/cjs/components/SurveyContainer.js +48 -0
  13. package/dist/cjs/components/SurveyForm.js +159 -0
  14. package/dist/cjs/components/SurveyMarshal.js +67 -0
  15. package/dist/cjs/components/useEscapeToDismiss.js +78 -0
  16. package/dist/cjs/constants.js +15 -0
  17. package/dist/cjs/index.js +35 -0
  18. package/dist/cjs/types.js +5 -0
  19. package/dist/cjs/version.json +5 -0
  20. package/dist/es2019/components/ContextualSurvey.js +178 -0
  21. package/dist/es2019/components/FeedbackAcknowledgement.js +12 -0
  22. package/dist/es2019/components/FeedbackScoreButtons.js +69 -0
  23. package/dist/es2019/components/SignUpPrompt.js +46 -0
  24. package/dist/es2019/components/SignUpSuccess.js +12 -0
  25. package/dist/es2019/components/SuccessContainer.js +22 -0
  26. package/dist/es2019/components/SurveyContainer.js +37 -0
  27. package/dist/es2019/components/SurveyForm.js +121 -0
  28. package/dist/es2019/components/SurveyMarshal.js +62 -0
  29. package/dist/es2019/components/useEscapeToDismiss.js +69 -0
  30. package/dist/es2019/constants.js +4 -0
  31. package/dist/es2019/index.js +2 -0
  32. package/dist/es2019/types.js +1 -0
  33. package/dist/es2019/version.json +5 -0
  34. package/dist/esm/components/ContextualSurvey.js +244 -0
  35. package/dist/esm/components/FeedbackAcknowledgement.js +13 -0
  36. package/dist/esm/components/FeedbackScoreButtons.js +44 -0
  37. package/dist/esm/components/SignUpPrompt.js +66 -0
  38. package/dist/esm/components/SignUpSuccess.js +16 -0
  39. package/dist/esm/components/SuccessContainer.js +21 -0
  40. package/dist/esm/components/SurveyContainer.js +30 -0
  41. package/dist/esm/components/SurveyForm.js +132 -0
  42. package/dist/esm/components/SurveyMarshal.js +55 -0
  43. package/dist/esm/components/useEscapeToDismiss.js +68 -0
  44. package/dist/esm/constants.js +4 -0
  45. package/dist/esm/index.js +2 -0
  46. package/dist/esm/types.js +1 -0
  47. package/dist/esm/version.json +5 -0
  48. package/dist/types/components/ContextualSurvey.d.ts +39 -0
  49. package/dist/types/components/FeedbackAcknowledgement.d.ts +2 -0
  50. package/dist/types/components/FeedbackScoreButtons.d.ts +6 -0
  51. package/dist/types/components/SignUpPrompt.d.ts +5 -0
  52. package/dist/types/components/SignUpSuccess.d.ts +4 -0
  53. package/dist/types/components/SuccessContainer.d.ts +6 -0
  54. package/dist/types/components/SurveyContainer.d.ts +7 -0
  55. package/dist/types/components/SurveyForm.d.ts +11 -0
  56. package/dist/types/components/SurveyMarshal.d.ts +13 -0
  57. package/dist/types/components/useEscapeToDismiss.d.ts +6 -0
  58. package/dist/types/constants.d.ts +2 -0
  59. package/dist/types/index.d.ts +3 -0
  60. package/dist/types/types.d.ts +5 -0
  61. package/docs/0-intro.tsx +115 -0
  62. package/package.json +58 -0
  63. package/tsconfig.json +16 -0
  64. package/types/package.json +7 -0
@@ -0,0 +1,4 @@
1
+ import { gridSize } from '@atlaskit/theme/constants';
2
+ export var surveyInnerWidth = gridSize() * 55; // 440
3
+
4
+ export var surveyOffset = gridSize() * 6; // 48
@@ -0,0 +1,2 @@
1
+ export { default as ContextualSurvey, DismissTrigger } from './components/ContextualSurvey';
2
+ export { default as SurveyMarshal } from './components/SurveyMarshal';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/contextual-survey",
3
+ "version": "2.0.11",
4
+ "sideEffects": false
5
+ }
@@ -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,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ onChange: (value: number) => void;
3
+ value: number | undefined;
4
+ }
5
+ declare const _default: ({ onChange, value }: Props) => JSX.Element;
6
+ export default _default;
@@ -0,0 +1,5 @@
1
+ interface Props {
2
+ onAnswer: (answer: boolean) => Promise<void>;
3
+ }
4
+ declare const _default: ({ onAnswer }: Props) => JSX.Element;
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ interface Props {
2
+ }
3
+ declare const _default: ({}: Props) => JSX.Element;
4
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface Props {
3
+ children: React.ReactNode;
4
+ }
5
+ declare const _default: ({ children }: Props) => JSX.Element;
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface Props {
3
+ children: React.ReactNode;
4
+ onDismiss: () => void;
5
+ }
6
+ declare const _default: ({ children, onDismiss }: Props) => JSX.Element;
7
+ 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 {};
@@ -0,0 +1,6 @@
1
+ export declare const escape: number;
2
+ declare type Args = {
3
+ onDismiss: () => void;
4
+ };
5
+ export default function useEscapeToDismiss({ onDismiss }: Args): void;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const surveyInnerWidth: number;
2
+ export declare const surveyOffset: number;
@@ -0,0 +1,3 @@
1
+ export { default as ContextualSurvey, DismissTrigger, } from './components/ContextualSurvey';
2
+ export type { OnDismissArgs } from './components/ContextualSurvey';
3
+ export { default as SurveyMarshal } from './components/SurveyMarshal';
@@ -0,0 +1,5 @@
1
+ export declare type FormValues = {
2
+ feedbackScore: number;
3
+ canContact: boolean;
4
+ writtenFeedback: string;
5
+ };
@@ -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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/contextual-survey/types",
3
+ "main": "../dist/cjs/types.js",
4
+ "module": "../dist/esm/types.js",
5
+ "module:es2019": "../dist/es2019/types.js",
6
+ "types": "../dist/types/types.d.ts"
7
+ }