Skip to content

Commit

Permalink
fix(types): missing/wrong types for modal. dropdown, popup, transition
Browse files Browse the repository at this point in the history
Some types fixes to reflect settings in modal, dropdown, popup and transition
  • Loading branch information
lubber-de authored Aug 8, 2024
1 parent fb2d8fc commit 263c192
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 13 deletions.
35 changes: 27 additions & 8 deletions types/fomantic-ui-dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ declare namespace FomanticUI {
* Alternatively you can provide an 'object' to set individual values for hide/show transitions as well as hide/show duration.
* @default 'auto'
*/
transition: boolean | object;
transition: string | Dropdown.TransitionSettings;

/**
* Duration of animation events.
Expand All @@ -468,13 +468,6 @@ declare namespace FomanticUI {
*/
displayType: false | string;

/**
* Maximum glyph width, used to calculate search size.
* This is usually size of a "W" in your font in 'em'.
* @default 1.037
*/
glyphWidth: number;

/**
* Whether option headers should have an additional divider line underneath when converted from '<select><optgroup>'.
* @default true
Expand Down Expand Up @@ -648,6 +641,7 @@ declare namespace FomanticUI {
}

namespace Dropdown {
type TransitionSettings = Partial<Pick<Settings.Transition, keyof Settings.Transition>>;
type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
type MessageSettings = Partial<Pick<Settings.Messages, keyof Settings.Messages>>;
Expand All @@ -658,6 +652,31 @@ declare namespace FomanticUI {
type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;

namespace Settings {
interface Transition {

/**
* Named animation show event to used.
* Must be defined in CSS.
*/
showMethod: string;

/**
* Duration of the CSS show transition animation
*/
showDuration: number;

/**
* Named animation hide event to used.
* Must be defined in CSS.
*/
hideMethod: string;

/**
* Duration of the CSS hide transition animation
*/
hideDuration: number;
}

interface Selectors {
/**
* @default '.addition'
Expand Down
28 changes: 27 additions & 1 deletion types/fomantic-ui-modal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ declare namespace FomanticUI {
* Custom settings to extend UI dimmer.
* @default 'scale'
*/
transition: string | Partial<Pick<TransitionSettings, keyof TransitionSettings>>;
transition: string | Modal.TransitionSettings;

/**
* Duration of animation.
Expand Down Expand Up @@ -359,12 +359,38 @@ declare namespace FomanticUI {
}

namespace Modal {
type TransitionSettings = Partial<Pick<Settings.Transition, keyof Settings.Transition>>;
type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;
type TemplatesSettings = Partial<Pick<Settings.Templates, keyof Settings.Templates>> & {[key: string]: (...args: any) => Partial<Pick<ModalSettings, keyof ModalSettings>>};

namespace Settings {
interface Transition {

/**
* Named animation show event to used.
* Must be defined in CSS.
*/
showMethod: string;

/**
* Duration of the CSS show transition animation
*/
showDuration: number;

/**
* Named animation hide event to used.
* Must be defined in CSS.
*/
hideMethod: string;

/**
* Duration of the CSS hide transition animation
*/
hideDuration: number;
}

interface Selectors {
/**
* @default '> .header'
Expand Down
28 changes: 27 additions & 1 deletion types/fomantic-ui-popup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ declare namespace FomanticUI {
* Alternatively you can provide an object to set individual values for hide/show transitions as well as hide/show duration.
* @default 'scale'
*/
transition: string | object;
transition: string | Popup.TransitionSettings;

/**
* Duration of animation events.
Expand Down Expand Up @@ -390,12 +390,38 @@ declare namespace FomanticUI {
}

namespace Popup {
type TransitionSettings = Partial<Pick<Settings.Transition, keyof Settings.Transition>>;
type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
type MetadataSettings = Partial<Pick<Settings.Metadatas, keyof Settings.Metadatas>>;
type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;

namespace Settings {
interface Transition {

/**
* Named animation show event to used.
* Must be defined in CSS.
*/
showMethod: string;

/**
* Duration of the CSS show transition animation
*/
showDuration: number;

/**
* Named animation hide event to used.
* Must be defined in CSS.
*/
hideMethod: string;

/**
* Duration of the CSS hide transition animation
*/
hideDuration: number;
}

interface Selectors {
/**
* @default '.ui.popup'
Expand Down
12 changes: 9 additions & 3 deletions types/fomantic-ui-transition.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,23 @@ declare namespace FomanticUI {
displayType: false | string;

/**
* Specify the final display type (block, inline-block etc) so that it doesn't have to be calculated.
* @default '500ms'
* Duration of the CSS transition animation
* @default false
*/
duration: string;
duration: string | number | false;

/**
* If enabled a 'timeout' will be added to ensure 'animationend' callback occurs even if element is hidden.
* @default true
*/
useFailSafe: boolean;

/**
* Delay in ms for fail safe
* @default 100
*/
failSafeDelay: number;

/**
* If enabled will allow same animation to be queued while it is already occurring.
* @default false
Expand Down

0 comments on commit 263c192

Please sign in to comment.