@rubenpazch/numeric-picker 3.0.0 → 4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"NumericPicker.d.ts","sourceRoot":"","sources":["../src/NumericPicker.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,GAAO,EACP,GAAY,EACZ,IAAQ,EACR,QAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,QAAgB,EAChB,WAAoB,GACrB,EAAE,kBAAkB,2CAwHpB"}
1
+ {"version":3,"file":"NumericPicker.d.ts","sourceRoot":"","sources":["../src/NumericPicker.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,GAAO,EACP,GAAY,EACZ,IAAQ,EACR,QAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,QAAgB,EAChB,WAAoB,GACrB,EAAE,kBAAkB,2CAmIpB"}
package/dist/index.cjs.js CHANGED
@@ -424,6 +424,37 @@ function requireJsxRuntime () {
424
424
 
425
425
  var jsxRuntimeExports = requireJsxRuntime();
426
426
 
427
+ function styleInject(css, ref) {
428
+ if ( ref === void 0 ) ref = {};
429
+ var insertAt = ref.insertAt;
430
+
431
+ if (typeof document === 'undefined') { return; }
432
+
433
+ var head = document.head || document.getElementsByTagName('head')[0];
434
+ var style = document.createElement('style');
435
+ style.type = 'text/css';
436
+
437
+ if (insertAt === 'top') {
438
+ if (head.firstChild) {
439
+ head.insertBefore(style, head.firstChild);
440
+ } else {
441
+ head.appendChild(style);
442
+ }
443
+ } else {
444
+ head.appendChild(style);
445
+ }
446
+
447
+ if (style.styleSheet) {
448
+ style.styleSheet.cssText = css;
449
+ } else {
450
+ style.appendChild(document.createTextNode(css));
451
+ }
452
+ }
453
+
454
+ var css_248z = "/* Container */\n.NumericPicker-module_container__Sw8zi {\n width: 100%;\n}\n\n/* Label */\n.NumericPicker-module_label__zRn12 {\n display: block;\n font-size: 0.875rem;\n line-height: 1.25rem;\n font-weight: 600;\n color: #374151;\n margin-bottom: 0.25rem;\n}\n\n.NumericPicker-module_required__3xCcz {\n color: #dc2626;\n}\n\n/* Input container */\n.NumericPicker-module_inputContainer__6ExpW {\n position: relative;\n}\n\n/* Currency symbol */\n.NumericPicker-module_currency__-sQrd {\n position: absolute;\n left: 0.75rem;\n top: 50%;\n transform: translateY(-50%);\n color: #4b5563;\n font-weight: 500;\n pointer-events: none;\n}\n\n/* Input field */\n.NumericPicker-module_input__U7-ux {\n width: 100%;\n padding: 0.625rem 3rem;\n border: 2px solid #d1d5db;\n border-radius: 0.5rem;\n outline: none;\n transition: all 150ms ease;\n}\n\n.NumericPicker-module_input__U7-ux:focus {\n border-color: #3b82f6;\n box-shadow: 0 0 0 1px #3b82f6;\n}\n\n.NumericPicker-module_input__U7-ux:disabled {\n background: #f9fafb;\n color: #6b7280;\n cursor: not-allowed;\n}\n\n/* Button container */\n.NumericPicker-module_buttonContainer__A0EZc {\n position: absolute;\n right: 0.25rem;\n top: 50%;\n transform: translateY(-50%);\n display: flex;\n flex-direction: column;\n gap: 0.125rem;\n}\n\n/* Buttons */\n.NumericPicker-module_button__eqqWo {\n padding: 0.25rem 0.5rem;\n background: #f3f4f6;\n border: none;\n border-radius: 0.125rem;\n transition: all 150ms ease;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n\n.NumericPicker-module_button__eqqWo:hover:not(:disabled) {\n background: #e5e7eb;\n}\n\n.NumericPicker-module_button__eqqWo:disabled {\n background: #f9fafb;\n color: #d1d5db;\n cursor: not-allowed;\n}\n\n.NumericPicker-module_buttonIcon__Z6fRE {\n width: 0.75rem;\n height: 0.75rem;\n}\n";
455
+ var styles = {"container":"NumericPicker-module_container__Sw8zi","label":"NumericPicker-module_label__zRn12","required":"NumericPicker-module_required__3xCcz","inputContainer":"NumericPicker-module_inputContainer__6ExpW","currency":"NumericPicker-module_currency__-sQrd","input":"NumericPicker-module_input__U7-ux","buttonContainer":"NumericPicker-module_buttonContainer__A0EZc","button":"NumericPicker-module_button__eqqWo","buttonIcon":"NumericPicker-module_buttonIcon__Z6fRE"};
456
+ styleInject(css_248z);
457
+
427
458
  function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decimals = 2, currency = "S/.", label, required = false, disabled = false, placeholder = "0.00", }) {
428
459
  const [displayValue, setDisplayValue] = require$$0.useState(String(value || ""));
429
460
  require$$0.useEffect(() => {
@@ -472,7 +503,7 @@ function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decim
472
503
  setDisplayValue(formatted);
473
504
  onChange(formatted);
474
505
  };
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" }) }) })] })] })] }));
506
+ return (jsxRuntimeExports.jsxs("div", { className: styles.container, "data-testid": "numeric-picker", children: [label && (jsxRuntimeExports.jsxs("label", { className: styles.label, children: [label, required && jsxRuntimeExports.jsx("span", { className: styles.required, children: " *" })] })), jsxRuntimeExports.jsxs("div", { className: styles.inputContainer, children: [jsxRuntimeExports.jsx("span", { className: styles.currency, "data-testid": "currency-symbol", children: currency }), jsxRuntimeExports.jsx("input", { type: "text", value: displayValue, onChange: (e) => handleInputChange(e.target.value), disabled: disabled, placeholder: placeholder, className: styles.input, "data-testid": "numeric-input" }), jsxRuntimeExports.jsxs("div", { className: styles.buttonContainer, children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: increment, disabled: disabled || parseFloat(displayValue || "0") >= max, className: styles.button, title: "Increment", "data-testid": "increment-button", children: jsxRuntimeExports.jsx("svg", { className: styles.buttonIcon, 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: styles.button, title: "Decrement", "data-testid": "decrement-button", children: jsxRuntimeExports.jsx("svg", { className: styles.buttonIcon, 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
507
  }
477
508
 
478
509
  module.exports = NumericPicker;
package/dist/index.esm.js CHANGED
@@ -422,6 +422,37 @@ function requireJsxRuntime () {
422
422
 
423
423
  var jsxRuntimeExports = requireJsxRuntime();
424
424
 
425
+ function styleInject(css, ref) {
426
+ if ( ref === void 0 ) ref = {};
427
+ var insertAt = ref.insertAt;
428
+
429
+ if (typeof document === 'undefined') { return; }
430
+
431
+ var head = document.head || document.getElementsByTagName('head')[0];
432
+ var style = document.createElement('style');
433
+ style.type = 'text/css';
434
+
435
+ if (insertAt === 'top') {
436
+ if (head.firstChild) {
437
+ head.insertBefore(style, head.firstChild);
438
+ } else {
439
+ head.appendChild(style);
440
+ }
441
+ } else {
442
+ head.appendChild(style);
443
+ }
444
+
445
+ if (style.styleSheet) {
446
+ style.styleSheet.cssText = css;
447
+ } else {
448
+ style.appendChild(document.createTextNode(css));
449
+ }
450
+ }
451
+
452
+ var css_248z = "/* Container */\n.NumericPicker-module_container__Sw8zi {\n width: 100%;\n}\n\n/* Label */\n.NumericPicker-module_label__zRn12 {\n display: block;\n font-size: 0.875rem;\n line-height: 1.25rem;\n font-weight: 600;\n color: #374151;\n margin-bottom: 0.25rem;\n}\n\n.NumericPicker-module_required__3xCcz {\n color: #dc2626;\n}\n\n/* Input container */\n.NumericPicker-module_inputContainer__6ExpW {\n position: relative;\n}\n\n/* Currency symbol */\n.NumericPicker-module_currency__-sQrd {\n position: absolute;\n left: 0.75rem;\n top: 50%;\n transform: translateY(-50%);\n color: #4b5563;\n font-weight: 500;\n pointer-events: none;\n}\n\n/* Input field */\n.NumericPicker-module_input__U7-ux {\n width: 100%;\n padding: 0.625rem 3rem;\n border: 2px solid #d1d5db;\n border-radius: 0.5rem;\n outline: none;\n transition: all 150ms ease;\n}\n\n.NumericPicker-module_input__U7-ux:focus {\n border-color: #3b82f6;\n box-shadow: 0 0 0 1px #3b82f6;\n}\n\n.NumericPicker-module_input__U7-ux:disabled {\n background: #f9fafb;\n color: #6b7280;\n cursor: not-allowed;\n}\n\n/* Button container */\n.NumericPicker-module_buttonContainer__A0EZc {\n position: absolute;\n right: 0.25rem;\n top: 50%;\n transform: translateY(-50%);\n display: flex;\n flex-direction: column;\n gap: 0.125rem;\n}\n\n/* Buttons */\n.NumericPicker-module_button__eqqWo {\n padding: 0.25rem 0.5rem;\n background: #f3f4f6;\n border: none;\n border-radius: 0.125rem;\n transition: all 150ms ease;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n}\n\n.NumericPicker-module_button__eqqWo:hover:not(:disabled) {\n background: #e5e7eb;\n}\n\n.NumericPicker-module_button__eqqWo:disabled {\n background: #f9fafb;\n color: #d1d5db;\n cursor: not-allowed;\n}\n\n.NumericPicker-module_buttonIcon__Z6fRE {\n width: 0.75rem;\n height: 0.75rem;\n}\n";
453
+ var styles = {"container":"NumericPicker-module_container__Sw8zi","label":"NumericPicker-module_label__zRn12","required":"NumericPicker-module_required__3xCcz","inputContainer":"NumericPicker-module_inputContainer__6ExpW","currency":"NumericPicker-module_currency__-sQrd","input":"NumericPicker-module_input__U7-ux","buttonContainer":"NumericPicker-module_buttonContainer__A0EZc","button":"NumericPicker-module_button__eqqWo","buttonIcon":"NumericPicker-module_buttonIcon__Z6fRE"};
454
+ styleInject(css_248z);
455
+
425
456
  function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decimals = 2, currency = "S/.", label, required = false, disabled = false, placeholder = "0.00", }) {
426
457
  const [displayValue, setDisplayValue] = useState(String(value || ""));
427
458
  useEffect(() => {
@@ -470,7 +501,7 @@ function NumericPicker({ value, onChange, min = 0, max = 999999, step = 1, decim
470
501
  setDisplayValue(formatted);
471
502
  onChange(formatted);
472
503
  };
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" }) }) })] })] })] }));
504
+ return (jsxRuntimeExports.jsxs("div", { className: styles.container, "data-testid": "numeric-picker", children: [label && (jsxRuntimeExports.jsxs("label", { className: styles.label, children: [label, required && jsxRuntimeExports.jsx("span", { className: styles.required, children: " *" })] })), jsxRuntimeExports.jsxs("div", { className: styles.inputContainer, children: [jsxRuntimeExports.jsx("span", { className: styles.currency, "data-testid": "currency-symbol", children: currency }), jsxRuntimeExports.jsx("input", { type: "text", value: displayValue, onChange: (e) => handleInputChange(e.target.value), disabled: disabled, placeholder: placeholder, className: styles.input, "data-testid": "numeric-input" }), jsxRuntimeExports.jsxs("div", { className: styles.buttonContainer, children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: increment, disabled: disabled || parseFloat(displayValue || "0") >= max, className: styles.button, title: "Increment", "data-testid": "increment-button", children: jsxRuntimeExports.jsx("svg", { className: styles.buttonIcon, 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: styles.button, title: "Decrement", "data-testid": "decrement-button", children: jsxRuntimeExports.jsx("svg", { className: styles.buttonIcon, 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
505
  }
475
506
 
476
507
  export { NumericPicker as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubenpazch/numeric-picker",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "repository": "https://github.com/rubenpazch/lbyte-ui-library.git",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,7 +11,9 @@
11
11
  "files": [
12
12
  "dist"
13
13
  ],
14
- "sideEffects": false,
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
15
17
  "exports": {
16
18
  ".": {
17
19
  "import": "./dist/index.esm.js",