react-hook-core 0.1.9 → 0.1.11

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/route.js CHANGED
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var qs = require("query-string");
4
- function navigate(history, stateTo) {
5
- history.push(stateTo);
6
- }
7
- exports.navigate = navigate;
8
4
  function buildFromUrl() {
9
5
  return buildParameters(window.location.search);
10
6
  }
@@ -13,7 +9,7 @@ function buildParameters(url) {
13
9
  var urlSearch = url;
14
10
  var i = urlSearch.indexOf('?');
15
11
  if (i >= 0) {
16
- urlSearch = url.substr(i + 1);
12
+ urlSearch = url.substring(i + 1);
17
13
  }
18
14
  var parsed = qs.parse(urlSearch);
19
15
  return parsed;
package/lib/state.js CHANGED
@@ -120,6 +120,14 @@ function buildState(e, state, ctrl, modelName, tloc) {
120
120
  return objSet;
121
121
  }
122
122
  else {
123
+ if (ctrl.tagName === 'SELECT') {
124
+ if (ctrl.value === '' || !ctrl.value) {
125
+ ctrl.removeAttribute('data-value');
126
+ }
127
+ else {
128
+ ctrl.setAttribute('data-value', 'data-value');
129
+ }
130
+ }
123
131
  var data = util_1.valueOf(ctrl, tloc, e.type);
124
132
  if (data.mustChange) {
125
133
  if (field.indexOf('.') < 0 && field.indexOf('[') < 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hook-core",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "react",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/route.ts CHANGED
@@ -1,10 +1,5 @@
1
- import * as H from 'history';
2
1
  import * as qs from 'query-string';
3
2
 
4
- export function navigate(history: H.History, stateTo: string) {
5
- history.push(stateTo);
6
- }
7
-
8
3
  export function buildFromUrl<S>(): S {
9
4
  return buildParameters(window.location.search);
10
5
  }
@@ -12,7 +7,7 @@ export function buildParameters<T>(url: string): T {
12
7
  let urlSearch = url;
13
8
  const i = urlSearch.indexOf('?');
14
9
  if (i >= 0) {
15
- urlSearch = url.substr(i + 1);
10
+ urlSearch = url.substring(i + 1);
16
11
  }
17
12
  const parsed: any = qs.parse(urlSearch);
18
13
  return parsed;
package/src/state.ts CHANGED
@@ -100,6 +100,13 @@ export function buildState<S, K extends keyof S>(e: any, state: Readonly<S>, ctr
100
100
  objSet[modelName] = model;
101
101
  return objSet;
102
102
  } else {
103
+ if (ctrl.tagName === 'SELECT') {
104
+ if (ctrl.value === '' || !ctrl.value) {
105
+ ctrl.removeAttribute('data-value');
106
+ } else {
107
+ ctrl.setAttribute('data-value', 'data-value');
108
+ }
109
+ }
103
110
  const data = valueOf(ctrl, tloc, e.type);
104
111
  if (data.mustChange) {
105
112
  if (field.indexOf('.') < 0 && field.indexOf('[') < 0) {
package/src/update.ts CHANGED
@@ -43,7 +43,7 @@ export const useUpdate = <T>(initialState: T, getName?: ((f?: HTMLFormElement|nu
43
43
  }
44
44
  const l = localeOf(lc, getLocale);
45
45
  handleEvent(e, removeErr);
46
- const objSet = buildState(e, state, ctrl, mn, l);
46
+ const objSet = buildState<T, any>(e, state, ctrl, mn, l);
47
47
  if (objSet) {
48
48
  if (callback) {
49
49
  setState(objSet, callback);
@@ -53,7 +53,7 @@ export const useUpdate = <T>(initialState: T, getName?: ((f?: HTMLFormElement|nu
53
53
  }
54
54
  };
55
55
  const updateFlatState = (e: any, callback?: () => void, lc?: Locale) => {
56
- const objSet = buildFlatState(e, state, lc);
56
+ const objSet = buildFlatState<T, any>(e, state, lc);
57
57
  if (objSet) {
58
58
  if (callback) {
59
59
  setState(objSet, callback);
package/src/useSearch.ts CHANGED
@@ -57,7 +57,7 @@ export interface InitSearchComponentParam<T, M extends Filter, S> extends Search
57
57
  createFilter?: () => M;
58
58
  initialize?: (ld: (s: M, auto?: boolean) => void, setState2: DispatchWithCallback<Partial<S>>, com?: SearchComponentState<T, M>) => void;
59
59
  }
60
- export interface HookPropsSearchParameter<T, S extends Filter, ST, P> extends HookPropsBaseSearchParameter<T, S, ST, P> {
60
+ export interface HookPropsSearchParameter<T, S extends Filter, ST extends SearchComponentState<T, S>, P> extends HookPropsBaseSearchParameter<T, S, ST, P> {
61
61
  createFilter?: () => S;
62
62
  initialize?: (ld: (s: S, auto?: boolean) => void, setState2: DispatchWithCallback<Partial<ST>>, com?: SearchComponentState<T, S>) => void;
63
63
  }
@@ -112,7 +112,7 @@ export interface HookBaseSearchParameter<T, S extends Filter, ST extends SearchC
112
112
  getLocale?: () => Locale;
113
113
  autoSearch?: boolean;
114
114
  }
115
- export interface HookPropsBaseSearchParameter<T, S extends Filter, ST, P> extends HookBaseSearchParameter<T, S, ST> {
115
+ export interface HookPropsBaseSearchParameter<T, S extends Filter, ST extends SearchComponentState<T, S>, P> extends HookBaseSearchParameter<T, S, ST> {
116
116
  props?: P;
117
117
  // prepareCustomData?: (data: any) => void;
118
118
  }