compostrap 1.0.3 → 1.1.0
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/dist/css/compostrap.css +119 -0
- package/dist/css/sortable.css +119 -0
- package/dist/css/theme.css +24 -7
- package/dist/js/index.js +7 -6
- package/dist/js/sortable.js +181 -0
- package/docs/blog.md +85 -85
- package/docs/layout.md +143 -143
- package/docs/sortable.md +59 -0
- package/package.json +2 -1
- package/readme.md +199 -198
- package/src/js/datepicker.js +154 -154
- package/src/js/index.js +2 -1
- package/src/js/sortable.js +408 -0
- package/src/scss/compostrap.scss +1 -0
- package/src/scss/datagrid.scss +5 -5
- package/src/scss/datepicker/_index.scss +557 -557
- package/src/scss/sidebar/_index.scss +8 -8
- package/src/scss/sortable/_index.scss +158 -0
- package/src/scss/sortable.scss +5 -0
- package/src/scss/theme/_tables.scss +3 -2
package/dist/css/compostrap.css
CHANGED
|
@@ -742,6 +742,125 @@ a.list-row:hover {
|
|
|
742
742
|
align-items: center;
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
+
.sortable {
|
|
746
|
+
--sortable-handle-size: 1.75rem;
|
|
747
|
+
--sortable-handle-color: color-mix(in srgb, var(--bs-secondary-color) 70%, transparent);
|
|
748
|
+
--sortable-place-bg: rgba(var(--bs-primary-rgb), .06);
|
|
749
|
+
--sortable-place-line: rgba(var(--bs-primary-rgb), .45);
|
|
750
|
+
--sortable-indent: 2.5rem;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.sortable-item {
|
|
754
|
+
display: flex;
|
|
755
|
+
gap: 0.75rem;
|
|
756
|
+
align-items: center;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.sortable-handle {
|
|
760
|
+
display: inline-flex;
|
|
761
|
+
flex-shrink: 0;
|
|
762
|
+
align-items: center;
|
|
763
|
+
align-self: flex-start;
|
|
764
|
+
justify-content: center;
|
|
765
|
+
width: var(--sortable-handle-size, 1.75rem);
|
|
766
|
+
height: var(--sortable-handle-size, 1.75rem);
|
|
767
|
+
margin-block: 0.125rem;
|
|
768
|
+
padding: 0;
|
|
769
|
+
cursor: grab;
|
|
770
|
+
touch-action: none;
|
|
771
|
+
background: none;
|
|
772
|
+
border: 0;
|
|
773
|
+
border-radius: var(--bs-border-radius-sm);
|
|
774
|
+
}
|
|
775
|
+
.sortable-handle::before {
|
|
776
|
+
width: 0.625rem;
|
|
777
|
+
height: 1rem;
|
|
778
|
+
content: "";
|
|
779
|
+
background-color: var(--sortable-handle-color, var(--bs-secondary-color));
|
|
780
|
+
mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 16'%3e%3cg fill='black'%3e%3ccircle cx='2.5' cy='3' r='1.5'/%3e%3ccircle cx='7.5' cy='3' r='1.5'/%3e%3ccircle cx='2.5' cy='8' r='1.5'/%3e%3ccircle cx='7.5' cy='8' r='1.5'/%3e%3ccircle cx='2.5' cy='13' r='1.5'/%3e%3ccircle cx='7.5' cy='13' r='1.5'/%3e%3c/g%3e%3c/svg%3e") no-repeat center/contain;
|
|
781
|
+
}
|
|
782
|
+
.sortable-handle:hover::before, .sortable-handle[aria-pressed=true]::before {
|
|
783
|
+
background-color: var(--bs-emphasis-color);
|
|
784
|
+
}
|
|
785
|
+
.sortable-handle:hover {
|
|
786
|
+
background-color: rgba(var(--bs-body-color-rgb), 0.05);
|
|
787
|
+
}
|
|
788
|
+
.sortable-handle:focus {
|
|
789
|
+
outline: 0;
|
|
790
|
+
}
|
|
791
|
+
.sortable-handle:focus-visible {
|
|
792
|
+
box-shadow: var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.sortable-placeholder {
|
|
796
|
+
background-color: var(--sortable-place-bg) !important;
|
|
797
|
+
outline: 1px dashed var(--sortable-place-line);
|
|
798
|
+
outline-offset: -1px;
|
|
799
|
+
}
|
|
800
|
+
.sortable-placeholder > * {
|
|
801
|
+
visibility: hidden;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
.sortable-grabbed {
|
|
805
|
+
position: relative;
|
|
806
|
+
z-index: 2;
|
|
807
|
+
background-color: var(--sortable-place-bg) !important;
|
|
808
|
+
outline: 1px solid var(--sortable-place-line);
|
|
809
|
+
outline-offset: -1px;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
.sortable-ghost {
|
|
813
|
+
position: fixed;
|
|
814
|
+
top: 0;
|
|
815
|
+
left: 0;
|
|
816
|
+
z-index: 1090;
|
|
817
|
+
margin: 0 !important;
|
|
818
|
+
pointer-events: none;
|
|
819
|
+
background-color: var(--bs-body-bg);
|
|
820
|
+
border-radius: var(--bs-border-radius) !important;
|
|
821
|
+
box-shadow: var(--bs-box-shadow);
|
|
822
|
+
opacity: 0.95;
|
|
823
|
+
}
|
|
824
|
+
.sortable-ghost .sortable-handle {
|
|
825
|
+
cursor: grabbing;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
.sortable-active,
|
|
829
|
+
.sortable-active * {
|
|
830
|
+
cursor: grabbing !important;
|
|
831
|
+
user-select: none;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
.sortable-nested {
|
|
835
|
+
width: 100%;
|
|
836
|
+
margin-top: 0.5rem;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
.sortable-item:has(> .sortable-nested) {
|
|
840
|
+
flex-wrap: wrap;
|
|
841
|
+
}
|
|
842
|
+
.sortable-item:has(> .sortable-nested) > .sortable-nested {
|
|
843
|
+
margin-left: var(--sortable-indent);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
.sortable:not(:has(> .sortable-item)) {
|
|
847
|
+
min-height: 2.75rem;
|
|
848
|
+
outline: 1px dashed rgba(var(--bs-body-color-rgb), 0.15);
|
|
849
|
+
outline-offset: -1px;
|
|
850
|
+
border-radius: var(--bs-border-radius);
|
|
851
|
+
}
|
|
852
|
+
.sortable:not(:has(> .sortable-item))::before {
|
|
853
|
+
display: block;
|
|
854
|
+
padding: 0.625rem 1rem;
|
|
855
|
+
color: var(--bs-secondary-color);
|
|
856
|
+
content: attr(data-sortable-empty);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
@media (prefers-reduced-motion: reduce) {
|
|
860
|
+
.sortable-ghost {
|
|
861
|
+
opacity: 1;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
745
864
|
.number-input {
|
|
746
865
|
--number-input-btn-size: 2rem;
|
|
747
866
|
--number-input-btn-bg: rgba(var(--bs-body-color-rgb), .06);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.sortable {
|
|
2
|
+
--sortable-handle-size: 1.75rem;
|
|
3
|
+
--sortable-handle-color: color-mix(in srgb, var(--bs-secondary-color) 70%, transparent);
|
|
4
|
+
--sortable-place-bg: rgba(var(--bs-primary-rgb), .06);
|
|
5
|
+
--sortable-place-line: rgba(var(--bs-primary-rgb), .45);
|
|
6
|
+
--sortable-indent: 2.5rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sortable-item {
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: 0.75rem;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sortable-handle {
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
align-items: center;
|
|
19
|
+
align-self: flex-start;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
width: var(--sortable-handle-size, 1.75rem);
|
|
22
|
+
height: var(--sortable-handle-size, 1.75rem);
|
|
23
|
+
margin-block: 0.125rem;
|
|
24
|
+
padding: 0;
|
|
25
|
+
cursor: grab;
|
|
26
|
+
touch-action: none;
|
|
27
|
+
background: none;
|
|
28
|
+
border: 0;
|
|
29
|
+
border-radius: var(--bs-border-radius-sm);
|
|
30
|
+
}
|
|
31
|
+
.sortable-handle::before {
|
|
32
|
+
width: 0.625rem;
|
|
33
|
+
height: 1rem;
|
|
34
|
+
content: "";
|
|
35
|
+
background-color: var(--sortable-handle-color, var(--bs-secondary-color));
|
|
36
|
+
mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 16'%3e%3cg fill='black'%3e%3ccircle cx='2.5' cy='3' r='1.5'/%3e%3ccircle cx='7.5' cy='3' r='1.5'/%3e%3ccircle cx='2.5' cy='8' r='1.5'/%3e%3ccircle cx='7.5' cy='8' r='1.5'/%3e%3ccircle cx='2.5' cy='13' r='1.5'/%3e%3ccircle cx='7.5' cy='13' r='1.5'/%3e%3c/g%3e%3c/svg%3e") no-repeat center/contain;
|
|
37
|
+
}
|
|
38
|
+
.sortable-handle:hover::before, .sortable-handle[aria-pressed=true]::before {
|
|
39
|
+
background-color: var(--bs-emphasis-color);
|
|
40
|
+
}
|
|
41
|
+
.sortable-handle:hover {
|
|
42
|
+
background-color: rgba(var(--bs-body-color-rgb), 0.05);
|
|
43
|
+
}
|
|
44
|
+
.sortable-handle:focus {
|
|
45
|
+
outline: 0;
|
|
46
|
+
}
|
|
47
|
+
.sortable-handle:focus-visible {
|
|
48
|
+
box-shadow: var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.sortable-placeholder {
|
|
52
|
+
background-color: var(--sortable-place-bg) !important;
|
|
53
|
+
outline: 1px dashed var(--sortable-place-line);
|
|
54
|
+
outline-offset: -1px;
|
|
55
|
+
}
|
|
56
|
+
.sortable-placeholder > * {
|
|
57
|
+
visibility: hidden;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.sortable-grabbed {
|
|
61
|
+
position: relative;
|
|
62
|
+
z-index: 2;
|
|
63
|
+
background-color: var(--sortable-place-bg) !important;
|
|
64
|
+
outline: 1px solid var(--sortable-place-line);
|
|
65
|
+
outline-offset: -1px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.sortable-ghost {
|
|
69
|
+
position: fixed;
|
|
70
|
+
top: 0;
|
|
71
|
+
left: 0;
|
|
72
|
+
z-index: 1090;
|
|
73
|
+
margin: 0 !important;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
background-color: var(--bs-body-bg);
|
|
76
|
+
border-radius: var(--bs-border-radius) !important;
|
|
77
|
+
box-shadow: var(--bs-box-shadow);
|
|
78
|
+
opacity: 0.95;
|
|
79
|
+
}
|
|
80
|
+
.sortable-ghost .sortable-handle {
|
|
81
|
+
cursor: grabbing;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sortable-active,
|
|
85
|
+
.sortable-active * {
|
|
86
|
+
cursor: grabbing !important;
|
|
87
|
+
user-select: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.sortable-nested {
|
|
91
|
+
width: 100%;
|
|
92
|
+
margin-top: 0.5rem;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.sortable-item:has(> .sortable-nested) {
|
|
96
|
+
flex-wrap: wrap;
|
|
97
|
+
}
|
|
98
|
+
.sortable-item:has(> .sortable-nested) > .sortable-nested {
|
|
99
|
+
margin-left: var(--sortable-indent);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.sortable:not(:has(> .sortable-item)) {
|
|
103
|
+
min-height: 2.75rem;
|
|
104
|
+
outline: 1px dashed rgba(var(--bs-body-color-rgb), 0.15);
|
|
105
|
+
outline-offset: -1px;
|
|
106
|
+
border-radius: var(--bs-border-radius);
|
|
107
|
+
}
|
|
108
|
+
.sortable:not(:has(> .sortable-item))::before {
|
|
109
|
+
display: block;
|
|
110
|
+
padding: 0.625rem 1rem;
|
|
111
|
+
color: var(--bs-secondary-color);
|
|
112
|
+
content: attr(data-sortable-empty);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@media (prefers-reduced-motion: reduce) {
|
|
116
|
+
.sortable-ghost {
|
|
117
|
+
opacity: 1;
|
|
118
|
+
}
|
|
119
|
+
}
|
package/dist/css/theme.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@charset "UTF-8";
|
|
2
2
|
/*!
|
|
3
|
-
* Bootstrap v5.3.
|
|
4
|
-
* Copyright 2011-
|
|
3
|
+
* Bootstrap v5.3.9 (https://getbootstrap.com/)
|
|
4
|
+
* Copyright 2011-2026 The Bootstrap Authors
|
|
5
5
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
6
6
|
*/
|
|
7
7
|
:root,
|
|
@@ -526,7 +526,7 @@ legend + * {
|
|
|
526
526
|
|
|
527
527
|
::-webkit-datetime-edit-fields-wrapper,
|
|
528
528
|
::-webkit-datetime-edit-text,
|
|
529
|
-
::-webkit-datetime-edit-minute,
|
|
529
|
+
::-webkit-datetime-edit-minute-field,
|
|
530
530
|
::-webkit-datetime-edit-hour-field,
|
|
531
531
|
::-webkit-datetime-edit-day-field,
|
|
532
532
|
::-webkit-datetime-edit-month-field,
|
|
@@ -5530,15 +5530,22 @@ textarea.form-control-lg {
|
|
|
5530
5530
|
}
|
|
5531
5531
|
@media (min-width: 992px) {
|
|
5532
5532
|
.modal-lg,
|
|
5533
|
-
.modal-xl
|
|
5533
|
+
.modal-xl,
|
|
5534
|
+
.modal-xxl {
|
|
5534
5535
|
--bs-modal-width: 800px;
|
|
5535
5536
|
}
|
|
5536
5537
|
}
|
|
5537
5538
|
@media (min-width: 1200px) {
|
|
5538
|
-
.modal-xl
|
|
5539
|
+
.modal-xl,
|
|
5540
|
+
.modal-xxl {
|
|
5539
5541
|
--bs-modal-width: 1140px;
|
|
5540
5542
|
}
|
|
5541
5543
|
}
|
|
5544
|
+
@media (min-width: 1400px) {
|
|
5545
|
+
.modal-xxl {
|
|
5546
|
+
--bs-modal-width: 1320px;
|
|
5547
|
+
}
|
|
5548
|
+
}
|
|
5542
5549
|
.modal-fullscreen {
|
|
5543
5550
|
width: 100vw;
|
|
5544
5551
|
max-width: none;
|
|
@@ -6713,6 +6720,11 @@ textarea.form-control-lg {
|
|
|
6713
6720
|
.placeholder-glow .placeholder {
|
|
6714
6721
|
animation: placeholder-glow 2s ease-in-out infinite;
|
|
6715
6722
|
}
|
|
6723
|
+
@media (prefers-reduced-motion: reduce) {
|
|
6724
|
+
.placeholder-glow .placeholder {
|
|
6725
|
+
animation: none;
|
|
6726
|
+
}
|
|
6727
|
+
}
|
|
6716
6728
|
|
|
6717
6729
|
@keyframes placeholder-glow {
|
|
6718
6730
|
50% {
|
|
@@ -6724,6 +6736,11 @@ textarea.form-control-lg {
|
|
|
6724
6736
|
mask-size: 200% 100%;
|
|
6725
6737
|
animation: placeholder-wave 2s linear infinite;
|
|
6726
6738
|
}
|
|
6739
|
+
@media (prefers-reduced-motion: reduce) {
|
|
6740
|
+
.placeholder-wave {
|
|
6741
|
+
animation: none;
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6727
6744
|
|
|
6728
6745
|
@keyframes placeholder-wave {
|
|
6729
6746
|
100% {
|
|
@@ -12704,13 +12721,13 @@ button.badge.badge-subtle.show {
|
|
|
12704
12721
|
color: var(--bs-body-color);
|
|
12705
12722
|
}
|
|
12706
12723
|
|
|
12707
|
-
.table td a:not(.btn, .dropdown-item):has(> i:only-child) {
|
|
12724
|
+
.table td a:not(.btn, .dropdown-item, .badge):has(> i:only-child) {
|
|
12708
12725
|
display: inline-block;
|
|
12709
12726
|
padding: 0 0.25rem;
|
|
12710
12727
|
color: var(--bs-secondary-color);
|
|
12711
12728
|
text-decoration: none;
|
|
12712
12729
|
}
|
|
12713
|
-
.table td a:not(.btn, .dropdown-item):has(> i:only-child):hover {
|
|
12730
|
+
.table td a:not(.btn, .dropdown-item, .badge):has(> i:only-child):hover {
|
|
12714
12731
|
color: var(--bs-body-color);
|
|
12715
12732
|
}
|
|
12716
12733
|
|
package/dist/js/index.js
CHANGED
|
@@ -8,17 +8,18 @@ import { PasswordToggle as o } from "./password-toggle.js";
|
|
|
8
8
|
import { NumberInput as s } from "./number-input.js";
|
|
9
9
|
import { OtpInput as c } from "./otp-input.js";
|
|
10
10
|
import { RowSelection as l } from "./selection.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { SortableList as u } from "./sortable.js";
|
|
12
|
+
import { Spinner as d } from "./spinner.js";
|
|
13
|
+
import { Dialogs as f } from "./dialogs.js";
|
|
14
|
+
import { CssTooltip as p } from "./tooltip.js";
|
|
14
15
|
// src/js/index.js
|
|
15
|
-
var
|
|
16
|
+
var m = class {
|
|
16
17
|
static init() {
|
|
17
18
|
e.init();
|
|
18
19
|
}
|
|
19
|
-
},
|
|
20
|
+
}, h = class {
|
|
20
21
|
static init() {
|
|
21
22
|
t.init();
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
|
-
export {
|
|
25
|
+
export { p as CssTooltip, f as Dialogs, r as DropzoneInput, i as Lightbox, s as NumberInput, c as OtpInput, o as PasswordToggle, l as RowSelection, e as Sidebar, t as SidebarMenu, h as SidebarMenuApp, m as SidebarSkeleton, u as SortableList, d as Spinner, a as Strength, n as ThemeSwitcher };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// src/js/sortable.js
|
|
2
|
+
var e = class {
|
|
3
|
+
static duration = 150;
|
|
4
|
+
static scrollEdge = 48;
|
|
5
|
+
static messages = {
|
|
6
|
+
grabbed: "{item} grabbed, position {position} of {count}. Arrows move it, Space drops it, Escape cancels.",
|
|
7
|
+
moved: "{item}, position {position} of {count}.",
|
|
8
|
+
dropped: "{item} dropped, position {position} of {count}.",
|
|
9
|
+
canceled: "Move canceled, {item} is back at position {position} of {count}."
|
|
10
|
+
};
|
|
11
|
+
static _initialized = !1;
|
|
12
|
+
static _drag = null;
|
|
13
|
+
static _grab = null;
|
|
14
|
+
static _live = null;
|
|
15
|
+
static init() {
|
|
16
|
+
this._initialized || (this._initialized = !0, document.addEventListener("pointerdown", (e) => this._pointerDown(e)), document.addEventListener("keydown", (e) => this._keyDown(e)), document.addEventListener("focusout", (e) => this._focusOut(e)));
|
|
17
|
+
}
|
|
18
|
+
static serialize(e) {
|
|
19
|
+
return this._items(e).map((e) => {
|
|
20
|
+
let t = e.querySelector(":scope > .sortable");
|
|
21
|
+
return t ? {
|
|
22
|
+
id: e.dataset.id,
|
|
23
|
+
children: this.serialize(t)
|
|
24
|
+
} : { id: e.dataset.id };
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
static _pointerDown(e) {
|
|
28
|
+
let t = e.target.closest?.(".sortable-handle"), n = t?.closest(".sortable-item"), r = n?.parentElement;
|
|
29
|
+
if (!t || !r?.matches(".sortable") || e.button !== 0 || this._drag) return;
|
|
30
|
+
e.preventDefault(), this._grab && this._drop(!1);
|
|
31
|
+
let i = n.getBoundingClientRect(), a = n.cloneNode(!0);
|
|
32
|
+
a.classList.add("sortable-ghost"), a.querySelectorAll("[id]").forEach((e) => e.removeAttribute("id")), a.removeAttribute("id"), a.setAttribute("aria-hidden", "true"), a.inert = !0, a.style.width = `${i.width}px`, a.style.height = `${i.height}px`, a.style.setProperty("--bs-list-group-bg", getComputedStyle(r).getPropertyValue("--bs-list-group-bg")), document.body.append(a), this._drag = {
|
|
33
|
+
item: n,
|
|
34
|
+
ghost: a,
|
|
35
|
+
from: r,
|
|
36
|
+
oldIndex: this._items(r).indexOf(n),
|
|
37
|
+
offsetX: e.clientX - i.left,
|
|
38
|
+
offsetY: e.clientY - i.top,
|
|
39
|
+
x: e.clientX,
|
|
40
|
+
y: e.clientY,
|
|
41
|
+
frame: 0
|
|
42
|
+
}, n.classList.add("sortable-placeholder"), document.documentElement.classList.add("sortable-active"), this._moveGhost(), this._onMove = (e) => {
|
|
43
|
+
this._drag.x = e.clientX, this._drag.y = e.clientY, this._moveGhost(), this._place();
|
|
44
|
+
}, this._onUp = () => this._endDrag(!1), this._onCancel = () => this._endDrag(!0), this._onEscape = (e) => {
|
|
45
|
+
e.key === "Escape" && (e.preventDefault(), this._endDrag(!0));
|
|
46
|
+
}, document.addEventListener("pointermove", this._onMove), document.addEventListener("pointerup", this._onUp), document.addEventListener("pointercancel", this._onCancel), document.addEventListener("keydown", this._onEscape, !0), this._drag.frame = requestAnimationFrame(() => this._autoScroll());
|
|
47
|
+
}
|
|
48
|
+
static _moveGhost() {
|
|
49
|
+
let { ghost: e, x: t, y: n, offsetX: r, offsetY: i } = this._drag;
|
|
50
|
+
e.style.transform = `translate(${t - r}px, ${n - i}px)`;
|
|
51
|
+
}
|
|
52
|
+
static _place() {
|
|
53
|
+
let { item: e, x: t, y: n } = this._drag, r = document.elementFromPoint(t, n);
|
|
54
|
+
if (!r || e.contains(r)) return;
|
|
55
|
+
let i = r.closest(".sortable-item");
|
|
56
|
+
for (; i && !this._accepts(i.parentElement, e);) i = i.parentElement.closest(".sortable-item");
|
|
57
|
+
if (i) {
|
|
58
|
+
let t = this._head(i);
|
|
59
|
+
if (n < t.top || n > t.bottom) return;
|
|
60
|
+
let r = t.top + t.height / 2, a = i.parentElement === e.parentElement, o = a ? !!(e.compareDocumentPosition(i) & Node.DOCUMENT_POSITION_FOLLOWING) : n > r;
|
|
61
|
+
if (a && (o ? n < r : n > r)) return;
|
|
62
|
+
this._moveTo(i.parentElement, o ? i.nextElementSibling : i);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
let a = r.closest(".sortable");
|
|
66
|
+
if (a && this._accepts(a, e)) {
|
|
67
|
+
let t = this._items(a), r = t[t.length - 1];
|
|
68
|
+
(!r || r !== e && n > r.getBoundingClientRect().bottom) && this._moveTo(a, null);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
static _head(e) {
|
|
72
|
+
let t = e.getBoundingClientRect(), n = e.querySelector(":scope > .sortable");
|
|
73
|
+
if (!n) return t;
|
|
74
|
+
let r = n.getBoundingClientRect().top;
|
|
75
|
+
return {
|
|
76
|
+
top: t.top,
|
|
77
|
+
bottom: r,
|
|
78
|
+
height: r - t.top
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
static _autoScroll() {
|
|
82
|
+
let e = this._drag;
|
|
83
|
+
if (!e) return;
|
|
84
|
+
let t = this.scrollEdge, n = e.y < t ? -(t - e.y) / 3 : e.y > innerHeight - t ? (e.y - innerHeight + t) / 3 : 0;
|
|
85
|
+
n !== 0 && (window.scrollBy(0, n), this._place()), e.frame = requestAnimationFrame(() => this._autoScroll());
|
|
86
|
+
}
|
|
87
|
+
static _endDrag(e) {
|
|
88
|
+
let t = this._drag;
|
|
89
|
+
t && (cancelAnimationFrame(t.frame), document.removeEventListener("pointermove", this._onMove), document.removeEventListener("pointerup", this._onUp), document.removeEventListener("pointercancel", this._onCancel), document.removeEventListener("keydown", this._onEscape, !0), document.documentElement.classList.remove("sortable-active"), t.ghost.remove(), t.item.classList.remove("sortable-placeholder"), this._drag = null, e ? this._restore(t) : this._changed(t));
|
|
90
|
+
}
|
|
91
|
+
static _keyDown(e) {
|
|
92
|
+
let t = e.target.closest?.(".sortable-handle"), n = t?.closest(".sortable-item");
|
|
93
|
+
if (!t || !n?.parentElement?.matches(".sortable") || this._drag) return;
|
|
94
|
+
let r = this._grab?.item === n;
|
|
95
|
+
if (e.key === " " || e.key === "Enter") e.preventDefault(), r ? this._drop(!0) : (this._grab && this._drop(!1), this._grabItem(n, t));
|
|
96
|
+
else if (r && (e.key === "ArrowUp" || e.key === "ArrowDown")) e.preventDefault(), this._step(e.key === "ArrowUp" ? -1 : 1);
|
|
97
|
+
else if (r && e.key === "Escape") {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
let t = this._grab;
|
|
100
|
+
this._release(), this._restore(t), this._announce("canceled", t.item), t.handle.focus();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
static _grabItem(e, t) {
|
|
104
|
+
this._grab = {
|
|
105
|
+
item: e,
|
|
106
|
+
handle: t,
|
|
107
|
+
from: e.parentElement,
|
|
108
|
+
oldIndex: this._items(e.parentElement).indexOf(e)
|
|
109
|
+
}, e.classList.add("sortable-grabbed"), t.setAttribute("aria-pressed", "true"), this._announce("grabbed", e);
|
|
110
|
+
}
|
|
111
|
+
static _step(e) {
|
|
112
|
+
let { item: t, handle: n } = this._grab, r = t.parentElement, i = e < 0 ? t.previousElementSibling : t.nextElementSibling;
|
|
113
|
+
if (i?.matches(".sortable-item")) this._moveTo(r, e < 0 ? i : i.nextElementSibling);
|
|
114
|
+
else {
|
|
115
|
+
let n = this._lists(t), i = n[n.indexOf(r) + e];
|
|
116
|
+
if (!i) return;
|
|
117
|
+
this._moveTo(i, e < 0 ? null : this._items(i)[0] ?? null);
|
|
118
|
+
}
|
|
119
|
+
n.focus(), t.scrollIntoView({ block: "nearest" }), this._announce("moved", t);
|
|
120
|
+
}
|
|
121
|
+
static _drop(e) {
|
|
122
|
+
let t = this._grab;
|
|
123
|
+
this._release(), e && this._announce("dropped", t.item), this._changed(t);
|
|
124
|
+
}
|
|
125
|
+
static _release() {
|
|
126
|
+
this._grab.item.classList.remove("sortable-grabbed"), this._grab.handle.removeAttribute("aria-pressed"), this._grab = null;
|
|
127
|
+
}
|
|
128
|
+
static _focusOut(e) {
|
|
129
|
+
this._grab && !this._moving && e.target === this._grab.handle && this._drop(!0);
|
|
130
|
+
}
|
|
131
|
+
static _items(e) {
|
|
132
|
+
return [...e.children].filter((e) => e.matches(".sortable-item"));
|
|
133
|
+
}
|
|
134
|
+
static _accepts(e, t) {
|
|
135
|
+
let n = t.parentElement;
|
|
136
|
+
if (!e?.matches(".sortable") || t.contains(e)) return !1;
|
|
137
|
+
if (e === n) return !0;
|
|
138
|
+
let r = n.dataset.sortableGroup;
|
|
139
|
+
return !r || e.dataset.sortableGroup !== r ? !1 : !(e.closest(".sortable-item") && t.querySelector(":scope > .sortable"));
|
|
140
|
+
}
|
|
141
|
+
static _lists(e) {
|
|
142
|
+
return e.parentElement.dataset.sortableGroup ? [...document.querySelectorAll(".sortable")].filter((t) => t === e.parentElement || this._accepts(t, e)) : [e.parentElement];
|
|
143
|
+
}
|
|
144
|
+
static _moveTo(e, t) {
|
|
145
|
+
let n = (this._drag ?? this._grab).item;
|
|
146
|
+
if (t === n || t === null && e.lastElementChild === n) return;
|
|
147
|
+
let r = this.duration > 0 && !matchMedia("(prefers-reduced-motion: reduce)").matches ? [.../* @__PURE__ */ new Set([...e.querySelectorAll(".sortable-item"), ...n.parentElement.querySelectorAll(".sortable-item")])].filter((e) => e !== n && !n.contains(e)) : [], i = new Map(r.map((e) => [e, e.getBoundingClientRect()]));
|
|
148
|
+
this._moving = !0, e.insertBefore(n, t), this._moving = !1;
|
|
149
|
+
for (let [e, t] of i) {
|
|
150
|
+
let n = e.getBoundingClientRect(), r = t.left - n.left, i = t.top - n.top;
|
|
151
|
+
(r !== 0 || i !== 0) && e.animate([{ transform: `translate(${r}px, ${i}px)` }, { transform: "none" }], {
|
|
152
|
+
duration: this.duration,
|
|
153
|
+
easing: "ease-out"
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
static _restore({ item: e, from: t, oldIndex: n }) {
|
|
158
|
+
this._moving = !0, t.insertBefore(e, this._items(t).filter((t) => t !== e)[n] ?? null), this._moving = !1;
|
|
159
|
+
}
|
|
160
|
+
static _changed({ item: e, from: t, oldIndex: n }) {
|
|
161
|
+
let r = e.parentElement, i = this._items(r).indexOf(e);
|
|
162
|
+
if (r === t && i === n) return;
|
|
163
|
+
let a = new CustomEvent("change.bs.sortable", {
|
|
164
|
+
bubbles: !0,
|
|
165
|
+
detail: {
|
|
166
|
+
item: e,
|
|
167
|
+
from: t,
|
|
168
|
+
to: r,
|
|
169
|
+
oldIndex: n,
|
|
170
|
+
newIndex: i
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
e.dispatchEvent(a);
|
|
174
|
+
}
|
|
175
|
+
static _announce(e, t) {
|
|
176
|
+
this._live || (this._live = document.createElement("div"), this._live.className = "sortable-live visually-hidden", this._live.setAttribute("aria-live", "assertive"), document.body.append(this._live));
|
|
177
|
+
let n = this._items(t.parentElement), r = t.querySelector(":scope > .sortable-handle"), i = t.dataset.sortableLabel || r?.getAttribute("aria-label")?.replace(/^Move\s+/, "") || t.textContent.trim();
|
|
178
|
+
this._live.textContent = this.messages[e].replace("{item}", i).replace("{position}", String(n.indexOf(t) + 1)).replace("{count}", String(n.length));
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
export { e as SortableList };
|