@coorpacademy/components 10.5.5 → 10.5.7-alpha.12
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/es/atom/range/handle.css +18 -2
- package/es/atom/range/handle.js +7 -3
- package/es/atom/range/handle.js.map +1 -1
- package/es/atom/range/style.css +2 -2
- package/es/atom/select/index.js +38 -20
- package/es/atom/select/index.js.map +1 -1
- package/es/atom/select/style.css +129 -40
- package/es/atom/select/test/fixtures/player.js +11 -0
- package/es/atom/select/test/fixtures/player.js.map +1 -0
- package/es/atom/select/test/fixtures.js +2 -0
- package/es/atom/select/test/fixtures.js.map +1 -1
- package/es/atom/select/test/select.js +49 -0
- package/es/atom/select/test/select.js.map +1 -0
- package/es/molecule/course-section/index.js +5 -3
- package/es/molecule/course-section/index.js.map +1 -1
- package/es/molecule/course-section/style.css +2 -1
- package/es/molecule/course-section/test/fixtures/chapter.js +2 -1
- package/es/molecule/course-section/test/fixtures/chapter.js.map +1 -1
- package/es/molecule/course-section/test/fixtures/course.js +2 -1
- package/es/molecule/course-section/test/fixtures/course.js.map +1 -1
- package/es/molecule/course-sections/index.js +40 -0
- package/es/molecule/course-sections/index.js.map +1 -0
- package/es/molecule/course-sections/style.css +3 -0
- package/es/molecule/course-sections/test/fixtures/default.js +149 -0
- package/es/molecule/course-sections/test/fixtures/default.js.map +1 -0
- package/es/molecule/course-sections/test/fixtures/loading.js +9 -0
- package/es/molecule/course-sections/test/fixtures/loading.js.map +1 -0
- package/es/molecule/course-sections/test/fixtures.js +15 -0
- package/es/molecule/course-sections/test/fixtures.js.map +1 -0
- package/es/molecule/draggable/index.js +1 -1
- package/es/molecule/draggable/index.js.map +1 -1
- package/es/molecule/draggable/style.css +1 -5
- package/es/molecule/draggable-list/index.js +6 -4
- package/es/molecule/draggable-list/index.js.map +1 -1
- package/es/molecule/draggable-list/test/fixtures/course-sections.js +20 -0
- package/es/molecule/draggable-list/test/fixtures/course-sections.js.map +1 -0
- package/es/molecule/draggable-list/test/fixtures.js +2 -0
- package/es/molecule/draggable-list/test/fixtures.js.map +1 -1
- package/es/molecule/draggable-list/test/on-drop.js +13 -13
- package/es/molecule/draggable-list/test/on-drop.js.map +1 -1
- package/es/molecule/questions/drop-down/index.js +1 -6
- package/es/molecule/questions/drop-down/index.js.map +1 -1
- package/es/molecule/questions/free-text/index.js +35 -15
- package/es/molecule/questions/free-text/index.js.map +1 -1
- package/es/molecule/questions/free-text/style.css +39 -15
- package/es/molecule/questions/free-text/test/fixtures/default.js +1 -1
- package/es/molecule/questions/free-text/test/fixtures/default.js.map +1 -1
- package/es/molecule/questions/free-text/test/fixtures/with-value-on-change.js +9 -0
- package/es/molecule/questions/free-text/test/fixtures/with-value-on-change.js.map +1 -0
- package/es/molecule/questions/free-text/test/fixtures/{with-default-value.js → with-value.js} +2 -2
- package/es/molecule/questions/free-text/test/fixtures/with-value.js.map +1 -0
- package/es/molecule/questions/free-text/test/fixtures.js +4 -2
- package/es/molecule/questions/free-text/test/fixtures.js.map +1 -1
- package/es/molecule/questions/free-text/test/free-text.js +106 -0
- package/es/molecule/questions/free-text/test/free-text.js.map +1 -0
- package/es/molecule/questions/qcm/index.js +37 -25
- package/es/molecule/questions/qcm/index.js.map +1 -1
- package/es/molecule/questions/qcm/style.css +48 -14
- package/es/molecule/questions/qcm/test/fixtures/default.js +8 -0
- package/es/molecule/questions/qcm/test/fixtures/default.js.map +1 -1
- package/es/molecule/questions/qcm/test/qcm.js +103 -0
- package/es/molecule/questions/qcm/test/qcm.js.map +1 -0
- package/es/molecule/questions/qcm-graphic/index.js +35 -17
- package/es/molecule/questions/qcm-graphic/index.js.map +1 -1
- package/es/molecule/questions/qcm-graphic/style.css +64 -13
- package/es/molecule/questions/qcm-graphic/test/qcm-graphic.js +65 -0
- package/es/molecule/questions/qcm-graphic/test/qcm-graphic.js.map +1 -0
- package/es/molecule/questions/question-range/style.css +9 -8
- package/es/molecule/questions/template/index.js +13 -10
- package/es/molecule/questions/template/index.js.map +1 -1
- package/es/molecule/setup-section/style.css +1 -0
- package/es/molecule/wizard-summary/test/fixtures/organize-courses.js +106 -0
- package/es/molecule/wizard-summary/test/fixtures/organize-courses.js.map +1 -0
- package/es/molecule/wizard-summary/test/fixtures.js +2 -0
- package/es/molecule/wizard-summary/test/fixtures.js.map +1 -1
- package/es/organism/wizard-contents/index.js +6 -0
- package/es/organism/wizard-contents/index.js.map +1 -1
- package/es/organism/wizard-contents/test/fixtures/playlist-organize-courses.js +45 -0
- package/es/organism/wizard-contents/test/fixtures/playlist-organize-courses.js.map +1 -0
- package/es/organism/wizard-contents/test/fixtures.js +2 -0
- package/es/organism/wizard-contents/test/fixtures.js.map +1 -1
- package/es/template/back-office/brand-update/test/fixtures/wizard-organize-courses-playlist.js +22 -0
- package/es/template/back-office/brand-update/test/fixtures/wizard-organize-courses-playlist.js.map +1 -0
- package/es/template/back-office/brand-update/test/fixtures.js +2 -0
- package/es/template/back-office/brand-update/test/fixtures.js.map +1 -1
- package/es/util/get-shadow-box-color-from-primary.js +4 -0
- package/es/util/get-shadow-box-color-from-primary.js.map +1 -0
- package/es/util/test/get-shadow-box-color-from-primary.js +33 -0
- package/es/util/test/get-shadow-box-color-from-primary.js.map +1 -0
- package/es/variables/colors.css +3 -0
- package/lib/atom/range/handle.css +18 -2
- package/lib/atom/range/handle.js +8 -3
- package/lib/atom/range/handle.js.map +1 -1
- package/lib/atom/range/style.css +2 -2
- package/lib/atom/select/index.js +40 -17
- package/lib/atom/select/index.js.map +1 -1
- package/lib/atom/select/style.css +129 -40
- package/lib/atom/select/test/fixtures/player.js +21 -0
- package/lib/atom/select/test/fixtures/player.js.map +1 -0
- package/lib/atom/select/test/fixtures.js +3 -0
- package/lib/atom/select/test/fixtures.js.map +1 -1
- package/lib/atom/select/test/select.js +62 -0
- package/lib/atom/select/test/select.js.map +1 -0
- package/lib/molecule/course-section/index.js +5 -3
- package/lib/molecule/course-section/index.js.map +1 -1
- package/lib/molecule/course-section/style.css +2 -1
- package/lib/molecule/course-section/test/fixtures/chapter.js +2 -1
- package/lib/molecule/course-section/test/fixtures/chapter.js.map +1 -1
- package/lib/molecule/course-section/test/fixtures/course.js +2 -1
- package/lib/molecule/course-section/test/fixtures/course.js.map +1 -1
- package/lib/molecule/course-sections/index.js +54 -0
- package/lib/molecule/course-sections/index.js.map +1 -0
- package/lib/molecule/course-sections/style.css +3 -0
- package/lib/molecule/course-sections/test/fixtures/default.js +154 -0
- package/lib/molecule/course-sections/test/fixtures/default.js.map +1 -0
- package/lib/molecule/course-sections/test/fixtures/loading.js +14 -0
- package/lib/molecule/course-sections/test/fixtures/loading.js.map +1 -0
- package/lib/molecule/course-sections/test/fixtures.js +25 -0
- package/lib/molecule/course-sections/test/fixtures.js.map +1 -0
- package/lib/molecule/draggable/index.js +1 -1
- package/lib/molecule/draggable/index.js.map +1 -1
- package/lib/molecule/draggable/style.css +1 -5
- package/lib/molecule/draggable-list/index.js +7 -4
- package/lib/molecule/draggable-list/index.js.map +1 -1
- package/lib/molecule/draggable-list/test/fixtures/course-sections.js +29 -0
- package/lib/molecule/draggable-list/test/fixtures/course-sections.js.map +1 -0
- package/lib/molecule/draggable-list/test/fixtures.js +3 -0
- package/lib/molecule/draggable-list/test/fixtures.js.map +1 -1
- package/lib/molecule/draggable-list/test/on-drop.js +13 -13
- package/lib/molecule/draggable-list/test/on-drop.js.map +1 -1
- package/lib/molecule/questions/drop-down/index.js +1 -5
- package/lib/molecule/questions/drop-down/index.js.map +1 -1
- package/lib/molecule/questions/free-text/index.js +32 -14
- package/lib/molecule/questions/free-text/index.js.map +1 -1
- package/lib/molecule/questions/free-text/style.css +39 -15
- package/lib/molecule/questions/free-text/test/fixtures/default.js +1 -1
- package/lib/molecule/questions/free-text/test/fixtures/default.js.map +1 -1
- package/lib/molecule/questions/free-text/test/fixtures/with-value-on-change.js +14 -0
- package/lib/molecule/questions/free-text/test/fixtures/with-value-on-change.js.map +1 -0
- package/lib/molecule/questions/free-text/test/fixtures/{with-default-value.js → with-value.js} +2 -2
- package/lib/molecule/questions/free-text/test/fixtures/with-value.js.map +1 -0
- package/lib/molecule/questions/free-text/test/fixtures.js +5 -2
- package/lib/molecule/questions/free-text/test/fixtures.js.map +1 -1
- package/lib/molecule/questions/free-text/test/free-text.js +119 -0
- package/lib/molecule/questions/free-text/test/free-text.js.map +1 -0
- package/lib/molecule/questions/qcm/index.js +44 -23
- package/lib/molecule/questions/qcm/index.js.map +1 -1
- package/lib/molecule/questions/qcm/style.css +48 -14
- package/lib/molecule/questions/qcm/test/fixtures/default.js +8 -0
- package/lib/molecule/questions/qcm/test/fixtures/default.js.map +1 -1
- package/lib/molecule/questions/qcm/test/qcm.js +115 -0
- package/lib/molecule/questions/qcm/test/qcm.js.map +1 -0
- package/lib/molecule/questions/qcm-graphic/index.js +33 -15
- package/lib/molecule/questions/qcm-graphic/index.js.map +1 -1
- package/lib/molecule/questions/qcm-graphic/style.css +64 -13
- package/lib/molecule/questions/qcm-graphic/test/qcm-graphic.js +76 -0
- package/lib/molecule/questions/qcm-graphic/test/qcm-graphic.js.map +1 -0
- package/lib/molecule/questions/question-range/style.css +9 -8
- package/lib/molecule/questions/template/index.js +13 -10
- package/lib/molecule/questions/template/index.js.map +1 -1
- package/lib/molecule/setup-section/style.css +1 -0
- package/lib/molecule/wizard-summary/test/fixtures/organize-courses.js +111 -0
- package/lib/molecule/wizard-summary/test/fixtures/organize-courses.js.map +1 -0
- package/lib/molecule/wizard-summary/test/fixtures.js +3 -0
- package/lib/molecule/wizard-summary/test/fixtures.js.map +1 -1
- package/lib/organism/wizard-contents/index.js +7 -0
- package/lib/organism/wizard-contents/index.js.map +1 -1
- package/lib/organism/wizard-contents/test/fixtures/playlist-organize-courses.js +54 -0
- package/lib/organism/wizard-contents/test/fixtures/playlist-organize-courses.js.map +1 -0
- package/lib/organism/wizard-contents/test/fixtures.js +3 -0
- package/lib/organism/wizard-contents/test/fixtures.js.map +1 -1
- package/lib/template/back-office/brand-update/test/fixtures/wizard-organize-courses-playlist.js +32 -0
- package/lib/template/back-office/brand-update/test/fixtures/wizard-organize-courses-playlist.js.map +1 -0
- package/lib/template/back-office/brand-update/test/fixtures.js +3 -0
- package/lib/template/back-office/brand-update/test/fixtures.js.map +1 -1
- package/lib/util/get-shadow-box-color-from-primary.js +12 -0
- package/lib/util/get-shadow-box-color-from-primary.js.map +1 -0
- package/lib/util/test/get-shadow-box-color-from-primary.js +40 -0
- package/lib/util/test/get-shadow-box-color-from-primary.js.map +1 -0
- package/lib/variables/colors.css +3 -0
- package/package.json +2 -2
- package/es/molecule/questions/free-text/test/fixtures/with-default-value.js.map +0 -1
- package/es/molecule/search/test/fixtures.js +0 -15
- package/es/molecule/search/test/fixtures.js.map +0 -1
- package/lib/molecule/questions/free-text/test/fixtures/with-default-value.js.map +0 -1
- package/lib/molecule/search/test/fixtures.js +0 -25
- package/lib/molecule/search/test/fixtures.js.map +0 -1
|
@@ -2,6 +2,7 @@ import test from 'ava';
|
|
|
2
2
|
import forEach from 'lodash/forEach';
|
|
3
3
|
import renderComponentMacro from '../../../test/helpers/render-component';
|
|
4
4
|
import MoleculeDraggableList from '..';
|
|
5
|
+
import fixtureCourseSections from './fixtures/course-sections';
|
|
5
6
|
import fixtureDashboardSections from './fixtures/dashboard-sections';
|
|
6
7
|
test('Molecule › MoleculeDraggableList > should have valid propTypes', t => {
|
|
7
8
|
t.pass();
|
|
@@ -9,5 +10,6 @@ test('Molecule › MoleculeDraggableList > should have valid propTypes', t => {
|
|
|
9
10
|
t.not(value, undefined, `PropType for "Molecule.MoleculeDraggableList.propTypes.${key}" may not be undefined. Did you mistype the propTypes definition?`);
|
|
10
11
|
});
|
|
11
12
|
});
|
|
13
|
+
test('Molecule › MoleculeDraggableList › CourseSections › should be rendered', renderComponentMacro, MoleculeDraggableList, fixtureCourseSections);
|
|
12
14
|
test('Molecule › MoleculeDraggableList › DashboardSections › should be rendered', renderComponentMacro, MoleculeDraggableList, fixtureDashboardSections);
|
|
13
15
|
//# sourceMappingURL=fixtures.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/draggable-list/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","MoleculeDraggableList","fixtureDashboardSections","t","pass","propTypes","value","key","not","undefined"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,KAAjB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,oBAAP,MAAiC,wCAAjC;AACA,OAAOC,qBAAP,MAAkC,IAAlC;AACA,OAAOC,wBAAP,MAAqC,+BAArC;
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/draggable-list/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","MoleculeDraggableList","fixtureCourseSections","fixtureDashboardSections","t","pass","propTypes","value","key","not","undefined"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,KAAjB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,oBAAP,MAAiC,wCAAjC;AACA,OAAOC,qBAAP,MAAkC,IAAlC;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,wBAAP,MAAqC,+BAArC;AAEAL,IAAI,CAAC,gEAAD,EAAmEM,CAAC,IAAI;AAC1EA,EAAAA,CAAC,CAACC,IAAF;AACAN,EAAAA,OAAO,CAACE,qBAAqB,CAACK,SAAvB,EAAkC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACvDJ,IAAAA,CAAC,CAACK,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,0DAAyDF,GAAI,mEAAtF;AACD,GAFM,CAAP;AAGD,CALG,CAAJ;AAOAV,IAAI,CAAC,wEAAD,EAA2EE,oBAA3E,EAAiGC,qBAAjG,EAAwHC,qBAAxH,CAAJ;AACAJ,IAAI,CAAC,2EAAD,EAA8EE,oBAA9E,EAAoGC,qBAApG,EAA2HE,wBAA3H,CAAJ","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../test/helpers/render-component';\nimport MoleculeDraggableList from '..';\nimport fixtureCourseSections from './fixtures/course-sections';\nimport fixtureDashboardSections from './fixtures/dashboard-sections';\n\ntest('Molecule › MoleculeDraggableList > should have valid propTypes', t => {\n t.pass();\n forEach(MoleculeDraggableList.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"Molecule.MoleculeDraggableList.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('Molecule › MoleculeDraggableList › CourseSections › should be rendered', renderComponentMacro, MoleculeDraggableList, fixtureCourseSections);\ntest('Molecule › MoleculeDraggableList › DashboardSections › should be rendered', renderComponentMacro, MoleculeDraggableList, fixtureDashboardSections);\n"],"file":"fixtures.js"}
|
|
@@ -43,12 +43,12 @@ test('should trigger onDrop handler', t => {
|
|
|
43
43
|
const dropEvent = {
|
|
44
44
|
preventDefault: () => t.pass()
|
|
45
45
|
};
|
|
46
|
-
wrapper.find(`.${style.
|
|
47
|
-
wrapper.find(`.${style.
|
|
48
|
-
wrapper.find(`.${style.
|
|
49
|
-
wrapper.find(`.${style.
|
|
50
|
-
wrapper.find(`.${style.
|
|
51
|
-
wrapper.find(`.${style.
|
|
46
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragStart', dragStartEvent);
|
|
47
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);
|
|
48
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);
|
|
49
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragLeave', dragLeaveEvent);
|
|
50
|
+
wrapper.find(`.${style.draggable}`).at(2).simulate('dragOver', dragOverEvent);
|
|
51
|
+
wrapper.find(`.${style.draggable}`).at(2).simulate('drop', dropEvent);
|
|
52
52
|
});
|
|
53
53
|
test('should skip drop event if dragStart is not called', t => {
|
|
54
54
|
t.plan(1);
|
|
@@ -65,7 +65,7 @@ test('should skip drop event if dragStart is not called', t => {
|
|
|
65
65
|
const dropEvent = {
|
|
66
66
|
preventDefault: () => t.pass()
|
|
67
67
|
};
|
|
68
|
-
wrapper.find(`.${style.
|
|
68
|
+
wrapper.find(`.${style.draggable}`).at(2).simulate('drop', dropEvent);
|
|
69
69
|
});
|
|
70
70
|
test('should skip dragStart event if section id is not defined', t => {
|
|
71
71
|
t.plan(0);
|
|
@@ -91,11 +91,11 @@ test('should skip dragStart event if section id is not defined', t => {
|
|
|
91
91
|
const dropEvent = {
|
|
92
92
|
preventDefault: () => {}
|
|
93
93
|
};
|
|
94
|
-
wrapper.find(`.${style.
|
|
95
|
-
wrapper.find(`.${style.
|
|
96
|
-
wrapper.find(`.${style.
|
|
97
|
-
wrapper.find(`.${style.
|
|
98
|
-
wrapper.find(`.${style.
|
|
99
|
-
wrapper.find(`.${style.
|
|
94
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragStart', dragStartEvent);
|
|
95
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);
|
|
96
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);
|
|
97
|
+
wrapper.find(`.${style.draggable}`).at(0).simulate('dragLeave', dragLeaveEvent);
|
|
98
|
+
wrapper.find(`.${style.draggable}`).at(2).simulate('dragOver', dragOverEvent);
|
|
99
|
+
wrapper.find(`.${style.draggable}`).at(2).simulate('drop', dropEvent);
|
|
100
100
|
});
|
|
101
101
|
//# sourceMappingURL=on-drop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/draggable-list/test/on-drop.js"],"names":["browserEnv","test","React","mount","configure","Adapter","wrappingComponent","SetupSections","style","fixtures","adapter","t","plan","elementToDrag","props","items","id","elementToDrop","dropHandler","dragged","dropped","is","wrapper","dragStartEvent","preventDefault","pass","dragOverEvent","dragLeaveEvent","dropEvent","find","
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/draggable-list/test/on-drop.js"],"names":["browserEnv","test","React","mount","configure","Adapter","wrappingComponent","SetupSections","style","fixtures","adapter","t","plan","elementToDrag","props","items","id","elementToDrop","dropHandler","dragged","dropped","is","wrapper","dragStartEvent","preventDefault","pass","dragOverEvent","dragLeaveEvent","dropEvent","find","draggable","at","simulate","fail"],"mappings":";;;;AAAA,OAAOA,UAAP,MAAuB,aAAvB;AACA,OAAOC,IAAP,MAAiB,KAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAAQC,KAAR,EAAeC,SAAf,QAA+B,QAA/B;AAEA,OAAOC,OAAP,MAAoB,yBAApB;AACA,SAAQC,iBAAR,QAAgC,wCAAhC;AACA,OAAOC,aAAP,MAA0B,IAA1B,C,CACA;;AACA,OAAOC,KAAP,MAAkB,2BAAlB;AACA,OAAOC,QAAP,MAAqB,+BAArB;AAEAT,UAAU;AACVI,SAAS,CAAC;AAACM,EAAAA,OAAO,EAAE,IAAIL,OAAJ;AAAV,CAAD,CAAT;AAEAJ,IAAI,CAAC,+BAAD,EAAkCU,CAAC,IAAI;AACzCA,EAAAA,CAAC,CAACC,IAAF,CAAO,CAAP;AAEA,QAAMC,aAAa,GAAGJ,QAAQ,CAACK,KAAT,CAAeC,KAAf,CAAqB,CAArB,EAAwBC,EAA9C;AACA,QAAMC,aAAa,GAAGR,QAAQ,CAACK,KAAT,CAAeC,KAAf,CAAqB,CAArB,EAAwBC,EAA9C;;AAEA,QAAME,WAAW,GAAG,CAACC,OAAD,EAAUC,OAAV,KAAsB;AACxCT,IAAAA,CAAC,CAACU,EAAF,CAAKD,OAAL,EAAcH,aAAd;AACAN,IAAAA,CAAC,CAACU,EAAF,CAAKF,OAAL,EAAcN,aAAd;AACD,GAHD;;AAKA,QAAMS,OAAO,GAAGnB,KAAK,eAAC,oBAAC,aAAD,eAAmBM,QAAQ,CAACK,KAA5B;AAAmC,IAAA,MAAM,EAAEI;AAA3C,KAAD,EAA6D;AAChFZ,IAAAA;AADgF,GAA7D,CAArB;AAIA,QAAMiB,cAAc,GAAG;AAACC,IAAAA,cAAc,E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vB;AACA,QAAMI,SAAS,GAAG;AAACJ,IAAAA,cAAc,EAAE,MAAM,CAAE;AAAzB,GAAlB;AAEAF,EAAAA,OAAO,CAACO,IAAR,CAAc,IAAGrB,KAAK,CAACsB,SAAU,EAAjC,EAAoCC,EAApC,CAAuC,CAAvC,EAA0CC,QAA1C,CAAmD,WAAnD,EAAgET,cAAhE;AACAD,EAAAA,OAAO,CAACO,IAAR,CAAc,IAAGrB,KAAK,CAACsB,SAAU,EAAjC,EAAoCC,EAApC,CAAuC,CAAvC,EAA0CC,QAA1C,CAAmD,UAAnD,EAA+DN,aAA/D;AACAJ,EAAAA,OAAO,CAACO,IAAR,CAAc,IAAGrB,KAAK,CAACsB,SAAU,EAAjC,EAAoCC,EAApC,CAAuC,CAAvC,EAA0CC,QAA1C,CAAmD,UAAnD,EAA+DN,aAA/D;AACAJ,EAAAA,OAAO,CAACO,IAAR,CAAc,IAAGrB,KAAK,CAACsB,SAAU,EAAjC,EAAoCC,EAApC,CAAuC,CAAvC,EAA0CC,QAA1C,CAAmD,WAAnD,EAAgEL,cAAhE;AACAL,EAAAA,OAAO,CAACO,IAAR,CAAc,IAAGrB,KAAK,CAACsB,SAAU,EAAjC,EAAoCC,EAApC,CAAuC,CAAvC,EAA0CC,QAA1C,CAAmD,UAAnD,EAA+DN,aAA/D;AACAJ,EAAAA,OAAO,CAACO,IAAR,CAAc,IAAGrB,KAAK,CAACsB,SAAU,EAAjC,EAAoCC,EAApC,CAAuC,CAAvC,EAA0CC,QAA1C,CAAmD,MAAnD,EAA2DJ,SAA3D;AACD,CAzBG,CAAJ","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {mount, configure} from 'enzyme';\nimport {set} from 'lodash/fp';\nimport Adapter from 'enzyme-adapter-react-16';\nimport {wrappingComponent} from '../../../test/helpers/render-component';\nimport SetupSections from '..';\n// eslint-disable-next-line css-modules/no-unused-class\nimport style from '../../draggable/style.css';\nimport fixtures from './fixtures/dashboard-sections';\n\nbrowserEnv();\nconfigure({adapter: new Adapter()});\n\ntest('should trigger onDrop handler', t => {\n t.plan(7);\n\n const elementToDrag = fixtures.props.items[0].id;\n const elementToDrop = fixtures.props.items[2].id;\n\n const dropHandler = (dragged, dropped) => {\n t.is(dropped, elementToDrop);\n t.is(dragged, elementToDrag);\n };\n\n const wrapper = mount(<SetupSections {...fixtures.props} onDrop={dropHandler} />, {\n wrappingComponent\n });\n\n const dragStartEvent = {preventDefault: () => t.pass()};\n const dragOverEvent = {preventDefault: () => t.pass()};\n const dragLeaveEvent = {preventDefault: () => t.pass()};\n const dropEvent = {preventDefault: () => t.pass()};\n\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragStart', dragStartEvent);\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragLeave', dragLeaveEvent);\n wrapper.find(`.${style.draggable}`).at(2).simulate('dragOver', dragOverEvent);\n wrapper.find(`.${style.draggable}`).at(2).simulate('drop', dropEvent);\n});\n\ntest('should skip drop event if dragStart is not called', t => {\n t.plan(1);\n\n const dropHandler = (dragged, dropped) => {\n t.fail();\n };\n\n const wrapper = mount(<SetupSections {...fixtures.props} onDrop={dropHandler} />, {\n wrappingComponent\n });\n\n const dropEvent = {preventDefault: () => t.pass()};\n wrapper.find(`.${style.draggable}`).at(2).simulate('drop', dropEvent);\n});\n\ntest('should skip dragStart event if section id is not defined', t => {\n t.plan(0);\n\n const dropHandler = (dragged, dropped) => {\n t.fail();\n };\n\n const wrapper = mount(\n <SetupSections {...set('items.0.id', '', fixtures.props)} onDrop={dropHandler} />,\n {\n wrappingComponent\n }\n );\n\n const dragStartEvent = {preventDefault: () => {}};\n const dragOverEvent = {preventDefault: () => {}};\n const dragLeaveEvent = {preventDefault: () => {}};\n const dropEvent = {preventDefault: () => {}};\n\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragStart', dragStartEvent);\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragOver', dragOverEvent);\n wrapper.find(`.${style.draggable}`).at(0).simulate('dragLeave', dragLeaveEvent);\n wrapper.find(`.${style.draggable}`).at(2).simulate('dragOver', dragOverEvent);\n wrapper.find(`.${style.draggable}`).at(2).simulate('drop', dropEvent);\n});\n"],"file":"on-drop.js"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import _find from "lodash/fp/find";
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
2
|
import React from 'react';
|
|
6
3
|
import PropTypes from 'prop-types';
|
|
7
4
|
import Select, { SelectOptionPropTypes } from '../../../atom/select';
|
|
@@ -29,9 +26,7 @@ const DropDown = props => {
|
|
|
29
26
|
|
|
30
27
|
DropDown.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
31
28
|
onChange: Select.propTypes.onChange,
|
|
32
|
-
options: PropTypes.arrayOf(PropTypes.shape(
|
|
33
|
-
validOption: PropTypes.bool
|
|
34
|
-
}))),
|
|
29
|
+
options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),
|
|
35
30
|
theme: Select.propTypes.theme
|
|
36
31
|
} : {};
|
|
37
32
|
export default DropDown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/questions/drop-down/index.js"],"names":["React","PropTypes","Select","SelectOptionPropTypes","style","DropDown","props","options","onChange","theme","propsTheme","currentSelection","defaultTheme","validOption","wrapper","propTypes","arrayOf","shape"
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/questions/drop-down/index.js"],"names":["React","PropTypes","Select","SelectOptionPropTypes","style","DropDown","props","options","onChange","theme","propsTheme","currentSelection","defaultTheme","validOption","wrapper","propTypes","arrayOf","shape"],"mappings":";AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,MAAP,IAAgBC,qBAAhB,QAA4C,sBAA5C;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,QAAQ,GAAGC,KAAK,IAAI;AACxB,QAAM;AAACC,IAAAA,OAAD;AAAUC,IAAAA,QAAV;AAAoBC,IAAAA,KAAK,EAAEC;AAA3B,MAAyCJ,KAA/C;;AAEA,QAAMK,gBAAgB,GAAG,MAAK,UAAL,EAAiBJ,OAAjB,CAAzB;;AACA,QAAMK,YAAY,GAChB,CAACD,gBAAD,IAAqBA,gBAAgB,CAACE,WAAjB,KAAiC,KAAtD,GAA8D,SAA9D,GAA0E,UAD5E;AAGA,QAAMJ,KAAK,GAAGC,UAAU,IAAIE,YAA5B;AAEA,sBACE;AAAK,IAAA,SAAS,EAAER,KAAK,CAACU;AAAtB,kBACE,oBAAC,MAAD;AAAQ,IAAA,KAAK,EAAEL,KAAf;AAAsB,IAAA,OAAO,EAAEF,OAA/B;AAAwC,IAAA,QAAQ,EAAEC;AAAlD,IADF,CADF;AAKD,CAdD;;AAgBAH,QAAQ,CAACU,SAAT,2CAAqB;AACnBP,EAAAA,QAAQ,EAAEN,MAAM,CAACa,SAAP,CAAiBP,QADR;AAEnBD,EAAAA,OAAO,EAAEN,SAAS,CAACe,OAAV,CAAkBf,SAAS,CAACgB,KAAV,CAAgBd,qBAAhB,CAAlB,CAFU;AAGnBM,EAAAA,KAAK,EAAEP,MAAM,CAACa,SAAP,CAAiBN;AAHL,CAArB;AAMA,eAAeJ,QAAf","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {find} from 'lodash/fp';\nimport Select, {SelectOptionPropTypes} from '../../../atom/select';\nimport style from './style.css';\n\nconst DropDown = props => {\n const {options, onChange, theme: propsTheme} = props;\n\n const currentSelection = find('selected', options);\n const defaultTheme =\n !currentSelection || currentSelection.validOption === false ? 'invalid' : 'question';\n\n const theme = propsTheme || defaultTheme;\n\n return (\n <div className={style.wrapper}>\n <Select theme={theme} options={options} onChange={onChange} />\n </div>\n );\n};\n\nDropDown.propTypes = {\n onChange: Select.propTypes.onChange,\n options: PropTypes.arrayOf(PropTypes.shape(SelectOptionPropTypes)),\n theme: Select.propTypes.theme\n};\n\nexport default DropDown;\n"],"file":"index.js"}
|
|
@@ -1,34 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _getOr from "lodash/fp/getOr";
|
|
2
2
|
import _noop from "lodash/fp/noop";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
+
|
|
6
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import { convert } from 'css-color-function';
|
|
5
9
|
import Provider from '../../../atom/provider';
|
|
6
10
|
import style from './style.css';
|
|
7
11
|
|
|
8
|
-
const FreeText = (props, {
|
|
9
|
-
skin
|
|
10
|
-
}) => {
|
|
12
|
+
const FreeText = (props, context) => {
|
|
11
13
|
const {
|
|
12
14
|
placeholder = '',
|
|
13
15
|
value = '',
|
|
14
|
-
onChange = _noop
|
|
16
|
+
onChange = _noop,
|
|
17
|
+
'aria-label': ariaLabel
|
|
15
18
|
} = props;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
19
|
+
const [hovered, setHovered] = useState(false);
|
|
20
|
+
const handleChange = useCallback(e => onChange(e.target.value), [onChange]);
|
|
21
|
+
|
|
22
|
+
const primarySkinColor = _getOr('#00B0FF', 'skin.common.primary', context);
|
|
23
|
+
|
|
24
|
+
const handleMouseOver = useCallback(() => setHovered(true), [setHovered]);
|
|
25
|
+
const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);
|
|
26
|
+
const shadowBoxPrimaryColor = useMemo(() => convert(`color(${primarySkinColor} a(12%))`), [primarySkinColor]);
|
|
18
27
|
return /*#__PURE__*/React.createElement("div", {
|
|
19
28
|
"data-name": "freeText",
|
|
20
|
-
className: style.wrapper
|
|
29
|
+
className: style.wrapper,
|
|
30
|
+
onMouseOver: handleMouseOver,
|
|
31
|
+
onMouseLeave: handleMouseLeave,
|
|
32
|
+
style: _extends({}, value && {
|
|
33
|
+
boxShadow: hovered ? 'none' : `0 4px 16px ${shadowBoxPrimaryColor}`
|
|
34
|
+
})
|
|
21
35
|
}, /*#__PURE__*/React.createElement("input", {
|
|
36
|
+
"data-name": "free-text-input",
|
|
22
37
|
type: "text",
|
|
23
|
-
|
|
38
|
+
"aria-label": ariaLabel || value || placeholder,
|
|
39
|
+
className: style.freeText,
|
|
24
40
|
placeholder: placeholder,
|
|
25
41
|
value: value,
|
|
26
42
|
onInput: handleChange,
|
|
27
43
|
onChange: _noop,
|
|
28
|
-
style: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
style: _extends(_extends({
|
|
45
|
+
boxShadow: `0 4px 16px ${shadowBoxPrimaryColor}`
|
|
46
|
+
}, value && {
|
|
47
|
+
boxShadow: `0 4px 16px ${hovered ? convert(`color(${primarySkinColor} a(20%))`) : shadowBoxPrimaryColor}`
|
|
48
|
+
}), {}, {
|
|
49
|
+
color: primarySkinColor
|
|
50
|
+
})
|
|
32
51
|
}));
|
|
33
52
|
};
|
|
34
53
|
|
|
@@ -38,7 +57,8 @@ FreeText.contextTypes = {
|
|
|
38
57
|
FreeText.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
39
58
|
placeholder: PropTypes.string,
|
|
40
59
|
value: PropTypes.string,
|
|
41
|
-
onChange: PropTypes.func
|
|
60
|
+
onChange: PropTypes.func,
|
|
61
|
+
'aria-label': PropTypes.string
|
|
42
62
|
} : {};
|
|
43
63
|
export default FreeText;
|
|
44
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/molecule/questions/free-text/index.js"],"names":["React","useMemo","PropTypes","Provider","style","FreeText","props","
|
|
1
|
+
{"version":3,"sources":["../../../../src/molecule/questions/free-text/index.js"],"names":["React","useCallback","useMemo","useState","PropTypes","convert","Provider","style","FreeText","props","context","placeholder","value","onChange","ariaLabel","hovered","setHovered","handleChange","e","target","primarySkinColor","handleMouseOver","handleMouseLeave","shadowBoxPrimaryColor","wrapper","boxShadow","freeText","color","contextTypes","skin","childContextTypes","propTypes","string","func"],"mappings":";;;;;AAAA,OAAOA,KAAP,IAAeC,WAAf,EAA4BC,OAA5B,EAAqCC,QAArC,QAAoD,OAApD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,SAAQC,OAAR,QAAsB,oBAAtB;AACA,OAAOC,QAAP,MAAqB,wBAArB;AACA,OAAOC,KAAP,MAAkB,aAAlB;;AAEA,MAAMC,QAAQ,GAAG,CAACC,KAAD,EAAQC,OAAR,KAAoB;AACnC,QAAM;AAACC,IAAAA,WAAW,GAAG,EAAf;AAAmBC,IAAAA,KAAK,GAAG,EAA3B;AAA+BC,IAAAA,QAAQ,QAAvC;AAAgD,kBAAcC;AAA9D,MAA2EL,KAAjF;AACA,QAAM,CAACM,OAAD,EAAUC,UAAV,IAAwBb,QAAQ,CAAC,KAAD,CAAtC;AAEA,QAAMc,YAAY,GAAGhB,WAAW,CAACiB,CAAC,IAAIL,QAAQ,CAACK,CAAC,CAACC,MAAF,CAASP,KAAV,CAAd,EAAgC,CAACC,QAAD,CAAhC,CAAhC;;AACA,QAAMO,gBAAgB,GAAG,OAAM,SAAN,EAAiB,qBAAjB,EAAwCV,OAAxC,CAAzB;;AAEA,QAAMW,eAAe,GAAGpB,WAAW,CAAC,MAAMe,UAAU,CAAC,IAAD,CAAjB,EAAyB,CAACA,UAAD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AAEnBpB,EAAAA,KAAK,EAAER,SAAS,CAAC4B,MAFE;AAGnBnB,EAAAA,QAAQ,EAAET,SAAS,CAAC6B,IAHD;AAInB,gBAAc7B,SAAS,CAAC4B;AAJL,CAArB;AAOA,eAAexB,QAAf","sourcesContent":["import React, {useCallback, useMemo, useState} from 'react';\nimport PropTypes from 'prop-types';\nimport {noop, getOr} from 'lodash/fp';\nimport {convert} from 'css-color-function';\nimport Provider from '../../../atom/provider';\nimport style from './style.css';\n\nconst FreeText = (props, context) => {\n const {placeholder = '', value = '', onChange = noop, 'aria-label': ariaLabel} = props;\n const [hovered, setHovered] = useState(false);\n\n const handleChange = useCallback(e => onChange(e.target.value), [onChange]);\n const primarySkinColor = getOr('#00B0FF', 'skin.common.primary', context);\n\n const handleMouseOver = useCallback(() => setHovered(true), [setHovered]);\n\n const handleMouseLeave = useCallback(() => setHovered(false), [setHovered]);\n\n const shadowBoxPrimaryColor = useMemo(() => convert(`color(${primarySkinColor} a(12%))`), [\n primarySkinColor\n ]);\n\n return (\n <div\n data-name=\"freeText\"\n className={style.wrapper}\n onMouseOver={handleMouseOver}\n onMouseLeave={handleMouseLeave}\n style={{\n ...(value && {\n boxShadow: hovered ? 'none' : `0 4px 16px ${shadowBoxPrimaryColor}`\n })\n }}\n >\n <input\n data-name=\"free-text-input\"\n type=\"text\"\n aria-label={ariaLabel || value || placeholder}\n className={style.freeText}\n placeholder={placeholder}\n value={value}\n onInput={handleChange}\n onChange={noop}\n style={{\n boxShadow: `0 4px 16px ${shadowBoxPrimaryColor}`,\n ...(value && {\n boxShadow: `0 4px 16px ${\n hovered ? convert(`color(${primarySkinColor} a(20%))`) : shadowBoxPrimaryColor\n }`\n }),\n color: primarySkinColor\n }}\n />\n </div>\n );\n};\n\nFreeText.contextTypes = {\n skin: Provider.childContextTypes.skin\n};\n\nFreeText.propTypes = {\n placeholder: PropTypes.string,\n value: PropTypes.string,\n onChange: PropTypes.func,\n 'aria-label': PropTypes.string\n};\n\nexport default FreeText;\n"],"file":"index.js"}
|
|
@@ -1,41 +1,65 @@
|
|
|
1
1
|
@value breakpoints: "../../../variables/breakpoints.css";
|
|
2
2
|
@value mobile from breakpoints;
|
|
3
3
|
@value colors: "../../../variables/colors.css";
|
|
4
|
-
@value
|
|
5
|
-
@value
|
|
4
|
+
@value box_shadow_light_dark from colors;
|
|
5
|
+
@value cm_blue_900 from colors;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
.freeText {
|
|
9
|
+
border: unset;
|
|
10
|
+
border-width: 0;
|
|
8
11
|
font-family: "Gilroy";
|
|
9
12
|
font-weight: 700;
|
|
10
13
|
text-transform: none;
|
|
11
|
-
padding: 0 15px;
|
|
12
|
-
border: solid 1px;
|
|
13
|
-
border-color: color(black lightness(85%));
|
|
14
14
|
height: 50px;
|
|
15
|
-
border-radius:
|
|
15
|
+
border-radius: 8px;
|
|
16
16
|
font-size: 14px;
|
|
17
|
-
width:
|
|
17
|
+
max-width: calc(100% - 24px);
|
|
18
|
+
width: 100%;
|
|
18
19
|
outline: none;
|
|
20
|
+
padding-left: 12px;
|
|
21
|
+
padding-right: 12px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.freeText::placeholder {
|
|
25
|
+
color: color(cm_blue_900 a(0.3));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.freeText:-ms-input-placeholder {
|
|
29
|
+
color: color(cm_blue_900 a(0.3))!important;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
.
|
|
22
|
-
|
|
32
|
+
.freeText:focus {
|
|
33
|
+
outline: none;
|
|
23
34
|
}
|
|
24
35
|
|
|
25
|
-
.
|
|
36
|
+
.freeText:hover {
|
|
26
37
|
outline: none;
|
|
27
38
|
}
|
|
28
39
|
|
|
40
|
+
.wrapper {
|
|
41
|
+
border-radius: 8px;
|
|
42
|
+
box-shadow: 0px 4px 16px box_shadow_light_dark;
|
|
43
|
+
margin: 0 15px;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
width: 230px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.wrapper:hover {
|
|
49
|
+
box-shadow: none;
|
|
50
|
+
overflow: visible;
|
|
51
|
+
}
|
|
52
|
+
|
|
29
53
|
@media mobile {
|
|
30
54
|
.wrapper {
|
|
31
|
-
width:
|
|
55
|
+
max-width: calc(100% - 30px);
|
|
56
|
+
width: auto;
|
|
32
57
|
box-sizing: border-box;
|
|
33
|
-
max-width: 100%;
|
|
34
58
|
}
|
|
35
59
|
|
|
36
|
-
.
|
|
60
|
+
.freeText {
|
|
61
|
+
min-width: fit-content;
|
|
37
62
|
width: 100%;
|
|
38
|
-
margin: 0;
|
|
39
63
|
box-sizing: border-box;
|
|
40
64
|
}
|
|
41
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/default.js"],"names":["props","placeholder","
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/default.js"],"names":["props","placeholder","value","undefined"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAEC;AAFF;AADM,CAAf","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: undefined\n }\n};\n"],"file":"default.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/with-value-on-change.js"],"names":["props","placeholder","value","onChange"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAE,OAFF;AAGLC,IAAAA,QAAQ,EAAE,MAAM,CAAE,CAHb;AAIL,kBAAc;AAJT;AADM,CAAf","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: 'plop!',\n onChange: () => {},\n 'aria-label': 'aria input'\n }\n};\n"],"file":"with-value-on-change.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/molecule/questions/free-text/test/fixtures/with-value.js"],"names":["props","placeholder","value"],"mappings":"AAAA,eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,WAAW,EAAE,uBADR;AAELC,IAAAA,KAAK,EAAE;AAFF;AADM,CAAf","sourcesContent":["export default {\n props: {\n placeholder: 'Type your answer here',\n value: 'plop!'\n }\n};\n"],"file":"with-value.js"}
|
|
@@ -3,7 +3,8 @@ import forEach from 'lodash/forEach';
|
|
|
3
3
|
import renderComponentMacro from '../../../../test/helpers/render-component';
|
|
4
4
|
import MoleculeQuestionsFreeText from '..';
|
|
5
5
|
import fixtureDefault from './fixtures/default';
|
|
6
|
-
import
|
|
6
|
+
import fixtureWithValueOnChange from './fixtures/with-value-on-change';
|
|
7
|
+
import fixtureWithValue from './fixtures/with-value';
|
|
7
8
|
test('MoleculeQuestions › MoleculeQuestionsFreeText > should have valid propTypes', t => {
|
|
8
9
|
t.pass();
|
|
9
10
|
forEach(MoleculeQuestionsFreeText.propTypes, (value, key) => {
|
|
@@ -11,5 +12,6 @@ test('MoleculeQuestions › MoleculeQuestionsFreeText > should have valid propTy
|
|
|
11
12
|
});
|
|
12
13
|
});
|
|
13
14
|
test('MoleculeQuestions › MoleculeQuestionsFreeText › Default › should be rendered', renderComponentMacro, MoleculeQuestionsFreeText, fixtureDefault);
|
|
14
|
-
test('MoleculeQuestions › MoleculeQuestionsFreeText ›
|
|
15
|
+
test('MoleculeQuestions › MoleculeQuestionsFreeText › WithValueOnChange › should be rendered', renderComponentMacro, MoleculeQuestionsFreeText, fixtureWithValueOnChange);
|
|
16
|
+
test('MoleculeQuestions › MoleculeQuestionsFreeText › WithValue › should be rendered', renderComponentMacro, MoleculeQuestionsFreeText, fixtureWithValue);
|
|
15
17
|
//# sourceMappingURL=fixtures.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/molecule/questions/free-text/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","MoleculeQuestionsFreeText","fixtureDefault","
|
|
1
|
+
{"version":3,"sources":["../../../../../src/molecule/questions/free-text/test/fixtures.js"],"names":["test","forEach","renderComponentMacro","MoleculeQuestionsFreeText","fixtureDefault","fixtureWithValueOnChange","fixtureWithValue","t","pass","propTypes","value","key","not","undefined"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,KAAjB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,oBAAP,MAAiC,2CAAjC;AACA,OAAOC,yBAAP,MAAsC,IAAtC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,wBAAP,MAAqC,iCAArC;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AAEAN,IAAI,CAAC,6EAAD,EAAgFO,CAAC,IAAI;AACvFA,EAAAA,CAAC,CAACC,IAAF;AACAP,EAAAA,OAAO,CAACE,yBAAyB,CAACM,SAA3B,EAAsC,CAACC,KAAD,EAAQC,GAAR,KAAgB;AAC3DJ,IAAAA,CAAC,CAACK,GAAF,CAAMF,KAAN,EAAaG,SAAb,EAAyB,uEAAsEF,GAAI,mEAAnG;AACD,GAFM,CAAP;AAGD,CALG,CAAJ;AAOAX,IAAI,CAAC,8EAAD,EAAiFE,oBAAjF,EAAuGC,yBAAvG,EAAkIC,cAAlI,CAAJ;AACAJ,IAAI,CAAC,wFAAD,EAA2FE,oBAA3F,EAAiHC,yBAAjH,EAA4IE,wBAA5I,CAAJ;AACAL,IAAI,CAAC,gFAAD,EAAmFE,oBAAnF,EAAyGC,yBAAzG,EAAoIG,gBAApI,CAAJ","sourcesContent":["import test from 'ava';\nimport forEach from 'lodash/forEach';\nimport renderComponentMacro from '../../../../test/helpers/render-component';\nimport MoleculeQuestionsFreeText from '..';\nimport fixtureDefault from './fixtures/default';\nimport fixtureWithValueOnChange from './fixtures/with-value-on-change';\nimport fixtureWithValue from './fixtures/with-value';\n\ntest('MoleculeQuestions › MoleculeQuestionsFreeText > should have valid propTypes', t => {\n t.pass();\n forEach(MoleculeQuestionsFreeText.propTypes, (value, key) => {\n t.not(value, undefined, `PropType for \"MoleculeQuestions.MoleculeQuestionsFreeText.propTypes.${key}\" may not be undefined. Did you mistype the propTypes definition?`);\n });\n});\n\ntest('MoleculeQuestions › MoleculeQuestionsFreeText › Default › should be rendered', renderComponentMacro, MoleculeQuestionsFreeText, fixtureDefault);\ntest('MoleculeQuestions › MoleculeQuestionsFreeText › WithValueOnChange › should be rendered', renderComponentMacro, MoleculeQuestionsFreeText, fixtureWithValueOnChange);\ntest('MoleculeQuestions › MoleculeQuestionsFreeText › WithValue › should be rendered', renderComponentMacro, MoleculeQuestionsFreeText, fixtureWithValue);\n"],"file":"fixtures.js"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import _identity from "lodash/fp/identity";
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
import browserEnv from 'browser-env';
|
|
6
|
+
import test from 'ava';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { shallow, mount, configure } from 'enzyme';
|
|
9
|
+
import Adapter from 'enzyme-adapter-react-16';
|
|
10
|
+
import FreeText from '..';
|
|
11
|
+
import defaultFixture from './fixtures/default';
|
|
12
|
+
import withValueFixture from './fixtures/with-value';
|
|
13
|
+
import withValueOnChangeFixture from './fixtures/with-value-on-change';
|
|
14
|
+
browserEnv();
|
|
15
|
+
configure({
|
|
16
|
+
adapter: new Adapter()
|
|
17
|
+
});
|
|
18
|
+
const translate = _identity;
|
|
19
|
+
test('onInput should be reachable and replace onChange, onChange should not trigger value changes, should use aria-label', t => {
|
|
20
|
+
t.plan(7);
|
|
21
|
+
let onInputWasTriggered = false;
|
|
22
|
+
|
|
23
|
+
const props = _extends(_extends({}, withValueOnChangeFixture.props), {}, {
|
|
24
|
+
onChange: value => {
|
|
25
|
+
onInputWasTriggered = true;
|
|
26
|
+
t.is(value, 'new value');
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(FreeText, props), {
|
|
31
|
+
context: {
|
|
32
|
+
translate
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
let freeText = wrapper.find('[data-name="free-text-input"]');
|
|
36
|
+
t.true(freeText.at(0).exists());
|
|
37
|
+
t.is(freeText.at(0).props()['aria-label'], 'aria input');
|
|
38
|
+
t.is(freeText.at(0).props().value, 'plop!'); // should not trigger a value change with onChange
|
|
39
|
+
|
|
40
|
+
freeText.at(0).simulate('change', {
|
|
41
|
+
target: {
|
|
42
|
+
value: 'new value'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
wrapper.update(); // should not update the trigger flag with onChange
|
|
46
|
+
|
|
47
|
+
t.false(onInputWasTriggered);
|
|
48
|
+
freeText.at(0).simulate('input', {
|
|
49
|
+
target: {
|
|
50
|
+
value: 'new value'
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
wrapper.update();
|
|
54
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
55
|
+
t.true(onInputWasTriggered);
|
|
56
|
+
t.pass();
|
|
57
|
+
});
|
|
58
|
+
test('should set: boxShadow (hover & not hovered variants) && color for the input if a value is provided', t => {
|
|
59
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(FreeText, withValueFixture.props));
|
|
60
|
+
let freeTextWrapper = wrapper.find('[data-name="freeText"]');
|
|
61
|
+
t.true(freeTextWrapper.at(0).exists());
|
|
62
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
63
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'
|
|
64
|
+
});
|
|
65
|
+
let freeText = wrapper.find('[data-name="free-text-input"]');
|
|
66
|
+
t.true(freeText.at(0).exists());
|
|
67
|
+
t.is(freeText.at(0).props().value, 'plop!');
|
|
68
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
69
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'
|
|
70
|
+
});
|
|
71
|
+
freeTextWrapper.simulate('mouseover');
|
|
72
|
+
wrapper.update();
|
|
73
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
74
|
+
freeTextWrapper = wrapper.find('[data-name="freeText"]'); // hovered
|
|
75
|
+
|
|
76
|
+
t.deepEqual(freeText.at(0).props().style, {
|
|
77
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.2)',
|
|
78
|
+
color: '#00B0FF'
|
|
79
|
+
});
|
|
80
|
+
t.deepEqual(freeTextWrapper.at(0).props().style, {
|
|
81
|
+
boxShadow: 'none'
|
|
82
|
+
});
|
|
83
|
+
freeTextWrapper.simulate('mouseleave');
|
|
84
|
+
wrapper.update();
|
|
85
|
+
freeText = wrapper.find('[data-name="free-text-input"]');
|
|
86
|
+
t.deepEqual(freeText.at(0).props().style, {
|
|
87
|
+
boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)',
|
|
88
|
+
color: '#00B0FF'
|
|
89
|
+
});
|
|
90
|
+
t.pass();
|
|
91
|
+
});
|
|
92
|
+
test('should use value as default aria-label if no aria-label is provided', t => {
|
|
93
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(FreeText, withValueFixture.props));
|
|
94
|
+
const freeText = wrapper.find('[data-name="free-text-input"]');
|
|
95
|
+
t.true(freeText.at(0).exists());
|
|
96
|
+
t.is(freeText.at(0).props()['aria-label'], 'plop!');
|
|
97
|
+
t.pass();
|
|
98
|
+
});
|
|
99
|
+
test('should use placeholder as default aria-label if no aria-label is provided and no value is present', t => {
|
|
100
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(FreeText, defaultFixture.props));
|
|
101
|
+
const freeText = wrapper.find('[data-name="free-text-input"]');
|
|
102
|
+
t.true(freeText.at(0).exists());
|
|
103
|
+
t.is(freeText.at(0).props()['aria-label'], 'Type your answer here');
|
|
104
|
+
t.pass();
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=free-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/molecule/questions/free-text/test/free-text.js"],"names":["browserEnv","test","React","shallow","mount","configure","Adapter","FreeText","defaultFixture","withValueFixture","withValueOnChangeFixture","adapter","translate","t","plan","onInputWasTriggered","props","onChange","value","is","wrapper","context","freeText","find","true","at","exists","simulate","target","update","false","pass","freeTextWrapper","deepEqual","style","boxShadow","color"],"mappings":";;;;AAAA,OAAOA,UAAP,MAAuB,aAAvB;AACA,OAAOC,IAAP,MAAiB,KAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAAQC,OAAR,EAAiBC,KAAjB,EAAwBC,SAAxB,QAAwC,QAAxC;AAEA,OAAOC,OAAP,MAAoB,yBAApB;AACA,OAAOC,QAAP,MAAqB,IAArB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AACA,OAAOC,wBAAP,MAAqC,iCAArC;AAEAV,UAAU;AACVK,SAAS,CAAC;AAACM,EAAAA,OAAO,EAAE,IAAIL,OAAJ;AAAV,CAAD,CAAT;AACA,MAAMM,SAAS,YAAf;AAEAX,IAAI,CAAC,oHAAD,EAAuHY,CAAC,IAAI;AAC9HA,EAAAA,CAAC,CAACC,IAAF,CAAO,CAAP;AACA,MAAIC,mBAAmB,GAAG,KAA1B;;AACA,QAAMC,KAAK,yBACNN,wBAAwB,CAACM,KADnB;AAETC,IAAAA,QAAQ,EAAEC,KAAK,IAAI;AACjBH,MAAAA,mBAAmB,GAAG,IAAtB;AACAF,MAAAA,CAAC,CAACM,EAAF,CAAKD,KAAL,EAAY,WAAZ;AACD;AALQ,IAAX;;AAOA,QAAME,OAAO,GAAG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CAAZ,EAAeC,MAAf,EAAP;AACAb,EAAAA,CAAC,CAACM,EAAF,CAAKG,QAAQ,CAACG,EAAT,CAAY,CAAZ,EAAeT,KAAf,GAAuB,YAAvB,CAAL,EAA2C,uBAA3C;AACAH,EAAAA,CAAC,CAACkB,IAAF;AACD,CANG,CAAJ","sourcesContent":["import browserEnv from 'browser-env';\nimport test from 'ava';\nimport React from 'react';\nimport {shallow, mount, configure} from 'enzyme';\nimport {identity} from 'lodash/fp';\nimport Adapter from 'enzyme-adapter-react-16';\nimport FreeText from '..';\nimport defaultFixture from './fixtures/default';\nimport withValueFixture from './fixtures/with-value';\nimport withValueOnChangeFixture from './fixtures/with-value-on-change';\n\nbrowserEnv();\nconfigure({adapter: new Adapter()});\nconst translate = identity;\n\ntest('onInput should be reachable and replace onChange, onChange should not trigger value changes, should use aria-label', t => {\n t.plan(7);\n let onInputWasTriggered = false;\n const props = {\n ...withValueOnChangeFixture.props,\n onChange: value => {\n onInputWasTriggered = true;\n t.is(value, 'new value');\n }\n };\n const wrapper = shallow(<FreeText {...props} />, {\n context: {translate}\n });\n let freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props()['aria-label'], 'aria input');\n t.is(freeText.at(0).props().value, 'plop!');\n // should not trigger a value change with onChange\n freeText.at(0).simulate('change', {target: {value: 'new value'}});\n wrapper.update();\n // should not update the trigger flag with onChange\n t.false(onInputWasTriggered);\n freeText.at(0).simulate('input', {target: {value: 'new value'}});\n wrapper.update();\n freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(onInputWasTriggered);\n t.pass();\n});\n\ntest('should set: boxShadow (hover & not hovered variants) && color for the input if a value is provided', t => {\n const wrapper = mount(<FreeText {...withValueFixture.props} />);\n let freeTextWrapper = wrapper.find('[data-name=\"freeText\"]');\n t.true(freeTextWrapper.at(0).exists());\n t.deepEqual(freeTextWrapper.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'\n });\n\n let freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props().value, 'plop!');\n t.deepEqual(freeTextWrapper.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)'\n });\n freeTextWrapper.simulate('mouseover');\n wrapper.update();\n\n freeText = wrapper.find('[data-name=\"free-text-input\"]');\n freeTextWrapper = wrapper.find('[data-name=\"freeText\"]');\n // hovered\n t.deepEqual(freeText.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.2)',\n color: '#00B0FF'\n });\n t.deepEqual(freeTextWrapper.at(0).props().style, {\n boxShadow: 'none'\n });\n\n freeTextWrapper.simulate('mouseleave');\n wrapper.update();\n freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.deepEqual(freeText.at(0).props().style, {\n boxShadow: '0 4px 16px rgba(0, 176, 255, 0.12)',\n color: '#00B0FF'\n });\n\n t.pass();\n});\n\ntest('should use value as default aria-label if no aria-label is provided', t => {\n const wrapper = mount(<FreeText {...withValueFixture.props} />);\n const freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props()['aria-label'], 'plop!');\n t.pass();\n});\n\ntest('should use placeholder as default aria-label if no aria-label is provided and no value is present', t => {\n const wrapper = mount(<FreeText {...defaultFixture.props} />);\n const freeText = wrapper.find('[data-name=\"free-text-input\"]');\n t.true(freeText.at(0).exists());\n t.is(freeText.at(0).props()['aria-label'], 'Type your answer here');\n t.pass();\n});\n"],"file":"free-text.js"}
|