@mediamonks/react-kit 2.0.4 → 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.
@@ -15,6 +15,10 @@ type SplitTextWrapperProps<T extends KnownTarget> = {
15
15
  * The element type to render, the default is `div`
16
16
  */
17
17
  as?: T;
18
+ /**
19
+ * Split the first element child of the element passed
20
+ */
21
+ splitFirstElementChild?: boolean;
18
22
  };
19
23
  /**
20
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 ?? {
package/dist/index.d.ts CHANGED
@@ -37,4 +37,5 @@ export * from './utils/adjustFontSize/adjustFontSize.js';
37
37
  export * from './utils/arrayRef/arrayRef.js';
38
38
  export * from './utils/createTimeout/createTimeout.js';
39
39
  export * from './utils/isRefObject/isRefObject.js';
40
+ export * from './utils/regexPatterns/regexPatterns.js';
40
41
  export * from './utils/unref/unref.js';
package/dist/index.js CHANGED
@@ -38,4 +38,5 @@ export * from './utils/adjustFontSize/adjustFontSize.js';
38
38
  export * from './utils/arrayRef/arrayRef.js';
39
39
  export * from './utils/createTimeout/createTimeout.js';
40
40
  export * from './utils/isRefObject/isRefObject.js';
41
+ export * from './utils/regexPatterns/regexPatterns.js';
41
42
  export * from './utils/unref/unref.js';
@@ -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": "2.0.4",
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",
@@ -57,25 +57,26 @@
57
57
  "@mediamonks/eslint-config-typescript": "^1.5.1",
58
58
  "@mediamonks/eslint-config-typescript-react": "^1.4.1",
59
59
  "@mediamonks/prettier-config": "^1.0.1",
60
- "@storybook/addon-essentials": "^7.6.17",
61
- "@storybook/addon-interactions": "^7.6.17",
62
- "@storybook/addon-links": "^7.6.17",
63
- "@storybook/blocks": "^7.6.17",
64
- "@storybook/cli": "^7.6.17",
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",
65
65
  "@storybook/jest": "^0.2.3",
66
- "@storybook/manager-api": "^7.6.17",
67
- "@storybook/react": "^7.6.17",
68
- "@storybook/react-vite": "^7.6.17",
69
- "@storybook/test-runner": "^0.16.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",
70
70
  "@storybook/testing-library": "^0.2.2",
71
- "@storybook/theming": "^7.6.17",
72
- "@storybook/types": "^7.6.17",
73
- "@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",
74
74
  "@types/lodash-es": "^4.17.11",
75
75
  "@types/react": "^18.0.25",
76
76
  "@vitejs/plugin-react": "^4.0.0",
77
77
  "concurrently": "^8.2.2",
78
78
  "eslint": "^8.28.0",
79
+ "gsap": "npm:@gsap/business@3.12.2",
79
80
  "http-server": "^14.1.1",
80
81
  "husky": "^8.0.0",
81
82
  "jsdom": "^22.0.0",
@@ -83,10 +84,10 @@
83
84
  "npm-run-all": "^4.1.5",
84
85
  "plop": "^4.0.0",
85
86
  "prettier": "^3.2.5",
86
- "react": "^18.2.0",
87
- "react-dom": "^18.2.0",
87
+ "react": "^19.0.0",
88
+ "react-dom": "^19.0.0",
88
89
  "shx": "^0.3.4",
89
- "storybook": "^7.5.2",
90
+ "storybook": "^8.5.2",
90
91
  "ts-node": "^10.9.1",
91
92
  "typescript": "^5.0.2",
92
93
  "vitest": "^0.34.3",
@@ -96,9 +97,6 @@
96
97
  "lodash-es": "^4.17.21"
97
98
  },
98
99
  "peerDependencies": {
99
- "react": ">= 17"
100
- },
101
- "optionalDependencies": {
102
- "gsap": "npm:@gsap/business@3.12.2"
100
+ "react": ">= 18"
103
101
  }
104
102
  }