@salutejs/plasma-new-hope 0.178.0-canary.1514.11575933383.0 → 0.178.1-canary.1515.11581730946.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Counter/Counter.css +1 -1
- package/cjs/components/Counter/Counter.js +3 -13
- package/cjs/components/Counter/Counter.js.map +1 -1
- package/cjs/components/Counter/Counter.tokens.js +0 -4
- package/cjs/components/Counter/Counter.tokens.js.map +1 -1
- package/cjs/components/Counter/variations/_size/base.js +1 -1
- package/cjs/components/Counter/variations/_size/base.js.map +1 -1
- package/cjs/components/Counter/variations/_size/{base_4mz17d.css → base_1z0ohiy.css} +1 -1
- package/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js +4 -2
- package/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js.map +1 -1
- package/cjs/components/Popover/Popover.js +2 -1
- package/cjs/components/Popover/Popover.js.map +1 -1
- package/cjs/components/Popup/Popup.js +2 -2
- package/cjs/components/Popup/Popup.js.map +1 -1
- package/cjs/components/Popup/PopupContext.js +1 -1
- package/cjs/components/Popup/PopupContext.js.map +1 -1
- package/cjs/components/Portal/Portal.js +4 -0
- package/cjs/components/Portal/Portal.js.map +1 -1
- package/cjs/index.css +1 -1
- package/emotion/cjs/components/Counter/Counter.js +3 -13
- package/emotion/cjs/components/Counter/Counter.template-doc.mdx +2 -2
- package/emotion/cjs/components/Counter/Counter.tokens.js +1 -4
- package/emotion/cjs/components/Counter/variations/_size/base.js +1 -1
- package/emotion/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js +6 -4
- package/emotion/cjs/components/Popover/Popover.js +2 -1
- package/emotion/cjs/components/Popup/Popup.js +1 -1
- package/emotion/cjs/components/Popup/PopupContext.js +1 -1
- package/emotion/cjs/components/Portal/Portal.js +4 -0
- package/emotion/cjs/examples/plasma_b2c/components/Counter/Counter.config.js +9 -12
- package/emotion/cjs/examples/plasma_b2c/components/Counter/Counter.stories.tsx +5 -7
- package/emotion/cjs/examples/plasma_b2c/components/TextArea/TextArea.stories.tsx +9 -6
- package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +10 -6
- package/emotion/cjs/examples/plasma_web/components/Counter/Counter.config.js +9 -12
- package/emotion/cjs/examples/plasma_web/components/Counter/Counter.stories.tsx +5 -7
- package/emotion/cjs/examples/plasma_web/components/TextArea/TextArea.stories.tsx +9 -6
- package/emotion/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +10 -6
- package/emotion/es/components/Counter/Counter.js +3 -13
- package/emotion/es/components/Counter/Counter.template-doc.mdx +2 -2
- package/emotion/es/components/Counter/Counter.tokens.js +0 -3
- package/emotion/es/components/Counter/variations/_size/base.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownOld/DropdownOld.js +4 -2
- package/emotion/es/components/Popover/Popover.js +2 -1
- package/emotion/es/components/Popup/Popup.js +1 -1
- package/emotion/es/components/Popup/PopupContext.js +1 -1
- package/emotion/es/components/Portal/Portal.js +4 -0
- package/emotion/es/examples/plasma_b2c/components/Counter/Counter.config.js +9 -12
- package/emotion/es/examples/plasma_b2c/components/Counter/Counter.stories.tsx +5 -7
- package/emotion/es/examples/plasma_b2c/components/TextArea/TextArea.stories.tsx +9 -6
- package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +10 -6
- package/emotion/es/examples/plasma_web/components/Counter/Counter.config.js +9 -12
- package/emotion/es/examples/plasma_web/components/Counter/Counter.stories.tsx +5 -7
- package/emotion/es/examples/plasma_web/components/TextArea/TextArea.stories.tsx +9 -6
- package/emotion/es/examples/plasma_web/components/TextField/TextField.stories.tsx +10 -6
- package/es/components/Counter/Counter.css +1 -1
- package/es/components/Counter/Counter.js +3 -13
- package/es/components/Counter/Counter.js.map +1 -1
- package/es/components/Counter/Counter.tokens.js +1 -4
- package/es/components/Counter/Counter.tokens.js.map +1 -1
- package/es/components/Counter/variations/_size/base.js +1 -1
- package/es/components/Counter/variations/_size/base.js.map +1 -1
- package/es/components/Counter/variations/_size/{base_4mz17d.css → base_1z0ohiy.css} +1 -1
- package/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownOld/DropdownOld.js +4 -2
- package/es/components/Dropdown/ui/DropdownOld/DropdownOld.js.map +1 -1
- package/es/components/Popover/Popover.js +2 -1
- package/es/components/Popover/Popover.js.map +1 -1
- package/es/components/Popup/Popup.js +2 -2
- package/es/components/Popup/Popup.js.map +1 -1
- package/es/components/Popup/PopupContext.js +1 -1
- package/es/components/Popup/PopupContext.js.map +1 -1
- package/es/components/Portal/Portal.js +4 -0
- package/es/components/Portal/Portal.js.map +1 -1
- package/es/index.css +1 -1
- package/package.json +4 -4
- package/styled-components/cjs/components/Counter/Counter.js +3 -13
- package/styled-components/cjs/components/Counter/Counter.template-doc.mdx +2 -2
- package/styled-components/cjs/components/Counter/Counter.tokens.js +1 -4
- package/styled-components/cjs/components/Counter/variations/_size/base.js +1 -1
- package/styled-components/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js +6 -4
- package/styled-components/cjs/components/Popover/Popover.js +2 -1
- package/styled-components/cjs/components/Popup/Popup.js +1 -1
- package/styled-components/cjs/components/Popup/PopupContext.js +1 -1
- package/styled-components/cjs/components/Portal/Portal.js +4 -0
- package/styled-components/cjs/examples/plasma_b2c/components/Counter/Counter.config.js +2 -5
- package/styled-components/cjs/examples/plasma_b2c/components/Counter/Counter.stories.tsx +5 -7
- package/styled-components/cjs/examples/plasma_b2c/components/TextArea/TextArea.stories.tsx +9 -6
- package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +10 -6
- package/styled-components/cjs/examples/plasma_web/components/Counter/Counter.config.js +2 -5
- package/styled-components/cjs/examples/plasma_web/components/Counter/Counter.stories.tsx +5 -7
- package/styled-components/cjs/examples/plasma_web/components/TextArea/TextArea.stories.tsx +9 -6
- package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +10 -6
- package/styled-components/es/components/Counter/Counter.js +3 -13
- package/styled-components/es/components/Counter/Counter.template-doc.mdx +2 -2
- package/styled-components/es/components/Counter/Counter.tokens.js +0 -3
- package/styled-components/es/components/Counter/variations/_size/base.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownOld/DropdownOld.js +4 -2
- package/styled-components/es/components/Popover/Popover.js +2 -1
- package/styled-components/es/components/Popup/Popup.js +1 -1
- package/styled-components/es/components/Popup/PopupContext.js +1 -1
- package/styled-components/es/components/Portal/Portal.js +4 -0
- package/styled-components/es/examples/plasma_b2c/components/Counter/Counter.config.js +2 -5
- package/styled-components/es/examples/plasma_b2c/components/Counter/Counter.stories.tsx +5 -7
- package/styled-components/es/examples/plasma_b2c/components/TextArea/TextArea.stories.tsx +9 -6
- package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +10 -6
- package/styled-components/es/examples/plasma_web/components/Counter/Counter.config.js +2 -5
- package/styled-components/es/examples/plasma_web/components/Counter/Counter.stories.tsx +5 -7
- package/styled-components/es/examples/plasma_web/components/TextArea/TextArea.stories.tsx +9 -6
- package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +10 -6
- package/types/components/Counter/Counter.d.ts.map +1 -1
- package/types/components/Counter/Counter.tokens.d.ts +0 -3
- package/types/components/Counter/Counter.tokens.d.ts.map +1 -1
- package/types/components/Counter/Counter.types.d.ts +2 -2
- package/types/components/Counter/variations/_size/base.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownDivider/DropdownDivider.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownFooter/DropdownFooter.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownGroup/DropdownGroup.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownHeader/DropdownHeader.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownOld/DropdownOld.d.ts.map +1 -1
- package/types/components/Popover/Popover.d.ts.map +1 -1
- package/types/components/Popup/PopupContext.d.ts.map +1 -1
- package/types/components/Portal/Portal.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Counter/Counter.config.d.ts +0 -3
- package/types/examples/plasma_b2c/components/Counter/Counter.config.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Counter/Counter.d.ts +0 -3
- package/types/examples/plasma_b2c/components/Counter/Counter.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Counter/Counter.config.d.ts +0 -3
- package/types/examples/plasma_web/components/Counter/Counter.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Counter/Counter.d.ts +0 -3
- package/types/examples/plasma_web/components/Counter/Counter.d.ts.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { canUseDOM, cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible, rootId } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n zIndex={zIndex}\n frame={frame}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && canUseDOM && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <Portal container={containerElement}>\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>{' '}\n </Portal>\n );\n }\n\n const globalPortal = canUseDOM && document.getElementById(rootId);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","rootId","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","Portal","container","withFrameId","containerElement","canUseDOM","document","getElementById","StyledPortalContainer","globalPortal","Fragment","popupConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;AAaO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,C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AEO,YAAAA;KAAehB,EAAAA,QAAiB,CAAI,CAAC,CAAA;AACtF,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMkB,WAAW,GAAG;AACvBC,EAAAA,IAAI,EAAE,OAAO;AACbC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEjE,SAAS;AACjBkE,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;"}
|
1
|
+
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { canUseDOM, cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible, rootId } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n zIndex={zIndex}\n frame={frame}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current && canUseDOM) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && canUseDOM && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <Portal container={containerElement}>\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>{' '}\n </Portal>\n );\n }\n\n const globalPortal = canUseDOM && document.getElementById(rootId);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","rootId","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","canUseDOM","Portal","container","withFrameId","containerElement","document","getElementById","StyledPortalContainer","globalPortal","Fragment","popupConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;AAaO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,SAAyB,EACzBC,MAA2C,EACvB;EACpB,IAAIC,CAAC,GAAG,MAAM,CAAA;EACd,IAAIC,CAAC,GAAG,MAAM,CAAA;AAEd,EAAA,IAAIF,MAAM,EAAE;AACR,IAAA,IAAAG,OAAA,GAAAC,cAAA,CAAiBJ,MAAM,EAAA,CAAA,CAAA;AAAhBK,MAAAA,EAAE,GAAAF,OAAA,CAAA,CAAA,CAAA;AAAEG,MAAAA,EAAE,GAAAH,OAAA,CAAA,CAAA,CAAA,CAAA;IACbF,CAAC,GAAG,OAAOI,EAAE,KAAK,QAAQ,MAAAE,MAAA,CAAMF,EAAE,EAAA,KAAA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76
|
return /*#__PURE__*/React.createElement(PopupContext.Provider, {
|
77
77
|
value: context
|
78
|
-
}, children, /*#__PURE__*/React.createElement(Portal, {
|
78
|
+
}, children, canUseDOM && /*#__PURE__*/React.createElement(Portal, {
|
79
79
|
container: document.body
|
80
80
|
}, /*#__PURE__*/React.createElement(StyledPortal, {
|
81
81
|
id: rootId
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PopupContext.js","sources":["../../../src/components/Popup/PopupContext.tsx"],"sourcesContent":["import React, { createContext, useState, useContext, FC, PropsWithChildren, useRef } from 'react';\n\nimport { hasModals } from '../Modal/ModalContext';\nimport { canUseDOM, safeUseId } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupContextType, PopupInfo } from './Popup.types';\nimport { StyledPortal } from './Popup.styles';\n\nexport const POPUP_PORTAL_ID = 'plasma-popup-root';\n\nconst items: PopupInfo[] = [];\n\nconst PopupContext = createContext<PopupContextType>({\n items,\n rootId: POPUP_PORTAL_ID,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n register(_info: PopupInfo): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n unregister(_id: string): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n});\n\nexport const usePopupContext = () => useContext(PopupContext);\n\nexport const PopupProvider: FC<PropsWithChildren> = ({ children }) => {\n const prevBodyOverflowY = useRef(canUseDOM ? document.body.style.overflowY : '');\n // eslint-disable-next-line no-shadow\n const [items, setItems] = useState<PopupInfo[]>([]);\n\n const uuid = safeUseId();\n const rootId = `${POPUP_PORTAL_ID}-${uuid}`;\n\n const register = (info: PopupInfo) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n if (info.info?.isModal && !hasModals(prevItems)) {\n prevBodyOverflowY.current = document.body.style.overflowY;\n document.body.style.overflowY = 'hidden';\n }\n\n return [...prevItems, info];\n });\n };\n\n const unregister = (id: string) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n const index = prevItems.findIndex((item: PopupInfo) => id === item.id);\n\n if (index === -1) {\n return prevItems;\n }\n\n const prevHasModals = hasModals(prevItems);\n prevItems.splice(index, 1);\n\n if (prevHasModals && !hasModals(prevItems)) {\n document.body.style.overflowY = prevBodyOverflowY.current;\n }\n\n // при return prevItems не обновится контекст\n return [...prevItems];\n });\n };\n\n const context = {\n items,\n rootId,\n register,\n unregister,\n };\n\n return (\n <PopupContext.Provider value={context}>\n {children}\n <Portal container={document.body}>\n
|
1
|
+
{"version":3,"file":"PopupContext.js","sources":["../../../src/components/Popup/PopupContext.tsx"],"sourcesContent":["import React, { createContext, useState, useContext, FC, PropsWithChildren, useRef } from 'react';\n\nimport { hasModals } from '../Modal/ModalContext';\nimport { canUseDOM, safeUseId } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupContextType, PopupInfo } from './Popup.types';\nimport { StyledPortal } from './Popup.styles';\n\nexport const POPUP_PORTAL_ID = 'plasma-popup-root';\n\nconst items: PopupInfo[] = [];\n\nconst PopupContext = createContext<PopupContextType>({\n items,\n rootId: POPUP_PORTAL_ID,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n register(_info: PopupInfo): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n unregister(_id: string): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n});\n\nexport const usePopupContext = () => useContext(PopupContext);\n\nexport const PopupProvider: FC<PropsWithChildren> = ({ children }) => {\n const prevBodyOverflowY = useRef(canUseDOM ? document.body.style.overflowY : '');\n // eslint-disable-next-line no-shadow\n const [items, setItems] = useState<PopupInfo[]>([]);\n\n const uuid = safeUseId();\n const rootId = `${POPUP_PORTAL_ID}-${uuid}`;\n\n const register = (info: PopupInfo) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n if (info.info?.isModal && !hasModals(prevItems)) {\n prevBodyOverflowY.current = document.body.style.overflowY;\n document.body.style.overflowY = 'hidden';\n }\n\n return [...prevItems, info];\n });\n };\n\n const unregister = (id: string) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n const index = prevItems.findIndex((item: PopupInfo) => id === item.id);\n\n if (index === -1) {\n return prevItems;\n }\n\n const prevHasModals = hasModals(prevItems);\n prevItems.splice(index, 1);\n\n if (prevHasModals && !hasModals(prevItems)) {\n document.body.style.overflowY = prevBodyOverflowY.current;\n }\n\n // при return prevItems не обновится контекст\n return [...prevItems];\n });\n };\n\n const context = {\n items,\n rootId,\n register,\n unregister,\n };\n\n return (\n <PopupContext.Provider value={context}>\n {children}\n {canUseDOM && (\n <Portal container={document.body}>\n <StyledPortal id={rootId} />\n </Portal>\n )}\n </PopupContext.Provider>\n );\n};\n"],"names":["POPUP_PORTAL_ID","items","PopupContext","createContext","rootId","register","_info","Error","unregister","_id","usePopupContext","useContext","PopupProvider","_ref","children","prevBodyOverflowY","useRef","canUseDOM","document","body","style","overflowY","_useState","useState","_useState2","_slicedToArray","setItems","uuid","safeUseId","concat","info","prevItems","_info$info","isModal","hasModals","current","_toConsumableArray","id","index","findIndex","item","prevHasModals","splice","context","React","createElement","Provider","value","Portal","container","StyledPortal"],"mappings":";;;;;;;;AASO,IAAMA,eAAe,GAAG,oBAAmB;AAElD,IAAMC,KAAkB,GAAG,EAAE,CAAA;AAE7B,IAAMC,YAAY,gBAAGC,aAAa,CAAmB;AACjDF,EAAAA,KAAK,EAALA,KAAK;AACLG,EAAAA,MAAM,EAAEJ,eAAe;AACvB;EACAK,QAAQ,EAAA,SAAAA,QAACC,CAAAA,KAAgB,EAAQ;AAC7B,IAAA,MAAM,IAAIC,KAAK,CAAC,6CAA6C,CAAC,CAAA;GACjE;AACD;EACAC,UAAU,EAAA,SAAAA,UAACC,CAAAA,GAAW,EAAQ;AAC1B,IAAA,MAAM,IAAIF,KAAK,CAAC,6CAA6C,CAAC,CAAA;AAClE,GAAA;AACJ,CAAC,CAAC,CA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AACC,IAAAA,KAAK,EAAEJ,OAAAA;GACzB7B,EAAAA,QAAQ,EACRG,SAAS,iBACN2B,KAAA,CAAAC,aAAA,CAACG,MAAM,EAAA;IAACC,SAAS,EAAE/B,QAAQ,CAACC,IAAAA;AAAK,GAAA,eAC7ByB,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAA;AAACb,IAAAA,EAAE,EAAEjC,MAAAA;GAAS,CACvB,CAEO,CAAC,CAAA;AAEhC;;;;"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
|
+
import { canUseDOM } from '../../utils/canUseDOM.js';
|
3
4
|
|
4
5
|
/**
|
5
6
|
* Вспомогательный компонент. Используется в Popup, Popover.
|
@@ -10,6 +11,9 @@ var Portal = function Portal(_ref) {
|
|
10
11
|
container = _ref.container,
|
11
12
|
_ref$disabled = _ref.disabled,
|
12
13
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
14
|
+
if (!canUseDOM) {
|
15
|
+
return null;
|
16
|
+
}
|
13
17
|
var portalContainer = typeof container === 'function' ? container() : container;
|
14
18
|
return /*#__PURE__*/React.createElement(React.Fragment, null, disabled && children, !disabled && /*#__PURE__*/ReactDOM.createPortal(children, portalContainer));
|
15
19
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { PortalProps } from './Portal.types';\n\n/**\n * Вспомогательный компонент. Используется в Popup, Popover.\n * Представляет собой ReactDOM.createPortal() в форме компонента.\n */\nexport const Portal: FC<PortalProps> = ({ children, container, disabled = false }) => {\n const portalContainer = typeof container === 'function' ? container() : container;\n\n return (\n <>\n {disabled && children}\n {!disabled && ReactDOM.createPortal(children, portalContainer)}\n </>\n );\n};\n"],"names":["Portal","_ref","children","container","_ref$disabled","disabled","portalContainer","React","createElement","Fragment","ReactDOM","createPortal"],"mappings":"
|
1
|
+
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { canUseDOM } from '../../utils';\n\nimport { PortalProps } from './Portal.types';\n\n/**\n * Вспомогательный компонент. Используется в Popup, Popover.\n * Представляет собой ReactDOM.createPortal() в форме компонента.\n */\nexport const Portal: FC<PortalProps> = ({ children, container, disabled = false }) => {\n if (!canUseDOM) {\n return null;\n }\n\n const portalContainer = typeof container === 'function' ? container() : container;\n\n return (\n <>\n {disabled && children}\n {!disabled && ReactDOM.createPortal(children, portalContainer)}\n </>\n );\n};\n"],"names":["Portal","_ref","children","container","_ref$disabled","disabled","canUseDOM","portalContainer","React","createElement","Fragment","ReactDOM","createPortal"],"mappings":";;;;AAOA;AACA;AACA;AACA;IACaA,MAAuB,GAAG,SAA1BA,MAAuBA,CAAAC,IAAA,EAAkD;AAAA,EAAA,IAA5CC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,SAAS,GAAAF,IAAA,CAATE,SAAS;IAAAC,aAAA,GAAAH,IAAA,CAAEI,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA,CAAA;EAC3E,IAAI,CAACE,SAAS,EAAE;AACZ,IAAA,OAAO,IAAI,CAAA;AACf,GAAA;EAEA,IAAMC,eAAe,GAAG,OAAOJ,SAAS,KAAK,UAAU,GAAGA,SAAS,EAAE,GAAGA,SAAS,CAAA;EAEjF,oBACIK,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EACKL,IAAAA,EAAAA,QAAQ,IAAIH,QAAQ,EACpB,CAACG,QAAQ,iBAAIM,QAAQ,CAACC,YAAY,CAACV,QAAQ,EAAEK,eAAe,CAC/D,CAAC,CAAA;AAEX;;;;"}
|
package/es/index.css
CHANGED
@@ -475,7 +475,7 @@
|
|
475
475
|
|
476
476
|
.base_1vjakah_b15waymg__f123ad8a{color:var(--plasma-counter-color);background-color:var(--plasma-counter-background);}
|
477
477
|
|
478
|
-
.
|
478
|
+
.base_1z0ohiy_b1t6e429__9712bb45{font-family:var(--plasma-counter-font-family);font-size:var(--plasma-counter-font-size);font-style:var(--plasma-counter-font-style);font-weight:var(--plasma-counter-font-weight);-webkit-letter-spacing:var(--plasma-counter-letter-spacing);-moz-letter-spacing:var(--plasma-counter-letter-spacing);-ms-letter-spacing:var(--plasma-counter-letter-spacing);letter-spacing:var(--plasma-counter-letter-spacing);line-height:var(--plasma-counter-lineheight);border-radius:var(--plasma-counter-border-radius);height:var(--plasma-counter-height);padding-top:var(--plasma-counter-padding-top);padding-right:var(--plasma-counter-padding-right);padding-bottom:var(--plasma-counter-padding-bottom);padding-left:var(--plasma-counter-padding-left);}
|
479
479
|
|
480
480
|
.Counter_styles_1uue90v_b1dqw7l5__00d0b847{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;box-sizing:border-box;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;width:-webkit-max-content;width:-moz-max-content;width:max-content;}
|
481
481
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.178.
|
3
|
+
"version": "0.178.1-canary.1515.11581730946.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -80,7 +80,7 @@
|
|
80
80
|
"@rollup/plugin-babel": "^6.0.4",
|
81
81
|
"@rollup/plugin-commonjs": "^25.0.4",
|
82
82
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
83
|
-
"@salutejs/plasma-sb-utils": "0.
|
83
|
+
"@salutejs/plasma-sb-utils": "0.181.1-dev.0",
|
84
84
|
"@salutejs/plasma-themes": "0.22.0-dev.0",
|
85
85
|
"@storybook/addon-docs": "^7.6.17",
|
86
86
|
"@storybook/addon-essentials": "^7.6.17",
|
@@ -115,7 +115,7 @@
|
|
115
115
|
"@linaria/react": "5.0.3",
|
116
116
|
"@popperjs/core": "2.11.8",
|
117
117
|
"@salutejs/input-core": "2.1.2",
|
118
|
-
"@salutejs/plasma-core": "1.
|
118
|
+
"@salutejs/plasma-core": "1.183.1-dev.0",
|
119
119
|
"@salutejs/react-maskinput": "3.2.6",
|
120
120
|
"classnames": "2.5.1",
|
121
121
|
"dayjs": "1.11.11",
|
@@ -128,5 +128,5 @@
|
|
128
128
|
"sideEffects": [
|
129
129
|
"*.css"
|
130
130
|
],
|
131
|
-
"gitHead": "
|
131
|
+
"gitHead": "0178d7a661a417a04fe6b9feb21fa9629ab05576"
|
132
132
|
}
|
@@ -6,38 +6,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.counterRoot = exports.counterConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var _utils = /*#__PURE__*/require("../../utils");
|
10
9
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
10
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
11
|
var _Counter = /*#__PURE__*/require("./Counter.styles");
|
13
|
-
var
|
14
|
-
var _excluded = ["count", "maxCount", "size", "view", "className"];
|
12
|
+
var _excluded = ["count", "maxCount", "size", "view"];
|
15
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
16
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
17
15
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
18
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
19
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
20
|
-
var MIN_COUNT = 1;
|
21
18
|
var counterRoot = exports.counterRoot = function counterRoot(Root) {
|
22
19
|
return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
23
20
|
var count = props.count,
|
24
21
|
maxCount = props.maxCount,
|
25
22
|
size = props.size,
|
26
23
|
view = props.view,
|
27
|
-
className = props.className,
|
28
24
|
rest = _objectWithoutProperties(props, _excluded);
|
29
|
-
var
|
30
|
-
var currentMaxCount = maxCount && maxCount < MIN_COUNT ? MIN_COUNT : maxCount;
|
31
|
-
var isCurrentCountOneDigit = currentCount >= 0 && currentCount < 10;
|
32
|
-
var isCurrentMaxCountExceeded = currentMaxCount && currentCount > currentMaxCount;
|
33
|
-
var content = isCurrentMaxCountExceeded ? "".concat(currentMaxCount, "+") : currentCount;
|
34
|
-
var roundClass = !isCurrentMaxCountExceeded && isCurrentCountOneDigit ? _Counter2.classes.round : undefined;
|
25
|
+
var content = maxCount && count > maxCount ? "".concat(maxCount, "+") : count;
|
35
26
|
return /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
36
27
|
ref: ref,
|
37
28
|
view: view,
|
38
29
|
size: size,
|
39
|
-
count: count
|
40
|
-
className: (0, _utils.cx)(roundClass, className)
|
30
|
+
count: count
|
41
31
|
}, rest), content);
|
42
32
|
});
|
43
33
|
};
|
@@ -12,7 +12,7 @@ import { PropsTable, Description } from '@site/src/components';
|
|
12
12
|
## Примеры
|
13
13
|
|
14
14
|
### Максимальное значение числового badge
|
15
|
-
Задается с помощью свойства `maxCount`.
|
15
|
+
Задается с помощью свойства `maxCount`.
|
16
16
|
|
17
17
|
```tsx live
|
18
18
|
import React from 'react';
|
@@ -29,7 +29,7 @@ export function App() {
|
|
29
29
|
```
|
30
30
|
|
31
31
|
### Размер числового badge
|
32
|
-
Размер задается с помощью свойства `size`. Возможные значения свойства: `
|
32
|
+
Размер задается с помощью свойства `size`. Возможные значения свойства: `"xs"` или `"xxs"`.
|
33
33
|
|
34
34
|
```tsx live
|
35
35
|
import React from 'react';
|
@@ -3,10 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.tokens =
|
7
|
-
var classes = exports.classes = {
|
8
|
-
round: '--plasma-counter-round'
|
9
|
-
};
|
6
|
+
exports.tokens = void 0;
|
10
7
|
var tokens = exports.tokens = {
|
11
8
|
background: '--plasma-counter-background',
|
12
9
|
color: '--plasma-counter-color',
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.base = void 0;
|
7
7
|
var _styledComponents = /*#__PURE__*/require("styled-components");
|
8
8
|
var _Counter = /*#__PURE__*/require("../../Counter.tokens");
|
9
|
-
var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["font-family:var(", ");font-size:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");border-radius:var(", ");height:var(", ");padding-top:var(", ");padding-right:var(", ");padding-bottom:var(", ");padding-left:var(", ")
|
9
|
+
var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["font-family:var(", ");font-size:var(", ");font-style:var(", ");font-weight:var(", ");letter-spacing:var(", ");line-height:var(", ");border-radius:var(", ");height:var(", ");padding-top:var(", ");padding-right:var(", ");padding-bottom:var(", ");padding-left:var(", ");"], _Counter.tokens.fontFamily, _Counter.tokens.fontSize, _Counter.tokens.fontStyle, _Counter.tokens.fontWeight, _Counter.tokens.letterSpacing, _Counter.tokens.lineHeight, _Counter.tokens.borderRadius, _Counter.tokens.height, _Counter.tokens.paddingTop, _Counter.tokens.paddingRight, _Counter.tokens.paddingBottom, _Counter.tokens.paddingLeft);
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownDividerRoot = exports.dropdownDividerConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _utils = /*#__PURE__*/require("../../../../utils");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownDivider = /*#__PURE__*/require("./DropdownDivider.styles");
|
@@ -26,7 +26,7 @@ var dropdownDividerRoot = exports.dropdownDividerRoot = function dropdownDivider
|
|
26
26
|
view = _ref.view,
|
27
27
|
size = _ref.size,
|
28
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
29
|
-
var uniqId = (0,
|
29
|
+
var uniqId = (0, _utils.safeUseId)();
|
30
30
|
var innerId = id || uniqId;
|
31
31
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
32
32
|
id: innerId,
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownFooterRoot = exports.dropdownFooterConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _utils = /*#__PURE__*/require("../../../../utils");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownFooter = /*#__PURE__*/require("./DropdownFooter.styles");
|
@@ -27,7 +27,7 @@ var dropdownFooterRoot = exports.dropdownFooterRoot = function dropdownFooterRoo
|
|
27
27
|
view = _ref.view,
|
28
28
|
size = _ref.size,
|
29
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
30
|
-
var uniqId = (0,
|
30
|
+
var uniqId = (0, _utils.safeUseId)();
|
31
31
|
var innerId = id || uniqId;
|
32
32
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
33
33
|
id: innerId,
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownGroupRoot = exports.dropdownGroupConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _utils = /*#__PURE__*/require("../../../../utils");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownGroup = /*#__PURE__*/require("./DropdownGroup.styles");
|
@@ -30,7 +30,7 @@ var dropdownGroupRoot = exports.dropdownGroupRoot = function dropdownGroupRoot(R
|
|
30
30
|
view = _ref.view,
|
31
31
|
size = _ref.size,
|
32
32
|
rest = _objectWithoutProperties(_ref, _excluded);
|
33
|
-
var uniqId = (0,
|
33
|
+
var uniqId = (0, _utils.safeUseId)();
|
34
34
|
var innerId = id || uniqId;
|
35
35
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
36
36
|
id: innerId,
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownHeaderRoot = exports.dropdownHeaderConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _utils = /*#__PURE__*/require("../../../../utils");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownHeader = /*#__PURE__*/require("./DropdownHeader.styles");
|
@@ -27,7 +27,7 @@ var dropdownHeaderRoot = exports.dropdownHeaderRoot = function dropdownHeaderRoo
|
|
27
27
|
size = _ref.size,
|
28
28
|
children = _ref.children,
|
29
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
30
|
-
var uniqId = (0,
|
30
|
+
var uniqId = (0, _utils.safeUseId)();
|
31
31
|
var innerId = id || uniqId;
|
32
32
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
33
33
|
id: innerId,
|
@@ -7,10 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.dropdownOldRoot = exports.dropdownOldConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
9
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
10
|
+
var _hooks = /*#__PURE__*/require("../../../../hooks");
|
11
|
+
var _utils = /*#__PURE__*/require("../../../../utils");
|
10
12
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
13
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
14
|
var _Dropdown = /*#__PURE__*/require("./Dropdown.styles");
|
13
|
-
var
|
15
|
+
var _utils2 = /*#__PURE__*/require("./utils");
|
14
16
|
var _excluded = ["id", "target", "children", "hasArrow", "role", "view", "size", "frame", "onToggle", "isFocusTrapped", "isOpen", "opened", "placement", "trigger", "offset", "preventOverflow", "closeOnOverlayClick", "closeOnEsc"];
|
15
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
16
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
@@ -51,12 +53,12 @@ var dropdownOldRoot = exports.dropdownOldRoot = function dropdownOldRoot(Root) {
|
|
51
53
|
closeOnEsc = _ref$closeOnEsc === void 0 ? false : _ref$closeOnEsc,
|
52
54
|
rest = _objectWithoutProperties(_ref, _excluded);
|
53
55
|
var innerIsOpen = Boolean(isOpen || opened);
|
54
|
-
var uniqId = (0,
|
56
|
+
var uniqId = (0, _utils.safeUseId)();
|
55
57
|
var innerId = id || uniqId;
|
56
58
|
var rootRef = (0, _react.useRef)(null);
|
57
59
|
var dropdownRef = (0, _react.useRef)(null);
|
58
60
|
var handleRef = (0, _plasmaCore.useForkRef)(rootRef, outerRootRef);
|
59
|
-
var trapRef = (0,
|
61
|
+
var trapRef = (0, _hooks.useFocusTrap)(innerIsOpen && isFocusTrapped);
|
60
62
|
var dropdownForkRef = (0, _plasmaCore.useForkRef)(dropdownRef, trapRef);
|
61
63
|
return /*#__PURE__*/_react["default"].createElement(_Dropdown.StyledPopover, {
|
62
64
|
role: role,
|
@@ -71,7 +73,7 @@ var dropdownOldRoot = exports.dropdownOldRoot = function dropdownOldRoot(Root) {
|
|
71
73
|
offset: offset,
|
72
74
|
preventOverflow: preventOverflow,
|
73
75
|
hasArrow: hasArrow,
|
74
|
-
placement: (0,
|
76
|
+
placement: (0, _utils2.getPlacements)(placement),
|
75
77
|
trigger: trigger,
|
76
78
|
closeOnOverlayClick: closeOnOverlayClick,
|
77
79
|
closeOnEsc: closeOnEsc,
|
@@ -8,6 +8,7 @@ exports.popoverRoot = exports.popoverConfig = exports.POPOVER_PORTAL_ID = export
|
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
9
|
var _reactPopper = /*#__PURE__*/require("react-popper");
|
10
10
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
11
|
+
var _hooks = /*#__PURE__*/require("../../hooks");
|
11
12
|
var _utils = /*#__PURE__*/require("../../utils");
|
12
13
|
var _Portal = /*#__PURE__*/require("../Portal");
|
13
14
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
@@ -72,7 +73,7 @@ var popoverRoot = exports.popoverRoot = function popoverRoot(Root) {
|
|
72
73
|
var popoverRef = (0, _react.useRef)(null);
|
73
74
|
var handleRef = (0, _plasmaCore.useForkRef)(rootRef, outerRootRef);
|
74
75
|
var portalRef = (0, _react.useRef)(null);
|
75
|
-
var trapRef = (0,
|
76
|
+
var trapRef = (0, _hooks.useFocusTrap)(innerIsOpen && isFocusTrapped);
|
76
77
|
var popoverForkRef = (0, _plasmaCore.useForkRef)(popoverRef, trapRef);
|
77
78
|
var _useState = (0, _react.useState)(null),
|
78
79
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -139,7 +139,7 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
139
139
|
animationInfo: animationInfo,
|
140
140
|
setVisible: setVisible
|
141
141
|
}, children));
|
142
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
142
|
+
if (typeof frame !== 'string' && frame && frame.current && _utils.canUseDOM) {
|
143
143
|
return /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
144
144
|
container: frame.current
|
145
145
|
}, rootNode);
|
@@ -91,7 +91,7 @@ var PopupProvider = exports.PopupProvider = function PopupProvider(_ref) {
|
|
91
91
|
};
|
92
92
|
return /*#__PURE__*/_react["default"].createElement(PopupContext.Provider, {
|
93
93
|
value: context
|
94
|
-
}, children, /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
94
|
+
}, children, _utils.canUseDOM && /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
95
95
|
container: document.body
|
96
96
|
}, /*#__PURE__*/_react["default"].createElement(_Popup.StyledPortal, {
|
97
97
|
id: rootId
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.Portal = void 0;
|
7
7
|
var _react = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react"));
|
8
8
|
var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
|
9
|
+
var _utils = /*#__PURE__*/require("../../utils");
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
10
11
|
/**
|
11
12
|
* Вспомогательный компонент. Используется в Popup, Popover.
|
@@ -16,6 +17,9 @@ var Portal = exports.Portal = function Portal(_ref) {
|
|
16
17
|
container = _ref.container,
|
17
18
|
_ref$disabled = _ref.disabled,
|
18
19
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
20
|
+
if (!_utils.canUseDOM) {
|
21
|
+
return null;
|
22
|
+
}
|
19
23
|
var portalContainer = typeof container === 'function' ? container() : container;
|
20
24
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, disabled && children, !disabled && /*#__PURE__*/_reactDom["default"].createPortal(children, portalContainer));
|
21
25
|
};
|
@@ -22,11 +22,8 @@ var config = exports.config = {
|
|
22
22
|
light: /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--on-light-text-primary);", ":var(--on-dark-surface-solid-default);"], _Counter.counterTokens.color, _Counter.counterTokens.background)
|
23
23
|
},
|
24
24
|
size: {
|
25
|
-
|
26
|
-
|
27
|
-
s: /*#__PURE__*/(0, _styledComponents.css)(["", ":1rem;", ":1.25rem;", ":0.375rem;", ":0.375rem;", ":var(--plasma-typo-body-xxs-font-family);", ":var(--plasma-typo-body-xxs-font-size);", ":var(--plasma-typo-body-xxs-font-style);", ":var(--plasma-typo-body-xxs-font-weight);", ":var(--plasma-typo-body-xxs-letter-spacing);", ":var(--plasma-typo-body-xxs-line-height);"], _Counter.counterTokens.borderRadius, _Counter.counterTokens.height, _Counter.counterTokens.paddingRight, _Counter.counterTokens.paddingLeft, _Counter.counterTokens.fontFamily, _Counter.counterTokens.fontSize, _Counter.counterTokens.fontStyle, _Counter.counterTokens.fontWeight, _Counter.counterTokens.letterSpacing, _Counter.counterTokens.lineHeight),
|
28
|
-
xs: /*#__PURE__*/(0, _styledComponents.css)(["", ":1rem;", ":1rem;", ":0.25rem;", ":0.25rem;", ":var(--plasma-typo-body-xxs-font-family);", ":var(--plasma-typo-body-xxs-font-size);", ":var(--plasma-typo-body-xxs-font-style);", ":var(--plasma-typo-body-xxs-font-weight);", ":var(--plasma-typo-body-xxs-letter-spacing);", ":var(--plasma-typo-body-xxs-line-height);"], _Counter.counterTokens.borderRadius, _Counter.counterTokens.height, _Counter.counterTokens.paddingRight, _Counter.counterTokens.paddingLeft, _Counter.counterTokens.fontFamily, _Counter.counterTokens.fontSize, _Counter.counterTokens.fontStyle, _Counter.counterTokens.fontWeight, _Counter.counterTokens.letterSpacing, _Counter.counterTokens.lineHeight),
|
29
|
-
xxs: /*#__PURE__*/(0, _styledComponents.css)(["", ":1rem;", ":0.75rem;", ":0.125rem;", ":0.125rem;", ":var(--plasma-typo-body-xxs-font-family);", ":var(--plasma-typo-body-xxs-font-size);", ":var(--plasma-typo-body-xxs-font-style);", ":var(--plasma-typo-body-xxs-font-weight);", ":var(--plasma-typo-body-xxs-letter-spacing);", ":var(--plasma-typo-body-xxs-line-height);"], _Counter.counterTokens.borderRadius, _Counter.counterTokens.height, _Counter.counterTokens.paddingRight, _Counter.counterTokens.paddingLeft, _Counter.counterTokens.fontFamily, _Counter.counterTokens.fontSize, _Counter.counterTokens.fontStyle, _Counter.counterTokens.fontWeight, _Counter.counterTokens.letterSpacing, _Counter.counterTokens.lineHeight)
|
25
|
+
xs: /*#__PURE__*/(0, _styledComponents.css)(["", ":0.5rem;", ":1rem;", ":0.25rem;", ":0.25rem;", ":var(--plasma-typo-body-xxs-font-family);", ":var(--plasma-typo-body-xxs-font-size);", ":var(--plasma-typo-body-xxs-font-style);", ":var(--plasma-typo-body-xxs-font-weight);", ":var(--plasma-typo-body-xxs-letter-spacing);", ":var(--plasma-typo-body-xxs-line-height);"], _Counter.counterTokens.borderRadius, _Counter.counterTokens.height, _Counter.counterTokens.paddingRight, _Counter.counterTokens.paddingLeft, _Counter.counterTokens.fontFamily, _Counter.counterTokens.fontSize, _Counter.counterTokens.fontStyle, _Counter.counterTokens.fontWeight, _Counter.counterTokens.letterSpacing, _Counter.counterTokens.lineHeight),
|
26
|
+
xxs: /*#__PURE__*/(0, _styledComponents.css)(["", ":0.5rem;", ":0.75rem;", ":0.25rem;", ":0.25rem;", ":var(--plasma-typo-body-xxs-font-family);", ":var(--plasma-typo-body-xxs-font-size);", ":var(--plasma-typo-body-xxs-font-style);", ":var(--plasma-typo-body-xxs-font-weight);", ":var(--plasma-typo-body-xxs-letter-spacing);", ":var(--plasma-typo-body-xxs-line-height);"], _Counter.counterTokens.borderRadius, _Counter.counterTokens.height, _Counter.counterTokens.paddingRight, _Counter.counterTokens.paddingLeft, _Counter.counterTokens.fontFamily, _Counter.counterTokens.fontSize, _Counter.counterTokens.fontStyle, _Counter.counterTokens.fontWeight, _Counter.counterTokens.letterSpacing, _Counter.counterTokens.lineHeight)
|
30
27
|
}
|
31
28
|
}
|
32
29
|
};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import React from 'react';
|
1
2
|
import { disableProps } from '@salutejs/plasma-sb-utils';
|
2
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
3
4
|
|
@@ -5,22 +6,19 @@ import { WithTheme } from '../../../_helpers';
|
|
5
6
|
|
6
7
|
import { Counter } from './Counter';
|
7
8
|
|
8
|
-
const sizes = ['l', 'm', 's', 'xs', 'xxs'];
|
9
|
-
const views = ['default', 'accent', 'positive', 'warning', 'negative', 'dark', 'light'];
|
10
|
-
|
11
9
|
const meta: Meta<typeof Counter> = {
|
12
10
|
title: 'plasma_b2c/Counter',
|
13
11
|
component: Counter,
|
14
12
|
decorators: [WithTheme],
|
15
13
|
argTypes: {
|
16
14
|
size: {
|
17
|
-
options:
|
15
|
+
options: ['xs', 'xxs'],
|
18
16
|
control: {
|
19
17
|
type: 'select',
|
20
18
|
},
|
21
19
|
},
|
22
20
|
view: {
|
23
|
-
options:
|
21
|
+
options: ['default', 'accent', 'positive', 'warning', 'negative', 'dark', 'light'],
|
24
22
|
control: {
|
25
23
|
type: 'select',
|
26
24
|
},
|
@@ -35,8 +33,8 @@ type Story = StoryObj<typeof Counter>;
|
|
35
33
|
|
36
34
|
export const Default: Story = {
|
37
35
|
args: {
|
38
|
-
count:
|
39
|
-
maxCount:
|
36
|
+
count: 25,
|
37
|
+
maxCount: 100,
|
40
38
|
view: 'default',
|
41
39
|
size: 'xs',
|
42
40
|
},
|
@@ -37,6 +37,7 @@ const placements: Array<PopoverPlacement> = [
|
|
37
37
|
];
|
38
38
|
|
39
39
|
type StoryTextAreaPropsCustom = {
|
40
|
+
hasHint?: boolean;
|
40
41
|
enableContentRight?: boolean;
|
41
42
|
};
|
42
43
|
|
@@ -92,43 +93,44 @@ const meta: Meta<StoryTextAreaProps> = {
|
|
92
93
|
},
|
93
94
|
hintText: {
|
94
95
|
control: { type: 'text' },
|
96
|
+
if: { arg: 'hasHint', truthy: true },
|
95
97
|
},
|
96
98
|
hintView: {
|
97
99
|
options: hintViews,
|
98
100
|
control: {
|
99
101
|
type: 'select',
|
100
102
|
},
|
101
|
-
if: { arg: '
|
103
|
+
if: { arg: 'hasHint', truthy: true },
|
102
104
|
},
|
103
105
|
hintSize: {
|
104
106
|
options: hintSizes,
|
105
107
|
control: {
|
106
108
|
type: 'select',
|
107
109
|
},
|
108
|
-
if: { arg: '
|
110
|
+
if: { arg: 'hasHint', truthy: true },
|
109
111
|
},
|
110
112
|
hintTrigger: {
|
111
113
|
options: hintTriggers,
|
112
114
|
control: {
|
113
115
|
type: 'inline-radio',
|
114
116
|
},
|
115
|
-
if: { arg: '
|
117
|
+
if: { arg: 'hasHint', truthy: true },
|
116
118
|
},
|
117
119
|
hintPlacement: {
|
118
120
|
options: placements,
|
119
121
|
control: {
|
120
122
|
type: 'select',
|
121
123
|
},
|
122
|
-
if: { arg: '
|
124
|
+
if: { arg: 'hasHint', truthy: true },
|
123
125
|
mappers: placements,
|
124
126
|
},
|
125
127
|
hintHasArrow: {
|
126
128
|
control: { type: 'boolean' },
|
127
|
-
if: { arg: '
|
129
|
+
if: { arg: 'hasHint', truthy: true },
|
128
130
|
},
|
129
131
|
hintWidth: {
|
130
132
|
control: { type: 'text' },
|
131
|
-
if: { arg: '
|
133
|
+
if: { arg: 'hasHint', truthy: true },
|
132
134
|
},
|
133
135
|
},
|
134
136
|
args: {
|
@@ -152,6 +154,7 @@ const meta: Meta<StoryTextAreaProps> = {
|
|
152
154
|
requiredPlacement: 'right',
|
153
155
|
clear: false,
|
154
156
|
hasDivider: false,
|
157
|
+
hasHint: true,
|
155
158
|
hintText: 'Текст подсказки',
|
156
159
|
hintTrigger: 'hover',
|
157
160
|
hintView: 'default',
|