@micromag/screen-survey 0.3.79 → 0.3.84

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.
@@ -1 +1 @@
1
- .micromag-screen-survey-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-survey-disabled.micromag-screen-survey-container{overflow:hidden;pointer-events:none}.micromag-screen-survey-hidden.micromag-screen-survey-container{display:none;visibility:hidden}.micromag-screen-survey-placeholder.micromag-screen-survey-container .micromag-screen-survey-content{position:relative;padding:6px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{margin:5px auto;border:2px dashed #343434;color:#343434}.micromag-screen-survey-container .micromag-screen-survey-question{margin-bottom:20px}.micromag-screen-survey-container .micromag-screen-survey-answers,.micromag-screen-survey-container .micromag-screen-survey-items{position:relative}.micromag-screen-survey-container .micromag-screen-survey-item{padding:5px 0}.micromag-screen-survey-container .micromag-screen-survey-item:first-child .micromag-screen-survey-placeholderAnswer{width:80%}.micromag-screen-survey-container .micromag-screen-survey-item:last-child .micromag-screen-survey-placeholderAnswer{width:90%}.micromag-screen-survey-container .micromag-screen-survey-itemContent{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.micromag-screen-survey-container .micromag-screen-survey-resultContainer{-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;padding:15px 0;-webkit-transition-property:padding;-o-transition-property:padding;transition-property:padding;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-survey-container .micromag-screen-survey-resultContent{width:0;height:1em;-webkit-transition-property:width opacity;-o-transition-property:width opacity;transition-property:width opacity;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;opacity:0}.micromag-screen-survey-container .micromag-screen-survey-result{position:relative;height:100%;background-color:#fff}.micromag-screen-survey-container .micromag-screen-survey-resultLabel{position:absolute;top:50%;left:100%;margin-left:5px;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);color:#fff}.micromag-screen-survey-container .micromag-screen-survey-itemInner{width:100%;-webkit-transition-property:width;-o-transition-property:width;transition-property:width;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-survey-container .micromag-screen-survey-button{display:-webkit-flex;display:-ms-flexbox;display:flex;position:relative;width:100%;padding:0;-webkit-transition:opacity .5s ease-out;-o-transition:opacity .5s ease-out;transition:opacity .5s ease-out;border:2px solid #6c6c6c}.micromag-screen-survey-container .micromag-screen-survey-button:disabled{opacity:1;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-itemLabel{display:inline-block;margin-left:50%;padding:10px;-webkit-transform:translate(-50%);-ms-transform:translate(-50%);transform:translate(-50%);-webkit-transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;-o-transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,-webkit-transform .3s ease-out}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{width:100%;margin:0 auto}.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{height:75px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer{height:50px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContainer{padding-right:50px;padding-left:15px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContent{width:100%;opacity:1}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button{border-color:rgba(0,0,0,0);background-color:rgba(0,0,0,0)}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-result,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultLabel{opacity:.6}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-itemLabel{margin-left:0;-webkit-transform:translate(-10px);-ms-transform:translate(-10px);transform:translate(-10px);text-align:left}.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-button,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-result,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-resultLabel{opacity:1}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-layout{padding:10px}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-item{padding:1px 0}
1
+ .micromag-screen-survey-container{position:relative;width:100%;height:100%;overflow:hidden}.micromag-screen-survey-disabled.micromag-screen-survey-container{overflow:hidden;pointer-events:none}.micromag-screen-survey-hidden.micromag-screen-survey-container{display:none;visibility:hidden}.micromag-screen-survey-placeholder.micromag-screen-survey-container .micromag-screen-survey-content{position:relative;padding:6px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{margin:5px auto;border:2px dashed #343434;color:#343434}.micromag-screen-survey-container .micromag-screen-survey-question{margin-bottom:20px}.micromag-screen-survey-container .micromag-screen-survey-answers,.micromag-screen-survey-container .micromag-screen-survey-items{position:relative}.micromag-screen-survey-container .micromag-screen-survey-item{padding:5px 0}.micromag-screen-survey-container .micromag-screen-survey-item:first-child .micromag-screen-survey-placeholderAnswer{width:80%}.micromag-screen-survey-container .micromag-screen-survey-item:last-child .micromag-screen-survey-placeholderAnswer{width:90%}.micromag-screen-survey-container .micromag-screen-survey-itemContent{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.micromag-screen-survey-container .micromag-screen-survey-resultContainer{-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;padding:15px 0;-webkit-transition-property:padding;-o-transition-property:padding;transition-property:padding;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-survey-container .micromag-screen-survey-resultContent{width:0;height:1em;-webkit-transition-property:width opacity;-o-transition-property:width opacity;transition-property:width opacity;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;opacity:0}.micromag-screen-survey-container .micromag-screen-survey-result{position:relative;height:100%;background-color:#fff}.micromag-screen-survey-container .micromag-screen-survey-resultLabel{position:absolute;top:50%;left:100%;margin-left:5px;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);color:#fff}.micromag-screen-survey-container .micromag-screen-survey-itemInner{width:100%;-webkit-transition-property:width;-o-transition-property:width;transition-property:width;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.micromag-screen-survey-container .micromag-screen-survey-button{display:-webkit-flex;display:-ms-flexbox;display:flex;position:relative;width:100%;padding:0;-webkit-transition:opacity .5s ease-out;-o-transition:opacity .5s ease-out;transition:opacity .5s ease-out}.micromag-screen-survey-container .micromag-screen-survey-button:disabled{opacity:1;pointer-events:none}.micromag-screen-survey-container .micromag-screen-survey-itemLabel{display:inline-block;padding:10px;-webkit-transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;transition:margin-left .3s ease-out,-webkit-transform .3s ease-out;-o-transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out;transition:margin-left .3s ease-out,transform .3s ease-out,-webkit-transform .3s ease-out}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer,.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{width:100%;margin:0 auto}.micromag-screen-survey-container .micromag-screen-survey-emptyQuestion{height:75px}.micromag-screen-survey-container .micromag-screen-survey-emptyAnswer{height:50px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContainer{padding-right:50px;padding-left:15px}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultContent{width:100%;opacity:1}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button{border-color:rgba(0,0,0,0);background-color:rgba(0,0,0,0)}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-button,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-result,.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-resultLabel{opacity:.6}.micromag-screen-survey-container.micromag-screen-survey-answered .micromag-screen-survey-itemLabel{margin-left:0;-webkit-transform:translate(-10px);-ms-transform:translate(-10px);transform:translate(-10px);text-align:left}.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-button,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-result,.micromag-screen-survey-container .micromag-screen-survey-userAnswer .micromag-screen-survey-resultLabel{opacity:1}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-layout{padding:10px}.micromag-screen-survey-container.micromag-screen-survey-isPlaceholder .micromag-screen-survey-item{padding:1px 0}
package/es/index.js CHANGED
@@ -247,23 +247,22 @@ var SurveyScreen = function SurveyScreen(_ref) {
247
247
  useEffect(function () {
248
248
  if (answers === null || isPlaceholder) {
249
249
  return;
250
- }
251
-
252
- var maxWidth = answers.reduce(function (currentMaxWidth, answer, answerI) {
253
- var button = buttonsRefs.current[answerI] || null;
254
- var label = labelsRefs.current[answerI] || null;
255
-
256
- if (button !== null && label !== null) {
257
- var borderWidth = button.offsetWidth - button.clientWidth;
258
- var totalWidth = borderWidth + label.getBoundingClientRect().width + 20;
259
- return Math.max(currentMaxWidth, totalWidth);
260
- }
261
-
262
- return currentMaxWidth;
263
- }, 0);
264
- setButtonMaxWidth(Math.min(width * 0.75, Math.max(width * 0.2, maxWidth)));
250
+ } // const maxWidth = answers.reduce((currentMaxWidth, answer, answerI) => {
251
+ // const button = buttonsRefs.current[answerI] || null;
252
+ // const label = labelsRefs.current[answerI] || null;
253
+ // if (button !== null && label !== null) {
254
+ // const borderWidth = button.offsetWidth - button.clientWidth;
255
+ // const totalWidth = borderWidth + label.getBoundingClientRect().width + 20;
256
+ // return Math.max(currentMaxWidth, totalWidth);
257
+ // }
258
+ // return currentMaxWidth;
259
+ // }, 0);
260
+ // setButtonMaxWidth(Math.min(width * 0.75, Math.max(width * 0.2, maxWidth)));
261
+
262
+
263
+ setButtonMaxWidth(withoutResults ? '100%' : width * 0.75);
265
264
  setReady(true);
266
- }, [answers, width, height, setButtonMaxWidth, finalTransitionDuration, isPlaceholder]);
265
+ }, [answers, width, height, setButtonMaxWidth, finalTransitionDuration, isPlaceholder, withoutResults]);
267
266
 
268
267
  var _ref6 = resultsStyle || {},
269
268
  _ref6$barColor = _ref6.barColor,
@@ -337,7 +336,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
337
336
  }, /*#__PURE__*/React.createElement("div", {
338
337
  className: styles.itemInner,
339
338
  style: {
340
- width: answered && !withoutResults ? buttonMaxWidth : null,
339
+ width: buttonMaxWidth,
341
340
  transitionDuration: finalTransitionDuration
342
341
  }
343
342
  }, /*#__PURE__*/React.createElement(Button, {
@@ -348,7 +347,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
348
347
  refButton: function refButton(el) {
349
348
  buttonsRefs.current[answerIndex] = el;
350
349
  },
351
- disabled: isPreview,
350
+ disabled: isPreview || userAnswerIndex !== null,
352
351
  focusable: current && isView,
353
352
  buttonStyle: !answered ? _objectSpread(_objectSpread({}, getStyleFromBox(buttonsStyle)), getStyleFromBox(answerButtonStyle)) : null
354
353
  }, /*#__PURE__*/React.createElement("span", {
@@ -360,7 +359,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
360
359
  textStyle: textStyle,
361
360
  inline: true,
362
361
  className: styles.itemText
363
- }))))), /*#__PURE__*/React.createElement("div", {
362
+ }))))), !withoutResults ? /*#__PURE__*/React.createElement("div", {
364
363
  className: styles.resultContainer,
365
364
  style: {
366
365
  transitionDuration: finalTransitionDuration
@@ -374,12 +373,12 @@ var SurveyScreen = function SurveyScreen(_ref) {
374
373
  }, /*#__PURE__*/React.createElement("div", {
375
374
  className: styles.result,
376
375
  style: _objectSpread({
377
- width: !withoutResults ? "".concat(percent, "%") : null
376
+ width: percent !== null ? "".concat(percent, "%") : null
378
377
  }, getStyleFromColor(answered ? answerResultBarColor || resultsBarColor || labelColor : null, 'backgroundColor'))
379
- }, withPercentLabels && !withoutResults ? /*#__PURE__*/React.createElement("div", {
378
+ }, withPercentLabels ? /*#__PURE__*/React.createElement("div", {
380
379
  className: styles.resultLabel,
381
380
  style: _objectSpread({}, getStyleFromColor(answered ? answerResultTextColor || resultsTextColor || answerResultBarColor || resultsBarColor || labelColor : null, 'color'))
382
- }, "".concat(percent, "%")) : null))))) : null));
381
+ }, "".concat(percent, "%")) : null))) : null)) : null));
383
382
  })) : null)); // Call to Action
384
383
 
385
384
  if (!isPlaceholder && hasCallToAction) {
@@ -496,7 +495,7 @@ var definition = {
496
495
  }]
497
496
  })
498
497
  }, {
499
- name: 'withoutResult',
498
+ name: 'withoutResults',
500
499
  type: 'toggle',
501
500
  defaultValue: false,
502
501
  label: defineMessage({
package/lib/index.js CHANGED
@@ -268,23 +268,22 @@ var SurveyScreen = function SurveyScreen(_ref) {
268
268
  React.useEffect(function () {
269
269
  if (answers === null || isPlaceholder) {
270
270
  return;
271
- }
272
-
273
- var maxWidth = answers.reduce(function (currentMaxWidth, answer, answerI) {
274
- var button = buttonsRefs.current[answerI] || null;
275
- var label = labelsRefs.current[answerI] || null;
276
-
277
- if (button !== null && label !== null) {
278
- var borderWidth = button.offsetWidth - button.clientWidth;
279
- var totalWidth = borderWidth + label.getBoundingClientRect().width + 20;
280
- return Math.max(currentMaxWidth, totalWidth);
281
- }
282
-
283
- return currentMaxWidth;
284
- }, 0);
285
- setButtonMaxWidth(Math.min(width * 0.75, Math.max(width * 0.2, maxWidth)));
271
+ } // const maxWidth = answers.reduce((currentMaxWidth, answer, answerI) => {
272
+ // const button = buttonsRefs.current[answerI] || null;
273
+ // const label = labelsRefs.current[answerI] || null;
274
+ // if (button !== null && label !== null) {
275
+ // const borderWidth = button.offsetWidth - button.clientWidth;
276
+ // const totalWidth = borderWidth + label.getBoundingClientRect().width + 20;
277
+ // return Math.max(currentMaxWidth, totalWidth);
278
+ // }
279
+ // return currentMaxWidth;
280
+ // }, 0);
281
+ // setButtonMaxWidth(Math.min(width * 0.75, Math.max(width * 0.2, maxWidth)));
282
+
283
+
284
+ setButtonMaxWidth(withoutResults ? '100%' : width * 0.75);
286
285
  setReady(true);
287
- }, [answers, width, height, setButtonMaxWidth, finalTransitionDuration, isPlaceholder]);
286
+ }, [answers, width, height, setButtonMaxWidth, finalTransitionDuration, isPlaceholder, withoutResults]);
288
287
 
289
288
  var _ref6 = resultsStyle || {},
290
289
  _ref6$barColor = _ref6.barColor,
@@ -358,7 +357,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
358
357
  }, /*#__PURE__*/React__default["default"].createElement("div", {
359
358
  className: styles.itemInner,
360
359
  style: {
361
- width: answered && !withoutResults ? buttonMaxWidth : null,
360
+ width: buttonMaxWidth,
362
361
  transitionDuration: finalTransitionDuration
363
362
  }
364
363
  }, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
@@ -369,7 +368,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
369
368
  refButton: function refButton(el) {
370
369
  buttonsRefs.current[answerIndex] = el;
371
370
  },
372
- disabled: isPreview,
371
+ disabled: isPreview || userAnswerIndex !== null,
373
372
  focusable: current && isView,
374
373
  buttonStyle: !answered ? _objectSpread__default["default"](_objectSpread__default["default"]({}, utils.getStyleFromBox(buttonsStyle)), utils.getStyleFromBox(answerButtonStyle)) : null
375
374
  }, /*#__PURE__*/React__default["default"].createElement("span", {
@@ -381,7 +380,7 @@ var SurveyScreen = function SurveyScreen(_ref) {
381
380
  textStyle: textStyle,
382
381
  inline: true,
383
382
  className: styles.itemText
384
- }))))), /*#__PURE__*/React__default["default"].createElement("div", {
383
+ }))))), !withoutResults ? /*#__PURE__*/React__default["default"].createElement("div", {
385
384
  className: styles.resultContainer,
386
385
  style: {
387
386
  transitionDuration: finalTransitionDuration
@@ -395,12 +394,12 @@ var SurveyScreen = function SurveyScreen(_ref) {
395
394
  }, /*#__PURE__*/React__default["default"].createElement("div", {
396
395
  className: styles.result,
397
396
  style: _objectSpread__default["default"]({
398
- width: !withoutResults ? "".concat(percent, "%") : null
397
+ width: percent !== null ? "".concat(percent, "%") : null
399
398
  }, utils.getStyleFromColor(answered ? answerResultBarColor || resultsBarColor || labelColor : null, 'backgroundColor'))
400
- }, withPercentLabels && !withoutResults ? /*#__PURE__*/React__default["default"].createElement("div", {
399
+ }, withPercentLabels ? /*#__PURE__*/React__default["default"].createElement("div", {
401
400
  className: styles.resultLabel,
402
401
  style: _objectSpread__default["default"]({}, utils.getStyleFromColor(answered ? answerResultTextColor || resultsTextColor || answerResultBarColor || resultsBarColor || labelColor : null, 'color'))
403
- }, "".concat(percent, "%")) : null))))) : null));
402
+ }, "".concat(percent, "%")) : null))) : null)) : null));
404
403
  })) : null)); // Call to Action
405
404
 
406
405
  if (!isPlaceholder && hasCallToAction) {
@@ -517,7 +516,7 @@ var definition = {
517
516
  }]
518
517
  })
519
518
  }, {
520
- name: 'withoutResult',
519
+ name: 'withoutResults',
521
520
  type: 'toggle',
522
521
  defaultValue: false,
523
522
  label: reactIntl.defineMessage({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-survey",
3
- "version": "0.3.79",
3
+ "version": "0.3.84",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -49,17 +49,17 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@babel/runtime": "^7.13.10",
52
- "@micromag/core": "^0.3.78",
53
- "@micromag/data": "^0.3.78",
54
- "@micromag/element-background": "^0.3.78",
55
- "@micromag/element-button": "^0.3.79",
56
- "@micromag/element-call-to-action": "^0.3.79",
57
- "@micromag/element-container": "^0.3.78",
58
- "@micromag/element-heading": "^0.3.78",
59
- "@micromag/element-layout": "^0.3.78",
60
- "@micromag/element-scroll": "^0.3.78",
61
- "@micromag/element-text": "^0.3.78",
62
- "@micromag/transforms": "^0.3.78",
52
+ "@micromag/core": "^0.3.81",
53
+ "@micromag/data": "^0.3.81",
54
+ "@micromag/element-background": "^0.3.81",
55
+ "@micromag/element-button": "^0.3.81",
56
+ "@micromag/element-call-to-action": "^0.3.81",
57
+ "@micromag/element-container": "^0.3.81",
58
+ "@micromag/element-heading": "^0.3.81",
59
+ "@micromag/element-layout": "^0.3.81",
60
+ "@micromag/element-scroll": "^0.3.81",
61
+ "@micromag/element-text": "^0.3.81",
62
+ "@micromag/transforms": "^0.3.81",
63
63
  "classnames": "^2.2.6",
64
64
  "lodash": "^4.17.21",
65
65
  "prop-types": "^15.7.2",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "b25bd1907137fd148b912a5a48c1bc9d2bd0dadd"
72
+ "gitHead": "0368383e7699c0223de5344ec861cc6ff6318393"
73
73
  }