repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
wingman-ai | github_2023 | RussellCanfield | typescript | computeDiff | const computeDiff = (
oldValue: string | Object,
newValue: string | Object,
compareMethod: string = DiffMethod.CHARS
): ComputedDiffInformation => {
const diffArray: JsDiffChangeObject[] = jsDiff[compareMethod](
oldValue,
newValue
);
const computedDiff: ComputedDiffInformation = {
left: [],
right: [],
};... | /**
* Computes word diff information in the line.
* [TODO]: Consider adding options argument for JsDiff text block comparison
*
* @param oldValue Old word in the line.
* @param newValue New word in the line.
* @param compareMethod JsDiff text diff method from https://github.com/kpdecker/jsdiff/tree/v4.0.1#api
*/ | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Common/DiffView/compute-lines.ts#L76-L110 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
wingman-ai | github_2023 | RussellCanfield | typescript | computeLineInformation | const computeLineInformation = (
oldString: string | Object,
newString: string | Object,
disableWordDiff: boolean = false,
lineCompareMethod: string = DiffMethod.CHARS,
linesOffset: number = 0,
showLines: string[] = []
): ComputedLineInformation => {
let diffArray: Diff.Change[] = [];
// Use diffLines for stri... | /**
* [TODO]: Think about moving common left and right value assignment to a
* common place. Better readability?
*
* Computes line wise information based in the js diff information passed. Each
* line contains information about left and right section. Left side denotes
* deletion and right side denotes addition.
... | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Common/DiffView/compute-lines.ts#L127-L290 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
wingman-ai | github_2023 | RussellCanfield | typescript | VSCodeAPIWrapper.postMessage | public postMessage(message: unknown) {
if (this.vsCodeApi) {
this.vsCodeApi.postMessage(message);
} else {
console.log(message);
}
} | /**
* Post a message (i.e. send arbitrary data) to the owner of the webview.
*
* @remarks When running webview code inside a web browser, postMessage will instead
* log the given message to the console.
*
* @param message Abitrary data (must be JSON serializable) to send to the extension context.
*/ | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Config/utilities/vscode.ts#L31-L37 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
wingman-ai | github_2023 | RussellCanfield | typescript | VSCodeAPIWrapper.getState | public getState(): unknown | undefined {
if (this.vsCodeApi) {
return this.vsCodeApi.getState();
} else {
const state = localStorage.getItem("vscodeState");
return state ? JSON.parse(state) : undefined;
}
} | /**
* Get the persistent state stored for this webview.
*
* @remarks When running webview source code inside a web browser, getState will retrieve state
* from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
*
* @return The current state or `undefined` if no state has b... | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Config/utilities/vscode.ts#L47-L54 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
wingman-ai | github_2023 | RussellCanfield | typescript | VSCodeAPIWrapper.setState | public setState<T extends unknown | undefined>(newState: T): T {
if (this.vsCodeApi) {
return this.vsCodeApi.setState(newState);
} else {
localStorage.setItem("vscodeState", JSON.stringify(newState));
return newState;
}
} | /**
* Set the persistent state stored for this webview.
*
* @remarks When running webview source code inside a web browser, setState will set the given
* state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
*
* @param newState New persisted state. This must be a ... | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Config/utilities/vscode.ts#L67-L74 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
wingman-ai | github_2023 | RussellCanfield | typescript | VSCodeAPIWrapper.postMessage | public postMessage(message: unknown) {
if (this.vsCodeApi) {
this.vsCodeApi.postMessage(message);
} else {
console.log(message);
}
} | /**
* Post a message (i.e. send arbitrary data) to the owner of the webview.
*
* @remarks When running webview code inside a web browser, postMessage will instead
* log the given message to the console.
*
* @param message Abitrary data (must be JSON serializable) to send to the extension context.
*/ | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Diff/utilities/vscode.ts#L37-L43 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
wingman-ai | github_2023 | RussellCanfield | typescript | VSCodeAPIWrapper.getState | public getState(): unknown | undefined {
if (this.vsCodeApi) {
return this.vsCodeApi.getState();
} else {
const state = localStorage.getItem("vscodeState");
return state ? JSON.parse(state) : undefined;
}
} | /**
* Get the persistent state stored for this webview.
*
* @remarks When running webview source code inside a web browser, getState will retrieve state
* from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
*
* @return The current state or `undefined` if no state has b... | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Diff/utilities/vscode.ts#L53-L60 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
wingman-ai | github_2023 | RussellCanfield | typescript | VSCodeAPIWrapper.setState | public setState<T extends unknown | undefined>(newState: T): T {
if (this.vsCodeApi) {
return this.vsCodeApi.setState(newState);
} else {
localStorage.setItem("vscodeState", JSON.stringify(newState));
return newState;
}
} | /**
* Set the persistent state stored for this webview.
*
* @remarks When running webview source code inside a web browser, setState will set the given
* state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
*
* @param newState New persisted state. This must be a ... | https://github.com/RussellCanfield/wingman-ai/blob/7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6/views-ui/src/Diff/utilities/vscode.ts#L73-L80 | 7c8c4c83499eaaf9c403a5613dbeb41ffb536ff6 |
private-mirrors | github_2023 | github-community-projects | typescript | normalizeExpirationDate | const normalizeExpirationDate = (seconds: number) => {
return Date.now() + seconds * 1000
} | /**
* Converts seconds until expiration to date in milliseconds
* @param seconds Seconds until expiration to convert
* @returns number — Expiration date in milliseconds
*/ | https://github.com/github-community-projects/private-mirrors/blob/31ec702405e4e6afd34f7f68313492eb81367a31/src/app/api/auth/lib/nextauth-options.ts#L16-L18 | 31ec702405e4e6afd34f7f68313492eb81367a31 |
private-mirrors | github_2023 | github-community-projects | typescript | createBranchProtectionRuleset | const createBranchProtectionRuleset = async (
context: ContextEvent,
bypassActorId: string,
ruleName: string,
includeRefs: string[],
isMirror = false,
) => {
rulesLogger.info('Creating branch protection via rulesets', {
isMirror,
})
// Get the current branch protection rulesets
const getBranchPro... | /**
* Creates branch protections rulesets
* @param context The context object
* @param bypassActorId The actor node ID to bypass branch protections
* @param ruleName The name of the branch protection ruleset
* @param includeRefs The refs to include in the branch protection ruleset
*/ | https://github.com/github-community-projects/private-mirrors/blob/31ec702405e4e6afd34f7f68313492eb81367a31/src/bot/rules.ts#L150-L196 | 31ec702405e4e6afd34f7f68313492eb81367a31 |
private-mirrors | github_2023 | github-community-projects | typescript | createBranchProtection | const createBranchProtection = async (
context: ContextEvent,
repositoryNodeId: string,
pattern: string,
actorId: string,
isMirror = false,
) => {
rulesLogger.info('Creating branch protection via GQL', {
isMirror,
})
const query = isMirror ? mirrorBranchProtectionGQL : forkBranchProtectionGQL
co... | /**
* Fallback function to create branch protection if ruleset creation fails
* @param context The context object
* @param repositoryNodeId The repository global node ID
* @param pattern The branch pattern
* @param actorId The bypass actor ID
*/ | https://github.com/github-community-projects/private-mirrors/blob/31ec702405e4e6afd34f7f68313492eb81367a31/src/bot/rules.ts#L205-L227 | 31ec702405e4e6afd34f7f68313492eb81367a31 |
private-mirrors | github_2023 | github-community-projects | typescript | createBranchProtectionREST | const createBranchProtectionREST = async (
context: ContextEvent,
pattern: string,
) => {
rulesLogger.info('Creating branch protection via REST')
const res = await context.octokit.repos.updateBranchProtection({
branch: pattern,
enforce_admins: true,
owner: context.payload.repository.owner.login,
... | /**
* The REST API fallback function to create branch protections in case GQL fails
* @param context The context object
* @param pattern The default branch pattern
*/ | https://github.com/github-community-projects/private-mirrors/blob/31ec702405e4e6afd34f7f68313492eb81367a31/src/bot/rules.ts#L234-L263 | 31ec702405e4e6afd34f7f68313492eb81367a31 |
private-mirrors | github_2023 | github-community-projects | typescript | stringify | const stringify = (obj: any) => {
try {
return JSON.stringify(obj)
} catch {
return safeStringify(obj)
}
} | // This is a workaround for the issue with JSON.stringify and circular references | https://github.com/github-community-projects/private-mirrors/blob/31ec702405e4e6afd34f7f68313492eb81367a31/src/utils/logger.ts#L7-L13 | 31ec702405e4e6afd34f7f68313492eb81367a31 |
private-mirrors | github_2023 | github-community-projects | typescript | getLoggerType | const getLoggerType = () => {
if (process.env.NODE_ENV === 'development') {
return 'pretty'
}
if (process.env.NODE_ENV === 'test' || process.env.TEST_LOGGING === '1') {
return 'pretty'
}
return 'json'
} | // If you need logs during tests you can set the env var TEST_LOGGING=true | https://github.com/github-community-projects/private-mirrors/blob/31ec702405e4e6afd34f7f68313492eb81367a31/src/utils/logger.ts#L16-L26 | 31ec702405e4e6afd34f7f68313492eb81367a31 |
stratus | github_2023 | cloudwalk | typescript | log | function log(event: any) {
let payloads = null;
let kind = "";
if (event.action == "sendRpcPayload") {
[kind, payloads] = ["REQ -> ", event.payload];
}
if (event.action == "receiveRpcResult") {
[kind, payloads] = ["RESP <- ", event.result];
}
if (!Array.isArray(payloads)) {
... | // Configure RPC logger if RPC_LOG env-var is configured. | https://github.com/cloudwalk/stratus/blob/e2e1043f0d25caf2ebc9b063d4568f99545278ba/e2e/test/helpers/rpc.ts#L83-L98 | e2e1043f0d25caf2ebc9b063d4568f99545278ba |
stratus | github_2023 | cloudwalk | typescript | addOpenListener | function addOpenListener(socket: WebSocket, subscription: string, params: any) {
socket.addEventListener("open", function () {
socket.send(JSON.stringify({ jsonrpc: "2.0", id: 0, method: "eth_subscribe", params: [subscription, params] }));
});
} | /// Add an "open" event listener to a WebSocket | https://github.com/cloudwalk/stratus/blob/e2e1043f0d25caf2ebc9b063d4568f99545278ba/e2e/test/helpers/rpc.ts#L298-L302 | e2e1043f0d25caf2ebc9b063d4568f99545278ba |
stratus | github_2023 | cloudwalk | typescript | addMessageListener | function addMessageListener(
socket: WebSocket,
messageToReturn: number,
callback: (messageEvent: { data: string }) => Promise<void>,
): Promise<any> {
return new Promise((resolve) => {
let messageCount = 0;
socket.addEventListener("message", async function (messageEvent: { data: string ... | /// Generalized function to add a "message" event listener to a WebSocket | https://github.com/cloudwalk/stratus/blob/e2e1043f0d25caf2ebc9b063d4568f99545278ba/e2e/test/helpers/rpc.ts#L305-L325 | e2e1043f0d25caf2ebc9b063d4568f99545278ba |
stratus | github_2023 | cloudwalk | typescript | asyncContractOperation | async function asyncContractOperation(contract: TestContractBalances, shouldMine: boolean = false) {
let nonce = await sendGetNonce(CHARLIE.address);
const contractOps = contract.connect(CHARLIE.signer());
if (shouldMine) {
const signedTx = await prepareSignedTx({
contract,
a... | /// Execute an async contract operation | https://github.com/cloudwalk/stratus/blob/e2e1043f0d25caf2ebc9b063d4568f99545278ba/e2e/test/helpers/rpc.ts#L328-L345 | e2e1043f0d25caf2ebc9b063d4568f99545278ba |
stratus | github_2023 | cloudwalk | typescript | normalizePollingOptions | function normalizePollingOptions(
options: {
timeoutInMs?: number;
pollingIntervalInMs?: number;
} = {},
): { timeoutInMs: number; pollingIntervalInMs: number } {
const timeoutInMs: number = options.timeoutInMs ? options.timeoutInMs : DEFAULT_TX_TIMEOUT_IN_MS;
const pollingIntervalInMs: ... | // Normalizes the options for poll functions | https://github.com/cloudwalk/stratus/blob/e2e1043f0d25caf2ebc9b063d4568f99545278ba/e2e/test/helpers/rpc.ts#L522-L534 | e2e1043f0d25caf2ebc9b063d4568f99545278ba |
action-table | github_2023 | colinaut | typescript | ActionTableFilterMenu.connectedCallback | public connectedCallback(): void {
const columnName = this.getAttribute("name");
// name is required
if (!columnName) return;
// If options are not specified then find them
if (this.hasAttribute("options")) {
this.options = this.getAttribute("options")?.split(",") || [];
} else {
this.findOptions(colu... | // Using connectedCallback because options may need to be rerendered when added to the DOM | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filter-menu.ts#L66-L77 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableFilterRange.constructor | constructor() {
super();
// this.shadow = this.attachShadow({ mode: "open" });
this.render();
this.addEventListeners();
} | // private shadow: ShadowRoot; | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filter-range.ts#L4-L9 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | setAttributes | function setAttributes(element: Element, attributes: Record<string, string>) {
for (const key in attributes) {
element.setAttribute(key, attributes[key]);
}
} | // Helper function | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filter-range.ts#L95-L99 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableFilters.connectedCallback | public connectedCallback(): void {
// Grab current filters from action-table
const filters: FiltersObject = this.actionTable.filters;
// 4.1 If filters are not empty, set the select/checkbox/radio elements
if (Object.keys(filters).length > 0) {
this.setFilterElements(filters);
}
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filters.ts#L16-L24 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableFilters.toggleHighlight | private toggleHighlight(el: HTMLInputElement | HTMLSelectElement): void {
if (el.value) {
el.classList.add("selected");
} else {
el.classList.remove("selected");
}
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filters.ts#L30-L36 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableFilters.addEventListeners | private addEventListeners(): void {
const hasAttr = (el: HTMLElement, attr: string) => {
return el.hasAttribute(attr) || !!el.closest(`[${attr}]`);
};
/* ------------ Event Listeners for select/checkbox/radio ------------ */
this.addEventListener("input", (e) => {
const el = e.target;
if (el instanceof... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filters.ts#L42-L136 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | debounce | function debounce<T extends (...args: any[]) => any>(func: T, timeout = 300) {
let timer: ReturnType<typeof setTimeout>;
return (...args: Parameters<T>) => {
clearTimeout(timer);
timer = setTimeout(() => {
func(...args);
}, timeout);
};
} | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filters.ts#L101-L109 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableFilters.resetAllFilterElements | public resetAllFilterElements() {
console.log("resetAllFilterElements");
// Casting to types as we know what it is from selector
const filterElements = this.querySelectorAll("select, input") as NodeListOf<HTMLSelectElement | HTMLInputElement>;
filterElements.forEach((el) => {
if (el instanceof HTMLInputEle... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filters.ts#L191-L215 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableFilters.setFilterElements | public setFilterElements(filters: FiltersObject) {
// 1. if there are filters then set the filters on all the elements
if (this.hasFilters(filters)) {
// enable reset button
this.enableReset();
// set filter elements
Object.keys(filters).forEach((key) => this.setFilterElement(key, filters[key].values));... | /* ------------------ If no args are passed then it resets ------------------ */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filters.ts#L222-L233 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableFilters.setSelectValueIgnoringCase | private setSelectValueIgnoringCase(selectElement: HTMLSelectElement, value: string) {
value = value.toLowerCase();
Array.from(selectElement.options).some((option) => {
const optionValue = option.value.toLowerCase() || option.text.toLowerCase();
if (optionValue === value) {
option.selected = true;
thi... | /**
* Sets the value of a select element, ignoring case, to match the provided value.
*
* @param {HTMLSelectElement} selectElement - The select element to set the value for.
* @param {string} value - The value to set, case insensitive.
*/ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-filters.ts#L243-L254 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | pageButton | function pageButton(i: number, className: string = "", text?: string): string {
return `<button type="button" class="${page === i ? `active ${className}` : `${className}`}" data-page="${i}" title="${className}">${text || i}</button>`;
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-pagination.ts#L46-L48 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableSwitch.checked | get checked(): boolean {
return this.hasAttribute("checked");
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-switch.ts#L17-L19 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableSwitch.addEventListeners | private addEventListeners() {
const input = this.querySelector("input");
if (input) {
input.addEventListener("change", () => {
this.checked = input.checked;
this.sendEvent();
});
}
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-switch.ts#L43-L51 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTableSwitch.sendEvent | private async sendEvent() {
const detail = { checked: this.checked, id: this.id || this.dataset.id, name: this.name, value: this.value };
this.dispatchEvent(new CustomEvent("action-table-switch", { detail, bubbles: true }));
} | /* ----------------- Send Event Triggered by checkbox change ---------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table-switch.ts#L59-L62 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | hasKeys | function hasKeys(obj: any): boolean {
return Object.keys(obj).length > 0;
} | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L5-L7 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.sort | get sort(): string {
return this.getCleanAttr("sort");
} | // sort attribute to set the sort column | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L78-L80 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.direction | get direction(): Direction {
const direction = this.getCleanAttr("direction");
return direction === "descending" ? direction : "ascending";
} | // direction attribute to set the sort direction | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L86-L89 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.store | get store(): string {
return this.hasAttribute("store") ? this.getCleanAttr("store") || "action-table" : "";
} | // store attribute to trigger loading and saving to sort and filters localStorage | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L95-L97 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.connectedCallback | public connectedCallback(): void {
/* -------------- Init code which requires DOM to be ready -------------- */
console.time("Connected Callback");
// 1. Get table, tbody, rows, and column names in this.cols
const table = this.querySelector("table");
// make sure table with thead and tbody exists
if (table... | /* ------------- Fires every time the event is added to the DOM ------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L142-L172 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.observedAttributes | static get observedAttributes(): string[] {
return ["sort", "direction", "pagination", "page"];
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L178-L180 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.setFiltersObject | private setFiltersObject(filters: FiltersObject = {}): void {
// If set empty it resets filters to default
this.filters = filters;
if (this.store) this.setStore({ filters: this.filters });
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L204-L210 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.setFilters | private setFilters(filters: FiltersObject = {}) {
this.setFiltersObject(filters);
this.filterTable();
this.appendRows();
} | /* ----------- Used by reset button and action-table-filter event ----------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L213-L217 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.addEventListeners | private addEventListeners(): void {
// Sort buttons
this.addEventListener(
"click",
(event) => {
const el = event.target;
// only fire if event target is a button with data-col
if (el instanceof HTMLButtonElement && el.dataset.col) {
const name = el.dataset.col;
let direction: Direction ... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L223-L290 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.getStore | private getStore() {
try {
const ls = localStorage.getItem(this.store);
const data = ls && JSON.parse(ls);
if (typeof data === "object" && data !== null) {
const hasKeys = ["sort", "direction", "filters"].some((key) => key in data);
if (hasKeys) return data as ActionTableStore;
}
return false;
... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L296-L308 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.setStore | private setStore(data: ActionTableStore) {
const lsData = this.getStore() || {};
if (lsData) {
data = { ...lsData, ...data };
}
localStorage.setItem(this.store, JSON.stringify(data));
} | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L314-L320 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.delayUntilNoLongerCalled | private delayUntilNoLongerCalled(callback: () => void) {
let timeoutId: number;
let isCalling = false;
function delayedCallback() {
// Execute the callback
callback();
// Reset the flag variable to false
isCalling = false;
}
return function () {
// If the function is already being called, cl... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L326-L350 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.getColumns | private getColumns(): void {
// console.time("getColumns");
// 1. Get column headers
// casting type as we know what it is from selector
const ths = this.table.querySelectorAll("thead th") as NodeListOf<HTMLTableCellElement>;
ths.forEach((th) => {
// 2. Column name is based on data-col attribute or result... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L376-L415 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.getCellContent | private getCellContent(cell: HTMLTableCellElement): string {
// 1. get cell content with innerText; set to empty string if null
let cellContent: string = (cell.textContent || "").trim();
// 3. if there is no cell content then check...
if (!cellContent) {
// 3.1 if there is an svg then get title; otherwise r... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L420-L444 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.getCellValues | public getCellValues(cell: HTMLTableCellElement): ActionTableCellData {
// 1. If data exists return it; else get it
if (this.tableContent.has(cell)) {
// console.log("getCellValues: Cached");
// @ts-expect-error has checks for data
return this.tableContent.get(cell);
} else {
const cellValues = this.s... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L450-L461 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.addObserver | private addObserver() {
// Good reference for MutationObserver: https://davidwalsh.name/mutationobserver-api
// 1. Create an observer instance
const observer = new MutationObserver((mutations) => {
// Make sure it only gets content once if there are several changes at the same time
// 1.1 sort through all m... | /* -------------------------------------------------------------------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L479-L515 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.filterTable | private filterTable(): void {
console.log("filterTable", this.filters);
// eslint-disable-next-line no-console
// console.time("filterTable");
// 1. Save current state of numberOfPages
const currentNumberOfPages = this.numberOfPages;
const currentRowsVisible = this.rowsSet.size;
// 2. get filter value ... | /* ------------- Also triggered by local storage and URL params ------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L523-L587 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.sortTable | private sortTable(columnName = this.sort, direction = this.direction) {
if (!this.sort || !direction) return;
// eslint-disable-next-line no-console
// console.time("sortTable");
columnName = columnName.toLowerCase();
// 1. Get column index from column name
const columnIndex = this.cols.findIndex((col) => c... | /* ------------- Also triggered by local storage and URL params ------------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L627-L683 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | checkSortOrder | const checkSortOrder = (value: string) => {
return sortOrder?.includes(value) ? sortOrder.indexOf(value).toString() : value;
}; | // helper function to return sort order index for row sort | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L642-L644 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.alphaNumSort | public alphaNumSort(a: string, b: string): number {
function isNumberOrDate(value: string): number | void {
if (!isNaN(Number(value))) {
return Number(value);
} else if (!isNaN(Date.parse(value))) {
return Date.parse(value);
}
}
const aSort = isNumberOrDate(a);
const bSort = isNumberOrDate(b);... | // Also used by action-table-filter-menu.js when building options menu | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L688-L704 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | ActionTable.appendRows | private appendRows(): void {
console.time("appendRows");
// Helper function for hiding rows based on pagination
const isActivePage = (i: number): boolean => {
// returns if pagination is enabled (> 0) and row is on current page.
// For instance if the current page is 2 and pagination is 10 then is greater ... | /* --------- Sets row visibility based on sort,filter and pagination -------- */ | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L711-L760 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
action-table | github_2023 | colinaut | typescript | isActivePage | const isActivePage = (i: number): boolean => {
// returns if pagination is enabled (> 0) and row is on current page.
// For instance if the current page is 2 and pagination is 10 then is greater than 10 and less than or equal to 20
const { pagination, page } = this;
return pagination === 0 || (i >= paginati... | // Helper function for hiding rows based on pagination | https://github.com/colinaut/action-table/blob/302c5f1f00aa26bc2b3e2f1a34f996711900dd7a/src/action-table.ts#L715-L720 | 302c5f1f00aa26bc2b3e2f1a34f996711900dd7a |
Journey.js | github_2023 | williamtroup | typescript | setupDefaultGroup | function setupDefaultGroup( groups: any = null ) : void {
_groups = Default.getObject( groups, {} as Groups );
_groups[ Constant.DEFAULT_GROUP ] = {
json: {} as BindingOptions,
keys: [],
position: 0
};
} | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Groups
* --------------------------------------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L89-L97 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
Journey.js | github_2023 | williamtroup | typescript | renderDialog | function renderDialog() : void {
_element_Dialog = DomElement.create( "div", "journey-js-dialog" );
_element_Dialog.style.display = "none";
document.body.appendChild( _element_Dialog );
_element_Dialog_Close_Button = DomElement.create( "button", "close" );
_element_Dialog_Close_... | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Render: Dialog
* -----------------------------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L124-L176 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
Journey.js | github_2023 | williamtroup | typescript | makeDialogMovable | function makeDialogMovable() : void {
_element_Dialog_Title.onmousedown = onMoveTitleBarMouseDown;
_element_Dialog_Title.onmouseup = onMoveTitleBarMouseUp;
_element_Dialog_Title.oncontextmenu = onMoveTitleBarMouseUp;
document.body.addEventListener( "mousemove", onMoveDocumentMouseMove )... | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Render: Dialog - Move
* ----------------------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L456-L463 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
Journey.js | github_2023 | williamtroup | typescript | getElements | function getElements() : void {
const tagTypes: string[] = _configuration.domElementTypes as string[];
const tagTypesLength: number = tagTypes.length;
for ( let tagTypeIndex: number = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++ ) {
const domElements: HTMLCollectionOf<Element> =... | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Rendering
* -----------------------------------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L511-L528 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
Journey.js | github_2023 | williamtroup | typescript | buildDocumentEvents | function buildDocumentEvents( addEvents: boolean = true ) : void {
const documentFunc: Function = addEvents ? document.addEventListener : document.removeEventListener;
const windowFunc: Function = addEvents ? window.addEventListener : window.removeEventListener;
if ( _configuration.shortcutKeys... | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Document Events
* -----------------------------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L616-L625 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
Journey.js | github_2023 | williamtroup | typescript | getBrowserUrlParameters | function getBrowserUrlParameters() : boolean {
let show: boolean = false;
if ( _configuration.browserUrlParametersEnabled ) {
const url: string = window.location.href;
const urlArguments: any = getBrowserUrlArguments( url );
if ( Is.defined( urlArguments.sjOrderId )... | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Browser URL Parameters
* ----------------------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L689-L710 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
Journey.js | github_2023 | williamtroup | typescript | getObjectFromString | function getObjectFromString( objectString: any ) : StringToJson {
const result: StringToJson = {
parsed: true,
object: null
} as StringToJson;
try {
if ( Is.definedString( objectString ) ) {
result.object = JSON.parse( objectString );
... | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Default Parameter/Option Handling
* -----------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L737-L767 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
Journey.js | github_2023 | williamtroup | typescript | resetDialogPosition | function resetDialogPosition() : void {
if ( _public.isOpen() ) {
onDialogClose( false );
_groups[ _groups_Current ].position = 0;
}
} | /*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Public API Functions: Helpers: Managing Steps
* ------------------------------------------------------------------------------------... | https://github.com/williamtroup/Journey.js/blob/d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432/src/journey.ts#L776-L782 | d7a2f953051baa3e0bfcfd3bedbb3bbe92c3d432 |
vite-plugin-stylex | github_2023 | HorusGoul | typescript | getAbsolutePath | function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")));
} | /**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/ | https://github.com/HorusGoul/vite-plugin-stylex/blob/b6a179cf370dc8a1a60cadde383d8cba5ba8c67f/apps/storybook-demo/.storybook/main.ts#L9-L11 | b6a179cf370dc8a1a60cadde383d8cba5ba8c67f |
ts-regex-builder | github_2023 | callstack | typescript | isAtomicPattern | function isAtomicPattern(pattern: string): boolean {
// Simple char, char class [...] or group (...)
return pattern.length === 1 || /^\[[^[\]]*\]$/.test(pattern) || /^\([^()]*\)$/.test(pattern);
} | // This is intended to catch only some popular atomic patterns like char classes and groups. | https://github.com/callstack/ts-regex-builder/blob/8918ec1d6dd812d30c620617ceaf675ebc4bcf1b/src/encoder.ts#L70-L73 | 8918ec1d6dd812d30c620617ceaf675ebc4bcf1b |
ts-regex-builder | github_2023 | callstack | typescript | escapeText | function escapeText(text: string) {
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
} | // Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping | https://github.com/callstack/ts-regex-builder/blob/8918ec1d6dd812d30c620617ceaf675ebc4bcf1b/src/encoder.ts#L76-L78 | 8918ec1d6dd812d30c620617ceaf675ebc4bcf1b |
ts-regex-builder | github_2023 | callstack | typescript | escapeChar | function escapeChar(text: string): string {
// anyOf(']-\\^')
return text.replace(/[\]\-\\^]/g, '\\$&'); // "$&" is whole matched string
} | /** Escape chars for usage inside char class */ | https://github.com/callstack/ts-regex-builder/blob/8918ec1d6dd812d30c620617ceaf675ebc4bcf1b/src/constructs/char-class.ts#L74-L77 | 8918ec1d6dd812d30c620617ceaf675ebc4bcf1b |
cloudfront-hosting-toolkit | github_2023 | awslabs | typescript | checkWWW | function checkWWW(domainName: string): boolean {
const regex = /^www\./;
return regex.test(domainName);
} | /**
* Checks if the given domain name starts with "www.".
* @param domainName The domain name to check.
* @returns A boolean value indicating whether the domainName starts with "www." (true) or not (false).
*/ | https://github.com/awslabs/cloudfront-hosting-toolkit/blob/199ce3142ba9f9c28f2849b78df387c8e59a26ec/bin/cli/utils/helper.ts#L645-L648 | 199ce3142ba9f9c28f2849b78df387c8e59a26ec |
cloudfront-hosting-toolkit | github_2023 | awslabs | typescript | DeployType.constructor | constructor(
scope: Construct,
id: string,
hostingConfiguration: HostingConfiguration
) {
//export function geteDeployIdentifier(stackConfig: IConfiguration) {
super(scope, id);
if (isRepoConfig(hostingConfiguration)) {
const repoUrl = hostingConfiguration.repoUrl;
const parsedUrl... | /**
* Constructs a deployment stack based on the provided configuration.
* Handles Git repository and S3 bucket deployment scenarios, setting up
* deployment identifiers and CloudFormation outputs accordingly.
* In case of incorrect configuration, logs an error and exits the process.
*
* @param stackC... | https://github.com/awslabs/cloudfront-hosting-toolkit/blob/199ce3142ba9f9c28f2849b78df387c8e59a26ec/lib/deploy_type.ts#L31-L61 | 199ce3142ba9f9c28f2849b78df387c8e59a26ec |
cloudfront-hosting-toolkit | github_2023 | awslabs | typescript | pointsToFile | function pointsToFile(uri: string) {
return /\/[^/]+\.[^/]+$/.test(uri);
} | // URL rewriting rules | https://github.com/awslabs/cloudfront-hosting-toolkit/blob/199ce3142ba9f9c28f2849b78df387c8e59a26ec/test/uri_rewrite.test.ts#L5-L7 | 199ce3142ba9f9c28f2849b78df387c8e59a26ec |
cloudfront-hosting-toolkit | github_2023 | awslabs | typescript | updateURI | function updateURI(uri: string) {
// Check for trailing slash and apply rule.
if (uri.endsWith("/") && rulePatterns["/$"]) {
return "/" + pathToAdd + uri.slice(0, -1) + rulePatterns["/$"];
}
// Check if URI doesn't point to a specific file.
if (!pointsToFile(uri)) {
// If URI doesn't ha... | // Function to determine rule and update the URI | https://github.com/awslabs/cloudfront-hosting-toolkit/blob/199ce3142ba9f9c28f2849b78df387c8e59a26ec/test/uri_rewrite.test.ts#L17-L39 | 199ce3142ba9f9c28f2849b78df387c8e59a26ec |
cloudfront-hosting-toolkit | github_2023 | awslabs | typescript | updateURI | function updateURI(uri: string) {
// Check for trailing slash and apply rule.
if (!pointsToFile(uri)) {
return `/${pathToAdd}/index.html`;
}
return `/${pathToAdd}${uri}`;
} | // Function to determine rule and update the URI | https://github.com/awslabs/cloudfront-hosting-toolkit/blob/199ce3142ba9f9c28f2849b78df387c8e59a26ec/test/uri_rewrite.test.ts#L78-L85 | 199ce3142ba9f9c28f2849b78df387c8e59a26ec |
nuxt-tiptap-editor | github_2023 | modbender | typescript | ImageUploaderPlugin.newUploadingImageNode | public newUploadingImageNode(attrs: any): Node {
// const empty_baseb4 = "data:image/svg+xml,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'/%3E\n";
const uploadId = this.config.id()
fileCache[uploadId] = attrs.src || attrs['data-src']
return this.view.state.schema.nodes.imagePlaceholde... | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/modbender/nuxt-tiptap-editor/blob/6e10b3c56e89ac672c7e5528bfdb716b79a94933/src/runtime/custom-extensions/extension-image-upload/imageUploader.ts#L185-L194 | 6e10b3c56e89ac672c7e5528bfdb716b79a94933 |
drag-and-drop | github_2023 | formkit | typescript | checkTouchSupport | function checkTouchSupport() {
if (!isBrowser) return false;
return "ontouchstart" in window || navigator.maxTouchPoints > 0;
} | /**
* Function to check if touch support is enabled.
*
* @returns {boolean}
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L78-L82 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleRootPointerdown | function handleRootPointerdown(_e: PointerEvent) {
if (state.activeState) setActive(state.activeState.parent, undefined, state);
if (state.selectedState)
deselect(state.selectedState.nodes, state.selectedState.parent, state);
state.selectedState = state.activeState = undefined;
} | /**
*
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L204-L211 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleRootKeydown | function handleRootKeydown(e: KeyboardEvent) {
if (e.key === "Escape") {
if (state.selectedState)
deselect(state.selectedState.nodes, state.selectedState.parent, state);
if (state.activeState)
setActive(state.activeState.parent, undefined, state);
state.selectedState = state.activeState = un... | /**
* Handles the keydown event on the root element.
*
* @param {KeyboardEvent} e - The keyboard event.
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L232-L242 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleRootDragover | function handleRootDragover(e: DragEvent) {
if (!isDragState(state)) return;
pd(e);
} | /**
* If we are currently dragging, then let's prevent default on dragover to avoid
* the default behavior of the browser on drop.
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L258-L262 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | setActive | function setActive<T>(
parent: ParentRecord<T>,
newActiveNode: NodeRecord<T> | undefined,
state: BaseDragState<T>
) {
const activeDescendantClass = parent.data.config.activeDescendantClass;
if (state.activeState) {
{
removeClass([state.activeState.node.el], activeDescendantClass);
if (state.... | /**
* This function sets the active node as well as removing any classes or
* attribute set.
*
* @param {ParentEventData} data - The parent event data.
* @param {NodeRecord} newActiveNode - The new active node.
* @param {BaseDragState} state - The current drag state.
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L559-L594 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | deselect | function deselect<T>(
nodes: Array<NodeRecord<T>>,
parent: ParentRecord<T>,
state: BaseDragState<T>
) {
const selectedClass = parent.data.config.selectedClass;
if (!state.selectedState) return;
const iterativeNodes = Array.from(nodes);
removeClass(
nodes.map((x) => x.el),
selectedClass
);
... | /**
* This function deselects the nodes. This will clean the prior selected state
* as well as removing any classes or attributes set.
*
* @param {Array<NodeRecord<T>>} nodes - The nodes to deselect.
* @param {ParentRecord<T>} parent - The parent record.
* @param {BaseDragState<T>} state - The current drag state.... | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L604-L631 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | setSelected | function setSelected<T>(
parent: ParentRecord<T>,
selectedNodes: Array<NodeRecord<T>>,
newActiveNode: NodeRecord<T> | undefined,
state: BaseDragState<T>,
pointerdown = false
) {
state.pointerSelection = pointerdown;
for (const node of selectedNodes) {
node.el.setAttribute("aria-selected", "true");
... | /**
* This function sets the selected nodes. This will clean the prior selected state
* as well as removing any classes or attributes set.
*
* @param {ParentRecord<T>} parent - The parent record.
* @param {Array<NodeRecord<T>>} selectedNodes - The nodes to select.
* @param {NodeRecord<T> | undefined} newActiveNod... | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L643-L685 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | updateLiveRegion | function updateLiveRegion<T>(parent: ParentRecord<T>, message: string) {
const liveRegion = document.querySelector('[data-dnd-live-region="true"]');
if (!liveRegion) return;
liveRegion.id = parent.el.id + "-live-region";
liveRegion.textContent = message;
} | /**
* Update the live region.
*
* @param {ParentRecord<T>} parent - The parent record.
* @param {string} message - The message to update the live region with.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L695-L703 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | clearLiveRegion | function clearLiveRegion<T>(parent: ParentRecord<T>) {
const liveRegion = document.getElementById(parent.el.id + "-live-region");
if (!liveRegion) return;
liveRegion.textContent = "";
} | /**
* Clear the live region.
*
* @param {ParentRecord<T>} parent - The parent record.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L712-L718 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | setup | function setup<T>(parent: HTMLElement, parentData: ParentData<T>): void {
parentData.abortControllers.mainParent = addEvents(parent, {
keydown: parentEventData(parentData.config.handleParentKeydown),
dragover: parentEventData(parentData.config.handleParentDragover),
handleParentPointerover: parentData.con... | /**
* Setup the parent.
*
* @param parent - The parent element.
* @param parentData - The parent data.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L977-L1057 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | reapplyDragClasses | function reapplyDragClasses<T>(node: Node, parentData: ParentData<T>) {
if (!isDragState(state)) return;
const dropZoneClass = isSynthDragState(state)
? parentData.config.synthDropZoneClass
: parentData.config.dropZoneClass;
if (state.draggedNode.el !== node) return;
addNodeClass([node], dropZoneClas... | /**
* Reapply the drag classes to the node.
*
* @param node - The node.
* @param parentData - The parent data.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L1139-L1149 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | nodesMutated | function nodesMutated(mutationList: MutationRecord[]) {
// TODO: This could be better, but using it as a way to ignore comments and text
if (
mutationList.length === 1 &&
mutationList[0].addedNodes.length === 1 &&
!(mutationList[0].addedNodes[0] instanceof HTMLElement)
)
return;
const parentEl ... | /**
* Called when the nodes of a given parent element are mutated.
*
* @param mutationList - The list of mutations.
*
* @returns void
*
* @internal
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L1191-L1221 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | draggedNodes | function draggedNodes<T>(pointerDown: {
parent: ParentRecord<T>;
node: NodeRecord<T>;
}): Array<NodeRecord<T>> {
if (!pointerDown.parent.data.config.multiDrag) {
return [pointerDown.node];
} else if (state.selectedState) {
return [
pointerDown.node,
...(state.selectedState?.nodes.filter(
... | /**
* Get the dragged nodes.
*
* @param pointerDown - The pointer down data.
*
* @returns The dragged nodes.
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L1421-L1437 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleParentScroll | function handleParentScroll<T>(_data: ParentEventData<T>) {
if (!isDragState(state)) return;
state.emit("scrollStarted", state);
if (isSynthDragState(state)) return;
state.preventEnter = true;
if (scrollTimeout) clearTimeout(scrollTimeout);
scrollTimeout = setTimeout(() => {
state.preventEnter = fa... | /**
* Handle the parent scroll.
*
* @param data - The parent event data.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L1446-L1462 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | initSynthDrag | function initSynthDrag<T>(
node: NodeRecord<T>,
parent: ParentRecord<T>,
e: PointerEvent,
_state: BaseDragState<T>,
draggedNodes: Array<NodeRecord<T>>
): SynthDragState<T> {
const config = parent.data.config;
let dragImage: HTMLElement | undefined;
let display = node.el.style.display;
let result = ... | /**
* Initialize the synth drag.
*
* @param node - The node.
* @param parent - The parent.
* @param e - The pointer event.
* @param _state - The drag state.
* @param draggedNodes - The dragged nodes.
*
* @returns The synth drag state.
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L2178-L2305 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleNodeDragenter | function handleNodeDragenter<T>(
data: NodeDragEventData<T>,
_state: DragState<T>
) {
pd(data.e);
} | /**
* Handle the node drag enter.
*
* @param data - The node drag event data.
* @param _state - The drag state.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L2571-L2576 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleNodeDragleave | function handleNodeDragleave<T>(
data: NodeDragEventData<T>,
_state: DragState<T>
) {
pd(data.e);
} | /**
* Handle the node drag leave.
*
* @param data - The node drag event data.
* @param _state - The drag state.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L2586-L2591 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | isScrollX | function isScrollX<T>(
el: HTMLElement,
e: PointerEvent,
style: CSSStyleDeclaration,
rect: DOMRect,
state: SynthDragState<T>
): { left: boolean; right: boolean } {
const threshold = 0.1;
if (el === document.scrollingElement) {
const canScrollLeft = el.scrollLeft > 0;
const canScrollRight =
... | /**
* Check if the element is scrollable on the x axis.
*
* @param el - The element.
* @param e - The event.
* @param style - The style.
* @param rect - The rect.
* @param state - The state.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L3023-L3064 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | isScrollY | function isScrollY(
el: HTMLElement,
e: PointerEvent,
style: CSSStyleDeclaration,
rect: DOMRect
): { up: boolean; down: boolean } {
const threshold = 0.1;
if (el === document.scrollingElement) {
return {
down: e.clientY > el.clientHeight * (1 - threshold),
up: e.clientY < el.clientHeight * ... | /**
* Check if the element is scrollable on the y axis.
*
* @param el - The element.
* @param e - The event.
* @param style - The style.
* @param rect - The rect.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L3076-L3112 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | scrollX | function scrollX<T>(
el: HTMLElement,
e: PointerEvent,
state: SynthDragState<T>,
right = true
) {
state.preventEnter = true;
const incr = right ? 5 : -5;
function scroll(el: HTMLElement) {
el.scrollBy({ left: incr });
moveNode(e, state, incr, 0);
state.animationFrameIdX = requestAnimationF... | /**
* Scroll the element on the x axis.
*
* @param el - The element.
* @param e - The event.
* @param state - The state.
* @param right - Whether to scroll right.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L3124-L3143 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | scrollY | function scrollY<T>(
el: Element,
e: PointerEvent,
state: SynthDragState<T>,
up = true
) {
state.preventEnter = true;
const incr = up ? -5 : 5;
function scroll() {
el.scrollBy({ top: incr });
moveNode(e, state, 0, incr);
state.animationFrameIdY = requestAnimationFrame(scroll);
}
state... | /**
* Scroll the element on the y axis.
*
* @param el - The element.
* @param e - The event.
* @param state - The state.
* @param up - Whether to scroll up.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L3155-L3174 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleSynthScroll | function handleSynthScroll<T>(
coordinates: { x: number; y: number },
e: PointerEvent,
state: SynthDragState<T>
) {
cancelSynthScroll(state);
const scrollables: Record<"x" | "y", HTMLElement | null> = {
x: null,
y: null,
};
const els = document.elementsFromPoint(coordinates.x, coordinates.y);
... | /**
* Handle the synth scroll.
*
* @param coordinates - The coordinates.
* @param e - The event.
* @param state - The state.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/index.ts#L3185-L3228 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | getValues | function getValues(parent: HTMLElement): Array<any> {
const values = parentValues.get(parent);
if (!values) {
console.warn("No values found for parent element");
return [];
}
return "value" in values ? values.value : values;
} | /**
* Returns the values of the parent element.
*
* @param parent - The parent element.
*
* @returns The values of the parent element.
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/vue/index.ts#L21-L31 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | setValues | function setValues(newValues: Array<any>, parent: HTMLElement): void {
const currentValues = parentValues.get(parent);
// Only update reactive values. If static, let's not update.
if (currentValues && "value" in currentValues)
currentValues.value = newValues;
//else if (currentValues) parentValues.set(pare... | /**
* Sets the values of the parent element.
*
* @param parent - The parent element.
*
* @param newValues - The new values for the parent element.
*
* @returns void
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/vue/index.ts#L42-L49 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
drag-and-drop | github_2023 | formkit | typescript | handleParent | function handleParent<T>(
config: Partial<VueParentConfig<T>>,
values: Ref<Array<T>> | Array<T>
) {
return (parent: HTMLElement) => {
parentValues.set(parent, values);
initParent({
parent,
getValues,
setValues,
config: {
...config,
},
});
};
} | /**
* Sets the HTMLElement parent to weakmap with provided values and calls
* initParent.
*
* @param config - The config of the parent.
*
* @param values - The values of the parent element.
*
*/ | https://github.com/formkit/drag-and-drop/blob/f987d198587ffa9b7b937fdc2375f88b4497a4dd/src/vue/index.ts#L111-L127 | f987d198587ffa9b7b937fdc2375f88b4497a4dd |
ai-group-tabs | github_2023 | MichaelYuhe | typescript | htmlToElement | const htmlToElement = <T extends ChildNode>(html: string) => {
const template = document.createElement("template");
html = html.trim(); // Never return a text node of whitespace as the result
template.innerHTML = html;
return template.content.firstChild as T;
}; | /**
* DO NOT USE FOR USER INPUT
*
* See https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
*/ | https://github.com/MichaelYuhe/ai-group-tabs/blob/36100d3f93028e72faa498b419be6ff226becd76/src/components/toast.ts#L9-L14 | 36100d3f93028e72faa498b419be6ff226becd76 |
gzm-design | github_2023 | LvHuaiSheng | typescript | config | const config=({mode})=>{
return{
plugins: [
vue(),
// 自动按需引入组件
AutoImport({
resolvers: [
ArcoResolver({
// importStyle: 'less',
}),
],
imports: ['vue', 'vue-rou... | // https://vitejs.dev/config/ | https://github.com/LvHuaiSheng/gzm-design/blob/6dc166eb6fd4b39cde64544180242ab2dce4ff4c/vite.config.ts#L10-L50 | 6dc166eb6fd4b39cde64544180242ab2dce4ff4c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.