@micromag/screen-game-sort 0.4.49 → 0.4.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +167 -154
- package/package.json +13 -13
package/es/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { useDrag } from '@use-gesture/react';
|
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import isString from 'lodash/isString';
|
|
10
10
|
import shuffle from 'lodash/shuffle';
|
|
11
|
-
import
|
|
11
|
+
import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
12
12
|
import { ScreenElement } from '@micromag/core/components';
|
|
13
13
|
import { useScreenSize, useScreenRenderContext, useViewerContext, useViewerWebView, usePlaybackContext, usePlaybackMediaRef } from '@micromag/core/contexts';
|
|
14
14
|
import { useDimensionObserver, useTrackScreenEvent } from '@micromag/core/hooks';
|
|
@@ -22,6 +22,7 @@ import Heading from '@micromag/element-heading';
|
|
|
22
22
|
import Layout, { Spacer } from '@micromag/element-layout';
|
|
23
23
|
import Text from '@micromag/element-text';
|
|
24
24
|
import Visual from '@micromag/element-visual';
|
|
25
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
25
26
|
|
|
26
27
|
var styles = {"container":"micromag-screen-game-sort-container","background":"micromag-screen-game-sort-background","content":"micromag-screen-game-sort-content","heading":"micromag-screen-game-sort-heading","layout":"micromag-screen-game-sort-layout","emptyHeading":"micromag-screen-game-sort-emptyHeading","emptyItems":"micromag-screen-game-sort-emptyItems","header":"micromag-screen-game-sort-header","footer":"micromag-screen-game-sort-footer","items":"micromag-screen-game-sort-items","item":"micromag-screen-game-sort-item","itemInner":"micromag-screen-game-sort-itemInner","thumbnail":"micromag-screen-game-sort-thumbnail","sorted":"micromag-screen-game-sort-sorted","draggable":"micromag-screen-game-sort-draggable","button":"micromag-screen-game-sort-button","buttonLabel":"micromag-screen-game-sort-buttonLabel","buttonResults":"micromag-screen-game-sort-buttonResults","label":"micromag-screen-game-sort-label","isEmpty":"micromag-screen-game-sort-isEmpty","valid":"micromag-screen-game-sort-valid","invalid":"micromag-screen-game-sort-invalid","resultsVisible":"micromag-screen-game-sort-resultsVisible","layoutLabelTop":"micromag-screen-game-sort-layoutLabelTop","layoutNoLabel":"micromag-screen-game-sort-layoutNoLabel","layoutLabelOver":"micromag-screen-game-sort-layoutLabelOver","buttonVisual":"micromag-screen-game-sort-buttonVisual","submitButton":"micromag-screen-game-sort-submitButton","results":"micromag-screen-game-sort-results"};
|
|
27
28
|
|
|
@@ -350,160 +351,172 @@ function GameSort(_ref) {
|
|
|
350
351
|
clearTimeout(timeout);
|
|
351
352
|
};
|
|
352
353
|
}, [validated]);
|
|
353
|
-
return /*#__PURE__*/
|
|
354
|
+
return /*#__PURE__*/jsxs("div", {
|
|
354
355
|
className: classNames([styles.container, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.sorted, initialSorted || !isView), styles.draggable, dragEnabled), styles.resultsVisible, resultsVisible), styles.isPlaceholder, isPlaceholder)]),
|
|
355
|
-
"data-screen-ready": true
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
356
|
+
"data-screen-ready": true,
|
|
357
|
+
children: [/*#__PURE__*/jsx(Container, {
|
|
358
|
+
width: width,
|
|
359
|
+
height: height,
|
|
360
|
+
className: styles.content,
|
|
361
|
+
children: /*#__PURE__*/jsxs(Layout, {
|
|
362
|
+
className: styles.layout,
|
|
363
|
+
verticalAlign: layout,
|
|
364
|
+
fullscreen: true,
|
|
365
|
+
style: !isPlaceholder ? {
|
|
366
|
+
padding: spacing,
|
|
367
|
+
paddingTop: (!isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
|
|
368
|
+
paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight || spacing)
|
|
369
|
+
} : null,
|
|
370
|
+
children: [!isPlaceholder && hasHeader ? /*#__PURE__*/jsx("div", {
|
|
371
|
+
className: styles.header,
|
|
372
|
+
ref: headerRef,
|
|
373
|
+
style: {
|
|
374
|
+
paddingTop: spacing / 2,
|
|
375
|
+
paddingBottom: spacing,
|
|
376
|
+
paddingLeft: spacing,
|
|
377
|
+
paddingRight: spacing,
|
|
378
|
+
transform: "translate(0px, ".concat(viewerTopHeight, "px)")
|
|
379
|
+
},
|
|
380
|
+
children: /*#__PURE__*/jsx(Header, _objectSpread({}, header))
|
|
381
|
+
}) : null, /*#__PURE__*/jsx(ScreenElement, {
|
|
382
|
+
placeholder: "title",
|
|
383
|
+
emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
384
|
+
id: "X7kRRa",
|
|
385
|
+
defaultMessage: [{
|
|
386
|
+
"type": 0,
|
|
387
|
+
"value": "Heading"
|
|
388
|
+
}]
|
|
389
|
+
}),
|
|
390
|
+
emptyClassName: styles.emptyHeading,
|
|
391
|
+
isEmpty: !heading || (heading === null || heading === void 0 ? void 0 : heading.body) === '',
|
|
392
|
+
children: heading ? /*#__PURE__*/jsx(Heading, _objectSpread({
|
|
393
|
+
className: classNames([styles.heading])
|
|
394
|
+
}, heading)) : null
|
|
395
|
+
}, "title"), /*#__PURE__*/jsxs("div", {
|
|
396
|
+
className: styles.items,
|
|
397
|
+
ref: itemsRef,
|
|
398
|
+
children: [/*#__PURE__*/jsx(Spacer, {
|
|
399
|
+
size: 5
|
|
400
|
+
}, "spacer"), /*#__PURE__*/jsx(ScreenElement, {
|
|
401
|
+
placeholder: "items",
|
|
402
|
+
emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
403
|
+
id: "03U69o",
|
|
404
|
+
defaultMessage: [{
|
|
405
|
+
"type": 0,
|
|
406
|
+
"value": "Buttons"
|
|
407
|
+
}]
|
|
408
|
+
}),
|
|
409
|
+
emptyClassName: styles.emptyItems,
|
|
410
|
+
isEmpty: (items || []).length === 0,
|
|
411
|
+
children: springs.map(function (_ref6, itemIndex) {
|
|
412
|
+
var y = _ref6.y,
|
|
413
|
+
scale = _ref6.scale;
|
|
414
|
+
var item = items[itemIndex] || {};
|
|
415
|
+
var _ref7 = item || {},
|
|
416
|
+
_ref7$id = _ref7.id,
|
|
417
|
+
id = _ref7$id === void 0 ? null : _ref7$id,
|
|
418
|
+
_ref7$visual = _ref7.visual,
|
|
419
|
+
visual = _ref7$visual === void 0 ? null : _ref7$visual,
|
|
420
|
+
itemLabel = _ref7.label,
|
|
421
|
+
_ref7$boxStyle = _ref7.boxStyle,
|
|
422
|
+
boxStyle = _ref7$boxStyle === void 0 ? null : _ref7$boxStyle,
|
|
423
|
+
_ref7$results = _ref7.results,
|
|
424
|
+
itemResults = _ref7$results === void 0 ? null : _ref7$results;
|
|
425
|
+
var finalLabel = isString(itemLabel) ? {
|
|
426
|
+
body: itemLabel
|
|
427
|
+
} : itemLabel || {};
|
|
428
|
+
var _ref8 = finalLabel || {},
|
|
429
|
+
_ref8$body = _ref8.body,
|
|
430
|
+
label = _ref8$body === void 0 ? null : _ref8$body,
|
|
431
|
+
labelTextStyle = _ref8.textStyle;
|
|
432
|
+
var isEmpty = label === null && visual === null;
|
|
433
|
+
var isValid = validated !== null && validated[itemIndex];
|
|
434
|
+
return /*#__PURE__*/jsx(animated.div, _objectSpread(_objectSpread({
|
|
435
|
+
className: classNames([styles.item, _defineProperty(_defineProperty(_defineProperty({
|
|
436
|
+
clickable: dragEnabled
|
|
437
|
+
}, styles.isEmpty, isEmpty), styles.valid, validated !== null && isValid), styles.invalid, validated !== null && !isValid)]),
|
|
438
|
+
ref: function ref(_ref1) {
|
|
439
|
+
elementsRef.current[id] = _ref1;
|
|
440
|
+
},
|
|
441
|
+
style: _objectSpread(_objectSpread({
|
|
442
|
+
transform: y.to(function (yValue) {
|
|
443
|
+
return "translateY(".concat(yValue, ")");
|
|
444
|
+
})
|
|
445
|
+
}, getStyleFromText(itemsTextStyle)), getStyleFromText(labelTextStyle))
|
|
446
|
+
}, bind(itemIndex)), {}, {
|
|
447
|
+
children: /*#__PURE__*/jsx("div", {
|
|
448
|
+
className: styles.itemInner,
|
|
449
|
+
children: /*#__PURE__*/jsxs(animated.div, {
|
|
450
|
+
className: classNames([styles.button, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.layoutLabelBottom, itemsLayout === 'label-bottom'), styles.layoutLabelTop, itemsLayout === 'label-top'), styles.layoutNoLabel, itemsLayout === 'no-label'), styles.layoutLabelOver, itemsLayout === 'label-over')]),
|
|
451
|
+
style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
452
|
+
transform: scale.to(function (scaleValue) {
|
|
453
|
+
return "scale(".concat(scaleValue, ")");
|
|
454
|
+
})
|
|
455
|
+
}, getStyleFromBox(itemsBoxStyle)), getStyleFromBox(boxStyle)), getStyleFromBox(validated && isValid ? validBoxStyle : null)), getStyleFromBox(validated && !isValid ? invalidBoxStyle : null))
|
|
456
|
+
// onClick={(e) => onItemClick(e, item, itemIndex)}
|
|
457
|
+
,
|
|
458
|
+
children: [visual !== null ? /*#__PURE__*/jsx(Visual, {
|
|
459
|
+
className: styles.buttonVisual,
|
|
460
|
+
imageClassName: styles.thumbnail,
|
|
461
|
+
media: visual,
|
|
462
|
+
width: "auto"
|
|
463
|
+
}) : null, label !== null || itemResults !== null && resultsVisible ? /*#__PURE__*/jsxs("div", {
|
|
464
|
+
className: styles.buttonLabel,
|
|
465
|
+
children: [label !== null ? /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({}, finalLabel), {}, {
|
|
466
|
+
textStyle: _objectSpread(_objectSpread({}, itemsTextStyle), labelTextStyle),
|
|
467
|
+
className: styles.label
|
|
468
|
+
})) : null, itemResults !== null && resultsVisible ? /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({}, itemResults), {}, {
|
|
469
|
+
className: styles.buttonResults,
|
|
470
|
+
textStyle: _objectSpread(_objectSpread({}, itemsResultsTextStyle), itemResults.textStyle)
|
|
471
|
+
})) : null]
|
|
472
|
+
}) : null]
|
|
473
|
+
})
|
|
474
|
+
})
|
|
475
|
+
}), "button-".concat(itemIndex));
|
|
476
|
+
})
|
|
477
|
+
}, "items")]
|
|
478
|
+
}), resultsVisible && results !== null ? /*#__PURE__*/jsx("div", {
|
|
479
|
+
className: styles.results,
|
|
480
|
+
style: _objectSpread({}, getStyleFromBox(resultsBoxStyle)),
|
|
481
|
+
children: /*#__PURE__*/jsx(Text, _objectSpread({}, results))
|
|
482
|
+
}) : !isPlaceholder ? /*#__PURE__*/jsx(Button, {
|
|
483
|
+
className: styles.submitButton,
|
|
484
|
+
disabled: validated !== null,
|
|
485
|
+
type: "button",
|
|
486
|
+
onClick: onClickSubmit,
|
|
487
|
+
style: _objectSpread(_objectSpread({}, getStyleFromBox(submitBoxStyle)), getStyleFromText(submitTextStyle)),
|
|
488
|
+
children: submitButtonLabel || intl.formatMessage({
|
|
489
|
+
id: "IbZVf0",
|
|
490
|
+
defaultMessage: [{
|
|
491
|
+
"type": 0,
|
|
492
|
+
"value": "Submit"
|
|
493
|
+
}]
|
|
494
|
+
})
|
|
495
|
+
}) : null, !isPlaceholder && hasFooter ? /*#__PURE__*/jsx("div", {
|
|
496
|
+
className: styles.footer,
|
|
497
|
+
ref: footerRef,
|
|
498
|
+
style: {
|
|
499
|
+
paddingTop: spacing,
|
|
500
|
+
paddingBottom: spacing / 2,
|
|
501
|
+
paddingLeft: Math.max(viewerBottomSidesWidth - spacing, 0),
|
|
502
|
+
paddingRight: Math.max(viewerBottomSidesWidth - spacing, 0)
|
|
503
|
+
},
|
|
504
|
+
children: /*#__PURE__*/jsx(Footer, _objectSpread({}, footerProps))
|
|
505
|
+
}) : null]
|
|
506
|
+
})
|
|
507
|
+
}), !isPlaceholder ? /*#__PURE__*/jsx(Background, {
|
|
508
|
+
background: background,
|
|
509
|
+
width: width,
|
|
510
|
+
height: height,
|
|
511
|
+
resolution: resolution,
|
|
512
|
+
playing: backgroundPlaying,
|
|
513
|
+
muted: muted,
|
|
514
|
+
shouldLoad: backgroundShouldLoad,
|
|
515
|
+
mediaRef: mediaRef,
|
|
516
|
+
withoutVideo: isPreview,
|
|
517
|
+
className: styles.background
|
|
518
|
+
}) : null]
|
|
519
|
+
});
|
|
507
520
|
}
|
|
508
521
|
|
|
509
522
|
// import * as transforms from './transforms/index';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-game-sort",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -65,17 +65,17 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@babel/runtime": "^7.28.6",
|
|
68
|
-
"@micromag/core": "^0.4.
|
|
69
|
-
"@micromag/element-background": "^0.4.
|
|
70
|
-
"@micromag/element-button": "^0.4.
|
|
71
|
-
"@micromag/element-container": "^0.4.
|
|
72
|
-
"@micromag/element-footer": "^0.4.
|
|
73
|
-
"@micromag/element-header": "^0.4.
|
|
74
|
-
"@micromag/element-heading": "^0.4.
|
|
75
|
-
"@micromag/element-layout": "^0.4.
|
|
76
|
-
"@micromag/element-text": "^0.4.
|
|
77
|
-
"@micromag/element-visual": "^0.4.
|
|
78
|
-
"@micromag/transforms": "^0.4.
|
|
68
|
+
"@micromag/core": "^0.4.50",
|
|
69
|
+
"@micromag/element-background": "^0.4.50",
|
|
70
|
+
"@micromag/element-button": "^0.4.50",
|
|
71
|
+
"@micromag/element-container": "^0.4.50",
|
|
72
|
+
"@micromag/element-footer": "^0.4.50",
|
|
73
|
+
"@micromag/element-header": "^0.4.50",
|
|
74
|
+
"@micromag/element-heading": "^0.4.50",
|
|
75
|
+
"@micromag/element-layout": "^0.4.50",
|
|
76
|
+
"@micromag/element-text": "^0.4.50",
|
|
77
|
+
"@micromag/element-visual": "^0.4.50",
|
|
78
|
+
"@micromag/transforms": "^0.4.50",
|
|
79
79
|
"@react-spring/web": "^10.0.3",
|
|
80
80
|
"@use-gesture/react": "^10.3.0",
|
|
81
81
|
"classnames": "^2.2.6",
|
|
@@ -87,6 +87,6 @@
|
|
|
87
87
|
"access": "public",
|
|
88
88
|
"registry": "https://registry.npmjs.org/"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "940d5ca98f8f448b79eaa3e2fa685c3ee95185b8",
|
|
91
91
|
"types": "es/index.d.ts"
|
|
92
92
|
}
|