From 46e4fdb74d3be7162285116aec5a084f52ed986d Mon Sep 17 00:00:00 2001 From: Matt Grande Date: Mon, 18 Mar 2019 10:43:44 -0400 Subject: [PATCH 1/8] feat(table): Add TypeScript definitions for table fields --- src/index.d.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/index.d.ts b/src/index.d.ts index 053143c5107..7a000f2fa14 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -14,6 +14,30 @@ declare module 'bootstrap-vue' { export default VuePlugin + type VueVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' + type SortDirection = 'asc' | 'desc' + type FormatterCallback = ((value: mixed, key: string, item: mixed) => string) + + export interface TableField { + label?: string + headerTitle?: string + headerAbbr?: string + class?: string | string[] + formatter?: string | FormatterCallback + sortable: boolean + sortDirection: SortDirection + tdClass: string | string[] | FormatterCallback + thClass: string | string[] + thStyle: mixed + variant: VueVariant + tdAttr: mixed | ((value: mixed, key: string, item: mixed) => mixed) + isRowHeader: boolean + } + export interface TableFieldObject { + [key: string]: TableField + } + export interface TableFieldArray extends Array {} + // Interfaces export interface Alert extends Vue { dismiss: () => void @@ -115,6 +139,7 @@ declare module 'bootstrap-vue' { export interface Progress extends Vue {} export interface Table extends Vue { refresh: () => void + fields: TableFieldObject | TableFieldArray } export interface Tabs extends Vue {} export interface Tooltip extends Vue { From 5274dad6265839b0be9200a394d31376ac947262 Mon Sep 17 00:00:00 2001 From: Matt Grande Date: Tue, 19 Mar 2019 09:32:59 -0400 Subject: [PATCH 2/8] Changes from code review VueVariant -> TableVariant interface TableFieldArray -> type TableFieldArray Make fields optional --- src/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 7a000f2fa14..a291bbca2bd 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -14,7 +14,7 @@ declare module 'bootstrap-vue' { export default VuePlugin - type VueVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' + type TableVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' type SortDirection = 'asc' | 'desc' type FormatterCallback = ((value: mixed, key: string, item: mixed) => string) @@ -29,14 +29,14 @@ declare module 'bootstrap-vue' { tdClass: string | string[] | FormatterCallback thClass: string | string[] thStyle: mixed - variant: VueVariant + variant: TableVariant tdAttr: mixed | ((value: mixed, key: string, item: mixed) => mixed) isRowHeader: boolean } export interface TableFieldObject { [key: string]: TableField } - export interface TableFieldArray extends Array {} + export type TableFieldArray = Array // Interfaces export interface Alert extends Vue { @@ -139,7 +139,7 @@ declare module 'bootstrap-vue' { export interface Progress extends Vue {} export interface Table extends Vue { refresh: () => void - fields: TableFieldObject | TableFieldArray + fields?: TableFieldObject | TableFieldArray } export interface Tabs extends Vue {} export interface Tooltip extends Vue { From 1eaec1f24af49a47adf3e7a4b71d3f31835b2efc Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Tue, 19 Mar 2019 10:34:22 -0300 Subject: [PATCH 3/8] Update README.md --- docs/markdown/reference/color-variants/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/markdown/reference/color-variants/README.md b/docs/markdown/reference/color-variants/README.md index 33ce014ef50..f2ebb0560ec 100644 --- a/docs/markdown/reference/color-variants/README.md +++ b/docs/markdown/reference/color-variants/README.md @@ -72,7 +72,9 @@ Note the `link` variant does not have an outline version. ### Table variants -All the **base variants**: +All the **base variants** plus: + +- `active` These variants translate to class names `table-`. From 834079559dbda20f5d35c9ed3bacfff038e55cc0 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Tue, 19 Mar 2019 10:39:14 -0300 Subject: [PATCH 4/8] Update README.md --- src/components/table/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/table/README.md b/src/components/table/README.md index 74aef89bd59..907bb01ac7a 100644 --- a/src/components/table/README.md +++ b/src/components/table/README.md @@ -68,8 +68,8 @@ modifier properties (make sure your field keys do not conflict with these names) | Property | Type | Description | | --------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `_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). | -| `_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) | +| `_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). | +| `_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) | | `_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 | **Example: Using variants for table cells** From 2793bcc7df429b8103e47fdbe2da1ecc2636e0b9 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Tue, 19 Mar 2019 10:42:02 -0300 Subject: [PATCH 5/8] Update index.d.ts --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index a291bbca2bd..9c545c941d5 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -14,7 +14,7 @@ declare module 'bootstrap-vue' { export default VuePlugin - type TableVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' + type TableVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' | 'primary' | 'secondary' | 'light' | 'dark' type SortDirection = 'asc' | 'desc' type FormatterCallback = ((value: mixed, key: string, item: mixed) => string) From 5b57d17a81f6aadd428792f853948df6e06a78bd Mon Sep 17 00:00:00 2001 From: Matt Grande Date: Wed, 20 Mar 2019 10:10:01 -0400 Subject: [PATCH 6/8] Updates from code review --- src/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index a291bbca2bd..49ef86c2e6c 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -16,7 +16,7 @@ declare module 'bootstrap-vue' { type TableVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' type SortDirection = 'asc' | 'desc' - type FormatterCallback = ((value: mixed, key: string, item: mixed) => string) + type FormatterCallback = ((value: mixed, key: string, item: mixed) => any) export interface TableField { label?: string @@ -29,7 +29,7 @@ declare module 'bootstrap-vue' { tdClass: string | string[] | FormatterCallback thClass: string | string[] thStyle: mixed - variant: TableVariant + variant: TableVariant | string tdAttr: mixed | ((value: mixed, key: string, item: mixed) => mixed) isRowHeader: boolean } From 76c56bda3dc67c378287b4aa1e634f5e29839db3 Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Sun, 24 Mar 2019 21:22:31 -0300 Subject: [PATCH 7/8] Update index.d.ts --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index bdc469c0bad..4eab8381b0e 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -15,7 +15,7 @@ declare module 'bootstrap-vue' { export default VuePlugin type TableVariant = 'active' | 'success' | 'info' | 'warning' | 'danger' | 'primary' | 'secondary' | 'light' | 'dark' - type SortDirection = 'asc' | 'desc' + type SortDirection = 'asc' | 'desc' | 'last' type FormatterCallback = ((value: mixed, key: string, item: mixed) => any) export interface TableField { From 7f2b2a6a2c95bab244ff32400d9058f6dfca729a Mon Sep 17 00:00:00 2001 From: Matt Grande Date: Tue, 26 Mar 2019 11:18:52 -0400 Subject: [PATCH 8/8] Update index.d.ts Change to `?:` --- src/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 4eab8381b0e..a9f887bd194 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -24,14 +24,14 @@ declare module 'bootstrap-vue' { headerAbbr?: string class?: string | string[] formatter?: string | FormatterCallback - sortable: boolean - sortDirection: SortDirection - tdClass: string | string[] | FormatterCallback - thClass: string | string[] - thStyle: mixed - variant: TableVariant | string - tdAttr: mixed | ((value: mixed, key: string, item: mixed) => mixed) - isRowHeader: boolean + sortable?: boolean + sortDirection?: SortDirection + tdClass?: string | string[] | FormatterCallback + thClass?: string | string[] + thStyle?: mixed + variant?: TableVariant | string + tdAttr?: mixed | ((value: mixed, key: string, item: mixed) => mixed) + isRowHeader?: boolean } export interface TableFieldObject { [key: string]: TableField