5htp-core 0.2.9-4 → 0.2.9-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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.2.9-
|
|
4
|
+
"version": "0.2.9-6",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -58,7 +58,7 @@ export default ({
|
|
|
58
58
|
- INIT
|
|
59
59
|
----------------------------------*/
|
|
60
60
|
|
|
61
|
-
const [{ value, focus, fieldProps }, setValue, commitValue, setState] = useInput(props, '');
|
|
61
|
+
const [{ value, focus, fieldProps }, setValue, commitValue, setState] = useInput(props, '' );
|
|
62
62
|
|
|
63
63
|
// Trigger onchange oly when finished typing
|
|
64
64
|
const refCommit = React.useRef<NodeJS.Timeout | null>(null);
|
|
@@ -71,7 +71,17 @@ export default ({
|
|
|
71
71
|
|
|
72
72
|
}, [value]);
|
|
73
73
|
|
|
74
|
-
const updateValue = v =>
|
|
74
|
+
const updateValue = v => {
|
|
75
|
+
if (type === 'number') {
|
|
76
|
+
|
|
77
|
+
// Fix on Safari: the browser allows to input text in input number
|
|
78
|
+
const numberValue = parseFloat(v);
|
|
79
|
+
if (!Number.isNaN( numberValue ))
|
|
80
|
+
setValue(numberValue);
|
|
81
|
+
|
|
82
|
+
} else
|
|
83
|
+
setValue(v);
|
|
84
|
+
}
|
|
75
85
|
|
|
76
86
|
const refInput = inputRef || React.useRef<HTMLInputElement>();
|
|
77
87
|
|
|
@@ -154,12 +164,12 @@ export default ({
|
|
|
154
164
|
// @ts-ignore: Property 'ref' does not exist on type 'IntrinsicAttributes'
|
|
155
165
|
ref={refInput}
|
|
156
166
|
value={value}
|
|
157
|
-
|
|
158
167
|
onFocus={() => setState({ focus: true })}
|
|
159
168
|
onBlur={() => setState({ focus: false })}
|
|
160
169
|
onChange={(e) => updateValue(e.target.value)}
|
|
161
170
|
|
|
162
|
-
onKeyDown={(e) => {
|
|
171
|
+
onKeyDown={(e: KeyboardEvent) => {
|
|
172
|
+
|
|
163
173
|
if (onPressEnter && e.key === 'Enter' && value !== undefined) {
|
|
164
174
|
commitValue();
|
|
165
175
|
onPressEnter(value)
|
|
@@ -69,9 +69,6 @@ type TColsToUpsert<TData extends TObjetDonnees> = (
|
|
|
69
69
|
|
|
70
70
|
const LogPrefix = '[database]'
|
|
71
71
|
|
|
72
|
-
const equalities = (data: TObjetDonnees, keys = Object.keys(data)) =>
|
|
73
|
-
keys.map(k => '' + k + ' = ' + mysql.escape( data[k] ))
|
|
74
|
-
|
|
75
72
|
/*----------------------------------
|
|
76
73
|
- CORE
|
|
77
74
|
----------------------------------*/
|
|
@@ -191,7 +188,7 @@ export default class SQL extends Service<Config, Hooks, Application> {
|
|
|
191
188
|
|
|
192
189
|
const keyword = prefix === '&' ? ' AND ' : ', '
|
|
193
190
|
|
|
194
|
-
value = Object.keys(value).length === 0 ? '1' : equalities(value).join( keyword );
|
|
191
|
+
value = Object.keys(value).length === 0 ? '1' : this.equalities(value).join( keyword );
|
|
195
192
|
|
|
196
193
|
// String: `SET :${column} = ${data}` => `SET balance = 10`
|
|
197
194
|
} else {
|
|
@@ -214,6 +211,9 @@ export default class SQL extends Service<Config, Hooks, Application> {
|
|
|
214
211
|
}).join(' ').trim();
|
|
215
212
|
}
|
|
216
213
|
|
|
214
|
+
public equalities = (data: TObjetDonnees, keys = Object.keys(data)) =>
|
|
215
|
+
keys.map(k => '' + k + ' = ' + mysql.escape( data[k] ))
|
|
216
|
+
|
|
217
217
|
/*----------------------------------
|
|
218
218
|
- OPERATIONS: LOW LEVELf
|
|
219
219
|
----------------------------------*/
|
|
@@ -336,8 +336,8 @@ export default class SQL extends Service<Config, Hooks, Application> {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
// Create equalities
|
|
339
|
-
const egalitesData = equalities(data).join(', ')
|
|
340
|
-
const egalitesWhere = equalities(where).join(' AND ')
|
|
339
|
+
const egalitesData = this.equalities(data).join(', ')
|
|
340
|
+
const egalitesWhere = this.equalities(where).join(' AND ')
|
|
341
341
|
|
|
342
342
|
// Build query
|
|
343
343
|
return this.database.query(`
|
|
@@ -509,7 +509,7 @@ export default class SQL extends Service<Config, Hooks, Application> {
|
|
|
509
509
|
|
|
510
510
|
const whereSql = typeof where === 'function' && where['string'] !== undefined
|
|
511
511
|
? where['string']
|
|
512
|
-
: equalities(where).join(' AND ');
|
|
512
|
+
: this.equalities(where).join(' AND ');
|
|
513
513
|
|
|
514
514
|
return this.database.query(`DELETE FROM ${table} WHERE ${whereSql};`, opts);
|
|
515
515
|
}
|