@micromag/element-text-input 0.3.673 → 0.3.679
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 +14 -2
- package/package.json +5 -4
package/es/index.js
CHANGED
|
@@ -3,7 +3,9 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { Helmet } from 'react-helmet';
|
|
6
7
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
8
|
+
import { usePlaceholderStyle } from '@micromag/core/hooks';
|
|
7
9
|
import { getStyleFromMargin, getStyleFromText, getStyleFromBox } from '@micromag/core/utils';
|
|
8
10
|
|
|
9
11
|
var styles = {"container":"micromag-element-text-input-container","element":"micromag-element-text-input-element"};
|
|
@@ -13,6 +15,7 @@ var propTypes = {
|
|
|
13
15
|
labelOutside: PropTypes.bool,
|
|
14
16
|
labelClassName: PropTypes.string,
|
|
15
17
|
textStyle: PropTypes$1.textStyle,
|
|
18
|
+
placeholderTextStyle: PropTypes$1.textStyle,
|
|
16
19
|
buttonStyle: PropTypes$1.boxStyle,
|
|
17
20
|
labelOutsideStyle: PropTypes$1.textStyle,
|
|
18
21
|
margin: PropTypes$1.margin,
|
|
@@ -31,6 +34,7 @@ var defaultProps = {
|
|
|
31
34
|
labelOutside: false,
|
|
32
35
|
labelClassName: null,
|
|
33
36
|
textStyle: null,
|
|
37
|
+
placeholderTextStyle: null,
|
|
34
38
|
buttonStyle: null,
|
|
35
39
|
labelOutsideStyle: null,
|
|
36
40
|
margin: null,
|
|
@@ -49,6 +53,7 @@ var TextInput = function TextInput(_ref) {
|
|
|
49
53
|
labelOutside = _ref.labelOutside,
|
|
50
54
|
labelClassName = _ref.labelClassName,
|
|
51
55
|
textStyle = _ref.textStyle,
|
|
56
|
+
placeholderTextStyle = _ref.placeholderTextStyle,
|
|
52
57
|
buttonStyle = _ref.buttonStyle,
|
|
53
58
|
labelOutsideStyle = _ref.labelOutsideStyle,
|
|
54
59
|
margin = _ref.margin,
|
|
@@ -64,6 +69,7 @@ var TextInput = function TextInput(_ref) {
|
|
|
64
69
|
var containerStyle = {};
|
|
65
70
|
var labelStyle = {};
|
|
66
71
|
var elementStyle = {};
|
|
72
|
+
var placeholderStyle = {};
|
|
67
73
|
if (margin !== null) {
|
|
68
74
|
containerStyle = _objectSpread(_objectSpread({}, containerStyle), getStyleFromMargin(margin));
|
|
69
75
|
}
|
|
@@ -76,6 +82,9 @@ var TextInput = function TextInput(_ref) {
|
|
|
76
82
|
if (buttonStyle !== null) {
|
|
77
83
|
elementStyle = _objectSpread(_objectSpread({}, elementStyle), getStyleFromBox(buttonStyle));
|
|
78
84
|
}
|
|
85
|
+
if (placeholderTextStyle !== null) {
|
|
86
|
+
placeholderStyle = _objectSpread(_objectSpread({}, placeholderStyle), getStyleFromText(placeholderTextStyle));
|
|
87
|
+
}
|
|
79
88
|
var containerProps = {
|
|
80
89
|
className: classNames([styles.container, _defineProperty(_defineProperty({}, className, className !== null), styles.element, !labelOutside)]),
|
|
81
90
|
style: containerStyle
|
|
@@ -92,16 +101,19 @@ var TextInput = function TextInput(_ref) {
|
|
|
92
101
|
required: required,
|
|
93
102
|
disabled: disabled
|
|
94
103
|
});
|
|
104
|
+
console.log('elementStyle', elementStyle);
|
|
95
105
|
var element = multiline ? /*#__PURE__*/React.createElement("textarea", Object.assign({}, elementProps, {
|
|
96
106
|
tabIndex: focusable ? '0' : '-1'
|
|
97
107
|
})) : /*#__PURE__*/React.createElement("input", Object.assign({}, elementProps, {
|
|
98
108
|
type: "text",
|
|
99
109
|
tabIndex: focusable ? '0' : '-1'
|
|
100
110
|
}));
|
|
101
|
-
|
|
111
|
+
var placeholderStyles = usePlaceholderStyle(styles.element, placeholderStyle);
|
|
112
|
+
var placeholderStyleElement = /*#__PURE__*/React.createElement(Helmet, null, /*#__PURE__*/React.createElement("style", null, placeholderStyles));
|
|
113
|
+
return !labelOutside ? /*#__PURE__*/React.createElement(React.Fragment, null, element, placeholderStyleElement) : /*#__PURE__*/React.createElement("label", containerProps, /*#__PURE__*/React.createElement("div", {
|
|
102
114
|
className: labelClassName,
|
|
103
115
|
style: labelStyle
|
|
104
|
-
}, label), element);
|
|
116
|
+
}, label), element, placeholderStyleElement);
|
|
105
117
|
};
|
|
106
118
|
TextInput.propTypes = propTypes;
|
|
107
119
|
TextInput.defaultProps = defaultProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-text-input",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.679",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -59,13 +59,14 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@babel/runtime": "^7.13.10",
|
|
62
|
-
"@micromag/core": "^0.3.
|
|
62
|
+
"@micromag/core": "^0.3.679",
|
|
63
63
|
"classnames": "^2.2.6",
|
|
64
|
-
"prop-types": "^15.7.2"
|
|
64
|
+
"prop-types": "^15.7.2",
|
|
65
|
+
"react-helmet": "^6.1.0"
|
|
65
66
|
},
|
|
66
67
|
"publishConfig": {
|
|
67
68
|
"access": "public",
|
|
68
69
|
"registry": "https://registry.npmjs.org/"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "ed32123e4d66d2cfe32ec1fecaf1a435e1b04bbf"
|
|
71
72
|
}
|