mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-17 17:48:06 +00:00
🤖 Merge PR #65730 [minimasonry] Initial types for minimasonry by @plbstl
* add types for minimasonry 1.3 * update minimasonry types to be used through a default ESM import * update minimasonry types to allow use as a browser script * remove dtslint errors - strict-export-declare-modifiers - npm-naming
This commit is contained in:
85
types/minimasonry/index.d.ts
vendored
Normal file
85
types/minimasonry/index.d.ts
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
// Type definitions for minimasonry 1.3
|
||||
// Project: https://spope.github.io/MiniMasonry.js/
|
||||
// Definitions by: Paul Ebose <https://github.com/plbstl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyType
|
||||
|
||||
export interface MiniMasonryOptions {
|
||||
/**
|
||||
* Target width of elements.
|
||||
* @default 255
|
||||
*/
|
||||
baseWidth?: number;
|
||||
/**
|
||||
* Container's selector or element.
|
||||
*/
|
||||
container: string | HTMLElement;
|
||||
/**
|
||||
* Width / height of gutter between elements. Use gutterX / gutterY to set different values.
|
||||
* @default 10
|
||||
*/
|
||||
gutter?: number;
|
||||
/**
|
||||
* Width of gutter between elements. Need gutterY to work, fallback to `gutter`.
|
||||
*/
|
||||
gutterX?: number;
|
||||
/**
|
||||
* Height of gutter between elements. Need gutterX to work, fallback to `gutter`.
|
||||
*/
|
||||
gutterY?: number;
|
||||
/**
|
||||
* Whether or not MiniMasonry places elements on the shortest column or keeps exact order of the list.
|
||||
* @default true
|
||||
*/
|
||||
minify?: boolean;
|
||||
/**
|
||||
* Set left gutter on first columns and right gutter on last.
|
||||
* @default true
|
||||
*/
|
||||
surroundingGutter?: boolean;
|
||||
/**
|
||||
* Gutter applied when only 1 column can be displayed.
|
||||
* @default 5
|
||||
*/
|
||||
ultimateGutter?: number;
|
||||
/**
|
||||
* Sorting direction, "ltr" or "rtl".
|
||||
* @default "ltr"
|
||||
*/
|
||||
direction?: 'ltr' | 'rtl';
|
||||
/**
|
||||
* False will start to sort from center, true will start from left or right according to direction parameter.
|
||||
* @default false
|
||||
*/
|
||||
wedge?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* You should have a container **relatively positioned** with your elements as children. Those children elements must be **absolutely positioned**.
|
||||
*
|
||||
* MiniMasonry will add a "resize" event listener on the window to redraw the masonry on window resize. This listener is throttled to *66ms (15fps)*.
|
||||
*
|
||||
* @example
|
||||
* import MiniMasonry from "minimasonry";
|
||||
* const masonry = new MiniMasonry({
|
||||
* container: '.masonry_transition'
|
||||
* });
|
||||
*/
|
||||
// tslint:disable-next-line:npm-naming
|
||||
export default class MiniMasonry {
|
||||
constructor(options: MiniMasonryOptions);
|
||||
/**
|
||||
* If list has changed, trigger a re-layout of the masonry.
|
||||
*/
|
||||
layout(): void;
|
||||
/**
|
||||
* Remove the resize listener and set back container as it was before initialization.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
// browser global variable `MiniMasonry`
|
||||
declare global {
|
||||
interface Window {
|
||||
MiniMasonry: MiniMasonry;
|
||||
}
|
||||
}
|
||||
19
types/minimasonry/minimasonry-tests.ts
Normal file
19
types/minimasonry/minimasonry-tests.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import MiniMasonry from 'minimasonry';
|
||||
|
||||
// $ExpectType MiniMasonry
|
||||
const masonry0 = window.MiniMasonry;
|
||||
|
||||
// $ExpectType MiniMasonry
|
||||
const masonry = new MiniMasonry({ container: '' });
|
||||
|
||||
// @ts-expect-error
|
||||
const masonry1 = new MiniMasonry(); // needs an argument
|
||||
|
||||
// @ts-expect-error
|
||||
const masonry2 = new MiniMasonry(''); // wrong argument type
|
||||
|
||||
// @ts-expect-error
|
||||
const masonry3 = new MiniMasonry({}); // `container` is required
|
||||
|
||||
// @ts-expect-error
|
||||
const masonry4 = new MiniMasonry({ baseWidth: 255 }); // `container` is required
|
||||
24
types/minimasonry/tsconfig.json
Normal file
24
types/minimasonry/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"minimasonry-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/minimasonry/tslint.json
Normal file
1
types/minimasonry/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "@definitelytyped/dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user