type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
InterfaceDeclaration
export interface SortDropdownAttrs extends ComponentAttrs { state: AbstractListState<Model>; updateUrl?: boolean; }
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
InterfaceDeclaration
export interface SortOptions { [key: string]: string; }
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
MethodDeclaration
view(): import("mithril").Vnode<{ className: string; buttonClassName: string; label: string; }, unknown>;
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
MethodDeclaration
className(): string;
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
MethodDeclaration
activeSort(): string;
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
MethodDeclaration
applySort(sort: string): void;
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
MethodDeclaration
abstract options(): SortOptions;
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
MethodDeclaration
defaultSort(): string;
flamarkt/core
js/dist-typings/common/components/AbstractSortDropdown.d.ts
TypeScript
ArrowFunction
res => { return res }
SimonGlew/SWEN325_Ionic
src/providers/user/user.ts
TypeScript
ArrowFunction
res => { if (!res) return false else { this.User.id = res.id this.events.publish("user:login", this.User); return true } }
SimonGlew/SWEN325_Ionic
src/providers/user/user.ts
TypeScript
ClassDeclaration
/* Generated class for the UserProvider provider. See https://angular.io/guide/dependency-injection for more info on providers and Angular DI. */ @Injectable() export class UserProvider { public User: any constructor(public http: HttpClient, public events: Events, public db: FirebaseDbProvider) { this.User = null } public addUser(user: any) { return this.db.addUser(user) .then(res => { return res }) } public checkUser(name: String, password: String) { this.User = { name: name, id: '' } return this.db.checkUser(name, password) .then(res => { if (!res) return false else { this.User.id = res.id this.events.publish("user:login", this.User); return true } }) } public getCurrentUser() { return this.User } public logout(){ this.User = null this.events.publish("user:logout", this.User); } }
SimonGlew/SWEN325_Ionic
src/providers/user/user.ts
TypeScript
MethodDeclaration
public addUser(user: any) { return this.db.addUser(user) .then(res => { return res }) }
SimonGlew/SWEN325_Ionic
src/providers/user/user.ts
TypeScript
MethodDeclaration
public checkUser(name: String, password: String) { this.User = { name: name, id: '' } return this.db.checkUser(name, password) .then(res => { if (!res) return false else { this.User.id = res.id this.events.publish("user:login", this.User); return true } }) }
SimonGlew/SWEN325_Ionic
src/providers/user/user.ts
TypeScript
MethodDeclaration
public getCurrentUser() { return this.User }
SimonGlew/SWEN325_Ionic
src/providers/user/user.ts
TypeScript
MethodDeclaration
public logout(){ this.User = null this.events.publish("user:logout", this.User); }
SimonGlew/SWEN325_Ionic
src/providers/user/user.ts
TypeScript
ArrowFunction
({ layoutItem, type }: TextBoxProps) => { const { readOnly, getValue, editorPreparing, editorInitialized, editorValidating, editorValueChanged, editorEntered, } = useContext(EditItemsContext); const [required, setRequired] = useState(layoutItem.required ?? false); const [readonly, setReadonly] = useState( !readOnly || readOnly() || layoutItem.readonly ); const [prepared, setPrepared] = useState<boolean>(); const valueNotificationRef = useRef(true); const editorRef = useRef<DxTextBox>(null); useEffect(() => { if (layoutItem && layoutItem.dataMember && editorPreparing && readOnly) { editorPreparing(layoutItem.dataMember, layoutItem); setReadonly(!readOnly || readOnly() || layoutItem.readonly); setRequired(layoutItem.required ?? false); setPrepared(true); } }, [layoutItem, editorPreparing, readOnly]); if ( prepared && readOnly && getValue && editorInitialized && editorValueChanged && editorValidating && editorEntered ) { const editor = { getOption: (option) => { switch (option) { case 'value': return editorRef.current?.instance.option('value'); case 'required': return required; case 'readonly': return readonly; } }, setOption: (option, newValue) => { switch (option) { case 'value': valueNotificationRef.current = false; editorRef.current?.instance.option('value', newValue); valueNotificationRef.current = true; break; case 'required': setRequired(newValue as boolean); break; case 'readonly': setReadonly(readOnly() || (newValue as boolean)); break; } }, } as EditorRef; return ( <FieldSet layoutItem={layoutItem}> <DxTextBox ref={editorRef} name={layoutItem.dataMember} defaultValue={getValue(layoutItem.dataMember)} readOnly={readonly} onInitialized={()
frankball/ballware-react-renderer-dx
src/editing/items/textbox.tsx
TypeScript
ArrowFunction
() => { if (layoutItem && layoutItem.dataMember && editorPreparing && readOnly) { editorPreparing(layoutItem.dataMember, layoutItem); setReadonly(!readOnly || readOnly() || layoutItem.readonly); setRequired(layoutItem.required ?? false); setPrepared(true); } }
frankball/ballware-react-renderer-dx
src/editing/items/textbox.tsx
TypeScript
ArrowFunction
(option) => { switch (option) { case 'value': return editorRef.current?.instance.option('value'); case 'required': return required; case 'readonly': return readonly; } }
frankball/ballware-react-renderer-dx
src/editing/items/textbox.tsx
TypeScript
ArrowFunction
(option, newValue) => { switch (option) { case 'value': valueNotificationRef.current = false; editorRef.current?.instance.option('value', newValue); valueNotificationRef.current = true; break; case 'required': setRequired(newValue as boolean); break; case 'readonly': setReadonly(readOnly() || (newValue as boolean)); break; } }
frankball/ballware-react-renderer-dx
src/editing/items/textbox.tsx
TypeScript
ArrowFunction
(v) => ( <CustomRule key={v.identifier}
frankball/ballware-react-renderer-dx
src/editing/items/textbox.tsx
TypeScript
InterfaceDeclaration
export interface TextBoxProps extends EditItemProps { type: 'text' | 'mail'; }
frankball/ballware-react-renderer-dx
src/editing/items/textbox.tsx
TypeScript
MethodDeclaration
getValue(layoutItem
frankball/ballware-react-renderer-dx
src/editing/items/textbox.tsx
TypeScript
FunctionDeclaration
function Page() { const { data } = useQuery( key, async () => { await sleep(10) if (!succeed) { throw new Error('Error') } else { return 'data' } }, { retry: false, useErrorBoundary: true, } ) return <div>{data}</div> }
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
FunctionDeclaration
function Page() { const { data } = useQuery( key, async () => { fetchCount++ await sleep(10) throw new Error('Error') }, { retry: false, useErrorBoundary: true, } ) return <div>{data}</div> }
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
() => { const queryCache = new QueryCache() const queryClient = new QueryClient({ queryCache }) it('should retry fetch if the reset error boundary has been reset', async () => { const key = queryKey() let succeed = false const consoleMock = mockConsoleError() function Page() { const { data } = useQuery( key, async () => { await sleep(10) if (!succeed) { throw new Error('Error') } else { return 'data' } }, { retry: false, useErrorBoundary: true, } ) return <div>{data}</div> } const rendered = renderWithClient( queryClient, <QueryErrorResetBoundary> {({ reset }) => ( <ErrorBoundary onReset={reset} fallbackRender={({ resetErrorBoundary }) => ( <div> <div>error boundary</div> <button onClick={() => { resetErrorBoundary() }} > retry </button> </div> )}
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
async () => { const key = queryKey() let succeed = false const consoleMock = mockConsoleError() function Page() { const { data } = useQuery( key, async () => { await sleep(10) if (!succeed) { throw new Error('Error') } else { return 'data' } }, { retry: false, useErrorBoundary: true, } ) return <div>{data}</div> } const rendered = renderWithClient( queryClient, <QueryErrorResetBoundary> {({ reset }) => ( <ErrorBoundary onReset={reset} fallbackRender={({ resetErrorBoundary }) => ( <div> <div>error boundary</div> <button onClick={() => { resetErrorBoundary() }}
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
async () => { await sleep(10) if (!succeed) { throw new Error('Error') } else { return 'data' } }
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
() => rendered.getByText('error boundary')
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
() => rendered.getByText('retry')
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
() => rendered.getByText('data')
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
async () => { const key = queryKey() const consoleMock = mockConsoleError() let fetchCount = 0 function Page() { const { data } = useQuery( key, async () => { fetchCount++ await sleep(10) throw new Error('Error') }, { retry: false, useErrorBoundary: true, } ) return <div>{data}</div> } const rendered = renderWithClient( queryClient, <QueryErrorResetBoundary> {({ reset }) => ( <ErrorBoundary onReset={reset} fallbackRender={({ resetErrorBoundary }) => ( <div> <div>error boundary</div> <button onClick={() => { resetErrorBoundary() }}
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
async () => { fetchCount++ await sleep(10) throw new Error('Error') }
5achinJani/react-query
src/react/tests/QueryResetErrorBoundary.test.tsx
TypeScript
ArrowFunction
() => { test('it throws for empty file', async () => { await expect(async () => { await TemplateRoot.create('./test/resources/empty-file.yml'); }).rejects.toThrowError(/empty-file/); await expect(async () => { await TemplateRoot.create('./test/resources/empty-file.yml'); }).rejects.toThrowError(/is empty/); }); test('it throws for invalid version', async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-version.yml'); }).rejects.toThrowError(/Unexpected AWSTemplateFormatVersion version/); }); test('it throws for invalid yaml', async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-yml.yml'); }).rejects.toThrowError(/unable to load file/); }); test('it throws for missing organization attribute', async () => { await expect(async () => { await TemplateRoot.create('./test/resources/missing-organization.yml'); }).rejects.toThrowError(/Organization attribute is missing/); }); test('it throws for invalid include (not found)', async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-include-notfound.yml'); }).rejects.toThrowError(/no such file or directory/); await expect(async () => { await TemplateRoot.create('./test/resources/invalid-include-notfound.yml'); }).rejects.toThrowError(/\/not-found.yml/); }); test('it throws for invalid include (invalid yml)', async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-include-invalid-yml.yml'); }).rejects.toThrowError(); }); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await expect(async () => { await TemplateRoot.create('./test/resources/empty-file.yml'); }).rejects.toThrowError(/empty-file/); await expect(async () => { await TemplateRoot.create('./test/resources/empty-file.yml'); }).rejects.toThrowError(/is empty/); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await TemplateRoot.create('./test/resources/empty-file.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-version.yml'); }).rejects.toThrowError(/Unexpected AWSTemplateFormatVersion version/); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await TemplateRoot.create('./test/resources/invalid-version.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-yml.yml'); }).rejects.toThrowError(/unable to load file/); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await TemplateRoot.create('./test/resources/invalid-yml.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await expect(async () => { await TemplateRoot.create('./test/resources/missing-organization.yml'); }).rejects.toThrowError(/Organization attribute is missing/); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await TemplateRoot.create('./test/resources/missing-organization.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-include-notfound.yml'); }).rejects.toThrowError(/no such file or directory/); await expect(async () => { await TemplateRoot.create('./test/resources/invalid-include-notfound.yml'); }).rejects.toThrowError(/\/not-found.yml/); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await TemplateRoot.create('./test/resources/invalid-include-notfound.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await expect(async () => { await TemplateRoot.create('./test/resources/invalid-include-invalid-yml.yml'); }).rejects.toThrowError(); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { await TemplateRoot.create('./test/resources/invalid-include-invalid-yml.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { let basic: TemplateRoot; beforeEach(async () => { basic = await TemplateRoot.create('./test/resources/valid-basic.yml'); }); test('it parses successfully', () => { expect(basic).toBeDefined(); }); test('it contains master account', () => { expect(basic.organizationSection.masterAccount).toBeDefined(); }); test('master account has logical id and type', () => { expect(basic.organizationSection.masterAccount.logicalId).toBe('MasterAccount'); expect(basic.organizationSection.masterAccount.type).toBe('OC::ORG::MasterAccount'); }); test('master account has the right attributes', () => { expect(basic.organizationSection.masterAccount.accountName).toBe('My Organization Root'); expect(basic.organizationSection.masterAccount.accountId).toBe('123456789012'); expect(basic.organizationSection.masterAccount.rootEmail).toBeUndefined(); }); test('it contains no other organizational resources', () => { expect(basic.organizationSection.accounts.length).toBe(0); expect(basic.organizationSection.organizationalUnits.length).toBe(0); expect(basic.organizationSection.serviceControlPolicies.length).toBe(0); expect(basic.organizationSection.organizationRoot).toBeUndefined(); }); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { basic = await TemplateRoot.create('./test/resources/valid-basic.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(basic).toBeDefined(); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(basic.organizationSection.masterAccount).toBeDefined(); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(basic.organizationSection.masterAccount.logicalId).toBe('MasterAccount'); expect(basic.organizationSection.masterAccount.type).toBe('OC::ORG::MasterAccount'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(basic.organizationSection.masterAccount.accountName).toBe('My Organization Root'); expect(basic.organizationSection.masterAccount.accountId).toBe('123456789012'); expect(basic.organizationSection.masterAccount.rootEmail).toBeUndefined(); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(basic.organizationSection.accounts.length).toBe(0); expect(basic.organizationSection.organizationalUnits.length).toBe(0); expect(basic.organizationSection.serviceControlPolicies.length).toBe(0); expect(basic.organizationSection.organizationRoot).toBeUndefined(); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { let basic: TemplateRoot; let include: TemplateRoot; beforeEach(async () => { basic = await TemplateRoot.create('./test/resources/valid-basic.yml'); include = await TemplateRoot.create('./test/resources/valid-include.yml'); }); test('it contains same organization contents when loading directly', () => { expect(JSON.stringify(include.contents.Organization)).toBe(JSON.stringify(basic.contents.Organization)); }); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { basic = await TemplateRoot.create('./test/resources/valid-basic.yml'); include = await TemplateRoot.create('./test/resources/valid-include.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(JSON.stringify(include.contents.Organization)).toBe(JSON.stringify(basic.contents.Organization)); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { let template: TemplateRoot; let sandbox = Sinon.createSandbox(); beforeEach(async () => { sandbox.stub(ConsoleUtil, 'LogWarning'); template = await TemplateRoot.create('./test/resources/valid-regular-cloudformation.yml'); }); afterEach(() => { sandbox.restore(); }) test('template contains organization resource', () => { expect(template.organizationSection.resources.length).toBe(1); }); test('template contains cloudformation resource', () => { expect(template.resourcesSection.resources.length).toBe(1); }); test('template contains output', () => { expect(template.contents.Outputs).toBeDefined(); }); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { sandbox.stub(ConsoleUtil, 'LogWarning'); template = await TemplateRoot.create('./test/resources/valid-regular-cloudformation.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { sandbox.restore(); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(template.organizationSection.resources.length).toBe(1); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(template.resourcesSection.resources.length).toBe(1); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(template.contents.Outputs).toBeDefined(); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { let template: TemplateRoot; let sandbox = Sinon.createSandbox(); beforeEach(async () => { sandbox.stub(ConsoleUtil, 'LogWarning'); template = await TemplateRoot.create('./test/resources/merge.yml'); }); test('template contains 9 accounts', () => { expect(template.organizationSection.accounts.length).toBe(9); }); afterEach(() => { sandbox.restore(); }) }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
async () => { sandbox.stub(ConsoleUtil, 'LogWarning'); template = await TemplateRoot.create('./test/resources/merge.yml'); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
ArrowFunction
() => { expect(template.organizationSection.accounts.length).toBe(9); }
GrahamCampbell/org-formation-cli
test/unit-tests/parser/parser.files.test.ts
TypeScript
FunctionDeclaration
// Helper to convert strings used for jsonPath where \. or - is present to use indexed notation, // for example: .metadata.labels.kubesphere\.io/alias-name -> .metadata.labels['kubesphere\.io/alias-name'] export function parseJsonPath(jsonPath: string) { let pathExpression = jsonPath; if (jsonPath.match(/[\\-]/g)) { // search for '\' and '-' const [first, ...rest] = jsonPath.split(/(?<=\w)\./); // split jsonPath by '.' (\. cases are ignored) pathExpression = `${convertToIndexNotation(first, true)}${rest.map(value => convertToIndexNotation(value)).join("")}`; } // strip '\' characters from the result return pathExpression.replace(/\\/g, ""); }
BlackHole1/lens
src/renderer/utils/jsonPath.ts
TypeScript
FunctionDeclaration
function convertToIndexNotation(key: string, firstItem = false) { if (key.match(/[\\-]/g)) { // check if found '\' and '-' in key if (key.includes("[")) { // handle cases where key contains [...] const keyToConvert = key.match(/^.*(?=\[)/g); // get the text from the key before '[' if (keyToConvert && keyToConvert[0].match(/[\\-]/g)) { // check if that part contains illegal characters return key.replace(keyToConvert[0], `['${keyToConvert[0]}']`); // surround key with '[' and ']' } else { return `.${key}`; // otherwise return as is with leading '.' } } return `['${key}']`; } else { // no illegal chracters found, do not touch const prefix = firstItem ? "" : "."; return `${prefix}${key}`; } }
BlackHole1/lens
src/renderer/utils/jsonPath.ts
TypeScript
ArrowFunction
value => convertToIndexNotation(value)
BlackHole1/lens
src/renderer/utils/jsonPath.ts
TypeScript
ArrowFunction
() => { return ( <div className=""> <Head> <title>Your Template App</title> <meta name="description" content="Generated by create next app" /> <link rel="icon" href="/favicon.ico" /> </Head> </div>
cptlstudio/nextjs-template
src/pages/index.tsx
TypeScript
FunctionDeclaration
function makeArrowStyles(direction: string, color: string, size: number): any { let arrowStyles; if (direction === 'topLeft') { arrowStyles = { borderLeft: `${size}px solid transparent`, borderRight: `${size}px solid transparent`, borderBottom: `${size}px solid ${color}`, borderTop: 0, top: `-${size}px`, left: `${size}px`, }; } if (direction === 'topCenter') { arrowStyles = { borderLeft: `${size}px solid transparent`, borderRight: `${size}px solid transparent`, borderBottom: `${size}px solid ${color}`, borderTop: 0, top: `-${size}px`, left: `calc(50% - ${size}px)`, }; } if (direction === 'topRight') { arrowStyles = { borderLeft: `${size}px solid transparent`, borderRight: `${size}px solid transparent`, borderBottom: `${size}px solid ${color}`, borderTop: 0, top: `-${size}px`, right: `${size}px`, }; } if (direction === 'rightTop') { arrowStyles = { borderLeft: `${size}px solid ${color}`, borderRight: 0, borderBottom: `${size}px solid transparent`, borderTop: `${size}px solid transparent`, right: `-${size}px`, top: `${size}px`, }; } if (direction === 'rightCenter') { arrowStyles = { borderLeft: `${size}px solid ${color}`, borderRight: 0, borderBottom: `${size}px solid transparent`, borderTop: `${size}px solid transparent`, right: `-${size}px`, top: `calc(50% - ${size}px)`, }; } if (direction === 'rightBottom') { arrowStyles = { borderLeft: `${size}px solid ${color}`, borderRight: 0, borderBottom: `${size}px solid transparent`, borderTop: `${size}px solid transparent`, right: `-${size}px`, bottom: `${size}px`, }; } if (direction === 'bottomRight') { arrowStyles = { borderLeft: `${size}px solid transparent`, borderRight: `${size}px solid transparent`, borderBottom: 0, borderTop: `${size}px solid ${color}`, right: `${size}px`, bottom: `-${size}px`, }; } if (direction === 'bottomCenter') { arrowStyles = { borderLeft: `${size}px solid transparent`, borderRight: `${size}px solid transparent`, borderBottom: 0, borderTop: `${size}px solid ${color}`, right: `calc(50% - ${size}px)`, bottom: `-${size}px`, }; } if (direction === 'bottomLeft') { arrowStyles = { borderLeft: `${size}px solid transparent`, borderRight: `${size}px solid transparent`, borderBottom: 0, borderTop: `${size}px solid ${color}`, left: `${size}px`, bottom: `-${size}px`, }; } if (direction === 'leftBottom') { arrowStyles = { borderLeft: 0, borderRight: `${size}px solid ${color}`, borderBottom: `${size}px solid transparent`, borderTop: `${size}px solid transparent`, left: `-${size}px`, bottom: `${size}px`, }; } if (direction === 'leftCenter') { arrowStyles = { borderLeft: 0, borderRight: `${size}px solid ${color}`, borderBottom: `${size}px solid transparent`, borderTop: `${size}px solid transparent`, left: `-${size}px`, bottom: `calc(50% - ${size}px)`, }; } if (direction === 'leftTop') { arrowStyles = { borderLeft: 0, borderRight: `${size}px solid ${color}`, borderBottom: `${size}px solid transparent`, borderTop: `${size}px solid transparent`, left: `-${size}px`, top: `${size}px`, }; } return arrowStyles; }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
FunctionDeclaration
function setTranslation(direction = 'topCenter', size: number) { let x = '0px'; let y = '0px'; if (direction === 'topLeft') { x = -(size * 2) + 'px'; y = (size + BUFFER) + 'px'; } if (direction === 'topCenter') { x = '-50%'; y = (size + BUFFER) + 'px'; } if (direction === 'topRight') { x = 'calc(-100% + ' + (size * 2) + 'px)'; y = (size + BUFFER) + 'px'; } if (direction === 'rightTop') { x = 'calc(-100% + ' + (-size - BUFFER) + 'px)'; y = -(size * 2) + 'px'; } if (direction === 'rightCenter') { x = 'calc(-100% + ' + (-size - BUFFER) + 'px)'; y = '-50%'; } if (direction === 'rightBottom') { x = 'calc(-100% + ' + (-size - BUFFER) + 'px)'; y = 'calc(-100% + ' + (size * 2) + 'px)'; } if (direction === 'bottomRight') { x = 'calc(-100% + ' + (size * 2) + 'px)'; y = 'calc(-100% + ' + (-size - BUFFER) + 'px)'; } if (direction === 'bottomCenter') { x = '-50%'; y = 'calc(-100% + ' + (-size - BUFFER) + 'px)'; } if (direction === 'bottomLeft') { x = -(size * 2) + 'px'; y = 'calc(-100% + ' + (-size - BUFFER) + 'px)'; } if (direction === 'leftBottom') { x = (size + BUFFER) + 'px'; y = 'calc(-100% + ' + (size * 2) + 'px)'; } if (direction === 'leftCenter') { x = (size + BUFFER) + 'px'; y = '-50%'; } if (direction === 'leftTop') { x = (size + BUFFER) + 'px'; y = -(size * 2) + 'px'; } return `translate(${x}, ${y})`; }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
ArrowFunction
(direction: string, color: string, size: number): React.CSSProperties => { return { ...base, ...makeArrowStyles(direction, color, size), }; }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
ArrowFunction
() => window.addEventListener('click', this.checkClick)
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
ClassDeclaration
export class ToolTip extends React.PureComponent<IToolTipProps, IToolTipState> { container: HTMLDivElement = null; state = { isVisible: this.props.isVisible, }; componentDidMount() { if (this.props.onDeactivate) { setTimeout(() => window.addEventListener('click', this.checkClick), 60); } } componentWillUpdate(nextProps: IToolTipProps) { if (this.props.isVisible !== nextProps.isVisible) { this.setState({ isVisible: nextProps.isVisible, }); } } componentWillUnmount() { window.removeEventListener('click', this.checkClick); } @autobind saveContainerRef(el: HTMLDivElement) { this.container = el; } @autobind checkClick(e: any) { e.preventDefault(); if (!this.container || this.container.contains(e.target as any)) { return; } this.setState({ isVisible: false, }); if (this.props.onDeactivate) { this.props.onDeactivate(); } } render() { const { arrowPosition, backgroundColor, hasDropShadow, children, position, size, zIndex, width, } = this.props; const { isVisible, } = this.state; return ( <div ref={this.saveContainerRef} {...css( STYLES.base, { position: 'absolute', backgroundColor }, width && { width }, position && { left: position.left, top: position.top, transform: setTranslation(arrowPosition, size), }, !isVisible && { display: 'none' }, zIndex ? { zIndex } : { zIndex: TOOLTIP_Z_INDEX }, hasDropShadow && { filter: 'drop-shadow(0px 0px 25px rgba(0, 0, 0, 0.117647))' }, )} > {children} <div {...css(makeArrow(this.props.arrowPosition, this.props.backgroundColor, this.props.size))} /> </div> ); } }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
InterfaceDeclaration
export interface IToolTipProps extends React.Props<any> { arrowPosition?: ArrowPosition; backgroundColor: string; hasDropShadow?: boolean; isVisible: boolean; size: number; position?: { top: number, left: number, }; zIndex?: number; onDeactivate?(): any; width?: number; }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
InterfaceDeclaration
export interface IToolTipState { isVisible: boolean; }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
TypeAliasDeclaration
export type ArrowPosition = 'topLeft' | 'topCenter' | 'topRight' | 'rightTop' | 'rightCenter' | 'rightBottom' | 'bottomRight' | 'bottomCenter' | 'bottomLeft' | 'leftBottom' | 'leftCenter' | 'leftTop';
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
MethodDeclaration
componentDidMount() { if (this.props.onDeactivate) { setTimeout(() => window.addEventListener('click', this.checkClick), 60); } }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
MethodDeclaration
componentWillUpdate(nextProps: IToolTipProps) { if (this.props.isVisible !== nextProps.isVisible) { this.setState({ isVisible: nextProps.isVisible, }); } }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
MethodDeclaration
componentWillUnmount() { window.removeEventListener('click', this.checkClick); }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
MethodDeclaration
@autobind saveContainerRef(el: HTMLDivElement) { this.container = el; }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
MethodDeclaration
@autobind checkClick(e: any) { e.preventDefault(); if (!this.container || this.container.contains(e.target as any)) { return; } this.setState({ isVisible: false, }); if (this.props.onDeactivate) { this.props.onDeactivate(); } }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
MethodDeclaration
render() { const { arrowPosition, backgroundColor, hasDropShadow, children, position, size, zIndex, width, } = this.props; const { isVisible, } = this.state; return ( <div ref={this.saveContainerRef} {...css( STYLES.base, { position: 'absolute', backgroundColor }, width && { width }, position && { left: position.left, top: position.top, transform: setTranslation(arrowPosition, size), }, !isVisible && { display: 'none' }, zIndex ? { zIndex } : { zIndex: TOOLTIP_Z_INDEX }, hasDropShadow && { filter: 'drop-shadow(0px 0px 25px rgba(0, 0, 0, 0.117647))' }, )} > {children} <div {...css(makeArrow(this.props.arrowPosition, this.props.backgroundColor, this.props.size))} /> </div> ); }
cameronaaron/conversationai-moderator
packages/frontend-web/src/app/components/ToolTip/ToolTip.tsx
TypeScript
ClassDeclaration
@Controller('categorias') export class CategoriaController { constructor( private readonly categoriaService: CategoriaService, ) {} @Get() @HttpCode(200) async get() { return await this.categoriaService.get(); } @Post() @HttpCode(200) async insert(@Body() categoria:Categoria) { return await this.categoriaService.save(new Categoria(categoria)); } @Put() @HttpCode(200) async update(@Body() categoria:Categoria) { return await this.categoriaService.save(new Categoria(categoria)); } @Delete(':id') @HttpCode(200) async delete(@Param('id') id:number) { return await this.categoriaService.delete(id); } }
dias1618/aquila-backend-records
src/controllers/categoria.controller.ts
TypeScript
MethodDeclaration
@Get() @HttpCode(200) async get() { return await this.categoriaService.get(); }
dias1618/aquila-backend-records
src/controllers/categoria.controller.ts
TypeScript
MethodDeclaration
@Post() @HttpCode(200) async insert(@Body() categoria:Categoria) { return await this.categoriaService.save(new Categoria(categoria)); }
dias1618/aquila-backend-records
src/controllers/categoria.controller.ts
TypeScript
MethodDeclaration
@Put() @HttpCode(200) async update(@Body() categoria:Categoria) { return await this.categoriaService.save(new Categoria(categoria)); }
dias1618/aquila-backend-records
src/controllers/categoria.controller.ts
TypeScript
MethodDeclaration
@Delete(':id') @HttpCode(200) async delete(@Param('id') id:number) { return await this.categoriaService.delete(id); }
dias1618/aquila-backend-records
src/controllers/categoria.controller.ts
TypeScript
ArrowFunction
async (packet: IlpPrepare, next: MiddlewareCallback<IlpPrepare, IlpReply>) => { const { amount } = packet // TODO: Do we need a BigNumber-based token bucket? if (!incomingBucket.take(Number(amount))) { throw new InsufficientLiquidityError('exceeded money bandwidth, throttling.') } return next(packet) }
1Crazymoney/ilp-connector
src/middlewares/throughput.ts
TypeScript
ClassDeclaration
export default class ThroughputMiddleware implements Middleware { async applyToPipelines (pipelines: Pipelines, account: Account) { if (account.info.throughput) { const { refillPeriod = DEFAULT_REFILL_PERIOD, incomingAmount = false, outgoingAmount = false } = account.info.throughput || {} if (incomingAmount) { // TODO: When we add the ability to update middleware, our state will get // reset every update, which may not be desired. const incomingBucket = new TokenBucket({ refillPeriod, refillCount: Number(incomingAmount) }) log.trace('created incoming amount limit token bucket for account. accountId=%s refillPeriod=%s incomingAmount=%s', account.id, refillPeriod, incomingAmount) pipelines.incomingData.insertLast({ name: 'throughput', method: async (packet: IlpPrepare, next: MiddlewareCallback<IlpPrepare, IlpReply>) => { const { amount } = packet // TODO: Do we need a BigNumber-based token bucket? if (!incomingBucket.take(Number(amount))) { throw new InsufficientLiquidityError('exceeded money bandwidth, throttling.') } return next(packet) } }) } if (outgoingAmount) { // TODO: When we add the ability to update middleware, our state will get // reset every update, which may not be desired. const incomingBucket = new TokenBucket({ refillPeriod, refillCount: Number(outgoingAmount) }) log.trace('created outgoing amount limit token bucket for account. accountId=%s refillPeriod=%s outgoingAmount=%s', account.id, refillPeriod, outgoingAmount) pipelines.outgoingData.insertLast({ name: 'throughput', method: async (packet: IlpPrepare, next: MiddlewareCallback<IlpPrepare, IlpReply>) => { const { amount } = packet // TODO: Do we need a BigNumber-based token bucket? if (!incomingBucket.take(Number(amount))) { throw new InsufficientLiquidityError('exceeded money bandwidth, throttling.') } return next(packet) } }) } } } }
1Crazymoney/ilp-connector
src/middlewares/throughput.ts
TypeScript
MethodDeclaration
async applyToPipelines (pipelines: Pipelines, account: Account) { if (account.info.throughput) { const { refillPeriod = DEFAULT_REFILL_PERIOD, incomingAmount = false, outgoingAmount = false } = account.info.throughput || {} if (incomingAmount) { // TODO: When we add the ability to update middleware, our state will get // reset every update, which may not be desired. const incomingBucket = new TokenBucket({ refillPeriod, refillCount: Number(incomingAmount) }) log.trace('created incoming amount limit token bucket for account. accountId=%s refillPeriod=%s incomingAmount=%s', account.id, refillPeriod, incomingAmount) pipelines.incomingData.insertLast({ name: 'throughput', method: async (packet: IlpPrepare, next: MiddlewareCallback<IlpPrepare, IlpReply>) => { const { amount } = packet // TODO: Do we need a BigNumber-based token bucket? if (!incomingBucket.take(Number(amount))) { throw new InsufficientLiquidityError('exceeded money bandwidth, throttling.') } return next(packet) } }) } if (outgoingAmount) { // TODO: When we add the ability to update middleware, our state will get // reset every update, which may not be desired. const incomingBucket = new TokenBucket({ refillPeriod, refillCount: Number(outgoingAmount) }) log.trace('created outgoing amount limit token bucket for account. accountId=%s refillPeriod=%s outgoingAmount=%s', account.id, refillPeriod, outgoingAmount) pipelines.outgoingData.insertLast({ name: 'throughput', method: async (packet: IlpPrepare, next: MiddlewareCallback<IlpPrepare, IlpReply>) => { const { amount } = packet // TODO: Do we need a BigNumber-based token bucket? if (!incomingBucket.take(Number(amount))) { throw new InsufficientLiquidityError('exceeded money bandwidth, throttling.') } return next(packet) } }) } } }
1Crazymoney/ilp-connector
src/middlewares/throughput.ts
TypeScript
ArrowFunction
() => localeCN
chalecao/preact-h5-ui
src/calendar/index.tsx
TypeScript
ClassDeclaration
export default class Calendar extends React.Component<CalendarProps, any> { static defaultProps = { prefixCls: 'am-calendar', timePickerPrefixCls: 'am-picker', timePickerPickerPrefixCls: 'am-picker-col' }; static contextTypes = { antLocale: PropTypes.object }; render() { // tslint:disable-next-line:no-this-assignment const { props, context } = this; const locale = getComponentLocale(props, context, 'Calendar', () => localeCN ); const Header = RMCalendar.DefaultHeader; return ( <RMCalendar locale={locale} // tslint:disable-next-line:jsx-no-multiline-js renderHeader={headerProps => ( <Header {...headerProps} closeIcon={<Icon type="cross" />}
chalecao/preact-h5-ui
src/calendar/index.tsx
TypeScript
MethodDeclaration
render() { // tslint:disable-next-line:no-this-assignment const { props, context } = this; const locale = getComponentLocale(props, context, 'Calendar', () => localeCN ); const Header = RMCalendar.DefaultHeader; return ( <RMCalendar locale={locale} // tslint:disable-next-line:jsx-no-multiline-js renderHeader={headerProps => ( <Header {...headerProps} closeIcon={<Icon type="cross" />}
chalecao/preact-h5-ui
src/calendar/index.tsx
TypeScript
ClassDeclaration
@Component({ selector: 'verseghy-toast', templateUrl: './toast.component.html', styleUrls: ['./toast.component.scss'], animations: [ trigger('toast', [ transition(':enter', [ style({ opacity: 0, transform: 'translate3d(0, calc(100% + 10px), 0)', }), animate( '200ms ease-out', style({ opacity: 1, transform: 'translate3d(0, 0, 0)', }) ), ]), transition(':leave', [ style({ opacity: 1, transform: 'translate3d(0, 0, 0)', }), animate( '200ms ease-in', style({ opacity: 0, transform: 'translate3d(0, calc(100% + 10px), 0)', }) ), ]), ]), ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class ToastComponent { toast$ = this.toastService.toast$ constructor(private toastService: ToastService) {} }
Verseghy/website_frontend
apps/frontend/src/app/components/toast/toast.component.ts
TypeScript
ArrowFunction
({ attributes, children, element, }: ElementProps) => { switch (element.type) { case ElementType['heading_one']: return <RichTextH1 {...attributes}>{children}</RichTextH1>; case ElementType['heading_two']: return <RichTextH2 {...attributes}>{children}</RichTextH2>; case ElementType['heading_three']: return <RichTextH3 {...attributes}>{children}</RichTextH3>; case ElementType['list_item']: return <RichTextLi {...attributes}>{children}</RichTextLi>; case ElementType['ol_list']: return <RichTextOl {...attributes}>{children}</RichTextOl>; case ElementType['ul_list']: return <RichTextUl {...attributes}>{children}</RichTextUl>; default: return <RichTextP {...attributes}>{children}</RichTextP>; } }
technologiestiftung/kulturdaten-frontend
components/richtext/Element.tsx
TypeScript
InterfaceDeclaration
export interface ElementProps { attributes: { [key: string]: string | number | boolean }; children: React.ReactNode; element: CustomElement; }
technologiestiftung/kulturdaten-frontend
components/richtext/Element.tsx
TypeScript
EnumDeclaration
export enum ElementType { 'heading_one' = 'heading_one', 'heading_two' = 'heading_two', 'heading_three' = 'heading_three', 'ol_list' = 'ol_list', 'ul_list' = 'ul_list', 'list_item' = 'list_item', 'paragraph' = 'paragraph', }
technologiestiftung/kulturdaten-frontend
components/richtext/Element.tsx
TypeScript
TypeAliasDeclaration
export type CustomText = { bold?: boolean; italic?: boolean; underline?: boolean; } & Text;
technologiestiftung/kulturdaten-frontend
components/richtext/Element.tsx
TypeScript
TypeAliasDeclaration
export type CustomDescendant = CustomElement | CustomText;
technologiestiftung/kulturdaten-frontend
components/richtext/Element.tsx
TypeScript
TypeAliasDeclaration
export type CustomElement = { type: ElementType; children: CustomDescendant[] } & SlateElement;
technologiestiftung/kulturdaten-frontend
components/richtext/Element.tsx
TypeScript