@nuxeo/nuxeo-ui-elements
Version:
Nuxeo UI Web Components.
96 lines (85 loc) • 2.71 kB
HTML
<!--
@license
(C) Copyright Nuxeo Corp. (http://nuxeo.com/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<title>nuxeo-tree</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes" />
<script src="/components/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<style>
[toggle] {
cursor: pointer;
}
</style>
</head>
<body unresolved>
<dom-bind>
<template>
<nuxeo-demo-section heading="Tree" size="small">
<nuxeo-tree data="[[data]]" controller="[[controller]]">
<template>
<template is="dom-if" if="[[!opened]]">
<iron-icon icon="hardware:keyboard-arrow-right" toggle></iron-icon>
</template>
<template is="dom-if" if="[[opened]]">
<iron-icon icon="hardware:keyboard-arrow-down" toggle></iron-icon>
</template>
<b>[[item.name]]</b> Am I a Leaf? ([[isLeaf]])
</template>
</nuxeo-tree>
</nuxeo-demo-section>
</template>
</dom-bind>
<script type="module">
import '@polymer/polymer/polymer-legacy.js';
import '@polymer/iron-icon/iron-icon.js';
import '@polymer/iron-icons/hardware-icons.js';
import '../nuxeo-demo.js';
import '../../nuxeo-tree/nuxeo-tree.js';
const t = document.querySelector('dom-bind');
t.data = {
name: 'root',
children: [
{
name: 'a',
children: [
{
name: 'c',
children: [{ name: 'd' }, { name: 'e' }],
},
],
},
{
name: 'b',
children: [{ name: 'x' }],
},
],
};
t.controller = {
getChildren(node) {
return Promise.resolve(node.children);
},
shouldExpand() {
return false;
},
isLeaf(node) {
if (node.children) {
return node.children.length === 0;
}
return true;
},
};
</script>
</body>
</html>