@hh.ru/magritte-ui-chips 7.0.24 → 7.0.26
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/CheckableChip.js +6 -2
- package/CheckableChip.js.map +1 -1
- package/ChipContent-Cjpr1LGC.js +23 -0
- package/{ChipContent-CqeSdYoC.js.map → ChipContent-Cjpr1LGC.js.map} +1 -1
- package/ChipContent.js +1 -1
- package/ChipsContainer.js +4 -2
- package/ChipsContainer.js.map +1 -1
- package/CustomChip.js +7 -3
- package/CustomChip.js.map +1 -1
- package/defaultProps.d.ts +8 -0
- package/defaultProps.js +14 -0
- package/defaultProps.js.map +1 -0
- package/index.css +1369 -1369
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mock.d.ts +1 -0
- package/index.mock.js +2 -0
- package/index.mock.js.map +1 -1
- package/package.json +7 -6
- package/types.d.ts +21 -6
- package/ChipContent-CqeSdYoC.js +0 -23
package/CheckableChip.js
CHANGED
|
@@ -3,14 +3,18 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
|
|
6
|
-
import { s as styles, C as ChipContent } from './ChipContent-
|
|
6
|
+
import { s as styles, C as ChipContent } from './ChipContent-Cjpr1LGC.js';
|
|
7
|
+
import { useChipDefaultProps } from './defaultProps.js';
|
|
7
8
|
import '@hh.ru/magritte-ui-typography';
|
|
9
|
+
import '@hh.ru/magritte-internal-default-props-context';
|
|
8
10
|
|
|
9
11
|
const STYLE_TO_CSS = {
|
|
10
12
|
neutral: styles.chipStyleNeutral,
|
|
11
13
|
accent: styles.chipStyleAccent,
|
|
12
14
|
};
|
|
13
|
-
const CheckableChipComponent = (
|
|
15
|
+
const CheckableChipComponent = (rawProps, ref) => {
|
|
16
|
+
const defaultProps = useChipDefaultProps();
|
|
17
|
+
const { style = 'neutral', type = 'checkbox', addon, postfix, hideLabel, children, disabled, 'aria-label': ariaLabel, dataQaWrapper = 'chip', size = 'small', mode = 'primary', ...inputProps } = { ...defaultProps, ...rawProps };
|
|
14
18
|
const forceDisabled = useDisabled();
|
|
15
19
|
const isComponentDisabled = disabled || forceDisabled;
|
|
16
20
|
return (jsxs("label", { className: classnames(styles.chip, STYLE_TO_CSS[style], {
|
package/CheckableChip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckableChip.js","sources":["src/CheckableChip.tsx"],"sourcesContent":["import { forwardRef, ForwardedRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport { CheckableChipProps } from '@hh.ru/magritte-ui-chips/types';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CheckableChipComponent = (\n {\n style = 'neutral',\n type = 'checkbox',\n addon,\n postfix,\n hideLabel,\n children,\n disabled,\n 'aria-label': ariaLabel,\n dataQaWrapper = 'chip',\n size = 'small',\n mode = 'primary',\n ...inputProps\n }
|
|
1
|
+
{"version":3,"file":"CheckableChip.js","sources":["src/CheckableChip.tsx"],"sourcesContent":["import { forwardRef, ForwardedRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport { useChipDefaultProps } from '@hh.ru/magritte-ui-chips/defaultProps';\nimport { CheckableChipProps } from '@hh.ru/magritte-ui-chips/types';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CheckableChipComponent = (rawProps: CheckableChipProps, ref: ForwardedRef<HTMLLabelElement>) => {\n const defaultProps = useChipDefaultProps();\n const {\n style = 'neutral',\n type = 'checkbox',\n addon,\n postfix,\n hideLabel,\n children,\n disabled,\n 'aria-label': ariaLabel,\n dataQaWrapper = 'chip',\n size = 'small',\n mode = 'primary',\n ...inputProps\n } = { ...defaultProps, ...rawProps } as CheckableChipProps;\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n return (\n <label\n className={classnames(styles.chip, STYLE_TO_CSS[style], {\n [styles.sizeExtraSmall]: size === 'extra-small',\n [styles.chipSecondary]: mode === 'secondary',\n })}\n ref={ref}\n data-qa={dataQaWrapper}\n data-interactive={true}\n >\n <input {...inputProps} type={type} className={styles.input} disabled={isComponentDisabled} />\n <ChipContent\n size={size}\n postfix={postfix}\n addon={addon}\n aria-label={ariaLabel}\n hideLabel={hideLabel}\n mode={mode}\n >\n {children}\n </ChipContent>\n </label>\n );\n};\n\nconst CheckableChip = forwardRef(CheckableChipComponent);\nexport { CheckableChip };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;AAUA,MAAM,YAAY,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC,gBAAgB;IAChC,MAAM,EAAE,MAAM,CAAC,eAAe;CACjC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,QAA4B,EAAE,GAAmC,KAAI;AACjG,IAAA,MAAM,YAAY,GAAG,mBAAmB,EAAE,CAAC;IAC3C,MAAM,EACF,KAAK,GAAG,SAAS,EACjB,IAAI,GAAG,UAAU,EACjB,KAAK,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,aAAa,GAAG,MAAM,EACtB,IAAI,GAAG,OAAO,EACd,IAAI,GAAG,SAAS,EAChB,GAAG,UAAU,EAChB,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,QAAQ,EAAwB,CAAC;AAC3D,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;AACpC,IAAA,MAAM,mBAAmB,GAAG,QAAQ,IAAI,aAAa,CAAC;AAEtD,IAAA,QACIA,IAAA,CAAA,OAAA,EAAA,EACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE;AACpD,YAAA,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,KAAK,aAAa;AAC/C,YAAA,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,KAAK,WAAW;SAC/C,CAAC,EACF,GAAG,EAAE,GAAG,EAAA,SAAA,EACC,aAAa,EAAA,kBAAA,EACJ,IAAI,EAAA,QAAA,EAAA,CAEtBC,GAAW,CAAA,OAAA,EAAA,EAAA,GAAA,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAA,CAAI,EAC7FA,GAAA,CAAC,WAAW,EACR,EAAA,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACA,YAAA,EAAA,SAAS,EACrB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EAAA,QAAA,EAET,QAAQ,EAAA,CACC,CACV,EAAA,CAAA,EACV;AACN,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,UAAU,CAAC,sBAAsB;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { cloneElement } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
6
|
+
|
|
7
|
+
var styles = {"input":"magritte-input___ctH9G_7-0-26","chip":"magritte-chip___uulZ9_7-0-26","chip-wrapper":"magritte-chip-wrapper___os8tP_7-0-26","chipWrapper":"magritte-chip-wrapper___os8tP_7-0-26","chip-wrapper__disabled":"magritte-chip-wrapper__disabled___mHM6-_7-0-26","chipWrapperDisabled":"magritte-chip-wrapper__disabled___mHM6-_7-0-26","content":"magritte-content___17f1s_7-0-26","size-extra-small":"magritte-size-extra-small___rVVLp_7-0-26","sizeExtraSmall":"magritte-size-extra-small___rVVLp_7-0-26","content__deletable":"magritte-content__deletable___iqF4W_7-0-26","contentDeletable":"magritte-content__deletable___iqF4W_7-0-26","addon":"magritte-addon___mlwVD_7-0-26","label-container":"magritte-label-container___VVRg1_7-0-26","labelContainer":"magritte-label-container___VVRg1_7-0-26","label":"magritte-label___NSEUN_7-0-26","postfix-wrapper":"magritte-postfix-wrapper___Qmxwy_7-0-26","postfixWrapper":"magritte-postfix-wrapper___Qmxwy_7-0-26","close":"magritte-close___5I1Fe_7-0-26","chip_style-neutral":"magritte-chip_style-neutral___gELi3_7-0-26","chipStyleNeutral":"magritte-chip_style-neutral___gELi3_7-0-26","postfix":"magritte-postfix___hgYUe_7-0-26","chip__checked":"magritte-chip__checked___3GRxf_7-0-26","chipChecked":"magritte-chip__checked___3GRxf_7-0-26","chip__custom":"magritte-chip__custom___mE-pN_7-0-26","chipCustom":"magritte-chip__custom___mE-pN_7-0-26","disabled":"magritte-disabled___CLRlf_7-0-26","chip_style-accent":"magritte-chip_style-accent___rD0pt_7-0-26","chipStyleAccent":"magritte-chip_style-accent___rD0pt_7-0-26","delete-only":"magritte-delete-only___dn3c7_7-0-26","deleteOnly":"magritte-delete-only___dn3c7_7-0-26","chip_secondary":"magritte-chip_secondary___druWa_7-0-26","chipSecondary":"magritte-chip_secondary___druWa_7-0-26","close_secondary":"magritte-close_secondary___7bJpC_7-0-26","closeSecondary":"magritte-close_secondary___7bJpC_7-0-26"};
|
|
8
|
+
|
|
9
|
+
const ChipContent = ({ addon, 'aria-label': ariaLabel, hideLabel, onDelete, postfix, children, size = 'small', mode = 'primary', }) => {
|
|
10
|
+
const showLabel = !hideLabel && !!children;
|
|
11
|
+
const typographyForPrimary = size === 'extra-small' ? 'subtitle-2-semibold' : 'subtitle-1-semibold';
|
|
12
|
+
const typography = mode === 'secondary' ? 'label-3-regular' : typographyForPrimary;
|
|
13
|
+
return (jsxs("span", { className: classnames(styles.content, {
|
|
14
|
+
[styles.contentDeletable]: !!onDelete,
|
|
15
|
+
}), children: [addon && (jsx("span", { className: styles.addon, children: cloneElement(addon, {
|
|
16
|
+
'data-qa': 'chip-addon',
|
|
17
|
+
'aria-label': ariaLabel,
|
|
18
|
+
'aria-hidden': showLabel,
|
|
19
|
+
}) })), showLabel && (jsxs("span", { className: styles.labelContainer, children: [jsx("span", { className: styles.label, children: jsx(Text, { Element: "span", typography: typography, children: children }) }), postfix && (jsx("span", { className: styles.postfixWrapper, children: jsx(Text, { Element: "span", typography: typography, children: jsx("span", { className: styles.postfix, children: postfix }) }) }))] }))] }));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { ChipContent as C, styles as s };
|
|
23
|
+
//# sourceMappingURL=ChipContent-Cjpr1LGC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipContent-
|
|
1
|
+
{"version":3,"file":"ChipContent-Cjpr1LGC.js","sources":["src/ChipContent.tsx"],"sourcesContent":["import { cloneElement, FC } from 'react';\nimport classnames from 'classnames';\n\nimport { CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './chips.less';\n\ntype ChipContentProps = Pick<\n CustomChipProps,\n 'addon' | 'hideLabel' | 'aria-label' | 'postfix' | 'onDelete' | 'children' | 'size' | 'mode'\n>;\n\nconst ChipContent: FC<ChipContentProps> = ({\n addon,\n 'aria-label': ariaLabel,\n hideLabel,\n onDelete,\n postfix,\n children,\n size = 'small',\n mode = 'primary',\n}) => {\n const showLabel = !hideLabel && !!children;\n const typographyForPrimary = size === 'extra-small' ? 'subtitle-2-semibold' : 'subtitle-1-semibold';\n const typography = mode === 'secondary' ? 'label-3-regular' : typographyForPrimary;\n return (\n <span\n className={classnames(styles.content, {\n [styles.contentDeletable]: !!onDelete,\n })}\n >\n {addon && (\n <span className={styles.addon}>\n {cloneElement(addon, {\n 'data-qa': 'chip-addon',\n 'aria-label': ariaLabel,\n 'aria-hidden': showLabel,\n })}\n </span>\n )}\n {showLabel && (\n <span className={styles.labelContainer}>\n <span className={styles.label}>\n <Text Element=\"span\" typography={typography}>\n {children}\n </Text>\n </span>\n {postfix && (\n <span className={styles.postfixWrapper}>\n <Text Element=\"span\" typography={typography}>\n <span className={styles.postfix}>{postfix}</span>\n </Text>\n </span>\n )}\n </span>\n )}\n </span>\n );\n};\n\nexport default ChipContent;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAaM,MAAA,WAAW,GAAyB,CAAC,EACvC,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,IAAI,GAAG,OAAO,EACd,IAAI,GAAG,SAAS,GACnB,KAAI;IACD,MAAM,SAAS,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC;AAC3C,IAAA,MAAM,oBAAoB,GAAG,IAAI,KAAK,aAAa,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AACpG,IAAA,MAAM,UAAU,GAAG,IAAI,KAAK,WAAW,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;IACnF,QACIA,eACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE;AAClC,YAAA,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC,QAAQ;AACxC,SAAA,CAAC,EAED,QAAA,EAAA,CAAA,KAAK,KACFC,cAAM,SAAS,EAAE,MAAM,CAAC,KAAK,EAAA,QAAA,EACxB,YAAY,CAAC,KAAK,EAAE;AACjB,oBAAA,SAAS,EAAE,YAAY;AACvB,oBAAA,YAAY,EAAE,SAAS;AACvB,oBAAA,aAAa,EAAE,SAAS;AAC3B,iBAAA,CAAC,EACC,CAAA,CACV,EACA,SAAS,KACND,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,cAAc,EAClC,QAAA,EAAA,CAAAC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,KAAK,EACzB,QAAA,EAAAA,GAAA,CAAC,IAAI,EAAA,EAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAE,UAAU,EAAA,QAAA,EACtC,QAAQ,EAAA,CACN,GACJ,EACN,OAAO,KACJA,GAAM,CAAA,MAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,cAAc,EAAA,QAAA,EAClCA,GAAC,CAAA,IAAI,IAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAE,UAAU,EACvC,QAAA,EAAAA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,OAAO,EAAG,QAAA,EAAA,OAAO,EAAQ,CAAA,EAAA,CAC9C,GACJ,CACV,CAAA,EAAA,CACE,CACV,CAAA,EAAA,CACE,EACT;AACN;;;;"}
|
package/ChipContent.js
CHANGED
|
@@ -3,5 +3,5 @@ import 'react/jsx-runtime';
|
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'classnames';
|
|
5
5
|
import '@hh.ru/magritte-ui-typography';
|
|
6
|
-
export { C as default } from './ChipContent-
|
|
6
|
+
export { C as default } from './ChipContent-Cjpr1LGC.js';
|
|
7
7
|
//# sourceMappingURL=ChipContent.js.map
|
package/ChipsContainer.js
CHANGED
|
@@ -6,11 +6,13 @@ import { CheckableChip } from './CheckableChip.js';
|
|
|
6
6
|
import { CustomChip } from './CustomChip.js';
|
|
7
7
|
import { ScrollableContainer, useGalleryContext, useScrollableControls } from '@hh.ru/magritte-ui-scrollable-container';
|
|
8
8
|
import '@hh.ru/magritte-common-use-disabled';
|
|
9
|
-
import './ChipContent-
|
|
9
|
+
import './ChipContent-Cjpr1LGC.js';
|
|
10
10
|
import '@hh.ru/magritte-ui-typography';
|
|
11
|
+
import './defaultProps.js';
|
|
12
|
+
import '@hh.ru/magritte-internal-default-props-context';
|
|
11
13
|
import '@hh.ru/magritte-ui-icon/variants/icon';
|
|
12
14
|
|
|
13
|
-
var styles = {"container":"magritte-container___o9zaa_7-0-
|
|
15
|
+
var styles = {"container":"magritte-container___o9zaa_7-0-26","scrollable":"magritte-scrollable___GhecO_7-0-26","item":"magritte-item___LBqGp_7-0-26","nowrap":"magritte-nowrap___ioKUP_7-0-26"};
|
|
14
16
|
|
|
15
17
|
const isValidCheckableChipElement = (child) => isValidElement(child) && child.type === CheckableChip;
|
|
16
18
|
const isValidCustomChipElement = (child) => isValidElement(child) && child.type === CustomChip;
|
package/ChipsContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipsContainer.js","sources":["src/ChipsContainer.tsx"],"sourcesContent":["import {\n type PropsWithChildren,\n type FC,\n type MouseEventHandler,\n type FocusEventHandler,\n useLayoutEffect,\n useRef,\n Children,\n cloneElement,\n ReactNode,\n ReactElement,\n isValidElement,\n Fragment,\n} from 'react';\nimport classnames from 'classnames';\n\nimport { CheckableChip } from '@hh.ru/magritte-ui-chips/CheckableChip';\nimport { CustomChip } from '@hh.ru/magritte-ui-chips/CustomChip';\nimport type { CheckableChipProps, ChipsContainerProps, CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { ScrollableContainer, useScrollableControls, useGalleryContext } from '@hh.ru/magritte-ui-scrollable-container';\n\nimport styles from './chips-container.less';\n\nconst isValidCheckableChipElement = (child: ReactNode): child is ReactElement<CheckableChipProps> =>\n isValidElement(child) && child.type === CheckableChip;\n\nconst isValidCustomChipElement = (child: ReactNode): child is ReactElement<CustomChipProps> =>\n isValidElement(child) && child.type === CustomChip;\n\nconst ContainerItem = ({\n children,\n}: {\n children: ReactElement<CheckableChipProps | CustomChipProps>;\n}): ReactElement => {\n const ref = useRef<HTMLDivElement>(null);\n const mouseDownRef = useRef(false);\n const { registerItem, removeItem } = useGalleryContext();\n const { scrollToItem } = useScrollableControls();\n useLayoutEffect(() => {\n registerItem(ref);\n return () => removeItem(ref);\n }, [registerItem, removeItem]);\n\n const handleClick: MouseEventHandler<HTMLElement> = (event) => {\n (children.props as React.DOMAttributes<HTMLElement>).onClick?.(event);\n scrollToItem(ref);\n mouseDownRef.current = false;\n };\n\n const handleFocus: FocusEventHandler<HTMLElement> = (event) => {\n (children.props as React.DOMAttributes<HTMLElement>).onFocus?.(event);\n // Проверка нужна для случая, когда клик длинный. Если не проверять, то произойдет скролл\n // и onClick не вызовется, потому что будет mousemove\n if (!mouseDownRef.current) {\n scrollToItem(ref);\n }\n };\n\n const handleMouseDown: MouseEventHandler<HTMLElement> = (event) => {\n (children.props as React.DOMAttributes<HTMLElement>).onMouseDown?.(event);\n mouseDownRef.current = true;\n };\n\n return (\n <div ref={ref} className={styles.item} role={'listitem'}>\n {cloneElement(children, {\n onClick: handleClick,\n onFocus: handleFocus,\n onMouseDown: handleMouseDown,\n })}\n </div>\n );\n};\n\nexport const ChipsContainer: FC<PropsWithChildren<ChipsContainerProps>> = ({\n children,\n noWrap = false,\n scrollable = false,\n 'data-qa': dataQa,\n ...containerProps\n}) => {\n const filteredChildren = Children.toArray(children).filter(\n (child): child is ReactElement<CheckableChipProps> | ReactElement<CustomChipProps> =>\n isValidCheckableChipElement(child) || isValidCustomChipElement(child)\n );\n\n if (!scrollable) {\n return (\n <div className={styles.container} {...containerProps} data-qa={dataQa || 'chips-container'}>\n {filteredChildren}\n </div>\n );\n }\n\n const WrapperComponent = noWrap ? ScrollableContainer.DefaultLayout : Fragment;\n return (\n <ScrollableContainer {...containerProps} data-qa={dataQa || 'chips-container'}>\n <WrapperComponent>\n <ScrollableContainer.Gallery>\n <div className={classnames(styles.container, styles.scrollable, noWrap && styles.nowrap)}>\n {Children.map(filteredChildren, (child) => (\n <ContainerItem>{child}</ContainerItem>\n ))}\n </div>\n </ScrollableContainer.Gallery>\n </WrapperComponent>\n </ScrollableContainer>\n );\n};\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChipsContainer.js","sources":["src/ChipsContainer.tsx"],"sourcesContent":["import {\n type PropsWithChildren,\n type FC,\n type MouseEventHandler,\n type FocusEventHandler,\n useLayoutEffect,\n useRef,\n Children,\n cloneElement,\n ReactNode,\n ReactElement,\n isValidElement,\n Fragment,\n} from 'react';\nimport classnames from 'classnames';\n\nimport { CheckableChip } from '@hh.ru/magritte-ui-chips/CheckableChip';\nimport { CustomChip } from '@hh.ru/magritte-ui-chips/CustomChip';\nimport type { CheckableChipProps, ChipsContainerProps, CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { ScrollableContainer, useScrollableControls, useGalleryContext } from '@hh.ru/magritte-ui-scrollable-container';\n\nimport styles from './chips-container.less';\n\nconst isValidCheckableChipElement = (child: ReactNode): child is ReactElement<CheckableChipProps> =>\n isValidElement(child) && child.type === CheckableChip;\n\nconst isValidCustomChipElement = (child: ReactNode): child is ReactElement<CustomChipProps> =>\n isValidElement(child) && child.type === CustomChip;\n\nconst ContainerItem = ({\n children,\n}: {\n children: ReactElement<CheckableChipProps | CustomChipProps>;\n}): ReactElement => {\n const ref = useRef<HTMLDivElement>(null);\n const mouseDownRef = useRef(false);\n const { registerItem, removeItem } = useGalleryContext();\n const { scrollToItem } = useScrollableControls();\n useLayoutEffect(() => {\n registerItem(ref);\n return () => removeItem(ref);\n }, [registerItem, removeItem]);\n\n const handleClick: MouseEventHandler<HTMLElement> = (event) => {\n (children.props as React.DOMAttributes<HTMLElement>).onClick?.(event);\n scrollToItem(ref);\n mouseDownRef.current = false;\n };\n\n const handleFocus: FocusEventHandler<HTMLElement> = (event) => {\n (children.props as React.DOMAttributes<HTMLElement>).onFocus?.(event);\n // Проверка нужна для случая, когда клик длинный. Если не проверять, то произойдет скролл\n // и onClick не вызовется, потому что будет mousemove\n if (!mouseDownRef.current) {\n scrollToItem(ref);\n }\n };\n\n const handleMouseDown: MouseEventHandler<HTMLElement> = (event) => {\n (children.props as React.DOMAttributes<HTMLElement>).onMouseDown?.(event);\n mouseDownRef.current = true;\n };\n\n return (\n <div ref={ref} className={styles.item} role={'listitem'}>\n {cloneElement(children, {\n onClick: handleClick,\n onFocus: handleFocus,\n onMouseDown: handleMouseDown,\n })}\n </div>\n );\n};\n\nexport const ChipsContainer: FC<PropsWithChildren<ChipsContainerProps>> = ({\n children,\n noWrap = false,\n scrollable = false,\n 'data-qa': dataQa,\n ...containerProps\n}) => {\n const filteredChildren = Children.toArray(children).filter(\n (child): child is ReactElement<CheckableChipProps> | ReactElement<CustomChipProps> =>\n isValidCheckableChipElement(child) || isValidCustomChipElement(child)\n );\n\n if (!scrollable) {\n return (\n <div className={styles.container} {...containerProps} data-qa={dataQa || 'chips-container'}>\n {filteredChildren}\n </div>\n );\n }\n\n const WrapperComponent = noWrap ? ScrollableContainer.DefaultLayout : Fragment;\n return (\n <ScrollableContainer {...containerProps} data-qa={dataQa || 'chips-container'}>\n <WrapperComponent>\n <ScrollableContainer.Gallery>\n <div className={classnames(styles.container, styles.scrollable, noWrap && styles.nowrap)}>\n {Children.map(filteredChildren, (child) => (\n <ContainerItem>{child}</ContainerItem>\n ))}\n </div>\n </ScrollableContainer.Gallery>\n </WrapperComponent>\n </ScrollableContainer>\n );\n};\n"],"names":["_jsx"],"mappings":"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"}
|
package/CustomChip.js
CHANGED
|
@@ -3,15 +3,19 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
|
|
6
|
-
import { s as styles, C as ChipContent } from './ChipContent-
|
|
6
|
+
import { s as styles, C as ChipContent } from './ChipContent-Cjpr1LGC.js';
|
|
7
|
+
import { useChipDefaultProps } from './defaultProps.js';
|
|
7
8
|
import { CrossOutlinedSize16, CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/variants/icon';
|
|
8
9
|
import '@hh.ru/magritte-ui-typography';
|
|
10
|
+
import '@hh.ru/magritte-internal-default-props-context';
|
|
9
11
|
|
|
10
12
|
const STYLE_TO_CSS = {
|
|
11
13
|
neutral: styles.chipStyleNeutral,
|
|
12
14
|
accent: styles.chipStyleAccent,
|
|
13
15
|
};
|
|
14
|
-
const CustomChipComponent = (
|
|
16
|
+
const CustomChipComponent = (rawProps, ref) => {
|
|
17
|
+
const defaultProps = useChipDefaultProps();
|
|
18
|
+
const { Element = 'button', addon, style = 'neutral', postfix, onDelete, deleteOnly = false, checked = false, disabled = false, 'aria-label': ariaLabel, hideLabel, dataQaWrapper = 'chip', children, size = 'small', mode = 'primary', deleteButtonAriaLabel, ...buttonProps } = { ...defaultProps, ...rawProps };
|
|
15
19
|
const forceDisabled = useDisabled();
|
|
16
20
|
const isComponentDisabled = disabled || forceDisabled;
|
|
17
21
|
let additionalAttributes;
|
|
@@ -36,7 +40,7 @@ const CustomChipComponent = ({ Element = 'button', addon, style = 'neutral', pos
|
|
|
36
40
|
[styles.sizeExtraSmall]: size === 'extra-small',
|
|
37
41
|
[styles.disabled]: isComponentDisabled,
|
|
38
42
|
[styles.chipSecondary]: mode === 'secondary',
|
|
39
|
-
}), disabled: isComponentDisabled || deleteOnly, children: jsx(ChipContent, { postfix: postfix, onDelete: onDelete, addon: addon, "aria-label": ariaLabel, hideLabel: hideLabel, size: size, mode: mode, children: children }) }), onDelete && (jsx("
|
|
43
|
+
}), disabled: isComponentDisabled || deleteOnly, children: jsx(ChipContent, { postfix: postfix, onDelete: onDelete, addon: addon, "aria-label": ariaLabel, hideLabel: hideLabel, size: size, mode: mode, children: children }) }), onDelete && (jsx("div", { className: classnames(styles.close, { [styles.closeSecondary]: mode === 'secondary' }), children: size === 'extra-small' || mode === 'secondary' ? (jsx(CrossOutlinedSize16, { padding: 8, "data-qa": "chip-delete-action", onClick: onDelete, disabled: isComponentDisabled, borderRadius: "halfHeight", "aria-label": deleteButtonAriaLabel })) : (jsx(CrossOutlinedSize24, { padding: 8, "data-qa": "chip-delete-action", onClick: onDelete, disabled: isComponentDisabled, borderRadius: "halfHeight", "aria-label": deleteButtonAriaLabel })) }))] }));
|
|
40
44
|
};
|
|
41
45
|
const CustomChip = forwardRef(CustomChipComponent);
|
|
42
46
|
|
package/CustomChip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomChip.js","sources":["src/CustomChip.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport type { PolymorphicForwardRefRenderFunc, PolymorphicComponentWithRef } from '@hh.ru/magritte-types';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport type { CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { CrossOutlinedSize24, CrossOutlinedSize16 } from '@hh.ru/magritte-ui-icon/variants/icon';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CustomChipComponent: PolymorphicForwardRefRenderFunc<CustomChipProps, 'button'> = (\n {\n Element = 'button',\n addon,\n style = 'neutral',\n postfix,\n onDelete,\n deleteOnly = false,\n checked = false,\n disabled = false,\n 'aria-label': ariaLabel,\n hideLabel,\n dataQaWrapper = 'chip',\n children,\n size = 'small',\n mode = 'primary',\n deleteButtonAriaLabel,\n ...buttonProps\n }
|
|
1
|
+
{"version":3,"file":"CustomChip.js","sources":["src/CustomChip.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport type { PolymorphicForwardRefRenderFunc, PolymorphicComponentWithRef } from '@hh.ru/magritte-types';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport { useChipDefaultProps } from '@hh.ru/magritte-ui-chips/defaultProps';\nimport type { CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { CrossOutlinedSize24, CrossOutlinedSize16 } from '@hh.ru/magritte-ui-icon/variants/icon';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CustomChipComponent: PolymorphicForwardRefRenderFunc<CustomChipProps, 'button'> = (rawProps, ref) => {\n const defaultProps = useChipDefaultProps();\n const {\n Element = 'button',\n addon,\n style = 'neutral',\n postfix,\n onDelete,\n deleteOnly = false,\n checked = false,\n disabled = false,\n 'aria-label': ariaLabel,\n hideLabel,\n dataQaWrapper = 'chip',\n children,\n size = 'small',\n mode = 'primary',\n deleteButtonAriaLabel,\n ...buttonProps\n } = { ...defaultProps, ...rawProps } as typeof rawProps;\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n let additionalAttributes: Record<string, unknown>;\n\n if (Element === 'button') {\n additionalAttributes = {\n type: 'button',\n tabIndex: isComponentDisabled || deleteOnly ? -1 : 0,\n };\n } else {\n additionalAttributes = {\n tabIndex: isComponentDisabled || deleteOnly ? -1 : 0,\n 'aria-disabled': disabled,\n };\n }\n\n if (ref) {\n additionalAttributes.ref = ref;\n }\n\n return (\n <div\n className={classnames(styles.chipWrapper, isComponentDisabled && styles.chipWrapperDisabled)}\n data-qa={dataQaWrapper}\n >\n <Element\n {...additionalAttributes}\n {...buttonProps}\n className={classnames(styles.chip, styles.chipCustom, STYLE_TO_CSS[style], {\n [styles.chipChecked]: checked,\n [styles.deleteOnly]: deleteOnly,\n [styles.sizeExtraSmall]: size === 'extra-small',\n [styles.disabled]: isComponentDisabled,\n [styles.chipSecondary]: mode === 'secondary',\n })}\n disabled={isComponentDisabled || deleteOnly}\n >\n <ChipContent\n postfix={postfix}\n onDelete={onDelete}\n addon={addon}\n aria-label={ariaLabel}\n hideLabel={hideLabel}\n size={size}\n mode={mode}\n >\n {children}\n </ChipContent>\n </Element>\n {onDelete && (\n <div className={classnames(styles.close, { [styles.closeSecondary]: mode === 'secondary' })}>\n {size === 'extra-small' || mode === 'secondary' ? (\n <CrossOutlinedSize16\n padding={8}\n data-qa=\"chip-delete-action\"\n onClick={onDelete}\n disabled={isComponentDisabled}\n borderRadius=\"halfHeight\"\n aria-label={deleteButtonAriaLabel}\n />\n ) : (\n <CrossOutlinedSize24\n padding={8}\n data-qa=\"chip-delete-action\"\n onClick={onDelete}\n disabled={isComponentDisabled}\n borderRadius=\"halfHeight\"\n aria-label={deleteButtonAriaLabel}\n />\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport const CustomChip = forwardRef(CustomChipComponent) as PolymorphicComponentWithRef<CustomChipProps, 'button'>;\n"],"names":["_jsxs","_jsx"],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChipCommonProps } from '@hh.ru/magritte-ui-chips/types';
|
|
2
|
+
/**
|
|
3
|
+
* Провайдер дефолтных пропсов для чипсов в поддереве.
|
|
4
|
+
* Заданные пропсы применяются ко всем `CustomChip` и `CheckableChip` внутри как дефолтные —
|
|
5
|
+
* явные пропсы на самом чипсе побеждают.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ChipDefaultPropsContext: import("react").FC<import("@hh.ru/magritte-internal-default-props-context").BoundDefaultPropsContextProps<ChipCommonProps>>;
|
|
8
|
+
export declare const useChipDefaultProps: () => Partial<ChipCommonProps>;
|
package/defaultProps.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { createDefaultPropsContext } from '@hh.ru/magritte-internal-default-props-context';
|
|
3
|
+
|
|
4
|
+
const { DefaultPropsContext, useDefaultProps } = createDefaultPropsContext('Chip');
|
|
5
|
+
/**
|
|
6
|
+
* Провайдер дефолтных пропсов для чипсов в поддереве.
|
|
7
|
+
* Заданные пропсы применяются ко всем `CustomChip` и `CheckableChip` внутри как дефолтные —
|
|
8
|
+
* явные пропсы на самом чипсе побеждают.
|
|
9
|
+
*/
|
|
10
|
+
const ChipDefaultPropsContext = DefaultPropsContext;
|
|
11
|
+
const useChipDefaultProps = useDefaultProps;
|
|
12
|
+
|
|
13
|
+
export { ChipDefaultPropsContext, useChipDefaultProps };
|
|
14
|
+
//# sourceMappingURL=defaultProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultProps.js","sources":["src/defaultProps.ts"],"sourcesContent":["import { createDefaultPropsContext } from '@hh.ru/magritte-internal-default-props-context';\nimport type { ChipCommonProps } from '@hh.ru/magritte-ui-chips/types';\n\nconst { DefaultPropsContext, useDefaultProps } = createDefaultPropsContext<ChipCommonProps>('Chip');\n\n/**\n * Провайдер дефолтных пропсов для чипсов в поддереве.\n * Заданные пропсы применяются ко всем `CustomChip` и `CheckableChip` внутри как дефолтные —\n * явные пропсы на самом чипсе побеждают.\n */\nexport const ChipDefaultPropsContext = DefaultPropsContext;\n\nexport const useChipDefaultProps = useDefaultProps;\n"],"names":[],"mappings":";;AAGA,MAAM,EAAE,mBAAmB,EAAE,eAAe,EAAE,GAAG,yBAAyB,CAAkB,MAAM,CAAC,CAAC;AAEpG;;;;AAIG;AACI,MAAM,uBAAuB,GAAG,oBAAoB;AAEpD,MAAM,mBAAmB,GAAG;;;;"}
|