@gitlab/ui 32.43.3 → 32.46.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/CHANGELOG.md +29 -0
- package/config.js +15 -3
- package/dist/components/base/avatar/avatar.documentation.js +2 -5
- package/dist/components/base/avatar_link/avatar_link.documentation.js +2 -5
- package/dist/components/base/form/form_group/form_group.js +11 -1
- package/dist/components/base/form/form_input/form_input.documentation.js +2 -27
- package/dist/components/base/form/form_input/form_input.js +23 -6
- package/dist/components/base/form/form_text/form_text.documentation.js +1 -4
- package/dist/components/base/label/label.documentation.js +2 -9
- package/dist/components/base/label/label.js +23 -1
- package/dist/components/base/pagination/pagination.documentation.js +2 -85
- package/dist/components/base/pagination/pagination.js +76 -0
- package/dist/components/base/segmented_control/segmented_control.documentation.js +2 -14
- package/dist/components/base/segmented_control/segmented_control.js +6 -0
- package/dist/components/base/skeleton_loader/skeleton_loader.documentation.js +2 -28
- package/dist/components/base/skeleton_loader/skeleton_loader.js +30 -0
- package/dist/components/charts/chart/chart.js +17 -4
- package/dist/components/charts/discrete_scatter/discrete_scatter.documentation.js +1 -7
- package/dist/components/charts/heatmap/heatmap.js +1 -9
- package/dist/components/charts/sparkline/sparkline.js +1 -1
- package/dist/components/charts/stacked_column/stacked_column.documentation.js +2 -5
- package/dist/config.js +15 -3
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +9 -0
- package/package.json +11 -10
- package/src/components/base/alert/alert.spec.js +2 -2
- package/src/components/base/avatar/avatar.documentation.js +0 -2
- package/src/components/base/avatar/avatar.md +0 -2
- package/src/components/base/avatar/avatar.spec.js +1 -2
- package/src/components/base/avatar/avatar.stories.js +88 -101
- package/src/components/base/avatar_link/avatar_link.documentation.js +0 -2
- package/src/components/base/avatar_link/avatar_link.md +4 -7
- package/src/components/base/avatar_link/avatar_link.stories.js +66 -54
- package/src/components/base/filtered_search/filtered_search.spec.js +35 -35
- package/src/components/base/filtered_search/filtered_search_term.spec.js +1 -1
- package/src/components/base/form/form_group/form_group.scss +4 -0
- package/src/components/base/form/form_group/form_group.spec.js +66 -64
- package/src/components/base/form/form_group/form_group.stories.js +36 -13
- package/src/components/base/form/form_group/form_group.vue +15 -2
- package/src/components/base/form/form_input/form_input.documentation.js +0 -31
- package/src/components/base/form/form_input/form_input.md +0 -2
- package/src/components/base/form/form_input/form_input.stories.js +50 -42
- package/src/components/base/form/form_input/form_input.vue +23 -6
- package/src/components/base/form/form_input_group/form_input_group.spec.js +1 -3
- package/src/components/base/form/form_text/form_text.documentation.js +0 -2
- package/src/components/base/form/form_text/form_text.md +1 -3
- package/src/components/base/form/form_text/form_text.stories.js +20 -8
- package/src/components/base/icon/icon.spec.js +1 -4
- package/src/components/base/infinite_scroll/infinite_scroll.spec.js +1 -4
- package/src/components/base/label/label.documentation.js +2 -12
- package/src/components/base/label/label.md +2 -7
- package/src/components/base/label/label.stories.js +66 -92
- package/src/components/base/label/label.vue +22 -2
- package/src/components/base/modal/modal.spec.js +19 -23
- package/src/components/base/paginated_list/__snapshots__/paginated_list.spec.js.snap +10 -10
- package/src/components/base/pagination/pagination.documentation.js +0 -100
- package/src/components/base/pagination/pagination.md +5 -9
- package/src/components/base/pagination/pagination.spec.js +1 -4
- package/src/components/base/pagination/pagination.stories.js +109 -117
- package/src/components/base/pagination/pagination.vue +85 -0
- package/src/components/base/search_box_by_click/search_box_by_click.spec.js +1 -5
- package/src/components/base/segmented_control/segmented_control.documentation.js +0 -15
- package/src/components/base/segmented_control/segmented_control.md +0 -2
- package/src/components/base/segmented_control/segmented_control.stories.js +46 -36
- package/src/components/base/segmented_control/segmented_control.vue +5 -0
- package/src/components/base/skeleton_loader/skeleton_loader.documentation.js +0 -27
- package/src/components/base/skeleton_loader/skeleton_loader.md +0 -2
- package/src/components/base/skeleton_loader/skeleton_loader.stories.js +23 -9
- package/src/components/base/skeleton_loader/skeleton_loader.vue +24 -0
- package/src/components/base/sorting/sorting.spec.js +1 -4
- package/src/components/base/toast/toast.spec.js +4 -6
- package/src/components/base/token/token.spec.js +1 -4
- package/src/components/base/token_selector/token_container.spec.js +2 -3
- package/src/components/charts/chart/chart.spec.js +33 -4
- package/src/components/charts/chart/chart.vue +16 -4
- package/src/components/charts/discrete_scatter/discrete_scatter.documentation.js +0 -5
- package/src/components/charts/discrete_scatter/discrete_scatter.stories.js +34 -46
- package/src/components/charts/gauge/gauge.spec.js +7 -7
- package/src/components/charts/heatmap/heatmap.vue +2 -9
- package/src/components/charts/sparkline/sparkline.spec.js +1 -4
- package/src/components/charts/sparkline/sparkline.vue +7 -1
- package/src/components/charts/stacked_column/stacked_column.documentation.js +0 -2
- package/src/components/charts/stacked_column/stacked_column.md +0 -2
- package/src/components/charts/stacked_column/stacked_column.stories.js +74 -99
- package/src/components/utilities/friendly_wrap/friendly_wrap.spec.js +1 -4
- package/src/components/utilities/intersperse/intersperse.spec.js +1 -4
- package/src/directives/hover_load/hover_load.spec.js +2 -13
- package/src/directives/outside/outside.spec.js +1 -6
- package/src/directives/resize_observer/resize_observer.spec.js +4 -10
- package/src/scss/storybook.scss +8 -0
- package/src/scss/utilities.scss +8 -0
- package/src/scss/utility-mixins/transform.scss +4 -0
- package/dist/components/base/avatar/examples/avatar.fallback.example.js +0 -38
- package/dist/components/base/avatar/examples/avatar.image.example.js +0 -38
- package/dist/components/base/avatar/examples/avatar.rect.example.js +0 -38
- package/dist/components/base/avatar/examples/avatar.tooltip.example.js +0 -38
- package/dist/components/base/avatar/examples/index.js +0 -31
- package/dist/components/base/avatar_link/examples/avatar.link.example.js +0 -38
- package/dist/components/base/avatar_link/examples/index.js +0 -13
- package/dist/components/base/form/form_input/examples/form_input/form_input.text.example.js +0 -38
- package/dist/components/base/form/form_input/examples/form_input/form_input.text_disabled.example.js +0 -38
- package/dist/components/base/form/form_input/examples/form_input/form_input.text_reactive.example.js +0 -57
- package/dist/components/base/form/form_input/examples/form_input/index.js +0 -22
- package/dist/components/base/form/form_text/examples/form_text.basic.example.js +0 -38
- package/dist/components/base/form/form_text/examples/index.js +0 -13
- package/dist/components/base/label/examples/index.js +0 -19
- package/dist/components/base/label/examples/label.basic.example.js +0 -38
- package/dist/components/base/label/examples/label.scoped.example.js +0 -38
- package/dist/components/base/pagination/examples/index.js +0 -37
- package/dist/components/base/pagination/examples/pagination.basic.example.js +0 -45
- package/dist/components/base/pagination/examples/pagination.compact.example.js +0 -58
- package/dist/components/base/pagination/examples/pagination.double_truncation.example.js +0 -45
- package/dist/components/base/pagination/examples/pagination.event.example.js +0 -51
- package/dist/components/base/pagination/examples/pagination.links.example.js +0 -45
- package/dist/components/base/segmented_control/examples/index.js +0 -19
- package/dist/components/base/segmented_control/examples/segmented_control.basic.example.js +0 -65
- package/dist/components/base/segmented_control/examples/segmented_control.whitespace.example.js +0 -55
- package/dist/components/base/skeleton_loader/examples/ci_header_skeleton.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/default_skeleton.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/default_skeleton_custom_props.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/index.js +0 -37
- package/dist/components/base/skeleton_loader/examples/issue_card_skeleton.basic.example.js +0 -38
- package/dist/components/base/skeleton_loader/examples/job_log_skeleton.basic.example.js +0 -38
- package/dist/components/charts/discrete_scatter/examples/discrete_scatter.basic.example.js +0 -51
- package/dist/components/charts/discrete_scatter/examples/index.js +0 -13
- package/dist/components/charts/stacked_column/examples/index.js +0 -13
- package/dist/components/charts/stacked_column/examples/stacked_column.basic.example.js +0 -46
- package/src/components/base/avatar/examples/avatar.fallback.example.vue +0 -3
- package/src/components/base/avatar/examples/avatar.image.example.vue +0 -3
- package/src/components/base/avatar/examples/avatar.rect.example.vue +0 -6
- package/src/components/base/avatar/examples/avatar.tooltip.example.vue +0 -3
- package/src/components/base/avatar/examples/index.js +0 -36
- package/src/components/base/avatar_link/examples/avatar.link.example.vue +0 -5
- package/src/components/base/avatar_link/examples/index.js +0 -15
- package/src/components/base/form/form_input/examples/form_input/form_input.text.example.vue +0 -3
- package/src/components/base/form/form_input/examples/form_input/form_input.text_disabled.example.vue +0 -3
- package/src/components/base/form/form_input/examples/form_input/form_input.text_reactive.example.vue +0 -24
- package/src/components/base/form/form_input/examples/form_input/index.js +0 -26
- package/src/components/base/form/form_text/examples/form_text.basic.example.vue +0 -5
- package/src/components/base/form/form_text/examples/index.js +0 -15
- package/src/components/base/label/examples/index.js +0 -22
- package/src/components/base/label/examples/label.basic.example.vue +0 -3
- package/src/components/base/label/examples/label.scoped.example.vue +0 -3
- package/src/components/base/pagination/examples/index.js +0 -43
- package/src/components/base/pagination/examples/pagination.basic.example.vue +0 -17
- package/src/components/base/pagination/examples/pagination.compact.example.vue +0 -33
- package/src/components/base/pagination/examples/pagination.double_truncation.example.vue +0 -11
- package/src/components/base/pagination/examples/pagination.event.example.vue +0 -26
- package/src/components/base/pagination/examples/pagination.links.example.vue +0 -18
- package/src/components/base/segmented_control/examples/index.js +0 -22
- package/src/components/base/segmented_control/examples/segmented_control.basic.example.vue +0 -19
- package/src/components/base/segmented_control/examples/segmented_control.whitespace.example.vue +0 -18
- package/src/components/base/skeleton_loader/examples/ci_header_skeleton.basic.example.vue +0 -10
- package/src/components/base/skeleton_loader/examples/default_skeleton.basic.example.vue +0 -3
- package/src/components/base/skeleton_loader/examples/default_skeleton_custom_props.basic.example.vue +0 -9
- package/src/components/base/skeleton_loader/examples/index.js +0 -44
- package/src/components/base/skeleton_loader/examples/issue_card_skeleton.basic.example.vue +0 -26
- package/src/components/base/skeleton_loader/examples/job_log_skeleton.basic.example.vue +0 -13
- package/src/components/charts/discrete_scatter/discrete_scatter.md +0 -1
- package/src/components/charts/discrete_scatter/examples/discrete_scatter.basic.example.vue +0 -31
- package/src/components/charts/discrete_scatter/examples/index.js +0 -15
- package/src/components/charts/stacked_column/examples/index.js +0 -15
- package/src/components/charts/stacked_column/examples/stacked_column.basic.example.vue +0 -18
|
@@ -37,7 +37,7 @@ exports[`Paginated List Pagination renders 1 item on page 7 with page size of 2
|
|
|
37
37
|
labelfirstpage="Go to first page"
|
|
38
38
|
labellastpage="Go to last page"
|
|
39
39
|
labelnextpage="Go to next page"
|
|
40
|
-
labelpage="
|
|
40
|
+
labelpage="[Function]"
|
|
41
41
|
labelprevpage="Go to previous page"
|
|
42
42
|
limits="[object Object]"
|
|
43
43
|
nexttext="Next"
|
|
@@ -114,7 +114,7 @@ exports[`Paginated List Pagination renders 3 items on page 2 with default page s
|
|
|
114
114
|
labelfirstpage="Go to first page"
|
|
115
115
|
labellastpage="Go to last page"
|
|
116
116
|
labelnextpage="Go to next page"
|
|
117
|
-
labelpage="
|
|
117
|
+
labelpage="[Function]"
|
|
118
118
|
labelprevpage="Go to previous page"
|
|
119
119
|
limits="[object Object]"
|
|
120
120
|
nexttext="Next"
|
|
@@ -217,7 +217,7 @@ exports[`Paginated List Pagination renders 5 items on page 1 for a page size of
|
|
|
217
217
|
labelfirstpage="Go to first page"
|
|
218
218
|
labellastpage="Go to last page"
|
|
219
219
|
labelnextpage="Go to next page"
|
|
220
|
-
labelpage="
|
|
220
|
+
labelpage="[Function]"
|
|
221
221
|
labelprevpage="Go to previous page"
|
|
222
222
|
limits="[object Object]"
|
|
223
223
|
nexttext="Next"
|
|
@@ -385,7 +385,7 @@ exports[`Paginated List Pagination renders 10 items for a default page size of 1
|
|
|
385
385
|
labelfirstpage="Go to first page"
|
|
386
386
|
labellastpage="Go to last page"
|
|
387
387
|
labelnextpage="Go to next page"
|
|
388
|
-
labelpage="
|
|
388
|
+
labelpage="[Function]"
|
|
389
389
|
labelprevpage="Go to previous page"
|
|
390
390
|
limits="[object Object]"
|
|
391
391
|
nexttext="Next"
|
|
@@ -592,7 +592,7 @@ exports[`Paginated List Pagination renders 13 items for a default page size of 2
|
|
|
592
592
|
labelfirstpage="Go to first page"
|
|
593
593
|
labellastpage="Go to last page"
|
|
594
594
|
labelnextpage="Go to next page"
|
|
595
|
-
labelpage="
|
|
595
|
+
labelpage="[Function]"
|
|
596
596
|
labelprevpage="Go to previous page"
|
|
597
597
|
limits="[object Object]"
|
|
598
598
|
nexttext="Next"
|
|
@@ -712,7 +712,7 @@ exports[`Paginated List Search states renders the list filtered by search result
|
|
|
712
712
|
labelfirstpage="Go to first page"
|
|
713
713
|
labellastpage="Go to last page"
|
|
714
714
|
labelnextpage="Go to next page"
|
|
715
|
-
labelpage="
|
|
715
|
+
labelpage="[Function]"
|
|
716
716
|
labelprevpage="Go to previous page"
|
|
717
717
|
limits="[object Object]"
|
|
718
718
|
nexttext="Next"
|
|
@@ -832,7 +832,7 @@ exports[`Paginated List Searchless states renders the list with nested items, wh
|
|
|
832
832
|
labelfirstpage="Go to first page"
|
|
833
833
|
labellastpage="Go to last page"
|
|
834
834
|
labelnextpage="Go to next page"
|
|
835
|
-
labelpage="
|
|
835
|
+
labelpage="[Function]"
|
|
836
836
|
labelprevpage="Go to previous page"
|
|
837
837
|
limits="[object Object]"
|
|
838
838
|
nexttext="Next"
|
|
@@ -883,7 +883,7 @@ exports[`Paginated List props filter filters on default "id" key 1`] = `
|
|
|
883
883
|
labelfirstpage="Go to first page"
|
|
884
884
|
labellastpage="Go to last page"
|
|
885
885
|
labelnextpage="Go to next page"
|
|
886
|
-
labelpage="
|
|
886
|
+
labelpage="[Function]"
|
|
887
887
|
labelprevpage="Go to previous page"
|
|
888
888
|
limits="[object Object]"
|
|
889
889
|
nexttext="Next"
|
|
@@ -934,7 +934,7 @@ exports[`Paginated List props filter filters on provided "myKey" key 1`] = `
|
|
|
934
934
|
labelfirstpage="Go to first page"
|
|
935
935
|
labellastpage="Go to last page"
|
|
936
936
|
labelnextpage="Go to next page"
|
|
937
|
-
labelpage="
|
|
937
|
+
labelpage="[Function]"
|
|
938
938
|
labelprevpage="Go to previous page"
|
|
939
939
|
limits="[object Object]"
|
|
940
940
|
nexttext="Next"
|
|
@@ -985,7 +985,7 @@ exports[`Paginated List props filter filters with provided filter function 1`] =
|
|
|
985
985
|
labelfirstpage="Go to first page"
|
|
986
986
|
labellastpage="Go to last page"
|
|
987
987
|
labelnextpage="Go to next page"
|
|
988
|
-
labelpage="
|
|
988
|
+
labelpage="[Function]"
|
|
989
989
|
labelprevpage="Go to previous page"
|
|
990
990
|
limits="[object Object]"
|
|
991
991
|
nexttext="Next"
|
|
@@ -1,106 +1,6 @@
|
|
|
1
|
-
import examples from './examples';
|
|
2
1
|
import description from './pagination.md';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
followsDesignSystem: true,
|
|
6
5
|
description,
|
|
7
|
-
examples,
|
|
8
|
-
propsInfo: {
|
|
9
|
-
perPage: {
|
|
10
|
-
additionalInfo: 'Number of items per page',
|
|
11
|
-
},
|
|
12
|
-
totalItems: {
|
|
13
|
-
additionalInfo: 'Total number of items',
|
|
14
|
-
},
|
|
15
|
-
limits: {
|
|
16
|
-
additionalInfo: 'The object must contain the xs, sm, md and default keys',
|
|
17
|
-
},
|
|
18
|
-
linkGen: {
|
|
19
|
-
additionalInfo:
|
|
20
|
-
'A function that receives the page number and that returns a string representing the page URL',
|
|
21
|
-
},
|
|
22
|
-
prevPage: {
|
|
23
|
-
additionalInfo:
|
|
24
|
-
'When using the compact pagination, use this prop to pass the previous page number',
|
|
25
|
-
},
|
|
26
|
-
prevText: {
|
|
27
|
-
additionalInfo: 'Text for the previous button (overridden by "previous" slot)',
|
|
28
|
-
},
|
|
29
|
-
nextPage: {
|
|
30
|
-
additionalInfo:
|
|
31
|
-
'When using the compact pagination, use this prop to pass the next page number',
|
|
32
|
-
},
|
|
33
|
-
nextText: {
|
|
34
|
-
additionalInfo: 'Text for the next button (overridden by "next" slot)',
|
|
35
|
-
},
|
|
36
|
-
ellipsisText: {
|
|
37
|
-
additionalInfo:
|
|
38
|
-
'Text for the ellipsis (overridden by "ellipsis-left" and "ellipsis-right" slots)',
|
|
39
|
-
},
|
|
40
|
-
labelFirstPage: {
|
|
41
|
-
additionalInfo: 'aria-label for the first page item',
|
|
42
|
-
},
|
|
43
|
-
labelPrevPage: {
|
|
44
|
-
additionalInfo: 'aria-label for the previous page item',
|
|
45
|
-
},
|
|
46
|
-
labelNextPage: {
|
|
47
|
-
additionalInfo: 'aria-label for the next page item',
|
|
48
|
-
},
|
|
49
|
-
labelLastPage: {
|
|
50
|
-
additionalInfo: 'aria-label for the last page item',
|
|
51
|
-
},
|
|
52
|
-
labelPage: {
|
|
53
|
-
additionalInfo:
|
|
54
|
-
'aria-label getter for numbered page items, defaults to "Go to page <page_number>"',
|
|
55
|
-
},
|
|
56
|
-
align: {
|
|
57
|
-
additionalInfo:
|
|
58
|
-
'Controls the component\'s horizontal alignment, value should be one of "left", "center", "right" or "fill"',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
events: [
|
|
62
|
-
{
|
|
63
|
-
event: 'input',
|
|
64
|
-
description: 'Emitted when the page changes',
|
|
65
|
-
args: [
|
|
66
|
-
{
|
|
67
|
-
arg: 'value',
|
|
68
|
-
description: 'The page that just got loaded',
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
event: 'next',
|
|
74
|
-
description: 'Emitted when the "next" button is clicked',
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
event: 'previous',
|
|
78
|
-
description: 'Emitted when the "previous" button is clicked',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
slots: [
|
|
82
|
-
{
|
|
83
|
-
name: 'previous',
|
|
84
|
-
description: `Content for the "previous" button. Overrides the "prevText" prop.`,
|
|
85
|
-
scopedProps: `{ active: boolean, disabled: boolean, page: number }`,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: 'next',
|
|
89
|
-
description: `Content for the "next" button. Overrides the "nextText" prop.`,
|
|
90
|
-
scopedProps: `{ active: boolean, disabled: boolean, page: number }`,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: 'page-number',
|
|
94
|
-
description: `Content for page number buttons.`,
|
|
95
|
-
scopedProps: `{ active: boolean, disabled: boolean, page: number }`,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: 'ellipsis-left',
|
|
99
|
-
description: `Content for the left ellipsis. Overrides the "ellipsisText" prop.`,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name: 'ellipsis-right',
|
|
103
|
-
description: `Content for the right ellipsis. Overrides the "ellipsisText" prop.`,
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
6
|
};
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
# Pagination
|
|
2
|
-
|
|
3
|
-
<!-- STORY -->
|
|
4
|
-
|
|
5
1
|
## Current page
|
|
6
2
|
|
|
7
3
|
The current page's value should be bound using `v-model`, e.g.:
|
|
8
4
|
|
|
9
5
|
```html
|
|
10
6
|
<script>
|
|
11
|
-
export default {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
7
|
+
export default {
|
|
8
|
+
data: () => ({
|
|
9
|
+
page: 2,
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
16
12
|
</script>
|
|
17
13
|
|
|
18
14
|
<template>
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { mount
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
2
|
import debounce from 'lodash/debounce';
|
|
3
3
|
import Pagination from './pagination.vue';
|
|
4
4
|
import { breakpoints } from '~/utils/breakpoints';
|
|
5
5
|
|
|
6
6
|
jest.mock('lodash/debounce', () => jest.fn((fn) => fn));
|
|
7
7
|
|
|
8
|
-
const localVue = createLocalVue();
|
|
9
|
-
|
|
10
8
|
const expectClassActive = expect.arrayContaining(['active']);
|
|
11
9
|
const mockResizeWidth = (width) => {
|
|
12
10
|
window.innerWidth = width;
|
|
@@ -29,7 +27,6 @@ describe('pagination component', () => {
|
|
|
29
27
|
itemsPerPage: 20,
|
|
30
28
|
...props,
|
|
31
29
|
},
|
|
32
|
-
localVue,
|
|
33
30
|
...options,
|
|
34
31
|
});
|
|
35
32
|
};
|
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
import { withKnobs, number, text, boolean } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
3
1
|
import { alignOptions } from '../../../utils/constants';
|
|
4
2
|
import readme from './pagination.md';
|
|
5
3
|
import GlPagination from './pagination.vue';
|
|
6
4
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
prevText: {
|
|
14
|
-
default: text('Prev button text', 'Prev'),
|
|
15
|
-
},
|
|
16
|
-
nextText: {
|
|
17
|
-
default: text('Next button text', 'Next'),
|
|
18
|
-
},
|
|
19
|
-
disabled: {
|
|
20
|
-
default: boolean('Disabled', false),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
5
|
+
const generateBaseProps = ({ prevText = 'Prev', nextText = 'Next', disabled = false } = {}) => ({
|
|
6
|
+
prevText,
|
|
7
|
+
nextText,
|
|
8
|
+
disabled,
|
|
9
|
+
});
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
default: number('per page', perPage),
|
|
32
|
-
},
|
|
33
|
-
totalItems: {
|
|
34
|
-
default: number('total items', totalItems),
|
|
35
|
-
},
|
|
36
|
-
...generateBaseProps(),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
11
|
+
const generateFullProps = ({ page = 3, perPage = 10, totalItems = 200 } = {}) => ({
|
|
12
|
+
initialPage: page,
|
|
13
|
+
perPage,
|
|
14
|
+
totalItems,
|
|
15
|
+
...generateBaseProps(),
|
|
16
|
+
});
|
|
39
17
|
|
|
40
18
|
const defaults = {
|
|
41
19
|
data() {
|
|
@@ -51,13 +29,10 @@ const defaults = {
|
|
|
51
29
|
},
|
|
52
30
|
};
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...defaults,
|
|
59
|
-
components,
|
|
60
|
-
template: `<gl-pagination
|
|
32
|
+
export const Default = (args, { argTypes }) => ({
|
|
33
|
+
props: Object.keys(argTypes),
|
|
34
|
+
...defaults,
|
|
35
|
+
template: `<gl-pagination
|
|
61
36
|
v-model="page"
|
|
62
37
|
:per-page="perPage"
|
|
63
38
|
:total-items="totalItems"
|
|
@@ -65,84 +40,101 @@ documentedStoriesOf('base/pagination', readme)
|
|
|
65
40
|
:next-text="nextText"
|
|
66
41
|
:disabled="disabled"
|
|
67
42
|
/>`,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
43
|
+
});
|
|
44
|
+
Default.args = generateFullProps();
|
|
45
|
+
|
|
46
|
+
export const Compact = () => ({
|
|
47
|
+
...defaults,
|
|
48
|
+
props: generateFullProps(),
|
|
49
|
+
data() {
|
|
50
|
+
return {
|
|
51
|
+
page: 1,
|
|
52
|
+
alignOptions,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
computed: {
|
|
56
|
+
prevPage() {
|
|
57
|
+
return Math.max(this.page - 1, 0);
|
|
76
58
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
prevPage() {
|
|
81
|
-
return Math.max(this.page - 1, 0);
|
|
82
|
-
},
|
|
83
|
-
nextPage() {
|
|
84
|
-
const nextPage = this.page + 1;
|
|
85
|
-
return nextPage > 3 ? 0 : nextPage;
|
|
86
|
-
},
|
|
59
|
+
nextPage() {
|
|
60
|
+
const nextPage = this.page + 1;
|
|
61
|
+
return nextPage > 3 ? 0 : nextPage;
|
|
87
62
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<gl-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
63
|
+
},
|
|
64
|
+
template: `
|
|
65
|
+
<div class="text-center gl-font-base">
|
|
66
|
+
<gl-pagination
|
|
67
|
+
v-model="page"
|
|
68
|
+
:prev-page="prevPage"
|
|
69
|
+
:next-page="nextPage"
|
|
70
|
+
:prev-text="prevText"
|
|
71
|
+
:next-text="nextText"
|
|
72
|
+
:disabled="disabled"
|
|
73
|
+
:align="alignOptions.center"
|
|
74
|
+
/>
|
|
75
|
+
Page {{ page }} of 3
|
|
76
|
+
</div>`,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const LinkBased = (args, { argTypes }) => ({
|
|
80
|
+
props: Object.keys(argTypes),
|
|
81
|
+
...defaults,
|
|
82
|
+
methods: {
|
|
83
|
+
linkGen(page) {
|
|
84
|
+
return `/page/${page}`;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
template: `<gl-pagination
|
|
88
|
+
v-model="page"
|
|
89
|
+
:per-page="perPage"
|
|
90
|
+
:total-items="totalItems"
|
|
91
|
+
:prev-text="prevText"
|
|
92
|
+
:next-text="nextText"
|
|
93
|
+
:disabled="disabled"
|
|
94
|
+
:link-gen="linkGen"
|
|
95
|
+
/>`,
|
|
96
|
+
});
|
|
97
|
+
LinkBased.args = generateFullProps();
|
|
98
|
+
|
|
99
|
+
export const AlignCenter = (args, { argTypes }) => ({
|
|
100
|
+
props: Object.keys(argTypes),
|
|
101
|
+
...defaults,
|
|
102
|
+
template: `<gl-pagination
|
|
103
|
+
v-model="page"
|
|
104
|
+
:per-page="perPage"
|
|
105
|
+
:total-items="totalItems"
|
|
106
|
+
:prev-text="prevText"
|
|
107
|
+
:next-text="nextText"
|
|
108
|
+
:disabled="disabled"
|
|
109
|
+
:align="alignOptions.center"
|
|
110
|
+
/>`,
|
|
111
|
+
});
|
|
112
|
+
AlignCenter.args = generateFullProps();
|
|
113
|
+
|
|
114
|
+
export const AlignRight = (args, { argTypes }) => ({
|
|
115
|
+
props: Object.keys(argTypes),
|
|
116
|
+
...defaults,
|
|
117
|
+
template: `<gl-pagination
|
|
118
|
+
v-model="page"
|
|
119
|
+
:per-page="perPage"
|
|
120
|
+
:total-items="totalItems"
|
|
121
|
+
:prev-text="prevText"
|
|
122
|
+
:next-text="nextText"
|
|
123
|
+
:disabled="disabled"
|
|
124
|
+
:align="alignOptions.right"
|
|
125
|
+
/>`,
|
|
126
|
+
});
|
|
127
|
+
AlignRight.args = generateFullProps();
|
|
128
|
+
|
|
129
|
+
export default {
|
|
130
|
+
title: 'base/pagination',
|
|
131
|
+
component: GlPagination,
|
|
132
|
+
parameters: {
|
|
133
|
+
knobs: { disable: true },
|
|
134
|
+
docs: {
|
|
135
|
+
description: {
|
|
136
|
+
component: readme,
|
|
109
137
|
},
|
|
110
138
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
:per-page="perPage"
|
|
114
|
-
:total-items="totalItems"
|
|
115
|
-
:prev-text="prevText"
|
|
116
|
-
:next-text="nextText"
|
|
117
|
-
:disabled="disabled"
|
|
118
|
-
:link-gen="linkGen"
|
|
119
|
-
/>`,
|
|
120
|
-
}))
|
|
121
|
-
.add('align center', () => ({
|
|
122
|
-
props: generateFullProps(),
|
|
123
|
-
...defaults,
|
|
124
|
-
components,
|
|
125
|
-
template: `<gl-pagination
|
|
126
|
-
v-model="page"
|
|
127
|
-
:per-page="perPage"
|
|
128
|
-
:total-items="totalItems"
|
|
129
|
-
:prev-text="prevText"
|
|
130
|
-
:next-text="nextText"
|
|
131
|
-
:disabled="disabled"
|
|
132
|
-
:align="alignOptions.center"
|
|
133
|
-
/>`,
|
|
134
|
-
}))
|
|
135
|
-
.add('align right', () => ({
|
|
136
|
-
props: generateFullProps(),
|
|
137
|
-
...defaults,
|
|
138
|
-
components,
|
|
139
|
-
template: `<gl-pagination
|
|
140
|
-
v-model="page"
|
|
141
|
-
:per-page="perPage"
|
|
142
|
-
:total-items="totalItems"
|
|
143
|
-
:prev-text="prevText"
|
|
144
|
-
:next-text="nextText"
|
|
145
|
-
:disabled="disabled"
|
|
146
|
-
:align="alignOptions.right"
|
|
147
|
-
/>`,
|
|
148
|
-
}));
|
|
139
|
+
},
|
|
140
|
+
};
|
|
@@ -26,17 +26,26 @@ export default {
|
|
|
26
26
|
default: 1,
|
|
27
27
|
validator: (x) => x > 0,
|
|
28
28
|
},
|
|
29
|
+
/**
|
|
30
|
+
* Number of items per page
|
|
31
|
+
*/
|
|
29
32
|
perPage: {
|
|
30
33
|
type: Number,
|
|
31
34
|
required: false,
|
|
32
35
|
default: 20,
|
|
33
36
|
validator: (x) => x > 0,
|
|
34
37
|
},
|
|
38
|
+
/**
|
|
39
|
+
* Total number of items
|
|
40
|
+
*/
|
|
35
41
|
totalItems: {
|
|
36
42
|
type: Number,
|
|
37
43
|
required: false,
|
|
38
44
|
default: 0,
|
|
39
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* The object must contain the xs, sm, md and default keys
|
|
48
|
+
*/
|
|
40
49
|
limits: {
|
|
41
50
|
type: Object,
|
|
42
51
|
required: false,
|
|
@@ -51,61 +60,97 @@ export default {
|
|
|
51
60
|
return missingSizes === 0 ? true : value.default;
|
|
52
61
|
},
|
|
53
62
|
},
|
|
63
|
+
/**
|
|
64
|
+
* A function that receives the page number and that returns a string representing the page URL
|
|
65
|
+
*/
|
|
54
66
|
linkGen: {
|
|
55
67
|
type: Function,
|
|
56
68
|
required: false,
|
|
57
69
|
default: null,
|
|
58
70
|
},
|
|
71
|
+
/**
|
|
72
|
+
* When using the compact pagination, use this prop to pass the previous page number
|
|
73
|
+
*/
|
|
59
74
|
prevPage: {
|
|
60
75
|
type: Number,
|
|
61
76
|
required: false,
|
|
62
77
|
default: null,
|
|
63
78
|
},
|
|
79
|
+
/**
|
|
80
|
+
* Text for the previous button (overridden by "previous" slot)
|
|
81
|
+
*/
|
|
64
82
|
prevText: {
|
|
65
83
|
type: String,
|
|
66
84
|
required: false,
|
|
67
85
|
default: 'Prev',
|
|
68
86
|
},
|
|
87
|
+
/**
|
|
88
|
+
* When using the compact pagination, use this prop to pass the next page number
|
|
89
|
+
*/
|
|
69
90
|
nextPage: {
|
|
70
91
|
type: Number,
|
|
71
92
|
required: false,
|
|
72
93
|
default: null,
|
|
73
94
|
},
|
|
95
|
+
/**
|
|
96
|
+
* Text for the next button (overridden by "next" slot)
|
|
97
|
+
*/
|
|
74
98
|
nextText: {
|
|
75
99
|
type: String,
|
|
76
100
|
required: false,
|
|
77
101
|
default: 'Next',
|
|
78
102
|
},
|
|
103
|
+
/**
|
|
104
|
+
* Text for the ellipsis (overridden by "ellipsis-left" and "ellipsis-right" slots)
|
|
105
|
+
*/
|
|
79
106
|
ellipsisText: {
|
|
80
107
|
type: String,
|
|
81
108
|
required: false,
|
|
82
109
|
default: '…',
|
|
83
110
|
},
|
|
111
|
+
/**
|
|
112
|
+
* aria-label for the first page item
|
|
113
|
+
*/
|
|
84
114
|
labelFirstPage: {
|
|
85
115
|
type: String,
|
|
86
116
|
required: false,
|
|
87
117
|
default: 'Go to first page',
|
|
88
118
|
},
|
|
119
|
+
/**
|
|
120
|
+
* aria-label for the previous page item
|
|
121
|
+
*/
|
|
89
122
|
labelPrevPage: {
|
|
90
123
|
type: String,
|
|
91
124
|
required: false,
|
|
92
125
|
default: 'Go to previous page',
|
|
93
126
|
},
|
|
127
|
+
/**
|
|
128
|
+
* aria-label for the next page item
|
|
129
|
+
*/
|
|
94
130
|
labelNextPage: {
|
|
95
131
|
type: String,
|
|
96
132
|
required: false,
|
|
97
133
|
default: 'Go to next page',
|
|
98
134
|
},
|
|
135
|
+
/**
|
|
136
|
+
* aria-label for the last page item
|
|
137
|
+
*/
|
|
99
138
|
labelLastPage: {
|
|
100
139
|
type: String,
|
|
101
140
|
required: false,
|
|
102
141
|
default: 'Go to last page',
|
|
103
142
|
},
|
|
143
|
+
/**
|
|
144
|
+
* aria-label getter for numbered page items, defaults to "Go to page <page_number>"
|
|
145
|
+
*/
|
|
104
146
|
labelPage: {
|
|
105
147
|
type: Function,
|
|
106
148
|
required: false,
|
|
107
149
|
default: (page) => `Go to page ${page}`,
|
|
108
150
|
},
|
|
151
|
+
/**
|
|
152
|
+
* Controls the component\'s horizontal alignment, value should be one of "left", "center", "right" or "fill"
|
|
153
|
+
*/
|
|
109
154
|
align: {
|
|
110
155
|
type: String,
|
|
111
156
|
required: false,
|
|
@@ -281,15 +326,28 @@ export default {
|
|
|
281
326
|
handleClick(event, value) {
|
|
282
327
|
if (!this.isLinkBased) {
|
|
283
328
|
event.preventDefault();
|
|
329
|
+
/**
|
|
330
|
+
* Emitted when the page changes
|
|
331
|
+
* @event input
|
|
332
|
+
* @arg {number} value The page that just got loaded
|
|
333
|
+
*/
|
|
284
334
|
this.$emit('input', value);
|
|
285
335
|
}
|
|
286
336
|
},
|
|
287
337
|
handlePrevious(event, value) {
|
|
288
338
|
this.handleClick(event, value);
|
|
339
|
+
/**
|
|
340
|
+
* Emitted when the "previous" button is clicked
|
|
341
|
+
* @event previous
|
|
342
|
+
*/
|
|
289
343
|
this.$emit('previous');
|
|
290
344
|
},
|
|
291
345
|
handleNext(event, value) {
|
|
292
346
|
this.handleClick(event, value);
|
|
347
|
+
/**
|
|
348
|
+
* Emitted when the "next" button is clicked
|
|
349
|
+
* @event next
|
|
350
|
+
*/
|
|
293
351
|
this.$emit('next');
|
|
294
352
|
},
|
|
295
353
|
},
|
|
@@ -319,6 +377,12 @@ export default {
|
|
|
319
377
|
:href="isLinkBased ? linkGen(value - 1) : '#'"
|
|
320
378
|
@click="handlePrevious($event, value - 1)"
|
|
321
379
|
>
|
|
380
|
+
<!--
|
|
381
|
+
@slot Content for the "previous" button. Overrides the "prevText" prop.
|
|
382
|
+
@binding {boolean} active
|
|
383
|
+
@binding {boolean} disabled
|
|
384
|
+
@binding {number} number
|
|
385
|
+
-->
|
|
322
386
|
<slot name="previous" v-bind="{ page: value - 1, disabled: prevPageIsDisabled }">
|
|
323
387
|
<gl-icon name="chevron-left" />
|
|
324
388
|
<span>{{ prevText }}</span>
|
|
@@ -342,6 +406,21 @@ export default {
|
|
|
342
406
|
v-bind="item.attrs"
|
|
343
407
|
v-on="item.listeners"
|
|
344
408
|
>
|
|
409
|
+
<!--
|
|
410
|
+
Content for page number buttons.
|
|
411
|
+
@slot page-number
|
|
412
|
+
@binding {boolean} active
|
|
413
|
+
@binding {boolean} disabled
|
|
414
|
+
@binding {number} number
|
|
415
|
+
-->
|
|
416
|
+
<!--
|
|
417
|
+
Content for the left ellipsis. Overrides the "ellipsisText" prop.
|
|
418
|
+
@slot ellipsis-left
|
|
419
|
+
-->
|
|
420
|
+
<!--
|
|
421
|
+
Content for the right ellipsis. Overrides the "ellipsisText" prop.
|
|
422
|
+
@slot ellipsis-right
|
|
423
|
+
-->
|
|
345
424
|
<slot :name="item.slot" v-bind="item.slotData">{{ item.content }}</slot>
|
|
346
425
|
</component>
|
|
347
426
|
</li>
|
|
@@ -361,6 +440,12 @@ export default {
|
|
|
361
440
|
:href="isLinkBased ? linkGen(value + 1) : '#'"
|
|
362
441
|
@click="handleNext($event, value + 1)"
|
|
363
442
|
>
|
|
443
|
+
<!--
|
|
444
|
+
@slot Content for the "next" button. Overrides the "nextText" prop.
|
|
445
|
+
@binding {boolean} active
|
|
446
|
+
@binding {boolean} disabled
|
|
447
|
+
@binding {number} number
|
|
448
|
+
-->
|
|
364
449
|
<slot name="next" v-bind="{ page: value + 1, disabled: nextPageIsDisabled }">
|
|
365
450
|
<span>{{ nextText }}</span>
|
|
366
451
|
<gl-icon name="chevron-right" />
|