@devekene001/super-input 0.0.2 → 1.0.0

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -46
  2. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
9
  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
10
  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; }
@@ -13,81 +12,54 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
13
12
  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
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
14
  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
-
15
+ /**
16
+ * SuperInput Component
17
+ * @param {string} label - The name of the box (e.g., "First Name")
18
+ * @param {string} value - What is currently typed inside
19
+ * @param {function} onChange - A magic function that runs when you type
20
+ * @param {string} placeholder - The grey "ghost text" inside
21
+ * @param {string} error - A red message if something is wrong
22
+ */
18
23
  var SuperInput = function SuperInput(_ref) {
19
24
  var label = _ref.label,
20
25
  value = _ref.value,
21
26
  _onChange = _ref.onChange,
22
27
  placeholder = _ref.placeholder,
23
28
  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));
29
+ style = _ref.style;
32
30
  return /*#__PURE__*/_react["default"].createElement("div", {
33
31
  style: {
34
32
  display: 'flex',
35
33
  flexDirection: 'column',
36
34
  marginBottom: '15px',
37
- fontFamily: 'Arial, sans-serif',
38
- opacity: disabled ? 0.6 : 1 // Look faded if locked
35
+ fontFamily: 'Arial'
39
36
  }
40
37
  }, label && /*#__PURE__*/_react["default"].createElement("label", {
41
- htmlFor: inputId,
42
38
  style: {
43
39
  fontWeight: 'bold',
44
- marginBottom: '5px',
45
- fontSize: '14px'
40
+ marginBottom: '5px'
46
41
  }
47
42
  }, label), /*#__PURE__*/_react["default"].createElement("input", {
48
- id: inputId,
49
- name: name,
50
- type: type,
43
+ type: "text",
51
44
  value: value,
52
- disabled: disabled,
53
45
  placeholder: placeholder,
54
46
  onChange: function onChange(e) {
55
47
  return _onChange(e.target.value);
56
- }
57
- // We use a CSS class or inline style with focus logic
58
- ,
48
+ },
59
49
  style: _objectSpread({
60
50
  padding: '12px',
61
51
  fontSize: '16px',
62
52
  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'
53
+ border: error ? '2px solid red' : '1px solid #ccc',
54
+ // Turns red if there's an error!
55
+ outline: 'none'
68
56
  }, style)
69
57
  }), error && /*#__PURE__*/_react["default"].createElement("span", {
70
58
  style: {
71
- color: '#ff4d4f',
59
+ color: 'red',
72
60
  fontSize: '12px',
73
- marginTop: '5px',
74
- fontWeight: '500'
61
+ marginTop: '5px'
75
62
  }
76
63
  }, error));
77
64
  };
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
65
  var _default = exports["default"] = SuperInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devekene001/super-input",
3
- "version": "0.0.2",
3
+ "version": "1.0.0",
4
4
  "description": "A very fancy and professional text input for React",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -14,7 +14,6 @@
14
14
  "author": "developerekene",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "prop-types": "^15.8.1",
18
17
  "react": ">=16",
19
18
  "react-dom": "^19.2.4"
20
19
  },