@micromag/core 0.3.115 → 0.3.120
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/components.js +22 -3
- package/es/hooks.js +25 -2
- package/es/index.js +2 -0
- package/es/utils.js +142 -3
- package/lib/components.js +22 -3
- package/lib/hooks.js +24 -0
- package/lib/index.js +2 -0
- package/lib/utils.js +144 -2
- package/package.json +2 -2
package/es/components.js
CHANGED
|
@@ -38,6 +38,7 @@ import { getSizeWithinBounds } from '@folklore/size';
|
|
|
38
38
|
import { faCommentDots } from '@fortawesome/free-solid-svg-icons/faCommentDots';
|
|
39
39
|
import { faCheck } from '@fortawesome/free-solid-svg-icons/faCheck';
|
|
40
40
|
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
|
|
41
|
+
import { faCircle } from '@fortawesome/free-solid-svg-icons/faCircle';
|
|
41
42
|
import { faPercent } from '@fortawesome/free-solid-svg-icons/faPercent';
|
|
42
43
|
import { useSpring } from '@react-spring/core';
|
|
43
44
|
import { animated } from '@react-spring/web';
|
|
@@ -3435,7 +3436,7 @@ var Timeline = function Timeline(props) {
|
|
|
3435
3436
|
};
|
|
3436
3437
|
|
|
3437
3438
|
/* eslint-disable react/jsx-props-no-spreading, react/destructuring-assignment, react/prop-types */
|
|
3438
|
-
var Title = function Title(props) {
|
|
3439
|
+
var Title$1 = function Title(props) {
|
|
3439
3440
|
return /*#__PURE__*/React.createElement(PlaceholderText, Object.assign({}, props, {
|
|
3440
3441
|
className: classNames([props.className, styles$c.title]),
|
|
3441
3442
|
height: 0.5,
|
|
@@ -3865,6 +3866,23 @@ var Answer$1 = function Answer(_ref) {
|
|
|
3865
3866
|
})));
|
|
3866
3867
|
};
|
|
3867
3868
|
|
|
3869
|
+
var Title = function Title(props) {
|
|
3870
|
+
return /*#__PURE__*/React.createElement(PlaceholderBlock, Object.assign({}, props, {
|
|
3871
|
+
width: "100%",
|
|
3872
|
+
height: "100%",
|
|
3873
|
+
className: classNames([styles$c.container, _defineProperty({}, props.className, props.className !== null)])
|
|
3874
|
+
}), /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
3875
|
+
icon: faCircle,
|
|
3876
|
+
className: styles$c.icon
|
|
3877
|
+
}), /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
3878
|
+
icon: faCircle,
|
|
3879
|
+
className: styles$c.icon
|
|
3880
|
+
}), /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
3881
|
+
icon: faCircle,
|
|
3882
|
+
className: styles$c.icon
|
|
3883
|
+
}));
|
|
3884
|
+
};
|
|
3885
|
+
|
|
3868
3886
|
var styles$2 = {"container":"micromag-core-placeholders-survey-answer-container","block":"micromag-core-placeholders-survey-answer-block","percent":"micromag-core-placeholders-survey-answer-percent","percentIcon":"micromag-core-placeholders-survey-answer-percentIcon"};
|
|
3869
3887
|
|
|
3870
3888
|
var Answer = function Answer(_ref) {
|
|
@@ -3905,12 +3923,13 @@ var Placeholders = /*#__PURE__*/Object.freeze({
|
|
|
3905
3923
|
MapPath: MapPath,
|
|
3906
3924
|
QuizAnswer: Answer$1,
|
|
3907
3925
|
Quote: Quote,
|
|
3926
|
+
ShareOptions: Title,
|
|
3908
3927
|
ShortText: ShortText,
|
|
3909
3928
|
Subtitle: Subtitle,
|
|
3910
3929
|
SurveyAnswer: Answer,
|
|
3911
3930
|
Text: TextPlaceholder,
|
|
3912
3931
|
Timeline: Timeline,
|
|
3913
|
-
Title: Title,
|
|
3932
|
+
Title: Title$1,
|
|
3914
3933
|
Video: Video,
|
|
3915
3934
|
Video360: Video360,
|
|
3916
3935
|
VideoLoop: VideoLoop
|
|
@@ -4343,4 +4362,4 @@ var LinkStyle = function LinkStyle(_ref) {
|
|
|
4343
4362
|
LinkStyle.propTypes = propTypes;
|
|
4344
4363
|
LinkStyle.defaultProps = defaultProps;
|
|
4345
4364
|
|
|
4346
|
-
export { BackButton, Breadcrumb, Button$1 as Button, Buttons, Card, Close, CollapsablePanel, Date$1 as Date, Detector, Dropdown as DropdownMenu, ElementComponent as Element, Empty, FieldForm, FontFaces, Form, FormPanel, HighlightStyle, Label, Link, LinkStyle, Media, Menu, Meta, Modal, ModalDialog, ModalPortal, Modals, Navbar, PaginationMenu as Pagination, Panel, PanelPortal, Panels, AdFrame as PlaceholderAdFrame, AdImage as PlaceholderAdImage, Audio as PlaceholderAudio, Button as PlaceholderButton, Image as PlaceholderImage, Line as PlaceholderLine, Map as PlaceholderMap, MapPath as PlaceholderMapPath, Quote as PlaceholderQuote, ShortText as PlaceholderShortText, Subtitle as PlaceholderSubtitle, TextPlaceholder as PlaceholderText, Timeline as PlaceholderTimeline, Title as PlaceholderTitle, Video as PlaceholderVideo, Video360 as PlaceholderVideo360, VideoLoop as PlaceholderVideoLoop, Screen$1 as Screen, ScreenElement, Placeholder as ScreenPlaceholder, Preview as ScreenPreview, ScreenSizer, Screens, Slideshow, Spinner, TabsMenu as Tabs, Transitions, TransitionsStagger, UploadModal };
|
|
4365
|
+
export { BackButton, Breadcrumb, Button$1 as Button, Buttons, Card, Close, CollapsablePanel, Date$1 as Date, Detector, Dropdown as DropdownMenu, ElementComponent as Element, Empty, FieldForm, FontFaces, Form, FormPanel, HighlightStyle, Label, Link, LinkStyle, Media, Menu, Meta, Modal, ModalDialog, ModalPortal, Modals, Navbar, PaginationMenu as Pagination, Panel, PanelPortal, Panels, AdFrame as PlaceholderAdFrame, AdImage as PlaceholderAdImage, Audio as PlaceholderAudio, Button as PlaceholderButton, Image as PlaceholderImage, Line as PlaceholderLine, Map as PlaceholderMap, MapPath as PlaceholderMapPath, Quote as PlaceholderQuote, ShortText as PlaceholderShortText, Subtitle as PlaceholderSubtitle, TextPlaceholder as PlaceholderText, Timeline as PlaceholderTimeline, Title$1 as PlaceholderTitle, Video as PlaceholderVideo, Video360 as PlaceholderVideo360, VideoLoop as PlaceholderVideoLoop, Screen$1 as Screen, ScreenElement, Placeholder as ScreenPlaceholder, Preview as ScreenPreview, ScreenSizer, Screens, Slideshow, Spinner, TabsMenu as Tabs, Transitions, TransitionsStagger, UploadModal };
|
package/es/hooks.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useIntl } from 'react-intl';
|
|
|
4
4
|
import isString from 'lodash/isString';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import { EventsManager, MediasParser, StoryParser, ThemeParser } from '@micromag/core';
|
|
7
|
-
import { createUseEvent } from '@micromag/core/utils';
|
|
7
|
+
import { createUseEvent, getMediaFilesAsArray } from '@micromag/core/utils';
|
|
8
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
9
9
|
import { useForm as useForm$1 } from '@folklore/forms';
|
|
10
10
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
@@ -1053,6 +1053,29 @@ var useMediasParser = function useMediasParser() {
|
|
|
1053
1053
|
};
|
|
1054
1054
|
};
|
|
1055
1055
|
|
|
1056
|
+
function useMediaThumbnail(media) {
|
|
1057
|
+
var file = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1058
|
+
|
|
1059
|
+
var _ref = media || {},
|
|
1060
|
+
_ref$thumbnail_url = _ref.thumbnail_url,
|
|
1061
|
+
defaultThumbnailUrl = _ref$thumbnail_url === void 0 ? null : _ref$thumbnail_url,
|
|
1062
|
+
_ref$files = _ref.files,
|
|
1063
|
+
files = _ref$files === void 0 ? null : _ref$files;
|
|
1064
|
+
|
|
1065
|
+
var thumbnailUrl = useMemo(function () {
|
|
1066
|
+
var filesArray = getMediaFilesAsArray(files) || [];
|
|
1067
|
+
|
|
1068
|
+
var _ref2 = (file !== null ? filesArray.find(function (_ref3) {
|
|
1069
|
+
var handle = _ref3.handle;
|
|
1070
|
+
return handle === file;
|
|
1071
|
+
}) || null : null) || {},
|
|
1072
|
+
url = _ref2.url;
|
|
1073
|
+
|
|
1074
|
+
return url || defaultThumbnailUrl;
|
|
1075
|
+
}, [files, file, defaultThumbnailUrl]);
|
|
1076
|
+
return thumbnailUrl;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1056
1079
|
var useParsedStory = function useParsedStory(story) {
|
|
1057
1080
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1058
1081
|
_ref$disabled = _ref.disabled,
|
|
@@ -1566,4 +1589,4 @@ var useTrackMedia = function useTrackMedia() {
|
|
|
1566
1589
|
var eventsManager = typeof window !== 'undefined' ? new EventsManager(window) : null;
|
|
1567
1590
|
var useWindowEvent = createUseEvent(eventsManager);
|
|
1568
1591
|
|
|
1569
|
-
export { getObserver, useAnimationFrame, useDocumentEvent, useForm, useFormTransition, useFormattedDate, useFormattedTime, useFullscreen, useIntersectionObserver, useIsVisible, useLoadedFonts, useLongPress, useMediaApi, useMediasParser, useObserver, useParsedStory, useResizeObserver, useScreenSizeFromElement, useScreenSizeFromWindow, useSwipe, useThemeParser, useTrackEvent, useTrackMedia, useTrackScreenEvent, useTrackScreenMedia, useTrackScreenView, useWindowEvent };
|
|
1592
|
+
export { getObserver, useAnimationFrame, useDocumentEvent, useForm, useFormTransition, useFormattedDate, useFormattedTime, useFullscreen, useIntersectionObserver, useIsVisible, useLoadedFonts, useLongPress, useMediaApi, useMediaThumbnail, useMediasParser, useObserver, useParsedStory, useResizeObserver, useScreenSizeFromElement, useScreenSizeFromWindow, useSwipe, useThemeParser, useTrackEvent, useTrackMedia, useTrackScreenEvent, useTrackScreenMedia, useTrackScreenView, useWindowEvent };
|
package/es/index.js
CHANGED
|
@@ -14,6 +14,8 @@ import _createSuper from '@babel/runtime/helpers/createSuper';
|
|
|
14
14
|
import EventEmitter from 'wolfy87-eventemitter';
|
|
15
15
|
import 'lodash/isNumber';
|
|
16
16
|
import 'param-case';
|
|
17
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
|
18
|
+
import '@babel/runtime/regenerator';
|
|
17
19
|
import 'react';
|
|
18
20
|
import isString from 'lodash/isString';
|
|
19
21
|
import 'tinycolor2';
|
package/es/utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import isNumber from 'lodash/isNumber';
|
|
2
2
|
import { paramCase } from 'param-case';
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
3
5
|
import isObject from 'lodash/isObject';
|
|
4
6
|
import { useEffect } from 'react';
|
|
5
7
|
import isString from 'lodash/isString';
|
|
@@ -20,6 +22,141 @@ var convertStyleToString = function convertStyleToString(style) {
|
|
|
20
22
|
}).join('\n') : '';
|
|
21
23
|
};
|
|
22
24
|
|
|
25
|
+
/*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
26
|
+
// @todo vendoring this: https://github.com/feross/clipboard-copy/blob/master/index.js
|
|
27
|
+
// we might want to add that to the npm deps and just use it?
|
|
28
|
+
function makeError() {
|
|
29
|
+
return new DOMException('The request is not allowed', 'NotAllowedError');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function copyClipboardApi(_x) {
|
|
33
|
+
return _copyClipboardApi.apply(this, arguments);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _copyClipboardApi() {
|
|
37
|
+
_copyClipboardApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
|
|
38
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
39
|
+
while (1) {
|
|
40
|
+
switch (_context.prev = _context.next) {
|
|
41
|
+
case 0:
|
|
42
|
+
if (navigator.clipboard) {
|
|
43
|
+
_context.next = 2;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
throw makeError();
|
|
48
|
+
|
|
49
|
+
case 2:
|
|
50
|
+
return _context.abrupt("return", navigator.clipboard.writeText(text));
|
|
51
|
+
|
|
52
|
+
case 3:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, _callee);
|
|
58
|
+
}));
|
|
59
|
+
return _copyClipboardApi.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function copyExecCommand(_x2) {
|
|
63
|
+
return _copyExecCommand.apply(this, arguments);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _copyExecCommand() {
|
|
67
|
+
_copyExecCommand = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(text) {
|
|
68
|
+
var span, selection, range, success;
|
|
69
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
70
|
+
while (1) {
|
|
71
|
+
switch (_context2.prev = _context2.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
// Put the text to copy into a <span>
|
|
74
|
+
span = document.createElement('span');
|
|
75
|
+
span.textContent = text; // Preserve consecutive spaces and newlines
|
|
76
|
+
|
|
77
|
+
span.style.whiteSpace = 'pre';
|
|
78
|
+
span.style.webkitUserSelect = 'auto';
|
|
79
|
+
span.style.userSelect = 'all'; // Add the <span> to the page
|
|
80
|
+
|
|
81
|
+
document.body.appendChild(span); // Make a selection object representing the range of text selected by the user
|
|
82
|
+
|
|
83
|
+
selection = window.getSelection();
|
|
84
|
+
range = window.document.createRange();
|
|
85
|
+
selection.removeAllRanges();
|
|
86
|
+
range.selectNode(span);
|
|
87
|
+
selection.addRange(range); // Copy text to the clipboard
|
|
88
|
+
|
|
89
|
+
success = false;
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
success = window.document.execCommand('copy');
|
|
93
|
+
} finally {
|
|
94
|
+
// Cleanup
|
|
95
|
+
selection.removeAllRanges();
|
|
96
|
+
window.document.body.removeChild(span);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (success) {
|
|
100
|
+
_context2.next = 15;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
throw makeError();
|
|
105
|
+
|
|
106
|
+
case 15:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context2.stop();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, _callee2);
|
|
112
|
+
}));
|
|
113
|
+
return _copyExecCommand.apply(this, arguments);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function copyToClipboard(_x3) {
|
|
117
|
+
return _copyToClipboard.apply(this, arguments);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function _copyToClipboard() {
|
|
121
|
+
_copyToClipboard = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(text) {
|
|
122
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
123
|
+
while (1) {
|
|
124
|
+
switch (_context3.prev = _context3.next) {
|
|
125
|
+
case 0:
|
|
126
|
+
_context3.prev = 0;
|
|
127
|
+
_context3.next = 3;
|
|
128
|
+
return copyClipboardApi(text);
|
|
129
|
+
|
|
130
|
+
case 3:
|
|
131
|
+
_context3.next = 15;
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
case 5:
|
|
135
|
+
_context3.prev = 5;
|
|
136
|
+
_context3.t0 = _context3["catch"](0);
|
|
137
|
+
_context3.prev = 7;
|
|
138
|
+
_context3.next = 10;
|
|
139
|
+
return copyExecCommand(text);
|
|
140
|
+
|
|
141
|
+
case 10:
|
|
142
|
+
_context3.next = 15;
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case 12:
|
|
146
|
+
_context3.prev = 12;
|
|
147
|
+
_context3.t1 = _context3["catch"](7);
|
|
148
|
+
throw _context3.t1 || _context3.t0 || makeError();
|
|
149
|
+
|
|
150
|
+
case 15:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context3.stop();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, _callee3, null, [[0, 5], [7, 12]]);
|
|
156
|
+
}));
|
|
157
|
+
return _copyToClipboard.apply(this, arguments);
|
|
158
|
+
}
|
|
159
|
+
|
|
23
160
|
var createNullableOnChange = function createNullableOnChange() {
|
|
24
161
|
var onChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
25
162
|
return function (newValue) {
|
|
@@ -789,7 +926,9 @@ var setValue = function setValue(value, keyParts, fieldValue) {
|
|
|
789
926
|
|
|
790
927
|
if (value !== null || fieldValue !== null) {
|
|
791
928
|
if (isArray) {
|
|
792
|
-
var index = parseInt(key, 10);
|
|
929
|
+
var index = parseInt(key, 10); // TODO: fix this with an explicit delete
|
|
930
|
+
// instead on splicing out the element on null fieldValue
|
|
931
|
+
|
|
793
932
|
var newArrayValue = fieldValue !== null ? [].concat(_toConsumableArray(value.slice(0, index)), [keyParts.length > 0 ? setValue(value !== null ? value[index] || null : null, keyParts, fieldValue) : fieldValue], _toConsumableArray(value.slice(index + 1))) : [].concat(_toConsumableArray(value.slice(0, index)), _toConsumableArray(value.slice(index + 1)));
|
|
794
933
|
return newArrayValue.length > 0 ? newArrayValue : null;
|
|
795
934
|
}
|
|
@@ -842,7 +981,7 @@ var getContrastingColor = function getContrastingColor(backgroundColor) {
|
|
|
842
981
|
color = _ref$color === void 0 ? 'white' : _ref$color;
|
|
843
982
|
|
|
844
983
|
if (tinycolor.equals(color, tinycolor('white'))) {
|
|
845
|
-
return '
|
|
984
|
+
return '#A13DFF';
|
|
846
985
|
}
|
|
847
986
|
|
|
848
987
|
if (tinycolor.equals(color, tinycolor('black'))) {
|
|
@@ -852,4 +991,4 @@ var getContrastingColor = function getContrastingColor(backgroundColor) {
|
|
|
852
991
|
return tinycolor(color).spin(30).toString();
|
|
853
992
|
};
|
|
854
993
|
|
|
855
|
-
export { convertStyleToString, createNullableOnChange, createUseEvent, getColorAsString, getComponentFromName, getContrastingColor, getDeviceScreens, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getFontFamily as getFontFamilyFromFont, getGridLayoutName, largestRemainderRound as getLargestRemainderRound, getLayersFromBackground, getLayoutParts, getMediaFilesAsArray, getOptimalImageUrl, getScreenExtraField, getSecondsFromTime, getShadowCoords, getStyleFromBorder, getStyleFromBox, getStyleFromColor, getStyleFromContainer, getStyleFromHighlight, getStyleFromImage, getStyleFromLink, getStyleFromMargin, getStyleFromText, isImageFilled, isIos, isTextFilled$1 as isLabelFilled, isMessage, isTextFilled, isValidUrl, schemaId, setValue as setFieldValue, slug, unique, validateFields };
|
|
994
|
+
export { convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, getColorAsString, getComponentFromName, getContrastingColor, getDeviceScreens, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getFontFamily as getFontFamilyFromFont, getGridLayoutName, largestRemainderRound as getLargestRemainderRound, getLayersFromBackground, getLayoutParts, getMediaFilesAsArray, getOptimalImageUrl, getScreenExtraField, getSecondsFromTime, getShadowCoords, getStyleFromBorder, getStyleFromBox, getStyleFromColor, getStyleFromContainer, getStyleFromHighlight, getStyleFromImage, getStyleFromLink, getStyleFromMargin, getStyleFromText, isImageFilled, isIos, isTextFilled$1 as isLabelFilled, isMessage, isTextFilled, isValidUrl, schemaId, setValue as setFieldValue, slug, unique, validateFields };
|
package/lib/components.js
CHANGED
|
@@ -42,6 +42,7 @@ var size = require('@folklore/size');
|
|
|
42
42
|
var faCommentDots = require('@fortawesome/free-solid-svg-icons/faCommentDots');
|
|
43
43
|
var faCheck = require('@fortawesome/free-solid-svg-icons/faCheck');
|
|
44
44
|
var faTimes = require('@fortawesome/free-solid-svg-icons/faTimes');
|
|
45
|
+
var faCircle = require('@fortawesome/free-solid-svg-icons/faCircle');
|
|
45
46
|
var faPercent = require('@fortawesome/free-solid-svg-icons/faPercent');
|
|
46
47
|
var core$1 = require('@react-spring/core');
|
|
47
48
|
var web = require('@react-spring/web');
|
|
@@ -3476,7 +3477,7 @@ var Timeline = function Timeline(props) {
|
|
|
3476
3477
|
};
|
|
3477
3478
|
|
|
3478
3479
|
/* eslint-disable react/jsx-props-no-spreading, react/destructuring-assignment, react/prop-types */
|
|
3479
|
-
var Title = function Title(props) {
|
|
3480
|
+
var Title$1 = function Title(props) {
|
|
3480
3481
|
return /*#__PURE__*/React__default["default"].createElement(PlaceholderText, Object.assign({}, props, {
|
|
3481
3482
|
className: classNames__default["default"]([props.className, styles$c.title]),
|
|
3482
3483
|
height: 0.5,
|
|
@@ -3906,6 +3907,23 @@ var Answer$1 = function Answer(_ref) {
|
|
|
3906
3907
|
})));
|
|
3907
3908
|
};
|
|
3908
3909
|
|
|
3910
|
+
var Title = function Title(props) {
|
|
3911
|
+
return /*#__PURE__*/React__default["default"].createElement(PlaceholderBlock, Object.assign({}, props, {
|
|
3912
|
+
width: "100%",
|
|
3913
|
+
height: "100%",
|
|
3914
|
+
className: classNames__default["default"]([styles$c.container, _defineProperty__default["default"]({}, props.className, props.className !== null)])
|
|
3915
|
+
}), /*#__PURE__*/React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
3916
|
+
icon: faCircle.faCircle,
|
|
3917
|
+
className: styles$c.icon
|
|
3918
|
+
}), /*#__PURE__*/React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
3919
|
+
icon: faCircle.faCircle,
|
|
3920
|
+
className: styles$c.icon
|
|
3921
|
+
}), /*#__PURE__*/React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
3922
|
+
icon: faCircle.faCircle,
|
|
3923
|
+
className: styles$c.icon
|
|
3924
|
+
}));
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3909
3927
|
var styles$2 = {"container":"micromag-core-placeholders-survey-answer-container","block":"micromag-core-placeholders-survey-answer-block","percent":"micromag-core-placeholders-survey-answer-percent","percentIcon":"micromag-core-placeholders-survey-answer-percentIcon"};
|
|
3910
3928
|
|
|
3911
3929
|
var Answer = function Answer(_ref) {
|
|
@@ -3946,12 +3964,13 @@ var Placeholders = /*#__PURE__*/Object.freeze({
|
|
|
3946
3964
|
MapPath: MapPath,
|
|
3947
3965
|
QuizAnswer: Answer$1,
|
|
3948
3966
|
Quote: Quote,
|
|
3967
|
+
ShareOptions: Title,
|
|
3949
3968
|
ShortText: ShortText,
|
|
3950
3969
|
Subtitle: Subtitle,
|
|
3951
3970
|
SurveyAnswer: Answer,
|
|
3952
3971
|
Text: TextPlaceholder,
|
|
3953
3972
|
Timeline: Timeline,
|
|
3954
|
-
Title: Title,
|
|
3973
|
+
Title: Title$1,
|
|
3955
3974
|
Video: Video,
|
|
3956
3975
|
Video360: Video360,
|
|
3957
3976
|
VideoLoop: VideoLoop
|
|
@@ -4429,7 +4448,7 @@ exports.PlaceholderShortText = ShortText;
|
|
|
4429
4448
|
exports.PlaceholderSubtitle = Subtitle;
|
|
4430
4449
|
exports.PlaceholderText = TextPlaceholder;
|
|
4431
4450
|
exports.PlaceholderTimeline = Timeline;
|
|
4432
|
-
exports.PlaceholderTitle = Title;
|
|
4451
|
+
exports.PlaceholderTitle = Title$1;
|
|
4433
4452
|
exports.PlaceholderVideo = Video;
|
|
4434
4453
|
exports.PlaceholderVideo360 = Video360;
|
|
4435
4454
|
exports.PlaceholderVideoLoop = VideoLoop;
|
package/lib/hooks.js
CHANGED
|
@@ -1089,6 +1089,29 @@ var useMediasParser = function useMediasParser() {
|
|
|
1089
1089
|
};
|
|
1090
1090
|
};
|
|
1091
1091
|
|
|
1092
|
+
function useMediaThumbnail(media) {
|
|
1093
|
+
var file = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1094
|
+
|
|
1095
|
+
var _ref = media || {},
|
|
1096
|
+
_ref$thumbnail_url = _ref.thumbnail_url,
|
|
1097
|
+
defaultThumbnailUrl = _ref$thumbnail_url === void 0 ? null : _ref$thumbnail_url,
|
|
1098
|
+
_ref$files = _ref.files,
|
|
1099
|
+
files = _ref$files === void 0 ? null : _ref$files;
|
|
1100
|
+
|
|
1101
|
+
var thumbnailUrl = react.useMemo(function () {
|
|
1102
|
+
var filesArray = utils.getMediaFilesAsArray(files) || [];
|
|
1103
|
+
|
|
1104
|
+
var _ref2 = (file !== null ? filesArray.find(function (_ref3) {
|
|
1105
|
+
var handle = _ref3.handle;
|
|
1106
|
+
return handle === file;
|
|
1107
|
+
}) || null : null) || {},
|
|
1108
|
+
url = _ref2.url;
|
|
1109
|
+
|
|
1110
|
+
return url || defaultThumbnailUrl;
|
|
1111
|
+
}, [files, file, defaultThumbnailUrl]);
|
|
1112
|
+
return thumbnailUrl;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1092
1115
|
var useParsedStory = function useParsedStory(story) {
|
|
1093
1116
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1094
1117
|
_ref$disabled = _ref.disabled,
|
|
@@ -1615,6 +1638,7 @@ exports.useIsVisible = useIsVisible;
|
|
|
1615
1638
|
exports.useLoadedFonts = useLoadedFonts;
|
|
1616
1639
|
exports.useLongPress = useLongPress;
|
|
1617
1640
|
exports.useMediaApi = useMediaApi;
|
|
1641
|
+
exports.useMediaThumbnail = useMediaThumbnail;
|
|
1618
1642
|
exports.useMediasParser = useMediasParser;
|
|
1619
1643
|
exports.useObserver = useObserver;
|
|
1620
1644
|
exports.useParsedStory = useParsedStory;
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,8 @@ var _createSuper = require('@babel/runtime/helpers/createSuper');
|
|
|
18
18
|
var EventEmitter = require('wolfy87-eventemitter');
|
|
19
19
|
require('lodash/isNumber');
|
|
20
20
|
require('param-case');
|
|
21
|
+
require('@babel/runtime/helpers/asyncToGenerator');
|
|
22
|
+
require('@babel/runtime/regenerator');
|
|
21
23
|
require('react');
|
|
22
24
|
var isString = require('lodash/isString');
|
|
23
25
|
require('tinycolor2');
|
package/lib/utils.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var isNumber = require('lodash/isNumber');
|
|
6
6
|
var paramCase = require('param-case');
|
|
7
|
+
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
8
|
+
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
7
9
|
var isObject = require('lodash/isObject');
|
|
8
10
|
var react = require('react');
|
|
9
11
|
var isString = require('lodash/isString');
|
|
@@ -20,6 +22,8 @@ var slugify = require('slugify');
|
|
|
20
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
23
|
|
|
22
24
|
var isNumber__default = /*#__PURE__*/_interopDefaultLegacy(isNumber);
|
|
25
|
+
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
26
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
23
27
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
24
28
|
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
25
29
|
var tinycolor__default = /*#__PURE__*/_interopDefaultLegacy(tinycolor);
|
|
@@ -37,6 +41,141 @@ var convertStyleToString = function convertStyleToString(style) {
|
|
|
37
41
|
}).join('\n') : '';
|
|
38
42
|
};
|
|
39
43
|
|
|
44
|
+
/*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
45
|
+
// @todo vendoring this: https://github.com/feross/clipboard-copy/blob/master/index.js
|
|
46
|
+
// we might want to add that to the npm deps and just use it?
|
|
47
|
+
function makeError() {
|
|
48
|
+
return new DOMException('The request is not allowed', 'NotAllowedError');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function copyClipboardApi(_x) {
|
|
52
|
+
return _copyClipboardApi.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _copyClipboardApi() {
|
|
56
|
+
_copyClipboardApi = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(text) {
|
|
57
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
58
|
+
while (1) {
|
|
59
|
+
switch (_context.prev = _context.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
if (navigator.clipboard) {
|
|
62
|
+
_context.next = 2;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
throw makeError();
|
|
67
|
+
|
|
68
|
+
case 2:
|
|
69
|
+
return _context.abrupt("return", navigator.clipboard.writeText(text));
|
|
70
|
+
|
|
71
|
+
case 3:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context.stop();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, _callee);
|
|
77
|
+
}));
|
|
78
|
+
return _copyClipboardApi.apply(this, arguments);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function copyExecCommand(_x2) {
|
|
82
|
+
return _copyExecCommand.apply(this, arguments);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function _copyExecCommand() {
|
|
86
|
+
_copyExecCommand = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(text) {
|
|
87
|
+
var span, selection, range, success;
|
|
88
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
89
|
+
while (1) {
|
|
90
|
+
switch (_context2.prev = _context2.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
// Put the text to copy into a <span>
|
|
93
|
+
span = document.createElement('span');
|
|
94
|
+
span.textContent = text; // Preserve consecutive spaces and newlines
|
|
95
|
+
|
|
96
|
+
span.style.whiteSpace = 'pre';
|
|
97
|
+
span.style.webkitUserSelect = 'auto';
|
|
98
|
+
span.style.userSelect = 'all'; // Add the <span> to the page
|
|
99
|
+
|
|
100
|
+
document.body.appendChild(span); // Make a selection object representing the range of text selected by the user
|
|
101
|
+
|
|
102
|
+
selection = window.getSelection();
|
|
103
|
+
range = window.document.createRange();
|
|
104
|
+
selection.removeAllRanges();
|
|
105
|
+
range.selectNode(span);
|
|
106
|
+
selection.addRange(range); // Copy text to the clipboard
|
|
107
|
+
|
|
108
|
+
success = false;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
success = window.document.execCommand('copy');
|
|
112
|
+
} finally {
|
|
113
|
+
// Cleanup
|
|
114
|
+
selection.removeAllRanges();
|
|
115
|
+
window.document.body.removeChild(span);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (success) {
|
|
119
|
+
_context2.next = 15;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
throw makeError();
|
|
124
|
+
|
|
125
|
+
case 15:
|
|
126
|
+
case "end":
|
|
127
|
+
return _context2.stop();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, _callee2);
|
|
131
|
+
}));
|
|
132
|
+
return _copyExecCommand.apply(this, arguments);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function copyToClipboard(_x3) {
|
|
136
|
+
return _copyToClipboard.apply(this, arguments);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function _copyToClipboard() {
|
|
140
|
+
_copyToClipboard = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(text) {
|
|
141
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
|
142
|
+
while (1) {
|
|
143
|
+
switch (_context3.prev = _context3.next) {
|
|
144
|
+
case 0:
|
|
145
|
+
_context3.prev = 0;
|
|
146
|
+
_context3.next = 3;
|
|
147
|
+
return copyClipboardApi(text);
|
|
148
|
+
|
|
149
|
+
case 3:
|
|
150
|
+
_context3.next = 15;
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case 5:
|
|
154
|
+
_context3.prev = 5;
|
|
155
|
+
_context3.t0 = _context3["catch"](0);
|
|
156
|
+
_context3.prev = 7;
|
|
157
|
+
_context3.next = 10;
|
|
158
|
+
return copyExecCommand(text);
|
|
159
|
+
|
|
160
|
+
case 10:
|
|
161
|
+
_context3.next = 15;
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
case 12:
|
|
165
|
+
_context3.prev = 12;
|
|
166
|
+
_context3.t1 = _context3["catch"](7);
|
|
167
|
+
throw _context3.t1 || _context3.t0 || makeError();
|
|
168
|
+
|
|
169
|
+
case 15:
|
|
170
|
+
case "end":
|
|
171
|
+
return _context3.stop();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, _callee3, null, [[0, 5], [7, 12]]);
|
|
175
|
+
}));
|
|
176
|
+
return _copyToClipboard.apply(this, arguments);
|
|
177
|
+
}
|
|
178
|
+
|
|
40
179
|
var createNullableOnChange = function createNullableOnChange() {
|
|
41
180
|
var onChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
42
181
|
return function (newValue) {
|
|
@@ -806,7 +945,9 @@ var setValue = function setValue(value, keyParts, fieldValue) {
|
|
|
806
945
|
|
|
807
946
|
if (value !== null || fieldValue !== null) {
|
|
808
947
|
if (isArray) {
|
|
809
|
-
var index = parseInt(key, 10);
|
|
948
|
+
var index = parseInt(key, 10); // TODO: fix this with an explicit delete
|
|
949
|
+
// instead on splicing out the element on null fieldValue
|
|
950
|
+
|
|
810
951
|
var newArrayValue = fieldValue !== null ? [].concat(_toConsumableArray__default["default"](value.slice(0, index)), [keyParts.length > 0 ? setValue(value !== null ? value[index] || null : null, keyParts, fieldValue) : fieldValue], _toConsumableArray__default["default"](value.slice(index + 1))) : [].concat(_toConsumableArray__default["default"](value.slice(0, index)), _toConsumableArray__default["default"](value.slice(index + 1)));
|
|
811
952
|
return newArrayValue.length > 0 ? newArrayValue : null;
|
|
812
953
|
}
|
|
@@ -859,7 +1000,7 @@ var getContrastingColor = function getContrastingColor(backgroundColor) {
|
|
|
859
1000
|
color = _ref$color === void 0 ? 'white' : _ref$color;
|
|
860
1001
|
|
|
861
1002
|
if (tinycolor__default["default"].equals(color, tinycolor__default["default"]('white'))) {
|
|
862
|
-
return '
|
|
1003
|
+
return '#A13DFF';
|
|
863
1004
|
}
|
|
864
1005
|
|
|
865
1006
|
if (tinycolor__default["default"].equals(color, tinycolor__default["default"]('black'))) {
|
|
@@ -878,6 +1019,7 @@ Object.defineProperty(exports, 'snakeCase', {
|
|
|
878
1019
|
get: function () { return changeCase.snakeCase; }
|
|
879
1020
|
});
|
|
880
1021
|
exports.convertStyleToString = convertStyleToString;
|
|
1022
|
+
exports.copyToClipboard = copyToClipboard;
|
|
881
1023
|
exports.createNullableOnChange = createNullableOnChange;
|
|
882
1024
|
exports.createUseEvent = createUseEvent;
|
|
883
1025
|
exports.getColorAsString = getColorAsString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.120",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"publishConfig": {
|
|
133
133
|
"access": "public"
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "997e92f10cf01fd5557b5c842c62bacf0babbd5a"
|
|
136
136
|
}
|