@tiny-codes/react-easy 1.0.4 → 1.0.5

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## 1.0.5
6
+
7
+ 2025-4-14
8
+
9
+ ### Features
10
+
11
+ - 🔥 Add `useRefValue` hook
12
+
5
13
  ## 1.0.4
6
14
 
7
15
  2025-3-28
@@ -1,3 +1,4 @@
1
+ export { default as useRefValue } from './useRefValue';
1
2
  export { default as useRefFunction } from './useRefFunction';
2
3
  export type { ValidatorRuleMap } from './useValidators';
3
4
  export { default as useValidators } from './useValidators';
package/es/hooks/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { default as useRefValue } from "./useRefValue";
1
2
  export { default as useRefFunction } from "./useRefFunction";
2
3
  export { default as useValidators } from "./useValidators";
3
4
  export { default as useValidator } from "./useValidator";
@@ -1 +1 @@
1
- {"version":3,"names":["default","useRefFunction","useValidators","useValidator","useValidatorBuilder"],"sources":["../../src/hooks/index.ts"],"sourcesContent":["export { default as useRefFunction } from './useRefFunction';\n\nexport type { ValidatorRuleMap } from './useValidators';\nexport { default as useValidators } from './useValidators';\nexport { default as useValidator } from './useValidator';\nexport type { Validator, RuleRegExpFlags, ValidatorRule, BuilderOptions } from './useValidatorBuilder';\nexport { default as useValidatorBuilder } from './useValidatorBuilder';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,cAAc;AAGlC,SAASD,OAAO,IAAIE,aAAa;AACjC,SAASF,OAAO,IAAIG,YAAY;AAEhC,SAASH,OAAO,IAAII,mBAAmB"}
1
+ {"version":3,"names":["default","useRefValue","useRefFunction","useValidators","useValidator","useValidatorBuilder"],"sources":["../../src/hooks/index.ts"],"sourcesContent":["export { default as useRefValue } from './useRefValue';\nexport { default as useRefFunction } from './useRefFunction';\n\nexport type { ValidatorRuleMap } from './useValidators';\nexport { default as useValidators } from './useValidators';\nexport { default as useValidator } from './useValidator';\nexport type { Validator, RuleRegExpFlags, ValidatorRule, BuilderOptions } from './useValidatorBuilder';\nexport { default as useValidatorBuilder } from './useValidatorBuilder';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAAW;AAC/B,SAASD,OAAO,IAAIE,cAAc;AAGlC,SAASF,OAAO,IAAIG,aAAa;AACjC,SAASH,OAAO,IAAII,YAAY;AAEhC,SAASJ,OAAO,IAAIK,mBAAmB"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * **EN:** Get a mutable ref object and automatically update the value change
4
+ *
5
+ * **CN:** 获取一个可变的ref对象,并自动更新值变化
6
+ *
7
+ * @param value the wrapped value | 被包装的值
8
+ *
9
+ * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变
10
+ */
11
+ declare const useRefValue: <T>(value: T) => import("react").RefObject<T>;
12
+ export default useRefValue;
@@ -0,0 +1,18 @@
1
+ import { useRef } from 'react';
2
+
3
+ /**
4
+ * **EN:** Get a mutable ref object and automatically update the value change
5
+ *
6
+ * **CN:** 获取一个可变的ref对象,并自动更新值变化
7
+ *
8
+ * @param value the wrapped value | 被包装的值
9
+ *
10
+ * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变
11
+ */
12
+ var useRefValue = function useRefValue(value) {
13
+ var ref = useRef(value);
14
+ ref.current = value;
15
+ return ref;
16
+ };
17
+ export default useRefValue;
18
+ //# sourceMappingURL=useRefValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useRef","useRefValue","value","ref","current"],"sources":["../../src/hooks/useRefValue.ts"],"sourcesContent":["import { useRef } from 'react';\n\n/**\n * **EN:** Get a mutable ref object and automatically update the value change\n *\n * **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T) => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAOC,KAAQ,EAAK;EACnC,IAAMC,GAAG,GAAGH,MAAM,CAAIE,KAAK,CAAC;EAC5BC,GAAG,CAACC,OAAO,GAAGF,KAAK;EACnB,OAAOC,GAAG;AACZ,CAAC;AAED,eAAeF,WAAW"}
@@ -1,3 +1,4 @@
1
+ export { default as useRefValue } from './useRefValue';
1
2
  export { default as useRefFunction } from './useRefFunction';
2
3
  export type { ValidatorRuleMap } from './useValidators';
3
4
  export { default as useValidators } from './useValidators';
@@ -30,11 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var hooks_exports = {};
31
31
  __export(hooks_exports, {
32
32
  useRefFunction: () => import_useRefFunction.default,
33
+ useRefValue: () => import_useRefValue.default,
33
34
  useValidator: () => import_useValidator.default,
34
35
  useValidatorBuilder: () => import_useValidatorBuilder.default,
35
36
  useValidators: () => import_useValidators.default
36
37
  });
37
38
  module.exports = __toCommonJS(hooks_exports);
39
+ var import_useRefValue = __toESM(require("./useRefValue"));
38
40
  var import_useRefFunction = __toESM(require("./useRefFunction"));
39
41
  var import_useValidators = __toESM(require("./useValidators"));
40
42
  var import_useValidator = __toESM(require("./useValidator"));
@@ -42,6 +44,7 @@ var import_useValidatorBuilder = __toESM(require("./useValidatorBuilder"));
42
44
  // Annotate the CommonJS export names for ESM import in node:
43
45
  0 && (module.exports = {
44
46
  useRefFunction,
47
+ useRefValue,
45
48
  useValidator,
46
49
  useValidatorBuilder,
47
50
  useValidators
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/index.ts"],
4
- "sourcesContent": ["export { default as useRefFunction } from './useRefFunction';\n\nexport type { ValidatorRuleMap } from './useValidators';\nexport { default as useValidators } from './useValidators';\nexport { default as useValidator } from './useValidator';\nexport type { Validator, RuleRegExpFlags, ValidatorRule, BuilderOptions } from './useValidatorBuilder';\nexport { default as useValidatorBuilder } from './useValidatorBuilder';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA0C;AAG1C,2BAAyC;AACzC,0BAAwC;AAExC,iCAA+C;",
4
+ "sourcesContent": ["export { default as useRefValue } from './useRefValue';\nexport { default as useRefFunction } from './useRefFunction';\n\nexport type { ValidatorRuleMap } from './useValidators';\nexport { default as useValidators } from './useValidators';\nexport { default as useValidator } from './useValidator';\nexport type { Validator, RuleRegExpFlags, ValidatorRule, BuilderOptions } from './useValidatorBuilder';\nexport { default as useValidatorBuilder } from './useValidatorBuilder';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuC;AACvC,4BAA0C;AAG1C,2BAAyC;AACzC,0BAAwC;AAExC,iCAA+C;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * **EN:** Get a mutable ref object and automatically update the value change
4
+ *
5
+ * **CN:** 获取一个可变的ref对象,并自动更新值变化
6
+ *
7
+ * @param value the wrapped value | 被包装的值
8
+ *
9
+ * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变
10
+ */
11
+ declare const useRefValue: <T>(value: T) => import("react").RefObject<T>;
12
+ export default useRefValue;
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/hooks/useRefValue.ts
20
+ var useRefValue_exports = {};
21
+ __export(useRefValue_exports, {
22
+ default: () => useRefValue_default
23
+ });
24
+ module.exports = __toCommonJS(useRefValue_exports);
25
+ var import_react = require("react");
26
+ var useRefValue = (value) => {
27
+ const ref = (0, import_react.useRef)(value);
28
+ ref.current = value;
29
+ return ref;
30
+ };
31
+ var useRefValue_default = useRefValue;
32
+ //# sourceMappingURL=useRefValue.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hooks/useRefValue.ts"],
4
+ "sourcesContent": ["import { useRef } from 'react';\n\n/**\n * **EN:** Get a mutable ref object and automatically update the value change\n *\n * **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T) => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAWvB,IAAM,cAAc,CAAI,UAAa;AACnC,QAAM,UAAM,qBAAU,KAAK;AAC3B,MAAI,UAAU;AACd,SAAO;AACT;AAEA,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Helps you use React and AntDesign more easily",
5
5
  "keywords": [
6
6
  "react",