native-document 1.0.139 → 1.0.141
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 +11639 -8757
- 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 +82 -7
- 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 +26 -24
- package/src/components/table/ColumnGroup.js +4 -13
- package/src/components/table/DataTable.js +388 -103
- package/src/components/table/SimpleTable.js +31 -140
- 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 +367 -0
- package/src/ui/components/table/data-table/toolbar.js +67 -0
- package/src/ui/components/table/simple-table/SimpleTableRender.js +191 -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
|
@@ -1,52 +1,38 @@
|
|
|
1
1
|
import Column from "./Column";
|
|
2
2
|
import ColumnGroup from "./ColumnGroup";
|
|
3
|
-
import
|
|
4
|
-
import DataTable from "./DataTable";
|
|
3
|
+
import BaseComponent from "../BaseComponent";
|
|
5
4
|
|
|
5
|
+
export default function SimpleTable(props = {}) {
|
|
6
|
+
if(!(this instanceof SimpleTable)) {
|
|
7
|
+
return new SimpleTable(props);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
BaseComponent.call(this, props);
|
|
6
11
|
|
|
7
|
-
export default function SimpleTable(configs = {}) {
|
|
8
12
|
this.$description = {
|
|
9
|
-
header:
|
|
10
|
-
columns:
|
|
11
|
-
hasGroups:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
header: [],
|
|
14
|
+
columns: [],
|
|
15
|
+
hasGroups: false,
|
|
16
|
+
data: null,
|
|
17
|
+
empty: null,
|
|
18
|
+
onRowClick: null,
|
|
19
|
+
rowProps: null,
|
|
20
|
+
noHeader: null,
|
|
21
|
+
cellProps: null,
|
|
22
|
+
headerProps: null,
|
|
18
23
|
};
|
|
19
|
-
|
|
20
|
-
this.$element = null;
|
|
21
|
-
this.$thead = null;
|
|
22
|
-
this.$tbody = null;
|
|
23
|
-
this.$tfoot = null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
SimpleTable
|
|
27
|
-
|
|
28
|
-
SimpleTable.
|
|
26
|
+
BaseComponent.extends(SimpleTable);
|
|
27
|
+
|
|
28
|
+
SimpleTable.defaultTemplate = null;
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {{
|
|
33
|
-
* column: { header: string|Function|null, render: string|Function|null },
|
|
34
|
-
* columnGroup: { header: string|Function|null },
|
|
35
|
-
* row: string|Function|null,
|
|
36
|
-
* table: string|Function|null
|
|
37
|
-
* empty: string|Function|null
|
|
38
|
-
* }} template
|
|
39
|
-
*/
|
|
40
30
|
SimpleTable.use = function(template) {
|
|
41
|
-
|
|
42
|
-
ColumnGroup.use(template.columnGroup || {});
|
|
43
|
-
SimpleTable.defaultRowTemplate = template.row || SimpleTable.defaultRowTemplate;
|
|
44
|
-
SimpleTable.defaultTableTemplate = template.table || SimpleTable.defaultTableTemplate;
|
|
45
|
-
SimpleTable.defaultEmptyTemplate = template.empty || SimpleTable.defaultEmptyTemplate;
|
|
31
|
+
SimpleTable.defaultTemplate = template;
|
|
46
32
|
};
|
|
47
33
|
|
|
48
|
-
SimpleTable.create = function(
|
|
49
|
-
return new SimpleTable(
|
|
34
|
+
SimpleTable.create = function(props) {
|
|
35
|
+
return new SimpleTable(props);
|
|
50
36
|
};
|
|
51
37
|
|
|
52
38
|
SimpleTable.prototype.column = function(key, title, callback) {
|
|
@@ -67,122 +53,27 @@ SimpleTable.prototype.group = function(title, callback) {
|
|
|
67
53
|
return this;
|
|
68
54
|
};
|
|
69
55
|
|
|
70
|
-
SimpleTable.prototype.columns = function(columnsArray) {
|
|
71
|
-
columnsArray.forEach(column => this.column(column.key, column.title, column.callback));
|
|
72
|
-
return this;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
56
|
SimpleTable.prototype.data = function(data) {
|
|
76
57
|
this.$description.data = data;
|
|
77
58
|
return this;
|
|
78
59
|
};
|
|
79
60
|
|
|
80
|
-
|
|
81
|
-
this.$description.
|
|
82
|
-
return this;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
SimpleTable.prototype.renderRow = function(template) {
|
|
86
|
-
this.$description.rowTemplate = template;
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
SimpleTable.prototype.buildRow = function(rowData) {
|
|
91
|
-
const rowTemplate = this.$description.rowTemplate || SimpleTable.defaultRowTemplate;
|
|
92
|
-
|
|
93
|
-
if(typeof rowTemplate === 'function') {
|
|
94
|
-
return rowTemplate(rowData, this);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return TRow(this.$description.columns.map(
|
|
98
|
-
column => TBodyCell({}, column.buildCell(rowData))
|
|
99
|
-
));
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
SimpleTable.prototype.renderTable = function(template) {
|
|
103
|
-
this.$description.tableTemplate = template;
|
|
104
|
-
return this;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
SimpleTable.prototype.buildTable = function(slots = {}) {
|
|
108
|
-
const { headerRows } = slots;
|
|
109
|
-
|
|
110
|
-
const tableTemplate = this.$description.tableTemplate || SimpleTable.defaultTableTemplate;
|
|
111
|
-
if(typeof tableTemplate === 'function') {
|
|
112
|
-
return tableTemplate(slots, this);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return Table({ border: 2 }, [
|
|
116
|
-
THead(headerRows),
|
|
117
|
-
TBody(
|
|
118
|
-
ForEachArray(this.$description.data, rowData => {
|
|
119
|
-
return this.buildRow(rowData, this);
|
|
120
|
-
})
|
|
121
|
-
)
|
|
122
|
-
]);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
SimpleTable.prototype.onClick = function(callback) {
|
|
126
|
-
this.$description.onClick = callback;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
//-----------------------------------------------------------------
|
|
132
|
-
// Expandable Actions
|
|
133
|
-
//-----------------------------------------------------------------
|
|
134
|
-
|
|
135
|
-
DataTable.prototype.expand = function(row) {
|
|
136
|
-
// TODO: implement this action
|
|
61
|
+
SimpleTable.prototype.empty = function(content) {
|
|
62
|
+
this.$description.empty = content;
|
|
137
63
|
return this;
|
|
138
64
|
};
|
|
139
65
|
|
|
140
|
-
|
|
141
|
-
|
|
66
|
+
SimpleTable.prototype.noHeader = function() {
|
|
67
|
+
this.$description.noHeader = true;
|
|
142
68
|
return this;
|
|
143
69
|
};
|
|
144
70
|
|
|
145
|
-
|
|
146
|
-
|
|
71
|
+
SimpleTable.prototype.onRowClick = function(handler) {
|
|
72
|
+
this.$description.onRowClick = handler;
|
|
147
73
|
return this;
|
|
148
74
|
};
|
|
149
75
|
|
|
150
|
-
|
|
151
|
-
|
|
76
|
+
SimpleTable.prototype.rowProps = function(fn) {
|
|
77
|
+
this.$description.rowProps = fn;
|
|
152
78
|
return this;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
SimpleTable.prototype.$build = function() {
|
|
160
|
-
const header = [];
|
|
161
|
-
if(this.$description.hasGroups) {
|
|
162
|
-
const firstRow = [];
|
|
163
|
-
const secondRow = [];
|
|
164
|
-
|
|
165
|
-
this.$description.header.forEach(columnOrGroup => {
|
|
166
|
-
if(columnOrGroup.isGroup) {
|
|
167
|
-
const columns = columnOrGroup.columns();
|
|
168
|
-
firstRow.push(columnOrGroup.buildHeader());
|
|
169
|
-
secondRow.push(columns.map(column => THeadCell({}, column.buildHeader())));
|
|
170
|
-
} else {
|
|
171
|
-
firstRow.push(columnOrGroup.buildHeader(2));
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
header.push(TRow(firstRow));
|
|
176
|
-
header.push(TRow(secondRow));
|
|
177
|
-
} else {
|
|
178
|
-
header.push(TRow(
|
|
179
|
-
this.$description.columns.map(column => column.buildHeader())
|
|
180
|
-
));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return this.buildTable({ headerRows: header });
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
SimpleTable.prototype.toNdElement = function() {
|
|
187
|
-
return this.$build();
|
|
188
79
|
};
|
|
@@ -1,110 +1,208 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
3
|
+
import { $ } from "../../../index";
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
export default function Tabs(
|
|
6
|
+
export default function Tabs(props = {}) {
|
|
6
7
|
if(!(this instanceof Tabs)) {
|
|
7
8
|
return new Tabs();
|
|
8
9
|
}
|
|
9
|
-
BaseComponent.apply(this);
|
|
10
|
+
BaseComponent.apply(this, props);
|
|
10
11
|
this.$description = {
|
|
11
12
|
active: $(''),
|
|
12
13
|
tabs: {},
|
|
13
|
-
|
|
14
|
+
sortable: false,
|
|
15
|
+
tabAppearance: 'segmented',
|
|
16
|
+
addPlusButton: null,
|
|
17
|
+
addPLusCallback: null,
|
|
18
|
+
stickyHeader: false,
|
|
19
|
+
overflow: 'scroll',
|
|
20
|
+
navigationBarPosition: 'top',
|
|
21
|
+
tabsAlignment: 'leading',
|
|
22
|
+
closable: false,
|
|
23
|
+
focusOnNewTab: false,
|
|
24
|
+
closeIcon: null,
|
|
25
|
+
renderCloseButton: null,
|
|
26
|
+
renderPlusButton: null,
|
|
27
|
+
props,
|
|
14
28
|
};
|
|
15
|
-
|
|
16
|
-
this.tabsMap = {};
|
|
17
29
|
}
|
|
18
30
|
|
|
19
|
-
BaseComponent.extends(Tabs
|
|
31
|
+
BaseComponent.extends(Tabs);
|
|
32
|
+
BaseComponent.use(Tabs, HasEventEmitter);
|
|
20
33
|
|
|
21
34
|
Tabs.defaultTemplate = null;
|
|
22
|
-
Tabs.defaultTabTemplate = null;
|
|
23
|
-
Tabs.defaultNavigationBarTemplate = null;
|
|
24
35
|
|
|
25
|
-
Tabs.use = function(template) {
|
|
36
|
+
Tabs.use = function(template) {
|
|
37
|
+
Tabs.defaultTemplate = template;
|
|
38
|
+
};
|
|
26
39
|
|
|
27
|
-
Tabs.prototype.
|
|
28
|
-
Tabs.prototype.
|
|
40
|
+
Tabs.prototype.parentEmit = HasEventEmitter.prototype.emit;
|
|
41
|
+
Tabs.prototype.emit = function(eventName, ...args) {
|
|
42
|
+
this.parentEmit.call(this, eventName, ...args);
|
|
43
|
+
this.parentEmit.call(this, 'change');
|
|
44
|
+
};
|
|
29
45
|
|
|
30
|
-
Tabs.prototype.
|
|
31
|
-
this.$description.
|
|
32
|
-
this
|
|
46
|
+
Tabs.prototype.sortable = function() {
|
|
47
|
+
this.$description.sortable = true;
|
|
48
|
+
return this;
|
|
49
|
+
};
|
|
50
|
+
Tabs.prototype.pills = function() {
|
|
51
|
+
this.$description.tabAppearance = 'pills';
|
|
52
|
+
return this;
|
|
53
|
+
};
|
|
54
|
+
Tabs.prototype.segmented = function() {
|
|
55
|
+
this.$description.tabAppearance = 'segmented';
|
|
56
|
+
return this;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Tabs.prototype.addPlusButton = function(callback) {
|
|
60
|
+
this.$description.addPlusButton = true;
|
|
61
|
+
this.$description.addPLusCallback = callback;
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
Tabs.prototype.closable = function(mode = true) {
|
|
66
|
+
this.$description.closable = mode;
|
|
67
|
+
return this;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
Tabs.prototype.renderCloseButton = function(renderFn) {
|
|
71
|
+
this.$description.renderCloseButton = renderFn;
|
|
72
|
+
return this;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
Tabs.prototype.renderPlusButton = function(renderFn) {
|
|
76
|
+
this.$description.renderPlusButton = renderFn;
|
|
77
|
+
return this;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
Tabs.prototype.overflow = function(overflow) {
|
|
81
|
+
this.$description.overflow = overflow;
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Tabs.prototype.scrollOnTabOverflow = function() {
|
|
86
|
+
this.$description.overflow = 'scroll';
|
|
87
|
+
return this;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
Tabs.prototype.menuOnTabOverflow = function() {
|
|
91
|
+
this.$description.overflow = 'menu';
|
|
92
|
+
return this;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
Tabs.prototype.focusOnNewTab = function(mode = true) {
|
|
96
|
+
this.$description.focusOnNewTab = mode;
|
|
97
|
+
return this;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
Tabs.prototype.stickyHeader = function(mode = true) {
|
|
101
|
+
this.$description.stickyHeader = mode;
|
|
102
|
+
return this;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
Tabs.prototype.addTab = function(icon, label, content, key) {
|
|
106
|
+
const tab = { icon, label, content, key };
|
|
107
|
+
this.$description.tabs[key] = tab;
|
|
108
|
+
this.emit('addTab', tab);
|
|
33
109
|
return this;
|
|
34
110
|
};
|
|
111
|
+
|
|
112
|
+
Tabs.prototype.tab = function(label, content, key) {
|
|
113
|
+
return this.addTab(null, label, content, key);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Tabs.prototype.tabWithIcon = function(icon, label, content, key) {
|
|
117
|
+
return this.addTab(icon, label, content, key);
|
|
118
|
+
};
|
|
119
|
+
|
|
35
120
|
Tabs.prototype.tabs = function(tabs) {
|
|
36
121
|
for(const item of tabs) {
|
|
37
|
-
this.
|
|
122
|
+
this.addTab(item.icon, item.label, item.content, item.key);
|
|
38
123
|
}
|
|
39
124
|
return this;
|
|
40
125
|
};
|
|
41
|
-
Tabs.prototype.
|
|
126
|
+
Tabs.prototype.closeTab = function(key) {
|
|
42
127
|
delete this.$description.tabs[key];
|
|
43
|
-
|
|
44
|
-
// Todo: remove tab from Match element
|
|
45
|
-
this.active(Object.keys(this.$description.tabs)[0]);
|
|
128
|
+
this.emit('closeTab', key);
|
|
46
129
|
return this;
|
|
47
130
|
};
|
|
48
131
|
|
|
49
132
|
Tabs.prototype.active = function(key) {
|
|
50
133
|
this.$description.active.set(key);
|
|
134
|
+
return this;
|
|
51
135
|
};
|
|
52
|
-
Tabs.prototype.defaultActive = function(key) {};
|
|
53
|
-
Tabs.prototype.getActive = function() {};
|
|
54
136
|
|
|
55
137
|
Tabs.prototype.navigationBarPosition = function(position) {
|
|
56
138
|
this.$description.navigationBarPosition = position;
|
|
57
139
|
return this;
|
|
58
140
|
};
|
|
59
141
|
Tabs.prototype.navigationBarAtLeft = function() {
|
|
60
|
-
|
|
142
|
+
this.$description.navigationBarPosition = 'left';
|
|
143
|
+
return this;
|
|
61
144
|
};
|
|
62
145
|
Tabs.prototype.navigationBarAtRight = function() {
|
|
63
|
-
|
|
146
|
+
this.$description.navigationBarPosition = 'right';
|
|
147
|
+
return this;
|
|
64
148
|
};
|
|
65
149
|
Tabs.prototype.navigationBarAtTop = function() {
|
|
66
|
-
|
|
150
|
+
this.$description.navigationBarPosition = 'top';
|
|
151
|
+
return this;
|
|
67
152
|
}
|
|
68
153
|
Tabs.prototype.navigationBarAsDock = function() {
|
|
69
|
-
|
|
154
|
+
this.$description.navigationBarPosition = 'dock';
|
|
155
|
+
return this;
|
|
70
156
|
};
|
|
71
157
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.on('change', handler);
|
|
158
|
+
Tabs.prototype.tabsAtLeading = function() {
|
|
159
|
+
this.$description.tabsAlignment = 'leading';
|
|
75
160
|
return this;
|
|
76
161
|
};
|
|
77
|
-
|
|
78
|
-
|
|
162
|
+
|
|
163
|
+
Tabs.prototype.tabsAtTrailing = function() {
|
|
164
|
+
this.$description.tabsAlignment = 'trailing';
|
|
79
165
|
return this;
|
|
80
166
|
};
|
|
81
|
-
Tabs.prototype.
|
|
82
|
-
this.
|
|
167
|
+
Tabs.prototype.tabsAtCenter = function() {
|
|
168
|
+
this.$description.tabsAlignment = 'center';
|
|
83
169
|
return this;
|
|
84
170
|
};
|
|
85
|
-
Tabs.prototype.
|
|
86
|
-
this.
|
|
171
|
+
Tabs.prototype.tabsJustified = function() {
|
|
172
|
+
this.$description.tabsAlignment = 'justified';
|
|
87
173
|
return this;
|
|
88
174
|
};
|
|
89
175
|
|
|
90
|
-
|
|
91
|
-
Tabs.prototype.
|
|
92
|
-
this
|
|
176
|
+
// Events
|
|
177
|
+
Tabs.prototype.onChange = function(handler) {
|
|
178
|
+
this.on('change', handler);
|
|
93
179
|
return this;
|
|
94
180
|
};
|
|
95
|
-
Tabs.prototype.
|
|
96
|
-
|
|
181
|
+
Tabs.prototype.onBeforeTabClose = function(handler) {
|
|
182
|
+
this.on('beforeTabClose', handler);
|
|
183
|
+
return this;
|
|
97
184
|
};
|
|
98
185
|
|
|
99
|
-
Tabs.prototype.
|
|
100
|
-
this
|
|
186
|
+
Tabs.prototype.onClickTab = function(handler) {
|
|
187
|
+
this.on('clickTab', handler);
|
|
101
188
|
return this;
|
|
102
189
|
};
|
|
103
190
|
|
|
104
|
-
Tabs.prototype
|
|
191
|
+
Tabs.prototype.onCloseTab = function(handler) {
|
|
192
|
+
this.on('closeTab', handler);
|
|
193
|
+
return this;
|
|
194
|
+
};
|
|
105
195
|
|
|
196
|
+
Tabs.prototype.onAddTab = function(handler) {
|
|
197
|
+
this.on('addTab', handler);
|
|
198
|
+
return this;
|
|
106
199
|
};
|
|
107
200
|
|
|
108
|
-
Tabs.prototype.toNdElement = function() {
|
|
109
201
|
|
|
110
|
-
|
|
202
|
+
Tabs.prototype.renderTab = function(renderFn) {
|
|
203
|
+
this.$description.renderTab = renderFn;
|
|
204
|
+
return this;
|
|
205
|
+
};
|
|
206
|
+
Tabs.prototype.renderNavigationBar = function(renderFn) {
|
|
207
|
+
return this.$description.renderNavigationBar = renderFn;
|
|
208
|
+
};
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
3
|
+
import {Observable} from "../../../index";
|
|
3
4
|
|
|
4
|
-
export default function Toast(
|
|
5
|
+
export default function Toast(content, props = {}) {
|
|
5
6
|
if (!(this instanceof Toast)) {
|
|
6
|
-
return new Toast(
|
|
7
|
+
return new Toast(content, props);
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
BaseComponent.call(this, props);
|
|
11
|
+
|
|
9
12
|
this.$description = {
|
|
13
|
+
visibility: Observable(true),
|
|
10
14
|
type: null,
|
|
11
15
|
title: null,
|
|
12
|
-
content
|
|
16
|
+
content,
|
|
13
17
|
icon: null,
|
|
14
18
|
showIcon: true,
|
|
15
|
-
duration:
|
|
19
|
+
duration: 5000,
|
|
16
20
|
closable: true,
|
|
17
21
|
pauseOnHover: true,
|
|
18
|
-
position: 'top-
|
|
22
|
+
position: 'top-trailing',
|
|
19
23
|
actions: [],
|
|
20
24
|
render: null,
|
|
21
|
-
|
|
25
|
+
props
|
|
22
26
|
};
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
BaseComponent.extends(Toast
|
|
29
|
+
BaseComponent.extends(Toast);
|
|
30
|
+
BaseComponent.use(Toast, HasEventEmitter);
|
|
26
31
|
|
|
27
|
-
Toast.use = function(template) {};
|
|
28
32
|
Toast.defaultTemplate = null;
|
|
33
|
+
Toast.use = function(template) {
|
|
34
|
+
Toast.defaultTemplate = template;
|
|
35
|
+
};
|
|
29
36
|
|
|
30
37
|
// Types
|
|
31
38
|
Toast.prototype.type = function(type) {
|
|
@@ -33,16 +40,20 @@ Toast.prototype.type = function(type) {
|
|
|
33
40
|
return this;
|
|
34
41
|
};
|
|
35
42
|
Toast.prototype.info = function() {
|
|
36
|
-
|
|
43
|
+
this.$description.type = 'info';
|
|
44
|
+
return this;
|
|
37
45
|
};
|
|
38
46
|
Toast.prototype.success = function() {
|
|
39
|
-
|
|
47
|
+
this.$description.type = 'success';
|
|
48
|
+
return this;
|
|
40
49
|
};
|
|
41
50
|
Toast.prototype.warning = function() {
|
|
42
|
-
|
|
51
|
+
this.$description.type = 'warning';
|
|
52
|
+
return this;
|
|
43
53
|
};
|
|
44
54
|
Toast.prototype.error = function() {
|
|
45
|
-
|
|
55
|
+
this.$description.type = 'error';
|
|
56
|
+
return this;
|
|
46
57
|
};
|
|
47
58
|
|
|
48
59
|
|
|
@@ -83,18 +94,19 @@ Toast.prototype.position = function(position) {
|
|
|
83
94
|
this.$description.position = position;
|
|
84
95
|
return this;
|
|
85
96
|
};
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
|
|
98
|
+
Toast.prototype.atTopLeading = function() {
|
|
99
|
+
return this.position('top-leading');
|
|
88
100
|
};
|
|
89
101
|
|
|
90
|
-
Toast.prototype.
|
|
91
|
-
return this.position('top-
|
|
102
|
+
Toast.prototype.atTopTrailing = function() {
|
|
103
|
+
return this.position('top-trailing');
|
|
92
104
|
};
|
|
93
|
-
Toast.prototype.
|
|
94
|
-
return this.position('bottom-
|
|
105
|
+
Toast.prototype.atBottomLeading = function() {
|
|
106
|
+
return this.position('bottom-leading');
|
|
95
107
|
};
|
|
96
|
-
Toast.prototype.
|
|
97
|
-
return this.position('bottom-
|
|
108
|
+
Toast.prototype.atBottomTrailing = function() {
|
|
109
|
+
return this.position('bottom-trailing');
|
|
98
110
|
};
|
|
99
111
|
Toast.prototype.atTopCenter = function() {
|
|
100
112
|
return this.position('top-center');
|
|
@@ -103,27 +115,20 @@ Toast.prototype.atBottomCenter = function() {
|
|
|
103
115
|
return this.position('bottom-center');
|
|
104
116
|
};
|
|
105
117
|
|
|
106
|
-
Toast.prototype.
|
|
107
|
-
|
|
118
|
+
Toast.prototype.action = function(label, handler, variant = null) {
|
|
119
|
+
handler = handler || (() => this.close());
|
|
120
|
+
this.$description.actions.push({ label, handler, variant });
|
|
108
121
|
return this;
|
|
109
122
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
|
|
124
|
+
Toast.prototype.close = function() {
|
|
125
|
+
this.$description.visibility?.set(false);
|
|
126
|
+
this.emit('close');
|
|
113
127
|
};
|
|
114
128
|
|
|
115
|
-
Toast.prototype.close = function() {};
|
|
116
129
|
Toast.prototype.onClose = function(handler) {
|
|
117
130
|
this.on('close', handler);
|
|
118
131
|
return this;
|
|
119
132
|
};
|
|
120
133
|
|
|
121
|
-
Toast.prototype.
|
|
122
|
-
this.$description.render = renderFn;
|
|
123
|
-
return this;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
Toast.prototype.$build = function() {
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
Toast.prototype.toNdElement = function() {};
|
|
134
|
+
Toast.prototype.show = BaseComponent.prototype.toNdElement;
|