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/JJSR.d.ts DELETED
@@ -1,71 +0,0 @@
1
- import { JJDF } from './JJDF.js';
2
- /**
3
- * Wraps a DOM ShadowRoot (which is a descendant of DocumentFragment).
4
- *
5
- * @remarks
6
- * The ShadowRoot interface of the Shadow DOM API is the root node of a DOM subtree
7
- * that is rendered separately from a document's main DOM tree.
8
- *
9
- * ShadowRoot inherits DocumentFragment and therefore has access to all its methods
10
- * most importantly `byId`, `query`, and `queryAll` which come handy to access and
11
- * update its children.
12
- *
13
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot | ShadowRoot}
14
- */
15
- export declare class JJSR<T extends ShadowRoot = ShadowRoot> extends JJDF<T> {
16
- /**
17
- * Creates a JJSR instance from a ShadowRoot reference.
18
- *
19
- * @example
20
- * ```ts
21
- * const shadow = JJSR.from(element.shadowRoot)
22
- * ```
23
- *
24
- * @param shadowRoot - The ShadowRoot instance.
25
- * @returns A new JJSR instance.
26
- */
27
- static from(shadowRoot: ShadowRoot): JJSR<ShadowRoot>;
28
- /**
29
- * Creates an instance of JJSR.
30
- *
31
- * @param shadowRoot - The ShadowRoot to wrap.
32
- * @throws {TypeError} If `shadowRoot` is not a ShadowRoot.
33
- */
34
- constructor(shadowRoot: T);
35
- /**
36
- * Gets the inner HTML of the ShadowRoot.
37
- *
38
- * @returns The inner HTML string.
39
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
40
- */
41
- getHTML(): string;
42
- /**
43
- * Sets the inner HTML of the ShadowRoot.
44
- *
45
- * @example
46
- * ```ts
47
- * shadow.setHTML('<p>Hello</p>', false)
48
- * ```
49
- *
50
- * @param value - The HTML string.
51
- * @param unsafe - Reserved for future use (must be false).
52
- * @returns This instance for chaining.
53
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
54
- */
55
- setHTML(value: string, unsafe: false): this;
56
- /**
57
- * Adds constructed stylesheets to the ShadowRoot.
58
- *
59
- * @example
60
- * ```ts
61
- * const sheet = new CSSStyleSheet()
62
- * sheet.replaceSync('p { color: red; }')
63
- * shadow.addStyleSheets(sheet)
64
- * ```
65
- *
66
- * @param styleSheets - The stylesheets to add.
67
- * @returns This instance for chaining.
68
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets | ShadowRoot.adoptedStyleSheets}
69
- */
70
- addStyleSheets(...styleSheets: CSSStyleSheet[]): this;
71
- }
package/lib/JJSR.js DELETED
@@ -1,90 +0,0 @@
1
- import { isA } from 'jty';
2
- import { JJDF } from './JJDF.js';
3
- /**
4
- * Wraps a DOM ShadowRoot (which is a descendant of DocumentFragment).
5
- *
6
- * @remarks
7
- * The ShadowRoot interface of the Shadow DOM API is the root node of a DOM subtree
8
- * that is rendered separately from a document's main DOM tree.
9
- *
10
- * ShadowRoot inherits DocumentFragment and therefore has access to all its methods
11
- * most importantly `byId`, `query`, and `queryAll` which come handy to access and
12
- * update its children.
13
- *
14
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot | ShadowRoot}
15
- */
16
- export class JJSR extends JJDF {
17
- /**
18
- * Creates a JJSR instance from a ShadowRoot reference.
19
- *
20
- * @example
21
- * ```ts
22
- * const shadow = JJSR.from(element.shadowRoot)
23
- * ```
24
- *
25
- * @param shadowRoot - The ShadowRoot instance.
26
- * @returns A new JJSR instance.
27
- */
28
- static from(shadowRoot) {
29
- return new JJSR(shadowRoot);
30
- }
31
- /**
32
- * Creates an instance of JJSR.
33
- *
34
- * @param shadowRoot - The ShadowRoot to wrap.
35
- * @throws {TypeError} If `shadowRoot` is not a ShadowRoot.
36
- */
37
- constructor(shadowRoot) {
38
- if (!isA(shadowRoot, ShadowRoot)) {
39
- throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${shadowRoot} (${typeof shadowRoot}). ` +
40
- `Access a shadow root using element.shadowRoot after calling element.attachShadow().`);
41
- }
42
- super(shadowRoot);
43
- }
44
- /**
45
- * Gets the inner HTML of the ShadowRoot.
46
- *
47
- * @returns The inner HTML string.
48
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
49
- */
50
- getHTML() {
51
- return this.ref.innerHTML;
52
- }
53
- /**
54
- * Sets the inner HTML of the ShadowRoot.
55
- *
56
- * @example
57
- * ```ts
58
- * shadow.setHTML('<p>Hello</p>', false)
59
- * ```
60
- *
61
- * @param value - The HTML string.
62
- * @param unsafe - Reserved for future use (must be false).
63
- * @returns This instance for chaining.
64
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML | Element.innerHTML}
65
- */
66
- setHTML(value, unsafe) {
67
- // TODO: https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/setHTMLUnsafe
68
- this.ref.innerHTML = value;
69
- return this;
70
- }
71
- /**
72
- * Adds constructed stylesheets to the ShadowRoot.
73
- *
74
- * @example
75
- * ```ts
76
- * const sheet = new CSSStyleSheet()
77
- * sheet.replaceSync('p { color: red; }')
78
- * shadow.addStyleSheets(sheet)
79
- * ```
80
- *
81
- * @param styleSheets - The stylesheets to add.
82
- * @returns This instance for chaining.
83
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets | ShadowRoot.adoptedStyleSheets}
84
- */
85
- addStyleSheets(...styleSheets) {
86
- this.ref.adoptedStyleSheets.push(...styleSheets);
87
- return this;
88
- }
89
- }
90
- //# sourceMappingURL=JJSR.js.map
package/lib/JJSR.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"JJSR.js","sourceRoot":"","sources":["../src/JJSR.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,IAAwC,SAAQ,IAAO;IAChE;;;;;;;;;;OAUG;IACH,MAAM,CAAC,IAAI,CAAC,UAAsB;QAC9B,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC/B,CAAC;IAED;;;;;OAKG;IACH,YAAY,UAAa;QACrB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,SAAS,CACf,2CAA2C,UAAU,KAAK,OAAO,UAAU,KAAK;gBAC5E,qFAAqF,CAC5F,CAAA;QACL,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;IAED;;;;;OAKG;IACH,OAAO;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAA;IAC7B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,KAAa,EAAE,MAAa;QAChC,kFAAkF;QAClF,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,KAAK,CAAA;QAC1B,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,GAAG,WAA4B;QAC1C,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAA;QAChD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
package/lib/JJT.d.ts DELETED
@@ -1,92 +0,0 @@
1
- import { JJN } from './JJN.js';
2
- /**
3
- * Wraps a DOM Text Node.
4
- *
5
- * @remarks
6
- * The Text interface represents the textual content of Element or Attr.
7
- * If an element has no markup within its content, it has a single child implementing Text
8
- * that contains the element's text.
9
- *
10
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Text | Text}
11
- */
12
- export declare class JJT<T extends Text = Text> extends JJN<Text> {
13
- /**
14
- * Creates a JJT instance from a Text node.
15
- *
16
- * @example
17
- * ```ts
18
- * const textNode = document.createTextNode('foo')
19
- * const text = JJT.from(textNode)
20
- * ```
21
- *
22
- * @param text - The Text node.
23
- * @returns A new JJT instance.
24
- * @throws {TypeError} If `text` is not a Text node.
25
- */
26
- static from(text: Text): JJT;
27
- static fromStr(text: string): JJT;
28
- /**
29
- * Creates an instance of JJT.
30
- *
31
- * @example
32
- * ```ts
33
- * const text = new JJT('Hello World')
34
- * ```
35
- *
36
- * @param ref - The Text node or a string to create a Text node from.
37
- * @throws {TypeError} If `ref` is not a Text node or string.
38
- */
39
- constructor(ref: T);
40
- /**
41
- * Gets the text content of the Text node.
42
- *
43
- * @example
44
- * ```ts
45
- * const content = text.getText()
46
- * ```
47
- *
48
- * @returns The text content.
49
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
50
- */
51
- getText(): string;
52
- /**
53
- * Sets the text content of the Text node.
54
- *
55
- * @example
56
- * ```ts
57
- * text.setText('New content')
58
- * ```
59
- *
60
- * @param text - The text to set. Set it to null or undefined to remove all text
61
- * @returns This instance for chaining.
62
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
63
- */
64
- setText(text?: any): this;
65
- /**
66
- * Appends text to the existing content.
67
- *
68
- * @example
69
- * ```ts
70
- * text.setText('hello')
71
- * text.addText(' world')
72
- * console.log(text.getText()) // 'hello world'
73
- * ```
74
- *
75
- * @param text - The string to add to the existing contents. If null or undefined, nothing is added.
76
- * @returns This instance for chaining.
77
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
78
- */
79
- addText(text?: any): this;
80
- /**
81
- * Clears the text content of the Text node.
82
- *
83
- * @example
84
- * ```ts
85
- * text.empty()
86
- * ```
87
- *
88
- * @returns This instance for chaining.
89
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
90
- */
91
- empty(): this;
92
- }
package/lib/JJT.js DELETED
@@ -1,116 +0,0 @@
1
- import { isA } from 'jty';
2
- import { JJN } from './JJN.js';
3
- /**
4
- * Wraps a DOM Text Node.
5
- *
6
- * @remarks
7
- * The Text interface represents the textual content of Element or Attr.
8
- * If an element has no markup within its content, it has a single child implementing Text
9
- * that contains the element's text.
10
- *
11
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Text | Text}
12
- */
13
- export class JJT extends JJN {
14
- /**
15
- * Creates a JJT instance from a Text node.
16
- *
17
- * @example
18
- * ```ts
19
- * const textNode = document.createTextNode('foo')
20
- * const text = JJT.from(textNode)
21
- * ```
22
- *
23
- * @param text - The Text node.
24
- * @returns A new JJT instance.
25
- * @throws {TypeError} If `text` is not a Text node.
26
- */
27
- static from(text) {
28
- return new JJT(text);
29
- }
30
- static fromStr(text) {
31
- return new JJT(document.createTextNode(text));
32
- }
33
- /**
34
- * Creates an instance of JJT.
35
- *
36
- * @example
37
- * ```ts
38
- * const text = new JJT('Hello World')
39
- * ```
40
- *
41
- * @param ref - The Text node or a string to create a Text node from.
42
- * @throws {TypeError} If `ref` is not a Text node or string.
43
- */
44
- constructor(ref) {
45
- if (!isA(ref, Text)) {
46
- throw new TypeError(`JJT expects a Text node. Got ${ref} (${typeof ref}). ` +
47
- `Create a Text node with JJT.fromStr() or document.createTextNode('text').`);
48
- }
49
- super(ref);
50
- }
51
- /**
52
- * Gets the text content of the Text node.
53
- *
54
- * @example
55
- * ```ts
56
- * const content = text.getText()
57
- * ```
58
- *
59
- * @returns The text content.
60
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
61
- */
62
- getText() {
63
- return this.ref.textContent;
64
- }
65
- /**
66
- * Sets the text content of the Text node.
67
- *
68
- * @example
69
- * ```ts
70
- * text.setText('New content')
71
- * ```
72
- *
73
- * @param text - The text to set. Set it to null or undefined to remove all text
74
- * @returns This instance for chaining.
75
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
76
- */
77
- setText(text) {
78
- this.ref.textContent = text ?? null;
79
- return this;
80
- }
81
- /**
82
- * Appends text to the existing content.
83
- *
84
- * @example
85
- * ```ts
86
- * text.setText('hello')
87
- * text.addText(' world')
88
- * console.log(text.getText()) // 'hello world'
89
- * ```
90
- *
91
- * @param text - The string to add to the existing contents. If null or undefined, nothing is added.
92
- * @returns This instance for chaining.
93
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
94
- */
95
- addText(text) {
96
- if (text != null) {
97
- this.ref.textContent += text;
98
- }
99
- return this;
100
- }
101
- /**
102
- * Clears the text content of the Text node.
103
- *
104
- * @example
105
- * ```ts
106
- * text.empty()
107
- * ```
108
- *
109
- * @returns This instance for chaining.
110
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
111
- */
112
- empty() {
113
- return this.setText('');
114
- }
115
- }
116
- //# sourceMappingURL=JJT.js.map
package/lib/JJT.js.map DELETED
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EAAE,CAAC,CAAA;IAC3B,CAAC;CACJ"}
package/lib/case.d.ts DELETED
@@ -1,60 +0,0 @@
1
- /**
2
- * Converts a PascalCase, camelCase, or snake_case string to kebab-case.
3
- *
4
- * @remarks
5
- * This function is useful for converting JavaScript property names to CSS or HTML attribute names.
6
- * It strictly validates the input to contain only alphanumeric characters and underscores.
7
- *
8
- * @example
9
- * ```ts
10
- * pas2keb('backgroundColor') // 'background-color'
11
- * pas2keb('MyComponent') // 'my-component'
12
- * pas2keb('user_id') // 'user-id'
13
- * ```
14
- *
15
- * @param str - The string to convert.
16
- * @returns The kebab-case string.
17
- * @throws {TypeError} If `str` is not a string or contains invalid characters (anything other than `/[a-zA-Z0-9_]/`).
18
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace | String.prototype.replace}
19
- */
20
- export declare function pas2keb(str: string): string;
21
- /**
22
- * Converts a kebab-case string to PascalCase.
23
- *
24
- * @remarks
25
- * This function splits the string by hyphens and capitalizes the first letter of each segment.
26
- * It handles multiple hyphens by ignoring empty segments.
27
- *
28
- * @example
29
- * ```ts
30
- * keb2pas('background-color') // 'BackgroundColor'
31
- * keb2pas('my-component') // 'MyComponent'
32
- * keb2pas('multi--dash') // 'MultiDash'
33
- * ```
34
- *
35
- * @param str - The string to convert.
36
- * @returns The PascalCase string.
37
- * @throws {TypeError} If `str` is not a string.
38
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split | String.prototype.split}
39
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.prototype.map}
40
- */
41
- export declare function keb2pas(str: string): string;
42
- /**
43
- * Converts a kebab-case string to camelCase.
44
- *
45
- * @remarks
46
- * This function is primarily useful for converting attributes to JavaScript property names.
47
- * Leading and trailing hyphens are removed before conversion.
48
- *
49
- * @example
50
- * ```ts
51
- * keb2cam('background-color') // 'backgroundColor'
52
- * keb2cam('-webkit-transform') // 'webkitTransform'
53
- * ```
54
- *
55
- * @param str - The string to convert.
56
- * @returns The camelCase string.
57
- * @throws {TypeError} If `str` is not a string.
58
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace | String.prototype.replace}
59
- */
60
- export declare function keb2cam(str: string): string;
package/lib/case.js DELETED
@@ -1,92 +0,0 @@
1
- import { isStr } from 'jty';
2
- /**
3
- * Converts a PascalCase, camelCase, or snake_case string to kebab-case.
4
- *
5
- * @remarks
6
- * This function is useful for converting JavaScript property names to CSS or HTML attribute names.
7
- * It strictly validates the input to contain only alphanumeric characters and underscores.
8
- *
9
- * @example
10
- * ```ts
11
- * pas2keb('backgroundColor') // 'background-color'
12
- * pas2keb('MyComponent') // 'my-component'
13
- * pas2keb('user_id') // 'user-id'
14
- * ```
15
- *
16
- * @param str - The string to convert.
17
- * @returns The kebab-case string.
18
- * @throws {TypeError} If `str` is not a string or contains invalid characters (anything other than `/[a-zA-Z0-9_]/`).
19
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace | String.prototype.replace}
20
- */
21
- export function pas2keb(str) {
22
- if (!isStr(str)) {
23
- throw new TypeError(`Expected a string. Got ${str} (${typeof str})`);
24
- }
25
- if (/[^a-zA-Z0-9_]/.test(str)) {
26
- throw new TypeError(`Invalid characters in string. Only alphanumeric and underscores are allowed. Got: ${str}`);
27
- }
28
- return str
29
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
30
- .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
31
- .replace(/_/g, '-')
32
- .toLowerCase();
33
- }
34
- /**
35
- * Converts a kebab-case string to PascalCase.
36
- *
37
- * @remarks
38
- * This function splits the string by hyphens and capitalizes the first letter of each segment.
39
- * It handles multiple hyphens by ignoring empty segments.
40
- *
41
- * @example
42
- * ```ts
43
- * keb2pas('background-color') // 'BackgroundColor'
44
- * keb2pas('my-component') // 'MyComponent'
45
- * keb2pas('multi--dash') // 'MultiDash'
46
- * ```
47
- *
48
- * @param str - The string to convert.
49
- * @returns The PascalCase string.
50
- * @throws {TypeError} If `str` is not a string.
51
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split | String.prototype.split}
52
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.prototype.map}
53
- */
54
- export function keb2pas(str) {
55
- if (!isStr(str)) {
56
- throw new TypeError(`Expected a string. Got ${str} (${typeof str})`);
57
- }
58
- return (str
59
- .split('-')
60
- .filter(Boolean) // Remove empty strings from leading/trailing/multiple hyphens
61
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
62
- .join('') ||
63
- // Handle strings that were not kebab-case to begin with (e.g. 'single', 'camelCase')
64
- (str.length > 0 ? str.charAt(0).toUpperCase() + str.slice(1) : ''));
65
- }
66
- /**
67
- * Converts a kebab-case string to camelCase.
68
- *
69
- * @remarks
70
- * This function is primarily useful for converting attributes to JavaScript property names.
71
- * Leading and trailing hyphens are removed before conversion.
72
- *
73
- * @example
74
- * ```ts
75
- * keb2cam('background-color') // 'backgroundColor'
76
- * keb2cam('-webkit-transform') // 'webkitTransform'
77
- * ```
78
- *
79
- * @param str - The string to convert.
80
- * @returns The camelCase string.
81
- * @throws {TypeError} If `str` is not a string.
82
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace | String.prototype.replace}
83
- */
84
- export function keb2cam(str) {
85
- if (!isStr(str)) {
86
- throw new TypeError(`Expected a string. Got ${str} (${typeof str})`);
87
- }
88
- return str
89
- .replace(/^-+|-+$/g, '') // Remove any leading or trailing hyphens
90
- .replace(/-+([a-z])/g, (g, c) => c.toUpperCase());
91
- }
92
- //# sourceMappingURL=case.js.map
package/lib/case.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"case.js","sourceRoot":"","sources":["../src/case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,E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AAC,EAAE,CAAC,CACrE,CAAA;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,SAAS,CAAC,0BAA0B,GAAG,KAAK,OAAO,GAAG,GAAG,CAAC,CAAA;IACxE,CAAC;IACD,OAAO,GAAG;SACL,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,yCAAyC;SACjE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACzD,CAAC"}
@@ -1,147 +0,0 @@
1
- import { JJStyleConfig, JJTemplateConfig, ShadowConfig } from './types.js';
2
- /**
3
- * Manages the resolution of Shadow DOM configuration (template and styles).
4
- *
5
- * Allows building up the configuration and resolving it lazily.
6
- *
7
- * @example
8
- * ```ts
9
- * const sm = ShadowMaster.create()
10
- * .setTemplate('<div>Hello World</div>')
11
- * .addStyles('div { color: red; }')
12
- *
13
- * class MyComponent extends HTMLElement {
14
- * async connectedCallback() {
15
- * // Resolves the config once and caches it
16
- * const shadowConfig = await sm.getResolved()
17
- * // ... init shadow root with shadowConfig
18
- * }
19
- * }
20
- * ```
21
- */
22
- export declare class ShadowMaster {
23
- #private;
24
- /**
25
- * Creates a new instance of ShadowMaster.
26
- *
27
- * @returns A new ShadowMaster instance.
28
- */
29
- static create(): ShadowMaster;
30
- constructor();
31
- /**
32
- * Sets the template configuration.
33
- *
34
- * @param templateConfig - The template configuration.
35
- * @returns The instance for chaining.
36
- *
37
- * @example
38
- * ```ts
39
- * // Accepts string, promise, or fetchHtml result
40
- * sm.setTemplate(fetchHtml('./template.html'))
41
- * ```
42
- */
43
- setTemplate(templateConfig?: JJTemplateConfig): this;
44
- /**
45
- * Adds one or more style configurations.
46
- *
47
- * @param stylesConfig - Variable number of style configurations.
48
- * @returns The instance for chaining.
49
- *
50
- * @example
51
- * ```ts
52
- * sm.addStyles(
53
- * 'p { color: red; }',
54
- * fetchCss('./styles.css'),
55
- * () => fetchCss('../lazy-loaded-styles.css'),
56
- * )
57
- * ```
58
- */
59
- addStyles(...stylesConfig: JJStyleConfig[]): this;
60
- /**
61
- * Resolves the configuration to something that can be fed to `JJHE.initShadow()` function
62
- *
63
- * The result is cached, so subsequent calls return the same promise.
64
- * Note: Any changes made to the ShadowMaster instance (via setTemplate/addStyles)
65
- * after the first call to getResolved() will be ignored.
66
- *
67
- * @returns A promise resolving to the ShadowConfig.
68
- */
69
- getResolved(): Promise<ShadowConfig>;
70
- }
71
- /**
72
- * A helper to bridge the attribute world (kebab-case) to the property world (camelCase).
73
- * It works in tandem with browser's `observedAttributes` feature which triggers
74
- * `attributeChangedCallback`.
75
- *
76
- * @remarks
77
- * Your custom component class MUST define `static observedAttributes[]` otherwise `attributeChangedCallback` won't trigger.
78
- * `observedAttributes` should contain kebab-based attribute names.
79
- *
80
- * @example
81
- * ```ts
82
- * class MyComponent extends HTMLElement {
83
- * static observedAttributes = ['user-name', 'counter']
84
- * userName = '' // Property MUST exist on the instance (or prototype setter)
85
- * #counter = 0 // You can also use private properties together with getter/setters
86
- *
87
- * attributeChangedCallback(name, oldValue, newValue) {
88
- * attr2prop(this, name, oldValue, newValue)
89
- * }
90
-
91
- * get counter() {
92
- * return this.#counter
93
- * }
94
- *
95
- * set counter(value) {
96
- * this.#counter = value
97
- * this.#render() // You can call your render function to update the DOM
98
- * }
99
- *
100
- * #render() {
101
- * const shadow = JJHE.from(this).shadow
102
- * if (shadow) {
103
- * shadow.byId('user').setText(this.userName)
104
- * shadow.byId('counter').setText(this.counter)
105
- * }
106
- * }
107
- * }
108
- * ```
109
- *
110
- * @param instance - A reference to the common component instance
111
- * @param name - kebab-case and in lower case exactly as it appears in `observedAttributes`.
112
- * @param oldValue - The previous value of the attribute.
113
- * @param newValue - The new value of the attribute.
114
- * @returns `true` if it tried to set the attribute; otherwise `false`.
115
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes | Responding to attribute changes}
116
- */
117
- export declare function attr2prop(instance: HTMLElement, name: string, oldValue: any, newValue: any): boolean;
118
- /**
119
- * Registers the custom element with the browser and waits till it is defined.
120
- *
121
- * @example
122
- * ```ts
123
- * class MyComponent extends HTMLElement {}
124
- * await registerComponent('my-component', MyComponent)
125
- * ```
126
- * Another convention is to have a `static async register()` function in the Custom Component.
127
- * ```ts
128
- * export class MyComponent extends HTMLElement {
129
- * static async register() {
130
- * return registerComponent('my-component', MyComponent)
131
- * }
132
- * }
133
- * ```
134
- * That way, you can import multiple components and do a `Promise.all()` on all their `.register()`s.
135
- * ```ts
136
- * import { MyComponent, YourComponent, TheirComponent } ...
137
- * await Promise.all([
138
- * MyComponent.register(),
139
- * YourComponent.register(),
140
- * TheirComponent.register(),
141
- * ])
142
- *
143
- * @throws {TypeError} If name is not a string or constructor is not a function
144
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define | customElements.define}
145
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/whenDefined | customElements.whenDefined}
146
- */
147
- export declare function registerComponent(name: string, constructor: CustomElementConstructor, options?: ElementDefinitionOptions): Promise<void>;