@devekene001/super-input 0.0.2
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/README.md +23 -0
- package/dist/index.js +93 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# My Super Input
|
|
2
|
+
|
|
3
|
+
A professional, reusable text input for React.
|
|
4
|
+
|
|
5
|
+
## How to use it:
|
|
6
|
+
1. Install it: `npm install my-super-input`
|
|
7
|
+
2. Use it in your code:
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import SuperInput from 'my-super-input';
|
|
11
|
+
|
|
12
|
+
function App() {
|
|
13
|
+
const [name, setName] = React.useState('');
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<SuperInput
|
|
17
|
+
label="Your Name"
|
|
18
|
+
value={name}
|
|
19
|
+
onChange={setName}
|
|
20
|
+
placeholder="Type here..."
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
// The "Safety Guard"
|
|
17
|
+
|
|
18
|
+
var SuperInput = function SuperInput(_ref) {
|
|
19
|
+
var label = _ref.label,
|
|
20
|
+
value = _ref.value,
|
|
21
|
+
_onChange = _ref.onChange,
|
|
22
|
+
placeholder = _ref.placeholder,
|
|
23
|
+
error = _ref.error,
|
|
24
|
+
style = _ref.style,
|
|
25
|
+
_ref$type = _ref.type,
|
|
26
|
+
type = _ref$type === void 0 ? 'text' : _ref$type,
|
|
27
|
+
_ref$disabled = _ref.disabled,
|
|
28
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
29
|
+
name = _ref.name;
|
|
30
|
+
// We create a unique ID so the label knows exactly which box it belongs to
|
|
31
|
+
var inputId = "super-input-".concat(name || Math.random().toString(36).substr(2, 9));
|
|
32
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
33
|
+
style: {
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
marginBottom: '15px',
|
|
37
|
+
fontFamily: 'Arial, sans-serif',
|
|
38
|
+
opacity: disabled ? 0.6 : 1 // Look faded if locked
|
|
39
|
+
}
|
|
40
|
+
}, label && /*#__PURE__*/_react["default"].createElement("label", {
|
|
41
|
+
htmlFor: inputId,
|
|
42
|
+
style: {
|
|
43
|
+
fontWeight: 'bold',
|
|
44
|
+
marginBottom: '5px',
|
|
45
|
+
fontSize: '14px'
|
|
46
|
+
}
|
|
47
|
+
}, label), /*#__PURE__*/_react["default"].createElement("input", {
|
|
48
|
+
id: inputId,
|
|
49
|
+
name: name,
|
|
50
|
+
type: type,
|
|
51
|
+
value: value,
|
|
52
|
+
disabled: disabled,
|
|
53
|
+
placeholder: placeholder,
|
|
54
|
+
onChange: function onChange(e) {
|
|
55
|
+
return _onChange(e.target.value);
|
|
56
|
+
}
|
|
57
|
+
// We use a CSS class or inline style with focus logic
|
|
58
|
+
,
|
|
59
|
+
style: _objectSpread({
|
|
60
|
+
padding: '12px',
|
|
61
|
+
fontSize: '16px',
|
|
62
|
+
borderRadius: '8px',
|
|
63
|
+
border: error ? '2px solid #ff4d4f' : '1px solid #d9d9d9',
|
|
64
|
+
outline: 'none',
|
|
65
|
+
transition: 'all 0.3s',
|
|
66
|
+
// Makes color changes smooth
|
|
67
|
+
cursor: disabled ? 'not-allowed' : 'text'
|
|
68
|
+
}, style)
|
|
69
|
+
}), error && /*#__PURE__*/_react["default"].createElement("span", {
|
|
70
|
+
style: {
|
|
71
|
+
color: '#ff4d4f',
|
|
72
|
+
fontSize: '12px',
|
|
73
|
+
marginTop: '5px',
|
|
74
|
+
fontWeight: '500'
|
|
75
|
+
}
|
|
76
|
+
}, error));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// This is the "Safety Manual" for other developers
|
|
80
|
+
SuperInput.propTypes = {
|
|
81
|
+
label: _propTypes["default"].string,
|
|
82
|
+
value: _propTypes["default"].string.isRequired,
|
|
83
|
+
// It MUST have a value
|
|
84
|
+
onChange: _propTypes["default"].func.isRequired,
|
|
85
|
+
// It MUST have a function
|
|
86
|
+
placeholder: _propTypes["default"].string,
|
|
87
|
+
error: _propTypes["default"].string,
|
|
88
|
+
type: _propTypes["default"].oneOf(['text', 'password', 'email', 'number']),
|
|
89
|
+
disabled: _propTypes["default"].bool,
|
|
90
|
+
style: _propTypes["default"].object,
|
|
91
|
+
name: _propTypes["default"].string
|
|
92
|
+
};
|
|
93
|
+
var _default = exports["default"] = SuperInput;
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@devekene001/super-input",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "A very fancy and professional text input for React",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "rm -rf dist && babel src --out-dir dist"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"react": ">=16"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "developerekene",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"prop-types": "^15.8.1",
|
|
18
|
+
"react": ">=16",
|
|
19
|
+
"react-dom": "^19.2.4"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@babel/cli": "^7.28.6",
|
|
23
|
+
"@babel/core": "^7.29.0",
|
|
24
|
+
"@babel/preset-env": "^7.29.2",
|
|
25
|
+
"@babel/preset-react": "^7.28.5"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
]
|
|
30
|
+
}
|