@tui-cruises/mein-schiff-web-react-component-library 3.0.0 → 3.0.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.0.2](https://bitbucket.org/yours_truly/tuic-mein-schiff-web-react-component-library/compare/v3.0.1...v3.0.2) (2025-09-12)
6
+
7
+
8
+ ### Features
9
+
10
+ * next15 prep ([cd34983](https://bitbucket.org/yours_truly/tuic-mein-schiff-web-react-component-library/commit/cd3498382498e9476bcf6a9b9972e8ffa7638482))
11
+
12
+ ### [3.0.1](https://bitbucket.org/yours_truly/tuic-mein-schiff-web-react-component-library/compare/v3.0.0...v3.0.1) (2025-09-12)
13
+
5
14
  ## [3.0.0](https://bitbucket.org/yours_truly/tuic-mein-schiff-web-react-component-library/compare/v2.2.9...v3.0.0) (2025-09-12)
6
15
 
7
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tui-cruises/mein-schiff-web-react-component-library",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "main": "./index.tsx",
5
5
  "types": "./index.tsx",
6
6
  "type": "module",
@@ -1,24 +1,14 @@
1
1
  import { ReactElement } from 'react';
2
+ import { isElementWithProps } from '../../../helpers/children';
2
3
 
3
4
  export const assignDefaultValues = (
4
5
  children: ReactElement[],
5
6
  ): ReactElement[] => {
6
- return children.map((item, idx) => {
7
- const props = item.props
8
- ? {
9
- ...item.props,
10
- value:
11
- (item.props &&
12
- typeof item.props === 'object' &&
13
- 'value' in item.props
14
- ? item.props.value
15
- : undefined) ?? `intermediateValue${idx}`,
16
- }
17
- : undefined;
18
-
19
- return {
20
- ...item,
21
- props,
22
- };
23
- });
7
+ return children.filter(isElementWithProps).map((item, idx) => ({
8
+ ...item,
9
+ props: {
10
+ ...item.props,
11
+ value: item.props.value ?? `intermediateValue${idx}`,
12
+ },
13
+ }));
24
14
  };
@@ -10,6 +10,7 @@ import { isElement, isFragment } from 'react-is';
10
10
  import { CarouselStage } from './CarouselStage';
11
11
  import { ScrollToIndex } from './CarouselInterface';
12
12
  import { logger } from '@tuic/logger';
13
+ import { isElementWithProps } from '../../../helpers/children';
13
14
 
14
15
  type StageRef = RefObject<HTMLUListElement | undefined | null>;
15
16
 
@@ -36,6 +37,10 @@ export const getChildrenAsArrayOfElements = (
36
37
  return asArray;
37
38
  }
38
39
 
40
+ if (!isElementWithProps(maybeFragment)) {
41
+ return asArray;
42
+ }
43
+
39
44
  // ... and if so, return its children instead.
40
45
  // We could make this recursive, but let's not dive too deep into the rabbit hole.
41
46
  return Children.toArray(maybeFragment.props.children).filter(
@@ -1,11 +1,11 @@
1
- import { Children, PropsWithChildren, ReactElement } from 'react';
2
- import { isElement, isFragment } from 'react-is';
1
+ import { Children, isValidElement, PropsWithChildren, ReactElement } from 'react';
2
+ import { isFragment } from 'react-is';
3
3
 
4
4
  export const getChildrenAsArrayOfElements = (
5
5
  children: PropsWithChildren['children'],
6
6
  ): ReactElement[] => {
7
7
  const asArray = Children.toArray(children).filter(
8
- (node): node is ReactElement => isElement(node),
8
+ (node): node is ReactElement => isValidElement(node),
9
9
  );
10
10
 
11
11
  if (asArray.length !== 1) {
@@ -18,10 +18,19 @@ export const getChildrenAsArrayOfElements = (
18
18
  if (!isFragment(maybeFragment)) {
19
19
  return asArray;
20
20
  }
21
+ if (!isElementWithProps(maybeFragment)) {
22
+ return asArray;
23
+ }
21
24
 
22
25
  // ... and if so, return its children instead.
23
26
  // We could make this recursive, but let's not dive too deep into the rabbit hole.
24
27
  return Children.toArray(maybeFragment.props.children).filter(
25
- (node): node is ReactElement => isElement(node),
28
+ (node): node is ReactElement => isValidElement(node),
26
29
  );
27
30
  };
31
+
32
+ export function isElementWithProps<P extends Record<string, any>>(
33
+ element: any,
34
+ ): element is ReactElement<P> {
35
+ return isValidElement(element) && element.props !== undefined;
36
+ }
@@ -1,4 +1,5 @@
1
1
  import { Children, cloneElement, isValidElement, PropsWithChildren, ReactNode } from 'react';
2
+ import { isElementWithProps } from './children';
2
3
 
3
4
  /**
4
5
  * Dynamically wraps the children intended for a Radix UI `Slot` with a specified wrapper element or component.
@@ -64,7 +65,9 @@ export const wrapSlottableChildren = (
64
65
  return wrapper(children);
65
66
  }
66
67
 
67
- const props = child.props as PropsWithChildren
68
+ if (!isElementWithProps(child)) {
69
+ return wrapper(children);
70
+ }
68
71
 
69
- return cloneElement(child, undefined, wrapper(props?.children));
72
+ return cloneElement(child, undefined, wrapper(child.props.children));
70
73
  };