From eff870d761597adc15f67f14b4ab39294ce0ce08 Mon Sep 17 00:00:00 2001 From: NicolasRichel Date: Mon, 14 Nov 2022 16:42:03 +0100 Subject: [PATCH] PATCH: fix(table): update styles and doc + add typings --- .eslintrc.json | 2 +- .../BIMDataTable/BIMDataTable.d.ts | 33 +++++++++++++++++++ .../BIMDataTable/BIMDataTable.vue | 2 +- .../BIMDataTable/_BIMDataTable.scss | 2 ++ src/web/views/Components/Table/props-data.js | 8 +++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/BIMDataComponents/BIMDataTable/BIMDataTable.d.ts diff --git a/.eslintrc.json b/.eslintrc.json index 8a7d48c9..4a87c8ea 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -15,7 +15,7 @@ "ecmaVersion": 11, "sourceType": "module" }, - "ignorePatterns": ["/dist", "/dist-web"], + "ignorePatterns": ["/dist", "/dist-web", "*.d.ts"], "rules": { "prettier/prettier": "error", "indent": "off", diff --git a/src/BIMDataComponents/BIMDataTable/BIMDataTable.d.ts b/src/BIMDataComponents/BIMDataTable/BIMDataTable.d.ts new file mode 100644 index 00000000..54dfd6b5 --- /dev/null +++ b/src/BIMDataComponents/BIMDataTable/BIMDataTable.d.ts @@ -0,0 +1,33 @@ +declare namespace BIMDataTable { + type Columns = string[] | Column[]; + type Rows = string[][] | Object[]; + + interface Data { + columns: Columns; + rows: Rows; + } + + interface Style { + tableWidth?: string; + tableLayout?: string; + rowHeight?: number; + placeholder?: string; + } + + interface Config { + rowKey?: string; + selectable?: boolean; + sortable?: boolean; + paginated?: boolean; + perPage?: number; + } + + interface Column { + id: string; + type?: "number" | "string" | "enum" | "boolean" | "date"; + label?: string; + width?: string; + align?: "left" | "center" | "right"; + sort?: (a: any, b: any) => number; + } +} diff --git a/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue b/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue index d6e23f69..f58c939f 100644 --- a/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue +++ b/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue @@ -65,7 +65,7 @@ class="bimdata-table__container__placeholder" v-if="rows.length === 0" :style="{ - height: `calc(100% - ${placeholder ? rowHeight : 0}px)`, + height: `calc(100% - ${rowHeight}px)`, }" > diff --git a/src/BIMDataComponents/BIMDataTable/_BIMDataTable.scss b/src/BIMDataComponents/BIMDataTable/_BIMDataTable.scss index 9082df83..67f1648e 100644 --- a/src/BIMDataComponents/BIMDataTable/_BIMDataTable.scss +++ b/src/BIMDataComponents/BIMDataTable/_BIMDataTable.scss @@ -4,6 +4,8 @@ background-color: var(--color-white); &__container { + height: 100%; + table { border-collapse: collapse; border-spacing: 0; diff --git a/src/web/views/Components/Table/props-data.js b/src/web/views/Components/Table/props-data.js index 49ef44ce..5bef1893 100644 --- a/src/web/views/Components/Table/props-data.js +++ b/src/web/views/Components/Table/props-data.js @@ -24,6 +24,14 @@ export default [ "Use this props to define table rows.", "[ ['John', 'Doe', 23], ['Jane', 'Doe', 24] ]", ], + [ + "rowKey", + "String", + "", + "", + "Define the field to be used as a key for each row.", + "", + ], [ "rowHeight", "Number",