@foxford/ui 2.52.0 → 2.53.0
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/_virtual/index7.mjs +1 -1
- package/_virtual/index8.js +2 -0
- package/_virtual/index8.js.map +1 -0
- package/_virtual/index8.mjs +2 -0
- package/_virtual/index8.mjs.map +1 -0
- package/components/DialogComponent/DialogComponent.js +1 -1
- package/components/DialogComponent/DialogComponent.js.map +1 -1
- package/components/DialogComponent/DialogComponent.mjs +1 -1
- package/components/DialogComponent/DialogComponent.mjs.map +1 -1
- package/components/FormInputLabel/FormInputLabel.js +1 -1
- package/components/FormInputLabel/FormInputLabel.js.map +1 -1
- package/components/FormInputLabel/FormInputLabel.mjs +1 -1
- package/components/FormInputLabel/FormInputLabel.mjs.map +1 -1
- package/components/FormInputLabel/constants.js +1 -1
- package/components/FormInputLabel/constants.js.map +1 -1
- package/components/FormInputLabel/constants.mjs +1 -1
- package/components/FormInputLabel/constants.mjs.map +1 -1
- package/components/FormInputLabel/style.js +1 -1
- package/components/FormInputLabel/style.js.map +1 -1
- package/components/FormInputLabel/style.mjs +1 -1
- package/components/FormInputLabel/style.mjs.map +1 -1
- package/components/MenuComponent/MenuComponent.js +1 -1
- package/components/MenuComponent/MenuComponent.js.map +1 -1
- package/components/MenuComponent/MenuComponent.mjs +1 -1
- package/components/MenuComponent/MenuComponent.mjs.map +1 -1
- package/components/Paper/Paper.js.map +1 -1
- package/components/Paper/Paper.mjs.map +1 -1
- package/components/Text/Ellipsis.js +1 -1
- package/components/Text/Ellipsis.js.map +1 -1
- package/components/Text/Ellipsis.mjs +1 -1
- package/components/Text/Ellipsis.mjs.map +1 -1
- package/components/Textarea/Textarea.js +1 -1
- package/components/Textarea/Textarea.js.map +1 -1
- package/components/Textarea/Textarea.mjs +1 -1
- package/components/Textarea/Textarea.mjs.map +1 -1
- package/components/Textarea/constants.js +2 -0
- package/components/Textarea/constants.js.map +1 -0
- package/components/Textarea/constants.mjs +2 -0
- package/components/Textarea/constants.mjs.map +1 -0
- package/components/Textarea/style.js +1 -1
- package/components/Textarea/style.js.map +1 -1
- package/components/Textarea/style.mjs +1 -1
- package/components/Textarea/style.mjs.map +1 -1
- package/dts/index.d.ts +95 -18
- package/external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/ResizeHandle/index.js +2 -0
- package/external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/ResizeHandle/index.js.map +1 -0
- package/external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/ResizeHandle/index.mjs +2 -0
- package/external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/ResizeHandle/index.mjs.map +1 -0
- package/external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/WarningTriangleFill/index.js +1 -1
- package/external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/WarningTriangleFill/index.mjs +1 -1
- package/hooks/useClickOutside.js +1 -1
- package/hooks/useClickOutside.js.map +1 -1
- package/hooks/useClickOutside.mjs +1 -1
- package/hooks/useClickOutside.mjs.map +1 -1
- package/hooks/useResizable.js +2 -0
- package/hooks/useResizable.js.map +1 -0
- package/hooks/useResizable.mjs +2 -0
- package/hooks/useResizable.mjs.map +1 -0
- package/package.json +1 -1
- package/shared/utils/misc.js +2 -0
- package/shared/utils/misc.js.map +1 -0
- package/shared/utils/misc.mjs +2 -0
- package/shared/utils/misc.mjs.map +1 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import styled,{css}from'styled-components';import tinycolor from'../../external/.pnpm/tinycolor2@1.4.2/node_modules/tinycolor2/tinycolor.mjs';import{createShouldForwardProp}from'../../shared/utils/style.mjs';import{responsiveSize}from'../../mixins/responsive-size.mjs';import{responsiveMargin}from'../../mixins/responsive-margin.mjs';const shouldForwardFormInputLabelProp=createShouldForwardProp((o=>!['primary','secondary','error','success','disabled','onColored','inline','zIndex'].includes(o)));const template=o=>`\n color: ${o.color};\n background-color: ${o.backgroundColor};\n border-color: ${o.borderColor};\n &:hover {\n background-color: ${o.backgroundColorHover};\n }\n &:focus-within {\n background-color: ${o.backgroundColor};\n }\n & [data-input-control]::after {\n color: ${o.backgroundColor}; \n }\n`;const COLOR_SCHEMA={contrast:{disabled:css(["",""],(o=>template({color:o.theme.colors['content-disabled'],backgroundColor:o.theme.colors['bg-disabled-large'],borderColor:o.theme.colors.transparent,backgroundColorHover:o.theme.colors['bg-disabled-large'],...o.palette}))),error:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-error-200'],borderColor:o.theme.colors['alert-bg-error-500'],backgroundColorHover:o.theme.colors['alert-bg-error-200'],...o.palette}))),success:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-success-200'],borderColor:o.theme.colors['alert-bg-success-500'],backgroundColorHover:o.theme.colors['alert-bg-success-200'],...o.palette}))),default:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['bg-onmain-primary'],borderColor:o.theme.colors['border-onmain-default-large'],backgroundColorHover:tinycolor(o.theme.colors['bg-onmain-primary']).darken(4).toString(),...o.palette})))},secondary:{disabled:css(["",""],(o=>template({color:o.theme.colors['content-disabled'],backgroundColor:o.theme.colors['bg-disabled-large'],borderColor:o.theme.colors.transparent,backgroundColorHover:o.theme.colors['bg-disabled-large'],...o.palette}))),error:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-error-100'],borderColor:o.theme.colors['alert-bg-error-500'],backgroundColorHover:o.theme.colors['alert-bg-error-100'],...o.palette}))),success:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-success-100'],borderColor:o.theme.colors['alert-bg-success-500'],backgroundColorHover:o.theme.colors['alert-bg-success-100'],...o.palette}))),default:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['bg-onmain-secondary'],borderColor:o.theme.colors['border-onmain-default-large'],backgroundColorHover:tinycolor(o.theme.colors['bg-onmain-secondary']).darken(4).toString(),...o.palette})))},primary:{disabled:css(["",""],(o=>template({color:o.theme.colors['content-disabled'],backgroundColor:o.theme.colors['bg-disabled-large'],borderColor:o.theme.colors.transparent,backgroundColorHover:o.theme.colors['bg-disabled-large'],...o.palette}))),error:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-error-100'],borderColor:o.theme.colors['alert-bg-error-500'],backgroundColorHover:o.theme.colors['alert-bg-error-100'],...o.palette}))),success:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-success-100'],borderColor:o.theme.colors['alert-bg-success-500'],backgroundColorHover:o.theme.colors['alert-bg-success-100'],...o.palette}))),default:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['bg-onmain-primary'],borderColor:o.theme.colors['border-onmain-default-large'],backgroundColorHover:tinycolor(o.theme.colors['bg-onmain-primary']).darken(4).toString(),...o.palette})))}};const Dropdown=styled.div.withConfig({displayName:"FormInputLabel__Dropdown",componentId:"ui__sc-1il4atw-0"})(["box-sizing:border-box;position:absolute;top:100%;margin-top:8px;"]);const Root=styled.div.withConfig({shouldForwardProp:shouldForwardFormInputLabelProp}).withConfig({displayName:"FormInputLabel__Root",componentId:"ui__sc-1il4atw-1"})([""," "," "," ",""],(o=>{const e='1px';return`\n box-sizing: border-box;\n position: relative;\n isolation: isolate;\n display: ${o.inline?'inline-flex':'flex'};\n cursor: ${o.disabled?'not-allowed':'pointer'};\n align-items: center;\n min-width: min-content;\n border: ${e} solid transparent;\n z-index: ${o.zIndex??'auto'};\n transition-property: background-color;\n transition-duration: 150ms;\n transition-timing-function: ease-in;\n\n & > ${Dropdown} {\n right: -${e};\n left: -${e};\n }\n\n &:focus-within {\n box-shadow: 0 0 0 2px ${o.theme.colors.white}, 0 0 0 4px ${o.theme.colors['border-focus']};\n outline: 2px solid transparent;\n outline-offset: 2px;\n }\n\n &:hover [data-input-control]::after,\n &:focus-within [data-input-control]::after {\n opacity: 0;\n }\n `}),(o=>{let e=COLOR_SCHEMA.primary;return o.secondary&&(e=COLOR_SCHEMA.secondary),(o.contrast||o.onColored)&&(e=COLOR_SCHEMA.contrast),o.disabled?e.disabled:o.error?e.error:o.success?e.success:e.default}),responsiveSize,responsiveMargin);const Label=styled.span.withConfig({displayName:"FormInputLabel__Label",componentId:"ui__sc-1il4atw-2"})(["box-sizing:border-box;position:absolute;left:0;top:
|
|
1
|
+
import styled,{css}from'styled-components';import tinycolor from'../../external/.pnpm/tinycolor2@1.4.2/node_modules/tinycolor2/tinycolor.mjs';import{createShouldForwardProp}from'../../shared/utils/style.mjs';import{responsiveSize}from'../../mixins/responsive-size.mjs';import{responsiveMargin}from'../../mixins/responsive-margin.mjs';const shouldForwardFormInputLabelProp=createShouldForwardProp((o=>!['primary','secondary','error','success','disabled','onColored','inline','zIndex','overflow'].includes(o)));const template=o=>`\n color: ${o.color};\n background-color: ${o.backgroundColor};\n border-color: ${o.borderColor};\n &:hover {\n background-color: ${o.backgroundColorHover};\n }\n &:focus-within {\n background-color: ${o.backgroundColor};\n }\n & [data-input-control]::after {\n color: ${o.backgroundColor}; \n }\n`;const COLOR_SCHEMA={contrast:{disabled:css(["",""],(o=>template({color:o.theme.colors['content-disabled'],backgroundColor:o.theme.colors['bg-disabled-large'],borderColor:o.theme.colors.transparent,backgroundColorHover:o.theme.colors['bg-disabled-large'],...o.palette}))),error:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-error-200'],borderColor:o.theme.colors['alert-bg-error-500'],backgroundColorHover:o.theme.colors['alert-bg-error-200'],...o.palette}))),success:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-success-200'],borderColor:o.theme.colors['alert-bg-success-500'],backgroundColorHover:o.theme.colors['alert-bg-success-200'],...o.palette}))),default:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['bg-onmain-primary'],borderColor:o.theme.colors['border-onmain-default-large'],backgroundColorHover:tinycolor(o.theme.colors['bg-onmain-primary']).darken(4).toString(),...o.palette})))},secondary:{disabled:css(["",""],(o=>template({color:o.theme.colors['content-disabled'],backgroundColor:o.theme.colors['bg-disabled-large'],borderColor:o.theme.colors.transparent,backgroundColorHover:o.theme.colors['bg-disabled-large'],...o.palette}))),error:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-error-100'],borderColor:o.theme.colors['alert-bg-error-500'],backgroundColorHover:o.theme.colors['alert-bg-error-100'],...o.palette}))),success:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-success-100'],borderColor:o.theme.colors['alert-bg-success-500'],backgroundColorHover:o.theme.colors['alert-bg-success-100'],...o.palette}))),default:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['bg-onmain-secondary'],borderColor:o.theme.colors['border-onmain-default-large'],backgroundColorHover:tinycolor(o.theme.colors['bg-onmain-secondary']).darken(4).toString(),...o.palette})))},primary:{disabled:css(["",""],(o=>template({color:o.theme.colors['content-disabled'],backgroundColor:o.theme.colors['bg-disabled-large'],borderColor:o.theme.colors.transparent,backgroundColorHover:o.theme.colors['bg-disabled-large'],...o.palette}))),error:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-error-100'],borderColor:o.theme.colors['alert-bg-error-500'],backgroundColorHover:o.theme.colors['alert-bg-error-100'],...o.palette}))),success:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['alert-bg-success-100'],borderColor:o.theme.colors['alert-bg-success-500'],backgroundColorHover:o.theme.colors['alert-bg-success-100'],...o.palette}))),default:css(["",""],(o=>template({color:o.theme.colors['content-onmain-secondary'],backgroundColor:o.theme.colors['bg-onmain-primary'],borderColor:o.theme.colors['border-onmain-default-large'],backgroundColorHover:tinycolor(o.theme.colors['bg-onmain-primary']).darken(4).toString(),...o.palette})))}};const Dropdown=styled.div.withConfig({displayName:"FormInputLabel__Dropdown",componentId:"ui__sc-1il4atw-0"})(["box-sizing:border-box;position:absolute;top:100%;margin-top:8px;"]);const Root=styled.div.withConfig({shouldForwardProp:shouldForwardFormInputLabelProp}).withConfig({displayName:"FormInputLabel__Root",componentId:"ui__sc-1il4atw-1"})([""," "," "," ",""],(o=>{const e='1px';return`\n box-sizing: border-box;\n position: relative;\n isolation: isolate;\n display: ${o.inline?'inline-flex':'flex'};\n cursor: ${o.disabled?'not-allowed':'pointer'};\n align-items: center;\n min-width: min-content;\n border: ${e} solid transparent;\n z-index: ${o.zIndex??'auto'};\n overflow: ${o.overflow??'visible'};\n transition-property: background-color;\n transition-duration: 150ms;\n transition-timing-function: ease-in;\n\n & > ${Dropdown} {\n right: -${e};\n left: -${e};\n }\n\n &:focus-within {\n box-shadow: 0 0 0 2px ${o.theme.colors.white}, 0 0 0 4px ${o.theme.colors['border-focus']};\n outline: 2px solid transparent;\n outline-offset: 2px;\n }\n\n &:hover [data-input-control]::after,\n &:focus-within [data-input-control]::after {\n opacity: 0;\n }\n `}),(o=>{let e=COLOR_SCHEMA.primary;return o.secondary&&(e=COLOR_SCHEMA.secondary),(o.contrast||o.onColored)&&(e=COLOR_SCHEMA.contrast),o.disabled?e.disabled:o.error?e.error:o.success?e.success:e.default}),responsiveSize,responsiveMargin);const Label=styled.span.withConfig({displayName:"FormInputLabel__Label",componentId:"ui__sc-1il4atw-2"})(["box-sizing:border-box;position:absolute;left:0;top:0;transform:translateY(0.7em);width:100%;white-space:nowrap;overflow:hidden;line-height:1;text-overflow:ellipsis;pointer-events:none;transition-property:transform,width;transition-duration:","ms,0ms;transition-delay:0ms,0ms;transition-timing-function:cubic-bezier(0,0,0.48,1);"],125);const InputContainer=styled.div.withConfig({shouldForwardProp:o=>!['position','labelPosition','labelActive'].includes(o)}).withConfig({displayName:"FormInputLabel__InputContainer",componentId:"ui__sc-1il4atw-3"})([""," "," "," ",""],(o=>`\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-grow: 1;\n align-self: ${o.position};\n cursor: inherit;\n min-height: 2.4em;\n `),(o=>o.labelPosition==='dynamic'&&`\n padding-top: 0.7em;\n\n & input, & textarea {\n opacity: ${o.labelActive?1:0};\n }\n\n ${o.labelActive&&`& > ${Label} {\n transition-delay: 0ms, 125ms;\n transform: scale(0.7) translateX(-21.4%) translateY(0px);\n width: 130%;\n }`}\n `),(o=>o.labelPosition==='top'&&`\n padding-top: 0.7em;\n\n & > ${Label} {\n transition-delay: 0ms, 125ms;\n transform: scale(0.7) translateX(-21.4%) translateY(0px);\n width: 130%;\n }\n `),(o=>o.labelPosition==='center'&&`\n & input, & textarea {\n opacity: ${o.labelActive?1:0};\n }\n\n & > ${Label} {\n opacity: ${o.labelActive?0:1};\n z-index: ${o.labelActive?-1:'auto'};\n }\n `));export{Dropdown,InputContainer,Label,Root};
|
|
2
2
|
//# sourceMappingURL=style.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","sources":["../../../../src/components/FormInputLabel/style.ts"],"sourcesContent":["import styled, { css } from 'styled-components'\nimport tinycolor from 'tinycolor2'\nimport { createShouldForwardProp } from 'shared/utils/style'\nimport { responsiveSize } from 'mixins/responsive-size'\nimport { responsiveMargin } from 'mixins/responsive-margin'\nimport type { CSSColor } from 'shared/types'\nimport type { StyledFormInputLabelProps, FormInputLabelPalette, StyledInputContainerProps } from './types'\n\nconst shouldForwardFormInputLabelProp = createShouldForwardProp(\n (propKey) =>\n !['primary', 'secondary', 'error', 'success', 'disabled', 'onColored', 'inline', 'zIndex'].includes(propKey)\n)\n\nconst labelTransitionMS = 125\n\nconst template = (palette: FormInputLabelPalette) => `\n color: ${palette.color};\n background-color: ${palette.backgroundColor};\n border-color: ${palette.borderColor};\n &:hover {\n background-color: ${palette.backgroundColorHover};\n }\n &:focus-within {\n background-color: ${palette.backgroundColor};\n }\n & [data-input-control]::after {\n color: ${palette.backgroundColor}; \n }\n`\n\nconst COLOR_SCHEMA = {\n contrast: {\n disabled: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-disabled'],\n backgroundColor: props.theme.colors['bg-disabled-large'],\n borderColor: props.theme.colors.transparent,\n backgroundColorHover: props.theme.colors['bg-disabled-large'],\n ...props.palette,\n })}\n `,\n error: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-error-200'],\n borderColor: props.theme.colors['alert-bg-error-500'],\n backgroundColorHover: props.theme.colors['alert-bg-error-200'],\n ...props.palette,\n })}\n `,\n success: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-success-200'],\n borderColor: props.theme.colors['alert-bg-success-500'],\n backgroundColorHover: props.theme.colors['alert-bg-success-200'],\n ...props.palette,\n })}\n `,\n default: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['bg-onmain-primary'],\n borderColor: props.theme.colors['border-onmain-default-large'],\n backgroundColorHover: tinycolor(props.theme.colors['bg-onmain-primary']).darken(4).toString() as CSSColor,\n ...props.palette,\n })}\n `,\n },\n secondary: {\n disabled: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-disabled'],\n backgroundColor: props.theme.colors['bg-disabled-large'],\n borderColor: props.theme.colors.transparent,\n backgroundColorHover: props.theme.colors['bg-disabled-large'],\n ...props.palette,\n })}\n `,\n error: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-error-100'],\n borderColor: props.theme.colors['alert-bg-error-500'],\n backgroundColorHover: props.theme.colors['alert-bg-error-100'],\n ...props.palette,\n })}\n `,\n success: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-success-100'],\n borderColor: props.theme.colors['alert-bg-success-500'],\n backgroundColorHover: props.theme.colors['alert-bg-success-100'],\n ...props.palette,\n })}\n `,\n default: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['bg-onmain-secondary'],\n borderColor: props.theme.colors['border-onmain-default-large'],\n backgroundColorHover: tinycolor(props.theme.colors['bg-onmain-secondary']).darken(4).toString() as CSSColor,\n ...props.palette,\n })}\n `,\n },\n primary: {\n disabled: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-disabled'],\n backgroundColor: props.theme.colors['bg-disabled-large'],\n borderColor: props.theme.colors.transparent,\n backgroundColorHover: props.theme.colors['bg-disabled-large'],\n ...props.palette,\n })}\n `,\n error: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-error-100'],\n borderColor: props.theme.colors['alert-bg-error-500'],\n backgroundColorHover: props.theme.colors['alert-bg-error-100'],\n ...props.palette,\n })}\n `,\n success: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-success-100'],\n borderColor: props.theme.colors['alert-bg-success-500'],\n backgroundColorHover: props.theme.colors['alert-bg-success-100'],\n ...props.palette,\n })}\n `,\n default: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['bg-onmain-primary'],\n borderColor: props.theme.colors['border-onmain-default-large'],\n backgroundColorHover: tinycolor(props.theme.colors['bg-onmain-primary']).darken(4).toString() as CSSColor,\n ...props.palette,\n })}\n `,\n },\n}\n\nexport const Dropdown = styled.div`\n box-sizing: border-box;\n position: absolute;\n top: 100%;\n margin-top: 8px;\n`\n\nexport const Root = styled.div.withConfig<StyledFormInputLabelProps>({\n shouldForwardProp: shouldForwardFormInputLabelProp,\n})`\n ${(props) => {\n const borderWidth = '1px'\n\n return `\n box-sizing: border-box;\n position: relative;\n isolation: isolate;\n display: ${props.inline ? 'inline-flex' : 'flex'};\n cursor: ${props.disabled ? 'not-allowed' : 'pointer'};\n align-items: center;\n min-width: min-content;\n border: ${borderWidth} solid transparent;\n z-index: ${props.zIndex ?? 'auto'};\n transition-property: background-color;\n transition-duration: 150ms;\n transition-timing-function: ease-in;\n\n & > ${Dropdown} {\n right: -${borderWidth};\n left: -${borderWidth};\n }\n\n &:focus-within {\n box-shadow: 0 0 0 2px ${props.theme.colors.white}, 0 0 0 4px ${props.theme.colors['border-focus']};\n outline: 2px solid transparent;\n outline-offset: 2px;\n }\n\n &:hover [data-input-control]::after,\n &:focus-within [data-input-control]::after {\n opacity: 0;\n }\n `\n }}\n ${(props) => {\n let schema = COLOR_SCHEMA.primary\n\n if (props.secondary) schema = COLOR_SCHEMA.secondary\n if (props.contrast || props.onColored) schema = COLOR_SCHEMA.contrast\n\n if (props.disabled) return schema.disabled\n if (props.error) return schema.error\n if (props.success) return schema.success\n\n return schema.default\n }}\n\n ${responsiveSize}\n ${responsiveMargin}\n`\n\nexport const Label = styled.span`\n box-sizing: border-box;\n position: absolute;\n left: 0;\n top: 50%;\n transform: translateY(-50%);\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n pointer-events: none;\n transition-property: transform, width;\n transition-duration: ${labelTransitionMS}ms, 0ms;\n transition-delay: 0ms, 0ms;\n transition-timing-function: cubic-bezier(0, 0, 0.48, 1);\n`\n\nexport const InputContainer = styled.div.withConfig<StyledInputContainerProps>({\n shouldForwardProp: (propKey) => !['labelPosition', 'labelActive'].includes(propKey),\n})`\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-grow: 1;\n align-self: stretch;\n cursor: inherit;\n\n ${(props) =>\n props.labelPosition === 'dynamic' &&\n `\n padding-top: 0.8em;\n\n & input {\n opacity: ${props.labelActive ? 1 : 0};\n }\n\n ${\n props.labelActive &&\n `& > ${Label} {\n transition-delay: 0ms, ${labelTransitionMS}ms;\n transform: scale(0.7) translateX(-21.4%) translateY(-140%);\n width: 130%;\n }`\n }\n `}\n\n ${(props) =>\n props.labelPosition === 'top' &&\n `\n padding-top: 0.8em;\n\n & > ${Label} {\n transition-delay: 0ms, ${labelTransitionMS}ms;\n transform: scale(0.7) translateX(-21.4%) translateY(-140%);\n width: 130%;\n }\n `}\n\n ${(props) =>\n props.labelPosition === 'center' &&\n `\n & input {\n opacity: ${props.labelActive ? 1 : 0};\n }\n\n & > ${Label} {\n opacity: ${props.labelActive ? 0 : 1};\n z-index: ${props.labelActive ? -1 : 'auto'};\n }\n `}\n`\n"],"names":["shouldForwardFormInputLabelProp","createShouldForwardProp","propKey","includes","template","palette","color","backgroundColor","borderColor","backgroundColorHover","COLOR_SCHEMA","contrast","disabled","css","props","theme","colors","transparent","error","success","default","tinycolor","darken","toString","secondary","primary","Dropdown","styled","div","withConfig","displayName","componentId","Root","shouldForwardProp","borderWidth","inline","zIndex","white","schema","onColored","responsiveSize","responsiveMargin","Label","span","InputContainer","labelPosition","labelActive"],"mappings":"8UAQA,MAAMA,gCAAkCC,yBACrCC,IACE,CAAC,UAAW,YAAa,QAAS,UAA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CAAW,CAAA,sOAAA,wFA/MN,KAgOnB,MAAMiB,eAAiBjB,OAAOC,IAAIC,WAAsC,CAC7EI,kBAAoB/B,IAAa,CAAC,gBAAiB,eAAeC,SAASD,KAC3E2B,WAAA,CAAAC,YAAA,iCAAAC,YAAA,oBAF4BJ,CAE5B,CAAA,sGAAA,IAAA,IAAA,KAQGb,GACDA,EAAM+B,gBAAkB,WACxB,oEAIe/B,EAAMgC,YAAc,EAAI,yBAIlChC,EAAMgC,aACN,OAAOJ,uLAQX5B,GACDA,EAAM+B,gBAAkB,OACxB,4CAGQH,6JAOP5B,GACDA,EAAM+B,gBAAkB,UACxB,uCAEe/B,EAAMgC,YAAc,EAAI,4BAG/BJ,6BACO5B,EAAMgC,YAAc,EAAI,wBACxBhC,EAAMgC,aAAe,EAAI"}
|
|
1
|
+
{"version":3,"file":"style.mjs","sources":["../../../../src/components/FormInputLabel/style.ts"],"sourcesContent":["import styled, { css } from 'styled-components'\nimport tinycolor from 'tinycolor2'\nimport { createShouldForwardProp } from 'shared/utils/style'\nimport { responsiveSize } from 'mixins/responsive-size'\nimport { responsiveMargin } from 'mixins/responsive-margin'\nimport type { CSSColor } from 'shared/types'\nimport type { StyledFormInputLabelProps, FormInputLabelPalette, StyledInputContainerProps } from './types'\n\nconst shouldForwardFormInputLabelProp = createShouldForwardProp(\n (propKey) =>\n !['primary', 'secondary', 'error', 'success', 'disabled', 'onColored', 'inline', 'zIndex', 'overflow'].includes(\n propKey\n )\n)\n\nconst labelTransitionMS = 125\n\nconst template = (palette: FormInputLabelPalette) => `\n color: ${palette.color};\n background-color: ${palette.backgroundColor};\n border-color: ${palette.borderColor};\n &:hover {\n background-color: ${palette.backgroundColorHover};\n }\n &:focus-within {\n background-color: ${palette.backgroundColor};\n }\n & [data-input-control]::after {\n color: ${palette.backgroundColor}; \n }\n`\n\nconst COLOR_SCHEMA = {\n contrast: {\n disabled: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-disabled'],\n backgroundColor: props.theme.colors['bg-disabled-large'],\n borderColor: props.theme.colors.transparent,\n backgroundColorHover: props.theme.colors['bg-disabled-large'],\n ...props.palette,\n })}\n `,\n error: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-error-200'],\n borderColor: props.theme.colors['alert-bg-error-500'],\n backgroundColorHover: props.theme.colors['alert-bg-error-200'],\n ...props.palette,\n })}\n `,\n success: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-success-200'],\n borderColor: props.theme.colors['alert-bg-success-500'],\n backgroundColorHover: props.theme.colors['alert-bg-success-200'],\n ...props.palette,\n })}\n `,\n default: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['bg-onmain-primary'],\n borderColor: props.theme.colors['border-onmain-default-large'],\n backgroundColorHover: tinycolor(props.theme.colors['bg-onmain-primary']).darken(4).toString() as CSSColor,\n ...props.palette,\n })}\n `,\n },\n secondary: {\n disabled: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-disabled'],\n backgroundColor: props.theme.colors['bg-disabled-large'],\n borderColor: props.theme.colors.transparent,\n backgroundColorHover: props.theme.colors['bg-disabled-large'],\n ...props.palette,\n })}\n `,\n error: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-error-100'],\n borderColor: props.theme.colors['alert-bg-error-500'],\n backgroundColorHover: props.theme.colors['alert-bg-error-100'],\n ...props.palette,\n })}\n `,\n success: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-success-100'],\n borderColor: props.theme.colors['alert-bg-success-500'],\n backgroundColorHover: props.theme.colors['alert-bg-success-100'],\n ...props.palette,\n })}\n `,\n default: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['bg-onmain-secondary'],\n borderColor: props.theme.colors['border-onmain-default-large'],\n backgroundColorHover: tinycolor(props.theme.colors['bg-onmain-secondary']).darken(4).toString() as CSSColor,\n ...props.palette,\n })}\n `,\n },\n primary: {\n disabled: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-disabled'],\n backgroundColor: props.theme.colors['bg-disabled-large'],\n borderColor: props.theme.colors.transparent,\n backgroundColorHover: props.theme.colors['bg-disabled-large'],\n ...props.palette,\n })}\n `,\n error: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-error-100'],\n borderColor: props.theme.colors['alert-bg-error-500'],\n backgroundColorHover: props.theme.colors['alert-bg-error-100'],\n ...props.palette,\n })}\n `,\n success: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['alert-bg-success-100'],\n borderColor: props.theme.colors['alert-bg-success-500'],\n backgroundColorHover: props.theme.colors['alert-bg-success-100'],\n ...props.palette,\n })}\n `,\n default: css<StyledFormInputLabelProps>`\n ${(props) =>\n template({\n color: props.theme.colors['content-onmain-secondary'],\n backgroundColor: props.theme.colors['bg-onmain-primary'],\n borderColor: props.theme.colors['border-onmain-default-large'],\n backgroundColorHover: tinycolor(props.theme.colors['bg-onmain-primary']).darken(4).toString() as CSSColor,\n ...props.palette,\n })}\n `,\n },\n}\n\nexport const Dropdown = styled.div`\n box-sizing: border-box;\n position: absolute;\n top: 100%;\n margin-top: 8px;\n`\n\nexport const Root = styled.div.withConfig<StyledFormInputLabelProps>({\n shouldForwardProp: shouldForwardFormInputLabelProp,\n})`\n ${(props) => {\n const borderWidth = '1px'\n\n return `\n box-sizing: border-box;\n position: relative;\n isolation: isolate;\n display: ${props.inline ? 'inline-flex' : 'flex'};\n cursor: ${props.disabled ? 'not-allowed' : 'pointer'};\n align-items: center;\n min-width: min-content;\n border: ${borderWidth} solid transparent;\n z-index: ${props.zIndex ?? 'auto'};\n overflow: ${props.overflow ?? 'visible'};\n transition-property: background-color;\n transition-duration: 150ms;\n transition-timing-function: ease-in;\n\n & > ${Dropdown} {\n right: -${borderWidth};\n left: -${borderWidth};\n }\n\n &:focus-within {\n box-shadow: 0 0 0 2px ${props.theme.colors.white}, 0 0 0 4px ${props.theme.colors['border-focus']};\n outline: 2px solid transparent;\n outline-offset: 2px;\n }\n\n &:hover [data-input-control]::after,\n &:focus-within [data-input-control]::after {\n opacity: 0;\n }\n `\n }}\n ${(props) => {\n let schema = COLOR_SCHEMA.primary\n\n if (props.secondary) schema = COLOR_SCHEMA.secondary\n if (props.contrast || props.onColored) schema = COLOR_SCHEMA.contrast\n\n if (props.disabled) return schema.disabled\n if (props.error) return schema.error\n if (props.success) return schema.success\n\n return schema.default\n }}\n\n ${responsiveSize}\n ${responsiveMargin}\n`\n\nexport const Label = styled.span`\n box-sizing: border-box;\n position: absolute;\n left: 0;\n top: 0;\n transform: translateY(0.7em);\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n line-height: 1;\n text-overflow: ellipsis;\n pointer-events: none;\n transition-property: transform, width;\n transition-duration: ${labelTransitionMS}ms, 0ms;\n transition-delay: 0ms, 0ms;\n transition-timing-function: cubic-bezier(0, 0, 0.48, 1);\n`\n\nexport const InputContainer = styled.div.withConfig<StyledInputContainerProps>({\n shouldForwardProp: (propKey) => !['position', 'labelPosition', 'labelActive'].includes(propKey),\n})`\n ${(props) => `\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-grow: 1;\n align-self: ${props.position};\n cursor: inherit;\n min-height: 2.4em;\n `}\n\n ${(props) =>\n props.labelPosition === 'dynamic' &&\n `\n padding-top: 0.7em;\n\n & input, & textarea {\n opacity: ${props.labelActive ? 1 : 0};\n }\n\n ${\n props.labelActive &&\n `& > ${Label} {\n transition-delay: 0ms, ${labelTransitionMS}ms;\n transform: scale(0.7) translateX(-21.4%) translateY(0px);\n width: 130%;\n }`\n }\n `}\n\n ${(props) =>\n props.labelPosition === 'top' &&\n `\n padding-top: 0.7em;\n\n & > ${Label} {\n transition-delay: 0ms, ${labelTransitionMS}ms;\n transform: scale(0.7) translateX(-21.4%) translateY(0px);\n width: 130%;\n }\n `}\n\n ${(props) =>\n props.labelPosition === 'center' &&\n `\n & input, & textarea {\n opacity: ${props.labelActive ? 1 : 0};\n }\n\n & > ${Label} {\n opacity: ${props.labelActive ? 0 : 1};\n z-index: ${props.labelActive ? -1 : 'auto'};\n }\n `}\n`\n"],"names":["shouldForwardFormInputLabelProp","createShouldForwardProp","propKey","includes","template","palette","color","backgroundColor","borderColor","backgroundColorHover","COLOR_SCHEMA","contrast","disabled","css","props","theme","colors","transparent","error","success","default","tinycolor","darken","toString","secondary","primary","Dropdown","styled","div","withConfig","displayName","componentId","Root","shouldForwardProp","borderWidth","inline","zIndex","overflow","white","schema","onColored","responsiveSize","responsiveMargin","Label","span","InputContainer","position","labelPosition","labelActive"],"mappings":"8UAQA,MAAMA,gCAAkCC,yBACrCC,IACE,CAAC,UAAW,YAAa,QAAS,UAAW,WAAY,YAAa,SAAU,SAAU,YAAYC,SACrGD,KAMN,MAAME,SAAYC,GAAmC,cAC1CA,EAAQC,+BACGD,EAAQE,qCACZF,EAAQG,oDAEFH,EAAQI,yEAGRJ,EAAQE,wEAGnBF,EAAQE,2BAIrB,MAAMG,aAAe,CACnBC,SAAU,CACRC,SAAUC,IAAG,CAAA,GAAA,KACRC,GACDV,SAAS,CACPE,MAAOQ,EAAMC,MAAMC,OAAO,oBAC1BT,gBAAiBO,EAAMC,MAAMC,OAAO,qBACpCR,YAAaM,EAAMC,MAAMC,OAAOC,YAChCR,qBAAsBK,EAAMC,MAAMC,OAAO,wBACtCF,EAAMT,YAGfa,MAAOL,IA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J,2JAOP7B,GACDA,EAAMiC,gBAAkB,UACxB,mDAEejC,EAAMkC,YAAc,EAAI,4BAG/BL,6BACO7B,EAAMkC,YAAc,EAAI,wBACxBlC,EAAMkC,aAAe,EAAI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var React=require('react');var withMergedProps=require('../../hocs/withMergedProps.js');var dom=require('../../shared/utils/dom.js');var constants=require('./constants.js');var style=require('./style.js');var require$$0=require('react/jsx-runtime');const noop=()=>{};const MenuComponent=withMergedProps.withMergedProps(React.forwardRef(((e,s)=>{const{size:t="m",closeFn:o=noop,sizeXXS:r,sizeXS:n,sizeS:
|
|
1
|
+
'use strict';var React=require('react');var withMergedProps=require('../../hocs/withMergedProps.js');var dom=require('../../shared/utils/dom.js');var constants=require('./constants.js');var style=require('./style.js');var require$$0=require('react/jsx-runtime');const noop=()=>{};const MenuComponent=withMergedProps.withMergedProps(React.forwardRef(((e,s)=>{const{size:t="m",closeFn:o=noop,sizeXXS:r,sizeXS:n,sizeS:i,sizeM:c,sizeL:u,sizeXL:a,children:l,autoFocus:p,disableAutoFocus:d,showCloseButton:m,closeButtonProps:z,...S}=e;const R=React.useRef(null);React.useImperativeHandle(s,(()=>R.current),[]),React.useEffect((()=>{const e=setTimeout((()=>{!d&&R.current&&dom.focusFirstFocusable(R.current)}),0);return()=>{clearTimeout(e)}}),[p,d]);const f={size:t,sizeXXS:r,sizeXS:n,sizeS:i,sizeM:c,sizeL:u,sizeXL:a};const h={showCloseButton:m,closeButtonProps:z,closeFn:o};const M=React.isValidElement(l)&&typeof l.props=='object'&&l.props!==null?l.props:{};return require$$0.jsx(style.Root,{...S,...f,ref:R,children:React.isValidElement(l)?React.cloneElement(l,{...f,...h,...M}):typeof l=='function'?l({...f,...h}):void 0})})),{displayName:'MenuComponent',sizes:constants.SIZES});exports.SIZES=constants.SIZES,exports.MenuComponent=MenuComponent;
|
|
2
2
|
//# sourceMappingURL=MenuComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuComponent.js","sources":["../../../../src/components/MenuComponent/MenuComponent.tsx"],"sourcesContent":["import { forwardRef, useRef, useImperativeHandle, useEffect, isValidElement, cloneElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { focusFirstFocusable } from 'shared/utils/dom'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { MenuComponentProps } from './types'\n\nconst COMPONENT_NAME = 'MenuComponent'\n\nconst noop = () => undefined\n\n/**\n *\n * Component accepts all \\<div\\> attributes.\n *\n * Responsive \"size\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [MenuComponentProps](https://github.com/foxford/ui/blob/master/src/components/MenuComponent/types.ts)\n */\nconst MenuComponent: React.ForwardRefExoticComponent<MenuComponentProps> = withMergedProps<\n MenuComponentProps,\n HTMLDivElement\n>(\n forwardRef((props, forwardedRef) => {\n const {\n size = 'm',\n closeFn = noop,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n children,\n autoFocus,\n disableAutoFocus,\n showCloseButton,\n closeButtonProps,\n
|
|
1
|
+
{"version":3,"file":"MenuComponent.js","sources":["../../../../src/components/MenuComponent/MenuComponent.tsx"],"sourcesContent":["import { forwardRef, useRef, useImperativeHandle, useEffect, isValidElement, cloneElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { focusFirstFocusable } from 'shared/utils/dom'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { MenuComponentProps } from './types'\n\nconst COMPONENT_NAME = 'MenuComponent'\n\nconst noop = () => undefined\n\n/**\n *\n * Component accepts all \\<div\\> attributes.\n *\n * Responsive \"size\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [MenuComponentProps](https://github.com/foxford/ui/blob/master/src/components/MenuComponent/types.ts)\n */\nconst MenuComponent: React.ForwardRefExoticComponent<MenuComponentProps> = withMergedProps<\n MenuComponentProps,\n HTMLDivElement\n>(\n forwardRef((props, forwardedRef) => {\n const {\n size = 'm',\n closeFn = noop,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n children,\n autoFocus,\n disableAutoFocus,\n showCloseButton,\n closeButtonProps,\n ...restProps\n } = props\n\n const ref = useRef<HTMLDivElement>(null)\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current, [])\n\n useEffect(() => {\n const timerId = setTimeout(() => {\n if (!disableAutoFocus && ref.current) focusFirstFocusable(ref.current)\n }, 0)\n\n return () => {\n clearTimeout(timerId)\n }\n }, [autoFocus, disableAutoFocus])\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const forwardProps = {\n showCloseButton,\n closeButtonProps,\n closeFn,\n }\n\n const elementProps =\n isValidElement(children) && typeof children.props === 'object' && children.props !== null ? children.props : {}\n\n return (\n <Styled.Root {...restProps} {...sizeProps} ref={ref}>\n {isValidElement(children)\n ? cloneElement(children, { ...sizeProps, ...forwardProps, ...elementProps })\n : typeof children === 'function'\n ? children({ ...sizeProps, ...forwardProps })\n : undefined}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { MenuComponent }\n\nexport { SIZES }\n"],"names":["noop","MenuComponent","withMergedProps","forwardRef","props","forwardedRef","size","closeFn","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","children","autoFocus","disableAutoFocus","showCloseButton","closeButtonProps","restProps","ref","useRef","useImperativeHandle","current","useEffect","timerId","setTimeout","focusFirstFocusable","clearTimeout","sizeProps","forwardProps","elementProps","isValidElement","_jsx","Styled","cloneElement","undefined","displayName","sizes","SIZES"],"mappings":"sQASA,MAAMA,KAAOA,KAAe,EAYtBC,MAAAA,cAAqEC,gBAAAA,gBAIzEC,MAAAA,YAAW,CAACC,EAAOC,KACjB,MAAMC,KACJA,EAAO,IAAGC,QACVA,EAAUP,KAAIQ,QACdA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,SACNA,EAAQC,UACRA,EAASC,iBACTA,EAAgBC,gBAChBA,EAAeC,iBACfA,KACGC,GACDf,EAEJ,MAAMgB,EAAMC,aAAuB,MAEnCC,MAAAA,oBAAkEjB,GAAc,IAAMe,EAAIG,SAAS,IAEnGC,MAAAA,WAAU,KACR,MAAMC,EAAUC,YAAW,MACpBV,GAAoBI,EAAIG,SAASI,IAAAA,oBAAoBP,EAAIG,QAAQ,GACrE,GAEH,MAAO,KACLK,aAAaH,EAAQ,CACtB,GACA,CAACV,EAAWC,IAEf,MAAMa,EAAY,CAChBvB,OACAE,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAMiB,EAAe,CACnBb,kBACAC,mBACAX,WAGF,MAAMwB,EACJC,MAAcA,eAAClB,WAAoBA,EAASV,OAAU,UAAYU,EAASV,QAAU,KAAOU,EAASV,MAAQ,CAAA,EAE/G,OACE6B,WAAAA,IAACC,MAAAA,KAAW,IAAKf,KAAeU,EAAWT,IAAKA,EAAIN,SACjDkB,MAAAA,eAAelB,GACZqB,MAAAA,aAAarB,EAAU,IAAKe,KAAcC,KAAiBC,WACpDjB,GAAa,WACpBA,EAAS,IAAKe,KAAcC,SAC5BM,GACQ,IAGlB,CACEC,YAhFmB,gBAiFnBC,MAAOC,UAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{forwardRef,useRef,useImperativeHandle,useEffect,isValidElement,cloneElement}from'react';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{focusFirstFocusable}from'../../shared/utils/dom.mjs';import{SIZES}from'./constants.mjs';import{Root}from'./style.mjs';import{jsx}from'react/jsx-runtime';const noop=()=>{};const MenuComponent=withMergedProps(forwardRef(((e,o)=>{const{size:s="m",closeFn:t=noop,sizeXXS:
|
|
1
|
+
import{forwardRef,useRef,useImperativeHandle,useEffect,isValidElement,cloneElement}from'react';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{focusFirstFocusable}from'../../shared/utils/dom.mjs';import{SIZES}from'./constants.mjs';import{Root}from'./style.mjs';import{jsx}from'react/jsx-runtime';const noop=()=>{};const MenuComponent=withMergedProps(forwardRef(((e,o)=>{const{size:s="m",closeFn:t=noop,sizeXXS:r,sizeXS:n,sizeS:i,sizeM:c,sizeL:u,sizeXL:m,children:l,autoFocus:p,disableAutoFocus:f,showCloseButton:a,closeButtonProps:d,...z}=e;const S=useRef(null);useImperativeHandle(o,(()=>S.current),[]),useEffect((()=>{const e=setTimeout((()=>{!f&&S.current&&focusFirstFocusable(S.current)}),0);return()=>{clearTimeout(e)}}),[p,f]);const E={size:s,sizeXXS:r,sizeXS:n,sizeS:i,sizeM:c,sizeL:u,sizeXL:m};const h={showCloseButton:a,closeButtonProps:d,closeFn:t};const j=isValidElement(l)&&typeof l.props=='object'&&l.props!==null?l.props:{};return jsx(Root,{...z,...E,ref:S,children:isValidElement(l)?cloneElement(l,{...E,...h,...j}):typeof l=='function'?l({...E,...h}):void 0})})),{displayName:'MenuComponent',sizes:SIZES});export{MenuComponent,SIZES};
|
|
2
2
|
//# sourceMappingURL=MenuComponent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuComponent.mjs","sources":["../../../../src/components/MenuComponent/MenuComponent.tsx"],"sourcesContent":["import { forwardRef, useRef, useImperativeHandle, useEffect, isValidElement, cloneElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { focusFirstFocusable } from 'shared/utils/dom'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { MenuComponentProps } from './types'\n\nconst COMPONENT_NAME = 'MenuComponent'\n\nconst noop = () => undefined\n\n/**\n *\n * Component accepts all \\<div\\> attributes.\n *\n * Responsive \"size\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [MenuComponentProps](https://github.com/foxford/ui/blob/master/src/components/MenuComponent/types.ts)\n */\nconst MenuComponent: React.ForwardRefExoticComponent<MenuComponentProps> = withMergedProps<\n MenuComponentProps,\n HTMLDivElement\n>(\n forwardRef((props, forwardedRef) => {\n const {\n size = 'm',\n closeFn = noop,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n children,\n autoFocus,\n disableAutoFocus,\n showCloseButton,\n closeButtonProps,\n
|
|
1
|
+
{"version":3,"file":"MenuComponent.mjs","sources":["../../../../src/components/MenuComponent/MenuComponent.tsx"],"sourcesContent":["import { forwardRef, useRef, useImperativeHandle, useEffect, isValidElement, cloneElement } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { focusFirstFocusable } from 'shared/utils/dom'\nimport { SIZES } from './constants'\nimport * as Styled from './style'\nimport type { MenuComponentProps } from './types'\n\nconst COMPONENT_NAME = 'MenuComponent'\n\nconst noop = () => undefined\n\n/**\n *\n * Component accepts all \\<div\\> attributes.\n *\n * Responsive \"size\" props are supported.\n *\n * Exposed \"ref\" attached to root node.\n *\n * See full [MenuComponentProps](https://github.com/foxford/ui/blob/master/src/components/MenuComponent/types.ts)\n */\nconst MenuComponent: React.ForwardRefExoticComponent<MenuComponentProps> = withMergedProps<\n MenuComponentProps,\n HTMLDivElement\n>(\n forwardRef((props, forwardedRef) => {\n const {\n size = 'm',\n closeFn = noop,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n children,\n autoFocus,\n disableAutoFocus,\n showCloseButton,\n closeButtonProps,\n ...restProps\n } = props\n\n const ref = useRef<HTMLDivElement>(null)\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current, [])\n\n useEffect(() => {\n const timerId = setTimeout(() => {\n if (!disableAutoFocus && ref.current) focusFirstFocusable(ref.current)\n }, 0)\n\n return () => {\n clearTimeout(timerId)\n }\n }, [autoFocus, disableAutoFocus])\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const forwardProps = {\n showCloseButton,\n closeButtonProps,\n closeFn,\n }\n\n const elementProps =\n isValidElement(children) && typeof children.props === 'object' && children.props !== null ? children.props : {}\n\n return (\n <Styled.Root {...restProps} {...sizeProps} ref={ref}>\n {isValidElement(children)\n ? cloneElement(children, { ...sizeProps, ...forwardProps, ...elementProps })\n : typeof children === 'function'\n ? children({ ...sizeProps, ...forwardProps })\n : undefined}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n)\n\nexport { MenuComponent }\n\nexport { SIZES }\n"],"names":["noop","MenuComponent","withMergedProps","forwardRef","props","forwardedRef","size","closeFn","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","children","autoFocus","disableAutoFocus","showCloseButton","closeButtonProps","restProps","ref","useRef","useImperativeHandle","current","useEffect","timerId","setTimeout","focusFirstFocusable","clearTimeout","sizeProps","forwardProps","elementProps","isValidElement","_jsx","Styled","cloneElement","undefined","displayName","sizes","SIZES"],"mappings":"2TASA,MAAMA,KAAOA,KAAe,EAYtBC,MAAAA,cAAqEC,gBAIzEC,YAAW,CAACC,EAAOC,KACjB,MAAMC,KACJA,EAAO,IAAGC,QACVA,EAAUP,KAAIQ,QACdA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,SACNA,EAAQC,UACRA,EAASC,iBACTA,EAAgBC,gBAChBA,EAAeC,iBACfA,KACGC,GACDf,EAEJ,MAAMgB,EAAMC,OAAuB,MAEnCC,oBAAkEjB,GAAc,IAAMe,EAAIG,SAAS,IAEnGC,WAAU,KACR,MAAMC,EAAUC,YAAW,MACpBV,GAAoBI,EAAIG,SAASI,oBAAoBP,EAAIG,QAAQ,GACrE,GAEH,MAAO,KACLK,aAAaH,EAAQ,CACtB,GACA,CAACV,EAAWC,IAEf,MAAMa,EAAY,CAChBvB,OACAE,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAMiB,EAAe,CACnBb,kBACAC,mBACAX,WAGF,MAAMwB,EACJC,eAAelB,WAAoBA,EAASV,OAAU,UAAYU,EAASV,QAAU,KAAOU,EAASV,MAAQ,CAAA,EAE/G,OACE6B,IAACC,KAAW,IAAKf,KAAeU,EAAWT,IAAKA,EAAIN,SACjDkB,eAAelB,GACZqB,aAAarB,EAAU,IAAKe,KAAcC,KAAiBC,WACpDjB,GAAa,WACpBA,EAAS,IAAKe,KAAcC,SAC5BM,GACQ,IAGlB,CACEC,YAhFmB,gBAiFnBC,MAAOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paper.js","sources":["../../../../src/components/Paper/Paper.tsx"],"sourcesContent":["import { ResponsiveNamedProperty } from 'mixins/responsive-property'\nimport { ColorProperty } from 'mixins/color'\nimport { useClassname } from 'hooks/useClassname'\nimport { SpacerProps } from 'components/Spacer'\nimport * as Styled from './style'\n\nexport interface PaperProps extends SpacerProps, ColorProperty, ResponsiveNamedProperty<'padding'> {\n /**\n * Set to true to generate a circlular paper container\n */\n circle?: boolean\n /**\n * Paper with rounded corners\n */\n rounded?: boolean\n /**\n * Paper with shadow\n */\n shadow?: boolean\n /**\n * This number represents the zDepth of the paper shadow\n */\n zDepth?: false | 0 | 1 | 2 | 3 | 4\n /**\n * Text align\n */\n textAlign?: 'left' | 'center' | 'right'\n}\n\nPaper.displayName = 'Paper'\n\n/**\n * Расширен:\n * - [`SpacerProps`](
|
|
1
|
+
{"version":3,"file":"Paper.js","sources":["../../../../src/components/Paper/Paper.tsx"],"sourcesContent":["import { ResponsiveNamedProperty } from 'mixins/responsive-property'\nimport { ColorProperty } from 'mixins/color'\nimport { useClassname } from 'hooks/useClassname'\nimport { SpacerProps } from 'components/Spacer'\nimport * as Styled from './style'\n\nexport interface PaperProps extends SpacerProps, ColorProperty, ResponsiveNamedProperty<'padding'> {\n /**\n * Set to true to generate a circlular paper container\n */\n circle?: boolean\n /**\n * Paper with rounded corners\n */\n rounded?: boolean\n /**\n * Paper with shadow\n */\n shadow?: boolean\n /**\n * This number represents the zDepth of the paper shadow\n */\n zDepth?: false | 0 | 1 | 2 | 3 | 4\n /**\n * Text align\n */\n textAlign?: 'left' | 'center' | 'right'\n}\n\nPaper.displayName = 'Paper'\n\n/**\n * Расширен:\n * - [`SpacerProps`](#/Разметка/Spacer)\n * - [`Color`](#/Миксины)\n * - [`ResponsiveNamedProperty<'padding'>`](#/Миксины)\n */\nexport function Paper({ padding = 'm', rounded = true, shadow = true, className, ...props }: PaperProps) {\n const _className = useClassname(Paper.displayName, className)\n\n return <Styled.Root padding={padding} rounded={rounded} shadow={shadow} className={_className} {...props} />\n}\n"],"names":["Paper","padding","rounded","shadow","className","props","_className","useClassname","displayName","_jsx","Styled"],"mappings":"iJAqCO,SAASA,OAAMC,QAAEA,EAAU,IAAGC,QAAEA,GAAU,EAAIC,OAAEA,GAAS,EAAIC,UAAEA,KAAcC,IAClF,MAAMC,EAAaC,aAAYA,aAACP,MAAMQ,YAAaJ,GAEnD,OAAOK,WAAAA,IAACC,MAAAA,KAAW,CAACT,QAASA,EAASC,QAASA,EAASC,OAAQA,EAAQC,UAAWE,KAAgBD,GACrG,CAZAL,MAAMQ,YAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paper.mjs","sources":["../../../../src/components/Paper/Paper.tsx"],"sourcesContent":["import { ResponsiveNamedProperty } from 'mixins/responsive-property'\nimport { ColorProperty } from 'mixins/color'\nimport { useClassname } from 'hooks/useClassname'\nimport { SpacerProps } from 'components/Spacer'\nimport * as Styled from './style'\n\nexport interface PaperProps extends SpacerProps, ColorProperty, ResponsiveNamedProperty<'padding'> {\n /**\n * Set to true to generate a circlular paper container\n */\n circle?: boolean\n /**\n * Paper with rounded corners\n */\n rounded?: boolean\n /**\n * Paper with shadow\n */\n shadow?: boolean\n /**\n * This number represents the zDepth of the paper shadow\n */\n zDepth?: false | 0 | 1 | 2 | 3 | 4\n /**\n * Text align\n */\n textAlign?: 'left' | 'center' | 'right'\n}\n\nPaper.displayName = 'Paper'\n\n/**\n * Расширен:\n * - [`SpacerProps`](
|
|
1
|
+
{"version":3,"file":"Paper.mjs","sources":["../../../../src/components/Paper/Paper.tsx"],"sourcesContent":["import { ResponsiveNamedProperty } from 'mixins/responsive-property'\nimport { ColorProperty } from 'mixins/color'\nimport { useClassname } from 'hooks/useClassname'\nimport { SpacerProps } from 'components/Spacer'\nimport * as Styled from './style'\n\nexport interface PaperProps extends SpacerProps, ColorProperty, ResponsiveNamedProperty<'padding'> {\n /**\n * Set to true to generate a circlular paper container\n */\n circle?: boolean\n /**\n * Paper with rounded corners\n */\n rounded?: boolean\n /**\n * Paper with shadow\n */\n shadow?: boolean\n /**\n * This number represents the zDepth of the paper shadow\n */\n zDepth?: false | 0 | 1 | 2 | 3 | 4\n /**\n * Text align\n */\n textAlign?: 'left' | 'center' | 'right'\n}\n\nPaper.displayName = 'Paper'\n\n/**\n * Расширен:\n * - [`SpacerProps`](#/Разметка/Spacer)\n * - [`Color`](#/Миксины)\n * - [`ResponsiveNamedProperty<'padding'>`](#/Миксины)\n */\nexport function Paper({ padding = 'm', rounded = true, shadow = true, className, ...props }: PaperProps) {\n const _className = useClassname(Paper.displayName, className)\n\n return <Styled.Root padding={padding} rounded={rounded} shadow={shadow} className={_className} {...props} />\n}\n"],"names":["Paper","padding","rounded","shadow","className","props","_className","useClassname","displayName","_jsx","Styled"],"mappings":"wHAqCO,SAASA,OAAMC,QAAEA,EAAU,IAAGC,QAAEA,GAAU,EAAIC,OAAEA,GAAS,EAAIC,UAAEA,KAAcC,IAClF,MAAMC,EAAaC,aAAaP,MAAMQ,YAAaJ,GAEnD,OAAOK,IAACC,KAAW,CAACT,QAASA,EAASC,QAASA,EAASC,OAAQA,EAAQC,UAAWE,KAAgBD,GACrG,CAZAL,MAAMQ,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var React=require('react');var ResizeObserver=require('../../external/.pnpm/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.js');var useMergedPalette=require('../../hooks/useMergedPalette.js');var style=require('./style.js');var require$$0=require('react/jsx-runtime');const resizeHandlerSymbol=Symbol('resize-handler');const resizeObserver=new ResizeObserver.default((e=>{e.forEach((e=>{typeof e.target[resizeHandlerSymbol]=='function'&&e.target[resizeHandlerSymbol](e.target)}))}));exports.Ellipsis=e=>{const{lines:r=1,defaultExpanded:t=!1,expandable:
|
|
1
|
+
'use strict';var React=require('react');var ResizeObserver=require('../../external/.pnpm/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.js');var useMergedPalette=require('../../hooks/useMergedPalette.js');var style=require('./style.js');var require$$0=require('react/jsx-runtime');const resizeHandlerSymbol=Symbol('resize-handler');const resizeObserver=new ResizeObserver.default((e=>{e.forEach((e=>{typeof e.target[resizeHandlerSymbol]=='function'&&e.target[resizeHandlerSymbol](e.target)}))}));exports.Ellipsis=e=>{const{lines:r=1,defaultExpanded:t=!1,expandable:s=!1,expandButtonProps:n={},children:i,expanded:l,onExpandedChange:a}=e;const{captionExpanded:c="Свернуть",captionCollapsed:o="Развернуть",...u}=n;const d=React.useRef(null);const p=React.useRef(null);const f=React.useRef(-1);const h=useMergedPalette.useMergedPalette(u);const[b,v]=React.useState(null);const[g,x]=React.useState(l??t);const y=React.useCallback((e=>{cancelAnimationFrame(f.current),f.current=requestAnimationFrame((()=>{if(p.current)if(g){const t=Math.round(e.clientHeight/p.current.clientHeight);v(t>r)}else{const r=Math.round(e.scrollHeight/p.current.clientHeight);const t=Math.round(e.clientHeight/p.current.clientHeight);v(r>t)}}))}),[r,g]);return React.useLayoutEffect((()=>{const e=d.current;return s&&e&&(e[resizeHandlerSymbol]=y,resizeObserver.observe(e)),()=>{e&&resizeObserver.unobserve(e)}}),[s,y]),React.useLayoutEffect((()=>{l!==void 0&&(x(l),a&&a(l))}),[l,a]),require$$0.jsxs(require$$0.Fragment,{children:[require$$0.jsxs(style.TextEllipsis,{ref:d,lines:r,expanded:g,children:[s&&require$$0.jsx(style.LineHeight,{ref:p,children:" "}),i]}),s&&b===!0&&require$$0.jsx(style.ExpandButton,{...u,type:"button",palette:h,onClick:e=>{if(u.onClick&&u.onClick(e),l===void 0){const e=!g;x(e),a&&a(e)}},children:g?c:o})]})};
|
|
2
2
|
//# sourceMappingURL=Ellipsis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ellipsis.js","sources":["../../../../src/components/Text/Ellipsis.tsx"],"sourcesContent":["import { useState, useLayoutEffect, useRef, useCallback } from 'react'\nimport ResizeObserver from 'resize-observer-polyfill'\nimport { useMergedPalette } from 'hooks/useMergedPalette'\nimport type { Nullable } from 'shared/types'\nimport type { EllipsisProps, ExpandButtonProps } from './types'\nimport * as Styled from './style'\n\nconst resizeHandlerSymbol = Symbol('resize-handler')\n\nconst resizeObserver = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n if (typeof entry.target[resizeHandlerSymbol] === 'function') {\n entry.target[resizeHandlerSymbol](entry.target)\n }\n })\n})\n\nconst Ellipsis = (props: EllipsisProps) => {\n const {\n lines = 1,\n defaultExpanded = false,\n expandable = false,\n expandButtonProps = {} as ExpandButtonProps,\n children,\n expanded,\n onExpandedChange,\n } = props\n\n const { captionExpanded = 'Свернуть', captionCollapsed = 'Развернуть', ...restExpandButtonProps } = expandButtonProps\n\n const textRef = useRef<HTMLSpanElement>(null)\n const lineHeightRef = useRef<HTMLSpanElement>(null)\n const requestAnimationId = useRef<number>(-1)\n\n const expandButtonPalette = useMergedPalette(restExpandButtonProps)\n\n const [expandButtonVisible, setExpandButtonVisible] = useState<Nullable<boolean>>(null)\n const [textExpanded, setTextExpanded] = useState<boolean>(expanded ?? defaultExpanded)\n\n const handleExpandButtonVisibility = useCallback(\n (e: HTMLSpanElement) => {\n cancelAnimationFrame(requestAnimationId.current)\n requestAnimationId.current = requestAnimationFrame(() => {\n if (!lineHeightRef.current) return\n\n if (textExpanded) {\n const linesTotalCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > lines)\n } else {\n const linesTotalCount = Math.round(e.scrollHeight / lineHeightRef.current.clientHeight)\n const linesVisibleCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > linesVisibleCount)\n }\n })\n },\n [lines, textExpanded]\n )\n\n useLayoutEffect(() => {\n if (expandable &&
|
|
1
|
+
{"version":3,"file":"Ellipsis.js","sources":["../../../../src/components/Text/Ellipsis.tsx"],"sourcesContent":["import { useState, useLayoutEffect, useRef, useCallback } from 'react'\nimport ResizeObserver from 'resize-observer-polyfill'\nimport { useMergedPalette } from 'hooks/useMergedPalette'\nimport type { Nullable } from 'shared/types'\nimport type { EllipsisProps, ExpandButtonProps } from './types'\nimport * as Styled from './style'\n\nconst resizeHandlerSymbol = Symbol('resize-handler')\n\nconst resizeObserver = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n if (typeof entry.target[resizeHandlerSymbol] === 'function') {\n entry.target[resizeHandlerSymbol](entry.target)\n }\n })\n})\n\nconst Ellipsis = (props: EllipsisProps) => {\n const {\n lines = 1,\n defaultExpanded = false,\n expandable = false,\n expandButtonProps = {} as ExpandButtonProps,\n children,\n expanded,\n onExpandedChange,\n } = props\n\n const { captionExpanded = 'Свернуть', captionCollapsed = 'Развернуть', ...restExpandButtonProps } = expandButtonProps\n\n const textRef = useRef<HTMLSpanElement>(null)\n const lineHeightRef = useRef<HTMLSpanElement>(null)\n const requestAnimationId = useRef<number>(-1)\n\n const expandButtonPalette = useMergedPalette(restExpandButtonProps)\n\n const [expandButtonVisible, setExpandButtonVisible] = useState<Nullable<boolean>>(null)\n const [textExpanded, setTextExpanded] = useState<boolean>(expanded ?? defaultExpanded)\n\n const handleExpandButtonVisibility = useCallback(\n (e: HTMLSpanElement) => {\n cancelAnimationFrame(requestAnimationId.current)\n requestAnimationId.current = requestAnimationFrame(() => {\n if (!lineHeightRef.current) return\n\n if (textExpanded) {\n const linesTotalCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > lines)\n } else {\n const linesTotalCount = Math.round(e.scrollHeight / lineHeightRef.current.clientHeight)\n const linesVisibleCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > linesVisibleCount)\n }\n })\n },\n [lines, textExpanded]\n )\n\n useLayoutEffect(() => {\n const observerTarget = textRef.current\n\n if (expandable && observerTarget) {\n observerTarget[resizeHandlerSymbol] = handleExpandButtonVisibility\n resizeObserver.observe(observerTarget)\n }\n\n return () => {\n if (observerTarget) {\n resizeObserver.unobserve(observerTarget)\n }\n }\n }, [expandable, handleExpandButtonVisibility])\n\n useLayoutEffect(() => {\n if (expanded !== undefined) {\n setTextExpanded(expanded)\n if (onExpandedChange) onExpandedChange(expanded)\n }\n }, [expanded, onExpandedChange])\n\n return (\n <>\n <Styled.TextEllipsis ref={textRef} lines={lines} expanded={textExpanded}>\n {expandable && <Styled.LineHeight ref={lineHeightRef}> </Styled.LineHeight>}\n {children}\n </Styled.TextEllipsis>\n {expandable && expandButtonVisible === true && (\n <Styled.ExpandButton\n {...restExpandButtonProps}\n type='button'\n palette={expandButtonPalette}\n onClick={(evt) => {\n if (restExpandButtonProps.onClick) restExpandButtonProps.onClick(evt)\n\n if (expanded === undefined) {\n const update = !textExpanded\n\n setTextExpanded(update)\n if (onExpandedChange) onExpandedChange(update)\n }\n }}\n >\n {textExpanded ? captionExpanded : captionCollapsed}\n </Styled.ExpandButton>\n )}\n </>\n )\n}\n\nexport { Ellipsis }\n"],"names":["resizeHandlerSymbol","Symbol","resizeObserver","ResizeObserver","default","entries","forEach","entry","target","props","lines","defaultExpanded","expandable","expandButtonProps","children","expanded","onExpandedChange","captionExpanded","captionCollapsed","restExpandButtonProps","textRef","useRef","lineHeightRef","requestAnimationId","expandButtonPalette","useMergedPalette","expandButtonVisible","setExpandButtonVisible","useState","textExpanded","setTextExpanded","handleExpandButtonVisibility","useCallback","e","cancelAnimationFrame","current","requestAnimationFrame","linesTotalCount","Math","round","clientHeight","scrollHeight","linesVisibleCount","useLayoutEffect","observerTarget","observe","unobserve","undefined","_jsxs","_Fragment","jsxs","Styled","ref","_jsx","jsx","type","palette","onClick","evt","update"],"mappings":"mUAOA,MAAMA,oBAAsBC,OAAO,kBAEnC,MAAMC,eAAiB,IAAIC,eAAcC,SAAEC,IACzCA,EAAQC,SAASC,WACJA,EAAMC,OAAOR,sBAAyB,YAC/CO,EAAMC,OAAOR,qBAAqBO,EAAMC,OAC1C,GACA,qBAGcC,IAChB,MAAMC,MACJA,EAAQ,EAACC,gBACTA,GAAkB,EAAKC,WACvBA,GAAa,EAAKC,kBAClBA,EAAoB,CAAuB,EAAAC,SAC3CA,EAAQC,SACRA,EAAQC,iBACRA,GACEP,EAEJ,MAAMQ,gBAAEA,EAAkB,WAAUC,iBAAEA,EAAmB,gBAAiBC,GAA0BN,EAEpG,MAAMO,EAAUC,aAAwB,MACxC,MAAMC,EAAgBD,aAAwB,MAC9C,MAAME,EAAqBF,MAAAA,QAAgB,GAE3C,MAAMG,EAAsBC,kCAAiBN,GAE7C,MAAOO,EAAqBC,GAA0BC,MAAQA,SAAoB,MAClF,MAAOC,EAAcC,GAAmBF,MAAAA,SAAkBb,GAAYJ,GAEtE,MAAMoB,EAA+BC,MAAWA,aAC7CC,IACCC,qBAAqBX,EAAmBY,SACxCZ,EAAmBY,QAAUC,uBAAsB,KACjD,GAAKd,EAAca,QAEnB,GAAIN,EAAc,CAChB,MAAMQ,EAAkBC,KAAKC,MAAMN,EAAEO,aAAelB,EAAca,QAAQK,cAE1Eb,EAAuBU,EAAkB3B,EAC3C,KAAO,CACL,MAAM2B,EAAkBC,KAAKC,MAAMN,EAAEQ,aAAenB,EAAca,QAAQK,cAC1E,MAAME,EAAoBJ,KAAKC,MAAMN,EAAEO,aAAelB,EAAca,QAAQK,cAE5Eb,EAAuBU,EAAkBK,EAC3C,IACA,GAEJ,CAAChC,EAAOmB,IAyBV,OAtBAc,MAAAA,iBAAgB,KACd,MAAMC,EAAiBxB,EAAQe,QAO/B,OALIvB,GAAcgC,IAChBA,EAAe5C,qBAAuB+B,EACtC7B,eAAe2C,QAAQD,IAGlB,KACDA,GACF1C,eAAe4C,UAAUF,EAC3B,CACD,GACA,CAAChC,EAAYmB,IAEhBY,MAAAA,iBAAgB,KACV5B,SAAagC,IACfjB,EAAgBf,GACZC,GAAkBA,EAAiBD,GACzC,GACC,CAACA,EAAUC,IAGZgC,WAAAA,KAAAC,WAAAA,SAAA,CAAAnC,SACEkC,CAAAA,WAAAE,KAACC,mBAAmB,CAACC,IAAKhC,EAASV,MAAOA,EAAOK,SAAUc,EAAaf,UACrEF,GAAcyC,WAAAC,IAACH,iBAAiB,CAACC,IAAK9B,EAAcR,SAAC,MACrDA,KAEFF,GAAcc,KAAwB,GACrC2B,WAAAA,IAACF,MAAAA,aAAmB,IACdhC,EACJoC,KAAK,SACLC,QAAShC,EACTiC,QAAUC,IAGR,GAFIvC,EAAsBsC,SAAStC,EAAsBsC,QAAQC,GAE7D3C,SAAagC,EAAW,CAC1B,MAAMY,GAAU9B,EAEhBC,EAAgB6B,GACZ3C,GAAkBA,EAAiB2C,EACzC,GACA7C,SAEDe,EAAeZ,EAAkBC,MAGrC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useRef,useState,useCallback,useLayoutEffect}from'react';import ResizeObserver from'../../external/.pnpm/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.mjs';import{useMergedPalette}from'../../hooks/useMergedPalette.mjs';import{TextEllipsis,LineHeight,ExpandButton}from'./style.mjs';import{jsxs,Fragment,jsx}from'react/jsx-runtime';const resizeHandlerSymbol=Symbol('resize-handler');const resizeObserver=new ResizeObserver((e=>{e.forEach((e=>{typeof e.target[resizeHandlerSymbol]=='function'&&e.target[resizeHandlerSymbol](e.target)}))}));const Ellipsis=e=>{const{lines:t=1,defaultExpanded:r=!1,expandable:
|
|
1
|
+
import{useRef,useState,useCallback,useLayoutEffect}from'react';import ResizeObserver from'../../external/.pnpm/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.mjs';import{useMergedPalette}from'../../hooks/useMergedPalette.mjs';import{TextEllipsis,LineHeight,ExpandButton}from'./style.mjs';import{jsxs,Fragment,jsx}from'react/jsx-runtime';const resizeHandlerSymbol=Symbol('resize-handler');const resizeObserver=new ResizeObserver((e=>{e.forEach((e=>{typeof e.target[resizeHandlerSymbol]=='function'&&e.target[resizeHandlerSymbol](e.target)}))}));const Ellipsis=e=>{const{lines:t=1,defaultExpanded:r=!1,expandable:s=!1,expandButtonProps:n={},children:o,expanded:i,onExpandedChange:l}=e;const{captionExpanded:a="Свернуть",captionCollapsed:c="Развернуть",...u}=n;const d=useRef(null);const p=useRef(null);const m=useRef(-1);const f=useMergedPalette(u);const[h,x]=useState(null);const[b,g]=useState(i??r);const y=useCallback((e=>{cancelAnimationFrame(m.current),m.current=requestAnimationFrame((()=>{if(p.current)if(b){const r=Math.round(e.clientHeight/p.current.clientHeight);x(r>t)}else{const t=Math.round(e.scrollHeight/p.current.clientHeight);const r=Math.round(e.clientHeight/p.current.clientHeight);x(t>r)}}))}),[t,b]);return useLayoutEffect((()=>{const e=d.current;return s&&e&&(e[resizeHandlerSymbol]=y,resizeObserver.observe(e)),()=>{e&&resizeObserver.unobserve(e)}}),[s,y]),useLayoutEffect((()=>{i!==void 0&&(g(i),l&&l(i))}),[i,l]),jsxs(Fragment,{children:[jsxs(TextEllipsis,{ref:d,lines:t,expanded:b,children:[s&&jsx(LineHeight,{ref:p,children:" "}),o]}),s&&h===!0&&jsx(ExpandButton,{...u,type:"button",palette:f,onClick:e=>{if(u.onClick&&u.onClick(e),i===void 0){const e=!b;g(e),l&&l(e)}},children:b?a:c})]})};export{Ellipsis};
|
|
2
2
|
//# sourceMappingURL=Ellipsis.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ellipsis.mjs","sources":["../../../../src/components/Text/Ellipsis.tsx"],"sourcesContent":["import { useState, useLayoutEffect, useRef, useCallback } from 'react'\nimport ResizeObserver from 'resize-observer-polyfill'\nimport { useMergedPalette } from 'hooks/useMergedPalette'\nimport type { Nullable } from 'shared/types'\nimport type { EllipsisProps, ExpandButtonProps } from './types'\nimport * as Styled from './style'\n\nconst resizeHandlerSymbol = Symbol('resize-handler')\n\nconst resizeObserver = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n if (typeof entry.target[resizeHandlerSymbol] === 'function') {\n entry.target[resizeHandlerSymbol](entry.target)\n }\n })\n})\n\nconst Ellipsis = (props: EllipsisProps) => {\n const {\n lines = 1,\n defaultExpanded = false,\n expandable = false,\n expandButtonProps = {} as ExpandButtonProps,\n children,\n expanded,\n onExpandedChange,\n } = props\n\n const { captionExpanded = 'Свернуть', captionCollapsed = 'Развернуть', ...restExpandButtonProps } = expandButtonProps\n\n const textRef = useRef<HTMLSpanElement>(null)\n const lineHeightRef = useRef<HTMLSpanElement>(null)\n const requestAnimationId = useRef<number>(-1)\n\n const expandButtonPalette = useMergedPalette(restExpandButtonProps)\n\n const [expandButtonVisible, setExpandButtonVisible] = useState<Nullable<boolean>>(null)\n const [textExpanded, setTextExpanded] = useState<boolean>(expanded ?? defaultExpanded)\n\n const handleExpandButtonVisibility = useCallback(\n (e: HTMLSpanElement) => {\n cancelAnimationFrame(requestAnimationId.current)\n requestAnimationId.current = requestAnimationFrame(() => {\n if (!lineHeightRef.current) return\n\n if (textExpanded) {\n const linesTotalCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > lines)\n } else {\n const linesTotalCount = Math.round(e.scrollHeight / lineHeightRef.current.clientHeight)\n const linesVisibleCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > linesVisibleCount)\n }\n })\n },\n [lines, textExpanded]\n )\n\n useLayoutEffect(() => {\n if (expandable &&
|
|
1
|
+
{"version":3,"file":"Ellipsis.mjs","sources":["../../../../src/components/Text/Ellipsis.tsx"],"sourcesContent":["import { useState, useLayoutEffect, useRef, useCallback } from 'react'\nimport ResizeObserver from 'resize-observer-polyfill'\nimport { useMergedPalette } from 'hooks/useMergedPalette'\nimport type { Nullable } from 'shared/types'\nimport type { EllipsisProps, ExpandButtonProps } from './types'\nimport * as Styled from './style'\n\nconst resizeHandlerSymbol = Symbol('resize-handler')\n\nconst resizeObserver = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n if (typeof entry.target[resizeHandlerSymbol] === 'function') {\n entry.target[resizeHandlerSymbol](entry.target)\n }\n })\n})\n\nconst Ellipsis = (props: EllipsisProps) => {\n const {\n lines = 1,\n defaultExpanded = false,\n expandable = false,\n expandButtonProps = {} as ExpandButtonProps,\n children,\n expanded,\n onExpandedChange,\n } = props\n\n const { captionExpanded = 'Свернуть', captionCollapsed = 'Развернуть', ...restExpandButtonProps } = expandButtonProps\n\n const textRef = useRef<HTMLSpanElement>(null)\n const lineHeightRef = useRef<HTMLSpanElement>(null)\n const requestAnimationId = useRef<number>(-1)\n\n const expandButtonPalette = useMergedPalette(restExpandButtonProps)\n\n const [expandButtonVisible, setExpandButtonVisible] = useState<Nullable<boolean>>(null)\n const [textExpanded, setTextExpanded] = useState<boolean>(expanded ?? defaultExpanded)\n\n const handleExpandButtonVisibility = useCallback(\n (e: HTMLSpanElement) => {\n cancelAnimationFrame(requestAnimationId.current)\n requestAnimationId.current = requestAnimationFrame(() => {\n if (!lineHeightRef.current) return\n\n if (textExpanded) {\n const linesTotalCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > lines)\n } else {\n const linesTotalCount = Math.round(e.scrollHeight / lineHeightRef.current.clientHeight)\n const linesVisibleCount = Math.round(e.clientHeight / lineHeightRef.current.clientHeight)\n\n setExpandButtonVisible(linesTotalCount > linesVisibleCount)\n }\n })\n },\n [lines, textExpanded]\n )\n\n useLayoutEffect(() => {\n const observerTarget = textRef.current\n\n if (expandable && observerTarget) {\n observerTarget[resizeHandlerSymbol] = handleExpandButtonVisibility\n resizeObserver.observe(observerTarget)\n }\n\n return () => {\n if (observerTarget) {\n resizeObserver.unobserve(observerTarget)\n }\n }\n }, [expandable, handleExpandButtonVisibility])\n\n useLayoutEffect(() => {\n if (expanded !== undefined) {\n setTextExpanded(expanded)\n if (onExpandedChange) onExpandedChange(expanded)\n }\n }, [expanded, onExpandedChange])\n\n return (\n <>\n <Styled.TextEllipsis ref={textRef} lines={lines} expanded={textExpanded}>\n {expandable && <Styled.LineHeight ref={lineHeightRef}> </Styled.LineHeight>}\n {children}\n </Styled.TextEllipsis>\n {expandable && expandButtonVisible === true && (\n <Styled.ExpandButton\n {...restExpandButtonProps}\n type='button'\n palette={expandButtonPalette}\n onClick={(evt) => {\n if (restExpandButtonProps.onClick) restExpandButtonProps.onClick(evt)\n\n if (expanded === undefined) {\n const update = !textExpanded\n\n setTextExpanded(update)\n if (onExpandedChange) onExpandedChange(update)\n }\n }}\n >\n {textExpanded ? captionExpanded : captionCollapsed}\n </Styled.ExpandButton>\n )}\n </>\n )\n}\n\nexport { Ellipsis }\n"],"names":["resizeHandlerSymbol","Symbol","resizeObserver","ResizeObserver","entries","forEach","entry","target","Ellipsis","props","lines","defaultExpanded","expandable","expandButtonProps","children","expanded","onExpandedChange","captionExpanded","captionCollapsed","restExpandButtonProps","textRef","useRef","lineHeightRef","requestAnimationId","expandButtonPalette","useMergedPalette","expandButtonVisible","setExpandButtonVisible","useState","textExpanded","setTextExpanded","handleExpandButtonVisibility","useCallback","e","cancelAnimationFrame","current","requestAnimationFrame","linesTotalCount","Math","round","clientHeight","scrollHeight","linesVisibleCount","useLayoutEffect","observerTarget","observe","unobserve","undefined","_jsxs","_Fragment","Styled","ref","_jsx","type","palette","onClick","ev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CAAChC,EAAYmB,IAEhBY,iBAAgB,KACV5B,SAAagC,IACfjB,EAAgBf,GACZC,GAAkBA,EAAiBD,GACzC,GACC,CAACA,EAAUC,IAGZgC,KAAAC,SAAA,CAAAnC,SACEkC,CAAAA,KAACE,aAAmB,CAACC,IAAK/B,EAASV,MAAOA,EAAOK,SAAUc,EAAaf,UACrEF,GAAcwC,IAACF,WAAiB,CAACC,IAAK7B,EAAcR,SAAC,MACrDA,KAEFF,GAAcc,KAAwB,GACrC0B,IAACF,aAAmB,IACd/B,EACJkC,KAAK,SACLC,QAAS9B,EACT+B,QAAUC,IAGR,GAFIrC,EAAsBoC,SAASpC,EAAsBoC,QAAQC,GAE7DzC,SAAagC,EAAW,CAC1B,MAAMU,GAAU5B,EAEhBC,EAAgB2B,GACZzC,GAAkBA,EAAiByC,EACzC,GACA3C,SAEDe,EAAeZ,EAAkBC,MAGrC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var React=require('react');var styled=require('styled-components');var
|
|
1
|
+
'use strict';var React=require('react');var styled=require('styled-components');var index_browser=require('../../external/.pnpm/nanoid@5.0.7/node_modules/nanoid/index.browser.js');var withMergedProps=require('../../hocs/withMergedProps.js');var useResizable=require('../../hooks/useResizable.js');var misc=require('../../shared/utils/misc.js');var constants=require('./constants.js');var style=require('./style.js');var require$$0=require('react/jsx-runtime');var FormInputLabel=require('../FormInputLabel/FormInputLabel.js');var index=require('../../external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/ResizeHandle/index.js');const Textarea=withMergedProps.withMergedProps(React.forwardRef(((e,r)=>{const t=styled.useTheme();const{size:a="m",rows:i=2,maxRows:n=30,autoRows:o=!1,labelPosition:s="dynamic",inline:l=!1,primary:c=!0,secondary:m=!1,contrast:d=!1,success:g=!1,error:u=!1,width:h=t.defaultInputControlsWidth,autosize:p=!0,rounded:X=!0,color:b="mineShaft",placeholderColor:L="silver",resize:S,sizeXXS:f,sizeXS:R,sizeS:w,sizeM:z,sizeL:v,sizeXL:x,sizes:M,sizeUnits:T,margin:C,marginXXS:y,marginXS:$,marginS:q,marginM:j,marginL:B,marginXL:I,marginTop:k,marginTopXXS:D,marginTopXS:F,marginTopS:_,marginTopM:N,marginTopL:E,marginTopXL:H,marginRight:P,marginRightXXS:A,marginRightXS:O,marginRightS:U,marginRightM:W,marginRightL:Z,marginRightXL:G,marginBottom:K,marginBottomXXS:V,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:te,marginLeftXXS:ae,marginLeftXS:ie,marginLeftS:ne,marginLeftM:oe,marginLeftL:se,marginLeftXL:le,widthXXS:ce,widthXS:me,widthS:de,widthM:ge,widthL:ue,widthXL:he,preset:pe,palette:Xe,label:be,fluid:Le,className:Se,style:fe,disabled:Re,...we}=e;const ze=React.useRef(null);const ve=React.useRef(null);const xe=React.useRef(null);React.useImperativeHandle(r,(()=>ze.current),[]);const[Me,Te,Ce]=useResizable.useResizable({target:xe,direction:S});const ye=React.useMemo((()=>index_browser.nanoid()),[]);const[$e,qe]=React.useState((()=>{const e=we.value??we.defaultValue;return typeof e=='string'&&e.length>0}));const[je,Be]=React.useState((()=>Math.min(i,n)));const Ie=pe==='brand'&&o||pe!=='brand'&&p?je:Math.min(i,n);const ke=S==='horizontal'?'ew-resize':S==='vertical'?'ns-resize':'nwse-resize';const De=React.useCallback((()=>{if(!ze.current)return;if(pe==='brand'){if(!ve.current)return;ve.current.value=ze.current.value;const e=Math.max(Math.round(ve.current.scrollHeight/ve.current.clientHeight),i);return void Be(Math.min(e,n))}const e=getComputedStyle(ze.current);const r=parseFloat(e.lineHeight);const t=Math.max(Math.round((ze.current.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom))/(Number.isNaN(r)?parseFloat(e.fontSize)*1.2:r)),i);Be((e=>t>e?Math.min(t,n):ze.current&&!ze.current.value?i:e))}),[pe,i,n]);return React.useLayoutEffect((()=>{pe==='brand'&&typeof we.value=='string'&&ze.current&&ze.current!==document.activeElement&&qe(we.value.length>0)}),[pe,we.value]),React.useEffect((()=>{const e=misc.createThrottledCallback(De,200);return(pe==='brand'&&o||pe!=='brand'&&p)&&(De(),window.addEventListener('resize',e)),()=>{window.removeEventListener('resize',e)}}),[pe,o,p,De]),pe!=='brand'?require$$0.jsx(style.Root,{...we,ref:ze,className:Se,style:fe,onChange:e=>{p&&De(),we.onChange&&we.onChange(e)},rows:Ie,color:b,rounded:X,placeholderColor:L,disabled:Re,error:u,fluid:Le,width:h,widthXXS:ce,widthXS:me,widthS:de,widthM:ge,widthL:ue,widthXL:he}):require$$0.jsx(FormInputLabel.FormInputLabel,{ref:xe,size:a,sizeXXS:f,sizeXS:R,sizeS:w,sizeM:z,sizeL:v,sizeXL:x,sizes:M,sizeUnits:T,margin:C,marginXXS:y,marginXS:$,marginS:q,marginM:j,marginL:B,marginXL:I,marginTop:k,marginTopXXS:D,marginTopXS:F,marginTopS:_,marginTopM:N,marginTopL:E,marginTopXL:H,marginRight:P,marginRightXXS:A,marginRightXS:O,marginRightS:U,marginRightM:W,marginRightL:Z,marginRightXL:G,marginBottom:K,marginBottomXXS:V,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:te,marginLeftXXS:ae,marginLeftXS:ie,marginLeftS:ne,marginLeftM:oe,marginLeftL:se,marginLeftXL:le,className:Se,style:fe,contrast:d,error:u,inline:l,label:be,labelId:ye,labelPosition:s,disabled:Re,active:$e,primary:c,secondary:m,success:g,palette:{color:Re?Xe.colorDisabled:Xe.color,backgroundColor:Re?Xe.backgroundColorDisabled:Xe.backgroundColor,backgroundColorHover:Re?Xe.backgroundColorDisabled:Xe.backgroundColorHover,borderColor:Re?Xe.borderColorDisabled:Xe.borderColor},onClick:()=>{ze.current&&ze.current.focus()},onFocus:()=>{qe(!0)},onPointerDown:e=>{e.target!==ze.current&&e.target instanceof Node&&e.preventDefault()},onBlur:e=>{ze.current&&!e.currentTarget.contains(e.relatedTarget)&&qe(Boolean(ze.current.value))},overflow:"hidden",inputPosition:"stretch",input:require$$0.jsxs(require$$0.Fragment,{children:[o&&require$$0.jsx(style.TextareaMimic,{ref:ve,rows:1}),require$$0.jsx(style.Textarea,{...we,ref:ze,"aria-labelledby":be?ye:void 0,disabled:Re,onChange:e=>{o&&De(),we.onChange&&we.onChange(e)},rows:Ie,palette:{color:Xe.color,colorDisabled:Xe.colorDisabled,placeholderColor:Xe.placeholderColor,placeholderColorDisabled:Xe.placeholderColorDisabled}})]}),addon:S?require$$0.jsxs(require$$0.Fragment,{children:[Me&&require$$0.jsx(style.ResizeGlobals,{cursor:ke}),require$$0.jsx(style.ResizeIcon,{size:"l",icon:require$$0.jsx(index.ResizeHandle,{}),color:"border-onmain-default-small",tabIndex:0,onPointerDown:Te,onKeyDown:Ce,cursor:ke})]}):void 0})})),{displayName:"Textarea",sizes:e=>e.label?constants.SIZES_WITH_LABEL:constants.SIZES});exports.COMPONENT_NAME="Textarea",exports.Textarea=Textarea;
|
|
2
2
|
//# sourceMappingURL=Textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\nimport { useTheme } from 'styled-components'\nimport { omit } from 'ramda'\nimport { useConfigPriority } from 'hooks/use-config-priority'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\nconst Textarea = (props: TextareaProps) => {\n const theme = useTheme()\n\n const {\n preset,\n disabled,\n error,\n fluid,\n name,\n onChange,\n maxLength,\n placeholder,\n required,\n tabIndex,\n value,\n className,\n style,\n autosize = true,\n rounded = true,\n cols = 20,\n rows = 2,\n maxRows = 30,\n color = 'mineShaft',\n placeholderColor = 'silver',\n width = theme.defaultInputControlsWidth,\n ...configProps\n } = useConfigPriority<TextareaProps>(theme.components?.[COMPONENT_NAME], omit(['children'], props))\n\n const textarea = useRef() as React.MutableRefObject<HTMLTextAreaElement>\n\n const [tRows, setRows] = useState(rows)\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n const { target } = event\n\n if (target instanceof HTMLTextAreaElement && autosize) {\n const rect = target.getBoundingClientRect()\n\n if (target.scrollHeight > rect.height && tRows < maxRows) {\n setRows(tRows + 1)\n } else if (!target.value || target.value === '') {\n setRows(rows)\n }\n }\n\n if (typeof onChange === 'function') {\n onChange(event)\n }\n },\n [onChange, tRows, maxRows, autosize]\n )\n\n useEffect(() => {\n if (!textarea || !textarea.current) return\n\n const el = textarea.current\n const rect = el.getBoundingClientRect()\n if (el.scrollHeight > rect.height) {\n const lh = parseInt(getComputedStyle(el).lineHeight, 10)\n const numberOfLines = Math.floor(el.scrollHeight / lh)\n if (numberOfLines <= maxRows && numberOfLines > rows) {\n setRows(numberOfLines)\n }\n }\n }, [])\n\n let brandPresetUsed = theme.preset === 'brand'\n if (typeof preset === 'string') brandPresetUsed = preset === 'brand'\n\n return (\n <Styled.Root\n {...configProps}\n ref={textarea}\n className={className}\n style={style}\n onChange={onChangeHandler}\n cols={cols}\n disabled={disabled}\n maxLength={maxLength}\n name={name}\n placeholder={placeholder}\n required={required}\n rows={tRows}\n tabIndex={tabIndex}\n value={value}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n fluid={fluid}\n error={error}\n width={width}\n brandPresetUsed={brandPresetUsed}\n />\n )\n}\n\nTextarea.displayName = COMPONENT_NAME\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["Textarea","props","theme","useTheme","preset","disabled","error","fluid","name","onChange","maxLength","placeholder","required","tabIndex","value","className","style","autosize","rounded","cols","rows","maxRows","color","placeholderColor","width","defaultInputControlsWidth","configProps","useConfigPriority","components","omit","textarea","useRef","tRows","setRows","useState","onChangeHandler","useCallback","event","target","HTMLTextAreaElement","rect","getBoundingClientRect","scrollHeight","height","useEffect","current","el","lh","parseInt","getComputedStyle","lineHeight","numberOfLines","Math","floor","brandPresetUsed","_jsx","Styled","ref","displayName"],"mappings":"2PASMA,MAAAA,SAAYC,IAChB,MAAMC,EAAQC,OAAAA,WAEd,MAAMC,OACJA,EAAMC,SACNA,EAAQC,MACRA,EAAKC,MACLA,EAAKC,KACLA,EAAIC,SACJA,EAAQC,UACRA,EAASC,YACTA,EAAWC,SACXA,EAAQC,SACRA,EAAQC,MACRA,EAAKC,UACLA,QACAC,EAAKC,SACLA,GAAW,EAAIC,QACfA,GAAU,EAAIC,KACdA,EAAO,GAAEC,KACTA,EAAO,EAACC,QACRA,EAAU,GAAEC,MACZA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,MAC3BA,EAAQtB,EAAMuB,6BACXC,GACDC,kBAAiBA,kBAAgBzB,EAAM0B,YAA2B,SAAGC,MAAIA,KAAC,CAAC,YAAa5B,IAE5F,MAAM6B,EAAWC,MAAAA,SAEjB,MAAOC,EAAOC,GAAWC,MAAQA,SAACd,GAElC,MAAMe,EAAkBC,MAAWA,aAChCC,IACC,MAAMC,OAAEA,GAAWD,EAEnB,GAAIC,aAAkBC,qBAAuBtB,EAAU,CACrD,MAAMuB,EAAOF,EAAOG,wBAEhBH,EAAOI,aAAeF,EAAKG,QAAUX,EAAQX,EAC/CY,EAAQD,EAAQ,GACNM,EAAOxB,OAASwB,EAAOxB,QAAU,IAC3CmB,EAAQb,EAEZ,QAEWX,GAAa,YACtBA,EAAS4B,EACX,GAEF,CAAC5B,EAAUuB,EAAOX,EAASJ,IAG7B2B,MAAAA,WAAU,KACR,IAAKd,IAAaA,EAASe,QAAS,OAEpC,MAAMC,EAAKhB,EAASe,QACpB,MAAML,EAAOM,EAAGL,wBAChB,GAAIK,EAAGJ,aAAeF,EAAKG,OAAQ,CACjC,MAAMI,EAAKC,SAASC,iBAAiBH,GAAII,WAAY,IACrD,MAAMC,EAAgBC,KAAKC,MAAMP,EAAGJ,aAAeK,GAC/CI,GAAiB9B,GAAW8B,EAAgB/B,GAC9Ca,EAAQkB,EAEZ,IACC,IAEH,IAAIG,EAAkBpD,EAAME,SAAW,QAGvC,cAFWA,GAAW,WAAUkD,EAAkBlD,IAAW,SAG3DmD,WAAAA,IAACC,MAAAA,KAAW,IACN9B,EACJ+B,IAAK3B,EACLf,UAAWA,EACXC,MAAOA,EACPP,SAAU0B,EACVhB,KAAMA,EACNd,SAAUA,EACVK,UAAWA,EACXF,KAAMA,EACNG,YAAaA,EACbC,SAAUA,EACVQ,KAAMY,EACNnB,SAAUA,EACVC,MAAOA,EACPQ,MAAOA,EACPJ,QAASA,EACTK,iBAAkBA,EAClBhB,MAAOA,EACPD,MAAOA,EACPkB,MAAOA,EACP8B,gBAAiBA,GACjB,EAINtD,SAAS0D,YAnGc,kCAAA"}
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n} from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { ResizeHandle } from '@foxford/icon-pack'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { useResizable } from 'hooks/useResizable'\nimport { createThrottledCallback } from 'shared/utils/misc'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { SIZES, SIZES_WITH_LABEL } from './constants'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<textarea\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<textarea\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Textarea/types.ts).\n */\nconst Textarea: React.ForwardRefExoticComponent<TextareaProps> = withMergedProps<TextareaProps, HTMLTextAreaElement>(\n forwardRef((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rows = 2,\n maxRows = 30,\n autoRows = false,\n labelPosition = 'dynamic',\n inline = false,\n primary = true,\n secondary = false,\n contrast = false,\n success = false,\n error = false,\n width = theme.defaultInputControlsWidth,\n autosize = true,\n rounded = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n resize,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\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 widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n preset,\n palette,\n label,\n fluid,\n className,\n style,\n disabled,\n ...textareaProps\n } = props\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n\n const textareaMimicRef = useRef<HTMLTextAreaElement>(null)\n\n const formInputLabelRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(forwardedRef, () => textareaRef.current as HTMLTextAreaElement, [])\n\n const [resizing, handleResizeStart, handleResizeOnNudge] = useResizable<HTMLDivElement, HTMLSpanElement>({\n target: formInputLabelRef,\n direction: resize,\n })\n\n const labelId = useMemo(() => nanoid(), [])\n\n const [active, setActive] = useState(() => {\n const valueInit = textareaProps.value ?? textareaProps.defaultValue\n\n return typeof valueInit === 'string' && valueInit.length > 0\n })\n\n const [autoRowsCount, setAutoRowsCount] = useState(() => Math.min(rows, maxRows))\n\n const rowsVisible =\n (preset === 'brand' && autoRows) || (preset !== 'brand' && autosize) ? autoRowsCount : Math.min(rows, maxRows)\n\n const cursorResize = resize === 'horizontal' ? 'ew-resize' : resize === 'vertical' ? 'ns-resize' : 'nwse-resize'\n\n const updateAutoRowsCount = useCallback(() => {\n if (!textareaRef.current) return\n\n if (preset === 'brand') {\n if (!textareaMimicRef.current) return\n\n textareaMimicRef.current.value = textareaRef.current.value\n\n const nextRows = Math.max(\n Math.round(textareaMimicRef.current.scrollHeight / textareaMimicRef.current.clientHeight),\n rows\n )\n\n setAutoRowsCount(Math.min(nextRows, maxRows))\n\n return\n }\n\n const styles = getComputedStyle(textareaRef.current)\n\n const lineHeight = parseFloat(styles.lineHeight)\n\n const nextRows = Math.max(\n Math.round(\n (textareaRef.current.scrollHeight - parseFloat(styles.paddingTop) - parseFloat(styles.paddingBottom)) /\n (Number.isNaN(lineHeight) ? parseFloat(styles.fontSize) * 1.2 : lineHeight)\n ),\n rows\n )\n\n setAutoRowsCount((prevRows) => {\n if (nextRows > prevRows) return Math.min(nextRows, maxRows)\n if (textareaRef.current && !textareaRef.current.value) return rows\n\n return prevRows\n })\n }, [preset, rows, maxRows])\n\n useLayoutEffect(() => {\n if (\n preset === 'brand' &&\n typeof textareaProps.value === 'string' &&\n textareaRef.current &&\n textareaRef.current !== document.activeElement\n ) {\n setActive(textareaProps.value.length > 0)\n }\n }, [preset, textareaProps.value])\n\n useEffect(() => {\n const handleResize = createThrottledCallback<UIEvent>(updateAutoRowsCount, 200)\n\n if ((preset === 'brand' && autoRows) || (preset !== 'brand' && autosize)) {\n updateAutoRowsCount()\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [preset, autoRows, autosize, updateAutoRowsCount])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...textareaProps}\n ref={textareaRef}\n className={className}\n style={style}\n onChange={(evt) => {\n if (autosize) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n disabled={disabled}\n error={error}\n fluid={fluid}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n />\n )\n }\n\n return (\n <FormInputLabel\n ref={formInputLabelRef}\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 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 className={className}\n style={style}\n contrast={contrast}\n error={error}\n inline={inline}\n label={label}\n labelId={labelId}\n labelPosition={labelPosition}\n disabled={disabled}\n active={active}\n primary={primary}\n secondary={secondary}\n success={success}\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 onClick={() => {\n if (textareaRef.current) {\n textareaRef.current.focus()\n }\n }}\n onFocus={() => {\n setActive(true)\n }}\n onPointerDown={(evt) => {\n if (evt.target === textareaRef.current || !(evt.target instanceof Node)) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (textareaRef.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setActive(Boolean(textareaRef.current.value))\n }\n }}\n overflow='hidden'\n inputPosition='stretch'\n input={\n <>\n {autoRows && <Styled.TextareaMimic ref={textareaMimicRef} rows={1} />}\n <Styled.Textarea\n {...textareaProps}\n ref={textareaRef}\n aria-labelledby={label ? labelId : undefined}\n disabled={disabled}\n onChange={(evt) => {\n if (autoRows) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n />\n </>\n }\n addon={\n resize ? (\n <>\n {resizing && <Styled.ResizeGlobals cursor={cursorResize} />}\n <Styled.ResizeIcon\n size='l'\n icon={<ResizeHandle />}\n color='border-onmain-default-small'\n tabIndex={0}\n onPointerDown={handleResizeStart}\n onKeyDown={handleResizeOnNudge}\n cursor={cursorResize}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => (props.label ? SIZES_WITH_LABEL : SIZES),\n }\n)\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["Textarea","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rows","maxRows","autoRows","labelPosition","inline","primary","secondary","contrast","success","error","width","defaultInputControlsWidth","autosize","rounded","color","placeholderColor","resize","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","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","widthXXS","widthXS","widthS","widthM","widthL","widthXL","preset","palette","label","fluid","className","style","disabled","textareaProps","textareaRef","useRef","textareaMimicRef","formInputLabelRef","useImperativeHandle","current","resizing","handleResizeStart","handleResizeOnNudge","useResizable","target","direction","labelId","useMemo","nanoid","active","setActive","useState","valueInit","value","defaultValue","length","autoRowsCount","setAutoRowsCount","Math","min","rowsVisible","cursorResize","updateAutoRowsCount","useCallback","nextRows","max","round","scrollHeight","clientHeight","styles","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","Number","isNaN","fontSize","prevRows","useLayoutEffect","document","activeElement","useEffect","handleResize","createThrottledCallback","window","addEventListener","removeEventListener","_jsx","Styled","ref","onChange","evt","FormInputLabel","colorDisabled","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","focus","onFocus","onPointerDown","Node","preventDefault","onBlur","currentTarget","contains","relatedTarget","Boolean","overflow","inputPosition","input","_jsxs","jsxs","_Fragment","children","jsx","undefined","placeholderColorDisabled","addon","cursor","icon","ResizeHandle","tabIndex","onKeyDown","displayName","SIZES_WITH_LABEL","SIZES"],"mappings":"0rBAiCMA,MAAAA,SAA2DC,gBAAAA,gBAC/DC,MAAAA,YAAW,CAACC,EAAOC,KACjB,MAAMC,EAAQC,OAAAA,WAEd,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,EAACC,QACRA,EAAU,GAAEC,SACZA,GAAW,EAAKC,cAChBA,EAAgB,UAASC,OACzBA,GAAS,EAAKC,QACdA,GAAU,EAAIC,UACdA,GAAY,EAAKC,SACjBA,GAAW,EAAKC,QAChB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AC,UACG7E,IAAYgD,WAAA8B,IAAC7B,oBAAoB,CAACiC,OAAQ7D,KAC3C2B,WAAA8B,IAAC7B,iBAAiB,CAChBlI,KAAK,IACLoK,KAAMnC,WAAAA,IAACoC,MAAYA,iBACnBtJ,MAAM,8BACNuJ,SAAU,EACVtB,cAAe9D,GACfqF,UAAWpF,GACXgF,OAAQ7D,aAGV0D,GAEN,IAGN,CACEQ,YArVmB,WAsVnBhJ,MAAQ5B,GAAWA,EAAMyE,MAAQoG,UAAgBA,iBAAGC,UAAAA,+BAtVjC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useRef,useState,useCallback,useEffect}from'react';import{useTheme}from'styled-components';import{
|
|
1
|
+
import{forwardRef,useRef,useImperativeHandle,useMemo,useState,useCallback,useLayoutEffect,useEffect}from'react';import{useTheme}from'styled-components';import{nanoid}from'../../external/.pnpm/nanoid@5.0.7/node_modules/nanoid/index.browser.mjs';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useResizable}from'../../hooks/useResizable.mjs';import{createThrottledCallback}from'../../shared/utils/misc.mjs';import{SIZES_WITH_LABEL,SIZES}from'./constants.mjs';import{Root,TextareaMimic,Textarea as Textarea$1,ResizeGlobals,ResizeIcon}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{FormInputLabel}from'../FormInputLabel/FormInputLabel.mjs';import{ResizeHandle as ResizeHandle_2}from'../../external/.pnpm/@foxford_icon-pack@0.10.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@foxford/icon-pack/icons/ResizeHandle/index.mjs';const COMPONENT_NAME='Textarea';const Textarea=withMergedProps(forwardRef(((e,r)=>{const o=useTheme();const{size:t="m",rows:a=2,maxRows:n=30,autoRows:i=!1,labelPosition:s="dynamic",inline:m=!1,primary:l=!0,secondary:d=!1,contrast:c=!1,success:g=!1,error:u=!1,width:h=o.defaultInputControlsWidth,autosize:p=!0,rounded:f=!0,color:S="mineShaft",placeholderColor:X="silver",resize:L,sizeXXS:b,sizeXS:z,sizeS:w,sizeM:R,sizeL:T,sizeXL:M,sizes:x,sizeUnits:C,margin:v,marginXXS:j,marginXS:B,marginS:y,marginM:E,marginL:I,marginXL:_,marginTop:k,marginTopXXS:H,marginTopXS:N,marginTopS:D,marginTopM:F,marginTopL:P,marginTopXL:A,marginRight:O,marginRightXXS:Z,marginRightXS:W,marginRightS:G,marginRightM:U,marginRightL:$,marginRightXL:K,marginBottom:V,marginBottomXXS:q,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:oe,marginLeftXXS:te,marginLeftXS:ae,marginLeftS:ne,marginLeftM:ie,marginLeftL:se,marginLeftXL:me,widthXXS:le,widthXS:de,widthS:ce,widthM:ge,widthL:ue,widthXL:he,preset:pe,palette:fe,label:Se,fluid:Xe,className:Le,style:be,disabled:ze,...we}=e;const Re=useRef(null);const Te=useRef(null);const Me=useRef(null);useImperativeHandle(r,(()=>Re.current),[]);const[xe,Ce,ve]=useResizable({target:Me,direction:L});const je=useMemo((()=>nanoid()),[]);const[Be,ye]=useState((()=>{const e=we.value??we.defaultValue;return typeof e=='string'&&e.length>0}));const[Ee,Ie]=useState((()=>Math.min(a,n)));const _e=pe==='brand'&&i||pe!=='brand'&&p?Ee:Math.min(a,n);const ke=L==='horizontal'?'ew-resize':L==='vertical'?'ns-resize':'nwse-resize';const He=useCallback((()=>{if(!Re.current)return;if(pe==='brand'){if(!Te.current)return;Te.current.value=Re.current.value;const e=Math.max(Math.round(Te.current.scrollHeight/Te.current.clientHeight),a);return void Ie(Math.min(e,n))}const e=getComputedStyle(Re.current);const r=parseFloat(e.lineHeight);const o=Math.max(Math.round((Re.current.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom))/(Number.isNaN(r)?parseFloat(e.fontSize)*1.2:r)),a);Ie((e=>o>e?Math.min(o,n):Re.current&&!Re.current.value?a:e))}),[pe,a,n]);return useLayoutEffect((()=>{pe==='brand'&&typeof we.value=='string'&&Re.current&&Re.current!==document.activeElement&&ye(we.value.length>0)}),[pe,we.value]),useEffect((()=>{const e=createThrottledCallback(He,200);return(pe==='brand'&&i||pe!=='brand'&&p)&&(He(),window.addEventListener('resize',e)),()=>{window.removeEventListener('resize',e)}}),[pe,i,p,He]),pe!=='brand'?jsx(Root,{...we,ref:Re,className:Le,style:be,onChange:e=>{p&&He(),we.onChange&&we.onChange(e)},rows:_e,color:S,rounded:f,placeholderColor:X,disabled:ze,error:u,fluid:Xe,width:h,widthXXS:le,widthXS:de,widthS:ce,widthM:ge,widthL:ue,widthXL:he}):jsx(FormInputLabel,{ref:Me,size:t,sizeXXS:b,sizeXS:z,sizeS:w,sizeM:R,sizeL:T,sizeXL:M,sizes:x,sizeUnits:C,margin:v,marginXXS:j,marginXS:B,marginS:y,marginM:E,marginL:I,marginXL:_,marginTop:k,marginTopXXS:H,marginTopXS:N,marginTopS:D,marginTopM:F,marginTopL:P,marginTopXL:A,marginRight:O,marginRightXXS:Z,marginRightXS:W,marginRightS:G,marginRightM:U,marginRightL:$,marginRightXL:K,marginBottom:V,marginBottomXXS:q,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:oe,marginLeftXXS:te,marginLeftXS:ae,marginLeftS:ne,marginLeftM:ie,marginLeftL:se,marginLeftXL:me,className:Le,style:be,contrast:c,error:u,inline:m,label:Se,labelId:je,labelPosition:s,disabled:ze,active:Be,primary:l,secondary:d,success:g,palette:{color:ze?fe.colorDisabled:fe.color,backgroundColor:ze?fe.backgroundColorDisabled:fe.backgroundColor,backgroundColorHover:ze?fe.backgroundColorDisabled:fe.backgroundColorHover,borderColor:ze?fe.borderColorDisabled:fe.borderColor},onClick:()=>{Re.current&&Re.current.focus()},onFocus:()=>{ye(!0)},onPointerDown:e=>{e.target!==Re.current&&e.target instanceof Node&&e.preventDefault()},onBlur:e=>{Re.current&&!e.currentTarget.contains(e.relatedTarget)&&ye(Boolean(Re.current.value))},overflow:"hidden",inputPosition:"stretch",input:jsxs(Fragment,{children:[i&&jsx(TextareaMimic,{ref:Te,rows:1}),jsx(Textarea$1,{...we,ref:Re,"aria-labelledby":Se?je:void 0,disabled:ze,onChange:e=>{i&&He(),we.onChange&&we.onChange(e)},rows:_e,palette:{color:fe.color,colorDisabled:fe.colorDisabled,placeholderColor:fe.placeholderColor,placeholderColorDisabled:fe.placeholderColorDisabled}})]}),addon:L?jsxs(Fragment,{children:[xe&&jsx(ResizeGlobals,{cursor:ke}),jsx(ResizeIcon,{size:"l",icon:jsx(ResizeHandle_2,{}),color:"border-onmain-default-small",tabIndex:0,onPointerDown:Ce,onKeyDown:ve,cursor:ke})]}):void 0})})),{displayName:"Textarea",sizes:e=>e.label?SIZES_WITH_LABEL:SIZES});export{COMPONENT_NAME,Textarea};
|
|
2
2
|
//# sourceMappingURL=Textarea.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.mjs","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\nimport { useTheme } from 'styled-components'\nimport { omit } from 'ramda'\nimport { useConfigPriority } from 'hooks/use-config-priority'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\nconst Textarea = (props: TextareaProps) => {\n const theme = useTheme()\n\n const {\n preset,\n disabled,\n error,\n fluid,\n name,\n onChange,\n maxLength,\n placeholder,\n required,\n tabIndex,\n value,\n className,\n style,\n autosize = true,\n rounded = true,\n cols = 20,\n rows = 2,\n maxRows = 30,\n color = 'mineShaft',\n placeholderColor = 'silver',\n width = theme.defaultInputControlsWidth,\n ...configProps\n } = useConfigPriority<TextareaProps>(theme.components?.[COMPONENT_NAME], omit(['children'], props))\n\n const textarea = useRef() as React.MutableRefObject<HTMLTextAreaElement>\n\n const [tRows, setRows] = useState(rows)\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n const { target } = event\n\n if (target instanceof HTMLTextAreaElement && autosize) {\n const rect = target.getBoundingClientRect()\n\n if (target.scrollHeight > rect.height && tRows < maxRows) {\n setRows(tRows + 1)\n } else if (!target.value || target.value === '') {\n setRows(rows)\n }\n }\n\n if (typeof onChange === 'function') {\n onChange(event)\n }\n },\n [onChange, tRows, maxRows, autosize]\n )\n\n useEffect(() => {\n if (!textarea || !textarea.current) return\n\n const el = textarea.current\n const rect = el.getBoundingClientRect()\n if (el.scrollHeight > rect.height) {\n const lh = parseInt(getComputedStyle(el).lineHeight, 10)\n const numberOfLines = Math.floor(el.scrollHeight / lh)\n if (numberOfLines <= maxRows && numberOfLines > rows) {\n setRows(numberOfLines)\n }\n }\n }, [])\n\n let brandPresetUsed = theme.preset === 'brand'\n if (typeof preset === 'string') brandPresetUsed = preset === 'brand'\n\n return (\n <Styled.Root\n {...configProps}\n ref={textarea}\n className={className}\n style={style}\n onChange={onChangeHandler}\n cols={cols}\n disabled={disabled}\n maxLength={maxLength}\n name={name}\n placeholder={placeholder}\n required={required}\n rows={tRows}\n tabIndex={tabIndex}\n value={value}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n fluid={fluid}\n error={error}\n width={width}\n brandPresetUsed={brandPresetUsed}\n />\n )\n}\n\nTextarea.displayName = COMPONENT_NAME\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Textarea","props","theme","useTheme","preset","disabled","error","fluid","name","onChange","maxLength","placeholder","required","tabIndex","value","className","style","autosize","rounded","cols","rows","maxRows","color","placeholderColor","width","defaultInputControlsWidth","configProps","useConfigPriority","components","omit","textarea","useRef","tRows","setRows","useState","onChangeHandler","useCallback","event","target","HTMLTextAreaElement","rect","getBoundingClientRect","scrollHeight","height","useEffect","current","el","lh","parseInt","getComputedStyle","lineHeight","numberOfLines","Math","floor","brandPresetUsed","_jsx","Styled","ref","displayName"],"mappings":"6PAOMA,MAAAA,eAAiB,WAEjBC,MAAAA,SA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W,IACN9B,EACJ+B,IAAK3B,EACLf,UAAWA,EACXC,MAAOA,EACPP,SAAU0B,EACVhB,KAAMA,EACNd,SAAUA,EACVK,UAAWA,EACXF,KAAMA,EACNG,YAAaA,EACbC,SAAUA,EACVQ,KAAMY,EACNnB,SAAUA,EACVC,MAAOA,EACPQ,MAAOA,EACPJ,QAASA,EACTK,iBAAkBA,EAClBhB,MAAOA,EACPD,MAAOA,EACPkB,MAAOA,EACP8B,gBAAiBA,GACjB,EAINtD,SAAS0D,YAnGc"}
|
|
1
|
+
{"version":3,"file":"Textarea.mjs","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n} from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { ResizeHandle } from '@foxford/icon-pack'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { useResizable } from 'hooks/useResizable'\nimport { createThrottledCallback } from 'shared/utils/misc'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { SIZES, SIZES_WITH_LABEL } from './constants'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<textarea\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<textarea\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Textarea/types.ts).\n */\nconst Textarea: React.ForwardRefExoticComponent<TextareaProps> = withMergedProps<TextareaProps, HTMLTextAreaElement>(\n forwardRef((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rows = 2,\n maxRows = 30,\n autoRows = false,\n labelPosition = 'dynamic',\n inline = false,\n primary = true,\n secondary = false,\n contrast = false,\n success = false,\n error = false,\n width = theme.defaultInputControlsWidth,\n autosize = true,\n rounded = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n resize,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\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 widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n preset,\n palette,\n label,\n fluid,\n className,\n style,\n disabled,\n ...textareaProps\n } = props\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n\n const textareaMimicRef = useRef<HTMLTextAreaElement>(null)\n\n const formInputLabelRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(forwardedRef, () => textareaRef.current as HTMLTextAreaElement, [])\n\n const [resizing, handleResizeStart, handleResizeOnNudge] = useResizable<HTMLDivElement, HTMLSpanElement>({\n target: formInputLabelRef,\n direction: resize,\n })\n\n const labelId = useMemo(() => nanoid(), [])\n\n const [active, setActive] = useState(() => {\n const valueInit = textareaProps.value ?? textareaProps.defaultValue\n\n return typeof valueInit === 'string' && valueInit.length > 0\n })\n\n const [autoRowsCount, setAutoRowsCount] = useState(() => Math.min(rows, maxRows))\n\n const rowsVisible =\n (preset === 'brand' && autoRows) || (preset !== 'brand' && autosize) ? autoRowsCount : Math.min(rows, maxRows)\n\n const cursorResize = resize === 'horizontal' ? 'ew-resize' : resize === 'vertical' ? 'ns-resize' : 'nwse-resize'\n\n const updateAutoRowsCount = useCallback(() => {\n if (!textareaRef.current) return\n\n if (preset === 'brand') {\n if (!textareaMimicRef.current) return\n\n textareaMimicRef.current.value = textareaRef.current.value\n\n const nextRows = Math.max(\n Math.round(textareaMimicRef.current.scrollHeight / textareaMimicRef.current.clientHeight),\n rows\n )\n\n setAutoRowsCount(Math.min(nextRows, maxRows))\n\n return\n }\n\n const styles = getComputedStyle(textareaRef.current)\n\n const lineHeight = parseFloat(styles.lineHeight)\n\n const nextRows = Math.max(\n Math.round(\n (textareaRef.current.scrollHeight - parseFloat(styles.paddingTop) - parseFloat(styles.paddingBottom)) /\n (Number.isNaN(lineHeight) ? parseFloat(styles.fontSize) * 1.2 : lineHeight)\n ),\n rows\n )\n\n setAutoRowsCount((prevRows) => {\n if (nextRows > prevRows) return Math.min(nextRows, maxRows)\n if (textareaRef.current && !textareaRef.current.value) return rows\n\n return prevRows\n })\n }, [preset, rows, maxRows])\n\n useLayoutEffect(() => {\n if (\n preset === 'brand' &&\n typeof textareaProps.value === 'string' &&\n textareaRef.current &&\n textareaRef.current !== document.activeElement\n ) {\n setActive(textareaProps.value.length > 0)\n }\n }, [preset, textareaProps.value])\n\n useEffect(() => {\n const handleResize = createThrottledCallback<UIEvent>(updateAutoRowsCount, 200)\n\n if ((preset === 'brand' && autoRows) || (preset !== 'brand' && autosize)) {\n updateAutoRowsCount()\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [preset, autoRows, autosize, updateAutoRowsCount])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...textareaProps}\n ref={textareaRef}\n className={className}\n style={style}\n onChange={(evt) => {\n if (autosize) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n disabled={disabled}\n error={error}\n fluid={fluid}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n />\n )\n }\n\n return (\n <FormInputLabel\n ref={formInputLabelRef}\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 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 className={className}\n style={style}\n contrast={contrast}\n error={error}\n inline={inline}\n label={label}\n labelId={labelId}\n labelPosition={labelPosition}\n disabled={disabled}\n active={active}\n primary={primary}\n secondary={secondary}\n success={success}\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 onClick={() => {\n if (textareaRef.current) {\n textareaRef.current.focus()\n }\n }}\n onFocus={() => {\n setActive(true)\n }}\n onPointerDown={(evt) => {\n if (evt.target === textareaRef.current || !(evt.target instanceof Node)) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (textareaRef.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setActive(Boolean(textareaRef.current.value))\n }\n }}\n overflow='hidden'\n inputPosition='stretch'\n input={\n <>\n {autoRows && <Styled.TextareaMimic ref={textareaMimicRef} rows={1} />}\n <Styled.Textarea\n {...textareaProps}\n ref={textareaRef}\n aria-labelledby={label ? labelId : undefined}\n disabled={disabled}\n onChange={(evt) => {\n if (autoRows) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n />\n </>\n }\n addon={\n resize ? (\n <>\n {resizing && <Styled.ResizeGlobals cursor={cursorResize} />}\n <Styled.ResizeIcon\n size='l'\n icon={<ResizeHandle />}\n color='border-onmain-default-small'\n tabIndex={0}\n onPointerDown={handleResizeStart}\n onKeyDown={handleResizeOnNudge}\n cursor={cursorResize}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => (props.label ? SIZES_WITH_LABEL : SIZES),\n }\n)\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Textarea","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rows","maxRows","autoRows","labelPosition","inline","primary","secondary","contrast","success","error","width","defaultInputControlsWidth","autosize","rounded","color","placeholderColor","resize","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","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","widthXXS","widthXS","widthS","widthM","widthL","widthXL","preset","palette","label","fluid","className","style","disabled","textareaProps","textareaRef","useRef","textareaMimicRef","formInputLabelRef","useImperativeHandle","current","resizing","handleResizeStart","handleResizeOnNudge","useResizable","target","direction","labelId","useMemo","nanoid","active","setActive","useState","valueInit","value","defaultValue","length","autoRowsCount","setAutoRowsCount","Math","min","rowsVisible","cursorResize","updateAutoRowsCount","useCallback","nextRows","max","round","scrollHeight","clientHeight","styles","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","Number","isNaN","fontSize","prevRows","useLayoutEffect","document","activeElement","useEffect","handleResize","createThrottledCallback","window","addEventListener","removeEventListener","_jsx","Styled","ref","onChange","evt","FormInputLabel","colorDisabled","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","focus","onFocus","onPointerDown","Node","preventDefault","onBlur","currentTarget","contains","relatedTarget","Boolean","overflow","inputPosition","input","_jsxs","_Fragment","children","undefined","placeholderColorDisabled","addon","cursor","icon","ResizeHandle","tabIndex","onKeyDown","displayName","SIZES_WITH_LABEL","SIZES"],"mappings":"82BAqBMA,MAAAA,eAAiB,WAYjBC,MAAAA,SAA2DC,gBAC/DC,YAAW,CAACC,EAAOC,KACjB,MAAMC,EAAQC,WAEd,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,EAACC,QACRA,EAAU,GAAEC,SACZA,GAAW,EAAKC,cAChBA,EAAgB,UAASC,OACzBA,GAAS,EAAKC,QACdA,GAAU,EAAIC,UACdA,GAAY,EAAKC,SACjBA,GAAW,EAAKC,QAChBA,GAAU,EAAKC,MACfA,GAAQ,EAAKC,MACbA,EAAQb,EAAMc,0BAAyBC,SACvCA,GAAW,EAAIC,QACfA,GAAU,EAAIC,MACdA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,OAC3BA,EAAMC,QACNA,EAAOC,OACPA,EA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strict';const SIZES={l:{fontSize:18,paddingTop:14,paddingRight:16,paddingBottom:14,paddingLeft:16,minHeight:'auto',borderRadius:12},m:{fontSize:16,paddingTop:12,paddingRight:16,paddingBottom:12,paddingLeft:16,minHeight:'auto',borderRadius:10},s:{fontSize:14,paddingTop:10,paddingRight:14,paddingBottom:10,paddingLeft:14,minHeight:'auto',borderRadius:8}};const SIZES_WITH_LABEL={l:{...SIZES.l,paddingTop:5},m:{...SIZES.m,paddingTop:4},s:{...SIZES.s,paddingTop:2}};exports.SIZES=SIZES,exports.SIZES_WITH_LABEL=SIZES_WITH_LABEL;
|
|
2
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/Textarea/constants.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\nimport type { TextareaSize } from './types'\n\nexport const SIZES: Record<TextareaSize, CSSProperties> = {\n l: {\n fontSize: 18,\n paddingTop: 14,\n paddingRight: 16,\n paddingBottom: 14,\n paddingLeft: 16,\n minHeight: 'auto',\n borderRadius: 12,\n },\n m: {\n fontSize: 16,\n paddingTop: 12,\n paddingRight: 16,\n paddingBottom: 12,\n paddingLeft: 16,\n minHeight: 'auto',\n borderRadius: 10,\n },\n s: {\n fontSize: 14,\n paddingTop: 10,\n paddingRight: 14,\n paddingBottom: 10,\n paddingLeft: 14,\n minHeight: 'auto',\n borderRadius: 8,\n },\n}\n\nexport const SIZES_WITH_LABEL: Record<TextareaSize, CSSProperties> = {\n l: {\n ...SIZES.l,\n paddingTop: 5,\n },\n m: {\n ...SIZES.m,\n paddingTop: 4,\n },\n s: {\n ...SIZES.s,\n paddingTop: 2,\n },\n}\n"],"names":["SIZES","l","fontSize","paddingTop","paddingRight","paddingBottom","paddingLeft","minHeight","borderRadius","m","s","SIZES_WITH_LABEL"],"mappings":"aAGO,MAAMA,MAA6C,CACxDC,EAAG,CACDC,SAAU,GACVC,WAAY,GACZC,aAAc,GACdC,cAAe,GACfC,YAAa,GACbC,UAAW,OACXC,aAAc,IAEhBC,EAAG,CACDP,SAAU,GACVC,WAAY,GACZC,aAAc,GACdC,cAAe,GACfC,YAAa,GACbC,UAAW,OACXC,aAAc,IAEhBE,EAAG,CACDR,SAAU,GACVC,WAAY,GACZC,aAAc,GACdC,cAAe,GACfC,YAAa,GACbC,UAAW,OACXC,aAAc,IAIX,MAAMG,iBAAwD,CACnEV,EAAG,IACED,MAAMC,EACTE,WAAY,GAEdM,EAAG,IACET,MAAMS,EACTN,WAAY,GAEdO,EAAG,IACEV,MAAMU,EACTP,WAAY"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const SIZES={l:{fontSize:18,paddingTop:14,paddingRight:16,paddingBottom:14,paddingLeft:16,minHeight:'auto',borderRadius:12},m:{fontSize:16,paddingTop:12,paddingRight:16,paddingBottom:12,paddingLeft:16,minHeight:'auto',borderRadius:10},s:{fontSize:14,paddingTop:10,paddingRight:14,paddingBottom:10,paddingLeft:14,minHeight:'auto',borderRadius:8}};const SIZES_WITH_LABEL={l:{...SIZES.l,paddingTop:5},m:{...SIZES.m,paddingTop:4},s:{...SIZES.s,paddingTop:2}};export{SIZES,SIZES_WITH_LABEL};
|
|
2
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../../src/components/Textarea/constants.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\nimport type { TextareaSize } from './types'\n\nexport const SIZES: Record<TextareaSize, CSSProperties> = {\n l: {\n fontSize: 18,\n paddingTop: 14,\n paddingRight: 16,\n paddingBottom: 14,\n paddingLeft: 16,\n minHeight: 'auto',\n borderRadius: 12,\n },\n m: {\n fontSize: 16,\n paddingTop: 12,\n paddingRight: 16,\n paddingBottom: 12,\n paddingLeft: 16,\n minHeight: 'auto',\n borderRadius: 10,\n },\n s: {\n fontSize: 14,\n paddingTop: 10,\n paddingRight: 14,\n paddingBottom: 10,\n paddingLeft: 14,\n minHeight: 'auto',\n borderRadius: 8,\n },\n}\n\nexport const SIZES_WITH_LABEL: Record<TextareaSize, CSSProperties> = {\n l: {\n ...SIZES.l,\n paddingTop: 5,\n },\n m: {\n ...SIZES.m,\n paddingTop: 4,\n },\n s: {\n ...SIZES.s,\n paddingTop: 2,\n },\n}\n"],"names":["SIZES","l","fontSize","paddingTop","paddingRight","paddingBottom","paddingLeft","minHeight","borderRadius","m","s","SIZES_WITH_LABEL"],"mappings":"AAGO,MAAMA,MAA6C,CACxDC,EAAG,CACDC,SAAU,GACVC,WAAY,GACZC,aAAc,GACdC,cAAe,GACfC,YAAa,GACbC,UAAW,OACXC,aAAc,IAEhBC,EAAG,CACDP,SAAU,GACVC,WAAY,GACZC,aAAc,GACdC,cAAe,GACfC,YAAa,GACbC,UAAW,OACXC,aAAc,IAEhBE,EAAG,CACDR,SAAU,GACVC,WAAY,GACZC,aAAc,GACdC,cAAe,GACfC,YAAa,GACbC,UAAW,OACXC,aAAc,IAIX,MAAMG,iBAAwD,CACnEV,EAAG,IACED,MAAMC,EACTE,WAAY,GAEdM,EAAG,IACET,MAAMS,EACTN,WAAY,GAEdO,EAAG,IACEV,MAAMU,EACTP,WAAY"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var styled=require('styled-components');var
|
|
1
|
+
'use strict';var styled=require('styled-components');var style=require('../Input/style.js');var Icon=require('../Icon/Icon.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var styled__default=_interopDefault(styled);const Root=styled__default.default.textarea.withConfig({shouldForwardProp:e=>!['color','placeholderColor','rounded','fluid','error'].includes(e)&&!e.includes('width')}).withConfig({displayName:"Textarea__Root",componentId:"ui__sc-a4hfy5-0"})(["resize:none;line-height:23px;padding:16px 20px 11px;",""],style.baseInputStyle);const Textarea=styled__default.default.textarea.withConfig({shouldForwardProp:e=>!['palette'].includes(e)}).withConfig({displayName:"Textarea",componentId:"ui__sc-a4hfy5-1"})(["box-sizing:border-box;display:block;appearance:none;resize:none;overflow:auto;border:none;padding:0;margin:0;background-color:transparent;font-family:inherit;font-size:inherit;line-height:inherit;width:100%;cursor:pointer;&[aria-labelledby]{margin-top:0.2em;}&:disabled{cursor:not-allowed;}&:focus{outline:none;}&:focus:read-write{cursor:text;}",""],(e=>{return`\n color: ${(o={color:e.palette.color??e.theme.colors['content-onmain-primary'],placeholderColor:e.palette.placeholderColor??e.theme.colors['content-onmain-secondary'],colorDisabled:e.palette.colorDisabled??e.theme.colors['content-disabled'],placeholderColorDisabled:e.palette.placeholderColorDisabled??e.theme.colors['content-disabled']}).color};\n &:disabled {\n color: ${o.colorDisabled};\n }\n &::placeholder {\n color: ${o.placeholderColor};\n }\n &:disabled::placeholder {\n color: ${o.placeholderColorDisabled};\n }\n`;var o}));const TextareaMimic=styled__default.default.textarea.withConfig({displayName:"Textarea__TextareaMimic",componentId:"ui__sc-a4hfy5-2"})(["box-sizing:border-box;display:block;visibility:hidden;position:absolute;top:0;left:0;width:100%;appearance:none;resize:none;overflow:hidden;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;line-height:inherit;"]);const ResizeGlobals=styled.createGlobalStyle(["",""],(e=>`\n body * {\n cursor: ${e.cursor} !important;\n user-select: none !important;\n }\n `));const ResizeIcon=styled__default.default(Icon.Icon).withConfig({shouldForwardProp:e=>e!=='cursor'}).withConfig({displayName:"Textarea__ResizeIcon",componentId:"ui__sc-a4hfy5-3"})(["",""],(e=>`\n position: absolute;\n right: 0px;\n bottom: 0px;\n padding: 4px;\n touch-action: none; \n cursor: ${e.cursor};\n &:focus-visible {\n outline: none;\n color: ${e.theme.colors['border-focus']};\n }\n &:focus-visible > svg {\n transform: scale(1.2);\n }\n `));exports.ResizeGlobals=ResizeGlobals,exports.ResizeIcon=ResizeIcon,exports.Root=Root,exports.Textarea=Textarea,exports.TextareaMimic=TextareaMimic;
|
|
2
2
|
//# sourceMappingURL=style.js.map
|