@stack-spot/citric-react 0.3.3 → 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.
- package/dist/components/CitricComponent.d.ts +8 -5
- package/dist/components/CitricComponent.d.ts.map +1 -1
- package/dist/components/CitricComponent.js +2 -2
- package/dist/components/CitricComponent.js.map +1 -1
- package/dist/components/Text.d.ts +14 -2
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +8 -2
- package/dist/components/Text.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CitricComponent.ts +7 -9
- package/src/components/Text.ts +19 -2
|
@@ -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
|
|
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:
|
|
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 }:
|
|
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":"CitricComponent.d.ts","sourceRoot":"","sources":["../../src/components/CitricComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE5D,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAC3H,cAAc,GAAG,SAAS,GAAG,aAAa,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,cAAc,GAClI,mBAAmB,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAClI,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,gBAAgB,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,GACjI,QAAQ,CAAA;AAEV,UAAU,
|
|
1
|
+
{"version":3,"file":"CitricComponent.d.ts","sourceRoot":"","sources":["../../src/components/CitricComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE5D,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,YAAY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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;
|
|
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"}
|
|
@@ -17,11 +17,23 @@ export interface BaseTextProps<T extends SupportedTags = SupportedTags> extends
|
|
|
17
17
|
* @default false
|
|
18
18
|
*/
|
|
19
19
|
showMargins?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Shortcut to `style.fontWeight`.
|
|
22
|
+
*/
|
|
23
|
+
weight?: React.CSSProperties['fontWeight'];
|
|
24
|
+
/**
|
|
25
|
+
* Shortcut to `style.textAlign`.
|
|
26
|
+
*/
|
|
27
|
+
align?: React.CSSProperties['textAlign'];
|
|
28
|
+
/**
|
|
29
|
+
* Shortcut to `style.whiteSpace = 'nowrap'; style.overflow = 'hidden'; style.textOverflow = 'ellipsis'`.
|
|
30
|
+
*/
|
|
31
|
+
nowrapEllipsis?: boolean;
|
|
20
32
|
}
|
|
21
33
|
export type TextProps<T extends SupportedTags> = HTMLTag[T] & BaseTextProps<T>;
|
|
22
|
-
export declare function Text<T extends SupportedTags>({ tag, appearance, color, showMargins, style, className, children, ...props }: TextProps<T>): import("react").DetailedReactHTMLElement<{
|
|
34
|
+
export declare function Text<T extends SupportedTags>({ tag, appearance, color, showMargins, weight, align, nowrapEllipsis, style, className, children, ...props }: TextProps<T>): import("react").DetailedReactHTMLElement<{
|
|
23
35
|
className: string;
|
|
24
36
|
style: import("react").CSSProperties | undefined;
|
|
25
|
-
} & Omit<TextProps<T>, "className" | "style" | "color" | "children" | "appearance" | "tag" | "showMargins">, HTMLElement>;
|
|
37
|
+
} & Omit<TextProps<T>, "className" | "style" | "color" | "children" | "weight" | "appearance" | "tag" | "align" | "showMargins" | "nowrapEllipsis">, HTMLElement>;
|
|
26
38
|
export {};
|
|
27
39
|
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/components/Text.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAG7D,KAAK,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,CAAA;AAoC9E,wBAAgB,IAAI,CAAC,CAAC,SAAS,aAAa,EAC1C,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;;;kKAiB3H"}
|
package/dist/components/Text.js
CHANGED
|
@@ -33,11 +33,17 @@ const appearanceToTag = {
|
|
|
33
33
|
subtitle3: 'p',
|
|
34
34
|
subtitle4: 'p',
|
|
35
35
|
};
|
|
36
|
-
export function Text({ tag, appearance, color, showMargins, style, className, children, ...props }) {
|
|
36
|
+
export function Text({ tag, appearance, color, showMargins, weight, align, nowrapEllipsis, style, className, children, ...props }) {
|
|
37
37
|
const renderedTag = tag || appearanceToTag[appearance || 'body2'];
|
|
38
38
|
const renderedAppearance = appearance || (tag ? tagToAppearance[tag] : undefined);
|
|
39
39
|
if (!appearance && !showMargins)
|
|
40
|
-
style = {
|
|
40
|
+
style = { margin: 0, ...style };
|
|
41
|
+
if (weight)
|
|
42
|
+
style = { fontWeight: weight, ...style };
|
|
43
|
+
if (align)
|
|
44
|
+
style = { textAlign: align, ...style };
|
|
45
|
+
if (nowrapEllipsis)
|
|
46
|
+
style = { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', ...style };
|
|
41
47
|
return createElement(renderedTag, {
|
|
42
48
|
className: applyTextAppearance(listToClass([className, showMargins && 'text-with-margins']), renderedAppearance),
|
|
43
49
|
style: applyColor(style, color),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../src/components/Text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,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jE,MAAM,kBAAkB,GAAG,UAAU,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACjF,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW;QAAE,KAAK,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAA;IAChE,IAAI,MAAM;QAAE,KAAK,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAA;IACpD,IAAI,KAAK;QAAE,KAAK,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAAA;IACjD,IAAI,cAAc;QAAE,KAAK,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,CAAA;IAC5G,OAAO,aAAa,CAClB,WAAW,EACX;QACE,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC,SAAS,EAAE,WAAW,IAAI,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,CAAC;QAChH,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC;QAC/B,GAAG,KAAK;KACT,EACD,QAAQ,CACT,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -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
|
|
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:
|
|
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 }:
|
|
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<
|
|
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
|
)
|
package/src/components/Text.ts
CHANGED
|
@@ -22,6 +22,18 @@ export interface BaseTextProps<T extends SupportedTags = SupportedTags> extends
|
|
|
22
22
|
* @default false
|
|
23
23
|
*/
|
|
24
24
|
showMargins?: boolean,
|
|
25
|
+
/**
|
|
26
|
+
* Shortcut to `style.fontWeight`.
|
|
27
|
+
*/
|
|
28
|
+
weight?: React.CSSProperties['fontWeight'],
|
|
29
|
+
/**
|
|
30
|
+
* Shortcut to `style.textAlign`.
|
|
31
|
+
*/
|
|
32
|
+
align?: React.CSSProperties['textAlign'],
|
|
33
|
+
/**
|
|
34
|
+
* Shortcut to `style.whiteSpace = 'nowrap'; style.overflow = 'hidden'; style.textOverflow = 'ellipsis'`.
|
|
35
|
+
*/
|
|
36
|
+
nowrapEllipsis?: boolean,
|
|
25
37
|
}
|
|
26
38
|
|
|
27
39
|
export type TextProps<T extends SupportedTags> = HTMLTag[T] & BaseTextProps<T>
|
|
@@ -60,10 +72,15 @@ const appearanceToTag: Record<TextAppearance, SupportedTags> = {
|
|
|
60
72
|
subtitle4: 'p',
|
|
61
73
|
}
|
|
62
74
|
|
|
63
|
-
export function Text<T extends SupportedTags>(
|
|
75
|
+
export function Text<T extends SupportedTags>(
|
|
76
|
+
{ tag, appearance, color, showMargins, weight, align, nowrapEllipsis, style, className, children, ...props }: TextProps<T>,
|
|
77
|
+
) {
|
|
64
78
|
const renderedTag = tag || appearanceToTag[appearance || 'body2']
|
|
65
79
|
const renderedAppearance = appearance || (tag ? tagToAppearance[tag] : undefined)
|
|
66
|
-
if (!appearance && !showMargins) style = {
|
|
80
|
+
if (!appearance && !showMargins) style = { margin: 0, ...style }
|
|
81
|
+
if (weight) style = { fontWeight: weight, ...style }
|
|
82
|
+
if (align) style = { textAlign: align, ...style }
|
|
83
|
+
if (nowrapEllipsis) style = { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', ...style }
|
|
67
84
|
return createElement(
|
|
68
85
|
renderedTag,
|
|
69
86
|
{
|