@purpurds/autocomplete 0.0.1

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.
@@ -0,0 +1,45 @@
1
+ Name: classnames
2
+ Version: 2.5.1
3
+ License: MIT
4
+ Private: false
5
+ Description: A simple utility for conditionally joining classNames together
6
+ Repository: git+https://github.com/JedWatson/classnames.git
7
+ Author: Jed Watson
8
+ License Copyright:
9
+ ===
10
+
11
+ The MIT License (MIT)
12
+
13
+ Copyright (c) 2018 Jed Watson
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+
33
+ ---
34
+
35
+ Name: @purpurds/icon
36
+ Version: 4.5.1
37
+ License: AGPL-3.0-only
38
+ Private: false
39
+
40
+ ---
41
+
42
+ Name: @purpurds/paragraph
43
+ Version: 4.5.1
44
+ License: AGPL-3.0-only
45
+ Private: false
@@ -0,0 +1,14 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react/jsx-runtime"),d=require("react");function _r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W={exports:{}};/*!
2
+ Copyright (c) 2018 Jed Watson.
3
+ Licensed under the MIT License (MIT), see
4
+ http://jedwatson.github.io/classnames
5
+ */(function(e){(function(){var o={}.hasOwnProperty;function n(){for(var r="",t=0;t<arguments.length;t++){var s=arguments[t];s&&(r=i(r,l.call(this,s)))}return r}function l(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var t="";for(var s in r)o.call(r,s)&&r[s]&&(t=i(t,this&&this[s]||s));return t}function i(r,t){return t?r?r+" "+t:r+t:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(W);var br=W.exports;const X=_r(br),hr={"purpur-autocomplete":"_purpur-autocomplete_19u9x_1","purpur-autocomplete__listbox":"_purpur-autocomplete__listbox_19u9x_4"};function vr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var rr={exports:{}};/*!
6
+ Copyright (c) 2018 Jed Watson.
7
+ Licensed under the MIT License (MIT), see
8
+ http://jedwatson.github.io/classnames
9
+ */(function(e){(function(){var o={}.hasOwnProperty;function n(){for(var r="",t=0;t<arguments.length;t++){var s=arguments[t];s&&(r=i(r,l.call(this,s)))}return r}function l(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var t="";for(var s in r)o.call(r,s)&&r[s]&&(t=i(t,this&&this[s]||s));return t}function i(r,t){return t?r?r+" "+t:r+t:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(rr);var xr=rr.exports;const gr=vr(xr),yr={"purpur-icon":"_purpur-icon_8u1lq_1","purpur-icon--xxs":"_purpur-icon--xxs_8u1lq_4","purpur-icon--xs":"_purpur-icon--xs_8u1lq_8","purpur-icon--sm":"_purpur-icon--sm_8u1lq_12","purpur-icon--md":"_purpur-icon--md_8u1lq_16","purpur-icon--lg":"_purpur-icon--lg_8u1lq_20","purpur-icon--xl":"_purpur-icon--xl_8u1lq_24"},wr={name:"checkmark",svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M21.06 3.795a.9.9 0 0 1 .145 1.264l-11.5 14.5a.9.9 0 0 1-1.341.077l-6-6a.9.9 0 0 1 1.272-1.272l5.286 5.286L19.795 3.94a.9.9 0 0 1 1.264-.145Z" clip-rule="evenodd"/></svg>',keywords:["checkmark"],category:"utility"},Ar=gr.bind(yr),F="purpur-icon",Rr="md",$r=e=>e.filter(o=>Object.keys(o).length>=1).map(o=>`${o.name}="${o.value}"`).join(" "),Ir=({content:e="",title:o}={})=>{const n=[{name:"xmlns",value:"http://www.w3.org/2000/svg"},{name:"fill",value:"currentColor"},{name:"viewBox",value:"0 0 24 24"},o?{name:"role",value:"img"}:{name:"aria-hidden",value:"true"}],l=o?`<title>${o}</title>`:"";return`<svg ${$r(n)}>${l}${e}</svg>`},Lr=e=>e.replace(/<(\/?)svg([^>]*)>/g,"").trim(),Er=({["data-testid"]:e,svg:o,allyTitle:n,className:l="",size:i=Rr,...r})=>{const t=Ir({content:Lr(o.svg),title:n}),s=Ar(l,F,`${F}--${i}`);return _.jsx("span",{"aria-label":n,className:s,"data-testid":e,dangerouslySetInnerHTML:{__html:t},...r})};function Sr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var er={exports:{}};/*!
10
+ Copyright (c) 2018 Jed Watson.
11
+ Licensed under the MIT License (MIT), see
12
+ http://jedwatson.github.io/classnames
13
+ */(function(e){(function(){var o={}.hasOwnProperty;function n(){for(var r="",t=0;t<arguments.length;t++){var s=arguments[t];s&&(r=i(r,l(s)))}return r}function l(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var t="";for(var s in r)o.call(r,s)&&r[s]&&(t=i(t,s));return t}function i(r,t){return t?r?r+" "+t:r+t:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(er);var Nr=er.exports;const Pr=Sr(Nr),I={"purpur-paragraph":"_purpur-paragraph_1rh57_1","purpur-paragraph--disabled":"_purpur-paragraph--disabled_1rh57_7","purpur-paragraph--hyphens":"_purpur-paragraph--hyphens_1rh57_10","purpur-paragraph--negative":"_purpur-paragraph--negative_1rh57_13","purpur-paragraph--paragraph-100":"_purpur-paragraph--paragraph-100_1rh57_16","purpur-paragraph--paragraph-100-medium":"_purpur-paragraph--paragraph-100-medium_1rh57_22","purpur-paragraph--paragraph-100-bold":"_purpur-paragraph--paragraph-100-bold_1rh57_29","purpur-paragraph--paragraph-200":"_purpur-paragraph--paragraph-200_1rh57_36","purpur-paragraph--preamble-100":"_purpur-paragraph--preamble-100_1rh57_42","purpur-paragraph--preamble-200":"_purpur-paragraph--preamble-200_1rh57_48","purpur-paragraph--additional-100":"_purpur-paragraph--additional-100_1rh57_54","purpur-paragraph--additional-100-medium":"_purpur-paragraph--additional-100-medium_1rh57_60","purpur-paragraph--overline-100":"_purpur-paragraph--overline-100_1rh57_67","purpur-paragraph--overline-200":"_purpur-paragraph--overline-200_1rh57_75"},jr={PARAGRAPH100:"paragraph-100",PARAGRAPH100MEDIUM:"paragraph-100-medium",PARAGRAPH100BOLD:"paragraph-100-bold",PARAGRAPH200:"paragraph-200",PREAMBLE100:"preamble-100",PREAMBLE200:"preamble-200",ADDITIONAL100:"additional-100",ADDITIONAL100MEDIUM:"additional-100-medium",OVERLINE100:"overline-100",OVERLINE200:"overline-200"},L="purpur-paragraph",Cr=({["data-testid"]:e,children:o,className:n="",disabled:l,enableHyphenation:i=!1,negative:r=!1,variant:t=jr.PARAGRAPH100,...s})=>{const b=Pr([n,I[L],I[`${L}--${t}`],{[I[`${L}--hyphens`]]:i,[I[`${L}--disabled`]]:l,[I[`${L}--negative`]]:r}]);return _.jsx("p",{...s,className:b,"data-testid":e,children:o})},Br={"purpur-listbox":"_purpur-listbox_qhoi7_1","purpur-listbox-item":"_purpur-listbox-item_qhoi7_15","purpur-listbox-item--hovered":"_purpur-listbox-item--hovered_qhoi7_29","purpur-listbox-item--highlighted":"_purpur-listbox-item--highlighted_qhoi7_37","purpur-listbox-item--noninteractive":"_purpur-listbox-item--noninteractive_qhoi7_41","purpur-listbox-item--disabled":"_purpur-listbox-item--disabled_qhoi7_44","purpur-listbox-item__icon":"_purpur-listbox-item__icon_qhoi7_51"},Dr=e=>d.useRef(e),kr=(e,o)=>{const n=d.useCallback(l=>{e&&!e.contains(l.target)&&o()},[o,e]);d.useEffect(()=>(document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}),[n])},tr=({highlightFirstOption:e,defaultInputValue:o,inputValue:n,filterOption:l,id:i,listboxLabel:r,listboxMaxHeight:t,onInputChange:s,openOnFocus:b,noOptionsText:A,onSelect:R,options:v,selectedOption:c,["data-testid"]:E})=>{const[j,f]=d.useState((typeof n=="string"?n:o)||(c==null?void 0:c.label)),S=typeof n=="string"?n:j,[u,x]=d.useState(e?v[0]:void 0),C=d.useRef(null),T=Dr(null),O=d.useRef(null),N=d.useRef({}),[V,K]=d.useState(!1);function B(a){return E?`${E}-${a}`:void 0}const P=()=>{K(!1),x(void 0)};kr(T.current,P);const $=({eventType:a})=>{K(!0),c&&requestAnimationFrame(()=>{x({...c,isSetByClickEvent:a==="CLICK"}),D(N.current[c.id])})},sr=a=>{if(l)return v.filter(m=>l(a,m));if(!a)return v;const p=a.toUpperCase().split(" ")||[];return v.filter(m=>p.every(h=>(m.value||m.label).toUpperCase().includes(h)))},H=a=>c&&(c==null?void 0:c.label)===a?v:sr(a),g=H(S),U=a=>{s==null||s(a),f(a)},D=a=>{var p;if(a){const m=a.getBoundingClientRect(),h=((p=O.current)==null?void 0:p.getBoundingClientRect())||{top:0,bottom:0};(m.top<h.top||m.bottom>h.bottom)&&a.scrollIntoView({block:"nearest"})}},G=a=>{var p;a&&((p=C.current)==null||p.focus(),U(a.label),R==null||R(a)),P()},or=a=>{const p=e&&!u?0:g.findIndex(h=>h&&(u==null?void 0:u.id)===h.id),m=g.length;return a==="ArrowDown"?g[(p??-1)+1]||g[0]:g[(p??m)-1]||g[m-1]},y=V&&(!!g.length||!!A),ur=a=>{!y&&$({eventType:"KEYBOARD"});const p=or(a);x(p),p&&D(N.current[p.id])},ir=a=>{switch(a.key){case"ArrowUp":case"ArrowDown":a.preventDefault(),ur(a.key);break;case"Enter":{const p=u||(e?v[0]:void 0);y&&G(p),!y&&$({eventType:"KEYBOARD"});break}case"Escape":case"Tab":P();break}},pr=a=>{const p=H(a.target.value);U(a.target.value),x(void 0),!y&&$({eventType:"KEYBOARD"}),e&&p[0]&&D(N.current[p[0].id])},lr=()=>{y?P():$({eventType:"CLICK"})},cr=()=>{var a;!V&&b&&$({eventType:"KEYBOARD"}),(a=C.current)==null||a.select()},dr={maxHeight:typeof t=="number"?`${t}px`:t},Y={"aria-label":r,"aria-expanded":y,"data-testid":B("listbox"),id:`${i}-listbox`,ref:O,onMouseLeave:()=>x(void 0),style:t?dr:void 0},z=a=>`${i}-listbox-item-${a.id}`,mr=(a,p)=>{const m=()=>a.id!==(u==null?void 0:u.id)&&x({...a,isSetByClickEvent:!0}),h=(a.id===(u==null?void 0:u.id)||!!e&&!u&&p===0)&&!(u!=null&&u.isSetByClickEvent);return{"data-testid":B(`listbox-item-${a.id}`),id:z(a),key:a.id,onMouseMove:m,onMouseUp:()=>G(a),ref:k=>k&&(N.current[a.id]=k),tabIndex:-1,selected:a.id===(c==null?void 0:c.id),disabled:a.disabled,highlighted:h,hovered:a.id===(u==null?void 0:u.id)&&!!(u!=null&&u.isSetByClickEvent)}},fr={"aria-activedescendant":u?z(u):void 0,"aria-autocomplete":"list","aria-controls":Y.id,"aria-expanded":y,"data-testid":B("input"),autoComplete:"off",id:`${i}-input`,onChange:pr,onMouseDown:lr,onFocus:cr,onKeyDown:ir,ref:C,role:"combobox",value:S};return{id:i,inputProps:fr,internalRef:T,optionsToShow:g,showListbox:y,noOptionsText:A,getListBoxItemProps:mr,listboxProps:Y}},M=X.bind(Br),w="purpur-listbox",ar=d.forwardRef(({children:e,...o},n)=>_.jsx("ul",{...o,ref:n,className:M(w,o.className),role:"listbox",children:d.Children.toArray(e).filter(Mr)}));ar.displayName="ListBox";const q=d.forwardRef((e,o)=>{const{disabled:n,highlighted:l,hovered:i,selected:r,children:t,noninteractive:s,...b}=e,A=M(`${w}-item`,b.className,{[`${w}-item--highlighted`]:l,[`${w}-item--selected`]:r,[`${w}-item--hovered`]:i,[`${w}-item--disabled`]:n,[`${w}-item--noninteractive`]:s});return _.jsxs("li",{...b,ref:o,className:A,"aria-selected":!!r,role:"option","aria-disabled":!!n,children:[typeof t=="string"?_.jsx(Cr,{children:t}):t,r&&_.jsx(Er,{svg:wr,size:"xs",className:M(`${w}-item__icon`)})]})});q.displayName="ListBoxItem";function Mr(e){return d.isValidElement(e)&&(e==null?void 0:e.type)===q}const qr=ar,Z=q,J=X.bind(hr),Q="purpur-autocomplete",Tr=({className:e,renderInput:o,renderOption:n,...l},i)=>{const{id:r,inputProps:t,internalRef:s,optionsToShow:b,showListbox:A,noOptionsText:R,getListBoxItemProps:v,listboxProps:c}=tr(l),E=(f,S)=>{const{key:u,...x}=v(f,S);return _.jsx(Z,{...x,children:n?n==null?void 0:n(f):f.label},u)},j=f=>{s.current=f,typeof i=="function"?i(f):i&&(i.current=f)};return _.jsxs("div",{id:r,ref:j,className:J([e,Q]),children:[o(t),A&&_.jsx(qr,{...c,className:J(`${Q}__listbox`),children:b.length?b.filter(f=>!!f).map(E):_.jsx(Z,{noninteractive:!0,children:R})})]})},nr=d.forwardRef(Tr);nr.displayName="Autocomplete";exports.Autocomplete=nr;exports.useAutocomplete=tr;
14
+ //# sourceMappingURL=autocomplete.cjs.js.map