@stack-spot/citric-react 0.4.0 → 0.5.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,14 +1,17 @@
1
1
  import { WithColorPalette, WithColorScheme } from '../types.js';
2
2
  export type CitricComponentName = 'alert' | 'avatar' | 'badge' | 'blockquote' | 'breadcrumb' | 'button' | 'card' | 'checkbox' | 'checkbox-row' | 'divider' | 'field-group' | 'form-group' | 'form' | 'icon-box' | 'input' | 'link' | 'pagination' | 'progress-bar' | 'progress-circular' | 'radio' | 'radio-row' | 'rating' | 'select' | 'select-box' | 'skeleton' | 'slider' | 'switch' | 'switch-row' | 'table' | 'tabs' | 'accordion' | 'favorite' | 'textarea' | 'avatar-group' | 'labeled-slider' | 'rich-select' | 'tooltip' | 'menu' | 'circle';
3
- interface CustomProps<T extends keyof JSX.IntrinsicElements> extends WithColorScheme, WithColorPalette {
4
- tag: T;
3
+ interface BaseCitricProps extends WithColorScheme, WithColorPalette {
5
4
  component: CitricComponentName;
6
5
  }
7
- type Props<T extends keyof JSX.IntrinsicElements> = CustomProps<T> & JSX.IntrinsicElements[T];
8
6
  interface CitricComponentType {
9
- <T extends keyof JSX.IntrinsicElements>(props: Props<T>): React.ReactNode;
7
+ <T extends keyof JSX.IntrinsicElements>(props: {
8
+ tag: T;
9
+ } & BaseCitricProps & JSX.IntrinsicElements[T]): React.ReactNode;
10
+ <T extends Record<string, any>>(props: {
11
+ render: React.FC<T>;
12
+ } & BaseCitricProps & T): React.ReactNode;
10
13
  }
11
- export declare function asCitricProps({ colorScheme, colorPalette, component, ...props }: Omit<CustomProps<any>, 'tag'> & Record<string, any>): Record<string, any>;
14
+ export declare function asCitricProps({ colorScheme, colorPalette, component, ...props }: BaseCitricProps & Record<string, any>): Record<string, any>;
12
15
  export declare const CitricComponent: CitricComponentType;
13
16
  export {};
14
17
  //# sourceMappingURL=CitricComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Cit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C,GAAG,KAAK,CAAC,SAAS,CAAC;CACxG;AAED,wBAAgB,aAAa,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,uBAKtH;AAGD,eAAO,MAAM,eAAe,EAAE,mBAK7B,CAAA"}
@@ -9,7 +9,7 @@ export function asCitricProps({ colorScheme, colorPalette, component, ...props }
9
9
  }
10
10
  // eslint-disable-next-line react/display-name
11
11
  export const CitricComponent = forwardRef((props, ref) => {
12
- const { tag, ...citricProps } = asCitricProps(props);
13
- return createElement(tag, { ...citricProps, ref });
12
+ const { tag, render, ...citricProps } = asCitricProps(props);
13
+ return createElement(tag || render, { ...citricProps, ref });
14
14
  });
15
15
  //# sourceMappingURL=CitricComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CitricComponent.js","sourceRoot":"","sources":["../../src/components/CitricComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAoBjD,MAAM,UAAU,aAAa,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,KAAK,EAAuD;IACnI,MAAM,WAAW,GAAwB,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,CAAA;IAC/E,IAAI,WAAW;QAAE,WAAW,CAAC,mBAAmB,CAAC,GAAG,WAAW,CAAA;IAC/D,IAAI,YAAY;QAAE,WAAW,CAAC,oBAAoB,CAAC,GAAG,YAAY,CAAA;IAClE,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAwB,UAAU,CAC5D,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IACpD,OAAO,aAAa,CAAC,GAAG,EAAE,EAAE,GAAG,WAAW,EAAE,GAAG,EAAE,CAAC,CAAA;AACpD,CAAC,CACF,CAAA"}
1
+ {"version":3,"file":"CitricComponent.js","sourceRoot":"","sources":["../../src/components/CitricComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAkBjD,MAAM,UAAU,aAAa,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,KAAK,EAAyC;IACrH,MAAM,WAAW,GAAwB,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,CAAA;IAC/E,IAAI,WAAW;QAAE,WAAW,CAAC,mBAAmB,CAAC,GAAG,WAAW,CAAA;IAC/D,IAAI,YAAY;QAAE,WAAW,CAAC,oBAAoB,CAAC,GAAG,YAAY,CAAA;IAClE,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAwB,UAAU,CAC5D,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IAC5D,OAAO,aAAa,CAAC,GAAG,IAAI,MAAM,EAAE,EAAE,GAAG,WAAW,EAAE,GAAG,EAAE,CAAC,CAAA;AAC9D,CAAC,CACF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stack-spot/citric-react",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "author": "StackSpot",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -7,18 +7,16 @@ export type CitricComponentName = 'alert' | 'avatar' | 'badge' | 'blockquote' |
7
7
  'table' | 'tabs' | 'accordion' | 'favorite' | 'textarea' | 'avatar-group' | 'labeled-slider' | 'rich-select' | 'tooltip' | 'menu' |
8
8
  'circle'
9
9
 
10
- interface CustomProps<T extends keyof JSX.IntrinsicElements> extends WithColorScheme, WithColorPalette {
11
- tag: T,
10
+ interface BaseCitricProps extends WithColorScheme, WithColorPalette {
12
11
  component: CitricComponentName,
13
12
  }
14
13
 
15
- type Props<T extends keyof JSX.IntrinsicElements> = CustomProps<T> & JSX.IntrinsicElements[T]
16
-
17
14
  interface CitricComponentType {
18
- <T extends keyof JSX.IntrinsicElements>(props: Props<T>): React.ReactNode,
15
+ <T extends keyof JSX.IntrinsicElements>(props: { tag: T } & BaseCitricProps & JSX.IntrinsicElements[T]): React.ReactNode,
16
+ <T extends Record<string, any>>(props: { render: React.FC<T> } & BaseCitricProps & T): React.ReactNode,
19
17
  }
20
18
 
21
- export function asCitricProps({ colorScheme, colorPalette, component, ...props }: Omit<CustomProps<any>, 'tag'> & Record<string, any>) {
19
+ export function asCitricProps({ colorScheme, colorPalette, component, ...props }: BaseCitricProps & Record<string, any>) {
22
20
  const citricProps: Record<string, any> = { ...props, 'data-citric': component }
23
21
  if (colorScheme) citricProps['data-color-scheme'] = colorScheme
24
22
  if (colorPalette) citricProps['data-color-palette'] = colorPalette
@@ -26,9 +24,9 @@ export function asCitricProps({ colorScheme, colorPalette, component, ...props }
26
24
  }
27
25
 
28
26
  // eslint-disable-next-line react/display-name
29
- export const CitricComponent: CitricComponentType = forwardRef<Props<any>, any>(
27
+ export const CitricComponent: CitricComponentType = forwardRef<any, any>(
30
28
  (props, ref) => {
31
- const { tag, ...citricProps } = asCitricProps(props)
32
- return createElement(tag, { ...citricProps, ref })
29
+ const { tag, render, ...citricProps } = asCitricProps(props)
30
+ return createElement(tag || render, { ...citricProps, ref })
33
31
  },
34
32
  )