webcoreui 0.4.1 → 0.6.0
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.
- package/README.md +237 -227
- package/astro.d.ts +115 -62
- package/astro.js +14 -0
- package/components/Avatar/Avatar.astro +9 -2
- package/components/Avatar/Avatar.svelte +3 -1
- package/components/Avatar/Avatar.tsx +4 -2
- package/components/Avatar/avatar.ts +1 -0
- package/components/Badge/Badge.astro +4 -0
- package/components/Badge/Badge.svelte +5 -1
- package/components/Badge/Badge.tsx +4 -0
- package/components/Badge/badge.module.scss +8 -0
- package/components/Badge/badge.ts +7 -3
- package/components/Breadcrumb/Breadcrumb.astro +51 -0
- package/components/Breadcrumb/Breadcrumb.svelte +45 -0
- package/components/Breadcrumb/Breadcrumb.tsx +51 -0
- package/components/Breadcrumb/breadcrumb.module.scss +26 -0
- package/components/Breadcrumb/breadcrumb.ts +12 -0
- package/components/Button/button.module.scss +6 -1
- package/components/Button/button.ts +13 -3
- package/components/Carousel/Carousel.astro +198 -0
- package/components/Carousel/Carousel.svelte +161 -0
- package/components/Carousel/Carousel.tsx +172 -0
- package/components/Carousel/carousel.module.scss +58 -0
- package/components/Carousel/carousel.ts +26 -0
- package/components/Checkbox/checkbox.ts +4 -2
- package/components/DataTable/DataTable.astro +332 -0
- package/components/DataTable/DataTable.svelte +272 -0
- package/components/DataTable/DataTable.tsx +287 -0
- package/components/DataTable/datatable.module.scss +102 -0
- package/components/DataTable/datatable.ts +41 -0
- package/components/Footer/Footer.astro +91 -0
- package/components/Footer/Footer.svelte +94 -0
- package/components/Footer/Footer.tsx +107 -0
- package/components/Footer/footer.module.scss +61 -0
- package/components/Footer/footer.ts +29 -0
- package/components/Icon/Icon.svelte +1 -1
- package/components/Icon/icon.ts +18 -1
- package/components/Icon/map.ts +14 -0
- package/components/Input/input.module.scss +6 -0
- package/components/List/List.astro +1 -1
- package/components/List/List.svelte +1 -1
- package/components/List/List.tsx +1 -2
- package/components/List/list.ts +3 -1
- package/components/Masonry/Masonry.astro +54 -0
- package/components/Masonry/Masonry.svelte +54 -0
- package/components/Masonry/Masonry.tsx +62 -0
- package/components/Masonry/masonry.module.scss +18 -0
- package/components/Masonry/masonry.ts +36 -0
- package/components/Menu/Menu.astro +1 -1
- package/components/Menu/Menu.svelte +1 -1
- package/components/Menu/Menu.tsx +1 -1
- package/components/Menu/menu.ts +4 -2
- package/components/Modal/Modal.astro +2 -0
- package/components/Modal/Modal.svelte +2 -0
- package/components/Modal/Modal.tsx +2 -0
- package/components/Modal/modal.module.scss +29 -22
- package/components/Modal/modal.ts +1 -0
- package/components/Pagination/Pagination.astro +189 -0
- package/components/Pagination/Pagination.svelte +144 -0
- package/components/Pagination/Pagination.tsx +162 -0
- package/components/Pagination/pagination.module.scss +49 -0
- package/components/Pagination/pagination.ts +35 -0
- package/components/Rating/rating.ts +3 -1
- package/components/Select/Select.astro +8 -4
- package/components/Select/Select.svelte +15 -6
- package/components/Select/Select.tsx +15 -8
- package/components/Select/select.ts +7 -2
- package/components/Sidebar/Sidebar.astro +61 -0
- package/components/Sidebar/Sidebar.svelte +50 -0
- package/components/Sidebar/Sidebar.tsx +58 -0
- package/components/Sidebar/sidebar.module.scss +43 -0
- package/components/Sidebar/sidebar.ts +21 -0
- package/components/Switch/switch.ts +4 -2
- package/components/Table/Table.svelte +1 -1
- package/components/Table/table.ts +1 -1
- package/icons/arrow-left.svg +3 -0
- package/icons/arrow-right.svg +3 -0
- package/icons/circle-close.svg +3 -0
- package/icons/components.svg +3 -0
- package/icons/file.svg +3 -0
- package/icons/home.svg +4 -0
- package/icons/order.svg +3 -0
- package/icons/sun.svg +1 -1
- package/icons.d.ts +7 -0
- package/icons.js +7 -0
- package/index.d.ts +6 -6
- package/package.json +8 -10
- package/react.d.ts +115 -62
- package/react.js +14 -0
- package/scss/resets.scss +27 -1
- package/svelte.d.ts +116 -62
- package/svelte.js +14 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import type { HeadingObject, ReactDataTableProps } from './datatable'
|
|
3
|
+
|
|
4
|
+
import Button from '../Button/Button.tsx'
|
|
5
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
6
|
+
import Input from '../Input/Input.tsx'
|
|
7
|
+
import Pagination from '../Pagination/Pagination.tsx'
|
|
8
|
+
import Select from '../Select/Select.tsx'
|
|
9
|
+
|
|
10
|
+
import { classNames } from '../../utils/classNames'
|
|
11
|
+
import { debounce } from '../../utils/debounce'
|
|
12
|
+
|
|
13
|
+
import checkIcon from '../../icons/check.svg?raw'
|
|
14
|
+
import orderIcon from '../../icons/order.svg?raw'
|
|
15
|
+
import searchIcon from '../../icons/search.svg?raw'
|
|
16
|
+
|
|
17
|
+
import styles from './datatable.module.scss'
|
|
18
|
+
|
|
19
|
+
import type { ListEventType } from '../List/list'
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line complexity
|
|
22
|
+
const DataTable = ({
|
|
23
|
+
headings,
|
|
24
|
+
filterPlaceholder = 'Filter entries',
|
|
25
|
+
showFilterIcon,
|
|
26
|
+
noResultsLabel = 'No results.',
|
|
27
|
+
itemsPerPage,
|
|
28
|
+
subText,
|
|
29
|
+
columnToggleLabel = 'Columns',
|
|
30
|
+
pagination,
|
|
31
|
+
data,
|
|
32
|
+
hover,
|
|
33
|
+
striped,
|
|
34
|
+
offsetStripe,
|
|
35
|
+
compact,
|
|
36
|
+
maxHeight,
|
|
37
|
+
className,
|
|
38
|
+
id,
|
|
39
|
+
onFilter,
|
|
40
|
+
children
|
|
41
|
+
}: ReactDataTableProps) => {
|
|
42
|
+
const [filteredData, setFilteredData] = useState<any>(data)
|
|
43
|
+
const [toggledData, setToggledData] = useState(filteredData)
|
|
44
|
+
const [filteredHeadings, setFilteredHeadings] = useState<any>(headings)
|
|
45
|
+
const [page, setPage] = useState(1)
|
|
46
|
+
const [hasActiveFilter, setHasActiveFilter] = useState(false)
|
|
47
|
+
const [sortOrder, setSortOrder] = useState(1)
|
|
48
|
+
|
|
49
|
+
const classes = classNames([
|
|
50
|
+
styles.table,
|
|
51
|
+
hover && styles.hover,
|
|
52
|
+
striped && styles[`striped-${striped}s`],
|
|
53
|
+
offsetStripe && styles.offset,
|
|
54
|
+
compact && styles.compact,
|
|
55
|
+
maxHeight && styles.scroll
|
|
56
|
+
])
|
|
57
|
+
|
|
58
|
+
const footerClasses = classNames([
|
|
59
|
+
styles.footer,
|
|
60
|
+
subText && styles.between
|
|
61
|
+
])
|
|
62
|
+
|
|
63
|
+
const styleVariables = {
|
|
64
|
+
...(maxHeight && { 'max-height': maxHeight })
|
|
65
|
+
} as React.CSSProperties
|
|
66
|
+
|
|
67
|
+
const showColumnToggle = headings?.some(heading => {
|
|
68
|
+
return typeof heading === 'string' ? false : heading.toggleable
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const columnToggleItems = [{
|
|
72
|
+
items: headings?.length ? headings
|
|
73
|
+
.filter(heading => typeof heading !== 'string' && heading.toggleable)
|
|
74
|
+
.map(heading => ({
|
|
75
|
+
icon: checkIcon,
|
|
76
|
+
name: (heading as HeadingObject).name,
|
|
77
|
+
value: String(headings.findIndex(h => {
|
|
78
|
+
return (h as HeadingObject).name === (heading as HeadingObject).name
|
|
79
|
+
}))
|
|
80
|
+
})) : []
|
|
81
|
+
}]
|
|
82
|
+
|
|
83
|
+
const columnFilterIndexes = headings?.map(heading => (heading as HeadingObject).filterable)
|
|
84
|
+
.map((heading, index) => heading ? index : null)
|
|
85
|
+
.filter(heading => heading !== null) || []
|
|
86
|
+
|
|
87
|
+
const hasPagination = data?.length && itemsPerPage
|
|
88
|
+
? data.length > itemsPerPage
|
|
89
|
+
: false
|
|
90
|
+
|
|
91
|
+
const filter = debounce((event: Event) => {
|
|
92
|
+
const target = event.target as HTMLInputElement
|
|
93
|
+
|
|
94
|
+
setHasActiveFilter(!!target.value)
|
|
95
|
+
|
|
96
|
+
setFilteredData(toggledData?.filter((row: string[]) => {
|
|
97
|
+
const rowValue = row.filter((_, index) => columnFilterIndexes.includes(index))
|
|
98
|
+
.join('')
|
|
99
|
+
.toLowerCase()
|
|
100
|
+
|
|
101
|
+
return rowValue.includes(target.value.toLowerCase())
|
|
102
|
+
}))
|
|
103
|
+
|
|
104
|
+
onFilter?.({
|
|
105
|
+
results: filteredData,
|
|
106
|
+
numberOfResults: filteredData.length
|
|
107
|
+
})
|
|
108
|
+
}, 400)
|
|
109
|
+
|
|
110
|
+
const toggleColumns = (event: ListEventType) => {
|
|
111
|
+
const columnToggleListElement = Array.from(event.list.children)
|
|
112
|
+
.find(child => (child as HTMLLIElement).dataset.name === event.name) as HTMLLIElement
|
|
113
|
+
const svgIcon = columnToggleListElement.children[0] as HTMLElement
|
|
114
|
+
let mappedData
|
|
115
|
+
|
|
116
|
+
svgIcon.style.opacity = svgIcon.style.opacity === '0'
|
|
117
|
+
? '1'
|
|
118
|
+
: '0'
|
|
119
|
+
|
|
120
|
+
if (svgIcon.style.opacity === '0') {
|
|
121
|
+
mappedData = (hasActiveFilter ? data : filteredData)?.map((row: string[]) => {
|
|
122
|
+
return row.map((column, index) => index === Number(event.value) ? null : column)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
setFilteredData(mappedData)
|
|
126
|
+
|
|
127
|
+
setFilteredHeadings(filteredHeadings.map((heading: HeadingObject | string) => {
|
|
128
|
+
return ((heading as HeadingObject)?.name || heading) === event.name ? null : heading
|
|
129
|
+
}))
|
|
130
|
+
} else {
|
|
131
|
+
mappedData = (hasActiveFilter ? data : filteredData)?.map((row: string[], x: number) => {
|
|
132
|
+
return row.map((column, y) => y === Number(event.value) ? data?.[x][y] : column)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
setFilteredData(mappedData)
|
|
136
|
+
|
|
137
|
+
setFilteredHeadings(filteredHeadings.map((heading: HeadingObject | string, index: number) => {
|
|
138
|
+
return ((headings?.[index] as HeadingObject)?.name || headings?.[index]) === event.name
|
|
139
|
+
? headings?.[index]
|
|
140
|
+
: heading
|
|
141
|
+
}))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
setToggledData(mappedData)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const sort = (index: number) => {
|
|
148
|
+
const sortedData = filteredData.sort((a: string[], b: string[]) => {
|
|
149
|
+
let aValue: string | number = a[index]
|
|
150
|
+
let bValue: string | number = b[index]
|
|
151
|
+
|
|
152
|
+
if (!isNaN(aValue as any)) {
|
|
153
|
+
aValue = Number(aValue)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!isNaN(bValue as any)) {
|
|
157
|
+
bValue = Number(bValue)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return aValue > bValue
|
|
161
|
+
? sortOrder * -1
|
|
162
|
+
: sortOrder
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
setFilteredData(sortedData)
|
|
166
|
+
setSortOrder(sortOrder === 1 ? -1 : 1)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const isNextPage = (index: number) => {
|
|
170
|
+
if (hasPagination && itemsPerPage && !hasActiveFilter) {
|
|
171
|
+
const currentPage = Math.ceil((index + 1) / itemsPerPage)
|
|
172
|
+
|
|
173
|
+
return currentPage !== page ? 'true' : undefined
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (hasActiveFilter && itemsPerPage) {
|
|
177
|
+
return index >= itemsPerPage ? 'true' : undefined
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return undefined
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<section className={className} id={id}>
|
|
185
|
+
{(!!columnFilterIndexes?.length || showColumnToggle) && (
|
|
186
|
+
<div className={styles.filters}>
|
|
187
|
+
{!!columnFilterIndexes?.length && (
|
|
188
|
+
<Input
|
|
189
|
+
type="search"
|
|
190
|
+
placeholder={filterPlaceholder}
|
|
191
|
+
onInput={filter}
|
|
192
|
+
>
|
|
193
|
+
{showFilterIcon && (
|
|
194
|
+
<span dangerouslySetInnerHTML={{ __html: searchIcon }} />
|
|
195
|
+
)}
|
|
196
|
+
</Input>
|
|
197
|
+
)}
|
|
198
|
+
{showColumnToggle && (
|
|
199
|
+
<Select
|
|
200
|
+
name={`data-table-${id || crypto.randomUUID()}`}
|
|
201
|
+
itemGroups={columnToggleItems}
|
|
202
|
+
position="bottom-end"
|
|
203
|
+
value={columnToggleLabel}
|
|
204
|
+
onChange={toggleColumns}
|
|
205
|
+
updateValue={false}
|
|
206
|
+
/>
|
|
207
|
+
)}
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
|
|
211
|
+
<div className={classes} style={styleVariables}>
|
|
212
|
+
<table>
|
|
213
|
+
{!!filteredHeadings?.length && (
|
|
214
|
+
<thead>
|
|
215
|
+
<tr>
|
|
216
|
+
{filteredHeadings?.map((heading: HeadingObject | string, index: number) => {
|
|
217
|
+
if (!heading) {
|
|
218
|
+
return null
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<th key={index}>
|
|
223
|
+
<ConditionalWrapper
|
|
224
|
+
condition={!!(heading as HeadingObject).sortable}
|
|
225
|
+
wrapper={children => (
|
|
226
|
+
<Button theme="flat" slot="wrapper" onClick={() => sort(index)}>
|
|
227
|
+
{children}
|
|
228
|
+
<span dangerouslySetInnerHTML={{ __html: orderIcon }} />
|
|
229
|
+
</Button>
|
|
230
|
+
)}
|
|
231
|
+
>
|
|
232
|
+
{(heading as HeadingObject).name || heading as string}
|
|
233
|
+
</ConditionalWrapper>
|
|
234
|
+
</th>
|
|
235
|
+
)
|
|
236
|
+
})}
|
|
237
|
+
</tr>
|
|
238
|
+
</thead>
|
|
239
|
+
)}
|
|
240
|
+
|
|
241
|
+
<tbody>
|
|
242
|
+
{filteredData?.map((row: string[], rowIndex: number) => (
|
|
243
|
+
<tr key={rowIndex} data-hidden={isNextPage(rowIndex)}>
|
|
244
|
+
{row.filter(Boolean).map((column, columnIndex) => (
|
|
245
|
+
<td
|
|
246
|
+
key={columnIndex}
|
|
247
|
+
dangerouslySetInnerHTML={{ __html: column }}
|
|
248
|
+
/>
|
|
249
|
+
))}
|
|
250
|
+
</tr>
|
|
251
|
+
))}
|
|
252
|
+
{children}
|
|
253
|
+
</tbody>
|
|
254
|
+
{!filteredData?.length && (
|
|
255
|
+
<tfoot>
|
|
256
|
+
<tr>
|
|
257
|
+
<td
|
|
258
|
+
colSpan={data?.[0].length}
|
|
259
|
+
className={styles['no-results']}
|
|
260
|
+
>
|
|
261
|
+
{noResultsLabel}
|
|
262
|
+
</td>
|
|
263
|
+
</tr>
|
|
264
|
+
</tfoot>
|
|
265
|
+
)}
|
|
266
|
+
</table>
|
|
267
|
+
</div>
|
|
268
|
+
{(subText || hasPagination) && (
|
|
269
|
+
<div className={footerClasses}>
|
|
270
|
+
{subText && (
|
|
271
|
+
<span className={styles.subtext}>{subText}</span>
|
|
272
|
+
)}
|
|
273
|
+
{(hasPagination && itemsPerPage && !hasActiveFilter) && (
|
|
274
|
+
<Pagination
|
|
275
|
+
{...pagination}
|
|
276
|
+
totalPages={Math.ceil((data?.length || 0) / itemsPerPage)}
|
|
277
|
+
currentPage={page}
|
|
278
|
+
onChange={event => setPage(event.page)}
|
|
279
|
+
/>
|
|
280
|
+
)}
|
|
281
|
+
</div>
|
|
282
|
+
)}
|
|
283
|
+
</section>
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export default DataTable
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.filters {
|
|
4
|
+
@include layout(flex, xs);
|
|
5
|
+
@include spacing(mb-sm);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.table {
|
|
9
|
+
@include visibility(auto);
|
|
10
|
+
|
|
11
|
+
table {
|
|
12
|
+
@include size('w100%');
|
|
13
|
+
@include typography(left);
|
|
14
|
+
|
|
15
|
+
border-collapse: collapse;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
thead,
|
|
19
|
+
thead button {
|
|
20
|
+
@include typography(bold);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
thead button {
|
|
24
|
+
@include spacing(p-xxs);
|
|
25
|
+
|
|
26
|
+
svg {
|
|
27
|
+
@include size(15px);
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
th,
|
|
33
|
+
td {
|
|
34
|
+
@include spacing(py-xs, px-sm);
|
|
35
|
+
|
|
36
|
+
&.no-results {
|
|
37
|
+
@include typography(center);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
thead,
|
|
42
|
+
tr {
|
|
43
|
+
@include border(bottom, primary-50);
|
|
44
|
+
|
|
45
|
+
&:last-child {
|
|
46
|
+
@include border(bottom, 0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-hidden] {
|
|
51
|
+
@include visibility(none);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.hover tr:hover,
|
|
55
|
+
&.striped-rows tbody tr:nth-child(odd),
|
|
56
|
+
&.striped-rows.offset tbody tr:nth-child(even),
|
|
57
|
+
&.striped-columns td:nth-child(odd),
|
|
58
|
+
&.striped-columns.offset td:nth-child(even),
|
|
59
|
+
&.hover.striped-rows.offset tbody tr:nth-child(odd):hover {
|
|
60
|
+
@include background(primary-60);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&.striped-rows tr,
|
|
64
|
+
&.striped-columns tr,
|
|
65
|
+
&.striped-columns thead {
|
|
66
|
+
@include border(bottom, 0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&.striped-rows.offset tbody tr:nth-child(odd),
|
|
70
|
+
&.striped-columns.offset td:nth-child(odd) {
|
|
71
|
+
@include background(transparent);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&.compact {
|
|
75
|
+
th, td {
|
|
76
|
+
@include spacing(py-xxs, px-sm);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&.scroll {
|
|
81
|
+
@include spacing(pr-sm);
|
|
82
|
+
|
|
83
|
+
thead {
|
|
84
|
+
@include position(sticky, t0);
|
|
85
|
+
@include background(primary-70);
|
|
86
|
+
box-shadow: 0 .5px 0 var(--w-color-primary-50);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.footer {
|
|
92
|
+
@include layout(flex, h-end, v-center, xs);
|
|
93
|
+
@include spacing(mt-sm);
|
|
94
|
+
|
|
95
|
+
&.between {
|
|
96
|
+
@include layout(h-between);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.subtext {
|
|
100
|
+
@include typography(md, primary-20);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PaginationProps } from '../Pagination/pagination'
|
|
2
|
+
|
|
3
|
+
export type DataTableEventType = {
|
|
4
|
+
results: string[][]
|
|
5
|
+
numberOfResults: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type HeadingObject = {
|
|
9
|
+
name: string
|
|
10
|
+
sortable?: boolean
|
|
11
|
+
toggleable?: boolean
|
|
12
|
+
filterable?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type DataTableProps = {
|
|
16
|
+
headings?: (HeadingObject | string)[]
|
|
17
|
+
filterPlaceholder?: string
|
|
18
|
+
showFilterIcon?: boolean
|
|
19
|
+
noResultsLabel?: string
|
|
20
|
+
itemsPerPage?: number | null
|
|
21
|
+
subText?: string
|
|
22
|
+
columnToggleLabel?: string
|
|
23
|
+
pagination?: PaginationProps
|
|
24
|
+
data: string[][]
|
|
25
|
+
hover?: boolean
|
|
26
|
+
striped?: 'column' | 'row' | null
|
|
27
|
+
offsetStripe?: boolean
|
|
28
|
+
compact?: boolean
|
|
29
|
+
maxHeight?: string
|
|
30
|
+
className?: string
|
|
31
|
+
id?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type SvelteDataTableProps = {
|
|
35
|
+
onFilter?: (event: DataTableEventType) => void
|
|
36
|
+
} & DataTableProps
|
|
37
|
+
|
|
38
|
+
export type ReactDataTableProps = {
|
|
39
|
+
onFilter?: (event: DataTableEventType) => void
|
|
40
|
+
children?: React.ReactNode
|
|
41
|
+
} & DataTableProps
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { FooterProps } from './footer'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
|
|
5
|
+
|
|
6
|
+
import styles from './footer.module.scss'
|
|
7
|
+
|
|
8
|
+
interface Props extends FooterProps {}
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
logo,
|
|
12
|
+
columns,
|
|
13
|
+
subText,
|
|
14
|
+
className,
|
|
15
|
+
wrapperClassName,
|
|
16
|
+
subTextClassName
|
|
17
|
+
} = Astro.props
|
|
18
|
+
|
|
19
|
+
const classes = [
|
|
20
|
+
styles.footer,
|
|
21
|
+
className
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const containerClasses = [
|
|
25
|
+
styles.container,
|
|
26
|
+
wrapperClassName
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
const subTextClasses = [
|
|
30
|
+
styles.subtext,
|
|
31
|
+
subTextClassName
|
|
32
|
+
]
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
<footer class:list={classes}>
|
|
36
|
+
<div class:list={containerClasses}>
|
|
37
|
+
<ConditionalWrapper condition={!!(logo?.url || logo?.html)}>
|
|
38
|
+
<div slot="wrapper" class={styles.wrapper}>children</div>
|
|
39
|
+
{logo?.url && (
|
|
40
|
+
<a href="/">
|
|
41
|
+
<img
|
|
42
|
+
src={logo.url}
|
|
43
|
+
alt={logo.alt || 'Logo'}
|
|
44
|
+
width={logo.width}
|
|
45
|
+
height={logo.height}
|
|
46
|
+
loading={logo.eager ? undefined : 'lazy'}
|
|
47
|
+
/>
|
|
48
|
+
</a>
|
|
49
|
+
)}
|
|
50
|
+
|
|
51
|
+
{logo?.html && (
|
|
52
|
+
<a href="/" aria-label={logo.alt || 'Logo'}>
|
|
53
|
+
<Fragment set:html={logo.html} />
|
|
54
|
+
</a>
|
|
55
|
+
)}
|
|
56
|
+
|
|
57
|
+
{!!columns?.length && (
|
|
58
|
+
<ConditionalWrapper condition={columns.length > 1}>
|
|
59
|
+
<div slot="wrapper" class={styles.columns}>children</div>
|
|
60
|
+
{columns.map(column => (
|
|
61
|
+
<ConditionalWrapper condition={!!column.title}>
|
|
62
|
+
<div slot="wrapper">children</div>
|
|
63
|
+
{column.title && (
|
|
64
|
+
<strong class={styles['column-title']}>{column.title}</strong>
|
|
65
|
+
)}
|
|
66
|
+
<ul class={styles.column}>
|
|
67
|
+
{column.items.map(item => (
|
|
68
|
+
<li>
|
|
69
|
+
<a
|
|
70
|
+
href={item.href}
|
|
71
|
+
target={item.target}
|
|
72
|
+
class:list={[item.active && styles.active]}
|
|
73
|
+
>
|
|
74
|
+
{item.name}
|
|
75
|
+
</a>
|
|
76
|
+
</li>
|
|
77
|
+
))}
|
|
78
|
+
</ul>
|
|
79
|
+
</ConditionalWrapper>
|
|
80
|
+
))}
|
|
81
|
+
</ConditionalWrapper>
|
|
82
|
+
)}
|
|
83
|
+
</ConditionalWrapper>
|
|
84
|
+
{(subText || Astro.slots.has('default')) && (
|
|
85
|
+
<div class:list={subTextClasses}>
|
|
86
|
+
{subText && <span set:html={subText} />}
|
|
87
|
+
<slot />
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
</footer>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FooterProps } from './footer'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
5
|
+
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
import styles from './footer.module.scss'
|
|
9
|
+
|
|
10
|
+
export let logo: FooterProps['logo'] = null
|
|
11
|
+
export let columns: FooterProps['columns'] = []
|
|
12
|
+
export let subText: FooterProps['subText'] = ''
|
|
13
|
+
export let className: FooterProps['className'] = ''
|
|
14
|
+
export let wrapperClassName: FooterProps['wrapperClassName'] = ''
|
|
15
|
+
export let subTextClassName: FooterProps['subTextClassName'] = ''
|
|
16
|
+
|
|
17
|
+
const classes = classNames([
|
|
18
|
+
styles.footer,
|
|
19
|
+
className
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
const containerClasses = classNames([
|
|
23
|
+
styles.container,
|
|
24
|
+
wrapperClassName
|
|
25
|
+
])
|
|
26
|
+
|
|
27
|
+
const subTextClasses = classNames([
|
|
28
|
+
styles.subtext,
|
|
29
|
+
subTextClassName
|
|
30
|
+
])
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<footer class={classes}>
|
|
34
|
+
<div class={containerClasses}>
|
|
35
|
+
<ConditionalWrapper
|
|
36
|
+
condition={!!(logo?.url || logo?.html)}
|
|
37
|
+
class={styles.wrapper}
|
|
38
|
+
>
|
|
39
|
+
{#if logo?.url}
|
|
40
|
+
<a href="/">
|
|
41
|
+
<img
|
|
42
|
+
src={logo.url}
|
|
43
|
+
alt={logo.alt || 'Logo'}
|
|
44
|
+
width={logo.width}
|
|
45
|
+
height={logo.height}
|
|
46
|
+
loading={logo.eager ? undefined : 'lazy'}
|
|
47
|
+
/>
|
|
48
|
+
</a>
|
|
49
|
+
{/if}
|
|
50
|
+
|
|
51
|
+
{#if logo?.html}
|
|
52
|
+
<a href="/" aria-label={logo.alt || 'Logo'}>
|
|
53
|
+
{@html logo.html}
|
|
54
|
+
</a>
|
|
55
|
+
{/if}
|
|
56
|
+
|
|
57
|
+
{#if columns?.length}
|
|
58
|
+
<ConditionalWrapper
|
|
59
|
+
condition={columns.length > 1}
|
|
60
|
+
class={styles.columns}
|
|
61
|
+
>
|
|
62
|
+
{#each columns as column}
|
|
63
|
+
<ConditionalWrapper condition={!!column.title}>
|
|
64
|
+
{#if column.title}
|
|
65
|
+
<strong class={styles['column-title']}>{column.title}</strong>
|
|
66
|
+
{/if}
|
|
67
|
+
<ul class={styles.column}>
|
|
68
|
+
{#each column.items as item}
|
|
69
|
+
<li>
|
|
70
|
+
<a
|
|
71
|
+
href={item.href}
|
|
72
|
+
target={item.target}
|
|
73
|
+
class={item.active ? styles.active : undefined}
|
|
74
|
+
>
|
|
75
|
+
{item.name}
|
|
76
|
+
</a>
|
|
77
|
+
</li>
|
|
78
|
+
{/each}
|
|
79
|
+
</ul>
|
|
80
|
+
</ConditionalWrapper>
|
|
81
|
+
{/each}
|
|
82
|
+
</ConditionalWrapper>
|
|
83
|
+
{/if}
|
|
84
|
+
</ConditionalWrapper>
|
|
85
|
+
{#if subText || $$slots.default}
|
|
86
|
+
<div class={subTextClasses}>
|
|
87
|
+
{#if subText}
|
|
88
|
+
<span>{@html subText}</span>
|
|
89
|
+
{/if}
|
|
90
|
+
<slot />
|
|
91
|
+
</div>
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
94
|
+
</footer>
|