quasar-ui-danx 0.4.89 → 0.4.91

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.89",
3
+ "version": "0.4.91",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -67,6 +67,7 @@ import {
67
67
  FaSolidCopy as CopyIcon,
68
68
  FaSolidDatabase as DatabaseIcon,
69
69
  FaSolidEye as ViewIcon,
70
+ FaSolidFile as DocumentIcon,
70
71
  FaSolidFileExport as ExportIcon,
71
72
  FaSolidFileImport as ImportIcon,
72
73
  FaSolidFloppyDisk as SaveIcon,
@@ -83,8 +84,8 @@ import { computed, ref } from "vue";
83
84
  import { ActionTarget, ResourceAction } from "../../../types";
84
85
 
85
86
  export interface ActionButtonProps {
86
- type?: "save" | "trash" | "back" | "create" | "edit" | "copy" | "folder" | "play" | "stop" | "pause" | "refresh" | "restart" | "confirm" | "cancel" | "export" | "import" | "minus" | "merge" | "check" | "clock" | "view" | "database";
87
- color?: "red" | "blue" | "blue-invert" | "sky" | "sky-invert" | "green" | "green-invert" | "lime" | "white" | "gray" | "slate" | "slate-invert" | "yellow" | "orange";
87
+ type?: "save" | "trash" | "back" | "create" | "edit" | "copy" | "folder" | "document" | "play" | "stop" | "pause" | "refresh" | "restart" | "confirm" | "cancel" | "export" | "import" | "minus" | "merge" | "check" | "clock" | "view" | "database";
88
+ color?: "red" | "blue" | "blue-invert" | "sky" | "sky-invert" | "green" | "green-invert" | "lime" | "white" | "gray" | "slate" | "slate-invert" | "yellow" | "orange" | "purple" | "teal" | "teal-invert";
88
89
  size?: "xxs" | "xs" | "sm" | "md" | "lg";
89
90
  icon?: object | string;
90
91
  iconClass?: string;
@@ -164,6 +165,10 @@ const colorClass = computed(() => {
164
165
  return "text-blue-900 bg-blue-300 hover:bg-blue-400";
165
166
  case "blue-invert":
166
167
  return "text-blue-300 bg-blue-900 hover:bg-blue-800";
168
+ case "teal":
169
+ return "text-teal-800 bg-teal-200 hover:bg-teal-400";
170
+ case "teal-invert":
171
+ return "text-teal-200 bg-teal-500 hover:bg-teal-600";
167
172
  case "sky":
168
173
  return "text-sky-900 bg-sky-300 hover:bg-sky-400";
169
174
  case "sky-invert":
@@ -180,6 +185,8 @@ const colorClass = computed(() => {
180
185
  return "text-slate-900 bg-slate-300 hover:bg-slate-400";
181
186
  case "slate-invert":
182
187
  return "text-slate-300 bg-slate-900 hover:bg-slate-800";
188
+ case "purple":
189
+ return "text-purple-300 bg-purple-900 hover:bg-purple-800";
183
190
  default:
184
191
  return "";
185
192
  }
@@ -211,6 +218,8 @@ const typeOptions = computed(() => {
211
218
  return { icon: CopyIcon };
212
219
  case "folder":
213
220
  return { icon: FolderIcon };
221
+ case "document":
222
+ return { icon: DocumentIcon };
214
223
  case "clock":
215
224
  return { icon: ClockIcon };
216
225
  case "play":
@@ -25,11 +25,12 @@ export function useActions(actions: ActionOptions[], globalOptions: ActionGlobal
25
25
 
26
26
  /**
27
27
  * Extend an action so the base action can be modified without affecting other places the action is used.
28
- * This isolates the action to the provided id, so it is still re-usable across the system, but does not affect behavior elsewhere.
28
+ * This isolates the action to the provided id, so it is still re-usable across the system, but does not affect
29
+ * behavior elsewhere.
29
30
  *
30
- * For example, when you have a list of items and you want to perform a callback on the action on a single item, you can extend the action
31
- * with the id of the item you want to perform the action on, allowing you to perform behavior on a single item, instead of all instances
32
- * in the list receiving the same callback.
31
+ * For example, when you have a list of items and you want to perform a callback on the action on a single item,
32
+ * you can extend the action with the id of the item you want to perform the action on, allowing you to perform
33
+ * behavior on a single item, instead of all instances in the list receiving the same callback.
33
34
  */
34
35
  function extendAction(actionName: string, extendedId: string | number, actionOptions: Partial<ActionOptions>): ResourceAction {
35
36
  const action = getAction(actionName);
@@ -134,7 +135,8 @@ export function useActions(actions: ActionOptions[], globalOptions: ActionGlobal
134
135
  confirm: async (confirmInput: any) => {
135
136
 
136
137
  // Resolve the input based on the useInputFromConfirm option
137
- // Not setting useInputFromConfirm will merge the input from the confirm dialog with the input from the action
138
+ // Not setting useInputFromConfirm will merge the input from the confirm dialog with the input
139
+ // from the action
138
140
  let resolvedInput;
139
141
  if (action.useInputFromConfirm === false) {
140
142
  resolvedInput = input;
@@ -207,7 +209,8 @@ function setTargetSavingState(target: ActionTarget, saving: boolean) {
207
209
  /**
208
210
  * Execute the confirmed action on the target (ie: calling the server, or whatever the callback function does).
209
211
  *
210
- * 1. If the action has an optimistic callback, it will be called before the actual action to immediately update the UI (non batch actions only).
212
+ * 1. If the action has an optimistic callback, it will be called before the actual action to immediately update the UI
213
+ * (non batch actions only).
211
214
  * 2. Call the onBatchAction or onAction callback of the action object, depending on if the target is an array or not.
212
215
  * 3. Call the onSuccess or onError callback based on the result of the action.
213
216
  * 4. Call the onFinish callback of the action object.
@@ -310,11 +313,11 @@ async function onConfirmAction(action: ActionOptions, target: ActionTarget, inpu
310
313
  export function withDefaultActions(label: string, listController?: ListController): ActionOptions[] {
311
314
  return [
312
315
  {
313
- name: "quick-create",
314
- alias: "create"
316
+ name: "create"
315
317
  },
316
318
  {
317
- name: "create",
319
+ name: "create-with-name",
320
+ alias: "create",
318
321
  label: "Create " + label,
319
322
  vnode: () => h(CreateNewWithNameDialog, { title: "Create " + label }),
320
323
  onFinish: listController && ((result) => {
@@ -345,11 +348,11 @@ export function withDefaultActions(label: string, listController?: ListControlle
345
348
  onAction: (action, target) => listController?.activatePanel(target, "edit")
346
349
  },
347
350
  {
348
- name: "quick-delete",
349
- alias: "delete"
351
+ name: "delete"
350
352
  },
351
353
  {
352
- name: "delete",
354
+ name: "delete-with-confirm",
355
+ alias: "delete",
353
356
  label: "Delete",
354
357
  class: "text-red-500",
355
358
  iconClass: "text-red-500",
@@ -57,16 +57,16 @@ export function fLocalizedDateTime(dateTimeString: string, options = {}) {
57
57
  * @returns {string}
58
58
  */
59
59
  export function fDateTime(
60
- dateTime: string | DateTime | null = null,
61
- { format = "M/d/yy h:mma", empty = "- -" }: fDateOptions = {}
60
+ dateTime: string | DateTime | null = null,
61
+ { format = "M/d/yy h:mma", empty = "- -" }: fDateOptions = {}
62
62
  ) {
63
63
  const formatted = parseDateTime(dateTime)?.toFormat(format).toLowerCase();
64
64
  return formatted || empty;
65
65
  }
66
66
 
67
67
  export function fDateTimeMs(
68
- dateTime: string | DateTime | null = null,
69
- { empty = "- -" }: fDateOptions = {}
68
+ dateTime: string | DateTime | null = null,
69
+ { empty = "- -" }: fDateOptions = {}
70
70
  ) {
71
71
  const formatted = parseDateTime(dateTime)?.toFormat("M/d/yy H:mm:ss.SSS").toLowerCase();
72
72
  return formatted || empty;
@@ -201,6 +201,15 @@ export function fSecondsToDuration(seconds: number) {
201
201
  return `${hours ? hours + "h " : ""}${minutes ? minutes + "m " : ""}${secs}s`;
202
202
  }
203
203
 
204
+ /**
205
+ * Formats a number of milliseconds into a duration string in 00h 00m 00s 000ms format
206
+ */
207
+ export function fMillisecondsToDuration(milliseconds: number) {
208
+ const durStr = fSecondsToDuration(Math.floor(milliseconds / 1000));
209
+ return (durStr === "0s" ? "" : durStr) + ` ${Math.floor(milliseconds % 1000)}ms`;
210
+ }
211
+
212
+
204
213
  /**
205
214
  * Formats a duration between two date strings in 00h 00m 00s format
206
215
  */
@@ -274,8 +283,8 @@ export function fShortNumber(value: string | number, options?: { round: boolean
274
283
  if (short) {
275
284
  n = n / Math.pow(10, short.pow);
276
285
  return options?.round
277
- ? n + short.unit
278
- : n.toFixed(n > 100 ? 0 : 1) + short.unit;
286
+ ? n + short.unit
287
+ : n.toFixed(n > 100 ? 0 : 1) + short.unit;
279
288
  }
280
289
 
281
290
  return n;
@@ -329,9 +338,9 @@ export function centerTruncate(str: string, maxLength: number) {
329
338
  const frontCharCount = Math.floor((maxLength - 3) / 2);
330
339
  const backCharCount = maxLength - frontCharCount - 3;
331
340
  return (
332
- str.substring(0, frontCharCount) +
333
- "..." +
334
- str.substring(str.length - backCharCount)
341
+ str.substring(0, frontCharCount) +
342
+ "..." +
343
+ str.substring(str.length - backCharCount)
335
344
  );
336
345
  } else {
337
346
  return str;