native-document 1.0.165 → 1.0.166
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/components.d.ts +2 -0
- package/devtools/widget.js +1 -1
- package/dist/native-document.components.min.js +11074 -2735
- package/dist/native-document.dev.js +2269 -392
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/eslint.config.js +28 -33
- package/i18n.js +1 -1
- package/i18n.ts +2 -0
- package/index.js +3 -0
- package/package.json +3 -2
- package/src/components/$traits/has-draggable/HasDraggable.d.ts +4 -0
- package/src/components/$traits/has-draggable/HasDraggable.js +13 -0
- package/src/components/$traits/has-items/HasItems.d.ts +9 -0
- package/src/components/$traits/has-items/HasItems.js +6 -6
- package/src/components/$traits/has-position/HasFullPosition.d.ts +14 -0
- package/src/components/$traits/has-position/HasFullPosition.js +44 -0
- package/src/components/$traits/has-position/HasPosition.d.ts +7 -0
- package/src/components/$traits/has-position/HasPosition.js +23 -1
- package/src/components/$traits/has-resizable/HasResizable.d.ts +13 -0
- package/src/components/$traits/has-resizable/HasResizable.js +9 -0
- package/src/components/$traits/has-validation/HasValidation.d.ts +17 -0
- package/src/components/$traits/has-validation/HasValidation.js +54 -7
- package/src/components/BaseComponent.d.ts +32 -0
- package/src/components/BaseComponent.js +65 -9
- package/src/components/accordion/Accordion.js +39 -14
- package/src/components/accordion/AccordionItem.js +45 -14
- package/src/components/accordion/index.js +2 -2
- package/src/components/accordion/types/Accordion.d.ts +47 -0
- package/src/components/accordion/types/AccordionItem.d.ts +48 -0
- package/src/components/alert/Alert.js +70 -38
- package/src/components/alert/index.js +2 -2
- package/src/components/alert/types/Alert.d.ts +62 -0
- package/src/components/avatar/Avatar.js +49 -12
- package/src/components/avatar/AvatarGroup.js +50 -2
- package/src/components/avatar/index.js +2 -2
- package/src/components/avatar/types/Avatar.d.ts +74 -0
- package/src/components/avatar/types/AvatarGroup.d.ts +32 -0
- package/src/components/badge/Badge.js +125 -5
- package/src/components/badge/index.js +2 -2
- package/src/components/badge/types/Badge.d.ts +51 -0
- package/src/components/breadcrumb/BreadCrumb.js +61 -5
- package/src/components/breadcrumb/index.js +2 -2
- package/src/components/breadcrumb/types/BreadCrumb.d.ts +42 -0
- package/src/components/button/Button.js +164 -9
- package/src/components/button/index.js +1 -1
- package/src/components/button/types/Button.d.ts +62 -0
- package/src/components/card/Card.js +128 -10
- package/src/components/card/index.js +3 -3
- package/src/components/card/types/Card.d.ts +42 -0
- package/src/components/context-menu/ContextMenu.js +49 -5
- package/src/components/context-menu/ContextMenuGroup.js +15 -2
- package/src/components/context-menu/ContextMenuItem.js +14 -2
- package/src/components/context-menu/index.js +5 -5
- package/src/components/context-menu/types/ContextMenu.d.ts +30 -0
- package/src/components/context-menu/types/ContextMenuGroup.d.ts +18 -0
- package/src/components/context-menu/types/ContextMenuItem.d.ts +18 -0
- package/src/components/divider/Divider.js +120 -4
- package/src/components/divider/index.js +3 -3
- package/src/components/divider/types/Divider.d.ts +55 -0
- package/src/components/dropdown/Dropdown.js +239 -16
- package/src/components/dropdown/DropdownDivider.js +22 -2
- package/src/components/dropdown/DropdownGroup.js +44 -5
- package/src/components/dropdown/DropdownItem.js +76 -3
- package/src/components/dropdown/DropdownTrigger.js +49 -20
- package/src/components/dropdown/helpers.js +1 -1
- package/src/components/dropdown/index.js +6 -6
- package/src/components/dropdown/types/Dropdown.d.ts +88 -0
- package/src/components/dropdown/types/DropdownDivider.d.ts +20 -0
- package/src/components/dropdown/types/DropdownGroup.d.ts +25 -0
- package/src/components/dropdown/types/DropdownItem.d.ts +41 -0
- package/src/components/dropdown/types/DropdownTrigger.d.ts +32 -0
- package/src/components/form/FormControl.js +156 -13
- package/src/components/form/field/Field.js +172 -9
- package/src/components/form/field/FieldCollection.js +116 -12
- package/src/components/form/field/types/AutocompleteField.js +92 -2
- package/src/components/form/field/types/CheckboxField.js +43 -2
- package/src/components/form/field/types/CheckboxGroupField.js +83 -6
- package/src/components/form/field/types/ColorField.js +56 -3
- package/src/components/form/field/types/DateField.js +155 -4
- package/src/components/form/field/types/EmailField.js +54 -4
- package/src/components/form/field/types/FileField.js +140 -6
- package/src/components/form/field/types/HiddenField.js +27 -1
- package/src/components/form/field/types/ImageField.js +82 -3
- package/src/components/form/field/types/NumberField.js +97 -4
- package/src/components/form/field/types/PasswordField.js +103 -7
- package/src/components/form/field/types/RadioField.js +75 -4
- package/src/components/form/field/types/RangeField.js +67 -1
- package/src/components/form/field/types/SearchField.js +41 -2
- package/src/components/form/field/types/SelectField.js +133 -4
- package/src/components/form/field/types/StringField.js +91 -2
- package/src/components/form/field/types/TelField.js +55 -4
- package/src/components/form/field/types/TextAreaField.js +76 -2
- package/src/components/form/field/types/TimeField.js +120 -5
- package/src/components/form/field/types/UrlField.js +59 -4
- package/src/components/form/field/types/file-field-mode/FileAvatarMode.js +83 -4
- package/src/components/form/field/types/file-field-mode/FileDropzoneMode.js +61 -3
- package/src/components/form/field/types/file-field-mode/FileItemPreview.js +79 -3
- package/src/components/form/field/types/file-field-mode/FileNativeMode.js +24 -2
- package/src/components/form/field/types/file-field-mode/FileUploadButtonMode.js +64 -3
- package/src/components/form/field/types/file-field-mode/FileWallMode.js +56 -3
- package/src/components/form/index.js +28 -28
- package/src/components/form/types/Field.d.ts +73 -0
- package/src/components/form/types/FieldCollection.d.ts +53 -0
- package/src/components/form/types/FormControl.d.ts +64 -0
- package/src/components/form/types/fields/AutocompleteField.d.ts +48 -0
- package/src/components/form/types/fields/CheckboxField.d.ts +33 -0
- package/src/components/form/types/fields/CheckboxGroupField.d.ts +49 -0
- package/src/components/form/types/fields/ColorField.d.ts +37 -0
- package/src/components/form/types/fields/DateField.d.ts +70 -0
- package/src/components/form/types/fields/EmailField.d.ts +35 -0
- package/src/components/form/types/fields/FileAvatarMode.d.ts +46 -0
- package/src/components/form/types/fields/FileDropzoneMode.d.ts +28 -0
- package/src/components/form/types/fields/FileField.d.ts +56 -0
- package/src/components/form/types/fields/FileItemPreview.d.ts +35 -0
- package/src/components/form/types/fields/FileNativeMode.d.ts +21 -0
- package/src/components/form/types/fields/FileUploadButtonMode.d.ts +34 -0
- package/src/components/form/types/fields/FileWallMode.d.ts +32 -0
- package/src/components/form/types/fields/HiddenField.d.ts +26 -0
- package/src/components/form/types/fields/ImageField.d.ts +45 -0
- package/src/components/form/types/fields/NumberField.d.ts +48 -0
- package/src/components/form/types/fields/PasswordField.d.ts +46 -0
- package/src/components/form/types/fields/RadioField.d.ts +48 -0
- package/src/components/form/types/fields/RangeField.d.ts +44 -0
- package/src/components/form/types/fields/SearchField.d.ts +34 -0
- package/src/components/form/types/fields/SelectField.d.ts +71 -0
- package/src/components/form/types/fields/StringField.d.ts +48 -0
- package/src/components/form/types/fields/TelField.d.ts +37 -0
- package/src/components/form/types/fields/TextAreaField.d.ts +44 -0
- package/src/components/form/types/fields/TimeField.d.ts +51 -0
- package/src/components/form/types/fields/UrlField.d.ts +35 -0
- package/src/components/form/validation/Validation.js +54 -54
- package/src/components/index.d.ts +160 -0
- package/src/components/list/List.js +99 -15
- package/src/components/list/ListGroup.js +58 -8
- package/src/components/list/ListItem.js +79 -18
- package/src/components/list/index.js +5 -5
- package/src/components/list/types/List.d.ts +43 -0
- package/src/components/list/types/ListGroup.d.ts +37 -0
- package/src/components/list/types/ListItem.d.ts +42 -0
- package/src/components/menu/HasMenuItem.js +55 -6
- package/src/components/menu/Menu.js +113 -22
- package/src/components/menu/MenuDivider.js +18 -2
- package/src/components/menu/MenuGroup.js +61 -6
- package/src/components/menu/MenuItem.js +95 -11
- package/src/components/menu/MenuLink.js +27 -2
- package/src/components/menu/index.js +6 -6
- package/src/components/menu/types/Menu.d.ts +60 -0
- package/src/components/menu/types/MenuDivider.d.ts +19 -0
- package/src/components/menu/types/MenuGroup.d.ts +44 -0
- package/src/components/menu/types/MenuItem.d.ts +46 -0
- package/src/components/menu/types/MenuLink.d.ts +16 -0
- package/src/components/modal/Modal.js +258 -17
- package/src/components/modal/index.js +3 -3
- package/src/components/modal/types/Modal.d.ts +94 -0
- package/src/components/pagination/Pagination.js +155 -7
- package/src/components/pagination/index.js +3 -3
- package/src/components/pagination/types/Pagination.d.ts +68 -0
- package/src/components/popover/Popover.js +198 -11
- package/src/components/popover/PopoverFooter.js +33 -9
- package/src/components/popover/PopoverHeader.js +33 -8
- package/src/components/popover/index.js +4 -4
- package/src/components/popover/types/Popover.d.ts +83 -0
- package/src/components/popover/types/PopoverFooter.d.ts +24 -0
- package/src/components/popover/types/PopoverHeader.d.ts +26 -0
- package/src/components/progress/Progress.js +182 -13
- package/src/components/progress/index.js +3 -3
- package/src/components/progress/types/Progress.d.ts +77 -0
- package/src/components/skeleton/Skeleton.js +117 -49
- package/src/components/skeleton/index.js +3 -3
- package/src/components/skeleton/types/Skeleton.d.ts +55 -0
- package/src/components/slider/Slider.js +207 -10
- package/src/components/slider/index.js +2 -2
- package/src/components/slider/types/Slider.d.ts +82 -0
- package/src/components/spacer/Spacer.js +11 -2
- package/src/components/spacer/index.js +2 -2
- package/src/components/spacer/types/Spacer.d.ts +19 -0
- package/src/components/spinner/Spinner.js +180 -9
- package/src/components/spinner/index.js +3 -3
- package/src/components/spinner/types/Spinner.d.ts +71 -0
- package/src/components/splitter/Splitter.js +76 -13
- package/src/components/splitter/SplitterGutter.js +67 -5
- package/src/components/splitter/SplitterPanel.js +69 -2
- package/src/components/splitter/index.js +5 -5
- package/src/components/splitter/types/Splitter.d.ts +38 -0
- package/src/components/splitter/types/SplitterGutter.d.ts +38 -0
- package/src/components/splitter/types/SplitterPanel.d.ts +41 -0
- package/src/components/stacks/AbsoluteStack.js +23 -3
- package/src/components/stacks/FixedStack.js +23 -3
- package/src/components/stacks/HStack.js +24 -3
- package/src/components/stacks/PositionStack.js +111 -3
- package/src/components/stacks/RelativeStack.js +23 -3
- package/src/components/stacks/Stack.js +73 -2
- package/src/components/stacks/VStack.js +24 -4
- package/src/components/stacks/index.js +7 -7
- package/src/components/stacks/types/AbsoluteStack.d.ts +16 -0
- package/src/components/stacks/types/FixedStack.d.ts +16 -0
- package/src/components/stacks/types/HStack.d.ts +16 -0
- package/src/components/stacks/types/PositionStack.d.ts +54 -0
- package/src/components/stacks/types/RelativeStack.d.ts +17 -0
- package/src/components/stacks/types/Stack.d.ts +39 -0
- package/src/components/stacks/types/VStack.d.ts +16 -0
- package/src/components/stepper/Stepper.js +152 -12
- package/src/components/stepper/StepperStep.js +104 -3
- package/src/components/stepper/index.js +4 -4
- package/src/components/stepper/types/Stepper.d.ts +68 -0
- package/src/components/stepper/types/StepperStep.d.ts +54 -0
- package/src/components/switch/Switch.js +143 -6
- package/src/components/switch/index.js +1 -1
- package/src/components/switch/types/Switch.d.ts +55 -0
- package/src/components/table/Column.js +105 -6
- package/src/components/table/ColumnGroup.js +48 -3
- package/src/components/table/DataTable.js +256 -19
- package/src/components/table/SimpleTable.js +58 -4
- package/src/components/table/index.js +2 -2
- package/src/components/table/types/Column.d.ts +49 -0
- package/src/components/table/types/ColumnGroup.d.ts +28 -0
- package/src/components/table/types/DataTable.d.ts +97 -0
- package/src/components/table/types/SimpleTable.d.ts +40 -0
- package/src/components/tabs/Tabs.js +192 -5
- package/src/components/tabs/index.js +3 -3
- package/src/components/tabs/types/Tabs.d.ts +78 -0
- package/src/components/toast/Toast.js +133 -5
- package/src/components/toast/index.js +3 -3
- package/src/components/toast/types/Toast.d.ts +57 -0
- package/src/components/toast/types/ToastError.d.ts +7 -0
- package/src/components/toast/types/ToastInfo.d.ts +7 -0
- package/src/components/toast/types/ToastSuccess.d.ts +7 -0
- package/src/components/toast/types/ToastWarning.d.ts +7 -0
- package/src/components/tooltip/Tooltip.js +157 -13
- package/src/components/tooltip/index.js +2 -2
- package/src/components/tooltip/prototypes.js +1 -1
- package/src/components/tooltip/types/Tooltip.d.ts +65 -0
- package/src/core/data/MemoryManager.js +2 -2
- package/src/core/data/Observable.js +15 -18
- package/src/core/data/ObservableArray.js +118 -46
- package/src/core/data/ObservableChecker.js +2 -2
- package/src/core/data/ObservableItem.js +135 -21
- package/src/core/data/ObservableObject.js +126 -35
- package/src/core/data/ObservableResource.js +113 -3
- package/src/core/data/Store.js +142 -26
- package/src/core/data/observable-helpers/observable.is-to.js +196 -1
- package/src/core/data/observable-helpers/observable.prototypes.js +33 -8
- package/src/core/elements/anchor/anchor-with-sentinel.js +23 -2
- package/src/core/elements/anchor/anchor.js +16 -7
- package/src/core/elements/anchor/one-child-anchor-overwriting.js +2 -2
- package/src/core/elements/content-formatter.js +1 -1
- package/src/core/elements/control/for-each-array.js +9 -9
- package/src/core/elements/control/for-each.js +14 -14
- package/src/core/elements/control/show-if.js +11 -11
- package/src/core/elements/control/show-when.js +5 -5
- package/src/core/elements/control/switch.js +14 -14
- package/src/core/elements/description-list.js +1 -1
- package/src/core/elements/form.js +2 -2
- package/src/core/elements/fragment.js +1 -1
- package/src/core/elements/html5-semantics.js +1 -1
- package/src/core/elements/img.js +3 -3
- package/src/core/elements/interactive.js +1 -1
- package/src/core/elements/list.js +1 -1
- package/src/core/elements/medias.js +1 -1
- package/src/core/elements/meta-data.js +1 -1
- package/src/core/elements/svg.js +1 -1
- package/src/core/elements/table.js +1 -1
- package/src/core/errors/ArgTypesError.js +1 -1
- package/src/core/utils/HasEventEmitter.js +36 -2
- package/src/core/utils/args-types.js +9 -9
- package/src/core/utils/cache.js +1 -1
- package/src/core/utils/callback-handler.js +29 -0
- package/src/core/utils/debug-manager.js +6 -6
- package/src/core/utils/events.js +139 -139
- package/src/core/utils/filters/date.js +84 -3
- package/src/core/utils/filters/standard.js +136 -11
- package/src/core/utils/filters/strings.js +34 -2
- package/src/core/utils/filters/utils.js +40 -4
- package/src/core/utils/formatters.js +4 -4
- package/src/core/utils/helpers.js +39 -7
- package/src/core/utils/localstorage.js +11 -11
- package/src/core/utils/memoize.js +56 -3
- package/src/core/utils/plugins-manager.js +3 -3
- package/src/core/utils/property-accumulator.js +6 -6
- package/src/core/utils/prototypes.js +26 -1
- package/src/core/utils/shortcut-manager.js +2 -2
- package/src/core/utils/validator.js +8 -8
- package/src/core/wrappers/AttributesWrapper.js +32 -22
- package/src/core/wrappers/DocumentObserver.js +3 -3
- package/src/core/wrappers/ElementCreator.js +5 -5
- package/src/core/wrappers/HtmlElementWrapper.js +38 -12
- package/src/core/wrappers/NDElement.js +328 -22
- package/src/core/wrappers/NdPrototype.js +60 -16
- package/src/core/wrappers/SingletonView.js +50 -2
- package/src/core/wrappers/SvgElementWrapper.js +1 -1
- package/src/core/wrappers/constants.js +35 -2
- package/src/core/wrappers/prototypes/attributes-extensions.js +7 -7
- package/src/core/wrappers/prototypes/nd-element-extensions.js +72 -6
- package/src/core/wrappers/prototypes/nd-element.transition.extensions.js +42 -2
- package/src/core/wrappers/template-cloner/NodeCloner.js +53 -8
- package/src/core/wrappers/template-cloner/TemplateCloner.js +75 -6
- package/src/core/wrappers/template-cloner/attributes-hydrator.js +58 -2
- package/src/core/wrappers/template-cloner/utils.js +42 -6
- package/src/fetch/NativeFetch.js +3 -3
- package/src/i18n/bin/scan.js +6 -6
- package/src/i18n/index.d.ts +2 -0
- package/src/i18n/service/I18nService.d.ts +27 -0
- package/src/i18n/service/I18nService.js +5 -5
- package/src/i18n/service/functions.d.ts +22 -0
- package/src/i18n/service/functions.js +2 -2
- package/src/router/Route.js +3 -3
- package/src/router/RouteGroupHelper.js +2 -2
- package/src/router/Router.js +15 -15
- package/src/router/RouterComponent.js +33 -7
- package/src/router/link.js +4 -4
- package/src/router/modes/HashRouter.js +2 -2
- package/src/router/modes/HistoryRouter.js +2 -2
- package/src/router/modes/MemoryRouter.js +1 -1
- package/src/ui/components/accordion/AccordionItemRender.js +3 -3
- package/src/ui/components/accordion/AccordionRender.js +1 -1
- package/src/ui/components/alert/AlertRender.js +10 -10
- package/src/ui/components/avatar/avata-group/AvatarGroupRender.js +1 -1
- package/src/ui/components/avatar/avatar/AvatarRender.js +1 -1
- package/src/ui/components/breadcrumb/BreadcrumbRender.js +2 -2
- package/src/ui/components/button/ButtonRender.js +1 -1
- package/src/ui/components/contextmenu/ContextmenuRender.js +5 -5
- package/src/ui/components/dropdown/DropdownRender.js +8 -8
- package/src/ui/components/dropdown/group/DropdownGroupRender.js +2 -2
- package/src/ui/components/dropdown/item/DropdownItemRender.js +1 -1
- package/src/ui/components/form/FieldCollectionRender.js +2 -2
- package/src/ui/components/form/FormControlRender.js +5 -5
- package/src/ui/components/form/fields/AutocompleteFieldRender.js +3 -3
- package/src/ui/components/form/fields/CheckboxFieldRender.js +1 -1
- package/src/ui/components/form/fields/CheckboxGroupFieldRender.js +1 -1
- package/src/ui/components/form/fields/DateFieldRender.js +7 -7
- package/src/ui/components/form/fields/EmailFieldRender.js +1 -1
- package/src/ui/components/form/fields/FieldRender.js +4 -4
- package/src/ui/components/form/fields/FileFieldRender.js +1 -1
- package/src/ui/components/form/fields/PasswordFieldRender.js +2 -2
- package/src/ui/components/form/fields/RadioFieldRender.js +1 -1
- package/src/ui/components/form/fields/RangeFieldRender.js +1 -1
- package/src/ui/components/form/fields/SelectFieldRender.js +2 -2
- package/src/ui/components/form/fields/SliderFieldRender.js +6 -6
- package/src/ui/components/form/fields/StringFieldRender.js +1 -1
- package/src/ui/components/form/fields/TelFieldRender.js +1 -1
- package/src/ui/components/form/fields/TextAreaFieldRender.js +1 -1
- package/src/ui/components/form/fields/TimeFieldRender.js +3 -3
- package/src/ui/components/form/fields/UrlFieldRender.js +1 -1
- package/src/ui/components/form/file-upload-mode/FileAvatarModeRender.js +1 -1
- package/src/ui/components/form/file-upload-mode/FileDropzoneModeRender.js +2 -2
- package/src/ui/components/form/file-upload-mode/FileUploadButtonModeRender.js +2 -2
- package/src/ui/components/form/file-upload-mode/FileWallModeRender.js +1 -1
- package/src/ui/components/form/helpers.js +8 -8
- package/src/ui/components/form/index.js +27 -27
- package/src/ui/components/menu/MenuDividerRender.js +1 -1
- package/src/ui/components/menu/MenuGroupRender.js +3 -3
- package/src/ui/components/menu/MenuItemRender.js +2 -2
- package/src/ui/components/menu/MenuLinkRender.js +3 -3
- package/src/ui/components/menu/helpers.js +4 -4
- package/src/ui/components/modal/ModalRender.js +4 -4
- package/src/ui/components/pagination/PaginationRender.js +9 -9
- package/src/ui/components/popover/PopoverRender.js +7 -7
- package/src/ui/components/progress/ProgressRender.js +12 -12
- package/src/ui/components/skeleton/SkeletonRender.js +56 -0
- package/src/ui/components/splitter/SplitterGutterRender.js +1 -1
- package/src/ui/components/splitter/SplitterPanelRender.js +2 -2
- package/src/ui/components/stacks/PositionStackRender.js +1 -1
- package/src/ui/components/stacks/StackRender.js +1 -1
- package/src/ui/components/stacks/absolute-stack/AbsoluteStackRender.js +1 -1
- package/src/ui/components/stacks/fixed-stack/FixedStackRender.js +1 -1
- package/src/ui/components/stacks/h-stack/HStackRender.js +1 -1
- package/src/ui/components/stacks/index.js +5 -5
- package/src/ui/components/stacks/relative-stack/RelativeStackRender.js +1 -1
- package/src/ui/components/stacks/v-stack/VStackRender.js +1 -1
- package/src/ui/components/stepper/StepperRender.js +2 -2
- package/src/ui/components/stepper/StepperStepRender.js +4 -4
- package/src/ui/components/switch/SwitchRender.js +4 -4
- package/src/ui/components/table/data-table/DataTableRender.js +5 -5
- package/src/ui/components/table/data-table/bulk-actions.js +7 -7
- package/src/ui/components/table/data-table/pagination.js +6 -6
- package/src/ui/components/table/data-table/tables.js +25 -25
- package/src/ui/components/table/data-table/toolbar.js +3 -3
- package/src/ui/components/table/simple-table/SimpleTableRender.js +8 -8
- package/src/ui/components/tabs/TabsRender.js +11 -11
- package/src/ui/components/toast/ToastRender.js +3 -3
- package/src/ui/components/tooltip/TooltipRender.js +1 -1
- package/src/ui/index.js +36 -36
- package/types/elements.d.ts +163 -1037
- package/types/forms.d.ts +16 -20
- package/types/globals.d.ts +543 -0
- package/types/images.d.ts +2 -2
- package/types/observable-resource.d.ts +3 -0
- package/types/property-accumulator.d.ts +4 -4
- package/types/store.d.ts +26 -2
- package/types/validator.ts +3 -3
- package/ui.js +1 -0
- package/src/components/form/field/DefaultRender.js +0 -77
- package/src/components/form/field/FieldFactory.js +0 -107
- package/src/components/skeleton/SkeletonCard.js +0 -0
- package/src/components/skeleton/SkeletonList.js +0 -0
- package/src/components/skeleton/SkeletonParagraph.js +0 -0
- package/src/components/skeleton/SkeletonTable.js +0 -0
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import Anchor from
|
|
2
|
-
|
|
1
|
+
import Anchor from '../elements/anchor/anchor';
|
|
3
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Creates a singleton view — a component that is instantiated only once,
|
|
5
|
+
* then reused across multiple renders. Useful for performance-critical components
|
|
6
|
+
* that are frequently shown/hidden or repeated in lists.
|
|
7
|
+
*
|
|
8
|
+
* @constructor
|
|
9
|
+
* @param {(instance: SingletonView) => Node} $viewCreator - Function that builds the view once and returns the root node.
|
|
10
|
+
* Receives the SingletonView instance so it can call .createSection().
|
|
11
|
+
* @example
|
|
12
|
+
* const Card = useSingleton((view) => {
|
|
13
|
+
* const nameSection = view.createSection('name');
|
|
14
|
+
* return Div({ class: 'card' }, nameSection);
|
|
15
|
+
* });
|
|
16
|
+
* Card([{ name: 'John' }]); // Renders once, reused on subsequent calls
|
|
17
|
+
*/
|
|
4
18
|
export function SingletonView($viewCreator) {
|
|
5
19
|
let $cacheNode = null;
|
|
6
20
|
let $components = null;
|
|
7
21
|
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Renders the singleton view with the given data.
|
|
25
|
+
* On the first call, create the view by calling $viewCreator.
|
|
26
|
+
* On later calls, updates registered sections via their update functions.
|
|
27
|
+
*
|
|
28
|
+
* @param {Array} data - Array where data[0] is an object mapping section names to new content
|
|
29
|
+
* @returns {Node} The cached root node
|
|
30
|
+
*/
|
|
8
31
|
this.render = (data) => {
|
|
9
32
|
if(!$cacheNode) {
|
|
10
33
|
$cacheNode = $viewCreator(this);
|
|
@@ -22,6 +45,18 @@ export function SingletonView($viewCreator) {
|
|
|
22
45
|
return $cacheNode;
|
|
23
46
|
};
|
|
24
47
|
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a named anchor section inside the singleton view.
|
|
51
|
+
* The section can be updated later by passing new content through .render().
|
|
52
|
+
*
|
|
53
|
+
* @param {string} name - Unique section name used as the update key
|
|
54
|
+
* @param {((content: *) => Node)?} [fn] - Optional transform function applied to new content before inserting
|
|
55
|
+
* @returns {AnchorDocumentFragment} Anchor fragment to place inside the view's DOM
|
|
56
|
+
* @example
|
|
57
|
+
* const nameSection = view.createSection('name');
|
|
58
|
+
* // Later: Card([{ name: 'Jane' }]); // replaces content in nameSection
|
|
59
|
+
*/
|
|
25
60
|
this.createSection = (name, fn) => {
|
|
26
61
|
$components = $components || {};
|
|
27
62
|
const anchor = Anchor('Component ' + name);
|
|
@@ -39,6 +74,19 @@ export function SingletonView($viewCreator) {
|
|
|
39
74
|
}
|
|
40
75
|
|
|
41
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Creates a memoized factory that returns a SingletonView instance.
|
|
79
|
+
* The singleton is created on the first call and reused for all subsequent calls.
|
|
80
|
+
*
|
|
81
|
+
* @param {(instance: SingletonView) => Node} fn - View creator function passed to SingletonView
|
|
82
|
+
* @returns {(...args: any[]) => Node} Function that renders the singleton with the given data
|
|
83
|
+
* @example
|
|
84
|
+
* const Card = useSingleton((view) => {
|
|
85
|
+
* const title = view.createSection('title');
|
|
86
|
+
* return Div({}, title);
|
|
87
|
+
* });
|
|
88
|
+
* Card([{ title: 'Hello' }]);
|
|
89
|
+
*/
|
|
42
90
|
export function useSingleton(fn) {
|
|
43
91
|
let $cache = null;
|
|
44
92
|
|
|
@@ -29,5 +29,38 @@ export const BOOLEAN_ATTRIBUTES = new Set([
|
|
|
29
29
|
'itemscope',
|
|
30
30
|
'allowfullscreen',
|
|
31
31
|
'allowpaymentrequest',
|
|
32
|
-
'playsinline'
|
|
33
|
-
]);
|
|
32
|
+
'playsinline',
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
export const BOOL_ATTRIBUTES_NAME = {
|
|
36
|
+
'allowfullscreen': 'allowFullscreen',
|
|
37
|
+
'allowpaymentrequest': 'allowPaymentRequest',
|
|
38
|
+
'async': 'async',
|
|
39
|
+
'autocomplete': 'autocomplete',
|
|
40
|
+
'autofocus': 'autofocus',
|
|
41
|
+
'autoplay': 'autoplay',
|
|
42
|
+
'checked': 'checked',
|
|
43
|
+
'controls': 'controls',
|
|
44
|
+
'default': 'default',
|
|
45
|
+
'defer': 'defer',
|
|
46
|
+
'disabled': 'disabled',
|
|
47
|
+
'download': 'download',
|
|
48
|
+
'draggable': 'draggable',
|
|
49
|
+
'formnovalidate': 'formNoValidate',
|
|
50
|
+
'contenteditable': 'contentEditable',
|
|
51
|
+
'hidden': 'hidden',
|
|
52
|
+
'itemscope': 'itemScope',
|
|
53
|
+
'loop': 'loop',
|
|
54
|
+
'multiple': 'multiple',
|
|
55
|
+
'muted': 'muted',
|
|
56
|
+
'novalidate': 'noValidate',
|
|
57
|
+
'open': 'open',
|
|
58
|
+
'playsinline': 'playsInline',
|
|
59
|
+
'readonly': 'readOnly',
|
|
60
|
+
'required': 'required',
|
|
61
|
+
'reversed': 'reversed',
|
|
62
|
+
'scoped': 'scoped',
|
|
63
|
+
'selected': 'selected',
|
|
64
|
+
'spellcheck': 'spellcheck',
|
|
65
|
+
'translate': 'translate',
|
|
66
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bindAttributeWithObservable,
|
|
3
|
-
bindBooleanAttribute
|
|
4
|
-
} from
|
|
5
|
-
import ObservableItem from
|
|
6
|
-
import TemplateBinding from
|
|
7
|
-
import {BOOLEAN_ATTRIBUTES} from
|
|
8
|
-
import ObservableChecker from
|
|
3
|
+
bindBooleanAttribute,
|
|
4
|
+
} from '../AttributesWrapper';
|
|
5
|
+
import ObservableItem from '../../data/ObservableItem';
|
|
6
|
+
import TemplateBinding from '../TemplateBinding';
|
|
7
|
+
import {BOOLEAN_ATTRIBUTES} from '../constants';
|
|
8
|
+
import ObservableChecker from '../../data/ObservableChecker';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
ObservableItem.prototype.handleNdAttribute = function(element, attributeName) {
|
|
@@ -19,6 +19,6 @@ ObservableItem.prototype.handleNdAttribute = function(element, attributeName) {
|
|
|
19
19
|
|
|
20
20
|
ObservableChecker.prototype.handleNdAttribute = ObservableItem.prototype.handleNdAttribute;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
TemplateBinding.prototype.handleNdAttribute = function(element, attributeName) {
|
|
23
23
|
this.$hydrate(element, attributeName);
|
|
24
24
|
};
|
|
@@ -1,43 +1,92 @@
|
|
|
1
|
-
import ObservableItem from
|
|
2
|
-
import {NDElement} from
|
|
3
|
-
import TemplateBinding from
|
|
4
|
-
import {ElementCreator} from
|
|
5
|
-
import PluginsManager from
|
|
6
|
-
import ObservableChecker from
|
|
1
|
+
import ObservableItem from '../../data/ObservableItem';
|
|
2
|
+
import {NDElement} from '../NDElement';
|
|
3
|
+
import TemplateBinding from '../TemplateBinding';
|
|
4
|
+
import {ElementCreator} from '../ElementCreator';
|
|
5
|
+
import PluginsManager from '../../utils/plugins-manager';
|
|
6
|
+
import ObservableChecker from '../../data/ObservableChecker';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
NDElement.$getChild = ElementCreator.getChild;
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Converts a string to a reactive text node.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Text} Static text node containing the string value
|
|
15
|
+
*/
|
|
11
16
|
String.prototype.toNdElement = function () {
|
|
12
17
|
return ElementCreator.createStaticTextNode(null, this);
|
|
13
18
|
};
|
|
14
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Converts a number to a static text node.
|
|
22
|
+
*
|
|
23
|
+
* @returns {Text} Static text node containing the number as a string
|
|
24
|
+
*/
|
|
15
25
|
Number.prototype.toNdElement = function () {
|
|
16
26
|
return ElementCreator.createStaticTextNode(null, this.toString());
|
|
17
27
|
};
|
|
18
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Returns the element itself (identity for DOM compatibility).
|
|
31
|
+
*
|
|
32
|
+
* @returns {Element} this
|
|
33
|
+
*/
|
|
19
34
|
Element.prototype.toNdElement = function () {
|
|
20
35
|
return this;
|
|
21
36
|
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns the text node itself (identity for DOM compatibility).
|
|
40
|
+
*
|
|
41
|
+
* @returns {Text} this
|
|
42
|
+
*/
|
|
22
43
|
Text.prototype.toNdElement = function () {
|
|
23
44
|
return this;
|
|
24
45
|
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns the comment node itself (identity for DOM compatibility).
|
|
49
|
+
*
|
|
50
|
+
* @returns {Comment} this
|
|
51
|
+
*/
|
|
25
52
|
Comment.prototype.toNdElement = function () {
|
|
26
53
|
return this;
|
|
27
54
|
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns the document itself (identity for DOM compatibility).
|
|
58
|
+
*
|
|
59
|
+
* @returns {Document} this
|
|
60
|
+
*/
|
|
28
61
|
Document.prototype.toNdElement = function () {
|
|
29
62
|
return this;
|
|
30
63
|
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Returns the document fragment itself (identity for DOM compatibility).
|
|
67
|
+
*
|
|
68
|
+
* @returns {DocumentFragment} this
|
|
69
|
+
*/
|
|
31
70
|
DocumentFragment.prototype.toNdElement = function () {
|
|
32
71
|
return this;
|
|
33
72
|
};
|
|
34
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Converts the ObservableItem to a reactive text node that updates automatically when the value changes.
|
|
76
|
+
*
|
|
77
|
+
* @returns {Text} Reactive text node bound to this observable
|
|
78
|
+
*/
|
|
35
79
|
ObservableItem.prototype.toNdElement = function () {
|
|
36
80
|
return ElementCreator.createObservableNode(null, this);
|
|
37
81
|
};
|
|
38
82
|
|
|
39
83
|
ObservableChecker.prototype.toNdElement = ObservableItem.prototype.toNdElement;
|
|
40
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Converts the NDElement to its underlying HTMLElement (or ghost DOM fragment if ghostDom was used).
|
|
87
|
+
*
|
|
88
|
+
* @returns {HTMLElement|DocumentFragment} The underlying DOM node
|
|
89
|
+
*/
|
|
41
90
|
NDElement.prototype.toNdElement = function () {
|
|
42
91
|
const element = this.$element ?? this.$build?.() ?? this.build?.() ?? null;
|
|
43
92
|
if(this.$attachements) {
|
|
@@ -49,6 +98,12 @@ NDElement.prototype.toNdElement = function () {
|
|
|
49
98
|
return element;
|
|
50
99
|
};
|
|
51
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Converts the array to a DocumentFragment containing all elements.
|
|
103
|
+
* Each item is processed through ElementCreator.getChild().
|
|
104
|
+
*
|
|
105
|
+
* @returns {DocumentFragment} Fragment containing all array children
|
|
106
|
+
*/
|
|
52
107
|
Array.prototype.toNdElement = function () {
|
|
53
108
|
const fragment = document.createDocumentFragment();
|
|
54
109
|
for(let i = 0, length = this.length; i < length; i++) {
|
|
@@ -59,6 +114,12 @@ Array.prototype.toNdElement = function () {
|
|
|
59
114
|
return fragment;
|
|
60
115
|
};
|
|
61
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Calls the function and converts its return value to a DOM node.
|
|
119
|
+
* Used internally by ElementCreator to process function-based children.
|
|
120
|
+
*
|
|
121
|
+
* @returns {Node} The DOM node returned by the function
|
|
122
|
+
*/
|
|
62
123
|
Function.prototype.toNdElement = function () {
|
|
63
124
|
const child = this;
|
|
64
125
|
if(process.env.NODE_ENV === 'development') {
|
|
@@ -67,6 +128,11 @@ Function.prototype.toNdElement = function () {
|
|
|
67
128
|
return ElementCreator.getChild(child());
|
|
68
129
|
};
|
|
69
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Converts the TemplateBinding to a hydratable DOM node for use in TemplateCloner.
|
|
133
|
+
*
|
|
134
|
+
* @returns {Node} Hydratable node
|
|
135
|
+
*/
|
|
70
136
|
TemplateBinding.prototype.toNdElement = function () {
|
|
71
137
|
return ElementCreator.createHydratableNode(null, this);
|
|
72
138
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {NDElement} from
|
|
1
|
+
import {NDElement} from '../NDElement';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {HTMLElement} el
|
|
@@ -34,6 +34,16 @@ const waitForVisualEnd = (el, timeout = 1000) => {
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Registers a beforeUnmount hook that plays an exit CSS transition before the element is removed.
|
|
39
|
+
* Adds the class `{transitionName}-exit`, waits for the transition/animation to end, then removes it.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} transitionName - CSS class prefix for the exit transition
|
|
42
|
+
* @returns {this}
|
|
43
|
+
* @example
|
|
44
|
+
* Div({ class: 'modal' }).nd.transitionOut('fade');
|
|
45
|
+
* // Adds 'fade-exit' before removal, waits for transitionend/animationend
|
|
46
|
+
*/
|
|
37
47
|
NDElement.prototype.transitionOut = function(transitionName) {
|
|
38
48
|
const exitClass = transitionName + '-exit';
|
|
39
49
|
const el = this.$element;
|
|
@@ -45,6 +55,17 @@ NDElement.prototype.transitionOut = function(transitionName) {
|
|
|
45
55
|
return this;
|
|
46
56
|
};
|
|
47
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Plays an enter CSS transition when the element is mounted into the DOM.
|
|
60
|
+
* Adds `{transitionName}-enter-from` immediately, then swaps to `{transitionName}-enter-to`
|
|
61
|
+
* on the next animation frame, and cleans up after the transition ends.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} transitionName - CSS class prefix for the enter transition
|
|
64
|
+
* @returns {this}
|
|
65
|
+
* @example
|
|
66
|
+
* Div({ class: 'modal' }).nd.transitionIn('fade');
|
|
67
|
+
* // On mount: adds 'fade-enter-from', then swaps to 'fade-enter-to'
|
|
68
|
+
*/
|
|
48
69
|
NDElement.prototype.transitionIn = function(transitionName) {
|
|
49
70
|
const startClass = transitionName + '-enter-from';
|
|
50
71
|
const endClass = transitionName + '-enter-to';
|
|
@@ -68,13 +89,32 @@ NDElement.prototype.transitionIn = function(transitionName) {
|
|
|
68
89
|
return this;
|
|
69
90
|
};
|
|
70
91
|
|
|
71
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Applies both enter and exit transitions to the element.
|
|
94
|
+
* Shorthand for calling .transitionIn(name) and .transitionOut(name).
|
|
95
|
+
*
|
|
96
|
+
* @param {string} transitionName - CSS class prefix for both enter and exit transitions
|
|
97
|
+
* @returns {this}
|
|
98
|
+
* @example
|
|
99
|
+
* Div({}).nd.transition('slide');
|
|
100
|
+
* // On mount: enter transition; on unmount: exit transition
|
|
101
|
+
*/
|
|
72
102
|
NDElement.prototype.transition = function (transitionName) {
|
|
73
103
|
this.transitionIn(transitionName);
|
|
74
104
|
this.transitionOut(transitionName);
|
|
75
105
|
return this;
|
|
76
106
|
};
|
|
77
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Immediately applies a CSS animation class to the element.
|
|
110
|
+
* Removes the class automatically once the animation ends.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} animationName - CSS animation class name to add
|
|
113
|
+
* @returns {this}
|
|
114
|
+
* @example
|
|
115
|
+
* Button('Click me').nd.animate('shake');
|
|
116
|
+
* // Adds 'shake' class, removes it when animationend fires
|
|
117
|
+
*/
|
|
78
118
|
NDElement.prototype.animate = function(animationName) {
|
|
79
119
|
const el = this.$element;
|
|
80
120
|
el.classes.add(animationName);
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {ElementCreator} from
|
|
2
|
-
import {createTextNode} from
|
|
3
|
-
import {NDElement} from
|
|
1
|
+
import {ElementCreator} from '../ElementCreator';
|
|
2
|
+
import {createTextNode} from '../HtmlElementWrapper';
|
|
3
|
+
import {NDElement} from '../NDElement';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Stores deferred attribute, class, style, and event bindings for a cloneable element.
|
|
7
|
+
* Used internally by TemplateCloner to apply per-instance data to cloned DOM nodes.
|
|
8
|
+
* Not intended for direct use in application code.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
* @constructor
|
|
12
|
+
* @param {HTMLElement} $element - The template element to clone
|
|
13
|
+
*/
|
|
5
14
|
export default function NodeCloner($element) {
|
|
6
15
|
this.$element = $element;
|
|
7
16
|
this.$classes = null;
|
|
@@ -41,6 +50,12 @@ const buildProperties = (cache, properties, data) => {
|
|
|
41
50
|
return cache;
|
|
42
51
|
};
|
|
43
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Pre-compiles all registered bindings into a sequence of optimised steps.
|
|
55
|
+
* Called once before the first clone operation. Subsequent calls are no-ops.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
44
59
|
NodeCloner.prototype.resolve = function() {
|
|
45
60
|
if(this.$content) {
|
|
46
61
|
return;
|
|
@@ -127,26 +142,56 @@ NodeCloner.prototype.resolve = function() {
|
|
|
127
142
|
};
|
|
128
143
|
};
|
|
129
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Clones the template element and applies all compiled binding steps with the given data.
|
|
147
|
+
*
|
|
148
|
+
* @internal
|
|
149
|
+
* @param {Array} data - Data array passed to each binding callback
|
|
150
|
+
* @returns {HTMLElement} The cloned and hydrated element
|
|
151
|
+
*/
|
|
130
152
|
NodeCloner.prototype.cloneNode = function(data) {
|
|
131
153
|
return this.$element.cloneNode(false);
|
|
132
154
|
};
|
|
133
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Registers an NDElement method binding (e.g. onClick, onInput) to be applied on each clone.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
* @param {string} methodName - Name of the NDElement method to call (e.g. 'onClick')
|
|
161
|
+
* @param {Function} callback - Callback function to pass to the method
|
|
162
|
+
* @returns {NodeCloner} this
|
|
163
|
+
*/
|
|
134
164
|
NodeCloner.prototype.attach = function(methodName, callback) {
|
|
135
165
|
this.$ndMethods = this.$ndMethods || {};
|
|
136
166
|
this.$ndMethods[methodName] = callback;
|
|
137
167
|
return this;
|
|
138
168
|
};
|
|
139
169
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Registers a reactive text content binding for the element.
|
|
172
|
+
*
|
|
173
|
+
* @internal
|
|
174
|
+
* @param {Function} valueorProperty - Function receiving data and returning the text content
|
|
175
|
+
* @returns {NodeCloner} this
|
|
176
|
+
*/
|
|
177
|
+
NodeCloner.prototype.text = function(valueorProperty) {
|
|
178
|
+
this.$content = valueorProperty;
|
|
179
|
+
if(typeof valueorProperty === 'function') {
|
|
180
|
+
this.cloneNode = (data) => createTextNode(valueorProperty.apply(null, data));
|
|
144
181
|
return this;
|
|
145
182
|
}
|
|
146
|
-
this.cloneNode = (data) => createTextNode(data[0][
|
|
183
|
+
this.cloneNode = (data) => createTextNode(data[0][valueorProperty]);
|
|
147
184
|
return this;
|
|
148
185
|
};
|
|
149
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Registers an attribute binding to be applied on each clone.
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
191
|
+
* @param {string} attrName - Attribute name
|
|
192
|
+
* @param {{property: string, value: *}} value - Function receiving data and returning the attribute value
|
|
193
|
+
* @returns {NodeCloner} this
|
|
194
|
+
*/
|
|
150
195
|
NodeCloner.prototype.attr = function(attrName, value) {
|
|
151
196
|
if(attrName === 'class') {
|
|
152
197
|
this.$classes = this.$classes || {};
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import TemplateBinding from
|
|
1
|
+
import TemplateBinding from '../TemplateBinding';
|
|
2
2
|
import { $hydrateFn} from './utils';
|
|
3
|
-
import NodeCloner from
|
|
3
|
+
import NodeCloner from './NodeCloner';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Creates a high-performance template cloner for repeated rendering of the same structure.
|
|
7
|
+
* On the first call, builds the template by calling $fn with a binder object.
|
|
8
|
+
* On subsequent calls, clones the compiled template and hydrates it with new data.
|
|
9
|
+
* Used internally by ForEachArray and other list renderers.
|
|
10
|
+
*
|
|
11
|
+
* @constructor
|
|
12
|
+
* @param {(binder: TemplateCloner) => HTMLElement} $fn - Function that builds the template using binder methods
|
|
13
|
+
* @example
|
|
14
|
+
* const cloner = new TemplateCloner((t) =>
|
|
15
|
+
* Div({},
|
|
16
|
+
* Span(t.text((item) => item.name)),
|
|
17
|
+
* Button({}, 'Delete').nd.onClick(t.event((item) => () => list.removeItem(item)))
|
|
18
|
+
* )
|
|
19
|
+
* );
|
|
20
|
+
* cloner.clone([item]); // returns a hydrated clone
|
|
21
|
+
*/
|
|
5
22
|
export function TemplateCloner($fn) {
|
|
6
23
|
let $node = null;
|
|
7
24
|
|
|
@@ -46,6 +63,14 @@ export function TemplateCloner($fn) {
|
|
|
46
63
|
return containDynamicNode;
|
|
47
64
|
};
|
|
48
65
|
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Clones the compiled template and hydrates it with the given data.
|
|
69
|
+
* On the first call, also compiles the template (builds and optimizes binding steps).
|
|
70
|
+
*
|
|
71
|
+
* @param {Array} data - Data array passed to all binding callbacks
|
|
72
|
+
* @returns {HTMLElement} Cloned and hydrated DOM node
|
|
73
|
+
*/
|
|
49
74
|
this.clone = (data) => {
|
|
50
75
|
const binder = createTemplateCloner(this);
|
|
51
76
|
$node = $fn(binder);
|
|
@@ -60,29 +85,73 @@ export function TemplateCloner($fn) {
|
|
|
60
85
|
|
|
61
86
|
const createBinding = (hydrateFunction, targetType) => {
|
|
62
87
|
return new TemplateBinding((element, property) => {
|
|
63
|
-
$hydrateFn(hydrateFunction, targetType, element, property)
|
|
88
|
+
$hydrateFn(hydrateFunction, targetType, element, property);
|
|
64
89
|
});
|
|
65
90
|
};
|
|
66
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Creates a style binding — the result of fn(data) is applied as inline styles.
|
|
94
|
+
*
|
|
95
|
+
* @param {((...data: any[]) => Record<string, string>)} fn - Function returning a style object
|
|
96
|
+
* @returns {TemplateBinding}
|
|
97
|
+
*/
|
|
67
98
|
this.style = (fn) => {
|
|
68
99
|
return createBinding(fn, 'style');
|
|
69
100
|
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Creates a class binding — the result of fn(data) is applied as a class map.
|
|
104
|
+
*
|
|
105
|
+
* @param {((...data: any[]) => Record<string, boolean>)} fn - Function returning a class map
|
|
106
|
+
* @returns {TemplateBinding}
|
|
107
|
+
*/
|
|
70
108
|
this.class = (fn) => {
|
|
71
109
|
return createBinding(fn, 'class');
|
|
72
110
|
};
|
|
111
|
+
|
|
73
112
|
this.property = (propertyName) => {
|
|
74
113
|
return this.value(propertyName);
|
|
75
|
-
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Creates a text/value binding — the result is set as text content or input value.
|
|
118
|
+
* Alias: .text()
|
|
119
|
+
*
|
|
120
|
+
* @param {string|(((...data: any[]) => string))} callbackOrProperty - Property name (string) or callback returning the value
|
|
121
|
+
* @returns {TemplateBinding}
|
|
122
|
+
*/
|
|
76
123
|
this.value = (callbackOrProperty) => {
|
|
77
124
|
return createBinding(callbackOrProperty, 'value');
|
|
78
125
|
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Alias for .value() — creates a text content binding.
|
|
129
|
+
*
|
|
130
|
+
* @param {string|(((...data: any[]) => string))} callbackOrProperty
|
|
131
|
+
* @returns {TemplateBinding}
|
|
132
|
+
*/
|
|
79
133
|
this.text = this.value;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Creates an attribute binding — the result of fn(data) is set as an attribute value.
|
|
137
|
+
*
|
|
138
|
+
* @param {((...data: any[]) => string)} fn - Function returning the attribute value
|
|
139
|
+
* @returns {TemplateBinding}
|
|
140
|
+
*/
|
|
80
141
|
this.attr = (fn) => {
|
|
81
142
|
return createBinding(fn, 'attributes');
|
|
82
143
|
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates an event binding — fn(data) returns the event handler to attach.
|
|
147
|
+
*
|
|
148
|
+
* @param {((...data: any[]) => EventListener)} fn - Function returning the event callback
|
|
149
|
+
* @returns {TemplateBinding}
|
|
150
|
+
*/
|
|
83
151
|
this.attach = (fn) => {
|
|
84
152
|
return createBinding(fn, 'attach');
|
|
85
153
|
};
|
|
154
|
+
|
|
86
155
|
this.callback = this.attach;
|
|
87
156
|
}
|
|
88
157
|
|
|
@@ -95,9 +164,9 @@ const createTemplateCloner = ($binder) => {
|
|
|
95
164
|
}
|
|
96
165
|
if (typeof prop === 'symbol') return target[prop];
|
|
97
166
|
return target.value(prop);
|
|
98
|
-
}
|
|
167
|
+
},
|
|
99
168
|
});
|
|
100
|
-
}
|
|
169
|
+
};
|
|
101
170
|
|
|
102
171
|
export function useCache(fn) {
|
|
103
172
|
let $cache = null;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {ElementCreator} from
|
|
2
|
-
|
|
1
|
+
import {ElementCreator} from '../ElementCreator';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hydrates a cloned node with all attribute, class, style, and attachment bindings
|
|
5
|
+
* from a compiled BindingData object. Full update path — applies both static attributes
|
|
6
|
+
* and dynamic class/style maps.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
* @param {HTMLElement} node - Cloned DOM node to hydrate
|
|
10
|
+
* @param {BindingData} bindDingData - Pre-compiled binding metadata
|
|
11
|
+
* @param {Array} data - Data array passed to each binding callback
|
|
12
|
+
* @returns {true}
|
|
13
|
+
*/
|
|
3
14
|
export const hydrateFull = (node, bindDingData, data) => {
|
|
4
15
|
const cacheAttributes = bindDingData._cache;
|
|
5
16
|
|
|
@@ -17,6 +28,16 @@ export const hydrateFull = (node, bindDingData, data) => {
|
|
|
17
28
|
return true;
|
|
18
29
|
};
|
|
19
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Hydrates only the dynamic class and style bindings on a cloned node.
|
|
33
|
+
* Used when there are no static attribute bindings.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
* @param {HTMLElement} node - Cloned DOM node to hydrate
|
|
37
|
+
* @param {BindingData} bindDingData - Pre-compiled binding metadata
|
|
38
|
+
* @param {Array} data - Data array passed to each binding callback
|
|
39
|
+
* @returns {true}
|
|
40
|
+
*/
|
|
20
41
|
export const hydrateDynamic = (node, bindDingData, data) => {
|
|
21
42
|
const cacheAttributes = bindDingData._cache;
|
|
22
43
|
|
|
@@ -30,6 +51,15 @@ export const hydrateDynamic = (node, bindDingData, data) => {
|
|
|
30
51
|
return true;
|
|
31
52
|
};
|
|
32
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Hydrates only the dynamic class bindings on a cloned node.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
* @param {HTMLElement} node - Cloned DOM node to hydrate
|
|
59
|
+
* @param {BindingData} bindDingData - Pre-compiled binding metadata
|
|
60
|
+
* @param {Array} data - Data array passed to each binding callback
|
|
61
|
+
* @returns {true}
|
|
62
|
+
*/
|
|
33
63
|
export const hydrateClassAttribute = (node, bindDingData, data) => {
|
|
34
64
|
const classAttributes = bindDingData._cache.class;
|
|
35
65
|
|
|
@@ -42,6 +72,15 @@ export const hydrateClassAttribute = (node, bindDingData, data) => {
|
|
|
42
72
|
return true;
|
|
43
73
|
};
|
|
44
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Hydrates only the dynamic style bindings on a cloned node.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
* @param {HTMLElement} node - Cloned DOM node to hydrate
|
|
80
|
+
* @param {BindingData} bindDingData - Pre-compiled binding metadata
|
|
81
|
+
* @param {Array} data - Data array passed to each binding callback
|
|
82
|
+
* @returns {true}
|
|
83
|
+
*/
|
|
45
84
|
export const hydrateStyleAttribute = (node, bindDingData, data) => {
|
|
46
85
|
const styleAttributes = bindDingData._cache;
|
|
47
86
|
|
|
@@ -54,6 +93,15 @@ export const hydrateStyleAttribute = (node, bindDingData, data) => {
|
|
|
54
93
|
return true;
|
|
55
94
|
};
|
|
56
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Hydrates only the static attribute bindings on a cloned node.
|
|
98
|
+
*
|
|
99
|
+
* @internal
|
|
100
|
+
* @param {HTMLElement} node - Cloned DOM node to hydrate
|
|
101
|
+
* @param {BindingData} bindDingData - Pre-compiled binding metadata
|
|
102
|
+
* @param {Array} data - Data array passed to each binding callback
|
|
103
|
+
* @returns {true}
|
|
104
|
+
*/
|
|
57
105
|
export const hydrateAttributes = (node, bindDingData, data) => {
|
|
58
106
|
const cacheAttributes = bindDingData._cache;
|
|
59
107
|
|
|
@@ -66,6 +114,14 @@ export const hydrateAttributes = (node, bindDingData, data) => {
|
|
|
66
114
|
return true;
|
|
67
115
|
};
|
|
68
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Selects and returns the most efficient hydration function for the given BindingData.
|
|
119
|
+
* Called once during template compilation to assign the optimal update path.
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
122
|
+
* @param {BindingData} bindDingData - Pre-compiled binding metadata
|
|
123
|
+
* @returns {Function} One of: hydrateFull, hydrateDynamic, hydrateClassAttribute, hydrateStyleAttribute, hydrateAttributes, or noUpdate
|
|
124
|
+
*/
|
|
69
125
|
export const getHydrator = (bindDingData) => {
|
|
70
126
|
if(!bindDingData._cache) {
|
|
71
127
|
return noUpdate;
|