@wallarm-org/design-system 1.29.0 → 1.31.0-rc-fix-filter-input-nested-menu-screenshot.1
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/components/Avatar/Avatar.d.ts +32 -0
- package/dist/components/Avatar/Avatar.figma.d.ts +1 -0
- package/dist/components/Avatar/Avatar.figma.js +27 -0
- package/dist/components/Avatar/Avatar.js +42 -0
- package/dist/components/Avatar/AvatarFallback.d.ts +11 -0
- package/dist/components/Avatar/AvatarFallback.js +25 -0
- package/dist/components/Avatar/AvatarImage.d.ts +9 -0
- package/dist/components/Avatar/AvatarImage.js +18 -0
- package/dist/components/Avatar/AvatarOverlay.d.ts +11 -0
- package/dist/components/Avatar/AvatarOverlay.js +22 -0
- package/dist/components/Avatar/classes.d.ts +6 -0
- package/dist/components/Avatar/classes.js +17 -0
- package/dist/components/Avatar/index.d.ts +4 -0
- package/dist/components/Avatar/index.js +4 -0
- package/dist/components/CodeEditor/CodeEditorContent.d.ts +17 -0
- package/dist/components/CodeEditor/CodeEditorContent.js +197 -0
- package/dist/components/CodeEditor/CodeEditorContext.d.ts +17 -0
- package/dist/components/CodeEditor/CodeEditorContext.js +8 -0
- package/dist/components/CodeEditor/CodeEditorRoot.d.ts +77 -0
- package/dist/components/CodeEditor/CodeEditorRoot.js +203 -0
- package/dist/components/CodeEditor/classes.d.ts +21 -0
- package/dist/components/CodeEditor/classes.js +41 -0
- package/dist/components/CodeEditor/engine/SearchPanel.d.ts +13 -0
- package/dist/components/CodeEditor/engine/SearchPanel.js +201 -0
- package/dist/components/CodeEditor/engine/adapterPainter.d.ts +23 -0
- package/dist/components/CodeEditor/engine/adapterPainter.js +110 -0
- package/dist/components/CodeEditor/engine/babelSyntax.d.ts +15 -0
- package/dist/components/CodeEditor/engine/babelSyntax.js +54 -0
- package/dist/components/CodeEditor/engine/completion.d.ts +17 -0
- package/dist/components/CodeEditor/engine/completion.js +129 -0
- package/dist/components/CodeEditor/engine/contentAttributes.d.ts +12 -0
- package/dist/components/CodeEditor/engine/contentAttributes.js +24 -0
- package/dist/components/CodeEditor/engine/diagnostics.d.ts +73 -0
- package/dist/components/CodeEditor/engine/diagnostics.js +327 -0
- package/dist/components/CodeEditor/engine/diff.d.ts +37 -0
- package/dist/components/CodeEditor/engine/diff.js +145 -0
- package/dist/components/CodeEditor/engine/folds.d.ts +25 -0
- package/dist/components/CodeEditor/engine/folds.js +458 -0
- package/dist/components/CodeEditor/engine/gutters.d.ts +22 -0
- package/dist/components/CodeEditor/engine/gutters.js +160 -0
- package/dist/components/CodeEditor/engine/index.d.ts +12 -0
- package/dist/components/CodeEditor/engine/index.js +387 -0
- package/dist/components/CodeEditor/engine/languages/http/index.d.ts +20 -0
- package/dist/components/CodeEditor/engine/languages/http/index.js +69 -0
- package/dist/components/CodeEditor/engine/languages/http/parser.d.ts +2 -0
- package/dist/components/CodeEditor/engine/languages/http/parser.js +31 -0
- package/dist/components/CodeEditor/engine/languages/http/parser.terms.d.ts +1 -0
- package/dist/components/CodeEditor/engine/languages/http/parser.terms.js +2 -0
- package/dist/components/CodeEditor/engine/languages/index.d.ts +8 -0
- package/dist/components/CodeEditor/engine/languages/index.js +41 -0
- package/dist/components/CodeEditor/engine/languages/json.d.ts +8 -0
- package/dist/components/CodeEditor/engine/languages/json.js +11 -0
- package/dist/components/CodeEditor/engine/languages/jsonPointers.d.ts +47 -0
- package/dist/components/CodeEditor/engine/languages/jsonPointers.js +125 -0
- package/dist/components/CodeEditor/engine/languages/yaml.d.ts +4 -0
- package/dist/components/CodeEditor/engine/languages/yaml.js +11 -0
- package/dist/components/CodeEditor/engine/lines.d.ts +22 -0
- package/dist/components/CodeEditor/engine/lines.js +131 -0
- package/dist/components/CodeEditor/engine/luaSyntax.d.ts +14 -0
- package/dist/components/CodeEditor/engine/luaSyntax.js +36 -0
- package/dist/components/CodeEditor/engine/positions.d.ts +19 -0
- package/dist/components/CodeEditor/engine/positions.js +22 -0
- package/dist/components/CodeEditor/engine/schema/complete.d.ts +12 -0
- package/dist/components/CodeEditor/engine/schema/complete.js +211 -0
- package/dist/components/CodeEditor/engine/schema/hover.d.ts +12 -0
- package/dist/components/CodeEditor/engine/schema/hover.js +73 -0
- package/dist/components/CodeEditor/engine/schema/loadSchema.d.ts +19 -0
- package/dist/components/CodeEditor/engine/schema/loadSchema.js +32 -0
- package/dist/components/CodeEditor/engine/schema/validate.d.ts +9 -0
- package/dist/components/CodeEditor/engine/schema/validate.js +67 -0
- package/dist/components/CodeEditor/engine/search.d.ts +13 -0
- package/dist/components/CodeEditor/engine/search.js +84 -0
- package/dist/components/CodeEditor/engine/searchMatches.d.ts +8 -0
- package/dist/components/CodeEditor/engine/searchMatches.js +15 -0
- package/dist/components/CodeEditor/engine/theme.d.ts +8 -0
- package/dist/components/CodeEditor/engine/theme.js +89 -0
- package/dist/components/CodeEditor/engine/types.d.ts +44 -0
- package/dist/components/CodeEditor/engine/types.js +0 -0
- package/dist/components/CodeEditor/hooks/useCodeEditor.d.ts +6 -0
- package/dist/components/CodeEditor/hooks/useCodeEditor.js +3 -0
- package/dist/components/CodeEditor/index.d.ts +6 -0
- package/dist/components/CodeEditor/index.js +5 -0
- package/dist/components/CodeEditor/lib/PortalOutlet.d.ts +11 -0
- package/dist/components/CodeEditor/lib/PortalOutlet.js +11 -0
- package/dist/components/CodeEditor/lib/httpCompletions.d.ts +7 -0
- package/dist/components/CodeEditor/lib/httpCompletions.js +102 -0
- package/dist/components/CodeEditor/lib/httpCompletionsData.d.ts +29 -0
- package/dist/components/CodeEditor/lib/httpCompletionsData.js +650 -0
- package/dist/components/CodeEditor/lib/keyboardHint.d.ts +5 -0
- package/dist/components/CodeEditor/lib/keyboardHint.js +2 -0
- package/dist/components/CodeEditor/lib/loadEngine.d.ts +7 -0
- package/dist/components/CodeEditor/lib/loadEngine.js +9 -0
- package/dist/components/CodeEditor/lib/portalRegistry.d.ts +20 -0
- package/dist/components/CodeEditor/lib/portalRegistry.js +47 -0
- package/dist/components/CodeEditor/lib/splitContentProps.d.ts +12 -0
- package/dist/components/CodeEditor/lib/splitContentProps.js +28 -0
- package/dist/components/CodeEditor/types.d.ts +72 -0
- package/dist/components/CodeEditor/types.js +0 -0
- package/dist/components/CodeSnippet/CodeSnippetCode.js +6 -23
- package/dist/components/CodeSnippet/CodeSnippetCopyButton.js +4 -3
- package/dist/components/CodeSnippet/CodeSnippetFrameContext.d.ts +25 -0
- package/dist/components/CodeSnippet/CodeSnippetFrameContext.js +3 -0
- package/dist/components/CodeSnippet/CodeSnippetFullscreenButton.js +2 -2
- package/dist/components/CodeSnippet/CodeSnippetRoot.d.ts +3 -5
- package/dist/components/CodeSnippet/CodeSnippetRoot.js +56 -50
- package/dist/components/CodeSnippet/CodeSnippetShowMoreButton.js +7 -5
- package/dist/components/CodeSnippet/CodeSnippetWrapButton.js +2 -2
- package/dist/components/CodeSnippet/adapters/highlightjs.js +1 -0
- package/dist/components/CodeSnippet/adapters/prism.js +3 -1
- package/dist/components/CodeSnippet/adapters/shiki.js +1 -0
- package/dist/components/CodeSnippet/adapters/types.d.ts +3 -3
- package/dist/components/CodeSnippet/classes.d.ts +3 -0
- package/dist/components/CodeSnippet/classes.js +14 -0
- package/dist/components/CodeSnippet/hooks/index.d.ts +1 -0
- package/dist/components/CodeSnippet/hooks/index.js +1 -0
- package/dist/components/CodeSnippet/hooks/useCodeSnippetFrame.d.ts +2 -0
- package/dist/components/CodeSnippet/hooks/useCodeSnippetFrame.js +8 -0
- package/dist/components/CodeSnippet/index.d.ts +2 -1
- package/dist/components/CodeSnippet/index.js +1 -1
- package/dist/components/CodeSnippet/internal/CodeSnippetFrame.d.ts +22 -0
- package/dist/components/CodeSnippet/internal/CodeSnippetFrame.js +81 -0
- package/dist/components/CodeSnippet/internal/CodeToken.d.ts +2 -1
- package/dist/components/CodeSnippet/internal/CodeToken.js +1 -1
- package/dist/components/CodeSnippet/internal/FoldSummary.d.ts +11 -0
- package/dist/components/CodeSnippet/internal/FoldSummary.js +27 -0
- package/dist/components/CodeSnippet/internal/FoldToggle.d.ts +2 -0
- package/dist/components/CodeSnippet/internal/FoldToggle.js +2 -1
- package/dist/components/CodeSnippet/internal/index.d.ts +1 -0
- package/dist/components/CodeSnippet/internal/index.js +1 -0
- package/dist/components/CodeSnippet/lib/foldUtils.d.ts +9 -2
- package/dist/components/CodeSnippet/lib/foldUtils.js +2 -2
- package/dist/components/CodeSnippet/lib/showMore.d.ts +7 -0
- package/dist/components/CodeSnippet/lib/showMore.js +7 -0
- package/dist/components/Copyable/Copyable.d.ts +5 -2
- package/dist/components/Copyable/Copyable.js +1 -1
- package/dist/components/FileUpload/FileUploadTrigger.d.ts +5 -0
- package/dist/components/FileUpload/FileUploadTrigger.js +18 -5
- package/dist/components/FileUpload/index.d.ts +1 -0
- package/dist/components/FileUpload/index.js +1 -0
- package/dist/components/FileUpload/useFilePreviewUrl.d.ts +6 -0
- package/dist/components/FileUpload/useFilePreviewUrl.js +14 -0
- package/dist/components/NavRail/NavRailItem.d.ts +1 -1
- package/dist/components/NavRail/NavRailItem.js +9 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/metadata/components.json +6029 -3516
- package/dist/theme/semantic.css +2 -0
- package/dist/utils/getInitials.d.ts +5 -0
- package/dist/utils/getInitials.js +13 -0
- package/package.json +24 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { Avatar as ArkAvatar } from '@ark-ui/react/avatar';
|
|
3
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { type TestableProps } from '../../utils/testId';
|
|
5
|
+
import { avatarVariants } from './classes';
|
|
6
|
+
export type AvatarStatusChangeDetails = ArkAvatar.StatusChangeDetails;
|
|
7
|
+
type AvatarButtonAttributes = Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled' | 'type' | 'name' | 'value' | 'form'>;
|
|
8
|
+
interface AvatarBaseProps extends HTMLAttributes<HTMLElement>, VariantProps<typeof avatarVariants>, TestableProps {
|
|
9
|
+
ref?: Ref<HTMLElement>;
|
|
10
|
+
onStatusChange?: (details: AvatarStatusChangeDetails) => void;
|
|
11
|
+
}
|
|
12
|
+
type AvatarRootProps = ({
|
|
13
|
+
/** Root tag. 'button' makes the avatar itself interactive (e.g. inside FileUploadTrigger asChild). */
|
|
14
|
+
as?: 'span';
|
|
15
|
+
/** Render the single child element as the root instead of `as`; takes precedence over it. */
|
|
16
|
+
asChild?: false;
|
|
17
|
+
} & {
|
|
18
|
+
[K in keyof AvatarButtonAttributes]?: never;
|
|
19
|
+
}) | ({
|
|
20
|
+
as: 'button';
|
|
21
|
+
asChild?: false;
|
|
22
|
+
} & AvatarButtonAttributes) | ({
|
|
23
|
+
as?: 'span' | 'button';
|
|
24
|
+
asChild: true;
|
|
25
|
+
} & AvatarButtonAttributes);
|
|
26
|
+
export type AvatarProps = AvatarBaseProps & AvatarRootProps;
|
|
27
|
+
/**
|
|
28
|
+
* A user's photo on a rounded plate, falling back to initials or an icon while the photo loads,
|
|
29
|
+
* when it fails, or when there is none.
|
|
30
|
+
*/
|
|
31
|
+
export declare const Avatar: FC<AvatarProps>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import code_connect from "@figma/code-connect";
|
|
3
|
+
import { Avatar, AvatarFallback, AvatarImage } from "./index.js";
|
|
4
|
+
const AVATAR_URL = 'https://www.figma.com/design/VKb5gW46uSGw0rqrhZsbXT/WADS-Components?node-id=12336-5504';
|
|
5
|
+
code_connect.connect(Avatar, AVATAR_URL, {
|
|
6
|
+
variant: {
|
|
7
|
+
Photo: 'On'
|
|
8
|
+
},
|
|
9
|
+
example: ()=>/*#__PURE__*/ jsxs(Avatar, {
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsx(AvatarImage, {
|
|
12
|
+
src: "/me.png"
|
|
13
|
+
}),
|
|
14
|
+
/*#__PURE__*/ jsx(AvatarFallback, {
|
|
15
|
+
name: "Ada Lovelace"
|
|
16
|
+
})
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
code_connect.connect(Avatar, AVATAR_URL, {
|
|
21
|
+
variant: {
|
|
22
|
+
Photo: 'Off'
|
|
23
|
+
},
|
|
24
|
+
example: ()=>/*#__PURE__*/ jsx(Avatar, {
|
|
25
|
+
children: /*#__PURE__*/ jsx(AvatarFallback, {})
|
|
26
|
+
})
|
|
27
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar } from "@ark-ui/react/avatar";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { TestIdProvider } from "../../utils/testId.js";
|
|
5
|
+
import { avatarVariants } from "./classes.js";
|
|
6
|
+
const Avatar_Avatar = ({ ref, id, size, as: Tag = 'span', asChild = false, disabled, type, name, value, form, onStatusChange, className, children, 'data-testid': testId, ...props })=>{
|
|
7
|
+
const role = props.role ?? (props['aria-label'] && !asChild && 'button' !== Tag ? 'img' : void 0);
|
|
8
|
+
const buttonAttributes = asChild || 'button' === Tag ? Object.fromEntries(Object.entries({
|
|
9
|
+
disabled,
|
|
10
|
+
name,
|
|
11
|
+
value,
|
|
12
|
+
form
|
|
13
|
+
}).filter(([, v])=>void 0 !== v)) : {};
|
|
14
|
+
return /*#__PURE__*/ jsx(TestIdProvider, {
|
|
15
|
+
value: testId,
|
|
16
|
+
children: /*#__PURE__*/ jsx(Avatar.Root, {
|
|
17
|
+
"data-slot": "avatar",
|
|
18
|
+
...props,
|
|
19
|
+
ids: id ? {
|
|
20
|
+
root: id
|
|
21
|
+
} : void 0,
|
|
22
|
+
...buttonAttributes,
|
|
23
|
+
ref: ref,
|
|
24
|
+
role: role,
|
|
25
|
+
...asChild && type ? {
|
|
26
|
+
type
|
|
27
|
+
} : {},
|
|
28
|
+
"data-testid": testId,
|
|
29
|
+
onStatusChange: onStatusChange,
|
|
30
|
+
className: cn(avatarVariants({
|
|
31
|
+
size
|
|
32
|
+
}), className),
|
|
33
|
+
asChild: true,
|
|
34
|
+
children: asChild ? children : /*#__PURE__*/ jsx(Tag, {
|
|
35
|
+
type: 'button' === Tag ? type ?? 'button' : void 0,
|
|
36
|
+
children: children
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
Avatar_Avatar.displayName = 'Avatar';
|
|
42
|
+
export { Avatar_Avatar as Avatar };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentType, FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { type SvgIconProps } from '../../icons';
|
|
3
|
+
export interface AvatarFallbackProps extends HTMLAttributes<HTMLSpanElement> {
|
|
4
|
+
ref?: Ref<HTMLSpanElement>;
|
|
5
|
+
/** Initials are taken from this: first letter of the first and of the last word. */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** Shown when there are no children and `name` gives no initials. */
|
|
8
|
+
icon?: ComponentType<SvgIconProps>;
|
|
9
|
+
}
|
|
10
|
+
/** Shown while the photo loads, when it fails, and when there is none. */
|
|
11
|
+
export declare const AvatarFallback: FC<AvatarFallbackProps>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar } from "@ark-ui/react/avatar";
|
|
3
|
+
import { UserRound } from "../../icons/index.js";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { getInitials } from "../../utils/getInitials.js";
|
|
6
|
+
import { useTestId } from "../../utils/testId.js";
|
|
7
|
+
import { avatarFallbackClassNames } from "./classes.js";
|
|
8
|
+
const AvatarFallback = ({ ref, name, icon: Icon = UserRound, className, children, ...props })=>{
|
|
9
|
+
const testId = useTestId('fallback');
|
|
10
|
+
const initials = name ? getInitials(name) : '';
|
|
11
|
+
const showsInitials = null == children && '' !== initials;
|
|
12
|
+
return /*#__PURE__*/ jsx(Avatar.Fallback, {
|
|
13
|
+
"aria-hidden": true,
|
|
14
|
+
...props,
|
|
15
|
+
ref: ref,
|
|
16
|
+
"data-slot": "avatar-fallback",
|
|
17
|
+
"data-testid": testId,
|
|
18
|
+
className: cn(avatarFallbackClassNames, showsInitials && 'text-text-primary', className),
|
|
19
|
+
children: children ?? (initials || /*#__PURE__*/ jsx(Icon, {
|
|
20
|
+
size: "md"
|
|
21
|
+
}))
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
AvatarFallback.displayName = 'AvatarFallback';
|
|
25
|
+
export { AvatarFallback };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FC, ImgHTMLAttributes, Ref } from 'react';
|
|
2
|
+
export interface AvatarImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'id'> {
|
|
3
|
+
ref?: Ref<HTMLImageElement>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The photo. Always render it — Ark tracks `src` changes on the mounted element — and pass
|
|
7
|
+
* `src={undefined}` for "no photo". Decorative by default (`alt=''`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const AvatarImage: FC<AvatarImageProps>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar } from "@ark-ui/react/avatar";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { avatarImageClassNames } from "./classes.js";
|
|
6
|
+
const AvatarImage = ({ ref, alt = '', className, ...props })=>{
|
|
7
|
+
const testId = useTestId('image');
|
|
8
|
+
return /*#__PURE__*/ jsx(Avatar.Image, {
|
|
9
|
+
...props,
|
|
10
|
+
ref: ref,
|
|
11
|
+
alt: alt,
|
|
12
|
+
"data-slot": "avatar-image",
|
|
13
|
+
"data-testid": testId,
|
|
14
|
+
className: cn(avatarImageClassNames, className)
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
AvatarImage.displayName = 'AvatarImage';
|
|
18
|
+
export { AvatarImage };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
export interface AvatarOverlayProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
ref?: Ref<HTMLSpanElement>;
|
|
4
|
+
/** Keep it shown regardless of hover — e.g. a `Loader` while the new photo uploads. */
|
|
5
|
+
visible?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The "change photo" affordance, shown on hover and keyboard focus of an interactive
|
|
9
|
+
* (`as='button'`) avatar. Over a photo it adds a wash; over the fallback it swaps the icon.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AvatarOverlay: FC<AvatarOverlayProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RefreshCcw } from "../../icons/index.js";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { avatarOverlayClassNames } from "./classes.js";
|
|
6
|
+
const AvatarOverlay = ({ ref, visible = false, className, children, ...props })=>{
|
|
7
|
+
const testId = useTestId('overlay');
|
|
8
|
+
return /*#__PURE__*/ jsx("span", {
|
|
9
|
+
...props,
|
|
10
|
+
ref: ref,
|
|
11
|
+
"aria-hidden": true,
|
|
12
|
+
"data-slot": "avatar-overlay",
|
|
13
|
+
"data-visible": visible ? '' : void 0,
|
|
14
|
+
"data-testid": testId,
|
|
15
|
+
className: cn(avatarOverlayClassNames, className),
|
|
16
|
+
children: children ?? /*#__PURE__*/ jsx(RefreshCcw, {
|
|
17
|
+
size: "md"
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
AvatarOverlay.displayName = 'AvatarOverlay';
|
|
22
|
+
export { AvatarOverlay };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const avatarVariants: (props?: ({
|
|
2
|
+
size?: "sm" | "xs" | null | undefined;
|
|
3
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
4
|
+
export declare const avatarImageClassNames: string;
|
|
5
|
+
export declare const avatarFallbackClassNames: string;
|
|
6
|
+
export declare const avatarOverlayClassNames: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
const avatarVariants = cva(cn('group/avatar inline-grid shrink-0 place-items-center overflow-hidden align-middle *:col-start-1 *:row-start-1', 'border border-border-primary bg-states-primary-hover text-icon-primary font-sans font-medium', 'branded:border-border-brand branded:bg-states-brand-hover branded:text-icon-brand', 'has-[>img[data-state=visible]]:border-0', 'hover:not-disabled:[&:has(>[data-slot=avatar-overlay])>[data-slot=avatar-fallback]]:invisible', 'focus-visible:[&:has(>[data-slot=avatar-overlay])>[data-slot=avatar-fallback]]:invisible', '[&:has(>[data-slot=avatar-overlay][data-visible])>[data-slot=avatar-fallback]]:invisible', 'enabled:cursor-pointer disabled:cursor-not-allowed', 'focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-focus-primary'), {
|
|
4
|
+
variants: {
|
|
5
|
+
size: {
|
|
6
|
+
xs: 'size-24 rounded-8 text-2xs',
|
|
7
|
+
sm: 'size-32 rounded-12 text-xs'
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
size: 'sm'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const avatarImageClassNames = cn('size-full object-cover data-[state=hidden]:hidden');
|
|
15
|
+
const avatarFallbackClassNames = cn('inline-flex items-center justify-center select-none data-[state=hidden]:hidden');
|
|
16
|
+
const avatarOverlayClassNames = cn('hidden size-full place-items-center text-icon-primary', 'group-hover/avatar:grid group-focus-visible/avatar:grid group-disabled/avatar:not-data-[visible]:hidden', 'data-[visible]:grid', 'group-has-[>img[data-state=visible]]/avatar:bg-component-avatar-overlay');
|
|
17
|
+
export { avatarFallbackClassNames, avatarImageClassNames, avatarOverlayClassNames, avatarVariants };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Avatar, type AvatarProps, type AvatarStatusChangeDetails } from './Avatar';
|
|
2
|
+
export { AvatarFallback, type AvatarFallbackProps } from './AvatarFallback';
|
|
3
|
+
export { AvatarImage, type AvatarImageProps } from './AvatarImage';
|
|
4
|
+
export { AvatarOverlay, type AvatarOverlayProps } from './AvatarOverlay';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
type CodeEditorContentNativeProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange' | 'contentEditable' | 'role' | 'defaultValue'>;
|
|
4
|
+
export interface CodeEditorContentProps extends CodeEditorContentNativeProps, TestableProps {
|
|
5
|
+
/** Content wrapper element */
|
|
6
|
+
ref?: Ref<HTMLDivElement>;
|
|
7
|
+
/** Show the line-number gutter (CodeSnippet's `<CodeSnippetLineNumbers />` equivalent) */
|
|
8
|
+
lineNumbers?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Editing surface of `CodeEditorRoot`. Loads the CodeMirror engine on mount and
|
|
12
|
+
* shows the value as static text until it is ready. `data-*`, `aria-*`, `id`,
|
|
13
|
+
* `title` and `tabIndex` land on the typing surface; `className`, `style`, `ref`
|
|
14
|
+
* and event handlers stay on this wrapper (events from the editor bubble to it).
|
|
15
|
+
*/
|
|
16
|
+
export declare const CodeEditorContent: FC<CodeEditorContentProps>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { flushSync } from "react-dom";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { useTestId } from "../../utils/testId.js";
|
|
6
|
+
import { useCodeSnippetFrame } from "../CodeSnippet/hooks/index.js";
|
|
7
|
+
import { useCodeEditorContext } from "./CodeEditorContext.js";
|
|
8
|
+
import { codeEditorContentVariants, codeEditorFallbackCodeVariants, codeEditorFallbackGutterVariants, codeEditorFallbackGuttersVariants, codeEditorFallbackLineVariants, codeEditorFallbackVariants, codeEditorHostVariants } from "./classes.js";
|
|
9
|
+
import { loadEngine } from "./lib/loadEngine.js";
|
|
10
|
+
import { PortalOutlet } from "./lib/PortalOutlet.js";
|
|
11
|
+
import { createPortalRegistry } from "./lib/portalRegistry.js";
|
|
12
|
+
import { splitContentProps } from "./lib/splitContentProps.js";
|
|
13
|
+
const ROW_HEIGHT = 20;
|
|
14
|
+
const VERTICAL_PADDING = 16;
|
|
15
|
+
const fallbackGuttersFor = (options)=>{
|
|
16
|
+
const configs = Object.values(options.lines);
|
|
17
|
+
const diff = void 0 !== options.original;
|
|
18
|
+
const { folds } = options;
|
|
19
|
+
return {
|
|
20
|
+
stick: diff || configs.some((line)=>null != line.color),
|
|
21
|
+
folds: void 0 !== folds && !(Array.isArray(folds) && 0 === folds.length),
|
|
22
|
+
prefix: diff || configs.some((line)=>null != line.prefix)
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const buildFallbackRows = (value, startingLineNumber, maxHeight)=>{
|
|
26
|
+
const lines = value.split('\n');
|
|
27
|
+
const visible = null === maxHeight ? lines : lines.slice(0, Math.max(0, Math.round((maxHeight - VERTICAL_PADDING) / ROW_HEIGHT)));
|
|
28
|
+
return visible.map((text, index)=>({
|
|
29
|
+
number: startingLineNumber + index,
|
|
30
|
+
text
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
const CodeEditorContent = ({ ref, lineNumbers = false, className, 'data-testid': testIdProp, ...props })=>{
|
|
34
|
+
const testId = useTestId('content', testIdProp);
|
|
35
|
+
const fallbackTestId = useTestId('fallback');
|
|
36
|
+
const fallbackGuttersTestId = useTestId('fallback-gutters');
|
|
37
|
+
const { options, callbacks, setHandle } = useCodeEditorContext();
|
|
38
|
+
const { isFullscreen } = useCodeSnippetFrame();
|
|
39
|
+
const [registry] = useState(createPortalRegistry);
|
|
40
|
+
const [handle, setLocalHandle] = useState(null);
|
|
41
|
+
const [loadFailed, setLoadFailed] = useState(false);
|
|
42
|
+
const hostRef = useRef(null);
|
|
43
|
+
const { contentAttributes: routedAttributes, wrapperProps } = splitContentProps(props);
|
|
44
|
+
const attributesKey = JSON.stringify(routedAttributes);
|
|
45
|
+
const contentAttributes = useMemo(()=>JSON.parse(attributesKey), [
|
|
46
|
+
attributesKey
|
|
47
|
+
]);
|
|
48
|
+
const engineOptions = useMemo(()=>({
|
|
49
|
+
...options,
|
|
50
|
+
lineNumbers,
|
|
51
|
+
contentAttributes
|
|
52
|
+
}), [
|
|
53
|
+
options,
|
|
54
|
+
lineNumbers,
|
|
55
|
+
contentAttributes
|
|
56
|
+
]);
|
|
57
|
+
const optionsRef = useRef(engineOptions);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
optionsRef.current = engineOptions;
|
|
60
|
+
}, [
|
|
61
|
+
engineOptions
|
|
62
|
+
]);
|
|
63
|
+
useEffect(()=>{
|
|
64
|
+
const host = hostRef.current;
|
|
65
|
+
if (!host) return;
|
|
66
|
+
let cancelled = false;
|
|
67
|
+
let created = null;
|
|
68
|
+
loadEngine().then((engine)=>{
|
|
69
|
+
if (cancelled) return;
|
|
70
|
+
created = engine.createEditor(host, optionsRef.current, {
|
|
71
|
+
...callbacks,
|
|
72
|
+
portals: registry
|
|
73
|
+
});
|
|
74
|
+
const mounted = created;
|
|
75
|
+
flushSync(()=>{
|
|
76
|
+
setHandle(mounted);
|
|
77
|
+
setLocalHandle(mounted);
|
|
78
|
+
});
|
|
79
|
+
}, (error)=>{
|
|
80
|
+
if (cancelled) return;
|
|
81
|
+
console.error('[CodeEditor] Failed to load the editor engine; showing read-only text.', error);
|
|
82
|
+
setLoadFailed(true);
|
|
83
|
+
});
|
|
84
|
+
return ()=>{
|
|
85
|
+
cancelled = true;
|
|
86
|
+
if (created) {
|
|
87
|
+
created.destroy();
|
|
88
|
+
setHandle(null);
|
|
89
|
+
}
|
|
90
|
+
setLocalHandle(null);
|
|
91
|
+
};
|
|
92
|
+
}, [
|
|
93
|
+
callbacks,
|
|
94
|
+
registry,
|
|
95
|
+
setHandle
|
|
96
|
+
]);
|
|
97
|
+
useEffect(()=>{
|
|
98
|
+
handle?.update(engineOptions);
|
|
99
|
+
}, [
|
|
100
|
+
handle,
|
|
101
|
+
engineOptions
|
|
102
|
+
]);
|
|
103
|
+
useEffect(()=>{
|
|
104
|
+
handle?.view.requestMeasure();
|
|
105
|
+
}, [
|
|
106
|
+
handle,
|
|
107
|
+
isFullscreen
|
|
108
|
+
]);
|
|
109
|
+
const hasAccessibleName = void 0 !== contentAttributes['aria-label'] || void 0 !== contentAttributes['aria-labelledby'];
|
|
110
|
+
useEffect(()=>{
|
|
111
|
+
if ('production' !== process.env.NODE_ENV && !hasAccessibleName) console.warn('[CodeEditor] CodeEditorContent has no accessible name. Pass `aria-label` or `aria-labelledby`.');
|
|
112
|
+
}, [
|
|
113
|
+
hasAccessibleName
|
|
114
|
+
]);
|
|
115
|
+
const fallbackRows = null === handle ? buildFallbackRows(options.value, options.startingLineNumber, options.maxHeight) : null;
|
|
116
|
+
const fallbackGutters = fallbackGuttersFor(options);
|
|
117
|
+
const hasGutter = lineNumbers || fallbackGutters.stick || fallbackGutters.folds || fallbackGutters.prefix;
|
|
118
|
+
const isDiff = void 0 !== options.original;
|
|
119
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
120
|
+
...wrapperProps,
|
|
121
|
+
ref: ref,
|
|
122
|
+
"data-slot": "code-editor-content",
|
|
123
|
+
"data-testid": testId,
|
|
124
|
+
"data-ds-suppress-parent-click": "",
|
|
125
|
+
className: cn(codeEditorContentVariants(), className),
|
|
126
|
+
children: [
|
|
127
|
+
fallbackRows && /*#__PURE__*/ jsxs("pre", {
|
|
128
|
+
"data-testid": fallbackTestId,
|
|
129
|
+
"aria-busy": loadFailed ? 'false' : 'true',
|
|
130
|
+
className: codeEditorFallbackVariants(),
|
|
131
|
+
children: [
|
|
132
|
+
hasGutter && /*#__PURE__*/ jsxs("span", {
|
|
133
|
+
"aria-hidden": "true",
|
|
134
|
+
"data-testid": fallbackGuttersTestId,
|
|
135
|
+
className: codeEditorFallbackGuttersVariants(),
|
|
136
|
+
children: [
|
|
137
|
+
fallbackGutters.stick && /*#__PURE__*/ jsx("span", {
|
|
138
|
+
className: codeEditorFallbackGutterVariants({
|
|
139
|
+
column: 'stick'
|
|
140
|
+
})
|
|
141
|
+
}),
|
|
142
|
+
lineNumbers && /*#__PURE__*/ jsx("span", {
|
|
143
|
+
className: codeEditorFallbackGutterVariants({
|
|
144
|
+
column: 'lineNumbers'
|
|
145
|
+
}),
|
|
146
|
+
children: fallbackRows.map((row)=>/*#__PURE__*/ jsx("span", {
|
|
147
|
+
className: codeEditorFallbackLineVariants(),
|
|
148
|
+
children: row.number
|
|
149
|
+
}, row.number))
|
|
150
|
+
}),
|
|
151
|
+
fallbackGutters.folds && /*#__PURE__*/ jsx("span", {
|
|
152
|
+
className: codeEditorFallbackGutterVariants({
|
|
153
|
+
column: 'folds'
|
|
154
|
+
})
|
|
155
|
+
}),
|
|
156
|
+
fallbackGutters.prefix && /*#__PURE__*/ jsxs("span", {
|
|
157
|
+
className: codeEditorFallbackGutterVariants({
|
|
158
|
+
column: 'prefix'
|
|
159
|
+
}),
|
|
160
|
+
children: [
|
|
161
|
+
fallbackRows.map((row)=>/*#__PURE__*/ jsx("span", {
|
|
162
|
+
className: codeEditorFallbackLineVariants(),
|
|
163
|
+
children: isDiff ? null : options.lines[row.number]?.prefix
|
|
164
|
+
}, row.number)),
|
|
165
|
+
isDiff && /*#__PURE__*/ jsx("span", {
|
|
166
|
+
className: "invisible h-0 overflow-hidden",
|
|
167
|
+
children: "+"
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
}),
|
|
173
|
+
/*#__PURE__*/ jsx("code", {
|
|
174
|
+
className: codeEditorFallbackCodeVariants({
|
|
175
|
+
hasGutter
|
|
176
|
+
}),
|
|
177
|
+
children: fallbackRows.map((row)=>/*#__PURE__*/ jsx("span", {
|
|
178
|
+
className: codeEditorFallbackLineVariants({
|
|
179
|
+
wrapLines: options.wrapLines
|
|
180
|
+
}),
|
|
181
|
+
children: row.text
|
|
182
|
+
}, row.number))
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ jsx("div", {
|
|
187
|
+
ref: hostRef,
|
|
188
|
+
className: codeEditorHostVariants()
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ jsx(PortalOutlet, {
|
|
191
|
+
registry: registry
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
CodeEditorContent.displayName = 'CodeEditorContent';
|
|
197
|
+
export { CodeEditorContent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EditorHandle, EngineCallbacks, EngineOptions } from './engine/types';
|
|
2
|
+
import type { CodeEditorApi } from './types';
|
|
3
|
+
/** Internal bridge between `CodeEditorRoot` (state owner) and `CodeEditorContent` (engine host). */
|
|
4
|
+
export interface CodeEditorContextValue {
|
|
5
|
+
/** Engine options owned by Root; Content adds `lineNumbers` and `contentAttributes` */
|
|
6
|
+
options: Omit<EngineOptions, 'lineNumbers' | 'contentAttributes' | 'maxHeight'> & {
|
|
7
|
+
maxHeight: number | null;
|
|
8
|
+
};
|
|
9
|
+
/** Stable callbacks (same identity for the Root's lifetime) */
|
|
10
|
+
callbacks: Omit<EngineCallbacks, 'portals'>;
|
|
11
|
+
/** Content registers the live handle after `createEditor()` and clears it on destroy */
|
|
12
|
+
setHandle: (handle: EditorHandle | null) => void;
|
|
13
|
+
/** Stable object delegating to the current handle (no-ops before the engine loads) */
|
|
14
|
+
api: CodeEditorApi;
|
|
15
|
+
}
|
|
16
|
+
export declare const CodeEditorContext: import("react").Context<CodeEditorContextValue | null>;
|
|
17
|
+
export declare const useCodeEditorContext: () => CodeEditorContextValue;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const CodeEditorContext = createContext(null);
|
|
3
|
+
const useCodeEditorContext = ()=>{
|
|
4
|
+
const context = useContext(CodeEditorContext);
|
|
5
|
+
if (!context) throw new Error('CodeEditor components must be used within CodeEditorRoot');
|
|
6
|
+
return context;
|
|
7
|
+
};
|
|
8
|
+
export { CodeEditorContext, useCodeEditorContext };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { type TestableProps } from '../../utils/testId';
|
|
4
|
+
import type { LineConfig } from '../CodeSnippet/CodeSnippetContext';
|
|
5
|
+
import { codeSnippetRootVariants } from '../CodeSnippet/classes';
|
|
6
|
+
import type { CodeEditorApi, CodeEditorCompletionSource, CodeEditorDiagnostic, CodeEditorFolds, CodeEditorLanguage, JsonSchema } from './types';
|
|
7
|
+
type CodeEditorRootNativeProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange' | 'defaultValue' | 'onCopy'>;
|
|
8
|
+
export interface CodeEditorRootProps extends CodeEditorRootNativeProps, TestableProps, VariantProps<typeof codeSnippetRootVariants> {
|
|
9
|
+
/** Root element, including in fullscreen */
|
|
10
|
+
ref?: Ref<HTMLDivElement>;
|
|
11
|
+
/** Controlled document */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** Uncontrolled initial document (controlled vs uncontrolled is locked on first render) */
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
/** Fired for user edits only, never for external `value` syncs */
|
|
16
|
+
onChange?: (value: string) => void;
|
|
17
|
+
/** Passed verbatim to the syntax adapter; selects the structural parser */
|
|
18
|
+
language?: CodeEditorLanguage;
|
|
19
|
+
/**
|
|
20
|
+
* Document identity: changing it swaps to that document's cached state (undo history,
|
|
21
|
+
* selection, folds). Requires a controlled `value`: when the id changes, `value` must already
|
|
22
|
+
* hold that document's text (an uncached id starts from `value`). In uncontrolled mode the new
|
|
23
|
+
* document would be seeded with the previous document's text.
|
|
24
|
+
*/
|
|
25
|
+
documentId?: string;
|
|
26
|
+
/** Focusable, selectable, searchable, copyable — but not editable by the user */
|
|
27
|
+
readOnly?: boolean;
|
|
28
|
+
/** Offsets gutter numbers; `lines`, `folds`, `diagnostics` use absolute numbers */
|
|
29
|
+
startingLineNumber?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Per-line configuration keyed by absolute line number (static, see spec D6).
|
|
32
|
+
* Compared by identity: memoise it (or hoist it to a constant) — a new object
|
|
33
|
+
* every render reconfigures the lines and gutters on every render.
|
|
34
|
+
*/
|
|
35
|
+
lines?: Record<number, LineConfig>;
|
|
36
|
+
/**
|
|
37
|
+
* Fold regions, or a function re-run after edits; collapsed state is kept by `id`.
|
|
38
|
+
* Compared by identity: memoise the array or pass a stable function (e.g. `getHttpFolds`) —
|
|
39
|
+
* an inline array/arrow reconfigures folds on every render and bypasses the re-run debounce.
|
|
40
|
+
*/
|
|
41
|
+
folds?: CodeEditorFolds;
|
|
42
|
+
/** Controlled line wrapping */
|
|
43
|
+
wrapLines?: boolean;
|
|
44
|
+
/** Uncontrolled initial line wrapping */
|
|
45
|
+
defaultWrapLines?: boolean;
|
|
46
|
+
/** Fired when the wrap button toggles wrapping */
|
|
47
|
+
onWrapLinesChange?: (wrap: boolean) => void;
|
|
48
|
+
/** Height clamp in rows; auto-renders `CodeSnippetShowMoreButton` unless one is a direct child */
|
|
49
|
+
maxLines?: number;
|
|
50
|
+
/** Enables diff mode against this text */
|
|
51
|
+
original?: string;
|
|
52
|
+
/** JSON Schema for the document (`json`) or the JSON body (`http`) */
|
|
53
|
+
schema?: JsonSchema;
|
|
54
|
+
/**
|
|
55
|
+
* Consumer completion sources, added after the built-in ones. Compared by identity: a new
|
|
56
|
+
* array reconfigures autocomplete and closes an open list, so keep it stable (module constant
|
|
57
|
+
* or `useMemo`).
|
|
58
|
+
*/
|
|
59
|
+
completions?: CodeEditorCompletionSource[];
|
|
60
|
+
/** External diagnostics, merged with syntax and schema ones */
|
|
61
|
+
diagnostics?: CodeEditorDiagnostic[];
|
|
62
|
+
/** Fired when the merged diagnostics change */
|
|
63
|
+
onDiagnosticsChange?: (diagnostics: CodeEditorDiagnostic[]) => void;
|
|
64
|
+
/** Imperative handle */
|
|
65
|
+
apiRef?: Ref<CodeEditorApi>;
|
|
66
|
+
/** Nonce for the style tags the editor injects */
|
|
67
|
+
cspNonce?: string;
|
|
68
|
+
/** Fired by `CodeSnippetCopyButton` after a copy, with the current document */
|
|
69
|
+
onCopy?: (value: string) => void;
|
|
70
|
+
/** Chrome (header, floating actions, show more) and `CodeEditorContent` */
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
}
|
|
73
|
+
export declare function CodeEditorRoot({ ref, value: valueProp, defaultValue, onChange, language, documentId, size, readOnly, startingLineNumber, lines, folds, wrapLines: wrapLinesProp, defaultWrapLines, onWrapLinesChange, maxLines, original, schema, completions, diagnostics, onDiagnosticsChange, apiRef, cspNonce, onCopy, className, children, 'data-testid': testId, ...props }: CodeEditorRootProps): import("react").JSX.Element;
|
|
74
|
+
export declare namespace CodeEditorRoot {
|
|
75
|
+
var displayName: string;
|
|
76
|
+
}
|
|
77
|
+
export {};
|