coveragebook_components 0.8.8 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/build/coco/app.css +292 -245
- data/app/assets/build/coco/app.js +64 -34
- data/app/assets/build/coco/book.css +67 -18
- data/app/assets/build/coco/book.js +50 -21
- data/app/assets/js/libs/alpine/directives/dropdown.js +5 -2
- data/app/components/coco/app/elements/alert/alert.css +1 -1
- data/app/components/coco/app/elements/button/button.css +38 -58
- data/app/components/coco/app/elements/button/button.rb +2 -3
- data/app/components/coco/app/elements/button_group/button_group.css +7 -2
- data/app/components/coco/app/elements/button_group/button_group.html.erb +2 -1
- data/app/components/coco/app/elements/button_group/button_group.js +28 -14
- data/app/components/coco/app/elements/button_to/button_to.css +4 -8
- data/app/components/coco/app/elements/color_picker_button/color_picker_button.css +1 -2
- data/app/components/coco/app/elements/image_picker_button/image_picker_button.css +1 -2
- data/app/components/coco/app/elements/layout_picker_button/layout_picker_button.css +1 -2
- data/app/components/coco/app/elements/menu/menu.css +7 -5
- data/app/components/coco/app/elements/menu_button/menu_button.css +1 -2
- data/app/components/coco/app/elements/snackbar/snackbar.css +3 -3
- data/app/components/coco/base/button/button.css +9 -9
- data/app/components/coco/base/button/button.html.erb +16 -18
- data/app/components/coco/base/button/button.js +6 -18
- data/app/components/coco/base/button/button.rb +38 -58
- data/app/components/coco/base/button/button_dropdown.js +27 -0
- data/app/components/coco/base/modal/modal.css +12 -0
- data/app/components/coco/base/modal/modal.html.erb +11 -1
- data/app/components/coco/base/modal/modal.rb +4 -1
- data/app/components/coco/base/modal_dialog/modal_dialog.css +6 -2
- data/app/components/coco/base/panel/panel.css +19 -0
- data/app/components/coco/base/panel/panel.html.erb +5 -0
- data/app/components/coco/base/panel/panel.rb +4 -0
- data/app/helpers/coco/app_helper.rb +4 -0
- data/lib/coco.rb +1 -1
- metadata +6 -2
@@ -6,7 +6,7 @@
|
|
6
6
|
@apply transition-all overflow-hidden;
|
7
7
|
border-radius: 44px;
|
8
8
|
|
9
|
-
|
9
|
+
.button-content {
|
10
10
|
@apply font-semibold;
|
11
11
|
}
|
12
12
|
}
|
@@ -23,7 +23,7 @@
|
|
23
23
|
@apply bg-primary-700;
|
24
24
|
}
|
25
25
|
|
26
|
-
&[data-state="loading"]
|
26
|
+
&[data-state="loading"] .button-icon {
|
27
27
|
@apply text-positive-300;
|
28
28
|
}
|
29
29
|
|
@@ -44,7 +44,7 @@
|
|
44
44
|
@apply bg-gray-blend-100;
|
45
45
|
}
|
46
46
|
|
47
|
-
&[data-state="loading"]
|
47
|
+
&[data-state="loading"] .button-icon {
|
48
48
|
@apply text-positive-300;
|
49
49
|
}
|
50
50
|
|
@@ -66,7 +66,7 @@
|
|
66
66
|
@apply bg-gray-blend-100;
|
67
67
|
}
|
68
68
|
|
69
|
-
&[data-state="loading"]
|
69
|
+
&[data-state="loading"] .button-icon {
|
70
70
|
@apply text-positive-300;
|
71
71
|
}
|
72
72
|
|
@@ -95,7 +95,7 @@
|
|
95
95
|
@apply bg-gray-blend-100;
|
96
96
|
}
|
97
97
|
|
98
|
-
&[data-state="loading"]
|
98
|
+
&[data-state="loading"] .button-icon {
|
99
99
|
@apply text-positive-300;
|
100
100
|
}
|
101
101
|
|
@@ -115,7 +115,7 @@
|
|
115
115
|
@apply bg-negative-800;
|
116
116
|
}
|
117
117
|
|
118
|
-
&[data-state="loading"]
|
118
|
+
&[data-state="loading"] .button-icon {
|
119
119
|
@apply text-negative-300;
|
120
120
|
}
|
121
121
|
|
@@ -135,7 +135,7 @@
|
|
135
135
|
@apply bg-gray-blend-100;
|
136
136
|
}
|
137
137
|
|
138
|
-
&[data-state="loading"]
|
138
|
+
&[data-state="loading"] .button-icon {
|
139
139
|
@apply text-negative-300;
|
140
140
|
}
|
141
141
|
|
@@ -155,7 +155,7 @@
|
|
155
155
|
@apply bg-warning-800;
|
156
156
|
}
|
157
157
|
|
158
|
-
&[data-state="loading"]
|
158
|
+
&[data-state="loading"] .button-icon {
|
159
159
|
@apply text-warning-300;
|
160
160
|
}
|
161
161
|
|
@@ -175,7 +175,7 @@
|
|
175
175
|
@apply bg-gray-blend-100;
|
176
176
|
}
|
177
177
|
|
178
|
-
&[data-state="loading"]
|
178
|
+
&[data-state="loading"] .button-icon {
|
179
179
|
@apply text-warning-300;
|
180
180
|
}
|
181
181
|
|
@@ -195,7 +195,7 @@
|
|
195
195
|
@apply bg-info-800;
|
196
196
|
}
|
197
197
|
|
198
|
-
&[data-state="loading"]
|
198
|
+
&[data-state="loading"] .button-icon {
|
199
199
|
@apply text-info-300;
|
200
200
|
}
|
201
201
|
|
@@ -215,7 +215,7 @@
|
|
215
215
|
@apply bg-gray-blend-100;
|
216
216
|
}
|
217
217
|
|
218
|
-
&[data-state="loading"]
|
218
|
+
&[data-state="loading"] .button-icon {
|
219
219
|
@apply text-info-300;
|
220
220
|
}
|
221
221
|
|
@@ -241,21 +241,17 @@
|
|
241
241
|
}
|
242
242
|
|
243
243
|
&[data-theme="neutral-light"] {
|
244
|
-
@apply border border-transparent;
|
244
|
+
@apply border border-transparent bg-background-light-1 text-content-dark-1 hover:bg-background-light-2 active:bg-background-light-3;
|
245
245
|
|
246
|
-
|
247
|
-
@apply bg-background-light-1 text-content-dark-1 hover:bg-background-light-2 active:bg-background-light-3;
|
248
|
-
}
|
249
|
-
|
250
|
-
&[data-state="loading"] .button-element {
|
246
|
+
&[data-state="loading"] {
|
251
247
|
@apply bg-background-light-1;
|
252
248
|
}
|
253
249
|
|
254
|
-
&[data-state="active"]
|
250
|
+
&[data-state="active"] {
|
255
251
|
@apply bg-background-light-3;
|
256
252
|
}
|
257
253
|
|
258
|
-
&[data-disabled="true"]
|
254
|
+
&[data-disabled="true"] {
|
259
255
|
@apply bg-background-light-1;
|
260
256
|
|
261
257
|
.button-inner {
|
@@ -415,23 +411,19 @@
|
|
415
411
|
}
|
416
412
|
|
417
413
|
&[data-theme] {
|
418
|
-
|
419
|
-
@apply py-2 px-3;
|
420
|
-
}
|
414
|
+
@apply py-2 px-3;
|
421
415
|
}
|
422
416
|
|
423
|
-
&.icon-only
|
424
|
-
&[data-collapsed="true"]
|
417
|
+
&.icon-only .button-icon,
|
418
|
+
&[data-collapsed="true"] .button-icon {
|
425
419
|
@apply -ml-1 -mr-1;
|
426
420
|
}
|
427
421
|
|
428
422
|
&[data-theme|="text"] {
|
429
|
-
|
430
|
-
@apply px-2;
|
431
|
-
}
|
423
|
+
@apply px-2;
|
432
424
|
|
433
|
-
&.icon-only
|
434
|
-
&[data-collapsed="true"]
|
425
|
+
&.icon-only .button-icon,
|
426
|
+
&[data-collapsed="true"] .button-icon {
|
435
427
|
@apply px-2;
|
436
428
|
}
|
437
429
|
}
|
@@ -448,23 +440,19 @@
|
|
448
440
|
}
|
449
441
|
|
450
442
|
&[data-theme] {
|
451
|
-
.
|
452
|
-
@apply py-2.5 px-4;
|
453
|
-
}
|
443
|
+
@apply py-2.5 px-4;
|
454
444
|
|
455
|
-
&.icon-only
|
456
|
-
&[data-collapsed="true"]
|
445
|
+
&.icon-only .button-icon,
|
446
|
+
&[data-collapsed="true"] .button-icon {
|
457
447
|
@apply -ml-1.5 -mr-1.5;
|
458
448
|
}
|
459
449
|
}
|
460
450
|
|
461
451
|
&[data-theme|="text"] {
|
462
|
-
|
463
|
-
@apply px-2;
|
464
|
-
}
|
452
|
+
@apply px-2;
|
465
453
|
|
466
|
-
&.icon-only
|
467
|
-
&[data-collapsed="true"]
|
454
|
+
&.icon-only .button-icon,
|
455
|
+
&[data-collapsed="true"] .button-icon {
|
468
456
|
@apply px-2;
|
469
457
|
}
|
470
458
|
}
|
@@ -481,23 +469,19 @@
|
|
481
469
|
}
|
482
470
|
|
483
471
|
&[data-theme] {
|
484
|
-
|
485
|
-
@apply py-3 px-5;
|
486
|
-
}
|
472
|
+
@apply py-3 px-5;
|
487
473
|
|
488
|
-
&.icon-only
|
489
|
-
&[data-collapsed="true"]
|
474
|
+
&.icon-only .button-icon,
|
475
|
+
&[data-collapsed="true"] .button-icon {
|
490
476
|
@apply -ml-2 -mr-2;
|
491
477
|
}
|
492
478
|
}
|
493
479
|
|
494
480
|
&[data-theme|="text"] {
|
495
|
-
|
496
|
-
@apply px-3;
|
497
|
-
}
|
481
|
+
@apply px-3;
|
498
482
|
|
499
|
-
&.icon-only
|
500
|
-
&[data-collapsed="true"]
|
483
|
+
&.icon-only .button-icon,
|
484
|
+
&[data-collapsed="true"] .button-icon {
|
501
485
|
@apply px-2;
|
502
486
|
}
|
503
487
|
}
|
@@ -514,23 +498,19 @@
|
|
514
498
|
}
|
515
499
|
|
516
500
|
&[data-theme] {
|
517
|
-
|
518
|
-
@apply py-4 px-6;
|
519
|
-
}
|
501
|
+
@apply py-4 px-6;
|
520
502
|
|
521
|
-
&.icon-only
|
503
|
+
&.icon-only .button-icon,
|
522
504
|
&[data-collapsed="true"] .button-inner {
|
523
505
|
@apply ml-[-8px] mr-[-8px];
|
524
506
|
}
|
525
507
|
}
|
526
508
|
|
527
509
|
&[data-theme|="text"] {
|
528
|
-
|
529
|
-
@apply px-3;
|
530
|
-
}
|
510
|
+
@apply px-3;
|
531
511
|
|
532
|
-
&.icon-only
|
533
|
-
&[data-collapsed="true"]
|
512
|
+
&.icon-only .button-icon,
|
513
|
+
&[data-collapsed="true"] .button-icon {
|
534
514
|
@apply px-3;
|
535
515
|
}
|
536
516
|
}
|
@@ -48,15 +48,14 @@ module Coco
|
|
48
48
|
}
|
49
49
|
|
50
50
|
before_initialize do |kwargs|
|
51
|
-
kwargs[:button_element] ||= {}
|
52
51
|
if kwargs.key?(:modal)
|
53
52
|
modal_name = (kwargs[:modal] == true) ? "default" : kwargs[:modal]
|
54
|
-
kwargs[:
|
53
|
+
kwargs[:data] = kwargs.fetch(:data, {}).merge(coco_modal_data_attributes(modal_name))
|
55
54
|
kwargs.delete(:modal)
|
56
55
|
end
|
57
56
|
if kwargs.key?(:frame)
|
58
57
|
turbo_data = {turbo: true, turbo_frame: kwargs[:frame]}
|
59
|
-
kwargs[:
|
58
|
+
kwargs[:data] = kwargs.fetch(:data, {}).merge(turbo_data)
|
60
59
|
kwargs.delete(:frame)
|
61
60
|
end
|
62
61
|
kwargs
|
@@ -2,6 +2,11 @@
|
|
2
2
|
[data-coco][data-component="app-button-group"] {
|
3
3
|
width: fit-content;
|
4
4
|
border-radius: 44px;
|
5
|
+
@apply opacity-0;
|
6
|
+
|
7
|
+
&.button-group-ready {
|
8
|
+
@apply opacity-100;
|
9
|
+
}
|
5
10
|
|
6
11
|
.button-group-buttons {
|
7
12
|
@apply flex items-center gap-x-2;
|
@@ -23,11 +28,11 @@
|
|
23
28
|
@apply gap-x-0;
|
24
29
|
}
|
25
30
|
|
26
|
-
.coco-button:not(:first-child) {
|
31
|
+
.coco-button-wrapper:not(:first-child) .coco-button {
|
27
32
|
@apply rounded-l-none border-l-0;
|
28
33
|
}
|
29
34
|
|
30
|
-
.coco-button:not(:last-child) {
|
35
|
+
.coco-button-wrapper:not(:last-child) .coco-button {
|
31
36
|
@apply rounded-r-none;
|
32
37
|
}
|
33
38
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
<%= render component_tag(x: {
|
2
2
|
data: "appButtonGroup",
|
3
3
|
"dimensions.parent": "onResize",
|
4
|
-
options: "options"
|
4
|
+
options: "options",
|
5
|
+
":class": "{'button-group-ready': ready}"
|
5
6
|
}) do %>
|
6
7
|
<div class="button-group-buttons" x-ref="buttons">
|
7
8
|
<% items.each do |item| %>
|
@@ -1,15 +1,17 @@
|
|
1
1
|
import { CocoComponent } from "@js/coco.js";
|
2
|
-
import {
|
2
|
+
import { getComponent } from "@helpers/alpine";
|
3
3
|
import { createSingleton } from "@libs/tippy";
|
4
4
|
|
5
5
|
export default CocoComponent("appButtonGroup", () => {
|
6
6
|
return {
|
7
7
|
options: ["collapsible"],
|
8
8
|
|
9
|
+
ready: false,
|
9
10
|
containerWidth: 0,
|
10
11
|
contentWidth: 0,
|
11
12
|
collapsed: false,
|
12
|
-
|
13
|
+
singletonTooltip: null,
|
14
|
+
tooltipInstances: [],
|
13
15
|
|
14
16
|
get collapsible() {
|
15
17
|
return this.$options.collapsible !== false;
|
@@ -19,7 +21,7 @@ export default CocoComponent("appButtonGroup", () => {
|
|
19
21
|
const buttonElements = this.$el.querySelectorAll(
|
20
22
|
"[data-component='app-button']"
|
21
23
|
);
|
22
|
-
return Array.from(buttonElements).map((el) =>
|
24
|
+
return Array.from(buttonElements).map((el) => getComponent(el));
|
23
25
|
},
|
24
26
|
|
25
27
|
get parent() {
|
@@ -29,31 +31,43 @@ export default CocoComponent("appButtonGroup", () => {
|
|
29
31
|
init() {
|
30
32
|
this.$nextTick(() => {
|
31
33
|
if (!this.collapsible) return;
|
34
|
+
this.ready = true;
|
32
35
|
|
33
|
-
this.createTooltipsSingleton();
|
34
36
|
this.onResize();
|
37
|
+
this.createSingletonTooltip();
|
35
38
|
});
|
36
39
|
|
37
40
|
this.$watch("collapsed", (value) => {
|
38
41
|
this.buttons.forEach((button) => {
|
39
42
|
button.isCollapsed = value;
|
40
43
|
});
|
44
|
+
this.$nextTick(() => this.createSingletonTooltip());
|
41
45
|
});
|
42
46
|
},
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
createSingletonTooltip() {
|
49
|
+
this.destroySingletonTooltip();
|
50
|
+
|
51
|
+
this.tooltipInstances = this.buttons
|
52
|
+
.map((button) => button.shouldShowTooltip() && button.tippyInstance)
|
49
53
|
.filter((t) => t);
|
50
54
|
|
51
|
-
this.
|
55
|
+
this.singletonTooltip = createSingleton(this.tooltipInstances, {
|
52
56
|
theme: "coco-tooltip",
|
53
|
-
|
57
|
+
delay: 100,
|
58
|
+
moveTransition: "transform 0.1s ease-out",
|
54
59
|
});
|
55
60
|
},
|
56
61
|
|
62
|
+
destroySingletonTooltip() {
|
63
|
+
if (this.singletonTooltip && this.singletonTooltip.destroy) {
|
64
|
+
this.singletonTooltip.destroy();
|
65
|
+
this.singletonTooltip = null;
|
66
|
+
this.tooltipInstances.forEach((tooltip) => tooltip.destroy());
|
67
|
+
this.tooltipInstances = [];
|
68
|
+
}
|
69
|
+
},
|
70
|
+
|
57
71
|
onResize() {
|
58
72
|
if (!this.collapsible) return;
|
59
73
|
|
@@ -73,9 +87,9 @@ export default CocoComponent("appButtonGroup", () => {
|
|
73
87
|
},
|
74
88
|
|
75
89
|
destroy() {
|
76
|
-
if (this.
|
77
|
-
this.
|
78
|
-
this.
|
90
|
+
if (this.singletonTooltip) {
|
91
|
+
this.singletonTooltip.destroy();
|
92
|
+
this.singletonTooltip = null;
|
79
93
|
}
|
80
94
|
},
|
81
95
|
};
|
@@ -1,14 +1,10 @@
|
|
1
1
|
@layer components {
|
2
2
|
[data-coco][data-component="app-button-to"] {
|
3
|
-
@apply
|
4
|
-
width: max-content;
|
3
|
+
@apply contents;
|
5
4
|
|
6
|
-
form
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
&[data-fit="full"] {
|
11
|
-
@apply w-full;
|
5
|
+
form,
|
6
|
+
input {
|
7
|
+
@apply contents;
|
12
8
|
}
|
13
9
|
}
|
14
10
|
}
|
@@ -8,9 +8,11 @@
|
|
8
8
|
@apply w-full;
|
9
9
|
}
|
10
10
|
|
11
|
-
>
|
12
|
-
> [data-component="app-button-to"],
|
13
|
-
> [data-component="app-menu-button"]
|
11
|
+
> .coco-button-wrapper > .coco-button,
|
12
|
+
> [data-component="app-button-to"] .coco-button,
|
13
|
+
> [data-component="app-menu-button"]
|
14
|
+
> .coco-button-wrapper
|
15
|
+
> .coco-button {
|
14
16
|
@apply hover:bg-gray-blend-50 active:bg-gray-blend-100;
|
15
17
|
|
16
18
|
.button-inner {
|
@@ -32,7 +34,7 @@
|
|
32
34
|
@apply py-1.5;
|
33
35
|
|
34
36
|
.menu-item {
|
35
|
-
[data-component="app-button"]
|
37
|
+
[data-component="app-button"] {
|
36
38
|
@apply px-4 py-2 text-label-sm;
|
37
39
|
|
38
40
|
.button-inner {
|
@@ -50,7 +52,7 @@
|
|
50
52
|
@apply py-2;
|
51
53
|
|
52
54
|
.menu-item {
|
53
|
-
[data-component="app-button"]
|
55
|
+
[data-component="app-button"] {
|
54
56
|
@apply px-5 py-2.5 text-label-md;
|
55
57
|
|
56
58
|
.button-inner {
|
@@ -25,14 +25,14 @@
|
|
25
25
|
@apply text-label-md text-content-light-1 font-semibold flex-grow mr-2 my-2;
|
26
26
|
}
|
27
27
|
|
28
|
-
.coco-button
|
28
|
+
.coco-button {
|
29
29
|
@apply hover:bg-background-dark-3;
|
30
30
|
}
|
31
31
|
|
32
32
|
.snackbar-action {
|
33
33
|
@apply flex-none ml-auto;
|
34
34
|
|
35
|
-
.coco-button
|
35
|
+
.coco-button {
|
36
36
|
@apply px-2 text-content-info-inverse;
|
37
37
|
}
|
38
38
|
}
|
@@ -40,7 +40,7 @@
|
|
40
40
|
.snackbar-dismiss {
|
41
41
|
@apply flex-none ml-auto;
|
42
42
|
|
43
|
-
.coco-button
|
43
|
+
.coco-button {
|
44
44
|
@apply text-content-light-2 hover:text-content-light-1;
|
45
45
|
}
|
46
46
|
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
@layer components {
|
2
|
+
.coco-button-wrapper {
|
3
|
+
@apply !contents;
|
4
|
+
}
|
5
|
+
|
2
6
|
[data-coco].coco-button {
|
3
|
-
@apply flex transition-colors w-auto bg-transparent text-current border border-transparent select-none flex-none;
|
7
|
+
@apply flex transition-colors w-auto bg-transparent text-current border border-transparent select-none flex-none no-underline outline-none focus-visible:outline-0;
|
4
8
|
width: min-content;
|
5
9
|
|
6
|
-
.button-element {
|
7
|
-
@apply inline-flex w-full no-underline outline-none focus-visible:outline-0;
|
8
|
-
}
|
9
|
-
|
10
10
|
.button-inner {
|
11
11
|
@apply inline-flex items-center text-center mx-auto gap-2;
|
12
12
|
width: fit-content;
|
@@ -34,13 +34,13 @@
|
|
34
34
|
|
35
35
|
/* disabled */
|
36
36
|
|
37
|
-
&[data-disabled="true"]
|
37
|
+
&[data-disabled="true"] {
|
38
38
|
@apply cursor-not-allowed pointer-events-none;
|
39
39
|
}
|
40
40
|
|
41
41
|
/* loading */
|
42
42
|
|
43
|
-
&[data-state="loading"]
|
43
|
+
&[data-state="loading"] .button-icon {
|
44
44
|
@apply animate-spin;
|
45
45
|
}
|
46
46
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
/* Icons */
|
54
54
|
|
55
|
-
&[data-icon-position="end"]
|
55
|
+
&[data-icon-position="end"] {
|
56
56
|
.button-content {
|
57
57
|
@apply order-1;
|
58
58
|
}
|
@@ -66,7 +66,7 @@
|
|
66
66
|
}
|
67
67
|
}
|
68
68
|
|
69
|
-
&.with-icon[data-collapsed="true"]
|
69
|
+
&.with-icon[data-collapsed="true"] {
|
70
70
|
.button-content {
|
71
71
|
display: none;
|
72
72
|
}
|
@@ -1,21 +1,19 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
18
|
-
) do %>
|
1
|
+
<%= coco_tag(:div, class: "coco-button-wrapper", x: alpine_wrapper_attrs || {}) do %>
|
2
|
+
<%= render component_tag(button_tag,
|
3
|
+
class: {
|
4
|
+
"coco-button": true,
|
5
|
+
"icon-only": icon_only?,
|
6
|
+
"with-icon": (icon? && !icon_only?)
|
7
|
+
},
|
8
|
+
x: {
|
9
|
+
data: x_data("button", alpine_data),
|
10
|
+
bind: "root",
|
11
|
+
":disabled": "disabled",
|
12
|
+
"dropdown:trigger": (true if dropdown?),
|
13
|
+
"dropdown:anchor": (true if dropdown?),
|
14
|
+
"@click": ("#{"checkConfirmation($event);" if confirm?} #{on_click}" if confirm? || on_click.present?)
|
15
|
+
}
|
16
|
+
) do %>
|
19
17
|
<span class="button-inner">
|
20
18
|
<% states.each do |name, props| %>
|
21
19
|
<% if props[:icon].present? %>
|
@@ -11,12 +11,14 @@ export default CocoComponent("button", (data = {}) => {
|
|
11
11
|
lastState: null,
|
12
12
|
stateTooltips: data.tooltips || {},
|
13
13
|
tooltipText: null,
|
14
|
-
dropdown: null,
|
15
14
|
|
16
15
|
...(data.props || {}),
|
17
16
|
|
18
17
|
init() {
|
19
18
|
this.lastState = this.state;
|
19
|
+
this.checkConfirmation = this.checkConfirmation.bind(this);
|
20
|
+
this.approveAndRun = this.approveAndRun.bind(this);
|
21
|
+
this.shouldShowTooltip = this.shouldShowTooltip.bind(this);
|
20
22
|
|
21
23
|
this.$nextTick(() => {
|
22
24
|
if (this.$options.confirm) {
|
@@ -53,7 +55,7 @@ export default CocoComponent("button", (data = {}) => {
|
|
53
55
|
}
|
54
56
|
},
|
55
57
|
|
56
|
-
|
58
|
+
shouldShowTooltip() {
|
57
59
|
return !!this.tooltipText;
|
58
60
|
},
|
59
61
|
|
@@ -65,18 +67,8 @@ export default CocoComponent("button", (data = {}) => {
|
|
65
67
|
this.$options.disabled = value;
|
66
68
|
},
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
hideDropdown() {
|
71
|
-
if (this.dropdown) {
|
72
|
-
this.dropdown.hide();
|
73
|
-
}
|
74
|
-
},
|
75
|
-
|
76
|
-
showDropdown() {
|
77
|
-
if (this.dropdown) {
|
78
|
-
this.dropdown.show();
|
79
|
-
}
|
70
|
+
get tippyInstance() {
|
71
|
+
return this.$root.__x_tippy;
|
80
72
|
},
|
81
73
|
|
82
74
|
/* confirmation */
|
@@ -189,10 +181,6 @@ export default CocoComponent("button", (data = {}) => {
|
|
189
181
|
"x-options": "options",
|
190
182
|
"x-tooltip": "tooltipText",
|
191
183
|
"x-effect": "setTooltipText",
|
192
|
-
"@confirmation:confirm": "approveAndRun",
|
193
|
-
"@confirmation:cancel": "cancelConfirmation",
|
194
|
-
"@dropdown:show": "setState('active')",
|
195
|
-
"@dropdown:hide": "resetState()",
|
196
184
|
},
|
197
185
|
};
|
198
186
|
});
|