mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
[semantic-ui-visibility] Different weak-type workaround.
This commit is contained in:
+53
-10
@@ -39,19 +39,60 @@ declare namespace SemanticUI {
|
||||
*/
|
||||
(behavior: 'get screen size'): Visibility.ScreenSize;
|
||||
(behavior: 'destroy'): JQuery;
|
||||
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value?: undefined): VisibilitySettings[K];
|
||||
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value: VisibilitySettings[K]): JQuery;
|
||||
(behavior: 'setting', value: VisibilitySettings.Param): JQuery;
|
||||
(settings?: VisibilitySettings.Param): JQuery;
|
||||
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value?: undefined): VisibilitySettings._Impl[K];
|
||||
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value: VisibilitySettings._Impl[K]): JQuery;
|
||||
(behavior: 'setting', value: VisibilitySettings): JQuery;
|
||||
(settings?: VisibilitySettings): JQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link http://semantic-ui.com/behaviors/visibility.html#/settings}
|
||||
*/
|
||||
interface VisibilitySettings extends Pick<VisibilitySettings._Impl, keyof VisibilitySettings._Impl> { }
|
||||
type VisibilitySettings = VisibilitySettings.Param;
|
||||
|
||||
namespace VisibilitySettings {
|
||||
type Param = VisibilitySettings | object;
|
||||
type Param = (Pick<_Impl, 'once'> |
|
||||
Pick<_Impl, 'continuous'> |
|
||||
Pick<_Impl, 'type'> |
|
||||
Pick<_Impl, 'initialCheck'> |
|
||||
Pick<_Impl, 'context'> |
|
||||
Pick<_Impl, 'refreshOnLoad'> |
|
||||
Pick<_Impl, 'refreshOnResize'> |
|
||||
Pick<_Impl, 'checkOnRefresh'> |
|
||||
Pick<_Impl, 'zIndex'> |
|
||||
Pick<_Impl, 'offset'> |
|
||||
Pick<_Impl, 'includeMargin'> |
|
||||
Pick<_Impl, 'throttle'> |
|
||||
Pick<_Impl, 'observeChanges'> |
|
||||
Pick<_Impl, 'transition'> |
|
||||
Pick<_Impl, 'duration'> |
|
||||
Pick<_Impl, 'onTopVisible'> |
|
||||
Pick<_Impl, 'onTopPassed'> |
|
||||
Pick<_Impl, 'onBottomVisible'> |
|
||||
Pick<_Impl, 'onPassing'> |
|
||||
Pick<_Impl, 'onBottomPassed'> |
|
||||
Pick<_Impl, 'onTopVisibleReverse'> |
|
||||
Pick<_Impl, 'onTopPassedReverse'> |
|
||||
Pick<_Impl, 'onBottomVisibleReverse'> |
|
||||
Pick<_Impl, 'onPassingReverse'> |
|
||||
Pick<_Impl, 'onBottomPassedReverse'> |
|
||||
Pick<_Impl, 'onOnScreen'> |
|
||||
Pick<_Impl, 'onOffScreen'> |
|
||||
Pick<_Impl, 'onLoad'> |
|
||||
Pick<_Impl, 'onAllLoaded'> |
|
||||
Pick<_Impl, 'onFixed'> |
|
||||
Pick<_Impl, 'onUnfixed'> |
|
||||
Pick<_Impl, 'onUpdate'> |
|
||||
Pick<_Impl, 'onRefresh'> |
|
||||
Pick<_Impl, 'className'> |
|
||||
Pick<_Impl, 'error'> |
|
||||
Pick<_Impl, 'namespace'> |
|
||||
Pick<_Impl, 'name'> |
|
||||
Pick<_Impl, 'silent'> |
|
||||
Pick<_Impl, 'debug'> |
|
||||
Pick<_Impl, 'performance'> |
|
||||
Pick<_Impl, 'verbose'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
// region Functionality
|
||||
@@ -337,10 +378,11 @@ declare namespace SemanticUI {
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
|
||||
type ClassNameSettings = ClassNameSettings.Param;
|
||||
|
||||
namespace ClassNameSettings {
|
||||
type Param = ClassNameSettings | object;
|
||||
type Param = (Pick<_Impl, 'fixed'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -350,10 +392,11 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
|
||||
type ErrorSettings = ErrorSettings.Param;
|
||||
|
||||
namespace ErrorSettings {
|
||||
type Param = ErrorSettings | object;
|
||||
type Param = (Pick<_Impl, 'method'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function test_visibility_static() {
|
||||
$.fn.visibility.settings.error.method = 'method';
|
||||
$.fn.visibility.settings.error!.method = 'method';
|
||||
$.fn.visibility.settings.namespace = 'namespace';
|
||||
$.fn.visibility.settings.name = 'name';
|
||||
$.fn.visibility.settings.silent = false;
|
||||
@@ -10,42 +10,19 @@ function test_visibility_static() {
|
||||
|
||||
function test_visibility() {
|
||||
const selector = '.ui.visibility';
|
||||
$(selector).visibility('disable callbacks') === $();
|
||||
$(selector).visibility('enable callbacks') === $();
|
||||
$(selector).visibility('is on screen') === false;
|
||||
$(selector).visibility('is off screen') === true;
|
||||
$(selector).visibility('get pixels passed') === 20;
|
||||
$(selector).visibility('get element calculations') === {
|
||||
fits: false,
|
||||
offset: {
|
||||
top: 955.96875,
|
||||
left: 292
|
||||
},
|
||||
width: 466,
|
||||
height: 1665.890625,
|
||||
top: 955.96875,
|
||||
bottom: 2621.859375,
|
||||
topPassed: true,
|
||||
bottomPassed: false,
|
||||
topVisible: true,
|
||||
bottomVisible: false,
|
||||
pixelsPassed: 742.03125,
|
||||
percentagePassed: 0.44542615155182,
|
||||
onScreen: true,
|
||||
passing: true,
|
||||
offScreen: false
|
||||
};
|
||||
$(selector).visibility('get screen calculations') === {
|
||||
bottom: 2658,
|
||||
top: 1698
|
||||
};
|
||||
$(selector).visibility('get screen size') === {
|
||||
height: 960
|
||||
};
|
||||
$(selector).visibility('destroy') === $();
|
||||
$(selector).visibility('setting', 'debug', undefined) === false;
|
||||
$(selector).visibility('setting', 'debug') === false;
|
||||
$(selector).visibility('setting', 'debug', true) === $();
|
||||
$(selector).visibility('disable callbacks'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).visibility('enable callbacks'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).visibility('is on screen'); // $ExpectType boolean
|
||||
$(selector).visibility('is off screen'); // $ExpectType boolean
|
||||
$(selector).visibility('get pixels passed'); // $ExpectType number
|
||||
$(selector).visibility('get element calculations'); // $ExpectType ElementCalculations
|
||||
$(selector).visibility('get screen calculations'); // $ExpectType ScreenCalculations
|
||||
$(selector).visibility('get screen size'); // $ExpectType ScreenSize
|
||||
$(selector).visibility('destroy'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).visibility('setting', 'debug', undefined); // $ExpectType boolean
|
||||
$(selector).visibility('setting', 'debug'); // $ExpectType boolean
|
||||
$(selector).visibility('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(selector).visibility('setting', {
|
||||
namespace: 'namespace',
|
||||
name: 'name',
|
||||
@@ -53,7 +30,8 @@ function test_visibility() {
|
||||
debug: true,
|
||||
performance: true,
|
||||
verbose: true
|
||||
}) === $();
|
||||
});
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(selector).visibility({
|
||||
once: false,
|
||||
continuous: true,
|
||||
@@ -71,78 +49,59 @@ function test_visibility() {
|
||||
transition: 'fade',
|
||||
duration: 5,
|
||||
onTopVisible() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onTopPassed() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onBottomVisible() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onPassing() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onBottomPassed() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onTopVisibleReverse() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onTopPassedReverse() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onBottomVisibleReverse() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onPassingReverse() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onBottomPassedReverse() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onOnScreen() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onOffScreen() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onLoad() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onAllLoaded() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onFixed() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onUnfixed() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onUpdate(calculations) {
|
||||
this === $();
|
||||
calculations === {
|
||||
fits: false,
|
||||
offset: {
|
||||
top: 955.96875,
|
||||
left: 292
|
||||
},
|
||||
width: 466,
|
||||
height: 1665.890625,
|
||||
top: 955.96875,
|
||||
bottom: 2621.859375,
|
||||
topPassed: true,
|
||||
bottomPassed: false,
|
||||
topVisible: true,
|
||||
bottomVisible: false,
|
||||
pixelsPassed: 742.03125,
|
||||
percentagePassed: 0.44542615155182,
|
||||
onScreen: true,
|
||||
passing: true,
|
||||
offScreen: false
|
||||
};
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
calculations; // $ExpectType ElementCalculations
|
||||
},
|
||||
onRefresh() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
className: {
|
||||
fixed: 'fixed',
|
||||
@@ -150,12 +109,16 @@ function test_visibility() {
|
||||
error: {
|
||||
method: 'method'
|
||||
}
|
||||
}) === $();
|
||||
$(selector).visibility() === $();
|
||||
});
|
||||
$(selector).visibility(); // $ExpectType JQuery<HTMLElement>
|
||||
|
||||
$(selector).visibility('foo'); // $ExpectError
|
||||
$(selector).visibility({ foo: 'bar' }); // $ExpectError
|
||||
}
|
||||
|
||||
import visibility = require('semantic-ui-visibility');
|
||||
|
||||
function test_module() {
|
||||
visibility; // $ExpectType Visibility
|
||||
$.fn.visibility = visibility;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user