-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
815 additions
and
677 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script> | ||
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script> | ||
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,11 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import invariant from 'invariant'; | ||
import hoistStatics from 'hoist-non-react-statics'; | ||
import { withFieldsCollection as baseWithFieldsCollection } from '@panneau/core'; | ||
|
||
import defaultFieldsCollection from './fields'; | ||
import defaultFieldsCollection from './items'; | ||
|
||
function getDisplayName(WrappedComponent) { | ||
return WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
} | ||
const withFieldsCollection = opts => baseWithFieldsCollection({ | ||
withRef: false, | ||
fieldsCollection: defaultFieldsCollection, | ||
...opts, | ||
}); | ||
|
||
const propTypes = { | ||
fieldsCollection: PropTypes.shape({ | ||
getComponent: PropTypes.func, | ||
}), | ||
}; | ||
|
||
const defaultProps = { | ||
fieldsCollection: null, | ||
}; | ||
|
||
const childContextTypes = { | ||
fieldsCollection: PropTypes.shape({ | ||
getComponent: PropTypes.func, | ||
}), | ||
}; | ||
|
||
export default function withFieldsCollection(opts) { | ||
const options = { | ||
withRef: false, | ||
fieldsCollection: defaultFieldsCollection, | ||
...opts, | ||
}; | ||
return (WrappedComponent) => { | ||
class WithFieldsCollection extends Component { | ||
static getWrappedInstance() { | ||
invariant( | ||
options.withRef, | ||
'To access the wrapped instance, you need to specify `{ withRef: true }` as the third argument of the withFieldsCollection() call.', | ||
); | ||
|
||
return this.wrappedInstance; | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
this.wrappedInstance = null; | ||
} | ||
|
||
getChildContext() { | ||
return { | ||
fieldsCollection: options.fieldsCollection, | ||
}; | ||
} | ||
|
||
render() { | ||
const props = { | ||
...this.props, | ||
fieldsCollection: options.fieldsCollection, | ||
}; | ||
if (options.withRef) { | ||
props.ref = (c) => { | ||
this.wrappedInstance = c; | ||
}; | ||
} | ||
|
||
return ( | ||
<WrappedComponent {...props} /> | ||
); | ||
} | ||
} | ||
|
||
WithFieldsCollection.propTypes = propTypes; | ||
WithFieldsCollection.defaultProps = defaultProps; | ||
WithFieldsCollection.childContextTypes = childContextTypes; | ||
WithFieldsCollection.displayName = `withFieldsCollection(${getDisplayName(WrappedComponent)})`; | ||
WithFieldsCollection.WrappedComponent = WrappedComponent; | ||
|
||
const WithFieldsCollectionComponent = hoistStatics(WithFieldsCollection, WrappedComponent); | ||
|
||
return WithFieldsCollectionComponent; | ||
}; | ||
} | ||
export default withFieldsCollection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,11 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import invariant from 'invariant'; | ||
import hoistStatics from 'hoist-non-react-statics'; | ||
import { withFormsCollection as baseWithFormsCollection } from '@panneau/core'; | ||
|
||
import defaultCollection from './items'; | ||
import defaultFormsCollection from './items'; | ||
|
||
function getDisplayName(WrappedComponent) { | ||
return WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
} | ||
const withFormsCollection = opts => baseWithFormsCollection({ | ||
withRef: false, | ||
formsCollection: defaultFormsCollection, | ||
...opts, | ||
}); | ||
|
||
const propTypes = { | ||
formsCollection: PropTypes.shape({ | ||
getComponent: PropTypes.func, | ||
}), | ||
}; | ||
|
||
const defaultProps = { | ||
formsCollection: null, | ||
}; | ||
|
||
const childContextTypes = { | ||
formsCollection: PropTypes.shape({ | ||
getComponent: PropTypes.func, | ||
}), | ||
}; | ||
|
||
export default function withFormsCollection(opts) { | ||
const options = { | ||
withRef: false, | ||
formsCollection: defaultCollection, | ||
...opts, | ||
}; | ||
return (WrappedComponent) => { | ||
class WithFormsCollection extends Component { | ||
static getWrappedInstance() { | ||
invariant( | ||
options.withRef, | ||
'To access the wrapped instance, you need to specify `{ withRef: true }` as the third argument of the withFormsCollection() call.', | ||
); | ||
|
||
return this.wrappedInstance; | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
this.wrappedInstance = null; | ||
} | ||
|
||
getChildContext() { | ||
return { | ||
formsCollection: options.formsCollection, | ||
}; | ||
} | ||
|
||
render() { | ||
const props = { | ||
...this.props, | ||
formsCollection: options.formsCollection, | ||
}; | ||
if (options.withRef) { | ||
props.ref = (c) => { | ||
this.wrappedInstance = c; | ||
}; | ||
} | ||
|
||
return ( | ||
<WrappedComponent {...props} /> | ||
); | ||
} | ||
} | ||
|
||
WithFormsCollection.propTypes = propTypes; | ||
WithFormsCollection.defaultProps = defaultProps; | ||
WithFormsCollection.childContextTypes = childContextTypes; | ||
WithFormsCollection.displayName = `withFormsCollection(${getDisplayName(WrappedComponent)})`; | ||
WithFormsCollection.WrappedComponent = WrappedComponent; | ||
|
||
const WithFormsCollectionComponent = hoistStatics( | ||
WithFormsCollection, | ||
WrappedComponent, | ||
); | ||
return WithFormsCollectionComponent; | ||
}; | ||
} | ||
export default withFormsCollection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import withLayoutsCollection from './withLayoutsCollection'; | ||
import layoutsCollection from './layouts'; | ||
import layoutsCollection from './items'; | ||
|
||
export { | ||
withLayoutsCollection, | ||
}; | ||
export { withLayoutsCollection }; | ||
|
||
export default layoutsCollection; |
File renamed without changes.
Oops, something went wrong.