@janbox/storefront-ui 2.0.24 → 2.0.25
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/dist/index.js +2 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/marquee/marquee/marquee.d.ts.map +1 -1
- package/dist/lib/marquee/marquee/marquee.js +41 -36
- package/dist/lib/suspense-query/index.d.ts +14 -0
- package/dist/lib/suspense-query/index.d.ts.map +1 -0
- package/dist/lib/suspense-query/index.js +32 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -81,6 +81,7 @@ import { Select } from "./lib/select/select.js";
|
|
|
81
81
|
import { StarRating } from "./lib/star-rating/star-rating.js";
|
|
82
82
|
import { Step } from "./lib/stepper/step.js";
|
|
83
83
|
import { Stepper } from "./lib/stepper/stepper.js";
|
|
84
|
+
import { SuspenseQuery } from "./lib/suspense-query/index.js";
|
|
84
85
|
import { Swiper } from "./lib/swiper/swiper/swiper.js";
|
|
85
86
|
import { SwiperSlide } from "./lib/swiper/swiper-slide/swiper-slide.js";
|
|
86
87
|
import { Switch } from "./lib/switch/switch.js";
|
|
@@ -226,6 +227,7 @@ export {
|
|
|
226
227
|
StarRating,
|
|
227
228
|
Step,
|
|
228
229
|
Stepper,
|
|
230
|
+
SuspenseQuery,
|
|
229
231
|
Swiper,
|
|
230
232
|
SwiperSlide,
|
|
231
233
|
Switch,
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC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cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["../../../../src/lib/marquee/marquee/marquee.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["../../../../src/lib/marquee/marquee/marquee.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAiD,MAAM,SAAS,CAAC;AAWtF,eAAO,MAAM,OAAO,iCAAkC,YAAY,qDAsFjE,CAAC"}
|
|
@@ -6,13 +6,13 @@ import useEmblaCarousel from "embla-carousel-react";
|
|
|
6
6
|
import { getMarqueeProps } from "./helpers.js";
|
|
7
7
|
import { MarqueeDataAttributes } from "./types.js";
|
|
8
8
|
import { HTMLClasses } from "../../../constants/index.js";
|
|
9
|
-
import { mediaQuery } from "../../../theme/screens.js";
|
|
10
|
-
import "../../../theme/palette.js";
|
|
11
9
|
import { flattenChildren } from "../../../utils/index.js";
|
|
10
|
+
import { isNumber } from "lodash-es";
|
|
12
11
|
import { Icon } from "../../icon/icon.js";
|
|
12
|
+
import { Primitive } from "../../primitive/primitive.js";
|
|
13
13
|
const Marquee = ({ children, ref, ..._props }) => {
|
|
14
|
-
|
|
15
|
-
const { sm
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const { spaceBetween, sm, md, lg, autoScrollOptions, separatorIcon, ...rest } = getMarqueeProps(_props);
|
|
16
16
|
const rootEl = useRef(null);
|
|
17
17
|
const [emblaRef, emblaApi] = useEmblaCarousel(
|
|
18
18
|
{
|
|
@@ -25,8 +25,8 @@ const Marquee = ({ children, ref, ..._props }) => {
|
|
|
25
25
|
const mergedRefs = useMergeRefs([emblaRef, ref, rootEl]);
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
const mutationObserver = new MutationObserver((records) => {
|
|
28
|
-
var
|
|
29
|
-
const target = (
|
|
28
|
+
var _a2;
|
|
29
|
+
const target = (_a2 = records.at(0)) == null ? void 0 : _a2.target;
|
|
30
30
|
if (!target) return;
|
|
31
31
|
const playState = target.getAttribute(MarqueeDataAttributes.PlayState);
|
|
32
32
|
const autoScrollPlugin = emblaApi == null ? void 0 : emblaApi.plugins().autoScroll;
|
|
@@ -48,12 +48,12 @@ const Marquee = ({ children, ref, ..._props }) => {
|
|
|
48
48
|
}, [emblaApi]);
|
|
49
49
|
useEffect(() => {
|
|
50
50
|
const onAutoScrollPlay = () => {
|
|
51
|
-
var
|
|
52
|
-
(
|
|
51
|
+
var _a2;
|
|
52
|
+
(_a2 = rootEl.current) == null ? void 0 : _a2.setAttribute(MarqueeDataAttributes.PlayState, "on");
|
|
53
53
|
};
|
|
54
54
|
const onAutoScrollStop = () => {
|
|
55
|
-
var
|
|
56
|
-
(
|
|
55
|
+
var _a2;
|
|
56
|
+
(_a2 = rootEl.current) == null ? void 0 : _a2.setAttribute(MarqueeDataAttributes.PlayState, "off");
|
|
57
57
|
};
|
|
58
58
|
emblaApi == null ? void 0 : emblaApi.on("autoScroll:play", onAutoScrollPlay);
|
|
59
59
|
emblaApi == null ? void 0 : emblaApi.on("autoScroll:stop", onAutoScrollStop);
|
|
@@ -63,41 +63,46 @@ const Marquee = ({ children, ref, ..._props }) => {
|
|
|
63
63
|
};
|
|
64
64
|
}, [emblaApi]);
|
|
65
65
|
return /* @__PURE__ */ jsx(
|
|
66
|
-
|
|
66
|
+
Primitive,
|
|
67
67
|
{
|
|
68
|
-
css: [
|
|
69
|
-
{
|
|
70
|
-
overflow: "hidden",
|
|
71
|
-
maxWidth: "100%"
|
|
72
|
-
},
|
|
73
|
-
createStyle({ spaceBetween }, sxXs),
|
|
74
|
-
{
|
|
75
|
-
[mediaQuery("sm")]: createStyle(sm, sxSm),
|
|
76
|
-
[mediaQuery("md")]: createStyle(md, sxMd),
|
|
77
|
-
[mediaQuery("lg")]: createStyle(lg, sxLg)
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
68
|
...rest,
|
|
69
|
+
sx: {
|
|
70
|
+
overflow: "hidden",
|
|
71
|
+
maxWidth: "100%",
|
|
72
|
+
...rest.sx,
|
|
73
|
+
...createStyle({ spaceBetween }),
|
|
74
|
+
sm: { ...(_a = rest.sx) == null ? void 0 : _a.sm, ...createStyle(sm) },
|
|
75
|
+
md: { ...(_b = rest.sx) == null ? void 0 : _b.md, ...createStyle(md) },
|
|
76
|
+
lg: { ...(_c = rest.sx) == null ? void 0 : _c.lg, ...createStyle(lg) }
|
|
77
|
+
},
|
|
81
78
|
ref: mergedRefs,
|
|
82
|
-
children: /* @__PURE__ */ jsx(
|
|
83
|
-
/* @__PURE__ */ jsx(
|
|
84
|
-
!!separatorIcon && /* @__PURE__ */ jsx(
|
|
79
|
+
children: /* @__PURE__ */ jsx(Primitive, { sx: { display: "flex", alignItems: "center", marginLeft: `calc(var(${SPACING_VAR}, 0px) * -1)` }, children: flattenChildren(children).map((child, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
+
/* @__PURE__ */ jsx(MarqueeSlide, { children: child }),
|
|
81
|
+
!!separatorIcon && /* @__PURE__ */ jsx(MarqueeSlide, { children: /* @__PURE__ */ jsx(Icon, { ...separatorIcon }) })
|
|
85
82
|
] }, `marquee-item-${index}`)) })
|
|
86
83
|
}
|
|
87
84
|
);
|
|
88
85
|
};
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
return
|
|
86
|
+
const SPACING_VAR = "--marquee-space-between";
|
|
87
|
+
const MarqueeSlide = ({ children }) => {
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
Primitive,
|
|
92
90
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
91
|
+
sx: {
|
|
92
|
+
flexShrink: 0,
|
|
93
|
+
flexGrow: 0,
|
|
94
|
+
overflow: "hidden",
|
|
95
|
+
paddingRight: `var(${SPACING_VAR}, 0px)`
|
|
96
|
+
},
|
|
97
|
+
className: HTMLClasses.MARQUEE_SLIDE,
|
|
98
|
+
children
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
const createStyle = ({ spaceBetween } = {}) => {
|
|
103
|
+
return isNumber(spaceBetween) ? {
|
|
104
|
+
[SPACING_VAR]: `${spaceBetween}px`
|
|
105
|
+
} : {};
|
|
101
106
|
};
|
|
102
107
|
export {
|
|
103
108
|
Marquee
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { FallbackProps } from 'react-error-boundary';
|
|
3
|
+
export type SuspenseQueryProps<A extends any[], R> = {
|
|
4
|
+
LoadingComponent?: ComponentType;
|
|
5
|
+
ErrorComponent?: ComponentType<FallbackProps>;
|
|
6
|
+
factory: (...args: A) => Promise<R>;
|
|
7
|
+
children: (data: R) => React.ReactNode;
|
|
8
|
+
} & (A extends [] ? {
|
|
9
|
+
deps?: [];
|
|
10
|
+
} : {
|
|
11
|
+
deps: A;
|
|
12
|
+
});
|
|
13
|
+
export declare function SuspenseQuery<A extends any[], R>({ factory, deps: propDeps, LoadingComponent, ErrorComponent, children, }: SuspenseQueryProps<A, R>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/suspense-query/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,OAAO,CAAC;AAG7D,OAAO,EAAiB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEpE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,IAAI;IACnD,gBAAgB,CAAC,EAAE,aAAa,CAAC;IACjC,cAAc,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC9C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACpC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;CACxC,GAAG,CAAC,CAAC,SAAS,EAAE,GAAG;IAAE,IAAI,CAAC,EAAE,EAAE,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEjD,wBAAgB,aAAa,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,EAAE,EAChD,OAAO,EACP,IAAI,EAAE,QAAQ,EACd,gBAAgB,EAChB,cAAsC,EACtC,QAAQ,GACT,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,2CAmB1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, Suspense, use } from "react";
|
|
3
|
+
import { isEqual } from "lodash-es";
|
|
4
|
+
import { ErrorBoundary } from "/Users/akashi/Work/iChiba/@janbox/storefront-ui/node_modules/.pnpm/react-error-boundary@6.1.2_react@19.2.4/node_modules/react-error-boundary/dist/react-error-boundary.js";
|
|
5
|
+
function SuspenseQuery({
|
|
6
|
+
factory,
|
|
7
|
+
deps: propDeps,
|
|
8
|
+
LoadingComponent,
|
|
9
|
+
ErrorComponent = DefaultErrorComponent,
|
|
10
|
+
children
|
|
11
|
+
}) {
|
|
12
|
+
const deps = propDeps ?? [];
|
|
13
|
+
const depsRef = useRef(deps);
|
|
14
|
+
const promiseRef = useRef(null);
|
|
15
|
+
const depsChanged = !isEqual(deps, depsRef.current);
|
|
16
|
+
if (promiseRef.current === null || depsChanged) {
|
|
17
|
+
depsRef.current = deps;
|
|
18
|
+
promiseRef.current = factory(...deps);
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent: ErrorComponent, children: /* @__PURE__ */ jsx(Suspense, { fallback: LoadingComponent ? /* @__PURE__ */ jsx(LoadingComponent, {}) : null, children: /* @__PURE__ */ jsx(Content, { promise: promiseRef.current, children }) }) });
|
|
21
|
+
}
|
|
22
|
+
function Content({ promise, children }) {
|
|
23
|
+
const data = use(promise);
|
|
24
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
|
|
25
|
+
}
|
|
26
|
+
const DefaultErrorComponent = ({ error }) => {
|
|
27
|
+
console.error("SuspenseQueryError", error);
|
|
28
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
SuspenseQuery
|
|
32
|
+
};
|