@pingux/astro 2.46.0-alpha.0 → 2.46.0-alpha.1
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/lib/cjs/components/Input/Input.d.ts +4 -0
- package/lib/cjs/components/Input/Input.js +13 -21
- package/lib/cjs/components/Input/Input.stories.d.ts +20 -0
- package/lib/cjs/components/Input/Input.styles.d.ts +8 -0
- package/lib/cjs/components/Input/Input.styles.js +0 -1
- package/lib/cjs/components/Input/Input.test.d.ts +1 -0
- package/lib/cjs/components/Input/Input.test.js +2 -10
- package/lib/cjs/components/Input/index.d.ts +1 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +24 -13
- package/lib/cjs/types/input.d.ts +18 -0
- package/lib/cjs/types/input.js +6 -0
- package/lib/cjs/types/shared/index.d.ts +1 -0
- package/lib/cjs/types/shared/index.js +12 -1
- package/lib/cjs/types/shared/validPositiveInteger.d.ts +4 -0
- package/lib/cjs/types/shared/validPositiveInteger.js +6 -0
- package/lib/components/Input/Input.js +12 -20
- package/lib/components/Input/Input.styles.js +0 -1
- package/lib/components/Input/Input.test.js +2 -10
- package/lib/types/index.js +1 -0
- package/lib/types/input.js +1 -0
- package/lib/types/shared/index.js +2 -1
- package/lib/types/shared/validPositiveInteger.js +1 -0
- package/package.json +1 -1
@@ -9,15 +9,16 @@ _Object$defineProperty(exports, "__esModule", {
|
|
9
9
|
value: true
|
10
10
|
});
|
11
11
|
exports["default"] = void 0;
|
12
|
-
var _isInteger = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
|
13
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
14
13
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
14
|
+
var _base = _interopRequireDefault(require("@emotion/styled/base"));
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
16
|
-
var
|
16
|
+
var _styledSystem = require("styled-system");
|
17
17
|
var _themeUi = require("theme-ui");
|
18
|
-
var _isValidPositiveInt = _interopRequireDefault(require("../../utils/devUtils/props/isValidPositiveInt"));
|
19
18
|
var _react2 = require("@emotion/react");
|
20
19
|
var _excluded = ["name", "placeholder", "maxLength"];
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21
22
|
/**
|
22
23
|
* Base input component.
|
23
24
|
*
|
@@ -28,34 +29,25 @@ var _excluded = ["name", "placeholder", "maxLength"];
|
|
28
29
|
* We instead encourage developers to utilize our Field components wherever possible.
|
29
30
|
* If this component is used, accessibility is left to the developer.
|
30
31
|
*/
|
31
|
-
|
32
|
-
|
32
|
+
|
33
|
+
var ExtendedInput = /*#__PURE__*/(0, _base["default"])(_themeUi.Input, process.env.NODE_ENV === "production" ? {
|
34
|
+
target: "e1lpwkt50"
|
35
|
+
} : {
|
36
|
+
target: "e1lpwkt50",
|
37
|
+
label: "ExtendedInput"
|
38
|
+
})(_styledSystem.layout, _styledSystem.flexbox, _styledSystem.typography, process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0lucHV0L0lucHV0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpQnNCIiwiZmlsZSI6Ii4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0lucHV0L0lucHV0LnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCwgeyBmb3J3YXJkUmVmIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgZmxleGJveCwgbGF5b3V0LCB0eXBvZ3JhcGh5IH0gZnJvbSAnc3R5bGVkLXN5c3RlbSc7XG5pbXBvcnQgeyBJbnB1dCBhcyBUaGVtZVVJSW5wdXQgfSBmcm9tICd0aGVtZS11aSc7XG5cbmltcG9ydCB7IElucHV0UHJvcHMgfSBmcm9tICcuLi8uLi90eXBlcyc7XG4vKipcbiAqIEJhc2UgaW5wdXQgY29tcG9uZW50LlxuICpcbiAqIEFjY2VwdHMgcmVsZXZhbnQgc3R5bGluZyBwcm9wcyBmcm9tIFtzdHlsZWQtc3lzdGVtXShodHRwczovL3N0eWxlZC1zeXN0ZW0uY29tL3RhYmxlKS5cbiAqIEJ1aWx0IG9uIHRvcCBvZiBbSW5wdXQgZnJvbSBUaGVtZS1VSV0oaHR0cHM6Ly90aGVtZS11aS5jb20vY29tcG9uZW50cy9pbnB1dC8pLlxuICpcbiAqICoqTm90ZSoqOiBUaGlzIGNvbXBvbmVudCBkb2VzIG5vdCBzdXBwbHkgYWxsIG9mIHRoZSBhY2Nlc3NpYmlsaXR5IGFzc2lzdGFuY2Ugb24gaXRzIG93bi5cbiAqIFdlIGluc3RlYWQgZW5jb3VyYWdlIGRldmVsb3BlcnMgdG8gdXRpbGl6ZSBvdXIgRmllbGQgY29tcG9uZW50cyB3aGVyZXZlciBwb3NzaWJsZS5cbiAqIElmIHRoaXMgY29tcG9uZW50IGlzIHVzZWQsIGFjY2Vzc2liaWxpdHkgaXMgbGVmdCB0byB0aGUgZGV2ZWxvcGVyLlxuICovXG5cbmNvbnN0IEV4dGVuZGVkSW5wdXQgPSBzdHlsZWQoVGhlbWVVSUlucHV0KShcbiAgbGF5b3V0LFxuICBmbGV4Ym94LFxuICB0eXBvZ3JhcGh5LFxuKTtcblxuY29uc3QgSW5wdXQgPSBmb3J3YXJkUmVmPEhUTUxJbnB1dEVsZW1lbnQsIElucHV0UHJvcHM+KChwcm9wcywgcmVmKSA9PiB7XG4gIGNvbnN0IHsgbmFtZSwgcGxhY2Vob2xkZXIsIG1heExlbmd0aCwgLi4ub3RoZXJzIH0gPSBwcm9wcztcblxuICByZXR1cm4gKFxuICAgIDxFeHRlbmRlZElucHV0XG4gICAgICByZWY9e3JlZn1cbiAgICAgIG5hbWU9e25hbWV9XG4gICAgICBwbGFjZWhvbGRlcj17cGxhY2Vob2xkZXJ9XG4gICAgICBtYXhMZW5ndGg9e21heExlbmd0aCAmJiBtYXhMZW5ndGh9XG4gICAgICB7Li4ub3RoZXJzfVxuICAgIC8+XG4gICk7XG59KTtcblxuSW5wdXQuZGlzcGxheU5hbWUgPSAnSW5wdXQnO1xuXG5leHBvcnQgZGVmYXVsdCBJbnB1dDtcbiJdfQ== */");
|
33
39
|
var Input = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
34
40
|
var name = props.name,
|
35
41
|
placeholder = props.placeholder,
|
36
42
|
maxLength = props.maxLength,
|
37
43
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
38
|
-
return (0, _react2.jsx)(
|
44
|
+
return (0, _react2.jsx)(ExtendedInput, (0, _extends2["default"])({
|
39
45
|
ref: ref,
|
40
46
|
name: name,
|
41
47
|
placeholder: placeholder,
|
42
|
-
maxLength:
|
48
|
+
maxLength: maxLength && maxLength
|
43
49
|
}, others));
|
44
50
|
});
|
45
51
|
Input.displayName = 'Input';
|
46
|
-
Input.propTypes = {
|
47
|
-
/** Defines a string value that labels the current element. */
|
48
|
-
'aria-label': _propTypes["default"].string,
|
49
|
-
/** Id of input. */
|
50
|
-
id: _propTypes["default"].string,
|
51
|
-
/** Name of input. */
|
52
|
-
name: _propTypes["default"].string,
|
53
|
-
/** Max length of input value */
|
54
|
-
maxLength: _isValidPositiveInt["default"],
|
55
|
-
/** Type of input. Accepts most [HTML input types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types) */
|
56
|
-
type: _propTypes["default"].string,
|
57
|
-
/** Placeholder for the input */
|
58
|
-
placeholder: _propTypes["default"].string
|
59
|
-
};
|
60
52
|
var _default = Input;
|
61
53
|
exports["default"] = _default;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { StoryFn } from '@storybook/react';
|
3
|
+
import { InputProps } from '../../types';
|
4
|
+
declare const _default: {
|
5
|
+
title: string;
|
6
|
+
component: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
7
|
+
argTypes: {
|
8
|
+
placeholder: {};
|
9
|
+
type: {};
|
10
|
+
name: {};
|
11
|
+
id: {};
|
12
|
+
};
|
13
|
+
args: {
|
14
|
+
placeholder: string;
|
15
|
+
};
|
16
|
+
};
|
17
|
+
export default _default;
|
18
|
+
export declare const Default: StoryFn<InputProps>;
|
19
|
+
export declare const Password: StoryFn;
|
20
|
+
export declare const LargeInput: StoryFn;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -45,17 +45,9 @@ test('maxlength field with a set maxlength', function () {
|
|
45
45
|
_userEvent["default"].type(input, 'banana');
|
46
46
|
expect(input.value.length).toBe(3);
|
47
47
|
});
|
48
|
-
test('maxlength field is not set as
|
48
|
+
test('maxlength field is not set as undefined', function () {
|
49
49
|
getComponent({
|
50
|
-
maxLength:
|
51
|
-
});
|
52
|
-
var input = _react2.screen.getByTestId(testId);
|
53
|
-
_userEvent["default"].type(input, 'banana');
|
54
|
-
expect(input.value.length).toBe(6);
|
55
|
-
});
|
56
|
-
test('maxlength field is not set as zero', function () {
|
57
|
-
getComponent({
|
58
|
-
maxLength: 0
|
50
|
+
maxLength: undefined
|
59
51
|
});
|
60
52
|
var input = _react2.screen.getByTestId(testId);
|
61
53
|
_userEvent["default"].type(input, 'banana');
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './Input';
|
package/lib/cjs/types/index.d.ts
CHANGED
package/lib/cjs/types/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22;
|
3
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23;
|
4
4
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
5
5
|
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
6
6
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
@@ -117,8 +117,19 @@ _forEachInstanceProperty(_context10 = _Object$keys(_iconButton)).call(_context10
|
|
117
117
|
}
|
118
118
|
});
|
119
119
|
});
|
120
|
+
var _input = require("./input");
|
121
|
+
_forEachInstanceProperty(_context11 = _Object$keys(_input)).call(_context11, function (key) {
|
122
|
+
if (key === "default" || key === "__esModule") return;
|
123
|
+
if (key in exports && exports[key] === _input[key]) return;
|
124
|
+
_Object$defineProperty(exports, key, {
|
125
|
+
enumerable: true,
|
126
|
+
get: function get() {
|
127
|
+
return _input[key];
|
128
|
+
}
|
129
|
+
});
|
130
|
+
});
|
120
131
|
var _item = require("./item");
|
121
|
-
_forEachInstanceProperty(
|
132
|
+
_forEachInstanceProperty(_context12 = _Object$keys(_item)).call(_context12, function (key) {
|
122
133
|
if (key === "default" || key === "__esModule") return;
|
123
134
|
if (key in exports && exports[key] === _item[key]) return;
|
124
135
|
_Object$defineProperty(exports, key, {
|
@@ -129,7 +140,7 @@ _forEachInstanceProperty(_context11 = _Object$keys(_item)).call(_context11, func
|
|
129
140
|
});
|
130
141
|
});
|
131
142
|
var _link = require("./link");
|
132
|
-
_forEachInstanceProperty(
|
143
|
+
_forEachInstanceProperty(_context13 = _Object$keys(_link)).call(_context13, function (key) {
|
133
144
|
if (key === "default" || key === "__esModule") return;
|
134
145
|
if (key in exports && exports[key] === _link[key]) return;
|
135
146
|
_Object$defineProperty(exports, key, {
|
@@ -140,7 +151,7 @@ _forEachInstanceProperty(_context12 = _Object$keys(_link)).call(_context12, func
|
|
140
151
|
});
|
141
152
|
});
|
142
153
|
var _listItem = require("./listItem");
|
143
|
-
_forEachInstanceProperty(
|
154
|
+
_forEachInstanceProperty(_context14 = _Object$keys(_listItem)).call(_context14, function (key) {
|
144
155
|
if (key === "default" || key === "__esModule") return;
|
145
156
|
if (key in exports && exports[key] === _listItem[key]) return;
|
146
157
|
_Object$defineProperty(exports, key, {
|
@@ -151,7 +162,7 @@ _forEachInstanceProperty(_context13 = _Object$keys(_listItem)).call(_context13,
|
|
151
162
|
});
|
152
163
|
});
|
153
164
|
var _loader = require("./loader");
|
154
|
-
_forEachInstanceProperty(
|
165
|
+
_forEachInstanceProperty(_context15 = _Object$keys(_loader)).call(_context15, function (key) {
|
155
166
|
if (key === "default" || key === "__esModule") return;
|
156
167
|
if (key in exports && exports[key] === _loader[key]) return;
|
157
168
|
_Object$defineProperty(exports, key, {
|
@@ -162,7 +173,7 @@ _forEachInstanceProperty(_context14 = _Object$keys(_loader)).call(_context14, fu
|
|
162
173
|
});
|
163
174
|
});
|
164
175
|
var _overlayPanel = require("./overlayPanel");
|
165
|
-
_forEachInstanceProperty(
|
176
|
+
_forEachInstanceProperty(_context16 = _Object$keys(_overlayPanel)).call(_context16, function (key) {
|
166
177
|
if (key === "default" || key === "__esModule") return;
|
167
178
|
if (key in exports && exports[key] === _overlayPanel[key]) return;
|
168
179
|
_Object$defineProperty(exports, key, {
|
@@ -173,7 +184,7 @@ _forEachInstanceProperty(_context15 = _Object$keys(_overlayPanel)).call(_context
|
|
173
184
|
});
|
174
185
|
});
|
175
186
|
var _popoverContainer = require("./popoverContainer");
|
176
|
-
_forEachInstanceProperty(
|
187
|
+
_forEachInstanceProperty(_context17 = _Object$keys(_popoverContainer)).call(_context17, function (key) {
|
177
188
|
if (key === "default" || key === "__esModule") return;
|
178
189
|
if (key in exports && exports[key] === _popoverContainer[key]) return;
|
179
190
|
_Object$defineProperty(exports, key, {
|
@@ -184,7 +195,7 @@ _forEachInstanceProperty(_context16 = _Object$keys(_popoverContainer)).call(_con
|
|
184
195
|
});
|
185
196
|
});
|
186
197
|
var _popoverMenu = require("./popoverMenu");
|
187
|
-
_forEachInstanceProperty(
|
198
|
+
_forEachInstanceProperty(_context18 = _Object$keys(_popoverMenu)).call(_context18, function (key) {
|
188
199
|
if (key === "default" || key === "__esModule") return;
|
189
200
|
if (key in exports && exports[key] === _popoverMenu[key]) return;
|
190
201
|
_Object$defineProperty(exports, key, {
|
@@ -195,7 +206,7 @@ _forEachInstanceProperty(_context17 = _Object$keys(_popoverMenu)).call(_context1
|
|
195
206
|
});
|
196
207
|
});
|
197
208
|
var _separator = require("./separator");
|
198
|
-
_forEachInstanceProperty(
|
209
|
+
_forEachInstanceProperty(_context19 = _Object$keys(_separator)).call(_context19, function (key) {
|
199
210
|
if (key === "default" || key === "__esModule") return;
|
200
211
|
if (key in exports && exports[key] === _separator[key]) return;
|
201
212
|
_Object$defineProperty(exports, key, {
|
@@ -206,7 +217,7 @@ _forEachInstanceProperty(_context18 = _Object$keys(_separator)).call(_context18,
|
|
206
217
|
});
|
207
218
|
});
|
208
219
|
var _shared = require("./shared");
|
209
|
-
_forEachInstanceProperty(
|
220
|
+
_forEachInstanceProperty(_context20 = _Object$keys(_shared)).call(_context20, function (key) {
|
210
221
|
if (key === "default" || key === "__esModule") return;
|
211
222
|
if (key in exports && exports[key] === _shared[key]) return;
|
212
223
|
_Object$defineProperty(exports, key, {
|
@@ -217,7 +228,7 @@ _forEachInstanceProperty(_context19 = _Object$keys(_shared)).call(_context19, fu
|
|
217
228
|
});
|
218
229
|
});
|
219
230
|
var _table = require("./table");
|
220
|
-
_forEachInstanceProperty(
|
231
|
+
_forEachInstanceProperty(_context21 = _Object$keys(_table)).call(_context21, function (key) {
|
221
232
|
if (key === "default" || key === "__esModule") return;
|
222
233
|
if (key in exports && exports[key] === _table[key]) return;
|
223
234
|
_Object$defineProperty(exports, key, {
|
@@ -228,7 +239,7 @@ _forEachInstanceProperty(_context20 = _Object$keys(_table)).call(_context20, fun
|
|
228
239
|
});
|
229
240
|
});
|
230
241
|
var _text = require("./text");
|
231
|
-
_forEachInstanceProperty(
|
242
|
+
_forEachInstanceProperty(_context22 = _Object$keys(_text)).call(_context22, function (key) {
|
232
243
|
if (key === "default" || key === "__esModule") return;
|
233
244
|
if (key in exports && exports[key] === _text[key]) return;
|
234
245
|
_Object$defineProperty(exports, key, {
|
@@ -239,7 +250,7 @@ _forEachInstanceProperty(_context21 = _Object$keys(_text)).call(_context21, func
|
|
239
250
|
});
|
240
251
|
});
|
241
252
|
var _tooltipTrigger = require("./tooltipTrigger");
|
242
|
-
_forEachInstanceProperty(
|
253
|
+
_forEachInstanceProperty(_context23 = _Object$keys(_tooltipTrigger)).call(_context23, function (key) {
|
243
254
|
if (key === "default" || key === "__esModule") return;
|
244
255
|
if (key in exports && exports[key] === _tooltipTrigger[key]) return;
|
245
256
|
_Object$defineProperty(exports, key, {
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { TestingAttributes } from './shared/test';
|
2
|
+
import { DOMAttributes, StyleProps, ValidPositiveInteger } from './shared';
|
3
|
+
export interface InputProps extends StyleProps, DOMAttributes, TestingAttributes {
|
4
|
+
/** Defines a string value that labels the current element. */
|
5
|
+
'aria-label'?: string;
|
6
|
+
/** Id of input. */
|
7
|
+
id?: string;
|
8
|
+
/** Name of input. */
|
9
|
+
name?: string;
|
10
|
+
/** Max length of input value */
|
11
|
+
maxLength?: ValidPositiveInteger;
|
12
|
+
/** Type of input. Accepts most [HTML input types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types) */
|
13
|
+
type?: string;
|
14
|
+
/** Placeholder for the input */
|
15
|
+
placeholder?: string;
|
16
|
+
/** Styling variant for the input */
|
17
|
+
variant?: string;
|
18
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _context, _context2, _context3, _context4, _context5;
|
3
|
+
var _context, _context2, _context3, _context4, _context5, _context6;
|
4
4
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
5
5
|
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
6
6
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
@@ -61,4 +61,15 @@ _forEachInstanceProperty(_context5 = _Object$keys(_utils)).call(_context5, funct
|
|
61
61
|
return _utils[key];
|
62
62
|
}
|
63
63
|
});
|
64
|
+
});
|
65
|
+
var _validPositiveInteger = require("./validPositiveInteger");
|
66
|
+
_forEachInstanceProperty(_context6 = _Object$keys(_validPositiveInteger)).call(_context6, function (key) {
|
67
|
+
if (key === "default" || key === "__esModule") return;
|
68
|
+
if (key in exports && exports[key] === _validPositiveInteger[key]) return;
|
69
|
+
_Object$defineProperty(exports, key, {
|
70
|
+
enumerable: true,
|
71
|
+
get: function get() {
|
72
|
+
return _validPositiveInteger[key];
|
73
|
+
}
|
74
|
+
});
|
64
75
|
});
|
@@ -0,0 +1,4 @@
|
|
1
|
+
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
|
2
|
+
type Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
|
3
|
+
export type ValidPositiveInteger = Range<1, 999>;
|
4
|
+
export {};
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
import _styled from "@emotion/styled/base";
|
3
4
|
var _excluded = ["name", "placeholder", "maxLength"];
|
4
|
-
import _Number$isInteger from "@babel/runtime-corejs3/core-js-stable/number/is-integer";
|
5
5
|
import React, { forwardRef } from 'react';
|
6
|
-
import
|
6
|
+
import { flexbox, layout, typography } from 'styled-system';
|
7
7
|
import { Input as ThemeUIInput } from 'theme-ui';
|
8
|
-
import
|
8
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
9
|
/**
|
10
10
|
* Base input component.
|
11
11
|
*
|
@@ -16,32 +16,24 @@ import isValidPositiveInt from '../../utils/devUtils/props/isValidPositiveInt';
|
|
16
16
|
* We instead encourage developers to utilize our Field components wherever possible.
|
17
17
|
* If this component is used, accessibility is left to the developer.
|
18
18
|
*/
|
19
|
-
|
19
|
+
|
20
|
+
var ExtendedInput = /*#__PURE__*/_styled(ThemeUIInput, process.env.NODE_ENV === "production" ? {
|
21
|
+
target: "e1lpwkt50"
|
22
|
+
} : {
|
23
|
+
target: "e1lpwkt50",
|
24
|
+
label: "ExtendedInput"
|
25
|
+
})(layout, flexbox, typography, process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0lucHV0L0lucHV0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpQnNCIiwiZmlsZSI6Ii4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0lucHV0L0lucHV0LnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZWFjdCwgeyBmb3J3YXJkUmVmIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgZmxleGJveCwgbGF5b3V0LCB0eXBvZ3JhcGh5IH0gZnJvbSAnc3R5bGVkLXN5c3RlbSc7XG5pbXBvcnQgeyBJbnB1dCBhcyBUaGVtZVVJSW5wdXQgfSBmcm9tICd0aGVtZS11aSc7XG5cbmltcG9ydCB7IElucHV0UHJvcHMgfSBmcm9tICcuLi8uLi90eXBlcyc7XG4vKipcbiAqIEJhc2UgaW5wdXQgY29tcG9uZW50LlxuICpcbiAqIEFjY2VwdHMgcmVsZXZhbnQgc3R5bGluZyBwcm9wcyBmcm9tIFtzdHlsZWQtc3lzdGVtXShodHRwczovL3N0eWxlZC1zeXN0ZW0uY29tL3RhYmxlKS5cbiAqIEJ1aWx0IG9uIHRvcCBvZiBbSW5wdXQgZnJvbSBUaGVtZS1VSV0oaHR0cHM6Ly90aGVtZS11aS5jb20vY29tcG9uZW50cy9pbnB1dC8pLlxuICpcbiAqICoqTm90ZSoqOiBUaGlzIGNvbXBvbmVudCBkb2VzIG5vdCBzdXBwbHkgYWxsIG9mIHRoZSBhY2Nlc3NpYmlsaXR5IGFzc2lzdGFuY2Ugb24gaXRzIG93bi5cbiAqIFdlIGluc3RlYWQgZW5jb3VyYWdlIGRldmVsb3BlcnMgdG8gdXRpbGl6ZSBvdXIgRmllbGQgY29tcG9uZW50cyB3aGVyZXZlciBwb3NzaWJsZS5cbiAqIElmIHRoaXMgY29tcG9uZW50IGlzIHVzZWQsIGFjY2Vzc2liaWxpdHkgaXMgbGVmdCB0byB0aGUgZGV2ZWxvcGVyLlxuICovXG5cbmNvbnN0IEV4dGVuZGVkSW5wdXQgPSBzdHlsZWQoVGhlbWVVSUlucHV0KShcbiAgbGF5b3V0LFxuICBmbGV4Ym94LFxuICB0eXBvZ3JhcGh5LFxuKTtcblxuY29uc3QgSW5wdXQgPSBmb3J3YXJkUmVmPEhUTUxJbnB1dEVsZW1lbnQsIElucHV0UHJvcHM+KChwcm9wcywgcmVmKSA9PiB7XG4gIGNvbnN0IHsgbmFtZSwgcGxhY2Vob2xkZXIsIG1heExlbmd0aCwgLi4ub3RoZXJzIH0gPSBwcm9wcztcblxuICByZXR1cm4gKFxuICAgIDxFeHRlbmRlZElucHV0XG4gICAgICByZWY9e3JlZn1cbiAgICAgIG5hbWU9e25hbWV9XG4gICAgICBwbGFjZWhvbGRlcj17cGxhY2Vob2xkZXJ9XG4gICAgICBtYXhMZW5ndGg9e21heExlbmd0aCAmJiBtYXhMZW5ndGh9XG4gICAgICB7Li4ub3RoZXJzfVxuICAgIC8+XG4gICk7XG59KTtcblxuSW5wdXQuZGlzcGxheU5hbWUgPSAnSW5wdXQnO1xuXG5leHBvcnQgZGVmYXVsdCBJbnB1dDtcbiJdfQ== */");
|
20
26
|
var Input = /*#__PURE__*/forwardRef(function (props, ref) {
|
21
27
|
var name = props.name,
|
22
28
|
placeholder = props.placeholder,
|
23
29
|
maxLength = props.maxLength,
|
24
30
|
others = _objectWithoutProperties(props, _excluded);
|
25
|
-
return ___EmotionJSX(
|
31
|
+
return ___EmotionJSX(ExtendedInput, _extends({
|
26
32
|
ref: ref,
|
27
33
|
name: name,
|
28
34
|
placeholder: placeholder,
|
29
|
-
maxLength:
|
35
|
+
maxLength: maxLength && maxLength
|
30
36
|
}, others));
|
31
37
|
});
|
32
38
|
Input.displayName = 'Input';
|
33
|
-
Input.propTypes = {
|
34
|
-
/** Defines a string value that labels the current element. */
|
35
|
-
'aria-label': PropTypes.string,
|
36
|
-
/** Id of input. */
|
37
|
-
id: PropTypes.string,
|
38
|
-
/** Name of input. */
|
39
|
-
name: PropTypes.string,
|
40
|
-
/** Max length of input value */
|
41
|
-
maxLength: isValidPositiveInt,
|
42
|
-
/** Type of input. Accepts most [HTML input types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types) */
|
43
|
-
type: PropTypes.string,
|
44
|
-
/** Placeholder for the input */
|
45
|
-
placeholder: PropTypes.string
|
46
|
-
};
|
47
39
|
export default Input;
|
@@ -42,17 +42,9 @@ test('maxlength field with a set maxlength', function () {
|
|
42
42
|
userEvent.type(input, 'banana');
|
43
43
|
expect(input.value.length).toBe(3);
|
44
44
|
});
|
45
|
-
test('maxlength field is not set as
|
45
|
+
test('maxlength field is not set as undefined', function () {
|
46
46
|
getComponent({
|
47
|
-
maxLength:
|
48
|
-
});
|
49
|
-
var input = screen.getByTestId(testId);
|
50
|
-
userEvent.type(input, 'banana');
|
51
|
-
expect(input.value.length).toBe(6);
|
52
|
-
});
|
53
|
-
test('maxlength field is not set as zero', function () {
|
54
|
-
getComponent({
|
55
|
-
maxLength: 0
|
47
|
+
maxLength: undefined
|
56
48
|
});
|
57
49
|
var input = screen.getByTestId(testId);
|
58
50
|
userEvent.type(input, 'banana');
|
package/lib/types/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|