@bitrise/bitkit-v2 0.3.372 → 0.3.374
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/components/BitkitPagination/BitkitPagination.js +1 -1
- package/dist/components/BitkitPagination/BitkitPagination.js.map +1 -1
- package/dist/components/BitkitTable/BitkitBulkActionsRow.d.ts +80 -0
- package/dist/components/BitkitTable/BitkitBulkActionsRow.js +124 -0
- package/dist/components/BitkitTable/BitkitBulkActionsRow.js.map +1 -0
- package/dist/components/BitkitTable/BitkitExpandableRow.js +30 -54
- package/dist/components/BitkitTable/BitkitExpandableRow.js.map +1 -1
- package/dist/components/BitkitTable/BitkitFilterRow.d.ts +25 -0
- package/dist/components/BitkitTable/BitkitFilterRow.js +41 -0
- package/dist/components/BitkitTable/BitkitFilterRow.js.map +1 -0
- package/dist/components/BitkitTable/BitkitLinkedRow.d.ts +12 -0
- package/dist/components/BitkitTable/BitkitLinkedRow.js +72 -0
- package/dist/components/BitkitTable/BitkitLinkedRow.js.map +1 -0
- package/dist/components/BitkitTable/BitkitRowActionsCell.d.ts +43 -0
- package/dist/components/BitkitTable/BitkitRowActionsCell.js +90 -0
- package/dist/components/BitkitTable/BitkitRowActionsCell.js.map +1 -0
- package/dist/components/BitkitTable/BitkitSortableColumnHeader.js +28 -41
- package/dist/components/BitkitTable/BitkitSortableColumnHeader.js.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/main.js +5 -1
- package/dist/theme/slot-recipes/Table.recipe.d.ts +20 -7
- package/dist/theme/slot-recipes/Table.recipe.js +163 -14
- package/dist/theme/slot-recipes/Table.recipe.js.map +1 -1
- package/dist/theme/slot-recipes/index.d.ts +20 -7
- package/dist/utilities/formatLabel.d.ts +7 -0
- package/dist/utilities/formatLabel.js +11 -0
- package/dist/utilities/formatLabel.js.map +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import IconChevronLeft from "../../icons/IconChevronLeft.js";
|
|
|
2
2
|
import IconChevronRight from "../../icons/IconChevronRight.js";
|
|
3
3
|
import BitkitIconButton from "../BitkitIconButton/BitkitIconButton.js";
|
|
4
4
|
import BitkitNativeSelect from "../BitkitNativeSelect/BitkitNativeSelect.js";
|
|
5
|
+
import formatLabel from "../../utilities/formatLabel.js";
|
|
5
6
|
import { Box } from "@chakra-ui/react/box";
|
|
6
7
|
import { chakra, useSlotRecipe } from "@chakra-ui/react/styled-system";
|
|
7
8
|
import { forwardRef, useMemo } from "react";
|
|
@@ -16,7 +17,6 @@ var DEFAULT_LABELS = {
|
|
|
16
17
|
pages: "of {totalPages} pages",
|
|
17
18
|
previousPage: "Previous page"
|
|
18
19
|
};
|
|
19
|
-
var formatLabel = (template, values) => Object.entries(values).reduce((str, [key, val]) => str.replaceAll(`{${key}}`, String(val)), template);
|
|
20
20
|
var BitkitPagination = forwardRef((props, ref) => {
|
|
21
21
|
const { labels: labelsProp, onPageChange, onPageSizeChange, page, pageSize, pageSizeOptions = [
|
|
22
22
|
10,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitPagination.js","names":[],"sources":["../../../lib/components/BitkitPagination/BitkitPagination.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\nimport { Separator } from '@chakra-ui/react/separator';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, useMemo } from 'react';\n\nimport { IconChevronLeft, IconChevronRight } from '../../icons';\nimport BitkitIconButton from '../BitkitIconButton/BitkitIconButton';\nimport BitkitNativeSelect from '../BitkitNativeSelect/BitkitNativeSelect';\n\nexport interface BitkitPaginationLabels {\n items?: string;\n itemsPerPage?: string;\n nextPage?: string;\n pages?: string;\n previousPage?: string;\n}\n\nconst DEFAULT_LABELS: Required<BitkitPaginationLabels> = {\n items: '{start}\\u2013{end} of {total} items',\n itemsPerPage: 'Items per page:',\n nextPage: 'Next page',\n pages: 'of {totalPages} pages',\n previousPage: 'Previous page',\n};\n\
|
|
1
|
+
{"version":3,"file":"BitkitPagination.js","names":[],"sources":["../../../lib/components/BitkitPagination/BitkitPagination.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\nimport { Separator } from '@chakra-ui/react/separator';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, useMemo } from 'react';\n\nimport { IconChevronLeft, IconChevronRight } from '../../icons';\nimport formatLabel from '../../utilities/formatLabel';\nimport BitkitIconButton from '../BitkitIconButton/BitkitIconButton';\nimport BitkitNativeSelect from '../BitkitNativeSelect/BitkitNativeSelect';\n\nexport interface BitkitPaginationLabels {\n items?: string;\n itemsPerPage?: string;\n nextPage?: string;\n pages?: string;\n previousPage?: string;\n}\n\nconst DEFAULT_LABELS: Required<BitkitPaginationLabels> = {\n items: '{start}\\u2013{end} of {total} items',\n itemsPerPage: 'Items per page:',\n nextPage: 'Next page',\n pages: 'of {totalPages} pages',\n previousPage: 'Previous page',\n};\n\nexport interface BitkitPaginationProps extends Omit<BoxProps, 'colorPalette' | 'page'> {\n labels?: BitkitPaginationLabels;\n onPageChange?: (page: number) => void;\n onPageSizeChange?: (pageSize: number) => void;\n page: number;\n pageSize: number;\n pageSizeOptions?: number[];\n state?: 'skeleton';\n totalItems: number;\n variant?: 'card' | 'page' | 'table';\n}\n\nconst BitkitPagination = forwardRef<HTMLDivElement, BitkitPaginationProps>((props, ref) => {\n const {\n labels: labelsProp,\n onPageChange,\n onPageSizeChange,\n page,\n pageSize,\n pageSizeOptions = [10, 25, 50],\n state,\n totalItems,\n variant = 'table',\n ...rest\n } = props;\n\n const recipe = useSlotRecipe({ key: 'pagination' });\n const styles = recipe({ variant });\n\n const safePageSize = Math.max(1, pageSize);\n const totalPages = Math.max(1, Math.ceil(totalItems / safePageSize));\n const safePage = Math.min(Math.max(1, page), totalPages);\n const start = totalItems === 0 ? 0 : (safePage - 1) * safePageSize + 1;\n const end = Math.min(safePage * safePageSize, totalItems);\n const isFirstPage = safePage <= 1;\n const isLastPage = safePage >= totalPages;\n const isSkeleton = state === 'skeleton';\n const showItemsPerPage = variant !== 'card';\n\n const values = { end, start, total: totalItems, totalPages };\n const labels = Object.fromEntries(\n Object.entries({ ...DEFAULT_LABELS, ...labelsProp }).map(([k, v]) => [k, formatLabel(v, values)]),\n ) as Required<BitkitPaginationLabels>;\n\n const pageSizeItems = useMemo(\n () => pageSizeOptions.map((opt) => ({ label: String(opt), value: String(opt) })),\n [pageSizeOptions],\n );\n\n const pageItems = useMemo(\n () => Array.from({ length: totalPages }, (_, i) => ({ label: String(i + 1), value: String(i + 1) })),\n [totalPages],\n );\n\n return (\n <Box ref={ref} css={styles.root} {...rest}>\n <chakra.div css={styles.itemsBlock}>\n {showItemsPerPage && (\n <>\n <chakra.span css={styles.text}>{labels.itemsPerPage}</chakra.span>\n <BitkitNativeSelect\n css={styles.itemsSelect}\n onChange={(e) => onPageSizeChange?.(Number(e.target.value))}\n size=\"md\"\n state={isSkeleton ? 'disabled' : undefined}\n value={String(safePageSize)}\n >\n {pageSizeItems.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </BitkitNativeSelect>\n <Separator alignSelf=\"stretch\" borderColor=\"border/minimal\" marginInline=\"8\" orientation=\"vertical\" />\n </>\n )}\n {isSkeleton ? <Skeleton height=\"20\" width=\"96\" /> : <chakra.span css={styles.text}>{labels.items}</chakra.span>}\n </chakra.div>\n\n <chakra.div css={styles.pageBlock}>\n <Separator alignSelf=\"stretch\" borderColor=\"border/minimal\" marginInline=\"8\" orientation=\"vertical\" />\n <BitkitNativeSelect\n css={styles.pageSelect}\n onChange={(e) => onPageChange?.(Number(e.target.value))}\n size=\"md\"\n state={isSkeleton ? 'disabled' : undefined}\n value={String(safePage)}\n >\n {pageItems.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </BitkitNativeSelect>\n {isSkeleton ? <Skeleton height=\"20\" width=\"64\" /> : <chakra.span css={styles.text}>{labels.pages}</chakra.span>}\n <BitkitIconButton\n icon={IconChevronLeft}\n label={labels.previousPage}\n marginInlineStart=\"8\"\n onClick={() => onPageChange?.(safePage - 1)}\n size=\"md\"\n state={isFirstPage || isSkeleton ? 'disabled' : undefined}\n variant=\"secondary\"\n />\n <BitkitIconButton\n icon={IconChevronRight}\n label={labels.nextPage}\n onClick={() => onPageChange?.(safePage + 1)}\n size=\"md\"\n state={isLastPage || isSkeleton ? 'disabled' : undefined}\n variant=\"secondary\"\n />\n </chakra.div>\n </Box>\n );\n});\n\nBitkitPagination.displayName = 'BitkitPagination';\n\nexport default BitkitPagination;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Table } from '@chakra-ui/react/table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The noun the bar counts. A single string is used for every count; pass `{ one, other }` to get
|
|
5
|
+
* `1 workflow selected.` instead of `1 workflows selected.`
|
|
6
|
+
*/
|
|
7
|
+
export type BitkitBulkActionsItems = string | {
|
|
8
|
+
one: string;
|
|
9
|
+
other: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Overrides for the bar's sentences. Each template can use `{items}` (the `items` prop, already
|
|
13
|
+
* resolved to the form matching that sentence's count), `{selectedCount}` and `{totalItems}`.
|
|
14
|
+
* Override a whole sentence for wording a template can't express, such as another language's
|
|
15
|
+
* grammar.
|
|
16
|
+
*/
|
|
17
|
+
export interface BitkitBulkActionsLabels {
|
|
18
|
+
/** `selectionState="all"`. Default: `All {totalItems} {items} selected.` */
|
|
19
|
+
allSelected?: string;
|
|
20
|
+
/** Default: `Cancel` */
|
|
21
|
+
cancel?: string;
|
|
22
|
+
/** The link offering the rows beyond this page. Default: `Select all {totalItems} {items}` */
|
|
23
|
+
selectAll?: string;
|
|
24
|
+
/** `selectionState="some"`. Default: `{selectedCount} {items} selected.` */
|
|
25
|
+
selected?: string;
|
|
26
|
+
/** `selectionState="allOnPage"`. Default: `{selectedCount} {items} selected on this page.` */
|
|
27
|
+
selectedOnPage?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface BitkitBulkActionsRowProps extends Omit<Table.RowProps, 'children'> {
|
|
30
|
+
/** The bulk action buttons, rendered after `Cancel`. */
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
/** Must match the table's column count, so the row spans the full width. */
|
|
33
|
+
colSpan: number;
|
|
34
|
+
/** The counted noun. Default: `{ one: 'item', other: 'items' }` */
|
|
35
|
+
items?: BitkitBulkActionsItems;
|
|
36
|
+
labels?: BitkitBulkActionsLabels;
|
|
37
|
+
onCancel: () => void;
|
|
38
|
+
/** Renders the `Select all {totalItems} {items}` link while `selectionState="allOnPage"`. */
|
|
39
|
+
onSelectAll?: () => void;
|
|
40
|
+
selectedCount: number;
|
|
41
|
+
/**
|
|
42
|
+
* `some` — part of the page is selected. `allOnPage` — the whole page is selected, and the rows
|
|
43
|
+
* beyond it are still on offer. `all` — everything across every page is selected.
|
|
44
|
+
*/
|
|
45
|
+
selectionState: 'some' | 'allOnPage' | 'all';
|
|
46
|
+
totalItems: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The bar above the column headers that appears while rows are selected: what is selected, the
|
|
50
|
+
* offer to widen the selection to every page, and the actions to run on it. Belongs in
|
|
51
|
+
* `Table.Header`, before the `Table.Row` that holds the column headers.
|
|
52
|
+
*
|
|
53
|
+
* The count is mirrored into a visually hidden `aria-live` region, which is deliberately filled a
|
|
54
|
+
* render after mount — a live region that enters the DOM with its text already in it is not
|
|
55
|
+
* announced, so the first selection would go unspoken otherwise.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <Table.Header>
|
|
60
|
+
* {selected.length > 0 && (
|
|
61
|
+
* <BitkitBulkActionsRow
|
|
62
|
+
* colSpan={COL_COUNT}
|
|
63
|
+
* items={{ one: 'workflow', other: 'workflows' }}
|
|
64
|
+
* onCancel={clearSelection}
|
|
65
|
+
* onSelectAll={() => setAllAcrossPages(true)}
|
|
66
|
+
* selectedCount={selected.length}
|
|
67
|
+
* selectionState={selectionState}
|
|
68
|
+
* totalItems={TOTAL_ITEMS}
|
|
69
|
+
* >
|
|
70
|
+
* <BitkitButton icon={IconMinusCircle} size="md" variant="danger-secondary">
|
|
71
|
+
* Remove
|
|
72
|
+
* </BitkitButton>
|
|
73
|
+
* </BitkitBulkActionsRow>
|
|
74
|
+
* )}
|
|
75
|
+
* <Table.Row>{columnHeaders}</Table.Row>
|
|
76
|
+
* </Table.Header>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare const BitkitBulkActionsRow: import('react').ForwardRefExoticComponent<BitkitBulkActionsRowProps & import('react').RefAttributes<HTMLTableRowElement>>;
|
|
80
|
+
export default BitkitBulkActionsRow;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import BitkitButton from "../BitkitButton/BitkitButton.js";
|
|
2
|
+
import formatLabel from "../../utilities/formatLabel.js";
|
|
3
|
+
import { Box } from "@chakra-ui/react/box";
|
|
4
|
+
import { forwardRef, useEffect, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Text } from "@chakra-ui/react/text";
|
|
7
|
+
import { VisuallyHidden } from "@chakra-ui/react/visually-hidden";
|
|
8
|
+
import { Table, useTableStyles } from "@chakra-ui/react/table";
|
|
9
|
+
//#region lib/components/BitkitTable/BitkitBulkActionsRow.tsx
|
|
10
|
+
var DEFAULT_LABELS = {
|
|
11
|
+
allSelected: "All {totalItems} {items} selected.",
|
|
12
|
+
cancel: "Cancel",
|
|
13
|
+
selectAll: "Select all {totalItems} {items}",
|
|
14
|
+
selected: "{selectedCount} {items} selected.",
|
|
15
|
+
selectedOnPage: "{selectedCount} {items} selected on this page."
|
|
16
|
+
};
|
|
17
|
+
var DEFAULT_ITEMS = {
|
|
18
|
+
one: "item",
|
|
19
|
+
other: "items"
|
|
20
|
+
};
|
|
21
|
+
var resolveItems = (items, count) => {
|
|
22
|
+
if (typeof items === "string") return items;
|
|
23
|
+
return count === 1 ? items.one : items.other;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The bar above the column headers that appears while rows are selected: what is selected, the
|
|
27
|
+
* offer to widen the selection to every page, and the actions to run on it. Belongs in
|
|
28
|
+
* `Table.Header`, before the `Table.Row` that holds the column headers.
|
|
29
|
+
*
|
|
30
|
+
* The count is mirrored into a visually hidden `aria-live` region, which is deliberately filled a
|
|
31
|
+
* render after mount — a live region that enters the DOM with its text already in it is not
|
|
32
|
+
* announced, so the first selection would go unspoken otherwise.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <Table.Header>
|
|
37
|
+
* {selected.length > 0 && (
|
|
38
|
+
* <BitkitBulkActionsRow
|
|
39
|
+
* colSpan={COL_COUNT}
|
|
40
|
+
* items={{ one: 'workflow', other: 'workflows' }}
|
|
41
|
+
* onCancel={clearSelection}
|
|
42
|
+
* onSelectAll={() => setAllAcrossPages(true)}
|
|
43
|
+
* selectedCount={selected.length}
|
|
44
|
+
* selectionState={selectionState}
|
|
45
|
+
* totalItems={TOTAL_ITEMS}
|
|
46
|
+
* >
|
|
47
|
+
* <BitkitButton icon={IconMinusCircle} size="md" variant="danger-secondary">
|
|
48
|
+
* Remove
|
|
49
|
+
* </BitkitButton>
|
|
50
|
+
* </BitkitBulkActionsRow>
|
|
51
|
+
* )}
|
|
52
|
+
* <Table.Row>{columnHeaders}</Table.Row>
|
|
53
|
+
* </Table.Header>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
var BitkitBulkActionsRow = forwardRef((props, ref) => {
|
|
57
|
+
const { children, colSpan, items = DEFAULT_ITEMS, labels: labelsProp, onCancel, onSelectAll, selectedCount, selectionState, totalItems, ...rest } = props;
|
|
58
|
+
const styles = useTableStyles();
|
|
59
|
+
const labels = {
|
|
60
|
+
...DEFAULT_LABELS,
|
|
61
|
+
...labelsProp
|
|
62
|
+
};
|
|
63
|
+
const countLabel = {
|
|
64
|
+
all: labels.allSelected,
|
|
65
|
+
allOnPage: labels.selectedOnPage,
|
|
66
|
+
some: labels.selected
|
|
67
|
+
}[selectionState];
|
|
68
|
+
const countText = formatLabel(countLabel, {
|
|
69
|
+
items: resolveItems(items, selectionState === "all" ? totalItems : selectedCount),
|
|
70
|
+
selectedCount,
|
|
71
|
+
totalItems
|
|
72
|
+
});
|
|
73
|
+
const selectAllText = formatLabel(labels.selectAll, {
|
|
74
|
+
items: resolveItems(items, totalItems),
|
|
75
|
+
selectedCount,
|
|
76
|
+
totalItems
|
|
77
|
+
});
|
|
78
|
+
const [announcement, setAnnouncement] = useState("");
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
setAnnouncement(countText);
|
|
81
|
+
}, [countText]);
|
|
82
|
+
return /* @__PURE__ */ jsx(Table.Row, {
|
|
83
|
+
ref,
|
|
84
|
+
...rest,
|
|
85
|
+
children: /* @__PURE__ */ jsx(Table.Cell, {
|
|
86
|
+
colSpan,
|
|
87
|
+
css: styles.utilityCell,
|
|
88
|
+
children: /* @__PURE__ */ jsxs(Box, {
|
|
89
|
+
css: styles.bulkActionsGroup,
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ jsx(Text, {
|
|
92
|
+
color: "text/body",
|
|
93
|
+
textStyle: "body/md/regular",
|
|
94
|
+
children: countText
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ jsx(VisuallyHidden, {
|
|
97
|
+
"aria-live": "polite",
|
|
98
|
+
children: announcement
|
|
99
|
+
}),
|
|
100
|
+
selectionState === "allOnPage" && !!onSelectAll && /* @__PURE__ */ jsx(BitkitButton, {
|
|
101
|
+
onClick: onSelectAll,
|
|
102
|
+
size: "sm",
|
|
103
|
+
variant: "tertiary",
|
|
104
|
+
children: selectAllText
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
107
|
+
css: styles.bulkActionsButtons,
|
|
108
|
+
children: [/* @__PURE__ */ jsx(BitkitButton, {
|
|
109
|
+
onClick: onCancel,
|
|
110
|
+
size: "md",
|
|
111
|
+
variant: "tertiary",
|
|
112
|
+
children: labels.cancel
|
|
113
|
+
}), children]
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
BitkitBulkActionsRow.displayName = "BitkitBulkActionsRow";
|
|
121
|
+
//#endregion
|
|
122
|
+
export { BitkitBulkActionsRow as default };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=BitkitBulkActionsRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitkitBulkActionsRow.js","names":[],"sources":["../../../lib/components/BitkitTable/BitkitBulkActionsRow.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Table, useTableStyles } from '@chakra-ui/react/table';\nimport { Text } from '@chakra-ui/react/text';\nimport { VisuallyHidden } from '@chakra-ui/react/visually-hidden';\nimport { forwardRef, type ReactNode, useEffect, useState } from 'react';\n\nimport formatLabel from '../../utilities/formatLabel';\nimport BitkitButton from '../BitkitButton/BitkitButton';\n\n/**\n * The noun the bar counts. A single string is used for every count; pass `{ one, other }` to get\n * `1 workflow selected.` instead of `1 workflows selected.`\n */\nexport type BitkitBulkActionsItems = string | { one: string; other: string };\n\n/**\n * Overrides for the bar's sentences. Each template can use `{items}` (the `items` prop, already\n * resolved to the form matching that sentence's count), `{selectedCount}` and `{totalItems}`.\n * Override a whole sentence for wording a template can't express, such as another language's\n * grammar.\n */\nexport interface BitkitBulkActionsLabels {\n /** `selectionState=\"all\"`. Default: `All {totalItems} {items} selected.` */\n allSelected?: string;\n /** Default: `Cancel` */\n cancel?: string;\n /** The link offering the rows beyond this page. Default: `Select all {totalItems} {items}` */\n selectAll?: string;\n /** `selectionState=\"some\"`. Default: `{selectedCount} {items} selected.` */\n selected?: string;\n /** `selectionState=\"allOnPage\"`. Default: `{selectedCount} {items} selected on this page.` */\n selectedOnPage?: string;\n}\n\nconst DEFAULT_LABELS: Required<BitkitBulkActionsLabels> = {\n allSelected: 'All {totalItems} {items} selected.',\n cancel: 'Cancel',\n selectAll: 'Select all {totalItems} {items}',\n selected: '{selectedCount} {items} selected.',\n selectedOnPage: '{selectedCount} {items} selected on this page.',\n};\n\nconst DEFAULT_ITEMS: BitkitBulkActionsItems = { one: 'item', other: 'items' };\n\nconst resolveItems = (items: BitkitBulkActionsItems, count: number) => {\n if (typeof items === 'string') return items;\n return count === 1 ? items.one : items.other;\n};\n\nexport interface BitkitBulkActionsRowProps extends Omit<Table.RowProps, 'children'> {\n /** The bulk action buttons, rendered after `Cancel`. */\n children?: ReactNode;\n /** Must match the table's column count, so the row spans the full width. */\n colSpan: number;\n /** The counted noun. Default: `{ one: 'item', other: 'items' }` */\n items?: BitkitBulkActionsItems;\n labels?: BitkitBulkActionsLabels;\n onCancel: () => void;\n /** Renders the `Select all {totalItems} {items}` link while `selectionState=\"allOnPage\"`. */\n onSelectAll?: () => void;\n selectedCount: number;\n /**\n * `some` — part of the page is selected. `allOnPage` — the whole page is selected, and the rows\n * beyond it are still on offer. `all` — everything across every page is selected.\n */\n selectionState: 'some' | 'allOnPage' | 'all';\n totalItems: number;\n}\n\n/**\n * The bar above the column headers that appears while rows are selected: what is selected, the\n * offer to widen the selection to every page, and the actions to run on it. Belongs in\n * `Table.Header`, before the `Table.Row` that holds the column headers.\n *\n * The count is mirrored into a visually hidden `aria-live` region, which is deliberately filled a\n * render after mount — a live region that enters the DOM with its text already in it is not\n * announced, so the first selection would go unspoken otherwise.\n *\n * @example\n * ```tsx\n * <Table.Header>\n * {selected.length > 0 && (\n * <BitkitBulkActionsRow\n * colSpan={COL_COUNT}\n * items={{ one: 'workflow', other: 'workflows' }}\n * onCancel={clearSelection}\n * onSelectAll={() => setAllAcrossPages(true)}\n * selectedCount={selected.length}\n * selectionState={selectionState}\n * totalItems={TOTAL_ITEMS}\n * >\n * <BitkitButton icon={IconMinusCircle} size=\"md\" variant=\"danger-secondary\">\n * Remove\n * </BitkitButton>\n * </BitkitBulkActionsRow>\n * )}\n * <Table.Row>{columnHeaders}</Table.Row>\n * </Table.Header>\n * ```\n */\nconst BitkitBulkActionsRow = forwardRef<HTMLTableRowElement, BitkitBulkActionsRowProps>((props, ref) => {\n const {\n children,\n colSpan,\n items = DEFAULT_ITEMS,\n labels: labelsProp,\n onCancel,\n onSelectAll,\n selectedCount,\n selectionState,\n totalItems,\n ...rest\n } = props;\n\n const styles = useTableStyles();\n const labels = { ...DEFAULT_LABELS, ...labelsProp };\n\n const countLabel = {\n all: labels.allSelected,\n allOnPage: labels.selectedOnPage,\n some: labels.selected,\n }[selectionState];\n const count = selectionState === 'all' ? totalItems : selectedCount;\n\n const countText = formatLabel(countLabel, {\n items: resolveItems(items, count),\n selectedCount,\n totalItems,\n });\n\n const selectAllText = formatLabel(labels.selectAll, {\n items: resolveItems(items, totalItems),\n selectedCount,\n totalItems,\n });\n\n const [announcement, setAnnouncement] = useState('');\n\n useEffect(() => {\n setAnnouncement(countText);\n }, [countText]);\n\n return (\n <Table.Row ref={ref} {...rest}>\n <Table.Cell colSpan={colSpan} css={styles.utilityCell}>\n <Box css={styles.bulkActionsGroup}>\n <Text color=\"text/body\" textStyle=\"body/md/regular\">\n {countText}\n </Text>\n <VisuallyHidden aria-live=\"polite\">{announcement}</VisuallyHidden>\n {selectionState === 'allOnPage' && !!onSelectAll && (\n <BitkitButton onClick={onSelectAll} size=\"sm\" variant=\"tertiary\">\n {selectAllText}\n </BitkitButton>\n )}\n <Box css={styles.bulkActionsButtons}>\n <BitkitButton onClick={onCancel} size=\"md\" variant=\"tertiary\">\n {labels.cancel}\n </BitkitButton>\n {children}\n </Box>\n </Box>\n </Table.Cell>\n </Table.Row>\n );\n});\n\nBitkitBulkActionsRow.displayName = 'BitkitBulkActionsRow';\n\nexport default BitkitBulkActionsRow;\n"],"mappings":";;;;;;;;;AAkCA,IAAM,iBAAoD;CACxD,aAAa;CACb,QAAQ;CACR,WAAW;CACX,UAAU;CACV,gBAAgB;AAClB;AAEA,IAAM,gBAAwC;CAAE,KAAK;CAAQ,OAAO;AAAQ;AAE5E,IAAM,gBAAgB,OAA+B,UAAkB;CACrE,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,UAAU,IAAI,MAAM,MAAM,MAAM;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,IAAM,uBAAuB,YAA4D,OAAO,QAAQ;CACtG,MAAM,EACJ,UACA,SACA,QAAQ,eACR,QAAQ,YACR,UACA,aACA,eACA,gBACA,YACA,GAAG,SACD;CAEJ,MAAM,SAAS,eAAe;CAC9B,MAAM,SAAS;EAAE,GAAG;EAAgB,GAAG;CAAW;CAElD,MAAM,aAAa;EACjB,KAAK,OAAO;EACZ,WAAW,OAAO;EAClB,MAAM,OAAO;CACf,EAAE;CAGF,MAAM,YAAY,YAAY,YAAY;EACxC,OAAO,aAAa,OAHR,mBAAmB,QAAQ,aAAa,aAGpB;EAChC;EACA;CACF,CAAC;CAED,MAAM,gBAAgB,YAAY,OAAO,WAAW;EAClD,OAAO,aAAa,OAAO,UAAU;EACrC;EACA;CACF,CAAC;CAED,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CAEnD,gBAAgB;EACd,gBAAgB,SAAS;CAC3B,GAAG,CAAC,SAAS,CAAC;CAEd,OACE,oBAAC,MAAM,KAAP;EAAgB;EAAK,GAAI;EACvB,UAAA,oBAAC,MAAM,MAAP;GAAqB;GAAS,KAAK,OAAO;GACxC,UAAA,qBAAC,KAAD;IAAK,KAAK,OAAO;IAAjB,UAAA;KACE,oBAAC,MAAD;MAAM,OAAM;MAAY,WAAU;MAC/B,UAAA;KACG,CAAA;KACN,oBAAC,gBAAD;MAAgB,aAAU;MAAU,UAAA;KAA6B,CAAA;KAChE,mBAAmB,eAAe,CAAC,CAAC,eACnC,oBAAC,cAAD;MAAc,SAAS;MAAa,MAAK;MAAK,SAAQ;MACnD,UAAA;KACW,CAAA;KAEhB,qBAAC,KAAD;MAAK,KAAK,OAAO;MAAjB,UAAA,CACE,oBAAC,cAAD;OAAc,SAAS;OAAU,MAAK;OAAK,SAAQ;OAChD,UAAA,OAAO;MACI,CAAA,GACb,QACE;;IACF;;EACK,CAAA;CACH,CAAA;AAEf,CAAC;AAED,qBAAqB,cAAc"}
|
|
@@ -1,66 +1,42 @@
|
|
|
1
1
|
import AssetSelectChevron from "../../utilities/AssetSelectChevron.js";
|
|
2
2
|
import { Box } from "@chakra-ui/react/box";
|
|
3
|
-
import { chakra } from "@chakra-ui/react/styled-system";
|
|
4
3
|
import { forwardRef } from "react";
|
|
5
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { Collapsible } from "@chakra-ui/react/collapsible";
|
|
7
|
-
import { Table } from "@chakra-ui/react/table";
|
|
6
|
+
import { Table, useTableStyles } from "@chakra-ui/react/table";
|
|
8
7
|
//#region lib/components/BitkitTable/BitkitExpandableRow.tsx
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
display: "flex",
|
|
21
|
-
justifyContent: "center",
|
|
22
|
-
padding: "12",
|
|
23
|
-
paddingInlineEnd: "4",
|
|
24
|
-
width: "full"
|
|
25
|
-
};
|
|
26
|
-
var expandedContentCss = {
|
|
27
|
-
paddingBlock: "16",
|
|
28
|
-
paddingInlineEnd: "16",
|
|
29
|
-
paddingInlineStart: "64"
|
|
30
|
-
};
|
|
31
|
-
var BitkitExpandableRow = forwardRef(({ children, colSpan, defaultOpen = false, expandedContent }, ref) => /* @__PURE__ */ jsx(Collapsible.Root, {
|
|
32
|
-
asChild: true,
|
|
33
|
-
defaultOpen,
|
|
34
|
-
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Table.Row, {
|
|
35
|
-
ref,
|
|
36
|
-
children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
37
|
-
css: expandCellCss,
|
|
38
|
-
children: /* @__PURE__ */ jsx(Collapsible.Trigger, {
|
|
39
|
-
asChild: true,
|
|
40
|
-
children: /* @__PURE__ */ jsx(chakra.button, {
|
|
8
|
+
var BitkitExpandableRow = forwardRef(({ children, colSpan, defaultOpen = false, expandedContent }, ref) => {
|
|
9
|
+
const styles = useTableStyles();
|
|
10
|
+
return /* @__PURE__ */ jsx(Collapsible.Root, {
|
|
11
|
+
asChild: true,
|
|
12
|
+
defaultOpen,
|
|
13
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Table.Row, {
|
|
14
|
+
ref,
|
|
15
|
+
css: styles.expandableRow,
|
|
16
|
+
children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
17
|
+
css: styles.expandCell,
|
|
18
|
+
children: /* @__PURE__ */ jsx(Collapsible.Trigger, {
|
|
41
19
|
"aria-label": "Toggle row details",
|
|
42
|
-
css:
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
css: styles.expandTrigger,
|
|
21
|
+
children: /* @__PURE__ */ jsx(Collapsible.Indicator, {
|
|
22
|
+
asChild: true,
|
|
23
|
+
children: /* @__PURE__ */ jsx(AssetSelectChevron, { color: "button/secondary/text" })
|
|
24
|
+
})
|
|
45
25
|
})
|
|
26
|
+
}), children]
|
|
27
|
+
}), /* @__PURE__ */ jsx(Table.Row, {
|
|
28
|
+
css: styles.expandedRow,
|
|
29
|
+
children: /* @__PURE__ */ jsx(Table.Cell, {
|
|
30
|
+
colSpan,
|
|
31
|
+
css: styles.expandedCell,
|
|
32
|
+
children: /* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsx(Box, {
|
|
33
|
+
css: styles.expandedContent,
|
|
34
|
+
children: expandedContent
|
|
35
|
+
}) })
|
|
46
36
|
})
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
children: /* @__PURE__ */ jsx(Table.Cell, {
|
|
51
|
-
colSpan,
|
|
52
|
-
css: {
|
|
53
|
-
paddingBlock: 0,
|
|
54
|
-
paddingInline: 0,
|
|
55
|
-
height: 0
|
|
56
|
-
},
|
|
57
|
-
children: /* @__PURE__ */ jsx(Collapsible.Content, { children: /* @__PURE__ */ jsx(Box, {
|
|
58
|
-
css: expandedContentCss,
|
|
59
|
-
children: expandedContent
|
|
60
|
-
}) })
|
|
61
|
-
})
|
|
62
|
-
})] })
|
|
63
|
-
}));
|
|
37
|
+
})] })
|
|
38
|
+
});
|
|
39
|
+
});
|
|
64
40
|
BitkitExpandableRow.displayName = "BitkitExpandableRow";
|
|
65
41
|
//#endregion
|
|
66
42
|
export { BitkitExpandableRow as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitExpandableRow.js","names":[],"sources":["../../../lib/components/BitkitTable/BitkitExpandableRow.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Collapsible } from '@chakra-ui/react/collapsible';\nimport {
|
|
1
|
+
{"version":3,"file":"BitkitExpandableRow.js","names":[],"sources":["../../../lib/components/BitkitTable/BitkitExpandableRow.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Collapsible } from '@chakra-ui/react/collapsible';\nimport { Table, useTableStyles } from '@chakra-ui/react/table';\nimport { forwardRef, type ReactNode } from 'react';\n\nimport AssetSelectChevron from '../../utilities/AssetSelectChevron';\n\nexport interface BitkitExpandableRowProps {\n children: ReactNode;\n colSpan: number;\n defaultOpen?: boolean;\n expandedContent: ReactNode;\n}\n\nconst BitkitExpandableRow = forwardRef<HTMLTableRowElement, BitkitExpandableRowProps>(\n ({ children, colSpan, defaultOpen = false, expandedContent }, ref) => {\n const styles = useTableStyles();\n\n return (\n <Collapsible.Root asChild defaultOpen={defaultOpen}>\n <>\n <Table.Row ref={ref} css={styles.expandableRow}>\n <Table.Cell css={styles.expandCell}>\n <Collapsible.Trigger aria-label=\"Toggle row details\" css={styles.expandTrigger}>\n <Collapsible.Indicator asChild>\n <AssetSelectChevron color=\"button/secondary/text\" />\n </Collapsible.Indicator>\n </Collapsible.Trigger>\n </Table.Cell>\n {children}\n </Table.Row>\n <Table.Row css={styles.expandedRow}>\n <Table.Cell colSpan={colSpan} css={styles.expandedCell}>\n <Collapsible.Content>\n <Box css={styles.expandedContent}>{expandedContent}</Box>\n </Collapsible.Content>\n </Table.Cell>\n </Table.Row>\n </>\n </Collapsible.Root>\n );\n },\n);\n\nBitkitExpandableRow.displayName = 'BitkitExpandableRow';\n\nexport default BitkitExpandableRow;\n"],"mappings":";;;;;;;AAcA,IAAM,sBAAsB,YACzB,EAAE,UAAU,SAAS,cAAc,OAAO,mBAAmB,QAAQ;CACpE,MAAM,SAAS,eAAe;CAE9B,OACE,oBAAC,YAAY,MAAb;EAAkB,SAAA;EAAqB;EACrC,UAAA,qBAAA,YAAA,EAAA,UAAA,CACE,qBAAC,MAAM,KAAP;GAAgB;GAAK,KAAK,OAAO;GAAjC,UAAA,CACE,oBAAC,MAAM,MAAP;IAAY,KAAK,OAAO;IACtB,UAAA,oBAAC,YAAY,SAAb;KAAqB,cAAW;KAAqB,KAAK,OAAO;KAC/D,UAAA,oBAAC,YAAY,WAAb;MAAuB,SAAA;MACrB,UAAA,oBAAC,oBAAD,EAAoB,OAAM,wBAAyB,CAAA;KAC9B,CAAA;IACJ,CAAA;GACX,CAAA,GACX,QACQ;EACX,CAAA,GAAA,oBAAC,MAAM,KAAP;GAAW,KAAK,OAAO;GACrB,UAAA,oBAAC,MAAM,MAAP;IAAqB;IAAS,KAAK,OAAO;IACxC,UAAA,oBAAC,YAAY,SAAb,EAAA,UACE,oBAAC,KAAD;KAAK,KAAK,OAAO;KAAkB,UAAA;IAAqB,CAAA,EACrC,CAAA;GACX,CAAA;EACH,CAAA,CACX,EAAA,CAAA;CACc,CAAA;AAEtB,CACF;AAEA,oBAAoB,cAAc"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Table } from '@chakra-ui/react/table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface BitkitFilterRowProps extends Omit<Table.RowProps, 'children'> {
|
|
4
|
+
/** The filter controls. Laid out in a wrapping row, so any number of them fits. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Must match the table's column count, so the row spans the full width. */
|
|
7
|
+
colSpan: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A full-width row of filter controls above the column headers. Belongs in `Table.Header`, before
|
|
11
|
+
* the `Table.Row` that holds the column headers.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Table.Header>
|
|
16
|
+
* <BitkitFilterRow colSpan={COL_COUNT}>
|
|
17
|
+
* <BitkitSearchInput onChange={...} value={search} />
|
|
18
|
+
* <BitkitSelect items={teams} onValueChange={...} value={team} />
|
|
19
|
+
* </BitkitFilterRow>
|
|
20
|
+
* <Table.Row>{columnHeaders}</Table.Row>
|
|
21
|
+
* </Table.Header>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare const BitkitFilterRow: import('react').ForwardRefExoticComponent<BitkitFilterRowProps & import('react').RefAttributes<HTMLTableRowElement>>;
|
|
25
|
+
export default BitkitFilterRow;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Box } from "@chakra-ui/react/box";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Table, useTableStyles } from "@chakra-ui/react/table";
|
|
5
|
+
//#region lib/components/BitkitTable/BitkitFilterRow.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A full-width row of filter controls above the column headers. Belongs in `Table.Header`, before
|
|
8
|
+
* the `Table.Row` that holds the column headers.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Table.Header>
|
|
13
|
+
* <BitkitFilterRow colSpan={COL_COUNT}>
|
|
14
|
+
* <BitkitSearchInput onChange={...} value={search} />
|
|
15
|
+
* <BitkitSelect items={teams} onValueChange={...} value={team} />
|
|
16
|
+
* </BitkitFilterRow>
|
|
17
|
+
* <Table.Row>{columnHeaders}</Table.Row>
|
|
18
|
+
* </Table.Header>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
var BitkitFilterRow = forwardRef((props, ref) => {
|
|
22
|
+
const { children, colSpan, ...rest } = props;
|
|
23
|
+
const styles = useTableStyles();
|
|
24
|
+
return /* @__PURE__ */ jsx(Table.Row, {
|
|
25
|
+
ref,
|
|
26
|
+
...rest,
|
|
27
|
+
children: /* @__PURE__ */ jsx(Table.Cell, {
|
|
28
|
+
colSpan,
|
|
29
|
+
css: styles.utilityCell,
|
|
30
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
31
|
+
css: styles.filterControls,
|
|
32
|
+
children
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
BitkitFilterRow.displayName = "BitkitFilterRow";
|
|
38
|
+
//#endregion
|
|
39
|
+
export { BitkitFilterRow as default };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=BitkitFilterRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitkitFilterRow.js","names":[],"sources":["../../../lib/components/BitkitTable/BitkitFilterRow.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Table, useTableStyles } from '@chakra-ui/react/table';\nimport { forwardRef, type ReactNode } from 'react';\n\nexport interface BitkitFilterRowProps extends Omit<Table.RowProps, 'children'> {\n /** The filter controls. Laid out in a wrapping row, so any number of them fits. */\n children: ReactNode;\n /** Must match the table's column count, so the row spans the full width. */\n colSpan: number;\n}\n\n/**\n * A full-width row of filter controls above the column headers. Belongs in `Table.Header`, before\n * the `Table.Row` that holds the column headers.\n *\n * @example\n * ```tsx\n * <Table.Header>\n * <BitkitFilterRow colSpan={COL_COUNT}>\n * <BitkitSearchInput onChange={...} value={search} />\n * <BitkitSelect items={teams} onValueChange={...} value={team} />\n * </BitkitFilterRow>\n * <Table.Row>{columnHeaders}</Table.Row>\n * </Table.Header>\n * ```\n */\nconst BitkitFilterRow = forwardRef<HTMLTableRowElement, BitkitFilterRowProps>((props, ref) => {\n const { children, colSpan, ...rest } = props;\n const styles = useTableStyles();\n\n return (\n <Table.Row ref={ref} {...rest}>\n <Table.Cell colSpan={colSpan} css={styles.utilityCell}>\n <Box css={styles.filterControls}>{children}</Box>\n </Table.Cell>\n </Table.Row>\n );\n});\n\nBitkitFilterRow.displayName = 'BitkitFilterRow';\n\nexport default BitkitFilterRow;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,IAAM,kBAAkB,YAAuD,OAAO,QAAQ;CAC5F,MAAM,EAAE,UAAU,SAAS,GAAG,SAAS;CACvC,MAAM,SAAS,eAAe;CAE9B,OACE,oBAAC,MAAM,KAAP;EAAgB;EAAK,GAAI;EACvB,UAAA,oBAAC,MAAM,MAAP;GAAqB;GAAS,KAAK,OAAO;GACxC,UAAA,oBAAC,KAAD;IAAK,KAAK,OAAO;IAAiB;GAAc,CAAA;EACtC,CAAA;CACH,CAAA;AAEf,CAAC;AAED,gBAAgB,cAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Table } from '@chakra-ui/react/table';
|
|
2
|
+
export interface BitkitLinkedRowProps extends Omit<Table.RowProps, 'onClick'> {
|
|
3
|
+
/** Target of the row link. Passed down to the `BitkitLinkedRow.LinkCell` inside the row. */
|
|
4
|
+
href: string;
|
|
5
|
+
/** Renders the link with the external-link affordance and opens it in a new tab. */
|
|
6
|
+
isExternal?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type BitkitLinkedRowLinkCellProps = Table.CellProps;
|
|
9
|
+
declare const _default: import('react').ForwardRefExoticComponent<BitkitLinkedRowProps & import('react').RefAttributes<HTMLTableRowElement>> & {
|
|
10
|
+
LinkCell: import('react').ForwardRefExoticComponent<Table.CellProps & import('react').RefAttributes<HTMLTableCellElement>>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { withSubComponents } from "../../utilities/withSubComponents.js";
|
|
2
|
+
import BitkitLink from "../BitkitLink/BitkitLink.js";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as createContext$1 } from "@chakra-ui/react";
|
|
6
|
+
import { Table, useTableStyles } from "@chakra-ui/react/table";
|
|
7
|
+
//#region lib/components/BitkitTable/BitkitLinkedRow.tsx
|
|
8
|
+
var [ContextProvider, useLinkedRowContext] = createContext$1({
|
|
9
|
+
name: "LinkedRowContext",
|
|
10
|
+
hookName: "useLinkedRowContext",
|
|
11
|
+
providerName: "<BitkitLinkedRow />"
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* A table row that navigates as a whole. Exactly one of its cells must be a
|
|
15
|
+
* `BitkitLinkedRow.LinkCell` — that cell's content becomes the accessible link text, and its
|
|
16
|
+
* stretched pseudo-element makes the entire row the click and focus target.
|
|
17
|
+
*
|
|
18
|
+
* Interactive elements in the other cells (buttons, checkboxes, other links) stay clickable: they
|
|
19
|
+
* are lifted above the stretched link, so a `BitkitRowActionsCell` works inside a linked row.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <BitkitLinkedRow href={`/workflows/${row.id}`}>
|
|
24
|
+
* <BitkitLinkedRow.LinkCell>{row.name}</BitkitLinkedRow.LinkCell>
|
|
25
|
+
* <Table.Cell>{row.status}</Table.Cell>
|
|
26
|
+
* <BitkitRowActionsCell actions={actions} />
|
|
27
|
+
* </BitkitLinkedRow>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
var BitkitLinkedRow = forwardRef((props, ref) => {
|
|
31
|
+
const { children, href, isExternal, ...rest } = props;
|
|
32
|
+
const styles = useTableStyles();
|
|
33
|
+
return /* @__PURE__ */ jsx(ContextProvider, {
|
|
34
|
+
value: {
|
|
35
|
+
href,
|
|
36
|
+
isExternal
|
|
37
|
+
},
|
|
38
|
+
children: /* @__PURE__ */ jsx(Table.Row, {
|
|
39
|
+
ref,
|
|
40
|
+
css: styles.linkedRow,
|
|
41
|
+
...rest,
|
|
42
|
+
children
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
BitkitLinkedRow.displayName = "BitkitLinkedRow";
|
|
47
|
+
/**
|
|
48
|
+
* The cell that carries the row's link. Its children are the accessible link text, so give it the
|
|
49
|
+
* cell that names the row. Reads `href` and `isExternal` from the surrounding `BitkitLinkedRow`.
|
|
50
|
+
*/
|
|
51
|
+
var LinkCell = forwardRef((props, ref) => {
|
|
52
|
+
const { children, ...rest } = props;
|
|
53
|
+
const { href, isExternal } = useLinkedRowContext();
|
|
54
|
+
const styles = useTableStyles();
|
|
55
|
+
return /* @__PURE__ */ jsx(Table.Cell, {
|
|
56
|
+
ref,
|
|
57
|
+
...rest,
|
|
58
|
+
children: /* @__PURE__ */ jsx(BitkitLink, {
|
|
59
|
+
css: styles.rowLink,
|
|
60
|
+
"data-row-link": true,
|
|
61
|
+
href,
|
|
62
|
+
isExternal,
|
|
63
|
+
children
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
LinkCell.displayName = "BitkitLinkedRow.LinkCell";
|
|
68
|
+
var BitkitLinkedRow_default = withSubComponents(BitkitLinkedRow, { LinkCell });
|
|
69
|
+
//#endregion
|
|
70
|
+
export { BitkitLinkedRow_default as default };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=BitkitLinkedRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitkitLinkedRow.js","names":[],"sources":["../../../lib/components/BitkitTable/BitkitLinkedRow.tsx"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport { createContext } from '@chakra-ui/react';\nimport { Table, useTableStyles } from '@chakra-ui/react/table';\nimport { forwardRef } from 'react';\n\nimport { withSubComponents } from '../../utilities/withSubComponents';\nimport BitkitLink from '../BitkitLink/BitkitLink';\n\ninterface LinkedRowContext {\n href: string;\n isExternal?: boolean;\n}\n\nconst [ContextProvider, useLinkedRowContext] = createContext<LinkedRowContext>({\n name: 'LinkedRowContext',\n hookName: 'useLinkedRowContext',\n providerName: '<BitkitLinkedRow />',\n});\n\nexport interface BitkitLinkedRowProps extends Omit<Table.RowProps, 'onClick'> {\n /** Target of the row link. Passed down to the `BitkitLinkedRow.LinkCell` inside the row. */\n href: string;\n /** Renders the link with the external-link affordance and opens it in a new tab. */\n isExternal?: boolean;\n}\n\n/**\n * A table row that navigates as a whole. Exactly one of its cells must be a\n * `BitkitLinkedRow.LinkCell` — that cell's content becomes the accessible link text, and its\n * stretched pseudo-element makes the entire row the click and focus target.\n *\n * Interactive elements in the other cells (buttons, checkboxes, other links) stay clickable: they\n * are lifted above the stretched link, so a `BitkitRowActionsCell` works inside a linked row.\n *\n * @example\n * ```tsx\n * <BitkitLinkedRow href={`/workflows/${row.id}`}>\n * <BitkitLinkedRow.LinkCell>{row.name}</BitkitLinkedRow.LinkCell>\n * <Table.Cell>{row.status}</Table.Cell>\n * <BitkitRowActionsCell actions={actions} />\n * </BitkitLinkedRow>\n * ```\n */\nconst BitkitLinkedRow = forwardRef<HTMLTableRowElement, BitkitLinkedRowProps>((props, ref) => {\n const { children, href, isExternal, ...rest } = props;\n const styles = useTableStyles();\n\n return (\n <ContextProvider value={{ href, isExternal }}>\n <Table.Row ref={ref} css={styles.linkedRow} {...rest}>\n {children}\n </Table.Row>\n </ContextProvider>\n );\n});\n\nBitkitLinkedRow.displayName = 'BitkitLinkedRow';\n\nexport type BitkitLinkedRowLinkCellProps = Table.CellProps;\n\n/**\n * The cell that carries the row's link. Its children are the accessible link text, so give it the\n * cell that names the row. Reads `href` and `isExternal` from the surrounding `BitkitLinkedRow`.\n */\nconst LinkCell = forwardRef<HTMLTableCellElement, BitkitLinkedRowLinkCellProps>((props, ref) => {\n const { children, ...rest } = props;\n const { href, isExternal } = useLinkedRowContext();\n const styles = useTableStyles();\n\n return (\n <Table.Cell ref={ref} {...rest}>\n <BitkitLink css={styles.rowLink} data-row-link href={href} isExternal={isExternal}>\n {children}\n </BitkitLink>\n </Table.Cell>\n );\n});\n\nLinkCell.displayName = 'BitkitLinkedRow.LinkCell';\n\nexport default withSubComponents(BitkitLinkedRow, { LinkCell });\n"],"mappings":";;;;;;;AAaA,IAAM,CAAC,iBAAiB,uBAAuB,gBAAgC;CAC7E,MAAM;CACN,UAAU;CACV,cAAc;AAChB,CAAC;;;;;;;;;;;;;;;;;;AA0BD,IAAM,kBAAkB,YAAuD,OAAO,QAAQ;CAC5F,MAAM,EAAE,UAAU,MAAM,YAAY,GAAG,SAAS;CAChD,MAAM,SAAS,eAAe;CAE9B,OACE,oBAAC,iBAAD;EAAiB,OAAO;GAAE;GAAM;EAAW;EACzC,UAAA,oBAAC,MAAM,KAAP;GAAgB;GAAK,KAAK,OAAO;GAAW,GAAI;GAC7C;EACQ,CAAA;CACI,CAAA;AAErB,CAAC;AAED,gBAAgB,cAAc;;;;;AAQ9B,IAAM,WAAW,YAAgE,OAAO,QAAQ;CAC9F,MAAM,EAAE,UAAU,GAAG,SAAS;CAC9B,MAAM,EAAE,MAAM,eAAe,oBAAoB;CACjD,MAAM,SAAS,eAAe;CAE9B,OACE,oBAAC,MAAM,MAAP;EAAiB;EAAK,GAAI;EACxB,UAAA,oBAAC,YAAD;GAAY,KAAK,OAAO;GAAS,iBAAA;GAAoB;GAAkB;GACpE;EACS,CAAA;CACF,CAAA;AAEhB,CAAC;AAED,SAAS,cAAc;AAEvB,IAAA,0BAAe,kBAAkB,iBAAiB,EAAE,SAAS,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Table } from '@chakra-ui/react/table';
|
|
2
|
+
import { MouseEvent } from 'react';
|
|
3
|
+
import { BitkitIconComponent } from '../../icons';
|
|
4
|
+
/** One row action, rendered either as an inline control button or as an action menu item. */
|
|
5
|
+
export interface BitkitRowAction {
|
|
6
|
+
/** Renders the action in the danger color set. */
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
/** Makes the action a link instead of a button. */
|
|
9
|
+
href?: string;
|
|
10
|
+
icon: BitkitIconComponent;
|
|
11
|
+
/** Only with `href`: opens the link in a new tab and adds the external-link affordance. */
|
|
12
|
+
isExternal?: boolean;
|
|
13
|
+
/** Accessible name of the inline button, and the visible text of the menu item. Must be unique
|
|
14
|
+
* within `actions`, since it keys the list. */
|
|
15
|
+
label: string;
|
|
16
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
17
|
+
state?: 'disabled';
|
|
18
|
+
}
|
|
19
|
+
export interface BitkitRowActionsCellProps extends Omit<Table.CellProps, 'children' | 'onClick'> {
|
|
20
|
+
/** Up to two actions render as inline icon buttons; three or more collapse into an action menu. */
|
|
21
|
+
actions: BitkitRowAction[];
|
|
22
|
+
/** Accessible name of the action menu trigger, used from the third action on. Default: `More actions` */
|
|
23
|
+
menuLabel?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The trailing cell of a table row, holding its actions. The column shrinks to fit the buttons.
|
|
27
|
+
*
|
|
28
|
+
* Up to two actions render as inline icon buttons; from the third on they collapse into a single
|
|
29
|
+
* action menu, so the column width stays predictable. Clicks are kept inside the cell, so the
|
|
30
|
+
* actions work in a `BitkitLinkedRow` without triggering the row link.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <BitkitRowActionsCell
|
|
35
|
+
* actions={[
|
|
36
|
+
* { icon: IconPencil, label: 'Edit', onClick: onEdit },
|
|
37
|
+
* { danger: true, icon: IconMinusCircle, label: 'Remove', onClick: onRemove },
|
|
38
|
+
* ]}
|
|
39
|
+
* />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare const BitkitRowActionsCell: import('react').ForwardRefExoticComponent<BitkitRowActionsCellProps & import('react').RefAttributes<HTMLTableCellElement>>;
|
|
43
|
+
export default BitkitRowActionsCell;
|