jj 2.5.0 → 2.6.0

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.
Files changed (77) hide show
  1. package/README.md +29 -1
  2. package/SKILL.md +671 -0
  3. package/lib/bundle.cjs +2031 -0
  4. package/lib/bundle.cjs.map +1 -0
  5. package/lib/bundle.d.cts +1782 -0
  6. package/lib/bundle.d.ts +1782 -1
  7. package/lib/bundle.global.js +1953 -0
  8. package/lib/bundle.global.js.map +1 -0
  9. package/lib/bundle.js +232 -230
  10. package/lib/bundle.js.map +1 -7
  11. package/lib/bundle.min.cjs +2 -0
  12. package/lib/bundle.min.cjs.map +1 -0
  13. package/lib/bundle.min.d.cts +1782 -0
  14. package/lib/bundle.min.d.ts +1782 -1
  15. package/lib/bundle.min.global.js +2 -0
  16. package/lib/bundle.min.global.js.map +1 -0
  17. package/lib/bundle.min.js +2 -1
  18. package/lib/bundle.min.js.map +1 -0
  19. package/package.json +5 -5
  20. package/lib/JJD.d.ts +0 -87
  21. package/lib/JJD.js +0 -119
  22. package/lib/JJD.js.map +0 -1
  23. package/lib/JJDF.d.ts +0 -74
  24. package/lib/JJDF.js +0 -98
  25. package/lib/JJDF.js.map +0 -1
  26. package/lib/JJE.d.ts +0 -299
  27. package/lib/JJE.js +0 -401
  28. package/lib/JJE.js.map +0 -1
  29. package/lib/JJET.d.ts +0 -79
  30. package/lib/JJET.js +0 -114
  31. package/lib/JJET.js.map +0 -1
  32. package/lib/JJEx.d.ts +0 -63
  33. package/lib/JJEx.js +0 -83
  34. package/lib/JJEx.js.map +0 -1
  35. package/lib/JJHE.d.ts +0 -109
  36. package/lib/JJHE.js +0 -136
  37. package/lib/JJHE.js.map +0 -1
  38. package/lib/JJN-wrap.d.ts +0 -1
  39. package/lib/JJN-wrap.js +0 -46
  40. package/lib/JJN-wrap.js.map +0 -1
  41. package/lib/JJN.d.ts +0 -126
  42. package/lib/JJN.js +0 -166
  43. package/lib/JJN.js.map +0 -1
  44. package/lib/JJNx.d.ts +0 -126
  45. package/lib/JJNx.js +0 -157
  46. package/lib/JJNx.js.map +0 -1
  47. package/lib/JJSE.d.ts +0 -170
  48. package/lib/JJSE.js +0 -217
  49. package/lib/JJSE.js.map +0 -1
  50. package/lib/JJSR.d.ts +0 -71
  51. package/lib/JJSR.js +0 -90
  52. package/lib/JJSR.js.map +0 -1
  53. package/lib/JJT.d.ts +0 -92
  54. package/lib/JJT.js +0 -116
  55. package/lib/JJT.js.map +0 -1
  56. package/lib/case.d.ts +0 -60
  57. package/lib/case.js +0 -92
  58. package/lib/case.js.map +0 -1
  59. package/lib/components.d.ts +0 -147
  60. package/lib/components.js +0 -287
  61. package/lib/components.js.map +0 -1
  62. package/lib/helpers.d.ts +0 -159
  63. package/lib/helpers.js +0 -233
  64. package/lib/helpers.js.map +0 -1
  65. package/lib/index.d.ts +0 -33
  66. package/lib/index.js +0 -35
  67. package/lib/index.js.map +0 -1
  68. package/lib/internal.d.ts +0 -30
  69. package/lib/internal.js +0 -35
  70. package/lib/internal.js.map +0 -1
  71. package/lib/types.d.ts +0 -65
  72. package/lib/types.js +0 -2
  73. package/lib/types.js.map +0 -1
  74. package/lib/util.d.ts +0 -68
  75. package/lib/util.js +0 -90
  76. package/lib/util.js.map +0 -1
  77. package/llms.txt +0 -214
package/lib/JJN.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJN.js","sourceRoot":"","sources":["../src/JJN.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;;;;;GAQG;AAEH,MAAM,OAAO,GAA2B,SAAQ,IAAO;IACnD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,IAAI,CAAC,IAAU;QAClB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IAED;;;;;;;;OAQG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;IAC3C,CAAC;IAED;;;;;OAKG;IACH,YAAY,GAAM;QACd,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,SAAS,CACf,oCAAoC,GAAG,KAAK,OAAO,GAAG,KAAK;gBACvD,uFAAuF,CAC9F,CAAA;QACL,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAc;QAChB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,IAAoB;QACxB,IAAI,IAAI,EAAE,CAAC;YACP,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
package/lib/JJNx.d.ts DELETED
@@ -1,126 +0,0 @@
1
- import { JJN } from './JJN.js';
2
- import { Wrappable, Wrapped } from './types.js';
3
- export declare abstract class JJNx<T extends Element | Document | DocumentFragment> extends JJN<T> {
4
- /**
5
- * Finds the first element matching a selector within this Element.
6
- *
7
- * @example
8
- * ```ts
9
- * const span = el.query('span') // Returns null if not found
10
- * const span = el.query('span', true) // Throws if not found
11
- * ```
12
- *
13
- * @param selector - The CSS selector.
14
- * @param required - Whether to throw an error if not found. Defaults to false.
15
- * @returns The wrapped element, or null if not found and required is false.
16
- * @throws {TypeError} If selector is not a string or element not found and required is true.
17
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | Element.querySelector}
18
- */
19
- query(selector: string, required?: boolean): Wrapped | null;
20
- /**
21
- * Finds all elements matching a selector within this Element.
22
- *
23
- * @example
24
- * ```ts
25
- * const items = el.queryAll('li')
26
- * ```
27
- *
28
- * @param selector - The CSS selector.
29
- * @returns An array of wrapped elements.
30
- * @throws {TypeError} If selector is not a string.
31
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll | Element.querySelectorAll}
32
- */
33
- queryAll(selector: string): Wrapped[];
34
- /**
35
- * Appends children to this Element.
36
- *
37
- * @example
38
- * ```ts
39
- * el.append(h('span', null, 'hello'))
40
- * ```
41
- *
42
- * @remarks
43
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
44
- *
45
- * @param children - The children to append.
46
- * @returns This instance for chaining.
47
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/append | Element.append}
48
- */
49
- append(...children: Wrappable[]): this;
50
- /**
51
- * Prepends children to this Element.
52
- *
53
- * @example
54
- * ```ts
55
- * el.prepend(h('span', null, 'first'))
56
- * ```
57
- *
58
- * @remarks
59
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
60
- *
61
- * @param children - The children to prepend.
62
- * @returns This instance for chaining.
63
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend | Element.prepend}
64
- */
65
- prepend(...children: Wrappable[]): this;
66
- /**
67
- * Maps an array to children and appends them.
68
- *
69
- * @example
70
- * ```ts
71
- * node.mapAppend(['a', 'b'], item => h('li', null, item))
72
- * ```
73
- *
74
- * @remarks
75
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
76
- *
77
- * @param array - The source array.
78
- * @param mapFn - The mapping function returning a Wrappable.
79
- * @returns This instance for chaining.
80
- */
81
- mapAppend(array: Wrappable[], mapFn: (item: Wrappable) => Wrappable): this;
82
- /**
83
- * Maps an array to children and prepends them.
84
- *
85
- * @example
86
- * ```ts
87
- * node.mapPrepend(['a', 'b'], item => JJHE.fromTag('li').setText(item))
88
- * ```
89
- *
90
- * @remarks
91
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
92
- *
93
- * @param array - The source array.
94
- * @param mapFn - The mapping function.
95
- * @returns This instance for chaining.
96
- */
97
- mapPrepend(array: Wrappable[], mapFn: (item: Wrappable) => Wrappable): this;
98
- /**
99
- * Replaces the existing children of an Element with a specified new set of children.
100
- *
101
- * @remarks
102
- * If no children are provided, it empties the Element.
103
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
104
- *
105
- * @example
106
- * ```ts
107
- * el.setChildren(h('p', null, 'New Content'))
108
- * ```
109
- * @param children - The children to replace with.
110
- * @returns This instance for chaining.
111
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
112
- */
113
- setChildren(...children: Wrappable[]): this;
114
- /**
115
- * Removes all children from this Element.
116
- *
117
- * @example
118
- * ```ts
119
- * el.empty()
120
- * ```
121
- *
122
- * @returns This instance for chaining.
123
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.setChildren}
124
- */
125
- empty(): this;
126
- }
package/lib/JJNx.js DELETED
@@ -1,157 +0,0 @@
1
- import { JJN } from './JJN.js';
2
- export class JJNx extends JJN {
3
- /**
4
- * Finds the first element matching a selector within this Element.
5
- *
6
- * @example
7
- * ```ts
8
- * const span = el.query('span') // Returns null if not found
9
- * const span = el.query('span', true) // Throws if not found
10
- * ```
11
- *
12
- * @param selector - The CSS selector.
13
- * @param required - Whether to throw an error if not found. Defaults to false.
14
- * @returns The wrapped element, or null if not found and required is false.
15
- * @throws {TypeError} If selector is not a string or element not found and required is true.
16
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | Element.querySelector}
17
- */
18
- query(selector, required = false) {
19
- const queryResult = this.ref.querySelector(selector);
20
- if (queryResult) {
21
- return JJN.wrap(queryResult);
22
- }
23
- if (required) {
24
- throw new TypeError(`Element with selector "${selector}" not found. ` +
25
- `Did you mean to call .query("${selector}", false) to return null instead? `);
26
- }
27
- return null;
28
- }
29
- /**
30
- * Finds all elements matching a selector within this Element.
31
- *
32
- * @example
33
- * ```ts
34
- * const items = el.queryAll('li')
35
- * ```
36
- *
37
- * @param selector - The CSS selector.
38
- * @returns An array of wrapped elements.
39
- * @throws {TypeError} If selector is not a string.
40
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll | Element.querySelectorAll}
41
- */
42
- queryAll(selector) {
43
- return JJN.wrapAll(this.ref.querySelectorAll(selector));
44
- }
45
- /**
46
- * Appends children to this Element.
47
- *
48
- * @example
49
- * ```ts
50
- * el.append(h('span', null, 'hello'))
51
- * ```
52
- *
53
- * @remarks
54
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
55
- *
56
- * @param children - The children to append.
57
- * @returns This instance for chaining.
58
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/append | Element.append}
59
- */
60
- append(...children) {
61
- const nodes = JJN.unwrapAll(children.filter(JJN.isWrapable));
62
- this.ref.append(...nodes);
63
- return this;
64
- }
65
- /**
66
- * Prepends children to this Element.
67
- *
68
- * @example
69
- * ```ts
70
- * el.prepend(h('span', null, 'first'))
71
- * ```
72
- *
73
- * @remarks
74
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
75
- *
76
- * @param children - The children to prepend.
77
- * @returns This instance for chaining.
78
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend | Element.prepend}
79
- */
80
- prepend(...children) {
81
- const nodes = JJN.unwrapAll(children.filter(JJN.isWrapable));
82
- this.ref.prepend(...nodes);
83
- return this;
84
- }
85
- /**
86
- * Maps an array to children and appends them.
87
- *
88
- * @example
89
- * ```ts
90
- * node.mapAppend(['a', 'b'], item => h('li', null, item))
91
- * ```
92
- *
93
- * @remarks
94
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
95
- *
96
- * @param array - The source array.
97
- * @param mapFn - The mapping function returning a Wrappable.
98
- * @returns This instance for chaining.
99
- */
100
- mapAppend(array, mapFn) {
101
- return this.append(...array.map(mapFn));
102
- }
103
- /**
104
- * Maps an array to children and prepends them.
105
- *
106
- * @example
107
- * ```ts
108
- * node.mapPrepend(['a', 'b'], item => JJHE.fromTag('li').setText(item))
109
- * ```
110
- *
111
- * @remarks
112
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
113
- *
114
- * @param array - The source array.
115
- * @param mapFn - The mapping function.
116
- * @returns This instance for chaining.
117
- */
118
- mapPrepend(array, mapFn) {
119
- return this.prepend(...array.map(mapFn));
120
- }
121
- /**
122
- * Replaces the existing children of an Element with a specified new set of children.
123
- *
124
- * @remarks
125
- * If no children are provided, it empties the Element.
126
- * To make template codes easier, this function ignores any child that is not possible to `wrap()` (e.g. undefined, null, false).
127
- *
128
- * @example
129
- * ```ts
130
- * el.setChildren(h('p', null, 'New Content'))
131
- * ```
132
- * @param children - The children to replace with.
133
- * @returns This instance for chaining.
134
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
135
- */
136
- setChildren(...children) {
137
- const nodes = JJN.unwrapAll(children.filter(JJN.isWrapable));
138
- this.ref.replaceChildren(...nodes);
139
- return this;
140
- }
141
- /**
142
- * Removes all children from this Element.
143
- *
144
- * @example
145
- * ```ts
146
- * el.empty()
147
- * ```
148
- *
149
- * @returns This instance for chaining.
150
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.setChildren}
151
- */
152
- empty() {
153
- this.setChildren();
154
- return this;
155
- }
156
- }
157
- //# sourceMappingURL=JJNx.js.map
package/lib/JJNx.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJNx.js","sourceRoot":"","sources":["../src/JJNx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG9B,MAAM,OAAgB,IAAsD,SAAQ,GAAM;IACtF;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,QAAgB,EAAE,QAAQ,GAAG,KAA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;;;;OAcG;IACH,UAAU,CAAC,KAAkB,EAAE,KAAqC;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,GAAG,QAAqB;QAChC,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAA;QAC5D,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC,CAAA;QAClC,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK;QACD,IAAI,CAAC,WAAW,EAAE,CAAA;QAClB,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
package/lib/JJSE.d.ts DELETED
@@ -1,170 +0,0 @@
1
- import { JJEx } from './JJEx.js';
2
- /**
3
- * Wraps a DOM SVGElement.
4
- *
5
- * @remarks
6
- * This class extends `JJE` to provide specific functionality for SVG elements,
7
- * including namespace-aware creation and helper methods for common SVG attributes.
8
- *
9
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement | SVGElement}
10
- */
11
- export declare class JJSE<T extends SVGElement = SVGElement> extends JJEx<T> {
12
- /**
13
- * Creates a JJSE instance from an SVGElement reference.
14
- *
15
- * @example
16
- * ```ts
17
- * const svg = JJSE.from(myCircle)
18
- * ```
19
- *
20
- * @param ref - The SVGElement.
21
- * @returns A new JJSE instance.
22
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement | SVGElement}
23
- */
24
- static from(ref: SVGElement): JJSE;
25
- /**
26
- * Creates a JJSE instance from a tag name (in the SVG namespace).
27
- *
28
- * @remarks
29
- * Automatically uses the correct SVG namespace URI: `http://www.w3.org/2000/svg`.
30
- *
31
- * @example
32
- * ```ts
33
- * const circle = JJSE.fromTag('circle')
34
- * ```
35
- *
36
- * @param tagName - The tag name.
37
- * @param options - Element creation options.
38
- * @returns A new JJSE instance.
39
- * @throws {TypeError} If `tagName` is not a string.
40
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS | document.createElementNS}
41
- */
42
- static fromTag(tagName: string, options?: ElementCreationOptions): JJSE;
43
- /**
44
- * Creates an instance of JJSE.
45
- *
46
- * @param ref - The SVGElement to wrap.
47
- * @throws {TypeError} If `ref` is not an SVGElement.
48
- */
49
- constructor(ref: T);
50
- /**
51
- * Gets the text content of the SVGElement.
52
- *
53
- * @remarks
54
- * This method operates on `textContent`. The method name is kept short for convenience.
55
- *
56
- * @example
57
- * ```ts
58
- * const text = svg.getText()
59
- * ```
60
- *
61
- * @returns The text content.
62
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
63
- */
64
- getText(): string;
65
- /**
66
- * Sets the text content of the SVGElement.
67
- *
68
- * @remarks
69
- * This method operates on `textContent`. The method name is kept short for convenience.
70
- * Pass an empty string, `null`, or `undefined` to clear the content.
71
- * Numbers and booleans are automatically converted to strings.
72
- *
73
- * @example
74
- * ```ts
75
- * svg.setText('Hello SVG')
76
- * svg.setText(null) // Clear content
77
- * svg.setText(42) // Numbers are converted
78
- * ```
79
- *
80
- * @param text - The text to set, or null/undefined to clear.
81
- * @returns This instance for chaining.
82
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
83
- */
84
- setText(text?: any): this;
85
- /**
86
- * Clears the text content of the SVGElement.
87
- *
88
- * @example
89
- * ```ts
90
- * svg.empty()
91
- * ```
92
- *
93
- * @returns This instance for chaining.
94
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
95
- */
96
- empty(): this;
97
- /**
98
- * Sets the fill attribute.
99
- *
100
- * @param value - The fill color/value.
101
- * @returns This instance for chaining.
102
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill | fill}
103
- */
104
- setFill(value: string): this;
105
- /**
106
- * Sets the stroke attribute.
107
- *
108
- * @param value - The stroke color/value.
109
- * @returns This instance for chaining.
110
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke | stroke}
111
- */
112
- setStroke(value: string): this;
113
- /**
114
- * Sets the stroke-width attribute.
115
- *
116
- * @param value - The width.
117
- * @returns This instance for chaining.
118
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width | stroke-width}
119
- */
120
- setStrokeWidth(value: string | number): this;
121
- /**
122
- * Sets the viewBox attribute.
123
- *
124
- * @example
125
- * ```ts
126
- * svg.setViewBox(0, 0, 100, 100)
127
- * svg.setViewBox('0 0 100 100')
128
- * ```
129
- *
130
- * @param p1 - Min-x or string/array value.
131
- * @param p2 - Min-y.
132
- * @param p3 - Width.
133
- * @param p4 - Height.
134
- * @returns This instance for chaining.
135
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox | viewBox}
136
- */
137
- setViewBox(p1: string | (string | number)[] | number, p2?: number, p3?: number, p4?: number): this;
138
- /**
139
- * Sets the width attribute.
140
- *
141
- * @param value - The width.
142
- * @returns This instance for chaining.
143
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/width | width}
144
- */
145
- setWidth(value: string | number): this;
146
- /**
147
- * Sets the height attribute.
148
- *
149
- * @param value - The height.
150
- * @returns This instance for chaining.
151
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/height | height}
152
- */
153
- setHeight(value: string | number): this;
154
- /**
155
- * Sets the d attribute (path data).
156
- *
157
- * @param value - The path data string or array of segments.
158
- * @returns This instance for chaining.
159
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d | d}
160
- */
161
- setD(value: string | (string | number)[]): this;
162
- /**
163
- * Sets the transform attribute.
164
- *
165
- * @param value - The transform string.
166
- * @returns This instance for chaining.
167
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform | transform}
168
- */
169
- setTransform(value: string): this;
170
- }
package/lib/JJSE.js DELETED
@@ -1,217 +0,0 @@
1
- import { isA, isStr } from 'jty';
2
- import { JJEx } from './JJEx.js';
3
- const SVG_NAMESPACE_URI = 'http://www.w3.org/2000/svg';
4
- /**
5
- * Wraps a DOM SVGElement.
6
- *
7
- * @remarks
8
- * This class extends `JJE` to provide specific functionality for SVG elements,
9
- * including namespace-aware creation and helper methods for common SVG attributes.
10
- *
11
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement | SVGElement}
12
- */
13
- export class JJSE extends JJEx {
14
- /**
15
- * Creates a JJSE instance from an SVGElement reference.
16
- *
17
- * @example
18
- * ```ts
19
- * const svg = JJSE.from(myCircle)
20
- * ```
21
- *
22
- * @param ref - The SVGElement.
23
- * @returns A new JJSE instance.
24
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SVGElement | SVGElement}
25
- */
26
- static from(ref) {
27
- return new JJSE(ref);
28
- }
29
- /**
30
- * Creates a JJSE instance from a tag name (in the SVG namespace).
31
- *
32
- * @remarks
33
- * Automatically uses the correct SVG namespace URI: `http://www.w3.org/2000/svg`.
34
- *
35
- * @example
36
- * ```ts
37
- * const circle = JJSE.fromTag('circle')
38
- * ```
39
- *
40
- * @param tagName - The tag name.
41
- * @param options - Element creation options.
42
- * @returns A new JJSE instance.
43
- * @throws {TypeError} If `tagName` is not a string.
44
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS | document.createElementNS}
45
- */
46
- static fromTag(tagName, options) {
47
- if (!isStr(tagName)) {
48
- throw new TypeError(`JJSE.fromTag() expects tagName to be a string (e.g., 'circle', 'path'). ` +
49
- `Got ${tagName} (${typeof tagName}). Did you mean to pass a string literal like 'circle'?`);
50
- }
51
- // SVG elements must be created with the SVG namespace
52
- const element = document.createElementNS(SVG_NAMESPACE_URI, tagName, options);
53
- return new JJSE(element);
54
- }
55
- /**
56
- * Creates an instance of JJSE.
57
- *
58
- * @param ref - The SVGElement to wrap.
59
- * @throws {TypeError} If `ref` is not an SVGElement.
60
- */
61
- constructor(ref) {
62
- if (!isA(ref, SVGElement)) {
63
- throw new TypeError(`JJSE expects an SVGElement. Got ${ref} (${typeof ref}). ` +
64
- `Use JJSE.from(element) with an SVG element, or JJSE.fromTag('circle') to create one.`);
65
- }
66
- super(ref);
67
- }
68
- /**
69
- * Gets the text content of the SVGElement.
70
- *
71
- * @remarks
72
- * This method operates on `textContent`. The method name is kept short for convenience.
73
- *
74
- * @example
75
- * ```ts
76
- * const text = svg.getText()
77
- * ```
78
- *
79
- * @returns The text content.
80
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
81
- */
82
- getText() {
83
- return this.ref.textContent ?? '';
84
- }
85
- /**
86
- * Sets the text content of the SVGElement.
87
- *
88
- * @remarks
89
- * This method operates on `textContent`. The method name is kept short for convenience.
90
- * Pass an empty string, `null`, or `undefined` to clear the content.
91
- * Numbers and booleans are automatically converted to strings.
92
- *
93
- * @example
94
- * ```ts
95
- * svg.setText('Hello SVG')
96
- * svg.setText(null) // Clear content
97
- * svg.setText(42) // Numbers are converted
98
- * ```
99
- *
100
- * @param text - The text to set, or null/undefined to clear.
101
- * @returns This instance for chaining.
102
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
103
- */
104
- setText(text) {
105
- this.ref.textContent = text ?? '';
106
- return this;
107
- }
108
- /**
109
- * Clears the text content of the SVGElement.
110
- *
111
- * @example
112
- * ```ts
113
- * svg.empty()
114
- * ```
115
- *
116
- * @returns This instance for chaining.
117
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
118
- */
119
- empty() {
120
- this.ref.textContent = '';
121
- return this;
122
- }
123
- /**
124
- * Sets the fill attribute.
125
- *
126
- * @param value - The fill color/value.
127
- * @returns This instance for chaining.
128
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill | fill}
129
- */
130
- setFill(value) {
131
- return this.setAttr('fill', value);
132
- }
133
- /**
134
- * Sets the stroke attribute.
135
- *
136
- * @param value - The stroke color/value.
137
- * @returns This instance for chaining.
138
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke | stroke}
139
- */
140
- setStroke(value) {
141
- return this.setAttr('stroke', value);
142
- }
143
- /**
144
- * Sets the stroke-width attribute.
145
- *
146
- * @param value - The width.
147
- * @returns This instance for chaining.
148
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width | stroke-width}
149
- */
150
- setStrokeWidth(value) {
151
- return this.setAttr('stroke-width', String(value));
152
- }
153
- /**
154
- * Sets the viewBox attribute.
155
- *
156
- * @example
157
- * ```ts
158
- * svg.setViewBox(0, 0, 100, 100)
159
- * svg.setViewBox('0 0 100 100')
160
- * ```
161
- *
162
- * @param p1 - Min-x or string/array value.
163
- * @param p2 - Min-y.
164
- * @param p3 - Width.
165
- * @param p4 - Height.
166
- * @returns This instance for chaining.
167
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox | viewBox}
168
- */
169
- setViewBox(p1, p2, p3, p4) {
170
- if (typeof p1 === 'number' && p2 !== undefined && p3 !== undefined && p4 !== undefined) {
171
- return this.setAttr('viewBox', `${p1} ${p2} ${p3} ${p4}`);
172
- }
173
- const value = p1;
174
- return this.setAttr('viewBox', Array.isArray(value) ? value.join(' ') : value);
175
- }
176
- /**
177
- * Sets the width attribute.
178
- *
179
- * @param value - The width.
180
- * @returns This instance for chaining.
181
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/width | width}
182
- */
183
- setWidth(value) {
184
- return this.setAttr('width', String(value));
185
- }
186
- /**
187
- * Sets the height attribute.
188
- *
189
- * @param value - The height.
190
- * @returns This instance for chaining.
191
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/height | height}
192
- */
193
- setHeight(value) {
194
- return this.setAttr('height', String(value));
195
- }
196
- /**
197
- * Sets the d attribute (path data).
198
- *
199
- * @param value - The path data string or array of segments.
200
- * @returns This instance for chaining.
201
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d | d}
202
- */
203
- setD(value) {
204
- return this.setAttr('d', Array.isArray(value) ? value.join(' ') : value);
205
- }
206
- /**
207
- * Sets the transform attribute.
208
- *
209
- * @param value - The transform string.
210
- * @returns This instance for chaining.
211
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform | transform}
212
- */
213
- setTransform(value) {
214
- return this.setAttr('transform', value);
215
- }
216
- }
217
- //# sourceMappingURL=JJSE.js.map
package/lib/JJSE.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJSE.js","sourceRoot":"","sources":["../src/JJSE.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,MAAM,iBAAiB,GAAG,4BAA4B,CAAA;AAEtD;;;;;;;;GAQG;AACH,MAAM,OAAO,IAAwC,SAAQ,IAAO;IAChE;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,CAAC,GAAe;QACvB,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,OAAgC;QAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,SAAS,CACf,0EAA0E;gBACtE,OAAO,OAAO,KAAK,OAAO,OAAO,yDAAyD,CACjG,CAAA;QACL,CAAC;QACD,sDAAsD;QACtD,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,iBAAiB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QAC7E,OAAO,IAAI,IAAI,CAAC,OAAqB,CAAC,C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