UNPKG

@carbon/ibm-products

Version:

Carbon for IBM Products

96 lines (88 loc) 2.71 kB
/** * Copyright IBM Corp. 2020, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import { offset as offset$1, flip as flip$1, shift as shift$1, arrow as arrow$2 } from '../../dom/dist/floating-ui.dom.js'; export { autoUpdate, computePosition, platform } from '../../dom/dist/floating-ui.dom.js'; import 'react'; import 'react-dom'; /** * Provides data to position an inner element of the floating element so that it * appears centered to the reference element. * This wraps the core `arrow` middleware to allow React refs as the element. * @see https://floating-ui.com/docs/arrow */ const arrow$1 = options => { function isRef(value) { return {}.hasOwnProperty.call(value, 'current'); } return { name: 'arrow', options, fn(state) { const { element, padding } = typeof options === 'function' ? options(state) : options; if (element && isRef(element)) { if (element.current != null) { return arrow$2({ element: element.current, padding }).fn(state); } return {}; } if (element) { return arrow$2({ element, padding }).fn(state); } return {}; } }; }; /** * Modifies the placement by translating the floating element along the * specified axes. * A number (shorthand for `mainAxis` or distance), or an axes configuration * object may be passed. * @see https://floating-ui.com/docs/offset */ const offset = (options, deps) => ({ ...offset$1(options), options: [options, deps] }); /** * Optimizes the visibility of the floating element by shifting it in order to * keep it in view when it will overflow the clipping boundary. * @see https://floating-ui.com/docs/shift */ const shift = (options, deps) => ({ ...shift$1(options), options: [options, deps] }); /** * Optimizes the visibility of the floating element by flipping the `placement` * in order to keep it in view when the preferred placement(s) will overflow the * clipping boundary. Alternative to `autoPlacement`. * @see https://floating-ui.com/docs/flip */ const flip = (options, deps) => ({ ...flip$1(options), options: [options, deps] }); /** * Provides data to position an inner element of the floating element so that it * appears centered to the reference element. * This wraps the core `arrow` middleware to allow React refs as the element. * @see https://floating-ui.com/docs/arrow */ const arrow = (options, deps) => ({ ...arrow$1(options), options: [options, deps] }); export { arrow, flip, offset, shift };