@rubenpazch/autocomplete 3.0.2 → 3.0.3
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 +4 -4
- package/dist/index.esm.js +4 -4
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -443,7 +443,7 @@ function requireJsxRuntime$1 () {
|
|
|
443
443
|
|
|
444
444
|
var jsxRuntimeExports$1 = requireJsxRuntime$1();
|
|
445
445
|
|
|
446
|
-
var
|
|
446
|
+
var r,o={exports:{}},t={};var l,n,a={};
|
|
447
447
|
/**
|
|
448
448
|
* @license React
|
|
449
449
|
* react-jsx-runtime.development.js
|
|
@@ -452,7 +452,7 @@ var s,o={exports:{}},t={};var n,l,a={};
|
|
|
452
452
|
*
|
|
453
453
|
* This source code is licensed under the MIT license found in the
|
|
454
454
|
* LICENSE file in the root directory of this source tree.
|
|
455
|
-
*/function i(){return
|
|
455
|
+
*/function i(){return l||(l=1,"production"!==process.env.NODE_ENV&&function(){function e(s){if(null==s)return null;if("function"==typeof s)return s.$$typeof===M?null:s.displayName||s.name||null;if("string"==typeof s)return s;switch(s){case x:return "Fragment";case p:return "Profiler";case v:return "StrictMode";case f:return "Suspense";case C:return "SuspenseList";case N:return "Activity"}if("object"==typeof s)switch("number"==typeof s.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case u:return "Portal";case j:return s.displayName||"Context";case g:return (s._context.displayName||"Context")+".Consumer";case k:var r=s.render;return (s=s.displayName)||(s=""!==(s=r.displayName||r.name||"")?"ForwardRef("+s+")":"ForwardRef"),s;case L:return null!==(r=s.displayName||null)?r:e(s.type)||"Memo";case y:r=s._payload,s=s._init;try{return e(s(r))}catch(e){}}return null}function r(e){return ""+e}function o(e){try{r(e);var s=!1;}catch(e){s=true;}if(s){var o=(s=console).error,t="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",t),r(e)}}function t(s){if(s===x)return "<>";if("object"==typeof s&&null!==s&&s.$$typeof===y)return "<...>";try{var r=e(s);return r?"<"+r+">":"<...>"}catch(e){return "<...>"}}function l(){return Error("react-stack-top-frame")}function n(){var s=e(this.type);return B[s]||(B[s]=true,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(s=this.props.ref)?s:null}function i(s,r,t,l,a,i){var h,m=r.children;if(void 0!==m)if(l)if(z(m)){for(l=0;l<m.length;l++)c(m[l]);Object.freeze&&Object.freeze(m);}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else c(m);if(b.call(r,"key")){m=e(s);var u=Object.keys(r).filter(function(e){return "key"!==e});l=0<u.length?"{key: someKey, "+u.join(": ..., ")+": ...}":"{key: someKey}",W[m+l]||(u=0<u.length?"{"+u.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,m,u,m),W[m+l]=true);}if(m=null,void 0!==t&&(o(t),m=""+t),function(e){if(b.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return false}return void 0!==e.key}(r)&&(o(r.key),m=""+r.key),"key"in r)for(var x in t={},r)"key"!==x&&(t[x]=r[x]);else t=r;return m&&function(e,s){function r(){d||(d=true,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s));}r.isReactWarning=true,Object.defineProperty(e,"key",{get:r,configurable:true});}(t,"function"==typeof s?s.displayName||s.name||"Unknown":s),function(e,s,r,o,t,l){var a=r.ref;return e={$$typeof:w,type:e,key:s,props:r,_owner:o},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:false,get:n}):Object.defineProperty(e,"ref",{enumerable:false,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:false,enumerable:false,writable:true,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:false,enumerable:false,writable:true,value:null}),Object.defineProperty(e,"_debugStack",{configurable:false,enumerable:false,writable:true,value:t}),Object.defineProperty(e,"_debugTask",{configurable:false,enumerable:false,writable:true,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(s,m,t,null===(h=$.A)?null:h.getOwner(),a,i)}function c(e){h(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===y&&("fulfilled"===e._payload.status?h(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1));}function h(e){return "object"==typeof e&&null!==e&&e.$$typeof===w}var d,m=require$$0,w=Symbol.for("react.transitional.element"),u=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),j=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),$=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,z=Array.isArray,H=console.createTask?console.createTask:function(){return null},B={},V=(m={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(m,l)(),Z=H(t(l)),W={};a.Fragment=x,a.jsx=function(e,s,r){var o=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,r,false,o?Error("react-stack-top-frame"):V,o?H(t(e)):Z)},a.jsxs=function(e,s,r){var o=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,r,true,o?Error("react-stack-top-frame"):V,o?H(t(e)):Z)};}()),a}var c=(n||(n=1,"production"===process.env.NODE_ENV?o.exports=function(){if(r)return t;r=1;var e=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function o(s,r,o){var t=null;if(void 0!==o&&(t=""+o),void 0!==r.key&&(t=""+r.key),"key"in r)for(var l in o={},r)"key"!==l&&(o[l]=r[l]);else o=r;return r=o.ref,{$$typeof:e,type:s,key:t,ref:void 0!==r?r:null,props:o}}return t.Fragment=s,t.jsx=o,t.jsxs=o,t}():o.exports=i()),o.exports);function p({className:e="",size:s="md"}){const r=`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${e}`;return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:r,"aria-label":"Check",children:c.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}const y=({className:e="",size:s="md",color:r="currentColor",direction:o="down"})=>c.jsx("svg",{className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${{up:"rotate-180",down:"",left:"rotate-90",right:"-rotate-90"}[o]} ${e}`,fill:"none",stroke:r,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M6 9l6 6 6-6"})});function B({className:e="",size:s="md",color:r="currentColor"}){return c.jsx("svg",{className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${e}`,fill:"none",stroke:r,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})}const Xe={outlined:"material-symbols-outlined",rounded:"material-symbols-rounded",sharp:"material-symbols-sharp"},Ye=require$$0__namespace.forwardRef(({name:e,variant:s="outlined",size:r="md",fill:o=0,weight:t=400,grade:l=0,opticalSize:n=24,style:a,className:i,...h},d)=>{const m=(e=>"number"==typeof e?e:"sm"===e?16:"md"===e?20:24)(r),w=`"FILL" ${o}, "wght" ${t}, "GRAD" ${l}, "opsz" ${n}`;return c.jsx("span",{ref:d,"aria-hidden":"true",className:Xe[s]+(i?` ${i}`:""),style:{fontVariationSettings:w,fontSize:m,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",...a},...h,children:e})});Ye.displayName="MaterialIcon";
|
|
456
456
|
|
|
457
457
|
var jsxRuntime = {exports: {}};
|
|
458
458
|
|
|
@@ -1146,12 +1146,12 @@ const Autocomplete = ({ label, value, onChange, options = [], placeholder = "Sea
|
|
|
1146
1146
|
const getInputClassName = () => {
|
|
1147
1147
|
return classNames(styles.input, icon ? styles.inputWithIcon : undefined, clearable && value ? styles.inputWithClear : styles.inputWithoutClear, readOnly ? styles.inputReadOnly : undefined, error ? styles.inputError : undefined, warning && !error ? styles.inputWarning : undefined, isFocused && !error && !warning ? styles.inputFocused : undefined);
|
|
1148
1148
|
};
|
|
1149
|
-
return (jsxRuntimeExports$1.jsxs("div", { className: classNames(styles.container, className), children: [label && (jsxRuntimeExports$1.jsxs("label", { className: styles.label, children: [label, required && jsxRuntimeExports$1.jsx("span", { className: styles.required, children: "*" })] })), jsxRuntimeExports$1.jsxs("div", { ref: containerRef, className: styles.inputWrapper, children: [icon && jsxRuntimeExports$1.jsx("div", { className: styles.iconLeft, children: icon }), jsxRuntimeExports$1.jsx("input", { ref: inputRef, type: "text", value: displayValue, onChange: handleInputChange, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: disabled, readOnly: readOnly || !searchable, className: getInputClassName(), "data-testid": "autocomplete-input", "data-has-error": error ? "true" : "false", "data-has-warning": warning ? "true" : "false", "data-is-focused": isFocused ? "true" : "false" }), jsxRuntimeExports$1.jsxs("div", { className: styles.rightIcons, children: [loading && jsxRuntimeExports$1.jsx(LoadingSpinner, { size: "sm", variant: "dots", inline: true }), clearable && value && !loading && !disabled && (jsxRuntimeExports$1.jsx("button", { type: "button", onClick: handleClear, className: styles.clearButton, "data-testid": "autocomplete-clear", "aria-label": "Clear selection", children: jsxRuntimeExports$1.jsx(
|
|
1149
|
+
return (jsxRuntimeExports$1.jsxs("div", { className: classNames(styles.container, className), children: [label && (jsxRuntimeExports$1.jsxs("label", { className: styles.label, children: [label, required && jsxRuntimeExports$1.jsx("span", { className: styles.required, children: "*" })] })), jsxRuntimeExports$1.jsxs("div", { ref: containerRef, className: styles.inputWrapper, children: [icon && jsxRuntimeExports$1.jsx("div", { className: styles.iconLeft, children: icon }), jsxRuntimeExports$1.jsx("input", { ref: inputRef, type: "text", value: displayValue, onChange: handleInputChange, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: disabled, readOnly: readOnly || !searchable, className: getInputClassName(), "data-testid": "autocomplete-input", "data-has-error": error ? "true" : "false", "data-has-warning": warning ? "true" : "false", "data-is-focused": isFocused ? "true" : "false" }), jsxRuntimeExports$1.jsxs("div", { className: styles.rightIcons, children: [loading && jsxRuntimeExports$1.jsx(LoadingSpinner, { size: "sm", variant: "dots", inline: true }), clearable && value && !loading && !disabled && (jsxRuntimeExports$1.jsx("button", { type: "button", onClick: handleClear, className: styles.clearButton, "data-testid": "autocomplete-clear", "aria-label": "Clear selection", children: jsxRuntimeExports$1.jsx(B, { className: "w-4 h-4" }) })), jsxRuntimeExports$1.jsx("button", { type: "button", onClick: handleToggle, className: styles.toggleButton, disabled: disabled, "data-testid": "autocomplete-toggle", "aria-label": isOpen ? "Close dropdown" : "Open dropdown", children: jsxRuntimeExports$1.jsx(y, { className: classNames(styles.toggleIcon, isOpen && styles.toggleIconOpen) }) })] }), isOpen && !disabled && !readOnly && (jsxRuntimeExports$1.jsxs("div", { ref: dropdownRef, className: classNames(styles.dropdown, position === "top" && styles.dropdownTop), style: { maxHeight }, "data-testid": "autocomplete-dropdown", children: [loading && filteredOptions.length === 0 && (jsxRuntimeExports$1.jsxs("div", { className: styles.loadingState, children: [jsxRuntimeExports$1.jsx(LoadingSpinner, { size: "sm", variant: "spinner", className: styles.loadingSpinner }), jsxRuntimeExports$1.jsx("span", { className: styles.loadingText, children: loadingText })] })), jsxRuntimeExports$1.jsx("div", { className: styles.dropdownContent, children: !loading && filteredOptions.length > 0 && (jsxRuntimeExports$1.jsx(jsxRuntimeExports$1.Fragment, { children: filteredOptions.map((option, index) => {
|
|
1150
1150
|
const isSelected = option.value === value;
|
|
1151
1151
|
const isHighlighted = index === highlightedIndex;
|
|
1152
1152
|
return (jsxRuntimeExports$1.jsx("div", { ref: (el) => {
|
|
1153
1153
|
optionRefs.current[index] = el;
|
|
1154
|
-
}, onClick: () => handleSelect(option), onMouseEnter: () => setHighlightedIndex(index), className: classNames(styles.option, option.disabled && styles.optionDisabled, isHighlighted && styles.optionHighlighted, isSelected && styles.optionSelected), "data-testid": `autocomplete-option-${option.value}`, "data-disabled": option.disabled ? "true" : "false", "data-selected": isSelected ? "true" : "false", "data-highlighted": isHighlighted ? "true" : "false", children: renderOption ? (renderOption(option, isSelected)) : (jsxRuntimeExports$1.jsxs(jsxRuntimeExports$1.Fragment, { children: [jsxRuntimeExports$1.jsxs("div", { className: styles.optionContent, children: [jsxRuntimeExports$1.jsx("div", { className: styles.optionLabel, children: highlightMatchText(option.label, searchTerm, highlightMatch) }), option.description && (jsxRuntimeExports$1.jsx("div", { className: styles.optionDescription, children: option.description }))] }), isSelected && (jsxRuntimeExports$1.jsx(
|
|
1154
|
+
}, onClick: () => handleSelect(option), onMouseEnter: () => setHighlightedIndex(index), className: classNames(styles.option, option.disabled && styles.optionDisabled, isHighlighted && styles.optionHighlighted, isSelected && styles.optionSelected), "data-testid": `autocomplete-option-${option.value}`, "data-disabled": option.disabled ? "true" : "false", "data-selected": isSelected ? "true" : "false", "data-highlighted": isHighlighted ? "true" : "false", children: renderOption ? (renderOption(option, isSelected)) : (jsxRuntimeExports$1.jsxs(jsxRuntimeExports$1.Fragment, { children: [jsxRuntimeExports$1.jsxs("div", { className: styles.optionContent, children: [jsxRuntimeExports$1.jsx("div", { className: styles.optionLabel, children: highlightMatchText(option.label, searchTerm, highlightMatch) }), option.description && (jsxRuntimeExports$1.jsx("div", { className: styles.optionDescription, children: option.description }))] }), isSelected && (jsxRuntimeExports$1.jsx(p, { className: styles.optionCheckIcon }))] })) }, option.value));
|
|
1155
1155
|
}) })) }), onCreate && searchTerm && (jsxRuntimeExports$1.jsxs("div", { onClick: () => {
|
|
1156
1156
|
onCreate(searchTerm.trim());
|
|
1157
1157
|
setIsOpen(false);
|
package/dist/index.esm.js
CHANGED
|
@@ -423,7 +423,7 @@ function requireJsxRuntime$1 () {
|
|
|
423
423
|
|
|
424
424
|
var jsxRuntimeExports$1 = requireJsxRuntime$1();
|
|
425
425
|
|
|
426
|
-
var
|
|
426
|
+
var r,o={exports:{}},t={};var l,n,a={};
|
|
427
427
|
/**
|
|
428
428
|
* @license React
|
|
429
429
|
* react-jsx-runtime.development.js
|
|
@@ -432,7 +432,7 @@ var s,o={exports:{}},t={};var n,l,a={};
|
|
|
432
432
|
*
|
|
433
433
|
* This source code is licensed under the MIT license found in the
|
|
434
434
|
* LICENSE file in the root directory of this source tree.
|
|
435
|
-
*/function i(){return
|
|
435
|
+
*/function i(){return l||(l=1,"production"!==process.env.NODE_ENV&&function(){function e(s){if(null==s)return null;if("function"==typeof s)return s.$$typeof===M?null:s.displayName||s.name||null;if("string"==typeof s)return s;switch(s){case x:return "Fragment";case p:return "Profiler";case v:return "StrictMode";case f:return "Suspense";case C:return "SuspenseList";case N:return "Activity"}if("object"==typeof s)switch("number"==typeof s.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case u:return "Portal";case j:return s.displayName||"Context";case g:return (s._context.displayName||"Context")+".Consumer";case k:var r=s.render;return (s=s.displayName)||(s=""!==(s=r.displayName||r.name||"")?"ForwardRef("+s+")":"ForwardRef"),s;case L:return null!==(r=s.displayName||null)?r:e(s.type)||"Memo";case y:r=s._payload,s=s._init;try{return e(s(r))}catch(e){}}return null}function r(e){return ""+e}function o(e){try{r(e);var s=!1;}catch(e){s=true;}if(s){var o=(s=console).error,t="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",t),r(e)}}function t(s){if(s===x)return "<>";if("object"==typeof s&&null!==s&&s.$$typeof===y)return "<...>";try{var r=e(s);return r?"<"+r+">":"<...>"}catch(e){return "<...>"}}function l(){return Error("react-stack-top-frame")}function n(){var s=e(this.type);return B[s]||(B[s]=true,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(s=this.props.ref)?s:null}function i(s,r,t,l,a,i){var h,m=r.children;if(void 0!==m)if(l)if(z(m)){for(l=0;l<m.length;l++)c(m[l]);Object.freeze&&Object.freeze(m);}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else c(m);if(b.call(r,"key")){m=e(s);var u=Object.keys(r).filter(function(e){return "key"!==e});l=0<u.length?"{key: someKey, "+u.join(": ..., ")+": ...}":"{key: someKey}",W[m+l]||(u=0<u.length?"{"+u.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',l,m,u,m),W[m+l]=true);}if(m=null,void 0!==t&&(o(t),m=""+t),function(e){if(b.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return false}return void 0!==e.key}(r)&&(o(r.key),m=""+r.key),"key"in r)for(var x in t={},r)"key"!==x&&(t[x]=r[x]);else t=r;return m&&function(e,s){function r(){d||(d=true,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s));}r.isReactWarning=true,Object.defineProperty(e,"key",{get:r,configurable:true});}(t,"function"==typeof s?s.displayName||s.name||"Unknown":s),function(e,s,r,o,t,l){var a=r.ref;return e={$$typeof:w,type:e,key:s,props:r,_owner:o},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:false,get:n}):Object.defineProperty(e,"ref",{enumerable:false,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:false,enumerable:false,writable:true,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:false,enumerable:false,writable:true,value:null}),Object.defineProperty(e,"_debugStack",{configurable:false,enumerable:false,writable:true,value:t}),Object.defineProperty(e,"_debugTask",{configurable:false,enumerable:false,writable:true,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(s,m,t,null===(h=$.A)?null:h.getOwner(),a,i)}function c(e){h(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===y&&("fulfilled"===e._payload.status?h(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1));}function h(e){return "object"==typeof e&&null!==e&&e.$$typeof===w}var d,m=require$$0__default,w=Symbol.for("react.transitional.element"),u=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),j=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),$=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,z=Array.isArray,H=console.createTask?console.createTask:function(){return null},B={},V=(m={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(m,l)(),Z=H(t(l)),W={};a.Fragment=x,a.jsx=function(e,s,r){var o=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,r,false,o?Error("react-stack-top-frame"):V,o?H(t(e)):Z)},a.jsxs=function(e,s,r){var o=1e4>$.recentlyCreatedOwnerStacks++;return i(e,s,r,true,o?Error("react-stack-top-frame"):V,o?H(t(e)):Z)};}()),a}var c=(n||(n=1,"production"===process.env.NODE_ENV?o.exports=function(){if(r)return t;r=1;var e=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function o(s,r,o){var t=null;if(void 0!==o&&(t=""+o),void 0!==r.key&&(t=""+r.key),"key"in r)for(var l in o={},r)"key"!==l&&(o[l]=r[l]);else o=r;return r=o.ref,{$$typeof:e,type:s,key:t,ref:void 0!==r?r:null,props:o}}return t.Fragment=s,t.jsx=o,t.jsxs=o,t}():o.exports=i()),o.exports);function p({className:e="",size:s="md"}){const r=`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${e}`;return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:r,"aria-label":"Check",children:c.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}const y=({className:e="",size:s="md",color:r="currentColor",direction:o="down"})=>c.jsx("svg",{className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${{up:"rotate-180",down:"",left:"rotate-90",right:"-rotate-90"}[o]} ${e}`,fill:"none",stroke:r,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M6 9l6 6 6-6"})});function B({className:e="",size:s="md",color:r="currentColor"}){return c.jsx("svg",{className:`${{sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"}[s]} ${e}`,fill:"none",stroke:r,viewBox:"0 0 24 24",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})}const Xe={outlined:"material-symbols-outlined",rounded:"material-symbols-rounded",sharp:"material-symbols-sharp"},Ye=require$$0.forwardRef(({name:e,variant:s="outlined",size:r="md",fill:o=0,weight:t=400,grade:l=0,opticalSize:n=24,style:a,className:i,...h},d)=>{const m=(e=>"number"==typeof e?e:"sm"===e?16:"md"===e?20:24)(r),w=`"FILL" ${o}, "wght" ${t}, "GRAD" ${l}, "opsz" ${n}`;return c.jsx("span",{ref:d,"aria-hidden":"true",className:Xe[s]+(i?` ${i}`:""),style:{fontVariationSettings:w,fontSize:m,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",...a},...h,children:e})});Ye.displayName="MaterialIcon";
|
|
436
436
|
|
|
437
437
|
var jsxRuntime = {exports: {}};
|
|
438
438
|
|
|
@@ -1126,12 +1126,12 @@ const Autocomplete = ({ label, value, onChange, options = [], placeholder = "Sea
|
|
|
1126
1126
|
const getInputClassName = () => {
|
|
1127
1127
|
return classNames(styles.input, icon ? styles.inputWithIcon : undefined, clearable && value ? styles.inputWithClear : styles.inputWithoutClear, readOnly ? styles.inputReadOnly : undefined, error ? styles.inputError : undefined, warning && !error ? styles.inputWarning : undefined, isFocused && !error && !warning ? styles.inputFocused : undefined);
|
|
1128
1128
|
};
|
|
1129
|
-
return (jsxRuntimeExports$1.jsxs("div", { className: classNames(styles.container, className), children: [label && (jsxRuntimeExports$1.jsxs("label", { className: styles.label, children: [label, required && jsxRuntimeExports$1.jsx("span", { className: styles.required, children: "*" })] })), jsxRuntimeExports$1.jsxs("div", { ref: containerRef, className: styles.inputWrapper, children: [icon && jsxRuntimeExports$1.jsx("div", { className: styles.iconLeft, children: icon }), jsxRuntimeExports$1.jsx("input", { ref: inputRef, type: "text", value: displayValue, onChange: handleInputChange, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: disabled, readOnly: readOnly || !searchable, className: getInputClassName(), "data-testid": "autocomplete-input", "data-has-error": error ? "true" : "false", "data-has-warning": warning ? "true" : "false", "data-is-focused": isFocused ? "true" : "false" }), jsxRuntimeExports$1.jsxs("div", { className: styles.rightIcons, children: [loading && jsxRuntimeExports$1.jsx(LoadingSpinner, { size: "sm", variant: "dots", inline: true }), clearable && value && !loading && !disabled && (jsxRuntimeExports$1.jsx("button", { type: "button", onClick: handleClear, className: styles.clearButton, "data-testid": "autocomplete-clear", "aria-label": "Clear selection", children: jsxRuntimeExports$1.jsx(
|
|
1129
|
+
return (jsxRuntimeExports$1.jsxs("div", { className: classNames(styles.container, className), children: [label && (jsxRuntimeExports$1.jsxs("label", { className: styles.label, children: [label, required && jsxRuntimeExports$1.jsx("span", { className: styles.required, children: "*" })] })), jsxRuntimeExports$1.jsxs("div", { ref: containerRef, className: styles.inputWrapper, children: [icon && jsxRuntimeExports$1.jsx("div", { className: styles.iconLeft, children: icon }), jsxRuntimeExports$1.jsx("input", { ref: inputRef, type: "text", value: displayValue, onChange: handleInputChange, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: disabled, readOnly: readOnly || !searchable, className: getInputClassName(), "data-testid": "autocomplete-input", "data-has-error": error ? "true" : "false", "data-has-warning": warning ? "true" : "false", "data-is-focused": isFocused ? "true" : "false" }), jsxRuntimeExports$1.jsxs("div", { className: styles.rightIcons, children: [loading && jsxRuntimeExports$1.jsx(LoadingSpinner, { size: "sm", variant: "dots", inline: true }), clearable && value && !loading && !disabled && (jsxRuntimeExports$1.jsx("button", { type: "button", onClick: handleClear, className: styles.clearButton, "data-testid": "autocomplete-clear", "aria-label": "Clear selection", children: jsxRuntimeExports$1.jsx(B, { className: "w-4 h-4" }) })), jsxRuntimeExports$1.jsx("button", { type: "button", onClick: handleToggle, className: styles.toggleButton, disabled: disabled, "data-testid": "autocomplete-toggle", "aria-label": isOpen ? "Close dropdown" : "Open dropdown", children: jsxRuntimeExports$1.jsx(y, { className: classNames(styles.toggleIcon, isOpen && styles.toggleIconOpen) }) })] }), isOpen && !disabled && !readOnly && (jsxRuntimeExports$1.jsxs("div", { ref: dropdownRef, className: classNames(styles.dropdown, position === "top" && styles.dropdownTop), style: { maxHeight }, "data-testid": "autocomplete-dropdown", children: [loading && filteredOptions.length === 0 && (jsxRuntimeExports$1.jsxs("div", { className: styles.loadingState, children: [jsxRuntimeExports$1.jsx(LoadingSpinner, { size: "sm", variant: "spinner", className: styles.loadingSpinner }), jsxRuntimeExports$1.jsx("span", { className: styles.loadingText, children: loadingText })] })), jsxRuntimeExports$1.jsx("div", { className: styles.dropdownContent, children: !loading && filteredOptions.length > 0 && (jsxRuntimeExports$1.jsx(jsxRuntimeExports$1.Fragment, { children: filteredOptions.map((option, index) => {
|
|
1130
1130
|
const isSelected = option.value === value;
|
|
1131
1131
|
const isHighlighted = index === highlightedIndex;
|
|
1132
1132
|
return (jsxRuntimeExports$1.jsx("div", { ref: (el) => {
|
|
1133
1133
|
optionRefs.current[index] = el;
|
|
1134
|
-
}, onClick: () => handleSelect(option), onMouseEnter: () => setHighlightedIndex(index), className: classNames(styles.option, option.disabled && styles.optionDisabled, isHighlighted && styles.optionHighlighted, isSelected && styles.optionSelected), "data-testid": `autocomplete-option-${option.value}`, "data-disabled": option.disabled ? "true" : "false", "data-selected": isSelected ? "true" : "false", "data-highlighted": isHighlighted ? "true" : "false", children: renderOption ? (renderOption(option, isSelected)) : (jsxRuntimeExports$1.jsxs(jsxRuntimeExports$1.Fragment, { children: [jsxRuntimeExports$1.jsxs("div", { className: styles.optionContent, children: [jsxRuntimeExports$1.jsx("div", { className: styles.optionLabel, children: highlightMatchText(option.label, searchTerm, highlightMatch) }), option.description && (jsxRuntimeExports$1.jsx("div", { className: styles.optionDescription, children: option.description }))] }), isSelected && (jsxRuntimeExports$1.jsx(
|
|
1134
|
+
}, onClick: () => handleSelect(option), onMouseEnter: () => setHighlightedIndex(index), className: classNames(styles.option, option.disabled && styles.optionDisabled, isHighlighted && styles.optionHighlighted, isSelected && styles.optionSelected), "data-testid": `autocomplete-option-${option.value}`, "data-disabled": option.disabled ? "true" : "false", "data-selected": isSelected ? "true" : "false", "data-highlighted": isHighlighted ? "true" : "false", children: renderOption ? (renderOption(option, isSelected)) : (jsxRuntimeExports$1.jsxs(jsxRuntimeExports$1.Fragment, { children: [jsxRuntimeExports$1.jsxs("div", { className: styles.optionContent, children: [jsxRuntimeExports$1.jsx("div", { className: styles.optionLabel, children: highlightMatchText(option.label, searchTerm, highlightMatch) }), option.description && (jsxRuntimeExports$1.jsx("div", { className: styles.optionDescription, children: option.description }))] }), isSelected && (jsxRuntimeExports$1.jsx(p, { className: styles.optionCheckIcon }))] })) }, option.value));
|
|
1135
1135
|
}) })) }), onCreate && searchTerm && (jsxRuntimeExports$1.jsxs("div", { onClick: () => {
|
|
1136
1136
|
onCreate(searchTerm.trim());
|
|
1137
1137
|
setIsOpen(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubenpazch/autocomplete",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Autocomplete component",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"react-dom": "^19.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@rubenpazch/icons": "
|
|
34
|
+
"@rubenpazch/icons": "5.0.0",
|
|
35
35
|
"@rubenpazch/loading-spinner": "3.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|