@sproutsocial/seeds-react-card 1.1.53 → 1.1.55

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/src/utils.ts DELETED
@@ -1,61 +0,0 @@
1
- import { createContext, useContext, useEffect } from "react";
2
- import { assertIsElement } from "@sproutsocial/seeds-react-utilities";
3
- import type { TypeCardProps, TypeCardContext } from "./CardTypes";
4
-
5
- export const SubComponentContext = createContext<TypeCardContext>({
6
- // eslint-disable-next-line @typescript-eslint/no-empty-function
7
- setHasSubComponent: () => {},
8
- href: "",
9
- linkRef: null,
10
- });
11
-
12
- export function useChildContext() {
13
- const { setHasSubComponent } = useContext(SubComponentContext);
14
- useEffect(() => {
15
- setHasSubComponent && setHasSubComponent(true);
16
- }, [setHasSubComponent]);
17
- }
18
-
19
- interface navigateToParams extends Pick<TypeCardProps, "href"> {
20
- e: React.MouseEvent | React.KeyboardEvent;
21
- ref: React.RefObject<HTMLDivElement>;
22
- }
23
-
24
- export const navigateTo = ({ e, href, ref }: navigateToParams) => {
25
- const { target } = e;
26
-
27
- // asserts that target is an element so `contains` accepts it
28
- assertIsElement(target);
29
-
30
- if (ref.current?.contains(target)) {
31
- if (
32
- target.getAttribute("onclick") !== null ||
33
- target.getAttribute("href") !== null
34
- ) {
35
- e.stopPropagation();
36
- return;
37
- }
38
- }
39
-
40
- window.open(href, "_blank")?.focus();
41
- };
42
-
43
- interface onKeyDownParams
44
- extends Pick<TypeCardProps, "href" | "onClick" | "role"> {
45
- e: React.KeyboardEvent;
46
- ref: React.RefObject<HTMLDivElement>;
47
- }
48
-
49
- export const onKeyDown = ({ e, href, onClick, ref, role }: onKeyDownParams) => {
50
- if (e?.key === "Enter") {
51
- if (role === "link") {
52
- return navigateTo({ e, href, ref });
53
- }
54
-
55
- if (role === "presentation") {
56
- return;
57
- }
58
-
59
- return onClick?.(e);
60
- }
61
- };
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "extends": "@sproutsocial/seeds-tsconfig/bundler/dom/library-monorepo",
3
- "compilerOptions": {
4
- "jsx": "react-jsx",
5
- "module": "esnext"
6
- },
7
- "include": ["src/**/*"],
8
- "exclude": [
9
- "node_modules",
10
- "dist",
11
- "coverage",
12
- "**/*.stories.tsx",
13
- "**/*.stories.ts"
14
- ]
15
- }
package/tsup.config.ts DELETED
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig((options) => ({
4
- entry: ["src/index.ts"],
5
- format: ["cjs", "esm"],
6
- clean: true,
7
- legacyOutput: true,
8
- dts: options.dts,
9
- external: ["react"],
10
- sourcemap: true,
11
- metafile: options.metafile,
12
- }));