@shoelace-style/localize 1.1.5 → 1.1.6

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/fast.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { CaptureType, ExecutionContext } from '@microsoft/fast-element';
1
+ import type { CaptureType, ExecutionContext, FASTElement } from '@microsoft/fast-element';
2
2
  import type { FunctionParams, Translation } from './';
3
3
  export declare function localize(): (targetClass: any) => any;
4
- export declare function translate<TSource, K extends keyof Translation>(context: ExecutionContext, key: K, ...args: FunctionParams<Translation[K]>): CaptureType<TSource>;
5
- export declare function formatDate<TSource = any>(context: ExecutionContext, date: Date | string, options?: Intl.DateTimeFormatOptions): CaptureType<TSource>;
6
- export declare function formatNumber<TSource = any>(context: ExecutionContext, number: number | string, options?: Intl.DateTimeFormatOptions): CaptureType<TSource>;
4
+ export declare function translate<TSource, K extends keyof Translation>(context: ExecutionContext | FASTElement | HTMLElement, key: K, ...args: FunctionParams<Translation[K]>): CaptureType<TSource>;
5
+ export declare function formatDate<TSource = any>(context: ExecutionContext | FASTElement | HTMLElement, date: Date | string, options?: Intl.DateTimeFormatOptions): CaptureType<TSource>;
6
+ export declare function formatNumber<TSource = any>(context: ExecutionContext | FASTElement | HTMLElement, number: number | string, options?: Intl.DateTimeFormatOptions): CaptureType<TSource>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoelace-style/localize",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "A micro library for localizing custom elements.",
5
5
  "main": "/dist/index.js",
6
6
  "module": "/dist/index.js",
package/src/fast.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { connectedElements, detectLanguage, translate as t, formatDate as d, formatNumber as n } from './';
2
- import type { CaptureType, ExecutionContext } from '@microsoft/fast-element';
2
+ import type { CaptureType, ExecutionContext, FASTElement } from '@microsoft/fast-element';
3
3
  import type { FunctionParams, Translation } from './';
4
4
 
5
5
  /**
@@ -73,7 +73,7 @@ function getLang(source: any) {
73
73
  * Formats a number using the element's current language.
74
74
  */
75
75
  export function translate<TSource, K extends keyof Translation>(
76
- context: ExecutionContext,
76
+ context: ExecutionContext | FASTElement | HTMLElement,
77
77
  key: K,
78
78
  ...args: FunctionParams<Translation[K]>
79
79
  ): CaptureType<TSource> {
@@ -86,7 +86,7 @@ export function translate<TSource, K extends keyof Translation>(
86
86
  * Formats a date using the element's current language.
87
87
  */
88
88
  export function formatDate<TSource = any>(
89
- context: ExecutionContext,
89
+ context: ExecutionContext | FASTElement | HTMLElement,
90
90
  date: Date | string,
91
91
  options?: Intl.DateTimeFormatOptions
92
92
  ): CaptureType<TSource> {
@@ -99,7 +99,7 @@ export function formatDate<TSource = any>(
99
99
  * Formats a number using the element's current language.
100
100
  */
101
101
  export function formatNumber<TSource = any>(
102
- context: ExecutionContext,
102
+ context: ExecutionContext | FASTElement | HTMLElement,
103
103
  number: number | string,
104
104
  options?: Intl.DateTimeFormatOptions
105
105
  ): CaptureType<TSource> {