@mediamonks/react-kit 1.0.3 → 2.0.5

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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="gsap/types/split-text.js" />
1
2
  import SplitText from 'gsap/SplitText';
2
3
  import { type ComponentProps, type ReactElement, type RefAttributes } from 'react';
3
4
  /**
@@ -14,6 +15,10 @@ type SplitTextWrapperProps<T extends KnownTarget> = {
14
15
  * The element type to render, the default is `div`
15
16
  */
16
17
  as?: T;
18
+ /**
19
+ * Split the first element child of the element passed
20
+ */
21
+ splitFirstElementChild?: boolean;
17
22
  };
18
23
  /**
19
24
  * Polymorphic component type, necessary to get all the attributes/props for the
@@ -7,7 +7,7 @@ if (typeof window !== 'undefined') {
7
7
  gsap.registerPlugin(SplitText);
8
8
  }
9
9
  // @ts-expect-error polymorphic type is not compatible with ensuredForwardRef function factory
10
- export const SplitTextWrapper = ensuredForwardRef(({ variables = {}, as, children, ...props }, ref) => {
10
+ export const SplitTextWrapper = ensuredForwardRef(({ variables = {}, as, children, splitFirstElementChild = false, ...props }, ref) => {
11
11
  /**
12
12
  * Not using useCallback on purpose so that a new SplitText instance is
13
13
  * created whenever this component rerenders the children
@@ -16,7 +16,11 @@ export const SplitTextWrapper = ensuredForwardRef(({ variables = {}, as, childre
16
16
  if (ref.current && 'isSplit' in ref.current && ref.current.isSplit) {
17
17
  return;
18
18
  }
19
- ref.current = new SplitText(element, variables);
19
+ if (splitFirstElementChild && element.childElementCount > 1) {
20
+ // eslint-disable-next-line no-console
21
+ console.warn("Split text wrapper should only contain 1 element when 'splitFirstElementChild' is set to true");
22
+ }
23
+ ref.current = new SplitText(splitFirstElementChild ? element.firstElementChild : element, variables);
20
24
  };
21
25
  const Component = (as ?? 'div');
22
26
  return (_jsx(Component, { ...props, dangerouslySetInnerHTML: props.dangerouslySetInnerHTML ?? {
@@ -1,4 +1,5 @@
1
1
  import gsap from 'gsap';
2
+ // eslint-disable-next-line @typescript-eslint/naming-convention
2
3
  import ScrollTrigger from 'gsap/ScrollTrigger';
3
4
  import { useEffect, useRef } from 'react';
4
5
  import { animations } from '../../animations.js';
package/dist/gsap.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './gsap/components/SplitTextWrapper/SplitTextWrapper.js';
2
+ export * from './gsap/hooks/useAnimation/useAnimation.js';
3
+ export * from './gsap/hooks/useExposeAnimation/useExposeAnimation.js';
4
+ export * from './gsap/hooks/useExposedAnimation/useExposedAnimation.js';
5
+ export * from './gsap/hooks/useExposedAnimations/useExposedAnimations.js';
6
+ export * from './gsap/hooks/useFlip/useFlip.js';
7
+ export * from './gsap/hooks/useScrollAnimation/useScrollAnimation.js';
8
+ export * from './gsap/utils/getAnimation/getAnimation.js';
package/dist/gsap.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './gsap/components/SplitTextWrapper/SplitTextWrapper.js';
2
+ export * from './gsap/hooks/useAnimation/useAnimation.js';
3
+ export * from './gsap/hooks/useExposeAnimation/useExposeAnimation.js';
4
+ export * from './gsap/hooks/useExposedAnimation/useExposedAnimation.js';
5
+ export * from './gsap/hooks/useExposedAnimations/useExposedAnimations.js';
6
+ export * from './gsap/hooks/useFlip/useFlip.js';
7
+ export * from './gsap/hooks/useScrollAnimation/useScrollAnimation.js';
8
+ export * from './gsap/utils/getAnimation/getAnimation.js';
package/dist/index.d.ts CHANGED
@@ -1,13 +1,5 @@
1
1
  export * from './components/AutoAdjustFontSize/AutoAdjustFontSize.js';
2
2
  export * from './components/AutoFill/AutoFill.js';
3
- export * from './gsap/components/SplitTextWrapper/SplitTextWrapper.js';
4
- export * from './gsap/hooks/useAnimation/useAnimation.js';
5
- export * from './gsap/hooks/useExposeAnimation/useExposeAnimation.js';
6
- export * from './gsap/hooks/useExposedAnimation/useExposedAnimation.js';
7
- export * from './gsap/hooks/useExposedAnimations/useExposedAnimations.js';
8
- export * from './gsap/hooks/useFlip/useFlip.js';
9
- export * from './gsap/hooks/useScrollAnimation/useScrollAnimation.js';
10
- export * from './gsap/utils/getAnimation/getAnimation.js';
11
3
  export * from './hocs/ensuredForwardRef/ensuredForwardRef.js';
12
4
  export * from './hooks/useClientSideValue/useClientSideValue.js';
13
5
  export * from './hooks/useContentRect/useContentRect.js';
@@ -31,18 +23,19 @@ export * from './hooks/useRefs/utils/validateAndUnwrapRefs/validateAndUnwrapRefs
31
23
  export * from './hooks/useResizeObserver/useResizeObserver.js';
32
24
  export * from './hooks/useStaticValue/useStaticValue.js';
33
25
  export * from './hooks/useToggle/useToggle.js';
26
+ export * from './lifecycle/components/CrossFlow/CrossFlow.js';
27
+ export * from './lifecycle/components/TransitionPresence/TransitionPresence.context.js';
28
+ export * from './lifecycle/components/TransitionPresence/TransitionPresence.js';
34
29
  export * from './lifecycle/hooks/useBeforeMount/useBeforeMount.js';
30
+ export * from './lifecycle/hooks/useBeforeUnmount/useBeforeUnmount.js';
35
31
  export * from './lifecycle/hooks/useIsMounted/useIsMounted.js';
36
32
  export * from './lifecycle/hooks/useIsMountedState/useIsMountedState.js';
37
33
  export * from './lifecycle/hooks/useMount/useMount.js';
38
34
  export * from './lifecycle/hooks/useUnmount/useUnmount.js';
39
- export * from './nextjs/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js';
35
+ export * from './types/PolymorphicComponentProps/PolymorphicComponentProps.js';
40
36
  export * from './utils/adjustFontSize/adjustFontSize.js';
41
37
  export * from './utils/arrayRef/arrayRef.js';
42
38
  export * from './utils/createTimeout/createTimeout.js';
43
39
  export * from './utils/isRefObject/isRefObject.js';
40
+ export * from './utils/regexPatterns/regexPatterns.js';
44
41
  export * from './utils/unref/unref.js';
45
- export { CrossFlow } from './lifecycle/components/CrossFlow/CrossFlow.js';
46
- export { TransitionPresenceContext } from './lifecycle/components/TransitionPresence/TransitionPresence.context.js';
47
- export { TransitionPresence } from './lifecycle/components/TransitionPresence/TransitionPresence.js';
48
- export { useBeforeUnmount, type BeforeUnmountCallback, } from './lifecycle/hooks/useBeforeUnmount/useBeforeUnmount.js';
package/dist/index.js CHANGED
@@ -1,14 +1,6 @@
1
1
  /* PLOP_ADD_EXPORT */
2
2
  export * from './components/AutoAdjustFontSize/AutoAdjustFontSize.js';
3
3
  export * from './components/AutoFill/AutoFill.js';
4
- export * from './gsap/components/SplitTextWrapper/SplitTextWrapper.js';
5
- export * from './gsap/hooks/useAnimation/useAnimation.js';
6
- export * from './gsap/hooks/useExposeAnimation/useExposeAnimation.js';
7
- export * from './gsap/hooks/useExposedAnimation/useExposedAnimation.js';
8
- export * from './gsap/hooks/useExposedAnimations/useExposedAnimations.js';
9
- export * from './gsap/hooks/useFlip/useFlip.js';
10
- export * from './gsap/hooks/useScrollAnimation/useScrollAnimation.js';
11
- export * from './gsap/utils/getAnimation/getAnimation.js';
12
4
  export * from './hocs/ensuredForwardRef/ensuredForwardRef.js';
13
5
  export * from './hooks/useClientSideValue/useClientSideValue.js';
14
6
  export * from './hooks/useContentRect/useContentRect.js';
@@ -32,19 +24,19 @@ export * from './hooks/useRefs/utils/validateAndUnwrapRefs/validateAndUnwrapRefs
32
24
  export * from './hooks/useResizeObserver/useResizeObserver.js';
33
25
  export * from './hooks/useStaticValue/useStaticValue.js';
34
26
  export * from './hooks/useToggle/useToggle.js';
27
+ export * from './lifecycle/components/CrossFlow/CrossFlow.js';
28
+ export * from './lifecycle/components/TransitionPresence/TransitionPresence.context.js';
29
+ export * from './lifecycle/components/TransitionPresence/TransitionPresence.js';
35
30
  export * from './lifecycle/hooks/useBeforeMount/useBeforeMount.js';
31
+ export * from './lifecycle/hooks/useBeforeUnmount/useBeforeUnmount.js';
36
32
  export * from './lifecycle/hooks/useIsMounted/useIsMounted.js';
37
33
  export * from './lifecycle/hooks/useIsMountedState/useIsMountedState.js';
38
34
  export * from './lifecycle/hooks/useMount/useMount.js';
39
35
  export * from './lifecycle/hooks/useUnmount/useUnmount.js';
40
- export * from './nextjs/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js';
36
+ export * from './types/PolymorphicComponentProps/PolymorphicComponentProps.js';
41
37
  export * from './utils/adjustFontSize/adjustFontSize.js';
42
38
  export * from './utils/arrayRef/arrayRef.js';
43
39
  export * from './utils/createTimeout/createTimeout.js';
44
40
  export * from './utils/isRefObject/isRefObject.js';
41
+ export * from './utils/regexPatterns/regexPatterns.js';
45
42
  export * from './utils/unref/unref.js';
46
- // Custom exports for external use only
47
- export { CrossFlow } from './lifecycle/components/CrossFlow/CrossFlow.js';
48
- export { TransitionPresenceContext } from './lifecycle/components/TransitionPresence/TransitionPresence.context.js';
49
- export { TransitionPresence } from './lifecycle/components/TransitionPresence/TransitionPresence.js';
50
- export { useBeforeUnmount, } from './lifecycle/hooks/useBeforeUnmount/useBeforeUnmount.js';
@@ -0,0 +1 @@
1
+ export * from './nextjs/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js';
package/dist/nextjs.js ADDED
@@ -0,0 +1 @@
1
+ export * from './nextjs/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js';
@@ -0,0 +1,17 @@
1
+ import type { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, PropsWithChildren } from 'react';
2
+ /**
3
+ * PropsFromAs is a type based on the supplied as prop.
4
+ */
5
+ type PropsFromAs<Type extends ElementType> = {
6
+ as?: Type;
7
+ };
8
+ /**
9
+ * MergeAndOverride is a type that omits type keys from BaseTypes that are also present in OverrideProps.
10
+ */
11
+ type MergeAndOverride<BaseType, OverrideProps> = Omit<BaseType, keyof OverrideProps> & OverrideProps;
12
+ export type PolymorphicRef<Type extends ElementType> = ComponentPropsWithRef<Type>['ref'];
13
+ export type PolymorphicComponentProps<BaseType extends ElementType, OwnProps = Record<string, never>> = PropsWithChildren<MergeAndOverride<ComponentPropsWithoutRef<BaseType>, PropsFromAs<BaseType> & OwnProps>>;
14
+ export type PolymorphicComponentPropsWithRef<BaseType extends ElementType, OwnProps = Record<string, never>> = PolymorphicComponentProps<BaseType, OwnProps> & {
15
+ ref?: PolymorphicRef<BaseType>;
16
+ };
17
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * PascalCaseString
3
+ * MyComponent
4
+ * MyComponent5
5
+ * MyC0mp0nent
6
+ * My00mponent
7
+ */
8
+ export declare const pascalCaseRegex: RegExp;
9
+ /**
10
+ * @example
11
+ * camelCaseString
12
+ * helloW0rld
13
+ * g00M0rning
14
+ * happyC0ding
15
+ */
16
+ export declare const camelCaseRegex: RegExp;
17
+ /**
18
+ * @example
19
+ * my-component
20
+ * my-component-5
21
+ * my-c0mp0nent
22
+ * c0ding1sfun
23
+ */
24
+ export declare const kebabCaseRegex: RegExp;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * PascalCaseString
3
+ * MyComponent
4
+ * MyComponent5
5
+ * MyC0mp0nent
6
+ * My00mponent
7
+ */
8
+ // eslint-disable-next-line unicorn/no-unsafe-regex
9
+ export const pascalCaseRegex = /^(?:[A-Z][\da-z]+)+$/u;
10
+ /**
11
+ * @example
12
+ * camelCaseString
13
+ * helloW0rld
14
+ * g00M0rning
15
+ * happyC0ding
16
+ */
17
+ // eslint-disable-next-line unicorn/no-unsafe-regex
18
+ export const camelCaseRegex = /^[\da-z]+(?:[A-Z][\da-z]+)*$/u;
19
+ /**
20
+ * @example
21
+ * my-component
22
+ * my-component-5
23
+ * my-c0mp0nent
24
+ * c0ding1sfun
25
+ */
26
+ // eslint-disable-next-line unicorn/no-unsafe-regex
27
+ export const kebabCaseRegex = /^[\da-z]+(?:-[\da-z]+)*$/u;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/react-kit",
3
- "version": "1.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "A collection of React hooks, components, utilities that we use at Media.Monks",
5
5
  "keywords": [
6
6
  "react",
@@ -17,7 +17,9 @@
17
17
  "types": "./dist/index.d.ts",
18
18
  "module": "./dist/index.js",
19
19
  "exports": {
20
- ".": "./dist/index.js"
20
+ ".": "./dist/index.js",
21
+ "./gsap": "./dist/gsap.js",
22
+ "./nextjs": "./dist/nextjs.js"
21
23
  },
22
24
  "type": "module",
23
25
  "files": [
@@ -25,8 +27,7 @@
25
27
  "README.md"
26
28
  ],
27
29
  "publishConfig": {
28
- "access": "public",
29
- "provenance": false
30
+ "access": "public"
30
31
  },
31
32
  "scripts": {
32
33
  "build": "npm-run-all -s clean build:*",
@@ -50,73 +51,43 @@
50
51
  "prepare": "husky install"
51
52
  },
52
53
  "prettier": "@mediamonks/prettier-config",
53
- "eslintConfig": {
54
- "overrides": [
55
- {
56
- "files": [
57
- "*.ts",
58
- "*.tsx"
59
- ],
60
- "extends": [
61
- "@mediamonks/eslint-config",
62
- "@mediamonks/eslint-config-react",
63
- "@mediamonks/eslint-config-typescript",
64
- "@mediamonks/eslint-config-typescript-react"
65
- ],
66
- "parserOptions": {
67
- "project": "./tsconfig.json"
68
- }
69
- },
70
- {
71
- "files": [
72
- "*.cjs",
73
- "*.js",
74
- "*.jsx",
75
- "*.mjs"
76
- ],
77
- "extends": [
78
- "@mediamonks/eslint-config"
79
- ],
80
- "parserOptions": {
81
- "ecmaVersion": "latest"
82
- }
83
- }
84
- ]
85
- },
86
54
  "devDependencies": {
87
- "@mediamonks/eslint-config": "^2.0.6",
88
- "@mediamonks/eslint-config-react": "^2.1.11",
89
- "@mediamonks/eslint-config-typescript": "^1.0.8",
90
- "@mediamonks/eslint-config-typescript-react": "^1.0.10",
55
+ "@mediamonks/eslint-config": "^2.5.0",
56
+ "@mediamonks/eslint-config-react": "^2.6.0",
57
+ "@mediamonks/eslint-config-typescript": "^1.5.1",
58
+ "@mediamonks/eslint-config-typescript-react": "^1.4.1",
91
59
  "@mediamonks/prettier-config": "^1.0.1",
92
- "@storybook/addon-essentials": "^7.5.2",
93
- "@storybook/addon-interactions": "^7.5.2",
94
- "@storybook/addon-links": "^7.5.2",
95
- "@storybook/blocks": "^7.5.2",
96
- "@storybook/cli": "^7.5.2",
60
+ "@storybook/addon-essentials": "^8.5.2",
61
+ "@storybook/addon-interactions": "^8.5.2",
62
+ "@storybook/addon-links": "^8.5.2",
63
+ "@storybook/blocks": "^8.5.2",
64
+ "@storybook/cli": "^8.5.2",
97
65
  "@storybook/jest": "^0.2.3",
98
- "@storybook/react": "^7.5.2",
99
- "@storybook/react-vite": "^7.5.2",
100
- "@storybook/test-runner": "^0.13.0",
66
+ "@storybook/manager-api": "^8.5.2",
67
+ "@storybook/react": "^8.5.2",
68
+ "@storybook/react-vite": "^8.5.2",
69
+ "@storybook/test-runner": "^0.21.0",
101
70
  "@storybook/testing-library": "^0.2.2",
102
- "@storybook/types": "^7.5.2",
103
- "@testing-library/react": "^14.0.0",
71
+ "@storybook/theming": "^8.5.2",
72
+ "@storybook/types": "^8.5.2",
73
+ "@testing-library/react": "^16.2.0",
104
74
  "@types/lodash-es": "^4.17.11",
105
75
  "@types/react": "^18.0.25",
106
76
  "@vitejs/plugin-react": "^4.0.0",
107
77
  "concurrently": "^8.2.2",
108
78
  "eslint": "^8.28.0",
79
+ "gsap": "npm:@gsap/business@3.12.2",
109
80
  "http-server": "^14.1.1",
110
81
  "husky": "^8.0.0",
111
82
  "jsdom": "^22.0.0",
112
83
  "lint-staged": "^13.1.0",
113
84
  "npm-run-all": "^4.1.5",
114
85
  "plop": "^4.0.0",
115
- "prettier": "^2.8.0",
116
- "react": "^18.2.0",
117
- "react-dom": "^18.2.0",
86
+ "prettier": "^3.2.5",
87
+ "react": "^19.0.0",
88
+ "react-dom": "^19.0.0",
118
89
  "shx": "^0.3.4",
119
- "storybook": "^7.5.2",
90
+ "storybook": "^8.5.2",
120
91
  "ts-node": "^10.9.1",
121
92
  "typescript": "^5.0.2",
122
93
  "vitest": "^0.34.3",
@@ -126,9 +97,6 @@
126
97
  "lodash-es": "^4.17.21"
127
98
  },
128
99
  "peerDependencies": {
129
- "react": ">= 17"
130
- },
131
- "optionalDependencies": {
132
- "gsap": "npm:@gsap/business@3.12.2"
100
+ "react": ">= 18"
133
101
  }
134
102
  }