@antcde/vue-utils 0.2.28-rc.2 → 0.2.28-rc.4

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.
@@ -1,4 +1,7 @@
1
1
  export { type DateFormatPreset, formatDate, type FormatDateOptions, formatDateRange, type FormatDateRangeOptions } from './formatDate';
2
+ export { formatRefreshLabel, type RefreshTranslate } from './refreshLabel';
3
+ export { browserZone, buildScheduleRule, defaultScheduleSpec, describeRefresh, parseScheduleRule, type RefreshDescription, SCHEDULE_DAYS, type ScheduleFreq, type ScheduleMonthly, type ScheduleNth, type ScheduleSpec, weekdayOf, } from './refreshSchedule';
4
+ export { nextOccurrences, type ScheduleOccurrence } from './refreshScheduleOccurrences';
2
5
  export { TASK_PRIORITIES, taskPriorityColor, taskPriorityIcon } from './taskPriority';
3
6
  export { useAntColorMode, type UseAntColorModeOptions, type UseAntColorModeReturn } from './useAntColorMode';
4
7
  export { useAntI18n, type UseAntI18nReturn } from './useAntI18n';
@@ -0,0 +1,14 @@
1
+ import { RefreshDescription } from './refreshSchedule';
2
+ /** vue-i18n's `t(key, named, plural)`, wrapped so each app passes its own. */
3
+ export type RefreshTranslate = (key: string, named: Record<string, unknown>, plural?: number) => string;
4
+ /**
5
+ * "Refreshed every 2 weeks on Monday at 06:00" (AAD-1111). The phrasing is shared; the
6
+ * strings are the caller's, under `prefix`: `interval.{300|86400|604800}`, `hourly`,
7
+ * `daily`, `weekly`, `monthlyDay`, `monthlyNth` (plural on `count`), `nth.{first…last}`,
8
+ * `ordinal.{one|two|few|other}`, `inZone`, `custom`, `customNext`.
9
+ */
10
+ export declare function formatRefreshLabel(description: RefreshDescription, options: {
11
+ t: RefreshTranslate;
12
+ locale: string;
13
+ prefix: string;
14
+ }): string;
@@ -0,0 +1,45 @@
1
+ import { TriggerRefreshPolicy, TriggerRefreshPreset } from '@antcde/connect-ts';
2
+ export type ScheduleFreq = 'hourly' | 'daily' | 'weekly' | 'monthly';
3
+ /** 1–4, or -1 for "last". */
4
+ export type ScheduleNth = 1 | 2 | 3 | 4 | -1;
5
+ export type ScheduleMonthly = {
6
+ day: number;
7
+ } | {
8
+ nth: ScheduleNth;
9
+ weekday: number;
10
+ };
11
+ export interface ScheduleSpec {
12
+ freq: ScheduleFreq;
13
+ interval: number;
14
+ /** 0 = Monday … 6 = Sunday. Weekly only. */
15
+ weekdays: number[];
16
+ /** Monthly only. */
17
+ monthly: ScheduleMonthly | null;
18
+ /** `HH:mm`; null for hourly, which counts from the start date's midnight. */
19
+ time: string | null;
20
+ /** `YYYY-MM-DD`: the anchor that makes "every 2 weeks" land on the right weeks. */
21
+ startDate: string;
22
+ /** IANA zone. */
23
+ timezone: string;
24
+ }
25
+ export type RefreshDescription = {
26
+ kind: 'interval';
27
+ preset: TriggerRefreshPreset;
28
+ } | {
29
+ kind: 'schedule';
30
+ spec: ScheduleSpec;
31
+ foreignZone: boolean;
32
+ } | {
33
+ kind: 'custom';
34
+ nextRefreshAt: string | null;
35
+ };
36
+ export declare const SCHEDULE_DAYS: readonly ["MO", "TU", "WE", "TH", "FR", "SA", "SU"];
37
+ export declare function browserZone(): string;
38
+ /** Weekly on Monday at 06:00 from today, in the browser's zone. */
39
+ export declare function defaultScheduleSpec(today?: Date): ScheduleSpec;
40
+ /** Monday-based weekday of a `YYYY-MM-DD` date. */
41
+ export declare function weekdayOf(date: string): number;
42
+ export declare function buildScheduleRule(spec: ScheduleSpec): string;
43
+ export declare function parseScheduleRule(text: string | null | undefined): ScheduleSpec | null;
44
+ /** A refresh policy as parts each app phrases in its own language. */
45
+ export declare function describeRefresh(policy: TriggerRefreshPolicy | null | undefined, viewerZone?: string): RefreshDescription | null;
@@ -0,0 +1,15 @@
1
+ import { ScheduleSpec } from './refreshSchedule';
2
+ export interface ScheduleOccurrence {
3
+ /** The real moment. */
4
+ at: Date;
5
+ /** The same moment as wall time in the schedule's zone, in UTC fields: format it with `timeZone: 'UTC'`. */
6
+ wall: Date;
7
+ }
8
+ /**
9
+ * The next refresh points of a schedule.
10
+ *
11
+ * ⚠️ rrule.js applies TZID relative to the HOST's zone, so the same rule gave different
12
+ * instants on machines in different zones. It runs on floating wall times here instead,
13
+ * and Intl turns each into a real instant in the schedule's own zone.
14
+ */
15
+ export declare function nextOccurrences(spec: ScheduleSpec, count?: number, from?: Date): ScheduleOccurrence[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antcde/vue-utils",
3
3
  "type": "module",
4
- "version": "0.2.28-rc.2",
4
+ "version": "0.2.28-rc.4",
5
5
  "description": "Helper to use ANT Comms in Vue 3",
6
6
  "author": "CollaborAll",
7
7
  "exports": {
@@ -22,6 +22,8 @@
22
22
  "build": "pnpm clean && vite build",
23
23
  "build:watch": "vite build --watch",
24
24
  "type-check": "vue-tsc --noEmit",
25
+ "test": "vitest --run",
26
+ "test:watch": "vitest",
25
27
  "clean": "pnpm dlx rimraf dist"
26
28
  },
27
29
  "peerDependencies": {
@@ -31,7 +33,8 @@
31
33
  "vue-i18n": "^11.1.12"
32
34
  },
33
35
  "dependencies": {
34
- "@antcde/connect-ts": "0.4.33-rc.2"
36
+ "@antcde/connect-ts": "0.4.33-rc.4",
37
+ "rrule": "^2.8.1"
35
38
  },
36
39
  "devDependencies": {
37
40
  "@tsconfig/node22": "^22.0.6",
@@ -39,9 +42,11 @@
39
42
  "@vitejs/plugin-vue": "^6.0.9",
40
43
  "@vue/language-core": "^3.3.11",
41
44
  "@vue/tsconfig": "^0.9.1",
45
+ "happy-dom": "^20.14.5",
42
46
  "typescript": "~6.0.3",
43
47
  "vite": "^8.3.0",
44
48
  "vite-plugin-dts": "^5.1.1",
49
+ "vitest": "^5.0.1",
45
50
  "vue-tsc": "^3.3.11"
46
51
  }
47
52
  }