jobdone-shared-files 1.0.2 → 1.0.4

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,372 +1,372 @@
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 "../bootstrap/scss/functions";
88
- @import "./style/scss/Settings/bs-variables";
89
- @import "../bootstrap/scss/mixins";
90
- @import "./style/scss/Settings/Mixins";
91
-
92
- li {
93
- list-style-type: none;
94
- }
95
-
96
- // 基本 sizes
97
- .tree-item {
98
- .btn {
99
- --bs-btn-padding-x: 0.75em;
100
- --bs-btn-padding-y: 0.375em;
101
- --bs-btn-font-size: 1em;
102
- }
103
-
104
- .card {
105
- --bs-card-spacer-y: 1em;
106
- --bs-card-spacer-x: 1em;
107
- --bs-card-title-spacer-y: 0.5em;
108
- --bs-card-cap-padding-y: 0.5em;
109
- --bs-card-cap-padding-x: 1em;
110
- --bs-card-img-overlay-padding: 1em;
111
- --bs-card-group-margin: 0.75em;
112
- }
113
-
114
- .material-icons {
115
- font-size: 1.5em;
116
-
117
- &.icon-14 {
118
- font-size: 0.875em;
119
- }
120
-
121
- &.icon-18 {
122
- font-size: 1.125em;
123
- }
124
-
125
- &.icon-28 {
126
- font-size: 1.75em;
127
- }
128
-
129
- &.icon-32 {
130
- font-size: 2em;
131
- }
132
- }
133
- }
134
-
135
- // hover效果與優化
136
- // firefox 暫不支援 has
137
- .tree-item:has([data-bs-toggle="collapse"]:hover) + .collapse {
138
- will-change: height;
139
- }
140
-
141
- .tree-item:hover > .card,
142
- .tree-item .card:focus-within {
143
- background-color: lighten( $primary, 32% );
144
- border-color: rgba( $primary, .4 );
145
- }
146
-
147
- // active效果
148
- .tree-item.active {
149
- > .card {
150
- background-color: lighten( $primary, 30% );
151
- border-color: rgba( $primary, .5 );
152
- }
153
-
154
- .btn-title {
155
- color: $primary;
156
- }
157
- }
158
-
159
- .btn-title {
160
- .btn {
161
- border-radius: 0;
162
-
163
- &:focus, &:active {
164
- border-color: transparent;
165
- }
166
- }
167
-
168
- .btn-text {
169
- width: 100%;
170
- text-align: left;
171
- overflow-wrap: anywhere;
172
- }
173
- }
174
-
175
- label.btn-title {
176
- cursor: pointer;
177
- }
178
-
179
- // 隱藏 input
180
- .tree-item {
181
- position: relative;
182
-
183
- input[type="checkbox"], input[type="radio"] {
184
- position: absolute;
185
- @include size(0);
186
- opacity: 0;
187
- pointer-events: none;
188
-
189
- ~ .btn-title .material-icons:before {
190
- content: "\e836";
191
- display: inline-block;
192
- font-family: inherit;
193
- }
194
-
195
- &:checked ~ .btn-title .material-icons:before {
196
- content: "\e837";
197
- }
198
- }
199
- }
200
-
201
-
202
- // 刪除子層標示 UI
203
- .tree-item:has(.btn.text-danger:hover) {
204
- .card {
205
- background-color: lighten( $danger, 43% );
206
- border-color: rgba( $danger, .5 );
207
-
208
- .btn {
209
- color: $danger;
210
- }
211
- }
212
- }
213
- // 刪除子層標示 UI (含子層)
214
- // .tree-child:has(.btn.text-danger:hover){
215
- // .card, + .content-children .card{
216
- // background-color: lighten( $danger, 43% );
217
- // border-color: rgba( $danger, .5 );
218
- // .btn{
219
- // color: $danger;
220
- // }
221
- // }
222
- // }
223
-
224
- .btn-no-children {
225
- cursor: auto;
226
-
227
- &:focus {
228
- border-color: transparent;
229
- }
230
- }
231
-
232
- // 基本 style
233
- $card-margin: .2em;
234
- $line-padding: .7em;
235
-
236
- .tree-item {
237
- display: flex;
238
- flex-direction: column;
239
- width: 100%;
240
- margin-top: $card-margin;
241
-
242
- .card {
243
- position: relative;
244
- flex-grow: 1;
245
- transition: $transition-base;
246
- z-index: 2;
247
- }
248
- }
249
-
250
- .col-action {
251
- @include flex-center;
252
- width: 2.8rem;
253
- }
254
-
255
-
256
- // 開合 style
257
- .btn[data-bs-toggle="collapse"] {
258
- .material-icons {
259
- transition: $transition-base;
260
- }
261
-
262
- &[aria-expanded="false"] .material-icons {
263
- transform: rotate(-90deg);
264
- }
265
-
266
- &:disabled, &.disabled {
267
- border-color: transparent;
268
- }
269
- }
270
-
271
- // 畫線 style
272
- .content-children {
273
- padding-left: 1.5rem;
274
- --tree-border-color: #fff;
275
- position: relative;
276
-
277
- &:before {
278
- content: "";
279
- position: absolute;
280
- display: block;
281
- left: -$line-padding;
282
- bottom: 24px;
283
- width: 1px;
284
- height: 100%;
285
- z-index: 1;
286
- background-color: var(--tree-border-color);
287
- }
288
- // // line color
289
- &:before, .tree-item .card:before, .tree-item .card:after {
290
- background-color: var(--tree-border-color);
291
- }
292
- }
293
-
294
- .tree-item {
295
- &:last-child > .content-children:before {
296
- display: none;
297
- }
298
-
299
- .card {
300
- position: relative;
301
-
302
- &:before, &:after {
303
- content: "";
304
- position: absolute;
305
- left: calc(-#{$line-padding} - #{$border-width});
306
- z-index: 1;
307
- }
308
-
309
- &:before {
310
- bottom: 50%;
311
- width: 1px;
312
- height: calc(100% + #{$card-margin}*2 + #{$border-width}*2);
313
- }
314
-
315
- &:after {
316
- top: 0;
317
- bottom: 0;
318
- width: $line-padding;
319
- height: 1px;
320
- margin: auto;
321
- }
322
- }
323
-
324
- &:nth-child(1) > .card:before {
325
- height: calc(50% + #{$card-margin} + #{$border-width});
326
- }
327
- }
328
-
329
-
330
- // 小版本
331
- .tree-item-sm {
332
- > .card {
333
- font-size: 86%;
334
- }
335
-
336
- .content-children {
337
- padding-left: 1rem;
338
- }
339
-
340
- .content-children:before {
341
- left: -10px;
342
- bottom: 19px;
343
- }
344
- }
345
- // .tree-item-sm + .content-children{
346
- // > .children-box{
347
- // padding-left: 1rem;
348
- // }
349
- // }
350
-
351
-
352
- // 白背景版本
353
- .tree-item-in-white {
354
- .content-children {
355
- --tree-border-color: var(--bs-border-color);
356
- }
357
-
358
- .card {
359
- --bs-card-bg: var(--gray-100);
360
- --bs-card-border-color: var(--bs-border-color);
361
- }
362
-
363
- &:hover > .card,
364
- .card:focus-within {
365
- background-color: $white;
366
- }
367
- // active效果
368
- &.active .card {
369
- background-color: $white;
370
- }
371
- }
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 "../bootstrap/scss/functions";
88
+ @import "./style/scss/Settings/bs-variables";
89
+ @import "../bootstrap/scss/mixins";
90
+ @import "./style/scss/Settings/Mixins";
91
+
92
+ li {
93
+ list-style-type: none;
94
+ }
95
+
96
+ // 基本 sizes
97
+ .tree-item {
98
+ .btn {
99
+ --bs-btn-padding-x: 0.75em;
100
+ --bs-btn-padding-y: 0.375em;
101
+ --bs-btn-font-size: 1em;
102
+ }
103
+
104
+ .card {
105
+ --bs-card-spacer-y: 1em;
106
+ --bs-card-spacer-x: 1em;
107
+ --bs-card-title-spacer-y: 0.5em;
108
+ --bs-card-cap-padding-y: 0.5em;
109
+ --bs-card-cap-padding-x: 1em;
110
+ --bs-card-img-overlay-padding: 1em;
111
+ --bs-card-group-margin: 0.75em;
112
+ }
113
+
114
+ .material-icons {
115
+ font-size: 1.5em;
116
+
117
+ &.icon-14 {
118
+ font-size: 0.875em;
119
+ }
120
+
121
+ &.icon-18 {
122
+ font-size: 1.125em;
123
+ }
124
+
125
+ &.icon-28 {
126
+ font-size: 1.75em;
127
+ }
128
+
129
+ &.icon-32 {
130
+ font-size: 2em;
131
+ }
132
+ }
133
+ }
134
+
135
+ // hover效果與優化
136
+ // firefox 暫不支援 has
137
+ .tree-item:has([data-bs-toggle="collapse"]:hover) + .collapse {
138
+ will-change: height;
139
+ }
140
+
141
+ .tree-item:hover > .card,
142
+ .tree-item .card:focus-within {
143
+ background-color: lighten( $primary, 32% );
144
+ border-color: rgba( $primary, .4 );
145
+ }
146
+
147
+ // active效果
148
+ .tree-item.active {
149
+ > .card {
150
+ background-color: lighten( $primary, 30% );
151
+ border-color: rgba( $primary, .5 );
152
+ }
153
+
154
+ .btn-title {
155
+ color: $primary;
156
+ }
157
+ }
158
+
159
+ .btn-title {
160
+ .btn {
161
+ border-radius: 0;
162
+
163
+ &:focus, &:active {
164
+ border-color: transparent;
165
+ }
166
+ }
167
+
168
+ .btn-text {
169
+ width: 100%;
170
+ text-align: left;
171
+ overflow-wrap: anywhere;
172
+ }
173
+ }
174
+
175
+ label.btn-title {
176
+ cursor: pointer;
177
+ }
178
+
179
+ // 隱藏 input
180
+ .tree-item {
181
+ position: relative;
182
+
183
+ input[type="checkbox"], input[type="radio"] {
184
+ position: absolute;
185
+ @include size(0);
186
+ opacity: 0;
187
+ pointer-events: none;
188
+
189
+ ~ .btn-title .material-icons:before {
190
+ content: "\e836";
191
+ display: inline-block;
192
+ font-family: inherit;
193
+ }
194
+
195
+ &:checked ~ .btn-title .material-icons:before {
196
+ content: "\e837";
197
+ }
198
+ }
199
+ }
200
+
201
+
202
+ // 刪除子層標示 UI
203
+ .tree-item:has(.btn.text-danger:hover) {
204
+ .card {
205
+ background-color: lighten( $danger, 43% );
206
+ border-color: rgba( $danger, .5 );
207
+
208
+ .btn {
209
+ color: $danger;
210
+ }
211
+ }
212
+ }
213
+ // 刪除子層標示 UI (含子層)
214
+ // .tree-child:has(.btn.text-danger:hover){
215
+ // .card, + .content-children .card{
216
+ // background-color: lighten( $danger, 43% );
217
+ // border-color: rgba( $danger, .5 );
218
+ // .btn{
219
+ // color: $danger;
220
+ // }
221
+ // }
222
+ // }
223
+
224
+ .btn-no-children {
225
+ cursor: auto;
226
+
227
+ &:focus {
228
+ border-color: transparent;
229
+ }
230
+ }
231
+
232
+ // 基本 style
233
+ $card-margin: .2em;
234
+ $line-padding: .7em;
235
+
236
+ .tree-item {
237
+ display: flex;
238
+ flex-direction: column;
239
+ width: 100%;
240
+ margin-top: $card-margin;
241
+
242
+ .card {
243
+ position: relative;
244
+ flex-grow: 1;
245
+ transition: $transition-base;
246
+ z-index: 2;
247
+ }
248
+ }
249
+
250
+ .col-action {
251
+ @include flex-center;
252
+ width: 2.8rem;
253
+ }
254
+
255
+
256
+ // 開合 style
257
+ .btn[data-bs-toggle="collapse"] {
258
+ .material-icons {
259
+ transition: $transition-base;
260
+ }
261
+
262
+ &[aria-expanded="false"] .material-icons {
263
+ transform: rotate(-90deg);
264
+ }
265
+
266
+ &:disabled, &.disabled {
267
+ border-color: transparent;
268
+ }
269
+ }
270
+
271
+ // 畫線 style
272
+ .content-children {
273
+ padding-left: 1.5rem;
274
+ --tree-border-color: #fff;
275
+ position: relative;
276
+
277
+ &:before {
278
+ content: "";
279
+ position: absolute;
280
+ display: block;
281
+ left: -$line-padding;
282
+ bottom: 24px;
283
+ width: 1px;
284
+ height: 100%;
285
+ z-index: 1;
286
+ background-color: var(--tree-border-color);
287
+ }
288
+ // // line color
289
+ &:before, .tree-item .card:before, .tree-item .card:after {
290
+ background-color: var(--tree-border-color);
291
+ }
292
+ }
293
+
294
+ .tree-item {
295
+ &:last-child > .content-children:before {
296
+ display: none;
297
+ }
298
+
299
+ .card {
300
+ position: relative;
301
+
302
+ &:before, &:after {
303
+ content: "";
304
+ position: absolute;
305
+ left: calc(-#{$line-padding} - #{$border-width});
306
+ z-index: 1;
307
+ }
308
+
309
+ &:before {
310
+ bottom: 50%;
311
+ width: 1px;
312
+ height: calc(100% + #{$card-margin}*2 + #{$border-width}*2);
313
+ }
314
+
315
+ &:after {
316
+ top: 0;
317
+ bottom: 0;
318
+ width: $line-padding;
319
+ height: 1px;
320
+ margin: auto;
321
+ }
322
+ }
323
+
324
+ &:nth-child(1) > .card:before {
325
+ height: calc(50% + #{$card-margin} + #{$border-width});
326
+ }
327
+ }
328
+
329
+
330
+ // 小版本
331
+ .tree-item-sm {
332
+ > .card {
333
+ font-size: 86%;
334
+ }
335
+
336
+ .content-children {
337
+ padding-left: 1rem;
338
+ }
339
+
340
+ .content-children:before {
341
+ left: -10px;
342
+ bottom: 19px;
343
+ }
344
+ }
345
+ // .tree-item-sm + .content-children{
346
+ // > .children-box{
347
+ // padding-left: 1rem;
348
+ // }
349
+ // }
350
+
351
+
352
+ // 白背景版本
353
+ .tree-item-in-white {
354
+ .content-children {
355
+ --tree-border-color: var(--bs-border-color);
356
+ }
357
+
358
+ .card {
359
+ --bs-card-bg: var(--gray-100);
360
+ --bs-card-border-color: var(--bs-border-color);
361
+ }
362
+
363
+ &:hover > .card,
364
+ .card:focus-within {
365
+ background-color: $white;
366
+ }
367
+ // active效果
368
+ &.active .card {
369
+ background-color: $white;
370
+ }
371
+ }
372
372
  </style>