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.
- package/dist/native-document.components.min.js +1088 -65
- package/dist/native-document.dev.js +695 -142
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/docs/advanced-components.md +814 -0
- package/docs/anchor.md +71 -11
- package/docs/cache.md +888 -0
- package/docs/conditional-rendering.md +91 -1
- package/docs/core-concepts.md +9 -2
- package/docs/elements.md +127 -2
- package/docs/extending-native-document-element.md +7 -1
- package/docs/filters.md +1216 -0
- package/docs/getting-started.md +12 -3
- package/docs/lifecycle-events.md +10 -2
- package/docs/list-rendering.md +453 -54
- package/docs/memory-management.md +9 -7
- package/docs/native-document-element.md +30 -9
- package/docs/native-fetch.md +744 -0
- package/docs/observables.md +135 -6
- package/docs/routing.md +7 -1
- package/docs/state-management.md +7 -1
- package/docs/validation.md +8 -1
- package/elements.js +1 -0
- package/eslint.config.js +3 -3
- package/index.def.js +350 -0
- package/package.json +3 -2
- package/readme.md +53 -14
- package/src/components/$traits/HasItems.js +42 -1
- package/src/components/BaseComponent.js +4 -1
- package/src/components/accordion/Accordion.js +112 -8
- package/src/components/accordion/AccordionItem.js +93 -4
- package/src/components/alert/Alert.js +164 -4
- package/src/components/avatar/Avatar.js +236 -22
- package/src/components/menu/index.js +1 -2
- package/src/core/data/ObservableArray.js +120 -2
- package/src/core/data/ObservableChecker.js +50 -0
- package/src/core/data/ObservableItem.js +124 -4
- package/src/core/data/ObservableWhen.js +36 -6
- package/src/core/data/observable-helpers/array.js +12 -3
- package/src/core/data/observable-helpers/computed.js +17 -4
- package/src/core/data/observable-helpers/object.js +19 -3
- package/src/core/elements/content-formatter.js +138 -1
- package/src/core/elements/control/for-each-array.js +20 -2
- package/src/core/elements/control/for-each.js +17 -5
- package/src/core/elements/control/show-if.js +31 -15
- package/src/core/elements/control/show-when.js +23 -0
- package/src/core/elements/control/switch.js +40 -10
- package/src/core/elements/description-list.js +14 -0
- package/src/core/elements/form.js +188 -4
- package/src/core/elements/html5-semantics.js +44 -1
- package/src/core/elements/img.js +22 -10
- package/src/core/elements/index.js +5 -0
- package/src/core/elements/interactive.js +19 -1
- package/src/core/elements/list.js +28 -1
- package/src/core/elements/medias.js +29 -0
- package/src/core/elements/meta-data.js +34 -0
- package/src/core/elements/table.js +59 -0
- package/src/core/utils/cache.js +5 -0
- package/src/core/utils/helpers.js +7 -2
- package/src/core/utils/memoize.js +25 -16
- package/src/core/utils/prototypes.js +3 -2
- package/src/core/wrappers/AttributesWrapper.js +1 -1
- package/src/core/wrappers/HtmlElementWrapper.js +2 -2
- package/src/core/wrappers/NDElement.js +42 -2
- package/src/core/wrappers/NdPrototype.js +4 -0
- package/src/core/wrappers/TemplateCloner.js +14 -11
- package/src/core/wrappers/prototypes/bind-class-extensions.js +1 -1
- package/src/core/wrappers/prototypes/nd-element-extensions.js +3 -0
- package/src/router/Route.js +9 -4
- package/src/router/Router.js +28 -9
- package/src/router/errors/RouterError.js +0 -1
- package/types/control-flow.d.ts +9 -6
- package/types/elements.d.ts +496 -111
- package/types/filters/index.d.ts +4 -0
- package/types/forms.d.ts +85 -48
- package/types/images.d.ts +16 -9
- package/types/nd-element.d.ts +5 -238
- package/types/observable.d.ts +9 -3
- package/types/router.d.ts +5 -1
- package/types/template-cloner.ts +1 -0
- package/types/validator.ts +11 -1
- package/utils.d.ts +2 -1
- package/utils.js +4 -4
- package/src/core/utils/service.js +0 -6
package/src/router/Route.js
CHANGED
|
@@ -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 {
|
|
12
|
-
* @
|
|
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
|
|
package/src/router/Router.js
CHANGED
|
@@ -14,7 +14,7 @@ export const DEFAULT_ROUTER_NAME = 'default';
|
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* @param {{mode: 'memory'|'history'|'hash'}} $options
|
|
17
|
-
* @
|
|
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 {
|
|
78
|
-
* @param {Function}
|
|
79
|
-
* @
|
|
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 {
|
|
199
|
-
* @param {
|
|
200
|
-
* @param {
|
|
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'
|
|
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);
|
package/types/control-flow.d.ts
CHANGED
|
@@ -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
|
-
|
|
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?: {
|
|
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(
|
|
49
|
-
export function ShowWhen(observer:
|
|
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;
|