@mintplayer/web-components 1.0.0 → 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/a11y/index.mjs +2 -56
- package/calendar/index.mjs +2 -363
- package/checkbox/index.mjs +4 -0
- package/checkbox/src/components/index.d.ts +2 -0
- package/checkbox/src/components/mp-checkbox.d.ts +69 -0
- package/checkbox/src/index.d.ts +2 -0
- package/chunks/color-C4VT0EL7.mjs +847 -0
- package/chunks/form-check.styles-jBlHetYX.mjs +151 -0
- package/chunks/live-announcer-CZDTKulf.mjs +58 -0
- package/chunks/mp-calendar.element-UC68iDbi.mjs +365 -0
- package/chunks/mp-checkbox-BokLL7BS.mjs +211 -0
- package/chunks/mp-datatable-CpAu8JJD.mjs +750 -0
- package/chunks/mp-pagination-BGxsawFL.mjs +326 -0
- package/chunks/mp-select-BDS1-YGn.mjs +254 -0
- package/chunks/mp-splitter-C8cGCmac.mjs +633 -0
- package/chunks/mp-tab-page-D1b4x-y2.mjs +414 -0
- package/chunks/mp-timepicker.element-BwEiwX92.mjs +428 -0
- package/chunks/mp-toggle-button-dLZNDUVz.mjs +534 -0
- package/chunks/mp-treeview-Bfq4_IVW.mjs +474 -0
- package/code-snippet/index.mjs +16 -13
- package/datatable/index.mjs +7 -0
- package/datatable/src/components/index.d.ts +2 -0
- package/datatable/src/components/mp-datatable.d.ts +156 -0
- package/datatable/src/index.d.ts +6 -0
- package/datatable/src/sort/compute-next-sort.d.ts +18 -0
- package/datatable/src/sort/index.d.ts +3 -0
- package/datatable/src/sort/sort-rows.d.ts +6 -0
- package/datatable/src/styles/datatable.styles.d.ts +2 -0
- package/datatable/src/styles/index.d.ts +1 -0
- package/datatable/src/types/column-def.d.ts +30 -0
- package/datatable/src/types/index.d.ts +1 -0
- package/datepicker/index.mjs +240 -0
- package/datepicker/src/index.d.ts +1 -0
- package/datepicker/src/mp-datepicker.element.d.ts +94 -0
- package/datepicker/src/mp-datepicker.element.template.d.ts +2 -0
- package/datetime-picker/index.mjs +427 -0
- package/datetime-picker/src/index.d.ts +1 -0
- package/datetime-picker/src/mp-datetime-picker.element.d.ts +174 -0
- package/datetime-picker/src/mp-datetime-picker.element.template.d.ts +2 -0
- package/dock/index.mjs +2402 -0
- package/dock/src/components/index.d.ts +1 -0
- package/dock/src/components/mint-dock-manager.element.d.ts +313 -0
- package/dock/src/components/mint-dock-manager.element.template.d.ts +2 -0
- package/dock/src/index.d.ts +2 -0
- package/dock/src/types/dock-layout.d.ts +65 -0
- package/dock/src/types/index.d.ts +1 -0
- package/file-manager/index.mjs +1263 -0
- package/file-manager/src/components/index.d.ts +2 -0
- package/file-manager/src/components/mp-file-manager.d.ts +320 -0
- package/file-manager/src/index.d.ts +5 -0
- package/file-manager/src/styles/file-manager.styles.d.ts +2 -0
- package/file-manager/src/styles/index.d.ts +1 -0
- package/file-manager/src/types/file-system-node.d.ts +24 -0
- package/file-manager/src/types/index.d.ts +3 -0
- package/file-manager/src/types/messages.d.ts +43 -0
- package/multi-range/index.mjs +407 -0
- package/multi-range/src/index.d.ts +2 -0
- package/multi-range/src/mint-multi-range.element.d.ts +124 -0
- package/multi-range/src/mint-multi-range.element.template.d.ts +2 -0
- package/multi-range/src/types/multi-range-orientation.d.ts +1 -0
- package/otp-input/index.mjs +362 -0
- package/otp-input/src/index.d.ts +4 -0
- package/otp-input/src/mint-otp-input.element.d.ts +134 -0
- package/otp-input/src/mint-otp-input.element.template.d.ts +2 -0
- package/otp-input/src/types/otp-input-case.d.ts +1 -0
- package/otp-input/src/types/otp-input-size.d.ts +1 -0
- package/otp-input/src/types/otp-input-type.d.ts +1 -0
- package/overlay/index.mjs +260 -0
- package/overlay/src/index.d.ts +2 -0
- package/overlay/src/overlay-controller.d.ts +205 -0
- package/package.json +1 -1
- package/pagination/index.mjs +5 -0
- package/pagination/src/components/index.d.ts +2 -0
- package/pagination/src/components/mp-pagination.d.ts +95 -0
- package/pagination/src/index.d.ts +2 -0
- package/pagination/src/styles/index.d.ts +1 -0
- package/pagination/src/styles/pagination.styles.d.ts +2 -0
- package/query-builder/index.mjs +3720 -0
- package/query-builder/src/context.d.ts +14 -0
- package/query-builder/src/dnd/drag-controller.d.ts +69 -0
- package/query-builder/src/index.d.ts +23 -0
- package/query-builder/src/model/default-tree.d.ts +7 -0
- package/query-builder/src/model/editor.d.ts +15 -0
- package/query-builder/src/model/errors.d.ts +6 -0
- package/query-builder/src/model/expression.d.ts +22 -0
- package/query-builder/src/model/field-def.d.ts +17 -0
- package/query-builder/src/model/messages.d.ts +17 -0
- package/query-builder/src/model/operator-overrides.d.ts +21 -0
- package/query-builder/src/model/operators.d.ts +8 -0
- package/query-builder/src/model/saved-query.d.ts +6 -0
- package/query-builder/src/model/sort.d.ts +9 -0
- package/query-builder/src/model/tree-ops.d.ts +56 -0
- package/query-builder/src/mp-query-builder.element.d.ts +158 -0
- package/query-builder/src/mp-query-builder.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-condition.element.d.ts +44 -0
- package/query-builder/src/mp-query-condition.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-group.element.d.ts +52 -0
- package/query-builder/src/mp-query-group.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-subquery.element.d.ts +37 -0
- package/query-builder/src/mp-query-subquery.element.template.d.ts +2 -0
- package/query-builder/src/preview/render-expression.d.ts +23 -0
- package/query-builder/src/value-editors/builtin-editors.d.ts +6 -0
- package/query-builder/src/visitor/visit-tree.d.ts +29 -0
- package/query-builder/src/visitor/visitor-types.d.ts +15 -0
- package/radio/index.mjs +162 -0
- package/radio/src/components/index.d.ts +2 -0
- package/radio/src/components/mp-radio.d.ts +63 -0
- package/radio/src/index.d.ts +2 -0
- package/ribbon/index.mjs +3151 -0
- package/ribbon/src/index.d.ts +10 -0
- package/ribbon/src/items/index.d.ts +15 -0
- package/ribbon/src/items/mp-ribbon-button.element.d.ts +10 -0
- package/ribbon/src/items/mp-ribbon-checkbox.element.d.ts +11 -0
- package/ribbon/src/items/mp-ribbon-color-picker.element.d.ts +12 -0
- package/ribbon/src/items/mp-ribbon-combobox.element.d.ts +19 -0
- package/ribbon/src/items/mp-ribbon-dropdown-button.element.d.ts +16 -0
- package/ribbon/src/items/mp-ribbon-gallery-item.element.d.ts +15 -0
- package/ribbon/src/items/mp-ribbon-gallery.element.d.ts +11 -0
- package/ribbon/src/items/mp-ribbon-group-button.element.d.ts +18 -0
- package/ribbon/src/items/mp-ribbon-item-base.d.ts +68 -0
- package/ribbon/src/items/mp-ribbon-menu-item.element.d.ts +13 -0
- package/ribbon/src/items/mp-ribbon-menu-separator.element.d.ts +6 -0
- package/ribbon/src/items/mp-ribbon-split-button.element.d.ts +23 -0
- package/ribbon/src/items/mp-ribbon-template-item.element.d.ts +12 -0
- package/ribbon/src/items/mp-ribbon-toggle-button.element.d.ts +12 -0
- package/ribbon/src/mp-quick-access-toolbar.element.d.ts +35 -0
- package/ribbon/src/mp-ribbon-contextual-tab-set.element.d.ts +18 -0
- package/ribbon/src/mp-ribbon-group.element.d.ts +59 -0
- package/ribbon/src/mp-ribbon-tab.element.d.ts +72 -0
- package/ribbon/src/mp-ribbon.element.d.ts +211 -0
- package/ribbon/src/types/ribbon.types.d.ts +4 -0
- package/scheduler/index.mjs +3567 -0
- package/scheduler/src/components/mp-scheduler.d.ts +238 -0
- package/scheduler/src/drag/drag-manager.d.ts +90 -0
- package/scheduler/src/drag/drag-preview.d.ts +42 -0
- package/scheduler/src/drag/drag-state-machine.d.ts +102 -0
- package/scheduler/src/drag/drag-types.d.ts +104 -0
- package/scheduler/src/drag/index.d.ts +4 -0
- package/scheduler/src/events/event-types.d.ts +58 -0
- package/scheduler/src/events/index.d.ts +2 -0
- package/scheduler/src/events/scheduler-event-emitter.d.ts +52 -0
- package/scheduler/src/index.d.ts +6 -0
- package/scheduler/src/input/index.d.ts +2 -0
- package/scheduler/src/input/input-handler.d.ts +105 -0
- package/scheduler/src/input/pointer-event.d.ts +39 -0
- package/scheduler/src/state/scheduler-state.d.ts +189 -0
- package/scheduler/src/styles/scheduler.styles.d.ts +2 -0
- package/scheduler/src/views/base-view.d.ts +87 -0
- package/scheduler/src/views/day-view.d.ts +25 -0
- package/scheduler/src/views/index.d.ts +6 -0
- package/scheduler/src/views/month-view.d.ts +27 -0
- package/scheduler/src/views/timeline-view.d.ts +23 -0
- package/scheduler/src/views/week-view.d.ts +28 -0
- package/scheduler/src/views/year-view.d.ts +25 -0
- package/scheduler-core/index.mjs +174 -0
- package/scheduler-core/src/index.d.ts +3 -0
- package/scheduler-core/src/models/drag-state.d.ts +43 -0
- package/scheduler-core/src/models/event.d.ts +111 -0
- package/scheduler-core/src/models/events.d.ts +108 -0
- package/scheduler-core/src/models/index.d.ts +7 -0
- package/scheduler-core/src/models/options.d.ts +88 -0
- package/scheduler-core/src/models/resource.d.ts +58 -0
- package/scheduler-core/src/models/time-slot.d.ts +31 -0
- package/scheduler-core/src/models/types.d.ts +20 -0
- package/scheduler-core/src/services/date.service.d.ts +140 -0
- package/scheduler-core/src/services/index.d.ts +4 -0
- package/scheduler-core/src/services/position.service.d.ts +35 -0
- package/scheduler-core/src/services/resource.service.d.ts +83 -0
- package/scheduler-core/src/services/timeline.service.d.ts +103 -0
- package/scheduler-core/src/utils/color.d.ts +24 -0
- package/scheduler-core/src/utils/dom.d.ts +54 -0
- package/scheduler-core/src/utils/id.d.ts +16 -0
- package/scheduler-core/src/utils/index.d.ts +3 -0
- package/select/index.mjs +4 -0
- package/select/src/components/index.d.ts +2 -0
- package/select/src/components/mp-select.d.ts +82 -0
- package/select/src/index.d.ts +2 -0
- package/splitter/index.mjs +10 -0
- package/splitter/src/components/index.d.ts +2 -0
- package/splitter/src/components/mp-splitter.d.ts +109 -0
- package/splitter/src/index.d.ts +11 -0
- package/splitter/src/input/index.d.ts +4 -0
- package/splitter/src/input/input-handler.d.ts +36 -0
- package/splitter/src/input/pointer-event.d.ts +9 -0
- package/splitter/src/managers/index.d.ts +2 -0
- package/splitter/src/managers/resize-manager.d.ts +13 -0
- package/splitter/src/state/index.d.ts +2 -0
- package/splitter/src/state/splitter-state.d.ts +24 -0
- package/splitter/src/styles/index.d.ts +1 -0
- package/splitter/src/styles/splitter.styles.d.ts +2 -0
- package/splitter/src/types/direction.d.ts +1 -0
- package/splitter/src/types/index.d.ts +5 -0
- package/splitter/src/types/panel-info.d.ts +6 -0
- package/splitter/src/types/point.d.ts +4 -0
- package/splitter/src/types/resize-operation.d.ts +13 -0
- package/tab-control/index.mjs +6 -0
- package/tab-control/src/components/index.d.ts +3 -0
- package/tab-control/src/components/mp-tab-control.d.ts +50 -0
- package/tab-control/src/components/mp-tab-page.d.ts +35 -0
- package/tab-control/src/index.d.ts +4 -0
- package/tab-control/src/styles/index.d.ts +1 -0
- package/tab-control/src/styles/tab-control.styles.d.ts +2 -0
- package/tab-control/src/types/index.d.ts +1 -0
- package/tab-control/src/types/tabs-position.d.ts +1 -0
- package/tile-manager/index.mjs +867 -0
- package/tile-manager/src/components/index.d.ts +2 -0
- package/tile-manager/src/components/mint-tile-manager.element.d.ts +204 -0
- package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +2 -0
- package/tile-manager/src/index.d.ts +4 -0
- package/tile-manager/src/types/grid-rect.d.ts +12 -0
- package/tile-manager/src/types/index.d.ts +3 -0
- package/tile-manager/src/types/tile-layout-snapshot.d.ts +15 -0
- package/tile-manager/src/types/tile-position.d.ts +10 -0
- package/tile-manager/src/utils/index.d.ts +1 -0
- package/tile-manager/src/utils/pack.d.ts +24 -0
- package/timepicker/index.mjs +5 -0
- package/timepicker/src/index.d.ts +2 -0
- package/timepicker/src/mp-time-list.element.d.ts +76 -0
- package/timepicker/src/mp-time-list.element.template.d.ts +2 -0
- package/timepicker/src/mp-timepicker.element.d.ts +87 -0
- package/timepicker/src/mp-timepicker.element.template.d.ts +2 -0
- package/toggle-button/index.mjs +5 -0
- package/toggle-button/src/components/index.d.ts +2 -0
- package/toggle-button/src/components/mp-toggle-button.d.ts +50 -0
- package/toggle-button/src/index.d.ts +3 -0
- package/toggle-button/src/styles/index.d.ts +1 -0
- package/toggle-button/src/styles/toggle-button.styles.d.ts +2 -0
- package/treeview/index.mjs +5 -0
- package/treeview/src/components/index.d.ts +2 -0
- package/treeview/src/components/mp-treeview.d.ts +113 -0
- package/treeview/src/index.d.ts +4 -0
- package/treeview/src/styles/index.d.ts +1 -0
- package/treeview/src/styles/treeview.styles.d.ts +2 -0
- package/treeview/src/types/index.d.ts +1 -0
- package/treeview/src/types/tree-node.d.ts +14 -0
- package/custom-elements.json +0 -1774
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { unsafeCSS as b, LitElement as g, html as s, nothing as l } from "lit";
|
|
2
|
+
import { repeat as _ } from "lit/directives/repeat.js";
|
|
3
|
+
import { unsafeHTML as u } from "lit/directives/unsafe-html.js";
|
|
4
|
+
import { createRef as v, ref as w } from "lit/directives/ref.js";
|
|
5
|
+
import { styleMap as y } from "lit/directives/style-map.js";
|
|
6
|
+
import "../chunks/mp-splitter-C8cGCmac.mjs";
|
|
7
|
+
import "../chunks/mp-treeview-Bfq4_IVW.mjs";
|
|
8
|
+
import "../chunks/mp-datatable-CpAu8JJD.mjs";
|
|
9
|
+
const $ = b(`:host {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
min-height: 24rem;
|
|
15
|
+
--mp-file-manager-border-color: var(--bs-border-color, rgba(0, 0, 0, 0.125));
|
|
16
|
+
--mp-file-manager-pane-bg: var(--bs-body-bg, transparent);
|
|
17
|
+
--mp-file-manager-drop-overlay-bg: rgba(13, 110, 253, 0.08);
|
|
18
|
+
--mp-file-manager-drop-overlay-border: var(--bs-primary, #0d6efd);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
* {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.toolbar {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 0.5rem;
|
|
29
|
+
padding: 0.5rem;
|
|
30
|
+
border-bottom: 1px solid var(--mp-file-manager-border-color);
|
|
31
|
+
flex: 0 0 auto;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.toolbar button {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 0.25rem;
|
|
39
|
+
padding: 0.3rem 0.6rem;
|
|
40
|
+
background-color: transparent;
|
|
41
|
+
border: 1px solid var(--mp-file-manager-border-color);
|
|
42
|
+
border-radius: 0.25rem;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
font: inherit;
|
|
45
|
+
color: inherit;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.toolbar button:hover:not([disabled]) {
|
|
49
|
+
background-color: var(--bs-secondary-bg, rgba(0, 0, 0, 0.04));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.toolbar button[disabled] {
|
|
53
|
+
opacity: 0.5;
|
|
54
|
+
cursor: not-allowed;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.toolbar .view-toggle {
|
|
58
|
+
display: inline-flex;
|
|
59
|
+
border: 1px solid var(--mp-file-manager-border-color);
|
|
60
|
+
border-radius: 0.25rem;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.toolbar .view-toggle button {
|
|
65
|
+
border: 0;
|
|
66
|
+
border-radius: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.toolbar .view-toggle button[data-active=true] {
|
|
70
|
+
background-color: var(--bs-primary, #0d6efd);
|
|
71
|
+
color: #fff;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.toolbar .search-input {
|
|
75
|
+
padding: 0.3rem 0.5rem;
|
|
76
|
+
border: 1px solid var(--mp-file-manager-border-color);
|
|
77
|
+
border-radius: 0.25rem;
|
|
78
|
+
background-color: transparent;
|
|
79
|
+
color: inherit;
|
|
80
|
+
font: inherit;
|
|
81
|
+
flex: 1 1 12rem;
|
|
82
|
+
min-width: 8rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.toolbar .spacer {
|
|
86
|
+
flex: 1 1 auto;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.breadcrumb-bar {
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
gap: 0.25rem;
|
|
93
|
+
padding: 0.4rem 0.75rem;
|
|
94
|
+
border-bottom: 1px solid var(--mp-file-manager-border-color);
|
|
95
|
+
font-size: 0.9rem;
|
|
96
|
+
flex: 0 0 auto;
|
|
97
|
+
flex-wrap: wrap;
|
|
98
|
+
background-color: var(--mp-file-manager-pane-bg);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.breadcrumb-segment {
|
|
102
|
+
background: transparent;
|
|
103
|
+
border: 0;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
color: var(--bs-link-color, var(--bs-primary, #0d6efd));
|
|
106
|
+
padding: 0.15rem 0.4rem;
|
|
107
|
+
font: inherit;
|
|
108
|
+
border-radius: 0.2rem;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.breadcrumb-segment:hover {
|
|
112
|
+
background-color: var(--bs-secondary-bg, rgba(0, 0, 0, 0.04));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.breadcrumb-segment[data-current=true] {
|
|
116
|
+
color: inherit;
|
|
117
|
+
cursor: default;
|
|
118
|
+
font-weight: 500;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.breadcrumb-separator {
|
|
122
|
+
color: var(--bs-secondary-color, #6c757d);
|
|
123
|
+
font-size: 0.85em;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.split-area {
|
|
127
|
+
flex: 1 1 auto;
|
|
128
|
+
min-height: 0;
|
|
129
|
+
display: flex;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
mp-splitter {
|
|
133
|
+
flex: 1 1 auto;
|
|
134
|
+
min-height: 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.tree-pane {
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 100%;
|
|
140
|
+
overflow: auto;
|
|
141
|
+
background-color: var(--mp-file-manager-pane-bg);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.content-pane {
|
|
145
|
+
position: relative;
|
|
146
|
+
width: 100%;
|
|
147
|
+
height: 100%;
|
|
148
|
+
display: flex;
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
background-color: var(--mp-file-manager-pane-bg);
|
|
151
|
+
overflow: hidden;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.content-body {
|
|
155
|
+
flex: 1 1 auto;
|
|
156
|
+
min-height: 0;
|
|
157
|
+
overflow: auto;
|
|
158
|
+
position: relative;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
mp-datatable {
|
|
162
|
+
width: 100%;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.icon-grid {
|
|
166
|
+
display: grid;
|
|
167
|
+
grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
|
|
168
|
+
gap: 0.5rem;
|
|
169
|
+
padding: 0.75rem;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.icon-card {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-direction: column;
|
|
175
|
+
align-items: center;
|
|
176
|
+
justify-content: flex-start;
|
|
177
|
+
padding: 0.6rem 0.4rem;
|
|
178
|
+
border: 1px solid transparent;
|
|
179
|
+
border-radius: 0.4rem;
|
|
180
|
+
cursor: pointer;
|
|
181
|
+
text-align: center;
|
|
182
|
+
background: transparent;
|
|
183
|
+
color: inherit;
|
|
184
|
+
font: inherit;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.icon-card:hover {
|
|
188
|
+
background-color: var(--bs-secondary-bg, rgba(0, 0, 0, 0.04));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.icon-card[data-selected=true] {
|
|
192
|
+
background-color: var(--bs-list-group-active-bg, var(--bs-primary, #0d6efd));
|
|
193
|
+
color: var(--bs-list-group-active-color, #fff);
|
|
194
|
+
border-color: transparent;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.icon-card[data-cut=true] {
|
|
198
|
+
opacity: 0.55;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.icon-card .file-icon {
|
|
202
|
+
width: 3rem;
|
|
203
|
+
height: 3rem;
|
|
204
|
+
display: flex;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
margin-bottom: 0.35rem;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.icon-card .file-icon svg {
|
|
211
|
+
width: 100%;
|
|
212
|
+
height: 100%;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.icon-card .file-name {
|
|
216
|
+
font-size: 0.85rem;
|
|
217
|
+
word-break: break-word;
|
|
218
|
+
display: -webkit-box;
|
|
219
|
+
-webkit-line-clamp: 2;
|
|
220
|
+
-webkit-box-orient: vertical;
|
|
221
|
+
overflow: hidden;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.row-cell {
|
|
225
|
+
display: inline-flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
gap: 0.4rem;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.row-cell .row-icon {
|
|
231
|
+
flex: 0 0 1rem;
|
|
232
|
+
width: 1rem;
|
|
233
|
+
height: 1rem;
|
|
234
|
+
display: inline-flex;
|
|
235
|
+
align-items: center;
|
|
236
|
+
justify-content: center;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.row-cell .row-icon svg {
|
|
240
|
+
width: 1rem;
|
|
241
|
+
height: 1rem;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.rename-input {
|
|
245
|
+
width: 100%;
|
|
246
|
+
font: inherit;
|
|
247
|
+
color: inherit;
|
|
248
|
+
background-color: var(--bs-body-bg, #fff);
|
|
249
|
+
border: 1px solid var(--bs-primary, #0d6efd);
|
|
250
|
+
padding: 0.1rem 0.3rem;
|
|
251
|
+
border-radius: 0.2rem;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.drop-overlay {
|
|
255
|
+
position: absolute;
|
|
256
|
+
inset: 0;
|
|
257
|
+
display: none;
|
|
258
|
+
align-items: center;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
background-color: var(--mp-file-manager-drop-overlay-bg);
|
|
261
|
+
border: 2px dashed var(--mp-file-manager-drop-overlay-border);
|
|
262
|
+
border-radius: 0.4rem;
|
|
263
|
+
pointer-events: none;
|
|
264
|
+
z-index: 5;
|
|
265
|
+
font-weight: 500;
|
|
266
|
+
font-size: 1.1rem;
|
|
267
|
+
color: var(--mp-file-manager-drop-overlay-border);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
:host([drop-active]) .drop-overlay {
|
|
271
|
+
display: flex;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.context-menu {
|
|
275
|
+
position: fixed;
|
|
276
|
+
z-index: 1080;
|
|
277
|
+
min-width: 9rem;
|
|
278
|
+
background-color: var(--bs-body-bg, #fff);
|
|
279
|
+
border: 1px solid var(--mp-file-manager-border-color);
|
|
280
|
+
border-radius: 0.3rem;
|
|
281
|
+
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
|
|
282
|
+
padding: 0.25rem 0;
|
|
283
|
+
margin: 0;
|
|
284
|
+
list-style: none;
|
|
285
|
+
font-size: 0.9rem;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.context-menu .menu-item {
|
|
289
|
+
display: flex;
|
|
290
|
+
width: 100%;
|
|
291
|
+
align-items: center;
|
|
292
|
+
gap: 0.4rem;
|
|
293
|
+
padding: 0.35rem 0.9rem;
|
|
294
|
+
background: transparent;
|
|
295
|
+
border: 0;
|
|
296
|
+
color: inherit;
|
|
297
|
+
font: inherit;
|
|
298
|
+
text-align: left;
|
|
299
|
+
cursor: pointer;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.context-menu .menu-item:hover:not([disabled]),
|
|
303
|
+
.context-menu .menu-item:focus-visible:not([disabled]) {
|
|
304
|
+
background-color: var(--bs-secondary-bg, rgba(0, 0, 0, 0.06));
|
|
305
|
+
outline: none;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.context-menu .menu-item[disabled] {
|
|
309
|
+
opacity: 0.5;
|
|
310
|
+
cursor: not-allowed;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.context-menu .menu-separator {
|
|
314
|
+
height: 1px;
|
|
315
|
+
background-color: var(--mp-file-manager-border-color);
|
|
316
|
+
margin: 0.25rem 0;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@media (prefers-reduced-motion: reduce) {
|
|
320
|
+
.icon-card,
|
|
321
|
+
.toolbar button {
|
|
322
|
+
transition: none !important;
|
|
323
|
+
}
|
|
324
|
+
}`), p = {
|
|
325
|
+
home: "Home",
|
|
326
|
+
newFolder: "New folder",
|
|
327
|
+
rename: "Rename",
|
|
328
|
+
delete: "Delete",
|
|
329
|
+
cut: "Cut",
|
|
330
|
+
copy: "Copy",
|
|
331
|
+
paste: "Paste",
|
|
332
|
+
upload: "Upload",
|
|
333
|
+
searchPlaceholder: "Search…",
|
|
334
|
+
listView: "List view",
|
|
335
|
+
iconsView: "Icons view",
|
|
336
|
+
name: "Name",
|
|
337
|
+
size: "Size",
|
|
338
|
+
modified: "Modified",
|
|
339
|
+
type: "Type",
|
|
340
|
+
folder: "Folder",
|
|
341
|
+
file: "File",
|
|
342
|
+
loading: "Loading…",
|
|
343
|
+
noFilesOrFolders: "No files or folders",
|
|
344
|
+
dropFilesToUpload: "↓ Drop files to upload ↓",
|
|
345
|
+
fileDropZone: "File drop zone",
|
|
346
|
+
deleteConfirm: (h) => `Delete ${h} item${h === 1 ? "" : "s"}?`,
|
|
347
|
+
folderNamePrompt: "Folder name",
|
|
348
|
+
defaultNewFolderName: "New folder",
|
|
349
|
+
conflictMessage: (h) => `"${h}" already exists. Replace?`,
|
|
350
|
+
conflictReplace: "Replace",
|
|
351
|
+
conflictSkip: "Skip",
|
|
352
|
+
conflictRename: "Keep both",
|
|
353
|
+
ariaToolbar: "File manager toolbar",
|
|
354
|
+
ariaBreadcrumb: "Breadcrumb",
|
|
355
|
+
ariaFileList: "Files and folders",
|
|
356
|
+
ariaFileManager: "File manager"
|
|
357
|
+
};
|
|
358
|
+
function x(h) {
|
|
359
|
+
return h ? { ...p, ...h } : p;
|
|
360
|
+
}
|
|
361
|
+
let C = 0;
|
|
362
|
+
const m = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M.54 3.87.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181L15.546 8H2.454l-.913-3.13a.5.5 0 0 1 .013-.087.5.5 0 0 1-.014-.913zM13.81 4H2.19l-.572 6 1.193 4 11.078-2.5L15.81 5.66A1 1 0 0 0 14.81 4z"/></svg>', k = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5L14 4.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h-2z"/></svg>', E = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"/></svg>', T = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M1 2.5A1.5 1.5 0 0 1 2.5 1h3A1.5 1.5 0 0 1 7 2.5v3A1.5 1.5 0 0 1 5.5 7h-3A1.5 1.5 0 0 1 1 5.5v-3zm8 0A1.5 1.5 0 0 1 10.5 1h3A1.5 1.5 0 0 1 15 2.5v3A1.5 1.5 0 0 1 13.5 7h-3A1.5 1.5 0 0 1 9 5.5v-3zm-8 8A1.5 1.5 0 0 1 2.5 9h3A1.5 1.5 0 0 1 7 10.5v3A1.5 1.5 0 0 1 5.5 15h-3A1.5 1.5 0 0 1 1 13.5v-3zm8 0A1.5 1.5 0 0 1 10.5 9h3a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1-1.5 1.5h-3A1.5 1.5 0 0 1 9 13.5v-3z"/></svg>';
|
|
363
|
+
class F extends g {
|
|
364
|
+
constructor() {
|
|
365
|
+
super(...arguments), this.instanceId = `mp-file-manager-${++C}`, this._nodes = [], this._rootFolderId = null, this._currentFolderId = null, this._allowUpload = !1, this._allowOperations = !0, this._viewMode = "list", this._selectionMode = "multiple", this._searchPlaceholder = "", this._messages = p, this._selection = /* @__PURE__ */ new Set(), this._expandedTreeIds = /* @__PURE__ */ new Set(), this._clipboard = null, this._searchQuery = "", this._renameTarget = null, this._renameInputRef = v(), this._dragDepth = 0, this._contextMenu = null, this._isTouchMode = !1, this._touchHoldTimer = null, this._touchHoldTarget = null, this._pendingOps = /* @__PURE__ */ new Map(), this._uploads = [], this._loadedFolders = /* @__PURE__ */ new Set(), this.onTouchStart = (e) => {
|
|
366
|
+
if (e.touches.length !== 1) return;
|
|
367
|
+
const t = e.touches[0], o = (e.composedPath().find(
|
|
368
|
+
(a) => a instanceof HTMLElement && a.hasAttribute("data-node-id")
|
|
369
|
+
) ?? this.shadowRoot?.elementFromPoint(t.clientX, t.clientY)?.closest("[data-node-id]"))?.getAttribute("data-node-id");
|
|
370
|
+
if (!o) return;
|
|
371
|
+
this._touchHoldTarget = o;
|
|
372
|
+
const r = t.clientX, n = t.clientY;
|
|
373
|
+
this._touchHoldTimer = setTimeout(() => {
|
|
374
|
+
this._touchHoldTarget === o && (this._touchHoldTimer = null, this._selectionMode !== "none" && !this._selection.has(o) && (this._selection = /* @__PURE__ */ new Set([o]), this.emitSelectionChange()), this.openContextMenu(o, r, n));
|
|
375
|
+
}, 600);
|
|
376
|
+
}, this.onTouchMove = () => {
|
|
377
|
+
this._touchHoldTimer && (clearTimeout(this._touchHoldTimer), this._touchHoldTimer = null), this._touchHoldTarget = null;
|
|
378
|
+
}, this.onTouchEnd = () => {
|
|
379
|
+
this._touchHoldTimer && (clearTimeout(this._touchHoldTimer), this._touchHoldTimer = null), this._touchHoldTarget = null;
|
|
380
|
+
}, this.openUploadPicker = () => {
|
|
381
|
+
if (!this._allowUpload) return;
|
|
382
|
+
const e = document.createElement("input");
|
|
383
|
+
e.type = "file", e.multiple = !0, e.style.display = "none", e.addEventListener("change", () => {
|
|
384
|
+
const t = Array.from(e.files ?? []);
|
|
385
|
+
t.length > 0 && this.handleFiles(t), e.remove();
|
|
386
|
+
}), document.body.appendChild(e), e.click();
|
|
387
|
+
}, this.onTreeNodeSelect = (e) => {
|
|
388
|
+
const t = e.detail;
|
|
389
|
+
this.navigateTo(t.node.id);
|
|
390
|
+
}, this.onTreeNodeExpand = (e) => {
|
|
391
|
+
const t = e.detail;
|
|
392
|
+
this._expandedTreeIds = new Set(t.expandedIds);
|
|
393
|
+
}, this.onTreeNodeCollapse = (e) => {
|
|
394
|
+
const t = e.detail;
|
|
395
|
+
this._expandedTreeIds = new Set(t.expandedIds);
|
|
396
|
+
}, this.onDatatableSelection = (e) => {
|
|
397
|
+
const t = e.detail;
|
|
398
|
+
this._selection = new Set(t.selectedIds), this.emitSelectionChange(), this.requestUpdate();
|
|
399
|
+
}, this.onRowClick = (e) => {
|
|
400
|
+
e.detail, this.emitSelectionChange();
|
|
401
|
+
}, this.onRowDblClick = (e) => {
|
|
402
|
+
const t = e.detail;
|
|
403
|
+
this.activateNode(t.row);
|
|
404
|
+
}, this.onRowContextMenu = (e) => {
|
|
405
|
+
const t = e.detail, i = t.originalEvent;
|
|
406
|
+
i.preventDefault(), this.openContextMenu(t.rowKey, i.clientX, i.clientY);
|
|
407
|
+
}, this.onContentKeydown = (e) => {
|
|
408
|
+
if ((e.key === "ContextMenu" || e.key === "F10" && e.shiftKey) && this._selection.size > 0) {
|
|
409
|
+
e.preventDefault();
|
|
410
|
+
const i = e.target?.getBoundingClientRect(), o = i ? i.left + i.width / 2 : 100, r = i ? i.bottom : 100, [n] = this._selection;
|
|
411
|
+
this.openContextMenu(n, o, r);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (e.key === "Delete" && this._selection.size > 0 && this.opEnabled("delete")) {
|
|
415
|
+
e.preventDefault(), this.deleteSelection();
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (e.key === "F2" && this._selection.size === 1 && this.opEnabled("rename")) {
|
|
419
|
+
e.preventDefault(), this.beginRenameFromToolbar();
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if ((e.ctrlKey || e.metaKey) && e.key === "x" && this._selection.size > 0 && this.opEnabled("cut")) {
|
|
423
|
+
e.preventDefault(), this.setClipboard("cut");
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if ((e.ctrlKey || e.metaKey) && e.key === "c" && this._selection.size > 0 && this.opEnabled("copy")) {
|
|
427
|
+
e.preventDefault(), this.setClipboard("copy");
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if ((e.ctrlKey || e.metaKey) && e.key === "v" && this._clipboard && this.opEnabled("paste")) {
|
|
431
|
+
e.preventDefault(), this.paste();
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if ((e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "N" || e.key === "n") && this.opEnabled("newFolder")) {
|
|
435
|
+
e.preventDefault(), this.promptNewFolder();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
}, this.promptNewFolder = async () => {
|
|
439
|
+
if (!this.opEnabled("newFolder")) return;
|
|
440
|
+
const e = this._messages, t = await this.invokeDialog({
|
|
441
|
+
kind: "prompt",
|
|
442
|
+
label: e.folderNamePrompt,
|
|
443
|
+
defaultValue: e.defaultNewFolderName
|
|
444
|
+
});
|
|
445
|
+
typeof t != "string" || !t.trim() || this.dispatchEvent(
|
|
446
|
+
new CustomEvent("mp-operation", {
|
|
447
|
+
detail: { kind: "new-folder", parentId: this._currentFolderId, name: t.trim() },
|
|
448
|
+
bubbles: !0,
|
|
449
|
+
composed: !0
|
|
450
|
+
})
|
|
451
|
+
);
|
|
452
|
+
}, this.beginRenameFromToolbar = () => {
|
|
453
|
+
if (this._selection.size !== 1) return;
|
|
454
|
+
const [e] = this._selection;
|
|
455
|
+
this._renameTarget = e, this.requestUpdate(), this.updateComplete.then(() => {
|
|
456
|
+
const t = this._renameInputRef.value;
|
|
457
|
+
t && (t.focus(), t.select());
|
|
458
|
+
});
|
|
459
|
+
}, this.deleteSelection = async () => {
|
|
460
|
+
if (this._selection.size === 0 || !this.opEnabledOnSelection("delete") || !await this.invokeDialog({
|
|
461
|
+
kind: "confirm",
|
|
462
|
+
message: this._messages.deleteConfirm(this._selection.size)
|
|
463
|
+
})) return;
|
|
464
|
+
const t = [...this._selection];
|
|
465
|
+
this._selection.clear(), this.requestUpdate(), this.dispatchEvent(
|
|
466
|
+
new CustomEvent("mp-operation", {
|
|
467
|
+
detail: { kind: "delete", nodeIds: t },
|
|
468
|
+
bubbles: !0,
|
|
469
|
+
composed: !0
|
|
470
|
+
})
|
|
471
|
+
);
|
|
472
|
+
}, this.paste = async () => {
|
|
473
|
+
if (!this._clipboard || !this.opEnabled("paste")) return;
|
|
474
|
+
const { mode: e, ids: t } = this._clipboard, i = await this.resolveConflictsForPaste(t, this._currentFolderId);
|
|
475
|
+
i !== null && (this.dispatchEvent(
|
|
476
|
+
new CustomEvent("mp-operation", {
|
|
477
|
+
detail: {
|
|
478
|
+
kind: "paste",
|
|
479
|
+
mode: e,
|
|
480
|
+
sourceIds: t,
|
|
481
|
+
targetFolderId: this._currentFolderId,
|
|
482
|
+
conflicts: i
|
|
483
|
+
},
|
|
484
|
+
bubbles: !0,
|
|
485
|
+
composed: !0
|
|
486
|
+
})
|
|
487
|
+
), e === "cut" && (this._clipboard = null), this.requestUpdate());
|
|
488
|
+
}, this.onDragEnter = (e) => {
|
|
489
|
+
this._allowUpload && (!e.dataTransfer || !e.dataTransfer.types.includes("Files") || (e.preventDefault(), this._dragDepth++, this._dragDepth === 1 && this.setAttribute("drop-active", "")));
|
|
490
|
+
}, this.onDragOver = (e) => {
|
|
491
|
+
this._allowUpload && (!e.dataTransfer || !e.dataTransfer.types.includes("Files") || (e.preventDefault(), e.dataTransfer.dropEffect = "copy"));
|
|
492
|
+
}, this.onDragLeave = (e) => {
|
|
493
|
+
this._allowUpload && (this._dragDepth = Math.max(0, this._dragDepth - 1), this._dragDepth === 0 && this.removeAttribute("drop-active"));
|
|
494
|
+
}, this.onDrop = (e) => {
|
|
495
|
+
if (!this._allowUpload || !e.dataTransfer || (e.preventDefault(), this._dragDepth = 0, this.removeAttribute("drop-active"), this._isTouchMode)) return;
|
|
496
|
+
const t = Array.from(e.dataTransfer.files ?? []);
|
|
497
|
+
t.length !== 0 && this.handleFiles(t);
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
static {
|
|
501
|
+
this.styles = [$];
|
|
502
|
+
}
|
|
503
|
+
static get observedAttributes() {
|
|
504
|
+
return [
|
|
505
|
+
...super.observedAttributes ?? [],
|
|
506
|
+
"root-folder-id",
|
|
507
|
+
"current-folder-id",
|
|
508
|
+
"allow-upload",
|
|
509
|
+
"view-mode",
|
|
510
|
+
"selection-mode",
|
|
511
|
+
"search-placeholder"
|
|
512
|
+
];
|
|
513
|
+
}
|
|
514
|
+
// ─── Property accessors ──────────────────────────────────────────────────
|
|
515
|
+
get nodes() {
|
|
516
|
+
return this._nodes;
|
|
517
|
+
}
|
|
518
|
+
set nodes(e) {
|
|
519
|
+
this._nodes = Array.isArray(e) ? e : [], this.pruneSelection(), this.requestUpdate();
|
|
520
|
+
}
|
|
521
|
+
get rootFolderId() {
|
|
522
|
+
return this._rootFolderId;
|
|
523
|
+
}
|
|
524
|
+
set rootFolderId(e) {
|
|
525
|
+
this._rootFolderId = e ?? null, this.requestUpdate();
|
|
526
|
+
}
|
|
527
|
+
get currentFolderId() {
|
|
528
|
+
return this._currentFolderId;
|
|
529
|
+
}
|
|
530
|
+
set currentFolderId(e) {
|
|
531
|
+
this._currentFolderId !== e && (this._currentFolderId = e ?? null, this._selection.clear(), this.requestUpdate());
|
|
532
|
+
}
|
|
533
|
+
get allowUpload() {
|
|
534
|
+
return this._allowUpload;
|
|
535
|
+
}
|
|
536
|
+
set allowUpload(e) {
|
|
537
|
+
this._allowUpload = !!e, this.requestUpdate();
|
|
538
|
+
}
|
|
539
|
+
get allowOperations() {
|
|
540
|
+
return this._allowOperations;
|
|
541
|
+
}
|
|
542
|
+
set allowOperations(e) {
|
|
543
|
+
this._allowOperations = e, this.requestUpdate();
|
|
544
|
+
}
|
|
545
|
+
get viewMode() {
|
|
546
|
+
return this._viewMode;
|
|
547
|
+
}
|
|
548
|
+
set viewMode(e) {
|
|
549
|
+
(e === "list" || e === "icons") && (this._viewMode = e, this.requestUpdate());
|
|
550
|
+
}
|
|
551
|
+
get selectionMode() {
|
|
552
|
+
return this._selectionMode;
|
|
553
|
+
}
|
|
554
|
+
set selectionMode(e) {
|
|
555
|
+
this._selectionMode = e, e === "none" && this._selection.clear(), this.requestUpdate();
|
|
556
|
+
}
|
|
557
|
+
get searchPlaceholder() {
|
|
558
|
+
return this._searchPlaceholder;
|
|
559
|
+
}
|
|
560
|
+
set searchPlaceholder(e) {
|
|
561
|
+
this._searchPlaceholder = e || "Search…", this.requestUpdate();
|
|
562
|
+
}
|
|
563
|
+
get iconResolver() {
|
|
564
|
+
return this._iconResolver;
|
|
565
|
+
}
|
|
566
|
+
set iconResolver(e) {
|
|
567
|
+
this._iconResolver = e, this.requestUpdate();
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Partial override of the visible-string set. Unset keys fall back to the
|
|
571
|
+
* English defaults in `DEFAULT_FILE_MANAGER_MESSAGES`.
|
|
572
|
+
*/
|
|
573
|
+
get messages() {
|
|
574
|
+
return this._messages;
|
|
575
|
+
}
|
|
576
|
+
set messages(e) {
|
|
577
|
+
this._messages = x(e), this.hasAttribute("aria-label") && this.setAttribute("aria-label", this._messages.ariaFileManager), this.requestUpdate();
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Replacement for `window.confirm` / `window.prompt`. When unset, falls
|
|
581
|
+
* back to the browser dialogs.
|
|
582
|
+
*/
|
|
583
|
+
get dialogResolver() {
|
|
584
|
+
return this._dialogResolver;
|
|
585
|
+
}
|
|
586
|
+
set dialogResolver(e) {
|
|
587
|
+
this._dialogResolver = e;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Invoked when paste / upload would overwrite an existing entry. When
|
|
591
|
+
* unset, the WC silently replaces (v1 behaviour).
|
|
592
|
+
*/
|
|
593
|
+
get conflictResolver() {
|
|
594
|
+
return this._conflictResolver;
|
|
595
|
+
}
|
|
596
|
+
set conflictResolver(e) {
|
|
597
|
+
this._conflictResolver = e;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Async loader invoked when a folder is expanded in the tree for the
|
|
601
|
+
* first time. Resolve with the folder's children; the consumer should
|
|
602
|
+
* merge them into the global `nodes` array. The WC also surfaces a
|
|
603
|
+
* loading indicator via `node.meta.loading = true` while the promise
|
|
604
|
+
* is in flight.
|
|
605
|
+
*/
|
|
606
|
+
get loadChildren() {
|
|
607
|
+
return this._loadChildren;
|
|
608
|
+
}
|
|
609
|
+
set loadChildren(e) {
|
|
610
|
+
this._loadChildren = e;
|
|
611
|
+
}
|
|
612
|
+
/** In-flight uploads, exposed for read-only consumption by progress UIs. */
|
|
613
|
+
get uploads() {
|
|
614
|
+
return this._uploads;
|
|
615
|
+
}
|
|
616
|
+
/** IDs of nodes currently being mutated server-side (set via `markPending`). */
|
|
617
|
+
get pendingOpIds() {
|
|
618
|
+
return new Set(this._pendingOps.keys());
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Mark a node as having an operation in flight. The row renders with a
|
|
622
|
+
* busy state and the consumer should call `clearPending()` when done.
|
|
623
|
+
*/
|
|
624
|
+
markPending(e, t) {
|
|
625
|
+
this._pendingOps.set(e, t), this.requestUpdate();
|
|
626
|
+
}
|
|
627
|
+
/** Clear the pending state on a node. */
|
|
628
|
+
clearPending(e) {
|
|
629
|
+
this._pendingOps.delete(e) && this.requestUpdate();
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Surface an error message to the consumer. The component also re-fires
|
|
633
|
+
* an `(error)` event with the same payload so toast systems can listen.
|
|
634
|
+
*/
|
|
635
|
+
reportError(e, t) {
|
|
636
|
+
this.dispatchEvent(
|
|
637
|
+
new CustomEvent("mp-error", {
|
|
638
|
+
detail: { kind: "operation", message: e, nodeId: t },
|
|
639
|
+
bubbles: !0,
|
|
640
|
+
composed: !0
|
|
641
|
+
})
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Push a progress update for an upload. The consumer calls this from
|
|
646
|
+
* their upload-pipeline progress callback so the WC can render a
|
|
647
|
+
* progress bar / completed state.
|
|
648
|
+
*/
|
|
649
|
+
reportUploadProgress(e, t, i, o) {
|
|
650
|
+
const r = this._uploads.findIndex((a) => a.id === e);
|
|
651
|
+
if (r < 0) return;
|
|
652
|
+
const n = { ...this._uploads[r], progress: t, ...i ? { status: i } : {}, ...o ? { error: o } : {} };
|
|
653
|
+
this._uploads = [...this._uploads.slice(0, r), n, ...this._uploads.slice(r + 1)], this.requestUpdate();
|
|
654
|
+
}
|
|
655
|
+
/** Remove a finished/aborted upload from the tracking list. */
|
|
656
|
+
clearUpload(e) {
|
|
657
|
+
const t = this._uploads.length;
|
|
658
|
+
this._uploads = this._uploads.filter((i) => i.id !== e), this._uploads.length !== t && this.requestUpdate();
|
|
659
|
+
}
|
|
660
|
+
attributeChangedCallback(e, t, i) {
|
|
661
|
+
switch (super.attributeChangedCallback(e, t, i), e) {
|
|
662
|
+
case "root-folder-id":
|
|
663
|
+
this._rootFolderId = i, this.requestUpdate();
|
|
664
|
+
break;
|
|
665
|
+
case "current-folder-id":
|
|
666
|
+
this._currentFolderId = i, this.requestUpdate();
|
|
667
|
+
break;
|
|
668
|
+
case "allow-upload":
|
|
669
|
+
this._allowUpload = i !== null, this.requestUpdate();
|
|
670
|
+
break;
|
|
671
|
+
case "view-mode":
|
|
672
|
+
(i === "list" || i === "icons") && (this._viewMode = i, this.requestUpdate());
|
|
673
|
+
break;
|
|
674
|
+
case "selection-mode":
|
|
675
|
+
(i === "none" || i === "single" || i === "multiple") && (this._selectionMode = i, i === "none" && this._selection.clear(), this.requestUpdate());
|
|
676
|
+
break;
|
|
677
|
+
case "search-placeholder":
|
|
678
|
+
this._searchPlaceholder = i ?? "Search…", this.requestUpdate();
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
connectedCallback() {
|
|
683
|
+
if (super.connectedCallback(), this.hasAttribute("role") || this.setAttribute("role", "region"), this.hasAttribute("aria-label") || this.setAttribute("aria-label", this._messages.ariaFileManager), typeof window < "u" && typeof window.matchMedia == "function")
|
|
684
|
+
try {
|
|
685
|
+
this._isTouchMode = window.matchMedia("(pointer: coarse)").matches;
|
|
686
|
+
} catch {
|
|
687
|
+
this._isTouchMode = !1;
|
|
688
|
+
}
|
|
689
|
+
this.addEventListener("touchstart", this.onTouchStart, { passive: !1 }), this.addEventListener("touchend", this.onTouchEnd), this.addEventListener("touchcancel", this.onTouchEnd), this.addEventListener("touchmove", this.onTouchMove);
|
|
690
|
+
}
|
|
691
|
+
disconnectedCallback() {
|
|
692
|
+
super.disconnectedCallback(), this.removeEventListener("touchstart", this.onTouchStart), this.removeEventListener("touchend", this.onTouchEnd), this.removeEventListener("touchcancel", this.onTouchEnd), this.removeEventListener("touchmove", this.onTouchMove), this._touchHoldTimer && (clearTimeout(this._touchHoldTimer), this._touchHoldTimer = null);
|
|
693
|
+
}
|
|
694
|
+
// ─── Operation flags helper ─────────────────────────────────────────────
|
|
695
|
+
/**
|
|
696
|
+
* Resolve whether `op` is allowed. When `nodeId` is provided, per-node
|
|
697
|
+
* overrides on `FileSystemNode.allowOperations` take precedence over the
|
|
698
|
+
* global flag. When `nodeId` is omitted (toolbar-level decisions like
|
|
699
|
+
* "new folder"), only the global flag applies.
|
|
700
|
+
*/
|
|
701
|
+
opEnabled(e, t) {
|
|
702
|
+
if (this._allowOperations === !1) return !1;
|
|
703
|
+
const i = this._allowOperations === !0 ? !0 : this._allowOperations[e] !== !1;
|
|
704
|
+
if (!t) return i;
|
|
705
|
+
const r = this._nodes.find((n) => n.id === t)?.allowOperations?.[e];
|
|
706
|
+
return r === void 0 ? i : r !== !1;
|
|
707
|
+
}
|
|
708
|
+
/** True iff EVERY selected node permits the given operation. */
|
|
709
|
+
opEnabledOnSelection(e) {
|
|
710
|
+
if (!this.opEnabled(e)) return !1;
|
|
711
|
+
for (const t of this._selection)
|
|
712
|
+
if (!this.opEnabled(e, t)) return !1;
|
|
713
|
+
return !0;
|
|
714
|
+
}
|
|
715
|
+
// ─── Derived collections ─────────────────────────────────────────────────
|
|
716
|
+
getTreeItems() {
|
|
717
|
+
const e = this._nodes.filter((n) => n.type === "folder"), t = /* @__PURE__ */ new Map();
|
|
718
|
+
for (const n of e) {
|
|
719
|
+
const a = t.get(n.parentId) ?? [];
|
|
720
|
+
a.push(n), t.set(n.parentId, a);
|
|
721
|
+
}
|
|
722
|
+
const i = !!this._loadChildren, o = (n) => {
|
|
723
|
+
const a = t.get(n);
|
|
724
|
+
return a ? a.map((d) => {
|
|
725
|
+
const c = o(d.id), f = i && c.length === 0 && !this._loadedFolders.has(d.id);
|
|
726
|
+
return {
|
|
727
|
+
id: d.id,
|
|
728
|
+
label: d.name,
|
|
729
|
+
iconKey: d.iconKey ?? "folder",
|
|
730
|
+
children: c,
|
|
731
|
+
lazy: f || void 0
|
|
732
|
+
};
|
|
733
|
+
}) : [];
|
|
734
|
+
}, r = this._rootFolderId;
|
|
735
|
+
return o(r === null ? null : r);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Bridge `mp-treeview`'s `loadChildren` to the consumer's `loadChildren`
|
|
739
|
+
* callback. Appends new nodes into the WC's local `_nodes` so the tree
|
|
740
|
+
* (and current-folder file list) re-render, then returns the loaded
|
|
741
|
+
* folder children to the treeview's lazy machinery for its own bookkeeping.
|
|
742
|
+
*/
|
|
743
|
+
async loadTreeChildren(e) {
|
|
744
|
+
if (!this._loadChildren) return [];
|
|
745
|
+
const t = await this._loadChildren(e), i = new Set(this._nodes.map((r) => r.id)), o = t.filter((r) => !i.has(r.id));
|
|
746
|
+
return this._nodes = [...this._nodes, ...o], this._loadedFolders.add(e), this.requestUpdate(), this.dispatchEvent(
|
|
747
|
+
new CustomEvent("mp-children-loaded", {
|
|
748
|
+
detail: { parentId: e, children: t },
|
|
749
|
+
bubbles: !0,
|
|
750
|
+
composed: !0
|
|
751
|
+
})
|
|
752
|
+
), o.filter((r) => r.type === "folder").map((r) => ({
|
|
753
|
+
id: r.id,
|
|
754
|
+
label: r.name,
|
|
755
|
+
iconKey: r.iconKey ?? "folder",
|
|
756
|
+
children: [],
|
|
757
|
+
lazy: !0
|
|
758
|
+
}));
|
|
759
|
+
}
|
|
760
|
+
getCurrentChildren() {
|
|
761
|
+
const e = this._currentFolderId, t = this._nodes.filter((r) => r.parentId === e), i = this._searchQuery.trim().toLowerCase();
|
|
762
|
+
return (i ? t.filter((r) => r.name.toLowerCase().includes(i)) : t).slice().sort((r, n) => r.type !== n.type ? r.type === "folder" ? -1 : 1 : r.name.localeCompare(n.name));
|
|
763
|
+
}
|
|
764
|
+
getBreadcrumb() {
|
|
765
|
+
if (this._currentFolderId === null) return [];
|
|
766
|
+
const e = [];
|
|
767
|
+
let t = this._currentFolderId;
|
|
768
|
+
for (; t !== null; ) {
|
|
769
|
+
const i = this._nodes.find((o) => o.id === t);
|
|
770
|
+
if (!i) break;
|
|
771
|
+
e.unshift(i), t = i.parentId;
|
|
772
|
+
}
|
|
773
|
+
return e;
|
|
774
|
+
}
|
|
775
|
+
// ─── Render ──────────────────────────────────────────────────────────────
|
|
776
|
+
render() {
|
|
777
|
+
const e = this.getTreeItems(), t = this.getCurrentChildren(), i = this.getBreadcrumb();
|
|
778
|
+
return s`
|
|
779
|
+
${this.renderToolbar()}
|
|
780
|
+
${this.renderBreadcrumb(i)}
|
|
781
|
+
<div class="split-area">
|
|
782
|
+
<mp-splitter orientation="horizontal" min-panel-size="120">
|
|
783
|
+
<div class="tree-pane">
|
|
784
|
+
<mp-treeview
|
|
785
|
+
.items=${e}
|
|
786
|
+
.expandedIds=${[...this._expandedTreeIds]}
|
|
787
|
+
.selectedIds=${this._currentFolderId ? [this._currentFolderId] : []}
|
|
788
|
+
.iconResolver=${(o, r) => this.resolveIconForTree(o, r)}
|
|
789
|
+
.loadChildren=${this._loadChildren ? (o) => this.loadTreeChildren(o) : void 0}
|
|
790
|
+
hide-borders
|
|
791
|
+
selection-mode="single"
|
|
792
|
+
@tree-node-select=${this.onTreeNodeSelect}
|
|
793
|
+
@tree-node-expand=${this.onTreeNodeExpand}
|
|
794
|
+
@tree-node-collapse=${this.onTreeNodeCollapse}
|
|
795
|
+
></mp-treeview>
|
|
796
|
+
</div>
|
|
797
|
+
<div
|
|
798
|
+
class="content-pane"
|
|
799
|
+
@dragenter=${this.onDragEnter}
|
|
800
|
+
@dragover=${this.onDragOver}
|
|
801
|
+
@dragleave=${this.onDragLeave}
|
|
802
|
+
@drop=${this.onDrop}
|
|
803
|
+
>
|
|
804
|
+
<div class="content-body">
|
|
805
|
+
${this._viewMode === "list" ? this.renderListView(t) : this.renderIconGridView(t)}
|
|
806
|
+
</div>
|
|
807
|
+
<div class="drop-overlay" aria-live="polite" aria-label=${this._messages.fileDropZone}>${this._messages.dropFilesToUpload}</div>
|
|
808
|
+
</div>
|
|
809
|
+
</mp-splitter>
|
|
810
|
+
</div>
|
|
811
|
+
${this.renderContextMenu()}
|
|
812
|
+
`;
|
|
813
|
+
}
|
|
814
|
+
renderContextMenu() {
|
|
815
|
+
const e = this._contextMenu;
|
|
816
|
+
if (!e) return s``;
|
|
817
|
+
const t = this._messages, i = this._selection.size > 0, o = this._clipboard !== null;
|
|
818
|
+
return s`
|
|
819
|
+
<ul
|
|
820
|
+
class="context-menu"
|
|
821
|
+
role="menu"
|
|
822
|
+
aria-label="File operations"
|
|
823
|
+
style=${y({ left: `${e.x}px`, top: `${e.y}px` })}
|
|
824
|
+
@click=${(r) => r.stopPropagation()}
|
|
825
|
+
>
|
|
826
|
+
${this.opEnabled("rename") ? s`<li role="none"><button class="menu-item" role="menuitem" ?disabled=${this._selection.size !== 1 || !this.opEnabledOnSelection("rename")} @click=${() => {
|
|
827
|
+
this.closeContextMenu(), this.beginRenameFromToolbar();
|
|
828
|
+
}}>${t.rename}</button></li>` : l}
|
|
829
|
+
${this.opEnabled("delete") ? s`<li role="none"><button class="menu-item" role="menuitem" ?disabled=${!i || !this.opEnabledOnSelection("delete")} @click=${() => {
|
|
830
|
+
this.closeContextMenu(), this.deleteSelection();
|
|
831
|
+
}}>${t.delete}</button></li>` : l}
|
|
832
|
+
<li role="separator" class="menu-separator"></li>
|
|
833
|
+
${this.opEnabled("cut") ? s`<li role="none"><button class="menu-item" role="menuitem" ?disabled=${!i || !this.opEnabledOnSelection("cut")} @click=${() => {
|
|
834
|
+
this.closeContextMenu(), this.setClipboard("cut");
|
|
835
|
+
}}>${t.cut}</button></li>` : l}
|
|
836
|
+
${this.opEnabled("copy") ? s`<li role="none"><button class="menu-item" role="menuitem" ?disabled=${!i || !this.opEnabledOnSelection("copy")} @click=${() => {
|
|
837
|
+
this.closeContextMenu(), this.setClipboard("copy");
|
|
838
|
+
}}>${t.copy}</button></li>` : l}
|
|
839
|
+
${this.opEnabled("paste") ? s`<li role="none"><button class="menu-item" role="menuitem" ?disabled=${!o} @click=${() => {
|
|
840
|
+
this.closeContextMenu(), this.paste();
|
|
841
|
+
}}>${t.paste}</button></li>` : l}
|
|
842
|
+
<li role="separator" class="menu-separator"></li>
|
|
843
|
+
${this.opEnabled("newFolder") ? s`<li role="none"><button class="menu-item" role="menuitem" @click=${() => {
|
|
844
|
+
this.closeContextMenu(), this.promptNewFolder();
|
|
845
|
+
}}>${t.newFolder}</button></li>` : l}
|
|
846
|
+
</ul>
|
|
847
|
+
`;
|
|
848
|
+
}
|
|
849
|
+
openContextMenu(e, t, i) {
|
|
850
|
+
this._allowOperations !== !1 && (this._contextMenu = { x: t, y: i, targetId: e }, this.requestUpdate(), this.updateComplete.then(() => {
|
|
851
|
+
const o = (r) => {
|
|
852
|
+
r instanceof KeyboardEvent && r.key !== "Escape" || (this.closeContextMenu(), document.removeEventListener("click", o, !0), document.removeEventListener("contextmenu", o, !0), document.removeEventListener("keydown", o, !0));
|
|
853
|
+
};
|
|
854
|
+
document.addEventListener("click", o, !0), document.addEventListener("contextmenu", o, !0), document.addEventListener("keydown", o, !0);
|
|
855
|
+
}));
|
|
856
|
+
}
|
|
857
|
+
closeContextMenu() {
|
|
858
|
+
this._contextMenu && (this._contextMenu = null, this.requestUpdate());
|
|
859
|
+
}
|
|
860
|
+
renderToolbar() {
|
|
861
|
+
const e = this._messages, t = this._selection.size > 0, i = this._clipboard !== null, o = this._searchPlaceholder || e.searchPlaceholder;
|
|
862
|
+
return s`
|
|
863
|
+
<div class="toolbar" role="toolbar" aria-label=${e.ariaToolbar}>
|
|
864
|
+
${this.opEnabled("newFolder") ? s`<button type="button" @click=${this.promptNewFolder} aria-label=${e.newFolder}>📁 ${e.newFolder}</button>` : l}
|
|
865
|
+
${this.opEnabled("rename") ? s`<button
|
|
866
|
+
type="button"
|
|
867
|
+
?disabled=${!t || this._selection.size !== 1 || !this.opEnabledOnSelection("rename")}
|
|
868
|
+
@click=${this.beginRenameFromToolbar}
|
|
869
|
+
aria-label=${e.rename}
|
|
870
|
+
>✏️ ${e.rename}</button>` : l}
|
|
871
|
+
${this.opEnabled("delete") ? s`<button
|
|
872
|
+
type="button"
|
|
873
|
+
?disabled=${!t || !this.opEnabledOnSelection("delete")}
|
|
874
|
+
@click=${this.deleteSelection}
|
|
875
|
+
aria-label=${e.delete}
|
|
876
|
+
>🗑 ${e.delete}</button>` : l}
|
|
877
|
+
${this.opEnabled("cut") ? s`<button
|
|
878
|
+
type="button"
|
|
879
|
+
?disabled=${!t || !this.opEnabledOnSelection("cut")}
|
|
880
|
+
@click=${() => this.setClipboard("cut")}
|
|
881
|
+
aria-label=${e.cut}
|
|
882
|
+
>✂ ${e.cut}</button>` : l}
|
|
883
|
+
${this.opEnabled("copy") ? s`<button
|
|
884
|
+
type="button"
|
|
885
|
+
?disabled=${!t || !this.opEnabledOnSelection("copy")}
|
|
886
|
+
@click=${() => this.setClipboard("copy")}
|
|
887
|
+
aria-label=${e.copy}
|
|
888
|
+
>📋 ${e.copy}</button>` : l}
|
|
889
|
+
${this.opEnabled("paste") ? s`<button
|
|
890
|
+
type="button"
|
|
891
|
+
?disabled=${!i}
|
|
892
|
+
@click=${this.paste}
|
|
893
|
+
aria-label=${e.paste}
|
|
894
|
+
>📥 ${e.paste}</button>` : l}
|
|
895
|
+
${this._allowUpload && this._isTouchMode ? s`<button
|
|
896
|
+
type="button"
|
|
897
|
+
@click=${this.openUploadPicker}
|
|
898
|
+
aria-label=${e.upload}
|
|
899
|
+
>📤 ${e.upload}</button>` : l}
|
|
900
|
+
<span class="spacer"></span>
|
|
901
|
+
<input
|
|
902
|
+
type="search"
|
|
903
|
+
class="search-input"
|
|
904
|
+
.value=${this._searchQuery}
|
|
905
|
+
placeholder=${o}
|
|
906
|
+
@input=${(r) => this.onSearchInput(r)}
|
|
907
|
+
aria-label=${e.searchPlaceholder}
|
|
908
|
+
/>
|
|
909
|
+
<div class="view-toggle" role="group" aria-label="View mode">
|
|
910
|
+
<button
|
|
911
|
+
type="button"
|
|
912
|
+
data-active=${this._viewMode === "list" ? "true" : "false"}
|
|
913
|
+
@click=${() => this.setViewMode("list")}
|
|
914
|
+
aria-label=${e.listView}
|
|
915
|
+
aria-pressed=${this._viewMode === "list"}
|
|
916
|
+
>${u(E)}</button>
|
|
917
|
+
<button
|
|
918
|
+
type="button"
|
|
919
|
+
data-active=${this._viewMode === "icons" ? "true" : "false"}
|
|
920
|
+
@click=${() => this.setViewMode("icons")}
|
|
921
|
+
aria-label=${e.iconsView}
|
|
922
|
+
aria-pressed=${this._viewMode === "icons"}
|
|
923
|
+
>${u(T)}</button>
|
|
924
|
+
</div>
|
|
925
|
+
</div>
|
|
926
|
+
`;
|
|
927
|
+
}
|
|
928
|
+
renderBreadcrumb(e) {
|
|
929
|
+
return s`
|
|
930
|
+
<nav class="breadcrumb-bar" aria-label=${this._messages.ariaBreadcrumb}>
|
|
931
|
+
<button
|
|
932
|
+
class="breadcrumb-segment"
|
|
933
|
+
data-current=${e.length === 0 ? "true" : "false"}
|
|
934
|
+
aria-current=${e.length === 0 ? "page" : "false"}
|
|
935
|
+
@click=${() => this.navigateTo(null)}
|
|
936
|
+
type="button"
|
|
937
|
+
>${this._messages.home}</button>
|
|
938
|
+
${e.map((t, i) => {
|
|
939
|
+
const o = i === e.length - 1;
|
|
940
|
+
return s`
|
|
941
|
+
<span class="breadcrumb-separator" aria-hidden="true">›</span>
|
|
942
|
+
<button
|
|
943
|
+
class="breadcrumb-segment"
|
|
944
|
+
data-current=${o ? "true" : "false"}
|
|
945
|
+
aria-current=${o ? "page" : "false"}
|
|
946
|
+
@click=${() => this.navigateTo(t.id)}
|
|
947
|
+
type="button"
|
|
948
|
+
>${t.name}</button>
|
|
949
|
+
`;
|
|
950
|
+
})}
|
|
951
|
+
</nav>
|
|
952
|
+
`;
|
|
953
|
+
}
|
|
954
|
+
renderListView(e) {
|
|
955
|
+
const t = this._messages, i = [
|
|
956
|
+
{
|
|
957
|
+
name: "name",
|
|
958
|
+
label: t.name,
|
|
959
|
+
sortable: !0,
|
|
960
|
+
cellClass: "text-nowrap",
|
|
961
|
+
cellRenderer: (o) => this.renderNameCell(o)
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
name: "size",
|
|
965
|
+
label: t.size,
|
|
966
|
+
sortable: !0,
|
|
967
|
+
cellClass: "text-nowrap",
|
|
968
|
+
cellRenderer: (o) => this.formatSize(o)
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
name: "modifiedAt",
|
|
972
|
+
label: t.modified,
|
|
973
|
+
sortable: !0,
|
|
974
|
+
cellClass: "text-nowrap",
|
|
975
|
+
cellRenderer: (o) => this.formatDate(o)
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
name: "type",
|
|
979
|
+
label: t.type,
|
|
980
|
+
sortable: !0,
|
|
981
|
+
cellClass: "text-nowrap",
|
|
982
|
+
cellRenderer: (o) => o.type === "folder" ? t.folder : o.mimeType ?? t.file
|
|
983
|
+
}
|
|
984
|
+
];
|
|
985
|
+
return s`
|
|
986
|
+
<mp-datatable
|
|
987
|
+
.columns=${i}
|
|
988
|
+
.data=${e}
|
|
989
|
+
.selectedIds=${[...this._selection]}
|
|
990
|
+
.rowKey=${(o) => o.id}
|
|
991
|
+
selection-mode=${this._selectionMode}
|
|
992
|
+
resizable-columns
|
|
993
|
+
virtual-scroll
|
|
994
|
+
item-size="40"
|
|
995
|
+
empty-message=${t.noFilesOrFolders}
|
|
996
|
+
@mp-datatable-selection-change=${this.onDatatableSelection}
|
|
997
|
+
@mp-datatable-row-click=${this.onRowClick}
|
|
998
|
+
@mp-datatable-row-dblclick=${this.onRowDblClick}
|
|
999
|
+
@mp-datatable-row-contextmenu=${this.onRowContextMenu}
|
|
1000
|
+
@keydown=${this.onContentKeydown}
|
|
1001
|
+
></mp-datatable>
|
|
1002
|
+
`;
|
|
1003
|
+
}
|
|
1004
|
+
renderNameCell(e) {
|
|
1005
|
+
const t = this.resolveIcon(e);
|
|
1006
|
+
return this._renameTarget === e.id ? s`
|
|
1007
|
+
<span class="row-cell">
|
|
1008
|
+
<span class="row-icon" aria-hidden="true">${t ? u(t) : l}</span>
|
|
1009
|
+
<input
|
|
1010
|
+
${w(this._renameInputRef)}
|
|
1011
|
+
type="text"
|
|
1012
|
+
class="rename-input"
|
|
1013
|
+
.value=${e.name}
|
|
1014
|
+
@click=${(i) => i.stopPropagation()}
|
|
1015
|
+
@keydown=${(i) => this.onRenameKeydown(i, e)}
|
|
1016
|
+
@blur=${(i) => this.commitRename(e, i.target.value)}
|
|
1017
|
+
/>
|
|
1018
|
+
</span>
|
|
1019
|
+
` : s`
|
|
1020
|
+
<span class="row-cell">
|
|
1021
|
+
<span class="row-icon" aria-hidden="true">${t ? u(t) : l}</span>
|
|
1022
|
+
<span>${e.name}</span>
|
|
1023
|
+
</span>
|
|
1024
|
+
`;
|
|
1025
|
+
}
|
|
1026
|
+
renderIconGridView(e) {
|
|
1027
|
+
return s`
|
|
1028
|
+
<div class="icon-grid" role="grid" aria-label="Files and folders" @keydown=${this.onContentKeydown} tabindex="0">
|
|
1029
|
+
${_(
|
|
1030
|
+
e,
|
|
1031
|
+
(t) => t.id,
|
|
1032
|
+
(t) => this.renderIconCard(t)
|
|
1033
|
+
)}
|
|
1034
|
+
</div>
|
|
1035
|
+
`;
|
|
1036
|
+
}
|
|
1037
|
+
renderIconCard(e) {
|
|
1038
|
+
const t = this._selection.has(e.id), i = this._clipboard?.mode === "cut" && this._clipboard.ids.includes(e.id), o = this.resolveIcon(e);
|
|
1039
|
+
return s`
|
|
1040
|
+
<button
|
|
1041
|
+
class="icon-card"
|
|
1042
|
+
type="button"
|
|
1043
|
+
role="gridcell"
|
|
1044
|
+
data-node-id=${e.id}
|
|
1045
|
+
data-selected=${t ? "true" : "false"}
|
|
1046
|
+
data-cut=${i ? "true" : "false"}
|
|
1047
|
+
aria-selected=${t ? "true" : "false"}
|
|
1048
|
+
@click=${(r) => this.onIconCardClick(e, r)}
|
|
1049
|
+
@dblclick=${() => this.activateNode(e)}
|
|
1050
|
+
@contextmenu=${(r) => this.onIconCardContextMenu(e, r)}
|
|
1051
|
+
>
|
|
1052
|
+
<span class="file-icon" aria-hidden="true">${o ? u(o) : l}</span>
|
|
1053
|
+
<span class="file-name">${e.name}</span>
|
|
1054
|
+
</button>
|
|
1055
|
+
`;
|
|
1056
|
+
}
|
|
1057
|
+
// ─── Icon resolution ─────────────────────────────────────────────────────
|
|
1058
|
+
resolveIcon(e) {
|
|
1059
|
+
const t = e.iconKey ?? (e.type === "folder" ? "folder" : "file");
|
|
1060
|
+
if (this._iconResolver) {
|
|
1061
|
+
const i = this._iconResolver(t, e);
|
|
1062
|
+
if (i) return i;
|
|
1063
|
+
}
|
|
1064
|
+
return e.type === "folder" ? m : k;
|
|
1065
|
+
}
|
|
1066
|
+
resolveIconForTree(e, t) {
|
|
1067
|
+
const i = this._nodes.find((o) => o.id === t.id);
|
|
1068
|
+
if (this._iconResolver) {
|
|
1069
|
+
const o = this._iconResolver(e, i);
|
|
1070
|
+
if (o) return o;
|
|
1071
|
+
}
|
|
1072
|
+
return m;
|
|
1073
|
+
}
|
|
1074
|
+
onIconCardContextMenu(e, t) {
|
|
1075
|
+
t.preventDefault(), this._selectionMode !== "none" && !this._selection.has(e.id) && (this._selection = /* @__PURE__ */ new Set([e.id]), this.emitSelectionChange()), this.openContextMenu(e.id, t.clientX, t.clientY);
|
|
1076
|
+
}
|
|
1077
|
+
onIconCardClick(e, t) {
|
|
1078
|
+
if (this._selectionMode !== "none") {
|
|
1079
|
+
if (this._selectionMode === "multiple" && (t.ctrlKey || t.metaKey))
|
|
1080
|
+
this._selection.has(e.id) ? this._selection.delete(e.id) : this._selection.add(e.id);
|
|
1081
|
+
else if (this._selectionMode === "multiple" && t.shiftKey && this._selection.size > 0) {
|
|
1082
|
+
const i = this.getCurrentChildren(), o = [...this._selection][this._selection.size - 1], r = i.findIndex((a) => a.id === o), n = i.findIndex((a) => a.id === e.id);
|
|
1083
|
+
if (r >= 0 && n >= 0) {
|
|
1084
|
+
const [a, d] = r < n ? [r, n] : [n, r];
|
|
1085
|
+
for (let c = a; c <= d; c++) this._selection.add(i[c].id);
|
|
1086
|
+
}
|
|
1087
|
+
} else
|
|
1088
|
+
this._selection = /* @__PURE__ */ new Set([e.id]);
|
|
1089
|
+
this.emitSelectionChange(), this.requestUpdate();
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
activateNode(e) {
|
|
1093
|
+
e.type === "folder" ? this.navigateTo(e.id) : this.dispatchEvent(
|
|
1094
|
+
new CustomEvent("mp-node-open", {
|
|
1095
|
+
detail: { node: e },
|
|
1096
|
+
bubbles: !0,
|
|
1097
|
+
composed: !0
|
|
1098
|
+
})
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
onSearchInput(e) {
|
|
1102
|
+
this._searchQuery = e.target.value, this.requestUpdate();
|
|
1103
|
+
}
|
|
1104
|
+
setViewMode(e) {
|
|
1105
|
+
this.viewMode = e;
|
|
1106
|
+
}
|
|
1107
|
+
// ─── Navigation ─────────────────────────────────────────────────────────
|
|
1108
|
+
navigateTo(e) {
|
|
1109
|
+
if (e !== null) {
|
|
1110
|
+
const i = this._nodes.find((r) => r.id === e);
|
|
1111
|
+
if (!i || i.type !== "folder") return;
|
|
1112
|
+
let o = i.parentId;
|
|
1113
|
+
for (; o !== null; )
|
|
1114
|
+
this._expandedTreeIds.add(o), o = this._nodes.find((n) => n.id === o)?.parentId ?? null;
|
|
1115
|
+
this._expandedTreeIds.add(e);
|
|
1116
|
+
}
|
|
1117
|
+
if (this._currentFolderId === e) return;
|
|
1118
|
+
this._currentFolderId = e;
|
|
1119
|
+
const t = this._selection.size > 0;
|
|
1120
|
+
this._selection.clear(), this.requestUpdate(), this.dispatchEvent(
|
|
1121
|
+
new CustomEvent("mp-navigate", {
|
|
1122
|
+
detail: { folderId: e },
|
|
1123
|
+
bubbles: !0,
|
|
1124
|
+
composed: !0
|
|
1125
|
+
})
|
|
1126
|
+
), t && this.emitSelectionChange();
|
|
1127
|
+
}
|
|
1128
|
+
async invokeDialog(e) {
|
|
1129
|
+
return this._dialogResolver ? this._dialogResolver(e) : e.kind === "confirm" ? window.confirm(e.message) : window.prompt(e.label, e.defaultValue ?? "");
|
|
1130
|
+
}
|
|
1131
|
+
commitRename(e, t) {
|
|
1132
|
+
if (this._renameTarget !== e.id) return;
|
|
1133
|
+
const i = t.trim();
|
|
1134
|
+
this._renameTarget = null, this.requestUpdate(), !(!i || i === e.name) && this.dispatchEvent(
|
|
1135
|
+
new CustomEvent("mp-operation", {
|
|
1136
|
+
detail: { kind: "rename", nodeId: e.id, previousName: e.name, newName: i },
|
|
1137
|
+
bubbles: !0,
|
|
1138
|
+
composed: !0
|
|
1139
|
+
})
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
onRenameKeydown(e, t) {
|
|
1143
|
+
if (e.key === "Enter") {
|
|
1144
|
+
e.preventDefault();
|
|
1145
|
+
const i = e.target.value;
|
|
1146
|
+
this.commitRename(t, i);
|
|
1147
|
+
} else e.key === "Escape" ? (e.preventDefault(), this._renameTarget = null, this.requestUpdate()) : (e.key === "ArrowUp" || e.key === "ArrowDown") && e.stopPropagation();
|
|
1148
|
+
}
|
|
1149
|
+
setClipboard(e) {
|
|
1150
|
+
this._selection.size !== 0 && (this._clipboard = { mode: e, ids: [...this._selection] }, this.requestUpdate());
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* For every source node whose name already exists in the target folder,
|
|
1154
|
+
* consult the conflictResolver. Returns a map of sourceId → resolution
|
|
1155
|
+
* (action + optional newName). Returns `null` if any resolver returned
|
|
1156
|
+
* abort. When no resolver is wired, returns an empty record (the
|
|
1157
|
+
* consumer's paste handler is expected to overwrite-by-default).
|
|
1158
|
+
*/
|
|
1159
|
+
async resolveConflictsForPaste(e, t) {
|
|
1160
|
+
if (!this._conflictResolver) return {};
|
|
1161
|
+
const i = {}, o = this._nodes.filter((r) => r.parentId === t);
|
|
1162
|
+
for (const r of e) {
|
|
1163
|
+
const n = this._nodes.find((c) => c.id === r);
|
|
1164
|
+
if (!n) continue;
|
|
1165
|
+
const a = o.find((c) => c.name === n.name && c.id !== r);
|
|
1166
|
+
if (!a) continue;
|
|
1167
|
+
const d = await this._conflictResolver({
|
|
1168
|
+
existingNode: a,
|
|
1169
|
+
incomingName: n.name,
|
|
1170
|
+
mode: "paste"
|
|
1171
|
+
});
|
|
1172
|
+
i[r] = d;
|
|
1173
|
+
}
|
|
1174
|
+
return i;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Common entry point for file-upload requests from either the drag-drop
|
|
1178
|
+
* overlay or the touch upload picker. Resolves conflicts against the
|
|
1179
|
+
* target folder, registers `UploadEntry` records in `uploads`, and
|
|
1180
|
+
* emits `mp-upload-request` with one resolved file per kept entry.
|
|
1181
|
+
*/
|
|
1182
|
+
async handleFiles(e) {
|
|
1183
|
+
const t = this._currentFolderId, i = this._nodes.filter((n) => n.parentId === t), o = [];
|
|
1184
|
+
for (const n of e) {
|
|
1185
|
+
const a = i.find((d) => d.name === n.name);
|
|
1186
|
+
if (a && this._conflictResolver) {
|
|
1187
|
+
const d = await this._conflictResolver({
|
|
1188
|
+
existingNode: a,
|
|
1189
|
+
incomingName: n.name,
|
|
1190
|
+
mode: "upload"
|
|
1191
|
+
});
|
|
1192
|
+
if (d.action === "skip") continue;
|
|
1193
|
+
o.push({
|
|
1194
|
+
file: n,
|
|
1195
|
+
entryId: this.makeUploadId(),
|
|
1196
|
+
conflict: d.action,
|
|
1197
|
+
renamedTo: d.newName
|
|
1198
|
+
});
|
|
1199
|
+
} else
|
|
1200
|
+
o.push({ file: n, entryId: this.makeUploadId() });
|
|
1201
|
+
}
|
|
1202
|
+
if (o.length === 0) return;
|
|
1203
|
+
const r = o.map((n) => ({
|
|
1204
|
+
id: n.entryId,
|
|
1205
|
+
file: n.file,
|
|
1206
|
+
targetFolderId: t,
|
|
1207
|
+
progress: 0,
|
|
1208
|
+
status: "pending"
|
|
1209
|
+
}));
|
|
1210
|
+
this._uploads = [...this._uploads, ...r], this.requestUpdate(), this.dispatchEvent(
|
|
1211
|
+
new CustomEvent("mp-upload-request", {
|
|
1212
|
+
detail: {
|
|
1213
|
+
files: o.map((n) => n.file),
|
|
1214
|
+
targetFolderId: t,
|
|
1215
|
+
uploads: r,
|
|
1216
|
+
conflictResolutions: o.filter((n) => n.conflict).map((n) => ({ fileName: n.file.name, action: n.conflict, newName: n.renamedTo }))
|
|
1217
|
+
},
|
|
1218
|
+
bubbles: !0,
|
|
1219
|
+
composed: !0
|
|
1220
|
+
})
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
makeUploadId() {
|
|
1224
|
+
return `upload-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
|
|
1225
|
+
}
|
|
1226
|
+
// ─── Helpers ────────────────────────────────────────────────────────────
|
|
1227
|
+
pruneSelection() {
|
|
1228
|
+
const e = new Set(this._nodes.map((i) => i.id));
|
|
1229
|
+
let t = !1;
|
|
1230
|
+
for (const i of this._selection)
|
|
1231
|
+
e.has(i) || (this._selection.delete(i), t = !0);
|
|
1232
|
+
t && this.emitSelectionChange();
|
|
1233
|
+
}
|
|
1234
|
+
emitSelectionChange() {
|
|
1235
|
+
this.dispatchEvent(
|
|
1236
|
+
new CustomEvent("mp-selection-change", {
|
|
1237
|
+
detail: { selectedIds: [...this._selection] },
|
|
1238
|
+
bubbles: !0,
|
|
1239
|
+
composed: !0
|
|
1240
|
+
})
|
|
1241
|
+
);
|
|
1242
|
+
}
|
|
1243
|
+
formatSize(e) {
|
|
1244
|
+
if (e.type === "folder" || e.size == null) return "—";
|
|
1245
|
+
const t = e.size;
|
|
1246
|
+
return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} kB` : t < 1024 * 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${(t / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
1247
|
+
}
|
|
1248
|
+
formatDate(e) {
|
|
1249
|
+
if (!e.modifiedAt) return "—";
|
|
1250
|
+
try {
|
|
1251
|
+
return new Date(e.modifiedAt).toLocaleDateString();
|
|
1252
|
+
} catch {
|
|
1253
|
+
return e.modifiedAt;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
typeof customElements < "u" && !customElements.get("mp-file-manager") && customElements.define("mp-file-manager", F);
|
|
1258
|
+
export {
|
|
1259
|
+
p as DEFAULT_FILE_MANAGER_MESSAGES,
|
|
1260
|
+
F as MpFileManager,
|
|
1261
|
+
$ as fileManagerStyles,
|
|
1262
|
+
x as mergeMessages
|
|
1263
|
+
};
|