@itfin/components 1.0.51 → 1.0.55
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/package.json +1 -1
- package/src/assets/scss/_variables.scss +2 -0
- package/src/components/alert/Alert.vue +4 -0
- package/src/components/avatar/Avatar.vue +1 -1
- package/src/components/breadcrumbs/Breadcrumbs.vue +34 -0
- package/src/components/button/Button.vue +1 -1
- package/src/components/overlay/SensitiveOverlay.vue +3 -3
- package/src/components/pagination/Pagination.vue +127 -0
- package/src/components/pagination/index.stories.js +41 -0
package/package.json
CHANGED
|
@@ -67,6 +67,8 @@ $dark-btn-secondary-color: $dark-secondary;
|
|
|
67
67
|
$dark-input-box-shadow: #3d3d3d;
|
|
68
68
|
$dark-input-focus-border: rgb(244 206 176 / 25%);
|
|
69
69
|
|
|
70
|
+
$pagination-border-width: 0;
|
|
71
|
+
|
|
70
72
|
// 3. Include remainder of required Bootstrap stylesheets
|
|
71
73
|
@import "~bootstrap/scss/variables.scss";
|
|
72
74
|
@import "~bootstrap/scss/mixins.scss";
|
|
@@ -26,8 +26,12 @@ export default @Component({
|
|
|
26
26
|
class itfAlert extends Vue {
|
|
27
27
|
@Prop({ type: String, default: 'info' }) type;
|
|
28
28
|
@Prop({ type: String }) message;
|
|
29
|
+
@Prop({ type: String }) icon;
|
|
29
30
|
|
|
30
31
|
get iconName() {
|
|
32
|
+
if (this.icon) {
|
|
33
|
+
return this.icon;
|
|
34
|
+
}
|
|
31
35
|
switch (this.type) {
|
|
32
36
|
case 'danger': return 'warning_hex';
|
|
33
37
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<nav aria-label="breadcrumb">
|
|
4
|
+
<ol class="breadcrumb mb-1">
|
|
5
|
+
<li
|
|
6
|
+
v-for="(crumb, n) of items"
|
|
7
|
+
class="breadcrumb-item"
|
|
8
|
+
:key="n"
|
|
9
|
+
:class="{'active': n === items.length - 1}"
|
|
10
|
+
:aria-current="n === items.length - 1 ? 'page' : null"
|
|
11
|
+
>
|
|
12
|
+
<span v-if="crumb.disabled || !crumb.to">{{crumb.text}}</span>
|
|
13
|
+
<nuxt-link v-else :to="crumb.to" :exact="crumb.exact">{{crumb.text}}</nuxt-link>
|
|
14
|
+
</li>
|
|
15
|
+
</ol>
|
|
16
|
+
</nav>
|
|
17
|
+
|
|
18
|
+
</template>
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
@import '../../assets/scss/variables';
|
|
21
|
+
@import '~bootstrap/scss/breadcrumb';
|
|
22
|
+
</style>
|
|
23
|
+
<script>
|
|
24
|
+
import { Vue, Component, Prop } from 'vue-property-decorator';
|
|
25
|
+
|
|
26
|
+
export default @Component({
|
|
27
|
+
name: 'itfBreadcrumb',
|
|
28
|
+
components: {
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
class itfBreadcrumb extends Vue {
|
|
32
|
+
@Prop({ type: Array }) items;
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
|
-
<div class="
|
|
3
|
+
<div class="itf-sensitive-overlay">
|
|
4
4
|
<slot></slot>
|
|
5
5
|
|
|
6
|
-
<div class="
|
|
6
|
+
<div class="itf-sensitive-overlay__cover">
|
|
7
7
|
<slot name="hint">
|
|
8
8
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 104.8 122.88" style="enable-background:new 0 0 104.8 122.88" xml:space="preserve"><g><path fill="currentColor" d="M39.92,0c11.02,0,21,4.47,28.23,11.69c7.22,7.22,11.69,17.2,11.69,28.23c0,3.8-0.53,7.47-1.52,10.95l-3.7-2.53 c0.65-2.7,1-5.52,1-8.42c0-9.86-4-18.78-10.46-25.24C58.7,8.21,49.78,4.22,39.92,4.22c-9.86,0-18.78,4-25.24,10.46 C8.21,21.13,4.22,30.06,4.22,39.92c0,9.86,4,18.78,10.46,25.24c4.79,4.79,10.93,8.22,17.8,9.68l0.34,4.36 c-8.17-1.47-15.48-5.43-21.11-11.06C4.47,60.92,0,50.94,0,39.92c0-11.02,4.47-21,11.69-28.23C18.91,4.47,28.89,0,39.92,0L39.92,0z M81.84,122.5c-0.89,0.41-1.88,0.48-2.76,0.25c-0.97-0.26-1.83-0.87-2.36-1.78l-9.91-17.08l-9.42,10.57 c-1.31,1.47-2.8,2.58-4.24,3.16c-1.11,0.45-2.2,0.59-3.22,0.37c-1.13-0.24-2.09-0.89-2.8-2c-0.56-0.89-0.93-2.07-1.05-3.59 l-5.25-68.42c-0.01-0.05-0.01-0.11-0.01-0.15c-0.01-0.43,0.07-0.85,0.25-1.23c0.19-0.44,0.51-0.84,0.91-1.13 c0.17-0.13,0.36-0.22,0.56-0.27c0.39-0.13,0.8-0.18,1.19-0.13c0.38,0.04,0.75,0.15,1.09,0.35c0.11,0.05,0.23,0.12,0.33,0.2 l56.52,38.7c1.25,0.86,2.09,1.77,2.58,2.7c0.62,1.17,0.69,2.32,0.33,3.42c-0.32,0.99-1,1.87-1.93,2.6 c-1.21,0.95-2.92,1.69-4.86,2.09c-0.02,0.01-0.05,0.01-0.07,0.01L83.92,94l9.84,17.13c0.52,0.91,0.62,1.96,0.36,2.92 c-0.25,0.94-0.85,1.8-1.72,2.37c-0.03,0.03-0.07,0.05-0.11,0.07l-10.21,5.9C81.99,122.43,81.92,122.47,81.84,122.5L81.84,122.5 L81.84,122.5z M79.99,119.28c0.1,0.03,0.2,0.03,0.29-0.01c0.03-0.02,0.07-0.04,0.11-0.05l10.08-5.82c0.09-0.07,0.15-0.17,0.19-0.27 c0.02-0.09,0.02-0.17-0.01-0.22L79.11,93.16h0.01c-0.09-0.16-0.16-0.34-0.2-0.53c-0.2-0.97,0.43-1.91,1.39-2.11l16.22-2.88 c0.02-0.01,0.04-0.01,0.07-0.01c1.4-0.29,2.58-0.79,3.38-1.41c0.39-0.31,0.65-0.61,0.74-0.9c0.06-0.18,0.03-0.4-0.1-0.65 c-0.23-0.43-0.69-0.89-1.43-1.41L45.01,46.02l5.12,65.4c0.07,0.91,0.25,1.54,0.5,1.94c0.15,0.23,0.33,0.37,0.51,0.41 c0.3,0.07,0.69-0.01,1.15-0.19c0.93-0.37,1.94-1.15,2.9-2.22l10.11-12.18l0,0c0.13-0.14,0.27-0.26,0.44-0.36 c0.85-0.49,1.95-0.21,2.44,0.65l11.63,19.69C79.85,119.22,79.91,119.26,79.99,119.28L79.99,119.28L79.99,119.28z M80.39,119.22 c0.23-0.11,0.5-0.18,0.78-0.18L80.39,119.22L80.39,119.22L80.39,119.22z M39.92,27.34c3.47,0,6.62,1.41,8.89,3.69 c0.23,0.23,0.46,0.48,0.67,0.73c-0.12-0.04-0.24-0.08-0.36-0.12c-0.65-0.21-1.35-0.37-2.09-0.48c-0.23-0.04-0.47-0.08-0.71-0.1 c-1.05-0.12-2.14-0.12-3.23,0c-0.15,0.02-0.3,0.04-0.46,0.06c-0.86-0.27-1.78-0.41-2.73-0.41c-2.55,0-4.86,1.03-6.52,2.69 l-0.01,0.01c-1.66,1.66-2.69,3.97-2.69,6.52c0,1.3,0.11,1.34-0.16,2.69c-0.14,0.68-0.22,1.44-0.24,2.28 c-0.04,0.56-0.04,1.13,0,1.71l0.12,1.58c-1.92-2.21-3.08-5.09-3.08-8.25c0-3.46,1.41-6.61,3.69-8.89l0.01-0.01 C33.31,28.74,36.45,27.34,39.92,27.34L39.92,27.34z M39.92,13.68c7.24,0,13.8,2.94,18.55,7.68c4.75,4.75,7.68,11.31,7.68,18.55 c0,0.86-0.04,1.7-0.12,2.54l-3.85-2.64c-0.03-6.11-2.51-11.64-6.52-15.64c-4.03-4.03-9.59-6.52-15.74-6.52 c-6.15,0-11.71,2.49-15.74,6.52c-4.03,4.03-6.52,9.59-6.52,15.74c0,6.15,2.49,11.71,6.52,15.74c2.04,2.04,4.48,3.69,7.19,4.82 l0.34,4.37c-3.94-1.3-7.47-3.51-10.34-6.37c-4.75-4.75-7.68-11.31-7.68-18.55c0-7.24,2.94-13.8,7.68-18.55 C26.11,16.62,32.67,13.68,39.92,13.68L39.92,13.68z"/></g></svg>
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
</template>
|
|
20
20
|
<style lang="scss">
|
|
21
|
-
.
|
|
21
|
+
.itf-sensitive-overlay {
|
|
22
22
|
position: relative;
|
|
23
23
|
min-height: 100px;
|
|
24
24
|
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<nav aria-label="Page navigation example">
|
|
4
|
+
<ul class="pagination itf-pagination">
|
|
5
|
+
<li
|
|
6
|
+
v-for="(page, n) in pagesArr"
|
|
7
|
+
:key="n"
|
|
8
|
+
class="page-item"
|
|
9
|
+
:class="{'active': page.current, 'disabled': !page.active && !page.current }"
|
|
10
|
+
>
|
|
11
|
+
<a v-if="page.type === 'prev'" href="" class="page-link" aria-label="Previous" @click.prevent="onPage(page.number)">
|
|
12
|
+
<itf-icon name="chevron_left" aria-hidden="true" />
|
|
13
|
+
<span class="sr-only">Previous</span>
|
|
14
|
+
</a>
|
|
15
|
+
<a v-else-if="page.type === 'first'" class="page-link" href="" @click.prevent="onPage(page.number)">{{page.number}}</a>
|
|
16
|
+
<a v-else-if="page.type === 'page'" class="page-link" href="" @click.prevent="onPage(page.number)">{{page.number}}</a>
|
|
17
|
+
<a v-else-if="page.type === 'last'" class="page-link" href="" @click.prevent="onPage(page.number)">{{page.number}}</a>
|
|
18
|
+
<span v-else-if="page.type === 'more'" class="page-link">…</span>
|
|
19
|
+
<a v-if="page.type === 'next'" href="" class="page-link" aria-label="Next" @click.prevent="onPage(page.number)">
|
|
20
|
+
<span class="sr-only">Next</span>
|
|
21
|
+
<itf-icon name="chevron_right" aria-hidden="true" />
|
|
22
|
+
</a>
|
|
23
|
+
</li>
|
|
24
|
+
</ul>
|
|
25
|
+
</nav>
|
|
26
|
+
|
|
27
|
+
</template>
|
|
28
|
+
<style lang="scss">
|
|
29
|
+
@import '../../assets/scss/variables';
|
|
30
|
+
@import '~bootstrap/scss/pagination';
|
|
31
|
+
|
|
32
|
+
.itf-pagination.pagination {
|
|
33
|
+
padding-left: 0;
|
|
34
|
+
|
|
35
|
+
.page-item {
|
|
36
|
+
margin-right: 3px;
|
|
37
|
+
.page-link {
|
|
38
|
+
border-radius: .5rem;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</style>
|
|
43
|
+
<script>
|
|
44
|
+
import { Vue, Component, Model, Prop } from 'vue-property-decorator';
|
|
45
|
+
import itfIcon from '../icon/Icon.vue';
|
|
46
|
+
|
|
47
|
+
const MIN_PAGES_BLOCKS = 2;
|
|
48
|
+
const MAX_PAGES_BLOCKS = 6;
|
|
49
|
+
|
|
50
|
+
export default @Component({
|
|
51
|
+
name: 'itfPagination',
|
|
52
|
+
components: {
|
|
53
|
+
itfIcon
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
class itfPagination extends Vue {
|
|
57
|
+
@Model('input') value;
|
|
58
|
+
@Prop({ type: [String, Number], default: 0 }) length;
|
|
59
|
+
@Prop({ type: [String, Number], default: 20 }) size;
|
|
60
|
+
@Prop({ type: [String, Number] }) pages;
|
|
61
|
+
@Prop({ type: [String, Number], default: MIN_PAGES_BLOCKS }) minBlocks;
|
|
62
|
+
@Prop({ type: [String, Number], default: MAX_PAGES_BLOCKS }) maxBlocks;
|
|
63
|
+
|
|
64
|
+
onPage(page) {
|
|
65
|
+
this.$emit('input', page);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get pagesArr () {
|
|
69
|
+
const pageSize = Number(this.size);
|
|
70
|
+
const totalItems = Number(this.length);
|
|
71
|
+
const currentPage = this.value;
|
|
72
|
+
let maxBlocks = Number(this.maxBlocks);
|
|
73
|
+
maxBlocks = maxBlocks && maxBlocks < MAX_PAGES_BLOCKS ? MAX_PAGES_BLOCKS : maxBlocks;
|
|
74
|
+
const minBlocks = Number(this.minBlocks);
|
|
75
|
+
|
|
76
|
+
const pages = [];
|
|
77
|
+
const numPages = this.pages ? Number(this.pages) : Math.ceil(totalItems / pageSize);
|
|
78
|
+
|
|
79
|
+
if (numPages > 1) {
|
|
80
|
+
pages.push({
|
|
81
|
+
type: 'prev',
|
|
82
|
+
number: Math.max(1, currentPage - 1),
|
|
83
|
+
active: currentPage > 1
|
|
84
|
+
});
|
|
85
|
+
pages.push({
|
|
86
|
+
type: 'first',
|
|
87
|
+
number: 1,
|
|
88
|
+
active: currentPage > 1,
|
|
89
|
+
current: currentPage === 1
|
|
90
|
+
});
|
|
91
|
+
const maxPivotPages = Math.round((maxBlocks - minBlocks) / 2);
|
|
92
|
+
let minPage = Math.max(2, currentPage - maxPivotPages);
|
|
93
|
+
const maxPage = Math.min(numPages - 1, currentPage + maxPivotPages * 2 - (currentPage - minPage));
|
|
94
|
+
minPage = Math.max(2, minPage - (maxPivotPages * 2 - (maxPage - minPage)));
|
|
95
|
+
let i = minPage;
|
|
96
|
+
while (i <= maxPage) {
|
|
97
|
+
if ((i === minPage && i !== 2) || (i === maxPage && i !== numPages - 1)) {
|
|
98
|
+
pages.push({
|
|
99
|
+
type: 'more',
|
|
100
|
+
active: false
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
pages.push({
|
|
104
|
+
type: 'page',
|
|
105
|
+
number: i,
|
|
106
|
+
active: currentPage !== i,
|
|
107
|
+
current: currentPage === i
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
i++;
|
|
111
|
+
}
|
|
112
|
+
pages.push({
|
|
113
|
+
type: 'last',
|
|
114
|
+
number: numPages,
|
|
115
|
+
active: currentPage !== numPages,
|
|
116
|
+
current: currentPage === numPages
|
|
117
|
+
});
|
|
118
|
+
pages.push({
|
|
119
|
+
type: 'next',
|
|
120
|
+
number: Math.min(numPages, currentPage + 1),
|
|
121
|
+
active: currentPage < numPages
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return pages;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { storiesOf } from '@storybook/vue';
|
|
2
|
+
import itfPagination from './Pagination.vue';
|
|
3
|
+
import itfApp from '../app/App.vue';
|
|
4
|
+
|
|
5
|
+
storiesOf('Common', module)
|
|
6
|
+
.add('Pagination', () => ({
|
|
7
|
+
components: {
|
|
8
|
+
itfApp,
|
|
9
|
+
itfPagination
|
|
10
|
+
},
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
page: 1,
|
|
14
|
+
customDays: {
|
|
15
|
+
'2021-10-21': { text: '🎉', class: 'test' }
|
|
16
|
+
},
|
|
17
|
+
dateRange: null,
|
|
18
|
+
month: '09-2021'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
template: `<div>
|
|
22
|
+
<p>You need wrap whole application with this tag</p>
|
|
23
|
+
|
|
24
|
+
<h2>Usage</h2>
|
|
25
|
+
|
|
26
|
+
<pre>
|
|
27
|
+
|
|
28
|
+
</pre>
|
|
29
|
+
|
|
30
|
+
<h2>Example</h2>
|
|
31
|
+
|
|
32
|
+
<itf-app ref="app">
|
|
33
|
+
|
|
34
|
+
{{page}}
|
|
35
|
+
|
|
36
|
+
<br />
|
|
37
|
+
<itf-pagination :length="500" v-model.lazy="page"></itf-pagination>
|
|
38
|
+
|
|
39
|
+
</itf-app>
|
|
40
|
+
</div>`,
|
|
41
|
+
}));
|