jobdone-shared-files 0.0.1-beta.87 → 0.0.1-beta.89

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/treeItem.vue CHANGED
@@ -1,368 +1,369 @@
1
- <template>
2
- <li class="tree-item" :class="[itemClass]">
3
- <div class="card flex-row d-flex input-group flex-nowrap">
4
- <button type="button" class="btn text-primary border-end px-1" :disabled="!item.children" data-bs-toggle="collapse" :data-bs-target="'#collapse-'+item.id">
5
- <span class="material-icons">arrow_drop_down</span>
6
- </button>
7
- <input type="radio" name="tree-item" :id="item.id">
8
- <label class="btn-title d-flex text-start rounded-0 flex-grow-1"
9
- :for="item.id" @click="clickItem(item)">
10
- <div class="btn btn-text border-start">{{item.title}}</div>
11
- <slot name="icon">
12
- <div class="btn d-flex align-items-center border-start rounded-0 text-primary h-100 ms-auto">
13
- <span class="material-icons icon-18"></span>
14
- </div>
15
- </slot>
16
- </label>
17
- </div>
18
- <template v-if="item.children">
19
- <ul :id="'collapse-'+item.id" class="content-children show" v-collapse>
20
- <TreeItem class="children-box" v-for="(subItem, subIndex) in item.children"
21
- :key="subItem.id"
22
- :item="subItem"
23
- :index="subIndex"
24
- :click-item="clickItem"
25
- :active-id="activeId"
26
- :tree-item-class="treeItemClass">
27
- <template v-slot:icon>
28
- <slot name="icon">
29
- <div class="btn d-flex align-items-center border-start rounded-0 text-primary h-100 ms-auto">
30
- <span class="material-icons icon-18"></span>
31
- </div>
32
- </slot>
33
- </template>
34
- </TreeItem>
35
- </ul>
36
- </template>
37
- </li>
38
- </template>
39
-
40
- <script>
41
- import { ref, computed } from 'vue';
42
- import collapse from './common/directives/collapse';
43
- export default {
44
- name: 'TreeItem',
45
- props: {
46
- item: {
47
- type: Object,
48
- required: true
49
- },
50
- index: {
51
- type: Number,
52
- required: true
53
- },
54
- clickItem: {
55
- type: Function
56
- },
57
- activeId: {
58
- type: String,
59
- required: true
60
- },
61
- treeItemClass: {
62
- type: Array,
63
- default: function () {
64
- return [];
65
- }
66
- }
67
- },
68
- directives: {
69
- collapse
70
- },
71
- setup(props, { emit }) {
72
- const itemClass = computed(() => {
73
- var classList = [...props.treeItemClass];
74
- if (props.activeId === props.item.id) {
75
- classList.push('active');
76
- }
77
- return classList;
78
- });
79
- return {
80
- itemClass: itemClass
81
- };
82
- }
83
- }
84
- </script>
85
-
86
- <style scoped lang="scss">
87
- @import "./style/scss/Settings/basic-import";
88
-
89
- li {
90
- list-style-type: none;
91
- }
92
-
93
- // 基本 sizes
94
- .tree-item {
95
- .btn {
96
- --bs-btn-padding-x: 0.75em;
97
- --bs-btn-padding-y: 0.375em;
98
- --bs-btn-font-size: 1em;
99
- }
100
-
101
- .card {
102
- --bs-card-spacer-y: 1em;
103
- --bs-card-spacer-x: 1em;
104
- --bs-card-title-spacer-y: 0.5em;
105
- --bs-card-cap-padding-y: 0.5em;
106
- --bs-card-cap-padding-x: 1em;
107
- --bs-card-img-overlay-padding: 1em;
108
- --bs-card-group-margin: 0.75em;
109
- }
110
-
111
- .material-icons {
112
- font-size: 1.5em;
113
-
114
- &.icon-14 {
115
- font-size: 0.875em;
116
- }
117
-
118
- &.icon-18 {
119
- font-size: 1.125em;
120
- }
121
-
122
- &.icon-28 {
123
- font-size: 1.75em;
124
- }
125
-
126
- &.icon-32 {
127
- font-size: 2em;
128
- }
129
- }
130
- }
131
-
132
- // hover效果與優化
133
- // firefox 暫不支援 has
134
- .tree-item:has([data-bs-toggle="collapse"]:hover) + .collapse {
135
- will-change: height;
136
- }
137
-
138
- .tree-item:hover > .card,
139
- .tree-item .card:focus-within {
140
- background-color: lighten( $primary, 32% );
141
- border-color: rgba( $primary, .4 );
142
- }
143
-
144
- // active效果
145
- .tree-item.active {
146
- > .card {
147
- background-color: lighten( $primary, 30% );
148
- border-color: rgba( $primary, .5 );
149
- }
150
-
151
- .btn-title {
152
- color: $primary;
153
- }
154
- }
155
-
156
- .btn-title {
157
- .btn {
158
- border-radius: 0;
159
-
160
- &:focus, &:active {
161
- border-color: transparent;
162
- }
163
- }
164
-
165
- .btn-text {
166
- width: 100%;
167
- text-align: left;
168
- word-break: break-word;
169
- }
170
- }
171
-
172
- label.btn-title {
173
- cursor: pointer;
174
- }
175
-
176
- // 隱藏 input
177
- .tree-item {
178
- position: relative;
179
-
180
- input[type="checkbox"], input[type="radio"] {
181
- position: absolute;
182
- @include size(0);
183
- pointer-events: none;
184
-
185
- ~ .btn-title .material-icons:before {
186
- content: "\e836";
187
- display: inline-block;
188
- font-family: inherit;
189
- }
190
-
191
- &:checked ~ .btn-title .material-icons:before {
192
- content: "\e837";
193
- }
194
- }
195
- }
196
-
197
-
198
- // 刪除子層標示 UI
199
- .tree-item:has(.btn.text-danger:hover) {
200
- .card {
201
- background-color: lighten( $danger, 43% );
202
- border-color: rgba( $danger, .5 );
203
-
204
- .btn {
205
- color: $danger;
206
- }
207
- }
208
- }
209
- // 刪除子層標示 UI (含子層)
210
- // .tree-child:has(.btn.text-danger:hover){
211
- // .card, + .content-children .card{
212
- // background-color: lighten( $danger, 43% );
213
- // border-color: rgba( $danger, .5 );
214
- // .btn{
215
- // color: $danger;
216
- // }
217
- // }
218
- // }
219
-
220
- .btn-no-children {
221
- cursor: auto;
222
-
223
- &:focus {
224
- border-color: transparent;
225
- }
226
- }
227
-
228
- // 基本 style
229
- $card-margin: .2em;
230
- $line-padding: .7em;
231
-
232
- .tree-item {
233
- display: flex;
234
- flex-direction: column;
235
- width: 100%;
236
- margin-top: $card-margin;
237
-
238
- .card {
239
- position: relative;
240
- flex-grow: 1;
241
- transition: $transition-base;
242
- z-index: 2;
243
- }
244
- }
245
-
246
- .col-action {
247
- @include flex-center;
248
- width: 2.8rem;
249
- }
250
-
251
-
252
- // 開合 style
253
- .btn[data-bs-toggle="collapse"] {
254
- .material-icons {
255
- transition: $transition-base;
256
- }
257
-
258
- &[aria-expanded="false"] .material-icons {
259
- transform: rotate(-90deg);
260
- }
261
-
262
- &:disabled, &.disabled {
263
- border-color: transparent;
264
- }
265
- }
266
-
267
- // 畫線 style
268
- .content-children {
269
- padding-left: 1.5rem;
270
- --tree-border-color: #fff;
271
- position: relative;
272
-
273
- &:before {
274
- content: "";
275
- position: absolute;
276
- display: block;
277
- left: -$line-padding;
278
- bottom: 24px;
279
- width: 1px;
280
- height: 100%;
281
- z-index: 1;
282
- background-color: var(--tree-border-color);
283
- }
284
- // // line color
285
- &:before, .tree-item .card:before, .tree-item .card:after {
286
- background-color: var(--tree-border-color);
287
- }
288
- }
289
-
290
- .tree-item {
291
- &:last-child > .content-children:before {
292
- display: none;
293
- }
294
-
295
- .card {
296
- position: relative;
297
-
298
- &:before, &:after {
299
- content: "";
300
- position: absolute;
301
- left: calc(-#{$line-padding} - #{$border-width});
302
- z-index: 1;
303
- }
304
-
305
- &:before {
306
- bottom: 50%;
307
- width: 1px;
308
- height: calc(100% + #{$card-margin}*2 + #{$border-width}*2);
309
- }
310
-
311
- &:after {
312
- top: 0;
313
- bottom: 0;
314
- width: $line-padding;
315
- height: 1px;
316
- margin: auto;
317
- }
318
- }
319
-
320
- &:nth-child(1) > .card:before {
321
- height: calc(50% + #{$card-margin} + #{$border-width});
322
- }
323
- }
324
-
325
-
326
- // 小版本
327
- .tree-item-sm {
328
- > .card {
329
- font-size: 86%;
330
- }
331
-
332
- .content-children {
333
- padding-left: 1rem;
334
- }
335
-
336
- .content-children:before {
337
- left: -10px;
338
- bottom: 19px;
339
- }
340
- }
341
- // .tree-item-sm + .content-children{
342
- // > .children-box{
343
- // padding-left: 1rem;
344
- // }
345
- // }
346
-
347
-
348
- // 白背景版本
349
- .tree-item-in-white {
350
- .content-children {
351
- --tree-border-color: var(--bs-border-color);
352
- }
353
-
354
- .card {
355
- --bs-card-bg: var(--gray-100);
356
- --bs-card-border-color: var(--bs-border-color);
357
- }
358
-
359
- &:hover > .card,
360
- .card:focus-within {
361
- background-color: $white;
362
- }
363
- // active效果
364
- &.active .card {
365
- background-color: $white;
366
- }
367
- }
1
+ <template>
2
+ <li class="tree-item" :class="[itemClass]">
3
+ <div class="card flex-row d-flex input-group flex-nowrap">
4
+ <button type="button" class="btn text-primary border-end px-1" :disabled="!item.children" data-bs-toggle="collapse" :data-bs-target="'#collapse-'+item.id">
5
+ <span class="material-icons">arrow_drop_down</span>
6
+ </button>
7
+ <input type="radio" name="tree-item" :id="item.id">
8
+ <label class="btn-title d-flex text-start rounded-0 flex-grow-1"
9
+ :for="item.id" @click="clickItem(item)">
10
+ <div class="btn btn-text border-start">{{item.title}}</div>
11
+ <slot name="icon">
12
+ <div class="btn d-flex align-items-center border-start rounded-0 text-primary h-100 ms-auto">
13
+ <span class="material-icons icon-18"></span>
14
+ </div>
15
+ </slot>
16
+ </label>
17
+ </div>
18
+ <template v-if="item.children">
19
+ <ul :id="'collapse-'+item.id" class="content-children show" v-collapse>
20
+ <TreeItem class="children-box" v-for="(subItem, subIndex) in item.children"
21
+ :key="subItem.id"
22
+ :item="subItem"
23
+ :index="subIndex"
24
+ :click-item="clickItem"
25
+ :active-id="activeId"
26
+ :tree-item-class="treeItemClass">
27
+ <template v-slot:icon>
28
+ <slot name="icon">
29
+ <div class="btn d-flex align-items-center border-start rounded-0 text-primary h-100 ms-auto">
30
+ <span class="material-icons icon-18"></span>
31
+ </div>
32
+ </slot>
33
+ </template>
34
+ </TreeItem>
35
+ </ul>
36
+ </template>
37
+ </li>
38
+ </template>
39
+
40
+ <script>
41
+ import { ref, computed } from 'vue';
42
+ import collapse from './common/directives/collapse';
43
+ export default {
44
+ name: 'TreeItem',
45
+ props: {
46
+ item: {
47
+ type: Object,
48
+ required: true
49
+ },
50
+ index: {
51
+ type: Number,
52
+ required: true
53
+ },
54
+ clickItem: {
55
+ type: Function
56
+ },
57
+ activeId: {
58
+ type: String,
59
+ required: true
60
+ },
61
+ treeItemClass: {
62
+ type: Array,
63
+ default: function () {
64
+ return [];
65
+ }
66
+ }
67
+ },
68
+ directives: {
69
+ collapse
70
+ },
71
+ setup(props, { emit }) {
72
+ const itemClass = computed(() => {
73
+ var classList = [...props.treeItemClass];
74
+ if (props.activeId === props.item.id) {
75
+ classList.push('active');
76
+ }
77
+ return classList;
78
+ });
79
+ return {
80
+ itemClass: itemClass
81
+ };
82
+ }
83
+ }
84
+ </script>
85
+
86
+ <style scoped lang="scss">
87
+ @import "./style/scss/Settings/bs-variables";
88
+ @import "./style/scss/Settings/Mixins";
89
+
90
+ li {
91
+ list-style-type: none;
92
+ }
93
+
94
+ // 基本 sizes
95
+ .tree-item {
96
+ .btn {
97
+ --bs-btn-padding-x: 0.75em;
98
+ --bs-btn-padding-y: 0.375em;
99
+ --bs-btn-font-size: 1em;
100
+ }
101
+
102
+ .card {
103
+ --bs-card-spacer-y: 1em;
104
+ --bs-card-spacer-x: 1em;
105
+ --bs-card-title-spacer-y: 0.5em;
106
+ --bs-card-cap-padding-y: 0.5em;
107
+ --bs-card-cap-padding-x: 1em;
108
+ --bs-card-img-overlay-padding: 1em;
109
+ --bs-card-group-margin: 0.75em;
110
+ }
111
+
112
+ .material-icons {
113
+ font-size: 1.5em;
114
+
115
+ &.icon-14 {
116
+ font-size: 0.875em;
117
+ }
118
+
119
+ &.icon-18 {
120
+ font-size: 1.125em;
121
+ }
122
+
123
+ &.icon-28 {
124
+ font-size: 1.75em;
125
+ }
126
+
127
+ &.icon-32 {
128
+ font-size: 2em;
129
+ }
130
+ }
131
+ }
132
+
133
+ // hover效果與優化
134
+ // firefox 暫不支援 has
135
+ .tree-item:has([data-bs-toggle="collapse"]:hover) + .collapse {
136
+ will-change: height;
137
+ }
138
+
139
+ .tree-item:hover > .card,
140
+ .tree-item .card:focus-within {
141
+ background-color: lighten( $primary, 32% );
142
+ border-color: rgba( $primary, .4 );
143
+ }
144
+
145
+ // active效果
146
+ .tree-item.active {
147
+ > .card {
148
+ background-color: lighten( $primary, 30% );
149
+ border-color: rgba( $primary, .5 );
150
+ }
151
+
152
+ .btn-title {
153
+ color: $primary;
154
+ }
155
+ }
156
+
157
+ .btn-title {
158
+ .btn {
159
+ border-radius: 0;
160
+
161
+ &:focus, &:active {
162
+ border-color: transparent;
163
+ }
164
+ }
165
+
166
+ .btn-text {
167
+ width: 100%;
168
+ text-align: left;
169
+ word-break: break-word;
170
+ }
171
+ }
172
+
173
+ label.btn-title {
174
+ cursor: pointer;
175
+ }
176
+
177
+ // 隱藏 input
178
+ .tree-item {
179
+ position: relative;
180
+
181
+ input[type="checkbox"], input[type="radio"] {
182
+ position: absolute;
183
+ @include size(0);
184
+ pointer-events: none;
185
+
186
+ ~ .btn-title .material-icons:before {
187
+ content: "\e836";
188
+ display: inline-block;
189
+ font-family: inherit;
190
+ }
191
+
192
+ &:checked ~ .btn-title .material-icons:before {
193
+ content: "\e837";
194
+ }
195
+ }
196
+ }
197
+
198
+
199
+ // 刪除子層標示 UI
200
+ .tree-item:has(.btn.text-danger:hover) {
201
+ .card {
202
+ background-color: lighten( $danger, 43% );
203
+ border-color: rgba( $danger, .5 );
204
+
205
+ .btn {
206
+ color: $danger;
207
+ }
208
+ }
209
+ }
210
+ // 刪除子層標示 UI (含子層)
211
+ // .tree-child:has(.btn.text-danger:hover){
212
+ // .card, + .content-children .card{
213
+ // background-color: lighten( $danger, 43% );
214
+ // border-color: rgba( $danger, .5 );
215
+ // .btn{
216
+ // color: $danger;
217
+ // }
218
+ // }
219
+ // }
220
+
221
+ .btn-no-children {
222
+ cursor: auto;
223
+
224
+ &:focus {
225
+ border-color: transparent;
226
+ }
227
+ }
228
+
229
+ // 基本 style
230
+ $card-margin: .2em;
231
+ $line-padding: .7em;
232
+
233
+ .tree-item {
234
+ display: flex;
235
+ flex-direction: column;
236
+ width: 100%;
237
+ margin-top: $card-margin;
238
+
239
+ .card {
240
+ position: relative;
241
+ flex-grow: 1;
242
+ transition: $transition-base;
243
+ z-index: 2;
244
+ }
245
+ }
246
+
247
+ .col-action {
248
+ @include flex-center;
249
+ width: 2.8rem;
250
+ }
251
+
252
+
253
+ // 開合 style
254
+ .btn[data-bs-toggle="collapse"] {
255
+ .material-icons {
256
+ transition: $transition-base;
257
+ }
258
+
259
+ &[aria-expanded="false"] .material-icons {
260
+ transform: rotate(-90deg);
261
+ }
262
+
263
+ &:disabled, &.disabled {
264
+ border-color: transparent;
265
+ }
266
+ }
267
+
268
+ // 畫線 style
269
+ .content-children {
270
+ padding-left: 1.5rem;
271
+ --tree-border-color: #fff;
272
+ position: relative;
273
+
274
+ &:before {
275
+ content: "";
276
+ position: absolute;
277
+ display: block;
278
+ left: -$line-padding;
279
+ bottom: 24px;
280
+ width: 1px;
281
+ height: 100%;
282
+ z-index: 1;
283
+ background-color: var(--tree-border-color);
284
+ }
285
+ // // line color
286
+ &:before, .tree-item .card:before, .tree-item .card:after {
287
+ background-color: var(--tree-border-color);
288
+ }
289
+ }
290
+
291
+ .tree-item {
292
+ &:last-child > .content-children:before {
293
+ display: none;
294
+ }
295
+
296
+ .card {
297
+ position: relative;
298
+
299
+ &:before, &:after {
300
+ content: "";
301
+ position: absolute;
302
+ left: calc(-#{$line-padding} - #{$border-width});
303
+ z-index: 1;
304
+ }
305
+
306
+ &:before {
307
+ bottom: 50%;
308
+ width: 1px;
309
+ height: calc(100% + #{$card-margin}*2 + #{$border-width}*2);
310
+ }
311
+
312
+ &:after {
313
+ top: 0;
314
+ bottom: 0;
315
+ width: $line-padding;
316
+ height: 1px;
317
+ margin: auto;
318
+ }
319
+ }
320
+
321
+ &:nth-child(1) > .card:before {
322
+ height: calc(50% + #{$card-margin} + #{$border-width});
323
+ }
324
+ }
325
+
326
+
327
+ // 小版本
328
+ .tree-item-sm {
329
+ > .card {
330
+ font-size: 86%;
331
+ }
332
+
333
+ .content-children {
334
+ padding-left: 1rem;
335
+ }
336
+
337
+ .content-children:before {
338
+ left: -10px;
339
+ bottom: 19px;
340
+ }
341
+ }
342
+ // .tree-item-sm + .content-children{
343
+ // > .children-box{
344
+ // padding-left: 1rem;
345
+ // }
346
+ // }
347
+
348
+
349
+ // 白背景版本
350
+ .tree-item-in-white {
351
+ .content-children {
352
+ --tree-border-color: var(--bs-border-color);
353
+ }
354
+
355
+ .card {
356
+ --bs-card-bg: var(--gray-100);
357
+ --bs-card-border-color: var(--bs-border-color);
358
+ }
359
+
360
+ &:hover > .card,
361
+ .card:focus-within {
362
+ background-color: $white;
363
+ }
364
+ // active效果
365
+ &.active .card {
366
+ background-color: $white;
367
+ }
368
+ }
368
369
  </style>