mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge pull request #22084 from sinziananicolae/add-clamp-js-main-types
Add clamp-js-main types
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import clamp, { ClampOptions, ClampResponse } from 'clamp-js-main';
|
||||
|
||||
const element: HTMLElement = document.createElement('div');
|
||||
element.style.setProperty('width', '5px');
|
||||
element.style.setProperty('height', '5px');
|
||||
element.style.setProperty('font-size', '12px');
|
||||
|
||||
const span: HTMLSpanElement = document.createElement('span');
|
||||
span.textContent = "Lorem ipsum. Lorem ipsum";
|
||||
element.appendChild(span);
|
||||
|
||||
const simpleClamp: ClampResponse = clamp(element);
|
||||
|
||||
const options: ClampOptions = {
|
||||
clamp: 2,
|
||||
useNativeClamp: false,
|
||||
splitOnChars: ['.'],
|
||||
animate: true,
|
||||
truncationChar: '--',
|
||||
truncationHTML: '<span></span>'
|
||||
};
|
||||
const clampWithOptions: ClampResponse = clamp(element, options);
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for clamp-js-main 0.11
|
||||
// Project: https://github.com/jmenglis/clamp-js-main#readme
|
||||
// Definitions by: Sinziana Nicolae <https://github.com/sinziananicolae>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface ClampOptions {
|
||||
clamp?: number|string;
|
||||
useNativeClamp?: boolean;
|
||||
splitOnChars?: string[];
|
||||
animate?: boolean;
|
||||
truncationChar?: string;
|
||||
truncationHTML?: string | null;
|
||||
}
|
||||
|
||||
export interface ClampResponse {
|
||||
original: string;
|
||||
clamped: string;
|
||||
}
|
||||
|
||||
export default function clamp(element: HTMLElement, options?: ClampOptions): ClampResponse;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"clamp-js-main-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user