@kkcompany/app-ui 0.1.26 → 0.1.28
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 +19 -6
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +19 -6
- package/package.json +37 -37
package/dist/index.cjs
CHANGED
|
@@ -738,6 +738,7 @@ const containerStyle = {
|
|
|
738
738
|
"&:hover": { color: "#fff" },
|
|
739
739
|
"&:disabled": {
|
|
740
740
|
opacity: "0",
|
|
741
|
+
pointerEvents: "none",
|
|
741
742
|
"-webkit-tap-highlight-color": "transparent"
|
|
742
743
|
},
|
|
743
744
|
"> span": {
|
|
@@ -783,6 +784,16 @@ const onResize = (container, handler) => {
|
|
|
783
784
|
observer.observe(container);
|
|
784
785
|
return () => observer.disconnect();
|
|
785
786
|
};
|
|
787
|
+
const getLineCount = (el) => {
|
|
788
|
+
const style = window.getComputedStyle(el);
|
|
789
|
+
let lineHeight = Number.parseFloat(style.lineHeight);
|
|
790
|
+
if (Number.isNaN(lineHeight) || lineHeight <= 0) {
|
|
791
|
+
const fontSize = Number.parseFloat(style.fontSize);
|
|
792
|
+
lineHeight = fontSize > 0 ? fontSize * 1.2 : 0;
|
|
793
|
+
}
|
|
794
|
+
if (!lineHeight) return 0;
|
|
795
|
+
return Math.max(1, Math.round(el.scrollHeight / lineHeight));
|
|
796
|
+
};
|
|
786
797
|
const defaultMessages = {
|
|
787
798
|
seeMore: "もっと見る",
|
|
788
799
|
seeLess: "閉じる"
|
|
@@ -790,15 +801,16 @@ const defaultMessages = {
|
|
|
790
801
|
const SeeMore = ({ style, messages = defaultMessages, children, ...rest }) => {
|
|
791
802
|
const [status, setStatus] = (0, react.useState)("no-expand");
|
|
792
803
|
const [expandedHeight, setExpandedHeight] = (0, react.useState)();
|
|
804
|
+
const rootRef = (0, react.useRef)(null);
|
|
793
805
|
const containeRef = (0, react.useRef)();
|
|
794
806
|
(0, react.useEffect)(() => {
|
|
795
|
-
if (!
|
|
796
|
-
return onResize(
|
|
807
|
+
if (!rootRef.current) return;
|
|
808
|
+
return onResize(rootRef.current, () => {
|
|
797
809
|
if (!containeRef.current) return;
|
|
798
|
-
const
|
|
799
|
-
const
|
|
800
|
-
const scrollable =
|
|
801
|
-
const fit =
|
|
810
|
+
const collapsedLines = Number.parseInt(window.getComputedStyle(containeRef.current).getPropertyValue("--see-more-collapsed-lines"), 10) || 2;
|
|
811
|
+
const lineCount = getLineCount(containeRef.current);
|
|
812
|
+
const scrollable = lineCount > collapsedLines;
|
|
813
|
+
const fit = lineCount <= collapsedLines;
|
|
802
814
|
setStatus((current) => current === "no-expand" && scrollable ? "collapsed" : current !== "no-expand" && fit ? "no-expand" : current);
|
|
803
815
|
setExpandedHeight(containeRef.current?.scrollHeight);
|
|
804
816
|
});
|
|
@@ -806,6 +818,7 @@ const SeeMore = ({ style, messages = defaultMessages, children, ...rest }) => {
|
|
|
806
818
|
const toggle = () => setStatus((current) => current === "collapsed" ? "expanded" : "collapsing");
|
|
807
819
|
return /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsxs)("div", {
|
|
808
820
|
css: [containerStyle, { div: addonStyles[status] }],
|
|
821
|
+
ref: rootRef,
|
|
809
822
|
...rest,
|
|
810
823
|
children: [/* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsxs)("div", {
|
|
811
824
|
css: [expandedHeight && { "--see-more-max-height": `${expandedHeight}px` }, style],
|
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
|
|
3
|
+
import * as _emotion_react_jsx_runtime0 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
|
-
}) =>
|
|
68
|
+
}) => _emotion_react_jsx_runtime0.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
|
-
}) =>
|
|
77
|
+
}) => _emotion_react_jsx_runtime0.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
|
-
}) =>
|
|
93
|
+
}) => _emotion_react_jsx_runtime0.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
|
-
}) =>
|
|
157
|
+
}) => _emotion_react_jsx_runtime0.JSX.Element;
|
|
158
158
|
//#endregion
|
|
159
159
|
export { Banner, Dropdown, HiddenToggle, Icon, SeeMore, VideoItem, VideoThumbnail };
|
package/dist/index.mjs
CHANGED
|
@@ -738,6 +738,7 @@ const containerStyle = {
|
|
|
738
738
|
"&:hover": { color: "#fff" },
|
|
739
739
|
"&:disabled": {
|
|
740
740
|
opacity: "0",
|
|
741
|
+
pointerEvents: "none",
|
|
741
742
|
"-webkit-tap-highlight-color": "transparent"
|
|
742
743
|
},
|
|
743
744
|
"> span": {
|
|
@@ -783,6 +784,16 @@ const onResize = (container, handler) => {
|
|
|
783
784
|
observer.observe(container);
|
|
784
785
|
return () => observer.disconnect();
|
|
785
786
|
};
|
|
787
|
+
const getLineCount = (el) => {
|
|
788
|
+
const style = window.getComputedStyle(el);
|
|
789
|
+
let lineHeight = Number.parseFloat(style.lineHeight);
|
|
790
|
+
if (Number.isNaN(lineHeight) || lineHeight <= 0) {
|
|
791
|
+
const fontSize = Number.parseFloat(style.fontSize);
|
|
792
|
+
lineHeight = fontSize > 0 ? fontSize * 1.2 : 0;
|
|
793
|
+
}
|
|
794
|
+
if (!lineHeight) return 0;
|
|
795
|
+
return Math.max(1, Math.round(el.scrollHeight / lineHeight));
|
|
796
|
+
};
|
|
786
797
|
const defaultMessages = {
|
|
787
798
|
seeMore: "もっと見る",
|
|
788
799
|
seeLess: "閉じる"
|
|
@@ -790,15 +801,16 @@ const defaultMessages = {
|
|
|
790
801
|
const SeeMore = ({ style, messages = defaultMessages, children, ...rest }) => {
|
|
791
802
|
const [status, setStatus] = useState("no-expand");
|
|
792
803
|
const [expandedHeight, setExpandedHeight] = useState();
|
|
804
|
+
const rootRef = useRef(null);
|
|
793
805
|
const containeRef = useRef();
|
|
794
806
|
useEffect(() => {
|
|
795
|
-
if (!
|
|
796
|
-
return onResize(
|
|
807
|
+
if (!rootRef.current) return;
|
|
808
|
+
return onResize(rootRef.current, () => {
|
|
797
809
|
if (!containeRef.current) return;
|
|
798
|
-
const
|
|
799
|
-
const
|
|
800
|
-
const scrollable =
|
|
801
|
-
const fit =
|
|
810
|
+
const collapsedLines = Number.parseInt(window.getComputedStyle(containeRef.current).getPropertyValue("--see-more-collapsed-lines"), 10) || 2;
|
|
811
|
+
const lineCount = getLineCount(containeRef.current);
|
|
812
|
+
const scrollable = lineCount > collapsedLines;
|
|
813
|
+
const fit = lineCount <= collapsedLines;
|
|
802
814
|
setStatus((current) => current === "no-expand" && scrollable ? "collapsed" : current !== "no-expand" && fit ? "no-expand" : current);
|
|
803
815
|
setExpandedHeight(containeRef.current?.scrollHeight);
|
|
804
816
|
});
|
|
@@ -806,6 +818,7 @@ const SeeMore = ({ style, messages = defaultMessages, children, ...rest }) => {
|
|
|
806
818
|
const toggle = () => setStatus((current) => current === "collapsed" ? "expanded" : "collapsing");
|
|
807
819
|
return /* @__PURE__ */ jsxs("div", {
|
|
808
820
|
css: [containerStyle, { div: addonStyles[status] }],
|
|
821
|
+
ref: rootRef,
|
|
809
822
|
...rest,
|
|
810
823
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
811
824
|
css: [expandedHeight && { "--see-more-max-height": `${expandedHeight}px` }, style],
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
2
|
+
"name": "@kkcompany/app-ui",
|
|
3
|
+
"version": "0.1.28",
|
|
4
|
+
"module": "dist/index.mjs",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.mts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "next",
|
|
22
|
+
"build": "tsdown --format esm --format cjs"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@emotion/react": "^11.14.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": "^16.8.0",
|
|
29
|
+
"react-dom": "^16.8.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@biomejs/biome": "^2.3.5",
|
|
33
|
+
"binary-base64-loader": "^1.0.0",
|
|
34
|
+
"next": "^16.0.2",
|
|
35
|
+
"rollup-plugin-base64": "^1.0.1",
|
|
36
|
+
"tsdown": "^0.16.4",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
}
|
|
39
39
|
}
|