@xsolla/xui-counter 0.200.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/native/index.d.mts +130 -0
- package/native/index.d.ts +130 -0
- package/native/index.js +676 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +646 -0
- package/native/index.mjs.map +1 -0
- package/package.json +59 -0
- package/web/index.d.mts +130 -0
- package/web/index.d.ts +130 -0
- package/web/index.js +696 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +659 -0
- package/web/index.mjs.map +1 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ThemeOverrideProps, ComponentSize } from '@xsolla/xui-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* How the Counter renders the value between the − and + buttons.
|
|
6
|
+
*
|
|
7
|
+
* - `"input"` — an editable text field. Supports Hover and Focus because it is
|
|
8
|
+
* a real input target.
|
|
9
|
+
* - `"readOnly"` — plain text changed only by the buttons. Has no Hover or
|
|
10
|
+
* Focus state of its own; the buttons carry their own hover states.
|
|
11
|
+
*
|
|
12
|
+
* `"readOnly"` renders the value as plain text, **not** as a disabled or
|
|
13
|
+
* `readonly` input — both would tell assistive technology the value cannot
|
|
14
|
+
* change, which is false.
|
|
15
|
+
*/
|
|
16
|
+
type CounterType = "input" | "readOnly";
|
|
17
|
+
interface CounterProps extends ThemeOverrideProps {
|
|
18
|
+
/**
|
|
19
|
+
* Current value (controlled). Pass `null` for a genuinely empty counter —
|
|
20
|
+
* the Figma `Filled=False` state. An empty counter is unusual; most counters
|
|
21
|
+
* start at a defined value such as `0` or `1`.
|
|
22
|
+
*/
|
|
23
|
+
value?: number | null;
|
|
24
|
+
/**
|
|
25
|
+
* Initial value when the component is uncontrolled. Ignored when `value` is
|
|
26
|
+
* provided.
|
|
27
|
+
*
|
|
28
|
+
* @default null
|
|
29
|
+
*/
|
|
30
|
+
defaultValue?: number | null;
|
|
31
|
+
/**
|
|
32
|
+
* Fired when the value is committed — on button press, on blur, or on Enter.
|
|
33
|
+
* Never fired on every keystroke, and never fired with an out-of-range or
|
|
34
|
+
* empty value: the committed number is always clamped into
|
|
35
|
+
* `[min, max]`.
|
|
36
|
+
*/
|
|
37
|
+
onChange?: (value: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Lowest allowed value. When reached, the − button becomes unavailable.
|
|
40
|
+
* Values below it are rounded up to it on commit.
|
|
41
|
+
*/
|
|
42
|
+
min?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Highest allowed value. When reached, the + button becomes unavailable.
|
|
45
|
+
* Values above it are rounded down to it on commit.
|
|
46
|
+
*/
|
|
47
|
+
max?: number;
|
|
48
|
+
/**
|
|
49
|
+
* How much one − / + press changes the value by. Define a larger step when
|
|
50
|
+
* the domain requires it (for example steps of 5 for bulk items).
|
|
51
|
+
*
|
|
52
|
+
* @default 1
|
|
53
|
+
*/
|
|
54
|
+
step?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Size of the counter. Drives the button box, the field height, the type
|
|
57
|
+
* scale, and the gap between the three elements.
|
|
58
|
+
*
|
|
59
|
+
* @default "md"
|
|
60
|
+
*/
|
|
61
|
+
size?: ComponentSize;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the value is an editable field (`"input"`) or plain text driven
|
|
64
|
+
* only by the buttons (`"readOnly"`).
|
|
65
|
+
*
|
|
66
|
+
* @default "input"
|
|
67
|
+
*/
|
|
68
|
+
type?: CounterType;
|
|
69
|
+
/**
|
|
70
|
+
* Disables the whole control — both buttons and, for `type="input"`, the
|
|
71
|
+
* field. The current value stays visible; always explain nearby why the
|
|
72
|
+
* quantity cannot be changed if the reason is not obvious.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Visible label rendered above the whole control (buttons + value), not
|
|
79
|
+
* between the buttons. Prefer FieldGroup or adjacent text in product UI;
|
|
80
|
+
* this prop is a convenience for the same layout. `type="input"` only —
|
|
81
|
+
* use `aria-label` for `type="readOnly"`. The − / + buttons alone do not
|
|
82
|
+
* name what is being counted.
|
|
83
|
+
*/
|
|
84
|
+
label?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Accessible name for the control when no visible `label` is present, e.g.
|
|
87
|
+
* `"Quantity"`, `"Number of guests"`, `"Quantity of Dragon Scale skin"`.
|
|
88
|
+
*/
|
|
89
|
+
"aria-label"?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Accessible name for the decrement button. Include the subject where
|
|
92
|
+
* possible so multiple counters on one page stay distinguishable.
|
|
93
|
+
*
|
|
94
|
+
* @default "Decrease quantity"
|
|
95
|
+
*/
|
|
96
|
+
decrementLabel?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Accessible name for the increment button.
|
|
99
|
+
*
|
|
100
|
+
* @default "Increase quantity"
|
|
101
|
+
*/
|
|
102
|
+
incrementLabel?: string;
|
|
103
|
+
/**
|
|
104
|
+
* `name` attribute forwarded to the underlying field. Only used for
|
|
105
|
+
* `type="input"`.
|
|
106
|
+
*/
|
|
107
|
+
name?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Unique identifier for the field element. Used for accessibility linking.
|
|
110
|
+
*/
|
|
111
|
+
id?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Test ID for testing frameworks. On web this renders as `data-testid`; on
|
|
114
|
+
* React Native it renders as `testID`. Sub-elements append `__decrement`,
|
|
115
|
+
* `__increment`, `__input`, and `__value`.
|
|
116
|
+
*/
|
|
117
|
+
testID?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A numeric stepper that lets the user increase or decrease a value using
|
|
122
|
+
* dedicated − and + buttons.
|
|
123
|
+
*
|
|
124
|
+
* Counter has no error state: values outside the allowed range are never
|
|
125
|
+
* rejected, they are silently clamped to the nearest bound on commit, so the
|
|
126
|
+
* component is always in a valid state.
|
|
127
|
+
*/
|
|
128
|
+
declare const Counter: React.ForwardRefExoticComponent<CounterProps & React.RefAttributes<HTMLInputElement>>;
|
|
129
|
+
|
|
130
|
+
export { Counter, type CounterProps, type CounterType };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ThemeOverrideProps, ComponentSize } from '@xsolla/xui-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* How the Counter renders the value between the − and + buttons.
|
|
6
|
+
*
|
|
7
|
+
* - `"input"` — an editable text field. Supports Hover and Focus because it is
|
|
8
|
+
* a real input target.
|
|
9
|
+
* - `"readOnly"` — plain text changed only by the buttons. Has no Hover or
|
|
10
|
+
* Focus state of its own; the buttons carry their own hover states.
|
|
11
|
+
*
|
|
12
|
+
* `"readOnly"` renders the value as plain text, **not** as a disabled or
|
|
13
|
+
* `readonly` input — both would tell assistive technology the value cannot
|
|
14
|
+
* change, which is false.
|
|
15
|
+
*/
|
|
16
|
+
type CounterType = "input" | "readOnly";
|
|
17
|
+
interface CounterProps extends ThemeOverrideProps {
|
|
18
|
+
/**
|
|
19
|
+
* Current value (controlled). Pass `null` for a genuinely empty counter —
|
|
20
|
+
* the Figma `Filled=False` state. An empty counter is unusual; most counters
|
|
21
|
+
* start at a defined value such as `0` or `1`.
|
|
22
|
+
*/
|
|
23
|
+
value?: number | null;
|
|
24
|
+
/**
|
|
25
|
+
* Initial value when the component is uncontrolled. Ignored when `value` is
|
|
26
|
+
* provided.
|
|
27
|
+
*
|
|
28
|
+
* @default null
|
|
29
|
+
*/
|
|
30
|
+
defaultValue?: number | null;
|
|
31
|
+
/**
|
|
32
|
+
* Fired when the value is committed — on button press, on blur, or on Enter.
|
|
33
|
+
* Never fired on every keystroke, and never fired with an out-of-range or
|
|
34
|
+
* empty value: the committed number is always clamped into
|
|
35
|
+
* `[min, max]`.
|
|
36
|
+
*/
|
|
37
|
+
onChange?: (value: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Lowest allowed value. When reached, the − button becomes unavailable.
|
|
40
|
+
* Values below it are rounded up to it on commit.
|
|
41
|
+
*/
|
|
42
|
+
min?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Highest allowed value. When reached, the + button becomes unavailable.
|
|
45
|
+
* Values above it are rounded down to it on commit.
|
|
46
|
+
*/
|
|
47
|
+
max?: number;
|
|
48
|
+
/**
|
|
49
|
+
* How much one − / + press changes the value by. Define a larger step when
|
|
50
|
+
* the domain requires it (for example steps of 5 for bulk items).
|
|
51
|
+
*
|
|
52
|
+
* @default 1
|
|
53
|
+
*/
|
|
54
|
+
step?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Size of the counter. Drives the button box, the field height, the type
|
|
57
|
+
* scale, and the gap between the three elements.
|
|
58
|
+
*
|
|
59
|
+
* @default "md"
|
|
60
|
+
*/
|
|
61
|
+
size?: ComponentSize;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the value is an editable field (`"input"`) or plain text driven
|
|
64
|
+
* only by the buttons (`"readOnly"`).
|
|
65
|
+
*
|
|
66
|
+
* @default "input"
|
|
67
|
+
*/
|
|
68
|
+
type?: CounterType;
|
|
69
|
+
/**
|
|
70
|
+
* Disables the whole control — both buttons and, for `type="input"`, the
|
|
71
|
+
* field. The current value stays visible; always explain nearby why the
|
|
72
|
+
* quantity cannot be changed if the reason is not obvious.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Visible label rendered above the whole control (buttons + value), not
|
|
79
|
+
* between the buttons. Prefer FieldGroup or adjacent text in product UI;
|
|
80
|
+
* this prop is a convenience for the same layout. `type="input"` only —
|
|
81
|
+
* use `aria-label` for `type="readOnly"`. The − / + buttons alone do not
|
|
82
|
+
* name what is being counted.
|
|
83
|
+
*/
|
|
84
|
+
label?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Accessible name for the control when no visible `label` is present, e.g.
|
|
87
|
+
* `"Quantity"`, `"Number of guests"`, `"Quantity of Dragon Scale skin"`.
|
|
88
|
+
*/
|
|
89
|
+
"aria-label"?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Accessible name for the decrement button. Include the subject where
|
|
92
|
+
* possible so multiple counters on one page stay distinguishable.
|
|
93
|
+
*
|
|
94
|
+
* @default "Decrease quantity"
|
|
95
|
+
*/
|
|
96
|
+
decrementLabel?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Accessible name for the increment button.
|
|
99
|
+
*
|
|
100
|
+
* @default "Increase quantity"
|
|
101
|
+
*/
|
|
102
|
+
incrementLabel?: string;
|
|
103
|
+
/**
|
|
104
|
+
* `name` attribute forwarded to the underlying field. Only used for
|
|
105
|
+
* `type="input"`.
|
|
106
|
+
*/
|
|
107
|
+
name?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Unique identifier for the field element. Used for accessibility linking.
|
|
110
|
+
*/
|
|
111
|
+
id?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Test ID for testing frameworks. On web this renders as `data-testid`; on
|
|
114
|
+
* React Native it renders as `testID`. Sub-elements append `__decrement`,
|
|
115
|
+
* `__increment`, `__input`, and `__value`.
|
|
116
|
+
*/
|
|
117
|
+
testID?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A numeric stepper that lets the user increase or decrease a value using
|
|
122
|
+
* dedicated − and + buttons.
|
|
123
|
+
*
|
|
124
|
+
* Counter has no error state: values outside the allowed range are never
|
|
125
|
+
* rejected, they are silently clamped to the nearest bound on commit, so the
|
|
126
|
+
* component is always in a valid state.
|
|
127
|
+
*/
|
|
128
|
+
declare const Counter: React.ForwardRefExoticComponent<CounterProps & React.RefAttributes<HTMLInputElement>>;
|
|
129
|
+
|
|
130
|
+
export { Counter, type CounterProps, type CounterType };
|