webcoreui 0.9.0 → 0.10.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 +20 -6
- package/components/Accordion/Accordion.astro +15 -10
- package/components/Accordion/Accordion.svelte +14 -12
- package/components/Accordion/Accordion.tsx +2 -2
- package/components/Alert/Alert.svelte +17 -12
- package/components/Alert/Alert.tsx +1 -1
- package/components/Alert/alert.ts +10 -3
- package/components/AspectRatio/AspectRatio.svelte +7 -4
- package/components/AspectRatio/aspectratio.ts +6 -0
- package/components/Avatar/Avatar.svelte +11 -9
- package/components/Badge/Badge.svelte +14 -10
- package/components/Badge/badge.ts +2 -1
- package/components/Banner/Banner.astro +10 -4
- package/components/Banner/Banner.svelte +14 -10
- package/components/Banner/Banner.tsx +1 -0
- package/components/Banner/banner.ts +6 -0
- package/components/BottomNavigation/BottomNavigation.svelte +7 -5
- package/components/Breadcrumb/Breadcrumb.astro +1 -1
- package/components/Breadcrumb/Breadcrumb.svelte +8 -6
- package/components/Breadcrumb/Breadcrumb.tsx +2 -2
- package/components/Button/Button.svelte +12 -8
- package/components/Button/Button.tsx +2 -2
- package/components/Button/button.ts +2 -3
- package/components/Card/Card.svelte +14 -10
- package/components/Card/card.ts +6 -0
- package/components/Carousel/Carousel.astro +46 -41
- package/components/Carousel/carousel.ts +3 -0
- package/components/Checkbox/Checkbox.svelte +12 -9
- package/components/Checkbox/checkbox.module.scss +4 -0
- package/components/Collapsible/Collapsible.astro +8 -5
- package/components/Collapsible/Collapsible.svelte +54 -49
- package/components/Collapsible/collapsible.ts +8 -0
- package/components/ConditionalWrapper/ConditionalWrapper.svelte +10 -6
- package/components/ConditionalWrapper/conditionalwrapper.ts +6 -0
- package/components/Copy/Copy.astro +17 -11
- package/components/Copy/Copy.svelte +68 -61
- package/components/Copy/Copy.tsx +1 -0
- package/components/Copy/copy.ts +8 -2
- package/components/DataTable/DataTable.astro +103 -93
- package/components/DataTable/DataTable.svelte +276 -272
- package/components/DataTable/datatable.ts +5 -2
- package/components/Flex/Flex.svelte +14 -10
- package/components/Flex/flex.ts +6 -0
- package/components/Footer/Footer.svelte +12 -9
- package/components/Footer/footer.ts +6 -0
- package/components/Grid/Grid.svelte +12 -8
- package/components/Grid/grid.ts +6 -0
- package/components/Group/Group.svelte +7 -4
- package/components/Group/group.ts +6 -0
- package/components/Icon/Icon.astro +19 -5
- package/components/Icon/Icon.svelte +23 -7
- package/components/Icon/Icon.tsx +19 -5
- package/components/Icon/icon.ts +9 -3
- package/components/Icon/map.ts +8 -10
- package/components/Input/Input.svelte +24 -20
- package/components/Input/input.ts +10 -3
- package/components/Kbd/Kbd.svelte +7 -4
- package/components/Kbd/kbd.ts +6 -0
- package/components/List/List.astro +65 -60
- package/components/List/List.svelte +149 -147
- package/components/List/List.tsx +1 -1
- package/components/Masonry/Masonry.svelte +12 -10
- package/components/Menu/Menu.astro +8 -3
- package/components/Menu/Menu.svelte +15 -10
- package/components/Menu/Menu.tsx +3 -1
- package/components/Menu/menu.ts +6 -0
- package/components/Modal/Modal.astro +1 -0
- package/components/Modal/Modal.svelte +18 -13
- package/components/Modal/Modal.tsx +2 -1
- package/components/Modal/modal.ts +6 -1
- package/components/Pagination/Pagination.astro +75 -69
- package/components/Pagination/Pagination.svelte +29 -26
- package/components/Pagination/Pagination.tsx +5 -4
- package/components/Pagination/pagination.module.scss +4 -0
- package/components/Popover/Popover.svelte +10 -6
- package/components/Popover/popover.ts +6 -0
- package/components/Progress/Progress.svelte +12 -10
- package/components/Progress/progress.ts +1 -1
- package/components/Radio/Radio.svelte +12 -9
- package/components/Radio/radio.ts +4 -2
- package/components/Rating/Rating.svelte +16 -14
- package/components/Ribbon/Ribbon.svelte +9 -6
- package/components/Ribbon/ribbon.ts +6 -0
- package/components/Select/Select.astro +73 -63
- package/components/Select/Select.svelte +27 -22
- package/components/Select/Select.tsx +8 -6
- package/components/Sheet/Sheet.svelte +9 -5
- package/components/Sheet/sheet.ts +6 -2
- package/components/Sidebar/Sidebar.svelte +7 -4
- package/components/Sidebar/sidebar.ts +6 -0
- package/components/Skeleton/Skeleton.svelte +9 -7
- package/components/Slider/Slider.svelte +15 -13
- package/components/Slider/slider.module.scss +4 -0
- package/components/Slider/slider.ts +4 -2
- package/components/Spinner/Spinner.svelte +7 -5
- package/components/Spoiler/Spoiler.astro +13 -8
- package/components/Spoiler/Spoiler.svelte +13 -10
- package/components/Spoiler/spoiler.ts +6 -0
- package/components/Stepper/Stepper.svelte +9 -7
- package/components/Switch/Switch.svelte +15 -12
- package/components/Table/Table.svelte +11 -9
- package/components/Table/table.ts +1 -1
- package/components/Tabs/Tabs.astro +8 -5
- package/components/Tabs/Tabs.svelte +14 -11
- package/components/Tabs/tabs.ts +7 -1
- package/components/Textarea/Textarea.svelte +14 -11
- package/components/Textarea/textarea.ts +9 -4
- package/components/ThemeSwitcher/ThemeSwitcher.astro +43 -37
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +14 -10
- package/components/ThemeSwitcher/themeswitcher.ts +7 -0
- package/components/Timeline/Timeline.svelte +12 -9
- package/components/Timeline/timeline.ts +7 -2
- package/components/TimelineItem/TimelineItem.svelte +8 -5
- package/components/TimelineItem/timelineitem.ts +6 -0
- package/components/Toast/Toast.svelte +18 -10
- package/components/Toast/toast.ts +6 -1
- package/icons/alert.svg +2 -2
- package/icons/check.svg +2 -2
- package/icons/chevron-down.svg +3 -0
- package/icons/chevron-left.svg +3 -0
- package/icons/chevron-right.svg +3 -0
- package/icons/chevron-up.svg +3 -0
- package/icons/circle-check.svg +3 -3
- package/icons/info.svg +3 -3
- package/icons.d.ts +4 -5
- package/icons.js +4 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +20 -20
- package/react.d.ts +3 -3
- package/svelte.d.ts +98 -98
- package/utils/bodyFreeze.ts +13 -0
- package/utils/modal.ts +12 -0
- package/icons/arrow-down.svg +0 -3
- package/icons/arrow-left.svg +0 -3
- package/icons/arrow-right.svg +0 -3
- package/icons/components.svg +0 -3
- package/icons/file.svg +0 -3
package/components/Copy/copy.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
3
|
+
import type { BadgeProps } from '../Badge/badge'
|
|
4
|
+
import type { IconProps } from '../Icon/icon'
|
|
3
5
|
|
|
4
6
|
export type CopyProps = {
|
|
5
7
|
tooltip?: string
|
|
@@ -9,6 +11,10 @@ export type CopyProps = {
|
|
|
9
11
|
className?: string
|
|
10
12
|
} & BadgeProps
|
|
11
13
|
|
|
14
|
+
export type SvelteCopyProps = {
|
|
15
|
+
children: Snippet
|
|
16
|
+
} & CopyProps
|
|
17
|
+
|
|
12
18
|
export type ReactCopyProps = {
|
|
13
19
|
children: React.ReactNode
|
|
14
20
|
} & CopyProps
|
|
@@ -173,117 +173,120 @@ const hasPagination = data?.length && itemsPerPage
|
|
|
173
173
|
import { debounce } from '../../utils/debounce'
|
|
174
174
|
import { dispatch, listen } from '../../utils/event'
|
|
175
175
|
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const rowValue = Array.from(row.querySelectorAll('td'))
|
|
190
|
-
.filter(td => filterableColumns?.includes(td.dataset.name || ''))
|
|
191
|
-
.map(td => td.innerText)
|
|
192
|
-
.join('')
|
|
193
|
-
.toLowerCase()
|
|
194
|
-
|
|
195
|
-
if (rowValue.includes(target.value.toLowerCase())) {
|
|
196
|
-
row.removeAttribute('data-hidden')
|
|
197
|
-
} else {
|
|
198
|
-
row.dataset.hidden = 'true'
|
|
199
|
-
}
|
|
200
|
-
})
|
|
176
|
+
const addEventListeners = () => {
|
|
177
|
+
const filters = document.querySelectorAll('[data-id="w-data-table-filter"]')
|
|
178
|
+
const sorts = document.querySelectorAll('[data-id="w-data-table-sort"]')
|
|
179
|
+
|
|
180
|
+
Array.from(filters).forEach(filter => {
|
|
181
|
+
filter.addEventListener('input', debounce((event: Event) => {
|
|
182
|
+
const target = event.target as HTMLInputElement
|
|
183
|
+
const filterableColumns = target.dataset.filter
|
|
184
|
+
const section = target.closest('section')
|
|
185
|
+
const table = section?.querySelector('table') as HTMLTableElement
|
|
186
|
+
const pagination = section?.querySelector('.w-data-table-pagination') as HTMLUListElement
|
|
187
|
+
const noResults = table.querySelector('tfoot') as HTMLElement
|
|
188
|
+
const tableRows = Array.from(table.querySelectorAll('tbody tr') as NodeListOf<HTMLTableRowElement>)
|
|
201
189
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
} else {
|
|
209
|
-
noResults.dataset.hidden = 'true'
|
|
210
|
-
}
|
|
190
|
+
tableRows.forEach(row => {
|
|
191
|
+
const rowValue = Array.from(row.querySelectorAll('td'))
|
|
192
|
+
.filter(td => filterableColumns?.includes(td.dataset.name || ''))
|
|
193
|
+
.map(td => td.innerText)
|
|
194
|
+
.join('')
|
|
195
|
+
.toLowerCase()
|
|
211
196
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
197
|
+
if (rowValue.includes(target.value.toLowerCase())) {
|
|
198
|
+
row.removeAttribute('data-hidden')
|
|
199
|
+
} else {
|
|
215
200
|
row.dataset.hidden = 'true'
|
|
216
201
|
}
|
|
217
202
|
})
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (target.value) {
|
|
221
|
-
pagination.style.display = 'none'
|
|
222
|
-
} else {
|
|
223
|
-
pagination.style.display = 'flex'
|
|
224
203
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
} else {
|
|
229
|
-
row.removeAttribute('data-hidden')
|
|
230
|
-
}
|
|
231
|
-
})
|
|
232
|
-
}
|
|
204
|
+
const filteredRows = Array.from(
|
|
205
|
+
table?.querySelectorAll('tbody tr:not([data-hidden])') as NodeListOf<HTMLTableRowElement>
|
|
206
|
+
)
|
|
233
207
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
})
|
|
208
|
+
if (!filteredRows.length) {
|
|
209
|
+
noResults.removeAttribute('data-hidden')
|
|
210
|
+
} else {
|
|
211
|
+
noResults.dataset.hidden = 'true'
|
|
212
|
+
}
|
|
240
213
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const table = target.closest('section')?.querySelector('table')
|
|
248
|
-
const tableBody = table?.querySelector('tbody')
|
|
249
|
-
const sortedTableRows = Array.from(
|
|
250
|
-
table?.querySelectorAll('tbody tr') as NodeListOf<HTMLTableRowElement>
|
|
251
|
-
).sort((a, b) => {
|
|
252
|
-
let aValue: string | number = (a.querySelector(`[data-name=${sortBy}]`) as HTMLElement)
|
|
253
|
-
?.innerText.replace(/\s/g, '')
|
|
254
|
-
let bValue: string | number = (b.querySelector(`[data-name=${sortBy}]`) as HTMLElement)
|
|
255
|
-
?.innerText.replace(/\s/g, '')
|
|
256
|
-
|
|
257
|
-
if (!isNaN(aValue as any)) {
|
|
258
|
-
aValue = Number(aValue)
|
|
214
|
+
if (table.dataset.itemsPerPage && filteredRows.length >= Number(table.dataset.itemsPerPage)) {
|
|
215
|
+
filteredRows.forEach((row, index) => {
|
|
216
|
+
if (index >= Number(table.dataset.itemsPerPage)) {
|
|
217
|
+
row.dataset.hidden = 'true'
|
|
218
|
+
}
|
|
219
|
+
})
|
|
259
220
|
}
|
|
260
221
|
|
|
261
|
-
if (
|
|
262
|
-
|
|
222
|
+
if (target.value) {
|
|
223
|
+
pagination.style.display = 'none'
|
|
224
|
+
} else {
|
|
225
|
+
pagination.style.display = 'flex'
|
|
226
|
+
|
|
227
|
+
tableRows.forEach(row => {
|
|
228
|
+
if (row.dataset.page !== table.dataset.page) {
|
|
229
|
+
row.dataset.hidden = 'true'
|
|
230
|
+
} else {
|
|
231
|
+
row.removeAttribute('data-hidden')
|
|
232
|
+
}
|
|
233
|
+
})
|
|
263
234
|
}
|
|
264
235
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
236
|
+
dispatch('dataTableFilter', {
|
|
237
|
+
results: filteredRows,
|
|
238
|
+
numberOfResults: filteredRows.length
|
|
239
|
+
})
|
|
240
|
+
}, 400))
|
|
241
|
+
})
|
|
271
242
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
243
|
+
Array.from(sorts).forEach(sort => {
|
|
244
|
+
let sortOrder = 1
|
|
245
|
+
|
|
246
|
+
sort.addEventListener('click', event => {
|
|
247
|
+
const target = event.target as HTMLButtonElement
|
|
248
|
+
const sortBy = target.parentElement?.dataset.name
|
|
249
|
+
const table = target.closest('section')?.querySelector('table')
|
|
250
|
+
const tableBody = table?.querySelector('tbody')
|
|
251
|
+
const sortedTableRows = Array.from(
|
|
252
|
+
table?.querySelectorAll('tbody tr') as NodeListOf<HTMLTableRowElement>
|
|
253
|
+
).sort((a, b) => {
|
|
254
|
+
let aValue: string | number = (a.querySelector(`[data-name=${sortBy}]`) as HTMLElement)
|
|
255
|
+
?.innerText.replace(/\s/g, '')
|
|
256
|
+
let bValue: string | number = (b.querySelector(`[data-name=${sortBy}]`) as HTMLElement)
|
|
257
|
+
?.innerText.replace(/\s/g, '')
|
|
258
|
+
|
|
259
|
+
if (!isNaN(aValue as any)) {
|
|
260
|
+
aValue = Number(aValue)
|
|
276
261
|
}
|
|
277
|
-
}
|
|
278
262
|
|
|
279
|
-
|
|
280
|
-
|
|
263
|
+
if (!isNaN(bValue as any)) {
|
|
264
|
+
bValue = Number(bValue)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return aValue > bValue
|
|
268
|
+
? sortOrder * -1
|
|
269
|
+
: sortOrder
|
|
270
|
+
}).map((row, index) => {
|
|
271
|
+
if (table?.dataset.page) {
|
|
272
|
+
row.dataset.page = `${Math.ceil((index + 1) / Number(table.dataset.itemsPerPage))}`
|
|
273
|
+
|
|
274
|
+
if (row.dataset.page !== table.dataset.page) {
|
|
275
|
+
row.dataset.hidden = 'true'
|
|
276
|
+
} else {
|
|
277
|
+
row.removeAttribute('data-hidden')
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return row
|
|
282
|
+
})
|
|
281
283
|
|
|
282
|
-
|
|
284
|
+
tableBody?.replaceChildren(...sortedTableRows)
|
|
283
285
|
|
|
284
|
-
|
|
286
|
+
sortOrder = sortOrder === 1 ? -1 : 1
|
|
287
|
+
})
|
|
285
288
|
})
|
|
286
|
-
}
|
|
289
|
+
}
|
|
287
290
|
|
|
288
291
|
listen('selectOnChange', event => {
|
|
289
292
|
const eventName = event.name.toLowerCase().replace(/\s/g, '')
|
|
@@ -291,6 +294,10 @@ const hasPagination = data?.length && itemsPerPage
|
|
|
291
294
|
?.closest('section') as HTMLElement)
|
|
292
295
|
.querySelector('table') as HTMLTableElement
|
|
293
296
|
|
|
297
|
+
if (!table) {
|
|
298
|
+
return
|
|
299
|
+
}
|
|
300
|
+
|
|
294
301
|
const affectedTableCells = Array.from(table.querySelectorAll(`[data-name=${eventName}]`)) as HTMLElement[]
|
|
295
302
|
|
|
296
303
|
const columnToggleListElement = Array.from(event.list.children)
|
|
@@ -329,4 +336,7 @@ const hasPagination = data?.length && itemsPerPage
|
|
|
329
336
|
}
|
|
330
337
|
})
|
|
331
338
|
})
|
|
339
|
+
|
|
340
|
+
document.addEventListener('astro:after-swap', addEventListeners)
|
|
341
|
+
addEventListeners()
|
|
332
342
|
</script>
|