Skip to content

Commit

Permalink
Merge pull request #35 from thinknimble/fix/remove-rn-uuid
Browse files Browse the repository at this point in the history
Remove react-native-uuid
  • Loading branch information
lakardion authored Jan 14, 2025
2 parents 4abd7ea + 07f688c commit 2afcf58
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-shirts-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@thinknimble/tn-forms': patch
---

Fix issue with uuid - remove it and use timestamp ms instead
7 changes: 2 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ __export(index_exports, {
});
module.exports = __toCommonJS(index_exports);

// src/forms.ts
var import_react_native_uuid = __toESM(require("react-native-uuid"));

// src/utils.ts
function notNullOrUndefined(value) {
return value !== null && typeof value !== "undefined";
Expand Down Expand Up @@ -130,12 +127,12 @@ var FormField = class _FormField {
label = ""
} = {}) {
this.value = Array.isArray(value) ? [...value] : value !== null && typeof value == "object" ? { ...value } : value === void 0 ? "" : value;
this.name = name ? name : import_react_native_uuid.default.v4();
this.name = name ? name : String(Date.now());
this.errors = errors;
this.validators = validators;
this.placeholder = placeholder;
this.type = type;
this.id = id ? id : name ? name : "field-" + import_react_native_uuid.default.v4();
this.id = id ? id : name ? name : "field-" + String(Date.now());
this._isTouched = isTouched;
this.label = label;
}
Expand Down
7 changes: 2 additions & 5 deletions dist/index.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// src/forms.ts
import uuid from "react-native-uuid";

// src/utils.ts
function notNullOrUndefined(value) {
return value !== null && typeof value !== "undefined";
Expand Down Expand Up @@ -71,12 +68,12 @@ var FormField = class _FormField {
label = ""
} = {}) {
this.value = Array.isArray(value) ? [...value] : value !== null && typeof value == "object" ? { ...value } : value === void 0 ? "" : value;
this.name = name ? name : uuid.v4();
this.name = name ? name : String(Date.now());
this.errors = errors;
this.validators = validators;
this.placeholder = placeholder;
this.type = type;
this.id = id ? id : name ? name : "field-" + uuid.v4();
this.id = id ? id : name ? name : "field-" + String(Date.now());
this._isTouched = isTouched;
this.label = label;
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"email-validator": "^2.0.4",
"install": "^0.13.0",
"libphonenumber-js": "^1.11.11",
"luxon": "^2.4.0",
"react-native-uuid": "^2.0.1"
"luxon": "^2.4.0"
},
"devDependencies": {
"@types/luxon": "^3.0.0",
Expand Down
9 changes: 0 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
TFormInstanceFields,
} from './interfaces'

import uuid from 'react-native-uuid'
import { isFormArray, isFormField } from './utils'

function setFormFieldValueFromKwargs<T, TName extends string = ''>(
Expand Down Expand Up @@ -79,12 +78,12 @@ export class FormField<T = string, TName extends string = ''> implements IFormFi
? ''
: value
) as T
this.name = (name ? name : (uuid.v4() as string)) as TName
this.name = (name ? name : (String(Date.now()))) as TName
this.errors = errors
this.validators = validators
this.placeholder = placeholder
this.type = type
this.id = id ? id : name ? name : 'field' + '-' + uuid.v4()
this.id = id ? id : name ? name : 'field' + '-' + String(Date.now())
this._isTouched = isTouched
this.label = label
}
Expand Down

0 comments on commit 2afcf58

Please sign in to comment.