mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 08:19:42 +08:00
replaced singleSlot with slotSize
This commit is contained in:
@@ -604,7 +604,7 @@ export default class Comment extends React.Component {
|
||||
defaultComponent={CommentContent}
|
||||
{...slotProps}
|
||||
queryData={queryData}
|
||||
singleSlot
|
||||
slotSize={1}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -38,7 +38,7 @@ class Slot extends React.Component {
|
||||
'inline',
|
||||
'className',
|
||||
'reduxState',
|
||||
'singleSlot',
|
||||
'slotSize',
|
||||
'defaultComponent_',
|
||||
'queryData',
|
||||
'childFactory',
|
||||
@@ -47,7 +47,7 @@ class Slot extends React.Component {
|
||||
}
|
||||
|
||||
getChildren(props = this.props) {
|
||||
const { singleSlot = false } = props;
|
||||
const { slotSize = 0 } = props;
|
||||
const { plugins } = this.context;
|
||||
|
||||
return plugins.getSlotElements(
|
||||
@@ -55,7 +55,7 @@ class Slot extends React.Component {
|
||||
props.reduxState,
|
||||
this.getSlotProps(props),
|
||||
props.queryData,
|
||||
{ singleSlot }
|
||||
{ slotSize }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,9 +113,9 @@ Slot.propTypes = {
|
||||
defaultComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
||||
|
||||
/**
|
||||
* When true, only the first plugin will take the slot.
|
||||
* Specifies the number of children that can fill the slot.
|
||||
*/
|
||||
singleSlot: PropTypes.bool,
|
||||
slotSize: PropTypes.number,
|
||||
|
||||
/**
|
||||
* You may specify the component to use as the root wrapper.
|
||||
|
||||
@@ -94,19 +94,12 @@ class PluginsService {
|
||||
};
|
||||
}
|
||||
|
||||
getSlotElement(slot, reduxState, props = {}, queryData = {}, options = {}) {
|
||||
return this.getSlotElements(slot, reduxState, props, queryData, {
|
||||
...options,
|
||||
singleSlot: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns React Elements for given slot.
|
||||
*/
|
||||
getSlotElements(slot, reduxState, props = {}, queryData = {}, options = {}) {
|
||||
const pluginConfig = get(reduxState, 'config.plugin_config') || emptyConfig;
|
||||
const { singleSlot = false } = options;
|
||||
const { slotSize = 0 } = options;
|
||||
|
||||
const isDisabled = component => {
|
||||
if (
|
||||
@@ -143,7 +136,7 @@ class PluginsService {
|
||||
.map(o => o.module.slots[slot])
|
||||
);
|
||||
|
||||
return (singleSlot ? slots.slice(0, 1) : slots)
|
||||
return (slotSize > 0 ? slots.slice(0, slotSize) : slots)
|
||||
.map((component, i) => ({
|
||||
component,
|
||||
disabled: isDisabled(component),
|
||||
|
||||
Reference in New Issue
Block a user