webcoreui 0.4.1 → 0.5.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.
Files changed (47) hide show
  1. package/README.md +230 -227
  2. package/astro.d.ts +6 -0
  3. package/astro.js +6 -0
  4. package/components/Avatar/Avatar.astro +9 -2
  5. package/components/Avatar/Avatar.svelte +3 -1
  6. package/components/Avatar/Avatar.tsx +4 -2
  7. package/components/Avatar/avatar.ts +1 -0
  8. package/components/Button/button.module.scss +6 -1
  9. package/components/Button/button.ts +2 -2
  10. package/components/Carousel/Carousel.astro +198 -0
  11. package/components/Carousel/Carousel.svelte +161 -0
  12. package/components/Carousel/Carousel.tsx +172 -0
  13. package/components/Carousel/carousel.module.scss +58 -0
  14. package/components/Carousel/carousel.ts +26 -0
  15. package/components/DataTable/DataTable.astro +332 -0
  16. package/components/DataTable/DataTable.svelte +272 -0
  17. package/components/DataTable/DataTable.tsx +287 -0
  18. package/components/DataTable/datatable.module.scss +102 -0
  19. package/components/DataTable/datatable.ts +41 -0
  20. package/components/Icon/map.ts +6 -0
  21. package/components/Input/input.module.scss +6 -0
  22. package/components/List/List.astro +1 -1
  23. package/components/List/List.svelte +1 -1
  24. package/components/List/List.tsx +1 -2
  25. package/components/Pagination/Pagination.astro +189 -0
  26. package/components/Pagination/Pagination.svelte +144 -0
  27. package/components/Pagination/Pagination.tsx +162 -0
  28. package/components/Pagination/pagination.module.scss +49 -0
  29. package/components/Pagination/pagination.ts +35 -0
  30. package/components/Select/Select.astro +8 -4
  31. package/components/Select/Select.svelte +15 -6
  32. package/components/Select/Select.tsx +15 -8
  33. package/components/Select/select.ts +7 -2
  34. package/components/Table/Table.svelte +1 -1
  35. package/components/Table/table.ts +1 -1
  36. package/icons/arrow-left.svg +3 -0
  37. package/icons/arrow-right.svg +3 -0
  38. package/icons/order.svg +3 -0
  39. package/icons.d.ts +3 -0
  40. package/icons.js +3 -0
  41. package/index.d.ts +6 -6
  42. package/package.json +1 -1
  43. package/react.d.ts +6 -0
  44. package/react.js +6 -0
  45. package/scss/resets.scss +27 -1
  46. package/svelte.d.ts +6 -0
  47. package/svelte.js +6 -0
@@ -15,6 +15,8 @@ import ArrowDown from '../../icons/arrow-down.svg?raw'
15
15
 
16
16
  import styles from './select.module.scss'
17
17
 
18
+ import type { ListEventType } from '../List/list'
19
+
18
20
  const Select = ({
19
21
  name,
20
22
  value,
@@ -22,8 +24,9 @@ const Select = ({
22
24
  label,
23
25
  subText,
24
26
  disabled,
25
- className,
27
+ updateValue = true,
26
28
  position = 'bottom',
29
+ className,
27
30
  onChange,
28
31
  ...rest
29
32
  }: ReactSelectProps) => {
@@ -41,18 +44,22 @@ const Select = ({
41
44
 
42
45
  let popoverInstance: any
43
46
 
44
- const select = (payload: any) => {
47
+ const select = (event: ListEventType) => {
45
48
  closePopover(`.w-options-${name}`)
46
49
 
47
- setValue(payload.name)
50
+ if (updateValue) {
51
+ setValue(event.name)
52
+ }
48
53
 
49
54
  onChange?.({
50
- select: name,
51
- ...payload
55
+ ...event,
56
+ select: name
52
57
  })
53
58
  }
54
59
 
55
60
  useEffect(() => {
61
+ let observer: ResizeObserver | undefined
62
+
56
63
  if (position === 'modal') {
57
64
  modal({
58
65
  trigger: `.w-select-${name}`,
@@ -76,7 +83,8 @@ const Select = ({
76
83
  dialogElement.style.width = `${width}px`
77
84
  })
78
85
 
79
- new ResizeObserver(() => resize()).observe(document.body)
86
+ observer = new ResizeObserver(() => resize())
87
+ observer.observe(document.body)
80
88
 
81
89
  popoverInstance = popover({
82
90
  trigger: `.w-select-${name}`,
@@ -95,6 +103,7 @@ const Select = ({
95
103
 
96
104
  return () => {
97
105
  popoverInstance?.remove()
106
+ observer?.unobserve(document.body)
98
107
  }
99
108
  }, [])
100
109
 
@@ -114,8 +123,6 @@ const Select = ({
114
123
  <span
115
124
  dangerouslySetInnerHTML={{ __html: ArrowDown }}
116
125
  style={{
117
- height: '18px',
118
- position: 'absolute',
119
126
  right: 0,
120
127
  pointerEvents: 'none'
121
128
  }}
@@ -2,6 +2,10 @@ import type { PopoverPosition } from '../../utils/popover'
2
2
 
3
3
  import type { ListEventType, ListProps } from '../List/list'
4
4
 
5
+ export type SelectEventType = {
6
+ select: string
7
+ } & ListEventType
8
+
5
9
  export type SelectProps = {
6
10
  name: string
7
11
  value?: string
@@ -9,13 +13,14 @@ export type SelectProps = {
9
13
  label?: string
10
14
  subText?: string
11
15
  disabled?: boolean
16
+ updateValue?: boolean
12
17
  position?: PopoverPosition | 'modal'
13
18
  } & ListProps
14
19
 
15
20
  export type SvelteSelectProps = {
16
- onChange?: (event: ListEventType & { select: string }) => void
21
+ onChange?: (event: SelectEventType) => void
17
22
  } & SelectProps
18
23
 
19
24
  export type ReactSelectProps = {
20
- onChange?: (event: ListEventType & { select: string }) => void
25
+ onChange?: (event: SelectEventType) => void
21
26
  } & SelectProps
@@ -12,7 +12,7 @@
12
12
  export let striped: TableProps['striped'] = null
13
13
  export let offsetStripe: TableProps['offsetStripe'] = false
14
14
  export let compact: TableProps['compact'] = false
15
- export let maxHeight: TableProps['maxHeight'] = 0
15
+ export let maxHeight: TableProps['maxHeight'] = ''
16
16
  export let className: TableProps['className'] = ''
17
17
 
18
18
  const classes = classNames([
@@ -6,6 +6,6 @@ export type TableProps = {
6
6
  striped?: 'column' | 'row' | null
7
7
  offsetStripe?: boolean
8
8
  compact?: boolean
9
- maxHeight?: number
9
+ maxHeight?: string
10
10
  className?: string
11
11
  }
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M17.5786 0.360618C18.1158 0.864272 18.143 1.70806 17.6394 2.24526L8.4943 12L17.6394 21.7547C18.143 22.292 18.1158 23.1358 17.5786 23.6395C17.0413 24.143 16.1976 24.1158 15.6939 23.5787L5.6938 12.9119C5.213 12.3991 5.213 11.601 5.6938 11.0881L15.6939 0.421418C16.1976 -0.11581 17.0414 -0.143009 17.5786 0.360618Z" fill="currentColor"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M6.42142 23.6394C5.88419 23.1357 5.85699 22.2919 6.36062 21.7547L15.5057 12L6.36062 2.2453C5.85699 1.708 5.88419 0.8642 6.42142 0.3605C6.95865 -0.143 7.80243 -0.115799 8.30606 0.421301L18.3062 11.0881C18.787 11.6009 18.787 12.399 18.3062 12.9119L8.30606 23.5786C7.80243 24.1158 6.95865 24.143 6.42142 23.6394Z" fill="currentColor"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M5.8125 20V4M5.8125 4L10.625 9.09091M5.8125 4L1 9.09091M18.1875 4V20M18.1875 20L23 14.9091M18.1875 20L13.375 14.9091" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
package/icons.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  declare module 'webcoreui/icons' {
2
2
  export const alert: string
3
3
  export const arrowDown: string
4
+ export const arrowLeft: string
5
+ export const arrowRight: string
4
6
  export const check: string
5
7
  export const circleCheck: string
6
8
  export const close: string
7
9
  export const github: string
8
10
  export const info: string
9
11
  export const moon: string
12
+ export const order: string
10
13
  export const search: string
11
14
  export const sun: string
12
15
  export const warning: string
package/icons.js CHANGED
@@ -1,11 +1,14 @@
1
1
  export { default as alert } from './icons/alert.svg?raw'
2
2
  export { default as arrowDown } from './icons/arrow-down.svg?raw'
3
+ export { default as arrowLeft } from './icons/arrow-left.svg?raw'
4
+ export { default as arrowRight } from './icons/arrow-right.svg?raw'
3
5
  export { default as check } from './icons/check.svg?raw'
4
6
  export { default as circleCheck } from './icons/circle-check.svg?raw'
5
7
  export { default as close } from './icons/close.svg?raw'
6
8
  export { default as github } from './icons/github.svg?raw'
7
9
  export { default as info } from './icons/info.svg?raw'
8
10
  export { default as moon } from './icons/moon.svg?raw'
11
+ export { default as order } from './icons/order.svg?raw'
9
12
  export { default as search } from './icons/search.svg?raw'
10
13
  export { default as sun } from './icons/sun.svg?raw'
11
14
  export { default as warning } from './icons/warning.svg?raw'
package/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
 
2
- type ModalCallback = {
2
+ export type ModalCallback = {
3
3
  trigger: Element | null
4
4
  modal: HTMLElement
5
5
  }
6
6
 
7
- type Modal = {
7
+ export type Modal = {
8
8
  trigger: string
9
9
  modal: string
10
10
  onOpen?: (args: ModalCallback) => unknown
11
11
  onClose?: (args: ModalCallback) => unknown
12
12
  }
13
13
 
14
- type PopoverPosition = 'top'
14
+ export type PopoverPosition = 'top'
15
15
  | 'top-start'
16
16
  | 'top-end'
17
17
  | 'left'
@@ -24,13 +24,13 @@ type PopoverPosition = 'top'
24
24
  | 'bottom-start'
25
25
  | 'bottom-end'
26
26
 
27
- type PopoverCallback = {
27
+ export type PopoverCallback = {
28
28
  trigger: HTMLElement
29
29
  popover: HTMLElement
30
30
  position: PopoverPosition | undefined
31
31
  }
32
32
 
33
- type Popover = {
33
+ export type Popover = {
34
34
  trigger: string
35
35
  popover: string
36
36
  position?: PopoverPosition
@@ -40,7 +40,7 @@ type Popover = {
40
40
  onClose?: (args: PopoverCallback) => unknown
41
41
  }
42
42
 
43
- type Toast = {
43
+ export type Toast = {
44
44
  element: string
45
45
  timeout?: number
46
46
  title?: string
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webcoreui",
3
3
  "type": "module",
4
- "version": "0.4.1",
4
+ "version": "0.5.0",
5
5
  "scripts": {
6
6
  "prepare": "husky",
7
7
  "pre-commit": "lint-staged",
package/react.d.ts CHANGED
@@ -5,15 +5,18 @@ import type { AvatarProps } from './components/Avatar/avatar'
5
5
  import type { ReactBadgeProps } from './components/Badge/badge'
6
6
  import type { ReactButtonProps } from './components/Button/button'
7
7
  import type { ReactCardProps } from './components/Card/card'
8
+ import type { ReactCarouselProps } from './components/Carousel/carousel'
8
9
  import type { ReactCheckboxProps } from './components/Checkbox/checkbox'
9
10
  import type { ReactCollapsibleProps } from './components/Collapsible/collapsible'
10
11
  import type { ReactConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
12
+ import type { ReactDataTableProps } from './components/DataTable/datatable'
11
13
  import type { ReactGroupProps } from './components/Group/group'
12
14
  import type { IconProps } from './components/Icon/icon'
13
15
  import type { ReactInputProps } from './components/Input/input'
14
16
  import type { ReactListProps } from './components/List/list'
15
17
  import type { ReactMenuProps } from './components/Menu/menu'
16
18
  import type { ReactModalProps } from './components/Modal/modal'
19
+ import type { ReactPaginationProps } from './components/Pagination/pagination'
17
20
  import type { ReactPopoverProps } from './components/Popover/popover'
18
21
  import type { ProgressProps } from './components/Progress/progress'
19
22
  import type { ReactRadioProps } from './components/Radio/radio'
@@ -38,15 +41,18 @@ declare module 'webcoreui/react' {
38
41
  export const Badge: FC<ReactBadgeProps>
39
42
  export const Button: FC<ReactButtonProps>
40
43
  export const Card: FC<ReactCardProps>
44
+ export const Carousel: FC<ReactCarouselProps>
41
45
  export const Checkbox: FC<ReactCheckboxProps>
42
46
  export const Collapsible: FC<ReactCollapsibleProps>
43
47
  export const ConditionalWrapper: FC<ReactConditionalWrapperProps>
48
+ export const DataTable: FC<ReactDataTableProps>
44
49
  export const Group: FC<ReactGroupProps>
45
50
  export const Icon: FC<IconProps>
46
51
  export const Input: FC<ReactInputProps>
47
52
  export const List: FC<ReactListProps>
48
53
  export const Menu: FC<ReactMenuProps>
49
54
  export const Modal: FC<ReactModalProps>
55
+ export const Pagination: FC<ReactPaginationProps>
50
56
  export const Popover: FC<ReactPopoverProps>
51
57
  export const Progress: FC<ProgressProps>
52
58
  export const Radio: FC<ReactRadioProps>
package/react.js CHANGED
@@ -4,15 +4,18 @@ import AvatarComponent from './components/Avatar/Avatar.tsx'
4
4
  import BadgeComponent from './components/Badge/Badge.tsx'
5
5
  import ButtonComponent from './components/Button/Button.tsx'
6
6
  import CardComponent from './components/Card/Card.tsx'
7
+ import CarouselComponent from './components/Carousel/Carousel.tsx'
7
8
  import CheckboxComponent from './components/Checkbox/Checkbox.tsx'
8
9
  import CollapsibleComponent from './components/Collapsible/Collapsible.tsx'
9
10
  import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.tsx'
11
+ import DataTableComponent from './components/DataTable/DataTable.tsx'
10
12
  import GroupComponent from './components/Group/Group.tsx'
11
13
  import IconComponent from './components/Icon/Icon.tsx'
12
14
  import InputComponent from './components/Input/Input.tsx'
13
15
  import ListComponent from './components/List/List.tsx'
14
16
  import MenuComponent from './components/Menu/Menu.tsx'
15
17
  import ModalComponent from './components/Modal/Modal.tsx'
18
+ import PaginationComponent from './components/Pagination/Pagination.tsx'
16
19
  import PopoverComponent from './components/Popover/Popover.tsx'
17
20
  import ProgressComponent from './components/Progress/Progress.tsx'
18
21
  import RadioComponent from './components/Radio/Radio.tsx'
@@ -36,15 +39,18 @@ export const Avatar = AvatarComponent
36
39
  export const Badge = BadgeComponent
37
40
  export const Button = ButtonComponent
38
41
  export const Card = CardComponent
42
+ export const Carousel = CarouselComponent
39
43
  export const Checkbox = CheckboxComponent
40
44
  export const Collapsible = CollapsibleComponent
41
45
  export const ConditionalWrapper = ConditionalWrapperComponent
46
+ export const DataTable = DataTableComponent
42
47
  export const Group = GroupComponent
43
48
  export const Icon = IconComponent
44
49
  export const Input = InputComponent
45
50
  export const List = ListComponent
46
51
  export const Menu = MenuComponent
47
52
  export const Modal = ModalComponent
53
+ export const Pagination = PaginationComponent
48
54
  export const Popover = PopoverComponent
49
55
  export const Progress = ProgressComponent
50
56
  export const Radio = RadioComponent
package/scss/resets.scss CHANGED
@@ -57,7 +57,7 @@
57
57
  }
58
58
 
59
59
  code {
60
- @include spacing(px-sm);
60
+ @include spacing(px-xs);
61
61
  display: inline-block;
62
62
  }
63
63
 
@@ -103,4 +103,30 @@
103
103
  @include border(0);
104
104
  @include background(primary-50);
105
105
  }
106
+
107
+ table {
108
+ @include size('w100%');
109
+ @include typography(left);
110
+
111
+ border-collapse: collapse;
112
+ }
113
+
114
+ thead,
115
+ tfoot {
116
+ @include typography(bold);
117
+ }
118
+
119
+ th,
120
+ td {
121
+ @include spacing(py-xs, px-sm);
122
+ }
123
+
124
+ thead,
125
+ tr {
126
+ @include border(bottom, primary-50);
127
+
128
+ &:last-child {
129
+ @include border(bottom, 0);
130
+ }
131
+ }
106
132
  }
package/svelte.d.ts CHANGED
@@ -4,15 +4,18 @@ import type { AvatarProps } from './components/Avatar/avatar'
4
4
  import type { SvelteBadgeProps } from './components/Badge/badge'
5
5
  import type { SvelteButtonProps } from './components/Button/button'
6
6
  import type { CardProps } from './components/Card/card'
7
+ import type { SvelteCarouselProps } from './components/Carousel/carousel'
7
8
  import type { SvelteCheckboxProps } from './components/Checkbox/checkbox'
8
9
  import type { CollapsibleProps } from './components/Collapsible/collapsible'
9
10
  import type { ConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
11
+ import type { SvelteDataTableProps } from './components/DataTable/datatable'
10
12
  import type { GroupProps } from './components/Group/group'
11
13
  import type { IconProps } from './components/Icon/icon'
12
14
  import type { SvelteInputProps } from './components/Input/input'
13
15
  import type { SvelteListProps } from './components/List/list'
14
16
  import type { MenuProps } from './components/Menu/menu'
15
17
  import type { ModalProps } from './components/Modal/modal'
18
+ import type { SveltePaginationProps } from './components/Pagination/pagination'
16
19
  import type { PopoverProps } from './components/Popover/popover'
17
20
  import type { ProgressProps } from './components/Progress/progress'
18
21
  import type { SvelteRadioProps } from './components/Radio/radio'
@@ -37,15 +40,18 @@ declare module 'webcoreui/svelte' {
37
40
  export function Badge(_props: SvelteBadgeProps): any
38
41
  export function Button(_props: SvelteButtonProps): any
39
42
  export function Card(_props: CardProps): any
43
+ export function Carousel(_props: SvelteCarouselProps): any
40
44
  export function Checkbox(_props: SvelteCheckboxProps): any
41
45
  export function Collapsible(_props: CollapsibleProps): any
42
46
  export function ConditionalWrapper(_props: ConditionalWrapperProps): any
47
+ export function DataTable(_props: SvelteDataTableProps): any
43
48
  export function Group(_props: GroupProps): any
44
49
  export function Icon(_props: IconProps): any
45
50
  export function Input(_props: SvelteInputProps): any
46
51
  export function List(_props: SvelteListProps): any
47
52
  export function Menu(_props: MenuProps): any
48
53
  export function Modal(_props: ModalProps): any
54
+ export function Pagination(_props: SveltePaginationProps): any
49
55
  export function Popover(_props: PopoverProps): any
50
56
  export function Progress(_props: ProgressProps): any
51
57
  export function Radio(_props: SvelteRadioProps): any
package/svelte.js CHANGED
@@ -4,15 +4,18 @@ import AvatarComponent from './components/Avatar/Avatar.svelte'
4
4
  import BadgeComponent from './components/Badge/Badge.svelte'
5
5
  import ButtonComponent from './components/Button/Button.svelte'
6
6
  import CardComponent from './components/Card/Card.svelte'
7
+ import CarouselComponent from './components/Carousel/Carousel.svelte'
7
8
  import CheckboxComponent from './components/Checkbox/Checkbox.svelte'
8
9
  import CollapsibleComponent from './components/Collapsible/Collapsible.svelte'
9
10
  import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.svelte'
11
+ import DataTableComponent from './components/DataTable/DataTable.svelte'
10
12
  import GroupComponent from './components/Group/Group.svelte'
11
13
  import IconComponent from './components/Icon/Icon.svelte'
12
14
  import InputComponent from './components/Input/Input.svelte'
13
15
  import ListComponent from './components/List/List.svelte'
14
16
  import MenuComponent from './components/Menu/Menu.svelte'
15
17
  import ModalComponent from './components/Modal/Modal.svelte'
18
+ import PaginationComponent from './components/Pagination/Pagination.svelte'
16
19
  import PopoverComponent from './components/Popover/Popover.svelte'
17
20
  import ProgressComponent from './components/Progress/Progress.svelte'
18
21
  import RadioComponent from './components/Radio/Radio.svelte'
@@ -36,15 +39,18 @@ export const Avatar = AvatarComponent
36
39
  export const Badge = BadgeComponent
37
40
  export const Button = ButtonComponent
38
41
  export const Card = CardComponent
42
+ export const Carousel = CarouselComponent
39
43
  export const Checkbox = CheckboxComponent
40
44
  export const Collapsible = CollapsibleComponent
41
45
  export const ConditionalWrapper = ConditionalWrapperComponent
46
+ export const DataTable = DataTableComponent
42
47
  export const Group = GroupComponent
43
48
  export const Icon = IconComponent
44
49
  export const Input = InputComponent
45
50
  export const List = ListComponent
46
51
  export const Menu = MenuComponent
47
52
  export const Modal = ModalComponent
53
+ export const Pagination = PaginationComponent
48
54
  export const Popover = PopoverComponent
49
55
  export const Progress = ProgressComponent
50
56
  export const Radio = RadioComponent