@ltht-react/table 2.0.190 → 2.0.192

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,249 +1,249 @@
1
- import {
2
- CSS_RESET,
3
- TRANSLUCENT_MID_GREY,
4
- SCROLLBAR,
5
- TRANSLUCENT_BRIGHT_BLUE,
6
- BTN_COLOURS,
7
- TABLE_COLOURS,
8
- StickyTableData,
9
- StickyTableHead,
10
- getZIndex,
11
- } from '@ltht-react/styles'
12
- import styled from '@emotion/styled'
13
- import Icon, { IconButton } from '@ltht-react/icon'
14
- import { Axis } from '@ltht-react/types'
15
-
16
- const setScrollableDisplay = (tableHeaderAxis: Axis, isFlex: boolean) => {
17
- if (isFlex) {
18
- return 'flex'
19
- }
20
-
21
- if (tableHeaderAxis === 'y') {
22
- return 'inline-flex'
23
- }
24
-
25
- return 'inline-block'
26
- }
27
-
28
- const ScrollableContainer = styled.div<IScrollableContainer>`
29
- ${CSS_RESET};
30
- background-color: white;
31
- ${({ tableHeaderAxis, maxWidth, maxHeight, isFlex }) => `
32
- display: ${setScrollableDisplay(tableHeaderAxis, isFlex)};
33
- ${isFlex && 'flex-direction: column'};
34
- max-width: ${maxWidth ?? '100%'};
35
- max-height: ${maxHeight ?? '100%'};
36
- `}
37
- border-radius: 6px;
38
- overflow: auto;
39
- &::-webkit-scrollbar {
40
- width: 7px;
41
- height: 7px;
42
- border: 0;
43
- }
44
- &::-webkit-scrollbar-thumb {
45
- background: ${SCROLLBAR};
46
- border-radius: 10px;
47
- }
48
- `
49
-
50
- const StyledTable = styled.table`
51
- border-spacing: 0;
52
- border-radius: 6px;
53
- `
54
-
55
- const StyledTableHeader = styled.th<IStyledTableCell>`
56
- background-color: ${TABLE_COLOURS.HEADER};
57
- border: thin solid ${TABLE_COLOURS.BORDER};
58
- font-weight: bold;
59
- padding: 0.5rem;
60
-
61
- ${({ stickyWidth }) =>
62
- stickyWidth !== undefined &&
63
- `
64
- position: sticky !important;
65
- left: ${stickyWidth}px;
66
- top: 0;
67
- z-index: ${getZIndex(StickyTableData)};`}
68
- `
69
- const StyledTableData = styled.td<IStyledTableCell>`
70
- border: thin solid ${TABLE_COLOURS.BORDER};
71
- white-space: normal;
72
- text-align: center;
73
- padding: 0.15rem;
74
-
75
- &:first-of-type {
76
- background-color: ${TABLE_COLOURS.HEADER} !important;
77
- font-weight: bold;
78
- }
79
-
80
- ${({ stickyWidth }) =>
81
- stickyWidth !== undefined &&
82
- `
83
- background-color: ${TABLE_COLOURS.STRIPE_LIGHT};
84
- position: sticky !important;
85
- left: ${stickyWidth}px;
86
- top: 0;
87
- z-index: ${getZIndex(StickyTableData)};`}
88
-
89
- ${({ tableHeaderAxis }) =>
90
- tableHeaderAxis === 'y' &&
91
- `
92
- &:nth-of-type(even) {
93
- background-color: ${TABLE_COLOURS.STRIPE_DARK};
94
- }`}
95
- `
96
- const StyledTableRow = styled.tr<IStyledTableCell>`
97
- ${({ tableHeaderAxis }) =>
98
- tableHeaderAxis === 'x' &&
99
- `
100
- &:nth-of-type(odd) {
101
- background-color: ${TABLE_COLOURS.STRIPE_DARK};
102
- }`}
103
- `
104
- const PaginationContainer = styled.div`
105
- ${CSS_RESET};
106
- margin-top: 5px;
107
- display: block;
108
- `
109
- const StyledPaginationPageInput = styled.input`
110
- ${CSS_RESET};
111
- width: 50px;
112
- border: 1px solid gray;
113
- `
114
- const StyledPaginationPageSelect = styled.select`
115
- ${CSS_RESET};
116
- width: 45px;
117
- display: inline-block;
118
- font-size: 0.9rem;
119
- border: 1px solid gray;
120
- `
121
- const StyledHideOnMobile = styled.span`
122
- font-size: 1.1em;
123
- padding: 2px;
124
- @media (max-width: 320px) {
125
- display: none;
126
- }
127
- `
128
- const StyledPaginationButtonDiv = styled.div`
129
- float: right;
130
- display: flex;
131
- justify-content: space-between;
132
- align-items: stretch;
133
- `
134
- const StyledPageCountDiv = styled.div`
135
- margin-right: 5px;
136
- margin-left: 5px;
137
- display: flex;
138
- font-size: 1.1em;
139
- padding: 1px;
140
- `
141
- const StyledStandardButton = styled(IconButton)`
142
- color: ${BTN_COLOURS.STANDARD.TEXT};
143
- background-color: ${BTN_COLOURS.STANDARD.VALUE};
144
- padding: 2px 5px;
145
- border-radius: 5px;
146
- &:hover {
147
- background-color: ${BTN_COLOURS.STANDARD.HOVER};
148
- }
149
-
150
- &:disabled {
151
- background-color: ${BTN_COLOURS.STANDARD.DISABLED};
152
- }
153
- `
154
- const StyledPaginationButton = styled(IconButton)`
155
- padding: 2px 5px;
156
- background-color: ${TRANSLUCENT_BRIGHT_BLUE};
157
- color: black;
158
- border: 1px solid ${TRANSLUCENT_MID_GREY};
159
- margin: 0 2.5px;
160
- border-radius: 3px;
161
-
162
- &:disabled {
163
- background-color: inherit;
164
- color: gray;
165
- border-color: ${TRANSLUCENT_MID_GREY};
166
- pointer-events: none;
167
- }
168
- `
169
- const StyledSpinnerIcon = styled(Icon)`
170
- margin: 3px 0;
171
- font-size: 1.1em;
172
- padding: 1.5px;
173
- `
174
- const StyledNextPageButtonContainer = styled.div<IStyledNextPageButtonContainer>`
175
- display: ${({ hidden, elementPosition }) => {
176
- if (!hidden) {
177
- return elementPosition === 'bottom' ? 'flex' : 'inline-flex'
178
- }
179
-
180
- return 'none'
181
- }};
182
- justify-content: center;
183
- cursor: pointer;
184
- align-items: center;
185
- padding: 10px;
186
- font-size: 1.3em;
187
- border: solid 2px #eeeeee;
188
- border-left: solid 1px #eeeeee;
189
-
190
- :hover {
191
- background-color: #f3f6f6;
192
- }
193
- `
194
-
195
- const StyledSpinnerContainer = styled.div<IStyledNextPageButtonContainer>`
196
- display: ${({ hidden, elementPosition }) => {
197
- if (!hidden) {
198
- return elementPosition === 'bottom' ? 'flex' : 'inline-flex'
199
- }
200
-
201
- return 'none'
202
- }};
203
- justify-content: center;
204
- cursor: pointer;
205
- align-items: center;
206
- padding: 5px;
207
- `
208
- const StyledTHead = styled.thead`
209
- position: sticky;
210
- left: 0;
211
- top: 0;
212
- z-index: ${getZIndex(StickyTableHead)};
213
- `
214
-
215
- interface IStyledTableCell {
216
- stickyWidth?: number
217
- tableHeaderAxis?: string
218
- }
219
-
220
- interface IStyledNextPageButtonContainer {
221
- elementPosition: 'right' | 'bottom'
222
- }
223
-
224
- interface IScrollableContainer {
225
- tableHeaderAxis: Axis
226
- maxHeight?: string
227
- maxWidth?: string
228
- isFlex: boolean
229
- }
230
-
231
- export {
232
- StyledTable,
233
- StyledTableHeader,
234
- StyledTableRow,
235
- StyledTableData,
236
- PaginationContainer,
237
- StyledPaginationPageInput,
238
- StyledPaginationPageSelect,
239
- StyledHideOnMobile,
240
- StyledPaginationButton,
241
- ScrollableContainer,
242
- StyledPaginationButtonDiv,
243
- StyledPageCountDiv,
244
- StyledStandardButton,
245
- StyledSpinnerIcon,
246
- StyledNextPageButtonContainer,
247
- StyledTHead,
248
- StyledSpinnerContainer,
249
- }
1
+ import {
2
+ CSS_RESET,
3
+ TRANSLUCENT_MID_GREY,
4
+ SCROLLBAR,
5
+ TRANSLUCENT_BRIGHT_BLUE,
6
+ BTN_COLOURS,
7
+ TABLE_COLOURS,
8
+ StickyTableData,
9
+ StickyTableHead,
10
+ getZIndex,
11
+ } from '@ltht-react/styles'
12
+ import styled from '@emotion/styled'
13
+ import Icon, { IconButton } from '@ltht-react/icon'
14
+ import { Axis } from '@ltht-react/types'
15
+
16
+ const setScrollableDisplay = (tableHeaderAxis: Axis, isFlex: boolean) => {
17
+ if (isFlex) {
18
+ return 'flex'
19
+ }
20
+
21
+ if (tableHeaderAxis === 'y') {
22
+ return 'inline-flex'
23
+ }
24
+
25
+ return 'inline-block'
26
+ }
27
+
28
+ const ScrollableContainer = styled.div<IScrollableContainer>`
29
+ ${CSS_RESET};
30
+ background-color: white;
31
+ ${({ tableHeaderAxis, maxWidth, maxHeight, isFlex }) => `
32
+ display: ${setScrollableDisplay(tableHeaderAxis, isFlex)};
33
+ ${isFlex && 'flex-direction: column'};
34
+ max-width: ${maxWidth ?? '100%'};
35
+ max-height: ${maxHeight ?? '100%'};
36
+ `}
37
+ border-radius: 6px;
38
+ overflow: auto;
39
+ &::-webkit-scrollbar {
40
+ width: 7px;
41
+ height: 7px;
42
+ border: 0;
43
+ }
44
+ &::-webkit-scrollbar-thumb {
45
+ background: ${SCROLLBAR};
46
+ border-radius: 10px;
47
+ }
48
+ `
49
+
50
+ const StyledTable = styled.table`
51
+ border-spacing: 0;
52
+ border-radius: 6px;
53
+ `
54
+
55
+ const StyledTableHeader = styled.th<IStyledTableCell>`
56
+ background-color: ${TABLE_COLOURS.HEADER};
57
+ border: thin solid ${TABLE_COLOURS.BORDER};
58
+ font-weight: bold;
59
+ padding: 0.5rem;
60
+
61
+ ${({ stickyWidth }) =>
62
+ stickyWidth !== undefined &&
63
+ `
64
+ position: sticky !important;
65
+ left: ${stickyWidth}px;
66
+ top: 0;
67
+ z-index: ${getZIndex(StickyTableData)};`}
68
+ `
69
+ const StyledTableData = styled.td<IStyledTableCell>`
70
+ border: thin solid ${TABLE_COLOURS.BORDER};
71
+ white-space: normal;
72
+ text-align: center;
73
+ padding: 0.15rem;
74
+
75
+ &:first-of-type {
76
+ background-color: ${TABLE_COLOURS.HEADER} !important;
77
+ font-weight: bold;
78
+ }
79
+
80
+ ${({ stickyWidth }) =>
81
+ stickyWidth !== undefined &&
82
+ `
83
+ background-color: ${TABLE_COLOURS.STRIPE_LIGHT};
84
+ position: sticky !important;
85
+ left: ${stickyWidth}px;
86
+ top: 0;
87
+ z-index: ${getZIndex(StickyTableData)};`}
88
+
89
+ ${({ tableHeaderAxis }) =>
90
+ tableHeaderAxis === 'y' &&
91
+ `
92
+ &:nth-of-type(even) {
93
+ background-color: ${TABLE_COLOURS.STRIPE_DARK};
94
+ }`}
95
+ `
96
+ const StyledTableRow = styled.tr<IStyledTableCell>`
97
+ ${({ tableHeaderAxis }) =>
98
+ tableHeaderAxis === 'x' &&
99
+ `
100
+ &:nth-of-type(odd) {
101
+ background-color: ${TABLE_COLOURS.STRIPE_DARK};
102
+ }`}
103
+ `
104
+ const PaginationContainer = styled.div`
105
+ ${CSS_RESET};
106
+ margin-top: 5px;
107
+ display: block;
108
+ `
109
+ const StyledPaginationPageInput = styled.input`
110
+ ${CSS_RESET};
111
+ width: 50px;
112
+ border: 1px solid gray;
113
+ `
114
+ const StyledPaginationPageSelect = styled.select`
115
+ ${CSS_RESET};
116
+ width: 45px;
117
+ display: inline-block;
118
+ font-size: 0.9rem;
119
+ border: 1px solid gray;
120
+ `
121
+ const StyledHideOnMobile = styled.span`
122
+ font-size: 1.1em;
123
+ padding: 2px;
124
+ @media (max-width: 320px) {
125
+ display: none;
126
+ }
127
+ `
128
+ const StyledPaginationButtonDiv = styled.div`
129
+ float: right;
130
+ display: flex;
131
+ justify-content: space-between;
132
+ align-items: stretch;
133
+ `
134
+ const StyledPageCountDiv = styled.div`
135
+ margin-right: 5px;
136
+ margin-left: 5px;
137
+ display: flex;
138
+ font-size: 1.1em;
139
+ padding: 1px;
140
+ `
141
+ const StyledStandardButton = styled(IconButton)`
142
+ color: ${BTN_COLOURS.STANDARD.TEXT};
143
+ background-color: ${BTN_COLOURS.STANDARD.VALUE};
144
+ padding: 2px 5px;
145
+ border-radius: 5px;
146
+ &:hover {
147
+ background-color: ${BTN_COLOURS.STANDARD.HOVER};
148
+ }
149
+
150
+ &:disabled {
151
+ background-color: ${BTN_COLOURS.STANDARD.DISABLED};
152
+ }
153
+ `
154
+ const StyledPaginationButton = styled(IconButton)`
155
+ padding: 2px 5px;
156
+ background-color: ${TRANSLUCENT_BRIGHT_BLUE};
157
+ color: black;
158
+ border: 1px solid ${TRANSLUCENT_MID_GREY};
159
+ margin: 0 2.5px;
160
+ border-radius: 3px;
161
+
162
+ &:disabled {
163
+ background-color: inherit;
164
+ color: gray;
165
+ border-color: ${TRANSLUCENT_MID_GREY};
166
+ pointer-events: none;
167
+ }
168
+ `
169
+ const StyledSpinnerIcon = styled(Icon)`
170
+ margin: 3px 0;
171
+ font-size: 1.1em;
172
+ padding: 1.5px;
173
+ `
174
+ const StyledNextPageButtonContainer = styled.div<IStyledNextPageButtonContainer>`
175
+ display: ${({ hidden, elementPosition }) => {
176
+ if (!hidden) {
177
+ return elementPosition === 'bottom' ? 'flex' : 'inline-flex'
178
+ }
179
+
180
+ return 'none'
181
+ }};
182
+ justify-content: center;
183
+ cursor: pointer;
184
+ align-items: center;
185
+ padding: 10px;
186
+ font-size: 1.3em;
187
+ border: solid 2px #eeeeee;
188
+ border-left: solid 1px #eeeeee;
189
+
190
+ :hover {
191
+ background-color: #f3f6f6;
192
+ }
193
+ `
194
+
195
+ const StyledSpinnerContainer = styled.div<IStyledNextPageButtonContainer>`
196
+ display: ${({ hidden, elementPosition }) => {
197
+ if (!hidden) {
198
+ return elementPosition === 'bottom' ? 'flex' : 'inline-flex'
199
+ }
200
+
201
+ return 'none'
202
+ }};
203
+ justify-content: center;
204
+ cursor: pointer;
205
+ align-items: center;
206
+ padding: 5px;
207
+ `
208
+ const StyledTHead = styled.thead`
209
+ position: sticky;
210
+ left: 0;
211
+ top: 0;
212
+ z-index: ${getZIndex(StickyTableHead)};
213
+ `
214
+
215
+ interface IStyledTableCell {
216
+ stickyWidth?: number
217
+ tableHeaderAxis?: string
218
+ }
219
+
220
+ interface IStyledNextPageButtonContainer {
221
+ elementPosition: 'right' | 'bottom'
222
+ }
223
+
224
+ interface IScrollableContainer {
225
+ tableHeaderAxis: Axis
226
+ maxHeight?: string
227
+ maxWidth?: string
228
+ isFlex: boolean
229
+ }
230
+
231
+ export {
232
+ StyledTable,
233
+ StyledTableHeader,
234
+ StyledTableRow,
235
+ StyledTableData,
236
+ PaginationContainer,
237
+ StyledPaginationPageInput,
238
+ StyledPaginationPageSelect,
239
+ StyledHideOnMobile,
240
+ StyledPaginationButton,
241
+ ScrollableContainer,
242
+ StyledPaginationButtonDiv,
243
+ StyledPageCountDiv,
244
+ StyledStandardButton,
245
+ StyledSpinnerIcon,
246
+ StyledNextPageButtonContainer,
247
+ StyledTHead,
248
+ StyledSpinnerContainer,
249
+ }