@commercetools-uikit/text-input 0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339
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/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/commercetools-uikit-text-input.cjs.d.ts +3 -0
- package/dist/commercetools-uikit-text-input.cjs.dev.js +108 -0
- package/dist/commercetools-uikit-text-input.cjs.js +7 -0
- package/dist/commercetools-uikit-text-input.cjs.prod.js +85 -0
- package/dist/commercetools-uikit-text-input.esm.js +89 -0
- package/dist/declarations/src/export-types.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/text-input.d.ts +82 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->
|
|
2
|
+
<!-- This file is created by the `yarn generate-readme` script. -->
|
|
3
|
+
|
|
4
|
+
# TextInput
|
|
5
|
+
|
|
6
|
+
## Description
|
|
7
|
+
|
|
8
|
+
A controlled text input component for single-line strings with validation states.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
yarn add @commercetools-uikit/text-input
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npm --save install @commercetools-uikit/text-input
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Additionally install the peer dependencies (if not present)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
yarn add react
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm --save install react
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```jsx
|
|
33
|
+
import TextInput from '@commercetools-uikit/text-input';
|
|
34
|
+
|
|
35
|
+
const Example = () => (
|
|
36
|
+
<TextInput value="foo" onChange={(event) => alert(event.target.value)} />
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export default Example;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Properties
|
|
43
|
+
|
|
44
|
+
| Props | Type | Required | Default | Description |
|
|
45
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
|
|
47
|
+
| `autoComplete` | `string` | | | Used as HTML autocomplete property |
|
|
48
|
+
| `aria-invalid` | `boolean` | | | Indicate if the value entered in the input is invalid. |
|
|
49
|
+
| `aria-errormessage` | `string` | | | HTML ID of an element containing an error message related to the input. |
|
|
50
|
+
| `className` | `string` | | | `className` forwarded to the underlying `<input />`. |
|
|
51
|
+
| `name` | `string` | | | Used as HTML name of the input component. property |
|
|
52
|
+
| `value` | `string` | ✅ | | Value of the input component. |
|
|
53
|
+
| `onChange` | `ChangeEventHandler` | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value. |
|
|
54
|
+
| `onBlur` | `FocusEventHandler` | | | Called when input is blurred |
|
|
55
|
+
| `onFocus` | `FocusEventHandler` | | | Called when input is focused |
|
|
56
|
+
| `isAutofocussed` | `boolean` | | | Focus the input on initial render |
|
|
57
|
+
| `isCondensed` | `boolean` | | | Use this property to reduce the paddings of the component for a ui compact variant |
|
|
58
|
+
| `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
|
|
59
|
+
| `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
|
|
60
|
+
| `hasError` | `boolean` | | | Indicates if the input has invalid values |
|
|
61
|
+
| `hasWarning` | `boolean` | | | |
|
|
62
|
+
| `placeholder` | `string` | | | Placeholder text for the input |
|
|
63
|
+
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
|
|
64
|
+
| `maxLength` | `number` | | | Maximum number of characters allowed in the input. If this prop is used, it is recommended to inform the user about this limit in the InputField description, or otherwise. |
|
|
65
|
+
|
|
66
|
+
## `data-*` props
|
|
67
|
+
|
|
68
|
+
The component further forwards all `data-` attributes to the underlying `input` component.
|
|
69
|
+
|
|
70
|
+
## Static methods
|
|
71
|
+
|
|
72
|
+
### `TextInput.isEmpty`
|
|
73
|
+
|
|
74
|
+
Returns `true` when the value is considered empty, which is when the value is empty or consists of spaces only.
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
TextInput.isEmpty(''); // -> true
|
|
78
|
+
TextInput.isEmpty(' '); // -> true
|
|
79
|
+
TextInput.isEmpty('tree'); // -> false
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Main Functions and use cases are:
|
|
83
|
+
|
|
84
|
+
- Input field for single-line strings
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
export { default } from "./declarations/src/index.js";
|
|
3
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy11aWtpdC10ZXh0LWlucHV0LmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
7
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
9
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
15
|
+
var _pt = require('prop-types');
|
|
16
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
17
|
+
var utils = require('@commercetools-uikit/utils');
|
|
18
|
+
var Constraints = require('@commercetools-uikit/constraints');
|
|
19
|
+
var inputUtils = require('@commercetools-uikit/input-utils');
|
|
20
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
21
|
+
|
|
22
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
23
|
+
|
|
24
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
25
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
26
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
27
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
28
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
29
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
30
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
31
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
32
|
+
var _pt__default = /*#__PURE__*/_interopDefault(_pt);
|
|
33
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
34
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
35
|
+
|
|
36
|
+
const _excluded = ["horizontalConstraint"];
|
|
37
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
39
|
+
const TextInput = _ref => {
|
|
40
|
+
let _ref$horizontalConstr = _ref.horizontalConstraint,
|
|
41
|
+
horizontalConstraint = _ref$horizontalConstr === void 0 ? 'scale' : _ref$horizontalConstr,
|
|
42
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
|
+
if (!props.isReadOnly) {
|
|
44
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof props.onChange === 'function', 'TextInput: `onChange` is required when is not read only.') : void 0;
|
|
45
|
+
}
|
|
46
|
+
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
47
|
+
max: horizontalConstraint,
|
|
48
|
+
children: jsxRuntime.jsx("input", _objectSpread(_objectSpread({
|
|
49
|
+
id: props.id,
|
|
50
|
+
name: props.name,
|
|
51
|
+
type: "text",
|
|
52
|
+
value: props.value,
|
|
53
|
+
onChange: props.onChange,
|
|
54
|
+
onBlur: props.onBlur,
|
|
55
|
+
onFocus: props.onFocus,
|
|
56
|
+
disabled: props.isDisabled,
|
|
57
|
+
placeholder: props.placeholder,
|
|
58
|
+
maxLength: props.maxLength,
|
|
59
|
+
readOnly: props.isReadOnly,
|
|
60
|
+
autoFocus: props.isAutofocussed,
|
|
61
|
+
autoComplete: props.autoComplete,
|
|
62
|
+
css: inputUtils.getInputStyles(props)
|
|
63
|
+
// Allow to override the styles by passing a `className` prop.
|
|
64
|
+
// Custom styles can also be passed using the `css` prop from emotion.
|
|
65
|
+
// https://emotion.sh/docs/css-prop#style-precedence
|
|
66
|
+
,
|
|
67
|
+
className: props.className
|
|
68
|
+
}, utils.filterDataAttributes(_objectSpread({
|
|
69
|
+
horizontalConstraint
|
|
70
|
+
}, props))), {}, {
|
|
71
|
+
/* ARIA */
|
|
72
|
+
"aria-readonly": props.isReadOnly,
|
|
73
|
+
contentEditable: !props.isReadOnly,
|
|
74
|
+
"aria-invalid": props['aria-invalid'],
|
|
75
|
+
"aria-errormessage": props['aria-errormessage']
|
|
76
|
+
}))
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
TextInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
80
|
+
id: _pt__default["default"].string,
|
|
81
|
+
autoComplete: _pt__default["default"].string,
|
|
82
|
+
'aria-invalid': _pt__default["default"].bool,
|
|
83
|
+
'aria-errormessage': _pt__default["default"].string,
|
|
84
|
+
className: _pt__default["default"].string,
|
|
85
|
+
name: _pt__default["default"].string,
|
|
86
|
+
value: _pt__default["default"].string.isRequired,
|
|
87
|
+
onChange: _pt__default["default"].func,
|
|
88
|
+
onBlur: _pt__default["default"].func,
|
|
89
|
+
onFocus: _pt__default["default"].func,
|
|
90
|
+
isAutofocussed: _pt__default["default"].bool,
|
|
91
|
+
isCondensed: _pt__default["default"].bool,
|
|
92
|
+
isDisabled: _pt__default["default"].bool,
|
|
93
|
+
isReadOnly: _pt__default["default"].bool,
|
|
94
|
+
hasError: _pt__default["default"].bool,
|
|
95
|
+
hasWarning: _pt__default["default"].bool,
|
|
96
|
+
placeholder: _pt__default["default"].string,
|
|
97
|
+
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
98
|
+
maxLength: _pt__default["default"].number
|
|
99
|
+
} : {};
|
|
100
|
+
TextInput.displayName = 'TextInput';
|
|
101
|
+
TextInput.isEmpty = value => !value || _trimInstanceProperty__default["default"](value).call(value).length === 0;
|
|
102
|
+
var TextInput$1 = TextInput;
|
|
103
|
+
|
|
104
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
105
|
+
var version = "19.25.1";
|
|
106
|
+
|
|
107
|
+
exports["default"] = TextInput$1;
|
|
108
|
+
exports.version = version;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
7
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
9
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
15
|
+
require('prop-types');
|
|
16
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
17
|
+
var utils = require('@commercetools-uikit/utils');
|
|
18
|
+
var Constraints = require('@commercetools-uikit/constraints');
|
|
19
|
+
var inputUtils = require('@commercetools-uikit/input-utils');
|
|
20
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
21
|
+
|
|
22
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
23
|
+
|
|
24
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
25
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
26
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
27
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
28
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
29
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
30
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
31
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
32
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
33
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
34
|
+
|
|
35
|
+
const _excluded = ["horizontalConstraint"];
|
|
36
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
37
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
38
|
+
const TextInput = _ref => {
|
|
39
|
+
let _ref$horizontalConstr = _ref.horizontalConstraint,
|
|
40
|
+
horizontalConstraint = _ref$horizontalConstr === void 0 ? 'scale' : _ref$horizontalConstr,
|
|
41
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
42
|
+
if (!props.isReadOnly) ;
|
|
43
|
+
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
44
|
+
max: horizontalConstraint,
|
|
45
|
+
children: jsxRuntime.jsx("input", _objectSpread(_objectSpread({
|
|
46
|
+
id: props.id,
|
|
47
|
+
name: props.name,
|
|
48
|
+
type: "text",
|
|
49
|
+
value: props.value,
|
|
50
|
+
onChange: props.onChange,
|
|
51
|
+
onBlur: props.onBlur,
|
|
52
|
+
onFocus: props.onFocus,
|
|
53
|
+
disabled: props.isDisabled,
|
|
54
|
+
placeholder: props.placeholder,
|
|
55
|
+
maxLength: props.maxLength,
|
|
56
|
+
readOnly: props.isReadOnly,
|
|
57
|
+
autoFocus: props.isAutofocussed,
|
|
58
|
+
autoComplete: props.autoComplete,
|
|
59
|
+
css: inputUtils.getInputStyles(props)
|
|
60
|
+
// Allow to override the styles by passing a `className` prop.
|
|
61
|
+
// Custom styles can also be passed using the `css` prop from emotion.
|
|
62
|
+
// https://emotion.sh/docs/css-prop#style-precedence
|
|
63
|
+
,
|
|
64
|
+
className: props.className
|
|
65
|
+
}, utils.filterDataAttributes(_objectSpread({
|
|
66
|
+
horizontalConstraint
|
|
67
|
+
}, props))), {}, {
|
|
68
|
+
/* ARIA */
|
|
69
|
+
"aria-readonly": props.isReadOnly,
|
|
70
|
+
contentEditable: !props.isReadOnly,
|
|
71
|
+
"aria-invalid": props['aria-invalid'],
|
|
72
|
+
"aria-errormessage": props['aria-errormessage']
|
|
73
|
+
}))
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
TextInput.propTypes = {};
|
|
77
|
+
TextInput.displayName = 'TextInput';
|
|
78
|
+
TextInput.isEmpty = value => !value || _trimInstanceProperty__default["default"](value).call(value).length === 0;
|
|
79
|
+
var TextInput$1 = TextInput;
|
|
80
|
+
|
|
81
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
82
|
+
var version = "19.25.1";
|
|
83
|
+
|
|
84
|
+
exports["default"] = TextInput$1;
|
|
85
|
+
exports.version = version;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
4
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
5
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
6
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
|
|
11
|
+
import _pt from 'prop-types';
|
|
12
|
+
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
13
|
+
import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
|
|
14
|
+
import Constraints from '@commercetools-uikit/constraints';
|
|
15
|
+
import { getInputStyles } from '@commercetools-uikit/input-utils';
|
|
16
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
17
|
+
|
|
18
|
+
const _excluded = ["horizontalConstraint"];
|
|
19
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
+
const TextInput = _ref => {
|
|
22
|
+
let _ref$horizontalConstr = _ref.horizontalConstraint,
|
|
23
|
+
horizontalConstraint = _ref$horizontalConstr === void 0 ? 'scale' : _ref$horizontalConstr,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
if (!props.isReadOnly) {
|
|
26
|
+
process.env.NODE_ENV !== "production" ? warning(typeof props.onChange === 'function', 'TextInput: `onChange` is required when is not read only.') : void 0;
|
|
27
|
+
}
|
|
28
|
+
return jsx(Constraints.Horizontal, {
|
|
29
|
+
max: horizontalConstraint,
|
|
30
|
+
children: jsx("input", _objectSpread(_objectSpread({
|
|
31
|
+
id: props.id,
|
|
32
|
+
name: props.name,
|
|
33
|
+
type: "text",
|
|
34
|
+
value: props.value,
|
|
35
|
+
onChange: props.onChange,
|
|
36
|
+
onBlur: props.onBlur,
|
|
37
|
+
onFocus: props.onFocus,
|
|
38
|
+
disabled: props.isDisabled,
|
|
39
|
+
placeholder: props.placeholder,
|
|
40
|
+
maxLength: props.maxLength,
|
|
41
|
+
readOnly: props.isReadOnly,
|
|
42
|
+
autoFocus: props.isAutofocussed,
|
|
43
|
+
autoComplete: props.autoComplete,
|
|
44
|
+
css: getInputStyles(props)
|
|
45
|
+
// Allow to override the styles by passing a `className` prop.
|
|
46
|
+
// Custom styles can also be passed using the `css` prop from emotion.
|
|
47
|
+
// https://emotion.sh/docs/css-prop#style-precedence
|
|
48
|
+
,
|
|
49
|
+
className: props.className
|
|
50
|
+
}, filterDataAttributes(_objectSpread({
|
|
51
|
+
horizontalConstraint
|
|
52
|
+
}, props))), {}, {
|
|
53
|
+
/* ARIA */
|
|
54
|
+
"aria-readonly": props.isReadOnly,
|
|
55
|
+
contentEditable: !props.isReadOnly,
|
|
56
|
+
"aria-invalid": props['aria-invalid'],
|
|
57
|
+
"aria-errormessage": props['aria-errormessage']
|
|
58
|
+
}))
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
TextInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
62
|
+
id: _pt.string,
|
|
63
|
+
autoComplete: _pt.string,
|
|
64
|
+
'aria-invalid': _pt.bool,
|
|
65
|
+
'aria-errormessage': _pt.string,
|
|
66
|
+
className: _pt.string,
|
|
67
|
+
name: _pt.string,
|
|
68
|
+
value: _pt.string.isRequired,
|
|
69
|
+
onChange: _pt.func,
|
|
70
|
+
onBlur: _pt.func,
|
|
71
|
+
onFocus: _pt.func,
|
|
72
|
+
isAutofocussed: _pt.bool,
|
|
73
|
+
isCondensed: _pt.bool,
|
|
74
|
+
isDisabled: _pt.bool,
|
|
75
|
+
isReadOnly: _pt.bool,
|
|
76
|
+
hasError: _pt.bool,
|
|
77
|
+
hasWarning: _pt.bool,
|
|
78
|
+
placeholder: _pt.string,
|
|
79
|
+
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
80
|
+
maxLength: _pt.number
|
|
81
|
+
} : {};
|
|
82
|
+
TextInput.displayName = 'TextInput';
|
|
83
|
+
TextInput.isEmpty = value => !value || _trimInstanceProperty(value).call(value).length === 0;
|
|
84
|
+
var TextInput$1 = TextInput;
|
|
85
|
+
|
|
86
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
87
|
+
var version = "19.25.1";
|
|
88
|
+
|
|
89
|
+
export { TextInput$1 as default, version };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { TTextInputProps } from "./text-input.js";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { FocusEventHandler, ChangeEventHandler } from 'react';
|
|
2
|
+
export type TTextInputProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Used as HTML id property. An id is auto-generated when it is not specified.
|
|
5
|
+
*/
|
|
6
|
+
id?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Used as HTML autocomplete property
|
|
9
|
+
*/
|
|
10
|
+
autoComplete?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Indicate if the value entered in the input is invalid.
|
|
13
|
+
*/
|
|
14
|
+
'aria-invalid'?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* HTML ID of an element containing an error message related to the input.
|
|
17
|
+
*/
|
|
18
|
+
'aria-errormessage'?: string;
|
|
19
|
+
/**
|
|
20
|
+
* `className` forwarded to the underlying `<input />`.
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Used as HTML name of the input component. property
|
|
25
|
+
*/
|
|
26
|
+
name?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Value of the input component.
|
|
29
|
+
*/
|
|
30
|
+
value: string;
|
|
31
|
+
/**
|
|
32
|
+
* Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
|
|
33
|
+
*/
|
|
34
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
35
|
+
/**
|
|
36
|
+
* Called when input is blurred
|
|
37
|
+
*/
|
|
38
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
39
|
+
/**
|
|
40
|
+
* Called when input is focused
|
|
41
|
+
*/
|
|
42
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
43
|
+
/**
|
|
44
|
+
* Focus the input on initial render
|
|
45
|
+
*/
|
|
46
|
+
isAutofocussed?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Use this property to reduce the paddings of the component for a ui compact variant
|
|
49
|
+
*/
|
|
50
|
+
isCondensed?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
|
|
53
|
+
*/
|
|
54
|
+
isDisabled?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Indicates that the field is displaying read-only content
|
|
57
|
+
*/
|
|
58
|
+
isReadOnly?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Indicates if the input has invalid values
|
|
61
|
+
*/
|
|
62
|
+
hasError?: boolean;
|
|
63
|
+
hasWarning?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Placeholder text for the input
|
|
66
|
+
*/
|
|
67
|
+
placeholder?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Horizontal size limit of the input fields.
|
|
70
|
+
*/
|
|
71
|
+
horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
72
|
+
/**
|
|
73
|
+
* Maximum number of characters allowed in the input. If this prop is used, it is recommended to inform the user about this limit in the InputField description, or otherwise.
|
|
74
|
+
*/
|
|
75
|
+
maxLength?: number;
|
|
76
|
+
};
|
|
77
|
+
declare const TextInput: {
|
|
78
|
+
({ horizontalConstraint, ...props }: TTextInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
79
|
+
displayName: string;
|
|
80
|
+
isEmpty(value: TTextInputProps["value"]): boolean;
|
|
81
|
+
};
|
|
82
|
+
export default TextInput;
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@commercetools-uikit/text-input",
|
|
3
|
+
"description": "A controlled text input component for single-line strings with validation states.",
|
|
4
|
+
"version": "0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339",
|
|
5
|
+
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/commercetools/ui-kit.git",
|
|
9
|
+
"directory": "packages/components/inputs/text-input"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://uikit.commercetools.com",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"javascript",
|
|
14
|
+
"typescript",
|
|
15
|
+
"design-system",
|
|
16
|
+
"react",
|
|
17
|
+
"uikit"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "dist/commercetools-uikit-text-input.cjs.js",
|
|
25
|
+
"module": "dist/commercetools-uikit-text-input.esm.js",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@babel/runtime": "^7.20.13",
|
|
31
|
+
"@babel/runtime-corejs3": "^7.20.13",
|
|
32
|
+
"@commercetools-uikit/constraints": "0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339",
|
|
33
|
+
"@commercetools-uikit/design-system": "0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339",
|
|
34
|
+
"@commercetools-uikit/input-utils": "0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339",
|
|
35
|
+
"@commercetools-uikit/utils": "0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339",
|
|
36
|
+
"@emotion/react": "^11.10.5",
|
|
37
|
+
"@emotion/styled": "^11.10.5",
|
|
38
|
+
"prop-types": "15.8.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"react": "17.0.2"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "17.x"
|
|
45
|
+
}
|
|
46
|
+
}
|