dn-react-router-toolkit 0.6.8 → 0.6.10

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.
@@ -128,22 +128,37 @@ function StoreTextEditor({
128
128
  getter,
129
129
  setter,
130
130
  defaultValue,
131
+ ref,
131
132
  ...props
132
133
  }) {
133
- const ref = (0, import_react4.useRef)(null);
134
+ const controllerRef = (0, import_react4.useRef)(null);
135
+ (0, import_react4.useImperativeHandle)(
136
+ ref,
137
+ () => controllerRef.current,
138
+ []
139
+ );
134
140
  const { dispatch } = (0, import_react_store_input.useStoreController)(store, {
135
141
  onSubscribe: (state) => {
136
- const controller = ref.current;
142
+ const controller = controllerRef.current;
137
143
  if (!controller) {
138
144
  return;
139
145
  }
140
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
146
+ const getResult = () => {
147
+ if (getter) {
148
+ return getter(state);
149
+ }
150
+ if (name) {
151
+ return state[name];
152
+ }
153
+ return "";
154
+ };
155
+ const result = getResult();
141
156
  if (controller.value !== result) {
142
157
  controller.value = result;
143
158
  }
144
159
  },
145
160
  onDispatch: (state) => {
146
- const controller = ref.current;
161
+ const controller = controllerRef.current;
147
162
  if (!controller) {
148
163
  return;
149
164
  }
@@ -169,7 +184,7 @@ function StoreTextEditor({
169
184
  import_dn_react_text_editor.TextEditor,
170
185
  {
171
186
  ...props,
172
- ref,
187
+ ref: controllerRef,
173
188
  defaultValue: defaultValue ?? getDefaultValue(),
174
189
  onChange: (e) => {
175
190
  dispatch();
@@ -83,29 +83,44 @@ import {
83
83
  TextEditor
84
84
  } from "dn-react-text-editor";
85
85
  import { useStoreController } from "react-store-input";
86
- import React3, { useRef } from "react";
86
+ import React3, { useImperativeHandle, useRef } from "react";
87
87
  function StoreTextEditor({
88
88
  store,
89
89
  name,
90
90
  getter,
91
91
  setter,
92
92
  defaultValue,
93
+ ref,
93
94
  ...props
94
95
  }) {
95
- const ref = useRef(null);
96
+ const controllerRef = useRef(null);
97
+ useImperativeHandle(
98
+ ref,
99
+ () => controllerRef.current,
100
+ []
101
+ );
96
102
  const { dispatch } = useStoreController(store, {
97
103
  onSubscribe: (state) => {
98
- const controller = ref.current;
104
+ const controller = controllerRef.current;
99
105
  if (!controller) {
100
106
  return;
101
107
  }
102
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
108
+ const getResult = () => {
109
+ if (getter) {
110
+ return getter(state);
111
+ }
112
+ if (name) {
113
+ return state[name];
114
+ }
115
+ return "";
116
+ };
117
+ const result = getResult();
103
118
  if (controller.value !== result) {
104
119
  controller.value = result;
105
120
  }
106
121
  },
107
122
  onDispatch: (state) => {
108
- const controller = ref.current;
123
+ const controller = controllerRef.current;
109
124
  if (!controller) {
110
125
  return;
111
126
  }
@@ -131,7 +146,7 @@ function StoreTextEditor({
131
146
  TextEditor,
132
147
  {
133
148
  ...props,
134
- ref,
149
+ ref: controllerRef,
135
150
  defaultValue: defaultValue ?? getDefaultValue(),
136
151
  onChange: (e) => {
137
152
  dispatch();
@@ -8,6 +8,6 @@ type Props<TState> = {
8
8
  getter?: (state: TState) => string;
9
9
  setter?: (state: TState, value: string) => void;
10
10
  } & TextEditorProps;
11
- declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ...props }: Props<TState>): React__default.JSX.Element;
11
+ declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ref, ...props }: Props<TState>): React__default.JSX.Element;
12
12
 
13
13
  export { StoreTextEditor };
@@ -8,6 +8,6 @@ type Props<TState> = {
8
8
  getter?: (state: TState) => string;
9
9
  setter?: (state: TState, value: string) => void;
10
10
  } & TextEditorProps;
11
- declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ...props }: Props<TState>): React__default.JSX.Element;
11
+ declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ref, ...props }: Props<TState>): React__default.JSX.Element;
12
12
 
13
13
  export { StoreTextEditor };
@@ -42,22 +42,37 @@ function StoreTextEditor({
42
42
  getter,
43
43
  setter,
44
44
  defaultValue,
45
+ ref,
45
46
  ...props
46
47
  }) {
47
- const ref = (0, import_react.useRef)(null);
48
+ const controllerRef = (0, import_react.useRef)(null);
49
+ (0, import_react.useImperativeHandle)(
50
+ ref,
51
+ () => controllerRef.current,
52
+ []
53
+ );
48
54
  const { dispatch } = (0, import_react_store_input.useStoreController)(store, {
49
55
  onSubscribe: (state) => {
50
- const controller = ref.current;
56
+ const controller = controllerRef.current;
51
57
  if (!controller) {
52
58
  return;
53
59
  }
54
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
60
+ const getResult = () => {
61
+ if (getter) {
62
+ return getter(state);
63
+ }
64
+ if (name) {
65
+ return state[name];
66
+ }
67
+ return "";
68
+ };
69
+ const result = getResult();
55
70
  if (controller.value !== result) {
56
71
  controller.value = result;
57
72
  }
58
73
  },
59
74
  onDispatch: (state) => {
60
- const controller = ref.current;
75
+ const controller = controllerRef.current;
61
76
  if (!controller) {
62
77
  return;
63
78
  }
@@ -83,7 +98,7 @@ function StoreTextEditor({
83
98
  import_dn_react_text_editor.TextEditor,
84
99
  {
85
100
  ...props,
86
- ref,
101
+ ref: controllerRef,
87
102
  defaultValue: defaultValue ?? getDefaultValue(),
88
103
  onChange: (e) => {
89
104
  dispatch();
@@ -3,29 +3,44 @@ import {
3
3
  TextEditor
4
4
  } from "dn-react-text-editor";
5
5
  import { useStoreController } from "react-store-input";
6
- import React, { useRef } from "react";
6
+ import React, { useImperativeHandle, useRef } from "react";
7
7
  function StoreTextEditor({
8
8
  store,
9
9
  name,
10
10
  getter,
11
11
  setter,
12
12
  defaultValue,
13
+ ref,
13
14
  ...props
14
15
  }) {
15
- const ref = useRef(null);
16
+ const controllerRef = useRef(null);
17
+ useImperativeHandle(
18
+ ref,
19
+ () => controllerRef.current,
20
+ []
21
+ );
16
22
  const { dispatch } = useStoreController(store, {
17
23
  onSubscribe: (state) => {
18
- const controller = ref.current;
24
+ const controller = controllerRef.current;
19
25
  if (!controller) {
20
26
  return;
21
27
  }
22
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
28
+ const getResult = () => {
29
+ if (getter) {
30
+ return getter(state);
31
+ }
32
+ if (name) {
33
+ return state[name];
34
+ }
35
+ return "";
36
+ };
37
+ const result = getResult();
23
38
  if (controller.value !== result) {
24
39
  controller.value = result;
25
40
  }
26
41
  },
27
42
  onDispatch: (state) => {
28
- const controller = ref.current;
43
+ const controller = controllerRef.current;
29
44
  if (!controller) {
30
45
  return;
31
46
  }
@@ -51,7 +66,7 @@ function StoreTextEditor({
51
66
  TextEditor,
52
67
  {
53
68
  ...props,
54
- ref,
69
+ ref: controllerRef,
55
70
  defaultValue: defaultValue ?? getDefaultValue(),
56
71
  onChange: (e) => {
57
72
  dispatch();
@@ -92,22 +92,37 @@ function StoreTextEditor({
92
92
  getter,
93
93
  setter,
94
94
  defaultValue,
95
+ ref,
95
96
  ...props
96
97
  }) {
97
- const ref = (0, import_react7.useRef)(null);
98
+ const controllerRef = (0, import_react7.useRef)(null);
99
+ (0, import_react7.useImperativeHandle)(
100
+ ref,
101
+ () => controllerRef.current,
102
+ []
103
+ );
98
104
  const { dispatch } = (0, import_react_store_input2.useStoreController)(store, {
99
105
  onSubscribe: (state) => {
100
- const controller = ref.current;
106
+ const controller = controllerRef.current;
101
107
  if (!controller) {
102
108
  return;
103
109
  }
104
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
110
+ const getResult = () => {
111
+ if (getter) {
112
+ return getter(state);
113
+ }
114
+ if (name) {
115
+ return state[name];
116
+ }
117
+ return "";
118
+ };
119
+ const result = getResult();
105
120
  if (controller.value !== result) {
106
121
  controller.value = result;
107
122
  }
108
123
  },
109
124
  onDispatch: (state) => {
110
- const controller = ref.current;
125
+ const controller = controllerRef.current;
111
126
  if (!controller) {
112
127
  return;
113
128
  }
@@ -133,7 +148,7 @@ function StoreTextEditor({
133
148
  import_dn_react_text_editor.TextEditor,
134
149
  {
135
150
  ...props,
136
- ref,
151
+ ref: controllerRef,
137
152
  defaultValue: defaultValue ?? getDefaultValue(),
138
153
  onChange: (e) => {
139
154
  dispatch();
@@ -51,29 +51,44 @@ import {
51
51
  TextEditor
52
52
  } from "dn-react-text-editor";
53
53
  import { useStoreController } from "react-store-input";
54
- import React5, { useRef } from "react";
54
+ import React5, { useImperativeHandle, useRef } from "react";
55
55
  function StoreTextEditor({
56
56
  store,
57
57
  name,
58
58
  getter,
59
59
  setter,
60
60
  defaultValue,
61
+ ref,
61
62
  ...props
62
63
  }) {
63
- const ref = useRef(null);
64
+ const controllerRef = useRef(null);
65
+ useImperativeHandle(
66
+ ref,
67
+ () => controllerRef.current,
68
+ []
69
+ );
64
70
  const { dispatch } = useStoreController(store, {
65
71
  onSubscribe: (state) => {
66
- const controller = ref.current;
72
+ const controller = controllerRef.current;
67
73
  if (!controller) {
68
74
  return;
69
75
  }
70
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
76
+ const getResult = () => {
77
+ if (getter) {
78
+ return getter(state);
79
+ }
80
+ if (name) {
81
+ return state[name];
82
+ }
83
+ return "";
84
+ };
85
+ const result = getResult();
71
86
  if (controller.value !== result) {
72
87
  controller.value = result;
73
88
  }
74
89
  },
75
90
  onDispatch: (state) => {
76
- const controller = ref.current;
91
+ const controller = controllerRef.current;
77
92
  if (!controller) {
78
93
  return;
79
94
  }
@@ -99,7 +114,7 @@ function StoreTextEditor({
99
114
  TextEditor,
100
115
  {
101
116
  ...props,
102
- ref,
117
+ ref: controllerRef,
103
118
  defaultValue: defaultValue ?? getDefaultValue(),
104
119
  onChange: (e) => {
105
120
  dispatch();
@@ -633,22 +633,37 @@ function StoreTextEditor({
633
633
  getter,
634
634
  setter,
635
635
  defaultValue,
636
+ ref,
636
637
  ...props
637
638
  }) {
638
- const ref = (0, import_react12.useRef)(null);
639
+ const controllerRef = (0, import_react12.useRef)(null);
640
+ (0, import_react12.useImperativeHandle)(
641
+ ref,
642
+ () => controllerRef.current,
643
+ []
644
+ );
639
645
  const { dispatch } = (0, import_react_store_input2.useStoreController)(store, {
640
646
  onSubscribe: (state) => {
641
- const controller = ref.current;
647
+ const controller = controllerRef.current;
642
648
  if (!controller) {
643
649
  return;
644
650
  }
645
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
651
+ const getResult = () => {
652
+ if (getter) {
653
+ return getter(state);
654
+ }
655
+ if (name) {
656
+ return state[name];
657
+ }
658
+ return "";
659
+ };
660
+ const result = getResult();
646
661
  if (controller.value !== result) {
647
662
  controller.value = result;
648
663
  }
649
664
  },
650
665
  onDispatch: (state) => {
651
- const controller = ref.current;
666
+ const controller = controllerRef.current;
652
667
  if (!controller) {
653
668
  return;
654
669
  }
@@ -674,7 +689,7 @@ function StoreTextEditor({
674
689
  import_dn_react_text_editor.TextEditor,
675
690
  {
676
691
  ...props,
677
- ref,
692
+ ref: controllerRef,
678
693
  defaultValue: defaultValue ?? getDefaultValue(),
679
694
  onChange: (e) => {
680
695
  dispatch();
@@ -600,29 +600,44 @@ import {
600
600
  TextEditor
601
601
  } from "dn-react-text-editor";
602
602
  import { useStoreController } from "react-store-input";
603
- import React10, { useRef } from "react";
603
+ import React10, { useImperativeHandle, useRef } from "react";
604
604
  function StoreTextEditor({
605
605
  store,
606
606
  name,
607
607
  getter,
608
608
  setter,
609
609
  defaultValue,
610
+ ref,
610
611
  ...props
611
612
  }) {
612
- const ref = useRef(null);
613
+ const controllerRef = useRef(null);
614
+ useImperativeHandle(
615
+ ref,
616
+ () => controllerRef.current,
617
+ []
618
+ );
613
619
  const { dispatch } = useStoreController(store, {
614
620
  onSubscribe: (state) => {
615
- const controller = ref.current;
621
+ const controller = controllerRef.current;
616
622
  if (!controller) {
617
623
  return;
618
624
  }
619
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
625
+ const getResult = () => {
626
+ if (getter) {
627
+ return getter(state);
628
+ }
629
+ if (name) {
630
+ return state[name];
631
+ }
632
+ return "";
633
+ };
634
+ const result = getResult();
620
635
  if (controller.value !== result) {
621
636
  controller.value = result;
622
637
  }
623
638
  },
624
639
  onDispatch: (state) => {
625
- const controller = ref.current;
640
+ const controller = controllerRef.current;
626
641
  if (!controller) {
627
642
  return;
628
643
  }
@@ -648,7 +663,7 @@ function StoreTextEditor({
648
663
  TextEditor,
649
664
  {
650
665
  ...props,
651
- ref,
666
+ ref: controllerRef,
652
667
  defaultValue: defaultValue ?? getDefaultValue(),
653
668
  onChange: (e) => {
654
669
  dispatch();
@@ -7832,22 +7832,37 @@ function StoreTextEditor({
7832
7832
  getter,
7833
7833
  setter,
7834
7834
  defaultValue,
7835
+ ref,
7835
7836
  ...props
7836
7837
  }) {
7837
- const ref = (0, import_react7.useRef)(null);
7838
+ const controllerRef = (0, import_react7.useRef)(null);
7839
+ (0, import_react7.useImperativeHandle)(
7840
+ ref,
7841
+ () => controllerRef.current,
7842
+ []
7843
+ );
7838
7844
  const { dispatch } = (0, import_react_store_input2.useStoreController)(store, {
7839
7845
  onSubscribe: (state) => {
7840
- const controller = ref.current;
7846
+ const controller = controllerRef.current;
7841
7847
  if (!controller) {
7842
7848
  return;
7843
7849
  }
7844
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
7850
+ const getResult = () => {
7851
+ if (getter) {
7852
+ return getter(state);
7853
+ }
7854
+ if (name) {
7855
+ return state[name];
7856
+ }
7857
+ return "";
7858
+ };
7859
+ const result = getResult();
7845
7860
  if (controller.value !== result) {
7846
7861
  controller.value = result;
7847
7862
  }
7848
7863
  },
7849
7864
  onDispatch: (state) => {
7850
- const controller = ref.current;
7865
+ const controller = controllerRef.current;
7851
7866
  if (!controller) {
7852
7867
  return;
7853
7868
  }
@@ -7873,7 +7888,7 @@ function StoreTextEditor({
7873
7888
  import_dn_react_text_editor.TextEditor,
7874
7889
  {
7875
7890
  ...props,
7876
- ref,
7891
+ ref: controllerRef,
7877
7892
  defaultValue: defaultValue ?? getDefaultValue(),
7878
7893
  onChange: (e) => {
7879
7894
  dispatch();
@@ -7808,29 +7808,44 @@ import {
7808
7808
  TextEditor
7809
7809
  } from "dn-react-text-editor";
7810
7810
  import { useStoreController } from "react-store-input";
7811
- import React5, { useRef } from "react";
7811
+ import React5, { useImperativeHandle, useRef } from "react";
7812
7812
  function StoreTextEditor({
7813
7813
  store,
7814
7814
  name,
7815
7815
  getter,
7816
7816
  setter,
7817
7817
  defaultValue,
7818
+ ref,
7818
7819
  ...props
7819
7820
  }) {
7820
- const ref = useRef(null);
7821
+ const controllerRef = useRef(null);
7822
+ useImperativeHandle(
7823
+ ref,
7824
+ () => controllerRef.current,
7825
+ []
7826
+ );
7821
7827
  const { dispatch } = useStoreController(store, {
7822
7828
  onSubscribe: (state) => {
7823
- const controller = ref.current;
7829
+ const controller = controllerRef.current;
7824
7830
  if (!controller) {
7825
7831
  return;
7826
7832
  }
7827
- const result = (getter ? getter(state) : name ? state[name] : "") || "";
7833
+ const getResult = () => {
7834
+ if (getter) {
7835
+ return getter(state);
7836
+ }
7837
+ if (name) {
7838
+ return state[name];
7839
+ }
7840
+ return "";
7841
+ };
7842
+ const result = getResult();
7828
7843
  if (controller.value !== result) {
7829
7844
  controller.value = result;
7830
7845
  }
7831
7846
  },
7832
7847
  onDispatch: (state) => {
7833
- const controller = ref.current;
7848
+ const controller = controllerRef.current;
7834
7849
  if (!controller) {
7835
7850
  return;
7836
7851
  }
@@ -7856,7 +7871,7 @@ function StoreTextEditor({
7856
7871
  TextEditor,
7857
7872
  {
7858
7873
  ...props,
7859
- ref,
7874
+ ref: controllerRef,
7860
7875
  defaultValue: defaultValue ?? getDefaultValue(),
7861
7876
  onChange: (e) => {
7862
7877
  dispatch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-router-toolkit",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",
@@ -89,7 +89,7 @@
89
89
  "dn-react-text-editor": "^0.3.5",
90
90
  "dn-react-toolkit": "^0.2.49",
91
91
  "pg": "^8.16.3",
92
- "react-store-input": "^0.1.7",
92
+ "react-store-input": "^0.1.9",
93
93
  "uuid": "^13.0.0"
94
94
  },
95
95
  "peerDependencies": {