@micromag/screen-game-sort 0.3.714

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.
@@ -0,0 +1 @@
1
+ .micromag-screen-game-sort-layout{scrollbar-width:none}.micromag-screen-game-sort-layout::-webkit-scrollbar{display:none}.micromag-screen-game-sort-button.micromag-screen-game-sort-layoutLabelOver .micromag-screen-game-sort-buttonLabel,.micromag-screen-game-sort-container .micromag-screen-game-sort-background{height:100%;left:0;position:absolute;top:0;width:100%}.micromag-screen-game-sort-container{height:100%;overflow:hidden;position:relative;width:100%}.micromag-screen-game-sort-disabled.micromag-screen-game-sort-container{overflow:hidden;pointer-events:none}.micromag-screen-game-sort-hidden.micromag-screen-game-sort-container{display:none;visibility:hidden}.micromag-screen-game-sort-placeholder.micromag-screen-game-sort-container .micromag-screen-game-sort-content{padding:6px;position:relative}.micromag-screen-game-sort-emptyHeading,.micromag-screen-game-sort-emptyItems{border:2px dashed #343434;color:#343434;margin:5px auto}.micromag-screen-game-sort-container .micromag-screen-game-sort-background{z-index:0}.micromag-screen-game-sort-container .micromag-screen-game-sort-content{z-index:1}.micromag-screen-game-sort-container .micromag-screen-game-sort-heading{margin-bottom:10px}.micromag-screen-game-sort-layout{overflow-x:hidden;overflow-y:auto;padding:10px}.micromag-screen-game-sort-emptyHeading,.micromag-screen-game-sort-emptyItems{margin:10px auto;padding:10px;width:100%}.micromag-screen-game-sort-emptyItems{padding:40px}.micromag-screen-game-sort-header{left:0;margin-top:0;position:absolute;top:0;width:100%;z-index:1}.micromag-screen-game-sort-footer{bottom:0;left:0;margin-top:0;position:absolute;width:100%}.micromag-screen-game-sort-items{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.micromag-screen-game-sort-item{border-radius:0;display:block;opacity:0;padding-bottom:10px;-ms-touch-action:none;touch-action:none;-webkit-transform-origin:50% 50%;-ms-transform-origin:50% 50%;transform-origin:50% 50%;width:100%}.micromag-screen-game-sort-sorted .micromag-screen-game-sort-item{opacity:1}.micromag-screen-game-sort-button{background-clip:padding-box;background-color:hsla(0,0%,100%,.1);display:block;padding:10px;text-align:center;width:100%}.micromag-screen-game-sort-isEmpty .micromag-screen-game-sort-button{min-height:2em}.micromag-screen-game-sort-valid .micromag-screen-game-sort-button{background:rgba(0,255,0,.4)}.micromag-screen-game-sort-invalid .micromag-screen-game-sort-button{background:rgba(255,0,0,.4)}.micromag-screen-game-sort-button.micromag-screen-game-sort-layoutLabelTop{display:-ms-flexbox;display:flex;-ms-flex-direction:column-reverse;flex-direction:column-reverse}.micromag-screen-game-sort-button.micromag-screen-game-sort-layoutNoLabel .micromag-screen-game-sort-buttonLabel{display:none}.micromag-screen-game-sort-button.micromag-screen-game-sort-layoutLabelOver .micromag-screen-game-sort-buttonVisual{position:relative;z-index:1}.micromag-screen-game-sort-button.micromag-screen-game-sort-layoutLabelOver .micromag-screen-game-sort-buttonLabel{background-image:-webkit-gradient(linear,left top,left bottom,from(rgba(28,28,28,0)),to(rgba(28,28,28,.75)));background-image:linear-gradient(180deg,rgba(28,28,28,0),rgba(28,28,28,.75));bottom:0;display:block;height:auto;top:auto;z-index:2}.micromag-screen-game-sort-submitButton{background:#fff;color:#000;padding:10px}.micromag-screen-game-sort-submitButton:disabled{opacity:.5}
package/es/index.js ADDED
@@ -0,0 +1,686 @@
1
+ import { useIntl, FormattedMessage, defineMessage } from 'react-intl';
2
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
5
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
+ import { useSprings, animated } from '@react-spring/web';
7
+ import { useDrag } from '@use-gesture/react';
8
+ import classNames from 'classnames';
9
+ import isString from 'lodash/isString';
10
+ import shuffle from 'lodash/shuffle';
11
+ import PropTypes from 'prop-types';
12
+ import React, { useState, useRef, useEffect, useCallback } from 'react';
13
+ import { PropTypes as PropTypes$1 } from '@micromag/core';
14
+ import { ScreenElement } from '@micromag/core/components';
15
+ import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
16
+ import { useDimensionObserver, useTrackScreenEvent } from '@micromag/core/hooks';
17
+ import { isHeaderFilled, isFooterFilled, getFooterProps, getStyleFromBox, getStyleFromText } from '@micromag/core/utils';
18
+ import Background from '@micromag/element-background';
19
+ import Button from '@micromag/element-button';
20
+ import Container from '@micromag/element-container';
21
+ import Footer from '@micromag/element-footer';
22
+ import Header from '@micromag/element-header';
23
+ import Heading from '@micromag/element-heading';
24
+ import Layout, { Spacer } from '@micromag/element-layout';
25
+ import Text from '@micromag/element-text';
26
+ import Visual from '@micromag/element-visual';
27
+
28
+ var styles = {"layout":"micromag-screen-game-sort-layout","button":"micromag-screen-game-sort-button","layoutLabelOver":"micromag-screen-game-sort-layoutLabelOver","buttonLabel":"micromag-screen-game-sort-buttonLabel","container":"micromag-screen-game-sort-container","background":"micromag-screen-game-sort-background","content":"micromag-screen-game-sort-content","emptyHeading":"micromag-screen-game-sort-emptyHeading","emptyItems":"micromag-screen-game-sort-emptyItems","heading":"micromag-screen-game-sort-heading","header":"micromag-screen-game-sort-header","footer":"micromag-screen-game-sort-footer","items":"micromag-screen-game-sort-items","item":"micromag-screen-game-sort-item","sorted":"micromag-screen-game-sort-sorted","isEmpty":"micromag-screen-game-sort-isEmpty","valid":"micromag-screen-game-sort-valid","invalid":"micromag-screen-game-sort-invalid","layoutLabelTop":"micromag-screen-game-sort-layoutLabelTop","layoutNoLabel":"micromag-screen-game-sort-layoutNoLabel","buttonVisual":"micromag-screen-game-sort-buttonVisual","submitButton":"micromag-screen-game-sort-submitButton"};
29
+
30
+ var propTypes = {
31
+ layout: PropTypes.oneOf(['top', 'middle', 'bottom']),
32
+ heading: PropTypes$1.headingElement,
33
+ // eslint-disable-next-line react/forbid-prop-types
34
+ items: PropTypes.array,
35
+ spacing: PropTypes.number,
36
+ buttonStyles: PropTypes.shape({}),
37
+ background: PropTypes$1.backgroundElement,
38
+ header: PropTypes$1.header,
39
+ footer: PropTypes$1.footer,
40
+ id: PropTypes.string,
41
+ index: PropTypes.number,
42
+ current: PropTypes.bool,
43
+ active: PropTypes.bool,
44
+ className: PropTypes.string
45
+ };
46
+ var defaultProps = {
47
+ layout: 'top',
48
+ heading: null,
49
+ items: null,
50
+ buttonStyles: null,
51
+ spacing: 20,
52
+ background: null,
53
+ header: null,
54
+ footer: null,
55
+ id: null,
56
+ index: null,
57
+ current: true,
58
+ active: true,
59
+ className: null
60
+ };
61
+ var ShareScreen = function ShareScreen(_ref) {
62
+ var layout = _ref.layout,
63
+ heading = _ref.heading,
64
+ items = _ref.items,
65
+ buttonStyles = _ref.buttonStyles,
66
+ spacing = _ref.spacing,
67
+ background = _ref.background,
68
+ header = _ref.header,
69
+ footer = _ref.footer;
70
+ _ref.id;
71
+ _ref.index;
72
+ var current = _ref.current,
73
+ active = _ref.active,
74
+ className = _ref.className;
75
+ var intl = useIntl();
76
+ var _useScreenSize = useScreenSize(),
77
+ width = _useScreenSize.width,
78
+ height = _useScreenSize.height,
79
+ resolution = _useScreenSize.resolution;
80
+ var _useScreenRenderConte = useScreenRenderContext(),
81
+ isView = _useScreenRenderConte.isView,
82
+ isPreview = _useScreenRenderConte.isPreview,
83
+ isPlaceholder = _useScreenRenderConte.isPlaceholder,
84
+ isEdit = _useScreenRenderConte.isEdit;
85
+ var _useViewerContext = useViewerContext(),
86
+ viewerTopHeight = _useViewerContext.topHeight,
87
+ viewerBottomHeight = _useViewerContext.bottomHeight,
88
+ viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
89
+ var _useViewerWebView = useViewerWebView(),
90
+ openWebView = _useViewerWebView.open;
91
+ var _usePlaybackContext = usePlaybackContext(),
92
+ muted = _usePlaybackContext.muted;
93
+ var mediaRef = usePlaybackMediaRef(current);
94
+ var backgroundPlaying = current && (isView || isEdit);
95
+ var backgroundShouldLoad = current || active;
96
+ var hasHeader = isHeaderFilled(header);
97
+ var hasFooter = isFooterFilled(footer);
98
+ var footerProps = getFooterProps(footer, {
99
+ isView: isView,
100
+ current: current,
101
+ openWebView: openWebView,
102
+ isPreview: isPreview
103
+ });
104
+ var _ref2 = buttonStyles || {},
105
+ _ref2$layout = _ref2.layout,
106
+ buttonLayout = _ref2$layout === void 0 ? null : _ref2$layout,
107
+ _ref2$textStyle = _ref2.textStyle,
108
+ buttonTextStyle = _ref2$textStyle === void 0 ? null : _ref2$textStyle,
109
+ _ref2$boxStyle = _ref2.boxStyle,
110
+ buttonBoxStyle = _ref2$boxStyle === void 0 ? null : _ref2$boxStyle,
111
+ _ref2$validBoxStyle = _ref2.validBoxStyle,
112
+ validBoxStyle = _ref2$validBoxStyle === void 0 ? null : _ref2$validBoxStyle,
113
+ _ref2$invalidBoxStyle = _ref2.invalidBoxStyle,
114
+ invalidBoxStyle = _ref2$invalidBoxStyle === void 0 ? null : _ref2$invalidBoxStyle,
115
+ _ref2$submitBoxStyle = _ref2.submitBoxStyle,
116
+ submitBoxStyle = _ref2$submitBoxStyle === void 0 ? null : _ref2$submitBoxStyle,
117
+ _ref2$submitButtonLab = _ref2.submitButtonLabel,
118
+ submitButtonLabel = _ref2$submitButtonLab === void 0 ? null : _ref2$submitButtonLab,
119
+ _ref2$validatedButton = _ref2.validatedButtonLabel,
120
+ validatedButtonLabel = _ref2$validatedButton === void 0 ? null : _ref2$validatedButton;
121
+ var _useDimensionObserver = useDimensionObserver(),
122
+ headerRef = _useDimensionObserver.ref,
123
+ _useDimensionObserver2 = _useDimensionObserver.height,
124
+ headerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
125
+ var _useDimensionObserver3 = useDimensionObserver(),
126
+ footerRef = _useDimensionObserver3.ref,
127
+ _useDimensionObserver4 = _useDimensionObserver3.height,
128
+ footerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
129
+ useTrackScreenEvent('game-sort');
130
+ var _useState = useState(isView ? shuffle(items || []) : items || []),
131
+ _useState2 = _slicedToArray(_useState, 2),
132
+ sortedItems = _useState2[0],
133
+ setSortedItems = _useState2[1];
134
+ var sortedItemsRef = useRef(sortedItems);
135
+ var currentItemsRef = useRef(items);
136
+ useEffect(function () {
137
+ if (currentItemsRef.current !== items) {
138
+ var newSortedItems = isView ? shuffle(items || []) : items || [];
139
+ setSortedItems(newSortedItems);
140
+ sortedItemsRef.current = newSortedItems;
141
+ currentItemsRef.current = items;
142
+ }
143
+ }, [items]);
144
+ var getNewSortedItems = useCallback(function (currentItems, item, newIndex) {
145
+ var currentIndex = currentItems.findIndex(function (it) {
146
+ return it === item;
147
+ });
148
+ var newSortedItems = _toConsumableArray(currentItems);
149
+ var currentItem = newSortedItems[newIndex];
150
+ newSortedItems[newIndex] = item;
151
+ newSortedItems[currentIndex] = currentItem;
152
+ return newSortedItems;
153
+ }, []);
154
+ var updateIndex = useCallback(function (item, newIndex) {
155
+ var newSortedItems = getNewSortedItems(sortedItems, item, newIndex);
156
+ setSortedItems(newSortedItems);
157
+ sortedItemsRef.current = newSortedItems;
158
+ }, [sortedItems, getNewSortedItems]);
159
+ var _useSprings = useSprings((items || []).length, function () {
160
+ return {
161
+ y: "0%",
162
+ scale: 1
163
+ };
164
+ }, []),
165
+ _useSprings2 = _slicedToArray(_useSprings, 2),
166
+ springs = _useSprings2[0],
167
+ api = _useSprings2[1];
168
+ var itemsRef = useRef([]);
169
+ var _useState3 = useState(false),
170
+ _useState4 = _slicedToArray(_useState3, 2),
171
+ initialSorted = _useState4[0],
172
+ setInitialSorted = _useState4[1];
173
+ var updateSpring = useCallback(function (currentItems) {
174
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
175
+ dragItem = _ref3.dragItem,
176
+ dragY = _ref3.dragY,
177
+ _ref3$initial = _ref3.initial,
178
+ initial = _ref3$initial === void 0 ? false : _ref3$initial;
179
+ var heights = itemsRef.current.map(function (item) {
180
+ var _item$getBoundingClie;
181
+ return (item === null || item === void 0 || (_item$getBoundingClie = item.getBoundingClientRect()) === null || _item$getBoundingClie === void 0 ? void 0 : _item$getBoundingClie.height) || 0;
182
+ });
183
+ api.start(function (itemIndex) {
184
+ var item = (items || [])[itemIndex] || null;
185
+ var sortedIndex = currentItems.findIndex(function (it) {
186
+ return it === item;
187
+ });
188
+ var currentHeight = heights[itemIndex] || 0;
189
+ if (item === dragItem) {
190
+ var _currentY = heights.slice(0, itemIndex).reduce(function (acc, itemHeight) {
191
+ return acc + itemHeight;
192
+ }, 0);
193
+ var _deltaY = dragY - _currentY;
194
+ return {
195
+ y: "".concat(_deltaY / currentHeight * 100, "%"),
196
+ scale: 1.02,
197
+ immediate: true
198
+ };
199
+ }
200
+ if (itemIndex === sortedIndex) {
201
+ return {
202
+ y: "0%",
203
+ scale: 1,
204
+ immediate: initial
205
+ };
206
+ }
207
+ var currentY = heights.slice(0, itemIndex).reduce(function (acc, itemHeight) {
208
+ return acc + itemHeight;
209
+ }, 0);
210
+ var newY = heights.slice(0, sortedIndex).reduce(function (acc, itemHeight) {
211
+ return acc + itemHeight;
212
+ }, 0);
213
+ var deltaY = newY - currentY;
214
+ return {
215
+ y: "".concat(deltaY / currentHeight * 100, "%"),
216
+ scale: 1,
217
+ immediate: initial
218
+ };
219
+ });
220
+ if (initial) {
221
+ setInitialSorted(true);
222
+ }
223
+ }, [api]);
224
+ var initialSortedItemsRef = useRef(sortedItems);
225
+ useEffect(function () {
226
+ if (!isView) {
227
+ return;
228
+ }
229
+ updateSpring(sortedItems, {
230
+ initial: initialSortedItemsRef.current === sortedItems
231
+ });
232
+ }, [sortedItems]);
233
+ var _useState5 = useState(null),
234
+ _useState6 = _slicedToArray(_useState5, 2),
235
+ validated = _useState6[0],
236
+ setValidated = _useState6[1];
237
+ var bind = useDrag(function (_ref4) {
238
+ var _ref4$args = _slicedToArray(_ref4.args, 1),
239
+ itemIndex = _ref4$args[0],
240
+ dragActive = _ref4.active,
241
+ _ref4$movement = _slicedToArray(_ref4.movement, 2),
242
+ movementY = _ref4$movement[1],
243
+ tap = _ref4.tap;
244
+ var item = items[itemIndex] || {};
245
+ if (tap) {
246
+ var currentIndex = sortedItems.findIndex(function (it) {
247
+ return it === item;
248
+ });
249
+ var _newIndex = currentIndex === 0 ? sortedItems.length - 1 : currentIndex - 1;
250
+ updateIndex(item, _newIndex);
251
+ return;
252
+ }
253
+ var sortedIndex = sortedItems.findIndex(function (it) {
254
+ return it === item;
255
+ });
256
+ var heights = sortedItems.map(function (sortedItem) {
257
+ var _itemsRef$current$ind;
258
+ var index = items.findIndex(function (it) {
259
+ return it === sortedItem;
260
+ });
261
+ return ((_itemsRef$current$ind = itemsRef.current[index]) === null || _itemsRef$current$ind === void 0 || (_itemsRef$current$ind = _itemsRef$current$ind.getBoundingClientRect()) === null || _itemsRef$current$ind === void 0 ? void 0 : _itemsRef$current$ind.height) || 0;
262
+ });
263
+ var ys = heights.map(function (itemHeight, index) {
264
+ var endY = itemHeight + heights.slice(0, index).reduce(function (acc, h) {
265
+ return acc + h;
266
+ }, 0);
267
+ return {
268
+ isStart: index === 0,
269
+ isEnd: index === heights.length - 1,
270
+ start: endY - itemHeight,
271
+ end: endY
272
+ };
273
+ });
274
+ var newY = ys[sortedIndex].end - heights[sortedIndex] / 2 + movementY;
275
+ var newIndex = ys.findIndex(function (_ref5) {
276
+ var isStart = _ref5.isStart,
277
+ isEnd = _ref5.isEnd,
278
+ start = _ref5.start,
279
+ end = _ref5.end;
280
+ return (isStart || newY >= start) && (isEnd || newY < end);
281
+ });
282
+ if (dragActive) {
283
+ var newSortedItems = getNewSortedItems(sortedItemsRef.current, item, newIndex);
284
+ sortedItemsRef.current = newSortedItems;
285
+ updateSpring(newSortedItems, {
286
+ dragItem: item,
287
+ dragY: ys[sortedIndex].start + movementY
288
+ });
289
+ } else {
290
+ setSortedItems(sortedItemsRef.current);
291
+ // updateIndex(item, newIndex !== -1 ? newIndex : sortedIndex);
292
+ }
293
+ // console.log({
294
+ // movementY,
295
+ // newY,
296
+ // itemIndex,
297
+ // sortedIndex,
298
+ // newIndex,
299
+ // ys,
300
+ // items: sortedItemsRef.current.map(({ label }) => label),
301
+ // });
302
+ }, {
303
+ axis: 'y',
304
+ preventDefault: true,
305
+ filterTaps: true,
306
+ enabled: isView && active && current && validated === null
307
+ // preventScroll: 250,
308
+ // preventScrollAxis: 'y',
309
+ });
310
+ var onClickSubmit = useCallback(function () {
311
+ setValidated(items.map(function (it, index) {
312
+ var sortedIndex = sortedItems.findIndex(function (sortedItem) {
313
+ return sortedItem === it;
314
+ });
315
+ return index === sortedIndex;
316
+ }));
317
+ }, [items, sortedItems]);
318
+ useEffect(function () {
319
+ if (validated === null) {
320
+ return function () {};
321
+ }
322
+ var timeout = setTimeout(function () {
323
+ setSortedItems(items);
324
+ }, 2000);
325
+ return function () {
326
+ clearTimeout(timeout);
327
+ };
328
+ }, [validated]);
329
+ return /*#__PURE__*/React.createElement("div", {
330
+ className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.sorted, initialSorted || !isView), styles.isPlaceholder, isPlaceholder)]),
331
+ "data-screen-ready": true
332
+ }, /*#__PURE__*/React.createElement(Container, {
333
+ width: width,
334
+ height: height,
335
+ className: styles.content
336
+ }, /*#__PURE__*/React.createElement(Layout, {
337
+ className: styles.layout,
338
+ verticalAlign: layout,
339
+ fullscreen: true,
340
+ style: !isPlaceholder ? {
341
+ padding: spacing,
342
+ paddingTop: (!isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
343
+ paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight || spacing)
344
+ } : null
345
+ }, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
346
+ className: styles.header,
347
+ ref: headerRef,
348
+ style: {
349
+ paddingTop: spacing / 2,
350
+ paddingBottom: spacing,
351
+ paddingLeft: spacing,
352
+ paddingRight: spacing,
353
+ transform: "translate(0px, ".concat(viewerTopHeight, "px)")
354
+ }
355
+ }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(ScreenElement, {
356
+ key: "title",
357
+ placeholder: "title",
358
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
359
+ id: "X7kRRa",
360
+ defaultMessage: [{
361
+ "type": 0,
362
+ "value": "Heading"
363
+ }]
364
+ }),
365
+ emptyClassName: styles.emptyHeading,
366
+ isEmpty: !heading || (heading === null || heading === void 0 ? void 0 : heading.body) === ''
367
+ }, heading ? /*#__PURE__*/React.createElement(Heading, Object.assign({
368
+ className: classNames([styles.heading])
369
+ }, heading)) : null), /*#__PURE__*/React.createElement(Spacer, {
370
+ key: "spacer",
371
+ size: 5
372
+ }), /*#__PURE__*/React.createElement(ScreenElement, {
373
+ key: "items",
374
+ placeholder: "items",
375
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
376
+ id: "03U69o",
377
+ defaultMessage: [{
378
+ "type": 0,
379
+ "value": "Buttons"
380
+ }]
381
+ }),
382
+ className: styles.items,
383
+ emptyClassName: styles.emptyItems,
384
+ isEmpty: (items || []).length === 0
385
+ }, springs.map(function (props, itemIndex) {
386
+ var item = items[itemIndex] || {};
387
+ var _ref7 = item || {},
388
+ _ref7$visual = _ref7.visual,
389
+ visual = _ref7$visual === void 0 ? null : _ref7$visual,
390
+ itemLabel = _ref7.label,
391
+ _ref7$boxStyle = _ref7.boxStyle,
392
+ boxStyle = _ref7$boxStyle === void 0 ? null : _ref7$boxStyle;
393
+ var finalLabel = isString(itemLabel) ? {
394
+ body: itemLabel
395
+ } : itemLabel || {};
396
+ var _ref8 = finalLabel || {},
397
+ _ref8$body = _ref8.body,
398
+ label = _ref8$body === void 0 ? null : _ref8$body,
399
+ _ref8$textStyle = _ref8.textStyle,
400
+ textStyle = _ref8$textStyle === void 0 ? null : _ref8$textStyle;
401
+ var isEmpty = label === null && visual === null;
402
+ var isValid = validated !== null && validated[itemIndex];
403
+ return /*#__PURE__*/React.createElement(animated.div, Object.assign({
404
+ key: "button-".concat(itemIndex),
405
+ className: classNames([styles.item, _defineProperty(_defineProperty(_defineProperty({}, styles.isEmpty, isEmpty), styles.valid, validated !== null && isValid), styles.invalid, validated !== null && !isValid)]),
406
+ style: props,
407
+ ref: function ref(_ref1) {
408
+ itemsRef.current[itemIndex] = _ref1;
409
+ }
410
+ }, bind(itemIndex)), /*#__PURE__*/React.createElement("div", {
411
+ className: classNames([styles.button, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.layoutLabelBottom, buttonLayout === 'label-bottom'), styles.layoutLabelTop, buttonLayout === 'label-top'), styles.layoutNoLabel, buttonLayout === 'no-label'), styles.layoutLabelOver, buttonLayout === 'label-over')]),
412
+ style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getStyleFromBox(buttonBoxStyle)), getStyleFromBox(boxStyle)), getStyleFromBox(validated && isValid ? validBoxStyle : null)), getStyleFromBox(validated && !isValid ? invalidBoxStyle : null))
413
+ // onClick={(e) => onItemClick(e, item, itemIndex)}
414
+ }, visual !== null ? /*#__PURE__*/React.createElement(Visual, {
415
+ className: styles.buttonVisual,
416
+ imageClassName: styles.thumbnail,
417
+ media: visual,
418
+ width: "auto"
419
+ }) : null, label !== null ? /*#__PURE__*/React.createElement(Text, Object.assign({
420
+ className: styles.buttonLabel
421
+ }, finalLabel, {
422
+ textStyle: _objectSpread(_objectSpread({}, getStyleFromText(buttonTextStyle)), getStyleFromText(textStyle))
423
+ })) : null));
424
+ })), /*#__PURE__*/React.createElement(Button, {
425
+ className: styles.submitButton,
426
+ disabled: validated !== null,
427
+ type: "button",
428
+ onClick: onClickSubmit,
429
+ style: getStyleFromBox(submitBoxStyle)
430
+ }, validated !== null ? /*#__PURE__*/React.createElement(Text, Object.assign({
431
+ className: styles.buttonLabel,
432
+ body: intl.formatMessage({
433
+ id: "CTculh",
434
+ defaultMessage: [{
435
+ "type": 0,
436
+ "value": "Validated"
437
+ }]
438
+ })
439
+ }, validatedButtonLabel)) : /*#__PURE__*/React.createElement(Text, Object.assign({
440
+ className: styles.buttonLabel,
441
+ body: intl.formatMessage({
442
+ id: "IbZVf0",
443
+ defaultMessage: [{
444
+ "type": 0,
445
+ "value": "Submit"
446
+ }]
447
+ })
448
+ }, submitButtonLabel))), !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
449
+ className: styles.footer,
450
+ ref: footerRef,
451
+ style: {
452
+ paddingTop: spacing,
453
+ paddingBottom: spacing / 2,
454
+ paddingLeft: Math.max(viewerBottomSidesWidth - spacing, 0),
455
+ paddingRight: Math.max(viewerBottomSidesWidth - spacing, 0)
456
+ }
457
+ }, /*#__PURE__*/React.createElement(Footer, footerProps)) : null)), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
458
+ background: background,
459
+ width: width,
460
+ height: height,
461
+ resolution: resolution,
462
+ playing: backgroundPlaying,
463
+ muted: muted,
464
+ shouldLoad: backgroundShouldLoad,
465
+ mediaRef: mediaRef,
466
+ withoutVideo: isPreview,
467
+ className: styles.background
468
+ }) : null);
469
+ };
470
+ ShareScreen.propTypes = propTypes;
471
+ ShareScreen.defaultProps = defaultProps;
472
+
473
+ // import * as transforms from './transforms/index';
474
+
475
+ var definition = {
476
+ id: 'game-sort',
477
+ type: 'screen',
478
+ group: {
479
+ label: defineMessage({
480
+ id: "w3+kFW",
481
+ defaultMessage: [{
482
+ "type": 0,
483
+ "value": "Game"
484
+ }]
485
+ }),
486
+ order: 12
487
+ },
488
+ title: defineMessage({
489
+ id: "OOIQh7",
490
+ defaultMessage: [{
491
+ "type": 0,
492
+ "value": "Game Sort"
493
+ }]
494
+ }),
495
+ component: ShareScreen,
496
+ layouts: ['top', 'middle', 'bottom'],
497
+ // transforms,
498
+ fields: [{
499
+ name: 'layout',
500
+ type: 'screen-layout',
501
+ defaultValue: 'middle',
502
+ label: defineMessage({
503
+ id: "4iBXj2",
504
+ defaultMessage: [{
505
+ "type": 0,
506
+ "value": "Layout"
507
+ }]
508
+ })
509
+ }, {
510
+ name: 'heading',
511
+ type: 'heading-element',
512
+ label: defineMessage({
513
+ id: "wx5PI0",
514
+ defaultMessage: [{
515
+ "type": 0,
516
+ "value": "Heading"
517
+ }]
518
+ })
519
+ }, {
520
+ name: 'items',
521
+ type: 'buttons',
522
+ label: defineMessage({
523
+ id: "l5uLMd",
524
+ defaultMessage: [{
525
+ "type": 0,
526
+ "value": "Buttons"
527
+ }]
528
+ }),
529
+ itemsProps: {
530
+ excludedFields: ['url', 'inWebView']
531
+ },
532
+ isSection: true
533
+ }, {
534
+ name: 'buttonStyles',
535
+ type: 'fields',
536
+ defaultValue: {
537
+ layout: 'label-bottom',
538
+ boxStyle: {
539
+ backgroundColor: {
540
+ alpha: 0.15,
541
+ color: '#000000'
542
+ }
543
+ }
544
+ },
545
+ isList: true,
546
+ fields: [{
547
+ name: 'layout',
548
+ type: 'button-layout',
549
+ label: defineMessage({
550
+ id: "OPxJx/",
551
+ defaultMessage: [{
552
+ "type": 0,
553
+ "value": "Layout"
554
+ }]
555
+ })
556
+ }, {
557
+ name: 'textStyle',
558
+ type: 'text-style-form',
559
+ label: defineMessage({
560
+ id: "rzXCu2",
561
+ defaultMessage: [{
562
+ "type": 0,
563
+ "value": "Label style"
564
+ }]
565
+ })
566
+ }, {
567
+ name: 'boxStyle',
568
+ type: 'box-style-form',
569
+ label: defineMessage({
570
+ id: "nno1Pq",
571
+ defaultMessage: [{
572
+ "type": 0,
573
+ "value": "Button style"
574
+ }]
575
+ })
576
+ }, {
577
+ name: 'validBoxStyle',
578
+ type: 'box-style-form',
579
+ label: defineMessage({
580
+ id: "6bqjZK",
581
+ defaultMessage: [{
582
+ "type": 0,
583
+ "value": "Valid button style"
584
+ }]
585
+ })
586
+ }, {
587
+ name: 'invalidBoxStyle',
588
+ type: 'box-style-form',
589
+ label: defineMessage({
590
+ id: "NPpncq",
591
+ defaultMessage: [{
592
+ "type": 0,
593
+ "value": "Invalid button style"
594
+ }]
595
+ })
596
+ }, {
597
+ name: 'submitBoxStyle',
598
+ type: 'box-style-form',
599
+ label: defineMessage({
600
+ id: "9QP1Kj",
601
+ defaultMessage: [{
602
+ "type": 0,
603
+ "value": "Submit button style"
604
+ }]
605
+ })
606
+ }, {
607
+ name: 'validatedBoxStyle',
608
+ type: 'box-style-form',
609
+ label: defineMessage({
610
+ id: "6EF9gy",
611
+ defaultMessage: [{
612
+ "type": 0,
613
+ "value": "Validated button style"
614
+ }]
615
+ })
616
+ }, {
617
+ name: 'submitButtonLabel',
618
+ type: 'text-element',
619
+ label: defineMessage({
620
+ id: "Vuj0dX",
621
+ defaultMessage: [{
622
+ "type": 0,
623
+ "value": "Submit button label"
624
+ }]
625
+ })
626
+ }, {
627
+ name: 'validatedButtonLabel',
628
+ type: 'text-element',
629
+ label: defineMessage({
630
+ id: "tbrIgP",
631
+ defaultMessage: [{
632
+ "type": 0,
633
+ "value": "Validated button label"
634
+ }]
635
+ })
636
+ }]
637
+ }, {
638
+ name: 'background',
639
+ type: 'background',
640
+ label: defineMessage({
641
+ id: "+MPZRu",
642
+ defaultMessage: [{
643
+ "type": 0,
644
+ "value": "Background"
645
+ }]
646
+ })
647
+ }, {
648
+ name: 'header',
649
+ type: 'header',
650
+ label: defineMessage({
651
+ id: "rhuDxI",
652
+ defaultMessage: [{
653
+ "type": 0,
654
+ "value": "Header"
655
+ }]
656
+ }),
657
+ theme: {
658
+ badge: {
659
+ label: {
660
+ textStyle: 'badge'
661
+ },
662
+ boxStyle: 'badge'
663
+ }
664
+ }
665
+ }, {
666
+ name: 'footer',
667
+ type: 'footer',
668
+ label: defineMessage({
669
+ id: "g4nybp",
670
+ defaultMessage: [{
671
+ "type": 0,
672
+ "value": "Footer"
673
+ }]
674
+ }),
675
+ theme: {
676
+ callToAction: {
677
+ label: {
678
+ textStyle: 'cta'
679
+ },
680
+ boxStyle: 'cta'
681
+ }
682
+ }
683
+ }]
684
+ };
685
+
686
+ export { ShareScreen as GameSortScreen, definition as default };
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@micromag/screen-game-sort",
3
+ "version": "0.3.714",
4
+ "private": false,
5
+ "description": "",
6
+ "keywords": [
7
+ "javascript"
8
+ ],
9
+ "homepage": "https://github.com/urbania-media/micromag-js",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/urbania-media/micromag-js.git"
13
+ },
14
+ "author": {
15
+ "name": "Folklore",
16
+ "email": "info@folklore.email"
17
+ },
18
+ "contributors": [
19
+ {
20
+ "name": "David Mongeau-Petitpas",
21
+ "email": "dmp@folklore.email"
22
+ },
23
+ {
24
+ "name": "Nicolas Roy-Bourdages",
25
+ "email": "nrb@folklore.email"
26
+ },
27
+ {
28
+ "name": "Julien Carignan",
29
+ "email": "jc@folklore.email"
30
+ },
31
+ {
32
+ "name": "Fred Mercy",
33
+ "email": "fred@atelierfolklore.ca"
34
+ }
35
+ ],
36
+ "license": "ISC",
37
+ "type": "module",
38
+ "module": "es/index.js",
39
+ "style": "assets/css/styles.css",
40
+ "exports": {
41
+ ".": {
42
+ "import": "./es/index.js"
43
+ },
44
+ "./assets/css/styles": "./assets/css/styles.css",
45
+ "./assets/css/styles.css": "./assets/css/styles.css"
46
+ },
47
+ "files": [
48
+ "lib",
49
+ "es",
50
+ "assets"
51
+ ],
52
+ "scripts": {
53
+ "clean": "rm -rf es && rm -rf lib && rm -rf assets",
54
+ "prepublishOnly": "npm run build",
55
+ "build": "../../scripts/prepare-package.sh"
56
+ },
57
+ "devDependencies": {
58
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
59
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
60
+ },
61
+ "peerDependencies": {
62
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
63
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
64
+ },
65
+ "dependencies": {
66
+ "@babel/runtime": "^7.13.10",
67
+ "@micromag/core": "^0.3.714",
68
+ "@micromag/element-background": "^0.3.714",
69
+ "@micromag/element-button": "^0.3.714",
70
+ "@micromag/element-container": "^0.3.714",
71
+ "@micromag/element-footer": "^0.3.714",
72
+ "@micromag/element-header": "^0.3.714",
73
+ "@micromag/element-heading": "^0.3.714",
74
+ "@micromag/element-layout": "^0.3.714",
75
+ "@micromag/element-text": "^0.3.714",
76
+ "@micromag/element-visual": "^0.3.714",
77
+ "@micromag/transforms": "^0.3.714",
78
+ "@react-spring/web": "^9.6.1",
79
+ "@use-gesture/react": "^10.3.0",
80
+ "classnames": "^2.2.6",
81
+ "lodash": "^4.17.21",
82
+ "prop-types": "^15.7.2",
83
+ "react-intl": "^6.6.4",
84
+ "uuid": "^9.0.0"
85
+ },
86
+ "publishConfig": {
87
+ "access": "public",
88
+ "registry": "https://registry.npmjs.org/"
89
+ },
90
+ "gitHead": "85dd03193fcac7776b74d8a41a2ebf116890b507"
91
+ }