Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 1x 1x 8x | import DefineMap from 'can-define/map/map';
import canViewModel from 'can-view-model';
let pageId = 0;
/**
* A `<sp-tab-page />` component's ViewModel
* @class ViewModel
* @memberof sp-tab-page
*
*/
const ViewModel = DefineMap.extend('NavPage', {
/** @lends sp-tab-page.ViewModel.prototype */
/**
* The display state of the page. If true, the page content will be shown
* @type {Boolean}
* @memberof sp-tab-page.ViewModel.prototype
*/
active: {type: 'boolean', default: false},
/**
* Add custom classes to the navigation containers nav tab.
* @type {String}
* @memberof sp-tab-page.ViewModel.prototype
*/
classes: 'string',
/**
* The label to display in the memberof container tab
* @type {String}
* @memberof sp-tab-page.ViewModel.prototype
*/
label: 'string',
/**
* Whether or not this page is currently loading
* @type {HTMLBoolean}
* @memberof sp-tab-page.ViewModel.prototype
*/
loading: {type: 'htmlbool', default: false},
/**
* A unique id to identify this page. The default is automatically provided.
* @type {String}
* @memberof sp-tab-page.ViewModel.prototype
*/
pageId: {
default () {
return 'page-' + pageId++;
}
},
/**
* A virtual property to determine if this page is active or not
* @type {Boolean}
*/
isActive: {
get () {
if (process.env.NODE_ENV !== 'production' && !this.parent) {
// eslint-disable-next-line
console.warn('sp-tab-page: No parent found. This component belongs inside a container component');
}
return this.parent && this.parent.isActive(this);
}
},
/**
* The parent containers view model
* @type {DefineMap}
* @memberof sp-tab-page.ViewModel.prototype
*/
parent: '*',
/**
* When the viewmodel is connected to an element,
* register this viewmodel with the parent
* @param {Element} el This component's element
*/
connectedCallback (el) {
this.parent = canViewModel(el.parentNode);
if (this.parent && this.parent.addPage) {
this.parent.addPage(this);
}
}
});
export default ViewModel;
|