@elice/material-quiz 1.221222.0 → 1.221228.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.
@@ -22,11 +22,8 @@ const MAX_OPTION_INFO_COUNT = 20;
22
22
  const StyledSortableList = styled__default["default"].div.withConfig({
23
23
  componentId: "sc-14yoda7-0"
24
24
  })(["margin:1rem 0;padding:0;"]);
25
- const StyledSortableListItemWrapper = styled__default["default"].div.withConfig({
26
- componentId: "sc-14yoda7-1"
27
- })(["display:flex;flex-direction:column;width:100%;&:not(:last-child){margin-bottom:0.5rem;}"]);
28
25
  const StyledOptionTitle = styled__default["default"].div.withConfig({
29
- componentId: "sc-14yoda7-2"
26
+ componentId: "sc-14yoda7-1"
30
27
  })(["display:flex;width:calc(100% - 2rem - 1.5rem);"]); //
31
28
  //
32
29
  //
@@ -125,12 +122,11 @@ const OptionGroupAnswerInfo = () => {
125
122
  return React__default["default"].createElement(blocks.SortableListGroup, {
126
123
  onSortEnd: onSortEnd,
127
124
  useDragHandle: true
128
- }, React__default["default"].createElement(StyledSortableList, null, watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.map((option, index) => React__default["default"].createElement(StyledSortableListItemWrapper, {
129
- key: option.id
130
- }, React__default["default"].createElement(OptionGroupAnswerListItem, {
125
+ }, React__default["default"].createElement(StyledSortableList, null, watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.map((option, index) => React__default["default"].createElement(OptionGroupAnswerListItem, {
126
+ key: option.id,
131
127
  optionId: index,
132
128
  onRemoveItem: () => handleRemoveItem(index)
133
- })))));
129
+ }))));
134
130
  };
135
131
  /**
136
132
  *
@@ -9,6 +9,7 @@ var designTokens = require('@elice/design-tokens');
9
9
  var icons = require('@elice/icons');
10
10
  var materialSharedUtils = require('@elice/material-shared-utils');
11
11
  var cloneDeep = require('lodash-es/cloneDeep');
12
+ var trim = require('lodash-es/trim');
12
13
  var styled = require('styled-components');
13
14
  var checkTwoDimensionArray = require('../../utils/checkTwoDimensionArray.js');
14
15
 
@@ -16,6 +17,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
16
17
 
17
18
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
18
19
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
20
+ var trim__default = /*#__PURE__*/_interopDefaultLegacy(trim);
19
21
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
20
22
 
21
23
  const SHEET_Z_INDEX = 982;
@@ -26,7 +28,7 @@ const FILE_ACCEPT = '.mp3, .mp4, .mov, .png, .jpg, .svg, .gif';
26
28
  const MAX_FILE_SIZE = 3 * 1024 * 1024;
27
29
  const StyledSortableListItem = styled__default["default"](blocks.SortableListItem).withConfig({
28
30
  componentId: "sc-18q96lt-0"
29
- })(["display:flex;flex:1;z-index:", ";padding:0;background:transparent;box-shadow:none;"], SHEET_Z_INDEX + 1);
31
+ })(["display:flex;flex:1;z-index:", ";padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
30
32
  const StyledSortableListItemOptionWrapper = styled__default["default"].div.withConfig({
31
33
  componentId: "sc-18q96lt-1"
32
34
  })(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border:1px solid ", ";border-radius:4px;background:", ";"], designTokens.base.color.gray3, designTokens.base.color.white);
@@ -120,15 +122,19 @@ const OptionGroupAnswerListItem = ({
120
122
  message: intl.formatMessage({
121
123
  id: 'answer.option.errorMessage'
122
124
  })
125
+ },
126
+ validate: e => {
127
+ if (!trim__default["default"](e).length) {
128
+ return intl.formatMessage({
129
+ id: 'answer.option.errorMessage'
130
+ });
131
+ }
123
132
  }
124
133
  },
125
134
  render: ({
126
135
  field
127
136
  }) => React__default["default"].createElement(StyledQuizOptionTextInput, Object.assign({}, field, {
128
- width: "full",
129
- onChange: e => {
130
- field.onChange(e.target.value.replace(' ', ''));
131
- }
137
+ width: "full"
132
138
  }))
133
139
  }));
134
140
  };
@@ -20,10 +20,7 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
20
20
  const MAX_GROUP_INFO_COUNT = 6;
21
21
  const StyledSortableList = styled__default["default"].div.withConfig({
22
22
  componentId: "sc-9aq3yn-0"
23
- })(["margin:1rem 0;padding:0;"]);
24
- const StyledSortableListItemWrapper = styled__default["default"].div.withConfig({
25
- componentId: "sc-9aq3yn-1"
26
- })(["display:flex;flex-direction:column;&:not(:last-child){margin-bottom:0.5rem;}"]); //
23
+ })(["margin:1rem 0;padding:0;"]); //
27
24
  //
28
25
  //
29
26
 
@@ -92,15 +89,12 @@ const OptionGroupGroupInfo = () => {
92
89
  return React__default["default"].createElement(blocks.SortableListGroup, {
93
90
  onSortEnd: onSortEnd,
94
91
  useDragHandle: true
95
- }, React__default["default"].createElement(StyledSortableList, null, groupInfoFields.map((group, index) => {
96
- return React__default["default"].createElement(StyledSortableListItemWrapper, {
97
- key: group.id
98
- }, React__default["default"].createElement(OptionGroupGroupListItem, {
99
- groupId: index,
100
- groupsCount: groupInfoFields.length,
101
- onRemoveOption: () => removeGroupAnswerInfo(index)
102
- }));
103
- })));
92
+ }, React__default["default"].createElement(StyledSortableList, null, groupInfoFields.map((group, index) => React__default["default"].createElement(OptionGroupGroupListItem, {
93
+ key: group.id,
94
+ groupId: index,
95
+ groupsCount: groupInfoFields.length,
96
+ onRemoveOption: () => removeGroupAnswerInfo(index)
97
+ }))));
104
98
  };
105
99
  /**
106
100
  *
@@ -6,18 +6,20 @@ var reactIntl = require('react-intl');
6
6
  var blocks = require('@elice/blocks');
7
7
  var designTokens = require('@elice/design-tokens');
8
8
  var icons = require('@elice/icons');
9
+ var trim = require('lodash-es/trim');
9
10
  var styled = require('styled-components');
10
11
 
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
13
 
13
14
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
+ var trim__default = /*#__PURE__*/_interopDefaultLegacy(trim);
14
16
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
15
17
 
16
18
  const SHEET_Z_INDEX = 982;
17
19
  const MIN_GROUP_INFO_COUNT = 2;
18
20
  const StyledSortableListItem = styled__default["default"](blocks.SortableListItem).withConfig({
19
21
  componentId: "sc-hj5nic-0"
20
- })(["display:flex;z-index:", ";width:100%;padding:0;background:transparent;box-shadow:none;"], SHEET_Z_INDEX + 1);
22
+ })(["display:flex;z-index:", ";width:100%;padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
21
23
  const StyledSortableListItemOptionWrapper = styled__default["default"].div.withConfig({
22
24
  componentId: "sc-hj5nic-1"
23
25
  })(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border-radius:4px;border:1px solid ", ";background:", ";"], ({
@@ -61,7 +63,13 @@ const OptionGroupGroupListItem = ({
61
63
  id: 'group.option.errorMessage.required'
62
64
  })
63
65
  },
64
- validate: () => {
66
+ validate: e => {
67
+ if (!trim__default["default"](e).length) {
68
+ return intl.formatMessage({
69
+ id: 'group.option.errorMessage.required'
70
+ });
71
+ }
72
+
65
73
  if (!isGroupChildAnswer) {
66
74
  return intl.formatMessage({
67
75
  id: 'group.option.errorMessage.notChild'
@@ -74,10 +82,7 @@ const OptionGroupGroupListItem = ({
74
82
  fieldState
75
83
  }) => React__default["default"].createElement(StyledInputGroup, Object.assign({}, field, {
76
84
  invalid: fieldState.invalid || !isGroupChildAnswer,
77
- width: "full",
78
- onChange: e => {
79
- field.onChange(e.target.value.replace(' ', ''));
80
- }
85
+ width: "full"
81
86
  }))
82
87
  }));
83
88
  };
@@ -2,8 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var trim = require('lodash-es/trim');
5
6
  var randomId = require('./randomId.js');
6
7
 
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var trim__default = /*#__PURE__*/_interopDefaultLegacy(trim);
11
+
7
12
  /**
8
13
  *
9
14
  */
@@ -34,13 +39,13 @@ function manipulateValue(v) {
34
39
  function restoreValue(v) {
35
40
  return Object.assign(Object.assign({}, v), {
36
41
  options: v.options.length ? v.options.map(option => ({
37
- title: option.title,
42
+ title: trim__default["default"](option.title),
38
43
  content: option.content
39
44
  })) : null,
40
45
  answerInfo: Array.isArray(v.answerInfo) || typeof v.answerInfo === 'string' ? v.answerInfo : undefined,
41
46
  groups: v.groups.length ? v.groups.map(({
42
47
  group
43
- }) => group) : null
48
+ }) => trim__default["default"](group)) : null
44
49
  });
45
50
  }
46
51
 
@@ -14,11 +14,8 @@ const MAX_OPTION_INFO_COUNT = 20;
14
14
  const StyledSortableList = styled.div.withConfig({
15
15
  componentId: "sc-14yoda7-0"
16
16
  })(["margin:1rem 0;padding:0;"]);
17
- const StyledSortableListItemWrapper = styled.div.withConfig({
18
- componentId: "sc-14yoda7-1"
19
- })(["display:flex;flex-direction:column;width:100%;&:not(:last-child){margin-bottom:0.5rem;}"]);
20
17
  const StyledOptionTitle = styled.div.withConfig({
21
- componentId: "sc-14yoda7-2"
18
+ componentId: "sc-14yoda7-1"
22
19
  })(["display:flex;width:calc(100% - 2rem - 1.5rem);"]); //
23
20
  //
24
21
  //
@@ -117,12 +114,11 @@ const OptionGroupAnswerInfo = () => {
117
114
  return React.createElement(SortableListGroup, {
118
115
  onSortEnd: onSortEnd,
119
116
  useDragHandle: true
120
- }, React.createElement(StyledSortableList, null, watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.map((option, index) => React.createElement(StyledSortableListItemWrapper, {
121
- key: option.id
122
- }, React.createElement(OptionGroupAnswerListItem, {
117
+ }, React.createElement(StyledSortableList, null, watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.map((option, index) => React.createElement(OptionGroupAnswerListItem, {
118
+ key: option.id,
123
119
  optionId: index,
124
120
  onRemoveItem: () => handleRemoveItem(index)
125
- })))));
121
+ }))));
126
122
  };
127
123
  /**
128
124
  *
@@ -7,6 +7,7 @@ import { base } from '@elice/design-tokens';
7
7
  import { eilMathsignMultiplyBasic } from '@elice/icons';
8
8
  import { useMaterialConfigApiClientUpdate } from '@elice/material-shared-utils';
9
9
  import cloneDeep from 'lodash-es/cloneDeep';
10
+ import trim from 'lodash-es/trim';
10
11
  import styled from 'styled-components';
11
12
  import { checkTwoDimensionArray } from '../../utils/checkTwoDimensionArray.js';
12
13
 
@@ -18,7 +19,7 @@ const FILE_ACCEPT = '.mp3, .mp4, .mov, .png, .jpg, .svg, .gif';
18
19
  const MAX_FILE_SIZE = 3 * 1024 * 1024;
19
20
  const StyledSortableListItem = styled(SortableListItem).withConfig({
20
21
  componentId: "sc-18q96lt-0"
21
- })(["display:flex;flex:1;z-index:", ";padding:0;background:transparent;box-shadow:none;"], SHEET_Z_INDEX + 1);
22
+ })(["display:flex;flex:1;z-index:", ";padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
22
23
  const StyledSortableListItemOptionWrapper = styled.div.withConfig({
23
24
  componentId: "sc-18q96lt-1"
24
25
  })(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border:1px solid ", ";border-radius:4px;background:", ";"], base.color.gray3, base.color.white);
@@ -112,15 +113,19 @@ const OptionGroupAnswerListItem = ({
112
113
  message: intl.formatMessage({
113
114
  id: 'answer.option.errorMessage'
114
115
  })
116
+ },
117
+ validate: e => {
118
+ if (!trim(e).length) {
119
+ return intl.formatMessage({
120
+ id: 'answer.option.errorMessage'
121
+ });
122
+ }
115
123
  }
116
124
  },
117
125
  render: ({
118
126
  field
119
127
  }) => React.createElement(StyledQuizOptionTextInput, Object.assign({}, field, {
120
- width: "full",
121
- onChange: e => {
122
- field.onChange(e.target.value.replace(' ', ''));
123
- }
128
+ width: "full"
124
129
  }))
125
130
  }));
126
131
  };
@@ -12,10 +12,7 @@ import OptionGroupGroupListItem from './OptionGroupGroupListItem.js';
12
12
  const MAX_GROUP_INFO_COUNT = 6;
13
13
  const StyledSortableList = styled.div.withConfig({
14
14
  componentId: "sc-9aq3yn-0"
15
- })(["margin:1rem 0;padding:0;"]);
16
- const StyledSortableListItemWrapper = styled.div.withConfig({
17
- componentId: "sc-9aq3yn-1"
18
- })(["display:flex;flex-direction:column;&:not(:last-child){margin-bottom:0.5rem;}"]); //
15
+ })(["margin:1rem 0;padding:0;"]); //
19
16
  //
20
17
  //
21
18
 
@@ -84,15 +81,12 @@ const OptionGroupGroupInfo = () => {
84
81
  return React.createElement(SortableListGroup, {
85
82
  onSortEnd: onSortEnd,
86
83
  useDragHandle: true
87
- }, React.createElement(StyledSortableList, null, groupInfoFields.map((group, index) => {
88
- return React.createElement(StyledSortableListItemWrapper, {
89
- key: group.id
90
- }, React.createElement(OptionGroupGroupListItem, {
91
- groupId: index,
92
- groupsCount: groupInfoFields.length,
93
- onRemoveOption: () => removeGroupAnswerInfo(index)
94
- }));
95
- })));
84
+ }, React.createElement(StyledSortableList, null, groupInfoFields.map((group, index) => React.createElement(OptionGroupGroupListItem, {
85
+ key: group.id,
86
+ groupId: index,
87
+ groupsCount: groupInfoFields.length,
88
+ onRemoveOption: () => removeGroupAnswerInfo(index)
89
+ }))));
96
90
  };
97
91
  /**
98
92
  *
@@ -4,13 +4,14 @@ import { useIntl } from 'react-intl';
4
4
  import { SortableListItem, Input, Flex, Hspace, Tooltip, IconButton, Text } from '@elice/blocks';
5
5
  import { base } from '@elice/design-tokens';
6
6
  import { eilMathsignMultiplyBasic } from '@elice/icons';
7
+ import trim from 'lodash-es/trim';
7
8
  import styled from 'styled-components';
8
9
 
9
10
  const SHEET_Z_INDEX = 982;
10
11
  const MIN_GROUP_INFO_COUNT = 2;
11
12
  const StyledSortableListItem = styled(SortableListItem).withConfig({
12
13
  componentId: "sc-hj5nic-0"
13
- })(["display:flex;z-index:", ";width:100%;padding:0;background:transparent;box-shadow:none;"], SHEET_Z_INDEX + 1);
14
+ })(["display:flex;z-index:", ";width:100%;padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
14
15
  const StyledSortableListItemOptionWrapper = styled.div.withConfig({
15
16
  componentId: "sc-hj5nic-1"
16
17
  })(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border-radius:4px;border:1px solid ", ";background:", ";"], ({
@@ -54,7 +55,13 @@ const OptionGroupGroupListItem = ({
54
55
  id: 'group.option.errorMessage.required'
55
56
  })
56
57
  },
57
- validate: () => {
58
+ validate: e => {
59
+ if (!trim(e).length) {
60
+ return intl.formatMessage({
61
+ id: 'group.option.errorMessage.required'
62
+ });
63
+ }
64
+
58
65
  if (!isGroupChildAnswer) {
59
66
  return intl.formatMessage({
60
67
  id: 'group.option.errorMessage.notChild'
@@ -67,10 +74,7 @@ const OptionGroupGroupListItem = ({
67
74
  fieldState
68
75
  }) => React.createElement(StyledInputGroup, Object.assign({}, field, {
69
76
  invalid: fieldState.invalid || !isGroupChildAnswer,
70
- width: "full",
71
- onChange: e => {
72
- field.onChange(e.target.value.replace(' ', ''));
73
- }
77
+ width: "full"
74
78
  }))
75
79
  }));
76
80
  };
@@ -1,3 +1,4 @@
1
+ import trim from 'lodash-es/trim';
1
2
  import { createRandomId } from './randomId.js';
2
3
 
3
4
  /**
@@ -30,13 +31,13 @@ function manipulateValue(v) {
30
31
  function restoreValue(v) {
31
32
  return Object.assign(Object.assign({}, v), {
32
33
  options: v.options.length ? v.options.map(option => ({
33
- title: option.title,
34
+ title: trim(option.title),
34
35
  content: option.content
35
36
  })) : null,
36
37
  answerInfo: Array.isArray(v.answerInfo) || typeof v.answerInfo === 'string' ? v.answerInfo : undefined,
37
38
  groups: v.groups.length ? v.groups.map(({
38
39
  group
39
- }) => group) : null
40
+ }) => trim(group)) : null
40
41
  });
41
42
  }
42
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-quiz",
3
- "version": "1.221222.0",
3
+ "version": "1.221228.0",
4
4
  "description": "User view and editing components of Elice material quiz",
5
5
  "repository": "https://git.elicer.io/elice/frontend/library/elice-material",
6
6
  "license": "UNLICENSED",
@@ -58,8 +58,8 @@
58
58
  "@elice/icons": "^1.220803.0",
59
59
  "@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
60
60
  "@elice/markdown": "^1.220803.0",
61
- "@elice/material-shared-types": "1.221222.0",
62
- "@elice/material-shared-utils": "1.221222.0",
61
+ "@elice/material-shared-types": "1.221228.0",
62
+ "@elice/material-shared-utils": "1.221228.0",
63
63
  "@elice/types": "1.221217.0",
64
64
  "@types/classnames": "^2.3.1",
65
65
  "@types/jquery": "^3.5.13",
@@ -73,5 +73,5 @@
73
73
  "react-use": "^17.2.4",
74
74
  "styled-components": "^5.3.0"
75
75
  },
76
- "gitHead": "417f2c0d5c6c4ffc7c5c2ab95ec7a2ca36dca843"
76
+ "gitHead": "53eaff58a939c390104c7e96f0bc3eb8738a3ee7"
77
77
  }