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,151 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { PREFIX } from '../../internal/constants.js';
|
|
3
|
+
import { invokeHandlers } from '../../internal/index.js';
|
|
4
|
+
import type { TextAreaProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
const FALLBACK_ID = $props.id();
|
|
7
|
+
const COMPONENT_NAME = 'textarea';
|
|
8
|
+
const ID = `${PREFIX}${COMPONENT_NAME}-${FALLBACK_ID}`;
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
id = ID,
|
|
12
|
+
name = id,
|
|
13
|
+
value = $bindable(''),
|
|
14
|
+
ref = $bindable(),
|
|
15
|
+
resize = 'vertical',
|
|
16
|
+
style,
|
|
17
|
+
wrapperAttributes,
|
|
18
|
+
onchange,
|
|
19
|
+
disabled = false,
|
|
20
|
+
wrapperRef = $bindable(),
|
|
21
|
+
...attributes
|
|
22
|
+
}: TextAreaProps = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!--
|
|
26
|
+
@component
|
|
27
|
+
A textarea allows users to enter and edit multi-line text. It supports resizing, placeholder text, and disabled/read-only states.
|
|
28
|
+
|
|
29
|
+
- Usage:
|
|
30
|
+
```tsx
|
|
31
|
+
<script>
|
|
32
|
+
import { TextArea } from 'fluentui-svelte';
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<TextArea placeholder="Enter text..." />
|
|
36
|
+
<TextArea resize="none" disabled />
|
|
37
|
+
```
|
|
38
|
+
-->
|
|
39
|
+
<div class="fs-textarea" {...wrapperAttributes} bind:this={wrapperRef}>
|
|
40
|
+
<textarea
|
|
41
|
+
{name}
|
|
42
|
+
{id}
|
|
43
|
+
{disabled}
|
|
44
|
+
onchange={(e) => invokeHandlers(e, [disabled], [onchange])}
|
|
45
|
+
style="resize: {resize}; {style}"
|
|
46
|
+
bind:this={ref}
|
|
47
|
+
bind:value
|
|
48
|
+
{...attributes}></textarea>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<style>
|
|
52
|
+
.fs-textarea {
|
|
53
|
+
display: flex;
|
|
54
|
+
position: relative;
|
|
55
|
+
border-radius: var(--fs-control-border-radius);
|
|
56
|
+
background: var(--fs-control-fill-default);
|
|
57
|
+
border: none;
|
|
58
|
+
max-width: 100%;
|
|
59
|
+
width: fit-content;
|
|
60
|
+
& textarea {
|
|
61
|
+
appearance: none;
|
|
62
|
+
background: transparent;
|
|
63
|
+
outline: none;
|
|
64
|
+
border: none;
|
|
65
|
+
margin: 0;
|
|
66
|
+
z-index: 1;
|
|
67
|
+
color: var(--fs-text-primary);
|
|
68
|
+
padding: 0.375rem 0.625rem;
|
|
69
|
+
min-height: 100px;
|
|
70
|
+
min-width: 250px;
|
|
71
|
+
flex-basis: fill;
|
|
72
|
+
/* Only for Edge, Chrome */
|
|
73
|
+
field-sizing: content;
|
|
74
|
+
&::placeholder {
|
|
75
|
+
color: var(--fs-text-secondary);
|
|
76
|
+
}
|
|
77
|
+
&:read-only {
|
|
78
|
+
color: var(--fs-text-secondary);
|
|
79
|
+
resize: none !important;
|
|
80
|
+
}
|
|
81
|
+
&::-ms-reveal,
|
|
82
|
+
&::-ms-clear {
|
|
83
|
+
display: none;
|
|
84
|
+
}
|
|
85
|
+
&::-webkit-outer-spin-button,
|
|
86
|
+
&::-webkit-inner-spin-button {
|
|
87
|
+
-webkit-appearance: none;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
&:before {
|
|
91
|
+
content: '';
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
width: calc(100% + 0.125rem);
|
|
94
|
+
height: calc(100% + 0.125rem);
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: -0.063rem;
|
|
97
|
+
left: -0.063rem;
|
|
98
|
+
padding: 0.063rem;
|
|
99
|
+
border-radius: 5px;
|
|
100
|
+
mask:
|
|
101
|
+
linear-gradient(#fff 0 0) content-box,
|
|
102
|
+
linear-gradient(#fff 0 0);
|
|
103
|
+
mask-composite: exclude;
|
|
104
|
+
background: var(--fs-elevation-text-border);
|
|
105
|
+
z-index: 1;
|
|
106
|
+
}
|
|
107
|
+
&:after {
|
|
108
|
+
content: '';
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
width: 0;
|
|
111
|
+
height: 10px;
|
|
112
|
+
border-radius: 0px 0px 5px 5px;
|
|
113
|
+
position: absolute;
|
|
114
|
+
bottom: -0.063rem;
|
|
115
|
+
left: calc(50% - 0.063rem);
|
|
116
|
+
clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0% 100%);
|
|
117
|
+
background: transparent;
|
|
118
|
+
transition:
|
|
119
|
+
width var(--fs-fast-duration) var(--fs-point-to-point),
|
|
120
|
+
left var(--fs-fast-duration) var(--fs-point-to-point);
|
|
121
|
+
z-index: 2;
|
|
122
|
+
}
|
|
123
|
+
&:hover {
|
|
124
|
+
background: var(--fs-control-fill-secondary);
|
|
125
|
+
}
|
|
126
|
+
&:has(textarea:focus-visible):after {
|
|
127
|
+
width: calc(100% + 0.125rem);
|
|
128
|
+
left: -0.063rem;
|
|
129
|
+
background: var(--fs-accent-fill-default);
|
|
130
|
+
}
|
|
131
|
+
&:has(textarea:focus) {
|
|
132
|
+
background: var(--fs-control-fill-input-active);
|
|
133
|
+
& textarea::placeholder {
|
|
134
|
+
color: var(--fs-text-tertiary);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
&:has(textarea:disabled) {
|
|
138
|
+
background: var(--fs-control-fill-disabled);
|
|
139
|
+
& textarea {
|
|
140
|
+
cursor: not-allowed;
|
|
141
|
+
resize: none;
|
|
142
|
+
}
|
|
143
|
+
& textarea::placeholder {
|
|
144
|
+
color: var(--fs-text-disabled);
|
|
145
|
+
}
|
|
146
|
+
&::before {
|
|
147
|
+
background: var(--fs-control-stroke-default);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TextAreaProps } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A textarea allows users to enter and edit multi-line text. It supports resizing, placeholder text, and disabled/read-only states.
|
|
4
|
+
*
|
|
5
|
+
* - Usage:
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <script>
|
|
8
|
+
* import { TextArea } from 'fluentui-svelte';
|
|
9
|
+
* </script>
|
|
10
|
+
*
|
|
11
|
+
* <TextArea placeholder="Enter text..." />
|
|
12
|
+
* <TextArea resize="none" disabled />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const Textarea: import("svelte").Component<TextAreaProps, {}, "ref" | "value" | "wrapperRef">;
|
|
16
|
+
type Textarea = ReturnType<typeof Textarea>;
|
|
17
|
+
export default Textarea;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HTMLAttributes, SvelteHTMLElements } from 'svelte/elements';
|
|
2
|
+
/** @propsmith TextAreaProps */
|
|
3
|
+
export type TextAreaProps = {
|
|
4
|
+
/** The current value of the textarea.
|
|
5
|
+
* @default ''
|
|
6
|
+
* @bindable
|
|
7
|
+
*/
|
|
8
|
+
value?: string;
|
|
9
|
+
/** The DOM reference of the textarea element.
|
|
10
|
+
* @bindable
|
|
11
|
+
*/
|
|
12
|
+
ref?: HTMLElement;
|
|
13
|
+
/** The placeholder text for the textarea. */
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
/** Configures the resize behavior of the textarea.
|
|
16
|
+
* @default 'vertical'
|
|
17
|
+
*/
|
|
18
|
+
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
|
|
19
|
+
/** Callback function for the change event. */
|
|
20
|
+
onChange?: (e: Event) => void;
|
|
21
|
+
/** Disables the user interaction.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/** The attributes to spread on the wrapper element.
|
|
26
|
+
* @type HTMLAttributes
|
|
27
|
+
*/
|
|
28
|
+
wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
|
|
29
|
+
/** The DOM reference of the wrapper element.
|
|
30
|
+
* @bindable
|
|
31
|
+
*/
|
|
32
|
+
wrapperRef?: HTMLDivElement;
|
|
33
|
+
} & SvelteHTMLElements['textarea'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Time Picker
|
|
2
|
+
|
|
3
|
+
An input for selecting a time from carousel-style hour, minute, and second columns, in 12- or 24-hour format.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { TimePicker } from 'fluentui-svelte';
|
|
10
|
+
|
|
11
|
+
let value = $state('');
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<TimePicker bind:value format={12} />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Clock Format
|
|
20
|
+
|
|
21
|
+
Use the `format` prop to choose between a 24-hour clock (`24`) and a 12-hour clock with an AM/PM column (`12`).
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<TimePicker format={24} />
|
|
25
|
+
<TimePicker format={12} />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Hiding Columns
|
|
29
|
+
|
|
30
|
+
Use `hideHours`, `hideMinutes`, or `hideSeconds` to hide individual columns. By default the seconds column is shown.
|
|
31
|
+
|
|
32
|
+
```svelte
|
|
33
|
+
<TimePicker format={24} hideSeconds />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Component Props
|
|
37
|
+
|
|
38
|
+
| Name | Type | Description |
|
|
39
|
+
| -------------- | --------------------------- | ------------------------------------------------------------------------------- |
|
|
40
|
+
| `value` | bindable `string` | Selected time as 24h `HH:mm` or `HH:mm:ss` (matches `<input type="time">`). |
|
|
41
|
+
| `format` | `12 \| 24` | Clock format: `24` (00–23) or `12` (01–12 with an AM/PM column). Default: `24`. |
|
|
42
|
+
| `open` | bindable `boolean` | Whether the picker flyout is open. |
|
|
43
|
+
| `hideHours` | `boolean` | Hide the hours column. |
|
|
44
|
+
| `hideMinutes` | `boolean` | Hide the minutes column. |
|
|
45
|
+
| `hideSeconds` | `boolean` | Hide the seconds column. |
|
|
46
|
+
| `element` | bindable `HTMLElement` | The DOM reference of the time picker root element. |
|
|
47
|
+
| `inputElement` | bindable `HTMLInputElement` | The DOM reference of the underlying input element. |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TimePicker } from './time-picker.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TimePicker } from './time-picker.svelte';
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TimePickerProps } from './types.js';
|
|
3
|
+
import { Flyout, Button, Divider } from '../../index.js';
|
|
4
|
+
import { on } from 'svelte/events';
|
|
5
|
+
import { tick } from 'svelte';
|
|
6
|
+
import { PREFIX } from '../../internal/constants.js';
|
|
7
|
+
import { floating } from '../../internal/index.js';
|
|
8
|
+
import { flip, hide, offset, shift } from '@floating-ui/dom';
|
|
9
|
+
import DynamicCarousel from '../../internal/components/dynamic-carousel/dynamic-carousel.svelte';
|
|
10
|
+
import { CheckmarkRegular, DismissRegular } from 'fluentui-icons-svelte';
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
format = 24,
|
|
14
|
+
value = $bindable(''),
|
|
15
|
+
open = $bindable(false),
|
|
16
|
+
hideHours = false,
|
|
17
|
+
hideMinutes = false,
|
|
18
|
+
hideSeconds = false,
|
|
19
|
+
element = $bindable(),
|
|
20
|
+
wrapperRef = $bindable(),
|
|
21
|
+
wrapperAttributes,
|
|
22
|
+
inputElement = $bindable(),
|
|
23
|
+
inputProps,
|
|
24
|
+
popupLabel = 'Choose a time',
|
|
25
|
+
...attributes
|
|
26
|
+
}: TimePickerProps = $props();
|
|
27
|
+
|
|
28
|
+
const FALLBACK_ID = $props.id();
|
|
29
|
+
const POPUP_ID = `${PREFIX}timepicker-${FALLBACK_ID}-popup`;
|
|
30
|
+
|
|
31
|
+
let popupRef: HTMLElement | undefined = $state();
|
|
32
|
+
|
|
33
|
+
/** Closing always hands the focus back, so the keyboard never lands nowhere. */
|
|
34
|
+
function closePopup() {
|
|
35
|
+
open = false;
|
|
36
|
+
element?.focus();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Escape has to work from inside the popup too, and the popup is not a descendant
|
|
40
|
+
// of the trigger, so the listener goes on the document.
|
|
41
|
+
$effect(() => {
|
|
42
|
+
if (!open) return;
|
|
43
|
+
|
|
44
|
+
return on(document, 'keydown', (event: KeyboardEvent) => {
|
|
45
|
+
if (event.key !== 'Escape') return;
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
closePopup();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Move into the dialog on open: the first wheel, so the arrows work straight away.
|
|
52
|
+
$effect(() => {
|
|
53
|
+
if (!open || !popupRef) return;
|
|
54
|
+
|
|
55
|
+
tick().then(() => {
|
|
56
|
+
(popupRef?.querySelector<HTMLElement>('[role="listbox"]') ?? popupRef)?.focus();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
type Column = 'hour' | 'minute' | 'second' | 'meridiem';
|
|
61
|
+
|
|
62
|
+
const pad = (n: number) => n.toString().padStart(2, '0');
|
|
63
|
+
const HOURS_24 = Array.from({ length: 24 }, (_, i) => pad(i));
|
|
64
|
+
const HOURS_12 = Array.from({ length: 12 }, (_, i) => pad(i === 0 ? 12 : i)); // 12, 01 … 11
|
|
65
|
+
const SIXTY = Array.from({ length: 60 }, (_, i) => pad(i));
|
|
66
|
+
const MERIDIEM = ['AM', 'PM'];
|
|
67
|
+
const LABELS: Record<Column, string> = {
|
|
68
|
+
hour: 'Hour',
|
|
69
|
+
minute: 'Minute',
|
|
70
|
+
second: 'Second',
|
|
71
|
+
meridiem: 'AM/PM'
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const hour12 = $derived(format === 12);
|
|
75
|
+
|
|
76
|
+
// Working selection — canonical 24h values, synced with `value` while the popup is closed.
|
|
77
|
+
let hour = $state(new Date().getHours()); // 0-23
|
|
78
|
+
let minute = $state(new Date().getMinutes()); // 0-59
|
|
79
|
+
let second = $state(new Date().getSeconds()); // 0-59
|
|
80
|
+
|
|
81
|
+
const isPM = $derived(hour >= 12);
|
|
82
|
+
// 12h wheel index: hour % 12 (0 → "12", 1 → "01", …, 11 → "11").
|
|
83
|
+
const hour12Index = $derived(hour % 12);
|
|
84
|
+
|
|
85
|
+
// Columns to render, filtered by the hide* flags; AM/PM only in 12h mode.
|
|
86
|
+
const columns = $derived.by<Column[]>(() => {
|
|
87
|
+
const cols: Column[] = [];
|
|
88
|
+
if (!hideHours) cols.push('hour');
|
|
89
|
+
if (!hideMinutes) cols.push('minute');
|
|
90
|
+
if (!hideSeconds) cols.push('second');
|
|
91
|
+
if (hour12) cols.push('meridiem');
|
|
92
|
+
return cols;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const hasValue = $derived(/^\d{2}:\d{2}(:\d{2})?$/.test(value ?? ''));
|
|
96
|
+
|
|
97
|
+
function parseValue(v: string) {
|
|
98
|
+
const m = /^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(v ?? '');
|
|
99
|
+
const t = new Date();
|
|
100
|
+
const raw = m
|
|
101
|
+
? { h: +m[1], mi: +m[2], s: m[3] ? +m[3] : 0 }
|
|
102
|
+
: { h: t.getHours(), mi: t.getMinutes(), s: t.getSeconds() };
|
|
103
|
+
return {
|
|
104
|
+
h: Math.min(23, Math.max(0, raw.h)),
|
|
105
|
+
mi: Math.min(59, Math.max(0, raw.mi)),
|
|
106
|
+
s: Math.min(59, Math.max(0, raw.s))
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Keep the working selection synced with `value` while the popup is closed.
|
|
111
|
+
$effect(() => {
|
|
112
|
+
if (!open) {
|
|
113
|
+
const { h, mi, s } = parseValue(value);
|
|
114
|
+
hour = h;
|
|
115
|
+
minute = mi;
|
|
116
|
+
second = s;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// 12h wheel index → canonical hour, keeping the current meridiem.
|
|
121
|
+
function setHour12(i: number) {
|
|
122
|
+
hour = (i % 12) + (isPM ? 12 : 0);
|
|
123
|
+
}
|
|
124
|
+
// AM/PM wheel index (0 = AM, 1 = PM) → canonical hour, keeping the clock hour.
|
|
125
|
+
function setMeridiem(i: number) {
|
|
126
|
+
hour = (hour % 12) + (i === 1 ? 12 : 0);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function confirm() {
|
|
130
|
+
value = `${pad(hour)}:${pad(minute)}${hideSeconds ? '' : `:${pad(second)}`}`;
|
|
131
|
+
closePopup();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function cancel() {
|
|
135
|
+
closePopup();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Trigger label per column: the live selection while open, the committed value once set,
|
|
139
|
+
// otherwise the placeholder column name.
|
|
140
|
+
function display(col: Column): string {
|
|
141
|
+
if (!open && !hasValue) return LABELS[col];
|
|
142
|
+
if (col === 'hour') return hour12 ? HOURS_12[hour12Index] : pad(hour);
|
|
143
|
+
if (col === 'minute') return pad(minute);
|
|
144
|
+
if (col === 'second') return pad(second);
|
|
145
|
+
return isPM ? 'PM' : 'AM';
|
|
146
|
+
}
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
<div class="fs-time-picker-wrapper" bind:this={wrapperRef} {...wrapperAttributes}>
|
|
150
|
+
<button
|
|
151
|
+
type="button"
|
|
152
|
+
class="fs-time-picker"
|
|
153
|
+
aria-haspopup="dialog"
|
|
154
|
+
aria-expanded={open}
|
|
155
|
+
aria-controls={open ? POPUP_ID : undefined}
|
|
156
|
+
onclick={() => (open = !open)}
|
|
157
|
+
bind:this={element}
|
|
158
|
+
{...attributes}
|
|
159
|
+
>
|
|
160
|
+
{#each columns as col, idx (col)}
|
|
161
|
+
{#if idx > 0}
|
|
162
|
+
<Divider as="span" vertical aria-hidden="true" />
|
|
163
|
+
{/if}
|
|
164
|
+
<span class="picker-content">{display(col)}</span>
|
|
165
|
+
{/each}
|
|
166
|
+
</button>
|
|
167
|
+
|
|
168
|
+
<!-- Carries the value into a form. -->
|
|
169
|
+
<input type="time" hidden step={hideSeconds ? undefined : 1} {value} bind:this={inputElement} {...inputProps} />
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
{#if open}
|
|
173
|
+
<Flyout
|
|
174
|
+
{@attach floating(element, {
|
|
175
|
+
placement: 'bottom',
|
|
176
|
+
middleware: [
|
|
177
|
+
offset(({ rects }) => {
|
|
178
|
+
return -rects.reference.height / 2 - rects.floating.height / 2;
|
|
179
|
+
}),
|
|
180
|
+
flip(),
|
|
181
|
+
shift(),
|
|
182
|
+
hide()
|
|
183
|
+
],
|
|
184
|
+
strategy: 'fixed'
|
|
185
|
+
})}
|
|
186
|
+
reference={element}
|
|
187
|
+
id={POPUP_ID}
|
|
188
|
+
role="dialog"
|
|
189
|
+
aria-modal="true"
|
|
190
|
+
aria-label={popupLabel}
|
|
191
|
+
tabindex={-1}
|
|
192
|
+
bind:ref={popupRef}
|
|
193
|
+
class="time-picker-flyout"
|
|
194
|
+
>
|
|
195
|
+
<div class="carousel-wrapper">
|
|
196
|
+
<div class="selection-bar"></div>
|
|
197
|
+
{#each columns as col (col)}
|
|
198
|
+
<div class="carousel-col col-{col}">
|
|
199
|
+
{#if col === 'hour'}
|
|
200
|
+
{#if hour12}
|
|
201
|
+
<DynamicCarousel values={HOURS_12} selectedIndex={hour12Index} onSelected={(_, i) => setHour12(i)} />
|
|
202
|
+
{:else}
|
|
203
|
+
<DynamicCarousel values={HOURS_24} selectedIndex={hour} onSelected={(_, i) => (hour = i)} />
|
|
204
|
+
{/if}
|
|
205
|
+
{:else if col === 'minute'}
|
|
206
|
+
<DynamicCarousel values={SIXTY} selectedIndex={minute} onSelected={(_, i) => (minute = i)} />
|
|
207
|
+
{:else if col === 'second'}
|
|
208
|
+
<DynamicCarousel values={SIXTY} selectedIndex={second} onSelected={(_, i) => (second = i)} />
|
|
209
|
+
{:else}
|
|
210
|
+
<DynamicCarousel
|
|
211
|
+
values={MERIDIEM}
|
|
212
|
+
selectedIndex={isPM ? 1 : 0}
|
|
213
|
+
infinite={false}
|
|
214
|
+
inertia={false}
|
|
215
|
+
onSelected={(_, i) => setMeridiem(i)}
|
|
216
|
+
/>
|
|
217
|
+
{/if}
|
|
218
|
+
</div>
|
|
219
|
+
{/each}
|
|
220
|
+
</div>
|
|
221
|
+
<div class="action-bar">
|
|
222
|
+
<Button class="justify" appearance="subtle" aria-label="Confirm" onclick={confirm}>
|
|
223
|
+
<CheckmarkRegular />
|
|
224
|
+
</Button>
|
|
225
|
+
<Button class="justify" appearance="subtle" aria-label="Cancel" onclick={cancel}>
|
|
226
|
+
<DismissRegular />
|
|
227
|
+
</Button>
|
|
228
|
+
</div>
|
|
229
|
+
</Flyout>
|
|
230
|
+
{/if}
|
|
231
|
+
|
|
232
|
+
<style>
|
|
233
|
+
.fs-time-picker-wrapper {
|
|
234
|
+
display: contents;
|
|
235
|
+
}
|
|
236
|
+
.fs-time-picker {
|
|
237
|
+
display: flex;
|
|
238
|
+
position: relative;
|
|
239
|
+
border-radius: var(--fs-control-border-radius);
|
|
240
|
+
font-size: var(--fs-body-font-size);
|
|
241
|
+
line-height: var(--fs-body-line-height);
|
|
242
|
+
color: var(--fs-text-primary);
|
|
243
|
+
background: var(--fs-control-fill-default);
|
|
244
|
+
border: none;
|
|
245
|
+
padding: 1px;
|
|
246
|
+
cursor: pointer;
|
|
247
|
+
outline: none;
|
|
248
|
+
user-select: none;
|
|
249
|
+
&:after {
|
|
250
|
+
content: '';
|
|
251
|
+
inset: 0;
|
|
252
|
+
position: absolute;
|
|
253
|
+
padding: 0.063rem;
|
|
254
|
+
mask:
|
|
255
|
+
linear-gradient(#fff 0 0) content-box,
|
|
256
|
+
linear-gradient(#fff 0 0);
|
|
257
|
+
mask-composite: exclude;
|
|
258
|
+
border-radius: inherit;
|
|
259
|
+
}
|
|
260
|
+
&::after {
|
|
261
|
+
background: var(--fs-elevation-control-border);
|
|
262
|
+
}
|
|
263
|
+
&:hover {
|
|
264
|
+
background: var(--fs-control-fill-secondary);
|
|
265
|
+
}
|
|
266
|
+
&:active {
|
|
267
|
+
color: var(--fs-text-secondary);
|
|
268
|
+
&::after {
|
|
269
|
+
background: var(--fs-control-stroke-default);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
&:disabled,
|
|
273
|
+
&.disabled {
|
|
274
|
+
background: var(--fs-control-fill-disabled) !important;
|
|
275
|
+
color: var(--fs-text-disabled) !important;
|
|
276
|
+
&::after {
|
|
277
|
+
background: var(--fs-control-stroke-default) !important;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
& .picker-content {
|
|
281
|
+
display: flex;
|
|
282
|
+
align-items: center;
|
|
283
|
+
padding: 0.375rem 1.626rem 0.5rem 1.626rem;
|
|
284
|
+
&:first-child {
|
|
285
|
+
padding-right: 2rem;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
:global(.time-picker-flyout) {
|
|
290
|
+
flex-direction: column;
|
|
291
|
+
position: fixed !important;
|
|
292
|
+
top: 0;
|
|
293
|
+
left: 0;
|
|
294
|
+
max-width: min-content;
|
|
295
|
+
padding: 0 !important;
|
|
296
|
+
& .wrapper {
|
|
297
|
+
gap: 0 !important;
|
|
298
|
+
}
|
|
299
|
+
& .carousel-wrapper {
|
|
300
|
+
display: flex;
|
|
301
|
+
position: relative;
|
|
302
|
+
width: max-content;
|
|
303
|
+
min-width: max-content;
|
|
304
|
+
padding: 0 0.4rem !important;
|
|
305
|
+
}
|
|
306
|
+
& .carousel-col {
|
|
307
|
+
width: 64px;
|
|
308
|
+
& :global(.fs-dynamic-carousel) {
|
|
309
|
+
width: 100%;
|
|
310
|
+
}
|
|
311
|
+
&:not(:last-child) :global(.fs-dynamic-carousel-track) {
|
|
312
|
+
border-right: 1px solid var(--fs-control-stroke-default);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
& .selection-bar {
|
|
316
|
+
position: absolute;
|
|
317
|
+
top: 50%;
|
|
318
|
+
left: 0.4rem;
|
|
319
|
+
width: calc(100% - 0.8rem);
|
|
320
|
+
height: 40px;
|
|
321
|
+
background: var(--fs-accent-fill-default);
|
|
322
|
+
transform: translateY(-50%);
|
|
323
|
+
border-radius: var(--fs-control-border-radius);
|
|
324
|
+
z-index: -1;
|
|
325
|
+
}
|
|
326
|
+
& .action-bar {
|
|
327
|
+
display: flex;
|
|
328
|
+
width: 100%;
|
|
329
|
+
padding: 0.2rem;
|
|
330
|
+
border-top: 1px solid var(--fs-control-stroke-default);
|
|
331
|
+
& :global(.justify) {
|
|
332
|
+
flex: 1;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
</style>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { HTMLAttributes, HTMLButtonAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
/** @propsmith TimePickerProps */
|
|
3
|
+
export type TimePickerProps = {
|
|
4
|
+
/** Selected time as 24h `HH:mm` or `HH:mm:ss` (matches `<input type="time">`).
|
|
5
|
+
* @default ''
|
|
6
|
+
* @bindable
|
|
7
|
+
*/
|
|
8
|
+
value?: string;
|
|
9
|
+
/** Clock format: `24` (00-23) or `12` (01-12 with an AM/PM column).
|
|
10
|
+
* @default 24
|
|
11
|
+
*/
|
|
12
|
+
format?: 12 | 24;
|
|
13
|
+
/** Controls the open state of the picker.
|
|
14
|
+
* @default false
|
|
15
|
+
* @bindable
|
|
16
|
+
*/
|
|
17
|
+
open?: boolean;
|
|
18
|
+
/** Removes the hour column.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
hideHours?: boolean;
|
|
22
|
+
/** Removes the minute column.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
hideMinutes?: boolean;
|
|
26
|
+
/** Removes the second column.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
hideSeconds?: boolean;
|
|
30
|
+
/** The DOM reference of the trigger button.
|
|
31
|
+
* @bindable
|
|
32
|
+
*/
|
|
33
|
+
element?: HTMLButtonElement;
|
|
34
|
+
/** The DOM reference of the element wrapping the trigger and its input.
|
|
35
|
+
* @bindable
|
|
36
|
+
*/
|
|
37
|
+
wrapperRef?: HTMLDivElement;
|
|
38
|
+
/** The attributes to spread on the wrapper element.
|
|
39
|
+
* @type HTMLAttributes
|
|
40
|
+
*/
|
|
41
|
+
wrapperAttributes?: HTMLAttributes<HTMLDivElement>;
|
|
42
|
+
/** The DOM reference of the underlying input element.
|
|
43
|
+
* @bindable
|
|
44
|
+
*/
|
|
45
|
+
inputElement?: HTMLInputElement;
|
|
46
|
+
/** HTML attributes for the underlying input element. Give it a `name` to submit the
|
|
47
|
+
* value with a form.
|
|
48
|
+
*/
|
|
49
|
+
inputProps?: HTMLInputAttributes;
|
|
50
|
+
/** The accessible name of the popup, which is announced as a dialog.
|
|
51
|
+
* @default 'Choose a time'
|
|
52
|
+
*/
|
|
53
|
+
popupLabel?: string;
|
|
54
|
+
} & HTMLButtonAttributes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Toggle Switch
|
|
2
|
+
|
|
3
|
+
A toggle switch represents a physical switch that allows someone to choose between two mutually exclusive options. For example, 'On/Off' and 'Show/Hide'. Choosing an option should produce an immediate result.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { ToggleSwitch } from 'fluentui-svelte';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<ToggleSwitch />
|
|
13
|
+
<ToggleSwitch label="Toggle me" />
|
|
14
|
+
<ToggleSwitch label="I'm disabled" disabled />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### States
|
|
20
|
+
|
|
21
|
+
A toggle switch can be labeled, checked, or disabled.
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<ToggleSwitch label="Off" />
|
|
25
|
+
<ToggleSwitch label="On" checked />
|
|
26
|
+
<ToggleSwitch label="Disabled" disabled />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Component Props
|
|
30
|
+
|
|
31
|
+
| Name | Type | Description |
|
|
32
|
+
| ------------------ | --------------------- | ------------------------------------------------------------ |
|
|
33
|
+
| `ref` | `HTMLInputElement` | Get the DOM reference of the input element. |
|
|
34
|
+
| `label` | `string` | The label for the toggle switch. |
|
|
35
|
+
| `labelAttributes` | `HTMLLabelAttributes` | Attributes to be spread on the label wrapper element. |
|
|
36
|
+
| `labelElement` | `HTMLLabelElement` | Get the DOM reference of the label element. |
|
|
37
|
+
| `disabled` | `boolean` | Whether the toggle switch is disabled. |
|
|
38
|
+
| `checked` | `boolean` | Whether the toggle switch is checked (on). |
|
|
39
|
+
| Element Attributes | `object` | Additional attributes to apply to the toggle switch element. |
|