layers-design-system 2.4.0 → 2.6.0
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/dist/layers-design-system.js +78505 -0
- package/dist/layers-design-system.umd.cjs +285 -0
- package/dist/style.css +1 -0
- package/package.json +26 -12
- package/.nvmrc +0 -1
- package/babel.config.js +0 -5
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -20
- package/src/assets/button-text-editor/double-quotes.svg +0 -4
- package/src/assets/button-text-editor/remove-formatting.svg +0 -5
- package/src/assets/button-text-editor/title.svg +0 -4
- package/src/assets/failed-to-load/failed-to-load.svg +0 -60
- package/src/assets/l-presentation/external-apps.png +0 -0
- package/src/assets/l-presentation/notification.png +0 -0
- package/src/assets/search-topics/empty-tags.svg +0 -59
- package/src/components/LAlert/docs.vue +0 -81
- package/src/components/LAlert/index.vue +0 -43
- package/src/components/LAttachmentChip/docs.vue +0 -84
- package/src/components/LAttachmentChip/index.vue +0 -179
- package/src/components/LBox/docs.vue +0 -26
- package/src/components/LBox/index.vue +0 -19
- package/src/components/LBoxHeader/index.vue +0 -24
- package/src/components/LBreadcrumb/docs.vue +0 -21
- package/src/components/LBreadcrumb/index.vue +0 -22
- package/src/components/LBreadcrumbItem/index.vue +0 -7
- package/src/components/LButton/docs.vue +0 -205
- package/src/components/LButton/index.vue +0 -369
- package/src/components/LButtonGroup/index.vue +0 -7
- package/src/components/LCarousel/docs.vue +0 -32
- package/src/components/LCarousel/index.vue +0 -88
- package/src/components/LCheckbox/docs.vue +0 -62
- package/src/components/LCheckbox/index.vue +0 -34
- package/src/components/LCheckboxButton/index.vue +0 -30
- package/src/components/LCheckboxGroup/index.vue +0 -53
- package/src/components/LChip/docs.vue +0 -113
- package/src/components/LChip/index.vue +0 -78
- package/src/components/LCircularLoader/docs.vue +0 -30
- package/src/components/LCircularLoader/index.vue +0 -97
- package/src/components/LCollapse/docs.vue +0 -68
- package/src/components/LCollapse/index.vue +0 -13
- package/src/components/LCollapseItem/index.vue +0 -28
- package/src/components/LDatePicker/docs.vue +0 -66
- package/src/components/LDatePicker/index.vue +0 -63
- package/src/components/LDialog/docs.vue +0 -36
- package/src/components/LDialog/index.vue +0 -37
- package/src/components/LDropdown/index.vue +0 -7
- package/src/components/LDropdownItem/index.vue +0 -13
- package/src/components/LDropdownMenu/docs.vue +0 -44
- package/src/components/LDropdownMenu/index.vue +0 -12
- package/src/components/LFailedToLoad/docs.vue +0 -37
- package/src/components/LFailedToLoad/index.vue +0 -61
- package/src/components/LForm/index.vue +0 -7
- package/src/components/LFormItem/index.vue +0 -12
- package/src/components/LHelperBox/assets/link.svg +0 -4
- package/src/components/LHelperBox/assets/open-envelope.svg +0 -9
- package/src/components/LHelperBox/docs.vue +0 -29
- package/src/components/LHelperBox/index.vue +0 -83
- package/src/components/LIcon/docs.vue +0 -174
- package/src/components/LIcon/index.vue +0 -55
- package/src/components/LImage/index.vue +0 -7
- package/src/components/LImageViewer/docs.vue +0 -111
- package/src/components/LImageViewer/index.vue +0 -449
- package/src/components/LInput/docs.vue +0 -43
- package/src/components/LInput/index.vue +0 -60
- package/src/components/LLinearProgress/docs.vue +0 -21
- package/src/components/LLinearProgress/index.vue +0 -74
- package/src/components/LNotice/docs.vue +0 -26
- package/src/components/LNotice/index.vue +0 -86
- package/src/components/LNotification/index.vue +0 -182
- package/src/components/LOption/index.vue +0 -7
- package/src/components/LOptionGroup/index.vue +0 -7
- package/src/components/LPresentation/docs.vue +0 -35
- package/src/components/LPresentation/index.vue +0 -182
- package/src/components/LProgress/index.vue +0 -7
- package/src/components/LPromptDialog/index.vue +0 -82
- package/src/components/LRadio/docs.vue +0 -54
- package/src/components/LRadio/index.vue +0 -13
- package/src/components/LRadioButton/index.vue +0 -30
- package/src/components/LRadioGroup/index.vue +0 -54
- package/src/components/LSearchBar/AddFilterButton.vue +0 -71
- package/src/components/LSearchBar/Filters/Editors/AmountEditor.vue +0 -110
- package/src/components/LSearchBar/Filters/Editors/DateEditor.vue +0 -146
- package/src/components/LSearchBar/Filters/Editors/NumberEditor.vue +0 -141
- package/src/components/LSearchBar/Filters/Editors/StringEditor.vue +0 -140
- package/src/components/LSearchBar/Filters/Editors/index.js +0 -16
- package/src/components/LSearchBar/Filters/FilterChip.vue +0 -105
- package/src/components/LSearchBar/Filters/Views/AmountView.vue +0 -28
- package/src/components/LSearchBar/Filters/Views/DateView.vue +0 -46
- package/src/components/LSearchBar/Filters/Views/NumberView.vue +0 -24
- package/src/components/LSearchBar/Filters/Views/StringView.vue +0 -47
- package/src/components/LSearchBar/Filters/Views/index.js +0 -16
- package/src/components/LSearchBar/docs.vue +0 -60
- package/src/components/LSearchBar/index.vue +0 -240
- package/src/components/LSearchTopics/RecentTermSearched.vue +0 -30
- package/src/components/LSearchTopics/TopicItem.vue +0 -346
- package/src/components/LSearchTopics/docs/drawer.vue +0 -254
- package/src/components/LSearchTopics/docs.vue +0 -60
- package/src/components/LSearchTopics/header.vue +0 -199
- package/src/components/LSearchTopics/helpers/showDialogConfirmation.js +0 -30
- package/src/components/LSearchTopics/helpers/showDiscardChangesDialog.js +0 -27
- package/src/components/LSearchTopics/index.vue +0 -750
- package/src/components/LSelect/docs.vue +0 -129
- package/src/components/LSelect/index.vue +0 -9
- package/src/components/LSlider/index.vue +0 -7
- package/src/components/LSwitch/docs.vue +0 -24
- package/src/components/LSwitch/index.vue +0 -60
- package/src/components/LTabPane/index.vue +0 -7
- package/src/components/LTable/FieldTypes/AmountView.vue +0 -16
- package/src/components/LTable/FieldTypes/DateView.vue +0 -18
- package/src/components/LTable/FieldTypes/EmailView.vue +0 -8
- package/src/components/LTable/FieldTypes/NumberView.vue +0 -13
- package/src/components/LTable/FieldTypes/PaymentStatusView.vue +0 -8
- package/src/components/LTable/FieldTypes/StringView.vue +0 -24
- package/src/components/LTable/FieldTypes/index.js +0 -18
- package/src/components/LTable/LTableBody.vue +0 -245
- package/src/components/LTable/LTableBodySpacer.vue +0 -17
- package/src/components/LTable/LTableEndspace.vue +0 -20
- package/src/components/LTable/LTableHeader.vue +0 -155
- package/src/components/LTable/LTableHeaderCell.vue +0 -188
- package/src/components/LTable/LTableHeaderLoader.vue +0 -62
- package/src/components/LTable/LTableHeaderResizer.vue +0 -162
- package/src/components/LTable/LTableLoadMore.vue +0 -56
- package/src/components/LTable/LTablePagination.vue +0 -174
- package/src/components/LTable/LTableReloader.vue +0 -61
- package/src/components/LTable/ListAdapter.js +0 -74
- package/src/components/LTable/docs.vue +0 -111
- package/src/components/LTable/helpers.js +0 -194
- package/src/components/LTable/index.vue +0 -961
- package/src/components/LTabs/docs.vue +0 -28
- package/src/components/LTabs/index.vue +0 -37
- package/src/components/LTargetChip/docs.vue +0 -86
- package/src/components/LTargetChip/index.vue +0 -64
- package/src/components/LTargetInput/docs.vue +0 -72
- package/src/components/LTargetInput/index.vue +0 -78
- package/src/components/LTextEditor/FloatingLink.vue +0 -91
- package/src/components/LTextEditor/LinkBox.vue +0 -94
- package/src/components/LTextEditor/docs.vue +0 -32
- package/src/components/LTextEditor/extensions/LayersBlockquote.js +0 -12
- package/src/components/LTextEditor/extensions/LayersBold.js +0 -11
- package/src/components/LTextEditor/extensions/LayersBreakLine.js +0 -16
- package/src/components/LTextEditor/extensions/LayersBubbleMenu.js +0 -10
- package/src/components/LTextEditor/extensions/LayersBulletList.js +0 -12
- package/src/components/LTextEditor/extensions/LayersHeading.js +0 -13
- package/src/components/LTextEditor/extensions/LayersHistory.js +0 -10
- package/src/components/LTextEditor/extensions/LayersItalic.js +0 -11
- package/src/components/LTextEditor/extensions/LayersLink.js +0 -29
- package/src/components/LTextEditor/extensions/LayersOrderedList.js +0 -12
- package/src/components/LTextEditor/extensions/LayersParagraph.js +0 -44
- package/src/components/LTextEditor/extensions/LayersPlaceholder.js +0 -11
- package/src/components/LTextEditor/extensions/LayersUnderline.js +0 -29
- package/src/components/LTextEditor/helpers/addProtocol.js +0 -5
- package/src/components/LTextEditor/helpers/removeEmptyTags.js +0 -5
- package/src/components/LTextEditor/index.vue +0 -421
- package/src/components/LTimeSelect/docs.vue +0 -41
- package/src/components/LTimeSelect/index.vue +0 -49
- package/src/components/LToggleButtonGroup/index.vue +0 -87
- package/src/components/LTooltip/docs.vue +0 -66
- package/src/components/LTooltip/index.vue +0 -28
- package/src/components/LTransitionExpand/docs.vue +0 -26
- package/src/components/LTransitionExpand/index.vue +0 -88
- package/src/components/LUpload/index.vue +0 -7
- package/src/docs/Colors.vue +0 -50
- package/src/docs/Home.vue +0 -11
- package/src/docs/Notifications.vue +0 -88
- package/src/docs/index.vue +0 -76
- package/src/docs/routes.js +0 -20
- package/src/helpers/Colors.js +0 -79
- package/src/helpers/FieldTypeComponents.js +0 -43
- package/src/helpers/Icons.js +0 -67
- package/src/helpers/Notification.js +0 -94
- package/src/helpers/PrettySize.js +0 -25
- package/src/helpers/RegisterElementUIComponents.js +0 -9
- package/src/helpers/Schemas.js +0 -18
- package/src/helpers/util.js +0 -15
- package/src/main-docs.js +0 -132
- package/src/main.js +0 -100
- package/src/style/colors.scss +0 -31
- package/src/style/element-variables.scss +0 -21
- package/src/style/icons.scss +0 -5
- package/src/style/layers-variables.scss +0 -73
- package/src/style/layout.scss +0 -2288
- package/src/style/main.scss +0 -11
- package/src/style/notifications.scss +0 -88
- package/src/style/transitions.scss +0 -43
- package/src/style/typography.scss +0 -155
- package/vue.config.js +0 -14
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="l-table-pagination">
|
|
3
|
-
<!-- <div class="l-table-pagination-pages"> -->
|
|
4
|
-
<transition-group tag="div" class="l-table-pagination-pages" name="l-table-pagination-transition">
|
|
5
|
-
<span
|
|
6
|
-
class="l-table-pagination-page-item"
|
|
7
|
-
v-for="page in visiblePages"
|
|
8
|
-
:key="page"
|
|
9
|
-
:class="{active: page == currentPage}"
|
|
10
|
-
@click="clicked(page)">
|
|
11
|
-
<template v-if="page === '<'">
|
|
12
|
-
<l-icon size="20">uil-angle-left</l-icon>
|
|
13
|
-
</template>
|
|
14
|
-
<template v-else-if="page === '>'">
|
|
15
|
-
<l-icon size="20">uil-angle-right</l-icon>
|
|
16
|
-
</template>
|
|
17
|
-
<template v-else-if="page === '...1' || page === '...2'">
|
|
18
|
-
<!-- <l-icon size="20">uil-ellipsis-h</l-icon> -->
|
|
19
|
-
...
|
|
20
|
-
</template>
|
|
21
|
-
<template v-else>
|
|
22
|
-
{{page + 1}}
|
|
23
|
-
</template>
|
|
24
|
-
</span>
|
|
25
|
-
</transition-group>
|
|
26
|
-
</div>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<script>
|
|
30
|
-
|
|
31
|
-
import {diggStylePagination} from './helpers'
|
|
32
|
-
|
|
33
|
-
export default {
|
|
34
|
-
name: 'LTablePagination',
|
|
35
|
-
props: {
|
|
36
|
-
pagesCount: Number,
|
|
37
|
-
totalCount: Number,
|
|
38
|
-
currentPage: {
|
|
39
|
-
type: Number,
|
|
40
|
-
default: 2,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
computed: {
|
|
45
|
-
visiblePages() {
|
|
46
|
-
if (!this.totalCount) {
|
|
47
|
-
return ['...1']
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return diggStylePagination({
|
|
51
|
-
pagesCount: this.pagesCount,
|
|
52
|
-
currentPage: this.currentPage,
|
|
53
|
-
adjacents: 1,
|
|
54
|
-
endingAdjacents: 1,
|
|
55
|
-
fixedWidth: true,
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
methods: {
|
|
61
|
-
clicked(page) {
|
|
62
|
-
if (typeof page === 'number') {
|
|
63
|
-
this.goto(parseInt(page))
|
|
64
|
-
} else if (page === '<') {
|
|
65
|
-
this.goto(this.currentPage - 1)
|
|
66
|
-
} else if (page === '>') {
|
|
67
|
-
this.goto(this.currentPage + 1)
|
|
68
|
-
} else if (page === '<<') {
|
|
69
|
-
this.goto(0)
|
|
70
|
-
} else if (page === '>>') {
|
|
71
|
-
this.goto(this.pagesCount - 1)
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
goto(pageIndex) {
|
|
76
|
-
// Avoid forcing change index if didnt change
|
|
77
|
-
if (this.currentPage == pageIndex) {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Limit page index
|
|
82
|
-
pageIndex = Math.max(0, Math.min(pageIndex, this.pagesCount - 1))
|
|
83
|
-
|
|
84
|
-
// Emit event to parent
|
|
85
|
-
this.$emit('goto', pageIndex)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
<style>
|
|
92
|
-
.l-table-pagination {
|
|
93
|
-
flex: 0 0 auto;
|
|
94
|
-
display: flex;
|
|
95
|
-
align-items: center;
|
|
96
|
-
|
|
97
|
-
position: sticky;
|
|
98
|
-
z-index: 10;
|
|
99
|
-
left: 0;
|
|
100
|
-
right: 0;
|
|
101
|
-
bottom: 0;
|
|
102
|
-
padding: 0px 12px;
|
|
103
|
-
|
|
104
|
-
height: var(--l-table-pagination-height);
|
|
105
|
-
background: var(--l-table-pagination-bg-color);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.l-table-pagination:after {
|
|
109
|
-
content: ' ';
|
|
110
|
-
position: absolute;
|
|
111
|
-
left: 0;
|
|
112
|
-
right: 0;
|
|
113
|
-
top: -4px;
|
|
114
|
-
height: 4px;
|
|
115
|
-
background-image: linear-gradient(to top, rgba(0,0,0,0.1), transparent);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.l-table-pagination-pages {
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/* List of page buttons */
|
|
123
|
-
.l-table-pagination-page-item {
|
|
124
|
-
position: relative;
|
|
125
|
-
display: inline-block;
|
|
126
|
-
vertical-align: middle;
|
|
127
|
-
padding: 6px 6px;
|
|
128
|
-
color: #232B34;
|
|
129
|
-
|
|
130
|
-
font-size: 12px;
|
|
131
|
-
min-width: 26px;
|
|
132
|
-
text-align: center;
|
|
133
|
-
|
|
134
|
-
cursor: pointer;
|
|
135
|
-
background: inherit;
|
|
136
|
-
user-select: none;
|
|
137
|
-
|
|
138
|
-
/* transition: all 1s; */
|
|
139
|
-
transition: transform 0.2s;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.l-table-pagination-page-item:hover,
|
|
143
|
-
.l-table-pagination-page-item.active {
|
|
144
|
-
color: var(--l-table-pagination-color);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.l-table-pagination-page-item.active:before {
|
|
148
|
-
background: var(--l-table-pagination-color);
|
|
149
|
-
opacity: 0.08;
|
|
150
|
-
content: ' ';
|
|
151
|
-
position: absolute;
|
|
152
|
-
top: 0;
|
|
153
|
-
left: 0;
|
|
154
|
-
right: 0;
|
|
155
|
-
bottom: 0;
|
|
156
|
-
border-radius: 4px;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/* Transition Group of list items */
|
|
160
|
-
.l-table-pagination-transition-enter,
|
|
161
|
-
.l-table-pagination-transition-leave-to {
|
|
162
|
-
opacity: 0;
|
|
163
|
-
transform: translateY(0px);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.l-table-pagination-transition-leave {
|
|
167
|
-
transition: none;
|
|
168
|
-
opacity: 0;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.l-table-pagination-transition-leave-active {
|
|
172
|
-
position: absolute;
|
|
173
|
-
}
|
|
174
|
-
</style>
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="l-table-reloader">
|
|
3
|
-
<div class="l-table-reloader-content">
|
|
4
|
-
<l-icon size="22">uil-cloud-exclamation</l-icon>
|
|
5
|
-
<span style="margin-left: 8px; flex: 1 1;">Algumas informações não puderam ser carregadas.</span>
|
|
6
|
-
<l-button size="mini" @click="reload()">Recarregar</l-button>
|
|
7
|
-
</div>
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script>
|
|
12
|
-
const RELOAD_TIMEOUT_GUARD = 2000
|
|
13
|
-
export default {
|
|
14
|
-
name: 'LTableReloader',
|
|
15
|
-
|
|
16
|
-
data() {
|
|
17
|
-
return {
|
|
18
|
-
canReload: true,
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
methods: {
|
|
23
|
-
reload() {
|
|
24
|
-
// Create guard
|
|
25
|
-
this.canReload = false
|
|
26
|
-
|
|
27
|
-
this.$emit('reload')
|
|
28
|
-
|
|
29
|
-
// Clear guard
|
|
30
|
-
setTimeout(() => this.canReload = true, RELOAD_TIMEOUT_GUARD)
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
}
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<style>
|
|
37
|
-
.l-table-reloader {
|
|
38
|
-
flex: 0 0 auto;
|
|
39
|
-
position: sticky;
|
|
40
|
-
left: 0;
|
|
41
|
-
right: 0;
|
|
42
|
-
bottom: var(--l-table-pagination-height);
|
|
43
|
-
|
|
44
|
-
z-index: 10;
|
|
45
|
-
padding: var(--l-table-reloader-margin);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.l-table-reloader > .l-table-reloader-content {
|
|
49
|
-
display: flex;
|
|
50
|
-
flex-direction: row;
|
|
51
|
-
align-items: center;
|
|
52
|
-
|
|
53
|
-
font-size: 14px;
|
|
54
|
-
padding: 8px 16px;
|
|
55
|
-
border-radius: 4px;
|
|
56
|
-
|
|
57
|
-
color: white;
|
|
58
|
-
background-color: var(--l-table-warning-color);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
</style>
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import Axios from "axios";
|
|
2
|
-
|
|
3
|
-
export default class ListAdapter {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.setParams({});
|
|
6
|
-
this.pages = [];
|
|
7
|
-
this.total = 0;
|
|
8
|
-
this.limit = 100;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
setParams(params) {
|
|
12
|
-
this.params = params;
|
|
13
|
-
this.hash = JSON.stringify(this.params);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
isLoaded(page) {
|
|
17
|
-
return Array.isArray(this.pages[page]);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setPage(page, data) {
|
|
21
|
-
return (this.pages[page] = data);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async getPage(page) {
|
|
25
|
-
if (this.isLoaded(page)) {
|
|
26
|
-
return this.pages[page];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return await this.fetchPage(page);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async fetchPage(page) {
|
|
33
|
-
let hash = this.hash;
|
|
34
|
-
let params = this.params;
|
|
35
|
-
|
|
36
|
-
// Check hash matches and there is an ongoing request
|
|
37
|
-
let ongoingRequest = this.getPage(page);
|
|
38
|
-
if (ongoingRequest) {
|
|
39
|
-
//
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Build page object
|
|
43
|
-
let doc = {
|
|
44
|
-
hash,
|
|
45
|
-
data: null,
|
|
46
|
-
loading: true,
|
|
47
|
-
failed: false
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Check if any page with same hash exists
|
|
51
|
-
this.setPage(page, doc);
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
const { data } = Axios.get("/url", { params });
|
|
55
|
-
|
|
56
|
-
// Check hash matches
|
|
57
|
-
if (hash !== this.hash) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Update limit
|
|
62
|
-
this.setLimit(data.total);
|
|
63
|
-
|
|
64
|
-
// Update page
|
|
65
|
-
Object.assign(doc, {
|
|
66
|
-
loading: false,
|
|
67
|
-
data: data.items
|
|
68
|
-
});
|
|
69
|
-
return this.setPage(page, doc);
|
|
70
|
-
} catch (e) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="app">
|
|
3
|
-
<h1>Table</h1>
|
|
4
|
-
<div>
|
|
5
|
-
<l-button @click="scrollToTop">Scroll to top</l-button>
|
|
6
|
-
<l-select v-model="display">
|
|
7
|
-
<l-option value="all" label="Todos (all)"></l-option>
|
|
8
|
-
<l-option value="more" label="Carregar mais (more)"></l-option>
|
|
9
|
-
<l-option value="paged" label="Paginado (paged)"></l-option>
|
|
10
|
-
</l-select>
|
|
11
|
-
<l-select v-model="recycle">
|
|
12
|
-
<l-option :value="true" label="Reciclavel"></l-option>
|
|
13
|
-
<l-option :value="false" label="Sem reciclar"></l-option>
|
|
14
|
-
</l-select>
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<l-table
|
|
18
|
-
ref="table"
|
|
19
|
-
style="flex: 1 1 auto; margin: 32px; border: 1px solid var(--l-table-border-color); border-radius: 6px;"
|
|
20
|
-
:display="display"
|
|
21
|
-
:loading="loading"
|
|
22
|
-
:fetch="fetch"
|
|
23
|
-
:schema="schema"
|
|
24
|
-
:columns="columns"
|
|
25
|
-
:recycle="recycle"
|
|
26
|
-
:rowHeight="rowHeight"
|
|
27
|
-
:allowInvertedSelection="allowInvertedSelection"
|
|
28
|
-
:multiple="multiple"
|
|
29
|
-
:borderTick="borderTick ? 1 : 0"
|
|
30
|
-
:selectable="selectable"
|
|
31
|
-
:autoLoadMore="false"
|
|
32
|
-
pagination
|
|
33
|
-
limitPerPage="10"
|
|
34
|
-
:style="{'--l-table-primary-color': 'var(--color-aqua)'}"
|
|
35
|
-
/>
|
|
36
|
-
</div>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script>
|
|
40
|
-
|
|
41
|
-
const sleep = ms => new Promise(res => setTimeout(res, ms))
|
|
42
|
-
|
|
43
|
-
export default {
|
|
44
|
-
name: "Table",
|
|
45
|
-
data() {
|
|
46
|
-
return {
|
|
47
|
-
display: 'all',
|
|
48
|
-
recycle: true,
|
|
49
|
-
loading: false,
|
|
50
|
-
multiple: true,
|
|
51
|
-
selectable: true,
|
|
52
|
-
rowHeight: 46,
|
|
53
|
-
borderTick: true,
|
|
54
|
-
allowInvertedSelection: true,
|
|
55
|
-
schema: this.$L.Schemas.get('payable'),
|
|
56
|
-
columns: [
|
|
57
|
-
{
|
|
58
|
-
path: "code",
|
|
59
|
-
sticky: true,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
path: "customer.name",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
path: "dueAt",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
path: "price.amount",
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
path: "status",
|
|
72
|
-
},
|
|
73
|
-
]
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
methods: {
|
|
78
|
-
scrollToTop() {
|
|
79
|
-
this.$refs.table.reload()
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
// eslint-disable-next-line no-unused-vars
|
|
83
|
-
async fetch({ page, offset, limit }) {
|
|
84
|
-
window['console'].log('Fetch', page)
|
|
85
|
-
if (page > 1 && Math.random() < 0.1) {
|
|
86
|
-
await sleep(1000)
|
|
87
|
-
throw new Error('Failure example')
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const total = 451
|
|
91
|
-
|
|
92
|
-
var items = [];
|
|
93
|
-
for (var i = offset; i < offset + Math.min(total - offset, limit); i++) {
|
|
94
|
-
items.push({ id: i, code: "#" + (i + 1), "dueAt": new Date(), price: {amount: i * 50}, customer: {name: "Teste da Silva"}, status: "paid" });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
await sleep(3000)
|
|
98
|
-
return {
|
|
99
|
-
hits: items,
|
|
100
|
-
total
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
</script>
|
|
106
|
-
|
|
107
|
-
<style scoped>
|
|
108
|
-
#app {
|
|
109
|
-
height: 100vh;
|
|
110
|
-
}
|
|
111
|
-
</style>
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import flatten from "lodash/flatten";
|
|
2
|
-
import uniq from "lodash/uniq";
|
|
3
|
-
|
|
4
|
-
export function changeSelection({ key, selected }, tableComponent) {
|
|
5
|
-
let { loadedPages, allowInvertedSelection, includedIds, excludedIds, multiselect, itemToId = (id) => id } = tableComponent
|
|
6
|
-
|
|
7
|
-
// Skip invalid values
|
|
8
|
-
if (!key === undefined || key === null) {
|
|
9
|
-
return {
|
|
10
|
-
includedIds,
|
|
11
|
-
excludedIds
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (key === "*") {
|
|
16
|
-
includedIds.splice(0, includedIds.length);
|
|
17
|
-
excludedIds.splice(0, excludedIds.length);
|
|
18
|
-
|
|
19
|
-
if (selected && multiselect && allowInvertedSelection) {
|
|
20
|
-
includedIds.push("*");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (selected && multiselect && !allowInvertedSelection) {
|
|
24
|
-
let allItems = flatten(loadedPages.filter(page => page.data).map(page => page.data));
|
|
25
|
-
let allIds = uniq(allItems.map(item => itemToId(item)));
|
|
26
|
-
includedIds = allIds;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
includedIds,
|
|
30
|
-
excludedIds
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let excluding = includedIds.includes("*");
|
|
35
|
-
let included = includedIds.includes(key);
|
|
36
|
-
let excluded = excludedIds.includes(key);
|
|
37
|
-
|
|
38
|
-
// If its single selection, clear all selections
|
|
39
|
-
if (!multiselect) {
|
|
40
|
-
includedIds.splice(0, includedIds.length);
|
|
41
|
-
excludedIds.splice(0, excludedIds.length);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (excluding && multiselect) {
|
|
45
|
-
// Remove from excluded set
|
|
46
|
-
if (selected && excluded) {
|
|
47
|
-
let index = excludedIds.indexOf(key);
|
|
48
|
-
excludedIds.splice(index, 1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Add to excluded set
|
|
52
|
-
if (!selected && !excluded && multiselect) {
|
|
53
|
-
excludedIds.push(key);
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
// Add selection
|
|
57
|
-
if (selected && !included) {
|
|
58
|
-
if (multiselect) {
|
|
59
|
-
// If its multiselect, add to set
|
|
60
|
-
includedIds.push(key);
|
|
61
|
-
} else {
|
|
62
|
-
// Or fully swap value of set
|
|
63
|
-
includedIds = [key];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Remove from set
|
|
68
|
-
if (!selected && included) {
|
|
69
|
-
let index = includedIds.indexOf(key);
|
|
70
|
-
includedIds.splice(index, 1);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
includedIds,
|
|
76
|
-
excludedIds
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Creates a pagination from the given state parameters
|
|
82
|
-
*/
|
|
83
|
-
export function diggStylePagination({
|
|
84
|
-
pagesCount,
|
|
85
|
-
currentPage,
|
|
86
|
-
endingAdjacents = 1,
|
|
87
|
-
adjacents = 2,
|
|
88
|
-
next = true,
|
|
89
|
-
previous = true,
|
|
90
|
-
last = false,
|
|
91
|
-
first = false,
|
|
92
|
-
fixedWidth = true,
|
|
93
|
-
}) {
|
|
94
|
-
const pages = []
|
|
95
|
-
|
|
96
|
-
if (!pagesCount) {
|
|
97
|
-
return pages
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const filledMaximum = fixedWidth ? endingAdjacents * 2 + adjacents * 2 + 3 : endingAdjacents * 2 + 1
|
|
101
|
-
|
|
102
|
-
if (pagesCount <= filledMaximum) {
|
|
103
|
-
// Show all pages since its small number of pages
|
|
104
|
-
for (let p = 0; p < pagesCount; p++)
|
|
105
|
-
pages.push(p)
|
|
106
|
-
} else {
|
|
107
|
-
let curr = 0
|
|
108
|
-
|
|
109
|
-
// Fill with start
|
|
110
|
-
for (let p = 0; p < Math.min(endingAdjacents, pagesCount); p++) {
|
|
111
|
-
pages.push(curr = p)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Compute extra padding
|
|
115
|
-
let minimumPadding = (endingAdjacents + adjacents * 2)
|
|
116
|
-
let adjacentsStart = adjacents
|
|
117
|
-
let adjacentsEnd = adjacents
|
|
118
|
-
if (fixedWidth && currentPage < minimumPadding) {
|
|
119
|
-
adjacentsEnd += minimumPadding - currentPage
|
|
120
|
-
}
|
|
121
|
-
if (fixedWidth && pagesCount - currentPage - 1 < minimumPadding) {
|
|
122
|
-
adjacentsStart += minimumPadding - (pagesCount - currentPage - 1)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Fill middle
|
|
126
|
-
for (let p = Math.max(curr + 1, currentPage - adjacentsStart); p < Math.min(currentPage + adjacentsEnd + 1, pagesCount); p++) {
|
|
127
|
-
if (curr + 2 === p) {
|
|
128
|
-
// Fill with single page between last and current
|
|
129
|
-
pages.push(curr = curr + 1)
|
|
130
|
-
}
|
|
131
|
-
if (curr + 1 !== p) {
|
|
132
|
-
// Add ellipsis if pages are not sequential
|
|
133
|
-
pages.push('...1')
|
|
134
|
-
}
|
|
135
|
-
// window['console'].log('add middle', p, Math.min(currentPage + adjacents, pagesCount))
|
|
136
|
-
pages.push(curr = p)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Fill with end
|
|
140
|
-
for (let p = Math.max(curr + 1, pagesCount - endingAdjacents); p < pagesCount; p++) {
|
|
141
|
-
if (curr + 2 === p) {
|
|
142
|
-
// Fill with single page between last and current
|
|
143
|
-
pages.push(curr = curr + 1)
|
|
144
|
-
}
|
|
145
|
-
if (curr + 1 !== p) {
|
|
146
|
-
// Add ellipsis if pages are not sequential
|
|
147
|
-
pages.push('...2')
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
pages.push(curr = p)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (previous) {
|
|
155
|
-
pages.unshift('<')
|
|
156
|
-
}
|
|
157
|
-
if (next) {
|
|
158
|
-
pages.push('>')
|
|
159
|
-
}
|
|
160
|
-
if (first) {
|
|
161
|
-
pages.unshift('<<')
|
|
162
|
-
}
|
|
163
|
-
if (last) {
|
|
164
|
-
pages.push('>>')
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return pages
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// export function testDiggStylePagination() {
|
|
172
|
-
// // const state1 = {pagesCount: 1}
|
|
173
|
-
// // let tests = [
|
|
174
|
-
// // ]
|
|
175
|
-
|
|
176
|
-
// for (let pagesCount = 0; pagesCount < 15; pagesCount++) {
|
|
177
|
-
// let results = []
|
|
178
|
-
// for (let currentPage = 0; currentPage < pagesCount; currentPage++) {
|
|
179
|
-
// results.push(diggStylePagination({
|
|
180
|
-
// pagesCount,
|
|
181
|
-
// currentPage,
|
|
182
|
-
// fixedWidth: true,
|
|
183
|
-
// adjacents: 2,
|
|
184
|
-
// endingAdjacents: 1,
|
|
185
|
-
// }))
|
|
186
|
-
|
|
187
|
-
// // window['console'].log(pagesCount, currentPage, result)
|
|
188
|
-
// }
|
|
189
|
-
// // window['console'].log({pagesCount})
|
|
190
|
-
// window['console'].table(results, {title: 'Current Page of ' + pagesCount})
|
|
191
|
-
// }
|
|
192
|
-
// }
|
|
193
|
-
|
|
194
|
-
// testDiggStylePagination()
|