@operato/data-tree 8.0.0-beta.0 β†’ 8.0.0-beta.1

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 CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
12
+
13
+
14
+
6
15
  ## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
7
16
 
8
17
  **Note:** Version bump only for package @operato/data-tree
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/data-tree",
3
- "version": "8.0.0-beta.0",
3
+ "version": "8.0.0-beta.1",
4
4
  "description": "User interface for tree structure data",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "storybook:build": "tsc && build-storybook"
50
50
  },
51
51
  "dependencies": {
52
- "@operato/styles": "^8.0.0-beta.0",
52
+ "@operato/styles": "^8.0.0-beta.1",
53
53
  "i18next": "^23.11.5",
54
54
  "lit": "^3.1.2",
55
55
  "lodash-es": "^4.17.21"
@@ -87,5 +87,5 @@
87
87
  "prettier --write"
88
88
  ]
89
89
  },
90
- "gitHead": "c4e9cc245659d050a9ffd66542083a6daad4bcb9"
90
+ "gitHead": "d5b28a2e9deb632c0dc80132f6a7196dd6fe4220"
91
91
  }
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- stories: ['../dist/stories/**/*.stories.{js,md,mdx}'],
3
- };
@@ -1,52 +0,0 @@
1
- import { i18next } from '@operato/i18n'
2
-
3
- export const globalTypes = {
4
- locale: {
5
- name: 'Locale',
6
- description: 'Internationalization locale',
7
- toolbar: {
8
- icon: 'globe',
9
- items: [
10
- { value: 'en', right: 'πŸ‡ΊπŸ‡Έ', title: 'English' },
11
- { value: 'ko', right: 'πŸ‡°πŸ‡·', title: 'ν•œκ΅­μ–΄' },
12
- { value: 'zh', right: 'πŸ‡¨πŸ‡³', title: 'δΈ­ζ–‡' },
13
- { value: 'ja', right: 'πŸ‡―πŸ‡΅', title: 'ζ—₯本θͺž' },
14
- { value: 'ms', right: 'πŸ‡²πŸ‡Ύ', title: 'Bahasa Melayu' }
15
- ],
16
- showName: true
17
- }
18
- },
19
- theme: {
20
- name: 'Theme',
21
- description: 'Global theme for components',
22
- toolbar: {
23
- icon: 'paintbrush',
24
- items: [
25
- { value: 'light', title: 'Light' },
26
- { value: 'dark', title: 'Dark' }
27
- ],
28
- showName: true
29
- }
30
- }
31
- }
32
-
33
- export const decorators = [
34
- (Story, context) => {
35
- const { locale, theme } = context.globals
36
-
37
- if (locale) {
38
- i18next.changeLanguage(locale)
39
- }
40
-
41
- // Set the theme class for the document
42
- if (theme === 'dark') {
43
- document.documentElement.classList.add('dark')
44
- document.documentElement.classList.remove('light')
45
- } else {
46
- document.documentElement.classList.add('light')
47
- document.documentElement.classList.remove('dark')
48
- }
49
-
50
- return Story()
51
- }
52
- ]
@@ -1,8 +0,0 @@
1
- import { storybookPlugin } from '@web/dev-server-storybook';
2
- import baseConfig from '../web-dev-server.config.mjs';
3
-
4
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
- ...baseConfig,
6
- open: '/',
7
- plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
8
- });
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './ox-tree'
2
- export * from './ox-tree-vertical'
3
- export * from './ox-tree-horizontal'
@@ -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]}&nbsp;</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
- }
@@ -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]}&nbsp;</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
- }