react-hook-core 0.5.5 → 0.5.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/lib/core.js CHANGED
@@ -4,6 +4,9 @@ exports.pageSizes = [12, 24, 60, 100, 120, 180, 300, 600]
4
4
  exports.sizes = exports.pageSizes
5
5
  var resources = (function () {
6
6
  function resources() {}
7
+ resources.getSortId = function (field) {
8
+ return field + "Sort"
9
+ }
7
10
  resources.removePhoneFormat = function (phone) {
8
11
  return phone ? phone.replace(resources.phone, "") : ""
9
12
  }
package/lib/search.js CHANGED
@@ -340,8 +340,26 @@ function buildSortFilter(obj, sortable) {
340
340
  return filter
341
341
  }
342
342
  exports.buildSortFilter = buildSortFilter
343
+ function getSortId(field) {
344
+ return core_1.resources.getSortId(field)
345
+ }
346
+ exports.getSortId = getSortId
343
347
  function addParametersIntoUrlWithSort(filter, state, isFirstLoad, setFilter) {
344
348
  var urlFilter = buildSortFilter(filter, state)
349
+ if (isFirstLoad) {
350
+ if (state.sortField) {
351
+ var eleId = getSortId(state.sortField)
352
+ var ele = document.getElementById(eleId)
353
+ if (ele) {
354
+ if (ele.children.length === 0) {
355
+ toggleSortStyle(ele)
356
+ if (state.sortType === "-") {
357
+ toggleSortStyle(ele)
358
+ }
359
+ }
360
+ }
361
+ }
362
+ }
345
363
  addParametersIntoUrl(urlFilter, isFirstLoad)
346
364
  if (setFilter) {
347
365
  setFilter(filter)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hook-core",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "react",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/core.ts CHANGED
@@ -16,6 +16,9 @@ export class resources {
16
16
  static pageMaxSize = 7
17
17
  static phone = / |\-|\.|\(|\)/g
18
18
  static fax = / |\-|\.|\(|\)/g
19
+ static getSortId(field: string): string {
20
+ return field + "Sort"
21
+ }
19
22
  static removePhoneFormat(phone?: string | null): string {
20
23
  return phone ? phone.replace(resources.phone, "") : ""
21
24
  }
package/src/search.ts CHANGED
@@ -361,6 +361,9 @@ export function buildSortFilter<S extends Filter>(obj: S, sortable: Sortable): S
361
361
  delete filter.fields
362
362
  return filter
363
363
  }
364
+ export function getSortId(field: string): string {
365
+ return resources.getSortId(field)
366
+ }
364
367
  export function addParametersIntoUrlWithSort<F extends Filter>(
365
368
  filter: F,
366
369
  state: Sortable,
@@ -368,6 +371,20 @@ export function addParametersIntoUrlWithSort<F extends Filter>(
368
371
  setFilter?: (v: React.SetStateAction<F>) => void,
369
372
  ) {
370
373
  const urlFilter = buildSortFilter(filter, state)
374
+ if (isFirstLoad) {
375
+ if (state.sortField) {
376
+ const eleId = getSortId(state.sortField)
377
+ const ele = document.getElementById(eleId)
378
+ if (ele) {
379
+ if (ele.children.length === 0) {
380
+ toggleSortStyle(ele)
381
+ if (state.sortType === "-") {
382
+ toggleSortStyle(ele)
383
+ }
384
+ }
385
+ }
386
+ }
387
+ }
371
388
  addParametersIntoUrl(urlFilter, isFirstLoad)
372
389
  if (setFilter) {
373
390
  setFilter(filter)