native-document 1.0.76 → 1.0.78
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 +26 -1
- package/dist/native-document.components.min.js +6447 -1984
- package/dist/native-document.dev.js +309 -196
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/rollup.config.js +0 -14
- package/src/components/$traits/HasItems.js +38 -0
- package/src/components/BaseComponent.js +70 -0
- package/src/components/accordion/Accordion.js +133 -0
- package/src/components/accordion/AccordionItem.js +119 -0
- package/src/components/accordion/index.js +7 -0
- package/src/components/alert/Alert.js +155 -0
- package/src/components/alert/index.js +6 -0
- package/src/components/avatar/Avatar.js +178 -0
- package/src/components/avatar/index.js +5 -0
- package/src/components/badge/Badge.js +103 -0
- package/src/components/badge/index.js +6 -0
- package/src/components/breadcrumb/BreadCrumb.js +70 -0
- package/src/components/breadcrumb/index.js +5 -0
- package/src/components/button/Button.js +174 -0
- package/src/components/button/index.js +5 -0
- package/src/components/card/Card.js +110 -0
- package/src/components/card/index.js +5 -0
- package/src/components/context-menu/ContextMenu.js +60 -0
- package/src/components/context-menu/ContextMenuGroup.js +16 -0
- package/src/components/context-menu/ContextMenuItem.js +16 -0
- package/src/components/context-menu/index.js +10 -0
- package/src/components/divider/Divider.js +126 -0
- package/src/components/divider/index.js +6 -0
- package/src/components/dropdown/Dropdown.js +170 -0
- package/src/components/dropdown/DropdownDivider.js +24 -0
- package/src/components/dropdown/DropdownGroup.js +44 -0
- package/src/components/dropdown/DropdownItem.js +71 -0
- package/src/components/dropdown/DropdownTrigger.js +64 -0
- package/src/components/dropdown/index.js +13 -0
- package/src/components/{fom-control → form}/FormControl.js +28 -20
- package/src/components/{fom-control → form}/field/DefaultRender.js +1 -15
- package/src/components/{fom-control → form}/field/Field.js +64 -137
- package/src/components/{fom-control → form}/field/FieldCollection.js +39 -19
- package/src/components/{fom-control → form}/field/types/AutocompleteField.js +11 -0
- package/src/components/form/field/types/CheckboxField.js +36 -0
- package/src/components/{fom-control → form}/field/types/CheckboxGroupField.js +10 -0
- package/src/components/{fom-control → form}/field/types/ColorField.js +10 -0
- package/src/components/{fom-control → form}/field/types/DateField.js +10 -0
- package/src/components/{fom-control → form}/field/types/EmailField.js +10 -0
- package/src/components/{fom-control → form}/field/types/FileField.js +10 -0
- package/src/components/form/field/types/HiddenField.js +18 -0
- package/src/components/{fom-control → form}/field/types/ImageField.js +10 -0
- package/src/components/{fom-control → form}/field/types/NumberField.js +10 -0
- package/src/components/{fom-control → form}/field/types/PasswordField.js +10 -0
- package/src/components/{fom-control → form}/field/types/RadioField.js +28 -2
- package/src/components/{fom-control → form}/field/types/RangeField.js +10 -0
- package/src/components/{fom-control → form}/field/types/SearchField.js +10 -0
- package/src/components/{fom-control → form}/field/types/SelectField.js +10 -0
- package/src/components/{fom-control → form}/field/types/StringField.js +10 -0
- package/src/components/{fom-control → form}/field/types/TelField.js +10 -1
- package/src/components/{fom-control → form}/field/types/TextAreaField.js +10 -0
- package/src/components/{fom-control → form}/field/types/TimeField.js +10 -1
- package/src/components/{fom-control → form}/field/types/UrlField.js +9 -1
- package/src/components/form/index.js +49 -0
- package/src/components/list/List.js +106 -0
- package/src/components/list/ListGroup.js +67 -0
- package/src/components/list/ListItem.js +103 -0
- package/src/components/list/index.js +10 -0
- package/src/components/menu/Menu.js +82 -0
- package/src/components/menu/MenuDivider.js +22 -0
- package/src/components/menu/MenuGroup.js +42 -0
- package/src/components/menu/MenuItem.js +71 -0
- package/src/components/menu/index.js +13 -0
- package/src/components/modal/Modal.js +153 -0
- package/src/components/modal/index.js +5 -0
- package/src/components/pagination/Pagination.js +229 -0
- package/src/components/pagination/index.js +5 -0
- package/src/components/popover/Popover.js +185 -0
- package/src/components/popover/PopoverFooter.js +37 -0
- package/src/components/popover/PopoverHeader.js +43 -0
- package/src/components/popover/index.js +10 -0
- package/src/components/progress/Progress.js +220 -0
- package/src/components/progress/index.js +6 -0
- package/src/components/skeleton/Skeleton.js +98 -0
- 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
- package/src/components/skeleton/index.js +6 -0
- package/src/components/slider/Slider.js +183 -0
- package/src/components/slider/index.js +5 -0
- package/src/components/spinner/Spinner.js +160 -0
- package/src/components/spinner/index.js +5 -0
- package/src/components/splitter/Splitter.js +94 -0
- package/src/components/splitter/SplitterGutter.js +57 -0
- package/src/components/splitter/SplitterPanel.js +82 -0
- package/src/components/splitter/index.js +8 -0
- package/src/components/stepper/Stepper.js +229 -0
- package/src/components/stepper/StepperStep.js +103 -0
- package/src/components/stepper/index.js +8 -0
- package/src/components/switch/Switch.js +99 -0
- package/src/components/switch/index.js +0 -0
- package/src/components/table/SimpleTable.js +36 -32
- package/src/components/tabs/Tabs.js +110 -0
- package/src/components/tabs/index.js +6 -0
- package/src/components/toast/Toast.js +129 -0
- package/src/components/toast/ToastError.js +0 -0
- package/src/components/toast/ToastInfo.js +0 -0
- package/src/components/toast/ToastSuccess.js +0 -0
- package/src/components/toast/ToastWarning.js +0 -0
- package/src/components/toast/index.js +5 -0
- package/src/components/tooltip/Tooltip.js +98 -0
- package/src/components/tooltip/index.js +5 -0
- package/src/components/tooltip/prototypes.js +6 -0
- package/src/core/data/MemoryManager.js +1 -2
- package/src/core/data/Observable.js +1 -1
- package/src/core/data/ObservableArray.js +10 -4
- package/src/core/data/ObservableItem.js +5 -5
- package/src/core/data/observable-helpers/array.js +1 -1
- package/src/core/data/observable-helpers/batch.js +1 -1
- package/src/core/data/observable-helpers/computed.js +1 -1
- package/src/core/elements/control/for-each-array.js +37 -64
- package/src/core/elements/control/for-each.js +1 -1
- package/src/core/elements/control/show-if.js +1 -1
- package/src/core/elements/control/switch.js +1 -1
- package/src/core/utils/events.js +68 -0
- package/src/core/utils/filters/standard.js +1 -1
- package/src/core/utils/filters/utils.js +1 -1
- package/src/core/utils/helpers.js +10 -7
- package/src/core/utils/validator.js +1 -0
- package/src/core/wrappers/AttributesWrapper.js +18 -35
- package/src/core/wrappers/DocumentObserver.js +0 -1
- package/src/core/wrappers/ElementCreator.js +6 -11
- package/src/core/wrappers/NdPrototype.js +24 -31
- package/src/core/wrappers/TemplateCloner.js +60 -18
- package/src/core/wrappers/constants.js +32 -1
- package/src/core/wrappers/prototypes/attributes-extensions.js +16 -3
- package/src/core/wrappers/prototypes/bind-class-extensions.js +18 -0
- package/src/devtools/app/App.js +1 -1
- package/src/devtools/hrm/ComponentRegistry.js +1 -1
- package/src/router/Router.js +1 -1
- package/src/router/link.js +4 -4
- package/src/router/modes/HistoryRouter.js +0 -1
- package/types/control-flow.d.ts +0 -1
- package/types/filters/standard.d.ts +0 -1
- package/src/components/fom-control/default/DefaultLayout.js +0 -8
- package/src/components/fom-control/default/collection/DefaultCollectionLayout.js +0 -12
- package/src/components/fom-control/default/collection/DefaultCollectionTemplate.js +0 -6
- package/src/components/fom-control/field/types/CheckboxField.js +0 -17
- package/src/components/fom-control/field/types/HiddenField.js +0 -8
- package/src/components/fom-control/index.js +0 -8
- /package/src/components/{fom-control → form}/field/FieldFactory.js +0 -0
- /package/src/components/{fom-control → form}/merge +0 -0
- /package/src/components/{fom-control → form}/utils.js +0 -0
- /package/src/components/{fom-control → form}/validation/Validation.js +0 -0
- /package/src/{core → router}/errors/RouterError.js +0 -0
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import Field from "../Field";
|
|
2
|
+
import {Validator} from "../../../../../index";
|
|
3
|
+
import CheckboxField from "./CheckboxField";
|
|
4
|
+
|
|
5
|
+
export default function RadioField(name, options, defaultConfig = {}) {
|
|
6
|
+
if(!(this instanceof RadioField)) {
|
|
7
|
+
return new RadioField(name, defaultConfig);
|
|
8
|
+
}
|
|
2
9
|
|
|
3
|
-
export default function RadioField(name, options, defaultConfig) {
|
|
4
10
|
Field.call(this, name, 'radio', defaultConfig);
|
|
5
11
|
|
|
6
12
|
Object.assign(this.$description, {
|
|
7
13
|
options: options || [],
|
|
8
|
-
layout: 'vertical'
|
|
14
|
+
layout: 'vertical' || defaultConfig?.layout,
|
|
15
|
+
checked: false
|
|
9
16
|
});
|
|
10
17
|
}
|
|
11
18
|
|
|
19
|
+
RadioField.defaultTemplate = null;
|
|
20
|
+
|
|
21
|
+
RadioField.use = function(template) {
|
|
22
|
+
RadioField.defaultTemplate = template.radioField;
|
|
23
|
+
};
|
|
24
|
+
|
|
12
25
|
RadioField.prototype = Object.create(Field.prototype);
|
|
13
26
|
RadioField.prototype.constructor = RadioField;
|
|
14
27
|
|
|
@@ -17,6 +30,19 @@ RadioField.prototype.options = function(opts) {
|
|
|
17
30
|
return this;
|
|
18
31
|
};
|
|
19
32
|
|
|
33
|
+
RadioField.prototype.model = function(observable) {
|
|
34
|
+
this.$description.checked = observable;
|
|
35
|
+
return this;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
CheckboxField.prototype.checked = function() {
|
|
39
|
+
const checked = this.$description.checked;
|
|
40
|
+
if(Validator.isObservable(checked)) {
|
|
41
|
+
return checked.val();
|
|
42
|
+
}
|
|
43
|
+
return checked;
|
|
44
|
+
};
|
|
45
|
+
|
|
20
46
|
RadioField.prototype.layout = function(value) {
|
|
21
47
|
const allowedLayouts = ['vertical', 'horizontal', 'grid'];
|
|
22
48
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import NumberField from "./NumberField";
|
|
2
2
|
|
|
3
3
|
export default function RangeField(name, defaultConfig) {
|
|
4
|
+
if(!(this instanceof RangeField)) {
|
|
5
|
+
return new RangeField(name, defaultConfig);
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
NumberField.call(this, name, 'range', defaultConfig);
|
|
5
9
|
|
|
6
10
|
Object.assign(this.$description, {
|
|
@@ -8,6 +12,12 @@ export default function RangeField(name, defaultConfig) {
|
|
|
8
12
|
});
|
|
9
13
|
}
|
|
10
14
|
|
|
15
|
+
RangeField.defaultTemplate = null;
|
|
16
|
+
|
|
17
|
+
RangeField.use = function(template) {
|
|
18
|
+
RangeField.defaultTemplate = template.rangeField;
|
|
19
|
+
};
|
|
20
|
+
|
|
11
21
|
RangeField.prototype = Object.create(NumberField.prototype);
|
|
12
22
|
RangeField.prototype.constructor = RangeField;
|
|
13
23
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import StringField from "./StringField";
|
|
2
2
|
|
|
3
3
|
export default function SearchField(name, defaultConfig) {
|
|
4
|
+
if(!(this instanceof SearchField)) {
|
|
5
|
+
return new SearchField(name, defaultConfig);
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
StringField.call(this, name, 'search', defaultConfig);
|
|
5
9
|
|
|
6
10
|
Object.assign(this.$description, {
|
|
@@ -8,6 +12,12 @@ export default function SearchField(name, defaultConfig) {
|
|
|
8
12
|
});
|
|
9
13
|
}
|
|
10
14
|
|
|
15
|
+
SearchField.defaultTemplate = null;
|
|
16
|
+
|
|
17
|
+
SearchField.use = function(template) {
|
|
18
|
+
SearchField.defaultTemplate = template.searchField;
|
|
19
|
+
};
|
|
20
|
+
|
|
11
21
|
SearchField.prototype = Object.create(StringField.prototype);
|
|
12
22
|
SearchField.prototype.constructor = SearchField;
|
|
13
23
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import Field from "../Field";
|
|
2
2
|
|
|
3
3
|
export default function SelectField(name, options, defaultConfig) {
|
|
4
|
+
if(!(this instanceof SelectField)) {
|
|
5
|
+
return new SelectField(name, defaultConfig);
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
Field.call(this, name, 'select', defaultConfig);
|
|
5
9
|
|
|
6
10
|
Object.assign(this.$description, {
|
|
@@ -12,6 +16,12 @@ export default function SelectField(name, options, defaultConfig) {
|
|
|
12
16
|
});
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
SelectField.defaultTemplate = null;
|
|
20
|
+
|
|
21
|
+
SelectField.use = function(template) {
|
|
22
|
+
SelectField.defaultTemplate = template.selectField;
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
SelectField.prototype = Object.create(Field.prototype);
|
|
16
26
|
SelectField.prototype.constructor = SelectField;
|
|
17
27
|
|
|
@@ -2,9 +2,19 @@ import Field from "../Field";
|
|
|
2
2
|
import {Validation} from "../../validation/Validation";
|
|
3
3
|
|
|
4
4
|
export default function StringField(name, type = 'text', defaultConfig = {}) {
|
|
5
|
+
if(!(this instanceof StringField)) {
|
|
6
|
+
return new StringField(name, defaultConfig);
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
Field.call(this, name, type, defaultConfig);
|
|
6
10
|
}
|
|
7
11
|
|
|
12
|
+
StringField.defaultTemplate = null;
|
|
13
|
+
|
|
14
|
+
StringField.use = function(template) {
|
|
15
|
+
StringField.defaultTemplate = template.stringField;
|
|
16
|
+
};
|
|
17
|
+
|
|
8
18
|
StringField.prototype = Object.create(Field.prototype);
|
|
9
19
|
StringField.prototype.constructor = StringField;
|
|
10
20
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
// TelField.js
|
|
2
1
|
import StringField from "./StringField";
|
|
3
2
|
import {Validation} from "../../validation/Validation";
|
|
4
3
|
|
|
5
4
|
export default function TelField(name, defaultConfig) {
|
|
5
|
+
if(!(this instanceof TelField)) {
|
|
6
|
+
return new TelField(name, defaultConfig);
|
|
7
|
+
}
|
|
8
|
+
|
|
6
9
|
StringField.call(this, name, 'tel', defaultConfig);
|
|
7
10
|
|
|
8
11
|
Object.assign(this.$description, {
|
|
@@ -11,6 +14,12 @@ export default function TelField(name, defaultConfig) {
|
|
|
11
14
|
});
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
TelField.defaultTemplate = null;
|
|
18
|
+
|
|
19
|
+
TelField.use = function(template) {
|
|
20
|
+
TelField.defaultTemplate = template.telField;
|
|
21
|
+
};
|
|
22
|
+
|
|
14
23
|
TelField.prototype = Object.create(StringField.prototype);
|
|
15
24
|
TelField.prototype.constructor = TelField;
|
|
16
25
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import StringField from "./StringField";
|
|
2
2
|
|
|
3
3
|
export default function TextAreaField(name, defaultConfig) {
|
|
4
|
+
if(!(this instanceof TextAreaField)) {
|
|
5
|
+
return new TextAreaField(name, defaultConfig);
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
StringField.call(this, name, 'textarea', defaultConfig);
|
|
5
9
|
|
|
6
10
|
Object.assign(this.$description, {
|
|
@@ -13,6 +17,12 @@ export default function TextAreaField(name, defaultConfig) {
|
|
|
13
17
|
});
|
|
14
18
|
}
|
|
15
19
|
|
|
20
|
+
TextAreaField.defaultTemplate = null;
|
|
21
|
+
|
|
22
|
+
TextAreaField.use = function(template) {
|
|
23
|
+
TextAreaField.defaultTemplate = template.textareaField;
|
|
24
|
+
};
|
|
25
|
+
|
|
16
26
|
TextAreaField.prototype = Object.create(StringField.prototype);
|
|
17
27
|
TextAreaField.prototype.constructor = TextAreaField;
|
|
18
28
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
// TimeField.js
|
|
2
1
|
import Field from "../Field";
|
|
3
2
|
import {Validation} from "../../validation/Validation";
|
|
4
3
|
|
|
5
4
|
export default function TimeField(name, defaultConfig) {
|
|
5
|
+
if(!(this instanceof TimeField)) {
|
|
6
|
+
return new TimeField(name, defaultConfig);
|
|
7
|
+
}
|
|
8
|
+
|
|
6
9
|
Field.call(this, name, 'time', defaultConfig);
|
|
7
10
|
|
|
8
11
|
Object.assign(this.$description, {
|
|
@@ -11,6 +14,12 @@ export default function TimeField(name, defaultConfig) {
|
|
|
11
14
|
});
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
TimeField.defaultTemplate = null;
|
|
18
|
+
|
|
19
|
+
TimeField.use = function(template) {
|
|
20
|
+
TimeField.defaultTemplate = template.timeField;
|
|
21
|
+
};
|
|
22
|
+
|
|
14
23
|
TimeField.prototype = Object.create(Field.prototype);
|
|
15
24
|
TimeField.prototype.constructor = TimeField;
|
|
16
25
|
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
// UrlField.js
|
|
2
1
|
import StringField from "./StringField";
|
|
3
2
|
import {Validation} from "../../validation/Validation";
|
|
4
3
|
|
|
5
4
|
export default function UrlField(name, defaultConfig) {
|
|
5
|
+
if(!(this instanceof UrlField)) {
|
|
6
|
+
return new UrlField(name, defaultConfig);
|
|
7
|
+
}
|
|
6
8
|
StringField.call(this, name, 'url', defaultConfig);
|
|
7
9
|
|
|
8
10
|
// Auto-apply url validation
|
|
9
11
|
this.addRule(Validation.url, []);
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
UrlField.defaultTemplate = null;
|
|
15
|
+
|
|
16
|
+
UrlField.use = function(template) {
|
|
17
|
+
UrlField.defaultTemplate = template.urlField;
|
|
18
|
+
};
|
|
19
|
+
|
|
12
20
|
UrlField.prototype = Object.create(StringField.prototype);
|
|
13
21
|
UrlField.prototype.constructor = UrlField;
|
|
14
22
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Field from "./field/Field";
|
|
2
|
+
import FormControl from "./FormControl";
|
|
3
|
+
import StringField from "./field/types/StringField";
|
|
4
|
+
import EmailField from "./field/types/EmailField";
|
|
5
|
+
import PasswordField from "./field/types/PasswordField";
|
|
6
|
+
import NumberField from "./field/types/NumberField";
|
|
7
|
+
import TextAreaField from "./field/types/TextAreaField";
|
|
8
|
+
import CheckboxField from "./field/types/CheckboxField";
|
|
9
|
+
import RadioField from "./field/types/RadioField";
|
|
10
|
+
import SelectField from "./field/types/SelectField";
|
|
11
|
+
import HiddenField from "./field/types/HiddenField";
|
|
12
|
+
import FileField from "./field/types/FileField";
|
|
13
|
+
import DateField from "./field/types/DateField";
|
|
14
|
+
import TimeField from "./field/types/TimeField";
|
|
15
|
+
import TelField from "./field/types/TelField";
|
|
16
|
+
import UrlField from "./field/types/UrlField";
|
|
17
|
+
import ColorField from "./field/types/ColorField";
|
|
18
|
+
import RangeField from "./field/types/RangeField";
|
|
19
|
+
import ImageField from "./field/types/ImageField";
|
|
20
|
+
import CheckboxGroupField from "./field/types/CheckboxGroupField";
|
|
21
|
+
import AutocompleteField from "./field/types/AutocompleteField";
|
|
22
|
+
import FieldCollection from "./field/FieldCollection";
|
|
23
|
+
|
|
24
|
+
import './field/FieldFactory';
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
Field,
|
|
28
|
+
FormControl,
|
|
29
|
+
StringField,
|
|
30
|
+
EmailField,
|
|
31
|
+
PasswordField,
|
|
32
|
+
NumberField,
|
|
33
|
+
TextAreaField,
|
|
34
|
+
CheckboxField,
|
|
35
|
+
RadioField,
|
|
36
|
+
SelectField,
|
|
37
|
+
HiddenField,
|
|
38
|
+
FileField,
|
|
39
|
+
DateField,
|
|
40
|
+
TimeField,
|
|
41
|
+
TelField,
|
|
42
|
+
UrlField,
|
|
43
|
+
ColorField,
|
|
44
|
+
RangeField,
|
|
45
|
+
ImageField,
|
|
46
|
+
CheckboxGroupField,
|
|
47
|
+
AutocompleteField,
|
|
48
|
+
FieldCollection
|
|
49
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
|
|
2
|
+
import BaseComponent from "../BaseComponent";
|
|
3
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
4
|
+
import HasItems from "../$traits/HasItems";
|
|
5
|
+
import Dropdown from "../dropdown/Dropdown";
|
|
6
|
+
|
|
7
|
+
export default function List(config = {}) {
|
|
8
|
+
if(!(this instanceof List)) {
|
|
9
|
+
return new List(config);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this.$description = {
|
|
13
|
+
selectable: false,
|
|
14
|
+
multiSelect: false,
|
|
15
|
+
selectedValues: null,
|
|
16
|
+
inset: false,
|
|
17
|
+
divider: false,
|
|
18
|
+
data: null,
|
|
19
|
+
render: null,
|
|
20
|
+
selectByCheckbox: false,
|
|
21
|
+
selectByClick: false,
|
|
22
|
+
loopOnKeyboard: true,
|
|
23
|
+
...config
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
List.defaultTemplate = null;
|
|
29
|
+
|
|
30
|
+
List.use = function(template) {
|
|
31
|
+
List.defaultTemplate = template.list;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
BaseComponent.extends(List, HasItems, EventEmitter);
|
|
35
|
+
|
|
36
|
+
List.defaultTemplate = null;
|
|
37
|
+
|
|
38
|
+
List.use = function(template) {
|
|
39
|
+
List.defaultTemplate = template.list;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
List.prototype.selectable = function(selectable = true) {
|
|
43
|
+
this.$description.selectable = selectable;
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
List.prototype.selectByClick = function() {
|
|
48
|
+
this.$description.selectByClick = true;
|
|
49
|
+
this.$description.selectByCheckbox = false;
|
|
50
|
+
};
|
|
51
|
+
List.prototype.selectByCheckbox = function() {
|
|
52
|
+
this.$description.selectByClick = false;
|
|
53
|
+
this.$description.selectByCheckbox = true;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
List.prototype.multiSelect = function(multi = true) {
|
|
57
|
+
this.$description.multiSelect = multi;
|
|
58
|
+
this.$description.selectable = true;
|
|
59
|
+
return this;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
List.prototype.selectedValuesModel = function(observable) {
|
|
63
|
+
this.$description.selectedValues = observable;
|
|
64
|
+
return this;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
List.prototype.inset = function(inset = true) {
|
|
68
|
+
this.$description.inset = inset;
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
Dropdown.prototype.next = function() {
|
|
73
|
+
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
Dropdown.prototype.preview = function() {
|
|
77
|
+
|
|
78
|
+
};
|
|
79
|
+
Dropdown.prototype.loopOnKeyboard = function(loopOnKeyboard) {
|
|
80
|
+
this.$description.loopOnKeyboard = loopOnKeyboard;
|
|
81
|
+
return this;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
List.prototype.withDivider = function(divider = true) {
|
|
85
|
+
this.$description.divider = divider;
|
|
86
|
+
return this;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
List.prototype.data = function(data) {
|
|
90
|
+
this.$description.data = data;
|
|
91
|
+
return this;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
List.prototype.onItemClick = function(handler) {
|
|
95
|
+
this.on('itemClick', handler);
|
|
96
|
+
return this;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
List.prototype.onItemSelect = function(handler) {
|
|
100
|
+
this.on('itemSelect', handler);
|
|
101
|
+
return this;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
List.prototype.$build = function() {
|
|
105
|
+
|
|
106
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import HasItems from "../$traits/HasItems";
|
|
3
|
+
|
|
4
|
+
export default function ListGroup(label, config = {}) {
|
|
5
|
+
if(!(this instanceof ListGroup)) {
|
|
6
|
+
return new ListGroup(label, config);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
this.$description = {
|
|
10
|
+
header: label || null,
|
|
11
|
+
footer: null,
|
|
12
|
+
items: [],
|
|
13
|
+
inset: false,
|
|
14
|
+
data: null,
|
|
15
|
+
renderHeader: null,
|
|
16
|
+
renderFooter: null,
|
|
17
|
+
render: null,
|
|
18
|
+
...config
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
BaseComponent.extends(ListGroup, HasItems);
|
|
23
|
+
|
|
24
|
+
ListGroup.defaultTemplate = null;
|
|
25
|
+
|
|
26
|
+
ListGroup.use = function(template) {
|
|
27
|
+
ListGroup.defaultTemplate = template.listGroup;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
ListGroup.prototype.header = function(header) {
|
|
31
|
+
this.$description.header = header;
|
|
32
|
+
return this;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
ListGroup.prototype.title = function(title) {
|
|
36
|
+
return this.header(title);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
ListGroup.prototype.footer = function(footer) {
|
|
40
|
+
this.$description.footer = footer;
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
ListGroup.prototype.inset = function(inset = true) {
|
|
45
|
+
this.$description.inset = inset;
|
|
46
|
+
return this;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
ListGroup.prototype.data = function(data) {
|
|
50
|
+
this.$description.data = data;
|
|
51
|
+
return this;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
ListGroup.prototype.renderHeader = function(renderFn) {
|
|
55
|
+
this.$description.renderHeader = renderFn;
|
|
56
|
+
return this;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
ListGroup.prototype.renderFooter = function(renderFn) {
|
|
60
|
+
this.$description.renderFooter = renderFn;
|
|
61
|
+
return this;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
ListGroup.prototype.$build = function() {
|
|
66
|
+
|
|
67
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import {Validator} from "../../../index";
|
|
3
|
+
|
|
4
|
+
export default function ListItem(content, config = {}) {
|
|
5
|
+
if(!(this instanceof ListItem)) {
|
|
6
|
+
return new ListItem(content, config);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
this.$description = {
|
|
10
|
+
content: content || null,
|
|
11
|
+
icon: null,
|
|
12
|
+
trailing: null,
|
|
13
|
+
leading: null,
|
|
14
|
+
disabled: false,
|
|
15
|
+
selectable: false,
|
|
16
|
+
selected: false,
|
|
17
|
+
divider: false,
|
|
18
|
+
data: null,
|
|
19
|
+
render: null,
|
|
20
|
+
...config
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
BaseComponent.extends(ListItem);
|
|
25
|
+
|
|
26
|
+
ListItem.defaultTemplate = null;
|
|
27
|
+
|
|
28
|
+
ListItem.use = function(template) {
|
|
29
|
+
ListItem.defaultTemplate = template.listItem;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
ListItem.prototype.content = function(content) {
|
|
33
|
+
this.$description.content = content;
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
ListItem.prototype.label = function(label) {
|
|
38
|
+
this.$description.content = label;
|
|
39
|
+
return this;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
ListItem.prototype.icon = function(icon) {
|
|
43
|
+
this.$description.icon = icon;
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
ListItem.prototype.leading = function(leading) {
|
|
48
|
+
this.$description.leading = leading;
|
|
49
|
+
return this;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
ListItem.prototype.trailing = function(trailing) {
|
|
53
|
+
this.$description.trailing = trailing;
|
|
54
|
+
return this;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
ListItem.prototype.leading = function(leading) {
|
|
58
|
+
this.$description.leading = leading;
|
|
59
|
+
return this;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
ListItem.prototype.disabled = function(disabled = true) {
|
|
63
|
+
this.$description.disabled = disabled;
|
|
64
|
+
return this;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
ListItem.prototype.selectable = function() {
|
|
68
|
+
this.$description.selectable = true;
|
|
69
|
+
if(Validator.isObservable(this.$description.selected)) {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
this.$description.selected = $(false);
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
ListItem.prototype.selected = function(selected = true) {
|
|
77
|
+
if(Validator.isObservable(this.$description.selected)) {
|
|
78
|
+
this.$description.selected.set(selected);
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
this.$description.selected = selected;
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
ListItem.prototype.divider = function(show = true) {
|
|
86
|
+
this.$description.divider = show;
|
|
87
|
+
return this;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
ListItem.prototype.data = function(data) {
|
|
91
|
+
this.$description.data = data;
|
|
92
|
+
return this;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
ListItem.prototype.render = function(renderFn) {
|
|
96
|
+
this.$description.render = renderFn;
|
|
97
|
+
return this;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
ListItem.prototype.$build = function() {
|
|
102
|
+
|
|
103
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
|
+
import HasItems from "../$traits/HasItems";
|
|
4
|
+
import MenuDivider from "./MenuDivider";
|
|
5
|
+
import MenuGroup from "./MenuGroup";
|
|
6
|
+
|
|
7
|
+
export default function Menu(config = {}) {
|
|
8
|
+
|
|
9
|
+
if(!(this instanceof Menu)) {
|
|
10
|
+
return new Menu(config)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
this.$description = {
|
|
14
|
+
items: [],
|
|
15
|
+
render: null,
|
|
16
|
+
orientation: 'horizontal',
|
|
17
|
+
closeOnSelect: true,
|
|
18
|
+
keyboardLoop: true,
|
|
19
|
+
...config
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
BaseComponent.extends(Menu, HasItems, EventEmitter);
|
|
25
|
+
|
|
26
|
+
Menu.defaultTemplate = null;
|
|
27
|
+
|
|
28
|
+
Menu.use = function(template) {
|
|
29
|
+
Menu.defaultTemplate = template.menu;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
Menu.prototype.orientation = function(orientation) {
|
|
33
|
+
this.$description.orientation = orientation;
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Menu.prototype.horizontal = function() {
|
|
38
|
+
this.$description.orientation = 'horizontal';
|
|
39
|
+
return this;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Menu.prototype.vertical = function() {
|
|
43
|
+
this.$description.orientation = 'vertical';
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Menu.prototype.closeOnSelect = function(close = true) {
|
|
48
|
+
this.$description.closeOnSelect = close;
|
|
49
|
+
return this;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Menu.prototype.keyboardLoop = function(keyboardLoop = true) {
|
|
53
|
+
this.$description.keyboardLoop = keyboardLoop;
|
|
54
|
+
return this;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
Menu.prototype.data = function(data) {
|
|
58
|
+
this.$description.data = data;
|
|
59
|
+
return this;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
Menu.prototype.onItemClick = function(handler) {
|
|
63
|
+
this.on('itemClick', handler);
|
|
64
|
+
return this;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Menu.prototype.onItemSelect = function(handler) {
|
|
68
|
+
this.on('itemSelect', handler);
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Menu.prototype.divider = function() {
|
|
75
|
+
return this.item(new MenuDivider());
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
Menu.prototype.group = function(label, builder) {
|
|
79
|
+
const group = new MenuGroup(label);
|
|
80
|
+
builder && builder(group);
|
|
81
|
+
return this.item(group);
|
|
82
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default function MenuDivider() {
|
|
5
|
+
if(!this instanceof MenuDivider) {
|
|
6
|
+
return new MenuDivider();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
BaseComponent.extends(MenuDivider);
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
MenuDivider.defaultTemplate = null;
|
|
15
|
+
|
|
16
|
+
MenuDivider.use = function(template) {
|
|
17
|
+
MenuDivider.defaultTemplate = template.divider;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
MenuDivider.prototype.$build = function() {
|
|
21
|
+
|
|
22
|
+
};
|