@ramathibodi/nuxt-commons 0.1.57 → 0.1.58

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.1.57",
7
+ "version": "0.1.58",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -89,7 +89,7 @@ const computedHeaders = computed(()=>{
89
89
  return combinedHeaders.map((header: any) => {
90
90
  return {...header,headerProps:
91
91
  {
92
- style: 'font-weight: 1000'
92
+ style: 'font-weight: 800'
93
93
  }
94
94
  }
95
95
  })
@@ -0,0 +1,40 @@
1
+ <script setup lang="ts">
2
+ import { DateTime } from "luxon";
3
+ import { computed } from "vue";
4
+
5
+ type Locale = "th" | "en" | "en-US" | "th-TH";
6
+
7
+ interface Props {
8
+ modelValue: DateTime;
9
+ endDate?: DateTime;
10
+ locale?: Locale;
11
+ zeroBase?: boolean; // true = start at 0, false = start at 1
12
+ }
13
+
14
+ const props = withDefaults(defineProps<Props>(), {
15
+ locale: "th",
16
+ zeroBase: true,
17
+ });
18
+
19
+ const normalizeLocale = (locale: Locale): "en" | "th" =>
20
+ locale.startsWith("en") ? "en" : "th";
21
+
22
+ const countDate = computed(() => {
23
+ const base = props.endDate ?? DateTime.now();
24
+ const baseLocale = normalizeLocale(props.locale);
25
+
26
+ let days = Math.floor(base.diff(props.modelValue, "days").days ?? 0);
27
+
28
+ if (!props.zeroBase) days += 1;
29
+
30
+ if (baseLocale === "en") {
31
+ return days === 1 ? "1 day" : `${days} days`;
32
+ }
33
+
34
+ return `${days} วัน`;
35
+ });
36
+ </script>
37
+
38
+ <template>
39
+ <span>{{ countDate }}</span>
40
+ </template>
@@ -3,7 +3,7 @@ import {
3
3
  processDefaultTemplate,
4
4
  useDocumentTemplate
5
5
  } from "./template.js";
6
- import { cloneDeep } from "lodash-es";
6
+ import { cloneDeep, isString, isArray } from "lodash-es";
7
7
  export function autoActionHeader(tableHeader) {
8
8
  let autoTableHeader = cloneDeep(tableHeader);
9
9
  if (!autoTableHeader.some((h) => h.key === "action")) autoTableHeader.push({ title: "Action", key: "action", width: "100px" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramathibodi/nuxt-commons",
3
- "version": "0.1.57",
3
+ "version": "0.1.58",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",