fluentui-svelte 0.1.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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/components/auto-suggest-box/auto-suggest-box.d.ts +2 -0
- package/dist/components/auto-suggest-box/auto-suggest-box.js +2 -0
- package/dist/components/auto-suggest-box/auto-suggest-box.svelte +457 -0
- package/dist/components/auto-suggest-box/auto-suggest-box.svelte.d.ts +4 -0
- package/dist/components/auto-suggest-box/docs/llms.md +73 -0
- package/dist/components/auto-suggest-box/option.svelte +82 -0
- package/dist/components/auto-suggest-box/option.svelte.d.ts +4 -0
- package/dist/components/auto-suggest-box/types.d.ts +140 -0
- package/dist/components/auto-suggest-box/types.js +1 -0
- package/dist/components/avatar/avatar.svelte +269 -0
- package/dist/components/avatar/avatar.svelte.d.ts +20 -0
- package/dist/components/avatar/docs/llms.md +92 -0
- package/dist/components/avatar/type.d.ts +63 -0
- package/dist/components/avatar/type.js +1 -0
- package/dist/components/badge/badge-icon.svelte +103 -0
- package/dist/components/badge/badge-icon.svelte.d.ts +25 -0
- package/dist/components/badge/badge.svelte +163 -0
- package/dist/components/badge/badge.svelte.d.ts +20 -0
- package/dist/components/badge/docs/llms.md +133 -0
- package/dist/components/badge/types.d.ts +70 -0
- package/dist/components/badge/types.js +1 -0
- package/dist/components/badge/utils.svelte.d.ts +16 -0
- package/dist/components/badge/utils.svelte.js +35 -0
- package/dist/components/button/button.svelte +203 -0
- package/dist/components/button/button.svelte.d.ts +38 -0
- package/dist/components/button/docs/llms.md +102 -0
- package/dist/components/button/split-button.svelte +66 -0
- package/dist/components/button/split-button.svelte.d.ts +4 -0
- package/dist/components/button/types.d.ts +84 -0
- package/dist/components/button/types.js +1 -0
- package/dist/components/calendar-date-picker/calendar-date-picker.svelte +119 -0
- package/dist/components/calendar-date-picker/calendar-date-picker.svelte.d.ts +4 -0
- package/dist/components/calendar-date-picker/docs/llms.md +33 -0
- package/dist/components/calendar-date-picker/types.d.ts +36 -0
- package/dist/components/calendar-date-picker/types.js +1 -0
- package/dist/components/calendar-view/calendar-view-controls.svelte +115 -0
- package/dist/components/calendar-view/calendar-view-controls.svelte.d.ts +3 -0
- package/dist/components/calendar-view/calendar-view-days.svelte +210 -0
- package/dist/components/calendar-view/calendar-view-days.svelte.d.ts +3 -0
- package/dist/components/calendar-view/calendar-view-grid.d.ts +38 -0
- package/dist/components/calendar-view/calendar-view-grid.js +140 -0
- package/dist/components/calendar-view/calendar-view-header.svelte +66 -0
- package/dist/components/calendar-view/calendar-view-header.svelte.d.ts +18 -0
- package/dist/components/calendar-view/calendar-view-item.svelte +181 -0
- package/dist/components/calendar-view/calendar-view-item.svelte.d.ts +4 -0
- package/dist/components/calendar-view/calendar-view-months.svelte +165 -0
- package/dist/components/calendar-view/calendar-view-months.svelte.d.ts +3 -0
- package/dist/components/calendar-view/calendar-view-years.svelte +161 -0
- package/dist/components/calendar-view/calendar-view-years.svelte.d.ts +3 -0
- package/dist/components/calendar-view/calendar-view.svelte +451 -0
- package/dist/components/calendar-view/calendar-view.svelte.d.ts +9 -0
- package/dist/components/calendar-view/calendar-view.svelte.js +196 -0
- package/dist/components/calendar-view/docs/llms.md +121 -0
- package/dist/components/calendar-view/index.d.ts +1 -0
- package/dist/components/calendar-view/index.js +1 -0
- package/dist/components/calendar-view/types.d.ts +174 -0
- package/dist/components/calendar-view/types.js +1 -0
- package/dist/components/checkbox/checkbox.svelte +171 -0
- package/dist/components/checkbox/checkbox.svelte.d.ts +40 -0
- package/dist/components/checkbox/docs/llms.md +78 -0
- package/dist/components/checkbox/types.d.ts +50 -0
- package/dist/components/checkbox/types.js +1 -0
- package/dist/components/date-picker/date-picker.svelte +381 -0
- package/dist/components/date-picker/date-picker.svelte.d.ts +4 -0
- package/dist/components/date-picker/docs/llms.md +52 -0
- package/dist/components/date-picker/index.d.ts +1 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-picker/types.d.ts +74 -0
- package/dist/components/date-picker/types.js +1 -0
- package/dist/components/dialog/dialog-actions.svelte +37 -0
- package/dist/components/dialog/dialog-actions.svelte.d.ts +4 -0
- package/dist/components/dialog/dialog-content.svelte +17 -0
- package/dist/components/dialog/dialog-content.svelte.d.ts +4 -0
- package/dist/components/dialog/dialog-surface.svelte +95 -0
- package/dist/components/dialog/dialog-surface.svelte.d.ts +4 -0
- package/dist/components/dialog/dialog-title.svelte +33 -0
- package/dist/components/dialog/dialog-title.svelte.d.ts +25 -0
- package/dist/components/dialog/dialog-trigger.svelte +23 -0
- package/dist/components/dialog/dialog-trigger.svelte.d.ts +4 -0
- package/dist/components/dialog/dialog.svelte +64 -0
- package/dist/components/dialog/dialog.svelte.d.ts +7 -0
- package/dist/components/dialog/dialog.svelte.js +2 -0
- package/dist/components/dialog/docs/llms.md +131 -0
- package/dist/components/dialog/types.d.ts +92 -0
- package/dist/components/dialog/types.js +1 -0
- package/dist/components/divider/divider.svelte +120 -0
- package/dist/components/divider/divider.svelte.d.ts +39 -0
- package/dist/components/divider/docs/llms.md +83 -0
- package/dist/components/divider/types.d.ts +32 -0
- package/dist/components/divider/types.js +1 -0
- package/dist/components/dropdown/docs/llms.md +70 -0
- package/dist/components/dropdown/dropdown-context.d.ts +2 -0
- package/dist/components/dropdown/dropdown-context.js +2 -0
- package/dist/components/dropdown/dropdown-option.svelte +31 -0
- package/dist/components/dropdown/dropdown-option.svelte.d.ts +4 -0
- package/dist/components/dropdown/dropdown.svelte +309 -0
- package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
- package/dist/components/dropdown/types.d.ts +82 -0
- package/dist/components/dropdown/types.js +1 -0
- package/dist/components/dropdown-select/docs/llms.md +72 -0
- package/dist/components/dropdown-select/dropdown-select-option.svelte +87 -0
- package/dist/components/dropdown-select/dropdown-select-option.svelte.d.ts +4 -0
- package/dist/components/dropdown-select/dropdown-select.svelte +165 -0
- package/dist/components/dropdown-select/dropdown-select.svelte.d.ts +4 -0
- package/dist/components/dropdown-select/dropdown-select.svelte.js +48 -0
- package/dist/components/dropdown-select/index.d.ts +2 -0
- package/dist/components/dropdown-select/index.js +2 -0
- package/dist/components/dropdown-select/types.d.ts +46 -0
- package/dist/components/dropdown-select/types.js +1 -0
- package/dist/components/expander/docs/llms.md +88 -0
- package/dist/components/expander/expander.svelte +249 -0
- package/dist/components/expander/expander.svelte.d.ts +21 -0
- package/dist/components/expander/types.d.ts +47 -0
- package/dist/components/expander/types.js +1 -0
- package/dist/components/flyout/docs/llms.md +31 -0
- package/dist/components/flyout/flyout.svelte +148 -0
- package/dist/components/flyout/flyout.svelte.d.ts +19 -0
- package/dist/components/flyout/types.d.ts +36 -0
- package/dist/components/flyout/types.js +1 -0
- package/dist/components/hyperlink/docs/llms.md +33 -0
- package/dist/components/hyperlink/hyperlink.svelte +66 -0
- package/dist/components/hyperlink/hyperlink.svelte.d.ts +16 -0
- package/dist/components/hyperlink/types.d.ts +14 -0
- package/dist/components/hyperlink/types.js +1 -0
- package/dist/components/info-bar/docs/llms.md +81 -0
- package/dist/components/info-bar/info-bar.svelte +140 -0
- package/dist/components/info-bar/info-bar.svelte.d.ts +19 -0
- package/dist/components/info-bar/types.d.ts +27 -0
- package/dist/components/info-bar/types.js +1 -0
- package/dist/components/label/docs/llms.md +67 -0
- package/dist/components/label/label.svelte +95 -0
- package/dist/components/label/label.svelte.d.ts +4 -0
- package/dist/components/label/types.d.ts +32 -0
- package/dist/components/label/types.js +1 -0
- package/dist/components/list-view/docs/llms.md +110 -0
- package/dist/components/list-view/list-view-item.svelte +168 -0
- package/dist/components/list-view/list-view-item.svelte.d.ts +25 -0
- package/dist/components/list-view/list-view.svelte +137 -0
- package/dist/components/list-view/list-view.svelte.d.ts +25 -0
- package/dist/components/list-view/types.d.ts +95 -0
- package/dist/components/list-view/types.js +1 -0
- package/dist/components/list-view/utils.d.ts +6 -0
- package/dist/components/list-view/utils.js +12 -0
- package/dist/components/menu/context-menu-trigger.svelte +84 -0
- package/dist/components/menu/context-menu-trigger.svelte.d.ts +9 -0
- package/dist/components/menu/docs/llms.md +169 -0
- package/dist/components/menu/menu-divider.svelte +9 -0
- package/dist/components/menu/menu-divider.svelte.d.ts +26 -0
- package/dist/components/menu/menu-group.svelte +31 -0
- package/dist/components/menu/menu-group.svelte.d.ts +4 -0
- package/dist/components/menu/menu-item-checkbox.svelte +143 -0
- package/dist/components/menu/menu-item-checkbox.svelte.d.ts +15 -0
- package/dist/components/menu/menu-item-radio.svelte +147 -0
- package/dist/components/menu/menu-item-radio.svelte.d.ts +15 -0
- package/dist/components/menu/menu-item-switch.svelte +194 -0
- package/dist/components/menu/menu-item-switch.svelte.d.ts +15 -0
- package/dist/components/menu/menu-item.svelte +124 -0
- package/dist/components/menu/menu-item.svelte.d.ts +18 -0
- package/dist/components/menu/menu-list.svelte +38 -0
- package/dist/components/menu/menu-list.svelte.d.ts +5 -0
- package/dist/components/menu/menu-popover.svelte +125 -0
- package/dist/components/menu/menu-popover.svelte.d.ts +12 -0
- package/dist/components/menu/menu-trigger.svelte +121 -0
- package/dist/components/menu/menu-trigger.svelte.d.ts +4 -0
- package/dist/components/menu/menu.svelte +124 -0
- package/dist/components/menu/menu.svelte.d.ts +4 -0
- package/dist/components/menu/menu.svelte.js +77 -0
- package/dist/components/menu/types.d.ts +127 -0
- package/dist/components/menu/types.js +1 -0
- package/dist/components/number-box/docs/llms.md +37 -0
- package/dist/components/number-box/number-box.svelte +115 -0
- package/dist/components/number-box/number-box.svelte.d.ts +15 -0
- package/dist/components/number-box/types.d.ts +16 -0
- package/dist/components/number-box/types.js +1 -0
- package/dist/components/persona/docs/llms.md +107 -0
- package/dist/components/persona/persona.svelte +79 -0
- package/dist/components/persona/persona.svelte.d.ts +4 -0
- package/dist/components/persona/types.d.ts +42 -0
- package/dist/components/persona/types.js +1 -0
- package/dist/components/progress-bar/docs/llms.md +67 -0
- package/dist/components/progress-bar/progress-bar.svelte +167 -0
- package/dist/components/progress-bar/progress-bar.svelte.d.ts +15 -0
- package/dist/components/progress-bar/types.d.ts +39 -0
- package/dist/components/progress-bar/types.js +1 -0
- package/dist/components/progress-ring/docs/llms.md +76 -0
- package/dist/components/progress-ring/progress-ring.svelte +145 -0
- package/dist/components/progress-ring/progress-ring.svelte.d.ts +15 -0
- package/dist/components/progress-ring/types.d.ts +42 -0
- package/dist/components/progress-ring/types.js +1 -0
- package/dist/components/radio-button/docs/llms.md +64 -0
- package/dist/components/radio-button/radio-button.svelte +129 -0
- package/dist/components/radio-button/radio-button.svelte.d.ts +19 -0
- package/dist/components/radio-button/types.d.ts +24 -0
- package/dist/components/radio-button/types.js +1 -0
- package/dist/components/skeleton/docs/llms.md +67 -0
- package/dist/components/skeleton/skeleton.svelte +106 -0
- package/dist/components/skeleton/skeleton.svelte.d.ts +39 -0
- package/dist/components/skeleton/types.d.ts +24 -0
- package/dist/components/skeleton/types.js +1 -0
- package/dist/components/slider/docs/llms.md +75 -0
- package/dist/components/slider/slider.svelte +486 -0
- package/dist/components/slider/slider.svelte.d.ts +19 -0
- package/dist/components/slider/types.d.ts +102 -0
- package/dist/components/slider/types.js +1 -0
- package/dist/components/text-box/docs/llms.md +86 -0
- package/dist/components/text-box/text-box-button.svelte +65 -0
- package/dist/components/text-box/text-box-button.svelte.d.ts +9 -0
- package/dist/components/text-box/text-box.svelte +299 -0
- package/dist/components/text-box/text-box.svelte.d.ts +16 -0
- package/dist/components/text-box/types.d.ts +60 -0
- package/dist/components/text-box/types.js +1 -0
- package/dist/components/textarea/docs/llms.md +55 -0
- package/dist/components/textarea/textarea.svelte +151 -0
- package/dist/components/textarea/textarea.svelte.d.ts +17 -0
- package/dist/components/textarea/types.d.ts +33 -0
- package/dist/components/textarea/types.js +1 -0
- package/dist/components/time-picker/docs/llms.md +47 -0
- package/dist/components/time-picker/index.d.ts +1 -0
- package/dist/components/time-picker/index.js +1 -0
- package/dist/components/time-picker/time-picker.svelte +336 -0
- package/dist/components/time-picker/time-picker.svelte.d.ts +4 -0
- package/dist/components/time-picker/types.d.ts +54 -0
- package/dist/components/time-picker/types.js +1 -0
- package/dist/components/toggle-switch/docs/llms.md +39 -0
- package/dist/components/toggle-switch/toggle-switch.svelte +151 -0
- package/dist/components/toggle-switch/toggle-switch.svelte.d.ts +17 -0
- package/dist/components/toggle-switch/types.d.ts +20 -0
- package/dist/components/toggle-switch/types.js +1 -0
- package/dist/components/tooltip/docs/llms.md +74 -0
- package/dist/components/tooltip/tooltip.svelte +246 -0
- package/dist/components/tooltip/tooltip.svelte.d.ts +18 -0
- package/dist/components/tooltip/types.d.ts +67 -0
- package/dist/components/tooltip/types.js +1 -0
- package/dist/components/tree-view/docs/llms.md +117 -0
- package/dist/components/tree-view/tree-view-item-content.svelte +158 -0
- package/dist/components/tree-view/tree-view-item-content.svelte.d.ts +4 -0
- package/dist/components/tree-view/tree-view-item.svelte +197 -0
- package/dist/components/tree-view/tree-view-item.svelte.d.ts +4 -0
- package/dist/components/tree-view/tree-view.svelte +220 -0
- package/dist/components/tree-view/tree-view.svelte.d.ts +4 -0
- package/dist/components/tree-view/tree-view.svelte.js +111 -0
- package/dist/components/tree-view/types.d.ts +185 -0
- package/dist/components/tree-view/types.js +1 -0
- package/dist/css/class-darkmode.css +186 -0
- package/dist/css/media-darkmode.css +189 -0
- package/dist/css/reset.css +53 -0
- package/dist/css/theme.css +276 -0
- package/dist/css/typography.css +67 -0
- package/dist/css/utils.d.ts +1 -0
- package/dist/css/utils.js +153 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +129 -0
- package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte +449 -0
- package/dist/internal/components/dynamic-carousel/dynamic-carousel.svelte.d.ts +22 -0
- package/dist/internal/components/render-soc/render-soc.svelte +29 -0
- package/dist/internal/components/render-soc/render-soc.svelte.d.ts +30 -0
- package/dist/internal/constants.d.ts +26 -0
- package/dist/internal/constants.js +4036 -0
- package/dist/internal/context.d.ts +14 -0
- package/dist/internal/context.js +13 -0
- package/dist/internal/dom-utils.svelte.d.ts +6 -0
- package/dist/internal/dom-utils.svelte.js +46 -0
- package/dist/internal/floating-ui/floating.svelte.d.ts +15 -0
- package/dist/internal/floating-ui/floating.svelte.js +26 -0
- package/dist/internal/floating-ui/utils.d.ts +3 -0
- package/dist/internal/floating-ui/utils.js +30 -0
- package/dist/internal/index.d.ts +9 -0
- package/dist/internal/index.js +9 -0
- package/dist/internal/polyfills/expander.svelte.d.ts +21 -0
- package/dist/internal/polyfills/expander.svelte.js +96 -0
- package/dist/internal/transitions.d.ts +32 -0
- package/dist/internal/transitions.js +37 -0
- package/dist/internal/utils.d.ts +22 -0
- package/dist/internal/utils.js +63 -0
- package/dist/providers/fluentui-svelte/fluentui-svelte.d.ts +19 -0
- package/dist/providers/fluentui-svelte/fluentui-svelte.js +11 -0
- package/dist/providers/fluentui-svelte/fluentui-svelte.svelte +68 -0
- package/dist/providers/fluentui-svelte/fluentui-svelte.svelte.d.ts +9 -0
- package/dist/types/index.d.ts +117 -0
- package/dist/types/index.js +1 -0
- package/package.json +142 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# TextBox
|
|
2
|
+
|
|
3
|
+
The TextBox control lets a user type text into an app. It's typically used to capture a single line of text, but can be configured to capture multiple lines of text. The text displays on the screen in a simple, uniform, plaintext format.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { TextBox } from 'fluentui-svelte';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<TextBox type="text" placeholder="Type here..." />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Component API
|
|
16
|
+
|
|
17
|
+
A brief explanation of the props that really need explaining. You can see the rest of the props in the Component Props table below.
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### Type
|
|
22
|
+
|
|
23
|
+
The `type` prop specifies the type of input element. It can be set to various types such as `text`, `search`, `email`, `url`, `tel`, `password`, or `number`. This determines the behavior and validation of the input.
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<TextBox type="text" placeholder="Text" />
|
|
27
|
+
<TextBox type="search" placeholder="Search" />
|
|
28
|
+
<TextBox type="password" placeholder="Password" />
|
|
29
|
+
<TextBox type="number" placeholder="Number" />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Input Element
|
|
33
|
+
|
|
34
|
+
The `ref` prop allows you to bind a reference to the underlying HTML input element (`bind:ref`). This can be useful for direct DOM manipulations or accessing native input properties. The wrapper element can be bound via `wrapperRef`.
|
|
35
|
+
|
|
36
|
+
### Readonly
|
|
37
|
+
|
|
38
|
+
The `readonly` prop makes the input field read-only, preventing users from modifying its value. This is useful for displaying information that should not be edited.
|
|
39
|
+
|
|
40
|
+
```svelte
|
|
41
|
+
<TextBox readonly value="Read-only value" />
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Placeholder
|
|
45
|
+
|
|
46
|
+
The `placeholder` prop sets the placeholder text for the input field, providing a hint to users about what to enter.
|
|
47
|
+
|
|
48
|
+
### Hide Buttons
|
|
49
|
+
|
|
50
|
+
The `hideActionButtons` prop allows you to hide the extra action buttons in the input, such as clear or submit buttons. This can be useful for a cleaner UI when those actions are not needed.
|
|
51
|
+
|
|
52
|
+
```svelte
|
|
53
|
+
<TextBox type="search" hideActionButtons placeholder="No action buttons" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Query Submitted
|
|
57
|
+
|
|
58
|
+
The `querySubmitted` event is triggered when a query is submitted, such as when the user presses Enter in a search input. This allows you to handle the submission of the input value.
|
|
59
|
+
|
|
60
|
+
### Text Changed
|
|
61
|
+
|
|
62
|
+
The `textChanged` event is triggered whenever the content of the text box changes. This can be used to react to user input in real-time, such as validating input or updating other parts of the UI.
|
|
63
|
+
|
|
64
|
+
### On Clear
|
|
65
|
+
|
|
66
|
+
The `onClear` event is triggered when the input is cleared, allowing you to handle any necessary actions when the user removes the input value.
|
|
67
|
+
|
|
68
|
+
## Component Props
|
|
69
|
+
|
|
70
|
+
| Name | Type | Description |
|
|
71
|
+
| ------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
72
|
+
| `type` | `string` | The type of the input element. Possible values: `'text'`, `'search'`, `'email'`, `'url'`, `'tel'`, `'password'`, `'number'`. |
|
|
73
|
+
| `ref` | `HTMLInputElement` | The DOM reference of the input element. |
|
|
74
|
+
| `wrapperRef` | `HTMLDivElement` | The DOM reference of the wrapper element. |
|
|
75
|
+
| `wrapperAttributes` | `HTMLAttributes<HTMLDivElement>` | Additional attributes forwarded to the wrapper element. |
|
|
76
|
+
| `size` | `'small' \| 'medium' \| 'large'` | The size of the input. |
|
|
77
|
+
| `readonly` | `boolean` | Whether the input is read-only. |
|
|
78
|
+
| `placeholder` | `string` | The placeholder text for the input. |
|
|
79
|
+
| `hideActionButtons` | `boolean` | Whether to hide the extra action buttons in the input. |
|
|
80
|
+
| `justify` | `boolean` | Whether the input fills the full width of the container. |
|
|
81
|
+
| `contentBefore` | `string \| Snippet \| Component` | Content rendered before the input (e.g. an icon). |
|
|
82
|
+
| `contentAfter` | `string \| Snippet \| Component` | Content rendered after the input (e.g. an icon). |
|
|
83
|
+
| `textChanged` | `(e: InputEvent, text: string) => void` | Event triggered when content changes in the text box. |
|
|
84
|
+
| `querySubmitted` | `(e: MouseEvent \| KeyboardEvent, query: string) => void` | Event triggered when a query is submitted (Enter or search icon click on `type="search"`). |
|
|
85
|
+
| `onClear` | `(e: MouseEvent) => void` | Event triggered when the input is cleared. |
|
|
86
|
+
| `children` | `Snippet` | The children elements to render inside the input. |
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
element = $bindable(),
|
|
7
|
+
type = 'button',
|
|
8
|
+
children,
|
|
9
|
+
...attributes
|
|
10
|
+
}: { element?: HTMLButtonElement; children: Snippet } & HTMLButtonAttributes = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<button {type} bind:this={element} {...attributes}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</button>
|
|
16
|
+
|
|
17
|
+
<style>
|
|
18
|
+
button {
|
|
19
|
+
outline: none;
|
|
20
|
+
background-color: var(--fs-subtle-fill-transparent);
|
|
21
|
+
border: 1px solid var(--fs-subtle-fill-transparent);
|
|
22
|
+
border-radius: var(--fs-control-border-radius);
|
|
23
|
+
color: var(--fs-text-secondary);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
padding: 0.188rem 0.313rem;
|
|
29
|
+
z-index: 1;
|
|
30
|
+
flex: 0 0 auto;
|
|
31
|
+
margin: 0 0.375rem;
|
|
32
|
+
&:first-of-type {
|
|
33
|
+
margin-left: 0;
|
|
34
|
+
}
|
|
35
|
+
&:last-of-type {
|
|
36
|
+
margin-right: 0.188rem;
|
|
37
|
+
}
|
|
38
|
+
&:focus-visible {
|
|
39
|
+
outline: 0.125rem solid var(--fs-focus-stroke-outer);
|
|
40
|
+
outline-offset: 1px;
|
|
41
|
+
}
|
|
42
|
+
&:hover {
|
|
43
|
+
background-color: var(--fs-subtle-fill-secondary);
|
|
44
|
+
}
|
|
45
|
+
&:active {
|
|
46
|
+
background-color: var(--fs-subtle-fill-tertiary);
|
|
47
|
+
color: var(--fs-text-secondary);
|
|
48
|
+
}
|
|
49
|
+
&:disabled {
|
|
50
|
+
background-color: var(--fs-subtle-fill-disabled);
|
|
51
|
+
border-color: var(--fs-control-stroke-default);
|
|
52
|
+
color: var(--fs-text-disabled);
|
|
53
|
+
cursor: not-allowed;
|
|
54
|
+
}
|
|
55
|
+
& :global(svg) {
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
fill: currentColor;
|
|
58
|
+
width: 1.1rem;
|
|
59
|
+
height: 1.1rem;
|
|
60
|
+
& :global(path) {
|
|
61
|
+
fill: currentColor;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
element?: HTMLButtonElement;
|
|
5
|
+
children: Snippet;
|
|
6
|
+
} & HTMLButtonAttributes;
|
|
7
|
+
declare const TextBoxButton: import("svelte").Component<$$ComponentProps, {}, "element">;
|
|
8
|
+
type TextBoxButton = ReturnType<typeof TextBoxButton>;
|
|
9
|
+
export default TextBoxButton;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import DismissFilled from 'fluentui-icons-svelte/DismissFilled.svelte';
|
|
3
|
+
import SearchFilled from 'fluentui-icons-svelte/SearchFilled.svelte';
|
|
4
|
+
import EyeShowFilled from 'fluentui-icons-svelte/EyeShowFilled.svelte';
|
|
5
|
+
import EyeHideFilled from 'fluentui-icons-svelte/EyeHideFilled.svelte';
|
|
6
|
+
import { TextBoxButton } from '../../index.js';
|
|
7
|
+
import { RenderSoC } from '../../internal/index.js';
|
|
8
|
+
import type { TextBoxProps } from './types.js';
|
|
9
|
+
|
|
10
|
+
const FALLBACK_ID = $props.id();
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
id = 'input-' + FALLBACK_ID,
|
|
14
|
+
readonly,
|
|
15
|
+
name = id,
|
|
16
|
+
hideActionButtons,
|
|
17
|
+
type = 'text',
|
|
18
|
+
class: classes,
|
|
19
|
+
wrapperAttributes,
|
|
20
|
+
wrapperRef = $bindable(),
|
|
21
|
+
value = $bindable(),
|
|
22
|
+
ref = $bindable(),
|
|
23
|
+
placeholder = 'Fluent TextBox',
|
|
24
|
+
size = 'medium',
|
|
25
|
+
contentBefore,
|
|
26
|
+
contentAfter,
|
|
27
|
+
querySubmitted,
|
|
28
|
+
textChanged,
|
|
29
|
+
onkeydown,
|
|
30
|
+
onClear,
|
|
31
|
+
children,
|
|
32
|
+
...attributes
|
|
33
|
+
}: TextBoxProps = $props();
|
|
34
|
+
|
|
35
|
+
let currentType = $derived(type);
|
|
36
|
+
let hasValue = $derived(!!((value && value.length > 0) || (typeof value === 'number' && value !== 0)));
|
|
37
|
+
|
|
38
|
+
const clearInput = (e: MouseEvent) => {
|
|
39
|
+
if (typeof value === 'string') {
|
|
40
|
+
value = '';
|
|
41
|
+
if (type === 'password' && currentType === 'text') {
|
|
42
|
+
ref?.setAttribute('type', 'password');
|
|
43
|
+
currentType = 'password';
|
|
44
|
+
ref?.focus();
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
value = 0;
|
|
48
|
+
}
|
|
49
|
+
onClear?.(e);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const revealPassword = () => {
|
|
53
|
+
if (ref) {
|
|
54
|
+
ref.setAttribute('type', currentType === 'password' ? 'text' : 'password');
|
|
55
|
+
currentType = currentType === 'password' ? 'text' : 'password';
|
|
56
|
+
ref.focus();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const handleKeyDown = (e: KeyboardEvent & { currentTarget: EventTarget & HTMLInputElement }) => {
|
|
61
|
+
if (e.key === 'Escape') {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
(e.target as HTMLInputElement).blur();
|
|
64
|
+
}
|
|
65
|
+
onkeydown?.(e);
|
|
66
|
+
};
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<!--
|
|
70
|
+
@component
|
|
71
|
+
|
|
72
|
+
This is a implementation of Fluent UI TextBox component. The TextBox component is a customizable input element that allows users to enter text. It is designed to be consistent with the Fluent Design System.
|
|
73
|
+
|
|
74
|
+
- Usage:
|
|
75
|
+
```tsx
|
|
76
|
+
<script>
|
|
77
|
+
import { TextBox } from 'fluentui-svelte';
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<TextBox type="text" placeholder="Enter your name" />
|
|
81
|
+
```
|
|
82
|
+
-->
|
|
83
|
+
<div class={['fs-textbox', id, `text-box-size-${size}`, classes]} {...wrapperAttributes} bind:this={wrapperRef}>
|
|
84
|
+
{#if contentBefore}
|
|
85
|
+
<span class="content-before">
|
|
86
|
+
{#if typeof contentBefore === 'string'}
|
|
87
|
+
{contentBefore}
|
|
88
|
+
{:else}
|
|
89
|
+
<RenderSoC SoC={contentBefore} />
|
|
90
|
+
{/if}
|
|
91
|
+
</span>
|
|
92
|
+
{/if}
|
|
93
|
+
<input
|
|
94
|
+
{type}
|
|
95
|
+
{id}
|
|
96
|
+
{name}
|
|
97
|
+
{placeholder}
|
|
98
|
+
{readonly}
|
|
99
|
+
bind:value
|
|
100
|
+
bind:this={ref}
|
|
101
|
+
onkeyup={handleKeyDown}
|
|
102
|
+
oninput={(e) => textChanged?.(e as any, value)}
|
|
103
|
+
onchange={(e) => textChanged?.(e as any, value)}
|
|
104
|
+
{...attributes}
|
|
105
|
+
/>
|
|
106
|
+
{#if contentAfter}
|
|
107
|
+
<span class="content-after">
|
|
108
|
+
{#if typeof contentAfter === 'string'}
|
|
109
|
+
{contentAfter}
|
|
110
|
+
{:else}
|
|
111
|
+
<RenderSoC SoC={contentAfter} />
|
|
112
|
+
{/if}
|
|
113
|
+
</span>
|
|
114
|
+
{/if}
|
|
115
|
+
{#if !hideActionButtons}
|
|
116
|
+
{#if !readonly}
|
|
117
|
+
<TextBoxButton
|
|
118
|
+
class="clear-button {hasValue ? '' : 'is-empty'}"
|
|
119
|
+
disabled={!hasValue}
|
|
120
|
+
aria-hidden={hasValue ? undefined : 'true'}
|
|
121
|
+
aria-label="Delete Text"
|
|
122
|
+
onclick={(e) => clearInput(e)}
|
|
123
|
+
>
|
|
124
|
+
<DismissFilled />
|
|
125
|
+
</TextBoxButton>
|
|
126
|
+
{/if}
|
|
127
|
+
{#if type === 'search'}
|
|
128
|
+
<TextBoxButton disabled={readonly} aria-label="Search" onclick={(e) => querySubmitted?.(e, value)}>
|
|
129
|
+
<SearchFilled />
|
|
130
|
+
</TextBoxButton>
|
|
131
|
+
{:else if type === 'password'}
|
|
132
|
+
<TextBoxButton disabled={readonly} aria-label="Reveal Password" onclick={() => revealPassword()}>
|
|
133
|
+
{#if currentType === 'password'}
|
|
134
|
+
<EyeShowFilled />
|
|
135
|
+
{:else}
|
|
136
|
+
<EyeHideFilled />
|
|
137
|
+
{/if}
|
|
138
|
+
</TextBoxButton>
|
|
139
|
+
{/if}
|
|
140
|
+
{/if}
|
|
141
|
+
{@render children?.()}
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<style>
|
|
145
|
+
.fs-textbox {
|
|
146
|
+
display: flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
position: relative;
|
|
149
|
+
border-radius: var(--fs-control-border-radius);
|
|
150
|
+
background: var(--fs-control-fill-default);
|
|
151
|
+
border: none;
|
|
152
|
+
& input {
|
|
153
|
+
appearance: none;
|
|
154
|
+
background: transparent;
|
|
155
|
+
outline: none;
|
|
156
|
+
border: none;
|
|
157
|
+
margin: 0;
|
|
158
|
+
z-index: 1;
|
|
159
|
+
color: var(--fs-text-primary);
|
|
160
|
+
padding: 0.375rem 0.75rem;
|
|
161
|
+
min-width: 2ch;
|
|
162
|
+
flex: 1 1 auto;
|
|
163
|
+
&::placeholder {
|
|
164
|
+
color: var(--fs-text-secondary);
|
|
165
|
+
}
|
|
166
|
+
&::-ms-reveal,
|
|
167
|
+
&::-ms-clear {
|
|
168
|
+
display: none;
|
|
169
|
+
}
|
|
170
|
+
&::-webkit-search-decoration,
|
|
171
|
+
&::-webkit-search-cancel-button,
|
|
172
|
+
&::-webkit-search-results-button,
|
|
173
|
+
&::-webkit-search-results-decoration,
|
|
174
|
+
&::-webkit-outer-spin-button,
|
|
175
|
+
&::-webkit-inner-spin-button {
|
|
176
|
+
-webkit-appearance: none;
|
|
177
|
+
}
|
|
178
|
+
&[type='number'] {
|
|
179
|
+
-moz-appearance: textfield;
|
|
180
|
+
appearance: textfield;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
&:before {
|
|
184
|
+
content: '';
|
|
185
|
+
pointer-events: none;
|
|
186
|
+
width: calc(100% + 0.125rem);
|
|
187
|
+
height: calc(100% + 0.125rem);
|
|
188
|
+
position: absolute;
|
|
189
|
+
top: -0.063rem;
|
|
190
|
+
left: -0.063rem;
|
|
191
|
+
padding: 0.063rem;
|
|
192
|
+
border-radius: 0.313rem;
|
|
193
|
+
mask:
|
|
194
|
+
linear-gradient(#fff 0 0) content-box,
|
|
195
|
+
linear-gradient(#fff 0 0);
|
|
196
|
+
mask-composite: exclude;
|
|
197
|
+
background: var(--fs-elevation-text-border);
|
|
198
|
+
z-index: 1;
|
|
199
|
+
}
|
|
200
|
+
&:after {
|
|
201
|
+
content: '';
|
|
202
|
+
pointer-events: none;
|
|
203
|
+
width: 0;
|
|
204
|
+
height: 10px;
|
|
205
|
+
border-radius: 0px 0px 5px 5px;
|
|
206
|
+
position: absolute;
|
|
207
|
+
bottom: -0.063rem;
|
|
208
|
+
left: calc(50% - 0.063rem);
|
|
209
|
+
clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0% 100%);
|
|
210
|
+
background: transparent;
|
|
211
|
+
transition:
|
|
212
|
+
width var(--fs-normal-duration) var(--fs-point-to-point),
|
|
213
|
+
left var(--fs-normal-duration) var(--fs-point-to-point);
|
|
214
|
+
z-index: 2;
|
|
215
|
+
}
|
|
216
|
+
&:hover {
|
|
217
|
+
background: var(--fs-control-fill-secondary);
|
|
218
|
+
}
|
|
219
|
+
&:has(input:focus-visible):after {
|
|
220
|
+
width: calc(100% + 0.125rem);
|
|
221
|
+
left: -0.063rem;
|
|
222
|
+
background-color: var(--fs-accent-fill-default);
|
|
223
|
+
}
|
|
224
|
+
&:has(input:focus) {
|
|
225
|
+
background: var(--fs-control-fill-input-active);
|
|
226
|
+
& input::placeholder {
|
|
227
|
+
color: var(--fs-text-tertiary);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
&:has(input:disabled) {
|
|
231
|
+
cursor: not-allowed;
|
|
232
|
+
background: var(--fs-control-fill-disabled);
|
|
233
|
+
& input::placeholder {
|
|
234
|
+
color: var(--fs-text-disabled);
|
|
235
|
+
}
|
|
236
|
+
&::before {
|
|
237
|
+
background: var(--fs-control-stroke-default);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
&:has(.content-before, .content-after) {
|
|
241
|
+
& input {
|
|
242
|
+
padding: 0.375rem 0.25rem;
|
|
243
|
+
}
|
|
244
|
+
& .content-before {
|
|
245
|
+
padding: 0.375rem 0.25rem 0.375rem 0.625rem;
|
|
246
|
+
}
|
|
247
|
+
& .content-after {
|
|
248
|
+
padding: 0.375rem 0.625rem 0.375rem 0.25rem;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
& .content-before,
|
|
252
|
+
& .content-after {
|
|
253
|
+
display: flex;
|
|
254
|
+
align-items: center;
|
|
255
|
+
justify-content: center;
|
|
256
|
+
color: var(--fs-text-secondary);
|
|
257
|
+
height: 100%;
|
|
258
|
+
min-width: max-content;
|
|
259
|
+
width: auto;
|
|
260
|
+
|
|
261
|
+
& :global(svg) {
|
|
262
|
+
fill: currentColor;
|
|
263
|
+
width: auto;
|
|
264
|
+
height: 100%;
|
|
265
|
+
& :global(path) {
|
|
266
|
+
fill: currentColor;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
& :global(.clear-button.is-empty) {
|
|
271
|
+
visibility: hidden;
|
|
272
|
+
}
|
|
273
|
+
&.text-box-size-small {
|
|
274
|
+
& :is(input, .content-after, .content-before) {
|
|
275
|
+
font-size: var(--fs-body2-font-size);
|
|
276
|
+
padding: 0.25rem;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
&.text-box-size-medium {
|
|
280
|
+
font-size: var(--fs-body-font-size);
|
|
281
|
+
& :is(input, .content-after, .content-before) {
|
|
282
|
+
padding: 0.375rem;
|
|
283
|
+
font-size: var(--fs-body-font-size);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
&.text-box-size-large {
|
|
287
|
+
& :is(input, .content-after, .content-before) {
|
|
288
|
+
padding: 0.625rem 0.625rem;
|
|
289
|
+
font-size: var(--fs-subtitle2-font-size);
|
|
290
|
+
}
|
|
291
|
+
& :is(.content-after, .content-before) {
|
|
292
|
+
font-size: var(--fs-body-font-size);
|
|
293
|
+
}
|
|
294
|
+
& :global(.clear-button:last-of-type) {
|
|
295
|
+
margin-right: 0.3125rem;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TextBoxProps } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* This is a implementation of Fluent UI TextBox component. The TextBox component is a customizable input element that allows users to enter text. It is designed to be consistent with the Fluent Design System.
|
|
4
|
+
*
|
|
5
|
+
* - Usage:
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <script>
|
|
8
|
+
* import { TextBox } from 'fluentui-svelte';
|
|
9
|
+
* </script>
|
|
10
|
+
*
|
|
11
|
+
* <TextBox type="text" placeholder="Enter your name" />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare const TextBox: import("svelte").Component<TextBoxProps, {}, "ref" | "value" | "wrapperRef">;
|
|
15
|
+
type TextBox = ReturnType<typeof TextBox>;
|
|
16
|
+
export default TextBox;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
import type { Sizes } from '../../types/index.js';
|
|
4
|
+
export type TextBoxTypes = 'text' | 'search' | 'email' | 'url' | 'tel' | 'password' | 'number';
|
|
5
|
+
/** @propsmith TextBoxProps */
|
|
6
|
+
export type TextBoxProps = {
|
|
7
|
+
/** The type of the input element.
|
|
8
|
+
* @default 'text'
|
|
9
|
+
*/
|
|
10
|
+
type?: TextBoxTypes;
|
|
11
|
+
/** The current value of the input.
|
|
12
|
+
* @type string | number
|
|
13
|
+
* @bindable
|
|
14
|
+
*/
|
|
15
|
+
value?: string | number;
|
|
16
|
+
/** The DOM reference of the wrapper element.
|
|
17
|
+
* @bindable
|
|
18
|
+
*/
|
|
19
|
+
wrapperRef?: HTMLDivElement;
|
|
20
|
+
/** The DOM reference of the input element.
|
|
21
|
+
* @bindable
|
|
22
|
+
*/
|
|
23
|
+
ref?: HTMLInputElement;
|
|
24
|
+
/** The placeholder text for the input.
|
|
25
|
+
* @default 'Fluent TextBox'
|
|
26
|
+
*/
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Whether to hide the extra action buttons in the input. */
|
|
29
|
+
hideActionButtons?: boolean;
|
|
30
|
+
/** Make the input fill the full width of the container. */
|
|
31
|
+
justify?: boolean;
|
|
32
|
+
/** Content rendered before the input, inside the wrapper.
|
|
33
|
+
* @type string | Snippet | Component
|
|
34
|
+
*/
|
|
35
|
+
contentBefore?: string | Snippet | Component;
|
|
36
|
+
/** Content rendered after the input, inside the wrapper.
|
|
37
|
+
* @type string | Snippet | Component
|
|
38
|
+
*/
|
|
39
|
+
contentAfter?: string | Snippet | Component;
|
|
40
|
+
/** The size of the input element.
|
|
41
|
+
* @default 'medium'
|
|
42
|
+
*/
|
|
43
|
+
size?: Sizes;
|
|
44
|
+
/** Occurs when content changes in the text box. */
|
|
45
|
+
textChanged?: (e: InputEvent, text: string) => void;
|
|
46
|
+
/** The QuerySubmitted event occurs when:
|
|
47
|
+
* 1. The input type is 'search'.
|
|
48
|
+
* 2. While the focus is in the text box, press Enter or click the query icon.
|
|
49
|
+
* @type (e: MouseEvent | KeyboardEvent, query: string) => void
|
|
50
|
+
*/
|
|
51
|
+
querySubmitted?: (e: MouseEvent | KeyboardEvent, query: string) => void;
|
|
52
|
+
/** Occurs when the clear button is clicked. */
|
|
53
|
+
onClear?: (e: MouseEvent) => void;
|
|
54
|
+
/** The children elements to render inside the input. */
|
|
55
|
+
children?: Snippet;
|
|
56
|
+
/** The attributes to apply to the wrapper element.
|
|
57
|
+
* @type HTMLAttributes
|
|
58
|
+
*/
|
|
59
|
+
wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
|
|
60
|
+
} & Omit<HTMLInputAttributes, 'size'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# TextArea
|
|
2
|
+
|
|
3
|
+
Textarea allows the user to enter and edit multiline text.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { TextArea } from 'fluentui-svelte';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<TextArea placeholder="Type your message here..." />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Component API
|
|
16
|
+
|
|
17
|
+
A brief explanation of the props that really need explaining. You can see the rest of the props in the Component Props table below.
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### Placeholder
|
|
22
|
+
|
|
23
|
+
The `placeholder` prop sets the placeholder text for the textarea, providing a hint to users about what to enter.
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<TextArea placeholder="Type your message here..." />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Resize
|
|
30
|
+
|
|
31
|
+
The `resize` prop controls whether the textarea can be resized by the user. It can be set to `none`, `both`, `horizontal`, or `vertical`. This allows you to control the resizing behavior of the textarea.
|
|
32
|
+
|
|
33
|
+
```svelte
|
|
34
|
+
<TextArea resize="none" placeholder="No resize" />
|
|
35
|
+
<TextArea resize="vertical" placeholder="Vertical resize" />
|
|
36
|
+
<TextArea resize="both" placeholder="Resize both" />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### On Change
|
|
40
|
+
|
|
41
|
+
The `onChange` event is triggered whenever the content of the textarea changes. This can be used to react to user input in real-time, such as validating input or updating other parts of the UI.
|
|
42
|
+
|
|
43
|
+
```svelte
|
|
44
|
+
<TextArea onChange={(e) => console.log(e)} placeholder="Type..." />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Component Props
|
|
48
|
+
|
|
49
|
+
| Name | Type | Description |
|
|
50
|
+
| ------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
51
|
+
| `placeholder` | `string` | The placeholder text for the textarea. |
|
|
52
|
+
| `resize` | `string` | Controls the resizing behavior of the textarea. Possible values: `'none'`, `'both'`, `'horizontal'`, `'vertical'`. |
|
|
53
|
+
| `onChange` | `function` | Event handler for when the content of the textarea changes. |
|
|
54
|
+
| `element` | | The DOM reference of the textarea element. |
|
|
55
|
+
| Element Attributes | | All other attributes that can be applied to the textarea element. |
|