@wonderflow/react-components 10.0.0-next.3 → 10.0.0-next.4

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 +1 @@
1
- {"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../../src/components/title/title.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3C,oBAAY,UAAU,GAAG;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IACtD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACxC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,aAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE5E,eAAO,MAAM,KAAK,kBAkCI,CAAC"}
1
+ {"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../../src/components/title/title.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3C,oBAAY,UAAU,GAAG;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IACtD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACxC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,aAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE5E,eAAO,MAAM,KAAK,kBA6CI,CAAC"}
@@ -1,15 +1,22 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import clsx from 'clsx';
3
- import { forwardRef } from 'react';
4
- import { useUIDSeed } from 'react-uid';
3
+ import { Children, forwardRef, useCallback, } from 'react';
5
4
  import slugify from 'slugify';
6
5
  import styles from './title.module.css';
7
6
  export const Title = forwardRef(({ children, className, as: Wrapper = 'span', lineHeight = 'small', level = '1', textAlign = 'start', maxWidth, responsive = true, style, id, ...otherProps }, forwardedRef) => {
8
7
  const computedLevel = level.match(/\d/g) ? `H${level}` : `${level.charAt(0).toUpperCase()}${level.slice(1)}`;
9
- const uid = useUIDSeed();
8
+ const getTextFromChildren = useCallback(() => {
9
+ let label = '';
10
+ Children.map(children, (child) => {
11
+ if (typeof child === 'string') {
12
+ label += child;
13
+ }
14
+ });
15
+ return label;
16
+ }, [children]);
10
17
  const dynamicStyle = {
11
18
  '--max-w': maxWidth,
12
19
  '--t-align': textAlign,
13
20
  };
14
- return (_jsx(Wrapper, { ref: forwardedRef, "data-title-line-height": lineHeight, "data-title-responsive": responsive, className: clsx(styles.Title, styles[computedLevel], className), style: { ...dynamicStyle, ...style }, id: slugify(String(id ?? uid('title-section')), { lower: true }), ...otherProps, children: children }));
21
+ return (_jsx(Wrapper, { ref: forwardedRef, "data-title-line-height": lineHeight, "data-title-responsive": responsive, className: clsx(styles.Title, styles[computedLevel], className), style: { ...dynamicStyle, ...style }, id: slugify(String(id ?? getTextFromChildren()), { lower: true }), ...otherProps, children: children }));
15
22
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "10.0.0-next.3",
3
+ "version": "10.0.0-next.4",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
@@ -80,7 +80,7 @@
80
80
  "react-dom": "17.0.2",
81
81
  "storybook-addon-themes": "6.1.0",
82
82
  "storybook-css-modules-preset": "1.1.1",
83
- "tsconfig": "*",
83
+ "tsconfig": "1.0.0-next.0",
84
84
  "typescript": "4.7.3",
85
85
  "typescript-plugin-css-modules": "3.4.0"
86
86
  },