@placeholderco/placeholder-ui 1.0.3 → 1.0.6
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 +26 -26
- package/README.md +179 -179
- package/dist/display/Alert.svelte +179 -179
- package/dist/display/Avatar.svelte +166 -166
- package/dist/display/LinkCollection.svelte +161 -161
- package/dist/display/Paper.svelte +118 -118
- package/dist/form/Autocomplete.svelte +223 -191
- package/dist/form/Autocomplete.svelte.d.ts +3 -1
- package/dist/form/AutocompleteMulti.svelte +356 -0
- package/dist/form/AutocompleteMulti.svelte.d.ts +28 -0
- package/dist/form/Checkbox.svelte +201 -201
- package/dist/form/Chips.svelte +128 -128
- package/dist/form/ComboBox.svelte +158 -158
- package/dist/form/ComboBox.svelte.d.ts +1 -1
- package/dist/form/ComboBoxItemBuilder.svelte +460 -460
- package/dist/form/ComboBoxMulti.svelte +197 -197
- package/dist/form/ComboBoxMulti.svelte.d.ts +1 -1
- package/dist/form/CronBuilder.svelte +693 -693
- package/dist/form/DatePicker.svelte +672 -672
- package/dist/form/DateTimePicker.svelte +712 -712
- package/dist/form/FileInput.svelte +235 -235
- package/dist/form/FormGroup.svelte +68 -68
- package/dist/form/Number.svelte +238 -238
- package/dist/form/PasswordInput.svelte +252 -252
- package/dist/form/RadioGroup.svelte +210 -210
- package/dist/form/Rating.svelte +235 -235
- package/dist/form/SegmentedControl.svelte +149 -149
- package/dist/form/Select.svelte +590 -590
- package/dist/form/Select.svelte.d.ts +1 -1
- package/dist/form/SelectMulti.svelte +613 -613
- package/dist/form/SelectMulti.svelte.d.ts +1 -1
- package/dist/form/Slider.svelte +358 -358
- package/dist/form/Switch.svelte +147 -147
- package/dist/form/TextArea.svelte +148 -148
- package/dist/form/Textbox.svelte +228 -228
- package/dist/form/TimePicker.svelte +267 -267
- package/dist/icon/Icon.svelte +52 -52
- package/dist/icon/alert-octagon.svg +5 -5
- package/dist/icon/alert-triangle.svg +5 -5
- package/dist/icon/archive.svg +1 -1
- package/dist/icon/arrow-down.svg +1 -1
- package/dist/icon/arrow-left.svg +1 -1
- package/dist/icon/arrow-right.svg +1 -1
- package/dist/icon/arrow-up.svg +1 -1
- package/dist/icon/at.svg +1 -1
- package/dist/icon/bell.svg +1 -1
- package/dist/icon/bookmark.svg +1 -1
- package/dist/icon/calendar.svg +1 -1
- package/dist/icon/camera.svg +1 -1
- package/dist/icon/chart-bar.svg +1 -1
- package/dist/icon/chart-line.svg +1 -1
- package/dist/icon/chart-pie.svg +1 -1
- package/dist/icon/checkbox.svg +1 -1
- package/dist/icon/checklist.svg +1 -1
- package/dist/icon/circle-check.svg +1 -1
- package/dist/icon/circle-x.svg +1 -1
- package/dist/icon/clock.svg +1 -1
- package/dist/icon/credit-card.svg +1 -1
- package/dist/icon/dots-vertical.svg +1 -1
- package/dist/icon/dots.svg +1 -1
- package/dist/icon/external-link.svg +1 -1
- package/dist/icon/eye-off.svg +1 -1
- package/dist/icon/eye.svg +1 -1
- package/dist/icon/filter.svg +1 -1
- package/dist/icon/fingerprint.svg +1 -1
- package/dist/icon/flag.svg +1 -1
- package/dist/icon/heart.svg +1 -1
- package/dist/icon/home.svg +1 -1
- package/dist/icon/key.svg +1 -1
- package/dist/icon/list-check.svg +1 -1
- package/dist/icon/login.svg +1 -1
- package/dist/icon/logout.svg +1 -1
- package/dist/icon/map-pin.svg +1 -1
- package/dist/icon/maximize.svg +1 -1
- package/dist/icon/microphone.svg +1 -1
- package/dist/icon/minimize.svg +1 -1
- package/dist/icon/note.svg +1 -1
- package/dist/icon/player-pause.svg +1 -1
- package/dist/icon/printer.svg +1 -1
- package/dist/icon/qrcode.svg +1 -1
- package/dist/icon/send.svg +1 -1
- package/dist/icon/settings.svg +1 -1
- package/dist/icon/share.svg +1 -1
- package/dist/icon/shopping-cart.svg +1 -1
- package/dist/icon/sort-ascending.svg +1 -1
- package/dist/icon/sort-descending.svg +1 -1
- package/dist/icon/star.svg +1 -1
- package/dist/icon/tag.svg +1 -1
- package/dist/icon/trending-down.svg +1 -1
- package/dist/icon/trending-up.svg +1 -1
- package/dist/icon/upload.svg +1 -1
- package/dist/icon/volume-off.svg +1 -1
- package/dist/icon/volume.svg +1 -1
- package/dist/icon/world.svg +1 -1
- package/dist/icon/zoom-in.svg +1 -1
- package/dist/icon/zoom-out.svg +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/AppShell.svelte +169 -169
- package/dist/layout/CustomNavbar.svelte +61 -61
- package/dist/layout/Navbar.svelte +206 -206
- package/dist/layout/NavbarItemDisplay.svelte +29 -29
- package/dist/layout/Sidenav.svelte +712 -712
- package/dist/styles/components.css +199 -199
- package/dist/styles/dark.css +146 -146
- package/dist/styles/index.css +116 -116
- package/dist/styles/reset.css +110 -110
- package/dist/styles/semantic.css +86 -86
- package/dist/styles/tokens.css +203 -197
- package/dist/styles/utilities.css +523 -523
- package/dist/ui/Accordion.svelte +289 -289
- package/dist/ui/ActionIcon.svelte +76 -76
- package/dist/ui/Badge.svelte +329 -279
- package/dist/ui/Breadcrumbs.svelte +131 -131
- package/dist/ui/Button.svelte +432 -370
- package/dist/ui/ButtonVariant.d.ts +1 -1
- package/dist/ui/Dialog.svelte +307 -307
- package/dist/ui/Drawer.svelte +524 -524
- package/dist/ui/Dropdown.svelte +97 -97
- package/dist/ui/Dropzone.svelte +122 -122
- package/dist/ui/Link.svelte +32 -32
- package/dist/ui/Loader.svelte +70 -70
- package/dist/ui/LoadingOverlay.svelte +53 -53
- package/dist/ui/Pagination.svelte +135 -135
- package/dist/ui/Popover.svelte +225 -225
- package/dist/ui/Progress.svelte +191 -191
- package/dist/ui/RingProgress.svelte +141 -141
- package/dist/ui/Skeleton.svelte +85 -85
- package/dist/ui/Stepper.svelte +355 -355
- package/dist/ui/Table.svelte +345 -345
- package/dist/ui/Tabs.svelte +146 -146
- package/dist/ui/ThemeSwitcher.svelte +39 -39
- package/dist/ui/Timeline.svelte +225 -225
- package/dist/ui/Toaster.svelte +6 -6
- package/dist/ui/Tooltip.svelte +434 -434
- package/package.json +14 -14
package/dist/form/Switch.svelte
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
// Sourced from https://svelte.dev/playground/d65a4e9f0ae74d1eb1b08d13e428af32?version=5.36.16, and updated from there
|
|
3
|
-
import FormGroup from './FormGroup.svelte';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
label: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
checked: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
description?: string;
|
|
11
|
-
containerClass?: string;
|
|
12
|
-
switchClass?: string;
|
|
13
|
-
onchange?: (value: boolean) => void;
|
|
14
|
-
showError?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
let { label, required = false, checked = $bindable(), disabled = false, containerClass, switchClass, onchange, showError }: Props = $props();
|
|
18
|
-
|
|
19
|
-
function handleClick(event: Event){
|
|
20
|
-
const target = event.target as HTMLElement
|
|
21
|
-
|
|
22
|
-
const state = target.getAttribute('aria-checked')
|
|
23
|
-
|
|
24
|
-
checked = !(state === 'true')
|
|
25
|
-
onchange?.(checked);
|
|
26
|
-
}
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<div class="switch-container {containerClass}">
|
|
30
|
-
<FormGroup {required} {label}>
|
|
31
|
-
<div class="s s--slider {switchClass} {required ? 'required' : ''}
|
|
32
|
-
{showError ? 'error' : ''}
|
|
33
|
-
{disabled ? 'disabled' : ''}">
|
|
34
|
-
<button
|
|
35
|
-
role="switch"
|
|
36
|
-
aria-checked={checked}
|
|
37
|
-
onclick={handleClick}
|
|
38
|
-
aria-labelledby="form-{label}"
|
|
39
|
-
class="{disabled ? 'disabled' : ''}"
|
|
40
|
-
{disabled}
|
|
41
|
-
>
|
|
42
|
-
</button>
|
|
43
|
-
</div>
|
|
44
|
-
<span class="slider"></span>
|
|
45
|
-
</FormGroup>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<style>
|
|
50
|
-
:root .switch-container {
|
|
51
|
-
--switch-accent-color: var(--pui-color-primary);
|
|
52
|
-
--switch-track-color: var(--pui-border-disabled);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
:global(.dark) .switch-container {
|
|
56
|
-
--switch-accent-color: var(--pui-color-primary);
|
|
57
|
-
--switch-track-color: var(--pui-color-gray-600);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.disabled button {
|
|
61
|
-
cursor: not-allowed;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/* Inner Design Option */
|
|
66
|
-
.s--inner button {
|
|
67
|
-
padding: var(--pui-spacing-2);
|
|
68
|
-
background-color: var(--pui-color-white);
|
|
69
|
-
border: 1px solid var(--switch-track-color);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.s--inner button:focus {
|
|
73
|
-
outline: var(--pui-color-primary) solid 1px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/* Slider Design Option */
|
|
77
|
-
|
|
78
|
-
.s--slider {
|
|
79
|
-
display: flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.s--slider button {
|
|
84
|
-
width: 3em;
|
|
85
|
-
height: 1.6em;
|
|
86
|
-
position: relative;
|
|
87
|
-
margin: 0 0 0 var(--pui-spacing-2);
|
|
88
|
-
background: var(--switch-track-color);
|
|
89
|
-
border: none;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.s--slider button::before {
|
|
93
|
-
content: '';
|
|
94
|
-
position: absolute;
|
|
95
|
-
width: 1.3em;
|
|
96
|
-
height: 1.3em;
|
|
97
|
-
background: var(--pui-color-white);
|
|
98
|
-
top: 0.13em;
|
|
99
|
-
right: 1.5em;
|
|
100
|
-
transition: transform var(--pui-transition-slow) var(--pui-ease-in-out);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.s--slider button[aria-checked='true']{
|
|
104
|
-
background-color: var(--pui-color-primary);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.s--slider button[aria-checked='true']::before{
|
|
108
|
-
transform: translateX(1.3em);
|
|
109
|
-
transition: transform var(--pui-transition-slow) var(--pui-ease-in-out);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.s--slider button:focus {
|
|
113
|
-
outline: 1px solid var(--pui-color-primary);
|
|
114
|
-
outline-offset: var(--pui-focus-ring-offset);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/* Multi Design Option */
|
|
118
|
-
|
|
119
|
-
/* Based on suggestions from Sara Soueidan https://www.sarasoueidan.com/blog/toggle-switch-design/
|
|
120
|
-
and this example from Scott O'hara https://codepen.io/scottohara/pen/zLZwNv */
|
|
121
|
-
|
|
122
|
-
.s--multi .group-container {
|
|
123
|
-
border: none;
|
|
124
|
-
padding: 0;
|
|
125
|
-
white-space: nowrap;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/* gravy */
|
|
130
|
-
|
|
131
|
-
/* Inner Design Option */
|
|
132
|
-
|
|
133
|
-
.s--inner button:focus {
|
|
134
|
-
outline-offset: var(--pui-focus-ring-offset);
|
|
135
|
-
border-radius: var(--pui-radius-sm);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/* Slider Design Option */
|
|
139
|
-
.s--slider button {
|
|
140
|
-
border-radius: var(--pui-radius-3xl);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.s--slider button::before {
|
|
144
|
-
border-radius: var(--pui-radius-full);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Sourced from https://svelte.dev/playground/d65a4e9f0ae74d1eb1b08d13e428af32?version=5.36.16, and updated from there
|
|
3
|
+
import FormGroup from './FormGroup.svelte';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
label: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
checked: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
description?: string;
|
|
11
|
+
containerClass?: string;
|
|
12
|
+
switchClass?: string;
|
|
13
|
+
onchange?: (value: boolean) => void;
|
|
14
|
+
showError?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let { label, required = false, checked = $bindable(), disabled = false, containerClass, switchClass, onchange, showError }: Props = $props();
|
|
18
|
+
|
|
19
|
+
function handleClick(event: Event){
|
|
20
|
+
const target = event.target as HTMLElement
|
|
21
|
+
|
|
22
|
+
const state = target.getAttribute('aria-checked')
|
|
23
|
+
|
|
24
|
+
checked = !(state === 'true')
|
|
25
|
+
onchange?.(checked);
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div class="switch-container {containerClass}">
|
|
30
|
+
<FormGroup {required} {label}>
|
|
31
|
+
<div class="s s--slider {switchClass} {required ? 'required' : ''}
|
|
32
|
+
{showError ? 'error' : ''}
|
|
33
|
+
{disabled ? 'disabled' : ''}">
|
|
34
|
+
<button
|
|
35
|
+
role="switch"
|
|
36
|
+
aria-checked={checked}
|
|
37
|
+
onclick={handleClick}
|
|
38
|
+
aria-labelledby="form-{label}"
|
|
39
|
+
class="{disabled ? 'disabled' : ''}"
|
|
40
|
+
{disabled}
|
|
41
|
+
>
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
<span class="slider"></span>
|
|
45
|
+
</FormGroup>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
:root .switch-container {
|
|
51
|
+
--switch-accent-color: var(--pui-color-primary);
|
|
52
|
+
--switch-track-color: var(--pui-border-disabled);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:global(.dark) .switch-container {
|
|
56
|
+
--switch-accent-color: var(--pui-color-primary);
|
|
57
|
+
--switch-track-color: var(--pui-color-gray-600);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.disabled button {
|
|
61
|
+
cursor: not-allowed;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/* Inner Design Option */
|
|
66
|
+
.s--inner button {
|
|
67
|
+
padding: var(--pui-spacing-2);
|
|
68
|
+
background-color: var(--pui-color-white);
|
|
69
|
+
border: 1px solid var(--switch-track-color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.s--inner button:focus {
|
|
73
|
+
outline: var(--pui-color-primary) solid 1px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Slider Design Option */
|
|
77
|
+
|
|
78
|
+
.s--slider {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.s--slider button {
|
|
84
|
+
width: 3em;
|
|
85
|
+
height: 1.6em;
|
|
86
|
+
position: relative;
|
|
87
|
+
margin: 0 0 0 var(--pui-spacing-2);
|
|
88
|
+
background: var(--switch-track-color);
|
|
89
|
+
border: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.s--slider button::before {
|
|
93
|
+
content: '';
|
|
94
|
+
position: absolute;
|
|
95
|
+
width: 1.3em;
|
|
96
|
+
height: 1.3em;
|
|
97
|
+
background: var(--pui-color-white);
|
|
98
|
+
top: 0.13em;
|
|
99
|
+
right: 1.5em;
|
|
100
|
+
transition: transform var(--pui-transition-slow) var(--pui-ease-in-out);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.s--slider button[aria-checked='true']{
|
|
104
|
+
background-color: var(--pui-color-primary);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.s--slider button[aria-checked='true']::before{
|
|
108
|
+
transform: translateX(1.3em);
|
|
109
|
+
transition: transform var(--pui-transition-slow) var(--pui-ease-in-out);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.s--slider button:focus {
|
|
113
|
+
outline: 1px solid var(--pui-color-primary);
|
|
114
|
+
outline-offset: var(--pui-focus-ring-offset);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Multi Design Option */
|
|
118
|
+
|
|
119
|
+
/* Based on suggestions from Sara Soueidan https://www.sarasoueidan.com/blog/toggle-switch-design/
|
|
120
|
+
and this example from Scott O'hara https://codepen.io/scottohara/pen/zLZwNv */
|
|
121
|
+
|
|
122
|
+
.s--multi .group-container {
|
|
123
|
+
border: none;
|
|
124
|
+
padding: 0;
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
/* gravy */
|
|
130
|
+
|
|
131
|
+
/* Inner Design Option */
|
|
132
|
+
|
|
133
|
+
.s--inner button:focus {
|
|
134
|
+
outline-offset: var(--pui-focus-ring-offset);
|
|
135
|
+
border-radius: var(--pui-radius-sm);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* Slider Design Option */
|
|
139
|
+
.s--slider button {
|
|
140
|
+
border-radius: var(--pui-radius-3xl);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.s--slider button::before {
|
|
144
|
+
border-radius: var(--pui-radius-full);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
148
|
</style>
|
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import FormGroup from './FormGroup.svelte';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
label?: string;
|
|
6
|
-
inputId?: string;
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
required?: boolean;
|
|
9
|
-
autofocus?: boolean;
|
|
10
|
-
noAutocomplete?: boolean;
|
|
11
|
-
groupClass?: string;
|
|
12
|
-
textboxElement?: HTMLElement;
|
|
13
|
-
class?: string;
|
|
14
|
-
containerClass?: string;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
value?: string;
|
|
17
|
-
tooltipLocation?: 'top' | 'bottom' | 'left' | 'right';
|
|
18
|
-
tooltipText?: string;
|
|
19
|
-
onblur?: (e: FocusEvent) => void;
|
|
20
|
-
onfocus?: (e: FocusEvent) => void;
|
|
21
|
-
onchange?: (e: FocusEvent) => void;
|
|
22
|
-
oninput?: (e: FocusEvent) => void;
|
|
23
|
-
onkeydown?: (e: FocusEvent) => void;
|
|
24
|
-
onkeypress?: (e: FocusEvent) => void;
|
|
25
|
-
onkeyup?: (e: FocusEvent) => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let {
|
|
29
|
-
label = '',
|
|
30
|
-
inputId = undefined,
|
|
31
|
-
placeholder = undefined,
|
|
32
|
-
required = false,
|
|
33
|
-
autofocus = false,
|
|
34
|
-
noAutocomplete = false,
|
|
35
|
-
class: classes = '',
|
|
36
|
-
containerClass = '',
|
|
37
|
-
groupClass = '',
|
|
38
|
-
textboxElement: textboxElement = undefined,
|
|
39
|
-
disabled = false,
|
|
40
|
-
value = $bindable(''),
|
|
41
|
-
tooltipLocation = 'top',
|
|
42
|
-
tooltipText = undefined,
|
|
43
|
-
onblur = undefined,
|
|
44
|
-
onfocus = undefined,
|
|
45
|
-
onchange = undefined,
|
|
46
|
-
oninput = undefined,
|
|
47
|
-
onkeydown = undefined,
|
|
48
|
-
onkeypress = undefined,
|
|
49
|
-
onkeyup = undefined,
|
|
50
|
-
}: Props = $props();
|
|
51
|
-
|
|
52
|
-
let showRequiredRing = $state(false);
|
|
53
|
-
const id = $derived(inputId ?? `input-${label.replaceAll(' ', '')}`);
|
|
54
|
-
</script>
|
|
55
|
-
|
|
56
|
-
<div class="textarea-container {containerClass}">
|
|
57
|
-
<FormGroup {label} {required} {id} class={groupClass} {tooltipLocation} {tooltipText}>
|
|
58
|
-
<!-- svelte-ignore a11y_autofocus -->
|
|
59
|
-
<textarea
|
|
60
|
-
class="
|
|
61
|
-
{showRequiredRing && '!border-required'}
|
|
62
|
-
{classes}"
|
|
63
|
-
{id}
|
|
64
|
-
{placeholder}
|
|
65
|
-
{disabled}
|
|
66
|
-
{autofocus}
|
|
67
|
-
{required}
|
|
68
|
-
autocomplete={!noAutocomplete ? 'on' : 'off'}
|
|
69
|
-
bind:value
|
|
70
|
-
bind:this={textboxElement}
|
|
71
|
-
{onblur}
|
|
72
|
-
{onfocus}
|
|
73
|
-
onchange={() => onchange?.(new FocusEvent('change'))}
|
|
74
|
-
oninput={() => oninput?.(new FocusEvent('input'))}
|
|
75
|
-
onkeydown={() => onkeydown?.(new FocusEvent('keydown'))}
|
|
76
|
-
onkeypress={() => onkeypress?.(new FocusEvent('keypress'))}
|
|
77
|
-
onkeyup={() => onkeyup?.(new FocusEvent('keyup'))}
|
|
78
|
-
></textarea>
|
|
79
|
-
</FormGroup>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<style>
|
|
83
|
-
textarea {
|
|
84
|
-
display: block;
|
|
85
|
-
width: 100%;
|
|
86
|
-
min-height: calc(2.25rem + 2px);
|
|
87
|
-
padding: var(--pui-spacing-2);
|
|
88
|
-
font-size: var(--pui-font-size-md);
|
|
89
|
-
font-weight: var(--pui-font-weight-normal);
|
|
90
|
-
line-height: var(--pui-line-height-normal);
|
|
91
|
-
color: var(--pui-input-text);
|
|
92
|
-
background-color: var(--pui-input-bg);
|
|
93
|
-
background-image: none;
|
|
94
|
-
border: 1px solid var(--pui-input-border);
|
|
95
|
-
border-radius: var(--pui-radius-md);
|
|
96
|
-
appearance: none;
|
|
97
|
-
transition: border-color var(--pui-transition-fast) var(--pui-ease-in-out);
|
|
98
|
-
resize: vertical;
|
|
99
|
-
|
|
100
|
-
&::placeholder {
|
|
101
|
-
color: var(--pui-text-placeholder);
|
|
102
|
-
opacity: 1;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&:focus {
|
|
106
|
-
border-color: var(--pui-color-primary);
|
|
107
|
-
outline: 0;
|
|
108
|
-
box-shadow: none;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
&:disabled {
|
|
112
|
-
background-color: var(--pui-bg-disabled);
|
|
113
|
-
opacity: 1;
|
|
114
|
-
cursor: not-allowed;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
:global(.dark) textarea {
|
|
119
|
-
background-color: var(--pui-input-bg);
|
|
120
|
-
color: var(--pui-input-text);
|
|
121
|
-
border-color: var(--pui-input-border);
|
|
122
|
-
|
|
123
|
-
&::placeholder {
|
|
124
|
-
color: var(--pui-text-placeholder);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
&:focus {
|
|
128
|
-
border-color: var(--pui-color-secondary);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
&:disabled {
|
|
132
|
-
background-color: var(--pui-bg-disabled);
|
|
133
|
-
color: var(--pui-input-text);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/* Fix for resize handle in dark mode */
|
|
138
|
-
:global(.dark) textarea::-webkit-resizer {
|
|
139
|
-
background-color: var(--pui-color-gray-700);
|
|
140
|
-
border-color: var(--pui-border-default);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.loader {
|
|
144
|
-
position: absolute;
|
|
145
|
-
right: var(--pui-spacing-2);
|
|
146
|
-
top: var(--pui-spacing-2);
|
|
147
|
-
}
|
|
148
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import FormGroup from './FormGroup.svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
label?: string;
|
|
6
|
+
inputId?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
autofocus?: boolean;
|
|
10
|
+
noAutocomplete?: boolean;
|
|
11
|
+
groupClass?: string;
|
|
12
|
+
textboxElement?: HTMLElement;
|
|
13
|
+
class?: string;
|
|
14
|
+
containerClass?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
value?: string;
|
|
17
|
+
tooltipLocation?: 'top' | 'bottom' | 'left' | 'right';
|
|
18
|
+
tooltipText?: string;
|
|
19
|
+
onblur?: (e: FocusEvent) => void;
|
|
20
|
+
onfocus?: (e: FocusEvent) => void;
|
|
21
|
+
onchange?: (e: FocusEvent) => void;
|
|
22
|
+
oninput?: (e: FocusEvent) => void;
|
|
23
|
+
onkeydown?: (e: FocusEvent) => void;
|
|
24
|
+
onkeypress?: (e: FocusEvent) => void;
|
|
25
|
+
onkeyup?: (e: FocusEvent) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
label = '',
|
|
30
|
+
inputId = undefined,
|
|
31
|
+
placeholder = undefined,
|
|
32
|
+
required = false,
|
|
33
|
+
autofocus = false,
|
|
34
|
+
noAutocomplete = false,
|
|
35
|
+
class: classes = '',
|
|
36
|
+
containerClass = '',
|
|
37
|
+
groupClass = '',
|
|
38
|
+
textboxElement: textboxElement = undefined,
|
|
39
|
+
disabled = false,
|
|
40
|
+
value = $bindable(''),
|
|
41
|
+
tooltipLocation = 'top',
|
|
42
|
+
tooltipText = undefined,
|
|
43
|
+
onblur = undefined,
|
|
44
|
+
onfocus = undefined,
|
|
45
|
+
onchange = undefined,
|
|
46
|
+
oninput = undefined,
|
|
47
|
+
onkeydown = undefined,
|
|
48
|
+
onkeypress = undefined,
|
|
49
|
+
onkeyup = undefined,
|
|
50
|
+
}: Props = $props();
|
|
51
|
+
|
|
52
|
+
let showRequiredRing = $state(false);
|
|
53
|
+
const id = $derived(inputId ?? `input-${label.replaceAll(' ', '')}`);
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div class="textarea-container {containerClass}">
|
|
57
|
+
<FormGroup {label} {required} {id} class={groupClass} {tooltipLocation} {tooltipText}>
|
|
58
|
+
<!-- svelte-ignore a11y_autofocus -->
|
|
59
|
+
<textarea
|
|
60
|
+
class="
|
|
61
|
+
{showRequiredRing && '!border-required'}
|
|
62
|
+
{classes}"
|
|
63
|
+
{id}
|
|
64
|
+
{placeholder}
|
|
65
|
+
{disabled}
|
|
66
|
+
{autofocus}
|
|
67
|
+
{required}
|
|
68
|
+
autocomplete={!noAutocomplete ? 'on' : 'off'}
|
|
69
|
+
bind:value
|
|
70
|
+
bind:this={textboxElement}
|
|
71
|
+
{onblur}
|
|
72
|
+
{onfocus}
|
|
73
|
+
onchange={() => onchange?.(new FocusEvent('change'))}
|
|
74
|
+
oninput={() => oninput?.(new FocusEvent('input'))}
|
|
75
|
+
onkeydown={() => onkeydown?.(new FocusEvent('keydown'))}
|
|
76
|
+
onkeypress={() => onkeypress?.(new FocusEvent('keypress'))}
|
|
77
|
+
onkeyup={() => onkeyup?.(new FocusEvent('keyup'))}
|
|
78
|
+
></textarea>
|
|
79
|
+
</FormGroup>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<style>
|
|
83
|
+
textarea {
|
|
84
|
+
display: block;
|
|
85
|
+
width: 100%;
|
|
86
|
+
min-height: calc(2.25rem + 2px);
|
|
87
|
+
padding: var(--pui-spacing-2);
|
|
88
|
+
font-size: var(--pui-font-size-md);
|
|
89
|
+
font-weight: var(--pui-font-weight-normal);
|
|
90
|
+
line-height: var(--pui-line-height-normal);
|
|
91
|
+
color: var(--pui-input-text);
|
|
92
|
+
background-color: var(--pui-input-bg);
|
|
93
|
+
background-image: none;
|
|
94
|
+
border: 1px solid var(--pui-input-border);
|
|
95
|
+
border-radius: var(--pui-radius-md);
|
|
96
|
+
appearance: none;
|
|
97
|
+
transition: border-color var(--pui-transition-fast) var(--pui-ease-in-out);
|
|
98
|
+
resize: vertical;
|
|
99
|
+
|
|
100
|
+
&::placeholder {
|
|
101
|
+
color: var(--pui-text-placeholder);
|
|
102
|
+
opacity: 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&:focus {
|
|
106
|
+
border-color: var(--pui-color-primary);
|
|
107
|
+
outline: 0;
|
|
108
|
+
box-shadow: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&:disabled {
|
|
112
|
+
background-color: var(--pui-bg-disabled);
|
|
113
|
+
opacity: 1;
|
|
114
|
+
cursor: not-allowed;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:global(.dark) textarea {
|
|
119
|
+
background-color: var(--pui-input-bg);
|
|
120
|
+
color: var(--pui-input-text);
|
|
121
|
+
border-color: var(--pui-input-border);
|
|
122
|
+
|
|
123
|
+
&::placeholder {
|
|
124
|
+
color: var(--pui-text-placeholder);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&:focus {
|
|
128
|
+
border-color: var(--pui-color-secondary);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&:disabled {
|
|
132
|
+
background-color: var(--pui-bg-disabled);
|
|
133
|
+
color: var(--pui-input-text);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Fix for resize handle in dark mode */
|
|
138
|
+
:global(.dark) textarea::-webkit-resizer {
|
|
139
|
+
background-color: var(--pui-color-gray-700);
|
|
140
|
+
border-color: var(--pui-border-default);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.loader {
|
|
144
|
+
position: absolute;
|
|
145
|
+
right: var(--pui-spacing-2);
|
|
146
|
+
top: var(--pui-spacing-2);
|
|
147
|
+
}
|
|
148
|
+
</style>
|