Skip to content

Commit 436e8c1

Browse files
Matt Grandejacobmllr95
Matt Grande
authored andcommitted
feat(table): add TypeScript definitions for table fields (#2867)
* feat(table): Add TypeScript definitions for table fields * Changes from code review VueVariant -> TableVariant interface TableFieldArray -> type TableFieldArray Make fields optional * Update README.md * Update README.md * Update index.d.ts * Updates from code review * Update index.d.ts * Update index.d.ts Change to `?:`
1 parent 547477b commit 436e8c1

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

docs/markdown/reference/color-variants/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ Note the `link` variant does not have an outline version.
7272

7373
### Table variants
7474

75-
All the **base variants**:
75+
All the **base variants** plus:
76+
77+
- `active`
7678

7779
These variants translate to class names `table-<variant>`.
7880

src/components/table/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ modifier properties (make sure your field keys do not conflict with these names)
7070

7171
| Property | Type | Description |
7272
| --------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
73-
| `_cellVariants` | Object | Bootstrap contextual state applied to individual cells. Keyed by field (Supported values: `active`, `success`, `info`, `warning`, `danger`). These variants map to classes `table-${variant}` or `bg-${variant}` (when the `dark` prop is set). |
74-
| `_rowVariant` | String | Bootstrap contextual state applied to the entire row (Supported values: `active`, `success`, `info`, `warning`, `danger`). These variants map to classes `table-${variant}` or `bg-${variant}` (when the `dark` prop is set) |
73+
| `_cellVariants` | Object | Bootstrap contextual state applied to individual cells. Keyed by field (See the [Color Variants](/docs/reference/color-variants) for supported values). These variants map to classes `table-${variant}` or `bg-${variant}` (when the `dark` prop is set). |
74+
| `_rowVariant` | String | Bootstrap contextual state applied to the entire row (See the [Color Variants](/docs/reference/color-variants) for supported values). These variants map to classes `table-${variant}` or `bg-${variant}` (when the `dark` prop is set) |
7575
| `_showDetails` | Boolean | Used to trigger the display of the `row-details` scoped slot. See section [Row details support](#row-details-support) below for additional information |
7676

7777
**Example: Using variants for table cells**

src/index.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@ declare module 'bootstrap-vue' {
1414

1515
export default VuePlugin
1616

17+
type TableVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' | 'primary' | 'secondary' | 'light' | 'dark'
18+
type SortDirection = 'asc' | 'desc' | 'last'
19+
type FormatterCallback = ((value: mixed, key: string, item: mixed) => any)
20+
21+
export interface TableField {
22+
label?: string
23+
headerTitle?: string
24+
headerAbbr?: string
25+
class?: string | string[]
26+
formatter?: string | FormatterCallback
27+
sortable?: boolean
28+
sortDirection?: SortDirection
29+
tdClass?: string | string[] | FormatterCallback
30+
thClass?: string | string[]
31+
thStyle?: mixed
32+
variant?: TableVariant | string
33+
tdAttr?: mixed | ((value: mixed, key: string, item: mixed) => mixed)
34+
isRowHeader?: boolean
35+
}
36+
export interface TableFieldObject {
37+
[key: string]: TableField
38+
}
39+
export type TableFieldArray = Array<string | ({key: string} & TableField)>
40+
1741
// Interfaces
1842
export interface Alert extends Vue {
1943
dismiss: () => void
@@ -115,6 +139,7 @@ declare module 'bootstrap-vue' {
115139
export interface Progress extends Vue {}
116140
export interface Table extends Vue {
117141
refresh: () => void
142+
fields?: TableFieldObject | TableFieldArray
118143
}
119144
export interface Tabs extends Vue {}
120145
export interface Tooltip extends Vue {

0 commit comments

Comments
 (0)