@gateweb/react-utils 1.4.1 → 1.5.0

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.
@@ -358,9 +358,17 @@ type TValueOptions<T> = AtLeastOne<{
358
358
  defaultValue?: T;
359
359
  }>;
360
360
  /**
361
+ * A hook to manage a value.
361
362
  *
363
+ * @example
364
+ *
365
+ * ```tsx
366
+ * const MyComponent = ({ value }: { value?: number }) => {
367
+ * const [currentValue, setCurrentValue] = useValue({ value });
368
+ * };
369
+ * ```
362
370
  */
363
- declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => (T | ((newValue: T) => void))[];
371
+ declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => readonly [T, (newValue: T) => void];
364
372
 
365
373
  declare function invariant(condition: any, message?: string | (() => string)): asserts condition;
366
374
 
package/dist/cjs/index.js CHANGED
@@ -474,7 +474,15 @@ const transformObjectKey = (obj, transformFunName)=>{
474
474
  };
475
475
 
476
476
  /**
477
+ * A hook to manage a value.
477
478
  *
479
+ * @example
480
+ *
481
+ * ```tsx
482
+ * const MyComponent = ({ value }: { value?: number }) => {
483
+ * const [currentValue, setCurrentValue] = useValue({ value });
484
+ * };
485
+ * ```
478
486
  */ const useValue = ({ value, defaultValue })=>{
479
487
  if (value === undefined && defaultValue === undefined) {
480
488
  throw new Error('Either `value` or `defaultValue` must be provided.');
@@ -358,9 +358,17 @@ type TValueOptions<T> = AtLeastOne<{
358
358
  defaultValue?: T;
359
359
  }>;
360
360
  /**
361
+ * A hook to manage a value.
361
362
  *
363
+ * @example
364
+ *
365
+ * ```tsx
366
+ * const MyComponent = ({ value }: { value?: number }) => {
367
+ * const [currentValue, setCurrentValue] = useValue({ value });
368
+ * };
369
+ * ```
362
370
  */
363
- declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => (T | ((newValue: T) => void))[];
371
+ declare const useValue: <T>({ value, defaultValue }: TValueOptions<T>) => readonly [T, (newValue: T) => void];
364
372
 
365
373
  declare function invariant(condition: any, message?: string | (() => string)): asserts condition;
366
374
 
package/dist/es/index.mjs CHANGED
@@ -468,7 +468,15 @@ const transformObjectKey = (obj, transformFunName)=>{
468
468
  };
469
469
 
470
470
  /**
471
+ * A hook to manage a value.
471
472
  *
473
+ * @example
474
+ *
475
+ * ```tsx
476
+ * const MyComponent = ({ value }: { value?: number }) => {
477
+ * const [currentValue, setCurrentValue] = useValue({ value });
478
+ * };
479
+ * ```
472
480
  */ const useValue = ({ value, defaultValue })=>{
473
481
  if (value === undefined && defaultValue === undefined) {
474
482
  throw new Error('Either `value` or `defaultValue` must be provided.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gateweb/react-utils",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "React Utils for GateWeb",
5
5
  "homepage": "https://github.com/GatewebSolutions/react-utils",
6
6
  "files": [
@@ -36,17 +36,17 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "dayjs": "^1.11.13",
39
- "react": "^18.3.1",
40
- "react-dom": "^18.3.1"
39
+ "react": "^19.0.0",
40
+ "react-dom": "^19.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@commitlint/cli": "^19.5.0",
44
44
  "@commitlint/config-conventional": "^19.5.0",
45
45
  "@gateweb/eslint-config-gateweb": "^1.0.6",
46
- "@testing-library/react": "^16.0.1",
46
+ "@testing-library/react": "^16.2.0",
47
47
  "@types/jest": "^29.5.13",
48
48
  "@types/node": "^22.7.7",
49
- "@types/react": "^18.3.11",
49
+ "@types/react": "^19.0.8",
50
50
  "@vitest/coverage-v8": "^2.1.4",
51
51
  "@vitest/ui": "2.1.4",
52
52
  "bunchee": "^5.6.1",