Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-customize-token-input

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-customize-token-input - npm Package Compare versions

Comparing version 1.3.1 to 1.4.1

dist/react-customize-token-input.original.css

2

lib/index.js
/*! For license information please see index.js.LICENSE.txt */
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(require("react")):t(e.React);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(function(e){return(()=>{var t={184:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var a=typeof n;if("string"===a||"number"===a)e.push(n);else if(Array.isArray(n)){if(n.length){var u=o.apply(null,n);u&&e.push(u)}}else if("object"===a)if(n.toString===Object.prototype.toString)for(var i in n)r.call(n,i)&&n[i]&&e.push(i);else e.push(n.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},703:(e,t,n)=>{"use strict";var r=n(414);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,u){if(u!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},697:(e,t,n)=>{e.exports=n(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},639:(e,t,n)=>{"use strict";var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(698),u=l(a),i=l(n(697));function l(e){return e&&e.__esModule?e:{default:e}}var s={position:"absolute",top:0,left:0,visibility:"hidden",height:0,overflow:"scroll",whiteSpace:"pre"},c=["extraWidth","injectStyles","inputClassName","inputRef","inputStyle","minWidth","onAutosize","placeholderIsMinWidth"],f=function(e,t){t.style.fontSize=e.fontSize,t.style.fontFamily=e.fontFamily,t.style.fontWeight=e.fontWeight,t.style.fontStyle=e.fontStyle,t.style.letterSpacing=e.letterSpacing,t.style.textTransform=e.textTransform},p=!("undefined"==typeof window||!window.navigator)&&/MSIE |Trident\/|Edge\//.test(window.navigator.userAgent),d=function(){return p?"_"+Math.random().toString(36).substr(2,12):void 0},y=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.inputRef=function(e){n.input=e,"function"==typeof n.props.inputRef&&n.props.inputRef(e)},n.placeHolderSizerRef=function(e){n.placeHolderSizer=e},n.sizerRef=function(e){n.sizer=e},n.state={inputWidth:e.minWidth,inputId:e.id||d(),prevId:e.id},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,null,[{key:"getDerivedStateFromProps",value:function(e,t){var n=e.id;return n!==t.prevId?{inputId:n||d(),prevId:n}:null}}]),o(t,[{key:"componentDidMount",value:function(){this.mounted=!0,this.copyInputStyles(),this.updateInputWidth()}},{key:"componentDidUpdate",value:function(e,t){t.inputWidth!==this.state.inputWidth&&"function"==typeof this.props.onAutosize&&this.props.onAutosize(this.state.inputWidth),this.updateInputWidth()}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"copyInputStyles",value:function(){if(this.mounted&&window.getComputedStyle){var e=this.input&&window.getComputedStyle(this.input);e&&(f(e,this.sizer),this.placeHolderSizer&&f(e,this.placeHolderSizer))}}},{key:"updateInputWidth",value:function(){if(this.mounted&&this.sizer&&void 0!==this.sizer.scrollWidth){var e=void 0;e=this.props.placeholder&&(!this.props.value||this.props.value&&this.props.placeholderIsMinWidth)?Math.max(this.sizer.scrollWidth,this.placeHolderSizer.scrollWidth)+2:this.sizer.scrollWidth+2,(e+="number"===this.props.type&&void 0===this.props.extraWidth?16:parseInt(this.props.extraWidth)||0)<this.props.minWidth&&(e=this.props.minWidth),e!==this.state.inputWidth&&this.setState({inputWidth:e})}}},{key:"getInput",value:function(){return this.input}},{key:"focus",value:function(){this.input.focus()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"renderStyles",value:function(){var e=this.props.injectStyles;return p&&e?u.default.createElement("style",{dangerouslySetInnerHTML:{__html:"input#"+this.state.inputId+"::-ms-clear {display: none;}"}}):null}},{key:"render",value:function(){var e=[this.props.defaultValue,this.props.value,""].reduce((function(e,t){return null!=e?e:t})),t=r({},this.props.style);t.display||(t.display="inline-block");var n=r({boxSizing:"content-box",width:this.state.inputWidth+"px"},this.props.inputStyle),o=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(this.props,[]);return function(e){c.forEach((function(t){return delete e[t]}))}(o),o.className=this.props.inputClassName,o.id=this.state.inputId,o.style=n,u.default.createElement("div",{className:this.props.className,style:t},this.renderStyles(),u.default.createElement("input",r({},o,{ref:this.inputRef})),u.default.createElement("div",{ref:this.sizerRef,style:s},e),this.props.placeholder?u.default.createElement("div",{ref:this.placeHolderSizerRef,style:s},this.props.placeholder):null)}}]),t}(a.Component);y.propTypes={className:i.default.string,defaultValue:i.default.any,extraWidth:i.default.oneOfType([i.default.number,i.default.string]),id:i.default.string,injectStyles:i.default.bool,inputClassName:i.default.string,inputRef:i.default.func,inputStyle:i.default.object,minWidth:i.default.oneOfType([i.default.number,i.default.string]),onAutosize:i.default.func,onChange:i.default.func,placeholder:i.default.string,placeholderIsMinWidth:i.default.bool,style:i.default.object,value:i.default.any},y.defaultProps={minWidth:1,injectStyles:!0},t.Z=y},698:t=>{"use strict";t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";r.r(o),r.d(o,{default:()=>U});var e=r(698),t=r.n(e),n=r(697),a=r.n(n),u=r(184),i=r.n(u),l=r(639);const s=function(e,t){var n=t.onBackspace,r=void 0===n?function(){}:n,o=t.onEnter,a=void 0===o?function(){}:o,u=t.onEscape,i=void 0===u?function(){}:u,l={Backspace:"Backspace",Enter:"Enter",Escape:"Escape"}[e.key];switch(e.keyCode&&229===e.keyCode&&(l="Process"),void 0===l&&(l={8:"Backspace",13:"Enter",27:"Escape"}[e.keyCode]),l){case"Backspace":r();break;case"Enter":a();break;case"Escape":i()}},c="customize-token-input---token---gTkkf",f="customize-token-input---autosized-wrapper---TXzhr";var p="token-delete-button";function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var y=(0,e.forwardRef)((function(n,r){var o,a,u=n.separators,i=n.onPreprocess,c=n.onBuildTokenValue,p=n.onNewTokenValuesAppend,y=n.onLastTokenDelete,h=n.placeholder,m=n.autoFocus,b=n.onFocus,v=n.onBlur,k=n.onInputValueChange,g=(o=(0,e.useState)(""),a=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return a}}(o,a)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(o,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),T=g[0],S=g[1],C=(0,e.useMemo)((function(){return new RegExp(u.join("|"))}),[u]),E=(0,e.useCallback)((function(e){S(e),k(e,T)}),[k,T,S]),w=(0,e.useCallback)((function(e){if(0!==e.trim().length){var t=e.split(C).filter((function(e){return e.trim().length>0})),n=i(t).map((function(e){return c(e)}));p(n),E("")}}),[C,i,c,p,E]),A=(0,e.useCallback)((function(e){var t=e.target.value,n=t.substring(t.length-1);!0!==C.test(n)?E(t):w(T)}),[C,w,T,E]),I=(0,e.useCallback)((function(e){s(e,{onBackspace:function(){0===T.length&&y()},onEscape:function(){return E("")},onEnter:function(){return w(T)}})}),[T,y,E,w]),O=(0,e.useCallback)((function(e){w(T),v(e)}),[w,T,v]),j=(0,e.useCallback)((function(e){e.preventDefault();var t=e.clipboardData.getData("text");w(t)}),[w]);return t().createElement("div",{className:f},t().createElement(l.Z,{ref:r,autoFocus:m,placeholder:h,value:T,onChange:A,onKeyDown:I,onPaste:j,onFocus:b,onBlur:O}))}));y.displayName="TokenCreator",y.propTypes={placeholder:a().string.isRequired,autoFocus:a().bool.isRequired,onFocus:a().func.isRequired,onBlur:a().func.isRequired,separators:a().array.isRequired,onInputValueChange:a().func.isRequired,onPreprocess:a().func.isRequired,onBuildTokenValue:a().func.isRequired,onNewTokenValuesAppend:a().func.isRequired,onLastTokenDelete:a().func.isRequired};const h=y,m=function(){return t().createElement("div",{role:"img",className:"customize-token-input---close-icon---BBHmf","aria-hidden":"true","data-component-name":"CloseIcon"})};var b=function(e){var n=e.onRenderContent,r="function"==typeof n;return t().createElement("span",{role:"button",className:i()(p,"customize-token-input---delete-button---RxqGs"),"aria-hidden":"true","data-component-name":"DeleteButton"},r&&n(),!r&&t().createElement(m,null))};b.propTypes={onRenderContent:a().func};const v=b;function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var T=function(e){e.stopPropagation()},S=function(n){var r,o,a=n.readOnly,u=n.tokenValue,d=n.tokenMeta,y=n.onGetClassName,h=n.onGetDisplayLabel,m=n.onRenderDeleteButtonContent,b=n.onGetEditableValue,S=n.onGetErrorMessage,C=n.onBuildTokenValue,E=n.onEditStart,w=n.onEditEnd,A=n.onDelete,I=(0,e.useRef)(null),O=(r=(0,e.useState)(""),o=2,function(e){if(Array.isArray(e))return e}(r)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return a}}(r,o)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(r,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),j=O[0],V=O[1],R=d.activated,M=d.error,x=(0,e.useCallback)((function(){var e=b(u,d);V(e),E()}),[V,u,d,b,E]);(0,e.useEffect)((function(){R&&I.current&&I.current.focus()}),[R]);var z=(0,e.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.reset,n=void 0!==t&&t,r=0===j.length;if(n||r)w();else{var o=C(j);w(o)}}),[j,C,w]),P=(0,e.useCallback)((function(e){e.stopPropagation(),a||(e.target.closest(".".concat(c," .").concat(p))?A():x())}),[a,A,x]),B=(0,e.useCallback)((function(e){var t=e.target.value;V(t)}),[V]),D=(0,e.useCallback)((function(e){s(e,{onEscape:function(){return z({reset:!0})},onEnter:function(){return z()}})}),[z]),N=(0,e.useCallback)((function(){z()}),[z]),W=(0,e.useMemo)((function(){var e;return i()(y(u,d),c,(k(e={},"customize-token-input---active---jZZPP",R),k(e,"customize-token-input---error---eNFRx",M&&!R),k(e,"customize-token-input---read-only---_IB6t",a),e))}),[a,M,R,y,u,d]),G=(0,e.useMemo)((function(){return S(u,d)}),[S,u,d]);return R?t().createElement("div",{role:"presentation",className:W,onClick:T},t().createElement("div",{className:f},t().createElement(l.Z,{ref:I,value:j,onChange:B,onKeyDown:D,onBlur:N}))):t().createElement("div",{role:"presentation",className:W,onClick:P,title:G,"data-component-name":"Token"},t().createElement("div",{className:"customize-token-input---label-wrapper---RRpXn"},h(u,d)),!a&&t().createElement(v,{onRenderContent:m}))};S.propTypes={readOnly:a().bool.isRequired,tokenValue:a().any.isRequired,tokenMeta:a().object.isRequired,onGetClassName:a().func.isRequired,onGetDisplayLabel:a().func.isRequired,onRenderDeleteButtonContent:a().func,onGetEditableValue:a().func.isRequired,onGetErrorMessage:a().func.isRequired,onBuildTokenValue:a().func.isRequired,onEditStart:a().func.isRequired,onEditEnd:a().func.isRequired,onDelete:a().func.isRequired};const C=S;function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const w=function(){var t,n,r=(t=(0,e.useState)(!1),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return a}}(t,n)||function(e,t){if(e){if("string"==typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=r[0],a=r[1];return{isTokenInputFocused:o,handleTokenInputFocus:(0,e.useCallback)((function(){a(!0)}),[]),handleTokenInputBlur:(0,e.useCallback)((function(){a(!1)}),[])}},A=function(e,t,n){return{key:"".concat(JSON.stringify(t),"-").concat(Date.now(),"-").concat(n),activated:!1,error:e}};function I(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const j=function(){var t,n,r=(t=(0,e.useState)([]),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return a}}(t,n)||I(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=r[0],a=r[1],u=(0,e.useCallback)((function(e,t){if(e>=o.length)throw new Error("setTokenActivated out of tokenMetas scope; targetIndex ".concat(e,"; tokenMetas.length ").concat(o.length));var n=function(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(o);n[e].activated=t,a(n)}),[o]);return{buildTokenMeta:A,tokenMetas:o,setTokenMetas:a,setTokenActivated:u}};function V(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return a}}(e,t)||R(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e,t){if(e){if("string"==typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const x=function(t){var n=t.tokenValues,r=t.onTokenValueValidate,o=j(),a=o.buildTokenMeta,u=o.tokenMetas,i=o.setTokenMetas,l=o.setTokenActivated,s=V((0,e.useState)(!1),2),c=s[0],f=s[1],p=V((0,e.useState)([]),2),d=p[0],y=p[1];return(0,e.useLayoutEffect)((function(){var e,t=!1,o=n.map((function(e,o){var u=r(e,o,n),i=a(u,e,o);return i.error&&!i.activated&&(t=!0),i}));y(function(e){if(Array.isArray(e))return M(e)}(e=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||R(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i(o),f(t)}),[n,r,i,a]),{hasInvalidToken:c,internalTokenValues:d,tokenMetas:u,setTokenActivated:l}};function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const P=function(t){var n=t.tokenValues,r=t.onTokenValuesChange,o=t.setTokenActivated,a=t.handleTokenInputFocus,u=t.handleTokenInputBlur,i=t.focusTokenCreator;return{handleTokenEditStart:(0,e.useCallback)((function(e){return function(){o(e,!0),a()}}),[o,a]),handleTokenEditEnd:(0,e.useCallback)((function(e){return function(t){if(o(e,!1),u(),i(),void 0!==t){var a=function(e){if(Array.isArray(e))return z(e)}(l=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||function(e,t){if(e){if("string"==typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,t):void 0}}(l)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();a[e]=t,r(a)}var l}}),[n,r,o,u,i])}};function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const D=function(t){var n=t.tokenValues,r=t.onTokenValuesChange,o=t.focusTokenCreator,a=(0,e.useCallback)((function(e){var t,a=function(e){if(Array.isArray(e))return B(e)}(t=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();a.splice(e,1),r(a),o()}),[n,r,o]);return{handleTokenDelete:(0,e.useCallback)((function(e){return function(){a(e)}}),[a]),handleLastTokenDelete:(0,e.useCallback)((function(){a(-1)}),[a])}},N=function(e,t){return e};var W=["className","readOnly","autoFocus","placeholder","tokenValues","onTokenValuesChange","onBuildTokenValue","customizeTokenComponent","onGetTokenClassName","onGetTokenDisplayLabel","onRenderTokenDeleteButtonContent","onGetTokenEditableValue","onGetTokenErrorMessage","separators","onPreprocess","onInputValueChange","onTokenValueValidate"];function G(){return(G=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function _(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function q(e){return function(e){if(Array.isArray(e))return F(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?F(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var L=function(n){var r,o=n.className,a=n.readOnly,u=n.autoFocus,l=n.placeholder,s=n.tokenValues,c=n.onTokenValuesChange,f=n.onBuildTokenValue,p=n.customizeTokenComponent,d=n.onGetTokenClassName,y=n.onGetTokenDisplayLabel,m=n.onRenderTokenDeleteButtonContent,b=n.onGetTokenEditableValue,v=n.onGetTokenErrorMessage,k=n.separators,g=n.onPreprocess,T=n.onInputValueChange,S=n.onTokenValueValidate,E=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(n,W),A=w(),I=A.isTokenInputFocused,O=A.handleTokenInputFocus,j=A.handleTokenInputBlur,V=function(){var t=(0,e.useRef)(null),n=(0,e.useCallback)((function(){t&&t.current&&t.current.focus()}),[]);return{tokenCreatorRef:t,focusTokenCreator:n}}(),R=V.tokenCreatorRef,M=V.focusTokenCreator,z=x({tokenValues:s,onTokenValueValidate:S}),B=z.hasInvalidToken,N=z.internalTokenValues,F=z.tokenMetas,L=z.setTokenActivated,U=P({tokenValues:s,onTokenValuesChange:c,setTokenActivated:L,handleTokenInputFocus:O,handleTokenInputBlur:j,focusTokenCreator:M}),H=U.handleTokenEditStart,$=U.handleTokenEditEnd,Z=D({tokenValues:s,onTokenValuesChange:c,focusTokenCreator:M}),X=Z.handleTokenDelete,K=Z.handleLastTokenDelete,Y=(0,e.useCallback)((function(e){if(0!==e.length){var t=[].concat(q(s),q(e));c(t)}}),[s,c]),J=(0,e.useCallback)((function(e){if("function"!=typeof g)return e;var t=g(e);if(!0!==Array.isArray(t))throw new Error("onPreprocess should return an array of values");return t}),[g]),Q=p||C;return t().createElement("div",G({},E,{className:i()(o,"customize-token-input---container---F6cN_",(r={},_(r,"customize-token-input---focused---k4Zch",I),_(r,"customize-token-input---errors---QXs7u",B),r)),onClick:M,role:"presentation","data-component-name":"TokenInput"}),t().createElement("div",{className:"customize-token-input---token-list---mZYkR"},N.map((function(e,n){var r=F[n],o=r.key;return t().createElement(Q,{key:o,readOnly:a,tokenValue:e,tokenMeta:r,onGetClassName:d,onGetDisplayLabel:y,onRenderDeleteButtonContent:m,onGetEditableValue:b,onGetErrorMessage:v,onBuildTokenValue:f,onEditStart:H(n),onEditEnd:$(n),onDelete:X(n)})}))),!a&&t().createElement(h,{ref:R,placeholder:l,autoFocus:u,onFocus:O,onBlur:j,separators:k,onPreprocess:J,onBuildTokenValue:f,onNewTokenValuesAppend:Y,onLastTokenDelete:K,onInputValueChange:T}))};L.propTypes={style:a().object,className:a().string,readOnly:a().bool,autoFocus:a().bool,placeholder:a().string,tokenValues:a().array.isRequired,onTokenValuesChange:a().func,separators:a().array,onPreprocess:a().func,onBuildTokenValue:a().func,onInputValueChange:a().func,onTokenValueValidate:a().func,onGetTokenClassName:a().func,onGetTokenDisplayLabel:a().func,onRenderTokenDeleteButtonContent:a().func,onGetTokenEditableValue:a().func,onGetTokenErrorMessage:a().func,customizeTokenComponent:a().func},L.defaultProps={className:"",readOnly:!1,autoFocus:!1,placeholder:"",separators:[",",";","\n","\r","\r\n"],onBuildTokenValue:function(e){return e.trim()},onInputValueChange:function(){},onTokenValueValidate:function(){},onGetTokenClassName:function(){return""},onGetTokenDisplayLabel:N,onGetTokenEditableValue:N,onGetTokenErrorMessage:function(e,t){if("string"==typeof t.error)return t.error}};const U=L})(),o})()}));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(require("react")):t(e.React);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(function(e){return(()=>{var t={184:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var a=typeof n;if("string"===a||"number"===a)e.push(n);else if(Array.isArray(n)){if(n.length){var i=o.apply(null,n);i&&e.push(i)}}else if("object"===a)if(n.toString===Object.prototype.toString)for(var u in n)r.call(n,u)&&n[u]&&e.push(u);else e.push(n.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},703:(e,t,n)=>{"use strict";var r=n(414);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,i){if(i!==r){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},697:(e,t,n)=>{e.exports=n(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},639:(e,t,n)=>{"use strict";var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(698),i=l(a),u=l(n(697));function l(e){return e&&e.__esModule?e:{default:e}}var s={position:"absolute",top:0,left:0,visibility:"hidden",height:0,overflow:"scroll",whiteSpace:"pre"},c=["extraWidth","injectStyles","inputClassName","inputRef","inputStyle","minWidth","onAutosize","placeholderIsMinWidth"],f=function(e,t){t.style.fontSize=e.fontSize,t.style.fontFamily=e.fontFamily,t.style.fontWeight=e.fontWeight,t.style.fontStyle=e.fontStyle,t.style.letterSpacing=e.letterSpacing,t.style.textTransform=e.textTransform},p=!("undefined"==typeof window||!window.navigator)&&/MSIE |Trident\/|Edge\//.test(window.navigator.userAgent),d=function(){return p?"_"+Math.random().toString(36).substr(2,12):void 0},y=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.inputRef=function(e){n.input=e,"function"==typeof n.props.inputRef&&n.props.inputRef(e)},n.placeHolderSizerRef=function(e){n.placeHolderSizer=e},n.sizerRef=function(e){n.sizer=e},n.state={inputWidth:e.minWidth,inputId:e.id||d(),prevId:e.id},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,null,[{key:"getDerivedStateFromProps",value:function(e,t){var n=e.id;return n!==t.prevId?{inputId:n||d(),prevId:n}:null}}]),o(t,[{key:"componentDidMount",value:function(){this.mounted=!0,this.copyInputStyles(),this.updateInputWidth()}},{key:"componentDidUpdate",value:function(e,t){t.inputWidth!==this.state.inputWidth&&"function"==typeof this.props.onAutosize&&this.props.onAutosize(this.state.inputWidth),this.updateInputWidth()}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"copyInputStyles",value:function(){if(this.mounted&&window.getComputedStyle){var e=this.input&&window.getComputedStyle(this.input);e&&(f(e,this.sizer),this.placeHolderSizer&&f(e,this.placeHolderSizer))}}},{key:"updateInputWidth",value:function(){if(this.mounted&&this.sizer&&void 0!==this.sizer.scrollWidth){var e=void 0;e=this.props.placeholder&&(!this.props.value||this.props.value&&this.props.placeholderIsMinWidth)?Math.max(this.sizer.scrollWidth,this.placeHolderSizer.scrollWidth)+2:this.sizer.scrollWidth+2,(e+="number"===this.props.type&&void 0===this.props.extraWidth?16:parseInt(this.props.extraWidth)||0)<this.props.minWidth&&(e=this.props.minWidth),e!==this.state.inputWidth&&this.setState({inputWidth:e})}}},{key:"getInput",value:function(){return this.input}},{key:"focus",value:function(){this.input.focus()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"renderStyles",value:function(){var e=this.props.injectStyles;return p&&e?i.default.createElement("style",{dangerouslySetInnerHTML:{__html:"input#"+this.state.inputId+"::-ms-clear {display: none;}"}}):null}},{key:"render",value:function(){var e=[this.props.defaultValue,this.props.value,""].reduce((function(e,t){return null!=e?e:t})),t=r({},this.props.style);t.display||(t.display="inline-block");var n=r({boxSizing:"content-box",width:this.state.inputWidth+"px"},this.props.inputStyle),o=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(this.props,[]);return function(e){c.forEach((function(t){return delete e[t]}))}(o),o.className=this.props.inputClassName,o.id=this.state.inputId,o.style=n,i.default.createElement("div",{className:this.props.className,style:t},this.renderStyles(),i.default.createElement("input",r({},o,{ref:this.inputRef})),i.default.createElement("div",{ref:this.sizerRef,style:s},e),this.props.placeholder?i.default.createElement("div",{ref:this.placeHolderSizerRef,style:s},this.props.placeholder):null)}}]),t}(a.Component);y.propTypes={className:u.default.string,defaultValue:u.default.any,extraWidth:u.default.oneOfType([u.default.number,u.default.string]),id:u.default.string,injectStyles:u.default.bool,inputClassName:u.default.string,inputRef:u.default.func,inputStyle:u.default.object,minWidth:u.default.oneOfType([u.default.number,u.default.string]),onAutosize:u.default.func,onChange:u.default.func,placeholder:u.default.string,placeholderIsMinWidth:u.default.bool,style:u.default.object,value:u.default.any},y.defaultProps={minWidth:1,injectStyles:!0},t.Z=y},698:t=>{"use strict";t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";r.r(o),r.d(o,{JS__TOKEN__DELETE_BUTTON__CLASS_NAME:()=>p,default:()=>X});var e=r(698),t=r.n(e),n=r(697),a=r.n(n),i=r(184),u=r.n(i),l=r(639);var s=function(){};const c=function(e,t){var n=t.onBackspace,r=void 0===n?s:n,o=t.onTab,a=void 0===o?s:o,i=t.onEnter,u=void 0===i?s:i,l=t.onEscape,c=void 0===l?s:l;switch(function(e){var t=e.key,n=e.keyCode,r=t;return n&&229===n&&(r="Process"),{key:r}}(e).key){case"Backspace":r(e);break;case"Tab":a(e);break;case"Enter":u(e);break;case"Escape":c(e)}};var f={onBackspace:1,onTab:0,onEnter:1,onEscape:1},p="js__token__delete-button";function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var b=function(e){var t=e.keyDownEvent,n=e.onKey,r=e.predefinedHandler;switch(!0){case 1===n:r(t)}};const v=function(t){var n=t.specialKeyDown,r=t.inputInitValue,o=t.inputValue,a=t.onLastTokenDelete,i=t.handleInputValueUpdate,u=t.handleTokensCreate,l=y(y({},f),n),s=l.onBackspace,c=l.onTab,p=l.onEnter,d=l.onEscape;return{handleBackspaceKeyDown:(0,e.useCallback)((function(e){b({keyDownEvent:e,onKey:s,predefinedHandler:function(){0===o.length&&a()}})}),[s,o,a]),handleTabKeyDown:(0,e.useCallback)((function(e){b({keyDownEvent:e,onKey:c,predefinedHandler:function(e){e.preventDefault(),u(o)}})}),[c,o,u]),handleEnterKeyDown:(0,e.useCallback)((function(e){b({keyDownEvent:e,onKey:p,predefinedHandler:function(){u(o)}})}),[p,o,u]),handleEscapeKeyDown:(0,e.useCallback)((function(e){b({keyDownEvent:e,onKey:d,predefinedHandler:function(){i(r)}})}),[d,r,i])}},m="token-input-token",k="token-input-autosized-wrapper";function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var T=(0,e.forwardRef)((function(n,r){var o,a,i=n.placeholder,u=n.autoFocus,s=n.onFocus,f=n.onBlur,p=n.separators,d=n.specialKeyDown,y=n.onInputValueChange,h=n.onPreprocess,b=n.onBuildTokenValue,m=n.onNewTokenValuesAppend,T=n.onLastTokenDelete,w=(o=(0,e.useState)(""),a=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}(o,a)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(o,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),S=w[0],E=w[1],C=(0,e.useMemo)((function(){return new RegExp(p.join("|"))}),[p]),O=(0,e.useCallback)((function(e){E(e),y(e,S)}),[y,S,E]),j=(0,e.useCallback)((function(e){if(0!==e.trim().length){var t=e.split(C).filter((function(e){return e.trim().length>0})),n=h(t).map((function(e){return b(e)}));m(n),O("")}}),[C,h,b,m,O]),A=(0,e.useCallback)((function(e){var t=e.target.value,n=t.substring(t.length-1);!0!==C.test(n)?O(t):j(S)}),[C,j,S,O]),I=v({specialKeyDown:d,inputInitValue:"",inputValue:S,onLastTokenDelete:T,handleInputValueUpdate:O,handleTokensCreate:j}),V=I.handleBackspaceKeyDown,D=I.handleTabKeyDown,R=I.handleEnterKeyDown,_=I.handleEscapeKeyDown,P=(0,e.useCallback)((function(e){c(e,{onBackspace:V,onTab:D,onEnter:R,onEscape:_})}),[V,D,R,_]),M=(0,e.useCallback)((function(e){j(S),f(e)}),[j,S,f]),x=(0,e.useCallback)((function(e){e.preventDefault();var t=e.clipboardData.getData("text");j(t)}),[j]);return t().createElement("div",{className:k},t().createElement(l.Z,{ref:r,autoFocus:u,placeholder:i,value:S,onChange:A,onKeyDown:P,onPaste:x,onFocus:s,onBlur:M}))}));T.displayName="TokenCreator",T.propTypes={placeholder:a().string.isRequired,autoFocus:a().bool.isRequired,onFocus:a().func.isRequired,onBlur:a().func.isRequired,separators:a().array.isRequired,specialKeyDown:a().object.isRequired,onInputValueChange:a().func.isRequired,onPreprocess:a().func.isRequired,onBuildTokenValue:a().func.isRequired,onNewTokenValuesAppend:a().func.isRequired,onLastTokenDelete:a().func.isRequired};const w=T,S=function(){return t().createElement("div",{role:"img",className:"token-input-token__delete-button__close-icon","aria-hidden":"true","data-component-name":"CloseIcon"})};var E=function(e){var n=e.onRenderContent,r="function"==typeof n;return t().createElement("span",{role:"button",className:u()(p,"token-input-token__delete-button"),"aria-hidden":"true","data-component-name":"DeleteButton"},r&&n(),!r&&t().createElement(S,null))};E.propTypes={onRenderContent:a().func};const C=E;function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var A=function(e){e.stopPropagation()},I=function(n){var r,o,a=n.readOnly,i=n.tokenValue,s=n.tokenMeta,f=n.onGetClassName,d=n.onGetDisplayLabel,y=n.onRenderDeleteButtonContent,h=n.onGetEditableValue,b=n.onGetErrorMessage,v=n.onBuildTokenValue,g=n.onEditStart,T=n.onEditEnd,w=n.onDelete,S=(0,e.useRef)(null),E=(r=(0,e.useState)(""),o=2,function(e){if(Array.isArray(e))return e}(r)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}(r,o)||function(e,t){if(e){if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?j(e,t):void 0}}(r,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),I=E[0],V=E[1],D=s.activated,R=s.error,_=(0,e.useCallback)((function(){var e=h(i,s);V(e),g()}),[V,i,s,h,g]);(0,e.useEffect)((function(){D&&S.current&&S.current.focus()}),[D]);var P=(0,e.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.reset,n=void 0!==t&&t,r=0===I.length;if(n||r)T();else{var o=v(I);T(o)}}),[I,v,T]),M=(0,e.useCallback)((function(e){e.stopPropagation(),a||(e.target.closest(".".concat(m," .").concat(p))?w():_())}),[a,w,_]),x=(0,e.useCallback)((function(e){var t=e.target.value;V(t)}),[V]),B=(0,e.useCallback)((function(e){c(e,{onEscape:function(){return P({reset:!0})},onEnter:function(){return P()}})}),[P]),N=(0,e.useCallback)((function(){P()}),[P]),W=(0,e.useMemo)((function(){var e;return u()(f(i,s),m,(O(e={},"token-input-token--active",D),O(e,"token-input-token--error",R&&!D),O(e,"token-input-token--read-only",a),e))}),[a,R,D,f,i,s]),G=(0,e.useMemo)((function(){return b(i,s)}),[b,i,s]);return D?t().createElement("div",{role:"presentation",className:W,onClick:A},t().createElement("div",{className:k},t().createElement(l.Z,{ref:S,value:I,onChange:x,onKeyDown:B,onBlur:N}))):t().createElement("div",{role:"presentation",className:W,onClick:M,title:G,"data-component-name":"Token"},t().createElement("div",{className:"token-input-token__label-wrapper"},d(i,s)),!a&&t().createElement(C,{onRenderContent:y}))};I.propTypes={readOnly:a().bool.isRequired,tokenValue:a().any.isRequired,tokenMeta:a().object.isRequired,onGetClassName:a().func.isRequired,onGetDisplayLabel:a().func.isRequired,onRenderDeleteButtonContent:a().func,onGetEditableValue:a().func.isRequired,onGetErrorMessage:a().func.isRequired,onBuildTokenValue:a().func.isRequired,onEditStart:a().func.isRequired,onEditEnd:a().func.isRequired,onDelete:a().func.isRequired};const V=I;function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const R=function(){var t,n,r=(t=(0,e.useState)(!1),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}(t,n)||function(e,t){if(e){if("string"==typeof e)return D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?D(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=r[0],a=r[1];return{isTokenInputFocused:o,handleTokenInputFocus:(0,e.useCallback)((function(){a(!0)}),[]),handleTokenInputBlur:(0,e.useCallback)((function(){a(!1)}),[])}},_=function(e,t,n){return{key:"".concat(JSON.stringify(t),"-").concat(Date.now(),"-").concat(n),activated:!1,error:e}};function P(e,t){if(e){if("string"==typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const x=function(){var t,n,r=(t=(0,e.useState)([]),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}(t,n)||P(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=r[0],a=r[1],i=(0,e.useCallback)((function(e,t){if(e>=o.length)throw new Error("setTokenActivated out of tokenMetas scope; targetIndex ".concat(e,"; tokenMetas.length ").concat(o.length));var n=function(e){return function(e){if(Array.isArray(e))return M(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||P(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(o);n[e].activated=t,a(n)}),[o]);return{buildTokenMeta:_,tokenMetas:o,setTokenMetas:a,setTokenActivated:i}};function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}(e,t)||N(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){if(e){if("string"==typeof e)return W(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?W(e,t):void 0}}function W(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const G=function(t){var n=t.tokenValues,r=t.onTokenValueValidate,o=x(),a=o.buildTokenMeta,i=o.tokenMetas,u=o.setTokenMetas,l=o.setTokenActivated,s=B((0,e.useState)(!1),2),c=s[0],f=s[1],p=B((0,e.useState)([]),2),d=p[0],y=p[1];return(0,e.useLayoutEffect)((function(){var e,t=!1,o=n.map((function(e,o){var i=r(e,o,n),u=a(i,e,o);return u.error&&!u.activated&&(t=!0),u}));y(function(e){if(Array.isArray(e))return W(e)}(e=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||N(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u(o),f(t)}),[n,r,u,a]),{hasInvalidToken:c,internalTokenValues:d,tokenMetas:i,setTokenActivated:l}};function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const z=function(t){var n=t.tokenValues,r=t.onTokenValuesChange,o=t.setTokenActivated,a=t.handleTokenInputFocus,i=t.handleTokenInputBlur,u=t.focusTokenCreator;return{handleTokenEditStart:(0,e.useCallback)((function(e){return function(){o(e,!0),a()}}),[o,a]),handleTokenEditEnd:(0,e.useCallback)((function(e){return function(t){if(o(e,!1),i(),u(),void 0!==t){var a=function(e){if(Array.isArray(e))return q(e)}(l=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||function(e,t){if(e){if("string"==typeof e)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?q(e,t):void 0}}(l)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();a[e]=t,r(a)}var l}}),[n,r,o,i,u])}};function K(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const F=function(t){var n=t.tokenValues,r=t.onTokenValuesChange,o=t.focusTokenCreator,a=(0,e.useCallback)((function(e){var t,a=function(e){if(Array.isArray(e))return K(e)}(t=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return K(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?K(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();a.splice(e,1),r(a),o()}),[n,r,o]);return{handleTokenDelete:(0,e.useCallback)((function(e){return function(){a(e)}}),[a]),handleLastTokenDelete:(0,e.useCallback)((function(){a(-1)}),[a])}},L=function(e,t){return e};var U=["className","readOnly","autoFocus","placeholder","tokenValues","onTokenValuesChange","onBuildTokenValue","customizeTokenComponent","onGetTokenClassName","onGetTokenDisplayLabel","onRenderTokenDeleteButtonContent","onGetTokenEditableValue","onGetTokenErrorMessage","separators","specialKeyDown","onPreprocess","onInputValueChange","onTokenValueValidate"];function H(){return(H=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function $(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Z(e){return function(e){if(Array.isArray(e))return J(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return J(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?J(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Y=function(n){var r,o=n.className,a=n.readOnly,i=n.autoFocus,l=n.placeholder,s=n.tokenValues,c=n.onTokenValuesChange,f=n.onBuildTokenValue,p=n.customizeTokenComponent,d=n.onGetTokenClassName,y=n.onGetTokenDisplayLabel,h=n.onRenderTokenDeleteButtonContent,b=n.onGetTokenEditableValue,v=n.onGetTokenErrorMessage,m=n.separators,k=n.specialKeyDown,g=n.onPreprocess,T=n.onInputValueChange,S=n.onTokenValueValidate,E=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(n,U),C=R(),O=C.isTokenInputFocused,j=C.handleTokenInputFocus,A=C.handleTokenInputBlur,I=function(){var t=(0,e.useRef)(null),n=(0,e.useCallback)((function(){t&&t.current&&t.current.focus()}),[]);return{tokenCreatorRef:t,focusTokenCreator:n}}(),D=I.tokenCreatorRef,_=I.focusTokenCreator,P=G({tokenValues:s,onTokenValueValidate:S}),M=P.hasInvalidToken,x=P.internalTokenValues,B=P.tokenMetas,N=P.setTokenActivated,W=z({tokenValues:s,onTokenValuesChange:c,setTokenActivated:N,handleTokenInputFocus:j,handleTokenInputBlur:A,focusTokenCreator:_}),q=W.handleTokenEditStart,K=W.handleTokenEditEnd,L=F({tokenValues:s,onTokenValuesChange:c,focusTokenCreator:_}),J=L.handleTokenDelete,Y=L.handleLastTokenDelete,Q=(0,e.useCallback)((function(e){if(0!==e.length){var t=[].concat(Z(s),Z(e));c(t)}}),[s,c]),X=(0,e.useCallback)((function(e){if("function"!=typeof g)return e;var t=g(e);if(!0!==Array.isArray(t))throw new Error("onPreprocess should return an array of values");return t}),[g]),ee=p||V;return t().createElement("div",H({},E,{className:u()(o,"token-input-container",(r={},$(r,"token-input-container--focused",O),$(r,"token-input-container--errors",M),r)),onClick:_,role:"presentation","data-component-name":"TokenInput"}),t().createElement("div",{className:"token-input-token-list"},x.map((function(e,n){var r=B[n],o=r.key;return t().createElement(ee,{key:o,readOnly:a,tokenValue:e,tokenMeta:r,onGetClassName:d,onGetDisplayLabel:y,onRenderDeleteButtonContent:h,onGetEditableValue:b,onGetErrorMessage:v,onBuildTokenValue:f,onEditStart:q(n),onEditEnd:K(n),onDelete:J(n)})}))),!a&&t().createElement(w,{ref:D,placeholder:l,autoFocus:i,onFocus:j,onBlur:A,separators:m,specialKeyDown:k,onInputValueChange:T,onPreprocess:X,onBuildTokenValue:f,onNewTokenValuesAppend:Q,onLastTokenDelete:Y}))};Y.propTypes={style:a().object,className:a().string,readOnly:a().bool,autoFocus:a().bool,placeholder:a().string,separators:a().array,tokenValues:a().array.isRequired,onTokenValuesChange:a().func,onPreprocess:a().func,onBuildTokenValue:a().func,onInputValueChange:a().func,onTokenValueValidate:a().func,onGetTokenClassName:a().func,onGetTokenDisplayLabel:a().func,onRenderTokenDeleteButtonContent:a().func,onGetTokenEditableValue:a().func,onGetTokenErrorMessage:a().func,customizeTokenComponent:a().func,specialKeyDown:a().object};var Q=function(){};Y.defaultProps={className:"",readOnly:!1,autoFocus:!1,placeholder:"",separators:[",",";","\n","\r","\r\n"],specialKeyDown:{onBackspace:1,onTab:0,onEnter:1,onEscape:1},onBuildTokenValue:function(e){return e.trim()},onInputValueChange:Q,onTokenValueValidate:Q,onTokenValuesChange:Q,onGetTokenClassName:Q,onGetTokenDisplayLabel:L,onGetTokenEditableValue:L,onGetTokenErrorMessage:function(e,t){if("string"==typeof t.error)return t.error}};const X=Y})(),o})()}));
//# sourceMappingURL=index.js.map

@@ -7,2 +7,2 @@ /*!

/*! react-customize-token-input v1.3.1 | (c) 2021 Mark Lin. | MIT | https://github.com/seawind543/react-token-input */
/*! react-customize-token-input v1.4.1 | (c) 2021 Mark Lin. | MIT | https://github.com/seawind543/react-token-input */
{
"name": "react-customize-token-input",
"version": "1.3.1",
"version": "1.4.1",
"description": "A react token (tag) input component. Allow customize data structure and Look & Feel",

@@ -65,2 +65,3 @@ "main": "lib/index.js",

"css-loader": "^6.2.0",
"css-minimizer-webpack-plugin": "^3.0.2",
"eslint": "^7.32.0",

@@ -67,0 +68,0 @@ "eslint-config-airbnb-base": "^14.2.1",

@@ -37,5 +37,7 @@ # React TokenInput [![build status](https://travis-ci.org/seawind543/react-token-input.svg?branch=master)](https://travis-ci.org/seawind543/react-token-input) [![Coverage Status](https://coveralls.io/repos/github/seawind543/react-token-input/badge.svg?branch=master)](https://coveralls.io/github/seawind543/react-token-input?branch=master)

import 'react-customize-token-input/dist/react-customize-token-input.css';
// Could find the not minimize version for easily customize style here
// 'react-customize-token-input/dist/react-customize-token-input.original.css';
```
## Dev

@@ -81,2 +83,15 @@

/**
* An array of characters for split the user input string.
* For example,
* Split the user input string `abc;def` into `['abc', 'def']`
* by separators `[';']`
*
* Note:
* It take the `String.prototype.split()` and `RegExp` to split the user input string.
* Make sure your customized separators could be used with `RegExp`.
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
*/
separators: PropTypes.array,
// [Required] An array of tokenValue of TokenInput

@@ -97,15 +112,2 @@ tokenValues: PropTypes.array.isRequired,

/**
* An array of characters for split the user input string.
* For example,
* Split the user input string `abc;def` into `['abc', 'def']`
* by separators `[';']`
*
* Note:
* It take the `String.prototype.split()` and `RegExp` to split the user input string.
* Make sure your customized separators could be used with `RegExp`.
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
*/
separators: PropTypes.array,
/**
* A callback function for preprocessing the user input string

@@ -313,4 +315,50 @@ * (after it is split into `array of value`).

customizeTokenComponent: PropTypes.func,
```
### Beta props
```javascript
/**
* [Beta; Might be change in the future version]
* Current only apply to Token Create
*
* The config settings to control the specials keyDown event handler behavior.
* Default setting as below.
* specialKeyDown: {
* onBackspace: 1,
* onTab: 0,
* onEnter: 1,
* onEscape: 1,
* },
*
* `0` means turn off (Took native browser behavior. TokenInput should NOT handle it).
* `1` means apply TokenInput predefined event handler.
*
* Reference section below for Predefined event handlers.
* `Predefined KeyDown Event Handlers`
*/
specialKeyDown: PropTypes.object,
```
## Predefined KeyDown Event Handlers
TokenInput have following Predefined event handlers on each Special KeyDown.
### For Token Create
KeyDown | Description | Note
---------- | :------------ | :---
Backspace | In case the value is an `empty string`, the token in the list tail will be deleted. |
Escape | Clear the input value. | A.K.A. Reset.
Enter | Create the token with the inputValue and continually focused on the inputBox for next inputting. |
Tab | Same as onEnter. | <ul> <li>Default not apply</li> <li>Under Beta</li> </ul>
### For Inline editing
KeyDown | Description | Note
---------- | :---------- | :---
Escape | End editing without change the value of the token. | A.K.A. Reset
Enter | End editing and apply the new value. In case the new value is an `empty string`, will perform the `onEscape`. |
## Default value of optional Props

@@ -334,2 +382,8 @@

specialKeyDown: {
onBackspace: 1,
onEnter: 1,
onEscape: 1,
},
onBuildTokenValue: buildDefaultTokenValue,

@@ -339,6 +393,8 @@

onTokenValueValidate: () => undefined,
onTokenValueValidate: () => {}, // Dummy function
onTokenValuesChange: () => {}, // Dummy function
// Token
onGetTokenClassName: () => '',
onGetTokenClassName: () => {}, // Dummy function
onGetTokenDisplayLabel: getDefaultTokenEditableValue,

@@ -345,0 +401,0 @@ onGetTokenEditableValue: getDefaultTokenEditableValue,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc