@bethinkpl/design-system 18.6.0 → 18.7.1
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/design-system.umd.js +230 -202
- package/dist/design-system.umd.js.map +1 -1
- package/dist/lib/js/components/Drawer/DrawerContent/DrawerContent.vue.d.ts +4 -3
- package/dist/lib/js/components/Drawer/DrawerDivider/DrawerDivider.vue.d.ts +20 -3
- package/dist/lib/js/components/Drawer/DrawerListItemGroup/DrawerListItemGroup.vue.d.ts +4 -3
- package/dist/lib/js/components/Drawer/DrawerSection/DrawerSection.vue.d.ts +230 -3
- package/dist/lib/js/components/Drawer/DrawerTile/DrawerTile.vue.d.ts +63 -3
- package/dist/lib/js/components/Dropdown/Dropdown.vue.d.ts +8 -0
- package/dist/lib/js/components/Pagination/Pagination.vue.d.ts +15 -0
- package/dist/lib/js/components/SelectList/SelectListItemTile/SelectListItemTile.vue.d.ts +62 -3
- package/dist/lib/js/components/SelectList/SelectListSectionTitle/SelectListSectionTitle.vue.d.ts +14 -3
- package/dist/lib/js/components/Tile/Tile.consts.d.ts +2 -0
- package/docs/iframe.html +1 -1
- package/docs/main.ef9c4703.iframe.bundle.js +1 -0
- package/docs/project.json +1 -1
- package/jest.config.js +1 -0
- package/lib/js/components/Dropdown/Dropdown.stories.ts +22 -12
- package/lib/js/components/Dropdown/Dropdown.vue +36 -4
- package/lib/js/components/Pagination/Pagination.spec.ts +115 -0
- package/lib/js/components/Pagination/Pagination.vue +71 -17
- package/lib/js/components/SelectList/SelectListItem/SelectListItem.stories.ts +6 -2
- package/lib/js/components/SelectList/SelectListItem/SelectListItem.vue +44 -3
- package/lib/js/components/SelectList/SelectListItemTile/SelectListItemTile.vue +18 -76
- package/lib/js/components/Tile/Tile.consts.ts +2 -0
- package/lib/js/components/Tile/Tile.vue +34 -0
- package/package.json +2 -2
- package/docs/main.9ebcaa8a.iframe.bundle.js +0 -1
package/docs/project.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"generatedAt":
|
|
1
|
+
{"generatedAt":1696404157704,"builder":{"name":"webpack5"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":true,"refCount":0,"metaFramework":{"name":"vue-cli","packageName":"@vue/cli-service","version":"5.0.4"},"packageManager":{"type":"yarn","version":"1.22.19"},"storybookVersion":"6.5.13","language":"typescript","storybookPackages":{"@storybook/builder-webpack5":{"version":"6.5.13"},"@storybook/manager-webpack5":{"version":"6.5.13"},"@storybook/vue3":{"version":"6.5.13"},"eslint-plugin-storybook":{"version":"0.6.6"}},"framework":{"name":"vue3"},"addons":{"@storybook/addon-actions":{"version":"6.5.16"},"@storybook/addon-docs":{"version":"6.5.15"},"@storybook/addon-controls":{"version":"6.5.15"},"@storybook/addon-storysource":{"version":"6.5.15"},"@storybook/addon-viewport":{"version":"6.5.15"},"storybook-addon-designs":{"version":"6.3.1"}}}
|
package/jest.config.js
CHANGED
|
@@ -6,6 +6,7 @@ module.exports = {
|
|
|
6
6
|
'^design-system/lib/(.*)$': '<rootDir>/lib/$1',
|
|
7
7
|
'^design-system/styles/(.*)$': '<rootDir>/lib/styles/$1',
|
|
8
8
|
'^design-system/images/(.*)$': '<rootDir>/lib/images/$1',
|
|
9
|
+
'^vue-popperjs/dist/vue-popper.css': '<rootDir>/lib/js/tests/emptyModule.ts',
|
|
9
10
|
},
|
|
10
11
|
testMatch: ['<rootDir>/lib/js/**/*.spec.ts', '<rootDir>/tools/importers/*.spec.ts'],
|
|
11
12
|
transform: {
|
|
@@ -20,18 +20,23 @@ const StoryTemplate: StoryFn<typeof Dropdown> = (args) => ({
|
|
|
20
20
|
return { ...args };
|
|
21
21
|
},
|
|
22
22
|
template: `
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
<div style="position: relative">
|
|
24
|
+
<dropdown :trigger-action="triggerAction"
|
|
25
|
+
:force-show="forceShow"
|
|
26
|
+
:same-width="sameWidth"
|
|
27
|
+
:radius="radius"
|
|
28
|
+
:placement="placement"
|
|
29
|
+
:max-height="maxHeight">
|
|
30
|
+
<template #reference="{ isOpened }"><span>Dropdown entry point {{ isOpened ? 'opened' : 'closed' }}</span>
|
|
31
|
+
</template>
|
|
32
|
+
<template #default="{ close }">
|
|
33
|
+
<select-list>
|
|
34
|
+
<select-list-item label="One" @click.native="close" />
|
|
35
|
+
<select-list-item label="Two" @click.native="close" />
|
|
36
|
+
</select-list>
|
|
37
|
+
</template>
|
|
38
|
+
</dropdown>
|
|
39
|
+
</div>`,
|
|
35
40
|
});
|
|
36
41
|
|
|
37
42
|
export const Interactive = StoryTemplate.bind({});
|
|
@@ -41,6 +46,7 @@ const args = {
|
|
|
41
46
|
radius: DROPDOWN_RADIUSES.BOTH,
|
|
42
47
|
forceShow: false,
|
|
43
48
|
sameWidth: false,
|
|
49
|
+
maxHeight: '',
|
|
44
50
|
} as Args;
|
|
45
51
|
|
|
46
52
|
const argTypes = {
|
|
@@ -56,6 +62,10 @@ const argTypes = {
|
|
|
56
62
|
control: { type: 'select', options: Object.values(DROPDOWN_PLACEMENTS) },
|
|
57
63
|
defaultValue: DROPDOWN_PLACEMENTS.BOTTOM_START,
|
|
58
64
|
},
|
|
65
|
+
maxHeight: {
|
|
66
|
+
control: { type: 'text' },
|
|
67
|
+
defaultValue: '',
|
|
68
|
+
},
|
|
59
69
|
} as ArgTypes;
|
|
60
70
|
|
|
61
71
|
Interactive.argTypes = argTypes;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
:trigger="triggerAction"
|
|
10
10
|
:delay-on-mouse-out="300"
|
|
11
11
|
@document-click="$emit('document-click')"
|
|
12
|
-
@hide="
|
|
13
|
-
@show="
|
|
12
|
+
@hide="onHide"
|
|
13
|
+
@show="onShow"
|
|
14
14
|
>
|
|
15
15
|
<div
|
|
16
16
|
class="popper dsDropdown"
|
|
@@ -20,11 +20,17 @@
|
|
|
20
20
|
'-radiusBottom -radiusTop': radius === DROPDOWN_RADIUSES.BOTH,
|
|
21
21
|
}"
|
|
22
22
|
>
|
|
23
|
-
<
|
|
23
|
+
<div
|
|
24
|
+
class="dsDropdown__scrollableWrapper"
|
|
25
|
+
:class="{ '-heightLimited': !!maxHeight }"
|
|
26
|
+
:style="scrollableWrapperStyles"
|
|
27
|
+
>
|
|
28
|
+
<slot :close="close" />
|
|
29
|
+
</div>
|
|
24
30
|
</div>
|
|
25
31
|
|
|
26
32
|
<template #reference>
|
|
27
|
-
<slot name="reference" />
|
|
33
|
+
<slot name="reference" :is-opened="isOpened" />
|
|
28
34
|
</template>
|
|
29
35
|
</vue-popper>
|
|
30
36
|
</template>
|
|
@@ -42,6 +48,7 @@
|
|
|
42
48
|
box-shadow: $shadow-m;
|
|
43
49
|
max-width: 100%;
|
|
44
50
|
min-width: 128px;
|
|
51
|
+
overflow: hidden;
|
|
45
52
|
padding: 0;
|
|
46
53
|
text-align: left;
|
|
47
54
|
|
|
@@ -62,6 +69,12 @@
|
|
|
62
69
|
&[x-placement^='top'] {
|
|
63
70
|
margin-bottom: $space-xxxxs;
|
|
64
71
|
}
|
|
72
|
+
|
|
73
|
+
&__scrollableWrapper {
|
|
74
|
+
&.-heightLimited {
|
|
75
|
+
overflow-y: auto;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
65
78
|
}
|
|
66
79
|
</style>
|
|
67
80
|
|
|
@@ -113,15 +126,25 @@ export default {
|
|
|
113
126
|
return Object.values(DROPDOWN_PLACEMENTS).includes(placement);
|
|
114
127
|
},
|
|
115
128
|
},
|
|
129
|
+
maxHeight: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: null,
|
|
132
|
+
},
|
|
116
133
|
},
|
|
117
134
|
emits: ['document-click', 'hide', 'show'],
|
|
118
135
|
data() {
|
|
119
136
|
return {
|
|
120
137
|
key: 1,
|
|
138
|
+
isOpened: false,
|
|
121
139
|
DROPDOWN_RADIUSES: Object.freeze(DROPDOWN_RADIUSES),
|
|
122
140
|
};
|
|
123
141
|
},
|
|
124
142
|
computed: {
|
|
143
|
+
scrollableWrapperStyles() {
|
|
144
|
+
return {
|
|
145
|
+
...(this.maxHeight && { maxHeight: this.maxHeight }),
|
|
146
|
+
};
|
|
147
|
+
},
|
|
125
148
|
options() {
|
|
126
149
|
return {
|
|
127
150
|
modifiers: { preventOverflow: { padding: 0 } },
|
|
@@ -153,6 +176,7 @@ export default {
|
|
|
153
176
|
},
|
|
154
177
|
methods: {
|
|
155
178
|
close() {
|
|
179
|
+
this.isOpened = false;
|
|
156
180
|
this.$refs.popper.doClose();
|
|
157
181
|
},
|
|
158
182
|
updateKey() {
|
|
@@ -160,6 +184,14 @@ export default {
|
|
|
160
184
|
// vue-popperjs doesn't support changing props in existing component
|
|
161
185
|
this.key++;
|
|
162
186
|
},
|
|
187
|
+
onHide() {
|
|
188
|
+
this.isOpened = false;
|
|
189
|
+
this.$emit('hide');
|
|
190
|
+
},
|
|
191
|
+
onShow() {
|
|
192
|
+
this.isOpened = true;
|
|
193
|
+
this.$emit('show');
|
|
194
|
+
},
|
|
163
195
|
},
|
|
164
196
|
};
|
|
165
197
|
</script>
|
|
@@ -9,6 +9,19 @@ describe('Pagination', () => {
|
|
|
9
9
|
currentPage,
|
|
10
10
|
itemsTotalAmount,
|
|
11
11
|
} as any,
|
|
12
|
+
global: {
|
|
13
|
+
stubs: {
|
|
14
|
+
Dropdown: {
|
|
15
|
+
template: '<div class="dropdown"><slot name="reference" /><slot/></div>',
|
|
16
|
+
},
|
|
17
|
+
SelectList: {
|
|
18
|
+
template: '<div class="select-list"><slot/></div>',
|
|
19
|
+
},
|
|
20
|
+
SelectListItem: {
|
|
21
|
+
template: '<div class="select-list-item"><slot/></div>',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
12
25
|
});
|
|
13
26
|
};
|
|
14
27
|
|
|
@@ -98,10 +111,112 @@ describe('Pagination', () => {
|
|
|
98
111
|
},
|
|
99
112
|
])('should calculate correct pagination for %o', ({ props, expected }) => {
|
|
100
113
|
const component = createComponent(props);
|
|
114
|
+
|
|
101
115
|
const elements: Array<string> = [];
|
|
102
116
|
component.findAll('.ds-pagination__itemWrapper').forEach((element) => {
|
|
103
117
|
elements.push(element.text().trim());
|
|
104
118
|
});
|
|
105
119
|
expect(elements).toEqual(expected);
|
|
106
120
|
});
|
|
121
|
+
|
|
122
|
+
test.each([
|
|
123
|
+
{
|
|
124
|
+
props: {
|
|
125
|
+
currentPage: 3,
|
|
126
|
+
itemsTotalAmount: 300,
|
|
127
|
+
},
|
|
128
|
+
expected: {
|
|
129
|
+
dropdowns: 1,
|
|
130
|
+
dropdownItemsCount: 10,
|
|
131
|
+
dropdownItems: [
|
|
132
|
+
{ label: '1 (1 - 30)', isSelected: 'false' },
|
|
133
|
+
{ label: '2 (31 - 60)', isSelected: 'false' },
|
|
134
|
+
{ label: '3 (61 - 90)', isSelected: 'true' },
|
|
135
|
+
{ label: '4 (91 - 120)', isSelected: 'false' },
|
|
136
|
+
{ label: '5 (121 - 150)', isSelected: 'false' },
|
|
137
|
+
{ label: '6 (151 - 180)', isSelected: 'false' },
|
|
138
|
+
{ label: '7 (181 - 210)', isSelected: 'false' },
|
|
139
|
+
{ label: '8 (211 - 240)', isSelected: 'false' },
|
|
140
|
+
{ label: '9 (241 - 270)', isSelected: 'false' },
|
|
141
|
+
{ label: '10 (271 - 300)', isSelected: 'false' },
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
props: {
|
|
147
|
+
currentPage: 3,
|
|
148
|
+
itemsTotalAmount: 221,
|
|
149
|
+
},
|
|
150
|
+
expected: {
|
|
151
|
+
dropdowns: 1,
|
|
152
|
+
dropdownItemsCount: 8,
|
|
153
|
+
dropdownItems: [
|
|
154
|
+
{ label: '1 (1 - 30)', isSelected: 'false' },
|
|
155
|
+
{ label: '2 (31 - 60)', isSelected: 'false' },
|
|
156
|
+
{ label: '3 (61 - 90)', isSelected: 'true' },
|
|
157
|
+
{ label: '4 (91 - 120)', isSelected: 'false' },
|
|
158
|
+
{ label: '5 (121 - 150)', isSelected: 'false' },
|
|
159
|
+
{ label: '6 (151 - 180)', isSelected: 'false' },
|
|
160
|
+
{ label: '7 (181 - 210)', isSelected: 'false' },
|
|
161
|
+
{ label: '8 (211 - 221)', isSelected: 'false' },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
props: {
|
|
167
|
+
currentPage: 6,
|
|
168
|
+
itemsTotalAmount: 311,
|
|
169
|
+
},
|
|
170
|
+
expected: {
|
|
171
|
+
dropdowns: 2,
|
|
172
|
+
dropdownItemsCount: 11,
|
|
173
|
+
dropdownItems: [
|
|
174
|
+
{ label: '1 (1 - 30)', isSelected: 'false' },
|
|
175
|
+
{ label: '2 (31 - 60)', isSelected: 'false' },
|
|
176
|
+
{ label: '3 (61 - 90)', isSelected: 'false' },
|
|
177
|
+
{ label: '4 (91 - 120)', isSelected: 'false' },
|
|
178
|
+
{ label: '5 (121 - 150)', isSelected: 'false' },
|
|
179
|
+
{ label: '6 (151 - 180)', isSelected: 'true' },
|
|
180
|
+
{ label: '7 (181 - 210)', isSelected: 'false' },
|
|
181
|
+
{ label: '8 (211 - 240)', isSelected: 'false' },
|
|
182
|
+
{ label: '9 (241 - 270)', isSelected: 'false' },
|
|
183
|
+
{ label: '10 (271 - 300)', isSelected: 'false' },
|
|
184
|
+
{ label: '11 (301 - 311)', isSelected: 'false' },
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
])('should render dropdown for %o', ({ props, expected }) => {
|
|
189
|
+
const component = createComponent(props);
|
|
190
|
+
|
|
191
|
+
expect(component.findAll('.dropdown').length).toBe(expected.dropdowns);
|
|
192
|
+
|
|
193
|
+
const dropdown = component.find('.dropdown');
|
|
194
|
+
expect(dropdown.findAll('.select-list-item').length).toBe(expected.dropdownItemsCount);
|
|
195
|
+
|
|
196
|
+
dropdown.findAll('.select-list-item').forEach((item, index) => {
|
|
197
|
+
expect(item.attributes('label')).toBe(expected.dropdownItems[index].label);
|
|
198
|
+
expect(item.attributes('is-selected')).toBe(expected.dropdownItems[index].isSelected);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('should update selected item after page change', async () => {
|
|
203
|
+
let currentPage = 3;
|
|
204
|
+
const component = createComponent({
|
|
205
|
+
currentPage,
|
|
206
|
+
itemsTotalAmount: 300,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const dropdown = component.find('.dropdown');
|
|
210
|
+
expect(
|
|
211
|
+
dropdown.findAll('.select-list-item')[currentPage - 1].attributes('is-selected'),
|
|
212
|
+
).toBe('true');
|
|
213
|
+
|
|
214
|
+
await component.setProps({ currentPage: 1 });
|
|
215
|
+
|
|
216
|
+
expect(component.findAll('.select-list-item')[0].attributes('is-selected')).toBe('true');
|
|
217
|
+
|
|
218
|
+
expect(
|
|
219
|
+
component.findAll('.select-list-item')[currentPage - 1].attributes('is-selected'),
|
|
220
|
+
).toBe('false');
|
|
221
|
+
});
|
|
107
222
|
});
|
|
@@ -27,8 +27,42 @@
|
|
|
27
27
|
{{ navigationItem }}
|
|
28
28
|
</span>
|
|
29
29
|
</div>
|
|
30
|
-
<div v-else :key="`ellipsis${index}`"
|
|
31
|
-
<
|
|
30
|
+
<div v-else :key="`ellipsis${index}`">
|
|
31
|
+
<dropdown
|
|
32
|
+
:radius="DROPDOWN_RADIUSES.BOTTOM"
|
|
33
|
+
max-height="250px"
|
|
34
|
+
:placement="
|
|
35
|
+
ellipsisAsSecond(index)
|
|
36
|
+
? DROPDOWN_PLACEMENTS.BOTTOM_START
|
|
37
|
+
: DROPDOWN_PLACEMENTS.BOTTOM_END
|
|
38
|
+
"
|
|
39
|
+
>
|
|
40
|
+
<template #reference="{ isOpened }">
|
|
41
|
+
<div class="ds-pagination__itemWrapper -touchable">
|
|
42
|
+
<span
|
|
43
|
+
class="ds-pagination__item"
|
|
44
|
+
:class="{ '-selected': isOpened }"
|
|
45
|
+
>…</span
|
|
46
|
+
>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<template #default="{ close }">
|
|
51
|
+
<select-list v-if="navigationItemsForDropdown.length">
|
|
52
|
+
<select-list-item
|
|
53
|
+
v-for="(
|
|
54
|
+
dropdownNavigationItem, dropdownIndex
|
|
55
|
+
) in navigationItemsForDropdown"
|
|
56
|
+
:key="dropdownIndex"
|
|
57
|
+
:label="dropdownNavigationItem.label"
|
|
58
|
+
:is-selected="currentPage === dropdownNavigationItem.value"
|
|
59
|
+
@click="
|
|
60
|
+
onDropdownClick(dropdownNavigationItem.value, close)
|
|
61
|
+
"
|
|
62
|
+
/>
|
|
63
|
+
</select-list>
|
|
64
|
+
</template>
|
|
65
|
+
</dropdown>
|
|
32
66
|
</div>
|
|
33
67
|
</template>
|
|
34
68
|
</div>
|
|
@@ -164,10 +198,10 @@ $pagination-input-height: 32px;
|
|
|
164
198
|
}
|
|
165
199
|
|
|
166
200
|
&__text {
|
|
167
|
-
@include
|
|
201
|
+
@include label-l-default-regular;
|
|
168
202
|
|
|
169
203
|
color: $color-neutral-text;
|
|
170
|
-
padding: $space-xxxs;
|
|
204
|
+
padding: $space-xxs $space-xxxs;
|
|
171
205
|
text-align: center;
|
|
172
206
|
}
|
|
173
207
|
|
|
@@ -178,7 +212,7 @@ $pagination-input-height: 32px;
|
|
|
178
212
|
}
|
|
179
213
|
|
|
180
214
|
&__itemWrapper {
|
|
181
|
-
@include
|
|
215
|
+
@include label-l-default-regular;
|
|
182
216
|
|
|
183
217
|
padding: $space-xxxxs;
|
|
184
218
|
text-align: center;
|
|
@@ -201,10 +235,10 @@ $pagination-input-height: 32px;
|
|
|
201
235
|
flex-direction: column;
|
|
202
236
|
justify-content: center;
|
|
203
237
|
min-width: $pagination-item-min-width;
|
|
204
|
-
padding: $space-
|
|
238
|
+
padding: $space-xxs;
|
|
205
239
|
|
|
206
240
|
&.-selected {
|
|
207
|
-
@include
|
|
241
|
+
@include label-l-default-bold;
|
|
208
242
|
|
|
209
243
|
background: $color-neutral-background-medium;
|
|
210
244
|
color: $color-neutral-text-heavy;
|
|
@@ -216,15 +250,6 @@ $pagination-input-height: 32px;
|
|
|
216
250
|
}
|
|
217
251
|
}
|
|
218
252
|
|
|
219
|
-
&__ellipsis {
|
|
220
|
-
align-items: center;
|
|
221
|
-
color: $color-neutral-text-weak;
|
|
222
|
-
display: flex;
|
|
223
|
-
flex-direction: column;
|
|
224
|
-
justify-content: center;
|
|
225
|
-
padding: $space-xxxs;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
253
|
&__accessorySlot {
|
|
229
254
|
align-items: center;
|
|
230
255
|
display: flex;
|
|
@@ -240,13 +265,19 @@ import IconButton from '../Buttons/IconButton/IconButton.vue';
|
|
|
240
265
|
import { ICON_BUTTON_COLORS, ICON_BUTTON_SIZES, ICON_BUTTON_STATES } from '../Buttons/IconButton';
|
|
241
266
|
import { ICONS } from '../Icons/Icon';
|
|
242
267
|
|
|
268
|
+
import { DROPDOWN_PLACEMENTS, DROPDOWN_RADIUSES } from '../Dropdown/Dropdown.consts';
|
|
269
|
+
import Dropdown from '../Dropdown/Dropdown.vue';
|
|
270
|
+
|
|
271
|
+
import SelectList from '../SelectList/SelectList.vue';
|
|
272
|
+
import SelectListItem from '../SelectList/SelectListItem/SelectListItem.vue';
|
|
273
|
+
|
|
243
274
|
const MAX_NAVIGATION_ITEMS = 7;
|
|
244
275
|
const ELLIPSIS_FILL = 'ellipsis';
|
|
245
276
|
const FIRST_PAGE_NUMBER = 1;
|
|
246
277
|
|
|
247
278
|
export default {
|
|
248
279
|
name: 'Pagination',
|
|
249
|
-
components: { IconButton },
|
|
280
|
+
components: { IconButton, Dropdown, SelectListItem, SelectList },
|
|
250
281
|
props: {
|
|
251
282
|
currentPage: {
|
|
252
283
|
type: Number,
|
|
@@ -278,6 +309,8 @@ export default {
|
|
|
278
309
|
emits: ['change-page'],
|
|
279
310
|
data() {
|
|
280
311
|
return {
|
|
312
|
+
DROPDOWN_PLACEMENTS: Object.freeze(DROPDOWN_PLACEMENTS),
|
|
313
|
+
DROPDOWN_RADIUSES: Object.freeze(DROPDOWN_RADIUSES),
|
|
281
314
|
ICON_BUTTON_SIZES: Object.freeze(ICON_BUTTON_SIZES),
|
|
282
315
|
ICON_BUTTON_COLORS: Object.freeze(ICON_BUTTON_COLORS),
|
|
283
316
|
ICON_BUTTON_STATES: Object.freeze(ICON_BUTTON_STATES),
|
|
@@ -333,8 +366,25 @@ export default {
|
|
|
333
366
|
|
|
334
367
|
return navigationItems;
|
|
335
368
|
},
|
|
369
|
+
navigationItemsForDropdown() {
|
|
370
|
+
return this.getRange(FIRST_PAGE_NUMBER, this.lastPage).map((pageNumber: number) => {
|
|
371
|
+
const startItem = (pageNumber - 1) * this.itemsPerPage;
|
|
372
|
+
const endItem =
|
|
373
|
+
pageNumber < this.lastPage
|
|
374
|
+
? startItem + this.itemsPerPage
|
|
375
|
+
: this.itemsTotalAmount;
|
|
376
|
+
|
|
377
|
+
return {
|
|
378
|
+
label: `${pageNumber} (${startItem + 1} - ${endItem})`,
|
|
379
|
+
value: pageNumber,
|
|
380
|
+
};
|
|
381
|
+
});
|
|
382
|
+
},
|
|
336
383
|
},
|
|
337
384
|
methods: {
|
|
385
|
+
ellipsisAsSecond(index: number) {
|
|
386
|
+
return index === 1;
|
|
387
|
+
},
|
|
338
388
|
getRange(start: number, end: number): Array<number> {
|
|
339
389
|
return Array(end - start + 1)
|
|
340
390
|
.fill(null)
|
|
@@ -355,6 +405,10 @@ export default {
|
|
|
355
405
|
|
|
356
406
|
this.changePage(page);
|
|
357
407
|
},
|
|
408
|
+
onDropdownClick(page: number, close: () => void) {
|
|
409
|
+
this.changePage(page);
|
|
410
|
+
close();
|
|
411
|
+
},
|
|
358
412
|
},
|
|
359
413
|
};
|
|
360
414
|
</script>
|
|
@@ -3,9 +3,9 @@ import { ICONS } from '../../Icons/Icon';
|
|
|
3
3
|
|
|
4
4
|
import { Args, ArgTypes, Meta, StoryFn } from '@storybook/vue3';
|
|
5
5
|
import {
|
|
6
|
-
SELECT_LIST_ITEM_STATES,
|
|
7
|
-
SELECT_LIST_ITEM_SIZES,
|
|
8
6
|
SELECT_LIST_ITEM_SELECTION_MODE,
|
|
7
|
+
SELECT_LIST_ITEM_SIZES,
|
|
8
|
+
SELECT_LIST_ITEM_STATES,
|
|
9
9
|
} from './SelectListItem.consts';
|
|
10
10
|
|
|
11
11
|
export default {
|
|
@@ -22,6 +22,8 @@ const StoryTemplate: StoryFn<typeof SelectListItem> = (args) => ({
|
|
|
22
22
|
<select-list-item
|
|
23
23
|
:icon-left="ICONS[iconLeft]"
|
|
24
24
|
:label="label"
|
|
25
|
+
:eyebrow-text="eyebrowText"
|
|
26
|
+
:is-eyebrow-text-uppercase="isEyebrowTextUppercase"
|
|
25
27
|
:is-selected="isSelected"
|
|
26
28
|
:selection-mode="selectionMode"
|
|
27
29
|
:size="size"
|
|
@@ -41,6 +43,8 @@ const args = {
|
|
|
41
43
|
size: SELECT_LIST_ITEM_SIZES.SMALL,
|
|
42
44
|
iconLeft: null,
|
|
43
45
|
label: 'Label',
|
|
46
|
+
eyebrowText: 'Eyebrow Text',
|
|
47
|
+
isEyebrowTextUppercase: false,
|
|
44
48
|
state: SELECT_LIST_ITEM_STATES.DEFAULT,
|
|
45
49
|
isSelected: false,
|
|
46
50
|
selectionMode: SELECT_LIST_ITEM_SELECTION_MODE.SELECT_ONLY,
|
|
@@ -18,7 +18,15 @@
|
|
|
18
18
|
:spinning="isLoading"
|
|
19
19
|
/>
|
|
20
20
|
|
|
21
|
-
<span class="
|
|
21
|
+
<span class="selectListItem__textWrapper">
|
|
22
|
+
<span
|
|
23
|
+
v-if="eyebrowText"
|
|
24
|
+
class="selectListItem__eyebrowText"
|
|
25
|
+
:class="{ '-uppercase': isEyebrowTextUppercase }"
|
|
26
|
+
>{{ eyebrowText }}</span
|
|
27
|
+
>
|
|
28
|
+
<span class="selectListItem__text">{{ label }}</span>
|
|
29
|
+
</span>
|
|
22
30
|
|
|
23
31
|
<ds-icon
|
|
24
32
|
v-if="isSelected"
|
|
@@ -38,6 +46,7 @@
|
|
|
38
46
|
|
|
39
47
|
.selectListItem {
|
|
40
48
|
$self: &;
|
|
49
|
+
$minHeight: 40px;
|
|
41
50
|
|
|
42
51
|
@include label-l-default-regular;
|
|
43
52
|
|
|
@@ -45,6 +54,7 @@
|
|
|
45
54
|
color: $color-neutral-text-heavy;
|
|
46
55
|
cursor: pointer;
|
|
47
56
|
display: flex;
|
|
57
|
+
min-height: $minHeight;
|
|
48
58
|
padding: $space-xs;
|
|
49
59
|
|
|
50
60
|
&:focus {
|
|
@@ -104,13 +114,32 @@
|
|
|
104
114
|
width: $icon-xs;
|
|
105
115
|
}
|
|
106
116
|
|
|
107
|
-
&
|
|
117
|
+
&__textWrapper {
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-direction: column;
|
|
108
120
|
flex-grow: 1;
|
|
121
|
+
gap: $space-xxxxxs;
|
|
109
122
|
overflow: hidden;
|
|
110
|
-
text-overflow: ellipsis;
|
|
111
123
|
white-space: nowrap;
|
|
112
124
|
}
|
|
113
125
|
|
|
126
|
+
&__text {
|
|
127
|
+
overflow: hidden;
|
|
128
|
+
text-overflow: ellipsis;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&__eyebrowText {
|
|
132
|
+
@include info-s-default-bold;
|
|
133
|
+
|
|
134
|
+
color: $color-neutral-text-weak;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
text-overflow: ellipsis;
|
|
137
|
+
|
|
138
|
+
&.-uppercase {
|
|
139
|
+
@include info-s-extensive-bold-uppercase;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
114
143
|
&.-disabled {
|
|
115
144
|
#{$self}__iconLeft {
|
|
116
145
|
color: $color-neutral-icon-disabled;
|
|
@@ -123,6 +152,10 @@
|
|
|
123
152
|
#{$self}__text {
|
|
124
153
|
color: $color-neutral-text-heavy-disabled;
|
|
125
154
|
}
|
|
155
|
+
|
|
156
|
+
#{$self}__eyebrowText {
|
|
157
|
+
color: $color-neutral-text-weak-disabled;
|
|
158
|
+
}
|
|
126
159
|
}
|
|
127
160
|
}
|
|
128
161
|
</style>
|
|
@@ -157,6 +190,14 @@ export default {
|
|
|
157
190
|
type: String,
|
|
158
191
|
required: true,
|
|
159
192
|
},
|
|
193
|
+
eyebrowText: {
|
|
194
|
+
type: String,
|
|
195
|
+
default: '',
|
|
196
|
+
},
|
|
197
|
+
isEyebrowTextUppercase: {
|
|
198
|
+
type: Boolean,
|
|
199
|
+
default: false,
|
|
200
|
+
},
|
|
160
201
|
selectionMode: {
|
|
161
202
|
type: String,
|
|
162
203
|
default: SELECT_LIST_ITEM_SELECTION_MODE.SELECT_ONLY,
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
<div class="selectListItemTile">
|
|
3
|
+
<ds-tile
|
|
4
|
+
:interactive="interactive"
|
|
5
|
+
:icon-left="iconLeft"
|
|
6
|
+
:icon-right="iconRight"
|
|
7
|
+
:text="text"
|
|
8
|
+
:eyebrow-text="eyebrowText"
|
|
9
|
+
:additional-text="additionalText"
|
|
10
|
+
:color="color"
|
|
11
|
+
:is-eyebrow-text-uppercase="isEyebrowTextUppercase"
|
|
12
|
+
:state="state"
|
|
13
|
+
:eyebrow-ellipsis="eyebrowEllipsis"
|
|
14
|
+
:text-ellipsis="textEllipsis"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
16
17
|
</template>
|
|
17
18
|
|
|
18
19
|
<style scoped lang="scss">
|
|
@@ -24,73 +25,14 @@
|
|
|
24
25
|
</style>
|
|
25
26
|
|
|
26
27
|
<script lang="ts">
|
|
27
|
-
import Tile
|
|
28
|
-
import {
|
|
29
|
-
import { toRaw } from 'vue';
|
|
30
|
-
import { Value } from 'utils/type.utils';
|
|
28
|
+
import Tile from '../../Tile';
|
|
29
|
+
import { props } from '../../Tile/Tile.shared';
|
|
31
30
|
|
|
32
31
|
export default {
|
|
33
32
|
name: 'SelectListItemTile',
|
|
34
33
|
components: {
|
|
35
34
|
DsTile: Tile,
|
|
36
35
|
},
|
|
37
|
-
props
|
|
38
|
-
interactive: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: false,
|
|
41
|
-
},
|
|
42
|
-
iconLeft: {
|
|
43
|
-
type: Object,
|
|
44
|
-
default: null,
|
|
45
|
-
validator(iconLeft) {
|
|
46
|
-
return Object.values(ICONS).includes(toRaw(iconLeft));
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
iconRight: {
|
|
50
|
-
type: Object,
|
|
51
|
-
default: null,
|
|
52
|
-
validator(iconRight) {
|
|
53
|
-
return Object.values(ICONS).includes(toRaw(iconRight));
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
text: {
|
|
57
|
-
type: String,
|
|
58
|
-
required: true,
|
|
59
|
-
},
|
|
60
|
-
eyebrowText: {
|
|
61
|
-
type: String,
|
|
62
|
-
required: true,
|
|
63
|
-
},
|
|
64
|
-
additionalText: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: null,
|
|
67
|
-
},
|
|
68
|
-
color: {
|
|
69
|
-
type: String,
|
|
70
|
-
default: TILE_COLORS.NEUTRAL,
|
|
71
|
-
validator(color) {
|
|
72
|
-
return Object.values(TILE_COLORS).includes(color);
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
isEyebrowTextUppercase: {
|
|
76
|
-
type: Boolean,
|
|
77
|
-
default: false,
|
|
78
|
-
},
|
|
79
|
-
state: {
|
|
80
|
-
type: String,
|
|
81
|
-
default: TILE_STATES.DEFAULT,
|
|
82
|
-
validator(value: Value<typeof TILE_STATES>) {
|
|
83
|
-
return Object.values(TILE_STATES).includes(value);
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
eyebrowEllipsis: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: true,
|
|
89
|
-
},
|
|
90
|
-
textEllipsis: {
|
|
91
|
-
type: Boolean,
|
|
92
|
-
default: true,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
36
|
+
props,
|
|
95
37
|
};
|
|
96
38
|
</script>
|