@aleph-alpha/ui-library 7.1.0 → 7.2.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.
Files changed (53) hide show
  1. package/dist/system/components/UiPagination/UiPagination.vue.d.ts +19 -0
  2. package/dist/system/components/UiPagination/constants.d.ts +6 -0
  3. package/dist/system/components/UiPagination/index.d.ts +3 -0
  4. package/dist/system/components/UiPagination/types.d.ts +81 -0
  5. package/dist/system/components/core/pagination/Pagination.vue.d.ts +29 -0
  6. package/dist/system/components/core/pagination/PaginationContent.vue.d.ts +29 -0
  7. package/dist/system/components/core/pagination/PaginationEllipsis.vue.d.ts +22 -0
  8. package/dist/system/components/core/pagination/PaginationFirst.vue.d.ts +22 -0
  9. package/dist/system/components/core/pagination/PaginationItem.vue.d.ts +26 -0
  10. package/dist/system/components/core/pagination/PaginationLast.vue.d.ts +22 -0
  11. package/dist/system/components/core/pagination/PaginationNext.vue.d.ts +22 -0
  12. package/dist/system/components/core/pagination/PaginationPrevious.vue.d.ts +22 -0
  13. package/dist/system/components/core/pagination/index.d.ts +8 -0
  14. package/dist/system/components/index.d.ts +1 -0
  15. package/dist/system/icons/story-sidebar-icons.json +4 -0
  16. package/dist/system/lib.js +11605 -10906
  17. package/dist/system/patterns/UiBulkAction/UiBulkAction.vue.d.ts +43 -0
  18. package/dist/system/patterns/UiBulkAction/index.d.ts +3 -0
  19. package/dist/system/patterns/UiBulkAction/types.d.ts +109 -0
  20. package/dist/system/patterns/UiBulkAction/useBulkAction.d.ts +7 -0
  21. package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
  22. package/dist/system/patterns/index.d.ts +1 -0
  23. package/dist/system/story-sidebar-icons.json +4 -0
  24. package/package.json +1 -1
  25. package/src/components/UiPagination/UiPagination.guidance.md +60 -0
  26. package/src/components/UiPagination/UiPagination.stories.ts +1070 -0
  27. package/src/components/UiPagination/UiPagination.vue +109 -0
  28. package/src/components/UiPagination/__tests__/UiPagination.test.ts +203 -0
  29. package/src/components/UiPagination/constants.ts +17 -0
  30. package/src/components/UiPagination/index.ts +3 -0
  31. package/src/components/UiPagination/types.ts +82 -0
  32. package/src/components/core/pagination/Pagination.vue +26 -0
  33. package/src/components/core/pagination/PaginationContent.vue +24 -0
  34. package/src/components/core/pagination/PaginationEllipsis.vue +30 -0
  35. package/src/components/core/pagination/PaginationFirst.vue +30 -0
  36. package/src/components/core/pagination/PaginationItem.vue +39 -0
  37. package/src/components/core/pagination/PaginationLast.vue +30 -0
  38. package/src/components/core/pagination/PaginationNext.vue +35 -0
  39. package/src/components/core/pagination/PaginationPrevious.vue +35 -0
  40. package/src/components/core/pagination/index.ts +8 -0
  41. package/src/components/index.ts +1 -0
  42. package/src/patterns/UiBulkAction/UiBulkAction.guidance.md +59 -0
  43. package/src/patterns/UiBulkAction/UiBulkAction.stories.ts +2238 -0
  44. package/src/patterns/UiBulkAction/UiBulkAction.vue +62 -0
  45. package/src/patterns/UiBulkAction/__tests__/useBulkAction.test.ts +78 -0
  46. package/src/patterns/UiBulkAction/index.ts +3 -0
  47. package/src/patterns/UiBulkAction/types.ts +126 -0
  48. package/src/patterns/UiBulkAction/useBulkAction.ts +50 -0
  49. package/src/patterns/UiDataTable/UiDataTable.stories.ts +375 -1
  50. package/src/patterns/UiDataTable/UiDataTablePagination.vue +43 -60
  51. package/src/patterns/UiDataTable/__tests__/UiDataTablePagination.test.ts +58 -29
  52. package/src/patterns/UiDataTable/constants.ts +10 -0
  53. 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,3 @@
1
+ export { default as UiBulkAction } from './UiBulkAction.vue';
2
+ export { useBulkAction } from './useBulkAction';
3
+ export * from './types';
@@ -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 */
@@ -2,6 +2,7 @@
2
2
  * This file is auto-generated by prepare-build.js script
3
3
  * Do not edit this file manually
4
4
  */
5
+ export * from './UiBulkAction';
5
6
  export * from './UiDataTable';
6
7
  export * from './UiDatePicker';
7
8
  export * from './UiFileUpload';
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/ui-library",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/system/lib.js",
@@ -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