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
@@ -5,11 +5,16 @@ export const RouteParamPatterns = {
5
5
  };
6
6
 
7
7
  /**
8
+ * Creates a new Route instance.
8
9
  *
9
- * @param {string} $path
10
- * @param {Function} $component
11
- * @param {{name:?string, middlewares:Function[], shouldRebuild:Boolean, with: Object }}$options
12
- * @class
10
+ * @param {string} $path - URL pattern with optional parameters (e.g., '/user/{id:number}')
11
+ * @param {Function} $component - Component function that returns HTMLElement or DocumentFragment
12
+ * @param {Object} [$options={}] - Route configuration options
13
+ * @param {string} [$options.name] - Unique name for the route (used for navigation)
14
+ * @param {Function[]} [$options.middlewares] - Array of middleware functions
15
+ * @param {boolean} [$options.shouldRebuild] - Whether to rebuild component on each navigation
16
+ * @param {Object} [$options.with] - Custom parameter validation patterns
17
+ * @param {Function} [$options.layout] - Layout component wrapper function
13
18
  */
14
19
  export function Route($path, $component, $options = {}) {
15
20
 
@@ -14,7 +14,7 @@ export const DEFAULT_ROUTER_NAME = 'default';
14
14
  /**
15
15
  *
16
16
  * @param {{mode: 'memory'|'history'|'hash'}} $options
17
- * @constructor
17
+ * @class
18
18
  */
19
19
  export default function Router($options = {}) {
20
20
 
@@ -72,11 +72,20 @@ export default function Router($options = {}) {
72
72
  };
73
73
 
74
74
  /**
75
+ * Groups routes under a common path prefix with shared options.
75
76
  *
76
- * @param {string} suffix
77
- * @param {{ middlewares: Function[], name: string}} options
78
- * @param {Function} callback
79
- * @returns {this}
77
+ * @param {string} suffix - Path prefix to prepend to all routes in the group
78
+ * @param {Object} options - Group configuration options
79
+ * @param {Function[]} [options.middlewares] - Middlewares applied to all routes in group
80
+ * @param {string} [options.name] - Name prefix for all routes in group
81
+ * @param {Function} [options.layout] - Layout component for all routes in group
82
+ * @param {Function} callback - Function that defines routes within the group
83
+ * @returns {this} Router instance for chaining
84
+ * @example
85
+ * router.group('/admin', { middlewares: [authMiddleware], layout: AdminLayout }, () => {
86
+ * router.add('/users', UsersPage, { name: 'users' });
87
+ * router.add('/settings', SettingsPage, { name: 'settings' });
88
+ * });
80
89
  */
81
90
  this.group = function(suffix, options, callback) {
82
91
  if(!Validator.isFunction(callback)) {
@@ -194,14 +203,24 @@ export default function Router($options = {}) {
194
203
  Router.routers = {};
195
204
 
196
205
  /**
206
+ * Creates and initializes a new router instance.
197
207
  *
198
- * @param {{mode: 'memory'|'history'|'hash', name?:string, entry?: string}} options
199
- * @param {Function} callback
200
- * @param {Element} container
208
+ * @param {Object} options - Router configuration
209
+ * @param {'memory'|'history'|'hash'} options.mode - Routing mode
210
+ * @param {string} [options.name] - Router name for multi-router apps
211
+ * @param {string} [options.entry] - Initial route path
212
+ * @param {Function} callback - Setup function that receives the router instance
213
+ * @returns {Router} The configured router instance with mount() method
214
+ * @example
215
+ * const router = Router.create({ mode: 'history' }, (r) => {
216
+ * r.add('/home', HomePage, { name: 'home' });
217
+ * r.add('/about', AboutPage, { name: 'about' });
218
+ * });
219
+ * router.mount('#app');
201
220
  */
202
221
  Router.create = function(options, callback) {
203
222
  if(!Validator.isFunction(callback)) {
204
- DebugManager.error('Router', 'Callback must be a function', e);
223
+ DebugManager.error('Router', 'Callback must be a function');
205
224
  throw new RouterError('Callback must be a function');
206
225
  }
207
226
  const router = new Router(options);
@@ -5,5 +5,4 @@ export default class RouterError extends Error {
5
5
  super(message);
6
6
  this.context = context;
7
7
  }
8
-
9
8
  }
@@ -12,7 +12,10 @@ export interface HideIfFunction {
12
12
  }
13
13
 
14
14
  export interface MatchFunction {
15
- <T extends string | number>(condition: ObservableItem<T> | ObservableChecker<T>, values: Record<T, ValidChild>, shouldKeepInCache?: boolean): DocumentFragment;
15
+ <T extends string | number>(condition: ObservableItem<T> | ObservableChecker<T>, values: Record<T, ValidChild>, shouldKeepInCache?: boolean): DocumentFragment & {
16
+ add(key: T, child: ValidChild, shouldFocusOn?: boolean): void;
17
+ remove(key: T): void;
18
+ };
16
19
  }
17
20
 
18
21
  export interface SwitchFunction {
@@ -30,14 +33,14 @@ export interface WhenFunction {
30
33
  export interface ForEachFunction {
31
34
  <T>(data: T[] | Record<string, T> | ObservableItem<T[]> | ObservableItem<Record<string, T>>,
32
35
  callback: (item: T, index?: ObservableItem<number>) => ValidChild,
33
- key?: string | ((item: T, defaultKey: string | number) => string),
34
- configs?: { shouldKeepItemsInCache: boolean, isParentUniqueChild: boolean, }): DocumentFragment,
36
+ key?: string | ((item: T, defaultKey: string | number) => string | number),
37
+ options?: { shouldKeepItemsInCache: boolean, isParentUniqueChild: boolean, }): DocumentFragment,
35
38
  }
36
39
 
37
40
  export interface ForEachArrayFunction {
38
41
  <T>(data: ObservableArray<T>,
39
42
  callback: (item: T, index?: ObservableItem<number>) => ValidChild,
40
- configs?: { pushDelay?: (items: T[]) => number, isParentUniqueChild: boolean, shouldKeepItemsInCache?: boolean }): DocumentFragment;
43
+ configs?: { isParentUniqueChild: boolean, shouldKeepItemsInCache?: boolean }): DocumentFragment;
41
44
  }
42
45
 
43
46
  export interface HideIfNotFunction {
@@ -45,8 +48,8 @@ export interface HideIfNotFunction {
45
48
  }
46
49
 
47
50
 
48
- export function ShowWhen(observer: ObservableWhen, target: any): ReturnType<typeof ShowIf>;
49
- export function ShowWhen(observer: ObservableWhen, target: any, view: any): ReturnType<typeof ShowIf>;
51
+ export function ShowWhen(observerWhenResult: ObservableWhen, view: ValidChild): ReturnType<typeof ShowIf>;
52
+ export function ShowWhen(observer: ObservableItem, target: any, view: ValidChild): ReturnType<typeof ShowIf>;
50
53
 
51
54
  // Control Flow Components
52
55
  export declare const ShowIf: ShowIfFunction;