quasar-ui-danx 0.4.61 → 0.4.68

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.4.61",
3
+ "version": "0.4.68",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -175,6 +175,7 @@ const selectedOptions = computed(() => {
175
175
  if (typeof v === "object") return v.value || v.id;
176
176
  return v;
177
177
  });
178
+
178
179
  return computedOptions.value.filter((o) => {
179
180
  return comparableValues.includes(o.value);
180
181
  });
@@ -249,7 +250,7 @@ function resolveValue(option) {
249
250
  if (!option || typeof option === "string") {
250
251
  return option;
251
252
  }
252
- let value = option.value || option.id;
253
+ let value = option.value !== undefined ? option.value : option.id;
253
254
  if (typeof props.optionValue === "string") {
254
255
  value = option[props.optionValue];
255
256
  } else if (typeof props.optionValue === "function") {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="group flex items-center flex-nowrap gap-x-1 relative">
2
+ <div class="group flex items-center flex-nowrap gap-x-2 relative">
3
3
  <ShowHideButton
4
4
  v-if="selectable"
5
5
  v-model="isSelecting"
@@ -8,7 +8,6 @@
8
8
  :saving="loading"
9
9
  :class="selectClass"
10
10
  :show-icon="selectIcon || DefaultSelectIcon"
11
- class="mr-2"
12
11
  :size="size"
13
12
  >
14
13
  <QMenu
@@ -19,14 +18,14 @@
19
18
  <div>
20
19
  <div
21
20
  v-for="option in optionsPlusSelected"
22
- :key="option.id"
21
+ :key="getId(option)"
23
22
  v-ripple
24
23
  class="cursor-pointer flex items-center relative"
25
- :class="{'bg-sky-900 hover:bg-sky-800': selected?.id === option.id, 'hover:bg-slate-600': selected?.id !== option.id}"
26
- @click="selected = option"
24
+ :class="{'bg-sky-900 hover:bg-sky-800': getId(selected) === getId(option), 'hover:bg-slate-600': getId(selected) !== getId(option)}"
25
+ @click="selected = selectionType === 'object' ? option : getId(option)"
27
26
  >
28
27
  <div class="flex-grow px-4 py-2">
29
- {{ option.name }}
28
+ {{ getName(option) }}
30
29
  </div>
31
30
  <ActionButton
32
31
  v-if="deletable"
@@ -58,12 +57,12 @@
58
57
  <template v-if="selected">
59
58
  <EditableDiv
60
59
  v-if="nameEditable"
61
- :model-value="selected.name"
60
+ :model-value="getName(selected)"
62
61
  color="slate-600"
63
62
  @update:model-value="name => $emit('update', {name})"
64
63
  />
65
64
  <template v-else>
66
- {{ selected.name }}
65
+ {{ getName(selected) }}
67
66
  </template>
68
67
  </template>
69
68
  <template v-else>
@@ -104,16 +103,17 @@ import {
104
103
  FaSolidPencil as EditIcon
105
104
  } from "danx-icon";
106
105
  import { computed, ref } from "vue";
107
- import { ActionTargetItem } from "../../../../types";
106
+ import { ActionTargetItem, LabelValueItem } from "../../../../types";
108
107
  import { ShowHideButton } from "../../../Utility/Buttons";
109
108
  import { ActionButtonProps, default as ActionButton } from "../../../Utility/Buttons/ActionButton";
110
109
  import EditableDiv from "./EditableDiv";
111
110
 
112
111
  defineEmits(["create", "update", "delete"]);
113
- const selected = defineModel<ActionTargetItem | null>("selected");
112
+ const selected = defineModel<ActionTargetItem | string | null>("selected");
114
113
  const editing = defineModel<boolean>("editing");
115
114
  const props = withDefaults(defineProps<{
116
- options: ActionTargetItem[];
115
+ options: ActionTargetItem[] | LabelValueItem[];
116
+ selectionType?: "object" | "string";
117
117
  showEdit?: boolean;
118
118
  loading?: boolean;
119
119
  selectText?: string;
@@ -137,6 +137,7 @@ const props = withDefaults(defineProps<{
137
137
  editDisabled?: boolean;
138
138
  size?: ActionButtonProps["size"];
139
139
  }>(), {
140
+ selectionType: "object",
140
141
  selectText: "",
141
142
  createText: "",
142
143
  editText: "",
@@ -154,8 +155,32 @@ const props = withDefaults(defineProps<{
154
155
  const isSelecting = ref(false);
155
156
 
156
157
  // If the selected option is not in the options list, it should be added in
157
- const optionsPlusSelected = computed(() => {
158
- if (!selected.value || props.options.find((o) => o.id === selected.value?.id)) return props.options;
158
+ const optionsPlusSelected = computed<ActionTargetItem[]>(() => {
159
+ if (!selected.value || props.options.find((o) => getId(o) === getId(selected.value))) return props.options;
159
160
  return [selected.value, ...props.options];
160
161
  });
162
+
163
+ function resolveOption(option) {
164
+ if (typeof option === "object") {
165
+ return option;
166
+ }
167
+
168
+ return props.options.find((o) => {
169
+ if (typeof o === "object") {
170
+ return getId(o) === option;
171
+ }
172
+ return o === option;
173
+ });
174
+ }
175
+
176
+ function getId(option) {
177
+ option = resolveOption(option);
178
+
179
+ return option?.id || option?.value || option?.name || option;
180
+ }
181
+
182
+ function getName(option) {
183
+ option = resolveOption(option);
184
+ return option?.name || option?.label || option?.value || option;
185
+ }
161
186
  </script>
@@ -62,6 +62,7 @@ import {
62
62
  FaSolidCopy as CopyIcon,
63
63
  FaSolidFileExport as ExportIcon,
64
64
  FaSolidFileImport as ImportIcon,
65
+ FaSolidFolder as FolderIcon,
65
66
  FaSolidMinus as MinusIcon,
66
67
  FaSolidPause as PauseIcon,
67
68
  FaSolidPencil as EditIcon,
@@ -74,7 +75,7 @@ import { computed, ref } from "vue";
74
75
  import { ActionTarget, ResourceAction } from "../../../types";
75
76
 
76
77
  export interface ActionButtonProps {
77
- type?: "trash" | "create" | "edit" | "copy" | "play" | "stop" | "pause" | "refresh" | "confirm" | "cancel" | "export" | "import" | "minus";
78
+ type?: "trash" | "create" | "edit" | "copy" | "folder" | "play" | "stop" | "pause" | "refresh" | "confirm" | "cancel" | "export" | "import" | "minus";
78
79
  color?: "red" | "blue" | "sky" | "sky-invert" | "green" | "green-invert" | "lime" | "white" | "gray" | "yellow" | "orange";
79
80
  size?: "xxs" | "xs" | "sm" | "md" | "lg";
80
81
  icon?: object | string;
@@ -190,6 +191,8 @@ const typeOptions = computed(() => {
190
191
  return { icon: EditIcon };
191
192
  case "copy":
192
193
  return { icon: CopyIcon };
194
+ case "folder":
195
+ return { icon: FolderIcon };
193
196
  case "play":
194
197
  return { icon: PlayIcon };
195
198
  case "stop":
@@ -94,9 +94,12 @@ export const request: RequestApi = {
94
94
 
95
95
  async poll(url: string, options, interval, fnUntil) {
96
96
  let response;
97
+ if (!fnUntil) {
98
+ fnUntil = (response: HttpResponse) => !!response;
99
+ }
97
100
  do {
98
101
  response = await request.call(url, options);
99
- await sleep(interval);
102
+ await sleep(interval || 1000);
100
103
  } while (!fnUntil(response));
101
104
 
102
105
  return response;
@@ -59,8 +59,7 @@ export function useActionRoutes(baseUrl: string, extend?: object): ListControlsR
59
59
  ignoreAbort: true,
60
60
  headers: {
61
61
  ...options?.headers,
62
- // @ts-expect-error This header is fine
63
- "X-Timestamp": Date.now()
62
+ "X-Timestamp": Date.now().toString()
64
63
  }
65
64
  };
66
65
  data = data || {};
@@ -1,8 +1,8 @@
1
- import { FilterGroup, ListController, ListControlsRoutes } from "src/types/controls";
2
- import { FormField } from "src/types/forms";
3
- import { TableColumn } from "src/types/tables";
4
1
  import { ComputedRef, Ref, ShallowRef, VNode } from "vue";
2
+ import { FilterGroup, ListController, ListControlsRoutes } from "./controls";
3
+ import { FormField } from "./forms";
5
4
  import { AnyObject, TypedObject } from "./shared";
5
+ import { TableColumn } from "./tables";
6
6
 
7
7
  export interface ActionTargetItem extends TypedObject {
8
8
  isSaving?: boolean;
@@ -1,5 +1,5 @@
1
- import { RequestCallOptions } from "src/types/requests";
2
1
  import { ComputedRef, Ref, ShallowRef } from "vue";
2
+ import { RequestCallOptions } from "../types";
3
3
  import { ActionOptions, ActionTargetItem, ResourceAction } from "./actions";
4
4
  import { AnyObject, LabelValueItem } from "./shared";
5
5
 
@@ -11,7 +11,7 @@ export interface RequestApi {
11
11
 
12
12
  post(url: string, data?: object, options?: RequestCallOptions): Promise<any>;
13
13
 
14
- poll(url: string, options?: RequestCallOptions, interval: number, fnUntil: (response) => boolean): Promise<any>;
14
+ poll(url: string, options?: RequestCallOptions, interval?: number, fnUntil?: (response) => boolean): Promise<any>;
15
15
  }
16
16
 
17
17
  export interface HttpResponse {
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "./tsconfig.build.json",
3
- "compilerOptions": {
4
- "paths": {
5
- "vue": [
6
- "../../gpt-manager/spa/node_modules/vue"
7
- ]
8
- }
9
- }
10
- }
11
-