@atlaskit/contextual-survey 3.0.3 → 3.1.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/CHANGELOG.md +13 -0
- package/afm-cc/tsconfig.json +6 -0
- package/afm-jira/tsconfig.json +6 -0
- package/afm-post-office/tsconfig.json +6 -0
- package/dist/cjs/compiled/ContextualSurvey.js +231 -0
- package/dist/cjs/compiled/FeedbackAcknowledgement.js +15 -0
- package/dist/cjs/compiled/FeedbackScoreButtons.compiled.css +10 -0
- package/dist/cjs/compiled/FeedbackScoreButtons.js +64 -0
- package/dist/cjs/compiled/SignUpPrompt.compiled.css +4 -0
- package/dist/cjs/compiled/SignUpPrompt.js +80 -0
- package/dist/cjs/compiled/SignUpSuccess.js +22 -0
- package/dist/cjs/compiled/SuccessContainer.compiled.css +4 -0
- package/dist/cjs/compiled/SuccessContainer.js +32 -0
- package/dist/cjs/compiled/SurveyContainer.compiled.css +11 -0
- package/dist/cjs/compiled/SurveyContainer.js +39 -0
- package/dist/cjs/compiled/SurveyForm.compiled.css +2 -0
- package/dist/cjs/compiled/SurveyForm.js +141 -0
- package/dist/cjs/compiled/SurveyMarshal.compiled.css +4 -0
- package/dist/cjs/compiled/SurveyMarshal.js +63 -0
- package/dist/cjs/compiled/useEscapeToDismiss.js +71 -0
- package/dist/cjs/fg-components.js +27 -0
- package/dist/cjs/index.js +4 -8
- package/dist/es2019/compiled/ContextualSurvey.js +176 -0
- package/dist/es2019/compiled/FeedbackAcknowledgement.js +6 -0
- package/dist/es2019/compiled/FeedbackScoreButtons.compiled.css +10 -0
- package/dist/es2019/compiled/FeedbackScoreButtons.js +51 -0
- package/dist/es2019/compiled/SignUpPrompt.compiled.css +4 -0
- package/dist/es2019/compiled/SignUpPrompt.js +47 -0
- package/dist/es2019/compiled/SignUpSuccess.js +11 -0
- package/dist/es2019/compiled/SuccessContainer.compiled.css +4 -0
- package/dist/es2019/compiled/SuccessContainer.js +21 -0
- package/dist/es2019/compiled/SurveyContainer.compiled.css +11 -0
- package/dist/es2019/compiled/SurveyContainer.js +26 -0
- package/dist/es2019/compiled/SurveyForm.compiled.css +2 -0
- package/dist/es2019/compiled/SurveyForm.js +119 -0
- package/dist/es2019/compiled/SurveyMarshal.compiled.css +4 -0
- package/dist/es2019/compiled/SurveyMarshal.js +56 -0
- package/dist/es2019/compiled/useEscapeToDismiss.js +65 -0
- package/dist/es2019/fg-components.js +13 -0
- package/dist/es2019/index.js +3 -2
- package/dist/esm/compiled/ContextualSurvey.js +221 -0
- package/dist/esm/compiled/FeedbackAcknowledgement.js +8 -0
- package/dist/esm/compiled/FeedbackScoreButtons.compiled.css +10 -0
- package/dist/esm/compiled/FeedbackScoreButtons.js +54 -0
- package/dist/esm/compiled/SignUpPrompt.compiled.css +4 -0
- package/dist/esm/compiled/SignUpPrompt.js +70 -0
- package/dist/esm/compiled/SignUpSuccess.js +15 -0
- package/dist/esm/compiled/SuccessContainer.compiled.css +4 -0
- package/dist/esm/compiled/SuccessContainer.js +22 -0
- package/dist/esm/compiled/SurveyContainer.compiled.css +11 -0
- package/dist/esm/compiled/SurveyContainer.js +29 -0
- package/dist/esm/compiled/SurveyForm.compiled.css +2 -0
- package/dist/esm/compiled/SurveyForm.js +131 -0
- package/dist/esm/compiled/SurveyMarshal.compiled.css +4 -0
- package/dist/esm/compiled/SurveyMarshal.js +54 -0
- package/dist/esm/compiled/useEscapeToDismiss.js +64 -0
- package/dist/esm/fg-components.js +19 -0
- package/dist/esm/index.js +3 -2
- package/dist/types/compiled/ContextualSurvey.d.ts +40 -0
- package/dist/types/compiled/FeedbackAcknowledgement.d.ts +3 -0
- package/dist/types/compiled/FeedbackScoreButtons.d.ts +11 -0
- package/dist/types/compiled/SignUpPrompt.d.ts +10 -0
- package/dist/types/compiled/SignUpSuccess.d.ts +5 -0
- package/dist/types/compiled/SuccessContainer.d.ts +6 -0
- package/dist/types/compiled/SurveyContainer.d.ts +11 -0
- package/dist/types/compiled/SurveyForm.d.ts +12 -0
- package/dist/types/compiled/SurveyMarshal.d.ts +16 -0
- package/dist/types/compiled/useEscapeToDismiss.d.ts +6 -0
- package/dist/types/components/ContextualSurvey.d.ts +1 -1
- package/dist/types/components/SurveyMarshal.d.ts +1 -2
- package/dist/types/fg-components.d.ts +5 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types-ts4.5/compiled/ContextualSurvey.d.ts +40 -0
- package/dist/types-ts4.5/compiled/FeedbackAcknowledgement.d.ts +3 -0
- package/dist/types-ts4.5/compiled/FeedbackScoreButtons.d.ts +11 -0
- package/dist/types-ts4.5/compiled/SignUpPrompt.d.ts +10 -0
- package/dist/types-ts4.5/compiled/SignUpSuccess.d.ts +5 -0
- package/dist/types-ts4.5/compiled/SuccessContainer.d.ts +6 -0
- package/dist/types-ts4.5/compiled/SurveyContainer.d.ts +11 -0
- package/dist/types-ts4.5/compiled/SurveyForm.d.ts +12 -0
- package/dist/types-ts4.5/compiled/SurveyMarshal.d.ts +16 -0
- package/dist/types-ts4.5/compiled/useEscapeToDismiss.d.ts +6 -0
- package/dist/types-ts4.5/components/ContextualSurvey.d.ts +1 -1
- package/dist/types-ts4.5/components/SurveyMarshal.d.ts +1 -2
- package/dist/types-ts4.5/fg-components.d.ts +5 -0
- package/dist/types-ts4.5/index.d.ts +3 -3
- package/package.json +12 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* SuccessContainer.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./SuccessContainer.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import CheckCircleIcon from '@atlaskit/icon/core/migration/success--check-circle';
|
|
6
|
+
import { G300 } from '@atlaskit/theme/colors';
|
|
7
|
+
const sectionStyles = null;
|
|
8
|
+
const iconContainerStyles = null;
|
|
9
|
+
export default (({
|
|
10
|
+
children
|
|
11
|
+
}) => /*#__PURE__*/React.createElement("section", {
|
|
12
|
+
className: ax(["_18u01jfw"])
|
|
13
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: ax(["_kqswstnw _154iv47k _1ltv1ejb"])
|
|
15
|
+
}, /*#__PURE__*/React.createElement(CheckCircleIcon, {
|
|
16
|
+
spacing: "spacious",
|
|
17
|
+
label: "",
|
|
18
|
+
"aria-hidden": true,
|
|
19
|
+
color: `var(--ds-icon-success, ${G300})`,
|
|
20
|
+
LEGACY_margin: "4px 0 0 0"
|
|
21
|
+
})), children));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko1sit{border-radius:var(--ds-border-radius,3px)}._154ipxbi{top:var(--ds-space-200,1pc)}
|
|
3
|
+
._16qsuzq3{box-shadow:var(--ds-shadow-overlay,0 20px 2pc -8px rgba(9,30,66,.25),0 0 1px rgba(9,30,66,.31))}
|
|
4
|
+
._19bv1ejb{padding-left:var(--ds-space-300,24px)}
|
|
5
|
+
._1bsb1vif{width:440px}
|
|
6
|
+
._1xi2pxbi{right:var(--ds-space-200,1pc)}
|
|
7
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
8
|
+
._ca0q1ejb{padding-top:var(--ds-space-300,24px)}
|
|
9
|
+
._kqswstnw{position:absolute}
|
|
10
|
+
._n3td1ejb{padding-bottom:var(--ds-space-300,24px)}
|
|
11
|
+
._u5f31ejb{padding-right:var(--ds-space-300,24px)}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* SurveyContainer.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./SurveyContainer.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { IconButton as Button } from '@atlaskit/button/new';
|
|
6
|
+
import CrossIcon from '@atlaskit/icon/core/migration/close--cross';
|
|
7
|
+
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
8
|
+
import { surveyInnerWidth } from '../constants';
|
|
9
|
+
const containerStyles = null;
|
|
10
|
+
const buttonWrapperStyles = null;
|
|
11
|
+
export default (({
|
|
12
|
+
children,
|
|
13
|
+
onDismiss
|
|
14
|
+
}) => {
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
style: {},
|
|
17
|
+
className: ax(["_2rko1sit _bfhk1bhr _ca0q1ejb _u5f31ejb _n3td1ejb _19bv1ejb _16qsuzq3 _1bsb1vif"])
|
|
18
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: ax(["_kqswstnw _154ipxbi _1xi2pxbi"])
|
|
20
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
21
|
+
icon: CrossIcon,
|
|
22
|
+
label: "Dismiss",
|
|
23
|
+
appearance: "subtle",
|
|
24
|
+
onClick: onDismiss
|
|
25
|
+
})), children);
|
|
26
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* SurveyForm.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./SurveyForm.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
import { useCallback, useRef, useState } from 'react';
|
|
7
|
+
import { Transition } from 'react-transition-group';
|
|
8
|
+
import Button from '@atlaskit/button/new';
|
|
9
|
+
import { Checkbox } from '@atlaskit/checkbox';
|
|
10
|
+
import Form, { CheckboxField, Field, FormFooter } from '@atlaskit/form';
|
|
11
|
+
import Heading from '@atlaskit/heading';
|
|
12
|
+
import { Stack, Text } from '@atlaskit/primitives/compiled';
|
|
13
|
+
import Textarea from '@atlaskit/textarea';
|
|
14
|
+
import FeedbackScoreButtons from './FeedbackScoreButtons';
|
|
15
|
+
const transitionBaseStyles = null;
|
|
16
|
+
const getExpandedHeight = (ref, state) => {
|
|
17
|
+
if (!ref.current) {
|
|
18
|
+
return '0';
|
|
19
|
+
}
|
|
20
|
+
switch (state) {
|
|
21
|
+
case 'entering':
|
|
22
|
+
return `${ref.current.scrollHeight}px`;
|
|
23
|
+
case 'entered':
|
|
24
|
+
// needed for TextField auto height expand
|
|
25
|
+
return `none`;
|
|
26
|
+
default:
|
|
27
|
+
return '0';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const transitionDuration = 200;
|
|
31
|
+
export default (({
|
|
32
|
+
question,
|
|
33
|
+
statement,
|
|
34
|
+
textPlaceholder,
|
|
35
|
+
textLabel,
|
|
36
|
+
onSubmit
|
|
37
|
+
}) => {
|
|
38
|
+
const [expanded, setExpanded] = useState(false);
|
|
39
|
+
const [canContactDefault, setCanContactDefault] = useState(false);
|
|
40
|
+
const hasAutoFilledCanContactRef = useRef(false);
|
|
41
|
+
const expandedAreaRef = useRef(null);
|
|
42
|
+
const onScoreSelect = useCallback(() => {
|
|
43
|
+
setExpanded(true);
|
|
44
|
+
}, [setExpanded]);
|
|
45
|
+
|
|
46
|
+
// On the first type the user types some feedback we auto select
|
|
47
|
+
// the option for allowing feedback. This automatic selection only
|
|
48
|
+
// happens once. After that it is up to the user to control
|
|
49
|
+
const onFeedbackChange = useCallback(() => {
|
|
50
|
+
if (hasAutoFilledCanContactRef.current) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
hasAutoFilledCanContactRef.current = true;
|
|
54
|
+
setCanContactDefault(true);
|
|
55
|
+
}, []);
|
|
56
|
+
return /*#__PURE__*/React.createElement("section", {
|
|
57
|
+
"aria-labelledby": "contextualSurveyQuestion"
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
59
|
+
space: "space.150"
|
|
60
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
61
|
+
id: "contextualSurveyQuestion",
|
|
62
|
+
size: "xsmall"
|
|
63
|
+
}, question), statement && /*#__PURE__*/React.createElement(Text, {
|
|
64
|
+
as: "p",
|
|
65
|
+
id: "contextualSurveyStatement"
|
|
66
|
+
}, statement)), /*#__PURE__*/React.createElement(Form, {
|
|
67
|
+
onSubmit: onSubmit
|
|
68
|
+
}, ({
|
|
69
|
+
formProps,
|
|
70
|
+
submitting
|
|
71
|
+
}) => /*#__PURE__*/React.createElement("form", formProps, /*#__PURE__*/React.createElement(Field, {
|
|
72
|
+
name: "feedbackScore",
|
|
73
|
+
isDisabled: submitting,
|
|
74
|
+
isRequired: true
|
|
75
|
+
}, ({
|
|
76
|
+
fieldProps
|
|
77
|
+
}) => /*#__PURE__*/React.createElement(FeedbackScoreButtons, _extends({}, fieldProps, {
|
|
78
|
+
onChange: score => {
|
|
79
|
+
fieldProps.onChange(score);
|
|
80
|
+
onScoreSelect();
|
|
81
|
+
}
|
|
82
|
+
}))), /*#__PURE__*/React.createElement(Transition, {
|
|
83
|
+
in: expanded,
|
|
84
|
+
timeout: transitionDuration,
|
|
85
|
+
mountOnEnter: true
|
|
86
|
+
}, state => /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
style: {
|
|
88
|
+
transition: `max-height ${transitionDuration}ms ease-in-out`,
|
|
89
|
+
maxHeight: getExpandedHeight(expandedAreaRef, state)
|
|
90
|
+
},
|
|
91
|
+
ref: expandedAreaRef,
|
|
92
|
+
className: ax(["_1reo15vq _18m915vq"])
|
|
93
|
+
}, /*#__PURE__*/React.createElement(Field, {
|
|
94
|
+
name: "writtenFeedback",
|
|
95
|
+
defaultValue: "",
|
|
96
|
+
isDisabled: submitting
|
|
97
|
+
}, ({
|
|
98
|
+
fieldProps
|
|
99
|
+
}) => /*#__PURE__*/React.createElement(Textarea, _extends({}, fieldProps, {
|
|
100
|
+
"aria-label": textLabel,
|
|
101
|
+
placeholder: textPlaceholder,
|
|
102
|
+
onChange: event => {
|
|
103
|
+
fieldProps.onChange(event);
|
|
104
|
+
onFeedbackChange();
|
|
105
|
+
}
|
|
106
|
+
}))), /*#__PURE__*/React.createElement(CheckboxField, {
|
|
107
|
+
name: "canContact",
|
|
108
|
+
isDisabled: submitting,
|
|
109
|
+
defaultIsChecked: canContactDefault
|
|
110
|
+
}, ({
|
|
111
|
+
fieldProps
|
|
112
|
+
}) => /*#__PURE__*/React.createElement(Checkbox, _extends({}, fieldProps, {
|
|
113
|
+
label: "Atlassian can contact me about this feedback"
|
|
114
|
+
}))), /*#__PURE__*/React.createElement(FormFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
115
|
+
type: "submit",
|
|
116
|
+
appearance: "primary",
|
|
117
|
+
isLoading: submitting
|
|
118
|
+
}, "Submit")))))));
|
|
119
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* SurveyMarshal.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./SurveyMarshal.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { Transition } from 'react-transition-group';
|
|
6
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
7
|
+
import { surveyInnerWidth, surveyOffset } from '../constants';
|
|
8
|
+
const animationDuration = 300;
|
|
9
|
+
const offscreen = {
|
|
10
|
+
translateX: `${surveyInnerWidth + surveyOffset}px`,
|
|
11
|
+
opacity: '0'
|
|
12
|
+
};
|
|
13
|
+
const getAnimationProps = state => {
|
|
14
|
+
switch (state) {
|
|
15
|
+
case 'entered':
|
|
16
|
+
{
|
|
17
|
+
return {
|
|
18
|
+
translateX: '0',
|
|
19
|
+
opacity: '1'
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
case 'entering':
|
|
23
|
+
case 'unmounted':
|
|
24
|
+
case 'exited':
|
|
25
|
+
case 'exiting':
|
|
26
|
+
{
|
|
27
|
+
return offscreen;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const transitionBaseStyles = null;
|
|
32
|
+
export default function SurveyMarshal(props) {
|
|
33
|
+
const {
|
|
34
|
+
children,
|
|
35
|
+
shouldShow
|
|
36
|
+
} = props;
|
|
37
|
+
return /*#__PURE__*/React.createElement(Transition, {
|
|
38
|
+
in: shouldShow,
|
|
39
|
+
timeout: animationDuration,
|
|
40
|
+
unmountOnExit: true
|
|
41
|
+
}, state => {
|
|
42
|
+
const {
|
|
43
|
+
translateX,
|
|
44
|
+
opacity
|
|
45
|
+
} = getAnimationProps(state);
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
style: {
|
|
48
|
+
opacity: opacity,
|
|
49
|
+
transition: `all ${animationDuration}ms ease-in-out`,
|
|
50
|
+
zIndex: layers.flag(),
|
|
51
|
+
transform: `translateX(${translateX})`
|
|
52
|
+
},
|
|
53
|
+
className: ax(["_kqsw1n9t _1xi2ckbl _94n5ckbl _k8m01rjc"])
|
|
54
|
+
}, children());
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
export const escape = 27;
|
|
3
|
+
function bind(target, eventName, handler, options) {
|
|
4
|
+
target.addEventListener(eventName, handler, options);
|
|
5
|
+
return function unbind() {
|
|
6
|
+
target.removeEventListener(eventName, handler, options);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function shouldDismiss(target) {
|
|
10
|
+
if (!target) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (!(target instanceof HTMLElement)) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Closest doesn't exist for ie11
|
|
18
|
+
// Because we cannot be sure if in a text area - just don't allow dismissing
|
|
19
|
+
if (!target.closest) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const inTextArea = Boolean(target.closest('textarea'));
|
|
23
|
+
|
|
24
|
+
// Allow dismissing if not in a textarea
|
|
25
|
+
return !inTextArea;
|
|
26
|
+
}
|
|
27
|
+
export default function useEscapeToDismiss({
|
|
28
|
+
onDismiss
|
|
29
|
+
}) {
|
|
30
|
+
const onDismissRef = useRef(onDismiss);
|
|
31
|
+
|
|
32
|
+
// Defensively accounting for consumer passing in a new function
|
|
33
|
+
// each time. We just want to call the latest one
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
onDismissRef.current = onDismiss;
|
|
36
|
+
}, [onDismiss]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
let unbind;
|
|
39
|
+
function onKeyDown(event) {
|
|
40
|
+
if (event.keyCode !== escape) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Escape pressed
|
|
45
|
+
|
|
46
|
+
// We don't want to close if the user is typing in the text area
|
|
47
|
+
if (!shouldDismiss(event.target)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (unbind) {
|
|
51
|
+
// only want to call dismiss once
|
|
52
|
+
unbind();
|
|
53
|
+
}
|
|
54
|
+
onDismissRef.current();
|
|
55
|
+
}
|
|
56
|
+
unbind = bind(window, 'keydown',
|
|
57
|
+
// @ts-ignore: the typescript for this is lame
|
|
58
|
+
onKeyDown, {
|
|
59
|
+
passive: true
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// double calls to unbind is fine
|
|
63
|
+
return unbind;
|
|
64
|
+
}, []);
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { default as CompiledContextualSurvey } from './compiled/ContextualSurvey';
|
|
4
|
+
import { default as CompiledSurveyMarshal } from './compiled/SurveyMarshal';
|
|
5
|
+
// exported props for FG check
|
|
6
|
+
import { default as EmotionContextualSurvey } from './components/ContextualSurvey';
|
|
7
|
+
import { default as EmotionSurveyMarshal } from './components/SurveyMarshal';
|
|
8
|
+
export const ContextualSurvey = props =>
|
|
9
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
10
|
+
fg('platform_contextual_survey_enable_compiled_fg') ? /*#__PURE__*/React.createElement(CompiledContextualSurvey, props) : /*#__PURE__*/React.createElement(EmotionContextualSurvey, props);
|
|
11
|
+
export const SurveyMarshal = props =>
|
|
12
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
13
|
+
fg('platform_contextual_survey_enable_compiled_fg') ? /*#__PURE__*/React.createElement(CompiledSurveyMarshal, props) : /*#__PURE__*/React.createElement(EmotionSurveyMarshal, props);
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { DismissTrigger } from './components/ContextualSurvey';
|
|
2
|
+
export { ContextualSurvey } from './fg-components';
|
|
3
|
+
export { SurveyMarshal } from './fg-components';
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import FeedbackAcknowledgement from './FeedbackAcknowledgement';
|
|
6
|
+
import SignUpPrompt from './SignUpPrompt';
|
|
7
|
+
import SignUpSuccess from './SignUpSuccess';
|
|
8
|
+
import SurveyContainer from './SurveyContainer';
|
|
9
|
+
import SurveyForm from './SurveyForm';
|
|
10
|
+
import useEscapeToDismiss from './useEscapeToDismiss';
|
|
11
|
+
export var DismissTrigger = /*#__PURE__*/function (DismissTrigger) {
|
|
12
|
+
DismissTrigger["AutoDismiss"] = "AUTO_DISMISS";
|
|
13
|
+
DismissTrigger["Manual"] = "MANUAL";
|
|
14
|
+
DismissTrigger["Finished"] = "FINISHED";
|
|
15
|
+
DismissTrigger["Unmount"] = "UNMOUNT";
|
|
16
|
+
return DismissTrigger;
|
|
17
|
+
}({});
|
|
18
|
+
export var AUTO_DISAPPEAR_DURATION = 8000;
|
|
19
|
+
export default (function (_ref) {
|
|
20
|
+
var question = _ref.question,
|
|
21
|
+
statement = _ref.statement,
|
|
22
|
+
onDismiss = _ref.onDismiss,
|
|
23
|
+
onSubmit = _ref.onSubmit,
|
|
24
|
+
onMailingListAnswer = _ref.onMailingListAnswer,
|
|
25
|
+
getUserHasAnsweredMailingList = _ref.getUserHasAnsweredMailingList,
|
|
26
|
+
_ref$textLabel = _ref.textLabel,
|
|
27
|
+
textLabel = _ref$textLabel === void 0 ? 'Why did you give that rating' : _ref$textLabel,
|
|
28
|
+
_ref$textPlaceholder = _ref.textPlaceholder,
|
|
29
|
+
textPlaceholder = _ref$textPlaceholder === void 0 ? 'Tell us why' : _ref$textPlaceholder;
|
|
30
|
+
var autoDisappearTimeoutRef = useRef(null);
|
|
31
|
+
|
|
32
|
+
// only allow a single dismiss for a component
|
|
33
|
+
var isDismissedRef = useRef(false);
|
|
34
|
+
var tryDismiss = useCallback(function (trigger) {
|
|
35
|
+
// Already called dismiss once
|
|
36
|
+
if (isDismissedRef.current) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
isDismissedRef.current = true;
|
|
40
|
+
onDismissRef.current({
|
|
41
|
+
trigger: trigger
|
|
42
|
+
});
|
|
43
|
+
}, []);
|
|
44
|
+
var _useState = useState('SURVEY'),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
currentStep = _useState2[0],
|
|
47
|
+
setCurrentStep = _useState2[1];
|
|
48
|
+
var trySetCurrentStep = useCallback(function (step) {
|
|
49
|
+
// Already dismissed - cannot update the step
|
|
50
|
+
if (isDismissedRef.current) {
|
|
51
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.log("not setting step \"".concat(step, "\" as survey is already dismissed"));
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setCurrentStep(step);
|
|
58
|
+
}, [setCurrentStep]);
|
|
59
|
+
|
|
60
|
+
// using a ref so that we don't break all of our caches if a consumer is using an arrow function
|
|
61
|
+
var onDismissRef = useRef(onDismiss);
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
onDismissRef.current = onDismiss;
|
|
64
|
+
}, [onDismiss]);
|
|
65
|
+
|
|
66
|
+
// reset isDismissedRef.current on mount to be compatible with double render in react18 strict mode
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
isDismissedRef.current = false;
|
|
69
|
+
}, []);
|
|
70
|
+
var tryClearTimeout = useCallback(function () {
|
|
71
|
+
var id = autoDisappearTimeoutRef.current;
|
|
72
|
+
if (id) {
|
|
73
|
+
clearTimeout(id);
|
|
74
|
+
autoDisappearTimeoutRef.current = null;
|
|
75
|
+
}
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
// Cleanup any auto dismiss after dismiss
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
return function unmount() {
|
|
81
|
+
tryClearTimeout();
|
|
82
|
+
tryDismiss(DismissTrigger.Unmount);
|
|
83
|
+
};
|
|
84
|
+
}, [tryClearTimeout, tryDismiss]);
|
|
85
|
+
var onSurveySubmit = useCallback( /*#__PURE__*/function () {
|
|
86
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(formValues, form) {
|
|
87
|
+
var callback,
|
|
88
|
+
userHasAnswered,
|
|
89
|
+
_args = arguments;
|
|
90
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
91
|
+
while (1) switch (_context.prev = _context.next) {
|
|
92
|
+
case 0:
|
|
93
|
+
callback = _args.length > 2 && _args[2] !== undefined ? _args[2] : function () {};
|
|
94
|
+
_context.next = 3;
|
|
95
|
+
return onSubmit(formValues);
|
|
96
|
+
case 3:
|
|
97
|
+
if (!isDismissedRef.current) {
|
|
98
|
+
_context.next = 6;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
callback();
|
|
102
|
+
return _context.abrupt("return");
|
|
103
|
+
case 6:
|
|
104
|
+
if (formValues.canContact) {
|
|
105
|
+
_context.next = 10;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
callback();
|
|
109
|
+
trySetCurrentStep('POST_SURVEY_NO_CONSENT');
|
|
110
|
+
return _context.abrupt("return");
|
|
111
|
+
case 10:
|
|
112
|
+
_context.next = 12;
|
|
113
|
+
return getUserHasAnsweredMailingList();
|
|
114
|
+
case 12:
|
|
115
|
+
userHasAnswered = _context.sent;
|
|
116
|
+
callback();
|
|
117
|
+
|
|
118
|
+
// Not entering phase 2: user has already answered this question
|
|
119
|
+
if (!userHasAnswered) {
|
|
120
|
+
_context.next = 17;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
trySetCurrentStep('POST_SURVEY_HAS_SIGN_UP');
|
|
124
|
+
return _context.abrupt("return");
|
|
125
|
+
case 17:
|
|
126
|
+
// Enter phase 2
|
|
127
|
+
trySetCurrentStep('SIGN_UP_PROMPT');
|
|
128
|
+
case 18:
|
|
129
|
+
case "end":
|
|
130
|
+
return _context.stop();
|
|
131
|
+
}
|
|
132
|
+
}, _callee);
|
|
133
|
+
}));
|
|
134
|
+
return function (_x, _x2) {
|
|
135
|
+
return _ref2.apply(this, arguments);
|
|
136
|
+
};
|
|
137
|
+
}(), [getUserHasAnsweredMailingList, onSubmit, trySetCurrentStep]);
|
|
138
|
+
var onMailingListResponse = useCallback( /*#__PURE__*/function () {
|
|
139
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(answer) {
|
|
140
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
141
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
142
|
+
case 0:
|
|
143
|
+
_context2.next = 2;
|
|
144
|
+
return onMailingListAnswer(answer);
|
|
145
|
+
case 2:
|
|
146
|
+
if (!answer) {
|
|
147
|
+
_context2.next = 5;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
trySetCurrentStep('SIGN_UP_SUCCESS');
|
|
151
|
+
return _context2.abrupt("return");
|
|
152
|
+
case 5:
|
|
153
|
+
// We have already thanked to user, we can simply close
|
|
154
|
+
tryDismiss(DismissTrigger.Finished);
|
|
155
|
+
case 6:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context2.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee2);
|
|
160
|
+
}));
|
|
161
|
+
return function (_x3) {
|
|
162
|
+
return _ref3.apply(this, arguments);
|
|
163
|
+
};
|
|
164
|
+
}(),
|
|
165
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
|
+
[tryDismiss, trySetCurrentStep]);
|
|
167
|
+
|
|
168
|
+
// Start the auto disappear when we are finished
|
|
169
|
+
useEffect(function () {
|
|
170
|
+
// Already dismissed
|
|
171
|
+
if (isDismissedRef.current) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Timeout already scheduled
|
|
176
|
+
if (autoDisappearTimeoutRef.current) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (['SIGN_UP_SUCCESS', 'POST_SURVEY_NO_CONSENT', 'POST_SURVEY_HAS_SIGN_UP'].includes(currentStep)) {
|
|
180
|
+
autoDisappearTimeoutRef.current = window.setTimeout(function () {
|
|
181
|
+
return tryDismiss(DismissTrigger.AutoDismiss);
|
|
182
|
+
}, AUTO_DISAPPEAR_DURATION);
|
|
183
|
+
}
|
|
184
|
+
}, [currentStep, tryDismiss]);
|
|
185
|
+
useEscapeToDismiss({
|
|
186
|
+
onDismiss: function onDismiss() {
|
|
187
|
+
return tryDismiss(DismissTrigger.Manual);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
var content = function () {
|
|
191
|
+
if (currentStep === 'SURVEY') {
|
|
192
|
+
return /*#__PURE__*/React.createElement(SurveyForm, {
|
|
193
|
+
question: question,
|
|
194
|
+
statement: statement,
|
|
195
|
+
textLabel: textLabel,
|
|
196
|
+
textPlaceholder: textPlaceholder,
|
|
197
|
+
onSubmit: onSurveySubmit
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (currentStep === 'SIGN_UP_PROMPT') {
|
|
201
|
+
return /*#__PURE__*/React.createElement(SignUpPrompt, {
|
|
202
|
+
onAnswer: onMailingListResponse
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (currentStep === 'SIGN_UP_SUCCESS') {
|
|
206
|
+
return /*#__PURE__*/React.createElement(SignUpSuccess, null);
|
|
207
|
+
}
|
|
208
|
+
if (currentStep === 'POST_SURVEY_NO_CONSENT' || currentStep === 'POST_SURVEY_HAS_SIGN_UP') {
|
|
209
|
+
return /*#__PURE__*/React.createElement(FeedbackAcknowledgement, null);
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}();
|
|
213
|
+
var manualDismiss = useCallback(function () {
|
|
214
|
+
// clear any pending timers
|
|
215
|
+
tryClearTimeout();
|
|
216
|
+
tryDismiss(DismissTrigger.Manual);
|
|
217
|
+
}, [tryDismiss, tryClearTimeout]);
|
|
218
|
+
return /*#__PURE__*/React.createElement(SurveyContainer, {
|
|
219
|
+
onDismiss: manualDismiss
|
|
220
|
+
}, content);
|
|
221
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Heading from '@atlaskit/heading';
|
|
3
|
+
import SuccessContainer from './SuccessContainer';
|
|
4
|
+
export default (function () {
|
|
5
|
+
return /*#__PURE__*/React.createElement(SuccessContainer, null, /*#__PURE__*/React.createElement(Heading, {
|
|
6
|
+
size: "xsmall"
|
|
7
|
+
}, "Thanks for your feedback"));
|
|
8
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
._13lsf1ug>*{flex-basis:0%}
|
|
2
|
+
._19pku2gc{margin-top:var(--ds-space-100,8px)}
|
|
3
|
+
._1bah1yb4{justify-content:space-between}
|
|
4
|
+
._1e0c1txw{display:flex}
|
|
5
|
+
._1o0a1h6o>*>button{justify-content:center}
|
|
6
|
+
._nbgx1epz>span{width:var(--ds-space-1000,5pc)}
|
|
7
|
+
._otyr1ejb{margin-bottom:var(--ds-space-300,24px)}
|
|
8
|
+
._pof3u2gc>*+*{margin-left:var(--ds-space-100,8px)}
|
|
9
|
+
._v5ynkb7n>*{flex-shrink:1}
|
|
10
|
+
._zdxokb7n>*{flex-grow:1}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* FeedbackScoreButtons.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./FeedbackScoreButtons.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import Button from '@atlaskit/button/new';
|
|
6
|
+
import { Text } from '@atlaskit/primitives/compiled';
|
|
7
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
8
|
+
var tooltipMessage = ['Strongly disagree', 'Disagree', 'Slightly disagree', 'Neutral', 'Slightly agree', 'Agree', 'Strongly agree'];
|
|
9
|
+
var buttonWrapperStyles = null;
|
|
10
|
+
var descriptionWrapperStyles = null;
|
|
11
|
+
export default (function (_ref) {
|
|
12
|
+
var onChange = _ref.onChange,
|
|
13
|
+
value = _ref.value;
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: ax(["_1e0c1txw _1bah1yb4 _zdxokb7n _v5ynkb7n _13lsf1ug _1o0a1h6o _pof3u2gc"])
|
|
16
|
+
}, Array.from({
|
|
17
|
+
length: 7
|
|
18
|
+
}, function (_, i) {
|
|
19
|
+
var score = i + 1;
|
|
20
|
+
var isSelected = value === score;
|
|
21
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
22
|
+
content: tooltipMessage[i],
|
|
23
|
+
key: score,
|
|
24
|
+
hideTooltipOnClick: true
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
26
|
+
onClick: function onClick() {
|
|
27
|
+
return onChange(score);
|
|
28
|
+
},
|
|
29
|
+
isSelected: isSelected,
|
|
30
|
+
"aria-pressed": isSelected,
|
|
31
|
+
"aria-describedby": "contextualSurveyStatement",
|
|
32
|
+
"aria-label": tooltipMessage[i],
|
|
33
|
+
shouldFitContainer: true
|
|
34
|
+
}, score));
|
|
35
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
"aria-hidden": true,
|
|
37
|
+
className: ax(["_1e0c1txw _19pku2gc _otyr1ejb _1bah1yb4 _nbgx1epz"])
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
39
|
+
color: "color.text.subtlest",
|
|
40
|
+
size: "UNSAFE_small",
|
|
41
|
+
weight: "semibold",
|
|
42
|
+
align: "start"
|
|
43
|
+
}, "Strongly disagree"), /*#__PURE__*/React.createElement(Text, {
|
|
44
|
+
color: "color.text.subtlest",
|
|
45
|
+
size: "UNSAFE_small",
|
|
46
|
+
weight: "semibold",
|
|
47
|
+
align: "center"
|
|
48
|
+
}, "Neutral"), /*#__PURE__*/React.createElement(Text, {
|
|
49
|
+
color: "color.text.subtlest",
|
|
50
|
+
size: "UNSAFE_small",
|
|
51
|
+
weight: "semibold",
|
|
52
|
+
align: "end"
|
|
53
|
+
}, "Strongly agree")));
|
|
54
|
+
});
|