freemium-survey-components 0.3.0 → 0.5.1-beta.2
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 +3 -1
- package/dist/declarations/lib/types/components/button/index.d.ts +24 -0
- package/dist/declarations/lib/types/components/checkbox/index.d.ts +13 -0
- package/{lib → dist/declarations/lib}/types/components/index.d.ts +0 -0
- package/dist/declarations/lib/types/components/nps/index.d.ts +22 -0
- package/dist/declarations/lib/types/components/progressbar/index.d.ts +7 -0
- package/dist/declarations/lib/types/components/radio-button/index.d.ts +26 -0
- package/dist/declarations/lib/types/components/text-input/index.d.ts +51 -0
- package/dist/declarations/lib/types/index.d.ts +1 -0
- package/dist/declarations/lib/types/survey/index.d.ts +11 -0
- package/{lib → dist/declarations/lib}/types/survey/question.d.ts +0 -0
- package/{lib → dist/declarations/lib}/types/utils.d.ts +0 -0
- package/dist/freemium-survey-components.cjs.d.ts +1 -0
- package/dist/freemium-survey-components.cjs.dev.js +336 -0
- package/dist/freemium-survey-components.cjs.js +7 -0
- package/dist/freemium-survey-components.cjs.prod.js +336 -0
- package/dist/freemium-survey-components.esm.js +328 -0
- package/package.json +16 -10
- package/yarn-error.log +15014 -0
- package/lib/index.cjs.js +0 -1
- package/lib/index.esm.js +0 -1
- package/lib/types/components/button/button.stories.d.ts +0 -1
- package/lib/types/components/button/index.d.ts +0 -2392
- package/lib/types/components/checkbox/checkbox.stories.d.ts +0 -1
- package/lib/types/components/checkbox/index.d.ts +0 -50
- package/lib/types/components/nps/index.d.ts +0 -59
- package/lib/types/components/nps/nps.stories.d.ts +0 -1
- package/lib/types/components/progressbar/index.d.ts +0 -35
- package/lib/types/components/progressbar/progressbar.stories.d.ts +0 -1
- package/lib/types/components/radio-button/index.d.ts +0 -70
- package/lib/types/components/radio-button/radio.stories.d.ts +0 -1
- package/lib/types/components/text-input/index.d.ts +0 -52
- package/lib/types/components/text-input/text-input.stories.d.ts +0 -1
- package/lib/types/index.d.ts +0 -2
- package/lib/types/mock.d.ts +0 -2
- package/lib/types/survey/index.d.ts +0 -12
- package/lib/types/survey/survey.stories.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# Freemium-survey-components
|
|
1
|
+
# [Freemium-survey-components](https://www.npmjs.com/package/freemium-survey-components)
|
|
2
|
+
|
|
3
|
+
⚠️ **Not ready for public usage yet!**
|
|
2
4
|
|
|
3
5
|
Freemium-survey-components is a react package that renders the survey collection form given the survey object from the survey-serv platform service.
|
|
4
6
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const BUTTON_SIZE_VARIANTS: {
|
|
3
|
+
LARGE: string;
|
|
4
|
+
MINI: string;
|
|
5
|
+
NORMAL: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type ButtonSizeKey = 'large' | 'mini' | 'normal' | undefined;
|
|
8
|
+
export declare type buttonHTMLType = 'button' | 'reset' | 'submit' | undefined;
|
|
9
|
+
export declare type buttonType = 'primary' | 'secondary' | 'danger' | 'link';
|
|
10
|
+
export declare type ButtonProps = {
|
|
11
|
+
type?: buttonType;
|
|
12
|
+
htmlType?: buttonHTMLType;
|
|
13
|
+
size?: ButtonSizeKey;
|
|
14
|
+
inline?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
large?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
ref?: any;
|
|
19
|
+
onClick?: any;
|
|
20
|
+
overrideStyleClassName?: string;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
children: any;
|
|
23
|
+
};
|
|
24
|
+
export declare const Button: (props: ButtonProps & React.HTMLAttributes<HTMLButtonElement>) => JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Option = {
|
|
3
|
+
id: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
interface CheckboxGroupInterface {
|
|
8
|
+
options: Array<Option>;
|
|
9
|
+
values: string[];
|
|
10
|
+
onChangeHandler: (newValues: string[]) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const CheckboxGroup: ({ values, options, onChangeHandler, }: CheckboxGroupInterface) => JSX.Element;
|
|
13
|
+
export { CheckboxGroup };
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type ButtonShapeType = 'rounded' | 'square' | 'curved';
|
|
3
|
+
declare type NPSProps = {
|
|
4
|
+
type_info: {
|
|
5
|
+
linear_scale: {
|
|
6
|
+
button_shape: ButtonShapeType;
|
|
7
|
+
button_style: any;
|
|
8
|
+
};
|
|
9
|
+
validation: {
|
|
10
|
+
min: number;
|
|
11
|
+
};
|
|
12
|
+
score_presets: {
|
|
13
|
+
start: string;
|
|
14
|
+
end: string;
|
|
15
|
+
};
|
|
16
|
+
footer_text: string;
|
|
17
|
+
};
|
|
18
|
+
onChangeHandler: (value: number) => void;
|
|
19
|
+
npsValue: number;
|
|
20
|
+
};
|
|
21
|
+
declare const NPS: (props: NPSProps) => JSX.Element;
|
|
22
|
+
export { NPS };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RadioButtonProps {
|
|
3
|
+
checked: boolean;
|
|
4
|
+
children: string;
|
|
5
|
+
value: string | number;
|
|
6
|
+
name: string;
|
|
7
|
+
onChange: (e: any) => void;
|
|
8
|
+
id?: string;
|
|
9
|
+
autoFocus?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface RadioGroupInterface {
|
|
12
|
+
options: Array<{
|
|
13
|
+
id: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}>;
|
|
17
|
+
value: string;
|
|
18
|
+
name: string;
|
|
19
|
+
onChangeHandler: (newValue: string) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const RadioGroup: ({ name, options, value, onChangeHandler, }: RadioGroupInterface) => JSX.Element;
|
|
22
|
+
declare const Radio: React.ComponentType<Partial<{
|
|
23
|
+
checked: boolean;
|
|
24
|
+
autoFocus: boolean;
|
|
25
|
+
}> & Pick<RadioButtonProps & React.RefAttributes<HTMLInputElement>, "ref" | "name" | "value" | "id" | "children" | "onChange" | "key">>;
|
|
26
|
+
export { Radio, RadioGroup };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface InputProps extends React.HTMLAttributes<HTMLInputElement> {
|
|
3
|
+
isErrored?: boolean;
|
|
4
|
+
showCount?: boolean;
|
|
5
|
+
errorText?: string;
|
|
6
|
+
maxLength?: any;
|
|
7
|
+
type?: string;
|
|
8
|
+
label: string;
|
|
9
|
+
style?: any;
|
|
10
|
+
value?: any;
|
|
11
|
+
inputStyle?: any;
|
|
12
|
+
className?: string;
|
|
13
|
+
startLabel?: React.ReactNode | any;
|
|
14
|
+
endLabel?: React.ReactNode | any;
|
|
15
|
+
isRequired?: boolean;
|
|
16
|
+
inline?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface TextAreaProps extends React.HTMLAttributes<HTMLTextAreaElement> {
|
|
19
|
+
isErrored: boolean;
|
|
20
|
+
showCount?: boolean;
|
|
21
|
+
maxLength?: any;
|
|
22
|
+
errorText?: string;
|
|
23
|
+
style?: any;
|
|
24
|
+
value?: any;
|
|
25
|
+
inputStyle?: any;
|
|
26
|
+
className?: string;
|
|
27
|
+
label: string;
|
|
28
|
+
startLabel?: React.ReactNode | any;
|
|
29
|
+
startAdornment?: React.ReactNode | any;
|
|
30
|
+
endLabel?: React.ReactNode | any;
|
|
31
|
+
endAdornment?: React.ReactNode | any;
|
|
32
|
+
isRequired?: boolean;
|
|
33
|
+
inline?: boolean;
|
|
34
|
+
}
|
|
35
|
+
declare const Input: React.ComponentType<Partial<{
|
|
36
|
+
isRequired: boolean;
|
|
37
|
+
showCount: boolean;
|
|
38
|
+
isErrored: boolean;
|
|
39
|
+
inline: boolean;
|
|
40
|
+
spellCheck: boolean;
|
|
41
|
+
autoFocus: boolean;
|
|
42
|
+
}> & Pick<InputProps & React.RefAttributes<HTMLInputElement>, "onSubmit" | "ref" | "label" | "slot" | "style" | "title" | "value" | "maxLength" | "errorText" | "inputStyle" | "className" | "startLabel" | "endLabel" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "type">>;
|
|
43
|
+
declare const TextArea: React.ComponentType<Partial<{
|
|
44
|
+
isRequired: boolean;
|
|
45
|
+
showCount: boolean;
|
|
46
|
+
isErrored: boolean;
|
|
47
|
+
inline: boolean;
|
|
48
|
+
spellCheck: boolean;
|
|
49
|
+
autoFocus: boolean;
|
|
50
|
+
}> & Pick<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>, "onSubmit" | "ref" | "label" | "slot" | "style" | "title" | "value" | "maxLength" | "errorText" | "inputStyle" | "className" | "startLabel" | "startAdornment" | "endLabel" | "endAdornment" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key">>;
|
|
51
|
+
export { Input, TextArea };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './survey';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface SurveyProps {
|
|
3
|
+
survey: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
onSubmit: (data: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const Survey: ({ survey, onSubmit }: SurveyProps) => JSX.Element | null;
|
|
11
|
+
export { Survey };
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./declarations/lib/types/index";
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var freemiumSurveyComponents = require('freemium-survey-components');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
|
+
|
|
12
|
+
function _extends() {
|
|
13
|
+
_extends = Object.assign || function (target) {
|
|
14
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
+
var source = arguments[i];
|
|
16
|
+
|
|
17
|
+
for (var key in source) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
19
|
+
target[key] = source[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return _extends.apply(this, arguments);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
31
|
+
if (source == null) return {};
|
|
32
|
+
var target = {};
|
|
33
|
+
var sourceKeys = Object.keys(source);
|
|
34
|
+
var key, i;
|
|
35
|
+
|
|
36
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
37
|
+
key = sourceKeys[i];
|
|
38
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
39
|
+
target[key] = source[key];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var withDefaults = function withDefaults(component, defaultProps) {
|
|
46
|
+
component.defaultProps = defaultProps;
|
|
47
|
+
return component;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var _excluded = ["inputStyle", "style", "className", "showCount", "isErrored", "startLabel", "isRequired", "errorText", "endLabel", "maxLength"],
|
|
51
|
+
_excluded2 = ["inputStyle", "style", "className", "showCount", "maxLength", "isErrored", "startLabel", "isRequired"];
|
|
52
|
+
|
|
53
|
+
var defaultProps$2 = {
|
|
54
|
+
isRequired: false,
|
|
55
|
+
showCount: false,
|
|
56
|
+
isErrored: false,
|
|
57
|
+
inline: false,
|
|
58
|
+
spellCheck: false,
|
|
59
|
+
autoFocus: false
|
|
60
|
+
};
|
|
61
|
+
var InputComponent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
62
|
+
var inputStyle = props.inputStyle,
|
|
63
|
+
style = props.style,
|
|
64
|
+
className = props.className,
|
|
65
|
+
showCount = props.showCount,
|
|
66
|
+
isErrored = props.isErrored,
|
|
67
|
+
startLabel = props.startLabel,
|
|
68
|
+
isRequired = props.isRequired,
|
|
69
|
+
errorText = props.errorText,
|
|
70
|
+
endLabel = props.endLabel,
|
|
71
|
+
maxLength = props.maxLength,
|
|
72
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
73
|
+
|
|
74
|
+
console.log(props.value);
|
|
75
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
76
|
+
className: "input-container",
|
|
77
|
+
style: style
|
|
78
|
+
}, props.label && /*#__PURE__*/React__default["default"].createElement("label", {
|
|
79
|
+
className: "input-label " + (isRequired ? 'required' : '')
|
|
80
|
+
}, props.label), /*#__PURE__*/React__default["default"].createElement("div", null, startLabel && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
81
|
+
className: "start-label"
|
|
82
|
+
}, startLabel), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
83
|
+
className: "input-basic " + (isErrored ? 'error' : '') + (className || '')
|
|
84
|
+
}, /*#__PURE__*/React__default["default"].createElement("input", _extends({
|
|
85
|
+
type: "text",
|
|
86
|
+
autoComplete: "off"
|
|
87
|
+
}, rest, {
|
|
88
|
+
ref: ref,
|
|
89
|
+
style: inputStyle
|
|
90
|
+
})), showCount && maxLength > 0 && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
91
|
+
className: "end-max-length"
|
|
92
|
+
}, (props.value && props.value.length || 0) + "/" + props.maxLength)), endLabel && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
93
|
+
className: "end-label"
|
|
94
|
+
}, endLabel)), isErrored && errorText && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
95
|
+
className: "input-error"
|
|
96
|
+
}, props.errorText));
|
|
97
|
+
});
|
|
98
|
+
var TextAreaComponent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
99
|
+
var inputStyle = props.inputStyle,
|
|
100
|
+
style = props.style,
|
|
101
|
+
className = props.className,
|
|
102
|
+
showCount = props.showCount,
|
|
103
|
+
maxLength = props.maxLength,
|
|
104
|
+
isErrored = props.isErrored,
|
|
105
|
+
startLabel = props.startLabel,
|
|
106
|
+
isRequired = props.isRequired,
|
|
107
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
108
|
+
|
|
109
|
+
console.log(props.value);
|
|
110
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
111
|
+
className: "textarea-container",
|
|
112
|
+
style: style
|
|
113
|
+
}, props.label && /*#__PURE__*/React__default["default"].createElement("label", {
|
|
114
|
+
className: "input-label " + (isRequired ? 'required' : '')
|
|
115
|
+
}, props.label), startLabel && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
116
|
+
className: "start-label"
|
|
117
|
+
}, startLabel), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
118
|
+
className: "input-basic " + (isErrored ? 'error' : '') + " " + (className || '')
|
|
119
|
+
}, /*#__PURE__*/React__default["default"].createElement("textarea", _extends({
|
|
120
|
+
autoComplete: "off"
|
|
121
|
+
}, rest, {
|
|
122
|
+
ref: ref,
|
|
123
|
+
style: inputStyle
|
|
124
|
+
})), showCount && maxLength && maxLength > 0 && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
125
|
+
className: "end-max-length"
|
|
126
|
+
}, (props.value && props.value.length || 0) + "/" + props.maxLength)), props.endLabel && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
127
|
+
className: "end-label"
|
|
128
|
+
}, props.endLabel)), props.isErrored && props.errorText && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
129
|
+
className: "input-error"
|
|
130
|
+
}, props.errorText));
|
|
131
|
+
});
|
|
132
|
+
withDefaults(InputComponent, defaultProps$2);
|
|
133
|
+
withDefaults(TextAreaComponent, defaultProps$2);
|
|
134
|
+
|
|
135
|
+
var defaultProps$1 = {
|
|
136
|
+
checked: false
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
var TickIcon = function TickIcon() {
|
|
140
|
+
return /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
141
|
+
id: "tick",
|
|
142
|
+
className: "tick-icon",
|
|
143
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
144
|
+
"aria-labelledby": "title",
|
|
145
|
+
viewBox: "0 0 10 10"
|
|
146
|
+
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
147
|
+
d: "M3 5.87c-.18666814.00267463-.36667109-.06932655-.5-.2L.21 3.41c-.1786328-.17863279-.24839684-.43899577-.1830127-.6830127.06538414-.24401694.25598306-.43461586.5-.5C.77100423 2.16160316 1.0313672 2.23136721 1.21 2.41L3 4.18 6.8.33c.27679776-.27455556.72320224-.27455556 1 0 .13696438.13025306.21450026.31098915.21450026.5S7.93696438 1.19974694 7.8 1.33L3.45 5.67c-.12082534.11896945-.28072735.19003701-.45.2Z",
|
|
148
|
+
fill: "#fff",
|
|
149
|
+
fillRule: "evenodd"
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
var CheckboxComponent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
154
|
+
return /*#__PURE__*/React__default["default"].createElement("label", {
|
|
155
|
+
className: "checkbox-label " + (props.disabled && 'disabled')
|
|
156
|
+
}, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
157
|
+
ref: ref,
|
|
158
|
+
id: props.id,
|
|
159
|
+
type: "checkbox",
|
|
160
|
+
name: props.name,
|
|
161
|
+
readOnly: props.readOnly,
|
|
162
|
+
disabled: props.disabled,
|
|
163
|
+
"aria-disabled": props.disabled,
|
|
164
|
+
value: props.value,
|
|
165
|
+
checked: props.checked,
|
|
166
|
+
autoFocus: props.autoFocus,
|
|
167
|
+
onChange: props.readOnly ? function () {
|
|
168
|
+
return undefined;
|
|
169
|
+
} : function (e) {
|
|
170
|
+
return props.onChange(e, e.target.checked);
|
|
171
|
+
}
|
|
172
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
173
|
+
className: "checkbox"
|
|
174
|
+
}, props.checked && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
175
|
+
className: "icon-container"
|
|
176
|
+
}, /*#__PURE__*/React__default["default"].createElement(TickIcon, null), ' ')), /*#__PURE__*/React__default["default"].createElement("div", null, props.children));
|
|
177
|
+
});
|
|
178
|
+
withDefaults(CheckboxComponent, defaultProps$1);
|
|
179
|
+
|
|
180
|
+
var defaultProps = {
|
|
181
|
+
checked: false,
|
|
182
|
+
autoFocus: false
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
var RadioComponent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
186
|
+
return /*#__PURE__*/React__default["default"].createElement("label", {
|
|
187
|
+
className: "radio-label"
|
|
188
|
+
}, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
189
|
+
ref: ref,
|
|
190
|
+
type: "radio",
|
|
191
|
+
name: props.name,
|
|
192
|
+
value: props.value,
|
|
193
|
+
checked: props.checked,
|
|
194
|
+
onChange: props.onChange,
|
|
195
|
+
autoFocus: props.autoFocus
|
|
196
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
197
|
+
className: "radio"
|
|
198
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", null, props.children));
|
|
199
|
+
});
|
|
200
|
+
withDefaults(RadioComponent, defaultProps);
|
|
201
|
+
|
|
202
|
+
var AUTO_COMMIT_FIELD_TYPES = ['RANGE', 'NPS', 'RADIO'];
|
|
203
|
+
|
|
204
|
+
var SurveyEndCard = function SurveyEndCard() {
|
|
205
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
206
|
+
className: "question-container",
|
|
207
|
+
style: {
|
|
208
|
+
gap: '16px'
|
|
209
|
+
}
|
|
210
|
+
}, /*#__PURE__*/React__default["default"].createElement("h4", null, "Thank you for taking our survey!."), /*#__PURE__*/React__default["default"].createElement("p", null, " Your response is very important to us."));
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
var Survey = function Survey(_ref) {
|
|
214
|
+
var survey = _ref.survey;
|
|
215
|
+
_ref.onSubmit;
|
|
216
|
+
var blocks = survey.meta.blocks,
|
|
217
|
+
questions = survey.question_details.questions;
|
|
218
|
+
|
|
219
|
+
var _useState = React.useState({}),
|
|
220
|
+
formValues = _useState[0];
|
|
221
|
+
_useState[1];
|
|
222
|
+
|
|
223
|
+
var _useState2 = React.useState(false),
|
|
224
|
+
isSurveyCompleted = _useState2[0],
|
|
225
|
+
setIsSurveyCompleted = _useState2[1];
|
|
226
|
+
|
|
227
|
+
var _useState3 = React.useState([]),
|
|
228
|
+
blocksWithQns = _useState3[0],
|
|
229
|
+
setBlocksWithQns = _useState3[1];
|
|
230
|
+
|
|
231
|
+
var currentBlock = React.useRef(null);
|
|
232
|
+
var currentQuestion = React.useRef(null);
|
|
233
|
+
var blockElementRef = React.useRef(null); // to focus on the newly added block
|
|
234
|
+
|
|
235
|
+
var currentBlockIndex = React.useRef(0); // to keep track of the index of the dirty block
|
|
236
|
+
|
|
237
|
+
var isValuesCommitted = React.useRef(false); // in case of non-auto commit fields, to check if the user commits the values or just modifying it
|
|
238
|
+
|
|
239
|
+
var tempBlocksWithQns = React.useRef([]);
|
|
240
|
+
React.useEffect(function () {
|
|
241
|
+
if (!blocks) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (!currentBlock.current && blocks.length > 0) {
|
|
246
|
+
handleBlockProgression(blocks[0]);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
}, [blocks]);
|
|
250
|
+
React.useEffect(function () {
|
|
251
|
+
var _blockElementRef$curr;
|
|
252
|
+
|
|
253
|
+
(_blockElementRef$curr = blockElementRef.current) == null ? void 0 : _blockElementRef$curr.scrollIntoView({
|
|
254
|
+
block: 'center',
|
|
255
|
+
behavior: 'smooth'
|
|
256
|
+
});
|
|
257
|
+
tempBlocksWithQns.current = blocksWithQns;
|
|
258
|
+
}, [blocksWithQns]);
|
|
259
|
+
React.useEffect(function () {
|
|
260
|
+
//if not the initial render
|
|
261
|
+
if (Object.keys(formValues).length > 0) {
|
|
262
|
+
// move to next block if current qn is a auto commit qn
|
|
263
|
+
// if current qn is committed
|
|
264
|
+
// and if the qn is not the final qn since for the final qn, submit should end the survey
|
|
265
|
+
if (currentQuestion.current && (AUTO_COMMIT_FIELD_TYPES.includes(currentQuestion.current.type_info.question_type) || isValuesCommitted.current) && !isCurrentBlockFinal()) {
|
|
266
|
+
moveToNextBlock();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}, [formValues]);
|
|
270
|
+
|
|
271
|
+
var isCurrentBlockFinal = function isCurrentBlockFinal() {
|
|
272
|
+
return currentBlockIndex.current === blocks.length - 1 || currentBlock.current.branchOption === 'end';
|
|
273
|
+
}; //if the already filled block is modified flash the state associated with all the blocks below the block being edited
|
|
274
|
+
|
|
275
|
+
var handleBlockProgression = function handleBlockProgression(block) {
|
|
276
|
+
var question = {};
|
|
277
|
+
|
|
278
|
+
if (block.is_based_on_score) {
|
|
279
|
+
var _questions$0$type_inf;
|
|
280
|
+
|
|
281
|
+
var possibleNextQuestions = (_questions$0$type_inf = questions[0].type_info.choices[formValues == null ? void 0 : formValues[questions[0].name]]) == null ? void 0 : _questions$0$type_inf.dependent_question_names;
|
|
282
|
+
var nextQuestionName = block.question_names.find(function (eachQuestion) {
|
|
283
|
+
return possibleNextQuestions == null ? void 0 : possibleNextQuestions.includes(eachQuestion);
|
|
284
|
+
});
|
|
285
|
+
question = questions.find(function (eachQuestion) {
|
|
286
|
+
return eachQuestion.name === nextQuestionName;
|
|
287
|
+
});
|
|
288
|
+
} else {
|
|
289
|
+
question = questions.find(function (eachQuestion) {
|
|
290
|
+
return eachQuestion.name === block.question_names[0];
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
currentBlock.current = block;
|
|
295
|
+
currentQuestion.current = question;
|
|
296
|
+
var isPresent = tempBlocksWithQns.current.find(function (eachBlock) {
|
|
297
|
+
return eachBlock.question.name === question.name;
|
|
298
|
+
});
|
|
299
|
+
if (!isPresent) setBlocksWithQns([].concat(tempBlocksWithQns.current, [_extends({}, block, {
|
|
300
|
+
question: question
|
|
301
|
+
})]));
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
var moveToNextBlock = function moveToNextBlock() {
|
|
305
|
+
if (isCurrentBlockFinal()) {
|
|
306
|
+
setIsSurveyCompleted(true);
|
|
307
|
+
} else {
|
|
308
|
+
if (currentBlock.current.nextBlock) {
|
|
309
|
+
currentBlockIndex.current = blocks.findIndex(function (block) {
|
|
310
|
+
return block.name === currentBlock.current.nextBlock;
|
|
311
|
+
});
|
|
312
|
+
} else {
|
|
313
|
+
currentBlockIndex.current += 1;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
handleBlockProgression(blocks[currentBlockIndex.current]);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
if (!currentBlock.current || !currentQuestion.current) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (isSurveyCompleted) {
|
|
325
|
+
return /*#__PURE__*/React__default["default"].createElement(SurveyEndCard, null);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return /*#__PURE__*/React__default["default"].createElement(freemiumSurveyComponents.Survey, {
|
|
329
|
+
survey: survey,
|
|
330
|
+
onSubmit: function onSubmit(data) {
|
|
331
|
+
return console.log(data);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
exports.Survey = Survey;
|