UNPKG

5.17 kBTypeScriptView Raw
1/**
2 * Copyright 2018 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import * as Api from '../../../api/v2';
17/** @public */
18export interface TableColumn extends Api.GoogleActionsV2UiElementsTableCardColumnProperties {
19 /**
20 * Alias for `horizontalAlignment`
21 *
22 * Horizontal alignment of content w.r.t column. If unspecified, content
23 * will be aligned to the leading edge.
24 * @public
25 */
26 align?: Api.GoogleActionsV2UiElementsTableCardColumnPropertiesHorizontalAlignment;
27}
28/** @public */
29export interface TableRow {
30 /**
31 * Cells in this row.
32 * The first 3 cells are guaranteed to be shown but others might be cut on certain surfaces.
33 * Please test with the simulator to see which cells will be shown for a given surface.
34 *
35 * When provided as a string array, creates the cells as text.
36 * @public
37 */
38 cells?: (Api.GoogleActionsV2UiElementsTableCardCell | string)[];
39 /**
40 * Indicates whether there should be a divider after each row.
41 *
42 * Overrides top level `dividers` property for this specific row if set.
43 * @public
44 */
45 dividerAfter?: boolean;
46}
47/** @public */
48export interface TableOptions {
49 /**
50 * Overall title of the table.
51 *
52 * Must be set if subtitle is set.
53 * @public
54 */
55 title?: string;
56 /**
57 * Subtitle for the table.
58 * @public
59 */
60 subtitle?: string;
61 /**
62 * Image associated with the table.
63 * @public
64 */
65 image?: Api.GoogleActionsV2UiElementsImage;
66 /**
67 * Headers and alignment of columns with shortened name.
68 * Alias of `columnProperties` with the additional capability of accepting a number type.
69 *
70 * This property or `columnProperties` is required.
71 *
72 * When provided as string array, just the header field is set per column.
73 * When provided a number, it represents the number of elements per row.
74 * @public
75 */
76 columns?: (TableColumn | string)[] | number;
77 /**
78 * Headers and alignment of columns.
79 *
80 * This property or `columns` is required.
81 *
82 * When provided as string array, just the header field is set per column.
83 * @public
84 */
85 columnProperties?: (TableColumn | string)[];
86 /**
87 * Row data of the table.
88 *
89 * The first 3 rows are guaranteed to be shown but others might be cut on certain surfaces.
90 * Please test with the simulator to see which rows will be shown for a given surface.
91 *
92 * On surfaces that support the WEB_BROWSER capability, you can point the user to
93 * a web page with more data.
94 * @public
95 */
96 rows: (TableRow | string[])[];
97 /**
98 * Default dividerAfter for all rows.
99 * Individual rows with `dividerAfter` set will override for that specific row.
100 * @public
101 */
102 dividers?: boolean;
103 /**
104 * Buttons for the Table.
105 * Currently at most 1 button is supported.
106 * @public
107 */
108 buttons?: Api.GoogleActionsV2UiElementsButton | Api.GoogleActionsV2UiElementsButton[];
109}
110/**
111 * Creates a Table card.
112 *
113 * @example
114 * ```javascript
115 *
116 * // Simple table
117 * conv.ask('Simple Response')
118 * conv.ask(new Table({
119 * dividers: true,
120 * columns: ['header 1', 'header 2', 'header 3'],
121 * rows: [
122 * ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
123 * ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
124 * ],
125 * }))
126 *
127 * // All fields
128 * conv.ask('Simple Response')
129 * conv.ask(new Table({
130 * title: 'Table Title',
131 * subtitle: 'Table Subtitle',
132 * image: new Image({
133 * url: 'https://avatars0.githubusercontent.com/u/23533486',
134 * alt: 'Actions on Google'
135 * }),
136 * columns: [
137 * {
138 * header: 'header 1',
139 * align: 'CENTER',
140 * },
141 * {
142 * header: 'header 2',
143 * align: 'LEADING',
144 * },
145 * {
146 * header: 'header 3',
147 * align: 'TRAILING',
148 * },
149 * ],
150 * rows: [
151 * {
152 * cells: ['row 1 item 1', 'row 1 item 2', 'row 1 item 3'],
153 * dividerAfter: false,
154 * },
155 * {
156 * cells: ['row 2 item 1', 'row 2 item 2', 'row 2 item 3'],
157 * dividerAfter: true,
158 * },
159 * {
160 * cells: ['row 3 item 1', 'row 3 item 2', 'row 3 item 3'],
161 * },
162 * ],
163 * buttons: new Button({
164 * title: 'Button Title',
165 * url: 'https://github.com/actions-on-google'
166 * }),
167 * }))
168 * ```
169 *
170 * @public
171 */
172export interface Table extends Api.GoogleActionsV2UiElementsTableCard {
173}
174export declare class Table implements Api.GoogleActionsV2UiElementsTableCard {
175 /** @public */
176 constructor(options: TableOptions);
177}