diff --git a/package.json b/package.json index 54354ac..fb4fe91 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "svelte-highlight": "^7.5.0", "svelte-preprocess": "^5.1.3", "tslib": "^2.6.2", - "typescript": "^5.3.3", + "typescript": "^5.4.2", "vite": "^5.0.12", "vitest": "^1.2.2" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8f594f0..8cb5ca6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,7 +7,7 @@ settings: devDependencies: '@commitlint/cli': specifier: ^18.6.0 - version: 18.6.0(@types/node@20.4.7)(typescript@5.3.3) + version: 18.6.0(@types/node@20.4.7)(typescript@5.4.2) '@commitlint/config-conventional': specifier: ^18.6.0 version: 18.6.0 @@ -31,10 +31,10 @@ devDependencies: version: 4.1.0(svelte@4.2.9) '@typescript-eslint/eslint-plugin': specifier: ^6.20.0 - version: 6.20.0(@typescript-eslint/parser@6.20.0)(eslint@8.56.0)(typescript@5.3.3) + version: 6.20.0(@typescript-eslint/parser@6.20.0)(eslint@8.56.0)(typescript@5.4.2) '@typescript-eslint/parser': specifier: ^6.20.0 - version: 6.20.0(eslint@8.56.0)(typescript@5.3.3) + version: 6.20.0(eslint@8.56.0)(typescript@5.4.2) axe-playwright: specifier: ^2.0.1 version: 2.0.1(playwright@1.41.2) @@ -82,13 +82,13 @@ devDependencies: version: 7.5.0 svelte-preprocess: specifier: ^5.1.3 - version: 5.1.3(postcss@8.4.30)(svelte@4.2.9)(typescript@5.3.3) + version: 5.1.3(postcss@8.4.30)(svelte@4.2.9)(typescript@5.4.2) tslib: specifier: ^2.6.2 version: 2.6.2 typescript: - specifier: ^5.3.3 - version: 5.3.3 + specifier: ^5.4.2 + version: 5.4.2 vite: specifier: ^5.0.12 version: 5.0.12(@types/node@20.4.7) @@ -139,14 +139,14 @@ packages: regenerator-runtime: 0.13.11 dev: true - /@commitlint/cli@18.6.0(@types/node@20.4.7)(typescript@5.3.3): + /@commitlint/cli@18.6.0(@types/node@20.4.7)(typescript@5.4.2): resolution: {integrity: sha512-FiH23cr9QG8VdfbmvJJZmdfHGVMCouOOAzoXZ3Cd7czGC52RbycwNt8YCI7SA69pAl+t30vh8LMaO/N+kcel6w==} engines: {node: '>=v18'} hasBin: true dependencies: '@commitlint/format': 18.6.0 '@commitlint/lint': 18.6.0 - '@commitlint/load': 18.6.0(@types/node@20.4.7)(typescript@5.3.3) + '@commitlint/load': 18.6.0(@types/node@20.4.7)(typescript@5.4.2) '@commitlint/read': 18.6.0 '@commitlint/types': 18.6.0 execa: 5.1.1 @@ -217,7 +217,7 @@ packages: '@commitlint/types': 18.6.0 dev: true - /@commitlint/load@18.6.0(@types/node@20.4.7)(typescript@5.3.3): + /@commitlint/load@18.6.0(@types/node@20.4.7)(typescript@5.4.2): resolution: {integrity: sha512-RRssj7TmzT0bowoEKlgwg8uQ7ORXWkw7lYLsZZBMi9aInsJuGNLNWcMxJxRZbwxG3jkCidGUg85WmqJvRjsaDA==} engines: {node: '>=v18'} dependencies: @@ -226,8 +226,8 @@ packages: '@commitlint/resolve-extends': 18.6.0 '@commitlint/types': 18.6.0 chalk: 4.1.2 - cosmiconfig: 8.3.6(typescript@5.3.3) - cosmiconfig-typescript-loader: 5.0.0(@types/node@20.4.7)(cosmiconfig@8.3.6)(typescript@5.3.3) + cosmiconfig: 8.3.6(typescript@5.4.2) + cosmiconfig-typescript-loader: 5.0.0(@types/node@20.4.7)(cosmiconfig@8.3.6)(typescript@5.4.2) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -919,7 +919,7 @@ packages: resolution: {integrity: sha512-7aqorHYgdNO4DM36stTiGO3DvKoex9TQRwsJU6vMaFGyqpBA1MNZkz+PG3gaNUPpTAOYhT1WR7M1JyA3fbS9Cw==} dev: true - /@typescript-eslint/eslint-plugin@6.20.0(@typescript-eslint/parser@6.20.0)(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/eslint-plugin@6.20.0(@typescript-eslint/parser@6.20.0)(eslint@8.56.0)(typescript@5.4.2): resolution: {integrity: sha512-fTwGQUnjhoYHeSF6m5pWNkzmDDdsKELYrOBxhjMrofPqCkoC2k3B2wvGHFxa1CTIqkEn88nlW1HVMztjo2K8Hg==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -931,10 +931,10 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.8.1 - '@typescript-eslint/parser': 6.20.0(eslint@8.56.0)(typescript@5.3.3) + '@typescript-eslint/parser': 6.20.0(eslint@8.56.0)(typescript@5.4.2) '@typescript-eslint/scope-manager': 6.20.0 - '@typescript-eslint/type-utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3) + '@typescript-eslint/type-utils': 6.20.0(eslint@8.56.0)(typescript@5.4.2) + '@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.4.2) '@typescript-eslint/visitor-keys': 6.20.0 debug: 4.3.4 eslint: 8.56.0 @@ -942,13 +942,13 @@ packages: ignore: 5.2.4 natural-compare: 1.4.0 semver: 7.5.4 - ts-api-utils: 1.0.3(typescript@5.3.3) - typescript: 5.3.3 + ts-api-utils: 1.0.3(typescript@5.4.2) + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.4.2): resolution: {integrity: sha512-bYerPDF/H5v6V76MdMYhjwmwgMA+jlPVqjSDq2cRqMi8bP5sR3Z+RLOiOMad3nsnmDVmn2gAFCyNgh/dIrfP/w==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -960,11 +960,11 @@ packages: dependencies: '@typescript-eslint/scope-manager': 6.20.0 '@typescript-eslint/types': 6.20.0 - '@typescript-eslint/typescript-estree': 6.20.0(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 6.20.0(typescript@5.4.2) '@typescript-eslint/visitor-keys': 6.20.0 debug: 4.3.4 eslint: 8.56.0 - typescript: 5.3.3 + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true @@ -977,7 +977,7 @@ packages: '@typescript-eslint/visitor-keys': 6.20.0 dev: true - /@typescript-eslint/type-utils@6.20.0(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/type-utils@6.20.0(eslint@8.56.0)(typescript@5.4.2): resolution: {integrity: sha512-qnSobiJQb1F5JjN0YDRPHruQTrX7ICsmltXhkV536mp4idGAYrIyr47zF/JmkJtEcAVnIz4gUYJ7gOZa6SmN4g==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -987,12 +987,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 6.20.0(typescript@5.3.3) - '@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 6.20.0(typescript@5.4.2) + '@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.4.2) debug: 4.3.4 eslint: 8.56.0 - ts-api-utils: 1.0.3(typescript@5.3.3) - typescript: 5.3.3 + ts-api-utils: 1.0.3(typescript@5.4.2) + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true @@ -1002,7 +1002,7 @@ packages: engines: {node: ^16.0.0 || >=18.0.0} dev: true - /@typescript-eslint/typescript-estree@6.20.0(typescript@5.3.3): + /@typescript-eslint/typescript-estree@6.20.0(typescript@5.4.2): resolution: {integrity: sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -1018,13 +1018,13 @@ packages: is-glob: 4.0.3 minimatch: 9.0.3 semver: 7.5.4 - ts-api-utils: 1.0.3(typescript@5.3.3) - typescript: 5.3.3 + ts-api-utils: 1.0.3(typescript@5.4.2) + typescript: 5.4.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@6.20.0(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/utils@6.20.0(eslint@8.56.0)(typescript@5.4.2): resolution: {integrity: sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -1035,7 +1035,7 @@ packages: '@types/semver': 7.5.2 '@typescript-eslint/scope-manager': 6.20.0 '@typescript-eslint/types': 6.20.0 - '@typescript-eslint/typescript-estree': 6.20.0(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 6.20.0(typescript@5.4.2) eslint: 8.56.0 semver: 7.5.4 transitivePeerDependencies: @@ -1546,7 +1546,7 @@ packages: engines: {node: '>= 0.6'} dev: true - /cosmiconfig-typescript-loader@5.0.0(@types/node@20.4.7)(cosmiconfig@8.3.6)(typescript@5.3.3): + /cosmiconfig-typescript-loader@5.0.0(@types/node@20.4.7)(cosmiconfig@8.3.6)(typescript@5.4.2): resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} engines: {node: '>=v16'} peerDependencies: @@ -1555,12 +1555,12 @@ packages: typescript: '>=4' dependencies: '@types/node': 20.4.7 - cosmiconfig: 8.3.6(typescript@5.3.3) + cosmiconfig: 8.3.6(typescript@5.4.2) jiti: 1.21.0 - typescript: 5.3.3 + typescript: 5.4.2 dev: true - /cosmiconfig@8.3.6(typescript@5.3.3): + /cosmiconfig@8.3.6(typescript@5.4.2): resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==} engines: {node: '>=14'} peerDependencies: @@ -1573,7 +1573,7 @@ packages: js-yaml: 4.1.0 parse-json: 5.2.0 path-type: 4.0.0 - typescript: 5.3.3 + typescript: 5.4.2 dev: true /cross-spawn@7.0.3: @@ -3862,8 +3862,8 @@ packages: picocolors: 1.0.0 sade: 1.8.1 svelte: 4.2.9 - svelte-preprocess: 5.1.3(postcss@8.4.30)(svelte@4.2.9)(typescript@5.3.3) - typescript: 5.3.3 + svelte-preprocess: 5.1.3(postcss@8.4.30)(svelte@4.2.9)(typescript@5.4.2) + typescript: 5.4.2 transitivePeerDependencies: - '@babel/core' - coffeescript @@ -3908,7 +3908,7 @@ packages: svelte: 4.2.9 dev: true - /svelte-preprocess@5.1.3(postcss@8.4.30)(svelte@4.2.9)(typescript@5.3.3): + /svelte-preprocess@5.1.3(postcss@8.4.30)(svelte@4.2.9)(typescript@5.4.2): resolution: {integrity: sha512-xxAkmxGHT+J/GourS5mVJeOXZzne1FR5ljeOUAMXUkfEhkLEllRreXpbl3dIYJlcJRfL1LO1uIAPpBpBfiqGPw==} engines: {node: '>= 16.0.0', pnpm: ^8.0.0} requiresBuild: true @@ -3953,7 +3953,7 @@ packages: sorcery: 0.11.0 strip-indent: 3.0.0 svelte: 4.2.9 - typescript: 5.3.3 + typescript: 5.4.2 dev: true /svelte@4.2.9: @@ -4070,13 +4070,13 @@ packages: engines: {node: '>=8'} dev: true - /ts-api-utils@1.0.3(typescript@5.3.3): + /ts-api-utils@1.0.3(typescript@5.4.2): resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} engines: {node: '>=16.13.0'} peerDependencies: typescript: '>=4.2.0' dependencies: - typescript: 5.3.3 + typescript: 5.4.2 dev: true /tslib@2.6.2: @@ -4115,8 +4115,8 @@ packages: engines: {node: '>=8'} dev: true - /typescript@5.3.3: - resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + /typescript@5.4.2: + resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} engines: {node: '>=14.17'} hasBin: true dev: true diff --git a/src/app.d.ts b/src/app.d.ts index c4675fa..ace1e20 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -59,4 +59,52 @@ declare namespace Intl { prototype: DurationFormat; new(locales?: LocalesArgument, options?: DurationFormatOptions): DurationFormat; }; + + // Borrowing from: https://github.com/microsoft/TypeScript/blob/e66049084b40ce85e28278c29cdd9784c7a9033a/src/lib/es2023.intl.d.ts + interface NumberFormatOptionsUseGroupingRegistry { + min2: never; + auto: never; + always: never; + } + + interface NumberFormatOptionsSignDisplayRegistry { + negative: never; + } + + interface NumberFormatOptions { + roundingPriority?: "auto" | "morePrecision" | "lessPrecision" | undefined; + roundingIncrement?: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000 | undefined; + roundingMode?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined; + trailingZeroDisplay?: "auto" | "stripIfInteger" | undefined; + } + + interface ResolvedNumberFormatOptions { + roundingPriority: "auto" | "morePrecision" | "lessPrecision"; + roundingMode: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven"; + roundingIncrement: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000; + trailingZeroDisplay: "auto" | "stripIfInteger"; + } + + interface NumberRangeFormatPart extends NumberFormatPart { + source: "startRange" | "endRange" | "shared"; + } + + interface NumberFormat { + formatRange(start: number | bigint, end: number | bigint): string; + formatRangeToParts(start: number | bigint, end: number | bigint): NumberRangeFormatPart[]; + } + + interface PluralRulesOptions { + roundingPriority?: "auto" | "morePrecision" | "lessPrecision" | undefined; + roundingIncrement?: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000 | undefined; + roundingMode?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined; + trailingZeroDisplay?: "auto" | "stripIfInteger" | undefined; + } + + interface ResolvedPluralRulesOptions { + roundingPriority: "auto" | "morePrecision" | "lessPrecision"; + roundingMode: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven"; + roundingIncrement: 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000; + trailingZeroDisplay: "auto" | "stripIfInteger"; + } } \ No newline at end of file diff --git a/src/lib/components/ui/Select.svelte b/src/lib/components/ui/Select.svelte index 821378a..ad627b9 100644 --- a/src/lib/components/ui/Select.svelte +++ b/src/lib/components/ui/Select.svelte @@ -17,6 +17,7 @@ export let fullWidth: boolean | undefined = undefined; export let removeEmpty: boolean | undefined = undefined; export let onChange: ((event: Event) => void) | undefined = undefined; + const getValue = (value: Type) => (value as string | number).toString();
@@ -30,7 +31,7 @@ {/if} {#each items as [key, value]} {#if value !== undefined} - + {/if} {/each} diff --git a/src/lib/format-options/common.options.ts b/src/lib/format-options/common.options.ts index f317d4e..cf39bed 100644 --- a/src/lib/format-options/common.options.ts +++ b/src/lib/format-options/common.options.ts @@ -1,2 +1,6 @@ export const style = [undefined, 'long', 'short', 'narrow'] as const; export const localeMatcher = [undefined, 'best fit', 'lookup'] as const; +export const roundingPriority = ["auto", "morePrecision", "lessPrecision", undefined] as const; +export const roundingIncrement = [1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000, undefined] as const +export const roundingMode = ["ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven", undefined] as const; +export const trailingZeroDisplay = ["auto", "stripIfInteger", undefined] as const; \ No newline at end of file diff --git a/src/lib/format-options/number-format.options.ts b/src/lib/format-options/number-format.options.ts index 4ba2b8f..2b51a49 100644 --- a/src/lib/format-options/number-format.options.ts +++ b/src/lib/format-options/number-format.options.ts @@ -1,7 +1,7 @@ import { currencies } from '$lib/locale-data/currencies'; import { units } from '$lib/locale-data/units'; import { defaultNumberRange } from '$lib/utils/format-utils'; -import { localeMatcher, style } from './common.options'; +import { localeMatcher, roundingIncrement, roundingMode, roundingPriority, trailingZeroDisplay, style } from './common.options'; export const numberFormatOptionsCommon = { style: ['currency', 'unit'], @@ -12,6 +12,10 @@ export const numberFormatOptionsCommon = { maximumFractionDigits: [...defaultNumberRange, undefined], minimumSignificantDigits: [...defaultNumberRange, undefined], maximumSignificantDigits: [...defaultNumberRange, undefined], + roundingIncrement, + roundingMode, + roundingPriority, + trailingZeroDisplay, localeMatcher } as const; diff --git a/src/lib/format-options/plural-rules.options.ts b/src/lib/format-options/plural-rules.options.ts index a5b7fc0..326f866 100644 --- a/src/lib/format-options/plural-rules.options.ts +++ b/src/lib/format-options/plural-rules.options.ts @@ -1,6 +1,16 @@ -import { localeMatcher } from './common.options'; +import { defaultNumberRange } from '$lib/utils/format-utils'; +import { localeMatcher, roundingIncrement, roundingMode, roundingPriority, trailingZeroDisplay } from './common.options'; export const pluralRulesFormatOptions = { type: ['cardinal', 'ordinal', undefined], + minimumIntegerDigits: [...defaultNumberRange, undefined], + minimumFractionDigits: [...defaultNumberRange, undefined], + maximumFractionDigits: [...defaultNumberRange, undefined], + minimumSignificantDigits: [...defaultNumberRange, undefined], + maximumSignificantDigits: [...defaultNumberRange, undefined], + roundingIncrement, + roundingMode, + roundingPriority, + trailingZeroDisplay, localeMatcher } as const; diff --git a/src/lib/playground/format.utils.ts b/src/lib/playground/format.utils.ts index f11fbb2..8d69239 100644 --- a/src/lib/playground/format.utils.ts +++ b/src/lib/playground/format.utils.ts @@ -77,10 +77,10 @@ export const schemaToPrimaryFormatterOutput = } // Casting to specific formatter to circumvent type errors, the types are too dynamic const primaryFormatter = schema.primaryFormatter as "formatToParts"; + //@ts-expect-error too complex type const formatted = (new Intl[schema.method]( locale, - // To dynamic to interpret this correctly - options as any + options ) as Intl.DateTimeFormat)[primaryFormatter](...prepareInputValues(schema)) if(schema.method === "Segmenter") { return `${print(Array.from(formatted))}` @@ -98,10 +98,10 @@ export const schemaToSecondaryFormattersOutput = { try { + //@ts-expect-error too complex type const output = (new Intl[schema.method]( locale, - // To dynamic to interpret this correctly - options as any + options ) as Intl.DateTimeFormat)[(formatter as "formatToParts")](...prepareInputValues(schema)) return { name: formatter, @@ -122,10 +122,10 @@ export const schemaToResolvedOptions = ( ) => { const { options } = prepareSchemaForOutput(schema); try { + //@ts-expect-error too complex type const intlObject = (new Intl[schema.method]( locale, - // To dynamic to interpret this correctly - options as any + options ) as Intl.PluralRules); return `${print(intlObject.resolvedOptions())}` } catch (error) { diff --git a/src/lib/playground/schemas/numberFormat.schema.ts b/src/lib/playground/schemas/numberFormat.schema.ts index 6b8fa4f..a6e9f4f 100644 --- a/src/lib/playground/schemas/numberFormat.schema.ts +++ b/src/lib/playground/schemas/numberFormat.schema.ts @@ -122,6 +122,30 @@ export const numberFormatSchema: PlaygroundSchema<'NumberFormat'> = { max: 21, min: 1 }, + { + name: 'roundingIncrement', + valueType: 'number', + defaultValue: undefined, + inputType: 'select' + }, + { + name: 'roundingMode', + valueType: 'string', + defaultValue: undefined, + inputType: 'select' + }, + { + name: 'roundingPriority', + valueType: 'string', + defaultValue: undefined, + inputType: 'select' + }, + { + name: 'trailingZeroDisplay', + valueType: 'string', + defaultValue: undefined, + inputType: 'select' + }, { name: 'localeMatcher', valueType: 'string', diff --git a/src/lib/playground/schemas/pluralRules.schema.ts b/src/lib/playground/schemas/pluralRules.schema.ts index e95654e..fdfd478 100644 --- a/src/lib/playground/schemas/pluralRules.schema.ts +++ b/src/lib/playground/schemas/pluralRules.schema.ts @@ -13,6 +13,69 @@ export const pluralRulesSchema: PlaygroundSchema<'PluralRules'> = { valueType: 'string', defaultValue: undefined, inputType: 'select' - } + }, + { + name: 'minimumIntegerDigits', + valueType: 'number', + defaultValue: undefined, + inputType: 'text', + max: 21, + min: 1 + }, + { + name: 'minimumFractionDigits', + valueType: 'number', + defaultValue: undefined, + inputType: 'text', + max: 20, + min: 1 + }, + { + name: 'maximumFractionDigits', + valueType: 'number', + defaultValue: undefined, + inputType: 'text', + max: 20, + min: 1 + }, + { + name: 'minimumSignificantDigits', + valueType: 'number', + defaultValue: undefined, + inputType: 'text', + max: 21, + min: 1 + }, + { + name: 'maximumSignificantDigits', + valueType: 'number', + defaultValue: undefined, + inputType: 'text', + max: 21, + min: 1 + }, { + name: 'roundingIncrement', + valueType: 'string', + defaultValue: undefined, + inputType: 'select' + }, + { + name: 'roundingMode', + valueType: 'string', + defaultValue: undefined, + inputType: 'select' + }, + { + name: 'roundingPriority', + valueType: 'string', + defaultValue: undefined, + inputType: 'select' + }, + { + name: 'trailingZeroDisplay', + valueType: 'string', + defaultValue: undefined, + inputType: 'select' + }, ] }; diff --git a/src/lib/utils/format-utils.ts b/src/lib/utils/format-utils.ts index 451fef6..e82d560 100644 --- a/src/lib/utils/format-utils.ts +++ b/src/lib/utils/format-utils.ts @@ -10,6 +10,7 @@ export const clampValue = ( if (typeof value !== 'string') return value; const parsed = parseInt(value, 10); if (isNaN(parsed)) return option.defaultValue; + if(!option.max && !option.min) return parsed; const clampedMax = option.max && parsed > option.max ? option.max : parsed; return option.min && parsed < option.min ? Math.max(option.min, clampedMax) : clampedMax; }; diff --git a/src/routes/DurationFormat/+page.server.ts b/src/routes/DurationFormat/+page.server.ts index b51dc0f..9d49fd7 100644 --- a/src/routes/DurationFormat/+page.server.ts +++ b/src/routes/DurationFormat/+page.server.ts @@ -2,6 +2,8 @@ import type { BrowserCompatData } from '$lib/types/BrowserSupport.types'; import { loadJson } from '$lib/utils/load-json'; import type { ServerLoadEvent } from '@sveltejs/kit'; +export const ssr = false; + export async function load(loadEvent: ServerLoadEvent): Promise { return loadJson(loadEvent); } diff --git a/src/routes/DurationFormat/+page.svelte b/src/routes/DurationFormat/+page.svelte index f6c8685..4afe6ac 100644 --- a/src/routes/DurationFormat/+page.svelte +++ b/src/routes/DurationFormat/+page.svelte @@ -14,8 +14,6 @@ const locale = getLocaleForSSR($page); - export const ssr = false; -