@dolusoft/query-table 3.19.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 ADDED
@@ -0,0 +1,203 @@
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
+ //#region src/cells/cell-action.vue?vue&type=script&setup=true&lang.ts
4
+ var _hoisted_1$6 = ["data-kind"];
5
+ //#endregion
6
+ //#region src/cells/cell-action.vue
7
+ var cell_action_default = /* @__PURE__ */ defineComponent({
8
+ name: "CellAction",
9
+ __name: "cell-action",
10
+ props: { kind: { default: "default" } },
11
+ setup(__props) {
12
+ return (_ctx, _cache) => {
13
+ return openBlock(), createElementBlock("button", {
14
+ type: "button",
15
+ class: "qt-cell-action",
16
+ "data-kind": __props.kind
17
+ }, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_1$6);
18
+ };
19
+ }
20
+ });
21
+ //#endregion
22
+ //#region src/cells/cell-actions.vue?vue&type=script&setup=true&lang.ts
23
+ var _hoisted_1$5 = { class: "qt-cell-actions" };
24
+ //#endregion
25
+ //#region src/cells/cell-actions.vue
26
+ var cell_actions_default = /* @__PURE__ */ defineComponent({
27
+ name: "CellActions",
28
+ __name: "cell-actions",
29
+ setup(__props) {
30
+ return (_ctx, _cache) => {
31
+ return openBlock(), createElementBlock("span", _hoisted_1$5, [renderSlot(_ctx.$slots, "default")]);
32
+ };
33
+ }
34
+ });
35
+ //#endregion
36
+ //#region src/cells/cell-badge.vue?vue&type=script&setup=true&lang.ts
37
+ var _hoisted_1$4 = ["data-tone"];
38
+ //#endregion
39
+ //#region src/cells/cell-badge.vue
40
+ var cell_badge_default = /* @__PURE__ */ defineComponent({
41
+ name: "CellBadge",
42
+ __name: "cell-badge",
43
+ props: {
44
+ text: { default: void 0 },
45
+ tone: { default: "neutral" }
46
+ },
47
+ setup(__props) {
48
+ return (_ctx, _cache) => {
49
+ return openBlock(), createElementBlock("span", {
50
+ class: "qt-cell-badge",
51
+ "data-tone": __props.tone
52
+ }, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.text), 1)])], 8, _hoisted_1$4);
53
+ };
54
+ }
55
+ });
56
+ //#endregion
57
+ //#region src/cells/cell-copy.vue?vue&type=script&setup=true&lang.ts
58
+ var _hoisted_1$3 = { class: "qt-cell-copy" };
59
+ var _hoisted_2$2 = { class: "qt-cell-copy-text" };
60
+ var _hoisted_3$2 = ["aria-label", "title"];
61
+ //#endregion
62
+ //#region src/cells/cell-copy.vue
63
+ var cell_copy_default = /* @__PURE__ */ defineComponent({
64
+ name: "CellCopy",
65
+ __name: "cell-copy",
66
+ props: { value: {} },
67
+ emits: ["copy"],
68
+ setup(__props, { emit: __emit }) {
69
+ const props = __props;
70
+ const emit = __emit;
71
+ const labels = useCellLabels();
72
+ const text = () => String(props.value);
73
+ const name = computed(() => labels().copyValue(text()));
74
+ return (_ctx, _cache) => {
75
+ return openBlock(), createElementBlock("span", _hoisted_1$3, [createElementVNode("code", _hoisted_2$2, toDisplayString(__props.value), 1), createElementVNode("button", {
76
+ type: "button",
77
+ class: "qt-cell-copy-button",
78
+ "aria-label": name.value,
79
+ title: name.value,
80
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("copy", text()))
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)]);
102
+ };
103
+ }
104
+ });
105
+ //#endregion
106
+ //#region src/cells/cell-preview.vue?vue&type=script&setup=true&lang.ts
107
+ var _hoisted_1$2 = { class: "qt-cell-preview" };
108
+ var _hoisted_2$1 = { class: "qt-cell-preview-text" };
109
+ var _hoisted_3$1 = ["aria-label", "title"];
110
+ //#endregion
111
+ //#region src/cells/cell-preview.vue
112
+ var cell_preview_default = /* @__PURE__ */ defineComponent({
113
+ name: "CellPreview",
114
+ __name: "cell-preview",
115
+ props: { text: {} },
116
+ emits: ["preview"],
117
+ setup(__props, { emit: __emit }) {
118
+ const props = __props;
119
+ const emit = __emit;
120
+ const labels = useCellLabels();
121
+ const value = () => String(props.text);
122
+ const name = computed(() => labels().previewValue(value()));
123
+ return (_ctx, _cache) => {
124
+ return openBlock(), createElementBlock("span", _hoisted_1$2, [createElementVNode("span", _hoisted_2$1, toDisplayString(__props.text), 1), createElementVNode("button", {
125
+ type: "button",
126
+ class: "qt-cell-preview-button",
127
+ "aria-label": name.value,
128
+ title: name.value,
129
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("preview", value()))
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)]);
149
+ };
150
+ }
151
+ });
152
+ //#endregion
153
+ //#region src/cells/cell-stack.vue?vue&type=script&setup=true&lang.ts
154
+ var _hoisted_1$1 = { class: "qt-cell-stack" };
155
+ var _hoisted_2 = { class: "qt-cell-primary" };
156
+ var _hoisted_3 = {
157
+ key: 0,
158
+ class: "qt-cell-secondary"
159
+ };
160
+ //#endregion
161
+ //#region src/cells/cell-stack.vue
162
+ var cell_stack_default = /* @__PURE__ */ defineComponent({
163
+ name: "CellStack",
164
+ __name: "cell-stack",
165
+ props: {
166
+ primary: {},
167
+ secondary: {}
168
+ },
169
+ setup(__props) {
170
+ const props = __props;
171
+ const slots = useSlots();
172
+ const hasSecondary = () => slots.secondary !== void 0 || props.secondary !== void 0 && props.secondary !== null && props.secondary !== "";
173
+ return (_ctx, _cache) => {
174
+ return openBlock(), createElementBlock("span", _hoisted_1$1, [createElementVNode("span", _hoisted_2, [renderSlot(_ctx.$slots, "primary", {}, () => [createTextVNode(toDisplayString(__props.primary), 1)])]), hasSecondary() ? (openBlock(), createElementBlock("span", _hoisted_3, [renderSlot(_ctx.$slots, "secondary", {}, () => [createTextVNode(toDisplayString(__props.secondary), 1)])])) : createCommentVNode("", true)]);
175
+ };
176
+ }
177
+ });
178
+ //#endregion
179
+ //#region src/cells/cell-value.vue?vue&type=script&setup=true&lang.ts
180
+ var _hoisted_1 = {
181
+ key: 0,
182
+ class: "qt-cell-empty"
183
+ };
184
+ //#endregion
185
+ //#region src/cells/cell-value.vue
186
+ var cell_value_default = /* @__PURE__ */ defineComponent({
187
+ name: "CellValue",
188
+ inheritAttrs: false,
189
+ __name: "cell-value",
190
+ props: { value: {} },
191
+ setup(__props) {
192
+ const props = __props;
193
+ const labels = useCellLabels();
194
+ const empty = () => props.value === null || props.value === void 0 || props.value === "";
195
+ return (_ctx, _cache) => {
196
+ return empty() ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(unref(labels)().emptyValue), 1)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(String(__props.value)), 1)], 64));
197
+ };
198
+ }
199
+ });
200
+ //#endregion
201
+ export { cell_action_default as CellAction, cell_actions_default as CellActions, cell_badge_default as CellBadge, cell_copy_default as CellCopy, cell_preview_default as CellPreview, cell_stack_default as CellStack, cell_value_default as CellValue };
202
+
203
+ //# sourceMappingURL=cells.js.map
@@ -0,0 +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","_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(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;;;;;;;;;;;;;;;;;EEVlB,MAAM,QAAQ;EAEd,MAAM,OAAO;EAKb,MAAM,SAAS,cAAc;EAC7B,MAAM,aAAa,OAAO,MAAM,KAAK;EAErC,MAAM,OAAO,eAAe,OAAO,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC;;GAIpD,OAAAK,UAAA,GAAAC,mBA4BO,QA5BPJ,cA4BO,CA3BLK,mBAAkD,QAAlDJ,cAAkDK,gBAAf,QAAA,KAAK,GAAA,CAAA,GACxCD,mBAyBS,UAAA;IAxBP,MAAK;IACL,OAAM;IACL,cAAY,KAAA;IACZ,OAAO,KAAA;IACP,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,QAAS,KAAI,CAAA;GAGzBE,GAAAA,CAAAA,YAgBYC,MAAA,QAAA,GAAA,EAhBD,MAAK,OAAM,GAAA;IACpB,SAAAC,c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;;;;;;;;;;;;;;;;;EE3ClC,MAAM,QAAQ;EAEd,MAAM,QAAQO,SAAA;EAOd,MAAM,qBACJ,MAAM,cAAc,KAAA,KACnB,MAAM,cAAc,KAAA,KACnB,MAAM,cAAc,QACpB,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"}
@@ -1,4 +1,4 @@
1
- import { r as query_table_default } from "./src-BTIXBmwM.js";
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: {},
@@ -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,G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;;;;;;;;AE1P7C,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,CAA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EAAE,SAAS,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"}
@@ -1,2 +1,2 @@
1
- import { i as useQueryTable, n as parseFilterInput, r as query_table_default, t as src_default } from "./src-BTIXBmwM.js";
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 };