@dolusoft/query-table 3.12.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/query-table.js +84 -35
- package/dist/query-table.js.map +1 -1
- package/dist/types/contract.d.ts +37 -3
- package/dist/types/core/labels.d.ts +3 -1
- package/dist/types/core/table-context.d.ts +2 -2
- package/dist/types/filter/use-filter-trigger.d.ts +3 -2
- package/dist/types/use-query-table.d.ts +6 -3
- package/package.json +3 -3
package/dist/query-table.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineComponent, effectScope, getCurrentInstance, getCurrentScope, guardReactiveProps, h, inject, mergeProps, nextTick, normalizeProps, normalizeStyle, onActivated, onBeforeUnmount, onBeforeUpdate, onDeactivated, onMounted, onScopeDispose, openBlock, provide, renderList, renderSlot, shallowRef, toDisplayString, toHandlers, toValue, unref, useSlots, watch, watchEffect, withCtx, withKeys, withModifiers } from "vue";
|
|
2
|
-
import { cloneQuery, columnTypeOf, columnTypeOf as columnTypeOf$1, conditionLabel, conditionOptions, isCursorQuery, parseFilterInput as parseFilterInput$1, rulesOf, sameQuery, searchOf } from "@dolusoft/query-protocol";
|
|
2
|
+
import { cloneQuery, columnTypeOf, columnTypeOf as columnTypeOf$1, conditionArity, conditionLabel, conditionOptions, isCursorQuery, parseFilterInput as parseFilterInput$1, rulesOf, sameQuery, searchOf } from "@dolusoft/query-protocol";
|
|
3
3
|
import { createRowChangeTracker } from "@dolusoft/query-table-core/row-changes";
|
|
4
4
|
import { dispose, filterInputFeature, projectServerQuery, serverQueryFeature } from "@dolusoft/query-table-core";
|
|
5
5
|
import { columnFilteringFeature, columnOrderingFeature, columnPinningFeature, columnVisibilityFeature, functionalUpdate, globalFilteringFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, tableFeatures, useTable } from "@tanstack/vue-table";
|
|
@@ -255,6 +255,8 @@ var defaultLabels = {
|
|
|
255
255
|
expandRow: "Expand row",
|
|
256
256
|
openRightPanel: "Open right panel",
|
|
257
257
|
filterInput: (column) => `Filter ${column}`,
|
|
258
|
+
filterInputFrom: (column) => `Filter ${column} from`,
|
|
259
|
+
filterInputTo: (column) => `Filter ${column} to`,
|
|
258
260
|
filterOptions: (column) => `Filter options for ${column}`,
|
|
259
261
|
resizeColumn: (column) => `Resize ${column}`,
|
|
260
262
|
moveColumn: (column) => `Move ${column}`,
|
|
@@ -1438,29 +1440,39 @@ var useFilterTrigger = (options) => defineComponent({
|
|
|
1438
1440
|
//#endregion
|
|
1439
1441
|
//#region src/parts/filter-cell.vue?vue&type=script&setup=true&lang.ts
|
|
1440
1442
|
var _hoisted_1$6 = { class: "qt-filter" };
|
|
1441
|
-
var _hoisted_2$3 = [
|
|
1442
|
-
var _hoisted_3$3 = [
|
|
1443
|
+
var _hoisted_2$3 = [
|
|
1443
1444
|
"type",
|
|
1445
|
+
"aria-label",
|
|
1446
|
+
"value",
|
|
1447
|
+
"onInput"
|
|
1448
|
+
];
|
|
1449
|
+
var _hoisted_3$3 = [
|
|
1444
1450
|
"aria-label",
|
|
1445
1451
|
"value",
|
|
1446
1452
|
"readonly"
|
|
1447
1453
|
];
|
|
1448
1454
|
var _hoisted_4$3 = [
|
|
1455
|
+
"type",
|
|
1456
|
+
"aria-label",
|
|
1457
|
+
"value",
|
|
1458
|
+
"readonly"
|
|
1459
|
+
];
|
|
1460
|
+
var _hoisted_5$1 = [
|
|
1449
1461
|
"aria-label",
|
|
1450
1462
|
"value",
|
|
1451
1463
|
"disabled"
|
|
1452
1464
|
];
|
|
1453
|
-
var
|
|
1454
|
-
var
|
|
1455
|
-
var
|
|
1456
|
-
var
|
|
1465
|
+
var _hoisted_6$1 = { value: "" };
|
|
1466
|
+
var _hoisted_7$1 = { value: "true" };
|
|
1467
|
+
var _hoisted_8$1 = { value: "false" };
|
|
1468
|
+
var _hoisted_9 = [
|
|
1457
1469
|
"type",
|
|
1458
1470
|
"aria-label",
|
|
1459
1471
|
"value",
|
|
1460
1472
|
"readonly"
|
|
1461
1473
|
];
|
|
1462
|
-
var
|
|
1463
|
-
key:
|
|
1474
|
+
var _hoisted_10 = {
|
|
1475
|
+
key: 7,
|
|
1464
1476
|
class: "qt-filter-condition"
|
|
1465
1477
|
};
|
|
1466
1478
|
//#endregion
|
|
@@ -1492,6 +1504,31 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1492
1504
|
const count = filters.multiOf(props.column.field);
|
|
1493
1505
|
return count > 0 ? `(${count})` : filters.draftOf(props.column.field).text;
|
|
1494
1506
|
};
|
|
1507
|
+
const draft = () => filters.draftOf(props.column.field);
|
|
1508
|
+
const isMulti = () => filters.multiOf(props.column.field) > 0;
|
|
1509
|
+
const ordered = [
|
|
1510
|
+
"number",
|
|
1511
|
+
"integer",
|
|
1512
|
+
"date",
|
|
1513
|
+
"datetime"
|
|
1514
|
+
];
|
|
1515
|
+
const isDated = () => props.type === "date" || props.type === "datetime";
|
|
1516
|
+
const hidesInput = () => {
|
|
1517
|
+
const { condition } = draft();
|
|
1518
|
+
return !isMulti() && props.type !== "bool" && condition !== null && conditionArity(condition) === 0;
|
|
1519
|
+
};
|
|
1520
|
+
const isRange = () => !isMulti() && draft().condition === "Between" && ordered.includes(props.type);
|
|
1521
|
+
const bounds = ["lower", "upper"];
|
|
1522
|
+
const boundText = (bound) => bound === "upper" ? draft().text2 ?? "" : draft().text;
|
|
1523
|
+
const boundName = (bound) => {
|
|
1524
|
+
const name = columnName(props.column);
|
|
1525
|
+
return bound === "upper" ? labels().filterInputTo(name) : labels().filterInputFrom(name);
|
|
1526
|
+
};
|
|
1527
|
+
const takes = (condition) => condition === "Between" ? ordered.includes(props.type) : conditionArity(condition) === 0 || conditionOptions[props.type].some((option) => option.value === condition);
|
|
1528
|
+
const offered = () => {
|
|
1529
|
+
const own = props.column.filterConditions;
|
|
1530
|
+
return own ? [...new Set(own)].filter(takes) : conditionOptions[props.type].map(({ value }) => value);
|
|
1531
|
+
};
|
|
1495
1532
|
const currentCondition = () => rulesOf(props.query.filters, props.column.field)[0]?.condition ?? filters.draftOf(props.column.field).condition;
|
|
1496
1533
|
const menuProps = () => {
|
|
1497
1534
|
const { column } = props;
|
|
@@ -1499,7 +1536,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1499
1536
|
column,
|
|
1500
1537
|
rules: rulesOf(props.query.filters, column.field),
|
|
1501
1538
|
condition: currentCondition(),
|
|
1502
|
-
conditions:
|
|
1539
|
+
conditions: offered().map((value) => ({
|
|
1503
1540
|
value,
|
|
1504
1541
|
label: labels().filterCondition(value, props.type)
|
|
1505
1542
|
})),
|
|
@@ -1512,10 +1549,11 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1512
1549
|
control: layout.controlOf(column.field)
|
|
1513
1550
|
};
|
|
1514
1551
|
};
|
|
1515
|
-
const datetimeProps = () => ({
|
|
1552
|
+
const datetimeProps = (bound = null) => ({
|
|
1516
1553
|
column: props.column,
|
|
1517
|
-
value:
|
|
1518
|
-
updateValue: (value) => filters.setInput(props.column.field, value)
|
|
1554
|
+
value: bound ? boundText(bound) : draft().text,
|
|
1555
|
+
updateValue: (value) => filters.setInput(props.column.field, value, bound ?? void 0),
|
|
1556
|
+
bound
|
|
1519
1557
|
});
|
|
1520
1558
|
const inputValue = (event) => event.target.value;
|
|
1521
1559
|
const pick = (event) => {
|
|
@@ -1524,46 +1562,57 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
|
|
|
1524
1562
|
};
|
|
1525
1563
|
return (_ctx, _cache) => {
|
|
1526
1564
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
1527
|
-
|
|
1528
|
-
key: 0,
|
|
1565
|
+
isRange() ? (openBlock(), createElementBlock(Fragment, { key: 0 }, renderList(bounds, (bound) => {
|
|
1566
|
+
return openBlock(), createElementBlock(Fragment, { key: bound }, [isDated() && _ctx.$slots["filter-datetime"] ? renderSlot(_ctx.$slots, "filter-datetime", mergeProps({ ref_for: true }, datetimeProps(bound)), void 0, void 0, 0) : (openBlock(), createElementBlock("input", {
|
|
1567
|
+
key: 1,
|
|
1568
|
+
type: isDated() ? "date" : "number",
|
|
1569
|
+
class: "qt-filter-input",
|
|
1570
|
+
"aria-label": boundName(bound),
|
|
1571
|
+
value: boundText(bound),
|
|
1572
|
+
onInput: ($event) => unref(filters).setInput(__props.column.field, inputValue($event), bound),
|
|
1573
|
+
onKeydown: _cache[0] || (_cache[0] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1574
|
+
}, null, 40, _hoisted_2$3))], 64);
|
|
1575
|
+
}), 64)) : hidesInput() ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [], 64)) : __props.type === "string" ? (openBlock(), createElementBlock("input", {
|
|
1576
|
+
key: 2,
|
|
1529
1577
|
type: "text",
|
|
1530
1578
|
class: "qt-filter-input",
|
|
1531
1579
|
"aria-label": inputName(),
|
|
1532
|
-
value:
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1580
|
+
value: inputText(),
|
|
1581
|
+
readonly: isMulti(),
|
|
1582
|
+
onInput: _cache[1] || (_cache[1] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
|
|
1583
|
+
onKeydown: _cache[2] || (_cache[2] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1584
|
+
}, null, 40, _hoisted_3$3)) : __props.type === "number" || __props.type === "integer" ? (openBlock(), createElementBlock("input", {
|
|
1585
|
+
key: 3,
|
|
1537
1586
|
type: unref(filters).multiOf(__props.column.field) ? "text" : "number",
|
|
1538
1587
|
class: "qt-filter-input",
|
|
1539
1588
|
"aria-label": inputName(),
|
|
1540
1589
|
value: inputText(),
|
|
1541
1590
|
readonly: unref(filters).multiOf(__props.column.field) > 0,
|
|
1542
|
-
onInput: _cache[
|
|
1543
|
-
onKeydown: _cache[
|
|
1544
|
-
}, null, 40,
|
|
1545
|
-
key:
|
|
1591
|
+
onInput: _cache[3] || (_cache[3] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
|
|
1592
|
+
onKeydown: _cache[4] || (_cache[4] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1593
|
+
}, null, 40, _hoisted_4$3)) : __props.type === "bool" ? (openBlock(), createElementBlock("select", {
|
|
1594
|
+
key: 4,
|
|
1546
1595
|
class: "qt-filter-input",
|
|
1547
1596
|
"aria-label": inputName(),
|
|
1548
1597
|
value: unref(filters).draftOf(__props.column.field).text,
|
|
1549
1598
|
disabled: unref(filters).multiOf(__props.column.field) > 0,
|
|
1550
|
-
onChange: _cache[
|
|
1599
|
+
onChange: _cache[5] || (_cache[5] = ($event) => pick($event))
|
|
1551
1600
|
}, [
|
|
1552
|
-
createElementVNode("option",
|
|
1553
|
-
createElementVNode("option",
|
|
1554
|
-
createElementVNode("option",
|
|
1555
|
-
], 40,
|
|
1601
|
+
createElementVNode("option", _hoisted_6$1, toDisplayString(unref(labels)().boolAll), 1),
|
|
1602
|
+
createElementVNode("option", _hoisted_7$1, toDisplayString(unref(labels)().boolTrue), 1),
|
|
1603
|
+
createElementVNode("option", _hoisted_8$1, toDisplayString(unref(labels)().boolFalse), 1)
|
|
1604
|
+
], 40, _hoisted_5$1)) : (openBlock(), createElementBlock(Fragment, { key: 5 }, [_ctx.$slots["filter-datetime"] ? renderSlot(_ctx.$slots, "filter-datetime", normalizeProps(guardReactiveProps(datetimeProps())), void 0, void 0, 0) : (openBlock(), createElementBlock("input", {
|
|
1556
1605
|
key: 1,
|
|
1557
1606
|
type: unref(filters).multiOf(__props.column.field) ? "text" : "date",
|
|
1558
1607
|
class: "qt-filter-input",
|
|
1559
1608
|
"aria-label": inputName(),
|
|
1560
1609
|
value: inputText(),
|
|
1561
1610
|
readonly: unref(filters).multiOf(__props.column.field) > 0,
|
|
1562
|
-
onInput: _cache[
|
|
1563
|
-
onKeydown: _cache[
|
|
1564
|
-
}, null, 40,
|
|
1565
|
-
__props.type !== "bool" ? renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(menuProps())), void 0, void 0,
|
|
1566
|
-
labelOf() ? (openBlock(), createElementBlock("small",
|
|
1611
|
+
onInput: _cache[6] || (_cache[6] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
|
|
1612
|
+
onKeydown: _cache[7] || (_cache[7] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
|
|
1613
|
+
}, null, 40, _hoisted_9))], 64)),
|
|
1614
|
+
__props.type !== "bool" ? renderSlot(_ctx.$slots, "filter-menu", normalizeProps(guardReactiveProps(menuProps())), void 0, void 0, 6) : createCommentVNode("", true),
|
|
1615
|
+
labelOf() ? (openBlock(), createElementBlock("small", _hoisted_10, toDisplayString(labelOf()), 1)) : createCommentVNode("", true)
|
|
1567
1616
|
]);
|
|
1568
1617
|
};
|
|
1569
1618
|
}
|
|
@@ -3030,7 +3079,7 @@ function useQueryTable(options) {
|
|
|
3030
3079
|
const draftOf = (field) => columnById(field)?.getFilterInput() ?? blank;
|
|
3031
3080
|
const filters = {
|
|
3032
3081
|
draftOf,
|
|
3033
|
-
setInput: (field, text) => columnById(field)?.setFilterInput(text),
|
|
3082
|
+
setInput: (field, text, bound) => columnById(field)?.setFilterInput(text, bound),
|
|
3034
3083
|
apply: (field) => columnById(field)?.applyFilterInput(),
|
|
3035
3084
|
flushAll: () => table.flushPendingFilters(),
|
|
3036
3085
|
setCondition: (field, condition) => columnById(field)?.setFilterCondition(condition),
|