@melt-ui/svelte
Advanced tools
Comparing version 0.47.5 to 0.47.6
@@ -48,3 +48,3 @@ /// <reference types="svelte" /> | ||
states: { | ||
value: (Multiple extends false ? import("svelte/store").Writable<string | undefined> : import("svelte/store").Writable<string[] | undefined>) & {}; | ||
value: import("svelte/store").Writable<import("../../internal/types.js").WhenTrue<Multiple, string[], string, string | string[]> | undefined>; | ||
}; | ||
@@ -51,0 +51,0 @@ helpers: { |
@@ -1,2 +0,2 @@ | ||
import type { BuilderReturn } from '../../internal/types.js'; | ||
import type { BuilderReturn, WhenTrue } from '../../internal/types.js'; | ||
import type { Writable } from 'svelte/store'; | ||
@@ -6,2 +6,3 @@ import type { createAccordion } from './create.js'; | ||
export type { AccordionComponentEvents } from './events.js'; | ||
type AccordionValue<Multiple extends boolean> = WhenTrue<Multiple, string[], string>; | ||
export type CreateAccordionProps<Multiple extends boolean = false> = { | ||
@@ -32,3 +33,3 @@ /** | ||
*/ | ||
defaultValue?: Multiple extends false ? string : string[]; | ||
defaultValue?: AccordionValue<Multiple>; | ||
/** | ||
@@ -40,3 +41,3 @@ * The controlled value store for the accordion. | ||
*/ | ||
value?: Multiple extends false ? Writable<string | undefined> : Writable<string[] | undefined>; | ||
value?: Writable<AccordionValue<Multiple> | undefined>; | ||
/** | ||
@@ -47,3 +48,3 @@ * A callback called when the value of the `value` store should be changed. | ||
*/ | ||
onValueChange?: Multiple extends false ? ChangeFn<string | undefined> : ChangeFn<string[] | undefined>; | ||
onValueChange?: ChangeFn<AccordionValue<Multiple> | undefined>; | ||
}; | ||
@@ -50,0 +51,0 @@ export type AccordionItemProps = { |
@@ -55,2 +55,5 @@ import type { ActionReturn } from 'svelte/action'; | ||
}; | ||
export type WhenTrue<TrueOrFalse, IfTrue, IfFalse, IfNeither = IfTrue | IfFalse> = [ | ||
TrueOrFalse | ||
] extends [true] ? IfTrue : [TrueOrFalse] extends [false] ? IfFalse : IfNeither; | ||
export {}; |
export {}; | ||
// This type is awesome, but can't be annotated it seems. | ||
// type Default<Label extends string> = `default${Capitalize<Label>}`; | ||
// type onChange<Label extends string> = `on${Capitalize<Label>}Change`; | ||
// type WithChangeFn<Label extends string, T> = { | ||
// [K in Default<Label> | onChange<Label> | Label]: K extends Default<Label> | ||
// ? T | ||
// : T extends onChange<Label> | ||
// ? ChangeFn<T> | ||
// : Writable<T>; | ||
// }; |
{ | ||
"name": "@melt-ui/svelte", | ||
"version": "0.47.5", | ||
"version": "0.47.6", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "exports": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
614089
14256