@micromag/screen-contribution 0.4.70 → 0.4.74

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.
Files changed (3) hide show
  1. package/es/index.d.ts +4 -2
  2. package/es/index.js +214 -312
  3. package/package.json +21 -20
package/es/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { HeadingElement, InputElement, TextElement, TextStyle, ButtonElement, BackgroundElement, Header, Footer, Transitions } from '@micromag/core';
2
+ import { ForwardedRef } from 'react';
3
+ import { HeadingElement, InputElement, TextElement, TextStyle, ButtonElement, BackgroundElement, Header, Footer, Transitions, MediaElement } from '@micromag/core';
3
4
 
4
5
  interface ContributionScreenProps {
5
6
  id?: string | null;
@@ -25,9 +26,10 @@ interface ContributionScreenProps {
25
26
  transitionStagger?: number;
26
27
  resizeTransitionDuration?: number;
27
28
  type?: string | null;
29
+ mediaRef?: ForwardedRef<MediaElement> | null;
28
30
  className?: string | null;
29
31
  }
30
- declare function ContributionScreen({ id, layout, title, name, message, submit, nameStyle, messageStyle, settings, spacing, background, header, footer, current, preload, transitions, transitionStagger, resizeTransitionDuration, type, className, }: ContributionScreenProps): react_jsx_runtime.JSX.Element;
32
+ declare function ContributionScreen({ id, layout, title, name, message, submit, nameStyle, messageStyle, settings, spacing, background, header, footer, current, preload, transitions, transitionStagger, resizeTransitionDuration, type, mediaRef: customMediaRef, className, }: ContributionScreenProps): react_jsx_runtime.JSX.Element;
31
33
 
32
34
  declare const _default: {
33
35
  id: string;
package/es/index.js CHANGED
@@ -1,8 +1,4 @@
1
1
  import { useIntl, FormattedMessage, defineMessage } from 'react-intl';
2
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
5
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
2
  import { faRedo } from '@fortawesome/free-solid-svg-icons/faRedo';
7
3
  import { faSpinner } from '@fortawesome/free-solid-svg-icons/faSpinner';
8
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -12,7 +8,7 @@ import { useRef, useState, useCallback, useEffect } from 'react';
12
8
  import { ScreenElement, Transitions } from '@micromag/core/components';
13
9
  import { useScreenSize, useViewerContext, useScreenRenderContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
14
10
  import { useTrackScreenEvent, useDimensionObserver } from '@micromag/core/hooks';
15
- import { isHeaderFilled, isFooterFilled, getFooterProps, isTextFilled, isLabelFilled, getStyleFromColor } from '@micromag/core/utils';
11
+ import { isHeaderFilled, isFooterFilled, getFooterProps, isTextFilled, isLabelFilled, getStyleFromColor, mergeRefs } from '@micromag/core/utils';
16
12
  import { useContributionCreate, useContributions } from '@micromag/data';
17
13
  import Background from '@micromag/element-background';
18
14
  import Button from '@micromag/element-button';
@@ -28,219 +24,183 @@ import { jsx, jsxs } from 'react/jsx-runtime';
28
24
 
29
25
  var styles = {"container":"micromag-screen-contribution-container","background":"micromag-screen-contribution-background","content":"micromag-screen-contribution-content","inner":"micromag-screen-contribution-inner","layout":"micromag-screen-contribution-layout","header":"micromag-screen-contribution-header","emptyTitle":"micromag-screen-contribution-emptyTitle","emptyInputName":"micromag-screen-contribution-emptyInputName","emptyInputMessage":"micromag-screen-contribution-emptyInputMessage","emptySubmit":"micromag-screen-contribution-emptySubmit","emptySkip":"micromag-screen-contribution-emptySkip","title":"micromag-screen-contribution-title","interactiveContainer":"micromag-screen-contribution-interactiveContainer","form":"micromag-screen-contribution-form","inputName":"micromag-screen-contribution-inputName","inputMessage":"micromag-screen-contribution-inputMessage","buttonSubmit":"micromag-screen-contribution-buttonSubmit","buttonSkip":"micromag-screen-contribution-buttonSkip","showBack":"micromag-screen-contribution-showBack","formContent":"micromag-screen-contribution-formContent","formLoading":"micromag-screen-contribution-formLoading","loadingIcon":"micromag-screen-contribution-loadingIcon","contributionsContainer":"micromag-screen-contribution-contributionsContainer","contributionsContent":"micromag-screen-contribution-contributionsContent","contributions":"micromag-screen-contribution-contributions","contribution":"micromag-screen-contribution-contribution","footer":"micromag-screen-contribution-footer","disabled":"micromag-screen-contribution-disabled","submitting":"micromag-screen-contribution-submitting","submitted":"micromag-screen-contribution-submitted","showContributions":"micromag-screen-contribution-showContributions","isPlaceholder":"micromag-screen-contribution-isPlaceholder","reset":"micromag-screen-contribution-reset"};
30
26
 
31
- function ContributionScreen(_ref) {
32
- var _ref$id = _ref.id,
33
- id = _ref$id === void 0 ? null : _ref$id,
34
- _ref$layout = _ref.layout,
35
- layout = _ref$layout === void 0 ? 'middle' : _ref$layout,
36
- _ref$title = _ref.title,
37
- title = _ref$title === void 0 ? null : _ref$title,
38
- _ref$name = _ref.name,
39
- name = _ref$name === void 0 ? null : _ref$name,
40
- _ref$message = _ref.message,
41
- message = _ref$message === void 0 ? null : _ref$message,
42
- _ref$submit = _ref.submit,
43
- submit = _ref$submit === void 0 ? null : _ref$submit,
44
- _ref$nameStyle = _ref.nameStyle,
45
- nameStyle = _ref$nameStyle === void 0 ? null : _ref$nameStyle,
46
- _ref$messageStyle = _ref.messageStyle,
47
- messageStyle = _ref$messageStyle === void 0 ? null : _ref$messageStyle,
48
- _ref$settings = _ref.settings,
49
- settings = _ref$settings === void 0 ? null : _ref$settings,
50
- _ref$spacing = _ref.spacing,
51
- spacing = _ref$spacing === void 0 ? 20 : _ref$spacing,
52
- _ref$background = _ref.background,
53
- background = _ref$background === void 0 ? null : _ref$background,
54
- _ref$header = _ref.header,
55
- header = _ref$header === void 0 ? null : _ref$header,
56
- _ref$footer = _ref.footer,
57
- footer = _ref$footer === void 0 ? null : _ref$footer,
58
- _ref$current = _ref.current,
59
- current = _ref$current === void 0 ? true : _ref$current,
60
- _ref$preload = _ref.preload,
61
- preload = _ref$preload === void 0 ? true : _ref$preload,
62
- _ref$transitions = _ref.transitions,
63
- transitions = _ref$transitions === void 0 ? null : _ref$transitions,
64
- _ref$transitionStagge = _ref.transitionStagger,
65
- transitionStagger = _ref$transitionStagge === void 0 ? 100 : _ref$transitionStagge,
66
- _ref$resizeTransition = _ref.resizeTransitionDuration,
67
- resizeTransitionDuration = _ref$resizeTransition === void 0 ? 750 : _ref$resizeTransition,
68
- _ref$type = _ref.type,
69
- type = _ref$type === void 0 ? null : _ref$type,
70
- _ref$className = _ref.className,
71
- className = _ref$className === void 0 ? null : _ref$className;
72
- var intl = useIntl();
73
- var screenId = id || 'screen-id';
74
- var trackScreenEvent = useTrackScreenEvent(type);
75
- var _useScreenSize = useScreenSize(),
76
- width = _useScreenSize.width,
77
- height = _useScreenSize.height,
78
- resolution = _useScreenSize.resolution;
79
- var _useViewerContext = useViewerContext(),
80
- viewerTopHeight = _useViewerContext.topHeight,
81
- viewerBottomHeight = _useViewerContext.bottomHeight,
82
- viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
83
- var _useScreenRenderConte = useScreenRenderContext(),
84
- isView = _useScreenRenderConte.isView,
85
- isPreview = _useScreenRenderConte.isPreview,
86
- isPlaceholder = _useScreenRenderConte.isPlaceholder,
87
- isEdit = _useScreenRenderConte.isEdit,
88
- isStatic = _useScreenRenderConte.isStatic,
89
- isCapture = _useScreenRenderConte.isCapture;
90
- var _useViewerWebView = useViewerWebView(),
91
- openWebView = _useViewerWebView.open;
92
- var _usePlaybackContext = usePlaybackContext(),
93
- muted = _usePlaybackContext.muted;
94
- var _usePlaybackMediaRef = usePlaybackMediaRef(current, true),
95
- mediaRef = _usePlaybackMediaRef.ref,
96
- _usePlaybackMediaRef$ = _usePlaybackMediaRef.isCurrent,
97
- isCurrentMedia = _usePlaybackMediaRef$ === void 0 ? false : _usePlaybackMediaRef$;
98
- var backgroundPlaying = current && (isView || isEdit) && (isCurrentMedia || !isView);
99
- var mediaShouldLoad = current || preload;
100
- var transitionPlaying = current;
101
- var transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
102
- var scrollingDisabled = !isEdit && transitionDisabled || !current;
103
- var hasHeader = isHeaderFilled(header);
104
- var hasFooter = isFooterFilled(footer);
105
- var footerProps = getFooterProps(footer, {
106
- isView: isView,
107
- current: current,
108
- openWebView: openWebView,
109
- isPreview: isPreview
27
+ function ContributionScreen({
28
+ id = null,
29
+ layout = 'middle',
30
+ title = null,
31
+ name = null,
32
+ message = null,
33
+ submit = null,
34
+ nameStyle = null,
35
+ messageStyle = null,
36
+ settings = null,
37
+ spacing = 20,
38
+ background = null,
39
+ header = null,
40
+ footer = null,
41
+ current = true,
42
+ preload = true,
43
+ transitions = null,
44
+ transitionStagger = 100,
45
+ resizeTransitionDuration = 750,
46
+ type = null,
47
+ mediaRef: customMediaRef = null,
48
+ className = null
49
+ }) {
50
+ const intl = useIntl();
51
+ const screenId = id || 'screen-id';
52
+ const trackScreenEvent = useTrackScreenEvent(type);
53
+ const {
54
+ width,
55
+ height,
56
+ resolution
57
+ } = useScreenSize();
58
+ const {
59
+ topHeight: viewerTopHeight,
60
+ bottomHeight: viewerBottomHeight,
61
+ bottomSidesWidth: viewerBottomSidesWidth
62
+ } = useViewerContext();
63
+ const {
64
+ isView,
65
+ isPreview,
66
+ isPlaceholder,
67
+ isEdit,
68
+ isStatic,
69
+ isCapture
70
+ } = useScreenRenderContext();
71
+ const {
72
+ open: openWebView
73
+ } = useViewerWebView();
74
+ const {
75
+ muted
76
+ } = usePlaybackContext();
77
+ const {
78
+ ref: mediaRef,
79
+ isCurrent: isCurrentMedia = false
80
+ } = usePlaybackMediaRef(current, true);
81
+ const backgroundPlaying = current && (isView || isEdit) && (isCurrentMedia || !isView);
82
+ const mediaShouldLoad = current || preload;
83
+ const transitionPlaying = current;
84
+ const transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
85
+ const scrollingDisabled = !isEdit && transitionDisabled || !current;
86
+ const hasHeader = isHeaderFilled(header);
87
+ const hasFooter = isFooterFilled(footer);
88
+ const footerProps = getFooterProps(footer, {
89
+ isView,
90
+ current,
91
+ openWebView,
92
+ isPreview
110
93
  });
111
- var hasTitle = isTextFilled(title);
112
- var hasNameLabel = isLabelFilled(name);
113
- var hasMessageLabel = isLabelFilled(message);
114
- var hasSubmit = isTextFilled(submit);
115
- var contributionsRef = useRef(null);
116
- var formRef = useRef(null);
117
- var _useState = useState(null),
118
- _useState2 = _slicedToArray(_useState, 2),
119
- interactiveContainerHeight = _useState2[0],
120
- setInteractiveContainerHeight = _useState2[1];
121
- var _useState3 = useState(''),
122
- _useState4 = _slicedToArray(_useState3, 2),
123
- userName = _useState4[0],
124
- setUserName = _useState4[1];
125
- var _useState5 = useState(''),
126
- _useState6 = _slicedToArray(_useState5, 2),
127
- userMessage = _useState6[0],
128
- setUserMessage = _useState6[1];
94
+ const hasTitle = isTextFilled(title);
95
+ const hasNameLabel = isLabelFilled(name);
96
+ const hasMessageLabel = isLabelFilled(message);
97
+ const hasSubmit = isTextFilled(submit);
98
+ const contributionsRef = useRef(null);
99
+ const formRef = useRef(null);
100
+ const [interactiveContainerHeight, setInteractiveContainerHeight] = useState(null);
101
+ const [userName, setUserName] = useState('');
102
+ const [userMessage, setUserMessage] = useState('');
129
103
 
130
104
  // 0 = default, 1 = submitting, 2 = submitted, 3 = resizing, 4 = done
131
- var _useState7 = useState(isStatic || isCapture ? 4 : 0),
132
- _useState8 = _slicedToArray(_useState7, 2),
133
- submitState = _useState8[0],
134
- setSubmitState = _useState8[1];
135
- var _useState9 = useState(false),
136
- _useState0 = _slicedToArray(_useState9, 2),
137
- hasSubmitted = _useState0[0],
138
- setHasSubmitted = _useState0[1];
139
- var _ref2 = settings || {},
140
- _ref2$canViewAnswers = _ref2.canViewAnswers,
141
- canViewAnswers = _ref2$canViewAnswers === void 0 ? false : _ref2$canViewAnswers,
142
- _ref2$skipButton = _ref2.skipButton,
143
- skipButton = _ref2$skipButton === void 0 ? null : _ref2$skipButton,
144
- _ref2$backButton = _ref2.backButton,
145
- backButton = _ref2$backButton === void 0 ? null : _ref2$backButton;
146
- var answersButton = submitState === 4 ? backButton : skipButton;
147
- var finalAnswersButton = isTextFilled(answersButton) ? answersButton : _objectSpread(_objectSpread({}, answersButton), {}, {
105
+ const [submitState, setSubmitState] = useState(isStatic || isCapture ? 4 : 0);
106
+ const [hasSubmitted, setHasSubmitted] = useState(false);
107
+ const {
108
+ canViewAnswers = false,
109
+ skipButton = null,
110
+ backButton = null
111
+ } = settings || {};
112
+ const answersButton = submitState === 4 ? backButton : skipButton;
113
+ const finalAnswersButton = isTextFilled(answersButton) ? answersButton : {
114
+ ...answersButton,
148
115
  body: submitState === 4 ? intl.formatMessage({
149
116
  id: "8NyYTH",
150
- defaultMessage: [{
151
- "type": 0,
152
- "value": "Back"
153
- }]
117
+ defaultMessage: "Back"
154
118
  }) : intl.formatMessage({
155
119
  id: "HpkW4J",
156
- defaultMessage: [{
157
- "type": 0,
158
- "value": "Skip"
159
- }]
120
+ defaultMessage: "Skip"
160
121
  })
161
- });
162
- var onContributionSubmitted = useCallback(function () {
122
+ };
123
+ const onContributionSubmitted = useCallback(() => {
163
124
  setSubmitState(2);
164
- trackScreenEvent('submit_success', "".concat(userName, ": ").concat(userMessage));
125
+ trackScreenEvent('submit_success', `${userName}: ${userMessage}`);
165
126
  setHasSubmitted(true);
166
127
  }, [setSubmitState, setHasSubmitted, trackScreenEvent, userName, userMessage]);
167
- var _useContributionCreat = useContributionCreate({
168
- screenId: screenId
169
- }),
170
- submitContribution = _useContributionCreat.create;
171
- var _useContributions = useContributions({
172
- screenId: screenId,
173
- opts: {
174
- autoload: !isPlaceholder
175
- }
176
- }),
177
- contributions = _useContributions.contributions;
178
- var onNameChange = useCallback(function (e) {
179
- var value = DOMPurify.sanitize(e.currentTarget.value || '');
128
+ const {
129
+ create: submitContribution
130
+ } = useContributionCreate({
131
+ screenId
132
+ });
133
+ const {
134
+ contributions
135
+ } = useContributions({
136
+ screenId,
137
+ opts: {
138
+ autoload: !isPlaceholder
139
+ }
140
+ });
141
+ const onNameChange = useCallback(e => {
142
+ const value = DOMPurify.sanitize(e.currentTarget.value || '');
180
143
  setUserName(value);
181
144
  }, [setUserName]);
182
- var onMessageChange = useCallback(function (e) {
183
- var value = DOMPurify.sanitize(e.currentTarget.value || '');
184
- setUserMessage(value);
145
+ const onMessageChange = useCallback(e_0 => {
146
+ const value_0 = DOMPurify.sanitize(e_0.currentTarget.value || '');
147
+ setUserMessage(value_0);
185
148
  }, [setUserMessage]);
186
- var onContributionReset = useCallback(function () {
149
+ const onContributionReset = useCallback(() => {
187
150
  setUserName('');
188
151
  setUserMessage('');
189
152
  setSubmitState(0);
190
153
  setHasSubmitted(false);
191
154
  }, [setUserName, setUserMessage, setSubmitState, setHasSubmitted]);
192
- var nameFilled = useRef(false);
193
- var onNameBlur = useCallback(function (e) {
194
- if (!nameFilled.current && e.currentTarget.value.length > 0) {
155
+ const nameFilled = useRef(false);
156
+ const onNameBlur = useCallback(e_1 => {
157
+ if (!nameFilled.current && e_1.currentTarget.value.length > 0) {
195
158
  nameFilled.current = true;
196
159
  trackScreenEvent('input_filled', 'Name', {
197
- userName: e.currentTarget.value,
198
- userMessage: userMessage
160
+ userName: e_1.currentTarget.value,
161
+ userMessage
199
162
  });
200
163
  }
201
164
  }, [trackScreenEvent, userMessage]);
202
- var messageFilled = useRef(false);
203
- var onMessageBlur = useCallback(function (e) {
204
- if (!messageFilled.current && e.currentTarget.value.length > 0) {
165
+ const messageFilled = useRef(false);
166
+ const onMessageBlur = useCallback(e_2 => {
167
+ if (!messageFilled.current && e_2.currentTarget.value.length > 0) {
205
168
  messageFilled.current = true;
206
169
  trackScreenEvent('input_filled', 'Message', {
207
- userName: userName,
208
- userMessage: e.currentTarget.value
170
+ userName,
171
+ userMessage: e_2.currentTarget.value
209
172
  });
210
173
  }
211
174
  }, [trackScreenEvent, userName]);
212
175
 
213
176
  // Call to Action
214
- var _useState1 = useState(false),
215
- _useState10 = _slicedToArray(_useState1, 2),
216
- scrolledBottom = _useState10[0],
217
- setScrolledBottom = _useState10[1];
218
- var swipeUpLinkActive = scrolledBottom && submitState === 4;
219
- var _useDimensionObserver = useDimensionObserver(),
220
- footerRef = _useDimensionObserver.ref,
221
- _useDimensionObserver2 = _useDimensionObserver.height,
222
- callToActionHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
223
- var onScrolledBottom = useCallback(function (_ref3) {
224
- var initial = _ref3.initial;
177
+ const [scrolledBottom, setScrolledBottom] = useState(false);
178
+ const swipeUpLinkActive = scrolledBottom && submitState === 4;
179
+ const {
180
+ ref: footerRef,
181
+ height: callToActionHeight = 0
182
+ } = useDimensionObserver();
183
+ const onScrolledBottom = useCallback(({
184
+ initial
185
+ }) => {
225
186
  if (initial) {
226
187
  trackScreenEvent('scroll', 'Contributions list');
227
188
  }
228
189
  setScrolledBottom(true);
229
190
  }, [trackScreenEvent, setScrolledBottom]);
230
- var onScrolledNotBottom = useCallback(function () {
191
+ const onScrolledNotBottom = useCallback(() => {
231
192
  setScrolledBottom(false);
232
193
  }, [setScrolledBottom]);
233
- var onScrolledTrigger = useCallback(function () {
234
- var trigger = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
194
+ const onScrolledTrigger = useCallback((trigger = null) => {
235
195
  if (trigger !== null) {
236
- var scrollPercent = Math.round(trigger * 100);
196
+ const scrollPercent = Math.round(trigger * 100);
237
197
  trackScreenEvent('scroll', scrollPercent, {
238
- scrollPercent: scrollPercent
198
+ scrollPercent
239
199
  });
240
200
  }
241
201
  }, [trackScreenEvent]);
242
- var onSubmit = useCallback(function (e) {
243
- e.preventDefault();
202
+ const onSubmit = useCallback(e_3 => {
203
+ e_3.preventDefault();
244
204
  if (submitState === 0) {
245
205
  setInteractiveContainerHeight(formRef.current.offsetHeight);
246
206
  setSubmitState(1);
@@ -249,13 +209,13 @@ function ContributionScreen(_ref) {
249
209
  message: userMessage
250
210
  });
251
211
  onContributionSubmitted();
252
- trackScreenEvent('click_submit', "".concat(userName, ": ").concat(userMessage), {
253
- userName: userName,
254
- userMessage: userMessage
212
+ trackScreenEvent('click_submit', `${userName}: ${userMessage}`, {
213
+ userName,
214
+ userMessage
255
215
  });
256
216
  }
257
217
  }, [submitState, setSubmitState, userName, userMessage, trackScreenEvent, onContributionSubmitted]);
258
- var onClickSkip = useCallback(function () {
218
+ const onClickSkip = useCallback(() => {
259
219
  if (submitState === 4) {
260
220
  setSubmitState(0);
261
221
  trackScreenEvent('click_skip', 'Skip button');
@@ -264,14 +224,14 @@ function ContributionScreen(_ref) {
264
224
  trackScreenEvent('click_back', 'Back button');
265
225
  }
266
226
  }, [submitState, setSubmitState, trackScreenEvent]);
267
- useEffect(function () {
268
- var timeout = null;
227
+ useEffect(() => {
228
+ let timeout = null;
269
229
  if (submitState === 2) {
270
230
  timeout = setTimeout(setSubmitState, resizeTransitionDuration, 4);
271
231
  setInteractiveContainerHeight(contributionsRef.current.offsetHeight);
272
232
  setSubmitState(3);
273
233
  }
274
- return function () {
234
+ return () => {
275
235
  if (submitState === 3 && timeout !== null) {
276
236
  clearTimeout(timeout);
277
237
  }
@@ -280,28 +240,26 @@ function ContributionScreen(_ref) {
280
240
 
281
241
  // Title
282
242
 
283
- var items = [/*#__PURE__*/jsx(ScreenElement, {
243
+ const items = [/*#__PURE__*/jsx(ScreenElement, {
284
244
  placeholder: "title",
285
245
  placeholderProps: {
286
246
  height: '0.75em'
287
247
  },
288
248
  emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
289
249
  id: "2ZOPe+",
290
- defaultMessage: [{
291
- "type": 0,
292
- "value": "Title"
293
- }]
250
+ defaultMessage: "Title"
294
251
  }),
295
252
  emptyClassName: styles.emptyTitle,
296
253
  isEmpty: !hasTitle,
297
- children: hasTitle ? /*#__PURE__*/jsx(Heading, _objectSpread(_objectSpread({}, title), {}, {
254
+ children: hasTitle ? /*#__PURE__*/jsx(Heading, {
255
+ ...title,
298
256
  className: styles.title
299
- })) : null
257
+ }) : null
300
258
  }, "title")];
301
- var allContributions = [].concat(_toConsumableArray(userName !== null && userName !== '' && userMessage !== null && userMessage !== '' ? [{
259
+ const allContributions = [...(userName !== null && userName !== '' && userMessage !== null && userMessage !== '' ? [{
302
260
  name: userName,
303
261
  message: userMessage
304
- }] : []), _toConsumableArray(contributions || []));
262
+ }] : []), ...(contributions || [])];
305
263
 
306
264
  // Form
307
265
 
@@ -309,7 +267,7 @@ function ContributionScreen(_ref) {
309
267
  className: styles.interactiveContainer,
310
268
  style: {
311
269
  height: submitState < 4 ? interactiveContainerHeight : null,
312
- transitionDuration: "".concat(resizeTransitionDuration, "ms")
270
+ transitionDuration: `${resizeTransitionDuration}ms`
313
271
  },
314
272
  children: [/*#__PURE__*/jsxs("form", {
315
273
  className: styles.form,
@@ -324,10 +282,7 @@ function ContributionScreen(_ref) {
324
282
  },
325
283
  emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
326
284
  id: "G/ITGY",
327
- defaultMessage: [{
328
- "type": 0,
329
- "value": "Your name"
330
- }]
285
+ defaultMessage: "Your name"
331
286
  }),
332
287
  emptyClassName: styles.emptyInputName,
333
288
  isEmpty: !hasNameLabel,
@@ -336,20 +291,16 @@ function ContributionScreen(_ref) {
336
291
  playing: transitionPlaying,
337
292
  delay: transitionStagger,
338
293
  disabled: transitionDisabled,
339
- children: /*#__PURE__*/jsx(TextInput, _objectSpread(_objectSpread({
340
- className: styles.inputName
341
- }, name), {}, {
294
+ children: /*#__PURE__*/jsx(TextInput, {
295
+ className: styles.inputName,
296
+ ...name,
342
297
  value: userName,
343
- onChange: function onChange(e) {
344
- return onNameChange(e);
345
- },
346
- onBlur: function onBlur(e) {
347
- return onNameBlur(e);
348
- },
298
+ onChange: e_4 => onNameChange(e_4),
299
+ onBlur: e_5 => onNameBlur(e_5),
349
300
  focusable: current && isView,
350
301
  disabled: isPreview,
351
302
  required: true
352
- }))
303
+ })
353
304
  })
354
305
  }), /*#__PURE__*/jsx(ScreenElement, {
355
306
  placeholder: "inputText",
@@ -358,10 +309,7 @@ function ContributionScreen(_ref) {
358
309
  },
359
310
  emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
360
311
  id: "JAguka",
361
- defaultMessage: [{
362
- "type": 0,
363
- "value": "Your message"
364
- }]
312
+ defaultMessage: "Your message"
365
313
  }),
366
314
  emptyClassName: styles.emptyInputMessage,
367
315
  isEmpty: !hasMessageLabel,
@@ -370,30 +318,23 @@ function ContributionScreen(_ref) {
370
318
  playing: transitionPlaying,
371
319
  delay: transitionStagger * 2,
372
320
  disabled: transitionDisabled,
373
- children: /*#__PURE__*/jsx(TextInput, _objectSpread(_objectSpread({
374
- className: styles.inputMessage
375
- }, message), {}, {
321
+ children: /*#__PURE__*/jsx(TextInput, {
322
+ className: styles.inputMessage,
323
+ ...message,
376
324
  value: userMessage,
377
- onChange: function onChange(e) {
378
- return onMessageChange(e);
379
- },
380
- onBlur: function onBlur(e) {
381
- return onMessageBlur(e);
382
- },
325
+ onChange: e_6 => onMessageChange(e_6),
326
+ onBlur: e_7 => onMessageBlur(e_7),
383
327
  disabled: isPreview,
384
328
  focusable: current && isView,
385
329
  multiline: true,
386
330
  required: true
387
- }))
331
+ })
388
332
  })
389
333
  }), /*#__PURE__*/jsx(ScreenElement, {
390
334
  placeholder: "button",
391
335
  emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
392
336
  id: "5uH4x7",
393
- defaultMessage: [{
394
- "type": 0,
395
- "value": "Submit"
396
- }]
337
+ defaultMessage: "Submit"
397
338
  }),
398
339
  emptyClassName: styles.emptySubmit,
399
340
  isEmpty: !hasSubmit,
@@ -408,9 +349,10 @@ function ContributionScreen(_ref) {
408
349
  disabled: isPreview,
409
350
  buttonStyle: submit !== null ? submit.buttonStyle : null,
410
351
  focusable: current && isView,
411
- children: /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({}, submit), {}, {
352
+ children: /*#__PURE__*/jsx(Text, {
353
+ ...submit,
412
354
  inline: true
413
- }))
355
+ })
414
356
  })
415
357
  })
416
358
  })]
@@ -425,16 +367,10 @@ function ContributionScreen(_ref) {
425
367
  placeholder: "button",
426
368
  emptyLabel: submitState !== 4 ? /*#__PURE__*/jsx(FormattedMessage, {
427
369
  id: "U2RZp5",
428
- defaultMessage: [{
429
- "type": 0,
430
- "value": "Skip"
431
- }]
370
+ defaultMessage: "Skip"
432
371
  }) : /*#__PURE__*/jsx(FormattedMessage, {
433
372
  id: "AzN1aW",
434
- defaultMessage: [{
435
- "type": 0,
436
- "value": "Back"
437
- }]
373
+ defaultMessage: "Back"
438
374
  }),
439
375
  emptyClassName: styles.emptySkip,
440
376
  children: /*#__PURE__*/jsx(Transitions, {
@@ -444,14 +380,17 @@ function ContributionScreen(_ref) {
444
380
  disabled: transitionDisabled,
445
381
  children: /*#__PURE__*/jsx(Button, {
446
382
  type: "button",
447
- className: classNames([styles.buttonSkip, _defineProperty({}, styles.showBack, submitState === 4)]),
383
+ className: classNames([styles.buttonSkip, {
384
+ [styles.showBack]: submitState === 4
385
+ }]),
448
386
  disabled: isPreview,
449
387
  onClick: onClickSkip,
450
388
  buttonStyle: finalAnswersButton !== null ? finalAnswersButton.buttonStyle : null,
451
389
  focusable: current && isView,
452
- children: /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({}, finalAnswersButton), {}, {
390
+ children: /*#__PURE__*/jsx(Text, {
391
+ ...finalAnswersButton,
453
392
  inline: true
454
- }))
393
+ })
455
394
  })
456
395
  })
457
396
  }) : null, /*#__PURE__*/jsx("div", {
@@ -462,9 +401,9 @@ function ContributionScreen(_ref) {
462
401
  children: /*#__PURE__*/jsx("div", {
463
402
  className: styles.contributions,
464
403
  ref: contributionsRef,
465
- children: allContributions.map(function (contribution, contributionIndex) {
466
- var nameInnerStyle = nameStyle !== null ? nameStyle.style || null : null;
467
- var messageInnerStyle = messageStyle !== null ? messageStyle.style || null : null;
404
+ children: allContributions.map((contribution, contributionIndex) => {
405
+ const nameInnerStyle = nameStyle !== null ? nameStyle.style || null : null;
406
+ const messageInnerStyle = messageStyle !== null ? messageStyle.style || null : null;
468
407
  return /*#__PURE__*/jsxs("div", {
469
408
  className: styles.contribution,
470
409
  style: nameInnerStyle !== null ? getStyleFromColor(nameInnerStyle.color, 'borderColor') : null,
@@ -478,7 +417,7 @@ function ContributionScreen(_ref) {
478
417
  body: contribution.message,
479
418
  textStyle: messageInnerStyle
480
419
  })]
481
- }, "contribution-".concat(contributionIndex));
420
+ }, `contribution-${contributionIndex}`);
482
421
  })
483
422
  })
484
423
  })
@@ -488,16 +427,23 @@ function ContributionScreen(_ref) {
488
427
  }
489
428
  }) : null]
490
429
  }, "form"));
491
- var headerElement = !isPlaceholder && hasHeader ? /*#__PURE__*/jsx("div", {
430
+ const headerElement = !isPlaceholder && hasHeader ? /*#__PURE__*/jsx("div", {
492
431
  className: styles.header,
493
432
  style: {
494
433
  paddingBottom: spacing
495
434
  },
496
- children: /*#__PURE__*/jsx(Header, _objectSpread({}, header))
435
+ children: /*#__PURE__*/jsx(Header, {
436
+ ...header
437
+ })
497
438
  }) : null;
498
- var showReset = isEdit && submitState === 4;
439
+ const showReset = isEdit && submitState === 4;
499
440
  return /*#__PURE__*/jsxs("div", {
500
- className: classNames([styles.container, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.isPlaceholder, isPlaceholder), styles.submitting, submitState === 1), styles.submitted, submitState > 1), styles.showContributions, submitState === 4)]),
441
+ className: classNames([styles.container, className, {
442
+ [styles.isPlaceholder]: isPlaceholder,
443
+ [styles.submitting]: submitState === 1,
444
+ [styles.submitted]: submitState > 1,
445
+ [styles.showContributions]: submitState === 4
446
+ }]),
501
447
  "data-screen-ready": true,
502
448
  children: [/*#__PURE__*/jsxs(Container, {
503
449
  width: width,
@@ -532,14 +478,18 @@ function ContributionScreen(_ref) {
532
478
  })
533
479
  }), !isPlaceholder && hasFooter ? /*#__PURE__*/jsx("div", {
534
480
  ref: footerRef,
535
- className: classNames([styles.footer, _defineProperty({}, styles.disabled, !swipeUpLinkActive)]),
481
+ className: classNames([styles.footer, {
482
+ [styles.disabled]: !swipeUpLinkActive
483
+ }]),
536
484
  style: {
537
485
  paddingLeft: Math.max(viewerBottomSidesWidth, spacing / 2),
538
486
  paddingRight: Math.max(viewerBottomSidesWidth, spacing / 2),
539
487
  paddingTop: 0,
540
488
  paddingBottom: (!isPreview ? viewerBottomHeight : 0) + spacing / 2
541
489
  },
542
- children: /*#__PURE__*/jsx(Footer, _objectSpread({}, footerProps))
490
+ children: /*#__PURE__*/jsx(Footer, {
491
+ ...footerProps
492
+ })
543
493
  }) : null]
544
494
  })]
545
495
  }), !isPlaceholder ? /*#__PURE__*/jsx(Background, {
@@ -550,7 +500,7 @@ function ContributionScreen(_ref) {
550
500
  playing: backgroundPlaying,
551
501
  muted: muted,
552
502
  shouldLoad: mediaShouldLoad,
553
- mediaRef: mediaRef,
503
+ mediaRef: mergeRefs(mediaRef, customMediaRef),
554
504
  withoutVideo: isPreview,
555
505
  className: styles.background
556
506
  }) : null]
@@ -563,19 +513,13 @@ var definition = {
563
513
  group: {
564
514
  label: defineMessage({
565
515
  id: "ZiWlL6",
566
- defaultMessage: [{
567
- "type": 0,
568
- "value": "Questions"
569
- }]
516
+ defaultMessage: "Questions"
570
517
  }),
571
518
  order: 7
572
519
  },
573
520
  title: defineMessage({
574
521
  id: "g6b9Lg",
575
- defaultMessage: [{
576
- "type": 0,
577
- "value": "Contribution"
578
- }]
522
+ defaultMessage: "Contribution"
579
523
  }),
580
524
  component: ContributionScreen,
581
525
  layouts: ['top', 'middle', 'bottom'],
@@ -585,10 +529,7 @@ var definition = {
585
529
  defaultValue: 'top',
586
530
  label: defineMessage({
587
531
  id: "4iBXj2",
588
- defaultMessage: [{
589
- "type": 0,
590
- "value": "Layout"
591
- }]
532
+ defaultMessage: "Layout"
592
533
  })
593
534
  }, {
594
535
  name: 'title',
@@ -598,10 +539,7 @@ var definition = {
598
539
  },
599
540
  label: defineMessage({
600
541
  id: "N25iDO",
601
- defaultMessage: [{
602
- "type": 0,
603
- "value": "Title"
604
- }]
542
+ defaultMessage: "Title"
605
543
  })
606
544
  }, {
607
545
  name: 'name',
@@ -611,10 +549,7 @@ var definition = {
611
549
  },
612
550
  label: defineMessage({
613
551
  id: "nXVNeg",
614
- defaultMessage: [{
615
- "type": 0,
616
- "value": "Name"
617
- }]
552
+ defaultMessage: "Name"
618
553
  })
619
554
  }, {
620
555
  name: 'message',
@@ -624,10 +559,7 @@ var definition = {
624
559
  },
625
560
  label: defineMessage({
626
561
  id: "RcLsua",
627
- defaultMessage: [{
628
- "type": 0,
629
- "value": "Message"
630
- }]
562
+ defaultMessage: "Message"
631
563
  })
632
564
  }, {
633
565
  name: 'submit',
@@ -637,10 +569,7 @@ var definition = {
637
569
  },
638
570
  label: defineMessage({
639
571
  id: "uAKPQ9",
640
- defaultMessage: [{
641
- "type": 0,
642
- "value": "Submit"
643
- }]
572
+ defaultMessage: "Submit"
644
573
  })
645
574
  }, {
646
575
  name: 'nameStyle',
@@ -652,10 +581,7 @@ var definition = {
652
581
  },
653
582
  label: defineMessage({
654
583
  id: "SyMSDa",
655
- defaultMessage: [{
656
- "type": 0,
657
- "value": "Published name style"
658
- }]
584
+ defaultMessage: "Published name style"
659
585
  })
660
586
  }, {
661
587
  name: 'messageStyle',
@@ -667,10 +593,7 @@ var definition = {
667
593
  },
668
594
  label: defineMessage({
669
595
  id: "+SlKOi",
670
- defaultMessage: [{
671
- "type": 0,
672
- "value": "Published message style"
673
- }]
596
+ defaultMessage: "Published message style"
674
597
  })
675
598
  }, {
676
599
  name: 'settings',
@@ -679,10 +602,7 @@ var definition = {
679
602
  isList: true,
680
603
  label: defineMessage({
681
604
  id: "9omJnT",
682
- defaultMessage: [{
683
- "type": 0,
684
- "value": "Answer settings"
685
- }]
605
+ defaultMessage: "Answer settings"
686
606
  }),
687
607
  fields: [{
688
608
  name: 'canViewAnswers',
@@ -690,10 +610,7 @@ var definition = {
690
610
  isHorizontal: true,
691
611
  label: defineMessage({
692
612
  id: "xcHW4o",
693
- defaultMessage: [{
694
- "type": 0,
695
- "value": "Can view answers"
696
- }]
613
+ defaultMessage: "Can view answers"
697
614
  })
698
615
  }, {
699
616
  name: 'skipButton',
@@ -703,10 +620,7 @@ var definition = {
703
620
  },
704
621
  label: defineMessage({
705
622
  id: "CpCykm",
706
- defaultMessage: [{
707
- "type": 0,
708
- "value": "Skip button"
709
- }]
623
+ defaultMessage: "Skip button"
710
624
  })
711
625
  }, {
712
626
  name: 'backButton',
@@ -716,10 +630,7 @@ var definition = {
716
630
  },
717
631
  label: defineMessage({
718
632
  id: "KIXg9M",
719
- defaultMessage: [{
720
- "type": 0,
721
- "value": "Back button"
722
- }]
633
+ defaultMessage: "Back button"
723
634
  })
724
635
  }]
725
636
  }, {
@@ -727,20 +638,14 @@ var definition = {
727
638
  type: 'background',
728
639
  label: defineMessage({
729
640
  id: "+MPZRu",
730
- defaultMessage: [{
731
- "type": 0,
732
- "value": "Background"
733
- }]
641
+ defaultMessage: "Background"
734
642
  })
735
643
  }, {
736
644
  name: 'header',
737
645
  type: 'header',
738
646
  label: defineMessage({
739
647
  id: "rhuDxI",
740
- defaultMessage: [{
741
- "type": 0,
742
- "value": "Header"
743
- }]
648
+ defaultMessage: "Header"
744
649
  }),
745
650
  theme: {
746
651
  badge: {
@@ -755,10 +660,7 @@ var definition = {
755
660
  type: 'footer',
756
661
  label: defineMessage({
757
662
  id: "g4nybp",
758
- defaultMessage: [{
759
- "type": 0,
760
- "value": "Footer"
761
- }]
663
+ defaultMessage: "Footer"
762
664
  }),
763
665
  theme: {
764
666
  callToAction: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-contribution",
3
- "version": "0.4.70",
3
+ "version": "0.4.74",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -36,6 +36,7 @@
36
36
  "exports": {
37
37
  ".": {
38
38
  "types": "./es/index.d.ts",
39
+ "style": "./assets/css/styles.css",
39
40
  "import": "./es/index.js"
40
41
  },
41
42
  "./assets/css/styles": "./assets/css/styles.css",
@@ -52,32 +53,32 @@
52
53
  "build": "../../scripts/prepare-package.sh --types"
53
54
  },
54
55
  "devDependencies": {
55
- "react": "^18.3.0 || ^19.0.0",
56
- "react-dom": "^18.3.0 || ^19.0.0"
56
+ "react": "^19.0.0",
57
+ "react-dom": "^19.0.0"
57
58
  },
58
59
  "peerDependencies": {
59
- "react": "^18.3.0 || ^19.0.0",
60
- "react-dom": "^18.3.0 || ^19.0.0"
60
+ "react": "^19.0.0",
61
+ "react-dom": "^19.0.0"
61
62
  },
62
63
  "dependencies": {
63
64
  "@babel/runtime": "^7.28.6",
64
65
  "@fortawesome/fontawesome-svg-core": "^7.2.0",
65
66
  "@fortawesome/free-solid-svg-icons": "^7.2.0",
66
67
  "@fortawesome/react-fontawesome": "^3.2.0",
67
- "@micromag/core": "^0.4.69",
68
- "@micromag/data": "^0.4.69",
69
- "@micromag/element-background": "^0.4.70",
70
- "@micromag/element-button": "^0.4.70",
71
- "@micromag/element-container": "^0.4.69",
72
- "@micromag/element-footer": "^0.4.70",
73
- "@micromag/element-header": "^0.4.69",
74
- "@micromag/element-heading": "^0.4.69",
75
- "@micromag/element-layout": "^0.4.69",
76
- "@micromag/element-scroll": "^0.4.69",
77
- "@micromag/element-share-incentive": "^0.4.69",
78
- "@micromag/element-text": "^0.4.69",
79
- "@micromag/element-text-input": "^0.4.69",
80
- "@micromag/transforms": "^0.4.69",
68
+ "@micromag/core": "^0.4.74",
69
+ "@micromag/data": "^0.4.74",
70
+ "@micromag/element-background": "^0.4.74",
71
+ "@micromag/element-button": "^0.4.74",
72
+ "@micromag/element-container": "^0.4.74",
73
+ "@micromag/element-footer": "^0.4.74",
74
+ "@micromag/element-header": "^0.4.74",
75
+ "@micromag/element-heading": "^0.4.74",
76
+ "@micromag/element-layout": "^0.4.74",
77
+ "@micromag/element-scroll": "^0.4.74",
78
+ "@micromag/element-share-incentive": "^0.4.74",
79
+ "@micromag/element-text": "^0.4.74",
80
+ "@micromag/element-text-input": "^0.4.74",
81
+ "@micromag/transforms": "^0.4.74",
81
82
  "classnames": "^2.2.6",
82
83
  "dompurify": "^3.2.6",
83
84
  "lodash": "^4.17.23",
@@ -88,6 +89,6 @@
88
89
  "access": "public",
89
90
  "registry": "https://registry.npmjs.org/"
90
91
  },
91
- "gitHead": "4f76a8f1ad594be2aadb4a593da5455da8afc8b6",
92
+ "gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
92
93
  "types": "es/index.d.ts"
93
94
  }