@wordpress/components
Version:
UI components for WordPress.
1 lines • 33.3 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","names":["styles"],"sources":["../../../style-runtime/src/index.ts","../../src/range-control/style.module.scss","../../src/range-control/index.tsx"],"sourcesContent":["type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n","import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"4d5e856f6b\", \"._6a1e01adf97c4762__root{-webkit-tap-highlight-color:transparent;align-items:center;display:flex;justify-content:flex-start;min-height:40px;padding:0;position:relative;touch-action:none;width:100%}._6a1e01adf97c4762__root:where(._2495fc3509946926__is-compact){min-height:32px}._811431d1b36d2890__wrapper{--_wp-components-range-control-color:initial;color:var(--_wp-components-range-control-color);display:block;flex:1;height:30px;min-height:30px;position:relative;width:100%}._2bab18807adcbaf7__default-color{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}._325bd79ef1e3c6cc__before-icon,._4c163a0fe307fef3__after-icon{display:flex;margin-top:4px}:where(._6a1e01adf97c4762__root:not(._4e480ef72e95c007__is-rtl)) ._325bd79ef1e3c6cc__before-icon{margin-right:6px}:where(._6a1e01adf97c4762__root._4e480ef72e95c007__is-rtl) ._325bd79ef1e3c6cc__before-icon{margin-left:6px}:where(._6a1e01adf97c4762__root:not(._4e480ef72e95c007__is-rtl)) ._4c163a0fe307fef3__after-icon{margin-left:6px}:where(._6a1e01adf97c4762__root._4e480ef72e95c007__is-rtl) ._4c163a0fe307fef3__after-icon{margin-right:6px}._7f1276e73f11c614__rail{--_wp-components-range-control-rail-color:initial;background:var(--_wp-components-range-control-rail-color,var(--wpds-color-background-track-neutral,#dbdbdb));border-radius:9999px;display:block;height:4px;left:0;margin-top:13px;pointer-events:none;position:absolute;right:0;top:0}._7f1276e73f11c614__rail:where(._42c8b908ae7f250e__is-disabled){background:var(--wp-components-color-gray-100,var(--wpds-color-background-surface-neutral,#fcfcfc))}._404ee8010545d96e__track{--_wp-components-range-control-track-color:initial;background:var(--_wp-components-range-control-track-color);border-radius:9999px;display:block;height:4px;margin-top:13px;pointer-events:none;position:absolute;top:0}._404ee8010545d96e__track:where(._42c8b908ae7f250e__is-disabled){background:var(--wp-components-color-gray-400,var(--wpds-color-stroke-interactive-neutral,#8b8b8b))}@media not (prefers-reduced-motion){.is-marked ._404ee8010545d96e__track{transition:width .1s ease}}.cc773bc17fc1e078__marks{display:block;margin-top:17px;pointer-events:none;position:relative;user-select:none;width:100%}.f723c0a62c1430b7__mark{background-color:var(--wp-components-color-background,var(--wpds-color-background-surface-neutral-strong,#fff));height:4px;left:0;position:absolute;top:-4px;transform:translateX(-50%);width:2px;z-index:1}.d32fdc2beb8f564b__mark-label{color:var(--wp-components-color-gray-300,var(--wpds-color-stroke-surface-neutral,#dbdbdb));font-size:11px;position:absolute;top:8px;transform:translateX(-50%);white-space:nowrap}.d32fdc2beb8f564b__mark-label:where(:not(._4e480ef72e95c007__is-rtl)){left:0}.d32fdc2beb8f564b__mark-label:where(._4e480ef72e95c007__is-rtl){right:0;transform:translateX(50%)}.d32fdc2beb8f564b__mark-label:where(.a76ff600efef8300__is-filled){color:var(--wp-components-color-gray-700,var(--wpds-color-foreground-content-neutral-weak,#6e6e6e))}._4e662f841e7693d5__thumb-wrapper{align-items:center;background:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));border-radius:50%;display:flex;height:12px;justify-content:center;margin-top:9px;outline:0;pointer-events:none;position:absolute;top:0;user-select:none;width:12px;z-index:3}._4e662f841e7693d5__thumb-wrapper:where(._42c8b908ae7f250e__is-disabled){background:var(--wp-components-color-gray-400,var(--wpds-color-stroke-interactive-neutral,#8b8b8b))}._4e662f841e7693d5__thumb-wrapper{transform:translateX(4.5px)}:where(._6a1e01adf97c4762__root:not(._4e480ef72e95c007__is-rtl)) ._4e662f841e7693d5__thumb-wrapper{margin-left:-10px}:where(._6a1e01adf97c4762__root._4e480ef72e95c007__is-rtl) ._4e662f841e7693d5__thumb-wrapper{margin-right:-10px;transform:translateX(-4.5px)}@media not (prefers-reduced-motion){.is-marked ._4e662f841e7693d5__thumb-wrapper{transition:left .1s ease}}.c291efee9339b385__thumb{align-items:center;background:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));border-radius:50%;box-shadow:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);height:100%;outline:0;position:absolute;user-select:none;width:100%}.c291efee9339b385__thumb:where(._42c8b908ae7f250e__is-disabled){background:var(--wp-components-color-gray-400,var(--wpds-color-stroke-interactive-neutral,#8b8b8b))}.c291efee9339b385__thumb:where(._4c40282bc4b85f01__is-focused){outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--focus-color,var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9)));outline-offset:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px))}._9f9d2d76949b6e97__input{box-sizing:border-box;cursor:var(--wpds-cursor-control,pointer);display:block;height:100%;left:0;margin:0 -6px;opacity:0;outline:none;position:absolute;right:0;top:0;width:calc(100% + 12px)}.e5e0e57fa03659d3__tooltip{background:rgba(0,0,0,.8);border-radius:2px;color:#fff;display:none;font-size:12px;line-height:1.4;min-width:32px;opacity:0;padding:4px 8px;pointer-events:none;position:absolute;text-align:center;transform:translateX(-50%);user-select:none}.e5e0e57fa03659d3__tooltip:where(._4e480ef72e95c007__is-rtl){transform:translateX(50%)}.e5e0e57fa03659d3__tooltip:where(._3d76f75f23a3b86b__is-visible){display:inline-block;opacity:1}.e5e0e57fa03659d3__tooltip:where(:not(.a2c1548960f4840f__is-bottom)){top:-80%}.e5e0e57fa03659d3__tooltip:where(.a2c1548960f4840f__is-bottom){bottom:-80%}@media not (prefers-reduced-motion){.e5e0e57fa03659d3__tooltip{transition:opacity .12s ease,display allow-discrete .12s ease}}@starting-style{.e5e0e57fa03659d3__tooltip{opacity:0}}.ce0552937139bab7__input-number{display:inline-block;font-size:13px;margin-top:0}:where(._6a1e01adf97c4762__root:not(._4e480ef72e95c007__is-rtl)) .ce0552937139bab7__input-number{margin-left:16px!important}:where(._6a1e01adf97c4762__root._4e480ef72e95c007__is-rtl) .ce0552937139bab7__input-number{margin-right:16px!important}._17a230bac5de238b__action-right{display:block;margin-top:0}:where(._6a1e01adf97c4762__root:not(._4e480ef72e95c007__is-rtl)) ._17a230bac5de238b__action-right{margin-left:8px}:where(._6a1e01adf97c4762__root._4e480ef72e95c007__is-rtl) ._17a230bac5de238b__action-right{margin-right:8px}._17a230bac5de238b__action-right button,._17a230bac5de238b__action-right button.is-small{height:30px;margin-left:0;min-height:30px}._21ecef0ddd6b30cc__color-inherit{color:inherit}._09208cae4be0d86a__background-inherit{background:inherit}._0912537971ff850a__color-initial{color:initial}._2725e6ff88306d8d__background-initial{background:initial}._5ced90e174221615__color-unset{color:unset}.d26df97a68a49058__background-unset{background:unset}._6ffdbff3c2cce7b1__color-revert{color:revert}._39937b8ec4d503f0__background-revert{background:revert}._7f42d7000a4d1141__color-revert-layer{color:revert-layer}._869689f01bfa7a3a__background-revert-layer{background:revert-layer}@media (forced-colors:active){._7f1276e73f11c614__rail{background:GrayText}._404ee8010545d96e__track,._4e662f841e7693d5__thumb-wrapper,.c291efee9339b385__thumb{background:CanvasText}._404ee8010545d96e__track:where(._42c8b908ae7f250e__is-disabled),._4e662f841e7693d5__thumb-wrapper:where(._42c8b908ae7f250e__is-disabled),.c291efee9339b385__thumb:where(._42c8b908ae7f250e__is-disabled){background:GrayText}}\");\n}\nexport default {\"root\":\"_6a1e01adf97c4762__root\",\"is-compact\":\"_2495fc3509946926__is-compact\",\"wrapper\":\"_811431d1b36d2890__wrapper\",\"default-color\":\"_2bab18807adcbaf7__default-color\",\"before-icon\":\"_325bd79ef1e3c6cc__before-icon\",\"after-icon\":\"_4c163a0fe307fef3__after-icon\",\"is-rtl\":\"_4e480ef72e95c007__is-rtl\",\"rail\":\"_7f1276e73f11c614__rail\",\"is-disabled\":\"_42c8b908ae7f250e__is-disabled\",\"track\":\"_404ee8010545d96e__track\",\"marks\":\"cc773bc17fc1e078__marks\",\"mark\":\"f723c0a62c1430b7__mark\",\"mark-label\":\"d32fdc2beb8f564b__mark-label\",\"is-filled\":\"a76ff600efef8300__is-filled\",\"thumb-wrapper\":\"_4e662f841e7693d5__thumb-wrapper\",\"thumb\":\"c291efee9339b385__thumb\",\"is-focused\":\"_4c40282bc4b85f01__is-focused\",\"input\":\"_9f9d2d76949b6e97__input\",\"tooltip\":\"e5e0e57fa03659d3__tooltip\",\"is-visible\":\"_3d76f75f23a3b86b__is-visible\",\"is-bottom\":\"a2c1548960f4840f__is-bottom\",\"input-number\":\"ce0552937139bab7__input-number\",\"action-right\":\"_17a230bac5de238b__action-right\",\"color-inherit\":\"_21ecef0ddd6b30cc__color-inherit\",\"background-inherit\":\"_09208cae4be0d86a__background-inherit\",\"color-initial\":\"_0912537971ff850a__color-initial\",\"background-initial\":\"_2725e6ff88306d8d__background-initial\",\"color-unset\":\"_5ced90e174221615__color-unset\",\"background-unset\":\"d26df97a68a49058__background-unset\",\"color-revert\":\"_6ffdbff3c2cce7b1__color-revert\",\"background-revert\":\"_39937b8ec4d503f0__background-revert\",\"color-revert-layer\":\"_7f42d7000a4d1141__color-revert-layer\",\"background-revert-layer\":\"_869689f01bfa7a3a__background-revert-layer\"};\n","import clsx from 'clsx';\nimport type { ChangeEvent, FocusEvent, ForwardedRef } from 'react';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport {\n\tfloatClamp,\n\tuseControlledRangeValue,\n\tgetCSSWideKeyword,\n} from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport NumberControl from '../number-control';\nimport styles from './style.module.scss';\nimport type { RangeControlProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nconst NUMBER_CONTROL_WIDTH = 80;\n\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue( {\n\tresetFallbackValue,\n\tinitialPosition,\n}: Pick< RangeControlProps, 'resetFallbackValue' | 'initialPosition' > ) {\n\tif ( resetFallbackValue !== undefined ) {\n\t\treturn ! Number.isNaN( resetFallbackValue ) ? resetFallbackValue : null;\n\t}\n\n\tif ( initialPosition !== undefined ) {\n\t\treturn ! Number.isNaN( initialPosition ) ? initialPosition : null;\n\t}\n\n\treturn null;\n}\n\nfunction UnforwardedRangeControl(\n\tprops: WordPressComponentProps< RangeControlProps, 'input', false >,\n\tforwardedRef: ForwardedRef< HTMLInputElement >\n) {\n\tconst {\n\t\t// Prevent passing legacy props to internal component.\n\t\t__nextHasNoMarginBottom: _,\n\t\t__next40pxDefaultSize: _next40pxDefaultSize,\n\t\tafterIcon,\n\t\tallowReset = false,\n\t\tbeforeIcon,\n\t\tclassName,\n\t\tcolor: colorProp,\n\t\tcurrentInput,\n\t\tdisabled = false,\n\t\thelp,\n\t\thideLabelFromVision = false,\n\t\tinitialPosition,\n\t\tisShiftStepEnabled = true,\n\t\tlabel,\n\t\tmarks = false,\n\t\tmax = 100,\n\t\tmin = 0,\n\t\tonBlur = noop,\n\t\tonChange = noop,\n\t\tonFocus = noop,\n\t\tonMouseLeave = noop,\n\t\tonMouseMove = noop,\n\t\trailColor,\n\t\trenderTooltipContent = ( v ) => v,\n\t\tresetFallbackValue,\n\t\tshiftStep = 10,\n\t\tshowTooltip: showTooltipProp,\n\t\tsize = 'default',\n\t\tstep = 1,\n\t\ttrackColor,\n\t\tvalue: valueProp,\n\t\twithInputField = true,\n\t\t...otherProps\n\t} = props;\n\n\tconst [ value, setValue ] = useControlledRangeValue( {\n\t\tmin,\n\t\tmax,\n\t\tvalue: valueProp ?? null,\n\t\tinitial: initialPosition,\n\t} );\n\tconst isResetPendent = useRef( false );\n\n\tlet hasTooltip = showTooltipProp;\n\tlet hasInputField = withInputField;\n\n\tif ( step === 'any' ) {\n\t\t// The tooltip and number input field are hidden when the step is \"any\"\n\t\t// because the decimals get too lengthy to fit well.\n\t\thasTooltip = false;\n\t\thasInputField = false;\n\t}\n\n\tconst [ showTooltip, setShowTooltip ] = useState( hasTooltip );\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\n\tconst inputRef = useRef< HTMLInputElement >( null );\n\tconst isCurrentlyFocused = inputRef.current?.matches( ':focus' );\n\tconst isThumbFocused = ! disabled && isFocused;\n\n\tconst isValueReset = value === null;\n\tconst currentValue = value !== undefined ? value : currentInput;\n\n\tconst inputSliderValue = isValueReset ? '' : currentValue;\n\tconst rangeFillValue = isValueReset ? ( max - min ) / 2 + min : value;\n\n\tconst fillValue = isValueReset\n\t\t? 50\n\t\t: ( ( value - min ) / ( max - min ) ) * 100;\n\tconst fillValueOffset = `${ clamp( fillValue, 0, 100 ) }%`;\n\n\tconst classes = clsx( 'components-range-control', className );\n\n\tconst colorKeyword = getCSSWideKeyword( colorProp );\n\tconst trackColorKeyword = getCSSWideKeyword( trackColor );\n\n\tconst wrapperClasses = clsx(\n\t\t'components-range-control__wrapper',\n\t\tstyles.wrapper,\n\t\tcolorProp === undefined && styles[ 'default-color' ],\n\t\tcolorKeyword && styles[ `color-${ colorKeyword }` ],\n\t\t!! marks && 'is-marked'\n\t);\n\n\tconst id = useInstanceId(\n\t\tUnforwardedRangeControl,\n\t\t'inspector-range-control'\n\t);\n\tconst describedBy = !! help ? `${ id }__help` : undefined;\n\tconst enableTooltip = hasTooltip !== false && Number.isFinite( value );\n\n\tconst handleOnRangeChange = ( event: ChangeEvent< HTMLInputElement > ) => {\n\t\tconst nextValue = parseFloat( event.target.value );\n\t\tsetValue( nextValue );\n\t\tonChange( nextValue );\n\t};\n\n\tconst handleOnChange = ( next?: string ) => {\n\t\t// @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n\t\t// potentially receive a NaN when next is undefined.\n\t\tlet nextValue = parseFloat( next );\n\t\tsetValue( nextValue );\n\n\t\t/*\n\t\t * Calls onChange only when nextValue is numeric\n\t\t * otherwise may queue a reset for the blur event.\n\t\t */\n\t\tif ( ! isNaN( nextValue ) ) {\n\t\t\tif ( nextValue < min || nextValue > max ) {\n\t\t\t\tnextValue = floatClamp( nextValue, min, max ) as number;\n\t\t\t}\n\n\t\t\tonChange( nextValue );\n\t\t\tisResetPendent.current = false;\n\t\t} else if ( allowReset ) {\n\t\t\tisResetPendent.current = true;\n\t\t}\n\t};\n\n\tconst handleOnInputNumberBlur = () => {\n\t\tif ( isResetPendent.current ) {\n\t\t\thandleOnReset();\n\t\t\tisResetPendent.current = false;\n\t\t}\n\t};\n\n\tconst handleOnReset = () => {\n\t\t// Reset to `resetFallbackValue` if defined, otherwise set internal value\n\t\t// to `null` — which, if propagated to the `value` prop, will cause\n\t\t// the value to be reset to the `initialPosition` prop if defined.\n\t\tconst resetValue = Number.isNaN( resetFallbackValue )\n\t\t\t? null\n\t\t\t: ( resetFallbackValue ?? null );\n\n\t\tsetValue( resetValue );\n\n\t\t/**\n\t\t * Previously, this callback would always receive undefined as\n\t\t * an argument. This behavior is unexpected, specifically\n\t\t * when resetFallbackValue is defined.\n\t\t *\n\t\t * The value of undefined is not ideal. Passing it through\n\t\t * to internal <input /> elements would change it from a\n\t\t * controlled component to an uncontrolled component.\n\t\t *\n\t\t * For now, to minimize unexpected regressions, we're going to\n\t\t * preserve the undefined callback argument, except when a\n\t\t * resetFallbackValue is defined.\n\t\t */\n\t\tonChange( resetValue ?? undefined );\n\t};\n\n\tconst handleShowTooltip = () => setShowTooltip( true );\n\tconst handleHideTooltip = () => setShowTooltip( false );\n\n\tconst handleOnBlur = ( event: FocusEvent< HTMLInputElement > ) => {\n\t\tonBlur( event );\n\t\tsetIsFocused( false );\n\t\thandleHideTooltip();\n\t};\n\n\tconst handleOnFocus = ( event: FocusEvent< HTMLInputElement > ) => {\n\t\tonFocus( event );\n\t\tsetIsFocused( true );\n\t\thandleShowTooltip();\n\t};\n\n\tconst offsetStyle = {\n\t\t[ isRTL() ? 'right' : 'left' ]: fillValueOffset,\n\t};\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName={ classes }\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ `${ id }` }\n\t\t\thelp={ help }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'components-range-control__root',\n\t\t\t\t\tstyles.root,\n\t\t\t\t\t{\n\t\t\t\t\t\t[ styles[ 'is-rtl' ] ]: isRTL(),\n\t\t\t\t\t\t[ styles[ 'is-compact' ] ]: size === 'compact',\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ beforeIcon && (\n\t\t\t\t\t<span className={ styles[ 'before-icon' ] }>\n\t\t\t\t\t\t<Icon icon={ beforeIcon } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div\n\t\t\t\t\tclassName={ wrapperClasses }\n\t\t\t\t\tstyle={\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'--_wp-components-range-control-color': colorProp,\n\t\t\t\t\t\t} as React.CSSProperties\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<InputRange\n\t\t\t\t\t\t{ ...otherProps }\n\t\t\t\t\t\tclassName=\"components-range-control__slider\"\n\t\t\t\t\t\tdescribedBy={ describedBy }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tid={ `${ id }` }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\t\t\tonChange={ handleOnRangeChange }\n\t\t\t\t\t\tonFocus={ handleOnFocus }\n\t\t\t\t\t\tonMouseMove={ onMouseMove }\n\t\t\t\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\t\t\t\tref={ useMergeRefs( [ inputRef, forwardedRef ] ) }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ inputSliderValue ?? undefined }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeRail\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tmarks={ marks }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\trailColor={ railColor }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ rangeFillValue }\n\t\t\t\t\t/>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'components-range-control__track',\n\t\t\t\t\t\t\tstyles.track,\n\t\t\t\t\t\t\t{ [ styles[ 'is-disabled' ] ]: disabled },\n\t\t\t\t\t\t\t! disabled &&\n\t\t\t\t\t\t\t\ttrackColorKeyword &&\n\t\t\t\t\t\t\t\tstyles[ `background-${ trackColorKeyword }` ]\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ...{ disabled } }\n\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\twidth: fillValueOffset,\n\t\t\t\t\t\t\t\t'--_wp-components-range-control-track-color':\n\t\t\t\t\t\t\t\t\ttrackColor || 'currentColor',\n\t\t\t\t\t\t\t} as React.CSSProperties\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'components-range-control__thumb-wrapper',\n\t\t\t\t\t\t\tstyles[ 'thumb-wrapper' ],\n\t\t\t\t\t\t\t{ [ styles[ 'is-disabled' ] ]: disabled }\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ offsetStyle }\n\t\t\t\t\t\t{ ...{ disabled } }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\tclassName={ clsx( styles.thumb, {\n\t\t\t\t\t\t\t\t[ styles[ 'is-disabled' ] ]: disabled,\n\t\t\t\t\t\t\t\t[ styles[ 'is-focused' ] ]: isThumbFocused,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t{ ...{ disabled } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</span>\n\t\t\t\t\t{ enableTooltip && (\n\t\t\t\t\t\t<SimpleTooltip\n\t\t\t\t\t\t\tclassName=\"components-range-control__tooltip\"\n\t\t\t\t\t\t\tinputRef={ inputRef }\n\t\t\t\t\t\t\ttooltipPlacement=\"bottom\"\n\t\t\t\t\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\t\t\t\t\tshow={ isCurrentlyFocused || showTooltip }\n\t\t\t\t\t\t\tstyle={ offsetStyle }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ afterIcon && (\n\t\t\t\t\t<span className={ styles[ 'after-icon' ] }>\n\t\t\t\t\t\t<Icon icon={ afterIcon } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ hasInputField && (\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'components-range-control__number',\n\t\t\t\t\t\t\tstyles[ 'input-number' ]\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tinputMode=\"decimal\"\n\t\t\t\t\t\tisShiftStepEnabled={ isShiftStepEnabled }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\tonBlur={ handleOnInputNumberBlur }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\tshiftStep={ shiftStep }\n\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t\t__unstableInputWidth={ `${ NUMBER_CONTROL_WIDTH }px` }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\t// @ts-expect-error TODO: Investigate if the `null` value is necessary\n\t\t\t\t\t\tvalue={ inputSliderValue }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowReset && (\n\t\t\t\t\t<span className={ styles[ 'action-right' ] }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"components-range-control__reset\"\n\t\t\t\t\t\t\t// If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n\t\t\t\t\t\t\taccessibleWhenDisabled={ ! disabled }\n\t\t\t\t\t\t\t// The reset button should be disabled if RangeControl itself is disabled,\n\t\t\t\t\t\t\t// or if the current `value` is equal to the value that would be currently\n\t\t\t\t\t\t\t// assigned when clicking the button.\n\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\tdisabled ||\n\t\t\t\t\t\t\t\tvalue ===\n\t\t\t\t\t\t\t\t\tcomputeResetValue( {\n\t\t\t\t\t\t\t\t\t\tresetFallbackValue,\n\t\t\t\t\t\t\t\t\t\tinitialPosition,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef( UnforwardedRangeControl );\nRangeControl.displayName = 'RangeControl';\n\nexport default RangeControl;\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,IAAK,OAAO,aAAa,aACxB,iBAAkB,QAAS;CAG5B,OAAO,YAAY;AACpB;;;;;;;;;AAUA,SAAS,0BACR,gBACA,MACU;CACV,IAAK,CAAE,eAAe,MACrB,OAAO;CAGR,KAAM,MAAM,SAAS,eAAe,KAAK,iBACxC,SAAU,qBAAsB,EACjC,GACC,IAAK,MAAM,aAAc,oBAAqB,MAAM,MACnD,OAAO;CAIT,OAAO;AACR;;;;;;;;;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;CAC3E,IAAK,CAAE,eAAe,MACrB;CAGD,MAAM,UAAU,WAAW;CAC3B,IAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;CAEhE,IAAK,CAAE,gBAAiB;EACvB,iCAAiB,IAAI,IAAI;EACzB,QAAQ,eAAe,IAAK,gBAAgB,cAAe;CAC5D;CAEA,IAAK,eAAe,IAAK,IAAK,GAC7B;CAMD,IAAK,0BAA2B,gBAAgB,IAAK,GAAI;EACxD,eAAe,IAAK,IAAK;EACzB;CACD;CAEA,MAAM,QAAQ,eAAe,cAAe,OAAQ;CACpD,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