Upload files to "/"
This commit is contained in:
commit
1fa6d558c7
149 changed files with 27987 additions and 0 deletions
18
.editorconfig
Normal file
18
.editorconfig
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.json]
|
||||||
|
indent_size = 4
|
||||||
157
CHANGELOG.md
Normal file
157
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [2.0.1] - 2026-02-04
|
||||||
|
|
||||||
|
* **ReadMe (`README.md`):** Updated ReadMe for better understanding
|
||||||
|
|
||||||
|
|
||||||
|
## [2.0.2] - 2026-02-08
|
||||||
|
|
||||||
|
### 🚀 Added (SSR & Architecture)
|
||||||
|
|
||||||
|
* **Server-Side Rendering (SSR):** Full support for Node.js environments via `jsdom`.
|
||||||
|
* Added `src/server.ts` with `parseHTML` utility.
|
||||||
|
* Added `bind(window)` factory in `src/index.ts` to create isolated jBase instances per request.
|
||||||
|
|
||||||
|
|
||||||
|
* **Context Awareness:** The core `jBase` class now accepts an optional `context` (Window/Document) in the constructor to support isolated environments.
|
||||||
|
* **Environment Detection:** Added `isBrowser()` utility in `src/utils.ts` to safely distinguish between browser and server environments.
|
||||||
|
|
||||||
|
### ⚡ Performance
|
||||||
|
|
||||||
|
* **Data Module (`data/objects.ts`):** Optimized search algorithms in `find.first`, `find.last`, `find.key`, and `find.value`. moved query normalization (`toLowerCase()`) outside of loops to significantly reduce CPU overhead.
|
||||||
|
* **Effects Module:** Added server-guards (`if (!isBrowser())`) to `fade.ts`, `slide.ts`, and `vertical.ts`. Animation logic is now skipped on the server to save resources.
|
||||||
|
|
||||||
|
### 🛡️ Fixed (Stability & Logic)
|
||||||
|
|
||||||
|
* **Core (`core.ts`):** Added crash protection for invalid CSS selectors. `$(...)` now catches `DOMException` errors internally and logs a warning instead of crashing.
|
||||||
|
* **DOM Manipulation (`dom/manipulation.ts`):**
|
||||||
|
* Rewrote `unwrap()` using a `Set` to safely handle parent removal without conflicts on sibling elements.
|
||||||
|
* Replaced global `window.document` usage with a `getDoc(this)` helper to prevent `ReferenceError` crashes in Node.js.
|
||||||
|
|
||||||
|
|
||||||
|
* **HTTP Module (`http/*.ts`):** Fixed potential crash when parsing JSON from `200 OK` responses that contain an empty body.
|
||||||
|
* **CSS Module (`css/styles.ts`):** Updated `css()` getter to access `getComputedStyle` via `el.ownerDocument` instead of global `window`.
|
||||||
|
|
||||||
|
### 🔧 Changed & Cleaned
|
||||||
|
|
||||||
|
* **Documentation:** Removed localized German JSDoc comments to reduce source code size and maintain a consistent English-only documentation standard.
|
||||||
|
* **Config:** Fixed invalid JSON syntax in `tsconfig.json`.
|
||||||
|
* **Type Safety:** Upgraded `isObject` utility to a TypeScript Type Guard for better type inference.
|
||||||
|
|
||||||
|
|
||||||
|
## [2.0.3] - 2026-02-13
|
||||||
|
|
||||||
|
### 🛡️ Fixed (http)
|
||||||
|
|
||||||
|
* **HTTP Module (`http/get.ts`):** Enforce GET method in get() and getText() utility. Overrides method to 'GET' if 'POST' is passed in options.
|
||||||
|
* **HTTP Module (`http/post.ts`):** Enforce POST method in post() utility. Overrides method to 'POST' if 'GET' is passed in options.
|
||||||
|
|
||||||
|
|
||||||
|
## [2.1.1] - 2026-02-22
|
||||||
|
|
||||||
|
### 🚀 Added (DOM Attributes)
|
||||||
|
|
||||||
|
* **Attributes Module (`dom/attributes.ts`):** Added `removeAttr()` method to safely remove HTML attributes from all elements in a selection.
|
||||||
|
* **Attributes Module (`dom/attributes.ts`):** Added `prop()` method for getting and setting underlying DOM properties (e.g., `checked`, `disabled`, `selectedIndex`) that don't directly map to standard HTML attributes.
|
||||||
|
|
||||||
|
### 🛡️ Fixed (CSS & HTTP)
|
||||||
|
|
||||||
|
* **CSS Module (`css/styles.ts`):** Enhanced the `css()` method to support passing an object (`Record<string, string | number>`) for setting multiple CSS properties simultaneously (e.g., `css({'background-color': 'blue', 'font-size': '14px'})`).
|
||||||
|
* **CSS Module (`css/styles.ts`):** Improved handling of kebab-case property names inside the `css()` method by utilizing `style.setProperty()` for greater robustness.
|
||||||
|
* **HTTP Module (`http/get.ts`):** Fixed a critical bug in `getText()` where it incorrectly attempted to parse the response with `JSON.parse()` instead of returning the raw text. It now safely returns the raw string/HTML as intended.
|
||||||
|
|
||||||
|
## [2.1.2] - 2026-02-22
|
||||||
|
|
||||||
|
### 🛡️ Fixed (Core & Browser Scope)
|
||||||
|
|
||||||
|
* **Core (`src/index.ts`):** Fixed an architectural bug where the `http` and `data` modules were not accessible via the main `$` wrapper (e.g., `$.http` or `$.data`) as documented in the wiki. They are now properly attached to the `init` factory function using `Object.assign()`.
|
||||||
|
* **Browser Module (`src/browser.ts`):** Removed the unintended global `window.http` export to prevent global namespace pollution. The HTTP module must now be accessed exclusively through the framework instance (e.g., `$.http` or `jBase.http`).
|
||||||
|
|
||||||
|
## [2.2.0] - 2026-04-12
|
||||||
|
|
||||||
|
### 🚀 Added (New Features)
|
||||||
|
* **Event System (`events/binding.ts`):** * Massive upgrade to the `.on()` and `.off()` methods. They now fully support **Event Delegation** (e.g., `$('table').on('click', 'tr', handler)`) and passing custom data to the event object (`event.data`).
|
||||||
|
* Added `.once()` method to execute a handler at most once per element and event type. Supports delegation and data.
|
||||||
|
* Added `.trigger()` method to programmatically execute native or custom events and pass optional data via `event.detail`.
|
||||||
|
* **Touch Events (`events/touch.ts`):** Added `.swipeLeft()`, `.swipeUp()` `.swipeDown()` and `.swipeRight()` helpers for robust mobile gesture detection.
|
||||||
|
* **Mouse Events (`events/mouse.ts`):** Added `.hover()` as a convenient shorthand for binding both `mouseenter` and `mouseleave` handlers.
|
||||||
|
* **Core Utilities (`utils.ts` & `index.ts`):** * Introduced `$.each()`, a highly performant, breakable iteration utility for arrays, NodeLists, and plain objects.
|
||||||
|
* `$.throttle` and `$.debounce` are now globally exposed on the main `$` object for easy access.
|
||||||
|
|
||||||
|
### ⚡ Performance
|
||||||
|
* **Core (`core.ts`):** Implemented a high-performance, native `for`-loop iteration method (`.each()`) inside the core class. Replaced standard `forEach` calls across the entire framework (DOM, CSS, Attributes, etc.) to significantly reduce CPU overhead and allow early loop termination.
|
||||||
|
|
||||||
|
### 🛡️ Fixed (Stability & Architecture)
|
||||||
|
* **SSR Safety (`core.ts`):** Fixed a critical bug in the constructor where string selectors would fall back to the global `document` instead of the passed isolated `context` (`this.doc`). Node.js environments are now completely safe.
|
||||||
|
* **Event Delegation (`events/binding.ts`):** Fixed a potential `TypeError` crash during event delegation when a user clicks on a pure `TextNode` (which lacks the `.closest()` method).
|
||||||
|
* **Typings (`index.ts`):** Fixed signature mismatch for `.prop()` to correctly handle getter (`any`) and setter (`jBase`) overloads.
|
||||||
|
* **Dependencies (`package.json`):** Moved `jsdom` and `tslib` from standard `dependencies` to `peerDependencies` / `devDependencies`. This drastically reduces the installation size for browser-only users via npm.
|
||||||
|
|
||||||
|
## [2.3.0] - 2026-04-20
|
||||||
|
|
||||||
|
### 🚀 Added (Upload Method)
|
||||||
|
* **HTTP Module:** Added `$.http.upload()` method. This introduces a modern, Promise-based wrapper around `XMLHttpRequest` specifically designed for file uploads. It solves the native limitation of the `fetch` API by allowing real-time upload progress tracking via an `onProgress` callback, while maintaining the same elegant `async/await` syntax as the rest of the HTTP module.
|
||||||
|
|
||||||
|
## [2.4.0] - 2026-05-03
|
||||||
|
|
||||||
|
### 🚀 Added (Dynamic Routing & API Symmetry)
|
||||||
|
* **Data Module (`data/index.ts`):** Introduced a smart, dynamic API router (Facade). You no longer need to explicitly specify `.arr` or `.obj` when calling data utilities.
|
||||||
|
* Methods can now be called directly on the main data namespace (e.g., `$.data.chunk()`, `$.data.remove.at()`).
|
||||||
|
* The framework automatically detects the input type under the hood (`Array.isArray()`) and routes the request to the correct underlying module.
|
||||||
|
* Full TypeScript overloads guarantee perfect IntelliSense and type safety depending on whether you pass an array or an object.
|
||||||
|
* *Note: Explicit calls via `.arr` and `.obj` remain fully supported for 100% backward compatibility.*
|
||||||
|
* **Data Module (`data/objects.ts`):** Massive expansion of object utilities to mirror the array API.
|
||||||
|
* Added `chunk()` for objects to split a large object into an array of smaller objects (batched processing).
|
||||||
|
* Added `add()` for safely injecting a key-value pair at a specific index position.
|
||||||
|
* Added `remove.at()`, `remove.first()`, `remove.last()`, `remove.byKey()`, `remove.byValue()`, and `remove.byMatch()` to immutably remove properties from an object based on complex queries or exact matches.
|
||||||
|
* Added `find.all()` to return a partial object containing only the properties that match a specific query.
|
||||||
|
* Aliased `merge` to `mergeObjects` to ensure naming consistency across the data module.
|
||||||
|
* **Data Module (`data/arrays.ts`):** Expanded array utilities to mirror the object API.
|
||||||
|
* Added `get()` and `set()` for safe, deep navigation and assignment within nested arrays.
|
||||||
|
* Added `find.key()` and `find.value()` to provide identical method signatures between arrays and objects.
|
||||||
|
* Added `pick()` and `omit()` to immutably extract or remove array elements based on a list of specific indices.
|
||||||
|
* Added `remove.byKey()` and `remove.byValue()` for strict API parity with object removals.
|
||||||
|
|
||||||
|
### 🚀 Added (DOM Content)
|
||||||
|
* **DOM Module (`dom/content.ts`):** Added `.load(url)` method. This provides a highly requested, classic shortcut to asynchronously fetch HTML from a server and inject it directly into the matched DOM elements. Under the hood, it seamlessly utilizes the robust `$.http.getText()` utility.
|
||||||
|
|
||||||
|
### ⚡ Performance & Logic
|
||||||
|
* **Data Module (`data/arrays.ts` & `data/objects.ts`):**
|
||||||
|
* All search queries within `find` and `remove` methods are now executed in a case-insensitive manner by default.
|
||||||
|
* Both modules are now completely symmetrical, utilizing the same internal `MatchMode` logic (`'exact'`, `'contains'`, `'startsWith'`, `'endsWith'`) for predictable data extraction.
|
||||||
|
|
||||||
|
### 🧹 Cleaned & Utility
|
||||||
|
* **Data Module (`data/arrays.ts` & `data/objects.ts`):**
|
||||||
|
* Added `clear()` (along with aliases `empty()` and `remove.all()`) to both modules. These methods provide a fast, standardized way to return a new, empty element of the respective type (`[]` or `{}`) without mutating the original data structure, adhering to the framework's functional design principles.
|
||||||
|
* **Effects Module (`effects/fade.ts`):** Added `show()`, `hide()` and `toggle()`, as semantic aliases for `fadeIn()`, `fadeOut()` and `fadeToggle()`. This provides a more intuitive, classic API for developers used to standard DOM visibility toggling, while maintaining the smooth CSS transition logic under the hood.
|
||||||
|
* **DOM Module (`dom/states.ts`):** Added semantic action aliases for state manipulation. You can now use `.check()`, `.uncheck()`, `.select()`, `.disable()`, and `.enable()` as highly readable, chainable alternatives to passing boolean values into `.checked()`, `.selected()`, and `.disabled()`.
|
||||||
|
|
||||||
|
### 🛡️ Secured (XSS Protection & Architecture)
|
||||||
|
* **Core Utilities (`utils.ts`):** Introduced a centralized, high-performance XSS sanitizer (`sanitizeDangerousAttributes`). This internal utility aggressively strips dangerous inline event handlers (like `onerror`) and malicious protocols (like `href="javascript:..."`) from raw HTML strings.
|
||||||
|
* **Core (`core.ts`):** Hardened the main `jBase` constructor. Creating new DOM elements via `$('<div...>')` now passes the string through the central sanitizer, ensuring "secure-by-default" behavior even when handling untrusted user input.
|
||||||
|
* **DOM Manipulation (`dom/manipulation.ts`):** Secured all structural insertion methods (`append`, `prepend`, `before`, `after`, `wrap`, and `replaceWith`). Any raw HTML strings passed into these methods are now automatically sanitized before being injected into the DOM, closing the backdoor for XSS injections.
|
||||||
|
* **DOM Content (`dom/content.ts`):** Completely overhauled the injection logic for `.html()` and `.load()`. They now inherit the strict XSS sanitization by default. To maintain full framework flexibility for trusted sources, we introduced the `{ executeScripts: true }` bypass, which safely extracts, injects, and evaluates embedded `<script>` tags on demand.
|
||||||
|
|
||||||
|
### 📚 Documentation & Developer Experience
|
||||||
|
* **HTTP Module (`http/get.ts`, `http/post.ts`):** Harmonized JSDoc comments and added practical, framework-native examples (using `$` instead of vanilla `querySelector`), perfectly matching the updated `upload` method documentation.
|
||||||
|
* **DOM States (`dom/states.ts`):** Cleaned up internal typings and refined JSDoc descriptions for attribute and class manipulation methods to guarantee a consistent developer experience across the entire DOM API.
|
||||||
|
|
||||||
|
## [2.4.1] - 2026-05-09
|
||||||
|
|
||||||
|
### 🚀 Features & Enhancements
|
||||||
|
* **Effects (Global Easing):** Added support for custom `easing` properties (e.g., `'linear'`, `'cubic-bezier'`) across all animation modules (Fade, Slide, Vertical), giving developers full control over transition timing.
|
||||||
|
* **Effects (Global Bounce):** Introduced a new `bounce: true` option across all effects.
|
||||||
|
* *Fade:* Applies a snappy scale-spring effect.
|
||||||
|
* *Slide:* Applies a `back-in`/`back-out` cubic-bezier curve, making menus physically hit the edge.
|
||||||
|
* *Vertical:* Intelligently utilizes specific curves for a smooth accordion-spring effect.
|
||||||
|
* **Developer Experience (Shorthand Syntax):** All effect methods (`fadeIn`, `fadeOut`, `fadeToggle`, `show`, `hide`, `toggle`, `slideIn`, `slideOut`, `slideToggle`, `slideDown`, `slideUp`, `slideToggleBox`) now accept a primitive `number` (duration in ms) as a direct argument (e.g., `$('main').hide(500)`). This restores classic, rapid-prototyping shorthand syntax while maintaining full configuration object support.
|
||||||
|
* **Types:** Expanded `FadeOptions`, `SlideOptions`, and `SlideVerticalOptions` interfaces to support the new `easing` and `bounce` properties safely.
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes
|
||||||
|
* **Effects (Core Architecture):** Fixed a critical `TypeError: Failed to construct 'HTMLElement': Illegal constructor` exception across all toggle methods (`fadeToggle`, `slideToggle`, `slideToggleBox`). This was resolved by adopting modern ES6 arrow functions to ensure proper `this` context binding within iteration loops.
|
||||||
|
* **Effects (Race Conditions):** Resolved the notorious "ghost timer" bug. Rapidly overlapping animation calls (e.g., fast toggling of menus or dropdowns) caused elements to unexpectedly revert to `display: none` or stutter. Animation timers are now strictly tracked and cleared on a per-element basis across all modules.
|
||||||
|
* **Effects (Slide):** Fixed a logical bug in `slideIn` where the `direction` parameter was completely ignored. Elements are now correctly pre-positioned off-canvas (`-100%` or `100%`) before the slide transition begins.
|
||||||
|
* **Effects (Vertical):** Resolved an issue where interrupting an active vertical slide caused the framework to incorrectly bail out due to static `display` state checks. Animations can now be smoothly reversed mid-flight.
|
||||||
69
CODE_OF_CONDUCT.md
Normal file
69
CODE_OF_CONDUCT.md
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at **[jbase@sven-minio.de]**.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
**Community Impact:** Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||||
|
**Consequence:** A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
**Community Impact:** A violation through a single incident or series of actions.
|
||||||
|
**Consequence:** A warning with consequences for continued behavior. No interaction with the involved people, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
**Community Impact:** A serious violation of community standards, including sustained inappropriate behavior.
|
||||||
|
**Consequence:** A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the involved people, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
**Community Impact:** Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
**Consequence:** A permanent ban from any sort of public interaction within the community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
96
CONTRIBUTING.md
Normal file
96
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
# Contributing to jBase
|
||||||
|
|
||||||
|
First off, thank you for considering contributing to jBase! It's people like you that make the open-source community such an amazing place to learn, inspire, and create.
|
||||||
|
|
||||||
|
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.
|
||||||
|
|
||||||
|
## ⚡ Quick Start
|
||||||
|
|
||||||
|
1. **Fork the repository** on GitHub.
|
||||||
|
2. **Clone your fork** locally:
|
||||||
|
```bash
|
||||||
|
git clone [https://github.com/k37z3r/jBase-2.git](https://github.com/k37z3r/jBase-2.git)
|
||||||
|
cd jbase
|
||||||
|
```
|
||||||
|
3. **Install dependencies**:
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
4. **Build the project** to ensure everything works:
|
||||||
|
```bash
|
||||||
|
node build.js
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🛠 Development Workflow
|
||||||
|
|
||||||
|
### 1. Branching
|
||||||
|
Always create a new branch for your work. Do not commit directly to `main`.
|
||||||
|
* **Features:** `feature/my-new-feature`
|
||||||
|
* **Bugfixes:** `fix/issue-description`
|
||||||
|
* **Docs:** `docs/update-readme`
|
||||||
|
|
||||||
|
### 2. Coding Standards
|
||||||
|
We enforce a strict coding style to maintain quality across the framework.
|
||||||
|
|
||||||
|
* **Language:** TypeScript (Strict mode).
|
||||||
|
* **Formatting:**
|
||||||
|
* **Indentation:** 4 Spaces (Check `.editorconfig`).
|
||||||
|
* **Quotes:** Single quotes preferred.
|
||||||
|
* **Semicolons:** Always use semicolons.
|
||||||
|
* **Documentation:**
|
||||||
|
* **Language:** English only. No German comments in the source code.
|
||||||
|
* **JSDoc:** Every exported function must have a JSDoc block describing parameters and return values.
|
||||||
|
* **SSR Safety:**
|
||||||
|
* Never access `window` or `document` globally in logic that might run on the server.
|
||||||
|
* Use `isBrowser()` check for effects/animations.
|
||||||
|
* Use `getDoc(this)` or `el.ownerDocument` for DOM access.
|
||||||
|
|
||||||
|
### 3. Commit Messages
|
||||||
|
We follow the **Conventional Commits** specification. This helps in generating changelogs automatically.
|
||||||
|
|
||||||
|
* `feat: add new slideDown animation`
|
||||||
|
* `fix: resolve crash in unwrap method`
|
||||||
|
* `docs: update installation guide`
|
||||||
|
* `perf: optimize object search algorithm`
|
||||||
|
* `refactor: clean up event binding`
|
||||||
|
|
||||||
|
## 🚀 Building the Project
|
||||||
|
|
||||||
|
The project uses a custom `esbuild` script. Before submitting a PR, make sure the build succeeds without errors.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node build.js
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
This command generates:
|
||||||
|
|
||||||
|
* `dist/jbase.min.js` (Browser)
|
||||||
|
* `dist/index.mjs` (ESM)
|
||||||
|
* `dist/index.cjs` (CommonJS)
|
||||||
|
* `dist/server.js` (Node.js/SSR)
|
||||||
|
* `dist/*.d.ts` (Type Definitions)
|
||||||
|
|
||||||
|
## 🐞 Reporting Bugs
|
||||||
|
|
||||||
|
We use GitHub issues to track public bugs. Report a bug by opening a new issue; it's that easy!
|
||||||
|
|
||||||
|
**Great Bug Reports tend to have:**
|
||||||
|
|
||||||
|
* A quick summary and/or background.
|
||||||
|
* Steps to reproduce.
|
||||||
|
* What you expected would happen.
|
||||||
|
* What actually happened.
|
||||||
|
* Notes (possibly including why you think this might be happening, or stuff you tried that didn't work).
|
||||||
|
|
||||||
|
## 📝 Pull Requests
|
||||||
|
|
||||||
|
1. Push your changes to your fork.
|
||||||
|
2. Open a Pull Request against the `main` branch of the `jBase` repository.
|
||||||
|
3. Describe your changes clearly.
|
||||||
|
4. Link to any related issues (e.g., "Closes #12").
|
||||||
|
5. Wait for a code review. We might ask for changes before merging.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Happy Coding!** 🚀
|
||||||
621
LICENSE
Normal file
621
LICENSE
Normal file
|
|
@ -0,0 +1,621 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
179
README.md
Normal file
179
README.md
Normal file
|
|
@ -0,0 +1,179 @@
|
||||||
|
# jBase
|
||||||
|
![Package Version][package-version-badge]
|
||||||
|
![Build][build-badge]
|
||||||
|
![Size][size-badge]
|
||||||
|
![License][license-badge]
|
||||||
|
|
||||||
|
![SSR Ready][ssr-ready-badge]
|
||||||
|
![Browser Ready][browser-ready-badge]
|
||||||
|
![Exports][exports-badge]
|
||||||
|
|
||||||
|
![NPM][available-badge-npm]
|
||||||
|
![GITHUB][available-badge-github]
|
||||||
|
![jsDelivr][cdn-badge-jsdelivr]
|
||||||
|
![Statically][cdn-badge-statically]
|
||||||
|
|
||||||
|
**A modern, lightweight, and modular JavaScript framework for high-performance DOM manipulation, event handling, and data management.**
|
||||||
|
|
||||||
|
jBase offers a familiar chainable API (similar to jQuery) but is built on modern ES6+ standards. It goes beyond UI logic by including a robust set of immutable data utilities and **full Server-Side Rendering (SSR) support**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📥 Installation
|
||||||
|
|
||||||
|
### via NPM / Yarn
|
||||||
|
Ideal for modern web apps using bundlers (Vite, Webpack) or Node.js.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @k37z3r/jbase
|
||||||
|
# or
|
||||||
|
yarn add @k37z3r/jbase
|
||||||
|
```
|
||||||
|
|
||||||
|
### via Script Tag
|
||||||
|
|
||||||
|
Download the [jbase.min.js](/k37z3r/jBase-2/releases/latest/download/jbase.min.js) file, upload it to your server, and include it in your HTML.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="dist/jbase.min.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
-- OR --
|
||||||
|
|
||||||
|
### via CDN
|
||||||
|
```html
|
||||||
|
<!-- CDN: jsDelivr @latest Version -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@k37z3r/jbase/dist/jbase.min.js"></script>
|
||||||
|
|
||||||
|
<!-- CDN: Statically @latest version -->
|
||||||
|
<script src="https://cdn.statically.io/npm/@k37z3r/jbase/dist/jbase.min.js"></script>
|
||||||
|
|
||||||
|
<!-- CDN: jsDelivr @2.2.0 Version -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/k37z3r/jBase-2@2.2.0/dist/jbase.min.js"></script>
|
||||||
|
|
||||||
|
<!-- CDN: Statically @2.2.0 Version -->
|
||||||
|
<script src="https://cdn.statically.io/gh/k37z3r/jBase-2@2.2.0/dist/jbase.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Use one of the examples above. You can find further examples in the jsDelivr or Statically documentation -->
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🖥️ Server-Side Rendering (SSR) & Node.js
|
||||||
|
|
||||||
|
jBase is **isomorphic**. You can use the exact same code on the client and the server.
|
||||||
|
To use DOM manipulation in Node.js, simply bind jBase to a `jsdom` window instance.
|
||||||
|
|
||||||
|
### 1. Install JSDOM (Optional Peer Dependency)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install jsdom
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Bind to a Virtual Window
|
||||||
|
|
||||||
|
Use the `bind` factory to create a jBase instance scoped to a specific request or document.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { JSDOM } from 'jsdom';
|
||||||
|
import { bind } from '@k37z3r/jbase'; // Adjust to your package name
|
||||||
|
|
||||||
|
// 1. Create a virtual DOM environment
|
||||||
|
const dom = new JSDOM('<!DOCTYPE html><div id="app"></div>');
|
||||||
|
const window = dom.window;
|
||||||
|
|
||||||
|
// 2. Create a scoped instance of jBase
|
||||||
|
const $ = bind(window);
|
||||||
|
|
||||||
|
// 3. Manipulate the DOM exactly like in the browser
|
||||||
|
$('#app')
|
||||||
|
.addClass('ssr-rendered')
|
||||||
|
.html('<h1>Hello from Node.js!</h1>')
|
||||||
|
.append('<p>This HTML was generated on the server.</p>');
|
||||||
|
|
||||||
|
// 4. Output the final HTML string
|
||||||
|
console.log(dom.serialize());
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Browser-only features like animations (`fadeIn`, `slideUp`) or Event Bindings (`click`) are **safely ignored** in Node.js environments to prevent crashes and save resources.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Client-Side Features
|
||||||
|
|
||||||
|
jBase exposes itself globally as `jBase` and the shorthand `$`.
|
||||||
|
|
||||||
|
### 1. DOM & Effects
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
$(document).ready(() => {
|
||||||
|
// Event Handling
|
||||||
|
$('button.save').on('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Chained manipulation & Animation
|
||||||
|
$('.notification')
|
||||||
|
.addClass('success')
|
||||||
|
.text('Saved successfully!')
|
||||||
|
.fadeIn(300);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Powerful Data Utilities
|
||||||
|
|
||||||
|
jBase includes a unique `$.data` module for **immutable** array and object manipulation. Optimized for high performance.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const users = [
|
||||||
|
{ id: 1, name: 'Alice', role: 'admin' },
|
||||||
|
{ id: 2, name: 'Bob', role: 'user' }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Find specific data efficiently (Optimized Search)
|
||||||
|
const admin = $.data.find.first(users, 'admin', 'exact', 'role');
|
||||||
|
|
||||||
|
// Remove data immutably (returns a new array)
|
||||||
|
const nonAdmins = $.data.remove.byMatch(users, 'admin', 'exact', 'role');
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. HTTP Requests
|
||||||
|
|
||||||
|
Simple, robust AJAX wrappers that handle JSON automatically.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
$.http.get('https://api.example.com/items')
|
||||||
|
.then(data => console.log('Items loaded:', data))
|
||||||
|
.catch(err => console.error('Error:', err));
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 Documentation
|
||||||
|
|
||||||
|
Detailed documentation for all methods is available in the **[GitHub Wiki](../../wiki)** or offline **[Documentation](./wiki)**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📄 License
|
||||||
|
|
||||||
|
**jBase** is open-source software licensed under the **[GPL-3.0-or-later](LICENSE)**.
|
||||||
|
|
||||||
|
**Author:** Sven Minio
|
||||||
|
|
||||||
|
**Website:** [sven-minio.de](https://sven-minio.de)
|
||||||
|
|
||||||
|
**Copyright:** © 2026 Sven Minio
|
||||||
|
|
||||||
|
[available-badge-npm]: https://img.shields.io/badge/available%20on-npm-CB3837?style=flat-square&logo=npm
|
||||||
|
[available-badge-github]: https://img.shields.io/badge/available%20on-GitHub-181717CB3837?style=flat-square&logo=github
|
||||||
|
[cdn-badge-jsdelivr]: https://img.shields.io/badge/CDN-jsDelivr-E84D3D?style=flat-square&logo=jsdelivr
|
||||||
|
[cdn-badge-statically]: https://img.shields.io/badge/CDN-Statically-ea6545?style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYuNjc1bW0iIGhlaWdodD0iMTYuNjc1bW0iIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbC1ydWxlPSJldmVub2RkIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgc2hhcGUtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iIHRleHQtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iIHZpZXdCb3g9IjAgMCA0NDUuNjcgNDQ1LjMzIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjExMC42NyIgeDI9IjMzNC4zMiIgeTE9IjQxNC44IiB5Mj0iMzAuMTkiIGdyYWRpZW50VHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwxNTU1LjcpIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agc3RvcC1jb2xvcj0iI2Q3MjQzMCIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iI2ZkYTI1OSIgb2Zmc2V0PSIxIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLjMzNDI3IC0xNTU2KSI+PHBhdGggZD0ibTMwIDE2NjYuN2M2Mi0xMDcgMTk4LTE0MyAzMDQtODEgMTA3IDYyIDE0MyAxOTggODEgMzA0LTYyIDEwNy0xOTggMTQzLTMwNCA4MS0xMDctNjItMTQzLTE5OC04MS0zMDR6IiBmaWxsPSJ1cmwoI2EpIi8+PGcgdHJhbnNmb3JtPSJtYXRyaXgoMS4yMTk0IC4xMTIzNiAtLjExMjkyIDEuMjI1NSAtMjIuMjUxIDE0NzguNCkiIHN0cm9rZT0iI2ZlZmVmZSIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyMy4wNDEiPjxnIHN0cm9rZT0iI2ZlZmVmZSIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyMy4wNDEiPjxwYXRoIGQ9Ik0yODMgMjI2bC00Ny0xOSA3NC0xMDVMMTU2IDIyMmw1MiAxOC03MyAxMDZ6IiBmaWxsPSIjZmVmZWZlIiBzdHJva2U9IiNmZWZlZmUiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMjMuMDQxIi8+PC9nPjwvZz48L2c+PC9zdmc+
|
||||||
|
[package-version-badge]: https://img.shields.io/github/package-json/v/k37z3r/jBase-2/main?style=flat-square&label=version
|
||||||
|
[ssr-ready-badge]: https://img.shields.io/badge/SSR-Ready-brightgreen?style=flat-square
|
||||||
|
[browser-ready-badge]: https://img.shields.io/badge/Browser-Ready-4CAF50?style=flat-square
|
||||||
|
[exports-badge]: https://img.shields.io/badge/exports-.js%20%7C%20.mjs%20%7C%20.cjs%20%7C%20.d.ts-007ec6?style=flat-square
|
||||||
|
[license-badge]: https://img.shields.io/badge/license-GPL--3.0-green.svg?style=flat-square
|
||||||
|
[size-badge]: https://img.shields.io/badge/size-lightweight-orange.svg?style=flat-square
|
||||||
|
[build-badge]: https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat-square
|
||||||
36
SECURITY.md
Normal file
36
SECURITY.md
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
We are currently supporting the following versions of jBase with security updates:
|
||||||
|
|
||||||
|
| Version | Supported | Notes |
|
||||||
|
| ------- | ------------------ | ----- |
|
||||||
|
| 2.x | :white_check_mark: | Current major version |
|
||||||
|
| 1.x | :x: | End of Life |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
We take the security of jBase seriously. If you believe you have found a security vulnerability in this framework, please report it to us as described below.
|
||||||
|
|
||||||
|
**Please do not report security vulnerabilities through public GitHub issues.**
|
||||||
|
|
||||||
|
### How to Report
|
||||||
|
|
||||||
|
Please email the lead developer directly at: **[jbase@sven-minio.de]**
|
||||||
|
|
||||||
|
Please include the following details in your report:
|
||||||
|
* The version of jBase you are using.
|
||||||
|
* A description of the vulnerability.
|
||||||
|
* Steps to reproduce the issue (code snippets or a proof-of-concept are highly appreciated).
|
||||||
|
* Any potential impact you foresee.
|
||||||
|
|
||||||
|
### Our Response Policy
|
||||||
|
|
||||||
|
1. **Acknowledgment:** We will make every effort to acknowledge your report within 48 hours.
|
||||||
|
2. **Investigation:** We will investigate the issue and verify the vulnerability.
|
||||||
|
3. **Fix:** Once confirmed, we will work on a patch.
|
||||||
|
4. **Release:** We will release a new version (e.g., v2.0.3) containing the security fix.
|
||||||
|
5. **Disclosure:** After the fix is released and users have had time to update, we will publicly acknowledge your contribution (unless you wish to remain anonymous).
|
||||||
|
|
||||||
|
Thank you for helping keep jBase safe for everyone!
|
||||||
113
build.js
Normal file
113
build.js
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
/**
|
||||||
|
* @file build.js
|
||||||
|
* @version 2.0.2
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Build
|
||||||
|
* @description
|
||||||
|
* * Build automation script using esbuild. Handles bundling, minification, and output generation.
|
||||||
|
* @requires esbuild
|
||||||
|
* * High-performance JavaScript bundler.
|
||||||
|
* @requires ./package.json
|
||||||
|
* * Project configuration and versioning.
|
||||||
|
* @requires child_process
|
||||||
|
* * For executing shell commands to generate TypeScript definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const esbuild = require('esbuild');
|
||||||
|
const pkg = require('./package.json');
|
||||||
|
const { exec } = require('child_process');
|
||||||
|
const banner = `/**
|
||||||
|
* ${pkg.name} - ${pkg.description}
|
||||||
|
* @version ${pkg.version}
|
||||||
|
* @homepage ${pkg.homepage}
|
||||||
|
* @author ${pkg.author}
|
||||||
|
* @license ${pkg.license}
|
||||||
|
* @copyright ${new Date().getFullYear()} ${pkg.author}
|
||||||
|
*/`;
|
||||||
|
|
||||||
|
const baseConfig = {
|
||||||
|
entryPoints: ['src/index.ts'],
|
||||||
|
bundle: true,
|
||||||
|
banner: { js: banner },
|
||||||
|
logLevel: 'info',
|
||||||
|
platform: 'neutral',
|
||||||
|
sourcemap: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const browserBuild = {
|
||||||
|
...baseConfig,
|
||||||
|
entryPoints: ['src/browser.ts'],
|
||||||
|
format: 'iife',
|
||||||
|
outfile: 'dist/jbase.browser.js',
|
||||||
|
legalComments: 'inline',
|
||||||
|
platform: 'browser',
|
||||||
|
};
|
||||||
|
|
||||||
|
const browserMinBuild = {
|
||||||
|
...browserBuild,
|
||||||
|
outfile: 'dist/jbase.min.js',
|
||||||
|
minify: true,
|
||||||
|
legalComments: 'none',
|
||||||
|
};
|
||||||
|
|
||||||
|
const esmBuild = {
|
||||||
|
...baseConfig,
|
||||||
|
format: 'esm',
|
||||||
|
outfile: 'dist/index.mjs',
|
||||||
|
};
|
||||||
|
|
||||||
|
const cjsBuild = {
|
||||||
|
...baseConfig,
|
||||||
|
format: 'cjs',
|
||||||
|
outfile: 'dist/index.cjs',
|
||||||
|
platform: 'node',
|
||||||
|
};
|
||||||
|
|
||||||
|
const serverBuild = {
|
||||||
|
...baseConfig,
|
||||||
|
entryPoints: ['src/server.ts'],
|
||||||
|
platform: 'node',
|
||||||
|
format: 'cjs',
|
||||||
|
outfile: 'dist/server.js',
|
||||||
|
external: ['jsdom', 'canvas', 'bufferutil', 'utf-8-validate'],
|
||||||
|
};
|
||||||
|
|
||||||
|
function generateTypes() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
console.log('\x1b[36m%s\x1b[0m', '🔨: Generating TypeScript Definitions...');
|
||||||
|
exec('npx tsc --emitDeclarationOnly --outDir dist', (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(`Error generating types: ${error.message}`);
|
||||||
|
reject(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stderr) console.error(`TSC Stderr: ${stderr}`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', '✅: TypeScript Definitions generated.');
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
esbuild.build(browserBuild),
|
||||||
|
esbuild.build(browserMinBuild),
|
||||||
|
esbuild.build(esmBuild),
|
||||||
|
esbuild.build(cjsBuild),
|
||||||
|
esbuild.build(serverBuild),
|
||||||
|
generateTypes()
|
||||||
|
]).then(() => {
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `*********************************************************************`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `🗊: jBase v${pkg.version}: A modern micro-framework for the web.`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `🗊: A modern micro-framework for the web: jBase offers the familiar`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `🗊: syntax of classic DOM libraries, but without their baggage. Fully`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `🗊: typed, modular, and optimized for modern browser engines.`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `Ⓒ: Copyright (C) ${new Date().getFullYear()} ${pkg.author}`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `§: Released under the ${pkg.license} License.`);
|
||||||
|
console.log('\x1b[32m%s\x1b[0m', `*********************************************************************`);
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error('\x1b[31m%s\x1b[0m', '❌ Build failed:', error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
32
dist/browser.d.ts
vendored
Normal file
32
dist/browser.d.ts
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
* @file src/browser.ts
|
||||||
|
* @version 2.2.1
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Browser
|
||||||
|
* @description
|
||||||
|
* * Browser Entry Point. Attaches the jBase library and utilities to the global window object
|
||||||
|
* * so they can be accessed via `$` or `jBase` (and other aliases) in inline scripts.
|
||||||
|
* @requires ./index
|
||||||
|
* * The core jBase class and its aliases are imported to be attached to the window object.
|
||||||
|
*/
|
||||||
|
import { $, jBase, jB, _jB, __jB, _jBase, __jBase, __ } from './index';
|
||||||
|
/**
|
||||||
|
* * TypeScript declaration merging to extend the global Window interface.
|
||||||
|
* * Ensures strict typing when accessing jBase aliases on the window object.
|
||||||
|
*/
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
$: typeof $;
|
||||||
|
jBase: typeof jBase;
|
||||||
|
jB: typeof jB;
|
||||||
|
_jB: typeof _jB;
|
||||||
|
__jB: typeof __jB;
|
||||||
|
_jBase: typeof _jBase;
|
||||||
|
__jBase: typeof __jBase;
|
||||||
|
__: typeof __;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=browser.d.ts.map
|
||||||
1
dist/browser.d.ts.map
vendored
Normal file
1
dist/browser.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAEvE;;;GAGG;AACH,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,CAAC,EAAE,OAAO,CAAC,CAAC;QACZ,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,EAAE,EAAE,OAAO,EAAE,CAAC;QACd,GAAG,EAAE,OAAO,GAAG,CAAC;QAChB,IAAI,EAAE,OAAO,IAAI,CAAC;QAClB,MAAM,EAAE,OAAO,MAAM,CAAC;QACtB,OAAO,EAAE,OAAO,OAAO,CAAC;QACxB,EAAE,EAAE,OAAO,EAAE,CAAC;KACjB;CACJ"}
|
||||||
45
dist/core.d.ts
vendored
Normal file
45
dist/core.d.ts
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
* @file src/core.ts
|
||||||
|
* @version 2.2.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Core
|
||||||
|
* @description
|
||||||
|
* * The main jBase class. Handles the selection engine, initialization, and plugin architecture.
|
||||||
|
* @requires ./types
|
||||||
|
* * Type definitions for the core class and its methods.
|
||||||
|
*/
|
||||||
|
import { JBaseElement, JBaseInput } from './types';
|
||||||
|
/**
|
||||||
|
* * The core class of the framework, inheriting from the native Array class. Acts as a wrapper around DOM elements and enables chainable methods (Fluent Interface).
|
||||||
|
*/
|
||||||
|
export declare class jBase extends Array<JBaseElement> {
|
||||||
|
/**
|
||||||
|
* * The original selector string or input type used to create this instance.
|
||||||
|
*/
|
||||||
|
selectorSource: string;
|
||||||
|
/**
|
||||||
|
* * The document context this instance is bound to (supports SSR via jsdom).
|
||||||
|
*/
|
||||||
|
doc: Document;
|
||||||
|
/**
|
||||||
|
* * Initializes a new jBase instance. Analyzes the provided selector and populates the internal array with found or created DOM elements.
|
||||||
|
* @param selector The input selector (CSS selector, HTML string, DOM element, or collection).
|
||||||
|
* @param context An optional specific Document or Window context (essential for SSR).
|
||||||
|
*/
|
||||||
|
constructor(selector?: JBaseInput, context?: Document | Window);
|
||||||
|
/**
|
||||||
|
* * Custom serializer for JSON.stringify. Prevents circular references and huge outputs by returning a simplified preview.
|
||||||
|
* @example toJson() => { meta: 'jBase Wrapper', query: '#myId', count: 1, preview: ['div'] }
|
||||||
|
* @returns A simplified object representation for debugging.
|
||||||
|
*/
|
||||||
|
toJSON(): {
|
||||||
|
meta: string;
|
||||||
|
query: string;
|
||||||
|
count: number;
|
||||||
|
preview: string[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=core.d.ts.map
|
||||||
1
dist/core.d.ts.map
vendored
Normal file
1
dist/core.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,qBAAa,KAAM,SAAQ,KAAK,CAAC,YAAY,CAAC;IAC1C;;OAEG;IACI,cAAc,EAAE,MAAM,CAAM;IAEnC;;OAEG;IACI,GAAG,EAAE,QAAQ,CAAC;IAErB;;;;OAIG;gBACS,QAAQ,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM;IA0D9D;;;;OAIG;IACH,MAAM;;;;;;CA4BT"}
|
||||||
3037
dist/index.cjs
vendored
Normal file
3037
dist/index.cjs
vendored
Normal file
File diff suppressed because it is too large
Load diff
7
dist/index.cjs.map
vendored
Normal file
7
dist/index.cjs.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1914
dist/index.d.ts
vendored
Normal file
1914
dist/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
dist/index.d.ts.map
vendored
Normal file
1
dist/index.d.ts.map
vendored
Normal file
File diff suppressed because one or more lines are too long
3002
dist/index.mjs
vendored
Normal file
3002
dist/index.mjs
vendored
Normal file
File diff suppressed because it is too large
Load diff
7
dist/index.mjs.map
vendored
Normal file
7
dist/index.mjs.map
vendored
Normal file
File diff suppressed because one or more lines are too long
3219
dist/jbase.browser.js
vendored
Normal file
3219
dist/jbase.browser.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
7
dist/jbase.browser.js.map
vendored
Normal file
7
dist/jbase.browser.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
10
dist/jbase.min.js
vendored
Normal file
10
dist/jbase.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
dist/jbase.min.js.map
vendored
Normal file
7
dist/jbase.min.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
43
dist/modules/css/classes.d.ts
vendored
Normal file
43
dist/modules/css/classes.d.ts
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/css/classes.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category CSS
|
||||||
|
* @description
|
||||||
|
* * Methods for manipulating CSS classes (add, remove, toggle, has).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Adds one or more CSS classes to each element in the collection.
|
||||||
|
* @example addClass('active', 'highlight') => Adds the 'active' and 'highlight' classes to all matched elements.
|
||||||
|
* @param classNames One or more class names to be added
|
||||||
|
* @returns The current jBase instance for method chaining
|
||||||
|
*/
|
||||||
|
export declare function addClass(this: jBase, ...classNames: string[]): jBase;
|
||||||
|
/**
|
||||||
|
* * Removes one or more CSS classes from each element in the collection.
|
||||||
|
* @example removeClass('active', 'highlight') => Removes the 'active' and 'highlight' classes from all matched elements.
|
||||||
|
* @param classNames One or more class names to be removed
|
||||||
|
* @returns The current jBase instance for method chaining
|
||||||
|
*/
|
||||||
|
export declare function removeClass(this: jBase, ...classNames: string[]): jBase;
|
||||||
|
/**
|
||||||
|
* * Toggles a CSS class (adds if missing, removes if present) for each element.
|
||||||
|
* @example toggleClass('active') => Toggles the 'active' class on all matched elements.
|
||||||
|
* @param className The class name to toggle.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function toggleClass(this: jBase, className: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Checks if at least one element in the collection has the specified class.
|
||||||
|
* @example hasClass('active') => Returns true if at least one matched element has the 'active' class, otherwise false.
|
||||||
|
* @param className The class name to check for.
|
||||||
|
* @returns True if the class exists on at least one element, otherwise false.
|
||||||
|
*/
|
||||||
|
export declare function hasClass(this: jBase, className: string): boolean;
|
||||||
|
//# sourceMappingURL=classes.d.ts.map
|
||||||
1
dist/modules/css/classes.d.ts.map
vendored
Normal file
1
dist/modules/css/classes.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"classes.d.ts","sourceRoot":"","sources":["../../../src/modules/css/classes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,CAKpE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,CAKvE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAKjE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAIhE"}
|
||||||
26
dist/modules/css/index.d.ts
vendored
Normal file
26
dist/modules/css/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/css/index.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category CSS
|
||||||
|
* @description
|
||||||
|
* * Central entry point for CSS operations. Aggregates class and style manipulation methods.
|
||||||
|
* @requires ./classes
|
||||||
|
* * Class manipulation methods (addClass, removeClass, etc.).
|
||||||
|
* @requires ./styles
|
||||||
|
* * Style manipulation methods (css).
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Aggregation of all CSS methods. This object bundles functions for class manipulation and style manipulation. It is exported to extend the jBase prototype centrally via Object.assign.
|
||||||
|
*/
|
||||||
|
export declare const cssMethods: {
|
||||||
|
css(this: import("../..").JBaseClass, property: string | Record<string, string | number>, value?: string | number): string | import("../..").JBaseClass;
|
||||||
|
addClass(this: import("../..").JBaseClass, ...classNames: string[]): import("../..").JBaseClass;
|
||||||
|
removeClass(this: import("../..").JBaseClass, ...classNames: string[]): import("../..").JBaseClass;
|
||||||
|
toggleClass(this: import("../..").JBaseClass, className: string): import("../..").JBaseClass;
|
||||||
|
hasClass(this: import("../..").JBaseClass, className: string): boolean;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
dist/modules/css/index.d.ts.map
vendored
Normal file
1
dist/modules/css/index.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/css/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;CAGtB,CAAC"}
|
||||||
25
dist/modules/css/styles.d.ts
vendored
Normal file
25
dist/modules/css/styles.d.ts
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/css/styles.ts
|
||||||
|
* @version 2.0.4
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category CSS
|
||||||
|
* @description
|
||||||
|
* * Methods for getting and setting inline CSS styles.
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Gets a CSS property value from the first element or sets one/multiple CSS properties for all elements.
|
||||||
|
* @example css('color', 'red') => Sets the 'color' style to 'red' for all matched elements.
|
||||||
|
* @example css({ color: 'red', backgroundColor: 'blue' }) => Sets multiple styles for all matched elements.
|
||||||
|
* @example css('color') => Returns the computed 'color' value of the first matched element.
|
||||||
|
* @param property A CSS property name as a string, or an object of property-value pairs to set multiple styles.
|
||||||
|
* @param value (Optional) The value to set if `property` is a string. If undefined and `property` is a string, acts as a getter.
|
||||||
|
* @returns The CSS value as a string when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export declare function css(this: jBase, property: string | Record<string, string | number>, value?: string | number): string | jBase;
|
||||||
|
//# sourceMappingURL=styles.d.ts.map
|
||||||
1
dist/modules/css/styles.d.ts.map
vendored
Normal file
1
dist/modules/css/styles.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/modules/css/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CA2C5H"}
|
||||||
238
dist/modules/data/arrays.d.ts
vendored
Normal file
238
dist/modules/data/arrays.d.ts
vendored
Normal file
|
|
@ -0,0 +1,238 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/arrays.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Utility functions for array manipulation and data processing.
|
||||||
|
* @requires ./types
|
||||||
|
* * Depends on types.
|
||||||
|
*/
|
||||||
|
import { MatchMode } from './types';
|
||||||
|
/**
|
||||||
|
* * Splits an array into smaller groups (chunks). Ideal for pagination or grid layouts.
|
||||||
|
* @example chunk([1, 2, 3, 4, 5], 2) => [[1, 2], [3, 4], [5]]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param size The size of each chunk.
|
||||||
|
* @returns An array of arrays.
|
||||||
|
*/
|
||||||
|
export declare function chunk<T>(array: T[], size: number): T[][];
|
||||||
|
/**
|
||||||
|
* * Merges multiple arrays into a single flat array.
|
||||||
|
* @example mergeArray([1, 2], [3, 4], [5]) => [1, 2, 3, 4, 5]
|
||||||
|
* @template T The type of the items in the arrays.
|
||||||
|
* @param arrays A list of arrays.
|
||||||
|
* @returns A new, merged array.
|
||||||
|
*/
|
||||||
|
export declare function mergeArray<T>(...arrays: T[][]): T[];
|
||||||
|
/**
|
||||||
|
* * ALIAS for mergeArray (Consistency with object.merge)
|
||||||
|
*/
|
||||||
|
export declare const merge: typeof mergeArray;
|
||||||
|
/**
|
||||||
|
* * Safely adds an element at a specific position without mutating the original array (Immutable).
|
||||||
|
* @example add([1, 2, 4], 3, 2) => [1, 2, 3, 4]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param item The item to add.
|
||||||
|
* @param index The position (default: end). Negative values count from the back (-1 = before the last one).
|
||||||
|
* @returns A new array including the element.
|
||||||
|
*/
|
||||||
|
export declare function add<T>(array: T[], item: T, index?: number): T[];
|
||||||
|
/**
|
||||||
|
* * Clears the array and returns a new empty array (Immutable).
|
||||||
|
* @example clear([1, 2, 3]) => []
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array to clear.
|
||||||
|
* @returns A new empty array.
|
||||||
|
*/
|
||||||
|
export declare function clear<T>(array: T[]): T[];
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear.
|
||||||
|
*/
|
||||||
|
export declare const empty: typeof clear;
|
||||||
|
/**
|
||||||
|
* * Creates a new array containing only the elements at the specified indices (Allowlist).
|
||||||
|
* * Mirrors object.pick.
|
||||||
|
* @example pick(['a', 'b', 'c', 'd'], [0, 2]) => ['a', 'c']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param indices Array of indices to keep.
|
||||||
|
* @returns A new array with selected elements.
|
||||||
|
*/
|
||||||
|
export declare function pick<T>(array: T[], indices: number[]): T[];
|
||||||
|
/**
|
||||||
|
* * Creates a new array containing all elements EXCEPT those at the specified indices (Blocklist).
|
||||||
|
* * Mirrors object.omit.
|
||||||
|
* @example omit(['a', 'b', 'c', 'd'], [1, 3]) => ['a', 'c']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param indices Array of indices to remove.
|
||||||
|
* @returns A new array without the specified elements.
|
||||||
|
*/
|
||||||
|
export declare function omit<T>(array: T[], indices: number[]): T[];
|
||||||
|
/**
|
||||||
|
* * Safely retrieves a value from a nested array/object structure (Safe Navigation).
|
||||||
|
* * Mirrors object.get.
|
||||||
|
* @example get(users, '0.profile.name') => Returns the name of the first user.
|
||||||
|
* @param array The array.
|
||||||
|
* @param path The path as a dot-notation string.
|
||||||
|
* @returns The found value or undefined.
|
||||||
|
*/
|
||||||
|
export declare function get(array: any[], path: string): any;
|
||||||
|
/**
|
||||||
|
* * Sets a value deeply within a nested array/object structure.
|
||||||
|
* * Mirrors object.set.
|
||||||
|
* @example set(users, '0.profile.name', 'Sven')
|
||||||
|
* @param array The array to modify.
|
||||||
|
* @param path The path as a string (e.g., '0.profile.name').
|
||||||
|
* @param value The value to set.
|
||||||
|
*/
|
||||||
|
export declare function set(array: any[], path: string, value: any): void;
|
||||||
|
/**
|
||||||
|
* * Removes elements based on index or match logic.
|
||||||
|
*/
|
||||||
|
export declare const remove: {
|
||||||
|
/**
|
||||||
|
* * Removes an element at a specific index.
|
||||||
|
* @example remove.at([1, 2, 3, 4], -2) => [1, 2, 4]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param index The index (negative values allowed).
|
||||||
|
* @returns A new array with the element removed.
|
||||||
|
*/
|
||||||
|
at<T>(array: T[], index: number): T[];
|
||||||
|
/**
|
||||||
|
* * Removes the first element.
|
||||||
|
* @example remove.first([1, 2, 3]) => [2, 3]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
*/
|
||||||
|
first<T>(array: T[]): T[];
|
||||||
|
/**
|
||||||
|
* * Removes the last element.
|
||||||
|
* @example remove.last([1, 2, 3]) => [1, 2]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
*/
|
||||||
|
last<T>(array: T[]): T[];
|
||||||
|
/**
|
||||||
|
* * Removes all elements matching a query condition.
|
||||||
|
* @example remove.byMatch(users, 'Admin', 'exact', 'role')
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
*/
|
||||||
|
byMatch<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[];
|
||||||
|
/**
|
||||||
|
* * Removes the element at a specific index.
|
||||||
|
* * Mirrors object.remove.byKey.
|
||||||
|
* @example remove.byKey(['a', 'b', 'c'], 1) => ['a', 'c']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param index The index (key) to remove.
|
||||||
|
* @returns A new array without the specified index.
|
||||||
|
*/
|
||||||
|
byKey<T>(array: T[], index: number): T[];
|
||||||
|
/**
|
||||||
|
* * Removes all elements that match a specific value exactly (Strict Equality).
|
||||||
|
* * Mirrors object.remove.byValue.
|
||||||
|
* @example remove.byValue([1, 2, 1, 3], 1) => [2, 3]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param value The value to remove.
|
||||||
|
* @returns A new array without the matching values.
|
||||||
|
*/
|
||||||
|
byValue<T>(array: T[], value: T): T[];
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear. Removes all elements.
|
||||||
|
* @param array The source array.
|
||||||
|
* @returns A new, empty array.
|
||||||
|
*/
|
||||||
|
all<T>(array: T[]): T[];
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* * Searches for elements in the array.
|
||||||
|
*/
|
||||||
|
export declare const find: {
|
||||||
|
/**
|
||||||
|
* * Finds the index of the first match.
|
||||||
|
* @example find.at(['apple', 'banana', 'cherry'], 'an', 'contains') => 1
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
at<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number;
|
||||||
|
/**
|
||||||
|
* * Returns all elements matching the condition (Filter).
|
||||||
|
* @example find.all(['apple', 'banana', 'cherry'], 'a', 'contains') => ['apple', 'banana']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns All matching elements or -1.
|
||||||
|
*/
|
||||||
|
all<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[];
|
||||||
|
/**
|
||||||
|
* * Returns the first matching element (or undefined).
|
||||||
|
* @example find.first(['apple', 'banana', 'cherry'], 'a', 'contains') => 'apple'
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
first<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined;
|
||||||
|
/**
|
||||||
|
* * Returns the last matching element (or undefined).
|
||||||
|
* @example find.last(['apple', 'banana', 'cherry'], 'a', 'contains') => 'banana'
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
last<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined;
|
||||||
|
/**
|
||||||
|
* * Finds all indices (keys) matching the query.
|
||||||
|
* * Mirrors object.find.key(). For arrays, keys are the indices.
|
||||||
|
* @param array The array to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode.
|
||||||
|
* @returns An array of matching indices as strings.
|
||||||
|
*/
|
||||||
|
key<T>(array: T[], query: string, mode?: MatchMode): string[];
|
||||||
|
/**
|
||||||
|
* * Finds all values matching the query.
|
||||||
|
* * Mirrors object.find.value(). Identical to find.all() for flat arrays.
|
||||||
|
* @param array The array to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode.
|
||||||
|
* @returns An array of matching values.
|
||||||
|
*/
|
||||||
|
value<T>(array: T[], query: string, mode?: MatchMode): T[];
|
||||||
|
/**
|
||||||
|
* * Finds the key of the first match based on the query condition.
|
||||||
|
* @example find.byMatch(users, 'Admin', 'exact', 'role') => 0
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
byMatch<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number | undefined;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=arrays.d.ts.map
|
||||||
1
dist/modules/data/arrays.d.ts.map
vendored
Normal file
1
dist/modules/data/arrays.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../../src/modules/data/arrays.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAMxD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAEnD;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,mBAAa,CAAC;AAEhC;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,GAAE,MAAqB,GAAG,CAAC,EAAE,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAExC;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,cAAQ,CAAC;AAE3B;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1D;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAWhE;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;IACf;;;;;;;OAOG;OACA,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,CAAC,EAAE;IASrC;;;;;OAKG;UACG,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE;IAEzB;;;;;OAKG;SACE,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE;IAExB;;;;;;;;OAQG;YACK,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,QAAkB,MAAM,CAAC,GAAG,CAAC,EAAE;IAe7F;;;;;;;;OAQG;UACG,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,CAAC,EAAE;IAIxC;;;;;;;;OAQG;YACK,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE;IAIrC;;;;OAIG;QACC,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE;CAG1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,IAAI;IACb;;;;;;;;;OASG;OACA,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,QAAkB,MAAM,CAAC,GAAG,MAAM;IAe3F;;;;;;;;;OASG;QACC,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,QAAkB,MAAM,CAAC,GAAG,CAAC,EAAE;IAezF;;;;;;;;;OASG;UACG,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,QAAkB,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS;IAerG;;;;;;;;;OASG;SACE,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,QAAkB,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS;IAepG;;;;;;;OAOG;QACC,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,SAAQ,SAAS,GAAa,MAAM,EAAE;IActE;;;;;;;OAOG;UACG,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,SAAQ,SAAS,GAAa,CAAC,EAAE;IAInE;;;;;;;;;OASG;YACK,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,QAAkB,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS;CAc/G,CAAC"}
|
||||||
227
dist/modules/data/index.d.ts
vendored
Normal file
227
dist/modules/data/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,227 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/index.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* * @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Central entry point for data manipulation.
|
||||||
|
* * Features a dynamic, overloaded API router that automatically delegates
|
||||||
|
* * to array or object utilities based on the input type.
|
||||||
|
* @requires ./arrays
|
||||||
|
* * Array manipulation methods.
|
||||||
|
* @requires ./objects
|
||||||
|
* * Object manipulation methods.
|
||||||
|
*/
|
||||||
|
import * as arr from './arrays';
|
||||||
|
import * as obj from './objects';
|
||||||
|
import { MatchMode } from './types';
|
||||||
|
/**
|
||||||
|
* * Splits an array or object into smaller chunks (batched processing).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param size The maximum size/length of each chunk.
|
||||||
|
* @returns An array containing the chunked arrays or partial objects.
|
||||||
|
*/
|
||||||
|
declare function chunk<T>(array: T[], size: number): T[][];
|
||||||
|
declare function chunk<T extends Record<string, any>>(object: T, size: number): Partial<T>[];
|
||||||
|
/**
|
||||||
|
* * Merges multiple arrays (flat) or objects (deep merge) into a single structure.
|
||||||
|
* @param data The target array or object.
|
||||||
|
* @param args The source arrays or objects to merge.
|
||||||
|
* @returns The newly merged array or modified target object.
|
||||||
|
*/
|
||||||
|
declare function merge(...arrays: any[][]): any[];
|
||||||
|
declare function merge(target: any, ...sources: any[]): any;
|
||||||
|
/**
|
||||||
|
* * Safely adds an element/property at a specific index without mutating the original structure (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param arg1 The item to add (array) or the key to add (object).
|
||||||
|
* @param arg2 The index (array) or the value to add (object).
|
||||||
|
* @param arg3 The index (object only).
|
||||||
|
* @returns A new array or object including the added element.
|
||||||
|
*/
|
||||||
|
declare function add<T>(array: T[], item: T, index?: number): T[];
|
||||||
|
declare function add<T extends Record<string, any>>(object: T, key: string, value: any, index?: number): T & Record<string, any>;
|
||||||
|
/**
|
||||||
|
* * Clears the array or object and returns a new empty one (Immutable).
|
||||||
|
* @param data The array or object to clear.
|
||||||
|
* @returns A new empty array `[]` or object `{}`.
|
||||||
|
*/
|
||||||
|
declare function clear<T>(array: T[]): T[];
|
||||||
|
declare function clear<T extends Record<string, any>>(object: T): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Creates a new array or object containing ONLY the specified indices/keys (Allowlist).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param keysOrIndices Array of keys (object) or indices (array) to keep.
|
||||||
|
* @returns A new filtered array or object.
|
||||||
|
*/
|
||||||
|
declare function pick<T>(array: T[], indices: number[]): T[];
|
||||||
|
declare function pick<T extends object, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
||||||
|
/**
|
||||||
|
* * Creates a new array or object containing all elements EXCEPT the specified indices/keys (Blocklist).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param keysOrIndices Array of keys (object) or indices (array) to remove.
|
||||||
|
* @returns A new filtered array or object.
|
||||||
|
*/
|
||||||
|
declare function omit<T>(array: T[], indices: number[]): T[];
|
||||||
|
declare function omit<T extends object, K extends keyof T>(object: T, keys: K[]): Omit<T, K>;
|
||||||
|
/**
|
||||||
|
* * Safely retrieves a value from a nested array/object structure using dot-notation.
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param path The path string (e.g., 'settings.theme' or '0.profile.name').
|
||||||
|
* @returns The found value or undefined if any part is missing.
|
||||||
|
*/
|
||||||
|
declare function get(array: any[], path: string): any;
|
||||||
|
declare function get(object: any, path: string): any;
|
||||||
|
/**
|
||||||
|
* * Sets a value deeply within a nested structure. Creates missing objects/arrays automatically.
|
||||||
|
* @param data The array or object to modify.
|
||||||
|
* @param path The path string (e.g., 'settings.theme').
|
||||||
|
* @param value The value to set.
|
||||||
|
*/
|
||||||
|
declare function set(array: any[], path: string, value: any): void;
|
||||||
|
declare function set(object: any, path: string, value: any): void;
|
||||||
|
/**
|
||||||
|
* * Removes an entry/element at a specific index (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param index The index to remove (negative values count from the end).
|
||||||
|
* @returns A new array or object without the specified element.
|
||||||
|
*/
|
||||||
|
declare function removeAt<T>(array: T[], index: number): T[];
|
||||||
|
declare function removeAt<T extends Record<string, any>>(object: T, index: number): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes the first entry/element (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @returns A new array or object without the first element.
|
||||||
|
*/
|
||||||
|
declare function removeFirst<T>(array: T[]): T[];
|
||||||
|
declare function removeFirst<T extends Record<string, any>>(object: T): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes the last entry/element (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @returns A new array or object without the last element.
|
||||||
|
*/
|
||||||
|
declare function removeLast<T>(array: T[]): T[];
|
||||||
|
declare function removeLast<T extends Record<string, any>>(object: T): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes all entries/elements matching a query condition (Immutable). Acts as an inverse filter.
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param query The search term.
|
||||||
|
* @param mode Comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns A new array or object containing only the non-matching elements.
|
||||||
|
*/
|
||||||
|
declare function removeByMatch<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[];
|
||||||
|
declare function removeByMatch<T extends Record<string, any>>(object: T, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes a specific element by its index (arrays) or key (objects) (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param keyOrIndex The index or key string to remove.
|
||||||
|
* @returns A new array or object without the specified property/element.
|
||||||
|
*/
|
||||||
|
declare function removeByKey<T>(array: T[], index: number): T[];
|
||||||
|
declare function removeByKey<T extends Record<string, any>>(object: T, key: string): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes all elements/entries that match a specific value exactly (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param value The exact value to remove (strict equality).
|
||||||
|
* @returns A new array or object without the matching values.
|
||||||
|
*/
|
||||||
|
declare function removeByValue<T>(array: T[], value: T): T[];
|
||||||
|
declare function removeByValue<T extends Record<string, any>>(object: T, value: any): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Arrays: Finds the index of the first match. Objects: Returns the n-th [key, value] tuple.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param arg1 Query term (array) or numeric index (object).
|
||||||
|
* @returns The index (array) or tuple (object), or undefined.
|
||||||
|
*/
|
||||||
|
declare function findAt<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number;
|
||||||
|
declare function findAt(object: any, index: number): [string, any] | undefined;
|
||||||
|
/**
|
||||||
|
* * Returns ALL elements/entries matching the condition. Similar to filter().
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @param mode Comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns A new array or partial object containing the matching elements.
|
||||||
|
*/
|
||||||
|
declare function findAll<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[];
|
||||||
|
declare function findAll<T extends Record<string, any>>(object: T, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Returns the FIRST matching element (array) or [key, value] tuple (object).
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns The found element/tuple or undefined.
|
||||||
|
*/
|
||||||
|
declare function findFirst<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined;
|
||||||
|
declare function findFirst(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): [string, any] | undefined;
|
||||||
|
/**
|
||||||
|
* * Returns the LAST matching element (array) or [key, value] tuple (object). Searches in reverse.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns The found element/tuple or undefined.
|
||||||
|
*/
|
||||||
|
declare function findLast<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined;
|
||||||
|
declare function findLast(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): [string, any] | undefined;
|
||||||
|
/**
|
||||||
|
* * Finds all matching indices (arrays) or keys (objects) based on the query.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns An array of matching stringified keys/indices.
|
||||||
|
*/
|
||||||
|
declare function findKey<T>(array: T[], query: string, mode?: MatchMode): string[];
|
||||||
|
declare function findKey(object: any, query: string, mode?: MatchMode): string[];
|
||||||
|
/**
|
||||||
|
* * Finds all matching values within the array or object.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns An array of matching values.
|
||||||
|
*/
|
||||||
|
declare function findValue<T>(array: T[], query: string, mode?: MatchMode): T[];
|
||||||
|
declare function findValue(object: any, query: string, mode?: MatchMode): any[];
|
||||||
|
/**
|
||||||
|
* * Finds the index (array) or key (object) of the first match based on the query condition.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns The matching index/key or undefined.
|
||||||
|
*/
|
||||||
|
declare function findByMatch<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number | undefined;
|
||||||
|
declare function findByMatch(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): string | undefined;
|
||||||
|
/**
|
||||||
|
* * Central data utility object.
|
||||||
|
* * Dynamically routes to array or object methods based on input.
|
||||||
|
* * Backward compatibility for strict calls is maintained via `.arr` and `.obj`.
|
||||||
|
*/
|
||||||
|
export declare const data: {
|
||||||
|
arr: typeof arr;
|
||||||
|
obj: typeof obj;
|
||||||
|
chunk: typeof chunk;
|
||||||
|
merge: typeof merge;
|
||||||
|
add: typeof add;
|
||||||
|
clear: typeof clear;
|
||||||
|
empty: typeof clear;
|
||||||
|
pick: typeof pick;
|
||||||
|
omit: typeof omit;
|
||||||
|
get: typeof get;
|
||||||
|
set: typeof set;
|
||||||
|
remove: {
|
||||||
|
at: typeof removeAt;
|
||||||
|
first: typeof removeFirst;
|
||||||
|
last: typeof removeLast;
|
||||||
|
byKey: typeof removeByKey;
|
||||||
|
byValue: typeof removeByValue;
|
||||||
|
byMatch: typeof removeByMatch;
|
||||||
|
all: typeof clear;
|
||||||
|
};
|
||||||
|
find: {
|
||||||
|
at: typeof findAt;
|
||||||
|
all: typeof findAll;
|
||||||
|
first: typeof findFirst;
|
||||||
|
last: typeof findLast;
|
||||||
|
key: typeof findKey;
|
||||||
|
value: typeof findValue;
|
||||||
|
byMatch: typeof findByMatch;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
dist/modules/data/index.d.ts.map
vendored
Normal file
1
dist/modules/data/index.d.ts.map
vendored
Normal file
File diff suppressed because one or more lines are too long
223
dist/modules/data/objects.d.ts
vendored
Normal file
223
dist/modules/data/objects.d.ts
vendored
Normal file
|
|
@ -0,0 +1,223 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/objects.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Utility functions for object manipulation (e.g., deep merging, extension).
|
||||||
|
* @requires ./types
|
||||||
|
* * Depends on types.
|
||||||
|
* @requires src/utils
|
||||||
|
* * Depends on utility functions (e.g., each).
|
||||||
|
*/
|
||||||
|
import { MatchMode } from './types';
|
||||||
|
/**
|
||||||
|
* * Recursively merges multiple objects (Deep Merge).
|
||||||
|
* @example mergeObjects({ a: 1, b: { x: 1 } }, { b: { y: 2 } }) => { a: 1, b: { x: 1, y: 2 } }
|
||||||
|
* @param target The target object (will be modified!).
|
||||||
|
* @param sources One or more source objects.
|
||||||
|
* @returns The modified target object.
|
||||||
|
*/
|
||||||
|
export declare function mergeObjects(target: any, ...sources: any[]): any;
|
||||||
|
/**
|
||||||
|
* * ALIAS for mergeObjects (Consistency with array.mergeArray)
|
||||||
|
*/
|
||||||
|
export declare const merge: typeof mergeObjects;
|
||||||
|
/**
|
||||||
|
* * Splits an object into an array of smaller objects (chunks). Ideal for batched processing.
|
||||||
|
* @example chunk({a: 1, b: 2, c: 3}, 2) => [{a: 1, b: 2}, {c: 3}]
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param size The maximum number of keys per chunk.
|
||||||
|
* @returns An array of partial objects.
|
||||||
|
*/
|
||||||
|
export declare function chunk<T extends Record<string, any>>(obj: T, size: number): Partial<T>[];
|
||||||
|
/**
|
||||||
|
* * Safely adds a key-value pair at a specific index without mutating the original object (Immutable).
|
||||||
|
* * Note: While JS object key order is generally insertion-based, relying on it is not always recommended.
|
||||||
|
* @example add({a: 1, c: 3}, 'b', 2, 1) => {a: 1, b: 2, c: 3}
|
||||||
|
* @param obj The object.
|
||||||
|
* @param key The key to add.
|
||||||
|
* @param value The value to add.
|
||||||
|
* @param index The position (default: end). Negative values count from the back.
|
||||||
|
* @returns A new object including the element at the specified position.
|
||||||
|
*/
|
||||||
|
export declare function add<T extends Record<string, any>>(obj: T, key: string, value: any, index?: number): T & Record<string, any>;
|
||||||
|
/**
|
||||||
|
* * Clears the object and returns a new empty object (Immutable).
|
||||||
|
* @example clear({ a: 1, b: 2 }) => {}
|
||||||
|
* @template T The type of the object.
|
||||||
|
* @param obj The object to clear.
|
||||||
|
* @returns A new empty object.
|
||||||
|
*/
|
||||||
|
export declare function clear<T extends Record<string, any>>(obj: T): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear.
|
||||||
|
*/
|
||||||
|
export declare const empty: typeof clear;
|
||||||
|
/**
|
||||||
|
* * Creates a new object containing only the specified keys (Allowlist).
|
||||||
|
* @example pick({ a: 1, b: 2, c: 3 }, ['a', 'c']) => { a: 1, c: 3 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param keys Array of keys to keep.
|
||||||
|
* @returns A new object with selected keys.
|
||||||
|
*/
|
||||||
|
export declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
||||||
|
/**
|
||||||
|
* * Creates a new object containing all keys EXCEPT the specified ones (Blocklist).
|
||||||
|
* @example omit({ a: 1, b: 2, c: 3 }, ['b']) => { a: 1, c: 3 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param keys Array of keys to remove.
|
||||||
|
* @returns A new object without the specified keys.
|
||||||
|
*/
|
||||||
|
export declare function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
||||||
|
/**
|
||||||
|
* * Safely retrieves a value from a nested object (Safe Navigation).
|
||||||
|
* @example get(config, 'settings.theme.color') => Returns the value of config.settings.theme.color or undefined if any part is missing.
|
||||||
|
* @param obj The object.
|
||||||
|
* @param path The path as a dot-notation string.
|
||||||
|
* @returns The found value or undefined.
|
||||||
|
*/
|
||||||
|
export declare function get(obj: any, path: string): any;
|
||||||
|
/**
|
||||||
|
* * Sets a value deeply within a nested object. Creates missing intermediate objects automatically.
|
||||||
|
* @example set(config, 'settings.theme.color', 'dark') => Sets config.settings.theme.color to 'dark', creating objects if needed.
|
||||||
|
* @param obj The object to modify.
|
||||||
|
* @param path The path as a string (e.g., 'settings.theme.color').
|
||||||
|
* @param value The value to set.
|
||||||
|
*/
|
||||||
|
export declare function set(obj: any, path: string, value: any): void;
|
||||||
|
/**
|
||||||
|
* * Removes elements from an object based on index or match logic (Immutable).
|
||||||
|
* * Mirrors the array.remove API.
|
||||||
|
*/
|
||||||
|
export declare const remove: {
|
||||||
|
/**
|
||||||
|
* * Removes an entry at a specific index.
|
||||||
|
* @example remove.at({a: 1, b: 2, c: 3}, -1) => {a: 1, b: 2}
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param index The index (negative values allowed).
|
||||||
|
* @returns A new object with the element removed.
|
||||||
|
*/
|
||||||
|
at<T extends Record<string, any>>(obj: T, index: number): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes the first entry from the object.
|
||||||
|
* @param obj The source object.
|
||||||
|
* @returns A new object without the first entry.
|
||||||
|
*/
|
||||||
|
first<T extends Record<string, any>>(obj: T): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes the last entry from the object.
|
||||||
|
* @param obj The source object.
|
||||||
|
* @returns A new object without the last entry.
|
||||||
|
*/
|
||||||
|
last<T extends Record<string, any>>(obj: T): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes all entries matching a query condition.
|
||||||
|
* @example remove.byMatch(config, 'hidden', 'exact', 'key')
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value' (default: 'key').
|
||||||
|
* @returns A new object without the matching elements.
|
||||||
|
*/
|
||||||
|
byMatch<T extends Record<string, any>>(obj: T, query: string | number, mode?: MatchMode, searchBy?: "key" | "value"): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes all entries that have a specific key.
|
||||||
|
* @example remove.byKey({ a: 1, b: 2, c: 3 }, 'b') => { a: 1, c: 3 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param key The key to remove.
|
||||||
|
* @returns A new object without the specified key.
|
||||||
|
*/
|
||||||
|
byKey<T extends Record<string, any>>(obj: T, key: string): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Removes all entries that match a specific value exactly (Strict Equality).
|
||||||
|
* @example remove.byValue({ a: 1, b: 2, c: 1 }, 1) => { b: 2 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param value The value to remove.
|
||||||
|
* @returns A new object without the matching values.
|
||||||
|
*/
|
||||||
|
byValue<T extends Record<string, any>>(obj: T, value: any): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear. Removes all entries.
|
||||||
|
* @param obj The source object.
|
||||||
|
* @returns A new, empty object.
|
||||||
|
*/
|
||||||
|
all<T extends Record<string, any>>(obj: T): Partial<T>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* * Searches keys or values in the object.
|
||||||
|
*/
|
||||||
|
export declare const find: {
|
||||||
|
/**
|
||||||
|
* * Returns the n-th entry of an object as a [key, value] pair. Supports negative indices.
|
||||||
|
* @example find.at({ a: 1, b: 2 }, 1) => ['b', 2]
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param index The index (0-based, negative counts from the back).
|
||||||
|
* @returns A [key, value] tuple or undefined.
|
||||||
|
*/
|
||||||
|
at(obj: any, index: number): [string, any] | undefined;
|
||||||
|
/**
|
||||||
|
* * Returns a NEW OBJECT containing ALL elements matching the condition.
|
||||||
|
* * Mirrors array.find.all() but returns a partial object.
|
||||||
|
* @example find.all({a: 1, b: 2, c: 1}, 1, 'exact', 'value') => {a: 1, c: 1}
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value' (default: 'key').
|
||||||
|
* @returns A new object with only the matching elements.
|
||||||
|
*/
|
||||||
|
all<T extends Record<string, any>>(obj: T, query: string | number, mode?: MatchMode, searchBy?: "key" | "value"): Partial<T>;
|
||||||
|
/**
|
||||||
|
* * Finds the first entry where the key or value matches the query.
|
||||||
|
* @example find.first(config, 'admin', 'exact', 'key')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value'.
|
||||||
|
* @returns The first matching [key, value] pair or undefined.
|
||||||
|
*/
|
||||||
|
first(obj: any, query: string | number, mode?: MatchMode, searchBy?: "key" | "value"): [string, any] | undefined;
|
||||||
|
/**
|
||||||
|
* * Finds the last entry where the key or value matches the query.
|
||||||
|
* @example find.last(config, '.php', 'endsWith', 'key')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value'.
|
||||||
|
* @returns The last matching [key, value] pair or undefined.
|
||||||
|
*/
|
||||||
|
last(obj: any, query: string | number, mode?: MatchMode, searchBy?: "key" | "value"): [string, any] | undefined;
|
||||||
|
/**
|
||||||
|
* * Finds all keys matching the query.
|
||||||
|
* @example find.key(config, 'api_', 'startsWith')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns An array of matching keys.
|
||||||
|
*/
|
||||||
|
key(obj: any, query: string, mode?: MatchMode): string[];
|
||||||
|
/**
|
||||||
|
* * Finds all values matching the query.
|
||||||
|
* @example find.value(config, 'enabled', 'exact')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns An array of matching values.
|
||||||
|
*/
|
||||||
|
value(obj: any, query: string, mode?: MatchMode): any[];
|
||||||
|
/**
|
||||||
|
* * Finds the key of the first match based on the query condition.
|
||||||
|
* * Mirrors array.find.byMatch(). For objects, it returns the key instead of a numeric index.
|
||||||
|
* @example find.byMatch(config, 'admin', 'exact', 'value') => 'role'
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value' (default: 'key').
|
||||||
|
* @returns The matched key as a string, or undefined if no match is found.
|
||||||
|
*/
|
||||||
|
byMatch(obj: any, query: string | number, mode?: MatchMode, searchBy?: "key" | "value"): string | undefined;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=objects.d.ts.map
|
||||||
1
dist/modules/data/objects.d.ts.map
vendored
Normal file
1
dist/modules/data/objects.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/modules/data/objects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAapC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,CAkBhE;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,qBAAe,CAAC;AAElC;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAQvF;AAED;;;;;;;;;GASG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAE,MAAgC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAKpJ;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEvE;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,cAAQ,CAAC;AAE3B;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAMvF;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAMxE;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAS5D;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM;IACf;;;;;;OAMG;OACA,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,SAAS,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IASpE;;;;OAIG;UACG,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxD;;;;OAIG;SACE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKvD;;;;;;;;OAQG;YACK,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,aAAsB,KAAK,GAAG,OAAO,GAAW,OAAO,CAAC,CAAC,CAAC;IAgBhJ;;;;;;OAMG;UACG,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAMrE;;;;;;OAMG;YACK,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE;;;;OAIG;QACC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAGzD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,IAAI;IACb;;;;;;OAMG;YACK,GAAG,SAAS,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS;IAMtD;;;;;;;;;OASG;QACC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,aAAsB,KAAK,GAAG,OAAO,GAAW,OAAO,CAAC,CAAC,CAAC;IAgB5I;;;;;;;;OAQG;eACQ,GAAG,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,aAAsB,KAAK,GAAG,OAAO,GAAW,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS;IAkBhI;;;;;;;;OAQG;cACO,GAAG,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,aAAsB,KAAK,GAAG,OAAO,GAAW,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS;IAkB/H;;;;;;;OAOG;aACM,GAAG,SAAS,MAAM,SAAQ,SAAS,GAAa,MAAM,EAAE;IAejE;;;;;;;OAOG;eACQ,GAAG,SAAS,MAAM,SAAQ,SAAS,GAAa,GAAG,EAAE;IAehE;;;;;;;;;OASG;iBACU,GAAG,SAAS,MAAM,GAAG,MAAM,SAAQ,SAAS,aAAsB,KAAK,GAAG,OAAO,GAAW,MAAM,GAAG,SAAS;CAmB9H,CAAC"}
|
||||||
16
dist/modules/data/types.d.ts
vendored
Normal file
16
dist/modules/data/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/types.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Type definitions and validation helpers for data structures.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Defines the matching modes for search operations.
|
||||||
|
*/
|
||||||
|
export type MatchMode = 'exact' | 'contains' | 'startsWith' | 'endsWith';
|
||||||
|
//# sourceMappingURL=types.d.ts.map
|
||||||
1
dist/modules/data/types.d.ts.map
vendored
Normal file
1
dist/modules/data/types.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/data/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,CAAC"}
|
||||||
50
dist/modules/dom/attributes.d.ts
vendored
Normal file
50
dist/modules/dom/attributes.d.ts
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/dom/attributes.ts
|
||||||
|
* @version 2.1.1
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category DOM
|
||||||
|
* @description
|
||||||
|
* * Methods for getting and setting HTML attributes and properties (attr, data, val).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Gets an attribute from the first element or sets it for all elements in the selection.
|
||||||
|
* @example attr('href', 'https://example.com') => Sets the 'href' attribute to 'https://example.com' for all matched elements.
|
||||||
|
* @example attr('href') => Returns the 'href' attribute value of the first matched element.
|
||||||
|
* @param name The name of the attribute (e.g., 'href', 'data-id').
|
||||||
|
* @param value (Optional) The value to set. If undefined, acts as a getter.
|
||||||
|
* @returns The attribute value (string/null) when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export declare function attr(this: jBase, name: string, value?: string): string | null | jBase;
|
||||||
|
/**
|
||||||
|
* * Gets the 'value' from the first form element or sets it for all elements. Supports Input, Textarea, and Select elements.
|
||||||
|
* @example val('Hello') => Sets the value of all matched form elements to 'Hello'.
|
||||||
|
* @example val() => Returns the value of the first matched form element.
|
||||||
|
* @param value (Optional) The value to set. If undefined, acts as a getter.
|
||||||
|
* @returns The current value as a string when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export declare function val(this: jBase, value?: string): string | jBase;
|
||||||
|
/**
|
||||||
|
* * Removes an attribute from all elements in the selection.
|
||||||
|
* @example removeAttr('disabled') => Removes the 'disabled' attribute from all matched elements.
|
||||||
|
* @param name The name of the attribute to remove (e.g., 'disabled', 'readonly').
|
||||||
|
* @returns The jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
export declare function removeAttr(this: jBase, name: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets a property from the first element or sets it for all elements in the selection.
|
||||||
|
* * Useful for DOM properties that don't directly map to HTML attributes (like 'checked' or 'selectedIndex').
|
||||||
|
* @example prop('checked', true) => Sets the 'checked' property to true for all matched elements (e.g., checkboxes).
|
||||||
|
* @example prop('checked') => Returns the 'checked' property value of the first matched element.
|
||||||
|
* @example prop('selectedIndex', 2) => Sets the 'selectedIndex' property to 2 for all matched <select> elements.
|
||||||
|
* @param name The name of the property (e.g., 'checked', 'disabled').
|
||||||
|
* @param value (Optional) The value to set. If undefined, acts as a getter.
|
||||||
|
* @returns The property value when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export declare function prop(this: jBase, name: string, value?: any): any | jBase;
|
||||||
|
//# sourceMappingURL=attributes.d.ts.map
|
||||||
1
dist/modules/dom/attributes.d.ts.map
vendored
Normal file
1
dist/modules/dom/attributes.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAUrF;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAe/D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAK3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,KAAK,CAYxE"}
|
||||||
46
dist/modules/dom/content.d.ts
vendored
Normal file
46
dist/modules/dom/content.d.ts
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/dom/content.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category DOM
|
||||||
|
* @description
|
||||||
|
* * Methods for getting and setting element content (html, text, empty, replaceWith).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Gets the HTML content of the first element, or sets the HTML content of all matched elements.
|
||||||
|
* @example html() => Returns the innerHTML of the first element.
|
||||||
|
* @example html('<div>New</div>') => Sets safe HTML for all matched elements.
|
||||||
|
* @example html('<script>alert("Hi")</script>', { executeScripts: true }) => Injects and executes scripts.
|
||||||
|
* @param content The HTML string to set. If undefined, acts as a getter.
|
||||||
|
* @param options Security and execution options.
|
||||||
|
* @returns HTML string (getter) or the current jBase instance (setter).
|
||||||
|
*/
|
||||||
|
export declare function html(this: jBase, content?: string, options?: {
|
||||||
|
executeScripts?: boolean;
|
||||||
|
}): string | jBase;
|
||||||
|
/**
|
||||||
|
* * Gets the text content of the first element or sets it for all elements. Safe against XSS attacks.
|
||||||
|
* @example text('Hello World') => Sets the text content of all matched elements to 'Hello World'.
|
||||||
|
* @example text() => Returns the text content of the first matched element.
|
||||||
|
* @param content (Optional) The text content to set.
|
||||||
|
* @returns The text content (getter) or the current jBase instance (setter).
|
||||||
|
*/
|
||||||
|
export declare function text(this: jBase, content?: string): string | jBase;
|
||||||
|
/**
|
||||||
|
* * Loads HTML from a server and injects it into the matched elements.
|
||||||
|
* * This is now a clean wrapper around $.http.getText() and this.html().
|
||||||
|
* @example $('#content').load('/pages/about.html')
|
||||||
|
* @param url The URL to fetch the HTML from.
|
||||||
|
* @param options Fetch options extended with jBase specific settings (e.g., executeScripts).
|
||||||
|
* @returns A Promise resolving to the current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function load(this: jBase, url: string, options?: RequestInit & {
|
||||||
|
executeScripts?: boolean;
|
||||||
|
}): Promise<jBase>;
|
||||||
|
//# sourceMappingURL=content.d.ts.map
|
||||||
1
dist/modules/dom/content.d.ts.map
vendored
Normal file
1
dist/modules/dom/content.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAmCnC;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,GAAG,KAAK,CAmB1G;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAWlE;AAED;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAazH"}
|
||||||
83
dist/modules/dom/index.d.ts
vendored
Normal file
83
dist/modules/dom/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/dom/index.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category DOM
|
||||||
|
* @description
|
||||||
|
* * Central entry point for DOM operations. Aggregates methods for attributes, content, manipulation, traversal, and states.
|
||||||
|
* @requires ./attributes
|
||||||
|
* * Attribute and value manipulation.
|
||||||
|
* @requires ./content
|
||||||
|
* * Content handling (html, text).
|
||||||
|
* @requires ./manipulation
|
||||||
|
* * DOM manipulation (append, remove, etc.).
|
||||||
|
* @requires ./traversal
|
||||||
|
* * Tree traversal (find, parent, children).
|
||||||
|
* @requires ./states
|
||||||
|
* * State checks (checked, disabled).
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Aggregation of all DOM methods. Bundles specialized sub-modules into a single interface. Used to extend the jBase prototype centrally via Object.assign.
|
||||||
|
*/
|
||||||
|
export declare const domMethods: {
|
||||||
|
checked(this: import("../..").JBaseClass, state?: boolean): boolean | import("../..").JBaseClass;
|
||||||
|
selected(this: import("../..").JBaseClass, state?: boolean): boolean | import("../..").JBaseClass;
|
||||||
|
disabled(this: import("../..").JBaseClass, state?: boolean): boolean | import("../..").JBaseClass;
|
||||||
|
check(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
uncheck(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
select(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
disable(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
enable(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
closest(this: import("../..").JBaseClass, selector: string): import("../..").JBaseClass;
|
||||||
|
parent(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
children(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
findAll(this: import("../..").JBaseClass, selector: string): import("../..").JBaseClass;
|
||||||
|
descendants(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
parents(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
parentsUntil(this: import("../..").JBaseClass, selector: string, filter?: string): import("../..").JBaseClass;
|
||||||
|
descendantsUntil(this: import("../..").JBaseClass, untilSelector: string, filter?: string): import("../..").JBaseClass;
|
||||||
|
next(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
prev(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
nextSibling(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
prevSibling(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
sibling(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
nextAll(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
prevAll(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
siblings(this: import("../..").JBaseClass, selector?: string): import("../..").JBaseClass;
|
||||||
|
nextUntil(this: import("../..").JBaseClass, untilSelector: string, filter?: string): import("../..").JBaseClass;
|
||||||
|
prevUntil(this: import("../..").JBaseClass, untilSelector: string, filter?: string): import("../..").JBaseClass;
|
||||||
|
eq(this: import("../..").JBaseClass, index: number): import("../..").JBaseClass;
|
||||||
|
first(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
last(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
filterBy(this: import("../..").JBaseClass, selectorOrFn: string | ((index: number, element: Element) => boolean)): import("../..").JBaseClass;
|
||||||
|
not(this: import("../..").JBaseClass, selectorOrFn: string | ((index: number, element: Element) => boolean)): import("../..").JBaseClass;
|
||||||
|
remove(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
empty(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
replaceWithClone(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
append(this: import("../..").JBaseClass, content: string | Node | import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
prepend(this: import("../..").JBaseClass, content: string | Node | import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
before(this: import("../..").JBaseClass, content: string | Node | import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
after(this: import("../..").JBaseClass, content: string | Node | import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
replaceWith(this: import("../..").JBaseClass, content: string | Node | import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
appendTo(this: import("../..").JBaseClass, target: string | Element): import("../..").JBaseClass;
|
||||||
|
prependTo(this: import("../..").JBaseClass, target: string | Element): import("../..").JBaseClass;
|
||||||
|
insertBefore(this: import("../..").JBaseClass, target: string | Element): import("../..").JBaseClass;
|
||||||
|
insertAfter(this: import("../..").JBaseClass, target: string | Element): import("../..").JBaseClass;
|
||||||
|
wrap(this: import("../..").JBaseClass, wrapperHtml: string): import("../..").JBaseClass;
|
||||||
|
unwrap(this: import("../..").JBaseClass): import("../..").JBaseClass;
|
||||||
|
html(this: import("../..").JBaseClass, content?: string, options?: {
|
||||||
|
executeScripts?: boolean;
|
||||||
|
}): string | import("../..").JBaseClass;
|
||||||
|
text(this: import("../..").JBaseClass, content?: string): string | import("../..").JBaseClass;
|
||||||
|
load(this: import("../..").JBaseClass, url: string, options?: RequestInit & {
|
||||||
|
executeScripts?: boolean;
|
||||||
|
}): Promise<import("../..").JBaseClass>;
|
||||||
|
attr(this: import("../..").JBaseClass, name: string, value?: string): string | null | import("../..").JBaseClass;
|
||||||
|
val(this: import("../..").JBaseClass, value?: string): string | import("../..").JBaseClass;
|
||||||
|
removeAttr(this: import("../..").JBaseClass, name: string): import("../..").JBaseClass;
|
||||||
|
prop(this: import("../..").JBaseClass, name: string, value?: any): any | import("../..").JBaseClass;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
dist/modules/dom/index.d.ts.map
vendored
Normal file
1
dist/modules/dom/index.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAMimC,CAAC;;;;sBAAo2D,CAAC;;;;;;CAA79F,CAAC"}
|
||||||
111
dist/modules/dom/manipulation.d.ts
vendored
Normal file
111
dist/modules/dom/manipulation.d.ts
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/dom/manipulation.ts
|
||||||
|
* @version 2.0.4
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category DOM
|
||||||
|
* @description
|
||||||
|
* * Methods for inserting, moving, and removing elements (append, prepend, remove).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
* @requires src/utils
|
||||||
|
* * Depends on utility functions (e.g., each).
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Removes the selected elements from the DOM.
|
||||||
|
* @example remove() => Removes all matched elements from the DOM.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function remove(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Removes all child nodes and text content from the selected elements.
|
||||||
|
* @example empty() => Empties the content of all matched elements, leaving them in the DOM.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function empty(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Replaces each element with a deep clone of itself. Useful for removing all event listeners ("Nuke" strategy).
|
||||||
|
* @example replaceWithClone() => Replaces each matched element with a clone, effectively removing all event listeners.
|
||||||
|
* @returns A new jBase instance containing the cloned elements.
|
||||||
|
*/
|
||||||
|
export declare function replaceWithClone(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Inserts content at the end of each selected element (inside).
|
||||||
|
* @example append('<span>New</span>') => Appends a new <span> element to the end of each matched element.
|
||||||
|
* @param content HTML string, DOM Node, or jBase collection.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function append(this: jBase, content: string | Node | jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Inserts content at the beginning of each selected element (inside).
|
||||||
|
* @example prepend('<span>New</span>') => Prepends a new <span> element to the beginning of each matched element.
|
||||||
|
* @param content HTML string, DOM Node, or jBase collection.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function prepend(this: jBase, content: string | Node | jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Inserts content before the element (outside).
|
||||||
|
* @example before('<div>New</div>') => Inserts a new <div> element immediately before each matched element.
|
||||||
|
* @param content HTML string, DOM Node, or jBase collection.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function before(this: jBase, content: string | Node | jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Inserts content after the element (outside).
|
||||||
|
* @example after('<div>New</div>') => Inserts a new <div> element immediately after each matched element.
|
||||||
|
* @param content HTML string, DOM Node, or jBase collection.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function after(this: jBase, content: string | Node | jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Replaces the element with new content.
|
||||||
|
* @example replaceWith('<div>New</div>') => Replaces each matched element with a new <div> element.
|
||||||
|
* @param content The new content.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function replaceWith(this: jBase, content: string | Node | jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Appends the selected elements to the end of a target element.
|
||||||
|
* @example appendTo('#container') => Appends all matched elements to the element with id 'container'.
|
||||||
|
* @param target CSS selector or DOM element.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function appendTo(this: jBase, target: string | Element): jBase;
|
||||||
|
/**
|
||||||
|
* * Prepends the selected elements to the beginning of a target element.
|
||||||
|
* @example prependTo('#container') => Prepends all matched elements to the element with id 'container', before its existing content.
|
||||||
|
* @param target CSS selector or DOM element.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function prependTo(this: jBase, target: string | Element): jBase;
|
||||||
|
/**
|
||||||
|
* * Inserts the selected elements immediately before the target element.
|
||||||
|
* @example insertBefore('#target') => Inserts all matched elements immediately before the element with id 'target'.
|
||||||
|
* @param target CSS selector or DOM element.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function insertBefore(this: jBase, target: string | Element): jBase;
|
||||||
|
/**
|
||||||
|
* * Inserts the selected elements immediately after the target element.
|
||||||
|
* @example insertAfter('#target') => Inserts all matched elements immediately after the element with id 'target'.
|
||||||
|
* @param target CSS selector or DOM element.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function insertAfter(this: jBase, target: string | Element): jBase;
|
||||||
|
/**
|
||||||
|
* * Wraps each selected element with the specified HTML structure.
|
||||||
|
* @example wrap('<div class="box"></div>') => Wraps each matched element with a <div class="box"></div> element.
|
||||||
|
* @param wrapperHtml HTML string defining the wrapper (e.g., `<div class="box"></div>`).
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function wrap(this: jBase, wrapperHtml: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Removes the direct parent of the selected elements from the DOM.
|
||||||
|
* * @example unwrap() => Removes the parent element of each matched element, effectively "unwrapping" it from its container.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function unwrap(this: jBase): jBase;
|
||||||
|
//# sourceMappingURL=manipulation.d.ts.map
|
||||||
1
dist/modules/dom/manipulation.d.ts.map
vendored
Normal file
1
dist/modules/dom/manipulation.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"manipulation.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/manipulation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA6DnC;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAKzC;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAKxC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAUnD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAsBzE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAsB1E;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAsBzE;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAsBxE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAa9E;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,CAarE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,CAatE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,CAazE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,CAaxE;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,KAAK,CAc5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAiBzC"}
|
||||||
69
dist/modules/dom/states.d.ts
vendored
Normal file
69
dist/modules/dom/states.d.ts
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/dom/states.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category DOM
|
||||||
|
* @description
|
||||||
|
* * Methods for checking element states (e.g., visibility, checked, disabled).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Gets or sets the 'checked' state of checkboxes and radio buttons.
|
||||||
|
* @example checked() => Gets the checked state of the first matched element.
|
||||||
|
* @example checked(true) => Checks the first matched element.
|
||||||
|
* @param state (Optional) `true` to check, `false` to uncheck. If undefined, acts as a getter.
|
||||||
|
* @returns Boolean (getter) or the current jBase instance (setter).
|
||||||
|
*/
|
||||||
|
export declare function checked(this: jBase, state?: boolean): boolean | jBase;
|
||||||
|
/**
|
||||||
|
* * Gets or sets the 'selected' state of `<option>` elements.
|
||||||
|
* @example selected() => Gets the selected state of the first matched option element.
|
||||||
|
* @example selected(true) => Selects the first matched option element.
|
||||||
|
* @param state (Optional) `true` to select, `false` to deselect. If undefined, acts as a getter.
|
||||||
|
* @returns Boolean (getter) or the current jBase instance (setter).
|
||||||
|
*/
|
||||||
|
export declare function selected(this: jBase, state?: boolean): boolean | jBase;
|
||||||
|
/**
|
||||||
|
* * Enables or disables form fields and buttons. Additionally toggles the CSS class `.disabled`.
|
||||||
|
* @example disabled() => Gets the disabled state of the first matched element.
|
||||||
|
* @example disabled(true) => Disables the first matched element.
|
||||||
|
* @param state (Optional) `true` to disable, `false` to enable. If undefined, acts as a getter.
|
||||||
|
* @returns Boolean (getter) or the current jBase instance (setter).
|
||||||
|
*/
|
||||||
|
export declare function disabled(this: jBase, state?: boolean): boolean | jBase;
|
||||||
|
/**
|
||||||
|
* * ALIAS for .checked(true). Checks the matched elements.
|
||||||
|
* @example check() => Checks all matched checkboxes/radio buttons.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function check(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * ALIAS for .checked(false). Unchecks the matched elements.
|
||||||
|
* @example uncheck() => Unchecks all matched checkboxes/radio buttons.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function uncheck(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * ALIAS for .selected(true). Selects the matched <option> elements.
|
||||||
|
* @example select() => Selects all matched option elements.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function select(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * ALIAS for .disabled(true). Disables the matched elements and adds the 'disabled' class.
|
||||||
|
* @example disable() => Disables all matched elements.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function disable(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * ALIAS for .disabled(false). Enables the matched elements and removes the 'disabled' class.
|
||||||
|
* @example enable() => Enables all matched elements.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function enable(this: jBase): jBase;
|
||||||
|
//# sourceMappingURL=states.d.ts.map
|
||||||
1
dist/modules/dom/states.d.ts.map
vendored
Normal file
1
dist/modules/dom/states.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"states.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/states.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,CAUrE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,CAUtE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,CAetE;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAExC;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAEzC"}
|
||||||
184
dist/modules/dom/traversal.d.ts
vendored
Normal file
184
dist/modules/dom/traversal.d.ts
vendored
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/dom/traversal.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category DOM
|
||||||
|
* @description
|
||||||
|
* * Methods for navigating the DOM tree (find, parent, children, siblings).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
* @requires ../../utils
|
||||||
|
* * Utility functions (e.g., `each` for iteration).
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Traverses the parents (heading toward the document root) of each element and finds the first element that matches the specified selector.
|
||||||
|
* @example closest('.container') => For each matched element, finds the nearest ancestor with the class 'container'.
|
||||||
|
* @param selector A string containing a selector expression.
|
||||||
|
* @returns A new jBase instance containing the matched elements.
|
||||||
|
*/
|
||||||
|
export declare function closest(this: jBase, selector: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets the direct parent of each element in the current set. Deduplicates results.
|
||||||
|
* @example parent() => Returns a new jBase instance containing the parent elements of all matched elements, without duplicates.
|
||||||
|
* @returns A new jBase instance containing the parent elements.
|
||||||
|
*/
|
||||||
|
export declare function parent(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets the direct children of each element in the set, optionally filtered by a selector.
|
||||||
|
* @example children() => Returns a new jBase instance containing all direct children of the matched elements.
|
||||||
|
* @example children('.item') => Returns a new jBase instance containing only the direct children that match the selector '.item'.
|
||||||
|
* @param selector (Optional) Filter selector.
|
||||||
|
* @returns A new jBase instance containing the children.
|
||||||
|
*/
|
||||||
|
export declare function children(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Finds descendants (deep) that match the selector using `querySelectorAll`.
|
||||||
|
* @example findAll('.item') => Returns a new jBase instance containing all descendant elements that match the selector '.item'.
|
||||||
|
* @param selector The CSS selector to search for.
|
||||||
|
* @returns A new jBase instance with the found elements.
|
||||||
|
*/
|
||||||
|
export declare function findAll(this: jBase, selector: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Recursively gets ALL descendants (not just direct children).
|
||||||
|
* @example descendants() => Returns a new jBase instance containing all descendant elements of the matched elements.
|
||||||
|
* @returns A new jBase instance with all descendants.
|
||||||
|
*/
|
||||||
|
export declare function descendants(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets all ancestors (parents, grandparents...) up to the root. Optionally filtered.
|
||||||
|
* @example parents() => Returns a new jBase instance containing all ancestors of the matched elements, without duplicates.
|
||||||
|
* @example parents('.container') => Returns a new jBase instance containing only the ancestors that match the selector '.container'.
|
||||||
|
* @param selector (Optional) Filter selector for ancestors.
|
||||||
|
* @returns A new jBase instance with the ancestors.
|
||||||
|
*/
|
||||||
|
export declare function parents(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets all ancestors UP TO (but not including) an element matching the selector.
|
||||||
|
* @example parentsUntil('.container') => Returns a new jBase instance containing all ancestors of the matched elements up to (but not including) the nearest ancestor that matches '.container'.
|
||||||
|
* @example parentsUntil('.container', '.item') => Returns a new jBase instance containing ancestors up to '.container' that also match '.item'.
|
||||||
|
* @param selector The selector where traversal stops.
|
||||||
|
* @param filter (Optional) Filter for the collected elements.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function parentsUntil(this: jBase, selector: string, filter?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Recursively finds descendants but stops traversing a branch if `untilSelector` is met. Useful for finding nested elements without going too deep (e.g., nested forms).
|
||||||
|
* @example descendantsUntil('.stop-here') => Returns a new jBase instance containing all descendant elements of the matched elements, but does not include any elements that are descendants of an element matching '.stop-here'.
|
||||||
|
* @example descendantsUntil('.stop-here', '.item') => Returns a new jBase instance containing descendant elements that match '.item', but does not include any elements that are descendants of an element matching '.stop-here'.
|
||||||
|
* @param untilSelector The selector that stops recursion in a branch.
|
||||||
|
* @param filter (Optional) Selector to filter collected elements.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function descendantsUntil(this: jBase, untilSelector: string, filter?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets the immediately following sibling.
|
||||||
|
* @example next() => Returns a new jBase instance containing the immediately following sibling of each matched element.
|
||||||
|
* @example next('.item') => Returns a new jBase instance containing the immediately following sibling that matches the selector '.item'.
|
||||||
|
* @param selector (Optional) Filter selector.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function next(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets the immediately preceding sibling.
|
||||||
|
* @example prev() => Returns a new jBase instance containing the immediately preceding sibling of each matched element.
|
||||||
|
* @example prev('.item') => Returns a new jBase instance containing the immediately preceding sibling that matches the selector '.item'.
|
||||||
|
* @param selector (Optional) Filter selector.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function prev(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Alias for `next()`.
|
||||||
|
*/
|
||||||
|
export declare function nextSibling(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Alias for `prev()`.
|
||||||
|
*/
|
||||||
|
export declare function prevSibling(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Alias for `next()`.
|
||||||
|
*/
|
||||||
|
export declare function sibling(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets ALL following siblings.
|
||||||
|
* @example nextAll() => Returns a new jBase instance containing all following siblings of each matched element.
|
||||||
|
* @example nextAll('.item') => Returns a new jBase instance containing all following siblings that match the selector '.item'.
|
||||||
|
* @param selector (Optional) Filter selector.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function nextAll(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets ALL preceding siblings.
|
||||||
|
* @example prevAll() => Returns a new jBase instance containing all preceding siblings of each matched element.
|
||||||
|
* @example prevAll('.item') => Returns a new jBase instance containing all preceding siblings that match the selector '.item'.
|
||||||
|
* @param selector (Optional) Filter selector.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function prevAll(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets ALL siblings (previous and next), excluding itself.
|
||||||
|
* @example siblings() => Returns a new jBase instance containing all siblings of each matched element, without duplicates.
|
||||||
|
* @example siblings('.item') => Returns a new jBase instance containing all siblings that match the selector '.item', without duplicates.
|
||||||
|
* @param selector (Optional) Filter selector.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function siblings(this: jBase, selector?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets all following siblings UNTIL a selector is met (exclusive).
|
||||||
|
* @example nextUntil('.stop-here') => Returns a new jBase instance containing all following siblings of the matched elements up to (but not including) the nearest sibling that matches '.stop-here'.
|
||||||
|
* @example nextUntil('.stop-here', '.item') => Returns a new jBase instance containing following siblings that match '.item' up to (but not including) the nearest sibling that matches '.stop-here'.
|
||||||
|
* @param untilSelector The selector that stops the search.
|
||||||
|
* @param filter (Optional) Filter for the found elements.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function nextUntil(this: jBase, untilSelector: string, filter?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Gets all preceding siblings UNTIL a selector is met (exclusive).
|
||||||
|
* @example prevUntil('.stop-here') => Returns a new jBase instance containing all preceding siblings of the matched elements up to (but not including) the nearest sibling that matches '.stop-here'.
|
||||||
|
* @example prevUntil('.stop-here', '.item') => Returns a new jBase instance containing preceding siblings that match '.item' up to (but not including) the nearest sibling that matches '.stop-here'.
|
||||||
|
* @param untilSelector The selector that stops the search.
|
||||||
|
* @param filter (Optional) Filter for the found elements.
|
||||||
|
* @returns A new jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function prevUntil(this: jBase, untilSelector: string, filter?: string): jBase;
|
||||||
|
/**
|
||||||
|
* * Reduces the set to the element at the specified index. Supports negative indices.
|
||||||
|
* @example eq(0) => Returns a new jBase instance containing only the first element of the matched set.
|
||||||
|
* @example eq(-1) => Returns a new jBase instance containing only the last element of the matched set.
|
||||||
|
* @param index The position (0-based). Negative values count from the end.
|
||||||
|
* @returns A new jBase instance containing the single element (or empty).
|
||||||
|
*/
|
||||||
|
export declare function eq(this: jBase, index: number): jBase;
|
||||||
|
/**
|
||||||
|
* * Reduces the set of matched elements to the first one in the collection.
|
||||||
|
* @example first() => Returns a new jBase instance containing only the first element of the matched set.
|
||||||
|
* @param selector (Optional) Filter selector to find the first matching element.
|
||||||
|
* @returns A new jBase instance containing only the first element, allowing for further method chaining.
|
||||||
|
*/
|
||||||
|
export declare function first(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Reduces the set of matched elements to the final one in the collection.
|
||||||
|
* @example last() => Returns a new jBase instance containing only the last element of the matched set.
|
||||||
|
* @returns A new jBase instance containing only the last element, allowing for further method chaining.
|
||||||
|
*/
|
||||||
|
export declare function last(this: jBase): jBase;
|
||||||
|
/**
|
||||||
|
* * Filters elements based on a selector or a function.
|
||||||
|
* @example filterBy('.active') => Returns a new jBase instance containing only the elements that match the selector '.active'.
|
||||||
|
* @example filterBy((index, el) => el.textContent.includes('Hello')) => Returns a new jBase instance containing only the elements for which the function returns true.
|
||||||
|
* @param selectorOrFn CSS selector string or filter function.
|
||||||
|
* @returns A new jBase instance with filtered elements.
|
||||||
|
*/
|
||||||
|
export declare function filterBy(this: jBase, selectorOrFn: string | ((index: number, element: Element) => boolean)): jBase;
|
||||||
|
/**
|
||||||
|
* * Removes elements from the set that match the selector or function (Inverse of filterBy).
|
||||||
|
* @example not('.active') => Returns a new jBase instance containing only the elements that do NOT match the selector '.active'.
|
||||||
|
* @example not((index, el) => el.textContent.includes('Hello')) => Returns a new jBase instance containing only the elements for which the function returns false.
|
||||||
|
* @param selectorOrFn CSS selector string or filter function.
|
||||||
|
* @returns A new jBase instance with remaining elements.
|
||||||
|
*/
|
||||||
|
export declare function not(this: jBase, selectorOrFn: string | ((index: number, element: Element) => boolean)): jBase;
|
||||||
|
//# sourceMappingURL=traversal.d.ts.map
|
||||||
1
dist/modules/dom/traversal.d.ts.map
vendored
Normal file
1
dist/modules/dom/traversal.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/traversal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAc5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CASzC;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAe9D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAY5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAE9C;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAgB7D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAelF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAsB3F;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAY1D;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAY1D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAEjE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAEjE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAe7D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAe7D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAgB9D;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAepF;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAepF;AAED;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAMpD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAExC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,CAEvC;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,KAAK,CAiBlH;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,KAAK,CAiB7G"}
|
||||||
60
dist/modules/effects/fade.d.ts
vendored
Normal file
60
dist/modules/effects/fade.d.ts
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/effects/fade.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Effects
|
||||||
|
* @description
|
||||||
|
* * Methods for fading elements in and out (fadeIn, fadeOut, fadeToggle).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
* @requires ../../utils
|
||||||
|
* * Uses utility functions for environment checks.
|
||||||
|
* @requires ./types
|
||||||
|
* * Type definitions for fade options.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
import { FadeOptions } from './types';
|
||||||
|
/**
|
||||||
|
* * Fades an element in (Opacity 0 -> 1).
|
||||||
|
* @example fadeIn() => Fades in all matched elements over 300ms with display: block.
|
||||||
|
* @example fadeIn({ duration: 500, displayType: 'inline-block' }) => Fades in all matched elements over 500ms with display: inline-block.
|
||||||
|
* @example fadeIn(500) => Fades in over 500ms.
|
||||||
|
* @param options Duration in ms (default: 300) and display type (default: 'block').
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function fadeIn(this: jBase, options?: FadeOptions | number): jBase;
|
||||||
|
/**
|
||||||
|
* * Fades an element out (Opacity 1 -> 0) and sets display: none afterwards.
|
||||||
|
* @example fadeOut() => Fades out all matched elements over 300ms with display: none.
|
||||||
|
* @example fadeOut({ duration: 500 }) => Fades out all matched elements over 500ms with display: none.
|
||||||
|
* @example fadeOut(500) => Fades out over 500ms.
|
||||||
|
* @param options Duration in ms (default: 300).
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function fadeOut(this: jBase, options?: FadeOptions | number): jBase;
|
||||||
|
/**
|
||||||
|
* * Toggles between fadeIn and fadeOut based on the current display state.
|
||||||
|
* @example fadeToggle() => Fades in hidden elements and fades out visible elements over 300ms.
|
||||||
|
* @example fadeToggle({ duration: 500 }) => Fades in hidden elements and fades out visible elements over 500ms.
|
||||||
|
* @example fadeToggle({ duration: 500, displayType: 'inline-block' }) => Fades in all matched elements over 500ms with display: inline-block.
|
||||||
|
* @example fadeToggle(500) => Fades in over 500ms.
|
||||||
|
* @param options Animation options.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function fadeToggle(this: jBase, options?: FadeOptions | number): jBase;
|
||||||
|
/**
|
||||||
|
* * ALIAS for fadeIn.
|
||||||
|
*/
|
||||||
|
export declare const show: typeof fadeIn;
|
||||||
|
/**
|
||||||
|
* * ALIAS for fadeOut.
|
||||||
|
*/
|
||||||
|
export declare const hide: typeof fadeOut;
|
||||||
|
/**
|
||||||
|
* * ALIAS for fadeToggle.
|
||||||
|
*/
|
||||||
|
export declare const toggle: typeof fadeToggle;
|
||||||
|
//# sourceMappingURL=fade.d.ts.map
|
||||||
1
dist/modules/effects/fade.d.ts.map
vendored
Normal file
1
dist/modules/effects/fade.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"fade.d.ts","sourceRoot":"","sources":["../../../src/modules/effects/fade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,WAAW,GAAG,MAAW,GAAG,KAAK,CA2B7E;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,WAAW,GAAG,MAAW,GAAG,KAAK,CA0B9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,WAAW,GAAG,MAAW,GAAG,KAAK,CAcjF;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,eAAS,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,IAAI,gBAAU,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,MAAM,mBAAa,CAAC"}
|
||||||
36
dist/modules/effects/index.d.ts
vendored
Normal file
36
dist/modules/effects/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/effects/index.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Effects
|
||||||
|
* @description
|
||||||
|
* * Central entry point for visual effects. Aggregates slide, fade, and vertical animation modules.
|
||||||
|
* @requires ./slide
|
||||||
|
* * Horizontal slide effects (slideIn, slideOut).
|
||||||
|
* @requires ./vertical
|
||||||
|
* * Vertical slide effects / Accordion (slideDown, slideUp).
|
||||||
|
* @requires ./fade
|
||||||
|
* * Opacity fade effects (fadeIn, fadeOut).
|
||||||
|
*/
|
||||||
|
import * as fadeMethods from './fade';
|
||||||
|
/**
|
||||||
|
* * Aggregation of all visual effect methods. Bundles sliding and fading animations to extend the jBase prototype.
|
||||||
|
*/
|
||||||
|
export declare const effectMethods: {
|
||||||
|
fadeIn(this: import("../..").JBaseClass, options?: import("./types").FadeOptions | number): import("../..").JBaseClass;
|
||||||
|
fadeOut(this: import("../..").JBaseClass, options?: import("./types").FadeOptions | number): import("../..").JBaseClass;
|
||||||
|
fadeToggle(this: import("../..").JBaseClass, options?: import("./types").FadeOptions | number): import("../..").JBaseClass;
|
||||||
|
show: typeof fadeMethods.fadeIn;
|
||||||
|
hide: typeof fadeMethods.fadeOut;
|
||||||
|
toggle: typeof fadeMethods.fadeToggle;
|
||||||
|
slideDown(this: import("../..").JBaseClass, options?: import("./types").SlideVerticalOptions): import("../..").JBaseClass;
|
||||||
|
slideUp(this: import("../..").JBaseClass, options?: import("./types").SlideVerticalOptions): import("../..").JBaseClass;
|
||||||
|
slideToggleBox(this: import("../..").JBaseClass, options?: import("./types").SlideVerticalOptions): import("../..").JBaseClass;
|
||||||
|
slideIn(this: import("../..").JBaseClass, options?: import("./types").SlideOptions): import("../..").JBaseClass;
|
||||||
|
slideOut(this: import("../..").JBaseClass, options?: import("./types").SlideOptions): import("../..").JBaseClass;
|
||||||
|
slideToggle(this: import("../..").JBaseClass, options?: import("./types").SlideOptions): import("../..").JBaseClass;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
dist/modules/effects/index.d.ts.map
vendored
Normal file
1
dist/modules/effects/index.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/effects/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,WAAW,MAAM,QAAQ,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;CAIzB,CAAC"}
|
||||||
44
dist/modules/effects/slide.d.ts
vendored
Normal file
44
dist/modules/effects/slide.d.ts
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/effects/slide.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Effects
|
||||||
|
* @description
|
||||||
|
* * Methods for horizontal sliding effects (slideIn, slideOut, slideToggle).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
* @requires ../../utils
|
||||||
|
* * Uses utility functions for environment checks.
|
||||||
|
* @requires ./types
|
||||||
|
* * Type definitions for slide options.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
import { SlideOptions } from './types';
|
||||||
|
/**
|
||||||
|
* * Slides an element (e.g., a menu) into view. Sets `transform: translateX(0)`.
|
||||||
|
* @example slideIn() => Slides in all matched elements over 300ms.
|
||||||
|
* @example slideIn({ duration: 500 }) => Slides in all matched elements over 500ms.
|
||||||
|
* @param options Direction ('left'|'right') and duration in ms.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function slideIn(this: jBase, options?: SlideOptions): jBase;
|
||||||
|
/**
|
||||||
|
* * Slides an element out of view.
|
||||||
|
* @example slideOut() => Slides out all matched elements to the left over 300ms.
|
||||||
|
* @example slideOut({ direction: 'right', duration: 500 }) => Slides out all matched elements to the right over 500ms.
|
||||||
|
* @param options Direction ('left'|'right') and duration in ms.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function slideOut(this: jBase, options?: SlideOptions): jBase;
|
||||||
|
/**
|
||||||
|
* * Toggles between slideIn and slideOut based on the current state.
|
||||||
|
* @example slideToggle() => Slides in hidden elements and slides out visible elements to the left over 300ms.
|
||||||
|
* @example slideToggle({ direction: 'right', duration: 500 }) => Slides in hidden elements and slides out visible elements to the right over 500ms.
|
||||||
|
* @param options Direction ('left'|'right') and duration in ms.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function slideToggle(this: jBase, options?: SlideOptions): jBase;
|
||||||
|
//# sourceMappingURL=slide.d.ts.map
|
||||||
1
dist/modules/effects/slide.d.ts.map
vendored
Normal file
1
dist/modules/effects/slide.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"slide.d.ts","sourceRoot":"","sources":["../../../src/modules/effects/slide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAkBtE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAmBvE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAkB1E"}
|
||||||
33
dist/modules/effects/types.d.ts
vendored
Normal file
33
dist/modules/effects/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/types.ts
|
||||||
|
* @version 2.0.2
|
||||||
|
* @since 2.0.2
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Type definitions and validation helpers for data structures.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Configuration options for fade effects.
|
||||||
|
*/
|
||||||
|
export interface FadeOptions {
|
||||||
|
duration?: number;
|
||||||
|
displayType?: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* * Configuration interface for slide methods.
|
||||||
|
*/
|
||||||
|
export interface SlideOptions {
|
||||||
|
direction?: 'left' | 'right';
|
||||||
|
duration?: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* * Configuration options for vertical slide effects.
|
||||||
|
*/
|
||||||
|
export interface SlideVerticalOptions {
|
||||||
|
duration?: number;
|
||||||
|
displayType?: string;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=types.d.ts.map
|
||||||
1
dist/modules/effects/types.d.ts.map
vendored
Normal file
1
dist/modules/effects/types.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/effects/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
||||||
44
dist/modules/effects/vertical.d.ts
vendored
Normal file
44
dist/modules/effects/vertical.d.ts
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/effects/vertical.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Effects
|
||||||
|
* @description
|
||||||
|
* * Methods for vertical sliding effects (slideDown, slideUp, slideToggle).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
* @requires ../../utils
|
||||||
|
* * Utility function to check for browser environment.
|
||||||
|
* @requires ./types
|
||||||
|
* * Type definitions for effect options.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
import { SlideVerticalOptions } from './types';
|
||||||
|
/**
|
||||||
|
* * Slides an element down (animates height from 0 to auto). Sets `display` property and animates height.
|
||||||
|
* @example slideDown() => Slides down all matched elements over 300ms with display: block.
|
||||||
|
* @example slideDown({ duration: 500, displayType: 'inline-block' }) => Slides down all matched elements over 500ms with display: inline-block.
|
||||||
|
* @param options Animation duration and display type.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function slideDown(this: jBase, options?: SlideVerticalOptions): jBase;
|
||||||
|
/**
|
||||||
|
* * Slides an element up (animates height to 0). Sets `display: none` after animation.
|
||||||
|
* @example slideUp() => Slides up all matched elements over 300ms with display: none.
|
||||||
|
* @example slideUp({ duration: 500 }) => Slides up all matched elements over 500ms with display: none.
|
||||||
|
* @param options Animation duration.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function slideUp(this: jBase, options?: SlideVerticalOptions): jBase;
|
||||||
|
/**
|
||||||
|
* * Toggles between slideDown and slideUp based on the display state.
|
||||||
|
* @example slideToggle() => Slides in hidden elements and slides out visible elements over 300ms.
|
||||||
|
* @example slideToggle({ duration: 500 }) => Slides in hidden elements and slides out visible elements over 500ms.
|
||||||
|
* @param options Animation duration.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function slideToggleBox(this: jBase, options?: SlideVerticalOptions): jBase;
|
||||||
|
//# sourceMappingURL=vertical.d.ts.map
|
||||||
1
dist/modules/effects/vertical.d.ts.map
vendored
Normal file
1
dist/modules/effects/vertical.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"vertical.d.ts","sourceRoot":"","sources":["../../../src/modules/effects/vertical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,oBAAyB,GAAG,KAAK,CA6BhF;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,oBAAyB,GAAG,KAAK,CAwB9E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,GAAE,oBAAyB,GAAG,KAAK,CAgBrF"}
|
||||||
66
dist/modules/events/binding.d.ts
vendored
Normal file
66
dist/modules/events/binding.d.ts
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/events/binding.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Events
|
||||||
|
* @description
|
||||||
|
* * Core event binding methods (on, off, trigger). Handles event registration and removal.
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
* @requires ../../utils
|
||||||
|
* * Uses utility functions for iteration and environment checks.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Attaches an event handler function for one or more events to the selected elements.
|
||||||
|
* * This core method handles dynamic event delegation and allows passing custom data.
|
||||||
|
* @example on('click', handler) => Binds a click event handler to all matched elements.
|
||||||
|
* @example on('click', '.btn', handler) => Binds a click event handler to all current and future elements matching '.btn' within the matched elements.
|
||||||
|
* @example on('click', { key: 'value' }, handler) => Binds a click event handler and passes custom data to the event object.
|
||||||
|
* @param events One or more space-separated event types (e.g., 'click', 'mouseenter mouseleave').
|
||||||
|
* @param selectorOrDataOrHandler A CSS selector string for delegation, custom data, or the callback function.
|
||||||
|
* @param dataOrHandler Custom data to pass to `event.data`, or the callback function.
|
||||||
|
* @param handlerOrUndefined The callback function to execute when the event is triggered.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function on(this: jBase, events: string, selectorOrDataOrHandler: any, dataOrHandler?: any, handlerOrUndefined?: any): jBase;
|
||||||
|
/**
|
||||||
|
* * Removes an event handler previously attached with `.on()`.
|
||||||
|
* * Can remove all handlers for an event, or specific ones by selector or handler reference.
|
||||||
|
* @example off('click') => Removes all click handlers from the matched elements.
|
||||||
|
* @example off('click', '.btn') => Removes all click handlers that were delegated to '.btn' within the matched elements.
|
||||||
|
* @example off('click', handler) => Removes the specific click handler function from the matched elements.
|
||||||
|
* @example off('click', '.btn', handler) => Removes the specific click handler function that was delegated to '.btn' within the matched elements.
|
||||||
|
* @param events One or more space-separated event types (e.g., 'click').
|
||||||
|
* @param selectorOrHandler A CSS selector string originally used for delegation, or the specific handler function.
|
||||||
|
* @param handlerOrUndefined The specific handler function to remove.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function off(this: jBase, events: string, selectorOrHandler?: any, handlerOrUndefined?: any): jBase;
|
||||||
|
/**
|
||||||
|
* * Attaches an event handler that will be executed at most once per element and event type.
|
||||||
|
* * Automatically unbinds itself after the first execution. Supports event delegation and custom data.
|
||||||
|
* @example once('click', handler) => Binds a click event handler that executes only once for all matched elements.
|
||||||
|
* @example once('click', '.btn', handler) => Binds a click event handler that executes only once for all current and future elements matching '.btn' within the matched elements.
|
||||||
|
* @example once('click', { key: 'value' }, handler) => Binds a click event handler that executes only once and passes custom data to the event object.
|
||||||
|
* @param events One or more space-separated event types.
|
||||||
|
* @param selectorOrDataOrHandler A CSS selector string for delegation, custom data, or the callback function.
|
||||||
|
* @param dataOrHandler Custom data to pass to `event.data`, or the callback function.
|
||||||
|
* @param handlerOrUndefined The callback function to execute when the event is triggered.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function once(this: jBase, events: string, selectorOrDataOrHandler: any, dataOrHandler?: any, handlerOrUndefined?: any): jBase;
|
||||||
|
/**
|
||||||
|
* * Triggers an event on each element in the collection.
|
||||||
|
* @example trigger('customEvent') => Triggers 'customEvent' on all matched elements.
|
||||||
|
* @example trigger('customEvent', { key: 'value' }) => Triggers 'customEvent' on all matched elements and passes custom data to the event object.
|
||||||
|
* @example trigger('click') => Programmatically triggers a click event on all matched elements.
|
||||||
|
* @example trigger('click', { key: 'value' }) => Programmatically triggers a click event on all matched elements and passes custom data to the event object.
|
||||||
|
* @param eventName The name of the event to trigger.
|
||||||
|
* @param data Optional data to pass to the event (accessible via event.detail).
|
||||||
|
*/
|
||||||
|
export declare function trigger(this: jBase, eventName: string, data?: any): jBase;
|
||||||
|
//# sourceMappingURL=binding.d.ts.map
|
||||||
1
dist/modules/events/binding.d.ts.map
vendored
Normal file
1
dist/modules/events/binding.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../../src/modules/events/binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC;;;;;;;;;;;GAWG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,GAAG,EAAE,kBAAkB,CAAC,EAAE,GAAG,GAAG,KAAK,CAiDlI;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,GAAG,EAAE,kBAAkB,CAAC,EAAE,GAAG,GAAG,KAAK,CA4BzG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,GAAG,EAAE,kBAAkB,CAAC,EAAE,GAAG,GAAG,KAAK,CAyBpI;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,KAAK,CAUzE"}
|
||||||
52
dist/modules/events/form.d.ts
vendored
Normal file
52
dist/modules/events/form.d.ts
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/events/form.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Events
|
||||||
|
* @description
|
||||||
|
* * Methods for handling form events (submit, change, focus, blur, input).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Registers an event handler for the 'submit' event. Triggered when a form is submitted.
|
||||||
|
* @example submit(handler) => Binds a submit event handler to all matched forms.
|
||||||
|
* @param handler The function to execute when the event occurs.
|
||||||
|
* @returns The current jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
export declare function submit(this: jBase, handler: (event: SubmitEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Registers an event handler for the 'change' event. Triggered when the value of an element (<input>, <select>, <textarea>) is changed by the user and committed (e.g., on blur).
|
||||||
|
* @example change(handler) => Binds a change event handler to all matched form elements.
|
||||||
|
* @param handler The function to execute when the event occurs.
|
||||||
|
* @returns The current jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
export declare function change(this: jBase, handler: (event: Event) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Registers an event handler for the 'input' event. Triggered immediately when the value changes (real-time, e.g., every keystroke).
|
||||||
|
* @example input(handler) => Binds an input event handler to all matched form elements.
|
||||||
|
* @param handler The function to execute when the event occurs.
|
||||||
|
* @returns The current jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
export declare function input(this: jBase, handler: (event: Event) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Handles the 'focus' event. If a handler is provided, it binds the listener. If no handler is provided, it programmatically sets focus on the element(s).
|
||||||
|
* @example focus(handler) => Binds a focus event handler to all matched elements.
|
||||||
|
* @example focus() => Programmatically focuses the first matched element.
|
||||||
|
* @param handler (Optional) The function to execute when the event occurs.
|
||||||
|
* @returns The current jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
export declare function focus(this: jBase, handler?: (event: FocusEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Handles the 'blur' event (element loses focus). If a handler is provided, it binds the listener. If no handler is provided, it programmatically removes focus.
|
||||||
|
* @example blur(handler) => Binds a blur event handler to all matched elements.
|
||||||
|
* @example blur() => Programmatically blurs the first matched element.
|
||||||
|
* @param handler (Optional) The function to execute when the event occurs.
|
||||||
|
* @returns The current jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
export declare function blur(this: jBase, handler?: (event: FocusEvent) => void): jBase;
|
||||||
|
//# sourceMappingURL=form.d.ts.map
|
||||||
1
dist/modules/events/form.d.ts.map
vendored
Normal file
1
dist/modules/events/form.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../src/modules/events/form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,KAAK,CAEhF;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,KAAK,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,KAAK,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAS/E;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAS9E"}
|
||||||
61
dist/modules/events/index.d.ts
vendored
Normal file
61
dist/modules/events/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/events/index.ts
|
||||||
|
* @version 2.0.2
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Events
|
||||||
|
* @description
|
||||||
|
* * Central entry point for event handling. Aggregates binding, mouse, lifecycle, keyboard, form, and touch events.
|
||||||
|
* @requires ./binding
|
||||||
|
* * General event binding (on, off).
|
||||||
|
* @requires ./mouse
|
||||||
|
* * Mouse interaction events (click, hover, etc.).
|
||||||
|
* @requires ./lifecycle
|
||||||
|
* * DOM lifecycle events (ready).
|
||||||
|
* @requires ./keyboard
|
||||||
|
* * Keyboard interaction events (keydown, keyup).
|
||||||
|
* @requires ./form
|
||||||
|
* * Form handling events (submit, change, input).
|
||||||
|
* @requires ./touch
|
||||||
|
* * Touch interaction events.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Aggregated object of all event methods. Combines logic from various sub-modules into a single object. Used to extend the `jBase` prototype via `Object.assign`.
|
||||||
|
*/
|
||||||
|
export declare const eventMethods: {
|
||||||
|
touchstart(this: import("../..").JBaseClass, handler: (event: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
touchend(this: import("../..").JBaseClass, handler: (event: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
touchmove(this: import("../..").JBaseClass, handler: (event: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
touchcancel(this: import("../..").JBaseClass, handler: (event: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
swipeLeft(this: import("../..").JBaseClass, handler: (e: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
swipeRight(this: import("../..").JBaseClass, handler: (e: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
swipeUp(this: import("../..").JBaseClass, handler: (e: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
swipeDown(this: import("../..").JBaseClass, handler: (e: TouchEvent) => void): import("../..").JBaseClass;
|
||||||
|
submit(this: import("../..").JBaseClass, handler: (event: SubmitEvent) => void): import("../..").JBaseClass;
|
||||||
|
change(this: import("../..").JBaseClass, handler: (event: Event) => void): import("../..").JBaseClass;
|
||||||
|
input(this: import("../..").JBaseClass, handler: (event: Event) => void): import("../..").JBaseClass;
|
||||||
|
focus(this: import("../..").JBaseClass, handler?: (event: FocusEvent) => void): import("../..").JBaseClass;
|
||||||
|
blur(this: import("../..").JBaseClass, handler?: (event: FocusEvent) => void): import("../..").JBaseClass;
|
||||||
|
keydown(this: import("../..").JBaseClass, handler: (event: KeyboardEvent) => void): import("../..").JBaseClass;
|
||||||
|
keyup(this: import("../..").JBaseClass, handler: (event: KeyboardEvent) => void): import("../..").JBaseClass;
|
||||||
|
keypress(this: import("../..").JBaseClass, handler: (event: KeyboardEvent) => void): import("../..").JBaseClass;
|
||||||
|
pressedKey(this: import("../..").JBaseClass, targetKey: string, handler: (event: KeyboardEvent) => void): import("../..").JBaseClass;
|
||||||
|
ready(this: import("../..").JBaseClass, handler: () => void): import("../..").JBaseClass;
|
||||||
|
click(this: import("../..").JBaseClass, handler?: (event: Event) => void): import("../..").JBaseClass;
|
||||||
|
mousemove(this: import("../..").JBaseClass, handler: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
mouseleave(this: import("../..").JBaseClass, handler: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
mouseenter(this: import("../..").JBaseClass, handler: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
mousedown(this: import("../..").JBaseClass, handler: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
mouseup(this: import("../..").JBaseClass, handler: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
dblclick(this: import("../..").JBaseClass, handler?: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
mouseout(this: import("../..").JBaseClass, handler: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
mouseover(this: import("../..").JBaseClass, handler: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
hover(this: import("../..").JBaseClass, handlerIn: (event: MouseEvent) => void, handlerOut: (event: MouseEvent) => void): import("../..").JBaseClass;
|
||||||
|
on(this: import("../..").JBaseClass, events: string, selectorOrDataOrHandler: any, dataOrHandler?: any, handlerOrUndefined?: any): import("../..").JBaseClass;
|
||||||
|
off(this: import("../..").JBaseClass, events: string, selectorOrHandler?: any, handlerOrUndefined?: any): import("../..").JBaseClass;
|
||||||
|
once(this: import("../..").JBaseClass, events: string, selectorOrDataOrHandler: any, dataOrHandler?: any, handlerOrUndefined?: any): import("../..").JBaseClass;
|
||||||
|
trigger(this: import("../..").JBaseClass, eventName: string, data?: any): import("../..").JBaseClass;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
dist/modules/events/index.d.ts.map
vendored
Normal file
1
dist/modules/events/index.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/events/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOxB,CAAC"}
|
||||||
44
dist/modules/events/keyboard.d.ts
vendored
Normal file
44
dist/modules/events/keyboard.d.ts
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/events/keyboard.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Events
|
||||||
|
* @description
|
||||||
|
* * Methods for handling keyboard events (keydown, keyup, keypress).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'keydown' event. Fires immediately when a key is pressed (repeats if held).
|
||||||
|
* @example keydown(handler) => Binds a keydown event handler to all matched elements.
|
||||||
|
* @param handler The callback function receiving the KeyboardEvent.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function keydown(this: jBase, handler: (event: KeyboardEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'keyup' event. Fires when a key is released.
|
||||||
|
* @example keyup(handler) => Binds a keyup event handler to all matched elements.
|
||||||
|
* @param handler The callback function receiving the KeyboardEvent.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function keyup(this: jBase, handler: (event: KeyboardEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'keypress' event. Deprecated in modern standards.
|
||||||
|
* @deprecated Use keydown or input instead.
|
||||||
|
* @param handler The callback function receiving the KeyboardEvent.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function keypress(this: jBase, handler: (event: KeyboardEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler for a specific key (case-insensitive).
|
||||||
|
* @example pressedKey('Enter', handler) => Binds a handler that executes when the Enter key is pressed on any matched element.
|
||||||
|
* @param targetKey The key to react to (e.g., 'm', 'Enter', 'Escape').
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function pressedKey(this: jBase, targetKey: string, handler: (event: KeyboardEvent) => void): jBase;
|
||||||
|
//# sourceMappingURL=keyboard.d.ts.map
|
||||||
1
dist/modules/events/keyboard.d.ts.map
vendored
Normal file
1
dist/modules/events/keyboard.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../../src/modules/events/keyboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,KAAK,CAEnF;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,KAAK,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,KAAK,CAEpF;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,KAAK,CAOzG"}
|
||||||
22
dist/modules/events/lifecycle.d.ts
vendored
Normal file
22
dist/modules/events/lifecycle.d.ts
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/events/lifecycle.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Events
|
||||||
|
* @description
|
||||||
|
* * Methods for handling DOM lifecycle events (e.g., ready).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Executes the handler as soon as the DOM is fully loaded and parsed. If the document is already ready (readyState 'interactive' or 'complete'), the handler executes immediately to avoid race conditions.
|
||||||
|
* @example ready(handler) => Binds a handler to execute when the DOM is ready.
|
||||||
|
* @param handler The callback function to execute when the DOM is ready.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function ready(this: jBase, handler: () => void): jBase;
|
||||||
|
//# sourceMappingURL=lifecycle.d.ts.map
|
||||||
1
dist/modules/events/lifecycle.d.ts.map
vendored
Normal file
1
dist/modules/events/lifecycle.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/modules/events/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,KAAK,CAQ7D"}
|
||||||
89
dist/modules/events/mouse.d.ts
vendored
Normal file
89
dist/modules/events/mouse.d.ts
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/events/mouse.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Events
|
||||||
|
* @description
|
||||||
|
* * Methods for handling mouse events (click, dblclick, hover, mouseenter, mouseleave).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the "click" JavaScript event, or triggers that event on an element.
|
||||||
|
* * If no handler is provided, it programmatically triggers a native click on all matched elements.
|
||||||
|
* @example click(handler) => Binds a click event handler to all matched elements.
|
||||||
|
* @example click() => Programmatically triggers a click event on all matched elements.
|
||||||
|
* @param handler (Optional) A function to execute each time the click event is triggered.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function click(this: jBase, handler?: (event: Event) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'mousemove' event. Fires continuously while the pointer moves inside the element.
|
||||||
|
* @example mousemove(handler) => Binds a mousemove event handler to all matched elements.
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function mousemove(this: jBase, handler: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'mouseleave' event. Fires when the pointer leaves the element (does not bubble).
|
||||||
|
* @example mouseleave(handler) => Binds a mouseleave event handler to all matched elements.
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function mouseleave(this: jBase, handler: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'mouseenter' event. Fires when the pointer enters the element (does not bubble).
|
||||||
|
* @example mouseenter(handler) => Binds a mouseenter event handler to all matched elements.
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function mouseenter(this: jBase, handler: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'mousedown' event. Fires as soon as a mouse button is pressed over the element.
|
||||||
|
* @example mousedown(handler) => Binds a mousedown event handler to all matched elements.
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function mousedown(this: jBase, handler: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'mouseup' event. Fires when a mouse button is released over the element.
|
||||||
|
* @example mouseup(handler) => Binds a mouseup event handler to all matched elements.
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function mouseup(this: jBase, handler: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'dblclick' event or triggers it manually.
|
||||||
|
* @example dblclick(handler) => Binds a dblclick event handler to all matched elements.
|
||||||
|
* @param handler (Optional) The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function dblclick(this: jBase, handler?: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'mouseout' event. Fires when the pointer leaves the element OR one of its children (bubbles).
|
||||||
|
* @example mouseout(handler) => Binds a mouseout event handler to all matched elements.
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function mouseout(this: jBase, handler: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'mouseover' event. Fires when the pointer enters the element OR one of its children (bubbles).
|
||||||
|
* @example mouseover(handler) => Binds a mouseover event handler to all matched elements.
|
||||||
|
* @param handler The callback function.
|
||||||
|
* @returns The current jBase instance.
|
||||||
|
*/
|
||||||
|
export declare function mouseover(this: jBase, handler: (event: MouseEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
|
||||||
|
* * This is a highly convenient shorthand for chaining `.mouseenter()` and `.mouseleave()`.
|
||||||
|
* @example hover(handlerIn, handlerOut) => Binds handlerIn to mouseenter and handlerOut to mouseleave for all matched elements.
|
||||||
|
* @param handlerIn A function to execute when the mouse pointer enters the element.
|
||||||
|
* @param handlerOut A function to execute when the mouse pointer leaves the element.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function hover(this: jBase, handlerIn: (event: MouseEvent) => void, handlerOut: (event: MouseEvent) => void): jBase;
|
||||||
|
//# sourceMappingURL=mouse.d.ts.map
|
||||||
1
dist/modules/events/mouse.d.ts.map
vendored
Normal file
1
dist/modules/events/mouse.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"mouse.d.ts","sourceRoot":"","sources":["../../../src/modules/events/mouse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,KAAK,CAS1E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEnF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEnF;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEhF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAelF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAElF;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEzH"}
|
||||||
75
dist/modules/events/touch.d.ts
vendored
Normal file
75
dist/modules/events/touch.d.ts
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/events/touch.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Events
|
||||||
|
* @description
|
||||||
|
* * Methods for handling touch events (touchstart, touchend, touchmove).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'touchstart' event. Triggered when a touch point is placed on the touch surface.
|
||||||
|
* @example touchstart(handler) => Binds a touchstart event handler to all matched elements.
|
||||||
|
* @param handler The callback function executed on touch start.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function touchstart(this: jBase, handler: (event: TouchEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'touchend' event. Triggered when a touch point is removed from the touch surface.
|
||||||
|
* @example touchend(handler) => Binds a touchend event handler to all matched elements.
|
||||||
|
* @param handler The callback function executed on touch end.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function touchend(this: jBase, handler: (event: TouchEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'touchmove' event. Triggered when a touch point moves along the touch surface. Important for swipe gestures or Drag & Drop.
|
||||||
|
* @example touchmove(handler) => Binds a touchmove event handler to all matched elements.
|
||||||
|
* @param handler The callback function executed on movement.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function touchmove(this: jBase, handler: (event: TouchEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to the 'touchcancel' event. Triggered when a touch point has been disrupted by the system (e.g., too many touch points or a UI popup).
|
||||||
|
* @example touchcancel(handler) => Binds a touchcancel event handler to all matched elements.
|
||||||
|
* @param handler The callback function executed on cancellation.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function touchcancel(this: jBase, handler: (event: TouchEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to be executed when the user swipes left across the selected elements.
|
||||||
|
* * The swipe must cover a minimum distance of 50 pixels to trigger.
|
||||||
|
* @example swipeLeft(handler) => Binds a handler to execute when a left swipe gesture is detected on all matched elements.
|
||||||
|
* @param handler A function to execute when the left swipe gesture is detected.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function swipeLeft(this: jBase, handler: (e: TouchEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to be executed when the user swipes right across the selected elements.
|
||||||
|
* * The swipe must cover a minimum distance of 50 pixels to trigger.
|
||||||
|
* @example swipeRight(handler) => Binds a handler to execute when a right swipe gesture is detected on all matched elements.
|
||||||
|
* @param handler A function to execute when the right swipe gesture is detected.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function swipeRight(this: jBase, handler: (e: TouchEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to be executed when the user swipes up across the selected elements.
|
||||||
|
* * The swipe must cover a minimum distance of 50 pixels to trigger.
|
||||||
|
* @example swipeUp(handler) => Binds a handler to execute when an upward swipe gesture is detected on all matched elements.
|
||||||
|
* @param handler A function to execute when the upward swipe gesture is detected.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function swipeUp(this: jBase, handler: (e: TouchEvent) => void): jBase;
|
||||||
|
/**
|
||||||
|
* * Binds an event handler to be executed when the user swipes down across the selected elements.
|
||||||
|
* * The swipe must cover a minimum distance of 50 pixels to trigger.
|
||||||
|
* @example swipeDown(handler) => Binds a handler to execute when a downward swipe gesture is detected on all matched elements.
|
||||||
|
* @param handler A function to execute when the downward swipe gesture is detected.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export declare function swipeDown(this: jBase, handler: (e: TouchEvent) => void): jBase;
|
||||||
|
//# sourceMappingURL=touch.d.ts.map
|
||||||
1
dist/modules/events/touch.d.ts.map
vendored
Normal file
1
dist/modules/events/touch.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"touch.d.ts","sourceRoot":"","sources":["../../../src/modules/events/touch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEnF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAEpF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAE9E;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAE/E;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAE9E"}
|
||||||
35
dist/modules/http/get.d.ts
vendored
Normal file
35
dist/modules/http/get.d.ts
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/http/get.ts
|
||||||
|
* @version 2.0.6
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category HTTP
|
||||||
|
* @description
|
||||||
|
* * Abstraction for HTTP GET requests.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Performs an asynchronous HTTP GET request and expects a JSON response. Includes an automatic timeout of 5000ms to avoid hanging requests.
|
||||||
|
* @example const data = await get<UserData>('/api/user/1'); => Fetches user data from the specified endpoint and parses it as JSON.
|
||||||
|
* @example const data = await get('/api/user/1', { signal: customAbortSignal }); => Fetches user data with a custom abort signal for cancellation.
|
||||||
|
* @template T The expected type of the response data (Generic).
|
||||||
|
* @param url The target URL for the request.
|
||||||
|
* @param option Optional RequestInit object to customize the fetch request.
|
||||||
|
* @returns A Promise resolving with the typed JSON data.
|
||||||
|
* @throws Error if HTTP status is not in success range (200-299) or a timeout occurs.
|
||||||
|
*/
|
||||||
|
export declare function get<T>(url: string, option?: RequestInit): Promise<T>;
|
||||||
|
/**
|
||||||
|
* * Performs an asynchronous HTTP GET request and returns the raw text content. Ideal for loading HTML fragments (Server-Side Rendering Partials) or plain text.
|
||||||
|
* @example const html = await getText('/templates/modal.html'); => Fetches an HTML template as a string for later insertion into the DOM.
|
||||||
|
* @example const text = await getText('/api/status'); => Fetches a plain text status message from the server.
|
||||||
|
* @example const html = await getText('/templates/modal.html', { signal: customAbortSignal }); => Fetches an HTML template with a custom abort signal for cancellation.
|
||||||
|
* @template T The expected type of the response data (Generic, defaults to string).
|
||||||
|
* @param url The target URL for the request.
|
||||||
|
* @param option Optional RequestInit object to customize the fetch request.
|
||||||
|
* @returns A Promise containing the response body as a string.
|
||||||
|
* @throws Error if HTTP status is not in success range (200-299).
|
||||||
|
*/
|
||||||
|
export declare function getText<T = string>(url: string, option?: RequestInit): Promise<T>;
|
||||||
|
//# sourceMappingURL=get.d.ts.map
|
||||||
1
dist/modules/http/get.d.ts.map
vendored
Normal file
1
dist/modules/http/get.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/modules/http/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AACH,wBAAsB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAoB1E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAoBvF"}
|
||||||
27
dist/modules/http/index.d.ts
vendored
Normal file
27
dist/modules/http/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/http/index.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category HTTP
|
||||||
|
* @description
|
||||||
|
* * Central entry point for HTTP requests. Aggregates GET and POST methods.
|
||||||
|
* @requires ./get
|
||||||
|
* * HTTP GET methods (get, getText).
|
||||||
|
* @requires ./post
|
||||||
|
* * HTTP POST methods.
|
||||||
|
* @requires ./upload
|
||||||
|
* * HTTP file upload method with progress tracking.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * The central HTTP client of the framework. Aggregates all HTTP methods (GET, POST, etc.) into a unified interface. Acts as a wrapper around the native `fetch` API to simplify JSON parsing, error handling, and typing.
|
||||||
|
*/
|
||||||
|
export declare const http: {
|
||||||
|
upload<T>(url: string, data: FormData | File, onProgress?: (percentage: number, loaded: number, total: number) => void): Promise<T>;
|
||||||
|
post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
|
||||||
|
get<T>(url: string, option?: RequestInit): Promise<T>;
|
||||||
|
getText<T = string>(url: string, option?: RequestInit): Promise<T>;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
dist/modules/http/index.d.ts.map
vendored
Normal file
1
dist/modules/http/index.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/http/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;CAIhB,CAAC"}
|
||||||
23
dist/modules/http/post.d.ts
vendored
Normal file
23
dist/modules/http/post.d.ts
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/http/post.ts
|
||||||
|
* @version 2.0.5
|
||||||
|
* @since 2.0.2
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category HTTP
|
||||||
|
* * @description
|
||||||
|
* * Abstraction for HTTP POST requests.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Performs an asynchronous HTTP POST request to the specified URL. Automatically sets the 'Content-Type' header to 'application/json' and serializes the body.
|
||||||
|
* @example const response = await post('/api/login', { username: 'user', password: 'pass' });
|
||||||
|
* @template T The expected response type (Generic).
|
||||||
|
* @param url The target URL for the request.
|
||||||
|
* @param body The data to send (automatically JSON serialized). Default is {}.
|
||||||
|
* @param option Optional RequestInit object to customize the fetch request.
|
||||||
|
* @returns A Promise resolving with the deserialized JSON response of type T.
|
||||||
|
* @throws Error if the HTTP status code is not in the range 200-299.
|
||||||
|
*/
|
||||||
|
export declare function post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
|
||||||
|
//# sourceMappingURL=post.d.ts.map
|
||||||
1
dist/modules/http/post.d.ts.map
vendored
Normal file
1
dist/modules/http/post.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/modules/http/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CA6B3F"}
|
||||||
30
dist/modules/http/upload.d.ts
vendored
Normal file
30
dist/modules/http/upload.d.ts
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/http/upload.ts
|
||||||
|
* @version 2.0.0
|
||||||
|
* @since 2.3.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category HTTP
|
||||||
|
* * @description
|
||||||
|
* * Abstraction for HTTP POST requests.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Performs a multipart/form-data upload with precise progress tracking.
|
||||||
|
* * Uses XMLHttpRequest under the hood because the native Fetch API lacks upload progress support.
|
||||||
|
* @example
|
||||||
|
* const fileInput = $('input[type="file"]')[0] as HTMLInputElement;
|
||||||
|
* if (fileInput && fileInput.files?.length) {
|
||||||
|
* await $.http.upload('/upload', fileInput.files[0], (percentage) => {
|
||||||
|
* // Update a progress bar using jBase
|
||||||
|
* $('#progress-bar').css('width', `${percentage}%`);
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
* @template T The expected response type (Generic).
|
||||||
|
* @param url The target endpoint.
|
||||||
|
* @param data A FormData object or a single File.
|
||||||
|
* @param onProgress Optional callback receiving the progress percentage (0-100), loaded bytes, and total bytes.
|
||||||
|
* @returns A Promise resolving to the parsed JSON response.
|
||||||
|
*/
|
||||||
|
export declare function upload<T>(url: string, data: FormData | File, onProgress?: (percentage: number, loaded: number, total: number) => void): Promise<T>;
|
||||||
|
//# sourceMappingURL=upload.d.ts.map
|
||||||
1
dist/modules/http/upload.d.ts.map
vendored
Normal file
1
dist/modules/http/upload.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/modules/http/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAoCxJ"}
|
||||||
13
dist/server.d.ts
vendored
Normal file
13
dist/server.d.ts
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* * Parses an HTML string on the server, allowing DOM manipulation.
|
||||||
|
* @param html The raw HTML string.
|
||||||
|
* @returns An object containing the window, document, and the jBase instance setup.
|
||||||
|
*/
|
||||||
|
export declare function parseHTML(html: string): {
|
||||||
|
$: (selector: import("./types").JBaseInput) => import("./core").jBase;
|
||||||
|
document: Document;
|
||||||
|
window: Window;
|
||||||
|
html: () => string;
|
||||||
|
close: () => void;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=server.d.ts.map
|
||||||
1
dist/server.d.ts.map
vendored
Normal file
1
dist/server.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM;;;;;;EAWrC"}
|
||||||
3027
dist/server.js
vendored
Normal file
3027
dist/server.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
7
dist/server.js.map
vendored
Normal file
7
dist/server.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
51
dist/types.d.ts
vendored
Normal file
51
dist/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
/**
|
||||||
|
* @file src/types.ts
|
||||||
|
* @version 2.0.2
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Types
|
||||||
|
* @description
|
||||||
|
* * Central type definitions, interfaces, and aliases for the jBase library.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Represents the basic DOM elements managed by a jBase instance. Includes standard HTML elements, the Document, the Window object, and generic elements (e.g., SVG).
|
||||||
|
*/
|
||||||
|
export type JBaseElement = HTMLElement | Document | Window | Element;
|
||||||
|
/**
|
||||||
|
* * Union type for all valid inputs to the main selector function $(...). Accepts CSS selectors (string), single DOM elements, NodeLists, Arrays, or null/undefined.
|
||||||
|
*/
|
||||||
|
export type JBaseInput = string | JBaseElement | NodeList | JBaseElement[] | null | undefined;
|
||||||
|
/**
|
||||||
|
* * Extracts valid CSS property names from the native CSSStyleDeclaration. Excludes methods (like setProperty) and numeric indices to ensure type safety and autocomplete.
|
||||||
|
*/
|
||||||
|
export type JBaseCSSProperty = Exclude<keyof CSSStyleDeclaration, 'length' | 'parentRule' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty' | number>;
|
||||||
|
/**
|
||||||
|
* * Extended event map linking native DOM events with framework-specific custom events. Serves as the base for generics in .on() and .off() to infer correct event types.
|
||||||
|
*/
|
||||||
|
export interface JBaseEventMap extends HTMLElementEventMap {
|
||||||
|
/**
|
||||||
|
* * Fired when the framework and DOM are fully initialized.
|
||||||
|
*/
|
||||||
|
'jbase:ready': CustomEvent;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* * Generic type for event handlers. Allows TypeScript to infer the 'event' parameter type based on the event name (K).
|
||||||
|
*/
|
||||||
|
export type JBaseEventHandler<K extends keyof JBaseEventMap> = (event: JBaseEventMap[K]) => void;
|
||||||
|
/**
|
||||||
|
* * Fallback type for generic event handlers where the specific event type is unknown.
|
||||||
|
*/
|
||||||
|
export type GenericEventHandler = (event: Event) => void;
|
||||||
|
/**
|
||||||
|
* * Standardized interface for API responses in the http module.
|
||||||
|
* @template T
|
||||||
|
* * The expected type of the data payload.
|
||||||
|
*/
|
||||||
|
export interface ApiResponse<T = any> {
|
||||||
|
success: boolean;
|
||||||
|
data?: T;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=types.d.ts.map
|
||||||
1
dist/types.d.ts.map
vendored
Normal file
1
dist/types.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,YAAY,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9F;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,mBAAmB,EAAE,QAAQ,GAAG,YAAY,GAAG,qBAAqB,GAAG,kBAAkB,GAAG,MAAM,GAAG,gBAAgB,GAAG,aAAa,GAAG,MAAM,CAAC,CAAC;AAE7L;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACtD;;OAEG;IACH,aAAa,EAAE,WAAW,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,aAAa,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEjG;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
||||||
59
dist/utils.d.ts
vendored
Normal file
59
dist/utils.d.ts
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
/**
|
||||||
|
* @file src/utils.ts
|
||||||
|
* @version 2.2.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Utilities
|
||||||
|
* @description
|
||||||
|
* * General utility functions and helpers (e.g., debounce, throttle, type checks).
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* * Creates a throttled version of the provided function. The function is executed at most once within the specified time interval, regardless of how often it is called.
|
||||||
|
* Use case: Performance optimization for high-frequency events (e.g., Scroll, Resize, Mousemove).
|
||||||
|
* @example const throttledScroll = throttle(() => { console.log('Scroll event'); }, 200); => Creates a throttled scroll event handler that logs at most once every 200 milliseconds.
|
||||||
|
* @template T The type of the original function.
|
||||||
|
* @param func The function to be throttled.
|
||||||
|
* @param limit The time interval in milliseconds during which at most one execution is permitted.
|
||||||
|
* @returns A new function that throttles calls.
|
||||||
|
*/
|
||||||
|
export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): (...args: Parameters<T>) => void;
|
||||||
|
/**
|
||||||
|
* * Creates a debounced version of the provided function. Execution is delayed until `delay` milliseconds have passed since the last invocation.
|
||||||
|
* Use case: Waiting for user input (e.g., Live Search, Validation) to avoid unnecessary calculations.
|
||||||
|
* @example const debouncedInput = debounce(() => { console.log('Input event'); }, 300); => Creates a debounced input event handler that logs only after the user has stopped typing for 300 milliseconds.
|
||||||
|
* @template T The type of the original function.
|
||||||
|
* @param func The function to be debounced.
|
||||||
|
* @param delay The waiting time in milliseconds after the last call.
|
||||||
|
* @returns A new function that delays execution.
|
||||||
|
*/
|
||||||
|
export declare function debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
|
||||||
|
/**
|
||||||
|
* * Checks if the code is running in a browser environment.
|
||||||
|
* * Verifies the existence of `window` and `requestAnimationFrame` to ensure animation support.
|
||||||
|
* * Used to safely guard DOM-dependent logic (Effects, Events) during Server-Side Rendering (SSR).
|
||||||
|
* @example const isBrowserEnv = isBrowser(); => Checks if the code is running in a browser environment.
|
||||||
|
* @returns `true` if running in a browser with animation support, otherwise `false`.
|
||||||
|
*/
|
||||||
|
export declare function isBrowser(): boolean;
|
||||||
|
/**
|
||||||
|
* * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays.
|
||||||
|
* * Arrays and array-like objects with a length property are iterated by numeric index.
|
||||||
|
* * Objects are iterated via their named properties.
|
||||||
|
* * Returning 'false' in the callback breaks the loop early.
|
||||||
|
* @example each([1, 2, 3], (index, value) => { console.log(index, value); }) => Logs the index and value of each item in the array.
|
||||||
|
* @example each({ a: 1, b: 2 }, (key, value) => { console.log(key, value); }) => Logs the key and value of each property in the object.
|
||||||
|
* @template T The type of the items in the collection.
|
||||||
|
* @param collection The array, array-like object, or plain object to iterate over.
|
||||||
|
* @param callback The function that will be executed on every object.
|
||||||
|
*/
|
||||||
|
export declare function each<T>(collection: T[] | ArrayLike<T> | Record<string, T>, callback: (this: T, indexOrKey: any, value: T) => boolean | void): collection is T[] | ArrayLike<T> | Record<string, T>;
|
||||||
|
/**
|
||||||
|
* * Internal Helper: Sanitizes an HTML string by removing dangerous attributes.
|
||||||
|
* * Strips inline event handlers and javascript: protocols to mitigate XSS.
|
||||||
|
* @param htmlStr The raw HTML string.
|
||||||
|
* @returns The sanitized HTML string.
|
||||||
|
*/
|
||||||
|
export declare function sanitizeDangerousAttributes(htmlStr: string): string;
|
||||||
|
//# sourceMappingURL=utils.d.ts.map
|
||||||
1
dist/utils.d.ts.map
vendored
Normal file
1
dist/utils.d.ts.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAUpH;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAMpH;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,GAAG,UAAU,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAoBlM;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAInE"}
|
||||||
85
package.json
Normal file
85
package.json
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
{
|
||||||
|
"name": "@k37z3r/jbase",
|
||||||
|
"version": "2.4.1",
|
||||||
|
"description": "Ditch the legacy bloat. jBase is a blazing-fast, SSR-ready micro-framework combining an elegant DOM chaining API with powerful, immutable data utilities. Fully typed, modular, and built for modern web & Node.js environments.",
|
||||||
|
"private": false,
|
||||||
|
"main": "./dist/index.cjs",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"browser": "./dist/jbase.min.js",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"README.md",
|
||||||
|
"LICENSE",
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"CODE_OF_CONDUCT.md",
|
||||||
|
"CONTRIBUTING.md",
|
||||||
|
"SECURITY.md",
|
||||||
|
"wiki"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build:ts": "tsc",
|
||||||
|
"build:browser": "node build.js",
|
||||||
|
"build": "npm run build:browser && npm run build:ts",
|
||||||
|
"prepublishOnly": "npm run build"
|
||||||
|
},
|
||||||
|
"author": "Sven Minio (https://github.com/k37z3r/jBase-2)",
|
||||||
|
"homepage": "https://github.com/k37z3r/jBase-2",
|
||||||
|
"funding": {
|
||||||
|
"type": "paypal",
|
||||||
|
"url": "https://www.paypal.com/donate/?hosted_button_id=PAE6M49YXLHUU"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/k37z3r/jBase-2/issues"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/k37z3r/jBase-2.git"
|
||||||
|
},
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"peerDependencies": {
|
||||||
|
"jsdom": "^28.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"jsdom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/jsdom": "^27.0.0",
|
||||||
|
"@types/node": "^22.0.0",
|
||||||
|
"esbuild": "^0.27.2",
|
||||||
|
"jsdom": "^28.0.0",
|
||||||
|
"tslib": "^2.8.1",
|
||||||
|
"typescript": "^5.3.3"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"framework",
|
||||||
|
"micro-framework",
|
||||||
|
"dom-manipulation",
|
||||||
|
"jquery-alternative",
|
||||||
|
"data-utilities",
|
||||||
|
"immutable",
|
||||||
|
"ssr",
|
||||||
|
"server-side-rendering",
|
||||||
|
"isomorphic",
|
||||||
|
"typescript",
|
||||||
|
"javascript",
|
||||||
|
"ajax",
|
||||||
|
"jbase"
|
||||||
|
],
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"import": "./dist/index.mjs",
|
||||||
|
"require": "./dist/index.cjs"
|
||||||
|
},
|
||||||
|
"./server": {
|
||||||
|
"import": "./dist/server.js",
|
||||||
|
"types": "./dist/server.d.ts",
|
||||||
|
"require": "./dist/server.js"
|
||||||
|
},
|
||||||
|
"./browser": "./dist/jbase.min.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/browser.ts
Normal file
47
src/browser.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
* @file src/browser.ts
|
||||||
|
* @version 2.2.1
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Browser
|
||||||
|
* @description
|
||||||
|
* * Browser Entry Point. Attaches the jBase library and utilities to the global window object
|
||||||
|
* * so they can be accessed via `$` or `jBase` (and other aliases) in inline scripts.
|
||||||
|
* @requires ./index
|
||||||
|
* * The core jBase class and its aliases are imported to be attached to the window object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { $, jBase, jB, _jB, __jB, _jBase, __jBase, __ } from './index';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * TypeScript declaration merging to extend the global Window interface.
|
||||||
|
* * Ensures strict typing when accessing jBase aliases on the window object.
|
||||||
|
*/
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
$: typeof $;
|
||||||
|
jBase: typeof jBase;
|
||||||
|
jB: typeof jB;
|
||||||
|
_jB: typeof _jB;
|
||||||
|
__jB: typeof __jB;
|
||||||
|
_jBase: typeof _jBase;
|
||||||
|
__jBase: typeof __jBase;
|
||||||
|
__: typeof __;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Expose the framework instance and its aliases to the global window object.
|
||||||
|
*/
|
||||||
|
(window as any).$ = $;
|
||||||
|
(window as any).jBase = jBase;
|
||||||
|
(window as any).jB = jB;
|
||||||
|
(window as any)._jB = _jB;
|
||||||
|
(window as any).__jB = __jB;
|
||||||
|
(window as any)._jBase = _jBase;
|
||||||
|
(window as any).__jBase = __jBase;
|
||||||
|
(window as any).__ = __;
|
||||||
|
|
||||||
|
console.log("jBase initialized and ready!");
|
||||||
128
src/core.ts
Normal file
128
src/core.ts
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
/**
|
||||||
|
* @file src/core.ts
|
||||||
|
* @version 2.2.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Core
|
||||||
|
* @description
|
||||||
|
* * The main jBase class. Handles the selection engine, initialization, and plugin architecture.
|
||||||
|
* @requires ./types
|
||||||
|
* * Type definitions for the core class and its methods.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { JBaseElement, JBaseInput } from './types';
|
||||||
|
import { sanitizeDangerousAttributes } from './utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * The core class of the framework, inheriting from the native Array class. Acts as a wrapper around DOM elements and enables chainable methods (Fluent Interface).
|
||||||
|
*/
|
||||||
|
export class jBase extends Array<JBaseElement> {
|
||||||
|
/**
|
||||||
|
* * The original selector string or input type used to create this instance.
|
||||||
|
*/
|
||||||
|
public selectorSource: string = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * The document context this instance is bound to (supports SSR via jsdom).
|
||||||
|
*/
|
||||||
|
public doc: Document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Initializes a new jBase instance. Analyzes the provided selector and populates the internal array with found or created DOM elements.
|
||||||
|
* @param selector The input selector (CSS selector, HTML string, DOM element, or collection).
|
||||||
|
* @param context An optional specific Document or Window context (essential for SSR).
|
||||||
|
*/
|
||||||
|
constructor(selector?: JBaseInput, context?: Document | Window) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
if (context instanceof Document) {
|
||||||
|
this.doc = context;
|
||||||
|
} else if (context && (context as Window).document) {
|
||||||
|
this.doc = (context as Window).document;
|
||||||
|
} else {
|
||||||
|
this.doc = (typeof document !== 'undefined') ? document : (null as any);
|
||||||
|
}
|
||||||
|
if (typeof document === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.selectorSource = typeof selector === 'string' ? selector : '<DOM Object/Array>';
|
||||||
|
|
||||||
|
if (!selector)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (selector instanceof HTMLElement || selector === document || selector === window || selector instanceof Element) {
|
||||||
|
this.push(selector);
|
||||||
|
}
|
||||||
|
else if (typeof selector === 'string') {
|
||||||
|
const trimmed = selector.trim();
|
||||||
|
if (trimmed.startsWith('<') && trimmed.endsWith('>')) {
|
||||||
|
const tempDiv = this.doc.createElement('div');
|
||||||
|
tempDiv.innerHTML = sanitizeDangerousAttributes(trimmed);
|
||||||
|
this.push(...Array.from(tempDiv.children));
|
||||||
|
}
|
||||||
|
else if (trimmed.startsWith('#') && !trimmed.includes(' ') && !trimmed.includes('.')) {
|
||||||
|
const el = this.doc.getElementById(trimmed.slice(1));
|
||||||
|
if (el)
|
||||||
|
this.push(el);
|
||||||
|
}
|
||||||
|
else if (trimmed.startsWith('.') && !trimmed.includes(' ') && !/[:\[#]/.test(trimmed)) {
|
||||||
|
const els = this.doc.getElementsByClassName(trimmed.slice(1));
|
||||||
|
for (let i = 0; i < els.length; i++) {
|
||||||
|
this.push(els[i] as HTMLElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (/^[a-zA-Z0-9]+$/.test(trimmed)) {
|
||||||
|
const els = this.doc.getElementsByTagName(trimmed);
|
||||||
|
for (let i = 0; i < els.length; i++) {
|
||||||
|
this.push(els[i] as HTMLElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
this.push(...Array.from(this.doc.querySelectorAll(selector)));
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`jBase: Invalid selector "${selector}"`, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (selector instanceof NodeList || Array.isArray(selector)) {
|
||||||
|
this.push(...Array.from(selector as ArrayLike<JBaseElement>));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Custom serializer for JSON.stringify. Prevents circular references and huge outputs by returning a simplified preview.
|
||||||
|
* @example toJson() => { meta: 'jBase Wrapper', query: '#myId', count: 1, preview: ['div'] }
|
||||||
|
* @returns A simplified object representation for debugging.
|
||||||
|
*/
|
||||||
|
toJSON() {
|
||||||
|
return {
|
||||||
|
meta: 'jBase Wrapper',
|
||||||
|
query: this.selectorSource,
|
||||||
|
count: this.length,
|
||||||
|
preview: this.slice(0, 10).map(el => {
|
||||||
|
if (el instanceof Element)
|
||||||
|
return el.tagName.toLowerCase();
|
||||||
|
return typeof el;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * High-performance iteration over matched elements.
|
||||||
|
* * Returning 'false' in the callback breaks the loop early.
|
||||||
|
* @example each((el, index) => { console.log(el); if (index === 5) return false; }) => Logs the first 6 matched elements to the console.
|
||||||
|
* @param callback The function to execute for each element. Context (`this`) is set to the current element.
|
||||||
|
* @returns The current jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
each(callback: (this: JBaseElement, el: JBaseElement, index: number) => boolean | void): this {
|
||||||
|
for (let i = 0, len = this.length; i < len; i++) {
|
||||||
|
if (callback.call(this[i], this[i], i) === false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
1172
src/index.ts
Normal file
1172
src/index.ts
Normal file
File diff suppressed because it is too large
Load diff
66
src/modules/css/classes.ts
Normal file
66
src/modules/css/classes.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/css/classes.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category CSS
|
||||||
|
* @description
|
||||||
|
* * Methods for manipulating CSS classes (add, remove, toggle, has).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Adds one or more CSS classes to each element in the collection.
|
||||||
|
* @example addClass('active', 'highlight') => Adds the 'active' and 'highlight' classes to all matched elements.
|
||||||
|
* @param classNames One or more class names to be added
|
||||||
|
* @returns The current jBase instance for method chaining
|
||||||
|
*/
|
||||||
|
export function addClass(this: jBase, ...classNames: string[]): jBase {
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof Element) el.classList.add(...classNames);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes one or more CSS classes from each element in the collection.
|
||||||
|
* @example removeClass('active', 'highlight') => Removes the 'active' and 'highlight' classes from all matched elements.
|
||||||
|
* @param classNames One or more class names to be removed
|
||||||
|
* @returns The current jBase instance for method chaining
|
||||||
|
*/
|
||||||
|
export function removeClass(this: jBase, ...classNames: string[]): jBase {
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof Element) el.classList.remove(...classNames);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Toggles a CSS class (adds if missing, removes if present) for each element.
|
||||||
|
* @example toggleClass('active') => Toggles the 'active' class on all matched elements.
|
||||||
|
* @param className The class name to toggle.
|
||||||
|
* @returns The current jBase instance for method chaining.
|
||||||
|
*/
|
||||||
|
export function toggleClass(this: jBase, className: string): jBase {
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof Element) el.classList.toggle(className);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Checks if at least one element in the collection has the specified class.
|
||||||
|
* @example hasClass('active') => Returns true if at least one matched element has the 'active' class, otherwise false.
|
||||||
|
* @param className The class name to check for.
|
||||||
|
* @returns True if the class exists on at least one element, otherwise false.
|
||||||
|
*/
|
||||||
|
export function hasClass(this: jBase, className: string): boolean {
|
||||||
|
return this.some(el => {
|
||||||
|
return (el instanceof Element) && el.classList.contains(className);
|
||||||
|
});
|
||||||
|
}
|
||||||
26
src/modules/css/index.ts
Normal file
26
src/modules/css/index.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/css/index.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category CSS
|
||||||
|
* @description
|
||||||
|
* * Central entry point for CSS operations. Aggregates class and style manipulation methods.
|
||||||
|
* @requires ./classes
|
||||||
|
* * Class manipulation methods (addClass, removeClass, etc.).
|
||||||
|
* @requires ./styles
|
||||||
|
* * Style manipulation methods (css).
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as classMethods from './classes';
|
||||||
|
import * as styleMethods from './styles';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Aggregation of all CSS methods. This object bundles functions for class manipulation and style manipulation. It is exported to extend the jBase prototype centrally via Object.assign.
|
||||||
|
*/
|
||||||
|
export const cssMethods = {
|
||||||
|
...classMethods,
|
||||||
|
...styleMethods
|
||||||
|
};
|
||||||
69
src/modules/css/styles.ts
Normal file
69
src/modules/css/styles.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/css/styles.ts
|
||||||
|
* @version 2.0.4
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category CSS
|
||||||
|
* @description
|
||||||
|
* * Methods for getting and setting inline CSS styles.
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Gets a CSS property value from the first element or sets one/multiple CSS properties for all elements.
|
||||||
|
* @example css('color', 'red') => Sets the 'color' style to 'red' for all matched elements.
|
||||||
|
* @example css({ color: 'red', backgroundColor: 'blue' }) => Sets multiple styles for all matched elements.
|
||||||
|
* @example css('color') => Returns the computed 'color' value of the first matched element.
|
||||||
|
* @param property A CSS property name as a string, or an object of property-value pairs to set multiple styles.
|
||||||
|
* @param value (Optional) The value to set if `property` is a string. If undefined and `property` is a string, acts as a getter.
|
||||||
|
* @returns The CSS value as a string when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export function css(this: jBase, property: string | Record<string, string | number>, value?: string | number): string | jBase {
|
||||||
|
if (typeof property === 'object' && property !== null) {
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
||||||
|
for (const key in property) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(property, key)) {
|
||||||
|
if (key.includes('-')) {
|
||||||
|
el.style.setProperty(key, String(property[key]));
|
||||||
|
} else {
|
||||||
|
(el.style as any)[key] = property[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if (typeof property === 'string') {
|
||||||
|
if (value === undefined) {
|
||||||
|
const el = this[0];
|
||||||
|
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
||||||
|
const doc = el.ownerDocument;
|
||||||
|
const win = doc ? doc.defaultView : null;
|
||||||
|
if (win) {
|
||||||
|
return win.getComputedStyle(el).getPropertyValue(property) || win.getComputedStyle(el)[property as any] || '';
|
||||||
|
} else {
|
||||||
|
return (el.style as any)[property] || '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
||||||
|
if (property.includes('-')) {
|
||||||
|
el.style.setProperty(property, String(value));
|
||||||
|
} else {
|
||||||
|
(el.style as any)[property] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
399
src/modules/data/arrays.ts
Normal file
399
src/modules/data/arrays.ts
Normal file
|
|
@ -0,0 +1,399 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/arrays.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Utility functions for array manipulation and data processing.
|
||||||
|
* @requires ./types
|
||||||
|
* * Depends on types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { MatchMode } from './types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Splits an array into smaller groups (chunks). Ideal for pagination or grid layouts.
|
||||||
|
* @example chunk([1, 2, 3, 4, 5], 2) => [[1, 2], [3, 4], [5]]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param size The size of each chunk.
|
||||||
|
* @returns An array of arrays.
|
||||||
|
*/
|
||||||
|
export function chunk<T>(array: T[], size: number): T[][] {
|
||||||
|
const chunks: T[][] = [];
|
||||||
|
for (let i = 0; i < array.length; i += size) {
|
||||||
|
chunks.push(array.slice(i, i + size));
|
||||||
|
}
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Merges multiple arrays into a single flat array.
|
||||||
|
* @example mergeArray([1, 2], [3, 4], [5]) => [1, 2, 3, 4, 5]
|
||||||
|
* @template T The type of the items in the arrays.
|
||||||
|
* @param arrays A list of arrays.
|
||||||
|
* @returns A new, merged array.
|
||||||
|
*/
|
||||||
|
export function mergeArray<T>(...arrays: T[][]): T[] {
|
||||||
|
return [].concat(...(arrays as any));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * ALIAS for mergeArray (Consistency with object.merge)
|
||||||
|
*/
|
||||||
|
export const merge = mergeArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Safely adds an element at a specific position without mutating the original array (Immutable).
|
||||||
|
* @example add([1, 2, 4], 3, 2) => [1, 2, 3, 4]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param item The item to add.
|
||||||
|
* @param index The position (default: end). Negative values count from the back (-1 = before the last one).
|
||||||
|
* @returns A new array including the element.
|
||||||
|
*/
|
||||||
|
export function add<T>(array: T[], item: T, index: number = array.length): T[] {
|
||||||
|
const copy = [...array];
|
||||||
|
const idx = index < 0 ? array.length + index + 1 : index;
|
||||||
|
copy.splice(idx, 0, item);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Clears the array and returns a new empty array (Immutable).
|
||||||
|
* @example clear([1, 2, 3]) => []
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array to clear.
|
||||||
|
* @returns A new empty array.
|
||||||
|
*/
|
||||||
|
export function clear<T>(array: T[]): T[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear.
|
||||||
|
*/
|
||||||
|
export const empty = clear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Creates a new array containing only the elements at the specified indices (Allowlist).
|
||||||
|
* * Mirrors object.pick.
|
||||||
|
* @example pick(['a', 'b', 'c', 'd'], [0, 2]) => ['a', 'c']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param indices Array of indices to keep.
|
||||||
|
* @returns A new array with selected elements.
|
||||||
|
*/
|
||||||
|
export function pick<T>(array: T[], indices: number[]): T[] {
|
||||||
|
return array.filter((_, index) => indices.includes(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Creates a new array containing all elements EXCEPT those at the specified indices (Blocklist).
|
||||||
|
* * Mirrors object.omit.
|
||||||
|
* @example omit(['a', 'b', 'c', 'd'], [1, 3]) => ['a', 'c']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param indices Array of indices to remove.
|
||||||
|
* @returns A new array without the specified elements.
|
||||||
|
*/
|
||||||
|
export function omit<T>(array: T[], indices: number[]): T[] {
|
||||||
|
return array.filter((_, index) => !indices.includes(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Safely retrieves a value from a nested array/object structure (Safe Navigation).
|
||||||
|
* * Mirrors object.get.
|
||||||
|
* @example get(users, '0.profile.name') => Returns the name of the first user.
|
||||||
|
* @param array The array.
|
||||||
|
* @param path The path as a dot-notation string.
|
||||||
|
* @returns The found value or undefined.
|
||||||
|
*/
|
||||||
|
export function get(array: any[], path: string): any {
|
||||||
|
return path.split('.').reduce((acc, part) => acc && acc[part as keyof typeof acc], array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Sets a value deeply within a nested array/object structure.
|
||||||
|
* * Mirrors object.set.
|
||||||
|
* @example set(users, '0.profile.name', 'Sven')
|
||||||
|
* @param array The array to modify.
|
||||||
|
* @param path The path as a string (e.g., '0.profile.name').
|
||||||
|
* @param value The value to set.
|
||||||
|
*/
|
||||||
|
export function set(array: any[], path: string, value: any): void {
|
||||||
|
const parts = path.split('.');
|
||||||
|
let current: any = array;
|
||||||
|
for (let i = 0; i < parts.length - 1; i++) {
|
||||||
|
const part = parts[i];
|
||||||
|
if (!current[part]) {
|
||||||
|
current[part] = isNaN(Number(parts[i + 1])) ? {} : [];
|
||||||
|
}
|
||||||
|
current = current[part];
|
||||||
|
}
|
||||||
|
current[parts[parts.length - 1]] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes elements based on index or match logic.
|
||||||
|
*/
|
||||||
|
export const remove = {
|
||||||
|
/**
|
||||||
|
* * Removes an element at a specific index.
|
||||||
|
* @example remove.at([1, 2, 3, 4], -2) => [1, 2, 4]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param index The index (negative values allowed).
|
||||||
|
* @returns A new array with the element removed.
|
||||||
|
*/
|
||||||
|
at<T>(array: T[], index: number): T[] {
|
||||||
|
const copy = [...array];
|
||||||
|
const idx = index < 0 ? array.length + index : index;
|
||||||
|
if (idx >= 0 && idx < copy.length) {
|
||||||
|
copy.splice(idx, 1);
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes the first element.
|
||||||
|
* @example remove.first([1, 2, 3]) => [2, 3]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
*/
|
||||||
|
first<T>(array: T[]): T[] { return array.slice(1); },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes the last element.
|
||||||
|
* @example remove.last([1, 2, 3]) => [1, 2]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
*/
|
||||||
|
last<T>(array: T[]): T[] { return array.slice(0, -1); },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes all elements matching a query condition.
|
||||||
|
* @example remove.byMatch(users, 'Admin', 'exact', 'role')
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
*/
|
||||||
|
byMatch<T>(array: T[], query: string | number, mode: MatchMode = 'exact', key?: keyof T): T[] {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
return array.filter(item => {
|
||||||
|
const val = key ? item[key] : item;
|
||||||
|
const valStr = String(val).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes the element at a specific index.
|
||||||
|
* * Mirrors object.remove.byKey.
|
||||||
|
* @example remove.byKey(['a', 'b', 'c'], 1) => ['a', 'c']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param index The index (key) to remove.
|
||||||
|
* @returns A new array without the specified index.
|
||||||
|
*/
|
||||||
|
byKey<T>(array: T[], index: number): T[] {
|
||||||
|
return this.at(array, index);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes all elements that match a specific value exactly (Strict Equality).
|
||||||
|
* * Mirrors object.remove.byValue.
|
||||||
|
* @example remove.byValue([1, 2, 1, 3], 1) => [2, 3]
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The source array.
|
||||||
|
* @param value The value to remove.
|
||||||
|
* @returns A new array without the matching values.
|
||||||
|
*/
|
||||||
|
byValue<T>(array: T[], value: T): T[] {
|
||||||
|
return array.filter(item => item !== value);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear. Removes all elements.
|
||||||
|
* @param array The source array.
|
||||||
|
* @returns A new, empty array.
|
||||||
|
*/
|
||||||
|
all<T>(array: T[]): T[] {
|
||||||
|
return clear(array);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Searches for elements in the array.
|
||||||
|
*/
|
||||||
|
export const find = {
|
||||||
|
/**
|
||||||
|
* * Finds the index of the first match.
|
||||||
|
* @example find.at(['apple', 'banana', 'cherry'], 'an', 'contains') => 1
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
at<T>(array: T[], query: string | number, mode: MatchMode = 'exact', key?: keyof T): number {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
return array.findIndex(item => {
|
||||||
|
const val = key ? item[key] : item;
|
||||||
|
const valStr = String(val).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Returns all elements matching the condition (Filter).
|
||||||
|
* @example find.all(['apple', 'banana', 'cherry'], 'a', 'contains') => ['apple', 'banana']
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns All matching elements or -1.
|
||||||
|
*/
|
||||||
|
all<T>(array: T[], query: string | number, mode: MatchMode = 'exact', key?: keyof T): T[] {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
return array.filter(item => {
|
||||||
|
const val = key ? item[key] : item;
|
||||||
|
const valStr = String(val).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Returns the first matching element (or undefined).
|
||||||
|
* @example find.first(['apple', 'banana', 'cherry'], 'a', 'contains') => 'apple'
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
first<T>(array: T[], query: string | number, mode: MatchMode = 'exact', key?: keyof T): T | undefined {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
return array.find(item => {
|
||||||
|
const val = key ? item[key] : item;
|
||||||
|
const valStr = String(val).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Returns the last matching element (or undefined).
|
||||||
|
* @example find.last(['apple', 'banana', 'cherry'], 'a', 'contains') => 'banana'
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
last<T>(array: T[], query: string | number, mode: MatchMode = 'exact', key?: keyof T): T | undefined {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
return [...array].reverse().find(item => {
|
||||||
|
const val = key ? item[key] : item;
|
||||||
|
const valStr = String(val).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds all indices (keys) matching the query.
|
||||||
|
* * Mirrors object.find.key(). For arrays, keys are the indices.
|
||||||
|
* @param array The array to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode.
|
||||||
|
* @returns An array of matching indices as strings.
|
||||||
|
*/
|
||||||
|
key<T>(array: T[], query: string, mode: MatchMode = 'exact'): string[] {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
return Object.keys(array).filter(indexKey => {
|
||||||
|
const valStr = String(indexKey).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds all values matching the query.
|
||||||
|
* * Mirrors object.find.value(). Identical to find.all() for flat arrays.
|
||||||
|
* @param array The array to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode.
|
||||||
|
* @returns An array of matching values.
|
||||||
|
*/
|
||||||
|
value<T>(array: T[], query: string, mode: MatchMode = 'exact'): T[] {
|
||||||
|
return this.all(array, query, mode);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds the key of the first match based on the query condition.
|
||||||
|
* @example find.byMatch(users, 'Admin', 'exact', 'role') => 0
|
||||||
|
* @template T The type of the items in the array.
|
||||||
|
* @param array The array.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param key (Optional) The object key if it is an array of objects.
|
||||||
|
* @returns Index or -1.
|
||||||
|
*/
|
||||||
|
byMatch<T>(array: T[], query: string | number, mode: MatchMode = 'exact', key?: keyof T): number | undefined {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
return array.findIndex(item => {
|
||||||
|
const val = key ? item[key] : item;
|
||||||
|
const valStr = String(val).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
315
src/modules/data/index.ts
Normal file
315
src/modules/data/index.ts
Normal file
|
|
@ -0,0 +1,315 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/index.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* * @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Central entry point for data manipulation.
|
||||||
|
* * Features a dynamic, overloaded API router that automatically delegates
|
||||||
|
* * to array or object utilities based on the input type.
|
||||||
|
* @requires ./arrays
|
||||||
|
* * Array manipulation methods.
|
||||||
|
* @requires ./objects
|
||||||
|
* * Object manipulation methods.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as arr from './arrays';
|
||||||
|
import * as obj from './objects';
|
||||||
|
import { MatchMode } from './types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Splits an array or object into smaller chunks (batched processing).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param size The maximum size/length of each chunk.
|
||||||
|
* @returns An array containing the chunked arrays or partial objects.
|
||||||
|
*/
|
||||||
|
function chunk<T>(array: T[], size: number): T[][];
|
||||||
|
function chunk<T extends Record<string, any>>(object: T, size: number): Partial<T>[];
|
||||||
|
function chunk(data: any, size: number): any {
|
||||||
|
return Array.isArray(data) ? arr.chunk(data, size) : obj.chunk(data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Merges multiple arrays (flat) or objects (deep merge) into a single structure.
|
||||||
|
* @param data The target array or object.
|
||||||
|
* @param args The source arrays or objects to merge.
|
||||||
|
* @returns The newly merged array or modified target object.
|
||||||
|
*/
|
||||||
|
function merge(...arrays: any[][]): any[];
|
||||||
|
function merge(target: any, ...sources: any[]): any;
|
||||||
|
function merge(data: any, ...args: any[]): any {
|
||||||
|
return Array.isArray(data) ? arr.merge(data, ...args) : obj.merge(data, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Safely adds an element/property at a specific index without mutating the original structure (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param arg1 The item to add (array) or the key to add (object).
|
||||||
|
* @param arg2 The index (array) or the value to add (object).
|
||||||
|
* @param arg3 The index (object only).
|
||||||
|
* @returns A new array or object including the added element.
|
||||||
|
*/
|
||||||
|
function add<T>(array: T[], item: T, index?: number): T[];
|
||||||
|
function add<T extends Record<string, any>>(object: T, key: string, value: any, index?: number): T & Record<string, any>;
|
||||||
|
function add(data: any, arg1: any, arg2?: any, arg3?: any): any {
|
||||||
|
return Array.isArray(data) ? arr.add(data, arg1, arg2) : obj.add(data, arg1, arg2, arg3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Clears the array or object and returns a new empty one (Immutable).
|
||||||
|
* @param data The array or object to clear.
|
||||||
|
* @returns A new empty array `[]` or object `{}`.
|
||||||
|
*/
|
||||||
|
function clear<T>(array: T[]): T[];
|
||||||
|
function clear<T extends Record<string, any>>(object: T): Partial<T>;
|
||||||
|
function clear(data: any): any {
|
||||||
|
return Array.isArray(data) ? arr.clear(data) : obj.clear(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Creates a new array or object containing ONLY the specified indices/keys (Allowlist).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param keysOrIndices Array of keys (object) or indices (array) to keep.
|
||||||
|
* @returns A new filtered array or object.
|
||||||
|
*/
|
||||||
|
function pick<T>(array: T[], indices: number[]): T[];
|
||||||
|
function pick<T extends object, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
||||||
|
function pick(data: any, keysOrIndices: any): any {
|
||||||
|
return Array.isArray(data) ? arr.pick(data, keysOrIndices) : obj.pick(data, keysOrIndices);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Creates a new array or object containing all elements EXCEPT the specified indices/keys (Blocklist).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param keysOrIndices Array of keys (object) or indices (array) to remove.
|
||||||
|
* @returns A new filtered array or object.
|
||||||
|
*/
|
||||||
|
function omit<T>(array: T[], indices: number[]): T[];
|
||||||
|
function omit<T extends object, K extends keyof T>(object: T, keys: K[]): Omit<T, K>;
|
||||||
|
function omit(data: any, keysOrIndices: any): any {
|
||||||
|
return Array.isArray(data) ? arr.omit(data, keysOrIndices) : obj.omit(data, keysOrIndices);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Safely retrieves a value from a nested array/object structure using dot-notation.
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param path The path string (e.g., 'settings.theme' or '0.profile.name').
|
||||||
|
* @returns The found value or undefined if any part is missing.
|
||||||
|
*/
|
||||||
|
function get(array: any[], path: string): any;
|
||||||
|
function get(object: any, path: string): any;
|
||||||
|
function get(data: any, path: string): any {
|
||||||
|
return Array.isArray(data) ? arr.get(data, path) : obj.get(data, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Sets a value deeply within a nested structure. Creates missing objects/arrays automatically.
|
||||||
|
* @param data The array or object to modify.
|
||||||
|
* @param path The path string (e.g., 'settings.theme').
|
||||||
|
* @param value The value to set.
|
||||||
|
*/
|
||||||
|
function set(array: any[], path: string, value: any): void;
|
||||||
|
function set(object: any, path: string, value: any): void;
|
||||||
|
function set(data: any, path: string, value: any): void {
|
||||||
|
return Array.isArray(data) ? arr.set(data, path, value) : obj.set(data, path, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- REMOVE NAMESPACE ---
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes an entry/element at a specific index (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param index The index to remove (negative values count from the end).
|
||||||
|
* @returns A new array or object without the specified element.
|
||||||
|
*/
|
||||||
|
function removeAt<T>(array: T[], index: number): T[];
|
||||||
|
function removeAt<T extends Record<string, any>>(object: T, index: number): Partial<T>;
|
||||||
|
function removeAt(data: any, index: number): any {
|
||||||
|
return Array.isArray(data) ? arr.remove.at(data, index) : obj.remove.at(data, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes the first entry/element (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @returns A new array or object without the first element.
|
||||||
|
*/
|
||||||
|
function removeFirst<T>(array: T[]): T[];
|
||||||
|
function removeFirst<T extends Record<string, any>>(object: T): Partial<T>;
|
||||||
|
function removeFirst(data: any): any {
|
||||||
|
return Array.isArray(data) ? arr.remove.first(data) : obj.remove.first(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes the last entry/element (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @returns A new array or object without the last element.
|
||||||
|
*/
|
||||||
|
function removeLast<T>(array: T[]): T[];
|
||||||
|
function removeLast<T extends Record<string, any>>(object: T): Partial<T>;
|
||||||
|
function removeLast(data: any): any {
|
||||||
|
return Array.isArray(data) ? arr.remove.last(data) : obj.remove.last(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes all entries/elements matching a query condition (Immutable). Acts as an inverse filter.
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param query The search term.
|
||||||
|
* @param mode Comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns A new array or object containing only the non-matching elements.
|
||||||
|
*/
|
||||||
|
function removeByMatch<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[];
|
||||||
|
function removeByMatch<T extends Record<string, any>>(object: T, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): Partial<T>;
|
||||||
|
function removeByMatch(data: any, query: any, mode?: any, keyOrSearchBy?: any): any {
|
||||||
|
return Array.isArray(data) ? arr.remove.byMatch(data, query, mode, keyOrSearchBy) : obj.remove.byMatch(data, query, mode, keyOrSearchBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes a specific element by its index (arrays) or key (objects) (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param keyOrIndex The index or key string to remove.
|
||||||
|
* @returns A new array or object without the specified property/element.
|
||||||
|
*/
|
||||||
|
function removeByKey<T>(array: T[], index: number): T[];
|
||||||
|
function removeByKey<T extends Record<string, any>>(object: T, key: string): Partial<T>;
|
||||||
|
function removeByKey(data: any, keyOrIndex: any): any {
|
||||||
|
return Array.isArray(data) ? arr.remove.byKey(data, keyOrIndex as number) : obj.remove.byKey(data, keyOrIndex as string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes all elements/entries that match a specific value exactly (Immutable).
|
||||||
|
* @param data The source array or object.
|
||||||
|
* @param value The exact value to remove (strict equality).
|
||||||
|
* @returns A new array or object without the matching values.
|
||||||
|
*/
|
||||||
|
function removeByValue<T>(array: T[], value: T): T[];
|
||||||
|
function removeByValue<T extends Record<string, any>>(object: T, value: any): Partial<T>;
|
||||||
|
function removeByValue(data: any, value: any): any {
|
||||||
|
return Array.isArray(data) ? arr.remove.byValue(data, value) : obj.remove.byValue(data, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- FIND NAMESPACE ---
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Arrays: Finds the index of the first match. Objects: Returns the n-th [key, value] tuple.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param arg1 Query term (array) or numeric index (object).
|
||||||
|
* @returns The index (array) or tuple (object), or undefined.
|
||||||
|
*/
|
||||||
|
function findAt<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number;
|
||||||
|
function findAt(object: any, index: number): [string, any] | undefined;
|
||||||
|
function findAt(data: any, arg1: any, arg2?: any, arg3?: any): any {
|
||||||
|
return Array.isArray(data) ? arr.find.at(data, arg1, arg2, arg3) : obj.find.at(data, arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Returns ALL elements/entries matching the condition. Similar to filter().
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @param mode Comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns A new array or partial object containing the matching elements.
|
||||||
|
*/
|
||||||
|
function findAll<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T[];
|
||||||
|
function findAll<T extends Record<string, any>>(object: T, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): Partial<T>;
|
||||||
|
function findAll(data: any, query: any, mode?: any, keyOrSearchBy?: any): any {
|
||||||
|
return Array.isArray(data) ? arr.find.all(data, query, mode, keyOrSearchBy) : obj.find.all(data, query, mode, keyOrSearchBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Returns the FIRST matching element (array) or [key, value] tuple (object).
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns The found element/tuple or undefined.
|
||||||
|
*/
|
||||||
|
function findFirst<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined;
|
||||||
|
function findFirst(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): [string, any] | undefined;
|
||||||
|
function findFirst(data: any, query: any, mode?: any, keyOrSearchBy?: any): any {
|
||||||
|
return Array.isArray(data) ? arr.find.first(data, query, mode, keyOrSearchBy) : obj.find.first(data, query, mode, keyOrSearchBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Returns the LAST matching element (array) or [key, value] tuple (object). Searches in reverse.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns The found element/tuple or undefined.
|
||||||
|
*/
|
||||||
|
function findLast<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): T | undefined;
|
||||||
|
function findLast(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): [string, any] | undefined;
|
||||||
|
function findLast(data: any, query: any, mode?: any, keyOrSearchBy?: any): any {
|
||||||
|
return Array.isArray(data) ? arr.find.last(data, query, mode, keyOrSearchBy) : obj.find.last(data, query, mode, keyOrSearchBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds all matching indices (arrays) or keys (objects) based on the query.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns An array of matching stringified keys/indices.
|
||||||
|
*/
|
||||||
|
function findKey<T>(array: T[], query: string, mode?: MatchMode): string[];
|
||||||
|
function findKey(object: any, query: string, mode?: MatchMode): string[];
|
||||||
|
function findKey(data: any, query: string, mode?: MatchMode): string[] {
|
||||||
|
return Array.isArray(data) ? arr.find.key(data, query, mode) : obj.find.key(data, query, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds all matching values within the array or object.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns An array of matching values.
|
||||||
|
*/
|
||||||
|
function findValue<T>(array: T[], query: string, mode?: MatchMode): T[];
|
||||||
|
function findValue(object: any, query: string, mode?: MatchMode): any[];
|
||||||
|
function findValue(data: any, query: string, mode?: MatchMode): any[] {
|
||||||
|
return Array.isArray(data) ? arr.find.value(data, query, mode) : obj.find.value(data, query, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds the index (array) or key (object) of the first match based on the query condition.
|
||||||
|
* @param data The array or object to search.
|
||||||
|
* @param query The search term.
|
||||||
|
* @returns The matching index/key or undefined.
|
||||||
|
*/
|
||||||
|
function findByMatch<T>(array: T[], query: string | number, mode?: MatchMode, key?: keyof T): number | undefined;
|
||||||
|
function findByMatch(object: any, query: string | number, mode?: MatchMode, searchBy?: 'key' | 'value'): string | undefined;
|
||||||
|
function findByMatch(data: any, query: any, mode?: any, keyOrSearchBy?: any): any {
|
||||||
|
return Array.isArray(data) ? arr.find.byMatch(data, query, mode, keyOrSearchBy) : obj.find.byMatch(data, query, mode, keyOrSearchBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Central data utility object.
|
||||||
|
* * Dynamically routes to array or object methods based on input.
|
||||||
|
* * Backward compatibility for strict calls is maintained via `.arr` and `.obj`.
|
||||||
|
*/
|
||||||
|
export const data = {
|
||||||
|
arr,
|
||||||
|
obj,
|
||||||
|
chunk,
|
||||||
|
merge,
|
||||||
|
add,
|
||||||
|
clear,
|
||||||
|
empty: clear,
|
||||||
|
pick,
|
||||||
|
omit,
|
||||||
|
get,
|
||||||
|
set,
|
||||||
|
remove: {
|
||||||
|
at: removeAt,
|
||||||
|
first: removeFirst,
|
||||||
|
last: removeLast,
|
||||||
|
byKey: removeByKey,
|
||||||
|
byValue: removeByValue,
|
||||||
|
byMatch: removeByMatch,
|
||||||
|
all: clear
|
||||||
|
},
|
||||||
|
find: {
|
||||||
|
at: findAt,
|
||||||
|
all: findAll,
|
||||||
|
first: findFirst,
|
||||||
|
last: findLast,
|
||||||
|
key: findKey,
|
||||||
|
value: findValue,
|
||||||
|
byMatch: findByMatch
|
||||||
|
}
|
||||||
|
};
|
||||||
445
src/modules/data/objects.ts
Normal file
445
src/modules/data/objects.ts
Normal file
|
|
@ -0,0 +1,445 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/objects.ts
|
||||||
|
* @version 2.1.0
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Utility functions for object manipulation (e.g., deep merging, extension).
|
||||||
|
* @requires ./types
|
||||||
|
* * Depends on types.
|
||||||
|
* @requires src/utils
|
||||||
|
* * Depends on utility functions (e.g., each).
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { each } from 'src/utils';
|
||||||
|
import { MatchMode } from './types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Checks if the provided value is a plain object (not null, not an array).
|
||||||
|
* * Acts as a TypeScript Type Guard.
|
||||||
|
* @private
|
||||||
|
* @param item The value to check.
|
||||||
|
* @returns True if the value is a plain object.
|
||||||
|
*/
|
||||||
|
function isObject(item: any): item is Record<string, any> {
|
||||||
|
return (item && typeof item === 'object' && !Array.isArray(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Recursively merges multiple objects (Deep Merge).
|
||||||
|
* @example mergeObjects({ a: 1, b: { x: 1 } }, { b: { y: 2 } }) => { a: 1, b: { x: 1, y: 2 } }
|
||||||
|
* @param target The target object (will be modified!).
|
||||||
|
* @param sources One or more source objects.
|
||||||
|
* @returns The modified target object.
|
||||||
|
*/
|
||||||
|
export function mergeObjects(target: any, ...sources: any[]): any {
|
||||||
|
if (!sources.length)
|
||||||
|
return target;
|
||||||
|
const source = sources.shift();
|
||||||
|
|
||||||
|
if (isObject(target) && isObject(source)) {
|
||||||
|
for (const key in source) {
|
||||||
|
if (key === '__proto__' || key === 'constructor')
|
||||||
|
continue;
|
||||||
|
if (isObject(source[key])) {
|
||||||
|
if (!target[key]) target[key] = {};
|
||||||
|
mergeObjects(target[key], source[key]);
|
||||||
|
} else {
|
||||||
|
target[key] = source[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mergeObjects(target, ...sources);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * ALIAS for mergeObjects (Consistency with array.mergeArray)
|
||||||
|
*/
|
||||||
|
export const merge = mergeObjects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Splits an object into an array of smaller objects (chunks). Ideal for batched processing.
|
||||||
|
* @example chunk({a: 1, b: 2, c: 3}, 2) => [{a: 1, b: 2}, {c: 3}]
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param size The maximum number of keys per chunk.
|
||||||
|
* @returns An array of partial objects.
|
||||||
|
*/
|
||||||
|
export function chunk<T extends Record<string, any>>(obj: T, size: number): Partial<T>[] {
|
||||||
|
const entries = Object.entries(obj);
|
||||||
|
const chunks: Partial<T>[] = [];
|
||||||
|
for (let i = 0; i < entries.length; i += size) {
|
||||||
|
const slice = entries.slice(i, i + size);
|
||||||
|
chunks.push(Object.fromEntries(slice) as Partial<T>);
|
||||||
|
}
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Safely adds a key-value pair at a specific index without mutating the original object (Immutable).
|
||||||
|
* * Note: While JS object key order is generally insertion-based, relying on it is not always recommended.
|
||||||
|
* @example add({a: 1, c: 3}, 'b', 2, 1) => {a: 1, b: 2, c: 3}
|
||||||
|
* @param obj The object.
|
||||||
|
* @param key The key to add.
|
||||||
|
* @param value The value to add.
|
||||||
|
* @param index The position (default: end). Negative values count from the back.
|
||||||
|
* @returns A new object including the element at the specified position.
|
||||||
|
*/
|
||||||
|
export function add<T extends Record<string, any>>(obj: T, key: string, value: any, index: number = Object.keys(obj).length): T & Record<string, any> {
|
||||||
|
const entries = Object.entries(obj);
|
||||||
|
const idx = index < 0 ? entries.length + index + 1 : index;
|
||||||
|
entries.splice(idx, 0, [key, value]);
|
||||||
|
return Object.fromEntries(entries) as T & Record<string, any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Clears the object and returns a new empty object (Immutable).
|
||||||
|
* @example clear({ a: 1, b: 2 }) => {}
|
||||||
|
* @template T The type of the object.
|
||||||
|
* @param obj The object to clear.
|
||||||
|
* @returns A new empty object.
|
||||||
|
*/
|
||||||
|
export function clear<T extends Record<string, any>>(obj: T): Partial<T> {
|
||||||
|
return {} as Partial<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear.
|
||||||
|
*/
|
||||||
|
export const empty = clear;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Creates a new object containing only the specified keys (Allowlist).
|
||||||
|
* @example pick({ a: 1, b: 2, c: 3 }, ['a', 'c']) => { a: 1, c: 3 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param keys Array of keys to keep.
|
||||||
|
* @returns A new object with selected keys.
|
||||||
|
*/
|
||||||
|
export function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {
|
||||||
|
const ret: any = {};
|
||||||
|
each(keys, function(_index, key) {
|
||||||
|
if (key in obj) ret[key] = obj[key];
|
||||||
|
});
|
||||||
|
return ret as Pick<T, K>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Creates a new object containing all keys EXCEPT the specified ones (Blocklist).
|
||||||
|
* @example omit({ a: 1, b: 2, c: 3 }, ['b']) => { a: 1, c: 3 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param keys Array of keys to remove.
|
||||||
|
* @returns A new object without the specified keys.
|
||||||
|
*/
|
||||||
|
export function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
|
||||||
|
const ret = { ...obj };
|
||||||
|
each(keys, function(_index, key) {
|
||||||
|
delete ret[key];
|
||||||
|
});
|
||||||
|
return ret as Omit<T, K>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Safely retrieves a value from a nested object (Safe Navigation).
|
||||||
|
* @example get(config, 'settings.theme.color') => Returns the value of config.settings.theme.color or undefined if any part is missing.
|
||||||
|
* @param obj The object.
|
||||||
|
* @param path The path as a dot-notation string.
|
||||||
|
* @returns The found value or undefined.
|
||||||
|
*/
|
||||||
|
export function get(obj: any, path: string): any {
|
||||||
|
return path.split('.').reduce((acc, part) => acc && acc[part], obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Sets a value deeply within a nested object. Creates missing intermediate objects automatically.
|
||||||
|
* @example set(config, 'settings.theme.color', 'dark') => Sets config.settings.theme.color to 'dark', creating objects if needed.
|
||||||
|
* @param obj The object to modify.
|
||||||
|
* @param path The path as a string (e.g., 'settings.theme.color').
|
||||||
|
* @param value The value to set.
|
||||||
|
*/
|
||||||
|
export function set(obj: any, path: string, value: any): void {
|
||||||
|
const parts = path.split('.');
|
||||||
|
let current = obj;
|
||||||
|
for (let i = 0; i < parts.length - 1; i++) {
|
||||||
|
const part = parts[i];
|
||||||
|
if (!current[part]) current[part] = {};
|
||||||
|
current = current[part];
|
||||||
|
}
|
||||||
|
current[parts[parts.length - 1]] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes elements from an object based on index or match logic (Immutable).
|
||||||
|
* * Mirrors the array.remove API.
|
||||||
|
*/
|
||||||
|
export const remove = {
|
||||||
|
/**
|
||||||
|
* * Removes an entry at a specific index.
|
||||||
|
* @example remove.at({a: 1, b: 2, c: 3}, -1) => {a: 1, b: 2}
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param index The index (negative values allowed).
|
||||||
|
* @returns A new object with the element removed.
|
||||||
|
*/
|
||||||
|
at<T extends Record<string, any>>(obj: T, index: number): Partial<T> {
|
||||||
|
const entries = Object.entries(obj);
|
||||||
|
const idx = index < 0 ? entries.length + index : index;
|
||||||
|
if (idx >= 0 && idx < entries.length) {
|
||||||
|
entries.splice(idx, 1);
|
||||||
|
}
|
||||||
|
return Object.fromEntries(entries) as Partial<T>;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes the first entry from the object.
|
||||||
|
* @param obj The source object.
|
||||||
|
* @returns A new object without the first entry.
|
||||||
|
*/
|
||||||
|
first<T extends Record<string, any>>(obj: T): Partial<T> {
|
||||||
|
const entries = Object.entries(obj).slice(1);
|
||||||
|
return Object.fromEntries(entries) as Partial<T>;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes the last entry from the object.
|
||||||
|
* @param obj The source object.
|
||||||
|
* @returns A new object without the last entry.
|
||||||
|
*/
|
||||||
|
last<T extends Record<string, any>>(obj: T): Partial<T> {
|
||||||
|
const entries = Object.entries(obj).slice(0, -1);
|
||||||
|
return Object.fromEntries(entries) as Partial<T>;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes all entries matching a query condition.
|
||||||
|
* @example remove.byMatch(config, 'hidden', 'exact', 'key')
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value' (default: 'key').
|
||||||
|
* @returns A new object without the matching elements.
|
||||||
|
*/
|
||||||
|
byMatch<T extends Record<string, any>>(obj: T, query: string | number, mode: MatchMode = 'exact', searchBy: 'key' | 'value' = 'key'): Partial<T> {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
const filteredEntries = Object.entries(obj).filter(([key, val]) => {
|
||||||
|
const target = searchBy === 'key' ? key : val;
|
||||||
|
const valStr = String(target).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr !== queryStr;
|
||||||
|
case 'startsWith': return !valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return !valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return !valStr.includes(queryStr);
|
||||||
|
default: return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return Object.fromEntries(filteredEntries) as Partial<T>;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes all entries that have a specific key.
|
||||||
|
* @example remove.byKey({ a: 1, b: 2, c: 3 }, 'b') => { a: 1, c: 3 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param key The key to remove.
|
||||||
|
* @returns A new object without the specified key.
|
||||||
|
*/
|
||||||
|
byKey<T extends Record<string, any>>(obj: T, key: string): Partial<T> {
|
||||||
|
const ret = { ...obj };
|
||||||
|
delete ret[key];
|
||||||
|
return ret as Partial<T>;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes all entries that match a specific value exactly (Strict Equality).
|
||||||
|
* @example remove.byValue({ a: 1, b: 2, c: 1 }, 1) => { b: 2 }
|
||||||
|
* @param obj The source object.
|
||||||
|
* @param value The value to remove.
|
||||||
|
* @returns A new object without the matching values.
|
||||||
|
*/
|
||||||
|
byValue<T extends Record<string, any>>(obj: T, value: any): Partial<T> {
|
||||||
|
const filteredEntries = Object.entries(obj).filter(([_key, val]) => val !== value);
|
||||||
|
return Object.fromEntries(filteredEntries) as Partial<T>;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * ALIAS for clear. Removes all entries.
|
||||||
|
* @param obj The source object.
|
||||||
|
* @returns A new, empty object.
|
||||||
|
*/
|
||||||
|
all<T extends Record<string, any>>(obj: T): Partial<T> {
|
||||||
|
return clear(obj);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Searches keys or values in the object.
|
||||||
|
*/
|
||||||
|
export const find = {
|
||||||
|
/**
|
||||||
|
* * Returns the n-th entry of an object as a [key, value] pair. Supports negative indices.
|
||||||
|
* @example find.at({ a: 1, b: 2 }, 1) => ['b', 2]
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param index The index (0-based, negative counts from the back).
|
||||||
|
* @returns A [key, value] tuple or undefined.
|
||||||
|
*/
|
||||||
|
at(obj: any, index: number): [string, any] | undefined {
|
||||||
|
const entries = Object.entries(obj);
|
||||||
|
const idx = index < 0 ? entries.length + index : index;
|
||||||
|
return entries[idx];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Returns a NEW OBJECT containing ALL elements matching the condition.
|
||||||
|
* * Mirrors array.find.all() but returns a partial object.
|
||||||
|
* @example find.all({a: 1, b: 2, c: 1}, 1, 'exact', 'value') => {a: 1, c: 1}
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value' (default: 'key').
|
||||||
|
* @returns A new object with only the matching elements.
|
||||||
|
*/
|
||||||
|
all<T extends Record<string, any>>(obj: T, query: string | number, mode: MatchMode = 'exact', searchBy: 'key' | 'value' = 'key'): Partial<T> {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
const filteredEntries = Object.entries(obj).filter(([key, val]) => {
|
||||||
|
const target = searchBy === 'key' ? key : val;
|
||||||
|
const valStr = String(target).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return Object.fromEntries(filteredEntries) as Partial<T>;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds the first entry where the key or value matches the query.
|
||||||
|
* @example find.first(config, 'admin', 'exact', 'key')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value'.
|
||||||
|
* @returns The first matching [key, value] pair or undefined.
|
||||||
|
*/
|
||||||
|
first(obj: any, query: string | number, mode: MatchMode = 'exact', searchBy: 'key' | 'value' = 'key'): [string, any] | undefined {
|
||||||
|
const entries = Object.entries(obj);
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
|
||||||
|
return entries.find(([key, val]) => {
|
||||||
|
const target = searchBy === 'key' ? key : val;
|
||||||
|
const valStr = String(target).toLowerCase();
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds the last entry where the key or value matches the query.
|
||||||
|
* @example find.last(config, '.php', 'endsWith', 'key')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value'.
|
||||||
|
* @returns The last matching [key, value] pair or undefined.
|
||||||
|
*/
|
||||||
|
last(obj: any, query: string | number, mode: MatchMode = 'exact', searchBy: 'key' | 'value' = 'key'): [string, any] | undefined {
|
||||||
|
const entries = Object.entries(obj);
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
|
||||||
|
return [...entries].reverse().find(([key, val]) => {
|
||||||
|
const target = searchBy === 'key' ? key : val;
|
||||||
|
const valStr = String(target).toLowerCase();
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds all keys matching the query.
|
||||||
|
* @example find.key(config, 'api_', 'startsWith')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns An array of matching keys.
|
||||||
|
*/
|
||||||
|
key(obj: any, query: string, mode: MatchMode = 'exact'): string[] {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
|
||||||
|
return Object.keys(obj).filter(key => {
|
||||||
|
const valStr = String(key).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds all values matching the query.
|
||||||
|
* @example find.value(config, 'enabled', 'exact')
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @returns An array of matching values.
|
||||||
|
*/
|
||||||
|
value(obj: any, query: string, mode: MatchMode = 'exact'): any[] {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
|
||||||
|
return Object.values(obj).filter(val => {
|
||||||
|
const valStr = String(val).toLowerCase();
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Finds the key of the first match based on the query condition.
|
||||||
|
* * Mirrors array.find.byMatch(). For objects, it returns the key instead of a numeric index.
|
||||||
|
* @example find.byMatch(config, 'admin', 'exact', 'value') => 'role'
|
||||||
|
* @param obj The object to search.
|
||||||
|
* @param query The search query.
|
||||||
|
* @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith').
|
||||||
|
* @param searchBy Whether to search by 'key' or 'value' (default: 'key').
|
||||||
|
* @returns The matched key as a string, or undefined if no match is found.
|
||||||
|
*/
|
||||||
|
byMatch(obj: any, query: string | number, mode: MatchMode = 'exact', searchBy: 'key' | 'value' = 'key'): string | undefined {
|
||||||
|
const queryStr = String(query).toLowerCase();
|
||||||
|
const entries = Object.entries(obj);
|
||||||
|
|
||||||
|
const found = entries.find(([key, val]) => {
|
||||||
|
const target = searchBy === 'key' ? key : val;
|
||||||
|
const valStr = String(target).toLowerCase();
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case 'exact': return valStr === queryStr;
|
||||||
|
case 'startsWith': return valStr.startsWith(queryStr);
|
||||||
|
case 'endsWith': return valStr.endsWith(queryStr);
|
||||||
|
case 'contains': return valStr.includes(queryStr);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return found ? found[0] : undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
16
src/modules/data/types.ts
Normal file
16
src/modules/data/types.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/data/types.ts
|
||||||
|
* @version 2.0.3
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category Data
|
||||||
|
* @description
|
||||||
|
* * Type definitions and validation helpers for data structures.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Defines the matching modes for search operations.
|
||||||
|
*/
|
||||||
|
export type MatchMode = 'exact' | 'contains' | 'startsWith' | 'endsWith';
|
||||||
96
src/modules/dom/attributes.ts
Normal file
96
src/modules/dom/attributes.ts
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
/**
|
||||||
|
* @file src/modules/dom/attributes.ts
|
||||||
|
* @version 2.1.1
|
||||||
|
* @since 2.0.0
|
||||||
|
* @license GPL-3.0-or-later
|
||||||
|
* @copyright Sven Minio 2026
|
||||||
|
* @author Sven Minio <https://sven-minio.de>
|
||||||
|
* @category DOM
|
||||||
|
* @description
|
||||||
|
* * Methods for getting and setting HTML attributes and properties (attr, data, val).
|
||||||
|
* @requires ../../core
|
||||||
|
* * Depends on the core jBase class for type definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { jBase } from '../../core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Gets an attribute from the first element or sets it for all elements in the selection.
|
||||||
|
* @example attr('href', 'https://example.com') => Sets the 'href' attribute to 'https://example.com' for all matched elements.
|
||||||
|
* @example attr('href') => Returns the 'href' attribute value of the first matched element.
|
||||||
|
* @param name The name of the attribute (e.g., 'href', 'data-id').
|
||||||
|
* @param value (Optional) The value to set. If undefined, acts as a getter.
|
||||||
|
* @returns The attribute value (string/null) when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export function attr(this: jBase, name: string, value?: string): string | null | jBase {
|
||||||
|
if (value === undefined) {
|
||||||
|
const el = this[0];
|
||||||
|
return (el instanceof Element) ? el.getAttribute(name) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof Element) el.setAttribute(name, value);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Gets the 'value' from the first form element or sets it for all elements. Supports Input, Textarea, and Select elements.
|
||||||
|
* @example val('Hello') => Sets the value of all matched form elements to 'Hello'.
|
||||||
|
* @example val() => Returns the value of the first matched form element.
|
||||||
|
* @param value (Optional) The value to set. If undefined, acts as a getter.
|
||||||
|
* @returns The current value as a string when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export function val(this: jBase, value?: string): string | jBase {
|
||||||
|
if (value === undefined) {
|
||||||
|
const el = this[0];
|
||||||
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) {
|
||||||
|
return el.value;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) {
|
||||||
|
el.value = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Removes an attribute from all elements in the selection.
|
||||||
|
* @example removeAttr('disabled') => Removes the 'disabled' attribute from all matched elements.
|
||||||
|
* @param name The name of the attribute to remove (e.g., 'disabled', 'readonly').
|
||||||
|
* @returns The jBase instance for chaining.
|
||||||
|
*/
|
||||||
|
export function removeAttr(this: jBase, name: string): jBase {
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof Element) el.removeAttribute(name);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Gets a property from the first element or sets it for all elements in the selection.
|
||||||
|
* * Useful for DOM properties that don't directly map to HTML attributes (like 'checked' or 'selectedIndex').
|
||||||
|
* @example prop('checked', true) => Sets the 'checked' property to true for all matched elements (e.g., checkboxes).
|
||||||
|
* @example prop('checked') => Returns the 'checked' property value of the first matched element.
|
||||||
|
* @example prop('selectedIndex', 2) => Sets the 'selectedIndex' property to 2 for all matched <select> elements.
|
||||||
|
* @param name The name of the property (e.g., 'checked', 'disabled').
|
||||||
|
* @param value (Optional) The value to set. If undefined, acts as a getter.
|
||||||
|
* @returns The property value when reading, or the jBase instance when writing.
|
||||||
|
*/
|
||||||
|
export function prop(this: jBase, name: string, value?: any): any | jBase {
|
||||||
|
if (value === undefined) {
|
||||||
|
const el = this[0];
|
||||||
|
return (el instanceof Element) ? (el as any)[name] : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.each(function(el) {
|
||||||
|
if (el instanceof Element) {
|
||||||
|
(el as any)[name] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue