native-document 1.0.92 → 1.0.94

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 (85) hide show
  1. package/dist/native-document.components.min.js +1088 -65
  2. package/dist/native-document.dev.js +695 -142
  3. package/dist/native-document.dev.js.map +1 -1
  4. package/dist/native-document.devtools.min.js +1 -1
  5. package/dist/native-document.min.js +1 -1
  6. package/docs/advanced-components.md +814 -0
  7. package/docs/anchor.md +71 -11
  8. package/docs/cache.md +888 -0
  9. package/docs/conditional-rendering.md +91 -1
  10. package/docs/core-concepts.md +9 -2
  11. package/docs/elements.md +127 -2
  12. package/docs/extending-native-document-element.md +7 -1
  13. package/docs/filters.md +1216 -0
  14. package/docs/getting-started.md +12 -3
  15. package/docs/lifecycle-events.md +10 -2
  16. package/docs/list-rendering.md +453 -54
  17. package/docs/memory-management.md +9 -7
  18. package/docs/native-document-element.md +30 -9
  19. package/docs/native-fetch.md +744 -0
  20. package/docs/observables.md +135 -6
  21. package/docs/routing.md +7 -1
  22. package/docs/state-management.md +7 -1
  23. package/docs/validation.md +8 -1
  24. package/elements.js +1 -0
  25. package/eslint.config.js +3 -3
  26. package/index.def.js +350 -0
  27. package/package.json +3 -2
  28. package/readme.md +53 -14
  29. package/src/components/$traits/HasItems.js +42 -1
  30. package/src/components/BaseComponent.js +4 -1
  31. package/src/components/accordion/Accordion.js +112 -8
  32. package/src/components/accordion/AccordionItem.js +93 -4
  33. package/src/components/alert/Alert.js +164 -4
  34. package/src/components/avatar/Avatar.js +236 -22
  35. package/src/components/menu/index.js +1 -2
  36. package/src/core/data/ObservableArray.js +120 -2
  37. package/src/core/data/ObservableChecker.js +50 -0
  38. package/src/core/data/ObservableItem.js +124 -4
  39. package/src/core/data/ObservableWhen.js +36 -6
  40. package/src/core/data/observable-helpers/array.js +12 -3
  41. package/src/core/data/observable-helpers/computed.js +17 -4
  42. package/src/core/data/observable-helpers/object.js +19 -3
  43. package/src/core/elements/content-formatter.js +138 -1
  44. package/src/core/elements/control/for-each-array.js +20 -2
  45. package/src/core/elements/control/for-each.js +17 -5
  46. package/src/core/elements/control/show-if.js +31 -15
  47. package/src/core/elements/control/show-when.js +23 -0
  48. package/src/core/elements/control/switch.js +40 -10
  49. package/src/core/elements/description-list.js +14 -0
  50. package/src/core/elements/form.js +188 -4
  51. package/src/core/elements/html5-semantics.js +44 -1
  52. package/src/core/elements/img.js +22 -10
  53. package/src/core/elements/index.js +5 -0
  54. package/src/core/elements/interactive.js +19 -1
  55. package/src/core/elements/list.js +28 -1
  56. package/src/core/elements/medias.js +29 -0
  57. package/src/core/elements/meta-data.js +34 -0
  58. package/src/core/elements/table.js +59 -0
  59. package/src/core/utils/cache.js +5 -0
  60. package/src/core/utils/helpers.js +7 -2
  61. package/src/core/utils/memoize.js +25 -16
  62. package/src/core/utils/prototypes.js +3 -2
  63. package/src/core/wrappers/AttributesWrapper.js +1 -1
  64. package/src/core/wrappers/HtmlElementWrapper.js +2 -2
  65. package/src/core/wrappers/NDElement.js +42 -2
  66. package/src/core/wrappers/NdPrototype.js +4 -0
  67. package/src/core/wrappers/TemplateCloner.js +14 -11
  68. package/src/core/wrappers/prototypes/bind-class-extensions.js +1 -1
  69. package/src/core/wrappers/prototypes/nd-element-extensions.js +3 -0
  70. package/src/router/Route.js +9 -4
  71. package/src/router/Router.js +28 -9
  72. package/src/router/errors/RouterError.js +0 -1
  73. package/types/control-flow.d.ts +9 -6
  74. package/types/elements.d.ts +496 -111
  75. package/types/filters/index.d.ts +4 -0
  76. package/types/forms.d.ts +85 -48
  77. package/types/images.d.ts +16 -9
  78. package/types/nd-element.d.ts +5 -238
  79. package/types/observable.d.ts +9 -3
  80. package/types/router.d.ts +5 -1
  81. package/types/template-cloner.ts +1 -0
  82. package/types/validator.ts +11 -1
  83. package/utils.d.ts +2 -1
  84. package/utils.js +4 -4
  85. package/src/core/utils/service.js +0 -6
package/readme.md CHANGED
@@ -10,6 +10,7 @@
10
10
  NativeDocument combines the familiarity of vanilla JavaScript with the power of modern reactivity. No compilation, no virtual DOM, just pure JavaScript with an intuitive API.
11
11
 
12
12
  ## Why NativeDocument?
13
+ > **Note**: NativeDocument works best with a bundler (Vite, Webpack, Rollup) for tree-shaking and optimal bundle size. The CDN version includes all features
13
14
 
14
15
  ### **Instant Start**
15
16
  ```html
@@ -18,7 +19,7 @@ NativeDocument combines the familiarity of vanilla JavaScript with the power of
18
19
 
19
20
  ### **Familiar API**
20
21
  ```javascript
21
- import { Div, Button } from 'native-document/src/elements';
22
+ import { Div, Button } from 'native-document/elements';
22
23
  import { Observable } from 'native-document';
23
24
 
24
25
  // CDN
@@ -29,7 +30,6 @@ const count = Observable(0);
29
30
 
30
31
  const App = Div({ class: 'app' }, [
31
32
  Div([ 'Count ', count]),
32
- // OR Div(`Count ${count}`),
33
33
  Button('Increment').nd.onClick(() => count.set(count.val() + 1))
34
34
  ]);
35
35
 
@@ -74,7 +74,7 @@ yarn add native-document
74
74
  ## Quick Example
75
75
 
76
76
  ```javascript
77
- import { Div, Input, Button, ShowIf, ForEach } from 'native-document/src/elements'
77
+ import { Div, Input, Button, ShowIf, ForEach } from 'native-document/elements'
78
78
  import { Observable } from 'native-document'
79
79
 
80
80
  // CDN
@@ -105,7 +105,7 @@ const TodoApp = Div({ class: 'todo-app' }, [
105
105
  Input({ type: 'checkbox', checked: todo.done }),
106
106
  `${todo.text}`,
107
107
  Button('Delete').nd.onClick(() => todos.splice(index.val(), 1))
108
- ]), /*item key (string | callback) */(item) => item),
108
+ ]), (item) => item.id ), // Key function - use unique identifier
109
109
 
110
110
  // Empty state
111
111
  ShowIf(
@@ -122,7 +122,7 @@ document.body.appendChild(TodoApp)
122
122
  ### Observables
123
123
  Reactive data that automatically updates the DOM:
124
124
  ```javascript
125
- import { Div } from 'native-document/src/elements'
125
+ import { Div } from 'native-document/elements'
126
126
  import { Observable } from 'native-document'
127
127
 
128
128
  // CDN
@@ -135,16 +135,19 @@ const greeting = Observable.computed(() => `Hello ${user.$value.name}!`, [user])
135
135
 
136
136
  document.body.appendChild(Div(greeting));
137
137
 
138
- // user.name = 'Fausty'; // will not work
139
- // user.$value = { ...user.$value, name: ' Hermes!' }; // will work
140
- // user.set(data => ({ ...data, name: 'Hermes!' })); // will work
138
+ // Direct mutation won't trigger updates
139
+ user.name = 'Fausty';
140
+
141
+ // These will trigger updates:
142
+ user.$value = { ...user.$value, name: ' Hermes!' };
143
+ user.set(data => ({ ...data, name: 'Hermes!' }));
141
144
  user.set({ ...user.val(), name: 'Hermes!' });
142
145
  ```
143
146
 
144
147
  ### Elements
145
148
  Familiar HTML element creation with reactive bindings:
146
149
  ```javascript
147
- import { Div, Button } from 'native-document/src/elements'
150
+ import { Div, Button } from 'native-document/elements'
148
151
  import { Observable } from 'native-document'
149
152
 
150
153
  // CDN
@@ -185,6 +188,30 @@ When(condition)
185
188
  .otherwise(onFalse)
186
189
  ```
187
190
 
191
+ ### List Rendering
192
+ Efficient rendering of lists with automatic updates:
193
+ ```javascript
194
+ import { ForEach, Div } from 'native-document/elements'
195
+ import { Observable } from 'native-document'
196
+
197
+ const items = Observable.array(['Apple', 'Banana', 'Cherry'])
198
+
199
+ ForEach(items, (item, index) =>
200
+ Div([index, '. ', item])
201
+ )
202
+
203
+ // With object arrays - use key function
204
+ const users = Observable.array([
205
+ { id: 1, name: 'Alice' },
206
+ { id: 2, name: 'Bob' }
207
+ ])
208
+
209
+ ForEach(users, (user) =>
210
+ Div(user.name),
211
+ (user) => user.id // Key for efficient updates
212
+ )
213
+ ```
214
+
188
215
  ## Documentation
189
216
 
190
217
  - **[Getting Started](docs/getting-started.md)** - Installation and first steps
@@ -198,10 +225,17 @@ When(condition)
198
225
  - **[Lifecycle Events](docs/lifecycle-events.md)** - Lifecycle events
199
226
  - **[NDElement](docs/native-document-element.md)** - Native Document Element
200
227
  - **[Extending NDElement](docs/extending-native-document-element.md)** - Custom Methods Guide
228
+ - **[Advanced Components](docs/advanced-components.md)** - Template caching and singleton views
201
229
  - **[Args Validation](docs/validation.md)** - Function Argument Validation
202
230
  - **[Memory Management](docs/memory-management.md)** - Memory management
203
231
  - **[Anchor](docs/anchor.md)** - Anchor
204
232
 
233
+ ### Utilities
234
+
235
+ - **[Cache](docs/utils/cache.md)** - Lazy initialization and singleton patterns
236
+ - **[NativeFetch](docs/utils/native-fetch.md)** - HTTP client with interceptors
237
+ - **[Filters](docs/utils/filters.md)** - Data filtering helpers
238
+
205
239
 
206
240
  ## Key Features Deep Dive
207
241
 
@@ -213,6 +247,8 @@ When(condition)
213
247
 
214
248
  ### Developer Experience
215
249
  ```javascript
250
+ import { ArgTypes } from 'native-document'
251
+
216
252
  // Built-in debugging
217
253
  Observable.debug.enable()
218
254
 
@@ -221,12 +257,15 @@ const createUser = (function (name, age) {
221
257
  // Auto-validates argument types
222
258
  }).args(ArgTypes.string('name'), ArgTypes.number('age'))
223
259
 
224
- // Error boundaries
225
- const AppWithBoundayError = App.errorBoundary(() => {
226
- return Div('Error in the Create User component');
227
- })
228
260
 
229
- document.body.appendChild(AppWithBoundayError());
261
+ const SafeApp = App.errorBoundary((error, { caller, args }) => {
262
+ return Div({ class: 'error' }, [
263
+ 'An error occurred: ',
264
+ error.message
265
+ ])
266
+ });
267
+
268
+ document.body.appendChild(SafeApp());
230
269
  ```
231
270
 
232
271
  ## Contributing
@@ -1,22 +1,45 @@
1
1
  import {$} from "../../../index";
2
2
 
3
+ /**
4
+ * Mixin for managing a collection of items with manipulation methods
5
+ * @class
6
+ */
3
7
  export default function HasItems() {}
4
8
 
9
+ /**
10
+ * Sets a dynamic observable array to store items
11
+ * @param {ObservableArray?} [observableArray=null] - Observable array to use, or creates a new one if null
12
+ * @returns {HasItems}
13
+ */
5
14
  HasItems.prototype.dynamic = function(observableArray = null) {
6
15
  this.$description.items = observableArray || $.array([]);
7
16
  return this;
8
17
  };
9
18
 
19
+ /**
20
+ * Replaces all existing items with a new array of items
21
+ * @param {Array} items - Array of new items
22
+ * @returns {HasItems}
23
+ */
10
24
  HasItems.prototype.items = function(items) {
11
25
  this.$description.items.splice(0, this.$description.items.length, ...items);
12
26
  return this;
13
27
  };
14
28
 
29
+ /**
30
+ * Adds an item to the collection
31
+ * @param {*} item - The item to add
32
+ * @returns {HasItems}
33
+ */
15
34
  HasItems.prototype.item = function(item) {
16
35
  this.$description.items.push(item);
17
36
  return this;
18
37
  };
19
38
 
39
+ /**
40
+ * Clears all items from the collection
41
+ * @returns {HasItems}
42
+ */
20
43
  HasItems.prototype.clear = function() {
21
44
  const items = this.$description.items;
22
45
  if(Array.isArray(items)) {
@@ -27,11 +50,29 @@ HasItems.prototype.clear = function() {
27
50
  return this;
28
51
  };
29
52
 
53
+ /**
54
+ * Removes a specific item from the collection
55
+ * @param {*} item - The item to remove
56
+ * @returns {HasItems}
57
+ */
30
58
  HasItems.prototype.removeItem = function(item) {
31
- // TODO: implement this method
59
+ const items = this.$description.items;
60
+ if(Array.isArray(items)) {
61
+ const index = items.indexOf(item);
62
+ if(index > -1) {
63
+ items.splice(index, 1);
64
+ return this;
65
+ }
66
+ }
67
+ items.removeItem(item);
32
68
  return this;
33
69
  };
34
70
 
71
+ /**
72
+ * Sets the render function for items
73
+ * @param {(element: *) => ValidChildren} renderFn - Render function to apply
74
+ * @returns {HasItems}
75
+ */
35
76
  HasItems.prototype.render = function(renderFn) {
36
77
  this.$description.render = renderFn;
37
78
  return this;
@@ -1,4 +1,7 @@
1
-
1
+ /**
2
+ *
3
+ * @class
4
+ */
2
5
  export default function BaseComponent() {
3
6
 
4
7
  }
@@ -1,6 +1,18 @@
1
1
  import BaseComponent from "../BaseComponent";
2
2
  import EventEmitter from "../../../src/core/utils/EventEmitter";
3
3
 
4
+
5
+ /**
6
+ * Valid children types that can be rendered in the DOM
7
+ * @typedef {HTMLElement|Text|DocumentFragment|string|Array<ValidChildren>} ValidChildren
8
+ */
9
+
10
+ /**
11
+ * Component for creating accordion interfaces with expandable/collapsible items
12
+ * @param {{ items?: Array<AccordionItem>, multiple?: boolean, variant?: string, renderContent?: (field: Accordion) => HTMLElement }} config
13
+ * @returns {Accordion}
14
+ * @class
15
+ */
4
16
  export default function Accordion(config = {}) {
5
17
  if (!(this instanceof Accordion)) {
6
18
  return new Accordion(config);
@@ -19,20 +31,47 @@ BaseComponent.extends(Accordion, EventEmitter);
19
31
 
20
32
  Accordion.defaultTemplate = null;
21
33
 
22
- Accordion.use = function(template) {};
23
34
 
35
+ /**
36
+ * Sets the default template for all Accordion instances
37
+ * @param {{accordion: (accordion: Accordion) => ValidChildren}} template - Template object containing accordion factory function
38
+ */
39
+ Accordion.use = function(template) {
40
+ Accordion.defaultTemplate = template.accordion;
41
+ };
42
+
43
+ /**
44
+ * Adds an accordion item to the collection
45
+ * @param {AccordionItem} accordionItem - The accordion item to add
46
+ * @returns {Accordion}
47
+ */
24
48
  Accordion.prototype.item = function(accordionItem) {
25
49
  this.$description.items.push(accordionItem);
26
50
  return this;
27
51
  };
28
52
 
53
+ /**
54
+ * Sets the accordion items collection
55
+ * @param {Array<AccordionItem>} items - Array of accordion items
56
+ * @returns {Accordion}
57
+ */
29
58
  Accordion.prototype.items = function(items) {
30
59
  this.$description.items = items;
31
60
  return this;
32
61
  };
33
62
 
63
+ /**
64
+ * Alias for item method
65
+ * @param {AccordionItem} accordionItem - The accordion item to add
66
+ * @returns {Accordion}
67
+ */
34
68
  Accordion.prototype.addItem = Accordion.prototype.item;
35
69
 
70
+ /**
71
+ * Removes an item by its id
72
+ * @param {string} id - The id of the item to remove
73
+ * @returns {Accordion}
74
+ */
36
75
  Accordion.prototype.removeItemById = function(id) {
37
76
  if (this.$description.items) {
38
77
  this.$description.items = this.$description.items.filter(item => item.id !== id);
@@ -40,40 +79,77 @@ Accordion.prototype.removeItemById = function(id) {
40
79
  return this;
41
80
  };
42
81
 
43
- Accordion.prototype.removeItem = function(item) {
82
+ /**
83
+ * Removes items matching the filter function
84
+ * @param {Function} filter - Filter function to determine which items to keep
85
+ * @returns {Accordion}
86
+ */
87
+ Accordion.prototype.remove = function(filter) {
44
88
  if (this.$description.items) {
45
- this.$description.items = this.$description.items.filter(item);
89
+ this.$description.items = this.$description.items.filter(filter);
46
90
  }
47
91
  return this;
48
92
  };
49
93
 
50
-
94
+ /**
95
+ * Enables or disables multiple items expansion
96
+ * @param {boolean} [enabled=true] - Whether multiple items can be expanded simultaneously
97
+ * @returns {Accordion}
98
+ */
51
99
  Accordion.prototype.multiple = function(enabled = true) {
52
100
  this.$description.multiple = enabled;
53
101
  return this;
54
102
  };
55
103
 
104
+ /**
105
+ * Sets the variant style for the accordion
106
+ * @param {string} name - The variant name
107
+ * @returns {Accordion}
108
+ */
56
109
  Accordion.prototype.variant = function(name) {
57
110
  this.$description.variant = name;
58
111
  return this;
59
112
  };
60
113
 
114
+ /**
115
+ * Sets the accordion variant to 'bordered'
116
+ * @returns {Accordion}
117
+ */
61
118
  Accordion.prototype.bordered = function() {
62
119
  return this.variant('bordered');
63
120
  };
64
121
 
122
+ /**
123
+ * Sets the accordion variant to 'separated'
124
+ * @returns {Accordion}
125
+ */
65
126
  Accordion.prototype.separated = function() {
66
127
  return this.variant('separated');
67
128
  };
68
129
 
130
+ /**
131
+ * Sets the accordion variant to 'flush'
132
+ * @returns {Accordion}
133
+ */
69
134
  Accordion.prototype.flush = function() {
70
135
  return this.variant('flush');
71
136
  };
72
137
 
138
+ /**
139
+ * Retrieves an accordion item by its key
140
+ * @param {string} key - The key of the item to retrieve
141
+ * @returns {AccordionItem|undefined}
142
+ */
73
143
  Accordion.prototype.getByKey = function(key) {
74
144
  return this.$description.items.find(item => item.key === key);
75
145
  };
76
146
 
147
+ /**
148
+ * Expands or collapses an accordion item by key
149
+ * @param {string} key - The key of the item
150
+ * @param {boolean} [state=true] - Whether to expand (true) or collapse (false)
151
+ * @returns {Accordion}
152
+ */
77
153
  Accordion.prototype.expanded = function(key, state = true) {
78
154
  const item = this.getByKey(key);
79
155
  if(item) {
@@ -86,35 +162,67 @@ Accordion.prototype.expanded = function(key, state = true) {
86
162
  return this;
87
163
  };
88
164
 
165
+ /**
166
+ * Expands all accordion items
167
+ * @returns {Accordion}
168
+ */
89
169
  Accordion.prototype.expandAll = function() {
90
170
  this.$description.items.forEach(item => item.expanded(true));
91
171
  return this;
92
172
  };
93
173
 
174
+ /**
175
+ * Collapses all accordion items
176
+ * @returns {Accordion}
177
+ */
94
178
  Accordion.prototype.collapseAll = function() {
95
179
  this.$description.items.forEach(item => item.expanded(false));
96
180
  return this;
97
181
  };
98
182
 
183
+ /**
184
+ * Checks if an accordion item is expanded
185
+ * @param {string} key - The key of the item to check
186
+ * @returns {boolean|undefined}
187
+ */
99
188
  Accordion.prototype.isExpanded = function(key) {
100
189
  return this.getByKey(key)?.isExpanded?.();
101
190
  };
102
191
 
192
+ /**
193
+ * Registers a handler for the expand event
194
+ * @param {Function} handler - The event handler
195
+ * @returns {Accordion}
196
+ */
103
197
  Accordion.prototype.onExpand = function(handler) {
104
198
  this.on('expand', handler);
105
199
  return this;
106
200
  };
107
201
 
202
+ /**
203
+ * Registers a handler for the collapse event
204
+ * @param {Function} handler - The event handler
205
+ * @returns {Accordion}
206
+ */
108
207
  Accordion.prototype.onCollapse = function(handler) {
109
208
  this.on('collapse', handler);
110
209
  return this;
111
210
  };
112
211
 
212
+ /**
213
+ * Sets the content render function
214
+ * @param {Function} renderFn - Function to render content
215
+ * @returns {Accordion}
216
+ */
113
217
  Accordion.prototype.renderContent = function(renderFn) {
114
218
  this.$description.renderContent = renderFn;
115
219
  return this;
116
220
  };
117
221
 
222
+ /**
223
+ * Builds the accordion component
224
+ * @private
225
+ */
118
226
  Accordion.prototype.$build = function() {
119
227
  // TODO: Implementation
120
228
  // this.$description.items.forEach(item => {
@@ -126,8 +234,4 @@ Accordion.prototype.$build = function() {
126
234
  // }
127
235
  // });
128
236
  // });
129
- };
130
-
131
- Accordion.prototype.toNdElement = function() {
132
- return this.$build();
133
237
  };
@@ -1,6 +1,11 @@
1
1
  import { $ } from '../../../index';
2
2
  import BaseComponent from "../BaseComponent";
3
3
 
4
+ /**
5
+ * Represents an individual item within an Accordion component
6
+ * @param {{ id?: string|number, title?: string, icon?: string, collapsible?: boolean, content?: ValidChildren, renderHeader?: Function, renderContent?: Function, render?: Function, expanded?: Observable<boolean>, disabled?: boolean }} config - Configuration object
7
+ * @class
8
+ */
4
9
  export default function AccordionItem(config = {}) {
5
10
  if(!(this instanceof AccordionItem)){
6
11
  return new AccordionItem()
@@ -23,42 +28,81 @@ export default function AccordionItem(config = {}) {
23
28
 
24
29
  BaseComponent.extends(AccordionItem);
25
30
 
31
+ /**
32
+ * Gets the id of the accordion item
33
+ * @type {string}
34
+ */
26
35
  Object.defineProperty(AccordionItem.prototype, 'id', {
27
36
  get() {
28
37
  this.$description.id;
29
38
  }
30
39
  });
31
40
 
41
+ /**
42
+ * Sets the identifier for the accordion item
43
+ * @param {string|number} id - The unique identifier
44
+ * @returns {AccordionItem}
45
+ */
32
46
  AccordionItem.prototype.identifyBy = function(id) {
33
47
  this.$description.id = id;
34
48
  return this;
35
49
  };
36
50
 
51
+ /**
52
+ * Sets the content of the accordion item
53
+ * @param {ValidChildren} content - The content to display
54
+ * @returns {AccordionItem}
55
+ */
37
56
  AccordionItem.prototype.content = function(content) {
38
57
  this.$description.content = content;
39
58
  return this;
40
59
  };
41
60
 
61
+ /**
62
+ * Sets the title of the accordion item
63
+ * @param {ValidChildren} title
64
+ * @returns {AccordionItem}
65
+ */
42
66
  AccordionItem.prototype.title = function(title) {
43
67
  this.$description.title = title;
44
68
  return this;
45
69
  };
46
70
 
71
+ /**
72
+ * Sets the icon for the accordion item
73
+ * @param {ValidChildren} icon - The icon identifier or element
74
+ * @returns {AccordionItem}
75
+ */
47
76
  AccordionItem.prototype.icon = function(icon) {
48
77
  this.$description.icon = icon;
49
78
  return this;
50
79
  };
51
80
 
81
+ /**
82
+ * Shows or hides the expansion indicator
83
+ * @param {boolean} [show=true] - Whether to show the indicator
84
+ * @returns {AccordionItem}
85
+ */
52
86
  AccordionItem.prototype.showIndicator = function(show = true) {
53
87
  this.$description.showIndicator = show;
54
88
  return this;
55
89
  }
56
90
 
91
+ /**
92
+ * Sets whether the item can be collapsed
93
+ * @param {boolean} [collapsible=true] - Whether the item is collapsible
94
+ * @returns {AccordionItem}
95
+ */
57
96
  AccordionItem.prototype.collapsible = function(collapsible = true) {
58
97
  this.$description.collapsible = collapsible;
59
98
  return this;
60
99
  };
61
100
 
101
+ /**
102
+ * Expands or collapses the accordion item
103
+ * @param {boolean} [expanded=true] - Whether to expand the item
104
+ * @returns {AccordionItem}
105
+ */
62
106
  AccordionItem.prototype.expanded = function(expanded = true) {
63
107
  this.$description.expanded.set(expanded);
64
108
  if (this.$description.expanded.val()) {
@@ -69,51 +113,96 @@ AccordionItem.prototype.expanded = function(expanded = true) {
69
113
  return this;
70
114
  };
71
115
 
116
+ /**
117
+ * Toggles the expanded state of the accordion item
118
+ * @returns {AccordionItem}
119
+ */
72
120
  AccordionItem.prototype.toggle = function() {
73
121
  return this.expanded(!this.$description.expanded.val());
74
122
  };
75
123
 
124
+
125
+ /**
126
+ * Sets the disabled state of the accordion item
127
+ * @param {boolean} [disabled=true] - Whether the item is disabled
128
+ * @returns {AccordionItem}
129
+ */
76
130
  AccordionItem.prototype.disabled = function(disabled = true) {
77
131
  this.$description.disabled = disabled;
78
132
  return this;
79
133
  };
80
134
 
135
+ /**
136
+ * Checks if the accordion item is currently expanded
137
+ * @returns {boolean}
138
+ */
81
139
  AccordionItem.prototype.isExpanded = function() {
82
140
  return this.$description.expanded.val();
83
141
  };
142
+
143
+ /**
144
+ * Registers a handler for the expand event
145
+ * @param {Function} handler - The event handler
146
+ * @returns {AccordionItem}
147
+ */
84
148
  AccordionItem.prototype.onExpand = function(handler) {
85
149
  this.on('expand', handler );
86
150
  return this;
87
151
  };
88
152
 
153
+ /**
154
+ * Registers a handler for the collapse event
155
+ * @param {Function} handler - The event handler
156
+ * @returns {AccordionItem}
157
+ */
89
158
  AccordionItem.prototype.onCollapse = function(handler) {
90
159
  this.on('collapse', handler);
91
160
  return this;
92
161
  };
93
162
 
163
+ /**
164
+ * Sets the header render function
165
+ * @param {Function} renderFn - Function to render the header
166
+ * @returns {AccordionItem}
167
+ */
94
168
  AccordionItem.prototype.renderHeader = function(renderFn) {
95
169
  this.$description.renderHeader = renderFn;
96
170
  return this;
97
171
  };
98
172
 
173
+ /**
174
+ * Sets the content render function
175
+ * @param {Function} renderFn - Function to render the content
176
+ * @returns {AccordionItem}
177
+ */
99
178
  AccordionItem.prototype.renderContent = function(renderFn) {
100
179
  this.$description.renderContent = renderFn;
101
180
  };
102
181
 
182
+ /**
183
+ * Sets the indicator render function
184
+ * @param {Function} renderFn - Function to render the indicator
185
+ * @returns {AccordionItem}
186
+ */
103
187
  AccordionItem.prototype.renderIndicator = function(renderFn) {
104
188
  this.$description.renderIndicator = renderFn;
105
189
  return this;
106
190
  };
107
191
 
192
+ /**
193
+ * Sets the render function for the entire item
194
+ * @param {Function} renderFn - Function to render the item
195
+ * @returns {AccordionItem}
196
+ */
108
197
  AccordionItem.prototype.render = function(renderFn) {
109
198
  this.$description.render = renderFn;
110
199
  return this;
111
200
  }
112
201
 
202
+ /**
203
+ * Builds the accordion item component
204
+ * @private
205
+ */
113
206
  AccordionItem.prototype.$build = function() {
114
207
 
115
208
  };
116
-
117
- AccordionItem.prototype.toNdElement = function() {
118
-
119
- }