@cerberus-design/react 0.16.0-next-22894bb → 0.16.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/build/legacy/_tsup-dts-rollup.d.cts +27 -248
- package/build/legacy/components/checkbox/checkbox.cjs.map +1 -1
- package/build/legacy/components/checkbox/index.cjs.map +1 -1
- package/build/legacy/components/for.cjs +4 -3
- package/build/legacy/components/for.cjs.map +1 -1
- package/build/legacy/{components/cta-dialog/provider.cjs → context/cta-modal.cjs} +150 -187
- package/build/legacy/context/cta-modal.cjs.map +1 -0
- package/build/legacy/index.cjs +720 -884
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +27 -248
- package/build/modern/{chunk-O542MPR7.js → chunk-CMYD5KWA.js} +4 -4
- package/build/modern/{chunk-H5WNUPGH.js → chunk-FMRWRVUS.js} +7 -7
- package/build/modern/chunk-IIH363FO.js +13 -0
- package/build/modern/chunk-IIH363FO.js.map +1 -0
- package/build/modern/{chunk-6ICNCCPD.js → chunk-P3SF56LT.js} +4 -4
- package/build/modern/{chunk-UNRQAXLJ.js → chunk-Y4ZEJ2EF.js} +1 -1
- package/build/modern/chunk-Y4ZEJ2EF.js.map +1 -0
- package/build/modern/{chunk-QEM3M4N3.js → chunk-ZDANBCM3.js} +31 -22
- package/build/modern/chunk-ZDANBCM3.js.map +1 -0
- package/build/modern/components/checkbox/checkbox.js +1 -1
- package/build/modern/components/checkbox/index.js +1 -1
- package/build/modern/components/for.js +1 -1
- package/build/modern/components/select/index.js +2 -2
- package/build/modern/components/select/select.js +2 -2
- package/build/modern/context/cta-modal.js +19 -0
- package/build/modern/context/notification-center.js +3 -3
- package/build/modern/context/prompt-modal.js +2 -2
- package/build/modern/index.js +92 -124
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/checkbox/checkbox.tsx +2 -2
- package/src/components/for.tsx +18 -13
- package/src/{components/cta-dialog/provider.tsx → context/cta-modal.tsx} +68 -34
- package/src/index.ts +1 -2
- package/build/legacy/components/cta-dialog/context.cjs +0 -33
- package/build/legacy/components/cta-dialog/context.cjs.map +0 -1
- package/build/legacy/components/cta-dialog/index.cjs +0 -433
- package/build/legacy/components/cta-dialog/index.cjs.map +0 -1
- package/build/legacy/components/cta-dialog/provider.cjs.map +0 -1
- package/build/legacy/components/cta-dialog/trigger-item.cjs +0 -99
- package/build/legacy/components/cta-dialog/trigger-item.cjs.map +0 -1
- package/build/legacy/components/cta-dialog/utils.cjs +0 -47
- package/build/legacy/components/cta-dialog/utils.cjs.map +0 -1
- package/build/legacy/components/rating/index.cjs +0 -167
- package/build/legacy/components/rating/index.cjs.map +0 -1
- package/build/legacy/components/rating/parts.cjs +0 -98
- package/build/legacy/components/rating/parts.cjs.map +0 -1
- package/build/legacy/components/rating/primitives.cjs +0 -97
- package/build/legacy/components/rating/primitives.cjs.map +0 -1
- package/build/legacy/components/rating/rating.cjs +0 -151
- package/build/legacy/components/rating/rating.cjs.map +0 -1
- package/build/modern/chunk-4LSTU6WU.js +0 -8
- package/build/modern/chunk-4LSTU6WU.js.map +0 -1
- package/build/modern/chunk-DXOKSZVQ.js +0 -12
- package/build/modern/chunk-DXOKSZVQ.js.map +0 -1
- package/build/modern/chunk-IKDXADLX.js +0 -1
- package/build/modern/chunk-MVO2GNUA.js +0 -47
- package/build/modern/chunk-MVO2GNUA.js.map +0 -1
- package/build/modern/chunk-OS73F4SR.js +0 -25
- package/build/modern/chunk-OS73F4SR.js.map +0 -1
- package/build/modern/chunk-PLHYOCY3.js +0 -23
- package/build/modern/chunk-PLHYOCY3.js.map +0 -1
- package/build/modern/chunk-QEM3M4N3.js.map +0 -1
- package/build/modern/chunk-QQCB6JXW.js +0 -36
- package/build/modern/chunk-QQCB6JXW.js.map +0 -1
- package/build/modern/chunk-UNRQAXLJ.js.map +0 -1
- package/build/modern/chunk-W47QEZD5.js +0 -71
- package/build/modern/chunk-W47QEZD5.js.map +0 -1
- package/build/modern/chunk-ZOSGUATV.js +0 -1
- package/build/modern/chunk-ZOSGUATV.js.map +0 -1
- package/build/modern/components/cta-dialog/context.js +0 -8
- package/build/modern/components/cta-dialog/context.js.map +0 -1
- package/build/modern/components/cta-dialog/index.js +0 -26
- package/build/modern/components/cta-dialog/index.js.map +0 -1
- package/build/modern/components/cta-dialog/provider.js +0 -22
- package/build/modern/components/cta-dialog/provider.js.map +0 -1
- package/build/modern/components/cta-dialog/trigger-item.js +0 -10
- package/build/modern/components/cta-dialog/trigger-item.js.map +0 -1
- package/build/modern/components/cta-dialog/utils.js +0 -7
- package/build/modern/components/cta-dialog/utils.js.map +0 -1
- package/build/modern/components/rating/index.js +0 -31
- package/build/modern/components/rating/index.js.map +0 -1
- package/build/modern/components/rating/parts.js +0 -8
- package/build/modern/components/rating/parts.js.map +0 -1
- package/build/modern/components/rating/primitives.js +0 -19
- package/build/modern/components/rating/primitives.js.map +0 -1
- package/build/modern/components/rating/rating.js +0 -12
- package/build/modern/components/rating/rating.js.map +0 -1
- package/src/components/cta-dialog/context.tsx +0 -34
- package/src/components/cta-dialog/index.ts +0 -2
- package/src/components/cta-dialog/trigger-item.tsx +0 -53
- package/src/components/cta-dialog/utils.ts +0 -57
- package/src/components/rating/index.ts +0 -8
- package/src/components/rating/parts.tsx +0 -65
- package/src/components/rating/primitives.tsx +0 -99
- package/src/components/rating/rating.tsx +0 -78
- /package/build/modern/{chunk-O542MPR7.js.map → chunk-CMYD5KWA.js.map} +0 -0
- /package/build/modern/{chunk-H5WNUPGH.js.map → chunk-FMRWRVUS.js.map} +0 -0
- /package/build/modern/{chunk-6ICNCCPD.js.map → chunk-P3SF56LT.js.map} +0 -0
- /package/build/modern/{chunk-IKDXADLX.js.map → context/cta-modal.js.map} +0 -0
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RatingContext,
|
|
3
|
-
RatingControl,
|
|
4
|
-
RatingHiddenInput,
|
|
5
|
-
RatingItem,
|
|
6
|
-
RatingItemContext,
|
|
7
|
-
RatingLabel,
|
|
8
|
-
RatingRoot
|
|
9
|
-
} from "../../chunk-W47QEZD5.js";
|
|
10
|
-
export {
|
|
11
|
-
RatingContext,
|
|
12
|
-
RatingControl,
|
|
13
|
-
RatingHiddenInput,
|
|
14
|
-
RatingItem,
|
|
15
|
-
RatingItemContext,
|
|
16
|
-
RatingLabel,
|
|
17
|
-
RatingRoot
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=primitives.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Rating
|
|
3
|
-
} from "../../chunk-QQCB6JXW.js";
|
|
4
|
-
import "../../chunk-OS73F4SR.js";
|
|
5
|
-
import "../../chunk-W47QEZD5.js";
|
|
6
|
-
import "../../chunk-BL7G3577.js";
|
|
7
|
-
import "../../chunk-FQLMPEYX.js";
|
|
8
|
-
import "../../chunk-BUVVRQLZ.js";
|
|
9
|
-
export {
|
|
10
|
-
Rating
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=rating.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { createContext, type ReactNode } from 'react'
|
|
4
|
-
import type { CTAModalActionReturn } from './utils'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This module provides the context for the cta modal.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export interface ShowCTAModalOptions {
|
|
12
|
-
/**
|
|
13
|
-
* The heading of the cta modal.
|
|
14
|
-
*/
|
|
15
|
-
heading: string
|
|
16
|
-
/**
|
|
17
|
-
* The description of the cta modal.
|
|
18
|
-
*/
|
|
19
|
-
description?: string
|
|
20
|
-
/**
|
|
21
|
-
* The icon used for the modal Avatar.
|
|
22
|
-
*/
|
|
23
|
-
icon?: ReactNode
|
|
24
|
-
/**
|
|
25
|
-
* The actions for the cta modal. Requires 2 actions.
|
|
26
|
-
*/
|
|
27
|
-
actions: CTAModalActionReturn
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface CTAModalValue {
|
|
31
|
-
show: (options: ShowCTAModalOptions) => void
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const CTAModalContext = createContext<CTAModalValue | null>(null)
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { css, cx } from '@cerberus/styled-system/css'
|
|
2
|
-
import { Button, type ButtonProps } from '../button/button'
|
|
3
|
-
import { ark } from '@ark-ui/react/factory'
|
|
4
|
-
import { button } from '@cerberus/styled-system/recipes'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This module provides the trigger item for the cta modal.
|
|
8
|
-
* @module 'react/cta-modal/trigger-item'
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export interface TriggerItemProps extends ButtonProps {
|
|
12
|
-
asChild?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Trigger item for the cta modal which renders content based on the actions.
|
|
17
|
-
* type.
|
|
18
|
-
*/
|
|
19
|
-
export function TriggerItem(props: TriggerItemProps) {
|
|
20
|
-
const { asChild, children, ...buttonProps } = props
|
|
21
|
-
|
|
22
|
-
if (asChild) {
|
|
23
|
-
return (
|
|
24
|
-
<ark.div
|
|
25
|
-
className={cx(
|
|
26
|
-
button({
|
|
27
|
-
shape: 'rounded',
|
|
28
|
-
usage: 'ghost',
|
|
29
|
-
}),
|
|
30
|
-
css({
|
|
31
|
-
w: '1/2',
|
|
32
|
-
}),
|
|
33
|
-
)}
|
|
34
|
-
asChild
|
|
35
|
-
>
|
|
36
|
-
{children}
|
|
37
|
-
</ark.div>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Button
|
|
43
|
-
{...buttonProps}
|
|
44
|
-
className={css({
|
|
45
|
-
w: '1/2',
|
|
46
|
-
})}
|
|
47
|
-
shape="rounded"
|
|
48
|
-
usage="outlined"
|
|
49
|
-
>
|
|
50
|
-
{children}
|
|
51
|
-
</Button>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { MouseEventHandler, ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This module provide utility functions for the cta modal.
|
|
5
|
-
* @module 'react/cta-modal/utils'
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export type CTAButtonAction = {
|
|
9
|
-
/**
|
|
10
|
-
* The text of the button.
|
|
11
|
-
*/
|
|
12
|
-
text: string
|
|
13
|
-
/**
|
|
14
|
-
* The onClick handler for the button.
|
|
15
|
-
*/
|
|
16
|
-
handleClick: MouseEventHandler<HTMLButtonElement>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type CTAModalAction = (CTAButtonAction | ReactNode)[]
|
|
20
|
-
|
|
21
|
-
export interface CTAModalActionReturn {
|
|
22
|
-
/**
|
|
23
|
-
* The type of the action content.
|
|
24
|
-
*/
|
|
25
|
-
type: 'reactNode' | 'btnAction'
|
|
26
|
-
/**
|
|
27
|
-
* The actions for the cta modal. Max of 2 actions.
|
|
28
|
-
*/
|
|
29
|
-
_actions: CTAModalAction
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Creates the action data to pass to the cta modal `show` method.
|
|
34
|
-
*/
|
|
35
|
-
export function createCTAModalActions(
|
|
36
|
-
providedActions: CTAModalAction,
|
|
37
|
-
): CTAModalActionReturn {
|
|
38
|
-
if (providedActions.length !== 2) {
|
|
39
|
-
throw new Error('CTAModal must include 2 actions')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
providedActions.every(
|
|
44
|
-
(action) => (action as unknown as CTAButtonAction)?.handleClick,
|
|
45
|
-
)
|
|
46
|
-
) {
|
|
47
|
-
return {
|
|
48
|
-
type: 'btnAction',
|
|
49
|
-
_actions: providedActions as CTAButtonAction[],
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
type: 'reactNode',
|
|
55
|
-
_actions: providedActions as ReactNode[],
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { ElementType } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
RatingContext,
|
|
4
|
-
RatingControl,
|
|
5
|
-
RatingHiddenInput,
|
|
6
|
-
RatingItem,
|
|
7
|
-
RatingItemContext,
|
|
8
|
-
RatingLabel,
|
|
9
|
-
RatingRoot,
|
|
10
|
-
} from './primitives'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This module contains the parts of the Rating component.
|
|
14
|
-
* @module 'rating/parts'
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
interface RatingPartsValue {
|
|
18
|
-
/**
|
|
19
|
-
* The container of the rating.
|
|
20
|
-
*/
|
|
21
|
-
Root: ElementType
|
|
22
|
-
/**
|
|
23
|
-
* The label of the rating.
|
|
24
|
-
*/
|
|
25
|
-
Label: ElementType
|
|
26
|
-
/**
|
|
27
|
-
* The visual representation of the rating.
|
|
28
|
-
*/
|
|
29
|
-
Control: ElementType
|
|
30
|
-
/**
|
|
31
|
-
* The context of the rating.
|
|
32
|
-
*/
|
|
33
|
-
Context: ElementType
|
|
34
|
-
/**
|
|
35
|
-
* The item to display for the rating.
|
|
36
|
-
*/
|
|
37
|
-
Item: ElementType
|
|
38
|
-
/**
|
|
39
|
-
* The context provider for the rating items.
|
|
40
|
-
*/
|
|
41
|
-
ItemContext: ElementType
|
|
42
|
-
/**
|
|
43
|
-
* The native input of the rating.
|
|
44
|
-
*/
|
|
45
|
-
HiddenInput: ElementType
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* An Object containing the parts of the Rating component. For users that
|
|
50
|
-
* prefer Object component syntax.
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
*
|
|
54
|
-
* When using object component syntax, you import the RatingParts object and
|
|
55
|
-
* the entire family of components vs. only what you use.
|
|
56
|
-
*/
|
|
57
|
-
export const RatingParts: RatingPartsValue = {
|
|
58
|
-
Root: RatingRoot,
|
|
59
|
-
Label: RatingLabel,
|
|
60
|
-
Control: RatingControl,
|
|
61
|
-
Context: RatingContext,
|
|
62
|
-
Item: RatingItem,
|
|
63
|
-
ItemContext: RatingItemContext,
|
|
64
|
-
HiddenInput: RatingHiddenInput,
|
|
65
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RatingGroup,
|
|
3
|
-
type RatingGroupContextProps,
|
|
4
|
-
type RatingGroupControlProps,
|
|
5
|
-
type RatingGroupHiddenInputProps,
|
|
6
|
-
type RatingGroupItemContextProps,
|
|
7
|
-
type RatingGroupItemProps,
|
|
8
|
-
type RatingGroupLabelProps,
|
|
9
|
-
type RatingGroupRootProps,
|
|
10
|
-
} from '@ark-ui/react/rating-group'
|
|
11
|
-
import { cx } from '@cerberus/styled-system/css'
|
|
12
|
-
import {
|
|
13
|
-
ratingGroup,
|
|
14
|
-
type RatingGroupVariantProps,
|
|
15
|
-
} from '@cerberus/styled-system/recipes'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* This module contains the primitives of the Rating component.
|
|
19
|
-
* @module 'rating/primitives'
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The root primitive of the Rating component.
|
|
24
|
-
*/
|
|
25
|
-
export function RatingRoot(
|
|
26
|
-
props: RatingGroupRootProps & RatingGroupVariantProps,
|
|
27
|
-
) {
|
|
28
|
-
const { orientation, size, ...rootProps } = props
|
|
29
|
-
const styles = ratingGroup({ orientation, size })
|
|
30
|
-
return (
|
|
31
|
-
<RatingGroup.Root
|
|
32
|
-
{...rootProps}
|
|
33
|
-
className={cx(styles.root, rootProps.className)}
|
|
34
|
-
/>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The label primitive of the Rating component.
|
|
40
|
-
*/
|
|
41
|
-
export function RatingLabel(props: RatingGroupLabelProps) {
|
|
42
|
-
const styles = ratingGroup()
|
|
43
|
-
return (
|
|
44
|
-
<RatingGroup.Label
|
|
45
|
-
{...props}
|
|
46
|
-
className={cx(styles.label, props.className)}
|
|
47
|
-
/>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The control primitive of the Rating component.
|
|
53
|
-
*/
|
|
54
|
-
export function RatingControl(props: RatingGroupControlProps) {
|
|
55
|
-
const styles = ratingGroup()
|
|
56
|
-
return (
|
|
57
|
-
<RatingGroup.Control
|
|
58
|
-
{...props}
|
|
59
|
-
className={cx(styles.control, props.className)}
|
|
60
|
-
/>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The context primitive of the Rating component.
|
|
66
|
-
*/
|
|
67
|
-
export function RatingContext(props: RatingGroupContextProps) {
|
|
68
|
-
return <RatingGroup.Context {...props} />
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The item primitive of the Rating component.
|
|
73
|
-
*/
|
|
74
|
-
export function RatingItem(
|
|
75
|
-
props: RatingGroupItemProps & RatingGroupVariantProps,
|
|
76
|
-
) {
|
|
77
|
-
const { palette, ...itemProps } = props
|
|
78
|
-
const styles = ratingGroup({ palette })
|
|
79
|
-
return (
|
|
80
|
-
<RatingGroup.Item
|
|
81
|
-
{...itemProps}
|
|
82
|
-
className={cx(styles.item, itemProps.className)}
|
|
83
|
-
/>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The item context primitive of the Rating component.
|
|
89
|
-
*/
|
|
90
|
-
export function RatingItemContext(props: RatingGroupItemContextProps) {
|
|
91
|
-
return <RatingGroup.ItemContext {...props} />
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The hidden input primitive of the Rating component.
|
|
96
|
-
*/
|
|
97
|
-
export function RatingHiddenInput(props: RatingGroupHiddenInputProps) {
|
|
98
|
-
return <RatingGroup.HiddenInput {...props} />
|
|
99
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
RatingGroupRootProps,
|
|
3
|
-
UseRatingGroupContext,
|
|
4
|
-
UseRatingGroupItemContext,
|
|
5
|
-
} from '@ark-ui/react/rating-group'
|
|
6
|
-
import type { RatingGroupVariantProps } from '@cerberus/styled-system/recipes'
|
|
7
|
-
import type { ReactNode } from 'react'
|
|
8
|
-
import { splitProps } from '../../utils/index'
|
|
9
|
-
import { Show } from '../Show'
|
|
10
|
-
import { RatingParts } from './parts'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This module contains the abstracted Rating component.
|
|
14
|
-
* @module 'react/rating'
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export interface RatingProps
|
|
18
|
-
extends Omit<RatingGroupRootProps, 'children'>,
|
|
19
|
-
RatingGroupVariantProps {
|
|
20
|
-
/**
|
|
21
|
-
* The label of the rating component.
|
|
22
|
-
*/
|
|
23
|
-
label?: string
|
|
24
|
-
/**
|
|
25
|
-
* The children of the rating component.
|
|
26
|
-
*/
|
|
27
|
-
children: (context: UseRatingGroupItemContext) => ReactNode
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The Rating component is an abstraction of the primitives which provides a
|
|
32
|
-
* visual rating system for a user to select a value.
|
|
33
|
-
* @description [Cerberus Docs](https://cerberus.digitalu.design/react/rating)
|
|
34
|
-
* @description [Ark Docs](https://ark-ui.com/react/docs/components/rating-group#api-reference)
|
|
35
|
-
* @example
|
|
36
|
-
* ```tsx
|
|
37
|
-
* <Rating count={5} defaultValue={3} allowHalf>
|
|
38
|
-
* {({ half, highlighted }) => {
|
|
39
|
-
* if (half) return <StarHalfIcon fill="current" />
|
|
40
|
-
* if (highlighted) return <StarIcon fill="current" />
|
|
41
|
-
* return <StarIcon />
|
|
42
|
-
* }}
|
|
43
|
-
* </Rating>
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export function Rating(props: RatingProps) {
|
|
47
|
-
const [{ label }, styleProps, rootProps] = splitProps(
|
|
48
|
-
props,
|
|
49
|
-
['label'],
|
|
50
|
-
['orientation', 'palette', 'size'],
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<RatingParts.Root {...styleProps} {...rootProps}>
|
|
55
|
-
<Show when={Boolean(label)}>
|
|
56
|
-
<RatingParts.Label>{label}</RatingParts.Label>
|
|
57
|
-
</Show>
|
|
58
|
-
|
|
59
|
-
<RatingParts.Control>
|
|
60
|
-
<RatingParts.Context>
|
|
61
|
-
{(context: UseRatingGroupContext) =>
|
|
62
|
-
context.items.map((item) => (
|
|
63
|
-
<RatingParts.Item
|
|
64
|
-
key={item}
|
|
65
|
-
index={item}
|
|
66
|
-
palette={styleProps.palette}
|
|
67
|
-
>
|
|
68
|
-
<RatingParts.ItemContext>
|
|
69
|
-
{rootProps.children}
|
|
70
|
-
</RatingParts.ItemContext>
|
|
71
|
-
</RatingParts.Item>
|
|
72
|
-
))
|
|
73
|
-
}
|
|
74
|
-
</RatingParts.Context>
|
|
75
|
-
</RatingParts.Control>
|
|
76
|
-
</RatingParts.Root>
|
|
77
|
-
)
|
|
78
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|