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.
- package/README.md +14 -6
- package/astro.d.ts +9 -0
- package/astro.js +6 -0
- package/components/Accordion/Accordion.astro +1 -0
- package/components/Accordion/Accordion.svelte +1 -1
- package/components/Accordion/Accordion.tsx +1 -1
- package/components/Accordion/accordion.ts +1 -0
- package/components/Avatar/Avatar.astro +4 -2
- package/components/Avatar/Avatar.svelte +6 -4
- package/components/Avatar/Avatar.tsx +4 -2
- package/components/Badge/Badge.astro +2 -0
- package/components/Badge/Badge.svelte +2 -0
- package/components/Badge/Badge.tsx +2 -0
- package/components/Badge/badge.module.scss +26 -0
- package/components/Badge/badge.ts +1 -0
- package/components/Checkbox/Checkbox.svelte +2 -0
- package/components/Checkbox/Checkbox.tsx +0 -2
- package/components/Checkbox/checkbox.ts +3 -1
- package/components/Collapsible/collapsible.ts +1 -1
- package/components/Counter/Counter.astro +164 -0
- package/components/Counter/Counter.svelte +141 -0
- package/components/Counter/Counter.tsx +161 -0
- package/components/Counter/counter.module.scss +155 -0
- package/components/Counter/counter.ts +21 -0
- package/components/DataTable/DataTable.astro +4 -4
- package/components/DataTable/DataTable.svelte +1 -1
- package/components/DataTable/DataTable.tsx +2 -2
- package/components/Icon/map.ts +2 -0
- package/components/Image/Image.astro +45 -0
- package/components/Image/Image.svelte +51 -0
- package/components/Image/Image.tsx +52 -0
- package/components/Image/image.module.scss +47 -0
- package/components/Image/image.ts +13 -0
- package/components/ImageLoader/ImageLoader.astro +82 -0
- package/components/ImageLoader/ImageLoader.svelte +72 -0
- package/components/ImageLoader/ImageLoader.tsx +82 -0
- package/components/ImageLoader/imageloader.module.scss +13 -0
- package/components/ImageLoader/imageloader.ts +6 -0
- package/components/Input/input.ts +2 -2
- package/components/List/List.astro +3 -0
- package/components/List/List.svelte +12 -9
- package/components/List/List.tsx +3 -0
- package/components/List/list.module.scss +5 -0
- package/components/List/list.ts +40 -39
- package/components/Menu/Menu.tsx +1 -1
- package/components/Pagination/Pagination.tsx +1 -1
- package/components/Pagination/pagination.module.scss +1 -0
- package/components/Popover/Popover.astro +28 -26
- package/components/Popover/Popover.svelte +2 -0
- package/components/Popover/Popover.tsx +2 -0
- package/components/Popover/popover.module.scss +10 -2
- package/components/Popover/popover.ts +17 -16
- package/components/Progress/Progress.astro +6 -2
- package/components/Progress/Progress.svelte +6 -2
- package/components/Progress/Progress.tsx +6 -2
- package/components/Progress/progress.module.scss +15 -0
- package/components/Progress/progress.ts +1 -0
- package/components/RangeSlider/RangeSlider.astro +5 -0
- package/components/RangeSlider/RangeSlider.svelte +3 -3
- package/components/RangeSlider/RangeSlider.tsx +1 -1
- package/components/RangeSlider/rangeslider.ts +1 -0
- package/components/Switch/Switch.svelte +2 -0
- package/components/Switch/Switch.tsx +0 -2
- package/components/Switch/switch.module.scss +1 -0
- package/components/Switch/switch.ts +3 -1
- package/components/Textarea/Textarea.svelte +2 -0
- package/components/Textarea/textarea.ts +7 -6
- package/components/ThemeSwitcher/themeswitcher.module.scss +1 -0
- package/components/ThemeSwitcher/themeswitcher.ts +1 -0
- package/icons/minus.svg +3 -0
- package/icons.d.ts +1 -0
- package/icons.js +1 -0
- package/index.d.ts +12 -5
- package/package.json +111 -109
- package/react.d.ts +9 -0
- package/react.js +6 -0
- package/scss/resets.scss +2 -0
- package/svelte.d.ts +9 -0
- package/svelte.js +6 -0
- package/utils/DOMUtils.ts +3 -3
- package/utils/modal.ts +2 -2
- 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
|
-
|
|
18
|
-
@include
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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: ${
|
|
41
|
-
{label && `${
|
|
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: ${
|
|
42
|
+
<div class={styles.progress} style={`--w-progress-width: ${currentValue}%;`}>
|
|
39
43
|
{#if label}
|
|
40
|
-
{`${
|
|
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': `${
|
|
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 && `${
|
|
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
|
+
}
|
|
@@ -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 @@
|
|
|
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>
|
|
@@ -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
|
|
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
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
-
|
|
22
|
+
onInput?: (event: React.InputEvent<HTMLTextAreaElement>) => void
|
|
23
|
+
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void
|
|
24
|
+
onKeyUp?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void
|
|
24
25
|
} & TextareaProps
|
package/icons/minus.svg
ADDED
package/icons.d.ts
CHANGED
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
|
|
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:
|
|
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
|