@apify/mcp-widgets 0.1.0 → 0.1.1-featmcpwidgetssearchcomponen-5114c0.4
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/README.md +7 -3
- package/dist/components/actor_card/actor_card.d.ts +10 -0
- package/dist/components/actor_card/actor_card.d.ts.map +1 -0
- package/dist/components/actor_card/actor_card.js +205 -0
- package/dist/components/actor_card/actor_card.test_ids.d.ts +5 -0
- package/dist/components/actor_card/actor_card.test_ids.d.ts.map +1 -0
- package/dist/components/actor_card/actor_card.test_ids.js +7 -0
- package/dist/components/actor_search/actor_search_detail.d.ts +7 -0
- package/dist/components/actor_search/actor_search_detail.d.ts.map +1 -0
- package/dist/components/actor_search/actor_search_detail.js +180 -0
- package/dist/components/actor_search/actor_search_detail.test_ids.d.ts +4 -0
- package/dist/components/actor_search/actor_search_detail.test_ids.d.ts.map +1 -0
- package/dist/components/actor_search/actor_search_detail.test_ids.js +4 -0
- package/dist/components/actor_search/actor_search_skeleton.d.ts +5 -0
- package/dist/components/actor_search/actor_search_skeleton.d.ts.map +1 -0
- package/dist/components/actor_search/actor_search_skeleton.js +189 -0
- package/dist/components/actor_search/actor_search_skeleton.test_ids.d.ts +5 -0
- package/dist/components/actor_search/actor_search_skeleton.test_ids.d.ts.map +1 -0
- package/dist/components/actor_search/actor_search_skeleton.test_ids.js +7 -0
- package/dist/components/actor_search/actor_search_widget.d.ts +9 -0
- package/dist/components/actor_search/actor_search_widget.d.ts.map +1 -0
- package/dist/components/actor_search/actor_search_widget.js +32 -0
- package/dist/components/actor_search/actor_search_widget.test_ids.d.ts +4 -0
- package/dist/components/actor_search/actor_search_widget.test_ids.d.ts.map +1 -0
- package/dist/components/actor_search/actor_search_widget.test_ids.js +4 -0
- package/dist/components/skeleton_block/skeleton_block.d.ts +3 -0
- package/dist/components/skeleton_block/skeleton_block.d.ts.map +1 -0
- package/dist/components/skeleton_block/skeleton_block.js +22 -0
- package/dist/components/widget_layout/widget_layout.d.ts +9 -0
- package/dist/components/widget_layout/widget_layout.d.ts.map +1 -0
- package/dist/components/widget_layout/widget_layout.js +25 -0
- package/dist/files_hash_at_build.txt +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/test_ids.d.ts +5 -0
- package/dist/test_ids.d.ts.map +1 -0
- package/dist/test_ids.js +5 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/formatting.d.ts +5 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +62 -0
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -12,16 +12,20 @@ Peer dependencies: `react`, `react-dom`, `styled-components`. The components bui
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
Components reach the environment through `WidgetHostProvider`:
|
|
15
|
+
Components take the tool's `structuredContent` as props and reach the environment through `WidgetHostProvider`:
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import { WidgetHostProvider } from '@apify/mcp-widgets';
|
|
18
|
+
import { ActorSearchWidget, WidgetHostProvider } from '@apify/mcp-widgets';
|
|
19
19
|
|
|
20
|
-
<WidgetHostProvider host={{ openLink: (url) => window.open(url, '_blank', 'noopener') }}>
|
|
20
|
+
<WidgetHostProvider host={{ openLink: (url) => window.open(url, '_blank', 'noopener') }}>
|
|
21
|
+
<ActorSearchWidget output={toolResult.structuredContent} />
|
|
22
|
+
</WidgetHostProvider>;
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
`WidgetHost` has one required member, `openLink`. `requestDisplayMode` and `maxHeight` are optional: hosts with a single display mode or no height limit leave them out.
|
|
24
26
|
|
|
27
|
+
Exports: `ActorSearchWidget`, `ActorSearchDetail`, `ActorCard`, `ActorSearchResultsSkeleton`, `ActorSearchDetailSkeleton`, `WidgetLayout`, `SkeletonBlock`, `WidgetHostProvider`, `useWidgetHost` and the tool output types. Test ids for Playwright live under `@apify/mcp-widgets/test-ids`.
|
|
28
|
+
|
|
25
29
|
## Development
|
|
26
30
|
|
|
27
31
|
Inside the apify-core monorepo:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Actor } from '../../types';
|
|
3
|
+
type ActorCardProps = {
|
|
4
|
+
actor: Actor;
|
|
5
|
+
isDetail?: boolean;
|
|
6
|
+
customActionButton?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare function ActorCard({ actor, isDetail, customActionButton }: ActorCardProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=actor_card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_card.d.ts","sourceRoot":"","sources":["../../../src/components/actor_card/actor_card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EAAE,KAAK,EAAqC,MAAM,aAAa,CAAC;AAI5E,KAAK,cAAc,GAAG;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,SAAS,CAAC;CAClC,CAAC;AAmKF,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,QAAgB,EAAE,kBAAkB,EAAE,EAAE,cAAc,2CA+DxF"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { useWidgetHost } from "../../host/widget_host_provider.js";
|
|
2
|
+
import { formatDecimalNumber, formatNumber, formatPricing } from "../../utils/formatting.js";
|
|
3
|
+
import { actorCardTestIds } from "./actor_card.test_ids.js";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { CoinIcon, ExternalLinkIcon, PeopleIcon, StarEmptyIcon } from "@apify/ui-icons";
|
|
6
|
+
import { ActorAvatar, Box, Text, clampLines, theme } from "@apify/ui-library";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/actor_card/actor_card.tsx
|
|
9
|
+
var Container = styled(Box)`
|
|
10
|
+
background: ${theme.color.neutral.background};
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: ${theme.space.space8};
|
|
14
|
+
border-radius: ${theme.radius.radius12};
|
|
15
|
+
border: ${(props) => props.$withBorder ? `1px solid ${theme.color.neutral.separatorSubtle}` : "none"};
|
|
16
|
+
|
|
17
|
+
.clampToOneLine {
|
|
18
|
+
${clampLines(1)}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
var BoxRow = styled(Box)`
|
|
22
|
+
display: flex;
|
|
23
|
+
gap: ${theme.space.space8};
|
|
24
|
+
align-items: center;
|
|
25
|
+
position: relative;
|
|
26
|
+
`;
|
|
27
|
+
var ActorHeaderWithActionButton = styled.div`
|
|
28
|
+
display: flex;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
align-items: center;
|
|
31
|
+
width: 100%;
|
|
32
|
+
`;
|
|
33
|
+
var BoxGroup = styled(Box)`
|
|
34
|
+
display: flex;
|
|
35
|
+
gap: ${theme.space.space4};
|
|
36
|
+
align-items: center;
|
|
37
|
+
`;
|
|
38
|
+
var ExternalLinkButton = styled.button`
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
width: 32px;
|
|
44
|
+
height: 32px;
|
|
45
|
+
padding: 0;
|
|
46
|
+
border-radius: ${theme.radius.radius6};
|
|
47
|
+
background-color: ${theme.color.neutral.backgroundMuted};
|
|
48
|
+
border: 1px solid ${theme.color.neutral.border};
|
|
49
|
+
color: ${theme.color.neutral.text};
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
background-color: ${theme.color.neutral.hover};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
& > * {
|
|
58
|
+
pointer-events: none;
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
var StyledSeparator = styled(Box)`
|
|
62
|
+
border-left: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
63
|
+
height: 8px;
|
|
64
|
+
width: 1px;
|
|
65
|
+
`;
|
|
66
|
+
var DescriptionText = styled(Text)`
|
|
67
|
+
white-space: pre-wrap;
|
|
68
|
+
${({ $isDetail }) => !$isDetail && clampLines(1)};
|
|
69
|
+
`;
|
|
70
|
+
var ActorHeader = styled.div`
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
gap: ${theme.space.space8};
|
|
74
|
+
`;
|
|
75
|
+
var ActorTitleWrapper = styled.div`
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
gap: ${theme.space.space2};
|
|
79
|
+
`;
|
|
80
|
+
var ActorAvatarWrapper = styled.div`
|
|
81
|
+
display: flex;
|
|
82
|
+
border: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
83
|
+
border-radius: ${theme.radius.radius8};
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
flex-shrink: 0;
|
|
86
|
+
`;
|
|
87
|
+
function Stat({ icon, value, additionalInfo }) {
|
|
88
|
+
return /* @__PURE__ */ jsxs(BoxGroup, { children: [icon, /* @__PURE__ */ jsxs(Text, {
|
|
89
|
+
size: "small",
|
|
90
|
+
weight: "medium",
|
|
91
|
+
color: theme.color.neutral.textMuted,
|
|
92
|
+
children: [value, additionalInfo && /* @__PURE__ */ jsxs(Text, {
|
|
93
|
+
size: "small",
|
|
94
|
+
color: theme.color.neutral.textSubtle,
|
|
95
|
+
as: "span",
|
|
96
|
+
children: [" ", additionalInfo]
|
|
97
|
+
})]
|
|
98
|
+
})] });
|
|
99
|
+
}
|
|
100
|
+
var StatsContainer = styled(Box)`
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: row;
|
|
103
|
+
flex-wrap: wrap;
|
|
104
|
+
gap: ${theme.space.space8};
|
|
105
|
+
align-items: center;
|
|
106
|
+
`;
|
|
107
|
+
var ShowOnMobile = styled(BoxRow)`
|
|
108
|
+
display: flex;
|
|
109
|
+
|
|
110
|
+
@media ${theme.device.tablet} {
|
|
111
|
+
display: none;
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
var ShowOnTabletAndDesktop = styled(BoxRow)`
|
|
115
|
+
display: none;
|
|
116
|
+
|
|
117
|
+
@media ${theme.device.tablet} {
|
|
118
|
+
display: flex;
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
function StatsRow({ stats, pricingInfo, showFirstSeparator = false }) {
|
|
122
|
+
return /* @__PURE__ */ jsxs(StatsContainer, { children: [
|
|
123
|
+
showFirstSeparator && /* @__PURE__ */ jsx(StyledSeparator, {}),
|
|
124
|
+
/* @__PURE__ */ jsx(Stat, {
|
|
125
|
+
icon: /* @__PURE__ */ jsx(PeopleIcon, {
|
|
126
|
+
size: "12",
|
|
127
|
+
color: theme.color.neutral.icon
|
|
128
|
+
}),
|
|
129
|
+
value: formatNumber(stats.totalUsers)
|
|
130
|
+
}),
|
|
131
|
+
/* @__PURE__ */ jsx(StyledSeparator, {}),
|
|
132
|
+
/* @__PURE__ */ jsx(Stat, {
|
|
133
|
+
icon: /* @__PURE__ */ jsx(StarEmptyIcon, {
|
|
134
|
+
size: "12",
|
|
135
|
+
color: theme.color.neutral.icon
|
|
136
|
+
}),
|
|
137
|
+
value: formatDecimalNumber(stats.actorReviewRating),
|
|
138
|
+
additionalInfo: `(${formatNumber(stats.actorReviewCount)})`
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsx(StyledSeparator, {}),
|
|
141
|
+
/* @__PURE__ */ jsx(Stat, {
|
|
142
|
+
icon: /* @__PURE__ */ jsx(CoinIcon, {
|
|
143
|
+
size: "12",
|
|
144
|
+
color: theme.color.neutral.icon
|
|
145
|
+
}),
|
|
146
|
+
value: formatPricing(pricingInfo)
|
|
147
|
+
})
|
|
148
|
+
] });
|
|
149
|
+
}
|
|
150
|
+
function ActorCard({ actor, isDetail = false, customActionButton }) {
|
|
151
|
+
const host = useWidgetHost();
|
|
152
|
+
const statsProps = {
|
|
153
|
+
stats: actor.stats,
|
|
154
|
+
pricingInfo: actor.currentPricingInfo
|
|
155
|
+
};
|
|
156
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
157
|
+
px: "space16",
|
|
158
|
+
py: "space12",
|
|
159
|
+
$withBorder: !isDetail,
|
|
160
|
+
"data-test": actorCardTestIds.ROOT,
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ jsx(BoxRow, { children: /* @__PURE__ */ jsxs(ActorHeaderWithActionButton, { children: [/* @__PURE__ */ jsxs(ActorHeader, { children: [/* @__PURE__ */ jsx(ActorAvatarWrapper, { children: /* @__PURE__ */ jsx(ActorAvatar, {
|
|
163
|
+
size: 40,
|
|
164
|
+
name: actor.title,
|
|
165
|
+
url: actor.pictureUrl
|
|
166
|
+
}) }), /* @__PURE__ */ jsxs(ActorTitleWrapper, { children: [/* @__PURE__ */ jsx(Text, {
|
|
167
|
+
as: "h3",
|
|
168
|
+
weight: "bold",
|
|
169
|
+
color: theme.color.neutral.text,
|
|
170
|
+
className: "clampToOneLine",
|
|
171
|
+
children: actor.title
|
|
172
|
+
}), /* @__PURE__ */ jsxs(BoxRow, { children: [/* @__PURE__ */ jsxs(Text, {
|
|
173
|
+
size: "small",
|
|
174
|
+
weight: "medium",
|
|
175
|
+
type: "code",
|
|
176
|
+
color: theme.color.neutral.textSubtle,
|
|
177
|
+
className: "clampToOneLine",
|
|
178
|
+
children: [
|
|
179
|
+
actor.username,
|
|
180
|
+
"/",
|
|
181
|
+
actor.name
|
|
182
|
+
]
|
|
183
|
+
}), !isDetail && /* @__PURE__ */ jsx(ShowOnTabletAndDesktop, { children: /* @__PURE__ */ jsx(StatsRow, {
|
|
184
|
+
...statsProps,
|
|
185
|
+
showFirstSeparator: true
|
|
186
|
+
}) })] })] })] }), customActionButton || /* @__PURE__ */ jsx(ExternalLinkButton, {
|
|
187
|
+
type: "button",
|
|
188
|
+
onClick: () => host.openLink(actor.url),
|
|
189
|
+
"aria-label": `Open ${actor.title} in Apify Store`,
|
|
190
|
+
"data-test": actorCardTestIds.OPEN_ACTOR_BUTTON,
|
|
191
|
+
children: /* @__PURE__ */ jsx(ExternalLinkIcon, { size: "16" })
|
|
192
|
+
})] }) }),
|
|
193
|
+
/* @__PURE__ */ jsx(DescriptionText, {
|
|
194
|
+
size: "small",
|
|
195
|
+
weight: "normal",
|
|
196
|
+
color: theme.color.neutral.text,
|
|
197
|
+
$isDetail: isDetail,
|
|
198
|
+
children: actor.description
|
|
199
|
+
}),
|
|
200
|
+
isDetail ? /* @__PURE__ */ jsx(StatsRow, { ...statsProps }) : /* @__PURE__ */ jsx(ShowOnMobile, { children: /* @__PURE__ */ jsx(StatsRow, { ...statsProps }) })
|
|
201
|
+
]
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
export { ActorCard };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_card.test_ids.d.ts","sourceRoot":"","sources":["../../../src/components/actor_card/actor_card.test_ids.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActorDetails } from '../../types';
|
|
2
|
+
type ActorSearchDetailProps = {
|
|
3
|
+
details: ActorDetails;
|
|
4
|
+
};
|
|
5
|
+
export declare function ActorSearchDetail({ details }: ActorSearchDetailProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=actor_search_detail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_search_detail.d.ts","sourceRoot":"","sources":["../../../src/components/actor_search/actor_search_detail.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAyJhD,KAAK,sBAAsB,GAAG;IAC1B,OAAO,EAAE,YAAY,CAAC;CACzB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,OAAO,EAAE,EAAE,sBAAsB,2CAsDpE"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { useWidgetHost } from "../../host/widget_host_provider.js";
|
|
2
|
+
import { ActorCard } from "../actor_card/actor_card.js";
|
|
3
|
+
import { actorSearchDetailTestIds } from "./actor_search_detail.test_ids.js";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { BookOpenIcon, FullscreenIcon, MinimizeIcon } from "@apify/ui-icons";
|
|
6
|
+
import { Badge, Box, ICON_BUTTON_VARIANTS, IconButton, Markdown, theme, useActorTitleHeadingFilter } from "@apify/ui-library";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/actor_search/actor_search_detail.tsx
|
|
10
|
+
var FULLSCREEN_WIDTH_THRESHOLD = 900;
|
|
11
|
+
var README_CLASSNAMES = {
|
|
12
|
+
MARKDOWN_WRAPPER: "Readme-MarkdownWrapper",
|
|
13
|
+
MARKDOWN: "Readme-Markdown",
|
|
14
|
+
ONELINE_SCROLLABLE_WRAPPER: "OneLineCode-ScrollableWrapper"
|
|
15
|
+
};
|
|
16
|
+
var Container = styled(Box)`
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
align-items: center;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
overflow: auto;
|
|
24
|
+
background: ${theme.color.neutral.background};
|
|
25
|
+
border-radius: ${theme.radius.radius12};
|
|
26
|
+
border: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
27
|
+
`;
|
|
28
|
+
var CardWrapper = styled(Box)`
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
width: 100%;
|
|
33
|
+
max-width: 796px;
|
|
34
|
+
`;
|
|
35
|
+
var SectionContent = styled(Box)`
|
|
36
|
+
background: ${theme.color.neutral.background};
|
|
37
|
+
border-top: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
38
|
+
color: ${theme.color.neutral.text};
|
|
39
|
+
position: relative;
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
|
|
43
|
+
${(props) => props.$isExpanded ? `
|
|
44
|
+
overflow-y: auto;
|
|
45
|
+
max-height: none;
|
|
46
|
+
flex: 1;
|
|
47
|
+
` : `
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
max-height: 408px;
|
|
50
|
+
`}
|
|
51
|
+
`;
|
|
52
|
+
var ReadmeWrapper = styled.div`
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
gap: ${theme.space.space16};
|
|
56
|
+
position: relative;
|
|
57
|
+
|
|
58
|
+
.${README_CLASSNAMES.MARKDOWN_WRAPPER} {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
gap: ${theme.space.space8};
|
|
62
|
+
}
|
|
63
|
+
/* Design-system exception: denser readme typography, links in text color. */
|
|
64
|
+
.${README_CLASSNAMES.MARKDOWN} {
|
|
65
|
+
a {
|
|
66
|
+
color: inherit;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
p,
|
|
70
|
+
li,
|
|
71
|
+
strong,
|
|
72
|
+
b,
|
|
73
|
+
table,
|
|
74
|
+
code {
|
|
75
|
+
font-size: 1.2rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ul {
|
|
79
|
+
display: block;
|
|
80
|
+
list-style-type: disc;
|
|
81
|
+
margin-block-start: 1em;
|
|
82
|
+
margin-block-end: 1em;
|
|
83
|
+
padding-inline-start: 40px;
|
|
84
|
+
unicode-bidi: isolate;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
div:not(.${README_CLASSNAMES.ONELINE_SCROLLABLE_WRAPPER}) > pre {
|
|
88
|
+
display: block;
|
|
89
|
+
padding-left: 1.6rem;
|
|
90
|
+
padding-right: 1.6rem;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
var GradientOverlay = styled.div`
|
|
95
|
+
position: absolute;
|
|
96
|
+
bottom: 0;
|
|
97
|
+
left: 0;
|
|
98
|
+
right: 0;
|
|
99
|
+
height: 155px;
|
|
100
|
+
background: linear-gradient(178.84deg, transparent 13.4%, ${theme.color.neutral.background} 81.59%);
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
z-index: 1;
|
|
103
|
+
`;
|
|
104
|
+
var ReadmeHeader = styled.div`
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: space-between;
|
|
108
|
+
width: 100%;
|
|
109
|
+
`;
|
|
110
|
+
var BadgeWrapper = styled.div`
|
|
111
|
+
flex-shrink: 0;
|
|
112
|
+
`;
|
|
113
|
+
function ReadmeSection({ readme, isExpanded }) {
|
|
114
|
+
const allowElement = useActorTitleHeadingFilter("Readme");
|
|
115
|
+
if (!readme) return null;
|
|
116
|
+
return /* @__PURE__ */ jsxs(SectionContent, {
|
|
117
|
+
p: "space16",
|
|
118
|
+
$isExpanded: isExpanded,
|
|
119
|
+
children: [/* @__PURE__ */ jsxs(ReadmeWrapper, { children: [/* @__PURE__ */ jsx(ReadmeHeader, { children: /* @__PURE__ */ jsx(BadgeWrapper, { children: /* @__PURE__ */ jsx(Badge, {
|
|
120
|
+
size: "small",
|
|
121
|
+
LeadingIcon: BookOpenIcon,
|
|
122
|
+
children: "Readme"
|
|
123
|
+
}) }) }), /* @__PURE__ */ jsx("div", {
|
|
124
|
+
className: README_CLASSNAMES.MARKDOWN_WRAPPER,
|
|
125
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
126
|
+
markdown: readme,
|
|
127
|
+
className: README_CLASSNAMES.MARKDOWN,
|
|
128
|
+
allowElement,
|
|
129
|
+
lazyLoadImages: true
|
|
130
|
+
})
|
|
131
|
+
})] }), !isExpanded && /* @__PURE__ */ jsx(GradientOverlay, {})]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function ActorSearchDetail({ details }) {
|
|
135
|
+
const host = useWidgetHost();
|
|
136
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
137
|
+
const manualMode = useRef(null);
|
|
138
|
+
const containerRef = useRef(null);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
const container = containerRef.current;
|
|
141
|
+
if (!container) return;
|
|
142
|
+
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
143
|
+
const shouldBeExpanded = entry.contentRect.width > FULLSCREEN_WIDTH_THRESHOLD;
|
|
144
|
+
if (manualMode.current === "collapsed" && shouldBeExpanded) return;
|
|
145
|
+
if (manualMode.current === "expanded" && !shouldBeExpanded) return;
|
|
146
|
+
manualMode.current = null;
|
|
147
|
+
setIsExpanded(shouldBeExpanded);
|
|
148
|
+
});
|
|
149
|
+
resizeObserver.observe(container);
|
|
150
|
+
return () => {
|
|
151
|
+
resizeObserver.disconnect();
|
|
152
|
+
};
|
|
153
|
+
}, []);
|
|
154
|
+
const handleToggleExpand = () => {
|
|
155
|
+
const nextExpanded = !isExpanded;
|
|
156
|
+
manualMode.current = nextExpanded ? "expanded" : "collapsed";
|
|
157
|
+
setIsExpanded(nextExpanded);
|
|
158
|
+
host.requestDisplayMode?.(nextExpanded ? "fullscreen" : "inline");
|
|
159
|
+
};
|
|
160
|
+
const fullscreenButton = /* @__PURE__ */ jsx(IconButton, {
|
|
161
|
+
Icon: isExpanded ? MinimizeIcon : FullscreenIcon,
|
|
162
|
+
variant: ICON_BUTTON_VARIANTS.BORDERED,
|
|
163
|
+
onClick: handleToggleExpand,
|
|
164
|
+
"aria-label": isExpanded ? "Collapse readme" : "Expand readme",
|
|
165
|
+
"data-test": actorSearchDetailTestIds.TOGGLE_FULLSCREEN_BUTTON
|
|
166
|
+
});
|
|
167
|
+
return /* @__PURE__ */ jsx(Container, {
|
|
168
|
+
ref: containerRef,
|
|
169
|
+
children: /* @__PURE__ */ jsxs(CardWrapper, { children: [/* @__PURE__ */ jsx(ActorCard, {
|
|
170
|
+
actor: details.actorInfo,
|
|
171
|
+
isDetail: true,
|
|
172
|
+
customActionButton: fullscreenButton
|
|
173
|
+
}), /* @__PURE__ */ jsx(ReadmeSection, {
|
|
174
|
+
readme: details.readme,
|
|
175
|
+
isExpanded
|
|
176
|
+
})] })
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { ActorSearchDetail };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_search_detail.test_ids.d.ts","sourceRoot":"","sources":["../../../src/components/actor_search/actor_search_detail.test_ids.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB;;CAE3B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function ActorSearchResultsSkeleton({ items }: {
|
|
2
|
+
items?: number;
|
|
3
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function ActorSearchDetailSkeleton(): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=actor_search_skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_search_skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/actor_search/actor_search_skeleton.tsx"],"names":[],"mappings":"AAsFA,wBAAgB,0BAA0B,CAAC,EAAE,KAAS,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,2CAQ3E;AAsED,wBAAgB,yBAAyB,4CA4BxC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { SkeletonBlock } from "../skeleton_block/skeleton_block.js";
|
|
2
|
+
import { actorSearchSkeletonTestIds } from "./actor_search_skeleton.test_ids.js";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Box, theme } from "@apify/ui-library";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/actor_search/actor_search_skeleton.tsx
|
|
7
|
+
var SquareSkeleton = styled(SkeletonBlock)`
|
|
8
|
+
width: ${({ $size }) => $size};
|
|
9
|
+
height: ${({ $size }) => $size};
|
|
10
|
+
border-radius: ${theme.radius.radius8};
|
|
11
|
+
flex-shrink: 0;
|
|
12
|
+
`;
|
|
13
|
+
var LineSkeleton = styled(SkeletonBlock)`
|
|
14
|
+
width: ${({ $width }) => $width};
|
|
15
|
+
height: ${({ $height }) => $height};
|
|
16
|
+
`;
|
|
17
|
+
var Container = styled(Box)`
|
|
18
|
+
background: ${theme.color.neutral.background};
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: ${theme.space.space8};
|
|
22
|
+
border-radius: ${theme.radius.radius12};
|
|
23
|
+
border: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
24
|
+
`;
|
|
25
|
+
var BoxRow = styled(Box)`
|
|
26
|
+
display: flex;
|
|
27
|
+
gap: ${theme.space.space8};
|
|
28
|
+
position: relative;
|
|
29
|
+
`;
|
|
30
|
+
var ContentColumn = styled(Box)`
|
|
31
|
+
display: flex;
|
|
32
|
+
flex: 1;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
gap: ${theme.space.space6};
|
|
35
|
+
min-width: 0;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
`;
|
|
38
|
+
var DescriptionGroup = styled(Box)`
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
gap: ${theme.space.space4};
|
|
42
|
+
width: 100%;
|
|
43
|
+
`;
|
|
44
|
+
var AlignEnd = styled.div`
|
|
45
|
+
margin-left: auto;
|
|
46
|
+
align-self: flex-start;
|
|
47
|
+
position: absolute;
|
|
48
|
+
right: 0;
|
|
49
|
+
top: 0;
|
|
50
|
+
`;
|
|
51
|
+
function ActorListItemSkeleton() {
|
|
52
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
53
|
+
px: "space16",
|
|
54
|
+
py: "space12",
|
|
55
|
+
children: [/* @__PURE__ */ jsxs(BoxRow, { children: [
|
|
56
|
+
/* @__PURE__ */ jsx(SquareSkeleton, { $size: "40px" }),
|
|
57
|
+
/* @__PURE__ */ jsxs(ContentColumn, { children: [/* @__PURE__ */ jsx(LineSkeleton, {
|
|
58
|
+
$height: "20px",
|
|
59
|
+
$width: "66%"
|
|
60
|
+
}), /* @__PURE__ */ jsx(LineSkeleton, {
|
|
61
|
+
$height: "16px",
|
|
62
|
+
$width: "80%"
|
|
63
|
+
})] }),
|
|
64
|
+
/* @__PURE__ */ jsx(AlignEnd, { children: /* @__PURE__ */ jsx(SquareSkeleton, { $size: "32px" }) })
|
|
65
|
+
] }), /* @__PURE__ */ jsxs(DescriptionGroup, { children: [/* @__PURE__ */ jsx(LineSkeleton, {
|
|
66
|
+
$height: "14px",
|
|
67
|
+
$width: "100%"
|
|
68
|
+
}), /* @__PURE__ */ jsx(LineSkeleton, {
|
|
69
|
+
$height: "14px",
|
|
70
|
+
$width: "100%"
|
|
71
|
+
})] })]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
var ResultsContainer = styled(Box)`
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
gap: ${theme.space.space8};
|
|
78
|
+
width: 100%;
|
|
79
|
+
`;
|
|
80
|
+
function ActorSearchResultsSkeleton({ items = 3 }) {
|
|
81
|
+
return /* @__PURE__ */ jsx(ResultsContainer, {
|
|
82
|
+
"data-test": actorSearchSkeletonTestIds.RESULTS,
|
|
83
|
+
children: Array.from({ length: items }).map((_, index) => /* @__PURE__ */ jsx(ActorListItemSkeleton, {}, index))
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
var DetailContainer = styled(Box)`
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
align-items: center;
|
|
91
|
+
width: 100%;
|
|
92
|
+
`;
|
|
93
|
+
var CardWrapper = styled(Box)`
|
|
94
|
+
background: ${theme.color.neutral.background};
|
|
95
|
+
border-radius: ${theme.radius.radius12};
|
|
96
|
+
border: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
max-width: 796px;
|
|
101
|
+
width: 100%;
|
|
102
|
+
`;
|
|
103
|
+
var HeaderSection = styled(Box)`
|
|
104
|
+
background: ${theme.color.neutral.background};
|
|
105
|
+
display: flex;
|
|
106
|
+
flex-direction: column;
|
|
107
|
+
gap: ${theme.space.space8};
|
|
108
|
+
`;
|
|
109
|
+
var HeaderRow = styled(Box)`
|
|
110
|
+
display: flex;
|
|
111
|
+
gap: ${theme.space.space8};
|
|
112
|
+
align-items: center;
|
|
113
|
+
`;
|
|
114
|
+
var HeaderColumn = styled(Box)`
|
|
115
|
+
display: flex;
|
|
116
|
+
flex: 1;
|
|
117
|
+
flex-direction: column;
|
|
118
|
+
gap: ${theme.space.space8};
|
|
119
|
+
min-width: 0;
|
|
120
|
+
`;
|
|
121
|
+
var DescriptionLines = styled(Box)`
|
|
122
|
+
display: flex;
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
gap: ${theme.space.space8};
|
|
125
|
+
`;
|
|
126
|
+
var SectionsGroup = styled(Box)`
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
`;
|
|
130
|
+
var SectionHeaderWrapper = styled(Box)`
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: space-between;
|
|
134
|
+
background: ${theme.color.neutral.background};
|
|
135
|
+
border-top: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
136
|
+
`;
|
|
137
|
+
function SectionHeaderSkeleton() {
|
|
138
|
+
return /* @__PURE__ */ jsxs(SectionHeaderWrapper, {
|
|
139
|
+
px: "space16",
|
|
140
|
+
py: "space12",
|
|
141
|
+
children: [/* @__PURE__ */ jsx(LineSkeleton, {
|
|
142
|
+
$height: "24px",
|
|
143
|
+
$width: "96px"
|
|
144
|
+
}), /* @__PURE__ */ jsx(LineSkeleton, {
|
|
145
|
+
$height: "16px",
|
|
146
|
+
$width: "64px"
|
|
147
|
+
})]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function ActorSearchDetailSkeleton() {
|
|
151
|
+
return /* @__PURE__ */ jsx(DetailContainer, {
|
|
152
|
+
"data-test": actorSearchSkeletonTestIds.DETAIL,
|
|
153
|
+
children: /* @__PURE__ */ jsxs(CardWrapper, { children: [/* @__PURE__ */ jsxs(HeaderSection, {
|
|
154
|
+
px: "space16",
|
|
155
|
+
py: "space12",
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ jsxs(HeaderRow, {
|
|
158
|
+
py: "space2",
|
|
159
|
+
children: [/* @__PURE__ */ jsx(SquareSkeleton, { $size: "64px" }), /* @__PURE__ */ jsxs(HeaderColumn, { children: [/* @__PURE__ */ jsx(LineSkeleton, {
|
|
160
|
+
$height: "20px",
|
|
161
|
+
$width: "50%"
|
|
162
|
+
}), /* @__PURE__ */ jsx(LineSkeleton, {
|
|
163
|
+
$height: "16px",
|
|
164
|
+
$width: "33%"
|
|
165
|
+
})] })]
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsxs(DescriptionLines, { children: [/* @__PURE__ */ jsx(LineSkeleton, {
|
|
168
|
+
$height: "16px",
|
|
169
|
+
$width: "100%"
|
|
170
|
+
}), /* @__PURE__ */ jsx(LineSkeleton, {
|
|
171
|
+
$height: "16px",
|
|
172
|
+
$width: "80%"
|
|
173
|
+
})] }),
|
|
174
|
+
/* @__PURE__ */ jsx(LineSkeleton, {
|
|
175
|
+
$height: "16px",
|
|
176
|
+
$width: "66%"
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
}), /* @__PURE__ */ jsxs(SectionsGroup, { children: [
|
|
180
|
+
/* @__PURE__ */ jsx(SectionHeaderSkeleton, {}),
|
|
181
|
+
/* @__PURE__ */ jsx(SectionHeaderSkeleton, {}),
|
|
182
|
+
/* @__PURE__ */ jsx(SectionHeaderSkeleton, {}),
|
|
183
|
+
/* @__PURE__ */ jsx(SectionHeaderSkeleton, {}),
|
|
184
|
+
/* @__PURE__ */ jsx(SectionHeaderSkeleton, {})
|
|
185
|
+
] })] })
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
export { ActorSearchDetailSkeleton, ActorSearchResultsSkeleton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_search_skeleton.test_ids.d.ts","sourceRoot":"","sources":["../../../src/components/actor_search/actor_search_skeleton.test_ids.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B;;;CAG7B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SearchActorsOutput } from '../../types';
|
|
2
|
+
type ActorSearchWidgetProps = {
|
|
3
|
+
/** `structuredContent` of the tool result; `null` while the result has not arrived. */
|
|
4
|
+
output: SearchActorsOutput | null;
|
|
5
|
+
};
|
|
6
|
+
/** Renders the `search-actors-widget` / `fetch-actor-details-widget` tool result. */
|
|
7
|
+
export declare function ActorSearchWidget({ output }: ActorSearchWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=actor_search_widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_search_widget.d.ts","sourceRoot":"","sources":["../../../src/components/actor_search/actor_search_widget.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AActD,KAAK,sBAAsB,GAAG;IAC1B,uFAAuF;IACvF,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACrC,CAAC;AAsBF,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,EAAE,sBAAsB,2CAQnE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActorCard } from "../actor_card/actor_card.js";
|
|
2
|
+
import { ActorSearchDetail } from "./actor_search_detail.js";
|
|
3
|
+
import { ActorSearchResultsSkeleton } from "./actor_search_skeleton.js";
|
|
4
|
+
import { WidgetLayout } from "../widget_layout/widget_layout.js";
|
|
5
|
+
import { actorSearchWidgetTestIds } from "./actor_search_widget.test_ids.js";
|
|
6
|
+
import styled from "styled-components";
|
|
7
|
+
import { Box, Message, theme } from "@apify/ui-library";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/actor_search/actor_search_widget.tsx
|
|
10
|
+
var ActorSearchResults = styled(Box)`
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: ${theme.space.space8};
|
|
14
|
+
width: 100%;
|
|
15
|
+
`;
|
|
16
|
+
function ActorSearchContent({ output }) {
|
|
17
|
+
if (output === null) return /* @__PURE__ */ jsx(ActorSearchResultsSkeleton, {});
|
|
18
|
+
if ("actorDetails" in output) return /* @__PURE__ */ jsx(ActorSearchDetail, { details: output.actorDetails });
|
|
19
|
+
if (output.widgetActors.length === 0) return /* @__PURE__ */ jsx(Message, {
|
|
20
|
+
type: "info",
|
|
21
|
+
caption: "No actors found",
|
|
22
|
+
"data-test": actorSearchWidgetTestIds.EMPTY_STATE,
|
|
23
|
+
children: "Try a different search query"
|
|
24
|
+
});
|
|
25
|
+
return output.widgetActors.map((actor) => /* @__PURE__ */ jsx(ActorCard, { actor }, actor.id));
|
|
26
|
+
}
|
|
27
|
+
/** Renders the `search-actors-widget` / `fetch-actor-details-widget` tool result. */
|
|
28
|
+
function ActorSearchWidget({ output }) {
|
|
29
|
+
return /* @__PURE__ */ jsx(WidgetLayout, { children: /* @__PURE__ */ jsx(ActorSearchResults, { children: /* @__PURE__ */ jsx(ActorSearchContent, { output }) }) });
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ActorSearchWidget };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor_search_widget.test_ids.d.ts","sourceRoot":"","sources":["../../../src/components/actor_search/actor_search_widget.test_ids.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB;;CAE3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton_block.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton_block/skeleton_block.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAoBtD,wBAAgB,aAAa,CAAC,KAAK,EAAE,wBAAwB,CAAC,KAAK,CAAC,2CAEnE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled, { keyframes } from "styled-components";
|
|
2
|
+
import { theme } from "@apify/ui-library";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/skeleton_block/skeleton_block.tsx
|
|
5
|
+
var pulse = keyframes`
|
|
6
|
+
0%, 100% {
|
|
7
|
+
opacity: 1;
|
|
8
|
+
}
|
|
9
|
+
50% {
|
|
10
|
+
opacity: 0.5;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
var StyledSkeletonBlock = styled.div`
|
|
14
|
+
background-color: ${theme.color.neutral.backgroundSubtle};
|
|
15
|
+
border-radius: ${theme.radius.radius4};
|
|
16
|
+
animation: ${pulse} 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
17
|
+
`;
|
|
18
|
+
function SkeletonBlock(props) {
|
|
19
|
+
return /* @__PURE__ */ jsx(StyledSkeletonBlock, { ...props });
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { SkeletonBlock };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
type WidgetLayoutProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
};
|
|
7
|
+
export declare function WidgetLayout({ children, className, style }: WidgetLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=widget_layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget_layout.d.ts","sourceRoot":"","sources":["../../../src/components/widget_layout/widget_layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAkBtD,KAAK,iBAAiB,GAAG;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,iBAAiB,2CAQ7E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useWidgetHost } from "../../host/widget_host_provider.js";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { Box } from "@apify/ui-library";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/widget_layout/widget_layout.tsx
|
|
6
|
+
var Layout = styled(Box)`
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: 1.5rem;
|
|
10
|
+
width: 100%;
|
|
11
|
+
padding: 1rem 1.25rem 2.5rem;
|
|
12
|
+
overflow-y: auto;
|
|
13
|
+
max-height: ${({ $maxHeight }) => $maxHeight ? `${$maxHeight}px` : "none"};
|
|
14
|
+
`;
|
|
15
|
+
function WidgetLayout({ children, className, style }) {
|
|
16
|
+
const { maxHeight } = useWidgetHost();
|
|
17
|
+
return /* @__PURE__ */ jsx(Layout, {
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
$maxHeight: maxHeight,
|
|
21
|
+
children
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { WidgetLayout };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9fe09228f3920b39eb00142fb1fe677e974207e8
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export { ActorCard } from './components/actor_card/actor_card';
|
|
2
|
+
export { ActorSearchDetail } from './components/actor_search/actor_search_detail';
|
|
3
|
+
export { ActorSearchDetailSkeleton, ActorSearchResultsSkeleton } from './components/actor_search/actor_search_skeleton';
|
|
4
|
+
export { ActorSearchWidget } from './components/actor_search/actor_search_widget';
|
|
5
|
+
export { SkeletonBlock } from './components/skeleton_block/skeleton_block';
|
|
6
|
+
export { WidgetLayout } from './components/widget_layout/widget_layout';
|
|
1
7
|
export type { WidgetDisplayMode, WidgetHost } from './host/types';
|
|
2
8
|
export { useWidgetHost, WidgetHostProvider } from './host/widget_host_provider';
|
|
9
|
+
export type { Actor, ActorDetails, ActorStats, SearchActorsOutput, StructuredPricingInfo } from './types';
|
|
3
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AACxH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAChF,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { WidgetHostProvider, useWidgetHost } from "./host/widget_host_provider.js";
|
|
2
|
-
|
|
2
|
+
import { ActorCard } from "./components/actor_card/actor_card.js";
|
|
3
|
+
import { ActorSearchDetail } from "./components/actor_search/actor_search_detail.js";
|
|
4
|
+
import { SkeletonBlock } from "./components/skeleton_block/skeleton_block.js";
|
|
5
|
+
import { ActorSearchDetailSkeleton, ActorSearchResultsSkeleton } from "./components/actor_search/actor_search_skeleton.js";
|
|
6
|
+
import { WidgetLayout } from "./components/widget_layout/widget_layout.js";
|
|
7
|
+
import { ActorSearchWidget } from "./components/actor_search/actor_search_widget.js";
|
|
8
|
+
export { ActorCard, ActorSearchDetail, ActorSearchDetailSkeleton, ActorSearchResultsSkeleton, ActorSearchWidget, SkeletonBlock, WidgetHostProvider, WidgetLayout, useWidgetHost };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { actorCardTestIds } from './components/actor_card/actor_card.test_ids.js';
|
|
2
|
+
export { actorSearchDetailTestIds } from './components/actor_search/actor_search_detail.test_ids.js';
|
|
3
|
+
export { actorSearchSkeletonTestIds } from './components/actor_search/actor_search_skeleton.test_ids.js';
|
|
4
|
+
export { actorSearchWidgetTestIds } from './components/actor_search/actor_search_widget.test_ids.js';
|
|
5
|
+
//# sourceMappingURL=test_ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test_ids.d.ts","sourceRoot":"","sources":["../src/test_ids.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AACzG,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC"}
|
package/dist/test_ids.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { actorCardTestIds } from "./components/actor_card/actor_card.test_ids.js";
|
|
2
|
+
import { actorSearchDetailTestIds } from "./components/actor_search/actor_search_detail.test_ids.js";
|
|
3
|
+
import { actorSearchSkeletonTestIds } from "./components/actor_search/actor_search_skeleton.test_ids.js";
|
|
4
|
+
import { actorSearchWidgetTestIds } from "./components/actor_search/actor_search_widget.test_ids.js";
|
|
5
|
+
export { actorCardTestIds, actorSearchDetailTestIds, actorSearchSkeletonTestIds, actorSearchWidgetTestIds };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type StructuredPricingInfo = {
|
|
2
|
+
model: string;
|
|
3
|
+
userTier?: string;
|
|
4
|
+
pricePerUnit?: number;
|
|
5
|
+
unitName?: string;
|
|
6
|
+
trialMinutes?: number;
|
|
7
|
+
tieredPricing?: {
|
|
8
|
+
tier: string;
|
|
9
|
+
pricePerUnit: number;
|
|
10
|
+
}[];
|
|
11
|
+
events?: {
|
|
12
|
+
title: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
priceUsd?: number;
|
|
15
|
+
tieredPricing?: {
|
|
16
|
+
tier: string;
|
|
17
|
+
priceUsd: number;
|
|
18
|
+
}[];
|
|
19
|
+
}[];
|
|
20
|
+
pricingNote?: string;
|
|
21
|
+
eventDescriptionsOmitted?: boolean;
|
|
22
|
+
eventDescriptionsNote?: string;
|
|
23
|
+
};
|
|
24
|
+
export type ActorStats = {
|
|
25
|
+
totalUsers: number;
|
|
26
|
+
actorReviewRating: number;
|
|
27
|
+
actorReviewCount: number;
|
|
28
|
+
};
|
|
29
|
+
/** Actor as the MCP server formats it for widgets (`widgetActors`, `actorDetails.actorInfo`). */
|
|
30
|
+
export type Actor = {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
username: string;
|
|
34
|
+
url: string;
|
|
35
|
+
fullName: string;
|
|
36
|
+
title: string;
|
|
37
|
+
description: string;
|
|
38
|
+
/** Empty when the Actor has no picture. */
|
|
39
|
+
pictureUrl: string;
|
|
40
|
+
stats: ActorStats;
|
|
41
|
+
currentPricingInfo: StructuredPricingInfo;
|
|
42
|
+
};
|
|
43
|
+
export type ActorDetails = {
|
|
44
|
+
actorInfo: Actor;
|
|
45
|
+
actorCard: string;
|
|
46
|
+
readme: string;
|
|
47
|
+
inputSchema?: {
|
|
48
|
+
type: string;
|
|
49
|
+
properties: Record<string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** `structuredContent` of the `search-actors-widget` tool, or of `fetch-actor-details-widget`. */
|
|
53
|
+
export type SearchActorsOutput = {
|
|
54
|
+
widgetActors: Actor[];
|
|
55
|
+
query: string;
|
|
56
|
+
} | {
|
|
57
|
+
actorDetails: ActorDetails;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;KACxB,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,CAAC;SACpB,EAAE,CAAC;KACP,EAAE,CAAC;IACJ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,iGAAiG;AACjG,MAAM,MAAM,KAAK,GAAG;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,kBAAkB,EAAE,qBAAqB,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB,SAAS,EAAE,KAAK,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACvC,CAAC;CACL,CAAC;AAEF,kGAAkG;AAClG,MAAM,MAAM,kBAAkB,GAAG;IAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,YAAY,EAAE,YAAY,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StructuredPricingInfo } from '../types';
|
|
2
|
+
export declare function formatPricing(pricing: StructuredPricingInfo): string;
|
|
3
|
+
export declare function formatNumber(value: number): string;
|
|
4
|
+
export declare function formatDecimalNumber(value: number): string;
|
|
5
|
+
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAyDtD,wBAAgB,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAiBpE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import pluralize from "pluralize";
|
|
2
|
+
//#region src/utils/formatting.ts
|
|
3
|
+
var PER_THOUSAND_PRICING_THRESHOLD = .01;
|
|
4
|
+
var PRICE_DISPLAY_UNIT_SIZE = 1e3;
|
|
5
|
+
function formatPriceUsd(price) {
|
|
6
|
+
return new Intl.NumberFormat("en-US", {
|
|
7
|
+
style: "currency",
|
|
8
|
+
currency: "USD",
|
|
9
|
+
useGrouping: true,
|
|
10
|
+
minimumFractionDigits: 2,
|
|
11
|
+
maximumFractionDigits: 2
|
|
12
|
+
}).format(price);
|
|
13
|
+
}
|
|
14
|
+
/** Cheapest paid tier scaled to 1,000 units, `null` when every tier is free. */
|
|
15
|
+
function cheapestPaidPricePerThousand(tiers) {
|
|
16
|
+
const paidPrices = tiers.filter(({ tier, price }) => tier !== "FREE" && price > 0).map(({ price }) => price);
|
|
17
|
+
if (paidPrices.length === 0) return null;
|
|
18
|
+
return Math.min(...paidPrices) * PRICE_DISPLAY_UNIT_SIZE;
|
|
19
|
+
}
|
|
20
|
+
function formatFlatPricePerMonth(pricePerUnit) {
|
|
21
|
+
return `${formatPriceUsd(pricePerUnit ?? 0)}/month + usage`;
|
|
22
|
+
}
|
|
23
|
+
function formatPayPerEventPricing(event) {
|
|
24
|
+
const title = event.title.toLowerCase() || "result";
|
|
25
|
+
const perThousand = `1,000 ${pluralize(title, PRICE_DISPLAY_UNIT_SIZE)}`;
|
|
26
|
+
const tieredPerThousand = cheapestPaidPricePerThousand((event.tieredPricing ?? []).map(({ tier, priceUsd }) => ({
|
|
27
|
+
tier,
|
|
28
|
+
price: priceUsd
|
|
29
|
+
})));
|
|
30
|
+
if (tieredPerThousand !== null) return `from ${formatPriceUsd(tieredPerThousand)} / ${perThousand}`;
|
|
31
|
+
if (typeof event.priceUsd === "number") {
|
|
32
|
+
if (event.priceUsd < PER_THOUSAND_PRICING_THRESHOLD) return `${formatPriceUsd(event.priceUsd * PRICE_DISPLAY_UNIT_SIZE)} / ${perThousand}`;
|
|
33
|
+
return `${formatPriceUsd(event.priceUsd)} / ${title}`;
|
|
34
|
+
}
|
|
35
|
+
return "Pay per event";
|
|
36
|
+
}
|
|
37
|
+
function formatPricePerDatasetItem(pricing) {
|
|
38
|
+
const perThousand = `1,000 ${pluralize(pricing.unitName || "result")}`;
|
|
39
|
+
return `from ${formatPriceUsd(cheapestPaidPricePerThousand((pricing.tieredPricing ?? []).map(({ tier, pricePerUnit }) => ({
|
|
40
|
+
tier,
|
|
41
|
+
price: pricePerUnit
|
|
42
|
+
}))) ?? (pricing.pricePerUnit ?? 0) * PRICE_DISPLAY_UNIT_SIZE)} / ${perThousand}`;
|
|
43
|
+
}
|
|
44
|
+
function formatPricing(pricing) {
|
|
45
|
+
if (pricing.model === "FLAT_PRICE_PER_MONTH") return formatFlatPricePerMonth(pricing.pricePerUnit);
|
|
46
|
+
if (pricing.model === "PAY_PER_EVENT") {
|
|
47
|
+
if (pricing.events?.length === 1) return formatPayPerEventPricing(pricing.events[0]);
|
|
48
|
+
return "Pay per event";
|
|
49
|
+
}
|
|
50
|
+
if (pricing.model === "PRICE_PER_DATASET_ITEM") return formatPricePerDatasetItem(pricing);
|
|
51
|
+
return "Pay per usage";
|
|
52
|
+
}
|
|
53
|
+
function formatNumber(value) {
|
|
54
|
+
if (value >= 1e6) return `${(value / 1e6).toFixed(1)}M`;
|
|
55
|
+
if (value >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
|
|
56
|
+
return value.toString();
|
|
57
|
+
}
|
|
58
|
+
function formatDecimalNumber(value) {
|
|
59
|
+
return Number.isInteger(value) ? value.toString() : value.toFixed(1);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { formatDecimalNumber, formatNumber, formatPricing };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/mcp-widgets",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "React components that render the output of Apify MCP tools",
|
|
3
|
+
"version": "0.1.1-featmcpwidgetssearchcomponen-5114c0.4+95308c53d47",
|
|
4
|
+
"description": "React components that render the output of Apify MCP tools (Actor search, Actor details)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apify",
|
|
7
7
|
"mcp",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"default": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
+
"./test-ids": {
|
|
22
|
+
"types": "./dist/test_ids.d.ts",
|
|
23
|
+
"default": "./dist/test_ids.js"
|
|
24
|
+
},
|
|
21
25
|
"./package.json": "./package.json"
|
|
22
26
|
},
|
|
23
27
|
"files": [
|
|
@@ -43,7 +47,8 @@
|
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
45
49
|
"@apify/ui-icons": "^1.50.0",
|
|
46
|
-
"@apify/ui-library": "^1.165.7"
|
|
50
|
+
"@apify/ui-library": "^1.165.7",
|
|
51
|
+
"pluralize": "^8.0.0"
|
|
47
52
|
},
|
|
48
53
|
"peerDependencies": {
|
|
49
54
|
"react": "17.x || 18.x || 19.x",
|
|
@@ -51,6 +56,8 @@
|
|
|
51
56
|
"styled-components": "^6.1.19"
|
|
52
57
|
},
|
|
53
58
|
"devDependencies": {
|
|
59
|
+
"@storybook/react-vite": "^10.3.5",
|
|
60
|
+
"@types/pluralize": "0.0.33",
|
|
54
61
|
"@types/react": "19.2.2",
|
|
55
62
|
"@types/react-dom": "19.2.2",
|
|
56
63
|
"@vitejs/plugin-react-swc": "^4.3.1",
|
|
@@ -60,5 +67,5 @@
|
|
|
60
67
|
"vite": "^8.0.14",
|
|
61
68
|
"vite-plugin-dts": "^5.0.1"
|
|
62
69
|
},
|
|
63
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "95308c53d4704fe965fa660fe731e4919e16b14b"
|
|
64
71
|
}
|