fenextjs-hook
Advanced tools
Comparing version 7.5.0 to 7.6.0
import { countryProps as CountryProps, stateProps as StateProps, cityProps as CityProps } from "country-state-city-nextjs"; | ||
import { CSCProps } from "fenextjs-interface/cjs/CSC"; | ||
import { CSCProps, CSCStringProps } from "fenextjs-interface/cjs/CSC"; | ||
import { useJsonStringProps } from "./useJsonString"; | ||
/** | ||
* Represents the properties for the useCSC hook. | ||
*/ | ||
export interface useCSCProps { | ||
/** | ||
* The default value for the CSC object. | ||
*/ | ||
defaultValue?: CSCProps; | ||
/** | ||
* onChangeDataAfter value for the CSC object. | ||
*/ | ||
onChange?: (data: CSCProps) => void; | ||
export interface useCSCProps extends useJsonStringProps<CSCProps, CSCStringProps> { | ||
} | ||
@@ -36,3 +29,3 @@ /** | ||
*/ | ||
export declare const useCSC: ({ defaultValue, onChange }: useCSCProps) => { | ||
export declare const useCSC: ({ defaultValue: defaultValueProps, value: valueProps, onChange: onChangeProps, defaultValueJsonString, valueJsonString, onChangeJsonString, parseJson_to_String, parseString_to_Json, }: useCSCProps) => { | ||
countrys: CountryProps[]; | ||
@@ -47,3 +40,3 @@ states: StateProps[]; | ||
}; | ||
export declare const useCountryStateCity: ({ defaultValue, onChange }: useCSCProps) => { | ||
export declare const useCountryStateCity: ({ defaultValue: defaultValueProps, value: valueProps, onChange: onChangeProps, defaultValueJsonString, valueJsonString, onChangeJsonString, parseJson_to_String, parseString_to_Json, }: useCSCProps) => { | ||
countrys: CountryProps[]; | ||
@@ -50,0 +43,0 @@ states: StateProps[]; |
@@ -7,2 +7,4 @@ "use strict"; | ||
const useData_1 = require("./useData"); | ||
const CSC_1 = require("fenextjs-functions/cjs/parse/CSC"); | ||
const useJsonString_1 = require("./useJsonString"); | ||
/** | ||
@@ -28,3 +30,13 @@ * Hook that provides a CSC (Country, State, City) selector functionality. | ||
*/ | ||
const useCSC = ({ defaultValue = {}, onChange }) => { | ||
const useCSC = ({ defaultValue: defaultValueProps, value: valueProps, onChange: onChangeProps, defaultValueJsonString, valueJsonString, onChangeJsonString, parseJson_to_String, parseString_to_Json, }) => { | ||
const { defaultValue, onChange, value: valueJson, } = (0, useJsonString_1.useJsonString)({ | ||
defaultValue: defaultValueProps, | ||
value: valueProps, | ||
onChange: onChangeProps, | ||
defaultValueJsonString, | ||
valueJsonString, | ||
onChangeJsonString, | ||
parseJson_to_String: parseJson_to_String ?? CSC_1.parseCSC_to_CSCString, | ||
parseString_to_Json: parseString_to_Json ?? CSC_1.parseCSCString_to_CSC, | ||
}); | ||
/** | ||
@@ -86,3 +98,3 @@ * An array of countries loaded by the hook. | ||
*/ | ||
const { data: value, onConcatData, setDataFunction, } = (0, useData_1.useData)({ | ||
const { data: valueData, onConcatData, setDataFunction, } = (0, useData_1.useData)({ | ||
...defaultValue, | ||
@@ -143,3 +155,3 @@ ...(defaultValue?.country | ||
onChangeCSC, | ||
value, | ||
value: (valueProps ? valueJson : valueData) ?? valueData, | ||
loadCountrys, | ||
@@ -146,0 +158,0 @@ loadStates, |
@@ -1,2 +0,2 @@ | ||
export interface useJsonStringProps<T = any> { | ||
export interface useJsonStringProps<T = any, P = string> { | ||
/** | ||
@@ -17,21 +17,21 @@ * Default Value = | ||
*/ | ||
defaultValueJsonString?: string; | ||
defaultValueJsonString?: P; | ||
/** | ||
* Value | ||
*/ | ||
valueJsonString?: string; | ||
valueJsonString?: P; | ||
/** | ||
* onChange | ||
*/ | ||
onChangeJsonString?: (data: string) => void; | ||
onChangeJsonString?: (data: P) => void; | ||
/** | ||
* parse | ||
*/ | ||
parseString_to_Json?: (data: string) => T; | ||
parseString_to_Json?: (data: P) => T; | ||
/** | ||
* parse | ||
*/ | ||
parseJson_to_String?: (data: T) => string; | ||
parseJson_to_String?: (data: T) => P; | ||
} | ||
export declare const useJsonString: <T = any>({ defaultValueJsonString, onChangeJsonString, parseJson_to_String, parseString_to_Json, valueJsonString, defaultValue, onChange, value, }: useJsonStringProps<T>) => { | ||
export declare const useJsonString: <T = any, P = string>({ defaultValueJsonString, onChangeJsonString, parseJson_to_String, parseString_to_Json, valueJsonString, defaultValue, onChange, value, }: useJsonStringProps<T, P>) => { | ||
value: T | undefined; | ||
@@ -38,0 +38,0 @@ defaultValue: T | undefined; |
155
package.json
{ | ||
"name": "fenextjs-hook", | ||
"version": "7.5.0", | ||
"description": "", | ||
"main": "./cjs/index.js", | ||
"module": "./cjs/index.js", | ||
"types": "./cjs/index.d.ts", | ||
"scripts": { | ||
"build": "npm run build:esm && npm run build:cjs", | ||
"build:esm": "echo 'esm'", | ||
"build:cjs": "tsc --module commonjs --outDir cjs", | ||
"lint": "npx eslint src", | ||
"lint:fix": "npm run lint -- --fix", | ||
"prettier": "npx prettier src --check", | ||
"prettier:fix": "npm run prettier -- --write", | ||
"format": "npm run prettier:fix && npm run lint:fix", | ||
"flb": "npm run format && npm run lint && npm run build", | ||
"bun-i": "bun i", | ||
"remove-bun-lockb": "rm -r bun.lockb", | ||
"remove-node-module": "rm -r node_modules", | ||
"remove": "npm run remove-node-module && npm run remove-bun-lockb", | ||
"update-package": "ncu -u '/^fenextjs.*$/' country-state-city-nextjs uselocalstoragenextjs", | ||
"update": "npm run update-package && npm run remove && npm run bun-i && npm run flb", | ||
"u": "npm run update", | ||
"test": "bun ./test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/franciscoblancojn/fenextjs-hook.git" | ||
}, | ||
"keywords": [ | ||
"fenextjs", | ||
"ts", | ||
"hook", | ||
"nextjs", | ||
"useData", | ||
"useRequest", | ||
"useModal", | ||
"useNotification", | ||
"useQuery", | ||
"useUser", | ||
"usePhone", | ||
"useValidator" | ||
], | ||
"author": "franciscoblancojn", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/franciscoblancojn/fenextjs-hook/issues" | ||
}, | ||
"homepage": "https://github.com/franciscoblancojn/fenextjs-hook#readme", | ||
"dependencies": { | ||
"country-state-city-nextjs": "^8.1.0", | ||
"fenextjs-error": "^2.0.0", | ||
"fenextjs-interface": "^2.5.0", | ||
"fenextjs-validator": "^2.0.1", | ||
"jwt-decode": "^4.0.0", | ||
"next": "13.5.1", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"uselocalstoragenextjs": "^2.0.0", | ||
"world-phones": "^1.0.2" | ||
}, | ||
"files": [ | ||
"cjs", | ||
"esm" | ||
], | ||
"devDependencies": { | ||
"@types/node": "20.12.4", | ||
"@types/react": "18.2.74", | ||
"@types/react-dom": "18.2.24", | ||
"@typescript-eslint/eslint-plugin": "^7.5.0", | ||
"@typescript-eslint/parser": "^7.5.0", | ||
"eslint": "8.57.0", | ||
"npm-check-updates": "^16.14.18", | ||
"prettier": "^3.2.5", | ||
"ts-loader": "^9.5.1", | ||
"typescript": "^5.4.4" | ||
} | ||
"name": "fenextjs-hook", | ||
"version": "7.6.0", | ||
"description": "", | ||
"main": "./cjs/index.js", | ||
"module": "./cjs/index.js", | ||
"types": "./cjs/index.d.ts", | ||
"scripts": { | ||
"build": "npm run build:esm && npm run build:cjs", | ||
"build:esm": "echo 'esm'", | ||
"build:cjs": "tsc --module commonjs --outDir cjs", | ||
"lint": "npx eslint src", | ||
"lint:fix": "npm run lint -- --fix", | ||
"prettier": "npx prettier src --check", | ||
"prettier:fix": "npm run prettier -- --write", | ||
"format": "npm run prettier:fix && npm run lint:fix", | ||
"flb": "npm run format && npm run lint && npm run build", | ||
"bun-i": "bun i", | ||
"remove-bun-lockb": "rm -r bun.lockb", | ||
"remove-node-module": "rm -r node_modules", | ||
"remove": "npm run remove-node-module && npm run remove-bun-lockb", | ||
"update-package": "ncu -u '/^fenextjs.*$/' country-state-city-nextjs uselocalstoragenextjs", | ||
"update": "npm run update-package && npm run remove && npm run bun-i && npm run flb", | ||
"u": "npm run update", | ||
"test": "bun ./test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/franciscoblancojn/fenextjs-hook.git" | ||
}, | ||
"keywords": [ | ||
"fenextjs", | ||
"ts", | ||
"hook", | ||
"nextjs", | ||
"useData", | ||
"useRequest", | ||
"useModal", | ||
"useNotification", | ||
"useQuery", | ||
"useUser", | ||
"usePhone", | ||
"useValidator" | ||
], | ||
"author": "franciscoblancojn", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/franciscoblancojn/fenextjs-hook/issues" | ||
}, | ||
"homepage": "https://github.com/franciscoblancojn/fenextjs-hook#readme", | ||
"dependencies": { | ||
"country-state-city-nextjs": "^8.1.0", | ||
"fenextjs-error": "^2.0.0", | ||
"fenextjs-functions": "^3.3.1", | ||
"fenextjs-interface": "^2.7.0", | ||
"fenextjs-validator": "^2.0.1", | ||
"jwt-decode": "^4.0.0", | ||
"next": "13.5.1", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"uselocalstoragenextjs": "^2.0.0", | ||
"world-phones": "^1.0.2" | ||
}, | ||
"files": [ | ||
"cjs", | ||
"esm" | ||
], | ||
"devDependencies": { | ||
"@types/node": "20.12.4", | ||
"@types/react": "18.2.74", | ||
"@types/react-dom": "18.2.24", | ||
"@typescript-eslint/eslint-plugin": "^7.5.0", | ||
"@typescript-eslint/parser": "^7.5.0", | ||
"eslint": "8.57.0", | ||
"npm-check-updates": "^16.14.18", | ||
"prettier": "^3.2.5", | ||
"ts-loader": "^9.5.1", | ||
"typescript": "^5.4.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
118651
2147
11
+ Addedfenextjs-functions@^3.3.1
+ Addedfenextjs-functions@3.5.1(transitive)
Updatedfenextjs-interface@^2.7.0