@foxford/ui 2.77.0 → 2.77.1-beta-0c09a09-20250813
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ActionBtn/ActionBtn.js.map +1 -1
- package/components/ActionBtn/ActionBtn.mjs.map +1 -1
- package/components/Amount/Amount.js.map +1 -1
- package/components/Amount/Amount.mjs.map +1 -1
- package/components/Anchor/Anchor.js.map +1 -1
- package/components/Anchor/Anchor.mjs.map +1 -1
- package/components/Arrow/Arrow.js.map +1 -1
- package/components/Arrow/Arrow.mjs.map +1 -1
- package/components/ArrowBadge/ArrowBadge.js.map +1 -1
- package/components/ArrowBadge/ArrowBadge.mjs.map +1 -1
- package/components/Avatar/Avatar.js.map +1 -1
- package/components/Avatar/Avatar.mjs.map +1 -1
- package/components/Badge/Badge.js.map +1 -1
- package/components/Badge/Badge.mjs.map +1 -1
- package/components/Button/Button.js.map +1 -1
- package/components/Button/Button.mjs.map +1 -1
- package/components/Chip/Chip.js.map +1 -1
- package/components/Chip/Chip.mjs.map +1 -1
- package/components/Container/Container.js.map +1 -1
- package/components/Container/Container.mjs.map +1 -1
- package/components/ContextMenu/ContextMenu.js.map +1 -1
- package/components/ContextMenu/ContextMenu.mjs.map +1 -1
- package/components/ContextMenu/Item.js.map +1 -1
- package/components/ContextMenu/Item.mjs.map +1 -1
- package/components/ContextMenu.Multilevel/ContextMenu.Multilevel.js.map +1 -1
- package/components/ContextMenu.Multilevel/ContextMenu.Multilevel.mjs.map +1 -1
- package/components/Dropdown/Dropdown.js.map +1 -1
- package/components/Dropdown/Dropdown.mjs.map +1 -1
- package/components/FormLabel/FormLabel.js.map +1 -1
- package/components/FormLabel/FormLabel.mjs.map +1 -1
- package/components/Icon/Icon.js.map +1 -1
- package/components/Icon/Icon.mjs.map +1 -1
- package/components/IconButton/IconButton.js.map +1 -1
- package/components/IconButton/IconButton.mjs.map +1 -1
- package/components/Indicator/Indicator.js.map +1 -1
- package/components/Indicator/Indicator.mjs.map +1 -1
- package/components/Input/Input.js.map +1 -1
- package/components/Input/Input.mjs.map +1 -1
- package/components/Input.Phone/Input.Phone.js.map +1 -1
- package/components/Input.Phone/Input.Phone.mjs.map +1 -1
- package/components/InputCheckbox/InputCheckbox.js.map +1 -1
- package/components/InputCheckbox/InputCheckbox.mjs.map +1 -1
- package/components/InputRadio/InputRadio.js.map +1 -1
- package/components/InputRadio/InputRadio.mjs.map +1 -1
- package/components/ListItem/ListItem.js.map +1 -1
- package/components/ListItem/ListItem.mjs.map +1 -1
- package/components/Menu/Menu.js.map +1 -1
- package/components/Menu/Menu.mjs.map +1 -1
- package/components/MenuComponent/MenuComponent.js.map +1 -1
- package/components/MenuComponent/MenuComponent.mjs.map +1 -1
- package/components/MenuContainer/MenuContainer.js.map +1 -1
- package/components/MenuContainer/MenuContainer.mjs.map +1 -1
- package/components/MenuDivider/MenuDivider.js.map +1 -1
- package/components/MenuDivider/MenuDivider.mjs.map +1 -1
- package/components/MenuList/MenuList.js.map +1 -1
- package/components/MenuList/MenuList.mjs.map +1 -1
- package/components/Modal/Modal.js.map +1 -1
- package/components/Modal/Modal.mjs.map +1 -1
- package/components/Notification/Notification.js.map +1 -1
- package/components/Notification/Notification.mjs.map +1 -1
- package/components/Paper/Paper.js.map +1 -1
- package/components/Paper/Paper.mjs.map +1 -1
- package/components/Progress/Progress.js.map +1 -1
- package/components/Progress/Progress.mjs.map +1 -1
- package/components/Progress.Circle/Progress.Circle.js.map +1 -1
- package/components/Progress.Circle/Progress.Circle.mjs.map +1 -1
- package/components/Progress.Segmented/Progress.Segmented.js.map +1 -1
- package/components/Progress.Segmented/Progress.Segmented.mjs.map +1 -1
- package/components/ProgressCircle/ProgressCircle.js.map +1 -1
- package/components/ProgressCircle/ProgressCircle.mjs.map +1 -1
- package/components/ProgressLine/ProgressLine.js.map +1 -1
- package/components/ProgressLine/ProgressLine.mjs.map +1 -1
- package/components/Radio/Radio.js.map +1 -1
- package/components/Radio/Radio.mjs.map +1 -1
- package/components/Section/Section.js.map +1 -1
- package/components/Section/Section.mjs.map +1 -1
- package/components/Separator/Separator.js.map +1 -1
- package/components/Separator/Separator.mjs.map +1 -1
- package/components/Skeleton/Skeleton.js.map +1 -1
- package/components/Skeleton/Skeleton.mjs.map +1 -1
- package/components/Spacer/Spacer.js.map +1 -1
- package/components/Spacer/Spacer.mjs.map +1 -1
- package/components/Spinner/Spinner.js.map +1 -1
- package/components/Spinner/Spinner.mjs.map +1 -1
- package/components/Switch/Switch.js.map +1 -1
- package/components/Switch/Switch.mjs.map +1 -1
- package/components/Tab/Tab.js.map +1 -1
- package/components/Tab/Tab.mjs.map +1 -1
- package/components/Tabs/Tabs.js.map +1 -1
- package/components/Tabs/Tabs.mjs.map +1 -1
- package/components/Tag/Tag.js.map +1 -1
- package/components/Tag/Tag.mjs.map +1 -1
- package/components/Text/Text.js.map +1 -1
- package/components/Text/Text.mjs.map +1 -1
- package/components/Text.Ellipse/Text.Ellipse.js.map +1 -1
- package/components/Text.Ellipse/Text.Ellipse.mjs.map +1 -1
- package/components/Textarea/Textarea.js.map +1 -1
- package/components/Textarea/Textarea.mjs.map +1 -1
- package/components/Tooltip/Tooltip.js.map +1 -1
- package/components/Tooltip/Tooltip.mjs.map +1 -1
- package/components/TooltipComponent/TooltipComponent.js.map +1 -1
- package/components/TooltipComponent/TooltipComponent.mjs.map +1 -1
- package/dts/index.d.ts +29 -165
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { forwardRef, useState, useImperativeHandle, useRef, useLayoutEffect, useMemo } from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { FormInputLabel, SIZES } from 'components/FormInputLabel'\nimport { FormInput } from 'components/FormInput'\nimport { InputPhone } from 'components/Input.Phone'\nimport { IconButton } from 'components/IconButton'\nimport { SIZES_ICON, SIZES_CONTROL } from './constants'\nimport * as Styled from './style'\nimport type { InputProps } from './types'\n\nconst COMPONENT_NAME = 'Input'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<input\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Input/types.ts).\n */\nconst Input: React.ForwardRefExoticComponent<InputProps> & { Phone: typeof InputPhone } = Object.assign(\n withMergedProps<InputProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputProps>>((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rounded = true,\n primary = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n width = theme.defaultInputControlsWidth,\n type = 'text',\n labelPosition = 'dynamic',\n iconProps = {},\n controls = {},\n addonButtonProps = {},\n preset,\n className,\n style,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n palette,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n error,\n success,\n label,\n icon,\n text,\n secondary,\n contrast,\n onColored,\n fluid,\n disabled,\n inline,\n inputRef,\n ...inputProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const { icon: additionalControlIcon, buttonProps: additionalControlButtonProps = {} } = controls.additional ?? {}\n\n const [iconBefore, iconAfter = !additionalControlButtonProps.onClick ? additionalControlIcon : undefined] =\n Array.isArray(icon) ? icon : [icon]\n\n const addonControlIcon = addonButtonProps.icon ?? additionalControlIcon\n\n const inputAlwaysActive = Boolean(inputProps.mask && inputProps.alwaysShowMask)\n\n const controlPalette = {\n color: palette.controlsColor,\n colorHover: palette.controlsColorHover,\n colorActive: palette.controlsColorActive,\n colorDisabled: palette.controlsColorDisabled,\n backgroundColor: palette.controlsBackgroundColor,\n backgroundColorHover: palette.controlsBackgroundColorHover,\n backgroundColorActive: palette.controlsBackgroundColorActive,\n backgroundColorDisabled: palette.controlsBackgroundColorDisabled,\n }\n\n const ref = useRef<HTMLInputElement | null>(null)\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(forwardedRef, () => ref.current, [])\n\n const addonRef = useRef<HTMLButtonElement | null>(null)\n const minusRef = useRef<HTMLButtonElement | null>(null)\n const plusRef = useRef<HTMLButtonElement | null>(null)\n\n const inputLabelId = useMemo(() => nanoid(), [])\n\n const [inputActive, setInputActive] = useState(() => {\n if (inputAlwaysActive) return true\n\n const initValue = inputProps.value ?? inputProps.defaultValue\n\n return (typeof initValue === 'string' && initValue.length > 0) || typeof initValue === 'number'\n })\n\n const [minusDisabled, setMinusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.min === undefined) return false\n\n const { value = Infinity, defaultValue = Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const minValue = typeof inputProps.min === 'number' ? inputProps.min : parseFloat(inputProps.min)\n\n return Math.min(initValue, initDefaultValue) <= minValue\n })\n\n const [plusDisabled, setPlusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.max === undefined) return false\n\n const { value = -Infinity, defaultValue = -Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const maxValue = typeof inputProps.max === 'number' ? inputProps.max : parseFloat(inputProps.max)\n\n return Math.max(initValue, initDefaultValue) >= maxValue\n })\n\n useLayoutEffect(() => {\n if (inputAlwaysActive) {\n setInputActive(true)\n } else if (\n inputProps.value !== undefined &&\n inputProps.value !== null &&\n ref.current &&\n ref.current !== document.activeElement\n ) {\n setInputActive(\n (typeof inputProps.value === 'string' && inputProps.value.length > 0) ||\n typeof inputProps.value === 'number'\n )\n }\n }, [inputAlwaysActive, inputProps.value])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...inputProps}\n inputRef={\n inputRef ??\n ((input) => {\n ref.current = input\n })\n }\n className={className}\n style={style}\n size={typeof size === 'number' ? size : undefined}\n rounded={rounded}\n color={color}\n placeholderColor={placeholderColor}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n error={error}\n type={type}\n fluid={fluid}\n disabled={disabled}\n />\n )\n }\n\n return (\n <FormInputLabel\n {...sizeProps}\n className={className}\n style={style}\n sizeUnits={sizeUnits}\n sizes={sizes}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n error={error}\n success={success}\n label={label}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n icon={[iconBefore, iconAfter]}\n text={text}\n primary={primary}\n secondary={secondary}\n contrast={contrast}\n onColored={onColored}\n disabled={disabled}\n inline={inline}\n active={inputActive}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n iconProps={{\n color: disabled ? 'content-disabled' : 'content-onmain-tertiary',\n sizes: SIZES_ICON,\n ...sizeProps,\n ...iconProps,\n }}\n onClick={() => {\n if (ref.current) {\n ref.current.focus()\n }\n }}\n onFocus={(evt) => {\n if (evt.target !== evt.currentTarget) {\n setInputActive(true)\n }\n }}\n onPointerDown={(evt) => {\n if (\n evt.target === ref.current ||\n !(evt.target instanceof Node) ||\n addonRef.current?.contains(evt.target) ||\n minusRef.current?.contains(evt.target) ||\n plusRef.current?.contains(evt.target)\n ) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (!inputAlwaysActive && ref.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setInputActive(Boolean(ref.current.value))\n }\n }}\n input={\n <FormInput\n {...inputProps}\n aria-labelledby={label ? inputLabelId : undefined}\n ref={ref}\n type={type}\n disabled={disabled}\n palette={{\n color: palette.inputColor,\n placeholderColor: palette.inputPlaceholderColor,\n colorDisabled: palette.inputColorDisabled,\n placeholderColorDisabled: palette.inputPlaceholderColorDisabled,\n }}\n onChange={(evt) => {\n if (inputProps.onChange) {\n inputProps.onChange(evt)\n }\n\n if (type === 'number') {\n const currentValue = parseFloat(evt.currentTarget.value)\n\n const minValueReached = currentValue <= parseFloat(evt.currentTarget.min)\n const maxValueReached = currentValue >= parseFloat(evt.currentTarget.max)\n\n setMinusDisabled(minValueReached)\n setPlusDisabled(maxValueReached)\n\n if (minValueReached || maxValueReached) {\n evt.currentTarget.focus()\n }\n }\n }}\n />\n }\n addon={\n (addonButtonProps.onClick || additionalControlButtonProps.onClick) && addonControlIcon ? (\n <IconButton\n ref={addonRef}\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n {...sizeProps}\n {...additionalControlButtonProps}\n {...addonButtonProps}\n icon={addonControlIcon}\n disabled={disabled || addonButtonProps.disabled || additionalControlButtonProps.disabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n if (addonButtonProps.onClick) addonButtonProps.onClick(evt)\n if (additionalControlButtonProps.onClick) additionalControlButtonProps.onClick(evt)\n }}\n />\n ) : undefined\n }\n controls={\n type === 'number' ? (\n <>\n <IconButton\n {...sizeProps}\n ref={minusRef}\n icon='minus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || minusDisabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepDown()\n\n const decremented = ref.current.value\n if (prev !== decremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n <Styled.IconButtonSeparated\n {...sizeProps}\n ref={plusRef}\n icon='plus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || plusDisabled}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepUp()\n\n const incremented = ref.current.value\n if (prev !== incremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n ),\n {\n Phone: InputPhone,\n }\n)\n\nexport { Input, COMPONENT_NAME }\n"],"names":["Input","Object","assign","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rounded","primary","color","placeholderColor","width","defaultInputControlsWidth","type","labelPosition","iconProps","controls","addonButtonProps","preset","className","style","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","palette","widthXXS","widthXS","widthS","widthM","widthL","widthXL","error","success","label","icon","text","secondary","contrast","onColored","fluid","disabled","inline","inputRef","inputProps","sizeProps","additionalControlIcon","buttonProps","additionalControlButtonProps","additional","iconBefore","iconAfter","onClick","undefined","Array","isArray","addonControlIcon","inputAlwaysActive","Boolean","mask","alwaysShowMask","controlPalette","controlsColor","colorHover","controlsColorHover","colorActive","controlsColorActive","colorDisabled","controlsColorDisabled","backgroundColor","controlsBackgroundColor","backgroundColorHover","controlsBackgroundColorHover","backgroundColorActive","controlsBackgroundColorActive","backgroundColorDisabled","controlsBackgroundColorDisabled","ref","useRef","useImperativeHandle","current","addonRef","minusRef","plusRef","inputLabelId","useMemo","nanoid","inputActive","setInputActive","useState","initValue","value","defaultValue","length","minusDisabled","setMinusDisabled","min","Infinity","parseFloat","initDefaultValue","minValue","Math","plusDisabled","setPlusDisabled","max","maxValue","useLayoutEffect","document","activeElement","_jsx","Styled","input","FormInputLabel","labelId","active","borderColor","borderColorDisabled","SIZES_ICON","focus","onFocus","evt","target","currentTarget","onPointerDown","Node","contains","preventDefault","onBlur","relatedTarget","jsx","FormInput","inputColor","inputPlaceholderColor","inputColorDisabled","placeholderColorDisabled","inputPlaceholderColorDisabled","onChange","currentValue","minValueReached","maxValueReached","addon","IconButton","SIZES_CONTROL","stopPropagation","readOnly","_jsxs","_Fragment","children","prev","stepDown","event","Event","bubbles","dispatchEvent","err","console","stepUp","SIZES","displayName","Phone","InputPhone"],"mappings":"4jBAyBA,MAAMA,MAAoFC,OAAOC,OAC/FC,gBAAAA,gBACEC,MAAAA,YAAsD,CAACC,EAAOC,KAC5D,MAAMC,EAAQC,OAAAA,WAEd,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EAAIC,QACdA,GAAU,EAAIC,MACdA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,MAC3BA,EAAQP,EAAMQ,0BAAyBC,KACvCA,EAAO,OAAMC,cACbA,EAAgB,UAASC,UACzBA,EAAY,CAAE,EAAAC,SACdA,EAAW,CAAE,EAAAC,iBACbA,EAAmB,CAAE,EAAAC,OACrBA,EAAMC,UACNA,QACAC,EAAKC,QACLA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,MACTA,EAAKC,OACLA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,QACPA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,UACRA,EAASC,aACTA,EAAYC,YACZA,EAAWC,WACXA,EAAUC,WACVA,EAAUC,WACVA,EAAUC,YACVA,EAAWC,YACXA,EAAWC,eACXA,EAAcC,cACdA,EAAaC,aACbA,EAAYC,aACZA,EAAYC,aACZA,EAAYC,cACZA,EAAaC,aACbA,EAAYC,gBACZA,EAAeC,eACfA,EAAcC,cACdA,EAAaC,cACbA,EAAaC,cACbA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AAM,QAAS,CAAEC,SAAS,IAC5C3E,GAAIG,QAAQyE,cAAcH,EAC5B,CACF,CACD,CAAC,MAAOI,GACPC,QAAQ3H,MAAM0H,EAChB,aAIJrG,GAEN,IAGN,CACEhE,MAAOwK,UAAKA,MACZC,YApbiB,UAubrB,CACEC,MAAOC,YAAAA,oCAxbY"}
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { forwardRef, useState, useImperativeHandle, useRef, useLayoutEffect, useMemo } from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { FormInputLabel, SIZES } from 'components/FormInputLabel'\nimport { FormInput } from 'components/FormInput'\nimport { InputPhone } from 'components/Input.Phone'\nimport { IconButton } from 'components/IconButton'\nimport { SIZES_ICON, SIZES_CONTROL } from './constants'\nimport * as Styled from './style'\nimport type { InputProps } from './types'\n\nconst COMPONENT_NAME = 'Input'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<input\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Input/types.ts).\n */\nconst Input: React.ForwardRefExoticComponent<InputProps> & { Phone: typeof InputPhone } = Object.assign(\n withMergedProps<InputProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputProps>>((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rounded = true,\n primary = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n width = theme.defaultInputControlsWidth,\n type = 'text',\n labelPosition = 'dynamic',\n iconProps = {},\n controls = {},\n addonButtonProps = {},\n preset,\n className,\n style,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n palette,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n error,\n success,\n label,\n icon,\n text,\n secondary,\n contrast,\n onColored,\n fluid,\n disabled,\n inline,\n inputRef,\n ...inputProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const { icon: additionalControlIcon, buttonProps: additionalControlButtonProps = {} } = controls.additional ?? {}\n\n const [iconBefore, iconAfter = !additionalControlButtonProps.onClick ? additionalControlIcon : undefined] =\n Array.isArray(icon) ? icon : [icon]\n\n const addonControlIcon = addonButtonProps.icon ?? additionalControlIcon\n\n const inputAlwaysActive = Boolean(inputProps.mask && inputProps.alwaysShowMask)\n\n const controlPalette = {\n color: palette.controlsColor,\n colorHover: palette.controlsColorHover,\n colorActive: palette.controlsColorActive,\n colorDisabled: palette.controlsColorDisabled,\n backgroundColor: palette.controlsBackgroundColor,\n backgroundColorHover: palette.controlsBackgroundColorHover,\n backgroundColorActive: palette.controlsBackgroundColorActive,\n backgroundColorDisabled: palette.controlsBackgroundColorDisabled,\n }\n\n const ref = useRef<HTMLInputElement | null>(null)\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(forwardedRef, () => ref.current, [])\n\n const addonRef = useRef<HTMLButtonElement | null>(null)\n const minusRef = useRef<HTMLButtonElement | null>(null)\n const plusRef = useRef<HTMLButtonElement | null>(null)\n\n const inputLabelId = useMemo(() => nanoid(), [])\n\n const [inputActive, setInputActive] = useState(() => {\n if (inputAlwaysActive) return true\n\n const initValue = inputProps.value ?? inputProps.defaultValue\n\n return (typeof initValue === 'string' && initValue.length > 0) || typeof initValue === 'number'\n })\n\n const [minusDisabled, setMinusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.min === undefined) return false\n\n const { value = Infinity, defaultValue = Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const minValue = typeof inputProps.min === 'number' ? inputProps.min : parseFloat(inputProps.min)\n\n return Math.min(initValue, initDefaultValue) <= minValue\n })\n\n const [plusDisabled, setPlusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.max === undefined) return false\n\n const { value = -Infinity, defaultValue = -Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const maxValue = typeof inputProps.max === 'number' ? inputProps.max : parseFloat(inputProps.max)\n\n return Math.max(initValue, initDefaultValue) >= maxValue\n })\n\n useLayoutEffect(() => {\n if (inputAlwaysActive) {\n setInputActive(true)\n } else if (\n inputProps.value !== undefined &&\n inputProps.value !== null &&\n ref.current &&\n ref.current !== document.activeElement\n ) {\n setInputActive(\n (typeof inputProps.value === 'string' && inputProps.value.length > 0) ||\n typeof inputProps.value === 'number'\n )\n }\n }, [inputAlwaysActive, inputProps.value])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...inputProps}\n inputRef={\n inputRef ??\n ((input) => {\n ref.current = input\n })\n }\n className={className}\n style={style}\n size={typeof size === 'number' ? size : undefined}\n rounded={rounded}\n color={color}\n placeholderColor={placeholderColor}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n error={error}\n type={type}\n fluid={fluid}\n disabled={disabled}\n />\n )\n }\n\n return (\n <FormInputLabel\n {...sizeProps}\n className={className}\n style={style}\n sizeUnits={sizeUnits}\n sizes={sizes}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n error={error}\n success={success}\n label={label}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n icon={[iconBefore, iconAfter]}\n text={text}\n primary={primary}\n secondary={secondary}\n contrast={contrast}\n onColored={onColored}\n disabled={disabled}\n inline={inline}\n active={inputActive}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n iconProps={{\n color: disabled ? 'content-disabled' : 'content-onmain-tertiary',\n sizes: SIZES_ICON,\n ...sizeProps,\n ...iconProps,\n }}\n onClick={() => {\n if (ref.current) {\n ref.current.focus()\n }\n }}\n onFocus={(evt) => {\n if (evt.target !== evt.currentTarget) {\n setInputActive(true)\n }\n }}\n onPointerDown={(evt) => {\n if (\n evt.target === ref.current ||\n !(evt.target instanceof Node) ||\n addonRef.current?.contains(evt.target) ||\n minusRef.current?.contains(evt.target) ||\n plusRef.current?.contains(evt.target)\n ) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (!inputAlwaysActive && ref.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setInputActive(Boolean(ref.current.value))\n }\n }}\n input={\n <FormInput\n {...inputProps}\n aria-labelledby={label ? inputLabelId : undefined}\n ref={ref}\n type={type}\n disabled={disabled}\n palette={{\n color: palette.inputColor,\n placeholderColor: palette.inputPlaceholderColor,\n colorDisabled: palette.inputColorDisabled,\n placeholderColorDisabled: palette.inputPlaceholderColorDisabled,\n }}\n onChange={(evt) => {\n if (inputProps.onChange) {\n inputProps.onChange(evt)\n }\n\n if (type === 'number') {\n const currentValue = parseFloat(evt.currentTarget.value)\n\n const minValueReached = currentValue <= parseFloat(evt.currentTarget.min)\n const maxValueReached = currentValue >= parseFloat(evt.currentTarget.max)\n\n setMinusDisabled(minValueReached)\n setPlusDisabled(maxValueReached)\n\n if (minValueReached || maxValueReached) {\n evt.currentTarget.focus()\n }\n }\n }}\n />\n }\n addon={\n (addonButtonProps.onClick || additionalControlButtonProps.onClick) && addonControlIcon ? (\n <IconButton\n ref={addonRef}\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n {...sizeProps}\n {...additionalControlButtonProps}\n {...addonButtonProps}\n icon={addonControlIcon}\n disabled={disabled || addonButtonProps.disabled || additionalControlButtonProps.disabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n if (addonButtonProps.onClick) addonButtonProps.onClick(evt)\n if (additionalControlButtonProps.onClick) additionalControlButtonProps.onClick(evt)\n }}\n />\n ) : undefined\n }\n controls={\n type === 'number' ? (\n <>\n <IconButton\n {...sizeProps}\n ref={minusRef}\n icon='minus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || minusDisabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepDown()\n\n const decremented = ref.current.value\n if (prev !== decremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n <Styled.IconButtonSeparated\n {...sizeProps}\n ref={plusRef}\n icon='plus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || plusDisabled}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepUp()\n\n const incremented = ref.current.value\n if (prev !== incremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n ),\n {\n Phone: InputPhone,\n }\n)\n\nexport { Input, COMPONENT_NAME }\n"],"names":["Input","Object","assign","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rounded","primary","color","placeholderColor","width","defaultInputControlsWidth","type","labelPosition","iconProps","controls","addonButtonProps","preset","className","style","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","palette","widthXXS","widthXS","widthS","widthM","widthL","widthXL","error","success","label","icon","text","secondary","contrast","onColored","fluid","disabled","inline","inputRef","inputProps","sizeProps","additionalControlIcon","buttonProps","additionalControlButtonProps","additional","iconBefore","iconAfter","onClick","undefined","Array","isArray","addonControlIcon","inputAlwaysActive","Boolean","mask","alwaysShowMask","controlPalette","controlsColor","colorHover","controlsColorHover","colorActive","controlsColorActive","colorDisabled","controlsColorDisabled","backgroundColor","controlsBackgroundColor","backgroundColorHover","controlsBackgroundColorHover","backgroundColorActive","controlsBackgroundColorActive","backgroundColorDisabled","controlsBackgroundColorDisabled","ref","useRef","useImperativeHandle","current","addonRef","minusRef","plusRef","inputLabelId","useMemo","nanoid","inputActive","setInputActive","useState","initValue","value","defaultValue","length","minusDisabled","setMinusDisabled","min","Infinity","parseFloat","initDefaultValue","minValue","Math","plusDisabled","setPlusDisabled","max","maxValue","useLayoutEffect","document","activeElement","_jsx","Styled","input","FormInputLabel","labelId","active","borderColor","borderColorDisabled","SIZES_ICON","focus","onFocus","evt","target","currentTarget","onPointerDown","Node","contains","preventDefault","onBlur","relatedTarget","jsx","FormInput","inputColor","inputPlaceholderColor","inputColorDisabled","placeholderColorDisabled","inputPlaceholderColorDisabled","onChange","currentValue","minValueReached","maxValueReached","addon","IconButton","SIZES_CONTROL","stopPropagation","readOnly","_jsxs","_Fragment","children","prev","stepDown","event","Event","bubbles","dispatchEvent","err","console","stepUp","SIZES","displayName","Phone","InputPhone"],"mappings":"4jBAyBA,MAAMA,MAAoFC,OAAOC,OAC/FC,gBAAAA,gBACEC,MAAAA,YAAsD,CAACC,EAAOC,KAC5D,MAAMC,EAAQC,OAAAA,WAEd,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EAAIC,QACdA,GAAU,EAAIC,MACdA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,MAC3BA,EAAQP,EAAMQ,0BAAyBC,KACvCA,EAAO,OAAMC,cACbA,EAAgB,UAASC,UACzBA,EAAY,CAAE,EAAA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RD,IADgBvE,GAAIG,QAAQW,MACN,CACxB,MAAM2D,EAAQ,IAAIC,MAAM,QAAS,CAAEC,SAAS,IAC5C3E,GAAIG,QAAQyE,cAAcH,EAC5B,CACF,CACD,CAAC,MAAOI,GACPC,QAAQ3H,MAAM0H,EAChB,KAGJ7C,WAAAoB,IAACnB,0BAA0B,IACrBjE,GACJgC,IAAKM,GACLhD,KAAK,OACL9C,MAAOyJ,YAAcA,cACrBrH,QAASoC,GACTpB,SAAUA,IAAY6D,GACtBlD,QAAUoE,IAER,GADAA,EAAIuB,mBACAnG,GAAWoG,SAEf,IACE,GAAInE,GAAIG,QAAS,CACfQ,IAAe,GAEf,MAAM4D,EAAOvE,GAAIG,QAAQW,MAIzB,GAHAd,GAAIG,QAAQ4E,SAGRR,IADgBvE,GAAIG,QAAQW,MACN,CACxB,MAAM2D,EAAQ,IAAIC,MAAM,QAAS,CAAEC,SAAS,IAC5C3E,GAAIG,QAAQyE,cAAcH,EAC5B,CACF,CACD,CAAC,MAAOI,GACPC,QAAQ3H,MAAM0H,EAChB,aAIJrG,GAEN,IAGN,CACEhE,MAAOwK,UAAKA,MACZC,YApbiB,UAubrB,CACEC,MAAOC,YAAAA,oCAxbY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.mjs","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { forwardRef, useState, useImperativeHandle, useRef, useLayoutEffect, useMemo } from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { FormInputLabel, SIZES } from 'components/FormInputLabel'\nimport { FormInput } from 'components/FormInput'\nimport { InputPhone } from 'components/Input.Phone'\nimport { IconButton } from 'components/IconButton'\nimport { SIZES_ICON, SIZES_CONTROL } from './constants'\nimport * as Styled from './style'\nimport type { InputProps } from './types'\n\nconst COMPONENT_NAME = 'Input'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<input\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Input/types.ts).\n */\nconst Input: React.ForwardRefExoticComponent<InputProps> & { Phone: typeof InputPhone } = Object.assign(\n withMergedProps<InputProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputProps>>((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rounded = true,\n primary = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n width = theme.defaultInputControlsWidth,\n type = 'text',\n labelPosition = 'dynamic',\n iconProps = {},\n controls = {},\n addonButtonProps = {},\n preset,\n className,\n style,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n palette,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n error,\n success,\n label,\n icon,\n text,\n secondary,\n contrast,\n onColored,\n fluid,\n disabled,\n inline,\n inputRef,\n ...inputProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const { icon: additionalControlIcon, buttonProps: additionalControlButtonProps = {} } = controls.additional ?? {}\n\n const [iconBefore, iconAfter = !additionalControlButtonProps.onClick ? additionalControlIcon : undefined] =\n Array.isArray(icon) ? icon : [icon]\n\n const addonControlIcon = addonButtonProps.icon ?? additionalControlIcon\n\n const inputAlwaysActive = Boolean(inputProps.mask && inputProps.alwaysShowMask)\n\n const controlPalette = {\n color: palette.controlsColor,\n colorHover: palette.controlsColorHover,\n colorActive: palette.controlsColorActive,\n colorDisabled: palette.controlsColorDisabled,\n backgroundColor: palette.controlsBackgroundColor,\n backgroundColorHover: palette.controlsBackgroundColorHover,\n backgroundColorActive: palette.controlsBackgroundColorActive,\n backgroundColorDisabled: palette.controlsBackgroundColorDisabled,\n }\n\n const ref = useRef<HTMLInputElement | null>(null)\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(forwardedRef, () => ref.current, [])\n\n const addonRef = useRef<HTMLButtonElement | null>(null)\n const minusRef = useRef<HTMLButtonElement | null>(null)\n const plusRef = useRef<HTMLButtonElement | null>(null)\n\n const inputLabelId = useMemo(() => nanoid(), [])\n\n const [inputActive, setInputActive] = useState(() => {\n if (inputAlwaysActive) return true\n\n const initValue = inputProps.value ?? inputProps.defaultValue\n\n return (typeof initValue === 'string' && initValue.length > 0) || typeof initValue === 'number'\n })\n\n const [minusDisabled, setMinusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.min === undefined) return false\n\n const { value = Infinity, defaultValue = Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const minValue = typeof inputProps.min === 'number' ? inputProps.min : parseFloat(inputProps.min)\n\n return Math.min(initValue, initDefaultValue) <= minValue\n })\n\n const [plusDisabled, setPlusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.max === undefined) return false\n\n const { value = -Infinity, defaultValue = -Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const maxValue = typeof inputProps.max === 'number' ? inputProps.max : parseFloat(inputProps.max)\n\n return Math.max(initValue, initDefaultValue) >= maxValue\n })\n\n useLayoutEffect(() => {\n if (inputAlwaysActive) {\n setInputActive(true)\n } else if (\n inputProps.value !== undefined &&\n inputProps.value !== null &&\n ref.current &&\n ref.current !== document.activeElement\n ) {\n setInputActive(\n (typeof inputProps.value === 'string' && inputProps.value.length > 0) ||\n typeof inputProps.value === 'number'\n )\n }\n }, [inputAlwaysActive, inputProps.value])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...inputProps}\n inputRef={\n inputRef ??\n ((input) => {\n ref.current = input\n })\n }\n className={className}\n style={style}\n size={typeof size === 'number' ? size : undefined}\n rounded={rounded}\n color={color}\n placeholderColor={placeholderColor}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n error={error}\n type={type}\n fluid={fluid}\n disabled={disabled}\n />\n )\n }\n\n return (\n <FormInputLabel\n {...sizeProps}\n className={className}\n style={style}\n sizeUnits={sizeUnits}\n sizes={sizes}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n error={error}\n success={success}\n label={label}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n icon={[iconBefore, iconAfter]}\n text={text}\n primary={primary}\n secondary={secondary}\n contrast={contrast}\n onColored={onColored}\n disabled={disabled}\n inline={inline}\n active={inputActive}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n iconProps={{\n color: disabled ? 'content-disabled' : 'content-onmain-tertiary',\n sizes: SIZES_ICON,\n ...sizeProps,\n ...iconProps,\n }}\n onClick={() => {\n if (ref.current) {\n ref.current.focus()\n }\n }}\n onFocus={(evt) => {\n if (evt.target !== evt.currentTarget) {\n setInputActive(true)\n }\n }}\n onPointerDown={(evt) => {\n if (\n evt.target === ref.current ||\n !(evt.target instanceof Node) ||\n addonRef.current?.contains(evt.target) ||\n minusRef.current?.contains(evt.target) ||\n plusRef.current?.contains(evt.target)\n ) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (!inputAlwaysActive && ref.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setInputActive(Boolean(ref.current.value))\n }\n }}\n input={\n <FormInput\n {...inputProps}\n aria-labelledby={label ? inputLabelId : undefined}\n ref={ref}\n type={type}\n disabled={disabled}\n palette={{\n color: palette.inputColor,\n placeholderColor: palette.inputPlaceholderColor,\n colorDisabled: palette.inputColorDisabled,\n placeholderColorDisabled: palette.inputPlaceholderColorDisabled,\n }}\n onChange={(evt) => {\n if (inputProps.onChange) {\n inputProps.onChange(evt)\n }\n\n if (type === 'number') {\n const currentValue = parseFloat(evt.currentTarget.value)\n\n const minValueReached = currentValue <= parseFloat(evt.currentTarget.min)\n const maxValueReached = currentValue >= parseFloat(evt.currentTarget.max)\n\n setMinusDisabled(minValueReached)\n setPlusDisabled(maxValueReached)\n\n if (minValueReached || maxValueReached) {\n evt.currentTarget.focus()\n }\n }\n }}\n />\n }\n addon={\n (addonButtonProps.onClick || additionalControlButtonProps.onClick) && addonControlIcon ? (\n <IconButton\n ref={addonRef}\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n {...sizeProps}\n {...additionalControlButtonProps}\n {...addonButtonProps}\n icon={addonControlIcon}\n disabled={disabled || addonButtonProps.disabled || additionalControlButtonProps.disabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n if (addonButtonProps.onClick) addonButtonProps.onClick(evt)\n if (additionalControlButtonProps.onClick) additionalControlButtonProps.onClick(evt)\n }}\n />\n ) : undefined\n }\n controls={\n type === 'number' ? (\n <>\n <IconButton\n {...sizeProps}\n ref={minusRef}\n icon='minus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || minusDisabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepDown()\n\n const decremented = ref.current.value\n if (prev !== decremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n <Styled.IconButtonSeparated\n {...sizeProps}\n ref={plusRef}\n icon='plus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || plusDisabled}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepUp()\n\n const incremented = ref.current.value\n if (prev !== incremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n ),\n {\n Phone: InputPhone,\n }\n)\n\nexport { Input, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Input","Object","assign","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rounded","primary","color","placeholderColor","width","defaultInputControlsWidth","type","labelPosition","iconProps","controls","addonButtonProps","preset","className","style","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","palette","widthXXS","widthXS","widthS","widthM","widthL","widthXL","error","success","label","icon","text","secondary","contrast","onColored","fluid","disabled","inline","inputRef","inputProps","sizeProps","additionalControlIcon","buttonProps","additionalControlButtonProps","additional","iconBefore","iconAfter","onClick","undefined","Array","isArray","addonControlIcon","inputAlwaysActive","Boolean","mask","alwaysShowMask","controlPalette","controlsColor","colorHover","controlsColorHover","colorActive","controlsColorActive","colorDisabled","controlsColorDisabled","backgroundColor","controlsBackgroundColor","backgroundColorHover","controlsBackgroundColorHover","backgroundColorActive","controlsBackgroundColorActive","backgroundColorDisabled","controlsBackgroundColorDisabled","ref","useRef","useImperativeHandle","current","addonRef","minusRef","plusRef","inputLabelId","useMemo","nanoid","inputActive","setInputActive","useState","initValue","value","defaultValue","length","minusDisabled","setMinusDisabled","min","Infinity","parseFloat","initDefaultValue","minValue","Math","plusDisabled","setPlusDisabled","max","maxValue","useLayoutEffect","document","activeElement","_jsx","Styled","input","FormInputLabel","labelId","active","borderColor","borderColorDisabled","SIZES_ICON","focus","onFocus","evt","target","currentTarget","onPointerDown","Node","contains","preventDefault","onBlur","relatedTarget","FormInput","inputColor","inputPlaceholderColor","inputColorDisabled","placeholderColorDisabled","inputPlaceholderColorDisabled","onChange","currentValue","minValueReached","maxValueReached","addon","IconButton","SIZES_CONTROL","stopPropagation","readOnly","_jsxs","_Fragment","children","prev","stepDown","event","Event","bubbles","dispatchEvent","err","console","stepUp","SIZES","displayName","Phone","InputPhone"],"mappings":"ooBAaMA,MAAAA,eAAiB,QAYvB,MAAMC,MAAoFC,OAAOC,OAC/FC,gBACEC,YAAsD,CAACC,EAAOC,KAC5D,MAAMC,EAAQC,WAEd,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EAAIC,QACdA,GAAU,EAAIC,MACdA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,MAC3BA,EAAQP,EAAMQ,0BAAyBC,KACvCA,EAAO,OAAMC,cACbA,EAAgB,UAASC,UACzBA,EAAY,CAAE,EAAAC,SACdA,EAAW,CAAE,EAAAC,iBACbA,EAAmB,CAAE,EAAAC,OACrBA,EAAMC,UACNA,EAASC,MACTA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,MACTA,EAAKC,OACLA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,QACPA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,UACRA,EAASC,aACTA,EAAYC,YACZA,EAAWC,WACXA,EAAUC,WACVA,EAAUC,WACVA,EAAUC,YACVA,EAAWC,YACXA,EAAWC,eACXA,EAAcC,cACdA,EAAaC,aACbA,EAAYC,aACZA,EAAYC,aACZA,EAAYC,cACZA,EAAaC,aACbA,EAAYC,gBACZA,EAAeC,eACfA,EAAcC,cACdA,EAAaC,cACbA,EAAaC,cACbA,EAAaC,eACbA,EAAcC,WACdA,EAAUC,cACVA,GAAaC,aACbA,GAAYC,YACZA,GAAWC,YACXA,GAAWC,YACXA,GAAWC,aACXA,GAAYC,QACZA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SAAS1E,EAAiB0E,QAAQoE,GACnDxE,GAA6BI,SAASJ,GAA6BI,QAAQoE,GAAI,SAGrFnE,EAEN5E,SACEH,IAAS,SACP0K,KAAAC,SAAA,CAAAC,SAAA,CACErC,IAAC+B,WAAU,IACL/F,GACJgC,IAAKK,GACL/C,KAAK,QACL9C,MAAOwJ,cACPpH,QAASoC,GACTpB,SAAUA,IAAYqD,GACtB5E,WAAY,GACZkC,QAAUoE,IAER,GADAA,EAAIsB,mBACAlG,GAAWmG,SAEf,IACE,GAAIlE,GAAIG,QAAS,CACfQ,IAAe,GAEf,MAAM2D,EAAOtE,GAAIG,QAAQW,MAIzB,GAHAd,GAAIG,QAAQoE,WAGRD,IADgBtE,GAAIG,QAAQW,MACN,CACxB,MAAM0D,EAAQ,IAAIC,MAAM,QAAS,CAAEC,SAAS,IAC5C1E,GAAIG,QAAQwE,cAAcH,EAC5B,CACF,CACD,CAAC,MAAOI,GACPC,QAAQ1H,MAAMyH,EAChB,KAGJ5C,IAACC,oBAA0B,IACrBjE,GACJgC,IAAKM,GACLhD,KAAK,OACL9C,MAAOwJ,cACPpH,QAASoC,GACTpB,SAAUA,IAAY6D,GACtBlD,QAAUoE,IAER,GADAA,EAAIsB,mBACAlG,GAAWmG,SAEf,IACE,GAAIlE,GAAIG,QAAS,CACfQ,IAAe,GAEf,MAAM2D,EAAOtE,GAAIG,QAAQW,MAIzB,GAHAd,GAAIG,QAAQ2E,SAGRR,IADgBtE,GAAIG,QAAQW,MACN,CACxB,MAAM0D,EAAQ,IAAIC,MAAM,QAAS,CAAEC,SAAS,IAC5C1E,GAAIG,QAAQwE,cAAcH,EAC5B,CACF,CACD,CAAC,MAAOI,GACPC,QAAQ1H,MAAMyH,EAChB,aAIJpG,GAEN,IAGN,CACEhE,MAAOuK,MACPC,YApbiB,UAubrB,CACEC,MAAOC"}
|
|
1
|
+
{"version":3,"file":"Input.mjs","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { forwardRef, useState, useImperativeHandle, useRef, useLayoutEffect, useMemo } from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { FormInputLabel, SIZES } from 'components/FormInputLabel'\nimport { FormInput } from 'components/FormInput'\nimport { InputPhone } from 'components/Input.Phone'\nimport { IconButton } from 'components/IconButton'\nimport { SIZES_ICON, SIZES_CONTROL } from './constants'\nimport * as Styled from './style'\nimport type { InputProps } from './types'\n\nconst COMPONENT_NAME = 'Input'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<input\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Input/types.ts).\n */\nconst Input: React.ForwardRefExoticComponent<InputProps> & { Phone: typeof InputPhone } = Object.assign(\n withMergedProps<InputProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputProps>>((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rounded = true,\n primary = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n width = theme.defaultInputControlsWidth,\n type = 'text',\n labelPosition = 'dynamic',\n iconProps = {},\n controls = {},\n addonButtonProps = {},\n preset,\n className,\n style,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n palette,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n error,\n success,\n label,\n icon,\n text,\n secondary,\n contrast,\n onColored,\n fluid,\n disabled,\n inline,\n inputRef,\n ...inputProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const { icon: additionalControlIcon, buttonProps: additionalControlButtonProps = {} } = controls.additional ?? {}\n\n const [iconBefore, iconAfter = !additionalControlButtonProps.onClick ? additionalControlIcon : undefined] =\n Array.isArray(icon) ? icon : [icon]\n\n const addonControlIcon = addonButtonProps.icon ?? additionalControlIcon\n\n const inputAlwaysActive = Boolean(inputProps.mask && inputProps.alwaysShowMask)\n\n const controlPalette = {\n color: palette.controlsColor,\n colorHover: palette.controlsColorHover,\n colorActive: palette.controlsColorActive,\n colorDisabled: palette.controlsColorDisabled,\n backgroundColor: palette.controlsBackgroundColor,\n backgroundColorHover: palette.controlsBackgroundColorHover,\n backgroundColorActive: palette.controlsBackgroundColorActive,\n backgroundColorDisabled: palette.controlsBackgroundColorDisabled,\n }\n\n const ref = useRef<HTMLInputElement | null>(null)\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(forwardedRef, () => ref.current, [])\n\n const addonRef = useRef<HTMLButtonElement | null>(null)\n const minusRef = useRef<HTMLButtonElement | null>(null)\n const plusRef = useRef<HTMLButtonElement | null>(null)\n\n const inputLabelId = useMemo(() => nanoid(), [])\n\n const [inputActive, setInputActive] = useState(() => {\n if (inputAlwaysActive) return true\n\n const initValue = inputProps.value ?? inputProps.defaultValue\n\n return (typeof initValue === 'string' && initValue.length > 0) || typeof initValue === 'number'\n })\n\n const [minusDisabled, setMinusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.min === undefined) return false\n\n const { value = Infinity, defaultValue = Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const minValue = typeof inputProps.min === 'number' ? inputProps.min : parseFloat(inputProps.min)\n\n return Math.min(initValue, initDefaultValue) <= minValue\n })\n\n const [plusDisabled, setPlusDisabled] = useState(() => {\n if (type !== 'number' || inputProps.max === undefined) return false\n\n const { value = -Infinity, defaultValue = -Infinity } = inputProps\n\n const initValue = typeof value === 'number' ? value : parseFloat(value)\n const initDefaultValue = typeof defaultValue === 'number' ? defaultValue : parseFloat(defaultValue)\n const maxValue = typeof inputProps.max === 'number' ? inputProps.max : parseFloat(inputProps.max)\n\n return Math.max(initValue, initDefaultValue) >= maxValue\n })\n\n useLayoutEffect(() => {\n if (inputAlwaysActive) {\n setInputActive(true)\n } else if (\n inputProps.value !== undefined &&\n inputProps.value !== null &&\n ref.current &&\n ref.current !== document.activeElement\n ) {\n setInputActive(\n (typeof inputProps.value === 'string' && inputProps.value.length > 0) ||\n typeof inputProps.value === 'number'\n )\n }\n }, [inputAlwaysActive, inputProps.value])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...inputProps}\n inputRef={\n inputRef ??\n ((input) => {\n ref.current = input\n })\n }\n className={className}\n style={style}\n size={typeof size === 'number' ? size : undefined}\n rounded={rounded}\n color={color}\n placeholderColor={placeholderColor}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n error={error}\n type={type}\n fluid={fluid}\n disabled={disabled}\n />\n )\n }\n\n return (\n <FormInputLabel\n {...sizeProps}\n className={className}\n style={style}\n sizeUnits={sizeUnits}\n sizes={sizes}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n error={error}\n success={success}\n label={label}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n icon={[iconBefore, iconAfter]}\n text={text}\n primary={primary}\n secondary={secondary}\n contrast={contrast}\n onColored={onColored}\n disabled={disabled}\n inline={inline}\n active={inputActive}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n iconProps={{\n color: disabled ? 'content-disabled' : 'content-onmain-tertiary',\n sizes: SIZES_ICON,\n ...sizeProps,\n ...iconProps,\n }}\n onClick={() => {\n if (ref.current) {\n ref.current.focus()\n }\n }}\n onFocus={(evt) => {\n if (evt.target !== evt.currentTarget) {\n setInputActive(true)\n }\n }}\n onPointerDown={(evt) => {\n if (\n evt.target === ref.current ||\n !(evt.target instanceof Node) ||\n addonRef.current?.contains(evt.target) ||\n minusRef.current?.contains(evt.target) ||\n plusRef.current?.contains(evt.target)\n ) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (!inputAlwaysActive && ref.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setInputActive(Boolean(ref.current.value))\n }\n }}\n input={\n <FormInput\n {...inputProps}\n aria-labelledby={label ? inputLabelId : undefined}\n ref={ref}\n type={type}\n disabled={disabled}\n palette={{\n color: palette.inputColor,\n placeholderColor: palette.inputPlaceholderColor,\n colorDisabled: palette.inputColorDisabled,\n placeholderColorDisabled: palette.inputPlaceholderColorDisabled,\n }}\n onChange={(evt) => {\n if (inputProps.onChange) {\n inputProps.onChange(evt)\n }\n\n if (type === 'number') {\n const currentValue = parseFloat(evt.currentTarget.value)\n\n const minValueReached = currentValue <= parseFloat(evt.currentTarget.min)\n const maxValueReached = currentValue >= parseFloat(evt.currentTarget.max)\n\n setMinusDisabled(minValueReached)\n setPlusDisabled(maxValueReached)\n\n if (minValueReached || maxValueReached) {\n evt.currentTarget.focus()\n }\n }\n }}\n />\n }\n addon={\n (addonButtonProps.onClick || additionalControlButtonProps.onClick) && addonControlIcon ? (\n <IconButton\n ref={addonRef}\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n {...sizeProps}\n {...additionalControlButtonProps}\n {...addonButtonProps}\n icon={addonControlIcon}\n disabled={disabled || addonButtonProps.disabled || additionalControlButtonProps.disabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n if (addonButtonProps.onClick) addonButtonProps.onClick(evt)\n if (additionalControlButtonProps.onClick) additionalControlButtonProps.onClick(evt)\n }}\n />\n ) : undefined\n }\n controls={\n type === 'number' ? (\n <>\n <IconButton\n {...sizeProps}\n ref={minusRef}\n icon='minus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || minusDisabled}\n marginLeft={12}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepDown()\n\n const decremented = ref.current.value\n if (prev !== decremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n <Styled.IconButtonSeparated\n {...sizeProps}\n ref={plusRef}\n icon='plus'\n sizes={SIZES_CONTROL}\n palette={controlPalette}\n disabled={disabled || plusDisabled}\n onClick={(evt) => {\n evt.stopPropagation()\n if (inputProps.readOnly) return\n\n try {\n if (ref.current) {\n setInputActive(true)\n\n const prev = ref.current.value\n ref.current.stepUp()\n\n const incremented = ref.current.value\n if (prev !== incremented) {\n const event = new Event('input', { bubbles: true })\n ref.current.dispatchEvent(event)\n }\n }\n } catch (err) {\n console.error(err)\n }\n }}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n ),\n {\n Phone: InputPhone,\n }\n)\n\nexport { Input, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Input","Object","assign","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rounded","primary","color","placeholderColor","width","defaultInputControlsWidth","type","labelPosition","iconProps","controls","addonButtonProps","preset","className","style","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","palette","widthXXS","widthXS","widthS","widthM","widthL","widthXL","error","success","label","icon","text","secondary","contrast","onColored","fluid","disabled","inline","inputRef","inputProps","sizeProps","additionalControlIcon","buttonProps","additionalControlButtonProps","additional","iconBefore","iconAfter","onClick","undefined","Array","isArray","addonControlIcon","inputAlwaysActive","Boolean","mask","alwaysShowMask","controlPalette","controlsColor","colorHover","controlsColorHover","colorActive","controlsColorActive","colorDisabled","controlsColorDisabled","backgroundColor","controlsBackgroundColor","backgroundColorHover","controlsBackgroundColorHover","backgroundColorActive","controlsBackgroundColorActive","backgroundColorDisabled","controlsBackgroundColorDisabled","ref","useRef","useImperativeHandle","current","addonRef","minusRef","plusRef","inputLabelId","useMemo","nanoid","inputActive","setInputActive","useState","initValue","value","defaultValue","length","minusDisabled","setMinusDisabled","min","Infinity","parseFloat","initDefaultValue","minValue","Math","plusDisabled","setPlusDisabled","max","maxValue","useLayoutEffect","document","activeElement","_jsx","Styled","input","FormInputLabel","labelId","active","borderColor","borderColorDisabled","SIZES_ICON","focus","onFocus","evt","target","currentTarget","onPointerDown","Node","contains","preventDefault","onBlur","relatedTarget","FormInput","inputColor","inputPlaceholderColor","inputColorDisabled","placeholderColorDisabled","inputPlaceholderColorDisabled","onChange","currentValue","minValueReached","maxValueReached","addon","IconButton","SIZES_CONTROL","stopPropagation","readOnly","_jsxs","_Fragment","children","prev","stepDown","event","Event","bubbles","dispatchEvent","err","console","stepUp","SIZES","displayName","Phone","InputPhone"],"mappings":"ooBAaMA,MAAAA,eAAiB,QAYvB,MAAMC,MAAoFC,OAAOC,OAC/FC,gBACEC,YAAsD,CAACC,EAAOC,KAC5D,MAAMC,EAAQC,WAEd,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EAAIC,QACdA,GAAU,EAAIC,MACdA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,MAC3BA,EAAQP,EAAMQ,0BAAyBC,KACvCA,EAAO,OAAMC,cACbA,EAAgB,UAASC,UACzBA,EAAY,CAAE,EAAAC,SACdA,EAAW,CAAE,EAAAC,iBACbA,EAAmB,CAAE,EAAAC,OACrBA,EAAMC,UACNA,EAASC,MACTA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,MACTA,EAAKC,OACLA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,QACPA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,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,MAIzB,GAHAd,GAAIG,QAAQ2E,SAGRR,IADgBtE,GAAIG,QAAQW,MACN,CACxB,MAAM0D,EAAQ,IAAIC,MAAM,QAAS,CAAEC,SAAS,IAC5C1E,GAAIG,QAAQwE,cAAcH,EAC5B,CACF,CACD,CAAC,MAAOI,GACPC,QAAQ1H,MAAMyH,EAChB,aAIJpG,GAEN,IAGN,CACEhE,MAAOuK,MACPC,YApbiB,UAubrB,CACEC,MAAOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.Phone.js","sources":["../../../../src/components/Input.Phone/Input.Phone.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport type { InputMaskState } from 'shared/interfaces'\nimport { Input } from '../Input/Input'\nimport type { InputProps } from '../Input'\nimport {\n COUNTRY_DATA,\n DEFAULT_MASK,\n INITIAL_MASK,\n REGEXPS,\n RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH,\n} from './constants'\n\nconst onlyNumbers = (value = ''): string => value.replace(REGEXPS.NOT_NUMBERS, '')\n\nexport interface InputPhoneProps extends InputProps {\n /**\n * Settings for different country codes\n */\n countryData?: string[][]\n /**\n * Default field mask that is set when none of the countryData prop matches\n */\n defaultMask?: string\n /**\n * The default field mask when the phone field is empty is required to enable autocomplete in\n * the browser\n */\n initialMask?: string\n /** If event should return stripped phone value (not for redux forms) */\n stripValue?: boolean\n}\n\ninterface InputPhoneState {\n mask: string\n regexp?: RegExp | null\n}\n\
|
|
1
|
+
{"version":3,"file":"Input.Phone.js","sources":["../../../../src/components/Input.Phone/Input.Phone.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport type { InputMaskState } from 'shared/interfaces'\nimport { Input } from '../Input/Input'\nimport type { InputProps } from '../Input'\nimport {\n COUNTRY_DATA,\n DEFAULT_MASK,\n INITIAL_MASK,\n REGEXPS,\n RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH,\n} from './constants'\n\nconst onlyNumbers = (value = ''): string => value.replace(REGEXPS.NOT_NUMBERS, '')\n\nexport interface InputPhoneProps extends InputProps {\n /**\n * Settings for different country codes\n */\n countryData?: string[][]\n /**\n * Default field mask that is set when none of the countryData prop matches\n */\n defaultMask?: string\n /**\n * The default field mask when the phone field is empty is required to enable autocomplete in\n * the browser\n */\n initialMask?: string\n /** If event should return stripped phone value (not for redux forms) */\n stripValue?: boolean\n}\n\ninterface InputPhoneState {\n mask: string\n regexp?: RegExp | null\n}\n\nexport class InputPhone extends PureComponent<typeof InputPhone.defaultProps & InputPhoneProps, InputPhoneState> {\n static displayName = 'Input.Phone'\n static defaultProps = {\n countryData: COUNTRY_DATA,\n defaultMask: DEFAULT_MASK,\n initialMask: INITIAL_MASK,\n placeholder: '+9 (999) 999-99-99',\n rounded: true,\n type: 'text',\n color: 'mineShaft',\n mask: '',\n placeholderColor: 'silver',\n }\n\n autocorrectOf8: boolean\n autocorrectOf9: boolean\n\n constructor(props: typeof InputPhone.defaultProps & InputPhoneProps) {\n super(props)\n\n this.autocorrectOf8 = true\n this.autocorrectOf9 = true\n\n const { mask } = this.getUpdates(props.value || '')\n\n this.state = { mask, regexp: null }\n }\n\n componentDidUpdate(nextProps: InputPhoneProps) {\n const { value } = this.props\n\n if (value !== nextProps.value) {\n this.change(value)\n }\n }\n\n getUpdates = (\n value: InputPhoneProps['value'],\n prevValue: InputPhoneProps['value'] = undefined\n ): {\n mask: string\n numbers: string\n startsFrom8: boolean\n startsFrom9: boolean\n regexp: RegExp | null\n } => {\n const { countryData, defaultMask, initialMask } = this.props\n const numbers = onlyNumbers(value as string)\n\n let mask = initialMask\n let regexp = null\n let startsFrom8 = false\n let startsFrom9 = false\n\n if (!numbers)\n return {\n mask,\n numbers,\n startsFrom8,\n startsFrom9,\n regexp,\n }\n\n let isRussian = false\n\n for (let i = 0; i < countryData.length; i++) {\n if (numbers.startsWith(countryData[i][1])) {\n ;[, , mask, regexp] = countryData[i]\n isRussian = i === 0 || i === 1\n }\n }\n\n startsFrom8 = isRussian && REGEXPS.FROM_8.test(numbers) && this.autocorrectOf8\n startsFrom9 =\n (!mask || (numbers.length === RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH && prevValue === '')) &&\n this.autocorrectOf9 &&\n REGEXPS.FROM_9.test(numbers)\n\n if (startsFrom8) {\n // RUSSIAN_MASK\n mask = COUNTRY_DATA[0][2]\n\n this.autocorrectOf8 = false\n }\n\n if (startsFrom9) {\n // RUSSIAN_MASK\n mask = COUNTRY_DATA[0][2]\n\n this.autocorrectOf9 = false\n }\n\n if (!mask) {\n mask = defaultMask\n }\n\n return {\n mask,\n numbers,\n startsFrom8,\n startsFrom9,\n regexp,\n }\n }\n\n change = (phone: InputPhoneProps['value']) => {\n const { mask } = this.getUpdates(phone)\n\n this.setState({ mask })\n }\n\n handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n e.persist()\n\n const { onChange, stripValue } = this.props\n\n if (onChange) {\n const _e = e\n if (stripValue) _e.target.value = onlyNumbers(e.target.value)\n onChange(_e)\n }\n }\n\n beforeMaskedValueChange = (newState: InputMaskState, oldState: InputMaskState) => {\n const { mask, numbers, startsFrom8, startsFrom9, regexp } = this.getUpdates(newState.value, oldState.value)\n\n this.setState({ mask, regexp })\n\n /**\n * For the correct caret position, when the user enters 9 in the phone field and it's replaced\n * by '+7 (9'\n */\n if (startsFrom9) {\n return {\n selection: numbers.length === 1 ? { start: 5, end: 5 } : newState.selection,\n value: newState.value.replace(REGEXPS.FROM_9, '+79$1'),\n }\n }\n\n if (startsFrom8) {\n return { selection: { start: 2, end: 2 }, value: newState.value.replace(REGEXPS.FROM_8, '+7$1') }\n }\n\n if (REGEXPS.FILLED.test(oldState.value) && numbers.length === 1) {\n return { selection: { start: 2, end: 2 }, value: newState.value }\n }\n\n if (!REGEXPS.FILLED.test(oldState.value) && REGEXPS.FILLED.test(newState.value)) {\n return {\n ...newState,\n selection: newState.selection ? { start: newState.selection.start + 1, end: newState.selection.end + 1 } : null,\n }\n }\n\n return newState\n }\n\n render() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { countryData, defaultMask, initialMask, stripValue, ...props } = this.props\n const { mask, regexp } = this.state\n\n return (\n <Input\n {...props}\n beforeMaskedValueChange={this.beforeMaskedValueChange}\n mask={mask}\n data-regexp={regexp instanceof RegExp ? regexp.toString() : undefined}\n onChange={this.handleChange}\n />\n )\n }\n}\n"],"names":["onlyNumbers","value","replace","REGEXPS","NOT_NUMBERS","InputPhone","PureComponent","static","countryData","COUNTRY_DATA","defaultMask","DEFAULT_MASK","initialMask","INITIAL_MASK","placeholder","rounded","type","color","mask","placeholderColor","constructor","props","super","this","autocorrectOf8","autocorrectOf9","getUpdates","state","regexp","componentDidUpdate","nextProps","change","prevValue","numbers","startsFrom8","startsFrom9","isRussian","i","length","startsWith","FROM_8","test","RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH","FROM_9","phone","setState","handleChange","e","persist","onChange","stripValue","_e","target","beforeMaskedValueChange","newState","oldState","selection","start","end","FILLED","render","_jsx","Input","RegExp","toString","undefined"],"mappings":"mKAYA,MAAMA,YAAcA,CAACC,EAAQ,KAAeA,EAAMC,QAAQC,UAAOA,QAACC,YAAa,uBAyBxE,MAAMC,mBAAmBC,MAAAA,cAC9BC,mBAAqB,cACrBA,oBAAsB,CACpBC,YAAaC,UAAYA,aACzBC,YAAaC,UAAYA,aACzBC,YAAaC,UAAYA,aACzBC,YAAa,qBACbC,SAAS,EACTC,KAAM,OACNC,MAAO,YACPC,KAAM,GACNC,iBAAkB,UAMpBC,WAAAA,CAAYC,GACVC,MAAMD,GAENE,KAAKC,gBAAiB,EACtBD,KAAKE,gBAAiB,EAEtB,MAAMP,KAAEA,GAASK,KAAKG,WAAWL,EAAMpB,OAAS,IAEhDsB,KAAKI,MAAQ,CAAET,OAAMU,OAAQ,KAC/B,CAEAC,kBAAAA,CAAmBC,GACjB,MAAM7B,MAAEA,GAAUsB,KAAKF,MAEnBpB,IAAU6B,EAAU7B,OACtBsB,K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C,YAAEA,EAAWC,YAAEA,EAAWP,OAAEA,GAAWL,KAAKG,WAAW4B,EAASrD,MAAOsD,EAAStD,OAQrG,OANAsB,KAAKsB,SAAS,CAAE3B,OAAMU,WAMlBO,EACK,CACLqB,UAAWvB,EAAQK,SAAW,EAAI,CAAEmB,MAAO,EAAGC,IAAK,GAAMJ,EAASE,UAClEvD,MAAOqD,EAASrD,MAAMC,QAAQC,UAAOA,QAACwC,OAAQ,UAI9CT,EACK,CAAEsB,UAAW,CAAEC,MAAO,EAAGC,IAAK,GAAKzD,MAAOqD,EAASrD,MAAMC,QAAQC,UAAOA,QAACqC,OAAQ,SAGtFrC,UAAOA,QAACwD,OAAOlB,KAAKc,EAAStD,QAAUgC,EAAQK,SAAW,EACrD,CAAEkB,UAAW,CAAEC,MAAO,EAAGC,IAAK,GAAKzD,MAAOqD,EAASrD,QAGvDE,UAAOA,QAACwD,OAAOlB,KAAKc,EAAStD,QAAUE,UAAAA,QAAQwD,OAAOlB,KAAKa,EAASrD,OAChE,IACFqD,EACHE,UAAWF,EAASE,UAAY,CAAEC,MAAOH,EAASE,UAAUC,MAAQ,EAAGC,IAAKJ,EAASE,UAAUE,IAAM,GAAM,MAIxGJ,CAAQ,EAGjBM,MAAAA,GAEE,MAAMpD,YAAEA,EAAWE,YAAEA,EAAWE,YAAEA,EAAWsC,WAAEA,KAAe7B,GAAUE,KAAKF,MAC7E,MAAMH,KAAEA,EAAIU,OAAEA,GAAWL,KAAKI,MAE9B,OACEkC,WAAAA,IAACC,MAAAA,MAAK,IACAzC,EACJgC,wBAAyB9B,KAAK8B,wBAC9BnC,KAAMA,EACN,cAAaU,aAAkBmC,OAASnC,EAAOoC,gBAAaC,EAC5DhB,SAAU1B,KAAKuB,cAGrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.Phone.mjs","sources":["../../../../src/components/Input.Phone/Input.Phone.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport type { InputMaskState } from 'shared/interfaces'\nimport { Input } from '../Input/Input'\nimport type { InputProps } from '../Input'\nimport {\n COUNTRY_DATA,\n DEFAULT_MASK,\n INITIAL_MASK,\n REGEXPS,\n RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH,\n} from './constants'\n\nconst onlyNumbers = (value = ''): string => value.replace(REGEXPS.NOT_NUMBERS, '')\n\nexport interface InputPhoneProps extends InputProps {\n /**\n * Settings for different country codes\n */\n countryData?: string[][]\n /**\n * Default field mask that is set when none of the countryData prop matches\n */\n defaultMask?: string\n /**\n * The default field mask when the phone field is empty is required to enable autocomplete in\n * the browser\n */\n initialMask?: string\n /** If event should return stripped phone value (not for redux forms) */\n stripValue?: boolean\n}\n\ninterface InputPhoneState {\n mask: string\n regexp?: RegExp | null\n}\n\
|
|
1
|
+
{"version":3,"file":"Input.Phone.mjs","sources":["../../../../src/components/Input.Phone/Input.Phone.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport type { InputMaskState } from 'shared/interfaces'\nimport { Input } from '../Input/Input'\nimport type { InputProps } from '../Input'\nimport {\n COUNTRY_DATA,\n DEFAULT_MASK,\n INITIAL_MASK,\n REGEXPS,\n RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH,\n} from './constants'\n\nconst onlyNumbers = (value = ''): string => value.replace(REGEXPS.NOT_NUMBERS, '')\n\nexport interface InputPhoneProps extends InputProps {\n /**\n * Settings for different country codes\n */\n countryData?: string[][]\n /**\n * Default field mask that is set when none of the countryData prop matches\n */\n defaultMask?: string\n /**\n * The default field mask when the phone field is empty is required to enable autocomplete in\n * the browser\n */\n initialMask?: string\n /** If event should return stripped phone value (not for redux forms) */\n stripValue?: boolean\n}\n\ninterface InputPhoneState {\n mask: string\n regexp?: RegExp | null\n}\n\nexport class InputPhone extends PureComponent<typeof InputPhone.defaultProps & InputPhoneProps, InputPhoneState> {\n static displayName = 'Input.Phone'\n static defaultProps = {\n countryData: COUNTRY_DATA,\n defaultMask: DEFAULT_MASK,\n initialMask: INITIAL_MASK,\n placeholder: '+9 (999) 999-99-99',\n rounded: true,\n type: 'text',\n color: 'mineShaft',\n mask: '',\n placeholderColor: 'silver',\n }\n\n autocorrectOf8: boolean\n autocorrectOf9: boolean\n\n constructor(props: typeof InputPhone.defaultProps & InputPhoneProps) {\n super(props)\n\n this.autocorrectOf8 = true\n this.autocorrectOf9 = true\n\n const { mask } = this.getUpdates(props.value || '')\n\n this.state = { mask, regexp: null }\n }\n\n componentDidUpdate(nextProps: InputPhoneProps) {\n const { value } = this.props\n\n if (value !== nextProps.value) {\n this.change(value)\n }\n }\n\n getUpdates = (\n value: InputPhoneProps['value'],\n prevValue: InputPhoneProps['value'] = undefined\n ): {\n mask: string\n numbers: string\n startsFrom8: boolean\n startsFrom9: boolean\n regexp: RegExp | null\n } => {\n const { countryData, defaultMask, initialMask } = this.props\n const numbers = onlyNumbers(value as string)\n\n let mask = initialMask\n let regexp = null\n let startsFrom8 = false\n let startsFrom9 = false\n\n if (!numbers)\n return {\n mask,\n numbers,\n startsFrom8,\n startsFrom9,\n regexp,\n }\n\n let isRussian = false\n\n for (let i = 0; i < countryData.length; i++) {\n if (numbers.startsWith(countryData[i][1])) {\n ;[, , mask, regexp] = countryData[i]\n isRussian = i === 0 || i === 1\n }\n }\n\n startsFrom8 = isRussian && REGEXPS.FROM_8.test(numbers) && this.autocorrectOf8\n startsFrom9 =\n (!mask || (numbers.length === RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH && prevValue === '')) &&\n this.autocorrectOf9 &&\n REGEXPS.FROM_9.test(numbers)\n\n if (startsFrom8) {\n // RUSSIAN_MASK\n mask = COUNTRY_DATA[0][2]\n\n this.autocorrectOf8 = false\n }\n\n if (startsFrom9) {\n // RUSSIAN_MASK\n mask = COUNTRY_DATA[0][2]\n\n this.autocorrectOf9 = false\n }\n\n if (!mask) {\n mask = defaultMask\n }\n\n return {\n mask,\n numbers,\n startsFrom8,\n startsFrom9,\n regexp,\n }\n }\n\n change = (phone: InputPhoneProps['value']) => {\n const { mask } = this.getUpdates(phone)\n\n this.setState({ mask })\n }\n\n handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n e.persist()\n\n const { onChange, stripValue } = this.props\n\n if (onChange) {\n const _e = e\n if (stripValue) _e.target.value = onlyNumbers(e.target.value)\n onChange(_e)\n }\n }\n\n beforeMaskedValueChange = (newState: InputMaskState, oldState: InputMaskState) => {\n const { mask, numbers, startsFrom8, startsFrom9, regexp } = this.getUpdates(newState.value, oldState.value)\n\n this.setState({ mask, regexp })\n\n /**\n * For the correct caret position, when the user enters 9 in the phone field and it's replaced\n * by '+7 (9'\n */\n if (startsFrom9) {\n return {\n selection: numbers.length === 1 ? { start: 5, end: 5 } : newState.selection,\n value: newState.value.replace(REGEXPS.FROM_9, '+79$1'),\n }\n }\n\n if (startsFrom8) {\n return { selection: { start: 2, end: 2 }, value: newState.value.replace(REGEXPS.FROM_8, '+7$1') }\n }\n\n if (REGEXPS.FILLED.test(oldState.value) && numbers.length === 1) {\n return { selection: { start: 2, end: 2 }, value: newState.value }\n }\n\n if (!REGEXPS.FILLED.test(oldState.value) && REGEXPS.FILLED.test(newState.value)) {\n return {\n ...newState,\n selection: newState.selection ? { start: newState.selection.start + 1, end: newState.selection.end + 1 } : null,\n }\n }\n\n return newState\n }\n\n render() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { countryData, defaultMask, initialMask, stripValue, ...props } = this.props\n const { mask, regexp } = this.state\n\n return (\n <Input\n {...props}\n beforeMaskedValueChange={this.beforeMaskedValueChange}\n mask={mask}\n data-regexp={regexp instanceof RegExp ? regexp.toString() : undefined}\n onChange={this.handleChange}\n />\n )\n }\n}\n"],"names":["onlyNumbers","value","replace","REGEXPS","NOT_NUMBERS","InputPhone","PureComponent","static","countryData","COUNTRY_DATA","defaultMask","DEFAULT_MASK","initialMask","INITIAL_MASK","placeholder","rounded","type","color","mask","placeholderColor","constructor","props","super","this","autocorrectOf8","autocorrectOf9","getUpdates","state","regexp","componentDidUpdate","nextProps","change","prevValue","numbers","startsFrom8","startsFrom9","isRussian","i","length","startsWith","FROM_8","test","RUSSIAN_PHONE_WITHOUT_COUNTY_CODE_LENGTH","FROM_9","phone","setState","handleChange","e","persist","onChange","stripValue","_e","target","beforeMaskedValueChange","newState","oldState","selection","start","end","FILLED","render","_jsx","Input","RegExp","toString","undefined"],"mappings":"+NAYA,MAAMA,YAAcA,CAACC,EAAQ,KAAeA,EAAMC,QAAQC,QAAQC,YAAa,IAyBxE,MAAMC,mBAAmBC,cAC9BC,mBAAqB,cACrBA,oBAAsB,CACpBC,YAAaC,aACbC,YAAaC,aACbC,YAAaC,aACbC,YAAa,qBACbC,SAAS,EACTC,KAAM,OACNC,MAAO,YACPC,KAAM,GACNC,iBAAkB,UAMpBC,WAAAA,CAAYC,GACVC,MAAMD,GAENE,KAAKC,gBAAiB,EACtBD,KAAKE,gBAAiB,EAEtB,MAAMP,KAAEA,GAASK,KAAKG,WAAWL,EAAMpB,OAAS,IAEhDsB,KAAKI,MAAQ,CAAET,OAAMU,OAAQ,KAC/B,CAEAC,kBAAAA,CAAmBC,GACjB,MAAM7B,MAAEA,GAAUsB,KAAKF,MAEnBpB,IAAU6B,EAAU7B,OACtBsB,KAAKQ,OAAO9B,EAEhB,CAEAyB,WAAaA,CACXzB,EACA+B,KAQA,MAAMxB,YAAEA,EAAWE,YAAEA,EAAWE,YAAEA,GAAgBW,KAAKF,MACvD,MAAMY,EAAUjC,YAAYC,GAE5B,IAAIiB,EAAON,EACX,IAAIgB,EAAS,KACb,IAAIM,GAAc,EAClB,IAAIC,GAAc,EAElB,IAAKF,EACH,MAAO,CACLf,OACAe,UACAC,cACAC,cACAP,UAGJ,IAAIQ,GAAY,EAEhB,IAAK,IAAIC,EAAI,EAAGA,EAAI7B,EAAY8B,OAAQD,IAClCJ,EAAQM,WAAW/B,EAAY6B,GAAG,OACnC,CAAA,CAAKnB,EAAMU,GAAUpB,EAAY6B,GAClCD,EAAYC,IAAM,GAAK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OqD,EAASrD,QAGvDE,QAAQwD,OAAOlB,KAAKc,EAAStD,QAAUE,QAAQwD,OAAOlB,KAAKa,EAASrD,OAChE,IACFqD,EACHE,UAAWF,EAASE,UAAY,CAAEC,MAAOH,EAASE,UAAUC,MAAQ,EAAGC,IAAKJ,EAASE,UAAUE,IAAM,GAAM,MAIxGJ,CAAQ,EAGjBM,MAAAA,GAEE,MAAMpD,YAAEA,EAAWE,YAAEA,EAAWE,YAAEA,EAAWsC,WAAEA,KAAe7B,GAAUE,KAAKF,MAC7E,MAAMH,KAAEA,EAAIU,OAAEA,GAAWL,KAAKI,MAE9B,OACEkC,IAACC,MAAK,IACAzC,EACJgC,wBAAyB9B,KAAK8B,wBAC9BnC,KAAMA,EACN,cAAaU,aAAkBmC,OAASnC,EAAOoC,gBAAaC,EAC5DhB,SAAU1B,KAAKuB,cAGrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputCheckbox.js","sources":["../../../../src/components/InputCheckbox/InputCheckbox.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputCheckboxProps } from './types'\n\nconst COMPONENT_NAME = 'InputCheckbox'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/InputCheckbox/types.ts).\n *\n * @visibleName Checkbox\n */\nconst InputCheckbox: React.ForwardRefExoticComponent<InputCheckboxProps> = withMergedProps<\n InputCheckboxProps,\n HTMLInputElement\n>(\n forwardRef<HTMLInputElement, MergedProps<InputCheckboxProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n indeterminate,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n indeterminate={indeterminate}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='checkbox' ref={ref} />\n <Styled.InputMask>\n {indeterminate === true ? <Styled.InputIndeterminate /> : <Styled.InputChecked />}\n </Styled.InputMask>\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputCheckbox, COMPONENT_NAME }\n"],"names":["InputCheckbox","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","indeterminate","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","jsx","type","InputChecked","displayName","SIZES"],"mappings":"yNAqBA,MAAMA,cAAqEC,gBAAAA,gBAIzEC,MAAAA,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,gBACAC,EACAC,gBACAC,YACAC,cACGC,GAELC,IAGEC,WAAAA,KAACC,MAAAA,KAAW,CACVvB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,cAAeA,EACfC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,WAAAC,IAACH,YAAY,IAAKH,EAAYD,SAAUA,EAAUQ,KAAK,WAAWN,IAAKA,IACvEI,WAAAC,IAACH,gBAAgB,CAAAC,SACWC,eAAzBR,KAAkB,EAAQM,MAAAA,mBAAgCA,MAAmBK,aAA1B,CAAA,UAM9D,CACEC,YA7EmB,gBA8EnBtB,MAAOuB,UAAAA,+BA9EY"}
|
|
1
|
+
{"version":3,"file":"InputCheckbox.js","sources":["../../../../src/components/InputCheckbox/InputCheckbox.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputCheckboxProps } from './types'\n\nconst COMPONENT_NAME = 'InputCheckbox'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/InputCheckbox/types.ts).\n *\n * @visibleName Checkbox\n */\nconst InputCheckbox: React.ForwardRefExoticComponent<InputCheckboxProps> = withMergedProps<\n InputCheckboxProps,\n HTMLInputElement\n>(\n forwardRef<HTMLInputElement, MergedProps<InputCheckboxProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n indeterminate,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n indeterminate={indeterminate}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='checkbox' ref={ref} />\n <Styled.InputMask>\n {indeterminate === true ? <Styled.InputIndeterminate /> : <Styled.InputChecked />}\n </Styled.InputMask>\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputCheckbox, COMPONENT_NAME }\n"],"names":["InputCheckbox","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","indeterminate","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","jsx","type","InputChecked","displayName","SIZES"],"mappings":"yNAqBA,MAAMA,cAAqEC,gBAAAA,gBAIzEC,MAAAA,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,gBACAC,EACAC,gBACAC,YACAC,cACGC,GAELC,IAGEC,WAAAA,KAACC,MAAAA,KAAW,CACVvB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,cAAeA,EACfC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,WAAAC,IAACH,YAAY,IAAKH,EAAYD,SAAUA,EAAUQ,KAAK,WAAWN,IAAKA,IACvEI,WAAAC,IAACH,gBAAgB,CAAAC,SACWC,eAAzBR,KAAkB,EAAQM,MAAAA,mBAAgCA,MAAmBK,aAA1B,CAAA,UAM9D,CACEC,YA7EmB,gBA8EnBtB,MAAOuB,UAAAA,+BA9EY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputCheckbox.mjs","sources":["../../../../src/components/InputCheckbox/InputCheckbox.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputCheckboxProps } from './types'\n\nconst COMPONENT_NAME = 'InputCheckbox'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/InputCheckbox/types.ts).\n *\n * @visibleName Checkbox\n */\nconst InputCheckbox: React.ForwardRefExoticComponent<InputCheckboxProps> = withMergedProps<\n InputCheckboxProps,\n HTMLInputElement\n>(\n forwardRef<HTMLInputElement, MergedProps<InputCheckboxProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n indeterminate,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n indeterminate={indeterminate}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='checkbox' ref={ref} />\n <Styled.InputMask>\n {indeterminate === true ? <Styled.InputIndeterminate /> : <Styled.InputChecked />}\n </Styled.InputMask>\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputCheckbox, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","InputCheckbox","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","indeterminate","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","type","displayName","SIZES"],"mappings":"mPAOMA,MAAAA,eAAiB,gBAcvB,MAAMC,cAAqEC,gBAIzEC,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,UACAC,QACAC,gBACAC,YACAC,cACGC,GAELC,IAGEC,KAACC,KAAW,CACVvB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,cAAeA,EACfC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,IAACF,MAAY,IAAKH,EAAYD,SAAUA,EAAUO,KAAK,WAAWL,IAAKA,IACvEI,IAACF,UAAgB,CAAAC,SACWC,IAAzBR,KAAkB,EAAQM,mBAAgCA,aAAP,CAAA,UAM9D,CACEI,YA7EmB,gBA8EnBpB,MAAOqB"}
|
|
1
|
+
{"version":3,"file":"InputCheckbox.mjs","sources":["../../../../src/components/InputCheckbox/InputCheckbox.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputCheckboxProps } from './types'\n\nconst COMPONENT_NAME = 'InputCheckbox'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/InputCheckbox/types.ts).\n *\n * @visibleName Checkbox\n */\nconst InputCheckbox: React.ForwardRefExoticComponent<InputCheckboxProps> = withMergedProps<\n InputCheckboxProps,\n HTMLInputElement\n>(\n forwardRef<HTMLInputElement, MergedProps<InputCheckboxProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n indeterminate,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n indeterminate={indeterminate}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='checkbox' ref={ref} />\n <Styled.InputMask>\n {indeterminate === true ? <Styled.InputIndeterminate /> : <Styled.InputChecked />}\n </Styled.InputMask>\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputCheckbox, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","InputCheckbox","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","indeterminate","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","type","displayName","SIZES"],"mappings":"mPAOMA,MAAAA,eAAiB,gBAcvB,MAAMC,cAAqEC,gBAIzEC,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,UACAC,QACAC,gBACAC,YACAC,cACGC,GAELC,IAGEC,KAACC,KAAW,CACVvB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,cAAeA,EACfC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,IAACF,MAAY,IAAKH,EAAYD,SAAUA,EAAUO,KAAK,WAAWL,IAAKA,IACvEI,IAACF,UAAgB,CAAAC,SACWC,IAAzBR,KAAkB,EAAQM,mBAAgCA,aAAP,CAAA,UAM9D,CACEI,YA7EmB,gBA8EnBpB,MAAOqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputRadio.js","sources":["../../../../src/components/InputRadio/InputRadio.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputRadioProps } from './types'\n\nconst COMPONENT_NAME = 'InputRadio'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/InputRadio/types.ts).\n *\n * @visibleName Radio\n */\nconst InputRadio: React.ForwardRefExoticComponent<InputRadioProps> = withMergedProps<InputRadioProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputRadioProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='radio' ref={ref} />\n <Styled.InputMask />\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputRadio, COMPONENT_NAME }\n"],"names":["InputRadio","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","jsx","type","displayName","SIZES"],"mappings":"yNAqBA,MAAMA,WAA+DC,gBAAAA,gBACnEC,MAAAA,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,gBACAC,EACAC,YACAC,cACGC,GAELC,IAGEC,WAAAA,KAACC,MAAAA,KAAW,CACVtB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,WAAAC,IAACH,YAAY,IAAKH,EAAYD,SAAUA,EAAUQ,KAAK,QAAQN,IAAKA,IACpEI,WAAAC,IAACH,yBAKT,CACEK,YAtEmB,aAuEnBpB,MAAOqB,UAAAA,+BAvEY"}
|
|
1
|
+
{"version":3,"file":"InputRadio.js","sources":["../../../../src/components/InputRadio/InputRadio.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputRadioProps } from './types'\n\nconst COMPONENT_NAME = 'InputRadio'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/InputRadio/types.ts).\n *\n * @visibleName Radio\n */\nconst InputRadio: React.ForwardRefExoticComponent<InputRadioProps> = withMergedProps<InputRadioProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputRadioProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='radio' ref={ref} />\n <Styled.InputMask />\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputRadio, COMPONENT_NAME }\n"],"names":["InputRadio","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","jsx","type","displayName","SIZES"],"mappings":"yNAqBA,MAAMA,WAA+DC,gBAAAA,gBACnEC,MAAAA,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,gBACAC,EACAC,YACAC,cACGC,GAELC,IAGEC,WAAAA,KAACC,MAAAA,KAAW,CACVtB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,WAAAC,IAACH,YAAY,IAAKH,EAAYD,SAAUA,EAAUQ,KAAK,QAAQN,IAAKA,IACpEI,WAAAC,IAACH,yBAKT,CACEK,YAtEmB,aAuEnBpB,MAAOqB,UAAAA,+BAvEY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputRadio.mjs","sources":["../../../../src/components/InputRadio/InputRadio.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputRadioProps } from './types'\n\nconst COMPONENT_NAME = 'InputRadio'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/InputRadio/types.ts).\n *\n * @visibleName Radio\n */\nconst InputRadio: React.ForwardRefExoticComponent<InputRadioProps> = withMergedProps<InputRadioProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputRadioProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='radio' ref={ref} />\n <Styled.InputMask />\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputRadio, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","InputRadio","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","type","displayName","SIZES"],"mappings":"mNAOMA,MAAAA,eAAiB,aAcvB,MAAMC,WAA+DC,gBACnEC,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,UACAC,QACAC,YACAC,cACGC,GAELC,IAGEC,KAACC,KAAW,CACVtB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,IAACF,MAAY,IAAKH,EAAYD,SAAUA,EAAUO,KAAK,QAAQL,IAAKA,IACpEI,IAACF,mBAKT,CACEI,YAtEmB,aAuEnBnB,MAAOoB"}
|
|
1
|
+
{"version":3,"file":"InputRadio.mjs","sources":["../../../../src/components/InputRadio/InputRadio.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { InputRadioProps } from './types'\n\nconst COMPONENT_NAME = 'InputRadio'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<input\\> элемента.\n *\n * Переданный \"ref\" будет ассоциирован с \\<input\\>.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/InputRadio/types.ts).\n *\n * @visibleName Radio\n */\nconst InputRadio: React.ForwardRefExoticComponent<InputRadioProps> = withMergedProps<InputRadioProps, HTMLInputElement>(\n forwardRef<HTMLInputElement, MergedProps<InputRadioProps>>(\n (\n {\n size = 'm',\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n preset,\n inline,\n error,\n success,\n contrast,\n onColored,\n palette,\n style,\n className,\n disabled,\n ...inputProps\n },\n ref\n ) => {\n return (\n <Styled.Root\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n preset={preset}\n inline={inline}\n error={error}\n success={success}\n contrast={contrast}\n onColored={onColored}\n palette={palette}\n style={style}\n className={className}\n disabled={disabled}\n >\n <Styled.Input {...inputProps} disabled={disabled} type='radio' ref={ref} />\n <Styled.InputMask />\n </Styled.Root>\n )\n }\n ),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { InputRadio, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","InputRadio","withMergedProps","forwardRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","preset","inline","error","success","contrast","onColored","palette","style","className","disabled","inputProps","ref","_jsxs","Styled","children","_jsx","type","displayName","SIZES"],"mappings":"mNAOMA,MAAAA,eAAiB,aAcvB,MAAMC,WAA+DC,gBACnEC,YACE,EAEIC,OAAO,IACPC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,YACAC,SACAC,SACAC,QACAC,UACAC,WACAC,YACAC,UACAC,QACAC,YACAC,cACGC,GAELC,IAGEC,KAACC,KAAW,CACVtB,KAAMA,EACNC,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,MAAOA,EACPC,UAAWA,EACXC,OAAQA,EACRC,OAAQA,EACRC,MAAOA,EACPC,QAASA,EACTC,SAAUA,EACVC,UAAWA,EACXC,QAASA,EACTC,MAAOA,EACPC,UAAWA,EACXC,SAAUA,EAASK,SAEnBC,CAAAA,IAACF,MAAY,IAAKH,EAAYD,SAAUA,EAAUO,KAAK,QAAQL,IAAKA,IACpEI,IAACF,mBAKT,CACEI,YAtEmB,aAuEnBnB,MAAOoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","sources":["../../../../src/components/ListItem/ListItem.tsx"],"sourcesContent":["import { forwardRef, cloneElement, isValidElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Skeleton } from 'components/Skeleton'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { ListItemProps } from './types'\n\nconst COMPONENT_NAME = 'ListItem'\n\n/**\n *\n * Component accepts all root HTML attributes.\n *\n * Responsive \"size\", \"margin\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [ListItemProps](https://github.com/foxford/ui/blob/master/src/components/ListItem/types.ts)\n */\nconst ListItem: React.ForwardRefExoticComponent<ListItemProps> = withMergedProps<ListItemProps>(\n forwardRef<HTMLElement, MergedProps<ListItemProps>>((props, ref) => {\n const {\n size = 's',\n borderRadius = 0,\n mediaBorderRadius = '50%',\n controlPosition = 'left',\n captionPosition = 'bottom',\n ellipsis = true,\n iconProps = {},\n textProps = {},\n captionProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n text,\n children,\n control,\n icon,\n media,\n caption,\n addon,\n onColored,\n disabled,\n loading,\n ...restProps\n } = props\n\n let rootNode: ListItemProps['as']\n\n if (control) rootNode = 'label'\n if (restProps.href) rootNode = 'a'\n if (restProps.as) rootNode = restProps.as\n\n let rootType: ListItemProps['type']\n\n if (!rootNode) rootType = 'button'\n if (restProps.type) rootType = restProps.type\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const stateProps = {\n onColored,\n disabled,\n }\n\n const controlProps =\n typeof control === 'object' && typeof control.props === 'object' && control.props !== null ? control.props : {}\n\n const [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const textBaseProps: TextProps = { appearance: 'body', size: 'inherit', color: 'inherit', ellipsis }\n\n const captionBaseProps: TextProps = { appearance: 'body', size: 0.9, sizeUnits: 'em', color: 'inherit', ellipsis }\n\n return (\n <Styled.Root\n {...sizeProps}\n {...stateProps}\n {...restProps}\n as={rootNode}\n type={rootType}\n borderRadius={borderRadius}\n mediaBorderRadius={mediaBorderRadius}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({\n textProps: textBaseProps,\n captionProps: captionBaseProps,\n })\n ) : loading ? (\n <>\n {media ? (\n <Styled.Media>\n <Skeleton width='100%' height='100%' borderRadius='inherit' />\n </Styled.Media>\n ) : null}\n <Styled.Content>\n <Skeleton width='100%' borderRadius={4}>\n <Text {...textBaseProps} {...textProps} />\n </Skeleton>\n </Styled.Content>\n </>\n ) : (\n <>\n {control && controlPosition === 'left'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n {before ? (\n <Icon\n preset='brand'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n />\n ) : null}\n {media ? (\n <Styled.Media>{isValidElement(media) ? media : <Styled.Img alt='' {...media} />}</Styled.Media>\n ) : null}\n {children || text || caption ? (\n <Styled.Content>\n {caption && captionPosition === 'top' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n {children || text ? (\n <Text as='span' {...textBaseProps} {...textProps}>\n {children ?? text}\n </Text>\n ) : null}\n {caption && captionPosition === 'bottom' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n </Styled.Content>\n ) : null}\n {addon}\n {after ? (\n <Icon\n preset='brand'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n />\n ) : null}\n {control && controlPosition === 'right'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { ListItem }\n"],"names":["ListItem","withMergedProps","forwardRef","props","ref","size","borderRadius","mediaBorderRadius","controlPosition","captionPosition","ellipsis","iconProps","textProps","captionProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","text","children","control","icon","media","caption","addon","onColored","disabled","loading","restProps","rootNode","rootType","href","as","type","sizeProps","stateProps","controlProps","before","after","Array","isArray","textBaseProps","appearance","color","captionBaseProps","sizeUnits","_jsx","Styled","_jsxs","jsxs","_Fragment","jsx","Skeleton","width","height","Text","cloneElement","Icon","preset","name","undefined","isValidElement","alt","displayName","sizes","SIZES"],"mappings":"iVAuBMA,MAAAA,SAA2DC,gBAAAA,gBAC/DC,MAAAA,YAAoD,CAACC,EAAOC,KAC1D,MAAMC,KACJA,EAAO,IAAGC,aACVA,EAAe,EAACC,kBAChBA,EAAoB,MAAKC,gBACzBA,EAAkB,OAAMC,gBACxBA,EAAkB,SAAQC,SAC1BA,GAAW,EAAIC,UACfA,EAAY,CAAE,EAAAC,UACdA,EAAY,CAAE,EAAAC,aACdA,EAAe,CAAE,EAAAC,QACjBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,KACNA,EAAIC,SACJA,EAAQC,QACRA,EAAOC,KACPA,EAAIC,MACJA,EAAKC,QACLA,EAAOC,MACPA,EAAKC,UACLA,EAASC,SACTA,EAAQC,QACRA,KACGC,GACD3B,EAEJ,IAAI4B,EAMJ,IAAIC,EAJAV,IAASS,EAAW,SACpBD,EAAUG,OAAMF,EAAW,KAC3BD,EAAUI,KAAIH,EAAWD,EAAUI,IAIlCH,IAAUC,EAAW,UACtBF,EAAUK,OAAMH,EAAWF,EAAUK,MAEzC,MAAMC,EAA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B,SAAE0C,MAAcA,eAACvC,GAASA,EAAQwB,WAAAA,IAACC,MAAAA,IAAU,CAACe,IAAI,MAAOxC,MACpE,KACHH,GAAYD,GAAQK,EACnByB,WAAAC,KAACF,cAAc,CAAA5B,SAAA,CACZI,GAAWhB,IAAoB,MAC9BuC,WAAAA,IAACS,KAAAA,KAAI,CAACvB,GAAG,UAAWY,KAAsBjC,EAAYQ,SACnDI,IAED,KACHJ,GAAYD,EACX4B,WAAAA,IAACS,KAAAA,KAAI,CAACvB,GAAG,UAAWS,KAAmB/B,EAASS,SAC7CA,GAAYD,IAEb,KACHK,GAAWhB,IAAoB,SAC9BuC,WAAAK,IAACI,UAAI,CAACvB,GAAG,UAAWY,KAAsBjC,EAAYQ,SACnDI,IAED,QAEJ,KACHC,EACAc,EACCQ,WAAAA,IAACW,KAAAA,KAAI,CACHC,OAAO,QACPC,YAAarB,GAAU,SAAWA,OAAQsB,EAC1CvC,YAAaiB,GAAU,SAAWA,OAAQsB,KACtCnD,IAEJ,KACHW,GAAWd,IAAoB,eACrBc,GAAY,WACjBA,EAAQ,IAAKc,KAAcC,IAC3BqB,MAAYA,aAACpC,EAAS,IAAKc,KAAcC,KAAeC,IAC1D,SAGI,IAGlB,CACE2B,YApKmB,WAqKnBC,MAAOC,UAAAA"}
|
|
1
|
+
{"version":3,"file":"ListItem.js","sources":["../../../../src/components/ListItem/ListItem.tsx"],"sourcesContent":["import { forwardRef, cloneElement, isValidElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Skeleton } from 'components/Skeleton'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { ListItemProps } from './types'\n\nconst COMPONENT_NAME = 'ListItem'\n\n/**\n *\n * Component accepts all root HTML attributes.\n *\n * Responsive \"size\", \"margin\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [ListItemProps](https://github.com/foxford/ui/blob/master/packages/ui/src/components/ListItem/types.ts)\n */\nconst ListItem: React.ForwardRefExoticComponent<ListItemProps> = withMergedProps<ListItemProps>(\n forwardRef<HTMLElement, MergedProps<ListItemProps>>((props, ref) => {\n const {\n size = 's',\n borderRadius = 0,\n mediaBorderRadius = '50%',\n controlPosition = 'left',\n captionPosition = 'bottom',\n ellipsis = true,\n iconProps = {},\n textProps = {},\n captionProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n text,\n children,\n control,\n icon,\n media,\n caption,\n addon,\n onColored,\n disabled,\n loading,\n ...restProps\n } = props\n\n let rootNode: ListItemProps['as']\n\n if (control) rootNode = 'label'\n if (restProps.href) rootNode = 'a'\n if (restProps.as) rootNode = restProps.as\n\n let rootType: ListItemProps['type']\n\n if (!rootNode) rootType = 'button'\n if (restProps.type) rootType = restProps.type\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const stateProps = {\n onColored,\n disabled,\n }\n\n const controlProps =\n typeof control === 'object' && typeof control.props === 'object' && control.props !== null ? control.props : {}\n\n const [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const textBaseProps: TextProps = { appearance: 'body', size: 'inherit', color: 'inherit', ellipsis }\n\n const captionBaseProps: TextProps = { appearance: 'body', size: 0.9, sizeUnits: 'em', color: 'inherit', ellipsis }\n\n return (\n <Styled.Root\n {...sizeProps}\n {...stateProps}\n {...restProps}\n as={rootNode}\n type={rootType}\n borderRadius={borderRadius}\n mediaBorderRadius={mediaBorderRadius}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({\n textProps: textBaseProps,\n captionProps: captionBaseProps,\n })\n ) : loading ? (\n <>\n {media ? (\n <Styled.Media>\n <Skeleton width='100%' height='100%' borderRadius='inherit' />\n </Styled.Media>\n ) : null}\n <Styled.Content>\n <Skeleton width='100%' borderRadius={4}>\n <Text {...textBaseProps} {...textProps} />\n </Skeleton>\n </Styled.Content>\n </>\n ) : (\n <>\n {control && controlPosition === 'left'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n {before ? (\n <Icon\n preset='brand'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n />\n ) : null}\n {media ? (\n <Styled.Media>{isValidElement(media) ? media : <Styled.Img alt='' {...media} />}</Styled.Media>\n ) : null}\n {children || text || caption ? (\n <Styled.Content>\n {caption && captionPosition === 'top' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n {children || text ? (\n <Text as='span' {...textBaseProps} {...textProps}>\n {children ?? text}\n </Text>\n ) : null}\n {caption && captionPosition === 'bottom' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n </Styled.Content>\n ) : null}\n {addon}\n {after ? (\n <Icon\n preset='brand'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n />\n ) : null}\n {control && controlPosition === 'right'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { ListItem }\n"],"names":["ListItem","withMergedProps","forwardRef","props","ref","size","borderRadius","mediaBorderRadius","controlPosition","captionPosition","ellipsis","iconProps","textProps","captionProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","text","children","control","icon","media","caption","addon","onColored","disabled","loading","restProps","rootNode","rootType","href","as","type","sizeProps","stateProps","controlProps","before","after","Array","isArray","textBaseProps","appearance","color","captionBaseProps","sizeUnits","_jsx","Styled","_jsxs","jsxs","_Fragment","jsx","Skeleton","width","height","Text","cloneElement","Icon","preset","name","undefined","isValidElement","alt","displayName","sizes","SIZES"],"mappings":"iVAuBMA,MAAAA,SAA2DC,gBAAAA,gBAC/DC,MAAAA,YAAoD,CAACC,EAAOC,KAC1D,MAAMC,KACJA,EAAO,IAAGC,aACVA,EAAe,EAACC,kBAChBA,EAAoB,MAAKC,gBACzBA,EAAkB,OAAMC,gBACxBA,EAAkB,SAAQC,SAC1BA,GAAW,EAAIC,UACfA,EAAY,CAAE,EAAAC,UACdA,EAAY,CAAE,EAAAC,aACdA,EAAe,CAAE,EAAAC,QACjBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,KACNA,EAAIC,SACJA,EAAQC,QACRA,EAAOC,KACPA,EAAIC,MACJA,EAAKC,QACLA,EAAOC,MACPA,EAAKC,UACLA,EAASC,SACTA,EAAQC,QACRA,KACGC,GACD3B,EAEJ,IAAI4B,EAMJ,IAAIC,EAJAV,IAASS,EAAW,SACpBD,EAAUG,OAAMF,EAAW,KAC3BD,EAAUI,KAAIH,EAAWD,EAAUI,IAIlCH,IAAUC,EAAW,UACtBF,EAAUK,OAAMH,EAAWF,EAAUK,MAEzC,MAAMC,EAAY,CAChB/B,OACAS,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAMkB,EAAa,CACjBV,YACAC,YAGF,MAAMU,SACGhB,GAAY,iBAAmBA,EAAQnB,OAAU,UAAYmB,EAAQnB,QAAU,KAAOmB,EAAQnB,MAAQ,CAAA,EAE/G,MAAOoC,EAAQC,GAASC,MAAMC,QAAQnB,GAAQA,EAAO,CAACA,GAEtD,MAAMoB,EAA2B,CAAEC,WAAY,OAAQvC,KAAM,UAAWwC,MAAO,UAAWnC,YAE1F,MAAMoC,EAA8B,CAAEF,WAAY,OAAQvC,KAAM,GAAK0C,UAAW,KAAMF,MAAO,UAAWnC,YAExG,OACEsC,WAAAA,IAACC,MAAAA,KAAW,IACNb,KACAC,KACAP,EACJI,GAAIH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ACHC,EACAc,EACCQ,WAAAA,IAACW,KAAAA,KAAI,CACHC,OAAO,QACPC,YAAarB,GAAU,SAAWA,OAAQsB,EAC1CvC,YAAaiB,GAAU,SAAWA,OAAQsB,KACtCnD,IAEJ,KACHW,GAAWd,IAAoB,eACrBc,GAAY,WACjBA,EAAQ,IAAKc,KAAcC,IAC3BqB,MAAYA,aAACpC,EAAS,IAAKc,KAAcC,KAAeC,IAC1D,SAGI,IAGlB,CACE2B,YApKmB,WAqKnBC,MAAOC,UAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.mjs","sources":["../../../../src/components/ListItem/ListItem.tsx"],"sourcesContent":["import { forwardRef, cloneElement, isValidElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Skeleton } from 'components/Skeleton'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { ListItemProps } from './types'\n\nconst COMPONENT_NAME = 'ListItem'\n\n/**\n *\n * Component accepts all root HTML attributes.\n *\n * Responsive \"size\", \"margin\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [ListItemProps](https://github.com/foxford/ui/blob/master/src/components/ListItem/types.ts)\n */\nconst ListItem: React.ForwardRefExoticComponent<ListItemProps> = withMergedProps<ListItemProps>(\n forwardRef<HTMLElement, MergedProps<ListItemProps>>((props, ref) => {\n const {\n size = 's',\n borderRadius = 0,\n mediaBorderRadius = '50%',\n controlPosition = 'left',\n captionPosition = 'bottom',\n ellipsis = true,\n iconProps = {},\n textProps = {},\n captionProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n text,\n children,\n control,\n icon,\n media,\n caption,\n addon,\n onColored,\n disabled,\n loading,\n ...restProps\n } = props\n\n let rootNode: ListItemProps['as']\n\n if (control) rootNode = 'label'\n if (restProps.href) rootNode = 'a'\n if (restProps.as) rootNode = restProps.as\n\n let rootType: ListItemProps['type']\n\n if (!rootNode) rootType = 'button'\n if (restProps.type) rootType = restProps.type\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const stateProps = {\n onColored,\n disabled,\n }\n\n const controlProps =\n typeof control === 'object' && typeof control.props === 'object' && control.props !== null ? control.props : {}\n\n const [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const textBaseProps: TextProps = { appearance: 'body', size: 'inherit', color: 'inherit', ellipsis }\n\n const captionBaseProps: TextProps = { appearance: 'body', size: 0.9, sizeUnits: 'em', color: 'inherit', ellipsis }\n\n return (\n <Styled.Root\n {...sizeProps}\n {...stateProps}\n {...restProps}\n as={rootNode}\n type={rootType}\n borderRadius={borderRadius}\n mediaBorderRadius={mediaBorderRadius}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({\n textProps: textBaseProps,\n captionProps: captionBaseProps,\n })\n ) : loading ? (\n <>\n {media ? (\n <Styled.Media>\n <Skeleton width='100%' height='100%' borderRadius='inherit' />\n </Styled.Media>\n ) : null}\n <Styled.Content>\n <Skeleton width='100%' borderRadius={4}>\n <Text {...textBaseProps} {...textProps} />\n </Skeleton>\n </Styled.Content>\n </>\n ) : (\n <>\n {control && controlPosition === 'left'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n {before ? (\n <Icon\n preset='brand'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n />\n ) : null}\n {media ? (\n <Styled.Media>{isValidElement(media) ? media : <Styled.Img alt='' {...media} />}</Styled.Media>\n ) : null}\n {children || text || caption ? (\n <Styled.Content>\n {caption && captionPosition === 'top' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n {children || text ? (\n <Text as='span' {...textBaseProps} {...textProps}>\n {children ?? text}\n </Text>\n ) : null}\n {caption && captionPosition === 'bottom' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n </Styled.Content>\n ) : null}\n {addon}\n {after ? (\n <Icon\n preset='brand'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n />\n ) : null}\n {control && controlPosition === 'right'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { ListItem }\n"],"names":["ListItem","withMergedProps","forwardRef","props","ref","size","borderRadius","mediaBorderRadius","controlPosition","captionPosition","ellipsis","iconProps","textProps","captionProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","text","children","control","icon","media","caption","addon","onColored","disabled","loading","restProps","rootNode","rootType","href","as","type","sizeProps","stateProps","controlProps","before","after","Array","isArray","textBaseProps","appearance","color","captionBaseProps","sizeUnits","_jsx","Styled","_jsxs","_Fragment","Skeleton","width","height","Text","cloneElement","Icon","preset","name","undefined","isValidElement","alt","displayName","sizes","SIZES"],"mappings":"+WAuBMA,MAAAA,SAA2DC,gBAC/DC,YAAoD,CAACC,EAAOC,KAC1D,MAAMC,KACJA,EAAO,IAAGC,aACVA,EAAe,EAACC,kBAChBA,EAAoB,MAAKC,gBACzBA,EAAkB,OAAMC,gBACxBA,EAAkB,SAAQC,SAC1BA,GAAW,EAAIC,UACfA,EAAY,CAAE,EAAAC,UACdA,EAAY,CAAE,EAAAC,aACdA,EAAe,CAAE,EAAAC,QACjBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,KACNA,EAAIC,SACJA,EAAQC,QACRA,EAAOC,KACPA,EAAIC,MACJA,E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KAAeC,IAC1D,KACHC,EACCS,IAACS,KAAI,CACHC,OAAO,QACPC,YAAapB,GAAW,SAAWA,OAASqB,EAC5CrC,YAAagB,GAAW,SAAWA,OAASqB,KACxCjD,IAEJ,KACHa,EACCwB,IAACC,MAAY,CAAA5B,SAAEwC,eAAerC,GAASA,EAAQwB,IAACC,IAAU,CAACa,IAAI,MAAOtC,MACpE,KACHH,GAAYD,GAAQK,EACnByB,KAACD,QAAc,CAAA5B,SAAA,CACZI,GAAWhB,IAAoB,MAC9BuC,IAACO,KAAI,CAACrB,GAAG,UAAWY,KAAsBjC,EAAYQ,SACnDI,IAED,KACHJ,GAAYD,EACX4B,IAACO,KAAI,CAACrB,GAAG,UAAWS,KAAmB/B,EAASS,SAC7CA,GAAYD,IAEb,KACHK,GAAWhB,IAAoB,SAC9BuC,IAACO,KAAI,CAACrB,GAAG,UAAWY,KAAsBjC,EAAYQ,SACnDI,IAED,QAEJ,KACHC,EACAc,EACCQ,IAACS,KAAI,CACHC,OAAO,QACPC,YAAanB,GAAU,SAAWA,OAAQoB,EAC1CrC,YAAaiB,GAAU,SAAWA,OAAQoB,KACtCjD,IAEJ,KACHW,GAAWd,IAAoB,eACrBc,GAAY,WACjBA,EAAQ,IAAKc,KAAcC,IAC3BmB,aAAalC,EAAS,IAAKc,KAAcC,KAAeC,IAC1D,SAGI,IAGlB,CACEyB,YApKmB,WAqKnBC,MAAOC"}
|
|
1
|
+
{"version":3,"file":"ListItem.mjs","sources":["../../../../src/components/ListItem/ListItem.tsx"],"sourcesContent":["import { forwardRef, cloneElement, isValidElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Skeleton } from 'components/Skeleton'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { ListItemProps } from './types'\n\nconst COMPONENT_NAME = 'ListItem'\n\n/**\n *\n * Component accepts all root HTML attributes.\n *\n * Responsive \"size\", \"margin\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [ListItemProps](https://github.com/foxford/ui/blob/master/packages/ui/src/components/ListItem/types.ts)\n */\nconst ListItem: React.ForwardRefExoticComponent<ListItemProps> = withMergedProps<ListItemProps>(\n forwardRef<HTMLElement, MergedProps<ListItemProps>>((props, ref) => {\n const {\n size = 's',\n borderRadius = 0,\n mediaBorderRadius = '50%',\n controlPosition = 'left',\n captionPosition = 'bottom',\n ellipsis = true,\n iconProps = {},\n textProps = {},\n captionProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n text,\n children,\n control,\n icon,\n media,\n caption,\n addon,\n onColored,\n disabled,\n loading,\n ...restProps\n } = props\n\n let rootNode: ListItemProps['as']\n\n if (control) rootNode = 'label'\n if (restProps.href) rootNode = 'a'\n if (restProps.as) rootNode = restProps.as\n\n let rootType: ListItemProps['type']\n\n if (!rootNode) rootType = 'button'\n if (restProps.type) rootType = restProps.type\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const stateProps = {\n onColored,\n disabled,\n }\n\n const controlProps =\n typeof control === 'object' && typeof control.props === 'object' && control.props !== null ? control.props : {}\n\n const [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const textBaseProps: TextProps = { appearance: 'body', size: 'inherit', color: 'inherit', ellipsis }\n\n const captionBaseProps: TextProps = { appearance: 'body', size: 0.9, sizeUnits: 'em', color: 'inherit', ellipsis }\n\n return (\n <Styled.Root\n {...sizeProps}\n {...stateProps}\n {...restProps}\n as={rootNode}\n type={rootType}\n borderRadius={borderRadius}\n mediaBorderRadius={mediaBorderRadius}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({\n textProps: textBaseProps,\n captionProps: captionBaseProps,\n })\n ) : loading ? (\n <>\n {media ? (\n <Styled.Media>\n <Skeleton width='100%' height='100%' borderRadius='inherit' />\n </Styled.Media>\n ) : null}\n <Styled.Content>\n <Skeleton width='100%' borderRadius={4}>\n <Text {...textBaseProps} {...textProps} />\n </Skeleton>\n </Styled.Content>\n </>\n ) : (\n <>\n {control && controlPosition === 'left'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n {before ? (\n <Icon\n preset='brand'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n />\n ) : null}\n {media ? (\n <Styled.Media>{isValidElement(media) ? media : <Styled.Img alt='' {...media} />}</Styled.Media>\n ) : null}\n {children || text || caption ? (\n <Styled.Content>\n {caption && captionPosition === 'top' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n {children || text ? (\n <Text as='span' {...textBaseProps} {...textProps}>\n {children ?? text}\n </Text>\n ) : null}\n {caption && captionPosition === 'bottom' ? (\n <Text as='span' {...captionBaseProps} {...captionProps}>\n {caption}\n </Text>\n ) : null}\n </Styled.Content>\n ) : null}\n {addon}\n {after ? (\n <Icon\n preset='brand'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n />\n ) : null}\n {control && controlPosition === 'right'\n ? typeof control === 'function'\n ? control({ ...sizeProps, ...stateProps })\n : cloneElement(control, { ...sizeProps, ...stateProps, ...controlProps })\n : null}\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { ListItem }\n"],"names":["ListItem","withMergedProps","forwardRef","props","ref","size","borderRadius","mediaBorderRadius","controlPosition","captionPosition","ellipsis","iconProps","textProps","captionProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","text","children","control","icon","media","caption","addon","onColored","disabled","loading","restProps","rootNode","rootType","href","as","type","sizeProps","stateProps","controlProps","before","after","Array","isArray","textBaseProps","appearance","color","captionBaseProps","sizeUnits","_jsx","Styled","_jsxs","_Fragment","Skeleton","width","height","Text","cloneElement","Icon","preset","name","undefined","isValidElement","alt","displayName","sizes","SIZES"],"mappings":"+WAuBMA,MAAAA,SAA2DC,gBAC/DC,YAAoD,CAACC,EAAOC,KAC1D,MAAMC,KACJA,EAAO,IAAGC,aACVA,EAAe,EAACC,kBAChBA,EAAoB,MAAKC,gBACzBA,EAAkB,OAAMC,gBACxBA,EAAkB,SAAQC,SAC1BA,GAAW,EAAIC,UACfA,EAAY,CAAE,EAAAC,UACdA,EAAY,CAAE,EAAAC,aACdA,EAAe,CAAE,EAAAC,QACjBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,KACNA,EAAIC,SACJA,EAAQC,QACRA,EAAOC,KACPA,EAAIC,MACJA,EAAKC,QACLA,EAAOC,MACPA,EAAKC,UACLA,EAASC,SACTA,EAAQC,QACRA,KACGC,GACD3B,EAEJ,IAAI4B,EAMJ,IAAIC,EAJAV,IAASS,EAAW,SACpBD,EAAUG,OAAMF,EAAW,KAC3BD,EAAUI,KAAIH,EAAWD,EAAUI,IAIlCH,IAAUC,EAAW,UACtBF,EAAUK,OAAMH,EAAWF,EAAUK,MAEzC,MAAMC,EAAY,CAChB/B,OACAS,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAMkB,EAAa,CACjBV,YACAC,YAGF,MAAMU,SACGhB,GAAY,iBAAmBA,EAAQnB,OAAU,UAAYmB,EAAQnB,QAAU,KAAOmB,EAAQnB,MAAQ,CAAA,EAE/G,MAAOoC,EAAQC,GAASC,MAAMC,QAAQnB,GAAQA,EAAO,CAACA,GAEtD,MAAMoB,EAA2B,CAAEC,WAAY,OAAQvC,KAAM,UAAWwC,MAAO,UAAWnC,YAE1F,MAAMoC,EAA8B,CAAEF,WAAY,OAAQvC,KAAM,GAAK0C,UAAW,KAAMF,MAAO,UAAWnC,YAExG,OACEsC,IAACC,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