@micromag/element-button 0.3.813 → 0.3.820
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/assets/css/styles.css +1 -1
- package/es/index.js +158 -13
- package/package.json +5 -3
package/assets/css/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.micromag-element-button-container{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;background-clip:padding-box;background-color:hsla(0,0%,100%,.1);border:0;border-radius:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;padding:0;padding:5px 10px;position:relative}.micromag-element-button-container:focus-visible{-webkit-box-shadow:0 0 2px 0 #fff!important;box-shadow:0 0 2px 0 #fff!important;-webkit-box-shadow:0 0 2px 0 var(--micromag-focus-color,#fff)!important;box-shadow:0 0 2px 0 var(--micromag-focus-color,#fff)!important;outline:2px solid #000!important}.micromag-element-button-container.micromag-element-button-disabled,.micromag-element-button-container:disabled{cursor:auto}.micromag-element-button-border{display:block}
|
|
1
|
+
.micromag-element-button-container{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;background-clip:padding-box;background-color:hsla(0,0%,100%,.1);border:0;border-radius:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;padding:0;padding:5px 10px;position:relative}.micromag-element-button-container:focus-visible{-webkit-box-shadow:0 0 2px 0 #fff!important;box-shadow:0 0 2px 0 #fff!important;-webkit-box-shadow:0 0 2px 0 var(--micromag-focus-color,#fff)!important;box-shadow:0 0 2px 0 var(--micromag-focus-color,#fff)!important;outline:2px solid #000!important}.micromag-element-button-container.micromag-element-button-disabled,.micromag-element-button-container:disabled{cursor:auto}.micromag-element-button-container.micromag-element-button-rich{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:10px}.micromag-element-button-container.micromag-element-button-rich.micromag-element-button-layoutLabelBottom{-ms-flex-direction:column;flex-direction:column}.micromag-element-button-container.micromag-element-button-rich.micromag-element-button-layoutLabelTop{-ms-flex-direction:column-reverse;flex-direction:column-reverse}.micromag-element-button-container.micromag-element-button-rich.micromag-element-button-layoutNoLabel{-ms-flex-direction:row;flex-direction:row}.micromag-element-button-container.micromag-element-button-rich.micromag-element-button-layoutLabelLeft{-ms-flex-direction:row-reverse;flex-direction:row-reverse}.micromag-element-button-container.micromag-element-button-rich.micromag-element-button-layoutLabelOver{position:relative}.micromag-element-button-container.micromag-element-button-rich.micromag-element-button-layoutLabelOver .micromag-element-button-text{background:-webkit-gradient(linear,left bottom,left top,from(rgba(0,0,0,.7)),to(transparent));background:linear-gradient(0deg,rgba(0,0,0,.7),transparent);bottom:0;left:0;padding:10px;position:absolute;right:0}.micromag-element-button-emptyButton{padding:10px 5px}.micromag-element-button-border{display:block}.micromag-element-button-visual{-ms-flex-positive:1;flex-grow:1;-ms-flex-negative:0;flex-shrink:0;overflow:auto}.micromag-element-button-video{position:relative!important}
|
package/es/index.js
CHANGED
|
@@ -3,16 +3,19 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import React from 'react';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
7
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
8
|
-
import { Button as Button$1 } from '@micromag/core/components';
|
|
8
|
+
import { Button as Button$1, ScreenElement } from '@micromag/core/components';
|
|
9
9
|
import { getStyleFromText, getStyleFromBox } from '@micromag/core/utils';
|
|
10
|
+
import { FormattedMessage } from 'react-intl';
|
|
11
|
+
import Text from '@micromag/element-text';
|
|
12
|
+
import Visual from '@micromag/element-visual';
|
|
10
13
|
|
|
11
|
-
var styles = {"container":"micromag-element-button-container"};
|
|
14
|
+
var styles = {"container":"micromag-element-button-container","rich":"micromag-element-button-rich","layoutLabelBottom":"micromag-element-button-layoutLabelBottom","layoutLabelTop":"micromag-element-button-layoutLabelTop","layoutNoLabel":"micromag-element-button-layoutNoLabel","layoutLabelLeft":"micromag-element-button-layoutLabelLeft","layoutLabelOver":"micromag-element-button-layoutLabelOver","text":"micromag-element-button-text","emptyButton":"micromag-element-button-emptyButton","visual":"micromag-element-button-visual","video":"micromag-element-button-video"};
|
|
12
15
|
|
|
13
|
-
var _excluded = ["textStyle", "buttonStyle", "type", "disabled", "focusable", "inline", "onClick", "children", "className", "withoutExternalBorder", "refButton"],
|
|
16
|
+
var _excluded$1 = ["textStyle", "buttonStyle", "type", "disabled", "focusable", "inline", "onClick", "children", "className", "withoutExternalBorder", "refButton", "style"],
|
|
14
17
|
_excluded2 = ["body"];
|
|
15
|
-
var propTypes = {
|
|
18
|
+
var propTypes$1 = {
|
|
16
19
|
textStyle: PropTypes$1.textStyle,
|
|
17
20
|
buttonStyle: PropTypes$1.boxStyle,
|
|
18
21
|
type: PropTypes.oneOf(['button', 'submit']),
|
|
@@ -25,9 +28,10 @@ var propTypes = {
|
|
|
25
28
|
withoutExternalBorder: PropTypes.bool,
|
|
26
29
|
refButton: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
27
30
|
current: PropTypes.any // eslint-disable-line
|
|
28
|
-
})])
|
|
31
|
+
})]),
|
|
32
|
+
style: PropTypes.object // eslint-disable-line
|
|
29
33
|
};
|
|
30
|
-
var defaultProps = {
|
|
34
|
+
var defaultProps$1 = {
|
|
31
35
|
textStyle: null,
|
|
32
36
|
buttonStyle: null,
|
|
33
37
|
type: 'button',
|
|
@@ -38,7 +42,8 @@ var defaultProps = {
|
|
|
38
42
|
children: null,
|
|
39
43
|
className: null,
|
|
40
44
|
withoutExternalBorder: true,
|
|
41
|
-
refButton: null
|
|
45
|
+
refButton: null,
|
|
46
|
+
style: null
|
|
42
47
|
};
|
|
43
48
|
var Button = function Button(_ref) {
|
|
44
49
|
var textStyle = _ref.textStyle,
|
|
@@ -52,8 +57,10 @@ var Button = function Button(_ref) {
|
|
|
52
57
|
className = _ref.className,
|
|
53
58
|
withoutExternalBorder = _ref.withoutExternalBorder,
|
|
54
59
|
refButton = _ref.refButton,
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
style = _ref.style,
|
|
61
|
+
buttonProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
62
|
+
var finalStyles = style;
|
|
63
|
+
|
|
57
64
|
// eslint-disable-next-line no-unused-vars
|
|
58
65
|
var _ref2 = buttonProps || {};
|
|
59
66
|
_ref2.body;
|
|
@@ -88,7 +95,145 @@ var Button = function Button(_ref) {
|
|
|
88
95
|
withoutBootstrapStyles: true
|
|
89
96
|
}, otherProps), children);
|
|
90
97
|
};
|
|
91
|
-
Button.propTypes = propTypes;
|
|
92
|
-
Button.defaultProps = defaultProps;
|
|
98
|
+
Button.propTypes = propTypes$1;
|
|
99
|
+
Button.defaultProps = defaultProps$1;
|
|
100
|
+
|
|
101
|
+
var _excluded = ["label", "visual", "visualWidth", "labelBoxStyle", "textStyle", "buttonStyle", "resolution", "shouldLoad", "layout", "type", "disabled", "focusable", "inline", "onClick", "className", "textClassName", "visualClassName", "imageClassName", "videoClassName", "withoutExternalBorder", "refButton", "children"];
|
|
102
|
+
var propTypes = {
|
|
103
|
+
label: PropTypes$1.textElement,
|
|
104
|
+
visual: PropTypes$1.media,
|
|
105
|
+
visualWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
106
|
+
labelBoxStyle: PropTypes$1.boxStyle,
|
|
107
|
+
textStyle: PropTypes$1.textStyle,
|
|
108
|
+
buttonStyle: PropTypes$1.boxStyle,
|
|
109
|
+
resolution: PropTypes.number,
|
|
110
|
+
shouldLoad: PropTypes.bool,
|
|
111
|
+
layout: PropTypes.oneOf(['label-bottom', 'label-top', 'no-label', 'label-over', 'label-right']),
|
|
112
|
+
type: PropTypes.oneOf(['button', 'submit']),
|
|
113
|
+
disabled: PropTypes.bool,
|
|
114
|
+
focusable: PropTypes.bool,
|
|
115
|
+
inline: PropTypes.bool,
|
|
116
|
+
onClick: PropTypes.func,
|
|
117
|
+
className: PropTypes.string,
|
|
118
|
+
textClassName: PropTypes.string,
|
|
119
|
+
imageClassName: PropTypes.string,
|
|
120
|
+
videoClassName: PropTypes.string,
|
|
121
|
+
visualClassName: PropTypes.string,
|
|
122
|
+
withoutExternalBorder: PropTypes.bool,
|
|
123
|
+
refButton: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
124
|
+
current: PropTypes.any // eslint-disable-line
|
|
125
|
+
})]),
|
|
126
|
+
children: PropTypes.node
|
|
127
|
+
};
|
|
128
|
+
var defaultProps = {
|
|
129
|
+
label: null,
|
|
130
|
+
visual: null,
|
|
131
|
+
visualWidth: null,
|
|
132
|
+
labelBoxStyle: null,
|
|
133
|
+
textStyle: null,
|
|
134
|
+
buttonStyle: null,
|
|
135
|
+
resolution: null,
|
|
136
|
+
shouldLoad: true,
|
|
137
|
+
layout: 'label-bottom',
|
|
138
|
+
type: 'button',
|
|
139
|
+
disabled: false,
|
|
140
|
+
focusable: true,
|
|
141
|
+
inline: false,
|
|
142
|
+
onClick: null,
|
|
143
|
+
className: null,
|
|
144
|
+
textClassName: null,
|
|
145
|
+
imageClassName: null,
|
|
146
|
+
videoClassName: null,
|
|
147
|
+
visualClassName: null,
|
|
148
|
+
withoutExternalBorder: true,
|
|
149
|
+
refButton: null,
|
|
150
|
+
children: null
|
|
151
|
+
};
|
|
152
|
+
var RichButton = function RichButton(_ref) {
|
|
153
|
+
var label = _ref.label,
|
|
154
|
+
visual = _ref.visual,
|
|
155
|
+
visualWidth = _ref.visualWidth,
|
|
156
|
+
labelBoxStyle = _ref.labelBoxStyle,
|
|
157
|
+
textStyle = _ref.textStyle,
|
|
158
|
+
buttonStyle = _ref.buttonStyle,
|
|
159
|
+
resolution = _ref.resolution,
|
|
160
|
+
shouldLoad = _ref.shouldLoad,
|
|
161
|
+
layout = _ref.layout,
|
|
162
|
+
type = _ref.type,
|
|
163
|
+
disabled = _ref.disabled,
|
|
164
|
+
focusable = _ref.focusable,
|
|
165
|
+
inline = _ref.inline,
|
|
166
|
+
onClick = _ref.onClick,
|
|
167
|
+
className = _ref.className,
|
|
168
|
+
textClassName = _ref.textClassName,
|
|
169
|
+
visualClassName = _ref.visualClassName,
|
|
170
|
+
imageClassName = _ref.imageClassName,
|
|
171
|
+
videoClassName = _ref.videoClassName,
|
|
172
|
+
withoutExternalBorder = _ref.withoutExternalBorder,
|
|
173
|
+
refButton = _ref.refButton,
|
|
174
|
+
children = _ref.children,
|
|
175
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
176
|
+
var Tag = useMemo(function () {
|
|
177
|
+
switch (type) {
|
|
178
|
+
case 'submit':
|
|
179
|
+
return Button;
|
|
180
|
+
case 'button':
|
|
181
|
+
return Button;
|
|
182
|
+
default:
|
|
183
|
+
return 'div';
|
|
184
|
+
}
|
|
185
|
+
}, [type]);
|
|
186
|
+
var _ref2 = visual || {},
|
|
187
|
+
_ref2$url = _ref2.url,
|
|
188
|
+
visualUrl = _ref2$url === void 0 ? null : _ref2$url;
|
|
189
|
+
var hasVisual = visualUrl !== null;
|
|
190
|
+
var _ref3 = label || {},
|
|
191
|
+
_ref3$body = _ref3.body,
|
|
192
|
+
body = _ref3$body === void 0 ? null : _ref3$body;
|
|
193
|
+
var hasBody = body !== null && body.trim() !== '';
|
|
194
|
+
var showLabel = layout !== 'no-label';
|
|
195
|
+
var defaultWidth = (layout === 'label-left' || layout === 'label-right') && hasBody && hasVisual ? '30%' : '100%';
|
|
196
|
+
var finalLayout = hasVisual ? layout : null;
|
|
197
|
+
|
|
198
|
+
// console.log('finalLayout', finalLayout);
|
|
199
|
+
|
|
200
|
+
return /*#__PURE__*/React.createElement(Tag, Object.assign({
|
|
201
|
+
type: type,
|
|
202
|
+
textStyle: textStyle,
|
|
203
|
+
buttonStyle: buttonStyle,
|
|
204
|
+
disabled: disabled,
|
|
205
|
+
focusable: focusable,
|
|
206
|
+
inline: inline,
|
|
207
|
+
onClick: onClick,
|
|
208
|
+
className: classNames([styles.container, styles.rich, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.layoutLabelBottom, finalLayout === 'label-bottom'), styles.layoutLabelTop, finalLayout === 'label-top'), styles.layoutNoLabel, finalLayout === 'no-label'), styles.layoutLabelOver, finalLayout === 'label-over'), styles.layoutLabelLeft, finalLayout === 'label-left'), className, className !== null)]),
|
|
209
|
+
withoutExternalBorder: withoutExternalBorder,
|
|
210
|
+
refButton: refButton
|
|
211
|
+
}, otherProps), /*#__PURE__*/React.createElement(ScreenElement, {
|
|
212
|
+
placeholder: "button",
|
|
213
|
+
emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
214
|
+
id: "bv3rRe",
|
|
215
|
+
defaultMessage: [{
|
|
216
|
+
"type": 0,
|
|
217
|
+
"value": "Button"
|
|
218
|
+
}]
|
|
219
|
+
}),
|
|
220
|
+
emptyClassName: styles.emptyButton,
|
|
221
|
+
isEmpty: !hasVisual && !hasBody
|
|
222
|
+
}, hasVisual ? /*#__PURE__*/React.createElement(Visual, {
|
|
223
|
+
media: visual,
|
|
224
|
+
width: visualWidth || defaultWidth,
|
|
225
|
+
resolution: resolution,
|
|
226
|
+
shouldLoad: shouldLoad,
|
|
227
|
+
className: classNames([styles.visual, _defineProperty({}, visualClassName, visualClassName !== null)]),
|
|
228
|
+
imageClassName: classNames([styles.image, _defineProperty({}, imageClassName, imageClassName !== null)]),
|
|
229
|
+
videoClassName: classNames([styles.video, _defineProperty({}, videoClassName, videoClassName !== null)])
|
|
230
|
+
}) : null, hasBody && showLabel ? /*#__PURE__*/React.createElement(Text, Object.assign({
|
|
231
|
+
boxStyle: labelBoxStyle
|
|
232
|
+
}, label, {
|
|
233
|
+
className: classNames([styles.text, _defineProperty({}, textClassName, textClassName !== null)])
|
|
234
|
+
})) : null, children));
|
|
235
|
+
};
|
|
236
|
+
RichButton.propTypes = propTypes;
|
|
237
|
+
RichButton.defaultProps = defaultProps;
|
|
93
238
|
|
|
94
|
-
export { Button as default };
|
|
239
|
+
export { RichButton, Button as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-button",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.820",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -59,7 +59,9 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@babel/runtime": "^7.13.10",
|
|
62
|
-
"@micromag/core": "^0.3.
|
|
62
|
+
"@micromag/core": "^0.3.820",
|
|
63
|
+
"@micromag/element-text": "^0.3.820",
|
|
64
|
+
"@micromag/element-visual": "^0.3.820",
|
|
63
65
|
"classnames": "^2.2.6",
|
|
64
66
|
"prop-types": "^15.7.2",
|
|
65
67
|
"react-intl": "^6.6.4",
|
|
@@ -69,5 +71,5 @@
|
|
|
69
71
|
"access": "public",
|
|
70
72
|
"registry": "https://registry.npmjs.org/"
|
|
71
73
|
},
|
|
72
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "c4ef0ae4055720a367551328e824ad3b111e4c9f"
|
|
73
75
|
}
|