@janbox/storefront-ui 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.
@@ -6,4 +6,5 @@ export * from './use-countdown-timer';
6
6
  export * from './use-query-params';
7
7
  export * from './use-first-mount-state';
8
8
  export * from './use-update-effect';
9
+ export * from './use-deep-compare-effect';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC"}
@@ -6,9 +6,11 @@ import { useCountdownTimer } from "./use-countdown-timer.js";
6
6
  import { useQueryParams } from "./use-query-params.js";
7
7
  import { useFirstMountState } from "./use-first-mount-state/index.js";
8
8
  import { useUpdateEffect } from "./use-update-effect/index.js";
9
+ import { useDeepCompareEffect } from "./use-deep-compare-effect/index.js";
9
10
  export {
10
11
  useControllableState,
11
12
  useCountdownTimer,
13
+ useDeepCompareEffect,
12
14
  useFirstMountState,
13
15
  useHoverLineEffect,
14
16
  useQueryParams,
@@ -1,6 +1,6 @@
1
1
  import { useRef, useState, useMemo, useCallback } from "react";
2
2
  import { isUndefined, isEqual } from "lodash-es";
3
- import useUpdateEffect from "../node_modules/.pnpm/react-use@17.6.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-use/esm/useUpdateEffect.js";
3
+ import { useUpdateEffect } from "./use-update-effect/index.js";
4
4
  const getIsControlled = (value) => !isUndefined(value);
5
5
  const useControllableState = ({
6
6
  defaultValue,
@@ -1,6 +1,6 @@
1
1
  import { useRef, useState } from "react";
2
2
  import dayjs from "dayjs";
3
- import useDeepCompareEffect from "../node_modules/.pnpm/react-use@17.6.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-use/esm/useDeepCompareEffect.js";
3
+ import { useDeepCompareEffect } from "./use-deep-compare-effect/index.js";
4
4
  const getTimeDiff = (end, omit) => {
5
5
  const now = dayjs();
6
6
  const target = dayjs(end);
@@ -0,0 +1,3 @@
1
+ import { DependencyList, EffectCallback } from 'react';
2
+ export declare const useDeepCompareEffect: (effect: EffectCallback, deps: DependencyList) => void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-deep-compare-effect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAqB,MAAM,OAAO,CAAC;AAc1E,eAAO,MAAM,oBAAoB,WACvB,cAAc,QAChB,cAAc,SAGrB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { isEqual } from "lodash-es";
3
+ function useDeepCompareMemoize(deps) {
4
+ const ref = useRef(deps);
5
+ if (!isEqual(deps, ref.current)) {
6
+ ref.current = deps;
7
+ }
8
+ return ref.current;
9
+ }
10
+ const useDeepCompareEffect = (effect, deps) => {
11
+ useEffect(effect, useDeepCompareMemoize(deps));
12
+ };
13
+ export {
14
+ useDeepCompareEffect
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janbox/storefront-ui",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Storefront UI component library for Janbox",
5
5
  "author": "Janbox",
6
6
  "keywords": [
@@ -91,7 +91,6 @@
91
91
  "react-i18next": "^14.0.0",
92
92
  "react-player": "^3.3.3",
93
93
  "react-router": "^7.9.6",
94
- "react-use": "^17.5.1",
95
94
  "react-zoom-pan-pinch": "^3.7.0",
96
95
  "slugify": "^1.6.6",
97
96
  "type-fest": "^5.2.0",
@@ -1,5 +0,0 @@
1
- import isDeepEqualReact from "/Users/akashi/Work/iChiba/@janbox/storefront-ui/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/react.js";
2
- import { default as default2 } from "/Users/akashi/Work/iChiba/@janbox/storefront-ui/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/react.js";
3
- export {
4
- default2 as default
5
- };
@@ -1,25 +0,0 @@
1
- import { useRef, useEffect } from "react";
2
- var isPrimitive = function(val) {
3
- return val !== Object(val);
4
- };
5
- var useCustomCompareEffect = function(effect, deps, depsEqual) {
6
- if (process.env.NODE_ENV !== "production") {
7
- if (!(deps instanceof Array) || !deps.length) {
8
- console.warn("`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead.");
9
- }
10
- if (deps.every(isPrimitive)) {
11
- console.warn("`useCustomCompareEffect` should not be used with dependencies that are all primitive values. Use React.useEffect instead.");
12
- }
13
- if (typeof depsEqual !== "function") {
14
- console.warn("`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list");
15
- }
16
- }
17
- var ref = useRef(void 0);
18
- if (!ref.current || !depsEqual(deps, ref.current)) {
19
- ref.current = deps;
20
- }
21
- useEffect(effect, ref.current);
22
- };
23
- export {
24
- useCustomCompareEffect as default
25
- };
@@ -1,19 +0,0 @@
1
- import useCustomCompareEffect from "./useCustomCompareEffect.js";
2
- import isDeepEqualReact from "/Users/akashi/Work/iChiba/@janbox/storefront-ui/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/react.js";
3
- var isPrimitive = function(val) {
4
- return val !== Object(val);
5
- };
6
- var useDeepCompareEffect = function(effect, deps) {
7
- if (process.env.NODE_ENV !== "production") {
8
- if (!(deps instanceof Array) || !deps.length) {
9
- console.warn("`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead.");
10
- }
11
- if (deps.every(isPrimitive)) {
12
- console.warn("`useDeepCompareEffect` should not be used with dependencies that are all primitive values. Use React.useEffect instead.");
13
- }
14
- }
15
- useCustomCompareEffect(effect, deps, isDeepEqualReact);
16
- };
17
- export {
18
- useDeepCompareEffect as default
19
- };
@@ -1,12 +0,0 @@
1
- import { useRef } from "react";
2
- function useFirstMountState() {
3
- var isFirst = useRef(true);
4
- if (isFirst.current) {
5
- isFirst.current = false;
6
- return true;
7
- }
8
- return isFirst.current;
9
- }
10
- export {
11
- useFirstMountState
12
- };
@@ -1,13 +0,0 @@
1
- import { useEffect } from "react";
2
- import { useFirstMountState } from "./useFirstMountState.js";
3
- var useUpdateEffect = function(effect, deps) {
4
- var isFirstMount = useFirstMountState();
5
- useEffect(function() {
6
- if (!isFirstMount) {
7
- return effect();
8
- }
9
- }, deps);
10
- };
11
- export {
12
- useUpdateEffect as default
13
- };