-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy pathsample.tsx
More file actions
193 lines (185 loc) · 6.07 KB
/
sample.tsx
File metadata and controls
193 lines (185 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import { useRef } from "react";
import createReactComponent from "@ui5/webcomponents-base/dist/createReactComponent.js";
import { type UI5CustomEvent } from "@ui5/webcomponents-base";
import BarClass from "@ui5/webcomponents/dist/Bar.js";
import LabelClass from "@ui5/webcomponents/dist/Label.js";
import SegmentedButtonClass from "@ui5/webcomponents/dist/SegmentedButton.js";
import SegmentedButtonItemClass from "@ui5/webcomponents/dist/SegmentedButtonItem.js";
import TableClass from "@ui5/webcomponents/dist/Table.js";
import TableCellClass from "@ui5/webcomponents/dist/TableCell.js";
import TableHeaderCellClass from "@ui5/webcomponents/dist/TableHeaderCell.js";
import TableHeaderRowClass from "@ui5/webcomponents/dist/TableHeaderRow.js";
import TableRowClass from "@ui5/webcomponents/dist/TableRow.js";
import "@ui5/webcomponents-icons/dist/detail-more.js";
import "@ui5/webcomponents-icons/dist/detail-less.js";
const Bar = createReactComponent(BarClass);
const Label = createReactComponent(LabelClass);
const SegmentedButton = createReactComponent(SegmentedButtonClass);
const SegmentedButtonItem = createReactComponent(SegmentedButtonItemClass);
const Table = createReactComponent(TableClass);
const TableCell = createReactComponent(TableCellClass);
const TableHeaderCell = createReactComponent(TableHeaderCellClass);
const TableHeaderRow = createReactComponent(TableHeaderRowClass);
const TableRow = createReactComponent(TableRowClass);
const HIDDEN_COLUMNS = ["dimensionsCol", "weightCol"];
function App() {
const tableRef = useRef(null);
const setPopinState = (hideDetails: boolean) => {
HIDDEN_COLUMNS.forEach((columnId) => {
const headerCell = document.getElementById(columnId) as any;
if (headerCell) {
headerCell.popinHidden = hideDetails;
}
});
};
const handleSizeBtnSelectionChange = (
e: UI5CustomEvent<SegmentedButtonClass, "selection-change">,
) => {
const selectedItem = e.detail.selectedItems[0];
if (tableRef.current) {
tableRef.current!.style.width = selectedItem.textContent;
}
};
const handleShowHideDetailsBtnSelectionChange = (
e: UI5CustomEvent<SegmentedButtonClass, "selection-change">,
) => {
const selectedItem = e.detail.selectedItems[0];
setPopinState((selectedItem as unknown as SegmentedButtonItemClass).tooltip === "Hide Details");
};
return (
<>
<Bar>
<SegmentedButton
id="sizeBtn"
accessibleName="Switch Table Size"
onSelectionChange={handleSizeBtnSelectionChange}
>
<SegmentedButtonItem>25%</SegmentedButtonItem>
<SegmentedButtonItem>50%</SegmentedButtonItem>
<SegmentedButtonItem>75%</SegmentedButtonItem>
<SegmentedButtonItem selected={true}>100%</SegmentedButtonItem>
</SegmentedButton>
<SegmentedButton
id="showHideDetailsBtn"
slot="endContent"
accessibleName="Show/Hide Details"
onSelectionChange={handleShowHideDetailsBtnSelectionChange}
>
<SegmentedButtonItem tooltip="Show Details" icon="detail-more" />
<SegmentedButtonItem
tooltip="Hide Details"
icon="detail-less"
selected={true}
/>
</SegmentedButton>
</Bar>
<Table ref={tableRef} id="table" overflowMode="Popin">
<TableHeaderRow slot="headerRow">
<TableHeaderCell id="produtCol" minWidth="300px">
<span>Product</span>
</TableHeaderCell>
<TableHeaderCell id="supplierCol" minWidth="200px">
Supplier
</TableHeaderCell>
<TableHeaderCell
id="dimensionsCol"
importance={-1}
minWidth="200px"
popinHidden={true}
>
Dimensions
</TableHeaderCell>
<TableHeaderCell
id="weightCol"
importance={-1}
minWidth="100px"
popinHidden={true}
>
Weight
</TableHeaderCell>
<TableHeaderCell id="priceCol" minWidth="150px">
Price
</TableHeaderCell>
</TableHeaderRow>
{/* playground-fold */}
<TableRow>
<TableCell>
<Label>
<b>Notebook Basic 15</b>
<br />
HT-1000
</Label>
</TableCell>
<TableCell>
<Label>Very Best Screens</Label>
</TableCell>
<TableCell>
<Label>30 x 18 x 3 cm</Label>
</TableCell>
<TableCell>
<Label style={{ color: "#2b7c2b" }}>
<b>4.2</b> KG
</Label>
</TableCell>
<TableCell>
<Label>
<b>956</b> EUR
</Label>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label>
<b>Notebook Basic 17</b>
<br />
HT-1001
</Label>
</TableCell>
<TableCell>
<Label>Smartcards</Label>
</TableCell>
<TableCell>
<Label>29 x 17 x 3.1 cm</Label>
</TableCell>
<TableCell>
<Label style={{ color: "#2b7c2b" }}>
<b>4.5</b> KG
</Label>
</TableCell>
<TableCell>
<Label>
<b>1249</b> EUR
</Label>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Label>
<b>Notebook Basic 18</b>
<br />
HT-1002
</Label>
</TableCell>
<TableCell>
<Label>Technocom</Label>
</TableCell>
<TableCell>
<Label>32 x 21 x 4 cm</Label>
</TableCell>
<TableCell>
<Label style={{ color: "#2b7c2b" }}>
<b>3.7</b> KG
</Label>
</TableCell>
<TableCell>
<Label>
<b>29</b> EUR
</Label>
</TableCell>
</TableRow>
{/* playground-fold-end */}
</Table>
</>
);
}
export default App;