@webiny/ui 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.97a151f74d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion/Accordion.d.ts +1 -1
- package/Accordion/Accordion.js +1 -5
- package/Accordion/Accordion.js.map +1 -1
- package/Accordion/AccordionItem.d.ts +18 -2
- package/Accordion/AccordionItem.js +48 -49
- package/Accordion/AccordionItem.js.map +1 -1
- package/Accordion/AccordionItemActions.d.ts +8 -0
- package/Accordion/AccordionItemActions.js +36 -0
- package/Accordion/AccordionItemActions.js.map +1 -0
- package/Alert/Alert.d.ts +1 -1
- package/Alert/Alert.js +1 -1
- package/Alert/Alert.js.map +1 -1
- package/Button/Button.d.ts +30 -1
- package/Button/Button.js.map +1 -1
- package/DataTable/DataTable.d.ts +3 -1
- package/DataTable/DataTable.js +9 -4
- package/DataTable/DataTable.js.map +1 -1
- package/DataTable/styled.d.ts +2 -1
- package/DataTable/styled.js.map +1 -1
- package/Dialog/Dialog.js +5 -2
- package/Dialog/Dialog.js.map +1 -1
- package/Input/Input.d.ts +1 -1
- package/Input/Input.js.map +1 -1
- package/Switch/Switch.d.ts +1 -1
- package/Switch/Switch.js.map +1 -1
- package/Tabs/Tab.d.ts +1 -0
- package/Tabs/Tab.js +4 -1
- package/Tabs/Tab.js.map +1 -1
- package/Tabs/Tabs.d.ts +1 -0
- package/Tabs/Tabs.js +8 -1
- package/Tabs/Tabs.js.map +1 -1
- package/Tags/Tags.d.ts +8 -15
- package/Tags/Tags.js +83 -112
- package/Tags/Tags.js.map +1 -1
- package/Typography/Typography.d.ts +2 -2
- package/Typography/Typography.js.map +1 -1
- package/package.json +8 -7
- package/types.d.ts +3 -3
- package/types.js.map +1 -1
package/Dialog/Dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Dialog","props","container","document","getElementById","createElement","setAttribute","body","appendChild","children","ReactDOM","createPortal","getClasses","React","Component","DialogTitle","DialogContent","DialogActions","DialogButton","DialogCancel","DialogAccept"],"sources":["Dialog.tsx"],"sourcesContent":["import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport {\n Dialog as RmwcDialog,\n DialogProps as RmwcDialogProps,\n DialogOnCloseEventT,\n DialogContent as RmwcDialogContent,\n DialogContentProps as RmwcDialogContentProps,\n DialogTitle as RmwcDialogTitle,\n DialogTitleProps as RmwcDialogTitleProps,\n DialogActions as RmwcDialogActions,\n DialogActionsProps as RmwcDialogActionsProps,\n DialogButton as RmwcDialogButton,\n DialogButtonProps as RmwcDialogButtonProps\n} from \"@rmwc/dialog\";\nimport { getClasses } from \"~/Helpers\";\n\nexport type DialogOnClose = (event: DialogOnCloseEventT) => void;\n\nexport interface DialogProps extends RmwcDialogProps {\n className?: string;\n\n // Component's custom in-line styles.\n style?: React.CSSProperties;\n\n // If true, dialog will be permanently fixed inside of a view (works for temporary and persistent modes).\n open?: boolean;\n\n onClose?: (evt: DialogOnCloseEventT) => void;\n\n preventOutsideDismiss?: boolean;\n}\n\nexport class Dialog extends React.Component<DialogProps> {\n container: HTMLElement;\n\n constructor(props: DialogProps) {\n super(props);\n /**\n * We can safely cast\n */\n this.container = document.getElementById(\"dialog-container\") as HTMLElement;\n\n if (!this.container) {\n this.container = document.createElement(\"div\");\n this.container.setAttribute(\"id\", \"dialog-container\");\n const container = this.container;\n document.body && document.body.appendChild(container);\n }\n }\n\n public override render() {\n const { children, ...props } = this.props;\n const container = this.container;\n\n // Let's pass \"permanent\" / \"persistent\" / \"temporary\" flags as \"mode\" prop instead.\n return ReactDOM.createPortal(\n <RmwcDialog {...getClasses(props, \"webiny-ui-dialog\")}>{children}</RmwcDialog>,\n container\n );\n }\n}\n\nexport interface DialogTitleProps extends RmwcDialogTitleProps {\n /**\n * Title text.\n */\n children: React.ReactNode[] | React.ReactNode;\n}\n\n/**\n * Dialog's header, which can accept DialogHeaderTitle component or any other set of components.\n */\nexport const DialogTitle: React.FC<DialogTitleProps> = props => (\n <RmwcDialogTitle {...getClasses(props, \"webiny-ui-dialog__title\")} />\n);\n\nexport type DialogContentProps = RmwcDialogContentProps & {\n /**\n * Dialog content.\n */\n children: React.ReactNode[] | React.ReactNode;\n\n className?: string;\n};\n\n/**\n * A simple component for showing dialog's body.\n */\nexport const DialogContent: React.FC<DialogContentProps> = props => (\n <RmwcDialogContent {...getClasses(props, \"webiny-ui-dialog__content\")} />\n);\n\nexport interface DialogActionsProps extends RmwcDialogActionsProps {\n /**\n * Action buttons.\n */\n children: React.ReactNode[] | React.ReactNode;\n\n // Dialog component's custom in-line styles.\n style?: React.CSSProperties;\n}\n\n/**\n * Can be used to show accept and cancel buttons.\n */\nexport const DialogActions: React.FC<DialogActionsProps> = props => (\n <RmwcDialogActions {...getClasses(props, \"webiny-ui-dialog__actions\")} />\n);\n\ninterface DialogButtonProps extends RmwcDialogButtonProps {\n /**\n * Callback to execute then button is clicked.\n */\n onClick?: (e: React.MouseEvent) => void;\n\n className?: string;\n}\n\n/**\n * Use this to show a simple button.\n */\nexport const DialogButton: React.FC<DialogButtonProps> = props => (\n <RmwcDialogButton {...getClasses(props, \"webiny-ui-dialog__button\")} />\n);\n\ninterface DialogCancelProps extends RmwcDialogButtonProps {\n /**\n * Callback to execute then button is clicked.\n */\n onClick?: (e: React.MouseEvent) => void;\n}\n\n/**\n * Use this to close the dialog without taking any additional action.\n */\nexport const DialogCancel: React.FC<DialogCancelProps> = props => {\n return (\n <DialogButton\n {...getClasses(props, \"webiny-ui-dialog__button webiny-ui-dialog__button--cancel\")}\n action=\"close\"\n data-testid=\"dialog-cancel\"\n >\n {props.children}\n </DialogButton>\n );\n};\n\ninterface DialogAcceptProps extends RmwcDialogButtonProps {\n /**\n * Callback to execute then button is clicked.\n */\n onClick?: (e: React.MouseEvent) => void;\n}\n\n/**\n * Use this to close the dialog without taking any additional action.\n */\nexport const DialogAccept: React.FC<DialogAcceptProps> = props => {\n return (\n <DialogButton\n {...getClasses(props, \"webiny-ui-dialog__button webiny-ui-dialog__button--accept\")}\n action=\"accept\"\n data-testid=\"dialog-accept\"\n >\n {props.children}\n </DialogButton>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAaA;;;;IAkBaA,M;;;;;EAGT,gBAAYC,KAAZ,EAAgC;IAAA;;IAAA;IAC5B,0BAAMA,KAAN;IACA;AACR;AACA;;IAJoC;IAK5B,MAAKC,SAAL,GAAiBC,QAAQ,CAACC,cAAT,CAAwB,kBAAxB,CAAjB;;IAEA,IAAI,CAAC,MAAKF,SAAV,EAAqB;MACjB,MAAKA,SAAL,GAAiBC,QAAQ,CAACE,aAAT,CAAuB,KAAvB,CAAjB;;MACA,MAAKH,SAAL,CAAeI,YAAf,CAA4B,IAA5B,EAAkC,kBAAlC;;MACA,IAAMJ,SAAS,GAAG,MAAKA,SAAvB;MACAC,QAAQ,CAACI,IAAT,IAAiBJ,QAAQ,CAACI,IAAT,CAAcC,WAAd,CAA0BN,SAA1B,CAAjB;IACH;;IAZ2B;EAa/B;;;;WAED,kBAAyB;MACrB,kBAA+B,KAAKD,KAApC;MAAA,IAAQQ,QAAR,eAAQA,QAAR;MAAA,IAAqBR,KAArB;MACA,IAAMC,SAAS,GAAG,KAAKA,SAAvB,CAFqB,CAIrB;;MACA,oBAAOQ,iBAAA,CAASC,YAAT,eACH,6BAAC,cAAD,EAAgB,IAAAC,mBAAA,EAAWX,KAAX,EAAkB,kBAAlB,CAAhB,EAAwDQ,QAAxD,CADG,EAEHP,SAFG,CAAP;IAIH;;;EA3BuBW,cAAA,CAAMC,S;;;;AAqClC;AACA;AACA;AACO,IAAMC,WAAuC,GAAG,SAA1CA,WAA0C,CAAAd,KAAK;EAAA,oBACxD,6BAAC,mBAAD,EAAqB,IAAAW,mBAAA,EAAWX,KAAX,EAAkB,yBAAlB,CAArB,CADwD;AAAA,CAArD;;;;AAaP;AACA;AACA;AACO,IAAMe,aAA2C,GAAG,SAA9CA,aAA8C,CAAAf,KAAK;EAAA,oBAC5D,6BAAC,qBAAD,EAAuB,IAAAW,mBAAA,EAAWX,KAAX,EAAkB,2BAAlB,CAAvB,CAD4D;AAAA,CAAzD
|
|
1
|
+
{"version":3,"names":["Dialog","props","container","document","getElementById","createElement","setAttribute","body","appendChild","children","ReactDOM","createPortal","getClasses","React","Component","DialogTitle","DialogContent","addMargin","css","DialogActions","DialogButton","DialogCancel","DialogAccept"],"sources":["Dialog.tsx"],"sourcesContent":["import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport {\n Dialog as RmwcDialog,\n DialogProps as RmwcDialogProps,\n DialogOnCloseEventT,\n DialogContent as RmwcDialogContent,\n DialogContentProps as RmwcDialogContentProps,\n DialogTitle as RmwcDialogTitle,\n DialogTitleProps as RmwcDialogTitleProps,\n DialogActions as RmwcDialogActions,\n DialogActionsProps as RmwcDialogActionsProps,\n DialogButton as RmwcDialogButton,\n DialogButtonProps as RmwcDialogButtonProps\n} from \"@rmwc/dialog\";\nimport { css } from \"emotion\";\nimport { getClasses } from \"~/Helpers\";\n\nexport type DialogOnClose = (event: DialogOnCloseEventT) => void;\n\nexport interface DialogProps extends RmwcDialogProps {\n className?: string;\n\n // Component's custom in-line styles.\n style?: React.CSSProperties;\n\n // If true, dialog will be permanently fixed inside of a view (works for temporary and persistent modes).\n open?: boolean;\n\n onClose?: (evt: DialogOnCloseEventT) => void;\n\n preventOutsideDismiss?: boolean;\n}\n\nexport class Dialog extends React.Component<DialogProps> {\n container: HTMLElement;\n\n constructor(props: DialogProps) {\n super(props);\n /**\n * We can safely cast\n */\n this.container = document.getElementById(\"dialog-container\") as HTMLElement;\n\n if (!this.container) {\n this.container = document.createElement(\"div\");\n this.container.setAttribute(\"id\", \"dialog-container\");\n const container = this.container;\n document.body && document.body.appendChild(container);\n }\n }\n\n public override render() {\n const { children, ...props } = this.props;\n const container = this.container;\n\n // Let's pass \"permanent\" / \"persistent\" / \"temporary\" flags as \"mode\" prop instead.\n return ReactDOM.createPortal(\n <RmwcDialog {...getClasses(props, \"webiny-ui-dialog\")}>{children}</RmwcDialog>,\n container\n );\n }\n}\n\nexport interface DialogTitleProps extends RmwcDialogTitleProps {\n /**\n * Title text.\n */\n children: React.ReactNode[] | React.ReactNode;\n}\n\n/**\n * Dialog's header, which can accept DialogHeaderTitle component or any other set of components.\n */\nexport const DialogTitle: React.FC<DialogTitleProps> = props => (\n <RmwcDialogTitle {...getClasses(props, \"webiny-ui-dialog__title\")} />\n);\n\nexport type DialogContentProps = RmwcDialogContentProps & {\n /**\n * Dialog content.\n */\n children: React.ReactNode[] | React.ReactNode;\n\n className?: string;\n};\n\n/**\n * A simple component for showing dialog's body.\n */\nexport const DialogContent: React.FC<DialogContentProps> = props => (\n <RmwcDialogContent {...getClasses(props, \"webiny-ui-dialog__content\")} />\n);\n\nexport interface DialogActionsProps extends RmwcDialogActionsProps {\n /**\n * Action buttons.\n */\n children: React.ReactNode[] | React.ReactNode;\n\n // Dialog component's custom in-line styles.\n style?: React.CSSProperties;\n}\n\nconst addMargin = css`\n button:last-of-type {\n margin-left: 8px;\n }\n`;\n\n/**\n * Can be used to show accept and cancel buttons.\n */\nexport const DialogActions: React.FC<DialogActionsProps> = props => (\n <RmwcDialogActions {...getClasses(props, [addMargin, \"webiny-ui-dialog__actions\"])} />\n);\n\ninterface DialogButtonProps extends RmwcDialogButtonProps {\n /**\n * Callback to execute then button is clicked.\n */\n onClick?: (e: React.MouseEvent) => void;\n\n className?: string;\n}\n\n/**\n * Use this to show a simple button.\n */\nexport const DialogButton: React.FC<DialogButtonProps> = props => (\n <RmwcDialogButton {...getClasses(props, \"webiny-ui-dialog__button\")} />\n);\n\ninterface DialogCancelProps extends RmwcDialogButtonProps {\n /**\n * Callback to execute then button is clicked.\n */\n onClick?: (e: React.MouseEvent) => void;\n}\n\n/**\n * Use this to close the dialog without taking any additional action.\n */\nexport const DialogCancel: React.FC<DialogCancelProps> = props => {\n return (\n <DialogButton\n {...getClasses(props, \"webiny-ui-dialog__button webiny-ui-dialog__button--cancel\")}\n action=\"close\"\n data-testid=\"dialog-cancel\"\n >\n {props.children}\n </DialogButton>\n );\n};\n\ninterface DialogAcceptProps extends RmwcDialogButtonProps {\n /**\n * Callback to execute then button is clicked.\n */\n onClick?: (e: React.MouseEvent) => void;\n}\n\n/**\n * Use this to close the dialog without taking any additional action.\n */\nexport const DialogAccept: React.FC<DialogAcceptProps> = props => {\n return (\n <DialogButton\n {...getClasses(props, \"webiny-ui-dialog__button webiny-ui-dialog__button--accept\")}\n action=\"accept\"\n data-testid=\"dialog-accept\"\n >\n {props.children}\n </DialogButton>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAaA;;AACA;;;;IAkBaA,M;;;;;EAGT,gBAAYC,KAAZ,EAAgC;IAAA;;IAAA;IAC5B,0BAAMA,KAAN;IACA;AACR;AACA;;IAJoC;IAK5B,MAAKC,SAAL,GAAiBC,QAAQ,CAACC,cAAT,CAAwB,kBAAxB,CAAjB;;IAEA,IAAI,CAAC,MAAKF,SAAV,EAAqB;MACjB,MAAKA,SAAL,GAAiBC,QAAQ,CAACE,aAAT,CAAuB,KAAvB,CAAjB;;MACA,MAAKH,SAAL,CAAeI,YAAf,CAA4B,IAA5B,EAAkC,kBAAlC;;MACA,IAAMJ,SAAS,GAAG,MAAKA,SAAvB;MACAC,QAAQ,CAACI,IAAT,IAAiBJ,QAAQ,CAACI,IAAT,CAAcC,WAAd,CAA0BN,SAA1B,CAAjB;IACH;;IAZ2B;EAa/B;;;;WAED,kBAAyB;MACrB,kBAA+B,KAAKD,KAApC;MAAA,IAAQQ,QAAR,eAAQA,QAAR;MAAA,IAAqBR,KAArB;MACA,IAAMC,SAAS,GAAG,KAAKA,SAAvB,CAFqB,CAIrB;;MACA,oBAAOQ,iBAAA,CAASC,YAAT,eACH,6BAAC,cAAD,EAAgB,IAAAC,mBAAA,EAAWX,KAAX,EAAkB,kBAAlB,CAAhB,EAAwDQ,QAA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X,KAAX,EAAkB,2DAAlB,CADR;IAEI,MAAM,EAAC,QAFX;IAGI,eAAY;EAHhB,IAKKA,KAAK,CAACQ,QALX,CADJ;AASH,CAVM"}
|
package/Input/Input.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { TextFieldProps } from "@rmwc/textfield";
|
|
4
4
|
import { FormComponentProps } from "../types";
|
|
5
5
|
import { ReactElement } from "react";
|
|
6
|
-
export declare type InputProps = FormComponentProps & TextFieldProps & {
|
|
6
|
+
export declare type InputProps<TValue = any> = FormComponentProps<TValue> & TextFieldProps & {
|
|
7
7
|
autoComplete?: string;
|
|
8
8
|
rawOnChange?: boolean;
|
|
9
9
|
autoFocus?: boolean;
|
package/Input/Input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["webinyInputStyles","css","Input","e","props","onChange","rawOnChange","target","value","validate","onBlur","persist","autoFocus","label","description","placeholder","rows","validation","icon","trailingIcon","onEnter","inputValue","validationIsValid","isValid","validationMessage","message","pick","rmwcProps","key","onKeyDown","rest","Boolean","undefined","classNames","React","Component"],"sources":["Input.tsx"],"sourcesContent":["import React from \"react\";\nimport { TextField, TextFieldProps } from \"@rmwc/textfield\";\nimport { FormElementMessage } from \"~/FormElementMessage\";\nimport pick from \"lodash/pick\";\nimport { FormComponentProps } from \"~/types\";\nimport { ReactElement } from \"react\";\nimport { css } from \"emotion\";\nimport classNames from \"classnames\";\n\nexport type InputProps = FormComponentProps &\n TextFieldProps & {\n // Should this input be filled with browser values\n autoComplete?: string;\n\n // If true, will pass native `event` to the `onChange` callback\n rawOnChange?: boolean;\n\n // Auto-focus input\n autoFocus?: boolean;\n\n // Input placeholder\n placeholder?: string;\n\n // Description beneath the input.\n description?: string | ReactElement;\n\n // Converts input into a text area with given number of rows.\n rows?: number;\n\n maxLength?: number;\n\n // A callback that is executed when input focus is lost.\n onBlur?: (e: React.SyntheticEvent<HTMLInputElement>) => any;\n\n onKeyDown?: (e: React.SyntheticEvent<HTMLInputElement>) => any;\n\n // A callback that gets triggered when the user presses the \"Enter\" key.\n onEnter?: () => any;\n\n // CSS class name\n className?: string;\n\n // For testing purposes.\n \"data-testid\"?: string;\n };\n\n/**\n * fix label position when autofilled\n * @type {string}\n */\nconst webinyInputStyles = css`\n .mdc-text-field__input:-webkit-autofill + .mdc-floating-label {\n transform: translateY(-106%) scale(0.75);\n }\n }\n`;\n\n/**\n * Use Input component to store short string values, like first name, last name, e-mail etc.\n * Additionally, with rows prop, it can also be turned into a text area, to store longer strings.\n */\n\nexport class Input extends React.Component<InputProps> {\n static defaultProps: InputProps = {\n rawOnChange: false\n };\n\n // IconProps directly passed to RMWC\n static rmwcProps = [\n \"label\",\n \"type\",\n \"step\",\n \"disabled\",\n \"readOnly\",\n \"placeholder\",\n \"outlined\",\n \"onKeyDown\",\n \"onKeyPress\",\n \"onKeyUp\",\n \"onFocus\",\n \"rootProps\",\n \"fullwidth\",\n \"inputRef\",\n \"className\",\n \"maxLength\",\n \"characterCount\"\n ];\n\n onChange = (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { onChange, rawOnChange } = this.props;\n if (!onChange) {\n return;\n }\n\n // @ts-ignore\n onChange(rawOnChange ? e : e.target.value);\n };\n\n onBlur = async (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { validate, onBlur } = this.props;\n if (validate) {\n // Since we are accessing event in an async operation, we need to persist it.\n // See https://reactjs.org/docs/events.html#event-pooling.\n e.persist();\n await validate();\n }\n onBlur && onBlur(e);\n };\n\n public override render() {\n const {\n autoFocus,\n value,\n label,\n description,\n placeholder,\n rows,\n validation,\n icon,\n trailingIcon,\n onEnter,\n ...props\n } = this.props;\n\n let inputValue = value;\n if (value === null || typeof value === \"undefined\") {\n inputValue = \"\";\n }\n\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n\n return (\n <React.Fragment>\n <TextField\n {...pick(props, Input.rmwcProps)}\n onKeyDown={(e, ...rest) => {\n if (typeof onEnter === \"function\" && e.key === \"Enter\") {\n onEnter();\n }\n\n if (typeof props.onKeyDown === \"function\") {\n return props.onKeyDown(e, ...rest);\n }\n }}\n autoFocus={autoFocus}\n textarea={Boolean(rows)}\n value={inputValue}\n onChange={this.onChange}\n onBlur={this.onBlur}\n label={label}\n icon={icon}\n placeholder={(!label && placeholder) || undefined}\n trailingIcon={trailingIcon}\n rows={this.props.rows}\n className={classNames(\"webiny-ui-input\", webinyInputStyles)}\n data-testid={props[\"data-testid\"]}\n />\n\n {validationIsValid === false && (\n <FormElementMessage error>{validationMessage}</FormElementMessage>\n )}\n {validationIsValid !== false && description && (\n <FormElementMessage>{description}</FormElementMessage>\n )}\n </React.Fragment>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;AAuCA;AACA;AACA;AACA;AACA,IAAMA,iBAAiB,oBAAGC,YAAH,qIAAvB;AAOA;AACA;AACA;AACA;;IAEaC,K;;;;;;;;;;;;;;;2FA0BE,UAACC,CAAD,EAA+C;MACtD,kBAAkC,MAAKC,KAAvC;MAAA,IAAQC,QAAR,eAAQA,QAAR;MAAA,IAAkBC,WAAlB,eAAkBA,WAAlB;;MACA,IAAI,CAACD,QAAL,EAAe;QACX;MACH,CAJqD,CAMtD;;;MACAA,QAAQ,CAACC,WAAW,GAAGH,CAAH,GAAOA,CAAC,CAACI,MAAF,CAASC,KAA5B,CAAR;IACH,C;;wGAEQ,iBAAOL,CAAP;QAAA;;QAAA;UAAA;YAAA;cAAA;gBAAA,eACwB,MAAKC,KAD7B,EACGK,QADH,gBACGA,QADH,EACaC,MADb,gBACaA,MADb;;gBAAA,KAEDD,QAFC;kBAAA;kBAAA;gBAAA;;gBAGD;gBACA;gBACAN,CAAC,CAACQ,OAAF;gBALC;gBAAA,OAMKF,QAAQ,EANb;;cAAA;gBAQLC,MAAM,IAAIA,MAAM,CAACP,CAAD,CAAhB;;cARK;cAAA;gBAAA;YAA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IAAD,CAZrB;QAaI,KAAK,EAAEK,UAbX;QAcI,QAAQ,EAAE,KAAKhB,QAdnB;QAeI,MAAM,EAAE,KAAKK,MAfjB;QAgBI,KAAK,EAAEG,KAhBX;QAiBI,IAAI,EAAEK,IAjBV;QAkBI,WAAW,EAAG,CAACL,KAAD,IAAUE,WAAX,IAA2BiB,SAlB5C;QAmBI,YAAY,EAAEb,YAnBlB;QAoBI,IAAI,EAAE,KAAKf,KAAL,CAAWY,IApBrB;QAqBI,SAAS,EAAE,IAAAiB,mBAAA,EAAW,iBAAX,EAA8BjC,iBAA9B,CArBf;QAsBI,eAAaI,KAAK,CAAC,aAAD;MAtBtB,GADJ,EA0BKkB,iBAAiB,KAAK,KAAtB,iBACG,6BAAC,sCAAD;QAAoB,KAAK;MAAzB,GAA2BE,iBAA3B,CA3BR,EA6BKF,iBAAiB,KAAK,KAAtB,IAA+BR,WAA/B,iBACG,6BAAC,sCAAD,QAAqBA,WAArB,CA9BR,CADJ;IAmCH;;;EAxGsBoB,cAAA,CAAMC,S;;;8BAApBjC,K,kBACyB;EAC9BI,WAAW,EAAE;AADiB,C;8BADzBJ,K,eAMU,CACf,OADe,EAEf,MAFe,EAGf,MAHe,EAIf,UAJe,EAKf,UALe,EAMf,aANe,EAOf,UAPe,EAQf,WARe,EASf,YATe,EAUf,SAVe,EAWf,SAXe,EAYf,WAZe,EAaf,WAbe,EAcf,UAde,EAef,WAfe,EAgBf,WAhBe,EAiBf,gBAjBe,C"}
|
|
1
|
+
{"version":3,"names":["webinyInputStyles","css","Input","e","props","onChange","rawOnChange","target","value","validate","onBlur","persist","autoFocus","label","description","placeholder","rows","validation","icon","trailingIcon","onEnter","inputValue","validationIsValid","isValid","validationMessage","message","pick","rmwcProps","key","onKeyDown","rest","Boolean","undefined","classNames","React","Component"],"sources":["Input.tsx"],"sourcesContent":["import React from \"react\";\nimport { TextField, TextFieldProps } from \"@rmwc/textfield\";\nimport { FormElementMessage } from \"~/FormElementMessage\";\nimport pick from \"lodash/pick\";\nimport { FormComponentProps } from \"~/types\";\nimport { ReactElement } from \"react\";\nimport { css } from \"emotion\";\nimport classNames from \"classnames\";\n\nexport type InputProps<TValue = any> = FormComponentProps<TValue> &\n TextFieldProps & {\n // Should this input be filled with browser values\n autoComplete?: string;\n\n // If true, will pass native `event` to the `onChange` callback\n rawOnChange?: boolean;\n\n // Auto-focus input\n autoFocus?: boolean;\n\n // Input placeholder\n placeholder?: string;\n\n // Description beneath the input.\n description?: string | ReactElement;\n\n // Converts input into a text area with given number of rows.\n rows?: number;\n\n maxLength?: number;\n\n // A callback that is executed when input focus is lost.\n onBlur?: (e: React.SyntheticEvent<HTMLInputElement>) => any;\n\n onKeyDown?: (e: React.SyntheticEvent<HTMLInputElement>) => any;\n\n // A callback that gets triggered when the user presses the \"Enter\" key.\n onEnter?: () => any;\n\n // CSS class name\n className?: string;\n\n // For testing purposes.\n \"data-testid\"?: string;\n };\n\n/**\n * fix label position when autofilled\n * @type {string}\n */\nconst webinyInputStyles = css`\n .mdc-text-field__input:-webkit-autofill + .mdc-floating-label {\n transform: translateY(-106%) scale(0.75);\n }\n }\n`;\n\n/**\n * Use Input component to store short string values, like first name, last name, e-mail etc.\n * Additionally, with rows prop, it can also be turned into a text area, to store longer strings.\n */\n\nexport class Input extends React.Component<InputProps> {\n static defaultProps: InputProps = {\n rawOnChange: false\n };\n\n // IconProps directly passed to RMWC\n static rmwcProps = [\n \"label\",\n \"type\",\n \"step\",\n \"disabled\",\n \"readOnly\",\n \"placeholder\",\n \"outlined\",\n \"onKeyDown\",\n \"onKeyPress\",\n \"onKeyUp\",\n \"onFocus\",\n \"rootProps\",\n \"fullwidth\",\n \"inputRef\",\n \"className\",\n \"maxLength\",\n \"characterCount\"\n ];\n\n onChange = (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { onChange, rawOnChange } = this.props;\n if (!onChange) {\n return;\n }\n\n // @ts-ignore\n onChange(rawOnChange ? e : e.target.value);\n };\n\n onBlur = async (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { validate, onBlur } = this.props;\n if (validate) {\n // Since we are accessing event in an async operation, we need to persist it.\n // See https://reactjs.org/docs/events.html#event-pooling.\n e.persist();\n await validate();\n }\n onBlur && onBlur(e);\n };\n\n public override render() {\n const {\n autoFocus,\n value,\n label,\n description,\n placeholder,\n rows,\n validation,\n icon,\n trailingIcon,\n onEnter,\n ...props\n } = this.props;\n\n let inputValue = value;\n if (value === null || typeof value === \"undefined\") {\n inputValue = \"\";\n }\n\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n\n return (\n <React.Fragment>\n <TextField\n {...pick(props, Input.rmwcProps)}\n onKeyDown={(e, ...rest) => {\n if (typeof onEnter === \"function\" && e.key === \"Enter\") {\n onEnter();\n }\n\n if (typeof props.onKeyDown === \"function\") {\n return props.onKeyDown(e, ...rest);\n }\n }}\n autoFocus={autoFocus}\n textarea={Boolean(rows)}\n value={inputValue}\n onChange={this.onChange}\n onBlur={this.onBlur}\n label={label}\n icon={icon}\n placeholder={(!label && placeholder) || undefined}\n trailingIcon={trailingIcon}\n rows={this.props.rows}\n className={classNames(\"webiny-ui-input\", webinyInputStyles)}\n data-testid={props[\"data-testid\"]}\n />\n\n {validationIsValid === false && (\n <FormElementMessage error>{validationMessage}</FormElementMessage>\n )}\n {validationIsValid !== false && description && (\n <FormElementMessage>{description}</FormElementMessage>\n )}\n </React.Fragment>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;AAuCA;AACA;AACA;AACA;AACA,IAAMA,iBAAiB,oBAAGC,YAAH,qIAAvB;AAOA;AACA;AACA;AACA;;IAEaC,K;;;;;;;;;;;;;;;2FA0BE,UAACC,CAAD,EAA+C;MACtD,kBAAkC,MAAKC,KAAvC;MAAA,IAAQC,QAAR,eAAQA,QAAR;MAAA,IAAkBC,WAAlB,eAAkBA,WAAlB;;MACA,IAAI,CAACD,QAAL,EAAe;QACX;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,WARe,EASf,YATe,EAUf,SAVe,EAWf,SAXe,EAYf,WAZe,EAaf,WAbe,EAcf,UAde,EAef,WAfe,EAgBf,WAhBe,EAiBf,gBAjBe,C"}
|
package/Switch/Switch.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { SwitchProps } from "@rmwc/switch";
|
|
4
4
|
import { FormComponentProps } from "../types";
|
|
5
|
-
declare type Props =
|
|
5
|
+
declare type Props = Omit<SwitchProps, "value"> & FormComponentProps<boolean> & {
|
|
6
6
|
description?: string;
|
|
7
7
|
className?: string;
|
|
8
8
|
};
|
package/Switch/Switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Switch","e","props","onChange","target","checked","value","description","validation","validationIsValid","isValid","validationMessage","message","getClasses","pick","rmwcProps","Boolean","React","Component"],"sources":["Switch.tsx"],"sourcesContent":["import React from \"react\";\nimport { Switch as RmwcSwitch, SwitchProps } from \"@rmwc/switch\";\nimport { FormComponentProps } from \"~/types\";\nimport pick from \"lodash/pick\";\nimport { FormElementMessage } from \"~/FormElementMessage\";\nimport { getClasses } from \"~/Helpers\";\n\ntype Props =
|
|
1
|
+
{"version":3,"names":["Switch","e","props","onChange","target","checked","value","description","validation","validationIsValid","isValid","validationMessage","message","getClasses","pick","rmwcProps","Boolean","React","Component"],"sources":["Switch.tsx"],"sourcesContent":["import React from \"react\";\nimport { Switch as RmwcSwitch, SwitchProps } from \"@rmwc/switch\";\nimport { FormComponentProps } from \"~/types\";\nimport pick from \"lodash/pick\";\nimport { FormElementMessage } from \"~/FormElementMessage\";\nimport { getClasses } from \"~/Helpers\";\n\ntype Props = Omit<SwitchProps, \"value\"> &\n FormComponentProps<boolean> & {\n // Description beneath the switch.\n description?: string;\n\n // Optional class name.\n className?: string;\n };\n\n/**\n * Switch component can be used to store simple boolean values.\n */\nclass Switch extends React.Component<Props> {\n static rmwcProps = [\"id\", \"disabled\", \"checked\", \"label\", \"rootProps\", \"className\"];\n\n onChange = (e: React.SyntheticEvent<HTMLElement>) => {\n this.props.onChange && this.props.onChange((e.target as any).checked);\n };\n\n public override render() {\n const { value, description, validation } = this.props;\n\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n\n return (\n <React.Fragment>\n <RmwcSwitch\n {...getClasses({ ...pick(this.props, Switch.rmwcProps) }, \"webiny-ui-switch\")}\n checked={Boolean(value)}\n onChange={this.onChange}\n />\n\n {validationIsValid === false && (\n <FormElementMessage error>{validationMessage}</FormElementMessage>\n )}\n\n {validationIsValid !== false && description && (\n <FormElementMessage>{description}</FormElementMessage>\n )}\n </React.Fragment>\n );\n }\n}\n\nexport { Switch };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AAWA;AACA;AACA;IACMA,M;;;;;;;;;;;;;;;2FAGS,UAACC,CAAD,EAA0C;MACjD,MAAKC,KAAL,CAAWC,QAAX,IAAuB,MAAKD,KAAL,CAAWC,QAAX,CAAqBF,CAAC,CAACG,MAAH,CAAkBC,OAAtC,CAAvB;IACH,C;;;;;;WAED,kBAAyB;MACrB,kBAA2C,KAAKH,KAAhD;MAAA,IAAQI,KAAR,eAAQA,KAAR;MAAA,IAAeC,WAAf,eAAeA,WAAf;MAAA,IAA4BC,UAA5B,eAA4BA,UAA5B;;MAEA,WAAmEA,UAAU,IAAI,EAAjF;MAAA,IAAiBC,iBAAjB,QAAQC,OAAR;MAAA,IAA6CC,iBAA7C,QAAoCC,OAApC;;MAEA,oBACI,6BAAC,cAAD,CAAO,QAAP,qBACI,6BAAC,cAAD,oBACQ,IAAAC,mBAAA,kCAAgB,IAAAC,aAAA,EAAK,KAAKZ,KAAV,EAAiBF,MAAM,CAACe,SAAxB,CAAhB,GAAsD,kBAAtD,CADR;QAEI,OAAO,EAAEC,OAAO,CAACV,KAAD,CAFpB;QAGI,QAAQ,EAAE,KAAKH;MAHnB,GADJ,EAOKM,iBAAiB,KAAK,KAAtB,iBACG,6BAAC,sCAAD;QAAoB,KAAK;MAAzB,GAA2BE,iBAA3B,CARR,EAWKF,iBAAiB,KAAK,KAAtB,IAA+BF,WAA/B,iBACG,6BAAC,sCAAD,QAAqBA,WAArB,CAZR,CADJ;IAiBH;;;EA7BgBU,cAAA,CAAMC,S;;;8BAArBlB,M,eACiB,CAAC,IAAD,EAAO,UAAP,EAAmB,SAAnB,EAA8B,OAA9B,EAAuC,WAAvC,EAAoD,WAApD,C"}
|
package/Tabs/Tab.d.ts
CHANGED
package/Tabs/Tab.js
CHANGED
|
@@ -21,8 +21,11 @@ var Tab = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
21
21
|
var tabsContext = (0, _react.useContext)(_Tabs.TabsContext);
|
|
22
22
|
var idRef = (0, _react.useRef)(_shortid.default.generate());
|
|
23
23
|
(0, _react.useEffect)(function () {
|
|
24
|
+
var _props$visible;
|
|
25
|
+
|
|
24
26
|
tabsContext.addTab((0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
|
|
25
|
-
id: idRef.current
|
|
27
|
+
id: idRef.current,
|
|
28
|
+
visible: (_props$visible = props.visible) !== null && _props$visible !== void 0 ? _props$visible : true
|
|
26
29
|
}));
|
|
27
30
|
}, [props]);
|
|
28
31
|
(0, _react.useEffect)(function () {
|
package/Tabs/Tab.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Tab","React","memo","props","tabsContext","useContext","TabsContext","idRef","useRef","shortid","generate","useEffect","addTab","id","current","removeTab","displayName"],"sources":["Tab.tsx"],"sourcesContent":["import React, { useContext, useEffect, useRef } from \"react\";\nimport { TabProps as RmwcTabProps } from \"@rmwc/tabs\";\nimport shortid from \"shortid\";\nimport { TabsContext } from \"./Tabs\";\n\nexport type TabProps = RmwcTabProps & {\n tag?: string;\n /**\n * Is tab disabled?\n */\n disabled?: boolean;\n /**\n * Style object\n */\n style?: React.CSSProperties;\n /**\n * Tab ID for the testing.\n */\n \"data-testid\"?: string;\n};\n\nexport const Tab: React.FC<TabProps> = React.memo(props => {\n const tabsContext = useContext(TabsContext);\n const idRef = useRef(shortid.generate());\n\n useEffect(() => {\n tabsContext!.addTab({ ...props, id: idRef.current });\n }, [props]);\n\n useEffect(() => {\n return () => {\n return tabsContext!.removeTab(idRef.current);\n };\n }, []);\n\n return null;\n});\n\nTab.displayName = \"Tab\";\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;
|
|
1
|
+
{"version":3,"names":["Tab","React","memo","props","tabsContext","useContext","TabsContext","idRef","useRef","shortid","generate","useEffect","addTab","id","current","visible","removeTab","displayName"],"sources":["Tab.tsx"],"sourcesContent":["import React, { useContext, useEffect, useRef } from \"react\";\nimport { TabProps as RmwcTabProps } from \"@rmwc/tabs\";\nimport shortid from \"shortid\";\nimport { TabsContext } from \"./Tabs\";\n\nexport type TabProps = RmwcTabProps & {\n visible?: boolean;\n\n tag?: string;\n /**\n * Is tab disabled?\n */\n disabled?: boolean;\n /**\n * Style object\n */\n style?: React.CSSProperties;\n /**\n * Tab ID for the testing.\n */\n \"data-testid\"?: string;\n};\n\nexport const Tab: React.FC<TabProps> = React.memo(props => {\n const tabsContext = useContext(TabsContext);\n const idRef = useRef(shortid.generate());\n\n useEffect(() => {\n tabsContext!.addTab({ ...props, id: idRef.current, visible: props.visible ?? true });\n }, [props]);\n\n useEffect(() => {\n return () => {\n return tabsContext!.removeTab(idRef.current);\n };\n }, []);\n\n return null;\n});\n\nTab.displayName = \"Tab\";\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AAoBO,IAAMA,GAAuB,gBAAGC,cAAA,CAAMC,IAAN,CAAW,UAAAC,KAAK,EAAI;EACvD,IAAMC,WAAW,GAAG,IAAAC,iBAAA,EAAWC,iBAAX,CAApB;EACA,IAAMC,KAAK,GAAG,IAAAC,aAAA,EAAOC,gBAAA,CAAQC,QAAR,EAAP,CAAd;EAEA,IAAAC,gBAAA,EAAU,YAAM;IAAA;;IACZP,WAAW,CAAEQ,MAAb,6DAAyBT,KAAzB;MAAgCU,EAAE,EAAEN,KAAK,CAACO,OAA1C;MAAmDC,OAAO,oBAAEZ,KAAK,CAACY,OAAR,2DAAmB;IAA7E;EACH,CAFD,EAEG,CAACZ,KAAD,CAFH;EAIA,IAAAQ,gBAAA,EAAU,YAAM;IACZ,OAAO,YAAM;MACT,OAAOP,WAAW,CAAEY,SAAb,CAAuBT,KAAK,CAACO,OAA7B,CAAP;IACH,CAFD;EAGH,CAJD,EAIG,EAJH;EAMA,OAAO,IAAP;AACH,CAfsC,CAAhC;;;AAiBPd,GAAG,CAACiB,WAAJ,GAAkB,KAAlB"}
|
package/Tabs/Tabs.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ interface TabsContext {
|
|
|
32
32
|
export declare const TabsContext: React.Context<TabsContext | undefined>;
|
|
33
33
|
export interface TabsImperativeApi {
|
|
34
34
|
switchTab(index: number): void;
|
|
35
|
+
getActiveIndex(): number;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Use Tabs component to display a list of choices, once the handler is triggered.
|
package/Tabs/Tabs.js
CHANGED
|
@@ -51,6 +51,9 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
51
51
|
}, []);
|
|
52
52
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
53
53
|
return {
|
|
54
|
+
getActiveIndex: function getActiveIndex() {
|
|
55
|
+
return activeIndex;
|
|
56
|
+
},
|
|
54
57
|
switchTab: function switchTab(tabIndex) {
|
|
55
58
|
activateTabIndex(tabIndex);
|
|
56
59
|
}
|
|
@@ -85,6 +88,10 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
85
88
|
props.onActivate && props.onActivate(evt.detail.index);
|
|
86
89
|
}
|
|
87
90
|
}, tabs.map(function (item) {
|
|
91
|
+
if (!item.visible) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
88
95
|
var style = item.style || {};
|
|
89
96
|
|
|
90
97
|
if (item.disabled) {
|
|
@@ -101,7 +108,7 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
101
108
|
} : {}), item.label);
|
|
102
109
|
}));
|
|
103
110
|
|
|
104
|
-
var content = tabs.map(function (tab, index) {
|
|
111
|
+
var content = tabs.filter(Boolean).map(function (tab, index) {
|
|
105
112
|
if (activeIndex === index) {
|
|
106
113
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
107
114
|
key: index
|
package/Tabs/Tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["disabledStyles","opacity","pointerEvents","TabsContext","createContext","undefined","Tabs","forwardRef","props","ref","useState","activeTabIndex","setActiveIndex","tabs","setTabs","activeIndex","value","activateTabIndex","useCallback","index","updateValue","useImperativeHandle","switchTab","tabIndex","useEffect","disabled","tabBar","map","tab","id","join","evt","detail","onActivate","item","style","Object","assign","icon","label","content","children","display","context","useMemo","addTab","existingIndex","findIndex","slice","removeTab","
|
|
1
|
+
{"version":3,"names":["disabledStyles","opacity","pointerEvents","TabsContext","createContext","undefined","Tabs","forwardRef","props","ref","useState","activeTabIndex","setActiveIndex","tabs","setTabs","activeIndex","value","activateTabIndex","useCallback","index","updateValue","useImperativeHandle","getActiveIndex","switchTab","tabIndex","useEffect","disabled","tabBar","map","tab","id","join","evt","detail","onActivate","item","visible","style","Object","assign","icon","label","content","filter","Boolean","children","display","context","useMemo","addTab","existingIndex","findIndex","slice","removeTab","classNames","className","displayName"],"sources":["Tabs.tsx"],"sourcesContent":["import React, {\n createContext,\n forwardRef,\n PropsWithChildren,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState\n} from \"react\";\nimport classNames from \"classnames\";\nimport { TabBar, Tab as RmwcTab } from \"@rmwc/tabs\";\nimport { TabProps } from \"./Tab\";\n\nexport type TabsProps = PropsWithChildren<{\n /**\n * Append a class name.\n */\n className?: string;\n\n /**\n * Callback to execute when a tab is changed.\n */\n onActivate?: (index: number) => void;\n\n /**\n * Active tab index value.\n */\n value?: number;\n\n /**\n * Function to change active tab.\n */\n updateValue?: (index: number) => void;\n /**\n * Tab ID for the testing.\n */\n \"data-testid\"?: string;\n}>;\n\nconst disabledStyles: Record<string, string | number> = {\n opacity: 0.5,\n pointerEvents: \"none\"\n};\n\ninterface TabItem extends TabProps {\n id: string;\n}\n\ninterface TabsContext {\n addTab(props: TabItem): void;\n removeTab(id: string): void;\n}\n\nexport const TabsContext = createContext<TabsContext | undefined>(undefined);\n\nexport interface TabsImperativeApi {\n switchTab(index: number): void;\n getActiveIndex(): number;\n}\n/**\n * Use Tabs component to display a list of choices, once the handler is triggered.\n */\nexport const Tabs = forwardRef<TabsImperativeApi | undefined, TabsProps>((props, ref) => {\n const [activeTabIndex, setActiveIndex] = useState(0);\n const [tabs, setTabs] = useState<TabItem[]>([]);\n\n const activeIndex = props.value !== undefined ? props.value : activeTabIndex;\n\n const activateTabIndex = useCallback((index: number) => {\n if (typeof props.updateValue === \"function\") {\n props.updateValue(index);\n return;\n }\n\n setActiveIndex(index);\n }, []);\n\n useImperativeHandle(ref, () => ({\n getActiveIndex() {\n return activeIndex;\n },\n switchTab(tabIndex: number) {\n activateTabIndex(tabIndex);\n }\n }));\n\n /**\n * This effect will make sure that disabled tabs automatically switch to the first tab.\n */\n useEffect(() => {\n if (tabs[activeIndex]?.disabled) {\n activateTabIndex(0);\n }\n });\n\n /* We need to generate a key like this to trigger a proper component re-render when child tabs change. */\n const tabBar = (\n <TabBar\n key={tabs.map(tab => tab.id).join(\";\")}\n className=\"webiny-ui-tabs__tab-bar\"\n activeTabIndex={activeIndex}\n onActivate={evt => {\n if (typeof props.updateValue === \"function\") {\n props.updateValue(evt.detail.index);\n } else {\n setActiveIndex(evt.detail.index);\n }\n props.onActivate && props.onActivate(evt.detail.index);\n }}\n >\n {tabs.map(item => {\n if (!item.visible) {\n return null;\n }\n\n const style = item.style || {};\n if (item.disabled) {\n Object.assign(style, disabledStyles);\n }\n\n return (\n <RmwcTab\n tag={\"div\"}\n style={style}\n key={item.id}\n data-testid={item[\"data-testid\"]}\n {...(item.icon ? { icon: item.icon } : {})}\n >\n {item.label}\n </RmwcTab>\n );\n })}\n </TabBar>\n );\n\n const content = tabs.filter(Boolean).map((tab, index) => {\n if (activeIndex === index) {\n return <div key={index}>{tab.children}</div>;\n } else {\n return (\n <div key={index} style={{ display: \"none\" }}>\n {tab.children}\n </div>\n );\n }\n });\n\n const context: TabsContext = useMemo(\n () => ({\n addTab(props) {\n setTabs(tabs => {\n const existingIndex = tabs.findIndex(tab => tab.id === props.id);\n if (existingIndex > -1) {\n return [\n ...tabs.slice(0, existingIndex),\n props,\n ...tabs.slice(existingIndex + 1)\n ];\n }\n return [...tabs, props];\n });\n },\n removeTab(id) {\n setTabs(tabs => tabs.filter(tab => tab.id === id));\n }\n }),\n [setTabs]\n );\n\n return (\n <div className={classNames(\"webiny-ui-tabs\", props.className)}>\n {tabBar}\n <div className={\"webiny-ui-tabs__content mdc-tab-content\"}>{content}</div>\n <TabsContext.Provider value={context}>{props.children}</TabsContext.Provider>\n </div>\n );\n});\n\nTabs.displayName = \"Tabs\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAUA;;AACA;;AA6BA,IAAMA,cAA+C,GAAG;EACpDC,OAAO,EAAE,GAD2C;EAEpDC,aAAa,EAAE;AAFqC,CAAxD;AAcO,IAAMC,WAAW,gBAAG,IAAAC,oBAAA,EAAuCC,SAAvC,CAApB;;;AAMP;AACA;AACA;AACO,IAAMC,IAAI,gBAAG,IAAAC,iBAAA,EAAqD,UAACC,KAAD,EAAQC,GAAR,EAAgB;EACrF,gBAAyC,IAAAC,eAAA,EAAS,CAAT,CAAzC;EAAA;EAAA,IAAOC,cAAP;EAAA,IAAuBC,cAAvB;;EACA,iBAAwB,IAAAF,eAAA,EAAoB,EAApB,CAAxB;EAAA;EAAA,IAAOG,IAAP;EAAA,IAAaC,O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,CAACsC,SAAL,CAAe,UAAAtB,GAAG;YAAA,OAAIA,GAAG,CAACC,EAAJ,KAAWtB,KAAK,CAACsB,EAArB;UAAA,CAAlB,CAAtB;;UACA,IAAIoB,aAAa,GAAG,CAAC,CAArB,EAAwB;YACpB,kDACOrC,IAAI,CAACuC,KAAL,CAAW,CAAX,EAAcF,aAAd,CADP,IAEI1C,KAFJ,oCAGOK,IAAI,CAACuC,KAAL,CAAWF,aAAa,GAAG,CAA3B,CAHP;UAKH;;UACD,kDAAWrC,IAAX,IAAiBL,KAAjB;QACH,CAVM,CAAP;MAWH,CAbE;MAcH6C,SAdG,qBAcOvB,EAdP,EAcW;QACVhB,OAAO,CAAC,UAAAD,IAAI;UAAA,OAAIA,IAAI,CAAC8B,MAAL,CAAY,UAAAd,GAAG;YAAA,OAAIA,GAAG,CAACC,EAAJ,KAAWA,EAAf;UAAA,CAAf,CAAJ;QAAA,CAAL,CAAP;MACH;IAhBE,CAAP;EAAA,CADyB,EAmBzB,CAAChB,OAAD,CAnByB,CAA7B;EAsBA,oBACI;IAAK,SAAS,EAAE,IAAAwC,mBAAA,EAAW,gBAAX,EAA6B9C,KAAK,CAAC+C,SAAnC;EAAhB,GACK5B,MADL,eAEI;IAAK,SAAS,EAAE;EAAhB,GAA4De,OAA5D,CAFJ,eAGI,6BAAC,WAAD,CAAa,QAAb;IAAsB,KAAK,EAAEK;EAA7B,GAAuCvC,KAAK,CAACqC,QAA7C,CAHJ,CADJ;AAOH,CAlHmB,CAAb;;AAoHPvC,IAAI,CAACkD,WAAL,GAAmB,MAAnB"}
|
package/Tags/Tags.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FormComponentProps } from "../types";
|
|
3
|
-
|
|
3
|
+
interface TagsProps extends FormComponentProps {
|
|
4
4
|
/**
|
|
5
5
|
* Component label.
|
|
6
6
|
*/
|
|
@@ -22,12 +22,9 @@ declare type TagsProps = FormComponentProps & {
|
|
|
22
22
|
*/
|
|
23
23
|
className?: string;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* A list of tags.
|
|
26
26
|
*/
|
|
27
|
-
value?:
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
};
|
|
27
|
+
value?: string[];
|
|
31
28
|
/**
|
|
32
29
|
* Callback that gets executed on change of input value.
|
|
33
30
|
*/
|
|
@@ -40,14 +37,10 @@ declare type TagsProps = FormComponentProps & {
|
|
|
40
37
|
* Automatically focus on the tags input.
|
|
41
38
|
*/
|
|
42
39
|
autoFocus?: boolean;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export declare class Tags extends React.Component<TagsProps, TagsState> {
|
|
48
|
-
state: {
|
|
49
|
-
inputValue: string;
|
|
50
|
-
};
|
|
51
|
-
render(): JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* Protected tags cannot be removed by the user.
|
|
42
|
+
*/
|
|
43
|
+
protectedTags?: string[];
|
|
52
44
|
}
|
|
45
|
+
export declare const Tags: React.FC<TagsProps>;
|
|
53
46
|
export default Tags;
|
package/Tags/Tags.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -13,33 +15,25 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
13
15
|
|
|
14
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
17
|
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
22
|
+
var _emotion = require("emotion");
|
|
25
23
|
|
|
26
|
-
var
|
|
24
|
+
var _keycode = _interopRequireDefault(require("keycode"));
|
|
27
25
|
|
|
28
|
-
var
|
|
26
|
+
var _minimatch = _interopRequireDefault(require("minimatch"));
|
|
29
27
|
|
|
30
28
|
var _Input = require("../Input");
|
|
31
29
|
|
|
32
30
|
var _Chips = require("../Chips");
|
|
33
31
|
|
|
34
|
-
var _emotion = require("emotion");
|
|
35
|
-
|
|
36
|
-
var _keycode = _interopRequireDefault(require("keycode"));
|
|
37
|
-
|
|
38
32
|
var _baselineClose24px = require("./icons/baseline-close-24px.svg");
|
|
39
33
|
|
|
40
34
|
var _FormElementMessage = require("../FormElementMessage");
|
|
41
35
|
|
|
42
|
-
var _excluded = ["validation", "value", "disabled", "onChange", "description"];
|
|
36
|
+
var _excluded = ["validation", "value", "disabled", "onChange", "description", "protectedTags"];
|
|
43
37
|
var tagsStyle = /*#__PURE__*/(0, _emotion.css)({
|
|
44
38
|
position: "relative",
|
|
45
39
|
".mdc-elevation--z1": {
|
|
@@ -62,110 +56,87 @@ var tagsStyle = /*#__PURE__*/(0, _emotion.css)({
|
|
|
62
56
|
}
|
|
63
57
|
}, "label:tagsStyle;");
|
|
64
58
|
|
|
65
|
-
var Tags =
|
|
66
|
-
(0,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
var Tags = function Tags(props) {
|
|
60
|
+
var _useState = (0, _react.useState)(""),
|
|
61
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
62
|
+
inputValue = _useState2[0],
|
|
63
|
+
setInputValue = _useState2[1];
|
|
64
|
+
|
|
65
|
+
var validation = props.validation,
|
|
66
|
+
value = props.value,
|
|
67
|
+
disabled = props.disabled,
|
|
68
|
+
onChange = props.onChange,
|
|
69
|
+
description = props.description,
|
|
70
|
+
_props$protectedTags = props.protectedTags,
|
|
71
|
+
protectedTags = _props$protectedTags === void 0 ? [] : _props$protectedTags,
|
|
72
|
+
otherInputProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
73
|
+
var isProtected = (0, _react.useCallback)(function (tag) {
|
|
74
|
+
return protectedTags.some(function (pattern) {
|
|
75
|
+
return (0, _minimatch.default)(tag, pattern);
|
|
82
76
|
});
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
inputValue
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
onKeyDown: function onKeyDown(ev) {
|
|
106
|
-
if (!onChange) {
|
|
107
|
-
return;
|
|
77
|
+
}, [protectedTags]);
|
|
78
|
+
var inputProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, otherInputProps), {}, {
|
|
79
|
+
value: inputValue,
|
|
80
|
+
onChange: function onChange(inputValue) {
|
|
81
|
+
setInputValue(inputValue);
|
|
82
|
+
},
|
|
83
|
+
onKeyDown: function onKeyDown(ev) {
|
|
84
|
+
if (!onChange) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var newValue = Array.isArray(value) ? (0, _toConsumableArray2.default)(value) : [];
|
|
89
|
+
/**
|
|
90
|
+
* We must cast as keycode only works with Event | string type.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
switch ((0, _keycode.default)(ev)) {
|
|
94
|
+
case "enter":
|
|
95
|
+
if (inputValue) {
|
|
96
|
+
newValue.push(inputValue);
|
|
97
|
+
onChange(newValue);
|
|
98
|
+
setInputValue("");
|
|
108
99
|
}
|
|
109
100
|
|
|
110
|
-
|
|
111
|
-
var inputValue = _this2.state.inputValue || "";
|
|
112
|
-
/**
|
|
113
|
-
* We must cast as keycode only works with Event | string type.
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
switch ((0, _keycode.default)(ev)) {
|
|
117
|
-
case "enter":
|
|
118
|
-
if (inputValue) {
|
|
119
|
-
newValue.push(inputValue);
|
|
120
|
-
onChange(newValue);
|
|
121
|
-
|
|
122
|
-
_this2.setState({
|
|
123
|
-
inputValue: ""
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
break;
|
|
101
|
+
break;
|
|
128
102
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
var _ref = validation || {},
|
|
141
|
-
validationIsValid = _ref.isValid,
|
|
142
|
-
validationMessage = _ref.message;
|
|
143
|
-
|
|
144
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
145
|
-
className: tagsStyle
|
|
146
|
-
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Input.Input, inputProps), validationIsValid === false && /*#__PURE__*/_react.default.createElement(_FormElementMessage.FormElementMessage, {
|
|
147
|
-
error: true
|
|
148
|
-
}, validationMessage), validationIsValid !== false && description && /*#__PURE__*/_react.default.createElement(_FormElementMessage.FormElementMessage, null, description), Array.isArray(value) && value.length ? /*#__PURE__*/_react.default.createElement(_Chips.Chips, {
|
|
149
|
-
disabled: disabled
|
|
150
|
-
}, value.map(function (item, index) {
|
|
151
|
-
return /*#__PURE__*/_react.default.createElement(_Chips.Chip, {
|
|
152
|
-
label: item,
|
|
153
|
-
trailingIcon: /*#__PURE__*/_react.default.createElement(_baselineClose24px.ReactComponent, null),
|
|
154
|
-
key: "".concat(item, "-").concat(index),
|
|
155
|
-
onRemove: function onRemove() {
|
|
156
|
-
// On removal, let's update the value and call "onChange" callback.
|
|
157
|
-
if (onChange) {
|
|
158
|
-
var newValue = (0, _toConsumableArray2.default)(value);
|
|
159
|
-
newValue.splice(index, 1);
|
|
160
|
-
onChange(newValue);
|
|
161
|
-
}
|
|
103
|
+
case "backspace":
|
|
104
|
+
if (newValue.length && !inputValue) {
|
|
105
|
+
newValue.splice(-1, 1);
|
|
106
|
+
onChange(newValue);
|
|
107
|
+
break;
|
|
162
108
|
}
|
|
163
|
-
|
|
164
|
-
}
|
|
109
|
+
|
|
110
|
+
}
|
|
165
111
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
var _ref = validation || {},
|
|
115
|
+
validationIsValid = _ref.isValid,
|
|
116
|
+
validationMessage = _ref.message;
|
|
117
|
+
|
|
118
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
119
|
+
className: tagsStyle
|
|
120
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Input.Input, inputProps), validationIsValid === false && /*#__PURE__*/_react.default.createElement(_FormElementMessage.FormElementMessage, {
|
|
121
|
+
error: true
|
|
122
|
+
}, validationMessage), validationIsValid !== false && description && /*#__PURE__*/_react.default.createElement(_FormElementMessage.FormElementMessage, null, description), Array.isArray(value) && value.length ? /*#__PURE__*/_react.default.createElement(_Chips.Chips, {
|
|
123
|
+
disabled: disabled
|
|
124
|
+
}, value.map(function (item, index) {
|
|
125
|
+
return /*#__PURE__*/_react.default.createElement(_Chips.Chip, {
|
|
126
|
+
label: item,
|
|
127
|
+
trailingIcon: isProtected(item) ? null : /*#__PURE__*/_react.default.createElement(_baselineClose24px.ReactComponent, null),
|
|
128
|
+
key: "".concat(item, "-").concat(index),
|
|
129
|
+
onRemove: function onRemove() {
|
|
130
|
+
// On removal, let's update the value and call "onChange" callback.
|
|
131
|
+
if (onChange) {
|
|
132
|
+
var newValue = (0, _toConsumableArray2.default)(value);
|
|
133
|
+
newValue.splice(index, 1);
|
|
134
|
+
onChange(newValue);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
})) : null));
|
|
139
|
+
};
|
|
169
140
|
|
|
170
141
|
exports.Tags = Tags;
|
|
171
142
|
var _default = Tags;
|
package/Tags/Tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["tagsStyle","css","position","width","left","top","zIndex","maxHeight","overflowY","backgroundColor","ul","listStyle","padding","li","Tags","inputValue","
|
|
1
|
+
{"version":3,"names":["tagsStyle","css","position","width","left","top","zIndex","maxHeight","overflowY","backgroundColor","ul","listStyle","padding","li","Tags","props","useState","inputValue","setInputValue","validation","value","disabled","onChange","description","protectedTags","otherInputProps","isProtected","useCallback","tag","some","pattern","minimatch","inputProps","onKeyDown","ev","newValue","Array","isArray","keycode","push","length","splice","validationIsValid","isValid","validationMessage","message","map","item","index"],"sources":["Tags.tsx"],"sourcesContent":["import React, { SyntheticEvent, useCallback, useState } from \"react\";\nimport { css } from \"emotion\";\nimport keycode from \"keycode\";\nimport minimatch from \"minimatch\";\nimport { Input, InputProps } from \"~/Input\";\nimport { Chips, Chip } from \"~/Chips\";\nimport { FormComponentProps } from \"~/types\";\nimport { ReactComponent as BaselineCloseIcon } from \"./icons/baseline-close-24px.svg\";\nimport { FormElementMessage } from \"~/FormElementMessage\";\n\ninterface TagsProps extends FormComponentProps {\n /**\n * Component label.\n */\n label?: string;\n\n /**\n * Are input and chosen tags disabled?\n */\n disabled?: boolean;\n\n /**\n * Placeholder text for the form control. Set to a blank string to create a non-floating placeholder label.\n */\n placeholder?: string;\n\n /**\n * Description beneath the input.\n */\n description?: string;\n\n /**\n * A className for the root element.\n */\n className?: string;\n\n /**\n * A list of tags.\n */\n value?: string[];\n\n /**\n * Callback that gets executed on change of input value.\n */\n onInput?: Function;\n\n /**\n * Callback that gets executed when the input is focused.\n */\n onFocus?: Function;\n\n /**\n * Automatically focus on the tags input.\n */\n autoFocus?: boolean;\n\n /**\n * Protected tags cannot be removed by the user.\n */\n protectedTags?: string[];\n}\n\nconst tagsStyle = css({\n position: \"relative\",\n \".mdc-elevation--z1\": {\n position: \"absolute\",\n width: \"calc(100% - 2px)\",\n left: 1,\n top: 56,\n zIndex: 10,\n maxHeight: 200,\n overflowY: \"scroll\",\n backgroundColor: \"var(--mdc-theme-surface)\"\n },\n ul: {\n listStyle: \"none\",\n width: \"100%\",\n padding: 0,\n li: {\n padding: 10\n }\n }\n});\n\nexport const Tags: React.FC<TagsProps> = props => {\n const [inputValue, setInputValue] = useState(\"\");\n\n const {\n validation,\n value,\n disabled,\n onChange,\n description,\n protectedTags = [],\n ...otherInputProps\n } = props;\n\n const isProtected = useCallback(\n (tag: string) => protectedTags.some(pattern => minimatch(tag, pattern)),\n [protectedTags]\n );\n\n const inputProps: InputProps<string> = {\n ...otherInputProps,\n value: inputValue,\n onChange: inputValue => {\n setInputValue(inputValue);\n },\n onKeyDown: (ev: SyntheticEvent) => {\n if (!onChange) {\n return;\n }\n\n const newValue = Array.isArray(value) ? [...value] : [];\n\n /**\n * We must cast as keycode only works with Event | string type.\n */\n switch (keycode(ev as unknown as Event)) {\n case \"enter\":\n if (inputValue) {\n newValue.push(inputValue);\n onChange(newValue);\n setInputValue(\"\");\n }\n break;\n case \"backspace\":\n if (newValue.length && !inputValue) {\n newValue.splice(-1, 1);\n onChange(newValue);\n break;\n }\n }\n }\n };\n\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n\n return (\n <div className={tagsStyle}>\n <div>\n <Input {...inputProps} />\n\n {validationIsValid === false && (\n <FormElementMessage error>{validationMessage}</FormElementMessage>\n )}\n {validationIsValid !== false && description && (\n <FormElementMessage>{description}</FormElementMessage>\n )}\n\n {Array.isArray(value) && value.length ? (\n <Chips disabled={disabled}>\n {value.map((item, index) => {\n return (\n <Chip\n label={item}\n trailingIcon={isProtected(item) ? null : <BaselineCloseIcon />}\n key={`${item}-${index}`}\n onRemove={() => {\n // On removal, let's update the value and call \"onChange\" callback.\n if (onChange) {\n const newValue = [...value];\n newValue.splice(index, 1);\n onChange(newValue);\n }\n }}\n />\n );\n })}\n </Chips>\n ) : null}\n </div>\n </div>\n );\n};\n\nexport default Tags;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;AAsDA,IAAMA,SAAS,gBAAG,IAAAC,YAAA,EAAI;EAClBC,QAAQ,EAAE,UADQ;EAElB,sBAAsB;IAClBA,QAAQ,EAAE,UADQ;IAElBC,KAAK,EAAE,kBAFW;IAGlBC,IAAI,EAAE,CAHY;IAIlBC,GAAG,EAAE,EAJa;IAKlBC,MAAM,EAAE,EALU;IAMlBC,SAAS,EAAE,GANO;IAOlBC,SAAS,EAAE,QAPO;IAQlBC,eAAe,EAAE;EARC,CAFJ;EAYlBC,EAAE,EAAE;IACAC,SAAS,EAAE,MADX;IAEAR,KAAK,EAAE,MAFP;IAGAS,OAAO,EAAE,CAHT;IAIAC,EAAE,EAAE;MACAD,OAAO,EAAE;IADT;EAJJ;AAZc,CAAJ,qBAAlB;;AAsBO,IAAME,IAAyB,GAAG,SAA5BA,IAA4B,CAAAC,KAAK,EAAI;EAC9C,gBAAoC,IAAAC,eAAA,EAAS,EAAT,CAApC;EAAA;EAAA,IAAOC,UAAP;EAAA,IAAmBC,aAAnB;;EAEA,IACIC,UADJ,GAQIJ,KARJ,CACII,UADJ;EAAA,IAEIC,KAFJ,GAQIL,KARJ,CAEIK,KAFJ;EAAA,IAGIC,QA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CA,WAAmEhB,UAAU,IAAI,EAAjF;EAAA,IAAiBuB,iBAAjB,QAAQC,OAAR;EAAA,IAA6CC,iBAA7C,QAAoCC,OAApC;;EAEA,oBACI;IAAK,SAAS,EAAE7C;EAAhB,gBACI,uDACI,6BAAC,YAAD,EAAWgC,UAAX,CADJ,EAGKU,iBAAiB,KAAK,KAAtB,iBACG,6BAAC,sCAAD;IAAoB,KAAK;EAAzB,GAA2BE,iBAA3B,CAJR,EAMKF,iBAAiB,KAAK,KAAtB,IAA+BnB,WAA/B,iBACG,6BAAC,sCAAD,QAAqBA,WAArB,CAPR,EAUKa,KAAK,CAACC,OAAN,CAAcjB,KAAd,KAAwBA,KAAK,CAACoB,MAA9B,gBACG,6BAAC,YAAD;IAAO,QAAQ,EAAEnB;EAAjB,GACKD,KAAK,CAAC0B,GAAN,CAAU,UAACC,IAAD,EAAOC,KAAP,EAAiB;IACxB,oBACI,6BAAC,WAAD;MACI,KAAK,EAAED,IADX;MAEI,YAAY,EAAErB,WAAW,CAACqB,IAAD,CAAX,GAAoB,IAApB,gBAA2B,6BAAC,iCAAD,OAF7C;MAGI,GAAG,YAAKA,IAAL,cAAaC,KAAb,CAHP;MAII,QAAQ,EAAE,oBAAM;QACZ;QACA,IAAI1B,QAAJ,EAAc;UACV,IAAMa,QAAQ,oCAAOf,KAAP,CAAd;UACAe,QAAQ,CAACM,MAAT,CAAgBO,KAAhB,EAAuB,CAAvB;UACA1B,QAAQ,CAACa,QAAD,CAAR;QACH;MACJ;IAXL,EADJ;EAeH,CAhBA,CADL,CADH,GAoBG,IA9BR,CADJ,CADJ;AAoCH,CA1FM;;;eA4FQrB,I"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TypographyProps as RmwcTypographyProps } from "@rmwc/typography";
|
|
3
|
-
|
|
3
|
+
interface TypographyProps extends RmwcTypographyProps {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
style?: React.CSSProperties;
|
|
@@ -10,4 +10,4 @@ export interface TypographyProps extends RmwcTypographyProps {
|
|
|
10
10
|
* Use Ripple component to display a list of choices, once the handler is triggered.
|
|
11
11
|
*/
|
|
12
12
|
declare const Typography: React.FC<TypographyProps>;
|
|
13
|
-
export { Typography };
|
|
13
|
+
export { Typography, TypographyProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Typography","props","children"],"sources":["Typography.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n Typography as RwmcTypography,\n TypographyProps as RmwcTypographyProps\n} from \"@rmwc/typography\";\n\
|
|
1
|
+
{"version":3,"names":["Typography","props","children"],"sources":["Typography.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n Typography as RwmcTypography,\n TypographyProps as RmwcTypographyProps\n} from \"@rmwc/typography\";\n\ninterface TypographyProps extends RmwcTypographyProps {\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n tag?: string;\n}\n\n/**\n * Use Ripple component to display a list of choices, once the handler is triggered.\n */\nconst Typography: React.FC<TypographyProps> = props => {\n return <RwmcTypography {...props}>{props.children}</RwmcTypography>;\n};\n\nexport { Typography, TypographyProps };\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAYA;AACA;AACA;AACA,IAAMA,UAAqC,GAAG,SAAxCA,UAAwC,CAAAC,KAAK,EAAI;EACnD,oBAAO,6BAAC,sBAAD,EAAoBA,KAApB,EAA4BA,KAAK,CAACC,QAAlC,CAAP;AACH,CAFD"}
|