@rubenpazch/numeric-picker 2.0.0 → 3.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.
package/dist/index.cjs.js CHANGED
@@ -424,18 +424,18 @@ function requireJsxRuntime () {
424
424
 
425
425
  var jsxRuntimeExports = requireJsxRuntime();
426
426
 
427
- function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decimals = 2, currency = 'S/.', label, required = false, disabled = false, placeholder = '0.00', }) {
428
- const [displayValue, setDisplayValue] = require$$0.useState(String(value || ''));
427
+ function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decimals = 2, currency = "S/.", label, required = false, disabled = false, placeholder = "0.00", }) {
428
+ const [displayValue, setDisplayValue] = require$$0.useState(String(value || ""));
429
429
  require$$0.useEffect(() => {
430
- setDisplayValue(String(value || ''));
430
+ setDisplayValue(String(value || ""));
431
431
  }, [value]);
432
432
  const handleInputChange = (newValue) => {
433
433
  // Remove currency symbol if present
434
- let cleanValue = newValue.replace(/[^\d.-]/g, '');
434
+ let cleanValue = newValue.replace(/[^\d.-]/g, "");
435
435
  // Validate and format
436
- if (cleanValue === '' || cleanValue === '-') {
436
+ if (cleanValue === "" || cleanValue === "-") {
437
437
  setDisplayValue(cleanValue);
438
- onChange('');
438
+ onChange("");
439
439
  return;
440
440
  }
441
441
  const numValue = parseFloat(cleanValue);
@@ -472,7 +472,7 @@ function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decim
472
472
  setDisplayValue(formatted);
473
473
  onChange(formatted);
474
474
  };
475
- return (jsxRuntimeExports.jsxs("div", { className: "w-full", children: [label && (jsxRuntimeExports.jsxs("label", { className: "block text-sm font-semibold text-gray-700 mb-1", children: [label, required && jsxRuntimeExports.jsx("span", { className: "text-red-600", children: " *" })] })), jsxRuntimeExports.jsxs("div", { className: "relative", children: [jsxRuntimeExports.jsx("span", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-600 font-medium pointer-events-none", children: currency }), jsxRuntimeExports.jsx("input", { type: "text", value: displayValue, onChange: (e) => handleInputChange(e.target.value), disabled: disabled, placeholder: placeholder, className: "w-full pl-12 pr-12 py-2.5 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed transition" }), jsxRuntimeExports.jsxs("div", { className: "absolute right-1 top-1/2 transform -translate-y-1/2 flex flex-col gap-0.5", children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: increment, disabled: disabled || parseFloat(displayValue || '0') >= max, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Increment", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V15a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z", clipRule: "evenodd" }) }) }), jsxRuntimeExports.jsx("button", { type: "button", onClick: decrement, disabled: disabled || parseFloat(displayValue || '0') <= min, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Decrement", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V5a1 1 0 012 0v9.586l4.293-4.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })] })] })] }));
475
+ return (jsxRuntimeExports.jsxs("div", { className: "w-full", children: [label && (jsxRuntimeExports.jsxs("label", { className: "block text-sm font-semibold text-gray-700 mb-1", children: [label, required && jsxRuntimeExports.jsx("span", { className: "text-red-600", children: " *" })] })), jsxRuntimeExports.jsxs("div", { className: "relative", children: [jsxRuntimeExports.jsx("span", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-600 font-medium pointer-events-none", children: currency }), jsxRuntimeExports.jsx("input", { type: "text", value: displayValue, onChange: (e) => handleInputChange(e.target.value), disabled: disabled, placeholder: placeholder, className: "w-full pl-12 pr-12 py-2.5 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed transition" }), jsxRuntimeExports.jsxs("div", { className: "absolute right-1 top-1/2 transform -translate-y-1/2 flex flex-col gap-0.5", children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: increment, disabled: disabled || parseFloat(displayValue || "0") >= max, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Increment", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V15a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z", clipRule: "evenodd" }) }) }), jsxRuntimeExports.jsx("button", { type: "button", onClick: decrement, disabled: disabled || parseFloat(displayValue || "0") <= min, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Decrement", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V5a1 1 0 012 0v9.586l4.293-4.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })] })] })] }));
476
476
  }
477
477
 
478
478
  module.exports = NumericPicker;
package/dist/index.esm.js CHANGED
@@ -422,18 +422,18 @@ function requireJsxRuntime () {
422
422
 
423
423
  var jsxRuntimeExports = requireJsxRuntime();
424
424
 
425
- function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decimals = 2, currency = 'S/.', label, required = false, disabled = false, placeholder = '0.00', }) {
426
- const [displayValue, setDisplayValue] = useState(String(value || ''));
425
+ function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decimals = 2, currency = "S/.", label, required = false, disabled = false, placeholder = "0.00", }) {
426
+ const [displayValue, setDisplayValue] = useState(String(value || ""));
427
427
  useEffect(() => {
428
- setDisplayValue(String(value || ''));
428
+ setDisplayValue(String(value || ""));
429
429
  }, [value]);
430
430
  const handleInputChange = (newValue) => {
431
431
  // Remove currency symbol if present
432
- let cleanValue = newValue.replace(/[^\d.-]/g, '');
432
+ let cleanValue = newValue.replace(/[^\d.-]/g, "");
433
433
  // Validate and format
434
- if (cleanValue === '' || cleanValue === '-') {
434
+ if (cleanValue === "" || cleanValue === "-") {
435
435
  setDisplayValue(cleanValue);
436
- onChange('');
436
+ onChange("");
437
437
  return;
438
438
  }
439
439
  const numValue = parseFloat(cleanValue);
@@ -470,7 +470,7 @@ function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decim
470
470
  setDisplayValue(formatted);
471
471
  onChange(formatted);
472
472
  };
473
- return (jsxRuntimeExports.jsxs("div", { className: "w-full", children: [label && (jsxRuntimeExports.jsxs("label", { className: "block text-sm font-semibold text-gray-700 mb-1", children: [label, required && jsxRuntimeExports.jsx("span", { className: "text-red-600", children: " *" })] })), jsxRuntimeExports.jsxs("div", { className: "relative", children: [jsxRuntimeExports.jsx("span", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-600 font-medium pointer-events-none", children: currency }), jsxRuntimeExports.jsx("input", { type: "text", value: displayValue, onChange: (e) => handleInputChange(e.target.value), disabled: disabled, placeholder: placeholder, className: "w-full pl-12 pr-12 py-2.5 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed transition" }), jsxRuntimeExports.jsxs("div", { className: "absolute right-1 top-1/2 transform -translate-y-1/2 flex flex-col gap-0.5", children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: increment, disabled: disabled || parseFloat(displayValue || '0') >= max, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Increment", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V15a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z", clipRule: "evenodd" }) }) }), jsxRuntimeExports.jsx("button", { type: "button", onClick: decrement, disabled: disabled || parseFloat(displayValue || '0') <= min, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Decrement", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V5a1 1 0 012 0v9.586l4.293-4.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })] })] })] }));
473
+ return (jsxRuntimeExports.jsxs("div", { className: "w-full", children: [label && (jsxRuntimeExports.jsxs("label", { className: "block text-sm font-semibold text-gray-700 mb-1", children: [label, required && jsxRuntimeExports.jsx("span", { className: "text-red-600", children: " *" })] })), jsxRuntimeExports.jsxs("div", { className: "relative", children: [jsxRuntimeExports.jsx("span", { className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-600 font-medium pointer-events-none", children: currency }), jsxRuntimeExports.jsx("input", { type: "text", value: displayValue, onChange: (e) => handleInputChange(e.target.value), disabled: disabled, placeholder: placeholder, className: "w-full pl-12 pr-12 py-2.5 border-2 border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed transition" }), jsxRuntimeExports.jsxs("div", { className: "absolute right-1 top-1/2 transform -translate-y-1/2 flex flex-col gap-0.5", children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: increment, disabled: disabled || parseFloat(displayValue || "0") >= max, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Increment", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V15a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z", clipRule: "evenodd" }) }) }), jsxRuntimeExports.jsx("button", { type: "button", onClick: decrement, disabled: disabled || parseFloat(displayValue || "0") <= min, className: "px-2 py-1 bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-300 rounded-sm transition flex items-center justify-center", title: "Decrement", children: jsxRuntimeExports.jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", d: "M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V5a1 1 0 012 0v9.586l4.293-4.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })] })] })] }));
474
474
  }
475
475
 
476
476
  export { NumericPicker as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/numeric-picker",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "repository": "https://github.com/rubenpazch/lbyte-ui-library.git",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,7 +24,7 @@
24
24
  "react-dom": "^19.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@rubenpazch/typescript-config": "2.0.0"
27
+ "@rubenpazch/typescript-config": "3.0.0"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "rollup -c",