@geoffcox/sterling-svelte 0.0.11 → 0.0.13
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/index.d.ts +3 -1
- package/index.js +3 -1
- package/inputs/Input.svelte +1 -1
- package/inputs/Switch.svelte +1 -1
- package/inputs/TextArea.svelte +152 -0
- package/inputs/TextArea.svelte.d.ts +50 -0
- package/inputs/TextArea.types.d.ts +1 -0
- package/inputs/TextArea.types.js +1 -0
- package/package.json +3 -1
package/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { neutrals } from './theme/colors';
|
|
|
8
8
|
export { toggleDarkTheme } from './theme/toggleDarkTheme';
|
|
9
9
|
export { type ButtonVariant, type ButtonShape } from './buttons/Button.types';
|
|
10
10
|
export { type ProgressColorful } from './display/Progress.types';
|
|
11
|
+
export { type TextAreaResize } from './inputs/TextArea.types';
|
|
11
12
|
export { clickOutside } from './clickOutside';
|
|
12
13
|
import Button from './buttons/Button.svelte';
|
|
13
14
|
import Checkbox from './inputs/Checkbox.svelte';
|
|
@@ -20,4 +21,5 @@ import Radio from './inputs/Radio.svelte';
|
|
|
20
21
|
import Select from './inputs/Select.svelte';
|
|
21
22
|
import Slider from './inputs/Slider.svelte';
|
|
22
23
|
import Switch from './inputs/Switch.svelte';
|
|
23
|
-
|
|
24
|
+
import TextArea from './inputs/TextArea.svelte';
|
|
25
|
+
export { Button, Checkbox, Dialog, Input, Label, List, Progress, Radio, Select, Slider, Switch, TextArea };
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { neutrals } from './theme/colors';
|
|
|
8
8
|
export { toggleDarkTheme } from './theme/toggleDarkTheme';
|
|
9
9
|
export {} from './buttons/Button.types';
|
|
10
10
|
export {} from './display/Progress.types';
|
|
11
|
+
export {} from './inputs/TextArea.types';
|
|
11
12
|
export { clickOutside } from './clickOutside';
|
|
12
13
|
import Button from './buttons/Button.svelte';
|
|
13
14
|
import Checkbox from './inputs/Checkbox.svelte';
|
|
@@ -20,4 +21,5 @@ import Radio from './inputs/Radio.svelte';
|
|
|
20
21
|
import Select from './inputs/Select.svelte';
|
|
21
22
|
import Slider from './inputs/Slider.svelte';
|
|
22
23
|
import Switch from './inputs/Switch.svelte';
|
|
23
|
-
|
|
24
|
+
import TextArea from './inputs/TextArea.svelte';
|
|
25
|
+
export { Button, Checkbox, Dialog, Input, Label, List, Progress, Radio, Select, Slider, Switch, TextArea };
|
package/inputs/Input.svelte
CHANGED
package/inputs/Switch.svelte
CHANGED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<script>import { v4 as uuid } from "uuid";
|
|
2
|
+
import Label from "../display/Label.svelte";
|
|
3
|
+
export let value;
|
|
4
|
+
export let resize = "none";
|
|
5
|
+
export let disabled = false;
|
|
6
|
+
export let autoHeight = false;
|
|
7
|
+
const inputId = uuid();
|
|
8
|
+
let textAreaRef;
|
|
9
|
+
const autoSetHeight = () => {
|
|
10
|
+
if (autoHeight && textAreaRef) {
|
|
11
|
+
textAreaRef.style.height = "auto";
|
|
12
|
+
textAreaRef.style.height = `${textAreaRef.scrollHeight}px`;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const onInput = () => {
|
|
16
|
+
autoSetHeight();
|
|
17
|
+
};
|
|
18
|
+
$:
|
|
19
|
+
autoHeight, autoSetHeight();
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div class="sterling-text-area" style={`--TextArea__resize: ${resize};`}>
|
|
23
|
+
{#if $$slots.label}
|
|
24
|
+
<div class="label">
|
|
25
|
+
<Label {disabled} for={inputId}>
|
|
26
|
+
<slot name="label" />
|
|
27
|
+
</Label>
|
|
28
|
+
</div>
|
|
29
|
+
{/if}
|
|
30
|
+
<textarea
|
|
31
|
+
{...$$restProps}
|
|
32
|
+
bind:this={textAreaRef}
|
|
33
|
+
bind:value
|
|
34
|
+
on:blur
|
|
35
|
+
on:click
|
|
36
|
+
on:change
|
|
37
|
+
on:copy
|
|
38
|
+
on:cut
|
|
39
|
+
on:paste
|
|
40
|
+
on:dblclick
|
|
41
|
+
on:focus
|
|
42
|
+
on:focusin
|
|
43
|
+
on:focusout
|
|
44
|
+
on:input={onInput}
|
|
45
|
+
on:input
|
|
46
|
+
on:invalid
|
|
47
|
+
on:keydown
|
|
48
|
+
on:keypress
|
|
49
|
+
on:keyup
|
|
50
|
+
on:mousedown
|
|
51
|
+
on:mouseenter
|
|
52
|
+
on:mouseleave
|
|
53
|
+
on:mousemove
|
|
54
|
+
on:mouseover
|
|
55
|
+
on:mouseout
|
|
56
|
+
on:mouseup
|
|
57
|
+
on:select
|
|
58
|
+
on:submit
|
|
59
|
+
on:reset
|
|
60
|
+
on:wheel
|
|
61
|
+
{disabled}
|
|
62
|
+
rows="1"
|
|
63
|
+
{...$$restProps}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<style>
|
|
68
|
+
.sterling-text-area {
|
|
69
|
+
background-color: var(--Input__background-color);
|
|
70
|
+
border-color: var(--Input__border-color);
|
|
71
|
+
border-radius: var(--Input__border-radius);
|
|
72
|
+
border-style: var(--Input__border-style);
|
|
73
|
+
border-width: var(--Input__border-width);
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
color: var(--Input__color);
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: 100%;
|
|
79
|
+
display: grid;
|
|
80
|
+
grid-template-columns: 1fr;
|
|
81
|
+
grid-template-rows: 1fr;
|
|
82
|
+
padding: 0;
|
|
83
|
+
margin: 0;
|
|
84
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.sterling-text-area:hover {
|
|
88
|
+
background-color: var(--Input__background-color--hover);
|
|
89
|
+
border-color: var(--Input__border-color--hover);
|
|
90
|
+
color: var(--Input__color--hover);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.sterling-text-area:focus-wthin {
|
|
94
|
+
background-color: var(--Input__background-color--focus);
|
|
95
|
+
border-color: var(--Input__border-color--focus);
|
|
96
|
+
color: var(--Input__color--focus);
|
|
97
|
+
outline-color: var(--Common__outline-color);
|
|
98
|
+
outline-offset: var(--Common__outline-offset);
|
|
99
|
+
outline-style: var(--Common__outline-style);
|
|
100
|
+
outline-width: var(--Common__outline-width);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sterling-text-area:disabled {
|
|
104
|
+
background-color: var(--Input__background-color--disabled);
|
|
105
|
+
border-color: var(---Input__border-color--disabled);
|
|
106
|
+
color: var(--Input__color--disabled);
|
|
107
|
+
cursor: not-allowed;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
textarea {
|
|
111
|
+
background: none;
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
color: inherit;
|
|
114
|
+
font: inherit;
|
|
115
|
+
line-height: inherit;
|
|
116
|
+
padding: 0 0.5em 0.5em 0.5em;
|
|
117
|
+
min-height: 3em;
|
|
118
|
+
margin: 0.5em 0 0 0;
|
|
119
|
+
resize: var(--TextArea__resize, none);
|
|
120
|
+
width: 100%;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
textarea,
|
|
124
|
+
textarea:hover,
|
|
125
|
+
textarea:focus-within,
|
|
126
|
+
textarea:disabled {
|
|
127
|
+
background-color: transparent;
|
|
128
|
+
border: none;
|
|
129
|
+
outline: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
textarea::placeholder {
|
|
133
|
+
color: var(--Display__color--faint);
|
|
134
|
+
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
textarea:disabled::placeholder {
|
|
138
|
+
color: var(--Display__color--disabled);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.label {
|
|
142
|
+
font-size: 0.7em;
|
|
143
|
+
margin: 0.5em 0 0 0.7em;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@media (prefers-reduced-motion) {
|
|
147
|
+
.sterling-text-area,
|
|
148
|
+
.sterling-text-area textarea::placeholder {
|
|
149
|
+
transition: none;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { TextAreaResize } from './TextArea.types';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
value: string;
|
|
7
|
+
resize?: TextAreaResize | undefined;
|
|
8
|
+
disabled?: boolean | undefined;
|
|
9
|
+
autoHeight?: boolean | undefined;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
blur: FocusEvent;
|
|
13
|
+
click: MouseEvent;
|
|
14
|
+
change: Event;
|
|
15
|
+
copy: ClipboardEvent;
|
|
16
|
+
cut: ClipboardEvent;
|
|
17
|
+
paste: ClipboardEvent;
|
|
18
|
+
dblclick: MouseEvent;
|
|
19
|
+
focus: FocusEvent;
|
|
20
|
+
focusin: FocusEvent;
|
|
21
|
+
focusout: FocusEvent;
|
|
22
|
+
input: Event;
|
|
23
|
+
invalid: Event;
|
|
24
|
+
keydown: KeyboardEvent;
|
|
25
|
+
keypress: KeyboardEvent;
|
|
26
|
+
keyup: KeyboardEvent;
|
|
27
|
+
mousedown: MouseEvent;
|
|
28
|
+
mouseenter: MouseEvent;
|
|
29
|
+
mouseleave: MouseEvent;
|
|
30
|
+
mousemove: MouseEvent;
|
|
31
|
+
mouseover: MouseEvent;
|
|
32
|
+
mouseout: MouseEvent;
|
|
33
|
+
mouseup: MouseEvent;
|
|
34
|
+
select: Event;
|
|
35
|
+
submit: SubmitEvent;
|
|
36
|
+
reset: Event;
|
|
37
|
+
wheel: WheelEvent;
|
|
38
|
+
} & {
|
|
39
|
+
[evt: string]: CustomEvent<any>;
|
|
40
|
+
};
|
|
41
|
+
slots: {
|
|
42
|
+
label: {};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export type TextAreaProps = typeof __propDef.props;
|
|
46
|
+
export type TextAreaEvents = typeof __propDef.events;
|
|
47
|
+
export type TextAreaSlots = typeof __propDef.slots;
|
|
48
|
+
export default class TextArea extends SvelteComponentTyped<TextAreaProps, TextAreaEvents, TextAreaSlots> {
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TextAreaResize = 'none' | 'both' | 'horizontal' | 'vertical';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoffcox/sterling-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"author": "Geoff Cox",
|
|
5
5
|
"description": "A modern, accessible, and lightweight component library for Svelte.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,6 +63,8 @@
|
|
|
63
63
|
"./inputs/Select.svelte": "./inputs/Select.svelte",
|
|
64
64
|
"./inputs/Slider.svelte": "./inputs/Slider.svelte",
|
|
65
65
|
"./inputs/Switch.svelte": "./inputs/Switch.svelte",
|
|
66
|
+
"./inputs/TextArea.svelte": "./inputs/TextArea.svelte",
|
|
67
|
+
"./inputs/TextArea.types": "./inputs/TextArea.types.js",
|
|
66
68
|
"./lists/List.svelte": "./lists/List.svelte",
|
|
67
69
|
"./surfaces/CloseX.svelte": "./surfaces/CloseX.svelte",
|
|
68
70
|
"./surfaces/Dialog.svelte": "./surfaces/Dialog.svelte",
|