'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, { useSpinnerBase_unstable: function() { return useSpinnerBase_unstable; }, useSpinner_unstable: function() { return useSpinner_unstable; } }); const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"); const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react")); const _reactutilities = require("@fluentui/react-utilities"); const _reactlabel = require("@fluentui/react-label"); const _SpinnerContext = require("../../contexts/SpinnerContext"); const useSpinner_unstable = (props, ref)=>{ const { size: contextSize } = (0, _SpinnerContext.useSpinnerContext)(); const { appearance = 'primary', size = contextSize !== null && contextSize !== void 0 ? contextSize : 'medium', ...baseProps } = props; const baseState = useSpinnerBase_unstable(baseProps, ref); return { ...baseState, appearance, size }; }; const useSpinnerBase_unstable = (props, ref)=>{ const { delay = 0, labelPosition = 'after' } = props; const baseId = (0, _reactutilities.useId)('spinner'); const { role = 'progressbar', ...rest } = props; const nativeRoot = _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', { // FIXME: // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement` // but since it would be a breaking change to fix it, we are casting ref to it's proper type ref: ref, role, ...rest }), { elementType: 'div' }); const [isShownAfterDelay, setIsShownAfterDelay] = _react.useState(false); const [setDelayTimeout, clearDelayTimeout] = (0, _reactutilities.useTimeout)(); _react.useEffect(()=>{ if (delay <= 0) { return; } setDelayTimeout(()=>{ setIsShownAfterDelay(true); }, delay); return ()=>{ clearDelayTimeout(); }; }, [ setDelayTimeout, clearDelayTimeout, delay ]); const labelShorthand = _reactutilities.slot.optional(props.label, { defaultProps: { id: baseId }, renderByDefault: false, elementType: _reactlabel.Label }); const spinnerShortHand = _reactutilities.slot.optional(props.spinner, { renderByDefault: true, elementType: 'span' }); if (labelShorthand && nativeRoot && !nativeRoot['aria-labelledby']) { nativeRoot['aria-labelledby'] = labelShorthand.id; } const state = { delay, labelPosition, shouldRenderSpinner: !delay || isShownAfterDelay, components: { root: 'div', spinner: 'span', spinnerTail: 'span', label: _reactlabel.Label }, root: nativeRoot, spinner: spinnerShortHand, spinnerTail: _reactutilities.slot.always(props.spinnerTail, { elementType: 'span' }), label: labelShorthand }; return state; };