adminforth 4.7.4 → 4.8.0

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.
@@ -186,8 +186,7 @@
186
186
  </span>
187
187
  <button type="button"
188
188
  class="ms-auto -mx-1.5 -my-1.5 bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity inline-flex justify-center items-center w-6 h-6 rounded-lg p-1 hover:brightness-110"
189
-
190
- data-dismiss-target="#dropdown-cta" aria-label="Close"
189
+ aria-label="Close"
191
190
  v-if="ctaBadge?.closable" @click="closeCTA"
192
191
  >
193
192
  <span class="sr-only">Close</span>
@@ -1,10 +1,12 @@
1
1
  import dayjs from 'dayjs';
2
2
  import utc from 'dayjs/plugin/utc';
3
3
  import timezone from 'dayjs/plugin/timezone';
4
+ import localeData from 'dayjs/plugin/localeData';
4
5
  import { useCoreStore } from '../stores/core';
5
6
 
6
7
  dayjs.extend(utc);
7
8
  dayjs.extend(timezone);
9
+ dayjs.extend(localeData);
8
10
 
9
11
  export const DEFAULT_DATES_FORMAT = 'YYYY-MM-DD';
10
12
  export const DEFAULT_TIME_FORMAT = 'HH:mm:ss';
@@ -50,8 +52,10 @@ export function formatTime(time: string | null | undefined): string {
50
52
  return dayjs(`0000-00-00 ${time}`).format(getTimeFormat());
51
53
  }
52
54
 
53
- /** Locale shape flowbite-datepicker passes to custom format functions. */
54
- type DatepickerLocale = { months: string[], monthsShort: string[] };
55
+ /** A day picked in a date picker: "2026-10-14", without time and timezone. */
56
+ export const PICKER_DAY_FORMAT = 'YYYY-MM-DD';
57
+ /** A picked day in the field of a date picker, the month is a word so the order of the parts is never ambiguous. */
58
+ const PICKER_DISPLAY_FORMAT = 'DD MMM YYYY';
55
59
 
56
60
  /** A run of letters or a run of digits, so "18Aug2003" and "Jun 23, 2022 ·" both tokenize cleanly. */
57
61
  const DATE_TOKEN_RE = /\p{L}+|\p{N}+/gu;
@@ -68,14 +72,29 @@ const CENTURY_PIVOT = 50;
68
72
  /** Shortest month abbreviation across locales; single letters would match random words. */
69
73
  const MIN_MONTH_NAME_LENGTH = 2;
70
74
 
71
- function findMonthIndex(name: string, locale: DatepickerLocale): number {
75
+ /**
76
+ * Month names of the active dayjs locale (the i18n plugin switches it), full and short. "D MMMM" gives the form
77
+ * a month takes inside a date, in uk and ru it differs from the standalone one ("14 січня", "січень").
78
+ */
79
+ function localeMonthNames(): string[][] {
80
+ const months = Array.from({ length: 12 }, (_, month) => dayjs().startOf('year').month(month));
81
+ const dayPrefix = months[0].format('D ');
82
+ return [
83
+ months.map(m => m.format('MMM')),
84
+ months.map(m => m.format('MMMM')),
85
+ months.map(m => m.format('D MMM').slice(dayPrefix.length)),
86
+ months.map(m => m.format('D MMMM').slice(dayPrefix.length)),
87
+ ];
88
+ }
89
+
90
+ function findMonthIndex(name: string): number {
72
91
  if (name.length < MIN_MONTH_NAME_LENGTH) {
73
92
  return -1;
74
93
  }
75
94
  const lowered = name.toLowerCase();
76
95
  const startsWithToken = (monthName: string) => monthName.toLowerCase().startsWith(lowered);
77
96
  // both short and full names, in the active language and in English (pasted dates are often English)
78
- for (const names of [locale.monthsShort, locale.months, EN_MONTHS_SHORT, EN_MONTHS]) {
97
+ for (const names of [...localeMonthNames(), EN_MONTHS_SHORT, EN_MONTHS]) {
79
98
  const index = names.findIndex(startsWithToken);
80
99
  if (index >= 0) {
81
100
  return index;
@@ -93,10 +112,10 @@ function normalizeYear(year: number, digits: number): number {
93
112
 
94
113
  /**
95
114
  * Parses a human-typed or pasted date in whatever order the parts came in:
96
- * "18 Aug 2003", "Aug 18, 2003", "18.08.2003", "2003-08-18", "Jun 23, 2022 ·".
97
- * Returns a local-midnight timestamp, or NaN when the string is not a date.
115
+ * "18 Aug 2003", "Aug 18, 2003", "18.08.2003", "2003-08-18", "Jun 23, 2022 ·", "14 січня".
116
+ * Returns the day in PICKER_DAY_FORMAT, or null when the string is not a date.
98
117
  */
99
- export function parseFlexibleDate(dateStr: string, locale: DatepickerLocale): number {
118
+ export function parseFlexibleDate(dateStr: string): string | null {
100
119
  const tokens = dateStr.replace(TIME_PART_RE, ' ').match(DATE_TOKEN_RE) || [];
101
120
 
102
121
  let month = -1;
@@ -105,7 +124,7 @@ export function parseFlexibleDate(dateStr: string, locale: DatepickerLocale): nu
105
124
  if (DIGITS_RE.test(token)) {
106
125
  numbers.push({ value: parseInt(token, 10), digits: token.length });
107
126
  } else if (month < 0) {
108
- month = findMonthIndex(token, locale);
127
+ month = findMonthIndex(token);
109
128
  }
110
129
  }
111
130
 
@@ -128,7 +147,7 @@ export function parseFlexibleDate(dateStr: string, locale: DatepickerLocale): nu
128
147
  day = numbers.shift()!.value;
129
148
  month = new Date().getMonth();
130
149
  } else {
131
- return NaN;
150
+ return null;
132
151
  }
133
152
 
134
153
  const leftover = numbers.shift();
@@ -141,17 +160,10 @@ export function parseFlexibleDate(dateStr: string, locale: DatepickerLocale): nu
141
160
  const date = new Date(year, month, day);
142
161
  date.setFullYear(year);
143
162
  // rejects impossible dates like "31 Feb" instead of silently rolling them over
144
- return date.getMonth() === month && date.getDate() === day ? date.getTime() : NaN;
163
+ return date.getMonth() === month && date.getDate() === day ? dayjs(date).format(PICKER_DAY_FORMAT) : null;
145
164
  }
146
165
 
147
- /**
148
- * flowbite-datepicker format: renders as "18 Aug 2003" and accepts any parsable order on input.
149
- */
150
- export const FLEXIBLE_DATEPICKER_FORMAT = {
151
- toDisplay(date: Date, format: unknown, locale: DatepickerLocale): string {
152
- return `${String(date.getDate()).padStart(2, '0')} ${locale.monthsShort[date.getMonth()]} ${date.getFullYear()}`;
153
- },
154
- toValue(dateStr: string, format: unknown, locale: DatepickerLocale): number {
155
- return parseFlexibleDate(dateStr, locale);
156
- },
157
- };
166
+ /** A picked day as the field of a date picker shows it: "14 Oct 2026", month names in the active language. */
167
+ export function formatPickerDay(day: string): string {
168
+ return dayjs(day).format(PICKER_DISPLAY_FORMAT);
169
+ }
@@ -1,34 +1,23 @@
1
1
  <template>
2
2
  <div class="w-full mt-[36px]">
3
- <div class="w-full border dark:border-darkFormBorder border-lightFormBorder rounded-lg overflow-hidden shadow-resourseFormShadow dark:shadow-darkResourseFormShadow bg-lightForm dark:bg-darkForm">
4
-
5
- <div class="flex px-5 items-center border-b border-lightFormBorder dark:border-darkFormBorder bg-lightFormHeading dark:bg-darkFormHeading h-[40px]">
6
- <div class="w-[208px] flex-shrink-0 pr-6 text-xs text-lightListTableHeadingText uppercase dark:text-darkListTableHeadingText font-bold">
7
- {{ $t('Field') }}
8
- </div>
9
- <div class="flex-1 text-xs text-lightListTableHeadingText uppercase dark:text-darkListTableHeadingText font-bold">
10
- {{ $t('Value') }}
11
- </div>
12
- </div>
13
-
3
+ <div class="w-full border dark:border-darkFormBorder border-lightFormBorder rounded-lg overflow-hidden shadow-resourseFormShadow dark:shadow-darkResourseFormShadow bg-lightForm dark:bg-darkForm divide-y divide-lightShowTableBodyBorder dark:divide-darkShowTableBodyBorder">
14
4
  <div
15
5
  v-for="i in 10"
16
6
  :key="i"
17
- class="flex items-center bg-lightForm dark:bg-darkForm border-b border-lightFormBorder dark:border-darkFormBorder h-[58px]"
7
+ class="flex items-center h-[58px]"
18
8
  >
19
- <div class="w-[208px] flex-shrink-0 px-6 flex items-center">
9
+ <div class="w-56 flex-shrink-0 px-5 flex items-center">
20
10
  <Skeleton class="w-24 h-[10px]" />
21
11
  </div>
22
12
 
23
- <div class="flex-1 px-6">
24
- <Skeleton class="h-[10px] w-full" />
13
+ <div class="flex-1 px-5">
14
+ <Skeleton class="h-[10px] w-full max-w-xl" />
25
15
  </div>
26
16
  </div>
27
-
28
17
  </div>
29
18
  </div>
30
19
  </template>
31
20
 
32
21
  <script setup lang="ts">
33
22
  import { Skeleton } from '@/afcl';
34
- </script>
23
+ </script>
@@ -96,41 +96,31 @@
96
96
  <div
97
97
  v-if="loading"
98
98
  role="status"
99
- class="animate-pulse overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow rounded-lg overflow-hidden border border-lightShowTableBodyBorder dark:border-darkShowTableBodyBorder"
99
+ class="animate-pulse overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow rounded-lg overflow-hidden border border-lightFormBorder dark:border-darkFormBorder bg-lightShowTablesBodyBackground dark:bg-darkShowTablesBodyBackground"
100
100
  >
101
- <div
102
- v-if="groups && groups.length > 0"
103
- class="text-sm font-semibold px-5 py-3 flex flex-1 items-center bg-lightShowTableHeadingBackground dark:bg-darkShowTableHeadingBackground dark:text-darkShowTableHeadingText border-b border-lightShowTableBodyBorder dark:border-darkShowTableBodyBorder"
104
- >
101
+ <div v-if="groups && groups.length > 0" class="px-5 pt-5 pb-2">
105
102
  <div class="h-3 bg-lightSkeletonBackgroundColor dark:bg-darkSkeletonBackgroundColor rounded-full w-32"></div>
106
103
  </div>
107
104
 
108
105
  <table class="w-full text-sm text-left table-fixed border-collapse">
109
- <thead class="bg-lightShowTableUnderHeadingBackground dark:bg-darkShowTableUnderHeadingBackground block md:table-row-group">
110
- <tr class="block md:table-row">
111
- <th scope="col" class="px-5 py-2.5 text-xs font-medium hidden md:w-56 md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
112
- {{ $t('Field') }}
113
- </th>
114
- <th scope="col" class="px-5 py-2.5 text-xs font-medium hidden md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
115
- {{ $t('Value') }}
116
- </th>
117
- </tr>
118
- </thead>
119
-
120
- <tbody>
121
- <tr
122
- v-for="i in skeletonRowsCount"
106
+ <colgroup>
107
+ <col class="md:w-56">
108
+ <col>
109
+ </colgroup>
110
+ <tbody class="divide-y divide-lightShowTableBodyBorder dark:divide-darkShowTableBodyBorder">
111
+ <tr
112
+ v-for="i in skeletonRowsCount"
123
113
  :key="i"
124
- class="bg-lightShowTablesBodyBackground border-t border-lightShowTableBodyBorder dark:bg-darkShowTablesBodyBackground dark:border-darkShowTableBodyBorder block md:table-row"
114
+ class="block md:table-row"
125
115
  >
126
- <td class="px-6 py-[15.5px] relative block md:table-cell pb-0 md:pb-[15.5px]">
127
- <div class="md:absolute md:inset-0 flex items-center px-6 py-[15.5px]">
116
+ <td class="px-5 pt-2.5 pb-0 md:pb-2.5 block md:table-cell">
117
+ <div class="flex items-center h-5">
128
118
  <div class="h-2.5 bg-lightSkeletonBackgroundColor dark:bg-darkSkeletonBackgroundColor rounded-full w-24"></div>
129
119
  </div>
130
120
  </td>
131
121
 
132
- <td class="px-6 py-[15.5px] whitespace-pre-wrap block md:table-cell">
133
- <div class="flex items-center h-full min-h-[21px]">
122
+ <td class="px-5 pt-1 pb-2.5 md:pt-2.5 block md:table-cell">
123
+ <div class="flex items-center h-5">
134
124
  <div class="h-2.5 bg-lightSkeletonBackgroundColor dark:bg-darkSkeletonBackgroundColor rounded-full w-full max-w-[280px]"></div>
135
125
  </div>
136
126
  </td>
@@ -3,7 +3,7 @@
3
3
  export default {
4
4
  // no spaces inside the braces, otherwise extensions are expanded as "* js", "* ts" and
5
5
  // classes declared in plain .ts/.js files (e.g. afcl/buttonStyles.ts) are not generated
6
- content: ["./src/**/*.{vue,js,ts,tsx}","./src/*.{vue,js,ts,tsx}", "./index.html", "./node_modules/flowbite-datepicker/**/*.js"],
6
+ content: ["./src/**/*.{vue,js,ts,tsx}","./src/*.{vue,js,ts,tsx}", "./index.html"],
7
7
  safelist: [
8
8
  /* IMPORTANT:ADMINFORTH TAILWIND SAFELIST */
9
9
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "4.7.4",
3
+ "version": "4.8.0",
4
4
  "description": "OpenSource Agent-Native forth-generation admin panel",
5
5
  "keywords": [
6
6
  "adminforth",