{"version":3,"names":["createChangeEventDetails","createGenericEventDetails","REASONS","CHANGE_VALUE_TICK_DELAY","DEFAULT_STEP","SCROLLING_POINTER_MOVE_DISTANCE","START_AUTO_CHANGE_DELAY","parseNumber","usePressAndHold","isTouchLikePointerType","pointerType","useNumberFieldButton","params","pressReason","isIncrement","incrementPress","decrementPress","commitValue","nativeEvent","allowInputSyncRef","current","parsedValue","inputValue","locale","formatOptionsRef","valueRef","setValue","undefined","direction","pointerHandlers","shouldSkipClick","disabled","readOnly","elementRef","inputRef","tickDelay","startDelay","scrollDistance","tick","triggerEvent","amount","getStepAmount","incrementValue","event","reason","onStop","committed","lastChangedValueRef","onValueCommitted","buttonProps","aria-readonly","id","tabIndex","style","handleEvent","onTouchStart","passive","onTouchEnd","onPointerUp","onPointerMove","onMouseEnter","onMouseLeave","onMouseUp","onClick","isDisabled","defaultPrevented","prev","onPointerDown","isMainButton","button","focus","props"],"sources":["use-number-field-button.ts"],"sourcesContent":["import {\n\tcreateChangeEventDetails,\n\tcreateGenericEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\nimport {\n\tCHANGE_VALUE_TICK_DELAY,\n\tDEFAULT_STEP,\n\tSCROLLING_POINTER_MOVE_DISTANCE,\n\tSTART_AUTO_CHANGE_DELAY,\n} from \"../utils/constants.ts\";\nimport { parseNumber } from \"../utils/parse.ts\";\nimport type {\n\tDirection,\n\tEventWithOptionalKeyState,\n\tIncrementValueParameters,\n} from \"../utils/types.ts\";\nimport {\n\ttype PressAndHoldPointerHandlers,\n\tusePressAndHold,\n} from \"../utils/use-press-and-hold.ts\";\nimport type { NumberFieldRootChangeEventDetails } from \"./number-field-root.tsx\";\nimport type {\n\tNumberFieldRootChangeEventReason,\n\tNumberFieldRootCommitEventDetails,\n} from \"./number-field-root-context.ts\";\n\nfunction isTouchLikePointerType(pointerType: string): boolean {\n\treturn pointerType === \"touch\" || pointerType === \"pen\";\n}\n\nexport interface UseNumberFieldButtonParameters {\n\tallowInputSyncRef: { current: boolean };\n\tdisabled: () => boolean;\n\tformatOptionsRef: { current: Intl.NumberFormatOptions | undefined };\n\tgetStepAmount: (event?: EventWithOptionalKeyState) => number | undefined;\n\tid: string;\n\tincrementValue: (amount: number, params: IncrementValueParameters) => boolean;\n\tinputRef: { current: HTMLInputElement | null };\n\tinputValue: () => string;\n\tisIncrement: boolean;\n\tlocale?: (() => Intl.LocalesArgument | undefined) | undefined;\n\treadOnly: () => boolean;\n\tsetValue: (\n\t\tvalue: number | null,\n\t\tdetails: NumberFieldRootChangeEventDetails,\n\t) => boolean;\n\tvalueRef: { current: number | null };\n\tlastChangedValueRef: { current: number | null };\n\tonValueCommitted: (\n\t\tvalue: number | null,\n\t\teventDetails: NumberFieldRootCommitEventDetails,\n\t) => void;\n}\n\nexport interface UseNumberFieldButtonReturn {\n\tprops: Record<string, unknown>;\n}\n\n/**\n * Shared handler factory for `<NumberField.Increment>` and\n * `<NumberField.Decrement>`. Mirrors React's\n * `useNumberFieldButton` — the single press path runs `commitValue` then\n * `incrementValue`; hold starts the auto-change sequence via\n * {@link usePressAndHold}.\n */\nexport function useNumberFieldButton(\n\tparams: UseNumberFieldButtonParameters,\n): UseNumberFieldButtonReturn {\n\tconst pressReason: NumberFieldRootChangeEventReason = params.isIncrement\n\t\t? REASONS.incrementPress\n\t\t: REASONS.decrementPress;\n\n\tfunction commitValue(nativeEvent: MouseEvent | PointerEvent): void {\n\t\tparams.allowInputSyncRef.current = true;\n\n\t\tconst parsedValue = parseNumber(\n\t\t\tparams.inputValue(),\n\t\t\tparams.locale?.(),\n\t\t\tparams.formatOptionsRef.current,\n\t\t);\n\n\t\tif (parsedValue !== null) {\n\t\t\tparams.valueRef.current = parsedValue;\n\t\t\tparams.setValue(\n\t\t\t\tparsedValue,\n\t\t\t\tcreateChangeEventDetails<\n\t\t\t\t\tNumberFieldRootChangeEventReason,\n\t\t\t\t\t{ direction?: Direction | undefined }\n\t\t\t\t>(pressReason, nativeEvent, undefined, {\n\t\t\t\t\tdirection: params.isIncrement ? 1 : -1,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tconst { pointerHandlers, shouldSkipClick } = usePressAndHold({\n\t\tdisabled: () => params.disabled() || params.readOnly(),\n\t\telementRef: params.inputRef,\n\t\ttickDelay: CHANGE_VALUE_TICK_DELAY,\n\t\tstartDelay: START_AUTO_CHANGE_DELAY,\n\t\tscrollDistance: SCROLLING_POINTER_MOVE_DISTANCE,\n\t\ttick(triggerEvent) {\n\t\t\tconst amount =\n\t\t\t\tparams.getStepAmount(triggerEvent as EventWithOptionalKeyState) ??\n\t\t\t\tDEFAULT_STEP;\n\t\t\treturn params.incrementValue(amount, {\n\t\t\t\tdirection: params.isIncrement ? 1 : -1,\n\t\t\t\tevent: triggerEvent,\n\t\t\t\treason: pressReason,\n\t\t\t});\n\t\t},\n\t\tonStop(nativeEvent: PointerEvent) {\n\t\t\tconst committed =\n\t\t\t\tparams.lastChangedValueRef.current ?? params.valueRef.current;\n\t\t\tparams.onValueCommitted(\n\t\t\t\tcommitted,\n\t\t\t\tcreateGenericEventDetails(pressReason, nativeEvent),\n\t\t\t);\n\t\t},\n\t});\n\n\tconst buttonProps: Record<string, unknown> = {\n\t\t// Seed `\"aria-readonly\"` with an empty string so Solid 2's DOM spread\n\t\t// keeps the key in `ownKeys` from render 1 (see\n\t\t// `test/internals/merge-props-undefined-attr.test.tsx`). `undefined`\n\t\t// collapses to \"absent\" via `mergePropsN`, but seeding avoids a late\n\t\t// binding issue when `readOnly` flips after render.\n\t\tget \"aria-readonly\"(): \"true\" | undefined {\n\t\t\treturn params.readOnly() ? \"true\" : undefined;\n\t\t},\n\t\t\"aria-label\": params.isIncrement ? \"Increase\" : \"Decrease\",\n\t\t\"aria-controls\": params.id,\n\t\ttabIndex: -1,\n\t\tstyle: {\n\t\t\t\"-webkit-user-select\": \"none\",\n\t\t\t\"user-select\": \"none\",\n\t\t},\n\t\t// `touchstart` is scroll-blocking: a plain `onTouchStart` prop registers a\n\t\t// non-passive listener (Chrome perf violation). The handler only flips a\n\t\t// flag, so register it passive via Solid's `on:` namespace (a non-function\n\t\t// value is forwarded as the `addEventListener` options). `touchend` is not\n\t\t// scroll-blocking, so it stays an ordinary prop.\n\t\t\"on:touchstart\": {\n\t\t\thandleEvent: pointerHandlers.onTouchStart,\n\t\t\tpassive: true,\n\t\t},\n\t\tonTouchEnd: pointerHandlers.onTouchEnd,\n\t\tonPointerUp: pointerHandlers.onPointerUp,\n\t\tonPointerMove: pointerHandlers.onPointerMove,\n\t\tonMouseEnter: pointerHandlers.onMouseEnter,\n\t\tonMouseLeave: pointerHandlers.onMouseLeave,\n\t\tonMouseUp: pointerHandlers.onMouseUp,\n\t\tonClick(event: MouseEvent) {\n\t\t\tconst isDisabled = params.disabled() || params.readOnly();\n\t\t\tif (event.defaultPrevented || isDisabled || shouldSkipClick(event)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcommitValue(event);\n\n\t\t\tconst amount = params.getStepAmount(event) ?? DEFAULT_STEP;\n\t\t\tconst prev = params.valueRef.current;\n\n\t\t\tparams.incrementValue(amount, {\n\t\t\t\tdirection: params.isIncrement ? 1 : -1,\n\t\t\t\tevent,\n\t\t\t\treason: pressReason,\n\t\t\t});\n\n\t\t\tconst committed =\n\t\t\t\tparams.lastChangedValueRef.current ?? params.valueRef.current;\n\t\t\tif (committed !== prev) {\n\t\t\t\tparams.onValueCommitted(\n\t\t\t\t\tcommitted,\n\t\t\t\t\tcreateGenericEventDetails(pressReason, event),\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tonPointerDown(event: PointerEvent) {\n\t\t\tconst isMainButton = !event.button || event.button === 0;\n\t\t\tif (\n\t\t\t\tevent.defaultPrevented ||\n\t\t\t\tparams.readOnly() ||\n\t\t\t\t!isMainButton ||\n\t\t\t\tparams.disabled()\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcommitValue(event);\n\n\t\t\tif (!isTouchLikePointerType(event.pointerType)) {\n\t\t\t\tparams.inputRef.current?.focus();\n\t\t\t}\n\n\t\t\tpointerHandlers.onPointerDown(event);\n\t\t},\n\t};\n\n\treturn { props: buttonProps };\n}\n\nexport type { PressAndHoldPointerHandlers };\n"],"mappings":"AAAA,SACCA,wBAAwB,EACxBC,yBAAyB,EACzBC,OAAO,QACD,sCAAsC;AAC7C,SACCC,uBAAuB,EACvBC,YAAY,EACZC,+BAA+B,EAC/BC,uBAAuB,QACjB,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,mBAAmB;AAM/C,SAECC,eAAe,QACT,gCAAgC;AAOvC,SAASC,sBAAsBA,CAACC,WAAmB,EAAW;EAC7D,OAAOA,WAAW,KAAK,OAAO,IAAIA,WAAW,KAAK,KAAK;AACxD;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CACnCC,MAAsC,EACT;EAC7B,MAAMC,WAA6C,GAAGD,MAAM,CAACE,WAAW,GACrEZ,OAAO,CAACa,cAAc,GACtBb,OAAO,CAACc,cAAc;EAEzB,SAASC,WAAWA,CAACC,WAAsC,EAAQ;IAClEN,MAAM,CAACO,iBAAiB,CAACC,OAAO,GAAG,IAAI;IAEvC,MAAMC,WAAW,GAAGd,WAAW,CAC9BK,MAAM,CAACU,UAAU,CAAC,CAAC,EACnBV,MAAM,CAACW,MAAM,GAAG,CAAC,EACjBX,MAAM,CAACY,gBAAgB,CAACJ,OACzB,CAAC;IAED,IAAIC,WAAW,KAAK,IAAI,EAAE;MACzBT,MAAM,CAACa,QAAQ,CAACL,OAAO,GAAGC,WAAW;MACrCT,MAAM,CAACc,QAAQ,CACdL,WAAW,EACXrB,wBAAwB,CAGtBa,WAAW,EAAEK,WAAW,EAAES,SAAS,EAAE;QACtCC,SAAS,EAAEhB,MAAM,CAACE,WAAW,GAAG,CAAC,GAAG,CAAC;MACtC,CAAC,CACF,CAAC;IACF;EACD;EAEA,MAAM;IAAEe,eAAe;IAAEC;EAAgB,CAAC,GAAGtB,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