intelliwaketssveltekitv25 0.1.115 → 0.1.117

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.
@@ -200,7 +200,7 @@ export declare function IsMobileOrTablet(): boolean;
200
200
  * @return {void}
201
201
  */
202
202
  export declare function DownloadString(filename: string, text: string): void;
203
- export declare function HandleKeyDownNumerics(event: KeyboardEvent, allowDecimals?: boolean): void;
203
+ export declare function HandleKeyDownNumerics(event: KeyboardEvent, allowDecimals?: boolean, allowNegative?: boolean): void;
204
204
  export type TInputNumberAttributes = Omit<HTMLInputAttributes, 'value' | 'this' | 'onchange' | 'min' | 'max' | 'use'> & {
205
205
  value: number | null;
206
206
  onchange?: (value: number | null) => void;
@@ -212,6 +212,7 @@ export type TInputNumberAttributes = Omit<HTMLInputAttributes, 'value' | 'this'
212
212
  prefix?: string;
213
213
  suffix?: string;
214
214
  shiftDigits?: number;
215
+ allowNegative?: boolean;
215
216
  use?: ActionArray;
216
217
  thisRef?: HTMLInputElement;
217
218
  };
package/dist/Functions.js CHANGED
@@ -607,11 +607,15 @@ export function DownloadString(filename, text) {
607
607
  element.click();
608
608
  document.body.removeChild(element);
609
609
  }
610
- export function HandleKeyDownNumerics(event, allowDecimals = true) {
610
+ export function HandleKeyDownNumerics(event, allowDecimals = true, allowNegative = false) {
611
611
  if (!allowDecimals && event.key === '.') {
612
612
  event.preventDefault();
613
613
  return;
614
614
  }
615
+ if (!allowNegative && event.key === '-') {
616
+ event.preventDefault();
617
+ return;
618
+ }
615
619
  if ([
616
620
  'Backspace',
617
621
  'Delete',
@@ -623,7 +627,8 @@ export function HandleKeyDownNumerics(event, allowDecimals = true) {
623
627
  'ArrowUp',
624
628
  'ArrowDown',
625
629
  '.',
626
- ','
630
+ ',',
631
+ '-'
627
632
  ].includes(event.key)) {
628
633
  return;
629
634
  }
@@ -21,6 +21,7 @@
21
21
  max = null,
22
22
  prefix,
23
23
  suffix,
24
+ allowNegative,
24
25
  shiftDigits = 0,
25
26
  use = [],
26
27
  thisRef = $bindable<HTMLInputElement>(),
@@ -70,7 +71,7 @@
70
71
  const input = event.target as HTMLInputElement
71
72
  const newValue = input.value
72
73
 
73
- const cleanValue = newValue.replace(/[^\d.]/g, '')
74
+ const cleanValue = newValue.replace(/[^\d.-]/g, '')
74
75
 
75
76
  let numericValue = CleanNumberNull(cleanValue, constrainDecimals)
76
77
  if (numericValue === null) {
@@ -106,7 +107,7 @@
106
107
  if (otherProps.oninput) otherProps.oninput(e)
107
108
  }}
108
109
  onkeydown={e => {
109
- HandleKeyDownNumerics(e, !!constrainDecimals)
110
+ HandleKeyDownNumerics(e, !!constrainDecimals, !!allowNegative)
110
111
  if (otherProps.onkeydown) otherProps.onkeydown(e)
111
112
  }}
112
113
  onblur={e => {
@@ -45,7 +45,10 @@
45
45
  controlClass = '',
46
46
  inputClass = '',
47
47
  parentDivElement = null,
48
- form = undefined
48
+ form = undefined,
49
+ onadd,
50
+ onclear,
51
+ onclearall
49
52
  }: {
50
53
  id?: string
51
54
  show?: boolean
@@ -82,7 +85,10 @@
82
85
  controlClass?: string
83
86
  inputClass?: string
84
87
  parentDivElement?: HTMLDivElement | null
85
- form?: string | undefined
88
+ form?: string | undefined,
89
+ onadd?: (item: T) => void,
90
+ onclear?: (item: T) => void,
91
+ onclearall?: () => void
86
92
  } = $props()
87
93
 
88
94
  let searchValue = $state('')
@@ -104,6 +110,7 @@
104
110
  searchValue = ''
105
111
  await tick()
106
112
  if (elInput) elInput.focus()
113
+ if (onadd) onadd(item)
107
114
  }
108
115
  }
109
116
  }
@@ -115,6 +122,7 @@
115
122
  await tick()
116
123
  elInput.focus()
117
124
  }
125
+ if (onclear) onclear(item)
118
126
  }
119
127
  }
120
128
 
@@ -129,6 +137,7 @@
129
137
  await tick()
130
138
  elInput.focus()
131
139
  }
140
+ if (onclearall) onclearall()
132
141
  }
133
142
  }
134
143
 
@@ -38,6 +38,9 @@ declare class __sveltets_Render<T extends TGenericMultiSelect> {
38
38
  inputClass?: string;
39
39
  parentDivElement?: HTMLDivElement | null;
40
40
  form?: string | undefined;
41
+ onadd?: ((item: T) => void) | undefined;
42
+ onclear?: ((item: T) => void) | undefined;
43
+ onclearall?: (() => void) | undefined;
41
44
  };
42
45
  events(): {};
43
46
  slots(): {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelliwaketssveltekitv25",
3
- "version": "0.1.115",
3
+ "version": "0.1.117",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",