native-document 1.0.138 → 1.0.140
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.js +1 -1
- package/devtools/ComponentRegistry.js +3 -2
- package/dist/native-document.components.min.css +1 -0
- package/dist/native-document.components.min.js +11506 -8566
- package/dist/native-document.dev.js +2645 -2166
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/index.js +1 -0
- package/package.json +5 -2
- package/rollup.config.js +5 -2
- package/src/components/$traits/has-draggable/HasDraggable.js +69 -0
- package/src/components/$traits/has-draggable/has-draggable.css +8 -0
- package/src/components/$traits/{HasItems.js → has-items/HasItems.js} +2 -11
- package/src/components/$traits/has-position/HasFullPosition.js +51 -0
- package/src/components/$traits/has-position/HasPosition.js +23 -0
- package/src/components/$traits/has-resizable/HasResizable.js +113 -0
- package/src/components/$traits/has-resizable/has-resizable.css +121 -0
- package/src/components/$traits/has-validation/HasValidation.js +86 -0
- package/src/components/BaseComponent.js +109 -4
- package/src/components/accordion/Accordion.js +37 -31
- package/src/components/accordion/AccordionItem.js +14 -21
- package/src/components/alert/Alert.js +48 -40
- package/src/components/avatar/Avatar.js +4 -3
- package/src/components/avatar/AvatarGroup.js +8 -2
- package/src/components/badge/Badge.js +7 -7
- package/src/components/base-component.css +0 -0
- package/src/components/breadcrumb/BreadCrumb.js +30 -21
- package/src/components/button/Button.js +3 -14
- package/src/components/context-menu/ContextMenu.js +49 -26
- package/src/components/dropdown/Dropdown.js +172 -34
- package/src/components/dropdown/DropdownDivider.js +4 -3
- package/src/components/dropdown/DropdownGroup.js +19 -19
- package/src/components/dropdown/DropdownItem.js +24 -18
- package/src/components/dropdown/helpers.js +52 -0
- package/src/components/form/FormControl.js +207 -108
- package/src/components/form/field/Field.js +106 -174
- package/src/components/form/field/FieldCollection.js +110 -203
- package/src/components/form/field/types/AutocompleteField.js +26 -5
- package/src/components/form/field/types/CheckboxField.js +4 -4
- package/src/components/form/field/types/CheckboxGroupField.js +11 -5
- package/src/components/form/field/types/ColorField.js +4 -4
- package/src/components/form/field/types/DateField.js +110 -18
- package/src/components/form/field/types/EmailField.js +2 -2
- package/src/components/form/field/types/FileField.js +87 -21
- package/src/components/form/field/types/HiddenField.js +4 -4
- package/src/components/form/field/types/ImageField.js +4 -4
- package/src/components/form/field/types/NumberField.js +5 -5
- package/src/components/form/field/types/PasswordField.js +28 -6
- package/src/components/form/field/types/RadioField.js +12 -8
- package/src/components/form/field/types/RangeField.js +29 -5
- package/src/components/form/field/types/SearchField.js +4 -4
- package/src/components/form/field/types/SelectField.js +75 -8
- package/src/components/form/field/types/StringField.js +4 -4
- package/src/components/form/field/types/TelField.js +4 -4
- package/src/components/form/field/types/TextAreaField.js +7 -5
- package/src/components/form/field/types/TimeField.js +52 -6
- package/src/components/form/field/types/UrlField.js +4 -5
- package/src/components/form/field/types/file-field-mode/FileAvatarMode.js +104 -0
- package/src/components/form/field/types/file-field-mode/FileDropzoneMode.js +59 -0
- package/src/components/form/field/types/file-field-mode/FileItemPreview.js +74 -0
- package/src/components/form/field/types/file-field-mode/FileNativeMode.js +21 -0
- package/src/components/form/field/types/file-field-mode/FileUploadButtonMode.js +59 -0
- package/src/components/form/field/types/file-field-mode/FileWallMode.js +53 -0
- package/src/components/form/index.js +14 -2
- package/src/components/form/validation/Validation.js +9 -0
- package/src/components/list/List.js +1 -1
- package/src/components/list/ListGroup.js +1 -1
- package/src/components/menu/HasMenuItem.js +133 -0
- package/src/components/menu/Menu.js +47 -56
- package/src/components/menu/MenuGroup.js +36 -8
- package/src/components/menu/MenuItem.js +24 -10
- package/src/components/menu/MenuLink.js +2 -0
- package/src/components/modal/Modal.js +153 -23
- package/src/components/pagination/Pagination.js +55 -21
- package/src/components/popover/Popover.js +127 -40
- package/src/components/progress/Progress.js +14 -24
- package/src/components/skeleton/Skeleton.js +36 -13
- package/src/components/slider/Slider.js +96 -70
- package/src/components/spinner/Spinner.js +4 -2
- package/src/components/splitter/Splitter.js +15 -8
- package/src/components/splitter/SplitterGutter.js +28 -7
- package/src/components/splitter/SplitterPanel.js +9 -15
- package/src/components/splitter/index.js +3 -1
- package/src/components/stacks/AbsoluteStack.js +33 -0
- package/src/components/stacks/FixedStack.js +33 -0
- package/src/components/stacks/PositionStack.js +146 -0
- package/src/components/stacks/RelativeStack.js +33 -0
- package/src/components/{layouts → stacks}/Stack.js +22 -3
- package/src/components/{layouts → stacks}/index.js +6 -4
- package/src/components/stepper/Stepper.js +159 -67
- package/src/components/stepper/StepperStep.js +49 -12
- package/src/components/switch/Switch.js +59 -29
- package/src/components/switch/index.js +6 -0
- package/src/components/table/Column.js +22 -26
- package/src/components/table/ColumnGroup.js +4 -13
- package/src/components/table/DataTable.js +388 -103
- package/src/components/table/SimpleTable.js +28 -143
- package/src/components/tabs/Tabs.js +142 -44
- package/src/components/toast/Toast.js +40 -35
- package/src/components/tooltip/Tooltip.js +152 -35
- package/src/core/data/ObservableArray.js +94 -30
- package/src/core/data/ObservableChecker.js +20 -75
- package/src/core/data/ObservableItem.js +35 -3
- package/src/core/data/observable-helpers/computed.js +2 -1
- package/src/core/data/observable-helpers/object.js +13 -8
- package/src/core/data/observable-helpers/observable.is-to.js +196 -0
- package/src/core/elements/anchor/anchor.js +3 -2
- package/src/core/elements/control/for-each-array.js +44 -30
- package/src/core/elements/control/for-each.js +6 -3
- package/src/core/elements/control/show-if.js +11 -6
- package/src/core/elements/control/switch.js +2 -1
- package/src/core/elements/index.js +1 -1
- package/src/core/elements/svg.js +61 -0
- package/src/core/utils/HasEventEmitter.js +6 -0
- package/src/core/utils/debug-manager.js +2 -5
- package/src/core/utils/filters/standard.js +2 -1
- package/src/core/utils/property-accumulator.js +35 -6
- package/src/core/utils/shortcut-manager.js +242 -0
- package/src/core/utils/validator.js +1 -1
- package/src/core/wrappers/AttributesWrapper.js +41 -4
- package/src/core/wrappers/DocumentObserver.js +0 -1
- package/src/core/wrappers/HtmlElementWrapper.js +1 -1
- package/src/core/wrappers/NDElement.js +15 -2
- package/src/core/wrappers/SvgElementWrapper.js +15 -0
- package/src/core/wrappers/prototypes/attributes-extensions.js +4 -1
- package/src/core/wrappers/prototypes/nd-element-extensions.js +8 -1
- package/src/router/Router.js +0 -1
- package/src/ui/components/accordion/AccordionItemRender.js +63 -0
- package/src/ui/components/accordion/AccordionRender.js +34 -0
- package/src/ui/components/accordion/accordion.css +121 -0
- package/src/ui/components/alert/AlertRender.js +80 -0
- package/src/ui/components/alert/alert.css +163 -0
- package/src/ui/components/avatar/avata-group/AvatarGroupRender.js +49 -0
- package/src/ui/components/avatar/avata-group/avatar-group.css +38 -0
- package/src/ui/components/avatar/avatar/AvatarRender.js +87 -0
- package/src/ui/components/avatar/avatar/avatar.css +189 -0
- package/src/ui/components/badge/BadgeRender.js +24 -0
- package/src/ui/components/badge/badge.css +168 -0
- package/src/ui/components/breadcrumb/BreadcrumbRender.js +43 -0
- package/src/ui/components/breadcrumb/breadcrumb.css +55 -0
- package/src/ui/components/button/ButtonRender.js +65 -0
- package/src/ui/components/button/button.css +288 -354
- package/src/ui/components/contextmenu/ContextmenuRender.js +70 -0
- package/src/ui/components/contextmenu/contextmenu.css +36 -0
- package/src/ui/components/divider/DividerRender.js +70 -0
- package/src/ui/components/divider/divider.css +70 -0
- package/src/ui/components/dropdown/DropdownRender.js +92 -0
- package/src/ui/components/dropdown/divider/DropdownDividerRender.js +9 -0
- package/src/ui/components/dropdown/divider/dropdown-divider.css +0 -0
- package/src/ui/components/dropdown/dropdown.css +179 -0
- package/src/ui/components/dropdown/group/DropdownGroupRender.js +23 -0
- package/src/ui/components/dropdown/group/dropdown-group.css +0 -0
- package/src/ui/components/dropdown/item/DropdownItemRender.js +29 -0
- package/src/ui/components/dropdown/item/dropdown-item.css +0 -0
- package/src/ui/components/form/FieldCollectionRender.js +110 -0
- package/src/ui/components/form/FormControlRender.js +84 -0
- package/src/ui/components/form/field-collection.css +55 -0
- package/src/ui/components/form/fields/AutocompleteFieldRender.js +143 -0
- package/src/ui/components/form/fields/CheckboxFieldRender.js +59 -0
- package/src/ui/components/form/fields/CheckboxGroupFieldRender.js +92 -0
- package/src/ui/components/form/fields/ColorFieldRender.js +30 -0
- package/src/ui/components/form/fields/DateFieldRender.js +154 -0
- package/src/ui/components/form/fields/EmailFieldRender.js +5 -0
- package/src/ui/components/form/fields/FieldRender.js +117 -0
- package/src/ui/components/form/fields/FileFieldRender.js +41 -0
- package/src/ui/components/form/fields/HiddenFieldRender.js +14 -0
- package/src/ui/components/form/fields/ImageFieldRender.js +0 -0
- package/src/ui/components/form/fields/NumberFieldRender.js +52 -0
- package/src/ui/components/form/fields/PasswordFieldRender.js +65 -0
- package/src/ui/components/form/fields/RadioFieldRender.js +77 -0
- package/src/ui/components/form/fields/RangeFieldRender.js +121 -0
- package/src/ui/components/form/fields/SelectFieldRender.js +248 -0
- package/src/ui/components/form/fields/SliderFieldRender.js +359 -0
- package/src/ui/components/form/fields/StringFieldRender.js +6 -0
- package/src/ui/components/form/fields/TelFieldRender.js +6 -0
- package/src/ui/components/form/fields/TextAreaFieldRender.js +96 -0
- package/src/ui/components/form/fields/TimeFieldRender.js +141 -0
- package/src/ui/components/form/fields/UrlFieldRender.js +6 -0
- package/src/ui/components/form/fields/date-field.css +32 -0
- package/src/ui/components/form/fields/field.css +402 -0
- package/src/ui/components/form/fields/file-field.css +79 -0
- package/src/ui/components/form/fields/password-field.css +50 -0
- package/src/ui/components/form/fields/range-field.css +120 -0
- package/src/ui/components/form/fields/slider.css +195 -0
- package/src/ui/components/form/file-upload-mode/FileAvatarModeRender.js +143 -0
- package/src/ui/components/form/file-upload-mode/FileDropzoneModeRender.js +108 -0
- package/src/ui/components/form/file-upload-mode/FileNativeModeRender.js +22 -0
- package/src/ui/components/form/file-upload-mode/FileUploadButtonModeRender.js +89 -0
- package/src/ui/components/form/file-upload-mode/FileWallModeRender.js +91 -0
- package/src/ui/components/form/file-upload-mode/file-avatar-mode.css +139 -0
- package/src/ui/components/form/file-upload-mode/file-dropzone-mode.css +88 -0
- package/src/ui/components/form/file-upload-mode/file-upload-button-mode.css +44 -0
- package/src/ui/components/form/file-upload-mode/file-wall-mode.css +88 -0
- package/src/ui/components/form/form-control.css +40 -0
- package/src/ui/components/form/helpers.js +112 -0
- package/src/ui/components/form/index.js +61 -0
- package/src/ui/components/menu/MenuDividerRender.js +12 -0
- package/src/ui/components/menu/MenuGroupRender.js +60 -0
- package/src/ui/components/menu/MenuItemRender.js +57 -0
- package/src/ui/components/menu/MenuLinkRender.js +55 -0
- package/src/ui/components/menu/MenuRender.js +21 -0
- package/src/ui/components/menu/helpers.js +121 -0
- package/src/ui/components/menu/menu.css +308 -0
- package/src/ui/components/modal/ModalRender.js +119 -0
- package/src/ui/components/modal/modal.css +156 -0
- package/src/ui/components/pagination/PaginationRender.js +112 -0
- package/src/ui/components/pagination/pagination.css +63 -0
- package/src/ui/components/popover/PopoverRender.js +234 -0
- package/src/ui/components/popover/popover.css +139 -0
- package/src/ui/components/progress/ProgressRender.js +168 -0
- package/src/ui/components/progress/progress.css +197 -0
- package/src/ui/components/skeleton/SkeletonRender.js +79 -0
- package/src/ui/components/skeleton/skeleton.css +154 -0
- package/src/ui/components/spinner/SpinnerRender.js +46 -0
- package/src/ui/components/spinner/spinner.css +152 -0
- package/src/ui/components/splitter/SplitterGutterRender.js +94 -0
- package/src/ui/components/splitter/SplitterPanelRender.js +38 -0
- package/src/ui/components/splitter/SplitterRender.js +74 -0
- package/src/ui/components/splitter/splitter.css +128 -0
- package/src/ui/components/stacks/PositionStackRender.js +38 -0
- package/src/ui/components/stacks/StackRender.js +42 -0
- package/src/ui/components/stacks/absolute-stack/AbsoluteStackRender.js +5 -0
- package/src/ui/components/stacks/fixed-stack/FixedStackRender.js +5 -0
- package/src/ui/components/stacks/h-stack/HStackRender.js +7 -0
- package/src/ui/components/stacks/h-stack/h-stack.css +4 -0
- package/src/ui/components/stacks/index.js +15 -0
- package/src/ui/components/stacks/position-stack.css +62 -0
- package/src/ui/components/stacks/relative-stack/RelativeStackRender.js +7 -0
- package/src/ui/components/stacks/relative-stack/relative-stack.css +3 -0
- package/src/ui/components/stacks/stack.css +78 -0
- package/src/ui/components/stacks/v-stack/VStackRender.js +5 -0
- package/src/ui/components/stacks/v-stack/v-stack.css +4 -0
- package/src/ui/components/stepper/StepperRender.js +70 -0
- package/src/ui/components/stepper/StepperStepRender.js +67 -0
- package/src/ui/components/stepper/stepper.css +359 -0
- package/src/ui/components/switch/SwitchRender.js +82 -0
- package/src/ui/components/switch/switch.css +143 -0
- package/src/ui/components/table/data-table/DataTableRender.js +49 -0
- package/src/ui/components/table/data-table/bulk-actions.js +35 -0
- package/src/ui/components/table/data-table/data-table.css +246 -0
- package/src/ui/components/table/data-table/pagination.js +56 -0
- package/src/ui/components/table/data-table/tables.js +363 -0
- package/src/ui/components/table/data-table/toolbar.js +67 -0
- package/src/ui/components/table/simple-table/SimpleTableRender.js +188 -0
- package/src/ui/components/table/simple-table/simple-table.css +50 -0
- package/src/ui/components/tabs/TabsRender.js +226 -0
- package/src/ui/components/tabs/tabs.css +253 -0
- package/src/ui/components/toast/ToastRender.js +98 -0
- package/src/ui/components/toast/toast.css +201 -0
- package/src/ui/components/tooltip/TooltipRender.js +8 -0
- package/src/ui/components/tooltip/tooltip.css +113 -0
- package/src/ui/index.js +82 -0
- package/src/ui/tokens/colors-dark.scss +2 -1
- package/src/ui/tokens/reset.scss +3 -0
- package/types/control-flow.d.ts +2 -2
- package/src/components/layouts/ZStack.js +0 -41
- package/src/ui/components/button/button.render.js +0 -63
- /package/src/components/{layouts → stacks}/HStack.js +0 -0
- /package/src/components/{layouts → stacks}/VStack.js +0 -0
|
@@ -20,8 +20,13 @@ import ImageField from "./field/types/ImageField";
|
|
|
20
20
|
import CheckboxGroupField from "./field/types/CheckboxGroupField";
|
|
21
21
|
import AutocompleteField from "./field/types/AutocompleteField";
|
|
22
22
|
import FieldCollection from "./field/FieldCollection";
|
|
23
|
+
import FileNativeMode from "./field/types/file-field-mode/FileNativeMode";
|
|
24
|
+
import FileDropzoneMode from "./field/types/file-field-mode/FileDropzoneMode";
|
|
25
|
+
import FileUploadButtonMode from "./field/types/file-field-mode/FileUploadButtonMode";
|
|
26
|
+
import FileWallMode from "./field/types/file-field-mode/FileWallMode";
|
|
27
|
+
import FileAvatarMode from "./field/types/file-field-mode/FileAvatarMode";
|
|
23
28
|
|
|
24
|
-
import './field/FieldFactory';
|
|
29
|
+
// import './field/FieldFactory';
|
|
25
30
|
|
|
26
31
|
export {
|
|
27
32
|
Field,
|
|
@@ -45,5 +50,12 @@ export {
|
|
|
45
50
|
ImageField,
|
|
46
51
|
CheckboxGroupField,
|
|
47
52
|
AutocompleteField,
|
|
48
|
-
FieldCollection
|
|
53
|
+
FieldCollection,
|
|
54
|
+
|
|
55
|
+
FileNativeMode,
|
|
56
|
+
FileAvatarMode,
|
|
57
|
+
FileWallMode,
|
|
58
|
+
FileUploadButtonMode,
|
|
59
|
+
FileDropzoneMode,
|
|
60
|
+
|
|
49
61
|
}
|
|
@@ -288,6 +288,15 @@ export const Validation = {
|
|
|
288
288
|
message: `Date must be between ${start.toLocaleDateString()} and ${end.toLocaleDateString()}`
|
|
289
289
|
};
|
|
290
290
|
},
|
|
291
|
+
weekday(value) {
|
|
292
|
+
if(!value) return {valid: true};
|
|
293
|
+
const day = new Date(value).getDay();
|
|
294
|
+
const valid = day !== 0 && day !== 6;
|
|
295
|
+
return {
|
|
296
|
+
valid,
|
|
297
|
+
message: 'Date must be a weekday'
|
|
298
|
+
};
|
|
299
|
+
},
|
|
291
300
|
|
|
292
301
|
afterTime(value, afterTime) {
|
|
293
302
|
if (!value) return { valid: true };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import BaseComponent from "../BaseComponent";
|
|
3
3
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
4
|
-
import HasItems from "../$traits/HasItems";
|
|
4
|
+
import HasItems from "../$traits/has-items/HasItems";
|
|
5
5
|
import Dropdown from "../dropdown/Dropdown";
|
|
6
6
|
|
|
7
7
|
export default function List(config = {}) {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import MenuDivider from "./MenuDivider";
|
|
2
|
+
|
|
3
|
+
const EMPTY_OPTIONS = {};
|
|
4
|
+
|
|
5
|
+
export default function HasMenuItem() {}
|
|
6
|
+
|
|
7
|
+
HasMenuItem.prototype.setParent = function(parent) {
|
|
8
|
+
this.$parent = parent;
|
|
9
|
+
return this;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
HasMenuItem.components = {
|
|
13
|
+
MenuItem: null,
|
|
14
|
+
MenuLink: null
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getParams = (options, configBuilder, props) => {
|
|
18
|
+
if(!options && !configBuilder && !props) {
|
|
19
|
+
return { options: EMPTY_OPTIONS, configBuilder: null, props: null };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if(typeof options === 'function') {
|
|
23
|
+
props = configBuilder || EMPTY_OPTIONS;
|
|
24
|
+
configBuilder = options;
|
|
25
|
+
options = EMPTY_OPTIONS;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { options, configBuilder, props }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
HasMenuItem.prototype.link = function(label, ...args) {
|
|
32
|
+
const { options, configBuilder, props } = getParams(...args);
|
|
33
|
+
const MenuLink = HasMenuItem.components.MenuLink;
|
|
34
|
+
const item = MenuLink(props);
|
|
35
|
+
this.add(item);
|
|
36
|
+
|
|
37
|
+
item.icon(options.icon)
|
|
38
|
+
.label(label)
|
|
39
|
+
.action(options.href)
|
|
40
|
+
.shortcut(options.shortcut)
|
|
41
|
+
.target(options.target);
|
|
42
|
+
if(options.disabled !== undefined) {
|
|
43
|
+
item.disabled(options.disabled);
|
|
44
|
+
}
|
|
45
|
+
if(typeof configBuilder === 'function') {
|
|
46
|
+
configBuilder(item);
|
|
47
|
+
}
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
HasMenuItem.prototype.linkTo = function(label, ...args) {
|
|
52
|
+
const { options, configBuilder, props } = getParams(...args);
|
|
53
|
+
return this.link(label, { ...options, href: {isRoute: true, to: options.href} }, configBuilder, props);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
HasMenuItem.prototype.item = function(label, ...args) {
|
|
59
|
+
const { options, configBuilder, props } = getParams(...args);
|
|
60
|
+
const MenuItem = HasMenuItem.components.MenuItem;
|
|
61
|
+
const item = MenuItem(props);
|
|
62
|
+
this.add(item);
|
|
63
|
+
|
|
64
|
+
item.icon(options.icon)
|
|
65
|
+
.label(label)
|
|
66
|
+
.action(options.action)
|
|
67
|
+
.shortcut(options.shortcut);
|
|
68
|
+
if(options.disabled !== undefined) {
|
|
69
|
+
item.disabled(options.disabled);
|
|
70
|
+
}
|
|
71
|
+
if(typeof configBuilder === 'function') {
|
|
72
|
+
configBuilder(item);
|
|
73
|
+
}
|
|
74
|
+
return this;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
HasMenuItem.prototype.group = function(label, builder) {
|
|
78
|
+
const MenuGroup = HasMenuItem.components.MenuGroup;
|
|
79
|
+
const group = new MenuGroup(label);
|
|
80
|
+
builder && builder(group);
|
|
81
|
+
return this.add(group);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
HasMenuItem.prototype.separator = function() {
|
|
85
|
+
return this.add(new MenuDivider());
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
HasMenuItem.prototype.divider = HasMenuItem.prototype.separator;
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
HasMenuItem.prototype.add = function(item) {
|
|
93
|
+
if(item === this) {
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
if(this.$description.orientation === 'inline') {
|
|
97
|
+
item.$description.orientation = 'inline';
|
|
98
|
+
}
|
|
99
|
+
item.$description.dataResolver = this.$description.dataResolver;
|
|
100
|
+
item.$parent = this;
|
|
101
|
+
this.$description.items.push(item);
|
|
102
|
+
return this;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
HasMenuItem.prototype.getDepth = function() {
|
|
106
|
+
let depth = 0;
|
|
107
|
+
let current = this.$parent;
|
|
108
|
+
|
|
109
|
+
while (current) {
|
|
110
|
+
depth++;
|
|
111
|
+
current = current.$parent;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return depth;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
HasMenuItem.prototype.onClicked = function() {
|
|
118
|
+
this.$description.interaction = 'click';
|
|
119
|
+
return this;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
HasMenuItem.prototype.onHovered = function() {
|
|
123
|
+
this.$description.interaction = 'hover';
|
|
124
|
+
return this;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
HasMenuItem.prototype.getRoot = function() {
|
|
128
|
+
let current = this;
|
|
129
|
+
while(current.$parent) {
|
|
130
|
+
current = current.$parent;
|
|
131
|
+
}
|
|
132
|
+
return current;
|
|
133
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
3
|
-
import HasItems from "../$traits/HasItems";
|
|
4
|
-
import MenuDivider from "./MenuDivider";
|
|
3
|
+
import HasItems from "../$traits/has-items/HasItems";
|
|
5
4
|
import MenuGroup from "./MenuGroup";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import HasMenuItem from "./HasMenuItem";
|
|
6
|
+
import { $ } from '../../../index'
|
|
8
7
|
|
|
9
8
|
export default function Menu(props = {}) {
|
|
10
9
|
|
|
@@ -12,20 +11,28 @@ export default function Menu(props = {}) {
|
|
|
12
11
|
return new Menu(props)
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
BaseComponent.call(this, props);
|
|
15
|
+
|
|
15
16
|
this.$description = {
|
|
16
|
-
items:
|
|
17
|
+
items: $.array(),
|
|
17
18
|
render: null,
|
|
18
19
|
orientation: 'horizontal',
|
|
19
20
|
closeOnSelect: true,
|
|
20
21
|
keyboardLoop: true,
|
|
22
|
+
activeItem: $(null),
|
|
21
23
|
active: null,
|
|
24
|
+
compactThreshold: 60,
|
|
25
|
+
clickFirst: false,
|
|
26
|
+
menuActive: $(null),
|
|
27
|
+
isMenuActivated: $(false),
|
|
28
|
+
compact: $(null),
|
|
22
29
|
props
|
|
23
30
|
};
|
|
24
31
|
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
BaseComponent.extends(Menu);
|
|
28
|
-
BaseComponent.use(Menu, HasItems, HasEventEmitter);
|
|
35
|
+
BaseComponent.use(Menu, HasItems, HasEventEmitter, HasMenuItem);
|
|
29
36
|
|
|
30
37
|
Menu.defaultTemplate = null;
|
|
31
38
|
|
|
@@ -33,10 +40,22 @@ Menu.use = function(template) {
|
|
|
33
40
|
Menu.defaultTemplate = template;
|
|
34
41
|
};
|
|
35
42
|
|
|
36
|
-
Menu.prototype
|
|
37
|
-
|
|
43
|
+
// Menu.prototype.$originalBuild = Menu.prototype.$build;
|
|
44
|
+
// Menu.prototype.$build = function() {
|
|
45
|
+
// const activeSource = (typeof this.$description.active === 'function') ? this.$description.active() : this.$description.active;
|
|
46
|
+
// if(activeSource.__$Observable) {
|
|
47
|
+
// activeSource.subscribe((a) => {
|
|
48
|
+
// console.log('Subscribe', a);
|
|
49
|
+
// // Todo: update active element
|
|
50
|
+
// });
|
|
51
|
+
// }
|
|
52
|
+
// return this.$originalBuild();
|
|
53
|
+
// };
|
|
54
|
+
|
|
55
|
+
Menu.prototype.dataResolver = function(resolver) {
|
|
56
|
+
this.$description.dataResolver = resolver;
|
|
38
57
|
return this;
|
|
39
|
-
}
|
|
58
|
+
};
|
|
40
59
|
|
|
41
60
|
Menu.prototype.title = function(title) {
|
|
42
61
|
this.$description.title = title;
|
|
@@ -58,6 +77,11 @@ Menu.prototype.vertical = function() {
|
|
|
58
77
|
return this;
|
|
59
78
|
};
|
|
60
79
|
|
|
80
|
+
Menu.prototype.inline = function() {
|
|
81
|
+
this.$description.orientation = 'inline';
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
|
|
61
85
|
Menu.prototype.closeOnSelect = function(close = true) {
|
|
62
86
|
this.$description.closeOnSelect = close;
|
|
63
87
|
return this;
|
|
@@ -88,58 +112,25 @@ Menu.prototype.onItemSelect = function(handler) {
|
|
|
88
112
|
return this;
|
|
89
113
|
};
|
|
90
114
|
|
|
91
|
-
Menu.prototype.
|
|
92
|
-
|
|
115
|
+
Menu.prototype.group = function(label, icon, builder, props = {}) {
|
|
116
|
+
const group = new MenuGroup(label, props);
|
|
117
|
+
group.icon(icon);
|
|
118
|
+
builder && builder(group);
|
|
119
|
+
return this.add(group);
|
|
93
120
|
};
|
|
94
121
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* @param {?NdChild} icon - The item to add
|
|
100
|
-
* @param {?Function} action - The item to add
|
|
101
|
-
* @param {?Function} configBuilder - The item to add
|
|
102
|
-
* @param {?*} props - The item to add
|
|
103
|
-
* @returns {HasItems}
|
|
104
|
-
*/
|
|
105
|
-
Menu.prototype.item = function(label, icon, action, configBuilder, props = {}) {
|
|
106
|
-
const item = MenuItem();
|
|
107
|
-
item.icon(icon).label(label).onClick(action);
|
|
108
|
-
if(typeof configBuilder === 'function') {
|
|
109
|
-
configBuilder.length ? configBuilder(item) : this.trailing(item);
|
|
110
|
-
} else if(configBuilder) {
|
|
111
|
-
this.trailing(item);
|
|
112
|
-
}
|
|
113
|
-
this.$description.items.push(item);
|
|
114
|
-
return this;
|
|
122
|
+
Menu.prototype.getItem = function(key) {
|
|
123
|
+
return this.$description.items.find(
|
|
124
|
+
item => item.$description.key === key || item.$description.label === key
|
|
125
|
+
);
|
|
115
126
|
};
|
|
116
127
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
* @param {NdChild} label - The item to add
|
|
120
|
-
* @param {?NdChild} icon - The item to add
|
|
121
|
-
* @param {?string|{to: string, params: ?*}} url - The item to add
|
|
122
|
-
* @param {?Function} configBuilder - The item to add
|
|
123
|
-
* @param {?*} props - The item to add
|
|
124
|
-
* @returns {HasItems}
|
|
125
|
-
*/
|
|
126
|
-
Menu.prototype.link = function(label, icon, url, configBuilder, props = {}) {
|
|
127
|
-
const item = MenuLink(props);
|
|
128
|
-
item.icon(icon).label(label).action(url)
|
|
129
|
-
if(typeof configBuilder === 'function') {
|
|
130
|
-
configBuilder.length ? configBuilder(item) : this.trailing(item);
|
|
131
|
-
} else if(configBuilder) {
|
|
132
|
-
this.trailing(item);
|
|
133
|
-
}
|
|
134
|
-
this.$description.items.push(item);
|
|
128
|
+
Menu.prototype.compactThreshold = function(width = 60) {
|
|
129
|
+
this.$description.compactThreshold = width;
|
|
135
130
|
return this;
|
|
136
131
|
};
|
|
137
132
|
|
|
138
|
-
Menu.prototype.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const group = new MenuGroup(label, props);
|
|
142
|
-
group.icon(icon);
|
|
143
|
-
builder && builder(group);
|
|
144
|
-
return this.add(group);
|
|
133
|
+
Menu.prototype.clickFirst = function(mode = true) {
|
|
134
|
+
this.$description.clickFirst = mode;
|
|
135
|
+
return this;
|
|
145
136
|
};
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
|
-
import HasItems from "../$traits/HasItems";
|
|
2
|
+
import HasItems from "../$traits/has-items/HasItems";
|
|
3
3
|
import MenuDivider from "./MenuDivider";
|
|
4
|
+
import HasMenuItem from "./HasMenuItem";
|
|
5
|
+
import { $ } from '../../../index';
|
|
4
6
|
|
|
5
7
|
|
|
6
|
-
export default function MenuGroup(label, props) {
|
|
8
|
+
export default function MenuGroup(label, props = {}) {
|
|
7
9
|
if(!(this instanceof MenuGroup)) {
|
|
8
10
|
return new MenuGroup(label, props);
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
BaseComponent.call(this, props);
|
|
14
|
+
|
|
11
15
|
this.$description = {
|
|
16
|
+
icon: null,
|
|
12
17
|
label,
|
|
13
18
|
data: null,
|
|
14
|
-
items:
|
|
19
|
+
items: $.array(),
|
|
15
20
|
render: null,
|
|
21
|
+
collapsable: false,
|
|
22
|
+
collapsed: null,
|
|
23
|
+
visibility: $(true),
|
|
24
|
+
collapsableOpenedIcon: null,
|
|
25
|
+
collapsableClosedIcon: null,
|
|
16
26
|
props
|
|
17
27
|
};
|
|
18
28
|
}
|
|
19
29
|
|
|
30
|
+
HasMenuItem.components.MenuGroup = MenuGroup;
|
|
31
|
+
|
|
20
32
|
MenuGroup.defaultTemplate = null;
|
|
21
33
|
|
|
22
34
|
MenuGroup.use = function(template) {
|
|
@@ -24,20 +36,36 @@ MenuGroup.use = function(template) {
|
|
|
24
36
|
};
|
|
25
37
|
|
|
26
38
|
BaseComponent.extends(MenuGroup);
|
|
27
|
-
BaseComponent.use(MenuGroup, HasItems);
|
|
39
|
+
BaseComponent.use(MenuGroup, HasItems, HasMenuItem);
|
|
28
40
|
|
|
29
41
|
MenuGroup.prototype.data = function(data) {
|
|
30
42
|
this.$description.data = data;
|
|
31
43
|
return this;
|
|
32
44
|
};
|
|
33
45
|
|
|
46
|
+
MenuGroup.prototype.icon = function(icon) {
|
|
47
|
+
this.$description.icon = icon;
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
MenuGroup.prototype.collapsable = function(mode = true, openedIcon, closedIcon) {
|
|
52
|
+
this.$description.collapsable = mode;
|
|
53
|
+
this.$description.collapsed = this.$description.collapsed || $(true);
|
|
54
|
+
this.$description.collapsableOpenedIcon = openedIcon;
|
|
55
|
+
this.$description.collapsableClosedIcon = closedIcon;
|
|
56
|
+
return this;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
MenuGroup.prototype.collapsed = function(mode = true) {
|
|
60
|
+
this.$description.collapsed.set(mode);
|
|
61
|
+
return this;
|
|
62
|
+
};
|
|
34
63
|
|
|
35
64
|
MenuGroup.prototype.divider = function() {
|
|
36
65
|
return this.item(new MenuDivider());
|
|
37
66
|
};
|
|
38
67
|
|
|
39
|
-
MenuGroup.prototype.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return this.item(group);
|
|
68
|
+
MenuGroup.prototype.visibility = function(mode) {
|
|
69
|
+
this.$description.visibility = BaseComponent.obs(mode);
|
|
70
|
+
return this;
|
|
43
71
|
};
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
|
-
import HasItems from "../$traits/HasItems";
|
|
2
|
+
import HasItems from "../$traits/has-items/HasItems";
|
|
3
3
|
import MenuDivider from "./MenuDivider";
|
|
4
4
|
import MenuGroup from "./MenuGroup";
|
|
5
|
+
import HasMenuItem from "./HasMenuItem";
|
|
6
|
+
import { $ } from '../../../index';
|
|
7
|
+
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
5
8
|
|
|
9
|
+
const EMPTY_PROPS = {}
|
|
6
10
|
|
|
7
11
|
export default function MenuItem(props = {}) {
|
|
8
12
|
if(!(this instanceof MenuItem)) {
|
|
9
|
-
return new MenuItem(props);
|
|
13
|
+
return new MenuItem(props || EMPTY_PROPS);
|
|
10
14
|
}
|
|
11
15
|
|
|
16
|
+
BaseComponent.call(this, props || EMPTY_PROPS);
|
|
17
|
+
|
|
12
18
|
this.$description = {
|
|
13
|
-
items:
|
|
19
|
+
items: $.array(),
|
|
20
|
+
key: null,
|
|
14
21
|
action: null,
|
|
15
22
|
label: null,
|
|
16
23
|
icon: null,
|
|
17
24
|
shortcut: null,
|
|
18
|
-
disabled:
|
|
19
|
-
selected:
|
|
25
|
+
disabled: null,
|
|
26
|
+
selected: null,
|
|
20
27
|
value: null,
|
|
21
28
|
data: null,
|
|
22
29
|
render: null,
|
|
23
30
|
trailing: null,
|
|
31
|
+
visibility: null,
|
|
24
32
|
props
|
|
25
33
|
};
|
|
26
34
|
|
|
@@ -33,7 +41,9 @@ MenuItem.use = function(template) {
|
|
|
33
41
|
};
|
|
34
42
|
|
|
35
43
|
BaseComponent.extends(MenuItem);
|
|
36
|
-
BaseComponent.use(MenuItem, HasItems);
|
|
44
|
+
BaseComponent.use(MenuItem, HasItems, HasEventEmitter, HasMenuItem);
|
|
45
|
+
|
|
46
|
+
HasMenuItem.components.MenuItem = MenuItem;
|
|
37
47
|
|
|
38
48
|
|
|
39
49
|
MenuItem.prototype.label = function(label) {
|
|
@@ -85,8 +95,12 @@ MenuItem.prototype.divider = function() {
|
|
|
85
95
|
return this.item(new MenuDivider());
|
|
86
96
|
};
|
|
87
97
|
|
|
88
|
-
MenuItem.prototype.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
MenuItem.prototype.key = function(key) {
|
|
99
|
+
this.$description.key = key;
|
|
100
|
+
return this;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
MenuItem.prototype.visibility = function(mode) {
|
|
104
|
+
this.$description.visibility = BaseComponent.obs(mode);
|
|
105
|
+
return this;
|
|
92
106
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import MenuItem from "./MenuItem";
|
|
2
|
+
import HasMenuItem from "./HasMenuItem";
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
export default function MenuLink(props = {}) {
|
|
@@ -11,6 +12,7 @@ export default function MenuLink(props = {}) {
|
|
|
11
12
|
MenuLink.prototype = Object.create(MenuItem.prototype);
|
|
12
13
|
MenuLink.prototype.constructor = MenuLink;
|
|
13
14
|
|
|
15
|
+
HasMenuItem.components.MenuLink = MenuLink;
|
|
14
16
|
|
|
15
17
|
MenuLink.defaultTemplate = null;
|
|
16
18
|
|