webcoreui 1.2.0 → 1.4.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 (82) hide show
  1. package/README.md +14 -6
  2. package/astro.d.ts +9 -0
  3. package/astro.js +6 -0
  4. package/components/Accordion/Accordion.astro +1 -0
  5. package/components/Accordion/Accordion.svelte +1 -1
  6. package/components/Accordion/Accordion.tsx +1 -1
  7. package/components/Accordion/accordion.ts +1 -0
  8. package/components/Avatar/Avatar.astro +4 -2
  9. package/components/Avatar/Avatar.svelte +6 -4
  10. package/components/Avatar/Avatar.tsx +4 -2
  11. package/components/Badge/Badge.astro +2 -0
  12. package/components/Badge/Badge.svelte +2 -0
  13. package/components/Badge/Badge.tsx +2 -0
  14. package/components/Badge/badge.module.scss +26 -0
  15. package/components/Badge/badge.ts +1 -0
  16. package/components/Checkbox/Checkbox.svelte +2 -0
  17. package/components/Checkbox/Checkbox.tsx +0 -2
  18. package/components/Checkbox/checkbox.ts +3 -1
  19. package/components/Collapsible/collapsible.ts +1 -1
  20. package/components/Counter/Counter.astro +164 -0
  21. package/components/Counter/Counter.svelte +141 -0
  22. package/components/Counter/Counter.tsx +161 -0
  23. package/components/Counter/counter.module.scss +155 -0
  24. package/components/Counter/counter.ts +21 -0
  25. package/components/DataTable/DataTable.astro +4 -4
  26. package/components/DataTable/DataTable.svelte +1 -1
  27. package/components/DataTable/DataTable.tsx +2 -2
  28. package/components/Icon/map.ts +2 -0
  29. package/components/Image/Image.astro +45 -0
  30. package/components/Image/Image.svelte +51 -0
  31. package/components/Image/Image.tsx +52 -0
  32. package/components/Image/image.module.scss +47 -0
  33. package/components/Image/image.ts +13 -0
  34. package/components/ImageLoader/ImageLoader.astro +82 -0
  35. package/components/ImageLoader/ImageLoader.svelte +72 -0
  36. package/components/ImageLoader/ImageLoader.tsx +82 -0
  37. package/components/ImageLoader/imageloader.module.scss +13 -0
  38. package/components/ImageLoader/imageloader.ts +6 -0
  39. package/components/Input/input.ts +2 -2
  40. package/components/List/List.astro +3 -0
  41. package/components/List/List.svelte +12 -9
  42. package/components/List/List.tsx +3 -0
  43. package/components/List/list.module.scss +5 -0
  44. package/components/List/list.ts +40 -39
  45. package/components/Menu/Menu.tsx +1 -1
  46. package/components/Pagination/Pagination.tsx +1 -1
  47. package/components/Pagination/pagination.module.scss +1 -0
  48. package/components/Popover/Popover.astro +28 -26
  49. package/components/Popover/Popover.svelte +2 -0
  50. package/components/Popover/Popover.tsx +2 -0
  51. package/components/Popover/popover.module.scss +10 -2
  52. package/components/Popover/popover.ts +17 -16
  53. package/components/Progress/Progress.astro +6 -2
  54. package/components/Progress/Progress.svelte +6 -2
  55. package/components/Progress/Progress.tsx +6 -2
  56. package/components/Progress/progress.module.scss +15 -0
  57. package/components/Progress/progress.ts +1 -0
  58. package/components/RangeSlider/RangeSlider.astro +5 -0
  59. package/components/RangeSlider/RangeSlider.svelte +3 -3
  60. package/components/RangeSlider/RangeSlider.tsx +1 -1
  61. package/components/RangeSlider/rangeslider.ts +1 -0
  62. package/components/Switch/Switch.svelte +2 -0
  63. package/components/Switch/Switch.tsx +0 -2
  64. package/components/Switch/switch.module.scss +1 -0
  65. package/components/Switch/switch.ts +3 -1
  66. package/components/Textarea/Textarea.svelte +2 -0
  67. package/components/Textarea/textarea.ts +7 -6
  68. package/components/ThemeSwitcher/themeswitcher.module.scss +1 -0
  69. package/components/ThemeSwitcher/themeswitcher.ts +1 -0
  70. package/icons/minus.svg +3 -0
  71. package/icons.d.ts +1 -0
  72. package/icons.js +1 -0
  73. package/index.d.ts +12 -5
  74. package/package.json +111 -109
  75. package/react.d.ts +9 -0
  76. package/react.js +6 -0
  77. package/scss/resets.scss +2 -0
  78. package/svelte.d.ts +9 -0
  79. package/svelte.js +6 -0
  80. package/utils/DOMUtils.ts +3 -3
  81. package/utils/modal.ts +2 -2
  82. package/utils/popover.ts +87 -46
@@ -9,6 +9,7 @@ import styles from './popover.module.scss'
9
9
  const Popover = ({
10
10
  id,
11
11
  className,
12
+ transparent,
12
13
  isInteractive = false,
13
14
  children,
14
15
  ...rest
@@ -17,6 +18,7 @@ const Popover = ({
17
18
 
18
19
  const classes = classNames([
19
20
  styles.popover,
21
+ transparent && styles.transparent,
20
22
  className
21
23
  ])
22
24
 
@@ -10,12 +10,20 @@
10
10
  @include border-radius(md);
11
11
  @include size(w300px);
12
12
  @include position('t-100%');
13
+ @include transition();
13
14
 
14
15
  transform: translateY(-5px);
15
16
  pointer-events: none;
17
+ will-change: transform, opacity;
16
18
 
17
- &[data-show] {
18
- @include transition();
19
+ &.transparent {
20
+ @include spacing(p0);
21
+ @include background(transparent);
22
+ @include border(0);
23
+ }
24
+
25
+ &[data-no-transition] {
26
+ @include transition(none);
19
27
  }
20
28
 
21
29
  &[data-show="true"] {
@@ -1,16 +1,17 @@
1
- import type { Snippet } from 'svelte'
2
-
3
- export type PopoverProps = {
4
- id?: string
5
- className?: string
6
- [key: string]: any
7
- }
8
-
9
- export type SveltePopoverProps = {
10
- children: Snippet
11
- } & PopoverProps
12
-
13
- export type ReactPopoverProps = {
14
- isInteractive?: boolean
15
- children?: React.ReactNode
16
- } & PopoverProps
1
+ import type { Snippet } from 'svelte'
2
+
3
+ export type PopoverProps = {
4
+ id?: string
5
+ className?: string
6
+ transparent?: boolean
7
+ [key: string]: any
8
+ }
9
+
10
+ export type SveltePopoverProps = {
11
+ children: Snippet
12
+ } & PopoverProps
13
+
14
+ export type ReactPopoverProps = {
15
+ isInteractive?: boolean
16
+ children?: React.ReactNode
17
+ } & PopoverProps
@@ -17,6 +17,7 @@ const {
17
17
  striped,
18
18
  stripeLight,
19
19
  stripeDark,
20
+ indeterminate,
20
21
  className
21
22
  } = Astro.props
22
23
 
@@ -25,6 +26,7 @@ const classes = [
25
26
  size && styles[size],
26
27
  striped && styles.striped,
27
28
  square && styles.square,
29
+ indeterminate && styles.indeterminate,
28
30
  className
29
31
  ]
30
32
 
@@ -34,10 +36,12 @@ const styleVariables = classNames([
34
36
  stripeLight && `--w-progress-stripe-light: ${stripeLight};`,
35
37
  stripeDark && `--w-progress-stripe-dark: ${stripeDark};`
36
38
  ])
39
+
40
+ const currentValue = indeterminate && !value ? 20 : value
37
41
  ---
38
42
 
39
43
  <div class:list={classes} style={styleVariables}>
40
- <div class={styles.progress} style={`--w-progress-width: ${value}%;`}>
41
- {label && `${value}%`}
44
+ <div class={styles.progress} style={`--w-progress-width: ${currentValue}%;`}>
45
+ {label && `${currentValue}%`}
42
46
  </div>
43
47
  </div>
@@ -15,6 +15,7 @@
15
15
  striped,
16
16
  stripeLight,
17
17
  stripeDark,
18
+ indeterminate,
18
19
  className
19
20
  }: ProgressProps = $props()
20
21
 
@@ -23,6 +24,7 @@
23
24
  size && styles[size],
24
25
  striped && styles.striped,
25
26
  square && styles.square,
27
+ indeterminate && styles.indeterminate,
26
28
  className
27
29
  ])
28
30
 
@@ -32,12 +34,14 @@
32
34
  stripeLight && `--w-progress-stripe-light: ${stripeLight};`,
33
35
  stripeDark && `--w-progress-stripe-dark: ${stripeDark};`
34
36
  ])
37
+
38
+ const currentValue = indeterminate && !value ? 20 : value
35
39
  </script>
36
40
 
37
41
  <div class={classes} style={styleVariables || null}>
38
- <div class={styles.progress} style={`--w-progress-width: ${value}%;`}>
42
+ <div class={styles.progress} style={`--w-progress-width: ${currentValue}%;`}>
39
43
  {#if label}
40
- {`${value}%`}
44
+ {`${currentValue}%`}
41
45
  {/if}
42
46
  </div>
43
47
  </div>
@@ -15,6 +15,7 @@ const Progress = ({
15
15
  striped,
16
16
  stripeLight,
17
17
  stripeDark,
18
+ indeterminate,
18
19
  className
19
20
  }: ProgressProps) => {
20
21
  const classes = classNames([
@@ -22,6 +23,7 @@ const Progress = ({
22
23
  size && styles[size],
23
24
  striped && styles.striped,
24
25
  square && styles.square,
26
+ indeterminate && styles.indeterminate,
25
27
  className
26
28
  ])
27
29
 
@@ -32,14 +34,16 @@ const Progress = ({
32
34
  ...(stripeDark && { '--w-progress-stripe-dark': stripeDark })
33
35
  } as React.CSSProperties
34
36
 
37
+ const currentValue = indeterminate && !value ? 20 : value
38
+
35
39
  const percent = {
36
- '--w-progress-width': `${value}%`
40
+ '--w-progress-width': `${currentValue}%`
37
41
  } as React.CSSProperties
38
42
 
39
43
  return (
40
44
  <div className={classes} style={styleVariables}>
41
45
  <div className={styles.progress} style={percent}>
42
- {label && `${value}%`}
46
+ {label && `${currentValue}%`}
43
47
  </div>
44
48
  </div>
45
49
  )
@@ -58,6 +58,12 @@ body {
58
58
  }
59
59
  }
60
60
 
61
+ &.indeterminate .progress {
62
+ @include position(relative);
63
+
64
+ animation: load 1s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
65
+ }
66
+
61
67
  .progress {
62
68
  @include transition(width);
63
69
  @include size('h100%');
@@ -68,3 +74,12 @@ body {
68
74
  width: var(--w-progress-width);
69
75
  }
70
76
  }
77
+
78
+ @keyframes load {
79
+ from {
80
+ left: -100%;
81
+ }
82
+ to {
83
+ left: 100%;
84
+ }
85
+ }
@@ -8,5 +8,6 @@ export type ProgressProps = {
8
8
  striped?: boolean
9
9
  stripeLight?: string
10
10
  stripeDark?: string
11
+ indeterminate?: boolean
11
12
  className?: string
12
13
  }
@@ -22,6 +22,7 @@ const {
22
22
  color,
23
23
  background,
24
24
  thumb,
25
+ name,
25
26
  label,
26
27
  subText,
27
28
  minLabel,
@@ -84,6 +85,7 @@ const labelStyle = updateLabels ? `min-width:${minLabelWidth};` : null
84
85
  />
85
86
  <input
86
87
  type="range"
88
+ name={name}
87
89
  class:list={[styles.input, styles.min]}
88
90
  min={min}
89
91
  max={max}
@@ -94,6 +96,7 @@ const labelStyle = updateLabels ? `min-width:${minLabelWidth};` : null
94
96
  />
95
97
  <input
96
98
  type="range"
99
+ name={name}
97
100
  min={min}
98
101
  max={max}
99
102
  class={styles.input}
@@ -189,6 +192,7 @@ const labelStyle = updateLabels ? `min-width:${minLabelWidth};` : null
189
192
  }
190
193
 
191
194
  dispatch('rangeSliderOnChange', {
195
+ name: target.name,
192
196
  min: minValue,
193
197
  max: maxValue
194
198
  })
@@ -257,6 +261,7 @@ const labelStyle = updateLabels ? `min-width:${minLabelWidth};` : null
257
261
  }
258
262
 
259
263
  dispatch('rangeSliderOnChange', {
264
+ name: minInput.name,
260
265
  min: minValue,
261
266
  max: maxValue
262
267
  })
@@ -173,12 +173,12 @@
173
173
  condition={!!interactiveLabels}
174
174
  onclick={(e: Event) => handleClick(e, 'right')}
175
175
  >
176
- {#if maxIcon}
177
- {@html maxIcon}
178
- {/if}
179
176
  {#if dynamicMaxLabel}
180
177
  <span style={labelStyle}>{dynamicMaxLabel}</span>
181
178
  {/if}
179
+ {#if maxIcon}
180
+ {@html maxIcon}
181
+ {/if}
182
182
  </ConditionalWrapper>
183
183
  </div>
184
184
 
@@ -187,13 +187,13 @@ const RangeSlider = ({
187
187
  <button onClick={(e: React.MouseEvent) => handleClick(e, 'right')}>{children}</button>
188
188
  )}
189
189
  >
190
+ {dynamicMaxLabel && <span style={labelStyle}>{dynamicMaxLabel}</span>}
190
191
  {maxIcon && (
191
192
  <span
192
193
  dangerouslySetInnerHTML={{ __html: maxIcon }}
193
194
  style={{ height: 18 }}
194
195
  />
195
196
  )}
196
- {dynamicMaxLabel && <span style={labelStyle}>{dynamicMaxLabel}</span>}
197
197
  </ConditionalWrapper>
198
198
  </div>
199
199
 
@@ -16,6 +16,7 @@ export type RangeSliderProps = {
16
16
  color?: string
17
17
  background?: string
18
18
  thumb?: string
19
+ name?: string
19
20
  label?: string
20
21
  subText?: string
21
22
  minLabel?: string
@@ -16,6 +16,7 @@
16
16
  disabled,
17
17
  className,
18
18
  onClick,
19
+ onChange,
19
20
  ...rest
20
21
  }: SvelteSwitchProps = $props()
21
22
 
@@ -40,6 +41,7 @@
40
41
  checked={toggled}
41
42
  disabled={disabled}
42
43
  onclick={onClick}
44
+ onchange={onChange}
43
45
  {...rest}
44
46
  />
45
47
  <span class={styles.toggle}></span>
@@ -15,7 +15,6 @@ const Switch = ({
15
15
  square,
16
16
  disabled,
17
17
  className,
18
- onClick,
19
18
  ...rest
20
19
  }: ReactSwitchProps) => {
21
20
  const classes = classNames([
@@ -38,7 +37,6 @@ const Switch = ({
38
37
  type="checkbox"
39
38
  defaultChecked={toggled}
40
39
  disabled={disabled}
41
- onClick={onClick}
42
40
  {...rest}
43
41
  />
44
42
  <span className={styles.toggle}></span>
@@ -8,6 +8,7 @@ body {
8
8
  .switch {
9
9
  @include layout(inline-flex, v-center, sm);
10
10
  cursor: pointer;
11
+ user-select: none;
11
12
 
12
13
  &.reverse {
13
14
  @include layout(row-reverse);
@@ -1,4 +1,4 @@
1
- import type { MouseEventHandler } from 'svelte/elements'
1
+ import type { ChangeEventHandler, MouseEventHandler } from 'svelte/elements'
2
2
 
3
3
  export type SwitchProps = {
4
4
  label?: string
@@ -14,9 +14,11 @@ export type SwitchProps = {
14
14
  }
15
15
 
16
16
  export type SvelteSwitchProps = {
17
+ onChange?: ChangeEventHandler<HTMLInputElement>
17
18
  onClick?: MouseEventHandler<HTMLInputElement>
18
19
  } & SwitchProps
19
20
 
20
21
  export type ReactSwitchProps = {
22
+ onChange?: React.ChangeEventHandler<HTMLInputElement>
21
23
  onClick?: React.MouseEventHandler<HTMLInputElement>
22
24
  } & SwitchProps
@@ -16,6 +16,7 @@
16
16
  className,
17
17
  onChange,
18
18
  onKeyUp,
19
+ onInput,
19
20
  ...rest
20
21
  }: SvelteTextareaProps = $props()
21
22
 
@@ -39,6 +40,7 @@
39
40
  placeholder={placeholder}
40
41
  disabled={disabled}
41
42
  class={classes}
43
+ oninput={onInput}
42
44
  onchange={onChange}
43
45
  onkeyup={onKeyUp}
44
46
  {...rest}
@@ -1,5 +1,4 @@
1
- type Target = {
2
- target: HTMLTextAreaElement
1
+ export type TextareaTarget = {
3
2
  currentTarget: HTMLTextAreaElement
4
3
  }
5
4
 
@@ -14,11 +13,13 @@ export type TextareaProps = {
14
13
  }
15
14
 
16
15
  export type SvelteTextareaProps = {
17
- onChange?: (event: Event & Target) => void
18
- onKeyUp?: (event: KeyboardEvent & Target) => void
16
+ onInput?: (event: Event & TextareaTarget) => void
17
+ onChange?: (event: Event & TextareaTarget) => void
18
+ onKeyUp?: (event: KeyboardEvent & TextareaTarget) => void
19
19
  } & TextareaProps
20
20
 
21
21
  export type ReactTextareaProps = {
22
- onChange?: (event: React.ChangeEvent<HTMLTextAreaElement> & Target) => void
23
- onKeyUp?: (event: React.KeyboardEvent<HTMLTextAreaElement> & Target) => void
22
+ onInput?: (event: React.InputEvent<HTMLTextAreaElement>) => void
23
+ onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void
24
+ onKeyUp?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void
24
25
  } & TextareaProps
@@ -38,6 +38,7 @@ body {
38
38
  width: var(--w-theme-switcher-size);
39
39
  height: var(--w-theme-switcher-size);
40
40
  cursor: pointer;
41
+ user-select: none;
41
42
 
42
43
  &.icons {
43
44
  @include transition(opacity);
@@ -12,6 +12,7 @@ export type ThemeSwitcherProps = {
12
12
  export type SvelteThemeSwitcherProps = {
13
13
  primaryIcon?: Snippet
14
14
  secondaryIcon?: Snippet
15
+ children?: Snippet
15
16
  } & ThemeSwitcherProps
16
17
 
17
18
  export type ReactThemeSwitcherProps = {
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M6 12h12" />
3
+ </svg>
package/icons.d.ts CHANGED
@@ -12,6 +12,7 @@ declare module 'webcoreui/icons' {
12
12
  export const github: string
13
13
  export const home: string
14
14
  export const info: string
15
+ export const minus: string
15
16
  export const moon: string
16
17
  export const order: string
17
18
  export const plus: string
package/icons.js CHANGED
@@ -11,6 +11,7 @@ export { default as copy } from './icons/copy.svg?raw'
11
11
  export { default as github } from './icons/github.svg?raw'
12
12
  export { default as home } from './icons/home.svg?raw'
13
13
  export { default as info } from './icons/info.svg?raw'
14
+ export { default as minus } from './icons/minus.svg?raw'
14
15
  export { default as moon } from './icons/moon.svg?raw'
15
16
  export { default as order } from './icons/order.svg?raw'
16
17
  export { default as plus } from './icons/plus.svg?raw'
package/index.d.ts CHANGED
@@ -86,7 +86,7 @@ export type ModalCallback = {
86
86
  }
87
87
 
88
88
  export type Modal = {
89
- trigger: string
89
+ trigger?: string
90
90
  modal: string
91
91
  onOpen?: (args: ModalCallback) => unknown
92
92
  onClose?: (args: ModalCallback) => unknown
@@ -105,6 +105,12 @@ export type PopoverPosition = 'top'
105
105
  | 'bottom-start'
106
106
  | 'bottom-end'
107
107
 
108
+ export type PopoverInstance = {
109
+ close: () => void
110
+ destroy: () => void
111
+ remove: () => void
112
+ }
113
+
108
114
  export type PopoverCallback = {
109
115
  trigger: HTMLElement
110
116
  popover: HTMLElement
@@ -152,7 +158,10 @@ declare module 'webcoreui' {
152
158
  cancel: () => void
153
159
  }
154
160
 
155
- export const get: (selector: string, all?: boolean) => Element | NodeListOf<Element> | null
161
+ export const get: <T extends Element = Element>(
162
+ selector: string,
163
+ all?: boolean
164
+ ) => T | NodeListOf<T> | null
156
165
  export const on: (
157
166
  selector: string | HTMLElement | Document,
158
167
  event: string,
@@ -189,9 +198,7 @@ declare module 'webcoreui' {
189
198
  export const modal: (config: Modal | string) => ModalInstance | undefined
190
199
  export const closeModal: (modal: string) => void
191
200
 
192
- export const popover: (config: Popover) => {
193
- remove: () => void
194
- } | void
201
+ export const popover: (config: Popover) => PopoverInstance | undefined
195
202
  export const closePopover: (selector: string) => void
196
203
 
197
204
  export const setDefaultTimeout: (time: number) => number