@rmwc/select
Advanced tools
Comparing version 14.0.10 to 14.0.11
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),g=require("@rmwc/base"),ge=require("@rmwc/floating-label"),Ce=require("@rmwc/line-ripple"),be=require("@rmwc/notched-outline"),z=require("@rmwc/menu"),ue=require("@rmwc/list"),ve=require("@rmwc/ripple"),ee=require("@material/select"),de=require("@rmwc/icon"),Se=e=>{const[c,x]=a.useState(),[u,f]=a.useState(!1),[o,h]=a.useState(0),[S,O]=a.useState(!1),[C,m]=a.useState(!1),[b,p]=a.useState(""),i=a.useRef(-1),_=a.useRef(),w=n=>{_.current=n},v=a.useRef(),G=n=>{v.current=n},j=a.useRef(null),he=n=>{j.current=n},B=a.useRef(),U=n=>{B.current=n},D=a.useRef(),te=n=>{D.current=n},q=a.useRef(!1),{foundation:r,...Q}=g.useFoundation({props:e,elements:{rootEl:!0,anchorEl:!0},foundation:({rootEl:n,anchorEl:R,getProps:L,emit:k})=>{const y=()=>!L().enhanced,K=()=>{const l=()=>{var s,d;return(y()?Array.apply(null,(s=D.current)==null?void 0:s.options):(d=v.current)==null?void 0:d.items())||[]},$=s=>s.getAttribute("data-value")||s.getAttribute("value")||"";return{setSelectedText:s=>p(s),openMenu:()=>{m(!0)},closeMenu:()=>{m(!1)},getAnchorElement:()=>j.current,setMenuAnchorElement:s=>he(s),setMenuAnchorCorner:s=>{var d;return(d=v.current)==null?void 0:d.setAnchorCorner(s)},setMenuWrapFocus:s=>{},focusMenuItemAtIndex:s=>{var d;return(d=v.current)==null?void 0:d.focusItemAtIndex(s)},getMenuItemCount:()=>l().length,getMenuItemValues:()=>l().map($)||[],getMenuItemTextAtIndex:s=>l()[s].textContent,isSelectAnchorFocused:()=>!!(R.ref&&R.ref===document.activeElement),getSelectAnchorAttr:s=>R.getProp(s),setSelectAnchorAttr:(s,d)=>{if(s==="tabindex"){if(y())return;s="tabIndex"}return R.setProp(s,d)},removeSelectAnchorAttr:s=>{var d;(d=j.current)==null||d.removeAttribute(s)},addMenuClass:s=>{var d,N,E;return(E=(N=(d=v.current)==null?void 0:d.getSurfaceElement())==null?void 0:N.querySelector(".mdc-deprecated-list-item--activated"))==null?void 0:E.classList.add(s)},removeMenuClass:s=>{var d,N,E;return(E=(N=(d=v.current)==null?void 0:d.getSurfaceElement())==null?void 0:N.querySelector(".mdc-deprecated-list-item--activated"))==null?void 0:E.classList.remove(s)},getSelectedIndex:()=>y()&&D.current!==void 0?D.current.selectedOptions[0].index:i.current,setSelectedIndex:s=>i}},I=()=>({addClass:l=>{n.addClass(l)},removeClass:l=>{n.removeClass(l)},hasClass:l=>n.hasClass(l),isRtl:()=>n.ref&&window.getComputedStyle(n.ref).getPropertyValue("direction")==="rtl",setRippleCenter:l=>{h(l)},activateBottomLine:()=>f(!0),deactivateBottomLine:()=>f(!1),notifyChange:l=>{q.current||k("onChange",{index:i.current,value:l},!0)}}),Z=()=>({hasOutline:()=>!!L().outlined,notchOutline:l=>{x(l)},closeOutline:()=>{x(void 0)}}),fe=()=>({hasLabel:()=>!!L().label,floatLabel:l=>{O(l)},getLabelWidth:()=>{var l;return((l=_.current)==null?void 0:l.getWidth())||0},setLabelRequired:l=>{var $;return($=_.current)==null?void 0:$.setRequired(l)}}),xe=()=>({leadingIcon:B.current&&B.current.getFoundation()||void 0}),M=new ee.MDCSelectFoundation({...K(),...I(),...Z(),...fe()},xe()),T=M.adapter;M.layout=()=>{(()=>{const $=M.getValue();if(T.hasLabel()){const s=!!L().placeholder||$.length>0||i.current>-1,d=T.hasClass(ee.cssClasses.FOCUSED),N=s||d,E=T.hasClass(ee.cssClasses.REQUIRED);M.notchOutline(N),T.floatLabel(N),T.setLabelRequired(E)}})()},Object.defineProperty(M,"menuItemValues",{get:()=>T.getMenuItemValues()});const pe=M.init.bind(M);return M.init=()=>{q.current=!0,pe();const l=String(L().placeholder||"");!M.getValue()&&l&&T.setSelectedText(l),q.current=!1},M}}),{rootEl:A}=Q,{onFocus:W}=e,ne=a.useCallback(n=>{W==null||W(n),r.handleFocus()},[W,r]),{onBlur:H}=e,ce=a.useCallback(n=>{H==null||H(n),r.handleBlur()},[H,r]),{onChange:P}=e,se=a.useCallback(n=>{P==null||P(n),r.handleChange()},[P,r]),re=a.useCallback(n=>{var k,y;if((k=A.ref)!=null&&k.querySelector(".mdc-select--disabled"))return;if((y=A.ref)!=null&&y.querySelector(".mdc-menu-surface--open")){r.handleMenuClosed();return}const L=(K=>{const I=K.target.getBoundingClientRect();return K.clientX-I.left})(n);A.ref&&A.ref.focus(),r.handleClick(L)},[r,A.ref]),{onKeyDown:V}=e,J=a.useCallback(n=>{V==null||V(n),r.handleKeydown(n)},[r,V]),le=a.useCallback(n=>{i.current=n,r.handleMenuItemAction(n)},[r]),ae=a.useCallback(()=>{r.handleMenuOpened()},[r]),oe=a.useCallback(()=>{m(!1),r.handleMenuClosed()},[r]),X=r.getValue(),F=e.value??(i.current===-1?e.defaultValue:void 0),Y=Array.isArray(e.options)?e.options.length:Object.values(e.options||{}).length;return a.useEffect(()=>{if(q.current=!0,F!==void 0&&F!==X){const n=r.menuItemValues.indexOf(F);if(i.current=n,r.setValue(F||""),r.menuItemValues.includes(F)){const R=r.adapter.getMenuItemTextAtIndex(n);p(R)}}g.raf(()=>{q.current=!1})},[F,X,Y,r]),a.useEffect(()=>{r.setDisabled(!!e.disabled)},[r,e.disabled]),a.useEffect(()=>{var n;A.ref&&((n=v.current)==null||n.setAnchorElement(A.ref))},[A.ref]),{notchWidth:c,menuOpen:C,lineRippleActive:u,lineRippleCenter:o,floatLabel:S,selectedIndex:i.current,selectedTextContent:b,setFloatingLabel:w,setMenu:G,setLeadingIcon:U,setNativeControl:te,handleFocus:ne,handleBlur:ce,handleClick:re,handleChange:se,handleKeydown:J,handleMenuClosed:oe,handleMenuOpened:ae,handleMenuSelected:le,...Q}},je=e=>{const{foundation:c,...x}=g.useFoundation({props:e,elements:{rootEl:!0},api:({foundation:u})=>({getFoundation:()=>u}),foundation:({rootEl:u,emit:f})=>new ee.MDCSelectIconFoundation({getAttr:o=>u.getProp(o),setAttr:(o,h)=>u.setProp(o,h),removeAttr:o=>u.removeProp(o),setContent:o=>{u.ref&&(u.ref.textContent=o)},registerInteractionHandler:(o,h)=>u.addEventListener(o,h),deregisterInteractionHandler:(o,h)=>u.removeEventListener(o,h),notifyIconAction:()=>f("onClick",{},!0)})});return{...x}},Ae=function(c){const{apiRef:x,...u}=c,{rootEl:f}=je(c),o=g.useClassNames(c,["mdc-select__icon"]);return t.jsx(de.Icon,{...f.props({...u,className:o})})},me=e=>Array.isArray(e)&&e[0]&&typeof e[0]=="object"?e.map(c=>{if(typeof c!="object")throw new Error(`Encountered non object for Select ${c}`);return{...c,options:me(c.options)}}):Array.isArray(e)?e.map(c=>({value:c,label:c})):typeof e=="object"?Object.keys(e).map(c=>({value:c,label:e[c]})):e,Ie=()=>t.jsxs("span",{className:"mdc-select__dropdown-icon",children:[t.jsx(de.Icon,{className:"mdc-select__dropdown-icon-inactive",icon:"arrow_drop_down"}),t.jsx(de.Icon,{className:"mdc-select__dropdown-icon-active",icon:"arrow_drop_up"})]});function Me(e){const{selectOptions:c,placeholder:x="",children:u,elementRef:f,open:o,...h}=e,S=({label:C,option:m,index:b})=>t.jsx("option",{...m,value:m.value,children:C},b),O=!e.value&&!e.defaultValue;return t.jsxs("select",{tabIndex:0,...h,ref:f,className:`rmwc-select__native-control ${h.className||""}`,children:[(e.placeholder!==void 0||O)&&t.jsx("option",{value:"",disabled:O,children:x}),!!c&&c.map(({label:C,options:m,...b},p)=>m?t.jsx("optgroup",{label:C,children:m.map(({label:i,..._},w)=>S({label:i,option:_,index:w}))},p):S({label:C,option:b,index:p})),u]})}const Re=ve.withRipple({surface:!1})(function(e){return t.jsx(g.Tag,{...e})}),Le=a.forwardRef((e,c)=>{const{selectOptions:x,menuApiRef:u,value:f,placeholder:o,children:h,selectedIndex:S,...O}=e;let C=0;const m=g.useClassNames(e,["mdc-select__menu"]),b=({label:p,option:i})=>(C+=1,t.jsx(z.MenuItem,{activated:f!==void 0?i.value===f:C-1===S,...i,"data-value":i.value,children:t.jsx("span",{className:"mdc-deprecated-list-item__text",children:p})},`${p}-${i.value}`));return t.jsxs(z.Menu,{...O,ref:c,apiRef:u,className:m,focusOnOpen:!0,children:[!!e.placeholder&&t.jsx(z.MenuItem,{selected:C-1===S,"data-value":"",theme:"textDisabledOnBackground",children:t.jsx("span",{className:"mdc-deprecated-list-item__text",children:o})}),x.map(({label:p,options:i,..._},w)=>i?t.jsxs(ue.ListGroup,{children:[p&&t.jsx(ue.ListGroupSubheader,{theme:"textDisabledOnBackground",children:p}),t.jsx(z.MenuItems,{children:i.map(({label:v,...G})=>b({label:v,option:G}))}),w<x.length-1&&t.jsx(ue.ListDivider,{})]},w):b({label:p,option:_})),h]})}),ye=({enhanced:e,children:c})=>e?t.jsx(z.MenuSurfaceAnchor,{children:c}):t.jsx(t.Fragment,{children:c}),Oe=g.createComponent(function(c,x){const{placeholder:u,children:f,value:o,outlined:h,label:S="",options:O=[],rootProps:C={},enhanced:m,icon:b,onChange:p,onFocus:i,onBlur:_,onKeyDown:w,invalid:v,inputRef:G,helpText:j,foundationRef:he,...B}=c,U=me(O),{rootEl:D,anchorEl:te,notchWidth:q,menuOpen:r,selectedTextContent:Q,lineRippleActive:A,lineRippleCenter:W,floatLabel:ne,setFloatingLabel:H,setNativeControl:ce,setLeadingIcon:P,selectedIndex:se,setMenu:re,handleFocus:V,handleBlur:J,handleClick:le,handleChange:ae,handleKeydown:oe,handleMenuClosed:X,handleMenuOpened:F,handleMenuSelected:Y}=Se(c),n=g.useId("select",c),R=g.useClassNames(c,["mdc-select","rmwc-select__default-width",{"mdc-select--outlined":!!h,"mdc-select--filled":!h,"mdc-select--required":!!c.required,"mdc-select--invalid":!!v,"mdc-select--with-leading-icon":!!b,"mdc-select--no-label":!S}]),L=typeof m=="object"?m:{},k=o!==void 0?void 0:c.defaultValue||"",y=t.jsx(ge.FloatingLabel,{float:ne,apiRef:H,htmlFor:n,children:S}),K=()=>{if(!!!j)return null;const Z=typeof j=="object"&&!a.isValidElement(j);return j&&Z?t.jsx(ie,{...j}):t.jsx(ie,{children:j})};return t.jsxs(ye,{enhanced:m,children:[t.jsxs(g.Tag,{...C,element:D,ref:x,className:R,children:[t.jsxs(Re,{className:"mdc-select__anchor",role:"button","aria-haspopup":"listbox",element:te,onFocus:V,onBlur:J,onClick:le,onKeyDown:oe,onChange:ae,tabIndex:m?void 0:-1,children:[!!b&&t.jsx(Ae,{apiRef:P,icon:b}),h?t.jsx(be.NotchedOutline,{notch:q,children:y}):t.jsxs(t.Fragment,{children:[t.jsx(Ce.LineRipple,{active:A,center:W}),y]}),t.jsx("span",{className:"mdc-select__selected-text-container",children:t.jsx("span",{className:"mdc-select__selected-text",children:Q})}),t.jsx(Ie,{}),!m&&t.jsx(Me,{...B,value:o,children:f,defaultValue:k,placeholder:u,selectOptions:U,elementRef:ce,onFocus:V,onBlur:I=>{J(I),X()},onChange:I=>{Y(I.currentTarget.selectedIndex)}})]}),m&&t.jsx(Le,{...B,...L,ref:x,anchorCorner:"bottomStart",defaultValue:k,placeholder:u,open:r,onClose:X,onOpen:F,onSelect:I=>{Y(I.detail.index)},selectOptions:U,value:o,selectedIndex:se,menuApiRef:re,children:f})]}),K()]})}),ie=g.createComponent(function(c,x){const{persistent:u,validationMsg:f,...o}=c,h=g.useClassNames(c,["mdc-select-helper-text",{"mdc-select-helper-text--persistent":u,"mdc-select-helper-text--validation-msg":f}]);return t.jsx(g.Tag,{tag:"p",...o,className:h,ref:x})});exports.Select=Oe;exports.SelectHelperText=ie; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("react"),b=require("@rmwc/base"),ge=require("@rmwc/floating-label"),Ce=require("@rmwc/line-ripple"),be=require("@rmwc/notched-outline"),z=require("@rmwc/menu"),ue=require("@rmwc/list"),ve=require("@rmwc/ripple"),ee=require("@material/select"),de=require("@rmwc/icon"),Se=e=>{const[c,x]=a.useState(),[u,m]=a.useState(!1),[o,f]=a.useState(0),[v,O]=a.useState(!1),[S,h]=a.useState(!1),[p,g]=a.useState(""),i=a.useRef(-1),N=a.useRef(),w=t=>{N.current=t},C=a.useRef(),G=t=>{C.current=t},j=a.useRef(null),he=t=>{j.current=t},B=a.useRef(),U=t=>{B.current=t},D=a.useRef(),te=t=>{D.current=t},q=a.useRef(!1),{foundation:r,...Q}=b.useFoundation({props:e,elements:{rootEl:!0,anchorEl:!0},foundation:({rootEl:t,anchorEl:R,getProps:L,emit:k})=>{const y=()=>!L().enhanced,$=()=>{const l=()=>{var s,d;return(y()?Array.apply(null,(s=D.current)==null?void 0:s.options):(d=C.current)==null?void 0:d.items())||[]},K=s=>s.getAttribute("data-value")||s.getAttribute("value")||"";return{setSelectedText:s=>g(s),openMenu:()=>{h(!0)},closeMenu:()=>{h(!1)},getAnchorElement:()=>j.current,setMenuAnchorElement:s=>he(s),setMenuAnchorCorner:s=>{var d;return(d=C.current)==null?void 0:d.setAnchorCorner(s)},setMenuWrapFocus:s=>{},focusMenuItemAtIndex:s=>{var d;return(d=C.current)==null?void 0:d.focusItemAtIndex(s)},getMenuItemCount:()=>l().length,getMenuItemValues:()=>l().map(K)||[],getMenuItemTextAtIndex:s=>l()[s].textContent,isSelectAnchorFocused:()=>!!(R.ref&&R.ref===document.activeElement),getSelectAnchorAttr:s=>R.getProp(s),setSelectAnchorAttr:(s,d)=>{if(s==="tabindex"){if(y())return;s="tabIndex"}return R.setProp(s,d)},removeSelectAnchorAttr:s=>{var d;(d=j.current)==null||d.removeAttribute(s)},addMenuClass:s=>{var d,F,E;return(E=(F=(d=C.current)==null?void 0:d.getSurfaceElement())==null?void 0:F.querySelector(".mdc-deprecated-list-item--activated"))==null?void 0:E.classList.add(s)},removeMenuClass:s=>{var d,F,E;return(E=(F=(d=C.current)==null?void 0:d.getSurfaceElement())==null?void 0:F.querySelector(".mdc-deprecated-list-item--activated"))==null?void 0:E.classList.remove(s)},getSelectedIndex:()=>y()&&D.current!==void 0?D.current.selectedOptions[0].index:i.current,setSelectedIndex:s=>i}},I=()=>({addClass:l=>{t.addClass(l)},removeClass:l=>{t.removeClass(l)},hasClass:l=>t.hasClass(l),isRtl:()=>t.ref&&window.getComputedStyle(t.ref).getPropertyValue("direction")==="rtl",setRippleCenter:l=>{f(l)},activateBottomLine:()=>m(!0),deactivateBottomLine:()=>m(!1),notifyChange:l=>{q.current||k("onChange",{index:i.current,value:l},!0)}}),Z=()=>({hasOutline:()=>!!L().outlined,notchOutline:l=>{x(l)},closeOutline:()=>{x(void 0)}}),fe=()=>({hasLabel:()=>!!L().label,floatLabel:l=>{O(l)},getLabelWidth:()=>{var l;return((l=N.current)==null?void 0:l.getWidth())||0},setLabelRequired:l=>{var K;return(K=N.current)==null?void 0:K.setRequired(l)}}),xe=()=>({leadingIcon:B.current&&B.current.getFoundation()||void 0}),M=new ee.MDCSelectFoundation({...$(),...I(),...Z(),...fe()},xe()),T=M.adapter;M.layout=()=>{(()=>{const K=M.getValue();if(T.hasLabel()){const s=!!L().placeholder||K.length>0||i.current>-1,d=T.hasClass(ee.cssClasses.FOCUSED),F=s||d,E=T.hasClass(ee.cssClasses.REQUIRED);M.notchOutline(F),T.floatLabel(F),T.setLabelRequired(E)}})()},Object.defineProperty(M,"menuItemValues",{get:()=>T.getMenuItemValues()});const pe=M.init.bind(M);return M.init=()=>{q.current=!0,pe();const l=String(L().placeholder||"");!M.getValue()&&l&&T.setSelectedText(l),q.current=!1},M}}),{rootEl:A}=Q,{onFocus:W}=e,ne=a.useCallback(t=>{W==null||W(t),r.handleFocus()},[W,r]),{onBlur:H}=e,ce=a.useCallback(t=>{H==null||H(t),r.handleBlur()},[H,r]),{onChange:P}=e,se=a.useCallback(t=>{P==null||P(t),r.handleChange()},[P,r]),re=a.useCallback(t=>{var k,y;if((k=A.ref)!=null&&k.querySelector(".mdc-select--disabled"))return;if((y=A.ref)!=null&&y.querySelector(".mdc-menu-surface--open")){r.handleMenuClosed();return}const L=($=>{const I=$.target.getBoundingClientRect();return $.clientX-I.left})(t);A.ref&&A.ref.focus(),r.handleClick(L)},[r,A.ref]),{onKeyDown:V}=e,J=a.useCallback(t=>{V==null||V(t),r.handleKeydown(t)},[r,V]),le=a.useCallback(t=>{i.current=t,r.handleMenuItemAction(t)},[r]),ae=a.useCallback(()=>{r.handleMenuOpened()},[r]),oe=a.useCallback(()=>{h(!1),r.handleMenuClosed()},[r]),X=r.getValue(),_=e.value??(i.current===-1?e.defaultValue:void 0),Y=Array.isArray(e.options)?e.options.length:Object.values(e.options||{}).length;return a.useEffect(()=>{if(q.current=!0,_!==void 0&&_!==X){const t=r.menuItemValues.indexOf(_);if(i.current=t,r.setValue(_||""),r.menuItemValues.includes(_)){const R=r.adapter.getMenuItemTextAtIndex(t);g(R)}}b.raf(()=>{q.current=!1})},[_,X,Y,r]),a.useEffect(()=>{r.setDisabled(!!e.disabled)},[r,e.disabled]),a.useEffect(()=>{var t;A.ref&&((t=C.current)==null||t.setAnchorElement(A.ref))},[A.ref]),{notchWidth:c,menuOpen:S,lineRippleActive:u,lineRippleCenter:o,floatLabel:v,selectedIndex:i.current,selectedTextContent:p,setFloatingLabel:w,setMenu:G,setLeadingIcon:U,setNativeControl:te,handleFocus:ne,handleBlur:ce,handleClick:re,handleChange:se,handleKeydown:J,handleMenuClosed:oe,handleMenuOpened:ae,handleMenuSelected:le,...Q}},je=e=>{const{foundation:c,...x}=b.useFoundation({props:e,elements:{rootEl:!0},api:({foundation:u})=>({getFoundation:()=>u}),foundation:({rootEl:u,emit:m})=>new ee.MDCSelectIconFoundation({getAttr:o=>u.getProp(o),setAttr:(o,f)=>u.setProp(o,f),removeAttr:o=>u.removeProp(o),setContent:o=>{u.ref&&(u.ref.textContent=o)},registerInteractionHandler:(o,f)=>u.addEventListener(o,f),deregisterInteractionHandler:(o,f)=>u.removeEventListener(o,f),notifyIconAction:()=>m("onClick",{},!0)})});return{...x}},Ae=function(c){const{apiRef:x,...u}=c,{rootEl:m}=je(c),o=b.useClassNames(c,["mdc-select__icon"]);return n.jsx(de.Icon,{...m.props({...u,className:o})})},me=e=>Array.isArray(e)&&e[0]&&typeof e[0]=="object"?e.map(c=>{if(typeof c!="object")throw new Error(`Encountered non object for Select ${c}`);return{...c,options:me(c.options)}}):Array.isArray(e)?e.map(c=>({value:c,label:c})):typeof e=="object"?Object.keys(e).map(c=>({value:c,label:e[c]})):e,Ie=()=>n.jsxs("span",{className:"mdc-select__dropdown-icon",children:[n.jsx(de.Icon,{className:"mdc-select__dropdown-icon-inactive",icon:"arrow_drop_down"}),n.jsx(de.Icon,{className:"mdc-select__dropdown-icon-active",icon:"arrow_drop_up"})]});function Me(e){const{selectOptions:c,placeholder:x="",children:u,elementRef:m,open:o,label:f,...v}=e,O=({label:h,option:p,index:g})=>n.jsx("option",{...p,value:p.value,children:h},g),S=!e.value&&!e.defaultValue;return n.jsxs("select",{tabIndex:0,...v,ref:m,className:`rmwc-select__native-control${v.className?` ${v.className}`:""}`,children:[(e.placeholder!==void 0||S)&&n.jsx("option",{value:"",disabled:S,children:x}),!!c&&c.map(({label:h,options:p,...g},i)=>p?n.jsx("optgroup",{label:h,children:p.map(({label:N,...w},C)=>O({label:N,option:w,index:C}))},i):O({label:h,option:g,index:i})),u]})}const Re=ve.withRipple({surface:!1})(function(e){return n.jsx(b.Tag,{...e})}),Le=a.forwardRef((e,c)=>{const{selectOptions:x,menuApiRef:u,value:m,placeholder:o,children:f,selectedIndex:v,...O}=e;let S=0;const h=b.useClassNames(e,["mdc-select__menu"]),p=({label:g,option:i})=>(S+=1,n.jsx(z.MenuItem,{activated:m!==void 0?i.value===m:S-1===v,...i,"data-value":i.value,children:n.jsx("span",{className:"mdc-deprecated-list-item__text",children:g})},`${g}-${i.value}`));return n.jsxs(z.Menu,{...O,ref:c,apiRef:u,className:h,focusOnOpen:!0,children:[!!e.placeholder&&n.jsx(z.MenuItem,{selected:S-1===v,"data-value":"",theme:"textDisabledOnBackground",children:n.jsx("span",{className:"mdc-deprecated-list-item__text",children:o})}),x.map(({label:g,options:i,...N},w)=>i?n.jsxs(ue.ListGroup,{children:[g&&n.jsx(ue.ListGroupSubheader,{theme:"textDisabledOnBackground",children:g}),n.jsx(z.MenuItems,{children:i.map(({label:C,...G})=>p({label:C,option:G}))}),w<x.length-1&&n.jsx(ue.ListDivider,{})]},w):p({label:g,option:N})),f]})}),ye=({enhanced:e,children:c})=>e?n.jsx(z.MenuSurfaceAnchor,{children:c}):n.jsx(n.Fragment,{children:c}),Oe=b.createComponent(function(c,x){const{placeholder:u,children:m,value:o,outlined:f,label:v="",options:O=[],rootProps:S={},enhanced:h,icon:p,onChange:g,onFocus:i,onBlur:N,onKeyDown:w,invalid:C,inputRef:G,helpText:j,foundationRef:he,...B}=c,U=me(O),{rootEl:D,anchorEl:te,notchWidth:q,menuOpen:r,selectedTextContent:Q,lineRippleActive:A,lineRippleCenter:W,floatLabel:ne,setFloatingLabel:H,setNativeControl:ce,setLeadingIcon:P,selectedIndex:se,setMenu:re,handleFocus:V,handleBlur:J,handleClick:le,handleChange:ae,handleKeydown:oe,handleMenuClosed:X,handleMenuOpened:_,handleMenuSelected:Y}=Se(c),t=b.useId("select",c),R=b.useClassNames(c,["mdc-select","rmwc-select__default-width",{"mdc-select--outlined":!!f,"mdc-select--filled":!f,"mdc-select--required":!!c.required,"mdc-select--invalid":!!C,"mdc-select--with-leading-icon":!!p,"mdc-select--no-label":!v}]),L=typeof h=="object"?h:{},k=o!==void 0?void 0:c.defaultValue||"",y=n.jsx(ge.FloatingLabel,{float:ne,apiRef:H,htmlFor:t,children:v}),$=()=>{if(!!!j)return null;const Z=typeof j=="object"&&!a.isValidElement(j);return j&&Z?n.jsx(ie,{...j}):n.jsx(ie,{children:j})};return n.jsxs(ye,{enhanced:h,children:[n.jsxs(b.Tag,{...S,element:D,ref:x,className:R,children:[n.jsxs(Re,{className:"mdc-select__anchor",role:"button","aria-haspopup":"listbox",element:te,onFocus:V,onBlur:J,onClick:le,onKeyDown:oe,onChange:ae,tabIndex:h?void 0:-1,children:[!!p&&n.jsx(Ae,{apiRef:P,icon:p}),f?n.jsx(be.NotchedOutline,{notch:q,children:y}):n.jsxs(n.Fragment,{children:[n.jsx(Ce.LineRipple,{active:A,center:W}),y]}),n.jsx("span",{className:"mdc-select__selected-text-container",children:n.jsx("span",{className:"mdc-select__selected-text",children:Q})}),n.jsx(Ie,{}),!h&&n.jsx(Me,{...B,id:t,value:o,children:m,defaultValue:k,placeholder:u,selectOptions:U,elementRef:ce,onFocus:V,onBlur:I=>{J(I),X()},onChange:I=>{Y(I.currentTarget.selectedIndex)}})]}),h&&n.jsx(Le,{...B,...L,ref:x,anchorCorner:"bottomStart",defaultValue:k,placeholder:u,open:r,onClose:X,onOpen:_,onSelect:I=>{Y(I.detail.index)},selectOptions:U,value:o,selectedIndex:se,menuApiRef:re,children:m})]}),$()]})}),ie=b.createComponent(function(c,x){const{persistent:u,validationMsg:m,...o}=c,f=b.useClassNames(c,["mdc-select-helper-text",{"mdc-select-helper-text--persistent":u,"mdc-select-helper-text--validation-msg":m}]);return n.jsx(b.Tag,{tag:"p",...o,className:f,ref:x})});exports.Select=Oe;exports.SelectHelperText=ie; |
{ | ||
"name": "@rmwc/select", | ||
"version": "14.0.10", | ||
"version": "14.0.11", | ||
"description": "RMWC Select component", | ||
@@ -43,12 +43,12 @@ "main": "./index.js", | ||
"@material/select": "^14.0.0", | ||
"@rmwc/base": "14.0.10", | ||
"@rmwc/floating-label": "14.0.10", | ||
"@rmwc/icon": "14.0.10", | ||
"@rmwc/line-ripple": "14.0.10", | ||
"@rmwc/list": "14.0.10", | ||
"@rmwc/menu": "14.0.10", | ||
"@rmwc/notched-outline": "14.0.10", | ||
"@rmwc/ripple": "14.0.10", | ||
"@rmwc/types": "14.0.10" | ||
"@rmwc/base": "14.0.11", | ||
"@rmwc/floating-label": "14.0.11", | ||
"@rmwc/icon": "14.0.11", | ||
"@rmwc/line-ripple": "14.0.11", | ||
"@rmwc/list": "14.0.11", | ||
"@rmwc/menu": "14.0.11", | ||
"@rmwc/notched-outline": "14.0.11", | ||
"@rmwc/ripple": "14.0.11", | ||
"@rmwc/types": "14.0.11" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40134
700
+ Added@rmwc/base@14.0.11(transitive)
+ Added@rmwc/floating-label@14.0.11(transitive)
+ Added@rmwc/icon@14.0.11(transitive)
+ Added@rmwc/line-ripple@14.0.11(transitive)
+ Added@rmwc/list@14.0.11(transitive)
+ Added@rmwc/menu@14.0.11(transitive)
+ Added@rmwc/notched-outline@14.0.11(transitive)
+ Added@rmwc/provider@14.0.11(transitive)
+ Added@rmwc/ripple@14.0.11(transitive)
+ Added@rmwc/types@14.0.11(transitive)
- Removed@rmwc/base@14.0.10(transitive)
- Removed@rmwc/floating-label@14.0.10(transitive)
- Removed@rmwc/icon@14.0.10(transitive)
- Removed@rmwc/line-ripple@14.0.10(transitive)
- Removed@rmwc/list@14.0.10(transitive)
- Removed@rmwc/menu@14.0.10(transitive)
- Removed@rmwc/notched-outline@14.0.10(transitive)
- Removed@rmwc/provider@14.0.10(transitive)
- Removed@rmwc/ripple@14.0.10(transitive)
- Removed@rmwc/types@14.0.10(transitive)
Updated@rmwc/base@14.0.11
Updated@rmwc/floating-label@14.0.11
Updated@rmwc/icon@14.0.11
Updated@rmwc/line-ripple@14.0.11
Updated@rmwc/list@14.0.11
Updated@rmwc/menu@14.0.11
Updated@rmwc/ripple@14.0.11
Updated@rmwc/types@14.0.11