@dou-ui/dashboard 0.1.0-alpha.1 → 0.1.0-alpha.11
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/chart/chart-settings.js.map +1 -1
- package/dist/chart/chart-settings.vue_vue_type_script_setup_true_lang.js +10 -8
- package/dist/chart/chart-settings.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/chart/chart.js.map +1 -1
- package/dist/chart/chart.vue_vue_type_script_setup_true_lang.js +19 -15
- package/dist/chart/chart.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/chart/read-props.js +26 -0
- package/dist/chart/read-props.js.map +1 -0
- package/dist/core/document.js +10 -1
- package/dist/core/document.js.map +1 -1
- package/dist/core/history.js +23 -0
- package/dist/core/history.js.map +1 -1
- package/dist/core/transaction.js +8 -2
- package/dist/core/transaction.js.map +1 -1
- package/dist/dashboard/comment-button.js +6 -0
- package/dist/dashboard/comment-button.js.map +1 -0
- package/dist/dashboard/comment-button.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/dashboard/comment-button.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/dashboard/comment-card.js +6 -0
- package/dist/dashboard/comment-card.js.map +1 -0
- package/dist/dashboard/comment-card.vue_vue_type_script_setup_true_lang.js +128 -0
- package/dist/dashboard/comment-card.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/dashboard/comments.js +144 -0
- package/dist/dashboard/comments.js.map +1 -0
- package/dist/dashboard/dashboard.js.map +1 -1
- package/dist/dashboard/dashboard.vue_vue_type_script_setup_true_lang.js +132 -20
- package/dist/dashboard/dashboard.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/dashboard/error-boundary.js +64 -0
- package/dist/dashboard/error-boundary.js.map +1 -0
- package/dist/dashboard/frame-context.js.map +1 -1
- package/dist/dashboard/widget-body.js.map +1 -1
- package/dist/dashboard/widget-body.vue_vue_type_script_setup_true_lang.js +53 -12
- package/dist/dashboard/widget-body.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/dashboard/widget-frame.js.map +1 -1
- package/dist/dashboard/widget-frame.vue_vue_type_script_setup_true_lang.js +20 -10
- package/dist/dashboard/widget-frame.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/dashboard/widget-settings.js.map +1 -1
- package/dist/dashboard/widget-settings.vue_vue_type_script_setup_true_lang.js +31 -5
- package/dist/dashboard/widget-settings.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/engine.js +176 -16
- package/dist/layout/engine.js.map +1 -1
- package/dist/locale.js +12 -0
- package/dist/locale.js.map +1 -1
- package/dist/pivot/pivot-settings.js.map +1 -1
- package/dist/pivot/pivot-settings.vue_vue_type_script_setup_true_lang.js +6 -4
- package/dist/pivot/pivot-settings.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/pivot/pivot.js.map +1 -1
- package/dist/pivot/pivot.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/pivot/pivot.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/pivot/read-props.js +44 -0
- package/dist/pivot/read-props.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/style.js +8 -3
- package/dist/types/chart/read-props.d.ts +3 -0
- package/dist/types/core/document.d.ts +3 -2
- package/dist/types/core/history.d.ts +7 -1
- package/dist/types/core/transaction.d.ts +10 -1
- package/dist/types/core/types.d.ts +5 -0
- package/dist/types/dashboard/comment-button.vue.d.ts +15 -0
- package/dist/types/dashboard/comment-card.vue.d.ts +13 -0
- package/dist/types/dashboard/comments.d.ts +44 -0
- package/dist/types/dashboard/dashboard.vue.d.ts +12 -0
- package/dist/types/dashboard/error-boundary.d.ts +12 -0
- package/dist/types/dashboard/frame-context.d.ts +4 -0
- package/dist/types/dashboard/types.d.ts +47 -0
- package/dist/types/dashboard/widget-body.vue.d.ts +2 -0
- package/dist/types/dashboard/widget-settings.vue.d.ts +4 -0
- package/dist/types/index.d.ts +22 -1
- package/dist/types/layout/engine.d.ts +4 -3
- package/dist/types/locale.d.ts +8 -0
- package/dist/types/pivot/read-props.d.ts +3 -0
- package/dist/types/widgets/index.d.ts +1 -1
- package/dist/types/widgets/read-props.d.ts +4 -0
- package/dist/types/widgets/shared.d.ts +20 -4
- package/dist/widgets/index.js +2 -2
- package/dist/widgets/index.js.map +1 -1
- package/dist/widgets/read-props.js +52 -0
- package/dist/widgets/read-props.js.map +1 -0
- package/dist/widgets/shared.js +27 -5
- package/dist/widgets/shared.js.map +1 -1
- package/dist/widgets/stat-settings.js.map +1 -1
- package/dist/widgets/stat-settings.vue_vue_type_script_setup_true_lang.js +12 -10
- package/dist/widgets/stat-settings.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/widgets/stat.js.map +1 -1
- package/dist/widgets/stat.vue_vue_type_script_setup_true_lang.js +10 -13
- package/dist/widgets/stat.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/widgets/table-settings.js.map +1 -1
- package/dist/widgets/table-settings.vue_vue_type_script_setup_true_lang.js +6 -4
- package/dist/widgets/table-settings.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/table.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/widgets/table.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/widgets/text-settings.js.map +1 -1
- package/dist/widgets/text-settings.vue_vue_type_script_setup_true_lang.js +5 -3
- package/dist/widgets/text-settings.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/widgets/text.js.map +1 -1
- package/dist/widgets/text.vue_vue_type_script_setup_true_lang.js +5 -3
- package/dist/widgets/text.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["GridLayout","GridLayoutHandle","Dashboard","DashboardPalette","DashboardFilterBar"],"sources":["../src/index.ts"],"sourcesContent":["import { withInstall } from 'dou-ui'\nimport GridLayout from './grid/grid-layout.vue'\nimport GridLayoutHandle from './grid/grid-handle.vue'\nimport Dashboard from './dashboard/dashboard.vue'\nimport DashboardPalette from './dashboard/palette.vue'\nimport DashboardFilterBar from './dashboard/filter-bar.vue'\n\nexport const DouGridLayout = withInstall(GridLayout)\nexport const DouGridLayoutHandle = withInstall(GridLayoutHandle)\nexport const DouDashboard = withInstall(Dashboard)\nexport const DouDashboardPalette = withInstall(DashboardPalette)\nexport const DouDashboardFilterBar = withInstall(DashboardFilterBar)\n\nexport type {\n DashboardAddOptions,\n DashboardEmits,\n DashboardExportErrorEvent,\n DashboardExportOptions,\n DashboardSaveOptions,\n DashboardExpose,\n DashboardFilterBarProps,\n DashboardPaletteProps,\n DashboardProps,\n} from './dashboard/types'\nexport type { DashboardDocument, DashboardPlace, DashboardWidget } from './core/types'\nexport { checkDocument, emptyDocument, isDashboardPlace, migrateDocument } from './core/document'\nexport type { CheckDocumentOptions, DocumentProblem } from './core/document'\nexport { applySteps, DashboardTransaction, replaceWidgets, sameValue } from './core/transaction'\nexport type {\n DashboardCollaboration,\n DashboardCollaborationHost,\n DashboardPeer,\n DashboardPresence,\n DashboardPresenceAction,\n} from './core/collaboration'\nexport type {\n DashboardStep,\n DashboardTransactionMeta,\n DashboardWidgetPatch,\n} from './core/transaction'\nexport { DashboardHistory } from './core/history'\nexport { defineDashboardWidget } from './widget/define'\nexport type { DashboardWidgetSize, DashboardWidgetType } from './widget/define'\nexport { useDashboardWidget } from './widget/context'\nexport { isEmptyFilter } from './data/filters'\nexport type { DashboardImageOptions } from './dashboard/export'\nexport type {\n DashboardDateRangeFilterField,\n DashboardFilterField,\n DashboardFilters,\n DashboardLinkedFilter,\n DashboardSearchFilterField,\n DashboardSelectFilterField,\n DashboardSetFilterOptions,\n DashboardSourceContext,\n DashboardSourceLoad,\n DashboardSourceOptions,\n DashboardSources,\n} from './data/types'\nexport type {\n DashboardWidgetContext,\n DashboardWidgetState,\n DashboardWidgetStatus,\n} from './widget/context'\n\nexport type {\n GridChangeEvent,\n GridChangeReason,\n GridDragEndEvent,\n GridDragEvent,\n GridDropEvent,\n GridDropItem,\n GridItemSlotProps,\n GridLayoutEmits,\n GridLayoutExpose,\n GridLayoutProps,\n GridLayouts,\n GridPlace,\n GridResizeHandle,\n} from './grid/types'\nexport {\n compactLayout,\n deriveLayout,\n findPlace,\n fitItem,\n layoutHeight,\n moveItem,\n moveItemBy,\n normalizeLayout,\n overlaps,\n resizeItem,\n resizeItemBy,\n} from './layout'\nexport type { GridCompact, GridItem, GridLayoutOptions, GridPosition, GridSize } from './layout'\nexport { dashboardLocales, useDashboardMessages } from './locale'\nexport type { DashboardMessages, DashboardMessagesOverride } from './locale'\n\ndeclare module 'vue' {\n export interface GlobalComponents {\n DouGridLayout: typeof DouGridLayout\n DouGridLayoutHandle: typeof DouGridLayoutHandle\n DouDashboard: typeof DouDashboard\n DouDashboardPalette: typeof DouDashboardPalette\n DouDashboardFilterBar: typeof DouDashboardFilterBar\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAa,gBAAgB,YAAYA,mBAAU;AACnD,IAAa,sBAAsB,YAAYC,mBAAgB;AAC/D,IAAa,eAAe,YAAYC,iBAAS;AACjD,IAAa,sBAAsB,YAAYC,eAAgB;AAC/D,IAAa,wBAAwB,YAAYC,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["GridLayout","GridLayoutHandle","Dashboard","DashboardPalette","DashboardFilterBar"],"sources":["../src/index.ts"],"sourcesContent":["import { withInstall } from 'dou-ui'\nimport GridLayout from './grid/grid-layout.vue'\nimport GridLayoutHandle from './grid/grid-handle.vue'\nimport Dashboard from './dashboard/dashboard.vue'\nimport DashboardPalette from './dashboard/palette.vue'\nimport DashboardFilterBar from './dashboard/filter-bar.vue'\n\nexport const DouGridLayout = withInstall(GridLayout)\nexport const DouGridLayoutHandle = withInstall(GridLayoutHandle)\nexport const DouDashboard = withInstall(Dashboard)\nexport const DouDashboardPalette = withInstall(DashboardPalette)\nexport const DouDashboardFilterBar = withInstall(DashboardFilterBar)\n\nexport type {\n DashboardAddOptions,\n DashboardEmits,\n DashboardExportErrorEvent,\n DashboardWidgetErrorEvent,\n DashboardExportOptions,\n DashboardSaveOptions,\n DashboardCommentAnchor,\n DashboardExpose,\n DashboardFilterBarProps,\n DashboardPaletteProps,\n DashboardProps,\n} from './dashboard/types'\nexport type { DashboardDocument, DashboardPlace, DashboardWidget } from './core/types'\nexport { checkDocument, emptyDocument, isDashboardPlace, migrateDocument } from './core/document'\nexport type { CheckDocumentOptions, DocumentProblem } from './core/document'\nexport { applySteps, DashboardTransaction, replaceWidgets, sameValue } from './core/transaction'\nexport type { ReplaceWidgetsOptions } from './core/transaction'\nexport type {\n DashboardCollaboration,\n DashboardCollaborationHost,\n DashboardPeer,\n DashboardPresence,\n DashboardPresenceAction,\n} from './core/collaboration'\nexport type {\n DashboardStep,\n DashboardTransactionMeta,\n DashboardWidgetPatch,\n} from './core/transaction'\nexport { DashboardHistory } from './core/history'\nexport { defineDashboardWidget } from './widget/define'\nexport type { DashboardWidgetSize, DashboardWidgetType } from './widget/define'\nexport { useDashboardWidget } from './widget/context'\nexport { isEmptyFilter } from './data/filters'\nexport type { DashboardImageOptions } from './dashboard/export'\nexport type {\n DashboardDateRangeFilterField,\n DashboardFilterField,\n DashboardFilters,\n DashboardLinkedFilter,\n DashboardSearchFilterField,\n DashboardSelectFilterField,\n DashboardSetFilterOptions,\n DashboardSourceContext,\n DashboardSourceLoad,\n DashboardSourceOptions,\n DashboardSources,\n} from './data/types'\nexport type {\n DashboardWidgetContext,\n DashboardWidgetState,\n DashboardWidgetStatus,\n} from './widget/context'\n\nexport type {\n GridChangeEvent,\n GridChangeReason,\n GridDragEndEvent,\n GridDragEvent,\n GridDropEvent,\n GridDropItem,\n GridItemSlotProps,\n GridLayoutEmits,\n GridLayoutExpose,\n GridLayoutProps,\n GridLayouts,\n GridPlace,\n GridResizeHandle,\n} from './grid/types'\nexport {\n compactLayout,\n deriveLayout,\n findPlace,\n fitItem,\n layoutHeight,\n moveItem,\n moveItemBy,\n normalizeLayout,\n overlaps,\n resizeItem,\n resizeItemBy,\n} from './layout'\nexport type { GridCompact, GridItem, GridLayoutOptions, GridPosition, GridSize } from './layout'\nexport { dashboardLocales, useDashboardMessages } from './locale'\nexport type { DashboardMessages, DashboardMessagesOverride } from './locale'\n\ndeclare module 'vue' {\n export interface GlobalComponents {\n DouGridLayout: typeof DouGridLayout\n DouGridLayoutHandle: typeof DouGridLayoutHandle\n DouDashboard: typeof DouDashboard\n DouDashboardPalette: typeof DouDashboardPalette\n DouDashboardFilterBar: typeof DouDashboardFilterBar\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAa,gBAAgB,YAAYA,mBAAU;AACnD,IAAa,sBAAsB,YAAYC,mBAAgB;AAC/D,IAAa,eAAe,YAAYC,iBAAS;AACjD,IAAa,sBAAsB,YAAYC,eAAgB;AAC/D,IAAa,wBAAwB,YAAYC,kBAAkB"}
|
package/dist/layout/engine.js
CHANGED
|
@@ -238,10 +238,157 @@ function findPlace(items, size, options) {
|
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
|
+
* Whether a row came out right: every item at least a column wide, none
|
|
242
|
+
* on top of the one before it or past the last column, and items that
|
|
243
|
+
* were equally wide still equally wide.
|
|
244
|
+
*/
|
|
245
|
+
function fair(spans, to) {
|
|
246
|
+
const widths = /* @__PURE__ */ new Map();
|
|
247
|
+
return spans.every((span, i) => {
|
|
248
|
+
const prev = spans[i - 1];
|
|
249
|
+
if (span.w < 1 || span.x + span.w > to) return false;
|
|
250
|
+
if (prev && prev.line === span.line && span.x < prev.x + prev.w) return false;
|
|
251
|
+
const w = widths.get(span.item.w);
|
|
252
|
+
if (w === void 0) widths.set(span.item.w, span.w);
|
|
253
|
+
return w === void 0 || w === span.w;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/** Both edges scaled and rounded, so items side by side stay side by side. */
|
|
257
|
+
function scaled(row, factor) {
|
|
258
|
+
const edge = (value) => Math.round(value * factor);
|
|
259
|
+
return row.map((item) => {
|
|
260
|
+
const x = edge(item.x);
|
|
261
|
+
return {
|
|
262
|
+
item,
|
|
263
|
+
x,
|
|
264
|
+
w: edge(item.x + item.w) - x,
|
|
265
|
+
line: 0,
|
|
266
|
+
factor
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The row wrapped onto as few lines as keep its items equally wide, at
|
|
272
|
+
* most `most`. Items are packed left to right without the gaps between
|
|
273
|
+
* them, each line holding the same number of source columns at most, the
|
|
274
|
+
* fullest line filling the grid. At least one line holds two items or
|
|
275
|
+
* more, so items never end up one per line. Widths are rounded down,
|
|
276
|
+
* leaving columns empty, when no number of lines keeps them equal otherwise.
|
|
277
|
+
*/
|
|
278
|
+
function wrapped(row, to, most) {
|
|
279
|
+
const total = row.reduce((sum, item) => sum + item.w, 0);
|
|
280
|
+
const pack = (size) => {
|
|
281
|
+
const lines = [];
|
|
282
|
+
let used = Infinity;
|
|
283
|
+
for (const item of row) {
|
|
284
|
+
if (used + item.w > size) {
|
|
285
|
+
lines.push([]);
|
|
286
|
+
used = 0;
|
|
287
|
+
}
|
|
288
|
+
lines[lines.length - 1].push(item);
|
|
289
|
+
used += item.w;
|
|
290
|
+
}
|
|
291
|
+
return lines;
|
|
292
|
+
};
|
|
293
|
+
const options = /* @__PURE__ */ new Map();
|
|
294
|
+
for (let size = Math.max(...row.map((item) => item.w)); size < total; size++) {
|
|
295
|
+
const lines = pack(size);
|
|
296
|
+
if (lines.length <= most && lines.length < row.length && !options.has(lines.length)) options.set(lines.length, {
|
|
297
|
+
lines,
|
|
298
|
+
size
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
const counts = [...options.keys()];
|
|
302
|
+
counts.sort((a, b) => a - b);
|
|
303
|
+
for (const down of [false, true]) for (const count of counts) {
|
|
304
|
+
const { lines, size } = options.get(count);
|
|
305
|
+
const factor = to / size;
|
|
306
|
+
const spans = [];
|
|
307
|
+
for (const [line, items] of lines.entries()) {
|
|
308
|
+
let start = 0;
|
|
309
|
+
let end = 0;
|
|
310
|
+
for (const item of items) {
|
|
311
|
+
const x = down ? end : Math.round(start * factor);
|
|
312
|
+
start += item.w;
|
|
313
|
+
const w = down ? Math.floor(item.w * factor) : Math.round(start * factor) - x;
|
|
314
|
+
end = x + w;
|
|
315
|
+
spans.push({
|
|
316
|
+
item,
|
|
317
|
+
x,
|
|
318
|
+
w,
|
|
319
|
+
line,
|
|
320
|
+
factor
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (fair(spans, to)) return spans;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The row kept on one line, items that share a width given the same
|
|
329
|
+
* number of columns: rounded to the nearest when they fit, otherwise
|
|
330
|
+
* rounded down. Items that touched still touch, so the columns left empty
|
|
331
|
+
* gather at the end; items with a gap between them stay near where they
|
|
332
|
+
* were, moved left only as far as it takes to fit.
|
|
333
|
+
*/
|
|
334
|
+
function oneLine(row, scale, to) {
|
|
335
|
+
const shared = /* @__PURE__ */ new Map();
|
|
336
|
+
for (const item of row) shared.set(item.w, (shared.get(item.w) ?? 0) + 1);
|
|
337
|
+
for (const round of [Math.round, Math.floor]) {
|
|
338
|
+
const spans = [];
|
|
339
|
+
for (const item of row) {
|
|
340
|
+
const prev = spans[spans.length - 1];
|
|
341
|
+
const x = !prev ? Math.round(item.x * scale) : prev.item.x + prev.item.w === item.x ? prev.x + prev.w : Math.max(Math.round(item.x * scale), prev.x + prev.w);
|
|
342
|
+
const w = (shared.get(item.w) > 1 ? round : Math.round)(item.w * scale);
|
|
343
|
+
spans.push({
|
|
344
|
+
item,
|
|
345
|
+
x,
|
|
346
|
+
w,
|
|
347
|
+
line: 0,
|
|
348
|
+
factor: scale
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
let end = to;
|
|
352
|
+
for (let i = spans.length - 1; i >= 0; i--) {
|
|
353
|
+
const span = spans[i];
|
|
354
|
+
span.x = Math.min(span.x, end - span.w);
|
|
355
|
+
end = span.x;
|
|
356
|
+
}
|
|
357
|
+
if (end >= 0 && fair(spans, to)) return spans;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* One row (items sharing a `y`, left to right) on `to` columns, keeping
|
|
362
|
+
* equally wide items equally wide. In order of preference: scaled as is;
|
|
363
|
+
* wrapped onto two lines; kept on one line; wrapped onto more lines. The
|
|
364
|
+
* widths are rounded to the nearest column when that keeps them equal and
|
|
365
|
+
* rounded down otherwise, leaving columns empty. Rows
|
|
366
|
+
* only wrap when the grid gets narrower and the row is a band of its own
|
|
367
|
+
* (all its items equally tall, nothing else reaching into it). Rounded as
|
|
368
|
+
* before when none of that works.
|
|
369
|
+
*/
|
|
370
|
+
function scaleRow(row, band, from, to) {
|
|
371
|
+
const scale = to / from;
|
|
372
|
+
const spans = scaled(row, scale);
|
|
373
|
+
if (fair(spans, to)) return spans;
|
|
374
|
+
const wraps = band && to < from;
|
|
375
|
+
const two = wraps ? wrapped(row, to, 2) : void 0;
|
|
376
|
+
if (two) return two;
|
|
377
|
+
const one = oneLine(row, scale, to);
|
|
378
|
+
if (one) return one;
|
|
379
|
+
return (wraps ? wrapped(row, to, row.length) : void 0) ?? spans.map((span) => ({
|
|
380
|
+
...span,
|
|
381
|
+
w: Math.max(1, span.w)
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
/** A `minW` or `maxW` scaled with the item. */
|
|
385
|
+
var limit = (value, factor) => value === void 0 ? void 0 : Math.max(1, Math.round(value * factor));
|
|
386
|
+
/**
|
|
241
387
|
* The layout worked out for a grid of another width: positions and widths
|
|
242
|
-
* scaled by the ratio of the columns, then settled.
|
|
243
|
-
*
|
|
244
|
-
*
|
|
388
|
+
* scaled by the ratio of the columns, then settled. Items in a row that
|
|
389
|
+
* were equally wide stay equally wide, by wrapping the row or leaving
|
|
390
|
+
* columns empty (see the docs). On a single column the items are stacked
|
|
391
|
+
* in reading order (top to bottom, then left to right), each keeping its height.
|
|
245
392
|
*/
|
|
246
393
|
function deriveLayout(items, from, options) {
|
|
247
394
|
const to = options.columns;
|
|
@@ -265,19 +412,32 @@ function deriveLayout(items, from, options) {
|
|
|
265
412
|
}
|
|
266
413
|
return out;
|
|
267
414
|
}
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
415
|
+
const rows = /* @__PURE__ */ new Map();
|
|
416
|
+
for (const item of items) {
|
|
417
|
+
const row = rows.get(item.y);
|
|
418
|
+
if (row) row.push(item);
|
|
419
|
+
else rows.set(item.y, [item]);
|
|
420
|
+
}
|
|
421
|
+
const ys = [...rows.keys()];
|
|
422
|
+
ys.sort((a, b) => a - b);
|
|
423
|
+
const placed = /* @__PURE__ */ new Map();
|
|
424
|
+
let shift = 0;
|
|
425
|
+
for (const y of ys) {
|
|
426
|
+
const row = rows.get(y);
|
|
427
|
+
row.sort((a, b) => a.x - b.x);
|
|
428
|
+
const h = row[0].h;
|
|
429
|
+
const spans = scaleRow(row, row.every((item) => item.h === h) && items.every((item) => item.y === y || item.y + item.h <= y || item.y >= y + h), from, to);
|
|
430
|
+
for (const span of spans) placed.set(span.item, fitItem({
|
|
431
|
+
...span.item,
|
|
432
|
+
x: span.x,
|
|
433
|
+
y: y + shift + span.line * h,
|
|
434
|
+
w: span.w,
|
|
435
|
+
minW: limit(span.item.minW, span.factor),
|
|
436
|
+
maxW: limit(span.item.maxW, span.factor)
|
|
437
|
+
}, to));
|
|
438
|
+
shift += spans[spans.length - 1].line * h;
|
|
439
|
+
}
|
|
440
|
+
return normalizeLayout(items.map((item) => placed.get(item)), options);
|
|
281
441
|
}
|
|
282
442
|
export { compactLayout, deriveLayout, findPlace, fitItem, layoutHeight, moveItem, moveItemBy, normalizeLayout, overlaps, resizeItem, resizeItemBy };
|
|
283
443
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","names":[],"sources":["../../src/layout/engine.ts"],"sourcesContent":["import type { GridItem, GridLayoutOptions, GridPosition, GridSize } from './types'\n\n/*\n * The layout engine: plain functions from a layout to a layout.\n *\n * Every function returns a new array in the same order as the one it was\n * given, and keeps the objects of the items that did not move, so a caller\n * can tell what changed by identity. The same input always gives the same\n * output: the order items are settled in depends only on their positions\n * and their places in the array, which is what lets several people editing\n * the same layout end up with the same result.\n */\n\ntype Box = Pick<GridItem, 'x' | 'y' | 'w' | 'h'>\n\n/** Whether two boxes share at least one cell. */\nexport function overlaps(a: Box, b: Box): boolean {\n return a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h\n}\n\n/** The row just below the lowest item: how many rows the layout takes up. */\nexport function layoutHeight(items: readonly Box[]): number {\n let bottom = 0\n for (const item of items) bottom = Math.max(bottom, item.y + item.h)\n return bottom\n}\n\nconst int = (value: number, fallback: number) =>\n Number.isFinite(value) ? Math.round(value) : fallback\n\n/** The width an item may have on a grid of `columns`. */\nfunction clampW(item: GridItem, w: number, columns: number) {\n const max = Math.min(columns, item.maxW ?? columns)\n const min = Math.min(max, Math.max(1, item.minW ?? 1))\n return Math.min(max, Math.max(min, int(w, min)))\n}\n\nfunction clampH(item: GridItem, h: number) {\n const max = Math.max(1, item.maxH ?? Infinity)\n const min = Math.min(max, Math.max(1, item.minH ?? 1))\n return Math.min(max, Math.max(min, int(h, min)))\n}\n\n/**\n * The item with its size inside its limits and the grid's width, and its\n * position on the grid, in whole cells. Returns the item itself when it fits.\n */\nexport function fitItem(item: GridItem, columns: number): GridItem {\n const w = clampW(item, item.w, columns)\n const h = clampH(item, item.h)\n const x = Math.min(columns - w, Math.max(0, int(item.x, 0)))\n const y = Math.max(0, int(item.y, 0))\n return x === item.x && y === item.y && w === item.w && h === item.h\n ? item\n : { ...item, x, y, w, h }\n}\n\nconst at = (item: GridItem, x: number, y: number): GridItem =>\n item.x === x && item.y === y ? item : { ...item, x, y }\n\n/**\n * Where an item the moved one landed on could step aside to: the same\n * row, shifted into the columns the moved item left. This is what turns\n * dropping an item onto its neighbour into a swap, instead of pushing the\n * neighbour down. `undefined` when the item isn't in the way, or wouldn't\n * fit in those columns.\n */\nfunction aside(item: GridItem, fixed?: GridItem, origin?: Box): number | undefined {\n if (!fixed || !origin || !overlaps(item, fixed)) return undefined\n const hi = origin.x + origin.w - item.w\n if (hi < origin.x) return undefined\n const x = Math.min(hi, Math.max(origin.x, item.x))\n return x === item.x ? undefined : x\n}\n\n/** The first of `boxes` that shares a cell with the box, if any. */\nfunction hit(boxes: readonly Box[], box: Box): Box | undefined {\n for (const other of boxes) if (overlaps(other, box)) return other\n return undefined\n}\n\n/** Moves the box down until it is clear of every one of `boxes`; returns its row. */\nfunction below(boxes: readonly Box[], box: Box): number {\n const probe = { ...box }\n for (let other = hit(boxes, probe); other; other = hit(boxes, probe)) probe.y = other.y + other.h\n return probe.y\n}\n\n/**\n * Settles every item that isn't locked and isn't `fixed`; those stay where\n * they are and the rest go around them. Items are settled from the top\n * down (then left to right, then by their place in the array).\n */\nfunction settle(\n items: readonly GridItem[],\n options: GridLayoutOptions,\n fixed?: GridItem,\n origin?: Box,\n): GridItem[] {\n const out = items.slice()\n const obstacles: GridItem[] = []\n const order: number[] = []\n items.forEach((item, i) => {\n if (item.locked || item === fixed) obstacles.push(item)\n else order.push(i)\n })\n order.sort((a, b) => items[a]!.y - items[b]!.y || items[a]!.x - items[b]!.x || a - b)\n\n if (options.compact === false) {\n // Each item keeps its row unless something settled before it is in the way.\n const placed = obstacles.slice()\n for (const i of order) {\n const item = items[i]!\n let x = item.x\n let y = below(placed, item)\n const side = aside(item, fixed, origin)\n if (side !== undefined && !hit(placed, { ...item, x: side })) [x, y] = [side, item.y]\n placed.push((out[i] = at(item, x, y)))\n }\n return out\n }\n\n // `top[c]` is the row below everything settled so far in column `c`: an\n // item can float up to the lowest of these across its columns, which is\n // as far as it can go without passing an item that was above it.\n const top = new Int32Array(options.columns)\n for (const i of order) {\n const item = items[i]!\n const rise = (x: number) => {\n let y = 0\n for (let c = x; c < x + item.w; c++) y = Math.max(y, top[c] ?? 0)\n return below(obstacles, { x, y, w: item.w, h: item.h })\n }\n let x = item.x\n let y = rise(x)\n const side = aside(item, fixed, origin)\n if (side !== undefined) {\n const y2 = rise(side)\n if (y2 < y) [x, y] = [side, y2]\n }\n for (let c = x; c < x + item.w; c++) top[c] = y + item.h\n out[i] = at(item, x, y)\n }\n return out\n}\n\n/**\n * The layout fitted to the grid: sizes inside their limits, nothing past\n * the last column, no two items on the same cell and, when compacting,\n * no gaps above items. Returns `items` itself when it is already settled.\n */\nexport function normalizeLayout(\n items: readonly GridItem[],\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const fitted = items.map((item) => fitItem(item, options.columns))\n const out = settle(fitted, options)\n return out.every((item, i) => item === items[i]) ? items : out\n}\n\n/** Floats every item up as far as it goes (ignores `compact`). */\nexport function compactLayout(items: readonly GridItem[], columns: number): GridItem[] {\n return settle(items, { columns, compact: 'vertical' })\n}\n\n/** Puts `item` at the given place, moved down below any locked item it lands on. */\nfunction place(\n items: readonly GridItem[],\n index: number,\n next: GridItem,\n options: GridLayoutOptions,\n): GridItem[] {\n const locked = items.filter((other) => other.locked && other !== items[index])\n const y = below(locked, next)\n const out = items.slice()\n const moved = (out[index] = at(next, next.x, y))\n const settled = settle(out, options, moved, items[index])\n // Compacting a second time lets the item itself float up into the gap\n // it would otherwise leave, and puts it after the items it was dropped below.\n return options.compact === false ? settled : settle(settled, options)\n}\n\n/**\n * Moves an item to a cell; the items it lands on make way. Locked items\n * and unknown ids leave the layout as it is.\n */\nexport function moveItem(\n items: readonly GridItem[],\n id: string,\n to: GridPosition,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const index = items.findIndex((item) => item.id === id)\n const item = items[index]\n if (!item || item.locked) return items\n const x = Math.min(options.columns - item.w, Math.max(0, int(to.x, item.x)))\n const y = Math.max(0, int(to.y, item.y))\n return place(items, index, { ...item, x, y }, options)\n}\n\n/**\n * Gives an item a new size, keeping its top-left corner; the items it now\n * covers make way. A size that would cover a locked item is refused.\n */\nexport function resizeItem(\n items: readonly GridItem[],\n id: string,\n to: GridSize,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const index = items.findIndex((item) => item.id === id)\n const item = items[index]\n if (!item || item.locked) return items\n const w = Math.min(options.columns - item.x, clampW(item, to.w, options.columns))\n const h = clampH(item, to.h)\n const next = { ...item, w: Math.max(1, w), h }\n if (items.some((other) => other.locked && other !== item && overlaps(other, next))) return items\n return place(items, index, next, options)\n}\n\nconst sameSpot = (a: GridItem | undefined, b: GridItem) =>\n !!a && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h\n\n/**\n * Moves an item by whole cells, as the arrow keys do. Moving up or down\n * goes on past rows where the item would only settle back where it was,\n * so one press always moves it, to the next place it can take.\n */\nexport function moveItemBy(\n items: readonly GridItem[],\n id: string,\n dx: number,\n dy: number,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const item = items.find((other) => other.id === id)\n if (!item || item.locked) return items\n if (!dy) return moveItem(items, id, { x: item.x + dx, y: item.y }, options)\n const step = Math.sign(dy)\n const last = layoutHeight(items)\n for (let y = item.y + dy; y >= 0 && y <= last; y += step) {\n const out = moveItem(items, id, { x: item.x + dx, y }, options)\n if (\n !sameSpot(\n out.find((other) => other.id === id),\n item,\n )\n )\n return out\n }\n return items\n}\n\n/** Resizes an item by whole cells, as Shift and the arrow keys do. */\nexport function resizeItemBy(\n items: readonly GridItem[],\n id: string,\n dw: number,\n dh: number,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const item = items.find((other) => other.id === id)\n if (!item) return items\n return resizeItem(items, id, { w: item.w + dw, h: item.h + dh }, options)\n}\n\n/**\n * Where a new item of `size` fits: the first free spot reading from the top\n * left, or below everything when no row has room.\n */\nexport function findPlace(\n items: readonly GridItem[],\n size: GridSize,\n options: GridLayoutOptions,\n): GridPosition {\n const w = Math.min(options.columns, Math.max(1, Math.round(size.w)))\n const h = Math.max(1, Math.round(size.h))\n const bottom = layoutHeight(items)\n for (let y = 0; y < bottom; y++)\n for (let x = 0; x + w <= options.columns; x++) {\n const other = hit(items, { x, y, w, h })\n if (!other) return { x, y }\n // skip to the column after the item in the way\n x = other.x + other.w - 1\n }\n return { x: 0, y: bottom }\n}\n\n/**\n * The layout worked out for a grid of another width: positions and widths\n * scaled by the ratio of the columns, then settled. On a single column the\n * items are stacked in reading order (top to bottom, then left to right),\n * each keeping its height.\n */\nexport function deriveLayout(\n items: readonly GridItem[],\n from: number,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const to = options.columns\n if (from === to) return normalizeLayout(items, options)\n if (to === 1) {\n const order = items.map((_, i) => i)\n order.sort((a, b) => items[a]!.y - items[b]!.y || items[a]!.x - items[b]!.x || a - b)\n const out = items.slice()\n let y = 0\n for (const i of order) {\n const item = fitItem({ ...items[i]!, x: 0, w: 1 }, 1)\n out[i] = { ...item, y }\n y += item.h\n }\n return out\n }\n const scale = to / from\n // both edges are scaled, so items side by side stay side by side\n const edge = (value: number) => Math.round(value * scale)\n const limit = (value: number | undefined) =>\n value === undefined ? undefined : Math.max(1, edge(value))\n const scaled = items.map((item) => {\n const x = edge(item.x)\n return fitItem(\n {\n ...item,\n x,\n w: Math.max(1, edge(item.x + item.w) - x),\n minW: limit(item.minW),\n maxW: limit(item.maxW),\n },\n to,\n )\n })\n return normalizeLayout(scaled, options)\n}\n"],"mappings":";;AAgBA,SAAgB,SAAS,GAAQ,GAAiB;CAChD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EA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AAK,CAAC;EACrB,OAAO,QACL;GACE,GAAG;GACH;GACA,GAAG,KAAK,IAAI,GAAG,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC;GACxC,MAAM,MAAM,KAAK,IAAI;GACrB,MAAM,MAAM,KAAK,IAAI;EACvB,GACA,EACF;CACF,CACuB,GAAQ,OAAO;AACxC"}
|
|
1
|
+
{"version":3,"file":"engine.js","names":[],"sources":["../../src/layout/engine.ts"],"sourcesContent":["import type { GridItem, GridLayoutOptions, GridPosition, GridSize } from './types'\n\n/*\n * The layout engine: plain functions from a layout to a layout.\n *\n * Every function returns a new array in the same order as the one it was\n * given, and keeps the objects of the items that did not move, so a caller\n * can tell what changed by identity. The same input always gives the same\n * output: the order items are settled in depends only on their positions\n * and their places in the array, which is what lets several people editing\n * the same layout end up with the same result.\n */\n\ntype Box = Pick<GridItem, 'x' | 'y' | 'w' | 'h'>\n\n/** Whether two boxes share at least one cell. */\nexport function overlaps(a: Box, b: Box): boolean {\n return a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h\n}\n\n/** The row just below the lowest item: how many rows the layout takes up. */\nexport function layoutHeight(items: readonly Box[]): number {\n let bottom = 0\n for (const item of items) bottom = Math.max(bottom, item.y + item.h)\n return bottom\n}\n\nconst int = (value: number, fallback: number) =>\n Number.isFinite(value) ? Math.round(value) : fallback\n\n/** The width an item may have on a grid of `columns`. */\nfunction clampW(item: GridItem, w: number, columns: number) {\n const max = Math.min(columns, item.maxW ?? columns)\n const min = Math.min(max, Math.max(1, item.minW ?? 1))\n return Math.min(max, Math.max(min, int(w, min)))\n}\n\nfunction clampH(item: GridItem, h: number) {\n const max = Math.max(1, item.maxH ?? Infinity)\n const min = Math.min(max, Math.max(1, item.minH ?? 1))\n return Math.min(max, Math.max(min, int(h, min)))\n}\n\n/**\n * The item with its size inside its limits and the grid's width, and its\n * position on the grid, in whole cells. Returns the item itself when it fits.\n */\nexport function fitItem(item: GridItem, columns: number): GridItem {\n const w = clampW(item, item.w, columns)\n const h = clampH(item, item.h)\n const x = Math.min(columns - w, Math.max(0, int(item.x, 0)))\n const y = Math.max(0, int(item.y, 0))\n return x === item.x && y === item.y && w === item.w && h === item.h\n ? item\n : { ...item, x, y, w, h }\n}\n\nconst at = (item: GridItem, x: number, y: number): GridItem =>\n item.x === x && item.y === y ? item : { ...item, x, y }\n\n/**\n * Where an item the moved one landed on could step aside to: the same\n * row, shifted into the columns the moved item left. This is what turns\n * dropping an item onto its neighbour into a swap, instead of pushing the\n * neighbour down. `undefined` when the item isn't in the way, or wouldn't\n * fit in those columns.\n */\nfunction aside(item: GridItem, fixed?: GridItem, origin?: Box): number | undefined {\n if (!fixed || !origin || !overlaps(item, fixed)) return undefined\n const hi = origin.x + origin.w - item.w\n if (hi < origin.x) return undefined\n const x = Math.min(hi, Math.max(origin.x, item.x))\n return x === item.x ? undefined : x\n}\n\n/** The first of `boxes` that shares a cell with the box, if any. */\nfunction hit(boxes: readonly Box[], box: Box): Box | undefined {\n for (const other of boxes) if (overlaps(other, box)) return other\n return undefined\n}\n\n/** Moves the box down until it is clear of every one of `boxes`; returns its row. */\nfunction below(boxes: readonly Box[], box: Box): number {\n const probe = { ...box }\n for (let other = hit(boxes, probe); other; other = hit(boxes, probe)) probe.y = other.y + other.h\n return probe.y\n}\n\n/**\n * Settles every item that isn't locked and isn't `fixed`; those stay where\n * they are and the rest go around them. Items are settled from the top\n * down (then left to right, then by their place in the array).\n */\nfunction settle(\n items: readonly GridItem[],\n options: GridLayoutOptions,\n fixed?: GridItem,\n origin?: Box,\n): GridItem[] {\n const out = items.slice()\n const obstacles: GridItem[] = []\n const order: number[] = []\n items.forEach((item, i) => {\n if (item.locked || item === fixed) obstacles.push(item)\n else order.push(i)\n })\n order.sort((a, b) => items[a]!.y - items[b]!.y || items[a]!.x - items[b]!.x || a - b)\n\n if (options.compact === false) {\n // Each item keeps its row unless something settled before it is in the way.\n const placed = obstacles.slice()\n for (const i of order) {\n const item = items[i]!\n let x = item.x\n let y = below(placed, item)\n const side = aside(item, fixed, origin)\n if (side !== undefined && !hit(placed, { ...item, x: side })) [x, y] = [side, item.y]\n placed.push((out[i] = at(item, x, y)))\n }\n return out\n }\n\n // `top[c]` is the row below everything settled so far in column `c`: an\n // item can float up to the lowest of these across its columns, which is\n // as far as it can go without passing an item that was above it.\n const top = new Int32Array(options.columns)\n for (const i of order) {\n const item = items[i]!\n const rise = (x: number) => {\n let y = 0\n for (let c = x; c < x + item.w; c++) y = Math.max(y, top[c] ?? 0)\n return below(obstacles, { x, y, w: item.w, h: item.h })\n }\n let x = item.x\n let y = rise(x)\n const side = aside(item, fixed, origin)\n if (side !== undefined) {\n const y2 = rise(side)\n if (y2 < y) [x, y] = [side, y2]\n }\n for (let c = x; c < x + item.w; c++) top[c] = y + item.h\n out[i] = at(item, x, y)\n }\n return out\n}\n\n/**\n * The layout fitted to the grid: sizes inside their limits, nothing past\n * the last column, no two items on the same cell and, when compacting,\n * no gaps above items. Returns `items` itself when it is already settled.\n */\nexport function normalizeLayout(\n items: readonly GridItem[],\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const fitted = items.map((item) => fitItem(item, options.columns))\n const out = settle(fitted, options)\n return out.every((item, i) => item === items[i]) ? items : out\n}\n\n/** Floats every item up as far as it goes (ignores `compact`). */\nexport function compactLayout(items: readonly GridItem[], columns: number): GridItem[] {\n return settle(items, { columns, compact: 'vertical' })\n}\n\n/** Puts `item` at the given place, moved down below any locked item it lands on. */\nfunction place(\n items: readonly GridItem[],\n index: number,\n next: GridItem,\n options: GridLayoutOptions,\n): GridItem[] {\n const locked = items.filter((other) => other.locked && other !== items[index])\n const y = below(locked, next)\n const out = items.slice()\n const moved = (out[index] = at(next, next.x, y))\n const settled = settle(out, options, moved, items[index])\n // Compacting a second time lets the item itself float up into the gap\n // it would otherwise leave, and puts it after the items it was dropped below.\n return options.compact === false ? settled : settle(settled, options)\n}\n\n/**\n * Moves an item to a cell; the items it lands on make way. Locked items\n * and unknown ids leave the layout as it is.\n */\nexport function moveItem(\n items: readonly GridItem[],\n id: string,\n to: GridPosition,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const index = items.findIndex((item) => item.id === id)\n const item = items[index]\n if (!item || item.locked) return items\n const x = Math.min(options.columns - item.w, Math.max(0, int(to.x, item.x)))\n const y = Math.max(0, int(to.y, item.y))\n return place(items, index, { ...item, x, y }, options)\n}\n\n/**\n * Gives an item a new size, keeping its top-left corner; the items it now\n * covers make way. A size that would cover a locked item is refused.\n */\nexport function resizeItem(\n items: readonly GridItem[],\n id: string,\n to: GridSize,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const index = items.findIndex((item) => item.id === id)\n const item = items[index]\n if (!item || item.locked) return items\n const w = Math.min(options.columns - item.x, clampW(item, to.w, options.columns))\n const h = clampH(item, to.h)\n const next = { ...item, w: Math.max(1, w), h }\n if (items.some((other) => other.locked && other !== item && overlaps(other, next))) return items\n return place(items, index, next, options)\n}\n\nconst sameSpot = (a: GridItem | undefined, b: GridItem) =>\n !!a && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h\n\n/**\n * Moves an item by whole cells, as the arrow keys do. Moving up or down\n * goes on past rows where the item would only settle back where it was,\n * so one press always moves it, to the next place it can take.\n */\nexport function moveItemBy(\n items: readonly GridItem[],\n id: string,\n dx: number,\n dy: number,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const item = items.find((other) => other.id === id)\n if (!item || item.locked) return items\n if (!dy) return moveItem(items, id, { x: item.x + dx, y: item.y }, options)\n const step = Math.sign(dy)\n const last = layoutHeight(items)\n for (let y = item.y + dy; y >= 0 && y <= last; y += step) {\n const out = moveItem(items, id, { x: item.x + dx, y }, options)\n if (\n !sameSpot(\n out.find((other) => other.id === id),\n item,\n )\n )\n return out\n }\n return items\n}\n\n/** Resizes an item by whole cells, as Shift and the arrow keys do. */\nexport function resizeItemBy(\n items: readonly GridItem[],\n id: string,\n dw: number,\n dh: number,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const item = items.find((other) => other.id === id)\n if (!item) return items\n return resizeItem(items, id, { w: item.w + dw, h: item.h + dh }, options)\n}\n\n/**\n * Where a new item of `size` fits: the first free spot reading from the top\n * left, or below everything when no row has room.\n */\nexport function findPlace(\n items: readonly GridItem[],\n size: GridSize,\n options: GridLayoutOptions,\n): GridPosition {\n const w = Math.min(options.columns, Math.max(1, Math.round(size.w)))\n const h = Math.max(1, Math.round(size.h))\n const bottom = layoutHeight(items)\n for (let y = 0; y < bottom; y++)\n for (let x = 0; x + w <= options.columns; x++) {\n const other = hit(items, { x, y, w, h })\n if (!other) return { x, y }\n // skip to the column after the item in the way\n x = other.x + other.w - 1\n }\n return { x: 0, y: bottom }\n}\n\ninterface Span {\n item: GridItem\n x: number\n w: number\n /** Line within the row, 0 when the row didn't wrap. */\n line: number\n /** What the item's width was scaled by, for its `minW` and `maxW`. */\n factor: number\n}\n\n/**\n * Whether a row came out right: every item at least a column wide, none\n * on top of the one before it or past the last column, and items that\n * were equally wide still equally wide.\n */\nfunction fair(spans: readonly Span[], to: number) {\n const widths = new Map<number, number>()\n return spans.every((span, i) => {\n const prev = spans[i - 1]\n if (span.w < 1 || span.x + span.w > to) return false\n if (prev && prev.line === span.line && span.x < prev.x + prev.w) return false\n const w = widths.get(span.item.w)\n if (w === undefined) widths.set(span.item.w, span.w)\n return w === undefined || w === span.w\n })\n}\n\n/** Both edges scaled and rounded, so items side by side stay side by side. */\nfunction scaled(row: readonly GridItem[], factor: number): Span[] {\n const edge = (value: number) => Math.round(value * factor)\n return row.map((item) => {\n const x = edge(item.x)\n return { item, x, w: edge(item.x + item.w) - x, line: 0, factor }\n })\n}\n\n/**\n * The row wrapped onto as few lines as keep its items equally wide, at\n * most `most`. Items are packed left to right without the gaps between\n * them, each line holding the same number of source columns at most, the\n * fullest line filling the grid. At least one line holds two items or\n * more, so items never end up one per line. Widths are rounded down,\n * leaving columns empty, when no number of lines keeps them equal otherwise.\n */\nfunction wrapped(row: readonly GridItem[], to: number, most: number): Span[] | undefined {\n const total = row.reduce((sum, item) => sum + item.w, 0)\n const pack = (size: number) => {\n const lines: GridItem[][] = []\n let used = Infinity\n for (const item of row) {\n if (used + item.w > size) {\n lines.push([])\n used = 0\n }\n lines[lines.length - 1]!.push(item)\n used += item.w\n }\n return lines\n }\n // the smallest size for each number of lines balances the lines best\n const options = new Map<number, { lines: GridItem[][]; size: number }>()\n for (let size = Math.max(...row.map((item) => item.w)); size < total; size++) {\n const lines = pack(size)\n if (lines.length <= most && lines.length < row.length && !options.has(lines.length))\n options.set(lines.length, { lines, size })\n }\n const counts = [...options.keys()]\n counts.sort((a, b) => a - b)\n for (const down of [false, true])\n for (const count of counts) {\n const { lines, size } = options.get(count)!\n const factor = to / size\n const spans: Span[] = []\n for (const [line, items] of lines.entries()) {\n let start = 0\n let end = 0\n for (const item of items) {\n const x = down ? end : Math.round(start * factor)\n start += item.w\n const w = down ? Math.floor(item.w * factor) : Math.round(start * factor) - x\n end = x + w\n spans.push({ item, x, w, line, factor })\n }\n }\n if (fair(spans, to)) return spans\n }\n return undefined\n}\n\n/**\n * The row kept on one line, items that share a width given the same\n * number of columns: rounded to the nearest when they fit, otherwise\n * rounded down. Items that touched still touch, so the columns left empty\n * gather at the end; items with a gap between them stay near where they\n * were, moved left only as far as it takes to fit.\n */\nfunction oneLine(row: readonly GridItem[], scale: number, to: number): Span[] | undefined {\n const shared = new Map<number, number>()\n for (const item of row) shared.set(item.w, (shared.get(item.w) ?? 0) + 1)\n for (const round of [Math.round, Math.floor]) {\n const spans: Span[] = []\n for (const item of row) {\n const prev = spans[spans.length - 1]\n // items that touched still touch, so empty columns gather at the end\n const x = !prev\n ? Math.round(item.x * scale)\n : prev.item.x + prev.item.w === item.x\n ? prev.x + prev.w\n : Math.max(Math.round(item.x * scale), prev.x + prev.w)\n const w = (shared.get(item.w)! > 1 ? round : Math.round)(item.w * scale)\n spans.push({ item, x, w, line: 0, factor: scale })\n }\n let end = to\n for (let i = spans.length - 1; i >= 0; i--) {\n const span = spans[i]!\n span.x = Math.min(span.x, end - span.w)\n end = span.x\n }\n if (end >= 0 && fair(spans, to)) return spans\n }\n return undefined\n}\n\n/**\n * One row (items sharing a `y`, left to right) on `to` columns, keeping\n * equally wide items equally wide. In order of preference: scaled as is;\n * wrapped onto two lines; kept on one line; wrapped onto more lines. The\n * widths are rounded to the nearest column when that keeps them equal and\n * rounded down otherwise, leaving columns empty. Rows\n * only wrap when the grid gets narrower and the row is a band of its own\n * (all its items equally tall, nothing else reaching into it). Rounded as\n * before when none of that works.\n */\nfunction scaleRow(row: readonly GridItem[], band: boolean, from: number, to: number): Span[] {\n const scale = to / from\n const spans = scaled(row, scale)\n if (fair(spans, to)) return spans\n const wraps = band && to < from\n const two = wraps ? wrapped(row, to, 2) : undefined\n if (two) return two\n const one = oneLine(row, scale, to)\n if (one) return one\n const more = wraps ? wrapped(row, to, row.length) : undefined\n return more ?? spans.map((span) => ({ ...span, w: Math.max(1, span.w) }))\n}\n\n/** A `minW` or `maxW` scaled with the item. */\nconst limit = (value: number | undefined, factor: number) =>\n value === undefined ? undefined : Math.max(1, Math.round(value * factor))\n\n/**\n * The layout worked out for a grid of another width: positions and widths\n * scaled by the ratio of the columns, then settled. Items in a row that\n * were equally wide stay equally wide, by wrapping the row or leaving\n * columns empty (see the docs). On a single column the items are stacked\n * in reading order (top to bottom, then left to right), each keeping its height.\n */\nexport function deriveLayout(\n items: readonly GridItem[],\n from: number,\n options: GridLayoutOptions,\n): readonly GridItem[] {\n const to = options.columns\n if (from === to) return normalizeLayout(items, options)\n if (to === 1) {\n const order = items.map((_, i) => i)\n order.sort((a, b) => items[a]!.y - items[b]!.y || items[a]!.x - items[b]!.x || a - b)\n const out = items.slice()\n let y = 0\n for (const i of order) {\n const item = fitItem({ ...items[i]!, x: 0, w: 1 }, 1)\n out[i] = { ...item, y }\n y += item.h\n }\n return out\n }\n const rows = new Map<number, GridItem[]>()\n for (const item of items) {\n const row = rows.get(item.y)\n if (row) row.push(item)\n else rows.set(item.y, [item])\n }\n const ys = [...rows.keys()]\n ys.sort((a, b) => a - b)\n const placed = new Map<GridItem, GridItem>()\n // lines a row wraps onto push everything below it down\n let shift = 0\n for (const y of ys) {\n const row = rows.get(y)!\n row.sort((a, b) => a.x - b.x)\n const h = row[0]!.h\n const band =\n row.every((item) => item.h === h) &&\n items.every((item) => item.y === y || item.y + item.h <= y || item.y >= y + h)\n const spans = scaleRow(row, band, from, to)\n for (const span of spans)\n placed.set(\n span.item,\n fitItem(\n {\n ...span.item,\n x: span.x,\n y: y + shift + span.line * h,\n w: span.w,\n minW: limit(span.item.minW, span.factor),\n maxW: limit(span.item.maxW, span.factor),\n },\n to,\n ),\n )\n shift += spans[spans.length - 1]!.line * h\n }\n return normalizeLayout(\n items.map((item) => placed.get(item)!),\n options,\n )\n}\n"],"mappings":";;AAgBA,SAAgB,SAAS,GAAQ,GAAiB;CAChD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE;AAChF;;AAGA,SAAgB,aAAa,OAA+B;CAC1D,IAAI,SAAS;CACb,KAAK,MAAM,QAAQ,OAAO,SAAS,KAAK,IAAI,QAAQ,KAAK,IAAI,KAAK,CAAC;CACnE,OAAO;AACT;AAEA,IAAM,OAAO,OAAe,aAC1B,OAAO,SAAS,KAAK,IAAI,KAAK,MAAM,KAAK,IAAI;;AAG/C,SAAS,OAAO,MAAgB,GAAW,SAAiB;CAC1D,MAAM,MAAM,KAAK,IAAI,SAAS,KAAK,QAAQ,OAAO;CAClD,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,QAAQ,CAAC,CAAC;CACrD,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,GAAG,CAAC,CAAC;AACjD;AAEA,SAAS,OAAO,MAAgB,GAAW;CACz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KAAK;GACR,GAAG,KAAK;GACR,GAAG,IAAI,QAAQ,KAAK,OAAO;GAC3B,GAAG,KAAK;GACR,MAAM,MAAM,KAAK,KAAK,MAAM,KAAK,MAAM;GACvC,MAAM,MAAM,KAAK,KAAK,MAAM,KAAK,MAAM;EACzC,GACA,EACF,CACF;EACF,SAAS,MAAM,MAAM,SAAS,EAAE,CAAE,OAAO;CAC3C;CACA,OAAO,gBACL,MAAM,KAAK,SAAS,OAAO,IAAI,IAAI,CAAE,GACrC,OACF;AACF"}
|
package/dist/locale.js
CHANGED
|
@@ -22,6 +22,8 @@ var zhCN = {
|
|
|
22
22
|
nothingToExport: "没有可导出的数据",
|
|
23
23
|
duplicate: "复制一份",
|
|
24
24
|
remove: "删除",
|
|
25
|
+
comment: "评论",
|
|
26
|
+
comments: "{count} 条评论",
|
|
25
27
|
settingsTitle: "{title}的设置",
|
|
26
28
|
titleField: "标题",
|
|
27
29
|
added: "已添加 {item}",
|
|
@@ -29,6 +31,8 @@ var zhCN = {
|
|
|
29
31
|
unknownType: "没有注册类型为 {type} 的格子",
|
|
30
32
|
loading: "加载中",
|
|
31
33
|
error: "加载失败",
|
|
34
|
+
renderError: "无法显示",
|
|
35
|
+
settingsError: "无法显示设置",
|
|
32
36
|
empty: "暂无数据",
|
|
33
37
|
retry: "重试",
|
|
34
38
|
emptyTitle: "还没有格子",
|
|
@@ -94,6 +98,8 @@ var zhTW = {
|
|
|
94
98
|
nothingToExport: "沒有可匯出的資料",
|
|
95
99
|
duplicate: "複製一份",
|
|
96
100
|
remove: "刪除",
|
|
101
|
+
comment: "評論",
|
|
102
|
+
comments: "{count} 則評論",
|
|
97
103
|
settingsTitle: "{title}的設定",
|
|
98
104
|
titleField: "標題",
|
|
99
105
|
added: "已新增 {item}",
|
|
@@ -101,6 +107,8 @@ var zhTW = {
|
|
|
101
107
|
unknownType: "沒有註冊類型為 {type} 的格子",
|
|
102
108
|
loading: "載入中",
|
|
103
109
|
error: "載入失敗",
|
|
110
|
+
renderError: "無法顯示",
|
|
111
|
+
settingsError: "無法顯示設定",
|
|
104
112
|
empty: "暫無資料",
|
|
105
113
|
retry: "重試",
|
|
106
114
|
emptyTitle: "還沒有格子",
|
|
@@ -166,6 +174,8 @@ var en = {
|
|
|
166
174
|
nothingToExport: "There is no data to export",
|
|
167
175
|
duplicate: "Duplicate",
|
|
168
176
|
remove: "Remove",
|
|
177
|
+
comment: "Comment",
|
|
178
|
+
comments: "{count} comments",
|
|
169
179
|
settingsTitle: "{title} settings",
|
|
170
180
|
titleField: "Title",
|
|
171
181
|
added: "Added {item}",
|
|
@@ -173,6 +183,8 @@ var en = {
|
|
|
173
183
|
unknownType: "No widget type “{type}” is registered",
|
|
174
184
|
loading: "Loading",
|
|
175
185
|
error: "Couldn’t load",
|
|
186
|
+
renderError: "Couldn’t display",
|
|
187
|
+
settingsError: "Couldn’t display the settings",
|
|
176
188
|
empty: "No data",
|
|
177
189
|
retry: "Retry",
|
|
178
190
|
emptyTitle: "No widgets yet",
|
package/dist/locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","names":[],"sources":["../src/locale.ts"],"sourcesContent":["import { useLocale } from 'dou-ui'\nimport { computed, toValue, type MaybeRefOrGetter } from 'vue'\n\nexport interface DashboardMessages {\n /** The grid layout's accessible name. */\n layout: string\n /** What an item of the grid is called by a screen reader. */\n item: string\n /** Read after an item's name while the layout can be edited. */\n itemHint: string\n /** An item that can't be moved: `{item}`. */\n locked: string\n /** An item's place: `{x}` `{y}` (from 1), `{w}` `{h}` (in columns and rows). */\n position: string\n /** An item's place when the grid has one column: `{n}` of `{count}` (from 1). */\n order: string\n /** An item picked up with the keyboard: `{item}` and `{position}`. */\n grabbed: string\n /** An item put down, with the keyboard or the pointer: `{item}` and `{position}`. */\n dropped: string\n /** A move or resize undone with Escape (or a drop outside the grid): `{item}`. */\n cancelled: string\n /** The handle in an item's corner. */\n resize: string\n /** The dashboard's accessible name. */\n dashboard: string\n /** The menu button in a widget's title bar. */\n widgetMenu: string\n /** Menu items. */\n settings: string\n fullscreen: string\n /** The menu of file types a widget's content can be exported as. */\n export: string\n /** A failed export, over the widget's content: `{name}` (the file), `{reason}`. */\n exportFailed: string\n /** Read out once the file is saved: `{name}`. */\n exported: string\n /** Why a widget can't be exported: it has no data, such as a chart without its fields. */\n nothingToExport: string\n duplicate: string\n remove: string\n /** The settings drawer's title: `{title}`. */\n settingsTitle: string\n /** The title field in the settings drawer. */\n titleField: string\n /** Read when a widget is added, copied or removed: `{item}`. */\n added: string\n removed: string\n /** A widget whose type isn't registered: `{type}`. */\n unknownType: string\n /** A widget's status. */\n loading: string\n error: string\n empty: string\n retry: string\n /** A dashboard without widgets, while editing. */\n emptyTitle: string\n emptyHint: string\n /** The list of widgets to add. */\n palette: string\n /** A widget in that list: `{label}`. */\n paletteItem: string\n /** In the title bar of a widget that set a filter: `{value}`. */\n filteredBy: string\n peerMoving: string\n peerResizing: string\n peerSettings: string\n /** The button clearing that filter: `{value}`. */\n clearFilter: string\n /** The filter bar's accessible name. */\n filterBar: string\n /** A filter set by a widget, in the filter bar: `{title}` and `{value}`. */\n linkedFilter: string\n /** Clears every filter. */\n clearFilters: string\n /** Settings of the built-in widgets. */\n source: string\n noSource: string\n field: string\n value: string\n prefix: string\n suffix: string\n precision: string\n trend: string\n delta: string\n /** The change under a number: `{value}`, e.g. `+12.5%`. */\n deltaText: string\n text: string\n textSize: string\n sizeSmall: string\n sizeMedium: string\n sizeLarge: string\n columns: string\n /** The title of a table column, while it has none: `{field}`. */\n columnTitle: string\n chartKind: string\n chartLine: string\n chartArea: string\n chartBar: string\n chartPie: string\n xField: string\n yFields: string\n stacked: string\n horizontal: string\n /** The filter set by clicking a chart. */\n chartFilter: string\n chartFilterHint: string\n /** Whether clicking a pivot table's cell filters the other widgets. */\n pivotFilter: string\n}\n\nconst zhCN: DashboardMessages = {\n layout: '网格布局',\n item: '格子',\n itemHint: '按 Enter 拿起,再用方向键移动、Shift 加方向键调整大小',\n locked: '{item} 已锁定,不能移动',\n position: '第 {x} 列第 {y} 行,宽 {w} 列,高 {h} 行',\n order: '第 {n} 个,共 {count} 个',\n grabbed: '已拿起 {item},{position}。方向键移动,Shift 加方向键调整大小,Enter 放下,Esc 取消',\n dropped: '已放下 {item},{position}',\n cancelled: '已取消,{item} 回到原处',\n resize: '调整大小',\n dashboard: '仪表盘',\n widgetMenu: '格子操作',\n settings: '设置',\n fullscreen: '全屏查看',\n export: '导出',\n exportFailed: '无法导出 {name}:{reason}',\n exported: '已导出 {name}',\n nothingToExport: '没有可导出的数据',\n duplicate: '复制一份',\n remove: '删除',\n settingsTitle: '{title}的设置',\n titleField: '标题',\n added: '已添加 {item}',\n removed: '已删除 {item}',\n unknownType: '没有注册类型为 {type} 的格子',\n loading: '加载中',\n error: '加载失败',\n empty: '暂无数据',\n retry: '重试',\n emptyTitle: '还没有格子',\n emptyHint: '从列表里拖进来,或点一下添加',\n palette: '添加格子',\n paletteItem: '添加{label}',\n filteredBy: '已按 {value} 筛选',\n peerMoving: '{name} 正在移动',\n peerResizing: '{name} 正在调整大小',\n peerSettings: '{name} 正在修改设置',\n clearFilter: '清除筛选:{value}',\n filterBar: '筛选',\n linkedFilter: '{title}:{value}',\n clearFilters: '清除筛选',\n source: '数据源',\n noSource: '不使用数据源',\n field: '字段',\n value: '数值',\n prefix: '前缀',\n suffix: '后缀',\n precision: '小数位数',\n trend: '迷你图字段',\n delta: '变化率字段',\n deltaText: '较上期 {value}',\n text: '文字',\n textSize: '字号',\n sizeSmall: '小',\n sizeMedium: '中',\n sizeLarge: '大',\n columns: '列',\n columnTitle: '{field} 的标题',\n chartKind: '图表',\n chartLine: '折线图',\n chartArea: '面积图',\n chartBar: '柱状图',\n chartPie: '饼图',\n xField: '分类或时间',\n yFields: '数值',\n stacked: '堆叠',\n horizontal: '横向',\n chartFilter: '点击时筛选',\n chartFilterHint: '点图表里的一项时,用这个名字筛选其他格子;留空则不筛选',\n pivotFilter: '点击单元格时,按它所在的分组筛选其他格子',\n}\n\nconst zhTW: DashboardMessages = {\n layout: '網格版面',\n item: '格子',\n itemHint: '按 Enter 拿起,再用方向鍵移動、Shift 加方向鍵調整大小',\n locked: '{item} 已鎖定,無法移動',\n position: '第 {x} 欄第 {y} 列,寬 {w} 欄,高 {h} 列',\n order: '第 {n} 個,共 {count} 個',\n grabbed: '已拿起 {item},{position}。方向鍵移動,Shift 加方向鍵調整大小,Enter 放下,Esc 取消',\n dropped: '已放下 {item},{position}',\n cancelled: '已取消,{item} 回到原處',\n resize: '調整大小',\n dashboard: '儀表板',\n widgetMenu: '格子操作',\n settings: '設定',\n fullscreen: '全螢幕檢視',\n export: '匯出',\n exportFailed: '無法匯出 {name}:{reason}',\n exported: '已匯出 {name}',\n nothingToExport: '沒有可匯出的資料',\n duplicate: '複製一份',\n remove: '刪除',\n settingsTitle: '{title}的設定',\n titleField: '標題',\n added: '已新增 {item}',\n removed: '已刪除 {item}',\n unknownType: '沒有註冊類型為 {type} 的格子',\n loading: '載入中',\n error: '載入失敗',\n empty: '暫無資料',\n retry: '重試',\n emptyTitle: '還沒有格子',\n emptyHint: '從清單拖進來,或點一下新增',\n palette: '新增格子',\n paletteItem: '新增{label}',\n filteredBy: '已按 {value} 篩選',\n peerMoving: '{name} 正在移動',\n peerResizing: '{name} 正在調整大小',\n peerSettings: '{name} 正在修改設定',\n clearFilter: '清除篩選:{value}',\n filterBar: '篩選',\n linkedFilter: '{title}:{value}',\n clearFilters: '清除篩選',\n source: '資料來源',\n noSource: '不使用資料來源',\n field: '欄位',\n value: '數值',\n prefix: '前綴',\n suffix: '後綴',\n precision: '小數位數',\n trend: '迷你圖欄位',\n delta: '變化率欄位',\n deltaText: '較上期 {value}',\n text: '文字',\n textSize: '字號',\n sizeSmall: '小',\n sizeMedium: '中',\n sizeLarge: '大',\n columns: '欄',\n columnTitle: '{field} 的標題',\n chartKind: '圖表',\n chartLine: '折線圖',\n chartArea: '面積圖',\n chartBar: '長條圖',\n chartPie: '圓餅圖',\n xField: '分類或時間',\n yFields: '數值',\n stacked: '堆疊',\n horizontal: '橫向',\n chartFilter: '點擊時篩選',\n chartFilterHint: '點圖表裡的一項時,用這個名字篩選其他格子;留空則不篩選',\n pivotFilter: '點擊儲存格時,依其所在的分組篩選其他格子',\n}\n\nconst en: DashboardMessages = {\n layout: 'Grid layout',\n item: 'tile',\n itemHint: 'Press Enter to pick up, then arrow keys to move and Shift with arrow keys to resize',\n locked: '{item} is locked and can’t be moved',\n position: 'column {x}, row {y}, {w} columns wide, {h} rows high',\n order: '{n} of {count}',\n grabbed:\n 'Picked up {item}, {position}. Arrow keys move, Shift with arrow keys resizes, Enter puts down, Escape cancels',\n dropped: 'Put down {item}, {position}',\n cancelled: 'Cancelled, {item} is back where it was',\n resize: 'Resize',\n dashboard: 'Dashboard',\n widgetMenu: 'Widget actions',\n settings: 'Settings',\n fullscreen: 'View full screen',\n export: 'Export',\n exportFailed: \"Couldn't export {name}: {reason}\",\n exported: 'Exported {name}',\n nothingToExport: 'There is no data to export',\n duplicate: 'Duplicate',\n remove: 'Remove',\n settingsTitle: '{title} settings',\n titleField: 'Title',\n added: 'Added {item}',\n removed: 'Removed {item}',\n unknownType: 'No widget type “{type}” is registered',\n loading: 'Loading',\n error: 'Couldn’t load',\n empty: 'No data',\n retry: 'Retry',\n emptyTitle: 'No widgets yet',\n emptyHint: 'Drag one in from the list, or click to add it',\n palette: 'Add widget',\n paletteItem: 'Add {label}',\n filteredBy: 'Filtered by {value}',\n peerMoving: '{name} is moving it',\n peerResizing: '{name} is resizing it',\n peerSettings: '{name} is changing its settings',\n clearFilter: 'Clear filter: {value}',\n filterBar: 'Filters',\n linkedFilter: '{title}: {value}',\n clearFilters: 'Clear filters',\n source: 'Source',\n noSource: 'No source',\n field: 'Field',\n value: 'Value',\n prefix: 'Prefix',\n suffix: 'Suffix',\n precision: 'Decimal places',\n trend: 'Sparkline field',\n delta: 'Change field',\n deltaText: '{value} vs. last period',\n text: 'Text',\n textSize: 'Size',\n sizeSmall: 'Small',\n sizeMedium: 'Medium',\n sizeLarge: 'Large',\n columns: 'Columns',\n columnTitle: 'Title of {field}',\n chartKind: 'Chart',\n chartLine: 'Line',\n chartArea: 'Area',\n chartBar: 'Bar',\n chartPie: 'Pie',\n xField: 'Category or time',\n yFields: 'Values',\n stacked: 'Stacked',\n horizontal: 'Horizontal',\n chartFilter: 'Filter on click',\n chartFilterHint:\n 'Clicking an item filters the other widgets by this name; leave empty to not filter',\n pivotFilter: 'Clicking a cell filters the other widgets by its groups',\n}\n\nexport const dashboardLocales: Record<string, DashboardMessages> = {\n 'zh-CN': zhCN,\n 'zh-TW': zhTW,\n en,\n}\n\nexport type DashboardMessagesOverride = Partial<DashboardMessages>\n\n/**\n * The dashboard's texts, picked by the name of DouUI's current locale.\n * Pass `messages` to override any of them.\n */\nexport function useDashboardMessages(\n override?: MaybeRefOrGetter<DashboardMessagesOverride | undefined>,\n) {\n const { locale } = useLocale()\n return computed<DashboardMessages>(() => {\n const name = locale.value.name\n const base =\n dashboardLocales[name] ??\n dashboardLocales[name.split('-')[0]!] ??\n (name.startsWith('zh') ? zhCN : en)\n const extra = toValue(override)\n return extra ? { ...base, ...extra } : base\n })\n}\n\n/** Fills `{name}` placeholders. */\nexport const format = (text: string, params: Record<string, string | number>) =>\n text.replace(/\\{(\\w+)\\}/g, (match, key: string) => String(params[key] ?? match))\n"],"mappings":";;;AA+GA,IAAM,OAA0B;CAC9B,QAAQ;CACR,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;CACV,OAAO;CACP,SAAS;CACT,SAAS;CACT,WAAW;CACX,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,QAAQ;CACR,cAAc;CACd,UAAU;CACV,iBAAiB;CACjB,WAAW;CACX,QAAQ;CACR,eAAe;CACf,YAAY;CACZ,OAAO;CACP,SAAS;CACT,aAAa;CACb,SAAS;CACT,OAAO;CACP,OAAO;CACP,OAAO;CACP,YAAY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AAU,MAAc,WACnC,KAAK,QAAQ,eAAe,OAAO,QAAgB,OAAO,OAAO,QAAQ,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"locale.js","names":[],"sources":["../src/locale.ts"],"sourcesContent":["import { useLocale } from 'dou-ui'\nimport { computed, toValue, type MaybeRefOrGetter } from 'vue'\n\nexport interface DashboardMessages {\n /** The grid layout's accessible name. */\n layout: string\n /** What an item of the grid is called by a screen reader. */\n item: string\n /** Read after an item's name while the layout can be edited. */\n itemHint: string\n /** An item that can't be moved: `{item}`. */\n locked: string\n /** An item's place: `{x}` `{y}` (from 1), `{w}` `{h}` (in columns and rows). */\n position: string\n /** An item's place when the grid has one column: `{n}` of `{count}` (from 1). */\n order: string\n /** An item picked up with the keyboard: `{item}` and `{position}`. */\n grabbed: string\n /** An item put down, with the keyboard or the pointer: `{item}` and `{position}`. */\n dropped: string\n /** A move or resize undone with Escape (or a drop outside the grid): `{item}`. */\n cancelled: string\n /** The handle in an item's corner. */\n resize: string\n /** The dashboard's accessible name. */\n dashboard: string\n /** The menu button in a widget's title bar. */\n widgetMenu: string\n /** Menu items. */\n settings: string\n fullscreen: string\n /** The menu of file types a widget's content can be exported as. */\n export: string\n /** A failed export, over the widget's content: `{name}` (the file), `{reason}`. */\n exportFailed: string\n /** Read out once the file is saved: `{name}`. */\n exported: string\n /** Why a widget can't be exported: it has no data, such as a chart without its fields. */\n nothingToExport: string\n duplicate: string\n remove: string\n /** The comment button and the card of a widget's discussions. */\n comment: string\n /** The comment button of a widget with discussions; `{count}` is how many are open. */\n comments: string\n /** The settings drawer's title: `{title}`. */\n settingsTitle: string\n /** The title field in the settings drawer. */\n titleField: string\n /** Read when a widget is added, copied or removed: `{item}`. */\n added: string\n removed: string\n /** A widget whose type isn't registered: `{type}`. */\n unknownType: string\n /** A widget's status. */\n loading: string\n error: string\n /** A widget that failed to show, e.g. for props it can't use. */\n renderError: string\n /** A widget's settings form that failed to show. */\n settingsError: string\n empty: string\n retry: string\n /** A dashboard without widgets, while editing. */\n emptyTitle: string\n emptyHint: string\n /** The list of widgets to add. */\n palette: string\n /** A widget in that list: `{label}`. */\n paletteItem: string\n /** In the title bar of a widget that set a filter: `{value}`. */\n filteredBy: string\n peerMoving: string\n peerResizing: string\n peerSettings: string\n /** The button clearing that filter: `{value}`. */\n clearFilter: string\n /** The filter bar's accessible name. */\n filterBar: string\n /** A filter set by a widget, in the filter bar: `{title}` and `{value}`. */\n linkedFilter: string\n /** Clears every filter. */\n clearFilters: string\n /** Settings of the built-in widgets. */\n source: string\n noSource: string\n field: string\n value: string\n prefix: string\n suffix: string\n precision: string\n trend: string\n delta: string\n /** The change under a number: `{value}`, e.g. `+12.5%`. */\n deltaText: string\n text: string\n textSize: string\n sizeSmall: string\n sizeMedium: string\n sizeLarge: string\n columns: string\n /** The title of a table column, while it has none: `{field}`. */\n columnTitle: string\n chartKind: string\n chartLine: string\n chartArea: string\n chartBar: string\n chartPie: string\n xField: string\n yFields: string\n stacked: string\n horizontal: string\n /** The filter set by clicking a chart. */\n chartFilter: string\n chartFilterHint: string\n /** Whether clicking a pivot table's cell filters the other widgets. */\n pivotFilter: string\n}\n\nconst zhCN: DashboardMessages = {\n layout: '网格布局',\n item: '格子',\n itemHint: '按 Enter 拿起,再用方向键移动、Shift 加方向键调整大小',\n locked: '{item} 已锁定,不能移动',\n position: '第 {x} 列第 {y} 行,宽 {w} 列,高 {h} 行',\n order: '第 {n} 个,共 {count} 个',\n grabbed: '已拿起 {item},{position}。方向键移动,Shift 加方向键调整大小,Enter 放下,Esc 取消',\n dropped: '已放下 {item},{position}',\n cancelled: '已取消,{item} 回到原处',\n resize: '调整大小',\n dashboard: '仪表盘',\n widgetMenu: '格子操作',\n settings: '设置',\n fullscreen: '全屏查看',\n export: '导出',\n exportFailed: '无法导出 {name}:{reason}',\n exported: '已导出 {name}',\n nothingToExport: '没有可导出的数据',\n duplicate: '复制一份',\n remove: '删除',\n comment: '评论',\n comments: '{count} 条评论',\n settingsTitle: '{title}的设置',\n titleField: '标题',\n added: '已添加 {item}',\n removed: '已删除 {item}',\n unknownType: '没有注册类型为 {type} 的格子',\n loading: '加载中',\n error: '加载失败',\n renderError: '无法显示',\n settingsError: '无法显示设置',\n empty: '暂无数据',\n retry: '重试',\n emptyTitle: '还没有格子',\n emptyHint: '从列表里拖进来,或点一下添加',\n palette: '添加格子',\n paletteItem: '添加{label}',\n filteredBy: '已按 {value} 筛选',\n peerMoving: '{name} 正在移动',\n peerResizing: '{name} 正在调整大小',\n peerSettings: '{name} 正在修改设置',\n clearFilter: '清除筛选:{value}',\n filterBar: '筛选',\n linkedFilter: '{title}:{value}',\n clearFilters: '清除筛选',\n source: '数据源',\n noSource: '不使用数据源',\n field: '字段',\n value: '数值',\n prefix: '前缀',\n suffix: '后缀',\n precision: '小数位数',\n trend: '迷你图字段',\n delta: '变化率字段',\n deltaText: '较上期 {value}',\n text: '文字',\n textSize: '字号',\n sizeSmall: '小',\n sizeMedium: '中',\n sizeLarge: '大',\n columns: '列',\n columnTitle: '{field} 的标题',\n chartKind: '图表',\n chartLine: '折线图',\n chartArea: '面积图',\n chartBar: '柱状图',\n chartPie: '饼图',\n xField: '分类或时间',\n yFields: '数值',\n stacked: '堆叠',\n horizontal: '横向',\n chartFilter: '点击时筛选',\n chartFilterHint: '点图表里的一项时,用这个名字筛选其他格子;留空则不筛选',\n pivotFilter: '点击单元格时,按它所在的分组筛选其他格子',\n}\n\nconst zhTW: DashboardMessages = {\n layout: '網格版面',\n item: '格子',\n itemHint: '按 Enter 拿起,再用方向鍵移動、Shift 加方向鍵調整大小',\n locked: '{item} 已鎖定,無法移動',\n position: '第 {x} 欄第 {y} 列,寬 {w} 欄,高 {h} 列',\n order: '第 {n} 個,共 {count} 個',\n grabbed: '已拿起 {item},{position}。方向鍵移動,Shift 加方向鍵調整大小,Enter 放下,Esc 取消',\n dropped: '已放下 {item},{position}',\n cancelled: '已取消,{item} 回到原處',\n resize: '調整大小',\n dashboard: '儀表板',\n widgetMenu: '格子操作',\n settings: '設定',\n fullscreen: '全螢幕檢視',\n export: '匯出',\n exportFailed: '無法匯出 {name}:{reason}',\n exported: '已匯出 {name}',\n nothingToExport: '沒有可匯出的資料',\n duplicate: '複製一份',\n remove: '刪除',\n comment: '評論',\n comments: '{count} 則評論',\n settingsTitle: '{title}的設定',\n titleField: '標題',\n added: '已新增 {item}',\n removed: '已刪除 {item}',\n unknownType: '沒有註冊類型為 {type} 的格子',\n loading: '載入中',\n error: '載入失敗',\n renderError: '無法顯示',\n settingsError: '無法顯示設定',\n empty: '暫無資料',\n retry: '重試',\n emptyTitle: '還沒有格子',\n emptyHint: '從清單拖進來,或點一下新增',\n palette: '新增格子',\n paletteItem: '新增{label}',\n filteredBy: '已按 {value} 篩選',\n peerMoving: '{name} 正在移動',\n peerResizing: '{name} 正在調整大小',\n peerSettings: '{name} 正在修改設定',\n clearFilter: '清除篩選:{value}',\n filterBar: '篩選',\n linkedFilter: '{title}:{value}',\n clearFilters: '清除篩選',\n source: '資料來源',\n noSource: '不使用資料來源',\n field: '欄位',\n value: '數值',\n prefix: '前綴',\n suffix: '後綴',\n precision: '小數位數',\n trend: '迷你圖欄位',\n delta: '變化率欄位',\n deltaText: '較上期 {value}',\n text: '文字',\n textSize: '字號',\n sizeSmall: '小',\n sizeMedium: '中',\n sizeLarge: '大',\n columns: '欄',\n columnTitle: '{field} 的標題',\n chartKind: '圖表',\n chartLine: '折線圖',\n chartArea: '面積圖',\n chartBar: '長條圖',\n chartPie: '圓餅圖',\n xField: '分類或時間',\n yFields: '數值',\n stacked: '堆疊',\n horizontal: '橫向',\n chartFilter: '點擊時篩選',\n chartFilterHint: '點圖表裡的一項時,用這個名字篩選其他格子;留空則不篩選',\n pivotFilter: '點擊儲存格時,依其所在的分組篩選其他格子',\n}\n\nconst en: DashboardMessages = {\n layout: 'Grid layout',\n item: 'tile',\n itemHint: 'Press Enter to pick up, then arrow keys to move and Shift with arrow keys to resize',\n locked: '{item} is locked and can’t be moved',\n position: 'column {x}, row {y}, {w} columns wide, {h} rows high',\n order: '{n} of {count}',\n grabbed:\n 'Picked up {item}, {position}. Arrow keys move, Shift with arrow keys resizes, Enter puts down, Escape cancels',\n dropped: 'Put down {item}, {position}',\n cancelled: 'Cancelled, {item} is back where it was',\n resize: 'Resize',\n dashboard: 'Dashboard',\n widgetMenu: 'Widget actions',\n settings: 'Settings',\n fullscreen: 'View full screen',\n export: 'Export',\n exportFailed: \"Couldn't export {name}: {reason}\",\n exported: 'Exported {name}',\n nothingToExport: 'There is no data to export',\n duplicate: 'Duplicate',\n remove: 'Remove',\n comment: 'Comment',\n comments: '{count} comments',\n settingsTitle: '{title} settings',\n titleField: 'Title',\n added: 'Added {item}',\n removed: 'Removed {item}',\n unknownType: 'No widget type “{type}” is registered',\n loading: 'Loading',\n error: 'Couldn’t load',\n renderError: 'Couldn’t display',\n settingsError: 'Couldn’t display the settings',\n empty: 'No data',\n retry: 'Retry',\n emptyTitle: 'No widgets yet',\n emptyHint: 'Drag one in from the list, or click to add it',\n palette: 'Add widget',\n paletteItem: 'Add {label}',\n filteredBy: 'Filtered by {value}',\n peerMoving: '{name} is moving it',\n peerResizing: '{name} is resizing it',\n peerSettings: '{name} is changing its settings',\n clearFilter: 'Clear filter: {value}',\n filterBar: 'Filters',\n linkedFilter: '{title}: {value}',\n clearFilters: 'Clear filters',\n source: 'Source',\n noSource: 'No source',\n field: 'Field',\n value: 'Value',\n prefix: 'Prefix',\n suffix: 'Suffix',\n precision: 'Decimal places',\n trend: 'Sparkline field',\n delta: 'Change field',\n deltaText: '{value} vs. last period',\n text: 'Text',\n textSize: 'Size',\n sizeSmall: 'Small',\n sizeMedium: 'Medium',\n sizeLarge: 'Large',\n columns: 'Columns',\n columnTitle: 'Title of {field}',\n chartKind: 'Chart',\n chartLine: 'Line',\n chartArea: 'Area',\n chartBar: 'Bar',\n chartPie: 'Pie',\n xField: 'Category or time',\n yFields: 'Values',\n stacked: 'Stacked',\n horizontal: 'Horizontal',\n chartFilter: 'Filter on click',\n chartFilterHint:\n 'Clicking an item filters the other widgets by this name; leave empty to not filter',\n pivotFilter: 'Clicking a cell filters the other widgets by its groups',\n}\n\nexport const dashboardLocales: Record<string, DashboardMessages> = {\n 'zh-CN': zhCN,\n 'zh-TW': zhTW,\n en,\n}\n\nexport type DashboardMessagesOverride = Partial<DashboardMessages>\n\n/**\n * The dashboard's texts, picked by the name of DouUI's current locale.\n * Pass `messages` to override any of them.\n */\nexport function useDashboardMessages(\n override?: MaybeRefOrGetter<DashboardMessagesOverride | undefined>,\n) {\n const { locale } = useLocale()\n return computed<DashboardMessages>(() => {\n const name = locale.value.name\n const base =\n dashboardLocales[name] ??\n dashboardLocales[name.split('-')[0]!] ??\n (name.startsWith('zh') ? zhCN : en)\n const extra = toValue(override)\n return extra ? { ...base, ...extra } : base\n })\n}\n\n/** Fills `{name}` placeholders. */\nexport const format = (text: string, params: Record<string, string | number>) =>\n text.replace(/\\{(\\w+)\\}/g, (match, key: string) => String(params[key] ?? match))\n"],"mappings":";;;AAuHA,IAAM,OAA0B;CAC9B,QAAQ;CACR,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;CACV,OAAO;CACP,SAAS;CACT,SAAS;CACT,WAAW;CACX,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,QAAQ;CACR,cAAc;CACd,UAAU;CACV,iBAAiB;CACjB,WAAW;CACX,QAAQ;CACR,SAAS;CACT,UAAU;CACV,eAAe;CACf,YAAY;CACZ,OAAO;CACP,SAAS;CACT,aAAa;CACb,SAAS;CACT,OAAO;CACP,aAAa;CACb,eAAe;CACf,OAAO;CACP,OAAO;CACP,YAAY;CACZ,WAAW;CACX,SAAS;CACT,aAAa;CACb,YAAY;CACZ,YAAY;CACZ,cAAc;CACd,cAAc;CACd,aAAa;CACb,WAAW;CACX,cAAc;CACd,cAAc;CACd,QAAQ;CACR,UAAU;CACV,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,W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|
-
{"version":3,"file":"pivot-settings.js","names":["_sfc_main"],"sources":["../../src/pivot/pivot-settings.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouPivotFields } from '@dou-ui/pivot'\nimport type { PivotField } from '@dou-ui/pivot'\nimport { DouSwitch } from 'dou-ui'\nimport { computed } from 'vue'\nimport { useDashboardMessages } from '../locale'\nimport { useDashboardWidget } from '../widget/context'\nimport SettingsField from '../widgets/settings-field.vue'\nimport { rowsOf } from '../widgets/shared'\nimport SourceField from '../widgets/source-field.vue'\nimport type { PivotWidgetProps } from './types'\n\ndefineOptions({ name: 'DouDashboardPivotSettings' })\n\ndefineProps<{ fields?: readonly PivotField[] }>()\nconst model = defineModel<PivotWidgetProps>({ required: true })\nconst messages = useDashboardMessages()\nconst { data } = useDashboardWidget()\nconst rows = computed(() => rowsOf(data.value,
|
|
1
|
+
{"version":3,"file":"pivot-settings.js","names":["_sfc_main"],"sources":["../../src/pivot/pivot-settings.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouPivotFields } from '@dou-ui/pivot'\nimport type { PivotField } from '@dou-ui/pivot'\nimport { DouSwitch } from 'dou-ui'\nimport { computed } from 'vue'\nimport { useDashboardMessages } from '../locale'\nimport { useDashboardWidget } from '../widget/context'\nimport SettingsField from '../widgets/settings-field.vue'\nimport { rowsOf } from '../widgets/shared'\nimport SourceField from '../widgets/source-field.vue'\nimport type { PivotWidgetProps } from './types'\nimport { pivotPropsOf } from './read-props'\n\ndefineOptions({ name: 'DouDashboardPivotSettings' })\n\ndefineProps<{ fields?: readonly PivotField[] }>()\nconst model = defineModel<PivotWidgetProps>({ required: true })\n// the props as saved may have the wrong types: read them as the widget does\nconst view = computed(() => pivotPropsOf(model.value as Record<string, unknown>))\nconst messages = useDashboardMessages()\nconst { data } = useDashboardWidget()\nconst rows = computed(() => rowsOf(data.value, view.value.path))\nconst set = (patch: Partial<PivotWidgetProps>) => (model.value = { ...model.value, ...patch })\n</script>\n\n<template>\n <div class=\"dou-dashboard__settings\">\n <SourceField :model-value=\"view.source\" @update:model-value=\"(source) => set({ source })\" />\n <SettingsField v-if=\"rows.length\" :label=\"messages.field\">\n <DouPivotFields\n :data=\"rows\"\n :fields=\"fields\"\n :config=\"view.config\"\n :drawer=\"false\"\n @update:config=\"(config) => set({ config })\"\n />\n </SettingsField>\n <DouSwitch\n :model-value=\"!!view.filter\"\n @update:model-value=\"(filter) => set({ filter: filter || undefined })\"\n >\n {{ messages.pivotFilter }}\n </DouSwitch>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -3,6 +3,7 @@ import { useDashboardWidget } from "../widget/context.js";
|
|
|
3
3
|
import { rowsOf } from "../widgets/shared.js";
|
|
4
4
|
import settings_field_default from "../widgets/settings-field.js";
|
|
5
5
|
import source_field_default from "../widgets/source-field.js";
|
|
6
|
+
import { pivotPropsOf } from "./read-props.js";
|
|
6
7
|
import { DouSwitch } from "dou-ui";
|
|
7
8
|
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, mergeModels, openBlock, toDisplayString, unref, useModel, withCtx } from "vue";
|
|
8
9
|
import { DouPivotFields } from "@dou-ui/pivot";
|
|
@@ -18,9 +19,10 @@ var pivot_settings_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
18
19
|
emits: ["update:modelValue"],
|
|
19
20
|
setup(__props) {
|
|
20
21
|
const model = useModel(__props, "modelValue");
|
|
22
|
+
const view = computed(() => pivotPropsOf(model.value));
|
|
21
23
|
const messages = useDashboardMessages();
|
|
22
24
|
const { data } = useDashboardWidget();
|
|
23
|
-
const rows = computed(() => rowsOf(data.value,
|
|
25
|
+
const rows = computed(() => rowsOf(data.value, view.value.path));
|
|
24
26
|
const set = (patch) => model.value = {
|
|
25
27
|
...model.value,
|
|
26
28
|
...patch
|
|
@@ -28,7 +30,7 @@ var pivot_settings_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
28
30
|
return (_ctx, _cache) => {
|
|
29
31
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
30
32
|
createVNode(source_field_default, {
|
|
31
|
-
"model-value":
|
|
33
|
+
"model-value": view.value.source,
|
|
32
34
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = (source) => set({ source }))
|
|
33
35
|
}, null, 8, ["model-value"]),
|
|
34
36
|
rows.value.length ? (openBlock(), createBlock(settings_field_default, {
|
|
@@ -38,7 +40,7 @@ var pivot_settings_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
38
40
|
default: withCtx(() => [createVNode(unref(DouPivotFields), {
|
|
39
41
|
data: rows.value,
|
|
40
42
|
fields: __props.fields,
|
|
41
|
-
config:
|
|
43
|
+
config: view.value.config,
|
|
42
44
|
drawer: false,
|
|
43
45
|
"onUpdate:config": _cache[1] || (_cache[1] = (config) => set({ config }))
|
|
44
46
|
}, null, 8, [
|
|
@@ -49,7 +51,7 @@ var pivot_settings_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
49
51
|
_: 1
|
|
50
52
|
}, 8, ["label"])) : createCommentVNode("", true),
|
|
51
53
|
createVNode(unref(DouSwitch), {
|
|
52
|
-
"model-value": !!
|
|
54
|
+
"model-value": !!view.value.filter,
|
|
53
55
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = (filter) => set({ filter: filter || void 0 }))
|
|
54
56
|
}, {
|
|
55
57
|
default: withCtx(() => [createTextVNode(toDisplayString(unref(messages).pivotFilter), 1)]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pivot-settings.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_createVNode","SourceField","_createBlock","SettingsField","_unref","_withCtx","_createCommentVNode","_createTextVNode","_toDisplayString"],"sources":["../../src/pivot/pivot-settings.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouPivotFields } from '@dou-ui/pivot'\nimport type { PivotField } from '@dou-ui/pivot'\nimport { DouSwitch } from 'dou-ui'\nimport { computed } from 'vue'\nimport { useDashboardMessages } from '../locale'\nimport { useDashboardWidget } from '../widget/context'\nimport SettingsField from '../widgets/settings-field.vue'\nimport { rowsOf } from '../widgets/shared'\nimport SourceField from '../widgets/source-field.vue'\nimport type { PivotWidgetProps } from './types'\n\ndefineOptions({ name: 'DouDashboardPivotSettings' })\n\ndefineProps<{ fields?: readonly PivotField[] }>()\nconst model = defineModel<PivotWidgetProps>({ required: true })\nconst messages = useDashboardMessages()\nconst { data } = useDashboardWidget()\nconst rows = computed(() => rowsOf(data.value,
|
|
1
|
+
{"version":3,"file":"pivot-settings.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_createVNode","SourceField","_createBlock","SettingsField","_unref","_withCtx","_createCommentVNode","_createTextVNode","_toDisplayString"],"sources":["../../src/pivot/pivot-settings.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouPivotFields } from '@dou-ui/pivot'\nimport type { PivotField } from '@dou-ui/pivot'\nimport { DouSwitch } from 'dou-ui'\nimport { computed } from 'vue'\nimport { useDashboardMessages } from '../locale'\nimport { useDashboardWidget } from '../widget/context'\nimport SettingsField from '../widgets/settings-field.vue'\nimport { rowsOf } from '../widgets/shared'\nimport SourceField from '../widgets/source-field.vue'\nimport type { PivotWidgetProps } from './types'\nimport { pivotPropsOf } from './read-props'\n\ndefineOptions({ name: 'DouDashboardPivotSettings' })\n\ndefineProps<{ fields?: readonly PivotField[] }>()\nconst model = defineModel<PivotWidgetProps>({ required: true })\n// the props as saved may have the wrong types: read them as the widget does\nconst view = computed(() => pivotPropsOf(model.value as Record<string, unknown>))\nconst messages = useDashboardMessages()\nconst { data } = useDashboardWidget()\nconst rows = computed(() => rowsOf(data.value, view.value.path))\nconst set = (patch: Partial<PivotWidgetProps>) => (model.value = { ...model.value, ...patch })\n</script>\n\n<template>\n <div class=\"dou-dashboard__settings\">\n <SourceField :model-value=\"view.source\" @update:model-value=\"(source) => set({ source })\" />\n <SettingsField v-if=\"rows.length\" :label=\"messages.field\">\n <DouPivotFields\n :data=\"rows\"\n :fields=\"fields\"\n :config=\"view.config\"\n :drawer=\"false\"\n @update:config=\"(config) => set({ config })\"\n />\n </SettingsField>\n <DouSwitch\n :model-value=\"!!view.filter\"\n @update:model-value=\"(filter) => set({ filter: filter || undefined })\"\n >\n {{ messages.pivotFilter }}\n </DouSwitch>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAgBA,MAAM,QAAQA,SAA6B,SAAA,YAAmB;EAE9D,MAAM,OAAO,eAAe,aAAa,MAAM,KAAgC,CAAC;EAChF,MAAM,WAAW,qBAAqB;EACtC,MAAM,EAAE,SAAS,mBAAmB;EACpC,MAAM,OAAO,eAAe,OAAO,KAAK,OAAO,KAAK,MAAM,IAAI,CAAC;EAC/D,MAAM,OAAO,UAAsC,MAAM,QAAQ;GAAE,GAAG,MAAM;GAAO,GAAG;EAAM;;GAI1F,OAAAC,UAAA,GAAAC,mBAiBM,OAjBN,YAiBM;IAhBJC,YAA4FC,sBAAA;KAA9E,eAAa,KAAA,MAAK;KAAS,uBAAkB,OAAA,OAAA,OAAA,MAAG,WAAW,IAAG,EAAG,OAAM,CAAA;;IAChE,KAAA,MAAK,UAA1BH,UAAA,GAAAI,YAQgBC,wBAAA;;KARmB,OAAOC,MAAA,QAAA,CAAQ,CAAC;;KACjD,SAAAC,cAME,CANFL,YAMEI,MAAA,cAAA,GAAA;MALC,MAAM,KAAA;MACN,QAAQ,QAAA;MACR,QAAQ,KAAA,MAAK;MACb,QAAQ;MACR,mBAAa,OAAA,OAAA,OAAA,MAAG,WAAW,IAAG,EAAG,OAAM,CAAA;;;;;;;;IAG5CJ,YAKYI,MAAA,SAAA,GAAA;KAJT,eAAW,CAAA,CAAI,KAAA,MAAK;KACpB,uBAAkB,OAAA,OAAA,OAAA,MAAG,WAAW,IAAG,EAAA,QAAW,UAAU,KAAA,EAAS,CAAA;;KAElE,SAAAC,cAA0B,CAAvBE,gBAAAC,gBAAAJ,MAAA,QAAA,CAAQ,CAAC,WAAW,GAAA,CAAA,C"}
|
package/dist/pivot/pivot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pivot.js","names":["_sfc_main"],"sources":["../../src/pivot/pivot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouPivot } from '@dou-ui/pivot'\nimport type {\n PivotCellEvent,\n PivotConfig,\n PivotDimension,\n PivotExpose,\n PivotField,\n} from '@dou-ui/pivot'\nimport { computed, shallowRef, watch } from 'vue'\nimport { useDashboardWidget } from '../widget/context'\nimport { filterValueOf, rowsOf } from '../widgets/shared'\nimport
|
|
1
|
+
{"version":3,"file":"pivot.js","names":["_sfc_main"],"sources":["../../src/pivot/pivot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { DouPivot } from '@dou-ui/pivot'\nimport type {\n PivotCellEvent,\n PivotConfig,\n PivotDimension,\n PivotExpose,\n PivotField,\n} from '@dou-ui/pivot'\nimport { computed, shallowRef, watch } from 'vue'\nimport { useDashboardWidget } from '../widget/context'\nimport { filterValueOf, rowsOf } from '../widgets/shared'\nimport { pivotPropsOf } from './read-props'\n\ndefineOptions({ name: 'DouDashboardPivotWidget' })\n\ndefineProps<{ fields?: readonly PivotField[] }>()\n\nconst {\n props: raw,\n data,\n size,\n setFilter,\n ownFilters,\n editing,\n setProps,\n setWorkbook,\n} = useDashboardWidget()\nconst props = computed(() => pivotPropsOf(raw.value))\nconst pivot = shallowRef<PivotExpose>()\n// the export menu writes the table as it shows: merged heads, totals, number formats\nsetWorkbook(() => pivot.value?.toSheet({ name: '' }))\nconst rows = computed(() => rowsOf(data.value, props.value.path))\n// sorting in the table works while viewing too; only while editing is it saved\nconst config = shallowRef<PivotConfig | undefined>(props.value.config)\n// only a new config from the props replaces it, not a change to another prop\nwatch(\n () => raw.value.config,\n () => (config.value = props.value.config),\n)\nfunction onConfig(next: PivotConfig) {\n config.value = next\n if (editing.value) setProps({ config: next }, { group: 'pivot-config' })\n}\nconst nameOf = (dimension: PivotDimension) =>\n typeof dimension === 'string' ? dimension : dimension.field\n\n/** The groups this widget's filters picked, marked in the table. */\nfunction pathOf(dimensions: readonly PivotDimension[] = [], filters: Record<string, unknown>) {\n const path: unknown[] = []\n for (const dimension of dimensions) {\n const value = filters[nameOf(dimension)]\n if (value === undefined) break\n path.push(value)\n }\n return path\n}\nconst highlight = computed(() => {\n if (!props.value.filter) return undefined\n const filters = ownFilters.value\n return {\n row: pathOf(config.value?.rows, filters),\n column: pathOf(config.value?.columns, filters),\n }\n})\n\n/** One filter per field of a group's path; the fields past its end are cleared. */\nfunction apply(\n dimensions: readonly PivotDimension[] = [],\n path: readonly unknown[],\n labels: string[],\n) {\n dimensions.forEach((dimension, i) =>\n i < path.length\n ? setFilter(nameOf(dimension), filterValueOf(path[i]), { label: labels[i] })\n : setFilter(nameOf(dimension), undefined),\n )\n}\n\n/** Sets one filter per field of the clicked cell's groups; a total clears the deeper ones. */\nfunction onCell(cell: PivotCellEvent) {\n if (!props.value.filter) return\n const { rows: rowDims, columns: columnDims } = config.value ?? {}\n apply(rowDims, cell.row, cell.labels.row)\n apply(columnDims, cell.column, cell.labels.column)\n}\n</script>\n\n<template>\n <DouPivot\n ref=\"pivot\"\n class=\"dou-dashboard-pivot\"\n :bordered=\"false\"\n :data=\"rows\"\n :fields=\"fields\"\n :config=\"config\"\n :highlight=\"highlight\"\n size=\"sm\"\n :max-height=\"size.height.value || undefined\"\n @update:config=\"onConfig\"\n @cell-click=\"onCell\"\n />\n</template>\n"],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useDashboardWidget } from "../widget/context.js";
|
|
2
2
|
import { filterValueOf, rowsOf } from "../widgets/shared.js";
|
|
3
|
+
import { pivotPropsOf } from "./read-props.js";
|
|
3
4
|
import { computed, createBlock, defineComponent, openBlock, shallowRef, unref, watch } from "vue";
|
|
4
5
|
import { DouPivot } from "@dou-ui/pivot";
|
|
5
6
|
// src/pivot/pivot.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -8,12 +9,13 @@ var pivot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
8
9
|
__name: "pivot",
|
|
9
10
|
props: { fields: {} },
|
|
10
11
|
setup(__props) {
|
|
11
|
-
const { props, data, size, setFilter, ownFilters, editing, setProps, setWorkbook } = useDashboardWidget();
|
|
12
|
+
const { props: raw, data, size, setFilter, ownFilters, editing, setProps, setWorkbook } = useDashboardWidget();
|
|
13
|
+
const props = computed(() => pivotPropsOf(raw.value));
|
|
12
14
|
const pivot = shallowRef();
|
|
13
15
|
setWorkbook(() => pivot.value?.toSheet({ name: "" }));
|
|
14
16
|
const rows = computed(() => rowsOf(data.value, props.value.path));
|
|
15
17
|
const config = shallowRef(props.value.config);
|
|
16
|
-
watch(() =>
|
|
18
|
+
watch(() => raw.value.config, () => config.value = props.value.config);
|
|
17
19
|
function onConfig(next) {
|
|
18
20
|
config.value = next;
|
|
19
21
|
if (editing.value) setProps({ config: next }, { group: "pivot-config" });
|
|
@@ -53,6 +55,7 @@ var pivot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComp
|
|
|
53
55
|
ref_key: "pivot",
|
|
54
56
|
ref: pivot,
|
|
55
57
|
class: "dou-dashboard-pivot",
|
|
58
|
+
bordered: false,
|
|
56
59
|
data: rows.value,
|
|
57
60
|
fields: __props.fields,
|
|
58
61
|
config: config.value,
|