@flightlesslabs/dodo-ui 0.8.0 → 0.9.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.
Files changed (54) hide show
  1. package/dist/index.d.ts +13 -2
  2. package/dist/index.js +8 -0
  3. package/dist/stories/components/Form/NumericInput/Events/Events.stories.svelte +126 -0
  4. package/dist/stories/components/Form/NumericInput/Events/Events.stories.svelte.d.ts +18 -0
  5. package/dist/stories/components/Form/NumericInput/NumericInput.stories.svelte +79 -0
  6. package/dist/stories/components/Form/NumericInput/NumericInput.stories.svelte.d.ts +21 -0
  7. package/dist/stories/components/Form/NumericInput/NumericInput.svelte +161 -0
  8. package/dist/stories/components/Form/NumericInput/NumericInput.svelte.d.ts +69 -0
  9. package/dist/stories/components/Form/NumericInput/Validation/Validation.stories.svelte +84 -0
  10. package/dist/stories/components/Form/NumericInput/Validation/Validation.stories.svelte.d.ts +18 -0
  11. package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte +27 -6
  12. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +5 -3
  13. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +7 -1
  14. package/dist/stories/components/Form/Select/Events/Events.stories.svelte +27 -0
  15. package/dist/stories/components/Form/Select/Select.svelte +4 -1
  16. package/dist/stories/components/Form/Select/Select.svelte.d.ts +7 -1
  17. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte +27 -0
  18. package/dist/stories/components/Form/TextInput/TextInput.svelte +5 -3
  19. package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +10 -1
  20. package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte +1 -1
  21. package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte +23 -5
  22. package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte.d.ts +13 -2
  23. package/dist/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte +115 -0
  24. package/dist/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte.d.ts +18 -0
  25. package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.d.ts +13 -0
  26. package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.js +26 -0
  27. package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/index.mdx +20 -0
  28. package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/index.mdx +71 -0
  29. package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.d.ts +51 -0
  30. package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.js +96 -0
  31. package/dist/stories/developer tools/helpers/logger/index.mdx +63 -0
  32. package/dist/stories/developer tools/helpers/logger/logger.d.ts +24 -0
  33. package/dist/stories/developer tools/helpers/logger/logger.js +31 -0
  34. package/package.json +1 -1
  35. package/src/lib/index.ts +20 -0
  36. package/src/lib/stories/components/Form/NumericInput/Events/Events.stories.svelte +134 -0
  37. package/src/lib/stories/components/Form/NumericInput/NumericInput.stories.svelte +84 -0
  38. package/src/lib/stories/components/Form/NumericInput/NumericInput.svelte +286 -0
  39. package/src/lib/stories/components/Form/NumericInput/Validation/Validation.stories.svelte +87 -0
  40. package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +28 -6
  41. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +15 -3
  42. package/src/lib/stories/components/Form/Select/Events/Events.stories.svelte +31 -1
  43. package/src/lib/stories/components/Form/Select/Select.svelte +13 -0
  44. package/src/lib/stories/components/Form/TextInput/Events/Events.stories.svelte +28 -0
  45. package/src/lib/stories/components/Form/TextInput/TextInput.svelte +18 -3
  46. package/src/lib/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte +1 -1
  47. package/src/lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte +43 -4
  48. package/src/lib/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte +121 -0
  49. package/src/lib/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.ts +27 -0
  50. package/src/lib/stories/developer tools/helpers/Numbers/cleanNumericString/index.mdx +20 -0
  51. package/src/lib/stories/developer tools/helpers/Numbers/isValidNumberValue/index.mdx +71 -0
  52. package/src/lib/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.ts +156 -0
  53. package/src/lib/stories/developer tools/helpers/logger/index.mdx +63 -0
  54. package/src/lib/stories/developer tools/helpers/logger/logger.ts +46 -0
@@ -0,0 +1,286 @@
1
+ <script lang="ts" module>
2
+ import type { ComponentRoundness } from '$lib/types/roundness.js';
3
+ import type { ComponentSize } from '$lib/types/size.js';
4
+
5
+ import { type Snippet } from 'svelte';
6
+ import type {
7
+ ChangeEventHandler,
8
+ ClipboardEventHandler,
9
+ FocusEventHandler,
10
+ FormEventHandler,
11
+ KeyboardEventHandler,
12
+ } from 'svelte/elements';
13
+
14
+ export interface NumericInputProps {
15
+ /** min */
16
+ min?: number;
17
+ /** max */
18
+ max?: number;
19
+ /** Allow Negative Values */
20
+ allowNegativeValues?: boolean;
21
+ /** Decimal Places */
22
+ decimalPlaces?: number;
23
+ /** Log number validations */
24
+ log?: boolean;
25
+ /** Input ref */
26
+ ref?: HTMLInputElement;
27
+ /** How large should the button be? */
28
+ size?: ComponentSize;
29
+ /** How round should the border radius be? */
30
+ roundness?: ComponentRoundness;
31
+ /** Add a border around the button. Default True */
32
+ outline?: boolean;
33
+ /** Input value */
34
+ value?: number;
35
+ /** How round should the border radius be? */
36
+ placeholder?: string;
37
+ /** disabled state */
38
+ disabled?: boolean;
39
+ /** Read only ? */
40
+ readonly?: boolean;
41
+ /** is there any associated Error ? */
42
+ error?: boolean;
43
+ /** Name */
44
+ name?: string;
45
+ /** Id */
46
+ id?: string;
47
+ /** Icon before button content */
48
+ before?: Snippet;
49
+ /** Icon after button content */
50
+ after?: Snippet;
51
+ /** Custom css class*/
52
+ class?: string;
53
+ /** on Numeric Value Change */
54
+ onValueChange?: (value: number | undefined) => void;
55
+ /** oninput event handler */
56
+ oninput?: FormEventHandler<HTMLInputElement>;
57
+ /** onchange event handler */
58
+ onchange?: ChangeEventHandler<HTMLInputElement>;
59
+ /** onblur event handler */
60
+ onblur?: FocusEventHandler<HTMLInputElement>;
61
+ /** onfocus event handler */
62
+ onfocus?: FocusEventHandler<HTMLInputElement>;
63
+ /** onpaste event handler */
64
+ onpaste?: ClipboardEventHandler<HTMLInputElement>;
65
+ /** oncopy event handler */
66
+ oncopy?: ClipboardEventHandler<HTMLInputElement>;
67
+ /** oncut event handler */
68
+ oncut?: ClipboardEventHandler<HTMLInputElement>;
69
+ /** onkeydown event handler */
70
+ onkeydown?: KeyboardEventHandler<HTMLInputElement>;
71
+ /** onkeypress event handler */
72
+ onkeypress?: KeyboardEventHandler<HTMLInputElement>;
73
+ /** onkeyup event handler */
74
+ onkeyup?: KeyboardEventHandler<HTMLInputElement>;
75
+ }
76
+ </script>
77
+
78
+ <script lang="ts">
79
+ import InputEnclosure from '$lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte';
80
+ import DynamicInput, {
81
+ type DynamicInputFocusEvent,
82
+ type DynamicInputKeyboardEvent,
83
+ } from '$lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte';
84
+ import type { TextInputFocusEvent, TextInputKeyboardEvent } from '../TextInput/TextInput.svelte';
85
+ import isValidNumberValue from '$lib/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.js';
86
+
87
+ let {
88
+ size = 'normal',
89
+ roundness = 1,
90
+ outline = true,
91
+ name,
92
+ id,
93
+ class: className = '',
94
+ disabled = false,
95
+ oninput,
96
+ onchange,
97
+ onblur,
98
+ onfocus,
99
+ onpaste,
100
+ oncopy,
101
+ oncut,
102
+ onkeydown,
103
+ onkeypress,
104
+ onkeyup,
105
+ before,
106
+ after,
107
+ error = false,
108
+ value: valueRaw,
109
+ placeholder,
110
+ ref = $bindable<HTMLInputElement>(),
111
+ readonly = false,
112
+ decimalPlaces = 0,
113
+ allowNegativeValues = false,
114
+ min,
115
+ max,
116
+ log = false,
117
+ onValueChange,
118
+ }: NumericInputProps = $props();
119
+
120
+ let value = $state<string>('');
121
+ let cachedValue = $state<string>('');
122
+
123
+ let focused: boolean = $state(false);
124
+
125
+ function onfocusMod(e: DynamicInputFocusEvent) {
126
+ const eTyped = e as TextInputFocusEvent;
127
+
128
+ if (onfocus) {
129
+ onfocus(eTyped);
130
+ }
131
+ }
132
+
133
+ function onblurMod(e: DynamicInputFocusEvent) {
134
+ const eTyped = e as TextInputFocusEvent;
135
+
136
+ const isValidWithoutMinMax = isValidNumberValue(`${value}`, {
137
+ decimalPlaces,
138
+ allowNegativeValues,
139
+ log,
140
+ });
141
+
142
+ const isValid = isValidNumberValue(`${value}`, {
143
+ decimalPlaces,
144
+ allowNegativeValues,
145
+ log,
146
+ min,
147
+ max,
148
+ });
149
+
150
+ if (isValid) {
151
+ if (onValueChange) {
152
+ onValueChange(Number(value));
153
+ }
154
+
155
+ value = `${Number(value)}`;
156
+ cachedValue = `${Number(value)}`;
157
+ } else if (isValidWithoutMinMax) {
158
+ if (min && Number(value) < min) {
159
+ if (onValueChange) {
160
+ onValueChange(min);
161
+ }
162
+
163
+ value = `${min}`;
164
+ cachedValue = `${min}`;
165
+ } else if (max && Number(value) > max) {
166
+ if (onValueChange) {
167
+ onValueChange(max);
168
+ }
169
+
170
+ value = `${max}`;
171
+ cachedValue = `${max}`;
172
+ }
173
+ } else if (value.trim() === '') {
174
+ if (onValueChange) {
175
+ onValueChange(undefined);
176
+ }
177
+
178
+ value = '';
179
+ cachedValue = '';
180
+ } else if (valueRaw || valueRaw === 0) {
181
+ if (onValueChange) {
182
+ onValueChange(valueRaw);
183
+ }
184
+
185
+ value = `${valueRaw}`;
186
+ cachedValue = `${valueRaw}`;
187
+ } else {
188
+ if (onValueChange) {
189
+ onValueChange(undefined);
190
+ }
191
+
192
+ value = '';
193
+ cachedValue = '';
194
+ }
195
+
196
+ if (onblur) {
197
+ onblur(eTyped);
198
+ }
199
+ }
200
+
201
+ function onkeydownMod(e: DynamicInputKeyboardEvent) {
202
+ if (onkeydown) {
203
+ onkeydown(e as TextInputKeyboardEvent);
204
+ }
205
+
206
+ if (e.ctrlKey && e.key.toLocaleLowerCase() === 'c') {
207
+ return;
208
+ } else if (e.ctrlKey && e.key.toLocaleLowerCase() === 'v') {
209
+ return;
210
+ } else if (e.ctrlKey && e.key.toLocaleLowerCase() === 'x') {
211
+ return;
212
+ }
213
+
214
+ const valueToCheck = `${value}${e.key.length === 1 ? e.key : ''}`;
215
+
216
+ const isValid = isValidNumberValue(valueToCheck, {
217
+ decimalPlaces,
218
+ allowNegativeValues,
219
+ log,
220
+ strict: false,
221
+ });
222
+
223
+ if (!isValid) {
224
+ e.preventDefault();
225
+ value = cachedValue;
226
+ } else {
227
+ cachedValue = valueToCheck;
228
+ }
229
+ }
230
+
231
+ $effect(() => {
232
+ let updatedValue = '';
233
+
234
+ const isValid = isValidNumberValue(`${valueRaw}`, {
235
+ decimalPlaces,
236
+ allowNegativeValues,
237
+ min,
238
+ max,
239
+ log,
240
+ });
241
+
242
+ if (valueRaw === undefined) {
243
+ updatedValue = '';
244
+ } else if (!isValid) {
245
+ updatedValue = '';
246
+ } else {
247
+ updatedValue = `${valueRaw}`;
248
+ }
249
+
250
+ value = updatedValue;
251
+ cachedValue = updatedValue;
252
+ });
253
+ </script>
254
+
255
+ <div
256
+ class:outline
257
+ class:disabled
258
+ class:error
259
+ class:focused
260
+ class={['dodo-ui-NumericInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
261
+ >
262
+ <InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
263
+ <DynamicInput
264
+ type="text"
265
+ {name}
266
+ {id}
267
+ {disabled}
268
+ bind:ref
269
+ bind:focused
270
+ {oninput}
271
+ {onchange}
272
+ onfocus={onfocusMod}
273
+ onblur={onblurMod}
274
+ {onpaste}
275
+ {oncopy}
276
+ {oncut}
277
+ onkeydown={onkeydownMod}
278
+ onkeypress={onkeypress ? (e) => onkeypress(e as TextInputKeyboardEvent) : undefined}
279
+ onkeyup={onkeyup ? (e) => onkeyup(e as TextInputKeyboardEvent) : undefined}
280
+ {placeholder}
281
+ {readonly}
282
+ variant="input"
283
+ bind:value
284
+ />
285
+ </InputEnclosure>
286
+ </div>
@@ -0,0 +1,87 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import NumericInput from '../NumericInput.svelte';
4
+ import { storyNumericInputArgTypes } from '../NumericInput.stories.svelte';
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
+ const { Story } = defineMeta({
8
+ component: NumericInput,
9
+ tags: ['autodocs'],
10
+ argTypes: storyNumericInputArgTypes,
11
+ });
12
+
13
+ let value = $state<undefined | number>(0);
14
+ </script>
15
+
16
+ <!-- NumericInput with default style -->
17
+ <Story
18
+ name="Default"
19
+ args={{
20
+ value,
21
+ onValueChange: (val) => {
22
+ value = val;
23
+ },
24
+ }}
25
+ />
26
+
27
+ <!-- Min, In this case min is set to 25 -->
28
+ <Story
29
+ name="Min"
30
+ args={{
31
+ value,
32
+ onValueChange: (val) => {
33
+ console.log(val);
34
+
35
+ value = val;
36
+ },
37
+ min: 25,
38
+ }}
39
+ />
40
+
41
+ <!-- Max, In this case max is set to 25 -->
42
+ <Story
43
+ name="Max"
44
+ args={{
45
+ value,
46
+ onValueChange: (val) => {
47
+ value = val;
48
+ },
49
+ max: 25,
50
+ }}
51
+ />
52
+
53
+ <!-- Allow Negative values -->
54
+ <Story
55
+ name="AllowNegativeValues"
56
+ args={{
57
+ value,
58
+ onValueChange: (val) => {
59
+ value = val;
60
+ },
61
+ allowNegativeValues: true,
62
+ }}
63
+ />
64
+
65
+ <!-- Decimal Places -->
66
+ <Story
67
+ name="DecimalPlaces"
68
+ args={{
69
+ value,
70
+ onValueChange: (val) => {
71
+ value = val;
72
+ },
73
+ decimalPlaces: 2,
74
+ }}
75
+ />
76
+
77
+ <!-- Log validations, check console -->
78
+ <Story
79
+ name="LogValidations"
80
+ args={{
81
+ value,
82
+ onValueChange: (val) => {
83
+ value = val;
84
+ },
85
+ log: true,
86
+ }}
87
+ />
@@ -5,6 +5,7 @@
5
5
  import type {
6
6
  TextInputFocusEvent,
7
7
  TextInputClipboardEvent,
8
+ TextInputKeyboardEvent,
8
9
  } from '../../TextInput/TextInput.svelte';
9
10
 
10
11
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
@@ -37,7 +38,6 @@
37
38
  }}
38
39
  />
39
40
 
40
- <!-- `e: PasswordInputToggleEvent` -->
41
41
  <Story
42
42
  name="Toggle"
43
43
  args={{
@@ -49,7 +49,6 @@
49
49
  }}
50
50
  />
51
51
 
52
- <!-- `e: TextInputFocusEvent` -->
53
52
  <Story
54
53
  name="Focus"
55
54
  args={{
@@ -61,7 +60,6 @@
61
60
  }}
62
61
  />
63
62
 
64
- <!-- `e: TextInputFocusEvent` -->
65
63
  <Story
66
64
  name="Blur"
67
65
  args={{
@@ -73,7 +71,6 @@
73
71
  }}
74
72
  />
75
73
 
76
- <!-- `e: TextInputClipboardEvent` -->
77
74
  <Story
78
75
  name="Copy"
79
76
  args={{
@@ -85,7 +82,6 @@
85
82
  }}
86
83
  />
87
84
 
88
- <!-- `e: TextInputClipboardEvent` -->
89
85
  <Story
90
86
  name="Cut"
91
87
  args={{
@@ -97,7 +93,6 @@
97
93
  }}
98
94
  />
99
95
 
100
- <!-- `e: TextInputClipboardEvent` -->
101
96
  <Story
102
97
  name="Paste"
103
98
  args={{
@@ -108,3 +103,30 @@
108
103
  },
109
104
  }}
110
105
  />
106
+
107
+ <Story
108
+ name="KeyDown"
109
+ args={{
110
+ onkeydown: (e: TextInputKeyboardEvent) => {
111
+ console.log('onkeydown Event', e.key);
112
+ },
113
+ }}
114
+ />
115
+
116
+ <Story
117
+ name="KeyPress"
118
+ args={{
119
+ onkeypress: (e: TextInputKeyboardEvent) => {
120
+ console.log('onkeypress Event', e.key);
121
+ },
122
+ }}
123
+ />
124
+
125
+ <Story
126
+ name="KeyUp"
127
+ args={{
128
+ onkeyup: (e: TextInputKeyboardEvent) => {
129
+ console.log('onkeyup Event', e.key);
130
+ },
131
+ }}
132
+ />
@@ -7,6 +7,7 @@
7
7
  ClipboardEventHandler,
8
8
  FocusEventHandler,
9
9
  FormEventHandler,
10
+ KeyboardEventHandler,
10
11
  } from 'svelte/elements';
11
12
 
12
13
  export type PasswordInputToggleEvent = {
@@ -65,6 +66,12 @@
65
66
  oncut?: ClipboardEventHandler<HTMLInputElement>;
66
67
  /** ontoggle event handler */
67
68
  ontoggle?: (e: PasswordInputToggleEvent) => void;
69
+ /** onkeydown event handler */
70
+ onkeydown?: KeyboardEventHandler<HTMLInputElement>;
71
+ /** onkeypress event handler */
72
+ onkeypress?: KeyboardEventHandler<HTMLInputElement>;
73
+ /** onkeyup event handler */
74
+ onkeyup?: KeyboardEventHandler<HTMLInputElement>;
68
75
  }
69
76
  </script>
70
77
 
@@ -72,7 +79,7 @@
72
79
  import Icon from '@iconify/svelte';
73
80
  import UtilityButton from '$lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte';
74
81
  import InputEnclosure from '$lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte';
75
- import type { TextInputFocusEvent } from '../TextInput/TextInput.svelte';
82
+ import type { TextInputFocusEvent, TextInputKeyboardEvent } from '../TextInput/TextInput.svelte';
76
83
  import { DynamicInput, type DynamicInputFocusEvent } from '$lib/index.js';
77
84
 
78
85
  let {
@@ -90,6 +97,9 @@
90
97
  onpaste,
91
98
  oncopy,
92
99
  oncut,
100
+ onkeydown,
101
+ onkeypress,
102
+ onkeyup,
93
103
  before,
94
104
  after,
95
105
  customPasswordToggleIcon,
@@ -111,7 +121,6 @@
111
121
 
112
122
  function onfocusMod(e: DynamicInputFocusEvent) {
113
123
  const eTyped = e as TextInputFocusEvent;
114
- focused = true;
115
124
 
116
125
  if (onfocus) {
117
126
  onfocus(eTyped);
@@ -120,7 +129,6 @@
120
129
 
121
130
  function onblurMod(e: DynamicInputFocusEvent) {
122
131
  const eTyped = e as TextInputFocusEvent;
123
- focused = false;
124
132
 
125
133
  if (onblur) {
126
134
  onblur(eTyped);
@@ -156,6 +164,7 @@
156
164
  {id}
157
165
  {disabled}
158
166
  bind:ref
167
+ bind:focused
159
168
  {oninput}
160
169
  {onchange}
161
170
  onfocus={onfocusMod}
@@ -163,6 +172,9 @@
163
172
  {onpaste}
164
173
  {oncopy}
165
174
  {oncut}
175
+ onkeydown={onkeydown ? (e) => onkeydown(e as TextInputKeyboardEvent) : undefined}
176
+ onkeypress={onkeypress ? (e) => onkeypress(e as TextInputKeyboardEvent) : undefined}
177
+ onkeyup={onkeyup ? (e) => onkeyup(e as TextInputKeyboardEvent) : undefined}
166
178
  {placeholder}
167
179
  bind:value
168
180
  {readonly}
@@ -3,7 +3,10 @@
3
3
  import { selectOptions, storySelectArgTypes } from '../Select.stories.svelte';
4
4
  import Select, { type SelectOption } from '../Select.svelte';
5
5
  import type { TextInputClipboardEvent } from '../../TextInput/TextInput.svelte';
6
- import type { DynamicInputFocusEvent } from '$lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte';
6
+ import type {
7
+ DynamicInputFocusEvent,
8
+ DynamicInputKeyboardEvent,
9
+ } from '$lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte';
7
10
 
8
11
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
9
12
  const { Story } = defineMeta({
@@ -142,3 +145,30 @@
142
145
  },
143
146
  }}
144
147
  />
148
+
149
+ <Story
150
+ name="KeyDown"
151
+ args={{
152
+ onkeydown: (e: DynamicInputKeyboardEvent) => {
153
+ console.log('onkeydown Event', e.key);
154
+ },
155
+ }}
156
+ />
157
+
158
+ <Story
159
+ name="KeyPress"
160
+ args={{
161
+ onkeypress: (e: DynamicInputKeyboardEvent) => {
162
+ console.log('onkeypress Event', e.key);
163
+ },
164
+ }}
165
+ />
166
+
167
+ <Story
168
+ name="KeyUp"
169
+ args={{
170
+ onkeyup: (e: DynamicInputKeyboardEvent) => {
171
+ console.log('onkeyup Event', e.key);
172
+ },
173
+ }}
174
+ />
@@ -7,6 +7,7 @@
7
7
  ClipboardEventHandler,
8
8
  FocusEventHandler,
9
9
  FormEventHandler,
10
+ KeyboardEventHandler,
10
11
  MouseEventHandler,
11
12
  } from 'svelte/elements';
12
13
 
@@ -73,6 +74,12 @@
73
74
  oncopy?: ClipboardEventHandler<HTMLInputElement>;
74
75
  /** oncut event handler */
75
76
  oncut?: ClipboardEventHandler<HTMLInputElement>;
77
+ /** onkeydown event handler */
78
+ onkeydown?: KeyboardEventHandler<HTMLInputElement | HTMLButtonElement>;
79
+ /** onkeypress event handler */
80
+ onkeypress?: KeyboardEventHandler<HTMLInputElement | HTMLButtonElement>;
81
+ /** onkeyup event handler */
82
+ onkeyup?: KeyboardEventHandler<HTMLInputElement | HTMLButtonElement>;
76
83
  /** custom Content Formatting for variant button */
77
84
  customInputContent?: (val: SelectOption) => Snippet;
78
85
  /** custom Content Formatting for variant button */
@@ -146,6 +153,9 @@
146
153
  onpaste,
147
154
  oncopy,
148
155
  oncut,
156
+ onkeydown,
157
+ onkeypress,
158
+ onkeyup,
149
159
  before,
150
160
  after,
151
161
  error = false,
@@ -375,6 +385,9 @@
375
385
  {onpaste}
376
386
  {oncopy}
377
387
  {oncut}
388
+ {onkeydown}
389
+ {onkeypress}
390
+ {onkeyup}
378
391
  {placeholder}
379
392
  value={searchable ? searchTerm : selectedOption?.label}
380
393
  {readonly}
@@ -3,6 +3,7 @@
3
3
  import TextInput, {
4
4
  type TextInputClipboardEvent,
5
5
  type TextInputFocusEvent,
6
+ type TextInputKeyboardEvent,
6
7
  } from '../TextInput.svelte';
7
8
  import { storyTextInputArgTypes } from '../TextInput.stories.svelte';
8
9
 
@@ -95,3 +96,30 @@
95
96
  },
96
97
  }}
97
98
  />
99
+
100
+ <Story
101
+ name="KeyDown"
102
+ args={{
103
+ onkeydown: (e: TextInputKeyboardEvent) => {
104
+ console.log('onkeydown Event', e.key);
105
+ },
106
+ }}
107
+ />
108
+
109
+ <Story
110
+ name="KeyPress"
111
+ args={{
112
+ onkeypress: (e: TextInputKeyboardEvent) => {
113
+ console.log('onkeypress Event', e.key);
114
+ },
115
+ }}
116
+ />
117
+
118
+ <Story
119
+ name="KeyUp"
120
+ args={{
121
+ onkeyup: (e: TextInputKeyboardEvent) => {
122
+ console.log('onkeyup Event', e.key);
123
+ },
124
+ }}
125
+ />