@kkcompany/app-ui 0.1.28 → 0.1.30

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.cjs CHANGED
@@ -267,8 +267,13 @@ const BannerRender = ({ children, className = "", autoplay = false, autoplayInte
267
267
  const movingWidth = Math.abs(movingVector);
268
268
  if (movingVector > 0 && movingWidth > triggerWidth && hasPrev) jumpTo(currentPosition - 1);
269
269
  else if (movingVector < 0 && movingWidth > triggerWidth && hasNext) jumpTo(currentPosition + 1);
270
- else if (movingVector !== 0) jumpTo(currentPosition);
271
- else resume();
270
+ else if (movingVector !== 0) {
271
+ dispatch({
272
+ type: "DRAG",
273
+ payload: { dragOffset: 0 }
274
+ });
275
+ resume();
276
+ } else resume();
272
277
  dragRef.current = {
273
278
  dragging: false,
274
279
  dragXFrom: -1,
@@ -803,17 +808,19 @@ const SeeMore = ({ style, messages = defaultMessages, children, ...rest }) => {
803
808
  const [expandedHeight, setExpandedHeight] = (0, react.useState)();
804
809
  const rootRef = (0, react.useRef)(null);
805
810
  const containeRef = (0, react.useRef)();
806
- (0, react.useEffect)(() => {
811
+ (0, react.useLayoutEffect)(() => {
807
812
  if (!rootRef.current) return;
808
- return onResize(rootRef.current, () => {
813
+ const updateExpandStatus = () => {
809
814
  if (!containeRef.current) return;
810
815
  const collapsedLines = Number.parseInt(window.getComputedStyle(containeRef.current).getPropertyValue("--see-more-collapsed-lines"), 10) || 2;
811
816
  const lineCount = getLineCount(containeRef.current);
812
817
  const scrollable = lineCount > collapsedLines;
813
818
  const fit = lineCount <= collapsedLines;
814
819
  setStatus((current) => current === "no-expand" && scrollable ? "collapsed" : current !== "no-expand" && fit ? "no-expand" : current);
815
- setExpandedHeight(containeRef.current?.scrollHeight);
816
- });
820
+ setExpandedHeight(containeRef.current.scrollHeight);
821
+ };
822
+ updateExpandStatus();
823
+ return onResize(rootRef.current, updateExpandStatus);
817
824
  }, []);
818
825
  const toggle = () => setStatus((current) => current === "collapsed" ? "expanded" : "collapsing");
819
826
  return /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsxs)("div", {
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react0 from "react";
2
2
  import { ElementType, MouseEventHandler, ReactElement, ReactNode } from "react";
3
- import * as _emotion_react_jsx_runtime0 from "@emotion/react/jsx-runtime";
3
+ import * as _emotion_react_jsx_runtime2 from "@emotion/react/jsx-runtime";
4
4
  import { CSSObject } from "@emotion/react";
5
5
  import Link from "next/link";
6
6
 
@@ -65,7 +65,7 @@ declare const HiddenToggle: ({
65
65
  defaultEnabled?: boolean;
66
66
  children: any;
67
67
  onChange: any;
68
- }) => _emotion_react_jsx_runtime0.JSX.Element;
68
+ }) => _emotion_react_jsx_runtime2.JSX.Element;
69
69
  //#endregion
70
70
  //#region src/Icon.d.ts
71
71
  declare const Icon: ({
@@ -74,7 +74,7 @@ declare const Icon: ({
74
74
  }: {
75
75
  style?: {};
76
76
  src: any;
77
- }) => _emotion_react_jsx_runtime0.JSX.Element;
77
+ }) => _emotion_react_jsx_runtime2.JSX.Element;
78
78
  //#endregion
79
79
  //#region src/SeeMore.d.ts
80
80
  declare const defaultMessages: {
@@ -90,7 +90,7 @@ declare const SeeMore: ({
90
90
  style?: CSSObject;
91
91
  messages?: typeof defaultMessages;
92
92
  children?: ReactNode;
93
- }) => _emotion_react_jsx_runtime0.JSX.Element;
93
+ }) => _emotion_react_jsx_runtime2.JSX.Element;
94
94
  //#endregion
95
95
  //#region src/VideoItem.d.ts
96
96
  type VideoDetail = {
@@ -154,6 +154,6 @@ declare const VideoThumbnail: ({
154
154
  Image?: ElementType;
155
155
  };
156
156
  onClick?: MouseEventHandler<HTMLAnchorElement>;
157
- }) => _emotion_react_jsx_runtime0.JSX.Element;
157
+ }) => _emotion_react_jsx_runtime2.JSX.Element;
158
158
  //#endregion
159
159
  export { Banner, Dropdown, HiddenToggle, Icon, SeeMore, VideoItem, VideoThumbnail };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState } from "react";
1
+ import { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { jsx as jsx$1, jsxs } from "@emotion/react/jsx-runtime";
4
4
  import { css } from "@emotion/react";
@@ -267,8 +267,13 @@ const BannerRender = ({ children, className = "", autoplay = false, autoplayInte
267
267
  const movingWidth = Math.abs(movingVector);
268
268
  if (movingVector > 0 && movingWidth > triggerWidth && hasPrev) jumpTo(currentPosition - 1);
269
269
  else if (movingVector < 0 && movingWidth > triggerWidth && hasNext) jumpTo(currentPosition + 1);
270
- else if (movingVector !== 0) jumpTo(currentPosition);
271
- else resume();
270
+ else if (movingVector !== 0) {
271
+ dispatch({
272
+ type: "DRAG",
273
+ payload: { dragOffset: 0 }
274
+ });
275
+ resume();
276
+ } else resume();
272
277
  dragRef.current = {
273
278
  dragging: false,
274
279
  dragXFrom: -1,
@@ -803,17 +808,19 @@ const SeeMore = ({ style, messages = defaultMessages, children, ...rest }) => {
803
808
  const [expandedHeight, setExpandedHeight] = useState();
804
809
  const rootRef = useRef(null);
805
810
  const containeRef = useRef();
806
- useEffect(() => {
811
+ useLayoutEffect(() => {
807
812
  if (!rootRef.current) return;
808
- return onResize(rootRef.current, () => {
813
+ const updateExpandStatus = () => {
809
814
  if (!containeRef.current) return;
810
815
  const collapsedLines = Number.parseInt(window.getComputedStyle(containeRef.current).getPropertyValue("--see-more-collapsed-lines"), 10) || 2;
811
816
  const lineCount = getLineCount(containeRef.current);
812
817
  const scrollable = lineCount > collapsedLines;
813
818
  const fit = lineCount <= collapsedLines;
814
819
  setStatus((current) => current === "no-expand" && scrollable ? "collapsed" : current !== "no-expand" && fit ? "no-expand" : current);
815
- setExpandedHeight(containeRef.current?.scrollHeight);
816
- });
820
+ setExpandedHeight(containeRef.current.scrollHeight);
821
+ };
822
+ updateExpandStatus();
823
+ return onResize(rootRef.current, updateExpandStatus);
817
824
  }, []);
818
825
  const toggle = () => setStatus((current) => current === "collapsed" ? "expanded" : "collapsing");
819
826
  return /* @__PURE__ */ jsxs("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kkcompany/app-ui",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "module": "dist/index.mjs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.mts",