native-document 1.0.169 → 1.0.172
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/CHANGELOG.md +62 -1
- package/docs/vitepress-conventions.md +2 -2
- package/package.json +11 -4
- package/src/components/BaseComponent.js +43 -1
- package/src/components/accordion/Accordion.js +1 -0
- package/src/components/accordion/AccordionItem.js +1 -0
- package/src/components/alert/Alert.js +4 -0
- package/src/components/avatar/Avatar.js +1 -0
- package/src/components/avatar/AvatarGroup.js +1 -0
- package/src/components/badge/Badge.js +1 -0
- package/src/components/breadcrumb/BreadCrumb.js +4 -0
- package/src/components/button/Button.js +1 -0
- package/src/components/card/Card.js +1 -0
- package/src/components/context-menu/ContextMenu.js +2 -0
- package/src/components/context-menu/ContextMenuGroup.js +2 -0
- package/src/components/context-menu/ContextMenuItem.js +2 -0
- package/src/components/divider/Divider.js +2 -0
- package/src/components/dropdown/Dropdown.js +1 -0
- package/src/components/dropdown/DropdownDivider.js +1 -0
- package/src/components/dropdown/DropdownGroup.js +1 -0
- package/src/components/dropdown/DropdownItem.js +1 -0
- package/src/components/dropdown/DropdownTrigger.js +1 -0
- package/src/components/form/FormControl.js +1 -0
- package/src/components/form/field/Field.js +1 -0
- package/src/components/form/field/types/StringField.js +1 -1
- package/src/components/icon/Icon.js +1 -0
- package/src/components/list/ListItem.js +1 -0
- package/src/components/menu/Menu.js +3 -0
- package/src/components/menu/MenuDivider.js +1 -0
- package/src/components/menu/MenuGroup.js +1 -0
- package/src/components/menu/MenuItem.js +1 -0
- package/src/components/menu/MenuLink.js +1 -0
- package/src/components/modal/Modal.js +4 -0
- package/src/components/pagination/Pagination.js +1 -0
- package/src/components/popover/Popover.js +1 -0
- package/src/components/popover/PopoverFooter.js +1 -0
- package/src/components/popover/PopoverHeader.js +1 -0
- package/src/components/progress/Progress.js +5 -0
- package/src/components/skeleton/Skeleton.js +4 -0
- package/src/components/slider/Slider.js +1 -0
- package/src/components/spacer/Spacer.js +1 -0
- package/src/components/spinner/Spinner.js +1 -0
- package/src/components/splitter/Splitter.js +1 -0
- package/src/components/splitter/SplitterGutter.js +6 -0
- package/src/components/splitter/SplitterPanel.js +1 -0
- package/src/components/stacks/AbsoluteStack.js +1 -0
- package/src/components/stacks/FixedStack.js +1 -0
- package/src/components/stacks/HStack.js +1 -0
- package/src/components/stacks/PositionStack.js +1 -0
- package/src/components/stacks/RelativeStack.js +1 -0
- package/src/components/stacks/Stack.js +1 -0
- package/src/components/stacks/VStack.js +1 -0
- package/src/components/stepper/Stepper.js +1 -0
- package/src/components/stepper/StepperStep.js +1 -0
- package/src/components/switch/Switch.js +1 -0
- package/src/components/table/DataTable.js +1 -0
- package/src/components/table/SimpleTable.js +1 -0
- package/src/components/tabs/Tabs.js +1 -0
- package/src/components/toast/Toast.js +1 -0
- package/src/components/tooltip/Tooltip.js +1 -0
- package/src/core/data/MemoryManager.js +6 -1
- package/src/core/data/ObservableItem.js +28 -10
- package/src/core/elements/anchor/anchor.js +4 -3
- package/src/core/elements/anchor/one-child-anchor-overwriting.js +4 -4
- package/src/core/elements/content-formatter.js +19 -0
- package/src/core/elements/control/for-each-array-cache.js +59 -0
- package/src/core/elements/control/for-each-array.js +15 -23
- package/src/core/wrappers/AttributesWrapper.js +12 -12
- package/src/core/wrappers/ElementCreator.js +33 -10
- package/src/core/wrappers/HtmlElementWrapper.js +9 -4
- package/src/core/wrappers/NDElement.js +23 -8
- package/src/core/wrappers/NdPrototype.js +31 -39
- package/src/core/wrappers/constants.js +12 -12
- package/src/core/wrappers/prototypes/nd-element-extensions.js +127 -57
- package/src/ui/components/accordion/AccordionItemRender.js +29 -7
- package/src/ui/components/alert/AlertRender.js +6 -0
- package/src/ui/components/breadcrumb/BreadcrumbRender.js +9 -1
- package/src/ui/components/button/ButtonRender.js +3 -0
- package/src/ui/components/contextmenu/ContextmenuRender.js +2 -0
- package/src/ui/components/dropdown/DropdownRender.js +3 -0
- package/src/ui/components/dropdown/item/DropdownItemRender.js +6 -1
- package/src/ui/components/form/FieldCollectionRender.js +4 -0
- package/src/ui/components/form/fields/CheckboxFieldRender.js +4 -0
- package/src/ui/components/form/fields/CheckboxGroupFieldRender.js +4 -0
- package/src/ui/components/form/fields/RadioFieldRender.js +4 -0
- package/src/ui/components/form/fields/RangeFieldRender.js +4 -0
- package/src/ui/components/form/fields/SelectFieldRender.js +5 -0
- package/src/ui/components/form/fields/SliderFieldRender.js +3 -0
- package/src/ui/components/icon/tabler/TablerIconRender.js +0 -1
- package/src/ui/components/list/item/ListItemRender.js +4 -0
- package/src/ui/components/menu/MenuItemRender.js +8 -0
- package/src/ui/components/menu/MenuLinkRender.js +11 -0
- package/src/ui/components/menu/MenuRender.js +5 -0
- package/src/ui/components/menu/helpers.js +2 -1
- package/src/ui/components/modal/ModalRender.js +8 -2
- package/src/ui/components/progress/ProgressRender.js +9 -0
- package/src/ui/components/skeleton/SkeletonRender.js +2 -0
- package/src/ui/components/spinner/SpinnerRender.js +3 -0
- package/src/ui/components/splitter/SplitterGutterRender.js +4 -0
- package/src/ui/components/splitter/SplitterPanelRender.js +4 -0
- package/src/ui/components/splitter/SplitterRender.js +2 -0
- package/src/ui/components/stepper/StepperRender.js +2 -1
- package/src/ui/components/stepper/StepperStepRender.js +8 -1
- package/src/ui/components/switch/SwitchRender.js +3 -0
- package/src/ui/components/table/data-table/DataTableRender.js +4 -0
- package/src/ui/components/table/simple-table/SimpleTableRender.js +2 -0
- package/src/ui/components/toast/ToastRender.js +4 -0
- package/src/ui/utils/aria.js +19 -0
- package/tests/integration/ui/attributes-wrapper.test.js +177 -0
- package/tests/integration/ui/for-each-array.test.js +167 -0
- package/tests/integration/ui/lifecycle.test.js +146 -0
- package/tests/integration/ui/show-if.test.js +168 -0
- package/tests/unit/core/observable-array.test.js +404 -0
- package/tests/unit/core/observable-item.test.js +428 -0
- package/tests/unit/core/observable-object.test.js +239 -0
- package/tests/unit/core/observable-resource.test.js +323 -0
- package/tests/unit/core/store.test.js +347 -0
- package/tests/unit/router/route-matching.test.js +169 -0
- package/tests/unit/router/router-guards.test.js +189 -0
- package/tests/unit/utils/cache.test.js +120 -0
- package/tests/unit/utils/filters.test.js +394 -0
- package/types/elements.d.ts +5 -0
- package/vitest.config.js +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,65 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
+
## [1.0.172] - 2026-06-15
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `Text(string)` — shorthand for `string.toNdChildren()`, parses Observable placeholders in template strings
|
|
19
|
+
- `String.prototype.toNdChildren()` — splits a string containing `{{obs:N}}` placeholders into a mixed array of strings and resolved Observables
|
|
20
|
+
- `ObservableItem.prototype.toString()` — auto-registers the Observable in MemoryManager and returns `{{obs:id}}`, enabling reactive interpolation via standard template literals
|
|
21
|
+
- `NDElement.prototype.className(classes)` — adds static classes, bypasses AttributesWrapper
|
|
22
|
+
- `NDElement.prototype.class(className, value)` — adds a reactive class binding, bypasses AttributesWrapper
|
|
23
|
+
- `__$isNativeNode` flag on DOM prototypes (`Element`, `Text`, `Comment`, `Document`, `DocumentFragment`) — faster alternative to `instanceof Node`
|
|
24
|
+
- `__$isValidNdChild` flag on all valid NdChild prototypes — single property check replaces multiple type guards
|
|
25
|
+
- `defineToNdElement`, `defineValidNdChild`, `defineNativeNode` — non-enumerable prototype helpers in `nd-element-extensions`
|
|
26
|
+
- camelCase variants added to `BOOLEAN_ATTRIBUTES` — removes `toLowerCase()` call on each attribute in the hot path
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- `ElementCreator.processChildren` and `getChild` — refactored for better performance
|
|
31
|
+
- `nd-element-extensions` — all prototype extensions converted to non-enumerable `defineProperty`
|
|
32
|
+
- `AttributesWrapper` — `options` defaults to `null` instead of `{}`, fixes truthy check issue
|
|
33
|
+
- NDElement events — inline handler (`on*`) used when no existing handler and no options; falls back to `addEventListener` for subsequent handlers or when options are provided
|
|
34
|
+
- `_prevent`, `_stop`, `_preventStop` — updated with same inline handler strategy
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## [1.0.170] - 2026-06-10
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- Vitest test suite — `vitest.config.js`, happy-dom environment, scripts `test`, `test:watch`, `test:ui`, `test:coverage`
|
|
43
|
+
- 372 tests passing across 13 files — 0 failures, 0 todo
|
|
44
|
+
|
|
45
|
+
#### Unit tests — core
|
|
46
|
+
- `observable-item` — 48 cases: set, val, subscribe, on/off, once, toggle, reset, transform, equals, clone, cleanup, intercept, assocTrigger
|
|
47
|
+
- `observable-array` — 48 cases: push, remove, clear, merge, swap, insertAfter, isIncludes, where, sync, clone, reset, deepSubscribe
|
|
48
|
+
- `observable-object` — 30 cases: constructor, val, get, set, subscribe, keys, observables, reset, clone
|
|
49
|
+
- `observable-resource` — 29 cases: states, fetch, refetch, mutate, abort, race condition, deps, onSuccess, onError, into, apply, destroy
|
|
50
|
+
- `store` — 43 cases: create, createResettable, createComposed, use, follow, reset, delete, group, protected, createPersistent
|
|
51
|
+
|
|
52
|
+
#### Unit tests — router
|
|
53
|
+
- `route-matching` — 26 cases: exact path, params, typed params, custom validators, url(), metadata
|
|
54
|
+
- `router-guards` — 14 cases: middleware execution, group middlewares, subscribe, resolve, currentState
|
|
55
|
+
|
|
56
|
+
#### Unit tests — utils
|
|
57
|
+
- `cache` — 12 cases: singleton, once, memoize
|
|
58
|
+
- `filters` — 60 cases: equals, comparison, inArray, isEmpty, match, and/or/not, custom, string filters, date/time filters
|
|
59
|
+
|
|
60
|
+
#### Integration tests — UI
|
|
61
|
+
- `attributes-wrapper` — 22 cases: string, class map, style, Observable, boolean, aria attributes
|
|
62
|
+
- `show-if` — 16 cases: static boolean, observable, factory child, HideIf, HideIfNot
|
|
63
|
+
- `for-each-array` — 13 cases: static array, push, removeItem, clear, set, swap, index observable, order preservation
|
|
64
|
+
- `lifecycle` — 11 cases: mounted, unmounted, destroy, destroyOnUnmount
|
|
65
|
+
|
|
66
|
+
### Fixed
|
|
67
|
+
|
|
68
|
+
- `NDElement.prototype.destroy()` — guard against double call when `$element` is already null
|
|
69
|
+
- `NDElement.prototype.destroy()` — disconnect lifecycle observer to prevent callbacks from firing after destroy
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
14
73
|
## [1.0.169] - 2026-06-06
|
|
15
74
|
|
|
16
75
|
### Added
|
|
@@ -181,7 +240,9 @@ Entries use the following categories:
|
|
|
181
240
|
|
|
182
241
|
---
|
|
183
242
|
|
|
184
|
-
[Unreleased]: https://github.com/afrocodeur/native-document/compare/v1.0.
|
|
243
|
+
[Unreleased]: https://github.com/afrocodeur/native-document/compare/v1.0.172...HEAD
|
|
244
|
+
[1.0.172]: https://github.com/afrocodeur/native-document/compare/v1.0.170...v1.0.172
|
|
245
|
+
[1.0.170]: https://github.com/afrocodeur/native-document/compare/v1.0.169...v1.0.170
|
|
185
246
|
[1.0.169]: https://github.com/afrocodeur/native-document/compare/v1.0.167...v1.0.169
|
|
186
247
|
[1.0.167]: https://github.com/afrocodeur/native-document/compare/v1.0.166...v1.0.167
|
|
187
248
|
[1.0.166]: https://github.com/afrocodeur/native-document/releases/tag/v1.0.166
|
|
@@ -75,7 +75,7 @@ docs/
|
|
|
75
75
|
## Internal Links
|
|
76
76
|
|
|
77
77
|
VitePress resolves links relative to the current file.
|
|
78
|
-
Always use `.md` extension
|
|
78
|
+
Always use `.md` extension - VitePress strips it at build time.
|
|
79
79
|
|
|
80
80
|
```markdown
|
|
81
81
|
<!-- From docs/readme.md or docs/getting-started.md -->
|
|
@@ -93,7 +93,7 @@ Never use absolute paths (`/docs/...`) or paths without `.md`.
|
|
|
93
93
|
|
|
94
94
|
---
|
|
95
95
|
|
|
96
|
-
## `.vitepress/config.js`
|
|
96
|
+
## `.vitepress/config.js` - Sidebar & Nav
|
|
97
97
|
|
|
98
98
|
```javascript
|
|
99
99
|
// .vitepress/config.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.172",
|
|
4
4
|
"description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
|
|
5
5
|
"author": "AfroCodeur <https://github.com/afrocodeur>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,11 @@
|
|
|
41
41
|
"build": "rollup --config rollup.config.js",
|
|
42
42
|
"build:watch": "rollup --config rollup.config.js --watch",
|
|
43
43
|
"lint": "eslint ./src",
|
|
44
|
-
"lint:fix": "eslint ./src --fix"
|
|
44
|
+
"lint:fix": "eslint ./src --fix",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest",
|
|
47
|
+
"test:ui": "vitest --ui",
|
|
48
|
+
"test:coverage": "vitest run --coverage"
|
|
45
49
|
},
|
|
46
50
|
"dependencies": {
|
|
47
51
|
"@floating-ui/dom": "^1.7.6",
|
|
@@ -53,14 +57,17 @@
|
|
|
53
57
|
"@rollup/plugin-alias": "^5.1.1",
|
|
54
58
|
"@rollup/plugin-replace": "^6.0.2",
|
|
55
59
|
"@rollup/plugin-terser": "^0.4.4",
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
56
61
|
"eslint": "^9.33.0",
|
|
57
62
|
"eslint-plugin-jsdoc": "^62.5.4",
|
|
63
|
+
"happy-dom": "^20.10.2",
|
|
58
64
|
"magic-string": "^0.30.21",
|
|
59
65
|
"postcss": "^8.5.12",
|
|
60
66
|
"rollup": "^4.53.3",
|
|
61
|
-
"rollup-plugin-postcss": "^4.0.2"
|
|
67
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
68
|
+
"vitest": "^4.1.8"
|
|
62
69
|
},
|
|
63
70
|
"engines": {
|
|
64
71
|
"node": ">=18.0.0"
|
|
65
72
|
}
|
|
66
|
-
}
|
|
73
|
+
}
|
|
@@ -181,6 +181,12 @@ BaseComponent.prototype.getEditableProps = function() {
|
|
|
181
181
|
class: classPropertyAccumulator(rawProps.class || {}),
|
|
182
182
|
style: cssPropertyAccumulator(rawProps.style || {}),
|
|
183
183
|
};
|
|
184
|
+
|
|
185
|
+
if (this.aria) {
|
|
186
|
+
for (const key in this.aria) {
|
|
187
|
+
this.$editableProps[resolveAriaKey(key)] = this.aria[key];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
184
190
|
}
|
|
185
191
|
|
|
186
192
|
return this.$editableProps;
|
|
@@ -244,4 +250,40 @@ BaseComponent.prototype.context = function(context) {
|
|
|
244
250
|
return this;
|
|
245
251
|
};
|
|
246
252
|
|
|
247
|
-
BaseComponent.prototype.visibility = BaseComponent.prototype.showIf;
|
|
253
|
+
BaseComponent.prototype.visibility = BaseComponent.prototype.showIf;
|
|
254
|
+
|
|
255
|
+
//------------------------------------------------------------------------------
|
|
256
|
+
//--Component Aria -------------------------------------------------------------
|
|
257
|
+
//------------------------------------------------------------------------------
|
|
258
|
+
const ARIA_NO_PREFIX = new Set(['role', 'id', 'tabindex']);
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @param {string} key
|
|
262
|
+
* @returns {string}
|
|
263
|
+
*/
|
|
264
|
+
const resolveAriaKey = (key) =>
|
|
265
|
+
ARIA_NO_PREFIX.has(key) || key.startsWith('aria-') ? key : `aria-${key}`;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Override or extend aria attributes on the root element.
|
|
269
|
+
* Automatically prefixes keys with 'aria-' unless they are in ARIA_NO_PREFIX.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* Modal()
|
|
273
|
+
* .setAria({ label: 'Confirmation dialog' })
|
|
274
|
+
* .setAria({ describedby: 'modal-desc' })
|
|
275
|
+
*
|
|
276
|
+
* @param {Record<string, string|boolean|Observable>} attrs
|
|
277
|
+
* @returns {this}
|
|
278
|
+
*/
|
|
279
|
+
BaseComponent.prototype.setAria = function(attrs) {
|
|
280
|
+
if (!this.aria) {
|
|
281
|
+
this.aria = {};
|
|
282
|
+
}
|
|
283
|
+
for (const key in attrs) {
|
|
284
|
+
this.aria[resolveAriaKey(key)] = attrs[key];
|
|
285
|
+
}
|
|
286
|
+
return this;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
|
|
@@ -26,7 +26,7 @@ import {Validation} from '../../validation/Validation';
|
|
|
26
26
|
*/
|
|
27
27
|
export default function StringField(name, type = 'text', props = {}) {
|
|
28
28
|
if(!(this instanceof StringField)) {
|
|
29
|
-
return new StringField(name, props);
|
|
29
|
+
return new StringField(name, type, props);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
Field.call(this, name, type, props);
|
|
@@ -33,6 +33,10 @@ export default function SplitterGutter(leftPanel, rightPanel, props = {}) {
|
|
|
33
33
|
isDragging: $(false),
|
|
34
34
|
props,
|
|
35
35
|
};
|
|
36
|
+
this.aria = {
|
|
37
|
+
'role': 'separator',
|
|
38
|
+
'aria-orientation': 'horizontal',
|
|
39
|
+
};
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
BaseComponent.extends(SplitterGutter);
|
|
@@ -62,6 +66,7 @@ SplitterGutter.use = function(template) {
|
|
|
62
66
|
SplitterGutter.prototype.vertical = function() {
|
|
63
67
|
this.$description.orientation = 'vertical';
|
|
64
68
|
this.$description.cursor = 'row-resize';
|
|
69
|
+
this.aria['aria-orientation'] = 'vertical';
|
|
65
70
|
return this;
|
|
66
71
|
};
|
|
67
72
|
|
|
@@ -71,6 +76,7 @@ SplitterGutter.prototype.vertical = function() {
|
|
|
71
76
|
SplitterGutter.prototype.horizontal = function() {
|
|
72
77
|
this.$description.orientation = 'horizontal';
|
|
73
78
|
this.$description.cursor = 'col-resize';
|
|
79
|
+
this.aria['aria-orientation'] = 'horizontal';
|
|
74
80
|
return this;
|
|
75
81
|
};
|
|
76
82
|
|