@stack-spot/citric-react 0.38.0 → 0.39.1
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/CHANGELOG.md +13 -13
- package/dist/citric.css +2844 -2844
- package/dist/components/Accordion.d.ts +1 -1
- package/dist/components/Accordion.js +1 -1
- package/dist/components/Alert.d.ts +1 -1
- package/dist/components/Alert.js +1 -1
- package/dist/components/AsyncContent.d.ts +1 -1
- package/dist/components/AsyncContent.js +1 -1
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +1 -1
- package/dist/components/AvatarGroup.d.ts +1 -1
- package/dist/components/AvatarGroup.js +1 -1
- package/dist/components/Badge.d.ts +1 -1
- package/dist/components/Badge.js +1 -1
- package/dist/components/Blockquote.d.ts +1 -1
- package/dist/components/Blockquote.js +1 -1
- package/dist/components/Breadcrumb.d.ts +1 -1
- package/dist/components/Breadcrumb.js +1 -1
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/ButtonLink.d.ts +1 -1
- package/dist/components/ButtonLink.js +1 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.js +1 -1
- package/dist/components/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/CheckboxGroup.d.ts +1 -1
- package/dist/components/CheckboxGroup.d.ts.map +1 -1
- package/dist/components/CheckboxGroup.js +2 -2
- package/dist/components/CheckboxGroup.js.map +1 -1
- package/dist/components/Circle.d.ts +1 -1
- package/dist/components/Circle.js +1 -1
- package/dist/components/Divider.d.ts +1 -1
- package/dist/components/Divider.js +1 -1
- package/dist/components/ErrorBoundary.d.ts +1 -1
- package/dist/components/ErrorBoundary.js +1 -1
- package/dist/components/ErrorMessage.d.ts +1 -1
- package/dist/components/ErrorMessage.js +1 -1
- package/dist/components/FallbackBoundary.d.ts +1 -1
- package/dist/components/FallbackBoundary.js +1 -1
- package/dist/components/Favorite.d.ts +1 -1
- package/dist/components/Favorite.js +1 -1
- package/dist/components/FieldGroup.d.ts +1 -1
- package/dist/components/FieldGroup.js +1 -1
- package/dist/components/Form.d.ts +2 -2
- package/dist/components/Form.js +1 -1
- package/dist/components/FormGroup.d.ts +1 -1
- package/dist/components/FormGroup.js +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +1 -1
- package/dist/components/IconBox.d.ts +3 -3
- package/dist/components/IconBox.js +1 -1
- package/dist/components/ImageBox.d.ts +3 -3
- package/dist/components/ImageBox.js +1 -1
- package/dist/components/ImageWithFallback.d.ts +1 -1
- package/dist/components/ImageWithFallback.js +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/LoadingPanel.d.ts +1 -1
- package/dist/components/LoadingPanel.js +1 -1
- package/dist/components/MenuOverlay/Menu.d.ts +1 -1
- package/dist/components/MenuOverlay/Menu.js +1 -1
- package/dist/components/MenuOverlay/index.d.ts +1 -1
- package/dist/components/MenuOverlay/index.js +1 -1
- package/dist/components/Overlay/index.d.ts +4 -1
- package/dist/components/Overlay/index.d.ts.map +1 -1
- package/dist/components/Overlay/index.js +4 -1
- package/dist/components/Overlay/index.js.map +1 -1
- package/dist/components/Pagination.d.ts +1 -1
- package/dist/components/Pagination.js +1 -1
- package/dist/components/ProgressBar.d.ts +1 -1
- package/dist/components/ProgressBar.js +1 -1
- package/dist/components/ProgressCircular.d.ts +1 -1
- package/dist/components/ProgressCircular.js +1 -1
- package/dist/components/RadioGroup.d.ts +1 -1
- package/dist/components/RadioGroup.d.ts.map +1 -1
- package/dist/components/RadioGroup.js +2 -2
- package/dist/components/RadioGroup.js.map +1 -1
- package/dist/components/Rating.d.ts +1 -1
- package/dist/components/Rating.js +1 -1
- package/dist/components/Select/MultiSelect.d.ts +1 -1
- package/dist/components/Select/MultiSelect.js +1 -1
- package/dist/components/Select/RichSelect.d.ts +1 -1
- package/dist/components/Select/RichSelect.js +1 -1
- package/dist/components/Select/SimpleSelect.d.ts +1 -1
- package/dist/components/Select/SimpleSelect.js +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SelectBox.d.ts +1 -1
- package/dist/components/SelectBox.js +1 -1
- package/dist/components/Skeleton.d.ts +1 -1
- package/dist/components/Skeleton.js +1 -1
- package/dist/components/Slider.d.ts +1 -1
- package/dist/components/Slider.js +1 -1
- package/dist/components/SmartTable.d.ts +1 -1
- package/dist/components/SmartTable.js +1 -1
- package/dist/components/Stepper.d.ts +1 -1
- package/dist/components/Stepper.js +1 -1
- package/dist/components/Table.d.ts +3 -3
- package/dist/components/Table.js +1 -1
- package/dist/components/Tabs/index.d.ts +1 -1
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Textarea.d.ts +1 -1
- package/dist/components/Textarea.js +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/context/CitricProvider.d.ts +1 -1
- package/dist/context/CitricProvider.js +1 -1
- package/dist/overlay.js +1 -1
- package/dist/theme.css +415 -415
- package/package.json +1 -1
- package/scripts/build-css.ts +49 -49
- package/src/components/Accordion.tsx +130 -130
- package/src/components/Alert.tsx +24 -24
- package/src/components/AsyncContent.tsx +70 -70
- package/src/components/Avatar.tsx +45 -45
- package/src/components/AvatarGroup.tsx +49 -49
- package/src/components/Badge.tsx +47 -47
- package/src/components/Blockquote.tsx +18 -18
- package/src/components/Breadcrumb.tsx +33 -33
- package/src/components/Button.tsx +105 -105
- package/src/components/ButtonLink.tsx +45 -45
- package/src/components/Card.tsx +68 -68
- package/src/components/Checkbox.tsx +51 -51
- package/src/components/CheckboxGroup.tsx +153 -152
- package/src/components/Circle.tsx +43 -43
- package/src/components/CitricComponent.ts +47 -47
- package/src/components/Divider.tsx +24 -24
- package/src/components/ErrorBoundary.tsx +75 -75
- package/src/components/ErrorMessage.tsx +11 -11
- package/src/components/FallbackBoundary.tsx +40 -40
- package/src/components/Favorite.tsx +57 -57
- package/src/components/FieldGroup.tsx +46 -46
- package/src/components/Form.tsx +36 -36
- package/src/components/FormGroup.tsx +57 -57
- package/src/components/Icon.tsx +35 -35
- package/src/components/IconBox.tsx +134 -134
- package/src/components/ImageBox.tsx +125 -125
- package/src/components/ImageWithFallback.tsx +65 -65
- package/src/components/Input.tsx +49 -49
- package/src/components/Link.tsx +55 -55
- package/src/components/LoadingPanel.tsx +8 -8
- package/src/components/MenuOverlay/Menu.tsx +158 -158
- package/src/components/MenuOverlay/context.ts +20 -20
- package/src/components/MenuOverlay/index.tsx +55 -55
- package/src/components/MenuOverlay/keyboard.ts +60 -60
- package/src/components/MenuOverlay/types.ts +171 -171
- package/src/components/Overlay/context.ts +10 -10
- package/src/components/Overlay/index.tsx +167 -164
- package/src/components/Overlay/types.ts +70 -70
- package/src/components/Pagination.tsx +133 -133
- package/src/components/ProgressBar.tsx +45 -45
- package/src/components/ProgressCircular.tsx +45 -45
- package/src/components/RadioGroup.tsx +147 -146
- package/src/components/Rating.tsx +98 -98
- package/src/components/Select/MultiSelect.tsx +217 -217
- package/src/components/Select/RichSelect.tsx +128 -128
- package/src/components/Select/SimpleSelect.tsx +73 -73
- package/src/components/Select/hooks.ts +133 -133
- package/src/components/Select/index.tsx +35 -35
- package/src/components/Select/types.ts +134 -134
- package/src/components/SelectBox.tsx +167 -167
- package/src/components/Skeleton.tsx +53 -53
- package/src/components/Slider.tsx +89 -89
- package/src/components/SmartTable.tsx +227 -227
- package/src/components/Stepper.tsx +163 -163
- package/src/components/Table.tsx +234 -234
- package/src/components/Tabs/TabController.ts +54 -54
- package/src/components/Tabs/index.tsx +87 -87
- package/src/components/Tabs/types.ts +54 -54
- package/src/components/Tabs/utils.ts +6 -6
- package/src/components/Text.ts +111 -111
- package/src/components/Textarea.tsx +27 -27
- package/src/components/Tooltip.tsx +72 -72
- package/src/components/layout.tsx +101 -101
- package/src/context/CitricContext.tsx +4 -4
- package/src/context/CitricProvider.tsx +14 -14
- package/src/context/hooks.ts +6 -6
- package/src/index.ts +58 -58
- package/src/overlay.ts +341 -341
- package/src/types.ts +216 -216
- package/src/utils/ValueController.ts +28 -28
- package/src/utils/acessibility.ts +92 -92
- package/src/utils/checkbox.ts +121 -121
- package/src/utils/css.ts +119 -119
- package/src/utils/options.ts +9 -9
- package/src/utils/radio.ts +93 -93
- package/src/utils/react.ts +6 -6
- package/tsconfig.json +10 -10
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
-
import { useRef } from 'react'
|
|
3
|
-
import { WithColorPalette, WithColorScheme } from '../types'
|
|
4
|
-
import { Overlay } from './Overlay'
|
|
5
|
-
import { BaseOverlayProps } from './Overlay/types'
|
|
6
|
-
|
|
7
|
-
export interface BaseTooltipProps extends
|
|
8
|
-
Omit<BaseOverlayProps<'div'>, 'tag' | 'onRenderChild' | 'reference'>, WithColorPalette, WithColorScheme {
|
|
9
|
-
/**
|
|
10
|
-
* Whether or not to show the tooltip's arrow.
|
|
11
|
-
*
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
|
-
showArrow?: boolean,
|
|
15
|
-
/**
|
|
16
|
-
* The unique id of the HTML element to be created to show the tooltip. If not provided, a random number will be used.
|
|
17
|
-
*/
|
|
18
|
-
tooltipId?: string,
|
|
19
|
-
/**
|
|
20
|
-
* Makes the tooltip text compact, centering it better when it's a single line.
|
|
21
|
-
*
|
|
22
|
-
* Effectively, it makes the line height equals to 1 and applies a slightly larger padding.
|
|
23
|
-
*
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
compact?: boolean,
|
|
27
|
-
/**
|
|
28
|
-
* Whether or not to disable the tooltip, i.e. not show it.
|
|
29
|
-
*
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
disabled?: boolean,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type TooltipProps = Omit<React.JSX.IntrinsicElements['div'], 'content'> & BaseTooltipProps
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Renders a tooltip overlay for its child. By default, the tooltip is rendered on hover, but this can be changed through the property
|
|
39
|
-
* "triggerOn".
|
|
40
|
-
*
|
|
41
|
-
* The content of the tooltip can be any React element.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```
|
|
45
|
-
* <Tooltip content="This is some help for you">
|
|
46
|
-
* <IconButton icon="Question" />
|
|
47
|
-
* </Tooltip>
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export const Tooltip = (
|
|
51
|
-
{ tooltipId, children, showArrow = true, compact = true, attributes, colorScheme, colorPalette, disabled, ...props }: TooltipProps,
|
|
52
|
-
) => {
|
|
53
|
-
const id = useRef(tooltipId || `${Math.random()}`)
|
|
54
|
-
return disabled ? children : (
|
|
55
|
-
<Overlay
|
|
56
|
-
attributes={{
|
|
57
|
-
className: listToClass([attributes?.className, showArrow && 'with-arrow', compact && 'compact']),
|
|
58
|
-
style: { margin: '6px', ...attributes?.style },
|
|
59
|
-
role: 'tooltip',
|
|
60
|
-
id: id.current,
|
|
61
|
-
'data-citric': 'tooltip',
|
|
62
|
-
'data-color-scheme': colorScheme,
|
|
63
|
-
'data-color-palette': colorPalette,
|
|
64
|
-
...attributes,
|
|
65
|
-
}}
|
|
66
|
-
onRenderChild={e => e.setAttribute('aria-describedby', id.current)}
|
|
67
|
-
{...props}
|
|
68
|
-
>
|
|
69
|
-
{children}
|
|
70
|
-
</Overlay>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
1
|
+
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
+
import { useRef } from 'react'
|
|
3
|
+
import { WithColorPalette, WithColorScheme } from '../types'
|
|
4
|
+
import { Overlay } from './Overlay'
|
|
5
|
+
import { BaseOverlayProps } from './Overlay/types'
|
|
6
|
+
|
|
7
|
+
export interface BaseTooltipProps extends
|
|
8
|
+
Omit<BaseOverlayProps<'div'>, 'tag' | 'onRenderChild' | 'reference'>, WithColorPalette, WithColorScheme {
|
|
9
|
+
/**
|
|
10
|
+
* Whether or not to show the tooltip's arrow.
|
|
11
|
+
*
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
showArrow?: boolean,
|
|
15
|
+
/**
|
|
16
|
+
* The unique id of the HTML element to be created to show the tooltip. If not provided, a random number will be used.
|
|
17
|
+
*/
|
|
18
|
+
tooltipId?: string,
|
|
19
|
+
/**
|
|
20
|
+
* Makes the tooltip text compact, centering it better when it's a single line.
|
|
21
|
+
*
|
|
22
|
+
* Effectively, it makes the line height equals to 1 and applies a slightly larger padding.
|
|
23
|
+
*
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
compact?: boolean,
|
|
27
|
+
/**
|
|
28
|
+
* Whether or not to disable the tooltip, i.e. not show it.
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type TooltipProps = Omit<React.JSX.IntrinsicElements['div'], 'content'> & BaseTooltipProps
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Renders a tooltip overlay for its child. By default, the tooltip is rendered on hover, but this can be changed through the property
|
|
39
|
+
* "triggerOn".
|
|
40
|
+
*
|
|
41
|
+
* The content of the tooltip can be any React element.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```
|
|
45
|
+
* <Tooltip content="This is some help for you">
|
|
46
|
+
* <IconButton icon="Question" />
|
|
47
|
+
* </Tooltip>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const Tooltip = (
|
|
51
|
+
{ tooltipId, children, showArrow = true, compact = true, attributes, colorScheme, colorPalette, disabled, ...props }: TooltipProps,
|
|
52
|
+
) => {
|
|
53
|
+
const id = useRef(tooltipId || `${Math.random()}`)
|
|
54
|
+
return disabled ? children : (
|
|
55
|
+
<Overlay
|
|
56
|
+
attributes={{
|
|
57
|
+
className: listToClass([attributes?.className, showArrow && 'with-arrow', compact && 'compact']),
|
|
58
|
+
style: { margin: '6px', ...attributes?.style },
|
|
59
|
+
role: 'tooltip',
|
|
60
|
+
id: id.current,
|
|
61
|
+
'data-citric': 'tooltip',
|
|
62
|
+
'data-color-scheme': colorScheme,
|
|
63
|
+
'data-color-palette': colorPalette,
|
|
64
|
+
...attributes,
|
|
65
|
+
}}
|
|
66
|
+
onRenderChild={e => e.setAttribute('aria-describedby', id.current)}
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
</Overlay>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
-
import { createElement } from 'react'
|
|
3
|
-
import { HTMLTag, WithStyleShortcuts } from '../types'
|
|
4
|
-
import { applyStyles } from '../utils/css'
|
|
5
|
-
import { withRef } from '../utils/react'
|
|
6
|
-
|
|
7
|
-
export const layout = {
|
|
8
|
-
center: 'center',
|
|
9
|
-
row: 'row',
|
|
10
|
-
column: 'column',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface BaseLayoutProps<T extends keyof HTMLTag> extends WithStyleShortcuts {
|
|
14
|
-
/**
|
|
15
|
-
* HTML tag to render.
|
|
16
|
-
*
|
|
17
|
-
* @default 'div'
|
|
18
|
-
*/
|
|
19
|
-
tag?: T,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface BaseRowProps<T extends keyof HTMLTag> extends BaseLayoutProps<T> {
|
|
23
|
-
/**
|
|
24
|
-
* Whether or not to center items horizontally.
|
|
25
|
-
*
|
|
26
|
-
* @default true
|
|
27
|
-
*/
|
|
28
|
-
center?: boolean,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface BaseColumnProps<T extends keyof HTMLTag> extends BaseLayoutProps<T> {
|
|
32
|
-
/**
|
|
33
|
-
* Whether or not to center items vertically.
|
|
34
|
-
*
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
center?: boolean,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type CenterProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseLayoutProps<T>
|
|
41
|
-
export type RowProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseRowProps<T>
|
|
42
|
-
export type ColumnProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseColumnProps<T>
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Centers the content both vertically and horizontally. Elements are placed in a column (flex).
|
|
46
|
-
*
|
|
47
|
-
* This element accepts many style shortcuts as attributes: bg, fg, border, radius, justifyContent, alignItems, flex, gap, m, mt, mb, ml,
|
|
48
|
-
* mr, p, pt, pb, pl, pr, w, h.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```
|
|
52
|
-
* <Center w="200px" h="200px" gap="10px">
|
|
53
|
-
* <img src="/an-image.png" />
|
|
54
|
-
* <Text>This content is centered!</Text>
|
|
55
|
-
* </Center>
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export const Center = withRef(
|
|
59
|
-
function Center<T extends keyof HTMLTag = 'div'>({ tag, className, ...props }: CenterProps<T>) {
|
|
60
|
-
return createElement(tag || 'div', { className: listToClass(['center', className]), ...applyStyles(props) })
|
|
61
|
-
},
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Creates a row (flex). The elements in this row are horizontally centered unless `center = false`.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```
|
|
69
|
-
* <Row gap={3}>
|
|
70
|
-
* <Icon icon="Stack" />
|
|
71
|
-
* <Text>Stacks</Text>
|
|
72
|
-
* </Row>
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
export const Row = withRef(
|
|
76
|
-
function Row<T extends keyof HTMLTag = 'div'>({ tag, className, center, ...props }: RowProps<T>) {
|
|
77
|
-
return createElement(
|
|
78
|
-
tag || 'div',
|
|
79
|
-
{ className: listToClass(['row', center === false && 'no-center', className]), ...applyStyles(props) },
|
|
80
|
-
)
|
|
81
|
-
},
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Creates a column (flex). The elements in this row are placed at the start of the horizontal axis, unless `center = true`, in this case,
|
|
86
|
-
* they're centered.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```
|
|
90
|
-
* <Column gap={5}>
|
|
91
|
-
* <Text>Item 1</Text>
|
|
92
|
-
* <Text>Item 2</Text>
|
|
93
|
-
* <Text>Item 3</Text>
|
|
94
|
-
* </Row>
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
export const Column = withRef(
|
|
98
|
-
function Column<T extends keyof HTMLTag = 'div'>({ tag, className, center, ...props }: ColumnProps<T>) {
|
|
99
|
-
return createElement(tag || 'div', { className: listToClass(['column', center && 'center', className]), ...applyStyles(props) })
|
|
100
|
-
},
|
|
101
|
-
)
|
|
1
|
+
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
+
import { createElement } from 'react'
|
|
3
|
+
import { HTMLTag, WithStyleShortcuts } from '../types'
|
|
4
|
+
import { applyStyles } from '../utils/css'
|
|
5
|
+
import { withRef } from '../utils/react'
|
|
6
|
+
|
|
7
|
+
export const layout = {
|
|
8
|
+
center: 'center',
|
|
9
|
+
row: 'row',
|
|
10
|
+
column: 'column',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BaseLayoutProps<T extends keyof HTMLTag> extends WithStyleShortcuts {
|
|
14
|
+
/**
|
|
15
|
+
* HTML tag to render.
|
|
16
|
+
*
|
|
17
|
+
* @default 'div'
|
|
18
|
+
*/
|
|
19
|
+
tag?: T,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BaseRowProps<T extends keyof HTMLTag> extends BaseLayoutProps<T> {
|
|
23
|
+
/**
|
|
24
|
+
* Whether or not to center items horizontally.
|
|
25
|
+
*
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
center?: boolean,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface BaseColumnProps<T extends keyof HTMLTag> extends BaseLayoutProps<T> {
|
|
32
|
+
/**
|
|
33
|
+
* Whether or not to center items vertically.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
center?: boolean,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type CenterProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseLayoutProps<T>
|
|
41
|
+
export type RowProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseRowProps<T>
|
|
42
|
+
export type ColumnProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseColumnProps<T>
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Centers the content both vertically and horizontally. Elements are placed in a column (flex).
|
|
46
|
+
*
|
|
47
|
+
* This element accepts many style shortcuts as attributes: bg, fg, border, radius, justifyContent, alignItems, flex, gap, m, mt, mb, ml,
|
|
48
|
+
* mr, p, pt, pb, pl, pr, w, h.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```
|
|
52
|
+
* <Center w="200px" h="200px" gap="10px">
|
|
53
|
+
* <img src="/an-image.png" />
|
|
54
|
+
* <Text>This content is centered!</Text>
|
|
55
|
+
* </Center>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export const Center = withRef(
|
|
59
|
+
function Center<T extends keyof HTMLTag = 'div'>({ tag, className, ...props }: CenterProps<T>) {
|
|
60
|
+
return createElement(tag || 'div', { className: listToClass(['center', className]), ...applyStyles(props) })
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Creates a row (flex). The elements in this row are horizontally centered unless `center = false`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```
|
|
69
|
+
* <Row gap={3}>
|
|
70
|
+
* <Icon icon="Stack" />
|
|
71
|
+
* <Text>Stacks</Text>
|
|
72
|
+
* </Row>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export const Row = withRef(
|
|
76
|
+
function Row<T extends keyof HTMLTag = 'div'>({ tag, className, center, ...props }: RowProps<T>) {
|
|
77
|
+
return createElement(
|
|
78
|
+
tag || 'div',
|
|
79
|
+
{ className: listToClass(['row', center === false && 'no-center', className]), ...applyStyles(props) },
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a column (flex). The elements in this row are placed at the start of the horizontal axis, unless `center = true`, in this case,
|
|
86
|
+
* they're centered.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```
|
|
90
|
+
* <Column gap={5}>
|
|
91
|
+
* <Text>Item 1</Text>
|
|
92
|
+
* <Text>Item 2</Text>
|
|
93
|
+
* <Text>Item 3</Text>
|
|
94
|
+
* </Row>
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export const Column = withRef(
|
|
98
|
+
function Column<T extends keyof HTMLTag = 'div'>({ tag, className, center, ...props }: ColumnProps<T>) {
|
|
99
|
+
return createElement(tag || 'div', { className: listToClass(['column', center && 'center', className]), ...applyStyles(props) })
|
|
100
|
+
},
|
|
101
|
+
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext } from 'react'
|
|
2
|
-
import { CitricController } from '../types'
|
|
3
|
-
|
|
4
|
-
export const CitricContext = createContext<CitricController | undefined>(undefined)
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
import { CitricController } from '../types'
|
|
3
|
+
|
|
4
|
+
export const CitricContext = createContext<CitricController | undefined>(undefined)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FallbackBoundary } from '../components/FallbackBoundary'
|
|
2
|
-
import { CitricController } from '../types'
|
|
3
|
-
import { CitricContext } from './CitricContext'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* An optional provider for customizing the behavior of the Design System. This accepts a CitricController as its value.
|
|
7
|
-
*/
|
|
8
|
-
export const CitricProvider = ({ children, value }: { children: React.ReactNode, value?: CitricController }) => (
|
|
9
|
-
<CitricContext.Provider value={value}>
|
|
10
|
-
<FallbackBoundary>
|
|
11
|
-
{children}
|
|
12
|
-
</FallbackBoundary>
|
|
13
|
-
</CitricContext.Provider>
|
|
14
|
-
)
|
|
1
|
+
import { FallbackBoundary } from '../components/FallbackBoundary'
|
|
2
|
+
import { CitricController } from '../types'
|
|
3
|
+
import { CitricContext } from './CitricContext'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An optional provider for customizing the behavior of the Design System. This accepts a CitricController as its value.
|
|
7
|
+
*/
|
|
8
|
+
export const CitricProvider = ({ children, value }: { children: React.ReactNode, value?: CitricController }) => (
|
|
9
|
+
<CitricContext.Provider value={value}>
|
|
10
|
+
<FallbackBoundary>
|
|
11
|
+
{children}
|
|
12
|
+
</FallbackBoundary>
|
|
13
|
+
</CitricContext.Provider>
|
|
14
|
+
)
|
package/src/context/hooks.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useContext } from 'react'
|
|
2
|
-
import { CitricContext } from './CitricContext'
|
|
3
|
-
|
|
4
|
-
export function useCitricController() {
|
|
5
|
-
return useContext(CitricContext)
|
|
6
|
-
}
|
|
1
|
+
import { useContext } from 'react'
|
|
2
|
+
import { CitricContext } from './CitricContext'
|
|
3
|
+
|
|
4
|
+
export function useCitricController() {
|
|
5
|
+
return useContext(CitricContext)
|
|
6
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
export * from './components/Accordion'
|
|
2
|
-
export * from './components/Alert'
|
|
3
|
-
export * from './components/AsyncContent'
|
|
4
|
-
export * from './components/Avatar'
|
|
5
|
-
export * from './components/AvatarGroup'
|
|
6
|
-
export * from './components/Badge'
|
|
7
|
-
export * from './components/Blockquote'
|
|
8
|
-
export * from './components/Breadcrumb'
|
|
9
|
-
export * from './components/Button'
|
|
10
|
-
export * from './components/ButtonLink'
|
|
11
|
-
export * from './components/Card'
|
|
12
|
-
export * from './components/Checkbox'
|
|
13
|
-
export * from './components/CheckboxGroup'
|
|
14
|
-
export * from './components/Circle'
|
|
15
|
-
export * from './components/CitricComponent'
|
|
16
|
-
export * from './components/Divider'
|
|
17
|
-
export * from './components/ErrorBoundary'
|
|
18
|
-
export * from './components/FallbackBoundary'
|
|
19
|
-
export * from './components/Favorite'
|
|
20
|
-
export * from './components/FieldGroup'
|
|
21
|
-
export * from './components/Form'
|
|
22
|
-
export * from './components/FormGroup'
|
|
23
|
-
export * from './components/Icon'
|
|
24
|
-
export * from './components/IconBox'
|
|
25
|
-
export * from './components/ImageBox'
|
|
26
|
-
export * from './components/ImageWithFallback'
|
|
27
|
-
export * from './components/Input'
|
|
28
|
-
export * from './components/layout'
|
|
29
|
-
export * from './components/Link'
|
|
30
|
-
export * from './components/MenuOverlay'
|
|
31
|
-
export * from './components/MenuOverlay/types'
|
|
32
|
-
export * from './components/Overlay'
|
|
33
|
-
export * from './components/Overlay/types'
|
|
34
|
-
export * from './components/Pagination'
|
|
35
|
-
export * from './components/ProgressBar'
|
|
36
|
-
export * from './components/ProgressCircular'
|
|
37
|
-
export * from './components/RadioGroup'
|
|
38
|
-
export * from './components/Rating'
|
|
39
|
-
export * from './components/Select'
|
|
40
|
-
export * from './components/Select/MultiSelect'
|
|
41
|
-
export * from './components/SelectBox'
|
|
42
|
-
export * from './components/Skeleton'
|
|
43
|
-
export * from './components/Slider'
|
|
44
|
-
export * from './components/SmartTable'
|
|
45
|
-
export * from './components/Stepper'
|
|
46
|
-
export * from './components/Table'
|
|
47
|
-
export * from './components/Tabs'
|
|
48
|
-
export * from './components/Tabs/TabController'
|
|
49
|
-
export * from './components/Tabs/types'
|
|
50
|
-
export * from './components/Text'
|
|
51
|
-
export * from './components/Textarea'
|
|
52
|
-
export * from './components/Tooltip'
|
|
53
|
-
export * from './context/CitricProvider'
|
|
54
|
-
export type { CitricController } from './types'
|
|
55
|
-
export * from './utils/checkbox'
|
|
56
|
-
export * from './utils/radio'
|
|
57
|
-
export * from './utils/ValueController'
|
|
58
|
-
|
|
1
|
+
export * from './components/Accordion'
|
|
2
|
+
export * from './components/Alert'
|
|
3
|
+
export * from './components/AsyncContent'
|
|
4
|
+
export * from './components/Avatar'
|
|
5
|
+
export * from './components/AvatarGroup'
|
|
6
|
+
export * from './components/Badge'
|
|
7
|
+
export * from './components/Blockquote'
|
|
8
|
+
export * from './components/Breadcrumb'
|
|
9
|
+
export * from './components/Button'
|
|
10
|
+
export * from './components/ButtonLink'
|
|
11
|
+
export * from './components/Card'
|
|
12
|
+
export * from './components/Checkbox'
|
|
13
|
+
export * from './components/CheckboxGroup'
|
|
14
|
+
export * from './components/Circle'
|
|
15
|
+
export * from './components/CitricComponent'
|
|
16
|
+
export * from './components/Divider'
|
|
17
|
+
export * from './components/ErrorBoundary'
|
|
18
|
+
export * from './components/FallbackBoundary'
|
|
19
|
+
export * from './components/Favorite'
|
|
20
|
+
export * from './components/FieldGroup'
|
|
21
|
+
export * from './components/Form'
|
|
22
|
+
export * from './components/FormGroup'
|
|
23
|
+
export * from './components/Icon'
|
|
24
|
+
export * from './components/IconBox'
|
|
25
|
+
export * from './components/ImageBox'
|
|
26
|
+
export * from './components/ImageWithFallback'
|
|
27
|
+
export * from './components/Input'
|
|
28
|
+
export * from './components/layout'
|
|
29
|
+
export * from './components/Link'
|
|
30
|
+
export * from './components/MenuOverlay'
|
|
31
|
+
export * from './components/MenuOverlay/types'
|
|
32
|
+
export * from './components/Overlay'
|
|
33
|
+
export * from './components/Overlay/types'
|
|
34
|
+
export * from './components/Pagination'
|
|
35
|
+
export * from './components/ProgressBar'
|
|
36
|
+
export * from './components/ProgressCircular'
|
|
37
|
+
export * from './components/RadioGroup'
|
|
38
|
+
export * from './components/Rating'
|
|
39
|
+
export * from './components/Select'
|
|
40
|
+
export * from './components/Select/MultiSelect'
|
|
41
|
+
export * from './components/SelectBox'
|
|
42
|
+
export * from './components/Skeleton'
|
|
43
|
+
export * from './components/Slider'
|
|
44
|
+
export * from './components/SmartTable'
|
|
45
|
+
export * from './components/Stepper'
|
|
46
|
+
export * from './components/Table'
|
|
47
|
+
export * from './components/Tabs'
|
|
48
|
+
export * from './components/Tabs/TabController'
|
|
49
|
+
export * from './components/Tabs/types'
|
|
50
|
+
export * from './components/Text'
|
|
51
|
+
export * from './components/Textarea'
|
|
52
|
+
export * from './components/Tooltip'
|
|
53
|
+
export * from './context/CitricProvider'
|
|
54
|
+
export type { CitricController } from './types'
|
|
55
|
+
export * from './utils/checkbox'
|
|
56
|
+
export * from './utils/radio'
|
|
57
|
+
export * from './utils/ValueController'
|
|
58
|
+
|