type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
public appendTo(parent: Node): void { if (this.isLinked && !!this.refNode) { this.addToLinked(); } else { this.isMounted = true; parent.appendChild(this.firstChild); } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public remove(): void { this.isMounted = false; this.firstChild.remove(); }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public addToLinked(): void { const refNode = this.refNode!; this.isMounted = true; refNode.parentNode!.insertBefore(this.firstChild, refNode); }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public unlink(): void { this.isLinked = false; this.next = void 0; this.refNode = void 0; }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public link(next: INodeSequence<Node> | (IRenderLocation & Comment) | undefined): void { this.isLinked = true; if (this.dom.isRenderLocation(next)) { this.refNode = next; } else { this.next = next; this.obtainRefNode(); } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
private obtainRefNode(): void { if (this.next !== void 0) { this.refNode = this.next.firstChild; } else { this.refNode = void 0; } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public insertBefore(refNode: IRenderLocation & Comment): void { if (this.isLinked && !!this.refNode) { this.addToLinked(); } else { const parent = refNode.parentNode!; if (this.isMounted) { let current = this.firstChild; const end = this.lastChild; let next: Node; while (current != null) { next = current.nextSibling!; parent.insertBefore(current, refNode); if (current === end) { break; } current = next; } } else { this.isMounted = true; refNode.parentNode!.insertBefore(this.fragment, refNode); } } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public appendTo(parent: Node): void { if (this.isMounted) { let current = this.firstChild; const end = this.lastChild; let next: Node; while (current != null) { next = current.nextSibling!; parent.appendChild(current); if (current === end) { break; } current = next; } } else { this.isMounted = true; parent.appendChild(this.fragment); } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public remove(): void { if (this.isMounted) { this.isMounted = false; const fragment = this.fragment; const end = this.lastChild; let next: Node; let current = this.firstChild; while (current !== null) { next = current.nextSibling!; fragment.appendChild(current); if (current === end) { break; } current = next; } } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public addToLinked(): void { const refNode = this.refNode!; const parent = refNode.parentNode!; if (this.isMounted) { let current = this.firstChild; const end = this.lastChild; let next: Node; while (current != null) { next = current.nextSibling!; parent.insertBefore(current, refNode); if (current === end) { break; } current = next; } } else { this.isMounted = true; parent.insertBefore(this.fragment, refNode); } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public link(next: INodeSequence<Node> | IRenderLocation & Comment | undefined): void { this.isLinked = true; if (this.dom.isRenderLocation(next)) { this.refNode = next; } else { this.next = next; this.obtainRefNode(); } }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public createNodeSequence(): INodeSequence { return new this.Type(this.dom, this.node.cloneNode(this.deepClone)); }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public remove(): void { /* do nothing */ }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public static register(container: IContainer): IResolver<ITemplateFactory> { return Registration.singleton(ITemplateFactory, this).register(container); }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
MethodDeclaration
public create(parentRenderContext: IRenderContext, definition: TemplateDefinition): ITemplate { return new CompiledTemplate(this.dom, definition, new NodeSequenceFactory(this.dom, definition.template as string | Node), parentRenderContext); }
josiahhaswell/aurelia
packages/runtime-html/src/dom.ts
TypeScript
ArrowFunction
(db: MongoDb.Db) => { return db.collection(this.getCollectionName()); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(collection: any) => { return collection.findOne({_id: id}).then((result) => { return result; }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(result) => { return result; }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(collection: MongoDb.Collection) => { return collection.deleteOne({ _id: id }).then((result) => { console.log(result); return result; }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(result) => { console.log(result); return result; }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(collection: MongoDb.Collection) => { entity.updatedAt = new Date(); return collection.updateOne({ _id: id }, entity).then((result) => { return entity; }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(result) => { return entity; }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(collection: MongoDb.Collection) => { return collection.find(filter).limit(top).skip(skip).toArray(); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(collection: MongoDb.Collection) => { entity.createdDate = new Date(); return collection.insertOne(entity).then((result) => { return entity; }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ClassDeclaration
abstract class MongoRepository<T extends IEntity> implements IRepository<IEntity> { protected collection: Promise<MongoDb.Collection>; constructor() { this.collection = this.getCollection(Configurations.Repository.connectionString); } protected abstract getCollectionName(): string; private getCollection(url: string): Promise<MongoDb.Collection> { return MongoDb.MongoClient.connect(url).then((db: MongoDb.Db) => { return db.collection(this.getCollectionName()); }); } public findById(id: string): Promise<T> { return this.collection.then((collection: any) => { return collection.findOne({_id: id}).then((result) => { return result; }); }); } public findByIdAndDelete(id: string): Promise<any> { return this.collection.then((collection: MongoDb.Collection) => { return collection.deleteOne({ _id: id }).then((result) => { console.log(result); return result; }); }); } public findByIdAndUpdate(id: string, entity: T): Promise<T> { return this.collection.then((collection: MongoDb.Collection) => { entity.updatedAt = new Date(); return collection.updateOne({ _id: id }, entity).then((result) => { return entity; }); }); } public find(filter: Object, top?: number, skip?: number): Promise<Array<T>> { return this.collection.then((collection: MongoDb.Collection) => { return collection.find(filter).limit(top).skip(skip).toArray(); }); } public create(entity: T): Promise<T> { entity._id = UUID.v4(); return this.collection.then((collection: MongoDb.Collection) => { entity.createdDate = new Date(); return collection.insertOne(entity).then((result) => { return entity; }); }); } }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
MethodDeclaration
protected abstract getCollectionName(): string;
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
MethodDeclaration
private getCollection(url: string): Promise<MongoDb.Collection> { return MongoDb.MongoClient.connect(url).then((db: MongoDb.Db) => { return db.collection(this.getCollectionName()); }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
MethodDeclaration
public findById(id: string): Promise<T> { return this.collection.then((collection: any) => { return collection.findOne({_id: id}).then((result) => { return result; }); }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
MethodDeclaration
public findByIdAndDelete(id: string): Promise<any> { return this.collection.then((collection: MongoDb.Collection) => { return collection.deleteOne({ _id: id }).then((result) => { console.log(result); return result; }); }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
MethodDeclaration
public findByIdAndUpdate(id: string, entity: T): Promise<T> { return this.collection.then((collection: MongoDb.Collection) => { entity.updatedAt = new Date(); return collection.updateOne({ _id: id }, entity).then((result) => { return entity; }); }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
MethodDeclaration
public find(filter: Object, top?: number, skip?: number): Promise<Array<T>> { return this.collection.then((collection: MongoDb.Collection) => { return collection.find(filter).limit(top).skip(skip).toArray(); }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
MethodDeclaration
public create(entity: T): Promise<T> { entity._id = UUID.v4(); return this.collection.then((collection: MongoDb.Collection) => { entity.createdDate = new Date(); return collection.insertOne(entity).then((result) => { return entity; }); }); }
divramod/boilerplate-server-api-hapijs
src/libs/repository/mongo/mongoRepository.ts
TypeScript
ArrowFunction
(props) => { return columnsRenderImg(props.value, props.data) }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
(props) => { return (props.value === true || props.value === 'true') ? <Switch checkedChildren={<Icon type="check" />} unCheckedChildren={<Icon type="close" />}
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
(props) => { if (props.value) { return <div style={{ textAlign: "center" }} > <Button style={{ height: 25, width: 25, objectFit: "cover" }} shape="circle" icon="download" onClick={e => { window.open(RequestFiles.onFileDownload(props.value)) }} /> </div> }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
(props) => { if (props.value) { let render = props.value // colDef.field if (Regular.isHtml.test(props.value)) { render = <span dangerouslySetInnerHTML={{ __html: props.value }}></span> } // // 前景色 // const forecolor = lodash.get(props.data, props.colDef.field + '__forecolor'); // // 背景色 // const backcolor = lodash.get(props.data, props.colDef.field + '__backcolor'); // if (forecolor || backcolor) { // render = <div style={{ color: forecolor, backgroundColor: backcolor, display: "inline-block" }}>{render}</div> // } return render } else { return '' } }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
e => { // 获取当前高度 ,高度 为 0 说明页面属于隐藏状态 if (lodash.get(this.refTableBody.current, 'clientHeight', 0) > 0) { if (!globalConfig.tabsPage) { this.onUpdateHeight(lodash.get(e, 'detail') === 'refFullscreen'); } this.sizeColumnsToFit(); } }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
(col: ColDef) => { // 根据 数据 定制 样式 col.cellStyle = col.cellStyle || ((props) => { if (props.data) { // 前景色 const forecolor = lodash.get(props.data, props.colDef.field + '__forecolor'); // 背景色 const backcolor = lodash.get(props.data, props.colDef.field + '__bgcolor'); return { color: forecolor, backgroundColor: backcolor } } }); // 渲染器 col.cellRenderer = col.cellRenderer || 'columnsRenderDefault'; return col }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
(props) => { if (props.data) { // 前景色 const forecolor = lodash.get(props.data, props.colDef.field + '__forecolor'); // 背景色 const backcolor = lodash.get(props.data, props.colDef.field + '__bgcolor'); return { color: forecolor, backgroundColor: backcolor } } }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
(rowProps) => { if (rowProps.data) { return <RowAction {...rowProps} />; } return null; }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ClassDeclaration
// export class AgGrid extends React.Component<ITableProps, any> { // /** // * 全屏 容器 // */ // refFullscreen = React.createRef<HTMLDivElement>(); // render() { // let { // ...props // } = this.props; // return ( // <Table {...props} /> // ); // } // } @observer @BindAll() export class AgGrid extends React.Component<ITableProps, any> { gridApi: GridApi; // 表格容器 refTableBody = React.createRef<HTMLDivElement>(); // 事件对象 resizeEvent: Subscription; minHeight = 400; state = { sortable: true, height: this.minHeight } /** * 修改 高度 * @param refFullscreen */ @Debounce(200) onUpdateHeight(refFullscreen = false) { try { // props 中传递了 height if (this.props.style && this.props.style.height) { return } const refTable = this.refTableBody.current;//ReactDOM.findDOMNode(this.ref.current) as HTMLDivElement; // 60 是头部 标题栏 高度 let height = window.innerHeight - refTable.offsetTop - 60 - 100; if (!globalConfig.tabsPage) { height += 90; } height = height < this.minHeight ? this.minHeight : height; if (this.state.height !== height) { this.gridApi.sizeColumnsToFit(); this.setState({ height }); } } catch (error) { console.log(error) } } // onGetColumnDefs() { // let columnDefs = [...this.props.columnDefs]; // console.log(columnDefs.reduce((accumulator, currentValue) => { // return accumulator.width + currentValue.w // }), 0) // return columnDefs; // } /** * 分页 参数 改变回调 * @param current * @param pageSize */ onChangePagination(current: number, pageSize: number) { console.log("TCL: App -> onChangePagination -> ", current, pageSize) this.props.Store.onSearch({ Page: current, Limit: pageSize }); } onSortChanged(event: SortChangedEvent) { const SortModel = lodash.head(event.api.getSortModel()); this.props.Store.onSearch({ SortInfo: SortModel && SortModel.sort && { Direction: lodash.capitalize(SortModel.sort), Property: SortModel.colId }, Page: 1, Limit: this.props.Store.DataSource.searchParams.Limit }) } /** * 选择的 行 数据 回调 * @param event */ onSelectionChanged(event: SelectionChangedEvent) { // console.log("TCL: App -> onSelectionChanged -> event", event.api.getSelectedRows()) // event.api.getSelectedNodesById() this.props.Store.DataSource.selectedRowKeys = lodash.map(event.api.getSelectedRows(), 'key'); } onColumnRowGroupChanged(event: ColumnRowGroupChangedEvent) { // this.setState({ sortable: event.columns.length > 0 }) } async componentDidMount() { this.onUpdateHeight(); this.resizeEvent = fromEvent(window, "resize").pipe(debounceTime(300)).subscribe(e => { // 获取当前高度 ,高度 为 0 说明页面属于隐藏状态 if (lodash.get(this.refTableBody.current, 'clientHeight', 0) > 0) { if (!globalConfig.tabsPage) { this.onUpdateHeight(lodash.get(e, 'detail') === 'refFullscreen'); } this.sizeColumnsToFit(); } }); await this.props.Store.onSearch(); this.sizeColumnsToFit() } componentWillUnmount() { this.resizeEvent && this.resizeEvent.unsubscribe() } sizeColumnsToFit() { if (lodash.get(this.refTableBody.current, 'clientHeight', 0) && this.gridApi) { this.gridApi.sizeColumnsToFit(); } } onGridReady(event: GridReadyEvent) { this.gridApi = event.api; // 更新 列 大小 event.api.sizeColumnsToFit(); } public render() { let { Store, rowAction: RowAction, rowActionCol, paginationProps, style, theme = globalConfig.agGridTheme,//'ag-theme-balham', className = '', children, onGridReady, loading, defaultColDef, columnDefs, checkboxSelection = true, frameworkComponents, // rowData, ...props } = this.props; const { DataSource } = Store; const dataSource = DataSource.tableList; const checkboxSelectionWidth = { "ag-theme-balham": 40, "ag-theme-material": 70, }[theme]; if (loading) { props.rowData = undefined } else { props.rowData = toJS(dataSource.Data); } // 替换默认的渲染器 columnDefs = columnDefs.map((col: ColDef) => { // 根据 数据 定制 样式 col.cellStyle = col.cellStyle || ((props) => { if (props.data) { // 前景色 const forecolor = lodash.get(props.data, props.colDef.field + '__forecolor'); // 背景色 const backcolor = lodash.get(props.data, props.colDef.field + '__bgcolor'); return { color: forecolor, backgroundColor: backcolor } } }); // 渲染器 col.cellRenderer = col.cellRenderer || 'columnsRenderDefault'; return col }) return ( <> <div ref={this.refTableBody} style={{ height: this.state.height, ...style }} className={`app-ag-grid ${className} ${theme}`}
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
InterfaceDeclaration
interface ITableProps extends AgGridReactProps { /** 状态 */ Store: Store; /** * 行 操作 */ rowAction?: any; /** * 行 操作列配置 */ rowActionCol?: ColDef; /** * 容器样式 */ style?: React.CSSProperties; /** * 主题 */ theme?: string; /** * 样式 */ className?: string; /** * 分页 */ paginationProps?: PaginationProps | boolean; /** * 加载中 */ loading?: boolean; /** * 选择 */ checkboxSelection?: boolean; }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
/** * 修改 高度 * @param refFullscreen */ @Debounce(200) onUpdateHeight(refFullscreen = false) { try { // props 中传递了 height if (this.props.style && this.props.style.height) { return } const refTable = this.refTableBody.current;//ReactDOM.findDOMNode(this.ref.current) as HTMLDivElement; // 60 是头部 标题栏 高度 let height = window.innerHeight - refTable.offsetTop - 60 - 100; if (!globalConfig.tabsPage) { height += 90; } height = height < this.minHeight ? this.minHeight : height; if (this.state.height !== height) { this.gridApi.sizeColumnsToFit(); this.setState({ height }); } } catch (error) { console.log(error) } }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
// onGetColumnDefs() { // let columnDefs = [...this.props.columnDefs]; // console.log(columnDefs.reduce((accumulator, currentValue) => { // return accumulator.width + currentValue.w // }), 0) // return columnDefs; // } /** * 分页 参数 改变回调 * @param current * @param pageSize */ onChangePagination(current: number, pageSize: number) { console.log("TCL: App -> onChangePagination -> ", current, pageSize) this.props.Store.onSearch({ Page: current, Limit: pageSize }); }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
onSortChanged(event: SortChangedEvent) { const SortModel = lodash.head(event.api.getSortModel()); this.props.Store.onSearch({ SortInfo: SortModel && SortModel.sort && { Direction: lodash.capitalize(SortModel.sort), Property: SortModel.colId }, Page: 1, Limit: this.props.Store.DataSource.searchParams.Limit }) }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
/** * 选择的 行 数据 回调 * @param event */ onSelectionChanged(event: SelectionChangedEvent) { // console.log("TCL: App -> onSelectionChanged -> event", event.api.getSelectedRows()) // event.api.getSelectedNodesById() this.props.Store.DataSource.selectedRowKeys = lodash.map(event.api.getSelectedRows(), 'key'); }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
onColumnRowGroupChanged(event: ColumnRowGroupChangedEvent) { // this.setState({ sortable: event.columns.length > 0 }) }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
async componentDidMount() { this.onUpdateHeight(); this.resizeEvent = fromEvent(window, "resize").pipe(debounceTime(300)).subscribe(e => { // 获取当前高度 ,高度 为 0 说明页面属于隐藏状态 if (lodash.get(this.refTableBody.current, 'clientHeight', 0) > 0) { if (!globalConfig.tabsPage) { this.onUpdateHeight(lodash.get(e, 'detail') === 'refFullscreen'); } this.sizeColumnsToFit(); } }); await this.props.Store.onSearch(); this.sizeColumnsToFit() }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
componentWillUnmount() { this.resizeEvent && this.resizeEvent.unsubscribe() }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
sizeColumnsToFit() { if (lodash.get(this.refTableBody.current, 'clientHeight', 0) && this.gridApi) { this.gridApi.sizeColumnsToFit(); } }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
onGridReady(event: GridReadyEvent) { this.gridApi = event.api; // 更新 列 大小 event.api.sizeColumnsToFit(); }
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
MethodDeclaration
public render() { let { Store, rowAction: RowAction, rowActionCol, paginationProps, style, theme = globalConfig.agGridTheme,//'ag-theme-balham', className = '', children, onGridReady, loading, defaultColDef, columnDefs, checkboxSelection = true, frameworkComponents, // rowData, ...props } = this.props; const { DataSource } = Store; const dataSource = DataSource.tableList; const checkboxSelectionWidth = { "ag-theme-balham": 40, "ag-theme-material": 70, }[theme]; if (loading) { props.rowData = undefined } else { props.rowData = toJS(dataSource.Data); } // 替换默认的渲染器 columnDefs = columnDefs.map((col: ColDef) => { // 根据 数据 定制 样式 col.cellStyle = col.cellStyle || ((props) => { if (props.data) { // 前景色 const forecolor = lodash.get(props.data, props.colDef.field + '__forecolor'); // 背景色 const backcolor = lodash.get(props.data, props.colDef.field + '__bgcolor'); return { color: forecolor, backgroundColor: backcolor } } }); // 渲染器 col.cellRenderer = col.cellRenderer || 'columnsRenderDefault'; return col }) return ( <> <div ref={this.refTableBody} style={{ height: this.state.height, ...style }}
17713017177/WTM
demo/WalkingTec.Mvvm.ReactDemo/ClientApp/src/components/dataView/content/agGrid.tsx
TypeScript
ArrowFunction
( reply: FastifyReply, code = 'BAD_REQUEST', message = 'Bad Request', ): FastifyReply => reply .code(400) .type('application/json') .send({ id: uuidv4(), code, message, })
IvanDimanov/demo-blog-backend
src/utils/httpReply/badRequestReply.ts
TypeScript
FunctionDeclaration
export default function OrphanageMarker(props:OrphanageProps){ return ( <Marker icon={mapIcon} position={[props.latitude,props.longitude]} > <Popup closeButton={false} minWidth={240} maxWidth={240} className="map-popup" > {props.name} <Link to={`/orphanages/${props.id}`}
DWRP/happy
web/src/components/OrphanageMarker/index.tsx
TypeScript
ArrowFunction
emission => { // If yes, we navigate away. if (emission?.behaviour === "Yes") { return true; } else { // Block navigation return false; } }
dozam8noh8/COMP3900-MealMatch-Website
frontend/MealMatch-Webapp/src/app/recipe-form-guard.service.ts
TypeScript
ClassDeclaration
@Injectable({ providedIn: 'root' }) /* This class stops away navigation for routes, it is currently disabled because there doesn't seem to be a way to cancel logout in a user clicks that. */ export class RecipeFormGuardService implements CanDeactivate<RecipeFormComponent> { constructor(private dialog: MatDialog) { } canDeactivate(component: RecipeFormComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot){ // Allow navigation only to the page associated with logout or the save button. // These are unlikely to be misclicks. if (nextState.url.includes('login') || nextState.url.includes('/recipe')) { return true; } // Make sure user confirms navigation away. let dialogRef = this.dialog.open(DangerousActionPopupComponent); dialogRef.componentInstance.description ="Wait!"; dialogRef.componentInstance.question = "Are you sure you want to navigate away, your changes will not be saved!" // Return observable which is subscribed to by guard. return dialogRef.afterClosed().pipe(map(emission => { // If yes, we navigate away. if (emission?.behaviour === "Yes") { return true; } else { // Block navigation return false; } })); } }
dozam8noh8/COMP3900-MealMatch-Website
frontend/MealMatch-Webapp/src/app/recipe-form-guard.service.ts
TypeScript
MethodDeclaration
canDeactivate(component: RecipeFormComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot){ // Allow navigation only to the page associated with logout or the save button. // These are unlikely to be misclicks. if (nextState.url.includes('login') || nextState.url.includes('/recipe')) { return true; } // Make sure user confirms navigation away. let dialogRef = this.dialog.open(DangerousActionPopupComponent); dialogRef.componentInstance.description ="Wait!"; dialogRef.componentInstance.question = "Are you sure you want to navigate away, your changes will not be saved!" // Return observable which is subscribed to by guard. return dialogRef.afterClosed().pipe(map(emission => { // If yes, we navigate away. if (emission?.behaviour === "Yes") { return true; } else { // Block navigation return false; } })); }
dozam8noh8/COMP3900-MealMatch-Website
frontend/MealMatch-Webapp/src/app/recipe-form-guard.service.ts
TypeScript
ArrowFunction
(debounce?: boolean, element?: ExplorerNode) => this.refreshWithLog(debounce, element)
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
(terminalId: string, message: string) => { appendOutput(terminalId, message); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
async (node: INodeData) => { executeExportJarTask(node); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
(uri, range) => window.showTextDocument(Uri.parse(uri), { selection: range })
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
() => commands.executeCommand(Commands.JAVA_BUILD_WORKSPACE)
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
() => commands.executeCommand(Commands.JAVA_CLEAN_WORKSPACE)
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
async (node: INodeData) => { if (!node.uri) { window.showErrorMessage("The URI of the project is not available, you can try to update the project by right clicking the project configuration file (pom.xml or *.gradle) from the File Explorer."); return; } const pattern: RelativePattern = new RelativePattern(Uri.parse(node.uri).fsPath, "{pom.xml,*.gradle}"); const uris: Uri[] = await workspace.findFiles(pattern, null /*exclude*/, 1 /*maxResults*/); if (uris.length >= 1) { commands.executeCommand(Commands.JAVA_PROJECT_CONFIGURATION_UPDATE, uris[0]); } }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
(updatedConfig, oldConfig) => { if (updatedConfig.refreshDelay !== oldConfig.refreshDelay) { this.setRefreshDelay(updatedConfig.refreshDelay); } }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
() => this.refresh(debounce, element)
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
(node: DataNode) => node.path === projectNodeData?.path && node.nodeData.name === projectNodeData?.name
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
(folder) => rootItems.push(new WorkspaceNode({ name: folder.name, uri: folder.uri.toString(), kind: NodeKind.Workspace, }, undefined))
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ArrowFunction
(project) => { rootItems.push(new ProjectNode(project, undefined)); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
ClassDeclaration
export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> { private _onDidChangeTreeData: EventEmitter<ExplorerNode | null | undefined> = new EventEmitter<ExplorerNode | null | undefined>(); // tslint:disable-next-line:member-ordering public onDidChangeTreeData: Event<ExplorerNode | null | undefined> = this._onDidChangeTreeData.event; private _rootItems: ExplorerNode[] | undefined = undefined; private _refreshDelayTrigger: _.DebouncedFunc<((element?: ExplorerNode) => void)>; constructor(public readonly context: ExtensionContext) { context.subscriptions.push(commands.registerCommand(Commands.VIEW_PACKAGE_REFRESH, (debounce?: boolean, element?: ExplorerNode) => this.refreshWithLog(debounce, element))); context.subscriptions.push(commands.registerCommand(Commands.EXPORT_JAR_REPORT, (terminalId: string, message: string) => { appendOutput(terminalId, message); })); context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_EXPORT_JAR, async (node: INodeData) => { executeExportJarTask(node); })); context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_OUTLINE, (uri, range) => window.showTextDocument(Uri.parse(uri), { selection: range }))); context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_BUILD_WORKSPACE, () => commands.executeCommand(Commands.JAVA_BUILD_WORKSPACE))); context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_CLEAN_WORKSPACE, () => commands.executeCommand(Commands.JAVA_CLEAN_WORKSPACE))); context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_UPDATE, async (node: INodeData) => { if (!node.uri) { window.showErrorMessage("The URI of the project is not available, you can try to update the project by right clicking the project configuration file (pom.xml or *.gradle) from the File Explorer."); return; } const pattern: RelativePattern = new RelativePattern(Uri.parse(node.uri).fsPath, "{pom.xml,*.gradle}"); const uris: Uri[] = await workspace.findFiles(pattern, null /*exclude*/, 1 /*maxResults*/); if (uris.length >= 1) { commands.executeCommand(Commands.JAVA_PROJECT_CONFIGURATION_UPDATE, uris[0]); } })); Settings.registerConfigurationListener((updatedConfig, oldConfig) => { if (updatedConfig.refreshDelay !== oldConfig.refreshDelay) { this.setRefreshDelay(updatedConfig.refreshDelay); } }); this.setRefreshDelay(); } public refreshWithLog(debounce?: boolean, element?: ExplorerNode) { if (Settings.autoRefresh()) { this.refresh(debounce, element); } else { instrumentOperation(Commands.VIEW_PACKAGE_REFRESH, () => this.refresh(debounce, element))(); } } public refresh(debounce = false, element?: ExplorerNode) { this._refreshDelayTrigger(element); if (!debounce) { // Immediately refresh this._refreshDelayTrigger.flush(); } } public setRefreshDelay(wait?: number) { if (!wait) { wait = Settings.refreshDelay(); } if (this._refreshDelayTrigger) { this._refreshDelayTrigger.cancel(); } this._refreshDelayTrigger = _.debounce(this.doRefresh, wait); } public getTreeItem(element: ExplorerNode): TreeItem | Promise<TreeItem> { return element.getTreeItem(); } public async getChildren(element?: ExplorerNode): Promise<ExplorerNode[] | undefined | null> { if (!await languageServerApiManager.ready()) { return []; } const children = (!this._rootItems || !element) ? await this.getRootNodes() : await element.getChildren(); explorerNodeCache.saveNodes(children || []); return children; } public getParent(element: ExplorerNode): ProviderResult<ExplorerNode> { return element.getParent(); } public async revealPaths(paths: INodeData[]): Promise<DataNode | undefined> { const projectNodeData = paths.shift(); const projects = await this.getRootProjects(); const project = projects ? <DataNode>projects.find((node: DataNode) => node.path === projectNodeData?.path && node.nodeData.name === projectNodeData?.name) : undefined; return project?.revealPaths(paths); } public async getRootProjects(): Promise<ExplorerNode[]> { const rootElements = await this.getRootNodes(); if (rootElements[0] instanceof ProjectNode) { return rootElements; } else { let result: ExplorerNode[] = []; for (const rootWorkspace of rootElements) { const projects = await rootWorkspace.getChildren(); if (projects) { result = result.concat(projects); } } return result; } } private doRefresh(element?: ExplorerNode): void { if (!element) { this._rootItems = undefined; } explorerNodeCache.removeNodeChildren(element); this._onDidChangeTreeData.fire(element); } private async getRootNodes(): Promise<ExplorerNode[]> { try { await explorerLock.acquireAsync(); if (this._rootItems) { return this._rootItems; } const rootItems: ExplorerNode[] = []; const folders = workspace.workspaceFolders; if (folders && folders.length) { if (folders.length > 1) { folders.forEach((folder) => rootItems.push(new WorkspaceNode({ name: folder.name, uri: folder.uri.toString(), kind: NodeKind.Workspace, }, undefined))); this._rootItems = rootItems; } else { const result: INodeData[] = await Jdtls.getProjects(folders[0].uri.toString()); result.forEach((project) => { rootItems.push(new ProjectNode(project, undefined)); }); this._rootItems = rootItems; } } contextManager.setContextValue(Context.NO_JAVA_PROJECT, _.isEmpty(rootItems)); return rootItems; } finally { explorerLock.release(); } } }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public refreshWithLog(debounce?: boolean, element?: ExplorerNode) { if (Settings.autoRefresh()) { this.refresh(debounce, element); } else { instrumentOperation(Commands.VIEW_PACKAGE_REFRESH, () => this.refresh(debounce, element))(); } }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public refresh(debounce = false, element?: ExplorerNode) { this._refreshDelayTrigger(element); if (!debounce) { // Immediately refresh this._refreshDelayTrigger.flush(); } }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public setRefreshDelay(wait?: number) { if (!wait) { wait = Settings.refreshDelay(); } if (this._refreshDelayTrigger) { this._refreshDelayTrigger.cancel(); } this._refreshDelayTrigger = _.debounce(this.doRefresh, wait); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public getTreeItem(element: ExplorerNode): TreeItem | Promise<TreeItem> { return element.getTreeItem(); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public async getChildren(element?: ExplorerNode): Promise<ExplorerNode[] | undefined | null> { if (!await languageServerApiManager.ready()) { return []; } const children = (!this._rootItems || !element) ? await this.getRootNodes() : await element.getChildren(); explorerNodeCache.saveNodes(children || []); return children; }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public getParent(element: ExplorerNode): ProviderResult<ExplorerNode> { return element.getParent(); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public async revealPaths(paths: INodeData[]): Promise<DataNode | undefined> { const projectNodeData = paths.shift(); const projects = await this.getRootProjects(); const project = projects ? <DataNode>projects.find((node: DataNode) => node.path === projectNodeData?.path && node.nodeData.name === projectNodeData?.name) : undefined; return project?.revealPaths(paths); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
public async getRootProjects(): Promise<ExplorerNode[]> { const rootElements = await this.getRootNodes(); if (rootElements[0] instanceof ProjectNode) { return rootElements; } else { let result: ExplorerNode[] = []; for (const rootWorkspace of rootElements) { const projects = await rootWorkspace.getChildren(); if (projects) { result = result.concat(projects); } } return result; } }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
private doRefresh(element?: ExplorerNode): void { if (!element) { this._rootItems = undefined; } explorerNodeCache.removeNodeChildren(element); this._onDidChangeTreeData.fire(element); }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
MethodDeclaration
private async getRootNodes(): Promise<ExplorerNode[]> { try { await explorerLock.acquireAsync(); if (this._rootItems) { return this._rootItems; } const rootItems: ExplorerNode[] = []; const folders = workspace.workspaceFolders; if (folders && folders.length) { if (folders.length > 1) { folders.forEach((folder) => rootItems.push(new WorkspaceNode({ name: folder.name, uri: folder.uri.toString(), kind: NodeKind.Workspace, }, undefined))); this._rootItems = rootItems; } else { const result: INodeData[] = await Jdtls.getProjects(folders[0].uri.toString()); result.forEach((project) => { rootItems.push(new ProjectNode(project, undefined)); }); this._rootItems = rootItems; } } contextManager.setContextValue(Context.NO_JAVA_PROJECT, _.isEmpty(rootItems)); return rootItems; } finally { explorerLock.release(); } }
EstherPerelman/vscode-java-dependency
src/views/dependencyDataProvider.ts
TypeScript
FunctionDeclaration
function TeacherForm() { const history = useHistory(); const [name, setName] = useState(''); const [avatar, setAvatar] = useState(''); const [whatsapp, setWhatsapp] = useState(''); const [bio, setBio] = useState(''); const [subject, setSubject] = useState(''); const [cost, setCost] = useState(''); const [scheduleItems, setScheduleItems] = useState([ { week_day: 0, from: '', to: ''} ]); function addNewScheduleItem() { setScheduleItems([ ...scheduleItems, { week_day: 0, from: '', to: ''} ]); } function setScheduleItemValue( position: number, field: string, value: string) { const updatedScheduleItems = scheduleItems.map((scheduleItem, index) => { if (index === position) { return { ...scheduleItem, [field]: value}; } return scheduleItem; }); setScheduleItems(updatedScheduleItems) } function handleCreateClass(e: FormEvent){ e.preventDefault(); api.post('classes', { name, avatar, whatsapp, bio, subject, cost: Number(cost), schedule: scheduleItems }).then(() => { alert('Cadastro realizado com sucesso!'); history.push('/'); }).catch(() => { alert('Erro no cadastro!'); }) } return ( <div id="page-teacher-form" className="container"> <PageHeader title="Que incrível que você quer dar aulas." description = "O primeiro passo é preencher esse formulário de inscrição" /> <main> <form onSubmit={handleCreateClass}> <fieldset> <legend>Seus dados</legend> <Input name="name" label="Nome completo" value={name} onChange={(e) => { setName(e.target.value)}}
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
FunctionDeclaration
function addNewScheduleItem() { setScheduleItems([ ...scheduleItems, { week_day: 0, from: '', to: ''} ]); }
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
FunctionDeclaration
function setScheduleItemValue( position: number, field: string, value: string) { const updatedScheduleItems = scheduleItems.map((scheduleItem, index) => { if (index === position) { return { ...scheduleItem, [field]: value}; } return scheduleItem; }); setScheduleItems(updatedScheduleItems) }
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
FunctionDeclaration
function handleCreateClass(e: FormEvent){ e.preventDefault(); api.post('classes', { name, avatar, whatsapp, bio, subject, cost: Number(cost), schedule: scheduleItems }).then(() => { alert('Cadastro realizado com sucesso!'); history.push('/'); }).catch(() => { alert('Erro no cadastro!'); }) }
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
ArrowFunction
(scheduleItem, index) => { if (index === position) { return { ...scheduleItem, [field]: value}; } return scheduleItem; }
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
ArrowFunction
() => { alert('Cadastro realizado com sucesso!'); history.push('/'); }
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
ArrowFunction
() => { alert('Erro no cadastro!'); }
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
ArrowFunction
(scheduleItem, index) => { return ( <div key={scheduleItem.week_day} className="schedule-item"> <Select name="week-day" label="Dia da semana" value={scheduleItem.week_day} onChange={e => setScheduleItemValue(index, 'week_day', e.target.value
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
MethodDeclaration
setScheduleItemValue(index, 'week_day', e
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
MethodDeclaration
setScheduleItemValue(index, 'from', e
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
MethodDeclaration
setScheduleItemValue(index, 'to', e
Marxneves/NLW-02
web/src/pages/TeacherForm/index.tsx
TypeScript
ClassDeclaration
export default class ArgContainer { private argList: Array<Arg>; constructor() { this.argList = new Array<Arg>(); } public get(): Array<Arg> { return this.argList; } public add(arg: Arg) { this.argList.push(arg); } }
Ciaanh/du-project
src/models/argContainer.ts
TypeScript
MethodDeclaration
public get(): Array<Arg> { return this.argList; }
Ciaanh/du-project
src/models/argContainer.ts
TypeScript
MethodDeclaration
public add(arg: Arg) { this.argList.push(arg); }
Ciaanh/du-project
src/models/argContainer.ts
TypeScript
FunctionDeclaration
function getExtraProductionArgument( prod: IProductionWithOccurrence ): string { if (prod instanceof Terminal) { return prod.terminalType.name } else if (prod instanceof NonTerminal) { return prod.nonTerminalName } else { return "" } }
Hocdoc/chevrotain
packages/chevrotain/src/parse/errors_public.ts
TypeScript
ArrowFunction
(result, currAltPaths) => result.concat(currAltPaths)
Hocdoc/chevrotain
packages/chevrotain/src/parse/errors_public.ts
TypeScript
ArrowFunction
currPath => `[${map(currPath, currTokenType => tokenLabel(currTokenType) ).join(", ")}]`
Hocdoc/chevrotain
packages/chevrotain/src/parse/errors_public.ts
TypeScript
ArrowFunction
currTokenType => tokenLabel(currTokenType)
Hocdoc/chevrotain
packages/chevrotain/src/parse/errors_public.ts
TypeScript
ArrowFunction
(itemMsg, idx) => ` ${idx + 1}. ${itemMsg}`
Hocdoc/chevrotain
packages/chevrotain/src/parse/errors_public.ts
TypeScript
ArrowFunction
currPath => `[${map(currPath, currTokenType => tokenLabel(currTokenType) ).join(",")}]`
Hocdoc/chevrotain
packages/chevrotain/src/parse/errors_public.ts
TypeScript