Skip to content

Commit 3518205

Browse files
committed
feat: chip add onChange$ event
1 parent 292c4f4 commit 3518205

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

apps/docs/content/_components/chip.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ When using `SfChip` without any text label/description inside, you should specif
7676

7777
## Props
7878

79-
| Prop name | Type | Default value | Possible values |
80-
| ------------- | -------------------------------- | ------------- | ---------------- |
81-
| `ref?` | `Signal<Element>` | | |
82-
| `class?` | `string` | | |
83-
| `size?` | `string` | `'base'` | `'sm'`, `'base'` |
84-
| `square?` | `boolean` | | |
85-
| `inputProps?` | `QwikIntrinsicElements['input']` | | |
86-
| `slotPrefix?` | `boolean` | | |
87-
| `slotSuffix?` | `boolean` | | |
79+
| Prop name | Type | Default value | Possible values |
80+
| ------------- | ------------------------------------------------------------------ | ------------- | ---------------- |
81+
| `ref?` | `Signal<Element>` | | |
82+
| `class?` | `string` | | |
83+
| `size?` | `string` | `'base'` | `'sm'`, `'base'` |
84+
| `square?` | `boolean` | | |
85+
| `inputProps?` | `QwikIntrinsicElements['input']` | | |
86+
| `slotPrefix?` | `boolean` | | |
87+
| `slotSuffix?` | `boolean` | | |
88+
| `onChange$?` | `PropFunction<(event: QwikChangeEvent<HTMLInputElement>) => void>` | | |
8889

8990
## Slots
9091

apps/website/src/routes/examples/SfChip/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export default component$(() => {
8080
onChange$: selectHandler,
8181
}}
8282
slotPrefix={true}
83+
onChange$={(e) => console.log(e)}
8384
>
8485
<div q:slot="prefix">
8586
<SfThumbnail

apps/website/src/routes/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { component$ } from '@builder.io/qwik';
2-
import { SfLink } from 'qwik-storefront-ui';
32
export default component$(() => (
43
<>
5-
<SfLink href="/examples?show=true">Examples</SfLink>
4+
<a href="/examples?show=true">Examples</a>
65
<hr />
7-
<SfLink href="/showcases?show=true">Showcases</SfLink>
6+
<a href="/showcases?show=true">Showcases</a>
87
</>
98
));

packages/qwik-storefront-ui/src/components/SfChip/SfChip.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const SfChip = component$<SfChipProps>(
1010
inputProps,
1111
square = false,
1212
ref,
13+
onChange$,
1314
...attributes
1415
}: SfChipProps) => {
1516
const chipId = useId();
@@ -59,6 +60,7 @@ export const SfChip = component$<SfChipProps>(
5960
class="hidden"
6061
type="checkbox"
6162
{...inputProps}
63+
onChange$={(e) => onChange$ && onChange$(e)}
6264
/>
6365
<label
6466
for={chipId}

packages/qwik-storefront-ui/src/components/SfChip/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { QwikIntrinsicElements, Signal } from '@builder.io/qwik';
1+
import {
2+
PropFunction,
3+
QwikChangeEvent,
4+
QwikIntrinsicElements,
5+
Signal,
6+
} from '@builder.io/qwik';
27

38
export type SfChipProps = {
49
ref?: Signal<Element | undefined>;
@@ -8,6 +13,7 @@ export type SfChipProps = {
813
inputProps?: QwikIntrinsicElements['input'];
914
slotPrefix?: boolean;
1015
slotSuffix?: boolean;
16+
onChange$?: PropFunction<(event: QwikChangeEvent<HTMLInputElement>) => void>;
1117
};
1218

1319
export enum SfChipSize {

0 commit comments

Comments
 (0)