@micromag/screen-game-sort 0.4.48 → 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.
Files changed (2) hide show
  1. package/es/index.js +167 -154
  2. 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 React, { useMemo, useState, useRef, useEffect, useCallback } from 'react';
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__*/React.createElement("div", {
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
- }, /*#__PURE__*/React.createElement(Container, {
357
- width: width,
358
- height: height,
359
- className: styles.content
360
- }, /*#__PURE__*/React.createElement(Layout, {
361
- className: styles.layout,
362
- verticalAlign: layout,
363
- fullscreen: true,
364
- style: !isPlaceholder ? {
365
- padding: spacing,
366
- paddingTop: (!isPreview ? viewerTopHeight : 0) + (headerHeight || spacing),
367
- paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight || spacing)
368
- } : null
369
- }, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
370
- className: styles.header,
371
- ref: headerRef,
372
- style: {
373
- paddingTop: spacing / 2,
374
- paddingBottom: spacing,
375
- paddingLeft: spacing,
376
- paddingRight: spacing,
377
- transform: "translate(0px, ".concat(viewerTopHeight, "px)")
378
- }
379
- }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(ScreenElement, {
380
- key: "title",
381
- placeholder: "title",
382
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
383
- id: "X7kRRa",
384
- defaultMessage: [{
385
- "type": 0,
386
- "value": "Heading"
387
- }]
388
- }),
389
- emptyClassName: styles.emptyHeading,
390
- isEmpty: !heading || (heading === null || heading === void 0 ? void 0 : heading.body) === ''
391
- }, heading ? /*#__PURE__*/React.createElement(Heading, Object.assign({
392
- className: classNames([styles.heading])
393
- }, heading)) : null), /*#__PURE__*/React.createElement("div", {
394
- className: styles.items,
395
- ref: itemsRef
396
- }, /*#__PURE__*/React.createElement(Spacer, {
397
- key: "spacer",
398
- size: 5
399
- }), /*#__PURE__*/React.createElement(ScreenElement, {
400
- key: "items",
401
- placeholder: "items",
402
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
403
- id: "03U69o",
404
- defaultMessage: [{
405
- "type": 0,
406
- "value": "Buttons"
407
- }]
408
- }),
409
- emptyClassName: styles.emptyItems,
410
- isEmpty: (items || []).length === 0
411
- }, 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__*/React.createElement(animated.div, Object.assign({
435
- key: "button-".concat(itemIndex),
436
- className: classNames([styles.item, _defineProperty(_defineProperty(_defineProperty({
437
- clickable: dragEnabled
438
- }, styles.isEmpty, isEmpty), styles.valid, validated !== null && isValid), styles.invalid, validated !== null && !isValid)]),
439
- ref: function ref(_ref1) {
440
- elementsRef.current[id] = _ref1;
441
- },
442
- style: _objectSpread(_objectSpread({
443
- transform: y.to(function (yValue) {
444
- return "translateY(".concat(yValue, ")");
445
- })
446
- }, getStyleFromText(itemsTextStyle)), getStyleFromText(labelTextStyle))
447
- }, bind(itemIndex)), /*#__PURE__*/React.createElement("div", {
448
- className: styles.itemInner
449
- }, /*#__PURE__*/React.createElement(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
- }, visual !== null ? /*#__PURE__*/React.createElement(Visual, {
458
- className: styles.buttonVisual,
459
- imageClassName: styles.thumbnail,
460
- media: visual,
461
- width: "auto"
462
- }) : null, label !== null || itemResults !== null && resultsVisible ? /*#__PURE__*/React.createElement("div", {
463
- className: styles.buttonLabel
464
- }, label !== null ? /*#__PURE__*/React.createElement(Text, Object.assign({}, finalLabel, {
465
- textStyle: _objectSpread(_objectSpread({}, itemsTextStyle), labelTextStyle),
466
- className: styles.label
467
- })) : null, itemResults !== null && resultsVisible ? /*#__PURE__*/React.createElement(Text, Object.assign({}, itemResults, {
468
- className: styles.buttonResults,
469
- textStyle: _objectSpread(_objectSpread({}, itemsResultsTextStyle), itemResults.textStyle)
470
- })) : null) : null)));
471
- }))), resultsVisible && results !== null ? /*#__PURE__*/React.createElement("div", {
472
- className: styles.results,
473
- style: _objectSpread({}, getStyleFromBox(resultsBoxStyle))
474
- }, /*#__PURE__*/React.createElement(Text, results)) : !isPlaceholder ? /*#__PURE__*/React.createElement(Button, {
475
- className: styles.submitButton,
476
- disabled: validated !== null,
477
- type: "button",
478
- onClick: onClickSubmit,
479
- style: _objectSpread(_objectSpread({}, getStyleFromBox(submitBoxStyle)), getStyleFromText(submitTextStyle))
480
- }, submitButtonLabel || intl.formatMessage({
481
- id: "IbZVf0",
482
- defaultMessage: [{
483
- "type": 0,
484
- "value": "Submit"
485
- }]
486
- })) : null, !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
487
- className: styles.footer,
488
- ref: footerRef,
489
- style: {
490
- paddingTop: spacing,
491
- paddingBottom: spacing / 2,
492
- paddingLeft: Math.max(viewerBottomSidesWidth - spacing, 0),
493
- paddingRight: Math.max(viewerBottomSidesWidth - spacing, 0)
494
- }
495
- }, /*#__PURE__*/React.createElement(Footer, footerProps)) : null)), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
496
- background: background,
497
- width: width,
498
- height: height,
499
- resolution: resolution,
500
- playing: backgroundPlaying,
501
- muted: muted,
502
- shouldLoad: backgroundShouldLoad,
503
- mediaRef: mediaRef,
504
- withoutVideo: isPreview,
505
- className: styles.background
506
- }) : null);
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.48",
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.48",
69
- "@micromag/element-background": "^0.4.48",
70
- "@micromag/element-button": "^0.4.48",
71
- "@micromag/element-container": "^0.4.48",
72
- "@micromag/element-footer": "^0.4.48",
73
- "@micromag/element-header": "^0.4.48",
74
- "@micromag/element-heading": "^0.4.48",
75
- "@micromag/element-layout": "^0.4.48",
76
- "@micromag/element-text": "^0.4.48",
77
- "@micromag/element-visual": "^0.4.48",
78
- "@micromag/transforms": "^0.4.48",
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": "d6772865be1ee3f2d19288ebfbf4b9b6860f4cd7",
90
+ "gitHead": "940d5ca98f8f448b79eaa3e2fa685c3ee95185b8",
91
91
  "types": "es/index.d.ts"
92
92
  }