dn-react-router-toolkit 0.6.7 → 0.6.8

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