@infonomic/uikit 5.4.0 → 5.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.
- package/dist/astro.d.ts +6 -0
- package/dist/astro.js +6 -0
- package/dist/components/forms/checkbox.astro +129 -0
- package/dist/components/forms/checkbox.js +1 -1
- package/dist/components/forms/text-area.astro +77 -0
- package/dist/icons/check-icon.astro +37 -0
- package/package.json +1 -1
- package/src/astro.js +6 -0
- package/src/components/forms/checkbox.astro +129 -0
- package/src/components/forms/checkbox.tsx +1 -1
- package/src/components/forms/text-area.astro +77 -0
- package/src/icons/check-icon.astro +37 -0
package/dist/astro.d.ts
CHANGED
|
@@ -7,14 +7,17 @@ import type CardHeaderComponent from './components/card/card-header.astro'
|
|
|
7
7
|
import type CardTitleComponent from './components/card/card-title.astro'
|
|
8
8
|
import type CardComponent from './components/card/card.astro'
|
|
9
9
|
import type ContainerComponent from './components/container/container.astro'
|
|
10
|
+
import type CheckboxComponent from './components/forms/checkbox.astro'
|
|
10
11
|
import type ErrorTextComponent from './components/forms/error-text.astro'
|
|
11
12
|
import type HelpTextComponent from './components/forms/help-text.astro'
|
|
12
13
|
import type InputAdornmentComponent from './components/forms/input-adornment.astro'
|
|
13
14
|
import type InputComponent from './components/forms/input.astro'
|
|
14
15
|
import type LabelComponent from './components/forms/label.astro'
|
|
16
|
+
import type TextAreaComponent from './components/forms/text-area.astro'
|
|
15
17
|
import type HamburgerComponent from './components/hamburger/hamburger.astro'
|
|
16
18
|
import type ScrollToTopComponent from './components/scroll-to-top/scroll-to-top.astro'
|
|
17
19
|
import type SectionComponent from './components/section/section.astro'
|
|
20
|
+
import type CheckIconComponent from './icons/check-icon.astro'
|
|
18
21
|
import type CloseIconComponent from './icons/close-icon.astro'
|
|
19
22
|
import type IconElementComponent from './icons/icon-element.astro'
|
|
20
23
|
import type LightIconComponent from './icons/light-icon.astro'
|
|
@@ -30,14 +33,17 @@ export declare const CardHeader: typeof CardHeaderComponent
|
|
|
30
33
|
export declare const CardTitle: typeof CardTitleComponent
|
|
31
34
|
export declare const Card: typeof CardComponent
|
|
32
35
|
export declare const Container: typeof ContainerComponent
|
|
36
|
+
export declare const Checkbox: typeof CheckboxComponent
|
|
33
37
|
export declare const ErrorText: typeof ErrorTextComponent
|
|
34
38
|
export declare const HelpText: typeof HelpTextComponent
|
|
35
39
|
export declare const InputAdornment: typeof InputAdornmentComponent
|
|
36
40
|
export declare const Input: typeof InputComponent
|
|
37
41
|
export declare const Label: typeof LabelComponent
|
|
42
|
+
export declare const TextArea: typeof TextAreaComponent
|
|
38
43
|
export declare const Hamburger: typeof HamburgerComponent
|
|
39
44
|
export declare const ScrollToTop: typeof ScrollToTopComponent
|
|
40
45
|
export declare const Section: typeof SectionComponent
|
|
46
|
+
export declare const CheckIcon: typeof CheckIconComponent
|
|
41
47
|
export declare const CloseIcon: typeof CloseIconComponent
|
|
42
48
|
export declare const IconElement: typeof IconElementComponent
|
|
43
49
|
export declare const LightIcon: typeof LightIconComponent
|
package/dist/astro.js
CHANGED
|
@@ -7,14 +7,17 @@ import CardHeaderComponent from './components/card/card-header.astro'
|
|
|
7
7
|
import CardTitleComponent from './components/card/card-title.astro'
|
|
8
8
|
import CardComponent from './components/card/card.astro'
|
|
9
9
|
import ContainerComponent from './components/container/container.astro'
|
|
10
|
+
import CheckboxComponent from './components/forms/checkbox.astro'
|
|
10
11
|
import ErrorTextComponent from './components/forms/error-text.astro'
|
|
11
12
|
import HelpTextComponent from './components/forms/help-text.astro'
|
|
12
13
|
import InputAdornmentComponent from './components/forms/input-adornment.astro'
|
|
13
14
|
import InputComponent from './components/forms/input.astro'
|
|
14
15
|
import LabelComponent from './components/forms/label.astro'
|
|
16
|
+
import TextAreaComponent from './components/forms/text-area.astro'
|
|
15
17
|
import HamburgerComponent from './components/hamburger/hamburger.astro'
|
|
16
18
|
import ScrollToTopComponent from './components/scroll-to-top/scroll-to-top.astro'
|
|
17
19
|
import SectionComponent from './components/section/section.astro'
|
|
20
|
+
import CheckIconComponent from './icons/check-icon.astro'
|
|
18
21
|
import CloseIconComponent from './icons/close-icon.astro'
|
|
19
22
|
import IconElementComponent from './icons/icon-element.astro'
|
|
20
23
|
import LightIconComponent from './icons/light-icon.astro'
|
|
@@ -30,14 +33,17 @@ export const CardHeader = CardHeaderComponent
|
|
|
30
33
|
export const CardTitle = CardTitleComponent
|
|
31
34
|
export const Card = CardComponent
|
|
32
35
|
export const Container = ContainerComponent
|
|
36
|
+
export const Checkbox = CheckboxComponent
|
|
33
37
|
export const ErrorText = ErrorTextComponent
|
|
34
38
|
export const HelpText = HelpTextComponent
|
|
35
39
|
export const InputAdornment = InputAdornmentComponent
|
|
36
40
|
export const Input = InputComponent
|
|
37
41
|
export const Label = LabelComponent
|
|
42
|
+
export const TextArea = TextAreaComponent
|
|
38
43
|
export const Hamburger = HamburgerComponent
|
|
39
44
|
export const ScrollToTop = ScrollToTopComponent
|
|
40
45
|
export const Section = SectionComponent
|
|
46
|
+
export const CheckIcon = CheckIconComponent
|
|
41
47
|
export const CloseIcon = CloseIconComponent
|
|
42
48
|
export const IconElement = IconElementComponent
|
|
43
49
|
export const LightIcon = LightIconComponent
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
import type { Intent, Size, Variant } from './@types/checkbox.js'
|
|
4
|
+
import CheckIcon from '../../icons/check-icon.astro'
|
|
5
|
+
import ErrorText from './error-text.astro'
|
|
6
|
+
import HelpText from './help-text.astro'
|
|
7
|
+
import styles from './checkbox.module.css'
|
|
8
|
+
|
|
9
|
+
interface Props extends HTMLAttributes<'input'> {
|
|
10
|
+
id: string
|
|
11
|
+
name: string
|
|
12
|
+
label: string
|
|
13
|
+
variant?: Variant
|
|
14
|
+
size?: Size
|
|
15
|
+
intent?: Intent
|
|
16
|
+
reverse?: boolean
|
|
17
|
+
checked?: boolean
|
|
18
|
+
class?: string
|
|
19
|
+
checkBoxClasses?: string
|
|
20
|
+
containerClasses?: string
|
|
21
|
+
componentClasses?: string
|
|
22
|
+
labelClasses?: string
|
|
23
|
+
error?: boolean
|
|
24
|
+
helpText?: string
|
|
25
|
+
errorText?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
id,
|
|
30
|
+
name,
|
|
31
|
+
label,
|
|
32
|
+
variant = 'outlined',
|
|
33
|
+
size = 'md',
|
|
34
|
+
intent = 'primary',
|
|
35
|
+
reverse = false,
|
|
36
|
+
checked = false,
|
|
37
|
+
class: className,
|
|
38
|
+
checkBoxClasses,
|
|
39
|
+
containerClasses,
|
|
40
|
+
componentClasses,
|
|
41
|
+
labelClasses,
|
|
42
|
+
error = false,
|
|
43
|
+
helpText = '',
|
|
44
|
+
errorText = '',
|
|
45
|
+
...rest
|
|
46
|
+
} = Astro.props
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<div class:list={['checkbox-container', containerClasses]}>
|
|
50
|
+
<div
|
|
51
|
+
class:list={[
|
|
52
|
+
'checkbox-component',
|
|
53
|
+
styles.container,
|
|
54
|
+
componentClasses,
|
|
55
|
+
{ [styles.reverse]: reverse }
|
|
56
|
+
]}
|
|
57
|
+
>
|
|
58
|
+
<input type="checkbox" id={id} name={name} checked={checked} class="sr-only peer" {...rest} />
|
|
59
|
+
|
|
60
|
+
<label
|
|
61
|
+
for={id}
|
|
62
|
+
class:list={[
|
|
63
|
+
'checkbox',
|
|
64
|
+
variant,
|
|
65
|
+
size,
|
|
66
|
+
intent,
|
|
67
|
+
styles.checkbox,
|
|
68
|
+
styles[variant],
|
|
69
|
+
styles[size],
|
|
70
|
+
styles[intent],
|
|
71
|
+
checkBoxClasses,
|
|
72
|
+
className
|
|
73
|
+
]}
|
|
74
|
+
data-state={checked ? 'checked' : 'unchecked'}
|
|
75
|
+
>
|
|
76
|
+
<span
|
|
77
|
+
class:list={['checkbox-indicator', styles.indicator]}
|
|
78
|
+
data-state={checked ? 'checked' : 'unchecked'}
|
|
79
|
+
>
|
|
80
|
+
<CheckIcon class={styles.icon} />
|
|
81
|
+
</span>
|
|
82
|
+
</label>
|
|
83
|
+
|
|
84
|
+
<label for={id} class:list={[styles.label, labelClasses]}>
|
|
85
|
+
{label}
|
|
86
|
+
</label>
|
|
87
|
+
</div>
|
|
88
|
+
{
|
|
89
|
+
error ? (
|
|
90
|
+
<ErrorText id={`error-for-${id}`} text={errorText ?? helpText} />
|
|
91
|
+
) : (
|
|
92
|
+
helpText?.length > 0 && <HelpText text={helpText} />
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<script>
|
|
98
|
+
function setupCheckboxes() {
|
|
99
|
+
const inputs = document.querySelectorAll('input[type="checkbox"].peer')
|
|
100
|
+
|
|
101
|
+
inputs.forEach((input) => {
|
|
102
|
+
const checkboxInput = input as HTMLInputElement
|
|
103
|
+
const id = checkboxInput.id
|
|
104
|
+
// Find the visual checkbox label associated with this input
|
|
105
|
+
const visualCheckbox = document.querySelector(`label.checkbox[for="${id}"]`)
|
|
106
|
+
const indicator = visualCheckbox?.querySelector('.checkbox-indicator')
|
|
107
|
+
|
|
108
|
+
if (visualCheckbox && indicator) {
|
|
109
|
+
// Update state on change
|
|
110
|
+
checkboxInput.addEventListener('change', () => {
|
|
111
|
+
const state = checkboxInput.checked ? 'checked' : 'unchecked'
|
|
112
|
+
visualCheckbox.setAttribute('data-state', state)
|
|
113
|
+
indicator.setAttribute('data-state', state)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// Ensure initial state is correct
|
|
117
|
+
const state = checkboxInput.checked ? 'checked' : 'unchecked'
|
|
118
|
+
visualCheckbox.setAttribute('data-state', state)
|
|
119
|
+
indicator.setAttribute('data-state', state)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Run on initial load
|
|
125
|
+
setupCheckboxes()
|
|
126
|
+
|
|
127
|
+
// Support Astro View Transitions
|
|
128
|
+
document.addEventListener('astro:page-load', setupCheckboxes)
|
|
129
|
+
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { CheckIcon } from "
|
|
3
|
+
import { CheckIcon } from "../../icons/check-icon.js";
|
|
4
4
|
import classnames from "classnames";
|
|
5
5
|
import { Checkbox as external_radix_ui_Checkbox, Label } from "radix-ui";
|
|
6
6
|
import checkbox_module from "./checkbox.module.js";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
import type { Intent, Variant } from './@types/input.js'
|
|
4
|
+
import ErrorText from './error-text.astro'
|
|
5
|
+
import HelpText from './help-text.astro'
|
|
6
|
+
import inputStyles from './input.module.css'
|
|
7
|
+
import Label from './label.astro'
|
|
8
|
+
import styles from './text-area.module.css'
|
|
9
|
+
|
|
10
|
+
interface Props extends HTMLAttributes<'textarea'> {
|
|
11
|
+
id: string
|
|
12
|
+
name: string
|
|
13
|
+
label: string
|
|
14
|
+
required?: boolean
|
|
15
|
+
variant?: Variant
|
|
16
|
+
intent?: Intent
|
|
17
|
+
rows?: number
|
|
18
|
+
placeHolder?: string
|
|
19
|
+
autoComplete?: string
|
|
20
|
+
error?: boolean
|
|
21
|
+
helpText?: string
|
|
22
|
+
errorText?: string
|
|
23
|
+
class?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
label,
|
|
30
|
+
rows = 4,
|
|
31
|
+
required = false,
|
|
32
|
+
variant = 'outlined',
|
|
33
|
+
intent = 'primary',
|
|
34
|
+
placeHolder = '',
|
|
35
|
+
autoComplete = 'off',
|
|
36
|
+
error = false,
|
|
37
|
+
helpText = '',
|
|
38
|
+
errorText = '',
|
|
39
|
+
class: className,
|
|
40
|
+
...rest
|
|
41
|
+
} = Astro.props as Props
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
<fieldset class:list={['text-area-wrapper', inputStyles['input-wrapper']]}>
|
|
45
|
+
<Label id={id} for={id} required={required} label={label} />
|
|
46
|
+
<textarea
|
|
47
|
+
id={id}
|
|
48
|
+
name={name}
|
|
49
|
+
required={required}
|
|
50
|
+
rows={rows}
|
|
51
|
+
auto-complete={autoComplete}
|
|
52
|
+
placeholder={placeHolder}
|
|
53
|
+
aria-labelledby={`label-for-${id}`}
|
|
54
|
+
aria-invalid={error}
|
|
55
|
+
aria-required={required}
|
|
56
|
+
aria-errormessage={errorText}
|
|
57
|
+
aria-describedby={error ? `error-for-${id}` : undefined}
|
|
58
|
+
class:list={[
|
|
59
|
+
'text-area',
|
|
60
|
+
variant,
|
|
61
|
+
intent,
|
|
62
|
+
inputStyles.input,
|
|
63
|
+
inputStyles[variant],
|
|
64
|
+
inputStyles[intent],
|
|
65
|
+
styles['text-area'],
|
|
66
|
+
error && inputStyles.error,
|
|
67
|
+
className
|
|
68
|
+
]}
|
|
69
|
+
{...rest}></textarea>
|
|
70
|
+
{
|
|
71
|
+
error ? (
|
|
72
|
+
<ErrorText id={`error-for-${id}`} text={errorText ?? helpText} />
|
|
73
|
+
) : (
|
|
74
|
+
helpText?.length > 0 && <HelpText text={helpText} />
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
</fieldset>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
|
|
4
|
+
interface Props extends HTMLAttributes<'div'> {
|
|
5
|
+
class?: string
|
|
6
|
+
width?: string
|
|
7
|
+
height?: string
|
|
8
|
+
menuItem?: boolean
|
|
9
|
+
svgClass?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
import IconElement from './icon-element.astro'
|
|
13
|
+
import styles from './icons.module.css'
|
|
14
|
+
|
|
15
|
+
const { class: className, width, height, svgClass: svgClassName, menuItem, ...rest } = Astro.props
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<IconElement
|
|
19
|
+
class:list={['check-icon', className]}
|
|
20
|
+
width={width}
|
|
21
|
+
height={height}
|
|
22
|
+
menuItem={menuItem}
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
<svg
|
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
viewBox="0 0 15 15"
|
|
28
|
+
class:list={[styles['fill-current'], svgClassName]}
|
|
29
|
+
focusable="false"
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
>
|
|
32
|
+
<path
|
|
33
|
+
d="M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z"
|
|
34
|
+
fill-rule="evenodd"
|
|
35
|
+
clip-rule="evenodd"></path>
|
|
36
|
+
</svg>
|
|
37
|
+
</IconElement>
|
package/package.json
CHANGED
package/src/astro.js
CHANGED
|
@@ -8,13 +8,16 @@ import CardHeaderComponent from './components/card/card-header.astro'
|
|
|
8
8
|
import CardTitleComponent from './components/card/card-title.astro'
|
|
9
9
|
import ContainerComponent from './components/container/container.astro'
|
|
10
10
|
import HamburgerComponent from './components/hamburger/hamburger.astro'
|
|
11
|
+
import CheckboxComponent from './components/forms/checkbox.astro'
|
|
11
12
|
import ErrorTextComponent from './components/forms/error-text.astro'
|
|
12
13
|
import HelpTextComponent from './components/forms/help-text.astro'
|
|
13
14
|
import InputComponent from './components/forms/input.astro'
|
|
14
15
|
import InputAdornmentComponent from './components/forms/input-adornment.astro'
|
|
15
16
|
import LabelComponent from './components/forms/label.astro'
|
|
17
|
+
import TextAreaComponent from './components/forms/text-area.astro'
|
|
16
18
|
import SectionComponent from './components/section/section.astro'
|
|
17
19
|
import ScrollToTopComponent from './components/scroll-to-top/scroll-to-top.astro'
|
|
20
|
+
import CheckIconComponent from './icons/check-icon.astro'
|
|
18
21
|
import CloseIconComponent from './icons/close-icon.astro'
|
|
19
22
|
import IconElementComponent from './icons/icon-element.astro'
|
|
20
23
|
import LightIconComponent from './icons/light-icon.astro'
|
|
@@ -32,15 +35,18 @@ export const CardHeader = CardHeaderComponent
|
|
|
32
35
|
export const CardTitle = CardTitleComponent
|
|
33
36
|
export const Card = CardComponent
|
|
34
37
|
export const Container = ContainerComponent
|
|
38
|
+
export const Checkbox = CheckboxComponent
|
|
35
39
|
export const ErrorText = ErrorTextComponent
|
|
36
40
|
export const HelpText = HelpTextComponent
|
|
37
41
|
export const InputAdornment = InputAdornmentComponent
|
|
38
42
|
export const Input = InputComponent
|
|
39
43
|
export const Label = LabelComponent
|
|
44
|
+
export const TextArea = TextAreaComponent
|
|
40
45
|
export const Section = SectionComponent
|
|
41
46
|
export const ScrollToTop = ScrollToTopComponent
|
|
42
47
|
export const IconElement = IconElementComponent
|
|
43
48
|
export const LightIcon = LightIconComponent
|
|
44
49
|
export const MoonIcon = MoonIconComponent
|
|
45
50
|
export const SearchIcon = SearchIconComponent
|
|
51
|
+
export const CheckIcon = CheckIconComponent
|
|
46
52
|
export const CloseIcon = CloseIconComponent
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
import type { Intent, Size, Variant } from './@types/checkbox.js'
|
|
4
|
+
import CheckIcon from '../../icons/check-icon.astro'
|
|
5
|
+
import ErrorText from './error-text.astro'
|
|
6
|
+
import HelpText from './help-text.astro'
|
|
7
|
+
import styles from './checkbox.module.css'
|
|
8
|
+
|
|
9
|
+
interface Props extends HTMLAttributes<'input'> {
|
|
10
|
+
id: string
|
|
11
|
+
name: string
|
|
12
|
+
label: string
|
|
13
|
+
variant?: Variant
|
|
14
|
+
size?: Size
|
|
15
|
+
intent?: Intent
|
|
16
|
+
reverse?: boolean
|
|
17
|
+
checked?: boolean
|
|
18
|
+
class?: string
|
|
19
|
+
checkBoxClasses?: string
|
|
20
|
+
containerClasses?: string
|
|
21
|
+
componentClasses?: string
|
|
22
|
+
labelClasses?: string
|
|
23
|
+
error?: boolean
|
|
24
|
+
helpText?: string
|
|
25
|
+
errorText?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
id,
|
|
30
|
+
name,
|
|
31
|
+
label,
|
|
32
|
+
variant = 'outlined',
|
|
33
|
+
size = 'md',
|
|
34
|
+
intent = 'primary',
|
|
35
|
+
reverse = false,
|
|
36
|
+
checked = false,
|
|
37
|
+
class: className,
|
|
38
|
+
checkBoxClasses,
|
|
39
|
+
containerClasses,
|
|
40
|
+
componentClasses,
|
|
41
|
+
labelClasses,
|
|
42
|
+
error = false,
|
|
43
|
+
helpText = '',
|
|
44
|
+
errorText = '',
|
|
45
|
+
...rest
|
|
46
|
+
} = Astro.props
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<div class:list={['checkbox-container', containerClasses]}>
|
|
50
|
+
<div
|
|
51
|
+
class:list={[
|
|
52
|
+
'checkbox-component',
|
|
53
|
+
styles.container,
|
|
54
|
+
componentClasses,
|
|
55
|
+
{ [styles.reverse]: reverse }
|
|
56
|
+
]}
|
|
57
|
+
>
|
|
58
|
+
<input type="checkbox" id={id} name={name} checked={checked} class="sr-only peer" {...rest} />
|
|
59
|
+
|
|
60
|
+
<label
|
|
61
|
+
for={id}
|
|
62
|
+
class:list={[
|
|
63
|
+
'checkbox',
|
|
64
|
+
variant,
|
|
65
|
+
size,
|
|
66
|
+
intent,
|
|
67
|
+
styles.checkbox,
|
|
68
|
+
styles[variant],
|
|
69
|
+
styles[size],
|
|
70
|
+
styles[intent],
|
|
71
|
+
checkBoxClasses,
|
|
72
|
+
className
|
|
73
|
+
]}
|
|
74
|
+
data-state={checked ? 'checked' : 'unchecked'}
|
|
75
|
+
>
|
|
76
|
+
<span
|
|
77
|
+
class:list={['checkbox-indicator', styles.indicator]}
|
|
78
|
+
data-state={checked ? 'checked' : 'unchecked'}
|
|
79
|
+
>
|
|
80
|
+
<CheckIcon class={styles.icon} />
|
|
81
|
+
</span>
|
|
82
|
+
</label>
|
|
83
|
+
|
|
84
|
+
<label for={id} class:list={[styles.label, labelClasses]}>
|
|
85
|
+
{label}
|
|
86
|
+
</label>
|
|
87
|
+
</div>
|
|
88
|
+
{
|
|
89
|
+
error ? (
|
|
90
|
+
<ErrorText id={`error-for-${id}`} text={errorText ?? helpText} />
|
|
91
|
+
) : (
|
|
92
|
+
helpText?.length > 0 && <HelpText text={helpText} />
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<script>
|
|
98
|
+
function setupCheckboxes() {
|
|
99
|
+
const inputs = document.querySelectorAll('input[type="checkbox"].peer')
|
|
100
|
+
|
|
101
|
+
inputs.forEach((input) => {
|
|
102
|
+
const checkboxInput = input as HTMLInputElement
|
|
103
|
+
const id = checkboxInput.id
|
|
104
|
+
// Find the visual checkbox label associated with this input
|
|
105
|
+
const visualCheckbox = document.querySelector(`label.checkbox[for="${id}"]`)
|
|
106
|
+
const indicator = visualCheckbox?.querySelector('.checkbox-indicator')
|
|
107
|
+
|
|
108
|
+
if (visualCheckbox && indicator) {
|
|
109
|
+
// Update state on change
|
|
110
|
+
checkboxInput.addEventListener('change', () => {
|
|
111
|
+
const state = checkboxInput.checked ? 'checked' : 'unchecked'
|
|
112
|
+
visualCheckbox.setAttribute('data-state', state)
|
|
113
|
+
indicator.setAttribute('data-state', state)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// Ensure initial state is correct
|
|
117
|
+
const state = checkboxInput.checked ? 'checked' : 'unchecked'
|
|
118
|
+
visualCheckbox.setAttribute('data-state', state)
|
|
119
|
+
indicator.setAttribute('data-state', state)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Run on initial load
|
|
125
|
+
setupCheckboxes()
|
|
126
|
+
|
|
127
|
+
// Support Astro View Transitions
|
|
128
|
+
document.addEventListener('astro:page-load', setupCheckboxes)
|
|
129
|
+
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { CheckIcon } from '
|
|
3
|
+
import { CheckIcon } from '../../icons/check-icon'
|
|
4
4
|
import cx from 'classnames'
|
|
5
5
|
import { Checkbox as CheckboxPrimitive, Label as LabelPrimitive } from 'radix-ui'
|
|
6
6
|
import type * as React from 'react'
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
import type { Intent, Variant } from './@types/input.js'
|
|
4
|
+
import ErrorText from './error-text.astro'
|
|
5
|
+
import HelpText from './help-text.astro'
|
|
6
|
+
import inputStyles from './input.module.css'
|
|
7
|
+
import Label from './label.astro'
|
|
8
|
+
import styles from './text-area.module.css'
|
|
9
|
+
|
|
10
|
+
interface Props extends HTMLAttributes<'textarea'> {
|
|
11
|
+
id: string
|
|
12
|
+
name: string
|
|
13
|
+
label: string
|
|
14
|
+
required?: boolean
|
|
15
|
+
variant?: Variant
|
|
16
|
+
intent?: Intent
|
|
17
|
+
rows?: number
|
|
18
|
+
placeHolder?: string
|
|
19
|
+
autoComplete?: string
|
|
20
|
+
error?: boolean
|
|
21
|
+
helpText?: string
|
|
22
|
+
errorText?: string
|
|
23
|
+
class?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
label,
|
|
30
|
+
rows = 4,
|
|
31
|
+
required = false,
|
|
32
|
+
variant = 'outlined',
|
|
33
|
+
intent = 'primary',
|
|
34
|
+
placeHolder = '',
|
|
35
|
+
autoComplete = 'off',
|
|
36
|
+
error = false,
|
|
37
|
+
helpText = '',
|
|
38
|
+
errorText = '',
|
|
39
|
+
class: className,
|
|
40
|
+
...rest
|
|
41
|
+
} = Astro.props as Props
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
<fieldset class:list={['text-area-wrapper', inputStyles['input-wrapper']]}>
|
|
45
|
+
<Label id={id} for={id} required={required} label={label} />
|
|
46
|
+
<textarea
|
|
47
|
+
id={id}
|
|
48
|
+
name={name}
|
|
49
|
+
required={required}
|
|
50
|
+
rows={rows}
|
|
51
|
+
auto-complete={autoComplete}
|
|
52
|
+
placeholder={placeHolder}
|
|
53
|
+
aria-labelledby={`label-for-${id}`}
|
|
54
|
+
aria-invalid={error}
|
|
55
|
+
aria-required={required}
|
|
56
|
+
aria-errormessage={errorText}
|
|
57
|
+
aria-describedby={error ? `error-for-${id}` : undefined}
|
|
58
|
+
class:list={[
|
|
59
|
+
'text-area',
|
|
60
|
+
variant,
|
|
61
|
+
intent,
|
|
62
|
+
inputStyles.input,
|
|
63
|
+
inputStyles[variant],
|
|
64
|
+
inputStyles[intent],
|
|
65
|
+
styles['text-area'],
|
|
66
|
+
error && inputStyles.error,
|
|
67
|
+
className
|
|
68
|
+
]}
|
|
69
|
+
{...rest}></textarea>
|
|
70
|
+
{
|
|
71
|
+
error ? (
|
|
72
|
+
<ErrorText id={`error-for-${id}`} text={errorText ?? helpText} />
|
|
73
|
+
) : (
|
|
74
|
+
helpText?.length > 0 && <HelpText text={helpText} />
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
</fieldset>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
|
|
4
|
+
interface Props extends HTMLAttributes<'div'> {
|
|
5
|
+
class?: string
|
|
6
|
+
width?: string
|
|
7
|
+
height?: string
|
|
8
|
+
menuItem?: boolean
|
|
9
|
+
svgClass?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
import IconElement from './icon-element.astro'
|
|
13
|
+
import styles from './icons.module.css'
|
|
14
|
+
|
|
15
|
+
const { class: className, width, height, svgClass: svgClassName, menuItem, ...rest } = Astro.props
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<IconElement
|
|
19
|
+
class:list={['check-icon', className]}
|
|
20
|
+
width={width}
|
|
21
|
+
height={height}
|
|
22
|
+
menuItem={menuItem}
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
<svg
|
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
viewBox="0 0 15 15"
|
|
28
|
+
class:list={[styles['fill-current'], svgClassName]}
|
|
29
|
+
focusable="false"
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
>
|
|
32
|
+
<path
|
|
33
|
+
d="M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z"
|
|
34
|
+
fill-rule="evenodd"
|
|
35
|
+
clip-rule="evenodd"></path>
|
|
36
|
+
</svg>
|
|
37
|
+
</IconElement>
|