Skip to content

Commit 33f85d8

Browse files
authored
Merge pull request #307 from silinternational/develop
Release - 11.9.0 - Checkbox: add name and value props
2 parents 08f39a2 + 1664723 commit 33f85d8

File tree

8 files changed

+129
-171
lines changed

8 files changed

+129
-171
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), enforced with [semantic-release](https://github.com/semantic-release/semantic-release).
55

6+
## [11.9.0](https://github.com/silinternational/ui-components/compare/v11.8.2...v11.9.0) (2025-05-05)
7+
8+
### Added
9+
10+
- **Checkbox:** add name and value attributes and expose change event ([df1d009](https://github.com/silinternational/ui-components/commit/df1d00960db1bda8f9c3210824fa10175450707a))
11+
12+
### [11.8.2](https://github.com/silinternational/ui-components/compare/v11.8.1...v11.8.2) (2025-05-02)
13+
14+
### Fixed
15+
16+
- **TextArea:** Fix label overlapping prefilled text ([17c5cf8](https://github.com/silinternational/ui-components/commit/17c5cf878048b2dc9304947a28477184bae0f1e4))
17+
618
### [11.8.1](https://github.com/silinternational/ui-components/compare/v11.8.0...v11.8.1) (2025-04-10)
719

820
### Fixed

components/mdc/Checkbox/Checkbox.svelte

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,48 @@ export let disabled = false
1919
export let uppercase = false
2020
/** @type {string} random id prefixed with checkbox- for the input id*/
2121
export let inputID = generateRandomID('checkbox-')
22+
/** @type {string} name attribute for the checkbox input - important for forms */
23+
export let name = ''
24+
/** @type {string} value attribute when checked (default is "on") */
25+
export let value = 'on'
2226
2327
let checkboxElement = {}
2428
let formFieldElement = {}
2529
let checkbox
2630
27-
$: if (checkbox) checkbox.checked = checked
28-
2931
onMount(() => {
3032
checkbox = new MDCCheckbox(checkboxElement)
3133
const formField = new MDCFormField(formFieldElement)
32-
3334
formField.input = checkbox
35+
36+
checkbox.checked = checked
3437
})
3538
36-
const handleChange = () => dispatch(checkbox.checked ? 'checked' : 'unchecked')
39+
$: if (checkbox && checkbox.checked !== checked) {
40+
checkbox.checked = checked
41+
}
42+
43+
const handleChange = () => {
44+
if (checkbox) {
45+
checked = checkbox.checked
46+
dispatch(checkbox.checked ? 'checked' : 'unchecked')
47+
}
48+
}
3749
</script>
3850

3951
<div class="mdc-form-field {$$props.class || ''}" bind:this={formFieldElement}>
4052
<div class="mdc-checkbox" bind:this={checkboxElement}>
41-
<input type="checkbox" {disabled} on:change={handleChange} class="mdc-checkbox__native-control" id={inputID} />
53+
<input
54+
type="checkbox"
55+
{name}
56+
{value}
57+
{checked}
58+
{disabled}
59+
on:change={handleChange}
60+
on:change
61+
class="mdc-checkbox__native-control"
62+
id={inputID}
63+
/>
4264
<div class="mdc-checkbox__background">
4365
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
4466
<path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59" />

components/mdc/TextInput/TextArea.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ $: valueIsEmpty = value === ' ' || !value
4444
$: warn = showWarn
4545
$: !valueIsEmpty && addOrRemoveInvalidClass(error, element)
4646
$: addOrRemoveInvalidClass(showError || showWarn, element)
47+
$: floating = !!label && !value.length
4748
4849
onMount(() => {
4950
resize()
@@ -82,8 +83,8 @@ label {
8283
<label
8384
class="mdc-text-field mdc-text-field--outlined mdc-text-field--textarea {$$props.class || ''} textfield-radius"
8485
class:mdc-text-field--no-label={!label}
85-
class:mdc-text-field--label-floating={label}
86-
class:mdc-text-field--with-internal-counter={maxlength}
86+
class:mdc-text-field--label-floating={floating}
87+
class:mdc-text-field--with-internal-counter={!!maxlength}
8788
class:warn
8889
class:showError
8990
bind:this={element}

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ declare module '@silintl/ui-components' {
3838
uppercase?: boolean
3939
class?: string
4040
inputID?: string
41+
name?: string
42+
value?: string
4143
}
4244
export class Checkbox extends SvelteComponent<CheckboxProps> {}
4345

0 commit comments

Comments
 (0)