code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function QJ(){return r.jsxs(et,{title:"Menus",lead:"Menus display a list of choices on a transient sheet of material.",module:"@rmwc/menu",styles:["@material/menu/dist/mdc.menu.css","@material/menu-surface/dist/mdc.menu-surface.css","@material/ripple/dist/mdc.ripple.css","@material/list/dist/mdc.list.css","@rmwc/icon/icon.css"],docsLink:"https://material.io/develop/web/components/menus/",examples:KJ,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can compose a menu with the given components, and manually manage the open state. `Menu` expects MenuItems as children while `MenuSurface` is a generic container which can have anything as a child."}),r.jsx(F,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ns,{children:[r.jsxs(Rr,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[r.jsx(Gn,{children:"Cookies"}),r.jsx(Gn,{children:"Pizza"}),r.jsx(di,{}),r.jsx(Gn,{children:"Icecream"})]}),r.jsx(ye,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),r.jsx(F,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ns,{children:[r.jsx(Cr,{open:t,onClose:a=>n(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})}),r.jsx(ye,{raised:!0,onClick:a=>n(!t),children:"Menu Surface"})]})}}),r.jsx(F,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ns,{children:[r.jsx(Cr,{open:t,onClose:()=>n(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Menu"})}),r.jsx(ut,{icon:"menu",onClick:()=>n(!t)})]})}}),r.jsx(F,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ns,{children:[r.jsxs(Rr,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[r.jsx(Gn,{children:"Item One"}),r.jsx(Gn,{disabled:!0,children:"Item Two (disabled)"}),r.jsx(Gn,{children:"Item Three"})]}),r.jsx(ye,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),r.jsx(fe,{children:"Simplified usage"}),r.jsx(ce,{children:"RMWC provides a convenience `SimpleMenu` component that takes a handle as a prop, and manages the open state for you."}),r.jsx(F,{children:r.jsxs(tm,{handle:r.jsx(ye,{children:"Simple Menu"}),children:[r.jsx(Gn,{children:"Cookies"}),r.jsx(Gn,{children:"Pizza"}),r.jsx(Gn,{children:"Icecream"})]})}),r.jsx(F,{children:r.jsx(D1,{handle:r.jsx(ye,{children:"Simple Menu Surface"}),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})})}),r.jsx(fe,{children:"Anchoring"}),r.jsx(ce,{children:"By default, Menus will attempt to automatically position themselves, but this behavior can be overridden by setting the `anchorCorner` prop."}),r.jsx(F,{children:function(){const[t,n]=q.useState("topLeft");return r.jsxs(r.Fragment,{children:[r.jsxs(ns,{children:[r.jsx(Cr,{anchorCorner:t,open:!0,children:r.jsxs("div",{style:{padding:"1rem",width:"8rem"},children:["anchorCorner: ",t]})}),r.jsx(ye,{raised:!0,label:"Anchored Menu"})]}),r.jsx(jt,{value:t,label:"anchorCorner",onChange:a=>n(a.currentTarget.value),options:["topLeft","topRight","bottomLeft","bottomRight","topStart","topEnd","bottomStart","bottomEnd"]})]})}}),r.jsx(fe,{children:"Rendering through Portals"}),r.jsx(ce,{children:"Occasionally, you may find your menu being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),r.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),r.jsx(F,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),r.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a menu being cut off due to `overflow: hidden`."}),r.jsx(F,{children:function(){const[t,n]=q.useState(!0),[a,s]=q.useState(!1),i=["Cookies","Pizza","Icecream"];return r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{marginBottom:"10rem",height:"3.5rem",overflow:"hidden"},children:r.jsxs(ns,{children:[r.jsx(ye,{raised:!0,onClick:()=>s(!a),children:"Open Menu"}),r.jsx(Rr,{open:a,onClose:()=>s(!1),renderToPortal:t,children:i.map(o=>r.jsx(Gn,{children:o},o))})]})}),r.jsx(Dn,{checked:t,onChange:o=>n(o.currentTarget.checked),label:"renderToPortal"})]})}}),r.jsx(nt,{src:XJ,components:[{displayName:"Menu",component:Rr},{displayName:"MenuItem",component:Gn},{displayName:"MenuSurface",component:Cr},{displayName:"MenuSurfaceAnchor",component:ns},{displayName:"SimpleMenu",component:tm},{displayName:"SimpleMenuSurface",component:D1}]})]})}
|
The handle can be any component you want
|
QJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-pCmSyOeM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-pCmSyOeM.js
|
MIT
|
function nee(){return r.jsxs(et,{title:"Provider",lead:"A component that provides global configuration for RMWC.",module:"@rmwc/provider",styles:[],examples:JJ,children:[r.jsx(ce,{children:"You can wrap your top level App component with RMWC provider to set global configuration options. Just pass the options in as props."}),r.jsx(F,{codeOnly:!0,children:`
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
// This example disables ripples globally by default
ReactDOM.render(
<RMWCProvider
// Globally disable ripples
ripple={false}
// Global options for icons
// Takes the same options as the icon component
icon={{
basename: 'material-icons'
}}
// Global options for typography
// allows mapping of a defaultTag or specific classes
// See the Typography docs for more info
typography={{
defaultTag: 'div',
headline1: 'h1'
}}
// Global options for tooltips
// Takes most of the options for tooltips
// See the Tooltip docs for more info
tooltip={{
align: 'right'
}}
>
<App />
</RMWCProvider>,
document.getElementById('root'),
);
`}),r.jsx(F,{label:"With ripple false",children:r.jsx(hi,{ripple:!1,children:r.jsx(ye,{children:"Click me"})})}),r.jsx(F,{label:"With ripple true",children:r.jsx(hi,{ripple:!0,children:r.jsx(ye,{children:"Click me"})})}),r.jsx(nt,{src:tee,components:[{displayName:"RMWCProvider",component:hi}]})]})}
|
The handle can be any component you want
|
nee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-pCmSyOeM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-pCmSyOeM.js
|
MIT
|
function Lee(){return r.jsxs(et,{title:"Snackbars",lead:"Snackbars provide brief feedback about an operation through a message at the bottom of the screen.",module:"@rmwc/snackbar",styles:["@material/snackbar/dist/mdc.snackbar.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/snackbars/",examples:Ree,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can render a snackbar in your UI and control its open state."}),r.jsx(F,{label:"Default",children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(jo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,action:r.jsx(Fo,{label:"Dismiss",onClick:()=>console.log("Click Me")})}),r.jsx(ye,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),r.jsx(F,{label:"Start Aligned",children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(jo,{open:t,onClose:a=>n(!1),message:"Start aligned, open until dismissed",stacked:!0,dismissesOnAction:!0,action:[r.jsx(Fo,{label:"Yeah!"}),r.jsx(Fo,{label:"No..."})],leading:!0,timeout:-1}),r.jsx(ye,{raised:!0,label:"Show start-aligned",onClick:a=>n(!t)})]})}}),r.jsx(F,{label:"With dismiss icon",children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(jo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,dismissIcon:"close",timeout:-1}),r.jsx(ye,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),r.jsx(fe,{children:"Usage with SnackbarQueue"}),r.jsx(ce,{children:"While rendering the Snackbar inline works for simple cases, you'll likely have a notification system, or want to send notifications from anywhere in your app. The `SnackbarQueue` exists as a convenient interface for handling these cases and rendering the snackbar messages for you. If you've used the `DialogQueue`, the `SnackbarQueue` is very similar."}),r.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `messages` to the `SnackbarQueue` component, and then use the `notify` function to send notifications."}),r.jsx(F,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createSnackbarQueue } from '@rmwc/snackbar';
export const queue = createSnackbarQueue();
`}),r.jsx(F,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the SnackbarQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<SnackbarQueue
messages={queue.messages}
// You can also pass default options to pass to your notifications
// ie, make them all leading, stacked, etc
leading
stacked
/>
</div>
)
}
`}),r.jsx(ce,{children:"The `notify` function was designed to mimic the the built-in browser Notifications api and can accept most of the relevant options (icon, image, title, body, actions, ,etc). It also can accept any of the Snackbar props. Just import your queue, and call the notify method."}),r.jsx(F,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
// Simple example
queue.notify({
title: 'Hi there'
});
// With some features
queue.notify({
title: <b>Warning</b>,
body: 'You have selected pizza instead icecream!',
icon: 'warning',
actions: [
{
// NotificationAction api format
title: 'Fix It!',
icon: 'close',
action: 'fixit' // action will be available as evt.detail.reason in the onClose event
},
{
// OR SnackbarActionProps format
label: 'Continue...',
icon: 'check',
onClick: () => {}
},
]
});
`}),r.jsx(F,{label:"Inline Example",children:()=>{const{messages:e,notify:t}=iL();function n(){return r.jsxs("div",{children:[r.jsx(ye,{label:"Notify",onClick:()=>t({title:r.jsx("b",{children:"Success"}),body:"You have selected pizza!",dismissesOnAction:!0,icon:"check",actions:[{title:"Dismiss"}]})}),r.jsx(sL,{messages:e})]})}return r.jsx(n,{})}}),r.jsx(nt,{src:Iee,components:[{displayName:"Snackbar",component:jo},{displayName:"SnackbarAction",component:Fo}]})]})}
|
Any additional items will be passed to the
child ListItem as props
|
Lee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-pCmSyOeM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-pCmSyOeM.js
|
MIT
|
function tJ(){return o.jsxs(lt,{title:"Dialogs",lead:"Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.",module:"@rmwc/dialog",styles:["@material/dialog/dist/mdc.dialog.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/dialogs/",examples:ZZ,children:[o.jsx(he,{children:"Standard Usage"}),o.jsx(M,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(km,{open:t,onClose:a=>{console.log(a.detail.action),n(!1)},onClosed:a=>console.log(a.detail.action),children:[o.jsx(wm,{children:"Dialog Title"}),o.jsx(Pm,{children:"This is a standard dialog."}),o.jsxs(Em,{children:[o.jsx(fc,{action:"close",children:"Cancel"}),o.jsx(fc,{action:"accept",isDefaultAction:!0,children:"Sweet!"})]})]}),o.jsx(ke,{raised:!0,onClick:()=>n(!0),children:"Open standard Dialog"})]})}}),o.jsx(he,{children:"Simplified Usage"}),o.jsx(ue,{children:"Material Dialogs are a complex component. RMWC contains an additional `SimpleDialog` component for ease of use that internally contains the default structure already built out. Illustrated below is both the standard and simple dialog usage."}),o.jsx(M,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Fu,{title:"This is a simple dialog",body:"You can pass the body prop or children.",open:t,onClose:a=>{console.log(a.detail.action),n(!1)}}),o.jsx(ke,{raised:!0,onClick:()=>n(!0),children:"Open Simple Dialog"})]})}}),o.jsx(he,{children:"Usage with DialogQueue"}),o.jsx(ue,{children:"Some dialog interactions are complex, but a lot of the time you just need a simple alert or confirm dialog. `DialogQueue` allows you to open dialogs from anywhere in your app and emulates the browsers built in `alert`, `confirm` and `prompt` dialogs. If you've used the `SnackbarQueue`, the `DialogQueue` is very similar."}),o.jsx(ue,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `dialogs` to the `DialogQueue`component, and then use the `alert`, `prompt` or `confirm` api to open dialogs."}),o.jsx(M,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createDialogQueue } from '@rmwc/dialog';
export const queue = createDialogQueue();
`}),o.jsx(M,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the DialogQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<DialogQueue
dialogs={queue.dialogs}
// You can also pass default options to pass to your dialogs
// ie, prevent all dialogs from dismissing from a click on the background scrim
preventOutsideDismiss
/>
</div>
)
}
`}),o.jsx(ue,{children:"The `alert`, `confirm`, and `prompt` functions were designed to mimic the the built-in browser methods with a couple of small difference. First, they all return a promise. The promise will always resolve successfully with the response indicating the appropriate action. `alert` the response will be `accept` for clicking the ok button, or `close`. `confirm` will resolve `true` or `false`, and `prompt` will resolve with the value entered into the input, or `null` if the closed the dialog. Second, all methods the methods accept any valid prop for `SimpleDialog`."}),o.jsx(M,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
queue.alert({
title: 'Hi there',
body: 'Whats going on?'
});
queue.confirm({
title: <b>Are you positive?</b>,
body: 'You have selected pizza instead icecream!',
acceptLabel: 'CONFIRM'
});
queue.prompt({
title: 'Whats your name?',
body: 'Anything will do',
acceptLabel: 'Submit',
cancelLabel: 'Skip',
// For prompts only, you can pass props to the input
inputProps: {
outlined: true
}
});
`}),o.jsx(M,{label:"Inline Example",children:()=>{const{dialogs:e,alert:t,confirm:n,prompt:a}=nD();function s(){const[i,r]=G.useState("____________"),l=()=>t({title:"Hello!"}).then(d=>r(d)),c=()=>n({}).then(d=>r(d)),p=()=>a({inputProps:{outlined:!0}}).then(d=>r(d));return o.jsxs("div",{children:[o.jsx(ke,{label:"Alert",onClick:l}),o.jsx(ke,{label:"Confirm",onClick:c}),o.jsx(ke,{label:"Prompt",onClick:p}),o.jsx(ke,{label:"In Sequence",onClick:()=>{l(),c(),p()}}),o.jsxs("p",{children:["Response: ",o.jsx("b",{children:String(i)})]}),o.jsx(tD,{dialogs:e})]})}return o.jsx(s,{})}}),o.jsx(he,{children:"Rendering through Portals"}),o.jsx(ue,{children:"Occasionally, you may find your dialog being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),o.jsx(ue,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),o.jsx(M,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),o.jsx(ue,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a dialog being cut off due to `overflow: hidden`."}),o.jsx(M,{children:function(){const[t,n]=G.useState(!0),[a,s]=G.useState(!1);return o.jsxs("div",{id:"dialog-portal-example",style:{transform:"translateZ(0)",height:"20rem",overflow:"hidden"},children:[o.jsx(Fu,{title:`This is a ${t?"working!":"broken :/"}`,renderToPortal:t,body:"Use `renderToPortal` to get around `overflow:hidden` and layout issues.",open:a,onClose:i=>{console.log(i.detail.action),s(!1)}}),o.jsx(ke,{raised:!0,onClick:()=>{n(!1),s(!0)},children:"Open Broken :/"}),o.jsx(ke,{raised:!0,onClick:()=>{n(!0),s(!0)},children:"Open in Portal"})]})}}),o.jsx(ct,{src:eJ,components:[{displayName:"Dialog",component:km},{displayName:"DialogTitle",component:wm},{displayName:"DialogContent",component:Pm},{displayName:"DialogActions",component:Em},{displayName:"DialogButton",component:fc},{displayName:"SimpleDialog",component:Fu}]})]})}
|
Wrapping a button in TouchTargetWrapper will automatically set its \`touch\` prop to true.
|
tJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-V3GUpERh.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-V3GUpERh.js
|
MIT
|
function NJ(){return o.jsxs(lt,{title:"Icons",lead:"Material icons use geometric shapes to visually represent core ideas, capabilities, or topics.",module:"@rmwc/icon",styles:["@rmwc/icon/icon.css"],docsLink:"https://material.io/icons",examples:DJ,children:[o.jsx(he,{children:"Setup"}),o.jsx(ue,{children:"Icons are not part of the official material-components-web spec, but they are referenced many times in the documentation. RMWC provides a declarative way to use icons. Note that RMWC does not ship with any icons of its own. Make sure you include an icon set! You can use any one you want, but Google's Material Icons are available through open source. Follow Google's developer guide to get them setup with your app. https://google.github.io/material-design-icons/"}),o.jsx(ue,{children:"There are lots of different strategies for implementing icons on the web, and the Icon component is flexible for most of them. Use ligatures, classNames, inline SVGs, HTML, or URLs to get icons into your app. The default strategy is 'ligature' which works with the material.io font icon set."}),o.jsx(he,{children:"Basic Usage"}),o.jsx(ue,{children:"The Icon component, (really the icon prop itself) can accept a variety of formats. Anywhere you see a component prop like `icon` or `trailingIcon` will inherit the same behavior."}),o.jsx(M,{label:"String",children:o.jsx(Ye,{icon:"favorite"})}),o.jsx(M,{label:"Child Component",children:o.jsx(Ye,{icon:o.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})})}),o.jsx(M,{label:"Passing Options",children:o.jsxs(o.Fragment,{children:[o.jsx(Ye,{icon:{icon:"star",strategy:"ligature"}}),o.jsx(ke,{label:"Hello!",icon:{icon:"add",onMouseOver:()=>console.log("OVER")}})]})}),o.jsx(he,{children:"Icon Sizing"}),o.jsx(ue,{children:"The Material spec details multiple sizes for icons. The Icon component doesn't assign a size by default, but these are available to you to force a size. Please note, this will only work if you've included the RMWC icon css file."}),o.jsx(M,{children:o.jsxs(o.Fragment,{children:[o.jsx(Ye,{icon:{icon:"favorite",size:"xsmall"}}),o.jsx(Ye,{icon:{icon:"favorite",size:"small"}}),o.jsx(Ye,{icon:{icon:"favorite",size:"medium"}}),o.jsx(Ye,{icon:{icon:"favorite",size:"large"}}),o.jsx(Ye,{icon:{icon:"favorite",size:"xlarge"}})]})}),o.jsx(he,{children:"Ligatures"}),o.jsx(ue,{children:"This is for icon fonts that support ligatures like material-icons. This is the default strategy if nothing is set and doesn't require any additional setup if you are using material-icons."}),o.jsx(M,{children:o.jsxs(o.Fragment,{children:[o.jsx(Ye,{icon:"favorite"}),o.jsx(Ye,{icon:"favorite_outline"}),o.jsx(Ye,{icon:{icon:"star",strategy:"ligature"}})]})}),o.jsx(he,{children:"URLs"}),o.jsx(ue,{children:"This is for icons that are accessible via HTTP(S) and will be loaded directly into an `img` tag. This can be auto-detected for things that look like urls. The image will be set as a backgroundImage of the icon. Make sure you impor the RMWC icon css file for this to work properly."}),o.jsx(M,{children:o.jsxs(o.Fragment,{children:[o.jsx(Ye,{icon:"images/icons/twitter.png"}),o.jsx(Ye,{icon:{icon:"images/icons/twitter.png",strategy:"url"}})]})}),o.jsx(he,{children:"Components / Inline SVGs"}),o.jsx(ue,{children:"This will render a child component inside of the icon. This is useful for all sorts of customization and for rendering inline SVGs. The following example shows rendering an SVG, as well as an arbitrary `div`."}),o.jsx(M,{children:o.jsxs(o.Fragment,{children:[o.jsx(Ye,{icon:o.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})}),o.jsx(Ye,{icon:{strategy:"component",icon:o.jsx("svg",{style:{width:"24px",height:"24px"},viewBox:"0 0 24 24",children:o.jsx("path",{fill:"#4285F4",d:"M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z"})})}})]})}),o.jsx(he,{children:"Classnames"}),o.jsx(ue,{children:"Some font icon sets like Ion Icons and Glyph Icons render based on a className that is set. RMWC docs doesn't include extra icon fonts so there is no example to render, but the below code should give you an approximation."}),o.jsx(ue,{children:"**THIS CANNOT BE AUTO DETECTED**. You'll have to explicitly set the strategy directly on the Icon or specify it globally via the RMWCProvider."}),o.jsx(M,{codeOnly:!0,children:o.jsxs(o.Fragment,{children:[o.jsx(Ye,{icon:{icon:"star",strategy:"className",basename:"icon",prefix:"ion-"}}),o.jsx(hi,{icon:{strategy:"className",basename:"glyphicons",prefix:"glyphicons-"},children:o.jsx(Ye,{icon:"heart"})})]})}),o.jsx(he,{children:"Custom Rendering"}),o.jsx(ue,{children:"Sometimes, you just need to do your own thing. Maybe you have a legacy project that already has icons and you want to incorporate them with RMWC. If none of the other strategies are what you need, then you can hijack the whole thing and delegate it to your own render function."}),o.jsx(M,{label:"Simple Example",children:o.jsx(Ye,{icon:{icon:"favorite",strategy:"custom",render:({content:e})=>o.jsxs("div",{children:["Hello + ",e]})}})}),o.jsx(ue,{children:"A more relevant example involves an app that has a custom / existing icon component. There are a litany of reasons why your app might need one, but if you've found this section of the docs you likely know what problem you need to solve."}),o.jsx(M,{codeOnly:!0,children:`
// 1) Your app has an icon component you use
import { MyIconComponent } from '@rmwc/icon';
<MyIconComponent name="search" />
// 2) Now you are using RMWC, lots of components are instances of Icons
// You need to be able to delegate the handling of an icon prop to your own component
import { TextField } from '@rmwc/textField';
import { Chip } from '@rmwc/chip';
<TextField icon="favorite" />
<Chip icon="favorite" />
// 3) Instead, you should set the custom strategy to be your default
// and add your own handling with RMWCProvider
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
import { MyIconComponent } from '@rmwc/icon';
const iconRenderHandler = ({ content, className, ...rest }) => {
// content is whatever was passed to the icon prop
// className is the fully processed className taking into account the basename and prefix defaults
// it's important to include this because MDC often has classes like text-field-icon directly
// on the component for alignment
// rest is just any other props
return <MyIconComponent className={className} name={content} {...rest} />
};
ReactDOM.render(
<RMWCProvider icon={{strategy: 'custom', render: iconRenderHandler}}>
<App />
</RMWCProvider>,
document.getElementById('root')
);
// 4) Now anywhere in your app that an Icon instance is used, it will be
// delegated to your handler and render your custom component
import { TextFieldIcon } from '@rmwc/textfield';
<TextFieldIcon icon="search" />
`}),o.jsx(ct,{src:_J,components:[{displayName:"Icon",component:Ye}]})]})}
|
Set the option globally throug RMWCProvider
Glyphicons <span class="glyphicons glyphicons-heart"></span>
|
NJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-V3GUpERh.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-V3GUpERh.js
|
MIT
|
function cee(){return o.jsxs(lt,{title:"Menus",lead:"Menus display a list of choices on a transient sheet of material.",module:"@rmwc/menu",styles:["@material/menu/dist/mdc.menu.css","@material/menu-surface/dist/mdc.menu-surface.css","@material/ripple/dist/mdc.ripple.css","@material/list/dist/mdc.list.css","@rmwc/icon/icon.css"],docsLink:"https://material.io/develop/web/components/menus/",examples:ree,children:[o.jsx(he,{children:"Basic Usage"}),o.jsx(ue,{children:"You can compose a menu with the given components, and manually manage the open state. `Menu` expects MenuItems as children while `MenuSurface` is a generic container which can have anything as a child."}),o.jsx(M,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(cs,{children:[o.jsxs(Or,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[o.jsx(ea,{children:"Cookies"}),o.jsx(ea,{children:"Pizza"}),o.jsx(di,{}),o.jsx(ea,{children:"Icecream"})]}),o.jsx(ke,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),o.jsx(M,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(cs,{children:[o.jsx(Dr,{open:t,onClose:a=>n(!1),children:o.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})}),o.jsx(ke,{raised:!0,onClick:a=>n(!t),children:"Menu Surface"})]})}}),o.jsx(M,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(cs,{children:[o.jsx(Dr,{open:t,onClose:()=>n(!1),children:o.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Menu"})}),o.jsx(xt,{icon:"menu",onClick:()=>n(!t)})]})}}),o.jsx(M,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(cs,{children:[o.jsxs(Or,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[o.jsx(ea,{children:"Item One"}),o.jsx(ea,{disabled:!0,children:"Item Two (disabled)"}),o.jsx(ea,{children:"Item Three"})]}),o.jsx(ke,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),o.jsx(he,{children:"Simplified usage"}),o.jsx(ue,{children:"RMWC provides a convenience `SimpleMenu` component that takes a handle as a prop, and manages the open state for you."}),o.jsx(M,{children:o.jsxs(am,{handle:o.jsx(ke,{children:"Simple Menu"}),children:[o.jsx(ea,{children:"Cookies"}),o.jsx(ea,{children:"Pizza"}),o.jsx(ea,{children:"Icecream"})]})}),o.jsx(M,{children:o.jsx(_1,{handle:o.jsx(ke,{children:"Simple Menu Surface"}),children:o.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})})}),o.jsx(he,{children:"Anchoring"}),o.jsx(ue,{children:"By default, Menus will attempt to automatically position themselves, but this behavior can be overridden by setting the `anchorCorner` prop."}),o.jsx(M,{children:function(){const[t,n]=G.useState("topLeft");return o.jsxs(o.Fragment,{children:[o.jsxs(cs,{children:[o.jsx(Dr,{anchorCorner:t,open:!0,children:o.jsxs("div",{style:{padding:"1rem",width:"8rem"},children:["anchorCorner: ",t]})}),o.jsx(ke,{raised:!0,label:"Anchored Menu"})]}),o.jsx(qt,{value:t,label:"anchorCorner",onChange:a=>n(a.currentTarget.value),options:["topLeft","topRight","bottomLeft","bottomRight","topStart","topEnd","bottomStart","bottomEnd"]})]})}}),o.jsx(he,{children:"Rendering through Portals"}),o.jsx(ue,{children:"Occasionally, you may find your menu being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),o.jsx(ue,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),o.jsx(M,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),o.jsx(ue,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a menu being cut off due to `overflow: hidden`."}),o.jsx(M,{children:function(){const[t,n]=G.useState(!0),[a,s]=G.useState(!1),i=["Cookies","Pizza","Icecream"];return o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{marginBottom:"10rem",height:"3.5rem",overflow:"hidden"},children:o.jsxs(cs,{children:[o.jsx(ke,{raised:!0,onClick:()=>s(!a),children:"Open Menu"}),o.jsx(Or,{open:a,onClose:()=>s(!1),renderToPortal:t,children:i.map(r=>o.jsx(ea,{children:r},r))})]})}),o.jsx(Fn,{checked:t,onChange:r=>n(r.currentTarget.checked),label:"renderToPortal"})]})}}),o.jsx(ct,{src:lee,components:[{displayName:"Menu",component:Or},{displayName:"MenuItem",component:ea},{displayName:"MenuSurface",component:Dr},{displayName:"MenuSurfaceAnchor",component:cs},{displayName:"SimpleMenu",component:am},{displayName:"SimpleMenuSurface",component:_1}]})]})}
|
The handle can be any component you want
|
cee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-V3GUpERh.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-V3GUpERh.js
|
MIT
|
function mee(){return o.jsxs(lt,{title:"Provider",lead:"A component that provides global configuration for RMWC.",module:"@rmwc/provider",styles:[],examples:pee,children:[o.jsx(ue,{children:"You can wrap your top level App component with RMWC provider to set global configuration options. Just pass the options in as props."}),o.jsx(M,{codeOnly:!0,children:`
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
// This example disables ripples globally by default
ReactDOM.render(
<RMWCProvider
// Globally disable ripples
ripple={false}
// Global options for icons
// Takes the same options as the icon component
icon={{
basename: 'material-icons'
}}
// Global options for typography
// allows mapping of a defaultTag or specific classes
// See the Typography docs for more info
typography={{
defaultTag: 'div',
headline1: 'h1'
}}
// Global options for tooltips
// Takes most of the options for tooltips
// See the Tooltip docs for more info
tooltip={{
align: 'right'
}}
>
<App />
</RMWCProvider>,
document.getElementById('root'),
);
`}),o.jsx(M,{label:"With ripple false",children:o.jsx(hi,{ripple:!1,children:o.jsx(ke,{children:"Click me"})})}),o.jsx(M,{label:"With ripple true",children:o.jsx(hi,{ripple:!0,children:o.jsx(ke,{children:"Click me"})})}),o.jsx(ct,{src:fee,components:[{displayName:"RMWCProvider",component:hi}]})]})}
|
The handle can be any component you want
|
mee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-V3GUpERh.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-V3GUpERh.js
|
MIT
|
function $ee(){return o.jsxs(lt,{title:"Snackbars",lead:"Snackbars provide brief feedback about an operation through a message at the bottom of the screen.",module:"@rmwc/snackbar",styles:["@material/snackbar/dist/mdc.snackbar.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/snackbars/",examples:Uee,children:[o.jsx(he,{children:"Basic Usage"}),o.jsx(ue,{children:"You can render a snackbar in your UI and control its open state."}),o.jsx(M,{label:"Default",children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Uo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,action:o.jsx(Ho,{label:"Dismiss",onClick:()=>console.log("Click Me")})}),o.jsx(ke,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),o.jsx(M,{label:"Start Aligned",children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Uo,{open:t,onClose:a=>n(!1),message:"Start aligned, open until dismissed",stacked:!0,dismissesOnAction:!0,action:[o.jsx(Ho,{label:"Yeah!"}),o.jsx(Ho,{label:"No..."})],leading:!0,timeout:-1}),o.jsx(ke,{raised:!0,label:"Show start-aligned",onClick:a=>n(!t)})]})}}),o.jsx(M,{label:"With dismiss icon",children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Uo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,dismissIcon:"close",timeout:-1}),o.jsx(ke,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),o.jsx(he,{children:"Usage with SnackbarQueue"}),o.jsx(ue,{children:"While rendering the Snackbar inline works for simple cases, you'll likely have a notification system, or want to send notifications from anywhere in your app. The `SnackbarQueue` exists as a convenient interface for handling these cases and rendering the snackbar messages for you. If you've used the `DialogQueue`, the `SnackbarQueue` is very similar."}),o.jsx(ue,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `messages` to the `SnackbarQueue` component, and then use the `notify` function to send notifications."}),o.jsx(M,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createSnackbarQueue } from '@rmwc/snackbar';
export const queue = createSnackbarQueue();
`}),o.jsx(M,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the SnackbarQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<SnackbarQueue
messages={queue.messages}
// You can also pass default options to pass to your notifications
// ie, make them all leading, stacked, etc
leading
stacked
/>
</div>
)
}
`}),o.jsx(ue,{children:"The `notify` function was designed to mimic the the built-in browser Notifications api and can accept most of the relevant options (icon, image, title, body, actions, ,etc). It also can accept any of the Snackbar props. Just import your queue, and call the notify method."}),o.jsx(M,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
// Simple example
queue.notify({
title: 'Hi there'
});
// With some features
queue.notify({
title: <b>Warning</b>,
body: 'You have selected pizza instead icecream!',
icon: 'warning',
actions: [
{
// NotificationAction api format
title: 'Fix It!',
icon: 'close',
action: 'fixit' // action will be available as evt.detail.reason in the onClose event
},
{
// OR SnackbarActionProps format
label: 'Continue...',
icon: 'check',
onClick: () => {}
},
]
});
`}),o.jsx(M,{label:"Inline Example",children:()=>{const{messages:e,notify:t}=cD();function n(){return o.jsxs("div",{children:[o.jsx(ke,{label:"Notify",onClick:()=>t({title:o.jsx("b",{children:"Success"}),body:"You have selected pizza!",dismissesOnAction:!0,icon:"check",actions:[{title:"Dismiss"}]})}),o.jsx(lD,{messages:e})]})}return o.jsx(n,{})}}),o.jsx(ct,{src:zee,components:[{displayName:"Snackbar",component:Uo},{displayName:"SnackbarAction",component:Ho}]})]})}
|
Any additional items will be passed to the
child ListItem as props
|
$ee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-V3GUpERh.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-V3GUpERh.js
|
MIT
|
function oJ(){return r.jsxs(Je,{title:"Dialogs",lead:"Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.",module:"@rmwc/dialog",styles:["@material/dialog/dist/mdc.dialog.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/dialogs/",examples:sJ,children:[r.jsx(fe,{children:"Standard Usage"}),r.jsx(j,{children:function(){const[t,n]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(Rm,{open:t,onClose:a=>{console.log(a.detail.action),n(!1)},onClosed:a=>console.log(a.detail.action),children:[r.jsx(Am,{children:"Dialog Title"}),r.jsx(Im,{children:"This is a standard dialog."}),r.jsxs(Lm,{children:[r.jsx(xc,{action:"close",children:"Cancel"}),r.jsx(xc,{action:"accept",isDefaultAction:!0,children:"Sweet!"})]})]}),r.jsx(ve,{raised:!0,onClick:()=>n(!0),children:"Open standard Dialog"})]})}}),r.jsx(fe,{children:"Simplified Usage"}),r.jsx(ce,{children:"Material Dialogs are a complex component. RMWC contains an additional `SimpleDialog` component for ease of use that internally contains the default structure already built out. Illustrated below is both the standard and simple dialog usage."}),r.jsx(j,{children:function(){const[t,n]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Gu,{title:"This is a simple dialog",body:"You can pass the body prop or children.",open:t,onClose:a=>{console.log(a.detail.action),n(!1)}}),r.jsx(ve,{raised:!0,onClick:()=>n(!0),children:"Open Simple Dialog"})]})}}),r.jsx(fe,{children:"Usage with DialogQueue"}),r.jsx(ce,{children:"Some dialog interactions are complex, but a lot of the time you just need a simple alert or confirm dialog. `DialogQueue` allows you to open dialogs from anywhere in your app and emulates the browsers built in `alert`, `confirm` and `prompt` dialogs. If you've used the `SnackbarQueue`, the `DialogQueue` is very similar."}),r.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `dialogs` to the `DialogQueue`component, and then use the `alert`, `prompt` or `confirm` api to open dialogs."}),r.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createDialogQueue } from '@rmwc/dialog';
export const queue = createDialogQueue();
`}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the DialogQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<DialogQueue
dialogs={queue.dialogs}
// You can also pass default options to pass to your dialogs
// ie, prevent all dialogs from dismissing from a click on the background scrim
preventOutsideDismiss
/>
</div>
)
}
`}),r.jsx(ce,{children:"The `alert`, `confirm`, and `prompt` functions were designed to mimic the the built-in browser methods with a couple of small difference. First, they all return a promise. The promise will always resolve successfully with the response indicating the appropriate action. `alert` the response will be `accept` for clicking the ok button, or `close`. `confirm` will resolve `true` or `false`, and `prompt` will resolve with the value entered into the input, or `null` if the closed the dialog. Second, all methods the methods accept any valid prop for `SimpleDialog`."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
queue.alert({
title: 'Hi there',
body: 'Whats going on?'
});
queue.confirm({
title: <b>Are you positive?</b>,
body: 'You have selected pizza instead icecream!',
acceptLabel: 'CONFIRM'
});
queue.prompt({
title: 'Whats your name?',
body: 'Anything will do',
acceptLabel: 'Submit',
cancelLabel: 'Skip',
// For prompts only, you can pass props to the input
inputProps: {
outlined: true
}
});
`}),r.jsx(j,{label:"Inline Example",children:()=>{const{dialogs:e,alert:t,confirm:n,prompt:a}=uL();function s(){const[i,o]=G.useState("____________"),l=()=>t({title:"Hello!"}).then(p=>o(p)),u=()=>n({}).then(p=>o(p)),d=()=>a({inputProps:{outlined:!0}}).then(p=>o(p));return r.jsxs("div",{children:[r.jsx(ve,{label:"Alert",onClick:l}),r.jsx(ve,{label:"Confirm",onClick:u}),r.jsx(ve,{label:"Prompt",onClick:d}),r.jsx(ve,{label:"In Sequence",onClick:()=>{l(),u(),d()}}),r.jsxs("p",{children:["Response: ",r.jsx("b",{children:String(i)})]}),r.jsx(cL,{dialogs:e})]})}return r.jsx(s,{})}}),r.jsx(fe,{children:"Rendering through Portals"}),r.jsx(ce,{children:"Occasionally, you may find your dialog being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),r.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),r.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a dialog being cut off due to `overflow: hidden`."}),r.jsx(j,{children:function(){const[t,n]=G.useState(!0),[a,s]=G.useState(!1);return r.jsxs("div",{id:"dialog-portal-example",style:{transform:"translateZ(0)",height:"20rem",overflow:"hidden"},children:[r.jsx(Gu,{title:`This is a ${t?"working!":"broken :/"}`,renderToPortal:t,body:"Use `renderToPortal` to get around `overflow:hidden` and layout issues.",open:a,onClose:i=>{console.log(i.detail.action),s(!1)}}),r.jsx(ve,{raised:!0,onClick:()=>{n(!1),s(!0)},children:"Open Broken :/"}),r.jsx(ve,{raised:!0,onClick:()=>{n(!0),s(!0)},children:"Open in Portal"})]})}}),r.jsx(tt,{src:rJ,components:[{displayName:"Dialog",component:Rm},{displayName:"DialogTitle",component:Am},{displayName:"DialogContent",component:Im},{displayName:"DialogActions",component:Lm},{displayName:"DialogButton",component:xc},{displayName:"SimpleDialog",component:Gu}]})]})}
|
Wrapping a button in TouchTargetWrapper will automatically set its \`touch\` prop to true.
|
oJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-VbmLhRNC.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-VbmLhRNC.js
|
MIT
|
function HJ(){return r.jsxs(Je,{title:"Icons",lead:"Material icons use geometric shapes to visually represent core ideas, capabilities, or topics.",module:"@rmwc/icon",styles:["@rmwc/icon/icon.css"],docsLink:"https://material.io/icons",examples:FJ,children:[r.jsx(fe,{children:"Setup"}),r.jsx(ce,{children:"Icons are not part of the official material-components-web spec, but they are referenced many times in the documentation. RMWC provides a declarative way to use icons. Note that RMWC does not ship with any icons of its own. Make sure you include an icon set! You can use any one you want, but Google's Material Icons are available through open source. Follow Google's developer guide to get them setup with your app. https://google.github.io/material-design-icons/"}),r.jsx(ce,{children:"There are lots of different strategies for implementing icons on the web, and the Icon component is flexible for most of them. Use ligatures, classNames, inline SVGs, HTML, or URLs to get icons into your app. The default strategy is 'ligature' which works with the material.io font icon set."}),r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"The Icon component, (really the icon prop itself) can accept a variety of formats. Anywhere you see a component prop like `icon` or `trailingIcon` will inherit the same behavior."}),r.jsx(j,{label:"String",children:r.jsx($e,{icon:"favorite"})}),r.jsx(j,{label:"Child Component",children:r.jsx($e,{icon:r.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})})}),r.jsx(j,{label:"Passing Options",children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:{icon:"star",strategy:"ligature"}}),r.jsx(ve,{label:"Hello!",icon:{icon:"add",onMouseOver:()=>console.log("OVER")}})]})}),r.jsx(fe,{children:"Icon Sizing"}),r.jsx(ce,{children:"The Material spec details multiple sizes for icons. The Icon component doesn't assign a size by default, but these are available to you to force a size. Please note, this will only work if you've included the RMWC icon css file."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:{icon:"favorite",size:"xsmall"}}),r.jsx($e,{icon:{icon:"favorite",size:"small"}}),r.jsx($e,{icon:{icon:"favorite",size:"medium"}}),r.jsx($e,{icon:{icon:"favorite",size:"large"}}),r.jsx($e,{icon:{icon:"favorite",size:"xlarge"}})]})}),r.jsx(fe,{children:"Ligatures"}),r.jsx(ce,{children:"This is for icon fonts that support ligatures like material-icons. This is the default strategy if nothing is set and doesn't require any additional setup if you are using material-icons."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:"favorite"}),r.jsx($e,{icon:"favorite_outline"}),r.jsx($e,{icon:{icon:"star",strategy:"ligature"}})]})}),r.jsx(fe,{children:"URLs"}),r.jsx(ce,{children:"This is for icons that are accessible via HTTP(S) and will be loaded directly into an `img` tag. This can be auto-detected for things that look like urls. The image will be set as a backgroundImage of the icon. Make sure you impor the RMWC icon css file for this to work properly."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:"images/icons/twitter.png"}),r.jsx($e,{icon:{icon:"images/icons/twitter.png",strategy:"url"}})]})}),r.jsx(fe,{children:"Components / Inline SVGs"}),r.jsx(ce,{children:"This will render a child component inside of the icon. This is useful for all sorts of customization and for rendering inline SVGs. The following example shows rendering an SVG, as well as an arbitrary `div`."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:r.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})}),r.jsx($e,{icon:{strategy:"component",icon:r.jsx("svg",{style:{width:"24px",height:"24px"},viewBox:"0 0 24 24",children:r.jsx("path",{fill:"#4285F4",d:"M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z"})})}})]})}),r.jsx(fe,{children:"Classnames"}),r.jsx(ce,{children:"Some font icon sets like Ion Icons and Glyph Icons render based on a className that is set. RMWC docs doesn't include extra icon fonts so there is no example to render, but the below code should give you an approximation."}),r.jsx(ce,{children:"**THIS CANNOT BE AUTO DETECTED**. You'll have to explicitly set the strategy directly on the Icon or specify it globally via the RMWCProvider."}),r.jsx(j,{codeOnly:!0,children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:{icon:"star",strategy:"className",basename:"icon",prefix:"ion-"}}),r.jsx(mi,{icon:{strategy:"className",basename:"glyphicons",prefix:"glyphicons-"},children:r.jsx($e,{icon:"heart"})})]})}),r.jsx(fe,{children:"Custom Rendering"}),r.jsx(ce,{children:"Sometimes, you just need to do your own thing. Maybe you have a legacy project that already has icons and you want to incorporate them with RMWC. If none of the other strategies are what you need, then you can hijack the whole thing and delegate it to your own render function."}),r.jsx(j,{label:"Simple Example",children:r.jsx($e,{icon:{icon:"favorite",strategy:"custom",render:({content:e})=>r.jsxs("div",{children:["Hello + ",e]})}})}),r.jsx(ce,{children:"A more relevant example involves an app that has a custom / existing icon component. There are a litany of reasons why your app might need one, but if you've found this section of the docs you likely know what problem you need to solve."}),r.jsx(j,{codeOnly:!0,children:`
// 1) Your app has an icon component you use
import { MyIconComponent } from '@rmwc/icon';
<MyIconComponent name="search" />
// 2) Now you are using RMWC, lots of components are instances of Icons
// You need to be able to delegate the handling of an icon prop to your own component
import { TextField } from '@rmwc/textField';
import { Chip } from '@rmwc/chip';
<TextField icon="favorite" />
<Chip icon="favorite" />
// 3) Instead, you should set the custom strategy to be your default
// and add your own handling with RMWCProvider
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
import { MyIconComponent } from '@rmwc/icon';
const iconRenderHandler = ({ content, className, ...rest }) => {
// content is whatever was passed to the icon prop
// className is the fully processed className taking into account the basename and prefix defaults
// it's important to include this because MDC often has classes like text-field-icon directly
// on the component for alignment
// rest is just any other props
return <MyIconComponent className={className} name={content} {...rest} />
};
ReactDOM.render(
<RMWCProvider icon={{strategy: 'custom', render: iconRenderHandler}}>
<App />
</RMWCProvider>,
document.getElementById('root')
);
// 4) Now anywhere in your app that an Icon instance is used, it will be
// delegated to your handler and render your custom component
import { TextFieldIcon } from '@rmwc/textfield';
<TextFieldIcon icon="search" />
`}),r.jsx(tt,{src:UJ,components:[{displayName:"Icon",component:$e}]})]})}
|
Set the option globally throug RMWCProvider
Glyphicons <span class="glyphicons glyphicons-heart"></span>
|
HJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-VbmLhRNC.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-VbmLhRNC.js
|
MIT
|
function hee(){return r.jsxs(Je,{title:"Menus",lead:"Menus display a list of choices on a transient sheet of material.",module:"@rmwc/menu",styles:["@material/menu/dist/mdc.menu.css","@material/menu-surface/dist/mdc.menu-surface.css","@material/ripple/dist/mdc.ripple.css","@material/list/dist/mdc.list.css","@rmwc/icon/icon.css"],docsLink:"https://material.io/develop/web/components/menus/",examples:pee,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can compose a menu with the given components, and manually manage the open state. `Menu` expects MenuItems as children while `MenuSurface` is a generic container which can have anything as a child."}),r.jsx(j,{children:function(){const[t,n]=G.useState(!1);return r.jsxs(is,{children:[r.jsxs(Mr,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[r.jsx(Kn,{children:"Cookies"}),r.jsx(Kn,{children:"Pizza"}),r.jsx(di,{}),r.jsx(Kn,{children:"Icecream"})]}),r.jsx(ve,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),r.jsx(j,{children:function(){const[t,n]=G.useState(!1);return r.jsxs(is,{children:[r.jsx(Nr,{open:t,onClose:a=>n(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})}),r.jsx(ve,{raised:!0,onClick:a=>n(!t),children:"Menu Surface"})]})}}),r.jsx(j,{children:function(){const[t,n]=G.useState(!1);return r.jsxs(is,{children:[r.jsx(Nr,{open:t,onClose:()=>n(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Menu"})}),r.jsx(ft,{icon:"menu",onClick:()=>n(!t)})]})}}),r.jsx(j,{children:function(){const[t,n]=G.useState(!1);return r.jsxs(is,{children:[r.jsxs(Mr,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[r.jsx(Kn,{children:"Item One"}),r.jsx(Kn,{disabled:!0,children:"Item Two (disabled)"}),r.jsx(Kn,{children:"Item Three"})]}),r.jsx(ve,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),r.jsx(fe,{children:"Simplified usage"}),r.jsx(ce,{children:"RMWC provides a convenience `SimpleMenu` component that takes a handle as a prop, and manages the open state for you."}),r.jsx(j,{children:r.jsxs(um,{handle:r.jsx(ve,{children:"Simple Menu"}),children:[r.jsx(Kn,{children:"Cookies"}),r.jsx(Kn,{children:"Pizza"}),r.jsx(Kn,{children:"Icecream"})]})}),r.jsx(j,{children:r.jsx(H1,{handle:r.jsx(ve,{children:"Simple Menu Surface"}),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})})}),r.jsx(fe,{children:"Anchoring"}),r.jsx(ce,{children:"By default, Menus will attempt to automatically position themselves, but this behavior can be overridden by setting the `anchorCorner` prop."}),r.jsx(j,{children:function(){const[t,n]=G.useState("topLeft");return r.jsxs(r.Fragment,{children:[r.jsxs(is,{children:[r.jsx(Nr,{anchorCorner:t,open:!0,children:r.jsxs("div",{style:{padding:"1rem",width:"8rem"},children:["anchorCorner: ",t]})}),r.jsx(ve,{raised:!0,label:"Anchored Menu"})]}),r.jsx(Ht,{value:t,label:"anchorCorner",onChange:a=>n(a.currentTarget.value),options:["topLeft","topRight","bottomLeft","bottomRight","topStart","topEnd","bottomStart","bottomEnd"]})]})}}),r.jsx(fe,{children:"Rendering through Portals"}),r.jsx(ce,{children:"Occasionally, you may find your menu being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),r.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),r.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a menu being cut off due to `overflow: hidden`."}),r.jsx(j,{children:function(){const[t,n]=G.useState(!0),[a,s]=G.useState(!1),i=["Cookies","Pizza","Icecream"];return r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{marginBottom:"10rem",height:"3.5rem",overflow:"hidden"},children:r.jsxs(is,{children:[r.jsx(ve,{raised:!0,onClick:()=>s(!a),children:"Open Menu"}),r.jsx(Mr,{open:a,onClose:()=>s(!1),renderToPortal:t,children:i.map(o=>r.jsx(Kn,{children:o},o))})]})}),r.jsx(_n,{checked:t,onChange:o=>n(o.currentTarget.checked),label:"renderToPortal"})]})}}),r.jsx(tt,{src:mee,components:[{displayName:"Menu",component:Mr},{displayName:"MenuItem",component:Kn},{displayName:"MenuSurface",component:Nr},{displayName:"MenuSurfaceAnchor",component:is},{displayName:"SimpleMenu",component:um},{displayName:"SimpleMenuSurface",component:H1}]})]})}
|
The handle can be any component you want
|
hee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-VbmLhRNC.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-VbmLhRNC.js
|
MIT
|
function xee(){return r.jsxs(Je,{title:"Provider",lead:"A component that provides global configuration for RMWC.",module:"@rmwc/provider",styles:[],examples:bee,children:[r.jsx(ce,{children:"You can wrap your top level App component with RMWC provider to set global configuration options. Just pass the options in as props."}),r.jsx(j,{codeOnly:!0,children:`
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
// This example disables ripples globally by default
ReactDOM.render(
<RMWCProvider
// Globally disable ripples
ripple={false}
// Global options for icons
// Takes the same options as the icon component
icon={{
basename: 'material-icons'
}}
// Global options for typography
// allows mapping of a defaultTag or specific classes
// See the Typography docs for more info
typography={{
defaultTag: 'div',
headline1: 'h1'
}}
// Global options for tooltips
// Takes most of the options for tooltips
// See the Tooltip docs for more info
tooltip={{
align: 'right'
}}
>
<App />
</RMWCProvider>,
document.getElementById('root'),
);
`}),r.jsx(j,{label:"With ripple false",children:r.jsx(mi,{ripple:!1,children:r.jsx(ve,{children:"Click me"})})}),r.jsx(j,{label:"With ripple true",children:r.jsx(mi,{ripple:!0,children:r.jsx(ve,{children:"Click me"})})}),r.jsx(tt,{src:yee,components:[{displayName:"RMWCProvider",component:mi}]})]})}
|
The handle can be any component you want
|
xee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-VbmLhRNC.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-VbmLhRNC.js
|
MIT
|
function Yee(){return r.jsxs(Je,{title:"Snackbars",lead:"Snackbars provide brief feedback about an operation through a message at the bottom of the screen.",module:"@rmwc/snackbar",styles:["@material/snackbar/dist/mdc.snackbar.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/snackbars/",examples:Vee,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can render a snackbar in your UI and control its open state."}),r.jsx(j,{label:"Default",children:function(){const[t,n]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,action:r.jsx(Go,{label:"Dismiss",onClick:()=>console.log("Click Me")})}),r.jsx(ve,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),r.jsx(j,{label:"Start Aligned",children:function(){const[t,n]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{open:t,onClose:a=>n(!1),message:"Start aligned, open until dismissed",stacked:!0,dismissesOnAction:!0,action:[r.jsx(Go,{label:"Yeah!"}),r.jsx(Go,{label:"No..."})],leading:!0,timeout:-1}),r.jsx(ve,{raised:!0,label:"Show start-aligned",onClick:a=>n(!t)})]})}}),r.jsx(j,{label:"With dismiss icon",children:function(){const[t,n]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,dismissIcon:"close",timeout:-1}),r.jsx(ve,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),r.jsx(fe,{children:"Usage with SnackbarQueue"}),r.jsx(ce,{children:"While rendering the Snackbar inline works for simple cases, you'll likely have a notification system, or want to send notifications from anywhere in your app. The `SnackbarQueue` exists as a convenient interface for handling these cases and rendering the snackbar messages for you. If you've used the `DialogQueue`, the `SnackbarQueue` is very similar."}),r.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `messages` to the `SnackbarQueue` component, and then use the `notify` function to send notifications."}),r.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createSnackbarQueue } from '@rmwc/snackbar';
export const queue = createSnackbarQueue();
`}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the SnackbarQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<SnackbarQueue
messages={queue.messages}
// You can also pass default options to pass to your notifications
// ie, make them all leading, stacked, etc
leading
stacked
/>
</div>
)
}
`}),r.jsx(ce,{children:"The `notify` function was designed to mimic the the built-in browser Notifications api and can accept most of the relevant options (icon, image, title, body, actions, ,etc). It also can accept any of the Snackbar props. Just import your queue, and call the notify method."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
// Simple example
queue.notify({
title: 'Hi there'
});
// With some features
queue.notify({
title: <b>Warning</b>,
body: 'You have selected pizza instead icecream!',
icon: 'warning',
actions: [
{
// NotificationAction api format
title: 'Fix It!',
icon: 'close',
action: 'fixit' // action will be available as evt.detail.reason in the onClose event
},
{
// OR SnackbarActionProps format
label: 'Continue...',
icon: 'check',
onClick: () => {}
},
]
});
`}),r.jsx(j,{label:"Inline Example",children:()=>{const{messages:e,notify:t}=bL();function n(){return r.jsxs("div",{children:[r.jsx(ve,{label:"Notify",onClick:()=>t({title:r.jsx("b",{children:"Success"}),body:"You have selected pizza!",dismissesOnAction:!0,icon:"check",actions:[{title:"Dismiss"}]})}),r.jsx(gL,{messages:e})]})}return r.jsx(n,{})}}),r.jsx(tt,{src:Kee,components:[{displayName:"Snackbar",component:Wo},{displayName:"SnackbarAction",component:Go}]})]})}
|
Any additional items will be passed to the
child ListItem as props
|
Yee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-VbmLhRNC.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-VbmLhRNC.js
|
MIT
|
function HZ(){return r.jsxs(et,{title:"Dialogs",lead:"Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.",module:"@rmwc/dialog",styles:["@material/dialog/dist/mdc.dialog.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/dialogs/",examples:FZ,children:[r.jsx(fe,{children:"Standard Usage"}),r.jsx(j,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(vm,{open:t,onClose:a=>{console.log(a.detail.action),n(!1)},onClosed:a=>console.log(a.detail.action),children:[r.jsx(xm,{children:"Dialog Title"}),r.jsx(km,{children:"This is a standard dialog."}),r.jsxs(wm,{children:[r.jsx(dc,{action:"close",children:"Cancel"}),r.jsx(dc,{action:"accept",isDefaultAction:!0,children:"Sweet!"})]})]}),r.jsx(ye,{raised:!0,onClick:()=>n(!0),children:"Open standard Dialog"})]})}}),r.jsx(fe,{children:"Simplified Usage"}),r.jsx(ce,{children:"Material Dialogs are a complex component. RMWC contains an additional `SimpleDialog` component for ease of use that internally contains the default structure already built out. Illustrated below is both the standard and simple dialog usage."}),r.jsx(j,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Nu,{title:"This is a simple dialog",body:"You can pass the body prop or children.",open:t,onClose:a=>{console.log(a.detail.action),n(!1)}}),r.jsx(ye,{raised:!0,onClick:()=>n(!0),children:"Open Simple Dialog"})]})}}),r.jsx(fe,{children:"Usage with DialogQueue"}),r.jsx(ce,{children:"Some dialog interactions are complex, but a lot of the time you just need a simple alert or confirm dialog. `DialogQueue` allows you to open dialogs from anywhere in your app and emulates the browsers built in `alert`, `confirm` and `prompt` dialogs. If you've used the `SnackbarQueue`, the `DialogQueue` is very similar."}),r.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `dialogs` to the `DialogQueue`component, and then use the `alert`, `prompt` or `confirm` api to open dialogs."}),r.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createDialogQueue } from '@rmwc/dialog';
export const queue = createDialogQueue();
`}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the DialogQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<DialogQueue
dialogs={queue.dialogs}
// You can also pass default options to pass to your dialogs
// ie, prevent all dialogs from dismissing from a click on the background scrim
preventOutsideDismiss
/>
</div>
)
}
`}),r.jsx(ce,{children:"The `alert`, `confirm`, and `prompt` functions were designed to mimic the the built-in browser methods with a couple of small difference. First, they all return a promise. The promise will always resolve successfully with the response indicating the appropriate action. `alert` the response will be `accept` for clicking the ok button, or `close`. `confirm` will resolve `true` or `false`, and `prompt` will resolve with the value entered into the input, or `null` if the closed the dialog. Second, all methods the methods accept any valid prop for `SimpleDialog`."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
queue.alert({
title: 'Hi there',
body: 'Whats going on?'
});
queue.confirm({
title: <b>Are you positive?</b>,
body: 'You have selected pizza instead icecream!',
acceptLabel: 'CONFIRM'
});
queue.prompt({
title: 'Whats your name?',
body: 'Anything will do',
acceptLabel: 'Submit',
cancelLabel: 'Skip',
// For prompts only, you can pass props to the input
inputProps: {
outlined: true
}
});
`}),r.jsx(j,{label:"Inline Example",children:()=>{const{dialogs:e,alert:t,confirm:n,prompt:a}=JL();function s(){const[i,o]=q.useState("____________"),l=()=>t({title:"Hello!"}).then(p=>o(p)),u=()=>n({}).then(p=>o(p)),d=()=>a({inputProps:{outlined:!0}}).then(p=>o(p));return r.jsxs("div",{children:[r.jsx(ye,{label:"Alert",onClick:l}),r.jsx(ye,{label:"Confirm",onClick:u}),r.jsx(ye,{label:"Prompt",onClick:d}),r.jsx(ye,{label:"In Sequence",onClick:()=>{l(),u(),d()}}),r.jsxs("p",{children:["Response: ",r.jsx("b",{children:String(i)})]}),r.jsx(ZL,{dialogs:e})]})}return r.jsx(s,{})}}),r.jsx(fe,{children:"Rendering through Portals"}),r.jsx(ce,{children:"Occasionally, you may find your dialog being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),r.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),r.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a dialog being cut off due to `overflow: hidden`."}),r.jsx(j,{children:function(){const[t,n]=q.useState(!0),[a,s]=q.useState(!1);return r.jsxs("div",{id:"dialog-portal-example",style:{transform:"translateZ(0)",height:"20rem",overflow:"hidden"},children:[r.jsx(Nu,{title:`This is a ${t?"working!":"broken :/"}`,renderToPortal:t,body:"Use `renderToPortal` to get around `overflow:hidden` and layout issues.",open:a,onClose:i=>{console.log(i.detail.action),s(!1)}}),r.jsx(ye,{raised:!0,onClick:()=>{n(!1),s(!0)},children:"Open Broken :/"}),r.jsx(ye,{raised:!0,onClick:()=>{n(!0),s(!0)},children:"Open in Portal"})]})}}),r.jsx(nt,{src:UZ,components:[{displayName:"Dialog",component:vm},{displayName:"DialogTitle",component:xm},{displayName:"DialogContent",component:km},{displayName:"DialogActions",component:wm},{displayName:"DialogButton",component:dc},{displayName:"SimpleDialog",component:Nu}]})]})}
|
Wrapping a button in TouchTargetWrapper will automatically set its \`touch\` prop to true.
|
HZ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-YsWvJUJf.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-YsWvJUJf.js
|
MIT
|
function kJ(){return r.jsxs(et,{title:"Icons",lead:"Material icons use geometric shapes to visually represent core ideas, capabilities, or topics.",module:"@rmwc/icon",styles:["@rmwc/icon/icon.css"],docsLink:"https://material.io/icons",examples:yJ,children:[r.jsx(fe,{children:"Setup"}),r.jsx(ce,{children:"Icons are not part of the official material-components-web spec, but they are referenced many times in the documentation. RMWC provides a declarative way to use icons. Note that RMWC does not ship with any icons of its own. Make sure you include an icon set! You can use any one you want, but Google's Material Icons are available through open source. Follow Google's developer guide to get them setup with your app. https://google.github.io/material-design-icons/"}),r.jsx(ce,{children:"There are lots of different strategies for implementing icons on the web, and the Icon component is flexible for most of them. Use ligatures, classNames, inline SVGs, HTML, or URLs to get icons into your app. The default strategy is 'ligature' which works with the material.io font icon set."}),r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"The Icon component, (really the icon prop itself) can accept a variety of formats. Anywhere you see a component prop like `icon` or `trailingIcon` will inherit the same behavior."}),r.jsx(j,{label:"String",children:r.jsx(qe,{icon:"favorite"})}),r.jsx(j,{label:"Child Component",children:r.jsx(qe,{icon:r.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})})}),r.jsx(j,{label:"Passing Options",children:r.jsxs(r.Fragment,{children:[r.jsx(qe,{icon:{icon:"star",strategy:"ligature"}}),r.jsx(ye,{label:"Hello!",icon:{icon:"add",onMouseOver:()=>console.log("OVER")}})]})}),r.jsx(fe,{children:"Icon Sizing"}),r.jsx(ce,{children:"The Material spec details multiple sizes for icons. The Icon component doesn't assign a size by default, but these are available to you to force a size. Please note, this will only work if you've included the RMWC icon css file."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx(qe,{icon:{icon:"favorite",size:"xsmall"}}),r.jsx(qe,{icon:{icon:"favorite",size:"small"}}),r.jsx(qe,{icon:{icon:"favorite",size:"medium"}}),r.jsx(qe,{icon:{icon:"favorite",size:"large"}}),r.jsx(qe,{icon:{icon:"favorite",size:"xlarge"}})]})}),r.jsx(fe,{children:"Ligatures"}),r.jsx(ce,{children:"This is for icon fonts that support ligatures like material-icons. This is the default strategy if nothing is set and doesn't require any additional setup if you are using material-icons."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx(qe,{icon:"favorite"}),r.jsx(qe,{icon:"favorite_outline"}),r.jsx(qe,{icon:{icon:"star",strategy:"ligature"}})]})}),r.jsx(fe,{children:"URLs"}),r.jsx(ce,{children:"This is for icons that are accessible via HTTP(S) and will be loaded directly into an `img` tag. This can be auto-detected for things that look like urls. The image will be set as a backgroundImage of the icon. Make sure you impor the RMWC icon css file for this to work properly."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx(qe,{icon:"images/icons/twitter.png"}),r.jsx(qe,{icon:{icon:"images/icons/twitter.png",strategy:"url"}})]})}),r.jsx(fe,{children:"Components / Inline SVGs"}),r.jsx(ce,{children:"This will render a child component inside of the icon. This is useful for all sorts of customization and for rendering inline SVGs. The following example shows rendering an SVG, as well as an arbitrary `div`."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx(qe,{icon:r.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})}),r.jsx(qe,{icon:{strategy:"component",icon:r.jsx("svg",{style:{width:"24px",height:"24px"},viewBox:"0 0 24 24",children:r.jsx("path",{fill:"#4285F4",d:"M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z"})})}})]})}),r.jsx(fe,{children:"Classnames"}),r.jsx(ce,{children:"Some font icon sets like Ion Icons and Glyph Icons render based on a className that is set. RMWC docs doesn't include extra icon fonts so there is no example to render, but the below code should give you an approximation."}),r.jsx(ce,{children:"**THIS CANNOT BE AUTO DETECTED**. You'll have to explicitly set the strategy directly on the Icon or specify it globally via the RMWCProvider."}),r.jsx(j,{codeOnly:!0,children:r.jsxs(r.Fragment,{children:[r.jsx(qe,{icon:{icon:"star",strategy:"className",basename:"icon",prefix:"ion-"}}),r.jsx(ui,{icon:{strategy:"className",basename:"glyphicons",prefix:"glyphicons-"},children:r.jsx(qe,{icon:"heart"})})]})}),r.jsx(fe,{children:"Custom Rendering"}),r.jsx(ce,{children:"Sometimes, you just need to do your own thing. Maybe you have a legacy project that already has icons and you want to incorporate them with RMWC. If none of the other strategies are what you need, then you can hijack the whole thing and delegate it to your own render function."}),r.jsx(j,{label:"Simple Example",children:r.jsx(qe,{icon:{icon:"favorite",strategy:"custom",render:({content:e})=>r.jsxs("div",{children:["Hello + ",e]})}})}),r.jsx(ce,{children:"A more relevant example involves an app that has a custom / existing icon component. There are a litany of reasons why your app might need one, but if you've found this section of the docs you likely know what problem you need to solve."}),r.jsx(j,{codeOnly:!0,children:`
// 1) Your app has an icon component you use
import { MyIconComponent } from '@rmwc/icon';
<MyIconComponent name="search" />
// 2) Now you are using RMWC, lots of components are instances of Icons
// You need to be able to delegate the handling of an icon prop to your own component
import { TextField } from '@rmwc/textField';
import { Chip } from '@rmwc/chip';
<TextField icon="favorite" />
<Chip icon="favorite" />
// 3) Instead, you should set the custom strategy to be your default
// and add your own handling with RMWCProvider
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
import { MyIconComponent } from '@rmwc/icon';
const iconRenderHandler = ({ content, className, ...rest }) => {
// content is whatever was passed to the icon prop
// className is the fully processed className taking into account the basename and prefix defaults
// it's important to include this because MDC often has classes like text-field-icon directly
// on the component for alignment
// rest is just any other props
return <MyIconComponent className={className} name={content} {...rest} />
};
ReactDOM.render(
<RMWCProvider icon={{strategy: 'custom', render: iconRenderHandler}}>
<App />
</RMWCProvider>,
document.getElementById('root')
);
// 4) Now anywhere in your app that an Icon instance is used, it will be
// delegated to your handler and render your custom component
import { TextFieldIcon } from '@rmwc/textfield';
<TextFieldIcon icon="search" />
`}),r.jsx(nt,{src:xJ,components:[{displayName:"Icon",component:qe}]})]})}
|
Set the option globally throug RMWCProvider
Glyphicons <span class="glyphicons glyphicons-heart"></span>
|
kJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-YsWvJUJf.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-YsWvJUJf.js
|
MIT
|
function YJ(){return r.jsxs(et,{title:"Menus",lead:"Menus display a list of choices on a transient sheet of material.",module:"@rmwc/menu",styles:["@material/menu/dist/mdc.menu.css","@material/menu-surface/dist/mdc.menu-surface.css","@material/ripple/dist/mdc.ripple.css","@material/list/dist/mdc.list.css","@rmwc/icon/icon.css"],docsLink:"https://material.io/develop/web/components/menus/",examples:VJ,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can compose a menu with the given components, and manually manage the open state. `Menu` expects MenuItems as children while `MenuSurface` is a generic container which can have anything as a child."}),r.jsx(j,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ts,{children:[r.jsxs(Ir,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[r.jsx(Wn,{children:"Cookies"}),r.jsx(Wn,{children:"Pizza"}),r.jsx(oi,{}),r.jsx(Wn,{children:"Icecream"})]}),r.jsx(ye,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),r.jsx(j,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ts,{children:[r.jsx(Ar,{open:t,onClose:a=>n(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})}),r.jsx(ye,{raised:!0,onClick:a=>n(!t),children:"Menu Surface"})]})}}),r.jsx(j,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ts,{children:[r.jsx(Ar,{open:t,onClose:()=>n(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Menu"})}),r.jsx(dt,{icon:"menu",onClick:()=>n(!t)})]})}}),r.jsx(j,{children:function(){const[t,n]=q.useState(!1);return r.jsxs(ts,{children:[r.jsxs(Ir,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[r.jsx(Wn,{children:"Item One"}),r.jsx(Wn,{disabled:!0,children:"Item Two (disabled)"}),r.jsx(Wn,{children:"Item Three"})]}),r.jsx(ye,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),r.jsx(fe,{children:"Simplified usage"}),r.jsx(ce,{children:"RMWC provides a convenience `SimpleMenu` component that takes a handle as a prop, and manages the open state for you."}),r.jsx(j,{children:r.jsxs(tm,{handle:r.jsx(ye,{children:"Simple Menu"}),children:[r.jsx(Wn,{children:"Cookies"}),r.jsx(Wn,{children:"Pizza"}),r.jsx(Wn,{children:"Icecream"})]})}),r.jsx(j,{children:r.jsx(D1,{handle:r.jsx(ye,{children:"Simple Menu Surface"}),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})})}),r.jsx(fe,{children:"Anchoring"}),r.jsx(ce,{children:"By default, Menus will attempt to automatically position themselves, but this behavior can be overridden by setting the `anchorCorner` prop."}),r.jsx(j,{children:function(){const[t,n]=q.useState("topLeft");return r.jsxs(r.Fragment,{children:[r.jsxs(ts,{children:[r.jsx(Ar,{anchorCorner:t,open:!0,children:r.jsxs("div",{style:{padding:"1rem",width:"8rem"},children:["anchorCorner: ",t]})}),r.jsx(ye,{raised:!0,label:"Anchored Menu"})]}),r.jsx(Ut,{value:t,label:"anchorCorner",onChange:a=>n(a.currentTarget.value),options:["topLeft","topRight","bottomLeft","bottomRight","topStart","topEnd","bottomStart","bottomEnd"]})]})}}),r.jsx(fe,{children:"Rendering through Portals"}),r.jsx(ce,{children:"Occasionally, you may find your menu being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),r.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),r.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a menu being cut off due to `overflow: hidden`."}),r.jsx(j,{children:function(){const[t,n]=q.useState(!0),[a,s]=q.useState(!1),i=["Cookies","Pizza","Icecream"];return r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{marginBottom:"10rem",height:"3.5rem",overflow:"hidden"},children:r.jsxs(ts,{children:[r.jsx(ye,{raised:!0,onClick:()=>s(!a),children:"Open Menu"}),r.jsx(Ir,{open:a,onClose:()=>s(!1),renderToPortal:t,children:i.map(o=>r.jsx(Wn,{children:o},o))})]})}),r.jsx(Dn,{checked:t,onChange:o=>n(o.currentTarget.checked),label:"renderToPortal"})]})}}),r.jsx(nt,{src:KJ,components:[{displayName:"Menu",component:Ir},{displayName:"MenuItem",component:Wn},{displayName:"MenuSurface",component:Ar},{displayName:"MenuSurfaceAnchor",component:ts},{displayName:"SimpleMenu",component:tm},{displayName:"SimpleMenuSurface",component:D1}]})]})}
|
The handle can be any component you want
|
YJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-YsWvJUJf.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-YsWvJUJf.js
|
MIT
|
function eee(){return r.jsxs(et,{title:"Provider",lead:"A component that provides global configuration for RMWC.",module:"@rmwc/provider",styles:[],examples:QJ,children:[r.jsx(ce,{children:"You can wrap your top level App component with RMWC provider to set global configuration options. Just pass the options in as props."}),r.jsx(j,{codeOnly:!0,children:`
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
// This example disables ripples globally by default
ReactDOM.render(
<RMWCProvider
// Globally disable ripples
ripple={false}
// Global options for icons
// Takes the same options as the icon component
icon={{
basename: 'material-icons'
}}
// Global options for typography
// allows mapping of a defaultTag or specific classes
// See the Typography docs for more info
typography={{
defaultTag: 'div',
headline1: 'h1'
}}
// Global options for tooltips
// Takes most of the options for tooltips
// See the Tooltip docs for more info
tooltip={{
align: 'right'
}}
>
<App />
</RMWCProvider>,
document.getElementById('root'),
);
`}),r.jsx(j,{label:"With ripple false",children:r.jsx(ui,{ripple:!1,children:r.jsx(ye,{children:"Click me"})})}),r.jsx(j,{label:"With ripple true",children:r.jsx(ui,{ripple:!0,children:r.jsx(ye,{children:"Click me"})})}),r.jsx(nt,{src:JJ,components:[{displayName:"RMWCProvider",component:ui}]})]})}
|
The handle can be any component you want
|
eee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-YsWvJUJf.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-YsWvJUJf.js
|
MIT
|
function Aee(){return r.jsxs(et,{title:"Snackbars",lead:"Snackbars provide brief feedback about an operation through a message at the bottom of the screen.",module:"@rmwc/snackbar",styles:["@material/snackbar/dist/mdc.snackbar.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/snackbars/",examples:Eee,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can render a snackbar in your UI and control its open state."}),r.jsx(j,{label:"Default",children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Fo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,action:r.jsx(Bo,{label:"Dismiss",onClick:()=>console.log("Click Me")})}),r.jsx(ye,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),r.jsx(j,{label:"Start Aligned",children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Fo,{open:t,onClose:a=>n(!1),message:"Start aligned, open until dismissed",stacked:!0,dismissesOnAction:!0,action:[r.jsx(Bo,{label:"Yeah!"}),r.jsx(Bo,{label:"No..."})],leading:!0,timeout:-1}),r.jsx(ye,{raised:!0,label:"Show start-aligned",onClick:a=>n(!t)})]})}}),r.jsx(j,{label:"With dismiss icon",children:function(){const[t,n]=q.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Fo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,dismissIcon:"close",timeout:-1}),r.jsx(ye,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),r.jsx(fe,{children:"Usage with SnackbarQueue"}),r.jsx(ce,{children:"While rendering the Snackbar inline works for simple cases, you'll likely have a notification system, or want to send notifications from anywhere in your app. The `SnackbarQueue` exists as a convenient interface for handling these cases and rendering the snackbar messages for you. If you've used the `DialogQueue`, the `SnackbarQueue` is very similar."}),r.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `messages` to the `SnackbarQueue` component, and then use the `notify` function to send notifications."}),r.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createSnackbarQueue } from '@rmwc/snackbar';
export const queue = createSnackbarQueue();
`}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the SnackbarQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<SnackbarQueue
messages={queue.messages}
// You can also pass default options to pass to your notifications
// ie, make them all leading, stacked, etc
leading
stacked
/>
</div>
)
}
`}),r.jsx(ce,{children:"The `notify` function was designed to mimic the the built-in browser Notifications api and can accept most of the relevant options (icon, image, title, body, actions, ,etc). It also can accept any of the Snackbar props. Just import your queue, and call the notify method."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
// Simple example
queue.notify({
title: 'Hi there'
});
// With some features
queue.notify({
title: <b>Warning</b>,
body: 'You have selected pizza instead icecream!',
icon: 'warning',
actions: [
{
// NotificationAction api format
title: 'Fix It!',
icon: 'close',
action: 'fixit' // action will be available as evt.detail.reason in the onClose event
},
{
// OR SnackbarActionProps format
label: 'Continue...',
icon: 'check',
onClick: () => {}
},
]
});
`}),r.jsx(j,{label:"Inline Example",children:()=>{const{messages:e,notify:t}=rD();function n(){return r.jsxs("div",{children:[r.jsx(ye,{label:"Notify",onClick:()=>t({title:r.jsx("b",{children:"Success"}),body:"You have selected pizza!",dismissesOnAction:!0,icon:"check",actions:[{title:"Dismiss"}]})}),r.jsx(iD,{messages:e})]})}return r.jsx(n,{})}}),r.jsx(nt,{src:Ree,components:[{displayName:"Snackbar",component:Fo},{displayName:"SnackbarAction",component:Bo}]})]})}
|
Any additional items will be passed to the
child ListItem as props
|
Aee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-YsWvJUJf.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-YsWvJUJf.js
|
MIT
|
function tJ(){return o.jsxs(Je,{title:"Dialogs",lead:"Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.",module:"@rmwc/dialog",styles:["@material/dialog/dist/mdc.dialog.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/dialogs/",examples:ZZ,children:[o.jsx(fe,{children:"Standard Usage"}),o.jsx(j,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(km,{open:t,onClose:a=>{console.log(a.detail.action),n(!1)},onClosed:a=>console.log(a.detail.action),children:[o.jsx(wm,{children:"Dialog Title"}),o.jsx(Pm,{children:"This is a standard dialog."}),o.jsxs(Em,{children:[o.jsx(fc,{action:"close",children:"Cancel"}),o.jsx(fc,{action:"accept",isDefaultAction:!0,children:"Sweet!"})]})]}),o.jsx(ve,{raised:!0,onClick:()=>n(!0),children:"Open standard Dialog"})]})}}),o.jsx(fe,{children:"Simplified Usage"}),o.jsx(ce,{children:"Material Dialogs are a complex component. RMWC contains an additional `SimpleDialog` component for ease of use that internally contains the default structure already built out. Illustrated below is both the standard and simple dialog usage."}),o.jsx(j,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Fu,{title:"This is a simple dialog",body:"You can pass the body prop or children.",open:t,onClose:a=>{console.log(a.detail.action),n(!1)}}),o.jsx(ve,{raised:!0,onClick:()=>n(!0),children:"Open Simple Dialog"})]})}}),o.jsx(fe,{children:"Usage with DialogQueue"}),o.jsx(ce,{children:"Some dialog interactions are complex, but a lot of the time you just need a simple alert or confirm dialog. `DialogQueue` allows you to open dialogs from anywhere in your app and emulates the browsers built in `alert`, `confirm` and `prompt` dialogs. If you've used the `SnackbarQueue`, the `DialogQueue` is very similar."}),o.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `dialogs` to the `DialogQueue`component, and then use the `alert`, `prompt` or `confirm` api to open dialogs."}),o.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createDialogQueue } from '@rmwc/dialog';
export const queue = createDialogQueue();
`}),o.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the DialogQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<DialogQueue
dialogs={queue.dialogs}
// You can also pass default options to pass to your dialogs
// ie, prevent all dialogs from dismissing from a click on the background scrim
preventOutsideDismiss
/>
</div>
)
}
`}),o.jsx(ce,{children:"The `alert`, `confirm`, and `prompt` functions were designed to mimic the the built-in browser methods with a couple of small difference. First, they all return a promise. The promise will always resolve successfully with the response indicating the appropriate action. `alert` the response will be `accept` for clicking the ok button, or `close`. `confirm` will resolve `true` or `false`, and `prompt` will resolve with the value entered into the input, or `null` if the closed the dialog. Second, all methods the methods accept any valid prop for `SimpleDialog`."}),o.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
queue.alert({
title: 'Hi there',
body: 'Whats going on?'
});
queue.confirm({
title: <b>Are you positive?</b>,
body: 'You have selected pizza instead icecream!',
acceptLabel: 'CONFIRM'
});
queue.prompt({
title: 'Whats your name?',
body: 'Anything will do',
acceptLabel: 'Submit',
cancelLabel: 'Skip',
// For prompts only, you can pass props to the input
inputProps: {
outlined: true
}
});
`}),o.jsx(j,{label:"Inline Example",children:()=>{const{dialogs:e,alert:t,confirm:n,prompt:a}=aD();function s(){const[i,r]=G.useState("____________"),l=()=>t({title:"Hello!"}).then(d=>r(d)),c=()=>n({}).then(d=>r(d)),p=()=>a({inputProps:{outlined:!0}}).then(d=>r(d));return o.jsxs("div",{children:[o.jsx(ve,{label:"Alert",onClick:l}),o.jsx(ve,{label:"Confirm",onClick:c}),o.jsx(ve,{label:"Prompt",onClick:p}),o.jsx(ve,{label:"In Sequence",onClick:()=>{l(),c(),p()}}),o.jsxs("p",{children:["Response: ",o.jsx("b",{children:String(i)})]}),o.jsx(nD,{dialogs:e})]})}return o.jsx(s,{})}}),o.jsx(fe,{children:"Rendering through Portals"}),o.jsx(ce,{children:"Occasionally, you may find your dialog being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),o.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),o.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),o.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a dialog being cut off due to `overflow: hidden`."}),o.jsx(j,{children:function(){const[t,n]=G.useState(!0),[a,s]=G.useState(!1);return o.jsxs("div",{id:"dialog-portal-example",style:{transform:"translateZ(0)",height:"20rem",overflow:"hidden"},children:[o.jsx(Fu,{title:`This is a ${t?"working!":"broken :/"}`,renderToPortal:t,body:"Use `renderToPortal` to get around `overflow:hidden` and layout issues.",open:a,onClose:i=>{console.log(i.detail.action),s(!1)}}),o.jsx(ve,{raised:!0,onClick:()=>{n(!1),s(!0)},children:"Open Broken :/"}),o.jsx(ve,{raised:!0,onClick:()=>{n(!0),s(!0)},children:"Open in Portal"})]})}}),o.jsx(tt,{src:eJ,components:[{displayName:"Dialog",component:km},{displayName:"DialogTitle",component:wm},{displayName:"DialogContent",component:Pm},{displayName:"DialogActions",component:Em},{displayName:"DialogButton",component:fc},{displayName:"SimpleDialog",component:Fu}]})]})}
|
Wrapping a button in TouchTargetWrapper will automatically set its \`touch\` prop to true.
|
tJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z-lyU3sM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z-lyU3sM.js
|
MIT
|
function NJ(){return o.jsxs(Je,{title:"Icons",lead:"Material icons use geometric shapes to visually represent core ideas, capabilities, or topics.",module:"@rmwc/icon",styles:["@rmwc/icon/icon.css"],docsLink:"https://material.io/icons",examples:DJ,children:[o.jsx(fe,{children:"Setup"}),o.jsx(ce,{children:"Icons are not part of the official material-components-web spec, but they are referenced many times in the documentation. RMWC provides a declarative way to use icons. Note that RMWC does not ship with any icons of its own. Make sure you include an icon set! You can use any one you want, but Google's Material Icons are available through open source. Follow Google's developer guide to get them setup with your app. https://google.github.io/material-design-icons/"}),o.jsx(ce,{children:"There are lots of different strategies for implementing icons on the web, and the Icon component is flexible for most of them. Use ligatures, classNames, inline SVGs, HTML, or URLs to get icons into your app. The default strategy is 'ligature' which works with the material.io font icon set."}),o.jsx(fe,{children:"Basic Usage"}),o.jsx(ce,{children:"The Icon component, (really the icon prop itself) can accept a variety of formats. Anywhere you see a component prop like `icon` or `trailingIcon` will inherit the same behavior."}),o.jsx(j,{label:"String",children:o.jsx($e,{icon:"favorite"})}),o.jsx(j,{label:"Child Component",children:o.jsx($e,{icon:o.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})})}),o.jsx(j,{label:"Passing Options",children:o.jsxs(o.Fragment,{children:[o.jsx($e,{icon:{icon:"star",strategy:"ligature"}}),o.jsx(ve,{label:"Hello!",icon:{icon:"add",onMouseOver:()=>console.log("OVER")}})]})}),o.jsx(fe,{children:"Icon Sizing"}),o.jsx(ce,{children:"The Material spec details multiple sizes for icons. The Icon component doesn't assign a size by default, but these are available to you to force a size. Please note, this will only work if you've included the RMWC icon css file."}),o.jsx(j,{children:o.jsxs(o.Fragment,{children:[o.jsx($e,{icon:{icon:"favorite",size:"xsmall"}}),o.jsx($e,{icon:{icon:"favorite",size:"small"}}),o.jsx($e,{icon:{icon:"favorite",size:"medium"}}),o.jsx($e,{icon:{icon:"favorite",size:"large"}}),o.jsx($e,{icon:{icon:"favorite",size:"xlarge"}})]})}),o.jsx(fe,{children:"Ligatures"}),o.jsx(ce,{children:"This is for icon fonts that support ligatures like material-icons. This is the default strategy if nothing is set and doesn't require any additional setup if you are using material-icons."}),o.jsx(j,{children:o.jsxs(o.Fragment,{children:[o.jsx($e,{icon:"favorite"}),o.jsx($e,{icon:"favorite_outline"}),o.jsx($e,{icon:{icon:"star",strategy:"ligature"}})]})}),o.jsx(fe,{children:"URLs"}),o.jsx(ce,{children:"This is for icons that are accessible via HTTP(S) and will be loaded directly into an `img` tag. This can be auto-detected for things that look like urls. The image will be set as a backgroundImage of the icon. Make sure you impor the RMWC icon css file for this to work properly."}),o.jsx(j,{children:o.jsxs(o.Fragment,{children:[o.jsx($e,{icon:"images/icons/twitter.png"}),o.jsx($e,{icon:{icon:"images/icons/twitter.png",strategy:"url"}})]})}),o.jsx(fe,{children:"Components / Inline SVGs"}),o.jsx(ce,{children:"This will render a child component inside of the icon. This is useful for all sorts of customization and for rendering inline SVGs. The following example shows rendering an SVG, as well as an arbitrary `div`."}),o.jsx(j,{children:o.jsxs(o.Fragment,{children:[o.jsx($e,{icon:o.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})}),o.jsx($e,{icon:{strategy:"component",icon:o.jsx("svg",{style:{width:"24px",height:"24px"},viewBox:"0 0 24 24",children:o.jsx("path",{fill:"#4285F4",d:"M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z"})})}})]})}),o.jsx(fe,{children:"Classnames"}),o.jsx(ce,{children:"Some font icon sets like Ion Icons and Glyph Icons render based on a className that is set. RMWC docs doesn't include extra icon fonts so there is no example to render, but the below code should give you an approximation."}),o.jsx(ce,{children:"**THIS CANNOT BE AUTO DETECTED**. You'll have to explicitly set the strategy directly on the Icon or specify it globally via the RMWCProvider."}),o.jsx(j,{codeOnly:!0,children:o.jsxs(o.Fragment,{children:[o.jsx($e,{icon:{icon:"star",strategy:"className",basename:"icon",prefix:"ion-"}}),o.jsx(pi,{icon:{strategy:"className",basename:"glyphicons",prefix:"glyphicons-"},children:o.jsx($e,{icon:"heart"})})]})}),o.jsx(fe,{children:"Custom Rendering"}),o.jsx(ce,{children:"Sometimes, you just need to do your own thing. Maybe you have a legacy project that already has icons and you want to incorporate them with RMWC. If none of the other strategies are what you need, then you can hijack the whole thing and delegate it to your own render function."}),o.jsx(j,{label:"Simple Example",children:o.jsx($e,{icon:{icon:"favorite",strategy:"custom",render:({content:e})=>o.jsxs("div",{children:["Hello + ",e]})}})}),o.jsx(ce,{children:"A more relevant example involves an app that has a custom / existing icon component. There are a litany of reasons why your app might need one, but if you've found this section of the docs you likely know what problem you need to solve."}),o.jsx(j,{codeOnly:!0,children:`
// 1) Your app has an icon component you use
import { MyIconComponent } from '@rmwc/icon';
<MyIconComponent name="search" />
// 2) Now you are using RMWC, lots of components are instances of Icons
// You need to be able to delegate the handling of an icon prop to your own component
import { TextField } from '@rmwc/textField';
import { Chip } from '@rmwc/chip';
<TextField icon="favorite" />
<Chip icon="favorite" />
// 3) Instead, you should set the custom strategy to be your default
// and add your own handling with RMWCProvider
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
import { MyIconComponent } from '@rmwc/icon';
const iconRenderHandler = ({ content, className, ...rest }) => {
// content is whatever was passed to the icon prop
// className is the fully processed className taking into account the basename and prefix defaults
// it's important to include this because MDC often has classes like text-field-icon directly
// on the component for alignment
// rest is just any other props
return <MyIconComponent className={className} name={content} {...rest} />
};
ReactDOM.render(
<RMWCProvider icon={{strategy: 'custom', render: iconRenderHandler}}>
<App />
</RMWCProvider>,
document.getElementById('root')
);
// 4) Now anywhere in your app that an Icon instance is used, it will be
// delegated to your handler and render your custom component
import { TextFieldIcon } from '@rmwc/textfield';
<TextFieldIcon icon="search" />
`}),o.jsx(tt,{src:_J,components:[{displayName:"Icon",component:$e}]})]})}
|
Set the option globally throug RMWCProvider
Glyphicons <span class="glyphicons glyphicons-heart"></span>
|
NJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z-lyU3sM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z-lyU3sM.js
|
MIT
|
function cee(){return o.jsxs(Je,{title:"Menus",lead:"Menus display a list of choices on a transient sheet of material.",module:"@rmwc/menu",styles:["@material/menu/dist/mdc.menu.css","@material/menu-surface/dist/mdc.menu-surface.css","@material/ripple/dist/mdc.ripple.css","@material/list/dist/mdc.list.css","@rmwc/icon/icon.css"],docsLink:"https://material.io/develop/web/components/menus/",examples:ree,children:[o.jsx(fe,{children:"Basic Usage"}),o.jsx(ce,{children:"You can compose a menu with the given components, and manually manage the open state. `Menu` expects MenuItems as children while `MenuSurface` is a generic container which can have anything as a child."}),o.jsx(j,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(ss,{children:[o.jsxs(Or,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[o.jsx(Vn,{children:"Cookies"}),o.jsx(Vn,{children:"Pizza"}),o.jsx(li,{}),o.jsx(Vn,{children:"Icecream"})]}),o.jsx(ve,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),o.jsx(j,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(ss,{children:[o.jsx(Dr,{open:t,onClose:a=>n(!1),children:o.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})}),o.jsx(ve,{raised:!0,onClick:a=>n(!t),children:"Menu Surface"})]})}}),o.jsx(j,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(ss,{children:[o.jsx(Dr,{open:t,onClose:()=>n(!1),children:o.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Menu"})}),o.jsx(dt,{icon:"menu",onClick:()=>n(!t)})]})}}),o.jsx(j,{children:function(){const[t,n]=G.useState(!1);return o.jsxs(ss,{children:[o.jsxs(Or,{open:t,onSelect:a=>console.log(a.detail.index),onClose:()=>n(!1),children:[o.jsx(Vn,{children:"Item One"}),o.jsx(Vn,{disabled:!0,children:"Item Two (disabled)"}),o.jsx(Vn,{children:"Item Three"})]}),o.jsx(ve,{raised:!0,onClick:()=>n(!t),children:"Menu"})]})}}),o.jsx(fe,{children:"Simplified usage"}),o.jsx(ce,{children:"RMWC provides a convenience `SimpleMenu` component that takes a handle as a prop, and manages the open state for you."}),o.jsx(j,{children:o.jsxs(am,{handle:o.jsx(ve,{children:"Simple Menu"}),children:[o.jsx(Vn,{children:"Cookies"}),o.jsx(Vn,{children:"Pizza"}),o.jsx(Vn,{children:"Icecream"})]})}),o.jsx(j,{children:o.jsx(_v,{handle:o.jsx(ve,{children:"Simple Menu Surface"}),children:o.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})})}),o.jsx(fe,{children:"Anchoring"}),o.jsx(ce,{children:"By default, Menus will attempt to automatically position themselves, but this behavior can be overridden by setting the `anchorCorner` prop."}),o.jsx(j,{children:function(){const[t,n]=G.useState("topLeft");return o.jsxs(o.Fragment,{children:[o.jsxs(ss,{children:[o.jsx(Dr,{anchorCorner:t,open:!0,children:o.jsxs("div",{style:{padding:"1rem",width:"8rem"},children:["anchorCorner: ",t]})}),o.jsx(ve,{raised:!0,label:"Anchored Menu"})]}),o.jsx(Ut,{value:t,label:"anchorCorner",onChange:a=>n(a.currentTarget.value),options:["topLeft","topRight","bottomLeft","bottomRight","topStart","topEnd","bottomStart","bottomEnd"]})]})}}),o.jsx(fe,{children:"Rendering through Portals"}),o.jsx(ce,{children:"Occasionally, you may find your menu being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),o.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),o.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),o.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a menu being cut off due to `overflow: hidden`."}),o.jsx(j,{children:function(){const[t,n]=G.useState(!0),[a,s]=G.useState(!1),i=["Cookies","Pizza","Icecream"];return o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{marginBottom:"10rem",height:"3.5rem",overflow:"hidden"},children:o.jsxs(ss,{children:[o.jsx(ve,{raised:!0,onClick:()=>s(!a),children:"Open Menu"}),o.jsx(Or,{open:a,onClose:()=>s(!1),renderToPortal:t,children:i.map(r=>o.jsx(Vn,{children:r},r))})]})}),o.jsx(Dn,{checked:t,onChange:r=>n(r.currentTarget.checked),label:"renderToPortal"})]})}}),o.jsx(tt,{src:lee,components:[{displayName:"Menu",component:Or},{displayName:"MenuItem",component:Vn},{displayName:"MenuSurface",component:Dr},{displayName:"MenuSurfaceAnchor",component:ss},{displayName:"SimpleMenu",component:am},{displayName:"SimpleMenuSurface",component:_v}]})]})}
|
The handle can be any component you want
|
cee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z-lyU3sM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z-lyU3sM.js
|
MIT
|
function mee(){return o.jsxs(Je,{title:"Provider",lead:"A component that provides global configuration for RMWC.",module:"@rmwc/provider",styles:[],examples:pee,children:[o.jsx(ce,{children:"You can wrap your top level App component with RMWC provider to set global configuration options. Just pass the options in as props."}),o.jsx(j,{codeOnly:!0,children:`
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
// This example disables ripples globally by default
ReactDOM.render(
<RMWCProvider
// Globally disable ripples
ripple={false}
// Global options for icons
// Takes the same options as the icon component
icon={{
basename: 'material-icons'
}}
// Global options for typography
// allows mapping of a defaultTag or specific classes
// See the Typography docs for more info
typography={{
defaultTag: 'div',
headline1: 'h1'
}}
// Global options for tooltips
// Takes most of the options for tooltips
// See the Tooltip docs for more info
tooltip={{
align: 'right'
}}
>
<App />
</RMWCProvider>,
document.getElementById('root'),
);
`}),o.jsx(j,{label:"With ripple false",children:o.jsx(pi,{ripple:!1,children:o.jsx(ve,{children:"Click me"})})}),o.jsx(j,{label:"With ripple true",children:o.jsx(pi,{ripple:!0,children:o.jsx(ve,{children:"Click me"})})}),o.jsx(tt,{src:fee,components:[{displayName:"RMWCProvider",component:pi}]})]})}
|
The handle can be any component you want
|
mee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z-lyU3sM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z-lyU3sM.js
|
MIT
|
function $ee(){return o.jsxs(Je,{title:"Snackbars",lead:"Snackbars provide brief feedback about an operation through a message at the bottom of the screen.",module:"@rmwc/snackbar",styles:["@material/snackbar/dist/mdc.snackbar.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/snackbars/",examples:Uee,children:[o.jsx(fe,{children:"Basic Usage"}),o.jsx(ce,{children:"You can render a snackbar in your UI and control its open state."}),o.jsx(j,{label:"Default",children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Uo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,action:o.jsx(Ho,{label:"Dismiss",onClick:()=>console.log("Click Me")})}),o.jsx(ve,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),o.jsx(j,{label:"Start Aligned",children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Uo,{open:t,onClose:a=>n(!1),message:"Start aligned, open until dismissed",stacked:!0,dismissesOnAction:!0,action:[o.jsx(Ho,{label:"Yeah!"}),o.jsx(Ho,{label:"No..."})],leading:!0,timeout:-1}),o.jsx(ve,{raised:!0,label:"Show start-aligned",onClick:a=>n(!t)})]})}}),o.jsx(j,{label:"With dismiss icon",children:function(){const[t,n]=G.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx(Uo,{open:t,onClose:a=>n(!1),message:"This is a new message",dismissesOnAction:!0,dismissIcon:"close",timeout:-1}),o.jsx(ve,{raised:!0,label:"Show snackbar",onClick:a=>n(!t)})]})}}),o.jsx(fe,{children:"Usage with SnackbarQueue"}),o.jsx(ce,{children:"While rendering the Snackbar inline works for simple cases, you'll likely have a notification system, or want to send notifications from anywhere in your app. The `SnackbarQueue` exists as a convenient interface for handling these cases and rendering the snackbar messages for you. If you've used the `DialogQueue`, the `SnackbarQueue` is very similar."}),o.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `messages` to the `SnackbarQueue` component, and then use the `notify` function to send notifications."}),o.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createSnackbarQueue } from '@rmwc/snackbar';
export const queue = createSnackbarQueue();
`}),o.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the SnackbarQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<SnackbarQueue
messages={queue.messages}
// You can also pass default options to pass to your notifications
// ie, make them all leading, stacked, etc
leading
stacked
/>
</div>
)
}
`}),o.jsx(ce,{children:"The `notify` function was designed to mimic the the built-in browser Notifications api and can accept most of the relevant options (icon, image, title, body, actions, ,etc). It also can accept any of the Snackbar props. Just import your queue, and call the notify method."}),o.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
// Simple example
queue.notify({
title: 'Hi there'
});
// With some features
queue.notify({
title: <b>Warning</b>,
body: 'You have selected pizza instead icecream!',
icon: 'warning',
actions: [
{
// NotificationAction api format
title: 'Fix It!',
icon: 'close',
action: 'fixit' // action will be available as evt.detail.reason in the onClose event
},
{
// OR SnackbarActionProps format
label: 'Continue...',
icon: 'check',
onClick: () => {}
},
]
});
`}),o.jsx(j,{label:"Inline Example",children:()=>{const{messages:e,notify:t}=uD();function n(){return o.jsxs("div",{children:[o.jsx(ve,{label:"Notify",onClick:()=>t({title:o.jsx("b",{children:"Success"}),body:"You have selected pizza!",dismissesOnAction:!0,icon:"check",actions:[{title:"Dismiss"}]})}),o.jsx(cD,{messages:e})]})}return o.jsx(n,{})}}),o.jsx(tt,{src:zee,components:[{displayName:"Snackbar",component:Uo},{displayName:"SnackbarAction",component:Ho}]})]})}
|
Any additional items will be passed to the
child ListItem as props
|
$ee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z-lyU3sM.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z-lyU3sM.js
|
MIT
|
function oJ(){return r.jsxs(Je,{title:"Dialogs",lead:"Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.",module:"@rmwc/dialog",styles:["@material/dialog/dist/mdc.dialog.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/dialogs/",examples:sJ,children:[r.jsx(fe,{children:"Standard Usage"}),r.jsx(j,{children:function(){const[t,a]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(Rm,{open:t,onClose:n=>{console.log(n.detail.action),a(!1)},onClosed:n=>console.log(n.detail.action),children:[r.jsx(Am,{children:"Dialog Title"}),r.jsx(Im,{children:"This is a standard dialog."}),r.jsxs(Lm,{children:[r.jsx(xc,{action:"close",children:"Cancel"}),r.jsx(xc,{action:"accept",isDefaultAction:!0,children:"Sweet!"})]})]}),r.jsx(ve,{raised:!0,onClick:()=>a(!0),children:"Open standard Dialog"})]})}}),r.jsx(fe,{children:"Simplified Usage"}),r.jsx(ce,{children:"Material Dialogs are a complex component. RMWC contains an additional `SimpleDialog` component for ease of use that internally contains the default structure already built out. Illustrated below is both the standard and simple dialog usage."}),r.jsx(j,{children:function(){const[t,a]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Gu,{title:"This is a simple dialog",body:"You can pass the body prop or children.",open:t,onClose:n=>{console.log(n.detail.action),a(!1)}}),r.jsx(ve,{raised:!0,onClick:()=>a(!0),children:"Open Simple Dialog"})]})}}),r.jsx(fe,{children:"Usage with DialogQueue"}),r.jsx(ce,{children:"Some dialog interactions are complex, but a lot of the time you just need a simple alert or confirm dialog. `DialogQueue` allows you to open dialogs from anywhere in your app and emulates the browsers built in `alert`, `confirm` and `prompt` dialogs. If you've used the `SnackbarQueue`, the `DialogQueue` is very similar."}),r.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `dialogs` to the `DialogQueue`component, and then use the `alert`, `prompt` or `confirm` api to open dialogs."}),r.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createDialogQueue } from '@rmwc/dialog';
export const queue = createDialogQueue();
`}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the DialogQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<DialogQueue
dialogs={queue.dialogs}
// You can also pass default options to pass to your dialogs
// ie, prevent all dialogs from dismissing from a click on the background scrim
preventOutsideDismiss
/>
</div>
)
}
`}),r.jsx(ce,{children:"The `alert`, `confirm`, and `prompt` functions were designed to mimic the the built-in browser methods with a couple of small difference. First, they all return a promise. The promise will always resolve successfully with the response indicating the appropriate action. `alert` the response will be `accept` for clicking the ok button, or `close`. `confirm` will resolve `true` or `false`, and `prompt` will resolve with the value entered into the input, or `null` if the closed the dialog. Second, all methods the methods accept any valid prop for `SimpleDialog`."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
queue.alert({
title: 'Hi there',
body: 'Whats going on?'
});
queue.confirm({
title: <b>Are you positive?</b>,
body: 'You have selected pizza instead icecream!',
acceptLabel: 'CONFIRM'
});
queue.prompt({
title: 'Whats your name?',
body: 'Anything will do',
acceptLabel: 'Submit',
cancelLabel: 'Skip',
// For prompts only, you can pass props to the input
inputProps: {
outlined: true
}
});
`}),r.jsx(j,{label:"Inline Example",children:()=>{const{dialogs:e,alert:t,confirm:a,prompt:n}=uD();function s(){const[i,o]=G.useState("____________"),l=()=>t({title:"Hello!"}).then(d=>o(d)),u=()=>a({}).then(d=>o(d)),p=()=>n({inputProps:{outlined:!0}}).then(d=>o(d));return r.jsxs("div",{children:[r.jsx(ve,{label:"Alert",onClick:l}),r.jsx(ve,{label:"Confirm",onClick:u}),r.jsx(ve,{label:"Prompt",onClick:p}),r.jsx(ve,{label:"In Sequence",onClick:()=>{l(),u(),p()}}),r.jsxs("p",{children:["Response: ",r.jsx("b",{children:String(i)})]}),r.jsx(cD,{dialogs:e})]})}return r.jsx(s,{})}}),r.jsx(fe,{children:"Rendering through Portals"}),r.jsx(ce,{children:"Occasionally, you may find your dialog being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),r.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),r.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a dialog being cut off due to `overflow: hidden`."}),r.jsx(j,{children:function(){const[t,a]=G.useState(!0),[n,s]=G.useState(!1);return r.jsxs("div",{id:"dialog-portal-example",style:{transform:"translateZ(0)",height:"20rem",overflow:"hidden"},children:[r.jsx(Gu,{title:`This is a ${t?"working!":"broken :/"}`,renderToPortal:t,body:"Use `renderToPortal` to get around `overflow:hidden` and layout issues.",open:n,onClose:i=>{console.log(i.detail.action),s(!1)}}),r.jsx(ve,{raised:!0,onClick:()=>{a(!1),s(!0)},children:"Open Broken :/"}),r.jsx(ve,{raised:!0,onClick:()=>{a(!0),s(!0)},children:"Open in Portal"})]})}}),r.jsx(tt,{src:rJ,components:[{displayName:"Dialog",component:Rm},{displayName:"DialogTitle",component:Am},{displayName:"DialogContent",component:Im},{displayName:"DialogActions",component:Lm},{displayName:"DialogButton",component:xc},{displayName:"SimpleDialog",component:Gu}]})]})}
|
Wrapping a button in TouchTargetWrapper will automatically set its \`touch\` prop to true.
|
oJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z0hksSNz.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z0hksSNz.js
|
MIT
|
function HJ(){return r.jsxs(Je,{title:"Icons",lead:"Material icons use geometric shapes to visually represent core ideas, capabilities, or topics.",module:"@rmwc/icon",styles:["@rmwc/icon/icon.css"],docsLink:"https://material.io/icons",examples:FJ,children:[r.jsx(fe,{children:"Setup"}),r.jsx(ce,{children:"Icons are not part of the official material-components-web spec, but they are referenced many times in the documentation. RMWC provides a declarative way to use icons. Note that RMWC does not ship with any icons of its own. Make sure you include an icon set! You can use any one you want, but Google's Material Icons are available through open source. Follow Google's developer guide to get them setup with your app. https://google.github.io/material-design-icons/"}),r.jsx(ce,{children:"There are lots of different strategies for implementing icons on the web, and the Icon component is flexible for most of them. Use ligatures, classNames, inline SVGs, HTML, or URLs to get icons into your app. The default strategy is 'ligature' which works with the material.io font icon set."}),r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"The Icon component, (really the icon prop itself) can accept a variety of formats. Anywhere you see a component prop like `icon` or `trailingIcon` will inherit the same behavior."}),r.jsx(j,{label:"String",children:r.jsx($e,{icon:"favorite"})}),r.jsx(j,{label:"Child Component",children:r.jsx($e,{icon:r.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})})}),r.jsx(j,{label:"Passing Options",children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:{icon:"star",strategy:"ligature"}}),r.jsx(ve,{label:"Hello!",icon:{icon:"add",onMouseOver:()=>console.log("OVER")}})]})}),r.jsx(fe,{children:"Icon Sizing"}),r.jsx(ce,{children:"The Material spec details multiple sizes for icons. The Icon component doesn't assign a size by default, but these are available to you to force a size. Please note, this will only work if you've included the RMWC icon css file."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:{icon:"favorite",size:"xsmall"}}),r.jsx($e,{icon:{icon:"favorite",size:"small"}}),r.jsx($e,{icon:{icon:"favorite",size:"medium"}}),r.jsx($e,{icon:{icon:"favorite",size:"large"}}),r.jsx($e,{icon:{icon:"favorite",size:"xlarge"}})]})}),r.jsx(fe,{children:"Ligatures"}),r.jsx(ce,{children:"This is for icon fonts that support ligatures like material-icons. This is the default strategy if nothing is set and doesn't require any additional setup if you are using material-icons."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:"favorite"}),r.jsx($e,{icon:"favorite_outline"}),r.jsx($e,{icon:{icon:"star",strategy:"ligature"}})]})}),r.jsx(fe,{children:"URLs"}),r.jsx(ce,{children:"This is for icons that are accessible via HTTP(S) and will be loaded directly into an `img` tag. This can be auto-detected for things that look like urls. The image will be set as a backgroundImage of the icon. Make sure you impor the RMWC icon css file for this to work properly."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:"images/icons/twitter.png"}),r.jsx($e,{icon:{icon:"images/icons/twitter.png",strategy:"url"}})]})}),r.jsx(fe,{children:"Components / Inline SVGs"}),r.jsx(ce,{children:"This will render a child component inside of the icon. This is useful for all sorts of customization and for rendering inline SVGs. The following example shows rendering an SVG, as well as an arbitrary `div`."}),r.jsx(j,{children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:r.jsx("div",{style:{background:"green",width:"24px",height:"24px",borderRadius:"100px"}})}),r.jsx($e,{icon:{strategy:"component",icon:r.jsx("svg",{style:{width:"24px",height:"24px"},viewBox:"0 0 24 24",children:r.jsx("path",{fill:"#4285F4",d:"M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z"})})}})]})}),r.jsx(fe,{children:"Classnames"}),r.jsx(ce,{children:"Some font icon sets like Ion Icons and Glyph Icons render based on a className that is set. RMWC docs doesn't include extra icon fonts so there is no example to render, but the below code should give you an approximation."}),r.jsx(ce,{children:"**THIS CANNOT BE AUTO DETECTED**. You'll have to explicitly set the strategy directly on the Icon or specify it globally via the RMWCProvider."}),r.jsx(j,{codeOnly:!0,children:r.jsxs(r.Fragment,{children:[r.jsx($e,{icon:{icon:"star",strategy:"className",basename:"icon",prefix:"ion-"}}),r.jsx(mi,{icon:{strategy:"className",basename:"glyphicons",prefix:"glyphicons-"},children:r.jsx($e,{icon:"heart"})})]})}),r.jsx(fe,{children:"Custom Rendering"}),r.jsx(ce,{children:"Sometimes, you just need to do your own thing. Maybe you have a legacy project that already has icons and you want to incorporate them with RMWC. If none of the other strategies are what you need, then you can hijack the whole thing and delegate it to your own render function."}),r.jsx(j,{label:"Simple Example",children:r.jsx($e,{icon:{icon:"favorite",strategy:"custom",render:({content:e})=>r.jsxs("div",{children:["Hello + ",e]})}})}),r.jsx(ce,{children:"A more relevant example involves an app that has a custom / existing icon component. There are a litany of reasons why your app might need one, but if you've found this section of the docs you likely know what problem you need to solve."}),r.jsx(j,{codeOnly:!0,children:`
// 1) Your app has an icon component you use
import { MyIconComponent } from '@rmwc/icon';
<MyIconComponent name="search" />
// 2) Now you are using RMWC, lots of components are instances of Icons
// You need to be able to delegate the handling of an icon prop to your own component
import { TextField } from '@rmwc/textField';
import { Chip } from '@rmwc/chip';
<TextField icon="favorite" />
<Chip icon="favorite" />
// 3) Instead, you should set the custom strategy to be your default
// and add your own handling with RMWCProvider
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
import { MyIconComponent } from '@rmwc/icon';
const iconRenderHandler = ({ content, className, ...rest }) => {
// content is whatever was passed to the icon prop
// className is the fully processed className taking into account the basename and prefix defaults
// it's important to include this because MDC often has classes like text-field-icon directly
// on the component for alignment
// rest is just any other props
return <MyIconComponent className={className} name={content} {...rest} />
};
ReactDOM.render(
<RMWCProvider icon={{strategy: 'custom', render: iconRenderHandler}}>
<App />
</RMWCProvider>,
document.getElementById('root')
);
// 4) Now anywhere in your app that an Icon instance is used, it will be
// delegated to your handler and render your custom component
import { TextFieldIcon } from '@rmwc/textfield';
<TextFieldIcon icon="search" />
`}),r.jsx(tt,{src:UJ,components:[{displayName:"Icon",component:$e}]})]})}
|
Set the option globally throug RMWCProvider
Glyphicons <span class="glyphicons glyphicons-heart"></span>
|
HJ
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z0hksSNz.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z0hksSNz.js
|
MIT
|
function hee(){return r.jsxs(Je,{title:"Menus",lead:"Menus display a list of choices on a transient sheet of material.",module:"@rmwc/menu",styles:["@material/menu/dist/mdc.menu.css","@material/menu-surface/dist/mdc.menu-surface.css","@material/ripple/dist/mdc.ripple.css","@material/list/dist/mdc.list.css","@rmwc/icon/icon.css"],docsLink:"https://material.io/develop/web/components/menus/",examples:dee,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can compose a menu with the given components, and manually manage the open state. `Menu` expects MenuItems as children while `MenuSurface` is a generic container which can have anything as a child."}),r.jsx(j,{children:function(){const[t,a]=G.useState(!1);return r.jsxs(is,{children:[r.jsxs(Mr,{open:t,onSelect:n=>console.log(n.detail.index),onClose:()=>a(!1),children:[r.jsx(qa,{children:"Cookies"}),r.jsx(qa,{children:"Pizza"}),r.jsx(pi,{}),r.jsx(qa,{children:"Icecream"})]}),r.jsx(ve,{raised:!0,onClick:()=>a(!t),children:"Menu"})]})}}),r.jsx(j,{children:function(){const[t,a]=G.useState(!1);return r.jsxs(is,{children:[r.jsx(Nr,{open:t,onClose:n=>a(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})}),r.jsx(ve,{raised:!0,onClick:n=>a(!t),children:"Menu Surface"})]})}}),r.jsx(j,{children:function(){const[t,a]=G.useState(!1);return r.jsxs(is,{children:[r.jsx(Nr,{open:t,onClose:()=>a(!1),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Menu"})}),r.jsx(ft,{icon:"menu",onClick:()=>a(!t)})]})}}),r.jsx(j,{children:function(){const[t,a]=G.useState(!1);return r.jsxs(is,{children:[r.jsxs(Mr,{open:t,onSelect:n=>console.log(n.detail.index),onClose:()=>a(!1),children:[r.jsx(qa,{children:"Item One"}),r.jsx(qa,{disabled:!0,children:"Item Two (disabled)"}),r.jsx(qa,{children:"Item Three"})]}),r.jsx(ve,{raised:!0,onClick:()=>a(!t),children:"Menu"})]})}}),r.jsx(fe,{children:"Simplified usage"}),r.jsx(ce,{children:"RMWC provides a convenience `SimpleMenu` component that takes a handle as a prop, and manages the open state for you."}),r.jsx(j,{children:r.jsxs(um,{handle:r.jsx(ve,{children:"Simple Menu"}),children:[r.jsx(qa,{children:"Cookies"}),r.jsx(qa,{children:"Pizza"}),r.jsx(qa,{children:"Icecream"})]})}),r.jsx(j,{children:r.jsx(H1,{handle:r.jsx(ve,{children:"Simple Menu Surface"}),children:r.jsx("div",{style:{padding:"1rem",width:"8rem"},children:"Make the content whatever you want."})})}),r.jsx(fe,{children:"Anchoring"}),r.jsx(ce,{children:"By default, Menus will attempt to automatically position themselves, but this behavior can be overridden by setting the `anchorCorner` prop."}),r.jsx(j,{children:function(){const[t,a]=G.useState("topLeft");return r.jsxs(r.Fragment,{children:[r.jsxs(is,{children:[r.jsx(Nr,{anchorCorner:t,open:!0,children:r.jsxs("div",{style:{padding:"1rem",width:"8rem"},children:["anchorCorner: ",t]})}),r.jsx(ve,{raised:!0,label:"Anchored Menu"})]}),r.jsx(Ht,{value:t,label:"anchorCorner",onChange:n=>a(n.currentTarget.value),options:["topLeft","topRight","bottomLeft","bottomRight","topStart","topEnd","bottomStart","bottomEnd"]})]})}}),r.jsx(fe,{children:"Rendering through Portals"}),r.jsx(ce,{children:"Occasionally, you may find your menu being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."}),r.jsx(ce,{children:"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the RMWC Portal
// You only have to do this once
import React from 'react';
import { Portal } from '@rmwc/base';
export default function App() {
return (
<div>
...
<Portal />
</div>
)
}
`}),r.jsx(ce,{children:"Now you can use the `renderToPortal` prop. Below is a contrived example of a menu being cut off due to `overflow: hidden`."}),r.jsx(j,{children:function(){const[t,a]=G.useState(!0),[n,s]=G.useState(!1),i=["Cookies","Pizza","Icecream"];return r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{marginBottom:"10rem",height:"3.5rem",overflow:"hidden"},children:r.jsxs(is,{children:[r.jsx(ve,{raised:!0,onClick:()=>s(!n),children:"Open Menu"}),r.jsx(Mr,{open:n,onClose:()=>s(!1),renderToPortal:t,children:i.map(o=>r.jsx(qa,{children:o},o))})]})}),r.jsx(Oa,{checked:t,onChange:o=>a(o.currentTarget.checked),label:"renderToPortal"})]})}}),r.jsx(tt,{src:mee,components:[{displayName:"Menu",component:Mr},{displayName:"MenuItem",component:qa},{displayName:"MenuSurface",component:Nr},{displayName:"MenuSurfaceAnchor",component:is},{displayName:"SimpleMenu",component:um},{displayName:"SimpleMenuSurface",component:H1}]})]})}
|
The handle can be any component you want
|
hee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z0hksSNz.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z0hksSNz.js
|
MIT
|
function xee(){return r.jsxs(Je,{title:"Provider",lead:"A component that provides global configuration for RMWC.",module:"@rmwc/provider",styles:[],examples:bee,children:[r.jsx(ce,{children:"You can wrap your top level App component with RMWC provider to set global configuration options. Just pass the options in as props."}),r.jsx(j,{codeOnly:!0,children:`
import React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App'; // your main app component
import { RMWCProvider } from '@rmwc/provider';
// This example disables ripples globally by default
ReactDOM.render(
<RMWCProvider
// Globally disable ripples
ripple={false}
// Global options for icons
// Takes the same options as the icon component
icon={{
basename: 'material-icons'
}}
// Global options for typography
// allows mapping of a defaultTag or specific classes
// See the Typography docs for more info
typography={{
defaultTag: 'div',
headline1: 'h1'
}}
// Global options for tooltips
// Takes most of the options for tooltips
// See the Tooltip docs for more info
tooltip={{
align: 'right'
}}
>
<App />
</RMWCProvider>,
document.getElementById('root'),
);
`}),r.jsx(j,{label:"With ripple false",children:r.jsx(mi,{ripple:!1,children:r.jsx(ve,{children:"Click me"})})}),r.jsx(j,{label:"With ripple true",children:r.jsx(mi,{ripple:!0,children:r.jsx(ve,{children:"Click me"})})}),r.jsx(tt,{src:yee,components:[{displayName:"RMWCProvider",component:mi}]})]})}
|
The handle can be any component you want
|
xee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z0hksSNz.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z0hksSNz.js
|
MIT
|
function Yee(){return r.jsxs(Je,{title:"Snackbars",lead:"Snackbars provide brief feedback about an operation through a message at the bottom of the screen.",module:"@rmwc/snackbar",styles:["@material/snackbar/dist/mdc.snackbar.css","@material/button/dist/mdc.button.css","@material/ripple/dist/mdc.ripple.css"],docsLink:"https://material.io/develop/web/components/snackbars/",examples:Vee,children:[r.jsx(fe,{children:"Basic Usage"}),r.jsx(ce,{children:"You can render a snackbar in your UI and control its open state."}),r.jsx(j,{label:"Default",children:function(){const[t,a]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{open:t,onClose:n=>a(!1),message:"This is a new message",dismissesOnAction:!0,action:r.jsx(Go,{label:"Dismiss",onClick:()=>console.log("Click Me")})}),r.jsx(ve,{raised:!0,label:"Show snackbar",onClick:n=>a(!t)})]})}}),r.jsx(j,{label:"Start Aligned",children:function(){const[t,a]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{open:t,onClose:n=>a(!1),message:"Start aligned, open until dismissed",stacked:!0,dismissesOnAction:!0,action:[r.jsx(Go,{label:"Yeah!"}),r.jsx(Go,{label:"No..."})],leading:!0,timeout:-1}),r.jsx(ve,{raised:!0,label:"Show start-aligned",onClick:n=>a(!t)})]})}}),r.jsx(j,{label:"With dismiss icon",children:function(){const[t,a]=G.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{open:t,onClose:n=>a(!1),message:"This is a new message",dismissesOnAction:!0,dismissIcon:"close",timeout:-1}),r.jsx(ve,{raised:!0,label:"Show snackbar",onClick:n=>a(!t)})]})}}),r.jsx(fe,{children:"Usage with SnackbarQueue"}),r.jsx(ce,{children:"While rendering the Snackbar inline works for simple cases, you'll likely have a notification system, or want to send notifications from anywhere in your app. The `SnackbarQueue` exists as a convenient interface for handling these cases and rendering the snackbar messages for you. If you've used the `DialogQueue`, the `SnackbarQueue` is very similar."}),r.jsx(ce,{children:"Setup is nice and easy, create a queue object you can pass around in your code base, pass the queues `messages` to the `SnackbarQueue` component, and then use the `notify` function to send notifications."}),r.jsx(j,{codeOnly:!0,children:`
// Create a file that exports your queue
// myQueue.js
import { createSnackbarQueue } from '@rmwc/snackbar';
export const queue = createSnackbarQueue();
`}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere at the top level of your app
// Render the SnackbarQueue
import React from 'react';
import { queue } from './myQueue';
export default function App() {
return (
<div>
...
<SnackbarQueue
messages={queue.messages}
// You can also pass default options to pass to your notifications
// ie, make them all leading, stacked, etc
leading
stacked
/>
</div>
)
}
`}),r.jsx(ce,{children:"The `notify` function was designed to mimic the the built-in browser Notifications api and can accept most of the relevant options (icon, image, title, body, actions, ,etc). It also can accept any of the Snackbar props. Just import your queue, and call the notify method."}),r.jsx(j,{codeOnly:!0,children:`
// Somewhere else in your app
// Could be a view, your redux store, anywhere you want...
import { queue } from './myQueue';
// Simple example
queue.notify({
title: 'Hi there'
});
// With some features
queue.notify({
title: <b>Warning</b>,
body: 'You have selected pizza instead icecream!',
icon: 'warning',
actions: [
{
// NotificationAction api format
title: 'Fix It!',
icon: 'close',
action: 'fixit' // action will be available as evt.detail.reason in the onClose event
},
{
// OR SnackbarActionProps format
label: 'Continue...',
icon: 'check',
onClick: () => {}
},
]
});
`}),r.jsx(j,{label:"Inline Example",children:()=>{const{messages:e,notify:t}=bD();function a(){return r.jsxs("div",{children:[r.jsx(ve,{label:"Notify",onClick:()=>t({title:r.jsx("b",{children:"Success"}),body:"You have selected pizza!",dismissesOnAction:!0,icon:"check",actions:[{title:"Dismiss"}]})}),r.jsx(gD,{messages:e})]})}return r.jsx(a,{})}}),r.jsx(tt,{src:Kee,components:[{displayName:"Snackbar",component:Wo},{displayName:"SnackbarAction",component:Go}]})]})}
|
Any additional items will be passed to the
child ListItem as props
|
Yee
|
javascript
|
rmwc/rmwc
|
docs/assets/index-z0hksSNz.js
|
https://github.com/rmwc/rmwc/blob/master/docs/assets/index-z0hksSNz.js
|
MIT
|
function f() {
return (0, p.jsxs)(a.WI, {
title: 'Drawers',
lead: 'A navigation drawer slides in from the left and contains the navigation destinations for your app.',
module: '@rmwc/drawer',
styles: ['@material/drawer/dist/mdc.drawer.css'],
docsLink: 'https://material.io/develop/web/components/drawers/',
examples: s,
children: [
(0, p.jsx)(a.sb, { children: 'Permanent' }),
(0, p.jsx)(a.PJ, {
children:
'These are drawers that are permanently fixed inside of a view.'
}),
(0, p.jsx)(a.q3, {
children: (0, p.jsxs)(l.dy, {
children: [
(0, p.jsxs)(l.OX, {
children: [
(0, p.jsx)(l.iI, { children: 'DrawerHeader' }),
(0, p.jsx)(l.I1, { children: 'Subtitle' })
]
}),
(0, p.jsx)(l.sc, {
children: (0, p.jsxs)(c.a, {
children: [
(0, p.jsx)(u.HC, { children: 'Cookies' }),
(0, p.jsx)(u.HC, { children: 'Pizza' }),
(0, p.jsx)(u.HC, { children: 'Icecream' })
]
})
})
]
})
}),
(0, p.jsx)(a.sb, { children: 'Dismissible' }),
(0, p.jsx)(a.PJ, {
children:
'These are drawers that can be toggled to an open or closed state inside of a view, but still takes up viewable space when closed.'
}),
(0, p.jsx)(a.q3, {
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, p.jsxs)(p.Fragment, {
children: [
(0, p.jsxs)('div', {
style: { overflow: 'hidden', position: 'relative' },
children: [
(0, p.jsxs)(l.dy, {
dismissible: !0,
open: n,
children: [
(0, p.jsxs)(l.OX, {
children: [
(0, p.jsx)(l.iI, {
children: 'DrawerHeader'
}),
(0, p.jsx)(l.I1, { children: 'Subtitle' })
]
}),
(0, p.jsx)(l.sc, {
children: (0, p.jsxs)(c.a, {
children: [
(0, p.jsx)(u.HC, { children: 'Cookies' }),
(0, p.jsx)(u.HC, { children: 'Pizza' }),
(0, p.jsx)(u.HC, { children: 'Icecream' })
]
})
})
]
}),
(0, p.jsx)(l.px, {
style: { minHeight: '15rem', padding: '1rem' },
children:
'DrawerAppContent is an optional component that will resize content when the dismissible drawer is open and closed. It must be placed directly after the Drawer component.'
})
]
}),
(0, p.jsx)('div', {
style: { textAlign: 'center' },
children: (0, p.jsx)(d.z, {
onClick: function () {
return a(!n);
},
raised: !0,
children: 'Toggle Dismissible'
})
})
]
});
}
}),
(0, p.jsx)(a.sb, { children: 'Modal' }),
(0, p.jsx)(a.PJ, {
children:
'These are drawers that can be temporarily displayed fixed on the side of the entire viewport.'
}),
(0, p.jsx)(a.q3, {
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, p.jsxs)(p.Fragment, {
children: [
(0, p.jsxs)(l.dy, {
modal: !0,
open: n,
onClose: function () {
return a(!1);
},
children: [
(0, p.jsxs)(l.OX, {
children: [
(0, p.jsx)(l.iI, { children: 'DrawerHeader' }),
(0, p.jsx)(l.I1, { children: 'Subtitle' })
]
}),
(0, p.jsx)(l.sc, {
children: (0, p.jsxs)(c.a, {
children: [
(0, p.jsx)(u.HC, { children: 'Cookies' }),
(0, p.jsx)(u.HC, { children: 'Pizza' }),
(0, p.jsx)(u.HC, { children: 'Icecream' })
]
})
})
]
}),
(0, p.jsx)(d.z, {
onClick: function () {
return a(!n);
},
raised: !0,
children: 'Toggle Modal'
})
]
});
}
}),
(0, p.jsx)(a.sb, { children: 'Right Side Drawers' }),
(0, p.jsx)(a.PJ, {
children:
"`material-components-web` doesn't directly support right hand drawers, but it respects the `dir` attribute on DOM elements. This simple hack will allow you to get drawers that appear from the right hand side of your app. As an aside, the `dir` attribute can be used to invert many other behaviors where the element is anchored on the left."
}),
(0, p.jsx)(a.q3, {
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, p.jsxs)(p.Fragment, {
children: [
(0, p.jsxs)(l.dy, {
dir: 'rtl',
modal: !0,
open: n,
onClose: function () {
return a(!1);
},
children: [
(0, p.jsxs)(l.OX, {
dir: 'ltr',
children: [
(0, p.jsx)(l.iI, { children: 'Right Drawer' }),
(0, p.jsx)(l.I1, { children: 'Subtitle' })
]
}),
(0, p.jsx)(l.sc, {
dir: 'ltr',
children: (0, p.jsxs)(c.a, {
children: [
(0, p.jsx)(u.HC, { children: 'Cookies' }),
(0, p.jsx)(u.HC, { children: 'Pizza' }),
(0, p.jsx)(u.HC, { children: 'Icecream' })
]
})
})
]
}),
(0, p.jsx)(d.z, {
onClick: function () {
return a(!n);
},
raised: !0,
children: 'Toggle Right Drawer'
})
]
});
}
}),
(0, p.jsx)(a.PQ, {
src: o,
components: [
{ displayName: 'Drawer', component: l.dy },
{ displayName: 'DrawerHeader', component: l.OX },
{ displayName: 'DrawerTitle', component: l.iI },
{ displayName: 'DrawerSubtitle', component: l.I1 },
{ displayName: 'DrawerContent', component: l.sc },
{ displayName: 'DrawerAppContent', component: l.px }
]
})
]
});
}
|
Set the content back to left-to-right
|
f
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function u() {
return (0, c.jsxs)(a.WI, {
title: 'Elevation',
lead: 'Elevation is the relative distance between two surfaces along the z-axis.',
module: '@rmwc/elevation',
styles: ['@material/elevation/dist/mdc.elevation.css'],
docsLink: 'https://material.io/develop/web/components/elevation/',
examples: s,
children: [
(0, c.jsx)(a.q3, {
label: 'Elevation',
children: (0, c.jsx)(c.Fragment, {
children: Array(25)
.fill(void 0)
.map(function (e, t) {
return (0, c.jsxs)(l.u, { z: t, children: [t, 'dp'] }, t);
})
})
}),
(0, c.jsx)(a.q3, {
label: 'Transition',
children: function () {
var e = i.useState(0),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, c.jsxs)(l.u, {
z: n,
transition: !0,
onMouseOver: function () {
return a(24);
},
onMouseOut: function () {
return a(0);
},
children: ['Hover Me ', n, 'dp']
});
}
}),
(0, c.jsx)(a.sb, { children: 'Wrapping Children' }),
(0, c.jsx)(a.PJ, {
children:
'You can avoid adding extra DOM nodes by using the `wrap` prop on elevation. This will apply the classes directly to the child component. Additionally, Elevation is simply a `className`, so you can achieve the same effect by adding `className="mdc-elevation--z15"`.'
}),
(0, c.jsx)(a.q3, {
children: (0, c.jsx)(l.u, {
z: 21,
wrap: !0,
children: (0, c.jsx)('span', { children: 'Wrapped!' })
})
}),
(0, c.jsx)(a.PQ, {
src: o,
components: [{ displayName: 'Elevation', component: l.u }]
})
]
});
}
|
Set the content back to left-to-right
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function l() {
return (0, s.jsxs)(r.WI, {
title: 'Fabs',
lead: 'A floating action button (FAB) represents the primary action of a screen.',
module: '@rmwc/fab',
styles: [
'@material/fab/dist/mdc.fab.css',
'@rmwc/icon/icon.css',
'@material/ripple/dist/mdc.ripple.css'
],
docsLink:
'https://material.io/develop/web/components/buttons/floating-action-buttons/',
examples: a,
children: [
(0, s.jsx)(r.q3, {
label: 'Default',
children: (0, s.jsx)(o.L, { icon: 'favorite' })
}),
(0, s.jsx)(r.q3, {
label: 'Mini',
children: (0, s.jsx)(o.L, { icon: 'favorite', mini: !0 })
}),
(0, s.jsx)(r.q3, {
label: 'Extended',
children: (0, s.jsxs)(s.Fragment, {
children: [
(0, s.jsx)(o.L, { icon: 'add', label: 'Create' }),
(0, s.jsx)(o.L, { trailingIcon: 'add', label: 'Create' }),
(0, s.jsx)(o.L, { label: 'Label only' })
]
})
}),
(0, s.jsx)(r.q3, {
label: 'Theming',
children: (0, s.jsxs)(s.Fragment, {
children: [
(0, s.jsx)(o.L, {
icon: 'favorite_outline',
theme: ['primaryBg', 'onPrimary']
}),
(0, s.jsx)(o.L, {
icon: 'delete',
style: { backgroundColor: 'var(--mdc-theme-error)' },
theme: ['onError']
})
]
})
}),
(0, s.jsx)(r.PQ, {
src: i,
components: [{ displayName: 'Fab', component: o.L }]
})
]
});
}
|
Set the content back to left-to-right
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
s = function (e, t) {
return (
(s =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
s(e, t)
);
}
|
Set the content back to left-to-right
|
s
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
l = function () {
return (
(l =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
l.apply(this, arguments)
);
}
|
Set the content back to left-to-right
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
var r = e.call(this, l(l({}, t.defaultAdapter), n)) || this;
return (
(r.shakeAnimationEndHandler_ = function () {
return r.handleShakeAnimationEnd_();
}),
r
);
}
|
Set the content back to left-to-right
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
Set the content back to left-to-right
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
o = function (e, t) {
return (
(o =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
o(e, t)
);
}
|
Set the content back to left-to-right
|
o
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
s = function () {
return (
(s =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
s.apply(this, arguments)
);
}
|
Set the content back to left-to-right
|
s
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
var r = e.call(this, s(s({}, t.defaultAdapter), n)) || this;
return (
(r.click = function () {
r.handleClick();
}),
r
);
}
|
Set the content back to left-to-right
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
Set the content back to left-to-right
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function m() {
return (0, f.jsxs)(s.WI, {
title: 'Grid Lists',
lead: 'Grid lists are an alternative to standard list views. Note that as of Material Components Web 6.0.0, this component is deprecated.',
module: '@rmwc/grid-list',
styles: ['@material/grid-list/dist/mdc.grid-list.css'],
docsLink: 'https://material.io/components/web/catalog/grid-lists/',
examples: c,
children: [
(0, f.jsx)(s.q3, {
children: function () {
var e = o.useState({
tileGutter1: !1,
headerCaption: !1,
twolineCaption: !1,
withIconAlignStart: !1,
tileAspect: '1x1'
}),
t = (0, a.Z)(e, 2),
n = t[0],
s = t[1];
return (0, f.jsxs)(f.Fragment, {
children: [
(0, f.jsx)(u.e_, {
tileGutter1: n.tileGutter1,
headerCaption: n.headerCaption,
twolineCaption: n.twolineCaption,
withIconAlignStart: n.withIconAlignStart,
tileAspect: n.tileAspect,
children: Array(8)
.fill(void 0)
.map(function (e, t) {
return (0,
f.jsxs)(u.$X, { children: [(0, f.jsx)(u.co, { children: (0, f.jsx)(u.lu, { src: 'images/backgrounds/mb-bg-fb-06.png', alt: 'test' }) }), (0, f.jsxs)(u.mu, { children: [(0, f.jsx)(u.F3, { icon: 'info' }), (0, f.jsxs)(u.uB, { children: ['Tile ', t + 1] })] })] }, t);
})
}),
[
'tileGutter1',
'headerCaption',
'twoLineCaption',
'withIconAlignStart'
].map(function (e) {
return (0, f.jsx)(
d.X,
{
label: e,
onChange: function (t) {
return s(
(0, i.Z)(
(0, i.Z)({}, n),
{},
(0, r.Z)({}, e, t.currentTarget.checked)
)
);
}
},
e
);
}),
(0, f.jsx)(p.P, {
value: n.tileAspect,
onChange: function (e) {
return s(
(0, i.Z)(
(0, i.Z)({}, n),
{},
{ tileAspect: String(e.currentTarget.value) }
)
);
},
label: 'tileAspect',
options: ['1x1', '16x9', '2x3', '3x2', '4x3', '3x4']
})
]
});
}
}),
(0, f.jsx)(s.PQ, {
src: l,
components: [
{ displayName: 'GridList', component: u.e_ },
{ displayName: 'GridTile', component: u.$X },
{ displayName: 'GridTileIcon', component: u.F3 },
{ displayName: 'GridTilePrimary', component: u.co },
{ displayName: 'GridTileSecondary', component: u.mu },
{ displayName: 'GridTileTitleSupportText', component: u.O$ },
{ displayName: 'GridTileTitle', component: u.uB }
]
})
]
});
}
|
Set the content back to left-to-right
|
m
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function l() {
return (0, s.jsxs)(r.WI, {
title: 'Layout Grid',
lead: 'Material design\u2019s responsive UI is based on a column-variate grid layout. It has 12 columns on desktop, 8 columns on tablet and 4 columns on phone.',
module: '@rmwc/grid',
styles: ['@material/layout-grid/dist/mdc.layout-grid.css'],
docsLink: 'https://material.io/develop/web/components/layout-grid/',
examples: a,
children: [
(0, s.jsx)(r.q3, {
label: 'Standard Grid',
children: (0, s.jsxs)(o.rj, {
children: [
(0, s.jsx)(o.r8, { span: 4, children: '1' }),
(0, s.jsx)(o.r8, { span: 4, children: '2' }),
(0, s.jsx)(o.r8, { span: 4, children: '3' })
]
})
}),
(0, s.jsx)(r.q3, {
label: 'Sub Grids',
children: (0, s.jsx)(o.rj, {
children: (0, s.jsxs)(o.Jn, {
children: [
(0, s.jsx)(o.r8, { span: 6, children: '1' }),
(0, s.jsx)(o.r8, {
span: 6,
children: (0, s.jsxs)(o.Jn, {
children: [
(0, s.jsx)(o.r8, { span: 6, children: 'a' }),
(0, s.jsx)(o.r8, { span: 6, children: 'b' })
]
})
})
]
})
})
}),
(0, s.jsx)(r.PQ, {
src: i,
components: [
{ displayName: 'Grid', component: o.rj },
{ displayName: 'GridCell', component: o.r8 },
{ displayName: 'GridRow', component: o.Jn }
]
})
]
});
}
|
Set the content back to left-to-right
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
u = function (e, t) {
return (
(u =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
u(e, t)
);
}
|
Set the content back to left-to-right
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
d = function () {
return (
(d =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
d.apply(this, arguments)
);
}
|
Set the content back to left-to-right
|
d
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
var r = e.call(this, d(d({}, t.defaultAdapter), n)) || this;
return (r.hasToggledAriaLabel = !1), r;
}
|
Set the content back to left-to-right
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
Set the content back to left-to-right
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function u() {
return (0, c.jsxs)(a.WI, {
title: 'Icon Buttons',
lead: 'Icon buttons allow users to take actions, and make choices, with a single tap.',
module: '@rmwc/icon-button',
styles: [
'@material/icon-button/dist/mdc.icon-button.css',
'@rmwc/icon/icon.css',
'@material/ripple/dist/mdc.ripple.css'
],
docsLink:
'https://material.io/develop/web/components/buttons/icon-buttons/',
examples: s,
children: [
(0, c.jsx)(a.sb, { children: 'Basic Usage' }),
(0, c.jsx)(a.PJ, {
children:
'`IconButton` inherits from the `Icon` component and can be passed icons in the same way.'
}),
(0, c.jsx)(a.q3, {
label: 'Default',
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(l.h, { icon: 'star', label: 'Rate this!' }),
(0, c.jsx)(l.h, {
icon: 'favorite',
label: 'Favorite',
disabled: !0
}),
(0, c.jsx)(l.h, {
icon: 'images/icons/twitter.png',
'aria-label': 'Tweet it!',
tag: 'a',
target: '_blank',
href: 'https://twitter.com/intent/tweet?text='.concat(
encodeURIComponent(
'You should definitely be using RMWC for your next project! https://rmwc.io'
)
)
})
]
})
}),
(0, c.jsx)(a.sb, { children: 'Usage as a Toggle' }),
(0, c.jsx)(a.PJ, {
children:
"To use as a toggle, specify an additional toggled on state using 'onIcon'."
}),
(0, c.jsx)(a.q3, {
label: 'Uncontrolled',
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(l.h, {
icon: 'favorite_border',
onIcon: 'favorite'
}),
(0, c.jsx)(l.h, {
icon: 'favorite',
onIcon: 'favorite',
disabled: !0
})
]
})
}),
(0, c.jsx)(a.q3, {
label: 'Controlled',
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(l.h, {
checked: n,
onClick: function () {
return a(!n);
},
onIcon: 'star',
icon: 'star_border'
}),
(0, c.jsx)(l.h, {
checked: n,
onClick: function () {
return a(!n);
},
onIcon: 'images/icons/twitter.png',
icon: 'images/icons/facebook.png'
})
]
});
}
}),
(0, c.jsx)(a.q3, {
label: 'Component as Icon',
children: (0, c.jsx)(l.h, {
onIcon: (0, c.jsx)('div', {
style: { background: 'red', width: '24px', height: '24px' }
}),
icon: (0, c.jsx)('div', {
style: {
background: 'green',
width: '24px',
height: '24px',
borderRadius: '50%'
}
})
})
}),
(0, c.jsx)(a.PQ, {
src: o,
components: [{ displayName: 'IconButton', component: l.h }]
})
]
});
}
|
Set the content back to left-to-right
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
y = function (e, t, n) {
return 'auto' === (t = t || n || 'auto')
? (function (e) {
return 'string' === typeof e && e.includes('/')
? 'url'
: o.isValidElement(e)
? 'component'
: 'ligature';
})(e)
: t;
}
|
Set the content back to left-to-right
|
y
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function u() {
return (0, c.jsxs)(r.WI, {
title: 'Icons',
lead: 'Material icons use geometric shapes to visually represent core ideas, capabilities, or topics.',
module: '@rmwc/icon',
styles: ['@rmwc/icon/icon.css'],
docsLink: 'https://material.io/icons',
examples: a,
children: [
(0, c.jsx)(r.sb, { children: 'Setup' }),
(0, c.jsx)(r.PJ, {
children:
"Icons are not part of the official material-components-web spec, but they are referenced many times in the documentation. RMWC provides a declarative way to use icons. Note that RMWC does not ship with any icons of its own. Make sure you include an icon set! You can use any one you want, but Google's Material Icons are available through open source. Follow Google's developer guide to get them setup with your app. https://google.github.io/material-design-icons/"
}),
(0, c.jsx)(r.PJ, {
children:
"There are lots of different strategies for implementing icons on the web, and the Icon component is flexible for most of them. Use ligatures, classNames, inline SVGs, HTML, or URLs to get icons into your app. The default strategy is 'ligature' which works with the material.io font icon set."
}),
(0, c.jsx)(r.sb, { children: 'Basic Usage' }),
(0, c.jsx)(r.PJ, {
children:
'The Icon component, (really the icon prop itself) can accept a variety of formats. Anywhere you see a component prop like `icon` or `trailingIcon` will inherit the same behavior.'
}),
(0, c.jsx)(r.q3, {
label: 'String',
children: (0, c.jsx)(o.J, { icon: 'favorite' })
}),
(0, c.jsx)(r.q3, {
label: 'Child Component',
children: (0, c.jsx)(o.J, {
icon: (0, c.jsx)('div', {
style: {
background: 'green',
width: '24px',
height: '24px',
borderRadius: '100px'
}
})
})
}),
(0, c.jsx)(r.q3, {
label: 'Passing Options',
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(o.J, {
icon: { icon: 'star', strategy: 'ligature' }
}),
(0, c.jsx)(s.z, {
label: 'Hello!',
icon: {
icon: 'add',
onMouseOver: function () {
return console.log('OVER');
}
}
})
]
})
}),
(0, c.jsx)(r.sb, { children: 'Icon Sizing' }),
(0, c.jsx)(r.PJ, {
children:
"The Material spec details multiple sizes for icons. The Icon component doesn't assign a size by default, but these are available to you to force a size. Please note, this will only work if you've included the RMWC icon css file."
}),
(0, c.jsx)(r.q3, {
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(o.J, {
icon: { icon: 'favorite', size: 'xsmall' }
}),
(0, c.jsx)(o.J, {
icon: { icon: 'favorite', size: 'small' }
}),
(0, c.jsx)(o.J, {
icon: { icon: 'favorite', size: 'medium' }
}),
(0, c.jsx)(o.J, {
icon: { icon: 'favorite', size: 'large' }
}),
(0, c.jsx)(o.J, {
icon: { icon: 'favorite', size: 'xlarge' }
})
]
})
}),
(0, c.jsx)(r.sb, { children: 'Ligatures' }),
(0, c.jsx)(r.PJ, {
children:
"This is for icon fonts that support ligatures like material-icons. This is the default strategy if nothing is set and doesn't require any additional setup if you are using material-icons."
}),
(0, c.jsx)(r.q3, {
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(o.J, { icon: 'favorite' }),
(0, c.jsx)(o.J, { icon: 'favorite_outline' }),
(0, c.jsx)(o.J, {
icon: { icon: 'star', strategy: 'ligature' }
})
]
})
}),
(0, c.jsx)(r.sb, { children: 'URLs' }),
(0, c.jsx)(r.PJ, {
children:
'This is for icons that are accessible via HTTP(S) and will be loaded directly into an `img` tag. This can be auto-detected for things that look like urls. The image will be set as a backgroundImage of the icon. Make sure you impor the RMWC icon css file for this to work properly.'
}),
(0, c.jsx)(r.q3, {
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(o.J, { icon: 'images/icons/twitter.png' }),
(0, c.jsx)(o.J, {
icon: {
icon: 'images/icons/twitter.png',
strategy: 'url'
}
})
]
})
}),
(0, c.jsx)(r.sb, { children: 'Components / Inline SVGs' }),
(0, c.jsx)(r.PJ, {
children:
'This will render a child component inside of the icon. This is useful for all sorts of customization and for rendering inline SVGs. The following example shows rendering an SVG, as well as an arbitrary `div`.'
}),
(0, c.jsx)(r.q3, {
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(o.J, {
icon: (0, c.jsx)('div', {
style: {
background: 'green',
width: '24px',
height: '24px',
borderRadius: '100px'
}
})
}),
(0, c.jsx)(o.J, {
icon: {
strategy: 'component',
icon: (0, c.jsx)('svg', {
style: { width: '24px', height: '24px' },
viewBox: '0 0 24 24',
children: (0, c.jsx)('path', {
fill: '#4285F4',
d: 'M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z'
})
})
}
})
]
})
}),
(0, c.jsx)(r.sb, { children: 'Classnames' }),
(0, c.jsx)(r.PJ, {
children:
"Some font icon sets like Ion Icons and Glyph Icons render based on a className that is set. RMWC docs doesn't include extra icon fonts so there is no example to render, but the below code should give you an approximation."
}),
(0, c.jsx)(r.PJ, {
children:
"**THIS CANNOT BE AUTO DETECTED**. You'll have to explicitly set the strategy directly on the Icon or specify it globally via the RMWCProvider."
}),
(0, c.jsx)(r.q3, {
codeOnly: !0,
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(o.J, {
icon: {
icon: 'star',
strategy: 'className',
basename: 'icon',
prefix: 'ion-'
}
}),
(0, c.jsx)(l.pK, {
icon: {
strategy: 'className',
basename: 'glyphicons',
prefix: 'glyphicons-'
},
children: (0, c.jsx)(o.J, { icon: 'heart' })
})
]
})
}),
(0, c.jsx)(r.sb, { children: 'Custom Rendering' }),
(0, c.jsx)(r.PJ, {
children:
'Sometimes, you just need to do your own thing. Maybe you have a legacy project that already has icons and you want to incorporate them with RMWC. If none of the other strategies are what you need, then you can hijack the whole thing and delegate it to your own render function.'
}),
(0, c.jsx)(r.q3, {
label: 'Simple Example',
children: (0, c.jsx)(o.J, {
icon: {
icon: 'favorite',
strategy: 'custom',
render: function (e) {
var t = e.content;
return (0, c.jsxs)('div', { children: ['Hello + ', t] });
}
}
})
}),
(0, c.jsx)(r.PJ, {
children:
"A more relevant example involves an app that has a custom / existing icon component. There are a litany of reasons why your app might need one, but if you've found this section of the docs you likely know what problem you need to solve."
}),
(0, c.jsx)(r.q3, {
codeOnly: !0,
children:
"\n // 1) Your app has an icon component you use\n import { MyIconComponent } from '@rmwc/icon';\n <MyIconComponent name=\"search\" />\n\n // 2) Now you are using RMWC, lots of components are instances of Icons\n // You need to be able to delegate the handling of an icon prop to your own component\n import { TextField } from '@rmwc/textField';\n import { Chip } from '@rmwc/chip';\n <TextField icon=\"favorite\" />\n <Chip icon=\"favorite\" />\n\n // 3) Instead, you should set the custom strategy to be your default\n // and add your own handling with RMWCProvider\n import React from 'react';\n import * as ReactDOM from 'react-dom';\n import App from './App'; // your main app component\n import { RMWCProvider } from '@rmwc/provider';\n import { MyIconComponent } from '@rmwc/icon';\n\n const iconRenderHandler = ({ content, className, ...rest }) => {\n // content is whatever was passed to the icon prop\n\n // className is the fully processed className taking into account the basename and prefix defaults\n // it's important to include this because MDC often has classes like text-field-icon directly\n // on the component for alignment\n\n // rest is just any other props\n return <MyIconComponent className={className} name={content} {...rest} />\n };\n\n ReactDOM.render(\n <RMWCProvider icon={{strategy: 'custom', render: iconRenderHandler}}>\n <App />\n </RMWCProvider>,\n document.getElementById('root')\n );\n\n // 4) Now anywhere in your app that an Icon instance is used, it will be\n // delegated to your handler and render your custom component\n import { TextFieldIcon } from '@rmwc/textfield';\n <TextFieldIcon icon=\"search\" />\n "
}),
(0, c.jsx)(r.PQ, {
src: i,
components: [{ displayName: 'Icon', component: o.J }]
})
]
});
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function l() {
return (0, s.jsxs)(r.WI, {
title: 'Image Lists',
lead: 'MDC Image List provides a RTL-aware Material Design image list component, representing an evolution of the Material Design Grid List spec. An Image List consists of several items, each containing an image and optionally supporting content (i.e. a text label).',
module: '@rmwc/image-list',
styles: ['@material/image-list/dist/mdc.image-list.css'],
docsLink: 'https://material.io/develop/web/components/image-lists/',
examples: a,
children: [
(0, s.jsx)(r.sb, { children: 'Standard Layout' }),
(0, s.jsx)(r.PJ, {
children:
'Image Lists will give you basic layout, but you will have to use inline styling or CSS to achieve things like spacing, aspect ratio, and column count. Check out the inline styles below as examples.'
}),
(0, s.jsx)(r.q3, {
label: 'Default',
children: (0, s.jsx)(o.Y, {
children: [
'images/photos/3x2-1.jpg',
'images/photos/2x3-1.jpg',
'images/photos/3x2-4.jpg',
'images/photos/3x2-5.jpg',
'images/photos/3x2-6.jpg',
'images/photos/2x3-2.jpg',
'images/photos/3x2-8.jpg',
'images/photos/3x2-11.jpg',
'images/photos/2x3-5.jpg',
'images/photos/3x2-13.jpg',
'images/photos/3x2-14.jpg',
'images/photos/2x3-6.jpg',
'images/photos/3x2-15.jpg',
'images/photos/3x2-16.jpg',
'images/photos/2x3-7.jpg'
].map(function (e) {
return (0,
s.jsxs)(o.W0, { style: { margin: '2px', width: 'calc(100% / 5 - 4.2px)' }, children: [(0, s.jsx)(o.i4, { style: { paddingBottom: 'calc(100% / 1.5)' }, children: (0, s.jsx)(o.OM, { src: e }) }), (0, s.jsx)(o.Bx, { children: (0, s.jsx)(o.rj, { children: 'Text label' }) })] }, e);
})
})
}),
(0, s.jsx)(r.sb, { children: 'Masonry Layout' }),
(0, s.jsx)(r.q3, {
children: (0, s.jsx)(o.Y, {
masonry: !0,
withTextProtection: !0,
style: {
columnCount: 5,
columnGap: '16px',
maxWidth: '1000px'
},
children: [
'images/photos/3x2-1.jpg',
'images/photos/2x3-1.jpg',
'images/photos/3x2-4.jpg',
'images/photos/3x2-5.jpg',
'images/photos/2x3-5.jpg',
'images/photos/3x2-6.jpg',
'images/photos/2x3-2.jpg',
'images/photos/3x2-8.jpg',
'images/photos/3x2-11.jpg',
'images/photos/3x2-13.jpg',
'images/photos/3x2-14.jpg',
'images/photos/2x3-6.jpg',
'images/photos/3x2-15.jpg',
'images/photos/2x3-7.jpg',
'images/photos/3x2-16.jpg'
].map(function (e) {
return (0,
s.jsxs)(o.W0, { style: { marginBottom: '16px' }, children: [(0, s.jsx)(o.OM, { src: e }), (0, s.jsx)(o.Bx, { children: (0, s.jsx)(o.rj, { children: 'Text label' }) })] }, e);
})
})
}),
(0, s.jsx)(r.PQ, {
src: i,
components: [
{ displayName: 'ImageList', component: o.Y },
{ displayName: 'ImageListItem', component: o.W0 },
{
displayName: 'ImageListImageAspectContainer',
component: o.i4
},
{ displayName: 'ImageListImage', component: o.OM },
{ displayName: 'ImageListSupporting', component: o.Bx },
{ displayName: 'ImageListLabel', component: o.rj }
]
})
]
});
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
s = function (e, t) {
return (
(s =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
s(e, t)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
s
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
l = function () {
return (
(l =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
l.apply(this, arguments)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
var r = e.call(this, l(l({}, t.defaultAdapter), n)) || this;
return (
(r.transitionEndHandler_ = function (e) {
return r.handleTransitionEnd(e);
}),
r
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
s = function (e, t) {
return (
(s =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
s(e, t)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
s
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
l = function () {
return (
(l =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
l.apply(this, arguments)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function u(e) {
return (
Boolean(e.document) &&
'function' === typeof e.document.createElement
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function e(e) {
void 0 === e && (e = {}), (this.adapter = e);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
e
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
return e.call(this, l(l({}, t.defaultAdapter), n)) || this;
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
t = function (e, t, n, r) {
var i,
a =
null !==
(i =
null === e || void 0 === e
? void 0
: e.querySelector(t)) && void 0 !== i
? i
: null;
a && (a.style[n] = r);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function l() {
return (0, s.jsxs)(r.WI, {
title: 'Linear Progress',
lead: 'Progress and activity indicators are visual indications of an app loading content.',
module: '@rmwc/linear-progress',
styles: ['@material/linear-progress/dist/mdc.linear-progress.css'],
docsLink:
'https://material.io/develop/web/components/linear-progress/',
examples: a,
children: [
(0, s.jsx)(r.q3, {
label: 'Default',
children: (0, s.jsx)(o.u, { progress: 0.5 })
}),
(0, s.jsx)(r.q3, {
label: 'Buffered',
children: (0, s.jsx)(o.u, { progress: 0.6, buffer: 0.8 })
}),
(0, s.jsx)(r.q3, {
label: 'Indeterminate',
children: (0, s.jsx)(o.u, {})
}),
(0, s.jsx)(r.q3, {
label: 'Reversed',
children: (0, s.jsx)(o.u, { progress: 0.2, reversed: !0 })
}),
(0, s.jsx)(r.PQ, {
src: i,
components: [{ displayName: 'LinearProgress', component: o.u }]
})
]
});
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
g = function (e) {
if (!e) return !1;
var t = e.getAttribute('tabindex');
return !!(t && Number(t) >= 0) && (e.focus(), !0);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
g
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
b = function e(t, n) {
if (!t) return null;
var r = n ? t.previousElementSibling : t.nextElementSibling;
return null === r ? e(t.parentElement, n) : r;
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
b
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n(e) {
var r;
return (
(0, a.Z)(this, n),
((r = t.call(this, e)).childContainer = null),
(r.root = null),
(r.rafId = null),
(r.timerId = null),
(r.state = {
open: !!r.props.defaultOpen || !!r.props.open,
childrenStyle: {}
}),
(r.handleClick = r.handleClick.bind((0, s.Z)(r))),
(r.handleKeydown = r.handleKeydown.bind((0, s.Z)(r))),
(r.handleFocus = r.handleFocus.bind((0, s.Z)(r))),
r
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
s = function (e, t) {
return (
(s =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
s(e, t)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
s
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
l = function () {
return (
(l =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
l.apply(this, arguments)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
f = function (e) {
var t = e.target;
if (t) {
var n = ('' + t.tagName).toLowerCase();
-1 === p.indexOf(n) && e.preventDefault();
}
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
f
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function m(e, t) {
var n,
r = e.nextChar,
i = e.focusItemAtIndex,
a = e.sortedIndexByFirstChar,
o = e.focusedItemIndex,
s = e.skipFocus,
l = e.isItemAtIndexDisabled;
return (
clearTimeout(t.bufferClearTimeout),
(t.bufferClearTimeout = setTimeout(function () {
g(t);
}, d.KT.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS)),
(t.typeaheadBuffer = t.typeaheadBuffer + r),
(n =
1 === t.typeaheadBuffer.length
? (function (e, t, n, r) {
var i = r.typeaheadBuffer[0],
a = e.get(i);
if (!a) return -1;
if (
i === r.currentFirstChar &&
a[r.sortedIndexCursor].index === t
) {
r.sortedIndexCursor =
(r.sortedIndexCursor + 1) % a.length;
var o = a[r.sortedIndexCursor].index;
if (!n(o)) return o;
}
r.currentFirstChar = i;
var s,
l = -1;
for (s = 0; s < a.length; s++)
if (!n(a[s].index)) {
l = s;
break;
}
for (; s < a.length; s++)
if (a[s].index > t && !n(a[s].index)) {
l = s;
break;
}
if (-1 !== l)
return (
(r.sortedIndexCursor = l), a[r.sortedIndexCursor].index
);
return -1;
})(a, o, l, t)
: (function (e, t, n) {
var r = n.typeaheadBuffer[0],
i = e.get(r);
if (!i) return -1;
var a = i[n.sortedIndexCursor];
if (
0 === a.text.lastIndexOf(n.typeaheadBuffer, 0) &&
!t(a.index)
)
return a.index;
var o = (n.sortedIndexCursor + 1) % i.length,
s = -1;
for (; o !== n.sortedIndexCursor; ) {
var l = i[o],
c = 0 === l.text.lastIndexOf(n.typeaheadBuffer, 0),
u = !t(l.index);
if (c && u) {
s = o;
break;
}
o = (o + 1) % i.length;
}
if (-1 !== s)
return (
(n.sortedIndexCursor = s), i[n.sortedIndexCursor].index
);
return -1;
})(a, l, t)),
-1 === n || s || i(n),
n
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
m
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function h(e) {
return e.typeaheadBuffer.length > 0;
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
h
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function g(e) {
e.typeaheadBuffer = '';
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
g
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function b(e, t) {
var n = e.event,
r = e.isTargetListItem,
i = e.focusedItemIndex,
a = e.focusItemAtIndex,
o = e.sortedIndexByFirstChar,
s = e.isItemAtIndexDisabled,
l = 'ArrowLeft' === (0, u.ku)(n),
c = 'ArrowUp' === (0, u.ku)(n),
d = 'ArrowRight' === (0, u.ku)(n),
p = 'ArrowDown' === (0, u.ku)(n),
g = 'Home' === (0, u.ku)(n),
b = 'End' === (0, u.ku)(n),
v = 'Enter' === (0, u.ku)(n),
x = 'Spacebar' === (0, u.ku)(n);
return l || c || d || p || g || b || v
? -1
: x || 1 !== n.key.length
? x
? (r && f(n),
r && h(t)
? m(
{
focusItemAtIndex: a,
focusedItemIndex: i,
nextChar: ' ',
sortedIndexByFirstChar: o,
skipFocus: !1,
isItemAtIndexDisabled: s
},
t
)
: -1)
: -1
: (f(n),
m(
{
focusItemAtIndex: a,
focusedItemIndex: i,
nextChar: n.key.toLowerCase(),
sortedIndexByFirstChar: o,
skipFocus: !1,
isItemAtIndexDisabled: s
},
t
));
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
b
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
var r = e.call(this, l(l({}, t.defaultAdapter), n)) || this;
return (
(r.wrapFocus_ = !1),
(r.isVertical_ = !0),
(r.isSingleSelectionList_ = !1),
(r.selectedIndex_ = d.KT.UNSET_INDEX),
(r.focusedItemIndex = d.KT.UNSET_INDEX),
(r.useActivatedClass_ = !1),
(r.ariaCurrentAttrValue_ = null),
(r.isCheckboxList_ = !1),
(r.isRadioList_ = !1),
(r.hasTypeahead = !1),
(r.typeaheadState = {
bufferClearTimeout: 0,
currentFirstChar: '',
sortedIndexCursor: 0,
typeaheadBuffer: ''
}),
(r.sortedIndexByFirstChar = new Map()),
r
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function c() {
return (0, l.jsxs)(r.WI, {
title: 'Lists',
lead: 'Lists are continuous, vertical indexes of text or images.',
module: '@rmwc/list',
styles: [
'@material/list/dist/mdc.list.css',
'@material/ripple/dist/mdc.ripple.css',
'@rmwc/icon/icon.css'
],
docsLink: 'https://material.io/develop/web/components/lists/',
examples: a,
children: [
(0, l.jsx)(r.sb, { children: 'Basic Usage' }),
(0, l.jsx)(r.q3, {
label: 'Default',
children: (0, l.jsxs)(o.a, {
children: [
(0, l.jsx)(s.HC, { children: 'Cookies' }),
(0, l.jsx)(s.HC, { children: 'Pizza' }),
(0, l.jsx)(s.HC, { children: 'Icecream' })
]
})
}),
(0, l.jsx)(r.q3, {
label: 'Fully Featured',
children: (0, l.jsxs)(o.a, {
twoLine: !0,
children: [
(0, l.jsxs)(s.HC, {
children: [
(0, l.jsx)(s.rk, { icon: 'star_border' }),
(0, l.jsxs)(s.F_, {
children: [
(0, l.jsx)(s.iY, { children: 'Cookies' }),
(0, l.jsx)(s.N0, { children: '$4.99 a dozen' })
]
}),
(0, l.jsx)(s.GN, { icon: 'info' })
]
}),
(0, l.jsxs)(s.HC, {
children: [
(0, l.jsx)(s.rk, { icon: 'local_pizza' }),
(0, l.jsxs)(s.F_, {
children: [
(0, l.jsx)(s.iY, { children: 'Pizza' }),
(0, l.jsx)(s.N0, { children: '$1.99 a slice' })
]
}),
(0, l.jsx)(s.GN, { icon: 'info' })
]
}),
(0, l.jsxs)(s.HC, {
activated: !0,
children: [
(0, l.jsx)(s.rk, { icon: 'mood' }),
(0, l.jsxs)(s.F_, {
children: [
(0, l.jsx)(s.iY, { children: 'Icecream' }),
(0, l.jsx)(s.N0, { children: '$0.99 a scoop' })
]
}),
(0, l.jsx)(s.GN, { children: 'Winner!' })
]
})
]
})
}),
(0, l.jsx)(r.sb, { children: 'Simplified Usage' }),
(0, l.jsx)(r.PJ, {
children:
'While there are siutations where you would need / want to compose the entire list yourself, it can be quite verbose. `SimpleListItem` provides a compact syntax that allows you to pass all options as props. The following example is roughly equivalent to the one above.'
}),
(0, l.jsx)(r.q3, {
label: 'Simple',
children: (0, l.jsxs)(o.a, {
twoLine: !0,
children: [
(0, l.jsx)(s.ug, {
graphic: 'star_border',
text: 'Cookies',
secondaryText: 'Chocolate chip',
metaIcon: 'info'
}),
(0, l.jsx)(s.ug, {
graphic: 'local_pizza',
text: 'Pizza',
secondaryText: 'Pepperoni',
metaIcon: 'info'
}),
(0, l.jsx)(s.ug, {
activated: !0,
graphic: 'mood',
text: 'Icecream',
secondaryText: 'Chocolate cookie dough',
meta: 'Winner!'
})
]
})
}),
(0, l.jsx)(r.PQ, {
src: i,
components: [
{ displayName: 'List', component: o.a },
{ displayName: 'ListItem', component: s.HC },
{ displayName: 'ListItemPrimaryText', component: s.iY },
{ displayName: 'ListItemSecondaryText', component: s.N0 },
{ displayName: 'ListItemGraphic', component: s.rk },
{ displayName: 'ListItemMeta', component: s.GN },
{ displayName: 'ListDivider', component: s.Rx },
{ displayName: 'ListGroup', component: s.NX },
{ displayName: 'ListGroupSubheader', component: s.JV },
{ displayName: 'SimpleListItem', component: s.ug }
]
})
]
});
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
c
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
g = function (e, t) {
var n = (0, o.useState)(e.open),
s = (0, l.Z)(n, 2),
g = s[0],
b = s[1],
v = (0, o.useRef)(null),
x = (0, o.useRef)(null),
y = (0, o.useRef)(null),
k = (0, o.useRef)(null),
w = (0, c.j)({
props: e,
elements: { rootEl: !0 },
api: function (e) {
var t = e.foundation,
n = e.rootEl;
return {
setAnchorCorner: function (e) {
return t.setAnchorCorner(e);
},
setAnchorElement: function (e) {
return (y.current = e);
},
setOpen: function (e) {
return b(e);
},
getSurfaceElement: function () {
return n.ref;
}
};
},
foundation: function (e) {
var t = e.rootEl,
n = e.getProps,
a = e.emit,
o = function (e) {
E.handleBodyClick(e);
},
s = function () {
document.body.removeEventListener('click', o),
document.body.removeEventListener('touchstart', o);
},
l = new f.k(
(0, i.Z)(
(0, i.Z)(
{
addClass: function (e) {
t.addClass(e);
},
removeClass: function (e) {
t.removeClass(e);
},
hasClass: function (e) {
return 'mdc-menu-surface' === e || t.hasClass(e);
},
hasAnchor: function () {
return !!y.current;
},
notifyClose: function () {
s(), b(!1);
},
notifyOpen: function () {
a('onOpen', {}),
setTimeout(function () {
document.body.addEventListener('click', o),
document.body.addEventListener(
'touchstart',
o
);
}, 150);
},
isElementInContainer: function (e) {
return (
t.ref === e || (!!t.ref && t.ref.contains(e))
);
},
isRtl: function () {
return (
!!t.ref &&
'rtl' ===
getComputedStyle(t.ref).getPropertyValue(
'direction'
)
);
},
setTransformOrigin: function (e) {
t.setStyle(
''.concat(
(function (e, t) {
if (
(void 0 === t && (t = !1),
void 0 === r || t)
) {
var n = e.document.createElement('div');
r =
'transform' in n.style
? 'transform'
: 'webkitTransform';
}
return r;
})(window),
'-origin'
),
e
);
}
},
{
isFocused: function () {
return document.activeElement === t.ref;
},
saveFocus: function () {
x.current = document.activeElement;
},
restoreFocus: function () {
t.ref &&
t.ref.contains(document.activeElement) &&
x.current &&
x.current.focus &&
x.current.focus();
},
isFirstElementFocused: function () {
return (
!!v.current &&
v.current === document.activeElement
);
},
isLastElementFocused: function () {
return (
!!v.current &&
v.current === document.activeElement
);
},
focusFirstElement: function () {
return (
!!v.current &&
v.current.focus &&
v.current.focus()
);
},
focusLastElement: function () {
return (
!!v.current &&
v.current.focus &&
v.current.focus()
);
}
}
),
{
getInnerDimensions: function () {
return {
width: t.ref ? t.ref.offsetWidth : 0,
height: t.ref ? t.ref.offsetHeight : 0
};
},
getAnchorDimensions: function () {
var e;
return (
(null === (e = y.current) || void 0 === e
? void 0
: e.getBoundingClientRect()) || u.B
);
},
getWindowDimensions: function () {
return {
width: window.innerWidth,
height: window.innerHeight
};
},
getBodyDimensions: function () {
return {
width: document.body.clientWidth,
height: document.body.clientHeight
};
},
getWindowScroll: function () {
return {
x: window.pageXOffset,
y: window.pageYOffset
};
},
setPosition: function (e) {
t.setStyle(
'left',
void 0 !== e.left ? e.left : null
),
t.setStyle(
'right',
void 0 !== e.right ? e.right : null
),
t.setStyle(
'top',
void 0 !== e.top ? e.top : null
),
t.setStyle(
'bottom',
void 0 !== e.bottom ? e.bottom : null
);
},
setMaxHeight: function (e) {
t.setStyle('maxHeight', e);
}
}
)
),
c = l.close.bind(l);
l.close = function () {
var e =
arguments.length > 0 &&
void 0 !== arguments[0] &&
arguments[0];
a('onClose', {}),
(k.current = window.setTimeout(function () {
n().open || c(e);
}));
};
var d = l.destroy.bind(l);
return (
(l.destroy = function () {
s(), d();
}),
l
);
}
}),
E = w.foundation,
T = (0, a.Z)(w, m),
C = T.rootEl,
S = e.onKeyDown,
_ = (0, o.useCallback)(
function (e) {
null === S || void 0 === S || S(e), E.handleKeydown(e);
},
[S, E]
);
return (
C.setProp('onKeyDown', _, !0),
(0, o.useEffect)(
function () {
E.setFixedPosition(!!e.fixed);
},
[e.fixed, E]
),
(0, o.useEffect)(
function () {
var e =
(null === t || void 0 === t ? void 0 : t.current) || C.ref;
if (e) {
var n = (0, d.o)(e, '.'.concat(f.k.cssClasses.ANCHOR));
n && (y.current = n);
}
},
[t, C.ref]
),
(0, o.useEffect)(
function () {
e.renderToPortal ? E.setIsHoisted(!0) : E.setIsHoisted(!1);
var t = e.renderToPortal
? function () {
try {
E.autoposition();
} catch (e) {}
}
: function () {};
return (
(0, p.W)(function () {
E.isOpen();
}),
window.addEventListener('resize', t),
function () {
window.removeEventListener('resize', t);
}
);
},
[e.renderToPortal, E]
),
(0, o.useEffect)(
function () {
var t =
e.anchorCorner &&
(function (e) {
return f.k.Corner[h[e]];
})(e.anchorCorner);
if (void 0 !== t) {
E.setAnchorCorner(t),
(E.dimensions = E.adapter.getInnerDimensions());
try {
E.autoposition();
} catch (n) {}
}
},
[e.anchorCorner, E]
),
(0, o.useEffect)(
function () {
if (g) {
var e = C.ref
? C.ref.querySelectorAll(f.k.strings.FOCUSABLE_ELEMENTS)
: [];
(v.current = e.length > 0 ? e[0] : null), E.open();
} else E.isOpen() && E.close();
},
[g, E, C.ref]
),
(0, o.useEffect)(
function () {
b(!!e.open);
},
[e.open]
),
(0, o.useEffect)(function () {
return function () {
k.current && window.clearTimeout(k.current);
};
}, []),
(0, i.Z)({}, T)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
g
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
s = function () {
document.body.removeEventListener('click', o),
document.body.removeEventListener('touchstart', o);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
s
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
m = function (e, t) {
return (
(m =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
m(e, t)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
m
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
h = function () {
return (
(h =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
h.apply(this, arguments)
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
h
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
var r = e.call(this, h(h({}, t.defaultAdapter), n)) || this;
return (
(r.closeAnimationEndTimerId_ = 0),
(r.defaultFocusState_ = g.LIST_ROOT),
r
);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
O = function (e) {
return 'MenuItems' === (0, u.G)(e);
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
O
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
N = function (e) {
return function (t) {
var n = (0, o.useState)(!!t.open),
s = (0, r.Z)(n, 2),
l = s[0],
c = s[1];
(0, o.useEffect)(
function () {
void 0 !== t.open && t.open !== l && c(!!t.open);
},
[t.open, l]
);
var u = t.handle,
d = t.onClose,
p = t.children,
m = t.rootProps,
h = void 0 === m ? {} : m,
g = t.open,
b = (t.foundationRef, (0, i.Z)(t, A)),
v = o.cloneElement(
u,
(0, a.Z)(
(0, a.Z)({}, u.props),
{},
{
onClick: function (e) {
c(!l), u.props.onClick && u.props.onClick(e);
}
}
)
),
x = e;
return (0, _.jsxs)(
f.W,
(0, a.Z)(
(0, a.Z)({}, h),
{},
{
children: [
(0, _.jsx)(
x,
(0, a.Z)(
(0, a.Z)({}, b),
{},
{
onClose: function (e) {
c(!!g || !1), null === d || void 0 === d || d(e);
},
open: l,
children: p
}
)
),
v
]
}
)
);
};
}
|
\\n * Set the option globally throug RMWCProvider\\n * Glyphicons <span class=\\\"glyphicons glyphicons-heart\\\"></span>\\n *
|
N
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function g() {
return (0, h.jsxs)(a.WI, {
title: 'Menus',
lead: 'Menus display a list of choices on a transient sheet of material.',
module: '@rmwc/menu',
styles: [
'@material/menu/dist/mdc.menu.css',
'@material/menu-surface/dist/mdc.menu-surface.css',
'@material/ripple/dist/mdc.ripple.css',
'@material/list/dist/mdc.list.css',
'@rmwc/icon/icon.css'
],
docsLink: 'https://material.io/develop/web/components/menus/',
examples: s,
children: [
(0, h.jsx)(a.sb, { children: 'Basic Usage' }),
(0, h.jsx)(a.PJ, {
children:
'You can compose a menu with the given components, and manually manage the open state. `Menu` expects MenuItems as children while `MenuSurface` is a generic container which can have anything as a child.'
}),
(0, h.jsx)(a.q3, {
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, h.jsxs)(l.W, {
children: [
(0, h.jsxs)(c.v2, {
open: n,
onSelect: function (e) {
return console.log(e.detail.index);
},
onClose: function (e) {
return a(!1);
},
children: [
(0, h.jsx)(c.sN, { children: 'Cookies' }),
(0, h.jsx)(c.sN, { children: 'Pizza' }),
(0, h.jsx)(u.Rx, {}),
(0, h.jsx)(c.sN, { children: 'Icecream' })
]
}),
(0, h.jsx)(d.z, {
raised: !0,
onClick: function (e) {
return a(!n);
},
children: 'Menu'
})
]
});
}
}),
(0, h.jsx)(a.q3, {
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, h.jsxs)(l.W, {
children: [
(0, h.jsx)(l.g, {
open: n,
onClose: function (e) {
return a(!1);
},
children: (0, h.jsx)('div', {
style: { padding: '1rem', width: '8rem' },
children: 'Make the content whatever you want.'
})
}),
(0, h.jsx)(d.z, {
raised: !0,
onClick: function (e) {
return a(!n);
},
children: 'Menu Surface'
})
]
});
}
}),
(0, h.jsx)(a.q3, {
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, h.jsxs)(l.W, {
children: [
(0, h.jsx)(l.g, {
open: n,
onClose: function (e) {
return a(!1);
},
children: (0, h.jsx)('div', {
style: { padding: '1rem', width: '8rem' },
children: 'Menu'
})
}),
(0, h.jsx)(f.h, {
icon: 'menu',
onClick: function (e) {
return a(!n);
}
})
]
});
}
}),
(0, h.jsx)(a.q3, {
children: function () {
var e = i.useState(!1),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, h.jsxs)(l.W, {
children: [
(0, h.jsxs)(c.v2, {
open: n,
onSelect: function (e) {
return console.log(e.detail.index);
},
onClose: function (e) {
return a(!1);
},
children: [
(0, h.jsx)(c.sN, { children: 'Item One' }),
(0, h.jsx)(c.sN, {
disabled: !0,
children: 'Item Two (disabled)'
}),
(0, h.jsx)(c.sN, { children: 'Item Three' })
]
}),
(0, h.jsx)(d.z, {
raised: !0,
onClick: function () {
return a(!n);
},
children: 'Menu'
})
]
});
}
}),
(0, h.jsx)(a.sb, { children: 'Simplified usage' }),
(0, h.jsx)(a.PJ, {
children:
'RMWC provides a convenience `SimpleMenu` component that takes a handle as a prop, and manages the open state for you.'
}),
(0, h.jsx)(a.q3, {
children: (0, h.jsxs)(c.O2, {
handle: (0, h.jsx)(d.z, { children: 'Simple Menu' }),
children: [
(0, h.jsx)(c.sN, { children: 'Cookies' }),
(0, h.jsx)(c.sN, { children: 'Pizza' }),
(0, h.jsx)(c.sN, { children: 'Icecream' })
]
})
}),
(0, h.jsx)(a.q3, {
children: (0, h.jsx)(c.jf, {
handle: (0, h.jsx)(d.z, { children: 'Simple Menu Surface' }),
children: (0, h.jsx)('div', {
style: { padding: '1rem', width: '8rem' },
children: 'Make the content whatever you want.'
})
})
}),
(0, h.jsx)(a.sb, { children: 'Anchoring' }),
(0, h.jsx)(a.PJ, {
children:
'By default, Menus will attempt to automatically position themselves, but this behavior can be overridden by setting the `anchorCorner` prop.'
}),
(0, h.jsx)(a.q3, {
children: function () {
var e = i.useState('topLeft'),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, h.jsxs)(h.Fragment, {
children: [
(0, h.jsxs)(l.W, {
children: [
(0, h.jsx)(l.g, {
anchorCorner: n,
open: !0,
children: (0, h.jsxs)('div', {
style: { padding: '1rem', width: '8rem' },
children: ['anchorCorner: ', n]
})
}),
(0, h.jsx)(d.z, {
raised: !0,
label: 'Anchored Menu'
})
]
}),
(0, h.jsx)(p.P, {
value: n,
label: 'anchorCorner',
onChange: function (e) {
return a(e.currentTarget.value);
},
options: [
'topLeft',
'topRight',
'bottomLeft',
'bottomRight',
'topStart',
'topEnd',
'bottomStart',
'bottomEnd'
]
})
]
});
}
}),
(0, h.jsx)(a.sb, { children: 'Rendering through Portals' }),
(0, h.jsx)(a.PJ, {
children:
"Occasionally, you may find your menu being cut off from being inside a container that is styled to be `overflow:hidden`. RMWC provides a `renderToPortal` prop that lets you use React's portal functionality to render the menu dropdown in a different container."
}),
(0, h.jsx)(a.PJ, {
children:
"You can specify any element or selector you want, but the simplest method is to pass `true` and use RMWC's built in `Portal` component."
}),
(0, h.jsx)(a.q3, {
codeOnly: !0,
children:
"\n // Somewhere at the top level of your app\n // Render the RMWC Portal\n // You only have to do this once\n import React from 'react';\n import { Portal } from '@rmwc/base';\n\n export default function App() {\n return (\n <div>\n ...\n <Portal />\n </div>\n )\n }\n "
}),
(0, h.jsx)(a.PJ, {
children:
'Now you can use the `renderToPortal` prop. Below is a contrived example of a menu being cut off due to `overflow: hidden`.'
}),
(0, h.jsx)(a.q3, {
children: function () {
var e = i.useState(!0),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1],
o = i.useState(!1),
s = (0, r.Z)(o, 2),
u = s[0],
p = s[1];
return (0, h.jsxs)(h.Fragment, {
children: [
(0, h.jsx)('div', {
style: {
marginBottom: '10rem',
height: '3.5rem',
overflow: 'hidden'
},
children: (0, h.jsxs)(l.W, {
children: [
(0, h.jsx)(d.z, {
raised: !0,
onClick: function () {
return p(!u);
},
children: 'Open Menu'
}),
(0, h.jsx)(c.v2, {
open: u,
onClose: function () {
return p(!1);
},
renderToPortal: n,
children: ['Cookies', 'Pizza', 'Icecream'].map(
function (e) {
return (0, h.jsx)(c.sN, { children: e }, e);
}
)
})
]
})
}),
(0, h.jsx)(m.X, {
checked: n,
onChange: function (e) {
return a(e.currentTarget.checked);
},
label: 'renderToPortal'
})
]
});
}
}),
(0, h.jsx)(a.PQ, {
src: o,
components: [
{ displayName: 'Menu', component: c.v2 },
{ displayName: 'MenuItem', component: c.sN },
{ displayName: 'MenuSurface', component: l.g },
{ displayName: 'MenuSurfaceAnchor', component: l.W },
{ displayName: 'SimpleMenu', component: c.O2 },
{ displayName: 'SimpleMenuSurface', component: c.jf }
]
})
]
});
}
|
The handle can be any component you want
|
g
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
s = function (e, t) {
return (
(s =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
s(e, t)
);
}
|
The handle can be any component you want
|
s
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
l = function () {
return (
(l =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
l.apply(this, arguments)
);
}
|
The handle can be any component you want
|
l
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
return e.call(this, l(l({}, t.defaultAdapter), n)) || this;
}
|
The handle can be any component you want
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
The handle can be any component you want
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
u = function () {
return a.useContext(c);
}
|
The handle can be any component you want
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
d = function (e) {
var t = e.children,
n = (0, i.Z)(e, s);
return (0, o.jsx)(c.Provider, {
value: (0, r.Z)((0, r.Z)({}, l), n),
children: t
});
}
|
The handle can be any component you want
|
d
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
u = function (e, t) {
return (
(u =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
u(e, t)
);
}
|
The handle can be any component you want
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
d = function () {
return (
(d =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
d.apply(this, arguments)
);
}
|
The handle can be any component you want
|
d
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
return e.call(this, d(d({}, t.defaultAdapter), n)) || this;
}
|
The handle can be any component you want
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
The handle can be any component you want
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function u() {
return (0, c.jsxs)(a.WI, {
title: 'Radio Buttons',
lead: 'Radio buttons allow the user to select one option from a set. Use radio buttons for exclusive selection if you think that the user needs to see all available options side-by-side.',
module: '@rmwc/radio',
styles: [
'@material/radio/dist/mdc.radio.css',
'@material/form-field/dist/mdc.form-field.css',
'@material/ripple/dist/mdc.ripple.css'
],
docsLink:
'https://material.io/develop/web/components/input-controls/radio-buttons/',
examples: s,
children: [
(0, c.jsx)(a.sb, { children: 'Controlled Usage' }),
(0, c.jsx)(a.q3, {
children: function () {
var e = i.useState('cookies'),
t = (0, r.Z)(e, 2),
n = t[0],
a = t[1];
return (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(l.Y, {
value: 'cookies',
checked: 'cookies' === n,
onChange: function (e) {
return a(String(e.currentTarget.value));
},
children: 'Cookies'
}),
(0, c.jsx)(l.Y, {
value: 'pizza',
checked: 'pizza' === n,
onChange: function (e) {
return a(String(e.currentTarget.value));
},
children: 'Pizza'
}),
(0, c.jsx)(l.Y, {
value: 'icecream',
checked: 'icecream' === n,
onChange: function (e) {
return a(String(e.currentTarget.value));
},
children: 'Icecream'
})
]
});
}
}),
(0, c.jsx)(a.sb, { children: 'Uncontrolled Usage' }),
(0, c.jsx)(a.PJ, {
children:
'You can use Radio Buttons and receive change events without having to manually set the `checked` prop. Just give the Radio components the same `name`. This example also shows using the `label` prop instead of setting the label as a child.'
}),
(0, c.jsx)(a.q3, {
children: (0, c.jsxs)(c.Fragment, {
children: [
(0, c.jsx)(l.Y, {
label: 'Cookies',
value: 'cookies',
name: 'myRadioGroup',
onChange: function (e) {
return console.log(e.currentTarget.value);
}
}),
(0, c.jsx)(l.Y, {
label: 'Pizza',
value: 'pizza',
name: 'myRadioGroup',
onChange: function (e) {
return console.log(e.currentTarget.value);
}
}),
(0, c.jsx)(l.Y, {
label: 'Icecream',
value: 'icecream',
name: 'myRadioGroup',
onChange: function (e) {
return console.log(e.currentTarget.value);
}
})
]
})
}),
(0, c.jsx)(a.PQ, {
src: o,
components: [{ displayName: 'Radio', component: l.Y }]
})
]
});
}
|
The handle can be any component you want
|
u
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
b = function (e, t) {
return (
(b =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
}),
b(e, t)
);
}
|
The handle can be any component you want
|
b
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
v = function () {
return (
(v =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in (t = arguments[n]))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
v.apply(this, arguments)
);
}
|
The handle can be any component you want
|
v
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function t(n) {
var r = e.call(this, v(v({}, t.defaultAdapter), n)) || this;
return (
(r.activationAnimationHasEnded_ = !1),
(r.activationTimer_ = 0),
(r.fgDeactivationRemovalTimer_ = 0),
(r.fgScale_ = '0'),
(r.frame_ = { width: 0, height: 0 }),
(r.initialSize_ = 0),
(r.layoutFrame_ = 0),
(r.maxRadius_ = 0),
(r.unboundedCoords_ = { left: 0, top: 0 }),
(r.activationState_ = r.defaultActivationState_()),
(r.activationTimerCallback_ = function () {
(r.activationAnimationHasEnded_ = !0),
r.runDeactivationUXLogicIfReady_();
}),
(r.activateHandler_ = function (e) {
return r.activate_(e);
}),
(r.deactivateHandler_ = function () {
return r.deactivate_();
}),
(r.focusHandler_ = function () {
return r.handleFocus();
}),
(r.blurHandler_ = function () {
return r.handleBlur();
}),
(r.resizeHandler_ = function () {
return r.layout();
}),
r
);
}
|
The handle can be any component you want
|
t
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function n() {
this.constructor = e;
}
|
The handle can be any component you want
|
n
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
A = function (e) {
var t = (0, c.useRef)(!1),
n = (0, m.j)({
props: e,
elements: { rootEl: !0, surfaceEl: !0 },
foundation: function (e) {
var t = e.rootEl,
n = e.surfaceEl,
r = e.getProps;
return new _({
browserSupportsCssVars: function () {
return (function (e, t) {
void 0 === t && (t = !1);
var n,
r = e.CSS;
if ('boolean' === typeof x && !t) return x;
if (!r || 'function' !== typeof r.supports) return !1;
var i = r.supports('--css-vars', 'yes'),
a =
r.supports('(--css-vars: yes)') &&
r.supports('color', '#00000000');
return (n = i || a), t || (x = n), n;
})(window);
},
isUnbounded: function () {
return !!r().unbounded;
},
isSurfaceActive: function () {
return !!t.ref && (0, g.w)(t.ref, ':active');
},
isSurfaceDisabled: function () {
return !!r().disabled;
},
addClass: function (e) {
n.addClass(e);
},
removeClass: function (e) {
n.removeClass(e);
},
containsEventTarget: function (e) {
return !!t.ref && t.ref.contains(e);
},
registerInteractionHandler: function (e, t) {},
deregisterInteractionHandler: function (e, t) {},
registerDocumentInteractionHandler: function (e, t) {
return document.documentElement.addEventListener(e, t, {
passive: !0
});
},
deregisterDocumentInteractionHandler: function (e, t) {
return document.documentElement.removeEventListener(e, t);
},
registerResizeHandler: function (e) {
return window.addEventListener('resize', e);
},
deregisterResizeHandler: function (e) {
return window.removeEventListener('resize', e);
},
updateCssVariable: function (e, t) {
return n.setStyle(e, t);
},
computeBoundingRect: function () {
return t.ref ? t.ref.getBoundingClientRect() : h.B;
},
getWindowPageOffset: function () {
return { x: window.pageXOffset, y: window.pageYOffset };
}
});
}
}),
a = n.foundation,
o = (0, r.Z)(n, P),
s = o.rootEl,
l = (0, c.useCallback)(
function (e) {
e.persist(), a.activate(e);
},
[a]
),
u = (0, c.useCallback)(
function (e) {
e.persist(), a.deactivate();
},
[a]
),
d = e.onFocus,
p = (0, c.useCallback)(
function (e) {
null === d || void 0 === d || d(e), a.handleFocus();
},
[a, d]
),
f = e.onBlur,
b = (0, c.useCallback)(
function (e) {
null === f || void 0 === f || f(e), a.handleBlur();
},
[a, f]
),
v = e.onMouseDown,
y = (0, c.useCallback)(
function (e) {
null === v || void 0 === v || v(e),
t.current || l(e),
(t.current = !1);
},
[v, l]
),
k = e.onMouseUp,
w = (0, c.useCallback)(
function (e) {
null === k || void 0 === k || k(e), u(e);
},
[k, u]
),
E = e.onTouchStart,
T = (0, c.useCallback)(
function (e) {
(t.current = !0), null === E || void 0 === E || E(e), l(e);
},
[E, l]
),
C = e.onTouchEnd,
S = (0, c.useCallback)(
function (e) {
null === C || void 0 === C || C(e), u(e);
},
[C, u]
),
A = e.onKeyDown,
I = (0, c.useCallback)(
function (e) {
null === A || void 0 === A || A(e), l(e);
},
[A, l]
),
R = e.onKeyUp,
O = (0, c.useCallback)(
function (e) {
null === R || void 0 === R || R(e), u(e);
},
[R, u]
);
return (
s.setProp('onFocus', p, !0),
s.setProp('onBlur', b, !0),
s.setProp('onMouseDown', y, !0),
s.setProp('onMouseUp', w, !0),
s.setProp('onTouchStart', T, !0),
s.setProp('onTouchEnd', S, !0),
s.setProp('onKeyDown', I, !0),
s.setProp('onKeyUp', O, !0),
(0, c.useEffect)(
function () {
s.setRef(e.domNode);
},
[s, e.domNode]
),
(0, c.useEffect)(
function () {
a.setUnbounded(!!e.unbounded);
},
[e.unbounded, a]
),
(0, c.useEffect)(
function () {
e.disabled && a.handleBlur();
},
[e.disabled, a]
),
(0, i.Z)({}, o)
);
}
|
The handle can be any component you want
|
A
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
function r() {
var e;
(0, a.Z)(this, r);
for (
var t = arguments.length, i = new Array(t), o = 0;
o < t;
o++
)
i[o] = arguments[o];
return (
((e = n.call.apply(n, [this].concat(i))).state = {
domNode: null
}),
e
);
}
|
The handle can be any component you want
|
r
|
javascript
|
rmwc/rmwc
|
docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
https://github.com/rmwc/rmwc/blob/master/docs/version/8.0.8/static/js/main.6c3f4ae5.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.