@xsolla/xui-b2c-card-selector 0.217.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/README.md +4 -0
- package/native/index.d.mts +112 -0
- package/native/index.d.ts +112 -0
- package/native/index.js +773 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +752 -0
- package/native/index.mjs.map +1 -0
- package/package.json +56 -0
- package/web/index.d.mts +112 -0
- package/web/index.d.ts +112 -0
- package/web/index.js +4345 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +4330 -0
- package/web/index.mjs.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ThemeOverrideProps } from '@xsolla/xui-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Figma `CardSelector` property `Platform`. Adjusts the card's internal
|
|
6
|
+
* proportions — control size, title scale and padding.
|
|
7
|
+
*/
|
|
8
|
+
type CardSelectorPlatform = "mobile" | "desktop";
|
|
9
|
+
/**
|
|
10
|
+
* Figma `CardSelector` property `Type`. `radio` = mutually exclusive choice
|
|
11
|
+
* within a group, `check` = independent toggle.
|
|
12
|
+
*/
|
|
13
|
+
type CardSelectorType = "radio" | "check";
|
|
14
|
+
/**
|
|
15
|
+
* Figma `CardSelector` property `Control`.
|
|
16
|
+
*
|
|
17
|
+
* - `text` — the selection control and the label sit in a solid text bar
|
|
18
|
+
* below the image. The control is always visible.
|
|
19
|
+
* - `onImage` — the control overlays the image and only renders when the card
|
|
20
|
+
* is selected; the label is a caption beneath the card.
|
|
21
|
+
*/
|
|
22
|
+
type CardSelectorControlPlacement = "text" | "onImage";
|
|
23
|
+
/** Figma `CardSelector` property `State`. `selected` is derived from `checked`. */
|
|
24
|
+
type CardSelectorState = "default" | "hover" | "press" | "disabled";
|
|
25
|
+
interface CardSelectorProps extends ThemeOverrideProps {
|
|
26
|
+
/**
|
|
27
|
+
* Option label. Required, single-line, truncates with an ellipsis — aim for
|
|
28
|
+
* under 24 characters.
|
|
29
|
+
*/
|
|
30
|
+
title: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Optional single-line clarification. Use it only when the title alone is
|
|
33
|
+
* ambiguous; never repeat the title.
|
|
34
|
+
*/
|
|
35
|
+
description?: ReactNode;
|
|
36
|
+
/** Media thumbnail (1:1). The image should preview the option itself. */
|
|
37
|
+
imageSrc?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Alt text. Defaults to `""` because the title normally describes the
|
|
40
|
+
* option; supply a meaningful value when the image carries meaning the
|
|
41
|
+
* title does not convey.
|
|
42
|
+
*/
|
|
43
|
+
imageAlt?: string;
|
|
44
|
+
/** Identifies the card inside a `CardSelectorGroup`. Required for `radio`. */
|
|
45
|
+
value?: string;
|
|
46
|
+
/** Inherited from `CardSelectorGroup` when unset. Defaults to `"radio"`. */
|
|
47
|
+
type?: CardSelectorType;
|
|
48
|
+
/** Inherited from `CardSelectorGroup` when unset. Defaults to `"text"`. */
|
|
49
|
+
control?: CardSelectorControlPlacement;
|
|
50
|
+
/** Inherited from `CardSelectorGroup` when unset. Defaults to `"mobile"`. */
|
|
51
|
+
platform?: CardSelectorPlatform;
|
|
52
|
+
/** Controlled selection state. Inside a radio group, derived from the group. */
|
|
53
|
+
checked?: boolean;
|
|
54
|
+
/** Uncontrolled initial selection state. */
|
|
55
|
+
defaultChecked?: boolean;
|
|
56
|
+
/** Fired when the card toggles. Not fired while disabled. */
|
|
57
|
+
onChange?: (checked: boolean, value?: string) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Interactive state. Web applies hover and press automatically — pass this
|
|
60
|
+
* explicitly only for design review. `selected` is not a member: it is
|
|
61
|
+
* derived from `checked` and takes visual priority over hover.
|
|
62
|
+
*/
|
|
63
|
+
state?: CardSelectorState;
|
|
64
|
+
/** Same effect as `state="disabled"`: 48% opacity, no interactivity, untabbable. */
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Card width. Defaults to `"100%"` so the card fills the grid cell the
|
|
68
|
+
* consumer lays out.
|
|
69
|
+
*/
|
|
70
|
+
width?: number | string;
|
|
71
|
+
/** Overrides the accessible name derived from the title and description. */
|
|
72
|
+
"aria-label"?: string;
|
|
73
|
+
testID?: string;
|
|
74
|
+
}
|
|
75
|
+
interface CardSelectorGroupProps extends ThemeOverrideProps {
|
|
76
|
+
children: ReactNode;
|
|
77
|
+
/** `radio` renders a `radiogroup`; `check` renders a plain `group`. */
|
|
78
|
+
type?: CardSelectorType;
|
|
79
|
+
/** Selected value for `type="radio"` (controlled). */
|
|
80
|
+
value?: string;
|
|
81
|
+
/** Initial selected value for `type="radio"` (uncontrolled). */
|
|
82
|
+
defaultValue?: string;
|
|
83
|
+
/** Fired with the newly selected value. `type="radio"` only. */
|
|
84
|
+
onValueChange?: (value: string) => void;
|
|
85
|
+
/** Applied to every card in the group unless the card overrides it. */
|
|
86
|
+
platform?: CardSelectorPlatform;
|
|
87
|
+
/** Applied to every card in the group unless the card overrides it. */
|
|
88
|
+
control?: CardSelectorControlPlacement;
|
|
89
|
+
/** Disables every card in the group. */
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
/** Grid gap between cards. */
|
|
92
|
+
gap?: number;
|
|
93
|
+
/** Accessible name for the group. Required unless `aria-labelledby` is set. */
|
|
94
|
+
"aria-label"?: string;
|
|
95
|
+
"aria-labelledby"?: string;
|
|
96
|
+
testID?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare const CardSelector: React.FC<CardSelectorProps>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Wraps a set of `CardSelector` cards.
|
|
103
|
+
*
|
|
104
|
+
* For `type="radio"` it renders a `radiogroup`, keeps the cards mutually
|
|
105
|
+
* exclusive, and implements the roving-tabindex + Arrow-key behaviour the
|
|
106
|
+
* Figma spec requires (3446:1761 — "within a Radio group, Arrow keys move
|
|
107
|
+
* focus and selection between cards"). For `type="check"` the cards toggle
|
|
108
|
+
* independently and the wrapper is a plain `group`.
|
|
109
|
+
*/
|
|
110
|
+
declare const CardSelectorGroup: React.FC<CardSelectorGroupProps>;
|
|
111
|
+
|
|
112
|
+
export { CardSelector, type CardSelectorControlPlacement, CardSelectorGroup, type CardSelectorGroupProps, type CardSelectorPlatform, type CardSelectorProps, type CardSelectorState, type CardSelectorType };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ThemeOverrideProps } from '@xsolla/xui-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Figma `CardSelector` property `Platform`. Adjusts the card's internal
|
|
6
|
+
* proportions — control size, title scale and padding.
|
|
7
|
+
*/
|
|
8
|
+
type CardSelectorPlatform = "mobile" | "desktop";
|
|
9
|
+
/**
|
|
10
|
+
* Figma `CardSelector` property `Type`. `radio` = mutually exclusive choice
|
|
11
|
+
* within a group, `check` = independent toggle.
|
|
12
|
+
*/
|
|
13
|
+
type CardSelectorType = "radio" | "check";
|
|
14
|
+
/**
|
|
15
|
+
* Figma `CardSelector` property `Control`.
|
|
16
|
+
*
|
|
17
|
+
* - `text` — the selection control and the label sit in a solid text bar
|
|
18
|
+
* below the image. The control is always visible.
|
|
19
|
+
* - `onImage` — the control overlays the image and only renders when the card
|
|
20
|
+
* is selected; the label is a caption beneath the card.
|
|
21
|
+
*/
|
|
22
|
+
type CardSelectorControlPlacement = "text" | "onImage";
|
|
23
|
+
/** Figma `CardSelector` property `State`. `selected` is derived from `checked`. */
|
|
24
|
+
type CardSelectorState = "default" | "hover" | "press" | "disabled";
|
|
25
|
+
interface CardSelectorProps extends ThemeOverrideProps {
|
|
26
|
+
/**
|
|
27
|
+
* Option label. Required, single-line, truncates with an ellipsis — aim for
|
|
28
|
+
* under 24 characters.
|
|
29
|
+
*/
|
|
30
|
+
title: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Optional single-line clarification. Use it only when the title alone is
|
|
33
|
+
* ambiguous; never repeat the title.
|
|
34
|
+
*/
|
|
35
|
+
description?: ReactNode;
|
|
36
|
+
/** Media thumbnail (1:1). The image should preview the option itself. */
|
|
37
|
+
imageSrc?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Alt text. Defaults to `""` because the title normally describes the
|
|
40
|
+
* option; supply a meaningful value when the image carries meaning the
|
|
41
|
+
* title does not convey.
|
|
42
|
+
*/
|
|
43
|
+
imageAlt?: string;
|
|
44
|
+
/** Identifies the card inside a `CardSelectorGroup`. Required for `radio`. */
|
|
45
|
+
value?: string;
|
|
46
|
+
/** Inherited from `CardSelectorGroup` when unset. Defaults to `"radio"`. */
|
|
47
|
+
type?: CardSelectorType;
|
|
48
|
+
/** Inherited from `CardSelectorGroup` when unset. Defaults to `"text"`. */
|
|
49
|
+
control?: CardSelectorControlPlacement;
|
|
50
|
+
/** Inherited from `CardSelectorGroup` when unset. Defaults to `"mobile"`. */
|
|
51
|
+
platform?: CardSelectorPlatform;
|
|
52
|
+
/** Controlled selection state. Inside a radio group, derived from the group. */
|
|
53
|
+
checked?: boolean;
|
|
54
|
+
/** Uncontrolled initial selection state. */
|
|
55
|
+
defaultChecked?: boolean;
|
|
56
|
+
/** Fired when the card toggles. Not fired while disabled. */
|
|
57
|
+
onChange?: (checked: boolean, value?: string) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Interactive state. Web applies hover and press automatically — pass this
|
|
60
|
+
* explicitly only for design review. `selected` is not a member: it is
|
|
61
|
+
* derived from `checked` and takes visual priority over hover.
|
|
62
|
+
*/
|
|
63
|
+
state?: CardSelectorState;
|
|
64
|
+
/** Same effect as `state="disabled"`: 48% opacity, no interactivity, untabbable. */
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Card width. Defaults to `"100%"` so the card fills the grid cell the
|
|
68
|
+
* consumer lays out.
|
|
69
|
+
*/
|
|
70
|
+
width?: number | string;
|
|
71
|
+
/** Overrides the accessible name derived from the title and description. */
|
|
72
|
+
"aria-label"?: string;
|
|
73
|
+
testID?: string;
|
|
74
|
+
}
|
|
75
|
+
interface CardSelectorGroupProps extends ThemeOverrideProps {
|
|
76
|
+
children: ReactNode;
|
|
77
|
+
/** `radio` renders a `radiogroup`; `check` renders a plain `group`. */
|
|
78
|
+
type?: CardSelectorType;
|
|
79
|
+
/** Selected value for `type="radio"` (controlled). */
|
|
80
|
+
value?: string;
|
|
81
|
+
/** Initial selected value for `type="radio"` (uncontrolled). */
|
|
82
|
+
defaultValue?: string;
|
|
83
|
+
/** Fired with the newly selected value. `type="radio"` only. */
|
|
84
|
+
onValueChange?: (value: string) => void;
|
|
85
|
+
/** Applied to every card in the group unless the card overrides it. */
|
|
86
|
+
platform?: CardSelectorPlatform;
|
|
87
|
+
/** Applied to every card in the group unless the card overrides it. */
|
|
88
|
+
control?: CardSelectorControlPlacement;
|
|
89
|
+
/** Disables every card in the group. */
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
/** Grid gap between cards. */
|
|
92
|
+
gap?: number;
|
|
93
|
+
/** Accessible name for the group. Required unless `aria-labelledby` is set. */
|
|
94
|
+
"aria-label"?: string;
|
|
95
|
+
"aria-labelledby"?: string;
|
|
96
|
+
testID?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare const CardSelector: React.FC<CardSelectorProps>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Wraps a set of `CardSelector` cards.
|
|
103
|
+
*
|
|
104
|
+
* For `type="radio"` it renders a `radiogroup`, keeps the cards mutually
|
|
105
|
+
* exclusive, and implements the roving-tabindex + Arrow-key behaviour the
|
|
106
|
+
* Figma spec requires (3446:1761 — "within a Radio group, Arrow keys move
|
|
107
|
+
* focus and selection between cards"). For `type="check"` the cards toggle
|
|
108
|
+
* independently and the wrapper is a plain `group`.
|
|
109
|
+
*/
|
|
110
|
+
declare const CardSelectorGroup: React.FC<CardSelectorGroupProps>;
|
|
111
|
+
|
|
112
|
+
export { CardSelector, type CardSelectorControlPlacement, CardSelectorGroup, type CardSelectorGroupProps, type CardSelectorPlatform, type CardSelectorProps, type CardSelectorState, type CardSelectorType };
|