react-hook-core 0.3.5 → 0.3.7

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/lib/index.js CHANGED
@@ -137,3 +137,7 @@ function datetimeToString(date) {
137
137
  }
138
138
  exports.datetimeToString = datetimeToString;
139
139
  ;
140
+ function getNumber(event) {
141
+ return parseInt(event.currentTarget.value, 10);
142
+ }
143
+ exports.getNumber = getNumber;
package/lib/search.js CHANGED
@@ -492,23 +492,28 @@ function addParametersIntoUrl(ft, isFirstLoad, page, fields, limit) {
492
492
  }
493
493
  }
494
494
  exports.addParametersIntoUrl = addParametersIntoUrl;
495
- function buildSort(filter) {
496
- var sort = {};
497
- var st = filter.sort;
498
- if (st && st.length > 0) {
499
- var ch = st.charAt(0);
495
+ function buildSort(sort) {
496
+ var sortObj = {};
497
+ if (sort && sort.length > 0) {
498
+ var ch = sort.charAt(0);
500
499
  if (ch === "+" || ch === "-") {
501
- sort.field = st.substring(1);
502
- sort.type = ch;
500
+ sortObj.field = sort.substring(1);
501
+ sortObj.type = ch;
503
502
  }
504
503
  else {
505
- sort.field = st;
506
- sort.type = "";
504
+ sortObj.field = sort;
505
+ sortObj.type = "";
507
506
  }
508
507
  }
509
- return sort;
508
+ return sortObj;
510
509
  }
511
510
  exports.buildSort = buildSort;
511
+ function setSort(sortable, sort) {
512
+ var st = buildSort(sort);
513
+ sortable.sortField = st.field;
514
+ sortable.sortType = st.type;
515
+ }
516
+ exports.setSort = setSort;
512
517
  function buildSortFilter(obj, sortable) {
513
518
  var filter = reflect_1.clone(obj);
514
519
  if (sortable.sortField && sortable.sortField.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hook-core",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "react",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -185,3 +185,6 @@ export function datetimeToString(date?: Date | string): string|undefined {
185
185
  const seconds = String(d2.getSeconds()).padStart(2, "0");
186
186
  return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
187
187
  };
188
+ export function getNumber(event: ChangeEvent<HTMLSelectElement|HTMLInputElement>): number {
189
+ return parseInt(event.currentTarget.value, 10)
190
+ }
package/src/reflect.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StringMap } from "core";
1
+ import { StringMap } from "./core";
2
2
  import { NavigateFunction } from "react-router-dom"
3
3
 
4
4
  export function clone(obj: any): any {
package/src/search.ts CHANGED
@@ -1,24 +1,6 @@
1
- import { Filter, resources, StringMap } from "./core";
1
+ import { Filter, Locale, resources, StringMap } from "./core";
2
2
  import { clone } from "./reflect";
3
3
 
4
- interface Locale {
5
- id?: string;
6
- countryCode: string;
7
- dateFormat: string;
8
- firstDayOfWeek: number;
9
- decimalSeparator: string;
10
- groupSeparator: string;
11
- decimalDigits: number;
12
- currencyCode: string;
13
- currencySymbol: string;
14
- currencyPattern: number;
15
- currencySample?: string;
16
- }
17
- interface ResourceService {
18
- value(key: string, param?: any): string;
19
- format(f: string, ...args: any[]): string;
20
- }
21
-
22
4
  export interface Sortable {
23
5
  sortField?: string;
24
6
  sortType?: string;
@@ -510,20 +492,24 @@ export interface Sort {
510
492
  field?: string;
511
493
  type?: string;
512
494
  }
513
- export function buildSort<F extends Filter>(filter: F): Sort {
514
- const sort: Sort = {}
515
- const st = filter.sort
516
- if (st && st.length > 0) {
517
- const ch = st.charAt(0)
495
+ export function buildSort(sort?: string | null): Sort {
496
+ const sortObj: Sort = {}
497
+ if (sort && sort.length > 0) {
498
+ const ch = sort.charAt(0)
518
499
  if (ch === "+" || ch === "-") {
519
- sort.field = st.substring(1)
520
- sort.type = ch
500
+ sortObj.field = sort.substring(1)
501
+ sortObj.type = ch
521
502
  } else {
522
- sort.field = st
523
- sort.type = ""
503
+ sortObj.field = sort
504
+ sortObj.type = ""
524
505
  }
525
506
  }
526
- return sort
507
+ return sortObj
508
+ }
509
+ export function setSort(sortable: Sortable, sort: string | undefined | null) {
510
+ const st = buildSort(sort);
511
+ sortable.sortField = st.field;
512
+ sortable.sortType = st.type;
527
513
  }
528
514
  export function buildSortFilter<S extends Filter>(obj: S, sortable: Sortable): S {
529
515
  const filter: any = clone(obj)