/* eslint import/no-unresolved: ["off"] */
/* eslint import/extensions: ["off"] */
import Utils from '../utils/utils';
import Mixins from '../utils/mixins';
import F7Badge from './badge';
export default {
name: 'f7-list-item-content',
props: {
id: [String, Number],
className: String, // phenome-react-line
style: Object, // phenome-react-line
title: [String, Number],
text: [String, Number],
media: String,
subtitle: [String, Number],
header: [String, Number],
footer: [String, Number],
after: [String, Number],
badge: [String, Number],
badgeColor: String,
mediaList: Boolean,
mediaItem: Boolean,
itemInput: Boolean,
itemInputWithInfo: Boolean,
inlineLabel: Boolean,
checkbox: Boolean,
checked: Boolean,
defaultChecked: Boolean,
radio: Boolean,
name: String,
value: [String, Number, Array],
readonly: Boolean,
required: Boolean,
disabled: Boolean,
...Mixins.colorProps,
},
state() {
return {
hasInput: false,
hasInlineLabel: false,
hasInputInfo: false,
hasInputErrorMessage: false,
hasInputValue: false,
hasInputFocused: false,
hasInputInvalid: false,
};
},
render() {
const self = this;
const props = self.props;
const {
id,
className,
style,
radio,
checkbox,
value,
name,
checked,
defaultChecked,
readonly,
disabled,
required,
media,
header,
footer,
title,
subtitle,
text,
after,
badge,
mediaList,
mediaItem,
badgeColor,
itemInput,
inlineLabel,
itemInputWithInfo,
} = props;
const hasInputFocused = self.state.hasInputFocused;
const hasInputInvalid = self.state.hasInputInvalid;
let hasInputValue = self.state.hasInputValue;
let hasInput = itemInput || self.state.hasInput;
let hasInlineLabel = inlineLabel || self.state.hasInlineLabel;
let hasInputInfo = itemInputWithInfo || self.state.hasInputInfo;
let hasInputErrorMessage = self.state.hasInputErrorMessage;
const slotsContentStart = [];
const slotsContent = [];
const slotsContentEnd = [];
const slotsInnerStart = [];
const slotsInner = [];
const slotsInnerEnd = [];
const slotsAfterStart = [];
const slotsAfter = [];
const slotsAfterEnd = [];
const slotsMedia = [];
const slotsBeforeTitle = [];
const slotsTitle = [];
const slotsAfterTitle = [];
const slotsSubtitle = [];
const slotsText = [];
const slotsHeader = [];
const slotsFooter = [];
let titleEl;
let afterWrapEl;
let afterEl;
let badgeEl;
let innerEl;
let titleRowEl;
let subtitleEl;
let textEl;
let mediaEl;
let inputEl;
let inputIconEl;
let headerEl;
let footerEl;
const slots = self.slots.default;
const flattenSlots = [];
if (slots && slots.length) {
slots.forEach((slot) => {
if (Array.isArray(slot)) flattenSlots.push(...slot);
else flattenSlots.push(slot);
});
}
flattenSlots.forEach((child) => {
if (typeof child === 'undefined') return;
if (process.env.COMPILER === 'react') {
const tag = child.type && (child.type.displayName || child.type.name);
if (tag === 'F7Input' || tag === 'f7-input') {
hasInput = true;
if (child.props && child.props.info) hasInputInfo = true;
if (child.props && child.props.errorMessage && child.props.errorMessageForce) hasInputErrorMessage = true;
if (!hasInputValue) {
if (child.props && (typeof child.props.value === 'undefined' ? child.props.defaultValue || child.props.defaultValue === 0 : child.props.value || child.props.value === 0)) hasInputValue = true;
else hasInputValue = false;
}
}
if (tag === 'F7Label' || tag === 'f7-label') {
if (child.props && child.props.inline) hasInlineLabel = true;
}
}
if (process.env.COMPILER === 'vue') {
const tag = child.tag;
if (tag && tag.indexOf('f7-input') >= 0) {
hasInput = true;
if (child.data && child.data.info) hasInputInfo = true;
if (child.data && child.data.errorMessage && child.data.errorMessageForce) hasInputErrorMessage = true;
if (!hasInputValue) {
if (child.data && (typeof child.data.value === 'undefined' ? child.data.defaultValue || child.data.defaultValue === 0 : child.data.value || child.data.value === 0)) {
hasInputValue = true;
} else if (child.componentOptions && child.componentOptions.propsData && (typeof child.componentOptions.propsData.value === 'undefined' ? child.componentOptions.propsData.defaultValue || child.componentOptions.propsData.defaultValue === 0 : child.componentOptions.propsData.value || child.componentOptions.propsData.value === 0)) {
hasInputValue = true;
}
}
}
if (tag && tag.indexOf('f7-label') >= 0) {
if (child.data && child.data.inline) hasInlineLabel = true;
}
}
let slotName;
// phenome-vue-next-line
slotName = child.data ? child.data.slot : undefined;
// phenome-react-next-line
slotName = child.props ? child.props.slot : undefined;
if (!slotName || (slotName === 'inner')) slotsInner.push(child);
if (slotName === 'content-start') slotsContentStart.push(child);
if (slotName === 'content') slotsContent.push(child);
if (slotName === 'content-end') slotsContentEnd.push(child);
if (slotName === 'after-start') slotsAfterStart.push(child);
if (slotName === 'after') slotsAfter.push(child);
if (slotName === 'after-end') slotsAfterEnd.push(child);
if (slotName === 'media') slotsMedia.push(child);
if (slotName === 'inner-start') slotsInnerStart.push(child);
if (slotName === 'inner-end') slotsInnerEnd.push(child);
if (slotName === 'before-title') slotsBeforeTitle.push(child);
if (slotName === 'title') slotsTitle.push(child);
if (slotName === 'after-title') slotsAfterTitle.push(child);
if (slotName === 'subtitle') slotsSubtitle.push(child);
if (slotName === 'text') slotsText.push(child);
if (slotName === 'header') slotsHeader.push(child);
if (slotName === 'footer') slotsFooter.push(child);
});
// Input
if (radio || checkbox) {
if (process.env.COMPILER === 'vue') {
inputEl = (
);
} else {
inputEl = (
);
}
inputIconEl = (
);
}
// Media
if (media || slotsMedia.length) {
let mediaImgEl;
if (media) {
mediaImgEl = (
);
}
mediaEl = (