@dolusoft/query-table 3.20.0 → 3.21.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/cells.js +42 -57
- package/dist/cells.js.map +1 -1
- package/dist/data-table.js +2 -1
- package/dist/data-table.js.map +1 -1
- package/dist/query-table.js +1 -1
- package/dist/{src-Cam4kRTd.js → src-DvUx4ur-.js} +454 -75
- package/dist/src-DvUx4ur-.js.map +1 -0
- package/dist/table-labels-DYrDE2Sq.js +58 -0
- package/dist/table-labels-DYrDE2Sq.js.map +1 -0
- package/dist/types/contract.d.ts +48 -0
- package/dist/types/core/table-context.d.ts +19 -3
- package/dist/types/core/table-labels.d.ts +13 -2
- package/dist/types/parts/table-body.vue.d.ts +2 -0
- package/dist/types/parts/table-row.d.ts +17 -1
- package/dist/types/resize/grow-shares.d.ts +29 -0
- package/dist/types/resize/use-column-resize.d.ts +7 -0
- package/dist/types/resize/use-growing-columns.d.ts +37 -0
- package/dist/types/use-query-table.d.ts +23 -3
- package/package.json +3 -3
- package/dist/src-Cam4kRTd.js.map +0 -1
- package/dist/table-context-Duuqp9Jq.js +0 -28
- package/dist/table-context-Duuqp9Jq.js.map +0 -1
package/dist/cells.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode,
|
|
1
|
+
import { n as useCellLabels, t as IconSlot } from "./table-labels-DYrDE2Sq.js";
|
|
2
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, renderSlot, toDisplayString, unref, useSlots, withCtx } from "vue";
|
|
3
3
|
//#region src/cells/cell-action.vue?vue&type=script&setup=true&lang.ts
|
|
4
4
|
var _hoisted_1$6 = ["data-kind"];
|
|
5
5
|
//#endregion
|
|
@@ -54,27 +54,6 @@ var cell_badge_default = /* @__PURE__ */ defineComponent({
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region src/core/table-labels.ts
|
|
58
|
-
/**
|
|
59
|
-
* The cell labels of the table a component sits in, read again on every
|
|
60
|
-
* call so they follow the table's `labels` prop. An entry the table leaves
|
|
61
|
-
* out, or gives as `undefined`, is the English default; outside a table
|
|
62
|
-
* every entry is (C-129). The one module of the main part the cell
|
|
63
|
-
* components import (ADR 0022, K320-6).
|
|
64
|
-
*/
|
|
65
|
-
var useCellLabels = () => {
|
|
66
|
-
const context = inject(tableContextKey, null);
|
|
67
|
-
if (!context) return () => cellLabelDefaults;
|
|
68
|
-
return () => {
|
|
69
|
-
const labels = context.labels();
|
|
70
|
-
return {
|
|
71
|
-
copyValue: labels.copyValue ?? cellLabelDefaults.copyValue,
|
|
72
|
-
previewValue: labels.previewValue ?? cellLabelDefaults.previewValue,
|
|
73
|
-
emptyValue: labels.emptyValue ?? cellLabelDefaults.emptyValue
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
//#endregion
|
|
78
57
|
//#region src/cells/cell-copy.vue?vue&type=script&setup=true&lang.ts
|
|
79
58
|
var _hoisted_1$3 = { class: "qt-cell-copy" };
|
|
80
59
|
var _hoisted_2$2 = { class: "qt-cell-copy-text" };
|
|
@@ -99,24 +78,27 @@ var cell_copy_default = /* @__PURE__ */ defineComponent({
|
|
|
99
78
|
"aria-label": name.value,
|
|
100
79
|
title: name.value,
|
|
101
80
|
onClick: _cache[0] || (_cache[0] = ($event) => emit("copy", text()))
|
|
102
|
-
}, [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
81
|
+
}, [createVNode(unref(IconSlot), { name: "copy" }, {
|
|
82
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createElementVNode("svg", {
|
|
83
|
+
class: "qt-cell-icon",
|
|
84
|
+
width: "14",
|
|
85
|
+
height: "14",
|
|
86
|
+
viewBox: "0 0 16 16",
|
|
87
|
+
fill: "none",
|
|
88
|
+
stroke: "currentColor",
|
|
89
|
+
"stroke-width": "1.5",
|
|
90
|
+
"stroke-linecap": "round",
|
|
91
|
+
"stroke-linejoin": "round",
|
|
92
|
+
"aria-hidden": "true"
|
|
93
|
+
}, [createElementVNode("rect", {
|
|
94
|
+
x: "5.5",
|
|
95
|
+
y: "5.5",
|
|
96
|
+
width: "7.5",
|
|
97
|
+
height: "7.5",
|
|
98
|
+
rx: "1.5"
|
|
99
|
+
}), createElementVNode("path", { d: "M3 10.5V4a1 1 0 0 1 1-1h6.5" })], -1)])]),
|
|
100
|
+
_: 1
|
|
101
|
+
})], 8, _hoisted_3$2)]);
|
|
120
102
|
};
|
|
121
103
|
}
|
|
122
104
|
});
|
|
@@ -145,22 +127,25 @@ var cell_preview_default = /* @__PURE__ */ defineComponent({
|
|
|
145
127
|
"aria-label": name.value,
|
|
146
128
|
title: name.value,
|
|
147
129
|
onClick: _cache[0] || (_cache[0] = ($event) => emit("preview", value()))
|
|
148
|
-
}, [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
130
|
+
}, [createVNode(unref(IconSlot), { name: "preview" }, {
|
|
131
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createElementVNode("svg", {
|
|
132
|
+
class: "qt-cell-icon",
|
|
133
|
+
width: "14",
|
|
134
|
+
height: "14",
|
|
135
|
+
viewBox: "0 0 16 16",
|
|
136
|
+
fill: "none",
|
|
137
|
+
stroke: "currentColor",
|
|
138
|
+
"stroke-width": "1.5",
|
|
139
|
+
"stroke-linecap": "round",
|
|
140
|
+
"stroke-linejoin": "round",
|
|
141
|
+
"aria-hidden": "true"
|
|
142
|
+
}, [createElementVNode("path", { d: "M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z" }), createElementVNode("circle", {
|
|
143
|
+
cx: "8",
|
|
144
|
+
cy: "8",
|
|
145
|
+
r: "1.75"
|
|
146
|
+
})], -1)])]),
|
|
147
|
+
_: 1
|
|
148
|
+
})], 8, _hoisted_3$1)]);
|
|
164
149
|
};
|
|
165
150
|
}
|
|
166
151
|
});
|
package/dist/cells.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cells.js","names":["_hoisted_1","_openBlock","_createElementBlock","_renderSlot","_sfc_main","_hoisted_1","_openBlock","_createElementBlock","_renderSlot","_sfc_main","_hoisted_1","_openBlock","_createElementBlock","_renderSlot","_createTextVNode","_toDisplayString","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_sfc_main","_hoisted_1","_useSlots","_openBlock","_createElementBlock","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString","_createCommentVNode","_sfc_main","_openBlock","_createElementBlock","_toDisplayString","_unref","_Fragment","_createTextVNode","_sfc_main"],"sources":["../src/cells/cell-action.vue","../src/cells/cell-action.vue","../src/cells/cell-actions.vue","../src/cells/cell-actions.vue","../src/cells/cell-badge.vue","../src/cells/cell-badge.vue","../src/core/table-labels.ts","../src/cells/cell-copy.vue","../src/cells/cell-copy.vue","../src/cells/cell-preview.vue","../src/cells/cell-preview.vue","../src/cells/cell-stack.vue","../src/cells/cell-stack.vue","../src/cells/cell-value.vue","../src/cells/cell-value.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { CellActionProps } from './contract'\n\n// Attributes and listeners (`onClick`, `aria-label`, `disabled`) fall\n// through to the button: the action is the consumer's.\ndefineOptions({ name: 'CellAction' })\n\nwithDefaults(defineProps<CellActionProps>(), { kind: 'default' })\n\ndefineSlots<{\n /** The button's text, the consumer's content (C-129). */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <button type=\"button\" class=\"qt-cell-action\" :data-kind=\"kind\">\n <slot />\n </button>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellActionProps } from './contract'\n\n// Attributes and listeners (`onClick`, `aria-label`, `disabled`) fall\n// through to the button: the action is the consumer's.\ndefineOptions({ name: 'CellAction' })\n\nwithDefaults(defineProps<CellActionProps>(), { kind: 'default' })\n\ndefineSlots<{\n /** The button's text, the consumer's content (C-129). */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <button type=\"button\" class=\"qt-cell-action\" :data-kind=\"kind\">\n <slot />\n </button>\n</template>\n","<script setup lang=\"ts\">\ndefineOptions({ name: 'CellActions' })\n\ndefineSlots<{\n /** The `CellAction` buttons. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-actions\"><slot /></span>\n</template>\n","<script setup lang=\"ts\">\ndefineOptions({ name: 'CellActions' })\n\ndefineSlots<{\n /** The `CellAction` buttons. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-actions\"><slot /></span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellBadgeProps } from './contract'\n\ndefineOptions({ name: 'CellBadge' })\n\nwithDefaults(defineProps<CellBadgeProps>(), {\n text: undefined,\n tone: 'neutral'\n})\n\ndefineSlots<{\n /** Replaces `text`. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-badge\" :data-tone=\"tone\"\n ><slot>{{ text }}</slot></span\n >\n</template>\n","<script setup lang=\"ts\">\nimport type { CellBadgeProps } from './contract'\n\ndefineOptions({ name: 'CellBadge' })\n\nwithDefaults(defineProps<CellBadgeProps>(), {\n text: undefined,\n tone: 'neutral'\n})\n\ndefineSlots<{\n /** Replaces `text`. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-badge\" :data-tone=\"tone\"\n ><slot>{{ text }}</slot></span\n >\n</template>\n","import { inject } from 'vue'\n\nimport { cellLabelDefaults, type CellLabels } from './cell-labels'\nimport { tableContextKey } from './table-context'\n\n/**\n * The cell labels of the table a component sits in, read again on every\n * call so they follow the table's `labels` prop. An entry the table leaves\n * out, or gives as `undefined`, is the English default; outside a table\n * every entry is (C-129). The one module of the main part the cell\n * components import (ADR 0022, K320-6).\n */\nexport const useCellLabels = (): (() => CellLabels) => {\n const context = inject(tableContextKey, null)\n if (!context) {\n return () => cellLabelDefaults\n }\n return () => {\n const labels: Partial<CellLabels> = context.labels()\n return {\n copyValue: labels.copyValue ?? cellLabelDefaults.copyValue,\n previewValue: labels.previewValue ?? cellLabelDefaults.previewValue,\n emptyValue: labels.emptyValue ?? cellLabelDefaults.emptyValue\n }\n }\n}\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellCopyProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellCopy' })\n\nconst props = defineProps<CellCopyProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Writing the clipboard is the consumer's (C-129). */\n copy: [value: string]\n}>()\n\nconst labels = useCellLabels()\nconst text = () => String(props.value)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().copyValue(text()))\n</script>\n\n<template>\n <span class=\"qt-cell-copy\">\n <code class=\"qt-cell-copy-text\">{{ value }}</code>\n <button\n type=\"button\"\n class=\"qt-cell-copy-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('copy', text())\"\n >\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect x=\"5.5\" y=\"5.5\" width=\"7.5\" height=\"7.5\" rx=\"1.5\" />\n <path d=\"M3 10.5V4a1 1 0 0 1 1-1h6.5\" />\n </svg>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellCopyProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellCopy' })\n\nconst props = defineProps<CellCopyProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Writing the clipboard is the consumer's (C-129). */\n copy: [value: string]\n}>()\n\nconst labels = useCellLabels()\nconst text = () => String(props.value)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().copyValue(text()))\n</script>\n\n<template>\n <span class=\"qt-cell-copy\">\n <code class=\"qt-cell-copy-text\">{{ value }}</code>\n <button\n type=\"button\"\n class=\"qt-cell-copy-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('copy', text())\"\n >\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect x=\"5.5\" y=\"5.5\" width=\"7.5\" height=\"7.5\" rx=\"1.5\" />\n <path d=\"M3 10.5V4a1 1 0 0 1 1-1h6.5\" />\n </svg>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellPreviewProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellPreview' })\n\nconst props = defineProps<CellPreviewProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Showing the preview is the consumer's (C-129). */\n preview: [text: string]\n}>()\n\nconst labels = useCellLabels()\nconst value = () => String(props.text)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().previewValue(value()))\n</script>\n\n<template>\n <span class=\"qt-cell-preview\">\n <span class=\"qt-cell-preview-text\">{{ text }}</span>\n <button\n type=\"button\"\n class=\"qt-cell-preview-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('preview', value())\"\n >\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path\n d=\"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"1.75\" />\n </svg>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellPreviewProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellPreview' })\n\nconst props = defineProps<CellPreviewProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Showing the preview is the consumer's (C-129). */\n preview: [text: string]\n}>()\n\nconst labels = useCellLabels()\nconst value = () => String(props.text)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().previewValue(value()))\n</script>\n\n<template>\n <span class=\"qt-cell-preview\">\n <span class=\"qt-cell-preview-text\">{{ text }}</span>\n <button\n type=\"button\"\n class=\"qt-cell-preview-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('preview', value())\"\n >\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path\n d=\"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"1.75\" />\n </svg>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellStackProps } from './contract'\n\ndefineOptions({ name: 'CellStack' })\n\nconst props = defineProps<CellStackProps>()\n\nconst slots = defineSlots<{\n /** Replaces `primary`. */\n primary?(): unknown\n /** Replaces `secondary`. */\n secondary?(): unknown\n}>()\n\nconst hasSecondary = () =>\n slots.secondary !== undefined ||\n (props.secondary !== undefined &&\n props.secondary !== null &&\n props.secondary !== '')\n</script>\n\n<template>\n <span class=\"qt-cell-stack\">\n <span class=\"qt-cell-primary\"\n ><slot name=\"primary\">{{ primary }}</slot></span\n >\n <span v-if=\"hasSecondary()\" class=\"qt-cell-secondary\"\n ><slot name=\"secondary\">{{ secondary }}</slot></span\n >\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellStackProps } from './contract'\n\ndefineOptions({ name: 'CellStack' })\n\nconst props = defineProps<CellStackProps>()\n\nconst slots = defineSlots<{\n /** Replaces `primary`. */\n primary?(): unknown\n /** Replaces `secondary`. */\n secondary?(): unknown\n}>()\n\nconst hasSecondary = () =>\n slots.secondary !== undefined ||\n (props.secondary !== undefined &&\n props.secondary !== null &&\n props.secondary !== '')\n</script>\n\n<template>\n <span class=\"qt-cell-stack\">\n <span class=\"qt-cell-primary\"\n ><slot name=\"primary\">{{ primary }}</slot></span\n >\n <span v-if=\"hasSecondary()\" class=\"qt-cell-secondary\"\n ><slot name=\"secondary\">{{ secondary }}</slot></span\n >\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellValueProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\n// A value is drawn as bare text, which cannot carry an attribute, so\n// CellValue takes none, whether the value is empty or not (C-128): the same\n// markup for every row, and no warning for an attribute dropped.\ndefineOptions({ name: 'CellValue', inheritAttrs: false })\n\nconst props = defineProps<CellValueProps>()\n\nconst labels = useCellLabels()\nconst empty = () =>\n props.value === null || props.value === undefined || props.value === ''\n</script>\n\n<template>\n <span v-if=\"empty()\" class=\"qt-cell-empty\">{{ labels().emptyValue }}</span>\n <template v-else>{{ String(value) }}</template>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellValueProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\n// A value is drawn as bare text, which cannot carry an attribute, so\n// CellValue takes none, whether the value is empty or not (C-128): the same\n// markup for every row, and no warning for an attribute dropped.\ndefineOptions({ name: 'CellValue', inheritAttrs: false })\n\nconst props = defineProps<CellValueProps>()\n\nconst labels = useCellLabels()\nconst empty = () =>\n props.value === null || props.value === undefined || props.value === ''\n</script>\n\n<template>\n <span v-if=\"empty()\" class=\"qt-cell-empty\">{{ labels().emptyValue }}</span>\n <template v-else>{{ String(value) }}</template>\n</template>\n"],"mappings":";;;;;;;;;;;;GAgBE,OAAAC,UAAA,GAAAC,mBAES,UAAA;IAFD,MAAK;IAAS,OAAM;IAAkB,aAAW,QAAA;GACvDC,GAAAA,CAAAA,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,GAAA,YAAA;;;;;;;;;;;;;;GEPV,OAAAG,UAAA,GAAAC,mBAA6C,QAA7CF,cAA6C,CAAfG,WAAQ,KAAA,QAAA,SAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;GEOtC,OAAAG,UAAA,GAAAC,mBAEC,QAAA;IAFK,OAAM;IAAiB,aAAW,QAAA;GACrCC,GAAAA,CAAAA,WAAuB,KAAA,QAAA,WAAA,CAAA,SAAA,CAAdC,gBAAAC,gBAAA,QAAA,IAAI,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,GAAA,YAAA;;;;;;;;;;;;;AENlB,IAAa,sBAA0C;CACrD,MAAM,UAAU,OAAO,iBAAiB,IAAI;CAC5C,IAAI,CAAC,SACH,aAAa;CAEf,aAAa;EACX,MAAM,SAA8B,QAAQ,OAAO;EACnD,OAAO;GACL,WAAW,OAAO,aAAa,kBAAkB;GACjD,cAAc,OAAO,gBAAgB,kBAAkB;GACvD,YAAY,OAAO,cAAc,kBAAkB;EACrD;CACF;AACF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CAAA,MACjEH,UAAA,GAAAC,mBAA+CG,UAAA,EAAA,KAAA,EAAA,GAAA,CAA3BC,gBAAAH,gBAAA,OAAO,QAAA,KAAK,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"cells.js","names":["_hoisted_1","_openBlock","_createElementBlock","_renderSlot","_sfc_main","_hoisted_1","_openBlock","_createElementBlock","_renderSlot","_sfc_main","_hoisted_1","_openBlock","_createElementBlock","_renderSlot","_createTextVNode","_toDisplayString","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_withCtx","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","_unref","_withCtx","_sfc_main","_hoisted_1","_useSlots","_openBlock","_createElementBlock","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString","_createCommentVNode","_sfc_main","_openBlock","_createElementBlock","_toDisplayString","_unref","_Fragment","_createTextVNode","_sfc_main"],"sources":["../src/cells/cell-action.vue","../src/cells/cell-action.vue","../src/cells/cell-actions.vue","../src/cells/cell-actions.vue","../src/cells/cell-badge.vue","../src/cells/cell-badge.vue","../src/cells/cell-copy.vue","../src/cells/cell-copy.vue","../src/cells/cell-preview.vue","../src/cells/cell-preview.vue","../src/cells/cell-stack.vue","../src/cells/cell-stack.vue","../src/cells/cell-value.vue","../src/cells/cell-value.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { CellActionProps } from './contract'\n\n// Attributes and listeners (`onClick`, `aria-label`, `disabled`) fall\n// through to the button: the action is the consumer's.\ndefineOptions({ name: 'CellAction' })\n\nwithDefaults(defineProps<CellActionProps>(), { kind: 'default' })\n\ndefineSlots<{\n /** The button's text, the consumer's content (C-129). */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <button type=\"button\" class=\"qt-cell-action\" :data-kind=\"kind\">\n <slot />\n </button>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellActionProps } from './contract'\n\n// Attributes and listeners (`onClick`, `aria-label`, `disabled`) fall\n// through to the button: the action is the consumer's.\ndefineOptions({ name: 'CellAction' })\n\nwithDefaults(defineProps<CellActionProps>(), { kind: 'default' })\n\ndefineSlots<{\n /** The button's text, the consumer's content (C-129). */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <button type=\"button\" class=\"qt-cell-action\" :data-kind=\"kind\">\n <slot />\n </button>\n</template>\n","<script setup lang=\"ts\">\ndefineOptions({ name: 'CellActions' })\n\ndefineSlots<{\n /** The `CellAction` buttons. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-actions\"><slot /></span>\n</template>\n","<script setup lang=\"ts\">\ndefineOptions({ name: 'CellActions' })\n\ndefineSlots<{\n /** The `CellAction` buttons. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-actions\"><slot /></span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellBadgeProps } from './contract'\n\ndefineOptions({ name: 'CellBadge' })\n\nwithDefaults(defineProps<CellBadgeProps>(), {\n text: undefined,\n tone: 'neutral'\n})\n\ndefineSlots<{\n /** Replaces `text`. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-badge\" :data-tone=\"tone\"\n ><slot>{{ text }}</slot></span\n >\n</template>\n","<script setup lang=\"ts\">\nimport type { CellBadgeProps } from './contract'\n\ndefineOptions({ name: 'CellBadge' })\n\nwithDefaults(defineProps<CellBadgeProps>(), {\n text: undefined,\n tone: 'neutral'\n})\n\ndefineSlots<{\n /** Replaces `text`. */\n default?(): unknown\n}>()\n</script>\n\n<template>\n <span class=\"qt-cell-badge\" :data-tone=\"tone\"\n ><slot>{{ text }}</slot></span\n >\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellCopyProps } from './contract'\nimport { IconSlot, useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellCopy' })\n\nconst props = defineProps<CellCopyProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Writing the clipboard is the consumer's (C-129). */\n copy: [value: string]\n}>()\n\nconst labels = useCellLabels()\nconst text = () => String(props.value)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().copyValue(text()))\n</script>\n\n<template>\n <span class=\"qt-cell-copy\">\n <code class=\"qt-cell-copy-text\">{{ value }}</code>\n <button\n type=\"button\"\n class=\"qt-cell-copy-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('copy', text())\"\n >\n <!-- C-131: the table's `icon-copy` slot, else the built-in icon. -->\n <icon-slot name=\"copy\">\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect x=\"5.5\" y=\"5.5\" width=\"7.5\" height=\"7.5\" rx=\"1.5\" />\n <path d=\"M3 10.5V4a1 1 0 0 1 1-1h6.5\" />\n </svg>\n </icon-slot>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellCopyProps } from './contract'\nimport { IconSlot, useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellCopy' })\n\nconst props = defineProps<CellCopyProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Writing the clipboard is the consumer's (C-129). */\n copy: [value: string]\n}>()\n\nconst labels = useCellLabels()\nconst text = () => String(props.value)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().copyValue(text()))\n</script>\n\n<template>\n <span class=\"qt-cell-copy\">\n <code class=\"qt-cell-copy-text\">{{ value }}</code>\n <button\n type=\"button\"\n class=\"qt-cell-copy-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('copy', text())\"\n >\n <!-- C-131: the table's `icon-copy` slot, else the built-in icon. -->\n <icon-slot name=\"copy\">\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect x=\"5.5\" y=\"5.5\" width=\"7.5\" height=\"7.5\" rx=\"1.5\" />\n <path d=\"M3 10.5V4a1 1 0 0 1 1-1h6.5\" />\n </svg>\n </icon-slot>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellPreviewProps } from './contract'\nimport { IconSlot, useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellPreview' })\n\nconst props = defineProps<CellPreviewProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Showing the preview is the consumer's (C-129). */\n preview: [text: string]\n}>()\n\nconst labels = useCellLabels()\nconst value = () => String(props.text)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().previewValue(value()))\n</script>\n\n<template>\n <span class=\"qt-cell-preview\">\n <span class=\"qt-cell-preview-text\">{{ text }}</span>\n <button\n type=\"button\"\n class=\"qt-cell-preview-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('preview', value())\"\n >\n <!-- C-131: the table's `icon-preview` slot, else the built-in icon. -->\n <icon-slot name=\"preview\">\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path\n d=\"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"1.75\" />\n </svg>\n </icon-slot>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { CellPreviewProps } from './contract'\nimport { IconSlot, useCellLabels } from '../core/table-labels'\n\ndefineOptions({ name: 'CellPreview' })\n\nconst props = defineProps<CellPreviewProps>()\n\nconst emit = defineEmits<{\n /** The button was pressed. Showing the preview is the consumer's (C-129). */\n preview: [text: string]\n}>()\n\nconst labels = useCellLabels()\nconst value = () => String(props.text)\n// One name for `aria-label` and `title`, computed once per change.\nconst name = computed(() => labels().previewValue(value()))\n</script>\n\n<template>\n <span class=\"qt-cell-preview\">\n <span class=\"qt-cell-preview-text\">{{ text }}</span>\n <button\n type=\"button\"\n class=\"qt-cell-preview-button\"\n :aria-label=\"name\"\n :title=\"name\"\n @click=\"emit('preview', value())\"\n >\n <!-- C-131: the table's `icon-preview` slot, else the built-in icon. -->\n <icon-slot name=\"preview\">\n <svg\n class=\"qt-cell-icon\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path\n d=\"M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"1.75\" />\n </svg>\n </icon-slot>\n </button>\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellStackProps } from './contract'\n\ndefineOptions({ name: 'CellStack' })\n\nconst props = defineProps<CellStackProps>()\n\nconst slots = defineSlots<{\n /** Replaces `primary`. */\n primary?(): unknown\n /** Replaces `secondary`. */\n secondary?(): unknown\n}>()\n\nconst hasSecondary = () =>\n slots.secondary !== undefined ||\n (props.secondary !== undefined &&\n props.secondary !== null &&\n props.secondary !== '')\n</script>\n\n<template>\n <span class=\"qt-cell-stack\">\n <span class=\"qt-cell-primary\"\n ><slot name=\"primary\">{{ primary }}</slot></span\n >\n <span v-if=\"hasSecondary()\" class=\"qt-cell-secondary\"\n ><slot name=\"secondary\">{{ secondary }}</slot></span\n >\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellStackProps } from './contract'\n\ndefineOptions({ name: 'CellStack' })\n\nconst props = defineProps<CellStackProps>()\n\nconst slots = defineSlots<{\n /** Replaces `primary`. */\n primary?(): unknown\n /** Replaces `secondary`. */\n secondary?(): unknown\n}>()\n\nconst hasSecondary = () =>\n slots.secondary !== undefined ||\n (props.secondary !== undefined &&\n props.secondary !== null &&\n props.secondary !== '')\n</script>\n\n<template>\n <span class=\"qt-cell-stack\">\n <span class=\"qt-cell-primary\"\n ><slot name=\"primary\">{{ primary }}</slot></span\n >\n <span v-if=\"hasSecondary()\" class=\"qt-cell-secondary\"\n ><slot name=\"secondary\">{{ secondary }}</slot></span\n >\n </span>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellValueProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\n// A value is drawn as bare text, which cannot carry an attribute, so\n// CellValue takes none, whether the value is empty or not (C-128): the same\n// markup for every row, and no warning for an attribute dropped.\ndefineOptions({ name: 'CellValue', inheritAttrs: false })\n\nconst props = defineProps<CellValueProps>()\n\nconst labels = useCellLabels()\nconst empty = () =>\n props.value === null || props.value === undefined || props.value === ''\n</script>\n\n<template>\n <span v-if=\"empty()\" class=\"qt-cell-empty\">{{ labels().emptyValue }}</span>\n <template v-else>{{ String(value) }}</template>\n</template>\n","<script setup lang=\"ts\">\nimport type { CellValueProps } from './contract'\nimport { useCellLabels } from '../core/table-labels'\n\n// A value is drawn as bare text, which cannot carry an attribute, so\n// CellValue takes none, whether the value is empty or not (C-128): the same\n// markup for every row, and no warning for an attribute dropped.\ndefineOptions({ name: 'CellValue', inheritAttrs: false })\n\nconst props = defineProps<CellValueProps>()\n\nconst labels = useCellLabels()\nconst empty = () =>\n props.value === null || props.value === undefined || props.value === ''\n</script>\n\n<template>\n <span v-if=\"empty()\" class=\"qt-cell-empty\">{{ labels().emptyValue }}</span>\n <template v-else>{{ String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,MAAM,cAAc;;GAItB,OAAAC,UAAA,GAAAC,mBAOO,QAPPH,cAOO,CANLI,mBAEC,QAFD,YAEC,CADEC,WAAyC,KAAA,QAAA,WAAA,CAAA,SAAA,CAAjBC,gBAAAC,gBAAA,QAAA,OAAO,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAEtB,aAAY,KAAxBL,UAAA,GAAAC,mBAEC,QAFD,YAEC,CADEE,WAA6C,KAAA,QAAA,aAAA,CAAA,SAAA,CAAnBC,gBAAAC,gBAAA,QAAA,SAAS,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;EElB1C,MAAM,QAAQ;EAEd,MAAM,SAAS,cAAc;EAC7B,MAAM,cACJ,MAAM,UAAU,QAAQ,MAAM,UAAU,KAAA,KAAa,MAAM,UAAU;;GAIzD,OAAA,MAAK,KAAjBG,UAAA,GAAAC,mBAA2E,QAA3E,YAA2EC,gBAA7BC,MAAA,MAAA,CAAM,CAAA,CAAA,CAAG,UAAU,GAAA,CAAA,MACjEH,UAAA,GAAAC,mBAA+CG,UAAA,EAAA,KAAA,EAAA,GAAA,CAA3BC,gBAAAH,gBAAA,OAAO,QAAA,KAAK,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA"}
|
package/dist/data-table.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as query_table_default } from "./src-
|
|
1
|
+
import { r as query_table_default } from "./src-DvUx4ur-.js";
|
|
2
2
|
import { t as useLocalQuery } from "./local-DDJEp4Nn.js";
|
|
3
3
|
import { camelize, computed, createBlock, createSlots, defineComponent, getCurrentInstance, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderList, renderSlot, shallowRef, unref, useSlots, useTemplateRef, watch, withCtx } from "vue";
|
|
4
4
|
import { columnTypeOf, sameQuery } from "@dolusoft/query-protocol";
|
|
@@ -77,6 +77,7 @@ var data_table_default = /* @__PURE__ */ defineComponent({
|
|
|
77
77
|
},
|
|
78
78
|
dataset: { default: void 0 },
|
|
79
79
|
selection: {},
|
|
80
|
+
rowSelectable: {},
|
|
80
81
|
rowPinning: {},
|
|
81
82
|
searchDebounce: {},
|
|
82
83
|
columns: {},
|
package/dist/data-table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.js","names":["_useSlots","_openBlock","_createBlock","_unref","QueryTable","_mergeProps","_createSlots","_renderList","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_sfc_main","DataTable"],"sources":["../src/data-table/derive-dataset.ts","../src/data-table/data-table.vue","../src/data-table/data-table.vue","../src/data-table/index.ts"],"sourcesContent":["import { columnTypeOf, type ColumnType } from '@dolusoft/query-protocol'\nimport {\n defineDataset,\n type Dataset,\n type DatasetField\n} from '@dolusoft/query-protocol/local'\n\nimport type { Column } from '../contract'\n\n/** What the dataset of a `DataTable` is built from, and nothing else (C-126). */\nexport interface DatasetSpec {\n key: string\n search: string[]\n fields: Array<{\n name: string\n type: ColumnType\n sortable: boolean\n filterable: boolean\n }>\n /** The `ip` columns, left out of the fields (C-118). */\n ip: string[]\n}\n\nexport interface DatasetSource {\n rowKey: string\n columns: readonly Column[]\n search: readonly string[] | undefined\n sortable: boolean\n filterable: boolean\n}\n\n/**\n * The spec of the columns: one field per column `field` (the first column of\n * a name wins), hidden ones included, `ip` columns left out (C-118).\n */\nexport const datasetSpecOf = (source: DatasetSource): DatasetSpec => {\n const fields: DatasetSpec['fields'] = []\n const ip: string[] = []\n const seen = new Set<string>()\n for (const column of source.columns) {\n if (seen.has(column.field)) {\n continue\n }\n seen.add(column.field)\n const type = columnTypeOf(column)\n if (type === 'ip') {\n ip.push(column.field)\n continue\n }\n fields.push({\n name: column.field,\n type,\n sortable: source.sortable && column.sortable !== false,\n filterable: source.filterable && column.filterable !== false\n })\n }\n // The order of the fields and of the search means nothing to the\n // evaluator: sorted, a reordered column list gives an equal spec.\n const byName = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0)\n fields.sort((a, b) => byName(a.name, b.name))\n return {\n key: source.rowKey,\n search: [...new Set(source.search ?? [])].sort(byName),\n fields,\n ip: ip.sort(byName)\n }\n}\n\n/** Equal specs build the same dataset. */\nexport const sameSpec = (a: DatasetSpec, b: DatasetSpec): boolean =>\n JSON.stringify(a) === JSON.stringify(b)\n\n/** The dataset of a spec. Throws a `TypeError` for a malformed one (C-126). */\nexport const datasetOf = <T>(spec: DatasetSpec): Dataset<T> => {\n // QueryTable reads `row[rowKey]` (C-26) while the evaluator reads a dotted\n // path: only a top-level name means the same field to both.\n if (spec.key.includes('.')) {\n throw new TypeError(\n `DataTable: the rowKey \"${spec.key}\" is not a top-level field`\n )\n }\n // No prototype: a field named `__proto__` or `toString` stays a field.\n const fields = Object.create(null) as Record<string, DatasetField<T>>\n for (const field of spec.fields) {\n fields[field.name] = {\n type: field.type,\n sortable: field.sortable,\n filterable: field.filterable\n }\n }\n for (const name of spec.search) {\n if (!Object.prototype.hasOwnProperty.call(fields, name)) {\n throw new TypeError(\n spec.ip.includes(name)\n ? `DataTable: the search field \"${name}\" is an ip column; only string columns are searched`\n : `DataTable: the search field \"${name}\" is not a column`\n )\n }\n fields[name] = { ...fields[name], search: true }\n }\n return defineDataset<T>({ key: spec.key, fields })\n}\n","<script setup lang=\"ts\" generic=\"T extends object\">\nimport { columnTypeOf, sameQuery } from '@dolusoft/query-protocol'\nimport type { Dataset, SemanticsProfile } from '@dolusoft/query-protocol/local'\nimport {\n camelize,\n computed,\n getCurrentInstance,\n shallowRef,\n useTemplateRef,\n watch\n} from 'vue'\n\nimport type { DataTableEmits, DataTableProps, DataTableSlots } from './contract'\nimport {\n datasetOf,\n datasetSpecOf,\n sameSpec,\n type DatasetSpec\n} from './derive-dataset'\nimport type {\n Column,\n ColumnChangeReason,\n QueryChangeReason,\n QueryTableExpose,\n RowsUpdate,\n TableQuery\n} from '../contract'\nimport { QueryTable } from '../index'\nimport { useLocalQuery } from '../local'\n\n// `useLocalQuery` and `QueryTable` side by side (ADR 0021, K319-1): no\n// markup, no table state and no table behavior of its own.\ndefineOptions({ name: 'DataTable', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<DataTableProps<T>>(), {\n query: undefined,\n profile: 'tr-2',\n search: undefined,\n paginate: true,\n dataset: undefined\n})\n\nconst emit = defineEmits<DataTableEmits<T>>()\n\nconst slots = defineSlots<DataTableSlots<T>>()\n\n// The query (C-125): the consumer's when given, else held here. Until the\n// first update the held query is the start query, which follows\n// `pageSizeOptions`; while the consumer gives one, the held query is dropped.\nconst start = computed<TableQuery>(previous => {\n const pageSize = props.pagination?.pageSizeOptions?.[0] ?? 10\n return previous?.pageSize === pageSize\n ? previous\n : { page: 1, pageSize, sort: null, filters: [] }\n})\nconst held = shallowRef<TableQuery | null>(null)\nwatch(\n () => props.query !== undefined,\n given => {\n if (given) {\n held.value = null\n }\n }\n)\nconst query = computed(() => props.query ?? held.value ?? start.value)\nconst onQuery = (next: TableQuery, reason: QueryChangeReason) => {\n if (props.query === undefined) {\n held.value = next\n }\n emit('update:query', next, reason)\n}\n\n// The dataset (C-126): built again only when what it is built from changes,\n// compared by value.\nconst spec = computed<DatasetSpec>(previous => {\n const next = datasetSpecOf({\n rowKey: props.rowKey,\n columns: props.columns,\n search: props.search,\n sortable: props.sortable,\n filterable: props.filterable\n })\n return previous && sameSpec(previous, next) ? previous : next\n})\nconst derived = computed(() => datasetOf<T>(spec.value))\nconst dataset = computed(() => props.dataset ?? derived.value)\n\nconst local = useLocalQuery<T>({\n allRows: () => props.rows,\n query,\n dataset,\n // Read on every evaluation, so a new profile evaluates again.\n get profile() {\n return props.profile\n },\n paginate: () => props.paginate\n})\n\n// The flash hint (C-124): a new context is a snapshot; a new page in the\n// same context comes from the source. The query is compared by value, so a\n// new but equal query object is the same context.\ninterface Context {\n query: TableQuery\n dataset: Dataset<T>\n profile: SemanticsProfile\n paginate: boolean\n}\nconst drawn = computed<{ rows: T[]; hint: RowsUpdate; context: Context }>(\n previous => {\n const context: Context = {\n query: query.value,\n dataset: dataset.value,\n profile: props.profile,\n paginate: props.paginate\n }\n const before = previous?.context\n const same =\n before !== undefined &&\n sameQuery(before.query, context.query) &&\n before.dataset === context.dataset &&\n before.profile === context.profile &&\n before.paginate === context.paginate\n return { rows: local.rows.value, hint: same ? 'live' : 'snapshot', context }\n }\n)\n\n// An `ip` column is not a field (C-118, C-126), so the table offers no sort\n// and no filter on it. `update:columns` gives the consumer's own `sortable`\n// and `filterable` back, so the change never reaches the consumer's columns.\nconst isIp = (column: Column) => columnTypeOf(column) === 'ip'\nconst closed = (column: Column) =>\n isIp(column) && (column.sortable !== false || column.filterable !== false)\nconst columns = computed(() =>\n props.columns.some(closed)\n ? props.columns.map(column =>\n closed(column)\n ? { ...column, sortable: false, filterable: false }\n : column\n )\n : props.columns\n)\nconst onColumns = (next: Column[], reason: ColumnChangeReason) => {\n const drawnColumns = columns.value\n const originals = new Map(\n props.columns.filter(closed).map(column => [column.field, column])\n )\n const restored = next.map(column => {\n const original = originals.get(column.field)\n if (!original || !isIp(column)) {\n return column\n }\n if (drawnColumns.includes(column)) {\n return original\n }\n const copy: Column = { ...column }\n for (const key of ['sortable', 'filterable'] as const) {\n if (key in original) {\n copy[key] = original[key]\n } else {\n delete copy[key]\n }\n }\n return copy\n })\n emit('update:columns', restored, reason)\n}\n\n// What the consumer gave reaches QueryTable as given; what it left out is\n// left out, so QueryTable applies its own default (C-124). A declared prop\n// is passed as Vue read it (`sortable=\"\"` is `true`); any other attribute\n// keeps its name (`data-testid`, `aria-label`).\nconst instance = getCurrentInstance()!\nconst own = new Set([\n 'columns',\n 'query',\n 'rows',\n 'profile',\n 'search',\n 'paginate',\n 'dataset',\n 'totalRows',\n 'cursors',\n 'infinite',\n 'rowsUpdate'\n])\nconst reserved = new Set(['key', 'ref', 'ref_for', 'ref_key'])\nconst passed = (): Record<string, unknown> => {\n const raw = instance.vnode.props ?? {}\n const declared = props as Record<string, unknown>\n const out: Record<string, unknown> = {}\n for (const key of Object.keys(raw)) {\n if (reserved.has(key) || key.startsWith('onVnode')) {\n continue\n }\n if (/^on[A-Z]/.test(key)) {\n // `update:query` and `update:columns`, `.once` included, are emitted\n // by DataTable itself.\n if (!/^onUpdate:(query|columns)/.test(key)) {\n out[key] = raw[key]\n }\n continue\n }\n const name = camelize(key)\n if (own.has(name)) {\n continue\n }\n if (name in declared) {\n out[name] = declared[name]\n } else {\n out[key] = raw[key]\n }\n }\n return out\n}\n\n// The slots QueryTable gets: the consumer's, without `error`, without\n// `pagination` when nothing is paged, and with `empty` replaced while the\n// evaluator reports an error and an `error` slot is given.\nconst showError = () => local.error.value !== null && slots.error !== undefined\nconst slotNames = () =>\n Object.keys(slots).filter(\n name =>\n name !== 'error' &&\n !(name === 'pagination' && !props.paginate) &&\n !(name === 'empty' && showError())\n ) as Array<keyof DataTableSlots<T>>\n\nconst table = useTemplateRef<QueryTableExpose>('table')\nconst exposed: QueryTableExpose = {\n collapseAll: () => table.value?.collapseAll(),\n expandAll: () => table.value?.expandAll(),\n focusFilter: field => table.value?.focusFilter(field) ?? false,\n flushPendingFilters: () => table.value?.flushPendingFilters(),\n scrollToIndex: (index, options) => table.value?.scrollToIndex(index, options),\n loadMore: () => table.value?.loadMore(),\n measureColumnWidths: fields => table.value?.measureColumnWidths(fields) ?? {}\n}\ndefineExpose(exposed)\n</script>\n\n<template>\n <QueryTable\n ref=\"table\"\n v-bind=\"passed()\"\n :columns=\"columns\"\n :query=\"query\"\n :rows=\"drawn.rows\"\n :total-rows=\"local.totalRows.value\"\n :rows-update=\"drawn.hint\"\n @update:query=\"onQuery\"\n @update:columns=\"onColumns\"\n >\n <template v-for=\"name in slotNames()\" :key=\"name\" #[name]=\"scope\">\n <slot :name=\"name\" v-bind=\"scope ?? {}\" />\n </template>\n <template v-if=\"showError()\" #empty>\n <slot name=\"error\" :error=\"local.error.value!\" />\n </template>\n </QueryTable>\n</template>\n","<script setup lang=\"ts\" generic=\"T extends object\">\nimport { columnTypeOf, sameQuery } from '@dolusoft/query-protocol'\nimport type { Dataset, SemanticsProfile } from '@dolusoft/query-protocol/local'\nimport {\n camelize,\n computed,\n getCurrentInstance,\n shallowRef,\n useTemplateRef,\n watch\n} from 'vue'\n\nimport type { DataTableEmits, DataTableProps, DataTableSlots } from './contract'\nimport {\n datasetOf,\n datasetSpecOf,\n sameSpec,\n type DatasetSpec\n} from './derive-dataset'\nimport type {\n Column,\n ColumnChangeReason,\n QueryChangeReason,\n QueryTableExpose,\n RowsUpdate,\n TableQuery\n} from '../contract'\nimport { QueryTable } from '../index'\nimport { useLocalQuery } from '../local'\n\n// `useLocalQuery` and `QueryTable` side by side (ADR 0021, K319-1): no\n// markup, no table state and no table behavior of its own.\ndefineOptions({ name: 'DataTable', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<DataTableProps<T>>(), {\n query: undefined,\n profile: 'tr-2',\n search: undefined,\n paginate: true,\n dataset: undefined\n})\n\nconst emit = defineEmits<DataTableEmits<T>>()\n\nconst slots = defineSlots<DataTableSlots<T>>()\n\n// The query (C-125): the consumer's when given, else held here. Until the\n// first update the held query is the start query, which follows\n// `pageSizeOptions`; while the consumer gives one, the held query is dropped.\nconst start = computed<TableQuery>(previous => {\n const pageSize = props.pagination?.pageSizeOptions?.[0] ?? 10\n return previous?.pageSize === pageSize\n ? previous\n : { page: 1, pageSize, sort: null, filters: [] }\n})\nconst held = shallowRef<TableQuery | null>(null)\nwatch(\n () => props.query !== undefined,\n given => {\n if (given) {\n held.value = null\n }\n }\n)\nconst query = computed(() => props.query ?? held.value ?? start.value)\nconst onQuery = (next: TableQuery, reason: QueryChangeReason) => {\n if (props.query === undefined) {\n held.value = next\n }\n emit('update:query', next, reason)\n}\n\n// The dataset (C-126): built again only when what it is built from changes,\n// compared by value.\nconst spec = computed<DatasetSpec>(previous => {\n const next = datasetSpecOf({\n rowKey: props.rowKey,\n columns: props.columns,\n search: props.search,\n sortable: props.sortable,\n filterable: props.filterable\n })\n return previous && sameSpec(previous, next) ? previous : next\n})\nconst derived = computed(() => datasetOf<T>(spec.value))\nconst dataset = computed(() => props.dataset ?? derived.value)\n\nconst local = useLocalQuery<T>({\n allRows: () => props.rows,\n query,\n dataset,\n // Read on every evaluation, so a new profile evaluates again.\n get profile() {\n return props.profile\n },\n paginate: () => props.paginate\n})\n\n// The flash hint (C-124): a new context is a snapshot; a new page in the\n// same context comes from the source. The query is compared by value, so a\n// new but equal query object is the same context.\ninterface Context {\n query: TableQuery\n dataset: Dataset<T>\n profile: SemanticsProfile\n paginate: boolean\n}\nconst drawn = computed<{ rows: T[]; hint: RowsUpdate; context: Context }>(\n previous => {\n const context: Context = {\n query: query.value,\n dataset: dataset.value,\n profile: props.profile,\n paginate: props.paginate\n }\n const before = previous?.context\n const same =\n before !== undefined &&\n sameQuery(before.query, context.query) &&\n before.dataset === context.dataset &&\n before.profile === context.profile &&\n before.paginate === context.paginate\n return { rows: local.rows.value, hint: same ? 'live' : 'snapshot', context }\n }\n)\n\n// An `ip` column is not a field (C-118, C-126), so the table offers no sort\n// and no filter on it. `update:columns` gives the consumer's own `sortable`\n// and `filterable` back, so the change never reaches the consumer's columns.\nconst isIp = (column: Column) => columnTypeOf(column) === 'ip'\nconst closed = (column: Column) =>\n isIp(column) && (column.sortable !== false || column.filterable !== false)\nconst columns = computed(() =>\n props.columns.some(closed)\n ? props.columns.map(column =>\n closed(column)\n ? { ...column, sortable: false, filterable: false }\n : column\n )\n : props.columns\n)\nconst onColumns = (next: Column[], reason: ColumnChangeReason) => {\n const drawnColumns = columns.value\n const originals = new Map(\n props.columns.filter(closed).map(column => [column.field, column])\n )\n const restored = next.map(column => {\n const original = originals.get(column.field)\n if (!original || !isIp(column)) {\n return column\n }\n if (drawnColumns.includes(column)) {\n return original\n }\n const copy: Column = { ...column }\n for (const key of ['sortable', 'filterable'] as const) {\n if (key in original) {\n copy[key] = original[key]\n } else {\n delete copy[key]\n }\n }\n return copy\n })\n emit('update:columns', restored, reason)\n}\n\n// What the consumer gave reaches QueryTable as given; what it left out is\n// left out, so QueryTable applies its own default (C-124). A declared prop\n// is passed as Vue read it (`sortable=\"\"` is `true`); any other attribute\n// keeps its name (`data-testid`, `aria-label`).\nconst instance = getCurrentInstance()!\nconst own = new Set([\n 'columns',\n 'query',\n 'rows',\n 'profile',\n 'search',\n 'paginate',\n 'dataset',\n 'totalRows',\n 'cursors',\n 'infinite',\n 'rowsUpdate'\n])\nconst reserved = new Set(['key', 'ref', 'ref_for', 'ref_key'])\nconst passed = (): Record<string, unknown> => {\n const raw = instance.vnode.props ?? {}\n const declared = props as Record<string, unknown>\n const out: Record<string, unknown> = {}\n for (const key of Object.keys(raw)) {\n if (reserved.has(key) || key.startsWith('onVnode')) {\n continue\n }\n if (/^on[A-Z]/.test(key)) {\n // `update:query` and `update:columns`, `.once` included, are emitted\n // by DataTable itself.\n if (!/^onUpdate:(query|columns)/.test(key)) {\n out[key] = raw[key]\n }\n continue\n }\n const name = camelize(key)\n if (own.has(name)) {\n continue\n }\n if (name in declared) {\n out[name] = declared[name]\n } else {\n out[key] = raw[key]\n }\n }\n return out\n}\n\n// The slots QueryTable gets: the consumer's, without `error`, without\n// `pagination` when nothing is paged, and with `empty` replaced while the\n// evaluator reports an error and an `error` slot is given.\nconst showError = () => local.error.value !== null && slots.error !== undefined\nconst slotNames = () =>\n Object.keys(slots).filter(\n name =>\n name !== 'error' &&\n !(name === 'pagination' && !props.paginate) &&\n !(name === 'empty' && showError())\n ) as Array<keyof DataTableSlots<T>>\n\nconst table = useTemplateRef<QueryTableExpose>('table')\nconst exposed: QueryTableExpose = {\n collapseAll: () => table.value?.collapseAll(),\n expandAll: () => table.value?.expandAll(),\n focusFilter: field => table.value?.focusFilter(field) ?? false,\n flushPendingFilters: () => table.value?.flushPendingFilters(),\n scrollToIndex: (index, options) => table.value?.scrollToIndex(index, options),\n loadMore: () => table.value?.loadMore(),\n measureColumnWidths: fields => table.value?.measureColumnWidths(fields) ?? {}\n}\ndefineExpose(exposed)\n</script>\n\n<template>\n <QueryTable\n ref=\"table\"\n v-bind=\"passed()\"\n :columns=\"columns\"\n :query=\"query\"\n :rows=\"drawn.rows\"\n :total-rows=\"local.totalRows.value\"\n :rows-update=\"drawn.hint\"\n @update:query=\"onQuery\"\n @update:columns=\"onColumns\"\n >\n <template v-for=\"name in slotNames()\" :key=\"name\" #[name]=\"scope\">\n <slot :name=\"name\" v-bind=\"scope ?? {}\" />\n </template>\n <template v-if=\"showError()\" #empty>\n <slot name=\"error\" :error=\"local.error.value!\" />\n </template>\n </QueryTable>\n</template>\n","// `DataTable`: a table for rows held in the page, `useLocalQuery` and\n// `QueryTable` composed behind their own entry (ADR 0021, P9, P14). The\n// default entry and `/local` never import it.\nimport DataTable from './data-table.vue'\n\nexport { DataTable }\nexport default DataTable\n\nexport type {\n DataTableEmits,\n DataTableOmittedProp,\n DataTableProps,\n DataTableSlots,\n ErrorSlotProps\n} from './contract'\n"],"mappings":";;;;;;;;;;AAmCA,IAAa,iBAAiB,WAAuC;CACnE,MAAM,SAAgC,CAAC;CACvC,MAAM,KAAe,CAAC;CACtB,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,UAAU,OAAO,SAAS;EACnC,IAAI,KAAK,IAAI,OAAO,KAAK,GACvB;EAEF,KAAK,IAAI,OAAO,KAAK;EACrB,MAAM,OAAO,aAAa,MAAM;EAChC,IAAI,SAAS,MAAM;GACjB,GAAG,KAAK,OAAO,KAAK;GACpB;EACF;EACA,OAAO,KAAK;GACV,MAAM,OAAO;GACb;GACA,UAAU,OAAO,YAAY,OAAO,aAAa;GACjD,YAAY,OAAO,cAAc,OAAO,eAAe;EACzD,CAAC;CACH;CAGA,MAAM,UAAU,GAAW,MAAe,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;CACnE,OAAO,MAAM,GAAG,MAAM,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC;CAC5C,OAAO;EACL,KAAK,OAAO;EACZ,QAAQ,CAAC,GAAG,IAAI,IAA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7C,IAAA,uBAAeU"}
|
|
1
|
+
{"version":3,"file":"data-table.js","names":["_useSlots","_openBlock","_createBlock","_unref","QueryTable","_mergeProps","_createSlots","_renderList","_withCtx","_renderSlot","_normalizeProps","_guardReactiveProps","_sfc_main","DataTable"],"sources":["../src/data-table/derive-dataset.ts","../src/data-table/data-table.vue","../src/data-table/data-table.vue","../src/data-table/index.ts"],"sourcesContent":["import { columnTypeOf, type ColumnType } from '@dolusoft/query-protocol'\nimport {\n defineDataset,\n type Dataset,\n type DatasetField\n} from '@dolusoft/query-protocol/local'\n\nimport type { Column } from '../contract'\n\n/** What the dataset of a `DataTable` is built from, and nothing else (C-126). */\nexport interface DatasetSpec {\n key: string\n search: string[]\n fields: Array<{\n name: string\n type: ColumnType\n sortable: boolean\n filterable: boolean\n }>\n /** The `ip` columns, left out of the fields (C-118). */\n ip: string[]\n}\n\nexport interface DatasetSource {\n rowKey: string\n columns: readonly Column[]\n search: readonly string[] | undefined\n sortable: boolean\n filterable: boolean\n}\n\n/**\n * The spec of the columns: one field per column `field` (the first column of\n * a name wins), hidden ones included, `ip` columns left out (C-118).\n */\nexport const datasetSpecOf = (source: DatasetSource): DatasetSpec => {\n const fields: DatasetSpec['fields'] = []\n const ip: string[] = []\n const seen = new Set<string>()\n for (const column of source.columns) {\n if (seen.has(column.field)) {\n continue\n }\n seen.add(column.field)\n const type = columnTypeOf(column)\n if (type === 'ip') {\n ip.push(column.field)\n continue\n }\n fields.push({\n name: column.field,\n type,\n sortable: source.sortable && column.sortable !== false,\n filterable: source.filterable && column.filterable !== false\n })\n }\n // The order of the fields and of the search means nothing to the\n // evaluator: sorted, a reordered column list gives an equal spec.\n const byName = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0)\n fields.sort((a, b) => byName(a.name, b.name))\n return {\n key: source.rowKey,\n search: [...new Set(source.search ?? [])].sort(byName),\n fields,\n ip: ip.sort(byName)\n }\n}\n\n/** Equal specs build the same dataset. */\nexport const sameSpec = (a: DatasetSpec, b: DatasetSpec): boolean =>\n JSON.stringify(a) === JSON.stringify(b)\n\n/** The dataset of a spec. Throws a `TypeError` for a malformed one (C-126). */\nexport const datasetOf = <T>(spec: DatasetSpec): Dataset<T> => {\n // QueryTable reads `row[rowKey]` (C-26) while the evaluator reads a dotted\n // path: only a top-level name means the same field to both.\n if (spec.key.includes('.')) {\n throw new TypeError(\n `DataTable: the rowKey \"${spec.key}\" is not a top-level field`\n )\n }\n // No prototype: a field named `__proto__` or `toString` stays a field.\n const fields = Object.create(null) as Record<string, DatasetField<T>>\n for (const field of spec.fields) {\n fields[field.name] = {\n type: field.type,\n sortable: field.sortable,\n filterable: field.filterable\n }\n }\n for (const name of spec.search) {\n if (!Object.prototype.hasOwnProperty.call(fields, name)) {\n throw new TypeError(\n spec.ip.includes(name)\n ? `DataTable: the search field \"${name}\" is an ip column; only string columns are searched`\n : `DataTable: the search field \"${name}\" is not a column`\n )\n }\n fields[name] = { ...fields[name], search: true }\n }\n return defineDataset<T>({ key: spec.key, fields })\n}\n","<script setup lang=\"ts\" generic=\"T extends object\">\nimport { columnTypeOf, sameQuery } from '@dolusoft/query-protocol'\nimport type { Dataset, SemanticsProfile } from '@dolusoft/query-protocol/local'\nimport {\n camelize,\n computed,\n getCurrentInstance,\n shallowRef,\n useTemplateRef,\n watch\n} from 'vue'\n\nimport type { DataTableEmits, DataTableProps, DataTableSlots } from './contract'\nimport {\n datasetOf,\n datasetSpecOf,\n sameSpec,\n type DatasetSpec\n} from './derive-dataset'\nimport type {\n Column,\n ColumnChangeReason,\n QueryChangeReason,\n QueryTableExpose,\n RowsUpdate,\n TableQuery\n} from '../contract'\nimport { QueryTable } from '../index'\nimport { useLocalQuery } from '../local'\n\n// `useLocalQuery` and `QueryTable` side by side (ADR 0021, K319-1): no\n// markup, no table state and no table behavior of its own.\ndefineOptions({ name: 'DataTable', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<DataTableProps<T>>(), {\n query: undefined,\n profile: 'tr-2',\n search: undefined,\n paginate: true,\n dataset: undefined\n})\n\nconst emit = defineEmits<DataTableEmits<T>>()\n\nconst slots = defineSlots<DataTableSlots<T>>()\n\n// The query (C-125): the consumer's when given, else held here. Until the\n// first update the held query is the start query, which follows\n// `pageSizeOptions`; while the consumer gives one, the held query is dropped.\nconst start = computed<TableQuery>(previous => {\n const pageSize = props.pagination?.pageSizeOptions?.[0] ?? 10\n return previous?.pageSize === pageSize\n ? previous\n : { page: 1, pageSize, sort: null, filters: [] }\n})\nconst held = shallowRef<TableQuery | null>(null)\nwatch(\n () => props.query !== undefined,\n given => {\n if (given) {\n held.value = null\n }\n }\n)\nconst query = computed(() => props.query ?? held.value ?? start.value)\nconst onQuery = (next: TableQuery, reason: QueryChangeReason) => {\n if (props.query === undefined) {\n held.value = next\n }\n emit('update:query', next, reason)\n}\n\n// The dataset (C-126): built again only when what it is built from changes,\n// compared by value.\nconst spec = computed<DatasetSpec>(previous => {\n const next = datasetSpecOf({\n rowKey: props.rowKey,\n columns: props.columns,\n search: props.search,\n sortable: props.sortable,\n filterable: props.filterable\n })\n return previous && sameSpec(previous, next) ? previous : next\n})\nconst derived = computed(() => datasetOf<T>(spec.value))\nconst dataset = computed(() => props.dataset ?? derived.value)\n\nconst local = useLocalQuery<T>({\n allRows: () => props.rows,\n query,\n dataset,\n // Read on every evaluation, so a new profile evaluates again.\n get profile() {\n return props.profile\n },\n paginate: () => props.paginate\n})\n\n// The flash hint (C-124): a new context is a snapshot; a new page in the\n// same context comes from the source. The query is compared by value, so a\n// new but equal query object is the same context.\ninterface Context {\n query: TableQuery\n dataset: Dataset<T>\n profile: SemanticsProfile\n paginate: boolean\n}\nconst drawn = computed<{ rows: T[]; hint: RowsUpdate; context: Context }>(\n previous => {\n const context: Context = {\n query: query.value,\n dataset: dataset.value,\n profile: props.profile,\n paginate: props.paginate\n }\n const before = previous?.context\n const same =\n before !== undefined &&\n sameQuery(before.query, context.query) &&\n before.dataset === context.dataset &&\n before.profile === context.profile &&\n before.paginate === context.paginate\n return { rows: local.rows.value, hint: same ? 'live' : 'snapshot', context }\n }\n)\n\n// An `ip` column is not a field (C-118, C-126), so the table offers no sort\n// and no filter on it. `update:columns` gives the consumer's own `sortable`\n// and `filterable` back, so the change never reaches the consumer's columns.\nconst isIp = (column: Column) => columnTypeOf(column) === 'ip'\nconst closed = (column: Column) =>\n isIp(column) && (column.sortable !== false || column.filterable !== false)\nconst columns = computed(() =>\n props.columns.some(closed)\n ? props.columns.map(column =>\n closed(column)\n ? { ...column, sortable: false, filterable: false }\n : column\n )\n : props.columns\n)\nconst onColumns = (next: Column[], reason: ColumnChangeReason) => {\n const drawnColumns = columns.value\n const originals = new Map(\n props.columns.filter(closed).map(column => [column.field, column])\n )\n const restored = next.map(column => {\n const original = originals.get(column.field)\n if (!original || !isIp(column)) {\n return column\n }\n if (drawnColumns.includes(column)) {\n return original\n }\n const copy: Column = { ...column }\n for (const key of ['sortable', 'filterable'] as const) {\n if (key in original) {\n copy[key] = original[key]\n } else {\n delete copy[key]\n }\n }\n return copy\n })\n emit('update:columns', restored, reason)\n}\n\n// What the consumer gave reaches QueryTable as given; what it left out is\n// left out, so QueryTable applies its own default (C-124). A declared prop\n// is passed as Vue read it (`sortable=\"\"` is `true`); any other attribute\n// keeps its name (`data-testid`, `aria-label`).\nconst instance = getCurrentInstance()!\nconst own = new Set([\n 'columns',\n 'query',\n 'rows',\n 'profile',\n 'search',\n 'paginate',\n 'dataset',\n 'totalRows',\n 'cursors',\n 'infinite',\n 'rowsUpdate'\n])\nconst reserved = new Set(['key', 'ref', 'ref_for', 'ref_key'])\nconst passed = (): Record<string, unknown> => {\n const raw = instance.vnode.props ?? {}\n const declared = props as Record<string, unknown>\n const out: Record<string, unknown> = {}\n for (const key of Object.keys(raw)) {\n if (reserved.has(key) || key.startsWith('onVnode')) {\n continue\n }\n if (/^on[A-Z]/.test(key)) {\n // `update:query` and `update:columns`, `.once` included, are emitted\n // by DataTable itself.\n if (!/^onUpdate:(query|columns)/.test(key)) {\n out[key] = raw[key]\n }\n continue\n }\n const name = camelize(key)\n if (own.has(name)) {\n continue\n }\n if (name in declared) {\n out[name] = declared[name]\n } else {\n out[key] = raw[key]\n }\n }\n return out\n}\n\n// The slots QueryTable gets: the consumer's, without `error`, without\n// `pagination` when nothing is paged, and with `empty` replaced while the\n// evaluator reports an error and an `error` slot is given.\nconst showError = () => local.error.value !== null && slots.error !== undefined\nconst slotNames = () =>\n Object.keys(slots).filter(\n name =>\n name !== 'error' &&\n !(name === 'pagination' && !props.paginate) &&\n !(name === 'empty' && showError())\n ) as Array<keyof DataTableSlots<T>>\n\nconst table = useTemplateRef<QueryTableExpose>('table')\nconst exposed: QueryTableExpose = {\n collapseAll: () => table.value?.collapseAll(),\n expandAll: () => table.value?.expandAll(),\n focusFilter: field => table.value?.focusFilter(field) ?? false,\n flushPendingFilters: () => table.value?.flushPendingFilters(),\n scrollToIndex: (index, options) => table.value?.scrollToIndex(index, options),\n loadMore: () => table.value?.loadMore(),\n measureColumnWidths: fields => table.value?.measureColumnWidths(fields) ?? {}\n}\ndefineExpose(exposed)\n</script>\n\n<template>\n <QueryTable\n ref=\"table\"\n v-bind=\"passed()\"\n :columns=\"columns\"\n :query=\"query\"\n :rows=\"drawn.rows\"\n :total-rows=\"local.totalRows.value\"\n :rows-update=\"drawn.hint\"\n @update:query=\"onQuery\"\n @update:columns=\"onColumns\"\n >\n <template v-for=\"name in slotNames()\" :key=\"name\" #[name]=\"scope\">\n <slot :name=\"name\" v-bind=\"scope ?? {}\" />\n </template>\n <template v-if=\"showError()\" #empty>\n <slot name=\"error\" :error=\"local.error.value!\" />\n </template>\n </QueryTable>\n</template>\n","<script setup lang=\"ts\" generic=\"T extends object\">\nimport { columnTypeOf, sameQuery } from '@dolusoft/query-protocol'\nimport type { Dataset, SemanticsProfile } from '@dolusoft/query-protocol/local'\nimport {\n camelize,\n computed,\n getCurrentInstance,\n shallowRef,\n useTemplateRef,\n watch\n} from 'vue'\n\nimport type { DataTableEmits, DataTableProps, DataTableSlots } from './contract'\nimport {\n datasetOf,\n datasetSpecOf,\n sameSpec,\n type DatasetSpec\n} from './derive-dataset'\nimport type {\n Column,\n ColumnChangeReason,\n QueryChangeReason,\n QueryTableExpose,\n RowsUpdate,\n TableQuery\n} from '../contract'\nimport { QueryTable } from '../index'\nimport { useLocalQuery } from '../local'\n\n// `useLocalQuery` and `QueryTable` side by side (ADR 0021, K319-1): no\n// markup, no table state and no table behavior of its own.\ndefineOptions({ name: 'DataTable', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<DataTableProps<T>>(), {\n query: undefined,\n profile: 'tr-2',\n search: undefined,\n paginate: true,\n dataset: undefined\n})\n\nconst emit = defineEmits<DataTableEmits<T>>()\n\nconst slots = defineSlots<DataTableSlots<T>>()\n\n// The query (C-125): the consumer's when given, else held here. Until the\n// first update the held query is the start query, which follows\n// `pageSizeOptions`; while the consumer gives one, the held query is dropped.\nconst start = computed<TableQuery>(previous => {\n const pageSize = props.pagination?.pageSizeOptions?.[0] ?? 10\n return previous?.pageSize === pageSize\n ? previous\n : { page: 1, pageSize, sort: null, filters: [] }\n})\nconst held = shallowRef<TableQuery | null>(null)\nwatch(\n () => props.query !== undefined,\n given => {\n if (given) {\n held.value = null\n }\n }\n)\nconst query = computed(() => props.query ?? held.value ?? start.value)\nconst onQuery = (next: TableQuery, reason: QueryChangeReason) => {\n if (props.query === undefined) {\n held.value = next\n }\n emit('update:query', next, reason)\n}\n\n// The dataset (C-126): built again only when what it is built from changes,\n// compared by value.\nconst spec = computed<DatasetSpec>(previous => {\n const next = datasetSpecOf({\n rowKey: props.rowKey,\n columns: props.columns,\n search: props.search,\n sortable: props.sortable,\n filterable: props.filterable\n })\n return previous && sameSpec(previous, next) ? previous : next\n})\nconst derived = computed(() => datasetOf<T>(spec.value))\nconst dataset = computed(() => props.dataset ?? derived.value)\n\nconst local = useLocalQuery<T>({\n allRows: () => props.rows,\n query,\n dataset,\n // Read on every evaluation, so a new profile evaluates again.\n get profile() {\n return props.profile\n },\n paginate: () => props.paginate\n})\n\n// The flash hint (C-124): a new context is a snapshot; a new page in the\n// same context comes from the source. The query is compared by value, so a\n// new but equal query object is the same context.\ninterface Context {\n query: TableQuery\n dataset: Dataset<T>\n profile: SemanticsProfile\n paginate: boolean\n}\nconst drawn = computed<{ rows: T[]; hint: RowsUpdate; context: Context }>(\n previous => {\n const context: Context = {\n query: query.value,\n dataset: dataset.value,\n profile: props.profile,\n paginate: props.paginate\n }\n const before = previous?.context\n const same =\n before !== undefined &&\n sameQuery(before.query, context.query) &&\n before.dataset === context.dataset &&\n before.profile === context.profile &&\n before.paginate === context.paginate\n return { rows: local.rows.value, hint: same ? 'live' : 'snapshot', context }\n }\n)\n\n// An `ip` column is not a field (C-118, C-126), so the table offers no sort\n// and no filter on it. `update:columns` gives the consumer's own `sortable`\n// and `filterable` back, so the change never reaches the consumer's columns.\nconst isIp = (column: Column) => columnTypeOf(column) === 'ip'\nconst closed = (column: Column) =>\n isIp(column) && (column.sortable !== false || column.filterable !== false)\nconst columns = computed(() =>\n props.columns.some(closed)\n ? props.columns.map(column =>\n closed(column)\n ? { ...column, sortable: false, filterable: false }\n : column\n )\n : props.columns\n)\nconst onColumns = (next: Column[], reason: ColumnChangeReason) => {\n const drawnColumns = columns.value\n const originals = new Map(\n props.columns.filter(closed).map(column => [column.field, column])\n )\n const restored = next.map(column => {\n const original = originals.get(column.field)\n if (!original || !isIp(column)) {\n return column\n }\n if (drawnColumns.includes(column)) {\n return original\n }\n const copy: Column = { ...column }\n for (const key of ['sortable', 'filterable'] as const) {\n if (key in original) {\n copy[key] = original[key]\n } else {\n delete copy[key]\n }\n }\n return copy\n })\n emit('update:columns', restored, reason)\n}\n\n// What the consumer gave reaches QueryTable as given; what it left out is\n// left out, so QueryTable applies its own default (C-124). A declared prop\n// is passed as Vue read it (`sortable=\"\"` is `true`); any other attribute\n// keeps its name (`data-testid`, `aria-label`).\nconst instance = getCurrentInstance()!\nconst own = new Set([\n 'columns',\n 'query',\n 'rows',\n 'profile',\n 'search',\n 'paginate',\n 'dataset',\n 'totalRows',\n 'cursors',\n 'infinite',\n 'rowsUpdate'\n])\nconst reserved = new Set(['key', 'ref', 'ref_for', 'ref_key'])\nconst passed = (): Record<string, unknown> => {\n const raw = instance.vnode.props ?? {}\n const declared = props as Record<string, unknown>\n const out: Record<string, unknown> = {}\n for (const key of Object.keys(raw)) {\n if (reserved.has(key) || key.startsWith('onVnode')) {\n continue\n }\n if (/^on[A-Z]/.test(key)) {\n // `update:query` and `update:columns`, `.once` included, are emitted\n // by DataTable itself.\n if (!/^onUpdate:(query|columns)/.test(key)) {\n out[key] = raw[key]\n }\n continue\n }\n const name = camelize(key)\n if (own.has(name)) {\n continue\n }\n if (name in declared) {\n out[name] = declared[name]\n } else {\n out[key] = raw[key]\n }\n }\n return out\n}\n\n// The slots QueryTable gets: the consumer's, without `error`, without\n// `pagination` when nothing is paged, and with `empty` replaced while the\n// evaluator reports an error and an `error` slot is given.\nconst showError = () => local.error.value !== null && slots.error !== undefined\nconst slotNames = () =>\n Object.keys(slots).filter(\n name =>\n name !== 'error' &&\n !(name === 'pagination' && !props.paginate) &&\n !(name === 'empty' && showError())\n ) as Array<keyof DataTableSlots<T>>\n\nconst table = useTemplateRef<QueryTableExpose>('table')\nconst exposed: QueryTableExpose = {\n collapseAll: () => table.value?.collapseAll(),\n expandAll: () => table.value?.expandAll(),\n focusFilter: field => table.value?.focusFilter(field) ?? false,\n flushPendingFilters: () => table.value?.flushPendingFilters(),\n scrollToIndex: (index, options) => table.value?.scrollToIndex(index, options),\n loadMore: () => table.value?.loadMore(),\n measureColumnWidths: fields => table.value?.measureColumnWidths(fields) ?? {}\n}\ndefineExpose(exposed)\n</script>\n\n<template>\n <QueryTable\n ref=\"table\"\n v-bind=\"passed()\"\n :columns=\"columns\"\n :query=\"query\"\n :rows=\"drawn.rows\"\n :total-rows=\"local.totalRows.value\"\n :rows-update=\"drawn.hint\"\n @update:query=\"onQuery\"\n @update:columns=\"onColumns\"\n >\n <template v-for=\"name in slotNames()\" :key=\"name\" #[name]=\"scope\">\n <slot :name=\"name\" v-bind=\"scope ?? {}\" />\n </template>\n <template v-if=\"showError()\" #empty>\n <slot name=\"error\" :error=\"local.error.value!\" />\n </template>\n </QueryTable>\n</template>\n","// `DataTable`: a table for rows held in the page, `useLocalQuery` and\n// `QueryTable` composed behind their own entry (ADR 0021, P9, P14). The\n// default entry and `/local` never import it.\nimport DataTable from './data-table.vue'\n\nexport { DataTable }\nexport default DataTable\n\nexport type {\n DataTableEmits,\n DataTableOmittedProp,\n DataTableProps,\n DataTableSlots,\n ErrorSlotProps\n} from './contract'\n"],"mappings":";;;;;;;;;;AAmCA,IAAa,iBAAiB,WAAuC;CACnE,MAAM,SAAgC,CAAC;CACvC,MAAM,KAAe,CAAC;CACtB,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,UAAU,OAAO,SAAS;EACnC,IAAI,KAAK,IAAI,OAAO,KAAK,GACvB;EAEF,KAAK,IAAI,OAAO,KAAK;EACrB,MAAM,OAAO,aAAa,MAAM;EAChC,IAAI,SAAS,MAAM;GACjB,GAAG,KAAK,OAAO,KAAK;GACpB;EACF;EACA,OAAO,KAAK;GACV,MAAM,OAAO;GACb;GACA,UAAU,OAAO,YAAY,OAAO,aAAa;GACjD,YAAY,OAAO,cAAc,OAAO,eAAe;EACzD,CAAC;CACH;CAGA,MAAM,UAAU,GAAW,MAAe,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;CACnE,OAAO,MAAM,GAAG,MAAM,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC;CAC5C,OAAO;EACL,KAAK,OAAO;EACZ,QAAQ,CAAC,GAAG,IAAI,IAAI,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM;EACrD;EACA,IAAI,GAAG,KAAK,MAAM;CACpB;AACF;;AAGA,IAAa,YAAY,GAAgB,MACvC,KAAK,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC;;AAG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AAS,WAAW,UAAU,EACpC;EAEF,MAAM,QAAQ,eAAiC,OAAO;EAUtD,SAAa;GARX,mBAAmB,MAAM,OAAO,YAAY;GAC5C,iBAAiB,MAAM,OAAO,UAAU;GACxC,cAAa,UAAS,MAAM,OAAO,YAAY,KAAK,KAAK;GACzD,2BAA2B,MAAM,OAAO,oBAAoB;GAC5D,gBAAgB,OAAO,YAAY,MAAM,OAAO,cAAc,OAAO,OAAO;GAC5E,gBAAgB,MAAM,OAAO,SAAS;GACtC,sBAAqB,WAAU,MAAM,OAAO,oBAAoB,MAAM,KAAK,CAAC;EAEjE,CAAO;;GAIlB,OAAAC,UAAA,GAAAC,YAiBaC,MAAAC,mBAAA,GAjBbC,WAiBa;IAhBP,SAAA;IAAJ,KAAI;GACI,GAAA,OAAM,GAAA;IACb,SAAS,QAAA;IACT,OAAO,MAAA;IACP,MAAM,MAAA,MAAM;IACZ,cAAYF,MAAA,KAAA,CAAK,CAAC,UAAU;IAC5B,eAAa,MAAA,MAAM;IACnB,kBAAc;IACd,oBAAgB;GAEQI,CAAAA,GAAAA,YAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,WAAA,UAAS,IAAjB,SAAI;;KAA8B;KACjD,IAAAC,SADyD,UAAK,CAC9DC,WAA0C,KAAA,QAA7B,MAAIC,eAAAC,mBAAU,SAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;GAElB,CAAA,GAAA,UAAS,IAAA;IAAK,MAAA;IAC5B,IAAAH,cAAiD,CAAjDC,WAAiD,KAAA,QAAA,SAAA,EAA7B,OAAON,MAAA,KAAA,CAAK,CAAC,MAAM,MAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;AE1P7C,IAAA,uBAAeU"}
|
package/dist/query-table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as useQueryTable, n as parseFilterInput, r as query_table_default, t as src_default } from "./src-
|
|
1
|
+
import { i as useQueryTable, n as parseFilterInput, r as query_table_default, t as src_default } from "./src-DvUx4ur-.js";
|
|
2
2
|
export { query_table_default as QueryTable, src_default as default, parseFilterInput, useQueryTable };
|