@data-fair/lib-vue 1.9.4 → 1.10.1

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,6 +1,8 @@
1
- export declare const locale: string, dayjs: (date?: string | number | import("dayjs").Dayjs | Date | null | undefined) => import("dayjs").Dayjs & {
1
+ export declare const locale: string, dayjs: (date?: string | number | import("dayjs").Dayjs | Date | null | undefined) => Omit<import("dayjs").Dayjs, "add" | "subtract"> & {
2
2
  fromNow(withoutSuffix?: boolean): string;
3
3
  from(compared: import("dayjs").ConfigType, withoutSuffix?: boolean): string;
4
4
  toNow(withoutSuffix?: boolean): string;
5
5
  to(compared: import("dayjs").ConfigType, withoutSuffix?: boolean): string;
6
+ add(duration: import("dayjs/plugin/duration.js").Duration): Omit<import("dayjs").Dayjs, "add" | "subtract"> & any;
7
+ subtract(duration: import("dayjs/plugin/duration.js").Duration): Omit<import("dayjs").Dayjs, "add" | "subtract"> & any;
6
8
  };
package/locale-dayjs.d.ts CHANGED
@@ -1,16 +1,20 @@
1
- import type { Dayjs, ConfigType } from 'dayjs';
2
1
  import type { App } from 'vue';
3
- import dayjs from 'dayjs';
2
+ import dayjs, { type Dayjs, ConfigType } from 'dayjs';
4
3
  import 'dayjs/locale/fr';
5
4
  import 'dayjs/locale/en';
6
- type RelativeDayjs = Dayjs & {
5
+ import duration, { type Duration } from 'dayjs/plugin/duration.js';
6
+ export type { ConfigType as DayjsConfigType } from 'dayjs';
7
+ type RelativeDayjs = Omit<Dayjs, 'add' | 'subtract'> & {
7
8
  fromNow(withoutSuffix?: boolean): string;
8
9
  from(compared: ConfigType, withoutSuffix?: boolean): string;
9
10
  toNow(withoutSuffix?: boolean): string;
10
11
  to(compared: ConfigType, withoutSuffix?: boolean): string;
12
+ add(duration: Duration): RelativeDayjs;
13
+ subtract(duration: Duration): RelativeDayjs;
11
14
  };
12
15
  export declare function getLocaleDayjs(locale?: string): {
13
16
  locale: string;
17
+ duration: (dur: duration.DurationUnitsObjectType) => duration.Duration;
14
18
  dayjs: (date?: string | number | dayjs.Dayjs | Date | null | undefined) => RelativeDayjs;
15
19
  };
16
20
  export declare const localeDayjsKey: unique symbol;
package/locale-dayjs.js CHANGED
@@ -4,14 +4,19 @@ import 'dayjs/locale/fr'
4
4
  import 'dayjs/locale/en'
5
5
  import localizedFormat from 'dayjs/plugin/localizedFormat.js'
6
6
  import relativeTime from 'dayjs/plugin/relativeTime.js'
7
+ import duration from 'dayjs/plugin/duration.js'
7
8
  dayjs.extend(localizedFormat)
8
9
  dayjs.extend(relativeTime)
10
+ dayjs.extend(duration)
9
11
  // main functionality, use through the createLocaleDayjs plugin and useLocaleDayjs composable
10
12
  // or as a global singleton through ./locale-dayjs-global.js
11
13
  export function getLocaleDayjs (locale) {
12
14
  locale = locale ?? 'fr'
13
15
  return {
14
16
  locale,
17
+ duration: (dur) => {
18
+ return dayjs.duration(dur).locale(locale)
19
+ },
15
20
  dayjs: (date) => {
16
21
  return dayjs(date).locale(locale)
17
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.9.4",
3
+ "version": "1.10.1",
4
4
  "description": "Composables and other utilities for Vue applications in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [
package/auto-imports.js DELETED
@@ -1,13 +0,0 @@
1
- // made for https://github.com/unplugin/unplugin-auto-import
2
- export default [
3
- 'vue',
4
- 'vue-i18n',
5
- 'vue-router',
6
- {
7
- '@data-fair/lib-vue/session.js': ['useSession'],
8
- '@data-fair/lib-vue/reactive-search-params.js': ['useReactiveSearchParams'],
9
- '@data-fair/lib-vue/locale-dayjs.js': ['useLocaleDayjs'],
10
- '@data-fair/lib-vue/concept-filters.js': ['useConceptFilters'],
11
- '@data-fair/lib-vue/ui-notif.js': ['useUiNotif']
12
- }
13
- ]
@@ -1 +0,0 @@
1
- export {}
@@ -1,8 +0,0 @@
1
- // same as use-ui-notif.js but in a module level singleton for convenience when not using SSR
2
- import { getUiNotif } from './ui-notif.js'
3
- // @ts-ignore
4
- if (import.meta.env?.SSR) {
5
- throw new Error('this module uses a module level singleton, it cannot be used in SSR mode')
6
- }
7
- console.error('ui-notif-global is deprecated, please use create + use')
8
- export default getUiNotif()