@aleph-alpha/ui-library 7.1.0 → 7.2.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/system/components/UiPagination/UiPagination.vue.d.ts +19 -0
- package/dist/system/components/UiPagination/constants.d.ts +6 -0
- package/dist/system/components/UiPagination/index.d.ts +3 -0
- package/dist/system/components/UiPagination/types.d.ts +81 -0
- package/dist/system/components/core/pagination/Pagination.vue.d.ts +29 -0
- package/dist/system/components/core/pagination/PaginationContent.vue.d.ts +29 -0
- package/dist/system/components/core/pagination/PaginationEllipsis.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationFirst.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationItem.vue.d.ts +26 -0
- package/dist/system/components/core/pagination/PaginationLast.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationNext.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationPrevious.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/index.d.ts +8 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/icons/story-sidebar-icons.json +4 -0
- package/dist/system/lib.js +11605 -10906
- package/dist/system/patterns/UiBulkAction/UiBulkAction.vue.d.ts +43 -0
- package/dist/system/patterns/UiBulkAction/index.d.ts +3 -0
- package/dist/system/patterns/UiBulkAction/types.d.ts +109 -0
- package/dist/system/patterns/UiBulkAction/useBulkAction.d.ts +7 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
- package/dist/system/patterns/index.d.ts +1 -0
- package/dist/system/story-sidebar-icons.json +4 -0
- package/package.json +10 -5
- package/src/components/UiPagination/UiPagination.guidance.md +60 -0
- package/src/components/UiPagination/UiPagination.stories.ts +1070 -0
- package/src/components/UiPagination/UiPagination.vue +109 -0
- package/src/components/UiPagination/__tests__/UiPagination.test.ts +203 -0
- package/src/components/UiPagination/constants.ts +17 -0
- package/src/components/UiPagination/index.ts +3 -0
- package/src/components/UiPagination/types.ts +82 -0
- package/src/components/core/pagination/Pagination.vue +26 -0
- package/src/components/core/pagination/PaginationContent.vue +24 -0
- package/src/components/core/pagination/PaginationEllipsis.vue +30 -0
- package/src/components/core/pagination/PaginationFirst.vue +30 -0
- package/src/components/core/pagination/PaginationItem.vue +39 -0
- package/src/components/core/pagination/PaginationLast.vue +30 -0
- package/src/components/core/pagination/PaginationNext.vue +35 -0
- package/src/components/core/pagination/PaginationPrevious.vue +35 -0
- package/src/components/core/pagination/index.ts +8 -0
- package/src/components/index.ts +1 -0
- package/src/patterns/UiBulkAction/UiBulkAction.guidance.md +59 -0
- package/src/patterns/UiBulkAction/UiBulkAction.stories.ts +2238 -0
- package/src/patterns/UiBulkAction/UiBulkAction.vue +62 -0
- package/src/patterns/UiBulkAction/__tests__/useBulkAction.test.ts +78 -0
- package/src/patterns/UiBulkAction/index.ts +3 -0
- package/src/patterns/UiBulkAction/types.ts +126 -0
- package/src/patterns/UiBulkAction/useBulkAction.ts +50 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +375 -1
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +43 -60
- package/src/patterns/UiDataTable/__tests__/UiDataTablePagination.test.ts +58 -29
- package/src/patterns/UiDataTable/constants.ts +10 -0
- package/src/patterns/index.ts +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { UiBulkActionCheckedState, UiBulkActionProps } from './types';
|
|
2
|
+
type __VLS_Props = UiBulkActionProps;
|
|
3
|
+
type __VLS_PublicProps = {
|
|
4
|
+
'checked'?: UiBulkActionCheckedState;
|
|
5
|
+
} & __VLS_Props;
|
|
6
|
+
declare function __VLS_template(): {
|
|
7
|
+
attrs: Partial<{}>;
|
|
8
|
+
slots: Readonly<{
|
|
9
|
+
/** Custom actions, rendered between the select-all checkbox and reset. */
|
|
10
|
+
default?(props: {
|
|
11
|
+
/** Number of currently selected items. */
|
|
12
|
+
selectedCount: number;
|
|
13
|
+
}): unknown;
|
|
14
|
+
}> & {
|
|
15
|
+
/** Custom actions, rendered between the select-all checkbox and reset. */
|
|
16
|
+
default?(props: {
|
|
17
|
+
/** Number of currently selected items. */
|
|
18
|
+
selectedCount: number;
|
|
19
|
+
}): unknown;
|
|
20
|
+
};
|
|
21
|
+
refs: {};
|
|
22
|
+
rootEl: any;
|
|
23
|
+
};
|
|
24
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
25
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
26
|
+
reset: () => any;
|
|
27
|
+
"update:checked": (value: UiBulkActionCheckedState) => any;
|
|
28
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
29
|
+
onReset?: (() => any) | undefined;
|
|
30
|
+
"onUpdate:checked"?: ((value: UiBulkActionCheckedState) => any) | undefined;
|
|
31
|
+
}>, {
|
|
32
|
+
ariaLabel: string;
|
|
33
|
+
selectedCount: number;
|
|
34
|
+
selectAllLabel: string;
|
|
35
|
+
resetLabel: string;
|
|
36
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
37
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
38
|
+
export default _default;
|
|
39
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
40
|
+
new (): {
|
|
41
|
+
$slots: S;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* State of the select-all checkbox. `'indeterminate'` when only some rows
|
|
4
|
+
* are selected.
|
|
5
|
+
*/
|
|
6
|
+
export type UiBulkActionCheckedState = boolean | 'indeterminate';
|
|
7
|
+
/**
|
|
8
|
+
* A bar of actions applied to every currently selected item at once.
|
|
9
|
+
* Always starts with the select-all checkbox and ends with the reset button;
|
|
10
|
+
* custom actions go in the default slot between them.
|
|
11
|
+
* @category Data Display
|
|
12
|
+
* @useCases bulk delete, bulk edit, multi-select actions, table selection toolbar
|
|
13
|
+
* @keywords bulk, batch, selection, multi-select, actions, toolbar
|
|
14
|
+
* @related UiDataTable, UiFloatActionItems
|
|
15
|
+
*/
|
|
16
|
+
export interface UiBulkActionProps {
|
|
17
|
+
/**
|
|
18
|
+
* State of the select-all checkbox. Use `v-model:checked`.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
checked?: UiBulkActionCheckedState;
|
|
22
|
+
/**
|
|
23
|
+
* Number of currently selected items, exposed to the default slot.
|
|
24
|
+
* @default 0
|
|
25
|
+
*/
|
|
26
|
+
selectedCount?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Accessible name of the toolbar.
|
|
29
|
+
* @default 'Bulk actions'
|
|
30
|
+
*/
|
|
31
|
+
ariaLabel?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Accessible name of the select-all checkbox.
|
|
34
|
+
* @default 'Select all rows on this page'
|
|
35
|
+
*/
|
|
36
|
+
selectAllLabel?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Accessible name of the reset button.
|
|
39
|
+
* @default 'Reset selection'
|
|
40
|
+
*/
|
|
41
|
+
resetLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* An action that can be applied to the selected items.
|
|
45
|
+
*/
|
|
46
|
+
export interface UiBulkActionDefinition<TItem, TKey extends string = string> {
|
|
47
|
+
/**
|
|
48
|
+
* Unique identifier used to run the action through `apply`.
|
|
49
|
+
*/
|
|
50
|
+
key: TKey;
|
|
51
|
+
/**
|
|
52
|
+
* Runs the action. Receives the items selected when `apply` was called.
|
|
53
|
+
*/
|
|
54
|
+
action: (items: TItem[]) => void | Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Options for the `useBulkAction` composable.
|
|
58
|
+
*/
|
|
59
|
+
export interface UseBulkActionOptions<TItem, TKey extends string = string> {
|
|
60
|
+
/**
|
|
61
|
+
* Actions that can be applied to the selection, identified by `key`.
|
|
62
|
+
*/
|
|
63
|
+
actions: UiBulkActionDefinition<TItem, TKey>[];
|
|
64
|
+
/**
|
|
65
|
+
* Called by `reset` after the selection is cleared, e.g. to reset the
|
|
66
|
+
* selection state of a table.
|
|
67
|
+
*/
|
|
68
|
+
onReset?: () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Items that are initially selected.
|
|
71
|
+
*/
|
|
72
|
+
initialSelection?: TItem[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* State and helpers returned by the `useBulkAction` composable.
|
|
76
|
+
*/
|
|
77
|
+
export interface UseBulkActionReturn<TItem, TKey extends string = string> {
|
|
78
|
+
/**
|
|
79
|
+
* Runs the action with the given key, or each action in the given array of
|
|
80
|
+
* keys in order, on the currently selected items. Resolves once every action
|
|
81
|
+
* has finished.
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* await apply('delete');
|
|
85
|
+
* await apply(['archive', 'notify']);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
apply: (keys: TKey | TKey[]) => Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Clears the selection and calls `onReset`.
|
|
91
|
+
*/
|
|
92
|
+
reset: () => void;
|
|
93
|
+
/**
|
|
94
|
+
* Currently selected items.
|
|
95
|
+
*/
|
|
96
|
+
selectedItems: Ref<TItem[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Number of currently selected items.
|
|
99
|
+
*/
|
|
100
|
+
selectedCount: ComputedRef<number>;
|
|
101
|
+
/**
|
|
102
|
+
* Whether at least one item is selected.
|
|
103
|
+
*/
|
|
104
|
+
hasSelection: ComputedRef<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* Remove every item from the selection.
|
|
107
|
+
*/
|
|
108
|
+
clearSelection: () => void;
|
|
109
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UseBulkActionOptions, UseBulkActionReturn } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Selection state and action runner for applying actions to many items at once.
|
|
4
|
+
* @param options - Available actions, reset callback, and initial selection
|
|
5
|
+
* @returns Reactive selection state, `apply` to run actions, and `reset`
|
|
6
|
+
*/
|
|
7
|
+
export declare function useBulkAction<TItem, TKey extends string = string>(options: UseBulkActionOptions<TItem, TKey>): UseBulkActionReturn<TItem, TKey>;
|
|
@@ -55,6 +55,16 @@ export interface PaginationLabels {
|
|
|
55
55
|
goToNextPage?: string;
|
|
56
56
|
/** Aria label for last page button */
|
|
57
57
|
goToLastPage?: string;
|
|
58
|
+
/** Visible text of the previous button */
|
|
59
|
+
previous?: string;
|
|
60
|
+
/** Visible text of the next button */
|
|
61
|
+
next?: string;
|
|
62
|
+
/** Aria label for a numbered page button */
|
|
63
|
+
goToPage?: (page: number) => string;
|
|
64
|
+
/** Screen-reader text for the ellipsis standing in for skipped pages */
|
|
65
|
+
morePages?: string;
|
|
66
|
+
/** Accessible name of the pagination navigation landmark */
|
|
67
|
+
navigation?: string;
|
|
58
68
|
/** Function to generate page info text */
|
|
59
69
|
pageOf?: (page: number, total: number) => string;
|
|
60
70
|
/** Function to generate selection count text */
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"components-uilistbox--accessibility": "accessibility",
|
|
50
50
|
"components-uinavigationmenu--design-notes": "palette",
|
|
51
51
|
"components-uinavigationmenu--accessibility": "accessibility",
|
|
52
|
+
"components-uipagination--design-notes": "palette",
|
|
53
|
+
"components-uipagination--accessibility": "accessibility",
|
|
52
54
|
"components-uipopover--design-notes": "palette",
|
|
53
55
|
"components-uipopover--accessibility": "accessibility",
|
|
54
56
|
"components-uiprogress--design-notes": "palette",
|
|
@@ -90,6 +92,8 @@
|
|
|
90
92
|
"components-uitogglegroup--accessibility": "accessibility",
|
|
91
93
|
"components-uitooltip--design-notes": "palette",
|
|
92
94
|
"components-uitooltip--accessibility": "accessibility",
|
|
95
|
+
"patterns-uibulkaction--design-notes": "palette",
|
|
96
|
+
"patterns-uibulkaction--accessibility": "accessibility",
|
|
93
97
|
"patterns-uidatatable--design-notes": "palette",
|
|
94
98
|
"patterns-uidatatable--accessibility": "accessibility",
|
|
95
99
|
"patterns-uidatepicker--design-notes": "palette",
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/ui-library",
|
|
3
|
-
"version": "7.1
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Aleph-Alpha/frontend-hub.git",
|
|
8
|
+
"directory": "packages/ui-library"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"main": "dist/system/lib.js",
|
|
7
12
|
"types": "dist/system/index.d.ts",
|
|
@@ -94,12 +99,12 @@
|
|
|
94
99
|
"vue-router": "4.6.4",
|
|
95
100
|
"vue-tsc": "^2.2.12",
|
|
96
101
|
"wait-on": "9.0.3",
|
|
97
|
-
"@aleph-alpha/eslint-config-frontend": "0.7.
|
|
98
|
-
"@aleph-alpha/prettier-config-frontend": "2.1.
|
|
102
|
+
"@aleph-alpha/eslint-config-frontend": "0.7.2",
|
|
103
|
+
"@aleph-alpha/prettier-config-frontend": "2.1.2",
|
|
99
104
|
"@aleph-alpha/storybook-addon-filters": "0.0.1",
|
|
100
105
|
"@aleph-alpha/storybook-addon-sidebar": "0.0.1",
|
|
101
106
|
"@aleph-alpha/storybook-addon-theming": "0.0.1",
|
|
102
|
-
"@aleph-alpha/tsconfig-frontend": "0.7.
|
|
107
|
+
"@aleph-alpha/tsconfig-frontend": "0.7.4"
|
|
103
108
|
},
|
|
104
109
|
"peerDependencies": {
|
|
105
110
|
"@unocss/preset-wind4": ">=66.0.0",
|
|
@@ -133,7 +138,7 @@
|
|
|
133
138
|
"shiki": "^3.0.0",
|
|
134
139
|
"tailwind-merge": "^3.4.0",
|
|
135
140
|
"vue-sonner": "^2.0.9",
|
|
136
|
-
"@aleph-alpha/config-unocss": "0.2.
|
|
141
|
+
"@aleph-alpha/config-unocss": "0.2.2"
|
|
137
142
|
},
|
|
138
143
|
"jest-junit": {
|
|
139
144
|
"outputDirectory": "reports/storybook",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
## Usage
|
|
2
|
+
|
|
3
|
+
The Pagination component moves through a long set one page at a time and, more importantly, tells the user where they are within it. That position is what makes a particular page findable again.
|
|
4
|
+
|
|
5
|
+
Use it when the set has a knowable size and users need to come back to a specific page. When the set is endless, or read in one pass, continuous loading is kinder.
|
|
6
|
+
|
|
7
|
+
### Position is the message
|
|
8
|
+
|
|
9
|
+
A page number only helps if the user can place it:
|
|
10
|
+
|
|
11
|
+
- The current page is unmistakably marked
|
|
12
|
+
- Neighbouring pages are reachable in one step
|
|
13
|
+
- The ellipsis stands in for the pages that do not fit
|
|
14
|
+
- First and last stay reachable from any position
|
|
15
|
+
|
|
16
|
+
### Ends are shown, not hidden
|
|
17
|
+
|
|
18
|
+
The controls tell the user where the set stops:
|
|
19
|
+
|
|
20
|
+
- Previous and next sit at the outside, in a fixed position
|
|
21
|
+
- Each is disabled, not removed, at its end of the set
|
|
22
|
+
- The current page never moves position as the user pages
|
|
23
|
+
- The row keeps the same width as the numbers change
|
|
24
|
+
|
|
25
|
+
### Consistency
|
|
26
|
+
|
|
27
|
+
Every pagination is built from the same parts:
|
|
28
|
+
|
|
29
|
+
- Pagination row, holding the items
|
|
30
|
+
- Previous and next items, with a disabled state
|
|
31
|
+
- Link items, with an active state
|
|
32
|
+
- Ellipsis item, standing in for collapsed pages
|
|
33
|
+
- One window size, so the row never changes width
|
|
34
|
+
|
|
35
|
+
## Do
|
|
36
|
+
|
|
37
|
+
- Mark the current page distinctly from the pages around it
|
|
38
|
+
- Keep previous and next in the same place, and disable them at the ends
|
|
39
|
+
- Collapse the middle with an ellipsis rather than growing the row
|
|
40
|
+
- Keep first and last reachable from any position
|
|
41
|
+
- Keep the row the same width as the numbers change
|
|
42
|
+
- Say how many results there are, near the control
|
|
43
|
+
|
|
44
|
+
## Don't
|
|
45
|
+
|
|
46
|
+
- Remove previous or next instead of disabling them
|
|
47
|
+
- Let the row change width as page numbers grow
|
|
48
|
+
- Rely on colour alone to mark the current page
|
|
49
|
+
- Show every page number in a long set
|
|
50
|
+
- Use pagination for an endless or one-pass set
|
|
51
|
+
- Move the current page's position within the row
|
|
52
|
+
|
|
53
|
+
## Accessibility
|
|
54
|
+
|
|
55
|
+
- The current page differs from the others by fill and weight, not colour alone
|
|
56
|
+
- Hover, focus and active are three distinguishable treatments on a page item
|
|
57
|
+
- Disabled previous and next are distinguishable by more than reduced opacity
|
|
58
|
+
- Every item is a comfortable target, with enough space between adjacent numbers
|
|
59
|
+
- The ellipsis reads as an omission rather than as a page
|
|
60
|
+
- The row keeps a stable width and position, so the control does not move under the reader
|