first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
@@ -0,0 +1,3 @@
import * as React from 'react';
import type { ILinkProps } from './Link.types';
export declare const LinkBase: React.FunctionComponent<ILinkProps>;
+12
View File
@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkBase = void 0;
var tslib_1 = require("tslib");
var React = require("react");
var useLink_1 = require("./useLink");
exports.LinkBase = React.forwardRef(function (props, ref) {
var _a = (0, useLink_1.useLink)(props, ref), slots = _a.slots, slotProps = _a.slotProps;
return React.createElement(slots.root, tslib_1.__assign({}, slotProps.root));
});
exports.LinkBase.displayName = 'LinkBase';
//# sourceMappingURL=Link.base.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Link.base.js","sourceRoot":"../src/","sources":["components/Link/Link.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,qCAAoC;AAGvB,QAAA,QAAQ,GAAwC,KAAK,CAAC,UAAU,CAA0B,UAAC,KAAK,EAAE,GAAG;IAC1G,IAAA,KAAuB,IAAA,iBAAO,EAAC,KAAK,EAAE,GAAG,CAAC,EAAxC,KAAK,WAAA,EAAE,SAAS,eAAwB,CAAC;IAEjD,OAAO,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import * as React from 'react';\nimport { useLink } from './useLink';\nimport type { ILinkProps } from './Link.types';\n\nexport const LinkBase: React.FunctionComponent<ILinkProps> = React.forwardRef<HTMLElement, ILinkProps>((props, ref) => {\n const { slots, slotProps } = useLink(props, ref);\n\n return <slots.root {...slotProps.root} />;\n});\n\nLinkBase.displayName = 'LinkBase';\n"]}
+3
View File
@@ -0,0 +1,3 @@
import * as React from 'react';
import type { ILinkProps } from './Link.types';
export declare const Link: React.FunctionComponent<ILinkProps>;
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Link = void 0;
var utilities_1 = require("@fluentui/utilities");
var Link_base_1 = require("./Link.base");
var Link_styles_1 = require("./Link.styles");
exports.Link = (0, utilities_1.styled)(Link_base_1.LinkBase, Link_styles_1.getStyles, undefined, {
scope: 'Link',
});
//# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Link.js","sourceRoot":"../src/","sources":["components/Link/Link.tsx"],"names":[],"mappings":";;;AACA,iDAA6C;AAC7C,yCAAuC;AACvC,6CAA0C;AAG7B,QAAA,IAAI,GAAwC,IAAA,kBAAM,EAC7D,oBAAQ,EACR,uBAAS,EACT,SAAS,EACT;IACE,KAAK,EAAE,MAAM;CACd,CACF,CAAC","sourcesContent":["import * as React from 'react';\nimport { styled } from '@fluentui/utilities';\nimport { LinkBase } from './Link.base';\nimport { getStyles } from './Link.styles';\nimport type { ILinkProps, ILinkStyleProps, ILinkStyles } from './Link.types';\n\nexport const Link: React.FunctionComponent<ILinkProps> = styled<ILinkProps, ILinkStyleProps, ILinkStyles>(\n LinkBase,\n getStyles,\n undefined,\n {\n scope: 'Link',\n },\n);\n"]}
@@ -0,0 +1,5 @@
import type { ILinkStyleProps, ILinkStyles } from './Link.types';
export declare const GlobalClassNames: {
root: string;
};
export declare const getStyles: (props: ILinkStyleProps) => ILinkStyles;
@@ -0,0 +1,124 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStyles = exports.GlobalClassNames = void 0;
var style_utilities_1 = require("@fluentui/style-utilities");
var utilities_1 = require("@fluentui/utilities");
exports.GlobalClassNames = {
root: 'ms-Link',
};
var getStyles = function (props) {
var _a, _b, _c, _d, _e, _f, _g;
var className = props.className, isButton = props.isButton, isDisabled = props.isDisabled, isUnderlined = props.isUnderlined, theme = props.theme;
var semanticColors = theme.semanticColors;
// Tokens
var linkColor = semanticColors.link;
var linkInteractedColor = semanticColors.linkHovered;
var linkDisabledColor = semanticColors.disabledText;
var focusBorderColor = semanticColors.focusBorder;
var classNames = (0, style_utilities_1.getGlobalClassNames)(exports.GlobalClassNames, theme);
return {
root: [
classNames.root,
theme.fonts.medium,
{
color: linkColor,
outline: 'none',
fontSize: 'inherit',
fontWeight: 'inherit',
textDecoration: isUnderlined ? 'underline' : 'none',
selectors: (_a = {},
_a[".".concat(utilities_1.IsFocusVisibleClassName, " &:focus, :host(.").concat(utilities_1.IsFocusVisibleClassName, ") &:focus")] = {
// Can't use getFocusStyle because it doesn't support wrapping links
// https://github.com/microsoft/fluentui/issues/4883#issuecomment-406743543
// Using box-shadow and outline allows the focus rect to wrap links that span multiple lines
// and helps the focus rect avoid getting clipped.
boxShadow: "0 0 0 1px ".concat(focusBorderColor, " inset"),
outline: "1px auto ".concat(focusBorderColor),
selectors: (_b = {},
_b[style_utilities_1.HighContrastSelector] = {
outline: '1px solid WindowText',
},
_b),
},
_a[style_utilities_1.HighContrastSelector] = {
// For IE high contrast mode
borderBottom: 'none',
},
_a),
},
isButton && {
background: 'none',
backgroundColor: 'transparent',
border: 'none',
cursor: 'pointer',
display: 'inline',
margin: 0,
overflow: 'inherit',
padding: 0,
textAlign: 'left',
textOverflow: 'inherit',
userSelect: 'text',
borderBottom: '1px solid transparent', // For Firefox high contrast mode
selectors: (_c = {},
_c[style_utilities_1.HighContrastSelector] = {
color: 'LinkText',
forcedColorAdjust: 'none',
},
_c),
},
!isButton && {
selectors: (_d = {},
_d[style_utilities_1.HighContrastSelector] = {
// This is mainly for MessageBar, which sets MsHighContrastAdjust: none by default
MsHighContrastAdjust: 'auto',
forcedColorAdjust: 'auto',
},
_d),
},
isDisabled && [
'is-disabled',
{
color: linkDisabledColor,
cursor: 'default',
},
{
selectors: (_e = {
'&:link, &:visited': {
pointerEvents: 'none',
}
},
_e[style_utilities_1.HighContrastSelector] = {
// We need to specify the color in High Contrast because of the case of Links rendering as buttons.
color: 'GrayText',
},
_e),
},
],
!isDisabled && {
selectors: {
'&:active, &:hover, &:active:hover': {
color: linkInteractedColor,
textDecoration: 'underline',
selectors: (_f = {},
_f[style_utilities_1.HighContrastSelector] = {
color: 'LinkText',
},
_f),
},
'&:focus': {
color: linkColor,
selectors: (_g = {},
_g[style_utilities_1.HighContrastSelector] = {
color: 'LinkText',
},
_g),
},
},
},
classNames.root,
className,
],
};
};
exports.getStyles = getStyles;
//# sourceMappingURL=Link.styles.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,110 @@
import * as React from 'react';
import type { IStyle, ITheme } from '@fluentui/style-utilities';
import type { IRefObject, IStyleFunctionOrObject } from '@fluentui/utilities';
/**
* {@docCategory Link}
*/
export interface ILink {
/** Sets focus to the link. */
focus(): void;
}
/**
* @deprecated No longer used.
*/
export interface ILinkHTMLAttributes<T> extends React.HTMLAttributes<T> {
type?: string;
download?: any;
href?: string;
hrefLang?: string;
media?: string;
rel?: string;
target?: string;
autoFocus?: boolean;
disabled?: boolean;
form?: string;
formAction?: string;
formEncType?: string;
formMethod?: string;
formNoValidate?: boolean;
formTarget?: string;
name?: string;
value?: string | string[] | number;
/** Any other props for HTMLElements or a React component passed to `as` */
[key: string]: any;
}
/**
* Link component props. All built-in props for `<a>` and `<button>` are supported (including
* various event handlers) even if not listed below.
* {@docCategory Link}
*/
export interface ILinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement | HTMLButtonElement | HTMLElement>, Omit<React.ButtonHTMLAttributes<HTMLAnchorElement | HTMLButtonElement | HTMLElement>, 'type'>, React.RefAttributes<HTMLElement> {
/**
* Optional callback to access the ILink interface. Use this instead of ref for accessing
* the public methods and properties of the component.
*/
componentRef?: IRefObject<ILink>;
/**
* URL the link points to. If not provided, the link renders as a button (unless that behavior is
* overridden using `as`).
*/
href?: string;
/**
* Where to open the linked URL. Common values are `_blank` (a new tab or window),
* `_self` (the current window/context), `_parent`, and `_top`.
*/
target?: string;
/**
* Relationship to the linked URL (can be a space-separated list).
* Most common values are `noreferrer` and/or `noopener`.
*/
rel?: string;
/**
* Click handler for the link.
*/
onClick?: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement | HTMLElement>) => void;
/**
* Whether the link is disabled
*/
disabled?: boolean;
/**
* Call to provide customized styling that will layer on top of the variant rules.
*/
styles?: IStyleFunctionOrObject<ILinkStyleProps, ILinkStyles>;
/**
* Theme (provided through customization.)
*/
theme?: ITheme;
/**
* A component type or primitive that is rendered as the type of the root element.
*/
as?: React.ElementType;
/**
* Built-in HTML attribute with different behavior depending on how the link is rendered.
* If rendered as `<a>`, hints at the MIME type.
* If rendered as `<button>`, override the type of button (`button` is the default).
*/
type?: string;
/**
* Whether the link is styled with an underline or not.
* Should be used when the link is placed alongside other text content.
*/
underline?: boolean;
/** Any other props for elements or a React component passed to `as` */
[key: string]: any;
}
/**
* {@docCategory Link}
*/
export interface ILinkStyleProps {
className?: string;
isButton?: boolean;
isDisabled?: boolean;
isUnderlined?: boolean;
theme: ITheme;
}
/**
* {@docCategory Link}
*/
export interface ILinkStyles {
root: IStyle;
}
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Link.types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Link.types.js","sourceRoot":"../src/","sources":["components/Link/Link.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { IStyle, ITheme } from '@fluentui/style-utilities';\nimport type { IRefObject, IStyleFunctionOrObject } from '@fluentui/utilities';\n\n/**\n * {@docCategory Link}\n */\nexport interface ILink {\n /** Sets focus to the link. */\n focus(): void;\n}\n\n/**\n * @deprecated No longer used.\n */\nexport interface ILinkHTMLAttributes<T> extends React.HTMLAttributes<T> {\n // Shared\n type?: string;\n\n // Anchor\n download?: any;\n href?: string;\n hrefLang?: string;\n media?: string;\n rel?: string;\n target?: string;\n\n // Button\n autoFocus?: boolean;\n disabled?: boolean;\n form?: string;\n formAction?: string;\n formEncType?: string;\n formMethod?: string;\n formNoValidate?: boolean;\n formTarget?: string;\n name?: string;\n value?: string | string[] | number;\n\n /** Any other props for HTMLElements or a React component passed to `as` */\n [key: string]: any;\n}\n\n/**\n * Link component props. All built-in props for `<a>` and `<button>` are supported (including\n * various event handlers) even if not listed below.\n * {@docCategory Link}\n */\nexport interface ILinkProps\n extends React.AnchorHTMLAttributes<HTMLAnchorElement | HTMLButtonElement | HTMLElement>,\n Omit<React.ButtonHTMLAttributes<HTMLAnchorElement | HTMLButtonElement | HTMLElement>, 'type'>,\n React.RefAttributes<HTMLElement> {\n /**\n * Optional callback to access the ILink interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<ILink>;\n\n /**\n * URL the link points to. If not provided, the link renders as a button (unless that behavior is\n * overridden using `as`).\n */\n href?: string;\n\n /**\n * Where to open the linked URL. Common values are `_blank` (a new tab or window),\n * `_self` (the current window/context), `_parent`, and `_top`.\n */\n target?: string;\n\n /**\n * Relationship to the linked URL (can be a space-separated list).\n * Most common values are `noreferrer` and/or `noopener`.\n */\n rel?: string;\n\n /**\n * Click handler for the link.\n */\n onClick?: (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement | HTMLElement>) => void;\n\n /**\n * Whether the link is disabled\n */\n disabled?: boolean;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: IStyleFunctionOrObject<ILinkStyleProps, ILinkStyles>;\n\n /**\n * Theme (provided through customization.)\n */\n theme?: ITheme;\n\n /**\n * A component type or primitive that is rendered as the type of the root element.\n */\n as?: React.ElementType;\n\n /**\n * Built-in HTML attribute with different behavior depending on how the link is rendered.\n * If rendered as `<a>`, hints at the MIME type.\n * If rendered as `<button>`, override the type of button (`button` is the default).\n */\n type?: string;\n\n /**\n * Whether the link is styled with an underline or not.\n * Should be used when the link is placed alongside other text content.\n */\n underline?: boolean;\n\n /** Any other props for elements or a React component passed to `as` */\n [key: string]: any;\n}\n\n/**\n * {@docCategory Link}\n */\nexport interface ILinkStyleProps {\n className?: string;\n isButton?: boolean;\n isDisabled?: boolean;\n isUnderlined?: boolean;\n theme: ITheme;\n}\n\n/**\n * {@docCategory Link}\n */\nexport interface ILinkStyles {\n root: IStyle;\n}\n"]}
+3
View File
@@ -0,0 +1,3 @@
export * from './Link';
export * from './Link.base';
export * from './Link.types';
+7
View File
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./Link"), exports);
tslib_1.__exportStar(require("./Link.base"), exports);
tslib_1.__exportStar(require("./Link.types"), exports);
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Link/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,sDAA4B;AAC5B,uDAA6B","sourcesContent":["export * from './Link';\nexport * from './Link.base';\nexport * from './Link.types';\n"]}
@@ -0,0 +1,7 @@
import * as React from 'react';
import type { ILinkProps } from './Link.types';
/**
* The useLink hook processes the Link component props and returns
* state, slots and slotProps for consumption by the component.
*/
export declare const useLink: (props: ILinkProps, forwardedRef: React.Ref<HTMLElement>) => any;
+73
View File
@@ -0,0 +1,73 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLink = void 0;
var tslib_1 = require("tslib");
var React = require("react");
var react_hooks_1 = require("@fluentui/react-hooks");
var utilities_1 = require("@fluentui/utilities");
var getClassNames = (0, utilities_1.classNamesFunction)();
/**
* The useLink hook processes the Link component props and returns
* state, slots and slotProps for consumption by the component.
*/
var useLink = function (props, forwardedRef) {
var as = props.as, className = props.className, disabled = props.disabled, href = props.href, onClick = props.onClick, styles = props.styles, theme = props.theme, underline = props.underline;
var rootRef = React.useRef(null);
var mergedRootRefs = (0, react_hooks_1.useMergedRefs)(rootRef, forwardedRef);
useComponentRef(props, rootRef);
(0, utilities_1.useFocusRects)(rootRef);
var classNames = getClassNames(styles, {
className: className,
isButton: !href,
isDisabled: disabled,
isUnderlined: underline,
theme: theme,
});
var _onClick = function (ev) {
if (disabled) {
ev.preventDefault();
}
else if (onClick) {
onClick(ev);
}
};
var rootType = as ? as : href ? 'a' : 'button';
var state = {};
var slots = { root: rootType };
var slotProps = {
root: tslib_1.__assign(tslib_1.__assign({}, adjustPropsForRootType(rootType, props)), { 'aria-disabled': disabled, className: classNames.root, onClick: _onClick, ref: mergedRootRefs }),
};
return { state: state, slots: slots, slotProps: slotProps };
};
exports.useLink = useLink;
var useComponentRef = function (props, link) {
React.useImperativeHandle(props.componentRef, function () { return ({
focus: function () {
if (link.current) {
link.current.focus();
}
},
}); }, [link]);
};
var adjustPropsForRootType = function (RootType, props) {
// Deconstruct the props so we remove props like `as`, `theme` and `styles`
// as those will always be removed. We also take some props that are optional
// based on the RootType.
var as = props.as, disabled = props.disabled, target = props.target, href = props.href, theme = props.theme, getStyles = props.getStyles, styles = props.styles, componentRef = props.componentRef, underline = props.underline, restProps = tslib_1.__rest(props, ["as", "disabled", "target", "href", "theme", "getStyles", "styles", "componentRef", "underline"]);
// RootType will be a string if we're dealing with an html component
if (typeof RootType === 'string') {
// Remove the disabled prop for anchor elements
if (RootType === 'a') {
return tslib_1.__assign({ target: target, href: disabled ? undefined : href }, restProps);
}
// Add the type='button' prop for button elements
if (RootType === 'button') {
return tslib_1.__assign({ type: 'button', disabled: disabled }, restProps);
}
// Remove the target and href props for all other non anchor elements
return tslib_1.__assign(tslib_1.__assign({}, restProps), { disabled: disabled });
}
// Retain all props except 'as' for ReactComponents
return tslib_1.__assign({ target: target, href: href, disabled: disabled }, restProps);
};
//# sourceMappingURL=useLink.js.map
File diff suppressed because one or more lines are too long