@kanso-labs/react-native-kanso-ui 0.9.0 → 0.11.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 -3
- package/dist/autocomplete/index.js +15 -1
- package/dist/autocomplete/index.js.map +1 -1
- package/dist/button/group.d.ts +5 -0
- package/dist/button/group.js +115 -0
- package/dist/button/group.js.map +1 -0
- package/dist/button/index.d.ts +4 -1
- package/dist/button/index.js +44 -22
- package/dist/button/index.js.map +1 -1
- package/dist/button/slots.js +2 -1
- package/dist/button/slots.js.map +1 -1
- package/dist/calendar/index.js +351 -182
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +33 -2
- package/dist/calendar/styles.js.map +1 -1
- package/dist/carousel/arrangement.d.ts +5 -0
- package/dist/carousel/arrangement.js +123 -0
- package/dist/carousel/arrangement.js.map +1 -0
- package/dist/chequer/index.js +95 -0
- package/dist/chequer/index.js.map +1 -0
- package/dist/collection/index.d.ts +157 -0
- package/dist/collection/index.js +1358 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/color-thumb/index.js +56 -0
- package/dist/color-thumb/index.js.map +1 -0
- package/dist/components/button/index.d.ts +4 -2
- package/dist/components/button/index.js +227 -188
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +87 -0
- package/dist/components/button-group/index.js +275 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +11 -3
- package/dist/components/calendar/index.js +60 -45
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +72 -0
- package/dist/components/carousel/index.js +496 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/checkbox-group/index.d.ts +3 -4
- package/dist/components/checkbox-group/index.js +1 -1
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +4 -1
- package/dist/components/chip/index.js +229 -161
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/color-area/index.d.ts +85 -0
- package/dist/components/color-area/index.js +630 -0
- package/dist/components/color-area/index.js.map +1 -0
- package/dist/components/color-field/index.d.ts +144 -0
- package/dist/components/color-field/index.js +516 -0
- package/dist/components/color-field/index.js.map +1 -0
- package/dist/components/color-picker/index.d.ts +74 -0
- package/dist/components/color-picker/index.js +317 -0
- package/dist/components/color-picker/index.js.map +1 -0
- package/dist/components/color-slider/index.d.ts +82 -0
- package/dist/components/color-slider/index.js +456 -0
- package/dist/components/color-slider/index.js.map +1 -0
- package/dist/components/color-swatch/index.d.ts +46 -0
- package/dist/components/color-swatch/index.js +127 -0
- package/dist/components/color-swatch/index.js.map +1 -0
- package/dist/components/color-swatch-picker/index.d.ts +81 -0
- package/dist/components/color-swatch-picker/index.js +287 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -0
- package/dist/components/color-wheel/index.d.ts +71 -0
- package/dist/components/color-wheel/index.js +407 -0
- package/dist/components/color-wheel/index.js.map +1 -0
- package/dist/components/combo-box/index.d.ts +193 -0
- package/dist/components/combo-box/index.js +616 -0
- package/dist/components/combo-box/index.js.map +1 -0
- package/dist/components/date-field/index.d.ts +120 -0
- package/dist/components/date-field/index.js +111 -0
- package/dist/components/date-field/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +130 -0
- package/dist/components/date-picker/index.js +310 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-range-picker/index.d.ts +139 -0
- package/dist/components/date-range-picker/index.js +421 -0
- package/dist/components/date-range-picker/index.js.map +1 -0
- package/dist/components/dialog/index.d.ts +5 -5
- package/dist/components/dialog/index.js +5 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/disclosure/index.d.ts +94 -0
- package/dist/components/disclosure/index.js +365 -0
- package/dist/components/disclosure/index.js.map +1 -0
- package/dist/components/disclosure-group/index.d.ts +61 -0
- package/dist/components/disclosure-group/index.js +100 -0
- package/dist/components/disclosure-group/index.js.map +1 -0
- package/dist/components/drop-zone/index.d.ts +113 -0
- package/dist/components/drop-zone/index.js +304 -0
- package/dist/components/drop-zone/index.js.map +1 -0
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/index.js +91 -76
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/form/index.d.ts +3 -2
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +4 -2
- package/dist/components/icon-button/index.js +204 -171
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/list/index.d.ts +15 -158
- package/dist/components/list/index.js +21 -1047
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +73 -0
- package/dist/components/list-box/index.js +82 -0
- package/dist/components/list-box/index.js.map +1 -0
- package/dist/components/loading-indicator/index.d.ts +32 -0
- package/dist/components/loading-indicator/index.js +174 -0
- package/dist/components/loading-indicator/index.js.map +1 -0
- package/dist/components/menu/index.d.ts +3 -3
- package/dist/components/menu/index.js +3 -3
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/navigation-tree/index.d.ts +117 -0
- package/dist/components/navigation-tree/index.js +135 -0
- package/dist/components/navigation-tree/index.js.map +1 -0
- package/dist/components/number-field/index.js +132 -143
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +69 -0
- package/dist/components/range-calendar/index.js +144 -0
- package/dist/components/range-calendar/index.js.map +1 -0
- package/dist/components/search-view/index.d.ts +79 -0
- package/dist/components/search-view/index.js +571 -0
- package/dist/components/search-view/index.js.map +1 -0
- package/dist/components/select/index.d.ts +152 -0
- package/dist/components/select/index.js +419 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/sheet/index.d.ts +16 -7
- package/dist/components/sheet/index.js +157 -152
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +111 -0
- package/dist/components/slider/index.js +673 -0
- package/dist/components/slider/index.js.map +1 -0
- package/dist/components/split-button/index.d.ts +77 -0
- package/dist/components/split-button/index.js +354 -0
- package/dist/components/split-button/index.js.map +1 -0
- package/dist/components/table/index.d.ts +391 -0
- package/dist/components/table/index.js +1708 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +196 -0
- package/dist/components/tabs/index.js +1137 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/time-field/index.d.ts +43 -0
- package/dist/components/time-field/index.js +107 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/time-picker/index.d.ts +65 -0
- package/dist/components/time-picker/index.js +1168 -0
- package/dist/components/time-picker/index.js.map +1 -0
- package/dist/components/token-field/index.d.ts +105 -0
- package/dist/components/token-field/index.js +574 -0
- package/dist/components/token-field/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +102 -0
- package/dist/components/tooltip/index.js +223 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tree/index.d.ts +112 -0
- package/dist/components/tree/index.js +157 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/disclosure/chevron.js +75 -0
- package/dist/disclosure/chevron.js.map +1 -0
- package/dist/disclosure/index.js +7 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/drop/index.d.ts +54 -0
- package/dist/drop/index.js +161 -0
- package/dist/drop/index.js.map +1 -0
- package/dist/field/chevron.js +74 -0
- package/dist/field/chevron.js.map +1 -0
- package/dist/field/index.d.ts +2 -1
- package/dist/field/index.js +359 -154
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +18 -1
- package/dist/field/styles.js.map +1 -1
- package/dist/files/index.d.ts +18 -0
- package/dist/files/index.js +107 -0
- package/dist/files/index.js.map +1 -0
- package/dist/form/index.d.ts +5 -2
- package/dist/form/index.js +64 -85
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/index.js +128 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +36 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1734 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +37 -3
- package/dist/index.js +36 -3
- package/dist/indicator/paths.js +23 -1
- package/dist/indicator/paths.js.map +1 -1
- package/dist/modal/index.js +92 -77
- package/dist/modal/index.js.map +1 -1
- package/dist/number/keyboard.js +16 -0
- package/dist/number/keyboard.js.map +1 -0
- package/dist/overlay/anchored.js +68 -38
- package/dist/overlay/anchored.js.map +1 -1
- package/dist/overlay/keyboard.js +57 -0
- package/dist/overlay/keyboard.js.map +1 -0
- package/dist/overlay/panel.js +173 -19
- package/dist/overlay/panel.js.map +1 -1
- package/dist/overlay/placement.js +13 -1
- package/dist/overlay/placement.js.map +1 -1
- package/dist/picker/index.js +322 -0
- package/dist/picker/index.js.map +1 -0
- package/dist/press/index.d.ts +2 -0
- package/dist/press/index.js +102 -100
- package/dist/press/index.js.map +1 -1
- package/dist/row/index.js +77 -69
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +13 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/field.js +277 -0
- package/dist/segments/field.js.map +1 -0
- package/dist/segments/index.js +574 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/styles.js +24 -0
- package/dist/segments/styles.js.map +1 -0
- package/dist/slider/index.js +145 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/swatch/index.js +56 -0
- package/dist/swatch/index.js.map +1 -0
- package/package.json +11 -2
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { useTheme } from "../../theme/scope.js";
|
|
2
|
+
import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
3
|
+
import { useTypeRole } from "../../typography/roles.js";
|
|
4
|
+
import { useLocaleOf } from "../../i18n/provider.js";
|
|
5
|
+
import { HIDDEN } from "../../glyphs/hidden.js";
|
|
6
|
+
import { ColorThumb } from "../../color-thumb/index.js";
|
|
7
|
+
import { ADJUSTABLE, adjustOf, lengthTo, seatPlaceOf, seats, useTrackGesture } from "../../slider/index.js";
|
|
8
|
+
import { usePickedColor } from "../../swatch/index.js";
|
|
9
|
+
import { Chequer } from "../../chequer/index.js";
|
|
10
|
+
import { c } from "react/compiler-runtime";
|
|
11
|
+
import { I18nManager, StyleSheet, Text, View } from "react-native";
|
|
12
|
+
import { useId, useState } from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
|
|
15
|
+
import { GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
|
|
16
|
+
import { useColorSliderState } from "react-stately/useColorSliderState";
|
|
17
|
+
//#region src/components/color-slider/index.tsx
|
|
18
|
+
const STRIP = 16;
|
|
19
|
+
const TARGET = 44;
|
|
20
|
+
const MARGIN = 14;
|
|
21
|
+
/** A vertical slider's height when the call site gives it none. */
|
|
22
|
+
const VERTICAL_HEIGHT = 240;
|
|
23
|
+
const HUES = [
|
|
24
|
+
0,
|
|
25
|
+
60,
|
|
26
|
+
120,
|
|
27
|
+
180,
|
|
28
|
+
240,
|
|
29
|
+
300,
|
|
30
|
+
360
|
|
31
|
+
];
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
area: { flexGrow: 1 },
|
|
34
|
+
output: { marginStart: "auto" },
|
|
35
|
+
root: { width: "100%" },
|
|
36
|
+
rootVertical: {
|
|
37
|
+
alignItems: "flex-start",
|
|
38
|
+
height: VERTICAL_HEIGHT
|
|
39
|
+
},
|
|
40
|
+
row: {
|
|
41
|
+
alignItems: "baseline",
|
|
42
|
+
flexDirection: "row"
|
|
43
|
+
},
|
|
44
|
+
strip: {
|
|
45
|
+
end: 0,
|
|
46
|
+
height: STRIP,
|
|
47
|
+
overflow: "hidden",
|
|
48
|
+
position: "absolute",
|
|
49
|
+
start: 0,
|
|
50
|
+
top: MARGIN
|
|
51
|
+
},
|
|
52
|
+
stripVertical: {
|
|
53
|
+
bottom: 0,
|
|
54
|
+
overflow: "hidden",
|
|
55
|
+
position: "absolute",
|
|
56
|
+
start: MARGIN,
|
|
57
|
+
top: 0,
|
|
58
|
+
width: STRIP
|
|
59
|
+
},
|
|
60
|
+
track: { height: TARGET },
|
|
61
|
+
trackVertical: {
|
|
62
|
+
flexGrow: 1,
|
|
63
|
+
minHeight: 0,
|
|
64
|
+
width: TARGET
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) => StyleSheet.create({
|
|
68
|
+
disabled: { opacity: stateLayerOpacity.disabledContent },
|
|
69
|
+
label: { color: colors.onSurfaceVariant },
|
|
70
|
+
output: { color: colors.onSurfaceVariant },
|
|
71
|
+
root: { gap: spacing.xs },
|
|
72
|
+
row: { gap: spacing.sm },
|
|
73
|
+
strip: { borderRadius: radii.sm }
|
|
74
|
+
}));
|
|
75
|
+
/**
|
|
76
|
+
* A slider over one channel of a colour: hue, saturation, lightness, alpha
|
|
77
|
+
* and the rest. Its state is React Stately's, as web's is: pass `value` with
|
|
78
|
+
* `onChange` to control it, or `defaultValue`, as a CSS colour string or a
|
|
79
|
+
* `Color` from `parseColor`, which this package re-exports. One of the two is
|
|
80
|
+
* required.
|
|
81
|
+
*
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <ColorSlider channel="hue" defaultValue="hsl(200, 100%, 50%)" label="Label" />
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* **`channel` has to name a channel the value's own space has.** A hex or
|
|
87
|
+
* `rgb()` value is read as RGB, which has no hue, so `channel="hue"` against
|
|
88
|
+
* one throws rather than converting. Pass `colorSpace="hsl"` to convert it,
|
|
89
|
+
* or give the value in the space you mean to slide.
|
|
90
|
+
*
|
|
91
|
+
* A press on the track moves the handle there, and a drag carries it. A
|
|
92
|
+
* screen reader hears an adjustable control named by the label, with the
|
|
93
|
+
* channel's value and the colour's name. `style`, `ref` and `testID` land on
|
|
94
|
+
* the slider as a whole, which is the view a layout positions. With a
|
|
95
|
+
* `testID`, the drag and the press are registered with Gesture Handler as
|
|
96
|
+
* `<testID>-pan` and `<testID>-tap`, which its `getByGestureTestId` finds in
|
|
97
|
+
* a test.
|
|
98
|
+
*
|
|
99
|
+
* Inside a `ColorPicker` it takes the picker's colour where it is given no
|
|
100
|
+
* `value`, and reports a change to the picker before its own `onChange`.
|
|
101
|
+
*/
|
|
102
|
+
function ColorSlider(t0) {
|
|
103
|
+
const $ = c(89);
|
|
104
|
+
const { "aria-label": ariaLabel, channel, colorSpace, defaultValue, isDisabled: t1, label, onChange, onChangeEnd, orientation: t2, ref, showValue: t3, style, testID, value } = t0;
|
|
105
|
+
const isDisabled = t1 === void 0 ? false : t1;
|
|
106
|
+
const orientation = t2 === void 0 ? "horizontal" : t2;
|
|
107
|
+
const showValue = t3 === void 0 ? true : t3;
|
|
108
|
+
const own = stylesOf(useTheme());
|
|
109
|
+
const locale = useLocaleOf(void 0);
|
|
110
|
+
const picked = usePickedColor(value, onChange);
|
|
111
|
+
let t4;
|
|
112
|
+
if ($[0] !== channel || $[1] !== colorSpace || $[2] !== defaultValue || $[3] !== isDisabled || $[4] !== locale || $[5] !== onChangeEnd || $[6] !== orientation || $[7] !== picked.onChange || $[8] !== picked.value) {
|
|
113
|
+
t4 = {
|
|
114
|
+
channel,
|
|
115
|
+
colorSpace,
|
|
116
|
+
defaultValue,
|
|
117
|
+
isDisabled,
|
|
118
|
+
locale,
|
|
119
|
+
onChange: picked.onChange,
|
|
120
|
+
onChangeEnd,
|
|
121
|
+
orientation,
|
|
122
|
+
value: picked.value
|
|
123
|
+
};
|
|
124
|
+
$[0] = channel;
|
|
125
|
+
$[1] = colorSpace;
|
|
126
|
+
$[2] = defaultValue;
|
|
127
|
+
$[3] = isDisabled;
|
|
128
|
+
$[4] = locale;
|
|
129
|
+
$[5] = onChangeEnd;
|
|
130
|
+
$[6] = orientation;
|
|
131
|
+
$[7] = picked.onChange;
|
|
132
|
+
$[8] = picked.value;
|
|
133
|
+
$[9] = t4;
|
|
134
|
+
} else t4 = $[9];
|
|
135
|
+
const state = useColorSliderState(t4);
|
|
136
|
+
const labelRole = useTypeRole("labelLarge");
|
|
137
|
+
const outputRole = useTypeRole("bodySmall");
|
|
138
|
+
const [length, setLength] = useState(0);
|
|
139
|
+
const vertical = orientation === "vertical";
|
|
140
|
+
let t5;
|
|
141
|
+
if ($[10] !== isDisabled || $[11] !== length || $[12] !== state || $[13] !== testID || $[14] !== vertical) {
|
|
142
|
+
t5 = {
|
|
143
|
+
isDisabled,
|
|
144
|
+
length,
|
|
145
|
+
state,
|
|
146
|
+
testID,
|
|
147
|
+
vertical
|
|
148
|
+
};
|
|
149
|
+
$[10] = isDisabled;
|
|
150
|
+
$[11] = length;
|
|
151
|
+
$[12] = state;
|
|
152
|
+
$[13] = testID;
|
|
153
|
+
$[14] = vertical;
|
|
154
|
+
$[15] = t5;
|
|
155
|
+
} else t5 = $[15];
|
|
156
|
+
const gesture = useTrackGesture(t5);
|
|
157
|
+
let t6;
|
|
158
|
+
if ($[16] !== state) {
|
|
159
|
+
t6 = state.getDisplayColor();
|
|
160
|
+
$[16] = state;
|
|
161
|
+
$[17] = t6;
|
|
162
|
+
} else t6 = $[17];
|
|
163
|
+
const display = t6;
|
|
164
|
+
const T0 = View;
|
|
165
|
+
const t7 = composeStyles(styles.root, vertical ? styles.rootVertical : void 0, own.root, style);
|
|
166
|
+
const t8 = label === void 0 && !showValue ? null : /* @__PURE__ */ jsxs(View, {
|
|
167
|
+
"aria-hidden": true,
|
|
168
|
+
style: composeStyles(styles.row, own.row),
|
|
169
|
+
children: [label === void 0 ? null : /* @__PURE__ */ jsx(Text, {
|
|
170
|
+
style: composeStyles(labelRole, own.label),
|
|
171
|
+
children: label
|
|
172
|
+
}), showValue ? /* @__PURE__ */ jsx(Text, {
|
|
173
|
+
style: composeStyles(outputRole, own.output, styles.output),
|
|
174
|
+
children: state.getThumbValueLabel(0)
|
|
175
|
+
}) : null]
|
|
176
|
+
});
|
|
177
|
+
const T1 = GestureHandlerRootView;
|
|
178
|
+
const t9 = vertical ? styles.trackVertical : styles.track;
|
|
179
|
+
const T2 = GestureDetector;
|
|
180
|
+
const T3 = View;
|
|
181
|
+
let t10;
|
|
182
|
+
if ($[18] !== vertical) {
|
|
183
|
+
t10 = lengthTo(setLength, vertical);
|
|
184
|
+
$[18] = vertical;
|
|
185
|
+
$[19] = t10;
|
|
186
|
+
} else t10 = $[19];
|
|
187
|
+
const t11 = composeStyles(styles.area, isDisabled ? own.disabled : void 0);
|
|
188
|
+
const T4 = View;
|
|
189
|
+
const t12 = composeStyles(vertical ? styles.stripVertical : styles.strip, own.strip);
|
|
190
|
+
let t13;
|
|
191
|
+
if ($[20] !== channel) {
|
|
192
|
+
t13 = channel === "alpha" ? /* @__PURE__ */ jsx(Chequer, {}) : null;
|
|
193
|
+
$[20] = channel;
|
|
194
|
+
$[21] = t13;
|
|
195
|
+
} else t13 = $[21];
|
|
196
|
+
let t14;
|
|
197
|
+
if ($[22] !== channel || $[23] !== state) {
|
|
198
|
+
t14 = stopsOf(state, channel);
|
|
199
|
+
$[22] = channel;
|
|
200
|
+
$[23] = state;
|
|
201
|
+
$[24] = t14;
|
|
202
|
+
} else t14 = $[24];
|
|
203
|
+
let t15;
|
|
204
|
+
if ($[25] !== t14 || $[26] !== vertical) {
|
|
205
|
+
t15 = /* @__PURE__ */ jsx(Gradient, {
|
|
206
|
+
stops: t14,
|
|
207
|
+
vertical
|
|
208
|
+
});
|
|
209
|
+
$[25] = t14;
|
|
210
|
+
$[26] = vertical;
|
|
211
|
+
$[27] = t15;
|
|
212
|
+
} else t15 = $[27];
|
|
213
|
+
let t16;
|
|
214
|
+
if ($[28] !== T4 || $[29] !== t12 || $[30] !== t13 || $[31] !== t15) {
|
|
215
|
+
t16 = /* @__PURE__ */ jsxs(T4, {
|
|
216
|
+
style: t12,
|
|
217
|
+
children: [t13, t15]
|
|
218
|
+
});
|
|
219
|
+
$[28] = T4;
|
|
220
|
+
$[29] = t12;
|
|
221
|
+
$[30] = t13;
|
|
222
|
+
$[31] = t15;
|
|
223
|
+
$[32] = t16;
|
|
224
|
+
} else t16 = $[32];
|
|
225
|
+
let t17;
|
|
226
|
+
if ($[33] !== ariaLabel || $[34] !== channel || $[35] !== label || $[36] !== locale || $[37] !== state.value) {
|
|
227
|
+
t17 = label ?? ariaLabel ?? state.value.getChannelName(channel, locale);
|
|
228
|
+
$[33] = ariaLabel;
|
|
229
|
+
$[34] = channel;
|
|
230
|
+
$[35] = label;
|
|
231
|
+
$[36] = locale;
|
|
232
|
+
$[37] = state.value;
|
|
233
|
+
$[38] = t17;
|
|
234
|
+
} else t17 = $[38];
|
|
235
|
+
let t18;
|
|
236
|
+
if ($[39] !== state) {
|
|
237
|
+
t18 = state.getThumbMaxValue(0);
|
|
238
|
+
$[39] = state;
|
|
239
|
+
$[40] = t18;
|
|
240
|
+
} else t18 = $[40];
|
|
241
|
+
let t19;
|
|
242
|
+
if ($[41] !== state) {
|
|
243
|
+
t19 = state.getThumbMinValue(0);
|
|
244
|
+
$[41] = state;
|
|
245
|
+
$[42] = t19;
|
|
246
|
+
} else t19 = $[42];
|
|
247
|
+
let t20;
|
|
248
|
+
if ($[43] !== state) {
|
|
249
|
+
t20 = state.getThumbValue(0);
|
|
250
|
+
$[43] = state;
|
|
251
|
+
$[44] = t20;
|
|
252
|
+
} else t20 = $[44];
|
|
253
|
+
let t21;
|
|
254
|
+
if ($[45] !== channel || $[46] !== locale || $[47] !== state) {
|
|
255
|
+
t21 = valueTextOf(state, channel, locale);
|
|
256
|
+
$[45] = channel;
|
|
257
|
+
$[46] = locale;
|
|
258
|
+
$[47] = state;
|
|
259
|
+
$[48] = t21;
|
|
260
|
+
} else t21 = $[48];
|
|
261
|
+
let t22;
|
|
262
|
+
if ($[49] !== state) {
|
|
263
|
+
t22 = adjustOf(state, 0);
|
|
264
|
+
$[49] = state;
|
|
265
|
+
$[50] = t22;
|
|
266
|
+
} else t22 = $[50];
|
|
267
|
+
const t23 = vertical ? seats.seatVertical : seats.seat;
|
|
268
|
+
let t24;
|
|
269
|
+
if ($[51] !== state || $[52] !== t23 || $[53] !== vertical) {
|
|
270
|
+
t24 = composeStyles(t23, seatPlaceOf(state.getThumbPercent(0), vertical));
|
|
271
|
+
$[51] = state;
|
|
272
|
+
$[52] = t23;
|
|
273
|
+
$[53] = vertical;
|
|
274
|
+
$[54] = t24;
|
|
275
|
+
} else t24 = $[54];
|
|
276
|
+
let t25;
|
|
277
|
+
if ($[55] !== display || $[56] !== state.isDragging) {
|
|
278
|
+
t25 = /* @__PURE__ */ jsx(ColorThumb, {
|
|
279
|
+
color: display,
|
|
280
|
+
dragging: state.isDragging
|
|
281
|
+
});
|
|
282
|
+
$[55] = display;
|
|
283
|
+
$[56] = state.isDragging;
|
|
284
|
+
$[57] = t25;
|
|
285
|
+
} else t25 = $[57];
|
|
286
|
+
let t26;
|
|
287
|
+
if ($[58] !== isDisabled || $[59] !== t17 || $[60] !== t18 || $[61] !== t19 || $[62] !== t20 || $[63] !== t21 || $[64] !== t22 || $[65] !== t24 || $[66] !== t25) {
|
|
288
|
+
t26 = /* @__PURE__ */ jsx(View, {
|
|
289
|
+
accessibilityActions: ADJUSTABLE,
|
|
290
|
+
accessible: true,
|
|
291
|
+
"aria-disabled": isDisabled,
|
|
292
|
+
"aria-label": t17,
|
|
293
|
+
"aria-valuemax": t18,
|
|
294
|
+
"aria-valuemin": t19,
|
|
295
|
+
"aria-valuenow": t20,
|
|
296
|
+
"aria-valuetext": t21,
|
|
297
|
+
onAccessibilityAction: t22,
|
|
298
|
+
role: "slider",
|
|
299
|
+
style: t24,
|
|
300
|
+
children: t25
|
|
301
|
+
});
|
|
302
|
+
$[58] = isDisabled;
|
|
303
|
+
$[59] = t17;
|
|
304
|
+
$[60] = t18;
|
|
305
|
+
$[61] = t19;
|
|
306
|
+
$[62] = t20;
|
|
307
|
+
$[63] = t21;
|
|
308
|
+
$[64] = t22;
|
|
309
|
+
$[65] = t24;
|
|
310
|
+
$[66] = t25;
|
|
311
|
+
$[67] = t26;
|
|
312
|
+
} else t26 = $[67];
|
|
313
|
+
let t27;
|
|
314
|
+
if ($[68] !== T3 || $[69] !== t10 || $[70] !== t11 || $[71] !== t16 || $[72] !== t26) {
|
|
315
|
+
t27 = /* @__PURE__ */ jsxs(T3, {
|
|
316
|
+
onLayout: t10,
|
|
317
|
+
style: t11,
|
|
318
|
+
children: [t16, t26]
|
|
319
|
+
});
|
|
320
|
+
$[68] = T3;
|
|
321
|
+
$[69] = t10;
|
|
322
|
+
$[70] = t11;
|
|
323
|
+
$[71] = t16;
|
|
324
|
+
$[72] = t26;
|
|
325
|
+
$[73] = t27;
|
|
326
|
+
} else t27 = $[73];
|
|
327
|
+
let t28;
|
|
328
|
+
if ($[74] !== T2 || $[75] !== gesture || $[76] !== t27) {
|
|
329
|
+
t28 = /* @__PURE__ */ jsx(T2, {
|
|
330
|
+
gesture,
|
|
331
|
+
children: t27
|
|
332
|
+
});
|
|
333
|
+
$[74] = T2;
|
|
334
|
+
$[75] = gesture;
|
|
335
|
+
$[76] = t27;
|
|
336
|
+
$[77] = t28;
|
|
337
|
+
} else t28 = $[77];
|
|
338
|
+
let t29;
|
|
339
|
+
if ($[78] !== T1 || $[79] !== t28 || $[80] !== t9) {
|
|
340
|
+
t29 = /* @__PURE__ */ jsx(T1, {
|
|
341
|
+
style: t9,
|
|
342
|
+
children: t28
|
|
343
|
+
});
|
|
344
|
+
$[78] = T1;
|
|
345
|
+
$[79] = t28;
|
|
346
|
+
$[80] = t9;
|
|
347
|
+
$[81] = t29;
|
|
348
|
+
} else t29 = $[81];
|
|
349
|
+
let t30;
|
|
350
|
+
if ($[82] !== T0 || $[83] !== ref || $[84] !== t29 || $[85] !== t7 || $[86] !== t8 || $[87] !== testID) {
|
|
351
|
+
t30 = /* @__PURE__ */ jsxs(T0, {
|
|
352
|
+
ref,
|
|
353
|
+
style: t7,
|
|
354
|
+
testID,
|
|
355
|
+
children: [t8, t29]
|
|
356
|
+
});
|
|
357
|
+
$[82] = T0;
|
|
358
|
+
$[83] = ref;
|
|
359
|
+
$[84] = t29;
|
|
360
|
+
$[85] = t7;
|
|
361
|
+
$[86] = t8;
|
|
362
|
+
$[87] = testID;
|
|
363
|
+
$[88] = t30;
|
|
364
|
+
} else t30 = $[88];
|
|
365
|
+
return t30;
|
|
366
|
+
}
|
|
367
|
+
function Gradient(t0) {
|
|
368
|
+
const $ = c(15);
|
|
369
|
+
const { stops, vertical } = t0;
|
|
370
|
+
const id = `channel${useId()}`;
|
|
371
|
+
const reversed = !vertical && I18nManager.isRTL;
|
|
372
|
+
const t1 = reversed ? 1 : 0;
|
|
373
|
+
const t2 = vertical || reversed ? 0 : 1;
|
|
374
|
+
const t3 = vertical ? 1 : 0;
|
|
375
|
+
let t4;
|
|
376
|
+
if ($[0] !== stops) {
|
|
377
|
+
let t5;
|
|
378
|
+
if ($[2] !== stops.length) {
|
|
379
|
+
t5 = (stop, index) => /* @__PURE__ */ jsx(Stop, {
|
|
380
|
+
offset: index / (stops.length - 1),
|
|
381
|
+
stopColor: stop.toFormat("rgb").withChannelValue("alpha", 1).toString("css"),
|
|
382
|
+
stopOpacity: stop.getChannelValue("alpha")
|
|
383
|
+
}, index);
|
|
384
|
+
$[2] = stops.length;
|
|
385
|
+
$[3] = t5;
|
|
386
|
+
} else t5 = $[3];
|
|
387
|
+
t4 = stops.map(t5);
|
|
388
|
+
$[0] = stops;
|
|
389
|
+
$[1] = t4;
|
|
390
|
+
} else t4 = $[1];
|
|
391
|
+
let t5;
|
|
392
|
+
if ($[4] !== id || $[5] !== t1 || $[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
|
|
393
|
+
t5 = /* @__PURE__ */ jsx(Defs, { children: /* @__PURE__ */ jsx(LinearGradient, {
|
|
394
|
+
id,
|
|
395
|
+
x1: t1,
|
|
396
|
+
x2: t2,
|
|
397
|
+
y1: t3,
|
|
398
|
+
y2: 0,
|
|
399
|
+
children: t4
|
|
400
|
+
}) });
|
|
401
|
+
$[4] = id;
|
|
402
|
+
$[5] = t1;
|
|
403
|
+
$[6] = t2;
|
|
404
|
+
$[7] = t3;
|
|
405
|
+
$[8] = t4;
|
|
406
|
+
$[9] = t5;
|
|
407
|
+
} else t5 = $[9];
|
|
408
|
+
const t6 = `url(#${id})`;
|
|
409
|
+
let t7;
|
|
410
|
+
if ($[10] !== t6) {
|
|
411
|
+
t7 = /* @__PURE__ */ jsx(Rect, {
|
|
412
|
+
fill: t6,
|
|
413
|
+
height: "100%",
|
|
414
|
+
width: "100%"
|
|
415
|
+
});
|
|
416
|
+
$[10] = t6;
|
|
417
|
+
$[11] = t7;
|
|
418
|
+
} else t7 = $[11];
|
|
419
|
+
let t8;
|
|
420
|
+
if ($[12] !== t5 || $[13] !== t7) {
|
|
421
|
+
t8 = /* @__PURE__ */ jsxs(Svg, {
|
|
422
|
+
...HIDDEN,
|
|
423
|
+
height: "100%",
|
|
424
|
+
style: StyleSheet.absoluteFill,
|
|
425
|
+
width: "100%",
|
|
426
|
+
children: [t5, t7]
|
|
427
|
+
});
|
|
428
|
+
$[12] = t5;
|
|
429
|
+
$[13] = t7;
|
|
430
|
+
$[14] = t8;
|
|
431
|
+
} else t8 = $[14];
|
|
432
|
+
return t8;
|
|
433
|
+
}
|
|
434
|
+
function stopsOf(state, channel) {
|
|
435
|
+
const display = state.getDisplayColor();
|
|
436
|
+
const min = state.getThumbMinValue(0);
|
|
437
|
+
const max = state.getThumbMaxValue(0);
|
|
438
|
+
if (channel === "hue") return HUES.map((hue) => display.withChannelValue("hue", hue));
|
|
439
|
+
if (channel === "lightness") return [
|
|
440
|
+
min,
|
|
441
|
+
(max - min) / 2,
|
|
442
|
+
max
|
|
443
|
+
].map((each) => display.withChannelValue(channel, each));
|
|
444
|
+
return [min, max].map((each) => display.withChannelValue(channel, each));
|
|
445
|
+
}
|
|
446
|
+
function valueTextOf(state, channel, locale) {
|
|
447
|
+
const words = state.getThumbValueLabel(0);
|
|
448
|
+
const display = state.getDisplayColor();
|
|
449
|
+
if (channel === "hue") return `${words}, ${display.getHueName(locale)}`;
|
|
450
|
+
if (channel === "alpha") return words;
|
|
451
|
+
return `${words}, ${display.getColorName(locale)}`;
|
|
452
|
+
}
|
|
453
|
+
//#endregion
|
|
454
|
+
export { ColorSlider };
|
|
455
|
+
|
|
456
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","Ref","StyleProp","TextStyle","ViewStyle","Color","ColorChannel","ColorSpace","ColorSliderState","useId","useState","I18nManager","Text","NativeText","StyleSheet","View","GestureDetector","GestureHandlerRootView","Svg","Defs","LinearGradient","Rect","Stop","useColorSliderState","Chequer","ColorThumb","HIDDEN","useLocaleOf","ADJUSTABLE","adjustOf","lengthTo","seatPlaceOf","seats","useTrackGesture","usePickedColor","useTheme","composeStyles","themedStyles","useTypeRole","ColorSliderProps","channel","colorSpace","defaultValue","isDisabled","label","onChange","value","onChangeEnd","orientation","ref","showValue","style","testID","STRIP","TARGET","MARGIN","VERTICAL_HEIGHT","HUES","styles","create","area","flexGrow","output","marginStart","root","width","rootVertical","alignItems","height","row","flexDirection","strip","end","overflow","position","start","top","stripVertical","bottom","track","trackVertical","minHeight","stylesOf","colors","radii","spacing","stateLayerOpacity","disabled","opacity","disabledContent","color","onSurfaceVariant","gap","xs","sm","borderRadius","ColorSlider","t0","$","_c","ariaLabel","t1","t2","t3","undefined","own","locale","picked","t4","state","labelRole","outputRole","length","setLength","vertical","t5","gesture","t6","getDisplayColor","display","T0","t7","t8","getThumbValueLabel","T1","t9","T2","T3","t10","t11","T4","t12","t13","t14","stopsOf","t15","t16","t17","getChannelName","t18","getThumbMaxValue","t19","getThumbMinValue","t20","getThumbValue","t21","valueTextOf","t22","t23","seatVertical","seat","t24","getThumbPercent","t25","isDragging","t26","t27","t28","t29","t30","Gradient","stops","id","reversed","isRTL","stop","index","toFormat","withChannelValue","toString","getChannelValue","map","absoluteFill","min","max","hue","each","words","getHueName","getColorName","_c","NativeText"],"sources":["../../../src/components/color-slider/index.tsx"],"sourcesContent":["import type { ComponentRef, Ref } from 'react'\nimport type { StyleProp, TextStyle, ViewStyle } from 'react-native'\nimport type { Color, ColorChannel, ColorSpace } from 'react-stately'\nimport type { ColorSliderState } from 'react-stately/useColorSliderState'\n\nimport { useId, useState } from 'react'\nimport { I18nManager, Text as NativeText, StyleSheet, View } from 'react-native'\nimport {\n GestureDetector,\n GestureHandlerRootView,\n} from 'react-native-gesture-handler'\nimport Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg'\nimport { useColorSliderState } from 'react-stately/useColorSliderState'\n\nimport { Chequer } from '../../chequer'\nimport { ColorThumb } from '../../color-thumb'\nimport { HIDDEN } from '../../glyphs/hidden'\nimport { useLocaleOf } from '../../i18n/provider'\nimport {\n ADJUSTABLE,\n adjustOf,\n lengthTo,\n seatPlaceOf,\n seats,\n useTrackGesture,\n} from '../../slider'\nimport { usePickedColor } from '../../swatch'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\n\n// kanso-ui's ColorSlider: the sliders page's track, carrying one channel of\n// a colour instead of an active and an inactive part. The page's 16dp strip\n// with its 8dp corner, centred in the 44dp a handle takes, and the same\n// label-large label above it, with the value at the far end of its line in\n// body-small in on surface variant, so it reads as a readout rather than a\n// second label. The gradient along the strip is React Aria's, stop for stop:\n// the channel's range through the colour, with the hue running through its\n// six primaries and lightness through the colour at its middle, so what runs\n// along the strip is the channel rather than anything chosen here.\n//\n// Three things depart from the page, each because a colour slider shows a\n// value the page's slider does not have, and each as web departs.\n//\n// **The handle is a circle carrying the colour, not the page's 4dp bar.** It\n// has to show the value it sits on, and 4dp of a colour is not a colour\n// anyone can read. It is the ringed handle in src/color-thumb, centred in the\n// page's 44dp.\n//\n// **There is no value indicator.** The page's label floats a number over the\n// handle; here the readout beside the label already says it, and the handle\n// itself shows the colour.\n//\n// **There is no stop at the inactive end**, since a channel has no inactive\n// part for it to mark.\n//\n// The alpha channel is the one drawn over a chequer, for the reason\n// src/chequer gives: a track fading to transparent over a light surface and\n// one fading to white are the same pixels without it. React Stately's display\n// colour is opaque on every other channel, so no other track shows one.\n//\n// Disabled, the strip and the handle fade and the label and the readout keep\n// their colour, since a disabled control still has to be readable.\n//\n// **The state is React Stately's `useColorSliderState`**, the one web's React\n// Aria keeps, and presses and drags work as they do on `Slider`, through the\n// same gesture in src/slider. The handle is an adjustable control to a screen\n// reader, named by the label, else `aria-label`, else the channel's name in\n// the provider's locale, as React Aria names it. Its value is the readout's\n// words with the hue's name after them on a hue track and the colour's name\n// on any other but alpha, \"200°, cyan blue\", as React Aria announces it.\n//\n// Vertical, the strip stands up 16dp across and the channel rises from the\n// bottom, 240dp tall until `style` says otherwise. Under a right-to-left\n// layout a horizontal channel runs from the right, as presses are read.\n\ntype ColorSliderProps = {\n /**\n * The slider's name for a screen reader, when no `label` is drawn. Left\n * out with the label too, the slider is named by its channel.\n */\n readonly 'aria-label'?: string\n /** Which channel of the colour the slider moves. */\n readonly channel: ColorChannel\n /**\n * The space the channel is read in, when the value is given in another: a\n * hex or `rgb()` value has no hue until it is read as `hsl` or `hsb`.\n */\n readonly colorSpace?: ColorSpace\n /**\n * The colour the slider starts at, when it keeps its own: a CSS colour\n * string, or a `Color` from `parseColor`.\n */\n readonly defaultValue?: Color | string\n /**\n * Draws the slider disabled, and takes no presses, drags or screen reader\n * actions.\n * @default false\n */\n readonly isDisabled?: boolean\n /** What the slider is for, drawn above the track. */\n readonly label?: string\n /** Called with the colour as the channel moves. */\n readonly onChange?: (value: Color) => void\n /** Called with the colour once a drag, a press or an action has ended. */\n readonly onChangeEnd?: (value: Color) => void\n /**\n * Along which axis the handle moves. A vertical slider is 240dp tall until\n * `style` says otherwise.\n * @default 'horizontal'\n */\n readonly orientation?: 'horizontal' | 'vertical'\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * Whether the channel's value is shown at the end of the label's line.\n * @default true\n */\n readonly showValue?: boolean\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n /** The colour, for a call site holding it itself with `onChange`. */\n readonly value?: Color | string\n}\n\n// The page's strip, and the room above and below it that makes up the 44dp\n// a press lands in.\nconst STRIP = 16\nconst TARGET = 44\nconst MARGIN = (TARGET - STRIP) / 2\n\n/** A vertical slider's height when the call site gives it none. */\nconst VERTICAL_HEIGHT = 240\n\n// The hues React Aria runs a hue track through.\nconst HUES = [0, 60, 120, 180, 240, 300, 360]\n\nconst styles = StyleSheet.create({\n // What a press is read along: the whole of the 44dp.\n area: {\n flexGrow: 1,\n },\n // The readout, at the far end of the label's line.\n output: {\n marginStart: 'auto',\n },\n // A slider fills the width it is given, as web's does.\n root: {\n width: '100%',\n },\n rootVertical: {\n alignItems: 'flex-start',\n height: VERTICAL_HEIGHT,\n },\n row: {\n alignItems: 'baseline',\n flexDirection: 'row',\n },\n // The strip, across the middle of the 44dp. It clips the gradient and the\n // chequer to its corners.\n strip: {\n end: 0,\n height: STRIP,\n overflow: 'hidden',\n position: 'absolute',\n start: 0,\n top: MARGIN,\n },\n stripVertical: {\n bottom: 0,\n overflow: 'hidden',\n position: 'absolute',\n start: MARGIN,\n top: 0,\n width: STRIP,\n },\n track: {\n height: TARGET,\n },\n trackVertical: {\n flexGrow: 1,\n minHeight: 0,\n width: TARGET,\n },\n})\n\nconst stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) =>\n StyleSheet.create({\n disabled: {\n opacity: stateLayerOpacity.disabledContent,\n },\n label: {\n color: colors.onSurfaceVariant,\n },\n output: {\n color: colors.onSurfaceVariant,\n },\n root: {\n gap: spacing.xs,\n },\n row: {\n gap: spacing.sm,\n },\n strip: {\n borderRadius: radii.sm,\n },\n }),\n)\n\n/**\n * A slider over one channel of a colour: hue, saturation, lightness, alpha\n * and the rest. Its state is React Stately's, as web's is: pass `value` with\n * `onChange` to control it, or `defaultValue`, as a CSS colour string or a\n * `Color` from `parseColor`, which this package re-exports. One of the two is\n * required.\n *\n * ```tsx\n * <ColorSlider channel=\"hue\" defaultValue=\"hsl(200, 100%, 50%)\" label=\"Label\" />\n * ```\n *\n * **`channel` has to name a channel the value's own space has.** A hex or\n * `rgb()` value is read as RGB, which has no hue, so `channel=\"hue\"` against\n * one throws rather than converting. Pass `colorSpace=\"hsl\"` to convert it,\n * or give the value in the space you mean to slide.\n *\n * A press on the track moves the handle there, and a drag carries it. A\n * screen reader hears an adjustable control named by the label, with the\n * channel's value and the colour's name. `style`, `ref` and `testID` land on\n * the slider as a whole, which is the view a layout positions. With a\n * `testID`, the drag and the press are registered with Gesture Handler as\n * `<testID>-pan` and `<testID>-tap`, which its `getByGestureTestId` finds in\n * a test.\n *\n * Inside a `ColorPicker` it takes the picker's colour where it is given no\n * `value`, and reports a change to the picker before its own `onChange`.\n */\nfunction ColorSlider({\n 'aria-label': ariaLabel,\n channel,\n colorSpace,\n defaultValue,\n isDisabled = false,\n label,\n onChange,\n onChangeEnd,\n orientation = 'horizontal',\n ref,\n showValue = true,\n style,\n testID,\n value,\n}: ColorSliderProps) {\n const own = stylesOf(useTheme())\n const locale = useLocaleOf(undefined)\n const picked = usePickedColor(value, onChange)\n const state = useColorSliderState({\n channel,\n colorSpace,\n defaultValue,\n isDisabled,\n locale,\n onChange: picked.onChange,\n onChangeEnd,\n orientation,\n value: picked.value,\n })\n const labelRole = useTypeRole('labelLarge')\n const outputRole = useTypeRole('bodySmall')\n const [length, setLength] = useState(0)\n const vertical = orientation === 'vertical'\n const gesture = useTrackGesture({\n isDisabled,\n length,\n state,\n testID,\n vertical,\n })\n const display = state.getDisplayColor()\n\n return (\n <View\n ref={ref}\n style={composeStyles<ViewStyle>(\n styles.root,\n vertical ? styles.rootVertical : undefined,\n own.root,\n style,\n )}\n testID={testID}\n >\n {label === undefined && !showValue ? null : (\n <View aria-hidden style={composeStyles<ViewStyle>(styles.row, own.row)}>\n {label === undefined ? null : (\n <NativeText style={composeStyles<TextStyle>(labelRole, own.label)}>\n {label}\n </NativeText>\n )}\n {showValue ? (\n <NativeText\n style={composeStyles<TextStyle>(\n outputRole,\n own.output,\n styles.output,\n )}\n >\n {state.getThumbValueLabel(0)}\n </NativeText>\n ) : null}\n </View>\n )}\n <GestureHandlerRootView\n style={vertical ? styles.trackVertical : styles.track}\n >\n <GestureDetector gesture={gesture}>\n <View\n onLayout={lengthTo(setLength, vertical)}\n style={composeStyles<ViewStyle>(\n styles.area,\n isDisabled ? own.disabled : undefined,\n )}\n >\n <View\n style={composeStyles<ViewStyle>(\n vertical ? styles.stripVertical : styles.strip,\n own.strip,\n )}\n >\n {channel === 'alpha' ? <Chequer /> : null}\n <Gradient stops={stopsOf(state, channel)} vertical={vertical} />\n </View>\n <View\n accessibilityActions={ADJUSTABLE}\n accessible\n aria-disabled={isDisabled}\n aria-label={\n label ??\n ariaLabel ??\n state.value.getChannelName(channel, locale)\n }\n aria-valuemax={state.getThumbMaxValue(0)}\n aria-valuemin={state.getThumbMinValue(0)}\n aria-valuenow={state.getThumbValue(0)}\n aria-valuetext={valueTextOf(state, channel, locale)}\n onAccessibilityAction={adjustOf(state, 0)}\n role=\"slider\"\n style={composeStyles<ViewStyle>(\n vertical ? seats.seatVertical : seats.seat,\n seatPlaceOf(state.getThumbPercent(0), vertical),\n )}\n >\n <ColorThumb color={display} dragging={state.isDragging} />\n </View>\n </View>\n </GestureDetector>\n </GestureHandlerRootView>\n </View>\n )\n}\n\n// The channel along the strip: the stops, evenly spaced, from the strip's\n// start, or from its bottom standing up. Each is drawn opaque at its own\n// opacity, since a gradient's stops take the two apart.\nfunction Gradient({\n stops,\n vertical,\n}: {\n readonly stops: readonly Color[]\n readonly vertical: boolean\n}) {\n // A gradient is found by its id, which has to be unique in the page under\n // React Native Web, as the chequer's pattern is.\n const id = `channel${useId()}`\n const reversed = !vertical && I18nManager.isRTL\n\n return (\n <Svg {...HIDDEN} height=\"100%\" style={StyleSheet.absoluteFill} width=\"100%\">\n <Defs>\n <LinearGradient\n id={id}\n x1={reversed ? 1 : 0}\n x2={vertical || reversed ? 0 : 1}\n y1={vertical ? 1 : 0}\n y2={0}\n >\n {stops.map((stop, index) => (\n <Stop\n // oxlint-disable-next-line react/no-array-index-key -- a stop's place is its identity\n key={index}\n offset={index / (stops.length - 1)}\n stopColor={stop\n .toFormat('rgb')\n .withChannelValue('alpha', 1)\n .toString('css')}\n stopOpacity={stop.getChannelValue('alpha')}\n />\n ))}\n </LinearGradient>\n </Defs>\n <Rect fill={`url(#${id})`} height=\"100%\" width=\"100%\" />\n </Svg>\n )\n}\n\n// React Aria's stops for a channel, from its useColorSlider: the hue through\n// its six primaries, lightness from its least through the colour at its\n// middle to its most, which is what keeps the hue showing at all, and every\n// other channel from its least to its most.\nfunction stopsOf(state: ColorSliderState, channel: ColorChannel): Color[] {\n const display = state.getDisplayColor()\n const min = state.getThumbMinValue(0)\n const max = state.getThumbMaxValue(0)\n\n if (channel === 'hue') {\n return HUES.map((hue) => display.withChannelValue('hue', hue))\n }\n if (channel === 'lightness') {\n return [min, (max - min) / 2, max].map((each) =>\n display.withChannelValue(channel, each),\n )\n }\n return [min, max].map((each) => display.withChannelValue(channel, each))\n}\n\n// What a screen reader hears the handle say, as React Aria writes it: the\n// readout's words, then the hue's name on a hue track and the colour's on any\n// other but alpha, whose readout is already all there is to say.\nfunction valueTextOf(\n state: ColorSliderState,\n channel: ColorChannel,\n locale: string,\n) {\n const words = state.getThumbValueLabel(0)\n const display = state.getDisplayColor()\n\n if (channel === 'hue') {\n return `${words}, ${display.getHueName(locale)}`\n }\n if (channel === 'alpha') {\n return words\n }\n return `${words}, ${display.getColorName(locale)}`\n}\n\nexport { ColorSlider }\nexport type { ColorSliderProps }\n"],"mappings":";;;;;;;;;;;;;;;;;AA8HA,MAAMqD,QAAQ;AACd,MAAMC,SAAS;AACf,MAAMC,SAAS;;AAGf,MAAMC,kBAAkB;AAGxB,MAAMC,OAAO;CAAC;CAAG;CAAI;CAAK;CAAK;CAAK;CAAK;AAAG;AAE5C,MAAM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MAAMuE,QAAQpE,MAAMc,mBAAmB,CAAC;CACxC,MAAMJ,UAAUV,MAAMS,gBAAgB;CAEtC,IAAI9E,YAAY,OACd,OAAO,GAAGyI,MAAK,IAAK1D,QAAQ2D,WAAWxE,MAAM;CAE/C,IAAIlE,YAAY,SACd,OAAOyI;CAET,OAAO,GAAGA,MAAK,IAAK1D,QAAQ4D,aAAazE,MAAM;AACjD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StyleProp, View, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { ComponentRef, Ref } from "react";
|
|
3
|
+
import { Color } from "react-stately";
|
|
4
|
+
//#region src/components/color-swatch/index.d.ts
|
|
5
|
+
type ColorSwatchProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
6
|
+
/**
|
|
7
|
+
* The colour to show: a CSS colour string, or a `Color` from `parseColor`,
|
|
8
|
+
* which this package re-exports. Left out, the swatch draws the colour of
|
|
9
|
+
* the `ColorSwatchPicker.Item` it is drawn in.
|
|
10
|
+
* @default the item's colour, else '#fff0'
|
|
11
|
+
*/
|
|
12
|
+
readonly color?: Color | string;
|
|
13
|
+
/**
|
|
14
|
+
* What the swatch is called, in place of the name the colour gives itself.
|
|
15
|
+
* A call site's `aria-label` follows either, after a comma.
|
|
16
|
+
*/
|
|
17
|
+
readonly colorName?: string;
|
|
18
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
19
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A colour shown as a value: a square of it, with a chequer behind so
|
|
23
|
+
* transparency reads as transparency. The colour is a CSS string, or a
|
|
24
|
+
* `Color` from `parseColor`, which this package re-exports.
|
|
25
|
+
*
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { ColorSwatch, parseColor } from '@kanso-labs/react-native-kanso-ui'
|
|
28
|
+
*
|
|
29
|
+
* <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* It names itself from the colour, "light vibrant cyan blue, 60%
|
|
33
|
+
* transparent", in the `I18nProvider`'s locale, or the device's outside one,
|
|
34
|
+
* so it needs no label. Pass `colorName` to say something else instead.
|
|
35
|
+
*
|
|
36
|
+
* `style`, `ref` and `testID` land on the square, and a `style` there applies
|
|
37
|
+
* over the swatch's own, so a call site sets another size with `width` and
|
|
38
|
+
* `height`. The colour fills whatever square it is given.
|
|
39
|
+
*
|
|
40
|
+
* Inside a `ColorPicker` it shows the picker's colour where it is given no
|
|
41
|
+
* `color` and sits in no `ColorSwatchPicker` item.
|
|
42
|
+
*/
|
|
43
|
+
declare function ColorSwatch({ 'aria-label': label, color, colorName, style, ...props }: ColorSwatchProps): import("react").JSX.Element;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ColorSwatch, type ColorSwatchProps };
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useTheme } from "../../theme/scope.js";
|
|
2
|
+
import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
3
|
+
import { useLocaleOf, useMessages } from "../../i18n/provider.js";
|
|
4
|
+
import { PickedColorContext, SwatchColorContext, colorNameOf, colorOf } from "../../swatch/index.js";
|
|
5
|
+
import { Chequer } from "../../chequer/index.js";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
7
|
+
import { StyleSheet, View } from "react-native";
|
|
8
|
+
import { use } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/color-swatch/index.tsx
|
|
11
|
+
const SIZE = 40;
|
|
12
|
+
const stylesOf = themedStyles(({ colors, radii }) => StyleSheet.create({
|
|
13
|
+
ground: {
|
|
14
|
+
borderRadius: radii.xs,
|
|
15
|
+
height: SIZE,
|
|
16
|
+
overflow: "hidden",
|
|
17
|
+
width: SIZE
|
|
18
|
+
},
|
|
19
|
+
hairline: {
|
|
20
|
+
...StyleSheet.absoluteFill,
|
|
21
|
+
borderColor: colors.outlineVariant,
|
|
22
|
+
borderRadius: radii.xs,
|
|
23
|
+
borderWidth: 1
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
/**
|
|
27
|
+
* A colour shown as a value: a square of it, with a chequer behind so
|
|
28
|
+
* transparency reads as transparency. The colour is a CSS string, or a
|
|
29
|
+
* `Color` from `parseColor`, which this package re-exports.
|
|
30
|
+
*
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import { ColorSwatch, parseColor } from '@kanso-labs/react-native-kanso-ui'
|
|
33
|
+
*
|
|
34
|
+
* <ColorSwatch color={parseColor('hsla(200, 100%, 50%, 0.4)')} />
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* It names itself from the colour, "light vibrant cyan blue, 60%
|
|
38
|
+
* transparent", in the `I18nProvider`'s locale, or the device's outside one,
|
|
39
|
+
* so it needs no label. Pass `colorName` to say something else instead.
|
|
40
|
+
*
|
|
41
|
+
* `style`, `ref` and `testID` land on the square, and a `style` there applies
|
|
42
|
+
* over the swatch's own, so a call site sets another size with `width` and
|
|
43
|
+
* `height`. The colour fills whatever square it is given.
|
|
44
|
+
*
|
|
45
|
+
* Inside a `ColorPicker` it shows the picker's colour where it is given no
|
|
46
|
+
* `color` and sits in no `ColorSwatchPicker` item.
|
|
47
|
+
*/
|
|
48
|
+
function ColorSwatch(t0) {
|
|
49
|
+
const $ = c(19);
|
|
50
|
+
let color;
|
|
51
|
+
let colorName;
|
|
52
|
+
let label;
|
|
53
|
+
let props;
|
|
54
|
+
let style;
|
|
55
|
+
if ($[0] !== t0) {
|
|
56
|
+
({"aria-label": label, color, colorName, style, ...props} = t0);
|
|
57
|
+
$[0] = t0;
|
|
58
|
+
$[1] = color;
|
|
59
|
+
$[2] = colorName;
|
|
60
|
+
$[3] = label;
|
|
61
|
+
$[4] = props;
|
|
62
|
+
$[5] = style;
|
|
63
|
+
} else {
|
|
64
|
+
color = $[1];
|
|
65
|
+
colorName = $[2];
|
|
66
|
+
label = $[3];
|
|
67
|
+
props = $[4];
|
|
68
|
+
style = $[5];
|
|
69
|
+
}
|
|
70
|
+
const styles = stylesOf(useTheme());
|
|
71
|
+
const locale = useLocaleOf(void 0);
|
|
72
|
+
const messages = useMessages();
|
|
73
|
+
const itemColor = use(SwatchColorContext);
|
|
74
|
+
const pickedColor = use(PickedColorContext)?.value;
|
|
75
|
+
const value = colorOf(color ?? itemColor ?? pickedColor ?? "#fff0");
|
|
76
|
+
const alpha = value.getChannelValue("alpha");
|
|
77
|
+
const name = colorName ?? colorNameOf(value, locale, messages.transparent);
|
|
78
|
+
const T0 = View;
|
|
79
|
+
const t1 = true;
|
|
80
|
+
const t2 = "img";
|
|
81
|
+
const t3 = [name, label].filter(Boolean).join(", ");
|
|
82
|
+
const t4 = composeStyles(styles.ground, style);
|
|
83
|
+
const t5 = alpha < 1 ? /* @__PURE__ */ jsx(Chequer, {}) : null;
|
|
84
|
+
const T1 = View;
|
|
85
|
+
const t6 = composeStyles(StyleSheet.absoluteFill, { backgroundColor: value.toString("css") });
|
|
86
|
+
let t7;
|
|
87
|
+
if ($[6] !== T1 || $[7] !== t6) {
|
|
88
|
+
t7 = /* @__PURE__ */ jsx(T1, { style: t6 });
|
|
89
|
+
$[6] = T1;
|
|
90
|
+
$[7] = t6;
|
|
91
|
+
$[8] = t7;
|
|
92
|
+
} else t7 = $[8];
|
|
93
|
+
let t8;
|
|
94
|
+
if ($[9] !== styles.hairline) {
|
|
95
|
+
t8 = /* @__PURE__ */ jsx(View, { style: styles.hairline });
|
|
96
|
+
$[9] = styles.hairline;
|
|
97
|
+
$[10] = t8;
|
|
98
|
+
} else t8 = $[10];
|
|
99
|
+
let t9;
|
|
100
|
+
if ($[11] !== T0 || $[12] !== props || $[13] !== t3 || $[14] !== t4 || $[15] !== t5 || $[16] !== t7 || $[17] !== t8) {
|
|
101
|
+
t9 = /* @__PURE__ */ jsxs(T0, {
|
|
102
|
+
accessible: t1,
|
|
103
|
+
role: t2,
|
|
104
|
+
...props,
|
|
105
|
+
"aria-label": t3,
|
|
106
|
+
style: t4,
|
|
107
|
+
children: [
|
|
108
|
+
t5,
|
|
109
|
+
t7,
|
|
110
|
+
t8
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
$[11] = T0;
|
|
114
|
+
$[12] = props;
|
|
115
|
+
$[13] = t3;
|
|
116
|
+
$[14] = t4;
|
|
117
|
+
$[15] = t5;
|
|
118
|
+
$[16] = t7;
|
|
119
|
+
$[17] = t8;
|
|
120
|
+
$[18] = t9;
|
|
121
|
+
} else t9 = $[18];
|
|
122
|
+
return t9;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { ColorSwatch };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=index.js.map
|