@growth-angels/ds-core 1.18.0 → 1.20.0

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,4 +1,2 @@
1
- import { JSX } from "react/jsx-runtime";
2
1
  import type { ButtonProps } from "./Button.types";
3
- import React from "react";
4
- export declare const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) => JSX.Element;
2
+ export declare const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from "react";
2
+ import { useReactAdapter } from "../../hooks/useReactAdaptater";
3
3
  import { Icon } from "../Icon/Icon";
4
4
  export const Button = (props) => {
5
+ const React = useReactAdapter();
5
6
  const { as, children, variant, preventDefault, icon, extraClassNames, ...restProps } = props;
6
7
  let customVariant = variant;
7
8
  if (icon) {
@@ -1,5 +1,5 @@
1
1
  import { WordpressDefault } from "../../global.types.js";
2
- import React, { ElementType, ComponentPropsWithoutRef } from "react";
2
+ import type { ElementType, ComponentPropsWithoutRef, ReactNode, MouseEventHandler, ElementRef } from "react";
3
3
  export type ButtonVariant = "primary" | "secondary" | "tertiary" | "link" | "icon";
4
4
  export type ButtonProps<T extends ElementType = "button"> = {
5
5
  as?: T;
@@ -7,7 +7,7 @@ export type ButtonProps<T extends ElementType = "button"> = {
7
7
  hasIcon?: "left" | "right";
8
8
  icon?: string;
9
9
  preventDefault?: boolean;
10
- children?: React.ReactNode;
10
+ children?: ReactNode;
11
11
  } & WordpressDefault & Omit<ComponentPropsWithoutRef<T>, "as" | "className" | "onClick"> & {
12
- onClick?: React.MouseEventHandler<React.ElementRef<T>>;
12
+ onClick?: MouseEventHandler<ElementRef<T>>;
13
13
  };
@@ -1,6 +1,5 @@
1
- import React from "react";
2
1
  import { TextProps } from "./Text.types";
3
- export declare const Text: (props: TextProps) => React.DetailedReactHTMLElement<{
2
+ export declare const Text: (props: TextProps) => import("react").DetailedReactHTMLElement<{
4
3
  className: string;
5
- style: React.CSSProperties | undefined;
4
+ style: import("react").CSSProperties | undefined;
6
5
  }, HTMLElement>;
@@ -1,5 +1,6 @@
1
- import React from "react";
1
+ import { useReactAdapter } from "../../hooks/useReactAdaptater";
2
2
  export const Text = (props) => {
3
+ const React = useReactAdapter();
3
4
  const { as, children, classNames, type = "paragraph", size, style } = props;
4
5
  const className = typeof classNames === "string" ? classNames : classNames?.join(" ") || "";
5
6
  return React.createElement(as, {
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  type ReactType = typeof import('react');
3
2
  type ExtendedReactType = ReactType & {
4
3
  createRoot: (container: Element | DocumentFragment) => {
@@ -1,10 +1,9 @@
1
- import React from 'react';
2
1
  export const useReactAdapter = () => {
3
- // Check if WordPress element is available (WordPress context)
4
- if (typeof window !== 'undefined' && window.wp?.element) {
5
- return window.wp.element;
2
+ if (typeof window === 'undefined') {
3
+ throw new Error('useReactAdapter requires a browser environment with window.wp.element');
6
4
  }
7
- // Fallback for non-WordPress environments (Storybook, tests, SSR)
8
- // This will bundle React only in non-WordPress builds
9
- return React;
5
+ if (!window.wp?.element) {
6
+ throw new Error('window.wp.element is not available. Make sure wp-element is loaded.');
7
+ }
8
+ return window.wp.element;
10
9
  };
@@ -1,3 +1,2 @@
1
- import { JSX } from "react/jsx-runtime";
2
1
  import type { CardProps } from "./Card.types";
3
- export declare const Card: ({ children, variant, extraClassNames, type, style, backgroundImage, }: CardProps) => JSX.Element;
2
+ export declare const Card: ({ children, variant, extraClassNames, type, style, backgroundImage }: CardProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export const Card = ({ children, variant = "primary", extraClassNames, type = "image", style, backgroundImage, }) => {
2
+ export const Card = ({ children, variant = "primary", extraClassNames, type = "image", style, backgroundImage }) => {
3
3
  const classNames = ["ga-ds-card", `ga-ds-card--${variant}`, `ga-ds-card--${type}`, ...(extraClassNames || [])];
4
4
  return (_jsxs("div", { ...(style && { style }), className: classNames.join(" "), children: [backgroundImage && _jsx("img", { src: backgroundImage.sizes?.full?.url, alt: backgroundImage?.alt }), children] }));
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-angels/ds-core",
3
- "version": "1.18.0",
3
+ "version": "1.20.0",
4
4
  "description": "Design system by Growth Angels",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,9 +1,9 @@
1
- import { JSX } from "react/jsx-runtime"
2
1
  import type { ButtonProps } from "./Button.types"
3
- import React from "react"
2
+ import { useReactAdapter } from "../../hooks/useReactAdaptater"
4
3
  import { Icon } from "../Icon/Icon"
5
4
 
6
- export const Button = <T extends React.ElementType = "button">(props: ButtonProps<T>): JSX.Element => {
5
+ export const Button = <T extends React.ElementType = "button">(props: ButtonProps<T>) => {
6
+ const React = useReactAdapter()
7
7
  const { as, children, variant, preventDefault, icon, extraClassNames, ...restProps } = props
8
8
  let customVariant = variant
9
9
  if (icon) {
@@ -1,5 +1,5 @@
1
1
  import { WordpressDefault } from "../../global.types.js"
2
- import React, { ElementType, ComponentPropsWithoutRef } from "react"
2
+ import type { ElementType, ComponentPropsWithoutRef, ReactNode, MouseEventHandler, ElementRef } from "react"
3
3
 
4
4
  export type ButtonVariant = "primary" | "secondary" | "tertiary" | "link" | "icon"
5
5
 
@@ -9,8 +9,8 @@ export type ButtonProps<T extends ElementType = "button"> = {
9
9
  hasIcon?: "left" | "right"
10
10
  icon?: string
11
11
  preventDefault?: boolean
12
- children?: React.ReactNode
12
+ children?: ReactNode
13
13
  } & WordpressDefault &
14
14
  Omit<ComponentPropsWithoutRef<T>, "as" | "className" | "onClick"> & {
15
- onClick?: React.MouseEventHandler<React.ElementRef<T>>
15
+ onClick?: MouseEventHandler<ElementRef<T>>
16
16
  }
@@ -1,7 +1,8 @@
1
- import React from "react"
1
+ import { useReactAdapter } from "../../hooks/useReactAdaptater"
2
2
  import { TextProps } from "./Text.types"
3
3
 
4
4
  export const Text = (props: TextProps) => {
5
+ const React = useReactAdapter()
5
6
  const { as, children, classNames, type = "paragraph", size, style } = props
6
7
 
7
8
  const className = typeof classNames === "string" ? classNames : classNames?.join(" ") || ""
@@ -1,4 +1,3 @@
1
- import React from 'react'
2
1
  // @ts-ignore - React types from window.wp.element
3
2
  type ReactType = typeof import('react')
4
3
 
@@ -21,13 +20,14 @@ declare global {
21
20
  }
22
21
 
23
22
  export const useReactAdapter = (): ExtendedReactType => {
24
- // Check if WordPress element is available (WordPress context)
25
- if (typeof window !== 'undefined' && window.wp?.element) {
26
- return window.wp.element
23
+ if (typeof window === 'undefined') {
24
+ throw new Error('useReactAdapter requires a browser environment with window.wp.element')
27
25
  }
28
26
 
29
- // Fallback for non-WordPress environments (Storybook, tests, SSR)
30
- // This will bundle React only in non-WordPress builds
31
- return React as ExtendedReactType
27
+ if (!window.wp?.element) {
28
+ throw new Error('window.wp.element is not available. Make sure wp-element is loaded.')
29
+ }
30
+
31
+ return window.wp.element
32
32
  }
33
33
 
@@ -1,14 +1,6 @@
1
- import { JSX } from "react/jsx-runtime"
2
1
  import type { CardProps } from "./Card.types"
3
2
 
4
- export const Card = ({
5
- children,
6
- variant = "primary",
7
- extraClassNames,
8
- type = "image",
9
- style,
10
- backgroundImage,
11
- }: CardProps): JSX.Element => {
3
+ export const Card = ({ children, variant = "primary", extraClassNames, type = "image", style, backgroundImage }: CardProps) => {
12
4
  const classNames = ["ga-ds-card", `ga-ds-card--${variant}`, `ga-ds-card--${type}`, ...(extraClassNames || [])]
13
5
  return (
14
6
  <div {...(style && { style })} className={classNames.join(" ")}>