@apify/ui-library 1.138.1 → 1.138.2-featpublictasks-2f3d3c.52
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/src/components/actor_example/actor_example.utils.d.ts +17 -0
- package/dist/src/components/actor_example/actor_example.utils.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example.utils.js +41 -0
- package/dist/src/components/actor_example/actor_example.utils.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_avatar.d.ts +13 -0
- package/dist/src/components/actor_example/actor_example_avatar.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_avatar.js +34 -0
- package/dist/src/components/actor_example/actor_example_avatar.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_card.d.ts +28 -0
- package/dist/src/components/actor_example/actor_example_card.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_card.js +79 -0
- package/dist/src/components/actor_example/actor_example_card.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_preview.d.ts +28 -0
- package/dist/src/components/actor_example/actor_example_preview.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_preview.js +208 -0
- package/dist/src/components/actor_example/actor_example_preview.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_run_button.d.ts +33 -0
- package/dist/src/components/actor_example/actor_example_run_button.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_run_button.js +12 -0
- package/dist/src/components/actor_example/actor_example_run_button.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema.d.ts +20 -0
- package/dist/src/components/actor_example/actor_example_schema.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema.js +27 -0
- package/dist/src/components/actor_example/actor_example_schema.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_field.d.ts +19 -0
- package/dist/src/components/actor_example/actor_example_schema_field.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_field.js +33 -0
- package/dist/src/components/actor_example/actor_example_schema_field.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_field_badge.d.ts +9 -0
- package/dist/src/components/actor_example/actor_example_schema_field_badge.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_field_badge.js +48 -0
- package/dist/src/components/actor_example/actor_example_schema_field_badge.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_legend.d.ts +10 -0
- package/dist/src/components/actor_example/actor_example_schema_legend.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_legend.js +29 -0
- package/dist/src/components/actor_example/actor_example_schema_legend.js.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_property.d.ts +24 -0
- package/dist/src/components/actor_example/actor_example_schema_property.d.ts.map +1 -0
- package/dist/src/components/actor_example/actor_example_schema_property.js +122 -0
- package/dist/src/components/actor_example/actor_example_schema_property.js.map +1 -0
- package/dist/src/components/actor_example/index.d.ts +11 -0
- package/dist/src/components/actor_example/index.d.ts.map +1 -0
- package/dist/src/components/actor_example/index.js +11 -0
- package/dist/src/components/actor_example/index.js.map +1 -0
- package/dist/src/components/browser_window/browser_window.d.ts +20 -0
- package/dist/src/components/browser_window/browser_window.d.ts.map +1 -0
- package/dist/src/components/browser_window/browser_window.js +72 -0
- package/dist/src/components/browser_window/browser_window.js.map +1 -0
- package/dist/src/components/browser_window/index.d.ts +2 -0
- package/dist/src/components/browser_window/index.d.ts.map +1 -0
- package/dist/src/components/browser_window/index.js +2 -0
- package/dist/src/components/browser_window/index.js.map +1 -0
- package/dist/src/components/chip.d.ts.map +1 -1
- package/dist/src/components/chip.js +25 -2
- package/dist/src/components/chip.js.map +1 -1
- package/dist/src/components/collapsible_card/collapsible_card.d.ts +3 -2
- package/dist/src/components/collapsible_card/collapsible_card.d.ts.map +1 -1
- package/dist/src/components/collapsible_card/collapsible_card.js +2 -2
- package/dist/src/components/collapsible_card/collapsible_card.js.map +1 -1
- package/dist/src/components/floating/floating_component_base.d.ts +72 -1
- package/dist/src/components/floating/floating_component_base.d.ts.map +1 -1
- package/dist/src/components/floating/floating_component_base.js +66 -36
- package/dist/src/components/floating/floating_component_base.js.map +1 -1
- package/dist/src/components/floating/tooltip.d.ts +10 -3
- package/dist/src/components/floating/tooltip.d.ts.map +1 -1
- package/dist/src/components/floating/tooltip.js +24 -20
- package/dist/src/components/floating/tooltip.js.map +1 -1
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/actor_example/actor_example.utils.ts +52 -0
- package/src/components/actor_example/actor_example_avatar.tsx +69 -0
- package/src/components/actor_example/actor_example_card.tsx +149 -0
- package/src/components/actor_example/actor_example_preview.tsx +295 -0
- package/src/components/actor_example/actor_example_run_button.tsx +61 -0
- package/src/components/actor_example/actor_example_schema.tsx +60 -0
- package/src/components/actor_example/actor_example_schema_field.tsx +87 -0
- package/src/components/actor_example/actor_example_schema_field_badge.tsx +66 -0
- package/src/components/actor_example/actor_example_schema_legend.tsx +49 -0
- package/src/components/actor_example/actor_example_schema_property.tsx +242 -0
- package/src/components/actor_example/index.ts +10 -0
- package/src/components/browser_window/browser_window.tsx +106 -0
- package/src/components/browser_window/index.ts +1 -0
- package/src/components/chip.tsx +27 -1
- package/src/components/collapsible_card/collapsible_card.tsx +6 -4
- package/src/components/floating/floating_component_base.tsx +89 -47
- package/src/components/floating/tooltip.tsx +53 -25
- package/src/components/index.ts +2 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import type { ActorExampleSchemaFieldSerialized } from '@apify-packages/types';
|
|
6
|
+
|
|
7
|
+
import { theme } from '../../design_system/theme.js';
|
|
8
|
+
import { ActorExampleSchemaField } from './actor_example_schema_field.js';
|
|
9
|
+
|
|
10
|
+
export const actorExampleSchemaClassNames = {
|
|
11
|
+
ROOT: 'actor-example-schema',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const ActorExampleSchemaWrapper = styled.div`
|
|
15
|
+
width: 100%;
|
|
16
|
+
padding: ${theme.space.space16};
|
|
17
|
+
background-color: ${theme.color.neutral.background};
|
|
18
|
+
border-radius: 1rem;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
flex-grow: 1;
|
|
22
|
+
gap: ${theme.space.space16};
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
type Props = {
|
|
26
|
+
fields: ActorExampleSchemaFieldSerialized[];
|
|
27
|
+
canCollapse?: boolean;
|
|
28
|
+
className?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Per-row slot rendered before the type badge on each top-level field
|
|
31
|
+
* (nested children render plain). Useful for configurators that need a
|
|
32
|
+
* checkbox or other control alongside each field.
|
|
33
|
+
*/
|
|
34
|
+
LeadingSlot?: (props: { field: ActorExampleSchemaFieldSerialized }) => React.ReactNode;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const ActorExampleSchema = ({ fields, canCollapse = false, className, LeadingSlot }: Props) => {
|
|
38
|
+
const [collapsedFields, setCollapsedFields] = useState<string[]>([]);
|
|
39
|
+
|
|
40
|
+
const handleToggleCollapse = (id: string) => {
|
|
41
|
+
setCollapsedFields((current) =>
|
|
42
|
+
current.includes(id) ? current.filter((currentId) => currentId !== id) : [...current, id],
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<ActorExampleSchemaWrapper className={clsx(actorExampleSchemaClassNames.ROOT, className)}>
|
|
48
|
+
{fields.map((field) => (
|
|
49
|
+
<ActorExampleSchemaField
|
|
50
|
+
key={field._id}
|
|
51
|
+
field={field}
|
|
52
|
+
canCollapse={canCollapse}
|
|
53
|
+
collapsedFields={collapsedFields}
|
|
54
|
+
onToggleCollapsed={handleToggleCollapse}
|
|
55
|
+
leadingSlot={LeadingSlot ? <LeadingSlot field={field} /> : undefined}
|
|
56
|
+
/>
|
|
57
|
+
))}
|
|
58
|
+
</ActorExampleSchemaWrapper>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import type { ActorExampleSchemaFieldSerialized } from '@apify-packages/types';
|
|
6
|
+
|
|
7
|
+
import { theme } from '../../design_system/theme.js';
|
|
8
|
+
import { ActorExampleSchemaProperty } from './actor_example_schema_property.js';
|
|
9
|
+
|
|
10
|
+
export const actorExampleSchemaFieldClassNames = {
|
|
11
|
+
FIELD: 'actor-example-schema-field',
|
|
12
|
+
CHILDREN: 'actor-example-schema-field__children',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const ActorExampleSchemaFieldWrapper = styled.div<{ $canCollapse: boolean }>`
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: ${theme.space.space8};
|
|
19
|
+
|
|
20
|
+
.${actorExampleSchemaFieldClassNames.CHILDREN} {
|
|
21
|
+
margin-left: ${({ $canCollapse }) => ($canCollapse ? '5.6rem' : '2.8rem')};
|
|
22
|
+
padding-left: 0.8rem;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: ${theme.space.space8};
|
|
26
|
+
border-left: 1px solid ${theme.color.neutral.border};
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const MAX_SCHEMA_FIELD_DEPTH = 1;
|
|
31
|
+
|
|
32
|
+
type Props = {
|
|
33
|
+
field: ActorExampleSchemaFieldSerialized;
|
|
34
|
+
collapsedFields: string[];
|
|
35
|
+
canCollapse?: boolean;
|
|
36
|
+
onToggleCollapsed: (id: string) => void;
|
|
37
|
+
depth?: number;
|
|
38
|
+
className?: string;
|
|
39
|
+
/** Slot rendered on the outer property only — nested children render plain. */
|
|
40
|
+
leadingSlot?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const ActorExampleSchemaField = ({
|
|
44
|
+
field,
|
|
45
|
+
collapsedFields,
|
|
46
|
+
canCollapse = false,
|
|
47
|
+
onToggleCollapsed,
|
|
48
|
+
depth = 0,
|
|
49
|
+
className,
|
|
50
|
+
leadingSlot,
|
|
51
|
+
}: Props) => {
|
|
52
|
+
const subfields = field.properties ?? field.items ?? [];
|
|
53
|
+
const isCollapsed = collapsedFields.includes(field._id);
|
|
54
|
+
|
|
55
|
+
if (subfields.length === 0 || depth >= MAX_SCHEMA_FIELD_DEPTH) {
|
|
56
|
+
return <ActorExampleSchemaProperty {...field} className={className} leadingSlot={leadingSlot} />;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<ActorExampleSchemaFieldWrapper
|
|
61
|
+
$canCollapse={canCollapse}
|
|
62
|
+
className={clsx(actorExampleSchemaFieldClassNames.FIELD, className)}
|
|
63
|
+
>
|
|
64
|
+
<ActorExampleSchemaProperty
|
|
65
|
+
{...field}
|
|
66
|
+
isCollapsable={canCollapse}
|
|
67
|
+
isCollapsed={isCollapsed}
|
|
68
|
+
onToggleCollapsed={onToggleCollapsed}
|
|
69
|
+
leadingSlot={leadingSlot}
|
|
70
|
+
/>
|
|
71
|
+
{!isCollapsed && (
|
|
72
|
+
<div className={actorExampleSchemaFieldClassNames.CHILDREN}>
|
|
73
|
+
{subfields.map((subfield) => (
|
|
74
|
+
<ActorExampleSchemaField
|
|
75
|
+
key={subfield._id}
|
|
76
|
+
field={subfield}
|
|
77
|
+
collapsedFields={collapsedFields}
|
|
78
|
+
canCollapse={canCollapse}
|
|
79
|
+
onToggleCollapsed={onToggleCollapsed}
|
|
80
|
+
depth={depth + 1}
|
|
81
|
+
/>
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
</ActorExampleSchemaFieldWrapper>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import type { IconComponent } from '@apify/ui-icons';
|
|
4
|
+
|
|
5
|
+
import type { ActorExampleSchemaFieldType } from '@apify-packages/types';
|
|
6
|
+
|
|
7
|
+
import { theme } from '../../design_system/theme.js';
|
|
8
|
+
import { actorExampleSchemaPropertyDefaultIcon, actorExampleSchemaPropertyMap } from './actor_example.utils.js';
|
|
9
|
+
|
|
10
|
+
// Per-type colour variables consumed via `var(--actor-schema-field-*)` in `actor_example.utils.ts`.
|
|
11
|
+
// Declared on this wrapper itself (rather than `:root`) so the badge is self-contained — no
|
|
12
|
+
// host-app globals required. Dark-mode overrides hook into the existing `html[data-theme='dark']`
|
|
13
|
+
// theming switch via a parent-selector cascade.
|
|
14
|
+
const ActorExampleSchemaFieldBadgeWrapper = styled.div<{ $type?: ActorExampleSchemaFieldType }>`
|
|
15
|
+
--actor-schema-field-string-text: #018181;
|
|
16
|
+
--actor-schema-field-string-background: #ebfbf8;
|
|
17
|
+
--actor-schema-field-number-text: #8c4e02;
|
|
18
|
+
--actor-schema-field-number-background: #f9f0db;
|
|
19
|
+
--actor-schema-field-boolean-text: #104b37;
|
|
20
|
+
--actor-schema-field-boolean-background: #dffff0;
|
|
21
|
+
--actor-schema-field-object-text: #4c41c0;
|
|
22
|
+
--actor-schema-field-object-background: #e8e6f9;
|
|
23
|
+
--actor-schema-field-array-text: #0043ca;
|
|
24
|
+
--actor-schema-field-array-background: #e0ebff;
|
|
25
|
+
|
|
26
|
+
html[data-theme='dark'] & {
|
|
27
|
+
--actor-schema-field-string-text: #84f5e5;
|
|
28
|
+
--actor-schema-field-string-background: #0f2e2a;
|
|
29
|
+
--actor-schema-field-number-text: #ffd761;
|
|
30
|
+
--actor-schema-field-number-background: #5d2e0e;
|
|
31
|
+
--actor-schema-field-boolean-text: #a3e8cf;
|
|
32
|
+
--actor-schema-field-boolean-background: #0b3225;
|
|
33
|
+
--actor-schema-field-object-text: #a08cf2;
|
|
34
|
+
--actor-schema-field-object-background: #2a2544;
|
|
35
|
+
--actor-schema-field-array-text: #97bcff;
|
|
36
|
+
--actor-schema-field-array-background: #152447;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
width: 2rem;
|
|
40
|
+
height: 2rem;
|
|
41
|
+
color: ${({ $type }) => ($type ? actorExampleSchemaPropertyMap[$type].textColor : theme.color.neutral.text)};
|
|
42
|
+
background-color: ${({ $type }) =>
|
|
43
|
+
$type ? actorExampleSchemaPropertyMap[$type].backgroundColor : theme.color.neutral.backgroundSubtle};
|
|
44
|
+
border-radius: ${theme.radius.radius4};
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
type Props = {
|
|
52
|
+
type?: ActorExampleSchemaFieldType;
|
|
53
|
+
title: string;
|
|
54
|
+
className?: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const ActorExampleSchemaFieldBadge = ({ type, title, className }: Props) => {
|
|
58
|
+
const Icon: IconComponent =
|
|
59
|
+
(type ? actorExampleSchemaPropertyMap[type]?.Icon : undefined) ?? actorExampleSchemaPropertyDefaultIcon;
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ActorExampleSchemaFieldBadgeWrapper $type={type} className={className}>
|
|
63
|
+
<Icon size="12" title={title} />
|
|
64
|
+
</ActorExampleSchemaFieldBadgeWrapper>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { ActorExampleSchemaFieldType } from '@apify-packages/types';
|
|
5
|
+
|
|
6
|
+
import { theme } from '../../design_system/theme.js';
|
|
7
|
+
import { Text } from '../text/index.js';
|
|
8
|
+
import { actorExampleSchemaPropertyMap } from './actor_example.utils.js';
|
|
9
|
+
import { ActorExampleSchemaFieldBadge } from './actor_example_schema_field_badge.js';
|
|
10
|
+
|
|
11
|
+
const LEGEND_TYPE_ORDER: ActorExampleSchemaFieldType[] = ['string', 'number', 'boolean', 'array', 'object'];
|
|
12
|
+
|
|
13
|
+
export const actorExampleSchemaLegendClassNames = {
|
|
14
|
+
ROOT: 'actor-example-schema-legend',
|
|
15
|
+
ITEM: 'actor-example-schema-legend__item',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ActorExampleSchemaLegendWrapper = styled.div`
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: ${theme.space.space12};
|
|
23
|
+
|
|
24
|
+
.${actorExampleSchemaLegendClassNames.ITEM} {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: ${theme.space.space4};
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
type Props = {
|
|
32
|
+
className?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const ActorExampleSchemaLegend = ({ className }: Props) => (
|
|
36
|
+
<ActorExampleSchemaLegendWrapper className={clsx(actorExampleSchemaLegendClassNames.ROOT, className)}>
|
|
37
|
+
{LEGEND_TYPE_ORDER.map((type) => {
|
|
38
|
+
const config = actorExampleSchemaPropertyMap[type];
|
|
39
|
+
return (
|
|
40
|
+
<span key={type} className={actorExampleSchemaLegendClassNames.ITEM}>
|
|
41
|
+
<ActorExampleSchemaFieldBadge type={type} title={config.title} />
|
|
42
|
+
<Text as="span" size="small" weight="medium">
|
|
43
|
+
{config.title}
|
|
44
|
+
</Text>
|
|
45
|
+
</span>
|
|
46
|
+
);
|
|
47
|
+
})}
|
|
48
|
+
</ActorExampleSchemaLegendWrapper>
|
|
49
|
+
);
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { ChevronDownIcon, QuestionMarkIcon } from '@apify/ui-icons';
|
|
6
|
+
|
|
7
|
+
import type { ActorExampleSchemaFieldSerialized, ActorExampleSchemaFieldType } from '@apify-packages/types';
|
|
8
|
+
|
|
9
|
+
import { theme } from '../../design_system/theme.js';
|
|
10
|
+
import { Tooltip } from '../floating/tooltip.js';
|
|
11
|
+
import { Text } from '../text/index.js';
|
|
12
|
+
import { actorExampleSchemaPropertyMap } from './actor_example.utils.js';
|
|
13
|
+
import { ActorExampleSchemaFieldBadge } from './actor_example_schema_field_badge.js';
|
|
14
|
+
|
|
15
|
+
type NormalizedPropertyValue = {
|
|
16
|
+
value: string;
|
|
17
|
+
remainingValues: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const normalizePropertyValue = (
|
|
21
|
+
type: ActorExampleSchemaFieldType | undefined,
|
|
22
|
+
value: unknown,
|
|
23
|
+
): NormalizedPropertyValue | undefined => {
|
|
24
|
+
if (type === 'object' || value == null) return undefined;
|
|
25
|
+
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
const first = value[0];
|
|
28
|
+
if (first == null || typeof first === 'object') return undefined;
|
|
29
|
+
const normalizedFirst = String(first).trim();
|
|
30
|
+
if (normalizedFirst.length === 0) return undefined;
|
|
31
|
+
return { value: normalizedFirst, remainingValues: value.length - 1 };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const normalizedValue = String(value).trim();
|
|
35
|
+
if (normalizedValue.length === 0) return undefined;
|
|
36
|
+
return { value: normalizedValue, remainingValues: 0 };
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const actorExampleSchemaPropertyClassNames = {
|
|
40
|
+
ROOT: 'actor-example-schema-property',
|
|
41
|
+
LEADING: 'actor-example-schema-property__leading',
|
|
42
|
+
TYPE: 'actor-example-schema-property__type',
|
|
43
|
+
NAME: 'actor-example-schema-property__name',
|
|
44
|
+
DELIMITER: 'actor-example-schema-property__delimiter',
|
|
45
|
+
VALUE: 'actor-example-schema-property__value',
|
|
46
|
+
TOGGLE: 'actor-example-schema-property__toggle',
|
|
47
|
+
PRESERVED: 'actor-example-schema-property__preserved',
|
|
48
|
+
INFO: 'actor-example-schema-property__info',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const ActorExampleSchemaPropertyWrapper = styled.div<{ $type?: ActorExampleSchemaFieldType; $isCollapsed: boolean }>`
|
|
52
|
+
width: 100%;
|
|
53
|
+
min-width: 0;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
gap: ${theme.space.space4};
|
|
57
|
+
|
|
58
|
+
.${actorExampleSchemaPropertyClassNames.LEADING} {
|
|
59
|
+
flex-shrink: 0;
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.${actorExampleSchemaPropertyClassNames.TOGGLE} {
|
|
65
|
+
all: unset;
|
|
66
|
+
width: 2rem;
|
|
67
|
+
height: 2rem;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
transition: transform 0.2s ease-in-out;
|
|
73
|
+
|
|
74
|
+
${({ $isCollapsed }) =>
|
|
75
|
+
$isCollapsed &&
|
|
76
|
+
css`
|
|
77
|
+
transform: rotate(-90deg);
|
|
78
|
+
`}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.${actorExampleSchemaPropertyClassNames.TYPE} {
|
|
82
|
+
margin-right: ${theme.space.space4};
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.${actorExampleSchemaPropertyClassNames.NAME} {
|
|
87
|
+
min-width: 1ch;
|
|
88
|
+
${({ $type }) =>
|
|
89
|
+
($type === 'object' || $type === 'array') &&
|
|
90
|
+
css`
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
`}
|
|
93
|
+
text-overflow: ellipsis;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.${actorExampleSchemaPropertyClassNames.DELIMITER} {
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
flex-shrink: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.${actorExampleSchemaPropertyClassNames.VALUE} {
|
|
104
|
+
min-width: 0;
|
|
105
|
+
margin-left: ${theme.space.space4};
|
|
106
|
+
padding: 1px ${theme.space.space6};
|
|
107
|
+
border: 1px solid ${theme.color.neutral.border};
|
|
108
|
+
border-radius: ${theme.radius.radius4};
|
|
109
|
+
text-overflow: ellipsis;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.${actorExampleSchemaPropertyClassNames.PRESERVED} {
|
|
115
|
+
margin-left: 0;
|
|
116
|
+
flex-shrink: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.${actorExampleSchemaPropertyClassNames.INFO} {
|
|
120
|
+
flex-shrink: 0;
|
|
121
|
+
color: ${theme.color.neutral.textSubtle};
|
|
122
|
+
display: inline-flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
const MIN_PROPERTY_NAME_LENGTH_PRESERVATION = 3;
|
|
128
|
+
|
|
129
|
+
type Props = ActorExampleSchemaFieldSerialized & {
|
|
130
|
+
className?: string;
|
|
131
|
+
isCollapsable?: boolean;
|
|
132
|
+
isCollapsed?: boolean;
|
|
133
|
+
onToggleCollapsed?: (id: string) => void;
|
|
134
|
+
/** Optional slot rendered before the type badge (e.g. a checkbox in a configurator). */
|
|
135
|
+
leadingSlot?: ReactNode;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const ActorExampleSchemaProperty = ({
|
|
139
|
+
type,
|
|
140
|
+
_id,
|
|
141
|
+
name,
|
|
142
|
+
title,
|
|
143
|
+
description,
|
|
144
|
+
value,
|
|
145
|
+
required = false,
|
|
146
|
+
isCollapsable = false,
|
|
147
|
+
isCollapsed = false,
|
|
148
|
+
onToggleCollapsed,
|
|
149
|
+
leadingSlot,
|
|
150
|
+
className,
|
|
151
|
+
}: Props) => {
|
|
152
|
+
const tooltip = type ? actorExampleSchemaPropertyMap[type]?.title : undefined;
|
|
153
|
+
|
|
154
|
+
const normalizedName = title ?? name;
|
|
155
|
+
const normalizedValue = normalizePropertyValue(type, value);
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<ActorExampleSchemaPropertyWrapper
|
|
159
|
+
$type={type}
|
|
160
|
+
$isCollapsed={isCollapsed}
|
|
161
|
+
className={clsx(actorExampleSchemaPropertyClassNames.ROOT, className)}
|
|
162
|
+
>
|
|
163
|
+
{leadingSlot && <span className={actorExampleSchemaPropertyClassNames.LEADING}>{leadingSlot}</span>}
|
|
164
|
+
{isCollapsable && (
|
|
165
|
+
<button
|
|
166
|
+
type="button"
|
|
167
|
+
className={actorExampleSchemaPropertyClassNames.TOGGLE}
|
|
168
|
+
onClick={() => onToggleCollapsed?.(_id)}
|
|
169
|
+
>
|
|
170
|
+
<ChevronDownIcon size="16" />
|
|
171
|
+
</button>
|
|
172
|
+
)}
|
|
173
|
+
<Tooltip content={tooltip} className={actorExampleSchemaPropertyClassNames.TYPE}>
|
|
174
|
+
<ActorExampleSchemaFieldBadge
|
|
175
|
+
type={type}
|
|
176
|
+
title={normalizedName}
|
|
177
|
+
className={tooltip == null ? actorExampleSchemaPropertyClassNames.TYPE : undefined}
|
|
178
|
+
/>
|
|
179
|
+
</Tooltip>
|
|
180
|
+
<Text
|
|
181
|
+
as="span"
|
|
182
|
+
weight="medium"
|
|
183
|
+
className={clsx(actorExampleSchemaPropertyClassNames.NAME, {
|
|
184
|
+
[actorExampleSchemaPropertyClassNames.PRESERVED]:
|
|
185
|
+
normalizedName.length <= MIN_PROPERTY_NAME_LENGTH_PRESERVATION,
|
|
186
|
+
})}
|
|
187
|
+
>
|
|
188
|
+
{normalizedName}
|
|
189
|
+
</Text>
|
|
190
|
+
|
|
191
|
+
{required && (
|
|
192
|
+
<Text
|
|
193
|
+
as="span"
|
|
194
|
+
size="small"
|
|
195
|
+
weight="medium"
|
|
196
|
+
color={theme.color.neutral.textSubtle}
|
|
197
|
+
className={actorExampleSchemaPropertyClassNames.PRESERVED}
|
|
198
|
+
>
|
|
199
|
+
(required)
|
|
200
|
+
</Text>
|
|
201
|
+
)}
|
|
202
|
+
|
|
203
|
+
{description && (
|
|
204
|
+
<Tooltip content={description} className={actorExampleSchemaPropertyClassNames.INFO}>
|
|
205
|
+
<QuestionMarkIcon size="16" />
|
|
206
|
+
</Tooltip>
|
|
207
|
+
)}
|
|
208
|
+
|
|
209
|
+
{normalizedValue && (
|
|
210
|
+
<>
|
|
211
|
+
<Text as="span" weight="medium" className={actorExampleSchemaPropertyClassNames.DELIMITER}>
|
|
212
|
+
:
|
|
213
|
+
</Text>
|
|
214
|
+
<Text
|
|
215
|
+
as="span"
|
|
216
|
+
size="small"
|
|
217
|
+
weight="medium"
|
|
218
|
+
className={clsx(actorExampleSchemaPropertyClassNames.VALUE, {
|
|
219
|
+
[actorExampleSchemaPropertyClassNames.PRESERVED]:
|
|
220
|
+
normalizedValue.value.length <= MIN_PROPERTY_NAME_LENGTH_PRESERVATION,
|
|
221
|
+
})}
|
|
222
|
+
>
|
|
223
|
+
{normalizedValue.value}
|
|
224
|
+
</Text>
|
|
225
|
+
{normalizedValue.remainingValues > 0 && (
|
|
226
|
+
<Text
|
|
227
|
+
as="span"
|
|
228
|
+
size="small"
|
|
229
|
+
weight="medium"
|
|
230
|
+
className={clsx(
|
|
231
|
+
actorExampleSchemaPropertyClassNames.VALUE,
|
|
232
|
+
actorExampleSchemaPropertyClassNames.PRESERVED,
|
|
233
|
+
)}
|
|
234
|
+
>
|
|
235
|
+
+{normalizedValue.remainingValues}
|
|
236
|
+
</Text>
|
|
237
|
+
)}
|
|
238
|
+
</>
|
|
239
|
+
)}
|
|
240
|
+
</ActorExampleSchemaPropertyWrapper>
|
|
241
|
+
);
|
|
242
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './actor_example_avatar.js';
|
|
2
|
+
export * from './actor_example_card.js';
|
|
3
|
+
export * from './actor_example_preview.js';
|
|
4
|
+
export * from './actor_example_run_button.js';
|
|
5
|
+
export * from './actor_example_schema.js';
|
|
6
|
+
export * from './actor_example_schema_field.js';
|
|
7
|
+
export * from './actor_example_schema_field_badge.js';
|
|
8
|
+
export * from './actor_example_schema_legend.js';
|
|
9
|
+
export * from './actor_example_schema_property.js';
|
|
10
|
+
export * from './actor_example.utils.js';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { theme } from '../../design_system/theme.js';
|
|
6
|
+
import { Badge } from '../badge.js';
|
|
7
|
+
|
|
8
|
+
const classNames = {
|
|
9
|
+
ROOT: 'browser-window',
|
|
10
|
+
HEADER: 'browser-window__header',
|
|
11
|
+
DOTS: 'browser-window__dots',
|
|
12
|
+
DOT: 'browser-window__dot',
|
|
13
|
+
URL: 'browser-window__url',
|
|
14
|
+
TITLE: 'browser-window__title',
|
|
15
|
+
CONTAINER: 'browser-window__container',
|
|
16
|
+
CONTENT: 'browser-window__content',
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
export { classNames as browserWindowClassNames };
|
|
20
|
+
|
|
21
|
+
const BrowserWindowWrapper = styled.div`
|
|
22
|
+
border: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
23
|
+
border-radius: ${theme.radius.radius12};
|
|
24
|
+
background-color: ${theme.color.neutral.background};
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
|
|
27
|
+
.${classNames.HEADER} {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: ${theme.space.space8};
|
|
31
|
+
padding: ${theme.space.space6} ${theme.space.space8};
|
|
32
|
+
border-bottom: 1px solid ${theme.color.neutral.separatorSubtle};
|
|
33
|
+
background-color: ${theme.color.neutral.backgroundMuted};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.${classNames.DOTS} {
|
|
37
|
+
display: flex;
|
|
38
|
+
gap: 0.3rem;
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.${classNames.DOT} {
|
|
43
|
+
width: 0.6rem;
|
|
44
|
+
height: 0.6rem;
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
background-color: ${theme.color.neutral.separatorSubtle};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.${classNames.URL} {
|
|
50
|
+
width: 100%;
|
|
51
|
+
min-width: 0;
|
|
52
|
+
justify-content: flex-start;
|
|
53
|
+
color: ${theme.color.neutral.textSubtle};
|
|
54
|
+
|
|
55
|
+
span {
|
|
56
|
+
min-width: 0;
|
|
57
|
+
text-overflow: ellipsis;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.${classNames.TITLE} {
|
|
64
|
+
margin-left: auto;
|
|
65
|
+
flex-shrink: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.${classNames.CONTAINER} {
|
|
69
|
+
min-width: 0;
|
|
70
|
+
overflow-x: auto;
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
type Props = {
|
|
75
|
+
title: string;
|
|
76
|
+
url?: ReactNode;
|
|
77
|
+
children: ReactNode;
|
|
78
|
+
className?: string;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const BrowserWindow = ({ title, url, children, className }: Props) => {
|
|
82
|
+
return (
|
|
83
|
+
<BrowserWindowWrapper className={clsx(classNames.ROOT, className)}>
|
|
84
|
+
<div className={classNames.HEADER}>
|
|
85
|
+
{url && (
|
|
86
|
+
<>
|
|
87
|
+
<div className={classNames.DOTS}>
|
|
88
|
+
<span className={classNames.DOT} />
|
|
89
|
+
<span className={classNames.DOT} />
|
|
90
|
+
<span className={classNames.DOT} />
|
|
91
|
+
</div>
|
|
92
|
+
<Badge size="extra_small" variant="neutral_subtle" className={classNames.URL}>
|
|
93
|
+
{url}
|
|
94
|
+
</Badge>
|
|
95
|
+
</>
|
|
96
|
+
)}
|
|
97
|
+
<Badge size="extra_small" className={classNames.TITLE}>
|
|
98
|
+
{title}
|
|
99
|
+
</Badge>
|
|
100
|
+
</div>
|
|
101
|
+
<div className={classNames.CONTAINER}>
|
|
102
|
+
<div className={classNames.CONTENT}>{children}</div>
|
|
103
|
+
</div>
|
|
104
|
+
</BrowserWindowWrapper>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './browser_window.js';
|
package/src/components/chip.tsx
CHANGED
|
@@ -80,9 +80,34 @@ const chipTypeStyle = {
|
|
|
80
80
|
`,
|
|
81
81
|
} satisfies Record<CHIP_TYPES, unknown>;
|
|
82
82
|
|
|
83
|
+
const chipTypeHoverStyle = {
|
|
84
|
+
[CHIP_TYPES.DEFAULT]: css`
|
|
85
|
+
background: ${theme.color.neutral.chipBackgroundHover};
|
|
86
|
+
`,
|
|
87
|
+
[CHIP_TYPES.PRIMARY]: css`
|
|
88
|
+
background: ${theme.color.primary.chipBackgroundHover};
|
|
89
|
+
`,
|
|
90
|
+
[CHIP_TYPES.SUCCESS]: css`
|
|
91
|
+
background: ${theme.color.success.chipBackgroundHover};
|
|
92
|
+
`,
|
|
93
|
+
[CHIP_TYPES.WARNING]: css`
|
|
94
|
+
background: ${theme.color.warning.chipBackgroundHover};
|
|
95
|
+
`,
|
|
96
|
+
[CHIP_TYPES.DANGER]: css`
|
|
97
|
+
background: ${theme.color.danger.chipBackgroundHover};
|
|
98
|
+
`,
|
|
99
|
+
} satisfies Record<CHIP_TYPES, unknown>;
|
|
100
|
+
|
|
83
101
|
const StyledChip = styled.span<{ size: CHIP_SIZES; type: CHIP_TYPES; clickable: boolean }>`
|
|
84
102
|
${({ size }) => chipSizeStyle[size]};
|
|
85
103
|
${({ type }) => chipTypeStyle[type]};
|
|
104
|
+
${({ type, clickable }) =>
|
|
105
|
+
clickable &&
|
|
106
|
+
css`
|
|
107
|
+
&:hover {
|
|
108
|
+
${chipTypeHoverStyle[type]};
|
|
109
|
+
}
|
|
110
|
+
`};
|
|
86
111
|
/* Static styles */
|
|
87
112
|
width: fit-content;
|
|
88
113
|
display: flex;
|
|
@@ -111,6 +136,7 @@ export const Chip = forwardRef(
|
|
|
111
136
|
{
|
|
112
137
|
type = CHIP_TYPES.DEFAULT,
|
|
113
138
|
size = CHIP_SIZES.MEDIUM,
|
|
139
|
+
clickable = false,
|
|
114
140
|
icon,
|
|
115
141
|
children,
|
|
116
142
|
className,
|
|
@@ -118,7 +144,7 @@ export const Chip = forwardRef(
|
|
|
118
144
|
}: ChipProps,
|
|
119
145
|
ref,
|
|
120
146
|
) => {
|
|
121
|
-
const otherProps = { ...passThroughProps, type, size, className: clsx(className, classNames.BODY) };
|
|
147
|
+
const otherProps = { ...passThroughProps, type, size, clickable, className: clsx(className, classNames.BODY) };
|
|
122
148
|
|
|
123
149
|
return (
|
|
124
150
|
<StyledChip ref={ref} {...otherProps}>
|