@betterstore/react 0.5.8 → 0.5.9
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/dist/index.cjs.js +25 -13
- package/dist/index.mjs +25 -13
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -8194,6 +8194,7 @@ const Toast = (props)=>{
|
|
|
8194
8194
|
pointerStartRef.current = null;
|
|
8195
8195
|
},
|
|
8196
8196
|
onPointerDown: (event)=>{
|
|
8197
|
+
if (event.button === 2) return; // Return early on right click
|
|
8197
8198
|
if (disabled || !dismissible) return;
|
|
8198
8199
|
dragStartTime.current = new Date();
|
|
8199
8200
|
setOffsetBeforeRemove(offset.current);
|
|
@@ -9136,8 +9137,9 @@ class ZodError extends Error {
|
|
|
9136
9137
|
const formErrors = [];
|
|
9137
9138
|
for (const sub of this.issues) {
|
|
9138
9139
|
if (sub.path.length > 0) {
|
|
9139
|
-
|
|
9140
|
-
fieldErrors[
|
|
9140
|
+
const firstEl = sub.path[0];
|
|
9141
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
9142
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
9141
9143
|
}
|
|
9142
9144
|
else {
|
|
9143
9145
|
formErrors.push(mapper(sub));
|
|
@@ -9221,6 +9223,8 @@ const errorMap = (issue, _ctx) => {
|
|
|
9221
9223
|
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
9222
9224
|
else if (issue.type === "number")
|
|
9223
9225
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
9226
|
+
else if (issue.type === "bigint")
|
|
9227
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
9224
9228
|
else if (issue.type === "date")
|
|
9225
9229
|
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
9226
9230
|
else
|
|
@@ -9818,6 +9822,8 @@ function isValidJWT(jwt, alg) {
|
|
|
9818
9822
|
return false;
|
|
9819
9823
|
try {
|
|
9820
9824
|
const [header] = jwt.split(".");
|
|
9825
|
+
if (!header)
|
|
9826
|
+
return false;
|
|
9821
9827
|
// Convert base64url to base64
|
|
9822
9828
|
const base64 = header
|
|
9823
9829
|
.replace(/-/g, "+")
|
|
@@ -12877,9 +12883,6 @@ function cloneObject(data) {
|
|
|
12877
12883
|
if (data instanceof Date) {
|
|
12878
12884
|
copy = new Date(data);
|
|
12879
12885
|
}
|
|
12880
|
-
else if (data instanceof Set) {
|
|
12881
|
-
copy = new Set(data);
|
|
12882
|
-
}
|
|
12883
12886
|
else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
|
|
12884
12887
|
(isArray || isObject(data))) {
|
|
12885
12888
|
copy = isArray ? [] : {};
|
|
@@ -13128,7 +13131,8 @@ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) =>
|
|
|
13128
13131
|
return get(formValues, names, defaultValue);
|
|
13129
13132
|
}
|
|
13130
13133
|
if (Array.isArray(names)) {
|
|
13131
|
-
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
|
|
13134
|
+
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
|
|
13135
|
+
get(formValues, fieldName)));
|
|
13132
13136
|
}
|
|
13133
13137
|
isGlobal && (_names.watchAll = true);
|
|
13134
13138
|
return formValues;
|
|
@@ -14003,7 +14007,7 @@ function createFormControl(props = {}) {
|
|
|
14003
14007
|
errors: _options.errors || {},
|
|
14004
14008
|
disabled: _options.disabled || false,
|
|
14005
14009
|
};
|
|
14006
|
-
|
|
14010
|
+
let _fields = {};
|
|
14007
14011
|
let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
|
|
14008
14012
|
? cloneObject(_options.defaultValues || _options.values) || {}
|
|
14009
14013
|
: {};
|
|
@@ -14849,15 +14853,20 @@ function createFormControl(props = {}) {
|
|
|
14849
14853
|
}
|
|
14850
14854
|
}
|
|
14851
14855
|
}
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
if (!isUndefined(value)) {
|
|
14855
|
-
set(values, fieldName, value);
|
|
14856
|
+
if (keepStateOptions.keepFieldsRef) {
|
|
14857
|
+
for (const fieldName of _names.mount) {
|
|
14856
14858
|
setValue(fieldName, get(values, fieldName));
|
|
14857
14859
|
}
|
|
14858
14860
|
}
|
|
14861
|
+
else {
|
|
14862
|
+
_fields = {};
|
|
14863
|
+
}
|
|
14859
14864
|
}
|
|
14860
|
-
_formValues =
|
|
14865
|
+
_formValues = _options.shouldUnregister
|
|
14866
|
+
? keepStateOptions.keepDefaultValues
|
|
14867
|
+
? cloneObject(_defaultValues)
|
|
14868
|
+
: {}
|
|
14869
|
+
: cloneObject(values);
|
|
14861
14870
|
_subjects.array.next({
|
|
14862
14871
|
values: { ...values },
|
|
14863
14872
|
});
|
|
@@ -15139,7 +15148,10 @@ function useForm(props = {}) {
|
|
|
15139
15148
|
}, [control, formState.isDirty]);
|
|
15140
15149
|
React.useEffect(() => {
|
|
15141
15150
|
if (props.values && !deepEqual$1(props.values, _values.current)) {
|
|
15142
|
-
control._reset(props.values,
|
|
15151
|
+
control._reset(props.values, {
|
|
15152
|
+
keepFieldsRef: true,
|
|
15153
|
+
...control._options.resetOptions,
|
|
15154
|
+
});
|
|
15143
15155
|
_values.current = props.values;
|
|
15144
15156
|
updateFormState((state) => ({ ...state }));
|
|
15145
15157
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -8174,6 +8174,7 @@ const Toast = (props)=>{
|
|
|
8174
8174
|
pointerStartRef.current = null;
|
|
8175
8175
|
},
|
|
8176
8176
|
onPointerDown: (event)=>{
|
|
8177
|
+
if (event.button === 2) return; // Return early on right click
|
|
8177
8178
|
if (disabled || !dismissible) return;
|
|
8178
8179
|
dragStartTime.current = new Date();
|
|
8179
8180
|
setOffsetBeforeRemove(offset.current);
|
|
@@ -9116,8 +9117,9 @@ class ZodError extends Error {
|
|
|
9116
9117
|
const formErrors = [];
|
|
9117
9118
|
for (const sub of this.issues) {
|
|
9118
9119
|
if (sub.path.length > 0) {
|
|
9119
|
-
|
|
9120
|
-
fieldErrors[
|
|
9120
|
+
const firstEl = sub.path[0];
|
|
9121
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
9122
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
9121
9123
|
}
|
|
9122
9124
|
else {
|
|
9123
9125
|
formErrors.push(mapper(sub));
|
|
@@ -9201,6 +9203,8 @@ const errorMap = (issue, _ctx) => {
|
|
|
9201
9203
|
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
9202
9204
|
else if (issue.type === "number")
|
|
9203
9205
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
9206
|
+
else if (issue.type === "bigint")
|
|
9207
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
9204
9208
|
else if (issue.type === "date")
|
|
9205
9209
|
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
9206
9210
|
else
|
|
@@ -9798,6 +9802,8 @@ function isValidJWT(jwt, alg) {
|
|
|
9798
9802
|
return false;
|
|
9799
9803
|
try {
|
|
9800
9804
|
const [header] = jwt.split(".");
|
|
9805
|
+
if (!header)
|
|
9806
|
+
return false;
|
|
9801
9807
|
// Convert base64url to base64
|
|
9802
9808
|
const base64 = header
|
|
9803
9809
|
.replace(/-/g, "+")
|
|
@@ -12857,9 +12863,6 @@ function cloneObject(data) {
|
|
|
12857
12863
|
if (data instanceof Date) {
|
|
12858
12864
|
copy = new Date(data);
|
|
12859
12865
|
}
|
|
12860
|
-
else if (data instanceof Set) {
|
|
12861
|
-
copy = new Set(data);
|
|
12862
|
-
}
|
|
12863
12866
|
else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
|
|
12864
12867
|
(isArray || isObject(data))) {
|
|
12865
12868
|
copy = isArray ? [] : {};
|
|
@@ -13108,7 +13111,8 @@ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) =>
|
|
|
13108
13111
|
return get(formValues, names, defaultValue);
|
|
13109
13112
|
}
|
|
13110
13113
|
if (Array.isArray(names)) {
|
|
13111
|
-
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
|
|
13114
|
+
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
|
|
13115
|
+
get(formValues, fieldName)));
|
|
13112
13116
|
}
|
|
13113
13117
|
isGlobal && (_names.watchAll = true);
|
|
13114
13118
|
return formValues;
|
|
@@ -13983,7 +13987,7 @@ function createFormControl(props = {}) {
|
|
|
13983
13987
|
errors: _options.errors || {},
|
|
13984
13988
|
disabled: _options.disabled || false,
|
|
13985
13989
|
};
|
|
13986
|
-
|
|
13990
|
+
let _fields = {};
|
|
13987
13991
|
let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
|
|
13988
13992
|
? cloneObject(_options.defaultValues || _options.values) || {}
|
|
13989
13993
|
: {};
|
|
@@ -14829,15 +14833,20 @@ function createFormControl(props = {}) {
|
|
|
14829
14833
|
}
|
|
14830
14834
|
}
|
|
14831
14835
|
}
|
|
14832
|
-
|
|
14833
|
-
|
|
14834
|
-
if (!isUndefined(value)) {
|
|
14835
|
-
set(values, fieldName, value);
|
|
14836
|
+
if (keepStateOptions.keepFieldsRef) {
|
|
14837
|
+
for (const fieldName of _names.mount) {
|
|
14836
14838
|
setValue(fieldName, get(values, fieldName));
|
|
14837
14839
|
}
|
|
14838
14840
|
}
|
|
14841
|
+
else {
|
|
14842
|
+
_fields = {};
|
|
14843
|
+
}
|
|
14839
14844
|
}
|
|
14840
|
-
_formValues =
|
|
14845
|
+
_formValues = _options.shouldUnregister
|
|
14846
|
+
? keepStateOptions.keepDefaultValues
|
|
14847
|
+
? cloneObject(_defaultValues)
|
|
14848
|
+
: {}
|
|
14849
|
+
: cloneObject(values);
|
|
14841
14850
|
_subjects.array.next({
|
|
14842
14851
|
values: { ...values },
|
|
14843
14852
|
});
|
|
@@ -15119,7 +15128,10 @@ function useForm(props = {}) {
|
|
|
15119
15128
|
}, [control, formState.isDirty]);
|
|
15120
15129
|
React__default.useEffect(() => {
|
|
15121
15130
|
if (props.values && !deepEqual$1(props.values, _values.current)) {
|
|
15122
|
-
control._reset(props.values,
|
|
15131
|
+
control._reset(props.values, {
|
|
15132
|
+
keepFieldsRef: true,
|
|
15133
|
+
...control._options.resetOptions,
|
|
15134
|
+
});
|
|
15123
15135
|
_values.current = props.values;
|
|
15124
15136
|
updateFormState((state) => ({ ...state }));
|
|
15125
15137
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betterstore/react",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"typescript": "5.8.2",
|
|
29
29
|
"vite": "^6.3.5",
|
|
30
30
|
"@betterstore/eslint-config": "0.0.0",
|
|
31
|
-
"@betterstore/
|
|
32
|
-
"@betterstore/
|
|
31
|
+
"@betterstore/typescript-config": "0.0.0",
|
|
32
|
+
"@betterstore/sdk": "0.5.9"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0 || ^19.0.0",
|