@micromag/element-button 0.3.814 → 0.3.823

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.
@@ -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
- buttonProps = _objectWithoutProperties(_ref, _excluded);
56
- var finalStyles = null;
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,142 @@ 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
+ return /*#__PURE__*/React.createElement(Tag, Object.assign({
198
+ type: type,
199
+ textStyle: textStyle,
200
+ buttonStyle: buttonStyle,
201
+ disabled: disabled,
202
+ focusable: focusable,
203
+ inline: inline,
204
+ onClick: onClick,
205
+ 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)]),
206
+ withoutExternalBorder: withoutExternalBorder,
207
+ refButton: refButton
208
+ }, otherProps), /*#__PURE__*/React.createElement(ScreenElement, {
209
+ placeholder: "button",
210
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
211
+ id: "bv3rRe",
212
+ defaultMessage: [{
213
+ "type": 0,
214
+ "value": "Button"
215
+ }]
216
+ }),
217
+ emptyClassName: styles.emptyButton,
218
+ isEmpty: !hasVisual && !hasBody
219
+ }, hasVisual ? /*#__PURE__*/React.createElement(Visual, {
220
+ media: visual,
221
+ width: visualWidth || defaultWidth,
222
+ resolution: resolution,
223
+ shouldLoad: shouldLoad,
224
+ className: classNames([styles.visual, _defineProperty({}, visualClassName, visualClassName !== null)]),
225
+ imageClassName: classNames([styles.image, _defineProperty({}, imageClassName, imageClassName !== null)]),
226
+ videoClassName: classNames([styles.video, _defineProperty({}, videoClassName, videoClassName !== null)])
227
+ }) : null, hasBody && showLabel ? /*#__PURE__*/React.createElement(Text, Object.assign({
228
+ boxStyle: labelBoxStyle
229
+ }, label, {
230
+ className: classNames([styles.text, _defineProperty({}, textClassName, textClassName !== null)])
231
+ })) : null, children));
232
+ };
233
+ RichButton.propTypes = propTypes;
234
+ RichButton.defaultProps = defaultProps;
93
235
 
94
- export { Button as default };
236
+ 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.814",
3
+ "version": "0.3.823",
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.814",
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": "96d19c8ede8dc2e8c051ba118975258e061a8da2"
74
+ "gitHead": "efd3562981f1148d707bf567cce77142350f59f5"
73
75
  }