fix(form-core): align on common Intl type formatOptions
This commit is contained in:
parent
b01cacbded
commit
b9327627c6
3 changed files with 12 additions and 11 deletions
6
.changeset/tiny-ears-agree.md
Normal file
6
.changeset/tiny-ears-agree.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@lion/form-core': patch
|
||||
'@lion/localize': patch
|
||||
---
|
||||
|
||||
These packages were using out of sync type definitions for FormatOptions, and the types were missing a bunch of options that Intl would normally accept. We now extend Intl's NumberFormatOptions and DateTimeFormatOptions properly, so we always have the right types and are more consistent on it.
|
||||
|
|
@ -7,7 +7,7 @@ import { ValidateMixin } from './validate/ValidateMixin.js';
|
|||
|
||||
/**
|
||||
* @typedef {import('../types/FormatMixinTypes').FormatMixin} FormatMixin
|
||||
* @typedef {import('../types/FormatMixinTypes').FormatOptions} FormatOptions
|
||||
* @typedef {import('@lion/localize/types/LocalizeMixinTypes').FormatNumberOptions} FormatOptions
|
||||
*/
|
||||
|
||||
// For a future breaking release:
|
||||
|
|
@ -357,8 +357,7 @@ const FormatMixinImplementation = superclass =>
|
|||
constructor() {
|
||||
super();
|
||||
this.formatOn = 'change';
|
||||
/** @type {FormatOptions} */
|
||||
this.formatOptions = {};
|
||||
this.formatOptions = /** @type {FormatOptions} */ ({});
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
|
|
|
|||
12
packages/form-core/types/FormatMixinTypes.d.ts
vendored
12
packages/form-core/types/FormatMixinTypes.d.ts
vendored
|
|
@ -1,24 +1,20 @@
|
|||
import { Constructor } from '@open-wc/dedupe-mixin';
|
||||
import { LitElement } from '@lion/core';
|
||||
import { FormatNumberOptions } from '@lion/localize/types/LocalizeMixinTypes';
|
||||
import { ValidateHost } from './validate/ValidateMixinTypes';
|
||||
import { FormControlHost } from './FormControlMixinTypes';
|
||||
|
||||
export declare interface FormatOptions {
|
||||
locale?: string;
|
||||
decimalSeparator?: string;
|
||||
}
|
||||
|
||||
export declare class FormatHost {
|
||||
formattedValue: string;
|
||||
serializedValue: string;
|
||||
formatOn: string;
|
||||
formatOptions: FormatOptions;
|
||||
formatOptions: FormatNumberOptions;
|
||||
value: string;
|
||||
__preventRecursiveTrigger: boolean;
|
||||
__isHandlingUserInput: boolean;
|
||||
|
||||
parser(v: string, opts: FormatOptions): unknown;
|
||||
formatter(v: unknown, opts: FormatOptions): string;
|
||||
parser(v: string, opts: FormatNumberOptions): unknown;
|
||||
formatter(v: unknown, opts: FormatNumberOptions): string;
|
||||
serializer(v: unknown): string;
|
||||
deserializer(v: string): unknown;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue