@stack-spot/citric-react 0.3.2 → 0.4.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/citric.css +4 -0
- package/dist/components/Accordion.d.ts +1 -2
- package/dist/components/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Alert.d.ts +1 -2
- package/dist/components/Alert.d.ts.map +1 -1
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Avatar.d.ts +2 -2
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/AvatarGroup.d.ts +2 -2
- package/dist/components/AvatarGroup.d.ts.map +1 -1
- package/dist/components/Badge.d.ts +2 -2
- package/dist/components/Badge.d.ts.map +1 -1
- package/dist/components/Blockquote.d.ts +2 -2
- package/dist/components/Blockquote.d.ts.map +1 -1
- package/dist/components/Breadcrumb.d.ts +1 -2
- package/dist/components/Breadcrumb.d.ts.map +1 -1
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Card.d.ts +2 -2
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Checkbox.d.ts +2 -2
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/CheckboxGroup.d.ts +2 -2
- package/dist/components/CheckboxGroup.d.ts.map +1 -1
- package/dist/components/Circle.d.ts +2 -2
- package/dist/components/Circle.d.ts.map +1 -1
- package/dist/components/CitricComponent.d.ts +1 -1
- package/dist/components/CitricComponent.d.ts.map +1 -1
- package/dist/components/CitricComponent.js.map +1 -1
- package/dist/components/Divider.d.ts +2 -2
- package/dist/components/Divider.d.ts.map +1 -1
- package/dist/components/Favorite.d.ts +2 -2
- package/dist/components/Favorite.d.ts.map +1 -1
- package/dist/components/FieldGroup.d.ts +1 -2
- package/dist/components/FieldGroup.d.ts.map +1 -1
- package/dist/components/FieldGroup.js.map +1 -1
- package/dist/components/FormGroup.d.ts +1 -2
- package/dist/components/FormGroup.d.ts.map +1 -1
- package/dist/components/FormGroup.js.map +1 -1
- package/dist/components/IconBox.d.ts +2 -2
- package/dist/components/IconBox.d.ts.map +1 -1
- package/dist/components/Input.d.ts +3 -3
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Link.d.ts +2 -2
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/MenuOverlay/types.d.ts +2 -3
- package/dist/components/MenuOverlay/types.d.ts.map +1 -1
- package/dist/components/Overlay/types.d.ts +2 -2
- package/dist/components/Overlay/types.d.ts.map +1 -1
- package/dist/components/Pagination.d.ts +1 -2
- package/dist/components/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination.js.map +1 -1
- package/dist/components/ProgressBar.d.ts +2 -2
- package/dist/components/ProgressBar.d.ts.map +1 -1
- package/dist/components/ProgressCircular.d.ts +2 -2
- package/dist/components/ProgressCircular.d.ts.map +1 -1
- package/dist/components/RadioGroup.d.ts +2 -2
- package/dist/components/RadioGroup.d.ts.map +1 -1
- package/dist/components/Rating.d.ts +1 -2
- package/dist/components/Rating.d.ts.map +1 -1
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/Select/SimpleSelect.d.ts.map +1 -1
- package/dist/components/Select/SimpleSelect.js +4 -6
- package/dist/components/Select/SimpleSelect.js.map +1 -1
- package/dist/components/Select/types.d.ts +2 -2
- package/dist/components/Select/types.d.ts.map +1 -1
- package/dist/components/SelectBox.d.ts +2 -2
- package/dist/components/SelectBox.d.ts.map +1 -1
- package/dist/components/Skeleton.d.ts +1 -2
- package/dist/components/Skeleton.d.ts.map +1 -1
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Slider.d.ts +2 -2
- package/dist/components/Slider.d.ts.map +1 -1
- package/dist/components/Stepper.d.ts +1 -2
- package/dist/components/Stepper.d.ts.map +1 -1
- package/dist/components/Stepper.js.map +1 -1
- package/dist/components/Switch.d.ts +2 -2
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Table.d.ts +3 -4
- package/dist/components/Table.d.ts.map +1 -1
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs/types.d.ts +2 -2
- package/dist/components/Tabs/types.d.ts.map +1 -1
- package/dist/components/Text.d.ts +16 -4
- 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/dist/components/Textarea.d.ts +2 -2
- package/dist/components/Textarea.d.ts.map +1 -1
- package/dist/components/Tooltip.d.ts +2 -2
- package/dist/components/Tooltip.d.ts.map +1 -1
- package/dist/components/layout.d.ts +4 -4
- package/dist/components/layout.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Accordion.tsx +1 -2
- package/src/components/Alert.tsx +1 -2
- package/src/components/Avatar.tsx +2 -2
- package/src/components/AvatarGroup.tsx +2 -2
- package/src/components/Badge.tsx +2 -2
- package/src/components/Blockquote.tsx +2 -2
- package/src/components/Breadcrumb.tsx +1 -2
- package/src/components/Button.tsx +2 -2
- package/src/components/Card.tsx +2 -2
- package/src/components/Checkbox.tsx +2 -2
- package/src/components/CheckboxGroup.tsx +2 -2
- package/src/components/Circle.tsx +2 -2
- package/src/components/CitricComponent.ts +1 -1
- package/src/components/Divider.tsx +2 -2
- package/src/components/Favorite.tsx +2 -2
- package/src/components/FieldGroup.tsx +1 -2
- package/src/components/FormGroup.tsx +1 -2
- package/src/components/IconBox.tsx +2 -2
- package/src/components/Input.tsx +2 -2
- package/src/components/Link.tsx +2 -2
- package/src/components/MenuOverlay/types.ts +2 -3
- package/src/components/Overlay/types.ts +2 -3
- package/src/components/Pagination.tsx +1 -2
- package/src/components/ProgressBar.tsx +2 -2
- package/src/components/ProgressCircular.tsx +2 -2
- package/src/components/RadioGroup.tsx +2 -2
- package/src/components/Rating.tsx +1 -2
- package/src/components/Select/SimpleSelect.tsx +12 -6
- package/src/components/Select/types.ts +2 -2
- package/src/components/SelectBox.tsx +2 -2
- package/src/components/Skeleton.tsx +1 -2
- package/src/components/Slider.tsx +2 -2
- package/src/components/Stepper.tsx +1 -2
- package/src/components/Switch.tsx +2 -2
- package/src/components/Table.tsx +3 -4
- package/src/components/Tabs/types.ts +2 -2
- package/src/components/Text.ts +21 -4
- package/src/components/Textarea.tsx +2 -2
- package/src/components/Tooltip.tsx +2 -2
- package/src/components/layout.tsx +4 -4
- package/src/types.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WithColorPalette, WithColorScheme } from '../../types'
|
|
2
2
|
import { TabController } from './TabController'
|
|
3
3
|
|
|
4
4
|
export interface Tab<Key extends string> {
|
|
@@ -45,4 +45,4 @@ export interface BaseTabsProps<Key extends string> extends WithColorScheme, With
|
|
|
45
45
|
controller?: TabController<Key>,
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export type TabsProps<Key extends string> =
|
|
48
|
+
export type TabsProps<Key extends string> = React.JSX.IntrinsicElements['div'] & BaseTabsProps<Key>
|
package/src/components/Text.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
2
|
import { createElement } from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { HTMLTag, TextAppearance, WithColor } from '../types'
|
|
4
4
|
import { applyColor, applyTextAppearance } from '../utils/css'
|
|
5
5
|
|
|
6
6
|
type SupportedTags = 'span' | 'small' | 'p' | `h${1|2|3|4|5|6}` | 'pre'
|
|
@@ -22,9 +22,21 @@ 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
|
-
export type TextProps<T extends SupportedTags> =
|
|
39
|
+
export type TextProps<T extends SupportedTags> = HTMLTag[T] & BaseTextProps<T>
|
|
28
40
|
|
|
29
41
|
const tagToAppearance: Record<SupportedTags, TextAppearance | undefined> = {
|
|
30
42
|
h1: 'h1',
|
|
@@ -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
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ControlledTextarea, WithColorScheme } from '../types'
|
|
2
2
|
import { CitricComponent } from './CitricComponent'
|
|
3
3
|
|
|
4
4
|
export interface BaseTextareaProps extends WithColorScheme {
|
|
@@ -6,7 +6,7 @@ export interface BaseTextareaProps extends WithColorScheme {
|
|
|
6
6
|
onChange?: (value: string) => void,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export type TextareaProps =
|
|
9
|
+
export type TextareaProps = ControlledTextarea & BaseTextareaProps
|
|
10
10
|
|
|
11
11
|
export const Textarea = ({ value, onChange, ...props }: TextareaProps) =>
|
|
12
12
|
<CitricComponent tag="textarea" component="textarea" value={value} onChange={e => onChange?.(e.target.value)} {...props} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
2
|
import { useRef } from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { WithColorPalette, WithColorScheme } from '../types'
|
|
4
4
|
import { Overlay } from './Overlay'
|
|
5
5
|
import { BaseOverlayProps } from './Overlay/types'
|
|
6
6
|
|
|
@@ -32,7 +32,7 @@ export interface BaseTooltipProps extends
|
|
|
32
32
|
disabled?: boolean,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export type TooltipProps =
|
|
35
|
+
export type TooltipProps = React.JSX.IntrinsicElements['div'] & BaseTooltipProps
|
|
36
36
|
|
|
37
37
|
export const Tooltip = (
|
|
38
38
|
{ tooltipId, children, showArrow = true, compact = true, attributes, colorScheme, colorPalette, disabled, ...props }: TooltipProps,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
2
|
import { createElement } from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { HTMLTag, WithStyleShortcuts } from '../types'
|
|
4
4
|
import { applyStyles } from '../utils/css'
|
|
5
5
|
|
|
6
6
|
export const layout = {
|
|
@@ -36,9 +36,9 @@ export interface BaseColumnProps<T extends keyof HTMLTag> extends BaseLayoutProp
|
|
|
36
36
|
center?: boolean,
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export type CenterProps<T extends keyof HTMLTag> =
|
|
40
|
-
export type RowProps<T extends keyof HTMLTag> =
|
|
41
|
-
export type ColumnProps<T extends keyof HTMLTag> =
|
|
39
|
+
export type CenterProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseLayoutProps<T>
|
|
40
|
+
export type RowProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseRowProps<T>
|
|
41
|
+
export type ColumnProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseColumnProps<T>
|
|
42
42
|
|
|
43
43
|
export function Center<T extends keyof HTMLTag = 'div'>({ tag, className, ...props }: CenterProps<T>) {
|
|
44
44
|
return createElement(tag || 'div', { className: listToClass(['center', className]), ...applyStyles(props) })
|
package/src/types.ts
CHANGED
|
@@ -51,7 +51,8 @@ export type HTMLTag = {
|
|
|
51
51
|
ul: React.HTMLAttributes<HTMLUListElement>,
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export type
|
|
54
|
+
export type ControlledInput = Omit<React.JSX.IntrinsicElements['input'], 'value' | 'onChange'>
|
|
55
|
+
export type ControlledTextarea = Omit<React.JSX.IntrinsicElements['textarea'], 'value' | 'onChange'>
|
|
55
56
|
|
|
56
57
|
export interface WithStyleShortcuts {
|
|
57
58
|
/**
|