@lu-development/ux-patterns-react
Advanced tools
Comparing version 1.6.0-dev.201910071538.b9ebf60 to 1.6.0-dev.201910071807.44558a1
import React from 'react'; | ||
export declare const createReactComponent: <PropType, ElementType>(tagName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").IonicReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>; | ||
export declare function createReactComponent<PropType, ElementType>(tagName: string): React.ForwardRefExoticComponent<React.PropsWithoutRef<PropType & { | ||
ref?: React.RefObject<ElementType>; | ||
children?: React.ReactNode; | ||
}> & React.RefAttributes<ElementType>>; |
@@ -13,43 +13,32 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import React from 'react'; | ||
import ReactDom from 'react-dom'; | ||
import { attachEventProps, createForwardRef, dashToPascalCase, isCoveredByReact } from './utils'; | ||
import { deprecationWarning } from './utils/dev'; | ||
export const createReactComponent = (tagName) => { | ||
import ReactDOM from 'react-dom'; | ||
import { dashToPascalCase, attachEventProps } from './utils'; | ||
export function createReactComponent(tagName) { | ||
const displayName = dashToPascalCase(tagName); | ||
const ReactComponent = class extends React.Component { | ||
class ReactComponent extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.componentRef = React.createRef(); | ||
} | ||
static get displayName() { | ||
return displayName; | ||
} | ||
componentDidMount() { | ||
this.componentDidUpdate(this.props); | ||
if (this.props.href) { | ||
setTimeout(() => { | ||
deprecationWarning('hrefchange', 'As of RC3, href links no longer go through the router, so transitions will not be applied to these links. To maintain transitions, use the new routerLink prop.'); | ||
}, 2000); | ||
} | ||
this.componentWillReceiveProps(this.props); | ||
} | ||
componentDidUpdate(prevProps) { | ||
const node = ReactDom.findDOMNode(this); | ||
attachEventProps(node, this.props, prevProps); | ||
componentWillReceiveProps(props) { | ||
const node = ReactDOM.findDOMNode(this); | ||
attachEventProps(node, props, this.props); | ||
} | ||
render() { | ||
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]); | ||
const propsToPass = Object.keys(cProps).reduce((acc, name) => { | ||
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) { | ||
const eventName = name.substring(2).toLowerCase(); | ||
if (isCoveredByReact(eventName)) { | ||
acc[name] = cProps[name]; | ||
} | ||
} | ||
return acc; | ||
}, {}); | ||
const newProps = Object.assign({}, propsToPass, { ref: forwardedRef, style }); | ||
return React.createElement(tagName, newProps, children); | ||
const _a = this.props, { children, forwardedRef } = _a, cProps = __rest(_a, ["children", "forwardedRef"]); | ||
return React.createElement(tagName, Object.assign({}, cProps, { ref: forwardedRef }), children); | ||
} | ||
static get displayName() { | ||
return displayName; | ||
} | ||
}; | ||
return createForwardRef(ReactComponent, displayName); | ||
}; | ||
} | ||
function forwardRef(props, ref) { | ||
return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref })); | ||
} | ||
forwardRef.displayName = displayName; | ||
return React.forwardRef(forwardRef); | ||
} | ||
//# sourceMappingURL=createComponent.js.map |
/// <reference types="react" /> | ||
import { JSX } from '@lu-development/ux-patterns/dist/types/interface'; | ||
export declare const LuIcon: import("react").ForwardRefExoticComponent<JSX.LuIcon & Pick<import("react").HTMLAttributes<HTMLLuIconElement>, "hidden" | "dir" | "slot" | "title" | "color" | "children" | "className" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("./LuReactProps").LuReactProps & import("react").RefAttributes<HTMLLuIconElement>>; | ||
export declare const LuSelect: import("react").ForwardRefExoticComponent<JSX.LuSelect & Pick<import("react").HTMLAttributes<HTMLLuSelectElement>, "hidden" | "dir" | "slot" | "title" | "color" | "children" | "className" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("./LuReactProps").LuReactProps & import("react").RefAttributes<HTMLLuSelectElement>>; | ||
import { ReactProps } from './ReactProps'; | ||
export declare const LuIcon: import("react").ForwardRefExoticComponent<Pick<JSX.LuIcon & ReactProps & { | ||
ref?: import("react").RefObject<HTMLLuIconElement>; | ||
children?: import("react").ReactNode; | ||
}, "hidden" | "dir" | "slot" | "style" | "title" | "contextmenu" | "ios" | "md" | "color" | "size" | "icon" | "children" | "className" | "key" | "ariaLabel" | "flipRtl" | "mode" | "name" | "src" | "innerHTML" | "accessKey" | "class" | "contentEditable" | "contenteditable" | "contextMenu" | "draggable" | "id" | "lang" | "spellCheck" | "spellcheck" | "tabIndex" | "tabindex" | "inputMode" | "inputmode" | "is" | "radioGroup" | "radiogroup" | "part" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autocapitalize" | "autoCorrect" | "autocorrect" | "autoSave" | "autosave" | "itemProp" | "itemprop" | "itemScope" | "itemscope" | "itemType" | "itemtype" | "itemID" | "itemid" | "itemRef" | "itemref" | "results" | "security" | "unselectable" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAuxClick" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDblClick" | "onDblClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("react").RefAttributes<HTMLLuIconElement>>; | ||
export declare const LuSelect: import("react").ForwardRefExoticComponent<Pick<JSX.LuSelect & ReactProps & { | ||
ref?: import("react").RefObject<HTMLLuSelectElement>; | ||
children?: import("react").ReactNode; | ||
}, "required" | "disabled" | "hidden" | "dir" | "slot" | "style" | "title" | "contextmenu" | "invalid" | "color" | "children" | "className" | "key" | "ariaLabel" | "name" | "innerHTML" | "accessKey" | "class" | "contentEditable" | "contenteditable" | "contextMenu" | "draggable" | "id" | "lang" | "spellCheck" | "spellcheck" | "tabIndex" | "tabindex" | "inputMode" | "inputmode" | "is" | "radioGroup" | "radiogroup" | "part" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autocapitalize" | "autoCorrect" | "autocorrect" | "autoSave" | "autosave" | "itemProp" | "itemprop" | "itemScope" | "itemscope" | "itemType" | "itemtype" | "itemID" | "itemid" | "itemRef" | "itemref" | "results" | "security" | "unselectable" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAuxClick" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDblClick" | "onDblClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "helpText" | "onLuBlur" | "onLuChange" | "onLuComponentError" | "onLuFocus" | "onLuInput" | "onLuStyle" | "options" | "placeholder" | "selectedValueName" | "showPlaceholderOption" | "useId" | "valid" | "value"> & import("react").RefAttributes<HTMLLuSelectElement>>; |
@@ -1,3 +0,3 @@ | ||
export declare const attachEventProps: (node: HTMLElement, newProps: any, oldProps?: any) => void; | ||
export declare const getClassName: (classList: DOMTokenList, newProps: any, oldProps: any) => string; | ||
export declare function attachEventProps(node: HTMLElement, newProps: any, oldProps?: any): void; | ||
export declare function getClassName(classList: DOMTokenList, newProps: any, oldProps: any): string; | ||
/** | ||
@@ -7,3 +7,3 @@ * Checks if an event is supported in the current execution environment. | ||
*/ | ||
export declare const isCoveredByReact: (eventNameSuffix: string, doc?: Document) => boolean; | ||
export declare const syncEvent: (node: Element, eventName: string, newEventHandler: (e: Event) => any) => void; | ||
export declare function isCoveredByReact(eventNameSuffix: string, doc?: Document): boolean; | ||
export declare function syncEvent(node: Element, eventName: string, newEventHandler: (e: Event) => any): void; |
@@ -1,10 +0,8 @@ | ||
import { camelToDashCase } from './case'; | ||
export const attachEventProps = (node, newProps, oldProps = {}) => { | ||
// add any classes in className to the class list | ||
export function attachEventProps(node, newProps, oldProps = {}) { | ||
const className = getClassName(node.classList, newProps, oldProps); | ||
if (className !== '') { | ||
if (className) { | ||
node.className = className; | ||
} | ||
Object.keys(newProps).forEach(name => { | ||
if (name === 'children' || name === 'style' || name === 'ref' || name === 'class' || name === 'className' || name === 'forwardedRef') { | ||
if (name === 'children' || name === 'style' || name === 'ref' || name === 'className') { | ||
return; | ||
@@ -20,22 +18,15 @@ } | ||
else { | ||
if (typeof newProps[name] === 'object') { | ||
node[name] = newProps[name]; | ||
} | ||
else { | ||
node.setAttribute(camelToDashCase(name), newProps[name]); | ||
} | ||
node[name] = newProps[name]; | ||
} | ||
}); | ||
}; | ||
export const getClassName = (classList, newProps, oldProps) => { | ||
const newClassProp = newProps.className || newProps.class; | ||
const oldClassProp = oldProps.className || oldProps.class; | ||
} | ||
export function getClassName(classList, newProps, oldProps) { | ||
// map the classes to Maps for performance | ||
const currentClasses = arrayToMap(classList); | ||
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []); | ||
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []); | ||
const incomingPropClasses = arrayToMap(newProps.className ? newProps.className.split(' ') : []); | ||
const oldPropClasses = arrayToMap(oldProps.className ? oldProps.className.split(' ') : []); | ||
const finalClassNames = []; | ||
// loop through each of the current classes on the component | ||
// to see if it should be a part of the classNames added | ||
currentClasses.forEach(currentClass => { | ||
currentClasses.forEach((currentClass) => { | ||
if (incomingPropClasses.has(currentClass)) { | ||
@@ -53,3 +44,3 @@ // add it as its already included in classnames coming in from newProps | ||
return finalClassNames.join(' '); | ||
}; | ||
} | ||
/** | ||
@@ -59,3 +50,3 @@ * Checks if an event is supported in the current execution environment. | ||
*/ | ||
export const isCoveredByReact = (eventNameSuffix, doc = document) => { | ||
export function isCoveredByReact(eventNameSuffix, doc = document) { | ||
const eventName = 'on' + eventNameSuffix; | ||
@@ -69,4 +60,4 @@ let isSupported = eventName in doc; | ||
return isSupported; | ||
}; | ||
export const syncEvent = (node, eventName, newEventHandler) => { | ||
} | ||
export function syncEvent(node, eventName, newEventHandler) { | ||
const eventStore = node.__events || (node.__events = {}); | ||
@@ -80,12 +71,10 @@ const oldEventHandler = eventStore[eventName]; | ||
node.addEventListener(eventName, eventStore[eventName] = function handler(e) { | ||
if (newEventHandler) { | ||
newEventHandler.call(this, e); | ||
} | ||
newEventHandler.call(this, e); | ||
}); | ||
}; | ||
const arrayToMap = (arr) => { | ||
} | ||
function arrayToMap(arr) { | ||
const map = new Map(); | ||
arr.forEach((s) => map.set(s, s)); | ||
return map; | ||
}; | ||
} | ||
//# sourceMappingURL=attachEventProps.js.map |
@@ -1,6 +0,2 @@ | ||
import React from 'react'; | ||
import { LuReactProps } from '../LuReactProps'; | ||
export declare type IonicReactExternalProps<PropType, ElementType> = PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & LuReactProps; | ||
export declare const createForwardRef: <PropType, ElementType>(ReactComponent: any, displayName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<IonicReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>; | ||
export declare const dashToPascalCase: (str: string) => string; | ||
export * from './attachEventProps'; | ||
export * from './case'; |
@@ -1,11 +0,3 @@ | ||
import React from 'react'; | ||
export const createForwardRef = (ReactComponent, displayName) => { | ||
const forwardRef = (props, ref) => { | ||
return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref })); | ||
}; | ||
forwardRef.displayName = displayName; | ||
return React.forwardRef(forwardRef); | ||
}; | ||
export const dashToPascalCase = (str) => str.toLowerCase().split('-').map(segment => segment.charAt(0).toUpperCase() + segment.slice(1)).join(''); | ||
export * from './attachEventProps'; | ||
export * from './case'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@lu-development/ux-patterns-react", | ||
"version": "1.6.0-dev.201910071538.b9ebf60", | ||
"version": "1.6.0-dev.201910071807.44558a1", | ||
"description": "React specific wrapper for @lu-development/ux-patterns", | ||
@@ -27,29 +27,30 @@ "keywords": [], | ||
"devDependencies": { | ||
"@types/jest": "^23.3.9", | ||
"@trust/webcrypto": "^0.9.2", | ||
"@types/jest": "23.3.9", | ||
"@types/node": "10.12.9", | ||
"@types/react": "^16.9.2", | ||
"@types/react-dom": "^16.9.0", | ||
"fs-extra": "^8.1.0", | ||
"jest": "^24.8.0", | ||
"jest-dom": "^3.4.0", | ||
"np": "^5.0.1", | ||
"react": "^16.9.0", | ||
"react-dom": "^16.9.0", | ||
"@types/react": "16.7.6", | ||
"@types/react-dom": "16.0.9", | ||
"@types/react-router": "^4.4.4", | ||
"@types/react-router-dom": "^4.3.1", | ||
"fs-extra": "^8.0.1", | ||
"jest": "^23.0.0", | ||
"jest-dom": "^3.0.2", | ||
"np": "^3.1.0", | ||
"path": "^0.12.7", | ||
"react": "^16.7.0", | ||
"react-dom": "^16.7.0", | ||
"react-router": "^4.3.1", | ||
"react-router-dom": "^4.3.1", | ||
"react-testing-library": "^7.0.0", | ||
"rollup": "^1.18.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-sourcemaps": "^0.4.2", | ||
"rollup-plugin-virtual": "^1.0.1", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.18.0", | ||
"tslint-ionic-rules": "0.0.21", | ||
"tslint-react": "^4.0.0", | ||
"typescript": "3.5.3" | ||
"ts-jest": "^23.10.5", | ||
"typescript": "^3.2.2" | ||
}, | ||
"dependencies": { | ||
"@lu-development/ux-patterns": "1.6.0-dev.201910071538.b9ebf60" | ||
"@lu-development/ux-patterns": "1.6.0-dev.201910071807.44558a1" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6" | ||
"react": "^16.7.0", | ||
"react-dom": "^16.7.0", | ||
"react-router": "^4.3.1", | ||
"react-router-dom": "^4.3.1" | ||
}, | ||
@@ -56,0 +57,0 @@ "jest": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19
152223
5
54
2310
+ Added@babel/runtime@7.26.0(transitive)
+ Added@lu-development/ux-patterns@1.6.0-dev.201910071807.44558a1(transitive)
+ Addedhistory@4.10.1(transitive)
+ Addedhoist-non-react-statics@2.5.5(transitive)
+ Addedinvariant@2.2.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedpath-to-regexp@1.9.0(transitive)
+ Addedreact-router@4.3.1(transitive)
+ Addedreact-router-dom@4.3.1(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedresolve-pathname@3.0.0(transitive)
+ Addedtiny-invariant@1.3.3(transitive)
+ Addedtiny-warning@1.0.3(transitive)
+ Addedvalue-equal@1.0.1(transitive)
+ Addedwarning@4.0.3(transitive)
- Removed@lu-development/ux-patterns@1.6.0-dev.201910071538.b9ebf60(transitive)
Updated@lu-development/ux-patterns@1.6.0-dev.201910071807.44558a1