@nextcloud/vue
Version:
Nextcloud vue components
1 lines • 2.06 kB
Source Map (JSON)
{"version":3,"file":"NcVNodes.cjs","sources":["../../src/components/NcVNodes/NcVNodes.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<docs>\nA util component to render a VNode or an array of VNodes from the prop or the default slot.\n\n### Render the given or generated VNodes\n\n```vue\n<template>\n\t<NcVNodes :vnodes=\"renderDiv()\" />\n</template>\n\n<script>\nexport default {\n\tmethods: {\n\t\trenderDiv() {\n\t\t\treturn this.$createElement('div', 'This div was created programmatically as a VNode')\n\t\t},\n\t}\n}\n</script>\n```\n\n### Render content in a conditional wrapper\n\n```vue\n<template>\n\t<div>\n\t\t<p>\n\t\t\t<NcCheckboxRadioSwitch :checked.sync=\"shouldRenderNcNoteCard\">Render text inside \"NcNoteCard\"</NcCheckboxRadioSwitch>\n\t\t</p>\n\t\t<component :is=\"shouldRenderNcNoteCard ? 'NcNoteCard' : 'NcVNodes'\">\n\t\t\t<p>This content is rendered {{ shouldRenderNcNoteCard ? 'with' : 'without' }} a \"NcNoteCard\" wrapper</p>\n\t\t</component>\n\t</div>\n</template>\n\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\tshouldRenderNcNoteCard: true,\n\t\t}\n\t},\n}\n</script>\n```\n</docs>\n\n<script>\nexport default {\n\tname: 'NcVNodes',\n\tprops: {\n\t\t/**\n\t\t * The vnodes to render\n\t\t */\n\t\tvnodes: {\n\t\t\ttype: [Array, Object],\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\t/**\n\t * The render function to display the component\n\t *\n\t * @return {object} The created VNode\n\t */\n\trender() {\n\t\t// eslint-disable-next-line jsdoc/check-tag-names\n\t\t/** @slot Directly rendered content */\n\t\treturn this.vnodes || this.$slots?.default || this.$scopedSlots?.default?.()\n\t},\n}\n</script>\n"],"names":[],"mappings":";;AAqDA,MAAA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA;AAAA;AAAA;AAAA,IAIA,QAAA;AAAA,MACA,MAAA,CAAA,OAAA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAGA,WAAA,KAAA,UAAA,KAAA,QAAA,WAAA,KAAA,cAAA,UAAA;AAAA,EACA;AACA;;;;;;;;;;;;;"}