@meniga/utils
v6.1.36-alpha.0
Published
Small re-usable utils/decorators/helpers for meniga projects
Downloads
1,005
Readme
@meniga/utils
The utils library contains smalls re-usable utils/decorators/helpers for Meniga projects
High Order Component Helpers
This is a set of utility helpers to work with recompose.
componentDidMount
Hook into the component did mount life cycle event in recompose
componentDidUpdate
Hook into the component did update life cycle event in recompose
componentWillReceiveProps
DEPRECATED. Use componentDidUpdate instead.
componentWillMount
DEPRECATED. Use componentDidMount instead.
componentWillUnmount
Hook into the component will unmount life cycle event in recompose
composeConnect
Connect the redux store in a HOC
createContext
Create a context method from a single object in recompose
getWindowSize
Create hooks in recompose that attach to window resizing and store in the windowSize state
getElementPosition
Create hook in recompose that attaches to window event to supply the elements position in the position state
React Utils
createProps
Create a props object with the given PropType
keyboardClick
Create a props object that contains react handlers for keyboard enter and space to trigger an onClick handler
visibleChildren
Returns a flattened list of child elements
Redux
createTypes
Create a list of types with a given prefix
reducerUtils
Some utility functions for setting known properties on state such as error information
Other
containsValue
Test if the first string includes the second string
formatText
String format
isEqualValue
Does case insensitive string comparison
shouldUpdate
Takes in a set of props to watch and detects if they have changed at all between 2 props objects
textRelevance
Sort a result set by relevance with a given matchText
uuid
Generate a unique (UUID format) id string
triggerResize
Dispatch a resize event to the window object
Device Detection
Detect various devices:
- isMobile
- isMobileOrTablet
- isTablet
- isIOS
- isAndroid
queryUtils
Utility functions for working with the query string
- getQueryString
- appendToQuery
- getFilterQuery
- getIncludeQuery
- getSkipAndTakeQuery
Data
makeTree
Make a tree from a parent / child structure
addOtherToCategoryTree
Add 'other' category to category tree
sortArray
Sorts an array of strings or an array of objects