quasar-ui-danx 0.4.88 → 0.4.90

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.88",
3
+ "version": "0.4.90",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -42,22 +42,22 @@ import { fDate, parseDateTime } from "../../../../helpers";
42
42
 
43
43
  const emit = defineEmits(["update:model-value"]);
44
44
  const props = defineProps<{
45
- modelValue?: string | null;
46
- label: string | null;
47
- clearable: boolean;
45
+ modelValue?: string | null;
46
+ label: string | null;
47
+ clearable?: boolean;
48
48
  }>();
49
49
 
50
50
  const formattedDate = computed(() => {
51
- if (props.modelValue) {
52
- return fDate(parseDateTime(props.modelValue || "0000-00-00"));
53
- }
54
- return "- -";
51
+ if (props.modelValue) {
52
+ return fDate(parseDateTime(props.modelValue || "0000-00-00"));
53
+ }
54
+ return "- -";
55
55
  });
56
56
 
57
57
  const date = ref(parseDateTime(props.modelValue));
58
58
  watch(() => props.modelValue, val => date.value = val);
59
59
 
60
60
  function onSave() {
61
- emit("update:model-value", date.value);
61
+ emit("update:model-value", date.value);
62
62
  }
63
63
  </script>
@@ -65,6 +65,7 @@ import {
65
65
  FaSolidClock as ClockIcon,
66
66
  FaSolidCodeMerge as MergeIcon,
67
67
  FaSolidCopy as CopyIcon,
68
+ FaSolidDatabase as DatabaseIcon,
68
69
  FaSolidEye as ViewIcon,
69
70
  FaSolidFileExport as ExportIcon,
70
71
  FaSolidFileImport as ImportIcon,
@@ -82,7 +83,7 @@ import { computed, ref } from "vue";
82
83
  import { ActionTarget, ResourceAction } from "../../../types";
83
84
 
84
85
  export interface ActionButtonProps {
85
- type?: "save" | "trash" | "back" | "create" | "edit" | "copy" | "folder" | "play" | "stop" | "pause" | "refresh" | "restart" | "confirm" | "cancel" | "export" | "import" | "minus" | "merge" | "check" | "clock" | "view";
86
+ type?: "save" | "trash" | "back" | "create" | "edit" | "copy" | "folder" | "play" | "stop" | "pause" | "refresh" | "restart" | "confirm" | "cancel" | "export" | "import" | "minus" | "merge" | "check" | "clock" | "view" | "database";
86
87
  color?: "red" | "blue" | "blue-invert" | "sky" | "sky-invert" | "green" | "green-invert" | "lime" | "white" | "gray" | "slate" | "slate-invert" | "yellow" | "orange";
87
88
  size?: "xxs" | "xs" | "sm" | "md" | "lg";
88
89
  icon?: object | string;
@@ -230,6 +231,8 @@ const typeOptions = computed(() => {
230
231
  return { icon: CheckIcon };
231
232
  case "view":
232
233
  return { icon: ViewIcon };
234
+ case "database":
235
+ return { icon: DatabaseIcon };
233
236
  default:
234
237
  return { icon: EditIcon };
235
238
  }
@@ -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;