mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
parent
186d2863d3
commit
08402e54bf
5 changed files with 32 additions and 4 deletions
|
@ -1447,7 +1447,9 @@ None.
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
|
||||||
None.
|
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||||
|
| :-------- | :--------------- | :------- | :--------------------------------------- | ----------------- | -------------------------------------- |
|
||||||
|
| ref | <code>let</code> | Yes | <code>null | HTMLFormElement</code> | <code>null</code> | Obtain a reference to the form element |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|
|
@ -3998,7 +3998,19 @@
|
||||||
{
|
{
|
||||||
"moduleName": "Form",
|
"moduleName": "Form",
|
||||||
"filePath": "src/Form/Form.svelte",
|
"filePath": "src/Form/Form.svelte",
|
||||||
"props": [],
|
"props": [
|
||||||
|
{
|
||||||
|
"name": "ref",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Obtain a reference to the form element",
|
||||||
|
"type": "null | HTMLFormElement",
|
||||||
|
"value": "null",
|
||||||
|
"isFunction": false,
|
||||||
|
"isFunctionDeclaration": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }],
|
"slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }],
|
||||||
"events": [
|
"events": [
|
||||||
{ "type": "forwarded", "name": "click", "element": "form" },
|
{ "type": "forwarded", "name": "click", "element": "form" },
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
|
<script>
|
||||||
|
/** Obtain a reference to the form element */
|
||||||
|
export let ref = null;
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||||
<form
|
<form
|
||||||
class:bx--form="{true}"
|
class:bx--form="{true}"
|
||||||
|
bind:this="{ref}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
on:keydown
|
on:keydown
|
||||||
|
|
|
@ -9,9 +9,11 @@
|
||||||
SelectItem,
|
SelectItem,
|
||||||
Button,
|
Button,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
|
|
||||||
|
let ref: HTMLFormElement;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Form on:submit>
|
<Form on:submit bind:ref>
|
||||||
<FormGroup legendText="Checkboxes">
|
<FormGroup legendText="Checkboxes">
|
||||||
<Checkbox id="checkbox-0" labelText="Checkbox Label" checked />
|
<Checkbox id="checkbox-0" labelText="Checkbox Label" checked />
|
||||||
<Checkbox id="checkbox-1" labelText="Checkbox Label" />
|
<Checkbox id="checkbox-1" labelText="Checkbox Label" />
|
||||||
|
|
8
types/Form/Form.svelte.d.ts
vendored
8
types/Form/Form.svelte.d.ts
vendored
|
@ -2,7 +2,13 @@
|
||||||
import { SvelteComponentTyped } from "svelte";
|
import { SvelteComponentTyped } from "svelte";
|
||||||
|
|
||||||
export interface FormProps
|
export interface FormProps
|
||||||
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["form"]> {}
|
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["form"]> {
|
||||||
|
/**
|
||||||
|
* Obtain a reference to the form element
|
||||||
|
* @default null
|
||||||
|
*/
|
||||||
|
ref?: null | HTMLFormElement;
|
||||||
|
}
|
||||||
|
|
||||||
export default class Form extends SvelteComponentTyped<
|
export default class Form extends SvelteComponentTyped<
|
||||||
FormProps,
|
FormProps,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue