sveltacular 0.0.47 → 0.0.48

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.
@@ -2,7 +2,7 @@
2
2
  import { createEventDispatcher } from "svelte";
3
3
  import FormField from "../form-field.svelte";
4
4
  import FormLabel from "../form-label.svelte";
5
- export let value;
5
+ export let value = "";
6
6
  export let size = "md";
7
7
  const id = uniqueId();
8
8
  const dispatch = createEventDispatcher();
@@ -63,6 +63,10 @@ const keyDown = (event) => {
63
63
  const isNumeric = !isNaN(Number(event.key));
64
64
  const isCursorHighlighting = props.target.selectionStart !== props.target.selectionEnd;
65
65
  const isAcceptable = isNumeric || isDelete;
66
+ const isRightArrow = event.key === "ArrowRight" || event.key === "Tab";
67
+ const isLeftArrow = event.key === "ArrowLeft";
68
+ if (isRightArrow || isLeftArrow)
69
+ return;
66
70
  if (!isAcceptable)
67
71
  event.preventDefault();
68
72
  const newValue = (() => {
@@ -2,7 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  import { type FormFieldSizeOptions } from '../../index.js';
3
3
  declare const __propDef: {
4
4
  props: {
5
- value: string;
5
+ value?: string | undefined;
6
6
  size?: FormFieldSizeOptions | undefined;
7
7
  };
8
8
  events: {
@@ -38,6 +38,15 @@ const onInput = (e) => {
38
38
  } else if (textCase === "upper") {
39
39
  value = value.toUpperCase();
40
40
  }
41
+ if (type === "email") {
42
+ value = value.replace(/\s/g, "");
43
+ }
44
+ if (type === "tel") {
45
+ value = value.replace(/[^0-9]/g, "");
46
+ }
47
+ if (type === "url") {
48
+ value = value.replace(/\s/g, "");
49
+ }
41
50
  dipatch("input", value);
42
51
  };
43
52
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltacular",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "description": "A Svelte component library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",