@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 5.18 kB
Source Map (JSON)
{"version":3,"file":"number-input.cjs","names":["createSlotComponent","numberInputStyle","useGroupItemProps","useNumberInput","useInputPropsContext","Input","ChevronUpIcon","ChevronDownIcon"],"sources":["../../../../src/components/number-input/number-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { HTMLStyledProps, ThemeProps, WithoutThemeProps } from \"../../core\"\nimport type { InputProps } from \"../input\"\nimport type { NumberInputStyle } from \"./number-input.style\"\nimport type { UseNumberInputProps } from \"./use-number-input\"\nimport { createSlotComponent } from \"../../core\"\nimport { useGroupItemProps } from \"../group\"\nimport { ChevronDownIcon, ChevronUpIcon } from \"../icon\"\nimport { Input, InputGroup, useInputPropsContext } from \"../input\"\nimport { numberInputStyle } from \"./number-input.style\"\nimport { useNumberInput } from \"./use-number-input\"\n\nexport interface NumberInputProps\n extends Omit<\n WithoutThemeProps<InputProps, NumberInputStyle>,\n keyof UseNumberInputProps\n >,\n ThemeProps<NumberInputStyle>,\n UseNumberInputProps {\n /**\n * The props for the control element.\n */\n controlProps?: NumberInputControlProps\n /**\n * The props for the decrement button element.\n */\n decrementProps?: NumberInputDecrementButtonProps\n /**\n * The props for the end element.\n */\n elementProps?: InputGroup.ElementProps\n /**\n * The props for the increment button element.\n */\n incrementProps?: NumberInputIncrementButtonProps\n /**\n * The props for the root element.\n */\n rootProps?: InputGroup.RootProps\n}\n\nconst {\n PropsContext: NumberInputPropsContext,\n usePropsContext: useNumberInputPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<NumberInputProps, NumberInputStyle>(\n \"number-input\",\n numberInputStyle,\n)\n\nexport { NumberInputPropsContext, useNumberInputPropsContext }\n\n/**\n * `NumberInput` is a component used to obtain numeric input from the user.\n *\n * @see https://yamada-ui.com/docs/components/number-input\n */\nexport const NumberInput = withProvider<\"input\", NumberInputProps>(\n ({\n className,\n css,\n colorScheme,\n controlProps,\n decrementProps,\n elementProps,\n incrementProps,\n rootProps,\n ...props\n }) => {\n const [groupItemProps, rest] = useGroupItemProps(props)\n const { getDecrementProps, getIncrementProps, getInputProps } =\n useNumberInput(rest)\n\n return (\n <InputGroup.Root\n className={className}\n css={css}\n colorScheme={colorScheme}\n {...groupItemProps}\n {...rootProps}\n >\n <NumberInputField {...getInputProps()} />\n\n <InputGroup.Element clickable {...elementProps}>\n <NumberInputControl {...controlProps}>\n <NumberInputIncrementButton\n {...getIncrementProps(incrementProps)}\n />\n <NumberInputDecrementButton\n {...getDecrementProps(decrementProps)}\n />\n </NumberInputControl>\n </InputGroup.Element>\n </InputGroup.Root>\n )\n },\n \"root\",\n)((props) => {\n const context = useInputPropsContext()\n\n return { ...context, ...props }\n})\n\ninterface NumberInputFieldProps extends InputProps {}\n\nconst NumberInputField = withContext<\"input\", NumberInputFieldProps>(\n Input,\n \"field\",\n)({ \"data-group-propagate\": \"\" })\n\ninterface NumberInputControlProps extends InputGroup.AddonProps {}\n\nconst NumberInputControl = withContext<\"div\", NumberInputControlProps>(\n \"div\",\n \"control\",\n)()\n\ntype NumberInputIncrementButtonProps = HTMLStyledProps<\"button\">\n\nconst NumberInputIncrementButton = withContext<\n \"button\",\n NumberInputIncrementButtonProps\n>(\"button\", [\"button\", \"increment\"])(({ children, ...rest }) => ({\n children: children ?? <ChevronUpIcon />,\n ...rest,\n}))\n\ntype NumberInputDecrementButtonProps = HTMLStyledProps<\"button\">\n\nconst NumberInputDecrementButton = withContext<\n \"button\",\n NumberInputDecrementButtonProps\n>(\"button\", [\"button\", \"decrement\"])(({ children, ...rest }) => ({\n children: children ?? <ChevronDownIcon />,\n ...rest,\n}))\n"],"mappings":";;;;;;;;;;;;;;;;;AA0CA,MAAM,EACJ,cAAc,yBACd,iBAAiB,4BACjB,aACA,iBACEA,6CACF,gBACAC,4CACD;;;;;;AASD,MAAa,cAAc,cACxB,EACC,WACA,KACA,aACA,cACA,gBACA,cACA,gBACA,UACA,GAAG,YACC;CACJ,MAAM,CAAC,gBAAgB,QAAQC,oCAAkB,MAAM;CACvD,MAAM,EAAE,mBAAmB,mBAAmB,kBAC5CC,wCAAe,KAAK;AAEtB,QACE;EACa;EACN;EACQ;EACb,GAAI;EACJ,GAAI;aAEJ,2CAAC,oBAAiB,GAAI,eAAe,GAAI,EAEzC;GAAoB;GAAU,GAAI;aAChC,4CAAC;IAAmB,GAAI;eACtB,2CAAC,8BACC,GAAI,kBAAkB,eAAe,GACrC,EACF,2CAAC,8BACC,GAAI,kBAAkB,eAAe,GACrC;KACiB;IACF;GACL;GAGtB,OACD,EAAE,UAAU;AAGX,QAAO;EAAE,GAFOC,oCAAsB;EAEjB,GAAG;EAAO;EAC/B;AAIF,MAAM,mBAAmB,YACvBC,qBACA,QACD,CAAC,EAAE,wBAAwB,IAAI,CAAC;AAIjC,MAAM,qBAAqB,YACzB,OACA,UACD,EAAE;AAIH,MAAM,6BAA6B,YAGjC,UAAU,CAAC,UAAU,YAAY,CAAC,EAAE,EAAE,SAAU,GAAG,YAAY;CAC/D,UAAU,YAAY,2CAACC,0CAAgB;CACvC,GAAG;CACJ,EAAE;AAIH,MAAM,6BAA6B,YAGjC,UAAU,CAAC,UAAU,YAAY,CAAC,EAAE,EAAE,SAAU,GAAG,YAAY;CAC/D,UAAU,YAAY,2CAACC,8CAAkB;CACzC,GAAG;CACJ,EAAE"}