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
|
@@ -1,192 +1,477 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import Column from "./Column";
|
|
2
|
+
import ColumnGroup from "./ColumnGroup";
|
|
3
|
+
import BaseComponent from "../BaseComponent";
|
|
4
|
+
import {Observable as $} from "../../../index";
|
|
5
|
+
import HasEventEmitter from "../../core/utils/HasEventEmitter";
|
|
6
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
7
|
+
|
|
8
|
+
export default function DataTable(props = {}) {
|
|
9
|
+
if(!(this instanceof DataTable)) {
|
|
10
|
+
return new DataTable(props);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
BaseComponent.call(this, props);
|
|
14
|
+
|
|
15
|
+
this.$description = {
|
|
16
|
+
// Colonnes
|
|
17
|
+
header: [],
|
|
18
|
+
columns: [],
|
|
19
|
+
hasGroups: false,
|
|
20
|
+
|
|
21
|
+
// Données
|
|
22
|
+
data: null,
|
|
23
|
+
total: null,
|
|
24
|
+
mode: 'client', // 'client' | 'server'
|
|
25
|
+
loading: null,
|
|
26
|
+
error: null,
|
|
27
|
+
|
|
28
|
+
// Tri
|
|
29
|
+
defaultSort: null,
|
|
30
|
+
multiSort: false,
|
|
31
|
+
|
|
32
|
+
// Recherche & Filtres
|
|
33
|
+
searchable: false,
|
|
34
|
+
filterable: false,
|
|
35
|
+
defaultFilters: null,
|
|
36
|
+
|
|
37
|
+
// Pagination
|
|
38
|
+
pageSize: null,
|
|
39
|
+
pageSizes: null,
|
|
40
|
+
defaultPage: 1,
|
|
41
|
+
|
|
42
|
+
// Sélection
|
|
43
|
+
selectable: false,
|
|
44
|
+
multiSelect: false,
|
|
45
|
+
|
|
46
|
+
// Édition
|
|
47
|
+
editable: false,
|
|
48
|
+
|
|
49
|
+
// Export
|
|
50
|
+
exports: [],
|
|
51
|
+
exportFileName: null,
|
|
52
|
+
|
|
53
|
+
// Lignes
|
|
54
|
+
expandable: null,
|
|
55
|
+
masterDetail: null,
|
|
56
|
+
bulkActions: null,
|
|
57
|
+
rowProps: null,
|
|
58
|
+
onRowClick: null,
|
|
59
|
+
onRowDoubleClick: null,
|
|
60
|
+
onRowHover: null,
|
|
61
|
+
|
|
62
|
+
// Empty & Error
|
|
63
|
+
empty: null,
|
|
64
|
+
|
|
65
|
+
// Layout & Labels
|
|
66
|
+
layout: null,
|
|
67
|
+
labels: {
|
|
68
|
+
searchPlaceholder: 'Rechercher...',
|
|
69
|
+
search: 'Rechercher',
|
|
70
|
+
filters: 'Filtres',
|
|
71
|
+
export: 'Export',
|
|
72
|
+
columns: 'Colonnes',
|
|
73
|
+
rowsPerPage: 'Lignes par page',
|
|
74
|
+
selected: (n) => `${n} sélectionnés`,
|
|
75
|
+
results: (total, page, pages) => `${total} résultats · Page ${page} sur ${pages}`,
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Persistance
|
|
79
|
+
persistKey: null,
|
|
80
|
+
persistOptions: null,
|
|
81
|
+
|
|
82
|
+
// État Observable
|
|
83
|
+
$currentPage: $(1),
|
|
84
|
+
$pageSize: $(10),
|
|
85
|
+
$total: $(0),
|
|
86
|
+
$selectedRows: $.array([]),
|
|
87
|
+
$sort: $.array([]),
|
|
88
|
+
$filters: $({}),
|
|
89
|
+
$search: $(''),
|
|
90
|
+
$isLoading: $(false),
|
|
91
|
+
|
|
92
|
+
isExpandedIcon: null,
|
|
93
|
+
isNotExpandedIcon: null,
|
|
94
|
+
};
|
|
20
95
|
}
|
|
21
96
|
|
|
22
|
-
DataTable
|
|
23
|
-
DataTable
|
|
24
|
-
|
|
97
|
+
BaseComponent.extends(DataTable);
|
|
98
|
+
BaseComponent.use(DataTable, HasEventEmitter);
|
|
99
|
+
|
|
100
|
+
DataTable.defaultTemplate = null;
|
|
25
101
|
|
|
26
102
|
DataTable.use = function(template) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
103
|
+
DataTable.defaultTemplate = template;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
DataTable.create = function(props) {
|
|
107
|
+
return new DataTable(props);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
DataTable.prototype.$beforeRender = function() {
|
|
111
|
+
const key = this.$description.persistKey;
|
|
112
|
+
const options = this.$description.persistOptions;
|
|
113
|
+
|
|
114
|
+
if(!key || !options) return;
|
|
115
|
+
|
|
116
|
+
const storage = options.storage === 'sessionStorage'
|
|
117
|
+
? sessionStorage
|
|
118
|
+
: localStorage;
|
|
119
|
+
|
|
120
|
+
const optionsKeys = {
|
|
121
|
+
page: this.$description.$currentPage,
|
|
122
|
+
pageSize: this.$description.$pageSize,
|
|
123
|
+
sort: this.$description.$sort,
|
|
124
|
+
filters: this.$description.$filters,
|
|
125
|
+
search: this.$description.$search,
|
|
126
|
+
};
|
|
127
|
+
try {
|
|
128
|
+
const saved = JSON.parse(storage.getItem(key) || '{}');
|
|
129
|
+
|
|
130
|
+
for(const optionKey in optionsKeys) {
|
|
131
|
+
const source = optionsKeys[optionKey];
|
|
132
|
+
if(options.include.includes(optionKey) && saved[optionKey]) {
|
|
133
|
+
source.set(saved[optionKey]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if(options.include.includes('columns') && saved.columns) {
|
|
137
|
+
for(let i = 0, length = this.$description.columns.length; i < length; i++) {
|
|
138
|
+
const col = this.$description.columns[i];
|
|
139
|
+
const colKey = col.$description.key;
|
|
140
|
+
if(saved.columns[colKey] !== undefined) {
|
|
141
|
+
col.$description.visible = saved.columns[colKey];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch(e) {
|
|
147
|
+
storage.removeItem(key);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const save = () => {
|
|
151
|
+
const state = {};
|
|
152
|
+
|
|
153
|
+
for(const optionKey in optionsKeys) {
|
|
154
|
+
const source = optionsKeys[optionKey];
|
|
155
|
+
if(options.include.includes(optionKey)) {
|
|
156
|
+
state[optionKey] = source.val()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if(options.include.includes('columns')) {
|
|
161
|
+
state.columns = {};
|
|
162
|
+
for(let i = 0, length = this.$description.columns.length; i < length; i++) {
|
|
163
|
+
const col = this.$description.columns[i];
|
|
164
|
+
state.columns[col.$description.key] = col.$description.visible;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
storage.setItem(key, JSON.stringify(state));
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
for(const optionKey in optionsKeys) {
|
|
172
|
+
const source = optionsKeys[optionKey];
|
|
173
|
+
if(options.include.includes(optionKey)) {
|
|
174
|
+
source.subscribe(save)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
31
177
|
};
|
|
32
178
|
|
|
33
|
-
|
|
34
|
-
|
|
179
|
+
// ---------------------------------------------
|
|
180
|
+
// COLONNES
|
|
181
|
+
// ---------------------------------------------
|
|
35
182
|
|
|
36
|
-
DataTable.prototype.
|
|
37
|
-
|
|
183
|
+
DataTable.prototype.column = function(key, title, callback) {
|
|
184
|
+
const column = new Column(key);
|
|
185
|
+
column.title(title);
|
|
186
|
+
callback && callback(column);
|
|
187
|
+
this.$description.columns.push(column);
|
|
188
|
+
this.$description.header.push(column);
|
|
38
189
|
return this;
|
|
39
190
|
};
|
|
40
191
|
|
|
41
|
-
DataTable.prototype.
|
|
42
|
-
|
|
192
|
+
DataTable.prototype.group = function(title, callback) {
|
|
193
|
+
const group = new ColumnGroup(title);
|
|
194
|
+
callback && callback(group);
|
|
195
|
+
this.$description.columns.push(...group.columns());
|
|
196
|
+
this.$description.header.push(group);
|
|
197
|
+
this.$description.hasGroups = true;
|
|
43
198
|
return this;
|
|
44
199
|
};
|
|
45
200
|
|
|
201
|
+
// ---------------------------------------------
|
|
202
|
+
// DONNÉES
|
|
203
|
+
// ---------------------------------------------
|
|
46
204
|
|
|
47
|
-
DataTable.prototype.
|
|
48
|
-
this.$description.
|
|
205
|
+
DataTable.prototype.data = function(data) {
|
|
206
|
+
this.$description.data = data;
|
|
49
207
|
return this;
|
|
50
208
|
};
|
|
51
209
|
|
|
52
|
-
DataTable.prototype.
|
|
53
|
-
this.$description
|
|
210
|
+
DataTable.prototype.total = function(total) {
|
|
211
|
+
this.$description.$total = BaseComponent.obs(total);
|
|
54
212
|
return this;
|
|
55
213
|
};
|
|
56
214
|
|
|
57
|
-
DataTable.prototype.
|
|
58
|
-
this.$description.
|
|
215
|
+
DataTable.prototype.clientSide = function() {
|
|
216
|
+
this.$description.mode = 'client';
|
|
59
217
|
return this;
|
|
60
218
|
};
|
|
61
219
|
|
|
220
|
+
DataTable.prototype.serverSide = function() {
|
|
221
|
+
this.$description.mode = 'server';
|
|
222
|
+
return this;
|
|
223
|
+
};
|
|
62
224
|
|
|
63
|
-
DataTable.prototype.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return toolbarTemplate(this);
|
|
67
|
-
}
|
|
68
|
-
return null;
|
|
225
|
+
DataTable.prototype.loading = function(loading) {
|
|
226
|
+
this.$description.loading = loading;
|
|
227
|
+
return this;
|
|
69
228
|
};
|
|
70
229
|
|
|
71
|
-
DataTable.prototype.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
230
|
+
DataTable.prototype.error = function(error) {
|
|
231
|
+
this.$description.error = error;
|
|
232
|
+
return this;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// ---------------------------------------------
|
|
236
|
+
// TRI
|
|
237
|
+
// ---------------------------------------------
|
|
238
|
+
|
|
239
|
+
DataTable.prototype.defaultSort = function(col, dir = 'asc') {
|
|
240
|
+
this.$description.defaultSort = {col, dir};
|
|
241
|
+
this.$description.$sort.push({col, dir});
|
|
242
|
+
return this;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
DataTable.prototype.multiSort = function(enabled = true) {
|
|
246
|
+
this.$description.multiSort = enabled;
|
|
247
|
+
return this;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
DataTable.prototype.onSort = function(handler) {
|
|
251
|
+
this.on('sort', handler);
|
|
252
|
+
return this;
|
|
77
253
|
};
|
|
78
254
|
|
|
255
|
+
// ---------------------------------------------
|
|
256
|
+
// RECHERCHE & FILTRES
|
|
257
|
+
// ---------------------------------------------
|
|
79
258
|
|
|
80
|
-
DataTable.prototype.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
259
|
+
DataTable.prototype.searchable = function(enabled = true) {
|
|
260
|
+
this.$description.searchable = enabled;
|
|
261
|
+
return this;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
DataTable.prototype.filterable = function(enabled = true) {
|
|
265
|
+
this.$description.filterable = enabled;
|
|
266
|
+
return this;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
DataTable.prototype.defaultFilters = function(filters) {
|
|
270
|
+
this.$description.defaultFilters = filters;
|
|
271
|
+
this.$description.$filters.set(filters);
|
|
272
|
+
return this;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
DataTable.prototype.onSearch = function(handler) {
|
|
276
|
+
this.on('search', handler);
|
|
277
|
+
return this;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
DataTable.prototype.onFilter = function(handler) {
|
|
281
|
+
this.on('filter', handler);
|
|
282
|
+
return this;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// ---------------------------------------------
|
|
286
|
+
// PAGINATION
|
|
287
|
+
// ---------------------------------------------
|
|
288
|
+
|
|
289
|
+
DataTable.prototype.pagination = function(pageSize) {
|
|
290
|
+
this.$description.pagination = true;
|
|
291
|
+
this.$description.$pageSize.set(pageSize);
|
|
292
|
+
return this;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
DataTable.prototype.pageSizes = function(sizes) {
|
|
296
|
+
this.$description.pageSizes = sizes;
|
|
297
|
+
return this;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
DataTable.prototype.defaultPage = function(page) {
|
|
301
|
+
this.$description.defaultPage = page;
|
|
302
|
+
this.$description.$currentPage.set(page);
|
|
303
|
+
return this;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
DataTable.prototype.onPage = function(handler) {
|
|
307
|
+
this.on('page', handler);
|
|
308
|
+
return this;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// ---------------------------------------------
|
|
312
|
+
// SÉLECTION
|
|
313
|
+
// ---------------------------------------------
|
|
314
|
+
|
|
315
|
+
DataTable.prototype.selectable = function(enabled = true) {
|
|
316
|
+
this.$description.selectable = enabled;
|
|
317
|
+
return this;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
DataTable.prototype.multiSelect = function(enabled = true) {
|
|
321
|
+
this.$description.multiSelect = enabled;
|
|
322
|
+
return this;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
DataTable.prototype.selectedRows = function($obs) {
|
|
326
|
+
if(!$obs.__$isObservableArray) {
|
|
327
|
+
DebugManager.warn('Database', 'selectedRow should take an Observable array');
|
|
84
328
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.build(),
|
|
88
|
-
this.buildPagination()
|
|
89
|
-
]);
|
|
329
|
+
this.$description.$selectedRows = $obs;
|
|
330
|
+
return this;
|
|
90
331
|
};
|
|
91
332
|
|
|
333
|
+
DataTable.prototype.onSelect = function(handler) {
|
|
334
|
+
this.on('select', handler);
|
|
335
|
+
return this;
|
|
336
|
+
};
|
|
92
337
|
|
|
93
|
-
|
|
94
|
-
//
|
|
95
|
-
|
|
338
|
+
// ---------------------------------------------
|
|
339
|
+
// ÉDITION
|
|
340
|
+
// ---------------------------------------------
|
|
96
341
|
|
|
97
|
-
DataTable.prototype.
|
|
98
|
-
|
|
342
|
+
DataTable.prototype.editable = function(enabled = true) {
|
|
343
|
+
this.$description.editable = enabled;
|
|
99
344
|
return this;
|
|
100
345
|
};
|
|
101
346
|
|
|
102
|
-
DataTable.prototype.
|
|
103
|
-
|
|
347
|
+
DataTable.prototype.onEdit = function(handler) {
|
|
348
|
+
this.on('edit', handler);
|
|
104
349
|
return this;
|
|
105
350
|
};
|
|
106
351
|
|
|
107
|
-
DataTable.prototype.
|
|
108
|
-
|
|
352
|
+
DataTable.prototype.onEditCancel = function(handler) {
|
|
353
|
+
this.on('editCancel', handler);
|
|
109
354
|
return this;
|
|
110
355
|
};
|
|
111
356
|
|
|
112
|
-
|
|
113
|
-
|
|
357
|
+
// ---------------------------------------------
|
|
358
|
+
// EXPORT
|
|
359
|
+
// ---------------------------------------------
|
|
360
|
+
|
|
361
|
+
DataTable.prototype.export = function(label, format, filename) {
|
|
362
|
+
this.$description.exports.push({ label, format, filename });
|
|
114
363
|
return this;
|
|
115
364
|
};
|
|
116
365
|
|
|
117
|
-
DataTable.prototype.
|
|
118
|
-
|
|
366
|
+
DataTable.prototype.exportFileName = function(name) {
|
|
367
|
+
this.$description.exportFileName = name;
|
|
119
368
|
return this;
|
|
120
369
|
};
|
|
121
370
|
|
|
122
|
-
DataTable.prototype.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
};
|
|
371
|
+
DataTable.prototype.onExport = function(handler) {
|
|
372
|
+
this.on('export', handler);
|
|
373
|
+
return this;
|
|
126
374
|
};
|
|
127
375
|
|
|
376
|
+
// ---------------------------------------------
|
|
377
|
+
// LIGNES
|
|
378
|
+
// ---------------------------------------------
|
|
128
379
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
380
|
+
DataTable.prototype.expandable = function(renderFn, isExpandedIcon = '▼', isNotExpandedIcon = '▶') {
|
|
381
|
+
this.$description.expandable = renderFn;
|
|
382
|
+
this.$description.isExpandedIcon = isExpandedIcon;
|
|
383
|
+
this.$description.isNotExpandedIcon = isNotExpandedIcon;
|
|
384
|
+
return this;
|
|
385
|
+
};
|
|
132
386
|
|
|
133
|
-
DataTable.prototype.
|
|
134
|
-
|
|
387
|
+
DataTable.prototype.masterDetail = function(renderFn) {
|
|
388
|
+
this.$description.masterDetail = renderFn;
|
|
135
389
|
return this;
|
|
136
390
|
};
|
|
137
391
|
|
|
138
|
-
DataTable.prototype.
|
|
139
|
-
|
|
392
|
+
DataTable.prototype.bulkActions = function(actions) {
|
|
393
|
+
this.$description.bulkActions = actions;
|
|
140
394
|
return this;
|
|
141
395
|
};
|
|
142
396
|
|
|
143
|
-
DataTable.prototype.
|
|
144
|
-
|
|
397
|
+
DataTable.prototype.rowProps = function(fn) {
|
|
398
|
+
this.$description.rowProps = fn;
|
|
145
399
|
return this;
|
|
146
400
|
};
|
|
147
401
|
|
|
148
|
-
DataTable.prototype.
|
|
149
|
-
|
|
402
|
+
DataTable.prototype.onRowClick = function(handler) {
|
|
403
|
+
this.$description.onRowClick = handler;
|
|
150
404
|
return this;
|
|
151
405
|
};
|
|
152
406
|
|
|
407
|
+
DataTable.prototype.onRowDoubleClick = function(handler) {
|
|
408
|
+
this.$description.onRowDoubleClick = handler;
|
|
409
|
+
return this;
|
|
410
|
+
};
|
|
153
411
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
412
|
+
DataTable.prototype.onRowHover = function(handler) {
|
|
413
|
+
this.$description.onRowHover = handler;
|
|
414
|
+
return this;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
// ---------------------------------------------
|
|
418
|
+
// EMPTY & ERROR
|
|
419
|
+
// ---------------------------------------------
|
|
157
420
|
|
|
158
|
-
DataTable.prototype.
|
|
159
|
-
|
|
421
|
+
DataTable.prototype.layout = function(layoutFn) {
|
|
422
|
+
this.$description.layout = layoutFn;
|
|
160
423
|
return this;
|
|
161
424
|
};
|
|
162
425
|
|
|
163
|
-
DataTable.prototype.
|
|
164
|
-
|
|
426
|
+
DataTable.prototype.labels = function(labels) {
|
|
427
|
+
this.$description.labels = {
|
|
428
|
+
...this.$description.labels,
|
|
429
|
+
...labels,
|
|
430
|
+
};
|
|
165
431
|
return this;
|
|
166
432
|
};
|
|
167
433
|
|
|
168
|
-
|
|
169
|
-
|
|
434
|
+
// ---------------------------------------------
|
|
435
|
+
// PERSISTANCE
|
|
436
|
+
// ---------------------------------------------
|
|
437
|
+
|
|
438
|
+
DataTable.prototype.persist = function(key, options = {}) {
|
|
439
|
+
this.$description.persistKey = key;
|
|
440
|
+
this.$description.persistOptions = {
|
|
441
|
+
include: options.include || ['sort', 'filters', 'search', 'page', 'pageSize', 'columns'],
|
|
442
|
+
storage: options.storage || 'localStorage',
|
|
443
|
+
};
|
|
170
444
|
return this;
|
|
171
445
|
};
|
|
172
446
|
|
|
173
|
-
|
|
174
|
-
|
|
447
|
+
// ---------------------------------------------
|
|
448
|
+
// ACTIONS PUBLIQUES
|
|
449
|
+
// ---------------------------------------------
|
|
450
|
+
|
|
451
|
+
DataTable.prototype.refresh = function() {
|
|
452
|
+
this.emit('refresh');
|
|
175
453
|
return this;
|
|
176
454
|
};
|
|
177
455
|
|
|
178
456
|
DataTable.prototype.clearSelection = function() {
|
|
179
|
-
|
|
457
|
+
this.$description.$selectedRows.clear();
|
|
180
458
|
return this;
|
|
181
459
|
};
|
|
182
460
|
|
|
183
|
-
DataTable.prototype.
|
|
184
|
-
|
|
461
|
+
DataTable.prototype.clearFilters = function() {
|
|
462
|
+
this.$description.$filters.set({});
|
|
463
|
+
this.$description.$search.set('');
|
|
464
|
+
this.emit('filter', {});
|
|
185
465
|
return this;
|
|
186
466
|
};
|
|
187
467
|
|
|
188
|
-
DataTable.prototype.
|
|
189
|
-
|
|
468
|
+
DataTable.prototype.goToPage = function(page) {
|
|
469
|
+
this.$description.$currentPage.set(page);
|
|
470
|
+
this.emit('page', page, this.$description.$pageSize.val());
|
|
190
471
|
return this;
|
|
191
472
|
};
|
|
192
473
|
|
|
474
|
+
DataTable.prototype.empty = function(content) {
|
|
475
|
+
this.$description.empty = content;
|
|
476
|
+
return this;
|
|
477
|
+
};
|