@hh.ru/magritte-ui-bottom-sheet 9.4.48 → 9.4.49
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/BottomSheet.d.ts +2 -2
- package/BottomSheet.js +948 -888
- package/BottomSheet.js.map +1 -1
- package/BottomSheetContext.d.ts +1 -1
- package/BottomSheetContext.js.map +1 -1
- package/BottomSheetFooter.js +2 -2
- package/BottomSheetFooter.js.map +1 -1
- package/BottomSheetIFrameAdapter.js +18 -15
- package/BottomSheetIFrameAdapter.js.map +1 -1
- package/BottomSheetMedia.js +25 -14
- package/BottomSheetMedia.js.map +1 -1
- package/BottomSheetWithImage.d.ts +1 -1
- package/BottomSheetWithImage.js +31 -7
- package/BottomSheetWithImage.js.map +1 -1
- package/ClickInterceptor.js +43 -47
- package/ClickInterceptor.js.map +1 -1
- package/actionBarDefaults.d.ts +1 -1
- package/actionBarDefaults.js +3 -18
- package/actionBarDefaults.js.map +1 -1
- package/bottom-sheet-DRUdtPUr.js +5 -0
- package/bottom-sheet-DRUdtPUr.js.map +1 -0
- package/index.css +79 -79
- package/index.d.ts +6 -6
- package/index.js +1 -1
- package/index.mock.d.ts +2 -2
- package/index.mock.js +23 -11
- package/index.mock.js.map +1 -1
- package/package.json +10 -10
- package/withImageDefaults.d.ts +2 -2
- package/withImageDefaults.js +5 -19
- package/withImageDefaults.js.map +1 -1
- package/bottom-sheet-kKgvx4B-.js +0 -5
- package/bottom-sheet-kKgvx4B-.js.map +0 -1
package/BottomSheetMedia.js
CHANGED
|
@@ -3,21 +3,32 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
|
|
6
|
-
var styles = {"media":"magritte-media___fzaJa_9-4-
|
|
6
|
+
var styles = {"media":"magritte-media___fzaJa_9-4-49","contain":"magritte-contain___Hu7Gu_9-4-49","cover":"magritte-cover___sueew_9-4-49"};
|
|
7
7
|
|
|
8
|
-
const BottomSheetMedia = forwardRef(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
const BottomSheetMedia = forwardRef(
|
|
9
|
+
({ backgroundUrl, children, className, height, imageSize, ratio, style, ...props }, ref) => {
|
|
10
|
+
const defaultRatio = children ? "auto" : 1.9;
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
...props,
|
|
15
|
+
className: classnames(className, styles.media, {
|
|
16
|
+
[styles.cover]: imageSize === "cover",
|
|
17
|
+
[styles.contain]: imageSize === "contain"
|
|
18
|
+
}),
|
|
19
|
+
ref,
|
|
20
|
+
style: {
|
|
21
|
+
...style,
|
|
22
|
+
aspectRatio: ratio ?? defaultRatio,
|
|
23
|
+
backgroundImage: backgroundUrl ? `url(${backgroundUrl})` : "none",
|
|
24
|
+
height: height ? `${height}px` : "auto"
|
|
25
|
+
},
|
|
26
|
+
children
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
BottomSheetMedia.displayName = "BottomSheet.Media";
|
|
21
32
|
|
|
22
33
|
export { BottomSheetMedia };
|
|
23
34
|
//# sourceMappingURL=BottomSheetMedia.js.map
|
package/BottomSheetMedia.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetMedia.js","sources":["src/BottomSheetMedia.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport styles from './bottom-sheet-media.less';\n\ninterface BottomSheetMediaProps extends React.HTMLAttributes<HTMLDivElement>, React.PropsWithChildren {\n ratio?: number;\n height?: number;\n backgroundUrl?: string;\n imageSize?: 'cover' | 'contain';\n}\n\nexport const BottomSheetMedia = forwardRef<HTMLDivElement, BottomSheetMediaProps>(\n ({ backgroundUrl, children, className, height, imageSize, ratio, style, ...props }, ref) => {\n const defaultRatio = children ? 'auto' : 1.9;\n\n return (\n <div\n {...props}\n className={classnames(className, styles.media, {\n [styles.cover]: imageSize === 'cover',\n [styles.contain]: imageSize === 'contain',\n })}\n ref={ref}\n style={{\n ...style,\n aspectRatio: ratio ?? defaultRatio,\n backgroundImage: backgroundUrl ? `url(${backgroundUrl})` : 'none',\n height: height ? `${height}px` : 'auto',\n }}\n >\n {children}\n </div>\n );\n }\n);\n\nBottomSheetMedia.displayName = 'BottomSheet.Media';\n"],"names":[
|
|
1
|
+
{"version":3,"file":"BottomSheetMedia.js","sources":["src/BottomSheetMedia.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport styles from './bottom-sheet-media.less';\n\ninterface BottomSheetMediaProps extends React.HTMLAttributes<HTMLDivElement>, React.PropsWithChildren {\n ratio?: number;\n height?: number;\n backgroundUrl?: string;\n imageSize?: 'cover' | 'contain';\n}\n\nexport const BottomSheetMedia = forwardRef<HTMLDivElement, BottomSheetMediaProps>(\n ({ backgroundUrl, children, className, height, imageSize, ratio, style, ...props }, ref) => {\n const defaultRatio = children ? 'auto' : 1.9;\n\n return (\n <div\n {...props}\n className={classnames(className, styles.media, {\n [styles.cover]: imageSize === 'cover',\n [styles.contain]: imageSize === 'contain',\n })}\n ref={ref}\n style={{\n ...style,\n aspectRatio: ratio ?? defaultRatio,\n backgroundImage: backgroundUrl ? `url(${backgroundUrl})` : 'none',\n height: height ? `${height}px` : 'auto',\n }}\n >\n {children}\n </div>\n );\n }\n);\n\nBottomSheetMedia.displayName = 'BottomSheet.Media';\n"],"names":[],"mappings":";;;;;;AAYO,MAAM,gBAAmB,GAAA,UAAA;AAAA,EAC5B,CAAC,EAAE,aAAe,EAAA,QAAA,EAAU,SAAW,EAAA,MAAA,EAAQ,SAAW,EAAA,KAAA,EAAO,KAAO,EAAA,GAAG,KAAM,EAAA,EAAG,GAAQ,KAAA;AACxF,IAAM,MAAA,YAAA,GAAe,WAAW,MAAS,GAAA,GAAA,CAAA;AAEzC,IACI,uBAAA,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACI,GAAG,KAAA;AAAA,QACJ,SAAW,EAAA,UAAA,CAAW,SAAW,EAAA,MAAA,CAAO,KAAO,EAAA;AAAA,UAC3C,CAAC,MAAA,CAAO,KAAK,GAAG,SAAc,KAAA,OAAA;AAAA,UAC9B,CAAC,MAAA,CAAO,OAAO,GAAG,SAAc,KAAA,SAAA;AAAA,SACnC,CAAA;AAAA,QACD,GAAA;AAAA,QACA,KAAO,EAAA;AAAA,UACH,GAAG,KAAA;AAAA,UACH,aAAa,KAAS,IAAA,YAAA;AAAA,UACtB,eAAiB,EAAA,aAAA,GAAgB,CAAO,IAAA,EAAA,aAAa,CAAM,CAAA,CAAA,GAAA,MAAA;AAAA,UAC3D,MAAQ,EAAA,MAAA,GAAS,CAAG,EAAA,MAAM,CAAO,EAAA,CAAA,GAAA,MAAA;AAAA,SACrC;AAAA,QAEC,QAAA;AAAA,OAAA;AAAA,KACL,CAAA;AAAA,GAER;AACJ,EAAA;AAEA,gBAAA,CAAiB,WAAc,GAAA,mBAAA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BottomSheetProps } from '
|
|
1
|
+
import { type BottomSheetProps } from './types';
|
|
2
2
|
export interface BottomSheetWithImageProps {
|
|
3
3
|
/** Картинка/иконка/видео/кастомный контент, обернутые в `<BottomSheet.Media />` */
|
|
4
4
|
image: React.ReactNode;
|
package/BottomSheetWithImage.js
CHANGED
|
@@ -27,18 +27,42 @@ import '@hh.ru/magritte-ui-layer';
|
|
|
27
27
|
import '@hh.ru/magritte-ui-textarea';
|
|
28
28
|
import '@hh.ru/magritte-ui-theme-wrapper';
|
|
29
29
|
import '@hh.ru/magritte-ui-tree-selector';
|
|
30
|
-
import './bottom-sheet-
|
|
30
|
+
import './bottom-sheet-DRUdtPUr.js';
|
|
31
31
|
|
|
32
|
-
var styles = {"top-padding":"magritte-top-padding___SfKyV_9-4-
|
|
32
|
+
var styles = {"top-padding":"magritte-top-padding___SfKyV_9-4-49","topPadding":"magritte-top-padding___SfKyV_9-4-49","title-wrapper":"magritte-title-wrapper___EqVH0_9-4-49","titleWrapper":"magritte-title-wrapper___EqVH0_9-4-49","content-wrapper":"magritte-content-wrapper___Y-au-_9-4-49","contentWrapper":"magritte-content-wrapper___Y-au-_9-4-49"};
|
|
33
33
|
|
|
34
|
-
// The values live in `withImageDefaults` because the Code Connect template reads them too (a nested snippet
|
|
35
|
-
// must not repeat what this wrapper already supplies). They are re-declared here with their context types so
|
|
36
|
-
// the plain-data module stays compile-checked against the props it is meant to fill.
|
|
37
34
|
const NAV_BAR_DEFAULT_PROPS = BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_DEFAULTS;
|
|
38
35
|
const NAV_BAR_ACTIONS_ICONS_DEFAULT_PROPS = BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_ICON_DEFAULTS;
|
|
39
36
|
const TITLE_DEFAULT_PROPS = BOTTOM_SHEET_WITH_IMAGE_TITLE_DEFAULTS;
|
|
40
|
-
const BottomSheetWithImage = ({
|
|
41
|
-
|
|
37
|
+
const BottomSheetWithImage = ({
|
|
38
|
+
children,
|
|
39
|
+
image,
|
|
40
|
+
title,
|
|
41
|
+
header,
|
|
42
|
+
...props
|
|
43
|
+
}) => {
|
|
44
|
+
return /* @__PURE__ */ jsx(NavBar.TriggerProvider, { children: /* @__PURE__ */ jsxs(
|
|
45
|
+
BottomSheet,
|
|
46
|
+
{
|
|
47
|
+
...props,
|
|
48
|
+
header: /* @__PURE__ */ jsxs(
|
|
49
|
+
NavBarDefaultPropsContext,
|
|
50
|
+
{
|
|
51
|
+
rootProps: NAV_BAR_DEFAULT_PROPS,
|
|
52
|
+
actionsIconsProps: NAV_BAR_ACTIONS_ICONS_DEFAULT_PROPS,
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx("div", { className: styles.topPadding }),
|
|
55
|
+
header
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
children: [
|
|
60
|
+
image,
|
|
61
|
+
title && /* @__PURE__ */ jsx(TitleDefaultPropsContext, { props: TITLE_DEFAULT_PROPS, children: /* @__PURE__ */ jsx("div", { className: styles.titleWrapper, children: title }) }),
|
|
62
|
+
children && /* @__PURE__ */ jsx("div", { className: styles.contentWrapper, children })
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
) });
|
|
42
66
|
};
|
|
43
67
|
|
|
44
68
|
export { BottomSheetWithImage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetWithImage.js","sources":["src/BottomSheetWithImage.tsx"],"sourcesContent":["import { BottomSheet } from '@hh.ru/magritte-ui-bottom-sheet/BottomSheet';\nimport { type BottomSheetProps } from '@hh.ru/magritte-ui-bottom-sheet/types';\nimport {\n BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_DEFAULTS,\n BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_ICON_DEFAULTS,\n BOTTOM_SHEET_WITH_IMAGE_TITLE_DEFAULTS,\n} from '@hh.ru/magritte-ui-bottom-sheet/withImageDefaults';\nimport { type NavBarDefaultPropsContextProps, NavBar, NavBarDefaultPropsContext } from '@hh.ru/magritte-ui-nav-bar';\nimport { type TitleProps, TitleDefaultPropsContext } from '@hh.ru/magritte-ui-title';\n\nimport styles from './bottom-sheet-with-image.less';\n\n// The values live in `withImageDefaults` because the Code Connect template reads them too (a nested snippet\n// must not repeat what this wrapper already supplies). They are re-declared here with their context types so\n// the plain-data module stays compile-checked against the props it is meant to fill.\nconst NAV_BAR_DEFAULT_PROPS: NavBarDefaultPropsContextProps['rootProps'] = BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_DEFAULTS;\n\nconst NAV_BAR_ACTIONS_ICONS_DEFAULT_PROPS: NavBarDefaultPropsContextProps['actionsIconsProps'] =\n BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_ICON_DEFAULTS;\n\nconst TITLE_DEFAULT_PROPS: Partial<TitleProps> = BOTTOM_SHEET_WITH_IMAGE_TITLE_DEFAULTS;\n\nexport interface BottomSheetWithImageProps {\n /** Картинка/иконка/видео/кастомный контент, обернутые в `<BottomSheet.Media />` */\n image: React.ReactNode;\n /** <Title /> */\n title?: React.ReactNode;\n}\n\nexport const BottomSheetWithImage: React.FC<BottomSheetProps & BottomSheetWithImageProps> = ({\n children,\n image,\n title,\n header,\n ...props\n}) => {\n return (\n <NavBar.TriggerProvider>\n <BottomSheet\n {...props}\n header={\n <NavBarDefaultPropsContext\n rootProps={NAV_BAR_DEFAULT_PROPS}\n actionsIconsProps={NAV_BAR_ACTIONS_ICONS_DEFAULT_PROPS}\n >\n <div className={styles.topPadding} />\n {header}\n </NavBarDefaultPropsContext>\n }\n >\n {image}\n {title && (\n <TitleDefaultPropsContext props={TITLE_DEFAULT_PROPS}>\n <div className={styles.titleWrapper}>{title}</div>\n </TitleDefaultPropsContext>\n )}\n {children && <div className={styles.contentWrapper}>{children}</div>}\n </BottomSheet>\n </NavBar.TriggerProvider>\n );\n};\n"],"names":[
|
|
1
|
+
{"version":3,"file":"BottomSheetWithImage.js","sources":["src/BottomSheetWithImage.tsx"],"sourcesContent":["import { BottomSheet } from '@hh.ru/magritte-ui-bottom-sheet/BottomSheet';\nimport { type BottomSheetProps } from '@hh.ru/magritte-ui-bottom-sheet/types';\nimport {\n BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_DEFAULTS,\n BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_ICON_DEFAULTS,\n BOTTOM_SHEET_WITH_IMAGE_TITLE_DEFAULTS,\n} from '@hh.ru/magritte-ui-bottom-sheet/withImageDefaults';\nimport { type NavBarDefaultPropsContextProps, NavBar, NavBarDefaultPropsContext } from '@hh.ru/magritte-ui-nav-bar';\nimport { type TitleProps, TitleDefaultPropsContext } from '@hh.ru/magritte-ui-title';\n\nimport styles from './bottom-sheet-with-image.less';\n\n// The values live in `withImageDefaults` because the Code Connect template reads them too (a nested snippet\n// must not repeat what this wrapper already supplies). They are re-declared here with their context types so\n// the plain-data module stays compile-checked against the props it is meant to fill.\nconst NAV_BAR_DEFAULT_PROPS: NavBarDefaultPropsContextProps['rootProps'] = BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_DEFAULTS;\n\nconst NAV_BAR_ACTIONS_ICONS_DEFAULT_PROPS: NavBarDefaultPropsContextProps['actionsIconsProps'] =\n BOTTOM_SHEET_WITH_IMAGE_NAV_BAR_ICON_DEFAULTS;\n\nconst TITLE_DEFAULT_PROPS: Partial<TitleProps> = BOTTOM_SHEET_WITH_IMAGE_TITLE_DEFAULTS;\n\nexport interface BottomSheetWithImageProps {\n /** Картинка/иконка/видео/кастомный контент, обернутые в `<BottomSheet.Media />` */\n image: React.ReactNode;\n /** <Title /> */\n title?: React.ReactNode;\n}\n\nexport const BottomSheetWithImage: React.FC<BottomSheetProps & BottomSheetWithImageProps> = ({\n children,\n image,\n title,\n header,\n ...props\n}) => {\n return (\n <NavBar.TriggerProvider>\n <BottomSheet\n {...props}\n header={\n <NavBarDefaultPropsContext\n rootProps={NAV_BAR_DEFAULT_PROPS}\n actionsIconsProps={NAV_BAR_ACTIONS_ICONS_DEFAULT_PROPS}\n >\n <div className={styles.topPadding} />\n {header}\n </NavBarDefaultPropsContext>\n }\n >\n {image}\n {title && (\n <TitleDefaultPropsContext props={TITLE_DEFAULT_PROPS}>\n <div className={styles.titleWrapper}>{title}</div>\n </TitleDefaultPropsContext>\n )}\n {children && <div className={styles.contentWrapper}>{children}</div>}\n </BottomSheet>\n </NavBar.TriggerProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,qBAAqE,GAAA,wCAAA,CAAA;AAE3E,MAAM,mCACF,GAAA,6CAAA,CAAA;AAEJ,MAAM,mBAA2C,GAAA,sCAAA,CAAA;AAS1C,MAAM,uBAA+E,CAAC;AAAA,EACzF,QAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG,KAAA;AACP,CAAM,KAAA;AACF,EACI,uBAAA,GAAA,CAAC,MAAO,CAAA,eAAA,EAAP,EACG,QAAA,kBAAA,IAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACI,GAAG,KAAA;AAAA,MACJ,MACI,kBAAA,IAAA;AAAA,QAAC,yBAAA;AAAA,QAAA;AAAA,UACG,SAAW,EAAA,qBAAA;AAAA,UACX,iBAAmB,EAAA,mCAAA;AAAA,UAEnB,QAAA,EAAA;AAAA,4BAAC,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,MAAA,CAAO,UAAY,EAAA,CAAA;AAAA,YAClC,MAAA;AAAA,WAAA;AAAA,SAAA;AAAA,OACL;AAAA,MAGH,QAAA,EAAA;AAAA,QAAA,KAAA;AAAA,QACA,KAAA,oBACI,GAAA,CAAA,wBAAA,EAAA,EAAyB,KAAO,EAAA,mBAAA,EAC7B,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,MAAA,CAAO,YAAe,EAAA,QAAA,EAAA,KAAA,EAAM,CAChD,EAAA,CAAA;AAAA,QAEH,4BAAa,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,MAAA,CAAO,gBAAiB,QAAS,EAAA,CAAA;AAAA,OAAA;AAAA,KAAA;AAAA,GAEtE,EAAA,CAAA,CAAA;AAER;;;;"}
|
package/ClickInterceptor.js
CHANGED
|
@@ -4,59 +4,55 @@ import { memo, isValidElement, Fragment, Children, cloneElement } from 'react';
|
|
|
4
4
|
|
|
5
5
|
const CLICK_DISTANCE_THRESHOLD_PX = 24;
|
|
6
6
|
const interceptClick = (node) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return cloneElement(node, props);
|
|
7
|
+
const props = {};
|
|
8
|
+
if (node.props.onClick) {
|
|
9
|
+
let click = false;
|
|
10
|
+
let coordinates = null;
|
|
11
|
+
props.onClick = () => {
|
|
12
|
+
};
|
|
13
|
+
props.onPointerDown = (event) => {
|
|
14
|
+
click = true;
|
|
15
|
+
coordinates = { x: event.pageX, y: event.pageY };
|
|
16
|
+
node.props.onPointerDown?.(event);
|
|
17
|
+
};
|
|
18
|
+
props.onPointerCancel = (event) => {
|
|
19
|
+
click = false;
|
|
20
|
+
node.props.onPointerCancel?.(event);
|
|
21
|
+
};
|
|
22
|
+
props.onPointerLeave = (event) => {
|
|
23
|
+
click = false;
|
|
24
|
+
node.props.onPointerLeave?.(event);
|
|
25
|
+
};
|
|
26
|
+
props.onPointerUp = (event) => {
|
|
27
|
+
if (click) {
|
|
28
|
+
if (coordinates !== null && Math.pow(event.pageX - coordinates.x, 2) + Math.pow(event.pageY - coordinates.y, 2) <= Math.pow(CLICK_DISTANCE_THRESHOLD_PX, 2)) {
|
|
29
|
+
node.props.onClick?.(event);
|
|
30
|
+
}
|
|
31
|
+
click = false;
|
|
32
|
+
coordinates = null;
|
|
33
|
+
}
|
|
34
|
+
node.props.onPointerUp?.(event);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return cloneElement(node, props);
|
|
39
38
|
};
|
|
40
39
|
const applyInterceptor = (node, func) => {
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (!isValidElement(node)) {
|
|
41
|
+
return /* @__PURE__ */ jsx(Fragment, { children: node });
|
|
42
|
+
}
|
|
43
|
+
let children;
|
|
44
|
+
((props) => {
|
|
45
|
+
if (props.children) {
|
|
46
|
+
const childrenArr = Children.toArray(props.children);
|
|
47
|
+
children = childrenArr.length === 1 ? applyInterceptor(childrenArr[0], func) : childrenArr.map((child) => applyInterceptor(child, func));
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (props.children) {
|
|
47
|
-
const childrenArr = Children.toArray(props.children);
|
|
48
|
-
children =
|
|
49
|
-
childrenArr.length === 1
|
|
50
|
-
? applyInterceptor(childrenArr[0], func)
|
|
51
|
-
: childrenArr.map((child) => applyInterceptor(child, func));
|
|
52
|
-
}
|
|
53
|
-
})(node.props);
|
|
54
|
-
return cloneElement(func(node), {}, children);
|
|
49
|
+
})(node.props);
|
|
50
|
+
return cloneElement(func(node), {}, children);
|
|
55
51
|
};
|
|
56
52
|
const ClickInterceptor = memo(({ children }) => {
|
|
57
|
-
|
|
53
|
+
return applyInterceptor(children, interceptClick);
|
|
58
54
|
});
|
|
59
|
-
ClickInterceptor.displayName =
|
|
55
|
+
ClickInterceptor.displayName = "ClickInterceptor";
|
|
60
56
|
|
|
61
57
|
export { ClickInterceptor };
|
|
62
58
|
//# sourceMappingURL=ClickInterceptor.js.map
|
package/ClickInterceptor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickInterceptor.js","sources":["src/ClickInterceptor.tsx"],"sourcesContent":["import {\n Children,\n DOMAttributes,\n FC,\n Fragment,\n ReactElement,\n ReactNode,\n cloneElement,\n isValidElement,\n memo,\n} from 'react';\n\ntype InterceptedProps = Pick<\n DOMAttributes<HTMLElement>,\n 'onClick' | 'onPointerDown' | 'onPointerCancel' | 'onPointerLeave' | 'onPointerUp'\n>;\n\nconst CLICK_DISTANCE_THRESHOLD_PX = 24;\n\nconst interceptClick = (node: ReactElement<InterceptedProps>) => {\n const props: InterceptedProps = {};\n\n if (node.props.onClick) {\n let click = false;\n let coordinates: { x: number; y: number } | null = null;\n props.onClick = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function\n props.onPointerDown = (event) => {\n click = true;\n coordinates = { x: event.pageX, y: event.pageY };\n node.props.onPointerDown?.(event);\n };\n props.onPointerCancel = (event) => {\n click = false;\n node.props.onPointerCancel?.(event);\n };\n props.onPointerLeave = (event) => {\n click = false;\n node.props.onPointerLeave?.(event);\n };\n props.onPointerUp = (event) => {\n if (click) {\n if (\n coordinates !== null &&\n Math.pow(event.pageX - coordinates.x, 2) + Math.pow(event.pageY - coordinates.y, 2) <=\n Math.pow(CLICK_DISTANCE_THRESHOLD_PX, 2)\n ) {\n node.props.onClick?.(event);\n }\n click = false;\n coordinates = null;\n }\n node.props.onPointerUp?.(event);\n };\n }\n\n return cloneElement(node, props);\n};\n\nconst applyInterceptor = (node: ReactNode, func: (node: ReactElement) => ReactElement): ReactElement => {\n if (!isValidElement(node)) {\n return <Fragment>{node}</Fragment>;\n }\n\n let children;\n ((props) => {\n if (props.children) {\n const childrenArr = Children.toArray(props.children);\n children =\n childrenArr.length === 1\n ? applyInterceptor(childrenArr[0], func)\n : childrenArr.map((child) => applyInterceptor(child, func));\n }\n })(node.props as { children: ReactNode[] });\n\n return cloneElement(func(node), {}, children);\n};\n\nexport interface ClickInterceptorProps {\n children: ReactNode;\n}\n\nexport const ClickInterceptor: FC<ClickInterceptorProps> = memo(({ children }) => {\n return applyInterceptor(children, interceptClick);\n});\n\nClickInterceptor.displayName = 'ClickInterceptor';\n"],"names":[
|
|
1
|
+
{"version":3,"file":"ClickInterceptor.js","sources":["src/ClickInterceptor.tsx"],"sourcesContent":["import {\n Children,\n DOMAttributes,\n FC,\n Fragment,\n ReactElement,\n ReactNode,\n cloneElement,\n isValidElement,\n memo,\n} from 'react';\n\ntype InterceptedProps = Pick<\n DOMAttributes<HTMLElement>,\n 'onClick' | 'onPointerDown' | 'onPointerCancel' | 'onPointerLeave' | 'onPointerUp'\n>;\n\nconst CLICK_DISTANCE_THRESHOLD_PX = 24;\n\nconst interceptClick = (node: ReactElement<InterceptedProps>) => {\n const props: InterceptedProps = {};\n\n if (node.props.onClick) {\n let click = false;\n let coordinates: { x: number; y: number } | null = null;\n props.onClick = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function\n props.onPointerDown = (event) => {\n click = true;\n coordinates = { x: event.pageX, y: event.pageY };\n node.props.onPointerDown?.(event);\n };\n props.onPointerCancel = (event) => {\n click = false;\n node.props.onPointerCancel?.(event);\n };\n props.onPointerLeave = (event) => {\n click = false;\n node.props.onPointerLeave?.(event);\n };\n props.onPointerUp = (event) => {\n if (click) {\n if (\n coordinates !== null &&\n Math.pow(event.pageX - coordinates.x, 2) + Math.pow(event.pageY - coordinates.y, 2) <=\n Math.pow(CLICK_DISTANCE_THRESHOLD_PX, 2)\n ) {\n node.props.onClick?.(event);\n }\n click = false;\n coordinates = null;\n }\n node.props.onPointerUp?.(event);\n };\n }\n\n return cloneElement(node, props);\n};\n\nconst applyInterceptor = (node: ReactNode, func: (node: ReactElement) => ReactElement): ReactElement => {\n if (!isValidElement(node)) {\n return <Fragment>{node}</Fragment>;\n }\n\n let children;\n ((props) => {\n if (props.children) {\n const childrenArr = Children.toArray(props.children);\n children =\n childrenArr.length === 1\n ? applyInterceptor(childrenArr[0], func)\n : childrenArr.map((child) => applyInterceptor(child, func));\n }\n })(node.props as { children: ReactNode[] });\n\n return cloneElement(func(node), {}, children);\n};\n\nexport interface ClickInterceptorProps {\n children: ReactNode;\n}\n\nexport const ClickInterceptor: FC<ClickInterceptorProps> = memo(({ children }) => {\n return applyInterceptor(children, interceptClick);\n});\n\nClickInterceptor.displayName = 'ClickInterceptor';\n"],"names":[],"mappings":";;;AAiBA,MAAM,2BAA8B,GAAA,EAAA,CAAA;AAEpC,MAAM,cAAA,GAAiB,CAAC,IAAyC,KAAA;AAC7D,EAAA,MAAM,QAA0B,EAAC,CAAA;AAEjC,EAAI,IAAA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in this position invariably gets.
|
|
15
15
|
*/
|
|
16
16
|
export declare const BOTTOM_SHEET_ACTION_BAR_DEFAULTS: {
|
|
17
|
-
readonly type:
|
|
17
|
+
readonly type: 'vertical';
|
|
18
18
|
readonly padding: 16;
|
|
19
19
|
readonly showDivider: false;
|
|
20
20
|
};
|
package/actionBarDefaults.js
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import './index.css';
|
|
2
|
-
/**
|
|
3
|
-
* The ActionBar props a BottomSheet supplies to whatever sits in its `footer` slot, at runtime by cloning the
|
|
4
|
-
* element (see `BottomSheet.tsx`).
|
|
5
|
-
*
|
|
6
|
-
* They live in their own module, as plain data with no imports, because they are read from TWO sides: the
|
|
7
|
-
* component applies them, and the Code Connect template declares them as contextual defaults so a footer
|
|
8
|
-
* snippet stops repeating what the bottom sheet already provides. A literal copied into the template would
|
|
9
|
-
* drift silently — change a value here and the published snippet would keep asserting the old one, with no
|
|
10
|
-
* build error and no render error. The bundler inlines this file into every template that imports it, which is
|
|
11
|
-
* the other reason it must stay free of runtime imports.
|
|
12
|
-
*
|
|
13
|
-
* `type` and `padding` are defaults in the ordinary sense — an explicit prop on the footer element wins.
|
|
14
|
-
* `showDivider` is not: the bottom sheet draws the divider itself (`styles.divider` above the footer) and
|
|
15
|
-
* always overrides the bar's own, so `false` is what an action bar in this position invariably gets.
|
|
16
|
-
*/
|
|
17
2
|
const BOTTOM_SHEET_ACTION_BAR_DEFAULTS = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
type: "vertical",
|
|
4
|
+
padding: 16,
|
|
5
|
+
showDivider: false
|
|
21
6
|
};
|
|
22
7
|
|
|
23
8
|
export { BOTTOM_SHEET_ACTION_BAR_DEFAULTS };
|
package/actionBarDefaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionBarDefaults.js","sources":["src/actionBarDefaults.ts"],"sourcesContent":["/**\n * The ActionBar props a BottomSheet supplies to whatever sits in its `footer` slot, at runtime by cloning the\n * element (see `BottomSheet.tsx`).\n *\n * They live in their own module, as plain data with no imports, because they are read from TWO sides: the\n * component applies them, and the Code Connect template declares them as contextual defaults so a footer\n * snippet stops repeating what the bottom sheet already provides. A literal copied into the template would\n * drift silently — change a value here and the published snippet would keep asserting the old one, with no\n * build error and no render error. The bundler inlines this file into every template that imports it, which is\n * the other reason it must stay free of runtime imports.\n *\n * `type` and `padding` are defaults in the ordinary sense — an explicit prop on the footer element wins.\n * `showDivider` is not: the bottom sheet draws the divider itself (`styles.divider` above the footer) and\n * always overrides the bar's own, so `false` is what an action bar in this position invariably gets.\n */\nexport const BOTTOM_SHEET_ACTION_BAR_DEFAULTS = {\n type: 'vertical',\n padding: 16,\n showDivider: false,\n} as const;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actionBarDefaults.js","sources":["src/actionBarDefaults.ts"],"sourcesContent":["/**\n * The ActionBar props a BottomSheet supplies to whatever sits in its `footer` slot, at runtime by cloning the\n * element (see `BottomSheet.tsx`).\n *\n * They live in their own module, as plain data with no imports, because they are read from TWO sides: the\n * component applies them, and the Code Connect template declares them as contextual defaults so a footer\n * snippet stops repeating what the bottom sheet already provides. A literal copied into the template would\n * drift silently — change a value here and the published snippet would keep asserting the old one, with no\n * build error and no render error. The bundler inlines this file into every template that imports it, which is\n * the other reason it must stay free of runtime imports.\n *\n * `type` and `padding` are defaults in the ordinary sense — an explicit prop on the footer element wins.\n * `showDivider` is not: the bottom sheet draws the divider itself (`styles.divider` above the footer) and\n * always overrides the bar's own, so `false` is what an action bar in this position invariably gets.\n */\nexport const BOTTOM_SHEET_ACTION_BAR_DEFAULTS = {\n type: 'vertical',\n padding: 16,\n showDivider: false,\n} as const;\n"],"names":[],"mappings":"AAeO,MAAM,gCAAmC,GAAA;AAAA,EAC5C,IAAM,EAAA,UAAA;AAAA,EACN,OAAS,EAAA,EAAA;AAAA,EACT,WAAa,EAAA,KAAA;AACjB;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
var styles = {"flex-container":"magritte-flex-container___muHAx_9-4-49","flexContainer":"magritte-flex-container___muHAx_9-4-49","animation-timeout":"magritte-animation-timeout___yd-SZ_9-4-49","animationTimeout":"magritte-animation-timeout___yd-SZ_9-4-49","css-variables-container":"magritte-css-variables-container___jBCr9_9-4-49","cssVariablesContainer":"magritte-css-variables-container___jBCr9_9-4-49","appear-animation":"magritte-appear-animation___P84Ln_9-4-49","appearAnimation":"magritte-appear-animation___P84Ln_9-4-49","disappear-animation":"magritte-disappear-animation___Putks_9-4-49","disappearAnimation":"magritte-disappear-animation___Putks_9-4-49","grabber-transition-animation":"magritte-grabber-transition-animation___s3Oh4_9-4-49","grabberTransitionAnimation":"magritte-grabber-transition-animation___s3Oh4_9-4-49","height-transition-animation":"magritte-height-transition-animation___xNprr_9-4-49","heightTransitionAnimation":"magritte-height-transition-animation___xNprr_9-4-49","close-by-swipe-animation":"magritte-close-by-swipe-animation___wdezY_9-4-49","closeBySwipeAnimation":"magritte-close-by-swipe-animation___wdezY_9-4-49","swipe-cancel-animation":"magritte-swipe-cancel-animation___AhYj5_9-4-49","swipeCancelAnimation":"magritte-swipe-cancel-animation___AhYj5_9-4-49","overlay":"magritte-overlay___5a2U-_9-4-49","overlay-background":"magritte-overlay-background___8Sd4V_9-4-49","overlayBackground":"magritte-overlay-background___8Sd4V_9-4-49","overlay-background_visible":"magritte-overlay-background_visible___FOJgj_9-4-49","overlayBackgroundVisible":"magritte-overlay-background_visible___FOJgj_9-4-49","swipe-container":"magritte-swipe-container___sZ2n5_9-4-49","swipeContainer":"magritte-swipe-container___sZ2n5_9-4-49","grabber":"magritte-grabber___A7SB-_9-4-49","grabber_ensure-safe":"magritte-grabber_ensure-safe___DR-dV_9-4-49","grabberEnsureSafe":"magritte-grabber_ensure-safe___DR-dV_9-4-49","visual-container":"magritte-visual-container___-VSuY_9-4-49","visualContainer":"magritte-visual-container___-VSuY_9-4-49","visual-container_full-screen":"magritte-visual-container_full-screen___jCCBb_9-4-49","visualContainerFullScreen":"magritte-visual-container_full-screen___jCCBb_9-4-49","scroll-container":"magritte-scroll-container___4ngNY_9-4-49","scrollContainer":"magritte-scroll-container___4ngNY_9-4-49","scroll-container_with-top-padding":"magritte-scroll-container_with-top-padding___o60Dl_9-4-49","scrollContainerWithTopPadding":"magritte-scroll-container_with-top-padding___o60Dl_9-4-49","native-scroll-container":"magritte-native-scroll-container___JOlxE_9-4-49","nativeScrollContainer":"magritte-native-scroll-container___JOlxE_9-4-49","content":"magritte-content___1gAwP_9-4-49","content_full-screen":"magritte-content_full-screen___2SFaO_9-4-49","contentFullScreen":"magritte-content_full-screen___2SFaO_9-4-49","content_sized-full-screen":"magritte-content_sized-full-screen___45pa6_9-4-49","contentSizedFullScreen":"magritte-content_sized-full-screen___45pa6_9-4-49","content_with-paddings":"magritte-content_with-paddings___gIiAv_9-4-49","contentWithPaddings":"magritte-content_with-paddings___gIiAv_9-4-49","content_with-top-padding":"magritte-content_with-top-padding___2e8N1_9-4-49","contentWithTopPadding":"magritte-content_with-top-padding___2e8N1_9-4-49","footer":"magritte-footer___RWslT_9-4-49","footer-with-padding":"magritte-footer-with-padding___KwkhC_9-4-49","footerWithPadding":"magritte-footer-with-padding___KwkhC_9-4-49","divider":"magritte-divider___0F8hh_9-4-49","divider_visible":"magritte-divider_visible___pAWZM_9-4-49","dividerVisible":"magritte-divider_visible___pAWZM_9-4-49","content-overlay":"magritte-content-overlay___HAyzL_9-4-49","contentOverlay":"magritte-content-overlay___HAyzL_9-4-49","no-caret":"magritte-no-caret___ewcMD_9-4-49","noCaret":"magritte-no-caret___ewcMD_9-4-49","iframe-wrapper":"magritte-iframe-wrapper___gBCL5_9-4-49","iframeWrapper":"magritte-iframe-wrapper___gBCL5_9-4-49","iframe-events-interceptor":"magritte-iframe-events-interceptor___FTW-8_9-4-49","iframeEventsInterceptor":"magritte-iframe-events-interceptor___FTW-8_9-4-49","grow-limiter":"magritte-grow-limiter___ANaBL_9-4-49","growLimiter":"magritte-grow-limiter___ANaBL_9-4-49","header-wrapper":"magritte-header-wrapper___LdLOU_9-4-49","headerWrapper":"magritte-header-wrapper___LdLOU_9-4-49"};
|
|
3
|
+
|
|
4
|
+
export { styles as s };
|
|
5
|
+
//# sourceMappingURL=bottom-sheet-DRUdtPUr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet-DRUdtPUr.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|