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

View File

@@ -0,0 +1,22 @@
"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, {
getEventClientCoords: function() {
return _mouseTouchHelpers.getEventClientCoords;
},
isMouseEvent: function() {
return _mouseTouchHelpers.isMouseEvent;
},
isTouchEvent: function() {
return _mouseTouchHelpers.isTouchEvent;
}
});
const _mouseTouchHelpers = require("./mouseTouchHelpers");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/events/index.ts"],"sourcesContent":["export type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './mouseTouchHelpers';\nexport { getEventClientCoords, isMouseEvent, isTouchEvent } from './mouseTouchHelpers';\n"],"names":["getEventClientCoords","isMouseEvent","isTouchEvent"],"mappings":";;;;;;;;;;;IACSA,oBAAoB;eAApBA,uCAAoB;;IAAEC,YAAY;eAAZA,+BAAY;;IAAEC,YAAY;eAAZA,+BAAY;;;mCAAQ"}

View File

@@ -0,0 +1,54 @@
"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, {
getEventClientCoords: function() {
return getEventClientCoords;
},
isMouseEvent: function() {
return isMouseEvent;
},
isTouchEvent: function() {
return isTouchEvent;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function isTouchEvent(event) {
return event.type.startsWith('touch');
}
function isMouseEvent(event) {
return event.type.startsWith('mouse') || [
'click',
'contextmenu',
'dblclick'
].indexOf(event.type) > -1;
}
function getEventClientCoords(event) {
if (isMouseEvent(event)) {
return {
clientX: event.clientX,
clientY: event.clientY
};
} else if (isTouchEvent(event)) {
return {
clientX: event.touches[0].clientX,
clientY: event.touches[0].clientY
};
} else {
if (process.env.NODE_ENV !== 'production') {
throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');
}
return {
clientX: 0,
clientY: 0
};
}
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/events/mouseTouchHelpers.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;\n\nexport type ReactTouchOrMouseEvent = React.MouseEvent | React.TouchEvent;\n\nexport type TouchOrMouseEvent = NativeTouchOrMouseEvent | ReactTouchOrMouseEvent;\n\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isTouchEvent(event: TouchOrMouseEvent): event is TouchEvent | React.TouchEvent {\n return event.type.startsWith('touch');\n}\n\n/**\n * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.\n */\nexport function isMouseEvent(event: TouchOrMouseEvent): event is MouseEvent | React.MouseEvent {\n return event.type.startsWith('mouse') || ['click', 'contextmenu', 'dblclick'].indexOf(event.type) > -1;\n}\n\n/**\n * Returns an object with clientX, clientY for TouchOrMouseEvent.\n * Returns zeros in case the event is not a mouse or a touch event.\n */\nexport function getEventClientCoords(event: TouchOrMouseEvent): { clientX: number; clientY: number } {\n if (isMouseEvent(event)) {\n return { clientX: event.clientX, clientY: event.clientY };\n } else if (isTouchEvent(event)) {\n return { clientX: event.touches[0].clientX, clientY: event.touches[0].clientY };\n } else {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');\n }\n return { clientX: 0, clientY: 0 };\n }\n}\n"],"names":["getEventClientCoords","isMouseEvent","isTouchEvent","event","type","startsWith","indexOf","clientX","clientY","touches","process","env","NODE_ENV","Error"],"mappings":";;;;;;;;;;;IA0BgBA,oBAAoB;eAApBA;;IARAC,YAAY;eAAZA;;IAPAC,YAAY;eAAZA;;;;iEAXO;AAWhB,SAASA,aAAaC,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC;AAC/B;AAKO,SAASJ,aAAaE,KAAwB;IACnD,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC,YAAY;QAAC;QAAS;QAAe;KAAW,CAACC,OAAO,CAACH,MAAMC,IAAI,IAAI,CAAC;AACvG;AAMO,SAASJ,qBAAqBG,KAAwB;IAC3D,IAAIF,aAAaE,QAAQ;QACvB,OAAO;YAAEI,SAASJ,MAAMI,OAAO;YAAEC,SAASL,MAAMK,OAAO;QAAC;IAC1D,OAAO,IAAIN,aAAaC,QAAQ;QAC9B,OAAO;YAAEI,SAASJ,MAAMM,OAAO,CAAC,EAAE,CAACF,OAAO;YAAEC,SAASL,MAAMM,OAAO,CAAC,EAAE,CAACD,OAAO;QAAC;IAChF,OAAO;QACL,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAM,IAAIC,MAAM;QAClB;QACA,OAAO;YAAEN,SAAS;YAAGC,SAAS;QAAE;IAClC;AACF"}

View File

@@ -0,0 +1,74 @@
"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, {
IdPrefixProvider: function() {
return _useId.IdPrefixProvider;
},
resetIdsForTests: function() {
return _useId.resetIdsForTests;
},
useAnimationFrame: function() {
return _useAnimationFrame.useAnimationFrame;
},
useApplyScrollbarWidth: function() {
return _useApplyScrollbarWidth.useApplyScrollbarWidth;
},
useControllableState: function() {
return _useControllableState.useControllableState;
},
useEventCallback: function() {
return _useEventCallback.useEventCallback;
},
useFirstMount: function() {
return _useFirstMount.useFirstMount;
},
useForceUpdate: function() {
return _useForceUpdate.useForceUpdate;
},
useId: function() {
return _useId.useId;
},
useIsomorphicLayoutEffect: function() {
return _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect;
},
useMergedRefs: function() {
return _useMergedRefs.useMergedRefs;
},
useOnClickOutside: function() {
return _useOnClickOutside.useOnClickOutside;
},
useOnScrollOutside: function() {
return _useOnScrollOutside.useOnScrollOutside;
},
usePrevious: function() {
return _usePrevious.usePrevious;
},
useScrollbarWidth: function() {
return _useScrollbarWidth.useScrollbarWidth;
},
useTimeout: function() {
return _useTimeout.useTimeout;
}
});
const _useAnimationFrame = require("./useAnimationFrame");
const _useApplyScrollbarWidth = require("./useApplyScrollbarWidth");
const _useControllableState = require("./useControllableState");
const _useEventCallback = require("./useEventCallback");
const _useFirstMount = require("./useFirstMount");
const _useForceUpdate = require("./useForceUpdate");
const _useId = require("./useId");
const _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect");
const _useMergedRefs = require("./useMergedRefs");
const _useOnClickOutside = require("./useOnClickOutside");
const _useOnScrollOutside = require("./useOnScrollOutside");
const _usePrevious = require("./usePrevious");
const _useScrollbarWidth = require("./useScrollbarWidth");
const _useTimeout = require("./useTimeout");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/index.ts"],"sourcesContent":["export { useAnimationFrame } from './useAnimationFrame';\nexport { useApplyScrollbarWidth } from './useApplyScrollbarWidth';\nexport type { UseControllableStateOptions } from './useControllableState';\nexport { useControllableState } from './useControllableState';\nexport { useEventCallback } from './useEventCallback';\nexport { useFirstMount } from './useFirstMount';\nexport { useForceUpdate } from './useForceUpdate';\nexport { IdPrefixProvider, resetIdsForTests, useId } from './useId';\nexport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\nexport type { RefObjectFunction } from './useMergedRefs';\nexport { useMergedRefs } from './useMergedRefs';\nexport type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';\nexport { useOnClickOutside } from './useOnClickOutside';\nexport { useOnScrollOutside } from './useOnScrollOutside';\nexport { usePrevious } from './usePrevious';\nexport { useScrollbarWidth } from './useScrollbarWidth';\nexport { useTimeout } from './useTimeout';\n"],"names":["IdPrefixProvider","resetIdsForTests","useAnimationFrame","useApplyScrollbarWidth","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout"],"mappings":";;;;;;;;;;;IAOSA,gBAAgB;eAAhBA,uBAAgB;;IAAEC,gBAAgB;eAAhBA,uBAAgB;;IAPlCC,iBAAiB;eAAjBA,oCAAiB;;IACjBC,sBAAsB;eAAtBA,8CAAsB;;IAEtBC,oBAAoB;eAApBA,0CAAoB;;IACpBC,gBAAgB;eAAhBA,kCAAgB;;IAChBC,aAAa;eAAbA,4BAAa;;IACbC,cAAc;eAAdA,8BAAc;;IACsBC,KAAK;eAALA,YAAK;;IACzCC,yBAAyB;eAAzBA,oDAAyB;;IAEzBC,aAAa;eAAbA,4BAAa;;IAEbC,iBAAiB;eAAjBA,oCAAiB;;IACjBC,kBAAkB;eAAlBA,sCAAkB;;IAClBC,WAAW;eAAXA,wBAAW;;IACXC,iBAAiB;eAAjBA,oCAAiB;;IACjBC,UAAU;eAAVA,sBAAU;;;mCAhBe;wCACK;sCAEF;kCACJ;+BACH;gCACC;uBAC2B;2CAChB;+BAEZ;mCAEI;oCACC;6BACP;mCACM;4BACP"}

View File

@@ -0,0 +1,25 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useAnimationFrame", {
enumerable: true,
get: function() {
return useAnimationFrame;
}
});
const _useBrowserTimer = require("./useBrowserTimer");
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
const setAnimationFrameNoop = (callback)=>{
callback(0);
return 0;
};
const cancelAnimationFrameNoop = (handle)=>handle;
function useAnimationFrame() {
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;
const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;
return (0, _useBrowserTimer.useBrowserTimer)(setAnimationFrame, clearAnimationFrame);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useAnimationFrame.ts"],"sourcesContent":["'use client';\n\nimport { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst setAnimationFrameNoop = (callback: FrameRequestCallback) => {\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle: number) => handle;\n\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */\nexport function useAnimationFrame(): readonly [(fn: FrameRequestCallback) => number, () => void] {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;\n\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame) as [(fn: FrameRequestCallback) => number, () => void];\n}\n"],"names":["useAnimationFrame","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","targetDocument","useFluent","win","defaultView","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame","useBrowserTimer"],"mappings":"AAAA;;;;;+BAmBgBA;;;eAAAA;;;iCAjBgB;qCACgB;AAEhD,MAAMC,wBAAwB,CAACC;IAC7BA,SAAS;IACT,OAAO;AACT;AACA,MAAMC,2BAA2B,CAACC,SAAmBA;AAU9C,SAASJ;IACd,MAAM,EAAEK,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,MAAMF,2BAAAA,qCAAAA,eAAgBG,WAAW;IAEvC,MAAMC,oBAAoBF,MAAMA,IAAIG,qBAAqB,GAAGT;IAC5D,MAAMU,sBAAsBJ,MAAMA,IAAIK,oBAAoB,GAAGT;IAE7D,OAAOU,IAAAA,gCAAe,EAACJ,mBAAmBE;AAC5C"}

View File

@@ -0,0 +1,39 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useApplyScrollbarWidth", {
enumerable: true,
get: function() {
return useApplyScrollbarWidth;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _measureScrollBarWidth = require("../utils/measureScrollBarWidth");
const cache = new WeakMap();
function useApplyScrollbarWidth(options = {}) {
const { force, property = 'width' } = options;
const applyScrollbarWidth = _react.useCallback((element)=>{
if (!element) {
return;
}
// If we have a cached value, use it
if (!force && cache.has(element.ownerDocument)) {
const cachedWidth = cache.get(element.ownerDocument);
if (cachedWidth !== undefined) {
element.style.setProperty(property, `${cachedWidth}px`);
return;
}
}
// Measure the scrollbar width and apply it to the element
const scrollbarWidth = (0, _measureScrollBarWidth.measureScrollbarWidth)(element.ownerDocument);
cache.set(element.ownerDocument, scrollbarWidth);
element.style.setProperty(property, `${scrollbarWidth}px`);
}, [
force,
property
]);
return applyScrollbarWidth;
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useApplyScrollbarWidth.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { measureScrollbarWidth } from '../utils/measureScrollBarWidth';\n\nconst cache = new WeakMap<Document, number>();\n\ninterface UseApplyScrollbarWidthOptions {\n /**\n * Does not use the cache and recalculates the scrollbar width\n */\n force?: boolean;\n\n /**\n * CSS property to apply the scrollbar width to.\n * @default 'width'\n */\n property?: string;\n}\n\n/**\n * A React hook that provides a ref for applying the browser's scrollbar width as a CSS property.\n *\n * This hook is SSR-safe and caches measurements per document to avoid redundant calculations.\n * When the ref is attached to an element, the hook automatically applies the measured scrollbar\n * width to the specified CSS property (defaults to 'width').\n *\n * @example\n * ```tsx\n * const scrollbarRef = useApplyScrollbarWidth({ targetDocument: document });\n * return <div ref={scrollbarRef} />;\n * ```\n */\nexport function useApplyScrollbarWidth<T extends HTMLElement>(\n options: UseApplyScrollbarWidthOptions = {},\n): React.RefCallback<T> {\n const { force, property = 'width' } = options;\n\n const applyScrollbarWidth = React.useCallback(\n (element: T | null) => {\n if (!element) {\n return;\n }\n\n // If we have a cached value, use it\n if (!force && cache.has(element.ownerDocument)) {\n const cachedWidth = cache.get(element.ownerDocument);\n if (cachedWidth !== undefined) {\n element.style.setProperty(property, `${cachedWidth}px`);\n return;\n }\n }\n\n // Measure the scrollbar width and apply it to the element\n const scrollbarWidth = measureScrollbarWidth(element.ownerDocument);\n cache.set(element.ownerDocument, scrollbarWidth);\n element.style.setProperty(property, `${scrollbarWidth}px`);\n },\n [force, property],\n );\n\n return applyScrollbarWidth;\n}\n"],"names":["useApplyScrollbarWidth","cache","WeakMap","options","force","property","applyScrollbarWidth","React","useCallback","element","has","ownerDocument","cachedWidth","get","undefined","style","setProperty","scrollbarWidth","measureScrollbarWidth","set"],"mappings":"AAAA;;;;;+BAiCgBA;;;eAAAA;;;;iEA/BO;uCACe;AAEtC,MAAMC,QAAQ,IAAIC;AA4BX,SAASF,uBACdG,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,KAAK,EAAEC,WAAW,OAAO,EAAE,GAAGF;IAEtC,MAAMG,sBAAsBC,OAAMC,WAAW,CAC3C,CAACC;QACC,IAAI,CAACA,SAAS;YACZ;QACF;QAEA,oCAAoC;QACpC,IAAI,CAACL,SAASH,MAAMS,GAAG,CAACD,QAAQE,aAAa,GAAG;YAC9C,MAAMC,cAAcX,MAAMY,GAAG,CAACJ,QAAQE,aAAa;YACnD,IAAIC,gBAAgBE,WAAW;gBAC7BL,QAAQM,KAAK,CAACC,WAAW,CAACX,UAAU,GAAGO,YAAY,EAAE,CAAC;gBACtD;YACF;QACF;QAEA,0DAA0D;QAC1D,MAAMK,iBAAiBC,IAAAA,4CAAqB,EAACT,QAAQE,aAAa;QAClEV,MAAMkB,GAAG,CAACV,QAAQE,aAAa,EAAEM;QACjCR,QAAQM,KAAK,CAACC,WAAW,CAACX,UAAU,GAAGY,eAAe,EAAE,CAAC;IAC3D,GACA;QAACb;QAAOC;KAAS;IAGnB,OAAOC;AACT"}

View File

@@ -0,0 +1,42 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useBrowserTimer", {
enumerable: true,
get: function() {
return useBrowserTimer;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function useBrowserTimer(setTimer, cancelTimer) {
const id = _react.useRef(undefined);
const set = _react.useCallback((fn, delay)=>{
if (id.current !== undefined) {
cancelTimer(id.current);
}
id.current = setTimer(fn, delay);
return id.current;
}, [
cancelTimer,
setTimer
]);
const cancel = _react.useCallback(()=>{
if (id.current !== undefined) {
cancelTimer(id.current);
id.current = undefined;
}
}, [
cancelTimer
]);
// Clean up the timeout when the component is unloaded
_react.useEffect(()=>cancel, [
cancel
]);
return [
set,
cancel
];
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useBrowserTimer.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\ntype BrowserTimerSetter =\n | ((fn: () => void, duration?: number, ...args: Record<string, unknown>[]) => number)\n | ((fn: () => void) => number);\n\n/**\n * @internal\n * Helper to manage a browser timer.\n * Ensures that the timer isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @param setTimer - The timer setter function\n * @param cancelTimer - The timer cancel function\n * @returns A pair of [setTimer, cancelTimer] that are stable between renders.\n *\n * @example\n * const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);\n *\n * setTimer(() => console.log('Hello world!'), 1000);\n * cancelTimer();\n */\nexport function useBrowserTimer(\n setTimer: BrowserTimerSetter,\n cancelTimer: (id: number) => void,\n): [(fn: () => void, delay?: number) => number, () => void] {\n const id = React.useRef<number | undefined>(undefined);\n\n const set = React.useCallback(\n (fn: () => void, delay?: number) => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n }\n\n id.current = setTimer(fn, delay);\n return id.current;\n },\n [cancelTimer, setTimer],\n );\n\n const cancel = React.useCallback(() => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n id.current = undefined;\n }\n }, [cancelTimer]);\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => cancel, [cancel]);\n\n return [set, cancel] as const;\n}\n"],"names":["useBrowserTimer","setTimer","cancelTimer","id","React","useRef","undefined","set","useCallback","fn","delay","current","cancel","useEffect"],"mappings":"AAAA;;;;;+BAwBgBA;;;eAAAA;;;;iEAtBO;AAsBhB,SAASA,gBACdC,QAA4B,EAC5BC,WAAiC;IAEjC,MAAMC,KAAKC,OAAMC,MAAM,CAAqBC;IAE5C,MAAMC,MAAMH,OAAMI,WAAW,CAC3B,CAACC,IAAgBC;QACf,IAAIP,GAAGQ,OAAO,KAAKL,WAAW;YAC5BJ,YAAYC,GAAGQ,OAAO;QACxB;QAEAR,GAAGQ,OAAO,GAAGV,SAASQ,IAAIC;QAC1B,OAAOP,GAAGQ,OAAO;IACnB,GACA;QAACT;QAAaD;KAAS;IAGzB,MAAMW,SAASR,OAAMI,WAAW,CAAC;QAC/B,IAAIL,GAAGQ,OAAO,KAAKL,WAAW;YAC5BJ,YAAYC,GAAGQ,OAAO;YACtBR,GAAGQ,OAAO,GAAGL;QACf;IACF,GAAG;QAACJ;KAAY;IAEhB,sDAAsD;IACtDE,OAAMS,SAAS,CAAC,IAAMD,QAAQ;QAACA;KAAO;IAEtC,OAAO;QAACL;QAAKK;KAAO;AACtB"}

View File

@@ -0,0 +1,87 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useControllableState", {
enumerable: true,
get: function() {
return useControllableState;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function isFactoryDispatch(newState) {
return typeof newState === 'function';
}
const useControllableState = (options)=>{
'use no memo';
if (process.env.NODE_ENV !== 'production') {
if (options.state !== undefined && options.defaultState !== undefined) {
// eslint-disable-next-line no-console
console.error(`@fluentui/react-utilities [useControllableState]:
A component must be either controlled or uncontrolled (specify either the state or the defaultState, but not both).
Decide between using a controlled or uncontrolled component and remove one of this props.
More info: https://reactjs.org/link/controlled-components
${new Error().stack}`);
}
}
const [internalState, setInternalState] = _react.useState(()=>{
if (options.defaultState === undefined) {
return options.initialState;
}
return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;
});
// Heads up!
// This part is specific for controlled mode and mocks behavior of React dispatcher function.
const stateValueRef = _react.useRef(options.state);
_react.useEffect(()=>{
stateValueRef.current = options.state;
}, [
options.state
]);
const setControlledState = _react.useCallback((newState)=>{
if (isFactoryDispatch(newState)) {
newState(stateValueRef.current);
}
}, []);
return useIsControlled(options.state) ? [
options.state,
setControlledState
] : [
internalState,
setInternalState
];
};
function isInitializer(value) {
return typeof value === 'function';
}
/**
* Helper hook to handle previous comparison of controlled/uncontrolled
* Prints an error when isControlled value switches between subsequent renders
* @returns - whether the value is controlled
*/ const useIsControlled = (controlledValue)=>{
'use no memo';
const [isControlled] = _react.useState(()=>controlledValue !== undefined);
if (process.env.NODE_ENV !== 'production') {
// We don't want these warnings in production even though it is against native behaviour
// eslint-disable-next-line react-hooks/rules-of-hooks
_react.useEffect(()=>{
if (isControlled !== (controlledValue !== undefined)) {
const error = new Error();
const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
// eslint-disable-next-line no-console
console.error(`@fluentui/react-utilities [useControllableState]:
A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.
Decide between using a controlled or uncontrolled input element for the lifetime of the component.
More info: https://reactjs.org/link/controlled-components
${error.stack}`);
}
}, [
isControlled,
controlledValue
]);
}
return isControlled;
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,30 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useEventCallback", {
enumerable: true,
get: function() {
return useEventCallback;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect");
const useEventCallback = (fn)=>{
const callbackRef = _react.useRef(()=>{
throw new Error('Cannot call an event handler while rendering');
});
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(()=>{
callbackRef.current = fn;
}, [
fn
]);
return _react.useCallback((...args)=>{
const callback = callbackRef.current;
return callback(...args);
}, [
callbackRef
]);
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useEventCallback.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\n/**\n * @internal\n * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n *\n * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when\n * e.g. user props are dependencies which could change on every render\n * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently\n *\n * This should not be used often, but can be a useful re-render optimization since the callback is a ref and\n * will not be invalidated between re-renders\n *\n * @param fn - The callback function that will be used\n */\nexport const useEventCallback = <Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): ((...args: Args) => Return) => {\n const callbackRef = React.useRef<typeof fn>(() => {\n throw new Error('Cannot call an event handler while rendering');\n });\n\n useIsomorphicLayoutEffect(() => {\n callbackRef.current = fn;\n }, [fn]);\n\n return React.useCallback(\n (...args: Args) => {\n const callback = callbackRef.current;\n return callback(...args);\n },\n [callbackRef],\n );\n};\n"],"names":["useEventCallback","fn","callbackRef","React","useRef","Error","useIsomorphicLayoutEffect","current","useCallback","args","callback"],"mappings":"AAAA;;;;;+BAkBaA;;;eAAAA;;;;iEAhBU;2CACmB;AAenC,MAAMA,mBAAmB,CAC9BC;IAEA,MAAMC,cAAcC,OAAMC,MAAM,CAAY;QAC1C,MAAM,IAAIC,MAAM;IAClB;IAEAC,IAAAA,oDAAyB,EAAC;QACxBJ,YAAYK,OAAO,GAAGN;IACxB,GAAG;QAACA;KAAG;IAEP,OAAOE,OAAMK,WAAW,CACtB,CAAC,GAAGC;QACF,MAAMC,WAAWR,YAAYK,OAAO;QACpC,OAAOG,YAAYD;IACrB,GACA;QAACP;KAAY;AAEjB"}

View File

@@ -0,0 +1,22 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useFirstMount", {
enumerable: true,
get: function() {
return useFirstMount;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function useFirstMount() {
const isFirst = _react.useRef(true);
_react.useEffect(()=>{
if (isFirst.current) {
isFirst.current = false;
}
}, []);
return isFirst.current;
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useFirstMount.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Supports React concurrent/strict mode by using `useEffect`\n * to track the first mount instead of mutating refs during render.\n *\n * @example\n * const isFirstMount = useFirstMount();\n */\nexport function useFirstMount(): boolean {\n const isFirst = React.useRef(true);\n\n React.useEffect(() => {\n if (isFirst.current) {\n isFirst.current = false;\n }\n }, []);\n\n return isFirst.current;\n}\n"],"names":["useFirstMount","isFirst","React","useRef","useEffect","current"],"mappings":"AAAA;;;;;+BAagBA;;;eAAAA;;;;iEAXO;AAWhB,SAASA;IACd,MAAMC,UAAUC,OAAMC,MAAM,CAAC;IAE7BD,OAAME,SAAS,CAAC;QACd,IAAIH,QAAQI,OAAO,EAAE;YACnBJ,QAAQI,OAAO,GAAG;QACpB;IACF,GAAG,EAAE;IAEL,OAAOJ,QAAQI,OAAO;AACxB"}

View File

@@ -0,0 +1,16 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useForceUpdate", {
enumerable: true,
get: function() {
return useForceUpdate;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function useForceUpdate() {
return _react.useReducer((x)=>x + 1, 0)[1];
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useForceUpdate.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate(): React.DispatchWithoutAction {\n return React.useReducer(x => x + 1, 0)[1];\n}\n"],"names":["useForceUpdate","React","useReducer","x"],"mappings":"AAAA;;;;;+BAOgBA;;;eAAAA;;;;iEALO;AAKhB,SAASA;IACd,OAAOC,OAAMC,UAAU,CAACC,CAAAA,IAAKA,IAAI,GAAG,EAAE,CAAC,EAAE;AAC3C"}

View File

@@ -0,0 +1,63 @@
'use client';
"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, {
IdPrefixProvider: function() {
return IdPrefixProvider;
},
resetIdsForTests: function() {
return resetIdsForTests;
},
useId: function() {
return useId;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _index = require("../ssr/index");
const IdPrefixContext = _react.createContext(undefined);
const IdPrefixProvider = IdPrefixContext.Provider;
function useIdPrefix() {
return _react.useContext(IdPrefixContext) || '';
}
function resetIdsForTests() {
_index.defaultSSRContextValue.current = 0;
}
function useId(prefix = 'fui-', providedId) {
'use no memo';
const contextValue = (0, _index.useSSRContext)();
const idPrefix = useIdPrefix();
// Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to
// prevent bundlers from complaining with older versions of React.
const _useId = _react['use' + 'Id'];
if (_useId) {
const generatedId = _useId();
// eslint-disable-next-line react-hooks/rules-of-hooks
const escapedId = _react.useMemo(()=>generatedId.replace(/:/g, ''), [
generatedId
]);
return providedId || `${idPrefix}${prefix}${escapedId}`;
}
// Hooks appear to be running conditionally, but they will always run in the same order since it's based on
// the version of React being used. This is safe to ignore.
// eslint-disable-next-line react-hooks/rules-of-hooks
return _react.useMemo(()=>{
if (providedId) {
return providedId;
}
return `${idPrefix}${prefix}${++contextValue.current}`;
}, [
idPrefix,
prefix,
providedId,
contextValue
]);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useId.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\nconst IdPrefixContext = React.createContext<string | undefined>(undefined);\n\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\n\nfunction useIdPrefix(): string {\n return React.useContext(IdPrefixContext) || '';\n}\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n 'use no memo';\n\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = (React as never)['use' + 'Id'] as (() => string) | undefined;\n\n if (_useId) {\n const generatedId = _useId();\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);\n\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n"],"names":["IdPrefixProvider","resetIdsForTests","useId","IdPrefixContext","React","createContext","undefined","Provider","useIdPrefix","useContext","defaultSSRContextValue","current","prefix","providedId","contextValue","useSSRContext","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"mappings":"AAAA;;;;;;;;;;;;IAWaA,gBAAgB;eAAhBA;;IASGC,gBAAgB;eAAhBA;;IAYAC,KAAK;eAALA;;;;iEA9BO;uBAC+B;AAEtD,MAAMC,kBAAkBC,OAAMC,aAAa,CAAqBC;AAMzD,MAAMN,mBAAmBG,gBAAgBI,QAAQ;AAExD,SAASC;IACP,OAAOJ,OAAMK,UAAU,CAACN,oBAAoB;AAC9C;AAKO,SAASF;IACdS,6BAAsB,CAACC,OAAO,GAAG;AACnC;AAUO,SAAST,MAAMU,SAAiB,MAAM,EAAEC,UAAmB;IAChE;IAEA,MAAMC,eAAeC,IAAAA,oBAAa;IAClC,MAAMC,WAAWR;IAEjB,mHAAmH;IACnH,kEAAkE;IAClE,MAAMS,SAAS,AAACb,MAAe,CAAC,QAAQ,KAAK;IAE7C,IAAIa,QAAQ;QACV,MAAMC,cAAcD;QAEpB,sDAAsD;QACtD,MAAME,YAAYf,OAAMgB,OAAO,CAAC,IAAMF,YAAYG,OAAO,CAAC,MAAM,KAAK;YAACH;SAAY;QAElF,OAAOL,cAAc,GAAGG,WAAWJ,SAASO,WAAW;IACzD;IAEA,2GAA2G;IAC3G,2DAA2D;IAC3D,sDAAsD;IACtD,OAAOf,OAAMgB,OAAO,CAAC;QACnB,IAAIP,YAAY;YACd,OAAOA;QACT;QAEA,OAAO,GAAGG,WAAWJ,SAAS,EAAEE,aAAaH,OAAO,EAAE;IACxD,GAAG;QAACK;QAAUJ;QAAQC;QAAYC;KAAa;AACjD"}

View File

@@ -0,0 +1,15 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useIsomorphicLayoutEffect", {
enumerable: true,
get: function() {
return useIsomorphicLayoutEffect;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _index = require("../ssr/index");
const useIsomorphicLayoutEffect = (0, _index.canUseDOM)() ? _react.useLayoutEffect : _react.useEffect;

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useIsomorphicLayoutEffect.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */\n// eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect: typeof React.useEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"],"names":["useIsomorphicLayoutEffect","canUseDOM","React","useLayoutEffect","useEffect"],"mappings":"AAAA;;;;;+BAeaA;;;eAAAA;;;;iEAbU;uBACG;AAYnB,MAAMA,4BAAoDC,IAAAA,gBAAS,MAAKC,OAAMC,eAAe,GAAGD,OAAME,SAAS"}

View File

@@ -0,0 +1,39 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useMergedRefs", {
enumerable: true,
get: function() {
return useMergedRefs;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function useMergedRefs(...refs) {
'use no memo';
const mergedCallback = _react.useCallback((value)=>{
// Update the "current" prop hanging on the function.
mergedCallback.current = value;
for (const ref of refs){
if (typeof ref === 'string' && process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.error(`@fluentui/react-utilities [useMergedRefs]:
This hook does not support the usage of string refs. Please use React.useRef instead.
For more info on 'React.useRef', see https://react.dev/reference/react/useRef.
For more info on string refs, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs.`);
}
if (typeof ref === 'function') {
ref(value);
} else if (ref) {
ref.current = value;
}
}
}, // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive
[
...refs
]);
return mergedCallback;
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useMergedRefs.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T | null> & ((value: T | null) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\n// LegacyRef is actually not supported, but in React v18 types this is leaking directly from forwardRef component declaration\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n 'use no memo';\n\n const mergedCallback = React.useCallback(\n (value: T | null) => {\n // Update the \"current\" prop hanging on the function.\n mergedCallback.current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'string' && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useMergedRefs]:\n This hook does not support the usage of string refs. Please use React.useRef instead.\n\n For more info on 'React.useRef', see https://react.dev/reference/react/useRef.\n For more info on string refs, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs.\n `);\n }\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"],"names":["useMergedRefs","refs","mergedCallback","React","useCallback","value","current","ref","process","env","NODE_ENV","console","error"],"mappings":"AAAA;;;;;+BAiBgBA;;;eAAAA;;;;iEAfO;AAehB,SAASA,cAAiB,GAAGC,IAAkC;IACpE;IAEA,MAAMC,iBAAiBC,OAAMC,WAAW,CACtC,CAACC;QACC,qDAAqD;QACrDH,eAAeI,OAAO,GAAGD;QAEzB,KAAK,MAAME,OAAON,KAAM;YACtB,IAAI,OAAOM,QAAQ,YAAYC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;gBACpE,sCAAsC;gBACtCC,QAAQC,KAAK,CAAuB,CAAC;;;;+GAMrC,CAAC;YACH;YACA,IAAI,OAAOL,QAAQ,YAAY;gBAC7BA,IAAIF;YACN,OAAO,IAAIE,KAAK;gBACdA,IAAID,OAAO,GAAGD;YAChB;QACF;IACF,GACA,6EAA6E;IAC7E;WAAIJ;KAAK;IAGX,OAAOC;AACT"}

View File

@@ -0,0 +1,158 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useOnClickOutside", {
enumerable: true,
get: function() {
return useOnClickOutside;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _useEventCallback = require("./useEventCallback");
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
const DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
const useOnClickOutside = (options)=>{
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
const { refs, callback, element, disabled, disabledFocusOnIframe, contains = DEFAULT_CONTAINS } = options;
const timeoutId = _react.useRef(undefined);
useIFrameFocus({
element,
disabled: disabledFocusOnIframe || disabled,
callback,
refs,
contains
});
const isMouseDownInsideRef = _react.useRef(false);
const listener = (0, _useEventCallback.useEventCallback)((ev)=>{
if (isMouseDownInsideRef.current) {
isMouseDownInsideRef.current = false;
return;
}
const target = ev.composedPath()[0];
const isOutside = refs.every((ref)=>!contains(ref.current || null, target));
if (isOutside && !disabled) {
callback(ev);
}
});
const handleMouseDown = (0, _useEventCallback.useEventCallback)((ev)=>{
// Selecting text from inside to outside will rigger click event.
// In this case click event target is outside but mouse down event target is inside.
// And this click event should be considered as inside click.
isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));
});
_react.useEffect(()=>{
if (disabled) {
return;
}
// Store the current event to avoid triggering handlers immediately
// Note this depends on a deprecated but extremely well supported quirk of the web platform
// https://github.com/facebook/react/issues/20074
let currentEvent = getWindowEvent(win);
const conditionalHandler = (event)=>{
// Skip if this event is the same as the one running when we added the handlers
if (event === currentEvent) {
currentEvent = undefined;
return;
}
listener(event);
};
// use capture phase because React can update DOM before the event bubbles to the document
element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
// Garbage collect this event after it's no longer useful to avoid memory leaks
timeoutId.current = win === null || win === void 0 ? void 0 : win.setTimeout(()=>{
currentEvent = undefined;
}, 1);
return ()=>{
element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);
element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);
win === null || win === void 0 ? void 0 : win.clearTimeout(timeoutId.current);
currentEvent = undefined;
};
}, [
listener,
element,
disabled,
handleMouseDown,
win
]);
};
const getWindowEvent = (target)=>{
if (target) {
var _target_ownerDocument_defaultView, _target_ownerDocument;
if (typeof target.window === 'object' && target.window === target) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return target.event;
}
var _target_ownerDocument_defaultView_event;
// eslint-disable-next-line @typescript-eslint/no-deprecated
return (_target_ownerDocument_defaultView_event = (_target_ownerDocument = target.ownerDocument) === null || _target_ownerDocument === void 0 ? void 0 : (_target_ownerDocument_defaultView = _target_ownerDocument.defaultView) === null || _target_ownerDocument_defaultView === void 0 ? void 0 : _target_ownerDocument_defaultView.event) !== null && _target_ownerDocument_defaultView_event !== void 0 ? _target_ownerDocument_defaultView_event : undefined;
}
return undefined;
};
const FUI_FRAME_EVENT = 'fuiframefocus';
/**
* Since click events do not propagate past iframes, we use focus to detect if a
* click has happened inside an iframe, since the only ways of focusing inside an
* iframe are:
* - clicking inside
* - tabbing inside
*
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
* a custom DOM event. When the custom event is received call the provided callback
*/ const useIFrameFocus = (options)=>{
const { disabled, element: targetDocument, callback, contains = DEFAULT_CONTAINS, pollDuration = 100, refs } = options;
const timeoutRef = _react.useRef(undefined);
const listener = (0, _useEventCallback.useEventCallback)((e)=>{
const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));
if (isOutside && !disabled) {
callback(e);
}
});
// Adds listener to the custom iframe focus event
_react.useEffect(()=>{
if (disabled) {
return;
}
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);
return ()=>{
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);
};
}, [
targetDocument,
disabled,
listener
]);
// Starts polling for the active element
_react.useEffect(()=>{
var _targetDocument_defaultView;
if (disabled) {
return;
}
timeoutRef.current = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.setInterval(()=>{
const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {
const event = new CustomEvent(FUI_FRAME_EVENT, {
bubbles: true
});
activeElement.dispatchEvent(event);
}
}, pollDuration);
return ()=>{
var _targetDocument_defaultView;
targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.clearInterval(timeoutRef.current);
};
}, [
targetDocument,
disabled,
pollDuration
]);
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useOnScrollOutside", {
enumerable: true,
get: function() {
return useOnScrollOutside;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _useEventCallback = require("./useEventCallback");
const useOnScrollOutside = (options)=>{
const { refs, callback, element, disabled, contains: containsProp } = options;
const listener = (0, _useEventCallback.useEventCallback)((ev)=>{
const contains = containsProp || ((parent, child)=>!!(parent === null || parent === void 0 ? void 0 : parent.contains(child)));
const target = ev.composedPath()[0];
const isOutside = refs.every((ref)=>!contains(ref.current || null, target));
if (isOutside && !disabled) {
callback(ev);
}
});
_react.useEffect(()=>{
if (disabled) {
return;
}
element === null || element === void 0 ? void 0 : element.addEventListener('wheel', listener);
element === null || element === void 0 ? void 0 : element.addEventListener('touchmove', listener);
return ()=>{
element === null || element === void 0 ? void 0 : element.removeEventListener('wheel', listener);
element === null || element === void 0 ? void 0 : element.removeEventListener('touchmove', listener);
};
}, [
listener,
element,
disabled
]);
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useOnScrollOutside.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nimport type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnScrollOutside = (options: UseOnClickOrScrollOutsideOptions): void => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const target = ev.composedPath()[0] as HTMLElement;\n const isOutside = refs.every(ref => !contains(ref.current || null, target));\n\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n element?.addEventListener('wheel', listener);\n element?.addEventListener('touchmove', listener);\n\n return () => {\n element?.removeEventListener('wheel', listener);\n element?.removeEventListener('touchmove', listener);\n };\n }, [listener, element, disabled]);\n};\n"],"names":["useOnScrollOutside","options","refs","callback","element","disabled","contains","containsProp","listener","useEventCallback","ev","parent","child","target","composedPath","isOutside","every","ref","current","React","useEffect","addEventListener","removeEventListener"],"mappings":"AAAA;;;;;+BAUaA;;;eAAAA;;;;iEARU;kCACU;AAO1B,MAAMA,qBAAqB,CAACC;IACjC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,UAAUC,YAAY,EAAE,GAAGN;IAEtE,MAAMO,WAAWC,IAAAA,kCAAgB,EAAC,CAACC;QACjC,MAAMJ,WACJC,gBAAiB,CAAA,CAACI,QAAQC,QAAU,CAAC,EAACD,mBAAAA,6BAAAA,OAAQL,QAAQ,CAACM,OAAK;QAE9D,MAAMC,SAASH,GAAGI,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYb,KAAKc,KAAK,CAACC,CAAAA,MAAO,CAACX,SAASW,IAAIC,OAAO,IAAI,MAAML;QAEnE,IAAIE,aAAa,CAACV,UAAU;YAC1BF,SAASO;QACX;IACF;IAEAS,OAAMC,SAAS,CAAC;QACd,IAAIf,UAAU;YACZ;QACF;QAEAD,oBAAAA,8BAAAA,QAASiB,gBAAgB,CAAC,SAASb;QACnCJ,oBAAAA,8BAAAA,QAASiB,gBAAgB,CAAC,aAAab;QAEvC,OAAO;YACLJ,oBAAAA,8BAAAA,QAASkB,mBAAmB,CAAC,SAASd;YACtCJ,oBAAAA,8BAAAA,QAASkB,mBAAmB,CAAC,aAAad;QAC5C;IACF,GAAG;QAACA;QAAUJ;QAASC;KAAS;AAClC"}

View File

@@ -0,0 +1,22 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "usePrevious", {
enumerable: true,
get: function() {
return usePrevious;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const usePrevious = (value)=>{
const ref = _react.useRef(null);
_react.useEffect(()=>{
ref.current = value;
}, [
value
]);
return ref.current;
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/usePrevious.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n/**\n * @internal\n */\nexport const usePrevious = <ValueType = unknown>(value: ValueType): ValueType | null => {\n const ref = React.useRef<ValueType | null>(null);\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref.current;\n};\n"],"names":["usePrevious","value","ref","React","useRef","useEffect","current"],"mappings":"AAAA;;;;;+BAOaA;;;eAAAA;;;;iEALU;AAKhB,MAAMA,cAAc,CAAsBC;IAC/C,MAAMC,MAAMC,OAAMC,MAAM,CAAmB;IAC3CD,OAAME,SAAS,CAAC;QACdH,IAAII,OAAO,GAAGL;IAChB,GAAG;QAACA;KAAM;IACV,OAAOC,IAAII,OAAO;AACpB"}

View File

@@ -0,0 +1,32 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useScrollbarWidth", {
enumerable: true,
get: function() {
return useScrollbarWidth;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _measureScrollBarWidth = require("../utils/measureScrollBarWidth");
const cache = new WeakMap();
function useScrollbarWidth(options) {
const { targetDocument, force } = options;
return _react.useMemo(()=>{
if (!targetDocument) {
return 0;
}
if (!force && cache.has(targetDocument)) {
return cache.get(targetDocument);
}
const scrollbarWidth = (0, _measureScrollBarWidth.measureScrollbarWidth)(targetDocument);
cache.set(targetDocument, scrollbarWidth);
return scrollbarWidth;
}, [
targetDocument,
force
]);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useScrollbarWidth.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { measureScrollbarWidth } from '../utils/measureScrollBarWidth';\n\nconst cache = new WeakMap<Document, number>();\n\ninterface UseScrollbarWidthOptions {\n /**\n * Reference document to measure the scrollbar width\n */\n targetDocument: Document | null | undefined;\n\n /**\n * Does not use the cache and recalculates the scrollbar width\n */\n force?: boolean;\n}\n\n/**\n * @returns The width in pixels of the scrollbar in the user agent\n * @remarks This hook is not SSR-safe. For SSR-safe scrollbar width application, use the `useApplyScrollbarWidth` from {@link file://./useApplyScrollbarWidth.ts} instead.\n */\nexport function useScrollbarWidth(options: UseScrollbarWidthOptions): number | undefined {\n const { targetDocument, force } = options;\n\n return React.useMemo(() => {\n if (!targetDocument) {\n return 0;\n }\n\n if (!force && cache.has(targetDocument)) {\n return cache.get(targetDocument);\n }\n\n const scrollbarWidth = measureScrollbarWidth(targetDocument);\n cache.set(targetDocument, scrollbarWidth);\n\n return scrollbarWidth;\n }, [targetDocument, force]);\n}\n"],"names":["useScrollbarWidth","cache","WeakMap","options","targetDocument","force","React","useMemo","has","get","scrollbarWidth","measureScrollbarWidth","set"],"mappings":"AAAA;;;;;+BAuBgBA;;;eAAAA;;;;iEArBO;uCACe;AAEtC,MAAMC,QAAQ,IAAIC;AAkBX,SAASF,kBAAkBG,OAAiC;IACjE,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAE,GAAGF;IAElC,OAAOG,OAAMC,OAAO,CAAC;QACnB,IAAI,CAACH,gBAAgB;YACnB,OAAO;QACT;QAEA,IAAI,CAACC,SAASJ,MAAMO,GAAG,CAACJ,iBAAiB;YACvC,OAAOH,MAAMQ,GAAG,CAACL;QACnB;QAEA,MAAMM,iBAAiBC,IAAAA,4CAAqB,EAACP;QAC7CH,MAAMW,GAAG,CAACR,gBAAgBM;QAE1B,OAAOA;IACT,GAAG;QAACN;QAAgBC;KAAM;AAC5B"}

View File

@@ -0,0 +1,22 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useTimeout", {
enumerable: true,
get: function() {
return useTimeout;
}
});
const _useBrowserTimer = require("./useBrowserTimer");
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
const setTimeoutNoop = (_callback)=>-1;
const clearTimeoutNoop = (_handle)=>undefined;
function useTimeout() {
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
const setTimerFn = win ? win.setTimeout : setTimeoutNoop;
const clearTimerFn = win ? win.clearTimeout : clearTimeoutNoop;
return (0, _useBrowserTimer.useBrowserTimer)(setTimerFn, clearTimerFn);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hooks/useTimeout.ts"],"sourcesContent":["'use client';\n\nimport { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst setTimeoutNoop = (_callback: Function) => -1;\nconst clearTimeoutNoop = (_handle: number) => undefined;\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout(): readonly [(fn: () => void, delay?: number) => number, () => void] {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const setTimerFn = win ? win.setTimeout : setTimeoutNoop;\n const clearTimerFn = win ? win.clearTimeout : clearTimeoutNoop;\n\n return useBrowserTimer(setTimerFn, clearTimerFn);\n}\n"],"names":["useTimeout","setTimeoutNoop","_callback","clearTimeoutNoop","_handle","undefined","targetDocument","useFluent","win","defaultView","setTimerFn","setTimeout","clearTimerFn","clearTimeout","useBrowserTimer"],"mappings":"AAAA;;;;;+BAgBgBA;;;eAAAA;;;iCAdgB;qCACgB;AAEhD,MAAMC,iBAAiB,CAACC,YAAwB,CAAC;AACjD,MAAMC,mBAAmB,CAACC,UAAoBC;AAUvC,SAASL;IACd,MAAM,EAAEM,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,MAAMF,2BAAAA,qCAAAA,eAAgBG,WAAW;IAEvC,MAAMC,aAAaF,MAAMA,IAAIG,UAAU,GAAGV;IAC1C,MAAMW,eAAeJ,MAAMA,IAAIK,YAAY,GAAGV;IAE9C,OAAOW,IAAAA,gCAAe,EAACJ,YAAYE;AACrC"}

View File

@@ -0,0 +1,177 @@
"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, {
IdPrefixProvider: function() {
return _index1.IdPrefixProvider;
},
SLOT_CLASS_NAME_PROP_SYMBOL: function() {
return _index.SLOT_CLASS_NAME_PROP_SYMBOL;
},
SLOT_ELEMENT_TYPE_SYMBOL: function() {
return _index.SLOT_ELEMENT_TYPE_SYMBOL;
},
SLOT_RENDER_FUNCTION_SYMBOL: function() {
return _index.SLOT_RENDER_FUNCTION_SYMBOL;
},
SSRProvider: function() {
return _index2.SSRProvider;
},
applyTriggerPropsToChildren: function() {
return _index4.applyTriggerPropsToChildren;
},
assertSlots: function() {
return _index.assertSlots;
},
canUseDOM: function() {
return _index2.canUseDOM;
},
clamp: function() {
return _index3.clamp;
},
createPriorityQueue: function() {
return _index3.createPriorityQueue;
},
elementContains: function() {
return _index7.elementContains;
},
getEventClientCoords: function() {
return _index5.getEventClientCoords;
},
getIntrinsicElementProps: function() {
return _index.getIntrinsicElementProps;
},
// eslint-disable-next-line @typescript-eslint/no-deprecated
getNativeElementProps: function() {
return _index3.getNativeElementProps;
},
getParent: function() {
return _index7.getParent;
},
getPartitionedNativeProps: function() {
return _index3.getPartitionedNativeProps;
},
getRTLSafeKey: function() {
return _index3.getRTLSafeKey;
},
getReactElementRef: function() {
return _index3.getReactElementRef;
},
getSlotClassNameProp_unstable: function() {
return _index.getSlotClassNameProp_unstable;
},
// eslint-disable-next-line @typescript-eslint/no-deprecated
getSlots: function() {
return _index.getSlots;
},
// eslint-disable-next-line @typescript-eslint/no-deprecated
getSlotsNext: function() {
return _index.getSlotsNext;
},
getTriggerChild: function() {
return _index4.getTriggerChild;
},
isFluentTrigger: function() {
return _index4.isFluentTrigger;
},
isHTMLElement: function() {
return _index3.isHTMLElement;
},
isInteractiveHTMLElement: function() {
return _index3.isInteractiveHTMLElement;
},
isMouseEvent: function() {
return _index5.isMouseEvent;
},
isResolvedShorthand: function() {
return _index.isResolvedShorthand;
},
isSlot: function() {
return _index.isSlot;
},
isTouchEvent: function() {
return _index5.isTouchEvent;
},
mergeCallbacks: function() {
return _index3.mergeCallbacks;
},
omit: function() {
return _index3.omit;
},
resetIdsForTests: function() {
return _index1.resetIdsForTests;
},
// eslint-disable-next-line @typescript-eslint/no-deprecated
resolveShorthand: function() {
return _index.resolveShorthand;
},
setVirtualParent: function() {
return _index7.setVirtualParent;
},
slot: function() {
return _index.slot;
},
useAnimationFrame: function() {
return _index1.useAnimationFrame;
},
useApplyScrollbarWidth: function() {
return _index1.useApplyScrollbarWidth;
},
useControllableState: function() {
return _index1.useControllableState;
},
useEventCallback: function() {
return _index1.useEventCallback;
},
useFirstMount: function() {
return _index1.useFirstMount;
},
useForceUpdate: function() {
return _index1.useForceUpdate;
},
useId: function() {
return _index1.useId;
},
useIsSSR: function() {
return _index2.useIsSSR;
},
useIsomorphicLayoutEffect: function() {
return _index1.useIsomorphicLayoutEffect;
},
useMergedRefs: function() {
return _index1.useMergedRefs;
},
useOnClickOutside: function() {
return _index1.useOnClickOutside;
},
useOnScrollOutside: function() {
return _index1.useOnScrollOutside;
},
usePrevious: function() {
return _index1.usePrevious;
},
useScrollbarWidth: function() {
return _index1.useScrollbarWidth;
},
useSelection: function() {
return _index6.useSelection;
},
useTimeout: function() {
return _index1.useTimeout;
}
});
const _index = require("./compose/index");
const _index1 = require("./hooks/index");
const _index2 = require("./ssr/index");
const _index3 = require("./utils/index");
const _index4 = require("./trigger/index");
const _index5 = require("./events/index");
const _index6 = require("./selection/index");
const _index7 = require("./virtualParent/index");

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useSelection", {
enumerable: true,
get: function() {
return _useSelection.useSelection;
}
});
const _useSelection = require("./useSelection");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/selection/index.ts"],"sourcesContent":["export type {\n OnSelectionChangeCallback,\n OnSelectionChangeData,\n SelectionHookParams,\n SelectionItemId,\n SelectionMethods,\n SelectionMode,\n} from './types';\nexport { useSelection } from './useSelection';\n"],"names":["useSelection"],"mappings":";;;;+BAQSA;;;eAAAA,0BAAY;;;8BAAQ"}

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"));

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/selection/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type SelectionMode = 'single' | 'multiselect';\n\nexport interface SelectionMethods {\n toggleItem(event: React.SyntheticEvent, id: SelectionItemId): void;\n selectItem(event: React.SyntheticEvent, id: SelectionItemId): void;\n deselectItem(event: React.SyntheticEvent, id: SelectionItemId): void;\n clearItems(event: React.SyntheticEvent): void;\n isSelected(id: SelectionItemId): boolean;\n toggleAllItems(event: React.SyntheticEvent, itemIds: SelectionItemId[]): void;\n}\n\nexport type SelectionItemId = string | number;\n\nexport type OnSelectionChangeCallback = (event: React.SyntheticEvent, selectedItems: Set<SelectionItemId>) => void;\n\nexport type OnSelectionChangeData = {\n selectedItems: Set<SelectionItemId>;\n};\n\nexport type SelectionHookParams = {\n selectionMode: SelectionMode;\n /**\n * Used in uncontrolled mode to set initial selected items on mount\n */\n defaultSelectedItems?: Iterable<SelectionItemId>;\n /**\n * Used to control selected items\n */\n selectedItems?: Iterable<SelectionItemId>;\n /**\n * Called when selection changes\n */\n onSelectionChange?(event: React.SyntheticEvent, data: OnSelectionChangeData): void;\n};\n"],"names":[],"mappings":";;;;;iEAAuB"}

View File

@@ -0,0 +1,116 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useSelection", {
enumerable: true,
get: function() {
return useSelection;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _useControllableState = require("../hooks/useControllableState");
const _createSetFromIterable = require("../utils/createSetFromIterable");
function useSelectionState(params) {
const [selected, setSelected] = (0, _useControllableState.useControllableState)({
initialState: new Set(),
defaultState: _react.useMemo(()=>params.defaultSelectedItems && (0, _createSetFromIterable.createSetFromIterable)(params.defaultSelectedItems), [
params.defaultSelectedItems
]),
state: _react.useMemo(()=>params.selectedItems && (0, _createSetFromIterable.createSetFromIterable)(params.selectedItems), [
params.selectedItems
])
});
const changeSelection = (event, nextSelectedItems)=>{
var _params_onSelectionChange;
(_params_onSelectionChange = params.onSelectionChange) === null || _params_onSelectionChange === void 0 ? void 0 : _params_onSelectionChange.call(params, event, {
selectedItems: nextSelectedItems
});
setSelected(nextSelectedItems);
};
return [
selected,
changeSelection
];
}
function useSingleSelection(params) {
const [selected, changeSelection] = useSelectionState(params);
const methods = {
deselectItem: (event)=>changeSelection(event, new Set()),
selectItem: (event, itemId)=>changeSelection(event, new Set([
itemId
])),
toggleAllItems: ()=>{
if (process.env.NODE_ENV !== 'production') {
throw new Error('[react-utilities]: `toggleAllItems` should not be used in single selection mode');
}
},
toggleItem: (event, itemId)=>changeSelection(event, new Set([
itemId
])),
clearItems: (event)=>changeSelection(event, new Set()),
isSelected: (itemId)=>{
var _selected_has;
return (_selected_has = selected.has(itemId)) !== null && _selected_has !== void 0 ? _selected_has : false;
}
};
return [
selected,
methods
];
}
function useMultipleSelection(params) {
const [selected, changeSelection] = useSelectionState(params);
const methods = {
toggleItem: (event, itemId)=>{
const nextSelectedItems = new Set(selected);
if (selected.has(itemId)) {
nextSelectedItems.delete(itemId);
} else {
nextSelectedItems.add(itemId);
}
changeSelection(event, nextSelectedItems);
},
selectItem: (event, itemId)=>{
const nextSelectedItems = new Set(selected);
nextSelectedItems.add(itemId);
changeSelection(event, nextSelectedItems);
},
deselectItem: (event, itemId)=>{
const nextSelectedItems = new Set(selected);
nextSelectedItems.delete(itemId);
changeSelection(event, nextSelectedItems);
},
clearItems: (event)=>{
changeSelection(event, new Set());
},
isSelected: (itemId)=>selected.has(itemId),
toggleAllItems: (event, itemIds)=>{
const allItemsSelected = itemIds.every((itemId)=>selected.has(itemId));
const nextSelectedItems = new Set(selected);
if (allItemsSelected) {
nextSelectedItems.clear();
} else {
itemIds.forEach((itemId)=>nextSelectedItems.add(itemId));
}
changeSelection(event, nextSelectedItems);
}
};
return [
selected,
methods
];
}
function useSelection(params) {
'use no memo';
if (params.selectionMode === 'multiselect') {
// selectionMode is a static value, so we can safely ignore rules-of-hooks
// eslint-disable-next-line react-hooks/rules-of-hooks
return useMultipleSelection(params);
}
// selectionMode is a static value, so we can safely ignore rules-of-hooks
// eslint-disable-next-line react-hooks/rules-of-hooks
return useSingleSelection(params);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
'use client';
"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, {
SSRContext: function() {
return SSRContext;
},
SSRProvider: function() {
return SSRProvider;
},
defaultSSRContextValue: function() {
return defaultSSRContextValue;
},
useIsSSR: function() {
return useIsSSR;
},
useSSRContext: function() {
return useSSRContext;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _canUseDOM = require("./canUseDOM");
const defaultSSRContextValue = {
current: 0
};
const SSRContext = /*#__PURE__*/ _react.createContext(undefined);
function useSSRContext() {
var _React_useContext;
return (_React_useContext = _react.useContext(SSRContext)) !== null && _React_useContext !== void 0 ? _React_useContext : defaultSSRContextValue;
}
const SSRProvider = (props)=>{
const [value] = _react.useState(()=>({
current: 0
}));
return /*#__PURE__*/ _react.createElement(SSRContext.Provider, {
value: value
}, props.children);
};
function useIsSSR() {
const isInSSRContext = useSSRContext() !== defaultSSRContextValue;
const [isSSR, setIsSSR] = _react.useState(isInSSRContext);
// If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the
// developer to add one.
if (process.env.NODE_ENV !== 'production') {
if (!isInSSRContext && !(0, _canUseDOM.canUseDOM)()) {
// eslint-disable-next-line no-console
console.error(`@fluentui/react-components [${useIsSSR.name}]:
When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.
Check documentation at https://aka.ms/fluentui-ssr.`);
}
}
// If on the client, and the component was initially server rendered, then schedule a layout effect to update the
// component after hydration.
if ((0, _canUseDOM.canUseDOM)() && isInSSRContext) {
// This if statement technically breaks the rules of hooks, but is safe because the condition never changes after
// mounting.
// eslint-disable-next-line
_react.useLayoutEffect(()=>{
setIsSSR(false);
}, []);
}
return isSSR;
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/ssr/SSRContext.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { canUseDOM } from './canUseDOM';\n\n/**\n * To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request\n * to ensure the client and server are consistent.\n *\n * @internal\n */\nexport type SSRContextValue = {\n current: number;\n};\n\n/**\n * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.\n *\n * @internal\n */\nexport const defaultSSRContextValue: SSRContextValue = {\n current: 0,\n};\n\nexport const SSRContext = React.createContext<SSRContextValue | undefined>(undefined) as React.Context<SSRContextValue>;\n\n/**\n * @internal\n */\nexport function useSSRContext(): SSRContextValue {\n return React.useContext(SSRContext) ?? defaultSSRContextValue;\n}\n\n/**\n * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids\n * are consistent between the client and server.\n *\n * @public\n */\nexport const SSRProvider: React.FC<{ children: React.ReactNode }> = props => {\n const [value] = React.useState<SSRContextValue>(() => ({ current: 0 }));\n\n return <SSRContext.Provider value={value}>{props.children}</SSRContext.Provider>;\n};\n\n/**\n * Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay\n * browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.\n */\nexport function useIsSSR(): boolean {\n const isInSSRContext = useSSRContext() !== defaultSSRContextValue;\n const [isSSR, setIsSSR] = React.useState(isInSSRContext);\n\n // If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the\n // developer to add one.\n if (process.env.NODE_ENV !== 'production') {\n if (!isInSSRContext && !canUseDOM()) {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-components [${useIsSSR.name}]:\n When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.\n\n\n Check documentation at https://aka.ms/fluentui-ssr.\n `);\n }\n }\n\n // If on the client, and the component was initially server rendered, then schedule a layout effect to update the\n // component after hydration.\n if (canUseDOM() && isInSSRContext) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line\n React.useLayoutEffect(() => {\n setIsSSR(false);\n }, []);\n }\n\n return isSSR;\n}\n"],"names":["SSRContext","SSRProvider","defaultSSRContextValue","useIsSSR","useSSRContext","current","React","createContext","undefined","useContext","props","value","useState","Provider","children","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","canUseDOM","console","error","name","useLayoutEffect"],"mappings":"AAAA;;;;;;;;;;;;IAwBaA,UAAU;eAAVA;;IAeAC,WAAW;eAAXA;;IAnBAC,sBAAsB;eAAtBA;;IA6BGC,QAAQ;eAARA;;IApBAC,aAAa;eAAbA;;;;iEA3BO;2BACG;AAiBnB,MAAMF,yBAA0C;IACrDG,SAAS;AACX;AAEO,MAAML,2BAAaM,OAAMC,aAAa,CAA8BC;AAKpE,SAASJ;QACPE;IAAP,OAAOA,CAAAA,oBAAAA,OAAMG,UAAU,CAACT,yBAAjBM,+BAAAA,oBAAgCJ;AACzC;AAQO,MAAMD,cAAuDS,CAAAA;IAClE,MAAM,CAACC,MAAM,GAAGL,OAAMM,QAAQ,CAAkB,IAAO,CAAA;YAAEP,SAAS;QAAE,CAAA;IAEpE,qBAAO,qBAACL,WAAWa,QAAQ;QAACF,OAAOA;OAAQD,MAAMI,QAAQ;AAC3D;AAMO,SAASX;IACd,MAAMY,iBAAiBX,oBAAoBF;IAC3C,MAAM,CAACc,OAAOC,SAAS,GAAGX,OAAMM,QAAQ,CAACG;IAEzC,6GAA6G;IAC7G,wBAAwB;IACxB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,CAACL,kBAAkB,CAACM,IAAAA,oBAAS,KAAI;YACnC,sCAAsC;YACtCC,QAAQC,KAAK,CAAuB,CAAC,4BACP,EAAEpB,SAASqB,IAAI,CAAC;;;;mDAK9C,CAAC;QACH;IACF;IAEA,iHAAiH;IACjH,6BAA6B;IAC7B,IAAIH,IAAAA,oBAAS,OAAMN,gBAAgB;QACjC,iHAAiH;QACjH,YAAY;QACZ,2BAA2B;QAC3BT,OAAMmB,eAAe,CAAC;YACpBR,SAAS;QACX,GAAG,EAAE;IACP;IAEA,OAAOD;AACT"}

View File

@@ -0,0 +1,15 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "canUseDOM", {
enumerable: true,
get: function() {
return canUseDOM;
}
});
function canUseDOM() {
return /* eslint-disable @nx/workspace-no-restricted-globals -- expected ignore ( SSR friendly acquisition of globals )*/ typeof window !== 'undefined' && !!(window.document && // eslint-disable-next-line @typescript-eslint/no-deprecated
window.document.createElement);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/ssr/canUseDOM.ts"],"sourcesContent":["'use client';\n\n/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n /* eslint-disable @nx/workspace-no-restricted-globals -- expected ignore ( SSR friendly acquisition of globals )*/\n typeof window !== 'undefined' &&\n !!(\n window.document &&\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n window.document.createElement\n )\n /* eslint-enable @nx/workspace-no-restricted-globals */\n );\n}\n"],"names":["canUseDOM","window","document","createElement"],"mappings":"AAAA;;;;;+BAKgBA;;;eAAAA;;;AAAT,SAASA;IACd,OACE,gHAAgH,GAChH,OAAOC,WAAW,eAClB,CAAC,CACCA,CAAAA,OAAOC,QAAQ,IACf,4DAA4D;IAC5DD,OAAOC,QAAQ,CAACC,aAAa,AAAD;AAIlC"}

View File

@@ -0,0 +1,32 @@
"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, {
SSRContext: function() {
return _SSRContext.SSRContext;
},
SSRProvider: function() {
return _SSRContext.SSRProvider;
},
canUseDOM: function() {
return _canUseDOM.canUseDOM;
},
defaultSSRContextValue: function() {
return _SSRContext.defaultSSRContextValue;
},
useIsSSR: function() {
return _SSRContext.useIsSSR;
},
useSSRContext: function() {
return _SSRContext.useSSRContext;
}
});
const _canUseDOM = require("./canUseDOM");
const _SSRContext = require("./SSRContext");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/ssr/index.ts"],"sourcesContent":["export { canUseDOM } from './canUseDOM';\nexport type { SSRContextValue } from './SSRContext';\nexport { SSRContext, SSRProvider, defaultSSRContextValue, useIsSSR, useSSRContext } from './SSRContext';\n"],"names":["SSRContext","SSRProvider","canUseDOM","defaultSSRContextValue","useIsSSR","useSSRContext"],"mappings":";;;;;;;;;;;IAESA,UAAU;eAAVA,sBAAU;;IAAEC,WAAW;eAAXA,uBAAW;;IAFvBC,SAAS;eAATA,oBAAS;;IAEgBC,sBAAsB;eAAtBA,kCAAsB;;IAAEC,QAAQ;eAARA,oBAAQ;;IAAEC,aAAa;eAAbA,yBAAa;;;2BAFvD;4BAE+D"}

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "applyTriggerPropsToChildren", {
enumerable: true,
get: function() {
return applyTriggerPropsToChildren;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _isFluentTrigger = require("./isFluentTrigger");
function applyTriggerPropsToChildren(children, triggerChildProps) {
if (typeof children === 'function') {
return children(triggerChildProps);
} else if (children) {
return cloneTriggerTree(children, triggerChildProps);
}
// Components in React should return either JSX elements or "null", otherwise React will throw:
// Nothing was returned from render.
// This usually means a return statement is missing. Or, to render nothing, return null.
return children || null;
}
/**
* Clones a React element tree, and applies the given props to the first grandchild that is not
* a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).
*/ function cloneTriggerTree(child, triggerProps) {
if (!_react.isValidElement(child) || child.type === _react.Fragment) {
throw new Error('A trigger element must be a single element for this component. ' + "Please ensure that you're not using React Fragments.");
}
if ((0, _isFluentTrigger.isFluentTrigger)(child)) {
const grandchild = cloneTriggerTree(child.props.children, triggerProps);
return _react.cloneElement(child, undefined, grandchild);
} else {
return _react.cloneElement(child, triggerProps);
}
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/trigger/applyTriggerPropsToChildren.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * resolve the trigger props to the children, either by calling the render function, or cloning with the new props.\n */\nexport function applyTriggerPropsToChildren<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n triggerChildProps: TriggerChildProps,\n): React.ReactElement | null {\n if (typeof children === 'function') {\n return children(triggerChildProps);\n } else if (children) {\n return cloneTriggerTree(children, triggerChildProps);\n }\n\n // Components in React should return either JSX elements or \"null\", otherwise React will throw:\n // Nothing was returned from render.\n // This usually means a return statement is missing. Or, to render nothing, return null.\n return children || null;\n}\n\n/**\n * Clones a React element tree, and applies the given props to the first grandchild that is not\n * a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).\n */\nfunction cloneTriggerTree<TriggerChildProps>(\n child: TriggerProps['children'],\n triggerProps: TriggerChildProps,\n): React.ReactElement {\n if (!React.isValidElement(child) || child.type === React.Fragment) {\n throw new Error(\n 'A trigger element must be a single element for this component. ' +\n \"Please ensure that you're not using React Fragments.\",\n );\n }\n\n if (isFluentTrigger(child)) {\n const grandchild = cloneTriggerTree(child.props.children, triggerProps);\n return React.cloneElement(child, undefined, grandchild);\n } else {\n return React.cloneElement(child, triggerProps as TriggerChildProps & React.Attributes);\n }\n}\n"],"names":["applyTriggerPropsToChildren","children","triggerChildProps","cloneTriggerTree","child","triggerProps","React","isValidElement","type","Fragment","Error","isFluentTrigger","grandchild","props","cloneElement","undefined"],"mappings":";;;;+BAQgBA;;;eAAAA;;;;iEARO;iCACS;AAOzB,SAASA,4BACdC,QAAqD,EACrDC,iBAAoC;IAEpC,IAAI,OAAOD,aAAa,YAAY;QAClC,OAAOA,SAASC;IAClB,OAAO,IAAID,UAAU;QACnB,OAAOE,iBAAiBF,UAAUC;IACpC;IAEA,+FAA+F;IAC/F,sCAAsC;IACtC,0FAA0F;IAC1F,OAAOD,YAAY;AACrB;AAEA;;;CAGC,GACD,SAASE,iBACPC,KAA+B,EAC/BC,YAA+B;IAE/B,IAAI,CAACC,OAAMC,cAAc,CAACH,UAAUA,MAAMI,IAAI,KAAKF,OAAMG,QAAQ,EAAE;QACjE,MAAM,IAAIC,MACR,oEACE;IAEN;IAEA,IAAIC,IAAAA,gCAAe,EAACP,QAAQ;QAC1B,MAAMQ,aAAaT,iBAAiBC,MAAMS,KAAK,CAACZ,QAAQ,EAAEI;QAC1D,OAAOC,OAAMQ,YAAY,CAACV,OAAOW,WAAWH;IAC9C,OAAO;QACL,OAAON,OAAMQ,YAAY,CAACV,OAAOC;IACnC;AACF"}

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getTriggerChild", {
enumerable: true,
get: function() {
return getTriggerChild;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _isFluentTrigger = require("./isFluentTrigger");
function getTriggerChild(children) {
if (!_react.isValidElement(children)) {
return null;
}
return (0, _isFluentTrigger.isFluentTrigger)(children) ? getTriggerChild(// FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,
// but for some reason it's failing on build
children.props.children) : children;
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/trigger/getTriggerChild.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n *\n * In the case where the immediate child is not a valid element,\n * null is returned\n */\nexport function getTriggerChild<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (React.ReactElement<Partial<TriggerChildProps>> & { ref?: React.Ref<any> }) | null {\n if (!React.isValidElement<TriggerChildProps>(children)) {\n return null;\n }\n return isFluentTrigger(children)\n ? getTriggerChild(\n // FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,\n // but for some reason it's failing on build\n (children.props as TriggerProps).children,\n )\n : children;\n}\n"],"names":["getTriggerChild","children","React","isValidElement","isFluentTrigger","props"],"mappings":";;;;+BA0BgBA;;;eAAAA;;;;iEA1BO;iCACS;AAyBzB,SAASA,gBACdC,QAAqD;IAGrD,IAAI,CAACC,OAAMC,cAAc,CAAoBF,WAAW;QACtD,OAAO;IACT;IACA,OAAOG,IAAAA,gCAAe,EAACH,YACnBD,gBAGE,AAFA,uFAAuF;IACvF,4CAA4C;IAC3CC,SAASI,KAAK,CAAkBJ,QAAQ,IAE3CA;AACN"}

View File

@@ -0,0 +1,24 @@
"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, {
applyTriggerPropsToChildren: function() {
return _applyTriggerPropsToChildren.applyTriggerPropsToChildren;
},
getTriggerChild: function() {
return _getTriggerChild.getTriggerChild;
},
isFluentTrigger: function() {
return _isFluentTrigger.isFluentTrigger;
}
});
const _applyTriggerPropsToChildren = require("./applyTriggerPropsToChildren");
const _getTriggerChild = require("./getTriggerChild");
const _isFluentTrigger = require("./isFluentTrigger");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/trigger/index.ts"],"sourcesContent":["export { applyTriggerPropsToChildren } from './applyTriggerPropsToChildren';\nexport { getTriggerChild } from './getTriggerChild';\nexport { isFluentTrigger } from './isFluentTrigger';\nexport type { FluentTriggerComponent, TriggerProps } from './types';\n"],"names":["applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger"],"mappings":";;;;;;;;;;;IAASA,2BAA2B;eAA3BA,wDAA2B;;IAC3BC,eAAe;eAAfA,gCAAe;;IACfC,eAAe;eAAfA,gCAAe;;;6CAFoB;iCACZ;iCACA"}

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isFluentTrigger", {
enumerable: true,
get: function() {
return isFluentTrigger;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function isFluentTrigger(element) {
return Boolean(element.type.isFluentTriggerComponent);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/trigger/isFluentTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport type { FluentTriggerComponent, TriggerProps } from './types';\n\n/**\n * @internal\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport function isFluentTrigger(element: React.ReactElement): element is React.ReactElement<TriggerProps> {\n return Boolean((element.type as FluentTriggerComponent).isFluentTriggerComponent);\n}\n"],"names":["isFluentTrigger","element","Boolean","type","isFluentTriggerComponent"],"mappings":";;;;+BAQgBA;;;eAAAA;;;;iEARO;AAQhB,SAASA,gBAAgBC,OAA2B;IACzD,OAAOC,QAAQ,AAACD,QAAQE,IAAI,CAA4BC,wBAAwB;AAClF"}

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"));

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/trigger/types.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Allows a component to be tagged as a FluentUI trigger component.\n *\n * Triggers are special-case components: they attach event listeners and other props on their child,\n * and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.\n *\n * A component can be tagged as a trigger as follows:\n * ```ts\n * const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;\n *\n * MyComponent.isFluentTriggerComponent = true; // MUST also set this to true\n * ```\n */\nexport type FluentTriggerComponent = {\n isFluentTriggerComponent?: boolean;\n};\n\n/**\n * A trigger may have a children that could be either:\n * 1. A single element\n * 2. A render function that will receive properties and must return a valid element or null\n * 3. null or undefined\n */\nexport type TriggerProps<TriggerChildProps = unknown> = {\n children?: React.ReactElement | ((props: TriggerChildProps) => React.ReactElement | null) | null;\n};\n"],"names":[],"mappings":";;;;;iEAAuB"}

View File

@@ -0,0 +1,18 @@
/**
* @internal
* Clamps `value` to a number between the min and max.
*
* @param value - the value to be clamped
* @param min - the lowest valid value
* @param max - the highest valid value
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "clamp", {
enumerable: true,
get: function() {
return clamp;
}
});
const clamp = (value, min, max)=>Math.max(min, Math.min(max, value || 0));

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/clamp.ts"],"sourcesContent":["/**\n * @internal\n * Clamps `value` to a number between the min and max.\n *\n * @param value - the value to be clamped\n * @param min - the lowest valid value\n * @param max - the highest valid value\n */\nexport const clamp = (value: number, min: number, max: number): number => Math.max(min, Math.min(max, value || 0));\n"],"names":["clamp","value","min","max","Math"],"mappings":"AAAA;;;;;;;CAOC;;;;+BACYA;;;eAAAA;;;AAAN,MAAMA,QAAQ,CAACC,OAAeC,KAAaC,MAAwBC,KAAKD,GAAG,CAACD,KAAKE,KAAKF,GAAG,CAACC,KAAKF,SAAS"}

View File

@@ -0,0 +1,15 @@
/**
* Creates a set from a given iterable, in case the iterable is a set itself, returns the given set instead.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "createSetFromIterable", {
enumerable: true,
get: function() {
return createSetFromIterable;
}
});
function createSetFromIterable(iterable) {
return iterable instanceof Set ? iterable : new Set(iterable);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/createSetFromIterable.ts"],"sourcesContent":["/**\n * Creates a set from a given iterable, in case the iterable is a set itself, returns the given set instead.\n */\nexport function createSetFromIterable<V>(iterable: Iterable<V>): Set<V> {\n return iterable instanceof Set ? iterable : new Set(iterable);\n}\n"],"names":["createSetFromIterable","iterable","Set"],"mappings":"AAAA;;CAEC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,sBAAyBC,QAAqB;IAC5D,OAAOA,oBAAoBC,MAAMD,WAAW,IAAIC,IAAID;AACtD"}

View File

@@ -0,0 +1,65 @@
"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, {
getNativeElementProps: function() {
return getNativeElementProps;
},
getPartitionedNativeProps: function() {
return getPartitionedNativeProps;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _properties = require("./properties");
const nativeElementMap = {
label: _properties.labelProperties,
audio: _properties.audioProperties,
video: _properties.videoProperties,
ol: _properties.olProperties,
li: _properties.liProperties,
a: _properties.anchorProperties,
button: _properties.buttonProperties,
input: _properties.inputProperties,
textarea: _properties.textAreaProperties,
select: _properties.selectProperties,
option: _properties.optionProperties,
table: _properties.tableProperties,
tr: _properties.trProperties,
th: _properties.thProperties,
td: _properties.tdProperties,
colGroup: _properties.colGroupProperties,
col: _properties.colProperties,
fieldset: _properties.fieldsetProperties,
form: _properties.formProperties,
iframe: _properties.iframeProperties,
img: _properties.imgProperties,
time: _properties.timeProperties,
dialog: _properties.dialogProperties
};
function getNativeElementProps(tagName, props, excludedPropNames) {
const allowedPropNames = tagName && nativeElementMap[tagName] || _properties.htmlElementProperties;
allowedPropNames.as = 1;
return (0, _properties.getNativeProps)(props, allowedPropNames, excludedPropNames);
}
const getPartitionedNativeProps = ({ primarySlotTagName, props, excludedPropNames })=>{
return {
root: {
style: props.style,
className: props.className
},
// eslint-disable-next-line @typescript-eslint/no-deprecated
primary: getNativeElementProps(primarySlotTagName, props, [
...excludedPropNames || [],
'style',
'className'
])
};
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
/**
* @internal
* Finds and swaps a provided key for it's right to left format.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getRTLSafeKey", {
enumerable: true,
get: function() {
return getRTLSafeKey;
}
});
const getRTLSafeKey = (key, dir)=>{
if (dir === 'rtl') {
switch(key){
case 'ArrowLeft':
{
return 'ArrowRight';
}
case 'ArrowRight':
{
return 'ArrowLeft';
}
}
}
return key;
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/getRTLSafeKey.ts"],"sourcesContent":["/**\n * @internal\n * Finds and swaps a provided key for it's right to left format.\n */\nexport const getRTLSafeKey = (key: string, dir: 'ltr' | 'rtl'): string => {\n if (dir === 'rtl') {\n switch (key) {\n case 'ArrowLeft': {\n return 'ArrowRight';\n }\n\n case 'ArrowRight': {\n return 'ArrowLeft';\n }\n }\n }\n\n return key;\n};\n"],"names":["getRTLSafeKey","key","dir"],"mappings":"AAAA;;;CAGC;;;;+BACYA;;;eAAAA;;;AAAN,MAAMA,gBAAgB,CAACC,KAAaC;IACzC,IAAIA,QAAQ,OAAO;QACjB,OAAQD;YACN,KAAK;gBAAa;oBAChB,OAAO;gBACT;YAEA,KAAK;gBAAc;oBACjB,OAAO;gBACT;QACF;IACF;IAEA,OAAOA;AACT"}

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getReactCallbackName", {
enumerable: true,
get: function() {
return getReactCallbackName;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
function getReactCallbackName(event) {
if (event._reactName) {
return event._reactName;
}
if (event.dispatchConfig) {
if (event.dispatchConfig.registrationName) {
return event.dispatchConfig.registrationName;
}
return event.dispatchConfig.phasedRegistrationNames.bubbled;
}
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.error(`@fluentui/react-utilities [${getReactCallbackName.name}]:
Passed React.SyntheticEvent does not contain ".dispatchConfig" or "._reactName". This should not happen, please report it to https://github.com/microsoft/fluentui.`);
}
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/getReactCallbackName.ts"],"sourcesContent":["import * as React from 'react';\n\ninterface ReactSyntheticEvent extends React.SyntheticEvent<unknown> {\n // React 17/18\n // See https://github.com/facebook/react/pull/19236\n _reactName?: string;\n\n // React 16\n dispatchConfig?: {\n registrationName: string;\n phasedRegistrationNames: {\n bubbled: string;\n captured: string;\n };\n };\n}\n\ntype NonUndefined<A> = A extends undefined ? never : A;\ntype FunctionKeys<T extends object> = {\n [K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;\n}[keyof T];\n\nexport type ReactCallbackName = FunctionKeys<React.DOMAttributes<unknown>>;\n\n/**\n * React.SyntheticEvent contains name of a callback that should be fired, this function returns it.\n *\n * Ideally, it should also distinguish regular and \"capture\" callbacks, but it's possible only with React 17 as\n * \".eventPhase\" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events\n * are handled in bubble phase.\n */\nexport function getReactCallbackName(event: ReactSyntheticEvent): ReactCallbackName | undefined {\n if (event._reactName) {\n return event._reactName as ReactCallbackName;\n }\n\n if (event.dispatchConfig) {\n if (event.dispatchConfig.registrationName) {\n return event.dispatchConfig.registrationName as ReactCallbackName;\n }\n\n return event.dispatchConfig.phasedRegistrationNames.bubbled as ReactCallbackName;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${getReactCallbackName.name}]:\n Passed React.SyntheticEvent does not contain \".dispatchConfig\" or \"._reactName\". This should not happen, please report it to https://github.com/microsoft/fluentui.\n `);\n }\n}\n"],"names":["getReactCallbackName","event","_reactName","dispatchConfig","registrationName","phasedRegistrationNames","bubbled","process","env","NODE_ENV","console","error","name"],"mappings":";;;;+BA+BgBA;;;eAAAA;;;;iEA/BO;AA+BhB,SAASA,qBAAqBC,KAA0B;IAC7D,IAAIA,MAAMC,UAAU,EAAE;QACpB,OAAOD,MAAMC,UAAU;IACzB;IAEA,IAAID,MAAME,cAAc,EAAE;QACxB,IAAIF,MAAME,cAAc,CAACC,gBAAgB,EAAE;YACzC,OAAOH,MAAME,cAAc,CAACC,gBAAgB;QAC9C;QAEA,OAAOH,MAAME,cAAc,CAACE,uBAAuB,CAACC,OAAO;IAC7D;IAEA,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,sCAAsC;QACtCC,QAAQC,KAAK,CAAuB,CAAC,2BACR,EAAEX,qBAAqBY,IAAI,CAAC;mKAEzD,CAAC;IACH;AACF"}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getReactElementRef", {
enumerable: true,
get: function() {
return getReactElementRef;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const IS_REACT_19_OR_HIGHER = parseInt(_react.version, 10) >= 19;
function getReactElementRef(element) {
if (!element) {
return undefined;
}
if (IS_REACT_19_OR_HIGHER) {
return element.props.ref;
}
return element.ref;
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/getReactElementRef.ts"],"sourcesContent":["import * as React from 'react';\n\nconst IS_REACT_19_OR_HIGHER = parseInt(React.version, 10) >= 19;\n\n/**\n * Returns a ref for the React element in a backwards-compatible way.\n *\n * @param element - The element to get the ref for.\n * @returns The ref for the element.\n */\nexport function getReactElementRef<T>(element: React.ReactElement | null | undefined): React.Ref<T> | undefined {\n if (!element) {\n return undefined;\n }\n\n if (IS_REACT_19_OR_HIGHER) {\n return (element as React.ReactElement<{ ref?: React.Ref<T> }>).props.ref;\n }\n\n return (element as React.ReactElement & { ref: React.Ref<T> | undefined }).ref;\n}\n"],"names":["getReactElementRef","IS_REACT_19_OR_HIGHER","parseInt","React","version","element","undefined","props","ref"],"mappings":";;;;+BAUgBA;;;eAAAA;;;;iEAVO;AAEvB,MAAMC,wBAAwBC,SAASC,OAAMC,OAAO,EAAE,OAAO;AAQtD,SAASJ,mBAAsBK,OAA8C;IAClF,IAAI,CAACA,SAAS;QACZ,OAAOC;IACT;IAEA,IAAIL,uBAAuB;QACzB,OAAO,AAACI,QAAuDE,KAAK,CAACC,GAAG;IAC1E;IAEA,OAAO,AAACH,QAAmEG,GAAG;AAChF"}

View File

@@ -0,0 +1,144 @@
"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, {
anchorProperties: function() {
return _properties.anchorProperties;
},
audioProperties: function() {
return _properties.audioProperties;
},
baseElementEvents: function() {
return _properties.baseElementEvents;
},
baseElementProperties: function() {
return _properties.baseElementProperties;
},
buttonProperties: function() {
return _properties.buttonProperties;
},
clamp: function() {
return _clamp.clamp;
},
colGroupProperties: function() {
return _properties.colGroupProperties;
},
colProperties: function() {
return _properties.colProperties;
},
createPriorityQueue: function() {
return _priorityQueue.createPriorityQueue;
},
dialogProperties: function() {
return _properties.dialogProperties;
},
divProperties: function() {
return _properties.divProperties;
},
fieldsetProperties: function() {
return _properties.fieldsetProperties;
},
formProperties: function() {
return _properties.formProperties;
},
// eslint-disable-next-line @typescript-eslint/no-deprecated
getNativeElementProps: function() {
return _getNativeElementProps.getNativeElementProps;
},
getNativeProps: function() {
return _properties.getNativeProps;
},
getPartitionedNativeProps: function() {
return _getNativeElementProps.getPartitionedNativeProps;
},
getRTLSafeKey: function() {
return _getRTLSafeKey.getRTLSafeKey;
},
getReactElementRef: function() {
return _getReactElementRef.getReactElementRef;
},
htmlElementProperties: function() {
return _properties.htmlElementProperties;
},
iframeProperties: function() {
return _properties.iframeProperties;
},
imgProperties: function() {
return _properties.imgProperties;
},
inputProperties: function() {
return _properties.inputProperties;
},
isHTMLElement: function() {
return _isHTMLElement.isHTMLElement;
},
isInteractiveHTMLElement: function() {
return _isInteractiveHTMLElement.isInteractiveHTMLElement;
},
labelProperties: function() {
return _properties.labelProperties;
},
liProperties: function() {
return _properties.liProperties;
},
measureScrollbarWidth: function() {
return _measureScrollBarWidth.measureScrollbarWidth;
},
mergeCallbacks: function() {
return _mergeCallbacks.mergeCallbacks;
},
microdataProperties: function() {
return _properties.microdataProperties;
},
olProperties: function() {
return _properties.olProperties;
},
omit: function() {
return _omit.omit;
},
optionProperties: function() {
return _properties.optionProperties;
},
selectProperties: function() {
return _properties.selectProperties;
},
tableProperties: function() {
return _properties.tableProperties;
},
tdProperties: function() {
return _properties.tdProperties;
},
textAreaProperties: function() {
return _properties.textAreaProperties;
},
thProperties: function() {
return _properties.thProperties;
},
timeProperties: function() {
return _properties.timeProperties;
},
trProperties: function() {
return _properties.trProperties;
},
videoProperties: function() {
return _properties.videoProperties;
}
});
const _clamp = require("./clamp");
const _getNativeElementProps = require("./getNativeElementProps");
const _getReactElementRef = require("./getReactElementRef");
const _getRTLSafeKey = require("./getRTLSafeKey");
const _mergeCallbacks = require("./mergeCallbacks");
const _omit = require("./omit");
const _properties = require("./properties");
const _isHTMLElement = require("./isHTMLElement");
const _isInteractiveHTMLElement = require("./isInteractiveHTMLElement");
const _priorityQueue = require("./priorityQueue");
const _measureScrollBarWidth = require("./measureScrollBarWidth");

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/index.ts"],"sourcesContent":["export { clamp } from './clamp';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n getNativeElementProps,\n getPartitionedNativeProps,\n} from './getNativeElementProps';\nexport { getReactElementRef } from './getReactElementRef';\nexport { getRTLSafeKey } from './getRTLSafeKey';\nexport { mergeCallbacks } from './mergeCallbacks';\nexport { omit } from './omit';\nexport {\n anchorProperties,\n audioProperties,\n baseElementEvents,\n baseElementProperties,\n buttonProperties,\n colGroupProperties,\n colProperties,\n dialogProperties,\n divProperties,\n fieldsetProperties,\n formProperties,\n getNativeProps,\n htmlElementProperties,\n iframeProperties,\n imgProperties,\n inputProperties,\n labelProperties,\n liProperties,\n microdataProperties,\n olProperties,\n optionProperties,\n selectProperties,\n tableProperties,\n tdProperties,\n textAreaProperties,\n thProperties,\n timeProperties,\n trProperties,\n videoProperties,\n} from './properties';\nexport { isHTMLElement } from './isHTMLElement';\nexport { isInteractiveHTMLElement } from './isInteractiveHTMLElement';\nexport type { PriorityQueue, PriorityQueueCompareFn } from './priorityQueue';\nexport { createPriorityQueue } from './priorityQueue';\nexport { measureScrollbarWidth } from './measureScrollBarWidth';\n"],"names":["anchorProperties","audioProperties","baseElementEvents","baseElementProperties","buttonProperties","clamp","colGroupProperties","colProperties","createPriorityQueue","dialogProperties","divProperties","fieldsetProperties","formProperties","getNativeElementProps","getNativeProps","getPartitionedNativeProps","getRTLSafeKey","getReactElementRef","htmlElementProperties","iframeProperties","imgProperties","inputProperties","isHTMLElement","isInteractiveHTMLElement","labelProperties","liProperties","measureScrollbarWidth","mergeCallbacks","microdataProperties","olProperties","omit","optionProperties","selectProperties","tableProperties","tdProperties","textAreaProperties","thProperties","timeProperties","trProperties","videoProperties"],"mappings":";;;;;;;;;;;IAWEA,gBAAgB;eAAhBA,4BAAgB;;IAChBC,eAAe;eAAfA,2BAAe;;IACfC,iBAAiB;eAAjBA,6BAAiB;;IACjBC,qBAAqB;eAArBA,iCAAqB;;IACrBC,gBAAgB;eAAhBA,4BAAgB;;IAfTC,KAAK;eAALA,YAAK;;IAgBZC,kBAAkB;eAAlBA,8BAAkB;;IAClBC,aAAa;eAAbA,yBAAa;;IA2BNC,mBAAmB;eAAnBA,kCAAmB;;IA1B1BC,gBAAgB;eAAhBA,4BAAgB;;IAChBC,aAAa;eAAbA,yBAAa;;IACbC,kBAAkB;eAAlBA,8BAAkB;;IAClBC,cAAc;eAAdA,0BAAc;;IAnBd,4DAA4D;IAC5DC,qBAAqB;eAArBA,4CAAqB;;IAmBrBC,cAAc;eAAdA,0BAAc;;IAlBdC,yBAAyB;eAAzBA,gDAAyB;;IAGlBC,aAAa;eAAbA,4BAAa;;IADbC,kBAAkB;eAAlBA,sCAAkB;;IAiBzBC,qBAAqB;eAArBA,iCAAqB;;IACrBC,gBAAgB;eAAhBA,4BAAgB;;IAChBC,aAAa;eAAbA,yBAAa;;IACbC,eAAe;eAAfA,2BAAe;;IAeRC,aAAa;eAAbA,4BAAa;;IACbC,wBAAwB;eAAxBA,kDAAwB;;IAf/BC,eAAe;eAAfA,2BAAe;;IACfC,YAAY;eAAZA,wBAAY;;IAiBLC,qBAAqB;eAArBA,4CAAqB;;IArCrBC,cAAc;eAAdA,8BAAc;;IAqBrBC,mBAAmB;eAAnBA,+BAAmB;;IACnBC,YAAY;eAAZA,wBAAY;;IArBLC,IAAI;eAAJA,UAAI;;IAsBXC,gBAAgB;eAAhBA,4BAAgB;;IAChBC,gBAAgB;eAAhBA,4BAAgB;;IAChBC,eAAe;eAAfA,2BAAe;;IACfC,YAAY;eAAZA,wBAAY;;IACZC,kBAAkB;eAAlBA,8BAAkB;;IAClBC,YAAY;eAAZA,wBAAY;;IACZC,cAAc;eAAdA,0BAAc;;IACdC,YAAY;eAAZA,wBAAY;;IACZC,eAAe;eAAfA,2BAAe;;;uBAvCK;uCAKf;oCAC4B;+BACL;gCACC;sBACV;4BA+Bd;+BACuB;0CACW;+BAEL;uCACE"}

View File

@@ -0,0 +1,29 @@
/**
* Verifies if a given node is an HTMLElement,
* this method works seamlessly with frames and elements from different documents
*
* This is preferred over simply using `instanceof`.
* Since `instanceof` might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
*
* @example
* ```ts
* isHTMLElement(event.target) && event.target.focus()
* isHTMLElement(event.target, {constructorName: 'HTMLInputElement'}) && event.target.value // some value
* ```
*
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isHTMLElement", {
enumerable: true,
get: function() {
return isHTMLElement;
}
});
function isHTMLElement(element, options) {
var _typedElement_ownerDocument;
const typedElement = element;
var _options_constructorName;
return Boolean((typedElement === null || typedElement === void 0 ? void 0 : (_typedElement_ownerDocument = typedElement.ownerDocument) === null || _typedElement_ownerDocument === void 0 ? void 0 : _typedElement_ownerDocument.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView[(_options_constructorName = options === null || options === void 0 ? void 0 : options.constructorName) !== null && _options_constructorName !== void 0 ? _options_constructorName : 'HTMLElement']);
}

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/isHTMLElement.ts"],"sourcesContent":["/**\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is preferred over simply using `instanceof`.\n * Since `instanceof` might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n * @example\n * ```ts\n * isHTMLElement(event.target) && event.target.focus()\n * isHTMLElement(event.target, {constructorName: 'HTMLInputElement'}) && event.target.value // some value\n * ```\n *\n */\nexport function isHTMLElement<ConstructorName extends HTMLElementConstructorName = 'HTMLElement'>(\n element?: unknown,\n options?: {\n /**\n * Can be used to provide a custom constructor instead of `HTMLElement`,\n * Like `HTMLInputElement` for example.\n */\n constructorName?: ConstructorName;\n },\n): element is InstanceType<(typeof globalThis)[ConstructorName]> {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView[options?.constructorName ?? 'HTMLElement'],\n );\n}\n\ntype HTMLElementConstructorName =\n | 'HTMLElement'\n | 'HTMLAnchorElement'\n | 'HTMLAreaElement'\n | 'HTMLAudioElement'\n | 'HTMLBaseElement'\n | 'HTMLBodyElement'\n | 'HTMLBRElement'\n | 'HTMLButtonElement'\n | 'HTMLCanvasElement'\n | 'HTMLDataElement'\n | 'HTMLDataListElement'\n | 'HTMLDetailsElement'\n // NOTE: dialog is not supported in safari 14, also it was removed from lib-dom starting typescript 4.4\n // | 'HTMLDialogElement'\n | 'HTMLDivElement'\n | 'HTMLDListElement'\n | 'HTMLEmbedElement'\n | 'HTMLFieldSetElement'\n | 'HTMLFormElement'\n | 'HTMLHeadingElement'\n | 'HTMLHeadElement'\n | 'HTMLHRElement'\n | 'HTMLHtmlElement'\n | 'HTMLIFrameElement'\n | 'HTMLImageElement'\n | 'HTMLInputElement'\n | 'HTMLModElement'\n | 'HTMLLabelElement'\n | 'HTMLLegendElement'\n | 'HTMLLIElement'\n | 'HTMLLinkElement'\n | 'HTMLMapElement'\n | 'HTMLMetaElement'\n | 'HTMLMeterElement'\n | 'HTMLObjectElement'\n | 'HTMLOListElement'\n | 'HTMLOptGroupElement'\n | 'HTMLOptionElement'\n | 'HTMLOutputElement'\n | 'HTMLParagraphElement'\n | 'HTMLParamElement'\n | 'HTMLPreElement'\n | 'HTMLProgressElement'\n | 'HTMLQuoteElement'\n | 'HTMLSlotElement'\n | 'HTMLScriptElement'\n | 'HTMLSelectElement'\n | 'HTMLSourceElement'\n | 'HTMLSpanElement'\n | 'HTMLStyleElement'\n | 'HTMLTableElement'\n | 'HTMLTableColElement'\n | 'HTMLTableRowElement'\n | 'HTMLTableSectionElement'\n | 'HTMLTemplateElement'\n | 'HTMLTextAreaElement'\n | 'HTMLTimeElement'\n | 'HTMLTitleElement'\n | 'HTMLTrackElement'\n | 'HTMLUListElement'\n | 'HTMLVideoElement';\n"],"names":["isHTMLElement","element","options","typedElement","Boolean","ownerDocument","defaultView","constructorName"],"mappings":"AAAA;;;;;;;;;;;;;CAaC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,cACdC,OAAiB,EACjBC,OAMC;QAICC;IAFF,MAAMA,eAAeF;QAG8CC;IAFnE,OAAOE,QACLD,CAAAA,yBAAAA,oCAAAA,8BAAAA,aAAcE,aAAa,cAA3BF,kDAAAA,4BAA6BG,WAAW,KACtCH,wBAAwBA,aAAaE,aAAa,CAACC,WAAW,CAACJ,CAAAA,2BAAAA,oBAAAA,8BAAAA,QAASK,eAAe,cAAxBL,sCAAAA,2BAA4B,cAAc;AAE/G"}

Some files were not shown because too many files have changed in this diff Show More