native-document 1.0.165 → 1.0.168
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/.vitepress/config.js +166 -0
- package/CHANGELOG.md +153 -0
- package/components.d.ts +2 -0
- package/components.js +2 -1
- package/devtools/widget.js +1 -1
- package/dist/native-document.components.min.js +11589 -2983
- package/dist/native-document.dev.js +2280 -396
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/docs/advanced-components.md +213 -608
- package/docs/anchor.md +173 -312
- package/docs/cache.md +95 -803
- package/docs/cli.md +179 -0
- package/docs/components/accordion.md +172 -0
- package/docs/components/alert.md +99 -0
- package/docs/components/avatar.md +160 -0
- package/docs/components/badge.md +102 -0
- package/docs/components/breadcrumb.md +89 -0
- package/docs/components/button.md +183 -0
- package/docs/components/card.md +69 -0
- package/docs/components/context-menu.md +118 -0
- package/docs/components/data-table.md +345 -0
- package/docs/components/dropdown.md +214 -0
- package/docs/components/form/autocomplete-field.md +81 -0
- package/docs/components/form/checkbox-field.md +41 -0
- package/docs/components/form/checkbox-group-field.md +54 -0
- package/docs/components/form/color-field.md +64 -0
- package/docs/components/form/date-field.md +92 -0
- package/docs/components/form/field-collection.md +63 -0
- package/docs/components/form/file-field.md +203 -0
- package/docs/components/form/form-control.md +87 -0
- package/docs/components/form/image-field.md +90 -0
- package/docs/components/form/index.md +115 -0
- package/docs/components/form/number-field.md +65 -0
- package/docs/components/form/radio-field.md +51 -0
- package/docs/components/form/select-field.md +123 -0
- package/docs/components/form/slider.md +136 -0
- package/docs/components/form/string-field.md +134 -0
- package/docs/components/form/textarea-field.md +65 -0
- package/docs/components/form-fields.md +372 -0
- package/docs/components/getting-started.md +264 -0
- package/docs/components/index.md +337 -0
- package/docs/components/layout.md +279 -0
- package/docs/components/list.md +73 -0
- package/docs/components/menu.md +215 -0
- package/docs/components/modal.md +156 -0
- package/docs/components/pagination.md +95 -0
- package/docs/components/popover.md +131 -0
- package/docs/components/progress.md +111 -0
- package/docs/components/shortcut-manager.md +221 -0
- package/docs/components/simple-table.md +107 -0
- package/docs/components/skeleton.md +155 -0
- package/docs/components/spinner.md +100 -0
- package/docs/components/splitter.md +133 -0
- package/docs/components/stepper.md +163 -0
- package/docs/components/switch.md +113 -0
- package/docs/components/tabs.md +153 -0
- package/docs/components/toast.md +119 -0
- package/docs/components/tooltip.md +151 -0
- package/docs/components/traits.md +261 -0
- package/docs/conditional-rendering.md +170 -588
- package/docs/contributing.md +300 -25
- package/docs/core-concepts.md +205 -374
- package/docs/elements.md +251 -367
- package/docs/extending-native-document-element.md +192 -207
- package/docs/filters.md +153 -1122
- package/docs/getting-started.md +193 -267
- package/docs/i18n.md +241 -0
- package/docs/index.md +76 -0
- package/docs/lifecycle-events.md +143 -75
- package/docs/list-rendering.md +227 -852
- package/docs/memory-management.md +134 -47
- package/docs/native-document-element.md +337 -186
- package/docs/native-fetch.md +99 -630
- package/docs/observable-resource.md +364 -0
- package/docs/observables.md +592 -526
- package/docs/routing.md +244 -653
- package/docs/state-management.md +134 -241
- package/docs/svg-elements.md +231 -0
- package/docs/theming.md +409 -0
- package/docs/validation.md +95 -97
- package/docs/vitepress-conventions.md +219 -0
- package/eslint.config.js +28 -33
- package/i18n.js +1 -1
- package/i18n.ts +2 -0
- package/index.js +3 -0
- package/package.json +36 -14
- package/readme.md +269 -89
- 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 +204 -32
- package/src/components/card/index.js +4 -4
- 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/HasListItem.js +171 -0
- package/src/components/list/List.js +85 -67
- package/src/components/list/ListDivider.js +39 -0
- package/src/components/list/ListGroup.js +105 -38
- package/src/components/list/ListItem.js +158 -49
- package/src/components/list/index.js +8 -6
- 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 +53 -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 +12 -3
- 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 +118 -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 +35 -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/card/CardRender.js +133 -0
- package/src/ui/components/card/card.css +169 -0
- package/src/ui/components/contextmenu/ContextmenuRender.js +6 -6
- 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/list/ListRender.js +18 -0
- package/src/ui/components/list/divider/ListDividerRender.js +10 -0
- package/src/ui/components/list/divider/list-divider.css +12 -0
- package/src/ui/components/list/group/ListGroupRender.js +61 -0
- package/src/ui/components/list/group/list-group.css +62 -0
- package/src/ui/components/list/item/ListItemRender.js +238 -0
- package/src/ui/components/list/item/list-item.css +191 -0
- package/src/ui/components/list/list.css +24 -0
- 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/spacer/SpacerRender.js +10 -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 +44 -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/SkeletonList.js +0 -0
- package/src/components/skeleton/SkeletonParagraph.js +0 -0
- package/src/components/skeleton/SkeletonTable.js +0 -0
- /package/{src/components/skeleton/SkeletonCard.js → docs/tutorials/.gitkeep} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {$} from
|
|
1
|
+
import {$} from '../../../core/data/Observable';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Mixin for managing a collection of items with manipulation methods
|
|
@@ -7,12 +7,12 @@ import {$} from "../../../core/data/Observable";
|
|
|
7
7
|
export default function HasItems() {}
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
HasItems.prototype.trailing = () => {}
|
|
10
|
+
HasItems.prototype.trailing = () => {};
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Sets a dynamic observable array to store items
|
|
14
14
|
* @param {ObservableArray?} [observableArray=null] - Observable array to use, or creates a new one if null
|
|
15
|
-
* @returns {
|
|
15
|
+
* @returns {this}
|
|
16
16
|
*/
|
|
17
17
|
HasItems.prototype.dynamic = function(observableArray = null) {
|
|
18
18
|
this.$description.items = observableArray || $.array([]);
|
|
@@ -23,7 +23,7 @@ HasItems.prototype.bind = HasItems.prototype.dynamic;
|
|
|
23
23
|
/**
|
|
24
24
|
* Replaces all existing items with a new array of items
|
|
25
25
|
* @param {Array} items - Array of new items
|
|
26
|
-
* @returns {
|
|
26
|
+
* @returns {this}
|
|
27
27
|
*/
|
|
28
28
|
HasItems.prototype.items = function(items) {
|
|
29
29
|
this.$description.items.splice(0, this.$description.items.length, ...items);
|
|
@@ -33,7 +33,7 @@ HasItems.prototype.items = function(items) {
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Clears all items from the collection
|
|
36
|
-
* @returns {
|
|
36
|
+
* @returns {this}
|
|
37
37
|
*/
|
|
38
38
|
HasItems.prototype.clear = function() {
|
|
39
39
|
const items = this.$description.items;
|
|
@@ -48,7 +48,7 @@ HasItems.prototype.clear = function() {
|
|
|
48
48
|
/**
|
|
49
49
|
* Removes a specific item from the collection
|
|
50
50
|
* @param {*} item - The item to remove
|
|
51
|
-
* @returns {
|
|
51
|
+
* @returns {this}
|
|
52
52
|
*/
|
|
53
53
|
HasItems.prototype.removeItem = function(item) {
|
|
54
54
|
const items = this.$description.items;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface HasFullPosition {
|
|
2
|
+
atTop(): this;
|
|
3
|
+
atBottom(): this;
|
|
4
|
+
atLeft(): this;
|
|
5
|
+
atRight(): this;
|
|
6
|
+
atTopLeading(): this;
|
|
7
|
+
atTopTrailing(): this;
|
|
8
|
+
atTopCenter(): this;
|
|
9
|
+
atBottomLeading(): this;
|
|
10
|
+
atBottomTrailing(): this;
|
|
11
|
+
atBottomCenter(): this;
|
|
12
|
+
atLeadingCenter(): this;
|
|
13
|
+
atTrailingCenter(): this;
|
|
14
|
+
}
|
|
@@ -5,46 +5,90 @@ HasFullPosition.prototype.atTop = function() {
|
|
|
5
5
|
this.$description.position = 'top';
|
|
6
6
|
return this;
|
|
7
7
|
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @returns {this}
|
|
11
|
+
*/
|
|
8
12
|
HasFullPosition.prototype.atBottom = function() {
|
|
9
13
|
this.$description.position = 'bottom';
|
|
10
14
|
return this;
|
|
11
15
|
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @returns {this}
|
|
19
|
+
*/
|
|
12
20
|
HasFullPosition.prototype.atLeft = function() {
|
|
13
21
|
this.$description.position = 'left';
|
|
14
22
|
return this;
|
|
15
23
|
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @returns {this}
|
|
27
|
+
*/
|
|
16
28
|
HasFullPosition.prototype.atRight = function() {
|
|
17
29
|
this.$description.position = 'right';
|
|
18
30
|
return this;
|
|
19
31
|
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @returns {this}
|
|
35
|
+
*/
|
|
20
36
|
HasFullPosition.prototype.atTopLeading = function() {
|
|
21
37
|
this.$description.position = 'top-leading';
|
|
22
38
|
return this;
|
|
23
39
|
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @returns {this}
|
|
43
|
+
*/
|
|
24
44
|
HasFullPosition.prototype.atTopTrailing = function() {
|
|
25
45
|
this.$description.position = 'top-trailing';
|
|
26
46
|
return this;
|
|
27
47
|
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @returns {this}
|
|
51
|
+
*/
|
|
28
52
|
HasFullPosition.prototype.atTopCenter = function() {
|
|
29
53
|
this.$description.position = 'top-center';
|
|
30
54
|
return this;
|
|
31
55
|
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @returns {this}
|
|
59
|
+
*/
|
|
32
60
|
HasFullPosition.prototype.atBottomLeading = function() {
|
|
33
61
|
this.$description.position = 'bottom-leading';
|
|
34
62
|
return this;
|
|
35
63
|
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @returns {this}
|
|
67
|
+
*/
|
|
36
68
|
HasFullPosition.prototype.atBottomTrailing = function() {
|
|
37
69
|
this.$description.position = 'bottom-trailing';
|
|
38
70
|
return this;
|
|
39
71
|
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @returns {this}
|
|
75
|
+
*/
|
|
40
76
|
HasFullPosition.prototype.atBottomCenter = function() {
|
|
41
77
|
this.$description.position = 'bottom-center';
|
|
42
78
|
return this;
|
|
43
79
|
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @returns {this}
|
|
83
|
+
*/
|
|
44
84
|
HasFullPosition.prototype.atLeadingCenter = function() {
|
|
45
85
|
this.$description.position = 'leading-center';
|
|
46
86
|
return this;
|
|
47
87
|
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @returns {this}
|
|
91
|
+
*/
|
|
48
92
|
HasFullPosition.prototype.atTrailingCenter = function() {
|
|
49
93
|
this.$description.position = 'trailing-center';
|
|
50
94
|
return this;
|
|
@@ -1,22 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
2
5
|
export default function HasPosition() {}
|
|
3
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @returns {this}
|
|
9
|
+
*/
|
|
4
10
|
HasPosition.prototype.atTop = function() {
|
|
5
11
|
this.$description.position = 'top';
|
|
6
12
|
return this;
|
|
7
13
|
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @returns {this}
|
|
17
|
+
*/
|
|
8
18
|
HasPosition.prototype.atBottom = function() {
|
|
9
19
|
this.$description.position = 'bottom';
|
|
10
20
|
return this;
|
|
11
21
|
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @returns {this}
|
|
25
|
+
*/
|
|
12
26
|
HasPosition.prototype.atLeft = function() {
|
|
13
27
|
this.$description.position = 'left';
|
|
14
28
|
return this;
|
|
15
29
|
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @returns {this}
|
|
33
|
+
*/
|
|
16
34
|
HasPosition.prototype.atRight = function() {
|
|
17
35
|
this.$description.position = 'right';
|
|
18
36
|
return this;
|
|
19
37
|
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @returns {this}
|
|
41
|
+
*/
|
|
20
42
|
HasPosition.prototype.atCenter = function() {
|
|
21
43
|
this.$description.position = 'center';
|
|
22
44
|
return this;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ResizableOptions {
|
|
2
|
+
directions?: string[];
|
|
3
|
+
size?: {
|
|
4
|
+
minWidth?: number;
|
|
5
|
+
maxWidth?: number;
|
|
6
|
+
minHeight?: number;
|
|
7
|
+
maxHeight?: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface HasResizable {
|
|
12
|
+
makeResizable(parent: HTMLElement, options?: ResizableOptions): () => void;
|
|
13
|
+
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
import './has-resizable.css';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @constructor
|
|
7
|
+
*/
|
|
4
8
|
export default function HasResizable() {}
|
|
5
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @param {HTMLElement} parent
|
|
12
|
+
* @param {{ directions?: string[], size?: { minWidth?: number, maxWidth?: number, minHeight?: number, maxHeight?: number } }} [options={}]
|
|
13
|
+
* @returns {() => void}
|
|
14
|
+
*/
|
|
6
15
|
HasResizable.prototype.makeResizable = function(parent, options = {}) {
|
|
7
16
|
if(!this.emit) {
|
|
8
17
|
throw new Error('HasResizable requires HasEventEmitter — add it via BaseComponent.use(Component, HasEventEmitter).');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ObservableItem } from '../../../../types/observable';
|
|
2
|
+
|
|
3
|
+
export interface HasValidation {
|
|
4
|
+
required(message?: string): this;
|
|
5
|
+
custom(validatorFn: (value: unknown, allValues?: Record<string, unknown>) => boolean, message?: string): this;
|
|
6
|
+
addRule(validationFn: Function, params?: unknown[], message?: string): this;
|
|
7
|
+
requiredIf(
|
|
8
|
+
condition: ObservableItem<boolean> | boolean | string | ((v: Record<string, unknown>) => boolean),
|
|
9
|
+
message?: string
|
|
10
|
+
): this;
|
|
11
|
+
clearErrorOn(event: string): this;
|
|
12
|
+
validateOn(event: string): this;
|
|
13
|
+
showErrors(show?: boolean | ObservableItem<boolean>): this;
|
|
14
|
+
hideErrors(): this;
|
|
15
|
+
setError(error: string | string[]): this;
|
|
16
|
+
validate(allValues?: Record<string, unknown>): { key: string; errors: string[] };
|
|
17
|
+
}
|
|
@@ -1,63 +1,110 @@
|
|
|
1
|
-
import {resolveParams} from
|
|
2
|
-
import BaseComponent from
|
|
3
|
-
import {Validation} from
|
|
4
|
-
|
|
1
|
+
import {resolveParams} from '../../form/utils';
|
|
2
|
+
import BaseComponent from '../../BaseComponent';
|
|
3
|
+
import {Validation} from '../../form/validation/Validation';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
5
9
|
export default function HasValidation() {}
|
|
6
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} message
|
|
13
|
+
* @returns {this}
|
|
14
|
+
*/
|
|
7
15
|
HasValidation.prototype.required = function(message) {
|
|
8
16
|
this.$description.rules.push({
|
|
9
17
|
fn: Validation.required,
|
|
10
|
-
message: message || `${this.$description.label || this.$description.name} is required
|
|
18
|
+
message: message || `${this.$description.label || this.$description.name} is required`,
|
|
11
19
|
});
|
|
12
20
|
return this;
|
|
13
21
|
};
|
|
14
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {(value: *, allValues?: Record<string, *>) => boolean} validatorFn
|
|
25
|
+
* @param {string} [message]
|
|
26
|
+
* @returns {this}
|
|
27
|
+
*/
|
|
15
28
|
HasValidation.prototype.custom = function(validatorFn, message) {
|
|
16
29
|
this.$description.rules.push({
|
|
17
30
|
validate: validatorFn,
|
|
18
|
-
message: message || 'Validation failed'
|
|
31
|
+
message: message || 'Validation failed',
|
|
19
32
|
});
|
|
20
33
|
return this;
|
|
21
34
|
};
|
|
22
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @param {Function} validationFn
|
|
38
|
+
* @param {*[]} params
|
|
39
|
+
* @param {string} [message]
|
|
40
|
+
* @returns {this}
|
|
41
|
+
*/
|
|
23
42
|
HasValidation.prototype.addRule = function(validationFn, params, message) {
|
|
24
43
|
this.$description.rules.push({
|
|
25
44
|
fn: validationFn,
|
|
26
45
|
params: params || [],
|
|
27
|
-
message
|
|
46
|
+
message,
|
|
28
47
|
});
|
|
29
48
|
return this;
|
|
30
49
|
};
|
|
31
50
|
|
|
51
|
+
/**
|
|
52
|
+
* @param {Observable<boolean>|boolean|string|((v: Record<string, *>) => boolean)} condition
|
|
53
|
+
* @param {string} [message]
|
|
54
|
+
* @returns {this}
|
|
55
|
+
*/
|
|
32
56
|
HasValidation.prototype.requiredIf = function(condition, message) {
|
|
33
57
|
return this.addRule(Validation.requiredIf, [condition], message);
|
|
34
58
|
};
|
|
35
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @param {string} event
|
|
62
|
+
* @returns {this}
|
|
63
|
+
*/
|
|
36
64
|
HasValidation.prototype.clearErrorOn = function(event) {
|
|
37
65
|
this.$description.clearErrorOn = event;
|
|
38
66
|
return this;
|
|
39
67
|
};
|
|
40
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @param {string} event
|
|
71
|
+
* @returns {this}
|
|
72
|
+
*/
|
|
41
73
|
HasValidation.prototype.validateOn = function(event) {
|
|
42
74
|
this.$description.validateOn = event;
|
|
43
75
|
return this;
|
|
44
76
|
};
|
|
45
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @param {boolean|Observable<boolean>} [show=true]
|
|
80
|
+
* @returns {this}
|
|
81
|
+
*/
|
|
46
82
|
HasValidation.prototype.showErrors = function(show = true) {
|
|
47
83
|
this.$description.showErrors = BaseComponent.obs(show);
|
|
48
84
|
return this;
|
|
49
85
|
};
|
|
50
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @returns {this}
|
|
89
|
+
*/
|
|
51
90
|
HasValidation.prototype.hideErrors = function() {
|
|
52
91
|
this.$description.showErrors.set(false);
|
|
53
92
|
return this;
|
|
54
93
|
};
|
|
55
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @param {string|string[]} error
|
|
97
|
+
* @returns {this}
|
|
98
|
+
*/
|
|
56
99
|
HasValidation.prototype.setError = function(error) {
|
|
57
100
|
this.$description.errors?.set?.(error);
|
|
58
101
|
return this;
|
|
59
102
|
};
|
|
60
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @param {Record<string, *>} [allValues={}]
|
|
106
|
+
* @returns {{ key: string, errors: string[] }}
|
|
107
|
+
*/
|
|
61
108
|
HasValidation.prototype.validate = function(allValues = {}) {
|
|
62
109
|
if(!this.$description.rules || this.$description.rules.length === 0) {
|
|
63
110
|
this.$description.errors.clear();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ValidChild, GlobalAttributes, NdStyleMap } from '../../types/elements';
|
|
2
|
+
import type { ObservableItem } from '../../types/observable';
|
|
3
|
+
import type { CssPropertyAccumulator, ClassPropertyAccumulator } from '../../types/property-accumulator';
|
|
4
|
+
|
|
5
|
+
export type EditableProps = Omit<GlobalAttributes, 'class' | 'style'> & {
|
|
6
|
+
class: ClassPropertyAccumulator;
|
|
7
|
+
style: CssPropertyAccumulator;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface BaseComponent {
|
|
11
|
+
setDescription(description: Record<string, unknown>): this;
|
|
12
|
+
postBuild(callback: (element: HTMLElement) => void): this;
|
|
13
|
+
refSelf(target: Record<string, unknown>, name: string): this;
|
|
14
|
+
toNdElement(): HTMLElement | DocumentFragment;
|
|
15
|
+
node(): HTMLElement | DocumentFragment;
|
|
16
|
+
toJSON(): Record<string, unknown>;
|
|
17
|
+
getEditableProps(): EditableProps;
|
|
18
|
+
resolveProps(): GlobalAttributes;
|
|
19
|
+
props(props: GlobalAttributes): this;
|
|
20
|
+
style(style: NdStyleMap): this;
|
|
21
|
+
showIf(condition: boolean | ObservableItem<boolean>): this;
|
|
22
|
+
visibility(condition: boolean | ObservableItem<boolean>): this;
|
|
23
|
+
context(context: unknown): this;
|
|
24
|
+
ghostDom(element: ValidChild): this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare namespace BaseComponent {
|
|
28
|
+
|
|
29
|
+
function use(Component: Function, ...traits: Function[]): void;
|
|
30
|
+
function obs<T>(value: T | ObservableItem<T>): ObservableItem<T>;
|
|
31
|
+
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {classPropertyAccumulator, cssPropertyAccumulator} from
|
|
2
|
-
import {Observable} from
|
|
3
|
-
import {ShowIf} from
|
|
4
|
-
import {NDElement} from
|
|
1
|
+
import {classPropertyAccumulator, cssPropertyAccumulator} from '../core/utils/property-accumulator';
|
|
2
|
+
import {Observable} from '../core/data/Observable';
|
|
3
|
+
import {ShowIf} from '../core/elements/control/show-if';
|
|
4
|
+
import {NDElement} from '../core/wrappers/NDElement';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -28,9 +28,13 @@ Object.defineProperty( BaseComponent.prototype, 'nd', {
|
|
|
28
28
|
nd.$attachements = this.$attachements;
|
|
29
29
|
}
|
|
30
30
|
return nd;
|
|
31
|
-
}
|
|
31
|
+
},
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @param {Function} Component
|
|
36
|
+
* @param {...Function} parents
|
|
37
|
+
*/
|
|
34
38
|
BaseComponent.extends = function(Component, ...parents) {
|
|
35
39
|
const MainParent = parents[0] || BaseComponent;
|
|
36
40
|
Component.prototype = Object.create(MainParent.prototype);
|
|
@@ -55,6 +59,10 @@ BaseComponent.obs = (value) => {
|
|
|
55
59
|
return value.__$Observable ? value : Observable(value);
|
|
56
60
|
};
|
|
57
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @param {Record<string, *>} description
|
|
64
|
+
* @returns {this}
|
|
65
|
+
*/
|
|
58
66
|
BaseComponent.prototype.setDescription = function(description) {
|
|
59
67
|
for(const key in description) {
|
|
60
68
|
if(this.$description[key]?.__$Observable) {
|
|
@@ -64,21 +72,30 @@ BaseComponent.prototype.setDescription = function(description) {
|
|
|
64
72
|
this.$description[key] = description[key];
|
|
65
73
|
}
|
|
66
74
|
return this;
|
|
67
|
-
}
|
|
75
|
+
};
|
|
68
76
|
|
|
69
77
|
BaseComponent.prototype.$storeElement = function(element) {
|
|
70
78
|
this.$element = element;
|
|
71
79
|
return this;
|
|
72
80
|
};
|
|
73
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @param {(element: HTMLElement) => void} callback
|
|
84
|
+
* @returns {this}
|
|
85
|
+
*/
|
|
74
86
|
BaseComponent.prototype.postBuild = function(callback) {
|
|
75
87
|
this.$postBuild = this.$postBuild || [];
|
|
76
88
|
this.$postBuild.push(callback);
|
|
77
89
|
return this;
|
|
78
|
-
}
|
|
90
|
+
};
|
|
79
91
|
|
|
80
92
|
BaseComponent.prototype.ghostDom = NDElement.prototype.ghostDom;
|
|
81
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @param {Record<string, *>} target
|
|
96
|
+
* @param {string} name
|
|
97
|
+
* @returns {this}
|
|
98
|
+
*/
|
|
82
99
|
BaseComponent.prototype.refSelf = function(target, name) {
|
|
83
100
|
target[name] = this;
|
|
84
101
|
return this;
|
|
@@ -98,6 +115,9 @@ BaseComponent.prototype.$build = function() {
|
|
|
98
115
|
return renderer(this.$description, this);
|
|
99
116
|
};
|
|
100
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @returns {HTMLElement|DocumentFragment}
|
|
120
|
+
*/
|
|
101
121
|
BaseComponent.prototype.toNdElement = function() {
|
|
102
122
|
if (this.$element) {
|
|
103
123
|
return this.$element;
|
|
@@ -124,6 +144,9 @@ BaseComponent.prototype.toNdElement = function() {
|
|
|
124
144
|
|
|
125
145
|
BaseComponent.prototype.node = BaseComponent.prototype.toNdElement;
|
|
126
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @returns {Record<string, *>}
|
|
149
|
+
*/
|
|
127
150
|
BaseComponent.prototype.toJSON = function() {
|
|
128
151
|
if(!this.$description) {
|
|
129
152
|
return {};
|
|
@@ -131,6 +154,10 @@ BaseComponent.prototype.toJSON = function() {
|
|
|
131
154
|
return { ...this.$description };
|
|
132
155
|
};
|
|
133
156
|
|
|
157
|
+
/**
|
|
158
|
+
* @param {(description: *, component: *) => NdChild} renderFn
|
|
159
|
+
* @returns {this}
|
|
160
|
+
*/
|
|
134
161
|
BaseComponent.prototype.render = function(renderFn) {
|
|
135
162
|
if (typeof renderFn !== 'function') {
|
|
136
163
|
throw new Error('Custom renderer must be a function');
|
|
@@ -139,19 +166,31 @@ BaseComponent.prototype.render = function(renderFn) {
|
|
|
139
166
|
return this;
|
|
140
167
|
};
|
|
141
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Returns the internal editable props object for this component.
|
|
171
|
+
* The `class` and `style` properties are wrapped in reactive accumulators
|
|
172
|
+
* ({@link ClassPropertyAccumulatorType} and {@link CssPropertyAccumulatorType})
|
|
173
|
+
* instead of plain strings, to allow incremental reactive updates.
|
|
174
|
+
* @returns {Omit<GlobalAttributes, "class"|"style"> & { class: ClassPropertyAccumulatorType, style: CssPropertyAccumulatorType }}
|
|
175
|
+
*/
|
|
142
176
|
BaseComponent.prototype.getEditableProps = function() {
|
|
143
177
|
if(!this.$editableProps) {
|
|
144
178
|
const rawProps = this.$description.props || {};
|
|
145
179
|
this.$editableProps = {
|
|
146
180
|
...rawProps,
|
|
147
181
|
class: classPropertyAccumulator(rawProps.class || {}),
|
|
148
|
-
style: cssPropertyAccumulator(rawProps.style || {})
|
|
182
|
+
style: cssPropertyAccumulator(rawProps.style || {}),
|
|
149
183
|
};
|
|
150
184
|
}
|
|
151
185
|
|
|
152
186
|
return this.$editableProps;
|
|
153
187
|
};
|
|
154
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Returns a plain snapshot of the resolved props, with class and style
|
|
191
|
+
* unwrapped from their reactive accumulators to their current values.
|
|
192
|
+
* @returns {GlobalAttributes}
|
|
193
|
+
*/
|
|
155
194
|
BaseComponent.prototype.resolveProps = function() {
|
|
156
195
|
if(!this.$editableProps) {
|
|
157
196
|
return this.$description.props ? { ...this.$description.props } : {};
|
|
@@ -167,25 +206,42 @@ BaseComponent.prototype.resolveProps = function() {
|
|
|
167
206
|
return props;
|
|
168
207
|
};
|
|
169
208
|
|
|
209
|
+
/**
|
|
210
|
+
* @param {GlobalAttributes} props
|
|
211
|
+
* @returns {this}
|
|
212
|
+
*/
|
|
170
213
|
BaseComponent.prototype.props = function(props) {
|
|
171
214
|
this.$description.props = props;
|
|
172
215
|
return this;
|
|
173
216
|
};
|
|
174
217
|
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @param {NdStyleMap} style
|
|
221
|
+
* @returns {this}
|
|
222
|
+
*/
|
|
175
223
|
BaseComponent.prototype.style = function(style) {
|
|
176
224
|
const props = this.getEditableProps();
|
|
177
225
|
props.style.add(style);
|
|
178
226
|
return this;
|
|
179
227
|
};
|
|
180
228
|
|
|
229
|
+
/**
|
|
230
|
+
* @param {boolean|Observable<boolean>} condition
|
|
231
|
+
* @returns {this}
|
|
232
|
+
*/
|
|
181
233
|
BaseComponent.prototype.showIf = function(condition) {
|
|
182
234
|
this.$description.showIf = BaseComponent.obs(condition);
|
|
183
235
|
return this;
|
|
184
236
|
};
|
|
185
237
|
|
|
238
|
+
/**
|
|
239
|
+
* @param {*} context
|
|
240
|
+
* @returns {this}
|
|
241
|
+
*/
|
|
186
242
|
BaseComponent.prototype.context = function(context) {
|
|
187
243
|
this.$description.$context = context;
|
|
188
244
|
return this;
|
|
189
|
-
}
|
|
245
|
+
};
|
|
190
246
|
|
|
191
247
|
BaseComponent.prototype.visibility = BaseComponent.prototype.showIf;
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import BaseComponent from
|
|
2
|
-
import HasEventEmitter from
|
|
3
|
-
import AccordionItem from
|
|
4
|
-
|
|
1
|
+
import BaseComponent from '../BaseComponent';
|
|
2
|
+
import HasEventEmitter from '../../core/utils/HasEventEmitter';
|
|
3
|
+
import AccordionItem from './AccordionItem';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
6
|
+
* Collapsible accordion component. Manages a list of AccordionItem instances with expand/collapse behaviour.
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const accordion = new Accordion()
|
|
11
|
+
* .item('Section 1', Div('Content of section 1'))
|
|
12
|
+
* .item('Section 2', Div('Content of section 2'))
|
|
13
|
+
* .multiple(true)
|
|
14
|
+
* .variant('bordered');
|
|
15
|
+
*
|
|
16
|
+
* Accordion.use((description, instance) => {
|
|
17
|
+
* // description.$items, description.multiple, description.variant...
|
|
18
|
+
* return Div({ class: 'my-accordion' }, description.items);
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* @constructor
|
|
22
|
+
* @param {GlobalAttributes} [props]
|
|
16
23
|
*/
|
|
17
24
|
export default function Accordion(props = {}) {
|
|
18
25
|
if (!(this instanceof Accordion)) {
|
|
@@ -27,7 +34,7 @@ export default function Accordion(props = {}) {
|
|
|
27
34
|
variant: null,
|
|
28
35
|
renderContent: null,
|
|
29
36
|
renderIndicator: null,
|
|
30
|
-
props
|
|
37
|
+
props,
|
|
31
38
|
};
|
|
32
39
|
}
|
|
33
40
|
|
|
@@ -35,11 +42,29 @@ BaseComponent.extends(Accordion);
|
|
|
35
42
|
BaseComponent.use(Accordion, HasEventEmitter);
|
|
36
43
|
|
|
37
44
|
Accordion.defaultTemplate = null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Registers the render template for Accordion.
|
|
48
|
+
* @param {(description: {
|
|
49
|
+
* items: AccordionItem[],
|
|
50
|
+
* multiple: boolean|null,
|
|
51
|
+
* variant: string|null,
|
|
52
|
+
* renderContent: ((desc: *, instance: Accordion) => NdChild)|null,
|
|
53
|
+
* renderIndicator: ((desc: *, instance: Accordion) => NdChild)|null,
|
|
54
|
+
* props: GlobalAttributes,
|
|
55
|
+
* }, instance: Accordion) => NdChild} template
|
|
56
|
+
*/
|
|
38
57
|
Accordion.use = function(template) {
|
|
39
58
|
Accordion.defaultTemplate = template;
|
|
40
59
|
};
|
|
41
60
|
|
|
42
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @param {NdChild|AccordionItem} title
|
|
64
|
+
* @param {NdChild} [content]
|
|
65
|
+
* @param {GlobalAttributes|((item: AccordionItem) => void)} [options]
|
|
66
|
+
* @returns {this}
|
|
67
|
+
*/
|
|
43
68
|
Accordion.prototype.item = function(title, content, options) {
|
|
44
69
|
let item = null;
|
|
45
70
|
|