@juit/vue-z 0.0.70 → 0.0.72

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/index.css CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  /* Suffix behind the input */
34
34
  .z-suffix {
35
- &[data-v-7f2feeca] {
35
+ &[data-v-8db93553] {
36
36
  user-select: none;
37
37
  position: absolute;
38
38
  top: 0;
@@ -42,9 +42,9 @@
42
42
  overflow: hidden;
43
43
  font-weight: 500
44
44
  }
45
- .z-suffix-hidden[data-v-7f2feeca] { color: transparent
45
+ .z-suffix-hidden[data-v-8db93553] { color: transparent
46
46
  }
47
- .z-suffix-visible[data-v-7f2feeca] { opacity: 0.5
47
+ .z-suffix-visible[data-v-8db93553] { opacity: 0.5
48
48
  }
49
49
  }
50
50
 
@@ -114,17 +114,17 @@
114
114
  }
115
115
 
116
116
  /* Let padding be done by a.table-link */
117
- td.q-td[data-v-c1278c50]:has(a.table-link) {
117
+ td.q-td[data-v-719597a3]:has(a.table-link) {
118
118
  padding: 0;
119
119
  vertical-align: top;
120
120
  }
121
- td.q-td.shrink[data-v-c1278c50] {
121
+ td.q-td.shrink[data-v-719597a3] {
122
122
  width: 1px;
123
123
  }
124
124
 
125
125
  /* Turn an "<a href=...>" into a glorified div */
126
126
  a.table-link {
127
- &[data-v-c1278c50] {
127
+ &[data-v-719597a3] {
128
128
  display: block;
129
129
  color: inherit;
130
130
  text-decoration: none;
@@ -134,7 +134,7 @@ a.table-link {
134
134
 
135
135
  /* center the content vertically */
136
136
  }
137
- > div[data-v-c1278c50] {
137
+ > div[data-v-719597a3] {
138
138
  position: relative;
139
139
  transform: translateY(-50%);
140
140
  top: 50%;
@@ -145,39 +145,39 @@ a.table-link {
145
145
  }
146
146
 
147
147
  /* Remove the top border from the "no-data" bottom slot */
148
- [data-v-c1278c50] .q-table__bottom--nodata {
148
+ [data-v-719597a3] .q-table__bottom--nodata {
149
149
  border-top: none;
150
150
  }
151
151
 
152
152
  /* Colorize loading in the primary color */
153
- [data-v-c1278c50] .q-linear-progress {
153
+ [data-v-719597a3] .q-linear-progress {
154
154
  color: var(--q-primary) !important;
155
155
  }
156
156
 
157
157
  /* Add padding for each cell (basically, cloned the quasar defaults) */
158
- td.q-td a.table-link[data-v-c1278c50] {
158
+ td.q-td a.table-link[data-v-719597a3] {
159
159
  padding: 7px 16px;
160
160
  }
161
- .q-table--dense td.q-td a.table-link[data-v-c1278c50] {
161
+ .q-table--dense td.q-td a.table-link[data-v-719597a3] {
162
162
  padding: 4px 8px;
163
163
  }
164
- .q-table--dense td.q-td:first-child a.table-link[data-v-c1278c50] {
164
+ .q-table--dense td.q-td:first-child a.table-link[data-v-719597a3] {
165
165
  padding-left: 16px;
166
166
  }
167
- .q-table--dense td.q-td:last-child a.table-link[data-v-c1278c50] {
167
+ .q-table--dense td.q-td:last-child a.table-link[data-v-719597a3] {
168
168
  padding-right: 16px;
169
169
  }
170
170
 
171
171
  /* Constrain padding for the table top */
172
- [data-v-c1278c50] .q-table__top {
172
+ [data-v-719597a3] .q-table__top {
173
173
  padding: 12px 16px;
174
174
  }
175
- .q-table--dense[data-v-c1278c50] .q-table__top {
175
+ .q-table--dense[data-v-719597a3] .q-table__top {
176
176
  padding: 12px 16px;
177
177
  }
178
178
 
179
179
  /* Default width for search and other inputs */
180
- .z-table-controls[data-v-c1278c50] .q-input {
180
+ .z-table-controls[data-v-719597a3] .q-input {
181
181
  width: 200px;
182
182
  }
183
183
 
@@ -295,6 +295,7 @@ td.q-td a.table-link[data-v-c1278c50] {
295
295
 
296
296
  &:hover {
297
297
  z-index: 1; /* Remains hovered over other overlapping clickable icons */
298
+ opacity: 1; /* Remove transparency on hover */
298
299
  background-color: var(--q-shade-primary);
299
300
  border: 1px solid var(--q-border-color);
300
301
  border-radius: calc(var(--q-border-radius) * 0.75);
package/dist/index.d.ts CHANGED
@@ -1591,6 +1591,12 @@ type: BooleanConstructor;
1591
1591
  required: false;
1592
1592
  default: boolean;
1593
1593
  };
1594
+ /** Autofocus on initial render */
1595
+ autofocus: {
1596
+ type: BooleanConstructor;
1597
+ required: false;
1598
+ default: boolean;
1599
+ };
1594
1600
  /** Indicates that the field is required (and errors when empty). */
1595
1601
  required: {
1596
1602
  type: BooleanConstructor;
@@ -1761,6 +1767,12 @@ type: BooleanConstructor;
1761
1767
  required: false;
1762
1768
  default: boolean;
1763
1769
  };
1770
+ /** Autofocus on initial render */
1771
+ autofocus: {
1772
+ type: BooleanConstructor;
1773
+ required: false;
1774
+ default: boolean;
1775
+ };
1764
1776
  /** Indicates that the field is required (and errors when empty). */
1765
1777
  required: {
1766
1778
  type: BooleanConstructor;
@@ -1833,6 +1845,7 @@ debounce: number | undefined;
1833
1845
  suffix: string;
1834
1846
  prefix: string;
1835
1847
  raw: boolean;
1848
+ autofocus: boolean;
1836
1849
  maxLength: number;
1837
1850
  rules: ValidationRule<string>[];
1838
1851
  clearable: boolean;
@@ -2199,7 +2212,6 @@ readonly default: undefined;
2199
2212
  };
2200
2213
  modelValue: {
2201
2214
  type: PropType<ZTableState>;
2202
- required: true;
2203
2215
  };
2204
2216
  selection: {
2205
2217
  type: PropType<any[]>;
@@ -2340,7 +2352,6 @@ readonly default: undefined;
2340
2352
  };
2341
2353
  modelValue: {
2342
2354
  type: PropType<ZTableState>;
2343
- required: true;
2344
2355
  };
2345
2356
  selection: {
2346
2357
  type: PropType<any[]>;
@@ -5014,11 +5025,21 @@ declare type __VLS_Slots_20 = {
5014
5025
  };
5015
5026
 
5016
5027
  declare type __VLS_Slots_21 = {
5028
+ /** Those are _normal_ data slots (that is, within a fully rendered "<q-td>") */
5017
5029
  [key: `data-${string}`]: (props: {
5018
5030
  index: number;
5019
5031
  row: any;
5020
5032
  value: any;
5021
5033
  }) => VNode[];
5034
+ /** Slot to completely replace the whole "<q-td>" (not even "rowLink" will work) */
5035
+ [key: `cell-${string}`]: (props: {
5036
+ index: number;
5037
+ row: any;
5038
+ col: any;
5039
+ value: any;
5040
+ rowLink: RouteLocationRaw | string | undefined;
5041
+ props: any;
5042
+ }) => VNode[];
5022
5043
  'bottom-row'?: () => VNode[];
5023
5044
  'default'?: () => VNode[];
5024
5045
  };
@@ -5251,8 +5272,8 @@ export declare function createBoundTableState<T extends {
5251
5272
  [k: string]: ZQueryReactiveDef & {
5252
5273
  isFilter?: boolean;
5253
5274
  };
5254
- } = {}>(options: {
5255
- length: number;
5275
+ } = {}>(options?: {
5276
+ length?: number;
5256
5277
  sort?: string;
5257
5278
  desc?: boolean;
5258
5279
  extra?: T;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QBtnDropdown, QTooltip, QBtnGroup, QBtn, QList, patterns, QInput, QIcon, useDialogPluginComponent, QDialog, QCard, QCardSection, QCardActions, QSeparator, QLinearProgress, QForm, QSelect, QItem, QItemSection, QSpinner, QItemLabel, QPopupProxy, QDate, QChip, is, useQuasar, QTr, QTh, QCheckbox, QTable, QTd, Dialog, Quasar } from "quasar";
2
- import { defineComponent, ref, useSlots, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, createCommentVNode, createElementBlock, Fragment, createTextVNode, toDisplayString, inject, reactive, watch, triggerRef, onBeforeUnmount, provide, shallowRef, computed, normalizeProps, guardReactiveProps, useModel, createVNode, normalizeClass, mergeModels, onMounted, createElementVNode, withModifiers, createSlots, renderList, normalizeStyle, nextTick, useAttrs, warn, toRaw, h, getCurrentScope } from "vue";
2
+ import { defineComponent, ref, useSlots, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, createCommentVNode, createElementBlock, Fragment, createTextVNode, toDisplayString, inject, reactive, watch, triggerRef, onBeforeUnmount, provide, shallowRef, computed, normalizeProps, guardReactiveProps, useModel, createVNode, normalizeClass, mergeModels, onMounted, createElementVNode, withModifiers, createSlots, renderList, normalizeStyle, nextTick, useAttrs, warn, toRaw, getCurrentScope, h } from "vue";
3
3
  import { useTranslator, ISO_COUNTRIES } from "@juit/vue-i18n";
4
4
  import { RouterLink, useRouter } from "vue-router";
5
5
  const iconSet = {
@@ -943,6 +943,12 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
943
943
  required: false,
944
944
  default: false
945
945
  },
946
+ /** Autofocus on initial render */
947
+ autofocus: {
948
+ type: Boolean,
949
+ required: false,
950
+ default: false
951
+ },
946
952
  /* ===== VALIDATION ======================================================= */
947
953
  /** Indicates that the field is required (and errors when empty). */
948
954
  required: {
@@ -1021,6 +1027,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
1021
1027
  if (string !== _value.value) _value.value = string;
1022
1028
  }
1023
1029
  const _onClear = computed(() => {
1030
+ if (!_props.clearable) return void 0;
1024
1031
  if (!_props.onClear) return void 0;
1025
1032
  if (!_value.value) return void 0;
1026
1033
  return () => {
@@ -1076,6 +1083,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
1076
1083
  if (_editable.value) _props.onClick?.(event);
1077
1084
  }
1078
1085
  function _onKeydownClear(event) {
1086
+ if (!_props.clearable) return;
1079
1087
  if (!_props.onClear) return;
1080
1088
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
1081
1089
  if (altKey || ctrlKey || metaKey || shiftKey) return;
@@ -1156,6 +1164,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
1156
1164
  "hide-bottom-space": !formProps2.bottomSlots,
1157
1165
  "lazy-rules": formProps2.lazyRules,
1158
1166
  debounce: __props.debounce,
1167
+ autofocus: __props.autofocus,
1159
1168
  readonly: _inactive.value || __props.nonInteractive,
1160
1169
  disable: _disabled.value,
1161
1170
  rules: _rules.value,
@@ -1232,7 +1241,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
1232
1241
  ])) : createCommentVNode("", true)
1233
1242
  ]),
1234
1243
  _: 2
1235
- }, 1032, ["class", "input-style", "type", "label", "placeholder", "hint", "counter", "maxlength", "bottom-slots", "hide-bottom-space", "lazy-rules", "debounce", "readonly", "disable", "rules", "prefix", "model-value"])
1244
+ }, 1032, ["class", "input-style", "type", "label", "placeholder", "hint", "counter", "maxlength", "bottom-slots", "hide-bottom-space", "lazy-rules", "debounce", "autofocus", "readonly", "disable", "rules", "prefix", "model-value"])
1236
1245
  ]),
1237
1246
  _: 3
1238
1247
  }, 8, ["bottom-slots", "disabled", "editable", "lazy-rules", "readonly"])
@@ -1240,7 +1249,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
1240
1249
  };
1241
1250
  }
1242
1251
  });
1243
- const ZText = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-7f2feeca"]]);
1252
+ const ZText = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-8db93553"]]);
1244
1253
  const _sfc_main$x = /* @__PURE__ */ defineComponent({
1245
1254
  ...{ name: "ZString" },
1246
1255
  __name: "string",
@@ -2084,6 +2093,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
2084
2093
  nextTick(() => _qselect.value?.options?.length && _qselect.value?.showPopup());
2085
2094
  }));
2086
2095
  }
2096
+ text;
2087
2097
  _canceled = false;
2088
2098
  /** Cancel this autocompleter */
2089
2099
  cancel() {
@@ -5578,6 +5588,149 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5578
5588
  }
5579
5589
  });
5580
5590
  const ZObject = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-494e69f9"]]);
5591
+ function getDefaultValueFor(def, state) {
5592
+ const value = typeof def.default === "function" ? def.default({ ...state }) : def.default;
5593
+ if (def.type === Boolean) return value || false;
5594
+ return value;
5595
+ }
5596
+ function createBoundObject(definition, useRoutes = false) {
5597
+ if (!getCurrentScope()) throw new Error("No reacive scope found");
5598
+ const object = reactive({});
5599
+ const defs = {};
5600
+ for (const [key, def] of Object.entries(definition)) {
5601
+ object[key] = getDefaultValueFor(def, object);
5602
+ const type = def.type || def;
5603
+ const useRoute = def.useRoute === false ? false : useRoutes;
5604
+ if (type === String || type === Number || type === Boolean) {
5605
+ defs[key] = { type, useRoute, default: def.default };
5606
+ continue;
5607
+ }
5608
+ throw new Error(`Invalid constructor definition "${key}": ${type}`);
5609
+ }
5610
+ if (!useRoutes) return object;
5611
+ const router = useRouter();
5612
+ watch(() => router.currentRoute.value.query, (query) => {
5613
+ for (const [key, def] of Object.entries(defs)) {
5614
+ if (!def.useRoute) continue;
5615
+ const defaultValue = getDefaultValueFor(defs[key], object);
5616
+ const string = Array.isArray(query[key]) ? query[key][0] : query[key];
5617
+ if (def.type === String) {
5618
+ const value = string || defaultValue;
5619
+ if (object[key] !== value) object[key] = value;
5620
+ continue;
5621
+ }
5622
+ if (def.type === Number) {
5623
+ let value = string ? Number(string) : defaultValue;
5624
+ if (typeof value !== "number" || isNaN(value)) value = defaultValue;
5625
+ if (object[key] !== value) object[key] = value;
5626
+ continue;
5627
+ }
5628
+ if (def.type === Boolean) {
5629
+ const value = string === null ? true : (
5630
+ // "?value&"
5631
+ string === "true" ? true : (
5632
+ // "?value=t&"
5633
+ string === "t" ? true : (
5634
+ // "?value=true&"
5635
+ string === "false" ? false : (
5636
+ // "?value=f&"
5637
+ string === "f" ? false : (
5638
+ // "?value=false&"
5639
+ defaultValue || false
5640
+ )
5641
+ )
5642
+ )
5643
+ )
5644
+ );
5645
+ if (object[key] !== value) object[key] = value;
5646
+ continue;
5647
+ }
5648
+ }
5649
+ }, { immediate: true });
5650
+ watch(object, (object2) => {
5651
+ const query = { ...router.currentRoute.value.query };
5652
+ let modified = false;
5653
+ for (const [key, def] of Object.entries(defs)) {
5654
+ if (!def.useRoute) continue;
5655
+ const defaultValue = getDefaultValueFor(defs[key], object2);
5656
+ let value;
5657
+ if (def.type === String || def.type === Number) {
5658
+ value = object2[key] === defaultValue ? void 0 : (
5659
+ // default values are omitted
5660
+ object2[key] === "" ? void 0 : (
5661
+ // empty strings (but not zeroes!!!) are omitted
5662
+ object2[key] === void 0 ? void 0 : (
5663
+ // undefineds are omitted
5664
+ object2[key] === null ? void 0 : (
5665
+ // nulls are omitted
5666
+ String(object2[key])
5667
+ )
5668
+ )
5669
+ )
5670
+ );
5671
+ } else if (def.type === Boolean) {
5672
+ value = object2[key] === defaultValue ? void 0 : (
5673
+ // default values are omitted
5674
+ object2[key] ? null : "f"
5675
+ );
5676
+ }
5677
+ if (value === query[key]) continue;
5678
+ if (value === void 0) delete query[key];
5679
+ else query[key] = value;
5680
+ modified = true;
5681
+ }
5682
+ if (modified) router.replace({ query });
5683
+ }, { immediate: true });
5684
+ return object;
5685
+ }
5686
+ const tableStateDefs = () => ({
5687
+ // remember, "q" needs to go _before_ "sort" and "desc" by default, so that
5688
+ // its value from the query can be used to set/reset the sort and order
5689
+ /** The optional free-text search to send alongside our query */
5690
+ q: { type: String, default: "", isFilter: true },
5691
+ // sort and desc go *after* q, so that q can affect their value
5692
+ /** The column to sort results on */
5693
+ sort: { type: String, isFilter: true, default: void 0 },
5694
+ /** The order for sorting (`true` for descending) */
5695
+ desc: { type: Boolean, isFilter: true, default: void 0 },
5696
+ // the rest of the properties can be in any order
5697
+ /** A flag indicating if deleted records should be included in the response */
5698
+ deleted: { type: Boolean, default: false, isFilter: true },
5699
+ /** The offset of the first result to return */
5700
+ offset: { type: Number, default: 0 },
5701
+ /** The maximum number of results to return */
5702
+ limit: { type: Number, default: 1 },
5703
+ /** The current reload count */
5704
+ reload: { type: Number, default: 0, useRoute: false }
5705
+ });
5706
+ function createBoundTableState(options = {}) {
5707
+ const { length = Number.MAX_SAFE_INTEGER, sort, desc = false, extra = {}, useRoute = false } = options;
5708
+ const defs = { ...tableStateDefs(), ...extra };
5709
+ if (length > 0) defs.limit.default = length + 1;
5710
+ if (defs.sort.default === void 0) {
5711
+ defs.sort.default = (state2) => {
5712
+ if (state2.q) return void 0;
5713
+ return sort;
5714
+ };
5715
+ }
5716
+ if (defs.desc.default === void 0) {
5717
+ defs.desc.default = (state2) => {
5718
+ if (state2.sort === sort) return desc;
5719
+ return false;
5720
+ };
5721
+ }
5722
+ const state = createBoundObject(defs, useRoute);
5723
+ watch(() => state.q, () => {
5724
+ state.sort = getDefaultValueFor(defs.sort, state);
5725
+ state.desc = getDefaultValueFor(defs.desc, state);
5726
+ });
5727
+ for (const [key, def] of Object.entries(defs)) {
5728
+ if ("isFilter" in def && def.isFilter) {
5729
+ watch(() => state[key], () => state.offset = 0);
5730
+ }
5731
+ }
5732
+ return state;
5733
+ }
5581
5734
  const tableProps = {
5582
5735
  /** Make this compact (or not!) */
5583
5736
  dense: {
@@ -6265,7 +6418,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6265
6418
  }, {
6266
6419
  "modelValue": {
6267
6420
  type: Object,
6268
- required: true
6421
+ required: false,
6422
+ default: () => createBoundTableState()
6269
6423
  },
6270
6424
  "modelModifiers": {},
6271
6425
  "selection": {
@@ -6444,26 +6598,38 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6444
6598
  _: 2
6445
6599
  }, 1024)) : createCommentVNode("", true),
6446
6600
  (openBlock(true), createElementBlock(Fragment, null, renderList(scope.cols, (col) => {
6447
- return openBlock(), createBlock(unref(QTd), {
6448
- key: col.name,
6449
- props: scope
6450
- }, {
6451
- default: withCtx(() => [
6452
- createVNode(unref(TableLink), { to: link }, {
6453
- default: withCtx(() => [
6454
- slots[`data-${col.name}`] ? (openBlock(), createElementBlock("div", _hoisted_4, [
6455
- renderSlot(_ctx.$slots, `data-${col.name}`, {
6456
- index: scope.rowIndex,
6457
- row: scope.row,
6458
- value: col.value
6459
- }, void 0, true)
6460
- ])) : (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(col.value), 1))
6461
- ]),
6462
- _: 2
6463
- }, 1032, ["to"])
6464
- ]),
6465
- _: 2
6466
- }, 1032, ["props"]);
6601
+ return openBlock(), createElementBlock(Fragment, {
6602
+ key: col.name
6603
+ }, [
6604
+ slots[`cell-${col.name}`] ? renderSlot(_ctx.$slots, `cell-${col.name}`, {
6605
+ key: 0,
6606
+ props: { ...scope, col },
6607
+ index: scope.rowIndex,
6608
+ row: scope.row,
6609
+ col,
6610
+ value: col.value,
6611
+ rowLink: link
6612
+ }, void 0, true) : (openBlock(), createBlock(unref(QTd), {
6613
+ key: 1,
6614
+ props: { ...scope, col }
6615
+ }, {
6616
+ default: withCtx(() => [
6617
+ createVNode(unref(TableLink), { to: link }, {
6618
+ default: withCtx(() => [
6619
+ slots[`data-${col.name}`] ? (openBlock(), createElementBlock("div", _hoisted_4, [
6620
+ renderSlot(_ctx.$slots, `data-${col.name}`, {
6621
+ index: scope.rowIndex,
6622
+ row: scope.row,
6623
+ value: col.value
6624
+ }, void 0, true)
6625
+ ])) : (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(col.value), 1))
6626
+ ]),
6627
+ _: 2
6628
+ }, 1032, ["to"])
6629
+ ]),
6630
+ _: 2
6631
+ }, 1032, ["props"]))
6632
+ ], 64);
6467
6633
  }), 128))
6468
6634
  ], 64);
6469
6635
  }), 128))
@@ -6580,150 +6746,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
6580
6746
  };
6581
6747
  }
6582
6748
  });
6583
- const ZTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c1278c50"]]);
6584
- function getDefaultValueFor(def, state) {
6585
- const value = typeof def.default === "function" ? def.default({ ...state }) : def.default;
6586
- if (def.type === Boolean) return value || false;
6587
- return value;
6588
- }
6589
- function createBoundObject(definition, useRoutes = false) {
6590
- if (!getCurrentScope()) throw new Error("No reacive scope found");
6591
- const object = reactive({});
6592
- const defs = {};
6593
- for (const [key, def] of Object.entries(definition)) {
6594
- object[key] = getDefaultValueFor(def, object);
6595
- const type = def.type || def;
6596
- const useRoute = def.useRoute === false ? false : useRoutes;
6597
- if (type === String || type === Number || type === Boolean) {
6598
- defs[key] = { type, useRoute, default: def.default };
6599
- continue;
6600
- }
6601
- throw new Error(`Invalid constructor definition "${key}": ${type}`);
6602
- }
6603
- if (!useRoutes) return object;
6604
- const router = useRouter();
6605
- watch(() => router.currentRoute.value.query, (query) => {
6606
- for (const [key, def] of Object.entries(defs)) {
6607
- if (!def.useRoute) continue;
6608
- const defaultValue = getDefaultValueFor(defs[key], object);
6609
- const string = Array.isArray(query[key]) ? query[key][0] : query[key];
6610
- if (def.type === String) {
6611
- const value = string || defaultValue;
6612
- if (object[key] !== value) object[key] = value;
6613
- continue;
6614
- }
6615
- if (def.type === Number) {
6616
- let value = string ? Number(string) : defaultValue;
6617
- if (typeof value !== "number" || isNaN(value)) value = defaultValue;
6618
- if (object[key] !== value) object[key] = value;
6619
- continue;
6620
- }
6621
- if (def.type === Boolean) {
6622
- const value = string === null ? true : (
6623
- // "?value&"
6624
- string === "true" ? true : (
6625
- // "?value=t&"
6626
- string === "t" ? true : (
6627
- // "?value=true&"
6628
- string === "false" ? false : (
6629
- // "?value=f&"
6630
- string === "f" ? false : (
6631
- // "?value=false&"
6632
- defaultValue || false
6633
- )
6634
- )
6635
- )
6636
- )
6637
- );
6638
- if (object[key] !== value) object[key] = value;
6639
- continue;
6640
- }
6641
- }
6642
- }, { immediate: true });
6643
- watch(object, (object2) => {
6644
- const query = { ...router.currentRoute.value.query };
6645
- let modified = false;
6646
- for (const [key, def] of Object.entries(defs)) {
6647
- if (!def.useRoute) continue;
6648
- const defaultValue = getDefaultValueFor(defs[key], object2);
6649
- let value;
6650
- if (def.type === String || def.type === Number) {
6651
- value = object2[key] === defaultValue ? void 0 : (
6652
- // default values are omitted
6653
- object2[key] === "" ? void 0 : (
6654
- // empty strings (but not zeroes!!!) are omitted
6655
- object2[key] === void 0 ? void 0 : (
6656
- // undefineds are omitted
6657
- object2[key] === null ? void 0 : (
6658
- // nulls are omitted
6659
- String(object2[key])
6660
- )
6661
- )
6662
- )
6663
- );
6664
- } else if (def.type === Boolean) {
6665
- value = object2[key] === defaultValue ? void 0 : (
6666
- // default values are omitted
6667
- object2[key] ? null : "f"
6668
- );
6669
- }
6670
- if (value === query[key]) continue;
6671
- if (value === void 0) delete query[key];
6672
- else query[key] = value;
6673
- modified = true;
6674
- }
6675
- if (modified) router.replace({ query });
6676
- }, { immediate: true });
6677
- return object;
6678
- }
6679
- const tableStateDefs = () => ({
6680
- // remember, "q" needs to go _before_ "sort" and "desc" by default, so that
6681
- // its value from the query can be used to set/reset the sort and order
6682
- /** The optional free-text search to send alongside our query */
6683
- q: { type: String, default: "", isFilter: true },
6684
- // sort and desc go *after* q, so that q can affect their value
6685
- /** The column to sort results on */
6686
- sort: { type: String, isFilter: true, default: void 0 },
6687
- /** The order for sorting (`true` for descending) */
6688
- desc: { type: Boolean, isFilter: true, default: void 0 },
6689
- // the rest of the properties can be in any order
6690
- /** A flag indicating if deleted records should be included in the response */
6691
- deleted: { type: Boolean, default: false, isFilter: true },
6692
- /** The offset of the first result to return */
6693
- offset: { type: Number, default: 0 },
6694
- /** The maximum number of results to return */
6695
- limit: { type: Number, default: 1 },
6696
- /** The current reload count */
6697
- reload: { type: Number, default: 0, useRoute: false }
6698
- });
6699
- function createBoundTableState(options) {
6700
- const { length, sort, desc = false, extra = {}, useRoute = false } = options;
6701
- const defs = { ...tableStateDefs(), ...extra };
6702
- if (length > 0) defs.limit.default = length + 1;
6703
- if (defs.sort.default === void 0) {
6704
- defs.sort.default = (state2) => {
6705
- if (state2.q) return void 0;
6706
- return sort;
6707
- };
6708
- }
6709
- if (defs.desc.default === void 0) {
6710
- defs.desc.default = (state2) => {
6711
- if (state2.sort === sort) return desc;
6712
- return false;
6713
- };
6714
- }
6715
- const state = createBoundObject(defs, useRoute);
6716
- watch(() => state.q, () => {
6717
- state.sort = getDefaultValueFor(defs.sort, state);
6718
- state.desc = getDefaultValueFor(defs.desc, state);
6719
- });
6720
- for (const [key, def] of Object.entries(defs)) {
6721
- if ("isFilter" in def && def.isFilter) {
6722
- watch(() => state[key], () => state.offset = 0);
6723
- }
6724
- }
6725
- return state;
6726
- }
6749
+ const ZTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-719597a3"]]);
6727
6750
  function JuitWidgets(app, quasarConfig = {}) {
6728
6751
  if (!quasarConfig.config) quasarConfig.config = {};
6729
6752
  if (!quasarConfig.config.loading) quasarConfig.config.loading = {};