Fix eslint issues

This commit is contained in:
Bill 2024-06-18 18:58:45 -04:00
parent df81cc7f92
commit 5bd351c3dc
570 changed files with 3584 additions and 3609 deletions

View File

@ -1,6 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
insert_final_newline = true
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

View File

@ -1,121 +0,0 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"react": {
"pragma": "React",
"version": "18.0.0"
}
},
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended"
],
"plugins": [
"@typescript-eslint",
"react"
],
"rules": {
"linebreak-style": [
"off"
],
"quotes": [
"error",
"single"
],
"@typescript-eslint/indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"array-bracket-spacing": [
"error",
"always"
],
"brace-style": [
"error",
"allman"
],
"template-curly-spacing": [
"error",
"always"
],
"no-multi-spaces": [
"error"
],
"@typescript-eslint/object-curly-spacing": [
"error",
"always",
{
"arraysInObjects": true,
"objectsInObjects": false
}
],
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"String": true,
"Boolean": true,
"Number": true,
"Symbol": true,
"{}": false,
"Object": false,
"object": false,
"Function": false
},
"extendDefaults": true
}
],
"no-switch-case-fall-through": [
"off"
],
"jsx-quotes": [
"error"
],
"react/prop-types": [
"off"
],
"react/jsx-curly-spacing": [
"error",
{
"when": "always",
"children": true
}
],
"react/jsx-equals-spacing": [
"error"
],
"react/jsx-newline": [
"error",
{
"prevent": true
}
],
"react/jsx-sort-props": [
"error",
{
"callbacksLast": true,
"shorthandFirst": true,
"shorthandLast": false,
"ignoreCase": true,
"noSortAlphabetically": false,
"reservedFirst": true
}
]
}
}

22
.vscode/settings.json vendored
View File

@ -6,7 +6,7 @@
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"editor.wordWrap": "on",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.eslint": "always",
"source.fixAll.sortJSON": "never",
"source.organizeImports": "always"
},
@ -17,10 +17,7 @@
"files.trimFinalNewlines": true,
"emmet.showExpandedAbbreviation": "never",
"eslint.format.enable": true,
"eslint.validate": [
"javascript",
"typescript"
],
"eslint.validate": ["javascript", "typescript"],
"eslint.workingDirectories": [
{
"pattern": "./src"
@ -34,18 +31,9 @@
"css": "css"
},
"tailwindCSS.experimental.classRegex": [
[
"classes \\=([^;]*);",
"'([^']*)'"
],
[
"classes \\=([^;]*);",
"\"([^\"]*)\""
],
[
"classes \\=([^;]*);",
"\\`([^\\`]*)\\`"
]
["classes \\=([^;]*);", "'([^']*)'"],
["classes \\=([^;]*);", "\"([^\"]*)\""],
["classes \\=([^;]*);", "\\`([^\\`]*)\\`"]
],
"editor.quickSuggestions": {
"strings": true

View File

@ -64,8 +64,6 @@ const generateShades = (colors) =>
}
}
console.log(colors)
return colors;
}

138
eslint.config.mjs Normal file
View File

@ -0,0 +1,138 @@
import typescriptEslintPlugin from "@typescript-eslint/eslint-plugin";
import typescriptEslintParser from "@typescript-eslint/parser";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default [
{
files: ["**/*.jsx", "**/*.js", "**/*.tsx", "**/*.ts"],
plugins: {
react: reactPlugin,
"react-hooks": reactHooksPlugin,
"@typescript-eslint": typescriptEslintPlugin,
},
languageOptions: {
parser: typescriptEslintParser,
ecmaVersion: "latest",
parserOptions: {
sourceType: "module",
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
ecmaFeatures: {
jsx: true,
},
},
},
rules: {
...reactPlugin.configs.recommended.rules,
...reactHooksPlugin.configs.recommended.rules,
...typescriptEslintPlugin.configs.recommended.rules,
...typescriptEslintPlugin.configs[
"recommended-requiring-type-checking"
].rules,
'indent': [
'error',
4,
{
'SwitchCase': 1
}
],
'no-multi-spaces': [
'error'
],
'no-trailing-spaces': [
'error',
{
'skipBlankLines': false,
'ignoreComments': true
}
],
'linebreak-style': [
'off'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
],
'brace-style': [
'error',
'allman'
],
'object-curly-spacing': [
'error',
'always'
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/explicit-module-boundary-types': [
'off',
{
'allowedNames': [
'getMessageArray'
]
}
],
'@typescript-eslint/unbound-method': [
'off'
],
'@typescript-eslint/ban-ts-comment': [
'off'
],
'@typescript-eslint/no-empty-function': [
'error',
{
'allow': [
'functions',
'arrowFunctions',
'generatorFunctions',
'methods',
'generatorMethods',
'constructors'
]
}
],
'@typescript-eslint/no-unused-vars': [
'off'
],
'@typescript-eslint/ban-types': [
'error',
{
'types':
{
'String': true,
'Boolean': true,
'Number': true,
'Symbol': true,
'{}': false,
'Object': false,
'object': false,
'Function': false
},
'extendDefaults': true
}
],
'react/react-in-jsx-scope': 'off'
},
settings: {
react: {
version: "18.3.1",
},
},
},
];

View File

@ -1,50 +1,47 @@
{
"name": "nitro-react",
"version": "2.2",
"homepage": ".",
"private": true,
"scripts": {
"start": "vite",
"build": "vite build",
"build:prod": "npx browserslist@latest --update-db && yarn build",
"eslint": "eslint src --ext .ts,.tsx"
},
"dependencies": {
"@tanstack/react-virtual": "3.2.0",
"@types/react-transition-group": "^4.4.10",
"dompurify": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
"react-slider": "^2.0.6",
"react-tiny-popover": "^8.0.4",
"react-transition-group": "^4.4.5",
"react-youtube": "^7.13.1",
"use-between": "^1.3.5"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.7",
"@types/node": "^20.11.30",
"@types/react": "^18.2.67",
"@types/react-dom": "^18.2.22",
"@types/react-slider": "^1.3.6",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss": "^8.4.38",
"postcss-nested": "^6.0.1",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.13",
"sass": "^1.72.0",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.2",
"vite": "^5.1.6",
"vite-tsconfig-paths": "^4.3.2"
}
"name": "nitro-react",
"version": "2.2",
"homepage": ".",
"private": true,
"scripts": {
"start": "vite",
"build": "vite build",
"build:prod": "npx browserslist@latest --update-db && yarn build",
"eslint": "eslint ./src"
},
"dependencies": {
"@tanstack/react-virtual": "3.2.0",
"@types/react-transition-group": "^4.4.10",
"dompurify": "^3.1.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"react-slider": "^2.0.6",
"react-tiny-popover": "^8.0.4",
"react-transition-group": "^4.4.5",
"react-youtube": "^7.13.1",
"use-between": "^1.3.5"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.7",
"@types/node": "^20.11.30",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-slider": "^1.3.6",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.19",
"eslint": "^9.5.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^5.1.0-rc-1434af3d22-20240618",
"postcss": "^8.4.38",
"postcss-nested": "^6.0.1",
"sass": "^1.77.4",
"tailwindcss": "^3.4.4",
"typescript": "^5.4.5",
"typescript-eslint": "^7.13.1",
"vite": "^5.2.13",
"vite-tsconfig-paths": "^4.3.2"
}
}

View File

@ -1,7 +0,0 @@
/** @type {import("prettier").Config} */
module.exports = {
plugins: [
'prettier-plugin-tailwindcss'
]
}

View File

@ -1,4 +1,25 @@
import { GetAssetManager, GetAvatarRenderManager, GetCommunication, GetConfiguration, GetLocalizationManager, GetRoomCameraWidgetManager, GetRoomEngine, GetRoomSessionManager, GetSessionDataManager, GetSoundManager, GetStage, GetTexturePool, GetTicker, HabboWebTools, LegacyExternalInterface, LoadGameUrlEvent, NitroLogger, NitroVersion, PrepareRenderer } from '@nitrots/nitro-renderer';
import
{
GetAssetManager,
GetAvatarRenderManager,
GetCommunication,
GetConfiguration,
GetLocalizationManager,
GetRoomCameraWidgetManager,
GetRoomEngine,
GetRoomSessionManager,
GetSessionDataManager,
GetSoundManager,
GetStage,
GetTexturePool,
GetTicker,
HabboWebTools,
LegacyExternalInterface,
LoadGameUrlEvent,
NitroLogger,
NitroVersion,
PrepareRenderer,
} from '@nitrots/nitro-renderer';
import { FC, useEffect, useState } from 'react';
import { GetUIVersion } from './api';
import { MainView } from './components/MainView';
@ -8,15 +29,15 @@ import { classNames } from './layout';
NitroVersion.UI_VERSION = GetUIVersion();
export const App: FC<{}> = props =>
export const App: FC<{}> = (props) =>
{
const [ isReady, setIsReady ] = useState(false);
const [isReady, setIsReady] = useState(false);
useMessageEvent<LoadGameUrlEvent>(LoadGameUrlEvent, event =>
useMessageEvent<LoadGameUrlEvent>(LoadGameUrlEvent, (event) =>
{
const parser = event.getParser();
if (!parser) return;
if(!parser) return;
LegacyExternalInterface.callGame('showGame', parser.url);
});
@ -27,78 +48,108 @@ export const App: FC<{}> = props =>
{
try
{
if (!window.NitroConfig) throw new Error('NitroConfig is not defined!');
if(!window.NitroConfig)
throw new Error('NitroConfig is not defined!');
const renderer = await PrepareRenderer({
width,
height,
resolution: window.devicePixelRatio,
autoDensity: true,
backgroundAlpha: 0,
preference: 'webgl',
eventMode: 'none',
failIfMajorPerformanceCaveat: false
failIfMajorPerformanceCaveat: false,
});
await GetConfiguration().init();
GetTicker().maxFPS = GetConfiguration().getValue<number>('system.fps.max', 24);
NitroLogger.LOG_DEBUG = GetConfiguration().getValue<boolean>('system.log.debug', true);
NitroLogger.LOG_WARN = GetConfiguration().getValue<boolean>('system.log.warn', false);
NitroLogger.LOG_ERROR = GetConfiguration().getValue<boolean>('system.log.error', false);
NitroLogger.LOG_EVENTS = GetConfiguration().getValue<boolean>('system.log.events', false);
NitroLogger.LOG_PACKETS = GetConfiguration().getValue<boolean>('system.log.packets', false);
const assetUrls = GetConfiguration().getValue<string[]>('preload.assets.urls').map(url => GetConfiguration().interpolate(url)) ?? [];
await Promise.all(
[
GetRoomCameraWidgetManager().init(),
GetAssetManager().downloadAssets(assetUrls),
GetLocalizationManager().init(),
GetAvatarRenderManager().init(),
GetSoundManager().init(),
GetSessionDataManager().init(),
GetRoomSessionManager().init(),
GetCommunication().init(),
]
GetTicker().maxFPS = GetConfiguration().getValue<number>(
'system.fps.max',
24,
);
NitroLogger.LOG_DEBUG = GetConfiguration().getValue<boolean>(
'system.log.debug',
true,
);
NitroLogger.LOG_WARN = GetConfiguration().getValue<boolean>(
'system.log.warn',
false,
);
NitroLogger.LOG_ERROR = GetConfiguration().getValue<boolean>(
'system.log.error',
false,
);
NitroLogger.LOG_EVENTS = GetConfiguration().getValue<boolean>(
'system.log.events',
false,
);
NitroLogger.LOG_PACKETS = GetConfiguration().getValue<boolean>(
'system.log.packets',
false,
);
const assetUrls =
GetConfiguration()
.getValue<string[]>('preload.assets.urls')
.map((url) => GetConfiguration().interpolate(url)) ??
[];
await Promise.all([
GetRoomCameraWidgetManager().init(),
GetAssetManager().downloadAssets(assetUrls),
GetLocalizationManager().init(),
GetAvatarRenderManager().init(),
GetSoundManager().init(),
GetSessionDataManager().init(),
GetRoomSessionManager().init(),
GetCommunication().init(),
]);
await GetRoomEngine().init();
// new GameMessageHandler();
if (LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'authentication', 'authok', []);
if(LegacyExternalInterface.available)
LegacyExternalInterface.call(
'legacyTrack',
'authentication',
'authok',
[],
);
HabboWebTools.sendHeartBeat();
setInterval(() => HabboWebTools.sendHeartBeat(), 10000);
GetTicker().add(ticker => GetRoomEngine().update(ticker));
GetTicker().add(ticker => renderer.render(GetStage()));
GetTicker().add(ticker => GetTexturePool().run());
GetTicker().add((ticker) => GetRoomEngine().update(ticker));
GetTicker().add((ticker) => renderer.render(GetStage()));
GetTicker().add((ticker) => GetTexturePool().run());
setIsReady(true);
// handle socket close
//canvas.addEventListener('webglcontextlost', () => instance.events.dispatchEvent(new NitroEvent(Nitro.WEBGL_CONTEXT_LOST)));
}
catch (err)
{
NitroLogger.error(err);
}
}
};
prepare(window.innerWidth, window.innerHeight);
}, []);
return (
<div className={ classNames('w-full h-full overflow-hidden text-base', !(window.devicePixelRatio % 1) && '[image-rendering:pixelated]') }>
{ !isReady &&
<LoadingView /> }
{ isReady && <MainView /> }
<div
className={classNames(
'w-full h-full overflow-hidden text-base',
!(window.devicePixelRatio % 1) && '[image-rendering:pixelated]',
)}
>
{!isReady && <LoadingView />}
{isReady && <MainView />}
<div id="draggable-windows-container" />
</div>
);
}
};

View File

@ -7,91 +7,91 @@ export class AchievementUtilities
public static getAchievementBadgeCode(achievement: AchievementData): string
{
if(!achievement) return null;
let badgeId = achievement.badgeId;
if(!achievement.finalLevel) badgeId = GetLocalizationManager().getPreviousLevelBadgeId(badgeId);
return badgeId;
}
public static getAchievementCategoryImageUrl(category: IAchievementCategory, progress: number = null, icon: boolean = false): string
{
const imageUrl = GetConfigurationValue<string>('achievements.images.url');
let imageName = icon ? 'achicon_' : 'achcategory_';
imageName += category.code;
if(progress !== null) imageName += `_${ ((progress > 0) ? 'active' : 'inactive') }`;
return imageUrl.replace('%image%', imageName);
}
public static getAchievementCategoryMaxProgress(category: IAchievementCategory): number
{
if(!category) return 0;
let progress = 0;
for(const achievement of category.achievements)
{
progress += achievement.levelCount;
}
return progress;
}
public static getAchievementCategoryProgress(category: IAchievementCategory): number
{
if(!category) return 0;
let progress = 0;
for(const achievement of category.achievements) progress += (achievement.finalLevel ? achievement.level : (achievement.level - 1));
return progress;
}
public static getAchievementCategoryTotalUnseen(category: IAchievementCategory): number
{
if(!category) return 0;
let unseen = 0;
for(const achievement of category.achievements) ((achievement.unseen > 0) && unseen++);
return unseen;
}
public static getAchievementHasStarted(achievement: AchievementData): boolean
{
if(!achievement) return false;
if(achievement.finalLevel || ((achievement.level - 1) > 0)) return true;
return false;
}
public static getAchievementIsIgnored(achievement: AchievementData): boolean
{
if(!achievement) return false;
const ignored = GetConfigurationValue<string[]>('achievements.unseen.ignored');
const value = achievement.badgeId.replace(/[0-9]/g, '');
const index = ignored.indexOf(value);
if(index >= 0) return true;
return false;
}
public static getAchievementLevel(achievement: AchievementData): number
{
if(!achievement) return 0;
if(achievement.finalLevel) return achievement.level;
return (achievement.level - 1);
}
}

View File

@ -14,4 +14,4 @@ export const AvatarEditorColorSorter = (a: IPartColor, b: IPartColor) =>
if(a.index > b.index) return 1;
return 0;
}
};

View File

@ -31,5 +31,5 @@ export const AvatarEditorPartSorter = (hcFirst: boolean) =>
if(a.partSet.id > b.partSet.id) return 1;
return 0;
}
}
};
};

View File

@ -108,7 +108,7 @@ export class AvatarEditorThumbnailsHelper
}
return container;
}
};
return new Promise(async (resolve, reject) =>
{
@ -120,7 +120,7 @@ export class AvatarEditorThumbnailsHelper
AvatarEditorThumbnailsHelper.THUMBNAIL_CACHE.set(thumbnailKey, imageUrl);
resolve(imageUrl);
}
};
const figureContainer = GetAvatarRenderManager().createFigureContainer(`${ setType }-${ part.partSet.id }`);
@ -168,11 +168,11 @@ export class AvatarEditorThumbnailsHelper
sprite.destroy();
avatarImage.dispose();
AvatarEditorThumbnailsHelper.THUMBNAIL_CACHE.set(thumbnailKey, imageUrl);
resolve(imageUrl);
}
};
resetFigure(figureString);
});

View File

@ -4,6 +4,6 @@ export class CameraPicture
{
constructor(
public texture: NitroTexture,
public imageUrl: string)
public imageUrl: string)
{}
}

View File

@ -2,6 +2,6 @@ export class CameraPictureThumbnail
{
constructor(
public effectName: string,
public thumbnailUrl: string)
public thumbnailUrl: string)
{}
}

View File

@ -1,7 +1,7 @@
import { NodeData } from '@nitrots/nitro-renderer';
import { ICatalogNode } from './ICatalogNode';
export class CatalogNode implements ICatalogNode
export class CatalogNode implements ICatalogNode
{
private _depth: number = 0;
private _localization: string = '';

View File

@ -1,4 +1,4 @@
export class CatalogPageName
export class CatalogPageName
{
public static DUCKET_INFO: string = 'ducket_info';
public static CREDITS: string = 'credits';

View File

@ -5,6 +5,6 @@ export class CatalogPetPalette
constructor(
public readonly breed: string,
public readonly palettes: SellablePetPaletteData[]
)
)
{}
}

View File

@ -4,12 +4,12 @@ import { ICatalogNode } from './ICatalogNode';
export const GetPixelEffectIcon = (id: number) =>
{
return '';
}
};
export const GetSubscriptionProductIcon = (id: number) =>
{
return '';
}
};
export const GetOfferNodes = (offerNodes: Map<number, ICatalogNode[]>, offerId: number) =>
{
@ -21,20 +21,20 @@ export const GetOfferNodes = (offerNodes: Map<number, ICatalogNode[]>, offerId:
for(const node of nodes)
{
if(!node.isVisible) continue;
allowedNodes.push(node);
}
}
return allowedNodes;
}
};
export const FilterCatalogNode = (search: string, furniLines: string[], node: ICatalogNode, nodes: ICatalogNode[]) =>
{
if(node.isVisible && (node.pageId > 0))
{
let nodeAdded = false;
const hayStack = [ node.pageName, node.localization ].join(' ').toLowerCase().replace(/ /gi, '');
if(hayStack.indexOf(search) > -1)
@ -59,7 +59,7 @@ export const FilterCatalogNode = (search: string, furniLines: string[], node: IC
}
for(const child of node.children) FilterCatalogNode(search, furniLines, child, nodes);
}
};
export function GetPetIndexFromLocalization(localization: string)
{

View File

@ -16,4 +16,4 @@ export const GetImageIconUrlForProduct = (productType: string, productClassId: n
}
return imageUrl;
}
};

View File

@ -1,4 +1,4 @@
export interface ICatalogNode
export interface ICatalogNode
{
activate(): void;
deactivate(): void;

View File

@ -1,4 +1,4 @@
export class MarketPlaceOfferState
export class MarketPlaceOfferState
{
public static readonly ONGOING = 1;
public static readonly ONGOING_OWN = 1;

View File

@ -60,7 +60,7 @@ export class Offer implements IPurchasableOffer
public activate(): void
{
}
public get clubLevel(): number
@ -228,7 +228,7 @@ export class Offer implements IPurchasableOffer
{
const products: IProduct[] = [];
const productData = GetProductDataForLocalization(this.localizationId);
for(const product of this._products)
{
const furnitureData = GetFurnitureData(product.productClassId, product.productType);

View File

@ -4,7 +4,7 @@ import { IPageLocalization } from './IPageLocalization';
export class PageLocalization implements IPageLocalization
{
private _images: string[];
private _texts: string[]
private _texts: string[];
constructor(images: string[], texts: string[])
{

View File

@ -11,7 +11,7 @@ export class PlacedObjectPurchaseData
public readonly x: number,
public readonly y: number,
public readonly direction: number,
public readonly offer: IPurchasableOffer)
public readonly offer: IPurchasableOffer)
{}
public get offerId(): number

View File

@ -1,4 +1,4 @@
export class RequestedPage
export class RequestedPage
{
public static REQUEST_TYPE_NONE: number = 0;
public static REQUEST_TYPE_ID: number = 1;

View File

@ -6,6 +6,6 @@ export class SearchResult
constructor(
public readonly searchValue: string,
public readonly offers: IPurchasableOffer[],
public readonly filteredNodes: ICatalogNode[])
public readonly filteredNodes: ICatalogNode[])
{}
}

View File

@ -3,4 +3,4 @@ export const ChatHistoryCurrentDate = () =>
const currentTime = new Date();
return `${ currentTime.getHours().toString().padStart(2, '0') }:${ currentTime.getMinutes().toString().padStart(2, '0') }`;
}
};

View File

@ -1,6 +1,6 @@
export const MessengerHistoryCurrentDate = (secondsSinceNow: number = 0) =>
{
const currentTime = secondsSinceNow ? new Date(Date.now() - secondsSinceNow * 1000) : new Date();
return `${ currentTime.getHours().toString().padStart(2, '0') }:${ currentTime.getMinutes().toString().padStart(2, '0') }`;
}
};

View File

@ -3,11 +3,11 @@ import { IGroupChatData } from './IGroupChatData';
export const GetGroupChatData = (extraData: string) =>
{
if(!extraData || !extraData.length) return null;
const splitData = extraData.split('/');
const username = splitData[0];
const figure = splitData[1];
const userId = parseInt(splitData[2]);
return ({ username: username, figure: figure, userId: userId } as IGroupChatData);
}
};

View File

@ -6,6 +6,6 @@ export class MessengerSettings
public userFriendLimit: number = 0,
public normalFriendLimit: number = 0,
public extendedFriendLimit: number = 0,
public categories: FriendCategoryData[] = [])
public categories: FriendCategoryData[] = [])
{}
}

View File

@ -40,7 +40,7 @@ export class MessengerThread
group.addChat(chat);
this._lastUpdated = new Date();
this._unreadCount++;
return chat;

View File

@ -19,7 +19,7 @@ export class GroupBadgePart
public get code(): string
{
if((this.key === 0) && (this.type !== GroupBadgePart.BASE)) return null;
return GroupBadgePart.getCode(this.type, this.key, this.color, this.position);
}

View File

@ -1,4 +1,4 @@
export class GroupType
export class GroupType
{
public static REGULAR: number = 0;
public static EXCLUSIVE: number = 1;

View File

@ -4,4 +4,4 @@ import { SendMessageComposer } from '../nitro';
export const ToggleFavoriteGroup = (group: HabboGroupEntryData) =>
{
SendMessageComposer(group.favourite ? new GroupUnfavoriteComposer(group.groupId) : new GroupFavoriteComposer(group.groupId));
}
};

View File

@ -2,7 +2,7 @@ export class GuideToolMessage
{
private _message: string;
private _roomId: number;
constructor(message: string, roomId?: number)
{
this._message = message;

View File

@ -1,4 +1,4 @@
export class ClubStatus
export class ClubStatus
{
public static ACTIVE: string = 'active';
public static NONE: string = 'none';

View File

@ -8,4 +8,4 @@ export const GetClubBadge = (badgeCodes: string[]) =>
BADGES.forEach(badge => ((badgeCodes.indexOf(badge) > -1) && (badgeCode = badge)));
return (badgeCode || DEFAULT_BADGE);
}
};

View File

@ -5,4 +5,4 @@ export const GetCloseReasonKey = (code: number) =>
if(code === 2) return 'abusive';
return 'resolved';
}
};

View File

@ -29,7 +29,7 @@ export class FurnitureItem implements IFurnitureItem
constructor(parser: IFurnitureItemData)
{
if(!parser) return;
this._locked = false;
this._id = parser.itemId;
this._type = parser.spriteId;

View File

@ -35,7 +35,7 @@ const addSingleFurnitureItem = (set: GroupItem[], item: FurnitureItem, unseen: b
}
return groupItem;
}
};
const addGroupableFurnitureItem = (set: GroupItem[], item: FurnitureItem, unseen: boolean) =>
{
@ -85,7 +85,7 @@ const addGroupableFurnitureItem = (set: GroupItem[], item: FurnitureItem, unseen
const index = set.indexOf(existingGroup);
if(index >= 0) set.splice(index, 1);
set.unshift(existingGroup);
}
@ -108,7 +108,7 @@ const addGroupableFurnitureItem = (set: GroupItem[], item: FurnitureItem, unseen
}
return existingGroup;
}
};
export const addFurnitureItem = (set: GroupItem[], item: FurnitureItem, unseen: boolean) =>
{
@ -120,7 +120,7 @@ export const addFurnitureItem = (set: GroupItem[], item: FurnitureItem, unseen:
{
addGroupableFurnitureItem(set, item, unseen);
}
}
};
export const mergeFurniFragments = (fragment: Map<number, FurnitureListItemParser>, totalFragments: number, fragmentNumber: number, fragments: Map<number, FurnitureListItemParser>[]) =>
{
@ -145,7 +145,7 @@ export const mergeFurniFragments = (fragment: Map<number, FurnitureListItemParse
fragments = null;
return merged;
}
};
export const getAllItemIds = (groupItems: GroupItem[]) =>
{
@ -168,4 +168,4 @@ export const getAllItemIds = (groupItems: GroupItem[]) =>
}
return itemIds;
}
};

View File

@ -19,12 +19,12 @@ export const setPlacingItemId = (id: number) => (itemIdInPlacing = id);
export const cancelRoomObjectPlacement = () =>
{
if(getPlacingItemId() === -1) return;
GetRoomEngine().cancelRoomObjectPlacement();
setPlacingItemId(-1);
setObjectMoverRequested(false);
}
};
export const attemptPetPlacement = (petItem: IPetItem, flag: boolean = false) =>
{
@ -47,7 +47,7 @@ export const attemptPetPlacement = (petItem: IPetItem, flag: boolean = false) =>
}
return true;
}
};
export const attemptItemPlacement = (groupItem: GroupItem, flag: boolean = false) =>
{
@ -92,7 +92,7 @@ export const attemptItemPlacement = (groupItem: GroupItem, flag: boolean = false
}
return true;
}
};
export const attemptBotPlacement = (botItem: IBotItem, flag: boolean = false) =>
@ -114,4 +114,4 @@ export const attemptBotPlacement = (botItem: IBotItem, flag: boolean = false) =>
}
return true;
}
};

View File

@ -12,7 +12,7 @@ export const addSinglePetItem = (petData: PetData, set: IPetItem[], unseen: bool
if(unseen)
{
//petItem.isUnseen = true;
set.unshift(petItem);
}
else
@ -21,7 +21,7 @@ export const addSinglePetItem = (petData: PetData, set: IPetItem[], unseen: bool
}
return petItem;
}
};
export const removePetItemById = (id: number, set: IPetItem[]) =>
{
@ -39,7 +39,7 @@ export const removePetItemById = (id: number, set: IPetItem[]) =>
CreateLinkEvent('inventory/open');
}
set.splice(index, 1);
return petItem;
@ -49,7 +49,7 @@ export const removePetItemById = (id: number, set: IPetItem[]) =>
}
return null;
}
};
export const processPetFragment = (set: IPetItem[], fragment: Map<number, PetData>, isUnseen: (category: number, itemId: number) => boolean) =>
{
@ -75,7 +75,7 @@ export const processPetFragment = (set: IPetItem[], fragment: Map<number, PetDat
}
return set;
}
};
export const mergePetFragments = (fragment: Map<number, PetData>, totalFragments: number, fragmentNumber: number, fragments: Map<number, PetData>[]) =>
{
@ -100,4 +100,4 @@ export const mergePetFragments = (fragment: Map<number, PetData>, totalFragments
fragments = null;
return merged;
}
};

View File

@ -10,6 +10,6 @@ export class TradeUserData
public itemCount: number = 0,
public creditsCount: number = 0,
public accepts: boolean = false,
public canTrade: boolean = false)
public canTrade: boolean = false)
{}
}

View File

@ -17,39 +17,39 @@ export const parseTradeItems = (items: ItemDataStructure[]) =>
{
const spriteId = item.spriteId;
const category = item.category;
let name = (item.furniType + spriteId);
if(!item.isGroupable || isExternalImage(spriteId))
{
name = ('itemid' + item.itemId);
}
if(item.category === FurniCategory.POSTER)
{
name = (item.itemId + 'poster' + item.stuffData.getLegacyString());
}
else if(item.category === FurniCategory.GUILD_FURNI)
{
name = '';
}
let groupItem = ((item.isGroupable && !isExternalImage(item.spriteId)) ? existingItems.getValue(name) : null);
if(!groupItem)
{
groupItem = createGroupItem(spriteId, category, item.stuffData);
existingItems.add(name, groupItem);
}
groupItem.push(new FurnitureItem(item));
}
}
return existingItems;
}
};
export const getGuildFurniType = (spriteId: number, stuffData: IObjectData) =>
{
@ -67,4 +67,4 @@ export const getGuildFurniType = (spriteId: number, stuffData: IObjectData) =>
}
return type;
}
};

View File

@ -32,4 +32,4 @@ export const GetIssueCategoryName = (categoryId: number) =>
}
return 'Unknown';
}
};

View File

@ -5,6 +5,6 @@ const BuildMaxVisitorsList = () =>
for(let i = 10; i <= 100; i = i + 10) list.push(i);
return list;
}
};
export const GetMaxVisitorsList = BuildMaxVisitorsList();

View File

@ -1,6 +1,6 @@
import { GetConfiguration } from '@nitrots/nitro-renderer';
export function GetConfigurationValue<T>(key: string, value: T = null): T
export function GetConfigurationValue<T = string>(key: string, value: T = null): T
{
return GetConfiguration().getValue(key, value);
}

View File

@ -3,7 +3,7 @@ import { CreateLinkEvent, HabboWebTools } from '@nitrots/nitro-renderer';
export const OpenUrl = (url: string) =>
{
if(!url || !url.length) return;
if(url.startsWith('http'))
{
HabboWebTools.openWebPage(url);
@ -12,4 +12,4 @@ export const OpenUrl = (url: string) =>
{
CreateLinkEvent(url);
}
}
};

View File

@ -49,6 +49,6 @@ export const DispatchMouseEvent = (event: MouseEvent, canvasId: number = 1) =>
break;
default: return;
}
GetRoomEngine().dispatchMouseEvent(canvasId, x, y, eventType, event.altKey, (event.ctrlKey || event.metaKey), event.shiftKey, false);
}
};

View File

@ -20,7 +20,7 @@ export const DispatchTouchEvent = (event: TouchEvent, canvasId: number = 1, long
x = event.changedTouches[0].clientX;
y = event.changedTouches[0].clientY;
}
let eventType = event.type;
if(longTouch) eventType = TouchEventType.TOUCH_LONG;
@ -53,7 +53,7 @@ export const DispatchTouchEvent = (event: TouchEvent, canvasId: number = 1, long
break;
case MouseEventType.DOUBLE_CLICK:
break;
case TouchEventType.TOUCH_START:
case TouchEventType.TOUCH_START:
eventType = MouseEventType.MOUSE_DOWN;
didMouseMove = false;
@ -72,10 +72,10 @@ export const DispatchTouchEvent = (event: TouchEvent, canvasId: number = 1, long
default: return;
}
if (eventType === TouchEventType.TOUCH_START)
if(eventType === TouchEventType.TOUCH_START)
{
GetRoomEngine().dispatchMouseEvent(canvasId, x, y, eventType, altKey, ctrlKey, shiftKey, false);
}
GetRoomEngine().dispatchMouseEvent(canvasId, x, y, eventType, altKey, ctrlKey, shiftKey, false);
}
};

View File

@ -10,4 +10,4 @@ export const GetRoomObjectBounds = (roomId: number, objectId: number, category:
rectangle.y = Math.round(rectangle.y);
return rectangle;
}
};

View File

@ -10,4 +10,4 @@ export const GetRoomObjectScreenLocation = (roomId: number, objectId: number, ca
point.y = Math.round(point.y);
return point;
}
};

View File

@ -6,4 +6,4 @@ export const InitializeRoomInstanceRenderingCanvas = (width: number, height: num
const roomId = roomEngine.activeRoomId;
roomEngine.initializeRoomInstanceRenderingCanvas(roomId, canvasId, width, height);
}
};

View File

@ -6,8 +6,8 @@ export function GetCanStandUp(): string
const roomObject = GetOwnRoomObject();
if(!roomObject) return AvatarAction.POSTURE_STAND;
const model = roomObject.model;
return model.getValue<string>(RoomObjectVariable.FIGURE_CAN_STAND_UP);
}

View File

@ -6,7 +6,7 @@ export function GetCanUseExpression(): boolean
const roomObject = GetOwnRoomObject();
if(!roomObject) return false;
const model = roomObject.model;
const effectId = model.getValue<number>(RoomObjectVariable.FIGURE_EFFECT);

View File

@ -4,6 +4,6 @@ import { GetConfigurationValue } from '../GetConfigurationValue';
export function GetClubMemberLevel(): number
{
if(GetConfigurationValue<boolean>('hc.disabled', false)) return HabboClubLevelEnum.VIP;
return GetSessionDataManager().clubLevel;
}

View File

@ -2,11 +2,11 @@ import { CatalogPageMessageProductData, FurnitureType, GetSessionDataManager, IF
export function GetFurnitureDataForProductOffer(offer: CatalogPageMessageProductData): IFurnitureData
{
if(!offer) return null;
if (!offer) return null;
let furniData: IFurnitureData = null;
switch((offer.productType.toUpperCase()))
switch ((offer.productType.toUpperCase()) as FurnitureType)
{
case FurnitureType.FLOOR:
furniData = GetSessionDataManager().getFloorItemData(offer.furniClassId);

View File

@ -6,8 +6,8 @@ export function GetOwnPosture(): string
const roomObject = GetOwnRoomObject();
if(!roomObject) return AvatarAction.POSTURE_STAND;
const model = roomObject.model;
return model.getValue<string>(RoomObjectVariable.FIGURE_POSTURE);
}

View File

@ -6,9 +6,9 @@ export function IsRidingHorse(): boolean
const roomObject = GetOwnRoomObject();
if(!roomObject) return false;
const model = roomObject.model;
const effectId = model.getValue<number>(RoomObjectVariable.FIGURE_EFFECT);
return (effectId === 77);
}

View File

@ -8,4 +8,4 @@ export const VisitDesktop = () =>
GoToDesktop();
GetRoomSessionManager().removeSession(-1);
}
};

View File

@ -1,4 +1,4 @@
export class NotificationBubbleType
export class NotificationBubbleType
{
public static FRIENDOFFLINE: string = 'friendoffline';
public static FRIENDONLINE: string = 'friendonline';

View File

@ -39,7 +39,7 @@ export class AvatarInfoUser implements IAvatarInfo
public targetRoomControllerLevel: number = 0;
public isAmbassador: boolean = false;
constructor(public readonly type: string)
constructor(public readonly type: string)
{}
public get isOwnUser(): boolean

View File

@ -398,7 +398,7 @@ export class AvatarInfoUtilities
default:
return (userInfo.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
};
return this.isValidSetting(userInfo, checkSetting);
}
@ -416,7 +416,7 @@ export class AvatarInfoUtilities
default:
return (userInfo.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
};
return this.isValidSetting(userInfo, checkSetting);
}
@ -432,7 +432,7 @@ export class AvatarInfoUtilities
default:
return (userInfo.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
};
return this.isValidSetting(userInfo, checkSetting);
}

View File

@ -10,7 +10,7 @@ export class ChatBubbleMessage
private _top: number = 0;
private _left: number = 0;
constructor(
public senderId: number = -1,
public senderCategory: number = -1,
@ -23,7 +23,7 @@ export class ChatBubbleMessage
public styleId: number = 0,
public imageUrl: string = null,
public color: string = null
)
)
{
this.id = ++ChatBubbleMessage.BUBBLE_COUNTER;
}

View File

@ -12,7 +12,7 @@ export class ChatBubbleUtilities
{
const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, {
resetFigure: figure => this.setFigureImage(figure),
dispose: () =>
dispose: () =>
{},
disposed: false
});

View File

@ -4,6 +4,6 @@ export class DimmerFurnitureWidgetPresetItem
public id: number = 0,
public type: number = 0,
public color: number = 0,
public light: number = 0)
public light: number = 0)
{}
}

View File

@ -3,5 +3,4 @@ import { ChatBubbleMessage } from './ChatBubbleMessage';
export const DoChatsOverlap = (a: ChatBubbleMessage, b: ChatBubbleMessage, additionalBTop: number, padding: number = 0) =>
{
return !((((a.left + padding) + a.width) < (b.left + padding)) || ((a.left + padding) > ((b.left + padding) + b.width)) || ((a.top + a.height) < (b.top + additionalBTop)) || (a.top > ((b.top + additionalBTop) + b.height)));
}
};

View File

@ -12,9 +12,9 @@ export const GetDiskColor = (name: string) =>
let b: number = 0;
let index: number = 0;
while (index < name.length)
while(index < name.length)
{
switch ((index % 3))
switch((index % 3))
{
case 0:
r = (r + ( name.charCodeAt(index) * 37) );
@ -34,4 +34,4 @@ export const GetDiskColor = (name: string) =>
b = ((b % DISK_COLOR_BLUE_RANGE) + DISK_COLOR_BLUE_MIN);
return `rgb(${ r },${ g },${ b })`;
}
};

View File

@ -29,10 +29,10 @@ export class MannequinUtilities
for(const part of figureContainer.getPartTypeIds())
{
if(this.MANNEQUIN_CLOTHING_PART_TYPES.indexOf(part) >= 0) continue;
figureContainer.removePart(part);
}
figureContainer.updatePart((this.MANNEQUIN_FIGURE[0] as string), (this.MANNEQUIN_FIGURE[1] as number), (this.MANNEQUIN_FIGURE[2] as number[]));
};
}

View File

@ -1,4 +1,4 @@
export class YoutubeVideoPlaybackStateEnum
export class YoutubeVideoPlaybackStateEnum
{
public static readonly UNSTARTED = -1;
public static readonly ENDED = 0;

View File

@ -11,4 +11,4 @@ export const CloneObject = <T>(object: T): T =>
}
return copy;
}
};

View File

@ -30,7 +30,7 @@ export class ColorUtils
*/
public static int_to_8BitVals(value: number): [number, number, number, number]
{
const val1 = ((value >> 24) & 0xFF)
const val1 = ((value >> 24) & 0xFF);
const val2 = ((value >> 16) & 0xFF);
const val3 = ((value >> 8) & 0xFF);
const val4 = (value & 0xFF);

View File

@ -6,4 +6,4 @@ export const ConvertSeconds = (seconds: number) =>
let numSeconds = ((seconds % 86400) % 3600) % 60;
return numDays.toString().padStart(2, '0') + ':' + numHours.toString().padStart(2, '0') + ':' + numMinutes.toString().padStart(2, '0') + ':' + numSeconds.toString().padStart(2, '0');
}
};

View File

@ -2,10 +2,10 @@ export const GetLocalStorage = <T>(key: string) =>
{
try
{
JSON.parse(window.localStorage.getItem(key)) as T ?? null
JSON.parse(window.localStorage.getItem(key)) as T ?? null;
}
catch(e)
catch (e)
{
return null;
}
}
};

View File

@ -7,4 +7,4 @@ export const LocalizeBadgeDescription = (key: string) =>
if(!badgeDesc || !badgeDesc.length) badgeDesc = `badge_desc_${ key }`;
return badgeDesc;
}
};

View File

@ -7,4 +7,4 @@ export const LocalizeBadgeName = (key: string) =>
if(!badgeName || !badgeName.length) badgeName = `badge_name_${ key }`;
return badgeName;
}
};

View File

@ -8,7 +8,7 @@ export const PlaySound = (sampleCode: string) =>
if(!canPlaySound) return;
DispatchMainEvent(new NitroSoundEvent(NitroSoundEvent.PLAY_SOUND, sampleCode));
}
};
const eventTypes = [ MouseEventType.MOUSE_CLICK ];
@ -19,6 +19,6 @@ const startListening = () =>
const onEvent = (event: Event) => ((canPlaySound = true) && stopListening());
eventTypes.forEach(type => window.addEventListener(type, onEvent));
}
};
startListening();

View File

@ -35,7 +35,7 @@ const encodeHTML = (str: string) =>
return full;
});
}
};
export const RoomChatFormatter = (content: string) =>
{
@ -72,4 +72,4 @@ export const RoomChatFormatter = (content: string) =>
}
return result;
}
};

View File

@ -5,4 +5,4 @@ export const GetWiredTimeLocale = (value: number) =>
if(!(value % 2)) return time.toString();
return (time + 0.5).toString();
}
};

View File

@ -16,7 +16,7 @@ export const AutoGrid: FC<AutoGridProps> = props =>
let newStyle: CSSProperties = {};
newStyle['--nitro-grid-column-min-height'] = (columnMinHeight + 'px');
if(columnCount > 1) newStyle.gridTemplateColumns = `repeat(auto-fill, minmax(${ columnMinWidth }px, 1fr))`;
if(Object.keys(style).length) newStyle = { ...newStyle, ...style };
@ -25,4 +25,4 @@ export const AutoGrid: FC<AutoGridProps> = props =>
}, [ columnMinWidth, columnMinHeight, columnCount, style ]);
return <Grid columnCount={ columnCount } fullHeight={ fullHeight } overflow={ overflow } style={ getStyle } { ...rest } />;
}
};

View File

@ -29,31 +29,31 @@ export const Base: FC<BaseProps<HTMLDivElement>> = props =>
{
const newClassNames: string[] = [];
if (display && display.length) newClassNames.push(display);
if(display && display.length) newClassNames.push(display);
if (fit || fullWidth) newClassNames.push('w-full');
if(fit || fullWidth) newClassNames.push('w-full');
if (fit || fullHeight) newClassNames.push('h-full');
if(fit || fullHeight) newClassNames.push('h-full');
if (fitV) newClassNames.push('vw-full', 'vh-full');
if(fitV) newClassNames.push('vw-full', 'vh-full');
if (grow) newClassNames.push('!flex-grow');
if(grow) newClassNames.push('!flex-grow');
if (shrink) newClassNames.push('!flex-shrink-0');
if(shrink) newClassNames.push('!flex-shrink-0');
if (overflow) newClassNames.push('overflow-' + overflow);
if(overflow) newClassNames.push('overflow-' + overflow);
if (position) newClassNames.push(position);
if(position) newClassNames.push(position);
if (float) newClassNames.push('float-' + float);
if(float) newClassNames.push('float-' + float);
if (pointer) newClassNames.push('cursor-pointer');
if(pointer) newClassNames.push('cursor-pointer');
if (visible !== null) newClassNames.push(visible ? 'visible' : 'invisible');
if(visible !== null) newClassNames.push(visible ? 'visible' : 'invisible');
if (textColor) newClassNames.push('text-' + textColor);
if(textColor) newClassNames.push('text-' + textColor);
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ display, fit, fitV, grow, shrink, fullWidth, fullHeight, overflow, position, float, pointer, visible, textColor, classNames ]);
@ -62,7 +62,7 @@ export const Base: FC<BaseProps<HTMLDivElement>> = props =>
{
let newClassName = getClassNames.join(' ');
if (className.length) newClassName += (' ' + className);
if(className.length) newClassName += (' ' + className);
return newClassName.trim();
}, [ getClassNames, className ]);
@ -71,7 +71,7 @@ export const Base: FC<BaseProps<HTMLDivElement>> = props =>
{
let newStyle: CSSProperties = {};
if (Object.keys(style).length) newStyle = { ...newStyle, ...style };
if(Object.keys(style).length) newStyle = { ...newStyle, ...style };
return newStyle;
}, [ style ]);
@ -81,4 +81,4 @@ export const Base: FC<BaseProps<HTMLDivElement>> = props =>
{ children }
</div>
);
}
};

View File

@ -21,48 +21,48 @@ export const Button: FC<ButtonProps> = props =>
const newClassNames: string[] = [ 'pointer-events-auto inline-block font-normal leading-normal text-[#fff] text-center no-underline align-middle cursor-pointer select-none border-[1px] border-[solid] border-[transparent] px-[.75rem] py-[.375rem] text-[.9rem] rounded-[.25rem] [transition:color_.15s_ease-in-out,_background-color_.15s_ease-in-out,_border-color_.15s_ease-in-out,_box-shadow_.15s_ease-in-out]' ];
if (variant)
if(variant)
{
if (variant == 'primary')
if(variant == 'primary')
newClassNames.push('text-white bg-[#1e7295] border-[#1e7295] [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-white hover:bg-[#1a617f] hover:border-[#185b77]');
if (variant == 'success')
if(variant == 'success')
newClassNames.push('text-white bg-[#00800b] border-[#00800b] [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-white hover:bg-[#006d09] hover:border-[#006609]');
if (variant == 'danger')
if(variant == 'danger')
newClassNames.push('text-white bg-[#a81a12] border-[#a81a12] [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-white hover:bg-[#8f160f] hover:border-[#86150e]');
if (variant == 'warning')
if(variant == 'warning')
newClassNames.push('text-white bg-[#ffc107] border-[#ffc107] [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-[#000] hover:bg-[#ffca2c] hover:border-[#ffc720]');
if (variant == 'black')
newClassNames.push('text-white bg-[#000] border-[#000] [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-white hover:bg-[#000] hover:border-[#000]')
if(variant == 'black')
newClassNames.push('text-white bg-[#000] border-[#000] [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-white hover:bg-[#000] hover:border-[#000]');
if (variant == 'secondary')
newClassNames.push('text-white bg-[#185d79] border-[#185d79] [box-shadow:inset_0_2px_#ffffff26,_inset_0_-2px_#0000001a,_0_1px_#0000001a] hover:text-white hover:bg-[#144f67] hover:border-[#134a61]')
if(variant == 'secondary')
newClassNames.push('text-white bg-[#185d79] border-[#185d79] [box-shadow:inset_0_2px_#ffffff26,_inset_0_-2px_#0000001a,_0_1px_#0000001a] hover:text-white hover:bg-[#144f67] hover:border-[#134a61]');
if (variant == 'dark')
newClassNames.push('text-white bg-dark [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-white hover:bg-[#18181bfb] hover:border-[#161619fb]')
if(variant == 'dark')
newClassNames.push('text-white bg-dark [box-shadow:inset_0_2px_#ffffff26,inset_0_-2px_#0000001a,0_1px_#0000001a] hover:text-white hover:bg-[#18181bfb] hover:border-[#161619fb]');
}
if (size)
if(size)
{
if (size == 'sm')
if(size == 'sm')
{
newClassNames.push('!px-[.5rem] !py-[.25rem] !text-[.7875rem] !rounded-[.2rem] !min-h-[28px]');
}
}
if (active) newClassNames.push('active');
if(active) newClassNames.push('active');
if (disabled) newClassNames.push('pointer-events-none opacity-[.65] [box-shadow:none]');
if(disabled) newClassNames.push('pointer-events-none opacity-[.65] [box-shadow:none]');
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ variant, size, active, disabled, classNames ]);
return <Flex center classNames={ getClassNames } { ...rest } />;
}
};

View File

@ -19,28 +19,28 @@ export const Column: FC<ColumnProps> = props =>
{
const newClassNames: string[] = [];
if (size)
if(size)
{
let colClassName = `col-span-${ size }`;
if (isCssGrid) colClassName = `${ colClassName }`;
if(isCssGrid) colClassName = `${ colClassName }`;
newClassNames.push(colClassName);
}
if (offset)
if(offset)
{
let colClassName = `offset-${ offset }`;
if (isCssGrid) colClassName = `g-start-${ offset }`;
if(isCssGrid) colClassName = `g-start-${ offset }`;
newClassNames.push(colClassName);
}
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ size, offset, isCssGrid, classNames ]);
return <Flex classNames={ getClassNames } column={ column } gap={ gap } { ...rest } />;
}
};

View File

@ -21,30 +21,30 @@ export const Flex: FC<FlexProps> = props =>
{
const newClassNames: string[] = [];
if (column)
if(column)
{
if (reverse) newClassNames.push('flex-col-span-reverse');
if(reverse) newClassNames.push('flex-col-span-reverse');
else newClassNames.push('flex-col');
}
else
{
if (reverse) newClassNames.push('flex-row-reverse');
if(reverse) newClassNames.push('flex-row-reverse');
}
if (gap) newClassNames.push('gap-' + gap);
if(gap) newClassNames.push('gap-' + gap);
if (alignSelf) newClassNames.push('self-' + alignSelf);
if(alignSelf) newClassNames.push('self-' + alignSelf);
if (alignItems) newClassNames.push('items-' + alignItems);
if(alignItems) newClassNames.push('items-' + alignItems);
if (justifyContent) newClassNames.push('justify-' + justifyContent);
if(justifyContent) newClassNames.push('justify-' + justifyContent);
if (!alignItems && !justifyContent && center) newClassNames.push('items-center', 'justify-center');
if(!alignItems && !justifyContent && center) newClassNames.push('items-center', 'justify-center');
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ column, reverse, gap, center, alignSelf, alignItems, justifyContent, classNames ]);
return <Base classNames={ getClassNames } display={ display } { ...rest } />;
}
};

View File

@ -19,4 +19,4 @@ export const FormGroup: FC<FormGroupProps> = props =>
}, [ classNames ]);
return <Flex classNames={ getClassNames } { ...rest } />;
}
};

View File

@ -24,23 +24,23 @@ export const Grid: FC<GridProps> = props =>
const newClassNames: string[] = [];
if (inline) newClassNames.push('inline-grid');
if(inline) newClassNames.push('inline-grid');
else newClassNames.push('grid grid-rows-[repeat(var(--bs-rows,_1),_1fr)] grid-cols-[repeat(var(--bs-columns,_12),_1fr)]');
if (gap) newClassNames.push('gap-' + gap);
else if (gap === 0) newClassNames.push('gap-0');
if(gap) newClassNames.push('gap-' + gap);
else if(gap === 0) newClassNames.push('gap-0');
if (maxContent) newClassNames.push('[flex-basis:max-content]');
if(maxContent) newClassNames.push('[flex-basis:max-content]');
if (alignSelf) newClassNames.push('self-' + alignSelf);
if(alignSelf) newClassNames.push('self-' + alignSelf);
if (alignItems) newClassNames.push('items-' + alignItems);
if(alignItems) newClassNames.push('items-' + alignItems);
if (justifyContent) newClassNames.push('justify-' + justifyContent);
if(justifyContent) newClassNames.push('justify-' + justifyContent);
if (!alignItems && !justifyContent && center) newClassNames.push('items-center', 'justify-center');
if(!alignItems && !justifyContent && center) newClassNames.push('items-center', 'justify-center');
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ inline, gap, maxContent, alignSelf, alignItems, justifyContent, center, classNames ]);
@ -49,9 +49,9 @@ export const Grid: FC<GridProps> = props =>
{
let newStyle: CSSProperties = {};
if (columnCount) newStyle['--bs-columns'] = columnCount.toString();
if(columnCount) newStyle['--bs-columns'] = columnCount.toString();
if (Object.keys(style).length) newStyle = { ...newStyle, ...style };
if(Object.keys(style).length) newStyle = { ...newStyle, ...style };
return newStyle;
}, [ columnCount, style ]);
@ -61,4 +61,4 @@ export const Grid: FC<GridProps> = props =>
<Base classNames={ getClassNames } fullHeight={ fullHeight } style={ getStyle } { ...rest } />
</GridContextProvider>
);
}
};

View File

@ -11,7 +11,7 @@ const GridContext = createContext<IGridContext>({
export const GridContextProvider: FC<ProviderProps<IGridContext>> = props =>
{
return <GridContext.Provider value={ props.value }>{ props.children }</GridContext.Provider>
}
return <GridContext.Provider value={ props.value }>{ props.children }</GridContext.Provider>;
};
export const useGridContext = () => useContext(GridContext);

View File

@ -35,4 +35,4 @@ export const HorizontalRule: FC<HorizontalRuleProps> = props =>
}, [ height, style ]);
return <Base classNames={ getClassNames } style={ getStyle } { ...rest } />;
}
};

View File

@ -52,4 +52,4 @@ export const InfiniteScroll: FC<InfiniteScrollProps> = props =>
</div>
</Base>
);
}
};

View File

@ -1,58 +1,40 @@
// @flow strict
'use client'
import { useEffect, useRef, useState } from 'react';
import { FC, PropsWithChildren, useEffect, useRef, useState } from 'react';
function ReactPopover({
children,
content,
trigger = 'click'
})
export const ReactPopover: FC<PropsWithChildren<{
content: JSX.Element;
trigger?: 'click' | 'hover';
}>> = props =>
{
const { content = null, trigger = null, children = null } = props;
const [ show, setShow ] = useState(false);
const wrapperRef = useRef(null);
const handleMouseOver = () =>
{
if (trigger === 'hover')
{
setShow(true);
};
};
const handleMouseOver = () => (trigger === 'hover') && setShow(true);
const handleMouseLeft = () =>
{
if (trigger === 'hover')
{
setShow(false);
};
};
const handleMouseLeft = () => (trigger === 'hover') && setShow(false);
useEffect(() =>
{
function handleClickOutside(event)
{
if (wrapperRef.current && !wrapperRef.current.contains(event.target))
{
setShow(false);
}
}
if(!show) return;
if (show)
const handleClickOutside = (event: MouseEvent) =>
{
// Bind the event listener
document.addEventListener('mousedown', handleClickOutside);
return () =>
{
// Unbind the event listener on clean up
document.removeEventListener('mousedown', handleClickOutside);
};
}
if(wrapperRef.current && !wrapperRef.current.contains(event.target)) setShow(false);
};
document.addEventListener('mousedown', handleClickOutside);
return () =>
{
// Unbind the event listener on clean up
document.removeEventListener('mousedown', handleClickOutside);
};
}, [ show, wrapperRef ]);
return (
<div
ref={ wrapperRef }
className="w-fit h-fit relative flex justify-center"
className="relative flex justify-center w-fit h-fit"
onMouseEnter={ handleMouseOver }
onMouseLeave={ handleMouseLeft }>
<div
@ -70,5 +52,3 @@ function ReactPopover({
</div>
);
};
export default ReactPopover;

View File

@ -28,36 +28,36 @@ export const Text: FC<TextProps> = props =>
{
const newClassNames: string[] = [ 'inline' ];
if (variant) newClassNames.push('text-' + variant);
if(variant) newClassNames.push('text-' + variant);
if (bold) newClassNames.push('font-bold ');
if(bold) newClassNames.push('font-bold ');
if (fontWeight) newClassNames.push('font-' + fontWeight);
if(fontWeight) newClassNames.push('font-' + fontWeight);
if (fontSize) newClassNames.push('fs-' + fontSize);
if(fontSize) newClassNames.push('fs-' + fontSize);
if (align) newClassNames.push('text-' + align);
if(align) newClassNames.push('text-' + align);
if (underline) newClassNames.push('underline');
if(underline) newClassNames.push('underline');
if (italics) newClassNames.push('italic');
if(italics) newClassNames.push('italic');
if (truncate) newClassNames.push('text-truncate');
if(truncate) newClassNames.push('text-truncate');
if (center) newClassNames.push('text-center');
if(center) newClassNames.push('text-center');
if (textEnd) newClassNames.push('text-end');
if(textEnd) newClassNames.push('text-end');
if (small) newClassNames.push('text-sm');
if(small) newClassNames.push('text-sm');
if (wrap) newClassNames.push('text-wrap');
if(wrap) newClassNames.push('text-wrap');
if (noWrap) newClassNames.push('text-nowrap');
if(noWrap) newClassNames.push('text-nowrap');
if (textBreak) newClassNames.push('text-break');
if(textBreak) newClassNames.push('text-break');
return newClassNames;
}, [ variant, fontWeight, fontSize, align, bold, underline, italics, truncate, center, textEnd, small, wrap, noWrap, textBreak ]);
return <Base classNames={ getClassNames } { ...rest } />;
}
};

View File

@ -10,10 +10,10 @@ export const NitroCardContentView: FC<ColumnProps> = props =>
// Theme Changer
const newClassNames: string[] = [ 'container-fluid', 'h-full p-[8px] overflow-auto', 'bg-light' ];
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ classNames ]);
return <Column classNames={ getClassNames } overflow={ overflow } { ...rest } />;
}
};

View File

@ -11,7 +11,7 @@ const NitroCardContext = createContext<INitroCardContext>({
export const NitroCardContextProvider: FC<ProviderProps<INitroCardContext>> = props =>
{
return <NitroCardContext.Provider value={ props.value }>{ props.children }</NitroCardContext.Provider>
}
return <NitroCardContext.Provider value={ props.value }>{ props.children }</NitroCardContext.Provider>;
};
export const useNitroCardContext = () => useContext(NitroCardContext);

View File

@ -21,7 +21,7 @@ export const NitroCardHeaderView: FC<NitroCardHeaderViewProps> = props =>
{
event.stopPropagation();
event.nativeEvent.stopImmediatePropagation();
}
};
return (
<Column center className={ 'relative flex items-center justify-center flex-col drag-handler min-h-card-header max-h-card-header bg-card-header' } { ...rest }>
@ -38,4 +38,4 @@ export const NitroCardHeaderView: FC<NitroCardHeaderViewProps> = props =>
</Flex>
</Column>
);
}
};

View File

@ -22,7 +22,7 @@ export const NitroCardView: FC<NitroCardViewProps> = props =>
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ classNames ]);
@ -34,4 +34,4 @@ export const NitroCardView: FC<NitroCardViewProps> = props =>
</DraggableWindow>
</NitroCardContextProvider>
);
}
};

View File

@ -16,6 +16,6 @@ const NitroCardAccordionContext = createContext<INitroCardAccordionContext>({
export const NitroCardAccordionContextProvider: FC<ProviderProps<INitroCardAccordionContext>> = props =>
{
return <NitroCardAccordionContext.Provider { ...props } />;
}
};
export const useNitroCardAccordionContext = () => useContext(NitroCardAccordionContext);

View File

@ -15,4 +15,4 @@ export const NitroCardAccordionItemView: FC<NitroCardAccordionItemViewProps> = p
{ children }
</Flex>
);
}
};

View File

@ -18,9 +18,9 @@ export const NitroCardAccordionSetView: FC<NitroCardAccordionSetViewProps> = pro
const onClick = () =>
{
closeAll();
setIsOpen(prevValue => !prevValue);
}
};
const onClose = useCallback(() => setIsOpen(false), []);
@ -62,10 +62,10 @@ export const NitroCardAccordionSetView: FC<NitroCardAccordionSetViewProps> = pro
const index = newClosers.indexOf(closeFunction);
if(index >= 0) newClosers.splice(index, 1);
return newClosers;
});
}
};
}, [ onClose, setClosers ]);
return (
@ -81,4 +81,4 @@ export const NitroCardAccordionSetView: FC<NitroCardAccordionSetViewProps> = pro
</Column> }
</Column>
);
}
};

View File

@ -4,7 +4,7 @@ import { NitroCardAccordionContextProvider } from './NitroCardAccordionContext';
interface NitroCardAccordionViewProps extends ColumnProps
{
}
export const NitroCardAccordionView: FC<NitroCardAccordionViewProps> = props =>
@ -22,4 +22,4 @@ export const NitroCardAccordionView: FC<NitroCardAccordionViewProps> = props =>
<Column gap={ 0 } { ...rest } />
</NitroCardAccordionContextProvider>
);
}
};

View File

@ -19,7 +19,7 @@ export const NitroCardTabsItemView: FC<NitroCardTabsItemViewProps> = props =>
//if (isActive) newClassNames.push('bg-[#dfdfdf] border-b-[1px_solid_black]');
if (classNames.length) newClassNames.push(...classNames);
if(classNames.length) newClassNames.push(...classNames);
return newClassNames;
}, [ isActive, classNames ]);
@ -33,4 +33,4 @@ export const NitroCardTabsItemView: FC<NitroCardTabsItemViewProps> = props =>
<LayoutItemCountView count={ count } /> }
</Flex>
);
}
};

Some files were not shown because too many files have changed in this diff Show More