@xaui/native 0.9.1-alpha.91 → 0.9.1-alpha.92
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/dist/chunk-3A5RK2R7.js +40 -0
- package/dist/chunk-6JAGPPZU.cjs +788 -0
- package/dist/chunk-7NQL5DXY.js +302 -0
- package/dist/chunk-FTPPUTWL.cjs +40 -0
- package/dist/chunk-GGP2ERSV.js +487 -0
- package/dist/chunk-KPKEZWZM.js +517 -0
- package/dist/chunk-LKRQUQZQ.cjs +487 -0
- package/dist/{chunk-LIEXFWTN.js → chunk-P5M5URAB.js} +29 -126
- package/dist/chunk-UR37LVPU.cjs +382 -0
- package/dist/chunk-XWIPLZTD.cjs +302 -0
- package/dist/components/carousel/index.cjs +3 -2
- package/dist/components/carousel/index.js +2 -1
- package/dist/components/index.d.cts +3 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/number-pad/index.cjs +40 -0
- package/dist/components/number-pad/index.d.cts +60 -0
- package/dist/components/number-pad/index.d.ts +60 -0
- package/dist/components/number-pad/index.js +40 -0
- package/dist/components/number-pad/number-pad-action.d.cts +24 -0
- package/dist/components/number-pad/number-pad-action.d.ts +24 -0
- package/dist/components/number-pad/number-pad-backspace.d.cts +18 -0
- package/dist/components/number-pad/number-pad-backspace.d.ts +18 -0
- package/dist/components/number-pad/number-pad-cell.d.cts +7 -0
- package/dist/components/number-pad/number-pad-cell.d.ts +7 -0
- package/dist/components/number-pad/number-pad-icon.d.cts +13 -0
- package/dist/components/number-pad/number-pad-icon.d.ts +13 -0
- package/dist/components/number-pad/number-pad-key.d.cts +24 -0
- package/dist/components/number-pad/number-pad-key.d.ts +24 -0
- package/dist/components/number-pad/number-pad-label.d.cts +14 -0
- package/dist/components/number-pad/number-pad-label.d.ts +14 -0
- package/dist/components/number-pad/number-pad.context.d.cts +18 -0
- package/dist/components/number-pad/number-pad.context.d.ts +18 -0
- package/dist/components/number-pad/number-pad.d.cts +57 -0
- package/dist/components/number-pad/number-pad.d.ts +57 -0
- package/dist/components/number-pad/number-pad.recipe.d.cts +11 -0
- package/dist/components/number-pad/number-pad.recipe.d.ts +11 -0
- package/dist/components/number-pad/number-pad.style.d.cts +13 -0
- package/dist/components/number-pad/number-pad.style.d.ts +13 -0
- package/dist/components/number-pad/number-pad.type.d.cts +135 -0
- package/dist/components/number-pad/number-pad.type.d.ts +135 -0
- package/dist/components/number-pad/number-pad.utils.d.cts +34 -0
- package/dist/components/number-pad/number-pad.utils.d.ts +34 -0
- package/dist/components/pager/index.cjs +31 -0
- package/dist/components/pager/index.d.cts +60 -0
- package/dist/components/pager/index.d.ts +60 -0
- package/dist/components/pager/index.js +31 -0
- package/dist/components/pager/pager-content.d.cts +24 -0
- package/dist/components/pager/pager-content.d.ts +24 -0
- package/dist/components/pager/pager-indicator.d.cts +47 -0
- package/dist/components/pager/pager-indicator.d.ts +47 -0
- package/dist/components/pager/pager-page.d.cts +16 -0
- package/dist/components/pager/pager-page.d.ts +16 -0
- package/dist/components/pager/pager.context.d.cts +7 -0
- package/dist/components/pager/pager.context.d.ts +7 -0
- package/dist/components/pager/pager.d.cts +71 -0
- package/dist/components/pager/pager.d.ts +71 -0
- package/dist/components/pager/pager.recipe.d.cts +15 -0
- package/dist/components/pager/pager.recipe.d.ts +15 -0
- package/dist/components/pager/pager.type.d.cts +108 -0
- package/dist/components/pager/pager.type.d.ts +108 -0
- package/dist/components/rating/index.cjs +30 -0
- package/dist/components/rating/index.d.cts +41 -0
- package/dist/components/rating/index.d.ts +41 -0
- package/dist/components/rating/index.js +30 -0
- package/dist/components/rating/rating-icon.d.cts +16 -0
- package/dist/components/rating/rating-icon.d.ts +16 -0
- package/dist/components/rating/rating-item.d.cts +23 -0
- package/dist/components/rating/rating-item.d.ts +23 -0
- package/dist/components/rating/rating-star.d.cts +19 -0
- package/dist/components/rating/rating-star.d.ts +19 -0
- package/dist/components/rating/rating.context.d.cts +16 -0
- package/dist/components/rating/rating.context.d.ts +16 -0
- package/dist/components/rating/rating.d.cts +59 -0
- package/dist/components/rating/rating.d.ts +59 -0
- package/dist/components/rating/rating.recipe.d.cts +11 -0
- package/dist/components/rating/rating.recipe.d.ts +11 -0
- package/dist/components/rating/rating.style.d.cts +24 -0
- package/dist/components/rating/rating.style.d.ts +24 -0
- package/dist/components/rating/rating.type.d.cts +108 -0
- package/dist/components/rating/rating.type.d.ts +108 -0
- package/dist/components/rating/rating.utils.d.cts +28 -0
- package/dist/components/rating/rating.utils.d.ts +28 -0
- package/dist/index.cjs +90 -29
- package/dist/index.js +146 -85
- package/package.json +31 -1
- package/dist/chunk-K5UO3HBW.cjs +0 -1007
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SlotStyles } from '../../system/recipe';
|
|
2
|
+
import type { XAUITheme } from '../../theme/theme.type';
|
|
3
|
+
import type { RatingSlot, RatingVariant } from './rating.type';
|
|
4
|
+
export declare const ratingRecipe: import("../..").Recipe<"root" | "glyph" | "item" | "glyphFill", RatingVariant, {
|
|
5
|
+
readonly size: {
|
|
6
|
+
readonly xs: (theme: XAUITheme) => SlotStyles<RatingSlot>;
|
|
7
|
+
readonly sm: (theme: XAUITheme) => SlotStyles<RatingSlot>;
|
|
8
|
+
readonly md: (theme: XAUITheme) => SlotStyles<RatingSlot>;
|
|
9
|
+
readonly lg: (theme: XAUITheme) => SlotStyles<RatingSlot>;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The clip the filled layer is drawn inside.
|
|
3
|
+
*
|
|
4
|
+
* **No token in it**, which is why it is here rather than in the recipe: this is geometry.
|
|
5
|
+
* The layer is pinned to the mark's leading edge and its width is the fraction that is
|
|
6
|
+
* filled, so `overflow: 'hidden'` cuts the glyph part-way through and a value of 4.3 shows
|
|
7
|
+
* three tenths of the fifth mark.
|
|
8
|
+
*
|
|
9
|
+
* `start` and `top` rather than `left` (R13): a right-to-left layout fills from the other
|
|
10
|
+
* edge, and the logical key is what makes that happen with no second branch.
|
|
11
|
+
*
|
|
12
|
+
* The glyph inside it must **not** be allowed to shrink to the clip's width, or the
|
|
13
|
+
* character would re-wrap instead of being cut — which is what the mark's own width on the
|
|
14
|
+
* inner node is for.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ratingSheet: {
|
|
17
|
+
clip: {
|
|
18
|
+
position: "absolute";
|
|
19
|
+
top: number;
|
|
20
|
+
start: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
overflow: "hidden";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The clip the filled layer is drawn inside.
|
|
3
|
+
*
|
|
4
|
+
* **No token in it**, which is why it is here rather than in the recipe: this is geometry.
|
|
5
|
+
* The layer is pinned to the mark's leading edge and its width is the fraction that is
|
|
6
|
+
* filled, so `overflow: 'hidden'` cuts the glyph part-way through and a value of 4.3 shows
|
|
7
|
+
* three tenths of the fifth mark.
|
|
8
|
+
*
|
|
9
|
+
* `start` and `top` rather than `left` (R13): a right-to-left layout fills from the other
|
|
10
|
+
* edge, and the logical key is what makes that happen with no second branch.
|
|
11
|
+
*
|
|
12
|
+
* The glyph inside it must **not** be allowed to shrink to the clip's width, or the
|
|
13
|
+
* character would re-wrap instead of being cut — which is what the mark's own width on the
|
|
14
|
+
* inner node is for.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ratingSheet: {
|
|
17
|
+
clip: {
|
|
18
|
+
position: "absolute";
|
|
19
|
+
top: number;
|
|
20
|
+
start: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
overflow: "hidden";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { PressableStateCallbackType, StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
import type { IconContextValue, IconProps } from '../../system/icon';
|
|
4
|
+
import type { PressableFeedbackProps } from '../../system/pressable-feedback';
|
|
5
|
+
import type { ViewStyleProps } from '../../system/style-props';
|
|
6
|
+
import type { Size } from '../../theme/theme.type';
|
|
7
|
+
export type RatingSlot = 'root' | 'item' | 'glyph' | 'glyphFill';
|
|
8
|
+
/**
|
|
9
|
+
* Three, naming **which colour a filled mark takes** — the only thing this component paints
|
|
10
|
+
* that is a decision. The unfilled marks keep a neutral fill, which is the ground the filled
|
|
11
|
+
* ones are read against.
|
|
12
|
+
*
|
|
13
|
+
* - `primary` — the accent.
|
|
14
|
+
* - `secondary` — the neutral foreground.
|
|
15
|
+
* - `tertiary` — the page's own foreground, for a rating on a coloured card.
|
|
16
|
+
*
|
|
17
|
+
* The amber every store uses is not a token here, because it is not a role the theme has an
|
|
18
|
+
* opinion about — it is `color="#f59e0b"`, which is what a raw tint is for (R7). `warning`
|
|
19
|
+
* is deliberately not offered in its place: it is a status, and a four-star review is not a
|
|
20
|
+
* warning.
|
|
21
|
+
*/
|
|
22
|
+
export type RatingVariant = 'primary' | 'secondary' | 'tertiary';
|
|
23
|
+
export type RatingSize = Size;
|
|
24
|
+
/** Which layer of a mark a glyph is drawn in. */
|
|
25
|
+
export type RatingTone = 'empty' | 'fill';
|
|
26
|
+
type RatingOwnProps = {
|
|
27
|
+
variant?: RatingVariant;
|
|
28
|
+
/** The mark's size and the gap between marks. */
|
|
29
|
+
size?: RatingSize;
|
|
30
|
+
/** A raw tint (R7) for the filled marks. The unfilled ones keep their neutral ground. */
|
|
31
|
+
color?: string;
|
|
32
|
+
/** How many marks. @default 5 */
|
|
33
|
+
max?: number;
|
|
34
|
+
/** Controlled. Leave it out and the rating keeps the value itself. */
|
|
35
|
+
value?: number;
|
|
36
|
+
/** The starting value when uncontrolled. @default 0 */
|
|
37
|
+
defaultValue?: number;
|
|
38
|
+
onValueChange?: (value: number) => void;
|
|
39
|
+
/**
|
|
40
|
+
* The step a press lands on. `1` is whole marks, `0.5` halves.
|
|
41
|
+
*
|
|
42
|
+
* It governs **input only** — a `value` of any precision displays as it is, so an average
|
|
43
|
+
* of 4.3 fills the fifth mark three tenths of the way whatever this says.
|
|
44
|
+
*
|
|
45
|
+
* @default 1
|
|
46
|
+
*/
|
|
47
|
+
precision?: number;
|
|
48
|
+
/**
|
|
49
|
+
* A display rather than a control: the marks stop responding and announce themselves as
|
|
50
|
+
* an image showing a value, not as buttons.
|
|
51
|
+
*/
|
|
52
|
+
isReadOnly?: boolean;
|
|
53
|
+
isDisabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* **The glyph**, drawn once per mark, in each of the two layers a mark has:
|
|
56
|
+
*
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <Rating max={5} value={value} onValueChange={setValue}>
|
|
59
|
+
* <Rating.Icon as={HeartIcon} />
|
|
60
|
+
* </Rating>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* One element rather than a row of them, because the number of marks is `max` — data, not
|
|
64
|
+
* markup — and five hand-written marks is a row that disagrees with the prop the moment
|
|
65
|
+
* either changes. Left out, the mark is a star.
|
|
66
|
+
*
|
|
67
|
+
* A label beside the row is **not** in here: that is a `Typography` in a `Row`, and it is
|
|
68
|
+
* the screen's rather than the rating's (R1).
|
|
69
|
+
*/
|
|
70
|
+
children?: ReactNode;
|
|
71
|
+
style?: StyleProp<ViewStyle>;
|
|
72
|
+
};
|
|
73
|
+
/** R14 — it renders a `View`, so it carries that node's style keys. */
|
|
74
|
+
export type RatingProps = RatingOwnProps & Omit<ViewProps, 'style' | 'children'> & Omit<ViewStyleProps, keyof RatingOwnProps>;
|
|
75
|
+
export type RatingItemProps = Omit<PressableFeedbackProps, 'isPressed' | 'layout' | 'style' | 'children'> & {
|
|
76
|
+
/** Which mark this is, counted from zero. */
|
|
77
|
+
index: number;
|
|
78
|
+
/** R9 — `Pressable`'s function form as much as an object or an array. */
|
|
79
|
+
style?: StyleProp<ViewStyle> | ((state: PressableStateCallbackType) => StyleProp<ViewStyle>);
|
|
80
|
+
children?: ReactNode;
|
|
81
|
+
};
|
|
82
|
+
export type RatingIconProps = IconProps;
|
|
83
|
+
/** R5 — resolved styles, not props for a slot to resolve a second time. */
|
|
84
|
+
export type RatingContextValue = {
|
|
85
|
+
itemStyle: StyleProp<ViewStyle>;
|
|
86
|
+
glyphStyle: StyleProp<TextStyle>;
|
|
87
|
+
glyphFillStyle: StyleProp<TextStyle>;
|
|
88
|
+
/**
|
|
89
|
+
* Values, not a style: `Icon` hands `size` and `color` to a third-party component, so the
|
|
90
|
+
* root flattens each layer once here rather than in every glyph it contains.
|
|
91
|
+
*/
|
|
92
|
+
icon: IconContextValue;
|
|
93
|
+
iconFill: IconContextValue;
|
|
94
|
+
/** How wide one mark is, which is what the fill layer is clipped against. */
|
|
95
|
+
markSize: number;
|
|
96
|
+
value: number;
|
|
97
|
+
max: number;
|
|
98
|
+
precision: number;
|
|
99
|
+
/** What a mark calls with the fraction of itself that was pressed. */
|
|
100
|
+
select: (index: number, ratio: number) => void;
|
|
101
|
+
isReadOnly: boolean;
|
|
102
|
+
isDisabled: boolean;
|
|
103
|
+
};
|
|
104
|
+
/** Which layer a glyph is in, so it needs no prop to know which colour it takes. */
|
|
105
|
+
export type RatingLayerContextValue = {
|
|
106
|
+
tone: RatingTone;
|
|
107
|
+
};
|
|
108
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { PressableStateCallbackType, StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
import type { IconContextValue, IconProps } from '../../system/icon';
|
|
4
|
+
import type { PressableFeedbackProps } from '../../system/pressable-feedback';
|
|
5
|
+
import type { ViewStyleProps } from '../../system/style-props';
|
|
6
|
+
import type { Size } from '../../theme/theme.type';
|
|
7
|
+
export type RatingSlot = 'root' | 'item' | 'glyph' | 'glyphFill';
|
|
8
|
+
/**
|
|
9
|
+
* Three, naming **which colour a filled mark takes** — the only thing this component paints
|
|
10
|
+
* that is a decision. The unfilled marks keep a neutral fill, which is the ground the filled
|
|
11
|
+
* ones are read against.
|
|
12
|
+
*
|
|
13
|
+
* - `primary` — the accent.
|
|
14
|
+
* - `secondary` — the neutral foreground.
|
|
15
|
+
* - `tertiary` — the page's own foreground, for a rating on a coloured card.
|
|
16
|
+
*
|
|
17
|
+
* The amber every store uses is not a token here, because it is not a role the theme has an
|
|
18
|
+
* opinion about — it is `color="#f59e0b"`, which is what a raw tint is for (R7). `warning`
|
|
19
|
+
* is deliberately not offered in its place: it is a status, and a four-star review is not a
|
|
20
|
+
* warning.
|
|
21
|
+
*/
|
|
22
|
+
export type RatingVariant = 'primary' | 'secondary' | 'tertiary';
|
|
23
|
+
export type RatingSize = Size;
|
|
24
|
+
/** Which layer of a mark a glyph is drawn in. */
|
|
25
|
+
export type RatingTone = 'empty' | 'fill';
|
|
26
|
+
type RatingOwnProps = {
|
|
27
|
+
variant?: RatingVariant;
|
|
28
|
+
/** The mark's size and the gap between marks. */
|
|
29
|
+
size?: RatingSize;
|
|
30
|
+
/** A raw tint (R7) for the filled marks. The unfilled ones keep their neutral ground. */
|
|
31
|
+
color?: string;
|
|
32
|
+
/** How many marks. @default 5 */
|
|
33
|
+
max?: number;
|
|
34
|
+
/** Controlled. Leave it out and the rating keeps the value itself. */
|
|
35
|
+
value?: number;
|
|
36
|
+
/** The starting value when uncontrolled. @default 0 */
|
|
37
|
+
defaultValue?: number;
|
|
38
|
+
onValueChange?: (value: number) => void;
|
|
39
|
+
/**
|
|
40
|
+
* The step a press lands on. `1` is whole marks, `0.5` halves.
|
|
41
|
+
*
|
|
42
|
+
* It governs **input only** — a `value` of any precision displays as it is, so an average
|
|
43
|
+
* of 4.3 fills the fifth mark three tenths of the way whatever this says.
|
|
44
|
+
*
|
|
45
|
+
* @default 1
|
|
46
|
+
*/
|
|
47
|
+
precision?: number;
|
|
48
|
+
/**
|
|
49
|
+
* A display rather than a control: the marks stop responding and announce themselves as
|
|
50
|
+
* an image showing a value, not as buttons.
|
|
51
|
+
*/
|
|
52
|
+
isReadOnly?: boolean;
|
|
53
|
+
isDisabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* **The glyph**, drawn once per mark, in each of the two layers a mark has:
|
|
56
|
+
*
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <Rating max={5} value={value} onValueChange={setValue}>
|
|
59
|
+
* <Rating.Icon as={HeartIcon} />
|
|
60
|
+
* </Rating>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* One element rather than a row of them, because the number of marks is `max` — data, not
|
|
64
|
+
* markup — and five hand-written marks is a row that disagrees with the prop the moment
|
|
65
|
+
* either changes. Left out, the mark is a star.
|
|
66
|
+
*
|
|
67
|
+
* A label beside the row is **not** in here: that is a `Typography` in a `Row`, and it is
|
|
68
|
+
* the screen's rather than the rating's (R1).
|
|
69
|
+
*/
|
|
70
|
+
children?: ReactNode;
|
|
71
|
+
style?: StyleProp<ViewStyle>;
|
|
72
|
+
};
|
|
73
|
+
/** R14 — it renders a `View`, so it carries that node's style keys. */
|
|
74
|
+
export type RatingProps = RatingOwnProps & Omit<ViewProps, 'style' | 'children'> & Omit<ViewStyleProps, keyof RatingOwnProps>;
|
|
75
|
+
export type RatingItemProps = Omit<PressableFeedbackProps, 'isPressed' | 'layout' | 'style' | 'children'> & {
|
|
76
|
+
/** Which mark this is, counted from zero. */
|
|
77
|
+
index: number;
|
|
78
|
+
/** R9 — `Pressable`'s function form as much as an object or an array. */
|
|
79
|
+
style?: StyleProp<ViewStyle> | ((state: PressableStateCallbackType) => StyleProp<ViewStyle>);
|
|
80
|
+
children?: ReactNode;
|
|
81
|
+
};
|
|
82
|
+
export type RatingIconProps = IconProps;
|
|
83
|
+
/** R5 — resolved styles, not props for a slot to resolve a second time. */
|
|
84
|
+
export type RatingContextValue = {
|
|
85
|
+
itemStyle: StyleProp<ViewStyle>;
|
|
86
|
+
glyphStyle: StyleProp<TextStyle>;
|
|
87
|
+
glyphFillStyle: StyleProp<TextStyle>;
|
|
88
|
+
/**
|
|
89
|
+
* Values, not a style: `Icon` hands `size` and `color` to a third-party component, so the
|
|
90
|
+
* root flattens each layer once here rather than in every glyph it contains.
|
|
91
|
+
*/
|
|
92
|
+
icon: IconContextValue;
|
|
93
|
+
iconFill: IconContextValue;
|
|
94
|
+
/** How wide one mark is, which is what the fill layer is clipped against. */
|
|
95
|
+
markSize: number;
|
|
96
|
+
value: number;
|
|
97
|
+
max: number;
|
|
98
|
+
precision: number;
|
|
99
|
+
/** What a mark calls with the fraction of itself that was pressed. */
|
|
100
|
+
select: (index: number, ratio: number) => void;
|
|
101
|
+
isReadOnly: boolean;
|
|
102
|
+
isDisabled: boolean;
|
|
103
|
+
};
|
|
104
|
+
/** Which layer a glyph is in, so it needs no prop to know which colour it takes. */
|
|
105
|
+
export type RatingLayerContextValue = {
|
|
106
|
+
tone: RatingTone;
|
|
107
|
+
};
|
|
108
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of the mark at `index` is filled, from 0 to 1.
|
|
3
|
+
*
|
|
4
|
+
* A fraction rather than a boolean, and that is what lets one component be both halves of
|
|
5
|
+
* the job: an average of 4.3 fills the fifth mark three tenths of the way, where a boolean
|
|
6
|
+
* would have to round it to 4 and lose the thing the average was for.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fillFor(value: number, index: number): number;
|
|
9
|
+
export type SnapOptions = {
|
|
10
|
+
/** Where the press landed, in marks — `2.34` is a third of the way into the third. */
|
|
11
|
+
raw: number;
|
|
12
|
+
/** The step a press lands on. `1` is whole marks, `0.5` halves. */
|
|
13
|
+
precision: number;
|
|
14
|
+
max: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The value a press at `raw` marks means.
|
|
18
|
+
*
|
|
19
|
+
* It rounds **up**, which is the only rounding that matches what a finger meant: a tap
|
|
20
|
+
* anywhere in the first mark is one star, not zero, and with `precision={0.5}` a tap on the
|
|
21
|
+
* left half of the third is 2.5 while the right half is 3. Rounding to nearest would make
|
|
22
|
+
* the first sliver of every mark select the one before it, so the leftmost strip of the row
|
|
23
|
+
* would silently rate zero.
|
|
24
|
+
*
|
|
25
|
+
* Clamped into `[precision, max]`: the smallest thing a press can express is one step, and
|
|
26
|
+
* no press can exceed the row it landed in.
|
|
27
|
+
*/
|
|
28
|
+
export declare function snapValue({ raw, precision, max }: SnapOptions): number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of the mark at `index` is filled, from 0 to 1.
|
|
3
|
+
*
|
|
4
|
+
* A fraction rather than a boolean, and that is what lets one component be both halves of
|
|
5
|
+
* the job: an average of 4.3 fills the fifth mark three tenths of the way, where a boolean
|
|
6
|
+
* would have to round it to 4 and lose the thing the average was for.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fillFor(value: number, index: number): number;
|
|
9
|
+
export type SnapOptions = {
|
|
10
|
+
/** Where the press landed, in marks — `2.34` is a third of the way into the third. */
|
|
11
|
+
raw: number;
|
|
12
|
+
/** The step a press lands on. `1` is whole marks, `0.5` halves. */
|
|
13
|
+
precision: number;
|
|
14
|
+
max: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The value a press at `raw` marks means.
|
|
18
|
+
*
|
|
19
|
+
* It rounds **up**, which is the only rounding that matches what a finger meant: a tap
|
|
20
|
+
* anywhere in the first mark is one star, not zero, and with `precision={0.5}` a tap on the
|
|
21
|
+
* left half of the third is 2.5 while the right half is 3. Rounding to nearest would make
|
|
22
|
+
* the first sliver of every mark select the one before it, so the leftmost strip of the row
|
|
23
|
+
* would silently rate zero.
|
|
24
|
+
*
|
|
25
|
+
* Clamped into `[precision, max]`: the smallest thing a press can express is one step, and
|
|
26
|
+
* no press can exceed the row it landed in.
|
|
27
|
+
*/
|
|
28
|
+
export declare function snapValue({ raw, precision, max }: SnapOptions): number;
|