[juijs] update jui, jui-core, jui-grid library (#13806)

* add jui-core

* update index.d.ts for jui-core

* update index.d.ts for jui

* update index.d.ts for jui

* update index.d.ts for jui-grid

* update index.d.ts for jui-grid

* fixed lint

* fixed lint for jui-core and jui-grid

* remove jquery.d.ts in tsconfig.json

* update rule for lint

* update rule for lint

* fixed space-before-function-paren problems

* update jui-core/index.d.ts
This commit is contained in:
jinho park
2017-01-17 17:34:44 -08:00
committed by Mohamed Hegazy
parent 9001e6d0ef
commit 4a723dcede
12 changed files with 3584 additions and 0 deletions
+824
View File
@@ -0,0 +1,824 @@
// Type definitions for jui-core 2.0
// Project: https://github.com/juijs/jui-core
// Definitions by: JinHo Park <https://github.com/easylogic>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery"/>
declare var jui: JuiStatic;
interface UtilBase {
/**
* @property browser check browser agent
* @property {Boolean} browser.webkit Webkit 브라우저 체크
* @property {Boolean} browser.mozilla Mozilla 브라우저 체크
* @property {Boolean} browser.msie IE 브라우저 체크 */
browser: {
webkit: boolean,
mozilla: boolean,
msie: boolean
};
/**
* @property {Boolean} isTouch
* check touch device
*/
isTouch: boolean;
/**
* @method inherit
*
* 프로토타입 기반의 상속 제공
*
* @param {Function} ctor base Class
* @param {Function} superCtor super Class
*/
inherit( ctor: ((...args: any[]) => any), superCtor: ((...args: any[]) => any) ): void;
/**
* @method extend
*
* implements object extend
*
* @param {Object|Function} origin
* @param {Object|Function} add
* @param {Boolean} skip
* @return {Object}
*/
extend(origin: any, add: any, skip: boolean): any;
/**
* convert px to integer
* @param {String or Number} px
* @return {Number}
*/
pxToInt(px: string| number): number;
/**
* @method clone
* implements object clone
* @param {Array/Object} obj 복사할 객체
* @return {Array}
*/
clone(obj: any): any[];
/**
* @method deepClone
* implements object deep clone
* @param obj
* @param emit
* @return {*}
*/
deepClone(obj: any, emit: any): any[];
/**
* @method sort
* use QuickSort
* @param {Array} array
* @return {QuickSort}
*/
sort(array: any[]): UtilQuickSort;
/**
* @method runtime
*
* caculate callback runtime
*
* @param {String} name
* @param {Function} callback
*/
runtime(name: string, callback: ((...args: any[]) => void)): void;
/**
* @method template
* parsing template string
* @param html
* @param obj
*/
template(html: string, obj?: any): ((obj: any) => string) | string;
/**
* @method resize
* add event in window resize event
* @param {Function} callback
* @param {Number} ms delay time
*/
resize(callback: ((...args: any[]) => void), ms: number): void;
/**
* @method index
*
* IndexParser 객체 생성
*
* @return {KeyParser}
*/
index(): UtilKeyParser;
/**
* @method chunk
* split array by length
* @param {Array} arr
* @param {Number} len
* @return {Array}
*/
chunk(arr: any[], len: number): any[];
/**
* @method typeCheck
* check data type
* @param {String} t type string
* @param {Object} v value object
* @return {Boolean}
*/
typeCheck(typeName: string, value: any): boolean;
typeCheckObj(uiObj: any, list: any): void;
/**
* @method dataToCsv
*
* data 를 csv 로 변환한다.
*
* @param {Array} keys
* @param {Array} dataList
* @param {Number} dataSize
* @return {String} 변환된 csv 문자열
*/
dataToCsv(keys: string[] , dataList: any[], dataSize: number): string;
/**
* @method dataToCsv2
*
* @param {Object} options
* @return {String}
*/
dataToCsv2(options: any): string;
/**
* @method fileToCsv
*
* file 에서 csv 컨텐츠 로드
*
* @param {File} file
* @param {Function} callback
*/
fileToCsv(fileText: string, callback: ((data: any) => void)): void;
/**
* @method csvToBase64
*
* csv 다운로드 링크로 변환
*
* @param {String} csv
* @return {String} data uri string
*/
csvToBase64(csv: string): string;
/**
* @method csvToData
*
* @param {Array} keys
* @param {String} csv
* @param {Number} csvNumber
* @return {Array}
*/
csvToData(keys: string[], csv: string, csvNumber: number): any[];
/**
* @method getCsvFields
*
* csv 에서 필드 얻어오기
*
* @param {Array} fields
* @param {Array} csvFields
* @return {Array}
*/
getCsvFields(fields: string[], csvFields: string[]): string[];
/**
* @method svgToBase64
*
* xml 문자열로 svg datauri 생성
*
* @param {String} xml
* @return {String} 변환된 data uri 링크
*/
svgToBase64(xml: string): string;
/**
* @method dateFormat
*
* implements date format function
*
* yyyy : 4 digits year
* yy : 2 digits year
* y : 1 digit year
*
* @param {Date} date
* @param {String} format date format string
* @param {Boolean} utc
* @return {string}
*/
dateFormat(date: Date, format: string, utc?: boolean): string;
/**
* @method createId
*
* 유니크 아이디 생성
*
* @param {String} key prefix string
* @return {String} 생성된 아이디 문자열
*/
createId(key: string): string;
/**
* @method btoa
*
* Base64 인코딩
*
* @return {String}
*/
btoa(input: any): string;
/**
* @method atob
*
* Base64 디코딩
*
* @return {Any}
*/
atob(input: string): any;
/**
* implement async loop without blocking ui
*
* @param {Number} total loop count
* @param {Object} context
* @returns {Function}
*/
timeLoop(total: number, context?: any): ((index: number) => void);
/**
* @method loop
*
* 최적화된 루프 생성 (5단계로 나눔)
*
* @param {Number} total loop count
* @param {Object} [context=null]
* @return {Function} 최적화된 루프 콜백 (index, groupIndex 2가지 파라미터를 받는다.)
*/
loop(total: number, context?: any): ((index: number, groupIndex: number) => void );
/**
* @method loopArray
*
* 배열을 사용해서 최적화된 루프로 생성한다.
*
*
* @param {Array} data 루프로 생성될 배열
* @param {Object} [context=null]
* @return {Function} 최적화된 루프 콜백 (data, index, groupIndex 3가지 파라미터를 받는다.)
*/
loopArray(data: any[], context?: any): ((data: any, index: number, groupIndex: number) => void );
/**
* @method makeIndex
*
* 배열의 키 기반 인덱스를 생성한다.
*
* 개별 값 별로 멀티 인덱스를 생성한다.
*
* @param {Array} data
* @param {String} keyField
* @return {Object} 생성된 인덱스
*/
makeIndex(data: any[], keyField: string): any;
/**
* @method startsWith
* Check that it matches the starting string search string.
*
* @param {String} string
* @param {String} searchString
* @param {Number} [position=0]
* @return {Number} position
*/
startsWith(str: string, searchString: string, position?: number): number;
/**
* @method endsWith
* Check that it matches the end of a string search string.
*
* @param {String} string
* @param {String} searchString
* @return {Number} position
*/
endsWith(str: string, searchString: string, position?: number): number;
inArray(target: any, list: any[]): number;
trim(text: string): string;
ready: ((...args: any[]) => void);
param(data: any): string;
ajax(data: any): void;
scrollWidth(): number;
}
interface JuiStatic {
/**
* @method ready
*
* ready 타임에 실행될 callback 정의
*
* @param {Function} callback
*/
ready(depends?: string[], callback?: (...args: any[]) => void): void;
/**
* @method defineUI
*
* 사용자가 실제로 사용할 수 있는 UI 클래스를 정의
*
* @param {String} name 모듈 로드와 상속에 사용될 이름을 정한다.
* @param {Array} depends 'define'이나 'defineUI'로 정의된 클래스나 객체를 인자로 받을 수 있다.
* @param {Function} callback UI 클래스를 해당 콜백 함수 내에서 클래스 형태로 구현하고 리턴해야 한다.
*/
defineUI(name: string, depends: string[], callback: () => void, parent?: string): void;
/**
* @method define
*
* UI 클래스에서 사용될 클래스를 정의하고, 자유롭게 상속할 수 있는 클래스를 정의
*
* @param {String} name 모듈 로드와 상속에 사용될 이름을 정한다.
* @param {Array} depends 'define'이나 'defineUI'로 정의된 클래스나 객체를 인자로 받을 수 있다.
* @param {Function} callback UI 클래스를 해당 콜백 함수 내에서 클래스 형태로 구현하고 리턴해야 한다.
* @param {String} parent 상속받을 클래스
*/
define(name: string, depends: string[], callback: () => void, parent?: string): void;
/**
* @method redefine
*
* UI 클래스에서 사용될 클래스를 정의하고, 자유롭게 상속할 수 있는 클래스를 정의
*
* @param {String} name 모듈 로드와 상속에 사용될 이름을 정한다.
* @param {Array} depends 'define'이나 'defineUI'로 정의된 클래스나 객체를 인자로 받을 수 있다.
* @param {Function} callback UI 클래스를 해당 콜백 함수 내에서 클래스 형태로 구현하고 리턴해야 한다.
* @param {String} parent 상속받을 클래스
*/
redefine(name: string, depends: string[], callback: () => void, parent?: string): void;
/**
* define과 defineUI로 정의된 클래스 또는 객체를 가져온다.
*
* @param name 가져온 클래스 또는 객체의 이름
* @return {*}
*/
include(name: string): any;
/**
* define과 defineUI로 정의된 모든 클래스와 객체를 가져온다.
*
* @return {Array}
*/
includeAll(): any[];
/**
* @method add
* Adds a component object created
*
* @param {Object} ui UI instance
*/
add(uiIns: any): void;
/**
* @method emit
* Generates a custom event to an applicable component
*
* @param {String} key Selector or UI type
* @param {String} type Event type
* @param {Array} args Event arguments
*/
emit(key: string, type: string, args: any[]): void;
/**
* @method get
* Gets a component currently created
*
* @param {Integer/String} key
* @returns {Object/Array} UI instance
*/
get(key: number|string): any;
/**
* @method getAll
* Gets all components currently created
*
* @return {Array} UI instances
*/
getAll(): any[];
/**
* @method create
* It is possible to create a component dynamically after the ready point
*
* @param {String} type UI type
* @param {String/DOMElement} selector
* @param {Object} options
* @return {Object}
*/
create(type: string, selector: any, options?: {}): any;
}
interface UICollection {
destroy(): void;
}
interface UICore {
tpl?: any;
event?: any;
root?: any;
/**
* @method emit
* Generates a custom event. The first parameter is the type of a custom event. A function defined as an option or on method is called
*
* @param {String} type Event type
* @param {Function} args Event Arguments
* @return {Mixed}
*/
emit(type: string, args: () => void): any;
/**
* @method on
* A callback function defined as an on method is run when an emit method is called
*
* @param {String} type Event type
* @param {Function} callback
*/
on(type: string, callback: () => void): void;
/**
* @method off
* Removes a custom event of an applicable type or callback handler
*
* @param {String} type Event type
*/
off(type: string): void;
/**
* @method addValid
* Check the parameter type of a UI method and generates an alarm when a wrong value is entered
*
* @param {String} name Method name
* @param {Array} params Parameters
*/
addValid(name: string, params: any[]): void;
/**
* @method callBefore
* Sets a callback function that is called before a UI method is run
*
* @param {String} name Method name
* @param {Function} callback
* @return {Mixed}
*/
callBefore(name: string, callback: () => void): void;
/**
* @method callAfter
* Sets a callback function that is called after a UI method is run
*
* @param {String} name Method name
* @param {Function} callback
* @return {Mixed}
*/
callAfter(name: string, callback: () => void): void;
/**
* @method callDelay
* Sets a callback function and the delay time before/after a UI method is run
*
* @param {String} name Method name
* @param {Function} callback
*/
callDelay(name: string, callObj: () => void): void;
/**
* @method setTpl
* Dynamically defines the template method of a UI
*
* @param {String} name Template name
* @param {String} html Template markup
*/
setTpl(name: string, html: string): void;
/**
* @method setOption
* Dynamically defines the options of a UI
*
* @param {String} key
* @param {Mixed} value
*/
setOption(key: string, value: any): void;
/**
* @method destroy
* Removes all events set in a UI obejct and the DOM element
*
*/
destroy(): void;
}
//noinspection TypeScriptUnresolvedVariable
export interface UIEvent extends UICore {
root?: any;
/**
* @method find
* Get the child element of the root element
*
* @param {String/HTMLElement} Selector
* @returns {*|jQuery}
*/
find(selector: any): JQuery;
}
export class ColorScale {
domain(color: string, color2: string): this;
ticks(max: number): this;
}
export interface UtilColor {
/**
* @method format
*
* convert color to format string
*
* // hex
* color.format({ r : 255, g : 255, b : 255 }, 'hex') // #FFFFFF
*
* // rgb
* color.format({ r : 255, g : 255, b : 255 }, 'rgb') // rgba(255, 255, 255, 0.5);
*
* // rgba
* color.format({ r : 255, g : 255, b : 255, a : 0.5 }, 'rgb') // rgba(255, 255, 255, 0.5);
*
* @param {Object} obj obj has r, g, b and a attributes
* @param {"hex"/"rgb"} type format string type
* @returns {*}
*/
format(obj: any, type: string): string;
/**
* @method scale
*
* get color scale
*
* var c = color.scale().domain('#FF0000', '#00FF00');
*
* // get middle color
* c(0.5) == #808000
*
* // get middle color list
* c.ticks(20); // return array , [startColor, ......, endColor ]
*
* @returns {func} scale function
*/
scale(): ColorScale;
/**
* @method map
*
* create color map
*
* var colorList = color.map(['#352a87', '#0f5cdd', '#00b5a6', '#ffc337', '#fdff00'], count)
*
* @param {Array} color_list
* @param {Number} count a divide number
* @returns {Array} converted color list
*/
map(color_list: string[], count: number): string[];
/**
* @method rgb
*
* parse string to rgb color
*
* color.rgb("#FF0000") === { r : 255, g : 0, b : 0 }
*
* color.rgb("rgb(255, 0, 0)") == { r : 255, g : 0, b : }
*
* @param {String} str color string
* @returns {Object} rgb object
*/
rgb(str: string): any;
/**
* @method HSVtoRGB
*
* convert hsv to rgb
*
* color.HSVtoRGB(0,0,1) === #FFFFF === { r : 255, g : 0, b : 0 }
*
* @param {Number} H hue color number (min : 0, max : 360)
* @param {Number} S Saturation number (min : 0, max : 1)
* @param {Number} V Value number (min : 0, max : 1 )
* @returns {Object}
*/
HSVtoRGB(H: number, S: number, V: number): any;
/**
* @method RGBtoHSV
*
* convert rgb to hsv
*
* color.RGBtoHSV(0, 0, 255) === { h : 240, s : 1, v : 1 } === '#FFFF00'
*
* @param {Number} R red color value
* @param {Number} G green color value
* @param {Number} B blue color value
* @return {Object} hsv color code
*/
RGBtoHSV(R: number, G: number, B: number): any;
/**
* @method lighten
*
* rgb 컬러 밝은 농도로 변환
*
* @param {String} color RGB color code
* @param {Number} rate 밝은 농도
* @return {String}
*/
lighten(color: string, rate: number): string;
/**
* @method darken
*
* rgb 컬러 어두운 농도로 변환
*
* @param {String} color RGB color code
* @param {Number} rate 어두운 농도
* @return {String}
*/
darken(color: string, rate: number): string;
}
interface UtilBase64 {
encode(input: string): string;
decode(input: string): string;
}
interface UtilKeyParser {
/**
* @method isIndexDepth
*
* @param {String} index
* @return {Boolean}
*/
isIndexDepth(index: string): boolean;
/**
* @method getIndexList
*
* @param {String} index
* @return {Array}
*/
getIndexList(index: string): boolean;
/**
* @method changeIndex
*
*
* @param {String} index
* @param {String} targetIndex
* @param {String} rootIndex
* @return {String}
*/
changeIndex(index: string, targetIndex: string, rootIndex: string): string;
/**
* @method getNextIndex
*
* @param {String} index
* @return {String}
*/
getNextIndex(index: string): string;
/**
* @method getParentIndex
*
*
* @param {String} index
* @returns {*}
*/
getParentIndex(index: string): string;
}
interface UtilMath {
/**
* @method rotate
*
* 2d rotate
*
* @param {Number} x
* @param {Number} y
* @param {Number} radian roate 할 radian
* @return {Object}
* @return {Number} return.x 변환된 x
* @return {Number} return.y 변환된 y
*
*/
rotate(x: number, y: number, radian: number): any;
resize(maxWidth: number, maxHeight: number, objectWidth: number, objectHeight: number): any;
/**
* @method radian
*
* convert degree to radian
*
* @param {Number} degree
* @return {Number} radian
*/
radian(degree: number): number;
/**
* @method degree
*
* convert radian to degree
*
* @param {Number} radian
* @return {Number} degree
*/
degree(radian: number): number;
angle(x1: number, y1: number, x2: number, y2: number): number;
/**
* @method interpolateNumber
*
* a, b 의 중간값 계산을 위한 callback 함수 만들기
*
* @param {Number} a first value
* @param {Number} b second value
* @return {Function}
*/
interpolateNumber(a: number, b: number): () => void;
// 중간값 round 해서 계산하기
interpolateRound(a: number, b: number): () => void;
round(num: number, fixed: number): number;
plus(a: number, b: number): number;
minus(a: number, b: number): number;
multi(a: number, b: number): number;
div(a: number, b: number): number;
remain(a: number, b: number): number;
/**
* 특정 구간의 값을 자동으로 계산
*
* @param {Object} min
* @param {Object} max
* @param {Object} ticks
* @param {Object} isNice
*/
nice(min: number, max: number, ticks: number, isNice: boolean): any;
matrix<T>(a: T[], b: T[]): T[];
matrix3d<T>(a: T[], b: T[]): T[];
inverseMatrix3d(a: any[]): any[];
}
export interface UtilScaleOrdinal extends Function {
(x: number): number;
domain(values: any[]): UtilScaleOrdinal;
range(values: any[]): UtilScaleOrdinal;
rangePoints(interval: number, padding?: number): () => void;
rangeBands(interval: number, padding?: number, outerPadding?: number): () => void;
invert(x: number): number;
}
export type UtilQuickSort = (array: number[], isClone: boolean) => this;
+15
View File
@@ -0,0 +1,15 @@
/// <reference types="jquery"/>
import {jui, UtilColor, UtilBase} from "./index";
jui.ready(["util.color"], function(color: UtilColor) {
console.log(color.rgb("#ff0000"));
});
let _ : UtilBase = jui.include("util.base");
let str: string = "10";
console.log(_.typeCheck("string", str));
let i: number = 10;
console.log(_.typeCheck("string", i));
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jui-core-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+996
View File
@@ -0,0 +1,996 @@
// Type definitions for jui-grid 2.0
// Project: https://github.com/juijs/jui-grid
// Definitions by: Jin-Ho Park <https://github.com/easylogic>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import {UIEvent} from 'jui-core';
export interface GridColumn {
(index: number|string): this;
/** @property {HTMLElement} [element=null] TH element of a specified column */
element: any;
/** @property {String} [order="asc"] Column sort state */
order: "asc"|"desc";
/** @property {String} [name=null] Column name */
name?: string;
/** @property {Array} data Data from all rows belonging for a specified column */
data: any[];
/** @property {Array} list TD element of all rows belonging to a specified column */
list: any[];
/** @property {Integer} index Column index */
index: number;
/** @property {"show"/"hide"/"resize"} [type="show"] The current column state */
type: "show"|"hide"|"resize";
/** @property {Integer} [width=null] Column width */
width?: number;
hide(): void;
show(): void;
}
export interface GridRow {
/** @property {Array} data Data of a specifiedrow. */
data: any[];
/** @property {Integer} seq Data of a sequence. */
seq: number;
/** @property {Integer} [rownum=null] The unique number of a child row under the specified parent row if a parent row exists. */
rownum?: number;
/** @property {String/Integer} [index=null] Index of a specified row. In the case of a tree structure, a depth is given. */
index: number|string;
/** @property {HTMLElement} [element=null] TR element of a specified row. */
element: any;
/** @property {Array} list List of TD elements of a specified row. */
list: any[];
/** @property {Object} list List of hidden TD element. */
hidden: {};
/** @property {uix.table.row} parent Variable that refers to the parent row. */
parent?: GridRow;
/** @property {Array} children List of child rows. */
children: any[];
/** @property {Integer} [depth=0] The depth of the current row in the case of a tree structure. */
depth: number;
/** @property {"open"/"fold"} [type="fold"] State value that indicates whether a child row is shown or hidden. */
type: "open"|"fold";
/** @property {Function} [type="null"] State value that indicates whether a child row is shown or hidden. */
tpl?: () => void;
setIndex(rownum: number|string): void;
reload(columns: GridColumn[], seq: any, xssFilter: any): void;
destroy(): void;
isLeaf(): boolean;
fold(): void;
open(): void;
appendChild(row: GridRow): void;
insertChild(rownum: number, row: GridRow, isReload?: any): void;
removeChild(index: number|string): void;
lastChild(): GridRow;
lastChildLeaf(lastRow: GridRow): GridRow|any;
showCell(index: number): void;
hideCell(index: number): void;
}
export interface GridBase {
appendRow(index: number|string, data?: {}): GridRow;
insertRow(index: number|string, data: {}): GridRow;
updateRow(index: number|string, data: {}): GridRow;
moveRow(index: number|string, targetIndex: number|string): void;
removeRow(index: number|string): void;
openRow(index: number|string): void;
openRowAll(): void;
foldRow(index: number|string): void;
foldRowAll(): void;
removeRows(): void;
sortRows(name: string, isDesc: boolean): void;
appendColumn(tplType: string, dataList: any[]): void;
removeColumn(index: number|string): void;
hideColumn(index: number|string): void;
showColumn(index: number|string): void;
getColumnCount(): number;
getRowCount(): number;
getColumn(index?: number|string): GridColumn|GridColumn[];
getRow(index?: number|string): GridRow|GridRow[];
getRowAll(index: number|string): GridRow[];
getRowParent(index: number|string): GridRow;
setColumn(index: number|string, column: GridColumn): void;
setRow(index: number|string, row: GridRow): void;
}
export interface GridTable extends UIEvent {
(selector: any, options?: {
tpl?: any,
event?: any,
/**
* @cfg {Array} [fields=null]
* Sets the name of columns in the order of being displayed on the table screen.
*/
fields?: any[],
/**
* @cfg {Array} [csv=null]
* Sets the column key shown when converted to a CSV string.
*/
csv?: any[],
/**
* @cfg {Array} [csvNames=null]
* Sets the name of a column shown when converting to a CSV string, which must be defined in the same order as the CSV option.
*/
csvNames?: any[],
/**
* @cfg {Array} [csvNumber=null]
* Sets the column key to be changed to a number form when converted to a CSV string.
*/
csvNumber?: any[],
/**
* @cfg {Array} data
* Sets the initial row list of a table.
*/
data?: any[],
/**
* @cfg {Boolean/Array} [colshow=false]
* Sets a column index shown when the Show/Hide Column menu is enabled.
*/
colshow?: boolean|any[],
/**
* @cfg {Boolean} [scroll=false]
* Determines whether to use a table scroll.
*/
scroll?: boolean,
/**
* @cfg {Integer} [scrollHeight=200]
* Sets the reference height of a body area when using a table scroll.
*/
scrollHeight?: number,
/**
* @cfg {Integer} [width=0]
* Sets the area of a table.
*/
width?: number,
/**
* @cfg {Boolean} [expand=false]
* Determines whether to use an extended row area.
*/
expand?: boolean,
/**
* @cfg {Boolean} [expandEvent=true]
* Sets the Show/Hide state of an extended row area when clicking on a row.
*/
expandEvent?: boolean,
/**
* @cfg {Boolean|Array} [editRow=false]
* Determines whether to use a modified row area.
*/
editRow?: boolean|any[],
/**
* @cfg {Boolean} [editEvent=true]
* Sets the Show/Hide state of an extended row area when doubleclicking on a row/cell.
*/
editEvent?: boolean,
/**
* @cfg {Boolean} [resize=false]
* Determines whether to use the column resizing function.
*/
resize?: boolean,
/**
* @cfg {Boolean/Array} [sort=false]
* Determines whether to use the table sort function.
*/
sort?: boolean|any[],
/**
* @cfg {Integer} [sortIndex=null]
* Determines whether to use the table sort function.
*/
sortIndex?: number,
/**
* @cfg {String} [sortOrder="asc"]
* Determines whether to use the table sort function.
*/
sortOrder?: "asc"|"desc",
/**
* @cfg {Boolean} [sortEvent=true]
* Determines whether to use the sort function when you click on a column.
*/
sortEvent?: boolean,
/**
* @cfg {Boolean} [moveRow=false]
* Determines whether to use the move function when you fire row draggable event.
*/
moveRow?: boolean,
}): this;
root?: any;
/**
* @method update
* Updates the list of rows or modifies the row at a specified index.
*
* @param {Array} rows
*/
update(indexOrRows?: any, rows?: any): void;
/**
* @method updateTree
* It is possible to configure a tree table using an object array with the index and data properties.
*
* @param {Array} rows
*/
updateTree(rows: any[]): void;
/**
* @method append
* Add a row or a child row to at a specified index.
*
* @param {RowObject} row
*/
append(rowOrIndex?: number|any, row?: any): void;
/**
* @method insert
* Adds a row at a specified index.
*
* @param {Integer} index
* @param {RowObject} row
*/
insert(index: number, dataList: {}): void;
/**
* @method select
* Adds a selected class to a row at a specified index and gets an instance of the applicable row.
*
* @param {Integer} index
* @return {RowObject} row
*/
select(index: number): GridRow;
/**
* @method unselect
* Removes a selected class from a selected row and gets an instance of the row in question.
*
* @return {RowObject} row
*/
unselect(): GridRow;
/**
* @method check
* Add a checked class to a row at a specified index.
*
* @param {Integer} index
*/
check(index: number): void;
/**
* @method uncheck
* Removes a checked class from a row at a specified index.
*
* @param {Integer} index
*/
uncheck(index: number): void;
/**
* @method uncheckAll
* Removes checked classes from all rows.
*/
uncheckAll(): void;
/**
* @method remove
* Remove a row at a specified index.
*
* @param {Integer} index
*/
remove(index: number): void;
/**
* @method reset
* Removes all rows.
*/
reset(): void;
/**
* @method move
* Moves a row iat a specified index to the target index.
*
* @param {Integer} index
* @param {Integer} targetIndex
*/
move(index: number, targetIndex: number): void;
/**
* @method sort
* Moves a row iat a specified index to the target index.
*
* @param {Integer} index
* @param {String} order "asc" or "desc"
*/
sort(index: number, order: string, e?: any): void;
/**
* @method scroll
* Sets the scroll based on the height of a table.
*
* @param {Integer} height
*/
scroll(height: number): void;
/**
* @method open
* Shows a child row of a specified index.
*
* @param {Integer} index
*/
open(index: number): void;
/**
* @method fold
* Hides a child row of a specified index.
*
* @param {Integer} index
*/
fold(index: number): void;
/**
* @method openAll
* Shows all child rows of a specified index.
*/
openAll(): void;
/**
* @method foldAll
* Hides all child rows of a specified index.
*/
foldAll(): void;
/**
* @method resize
* Resets the inner scroll and columns of a table.
*/
resize(): void;
/**
* @method resizeColumns
* Resets the sizes of all columns of a table.
*/
resizeColumns(): void;
/**
* @method size
* Gets the size of all the rows of a table.
*
* @return {Integer} size
*/
size(): number;
/**
* @method count
* Gets the number of trows of a table.
*
* @return {Integer} count
*/
count(): number;
/**
* @method list
* Gets all the rows of a table.
*
* @return {Array} rows
*/
list(): GridRow[];
/**
* @method listData
* Gets the data of all the rows of a table.
*
* @return {Array} datas
*/
listData(): any[];
/**
* @method listAll
* Gets all the rows of a table including child rows.
*
* @return {Array} rows
*/
listAll(): GridRow[];
/**
* @method listChecked
* Gets all rows in a check state.
*
* @return {Array} rows
*/
listChecked(): GridRow[];
/**
* @method listColumn
* Gets all columns.
*
* @return {Array} columns
*/
listColumn(): GridColumn;
/**
* @method get
* Gets the row at the specified index.
*
* @param {Integer} index
* @return {RowObject} row
*/
get(index: number): GridRow;
/**
* @method getAll
* Gets all rows of at the specified index including child rows.
*
* @param {Integer} index
* @return {Array} rows
*/
getAll(index: number): GridRow[];
/**
* @method getColumn
* Gets the column at the specified index.
*
* @param {"Integer"/"String"} key index or column key
* @return {ColumnObject} column
*/
getColumn(index: number|string): GridColumn;
/**
* @method showColumn
* Shows the column index (or column name).
*
* @param {"Integer"/"String"} key index or column name
*/
showColumn(index: number|string, e?: any): void;
/**
* @method hideColumn
* Hides the column index (or column name).
*
* @param {"Integer"/"String"} key index or column name
*/
hideColumn(index: number|string, e?: any): void;
/**
* @method initColumns
* It is possible to determine the index or name of the column to be shown in an array.
*
* @param {"Integer"/"String"} key index or column name
*/
initColumns(keys: any): void;
/**
* @method showColumnMenu
* Shows the Show/Hide Column menu at specified coordinates.
*
* @param {Integer} x
* @param {Integer} y
*/
showColumnMenu(x: number, y: number): void;
/**
* @method hideColumnMenu
* Hides the Show/Hide Column menu.
*/
hideColumnMenu(): void;
/**
* @method toggleColumnMenu
* Shows or hides the Show/Hide Column menu.
*
* @param {Integer} x
* @param {Integer} y
*/
toggleColumnMenu(x: number, y: number): void;
/**
* @method showExpand
* Shows the extended row area of a specified index.
*
* @param {Integer} index
*/
showExpand(index: number, obj?: any, e?: any): void;
/**
* @method hideExpand
* Hides the extended row area of a specified index.
*/
hideExpand(e?: any): void;
/**
* @method getExpand
* Get a row in which the extended area is currently activated.
*
* @return {RowObject} row
*/
getExpand(): GridRow;
/**
* @method showEditRow
* Shows the modified row area of a specified index.
*
* @param {Integer} index
*/
showEditRow(index: number, e?: any): void;
/**
* @method hideEditRow
* Hides the modified row area of a specified index.
*/
hideEditRow(data?: any): void;
/**
* @method getEditRow
* Get a row in which the modified area is currently activated.
*
* @return {RowObject} row
*/
getEditRow(): GridRow;
/**
* @method setCsv
* Updates a table using a CVS string.
*/
setCsv(csvOrKey: any, key?: any): void;
/**
* @method setCsvFile
* Updates a table using a CVS file.
*/
setCsvFile(fileOrKey: any, key?: any): void;
/**
* @method getCsv
* Gets the data of a table as a CSV string.
*
* @param {Boolean} isTree
* @return {String} csv
*/
getCsv(isTree: boolean): string;
/**
* @method getCsvBase64
* Gets the data of a table as a CSV string encoded as base64.
*
* @param {Boolean} isTree
* @return {String} base64
*/
getCsvBase64(isTree: boolean): string;
/**
* @method downloadCsv
* Downloads the data of a table as a CSV file.
*
* @param {String} name
* @param {Boolean} isTree
*/
downloadCsv(name: string, isTree: boolean): void;
/**
* @method activeIndex
* Gets the index of a row that is activated in an extended/modified/selected state.
*
* @return {Integer} index
*/
activeIndex(): number;
}
export interface GridXTable extends UIEvent {
(selector: any, options?: {
}): this;
render(isTree?: boolean): void;
/**
* @method select
* Adds a selected class to a row at a specified index and gets an instance of the applicable row.
*
* @param {Integer} index
* @return {RowObject} row
*/
select(index: number): GridRow;
/**
* @method unselect
* Removes a selected class from a selected row and gets an instance of the row in question.
*
* @return {RowObject} row
*/
unselect(): GridRow;
/**
* @method update
* Updates the list of rows or modifies the row at a specified index.
*
* @param {Array} rows
*/
update(dataList: any[]): void;
/**
* @method updateTree
* It is possible to configure a tree table using an object array with the index and data properties.
*
* @param {Array} rows
*/
updateTree(tree: any[]): void;
/**
* @method append
* Add a row or a child row to at a specified index.
*
* @param {RowObject} row
* @param {RowObject} row
*/
append(index: number, data: {}): void;
/**
* @method open
* Shows a child row of a specified index.
*
* @param {Integer} index
*/
open(index: number|string): void;
/**
* @method fold
* Hides a child row of a specified index.
*
* @param {Integer} index
*/
fold(index: number|string): void;
/**
* @method openAll
* Shows all child rows of a specified index.
*/
openAll(index: number|string): void;
/**
* @method foldAll
* Hides all child rows of a specified index.
*/
foldAll(index: number|string): void;
/**
* @method next
* Changes to the next page.
*/
next(): void;
/**
* @method page
* Changes to the page of at a specified index.
*
* @param {Integer} index
*/
page(pNo: number): void;
/**
* @method sort
* Moves a row iat a specified index to the target index.
*
* @param {Integer} index
* @param {String} order "asc" or "desc"
*/
sort(index: number, order: "asc"|"desc", e?: any, isNotLoading?: any): void;
/**
* @method filter
* Filters columns at a specified to locate rows that contain keywords in the cell value.
*
* @param {Function} callback
*/
filter(callback: (data: any) => void): void;
/**
* @method rollback
* Returns filtered rows to the original state.
*/
rollback(): void;
/**
* @method clear
* Remove all row elements.
*/
clear(): void;
/**
* @method clear
* Remove all data
*/
reset(): void;
/**
* @method resize
* Resets the inner scroll and columns of a table.
*/
resize(): void;
/**
* @method scrollWidth
* Sets the scroll based on the width of a table.
*
* @param {Integer} width
*/
scrollWidth(scrollWidth: number, isInit?: boolean): void;
/**
* @method scrollHeight
* Sets the scroll based on the height of a table.
*
* @param {Integer} height
*/
scrollHeight(h: number): void;
/**
* @method scrollTop
* Sets the scroll based on the height of a table.
*
* @param {Integer|String} index
* @param {Integer} dist
*/
scrollTop(index: number|string, dist: number): void;
/**
* @deprecated
* @method height
* Sets the scroll based on the height of a table.
*
* @param {Integer} height
*/
height(h: number): void;
/**
* @method size
* Gets the size of all the rows of a table.
*
* @return {Integer} size
*/
size(): number;
/**
* @method count
* Gets the number of trows of a table.
*
* @return {Integer} count
*/
count(): number;
/**
* @method list
* Gets all the rows of a table.
*
* @return {Array} rows
*/
list(): GridRow[];
/**
* @method listColumn
* Gets all columns.
*
* @return {Array} columns
*/
listColumn(): GridColumn[];
/**
* @method listData
* Gets the data of all the rows of a table.
*
* @return {Array} datas
*/
listData(): any[];
/**
* @method get
* Gets the row at the specified index.
*
* @param {Integer|String} index
* @return {RowObject} row
*/
get(index: number): GridRow;
getAll(index: number, _result?: any): GridRow[];
/**
* @method getColumn
* Gets the column at the specified index.
*
* @param {"Integer"/"String"} key index or column key
* @return {ColumnObject} column
*/
getColumn(index: number|string): GridColumn;
/**
* @method getData
* Gets the data at the specified index.
*
* @param {"Integer"/"String"} key index
* @return {ColumnObject} data
*/
getData(index: number|string): any;
/**
* @method showColumn
* Shows the column index (or column name).
*
* @param {"Integer"/"String"} key index or column name
*/
showColumn(index: number|string): void;
/**
* @method hideColumn
* Hides the column index (or column name).
*
* @param {"Integer"/"String"} key index or column name
*/
hideColumn(index: number|string): void;
/**
* @method initColumns
* It is possible to determine the index or name of the column to be shown in an array.
*
* @param {"Integer"/"String"} key index or column name
*/
initColumns(keys: number|string): void;
/**
* @method showColumnMenu
* Shows the Show/Hide Column menu at specified coordinates.
*
* @param {Integer} x
* @param {Integer} y
*/
showColumnMenu(x: number, y: number): void;
/**
* @method hideColumnMenu
* Hides the Show/Hide Column menu.
*/
hideColumnMenu(): void;
/**
* @method toggleColumnMenu
* Shows or hides the Show/Hide Column menu.
*
* @param {Integer} x
* @param {Integer} y
*/
toggleColumnMenu(x: number, y: number): void;
/**
* @method showExpand
* Shows the extended row area of a specified index.
*
* @param {Integer} index
*/
showExpand(index: number, obj: any): void;
/**
* @method hideExpand
* Hides the extended row area of a specified index.
*/
hideExpand(index: number): void;
/**
* @method getExpand
* Get a row in which the extended area is currently activated.
*
* @return {RowObject} row
*/
getExpand(): GridRow;
/**
* @method showLoading
* Shows the loading screen for the specified delay time.
*
* @param {Integer} delay
*/
showLoading(delay: number): void;
/**
* @method hideLoading
* Hides the loading screen.
*/
hideLoading(): void;
/**
* @method setCsv
* Updates a table using a CVS string.
*/
setCsv(csv: string): void;
/**
* @method setCsvFile
* Updates a table using a CVS file.
*/
setCsvFile(file: any): void;
/**
* @method getCsv
* Gets the data of a table as a CSV string.
*
* @param {Boolean} isTree
* @return {String} csv
*/
getCsv(): string;
/**
* @method getCsvBase64
* Gets the data of a table as a CSV string encoded as base64.
*
* @param {Boolean} isTree
* @return {String} base64
*/
getCsvBase64(): string;
/**
* @method downloadCsv
* Downloads the data of a table as a CSV file.
*
* @param {String} name
* @param {Boolean} isTree
*/
downloadCsv(name: string): void;
/**
* @method rowFunc
* Ir is possible to use a function for all row data applicable to the column (or column name) of a specified column (or column name). Currently only SUM and AVG are supported.
*
* @param {"sum"/"svg"} funcType
* @param {Integer} columnIndex
* @param {Function} callback
*/
rowFunc(type: "sum"|"avg", index: number, callback: (data: any) => void): any;
/**
* @method getPage
* Gets the current page of a table.
*
* @return {Integer} page
*/
getPage(): number;
/**
* @method activeIndex
* Gets the index of a row that is activated in an extended/modified/selected state.
*
* @return {Integer} index
*/
activeIndex(): number;
}
+182
View File
@@ -0,0 +1,182 @@
/// <reference types="jquery" />
import {jui} from 'jui-core';
import {GridTable, GridXTable, GridRow} from "./index";
jui.ready([ "grid.table" ], function(table: GridTable) {
let table_1: GridTable = table("#table_1", {
data: [
{ name: "Hong", age: "20", location: "Ilsan" },
{ name: "Jung", age: "30", location: "Seoul" },
{ name: "Park", age: "15", location: "Yeosu" },
{ name: "Kang", age: "32", location: "Seoul" },
{ name: "Song", age: "12", location: "Gwangju" },
{ name: "Yoon", age: "22", location: "Damyang" },
{ name: "Kim", age: "33", location: "Busan" },
{ name: "Hwang", age: "21", location: "Seoul" }
]
});
table_1.scroll(100);
});
jui.ready([ "grid.table" ], function(table: GridTable) {
let table_3:GridTable = table("#table_3", {
event: {
expand: function(row: any, e: any): void {
$(row.list[0]).html("<i class='icon-right'></i>");
},
expandend: function(row: any, e: any): void {
$(row.list[0]).html("<i class='icon-left'></i>");
}
},
expand: true
});
table_3.update([
{ name: "Hong", age: "20", location: "Ilsan" },
{ name: "Jung", age: "30", location: "Seoul" },
{ name: "Park", age: "10", location: "Dangjin" }
]);
let table_3_submit: Function = function(index: number) {
var name = $(table_3.root).find(".name").val(),
age = $(table_3.root).find(".age").val(),
location = $(table_3.root).find(".location").val();
//noinspection TypeScriptValidateTypes
table_3.update(index, { name: name, age: age, location: location });
table_3.hideExpand();
}
});
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
var page = 1;
let xtable_2: GridXTable = xtable("#xtable_2", {
fields: [ "name", "age", "location" ],
resize: true,
sort: true,
buffer: "page",
bufferCount: 20
});
let xtable_2_submit: Function = function() {
var result: any[] = [];
for(var i = 0; i < 1000000; i++) {
result.push({ name: "Alvin" + i, age: Math.floor(Math.random() * 100) + 1, location: "LA" });
}
page = 1;
xtable_2.update(result);
xtable_2.resize();
}
let xtable_2_page: Function = function(no: number) {
page += no;
page = (page < 1) ? 1 : page;
xtable_2.page(page);
}
});
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
let xtable_4:GridXTable = xtable("#xtable_4", {
fields: [ "name", "age", "location" ],
data: [
{ name: "Hong", age: "20", location: "Ilsan" },
{ name: "Jung", age: "30", location: "Seoul" },
{ name: "Park", age: "10", location: "Dangjin" }
],
resize: true,
sort: true,
buffer: "s-page",
bufferCount: 20
});
let xtable_4_submit: Function = function(isMulti: boolean) {
if(isMulti) {
xtable_4.filter(function(data: any) {
if(data.age >= 30 || data.name.indexOf("ng") != -1) {
return true;
}
});
} else {
xtable_4.filter(function(data: any) {
if(data.location.indexOf("eo") != -1) {
return true;
}
});
}
}
});
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
let xtable_6: GridXTable = xtable("#xtable_6", {
fields: [ "name", "age", "location" ],
resize: true,
sort: true,
width: 800,
scrollWidth: 600,
scrollHeight: 400,
rowHeight: 26,
buffer: "vscroll",
tpl: {
row: "<tr><td><!= name !></td><td><!= age !></td><td><!= location !></td></tr>",
none: "<tr><td colspan='3' class='none' align='center'>Data does not exist.</td></tr>"
}
});
let xtable_6_submit: Function = function() {
var result: any[] = [];
for(var i = 0; i < 1000000; i++) {
result.push({ name: "Alvin" + i, age: Math.floor(Math.random() * 100) + 1, location: "LA" });
}
xtable_6.update(result);
}
});
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
let xtable_8: GridXTable = xtable("#xtable_8", {
fields: [ "url", "count" ],
resize: true,
buffer: "vscroll",
rowHeight: 27,
scrollHeight: 300,
tpl: {
row: $("#tpl_row").html(),
none: $("#tpl_none").html()
},
event: {
select: function(row: GridRow, e:any) {
if(row.type == "fold") {
xtable_8.open(row.index);
} else {
xtable_8.fold(row.index);
}
}
}
});
xtable_8.updateTree([
{ index: "0", type: "open", data: { url: "/", count: 105 } },
{ index: "0.0", type: "fold", data: { url: "/css", count: 35 } },
{ index: "0.0.0", type: "fold", data: { url: "/index.css", count: 15 } },
{ index: "0.0.1", type: "fold", data: { url: "/layout.css", count: 15 } },
{ index: "0.0.2", type: "fold", data: { url: "/login.css", count: 5 } },
{ index: "0.1", type: "fold", data: { url: "/js", count: 35 } },
{ index: "0.1.0", type: "fold", data: { url: "/index.js", count: 23 } },
{ index: "0.1.1", type: "fold", data: { url: "/jquery.js", count: 12 } },
{ index: "0.2", type: "fold", data: { url: "/img", count: 0 } },
{ index: "0.2.0", type: "fold", data: { url: "logo.ico", count: 0 } },
{ index: "0.3", type: "fold", data: { url: "/main.jsp", count: 10 } },
{ index: "0.4", type: "fold", data: { url: "/login.jsp", count: 10 } },
{ index: "0.5", type: "fold", data: { url: "/sitemap.xml", count: 10 } },
{ index: "0.6", type: "fold", data: { url: "/package.json", count: 5 } }
]);
});
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jui-grid-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+1380
View File
File diff suppressed because it is too large Load Diff
+124
View File
@@ -0,0 +1,124 @@
/// <reference types="jui-core"/>
import {jui} from 'jui-core';
import {
UIAccordion, UIAutoComplete, UIColorPicker, UICombo, UIDatePicker, UIDropdown, UIModal, UINotify,
UIPaging, UIProgress, UIProperty, UISelect
} from 'jui';
jui.ready([
'ui.accordion',
'ui.autocomplete',
'ui.colorpicker',
'ui.combo',
'ui.datepicker',
'ui.dropdown',
'ui.modal',
'ui.notify',
'ui.paging',
'ui.progress',
'ui.property',
'ui.select'
], function (
accordion: UIAccordion,
autocomplete: UIAutoComplete,
colorpicker: UIColorPicker,
combo: UICombo,
datepicker: UIDatePicker,
dropdown: UIDropdown,
modal: UIModal,
notify: UINotify,
paging: UIPaging,
progress: UIProgress,
property: UIProperty,
select: UISelect
) {
let a: UIAccordion = accordion("#test", {
multipanel: false
});
console.log(a.activeIndex());
let autoComplete: UIAutoComplete = autocomplete("#test", {
words : []
});
autoComplete.update([]);
let colorPicker: UIColorPicker = colorpicker("#test", {
color: '#FFFF00'
});
console.log(colorPicker.getColor('hex'));
let comboInstance: UICombo = combo("#test", {
keydown: true
})
console.log(comboInstance.getValue());
let datePicker: UIDatePicker = datepicker("#test", {
type: "daily"
});
datePicker.select(Date.now());
datePicker.select(2016, 1, 2);
datePicker.select(new Date());
let dropdownInstance: UIDropdown = dropdown("#test", {
width: 100
})
dropdownInstance.update([]);
dropdownInstance.hide();
dropdownInstance.reload();
let m : UIModal = modal("#test", {autoHide: true});
m.show();
let n: UINotify = notify("#test");
n.add({ title: "Caution message Send!!!", message: "Feb 15, 2013-12-24 02:24:19", color: 'warning' }, 1000);
n.add({ title: "Caution message Send!!!", message: "Feb 15, 2013-12-24 02:24:19", color: 'success' }, 1000);
n.reset();
let p: UIPaging = paging("#test", { count :100, pageCount : 5 });
p.first();
p.last();
p.next();
p.prev();
p.page(10);
let prog: UIProgress = progress("#test", { striped: true });
console.log(prog.getValue());
prog.setValue(100);
let propertyView: UIProperty = property("#test", {
items : [
{ type : 'group', title : 'Sample Category'},
{ type : 'text', title : 'Category Name', key: 'sample-category-name', value : 'test'}
]
})
console.log(propertyView.getValue());
let selectInstance: UISelect = select("#test", {
items : [
{ type : 'item', value : '0', text : 'first', html : '<div>test</div>', selected : true },
{ type : 'divider' }
],
multi: true,
placeholder: 'Sample Select'
});
console.log(selectInstance.getValue());
});
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jui-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }