UNPKG

@julo-ui/sliders

Version:

A React Slider component that implements input[type='range']

48 lines (46 loc) 1.87 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/range-slider/usecase/use-handle-focus-thumb.ts var use_handle_focus_thumb_exports = {}; __export(use_handle_focus_thumb_exports, { default: () => use_handle_focus_thumb_default }); module.exports = __toCommonJS(use_handle_focus_thumb_exports); var import_react = require("react"); function useHandleFocusThumb(options) { const { focusThumbOnChange, rootRef, ids, activeIndex } = options; const onFocusThumb = (0, import_react.useCallback)( (index) => { var _a; const targetIndex = index != null ? index : activeIndex; if (targetIndex === -1 || !focusThumbOnChange) return; const id = ids.getThumb(targetIndex); const thumb = (_a = rootRef.current) == null ? void 0 : _a.ownerDocument.getElementById(id); if (thumb) { setTimeout(() => thumb.focus()); } }, [activeIndex, focusThumbOnChange, ids, rootRef] ); return { onFocusThumb }; } var use_handle_focus_thumb_default = useHandleFocusThumb; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = {});