{"version":3,"names":["dynamic","createMemo","omit","userRef","mergeRootProps","resolveClassStyle","useSliderRootContext","sliderDataAttrs","formatNumber","value","locale","format","String","Intl","NumberFormat","SliderValue","props","context","outputFor","out","thumbMetadata","thumbMap","values","inputId","trimmed","trim","length","undefined","formattedValues","formatOptions","v","push","defaultDisplayValue","join","userClassStyle","state","userProps","internalSlot","aria-live","for","children","consumer","merged","Tag","as"],"sources":["slider-value.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { createMemo, omit } from \"solid-js\";\nimport { userRef } from \"../../internals/compose-refs\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type { BaseUIComponentProps } from \"../../internals/types\";\nimport {\n\ttype SliderRootState,\n\tuseSliderRootContext,\n} from \"../slider-root-context.ts\";\nimport { sliderDataAttrs } from \"../utils/state-attrs.ts\";\n\nexport interface SliderValueState extends SliderRootState {}\n\nexport interface SliderValueProps\n\textends Omit<BaseUIComponentProps<\"output\", SliderValueState>, \"children\"> {\n\t/** Tag/component to render. Defaults to `\"output\"`. */\n\tas?: ValidComponent;\n\t/**\n\t * Consumer-supplied renderer for the displayed value. Receives the array\n\t * of formatted values and the raw numeric array. Returning `null` falls\n\t * back to the default join.\n\t */\n\tchildren?:\n\t\t| null\n\t\t| ((\n\t\t\t\tformattedValues: readonly string[],\n\t\t\t\tvalues: readonly number[],\n\t\t  ) => JSX.Element)\n\t\t| undefined;\n\t/** @default 'off' */\n\t\"aria-live\"?: JSX.AriaAttributes[\"aria-live\"] | undefined;\n}\n\nfunction formatNumber(\n\tvalue: number,\n\tlocale: Intl.LocalesArgument | undefined,\n\tformat: Intl.NumberFormatOptions | undefined,\n): string {\n\tif (!format) return String(value);\n\ttry {\n\t\treturn new Intl.NumberFormat(locale, format).format(value);\n\t} catch {\n\t\treturn String(value);\n\t}\n}\n\n/**\n * Displays the current value of the slider as text. Renders an `<output>`\n * (or `as` override).\n *\n * `htmlFor` is composed from every registered thumb's `inputId` — reading\n * `thumbMap()` subscribes to thumb registrations so the attribute updates when\n * thumbs mount or unmount.\n *\n * §1 wave 3: replaces `renderElement` with `dynamic(() => props.as ?? \"output\")`.\n */\nexport function SliderValue(props: SliderValueProps): JSX.Element {\n\tconst context = useSliderRootContext();\n\n\tconst outputFor = createMemo((): string | undefined => {\n\t\tlet out = \"\";\n\t\tfor (const thumbMetadata of context.thumbMap().values()) {\n\t\t\tif (thumbMetadata?.inputId) {\n\t\t\t\tout += `${thumbMetadata.inputId} `;\n\t\t\t}\n\t\t}\n\t\tconst trimmed = out.trim();\n\t\treturn trimmed.length === 0 ? undefined : trimmed;\n\t});\n\n\tconst formattedValues = createMemo((): readonly string[] => {\n\t\tconst out: string[] = [];\n\t\tconst format = context.formatOptions();\n\t\tconst locale = context.locale();\n\t\tfor (const v of context.values()) {\n\t\t\tout.push(formatNumber(v, locale, format));\n\t\t}\n\t\treturn out;\n\t});\n\n\tconst defaultDisplayValue = createMemo((): string => {\n\t\treturn formattedValues().join(\" – \");\n\t});\n\n\t// Resolve `class`/`style` here so function values (stateful styling) are\n\t// invoked with the slider state instead of being spread to the DOM raw.\n\tconst userClassStyle = resolveClassStyle(props, () => context.state());\n\t// Strip our callback-shape `children` and `aria-live` (re-injected via the\n\t// internal slot below).\n\tconst userProps = omit(\n\t\tprops as Record<string, unknown>,\n\t\t\"as\",\n\t\t\"children\",\n\t\t\"aria-live\",\n\t\t\"class\",\n\t\t\"style\",\n\t\t\"attrs\",\n\t);\n\n\tconst internalSlot = {\n\t\tget \"aria-live\"() {\n\t\t\treturn props[\"aria-live\"] ?? \"off\";\n\t\t},\n\t\t// Solid 2 DOM binding uses native attribute name `for`, not\n\t\t// React's `htmlFor`. Seed `\"\"` so the key stays in `ownKeys`\n\t\t// on render 1 (see\n\t\t// `test/internals/merge-props-undefined-attr.test.tsx`).\n\t\tget for() {\n\t\t\treturn outputFor() ?? \"\";\n\t\t},\n\t\tget children() {\n\t\t\tconst consumer = props.children;\n\t\t\tif (typeof consumer === \"function\") {\n\t\t\t\treturn consumer(formattedValues(), context.values());\n\t\t\t}\n\t\t\treturn defaultDisplayValue();\n\t\t},\n\t};\n\n\tlet merged: Record<string, unknown> = mergeRootProps(\n\t\tinternalSlot,\n\t\tsliderDataAttrs(context.state),\n\t);\n\tmerged = mergeRootProps(merged, userClassStyle);\n\tmerged = mergeRootProps(merged, userProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"output\");\n\treturn <Tag {...merged} ref={userRef(props)} />;\n}\n\nexport namespace SliderValue {\n\texport type State = SliderValueState;\n\texport type Props = SliderValueProps;\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,UAAU,EAAEC,IAAI,QAAQ,UAAU;AAC3C,SAASC,OAAO,QAAQ,8BAA8B;AACtD,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,iBAAiB,QAAQ,qCAAqC;AAEvE,SAECC,oBAAoB,QACd,2BAA2B;AAClC,SAASC,eAAe,QAAQ,yBAAyB;AAwBzD,SAASC,YAAYA,CACpBC,KAAa,EACbC,MAAwC,EACxCC,MAA4C,EACnC;EACT,IAAI,CAACA,MAAM,EAAE,OAAOC,MAAM,CAACH,KAAK,CAAC;EACjC,IAAI;IACH,OAAO,IAAII,IAAI,CAACC,YAAY,CAACJ,MAAM,EAAEC,MAAM,CAAC,CAACA,MAAM,CAACF,KAAK,CAAC;EAC3D,CAAC,CAAC,MAAM;IACP,OAAOG,MAAM,CAACH,KAAK,CAAC;EACrB;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,WAAWA,CAACC,KAAuB,EAAe;EACjE,MAAMC,OAAO,GAAGX,oBAAoB,CAAC,CAAC;EAEtC,MAAMY,SAAS,GAAGjB,UAAU,CAAC,MAA0B;IACtD,IAAIkB,GAAG,GAAG,EAAE;IACZ,KAAK,M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