Private
Public Access
1
0

feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
2026-04-14 18:52:25 +00:00
parent 1199eff6c3
commit dfa4010406
34820 changed files with 1003813 additions and 205 deletions

View File

@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "assertSlots", {
enumerable: true,
get: function() {
return assertSlots;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _constants = require("./constants");
const _isSlot = require("./isSlot");
const _slot = /*#__PURE__*/ _interop_require_wildcard._(require("./slot"));
function assertSlots(state) {
/**
* This verification is not necessary in production
* as we're verifying static properties that will not change between environments
*/ if (process.env.NODE_ENV !== 'production') {
const typedState = state;
// eslint-disable-next-line @typescript-eslint/no-deprecated
for (const slotName of Object.keys(typedState.components)){
const slotElement = typedState[slotName];
if (slotElement === undefined) {
continue;
}
// this means a slot is being declared without using, slot.always or slot.optional or even resolveShorthand on the state hook,
// but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type
// FIXME: this slot will still fail to support child render function scenario
if (!(0, _isSlot.isSlot)(slotElement)) {
typedState[slotName] = _slot.always(slotElement, {
// eslint-disable-next-line @typescript-eslint/no-deprecated
elementType: typedState.components[slotName]
});
// eslint-disable-next-line no-console
console.warn(`@fluentui/react-utilities [${assertSlots.name}]:
"state.${slotName}" is not a slot!
Be sure to create slots properly by using "slot.always" or "slot.optional".`);
} else {
// This means a slot is being declared by using resolveShorthand on the state hook,
// but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type
const { [_constants.SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (elementType !== typedState.components[slotName]) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
slotElement[_constants.SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName];
// eslint-disable-next-line no-console
console.warn(`@fluentui/react-utilities [${assertSlots.name}]:
"state.${slotName}" element type differs from "state.components.${slotName}",
${elementType} !== ${typedState.components[slotName]}.
Be sure to create slots properly by using "slot.always" or "slot.optional" with the correct elementType.`);
}
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,27 @@
/**
* @internal
* Internal reference for the render function
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
SLOT_CLASS_NAME_PROP_SYMBOL: function() {
return SLOT_CLASS_NAME_PROP_SYMBOL;
},
SLOT_ELEMENT_TYPE_SYMBOL: function() {
return SLOT_ELEMENT_TYPE_SYMBOL;
},
SLOT_RENDER_FUNCTION_SYMBOL: function() {
return SLOT_RENDER_FUNCTION_SYMBOL;
}
});
const SLOT_RENDER_FUNCTION_SYMBOL = Symbol.for('fui.slotRenderFunction');
const SLOT_ELEMENT_TYPE_SYMBOL = Symbol.for('fui.slotElementType');
const SLOT_CLASS_NAME_PROP_SYMBOL = Symbol.for('fui.slotClassNameProp');

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/constants.ts"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_RENDER_FUNCTION_SYMBOL = Symbol.for('fui.slotRenderFunction');\n/**\n * @internal\n * Internal reference for the render function\n */\nexport const SLOT_ELEMENT_TYPE_SYMBOL = Symbol.for('fui.slotElementType');\n/**\n * @internal\n * Internal cache of the original className prop for the slot, before being modified by the useStyles hook.\n */\nexport const SLOT_CLASS_NAME_PROP_SYMBOL = Symbol.for('fui.slotClassNameProp');\n"],"names":["SLOT_CLASS_NAME_PROP_SYMBOL","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","Symbol","for"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;IAWYA,2BAA2B;eAA3BA;;IALAC,wBAAwB;eAAxBA;;IALAC,2BAA2B;eAA3BA;;;AAAN,MAAMA,8BAA8BC,OAAOC,GAAG,CAAC;AAK/C,MAAMH,2BAA2BE,OAAOC,GAAG,CAAC;AAK5C,MAAMJ,8BAA8BG,OAAOC,GAAG,CAAC"}

View File

@@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSlots", {
enumerable: true,
get: function() {
return getSlots;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _omit = require("../../utils/omit");
const _isSlot = require("../isSlot");
const _constants = require("../constants");
function getSlots(state) {
const typeState = state;
// eslint-disable-next-line @typescript-eslint/no-deprecated
const slots = {};
const slotProps = {};
// eslint-disable-next-line @typescript-eslint/no-deprecated
const slotNames = Object.keys(typeState.components);
for (const slotName of slotNames){
const [slot, props] = getSlot(typeState, slotName);
// eslint-disable-next-line @typescript-eslint/no-deprecated
slots[slotName] = slot;
slotProps[slotName] = props;
}
// eslint-disable-next-line @typescript-eslint/no-deprecated
return {
slots,
slotProps: slotProps
};
}
function getSlot(state, slotName) {
var _state_components, _state_components1;
const props = state[slotName];
if (props === undefined) {
return [
null,
undefined
];
}
// TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)
const { as: asProp, children, ...rest } = props;
const renderFunction = (0, _isSlot.isSlot)(props) ? props[_constants.SLOT_RENDER_FUNCTION_SYMBOL] : undefined;
const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || // eslint-disable-line @typescript-eslint/no-deprecated
// eslint-disable-next-line @typescript-eslint/no-deprecated
typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];
const asserted = slot;
if (renderFunction || typeof children === 'function') {
const render = renderFunction || children;
return [
_react.Fragment,
{
children: render(asserted, rest)
}
];
}
const shouldOmitAsProp = typeof slot === 'string' && asProp;
const slotProps = shouldOmitAsProp ? (0, _omit.omit)(props, [
'as'
]) : props;
return [
asserted,
slotProps
];
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSlotsNext", {
enumerable: true,
get: function() {
return getSlotsNext;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function getSlotsNext(state) {
const typedState = state;
// eslint-disable-next-line @typescript-eslint/no-deprecated
const slots = {};
const slotProps = {};
// eslint-disable-next-line @typescript-eslint/no-deprecated
const slotNames = Object.keys(typedState.components);
for (const slotName of slotNames){
// eslint-disable-next-line @typescript-eslint/no-deprecated
const [slot, props] = getSlotNext(typedState, slotName);
// eslint-disable-next-line @typescript-eslint/no-deprecated
slots[slotName] = slot;
slotProps[slotName] = props;
}
// eslint-disable-next-line @typescript-eslint/no-deprecated
return {
slots,
slotProps: slotProps
};
}
/**
* @deprecated use slot.always or slot.optional combined with assertSlots instead
*/ function getSlotNext(state, slotName) {
var _state_components, _state_components1;
const props = state[slotName];
if (props === undefined) {
return [
null,
undefined
];
}
// TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)
const { as: asProp, ...propsWithoutAs } = props;
const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || // eslint-disable-line @typescript-eslint/no-deprecated
// eslint-disable-next-line @typescript-eslint/no-deprecated
typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];
const shouldOmitAsProp = typeof slot === 'string' && asProp;
const slotProps = shouldOmitAsProp ? propsWithoutAs : props;
return [
slot,
slotProps
];
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/deprecated/getSlotsNext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentState, SlotPropsRecord, UnknownSlotProps } from '../types';\nimport { ObjectSlotProps, Slots } from './getSlots';\n\n/**\n * Similar to `getSlots`, main difference is that it's compatible with new custom jsx pragma\n *\n * @internal\n * This is an internal temporary method, this method will cease to exist eventually!\n *\n * * ❗️❗️ **DO NOT USE IT EXTERNALLY** ❗️❗️\n *\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport function getSlotsNext<R extends SlotPropsRecord>(\n state: unknown,\n): {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots: Slots<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slotProps: ObjectSlotProps<R>;\n} {\n const typedState = state as ComponentState<R>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const slotNames: (keyof R)[] = Object.keys(typedState.components);\n for (const slotName of slotNames) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const [slot, props] = getSlotNext(typedState, slotName);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return { slots, slotProps: slotProps as unknown as ObjectSlotProps<R> };\n}\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nfunction getSlotNext<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n const props = state[slotName];\n\n if (props === undefined) {\n return [null, undefined as R[K]];\n }\n\n type NonUndefined<T> = T extends undefined ? never : T;\n // TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)\n const { as: asProp, ...propsWithoutAs } = props as NonUndefined<typeof props>;\n\n const slot = (\n state.components?.[slotName] === undefined || // eslint-disable-line @typescript-eslint/no-deprecated\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n typeof state.components[slotName] === 'string'\n ? // eslint-disable-next-line @typescript-eslint/no-deprecated\n asProp || state.components?.[slotName] || 'div'\n : // eslint-disable-next-line @typescript-eslint/no-deprecated\n state.components[slotName]\n ) as React.ElementType<R[K]>;\n\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps: UnknownSlotProps = shouldOmitAsProp ? propsWithoutAs : props;\n\n return [slot as React.ElementType<R[K]>, slotProps as R[K]];\n}\n"],"names":["getSlotsNext","state","typedState","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlotNext","undefined","as","asProp","propsWithoutAs","shouldOmitAsProp"],"mappings":";;;;+BAcgBA;;;eAAAA;;;;iEAdO;AAchB,SAASA,aACdC,KAAc;IAOd,MAAMC,aAAaD;IACnB,4DAA4D;IAC5D,MAAME,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IAEnB,4DAA4D;IAC5D,MAAMC,YAAyBC,OAAOC,IAAI,CAACL,WAAWM,UAAU;IAChE,KAAK,MAAMC,YAAYJ,UAAW;QAChC,4DAA4D;QAC5D,MAAM,CAACK,MAAMC,MAAM,GAAGC,YAAYV,YAAYO;QAC9C,4DAA4D;QAC5DN,KAAK,CAACM,SAAS,GAAGC;QAClBN,SAAS,CAACK,SAAS,GAAGE;IACxB;IACA,4DAA4D;IAC5D,OAAO;QAAER;QAAOC,WAAWA;IAA2C;AACxE;AAEA;;CAEC,GACD,SAASQ,YACPX,KAAwB,EACxBQ,QAAW;QAaTR,mBAIcA;IAfhB,MAAMU,QAAQV,KAAK,CAACQ,SAAS;IAE7B,IAAIE,UAAUE,WAAW;QACvB,OAAO;YAAC;YAAMA;SAAkB;IAClC;IAGA,yFAAyF;IACzF,MAAM,EAAEC,IAAIC,MAAM,EAAE,GAAGC,gBAAgB,GAAGL;IAE1C,MAAMD,OACJT,EAAAA,oBAAAA,MAAMO,UAAU,cAAhBP,wCAAAA,iBAAkB,CAACQ,SAAS,MAAKI,aAAa,uDAAuD;IACrG,4DAA4D;IAC5D,OAAOZ,MAAMO,UAAU,CAACC,SAAS,KAAK,WAElCM,YAAUd,qBAAAA,MAAMO,UAAU,cAAhBP,yCAAAA,kBAAkB,CAACQ,SAAS,KAAI,QAE1CR,MAAMO,UAAU,CAACC,SAAS;IAGhC,MAAMQ,mBAAmB,OAAOP,SAAS,YAAYK;IACrD,MAAMX,YAA8Ba,mBAAmBD,iBAAiBL;IAExE,OAAO;QAACD;QAAiCN;KAAkB;AAC7D"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "resolveShorthand", {
enumerable: true,
get: function() {
return resolveShorthand;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _slot = /*#__PURE__*/ _interop_require_wildcard._(require("../slot"));
const resolveShorthand = (value, options)=>_slot.optional(value, {
...options,
renderByDefault: options === null || options === void 0 ? void 0 : options.required,
// elementType as undefined is the way to identify between a slot and a resolveShorthand call
// in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.
elementType: undefined
});

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/deprecated/resolveShorthand.ts"],"sourcesContent":["import * as slot from '../slot';\nimport type { UnknownSlotProps, SlotShorthandValue, WithoutSlotRenderFunction } from '../types';\n\n/**\n * @deprecated - use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true\n ? { required: true; defaultProps?: Props }\n : { required?: Required; defaultProps?: Props };\n\n/**\n * @deprecated use slot.always or slot.optional combined with assertSlots instead\n */\nexport type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {\n <P extends Props>(\n value: P | SlotShorthandValue | undefined,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n options: ResolveShorthandOptions<P, true>,\n ): WithoutSlotRenderFunction<P>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>):\n | WithoutSlotRenderFunction<P>\n | undefined;\n};\n\n/**\n *\n * Resolves shorthands into slot props, to ensure normalization of the signature\n * being passed down to getSlots method\n * @param value - the base shorthand props\n * @param options - options to resolve shorthand props\n *\n * @deprecated use slot.always, slot.optional, slot.resolveShorthand combined with assertSlots instead\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport const resolveShorthand: ResolveShorthandFunction<UnknownSlotProps> = (value, options) =>\n slot.optional<UnknownSlotProps>(value, {\n ...options,\n renderByDefault: options?.required,\n // elementType as undefined is the way to identify between a slot and a resolveShorthand call\n // in the case elementType is undefined assertSlots will fail, ensuring it'll only work with slot method.\n elementType: undefined!,\n }) as WithoutSlotRenderFunction<UnknownSlotProps>;\n"],"names":["resolveShorthand","value","options","slot","optional","renderByDefault","required","elementType","undefined"],"mappings":";;;;+BAmCaA;;;eAAAA;;;;gEAnCS;AAmCf,MAAMA,mBAA+D,CAACC,OAAOC,UAClFC,MAAKC,QAAQ,CAAmBH,OAAO;QACrC,GAAGC,OAAO;QACVG,eAAe,EAAEH,oBAAAA,8BAAAA,QAASI,QAAQ;QAClC,6FAA6F;QAC7F,yGAAyG;QACzGC,aAAaC;IACf"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getIntrinsicElementProps", {
enumerable: true,
get: function() {
return getIntrinsicElementProps;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _getNativeElementProps = require("../utils/getNativeElementProps");
const getIntrinsicElementProps = (tagName, // eslint-disable-next-line @typescript-eslint/no-restricted-types -- in order to not introduce Type Restriction CHANGe which is kinda "breaking change from Types POV", we don't enforce our custom `RefAttributes` in this API, to be compatible with scenarios where non v9 interfaces might be used. This may/will change with React 19
props, excludedPropNames)=>{
var _props_as;
// eslint-disable-next-line @typescript-eslint/no-deprecated
return (0, _getNativeElementProps.getNativeElementProps)((_props_as = props.as) !== null && _props_as !== void 0 ? _props_as : tagName, props, excludedPropNames);
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/getIntrinsicElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '../utils/getNativeElementProps';\nimport type { InferredElementRefType, UnknownSlotProps } from './types';\nimport type { DistributiveOmit } from '../utils/types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype HTMLAttributes = React.HTMLAttributes<any>;\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n *\n * Equivalent to {@link getNativeElementProps}, but more type-safe.\n *\n * @param tagName - The slot's default element type (e.g. 'div')\n * @param props - The component's props object\n * @param excludedPropNames - List of native props to exclude from the returned value\n */\nexport const getIntrinsicElementProps = <\n Props extends UnknownSlotProps,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>(\n tagName: NonNullable<Props['as']>,\n // eslint-disable-next-line @typescript-eslint/no-restricted-types -- in order to not introduce Type Restriction CHANGe which is kinda \"breaking change from Types POV\", we don't enforce our custom `RefAttributes` in this API, to be compatible with scenarios where non v9 interfaces might be used. This may/will change with React 19\n props: Props & React.RefAttributes<InferredElementRefType<Props>>,\n excludedPropNames?: ExcludedPropKeys[],\n): DistributiveOmit<Props, ExcludedPropKeys | Exclude<keyof Props, 'as' | keyof HTMLAttributes>> => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return getNativeElementProps<\n DistributiveOmit<Props, Exclude<keyof Props, keyof HTMLAttributes | keyof UnknownSlotProps> | ExcludedPropKeys>\n >(props.as ?? tagName, props, excludedPropNames);\n};\n"],"names":["getIntrinsicElementProps","tagName","props","excludedPropNames","getNativeElementProps","as"],"mappings":";;;;+BAkBaA;;;eAAAA;;;;iEAlBU;uCACe;AAiB/B,MAAMA,2BAA2B,CAItCC,SACA,2UAA2U;AAC3UC,OACAC;QAKED;IAHF,4DAA4D;IAC5D,OAAOE,IAAAA,4CAAqB,EAE1BF,CAAAA,YAAAA,MAAMG,EAAE,cAARH,uBAAAA,YAAYD,SAASC,OAAOC;AAChC"}

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSlotClassNameProp", {
enumerable: true,
get: function() {
return getSlotClassNameProp;
}
});
const _constants = require("../compose/constants");
const getSlotClassNameProp = (slot)=>{
if (_constants.SLOT_CLASS_NAME_PROP_SYMBOL in slot && typeof slot[_constants.SLOT_CLASS_NAME_PROP_SYMBOL] === 'string') {
return slot[_constants.SLOT_CLASS_NAME_PROP_SYMBOL];
}
return undefined;
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/getSlotClassNameProp.ts"],"sourcesContent":["import { SLOT_CLASS_NAME_PROP_SYMBOL } from '../compose/constants';\nimport type { UnknownSlotProps } from '../compose/types';\n\n/**\n * Get the className prop set on the slot by the user, without including the default classes added by the component.\n * Custom style hooks should merge this className _after_ any additional classes added by the hook, to ensure that\n * classes added by the user take precedence over the custom style hook.\n *\n * Example usage in a custom style hook:\n * ```ts\n * state.root.className = mergeClasses(\n * state.root.className,\n * customStyles.root,\n * getSlotClassNameProp_unstable(state.root));\n * ```\n *\n * @returns The className prop set on the slot by the user, or undefined if not set.\n */\nexport const getSlotClassNameProp = (slot: UnknownSlotProps): string | undefined => {\n if (SLOT_CLASS_NAME_PROP_SYMBOL in slot && typeof slot[SLOT_CLASS_NAME_PROP_SYMBOL] === 'string') {\n return slot[SLOT_CLASS_NAME_PROP_SYMBOL];\n }\n return undefined;\n};\n"],"names":["getSlotClassNameProp","slot","SLOT_CLASS_NAME_PROP_SYMBOL","undefined"],"mappings":";;;;+BAkBaA;;;eAAAA;;;2BAlB+B;AAkBrC,MAAMA,uBAAuB,CAACC;IACnC,IAAIC,sCAA2B,IAAID,QAAQ,OAAOA,IAAI,CAACC,sCAA2B,CAAC,KAAK,UAAU;QAChG,OAAOD,IAAI,CAACC,sCAA2B,CAAC;IAC1C;IACA,OAAOC;AACT"}

View File

@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
SLOT_CLASS_NAME_PROP_SYMBOL: function() {
return _constants.SLOT_CLASS_NAME_PROP_SYMBOL;
},
SLOT_ELEMENT_TYPE_SYMBOL: function() {
return _constants.SLOT_ELEMENT_TYPE_SYMBOL;
},
SLOT_RENDER_FUNCTION_SYMBOL: function() {
return _constants.SLOT_RENDER_FUNCTION_SYMBOL;
},
assertSlots: function() {
return _assertSlots.assertSlots;
},
getIntrinsicElementProps: function() {
return _getIntrinsicElementProps.getIntrinsicElementProps;
},
getSlotClassNameProp_unstable: function() {
return _getSlotClassNameProp.getSlotClassNameProp;
},
getSlots: function() {
return _getSlots.getSlots;
},
getSlotsNext: function() {
return _getSlotsNext.getSlotsNext;
},
isResolvedShorthand: function() {
return _isResolvedShorthand.isResolvedShorthand;
},
isSlot: function() {
return _isSlot.isSlot;
},
resolveShorthand: function() {
return _resolveShorthand.resolveShorthand;
},
slot: function() {
return _slot;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _slot = /*#__PURE__*/ _interop_require_wildcard._(require("./slot"));
const _isResolvedShorthand = require("./isResolvedShorthand");
const _constants = require("./constants");
const _isSlot = require("./isSlot");
const _assertSlots = require("./assertSlots");
const _getIntrinsicElementProps = require("./getIntrinsicElementProps");
const _getSlotClassNameProp = require("./getSlotClassNameProp");
const _getSlots = require("./deprecated/getSlots");
const _resolveShorthand = require("./deprecated/resolveShorthand");
const _getSlotsNext = require("./deprecated/getSlotsNext");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/index.ts"],"sourcesContent":["import * as slot from './slot';\n\nexport type {\n AsIntrinsicElement,\n ComponentProps,\n ComponentState,\n EventData,\n EventHandler,\n ExtractSlotProps,\n ForwardRefComponent,\n RefAttributes,\n InferredElementRefType,\n IsSingleton,\n Slot,\n SlotClassNames,\n SlotComponentType,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './types';\n\nexport { isResolvedShorthand } from './isResolvedShorthand';\nexport { SLOT_CLASS_NAME_PROP_SYMBOL, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\nexport { isSlot } from './isSlot';\nexport { assertSlots } from './assertSlots';\nexport { getIntrinsicElementProps } from './getIntrinsicElementProps';\nexport { getSlotClassNameProp as getSlotClassNameProp_unstable } from './getSlotClassNameProp';\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { ObjectSlotProps, Slots } from './deprecated/getSlots';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { getSlots } from './deprecated/getSlots';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { ResolveShorthandFunction, ResolveShorthandOptions } from './deprecated/resolveShorthand';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { resolveShorthand } from './deprecated/resolveShorthand';\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { getSlotsNext } from './deprecated/getSlotsNext';\n\nexport { slot };\nexport type { SlotOptions } from './slot';\nexport type { PropsWithoutChildren, PropsWithoutRef } from '../utils/types';\n"],"names":["SLOT_CLASS_NAME_PROP_SYMBOL","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","assertSlots","getIntrinsicElementProps","getSlotClassNameProp_unstable","getSlotClassNameProp","getSlots","getSlotsNext","isResolvedShorthand","isSlot","resolveShorthand","slot"],"mappings":";;;;;;;;;;;IAuBSA,2BAA2B;eAA3BA,sCAA2B;;IAAEC,wBAAwB;eAAxBA,mCAAwB;;IAAEC,2BAA2B;eAA3BA,sCAA2B;;IAElFC,WAAW;eAAXA,wBAAW;;IACXC,wBAAwB;eAAxBA,kDAAwB;;IACAC,6BAA6B;eAArDC,0CAAoB;;IAKpBC,QAAQ;eAARA,kBAAQ;;IAMRC,YAAY;eAAZA,0BAAY;;IAhBZC,mBAAmB;eAAnBA,wCAAmB;;IAEnBC,MAAM;eAANA,cAAM;;IAYNC,gBAAgB;eAAhBA,kCAAgB;;IAIhBC,IAAI;eAAJA;;;;gEAxCa;qCAsBc;2BAC+D;wBAC5E;6BACK;0CACa;sCAC6B;0BAK7C;kCAIQ;8BAEJ"}

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isResolvedShorthand", {
enumerable: true,
get: function() {
return isResolvedShorthand;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function isResolvedShorthand(shorthand) {
return shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !_react.isValidElement(shorthand);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/isResolvedShorthand.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ExtractSlotProps, Slot, UnknownSlotProps } from './types';\n\n/**\n * Guard method that validates if a shorthand is a slot\n * can be used to extends properties provided by a slot\n *\n * @example\n * ```\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(event => {\n * if (isResolvedShorthand(backdrop)) {\n * backdrop.onClick?.(event)\n * }\n * // do something after passing click down the line\n * }),\n * },\n * })\n * ```\n * @example\n * ```\n * const handleBackDropClick = (event) => {\n * // do your thing\n * }\n * const backdropSlot = resolveShorthand(backdrop, {\n * defaultProps: {\n * onClick: useEventCallback(\n * mergeCallbacks(isResolvedShorthand(backdrop) ? backdrop.onClick : undefined, handleBackdropClick)\n * )\n * })\n * ```\n */\nexport function isResolvedShorthand<Shorthand extends Slot<UnknownSlotProps>>(\n shorthand?: Shorthand,\n): shorthand is ExtractSlotProps<Shorthand> {\n return (\n shorthand !== null && typeof shorthand === 'object' && !Array.isArray(shorthand) && !React.isValidElement(shorthand)\n );\n}\n"],"names":["isResolvedShorthand","shorthand","Array","isArray","React","isValidElement"],"mappings":";;;;+BAiCgBA;;;eAAAA;;;;iEAjCO;AAiChB,SAASA,oBACdC,SAAqB;IAErB,OACEA,cAAc,QAAQ,OAAOA,cAAc,YAAY,CAACC,MAAMC,OAAO,CAACF,cAAc,CAACG,OAAMC,cAAc,CAACJ;AAE9G"}

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isSlot", {
enumerable: true,
get: function() {
return isSlot;
}
});
const _constants = require("./constants");
function isSlot(element) {
return Boolean(element === null || element === void 0 ? void 0 : element.hasOwnProperty(_constants.SLOT_ELEMENT_TYPE_SYMBOL));
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/compose/isSlot.ts"],"sourcesContent":["import { SLOT_ELEMENT_TYPE_SYMBOL } from './constants';\nimport { SlotComponentType } from './types';\n\n/**\n * Guard method to ensure a given element is a slot.\n * This is mainly used internally to ensure a slot is being used as a component.\n */\nexport function isSlot<Props extends {}>(element: unknown): element is SlotComponentType<Props> {\n return Boolean((element as {} | undefined)?.hasOwnProperty(SLOT_ELEMENT_TYPE_SYMBOL));\n}\n"],"names":["isSlot","element","Boolean","hasOwnProperty","SLOT_ELEMENT_TYPE_SYMBOL"],"mappings":";;;;+BAOgBA;;;eAAAA;;;2BAPyB;AAOlC,SAASA,OAAyBC,OAAgB;IACvD,OAAOC,QAASD,oBAAAA,8BAAD,AAACA,QAA4BE,cAAc,CAACC,mCAAwB;AACrF"}

View File

@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
always: function() {
return always;
},
optional: function() {
return optional;
},
resolveShorthand: function() {
return resolveShorthand;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _constants = require("./constants");
function always(value, options) {
const { defaultProps, elementType } = options;
const props = resolveShorthand(value);
/**
* Casting is required here as SlotComponentType is a function, not an object.
* Although SlotComponentType has a function signature, it is still just an object.
* This is required to make a slot callable (JSX compatible), this is the exact same approach
* that is used on `@types/react` components
*/ const propsWithMetadata = {
...defaultProps,
...props,
[_constants.SLOT_ELEMENT_TYPE_SYMBOL]: elementType,
[_constants.SLOT_CLASS_NAME_PROP_SYMBOL]: (props === null || props === void 0 ? void 0 : props.className) || (defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.className)
};
if (props && typeof props.children === 'function') {
propsWithMetadata[_constants.SLOT_RENDER_FUNCTION_SYMBOL] = props.children;
propsWithMetadata.children = defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.children;
}
return propsWithMetadata;
}
function optional(value, options) {
if (value === null || value === undefined && !options.renderByDefault) {
return undefined;
}
return always(value, options);
}
function resolveShorthand(value) {
if (typeof value === 'string' || typeof value === 'number' || isIterable(value) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
_react.isValidElement(value)) {
return {
children: value
};
}
if (value && typeof value !== 'object' && process.env.NODE_ENV !== 'production') {
// TODO: would be nice to have a link to slot documentation in this error message
// eslint-disable-next-line no-console
console.error(`@fluentui/react-utilities [slot.${resolveShorthand.name}]:
A slot got an invalid value "${value}" (${typeof value}).
A valid value for a slot is a slot shorthand or slot properties object.
Slot shorthands can be strings, numbers, arrays or JSX elements`);
}
return value;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isIterable = (value)=>typeof value === 'object' && value !== null && Symbol.iterator in value;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));

File diff suppressed because one or more lines are too long