@stack-spot/citric-react 0.37.1 → 0.39.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/CHANGELOG.md +13 -0
- 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.js +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 +2 -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 +146 -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,133 +1,133 @@
|
|
|
1
|
-
import { Dictionary, interpolate, useTranslate } from '@stack-spot/portal-translate'
|
|
2
|
-
import { useMemo } from 'react'
|
|
3
|
-
import { withRef } from '../utils/react'
|
|
4
|
-
import { CitricComponent } from './CitricComponent'
|
|
5
|
-
import { IconButton } from './IconBox'
|
|
6
|
-
|
|
7
|
-
const DEFAULT_PAGE = 1
|
|
8
|
-
const DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 30]
|
|
9
|
-
|
|
10
|
-
export interface PaginationValue {
|
|
11
|
-
/**
|
|
12
|
-
* The first page is 1. If "0" is provided, it will be treated as if it was "1".
|
|
13
|
-
*/
|
|
14
|
-
page: number,
|
|
15
|
-
/**
|
|
16
|
-
* The current number of items in a page.
|
|
17
|
-
*/
|
|
18
|
-
size: number,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface BasePaginationProps {
|
|
22
|
-
/**
|
|
23
|
-
* The options for the page size.
|
|
24
|
-
*
|
|
25
|
-
* @default [10, 20, 30]
|
|
26
|
-
*/
|
|
27
|
-
pageSizeOptions?: number[],
|
|
28
|
-
/**
|
|
29
|
-
* Total number of pages
|
|
30
|
-
*/
|
|
31
|
-
totalPages: number,
|
|
32
|
-
/**
|
|
33
|
-
* The current page and page size.
|
|
34
|
-
*/
|
|
35
|
-
value: PaginationValue,
|
|
36
|
-
/**
|
|
37
|
-
* Function to run whenever the page size or current page changes.
|
|
38
|
-
*/
|
|
39
|
-
onChange: (value: PaginationValue) => void,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type PaginationProps = Omit<React.JSX.IntrinsicElements['div'], 'onChange'> & BasePaginationProps
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Renders a pagination UI, letting the user chose one among multiple pages. This is generally rendered at the bottom of a table.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```
|
|
49
|
-
* const [pageData, setPageData] = useState({ page: 1, size: 10 })
|
|
50
|
-
* return <Pagination
|
|
51
|
-
* value={pageData}
|
|
52
|
-
* totalPages={50}
|
|
53
|
-
* onChange={setPageData}
|
|
54
|
-
* />
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export const Pagination = withRef((
|
|
58
|
-
{
|
|
59
|
-
value,
|
|
60
|
-
onChange,
|
|
61
|
-
totalPages,
|
|
62
|
-
pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
|
|
63
|
-
...props
|
|
64
|
-
}: PaginationProps,
|
|
65
|
-
) => {
|
|
66
|
-
const t = useTranslate(dictionary)
|
|
67
|
-
const sizeOptions = useMemo(
|
|
68
|
-
() => pageSizeOptions.map(o => <option key={o} selected={value.size === o}>{o}</option>),
|
|
69
|
-
[pageSizeOptions],
|
|
70
|
-
)
|
|
71
|
-
const pageOptions = useMemo(() => {
|
|
72
|
-
const options: React.ReactElement[] = []
|
|
73
|
-
for (let i = 1; i <= totalPages; i++) {
|
|
74
|
-
options.push(<option key={i} value={i} selected={value.page === i}>{i}</option>)
|
|
75
|
-
}
|
|
76
|
-
return options
|
|
77
|
-
}, [value.page, totalPages])
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<CitricComponent tag="div" component="pagination" {...props}>
|
|
81
|
-
<div className="page-size">
|
|
82
|
-
<label>
|
|
83
|
-
{t.itemsPerPage}:
|
|
84
|
-
<select
|
|
85
|
-
name="itemsPerPage"
|
|
86
|
-
onChange={e => onChange({ page: DEFAULT_PAGE, size: parseInt(e.target.value) })}
|
|
87
|
-
>
|
|
88
|
-
{sizeOptions}
|
|
89
|
-
</select>
|
|
90
|
-
</label>
|
|
91
|
-
</div>
|
|
92
|
-
<div className="page-number">
|
|
93
|
-
<label>
|
|
94
|
-
<select
|
|
95
|
-
name="page"
|
|
96
|
-
onChange={e => onChange({ page: parseInt(e.target.value), size: value.size })}
|
|
97
|
-
value={value.page || DEFAULT_PAGE}
|
|
98
|
-
>
|
|
99
|
-
{pageOptions}
|
|
100
|
-
</select>
|
|
101
|
-
</label>
|
|
102
|
-
{totalPages > 1 ? interpolate(t.ofTotalPlural, totalPages) : t.ofTotalSingular}
|
|
103
|
-
<IconButton
|
|
104
|
-
icon="ChevronLeft"
|
|
105
|
-
aria-label="previous"
|
|
106
|
-
title="previous"
|
|
107
|
-
disabled={value.page === DEFAULT_PAGE}
|
|
108
|
-
onClick={() => onChange({ page: Math.max(value.page - 1, DEFAULT_PAGE), size: value.size })}
|
|
109
|
-
/>
|
|
110
|
-
<IconButton
|
|
111
|
-
icon="ChevronRight"
|
|
112
|
-
aria-label="next"
|
|
113
|
-
title="next"
|
|
114
|
-
disabled={value.page === totalPages}
|
|
115
|
-
onClick={() => onChange({ page: Math.min(totalPages, value.page + 1), size: value.size })}
|
|
116
|
-
/>
|
|
117
|
-
</div>
|
|
118
|
-
</CitricComponent>
|
|
119
|
-
)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
const dictionary = {
|
|
123
|
-
en: {
|
|
124
|
-
itemsPerPage: 'Items per page',
|
|
125
|
-
ofTotalSingular: 'of 1 page',
|
|
126
|
-
ofTotalPlural: 'of $0 pages',
|
|
127
|
-
},
|
|
128
|
-
pt: {
|
|
129
|
-
itemsPerPage: 'Itens por página',
|
|
130
|
-
ofTotalSingular: 'de 1 página',
|
|
131
|
-
ofTotalPlural: 'de $0 páginas',
|
|
132
|
-
},
|
|
133
|
-
} satisfies Dictionary
|
|
1
|
+
import { Dictionary, interpolate, useTranslate } from '@stack-spot/portal-translate'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
import { withRef } from '../utils/react'
|
|
4
|
+
import { CitricComponent } from './CitricComponent'
|
|
5
|
+
import { IconButton } from './IconBox'
|
|
6
|
+
|
|
7
|
+
const DEFAULT_PAGE = 1
|
|
8
|
+
const DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 30]
|
|
9
|
+
|
|
10
|
+
export interface PaginationValue {
|
|
11
|
+
/**
|
|
12
|
+
* The first page is 1. If "0" is provided, it will be treated as if it was "1".
|
|
13
|
+
*/
|
|
14
|
+
page: number,
|
|
15
|
+
/**
|
|
16
|
+
* The current number of items in a page.
|
|
17
|
+
*/
|
|
18
|
+
size: number,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BasePaginationProps {
|
|
22
|
+
/**
|
|
23
|
+
* The options for the page size.
|
|
24
|
+
*
|
|
25
|
+
* @default [10, 20, 30]
|
|
26
|
+
*/
|
|
27
|
+
pageSizeOptions?: number[],
|
|
28
|
+
/**
|
|
29
|
+
* Total number of pages
|
|
30
|
+
*/
|
|
31
|
+
totalPages: number,
|
|
32
|
+
/**
|
|
33
|
+
* The current page and page size.
|
|
34
|
+
*/
|
|
35
|
+
value: PaginationValue,
|
|
36
|
+
/**
|
|
37
|
+
* Function to run whenever the page size or current page changes.
|
|
38
|
+
*/
|
|
39
|
+
onChange: (value: PaginationValue) => void,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type PaginationProps = Omit<React.JSX.IntrinsicElements['div'], 'onChange'> & BasePaginationProps
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Renders a pagination UI, letting the user chose one among multiple pages. This is generally rendered at the bottom of a table.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```
|
|
49
|
+
* const [pageData, setPageData] = useState({ page: 1, size: 10 })
|
|
50
|
+
* return <Pagination
|
|
51
|
+
* value={pageData}
|
|
52
|
+
* totalPages={50}
|
|
53
|
+
* onChange={setPageData}
|
|
54
|
+
* />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const Pagination = withRef((
|
|
58
|
+
{
|
|
59
|
+
value,
|
|
60
|
+
onChange,
|
|
61
|
+
totalPages,
|
|
62
|
+
pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
|
|
63
|
+
...props
|
|
64
|
+
}: PaginationProps,
|
|
65
|
+
) => {
|
|
66
|
+
const t = useTranslate(dictionary)
|
|
67
|
+
const sizeOptions = useMemo(
|
|
68
|
+
() => pageSizeOptions.map(o => <option key={o} selected={value.size === o}>{o}</option>),
|
|
69
|
+
[pageSizeOptions],
|
|
70
|
+
)
|
|
71
|
+
const pageOptions = useMemo(() => {
|
|
72
|
+
const options: React.ReactElement[] = []
|
|
73
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
74
|
+
options.push(<option key={i} value={i} selected={value.page === i}>{i}</option>)
|
|
75
|
+
}
|
|
76
|
+
return options
|
|
77
|
+
}, [value.page, totalPages])
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<CitricComponent tag="div" component="pagination" {...props}>
|
|
81
|
+
<div className="page-size">
|
|
82
|
+
<label>
|
|
83
|
+
{t.itemsPerPage}:
|
|
84
|
+
<select
|
|
85
|
+
name="itemsPerPage"
|
|
86
|
+
onChange={e => onChange({ page: DEFAULT_PAGE, size: parseInt(e.target.value) })}
|
|
87
|
+
>
|
|
88
|
+
{sizeOptions}
|
|
89
|
+
</select>
|
|
90
|
+
</label>
|
|
91
|
+
</div>
|
|
92
|
+
<div className="page-number">
|
|
93
|
+
<label>
|
|
94
|
+
<select
|
|
95
|
+
name="page"
|
|
96
|
+
onChange={e => onChange({ page: parseInt(e.target.value), size: value.size })}
|
|
97
|
+
value={value.page || DEFAULT_PAGE}
|
|
98
|
+
>
|
|
99
|
+
{pageOptions}
|
|
100
|
+
</select>
|
|
101
|
+
</label>
|
|
102
|
+
{totalPages > 1 ? interpolate(t.ofTotalPlural, totalPages) : t.ofTotalSingular}
|
|
103
|
+
<IconButton
|
|
104
|
+
icon="ChevronLeft"
|
|
105
|
+
aria-label="previous"
|
|
106
|
+
title="previous"
|
|
107
|
+
disabled={value.page === DEFAULT_PAGE}
|
|
108
|
+
onClick={() => onChange({ page: Math.max(value.page - 1, DEFAULT_PAGE), size: value.size })}
|
|
109
|
+
/>
|
|
110
|
+
<IconButton
|
|
111
|
+
icon="ChevronRight"
|
|
112
|
+
aria-label="next"
|
|
113
|
+
title="next"
|
|
114
|
+
disabled={value.page === totalPages}
|
|
115
|
+
onClick={() => onChange({ page: Math.min(totalPages, value.page + 1), size: value.size })}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</CitricComponent>
|
|
119
|
+
)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
const dictionary = {
|
|
123
|
+
en: {
|
|
124
|
+
itemsPerPage: 'Items per page',
|
|
125
|
+
ofTotalSingular: 'of 1 page',
|
|
126
|
+
ofTotalPlural: 'of $0 pages',
|
|
127
|
+
},
|
|
128
|
+
pt: {
|
|
129
|
+
itemsPerPage: 'Itens por página',
|
|
130
|
+
ofTotalSingular: 'de 1 página',
|
|
131
|
+
ofTotalPlural: 'de $0 páginas',
|
|
132
|
+
},
|
|
133
|
+
} satisfies Dictionary
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
-
import { isNil } from 'lodash'
|
|
3
|
-
import { WithColorPalette, WithColorScheme } from '../types'
|
|
4
|
-
import { applyCSSVariable } from '../utils/css'
|
|
5
|
-
import { withRef } from '../utils/react'
|
|
6
|
-
import { CitricComponent } from './CitricComponent'
|
|
7
|
-
|
|
8
|
-
export interface BaseProgressBarProps extends WithColorScheme, WithColorPalette {
|
|
9
|
-
/**
|
|
10
|
-
* A number varying from 0 to 100.
|
|
11
|
-
*
|
|
12
|
-
* If not provided, the progress will be indeterminate, causing an animation loop.
|
|
13
|
-
*/
|
|
14
|
-
progress?: number,
|
|
15
|
-
/**
|
|
16
|
-
* The speed which the bar animation runs. Only valid if `progress` is `undefined`.
|
|
17
|
-
*/
|
|
18
|
-
speed?: 'normal' | 'fast',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type ProgressBarProps = React.JSX.IntrinsicElements['div'] & BaseProgressBarProps
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Shows a progress bar. This can indicate a loading state or the progress of a task. When "progress" is not set, the bar is animated,
|
|
25
|
-
* indicating a busy state.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* A simple loading with a Progress Bar.
|
|
29
|
-
* ```
|
|
30
|
-
* <ProgressBar />
|
|
31
|
-
* ```
|
|
32
|
-
* A Progress Bar that is 50% complete.
|
|
33
|
-
* ```
|
|
34
|
-
* <ProgressBar progress={50} />
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export const ProgressBar = withRef(({ progress, speed, style, className, ...props }: ProgressBarProps) =>
|
|
38
|
-
<CitricComponent
|
|
39
|
-
tag="div"
|
|
40
|
-
component="progress-bar"
|
|
41
|
-
className={listToClass([className, isNil(progress) && 'indeterminate', speed === 'fast' && 'fast'])}
|
|
42
|
-
style={progress === undefined ? style : applyCSSVariable(style, 'progress', progress)}
|
|
43
|
-
{...props}
|
|
44
|
-
/>,
|
|
45
|
-
)
|
|
1
|
+
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
+
import { isNil } from 'lodash'
|
|
3
|
+
import { WithColorPalette, WithColorScheme } from '../types'
|
|
4
|
+
import { applyCSSVariable } from '../utils/css'
|
|
5
|
+
import { withRef } from '../utils/react'
|
|
6
|
+
import { CitricComponent } from './CitricComponent'
|
|
7
|
+
|
|
8
|
+
export interface BaseProgressBarProps extends WithColorScheme, WithColorPalette {
|
|
9
|
+
/**
|
|
10
|
+
* A number varying from 0 to 100.
|
|
11
|
+
*
|
|
12
|
+
* If not provided, the progress will be indeterminate, causing an animation loop.
|
|
13
|
+
*/
|
|
14
|
+
progress?: number,
|
|
15
|
+
/**
|
|
16
|
+
* The speed which the bar animation runs. Only valid if `progress` is `undefined`.
|
|
17
|
+
*/
|
|
18
|
+
speed?: 'normal' | 'fast',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ProgressBarProps = React.JSX.IntrinsicElements['div'] & BaseProgressBarProps
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Shows a progress bar. This can indicate a loading state or the progress of a task. When "progress" is not set, the bar is animated,
|
|
25
|
+
* indicating a busy state.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* A simple loading with a Progress Bar.
|
|
29
|
+
* ```
|
|
30
|
+
* <ProgressBar />
|
|
31
|
+
* ```
|
|
32
|
+
* A Progress Bar that is 50% complete.
|
|
33
|
+
* ```
|
|
34
|
+
* <ProgressBar progress={50} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const ProgressBar = withRef(({ progress, speed, style, className, ...props }: ProgressBarProps) =>
|
|
38
|
+
<CitricComponent
|
|
39
|
+
tag="div"
|
|
40
|
+
component="progress-bar"
|
|
41
|
+
className={listToClass([className, isNil(progress) && 'indeterminate', speed === 'fast' && 'fast'])}
|
|
42
|
+
style={progress === undefined ? style : applyCSSVariable(style, 'progress', progress)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>,
|
|
45
|
+
)
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
-
import { isNil } from 'lodash'
|
|
3
|
-
import { WithColorPalette, WithColorScheme } from '../types'
|
|
4
|
-
import { applyCSSVariable } from '../utils/css'
|
|
5
|
-
import { withRef } from '../utils/react'
|
|
6
|
-
import { CitricComponent } from './CitricComponent'
|
|
7
|
-
|
|
8
|
-
export interface BaseProgressCircularProps extends WithColorScheme, WithColorPalette {
|
|
9
|
-
/**
|
|
10
|
-
* A number varying from 0 to 100.
|
|
11
|
-
*
|
|
12
|
-
* If not provided, the progress will be indeterminate, causing an animation loop.
|
|
13
|
-
*/
|
|
14
|
-
progress?: number,
|
|
15
|
-
/**
|
|
16
|
-
* @default 'md'
|
|
17
|
-
*/
|
|
18
|
-
size?: 'xs' | 'sm' | 'md' | 'lg',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type ProgressCircularProps = React.JSX.IntrinsicElements['div'] & BaseProgressCircularProps
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Shows a circular progress. This can indicate a loading state (spinner) or the progress of a task. When "progress" is not set, the
|
|
25
|
-
* spinner is animated, indicating a busy state.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* A simple loading with a Progress Circular.
|
|
29
|
-
* ```
|
|
30
|
-
* <ProgressCircular />
|
|
31
|
-
* ```
|
|
32
|
-
* A Progress Circular that is 50% complete.
|
|
33
|
-
* ```
|
|
34
|
-
* <ProgressCircular progress={50} />
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export const ProgressCircular = withRef(({ progress, size, style, className, ...props }: ProgressCircularProps) =>
|
|
38
|
-
<CitricComponent
|
|
39
|
-
tag="div"
|
|
40
|
-
component="progress-circular"
|
|
41
|
-
className={listToClass([size, className, isNil(progress) && 'indeterminate'])}
|
|
42
|
-
style={progress === undefined ? style : applyCSSVariable(style, 'progress', progress)}
|
|
43
|
-
{...props}
|
|
44
|
-
/>,
|
|
45
|
-
)
|
|
1
|
+
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
+
import { isNil } from 'lodash'
|
|
3
|
+
import { WithColorPalette, WithColorScheme } from '../types'
|
|
4
|
+
import { applyCSSVariable } from '../utils/css'
|
|
5
|
+
import { withRef } from '../utils/react'
|
|
6
|
+
import { CitricComponent } from './CitricComponent'
|
|
7
|
+
|
|
8
|
+
export interface BaseProgressCircularProps extends WithColorScheme, WithColorPalette {
|
|
9
|
+
/**
|
|
10
|
+
* A number varying from 0 to 100.
|
|
11
|
+
*
|
|
12
|
+
* If not provided, the progress will be indeterminate, causing an animation loop.
|
|
13
|
+
*/
|
|
14
|
+
progress?: number,
|
|
15
|
+
/**
|
|
16
|
+
* @default 'md'
|
|
17
|
+
*/
|
|
18
|
+
size?: 'xs' | 'sm' | 'md' | 'lg',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ProgressCircularProps = React.JSX.IntrinsicElements['div'] & BaseProgressCircularProps
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Shows a circular progress. This can indicate a loading state (spinner) or the progress of a task. When "progress" is not set, the
|
|
25
|
+
* spinner is animated, indicating a busy state.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* A simple loading with a Progress Circular.
|
|
29
|
+
* ```
|
|
30
|
+
* <ProgressCircular />
|
|
31
|
+
* ```
|
|
32
|
+
* A Progress Circular that is 50% complete.
|
|
33
|
+
* ```
|
|
34
|
+
* <ProgressCircular progress={50} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const ProgressCircular = withRef(({ progress, size, style, className, ...props }: ProgressCircularProps) =>
|
|
38
|
+
<CitricComponent
|
|
39
|
+
tag="div"
|
|
40
|
+
component="progress-circular"
|
|
41
|
+
className={listToClass([size, className, isNil(progress) && 'indeterminate'])}
|
|
42
|
+
style={progress === undefined ? style : applyCSSVariable(style, 'progress', progress)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>,
|
|
45
|
+
)
|