@kong-ui-public/dashboard-renderer 0.34.3 → 0.35.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/dashboard-renderer.es.js +3240 -441
- package/dist/dashboard-renderer.umd.js +9 -1
- package/dist/style.css +1 -1
- package/dist/types/components/DashboardRenderer.vue.d.ts +311 -1
- package/dist/types/components/DashboardRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/DashboardTile.vue.d.ts.map +1 -1
- package/dist/types/components/layout/DraggableGridLayout.vue.d.ts +29 -0
- package/dist/types/components/layout/DraggableGridLayout.vue.d.ts.map +1 -0
- package/package.json +10 -9
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { stripUnknownFilters as
|
|
3
|
-
import { SimpleChart as
|
|
4
|
-
import
|
|
1
|
+
import { ref as U, watchEffect as Oe, inject as j, defineComponent as M, onUnmounted as le, computed as S, watch as Ee, resolveComponent as W, unref as x, openBlock as E, createBlock as T, withCtx as H, createTextVNode as re, toDisplayString as G, renderSlot as ne, createCommentVNode as I, useCssVars as oe, createElementVNode as K, createVNode as $, mergeProps as xe, createSlots as Ce, createElementBlock as L, normalizeProps as Me, guardReactiveProps as Ie, resolveDynamicComponent as Re, onMounted as De, Fragment as ze, renderList as Se, normalizeClass as Pe, normalizeStyle as fe } from "vue";
|
|
2
|
+
import { stripUnknownFilters as Be, Timeframe as qe, TimePeriods as Te, TIMEFRAME_LOOKUP as Ue, formatTime as ge, msToGranularity as $e } from "@kong-ui-public/analytics-utilities";
|
|
3
|
+
import { SimpleChart as Fe, AnalyticsChart as Ge, TopNTable as We, CsvExportModal as Ke } from "@kong-ui-public/analytics-chart";
|
|
4
|
+
import Ve from "swrv";
|
|
5
5
|
import "axios";
|
|
6
|
-
import { createI18n as
|
|
7
|
-
import { MetricsProvider as
|
|
8
|
-
import { EntityLink as
|
|
9
|
-
import { EditIcon as
|
|
10
|
-
import { useAnalyticsConfigStore as
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
var
|
|
14
|
-
return
|
|
15
|
-
((
|
|
6
|
+
import { createI18n as Ye, i18nTComponent as Xe } from "@kong-ui-public/i18n";
|
|
7
|
+
import { MetricsProvider as je, MetricsConsumer as Qe } from "@kong-ui-public/analytics-metric-provider";
|
|
8
|
+
import { EntityLink as Je } from "@kong-ui-public/entities-shared";
|
|
9
|
+
import { EditIcon as Ze, MoreIcon as et } from "@kong/icons";
|
|
10
|
+
import { useAnalyticsConfigStore as tt } from "@kong-ui-public/analytics-config-store";
|
|
11
|
+
var ke = /* @__PURE__ */ ((c) => (c.VALIDATING = "VALIDATING", c.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", c.PENDING = "PENDING", c.SUCCESS = "SUCCESS", c.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", c.ERROR = "ERROR", c.STALE_IF_ERROR = "STALE_IF_ERROR", c))(ke || {});
|
|
12
|
+
const it = (c) => {
|
|
13
|
+
var e, t, i, s, r;
|
|
14
|
+
return c ? !!// TODO: revisit: currently only the first check ever matters?
|
|
15
|
+
((e = Object.keys(c)) != null && e.length || (t = c.data) != null && t.length || (s = (i = c.data) == null ? void 0 : i.data) != null && s.length || !((r = c.data) != null && r.data) && typeof c.data == "object" && Object.keys(c == null ? void 0 : c.data).length) : !1;
|
|
16
16
|
};
|
|
17
|
-
function
|
|
18
|
-
const s =
|
|
17
|
+
function st(c = U({}), e, t, i = it) {
|
|
18
|
+
const s = U(
|
|
19
19
|
"PENDING"
|
|
20
20
|
/* PENDING */
|
|
21
21
|
);
|
|
22
|
-
return
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
22
|
+
return Oe(() => {
|
|
23
|
+
const r = i(c.value);
|
|
24
|
+
if (c.value && r && t.value) {
|
|
25
25
|
s.value = "VALIDATING_HAS_DATA";
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
28
|
+
if (c.value && t.value) {
|
|
29
29
|
s.value = "VALIDATING";
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
if (
|
|
32
|
+
if (c.value && e.value) {
|
|
33
33
|
s.value = "STALE_IF_ERROR";
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
36
|
+
if (c.value === void 0 && !e.value) {
|
|
37
37
|
s.value = "PENDING";
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if (
|
|
40
|
+
if (c.value && !e.value && r) {
|
|
41
41
|
s.value = "SUCCESS_HAS_DATA";
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
44
|
+
if (c.value && !e.value) {
|
|
45
45
|
s.value = "SUCCESS";
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
c.value === void 0 && e && (s.value = "ERROR");
|
|
49
49
|
}), {
|
|
50
50
|
state: s,
|
|
51
|
-
swrvState:
|
|
51
|
+
swrvState: ke
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const rt = {
|
|
55
55
|
noQueryBridge: "No query bridge provided. Unable to render dashboard.",
|
|
56
56
|
trendRange: {
|
|
57
57
|
"24h": "Last 24-Hour Summary",
|
|
@@ -59,36 +59,36 @@ const Ne = {
|
|
|
59
59
|
"30d": "Last 30-Day Summary"
|
|
60
60
|
},
|
|
61
61
|
edit: "Edit"
|
|
62
|
-
},
|
|
62
|
+
}, nt = {
|
|
63
63
|
timeRangeExceeded: "The time range for this report is outside of your organization's data retention period"
|
|
64
|
-
},
|
|
64
|
+
}, ot = {
|
|
65
65
|
defaultFilename: "Chart Export",
|
|
66
66
|
exportAsCsv: "Export as CSV"
|
|
67
|
-
},
|
|
68
|
-
renderer:
|
|
69
|
-
queryDataProvider:
|
|
70
|
-
csvExport:
|
|
71
|
-
jumpToExplore:
|
|
67
|
+
}, at = "Explore", lt = {
|
|
68
|
+
renderer: rt,
|
|
69
|
+
queryDataProvider: nt,
|
|
70
|
+
csvExport: ot,
|
|
71
|
+
jumpToExplore: at
|
|
72
72
|
};
|
|
73
|
-
function
|
|
74
|
-
const
|
|
73
|
+
function ht() {
|
|
74
|
+
const c = Ye("en-us", lt);
|
|
75
75
|
return {
|
|
76
|
-
i18n:
|
|
77
|
-
i18nT:
|
|
76
|
+
i18n: c,
|
|
77
|
+
i18nT: Xe(c)
|
|
78
78
|
// Translation component <i18n-t>
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
const
|
|
82
|
-
function
|
|
83
|
-
const
|
|
81
|
+
const he = 170, Q = "analytics-query-provider", pe = "{entity-id}", dt = "{cp-id}", ut = "{timeframe}", ct = 30 * 1e3;
|
|
82
|
+
function ft() {
|
|
83
|
+
const c = j(Q);
|
|
84
84
|
return {
|
|
85
|
-
evaluateFeatureFlag: (
|
|
85
|
+
evaluateFeatureFlag: (t, i) => c ? c.evaluateFeatureFlagFn(t, i) : i
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
const
|
|
89
|
-
useI18n:
|
|
90
|
-
useEvaluateFeatureFlag:
|
|
91
|
-
},
|
|
88
|
+
const F = {
|
|
89
|
+
useI18n: ht,
|
|
90
|
+
useEvaluateFeatureFlag: ft
|
|
91
|
+
}, de = /* @__PURE__ */ M({
|
|
92
92
|
__name: "QueryDataProvider",
|
|
93
93
|
props: {
|
|
94
94
|
context: {},
|
|
@@ -97,74 +97,74 @@ const $ = {
|
|
|
97
97
|
refreshCounter: {}
|
|
98
98
|
},
|
|
99
99
|
emits: ["chart-data", "queryComplete"],
|
|
100
|
-
setup(
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
setup(c, { emit: e }) {
|
|
101
|
+
const t = c, i = e, { i18n: s } = F.useI18n(), r = j(Q), o = () => t.queryReady && r ? JSON.stringify([t.query, t.context, t.refreshCounter]) : null, n = new AbortController();
|
|
102
|
+
le(() => {
|
|
103
|
+
n.abort();
|
|
104
104
|
});
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
return
|
|
108
|
-
}, { data:
|
|
109
|
-
var
|
|
105
|
+
const l = (w, C, D) => {
|
|
106
|
+
const z = [];
|
|
107
|
+
return C && z.push(...C), z.push(...Be(w, D)), z;
|
|
108
|
+
}, { data: h, error: d, isValidating: u } = Ve(o, async () => {
|
|
109
|
+
var w, C, D, z;
|
|
110
110
|
try {
|
|
111
111
|
let {
|
|
112
|
-
datasource:
|
|
113
|
-
...
|
|
114
|
-
} =
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
...
|
|
120
|
-
tz:
|
|
121
|
-
}) :
|
|
122
|
-
...
|
|
123
|
-
tz:
|
|
112
|
+
datasource: R,
|
|
113
|
+
...y
|
|
114
|
+
} = t.query;
|
|
115
|
+
R || (R = "basic");
|
|
116
|
+
const q = l(R, t.query.filters, t.context.filters);
|
|
117
|
+
let N = t.query.time_range;
|
|
118
|
+
N ? N.tz || (N = {
|
|
119
|
+
...N,
|
|
120
|
+
tz: t.context.tz
|
|
121
|
+
}) : N = {
|
|
122
|
+
...t.context.timeSpec,
|
|
123
|
+
tz: t.context.tz
|
|
124
124
|
};
|
|
125
|
-
const
|
|
126
|
-
datasource:
|
|
125
|
+
const J = {
|
|
126
|
+
datasource: R,
|
|
127
127
|
query: {
|
|
128
|
-
...
|
|
129
|
-
time_range:
|
|
130
|
-
filters:
|
|
128
|
+
...y,
|
|
129
|
+
time_range: N,
|
|
130
|
+
filters: q
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
|
-
return
|
|
134
|
-
} catch (
|
|
135
|
-
|
|
133
|
+
return r == null ? void 0 : r.queryFn(J, n);
|
|
134
|
+
} catch (R) {
|
|
135
|
+
v.value = ((C = (w = R == null ? void 0 : R.response) == null ? void 0 : w.data) == null ? void 0 : C.message) === "Range not allowed for this tier" ? s.t("queryDataProvider.timeRangeExceeded") : ((z = (D = R == null ? void 0 : R.response) == null ? void 0 : D.data) == null ? void 0 : z.message) || (R == null ? void 0 : R.message);
|
|
136
136
|
} finally {
|
|
137
|
-
|
|
137
|
+
i("queryComplete");
|
|
138
138
|
}
|
|
139
139
|
}, {
|
|
140
|
-
refreshInterval:
|
|
140
|
+
refreshInterval: t.context.refreshInterval,
|
|
141
141
|
revalidateOnFocus: !1
|
|
142
|
-
}), { state:
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
}), (
|
|
146
|
-
const
|
|
147
|
-
return
|
|
142
|
+
}), { state: f, swrvState: _ } = st(h, d, u), v = U(null), b = S(() => f.value === _.ERROR || !!v.value), p = S(() => !t.queryReady || f.value === _.PENDING);
|
|
143
|
+
return Ee(h, (w) => {
|
|
144
|
+
w && i("chart-data", w);
|
|
145
|
+
}), (w, C) => {
|
|
146
|
+
const D = W("KSkeleton"), z = W("KEmptyState");
|
|
147
|
+
return p.value || !x(h) && !b.value ? (E(), T(D, {
|
|
148
148
|
key: 0,
|
|
149
149
|
class: "chart-skeleton",
|
|
150
150
|
type: "table"
|
|
151
|
-
})) :
|
|
151
|
+
})) : b.value ? (E(), T(z, {
|
|
152
152
|
key: 1,
|
|
153
153
|
"action-button-visible": !1,
|
|
154
154
|
"data-testid": "chart-empty-state",
|
|
155
155
|
"icon-variant": "error"
|
|
156
156
|
}, {
|
|
157
|
-
default:
|
|
158
|
-
|
|
157
|
+
default: H(() => [
|
|
158
|
+
re(G(v.value), 1)
|
|
159
159
|
]),
|
|
160
160
|
_: 1
|
|
161
|
-
})) :
|
|
161
|
+
})) : x(h) ? ne(w.$slots, "default", {
|
|
162
162
|
key: 2,
|
|
163
|
-
data:
|
|
164
|
-
}) :
|
|
163
|
+
data: x(h)
|
|
164
|
+
}) : I("", !0);
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
}),
|
|
167
|
+
}), gt = { class: "analytics-chart" }, pt = /* @__PURE__ */ M({
|
|
168
168
|
__name: "SimpleChartRenderer",
|
|
169
169
|
props: {
|
|
170
170
|
query: {},
|
|
@@ -174,35 +174,35 @@ const $ = {
|
|
|
174
174
|
height: {},
|
|
175
175
|
refreshCounter: {}
|
|
176
176
|
},
|
|
177
|
-
setup(
|
|
178
|
-
|
|
179
|
-
c40c0e86: `${
|
|
177
|
+
setup(c) {
|
|
178
|
+
oe((t) => ({
|
|
179
|
+
c40c0e86: `${t.height}px`
|
|
180
180
|
}));
|
|
181
|
-
const
|
|
182
|
-
return (
|
|
183
|
-
context:
|
|
184
|
-
query:
|
|
185
|
-
"query-ready":
|
|
186
|
-
"refresh-counter":
|
|
181
|
+
const e = c;
|
|
182
|
+
return (t, i) => (E(), T(de, {
|
|
183
|
+
context: t.context,
|
|
184
|
+
query: t.query,
|
|
185
|
+
"query-ready": t.queryReady,
|
|
186
|
+
"refresh-counter": t.refreshCounter
|
|
187
187
|
}, {
|
|
188
|
-
default:
|
|
189
|
-
K("div",
|
|
190
|
-
|
|
188
|
+
default: H(({ data: s }) => [
|
|
189
|
+
K("div", gt, [
|
|
190
|
+
$(x(Fe), {
|
|
191
191
|
"chart-data": s,
|
|
192
|
-
"chart-options":
|
|
193
|
-
"synthetics-data-key":
|
|
192
|
+
"chart-options": e.chartOptions,
|
|
193
|
+
"synthetics-data-key": t.chartOptions.syntheticsDataKey
|
|
194
194
|
}, null, 8, ["chart-data", "chart-options", "synthetics-data-key"])
|
|
195
195
|
])
|
|
196
196
|
]),
|
|
197
197
|
_: 1
|
|
198
198
|
}, 8, ["context", "query", "query-ready", "refresh-counter"]));
|
|
199
199
|
}
|
|
200
|
-
}),
|
|
201
|
-
const
|
|
202
|
-
for (const [
|
|
203
|
-
|
|
204
|
-
return
|
|
205
|
-
},
|
|
200
|
+
}), V = (c, e) => {
|
|
201
|
+
const t = c.__vccOpts || c;
|
|
202
|
+
for (const [i, s] of e)
|
|
203
|
+
t[i] = s;
|
|
204
|
+
return t;
|
|
205
|
+
}, mt = /* @__PURE__ */ V(pt, [["__scopeId", "data-v-694cf637"]]), yt = { class: "analytics-chart" }, _t = /* @__PURE__ */ M({
|
|
206
206
|
__name: "BaseAnalyticsChartRenderer",
|
|
207
207
|
props: {
|
|
208
208
|
query: {},
|
|
@@ -214,56 +214,56 @@ const $ = {
|
|
|
214
214
|
extraProps: {}
|
|
215
215
|
},
|
|
216
216
|
emits: ["edit-tile", "chart-data"],
|
|
217
|
-
setup(
|
|
218
|
-
const
|
|
219
|
-
type:
|
|
220
|
-
stacked:
|
|
221
|
-
chartDatasetColors:
|
|
222
|
-
threshold:
|
|
223
|
-
})),
|
|
217
|
+
setup(c, { emit: e }) {
|
|
218
|
+
const t = c, i = e, s = j(Q), { i18n: r } = F.useI18n(), { evaluateFeatureFlag: o } = F.useEvaluateFeatureFlag(), n = o("ma-3043-analytics-chart-kebab-menu", !1), l = S(() => ({
|
|
219
|
+
type: t.chartOptions.type,
|
|
220
|
+
stacked: t.chartOptions.stacked ?? !1,
|
|
221
|
+
chartDatasetColors: t.chartOptions.chartDatasetColors,
|
|
222
|
+
threshold: t.chartOptions.threshold
|
|
223
|
+
})), h = S(() => {
|
|
224
224
|
if (s && s.exploreBaseUrl) {
|
|
225
|
-
const
|
|
226
|
-
filters: [...
|
|
227
|
-
metrics:
|
|
228
|
-
dimensions:
|
|
229
|
-
time_range:
|
|
230
|
-
},
|
|
231
|
-
return `${s.exploreBaseUrl()}?q=${JSON.stringify(
|
|
225
|
+
const f = {
|
|
226
|
+
filters: [...t.context.filters, ...t.query.filters ?? []],
|
|
227
|
+
metrics: t.query.metrics ?? [],
|
|
228
|
+
dimensions: t.query.dimensions ?? [],
|
|
229
|
+
time_range: t.query.time_range || t.context.timeSpec
|
|
230
|
+
}, _ = ["advanced", "ai"].includes(t.query.datasource) ? t.query.datasource : "advanced";
|
|
231
|
+
return `${s.exploreBaseUrl()}?q=${JSON.stringify(f)}&d=${_}&c=${t.chartOptions.type}`;
|
|
232
232
|
}
|
|
233
233
|
return "";
|
|
234
|
-
}),
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
|
|
234
|
+
}), d = () => {
|
|
235
|
+
i("edit-tile");
|
|
236
|
+
}, u = (f) => {
|
|
237
|
+
i("chart-data", f);
|
|
238
238
|
};
|
|
239
|
-
return (
|
|
240
|
-
const
|
|
241
|
-
return
|
|
242
|
-
context:
|
|
243
|
-
query:
|
|
244
|
-
"query-ready":
|
|
245
|
-
"refresh-counter":
|
|
246
|
-
onChartData:
|
|
239
|
+
return (f, _) => {
|
|
240
|
+
const v = W("KDropdownItem");
|
|
241
|
+
return E(), T(de, {
|
|
242
|
+
context: f.context,
|
|
243
|
+
query: f.query,
|
|
244
|
+
"query-ready": f.queryReady,
|
|
245
|
+
"refresh-counter": f.refreshCounter,
|
|
246
|
+
onChartData: u
|
|
247
247
|
}, {
|
|
248
|
-
default:
|
|
249
|
-
K("div",
|
|
250
|
-
|
|
251
|
-
"allow-csv-export":
|
|
252
|
-
"chart-data":
|
|
253
|
-
"chart-options":
|
|
254
|
-
"chart-title": !
|
|
255
|
-
"go-to-explore":
|
|
248
|
+
default: H(({ data: b }) => [
|
|
249
|
+
K("div", yt, [
|
|
250
|
+
$(x(Ge), xe({
|
|
251
|
+
"allow-csv-export": f.chartOptions.allowCsvExport,
|
|
252
|
+
"chart-data": b,
|
|
253
|
+
"chart-options": l.value,
|
|
254
|
+
"chart-title": !x(n) && f.chartOptions.chartTitle || "",
|
|
255
|
+
"go-to-explore": h.value,
|
|
256
256
|
"legend-position": "bottom",
|
|
257
|
-
"show-menu":
|
|
258
|
-
"synthetics-data-key":
|
|
257
|
+
"show-menu": f.context.editable,
|
|
258
|
+
"synthetics-data-key": f.chartOptions.syntheticsDataKey,
|
|
259
259
|
"tooltip-title": ""
|
|
260
|
-
},
|
|
261
|
-
|
|
260
|
+
}, f.extraProps), Ce({ _: 2 }, [
|
|
261
|
+
f.context.editable ? {
|
|
262
262
|
name: "menu-items",
|
|
263
|
-
fn:
|
|
264
|
-
|
|
265
|
-
default:
|
|
266
|
-
|
|
263
|
+
fn: H(() => [
|
|
264
|
+
$(v, { onClick: d }, {
|
|
265
|
+
default: H(() => [
|
|
266
|
+
re(G(x(r).t("renderer.edit")), 1)
|
|
267
267
|
]),
|
|
268
268
|
_: 1
|
|
269
269
|
})
|
|
@@ -277,7 +277,7 @@ const $ = {
|
|
|
277
277
|
}, 8, ["context", "query", "query-ready", "refresh-counter"]);
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
|
-
}),
|
|
280
|
+
}), Ne = /* @__PURE__ */ V(_t, [["__scopeId", "data-v-1bc587d3"]]), me = /* @__PURE__ */ M({
|
|
281
281
|
__name: "BarChartRenderer",
|
|
282
282
|
props: {
|
|
283
283
|
query: {},
|
|
@@ -287,18 +287,18 @@ const $ = {
|
|
|
287
287
|
height: {},
|
|
288
288
|
refreshCounter: {}
|
|
289
289
|
},
|
|
290
|
-
setup(
|
|
291
|
-
return (
|
|
292
|
-
"chart-options":
|
|
293
|
-
context:
|
|
290
|
+
setup(c) {
|
|
291
|
+
return (e, t) => (E(), T(Ne, {
|
|
292
|
+
"chart-options": e.chartOptions,
|
|
293
|
+
context: e.context,
|
|
294
294
|
"extra-props": { showAnnotations: !1 },
|
|
295
|
-
height:
|
|
296
|
-
query:
|
|
297
|
-
"query-ready":
|
|
298
|
-
"refresh-counter":
|
|
295
|
+
height: e.height,
|
|
296
|
+
query: e.query,
|
|
297
|
+
"query-ready": e.queryReady,
|
|
298
|
+
"refresh-counter": e.refreshCounter
|
|
299
299
|
}, null, 8, ["chart-options", "context", "height", "query", "query-ready", "refresh-counter"]));
|
|
300
300
|
}
|
|
301
|
-
}),
|
|
301
|
+
}), ye = /* @__PURE__ */ M({
|
|
302
302
|
__name: "TimeseriesChartRenderer",
|
|
303
303
|
props: {
|
|
304
304
|
query: {},
|
|
@@ -308,17 +308,17 @@ const $ = {
|
|
|
308
308
|
height: {},
|
|
309
309
|
refreshCounter: {}
|
|
310
310
|
},
|
|
311
|
-
setup(
|
|
312
|
-
return (
|
|
313
|
-
"chart-options":
|
|
314
|
-
context:
|
|
315
|
-
height:
|
|
316
|
-
query:
|
|
317
|
-
"query-ready":
|
|
318
|
-
"refresh-counter":
|
|
311
|
+
setup(c) {
|
|
312
|
+
return (e, t) => (E(), T(Ne, {
|
|
313
|
+
"chart-options": e.chartOptions,
|
|
314
|
+
context: e.context,
|
|
315
|
+
height: e.height,
|
|
316
|
+
query: e.query,
|
|
317
|
+
"query-ready": e.queryReady,
|
|
318
|
+
"refresh-counter": e.refreshCounter
|
|
319
319
|
}, null, 8, ["chart-options", "context", "height", "query", "query-ready", "refresh-counter"]));
|
|
320
320
|
}
|
|
321
|
-
}),
|
|
321
|
+
}), vt = { class: "metric-card-tile-wrapper" }, bt = /* @__PURE__ */ M({
|
|
322
322
|
__name: "GoldenSignalsRenderer",
|
|
323
323
|
props: {
|
|
324
324
|
query: {},
|
|
@@ -328,61 +328,61 @@ const $ = {
|
|
|
328
328
|
height: {},
|
|
329
329
|
refreshCounter: {}
|
|
330
330
|
},
|
|
331
|
-
setup(
|
|
332
|
-
|
|
333
|
-
"926e3b48":
|
|
334
|
-
"7be2893e":
|
|
335
|
-
"0d55c162":
|
|
331
|
+
setup(c) {
|
|
332
|
+
oe((o) => ({
|
|
333
|
+
"926e3b48": x(i) ? "90%" : "100%",
|
|
334
|
+
"7be2893e": x(i) ? "auto" : "100%",
|
|
335
|
+
"0d55c162": x(i) ? "100%" : "none"
|
|
336
336
|
}));
|
|
337
|
-
const
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
return new
|
|
337
|
+
const e = c, { evaluateFeatureFlag: t } = F.useEvaluateFeatureFlag(), i = t("ma-3043-analytics-chart-kebab-menu", !1), s = S(() => {
|
|
338
|
+
const o = e.context.timeSpec;
|
|
339
|
+
if (o.type === "absolute")
|
|
340
|
+
return new qe({
|
|
341
341
|
key: "custom",
|
|
342
342
|
timeframeText: "custom",
|
|
343
343
|
display: "custom",
|
|
344
|
-
startCustom:
|
|
345
|
-
endCustom:
|
|
346
|
-
timeframeLength: () =>
|
|
344
|
+
startCustom: o.start,
|
|
345
|
+
endCustom: o.end,
|
|
346
|
+
timeframeLength: () => o.end.getTime() - o.start.getTime(),
|
|
347
347
|
defaultResponseGranularity: "daily",
|
|
348
348
|
dataGranularity: "daily",
|
|
349
349
|
isRelative: !1,
|
|
350
350
|
allowedTiers: ["free", "plus", "enterprise"]
|
|
351
351
|
});
|
|
352
|
-
const
|
|
353
|
-
if (!
|
|
352
|
+
const n = Te.get(o.time_range);
|
|
353
|
+
if (!n)
|
|
354
354
|
throw new Error("Unknown time range");
|
|
355
|
-
return
|
|
356
|
-
}),
|
|
357
|
-
var
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
throw new Error(`Invalid datasource value: ${
|
|
355
|
+
return n;
|
|
356
|
+
}), r = S(() => {
|
|
357
|
+
var n, l;
|
|
358
|
+
const o = (n = e.query) == null ? void 0 : n.datasource;
|
|
359
|
+
if (o && o !== "advanced" && o !== "basic")
|
|
360
|
+
throw new Error(`Invalid datasource value: ${o}`);
|
|
361
361
|
return {
|
|
362
|
-
datasource: (
|
|
362
|
+
datasource: (l = e.query) == null ? void 0 : l.datasource,
|
|
363
363
|
overrideTimeframe: s.value,
|
|
364
|
-
tz:
|
|
365
|
-
additionalFilter:
|
|
364
|
+
tz: e.context.tz,
|
|
365
|
+
additionalFilter: e.context.filters,
|
|
366
366
|
// TODO: Decide how to handle metric card filters.
|
|
367
|
-
longCardTitles:
|
|
368
|
-
...!
|
|
369
|
-
...!
|
|
370
|
-
percentileLatency:
|
|
371
|
-
refreshInterval:
|
|
372
|
-
queryReady:
|
|
373
|
-
refreshCounter:
|
|
367
|
+
longCardTitles: e.chartOptions.longCardTitles,
|
|
368
|
+
...!i && { containerTitle: e.chartOptions.chartTitle },
|
|
369
|
+
...!i && { description: e.chartOptions.description },
|
|
370
|
+
percentileLatency: e.chartOptions.percentileLatency,
|
|
371
|
+
refreshInterval: e.context.refreshInterval,
|
|
372
|
+
queryReady: e.queryReady,
|
|
373
|
+
refreshCounter: e.refreshCounter
|
|
374
374
|
};
|
|
375
375
|
});
|
|
376
|
-
return (
|
|
377
|
-
|
|
378
|
-
default:
|
|
379
|
-
|
|
376
|
+
return (o, n) => (E(), L("div", vt, [
|
|
377
|
+
$(x(je), Me(Ie(r.value)), {
|
|
378
|
+
default: H(() => [
|
|
379
|
+
$(x(Qe))
|
|
380
380
|
]),
|
|
381
381
|
_: 1
|
|
382
382
|
}, 16)
|
|
383
383
|
]));
|
|
384
384
|
}
|
|
385
|
-
}),
|
|
385
|
+
}), wt = /* @__PURE__ */ V(bt, [["__scopeId", "data-v-0f571079"]]), _e = "#6c7489", ve = "20px", He = "20px", Et = /* @__PURE__ */ M({
|
|
386
386
|
__name: "TopNTableRenderer",
|
|
387
387
|
props: {
|
|
388
388
|
query: {},
|
|
@@ -392,40 +392,40 @@ const $ = {
|
|
|
392
392
|
height: {},
|
|
393
393
|
refreshCounter: {}
|
|
394
394
|
},
|
|
395
|
-
setup(
|
|
396
|
-
const
|
|
397
|
-
var
|
|
398
|
-
if ((
|
|
399
|
-
if (
|
|
400
|
-
const [
|
|
401
|
-
return
|
|
395
|
+
setup(c) {
|
|
396
|
+
const e = c, { evaluateFeatureFlag: t } = F.useEvaluateFeatureFlag(), i = t("ma-3043-analytics-chart-kebab-menu", !1), s = (r) => {
|
|
397
|
+
var o;
|
|
398
|
+
if ((o = e.chartOptions) != null && o.entityLink)
|
|
399
|
+
if (r.id.includes(":")) {
|
|
400
|
+
const [n, l] = r.id.split(":");
|
|
401
|
+
return e.chartOptions.entityLink.replace(dt, n).replace(pe, l);
|
|
402
402
|
} else
|
|
403
|
-
return
|
|
403
|
+
return e.chartOptions.entityLink.replace(pe, r.id);
|
|
404
404
|
return "";
|
|
405
405
|
};
|
|
406
|
-
return (
|
|
407
|
-
context:
|
|
408
|
-
query:
|
|
409
|
-
"query-ready":
|
|
410
|
-
"refresh-counter":
|
|
406
|
+
return (r, o) => (E(), T(de, {
|
|
407
|
+
context: r.context,
|
|
408
|
+
query: r.query,
|
|
409
|
+
"query-ready": r.queryReady,
|
|
410
|
+
"refresh-counter": r.refreshCounter
|
|
411
411
|
}, {
|
|
412
|
-
default:
|
|
413
|
-
|
|
414
|
-
data:
|
|
415
|
-
description: !
|
|
416
|
-
"synthetics-data-key":
|
|
417
|
-
title: !
|
|
418
|
-
},
|
|
419
|
-
|
|
412
|
+
default: H(({ data: n }) => [
|
|
413
|
+
$(x(We), {
|
|
414
|
+
data: n,
|
|
415
|
+
description: !x(i) && r.chartOptions.description || "",
|
|
416
|
+
"synthetics-data-key": r.chartOptions.syntheticsDataKey,
|
|
417
|
+
title: !x(i) && r.chartOptions.chartTitle || ""
|
|
418
|
+
}, Ce({ _: 2 }, [
|
|
419
|
+
e.chartOptions.entityLink ? {
|
|
420
420
|
name: "name",
|
|
421
|
-
fn:
|
|
422
|
-
|
|
421
|
+
fn: H(({ record: l }) => [
|
|
422
|
+
$(x(Je), {
|
|
423
423
|
"entity-link-data": {
|
|
424
|
-
id:
|
|
425
|
-
label:
|
|
426
|
-
deleted:
|
|
424
|
+
id: l.id,
|
|
425
|
+
label: l.name,
|
|
426
|
+
deleted: l.deleted
|
|
427
427
|
},
|
|
428
|
-
"external-link": s(
|
|
428
|
+
"external-link": s(l)
|
|
429
429
|
}, null, 8, ["entity-link-data", "external-link"])
|
|
430
430
|
]),
|
|
431
431
|
key: "0"
|
|
@@ -435,178 +435,178 @@ const $ = {
|
|
|
435
435
|
_: 1
|
|
436
436
|
}, 8, ["context", "query", "query-ready", "refresh-counter"]));
|
|
437
437
|
}
|
|
438
|
-
}),
|
|
438
|
+
}), xt = ["data-testid"], Ct = {
|
|
439
439
|
key: 0,
|
|
440
440
|
class: "tile-header"
|
|
441
|
-
},
|
|
441
|
+
}, Rt = ["data-testid"], Dt = ["data-testid"], zt = ["data-testid"], St = ["data-testid"], Tt = ["data-testid"], kt = /* @__PURE__ */ M({
|
|
442
442
|
__name: "DashboardTile",
|
|
443
443
|
props: {
|
|
444
444
|
definition: {},
|
|
445
445
|
context: {},
|
|
446
|
-
height: { default:
|
|
446
|
+
height: { default: he },
|
|
447
447
|
queryReady: { type: Boolean },
|
|
448
448
|
refreshCounter: {},
|
|
449
449
|
tileId: {}
|
|
450
450
|
},
|
|
451
451
|
emits: ["edit-tile"],
|
|
452
|
-
setup(
|
|
453
|
-
|
|
454
|
-
|
|
452
|
+
setup(c, { emit: e }) {
|
|
453
|
+
oe((y) => ({
|
|
454
|
+
bb9f837a: `${y.height}px`
|
|
455
455
|
}));
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
const
|
|
459
|
-
filters: [...
|
|
460
|
-
metrics:
|
|
461
|
-
dimensions:
|
|
462
|
-
time_range:
|
|
463
|
-
granularity:
|
|
464
|
-
},
|
|
465
|
-
return `${
|
|
456
|
+
const t = parseInt(He, 10), i = c, s = e, r = j(Q), { evaluateFeatureFlag: o } = F.useEvaluateFeatureFlag(), { i18n: n } = F.useI18n(), l = o("ma-3043-analytics-chart-kebab-menu", !1), h = U(), d = U(!1), u = S(() => {
|
|
457
|
+
if (r && r.exploreBaseUrl) {
|
|
458
|
+
const y = {
|
|
459
|
+
filters: [...i.context.filters, ...i.definition.query.filters ?? []],
|
|
460
|
+
metrics: i.definition.query.metrics ?? [],
|
|
461
|
+
dimensions: i.definition.query.dimensions ?? [],
|
|
462
|
+
time_range: i.definition.query.time_range || i.context.timeSpec,
|
|
463
|
+
granularity: i.definition.query.granularity || w.value
|
|
464
|
+
}, q = ["advanced", "ai"].includes(i.definition.query.datasource) ? i.definition.query.datasource : "advanced";
|
|
465
|
+
return `${r.exploreBaseUrl()}?q=${JSON.stringify(y)}&d=${q}&c=${i.definition.chart.type}`;
|
|
466
466
|
}
|
|
467
467
|
return "";
|
|
468
|
-
}),
|
|
469
|
-
timeseries_line:
|
|
470
|
-
timeseries_bar:
|
|
471
|
-
horizontal_bar:
|
|
472
|
-
vertical_bar:
|
|
473
|
-
gauge:
|
|
474
|
-
golden_signals:
|
|
475
|
-
top_n:
|
|
468
|
+
}), f = S(() => n.t("csvExport.defaultFilename")), _ = S(() => l && !["golden_signals", "top_n", "gauge"].includes(i.definition.chart.type)), v = {
|
|
469
|
+
timeseries_line: ye,
|
|
470
|
+
timeseries_bar: ye,
|
|
471
|
+
horizontal_bar: me,
|
|
472
|
+
vertical_bar: me,
|
|
473
|
+
gauge: mt,
|
|
474
|
+
golden_signals: wt,
|
|
475
|
+
top_n: Et,
|
|
476
476
|
slottable: void 0
|
|
477
|
-
},
|
|
478
|
-
const
|
|
479
|
-
return
|
|
480
|
-
component:
|
|
477
|
+
}, b = S(() => {
|
|
478
|
+
const y = v[i.definition.chart.type];
|
|
479
|
+
return y && {
|
|
480
|
+
component: y,
|
|
481
481
|
rendererProps: {
|
|
482
|
-
query:
|
|
483
|
-
context:
|
|
484
|
-
queryReady:
|
|
485
|
-
chartOptions:
|
|
486
|
-
height:
|
|
487
|
-
refreshCounter:
|
|
482
|
+
query: i.definition.query,
|
|
483
|
+
context: i.context,
|
|
484
|
+
queryReady: i.queryReady,
|
|
485
|
+
chartOptions: i.definition.chart,
|
|
486
|
+
height: i.height - t * 2,
|
|
487
|
+
refreshCounter: i.refreshCounter
|
|
488
488
|
}
|
|
489
489
|
};
|
|
490
|
-
}),
|
|
491
|
-
var
|
|
492
|
-
const
|
|
493
|
-
if ((
|
|
494
|
-
const
|
|
495
|
-
return
|
|
496
|
-
} else if ((
|
|
497
|
-
const
|
|
498
|
-
return `${
|
|
490
|
+
}), p = S(() => {
|
|
491
|
+
var q;
|
|
492
|
+
const y = (q = i.definition.query) == null ? void 0 : q.time_range;
|
|
493
|
+
if ((y == null ? void 0 : y.type) === "relative") {
|
|
494
|
+
const N = Te.get(Ue[y.time_range]);
|
|
495
|
+
return N ? N.display : (console.warn("Did not recognize the given relative time range:", y.time_range), y.time_range);
|
|
496
|
+
} else if ((y == null ? void 0 : y.type) === "absolute") {
|
|
497
|
+
const N = y.tz || "Etc/UTC";
|
|
498
|
+
return `${ge(y.start, { short: !0, tz: N })} - ${ge(y.end, { short: !0, tz: N })}`;
|
|
499
499
|
}
|
|
500
500
|
return null;
|
|
501
|
-
}),
|
|
502
|
-
s("edit-tile",
|
|
503
|
-
},
|
|
504
|
-
|
|
505
|
-
},
|
|
506
|
-
|
|
507
|
-
},
|
|
508
|
-
|
|
501
|
+
}), w = S(() => h.value ? $e(h.value.meta.granularity_ms) : void 0), C = () => {
|
|
502
|
+
s("edit-tile", i.definition);
|
|
503
|
+
}, D = (y) => {
|
|
504
|
+
h.value = y;
|
|
505
|
+
}, z = (y) => {
|
|
506
|
+
d.value = y;
|
|
507
|
+
}, R = () => {
|
|
508
|
+
z(!0);
|
|
509
509
|
};
|
|
510
|
-
return (
|
|
511
|
-
const
|
|
512
|
-
return
|
|
510
|
+
return (y, q) => {
|
|
511
|
+
const N = W("KBadge"), J = W("KDropdownItem"), Le = W("KDropdown");
|
|
512
|
+
return E(), L("div", {
|
|
513
513
|
class: "tile-boundary",
|
|
514
|
-
"data-testid": `tile-${
|
|
514
|
+
"data-testid": `tile-${y.tileId}`
|
|
515
515
|
}, [
|
|
516
|
-
l
|
|
516
|
+
x(l) && y.definition.chart.type !== "slottable" ? (E(), L("div", Ct, [
|
|
517
517
|
K("div", {
|
|
518
518
|
class: "title",
|
|
519
|
-
"data-testid": `tile-title-${
|
|
520
|
-
},
|
|
521
|
-
|
|
519
|
+
"data-testid": `tile-title-${y.tileId}`
|
|
520
|
+
}, G(y.definition.chart.chartTitle), 9, Rt),
|
|
521
|
+
_.value || p.value ? (E(), L("div", {
|
|
522
522
|
key: 0,
|
|
523
523
|
class: "tile-actions",
|
|
524
|
-
"data-testid": `tile-actions-${
|
|
524
|
+
"data-testid": `tile-actions-${y.tileId}`
|
|
525
525
|
}, [
|
|
526
|
-
|
|
527
|
-
default:
|
|
528
|
-
|
|
526
|
+
p.value ? (E(), T(N, { key: 0 }, {
|
|
527
|
+
default: H(() => [
|
|
528
|
+
re(G(p.value), 1)
|
|
529
529
|
]),
|
|
530
530
|
_: 1
|
|
531
|
-
})) :
|
|
532
|
-
|
|
531
|
+
})) : I("", !0),
|
|
532
|
+
_.value && y.context.editable ? (E(), T(x(Ze), {
|
|
533
533
|
key: 1,
|
|
534
534
|
class: "edit-icon",
|
|
535
|
-
color:
|
|
536
|
-
"data-testid": `edit-tile-${
|
|
537
|
-
size:
|
|
538
|
-
onClick:
|
|
539
|
-
}, null, 8, ["color", "data-testid", "size"])) :
|
|
540
|
-
|
|
535
|
+
color: x(_e),
|
|
536
|
+
"data-testid": `edit-tile-${y.tileId}`,
|
|
537
|
+
size: x(ve),
|
|
538
|
+
onClick: C
|
|
539
|
+
}, null, 8, ["color", "data-testid", "size"])) : I("", !0),
|
|
540
|
+
_.value ? (E(), T(Le, {
|
|
541
541
|
key: 2,
|
|
542
542
|
class: "dropdown",
|
|
543
|
-
"data-testid": `chart-action-menu-${
|
|
543
|
+
"data-testid": `chart-action-menu-${y.tileId}`,
|
|
544
544
|
"kpop-attributes": { placement: "bottom-end" }
|
|
545
545
|
}, {
|
|
546
|
-
items:
|
|
547
|
-
|
|
546
|
+
items: H(() => [
|
|
547
|
+
u.value ? (E(), T(J, {
|
|
548
548
|
key: 0,
|
|
549
|
-
"data-testid": `chart-jump-to-explore-${
|
|
550
|
-
item: { label:
|
|
551
|
-
}, null, 8, ["data-testid", "item"])) :
|
|
552
|
-
"allowCsvExport" in
|
|
549
|
+
"data-testid": `chart-jump-to-explore-${y.tileId}`,
|
|
550
|
+
item: { label: x(n).t("jumpToExplore"), to: u.value }
|
|
551
|
+
}, null, 8, ["data-testid", "item"])) : I("", !0),
|
|
552
|
+
"allowCsvExport" in y.definition.chart && y.definition.chart.allowCsvExport ? (E(), T(J, {
|
|
553
553
|
key: 1,
|
|
554
554
|
class: "chart-export-button",
|
|
555
|
-
"data-testid": `chart-csv-export-${
|
|
556
|
-
onClick:
|
|
555
|
+
"data-testid": `chart-csv-export-${y.tileId}`,
|
|
556
|
+
onClick: q[0] || (q[0] = (Wt) => R())
|
|
557
557
|
}, {
|
|
558
|
-
default:
|
|
558
|
+
default: H(() => [
|
|
559
559
|
K("span", {
|
|
560
560
|
class: "chart-export-trigger",
|
|
561
|
-
"data-testid": `csv-export-button-${
|
|
562
|
-
},
|
|
561
|
+
"data-testid": `csv-export-button-${y.tileId}`
|
|
562
|
+
}, G(x(n).t("csvExport.exportAsCsv")), 9, zt)
|
|
563
563
|
]),
|
|
564
564
|
_: 1
|
|
565
|
-
}, 8, ["data-testid"])) :
|
|
565
|
+
}, 8, ["data-testid"])) : I("", !0)
|
|
566
566
|
]),
|
|
567
|
-
default:
|
|
568
|
-
|
|
567
|
+
default: H(() => [
|
|
568
|
+
$(x(et), {
|
|
569
569
|
class: "kebab-action-menu",
|
|
570
|
-
color:
|
|
571
|
-
"data-testid": `kebab-action-menu-${
|
|
572
|
-
size:
|
|
570
|
+
color: x(_e),
|
|
571
|
+
"data-testid": `kebab-action-menu-${y.tileId}`,
|
|
572
|
+
size: x(ve)
|
|
573
573
|
}, null, 8, ["color", "data-testid", "size"])
|
|
574
574
|
]),
|
|
575
575
|
_: 1
|
|
576
|
-
}, 8, ["data-testid"])) :
|
|
577
|
-
], 8,
|
|
576
|
+
}, 8, ["data-testid"])) : I("", !0)
|
|
577
|
+
], 8, Dt)) : "description" in y.definition.chart ? (E(), L("div", {
|
|
578
578
|
key: 1,
|
|
579
579
|
class: "header-description",
|
|
580
|
-
"data-testid": `tile-description-${
|
|
581
|
-
},
|
|
582
|
-
|
|
580
|
+
"data-testid": `tile-description-${y.tileId}`
|
|
581
|
+
}, G(y.definition.chart.description), 9, St)) : I("", !0),
|
|
582
|
+
d.value ? (E(), T(x(Ke), {
|
|
583
583
|
key: 2,
|
|
584
|
-
"chart-data":
|
|
585
|
-
"data-testid": `csv-export-modal-${
|
|
586
|
-
filename:
|
|
587
|
-
onToggleModal:
|
|
588
|
-
}, null, 8, ["chart-data", "data-testid", "filename"])) :
|
|
589
|
-
])) :
|
|
584
|
+
"chart-data": h.value,
|
|
585
|
+
"data-testid": `csv-export-modal-${y.tileId}`,
|
|
586
|
+
filename: f.value,
|
|
587
|
+
onToggleModal: z
|
|
588
|
+
}, null, 8, ["chart-data", "data-testid", "filename"])) : I("", !0)
|
|
589
|
+
])) : I("", !0),
|
|
590
590
|
K("div", {
|
|
591
591
|
class: "tile-content",
|
|
592
|
-
"data-testid": `tile-content-${
|
|
592
|
+
"data-testid": `tile-content-${y.tileId}`
|
|
593
593
|
}, [
|
|
594
|
-
|
|
595
|
-
], 8,
|
|
596
|
-
], 8,
|
|
594
|
+
b.value ? (E(), T(Re(b.value.component), xe({ key: 0 }, b.value.rendererProps, { onChartData: D }), null, 16)) : I("", !0)
|
|
595
|
+
], 8, Tt)
|
|
596
|
+
], 8, xt);
|
|
597
597
|
};
|
|
598
598
|
}
|
|
599
|
-
}),
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
const
|
|
603
|
-
|
|
599
|
+
}), Nt = /* @__PURE__ */ V(kt, [["__scopeId", "data-v-12d69e34"]]), Ht = (c, e, t) => {
|
|
600
|
+
const i = /* @__PURE__ */ new Map();
|
|
601
|
+
t.forEach((r) => {
|
|
602
|
+
const o = r.layout.position.row, n = i.get(o), l = r.layout.size.rows === 1 && !!r.layout.size.fitToContent;
|
|
603
|
+
n === void 0 ? i.set(o, l) : i.set(o, n && l);
|
|
604
604
|
});
|
|
605
605
|
const s = [];
|
|
606
|
-
for (let
|
|
607
|
-
|
|
606
|
+
for (let r = 0; r < c; r++)
|
|
607
|
+
i.get(r) ? s.push("auto") : s.push(`${e}px`);
|
|
608
608
|
return s;
|
|
609
|
-
},
|
|
609
|
+
}, At = /* @__PURE__ */ M({
|
|
610
610
|
__name: "GridLayout",
|
|
611
611
|
props: {
|
|
612
612
|
gridSize: {
|
|
@@ -616,157 +616,2956 @@ const $ = {
|
|
|
616
616
|
tileHeight: {
|
|
617
617
|
type: Number,
|
|
618
618
|
required: !1,
|
|
619
|
-
default: () =>
|
|
619
|
+
default: () => he
|
|
620
620
|
},
|
|
621
621
|
tiles: {
|
|
622
622
|
type: Array,
|
|
623
623
|
required: !0
|
|
624
624
|
}
|
|
625
625
|
},
|
|
626
|
-
setup(
|
|
627
|
-
|
|
628
|
-
"3bc5e939":
|
|
629
|
-
"77aa3028":
|
|
626
|
+
setup(c) {
|
|
627
|
+
oe((n) => ({
|
|
628
|
+
"3bc5e939": c.gridSize.cols,
|
|
629
|
+
"77aa3028": r.value
|
|
630
630
|
}));
|
|
631
|
-
const
|
|
631
|
+
const e = c, t = U(null), i = U(0), s = new ResizeObserver((n) => {
|
|
632
632
|
window.requestAnimationFrame(() => {
|
|
633
|
-
!Array.isArray(
|
|
633
|
+
!Array.isArray(n) || !n.length || (i.value = n[0].contentRect.width);
|
|
634
634
|
});
|
|
635
635
|
});
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}),
|
|
639
|
-
|
|
636
|
+
De(() => {
|
|
637
|
+
t.value && s.observe(t.value);
|
|
638
|
+
}), le(() => {
|
|
639
|
+
t.value && s.unobserve(t.value);
|
|
640
640
|
});
|
|
641
|
-
const
|
|
642
|
-
var
|
|
643
|
-
return
|
|
644
|
-
}),
|
|
645
|
-
key: `tile-${
|
|
646
|
-
tile:
|
|
641
|
+
const r = S(() => {
|
|
642
|
+
var l;
|
|
643
|
+
return Ht((l = e.gridSize) == null ? void 0 : l.rows, e.tileHeight, e.tiles).join(" ");
|
|
644
|
+
}), o = S(() => e.tiles.map((n, l) => ({
|
|
645
|
+
key: `tile-${l}`,
|
|
646
|
+
tile: n,
|
|
647
647
|
style: {
|
|
648
|
-
"grid-column-start":
|
|
649
|
-
"grid-column-end":
|
|
650
|
-
"grid-row-start":
|
|
651
|
-
"grid-row-end":
|
|
648
|
+
"grid-column-start": n.layout.position.col + 1,
|
|
649
|
+
"grid-column-end": n.layout.position.col + 1 + n.layout.size.cols,
|
|
650
|
+
"grid-row-start": n.layout.position.row + 1,
|
|
651
|
+
"grid-row-end": n.layout.position.row + 1 + n.layout.size.rows
|
|
652
652
|
}
|
|
653
653
|
})));
|
|
654
|
-
return (
|
|
654
|
+
return (n, l) => (E(), L("div", {
|
|
655
655
|
ref_key: "gridContainer",
|
|
656
|
-
ref:
|
|
656
|
+
ref: t,
|
|
657
657
|
class: "kong-ui-public-grid-layout"
|
|
658
658
|
}, [
|
|
659
|
-
(
|
|
660
|
-
key:
|
|
661
|
-
class:
|
|
662
|
-
"empty-cell": !
|
|
659
|
+
(E(!0), L(ze, null, Se(o.value, (h) => (E(), L("div", {
|
|
660
|
+
key: h.key,
|
|
661
|
+
class: Pe(["grid-cell", {
|
|
662
|
+
"empty-cell": !h.tile
|
|
663
663
|
}]),
|
|
664
|
-
style:
|
|
664
|
+
style: fe(h.style)
|
|
665
665
|
}, [
|
|
666
|
-
|
|
667
|
-
style:
|
|
668
|
-
tile:
|
|
666
|
+
ne(n.$slots, "tile", {
|
|
667
|
+
style: fe(h.style),
|
|
668
|
+
tile: h.tile
|
|
669
669
|
}, void 0, !0)
|
|
670
670
|
], 6))), 128))
|
|
671
671
|
], 512));
|
|
672
672
|
}
|
|
673
|
-
}),
|
|
673
|
+
}), Lt = /* @__PURE__ */ V(At, [["__scopeId", "data-v-f43eb7b8"]]);
|
|
674
|
+
function Ot(c, e, t, i, s) {
|
|
675
|
+
const r = (...o) => (console.warn("gridstack.js: Function `" + t + "` is deprecated in " + s + " and has been replaced with `" + i + "`. It will be **removed** in a future release"), e.apply(c, o));
|
|
676
|
+
return r.prototype = e.prototype, r;
|
|
677
|
+
}
|
|
678
|
+
class a {
|
|
679
|
+
/** convert a potential selector into actual list of html elements. optional root which defaults to document (for shadow dom) */
|
|
680
|
+
static getElements(e, t = document) {
|
|
681
|
+
if (typeof e == "string") {
|
|
682
|
+
const i = "getElementById" in t ? t : void 0;
|
|
683
|
+
if (i && !isNaN(+e[0])) {
|
|
684
|
+
const r = i.getElementById(e);
|
|
685
|
+
return r ? [r] : [];
|
|
686
|
+
}
|
|
687
|
+
let s = t.querySelectorAll(e);
|
|
688
|
+
return !s.length && e[0] !== "." && e[0] !== "#" && (s = t.querySelectorAll("." + e), s.length || (s = t.querySelectorAll("#" + e))), Array.from(s);
|
|
689
|
+
}
|
|
690
|
+
return [e];
|
|
691
|
+
}
|
|
692
|
+
/** convert a potential selector into actual single element. optional root which defaults to document (for shadow dom) */
|
|
693
|
+
static getElement(e, t = document) {
|
|
694
|
+
if (typeof e == "string") {
|
|
695
|
+
const i = "getElementById" in t ? t : void 0;
|
|
696
|
+
if (!e.length)
|
|
697
|
+
return null;
|
|
698
|
+
if (i && e[0] === "#")
|
|
699
|
+
return i.getElementById(e.substring(1));
|
|
700
|
+
if (e[0] === "#" || e[0] === "." || e[0] === "[")
|
|
701
|
+
return t.querySelector(e);
|
|
702
|
+
if (i && !isNaN(+e[0]))
|
|
703
|
+
return i.getElementById(e);
|
|
704
|
+
let s = t.querySelector(e);
|
|
705
|
+
return i && !s && (s = i.getElementById(e)), s || (s = t.querySelector("." + e)), s;
|
|
706
|
+
}
|
|
707
|
+
return e;
|
|
708
|
+
}
|
|
709
|
+
/** create the default grid item divs, and content possibly lazy loaded calling GridStack.renderCB */
|
|
710
|
+
static createWidgetDivs(e, t) {
|
|
711
|
+
var o, n;
|
|
712
|
+
const i = a.createDiv(["grid-stack-item", e]), s = a.createDiv(["grid-stack-item-content"], i);
|
|
713
|
+
return t.lazyLoad || ((n = (o = t.grid) == null ? void 0 : o.opts) == null ? void 0 : n.lazyLoad) && t.lazyLoad !== !1 ? t.visibleObservable || (t.visibleObservable = new IntersectionObserver(([l]) => {
|
|
714
|
+
var h;
|
|
715
|
+
l.isIntersecting && ((h = t.visibleObservable) == null || h.disconnect(), delete t.visibleObservable, g.renderCB(s, t));
|
|
716
|
+
}), window.setTimeout(() => {
|
|
717
|
+
var l;
|
|
718
|
+
return (l = t.visibleObservable) == null ? void 0 : l.observe(i);
|
|
719
|
+
})) : g.renderCB(s, t), i;
|
|
720
|
+
}
|
|
721
|
+
/** create a div with the given classes */
|
|
722
|
+
static createDiv(e, t) {
|
|
723
|
+
const i = document.createElement("div");
|
|
724
|
+
return e.forEach((s) => {
|
|
725
|
+
s && i.classList.add(s);
|
|
726
|
+
}), t == null || t.appendChild(i), i;
|
|
727
|
+
}
|
|
728
|
+
/** true if we should resize to content. strict=true when only 'sizeToContent:true' and not a number which lets user adjust */
|
|
729
|
+
static shouldSizeToContent(e, t = !1) {
|
|
730
|
+
return (e == null ? void 0 : e.grid) && (t ? e.sizeToContent === !0 || e.grid.opts.sizeToContent === !0 && e.sizeToContent === void 0 : !!e.sizeToContent || e.grid.opts.sizeToContent && e.sizeToContent !== !1);
|
|
731
|
+
}
|
|
732
|
+
/** returns true if a and b overlap */
|
|
733
|
+
static isIntercepted(e, t) {
|
|
734
|
+
return !(e.y >= t.y + t.h || e.y + e.h <= t.y || e.x + e.w <= t.x || e.x >= t.x + t.w);
|
|
735
|
+
}
|
|
736
|
+
/** returns true if a and b touch edges or corners */
|
|
737
|
+
static isTouching(e, t) {
|
|
738
|
+
return a.isIntercepted(e, { x: t.x - 0.5, y: t.y - 0.5, w: t.w + 1, h: t.h + 1 });
|
|
739
|
+
}
|
|
740
|
+
/** returns the area a and b overlap */
|
|
741
|
+
static areaIntercept(e, t) {
|
|
742
|
+
const i = e.x > t.x ? e.x : t.x, s = e.x + e.w < t.x + t.w ? e.x + e.w : t.x + t.w;
|
|
743
|
+
if (s <= i)
|
|
744
|
+
return 0;
|
|
745
|
+
const r = e.y > t.y ? e.y : t.y, o = e.y + e.h < t.y + t.h ? e.y + e.h : t.y + t.h;
|
|
746
|
+
return o <= r ? 0 : (s - i) * (o - r);
|
|
747
|
+
}
|
|
748
|
+
/** returns the area */
|
|
749
|
+
static area(e) {
|
|
750
|
+
return e.w * e.h;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Sorts array of nodes
|
|
754
|
+
* @param nodes array to sort
|
|
755
|
+
* @param dir 1 for ascending, -1 for descending (optional)
|
|
756
|
+
**/
|
|
757
|
+
static sort(e, t = 1) {
|
|
758
|
+
return e.sort((s, r) => {
|
|
759
|
+
const o = t * ((s.y ?? 1e4) - (r.y ?? 1e4));
|
|
760
|
+
return o === 0 ? t * ((s.x ?? 1e4) - (r.x ?? 1e4)) : o;
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
/** find an item by id */
|
|
764
|
+
static find(e, t) {
|
|
765
|
+
return t ? e.find((i) => i.id === t) : void 0;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* creates a style sheet with style id under given parent
|
|
769
|
+
* @param id will set the 'gs-style-id' attribute to that id
|
|
770
|
+
* @param parent to insert the stylesheet as first child,
|
|
771
|
+
* if none supplied it will be appended to the document head instead.
|
|
772
|
+
*/
|
|
773
|
+
static createStylesheet(e, t, i) {
|
|
774
|
+
const s = document.createElement("style"), r = i == null ? void 0 : i.nonce;
|
|
775
|
+
return r && (s.nonce = r), s.setAttribute("type", "text/css"), s.setAttribute("gs-style-id", e), s.styleSheet ? s.styleSheet.cssText = "" : s.appendChild(document.createTextNode("")), t ? t.insertBefore(s, t.firstChild) : (t = document.getElementsByTagName("head")[0], t.appendChild(s)), s;
|
|
776
|
+
}
|
|
777
|
+
/** removed the given stylesheet id */
|
|
778
|
+
static removeStylesheet(e, t) {
|
|
779
|
+
const s = (t || document).querySelector("STYLE[gs-style-id=" + e + "]");
|
|
780
|
+
s && s.parentNode && s.remove();
|
|
781
|
+
}
|
|
782
|
+
/** inserts a CSS rule */
|
|
783
|
+
static addCSSRule(e, t, i) {
|
|
784
|
+
e.textContent += `${t} { ${i} } `;
|
|
785
|
+
}
|
|
786
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
787
|
+
static toBool(e) {
|
|
788
|
+
return typeof e == "boolean" ? e : typeof e == "string" ? (e = e.toLowerCase(), !(e === "" || e === "no" || e === "false" || e === "0")) : !!e;
|
|
789
|
+
}
|
|
790
|
+
static toNumber(e) {
|
|
791
|
+
return e === null || e.length === 0 ? void 0 : Number(e);
|
|
792
|
+
}
|
|
793
|
+
static parseHeight(e) {
|
|
794
|
+
let t, i = "px";
|
|
795
|
+
if (typeof e == "string")
|
|
796
|
+
if (e === "auto" || e === "")
|
|
797
|
+
t = 0;
|
|
798
|
+
else {
|
|
799
|
+
const s = e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);
|
|
800
|
+
if (!s)
|
|
801
|
+
throw new Error(`Invalid height val = ${e}`);
|
|
802
|
+
i = s[2] || "px", t = parseFloat(s[1]);
|
|
803
|
+
}
|
|
804
|
+
else
|
|
805
|
+
t = e;
|
|
806
|
+
return { h: t, unit: i };
|
|
807
|
+
}
|
|
808
|
+
/** copies unset fields in target to use the given default sources values */
|
|
809
|
+
// eslint-disable-next-line
|
|
810
|
+
static defaults(e, ...t) {
|
|
811
|
+
return t.forEach((i) => {
|
|
812
|
+
for (const s in i) {
|
|
813
|
+
if (!i.hasOwnProperty(s))
|
|
814
|
+
return;
|
|
815
|
+
e[s] === null || e[s] === void 0 ? e[s] = i[s] : typeof i[s] == "object" && typeof e[s] == "object" && this.defaults(e[s], i[s]);
|
|
816
|
+
}
|
|
817
|
+
}), e;
|
|
818
|
+
}
|
|
819
|
+
/** given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) */
|
|
820
|
+
static same(e, t) {
|
|
821
|
+
if (typeof e != "object")
|
|
822
|
+
return e == t;
|
|
823
|
+
if (typeof e != typeof t || Object.keys(e).length !== Object.keys(t).length)
|
|
824
|
+
return !1;
|
|
825
|
+
for (const i in e)
|
|
826
|
+
if (e[i] !== t[i])
|
|
827
|
+
return !1;
|
|
828
|
+
return !0;
|
|
829
|
+
}
|
|
830
|
+
/** copies over b size & position (GridStackPosition), and optionally min/max as well */
|
|
831
|
+
static copyPos(e, t, i = !1) {
|
|
832
|
+
return t.x !== void 0 && (e.x = t.x), t.y !== void 0 && (e.y = t.y), t.w !== void 0 && (e.w = t.w), t.h !== void 0 && (e.h = t.h), i && (t.minW && (e.minW = t.minW), t.minH && (e.minH = t.minH), t.maxW && (e.maxW = t.maxW), t.maxH && (e.maxH = t.maxH)), e;
|
|
833
|
+
}
|
|
834
|
+
/** true if a and b has same size & position */
|
|
835
|
+
static samePos(e, t) {
|
|
836
|
+
return e && t && e.x === t.x && e.y === t.y && (e.w || 1) === (t.w || 1) && (e.h || 1) === (t.h || 1);
|
|
837
|
+
}
|
|
838
|
+
/** given a node, makes sure it's min/max are valid */
|
|
839
|
+
static sanitizeMinMax(e) {
|
|
840
|
+
e.minW || delete e.minW, e.minH || delete e.minH, e.maxW || delete e.maxW, e.maxH || delete e.maxH;
|
|
841
|
+
}
|
|
842
|
+
/** removes field from the first object if same as the second objects (like diffing) and internal '_' for saving */
|
|
843
|
+
static removeInternalAndSame(e, t) {
|
|
844
|
+
if (!(typeof e != "object" || typeof t != "object"))
|
|
845
|
+
for (let i in e) {
|
|
846
|
+
const s = e[i], r = t[i];
|
|
847
|
+
i[0] === "_" || s === r ? delete e[i] : s && typeof s == "object" && r !== void 0 && (a.removeInternalAndSame(s, r), Object.keys(s).length || delete e[i]);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
/** removes internal fields '_' and default values for saving */
|
|
851
|
+
static removeInternalForSave(e, t = !0) {
|
|
852
|
+
for (let i in e)
|
|
853
|
+
(i[0] === "_" || e[i] === null || e[i] === void 0) && delete e[i];
|
|
854
|
+
delete e.grid, t && delete e.el, e.autoPosition || delete e.autoPosition, e.noResize || delete e.noResize, e.noMove || delete e.noMove, e.locked || delete e.locked, (e.w === 1 || e.w === e.minW) && delete e.w, (e.h === 1 || e.h === e.minH) && delete e.h;
|
|
855
|
+
}
|
|
856
|
+
/** return the closest parent (or itself) matching the given class */
|
|
857
|
+
// static closestUpByClass(el: HTMLElement, name: string): HTMLElement {
|
|
858
|
+
// while (el) {
|
|
859
|
+
// if (el.classList.contains(name)) return el;
|
|
860
|
+
// el = el.parentElement
|
|
861
|
+
// }
|
|
862
|
+
// return null;
|
|
863
|
+
// }
|
|
864
|
+
/** delay calling the given function for given delay, preventing new calls from happening while waiting */
|
|
865
|
+
static throttle(e, t) {
|
|
866
|
+
let i = !1;
|
|
867
|
+
return (...s) => {
|
|
868
|
+
i || (i = !0, setTimeout(() => {
|
|
869
|
+
e(...s), i = !1;
|
|
870
|
+
}, t));
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
static removePositioningStyles(e) {
|
|
874
|
+
const t = e.style;
|
|
875
|
+
t.position && t.removeProperty("position"), t.left && t.removeProperty("left"), t.top && t.removeProperty("top"), t.width && t.removeProperty("width"), t.height && t.removeProperty("height");
|
|
876
|
+
}
|
|
877
|
+
/** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */
|
|
878
|
+
static getScrollElement(e) {
|
|
879
|
+
if (!e)
|
|
880
|
+
return document.scrollingElement || document.documentElement;
|
|
881
|
+
const t = getComputedStyle(e);
|
|
882
|
+
return /(auto|scroll)/.test(t.overflow + t.overflowY) ? e : this.getScrollElement(e.parentElement);
|
|
883
|
+
}
|
|
884
|
+
/** @internal */
|
|
885
|
+
static updateScrollPosition(e, t, i) {
|
|
886
|
+
const s = e.getBoundingClientRect(), r = window.innerHeight || document.documentElement.clientHeight;
|
|
887
|
+
if (s.top < 0 || s.bottom > r) {
|
|
888
|
+
const o = s.bottom - r, n = s.top, l = this.getScrollElement(e);
|
|
889
|
+
if (l !== null) {
|
|
890
|
+
const h = l.scrollTop;
|
|
891
|
+
s.top < 0 && i < 0 ? e.offsetHeight > r ? l.scrollTop += i : l.scrollTop += Math.abs(n) > Math.abs(i) ? i : n : i > 0 && (e.offsetHeight > r ? l.scrollTop += i : l.scrollTop += o > i ? i : o), t.top += l.scrollTop - h;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* @internal Function used to scroll the page.
|
|
897
|
+
*
|
|
898
|
+
* @param event `MouseEvent` that triggers the resize
|
|
899
|
+
* @param el `HTMLElement` that's being resized
|
|
900
|
+
* @param distance Distance from the V edges to start scrolling
|
|
901
|
+
*/
|
|
902
|
+
static updateScrollResize(e, t, i) {
|
|
903
|
+
const s = this.getScrollElement(t), r = s.clientHeight, o = s === this.getScrollElement() ? 0 : s.getBoundingClientRect().top, n = e.clientY - o, l = n < i, h = n > r - i;
|
|
904
|
+
l ? s.scrollBy({ behavior: "smooth", top: n - i }) : h && s.scrollBy({ behavior: "smooth", top: i - (r - n) });
|
|
905
|
+
}
|
|
906
|
+
/** single level clone, returning a new object with same top fields. This will share sub objects and arrays */
|
|
907
|
+
static clone(e) {
|
|
908
|
+
return e == null || typeof e != "object" ? e : e instanceof Array ? [...e] : { ...e };
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY.
|
|
912
|
+
* Note: this will use as-is any key starting with double __ (and not copy inside) some lib have circular dependencies.
|
|
913
|
+
*/
|
|
914
|
+
static cloneDeep(e) {
|
|
915
|
+
const t = ["parentGrid", "el", "grid", "subGrid", "engine"], i = a.clone(e);
|
|
916
|
+
for (const s in i)
|
|
917
|
+
i.hasOwnProperty(s) && typeof i[s] == "object" && s.substring(0, 2) !== "__" && !t.find((r) => r === s) && (i[s] = a.cloneDeep(e[s]));
|
|
918
|
+
return i;
|
|
919
|
+
}
|
|
920
|
+
/** deep clone the given HTML node, removing teh unique id field */
|
|
921
|
+
static cloneNode(e) {
|
|
922
|
+
const t = e.cloneNode(!0);
|
|
923
|
+
return t.removeAttribute("id"), t;
|
|
924
|
+
}
|
|
925
|
+
static appendTo(e, t) {
|
|
926
|
+
let i;
|
|
927
|
+
typeof t == "string" ? i = a.getElement(t) : i = t, i && i.appendChild(e);
|
|
928
|
+
}
|
|
929
|
+
// public static setPositionRelative(el: HTMLElement): void {
|
|
930
|
+
// if (!(/^(?:r|a|f)/).test(getComputedStyle(el).position)) {
|
|
931
|
+
// el.style.position = "relative";
|
|
932
|
+
// }
|
|
933
|
+
// }
|
|
934
|
+
static addElStyles(e, t) {
|
|
935
|
+
if (t instanceof Object)
|
|
936
|
+
for (const i in t)
|
|
937
|
+
t.hasOwnProperty(i) && (Array.isArray(t[i]) ? t[i].forEach((s) => {
|
|
938
|
+
e.style[i] = s;
|
|
939
|
+
}) : e.style[i] = t[i]);
|
|
940
|
+
}
|
|
941
|
+
static initEvent(e, t) {
|
|
942
|
+
const i = { type: t.type }, s = {
|
|
943
|
+
button: 0,
|
|
944
|
+
which: 0,
|
|
945
|
+
buttons: 1,
|
|
946
|
+
bubbles: !0,
|
|
947
|
+
cancelable: !0,
|
|
948
|
+
target: t.target ? t.target : e.target
|
|
949
|
+
};
|
|
950
|
+
return ["altKey", "ctrlKey", "metaKey", "shiftKey"].forEach((r) => i[r] = e[r]), ["pageX", "pageY", "clientX", "clientY", "screenX", "screenY"].forEach((r) => i[r] = e[r]), { ...i, ...s };
|
|
951
|
+
}
|
|
952
|
+
/** copies the MouseEvent properties and sends it as another event to the given target */
|
|
953
|
+
static simulateMouseEvent(e, t, i) {
|
|
954
|
+
const s = document.createEvent("MouseEvents");
|
|
955
|
+
s.initMouseEvent(
|
|
956
|
+
t,
|
|
957
|
+
// type
|
|
958
|
+
!0,
|
|
959
|
+
// bubbles
|
|
960
|
+
!0,
|
|
961
|
+
// cancelable
|
|
962
|
+
window,
|
|
963
|
+
// view
|
|
964
|
+
1,
|
|
965
|
+
// detail
|
|
966
|
+
e.screenX,
|
|
967
|
+
// screenX
|
|
968
|
+
e.screenY,
|
|
969
|
+
// screenY
|
|
970
|
+
e.clientX,
|
|
971
|
+
// clientX
|
|
972
|
+
e.clientY,
|
|
973
|
+
// clientY
|
|
974
|
+
e.ctrlKey,
|
|
975
|
+
// ctrlKey
|
|
976
|
+
e.altKey,
|
|
977
|
+
// altKey
|
|
978
|
+
e.shiftKey,
|
|
979
|
+
// shiftKey
|
|
980
|
+
e.metaKey,
|
|
981
|
+
// metaKey
|
|
982
|
+
0,
|
|
983
|
+
// button
|
|
984
|
+
e.target
|
|
985
|
+
// relatedTarget
|
|
986
|
+
), (i || e.target).dispatchEvent(s);
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* defines an element that is used to get the offset and scale from grid transforms
|
|
990
|
+
* returns the scale and offsets from said element
|
|
991
|
+
*/
|
|
992
|
+
static getValuesFromTransformedElement(e) {
|
|
993
|
+
const t = document.createElement("div");
|
|
994
|
+
a.addElStyles(t, {
|
|
995
|
+
opacity: "0",
|
|
996
|
+
position: "fixed",
|
|
997
|
+
top: "0px",
|
|
998
|
+
left: "0px",
|
|
999
|
+
width: "1px",
|
|
1000
|
+
height: "1px",
|
|
1001
|
+
zIndex: "-999999"
|
|
1002
|
+
}), e.appendChild(t);
|
|
1003
|
+
const i = t.getBoundingClientRect();
|
|
1004
|
+
return e.removeChild(t), t.remove(), {
|
|
1005
|
+
xScale: 1 / i.width,
|
|
1006
|
+
yScale: 1 / i.height,
|
|
1007
|
+
xOffset: i.left,
|
|
1008
|
+
yOffset: i.top
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
/** swap the given object 2 field values */
|
|
1012
|
+
static swap(e, t, i) {
|
|
1013
|
+
if (!e)
|
|
1014
|
+
return;
|
|
1015
|
+
const s = e[t];
|
|
1016
|
+
e[t] = e[i], e[i] = s;
|
|
1017
|
+
}
|
|
1018
|
+
/** returns true if event is inside the given element rectangle */
|
|
1019
|
+
// Note: Safari Mac has null event.relatedTarget which causes #1684 so check if DragEvent is inside the coordinates instead
|
|
1020
|
+
// this.el.contains(event.relatedTarget as HTMLElement)
|
|
1021
|
+
// public static inside(e: MouseEvent, el: HTMLElement): boolean {
|
|
1022
|
+
// // srcElement, toElement, target: all set to placeholder when leaving simple grid, so we can't use that (Chrome)
|
|
1023
|
+
// const target: HTMLElement = e.relatedTarget || (e as any).fromElement;
|
|
1024
|
+
// if (!target) {
|
|
1025
|
+
// const { bottom, left, right, top } = el.getBoundingClientRect();
|
|
1026
|
+
// return (e.x < right && e.x > left && e.y < bottom && e.y > top);
|
|
1027
|
+
// }
|
|
1028
|
+
// return el.contains(target);
|
|
1029
|
+
// }
|
|
1030
|
+
/** true if the item can be rotated (checking for prop, not space available) */
|
|
1031
|
+
static canBeRotated(e) {
|
|
1032
|
+
var t;
|
|
1033
|
+
return !(!e || e.w === e.h || e.locked || e.noResize || (t = e.grid) != null && t.opts.disableResize || e.minW && e.minW === e.maxW || e.minH && e.minH === e.maxH);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
class P {
|
|
1037
|
+
constructor(e = {}) {
|
|
1038
|
+
this.addedNodes = [], this.removedNodes = [], this.defaultColumn = 12, this.column = e.column || this.defaultColumn, this.column > this.defaultColumn && (this.defaultColumn = this.column), this.maxRow = e.maxRow, this._float = e.float, this.nodes = e.nodes || [], this.onChange = e.onChange;
|
|
1039
|
+
}
|
|
1040
|
+
batchUpdate(e = !0, t = !0) {
|
|
1041
|
+
return !!this.batchMode === e ? this : (this.batchMode = e, e ? (this._prevFloat = this._float, this._float = !0, this.cleanNodes(), this.saveInitial()) : (this._float = this._prevFloat, delete this._prevFloat, t && this._packNodes(), this._notify()), this);
|
|
1042
|
+
}
|
|
1043
|
+
// use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip
|
|
1044
|
+
_useEntireRowArea(e, t) {
|
|
1045
|
+
return (!this.float || this.batchMode && !this._prevFloat) && !this._hasLocked && (!e._moving || e._skipDown || t.y <= e.y);
|
|
1046
|
+
}
|
|
1047
|
+
/** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.
|
|
1048
|
+
* return true if we moved. */
|
|
1049
|
+
_fixCollisions(e, t = e, i, s = {}) {
|
|
1050
|
+
if (this.sortNodes(-1), i = i || this.collide(e, t), !i)
|
|
1051
|
+
return !1;
|
|
1052
|
+
if (e._moving && !s.nested && !this.float && this.swap(e, i))
|
|
1053
|
+
return !0;
|
|
1054
|
+
let r = t;
|
|
1055
|
+
!this._loading && this._useEntireRowArea(e, t) && (r = { x: 0, w: this.column, y: t.y, h: t.h }, i = this.collide(e, r, s.skip));
|
|
1056
|
+
let o = !1;
|
|
1057
|
+
const n = { nested: !0, pack: !1 };
|
|
1058
|
+
let l = 0;
|
|
1059
|
+
for (; i = i || this.collide(e, r, s.skip); ) {
|
|
1060
|
+
if (l++ > this.nodes.length * 2)
|
|
1061
|
+
throw new Error("Infinite collide check");
|
|
1062
|
+
let h;
|
|
1063
|
+
if (i.locked || this._loading || e._moving && !e._skipDown && t.y > e.y && !this.float && // can take space we had, or before where we're going
|
|
1064
|
+
(!this.collide(i, { ...i, y: e.y }, e) || !this.collide(i, { ...i, y: t.y - i.h }, e))) {
|
|
1065
|
+
e._skipDown = e._skipDown || t.y > e.y;
|
|
1066
|
+
const d = { ...t, y: i.y + i.h, ...n };
|
|
1067
|
+
h = this._loading && a.samePos(e, d) ? !0 : this.moveNode(e, d), (i.locked || this._loading) && h ? a.copyPos(t, e) : !i.locked && h && s.pack && (this._packNodes(), t.y = i.y + i.h, a.copyPos(e, t)), o = o || h;
|
|
1068
|
+
} else
|
|
1069
|
+
h = this.moveNode(i, { ...i, y: t.y + t.h, skip: e, ...n });
|
|
1070
|
+
if (!h)
|
|
1071
|
+
return o;
|
|
1072
|
+
i = void 0;
|
|
1073
|
+
}
|
|
1074
|
+
return o;
|
|
1075
|
+
}
|
|
1076
|
+
/** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */
|
|
1077
|
+
collide(e, t = e, i) {
|
|
1078
|
+
const s = e._id, r = i == null ? void 0 : i._id;
|
|
1079
|
+
return this.nodes.find((o) => o._id !== s && o._id !== r && a.isIntercepted(o, t));
|
|
1080
|
+
}
|
|
1081
|
+
collideAll(e, t = e, i) {
|
|
1082
|
+
const s = e._id, r = i == null ? void 0 : i._id;
|
|
1083
|
+
return this.nodes.filter((o) => o._id !== s && o._id !== r && a.isIntercepted(o, t));
|
|
1084
|
+
}
|
|
1085
|
+
/** does a pixel coverage collision based on where we started, returning the node that has the most coverage that is >50% mid line */
|
|
1086
|
+
directionCollideCoverage(e, t, i) {
|
|
1087
|
+
if (!t.rect || !e._rect)
|
|
1088
|
+
return;
|
|
1089
|
+
const s = e._rect, r = { ...t.rect };
|
|
1090
|
+
r.y > s.y ? (r.h += r.y - s.y, r.y = s.y) : r.h += s.y - r.y, r.x > s.x ? (r.w += r.x - s.x, r.x = s.x) : r.w += s.x - r.x;
|
|
1091
|
+
let o, n = 0.5;
|
|
1092
|
+
for (let l of i) {
|
|
1093
|
+
if (l.locked || !l._rect)
|
|
1094
|
+
break;
|
|
1095
|
+
const h = l._rect;
|
|
1096
|
+
let d = Number.MAX_VALUE, u = Number.MAX_VALUE;
|
|
1097
|
+
s.y < h.y ? d = (r.y + r.h - h.y) / h.h : s.y + s.h > h.y + h.h && (d = (h.y + h.h - r.y) / h.h), s.x < h.x ? u = (r.x + r.w - h.x) / h.w : s.x + s.w > h.x + h.w && (u = (h.x + h.w - r.x) / h.w);
|
|
1098
|
+
const f = Math.min(u, d);
|
|
1099
|
+
f > n && (n = f, o = l);
|
|
1100
|
+
}
|
|
1101
|
+
return t.collide = o, o;
|
|
1102
|
+
}
|
|
1103
|
+
/** does a pixel coverage returning the node that has the most coverage by area */
|
|
1104
|
+
/*
|
|
1105
|
+
protected collideCoverage(r: GridStackPosition, collides: GridStackNode[]): {collide: GridStackNode, over: number} {
|
|
1106
|
+
const collide: GridStackNode;
|
|
1107
|
+
const overMax = 0;
|
|
1108
|
+
collides.forEach(n => {
|
|
1109
|
+
if (n.locked || !n._rect) return;
|
|
1110
|
+
const over = Utils.areaIntercept(r, n._rect);
|
|
1111
|
+
if (over > overMax) {
|
|
1112
|
+
overMax = over;
|
|
1113
|
+
collide = n;
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
return {collide, over: overMax};
|
|
1117
|
+
}
|
|
1118
|
+
*/
|
|
1119
|
+
/** called to cache the nodes pixel rectangles used for collision detection during drag */
|
|
1120
|
+
cacheRects(e, t, i, s, r, o) {
|
|
1121
|
+
return this.nodes.forEach((n) => n._rect = {
|
|
1122
|
+
y: n.y * t + i,
|
|
1123
|
+
x: n.x * e + o,
|
|
1124
|
+
w: n.w * e - o - s,
|
|
1125
|
+
h: n.h * t - i - r
|
|
1126
|
+
}), this;
|
|
1127
|
+
}
|
|
1128
|
+
/** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */
|
|
1129
|
+
swap(e, t) {
|
|
1130
|
+
if (!t || t.locked || !e || e.locked)
|
|
1131
|
+
return !1;
|
|
1132
|
+
function i() {
|
|
1133
|
+
const r = t.x, o = t.y;
|
|
1134
|
+
return t.x = e.x, t.y = e.y, e.h != t.h ? (e.x = r, e.y = t.y + t.h) : e.w != t.w ? (e.x = t.x + t.w, e.y = o) : (e.x = r, e.y = o), e._dirty = t._dirty = !0, !0;
|
|
1135
|
+
}
|
|
1136
|
+
let s;
|
|
1137
|
+
if (e.w === t.w && e.h === t.h && (e.x === t.x || e.y === t.y) && (s = a.isTouching(e, t)))
|
|
1138
|
+
return i();
|
|
1139
|
+
if (s !== !1) {
|
|
1140
|
+
if (e.w === t.w && e.x === t.x && (s || (s = a.isTouching(e, t)))) {
|
|
1141
|
+
if (t.y < e.y) {
|
|
1142
|
+
const r = e;
|
|
1143
|
+
e = t, t = r;
|
|
1144
|
+
}
|
|
1145
|
+
return i();
|
|
1146
|
+
}
|
|
1147
|
+
if (s !== !1) {
|
|
1148
|
+
if (e.h === t.h && e.y === t.y && (s || (s = a.isTouching(e, t)))) {
|
|
1149
|
+
if (t.x < e.x) {
|
|
1150
|
+
const r = e;
|
|
1151
|
+
e = t, t = r;
|
|
1152
|
+
}
|
|
1153
|
+
return i();
|
|
1154
|
+
}
|
|
1155
|
+
return !1;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
isAreaEmpty(e, t, i, s) {
|
|
1160
|
+
const r = { x: e || 0, y: t || 0, w: i || 1, h: s || 1 };
|
|
1161
|
+
return !this.collide(r);
|
|
1162
|
+
}
|
|
1163
|
+
/** re-layout grid items to reclaim any empty space - optionally keeping the sort order exactly the same ('list' mode) vs truly finding an empty spaces */
|
|
1164
|
+
compact(e = "compact", t = !0) {
|
|
1165
|
+
if (this.nodes.length === 0)
|
|
1166
|
+
return this;
|
|
1167
|
+
t && this.sortNodes();
|
|
1168
|
+
const i = this.batchMode;
|
|
1169
|
+
i || this.batchUpdate();
|
|
1170
|
+
const s = this._inColumnResize;
|
|
1171
|
+
s || (this._inColumnResize = !0);
|
|
1172
|
+
const r = this.nodes;
|
|
1173
|
+
return this.nodes = [], r.forEach((o, n, l) => {
|
|
1174
|
+
let h;
|
|
1175
|
+
o.locked || (o.autoPosition = !0, e === "list" && n && (h = l[n - 1])), this.addNode(o, !1, h);
|
|
1176
|
+
}), s || delete this._inColumnResize, i || this.batchUpdate(!1), this;
|
|
1177
|
+
}
|
|
1178
|
+
/** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */
|
|
1179
|
+
set float(e) {
|
|
1180
|
+
this._float !== e && (this._float = e || !1, e || this._packNodes()._notify());
|
|
1181
|
+
}
|
|
1182
|
+
/** float getter method */
|
|
1183
|
+
get float() {
|
|
1184
|
+
return this._float || !1;
|
|
1185
|
+
}
|
|
1186
|
+
/** sort the nodes array from first to last, or reverse. Called during collision/placement to force an order */
|
|
1187
|
+
sortNodes(e = 1) {
|
|
1188
|
+
return this.nodes = a.sort(this.nodes, e), this;
|
|
1189
|
+
}
|
|
1190
|
+
/** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */
|
|
1191
|
+
_packNodes() {
|
|
1192
|
+
return this.batchMode ? this : (this.sortNodes(), this.float ? this.nodes.forEach((e) => {
|
|
1193
|
+
if (e._updating || e._orig === void 0 || e.y === e._orig.y)
|
|
1194
|
+
return;
|
|
1195
|
+
let t = e.y;
|
|
1196
|
+
for (; t > e._orig.y; )
|
|
1197
|
+
--t, this.collide(e, { x: e.x, y: t, w: e.w, h: e.h }) || (e._dirty = !0, e.y = t);
|
|
1198
|
+
}) : this.nodes.forEach((e, t) => {
|
|
1199
|
+
if (!e.locked)
|
|
1200
|
+
for (; e.y > 0; ) {
|
|
1201
|
+
const i = t === 0 ? 0 : e.y - 1;
|
|
1202
|
+
if (!(t === 0 || !this.collide(e, { x: e.x, y: i, w: e.w, h: e.h })))
|
|
1203
|
+
break;
|
|
1204
|
+
e._dirty = e.y !== i, e.y = i;
|
|
1205
|
+
}
|
|
1206
|
+
}), this);
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* given a random node, makes sure it's coordinates/values are valid in the current grid
|
|
1210
|
+
* @param node to adjust
|
|
1211
|
+
* @param resizing if out of bound, resize down or move into the grid to fit ?
|
|
1212
|
+
*/
|
|
1213
|
+
prepareNode(e, t) {
|
|
1214
|
+
e._id = e._id ?? P._idSeq++;
|
|
1215
|
+
const i = e.id;
|
|
1216
|
+
if (i) {
|
|
1217
|
+
let r = 1;
|
|
1218
|
+
for (; this.nodes.find((o) => o.id === e.id && o !== e); )
|
|
1219
|
+
e.id = i + "_" + r++;
|
|
1220
|
+
}
|
|
1221
|
+
(e.x === void 0 || e.y === void 0 || e.x === null || e.y === null) && (e.autoPosition = !0);
|
|
1222
|
+
const s = { x: 0, y: 0, w: 1, h: 1 };
|
|
1223
|
+
return a.defaults(e, s), e.autoPosition || delete e.autoPosition, e.noResize || delete e.noResize, e.noMove || delete e.noMove, a.sanitizeMinMax(e), typeof e.x == "string" && (e.x = Number(e.x)), typeof e.y == "string" && (e.y = Number(e.y)), typeof e.w == "string" && (e.w = Number(e.w)), typeof e.h == "string" && (e.h = Number(e.h)), isNaN(e.x) && (e.x = s.x, e.autoPosition = !0), isNaN(e.y) && (e.y = s.y, e.autoPosition = !0), isNaN(e.w) && (e.w = s.w), isNaN(e.h) && (e.h = s.h), this.nodeBoundFix(e, t), e;
|
|
1224
|
+
}
|
|
1225
|
+
/** part2 of preparing a node to fit inside our grid - checks for x,y,w from grid dimensions */
|
|
1226
|
+
nodeBoundFix(e, t) {
|
|
1227
|
+
const i = e._orig || a.copyPos({}, e);
|
|
1228
|
+
if (e.maxW && e.w && (e.w = Math.min(e.w, e.maxW)), e.maxH && e.h && (e.h = Math.min(e.h, e.maxH)), e.minW && e.w && e.minW <= this.column && (e.w = Math.max(e.w, e.minW)), e.minH && e.h && (e.h = Math.max(e.h, e.minH)), (e.x || 0) + (e.w || 1) > this.column && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && e._id && this.findCacheLayout(e, this.defaultColumn) === -1) {
|
|
1229
|
+
const r = { ...e };
|
|
1230
|
+
r.autoPosition || r.x === void 0 ? (delete r.x, delete r.y) : r.x = Math.min(this.defaultColumn - 1, r.x), r.w = Math.min(this.defaultColumn, r.w || 1), this.cacheOneLayout(r, this.defaultColumn);
|
|
1231
|
+
}
|
|
1232
|
+
return e.w > this.column ? e.w = this.column : e.w < 1 && (e.w = 1), this.maxRow && e.h > this.maxRow ? e.h = this.maxRow : e.h < 1 && (e.h = 1), e.x < 0 && (e.x = 0), e.y < 0 && (e.y = 0), e.x + e.w > this.column && (t ? e.w = this.column - e.x : e.x = this.column - e.w), this.maxRow && e.y + e.h > this.maxRow && (t ? e.h = this.maxRow - e.y : e.y = this.maxRow - e.h), a.samePos(e, i) || (e._dirty = !0), this;
|
|
1233
|
+
}
|
|
1234
|
+
/** returns a list of modified nodes from their original values */
|
|
1235
|
+
getDirtyNodes(e) {
|
|
1236
|
+
return e ? this.nodes.filter((t) => t._dirty && !a.samePos(t, t._orig)) : this.nodes.filter((t) => t._dirty);
|
|
1237
|
+
}
|
|
1238
|
+
/** @internal call this to call onChange callback with dirty nodes so DOM can be updated */
|
|
1239
|
+
_notify(e) {
|
|
1240
|
+
if (this.batchMode || !this.onChange)
|
|
1241
|
+
return this;
|
|
1242
|
+
const t = (e || []).concat(this.getDirtyNodes());
|
|
1243
|
+
return this.onChange(t), this;
|
|
1244
|
+
}
|
|
1245
|
+
/** @internal remove dirty and last tried info */
|
|
1246
|
+
cleanNodes() {
|
|
1247
|
+
return this.batchMode ? this : (this.nodes.forEach((e) => {
|
|
1248
|
+
delete e._dirty, delete e._lastTried;
|
|
1249
|
+
}), this);
|
|
1250
|
+
}
|
|
1251
|
+
/** @internal called to save initial position/size to track real dirty state.
|
|
1252
|
+
* Note: should be called right after we call change event (so next API is can detect changes)
|
|
1253
|
+
* as well as right before we start move/resize/enter (so we can restore items to prev values) */
|
|
1254
|
+
saveInitial() {
|
|
1255
|
+
return this.nodes.forEach((e) => {
|
|
1256
|
+
e._orig = a.copyPos({}, e), delete e._dirty;
|
|
1257
|
+
}), this._hasLocked = this.nodes.some((e) => e.locked), this;
|
|
1258
|
+
}
|
|
1259
|
+
/** @internal restore all the nodes back to initial values (called when we leave) */
|
|
1260
|
+
restoreInitial() {
|
|
1261
|
+
return this.nodes.forEach((e) => {
|
|
1262
|
+
!e._orig || a.samePos(e, e._orig) || (a.copyPos(e, e._orig), e._dirty = !0);
|
|
1263
|
+
}), this._notify(), this;
|
|
1264
|
+
}
|
|
1265
|
+
/** find the first available empty spot for the given node width/height, updating the x,y attributes. return true if found.
|
|
1266
|
+
* optionally you can pass your own existing node list and column count, otherwise defaults to that engine data.
|
|
1267
|
+
* Optionally pass a widget to start search AFTER, meaning the order will remain the same but possibly have empty slots we skipped
|
|
1268
|
+
*/
|
|
1269
|
+
findEmptyPosition(e, t = this.nodes, i = this.column, s) {
|
|
1270
|
+
const r = s ? s.y * i + (s.x + s.w) : 0;
|
|
1271
|
+
let o = !1;
|
|
1272
|
+
for (let n = r; !o; ++n) {
|
|
1273
|
+
const l = n % i, h = Math.floor(n / i);
|
|
1274
|
+
if (l + e.w > i)
|
|
1275
|
+
continue;
|
|
1276
|
+
const d = { x: l, y: h, w: e.w, h: e.h };
|
|
1277
|
+
t.find((u) => a.isIntercepted(d, u)) || ((e.x !== l || e.y !== h) && (e._dirty = !0), e.x = l, e.y = h, delete e.autoPosition, o = !0);
|
|
1278
|
+
}
|
|
1279
|
+
return o;
|
|
1280
|
+
}
|
|
1281
|
+
/** call to add the given node to our list, fixing collision and re-packing */
|
|
1282
|
+
addNode(e, t = !1, i) {
|
|
1283
|
+
const s = this.nodes.find((o) => o._id === e._id);
|
|
1284
|
+
if (s)
|
|
1285
|
+
return s;
|
|
1286
|
+
this._inColumnResize ? this.nodeBoundFix(e) : this.prepareNode(e), delete e._temporaryRemoved, delete e._removeDOM;
|
|
1287
|
+
let r;
|
|
1288
|
+
return e.autoPosition && this.findEmptyPosition(e, this.nodes, this.column, i) && (delete e.autoPosition, r = !0), this.nodes.push(e), t && this.addedNodes.push(e), r || this._fixCollisions(e), this.batchMode || this._packNodes()._notify(), e;
|
|
1289
|
+
}
|
|
1290
|
+
removeNode(e, t = !0, i = !1) {
|
|
1291
|
+
return this.nodes.find((s) => s._id === e._id) ? (i && this.removedNodes.push(e), t && (e._removeDOM = !0), this.nodes = this.nodes.filter((s) => s._id !== e._id), e._isAboutToRemove || this._packNodes(), this._notify([e]), this) : this;
|
|
1292
|
+
}
|
|
1293
|
+
removeAll(e = !0, t = !0) {
|
|
1294
|
+
if (delete this._layouts, !this.nodes.length)
|
|
1295
|
+
return this;
|
|
1296
|
+
e && this.nodes.forEach((s) => s._removeDOM = !0);
|
|
1297
|
+
const i = this.nodes;
|
|
1298
|
+
return this.removedNodes = t ? i : [], this.nodes = [], this._notify(i);
|
|
1299
|
+
}
|
|
1300
|
+
/** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.
|
|
1301
|
+
* In more complicated cases (maxRow) it will attempt at moving the item and fixing
|
|
1302
|
+
* others in a clone first, then apply those changes if still within specs. */
|
|
1303
|
+
moveNodeCheck(e, t) {
|
|
1304
|
+
if (!this.changedPosConstrain(e, t))
|
|
1305
|
+
return !1;
|
|
1306
|
+
if (t.pack = !0, !this.maxRow)
|
|
1307
|
+
return this.moveNode(e, t);
|
|
1308
|
+
let i;
|
|
1309
|
+
const s = new P({
|
|
1310
|
+
column: this.column,
|
|
1311
|
+
float: this.float,
|
|
1312
|
+
nodes: this.nodes.map((o) => o._id === e._id ? (i = { ...o }, i) : { ...o })
|
|
1313
|
+
});
|
|
1314
|
+
if (!i)
|
|
1315
|
+
return !1;
|
|
1316
|
+
const r = s.moveNode(i, t) && s.getRow() <= Math.max(this.getRow(), this.maxRow);
|
|
1317
|
+
if (!r && !t.resizing && t.collide) {
|
|
1318
|
+
const o = t.collide.el.gridstackNode;
|
|
1319
|
+
if (this.swap(e, o))
|
|
1320
|
+
return this._notify(), !0;
|
|
1321
|
+
}
|
|
1322
|
+
return r ? (s.nodes.filter((o) => o._dirty).forEach((o) => {
|
|
1323
|
+
const n = this.nodes.find((l) => l._id === o._id);
|
|
1324
|
+
n && (a.copyPos(n, o), n._dirty = !0);
|
|
1325
|
+
}), this._notify(), !0) : !1;
|
|
1326
|
+
}
|
|
1327
|
+
/** return true if can fit in grid height constrain only (always true if no maxRow) */
|
|
1328
|
+
willItFit(e) {
|
|
1329
|
+
if (delete e._willFitPos, !this.maxRow)
|
|
1330
|
+
return !0;
|
|
1331
|
+
const t = new P({
|
|
1332
|
+
column: this.column,
|
|
1333
|
+
float: this.float,
|
|
1334
|
+
nodes: this.nodes.map((s) => ({ ...s }))
|
|
1335
|
+
}), i = { ...e };
|
|
1336
|
+
return this.cleanupNode(i), delete i.el, delete i._id, delete i.content, delete i.grid, t.addNode(i), t.getRow() <= this.maxRow ? (e._willFitPos = a.copyPos({}, i), !0) : !1;
|
|
1337
|
+
}
|
|
1338
|
+
/** true if x,y or w,h are different after clamping to min/max */
|
|
1339
|
+
changedPosConstrain(e, t) {
|
|
1340
|
+
return t.w = t.w || e.w, t.h = t.h || e.h, e.x !== t.x || e.y !== t.y ? !0 : (e.maxW && (t.w = Math.min(t.w, e.maxW)), e.maxH && (t.h = Math.min(t.h, e.maxH)), e.minW && (t.w = Math.max(t.w, e.minW)), e.minH && (t.h = Math.max(t.h, e.minH)), e.w !== t.w || e.h !== t.h);
|
|
1341
|
+
}
|
|
1342
|
+
/** return true if the passed in node was actually moved (checks for no-op and locked) */
|
|
1343
|
+
moveNode(e, t) {
|
|
1344
|
+
var h, d;
|
|
1345
|
+
if (!e || /*node.locked ||*/
|
|
1346
|
+
!t)
|
|
1347
|
+
return !1;
|
|
1348
|
+
let i;
|
|
1349
|
+
t.pack === void 0 && !this.batchMode && (i = t.pack = !0), typeof t.x != "number" && (t.x = e.x), typeof t.y != "number" && (t.y = e.y), typeof t.w != "number" && (t.w = e.w), typeof t.h != "number" && (t.h = e.h);
|
|
1350
|
+
const s = e.w !== t.w || e.h !== t.h, r = a.copyPos({}, e, !0);
|
|
1351
|
+
if (a.copyPos(r, t), this.nodeBoundFix(r, s), a.copyPos(t, r), !t.forceCollide && a.samePos(e, t))
|
|
1352
|
+
return !1;
|
|
1353
|
+
const o = a.copyPos({}, e), n = this.collideAll(e, r, t.skip);
|
|
1354
|
+
let l = !0;
|
|
1355
|
+
if (n.length) {
|
|
1356
|
+
const u = e._moving && !t.nested;
|
|
1357
|
+
let f = u ? this.directionCollideCoverage(e, t, n) : n[0];
|
|
1358
|
+
if (u && f && ((d = (h = e.grid) == null ? void 0 : h.opts) != null && d.subGridDynamic) && !e.grid._isTemp) {
|
|
1359
|
+
const _ = a.areaIntercept(t.rect, f._rect), v = a.area(t.rect), b = a.area(f._rect);
|
|
1360
|
+
_ / (v < b ? v : b) > 0.8 && (f.grid.makeSubGrid(f.el, void 0, e), f = void 0);
|
|
1361
|
+
}
|
|
1362
|
+
f ? l = !this._fixCollisions(e, r, f, t) : (l = !1, i && delete t.pack);
|
|
1363
|
+
}
|
|
1364
|
+
return l && !a.samePos(e, r) && (e._dirty = !0, a.copyPos(e, r)), t.pack && this._packNodes()._notify(), !a.samePos(e, o);
|
|
1365
|
+
}
|
|
1366
|
+
getRow() {
|
|
1367
|
+
return this.nodes.reduce((e, t) => Math.max(e, t.y + t.h), 0);
|
|
1368
|
+
}
|
|
1369
|
+
beginUpdate(e) {
|
|
1370
|
+
return e._updating || (e._updating = !0, delete e._skipDown, this.batchMode || this.saveInitial()), this;
|
|
1371
|
+
}
|
|
1372
|
+
endUpdate() {
|
|
1373
|
+
const e = this.nodes.find((t) => t._updating);
|
|
1374
|
+
return e && (delete e._updating, delete e._skipDown), this;
|
|
1375
|
+
}
|
|
1376
|
+
/** saves a copy of the largest column layout (eg 12 even when rendering oneColumnMode) so we don't loose orig layout,
|
|
1377
|
+
* returning a list of widgets for serialization */
|
|
1378
|
+
save(e = !0, t) {
|
|
1379
|
+
var o;
|
|
1380
|
+
const i = (o = this._layouts) == null ? void 0 : o.length, s = i && this.column !== i - 1 ? this._layouts[i - 1] : null, r = [];
|
|
1381
|
+
return this.sortNodes(), this.nodes.forEach((n) => {
|
|
1382
|
+
const l = s == null ? void 0 : s.find((d) => d._id === n._id), h = { ...n, ...l || {} };
|
|
1383
|
+
a.removeInternalForSave(h, !e), t && t(n, h), r.push(h);
|
|
1384
|
+
}), r;
|
|
1385
|
+
}
|
|
1386
|
+
/** @internal called whenever a node is added or moved - updates the cached layouts */
|
|
1387
|
+
layoutsNodesChange(e) {
|
|
1388
|
+
return !this._layouts || this._inColumnResize ? this : (this._layouts.forEach((t, i) => {
|
|
1389
|
+
if (!t || i === this.column)
|
|
1390
|
+
return this;
|
|
1391
|
+
if (i < this.column)
|
|
1392
|
+
this._layouts[i] = void 0;
|
|
1393
|
+
else {
|
|
1394
|
+
const s = i / this.column;
|
|
1395
|
+
e.forEach((r) => {
|
|
1396
|
+
if (!r._orig)
|
|
1397
|
+
return;
|
|
1398
|
+
const o = t.find((n) => n._id === r._id);
|
|
1399
|
+
o && (o.y >= 0 && r.y !== r._orig.y && (o.y += r.y - r._orig.y), r.x !== r._orig.x && (o.x = Math.round(r.x * s)), r.w !== r._orig.w && (o.w = Math.round(r.w * s)));
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
}), this);
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* @internal Called to scale the widget width & position up/down based on the column change.
|
|
1406
|
+
* Note we store previous layouts (especially original ones) to make it possible to go
|
|
1407
|
+
* from say 12 -> 1 -> 12 and get back to where we were.
|
|
1408
|
+
*
|
|
1409
|
+
* @param prevColumn previous number of columns
|
|
1410
|
+
* @param column new column number
|
|
1411
|
+
* @param layout specify the type of re-layout that will happen (position, size, etc...).
|
|
1412
|
+
* Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column
|
|
1413
|
+
*/
|
|
1414
|
+
columnChanged(e, t, i = "moveScale") {
|
|
1415
|
+
var n;
|
|
1416
|
+
if (!this.nodes.length || !t || e === t)
|
|
1417
|
+
return this;
|
|
1418
|
+
const s = i === "compact" || i === "list";
|
|
1419
|
+
s && this.sortNodes(1), t < e && this.cacheLayout(this.nodes, e), this.batchUpdate();
|
|
1420
|
+
let r = [], o = s ? this.nodes : a.sort(this.nodes, -1);
|
|
1421
|
+
if (t > e && this._layouts) {
|
|
1422
|
+
const l = this._layouts[t] || [], h = this._layouts.length - 1;
|
|
1423
|
+
!l.length && e !== h && ((n = this._layouts[h]) != null && n.length) && (e = h, this._layouts[h].forEach((d) => {
|
|
1424
|
+
const u = o.find((f) => f._id === d._id);
|
|
1425
|
+
u && (!s && !d.autoPosition && (u.x = d.x ?? u.x, u.y = d.y ?? u.y), u.w = d.w ?? u.w, (d.x == null || d.y === void 0) && (u.autoPosition = !0));
|
|
1426
|
+
})), l.forEach((d) => {
|
|
1427
|
+
const u = o.findIndex((f) => f._id === d._id);
|
|
1428
|
+
if (u !== -1) {
|
|
1429
|
+
const f = o[u];
|
|
1430
|
+
if (s) {
|
|
1431
|
+
f.w = d.w;
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
(d.autoPosition || isNaN(d.x) || isNaN(d.y)) && this.findEmptyPosition(d, r), d.autoPosition || (f.x = d.x ?? f.x, f.y = d.y ?? f.y, f.w = d.w ?? f.w, r.push(f)), o.splice(u, 1);
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
if (s)
|
|
1439
|
+
this.compact(i, !1);
|
|
1440
|
+
else {
|
|
1441
|
+
if (o.length)
|
|
1442
|
+
if (typeof i == "function")
|
|
1443
|
+
i(t, e, r, o);
|
|
1444
|
+
else {
|
|
1445
|
+
const l = s || i === "none" ? 1 : t / e, h = i === "move" || i === "moveScale", d = i === "scale" || i === "moveScale";
|
|
1446
|
+
o.forEach((u) => {
|
|
1447
|
+
u.x = t === 1 ? 0 : h ? Math.round(u.x * l) : Math.min(u.x, t - 1), u.w = t === 1 || e === 1 ? 1 : d ? Math.round(u.w * l) || 1 : Math.min(u.w, t), r.push(u);
|
|
1448
|
+
}), o = [];
|
|
1449
|
+
}
|
|
1450
|
+
r = a.sort(r, -1), this._inColumnResize = !0, this.nodes = [], r.forEach((l) => {
|
|
1451
|
+
this.addNode(l, !1), delete l._orig;
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
return this.nodes.forEach((l) => delete l._orig), this.batchUpdate(!1, !s), delete this._inColumnResize, this;
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* call to cache the given layout internally to the given location so we can restore back when column changes size
|
|
1458
|
+
* @param nodes list of nodes
|
|
1459
|
+
* @param column corresponding column index to save it under
|
|
1460
|
+
* @param clear if true, will force other caches to be removed (default false)
|
|
1461
|
+
*/
|
|
1462
|
+
cacheLayout(e, t, i = !1) {
|
|
1463
|
+
const s = [];
|
|
1464
|
+
return e.forEach((r, o) => {
|
|
1465
|
+
if (r._id === void 0) {
|
|
1466
|
+
const n = r.id ? this.nodes.find((l) => l.id === r.id) : void 0;
|
|
1467
|
+
r._id = (n == null ? void 0 : n._id) ?? P._idSeq++;
|
|
1468
|
+
}
|
|
1469
|
+
s[o] = { x: r.x, y: r.y, w: r.w, _id: r._id };
|
|
1470
|
+
}), this._layouts = i ? [] : this._layouts || [], this._layouts[t] = s, this;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* call to cache the given node layout internally to the given location so we can restore back when column changes size
|
|
1474
|
+
* @param node single node to cache
|
|
1475
|
+
* @param column corresponding column index to save it under
|
|
1476
|
+
*/
|
|
1477
|
+
cacheOneLayout(e, t) {
|
|
1478
|
+
e._id = e._id ?? P._idSeq++;
|
|
1479
|
+
const i = { x: e.x, y: e.y, w: e.w, _id: e._id };
|
|
1480
|
+
(e.autoPosition || e.x === void 0) && (delete i.x, delete i.y, e.autoPosition && (i.autoPosition = !0)), this._layouts = this._layouts || [], this._layouts[t] = this._layouts[t] || [];
|
|
1481
|
+
const s = this.findCacheLayout(e, t);
|
|
1482
|
+
return s === -1 ? this._layouts[t].push(i) : this._layouts[t][s] = i, this;
|
|
1483
|
+
}
|
|
1484
|
+
findCacheLayout(e, t) {
|
|
1485
|
+
var i, s;
|
|
1486
|
+
return ((s = (i = this._layouts) == null ? void 0 : i[t]) == null ? void 0 : s.findIndex((r) => r._id === e._id)) ?? -1;
|
|
1487
|
+
}
|
|
1488
|
+
removeNodeFromLayoutCache(e) {
|
|
1489
|
+
if (this._layouts)
|
|
1490
|
+
for (let t = 0; t < this._layouts.length; t++) {
|
|
1491
|
+
const i = this.findCacheLayout(e, t);
|
|
1492
|
+
i !== -1 && this._layouts[t].splice(i, 1);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
/** called to remove all internal values but the _id */
|
|
1496
|
+
cleanupNode(e) {
|
|
1497
|
+
for (const t in e)
|
|
1498
|
+
t[0] === "_" && t !== "_id" && delete e[t];
|
|
1499
|
+
return this;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
P._idSeq = 0;
|
|
1503
|
+
const A = {
|
|
1504
|
+
alwaysShowResizeHandle: "mobile",
|
|
1505
|
+
animate: !0,
|
|
1506
|
+
auto: !0,
|
|
1507
|
+
cellHeight: "auto",
|
|
1508
|
+
cellHeightThrottle: 100,
|
|
1509
|
+
cellHeightUnit: "px",
|
|
1510
|
+
column: 12,
|
|
1511
|
+
draggable: { handle: ".grid-stack-item-content", appendTo: "body", scroll: !0 },
|
|
1512
|
+
handle: ".grid-stack-item-content",
|
|
1513
|
+
itemClass: "grid-stack-item",
|
|
1514
|
+
margin: 10,
|
|
1515
|
+
marginUnit: "px",
|
|
1516
|
+
maxRow: 0,
|
|
1517
|
+
minRow: 0,
|
|
1518
|
+
placeholderClass: "grid-stack-placeholder",
|
|
1519
|
+
placeholderText: "",
|
|
1520
|
+
removableOptions: { accept: "grid-stack-item", decline: "grid-stack-non-removable" },
|
|
1521
|
+
resizable: { handles: "se" },
|
|
1522
|
+
rtl: "auto"
|
|
1523
|
+
// **** same as not being set ****
|
|
1524
|
+
// disableDrag: false,
|
|
1525
|
+
// disableResize: false,
|
|
1526
|
+
// float: false,
|
|
1527
|
+
// handleClass: null,
|
|
1528
|
+
// removable: false,
|
|
1529
|
+
// staticGrid: false,
|
|
1530
|
+
// styleInHead: false,
|
|
1531
|
+
//removable
|
|
1532
|
+
};
|
|
1533
|
+
class m {
|
|
1534
|
+
}
|
|
1535
|
+
const O = typeof window < "u" && typeof document < "u" && ("ontouchstart" in document || "ontouchstart" in window || window.DocumentTouch && document instanceof window.DocumentTouch || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
|
|
1536
|
+
class B {
|
|
1537
|
+
}
|
|
1538
|
+
function Z(c, e) {
|
|
1539
|
+
if (c.touches.length > 1)
|
|
1540
|
+
return;
|
|
1541
|
+
c.cancelable && c.preventDefault();
|
|
1542
|
+
const t = c.changedTouches[0], i = document.createEvent("MouseEvents");
|
|
1543
|
+
i.initMouseEvent(
|
|
1544
|
+
e,
|
|
1545
|
+
// type
|
|
1546
|
+
!0,
|
|
1547
|
+
// bubbles
|
|
1548
|
+
!0,
|
|
1549
|
+
// cancelable
|
|
1550
|
+
window,
|
|
1551
|
+
// view
|
|
1552
|
+
1,
|
|
1553
|
+
// detail
|
|
1554
|
+
t.screenX,
|
|
1555
|
+
// screenX
|
|
1556
|
+
t.screenY,
|
|
1557
|
+
// screenY
|
|
1558
|
+
t.clientX,
|
|
1559
|
+
// clientX
|
|
1560
|
+
t.clientY,
|
|
1561
|
+
// clientY
|
|
1562
|
+
!1,
|
|
1563
|
+
// ctrlKey
|
|
1564
|
+
!1,
|
|
1565
|
+
// altKey
|
|
1566
|
+
!1,
|
|
1567
|
+
// shiftKey
|
|
1568
|
+
!1,
|
|
1569
|
+
// metaKey
|
|
1570
|
+
0,
|
|
1571
|
+
// button
|
|
1572
|
+
null
|
|
1573
|
+
// relatedTarget
|
|
1574
|
+
), c.target.dispatchEvent(i);
|
|
1575
|
+
}
|
|
1576
|
+
function Ae(c, e) {
|
|
1577
|
+
c.cancelable && c.preventDefault();
|
|
1578
|
+
const t = document.createEvent("MouseEvents");
|
|
1579
|
+
t.initMouseEvent(
|
|
1580
|
+
e,
|
|
1581
|
+
// type
|
|
1582
|
+
!0,
|
|
1583
|
+
// bubbles
|
|
1584
|
+
!0,
|
|
1585
|
+
// cancelable
|
|
1586
|
+
window,
|
|
1587
|
+
// view
|
|
1588
|
+
1,
|
|
1589
|
+
// detail
|
|
1590
|
+
c.screenX,
|
|
1591
|
+
// screenX
|
|
1592
|
+
c.screenY,
|
|
1593
|
+
// screenY
|
|
1594
|
+
c.clientX,
|
|
1595
|
+
// clientX
|
|
1596
|
+
c.clientY,
|
|
1597
|
+
// clientY
|
|
1598
|
+
!1,
|
|
1599
|
+
// ctrlKey
|
|
1600
|
+
!1,
|
|
1601
|
+
// altKey
|
|
1602
|
+
!1,
|
|
1603
|
+
// shiftKey
|
|
1604
|
+
!1,
|
|
1605
|
+
// metaKey
|
|
1606
|
+
0,
|
|
1607
|
+
// button
|
|
1608
|
+
null
|
|
1609
|
+
// relatedTarget
|
|
1610
|
+
), c.target.dispatchEvent(t);
|
|
1611
|
+
}
|
|
1612
|
+
function ee(c) {
|
|
1613
|
+
B.touchHandled || (B.touchHandled = !0, Z(c, "mousedown"));
|
|
1614
|
+
}
|
|
1615
|
+
function te(c) {
|
|
1616
|
+
B.touchHandled && Z(c, "mousemove");
|
|
1617
|
+
}
|
|
1618
|
+
function ie(c) {
|
|
1619
|
+
if (!B.touchHandled)
|
|
1620
|
+
return;
|
|
1621
|
+
B.pointerLeaveTimeout && (window.clearTimeout(B.pointerLeaveTimeout), delete B.pointerLeaveTimeout);
|
|
1622
|
+
const e = !!m.dragElement;
|
|
1623
|
+
Z(c, "mouseup"), e || Z(c, "click"), B.touchHandled = !1;
|
|
1624
|
+
}
|
|
1625
|
+
function se(c) {
|
|
1626
|
+
c.pointerType !== "mouse" && c.target.releasePointerCapture(c.pointerId);
|
|
1627
|
+
}
|
|
1628
|
+
function be(c) {
|
|
1629
|
+
m.dragElement && c.pointerType !== "mouse" && Ae(c, "mouseenter");
|
|
1630
|
+
}
|
|
1631
|
+
function we(c) {
|
|
1632
|
+
m.dragElement && c.pointerType !== "mouse" && (B.pointerLeaveTimeout = window.setTimeout(() => {
|
|
1633
|
+
delete B.pointerLeaveTimeout, Ae(c, "mouseleave");
|
|
1634
|
+
}, 10));
|
|
1635
|
+
}
|
|
1636
|
+
class ae {
|
|
1637
|
+
constructor(e, t, i) {
|
|
1638
|
+
this.host = e, this.dir = t, this.option = i, this.moving = !1, this._mouseDown = this._mouseDown.bind(this), this._mouseMove = this._mouseMove.bind(this), this._mouseUp = this._mouseUp.bind(this), this._keyEvent = this._keyEvent.bind(this), this._init();
|
|
1639
|
+
}
|
|
1640
|
+
/** @internal */
|
|
1641
|
+
_init() {
|
|
1642
|
+
const e = this.el = document.createElement("div");
|
|
1643
|
+
return e.classList.add("ui-resizable-handle"), e.classList.add(`${ae.prefix}${this.dir}`), e.style.zIndex = "100", e.style.userSelect = "none", this.host.appendChild(this.el), this.el.addEventListener("mousedown", this._mouseDown), O && (this.el.addEventListener("touchstart", ee), this.el.addEventListener("pointerdown", se)), this;
|
|
1644
|
+
}
|
|
1645
|
+
/** call this when resize handle needs to be removed and cleaned up */
|
|
1646
|
+
destroy() {
|
|
1647
|
+
return this.moving && this._mouseUp(this.mouseDownEvent), this.el.removeEventListener("mousedown", this._mouseDown), O && (this.el.removeEventListener("touchstart", ee), this.el.removeEventListener("pointerdown", se)), this.host.removeChild(this.el), delete this.el, delete this.host, this;
|
|
1648
|
+
}
|
|
1649
|
+
/** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */
|
|
1650
|
+
_mouseDown(e) {
|
|
1651
|
+
this.mouseDownEvent = e, document.addEventListener("mousemove", this._mouseMove, { capture: !0, passive: !0 }), document.addEventListener("mouseup", this._mouseUp, !0), O && (this.el.addEventListener("touchmove", te), this.el.addEventListener("touchend", ie)), e.stopPropagation(), e.preventDefault();
|
|
1652
|
+
}
|
|
1653
|
+
/** @internal */
|
|
1654
|
+
_mouseMove(e) {
|
|
1655
|
+
const t = this.mouseDownEvent;
|
|
1656
|
+
this.moving ? this._triggerEvent("move", e) : Math.abs(e.x - t.x) + Math.abs(e.y - t.y) > 2 && (this.moving = !0, this._triggerEvent("start", this.mouseDownEvent), this._triggerEvent("move", e), document.addEventListener("keydown", this._keyEvent)), e.stopPropagation();
|
|
1657
|
+
}
|
|
1658
|
+
/** @internal */
|
|
1659
|
+
_mouseUp(e) {
|
|
1660
|
+
this.moving && (this._triggerEvent("stop", e), document.removeEventListener("keydown", this._keyEvent)), document.removeEventListener("mousemove", this._mouseMove, !0), document.removeEventListener("mouseup", this._mouseUp, !0), O && (this.el.removeEventListener("touchmove", te), this.el.removeEventListener("touchend", ie)), delete this.moving, delete this.mouseDownEvent, e.stopPropagation(), e.preventDefault();
|
|
1661
|
+
}
|
|
1662
|
+
/** @internal call when keys are being pressed - use Esc to cancel */
|
|
1663
|
+
_keyEvent(e) {
|
|
1664
|
+
var t, i;
|
|
1665
|
+
e.key === "Escape" && ((i = (t = this.host.gridstackNode) == null ? void 0 : t.grid) == null || i.engine.restoreInitial(), this._mouseUp(this.mouseDownEvent));
|
|
1666
|
+
}
|
|
1667
|
+
/** @internal */
|
|
1668
|
+
_triggerEvent(e, t) {
|
|
1669
|
+
return this.option[e] && this.option[e](t), this;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
ae.prefix = "ui-resizable-";
|
|
1673
|
+
class ue {
|
|
1674
|
+
constructor() {
|
|
1675
|
+
this._eventRegister = {};
|
|
1676
|
+
}
|
|
1677
|
+
/** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */
|
|
1678
|
+
get disabled() {
|
|
1679
|
+
return this._disabled;
|
|
1680
|
+
}
|
|
1681
|
+
on(e, t) {
|
|
1682
|
+
this._eventRegister[e] = t;
|
|
1683
|
+
}
|
|
1684
|
+
off(e) {
|
|
1685
|
+
delete this._eventRegister[e];
|
|
1686
|
+
}
|
|
1687
|
+
enable() {
|
|
1688
|
+
this._disabled = !1;
|
|
1689
|
+
}
|
|
1690
|
+
disable() {
|
|
1691
|
+
this._disabled = !0;
|
|
1692
|
+
}
|
|
1693
|
+
destroy() {
|
|
1694
|
+
delete this._eventRegister;
|
|
1695
|
+
}
|
|
1696
|
+
triggerEvent(e, t) {
|
|
1697
|
+
if (!this.disabled && this._eventRegister && this._eventRegister[e])
|
|
1698
|
+
return this._eventRegister[e](t);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
class Y extends ue {
|
|
1702
|
+
// have to be public else complains for HTMLElementExtendOpt ?
|
|
1703
|
+
constructor(e, t = {}) {
|
|
1704
|
+
super(), this.el = e, this.option = t, this.rectScale = { x: 1, y: 1 }, this._ui = () => {
|
|
1705
|
+
const s = this.el.parentElement.getBoundingClientRect(), r = {
|
|
1706
|
+
width: this.originalRect.width,
|
|
1707
|
+
height: this.originalRect.height + this.scrolled,
|
|
1708
|
+
left: this.originalRect.left,
|
|
1709
|
+
top: this.originalRect.top - this.scrolled
|
|
1710
|
+
}, o = this.temporalRect || r;
|
|
1711
|
+
return {
|
|
1712
|
+
position: {
|
|
1713
|
+
left: (o.left - s.left) * this.rectScale.x,
|
|
1714
|
+
top: (o.top - s.top) * this.rectScale.y
|
|
1715
|
+
},
|
|
1716
|
+
size: {
|
|
1717
|
+
width: o.width * this.rectScale.x,
|
|
1718
|
+
height: o.height * this.rectScale.y
|
|
1719
|
+
}
|
|
1720
|
+
/* Gridstack ONLY needs position set above... keep around in case.
|
|
1721
|
+
element: [this.el], // The object representing the element to be resized
|
|
1722
|
+
helper: [], // TODO: not support yet - The object representing the helper that's being resized
|
|
1723
|
+
originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped
|
|
1724
|
+
originalPosition: { // The position represented as { left, top } before the resizable is resized
|
|
1725
|
+
left: this.originalRect.left - containmentRect.left,
|
|
1726
|
+
top: this.originalRect.top - containmentRect.top
|
|
1727
|
+
},
|
|
1728
|
+
originalSize: { // The size represented as { width, height } before the resizable is resized
|
|
1729
|
+
width: this.originalRect.width,
|
|
1730
|
+
height: this.originalRect.height
|
|
1731
|
+
}
|
|
1732
|
+
*/
|
|
1733
|
+
};
|
|
1734
|
+
}, this._mouseOver = this._mouseOver.bind(this), this._mouseOut = this._mouseOut.bind(this), this.enable(), this._setupAutoHide(this.option.autoHide), this._setupHandlers();
|
|
1735
|
+
}
|
|
1736
|
+
on(e, t) {
|
|
1737
|
+
super.on(e, t);
|
|
1738
|
+
}
|
|
1739
|
+
off(e) {
|
|
1740
|
+
super.off(e);
|
|
1741
|
+
}
|
|
1742
|
+
enable() {
|
|
1743
|
+
super.enable(), this.el.classList.remove("ui-resizable-disabled"), this._setupAutoHide(this.option.autoHide);
|
|
1744
|
+
}
|
|
1745
|
+
disable() {
|
|
1746
|
+
super.disable(), this.el.classList.add("ui-resizable-disabled"), this._setupAutoHide(!1);
|
|
1747
|
+
}
|
|
1748
|
+
destroy() {
|
|
1749
|
+
this._removeHandlers(), this._setupAutoHide(!1), delete this.el, super.destroy();
|
|
1750
|
+
}
|
|
1751
|
+
updateOption(e) {
|
|
1752
|
+
const t = e.handles && e.handles !== this.option.handles, i = e.autoHide && e.autoHide !== this.option.autoHide;
|
|
1753
|
+
return Object.keys(e).forEach((s) => this.option[s] = e[s]), t && (this._removeHandlers(), this._setupHandlers()), i && this._setupAutoHide(this.option.autoHide), this;
|
|
1754
|
+
}
|
|
1755
|
+
/** @internal turns auto hide on/off */
|
|
1756
|
+
_setupAutoHide(e) {
|
|
1757
|
+
return e ? (this.el.classList.add("ui-resizable-autohide"), this.el.addEventListener("mouseover", this._mouseOver), this.el.addEventListener("mouseout", this._mouseOut)) : (this.el.classList.remove("ui-resizable-autohide"), this.el.removeEventListener("mouseover", this._mouseOver), this.el.removeEventListener("mouseout", this._mouseOut), m.overResizeElement === this && delete m.overResizeElement), this;
|
|
1758
|
+
}
|
|
1759
|
+
/** @internal */
|
|
1760
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1761
|
+
_mouseOver(e) {
|
|
1762
|
+
m.overResizeElement || m.dragElement || (m.overResizeElement = this, this.el.classList.remove("ui-resizable-autohide"));
|
|
1763
|
+
}
|
|
1764
|
+
/** @internal */
|
|
1765
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1766
|
+
_mouseOut(e) {
|
|
1767
|
+
m.overResizeElement === this && (delete m.overResizeElement, this.el.classList.add("ui-resizable-autohide"));
|
|
1768
|
+
}
|
|
1769
|
+
/** @internal */
|
|
1770
|
+
_setupHandlers() {
|
|
1771
|
+
return this.handlers = this.option.handles.split(",").map((e) => e.trim()).map((e) => new ae(this.el, e, {
|
|
1772
|
+
start: (t) => {
|
|
1773
|
+
this._resizeStart(t);
|
|
1774
|
+
},
|
|
1775
|
+
stop: (t) => {
|
|
1776
|
+
this._resizeStop(t);
|
|
1777
|
+
},
|
|
1778
|
+
move: (t) => {
|
|
1779
|
+
this._resizing(t, e);
|
|
1780
|
+
}
|
|
1781
|
+
})), this;
|
|
1782
|
+
}
|
|
1783
|
+
/** @internal */
|
|
1784
|
+
_resizeStart(e) {
|
|
1785
|
+
this.sizeToContent = a.shouldSizeToContent(this.el.gridstackNode, !0), this.originalRect = this.el.getBoundingClientRect(), this.scrollEl = a.getScrollElement(this.el), this.scrollY = this.scrollEl.scrollTop, this.scrolled = 0, this.startEvent = e, this._setupHelper(), this._applyChange();
|
|
1786
|
+
const t = a.initEvent(e, { type: "resizestart", target: this.el });
|
|
1787
|
+
return this.option.start && this.option.start(t, this._ui()), this.el.classList.add("ui-resizable-resizing"), this.triggerEvent("resizestart", t), this;
|
|
1788
|
+
}
|
|
1789
|
+
/** @internal */
|
|
1790
|
+
_resizing(e, t) {
|
|
1791
|
+
this.scrolled = this.scrollEl.scrollTop - this.scrollY, this.temporalRect = this._getChange(e, t), this._applyChange();
|
|
1792
|
+
const i = a.initEvent(e, { type: "resize", target: this.el });
|
|
1793
|
+
return this.option.resize && this.option.resize(i, this._ui()), this.triggerEvent("resize", i), this;
|
|
1794
|
+
}
|
|
1795
|
+
/** @internal */
|
|
1796
|
+
_resizeStop(e) {
|
|
1797
|
+
const t = a.initEvent(e, { type: "resizestop", target: this.el });
|
|
1798
|
+
return this.option.stop && this.option.stop(t), this.el.classList.remove("ui-resizable-resizing"), this.triggerEvent("resizestop", t), this._cleanHelper(), delete this.startEvent, delete this.originalRect, delete this.temporalRect, delete this.scrollY, delete this.scrolled, this;
|
|
1799
|
+
}
|
|
1800
|
+
/** @internal */
|
|
1801
|
+
_setupHelper() {
|
|
1802
|
+
this.elOriginStyleVal = Y._originStyleProp.map((i) => this.el.style[i]), this.parentOriginStylePosition = this.el.parentElement.style.position;
|
|
1803
|
+
const e = this.el.parentElement, t = a.getValuesFromTransformedElement(e);
|
|
1804
|
+
return this.rectScale = {
|
|
1805
|
+
x: t.xScale,
|
|
1806
|
+
y: t.yScale
|
|
1807
|
+
}, getComputedStyle(this.el.parentElement).position.match(/static/) && (this.el.parentElement.style.position = "relative"), this.el.style.position = "absolute", this.el.style.opacity = "0.8", this;
|
|
1808
|
+
}
|
|
1809
|
+
/** @internal */
|
|
1810
|
+
_cleanHelper() {
|
|
1811
|
+
return Y._originStyleProp.forEach((e, t) => {
|
|
1812
|
+
this.el.style[e] = this.elOriginStyleVal[t] || null;
|
|
1813
|
+
}), this.el.parentElement.style.position = this.parentOriginStylePosition || null, this;
|
|
1814
|
+
}
|
|
1815
|
+
/** @internal */
|
|
1816
|
+
_getChange(e, t) {
|
|
1817
|
+
const i = this.startEvent, s = {
|
|
1818
|
+
width: this.originalRect.width,
|
|
1819
|
+
height: this.originalRect.height + this.scrolled,
|
|
1820
|
+
left: this.originalRect.left,
|
|
1821
|
+
top: this.originalRect.top - this.scrolled
|
|
1822
|
+
}, r = e.clientX - i.clientX, o = this.sizeToContent ? 0 : e.clientY - i.clientY;
|
|
1823
|
+
let n, l;
|
|
1824
|
+
t.indexOf("e") > -1 ? s.width += r : t.indexOf("w") > -1 && (s.width -= r, s.left += r, n = !0), t.indexOf("s") > -1 ? s.height += o : t.indexOf("n") > -1 && (s.height -= o, s.top += o, l = !0);
|
|
1825
|
+
const h = this._constrainSize(s.width, s.height, n, l);
|
|
1826
|
+
return Math.round(s.width) !== Math.round(h.width) && (t.indexOf("w") > -1 && (s.left += s.width - h.width), s.width = h.width), Math.round(s.height) !== Math.round(h.height) && (t.indexOf("n") > -1 && (s.top += s.height - h.height), s.height = h.height), s;
|
|
1827
|
+
}
|
|
1828
|
+
/** @internal constrain the size to the set min/max values */
|
|
1829
|
+
_constrainSize(e, t, i, s) {
|
|
1830
|
+
const r = this.option, o = (i ? r.maxWidthMoveLeft : r.maxWidth) || Number.MAX_SAFE_INTEGER, n = r.minWidth / this.rectScale.x || e, l = (s ? r.maxHeightMoveUp : r.maxHeight) || Number.MAX_SAFE_INTEGER, h = r.minHeight / this.rectScale.y || t, d = Math.min(o, Math.max(n, e)), u = Math.min(l, Math.max(h, t));
|
|
1831
|
+
return { width: d, height: u };
|
|
1832
|
+
}
|
|
1833
|
+
/** @internal */
|
|
1834
|
+
_applyChange() {
|
|
1835
|
+
let e = { left: 0, top: 0, width: 0, height: 0 };
|
|
1836
|
+
if (this.el.style.position === "absolute") {
|
|
1837
|
+
const t = this.el.parentElement, { left: i, top: s } = t.getBoundingClientRect();
|
|
1838
|
+
e = { left: i, top: s, width: 0, height: 0 };
|
|
1839
|
+
}
|
|
1840
|
+
return this.temporalRect ? (Object.keys(this.temporalRect).forEach((t) => {
|
|
1841
|
+
const i = this.temporalRect[t], s = t === "width" || t === "left" ? this.rectScale.x : t === "height" || t === "top" ? this.rectScale.y : 1;
|
|
1842
|
+
this.el.style[t] = (i - e[t]) * s + "px";
|
|
1843
|
+
}), this) : this;
|
|
1844
|
+
}
|
|
1845
|
+
/** @internal */
|
|
1846
|
+
_removeHandlers() {
|
|
1847
|
+
return this.handlers.forEach((e) => e.destroy()), delete this.handlers, this;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
Y._originStyleProp = ["width", "height", "position", "left", "top", "opacity", "zIndex"];
|
|
1851
|
+
const Mt = 'input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';
|
|
1852
|
+
class X extends ue {
|
|
1853
|
+
constructor(e, t = {}) {
|
|
1854
|
+
var r;
|
|
1855
|
+
super(), this.el = e, this.option = t, this.dragTransform = {
|
|
1856
|
+
xScale: 1,
|
|
1857
|
+
yScale: 1,
|
|
1858
|
+
xOffset: 0,
|
|
1859
|
+
yOffset: 0
|
|
1860
|
+
};
|
|
1861
|
+
const i = (r = t == null ? void 0 : t.handle) == null ? void 0 : r.substring(1), s = e.gridstackNode;
|
|
1862
|
+
this.dragEls = !i || e.classList.contains(i) ? [e] : s != null && s.subGrid ? [e.querySelector(t.handle) || e] : Array.from(e.querySelectorAll(t.handle)), this.dragEls.length === 0 && (this.dragEls = [e]), this._mouseDown = this._mouseDown.bind(this), this._mouseMove = this._mouseMove.bind(this), this._mouseUp = this._mouseUp.bind(this), this._keyEvent = this._keyEvent.bind(this), this.enable();
|
|
1863
|
+
}
|
|
1864
|
+
on(e, t) {
|
|
1865
|
+
super.on(e, t);
|
|
1866
|
+
}
|
|
1867
|
+
off(e) {
|
|
1868
|
+
super.off(e);
|
|
1869
|
+
}
|
|
1870
|
+
enable() {
|
|
1871
|
+
this.disabled !== !1 && (super.enable(), this.dragEls.forEach((e) => {
|
|
1872
|
+
e.addEventListener("mousedown", this._mouseDown), O && (e.addEventListener("touchstart", ee), e.addEventListener("pointerdown", se));
|
|
1873
|
+
}), this.el.classList.remove("ui-draggable-disabled"));
|
|
1874
|
+
}
|
|
1875
|
+
disable(e = !1) {
|
|
1876
|
+
this.disabled !== !0 && (super.disable(), this.dragEls.forEach((t) => {
|
|
1877
|
+
t.removeEventListener("mousedown", this._mouseDown), O && (t.removeEventListener("touchstart", ee), t.removeEventListener("pointerdown", se));
|
|
1878
|
+
}), e || this.el.classList.add("ui-draggable-disabled"));
|
|
1879
|
+
}
|
|
1880
|
+
destroy() {
|
|
1881
|
+
this.dragTimeout && window.clearTimeout(this.dragTimeout), delete this.dragTimeout, this.mouseDownEvent && this._mouseUp(this.mouseDownEvent), this.disable(!0), delete this.el, delete this.helper, delete this.option, super.destroy();
|
|
1882
|
+
}
|
|
1883
|
+
updateOption(e) {
|
|
1884
|
+
return Object.keys(e).forEach((t) => this.option[t] = e[t]), this;
|
|
1885
|
+
}
|
|
1886
|
+
/** @internal call when mouse goes down before a dragstart happens */
|
|
1887
|
+
_mouseDown(e) {
|
|
1888
|
+
if (!m.mouseHandled)
|
|
1889
|
+
return e.button !== 0 || !this.dragEls.find((t) => t === e.target) && e.target.closest(Mt) || this.option.cancel && e.target.closest(this.option.cancel) || (this.mouseDownEvent = e, delete this.dragging, delete m.dragElement, delete m.dropElement, document.addEventListener("mousemove", this._mouseMove, { capture: !0, passive: !0 }), document.addEventListener("mouseup", this._mouseUp, !0), O && (e.currentTarget.addEventListener("touchmove", te), e.currentTarget.addEventListener("touchend", ie)), e.preventDefault(), document.activeElement && document.activeElement.blur(), m.mouseHandled = !0), !0;
|
|
1890
|
+
}
|
|
1891
|
+
/** @internal method to call actual drag event */
|
|
1892
|
+
_callDrag(e) {
|
|
1893
|
+
if (!this.dragging)
|
|
1894
|
+
return;
|
|
1895
|
+
const t = a.initEvent(e, { target: this.el, type: "drag" });
|
|
1896
|
+
this.option.drag && this.option.drag(t, this.ui()), this.triggerEvent("drag", t);
|
|
1897
|
+
}
|
|
1898
|
+
/** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
|
|
1899
|
+
_mouseMove(e) {
|
|
1900
|
+
var i;
|
|
1901
|
+
const t = this.mouseDownEvent;
|
|
1902
|
+
if (this.lastDrag = e, this.dragging)
|
|
1903
|
+
if (this._dragFollow(e), m.pauseDrag) {
|
|
1904
|
+
const s = Number.isInteger(m.pauseDrag) ? m.pauseDrag : 100;
|
|
1905
|
+
this.dragTimeout && window.clearTimeout(this.dragTimeout), this.dragTimeout = window.setTimeout(() => this._callDrag(e), s);
|
|
1906
|
+
} else
|
|
1907
|
+
this._callDrag(e);
|
|
1908
|
+
else if (Math.abs(e.x - t.x) + Math.abs(e.y - t.y) > 3) {
|
|
1909
|
+
this.dragging = !0, m.dragElement = this;
|
|
1910
|
+
const s = (i = this.el.gridstackNode) == null ? void 0 : i.grid;
|
|
1911
|
+
s ? m.dropElement = s.el.ddElement.ddDroppable : delete m.dropElement, this.helper = this._createHelper(), this._setupHelperContainmentStyle(), this.dragTransform = a.getValuesFromTransformedElement(this.helperContainment), this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment), this._setupHelperStyle(e);
|
|
1912
|
+
const r = a.initEvent(e, { target: this.el, type: "dragstart" });
|
|
1913
|
+
this.option.start && this.option.start(r, this.ui()), this.triggerEvent("dragstart", r), document.addEventListener("keydown", this._keyEvent);
|
|
1914
|
+
}
|
|
1915
|
+
return !0;
|
|
1916
|
+
}
|
|
1917
|
+
/** @internal call when the mouse gets released to drop the item at current location */
|
|
1918
|
+
_mouseUp(e) {
|
|
1919
|
+
var t, i;
|
|
1920
|
+
if (document.removeEventListener("mousemove", this._mouseMove, !0), document.removeEventListener("mouseup", this._mouseUp, !0), O && e.currentTarget && (e.currentTarget.removeEventListener("touchmove", te, !0), e.currentTarget.removeEventListener("touchend", ie, !0)), this.dragging) {
|
|
1921
|
+
delete this.dragging, (t = this.el.gridstackNode) == null || delete t._origRotate, document.removeEventListener("keydown", this._keyEvent), ((i = m.dropElement) == null ? void 0 : i.el) === this.el.parentElement && delete m.dropElement, this.helperContainment.style.position = this.parentOriginStylePosition || null, this.helper !== this.el && this.helper.remove(), this._removeHelperStyle();
|
|
1922
|
+
const s = a.initEvent(e, { target: this.el, type: "dragstop" });
|
|
1923
|
+
this.option.stop && this.option.stop(s), this.triggerEvent("dragstop", s), m.dropElement && m.dropElement.drop(e);
|
|
1924
|
+
}
|
|
1925
|
+
delete this.helper, delete this.mouseDownEvent, delete m.dragElement, delete m.dropElement, delete m.mouseHandled, e.preventDefault();
|
|
1926
|
+
}
|
|
1927
|
+
/** @internal call when keys are being pressed - use Esc to cancel, R to rotate */
|
|
1928
|
+
_keyEvent(e) {
|
|
1929
|
+
var s, r;
|
|
1930
|
+
const t = this.el.gridstackNode, i = (t == null ? void 0 : t.grid) || ((r = (s = m.dropElement) == null ? void 0 : s.el) == null ? void 0 : r.gridstack);
|
|
1931
|
+
if (e.key === "Escape")
|
|
1932
|
+
t && t._origRotate && (t._orig = t._origRotate, delete t._origRotate), i == null || i.cancelDrag(), this._mouseUp(this.mouseDownEvent);
|
|
1933
|
+
else if (t && i && (e.key === "r" || e.key === "R")) {
|
|
1934
|
+
if (!a.canBeRotated(t))
|
|
1935
|
+
return;
|
|
1936
|
+
t._origRotate = t._origRotate || { ...t._orig }, delete t._moving, i.setAnimation(!1).rotate(t.el, { top: -this.dragOffset.offsetTop, left: -this.dragOffset.offsetLeft }).setAnimation(), t._moving = !0, this.dragOffset = this._getDragOffset(this.lastDrag, t.el, this.helperContainment), this.helper.style.width = this.dragOffset.width + "px", this.helper.style.height = this.dragOffset.height + "px", a.swap(t._orig, "w", "h"), delete t._rect, this._mouseMove(this.lastDrag);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
/** @internal create a clone copy (or user defined method) of the original drag item if set */
|
|
1940
|
+
_createHelper() {
|
|
1941
|
+
let e = this.el;
|
|
1942
|
+
return typeof this.option.helper == "function" ? e = this.option.helper(this.el) : this.option.helper === "clone" && (e = a.cloneNode(this.el)), document.body.contains(e) || a.appendTo(e, this.option.appendTo === "parent" ? this.el.parentElement : this.option.appendTo), this.dragElementOriginStyle = X.originStyleProp.map((t) => this.el.style[t]), e;
|
|
1943
|
+
}
|
|
1944
|
+
/** @internal set the fix position of the dragged item */
|
|
1945
|
+
_setupHelperStyle(e) {
|
|
1946
|
+
this.helper.classList.add("ui-draggable-dragging");
|
|
1947
|
+
const t = this.helper.style;
|
|
1948
|
+
return t.pointerEvents = "none", t.width = this.dragOffset.width + "px", t.height = this.dragOffset.height + "px", t.willChange = "left, top", t.position = "fixed", this._dragFollow(e), t.transition = "none", setTimeout(() => {
|
|
1949
|
+
this.helper && (t.transition = null);
|
|
1950
|
+
}, 0), this;
|
|
1951
|
+
}
|
|
1952
|
+
/** @internal restore back the original style before dragging */
|
|
1953
|
+
_removeHelperStyle() {
|
|
1954
|
+
var t;
|
|
1955
|
+
this.helper.classList.remove("ui-draggable-dragging");
|
|
1956
|
+
const e = (t = this.helper) == null ? void 0 : t.gridstackNode;
|
|
1957
|
+
if (!(e != null && e._isAboutToRemove) && this.dragElementOriginStyle) {
|
|
1958
|
+
const i = this.helper, s = this.dragElementOriginStyle.transition || null;
|
|
1959
|
+
i.style.transition = this.dragElementOriginStyle.transition = "none", X.originStyleProp.forEach((r) => i.style[r] = this.dragElementOriginStyle[r] || null), setTimeout(() => i.style.transition = s, 50);
|
|
1960
|
+
}
|
|
1961
|
+
return delete this.dragElementOriginStyle, this;
|
|
1962
|
+
}
|
|
1963
|
+
/** @internal updates the top/left position to follow the mouse */
|
|
1964
|
+
_dragFollow(e) {
|
|
1965
|
+
const t = { left: 0, top: 0 }, i = this.helper.style, s = this.dragOffset;
|
|
1966
|
+
i.left = (e.clientX + s.offsetLeft - t.left) * this.dragTransform.xScale + "px", i.top = (e.clientY + s.offsetTop - t.top) * this.dragTransform.yScale + "px";
|
|
1967
|
+
}
|
|
1968
|
+
/** @internal */
|
|
1969
|
+
_setupHelperContainmentStyle() {
|
|
1970
|
+
return this.helperContainment = this.helper.parentElement, this.helper.style.position !== "fixed" && (this.parentOriginStylePosition = this.helperContainment.style.position, getComputedStyle(this.helperContainment).position.match(/static/) && (this.helperContainment.style.position = "relative")), this;
|
|
1971
|
+
}
|
|
1972
|
+
/** @internal */
|
|
1973
|
+
_getDragOffset(e, t, i) {
|
|
1974
|
+
let s = 0, r = 0;
|
|
1975
|
+
i && (s = this.dragTransform.xOffset, r = this.dragTransform.yOffset);
|
|
1976
|
+
const o = t.getBoundingClientRect();
|
|
1977
|
+
return {
|
|
1978
|
+
left: o.left,
|
|
1979
|
+
top: o.top,
|
|
1980
|
+
offsetLeft: -e.clientX + o.left - s,
|
|
1981
|
+
offsetTop: -e.clientY + o.top - r,
|
|
1982
|
+
width: o.width * this.dragTransform.xScale,
|
|
1983
|
+
height: o.height * this.dragTransform.yScale
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1986
|
+
/** @internal TODO: set to public as called by DDDroppable! */
|
|
1987
|
+
ui() {
|
|
1988
|
+
const t = this.el.parentElement.getBoundingClientRect(), i = this.helper.getBoundingClientRect();
|
|
1989
|
+
return {
|
|
1990
|
+
position: {
|
|
1991
|
+
top: (i.top - t.top) * this.dragTransform.yScale,
|
|
1992
|
+
left: (i.left - t.left) * this.dragTransform.xScale
|
|
1993
|
+
}
|
|
1994
|
+
/* not used by GridStack for now...
|
|
1995
|
+
helper: [this.helper], //The object arr representing the helper that's being dragged.
|
|
1996
|
+
offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.
|
|
1997
|
+
*/
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
X.originStyleProp = ["width", "height", "transform", "transform-origin", "transition", "pointerEvents", "position", "left", "top", "minWidth", "willChange"];
|
|
2002
|
+
class It extends ue {
|
|
2003
|
+
constructor(e, t = {}) {
|
|
2004
|
+
super(), this.el = e, this.option = t, this._mouseEnter = this._mouseEnter.bind(this), this._mouseLeave = this._mouseLeave.bind(this), this.enable(), this._setupAccept();
|
|
2005
|
+
}
|
|
2006
|
+
on(e, t) {
|
|
2007
|
+
super.on(e, t);
|
|
2008
|
+
}
|
|
2009
|
+
off(e) {
|
|
2010
|
+
super.off(e);
|
|
2011
|
+
}
|
|
2012
|
+
enable() {
|
|
2013
|
+
this.disabled !== !1 && (super.enable(), this.el.classList.add("ui-droppable"), this.el.classList.remove("ui-droppable-disabled"), this.el.addEventListener("mouseenter", this._mouseEnter), this.el.addEventListener("mouseleave", this._mouseLeave), O && (this.el.addEventListener("pointerenter", be), this.el.addEventListener("pointerleave", we)));
|
|
2014
|
+
}
|
|
2015
|
+
disable(e = !1) {
|
|
2016
|
+
this.disabled !== !0 && (super.disable(), this.el.classList.remove("ui-droppable"), e || this.el.classList.add("ui-droppable-disabled"), this.el.removeEventListener("mouseenter", this._mouseEnter), this.el.removeEventListener("mouseleave", this._mouseLeave), O && (this.el.removeEventListener("pointerenter", be), this.el.removeEventListener("pointerleave", we)));
|
|
2017
|
+
}
|
|
2018
|
+
destroy() {
|
|
2019
|
+
this.disable(!0), this.el.classList.remove("ui-droppable"), this.el.classList.remove("ui-droppable-disabled"), super.destroy();
|
|
2020
|
+
}
|
|
2021
|
+
updateOption(e) {
|
|
2022
|
+
return Object.keys(e).forEach((t) => this.option[t] = e[t]), this._setupAccept(), this;
|
|
2023
|
+
}
|
|
2024
|
+
/** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
|
|
2025
|
+
_mouseEnter(e) {
|
|
2026
|
+
if (!m.dragElement || !this._canDrop(m.dragElement.el))
|
|
2027
|
+
return;
|
|
2028
|
+
e.preventDefault(), e.stopPropagation(), m.dropElement && m.dropElement !== this && m.dropElement._mouseLeave(e, !0), m.dropElement = this;
|
|
2029
|
+
const t = a.initEvent(e, { target: this.el, type: "dropover" });
|
|
2030
|
+
this.option.over && this.option.over(t, this._ui(m.dragElement)), this.triggerEvent("dropover", t), this.el.classList.add("ui-droppable-over");
|
|
2031
|
+
}
|
|
2032
|
+
/** @internal called when the item is leaving our area, stop tracking if we had moving item */
|
|
2033
|
+
_mouseLeave(e, t = !1) {
|
|
2034
|
+
var s;
|
|
2035
|
+
if (!m.dragElement || m.dropElement !== this)
|
|
2036
|
+
return;
|
|
2037
|
+
e.preventDefault(), e.stopPropagation();
|
|
2038
|
+
const i = a.initEvent(e, { target: this.el, type: "dropout" });
|
|
2039
|
+
if (this.option.out && this.option.out(i, this._ui(m.dragElement)), this.triggerEvent("dropout", i), m.dropElement === this && (delete m.dropElement, !t)) {
|
|
2040
|
+
let r, o = this.el.parentElement;
|
|
2041
|
+
for (; !r && o; )
|
|
2042
|
+
r = (s = o.ddElement) == null ? void 0 : s.ddDroppable, o = o.parentElement;
|
|
2043
|
+
r && r._mouseEnter(e);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
/** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
|
|
2047
|
+
drop(e) {
|
|
2048
|
+
e.preventDefault();
|
|
2049
|
+
const t = a.initEvent(e, { target: this.el, type: "drop" });
|
|
2050
|
+
this.option.drop && this.option.drop(t, this._ui(m.dragElement)), this.triggerEvent("drop", t);
|
|
2051
|
+
}
|
|
2052
|
+
/** @internal true if element matches the string/method accept option */
|
|
2053
|
+
_canDrop(e) {
|
|
2054
|
+
return e && (!this.accept || this.accept(e));
|
|
2055
|
+
}
|
|
2056
|
+
/** @internal */
|
|
2057
|
+
_setupAccept() {
|
|
2058
|
+
return this.option.accept ? (typeof this.option.accept == "string" ? this.accept = (e) => e.classList.contains(this.option.accept) || e.matches(this.option.accept) : this.accept = this.option.accept, this) : this;
|
|
2059
|
+
}
|
|
2060
|
+
/** @internal */
|
|
2061
|
+
_ui(e) {
|
|
2062
|
+
return {
|
|
2063
|
+
draggable: e.el,
|
|
2064
|
+
...e.ui()
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
class ce {
|
|
2069
|
+
static init(e) {
|
|
2070
|
+
return e.ddElement || (e.ddElement = new ce(e)), e.ddElement;
|
|
2071
|
+
}
|
|
2072
|
+
constructor(e) {
|
|
2073
|
+
this.el = e;
|
|
2074
|
+
}
|
|
2075
|
+
on(e, t) {
|
|
2076
|
+
return this.ddDraggable && ["drag", "dragstart", "dragstop"].indexOf(e) > -1 ? this.ddDraggable.on(e, t) : this.ddDroppable && ["drop", "dropover", "dropout"].indexOf(e) > -1 ? this.ddDroppable.on(e, t) : this.ddResizable && ["resizestart", "resize", "resizestop"].indexOf(e) > -1 && this.ddResizable.on(e, t), this;
|
|
2077
|
+
}
|
|
2078
|
+
off(e) {
|
|
2079
|
+
return this.ddDraggable && ["drag", "dragstart", "dragstop"].indexOf(e) > -1 ? this.ddDraggable.off(e) : this.ddDroppable && ["drop", "dropover", "dropout"].indexOf(e) > -1 ? this.ddDroppable.off(e) : this.ddResizable && ["resizestart", "resize", "resizestop"].indexOf(e) > -1 && this.ddResizable.off(e), this;
|
|
2080
|
+
}
|
|
2081
|
+
setupDraggable(e) {
|
|
2082
|
+
return this.ddDraggable ? this.ddDraggable.updateOption(e) : this.ddDraggable = new X(this.el, e), this;
|
|
2083
|
+
}
|
|
2084
|
+
cleanDraggable() {
|
|
2085
|
+
return this.ddDraggable && (this.ddDraggable.destroy(), delete this.ddDraggable), this;
|
|
2086
|
+
}
|
|
2087
|
+
setupResizable(e) {
|
|
2088
|
+
return this.ddResizable ? this.ddResizable.updateOption(e) : this.ddResizable = new Y(this.el, e), this;
|
|
2089
|
+
}
|
|
2090
|
+
cleanResizable() {
|
|
2091
|
+
return this.ddResizable && (this.ddResizable.destroy(), delete this.ddResizable), this;
|
|
2092
|
+
}
|
|
2093
|
+
setupDroppable(e) {
|
|
2094
|
+
return this.ddDroppable ? this.ddDroppable.updateOption(e) : this.ddDroppable = new It(this.el, e), this;
|
|
2095
|
+
}
|
|
2096
|
+
cleanDroppable() {
|
|
2097
|
+
return this.ddDroppable && (this.ddDroppable.destroy(), delete this.ddDroppable), this;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
class Pt {
|
|
2101
|
+
resizable(e, t, i, s) {
|
|
2102
|
+
return this._getDDElements(e).forEach((r) => {
|
|
2103
|
+
if (t === "disable" || t === "enable")
|
|
2104
|
+
r.ddResizable && r.ddResizable[t]();
|
|
2105
|
+
else if (t === "destroy")
|
|
2106
|
+
r.ddResizable && r.cleanResizable();
|
|
2107
|
+
else if (t === "option")
|
|
2108
|
+
r.setupResizable({ [i]: s });
|
|
2109
|
+
else {
|
|
2110
|
+
const n = r.el.gridstackNode.grid;
|
|
2111
|
+
let l = r.el.getAttribute("gs-resize-handles") || n.opts.resizable.handles || "e,s,se";
|
|
2112
|
+
l === "all" && (l = "n,e,s,w,se,sw,ne,nw");
|
|
2113
|
+
const h = !n.opts.alwaysShowResizeHandle;
|
|
2114
|
+
r.setupResizable({
|
|
2115
|
+
...n.opts.resizable,
|
|
2116
|
+
handles: l,
|
|
2117
|
+
autoHide: h,
|
|
2118
|
+
start: t.start,
|
|
2119
|
+
stop: t.stop,
|
|
2120
|
+
resize: t.resize
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
}), this;
|
|
2124
|
+
}
|
|
2125
|
+
draggable(e, t, i, s) {
|
|
2126
|
+
return this._getDDElements(e).forEach((r) => {
|
|
2127
|
+
if (t === "disable" || t === "enable")
|
|
2128
|
+
r.ddDraggable && r.ddDraggable[t]();
|
|
2129
|
+
else if (t === "destroy")
|
|
2130
|
+
r.ddDraggable && r.cleanDraggable();
|
|
2131
|
+
else if (t === "option")
|
|
2132
|
+
r.setupDraggable({ [i]: s });
|
|
2133
|
+
else {
|
|
2134
|
+
const o = r.el.gridstackNode.grid;
|
|
2135
|
+
r.setupDraggable({
|
|
2136
|
+
...o.opts.draggable,
|
|
2137
|
+
// containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),
|
|
2138
|
+
start: t.start,
|
|
2139
|
+
stop: t.stop,
|
|
2140
|
+
drag: t.drag
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
}), this;
|
|
2144
|
+
}
|
|
2145
|
+
dragIn(e, t) {
|
|
2146
|
+
return this._getDDElements(e).forEach((i) => i.setupDraggable(t)), this;
|
|
2147
|
+
}
|
|
2148
|
+
droppable(e, t, i, s) {
|
|
2149
|
+
return typeof t.accept == "function" && !t._accept && (t._accept = t.accept, t.accept = (r) => t._accept(r)), this._getDDElements(e).forEach((r) => {
|
|
2150
|
+
t === "disable" || t === "enable" ? r.ddDroppable && r.ddDroppable[t]() : t === "destroy" ? r.ddDroppable && r.cleanDroppable() : t === "option" ? r.setupDroppable({ [i]: s }) : r.setupDroppable(t);
|
|
2151
|
+
}), this;
|
|
2152
|
+
}
|
|
2153
|
+
/** true if element is droppable */
|
|
2154
|
+
isDroppable(e) {
|
|
2155
|
+
var t;
|
|
2156
|
+
return !!((t = e == null ? void 0 : e.ddElement) != null && t.ddDroppable && !e.ddElement.ddDroppable.disabled);
|
|
2157
|
+
}
|
|
2158
|
+
/** true if element is draggable */
|
|
2159
|
+
isDraggable(e) {
|
|
2160
|
+
var t;
|
|
2161
|
+
return !!((t = e == null ? void 0 : e.ddElement) != null && t.ddDraggable && !e.ddElement.ddDraggable.disabled);
|
|
2162
|
+
}
|
|
2163
|
+
/** true if element is draggable */
|
|
2164
|
+
isResizable(e) {
|
|
2165
|
+
var t;
|
|
2166
|
+
return !!((t = e == null ? void 0 : e.ddElement) != null && t.ddResizable && !e.ddElement.ddResizable.disabled);
|
|
2167
|
+
}
|
|
2168
|
+
on(e, t, i) {
|
|
2169
|
+
return this._getDDElements(e).forEach((s) => s.on(t, (r) => {
|
|
2170
|
+
i(r, m.dragElement ? m.dragElement.el : r.target, m.dragElement ? m.dragElement.helper : null);
|
|
2171
|
+
})), this;
|
|
2172
|
+
}
|
|
2173
|
+
off(e, t) {
|
|
2174
|
+
return this._getDDElements(e).forEach((i) => i.off(t)), this;
|
|
2175
|
+
}
|
|
2176
|
+
/** @internal returns a list of DD elements, creating them on the fly by default */
|
|
2177
|
+
_getDDElements(e, t = !0) {
|
|
2178
|
+
const i = a.getElements(e);
|
|
2179
|
+
if (!i.length)
|
|
2180
|
+
return [];
|
|
2181
|
+
const s = i.map((r) => r.ddElement || (t ? ce.init(r) : null));
|
|
2182
|
+
return t || s.filter((r) => r), s;
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
/*!
|
|
2186
|
+
* GridStack 11.3.0
|
|
2187
|
+
* https://gridstackjs.com/
|
|
2188
|
+
*
|
|
2189
|
+
* Copyright (c) 2021-2024 Alain Dumesny
|
|
2190
|
+
* see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
|
|
2191
|
+
*/
|
|
2192
|
+
const k = new Pt();
|
|
2193
|
+
class g {
|
|
2194
|
+
/**
|
|
2195
|
+
* initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will
|
|
2196
|
+
* simply return the existing instance (ignore any passed options). There is also an initAll() version that support
|
|
2197
|
+
* multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON.
|
|
2198
|
+
* @param options grid options (optional)
|
|
2199
|
+
* @param elOrString element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector)
|
|
2200
|
+
*
|
|
2201
|
+
* @example
|
|
2202
|
+
* const grid = GridStack.init();
|
|
2203
|
+
*
|
|
2204
|
+
* Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later
|
|
2205
|
+
* const grid = document.querySelector('.grid-stack').gridstack;
|
|
2206
|
+
*/
|
|
2207
|
+
static init(e = {}, t = ".grid-stack") {
|
|
2208
|
+
if (typeof document > "u")
|
|
2209
|
+
return null;
|
|
2210
|
+
const i = g.getGridElement(t);
|
|
2211
|
+
return i ? (i.gridstack || (i.gridstack = new g(i, a.cloneDeep(e))), i.gridstack) : (console.error(typeof t == "string" ? 'GridStack.initAll() no grid was found with selector "' + t + `" - element missing or wrong selector ?
|
|
2212
|
+
Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.` : "GridStack.init() no grid element was passed."), null);
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Will initialize a list of elements (given a selector) and return an array of grids.
|
|
2216
|
+
* @param options grid options (optional)
|
|
2217
|
+
* @param selector elements selector to convert to grids (default to '.grid-stack' class selector)
|
|
2218
|
+
*
|
|
2219
|
+
* @example
|
|
2220
|
+
* const grids = GridStack.initAll();
|
|
2221
|
+
* grids.forEach(...)
|
|
2222
|
+
*/
|
|
2223
|
+
static initAll(e = {}, t = ".grid-stack") {
|
|
2224
|
+
const i = [];
|
|
2225
|
+
return typeof document > "u" || (g.getGridElements(t).forEach((s) => {
|
|
2226
|
+
s.gridstack || (s.gridstack = new g(s, a.cloneDeep(e))), i.push(s.gridstack);
|
|
2227
|
+
}), i.length === 0 && console.error('GridStack.initAll() no grid was found with selector "' + t + `" - element missing or wrong selector ?
|
|
2228
|
+
Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)), i;
|
|
2229
|
+
}
|
|
2230
|
+
/**
|
|
2231
|
+
* call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then
|
|
2232
|
+
* grid.load() on any passed children (recursively). Great alternative to calling init() if you want entire grid to come from
|
|
2233
|
+
* JSON serialized data, including options.
|
|
2234
|
+
* @param parent HTML element parent to the grid
|
|
2235
|
+
* @param opt grids options used to initialize the grid, and list of children
|
|
2236
|
+
*/
|
|
2237
|
+
static addGrid(e, t = {}) {
|
|
2238
|
+
if (!e)
|
|
2239
|
+
return null;
|
|
2240
|
+
let i = e;
|
|
2241
|
+
if (i.gridstack) {
|
|
2242
|
+
const o = i.gridstack;
|
|
2243
|
+
return t && (o.opts = { ...o.opts, ...t }), t.children !== void 0 && o.load(t.children), o;
|
|
2244
|
+
}
|
|
2245
|
+
return (!e.classList.contains("grid-stack") || g.addRemoveCB) && (g.addRemoveCB ? i = g.addRemoveCB(e, t, !0, !0) : i = a.createDiv(["grid-stack", t.class], e)), g.init(t, i);
|
|
2246
|
+
}
|
|
2247
|
+
/** call this method to register your engine instead of the default one.
|
|
2248
|
+
* See instead `GridStackOptions.engineClass` if you only need to
|
|
2249
|
+
* replace just one instance.
|
|
2250
|
+
*/
|
|
2251
|
+
static registerEngine(e) {
|
|
2252
|
+
g.engineClass = e;
|
|
2253
|
+
}
|
|
2254
|
+
/** @internal create placeholder DIV as needed */
|
|
2255
|
+
get placeholder() {
|
|
2256
|
+
if (!this._placeholder) {
|
|
2257
|
+
this._placeholder = a.createDiv([this.opts.placeholderClass, A.itemClass, this.opts.itemClass]);
|
|
2258
|
+
const e = a.createDiv(["placeholder-content"], this._placeholder);
|
|
2259
|
+
this.opts.placeholderText && (e.textContent = this.opts.placeholderText);
|
|
2260
|
+
}
|
|
2261
|
+
return this._placeholder;
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Construct a grid item from the given element and options
|
|
2265
|
+
* @param el the HTML element tied to this grid after it's been initialized
|
|
2266
|
+
* @param opts grid options - public for classes to access, but use methods to modify!
|
|
2267
|
+
*/
|
|
2268
|
+
constructor(e, t = {}) {
|
|
2269
|
+
var u, f, _;
|
|
2270
|
+
this.el = e, this.opts = t, this.animationDelay = 310, this._gsEventHandler = {}, this._extraDragRow = 0, this.dragTransform = { xScale: 1, yScale: 1, xOffset: 0, yOffset: 0 }, e.gridstack = this, this.opts = t = t || {}, e.classList.contains("grid-stack") || this.el.classList.add("grid-stack"), t.row && (t.minRow = t.maxRow = t.row, delete t.row);
|
|
2271
|
+
const i = a.toNumber(e.getAttribute("gs-row"));
|
|
2272
|
+
t.column === "auto" && delete t.column, t.alwaysShowResizeHandle !== void 0 && (t._alwaysShowResizeHandle = t.alwaysShowResizeHandle);
|
|
2273
|
+
let s = (u = t.columnOpts) == null ? void 0 : u.breakpoints;
|
|
2274
|
+
const r = t;
|
|
2275
|
+
if (r.oneColumnModeDomSort && (delete r.oneColumnModeDomSort, console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")), r.oneColumnSize || r.disableOneColumnMode === !1) {
|
|
2276
|
+
const v = r.oneColumnSize || 768;
|
|
2277
|
+
delete r.oneColumnSize, delete r.disableOneColumnMode, t.columnOpts = t.columnOpts || {}, s = t.columnOpts.breakpoints = t.columnOpts.breakpoints || [];
|
|
2278
|
+
let b = s.find((p) => p.c === 1);
|
|
2279
|
+
b ? b.w = v : (b = { c: 1, w: v }, s.push(b, { c: 12, w: v + 1 }));
|
|
2280
|
+
}
|
|
2281
|
+
const o = t.columnOpts;
|
|
2282
|
+
o && (!o.columnWidth && !((f = o.breakpoints) != null && f.length) ? (delete t.columnOpts, s = void 0) : o.columnMax = o.columnMax || 12), (s == null ? void 0 : s.length) > 1 && s.sort((v, b) => (b.w || 0) - (v.w || 0));
|
|
2283
|
+
const n = {
|
|
2284
|
+
...a.cloneDeep(A),
|
|
2285
|
+
column: a.toNumber(e.getAttribute("gs-column")) || A.column,
|
|
2286
|
+
minRow: i || a.toNumber(e.getAttribute("gs-min-row")) || A.minRow,
|
|
2287
|
+
maxRow: i || a.toNumber(e.getAttribute("gs-max-row")) || A.maxRow,
|
|
2288
|
+
staticGrid: a.toBool(e.getAttribute("gs-static")) || A.staticGrid,
|
|
2289
|
+
sizeToContent: a.toBool(e.getAttribute("gs-size-to-content")) || void 0,
|
|
2290
|
+
draggable: {
|
|
2291
|
+
handle: (t.handleClass ? "." + t.handleClass : t.handle ? t.handle : "") || A.draggable.handle
|
|
2292
|
+
},
|
|
2293
|
+
removableOptions: {
|
|
2294
|
+
accept: t.itemClass || A.removableOptions.accept,
|
|
2295
|
+
decline: A.removableOptions.decline
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
e.getAttribute("gs-animate") && (n.animate = a.toBool(e.getAttribute("gs-animate"))), t = a.defaults(t, n), this._initMargin(), this.checkDynamicColumn(), this.el.classList.add("gs-" + t.column), t.rtl === "auto" && (t.rtl = e.style.direction === "rtl"), t.rtl && this.el.classList.add("grid-stack-rtl");
|
|
2299
|
+
const l = this.el.closest("." + A.itemClass), h = l == null ? void 0 : l.gridstackNode;
|
|
2300
|
+
h && (h.subGrid = this, this.parentGridNode = h, this.el.classList.add("grid-stack-nested"), h.el.classList.add("grid-stack-sub-grid")), this._isAutoCellHeight = t.cellHeight === "auto", this._isAutoCellHeight || t.cellHeight === "initial" ? this.cellHeight(void 0, !1) : (typeof t.cellHeight == "number" && t.cellHeightUnit && t.cellHeightUnit !== A.cellHeightUnit && (t.cellHeight = t.cellHeight + t.cellHeightUnit, delete t.cellHeightUnit), this.cellHeight(t.cellHeight, !1)), t.alwaysShowResizeHandle === "mobile" && (t.alwaysShowResizeHandle = O), this._styleSheetClass = "gs-id-" + P._idSeq++, this.el.classList.add(this._styleSheetClass), this._setStaticClass();
|
|
2301
|
+
const d = t.engineClass || g.engineClass || P;
|
|
2302
|
+
if (this.engine = new d({
|
|
2303
|
+
column: this.getColumn(),
|
|
2304
|
+
float: t.float,
|
|
2305
|
+
maxRow: t.maxRow,
|
|
2306
|
+
onChange: (v) => {
|
|
2307
|
+
let b = 0;
|
|
2308
|
+
this.engine.nodes.forEach((p) => {
|
|
2309
|
+
b = Math.max(b, p.y + p.h);
|
|
2310
|
+
}), v.forEach((p) => {
|
|
2311
|
+
const w = p.el;
|
|
2312
|
+
w && (p._removeDOM ? (w && w.remove(), delete p._removeDOM) : this._writePosAttr(w, p));
|
|
2313
|
+
}), this._updateStyles(!1, b);
|
|
2314
|
+
}
|
|
2315
|
+
}), this._updateStyles(!1, 0), t.auto && (this.batchUpdate(), this.engine._loading = !0, this.getGridItems().forEach((v) => this._prepareElement(v)), delete this.engine._loading, this.batchUpdate(!1)), t.children) {
|
|
2316
|
+
const v = t.children;
|
|
2317
|
+
delete t.children, v.length && this.load(v);
|
|
2318
|
+
}
|
|
2319
|
+
this.setAnimation(), t.subGridDynamic && !m.pauseDrag && (m.pauseDrag = !0), ((_ = t.draggable) == null ? void 0 : _.pause) !== void 0 && (m.pauseDrag = t.draggable.pause), this._setupRemoveDrop(), this._setupAcceptWidget(), this._updateResizeEvent();
|
|
2320
|
+
}
|
|
2321
|
+
/**
|
|
2322
|
+
* add a new widget and returns it.
|
|
2323
|
+
*
|
|
2324
|
+
* Widget will be always placed even if result height is more than actual grid height.
|
|
2325
|
+
* You need to use `willItFit()` before calling addWidget for additional check.
|
|
2326
|
+
* See also `makeWidget(el)` for DOM element.
|
|
2327
|
+
*
|
|
2328
|
+
* @example
|
|
2329
|
+
* const grid = GridStack.init();
|
|
2330
|
+
* grid.addWidget({w: 3, content: 'hello'});
|
|
2331
|
+
*
|
|
2332
|
+
* @param w GridStackWidget definition. used MakeWidget(el) if you have dom element instead.
|
|
2333
|
+
*/
|
|
2334
|
+
addWidget(e) {
|
|
2335
|
+
if (typeof e == "string") {
|
|
2336
|
+
console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
if (e.ELEMENT_NODE)
|
|
2340
|
+
return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"), this.makeWidget(e);
|
|
2341
|
+
let t, i = e;
|
|
2342
|
+
if (i.grid = this, i != null && i.el ? t = i.el : g.addRemoveCB ? t = g.addRemoveCB(this.el, e, !0, !1) : t = a.createWidgetDivs(this.opts.itemClass, i), !t)
|
|
2343
|
+
return;
|
|
2344
|
+
if (i = t.gridstackNode, i && t.parentElement === this.el && this.engine.nodes.find((r) => r._id === i._id))
|
|
2345
|
+
return t;
|
|
2346
|
+
const s = this._readAttr(t);
|
|
2347
|
+
return a.defaults(e, s), this.engine.prepareNode(e), this.el.appendChild(t), this.makeWidget(t, e), t;
|
|
2348
|
+
}
|
|
2349
|
+
/**
|
|
2350
|
+
* Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
|
|
2351
|
+
* from the parent's subGrid options.
|
|
2352
|
+
* @param el gridItem element to convert
|
|
2353
|
+
* @param ops (optional) sub-grid options, else default to node, then parent settings, else defaults
|
|
2354
|
+
* @param nodeToAdd (optional) node to add to the newly created sub grid (used when dragging over existing regular item)
|
|
2355
|
+
* @param saveContent if true (default) the html inside .grid-stack-content will be saved to child widget
|
|
2356
|
+
* @returns newly created grid
|
|
2357
|
+
*/
|
|
2358
|
+
makeSubGrid(e, t, i, s = !0) {
|
|
2359
|
+
var _, v, b;
|
|
2360
|
+
let r = e.gridstackNode;
|
|
2361
|
+
if (r || (r = this.makeWidget(e).gridstackNode), (_ = r.subGrid) != null && _.el)
|
|
2362
|
+
return r.subGrid;
|
|
2363
|
+
let o, n = this;
|
|
2364
|
+
for (; n && !o; )
|
|
2365
|
+
o = (v = n.opts) == null ? void 0 : v.subGridOpts, n = (b = n.parentGridNode) == null ? void 0 : b.grid;
|
|
2366
|
+
t = a.cloneDeep({
|
|
2367
|
+
// by default sub-grid inherit from us | parent, other than id, children, etc...
|
|
2368
|
+
...this.opts,
|
|
2369
|
+
id: void 0,
|
|
2370
|
+
children: void 0,
|
|
2371
|
+
column: "auto",
|
|
2372
|
+
columnOpts: void 0,
|
|
2373
|
+
layout: "list",
|
|
2374
|
+
subGridOpts: void 0,
|
|
2375
|
+
...o || {},
|
|
2376
|
+
...t || r.subGridOpts || {}
|
|
2377
|
+
}), r.subGridOpts = t;
|
|
2378
|
+
let l;
|
|
2379
|
+
t.column === "auto" && (l = !0, t.column = Math.max(r.w || 1, (i == null ? void 0 : i.w) || 1), delete t.columnOpts);
|
|
2380
|
+
let h = r.el.querySelector(".grid-stack-item-content"), d, u;
|
|
2381
|
+
if (s && (this._removeDD(r.el), u = { ...r, x: 0, y: 0 }, a.removeInternalForSave(u), delete u.subGridOpts, r.content && (u.content = r.content, delete r.content), g.addRemoveCB ? d = g.addRemoveCB(this.el, u, !0, !1) : (d = a.createDiv(["grid-stack-item"]), d.appendChild(h), h = a.createDiv(["grid-stack-item-content"], r.el)), this._prepareDragDropByNode(r)), i) {
|
|
2382
|
+
const p = l ? t.column : r.w, w = r.h + i.h, C = r.el.style;
|
|
2383
|
+
C.transition = "none", this.update(r.el, { w: p, h: w }), setTimeout(() => C.transition = null);
|
|
2384
|
+
}
|
|
2385
|
+
const f = r.subGrid = g.addGrid(h, t);
|
|
2386
|
+
return i != null && i._moving && (f._isTemp = !0), l && (f._autoColumn = !0), s && f.makeWidget(d, u), i && (i._moving ? window.setTimeout(() => a.simulateMouseEvent(i._event, "mouseenter", f.el), 0) : f.makeWidget(r.el, r)), this.resizeToContentCheck(!1, r), f;
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* called when an item was converted into a nested grid to accommodate a dragged over item, but then item leaves - return back
|
|
2390
|
+
* to the original grid-item. Also called to remove empty sub-grids when last item is dragged out (since re-creating is simple)
|
|
2391
|
+
*/
|
|
2392
|
+
removeAsSubGrid(e) {
|
|
2393
|
+
var i;
|
|
2394
|
+
const t = (i = this.parentGridNode) == null ? void 0 : i.grid;
|
|
2395
|
+
t && (t.batchUpdate(), t.removeWidget(this.parentGridNode.el, !0, !0), this.engine.nodes.forEach((s) => {
|
|
2396
|
+
s.x += this.parentGridNode.x, s.y += this.parentGridNode.y, t.makeWidget(s.el, s);
|
|
2397
|
+
}), t.batchUpdate(!1), this.parentGridNode && delete this.parentGridNode.subGrid, delete this.parentGridNode, e && window.setTimeout(() => a.simulateMouseEvent(e._event, "mouseenter", t.el), 0));
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* saves the current layout returning a list of widgets for serialization which might include any nested grids.
|
|
2401
|
+
* @param saveContent if true (default) the latest html inside .grid-stack-content will be saved to GridStackWidget.content field, else it will
|
|
2402
|
+
* be removed.
|
|
2403
|
+
* @param saveGridOpt if true (default false), save the grid options itself, so you can call the new GridStack.addGrid()
|
|
2404
|
+
* to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead.
|
|
2405
|
+
* @param saveCB callback for each node -> widget, so application can insert additional data to be saved into the widget data structure.
|
|
2406
|
+
* @returns list of widgets or full grid option, including .children list of widgets
|
|
2407
|
+
*/
|
|
2408
|
+
save(e = !0, t = !1, i = g.saveCB) {
|
|
2409
|
+
const s = this.engine.save(e, i);
|
|
2410
|
+
if (s.forEach((r) => {
|
|
2411
|
+
var o;
|
|
2412
|
+
if (e && r.el && !r.subGrid && !i) {
|
|
2413
|
+
const n = r.el.querySelector(".grid-stack-item-content");
|
|
2414
|
+
r.content = n == null ? void 0 : n.innerHTML, r.content || delete r.content;
|
|
2415
|
+
} else if (!e && !i && delete r.content, (o = r.subGrid) != null && o.el) {
|
|
2416
|
+
const n = r.subGrid.save(e, t, i);
|
|
2417
|
+
r.subGridOpts = t ? n : { children: n }, delete r.subGrid;
|
|
2418
|
+
}
|
|
2419
|
+
delete r.el;
|
|
2420
|
+
}), t) {
|
|
2421
|
+
const r = a.cloneDeep(this.opts);
|
|
2422
|
+
r.marginBottom === r.marginTop && r.marginRight === r.marginLeft && r.marginTop === r.marginRight && (r.margin = r.marginTop, delete r.marginTop, delete r.marginRight, delete r.marginBottom, delete r.marginLeft), r.rtl === (this.el.style.direction === "rtl") && (r.rtl = "auto"), this._isAutoCellHeight && (r.cellHeight = "auto"), this._autoColumn && (r.column = "auto");
|
|
2423
|
+
const o = r._alwaysShowResizeHandle;
|
|
2424
|
+
return delete r._alwaysShowResizeHandle, o !== void 0 ? r.alwaysShowResizeHandle = o : delete r.alwaysShowResizeHandle, a.removeInternalAndSame(r, A), r.children = s, r;
|
|
2425
|
+
}
|
|
2426
|
+
return s;
|
|
2427
|
+
}
|
|
2428
|
+
/**
|
|
2429
|
+
* load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
|
|
2430
|
+
*
|
|
2431
|
+
* @param layout list of widgets definition to update/create
|
|
2432
|
+
* @param addAndRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
|
|
2433
|
+
* the user control of insertion.
|
|
2434
|
+
*
|
|
2435
|
+
* @example
|
|
2436
|
+
* see http://gridstackjs.com/demo/serialization.html
|
|
2437
|
+
*/
|
|
2438
|
+
load(e, t = g.addRemoveCB || !0) {
|
|
2439
|
+
var h;
|
|
2440
|
+
e = a.cloneDeep(e);
|
|
2441
|
+
const i = this.getColumn();
|
|
2442
|
+
e.forEach((d) => {
|
|
2443
|
+
d.w = d.w || 1, d.h = d.h || 1;
|
|
2444
|
+
}), e = a.sort(e), this.engine.skipCacheUpdate = this._ignoreLayoutsNodeChange = !0;
|
|
2445
|
+
let s = 0;
|
|
2446
|
+
e.forEach((d) => {
|
|
2447
|
+
s = Math.max(s, (d.x || 0) + d.w);
|
|
2448
|
+
}), s > this.engine.defaultColumn && (this.engine.defaultColumn = s), s > i && this.engine.cacheLayout(e, s, !0);
|
|
2449
|
+
const r = g.addRemoveCB;
|
|
2450
|
+
typeof t == "function" && (g.addRemoveCB = t);
|
|
2451
|
+
const o = [];
|
|
2452
|
+
this.batchUpdate();
|
|
2453
|
+
const n = !this.engine.nodes.length;
|
|
2454
|
+
n && this.setAnimation(!1), !n && t && [...this.engine.nodes].forEach((u) => {
|
|
2455
|
+
if (!u.id)
|
|
2456
|
+
return;
|
|
2457
|
+
a.find(e, u.id) || (g.addRemoveCB && g.addRemoveCB(this.el, u, !1, !1), o.push(u), this.removeWidget(u.el, !0, !1));
|
|
2458
|
+
}), this.engine._loading = !0;
|
|
2459
|
+
const l = [];
|
|
2460
|
+
return this.engine.nodes = this.engine.nodes.filter((d) => a.find(e, d.id) ? (l.push(d), !1) : !0), e.forEach((d) => {
|
|
2461
|
+
var f;
|
|
2462
|
+
const u = a.find(l, d.id);
|
|
2463
|
+
if (u) {
|
|
2464
|
+
if (a.shouldSizeToContent(u) && (d.h = u.h), this.engine.nodeBoundFix(d), (d.autoPosition || d.x === void 0 || d.y === void 0) && (d.w = d.w || u.w, d.h = d.h || u.h, this.engine.findEmptyPosition(d)), this.engine.nodes.push(u), a.samePos(u, d) && this.engine.nodes.length > 1 && (this.moveNode(u, { ...d, forceCollide: !0 }), a.copyPos(d, u)), this.update(u.el, d), (f = d.subGridOpts) != null && f.children) {
|
|
2465
|
+
const _ = u.el.querySelector(".grid-stack");
|
|
2466
|
+
_ && _.gridstack && _.gridstack.load(d.subGridOpts.children);
|
|
2467
|
+
}
|
|
2468
|
+
} else t && this.addWidget(d);
|
|
2469
|
+
}), delete this.engine._loading, this.engine.removedNodes = o, this.batchUpdate(!1), delete this._ignoreLayoutsNodeChange, delete this.engine.skipCacheUpdate, r ? g.addRemoveCB = r : delete g.addRemoveCB, n && ((h = this.opts) != null && h.animate) && this.setAnimation(this.opts.animate, !0), this;
|
|
2470
|
+
}
|
|
2471
|
+
/**
|
|
2472
|
+
* use before calling a bunch of `addWidget()` to prevent un-necessary relayouts in between (more efficient)
|
|
2473
|
+
* and get a single event callback. You will see no changes until `batchUpdate(false)` is called.
|
|
2474
|
+
*/
|
|
2475
|
+
batchUpdate(e = !0) {
|
|
2476
|
+
return this.engine.batchUpdate(e), e || (this._updateContainerHeight(), this._triggerRemoveEvent(), this._triggerAddEvent(), this._triggerChangeEvent()), this;
|
|
2477
|
+
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Gets current cell height.
|
|
2480
|
+
*/
|
|
2481
|
+
getCellHeight(e = !1) {
|
|
2482
|
+
if (this.opts.cellHeight && this.opts.cellHeight !== "auto" && (!e || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === "px"))
|
|
2483
|
+
return this.opts.cellHeight;
|
|
2484
|
+
if (this.opts.cellHeightUnit === "rem")
|
|
2485
|
+
return this.opts.cellHeight * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
2486
|
+
if (this.opts.cellHeightUnit === "em")
|
|
2487
|
+
return this.opts.cellHeight * parseFloat(getComputedStyle(this.el).fontSize);
|
|
2488
|
+
if (this.opts.cellHeightUnit === "cm")
|
|
2489
|
+
return this.opts.cellHeight * (96 / 2.54);
|
|
2490
|
+
if (this.opts.cellHeightUnit === "mm")
|
|
2491
|
+
return this.opts.cellHeight * (96 / 2.54) / 10;
|
|
2492
|
+
const t = this.el.querySelector("." + this.opts.itemClass);
|
|
2493
|
+
if (t) {
|
|
2494
|
+
const s = a.toNumber(t.getAttribute("gs-h")) || 1;
|
|
2495
|
+
return Math.round(t.offsetHeight / s);
|
|
2496
|
+
}
|
|
2497
|
+
const i = parseInt(this.el.getAttribute("gs-current-row"));
|
|
2498
|
+
return i ? Math.round(this.el.getBoundingClientRect().height / i) : this.opts.cellHeight;
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Update current cell height - see `GridStackOptions.cellHeight` for format.
|
|
2502
|
+
* This method rebuilds an internal CSS style sheet.
|
|
2503
|
+
* Note: You can expect performance issues if call this method too often.
|
|
2504
|
+
*
|
|
2505
|
+
* @param val the cell height. If not passed (undefined), cells content will be made square (match width minus margin),
|
|
2506
|
+
* if pass 0 the CSS will be generated by the application instead.
|
|
2507
|
+
* @param update (Optional) if false, styles will not be updated
|
|
2508
|
+
*
|
|
2509
|
+
* @example
|
|
2510
|
+
* grid.cellHeight(100); // same as 100px
|
|
2511
|
+
* grid.cellHeight('70px');
|
|
2512
|
+
* grid.cellHeight(grid.cellWidth() * 1.2);
|
|
2513
|
+
*/
|
|
2514
|
+
cellHeight(e, t = !0) {
|
|
2515
|
+
if (t && e !== void 0 && this._isAutoCellHeight !== (e === "auto") && (this._isAutoCellHeight = e === "auto", this._updateResizeEvent()), (e === "initial" || e === "auto") && (e = void 0), e === void 0) {
|
|
2516
|
+
const s = -this.opts.marginRight - this.opts.marginLeft + this.opts.marginTop + this.opts.marginBottom;
|
|
2517
|
+
e = this.cellWidth() + s;
|
|
2518
|
+
}
|
|
2519
|
+
const i = a.parseHeight(e);
|
|
2520
|
+
return this.opts.cellHeightUnit === i.unit && this.opts.cellHeight === i.h ? this : (this.opts.cellHeightUnit = i.unit, this.opts.cellHeight = i.h, this.resizeToContentCheck(), t && this._updateStyles(!0), this);
|
|
2521
|
+
}
|
|
2522
|
+
/** Gets current cell width. */
|
|
2523
|
+
cellWidth() {
|
|
2524
|
+
return this._widthOrContainer() / this.getColumn();
|
|
2525
|
+
}
|
|
2526
|
+
/** return our expected width (or parent) , and optionally of window for dynamic column check */
|
|
2527
|
+
_widthOrContainer(e = !1) {
|
|
2528
|
+
var t;
|
|
2529
|
+
return e && ((t = this.opts.columnOpts) != null && t.breakpointForWindow) ? window.innerWidth : this.el.clientWidth || this.el.parentElement.clientWidth || window.innerWidth;
|
|
2530
|
+
}
|
|
2531
|
+
/** checks for dynamic column count for our current size, returning true if changed */
|
|
2532
|
+
checkDynamicColumn() {
|
|
2533
|
+
var r, o;
|
|
2534
|
+
const e = this.opts.columnOpts;
|
|
2535
|
+
if (!e || !e.columnWidth && !((r = e.breakpoints) != null && r.length))
|
|
2536
|
+
return !1;
|
|
2537
|
+
const t = this.getColumn();
|
|
2538
|
+
let i = t;
|
|
2539
|
+
const s = this._widthOrContainer(!0);
|
|
2540
|
+
if (e.columnWidth)
|
|
2541
|
+
i = Math.min(Math.round(s / e.columnWidth) || 1, e.columnMax);
|
|
2542
|
+
else {
|
|
2543
|
+
i = e.columnMax;
|
|
2544
|
+
let n = 0;
|
|
2545
|
+
for (; n < e.breakpoints.length && s <= e.breakpoints[n].w; )
|
|
2546
|
+
i = e.breakpoints[n++].c || t;
|
|
2547
|
+
}
|
|
2548
|
+
if (i !== t) {
|
|
2549
|
+
const n = (o = e.breakpoints) == null ? void 0 : o.find((l) => l.c === i);
|
|
2550
|
+
return this.column(i, (n == null ? void 0 : n.layout) || e.layout), !0;
|
|
2551
|
+
}
|
|
2552
|
+
return !1;
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* re-layout grid items to reclaim any empty space. Options are:
|
|
2556
|
+
* 'list' keep the widget left->right order the same, even if that means leaving an empty slot if things don't fit
|
|
2557
|
+
* 'compact' might re-order items to fill any empty space
|
|
2558
|
+
*
|
|
2559
|
+
* doSort - 'false' to let you do your own sorting ahead in case you need to control a different order. (default to sort)
|
|
2560
|
+
*/
|
|
2561
|
+
compact(e = "compact", t = !0) {
|
|
2562
|
+
return this.engine.compact(e, t), this._triggerChangeEvent(), this;
|
|
2563
|
+
}
|
|
2564
|
+
/**
|
|
2565
|
+
* set the number of columns in the grid. Will update existing widgets to conform to new number of columns,
|
|
2566
|
+
* as well as cache the original layout so you can revert back to previous positions without loss.
|
|
2567
|
+
* Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11],
|
|
2568
|
+
* else you will need to generate correct CSS (see https://github.com/gridstack/gridstack.js#change-grid-columns)
|
|
2569
|
+
* @param column - Integer > 0 (default 12).
|
|
2570
|
+
* @param layout specify the type of re-layout that will happen (position, size, etc...).
|
|
2571
|
+
* Note: items will never be outside of the current column boundaries. default ('moveScale'). Ignored for 1 column
|
|
2572
|
+
*/
|
|
2573
|
+
column(e, t = "moveScale") {
|
|
2574
|
+
if (!e || e < 1 || this.opts.column === e)
|
|
2575
|
+
return this;
|
|
2576
|
+
const i = this.getColumn();
|
|
2577
|
+
return this.opts.column = e, this.engine ? (this.engine.column = e, this.el.classList.remove("gs-" + i), this.el.classList.add("gs-" + e), this.engine.columnChanged(i, e, t), this._isAutoCellHeight && this.cellHeight(), this.resizeToContentCheck(!0), this._ignoreLayoutsNodeChange = !0, this._triggerChangeEvent(), delete this._ignoreLayoutsNodeChange, this) : this;
|
|
2578
|
+
}
|
|
2579
|
+
/**
|
|
2580
|
+
* get the number of columns in the grid (default 12)
|
|
2581
|
+
*/
|
|
2582
|
+
getColumn() {
|
|
2583
|
+
return this.opts.column;
|
|
2584
|
+
}
|
|
2585
|
+
/** returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order */
|
|
2586
|
+
getGridItems() {
|
|
2587
|
+
return Array.from(this.el.children).filter((e) => e.matches("." + this.opts.itemClass) && !e.matches("." + this.opts.placeholderClass));
|
|
2588
|
+
}
|
|
2589
|
+
/** true if changeCB should be ignored due to column change, sizeToContent, loading, etc... which caller can ignore for dirty flag case */
|
|
2590
|
+
isIgnoreChangeCB() {
|
|
2591
|
+
return this._ignoreLayoutsNodeChange;
|
|
2592
|
+
}
|
|
2593
|
+
/**
|
|
2594
|
+
* Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.
|
|
2595
|
+
* @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).
|
|
2596
|
+
*/
|
|
2597
|
+
destroy(e = !0) {
|
|
2598
|
+
var t, i;
|
|
2599
|
+
if (this.el)
|
|
2600
|
+
return this.offAll(), this._updateResizeEvent(!0), this.setStatic(!0, !1), this.setAnimation(!1), e ? this.el.parentNode.removeChild(this.el) : (this.removeAll(e), this.el.classList.remove(this._styleSheetClass), this.el.removeAttribute("gs-current-row")), this._removeStylesheet(), (t = this.parentGridNode) == null || delete t.subGrid, delete this.parentGridNode, delete this.opts, (i = this._placeholder) == null || delete i.gridstackNode, delete this._placeholder, delete this.engine, delete this.el.gridstack, delete this.el, this;
|
|
2601
|
+
}
|
|
2602
|
+
/**
|
|
2603
|
+
* enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)
|
|
2604
|
+
*/
|
|
2605
|
+
float(e) {
|
|
2606
|
+
return this.opts.float !== e && (this.opts.float = this.engine.float = e, this._triggerChangeEvent()), this;
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2609
|
+
* get the current float mode
|
|
2610
|
+
*/
|
|
2611
|
+
getFloat() {
|
|
2612
|
+
return this.engine.float;
|
|
2613
|
+
}
|
|
2614
|
+
/**
|
|
2615
|
+
* Get the position of the cell under a pixel on screen.
|
|
2616
|
+
* @param position the position of the pixel to resolve in
|
|
2617
|
+
* absolute coordinates, as an object with top and left properties
|
|
2618
|
+
* @param useDocRelative if true, value will be based on document position vs parent position (Optional. Default false).
|
|
2619
|
+
* Useful when grid is within `position: relative` element
|
|
2620
|
+
*
|
|
2621
|
+
* Returns an object with properties `x` and `y` i.e. the column and row in the grid.
|
|
2622
|
+
*/
|
|
2623
|
+
getCellFromPixel(e, t = !1) {
|
|
2624
|
+
const i = this.el.getBoundingClientRect();
|
|
2625
|
+
let s;
|
|
2626
|
+
t ? s = { top: i.top + document.documentElement.scrollTop, left: i.left } : s = { top: this.el.offsetTop, left: this.el.offsetLeft };
|
|
2627
|
+
const r = e.left - s.left, o = e.top - s.top, n = i.width / this.getColumn(), l = i.height / parseInt(this.el.getAttribute("gs-current-row"));
|
|
2628
|
+
return { x: Math.floor(r / n), y: Math.floor(o / l) };
|
|
2629
|
+
}
|
|
2630
|
+
/** returns the current number of rows, which will be at least `minRow` if set */
|
|
2631
|
+
getRow() {
|
|
2632
|
+
return Math.max(this.engine.getRow(), this.opts.minRow);
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* Checks if specified area is empty.
|
|
2636
|
+
* @param x the position x.
|
|
2637
|
+
* @param y the position y.
|
|
2638
|
+
* @param w the width of to check
|
|
2639
|
+
* @param h the height of to check
|
|
2640
|
+
*/
|
|
2641
|
+
isAreaEmpty(e, t, i, s) {
|
|
2642
|
+
return this.engine.isAreaEmpty(e, t, i, s);
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* If you add elements to your grid by hand (or have some framework creating DOM), you have to tell gridstack afterwards to make them widgets.
|
|
2646
|
+
* If you want gridstack to add the elements for you, use `addWidget()` instead.
|
|
2647
|
+
* Makes the given element a widget and returns it.
|
|
2648
|
+
* @param els widget or single selector to convert.
|
|
2649
|
+
* @param options widget definition to use instead of reading attributes or using default sizing values
|
|
2650
|
+
*
|
|
2651
|
+
* @example
|
|
2652
|
+
* const grid = GridStack.init();
|
|
2653
|
+
* grid.el.innerHtml = '<div id="1" gs-w="3"></div><div id="2"></div>';
|
|
2654
|
+
* grid.makeWidget('1');
|
|
2655
|
+
* grid.makeWidget('2', {w:2, content: 'hello'});
|
|
2656
|
+
*/
|
|
2657
|
+
makeWidget(e, t) {
|
|
2658
|
+
const i = g.getElement(e);
|
|
2659
|
+
if (!i)
|
|
2660
|
+
return;
|
|
2661
|
+
i.parentElement || this.el.appendChild(i), this._prepareElement(i, !0, t);
|
|
2662
|
+
const s = i.gridstackNode;
|
|
2663
|
+
this._updateContainerHeight(), s.subGridOpts && this.makeSubGrid(i, s.subGridOpts, void 0, !1);
|
|
2664
|
+
let r;
|
|
2665
|
+
return this.opts.column === 1 && !this._ignoreLayoutsNodeChange && (r = this._ignoreLayoutsNodeChange = !0), this._triggerAddEvent(), this._triggerChangeEvent(), r && delete this._ignoreLayoutsNodeChange, i;
|
|
2666
|
+
}
|
|
2667
|
+
on(e, t) {
|
|
2668
|
+
return e.indexOf(" ") !== -1 ? (e.split(" ").forEach((s) => this.on(s, t)), this) : (e === "change" || e === "added" || e === "removed" || e === "enable" || e === "disable" ? (e === "enable" || e === "disable" ? this._gsEventHandler[e] = (s) => t(s) : this._gsEventHandler[e] = (s) => {
|
|
2669
|
+
s.detail && t(s, s.detail);
|
|
2670
|
+
}, this.el.addEventListener(e, this._gsEventHandler[e])) : e === "drag" || e === "dragstart" || e === "dragstop" || e === "resizestart" || e === "resize" || e === "resizestop" || e === "dropped" || e === "resizecontent" ? this._gsEventHandler[e] = t : console.error("GridStack.on(" + e + ") event not supported"), this);
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* unsubscribe from the 'on' event GridStackEvent
|
|
2674
|
+
* @param name of the event (see possible values) or list of names space separated
|
|
2675
|
+
*/
|
|
2676
|
+
off(e) {
|
|
2677
|
+
return e.indexOf(" ") !== -1 ? (e.split(" ").forEach((i) => this.off(i)), this) : ((e === "change" || e === "added" || e === "removed" || e === "enable" || e === "disable") && this._gsEventHandler[e] && this.el.removeEventListener(e, this._gsEventHandler[e]), delete this._gsEventHandler[e], this);
|
|
2678
|
+
}
|
|
2679
|
+
/** remove all event handlers */
|
|
2680
|
+
offAll() {
|
|
2681
|
+
return Object.keys(this._gsEventHandler).forEach((e) => this.off(e)), this;
|
|
2682
|
+
}
|
|
2683
|
+
/**
|
|
2684
|
+
* Removes widget from the grid.
|
|
2685
|
+
* @param el widget or selector to modify
|
|
2686
|
+
* @param removeDOM if `false` DOM element won't be removed from the tree (Default? true).
|
|
2687
|
+
* @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).
|
|
2688
|
+
*/
|
|
2689
|
+
removeWidget(e, t = !0, i = !0) {
|
|
2690
|
+
return e ? (g.getElements(e).forEach((s) => {
|
|
2691
|
+
if (s.parentElement && s.parentElement !== this.el)
|
|
2692
|
+
return;
|
|
2693
|
+
let r = s.gridstackNode;
|
|
2694
|
+
r || (r = this.engine.nodes.find((o) => s === o.el)), r && (t && g.addRemoveCB && g.addRemoveCB(this.el, r, !1, !1), delete s.gridstackNode, this._removeDD(s), this.engine.removeNode(r, t, i), t && s.parentElement && s.remove());
|
|
2695
|
+
}), i && (this._triggerRemoveEvent(), this._triggerChangeEvent()), this) : (console.error("Error: GridStack.removeWidget(undefined) called"), this);
|
|
2696
|
+
}
|
|
2697
|
+
/**
|
|
2698
|
+
* Removes all widgets from the grid.
|
|
2699
|
+
* @param removeDOM if `false` DOM elements won't be removed from the tree (Default? `true`).
|
|
2700
|
+
* @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).
|
|
2701
|
+
*/
|
|
2702
|
+
removeAll(e = !0, t = !0) {
|
|
2703
|
+
return this.engine.nodes.forEach((i) => {
|
|
2704
|
+
e && g.addRemoveCB && g.addRemoveCB(this.el, i, !1, !1), delete i.el.gridstackNode, this.opts.staticGrid || this._removeDD(i.el);
|
|
2705
|
+
}), this.engine.removeAll(e, t), t && this._triggerRemoveEvent(), this;
|
|
2706
|
+
}
|
|
2707
|
+
/**
|
|
2708
|
+
* Toggle the grid animation state. Toggles the `grid-stack-animate` class.
|
|
2709
|
+
* @param doAnimate if true the grid will animate.
|
|
2710
|
+
* @param delay if true setting will be set on next event loop.
|
|
2711
|
+
*/
|
|
2712
|
+
setAnimation(e = this.opts.animate, t) {
|
|
2713
|
+
return t ? setTimeout(() => {
|
|
2714
|
+
this.opts && this.setAnimation(e);
|
|
2715
|
+
}) : e ? this.el.classList.add("grid-stack-animate") : this.el.classList.remove("grid-stack-animate"), this;
|
|
2716
|
+
}
|
|
2717
|
+
/** @internal */
|
|
2718
|
+
hasAnimationCSS() {
|
|
2719
|
+
return this.el.classList.contains("grid-stack-animate");
|
|
2720
|
+
}
|
|
2721
|
+
/**
|
|
2722
|
+
* Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.
|
|
2723
|
+
* Also toggle the grid-stack-static class.
|
|
2724
|
+
* @param val if true the grid become static.
|
|
2725
|
+
* @param updateClass true (default) if css class gets updated
|
|
2726
|
+
* @param recurse true (default) if sub-grids also get updated
|
|
2727
|
+
*/
|
|
2728
|
+
setStatic(e, t = !0, i = !0) {
|
|
2729
|
+
return !!this.opts.staticGrid === e ? this : (e ? this.opts.staticGrid = !0 : delete this.opts.staticGrid, this._setupRemoveDrop(), this._setupAcceptWidget(), this.engine.nodes.forEach((s) => {
|
|
2730
|
+
this._prepareDragDropByNode(s), s.subGrid && i && s.subGrid.setStatic(e, t, i);
|
|
2731
|
+
}), t && this._setStaticClass(), this);
|
|
2732
|
+
}
|
|
2733
|
+
/**
|
|
2734
|
+
* Updates widget position/size and other info. Note: if you need to call this on all nodes, use load() instead which will update what changed.
|
|
2735
|
+
* @param els widget or selector of objects to modify (note: setting the same x,y for multiple items will be indeterministic and likely unwanted)
|
|
2736
|
+
* @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.
|
|
2737
|
+
*/
|
|
2738
|
+
update(e, t) {
|
|
2739
|
+
if (arguments.length > 2) {
|
|
2740
|
+
console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");
|
|
2741
|
+
const i = arguments;
|
|
2742
|
+
let s = 1;
|
|
2743
|
+
return t = { x: i[s++], y: i[s++], w: i[s++], h: i[s++] }, this.update(e, t);
|
|
2744
|
+
}
|
|
2745
|
+
return g.getElements(e).forEach((i) => {
|
|
2746
|
+
var d;
|
|
2747
|
+
const s = i == null ? void 0 : i.gridstackNode;
|
|
2748
|
+
if (!s)
|
|
2749
|
+
return;
|
|
2750
|
+
const r = a.cloneDeep(t);
|
|
2751
|
+
this.engine.nodeBoundFix(r), delete r.autoPosition;
|
|
2752
|
+
const o = ["x", "y", "w", "h"];
|
|
2753
|
+
let n;
|
|
2754
|
+
if (o.some((u) => r[u] !== void 0 && r[u] !== s[u]) && (n = {}, o.forEach((u) => {
|
|
2755
|
+
n[u] = r[u] !== void 0 ? r[u] : s[u], delete r[u];
|
|
2756
|
+
})), !n && (r.minW || r.minH || r.maxW || r.maxH) && (n = {}), r.content !== void 0) {
|
|
2757
|
+
const u = i.querySelector(".grid-stack-item-content");
|
|
2758
|
+
u && u.textContent !== r.content && (s.content = r.content, g.renderCB(u, r), (d = s.subGrid) != null && d.el && (u.appendChild(s.subGrid.el), s.subGrid.opts.styleInHead || s.subGrid._updateStyles(!0))), delete r.content;
|
|
2759
|
+
}
|
|
2760
|
+
let l = !1, h = !1;
|
|
2761
|
+
for (const u in r)
|
|
2762
|
+
u[0] !== "_" && s[u] !== r[u] && (s[u] = r[u], l = !0, h = h || !this.opts.staticGrid && (u === "noResize" || u === "noMove" || u === "locked"));
|
|
2763
|
+
if (a.sanitizeMinMax(s), n) {
|
|
2764
|
+
const u = n.w !== void 0 && n.w !== s.w;
|
|
2765
|
+
this.moveNode(s, n), u && s.subGrid ? s.subGrid.onResize(this.hasAnimationCSS() ? s.w : void 0) : this.resizeToContentCheck(u, s), delete s._orig;
|
|
2766
|
+
}
|
|
2767
|
+
(n || l) && this._writeAttr(i, s), h && this._prepareDragDropByNode(s);
|
|
2768
|
+
}), this;
|
|
2769
|
+
}
|
|
2770
|
+
moveNode(e, t) {
|
|
2771
|
+
const i = e._updating;
|
|
2772
|
+
i || this.engine.cleanNodes().beginUpdate(e), this.engine.moveNode(e, t), this._updateContainerHeight(), i || (this._triggerChangeEvent(), this.engine.endUpdate());
|
|
2773
|
+
}
|
|
2774
|
+
/**
|
|
2775
|
+
* Updates widget height to match the content height to avoid v-scrollbar or dead space.
|
|
2776
|
+
* Note: this assumes only 1 child under resizeToContentParent='.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted.
|
|
2777
|
+
* @param el grid item element
|
|
2778
|
+
* @param useNodeH set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights
|
|
2779
|
+
*/
|
|
2780
|
+
resizeToContent(e) {
|
|
2781
|
+
var f, _;
|
|
2782
|
+
if (!e || (e.classList.remove("size-to-content-max"), !e.clientHeight))
|
|
2783
|
+
return;
|
|
2784
|
+
const t = e.gridstackNode;
|
|
2785
|
+
if (!t)
|
|
2786
|
+
return;
|
|
2787
|
+
const i = t.grid;
|
|
2788
|
+
if (!i || e.parentElement !== i.el)
|
|
2789
|
+
return;
|
|
2790
|
+
const s = i.getCellHeight(!0);
|
|
2791
|
+
if (!s)
|
|
2792
|
+
return;
|
|
2793
|
+
let r = t.h ? t.h * s : e.clientHeight, o;
|
|
2794
|
+
if (t.resizeToContentParent && (o = e.querySelector(t.resizeToContentParent)), o || (o = e.querySelector(g.resizeToContentParent)), !o)
|
|
2795
|
+
return;
|
|
2796
|
+
const n = e.clientHeight - o.clientHeight, l = t.h ? t.h * s - n : o.clientHeight;
|
|
2797
|
+
let h;
|
|
2798
|
+
if (t.subGrid) {
|
|
2799
|
+
h = t.subGrid.getRow() * t.subGrid.getCellHeight(!0);
|
|
2800
|
+
const v = t.subGrid.el.getBoundingClientRect(), b = t.subGrid.el.parentElement.getBoundingClientRect();
|
|
2801
|
+
h += v.top - b.top;
|
|
2802
|
+
} else {
|
|
2803
|
+
if ((_ = (f = t.subGridOpts) == null ? void 0 : f.children) != null && _.length)
|
|
2804
|
+
return;
|
|
2805
|
+
{
|
|
2806
|
+
const v = o.firstElementChild;
|
|
2807
|
+
if (!v) {
|
|
2808
|
+
console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${g.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);
|
|
2809
|
+
return;
|
|
2810
|
+
}
|
|
2811
|
+
h = v.getBoundingClientRect().height || l;
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
if (l === h)
|
|
2815
|
+
return;
|
|
2816
|
+
r += h - l;
|
|
2817
|
+
let d = Math.ceil(r / s);
|
|
2818
|
+
const u = Number.isInteger(t.sizeToContent) ? t.sizeToContent : 0;
|
|
2819
|
+
u && d > u && (d = u, e.classList.add("size-to-content-max")), t.minH && d < t.minH ? d = t.minH : t.maxH && d > t.maxH && (d = t.maxH), d !== t.h && (i._ignoreLayoutsNodeChange = !0, i.moveNode(t, { h: d }), delete i._ignoreLayoutsNodeChange);
|
|
2820
|
+
}
|
|
2821
|
+
/** call the user resize (so they can do extra work) else our build in version */
|
|
2822
|
+
resizeToContentCBCheck(e) {
|
|
2823
|
+
g.resizeToContentCB ? g.resizeToContentCB(e) : this.resizeToContent(e);
|
|
2824
|
+
}
|
|
2825
|
+
/** rotate (by swapping w & h) the passed in node - called when user press 'r' during dragging
|
|
2826
|
+
* @param els widget or selector of objects to modify
|
|
2827
|
+
* @param relative optional pixel coord relative to upper/left corner to rotate around (will keep that cell under cursor)
|
|
2828
|
+
*/
|
|
2829
|
+
rotate(e, t) {
|
|
2830
|
+
return g.getElements(e).forEach((i) => {
|
|
2831
|
+
const s = i.gridstackNode;
|
|
2832
|
+
if (!a.canBeRotated(s))
|
|
2833
|
+
return;
|
|
2834
|
+
const r = { w: s.h, h: s.w, minH: s.minW, minW: s.minH, maxH: s.maxW, maxW: s.maxH };
|
|
2835
|
+
if (t) {
|
|
2836
|
+
const n = t.left > 0 ? Math.floor(t.left / this.cellWidth()) : 0, l = t.top > 0 ? Math.floor(t.top / this.opts.cellHeight) : 0;
|
|
2837
|
+
r.x = s.x + n - (s.h - (l + 1)), r.y = s.y + l - n;
|
|
2838
|
+
}
|
|
2839
|
+
Object.keys(r).forEach((n) => {
|
|
2840
|
+
r[n] === void 0 && delete r[n];
|
|
2841
|
+
});
|
|
2842
|
+
const o = s._orig;
|
|
2843
|
+
this.update(i, r), s._orig = o;
|
|
2844
|
+
}), this;
|
|
2845
|
+
}
|
|
2846
|
+
/**
|
|
2847
|
+
* Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).
|
|
2848
|
+
* @param value margin value
|
|
2849
|
+
*/
|
|
2850
|
+
margin(e) {
|
|
2851
|
+
if (!(typeof e == "string" && e.split(" ").length > 1)) {
|
|
2852
|
+
const i = a.parseHeight(e);
|
|
2853
|
+
if (this.opts.marginUnit === i.unit && this.opts.margin === i.h)
|
|
2854
|
+
return;
|
|
2855
|
+
}
|
|
2856
|
+
return this.opts.margin = e, this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = void 0, this._initMargin(), this._updateStyles(!0), this;
|
|
2857
|
+
}
|
|
2858
|
+
/** returns current margin number value (undefined if 4 sides don't match) */
|
|
2859
|
+
getMargin() {
|
|
2860
|
+
return this.opts.margin;
|
|
2861
|
+
}
|
|
2862
|
+
/**
|
|
2863
|
+
* Returns true if the height of the grid will be less than the vertical
|
|
2864
|
+
* constraint. Always returns true if grid doesn't have height constraint.
|
|
2865
|
+
* @param node contains x,y,w,h,auto-position options
|
|
2866
|
+
*
|
|
2867
|
+
* @example
|
|
2868
|
+
* if (grid.willItFit(newWidget)) {
|
|
2869
|
+
* grid.addWidget(newWidget);
|
|
2870
|
+
* } else {
|
|
2871
|
+
* alert('Not enough free space to place the widget');
|
|
2872
|
+
* }
|
|
2873
|
+
*/
|
|
2874
|
+
willItFit(e) {
|
|
2875
|
+
if (arguments.length > 1) {
|
|
2876
|
+
console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");
|
|
2877
|
+
const t = arguments;
|
|
2878
|
+
let i = 0, s = { x: t[i++], y: t[i++], w: t[i++], h: t[i++], autoPosition: t[i++] };
|
|
2879
|
+
return this.willItFit(s);
|
|
2880
|
+
}
|
|
2881
|
+
return this.engine.willItFit(e);
|
|
2882
|
+
}
|
|
2883
|
+
/** @internal */
|
|
2884
|
+
_triggerChangeEvent() {
|
|
2885
|
+
if (this.engine.batchMode)
|
|
2886
|
+
return this;
|
|
2887
|
+
const e = this.engine.getDirtyNodes(!0);
|
|
2888
|
+
return e && e.length && (this._ignoreLayoutsNodeChange || this.engine.layoutsNodesChange(e), this._triggerEvent("change", e)), this.engine.saveInitial(), this;
|
|
2889
|
+
}
|
|
2890
|
+
/** @internal */
|
|
2891
|
+
_triggerAddEvent() {
|
|
2892
|
+
var e;
|
|
2893
|
+
if (this.engine.batchMode)
|
|
2894
|
+
return this;
|
|
2895
|
+
if ((e = this.engine.addedNodes) != null && e.length) {
|
|
2896
|
+
this._ignoreLayoutsNodeChange || this.engine.layoutsNodesChange(this.engine.addedNodes), this.engine.addedNodes.forEach((i) => {
|
|
2897
|
+
delete i._dirty;
|
|
2898
|
+
});
|
|
2899
|
+
const t = [...this.engine.addedNodes];
|
|
2900
|
+
this.engine.addedNodes = [], this._triggerEvent("added", t);
|
|
2901
|
+
}
|
|
2902
|
+
return this;
|
|
2903
|
+
}
|
|
2904
|
+
/** @internal */
|
|
2905
|
+
_triggerRemoveEvent() {
|
|
2906
|
+
var e;
|
|
2907
|
+
if (this.engine.batchMode)
|
|
2908
|
+
return this;
|
|
2909
|
+
if ((e = this.engine.removedNodes) != null && e.length) {
|
|
2910
|
+
const t = [...this.engine.removedNodes];
|
|
2911
|
+
this.engine.removedNodes = [], this._triggerEvent("removed", t);
|
|
2912
|
+
}
|
|
2913
|
+
return this;
|
|
2914
|
+
}
|
|
2915
|
+
/** @internal */
|
|
2916
|
+
_triggerEvent(e, t) {
|
|
2917
|
+
const i = t ? new CustomEvent(e, { bubbles: !1, detail: t }) : new Event(e);
|
|
2918
|
+
return this.el.dispatchEvent(i), this;
|
|
2919
|
+
}
|
|
2920
|
+
/** @internal called to delete the current dynamic style sheet used for our layout */
|
|
2921
|
+
_removeStylesheet() {
|
|
2922
|
+
if (this._styles) {
|
|
2923
|
+
const e = this.opts.styleInHead ? void 0 : this.el.parentNode;
|
|
2924
|
+
a.removeStylesheet(this._styleSheetClass, e), delete this._styles;
|
|
2925
|
+
}
|
|
2926
|
+
return this;
|
|
2927
|
+
}
|
|
2928
|
+
/** @internal updated/create the CSS styles for row based layout and initial margin setting */
|
|
2929
|
+
_updateStyles(e = !1, t) {
|
|
2930
|
+
if (e && this._removeStylesheet(), t === void 0 && (t = this.getRow()), this._updateContainerHeight(), this.opts.cellHeight === 0)
|
|
2931
|
+
return this;
|
|
2932
|
+
const i = this.opts.cellHeight, s = this.opts.cellHeightUnit, r = `.${this._styleSheetClass} > .${this.opts.itemClass}`;
|
|
2933
|
+
if (!this._styles) {
|
|
2934
|
+
const o = this.opts.styleInHead ? void 0 : this.el.parentNode;
|
|
2935
|
+
if (this._styles = a.createStylesheet(this._styleSheetClass, o, {
|
|
2936
|
+
nonce: this.opts.nonce
|
|
2937
|
+
}), !this._styles)
|
|
2938
|
+
return this;
|
|
2939
|
+
this._styles._max = 0, a.addCSSRule(this._styles, r, `height: ${i}${s}`);
|
|
2940
|
+
const n = this.opts.marginTop + this.opts.marginUnit, l = this.opts.marginBottom + this.opts.marginUnit, h = this.opts.marginRight + this.opts.marginUnit, d = this.opts.marginLeft + this.opts.marginUnit, u = `${r} > .grid-stack-item-content`, f = `.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;
|
|
2941
|
+
a.addCSSRule(this._styles, u, `top: ${n}; right: ${h}; bottom: ${l}; left: ${d};`), a.addCSSRule(this._styles, f, `top: ${n}; right: ${h}; bottom: ${l}; left: ${d};`), a.addCSSRule(this._styles, `${r} > .ui-resizable-n`, `top: ${n};`), a.addCSSRule(this._styles, `${r} > .ui-resizable-s`, `bottom: ${l}`), a.addCSSRule(this._styles, `${r} > .ui-resizable-ne`, `right: ${h}; top: ${n}`), a.addCSSRule(this._styles, `${r} > .ui-resizable-e`, `right: ${h}`), a.addCSSRule(this._styles, `${r} > .ui-resizable-se`, `right: ${h}; bottom: ${l}`), a.addCSSRule(this._styles, `${r} > .ui-resizable-nw`, `left: ${d}; top: ${n}`), a.addCSSRule(this._styles, `${r} > .ui-resizable-w`, `left: ${d}`), a.addCSSRule(this._styles, `${r} > .ui-resizable-sw`, `left: ${d}; bottom: ${l}`);
|
|
2942
|
+
}
|
|
2943
|
+
if (t = t || this._styles._max, t > this._styles._max) {
|
|
2944
|
+
const o = (n) => i * n + s;
|
|
2945
|
+
for (let n = this._styles._max + 1; n <= t; n++)
|
|
2946
|
+
a.addCSSRule(this._styles, `${r}[gs-y="${n}"]`, `top: ${o(n)}`), a.addCSSRule(this._styles, `${r}[gs-h="${n + 1}"]`, `height: ${o(n + 1)}`);
|
|
2947
|
+
this._styles._max = t;
|
|
2948
|
+
}
|
|
2949
|
+
return this;
|
|
2950
|
+
}
|
|
2951
|
+
/** @internal */
|
|
2952
|
+
_updateContainerHeight() {
|
|
2953
|
+
if (!this.engine || this.engine.batchMode)
|
|
2954
|
+
return this;
|
|
2955
|
+
const e = this.parentGridNode;
|
|
2956
|
+
let t = this.getRow() + this._extraDragRow;
|
|
2957
|
+
const i = this.opts.cellHeight, s = this.opts.cellHeightUnit;
|
|
2958
|
+
if (!i)
|
|
2959
|
+
return this;
|
|
2960
|
+
if (!e) {
|
|
2961
|
+
const r = a.parseHeight(getComputedStyle(this.el).minHeight);
|
|
2962
|
+
if (r.h > 0 && r.unit === s) {
|
|
2963
|
+
const o = Math.floor(r.h / i);
|
|
2964
|
+
t < o && (t = o);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
return this.el.setAttribute("gs-current-row", String(t)), this.el.style.removeProperty("min-height"), this.el.style.removeProperty("height"), t && (this.el.style[e ? "minHeight" : "height"] = t * i + s), e && !e.grid.engine.batchMode && a.shouldSizeToContent(e) && e.grid.resizeToContentCBCheck(e.el), this;
|
|
2968
|
+
}
|
|
2969
|
+
/** @internal */
|
|
2970
|
+
_prepareElement(e, t = !1, i) {
|
|
2971
|
+
i = i || this._readAttr(e), e.gridstackNode = i, i.el = e, i.grid = this, i = this.engine.addNode(i, t), this._writeAttr(e, i), e.classList.add(A.itemClass, this.opts.itemClass);
|
|
2972
|
+
const s = a.shouldSizeToContent(i);
|
|
2973
|
+
return s ? e.classList.add("size-to-content") : e.classList.remove("size-to-content"), s && this.resizeToContentCheck(!1, i), this._prepareDragDropByNode(i), this;
|
|
2974
|
+
}
|
|
2975
|
+
/** @internal call to write position x,y,w,h attributes back to element */
|
|
2976
|
+
_writePosAttr(e, t) {
|
|
2977
|
+
return t.x !== void 0 && t.x !== null && e.setAttribute("gs-x", String(t.x)), t.y !== void 0 && t.y !== null && e.setAttribute("gs-y", String(t.y)), t.w > 1 ? e.setAttribute("gs-w", String(t.w)) : e.removeAttribute("gs-w"), t.h > 1 ? e.setAttribute("gs-h", String(t.h)) : e.removeAttribute("gs-h"), this;
|
|
2978
|
+
}
|
|
2979
|
+
/** @internal call to write any default attributes back to element */
|
|
2980
|
+
_writeAttr(e, t) {
|
|
2981
|
+
if (!t)
|
|
2982
|
+
return this;
|
|
2983
|
+
this._writePosAttr(e, t);
|
|
2984
|
+
const i = {
|
|
2985
|
+
// autoPosition: 'gs-auto-position', // no need to write out as already in node and doesn't affect CSS
|
|
2986
|
+
noResize: "gs-no-resize",
|
|
2987
|
+
noMove: "gs-no-move",
|
|
2988
|
+
locked: "gs-locked",
|
|
2989
|
+
id: "gs-id",
|
|
2990
|
+
sizeToContent: "gs-size-to-content"
|
|
2991
|
+
};
|
|
2992
|
+
for (const s in i)
|
|
2993
|
+
t[s] ? e.setAttribute(i[s], String(t[s])) : e.removeAttribute(i[s]);
|
|
2994
|
+
return this;
|
|
2995
|
+
}
|
|
2996
|
+
/** @internal call to read any default attributes from element */
|
|
2997
|
+
_readAttr(e, t = !0) {
|
|
2998
|
+
const i = {};
|
|
2999
|
+
i.x = a.toNumber(e.getAttribute("gs-x")), i.y = a.toNumber(e.getAttribute("gs-y")), i.w = a.toNumber(e.getAttribute("gs-w")), i.h = a.toNumber(e.getAttribute("gs-h")), i.autoPosition = a.toBool(e.getAttribute("gs-auto-position")), i.noResize = a.toBool(e.getAttribute("gs-no-resize")), i.noMove = a.toBool(e.getAttribute("gs-no-move")), i.locked = a.toBool(e.getAttribute("gs-locked")), i.sizeToContent = a.toBool(e.getAttribute("gs-size-to-content")), i.id = e.getAttribute("gs-id"), i.maxW = a.toNumber(e.getAttribute("gs-max-w")), i.minW = a.toNumber(e.getAttribute("gs-min-w")), i.maxH = a.toNumber(e.getAttribute("gs-max-h")), i.minH = a.toNumber(e.getAttribute("gs-min-h")), t && (i.w === 1 && e.removeAttribute("gs-w"), i.h === 1 && e.removeAttribute("gs-h"), i.maxW && e.removeAttribute("gs-max-w"), i.minW && e.removeAttribute("gs-min-w"), i.maxH && e.removeAttribute("gs-max-h"), i.minH && e.removeAttribute("gs-min-h"));
|
|
3000
|
+
for (const s in i) {
|
|
3001
|
+
if (!i.hasOwnProperty(s))
|
|
3002
|
+
return;
|
|
3003
|
+
!i[s] && i[s] !== 0 && delete i[s];
|
|
3004
|
+
}
|
|
3005
|
+
return i;
|
|
3006
|
+
}
|
|
3007
|
+
/** @internal */
|
|
3008
|
+
_setStaticClass() {
|
|
3009
|
+
const e = ["grid-stack-static"];
|
|
3010
|
+
return this.opts.staticGrid ? (this.el.classList.add(...e), this.el.setAttribute("gs-static", "true")) : (this.el.classList.remove(...e), this.el.removeAttribute("gs-static")), this;
|
|
3011
|
+
}
|
|
3012
|
+
/**
|
|
3013
|
+
* called when we are being resized - check if the one Column Mode needs to be turned on/off
|
|
3014
|
+
* and remember the prev columns we used, or get our count from parent, as well as check for cellHeight==='auto' (square)
|
|
3015
|
+
* or `sizeToContent` gridItem options.
|
|
3016
|
+
*/
|
|
3017
|
+
onResize(e = ((t) => (t = this.el) == null ? void 0 : t.clientWidth)()) {
|
|
3018
|
+
if (!e || this.prevWidth === e)
|
|
3019
|
+
return;
|
|
3020
|
+
this.prevWidth = e, this.batchUpdate();
|
|
3021
|
+
let i = !1;
|
|
3022
|
+
return this._autoColumn && this.parentGridNode ? this.opts.column !== this.parentGridNode.w && (this.column(this.parentGridNode.w, this.opts.layout || "list"), i = !0) : i = this.checkDynamicColumn(), this._isAutoCellHeight && this.cellHeight(), this.engine.nodes.forEach((s) => {
|
|
3023
|
+
s.subGrid && s.subGrid.onResize();
|
|
3024
|
+
}), this._skipInitialResize || this.resizeToContentCheck(i), delete this._skipInitialResize, this.batchUpdate(!1), this;
|
|
3025
|
+
}
|
|
3026
|
+
/** resizes content for given node (or all) if shouldSizeToContent() is true */
|
|
3027
|
+
resizeToContentCheck(e = !1, t = void 0) {
|
|
3028
|
+
if (this.engine) {
|
|
3029
|
+
if (e && this.hasAnimationCSS())
|
|
3030
|
+
return setTimeout(() => this.resizeToContentCheck(!1, t), this.animationDelay);
|
|
3031
|
+
if (t)
|
|
3032
|
+
a.shouldSizeToContent(t) && this.resizeToContentCBCheck(t.el);
|
|
3033
|
+
else if (this.engine.nodes.some((i) => a.shouldSizeToContent(i))) {
|
|
3034
|
+
const i = [...this.engine.nodes];
|
|
3035
|
+
this.batchUpdate(), i.forEach((s) => {
|
|
3036
|
+
a.shouldSizeToContent(s) && this.resizeToContentCBCheck(s.el);
|
|
3037
|
+
}), this.batchUpdate(!1);
|
|
3038
|
+
}
|
|
3039
|
+
this._gsEventHandler.resizecontent && this._gsEventHandler.resizecontent(null, t ? [t] : this.engine.nodes);
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
/** add or remove the grid element size event handler */
|
|
3043
|
+
_updateResizeEvent(e = !1) {
|
|
3044
|
+
const t = !this.parentGridNode && (this._isAutoCellHeight || this.opts.sizeToContent || this.opts.columnOpts || this.engine.nodes.find((i) => i.sizeToContent));
|
|
3045
|
+
return !e && t && !this.resizeObserver ? (this._sizeThrottle = a.throttle(() => this.onResize(), this.opts.cellHeightThrottle), this.resizeObserver = new ResizeObserver(() => this._sizeThrottle()), this.resizeObserver.observe(this.el), this._skipInitialResize = !0) : (e || !t) && this.resizeObserver && (this.resizeObserver.disconnect(), delete this.resizeObserver, delete this._sizeThrottle), this;
|
|
3046
|
+
}
|
|
3047
|
+
/** @internal convert a potential selector into actual element */
|
|
3048
|
+
static getElement(e = ".grid-stack-item") {
|
|
3049
|
+
return a.getElement(e);
|
|
3050
|
+
}
|
|
3051
|
+
/** @internal */
|
|
3052
|
+
static getElements(e = ".grid-stack-item") {
|
|
3053
|
+
return a.getElements(e);
|
|
3054
|
+
}
|
|
3055
|
+
/** @internal */
|
|
3056
|
+
static getGridElement(e) {
|
|
3057
|
+
return g.getElement(e);
|
|
3058
|
+
}
|
|
3059
|
+
/** @internal */
|
|
3060
|
+
static getGridElements(e) {
|
|
3061
|
+
return a.getElements(e);
|
|
3062
|
+
}
|
|
3063
|
+
/** @internal initialize margin top/bottom/left/right and units */
|
|
3064
|
+
_initMargin() {
|
|
3065
|
+
let e, t = 0, i = [];
|
|
3066
|
+
return typeof this.opts.margin == "string" && (i = this.opts.margin.split(" ")), i.length === 2 ? (this.opts.marginTop = this.opts.marginBottom = i[0], this.opts.marginLeft = this.opts.marginRight = i[1]) : i.length === 4 ? (this.opts.marginTop = i[0], this.opts.marginRight = i[1], this.opts.marginBottom = i[2], this.opts.marginLeft = i[3]) : (e = a.parseHeight(this.opts.margin), this.opts.marginUnit = e.unit, t = this.opts.margin = e.h), this.opts.marginTop === void 0 ? this.opts.marginTop = t : (e = a.parseHeight(this.opts.marginTop), this.opts.marginTop = e.h, delete this.opts.margin), this.opts.marginBottom === void 0 ? this.opts.marginBottom = t : (e = a.parseHeight(this.opts.marginBottom), this.opts.marginBottom = e.h, delete this.opts.margin), this.opts.marginRight === void 0 ? this.opts.marginRight = t : (e = a.parseHeight(this.opts.marginRight), this.opts.marginRight = e.h, delete this.opts.margin), this.opts.marginLeft === void 0 ? this.opts.marginLeft = t : (e = a.parseHeight(this.opts.marginLeft), this.opts.marginLeft = e.h, delete this.opts.margin), this.opts.marginUnit = e.unit, this.opts.marginTop === this.opts.marginBottom && this.opts.marginLeft === this.opts.marginRight && this.opts.marginTop === this.opts.marginRight && (this.opts.margin = this.opts.marginTop), this;
|
|
3067
|
+
}
|
|
3068
|
+
/* ===========================================================================================
|
|
3069
|
+
* drag&drop methods that used to be stubbed out and implemented in dd-gridstack.ts
|
|
3070
|
+
* but caused loading issues in prod - see https://github.com/gridstack/gridstack.js/issues/2039
|
|
3071
|
+
* ===========================================================================================
|
|
3072
|
+
*/
|
|
3073
|
+
/** get the global (but static to this code) DD implementation */
|
|
3074
|
+
static getDD() {
|
|
3075
|
+
return k;
|
|
3076
|
+
}
|
|
3077
|
+
/**
|
|
3078
|
+
* call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
|
|
3079
|
+
* Called during GridStack.init() as options, but can also be called directly (last param are used) in case the toolbar
|
|
3080
|
+
* is dynamically create and needs to be set later.
|
|
3081
|
+
* @param dragIn string selector (ex: '.sidebar-item') or list of dom elements
|
|
3082
|
+
* @param dragInOptions options - see DDDragOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'}
|
|
3083
|
+
* @param widgets GridStackWidget def to assign to each element which defines what to create on drop
|
|
3084
|
+
* @param root optional root which defaults to document (for shadow dom pass the parent HTMLDocument)
|
|
3085
|
+
*/
|
|
3086
|
+
static setupDragIn(e, t, i, s = document) {
|
|
3087
|
+
(t == null ? void 0 : t.pause) !== void 0 && (m.pauseDrag = t.pause), t = { appendTo: "body", helper: "clone", ...t || {} }, (typeof e == "string" ? a.getElements(e, s) : e).forEach((o, n) => {
|
|
3088
|
+
k.isDraggable(o) || k.dragIn(o, t), i != null && i[n] && (o.gridstackNode = i[n]);
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
/**
|
|
3092
|
+
* Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids.
|
|
3093
|
+
* IF you are looking to prevent an item from moving (due to being pushed around by another during collision) use locked property instead.
|
|
3094
|
+
* @param els widget or selector to modify.
|
|
3095
|
+
* @param val if true widget will be draggable, assuming the parent grid isn't noMove or static.
|
|
3096
|
+
*/
|
|
3097
|
+
movable(e, t) {
|
|
3098
|
+
return this.opts.staticGrid ? this : (g.getElements(e).forEach((i) => {
|
|
3099
|
+
const s = i.gridstackNode;
|
|
3100
|
+
s && (t ? delete s.noMove : s.noMove = !0, this._prepareDragDropByNode(s));
|
|
3101
|
+
}), this);
|
|
3102
|
+
}
|
|
3103
|
+
/**
|
|
3104
|
+
* Enables/Disables user resizing of specific grid element. If you want all items, and have it affect future items, use enableResize() instead. No-op for static grids.
|
|
3105
|
+
* @param els widget or selector to modify
|
|
3106
|
+
* @param val if true widget will be resizable, assuming the parent grid isn't noResize or static.
|
|
3107
|
+
*/
|
|
3108
|
+
resizable(e, t) {
|
|
3109
|
+
return this.opts.staticGrid ? this : (g.getElements(e).forEach((i) => {
|
|
3110
|
+
const s = i.gridstackNode;
|
|
3111
|
+
s && (t ? delete s.noResize : s.noResize = !0, this._prepareDragDropByNode(s));
|
|
3112
|
+
}), this);
|
|
3113
|
+
}
|
|
3114
|
+
/**
|
|
3115
|
+
* Temporarily disables widgets moving/resizing.
|
|
3116
|
+
* If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.
|
|
3117
|
+
* Note: no-op for static grid
|
|
3118
|
+
* This is a shortcut for:
|
|
3119
|
+
* @example
|
|
3120
|
+
* grid.enableMove(false);
|
|
3121
|
+
* grid.enableResize(false);
|
|
3122
|
+
* @param recurse true (default) if sub-grids also get updated
|
|
3123
|
+
*/
|
|
3124
|
+
disable(e = !0) {
|
|
3125
|
+
if (!this.opts.staticGrid)
|
|
3126
|
+
return this.enableMove(!1, e), this.enableResize(!1, e), this._triggerEvent("disable"), this;
|
|
3127
|
+
}
|
|
3128
|
+
/**
|
|
3129
|
+
* Re-enables widgets moving/resizing - see disable().
|
|
3130
|
+
* Note: no-op for static grid.
|
|
3131
|
+
* This is a shortcut for:
|
|
3132
|
+
* @example
|
|
3133
|
+
* grid.enableMove(true);
|
|
3134
|
+
* grid.enableResize(true);
|
|
3135
|
+
* @param recurse true (default) if sub-grids also get updated
|
|
3136
|
+
*/
|
|
3137
|
+
enable(e = !0) {
|
|
3138
|
+
if (!this.opts.staticGrid)
|
|
3139
|
+
return this.enableMove(!0, e), this.enableResize(!0, e), this._triggerEvent("enable"), this;
|
|
3140
|
+
}
|
|
3141
|
+
/**
|
|
3142
|
+
* Enables/disables widget moving. No-op for static grids, and locally defined items still overrule
|
|
3143
|
+
* @param recurse true (default) if sub-grids also get updated
|
|
3144
|
+
*/
|
|
3145
|
+
enableMove(e, t = !0) {
|
|
3146
|
+
return this.opts.staticGrid ? this : (e ? delete this.opts.disableDrag : this.opts.disableDrag = !0, this.engine.nodes.forEach((i) => {
|
|
3147
|
+
this._prepareDragDropByNode(i), i.subGrid && t && i.subGrid.enableMove(e, t);
|
|
3148
|
+
}), this);
|
|
3149
|
+
}
|
|
3150
|
+
/**
|
|
3151
|
+
* Enables/disables widget resizing. No-op for static grids.
|
|
3152
|
+
* @param recurse true (default) if sub-grids also get updated
|
|
3153
|
+
*/
|
|
3154
|
+
enableResize(e, t = !0) {
|
|
3155
|
+
return this.opts.staticGrid ? this : (e ? delete this.opts.disableResize : this.opts.disableResize = !0, this.engine.nodes.forEach((i) => {
|
|
3156
|
+
this._prepareDragDropByNode(i), i.subGrid && t && i.subGrid.enableResize(e, t);
|
|
3157
|
+
}), this);
|
|
3158
|
+
}
|
|
3159
|
+
/** @internal call when drag (and drop) needs to be cancelled (Esc key) */
|
|
3160
|
+
cancelDrag() {
|
|
3161
|
+
var t;
|
|
3162
|
+
const e = (t = this._placeholder) == null ? void 0 : t.gridstackNode;
|
|
3163
|
+
e && (e._isExternal ? (e._isAboutToRemove = !0, this.engine.removeNode(e)) : e._isAboutToRemove && g._itemRemoving(e.el, !1), this.engine.restoreInitial());
|
|
3164
|
+
}
|
|
3165
|
+
/** @internal removes any drag&drop present (called during destroy) */
|
|
3166
|
+
_removeDD(e) {
|
|
3167
|
+
return k.draggable(e, "destroy").resizable(e, "destroy"), e.gridstackNode && delete e.gridstackNode._initDD, delete e.ddElement, this;
|
|
3168
|
+
}
|
|
3169
|
+
/** @internal called to add drag over to support widgets being added externally */
|
|
3170
|
+
_setupAcceptWidget() {
|
|
3171
|
+
if (this.opts.staticGrid || !this.opts.acceptWidgets && !this.opts.removable)
|
|
3172
|
+
return k.droppable(this.el, "destroy"), this;
|
|
3173
|
+
let e, t;
|
|
3174
|
+
const i = (s, r, o) => {
|
|
3175
|
+
var f;
|
|
3176
|
+
o = o || r;
|
|
3177
|
+
const n = o.gridstackNode;
|
|
3178
|
+
if (!n)
|
|
3179
|
+
return;
|
|
3180
|
+
if (!((f = n.grid) != null && f.el)) {
|
|
3181
|
+
o.style.transform = `scale(${1 / this.dragTransform.xScale},${1 / this.dragTransform.yScale})`;
|
|
3182
|
+
const _ = o.getBoundingClientRect();
|
|
3183
|
+
o.style.left = _.x + (this.dragTransform.xScale - 1) * (s.clientX - _.x) / this.dragTransform.xScale + "px", o.style.top = _.y + (this.dragTransform.yScale - 1) * (s.clientY - _.y) / this.dragTransform.yScale + "px", o.style.transformOrigin = "0px 0px";
|
|
3184
|
+
}
|
|
3185
|
+
let { top: l, left: h } = o.getBoundingClientRect();
|
|
3186
|
+
const d = this.el.getBoundingClientRect();
|
|
3187
|
+
h -= d.left, l -= d.top;
|
|
3188
|
+
const u = {
|
|
3189
|
+
position: {
|
|
3190
|
+
top: l * this.dragTransform.xScale,
|
|
3191
|
+
left: h * this.dragTransform.yScale
|
|
3192
|
+
}
|
|
3193
|
+
};
|
|
3194
|
+
if (n._temporaryRemoved) {
|
|
3195
|
+
if (n.x = Math.max(0, Math.round(h / t)), n.y = Math.max(0, Math.round(l / e)), delete n.autoPosition, this.engine.nodeBoundFix(n), !this.engine.willItFit(n)) {
|
|
3196
|
+
if (n.autoPosition = !0, !this.engine.willItFit(n)) {
|
|
3197
|
+
k.off(r, "drag");
|
|
3198
|
+
return;
|
|
3199
|
+
}
|
|
3200
|
+
n._willFitPos && (a.copyPos(n, n._willFitPos), delete n._willFitPos);
|
|
3201
|
+
}
|
|
3202
|
+
this._onStartMoving(o, s, u, n, t, e);
|
|
3203
|
+
} else
|
|
3204
|
+
this._dragOrResize(o, s, u, n, t, e);
|
|
3205
|
+
};
|
|
3206
|
+
return k.droppable(this.el, {
|
|
3207
|
+
accept: (s) => {
|
|
3208
|
+
const r = s.gridstackNode || this._readAttr(s, !1);
|
|
3209
|
+
if ((r == null ? void 0 : r.grid) === this)
|
|
3210
|
+
return !0;
|
|
3211
|
+
if (!this.opts.acceptWidgets)
|
|
3212
|
+
return !1;
|
|
3213
|
+
let o = !0;
|
|
3214
|
+
if (typeof this.opts.acceptWidgets == "function")
|
|
3215
|
+
o = this.opts.acceptWidgets(s);
|
|
3216
|
+
else {
|
|
3217
|
+
const n = this.opts.acceptWidgets === !0 ? ".grid-stack-item" : this.opts.acceptWidgets;
|
|
3218
|
+
o = s.matches(n);
|
|
3219
|
+
}
|
|
3220
|
+
if (o && r && this.opts.maxRow) {
|
|
3221
|
+
const n = { w: r.w, h: r.h, minW: r.minW, minH: r.minH };
|
|
3222
|
+
o = this.engine.willItFit(n);
|
|
3223
|
+
}
|
|
3224
|
+
return o;
|
|
3225
|
+
}
|
|
3226
|
+
}).on(this.el, "dropover", (s, r, o) => {
|
|
3227
|
+
let n = (o == null ? void 0 : o.gridstackNode) || r.gridstackNode;
|
|
3228
|
+
if ((n == null ? void 0 : n.grid) === this && !n._temporaryRemoved)
|
|
3229
|
+
return !1;
|
|
3230
|
+
if (n != null && n.grid && n.grid !== this && !n._temporaryRemoved && n.grid._leave(r, o), o = o || r, t = this.cellWidth(), e = this.getCellHeight(!0), !n) {
|
|
3231
|
+
const d = o.getAttribute("data-gs-widget") || o.getAttribute("gridstacknode");
|
|
3232
|
+
if (d) {
|
|
3233
|
+
try {
|
|
3234
|
+
n = JSON.parse(d);
|
|
3235
|
+
} catch {
|
|
3236
|
+
console.error("Gridstack dropover: Bad JSON format: ", d);
|
|
3237
|
+
}
|
|
3238
|
+
o.removeAttribute("data-gs-widget"), o.removeAttribute("gridstacknode");
|
|
3239
|
+
}
|
|
3240
|
+
n || (n = this._readAttr(o));
|
|
3241
|
+
}
|
|
3242
|
+
n.grid || (n.el || (n = { ...n }), n._isExternal = !0, o.gridstackNode = n);
|
|
3243
|
+
const l = n.w || Math.round(o.offsetWidth / t) || 1, h = n.h || Math.round(o.offsetHeight / e) || 1;
|
|
3244
|
+
return n.grid && n.grid !== this ? (r._gridstackNodeOrig || (r._gridstackNodeOrig = n), r.gridstackNode = n = { ...n, w: l, h, grid: this }, delete n.x, delete n.y, this.engine.cleanupNode(n).nodeBoundFix(n), n._initDD = n._isExternal = // DOM needs to be re-parented on a drop
|
|
3245
|
+
n._temporaryRemoved = !0) : (n.w = l, n.h = h, n._temporaryRemoved = !0), g._itemRemoving(n.el, !1), k.on(r, "drag", i), i(s, r, o), !1;
|
|
3246
|
+
}).on(this.el, "dropout", (s, r, o) => {
|
|
3247
|
+
const n = (o == null ? void 0 : o.gridstackNode) || r.gridstackNode;
|
|
3248
|
+
return n && (!n.grid || n.grid === this) && (this._leave(r, o), this._isTemp && this.removeAsSubGrid(n)), !1;
|
|
3249
|
+
}).on(this.el, "drop", (s, r, o) => {
|
|
3250
|
+
var _, v, b;
|
|
3251
|
+
const n = (o == null ? void 0 : o.gridstackNode) || r.gridstackNode;
|
|
3252
|
+
if ((n == null ? void 0 : n.grid) === this && !n._isExternal)
|
|
3253
|
+
return !1;
|
|
3254
|
+
const l = !!this.placeholder.parentElement, h = r !== o;
|
|
3255
|
+
this.placeholder.remove(), delete this.placeholder.gridstackNode;
|
|
3256
|
+
const d = l && this.opts.animate;
|
|
3257
|
+
d && this.setAnimation(!1);
|
|
3258
|
+
const u = r._gridstackNodeOrig;
|
|
3259
|
+
if (delete r._gridstackNodeOrig, l && (u != null && u.grid) && u.grid !== this) {
|
|
3260
|
+
const p = u.grid;
|
|
3261
|
+
p.engine.removeNodeFromLayoutCache(u), p.engine.removedNodes.push(u), p._triggerRemoveEvent()._triggerChangeEvent(), p.parentGridNode && !p.engine.nodes.length && p.opts.subGridDynamic && p.removeAsSubGrid();
|
|
3262
|
+
}
|
|
3263
|
+
if (!n || (l && (this.engine.cleanupNode(n), n.grid = this), (_ = n.grid) == null || delete _._isTemp, k.off(r, "drag"), o !== r ? (o.remove(), r = o) : r.remove(), this._removeDD(r), !l))
|
|
3264
|
+
return !1;
|
|
3265
|
+
const f = (b = (v = n.subGrid) == null ? void 0 : v.el) == null ? void 0 : b.gridstack;
|
|
3266
|
+
return a.copyPos(n, this._readAttr(this.placeholder)), a.removePositioningStyles(r), h && (n.content || n.subGridOpts || g.addRemoveCB) ? (delete n.el, r = this.addWidget(n)) : (this._prepareElement(r, !0, n), this.el.appendChild(r), this.resizeToContentCheck(!1, n), f && (f.parentGridNode = n, f.opts.styleInHead || f._updateStyles(!0)), this._updateContainerHeight()), this.engine.addedNodes.push(n), this._triggerAddEvent(), this._triggerChangeEvent(), this.engine.endUpdate(), this._gsEventHandler.dropped && this._gsEventHandler.dropped({ ...s, type: "dropped" }, u && u.grid ? u : void 0, n), d && this.setAnimation(this.opts.animate, !0), !1;
|
|
3267
|
+
}), this;
|
|
3268
|
+
}
|
|
3269
|
+
/** @internal mark item for removal */
|
|
3270
|
+
static _itemRemoving(e, t) {
|
|
3271
|
+
if (!e)
|
|
3272
|
+
return;
|
|
3273
|
+
const i = e ? e.gridstackNode : void 0;
|
|
3274
|
+
!(i != null && i.grid) || e.classList.contains(i.grid.opts.removableOptions.decline) || (t ? i._isAboutToRemove = !0 : delete i._isAboutToRemove, t ? e.classList.add("grid-stack-item-removing") : e.classList.remove("grid-stack-item-removing"));
|
|
3275
|
+
}
|
|
3276
|
+
/** @internal called to setup a trash drop zone if the user specifies it */
|
|
3277
|
+
_setupRemoveDrop() {
|
|
3278
|
+
if (typeof this.opts.removable != "string")
|
|
3279
|
+
return this;
|
|
3280
|
+
const e = document.querySelector(this.opts.removable);
|
|
3281
|
+
return e ? (!this.opts.staticGrid && !k.isDroppable(e) && k.droppable(e, this.opts.removableOptions).on(e, "dropover", (t, i) => g._itemRemoving(i, !0)).on(e, "dropout", (t, i) => g._itemRemoving(i, !1)), this) : this;
|
|
3282
|
+
}
|
|
3283
|
+
/** @internal prepares the element for drag&drop */
|
|
3284
|
+
_prepareDragDropByNode(e) {
|
|
3285
|
+
const t = e.el, i = e.noMove || this.opts.disableDrag, s = e.noResize || this.opts.disableResize;
|
|
3286
|
+
if (this.opts.staticGrid || i && s)
|
|
3287
|
+
return e._initDD && (this._removeDD(t), delete e._initDD), t.classList.add("ui-draggable-disabled", "ui-resizable-disabled"), this;
|
|
3288
|
+
if (!e._initDD) {
|
|
3289
|
+
let r, o;
|
|
3290
|
+
const n = (d, u) => {
|
|
3291
|
+
this._gsEventHandler[d.type] && this._gsEventHandler[d.type](d, d.target), r = this.cellWidth(), o = this.getCellHeight(!0), this._onStartMoving(t, d, u, e, r, o);
|
|
3292
|
+
}, l = (d, u) => {
|
|
3293
|
+
this._dragOrResize(t, d, u, e, r, o);
|
|
3294
|
+
}, h = (d) => {
|
|
3295
|
+
this.placeholder.remove(), delete this.placeholder.gridstackNode, delete e._moving, delete e._event, delete e._lastTried;
|
|
3296
|
+
const u = e.w !== e._orig.w, f = d.target;
|
|
3297
|
+
if (!(!f.gridstackNode || f.gridstackNode.grid !== this)) {
|
|
3298
|
+
if (e.el = f, e._isAboutToRemove) {
|
|
3299
|
+
const _ = t.gridstackNode.grid;
|
|
3300
|
+
_._gsEventHandler[d.type] && _._gsEventHandler[d.type](d, f), _.engine.nodes.push(e), _.removeWidget(t, !0, !0);
|
|
3301
|
+
} else
|
|
3302
|
+
a.removePositioningStyles(f), e._temporaryRemoved ? (a.copyPos(e, e._orig), this._writePosAttr(f, e), this.engine.addNode(e)) : this._writePosAttr(f, e), this._gsEventHandler[d.type] && this._gsEventHandler[d.type](d, f);
|
|
3303
|
+
this._extraDragRow = 0, this._updateContainerHeight(), this._triggerChangeEvent(), this.engine.endUpdate(), d.type === "resizestop" && (Number.isInteger(e.sizeToContent) && (e.sizeToContent = e.h), this.resizeToContentCheck(u, e));
|
|
3304
|
+
}
|
|
3305
|
+
};
|
|
3306
|
+
k.draggable(t, {
|
|
3307
|
+
start: n,
|
|
3308
|
+
stop: h,
|
|
3309
|
+
drag: l
|
|
3310
|
+
}).resizable(t, {
|
|
3311
|
+
start: n,
|
|
3312
|
+
stop: h,
|
|
3313
|
+
resize: l
|
|
3314
|
+
}), e._initDD = !0;
|
|
3315
|
+
}
|
|
3316
|
+
return k.draggable(t, i ? "disable" : "enable").resizable(t, s ? "disable" : "enable"), this;
|
|
3317
|
+
}
|
|
3318
|
+
/** @internal handles actual drag/resize start */
|
|
3319
|
+
_onStartMoving(e, t, i, s, r, o) {
|
|
3320
|
+
var n;
|
|
3321
|
+
if (this.engine.cleanNodes().beginUpdate(s), this._writePosAttr(this.placeholder, s), this.el.appendChild(this.placeholder), this.placeholder.gridstackNode = s, (n = s.grid) != null && n.el)
|
|
3322
|
+
this.dragTransform = a.getValuesFromTransformedElement(e);
|
|
3323
|
+
else if (this.placeholder && this.placeholder.closest(".grid-stack")) {
|
|
3324
|
+
const l = this.placeholder.closest(".grid-stack");
|
|
3325
|
+
this.dragTransform = a.getValuesFromTransformedElement(l);
|
|
3326
|
+
} else
|
|
3327
|
+
this.dragTransform = {
|
|
3328
|
+
xScale: 1,
|
|
3329
|
+
xOffset: 0,
|
|
3330
|
+
yScale: 1,
|
|
3331
|
+
yOffset: 0
|
|
3332
|
+
};
|
|
3333
|
+
if (s.el = this.placeholder, s._lastUiPosition = i.position, s._prevYPix = i.position.top, s._moving = t.type === "dragstart", delete s._lastTried, t.type === "dropover" && s._temporaryRemoved && (this.engine.addNode(s), s._moving = !0), this.engine.cacheRects(r, o, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft), t.type === "resizestart") {
|
|
3334
|
+
const l = this.getColumn() - s.x, h = (this.opts.maxRow || Number.MAX_SAFE_INTEGER) - s.y;
|
|
3335
|
+
k.resizable(e, "option", "minWidth", r * Math.min(s.minW || 1, l)).resizable(e, "option", "minHeight", o * Math.min(s.minH || 1, h)).resizable(e, "option", "maxWidth", r * Math.min(s.maxW || Number.MAX_SAFE_INTEGER, l)).resizable(e, "option", "maxWidthMoveLeft", r * Math.min(s.maxW || Number.MAX_SAFE_INTEGER, s.x + s.w)).resizable(e, "option", "maxHeight", o * Math.min(s.maxH || Number.MAX_SAFE_INTEGER, h)).resizable(e, "option", "maxHeightMoveUp", o * Math.min(s.maxH || Number.MAX_SAFE_INTEGER, s.y + s.h));
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
/** @internal handles actual drag/resize */
|
|
3339
|
+
_dragOrResize(e, t, i, s, r, o) {
|
|
3340
|
+
const n = { ...s._orig };
|
|
3341
|
+
let l, h = this.opts.marginLeft, d = this.opts.marginRight, u = this.opts.marginTop, f = this.opts.marginBottom;
|
|
3342
|
+
const _ = Math.round(o * 0.1), v = Math.round(r * 0.1);
|
|
3343
|
+
if (h = Math.min(h, v), d = Math.min(d, v), u = Math.min(u, _), f = Math.min(f, _), t.type === "drag") {
|
|
3344
|
+
if (s._temporaryRemoved)
|
|
3345
|
+
return;
|
|
3346
|
+
const p = i.position.top - s._prevYPix;
|
|
3347
|
+
s._prevYPix = i.position.top, this.opts.draggable.scroll !== !1 && a.updateScrollPosition(e, i.position, p);
|
|
3348
|
+
const w = i.position.left + (i.position.left > s._lastUiPosition.left ? -d : h), C = i.position.top + (i.position.top > s._lastUiPosition.top ? -f : u);
|
|
3349
|
+
n.x = Math.round(w / r), n.y = Math.round(C / o);
|
|
3350
|
+
const D = this._extraDragRow;
|
|
3351
|
+
if (this.engine.collide(s, n)) {
|
|
3352
|
+
const z = this.getRow();
|
|
3353
|
+
let R = Math.max(0, n.y + s.h - z);
|
|
3354
|
+
this.opts.maxRow && z + R > this.opts.maxRow && (R = Math.max(0, this.opts.maxRow - z)), this._extraDragRow = R;
|
|
3355
|
+
} else
|
|
3356
|
+
this._extraDragRow = 0;
|
|
3357
|
+
if (this._extraDragRow !== D && this._updateContainerHeight(), s.x === n.x && s.y === n.y)
|
|
3358
|
+
return;
|
|
3359
|
+
} else if (t.type === "resize") {
|
|
3360
|
+
if (n.x < 0 || (a.updateScrollResize(t, e, o), n.w = Math.round((i.size.width - h) / r), n.h = Math.round((i.size.height - u) / o), s.w === n.w && s.h === n.h) || s._lastTried && s._lastTried.w === n.w && s._lastTried.h === n.h)
|
|
3361
|
+
return;
|
|
3362
|
+
const p = i.position.left + h, w = i.position.top + u;
|
|
3363
|
+
n.x = Math.round(p / r), n.y = Math.round(w / o), l = !0;
|
|
3364
|
+
}
|
|
3365
|
+
s._event = t, s._lastTried = n;
|
|
3366
|
+
const b = {
|
|
3367
|
+
x: i.position.left + h,
|
|
3368
|
+
y: i.position.top + u,
|
|
3369
|
+
w: (i.size ? i.size.width : s.w * r) - h - d,
|
|
3370
|
+
h: (i.size ? i.size.height : s.h * o) - u - f
|
|
3371
|
+
};
|
|
3372
|
+
if (this.engine.moveNodeCheck(s, { ...n, cellWidth: r, cellHeight: o, rect: b, resizing: l })) {
|
|
3373
|
+
s._lastUiPosition = i.position, this.engine.cacheRects(r, o, u, d, f, h), delete s._skipDown, l && s.subGrid && s.subGrid.onResize(), this._extraDragRow = 0, this._updateContainerHeight();
|
|
3374
|
+
const p = t.target;
|
|
3375
|
+
this._writePosAttr(p, s), this._gsEventHandler[t.type] && this._gsEventHandler[t.type](t, p);
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
/** @internal called when item leaving our area by either cursor dropout event
|
|
3379
|
+
* or shape is outside our boundaries. remove it from us, and mark temporary if this was
|
|
3380
|
+
* our item to start with else restore prev node values from prev grid it came from.
|
|
3381
|
+
*/
|
|
3382
|
+
_leave(e, t) {
|
|
3383
|
+
t = t || e;
|
|
3384
|
+
const i = t.gridstackNode;
|
|
3385
|
+
i && (t.style.transform = t.style.transformOrigin = null, k.off(e, "drag"), !i._temporaryRemoved && (i._temporaryRemoved = !0, this.engine.removeNode(i), i.el = i._isExternal && t ? t : e, i._isExternal && this.engine.cleanupNode(i), this.opts.removable === !0 && g._itemRemoving(e, !0), e._gridstackNodeOrig ? (e.gridstackNode = e._gridstackNodeOrig, delete e._gridstackNodeOrig) : i._isExternal && this.engine.restoreInitial()));
|
|
3386
|
+
}
|
|
3387
|
+
// legacy method removed
|
|
3388
|
+
commit() {
|
|
3389
|
+
return Ot(this, this.batchUpdate(!1), "commit", "batchUpdate", "5.2"), this;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
g.renderCB = (c, e) => {
|
|
3393
|
+
c && (e != null && e.content) && (c.textContent = e.content);
|
|
3394
|
+
};
|
|
3395
|
+
g.resizeToContentParent = ".grid-stack-item-content";
|
|
3396
|
+
g.Utils = a;
|
|
3397
|
+
g.Engine = P;
|
|
3398
|
+
g.GDRev = "11.3.0";
|
|
3399
|
+
const Bt = ["data-index", "gs-h", "gs-w", "gs-x", "gs-y"], qt = { class: "grid-stack-item-content" }, Ut = /* @__PURE__ */ M({
|
|
3400
|
+
__name: "DraggableGridLayout",
|
|
3401
|
+
props: {
|
|
3402
|
+
tiles: {},
|
|
3403
|
+
gridSize: {},
|
|
3404
|
+
tileHeight: { default: 200 }
|
|
3405
|
+
},
|
|
3406
|
+
emits: ["update-tiles"],
|
|
3407
|
+
setup(c, { emit: e }) {
|
|
3408
|
+
const t = c, i = e, s = U(null);
|
|
3409
|
+
let r = null;
|
|
3410
|
+
return De(() => {
|
|
3411
|
+
s.value && (r = g.init({
|
|
3412
|
+
column: t.gridSize.cols,
|
|
3413
|
+
cellHeight: t.tileHeight,
|
|
3414
|
+
resizable: { handles: "all" }
|
|
3415
|
+
}, s.value), r.on("change", (o, n) => {
|
|
3416
|
+
const l = t.tiles.map((h, d) => {
|
|
3417
|
+
const u = n.find((f) => {
|
|
3418
|
+
var _;
|
|
3419
|
+
return Number((_ = f.el) == null ? void 0 : _.getAttribute("data-index")) === d;
|
|
3420
|
+
});
|
|
3421
|
+
return u ? {
|
|
3422
|
+
...h,
|
|
3423
|
+
layout: {
|
|
3424
|
+
position: { col: u.x, row: u.y },
|
|
3425
|
+
size: { cols: u.w, rows: u.h }
|
|
3426
|
+
}
|
|
3427
|
+
} : h;
|
|
3428
|
+
});
|
|
3429
|
+
i("update-tiles", l);
|
|
3430
|
+
}));
|
|
3431
|
+
}), le(() => {
|
|
3432
|
+
r && r.destroy(!1);
|
|
3433
|
+
}), Ee(() => t.tiles, (o) => {
|
|
3434
|
+
r && s.value && o.forEach((n, l) => {
|
|
3435
|
+
var d;
|
|
3436
|
+
const h = (d = s.value) == null ? void 0 : d.querySelector(`[data-index="${l}"]`);
|
|
3437
|
+
h && (r == null || r.update(h, {
|
|
3438
|
+
x: n.layout.position.col,
|
|
3439
|
+
y: n.layout.position.row,
|
|
3440
|
+
w: n.layout.size.cols,
|
|
3441
|
+
h: n.layout.size.rows
|
|
3442
|
+
}));
|
|
3443
|
+
});
|
|
3444
|
+
}, { deep: !0 }), (o, n) => (E(), L("div", {
|
|
3445
|
+
ref_key: "gridContainer",
|
|
3446
|
+
ref: s,
|
|
3447
|
+
class: "grid-stack"
|
|
3448
|
+
}, [
|
|
3449
|
+
(E(!0), L(ze, null, Se(o.tiles, (l, h) => (E(), L("div", {
|
|
3450
|
+
key: "tile-" + h,
|
|
3451
|
+
class: "grid-stack-item",
|
|
3452
|
+
"data-index": h,
|
|
3453
|
+
"gs-h": l.layout.size.rows,
|
|
3454
|
+
"gs-w": l.layout.size.cols,
|
|
3455
|
+
"gs-x": l.layout.position.col,
|
|
3456
|
+
"gs-y": l.layout.position.row
|
|
3457
|
+
}, [
|
|
3458
|
+
K("div", qt, [
|
|
3459
|
+
ne(o.$slots, "tile", { tile: l })
|
|
3460
|
+
])
|
|
3461
|
+
], 8, Bt))), 128))
|
|
3462
|
+
], 512));
|
|
3463
|
+
}
|
|
3464
|
+
}), $t = { class: "kong-ui-public-dashboard-renderer" }, Ft = {
|
|
674
3465
|
key: 0,
|
|
675
3466
|
class: "tile-container"
|
|
676
|
-
},
|
|
3467
|
+
}, Gt = /* @__PURE__ */ M({
|
|
677
3468
|
__name: "DashboardRenderer",
|
|
678
3469
|
props: {
|
|
679
3470
|
context: {},
|
|
680
|
-
config: {}
|
|
3471
|
+
config: {},
|
|
3472
|
+
draggable: { type: Boolean, default: !1 }
|
|
681
3473
|
},
|
|
682
|
-
emits: ["edit-tile"],
|
|
683
|
-
setup(
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
const
|
|
3474
|
+
emits: ["edit-tile", "update-tiles"],
|
|
3475
|
+
setup(c, { expose: e, emit: t }) {
|
|
3476
|
+
const i = c, s = t, { i18n: r } = F.useI18n(), o = U(0), n = j(Q);
|
|
3477
|
+
n || (console.warn("Analytics dashboards require a query bridge supplied via provide / inject."), console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"), console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/README.md#requirements"));
|
|
3478
|
+
const l = tt(), h = S(() => i.context.timeSpec ? i.context.timeSpec : {
|
|
687
3479
|
type: "relative",
|
|
688
|
-
time_range:
|
|
689
|
-
}),
|
|
690
|
-
var
|
|
691
|
-
let
|
|
692
|
-
if ("description" in
|
|
693
|
-
const
|
|
694
|
-
const
|
|
695
|
-
return
|
|
3480
|
+
time_range: l.defaultQueryTimeForOrg
|
|
3481
|
+
}), d = S(() => !!i.context.timeSpec || !l.loading), u = S(() => i.config.tiles.map((p, w) => {
|
|
3482
|
+
var D;
|
|
3483
|
+
let C = p.definition;
|
|
3484
|
+
if ("description" in C.chart) {
|
|
3485
|
+
const z = (D = C.chart.description) == null ? void 0 : D.replace(ut, () => {
|
|
3486
|
+
const y = `renderer.trendRange.${h.value.type === "absolute" ? "custom" : h.value.time_range}`;
|
|
3487
|
+
return r.te(y) ? r.t(y) : "";
|
|
696
3488
|
});
|
|
697
|
-
|
|
698
|
-
...
|
|
3489
|
+
C = {
|
|
3490
|
+
...C,
|
|
699
3491
|
chart: {
|
|
700
|
-
...
|
|
701
|
-
description:
|
|
3492
|
+
...C.chart,
|
|
3493
|
+
description: z
|
|
702
3494
|
}
|
|
703
3495
|
};
|
|
704
3496
|
}
|
|
705
3497
|
return {
|
|
706
|
-
layout:
|
|
707
|
-
meta:
|
|
3498
|
+
layout: p.layout,
|
|
3499
|
+
meta: C,
|
|
708
3500
|
// Add a unique key to each tile internally.
|
|
709
|
-
id:
|
|
3501
|
+
id: w
|
|
710
3502
|
};
|
|
711
|
-
})),
|
|
712
|
-
let { tz:
|
|
713
|
-
return
|
|
714
|
-
...
|
|
715
|
-
tz:
|
|
716
|
-
timeSpec:
|
|
717
|
-
refreshInterval:
|
|
718
|
-
editable:
|
|
3503
|
+
})), f = S(() => {
|
|
3504
|
+
let { tz: p, refreshInterval: w, editable: C } = i.context;
|
|
3505
|
+
return p || (p = new Intl.DateTimeFormat().resolvedOptions().timeZone), w === void 0 && (w = ct), C === void 0 && (C = !1), {
|
|
3506
|
+
...i.context,
|
|
3507
|
+
tz: p,
|
|
3508
|
+
timeSpec: h.value,
|
|
3509
|
+
refreshInterval: w,
|
|
3510
|
+
editable: C
|
|
719
3511
|
};
|
|
720
|
-
}),
|
|
721
|
-
s("edit-tile",
|
|
3512
|
+
}), _ = (p) => {
|
|
3513
|
+
s("edit-tile", p);
|
|
3514
|
+
}, v = () => {
|
|
3515
|
+
o.value++;
|
|
3516
|
+
}, b = (p) => {
|
|
3517
|
+
const w = p.map((C) => ({
|
|
3518
|
+
layout: C.layout,
|
|
3519
|
+
definition: C.meta
|
|
3520
|
+
}));
|
|
3521
|
+
s("update-tiles", w);
|
|
722
3522
|
};
|
|
723
|
-
return
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return d(), R("div", ht, [
|
|
728
|
-
l(i) ? (d(), _(yt, {
|
|
3523
|
+
return e({ refresh: v }), (p, w) => {
|
|
3524
|
+
const C = W("KAlert");
|
|
3525
|
+
return E(), L("div", $t, [
|
|
3526
|
+
x(n) ? (E(), T(Re(p.draggable ? Ut : Lt), {
|
|
729
3527
|
key: 1,
|
|
730
|
-
"grid-size":
|
|
731
|
-
"tile-height":
|
|
732
|
-
tiles:
|
|
3528
|
+
"grid-size": p.config.gridSize,
|
|
3529
|
+
"tile-height": p.config.tileHeight,
|
|
3530
|
+
tiles: u.value,
|
|
3531
|
+
onUpdateTiles: b
|
|
733
3532
|
}, {
|
|
734
|
-
tile:
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
])) : (
|
|
3533
|
+
tile: H(({ tile: D }) => [
|
|
3534
|
+
D.meta.chart.type === "slottable" ? (E(), L("div", Ft, [
|
|
3535
|
+
ne(p.$slots, D.meta.chart.id, {}, void 0, !0)
|
|
3536
|
+
])) : (E(), T(Nt, {
|
|
738
3537
|
key: 1,
|
|
739
3538
|
class: "tile-container",
|
|
740
|
-
context:
|
|
741
|
-
definition:
|
|
742
|
-
height:
|
|
743
|
-
"query-ready":
|
|
744
|
-
"refresh-counter":
|
|
745
|
-
"tile-id":
|
|
746
|
-
onEditTile: (
|
|
3539
|
+
context: f.value,
|
|
3540
|
+
definition: D.meta,
|
|
3541
|
+
height: D.layout.size.rows * (p.config.tileHeight || x(he)) + parseInt(x(He), 10),
|
|
3542
|
+
"query-ready": d.value,
|
|
3543
|
+
"refresh-counter": o.value,
|
|
3544
|
+
"tile-id": D.id,
|
|
3545
|
+
onEditTile: (z) => _(D)
|
|
747
3546
|
}, null, 8, ["context", "definition", "height", "query-ready", "refresh-counter", "tile-id", "onEditTile"]))
|
|
748
3547
|
]),
|
|
749
3548
|
_: 3
|
|
750
|
-
},
|
|
3549
|
+
}, 40, ["grid-size", "tile-height", "tiles"])) : (E(), T(C, {
|
|
751
3550
|
key: 0,
|
|
752
3551
|
appearance: "danger"
|
|
753
3552
|
}, {
|
|
754
|
-
default:
|
|
755
|
-
|
|
3553
|
+
default: H(() => [
|
|
3554
|
+
re(G(x(r).t("renderer.noQueryBridge")), 1)
|
|
756
3555
|
]),
|
|
757
3556
|
_: 1
|
|
758
3557
|
}))
|
|
759
3558
|
]);
|
|
760
3559
|
};
|
|
761
3560
|
}
|
|
762
|
-
}),
|
|
3561
|
+
}), ii = /* @__PURE__ */ V(Gt, [["__scopeId", "data-v-57e1dfb8"]]);
|
|
763
3562
|
export {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
3563
|
+
dt as CP_ID_TOKEN,
|
|
3564
|
+
he as DEFAULT_TILE_HEIGHT,
|
|
3565
|
+
ct as DEFAULT_TILE_REFRESH_INTERVAL_MS,
|
|
3566
|
+
ii as DashboardRenderer,
|
|
3567
|
+
pe as ENTITY_ID_TOKEN,
|
|
3568
|
+
Lt as GridLayout,
|
|
3569
|
+
Q as INJECT_QUERY_PROVIDER,
|
|
3570
|
+
ut as TIMEFRAME_TOKEN
|
|
772
3571
|
};
|