@operato/data-tree 7.1.25 → 7.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/themes/calendar-theme.css +3 -1
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/demo/favicon.ico +0 -0
- package/demo/index-vertical.html +0 -144
- package/demo/index.html +0 -107
- package/src/index.ts +0 -3
- package/src/ox-tree-horizontal.ts +0 -260
- package/src/ox-tree-vertical.ts +0 -227
- package/src/ox-tree.ts +0 -262
- package/stories/data-tree-horizontal.stories.ts +0 -231
- package/stories/data-tree-vertical.stories.ts +0 -231
- package/stories/data-tree.stories.ts +0 -90
- package/tsconfig.json +0 -26
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -45
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { html, css, LitElement, TemplateResult, nothing } from 'lit'
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
-
import { ScrollbarStyles } from '@operato/styles'
|
|
4
|
-
|
|
5
|
-
type TreeItem = {
|
|
6
|
-
[key: string]: any
|
|
7
|
-
__status__?: { [state: string]: boolean | string }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@customElement('ox-tree-horizontal')
|
|
11
|
-
export class TreeViewHorizontal extends LitElement {
|
|
12
|
-
static styles = [
|
|
13
|
-
ScrollbarStyles,
|
|
14
|
-
css`
|
|
15
|
-
:host {
|
|
16
|
-
display: block;
|
|
17
|
-
overflow: auto;
|
|
18
|
-
padding: 1em;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
ul,
|
|
22
|
-
li {
|
|
23
|
-
list-style: none;
|
|
24
|
-
margin: 0;
|
|
25
|
-
padding: 0;
|
|
26
|
-
position: relative;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
ul[root] {
|
|
30
|
-
margin: 0 0 1em;
|
|
31
|
-
text-align: left;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
ul[root]:before {
|
|
35
|
-
display: none;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
ul {
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
align-items: flex-start;
|
|
42
|
-
justify-content: center;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
ul {
|
|
46
|
-
width: 100%;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
li {
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-direction: row;
|
|
52
|
-
position: relative;
|
|
53
|
-
align-items: center;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
li:before,
|
|
57
|
-
li:after {
|
|
58
|
-
content: '';
|
|
59
|
-
position: absolute;
|
|
60
|
-
left: -1em;
|
|
61
|
-
border-left: 1px solid #666;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
li:before {
|
|
65
|
-
top: 0;
|
|
66
|
-
bottom: 50%;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
li:after {
|
|
70
|
-
top: 50%;
|
|
71
|
-
bottom: 0;
|
|
72
|
-
border-top: 1px solid #666;
|
|
73
|
-
width: 1em;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
ul[root] > li:after {
|
|
77
|
-
content: none;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
li:first-child:before {
|
|
81
|
-
top: 50%;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
li:last-child:after {
|
|
85
|
-
bottom: 50%;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
li > ul {
|
|
89
|
-
padding-left: 2em;
|
|
90
|
-
position: relative;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
li > ul:before {
|
|
94
|
-
content: '';
|
|
95
|
-
position: absolute;
|
|
96
|
-
top: 0;
|
|
97
|
-
bottom: -2px;
|
|
98
|
-
left: 0;
|
|
99
|
-
border-bottom: 1px solid #666;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
code,
|
|
103
|
-
span {
|
|
104
|
-
border: solid 0.1em #666;
|
|
105
|
-
border-radius: 0.2em;
|
|
106
|
-
display: inline-block;
|
|
107
|
-
margin: 0.3em 0;
|
|
108
|
-
position: relative;
|
|
109
|
-
min-width: 120px;
|
|
110
|
-
background-color: #f9f9f9;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
span[selected] {
|
|
114
|
-
color: var(--md-sys-color-on-tertiary);
|
|
115
|
-
background-color: var(--md-sys-color-tertiary);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
ul:before,
|
|
119
|
-
code:before,
|
|
120
|
-
span:before {
|
|
121
|
-
content: '';
|
|
122
|
-
width: 1em;
|
|
123
|
-
top: 50%;
|
|
124
|
-
position: absolute;
|
|
125
|
-
transform: translateY(-50%);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
ul:before {
|
|
129
|
-
left: -1em;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
code:before,
|
|
133
|
-
span:before {
|
|
134
|
-
left: -1.1em;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
ul[root] > li {
|
|
138
|
-
margin-left: 0;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
ul[root] > li:before,
|
|
142
|
-
ul[root] > li:after,
|
|
143
|
-
ul[root] > li > code:before,
|
|
144
|
-
ul[root] > li > span:before {
|
|
145
|
-
outline: none;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
span {
|
|
149
|
-
display: inline-block;
|
|
150
|
-
background-color: var(--md-sys-color-surface);
|
|
151
|
-
|
|
152
|
-
div[header] {
|
|
153
|
-
font-weight: bold;
|
|
154
|
-
font-size: 0.8em;
|
|
155
|
-
color: var(--md-sys-color-on-primary, #fff);
|
|
156
|
-
background-color: var(--md-sys-color-primary, #333);
|
|
157
|
-
padding: 0.5em 1em;
|
|
158
|
-
text-align: center;
|
|
159
|
-
width: 100%;
|
|
160
|
-
box-sizing: border-box;
|
|
161
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
div[label] {
|
|
165
|
-
font-size: 1em;
|
|
166
|
-
background-color: transparent;
|
|
167
|
-
padding: 0.5em;
|
|
168
|
-
text-align: left;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
div[description] {
|
|
172
|
-
font-size: 0.8em;
|
|
173
|
-
background-color: transparent;
|
|
174
|
-
padding: 0.5em;
|
|
175
|
-
text-align: left;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
`
|
|
179
|
-
]
|
|
180
|
-
|
|
181
|
-
@property({ type: Object }) data?: TreeItem | TreeItem[]
|
|
182
|
-
@property({ type: Object }) selected?: TreeItem
|
|
183
|
-
@property({ type: String, attribute: 'id-property' }) idProperty: string = 'id'
|
|
184
|
-
@property({ type: String, attribute: 'label-property' }) labelProperty: string = 'label'
|
|
185
|
-
@property({ type: String, attribute: 'description-property' }) descriptionProperty?: string
|
|
186
|
-
@property({ type: String, attribute: 'children-property' }) childrenProperty: string = 'children'
|
|
187
|
-
|
|
188
|
-
render() {
|
|
189
|
-
if (!this.data) return html``
|
|
190
|
-
|
|
191
|
-
const dataArray = Array.isArray(this.data) ? this.data : [this.data]
|
|
192
|
-
|
|
193
|
-
return html`
|
|
194
|
-
${dataArray.map(
|
|
195
|
-
root => html`
|
|
196
|
-
<ul root>
|
|
197
|
-
${this.renderItem(root)}
|
|
198
|
-
</ul>
|
|
199
|
-
`
|
|
200
|
-
)}
|
|
201
|
-
`
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
renderItem(item: TreeItem): TemplateResult {
|
|
205
|
-
const id = item[this.idProperty]
|
|
206
|
-
const label = item[this.labelProperty]
|
|
207
|
-
const children = item[this.childrenProperty] as TreeItem[]
|
|
208
|
-
|
|
209
|
-
const expandable = children && children.length > 0
|
|
210
|
-
const selected = id === this.selected?.[this.idProperty]
|
|
211
|
-
|
|
212
|
-
return html`
|
|
213
|
-
<li .item=${item}>
|
|
214
|
-
<span
|
|
215
|
-
?selected=${selected}
|
|
216
|
-
@click=${this.onClickSelect.bind(this)}
|
|
217
|
-
@dblclick=${this.onClickSelectConfirm.bind(this)}
|
|
218
|
-
>
|
|
219
|
-
<div header>${id}</div>
|
|
220
|
-
<div label>${label}</div>
|
|
221
|
-
${this.descriptionProperty ? html` <div description>${item[this.descriptionProperty]} </div>` : nothing}
|
|
222
|
-
</span>
|
|
223
|
-
|
|
224
|
-
${expandable
|
|
225
|
-
? html`
|
|
226
|
-
<ul>
|
|
227
|
-
${children.map(child => this.renderItem(child))}
|
|
228
|
-
</ul>
|
|
229
|
-
`
|
|
230
|
-
: html``}
|
|
231
|
-
</li>
|
|
232
|
-
`
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
onClickSelect(e: MouseEvent) {
|
|
236
|
-
e.stopPropagation()
|
|
237
|
-
|
|
238
|
-
const target = e.target as HTMLElement
|
|
239
|
-
this.selected = (target.closest('li') as any)?.item
|
|
240
|
-
|
|
241
|
-
this.dispatchEvent(
|
|
242
|
-
new CustomEvent('select', {
|
|
243
|
-
detail: this.selected
|
|
244
|
-
})
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
onClickSelectConfirm(e: MouseEvent) {
|
|
249
|
-
e.stopPropagation()
|
|
250
|
-
|
|
251
|
-
const target = e.target as HTMLElement
|
|
252
|
-
this.selected = (target.closest('li') as any)?.item
|
|
253
|
-
|
|
254
|
-
this.dispatchEvent(
|
|
255
|
-
new CustomEvent('select-confirm', {
|
|
256
|
-
detail: this.selected
|
|
257
|
-
})
|
|
258
|
-
)
|
|
259
|
-
}
|
|
260
|
-
}
|
package/src/ox-tree-vertical.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/* Inspired by https://www.cssscript.com/clean-tree-diagram/ */
|
|
2
|
-
|
|
3
|
-
import { html, css, LitElement, TemplateResult, nothing } from 'lit'
|
|
4
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
5
|
-
import { ScrollbarStyles } from '@operato/styles'
|
|
6
|
-
type TreeItem = {
|
|
7
|
-
[key: string]: any
|
|
8
|
-
__status__?: { [state: string]: boolean | string }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@customElement('ox-tree-vertical')
|
|
12
|
-
export class TreeViewVertical extends LitElement {
|
|
13
|
-
static styles = [
|
|
14
|
-
ScrollbarStyles,
|
|
15
|
-
css`
|
|
16
|
-
:host {
|
|
17
|
-
display: block;
|
|
18
|
-
overflow: auto;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
ul,
|
|
22
|
-
li {
|
|
23
|
-
list-style: none;
|
|
24
|
-
margin: 0;
|
|
25
|
-
padding: 0;
|
|
26
|
-
position: relative;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
ul[root] {
|
|
30
|
-
margin: 0 0 1em;
|
|
31
|
-
text-align: center;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
ul[root]:before,
|
|
35
|
-
ul[root]:after {
|
|
36
|
-
display: none;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
ul {
|
|
40
|
-
display: table;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
ul {
|
|
44
|
-
width: 100%;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
li {
|
|
48
|
-
display: table-cell;
|
|
49
|
-
padding: 1em 0;
|
|
50
|
-
vertical-align: top;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
li:before {
|
|
54
|
-
outline: solid 1px #666;
|
|
55
|
-
content: '';
|
|
56
|
-
left: 0;
|
|
57
|
-
position: absolute;
|
|
58
|
-
right: 0;
|
|
59
|
-
top: 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
li:first-child:before {
|
|
63
|
-
left: 50%;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
li:last-child:before {
|
|
67
|
-
right: 50%;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
code,
|
|
71
|
-
span {
|
|
72
|
-
border: solid 0.1em #666;
|
|
73
|
-
border-radius: 0.2em;
|
|
74
|
-
display: inline-block;
|
|
75
|
-
margin: 0 0.2em 1em;
|
|
76
|
-
position: relative;
|
|
77
|
-
min-width: 120px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
span[selected] {
|
|
81
|
-
color: var(--md-sys-color-on-tertiary);
|
|
82
|
-
background-color: var(--md-sys-color-tertiary);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
ul:before,
|
|
86
|
-
code:before,
|
|
87
|
-
span:before {
|
|
88
|
-
outline: solid 1px #666;
|
|
89
|
-
content: '';
|
|
90
|
-
height: 1em;
|
|
91
|
-
left: 50%;
|
|
92
|
-
position: absolute;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
ul:before {
|
|
96
|
-
top: -1em;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
code:before,
|
|
100
|
-
span:before {
|
|
101
|
-
top: -1.1em;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
ul[root] > li {
|
|
105
|
-
margin-top: 0;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
ul[root] > li:before,
|
|
109
|
-
ul[root] > li:after,
|
|
110
|
-
ul[root] > li > code:before,
|
|
111
|
-
ul[root] > li > span:before {
|
|
112
|
-
outline: none;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
span {
|
|
116
|
-
display: inline-block;
|
|
117
|
-
background-color: var(--md-sys-color-surface);
|
|
118
|
-
|
|
119
|
-
div[header] {
|
|
120
|
-
font-weight: bold;
|
|
121
|
-
font-size: 0.8em;
|
|
122
|
-
color: var(--md-sys-color-on-primary, #fff);
|
|
123
|
-
background-color: var(--md-sys-color-primary, #333);
|
|
124
|
-
padding: 0.5em 1em;
|
|
125
|
-
text-align: center;
|
|
126
|
-
width: 100%;
|
|
127
|
-
box-sizing: border-box;
|
|
128
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
div[label] {
|
|
132
|
-
font-size: 1em;
|
|
133
|
-
background-color: transparent;
|
|
134
|
-
padding: 0.5em;
|
|
135
|
-
text-align: left;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
div[description] {
|
|
139
|
-
font-size: 0.8em;
|
|
140
|
-
background-color: transparent;
|
|
141
|
-
padding: 0.5em;
|
|
142
|
-
text-align: left;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
`
|
|
146
|
-
]
|
|
147
|
-
|
|
148
|
-
@property({ type: Object }) data?: TreeItem | TreeItem[]
|
|
149
|
-
@property({ type: Object }) selected?: TreeItem
|
|
150
|
-
@property({ type: String, attribute: 'id-property' }) idProperty: string = 'id'
|
|
151
|
-
@property({ type: String, attribute: 'label-property' }) labelProperty: string = 'label'
|
|
152
|
-
@property({ type: String, attribute: 'description-property' }) descriptionProperty?: string
|
|
153
|
-
@property({ type: String, attribute: 'children-property' }) childrenProperty: string = 'children'
|
|
154
|
-
|
|
155
|
-
render() {
|
|
156
|
-
if (!this.data) return html``
|
|
157
|
-
|
|
158
|
-
const dataArray = Array.isArray(this.data) ? this.data : [this.data]
|
|
159
|
-
|
|
160
|
-
return html`
|
|
161
|
-
${dataArray.map(
|
|
162
|
-
root => html`
|
|
163
|
-
<ul root>
|
|
164
|
-
${this.renderItem(root)}
|
|
165
|
-
</ul>
|
|
166
|
-
`
|
|
167
|
-
)}
|
|
168
|
-
`
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
renderItem(item: TreeItem): TemplateResult {
|
|
172
|
-
const id = item[this.idProperty]
|
|
173
|
-
const label = item[this.labelProperty]
|
|
174
|
-
const children = item[this.childrenProperty] as TreeItem[]
|
|
175
|
-
|
|
176
|
-
const expandable = children && children.length > 0
|
|
177
|
-
const selected = id === this.selected?.[this.idProperty]
|
|
178
|
-
|
|
179
|
-
return html`
|
|
180
|
-
<li .item=${item}>
|
|
181
|
-
<span
|
|
182
|
-
?selected=${selected}
|
|
183
|
-
@click=${this.onClickSelect.bind(this)}
|
|
184
|
-
@dblclick=${this.onClickSelectConfirm.bind(this)}
|
|
185
|
-
>
|
|
186
|
-
<div header>${id}</div>
|
|
187
|
-
<div label>${label}</div>
|
|
188
|
-
${this.descriptionProperty ? html` <div description>${item[this.descriptionProperty]} </div>` : nothing}
|
|
189
|
-
</span>
|
|
190
|
-
|
|
191
|
-
${expandable
|
|
192
|
-
? html`
|
|
193
|
-
<ul>
|
|
194
|
-
${children.map(child => this.renderItem(child))}
|
|
195
|
-
</ul>
|
|
196
|
-
`
|
|
197
|
-
: html``}
|
|
198
|
-
</li>
|
|
199
|
-
`
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
onClickSelect(e: MouseEvent) {
|
|
203
|
-
e.stopPropagation()
|
|
204
|
-
|
|
205
|
-
const target = e.target as HTMLElement
|
|
206
|
-
this.selected = (target.closest('li') as any)?.item
|
|
207
|
-
|
|
208
|
-
this.dispatchEvent(
|
|
209
|
-
new CustomEvent('select', {
|
|
210
|
-
detail: this.selected
|
|
211
|
-
})
|
|
212
|
-
)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
onClickSelectConfirm(e: MouseEvent) {
|
|
216
|
-
e.stopPropagation()
|
|
217
|
-
|
|
218
|
-
const target = e.target as HTMLElement
|
|
219
|
-
this.selected = (target.closest('li') as any)?.item
|
|
220
|
-
|
|
221
|
-
this.dispatchEvent(
|
|
222
|
-
new CustomEvent('select-confirm', {
|
|
223
|
-
detail: this.selected
|
|
224
|
-
})
|
|
225
|
-
)
|
|
226
|
-
}
|
|
227
|
-
}
|