@k37z3r/jbase 2.0.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@
17
17
  * * 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.
18
18
  */
19
19
  export declare const cssMethods: {
20
- css(this: import("../..").JBaseClass, property: string, value?: string | number): string | import("../..").JBaseClass;
20
+ css(this: import("../..").JBaseClass, property: string | Record<string, string | number>, value?: string | number): string | import("../..").JBaseClass;
21
21
  addClass(this: import("../..").JBaseClass, ...classNames: string[]): import("../..").JBaseClass;
22
22
  removeClass(this: import("../..").JBaseClass, ...classNames: string[]): import("../..").JBaseClass;
23
23
  toggleClass(this: import("../..").JBaseClass, className: string): import("../..").JBaseClass;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file src/modules/css/styles.ts
3
- * @version 2.0.2
3
+ * @version 2.0.3
4
4
  * @since 2.0.0
5
5
  * @license GPL-3.0-or-later
6
6
  * @copyright Sven Minio 2026
@@ -13,13 +13,13 @@
13
13
  */
14
14
  import { jBase } from '../../core';
15
15
  /**
16
- * * Sets or gets the value of a style property for the selected elements.
16
+ * * Gets a CSS property value from the first element or sets one/multiple CSS properties for all elements.
17
17
  * @param property
18
- * * The CSS property name (camelCase).
18
+ * * A CSS property name as a string, or an object of property-value pairs to set multiple styles.
19
19
  * @param value
20
- * * (Optional) The value to set. If undefined, the method acts as a getter.
20
+ * * (Optional) The value to set if `property` is a string. If undefined and `property` is a string, acts as a getter.
21
21
  * @returns
22
- * * The computed style value (string) if acting as a getter, or the current jBase instance if setting.
22
+ * * The CSS value as a string when reading, or the jBase instance when writing.
23
23
  */
24
- export declare function css(this: jBase, property: string, value?: string | number): string | jBase;
24
+ export declare function css(this: jBase, property: string | Record<string, string | number>, value?: string | number): string | jBase;
25
25
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
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,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAoB1F"}
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,CA4C5H"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file src/modules/dom/attributes.ts
3
- * @version 2.0.2
3
+ * @version 2.1.0
4
4
  * @since 2.0.0
5
5
  * @license GPL-3.0-or-later
6
6
  * @copyright Sven Minio 2026
@@ -30,4 +30,23 @@ export declare function attr(this: jBase, name: string, value?: string): string
30
30
  * * The current value as a string when reading, or the jBase instance when writing.
31
31
  */
32
32
  export declare function val(this: jBase, value?: string): string | jBase;
33
+ /**
34
+ * * Removes an attribute from all elements in the selection.
35
+ * @param name
36
+ * * The name of the attribute to remove (e.g., 'disabled', 'readonly').
37
+ * @returns
38
+ * * The jBase instance for chaining.
39
+ */
40
+ export declare function removeAttr(this: jBase, name: string): jBase;
41
+ /**
42
+ * * Gets a property from the first element or sets it for all elements in the selection.
43
+ * * Useful for DOM properties that don't directly map to HTML attributes (like 'checked' or 'selectedIndex').
44
+ * @param name
45
+ * * The name of the property (e.g., 'checked', 'disabled').
46
+ * @param value
47
+ * * (Optional) The value to set. If undefined, acts as a getter.
48
+ * @returns
49
+ * * The property value when reading, or the jBase instance when writing.
50
+ */
51
+ export declare function prop(this: jBase, name: string, value?: any): any | jBase;
33
52
  //# sourceMappingURL=attributes.d.ts.map
@@ -1 +1 @@
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;;;;;;;;GAQG;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"}
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;;;;;;;;GAQG;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;;;;;;GAMG;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"}
@@ -67,5 +67,7 @@ export declare const domMethods: {
67
67
  text(this: import("../..").JBaseClass, content?: string): string | import("../..").JBaseClass;
68
68
  attr(this: import("../..").JBaseClass, name: string, value?: string): string | null | import("../..").JBaseClass;
69
69
  val(this: import("../..").JBaseClass, value?: string): string | import("../..").JBaseClass;
70
+ removeAttr(this: import("../..").JBaseClass, name: string): import("../..").JBaseClass;
71
+ prop(this: import("../..").JBaseClass, name: string, value?: any): any | import("../..").JBaseClass;
70
72
  };
71
73
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/dom/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMtB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file src/modules/http/get.ts
3
- * @version 2.0.2
3
+ * @version 2.0.4
4
4
  * @since 2.0.0
5
5
  * @license GPL-3.0-or-later
6
6
  * @copyright Sven Minio 2026
@@ -17,20 +17,24 @@
17
17
  * * The expected type of the response data (Generic).
18
18
  * @param url
19
19
  * * The target URL for the request.
20
+ * @param option
21
+ * * Optional RequestInit object to customize the fetch request.
20
22
  * @returns
21
23
  * * A Promise resolving with the typed JSON data.
22
24
  * @throws
23
25
  * * Error if HTTP status is not in success range (200-299) or a timeout occurs.
24
26
  */
25
- export declare function get<T>(url: string): Promise<T>;
27
+ export declare function get<T>(url: string, option?: RequestInit): Promise<T>;
26
28
  /**
27
29
  * * Performs an asynchronous HTTP GET request and returns the raw text content. Ideal for loading HTML fragments (Server-Side Rendering Partials) or plain text.
28
30
  * @param url
29
31
  * * The target URL for the request.
32
+ * @param option
33
+ * * Optional RequestInit object to customize the fetch request.
30
34
  * @returns
31
35
  * * A Promise containing the response body as a string.
32
36
  * @throws
33
37
  * * Error if HTTP status is not in success range (200-299).
34
38
  */
35
- export declare function getText<T>(url: string): Promise<T>;
39
+ export declare function getText<T = string>(url: string, option?: RequestInit): Promise<T>;
36
40
  //# sourceMappingURL=get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/modules/http/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;GAUG;AACH,wBAAsB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CASpD;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxD"}
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/modules/http/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAgB1E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAoBvF"}
@@ -26,8 +26,8 @@
26
26
  * const html = await http.getText('/templates/modal.html');
27
27
  */
28
28
  export declare const http: {
29
- post<T>(url: string, body?: any): Promise<T>;
30
- get<T>(url: string): Promise<T>;
31
- getText<T>(url: string): Promise<T>;
29
+ post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
30
+ get<T>(url: string, option?: RequestInit): Promise<T>;
31
+ getText<T = string>(url: string, option?: RequestInit): Promise<T>;
32
32
  };
33
33
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file src/modules/http/post.ts
3
- * @version 2.0.2
4
- * @since 2.0.0
3
+ * @version 2.0.3
4
+ * @since 2.0.2
5
5
  * @license GPL-3.0-or-later
6
6
  * @copyright Sven Minio 2026
7
7
  * @author Sven Minio <https://sven-minio.de>
@@ -19,10 +19,12 @@
19
19
  * * The target URL for the request.
20
20
  * @param body
21
21
  * * The data to send (automatically JSON serialized). Default is {}.
22
+ * @param option
23
+ * * Optional RequestInit object to customize the fetch request.
22
24
  * @returns
23
25
  * * A Promise resolving with the deserialized JSON response of type T.
24
26
  * @throws
25
27
  * * Error if the HTTP status code is not in the range 200-299.
26
28
  */
27
- export declare function post<T>(url: string, body?: any): Promise<T>;
29
+ export declare function post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
28
30
  //# sourceMappingURL=post.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/modules/http/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAkBrE"}
1
+ {"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/modules/http/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAyB3F"}
package/dist/server.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @k37z3r/jbase - A modern micro-framework for the web: jBase offers the familiar syntax of classic DOM libraries, but without their baggage. Fully typed, modular, and optimized for modern browser engines.
3
- * @version 2.0.2
4
- * @homepage https://github.com/k37z3r/jBase-2.0
5
- * @author Sven Minio (https://github.com/k37z3r/jBase-2.0)
3
+ * @version 2.1.1
4
+ * @homepage https://github.com/k37z3r/jBase-2
5
+ * @author Sven Minio (https://github.com/k37z3r/jBase-2)
6
6
  * @license GPL-3.0-or-later
7
- * @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2.0)
7
+ * @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2)
8
8
  */
9
9
  "use strict";
10
10
  var __defProp = Object.defineProperty;
@@ -147,24 +147,46 @@ __export(styles_exports, {
147
147
  css: () => css
148
148
  });
149
149
  function css(property, value) {
150
- if (value === void 0) {
151
- const el = this[0];
152
- if (el instanceof HTMLElement || el instanceof SVGElement) {
153
- const doc = el.ownerDocument;
154
- const win = doc ? doc.defaultView : null;
155
- if (win) {
156
- return win.getComputedStyle(el)[property];
157
- } else {
158
- return el.style[property] || "";
150
+ if (typeof property === "object" && property !== null) {
151
+ this.forEach((el) => {
152
+ if (el instanceof HTMLElement || el instanceof SVGElement) {
153
+ for (const key in property) {
154
+ if (Object.prototype.hasOwnProperty.call(property, key)) {
155
+ if (key.includes("-")) {
156
+ el.style.setProperty(key, String(property[key]));
157
+ } else {
158
+ el.style[key] = property[key];
159
+ }
160
+ }
161
+ }
159
162
  }
160
- }
161
- return "";
163
+ });
164
+ return this;
162
165
  }
163
- this.forEach((el) => {
164
- if (el instanceof HTMLElement || el instanceof SVGElement) {
165
- el.style[property] = value;
166
+ if (typeof property === "string") {
167
+ if (value === void 0) {
168
+ const el = this[0];
169
+ if (el instanceof HTMLElement || el instanceof SVGElement) {
170
+ const doc = el.ownerDocument;
171
+ const win = doc ? doc.defaultView : null;
172
+ if (win) {
173
+ return win.getComputedStyle(el).getPropertyValue(property) || win.getComputedStyle(el)[property] || "";
174
+ } else {
175
+ return el.style[property] || "";
176
+ }
177
+ }
178
+ return "";
166
179
  }
167
- });
180
+ this.forEach((el) => {
181
+ if (el instanceof HTMLElement || el instanceof SVGElement) {
182
+ if (property.includes("-")) {
183
+ el.style.setProperty(property, String(value));
184
+ } else {
185
+ el.style[property] = value;
186
+ }
187
+ }
188
+ });
189
+ }
168
190
  return this;
169
191
  }
170
192
 
@@ -369,6 +391,8 @@ var eventMethods = {
369
391
  var attributes_exports = {};
370
392
  __export(attributes_exports, {
371
393
  attr: () => attr,
394
+ prop: () => prop,
395
+ removeAttr: () => removeAttr,
372
396
  val: () => val
373
397
  });
374
398
  function attr(name, value) {
@@ -396,6 +420,24 @@ function val(value) {
396
420
  });
397
421
  return this;
398
422
  }
423
+ function removeAttr(name) {
424
+ this.forEach((el) => {
425
+ if (el instanceof Element) el.removeAttribute(name);
426
+ });
427
+ return this;
428
+ }
429
+ function prop(name, value) {
430
+ if (value === void 0) {
431
+ const el = this[0];
432
+ return el instanceof Element ? el[name] : void 0;
433
+ }
434
+ this.forEach((el) => {
435
+ if (el instanceof Element) {
436
+ el[name] = value;
437
+ }
438
+ });
439
+ return this;
440
+ }
399
441
 
400
442
  // src/modules/dom/content.ts
401
443
  var content_exports = {};
@@ -1248,9 +1290,16 @@ __export(get_exports, {
1248
1290
  get: () => get,
1249
1291
  getText: () => getText
1250
1292
  });
1251
- async function get(url) {
1293
+ async function get(url, option) {
1294
+ const fetchOptions = { ...option };
1295
+ if (fetchOptions.method?.toLowerCase() === "post") {
1296
+ fetchOptions.method = "GET";
1297
+ }
1298
+ if (!fetchOptions.signal) {
1299
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1300
+ }
1252
1301
  const response = await fetch(url, {
1253
- signal: AbortSignal.timeout(5e3)
1302
+ ...fetchOptions
1254
1303
  });
1255
1304
  if (!response.ok) {
1256
1305
  throw new Error(`HTTP Error: ${response.status}`);
@@ -1258,13 +1307,22 @@ async function get(url) {
1258
1307
  const text2 = await response.text();
1259
1308
  return text2 ? JSON.parse(text2) : {};
1260
1309
  }
1261
- async function getText(url) {
1262
- const response = await fetch(url);
1310
+ async function getText(url, option) {
1311
+ const fetchOptions = { ...option };
1312
+ if (fetchOptions.method?.toLowerCase() !== "get") {
1313
+ fetchOptions.method = "GET";
1314
+ }
1315
+ if (!fetchOptions.signal) {
1316
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1317
+ }
1318
+ const response = await fetch(url, {
1319
+ ...fetchOptions
1320
+ });
1263
1321
  if (!response.ok) {
1264
1322
  throw new Error(`HTTP Error: ${response.status}`);
1265
1323
  }
1266
1324
  const text2 = await response.text();
1267
- return text2 ? JSON.parse(text2) : {};
1325
+ return text2;
1268
1326
  }
1269
1327
 
1270
1328
  // src/modules/http/post.ts
@@ -1272,9 +1330,16 @@ var post_exports = {};
1272
1330
  __export(post_exports, {
1273
1331
  post: () => post
1274
1332
  });
1275
- async function post(url, body = {}) {
1333
+ async function post(url, body = {}, option) {
1334
+ const fetchOptions = { ...option };
1335
+ if (fetchOptions.method?.toLowerCase() !== "post") {
1336
+ fetchOptions.method = "post";
1337
+ }
1338
+ if (!fetchOptions.signal) {
1339
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1340
+ }
1276
1341
  const response = await fetch(url, {
1277
- method: "POST",
1342
+ ...fetchOptions,
1278
1343
  headers: { "Content-Type": "application/json" },
1279
1344
  body: JSON.stringify(body)
1280
1345
  });
@@ -1818,7 +1883,7 @@ function parseHTML2(html2) {
1818
1883
  */
1819
1884
  /**
1820
1885
  * @file src/modules/css/styles.ts
1821
- * @version 2.0.2
1886
+ * @version 2.0.3
1822
1887
  * @since 2.0.0
1823
1888
  * @license GPL-3.0-or-later
1824
1889
  * @copyright Sven Minio 2026
@@ -1947,7 +2012,7 @@ function parseHTML2(html2) {
1947
2012
  */
1948
2013
  /**
1949
2014
  * @file src/modules/dom/attributes.ts
1950
- * @version 2.0.2
2015
+ * @version 2.1.0
1951
2016
  * @since 2.0.0
1952
2017
  * @license GPL-3.0-or-later
1953
2018
  * @copyright Sven Minio 2026
@@ -2100,7 +2165,7 @@ function parseHTML2(html2) {
2100
2165
  */
2101
2166
  /**
2102
2167
  * @file src/modules/http/get.ts
2103
- * @version 2.0.2
2168
+ * @version 2.0.4
2104
2169
  * @since 2.0.0
2105
2170
  * @license GPL-3.0-or-later
2106
2171
  * @copyright Sven Minio 2026
@@ -2113,8 +2178,8 @@ function parseHTML2(html2) {
2113
2178
  */
2114
2179
  /**
2115
2180
  * @file src/modules/http/post.ts
2116
- * @version 2.0.2
2117
- * @since 2.0.0
2181
+ * @version 2.0.3
2182
+ * @since 2.0.2
2118
2183
  * @license GPL-3.0-or-later
2119
2184
  * @copyright Sven Minio 2026
2120
2185
  * @author Sven Minio <https://sven-minio.de>
@@ -2182,7 +2247,7 @@ function parseHTML2(html2) {
2182
2247
  */
2183
2248
  /**
2184
2249
  * @file src/index.ts
2185
- * @version 2.0.2
2250
+ * @version 2.1.1
2186
2251
  * @since 2.0.0
2187
2252
  * @license GPL-3.0-or-later
2188
2253
  * @copyright Sven Minio 2026