@kanso-labs/react-native-kanso-ui 0.9.0 → 0.10.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 +1331 -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/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/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/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/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 +78 -0
- package/dist/components/search-view/index.js +570 -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/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/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/tooltip/index.d.ts +101 -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 +310 -154
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +9 -0
- 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 +92 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +20 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1394 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +35 -3
- package/dist/index.js +34 -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,516 @@
|
|
|
1
|
+
import { useLocaleOf } from "../../i18n/provider.js";
|
|
2
|
+
import { useFieldValidation } from "../../form/index.js";
|
|
3
|
+
import { FieldBox, FieldInput, FieldMessage, describedBy, useFieldFocus } from "../../field/index.js";
|
|
4
|
+
import { colorOf, usePickedColor } from "../../swatch/index.js";
|
|
5
|
+
import { keyboardFor } from "../../number/keyboard.js";
|
|
6
|
+
import { useNumberFieldState } from "../../number/state.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { View } from "react-native";
|
|
9
|
+
import { useId, useImperativeHandle, useRef, useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { parseColor } from "react-stately";
|
|
12
|
+
import { useColorFieldState } from "react-stately/useColorFieldState";
|
|
13
|
+
//#region src/components/color-field/index.tsx
|
|
14
|
+
const BLACK = parseColor("#000");
|
|
15
|
+
function blurThen(onBlur, then) {
|
|
16
|
+
return (event) => {
|
|
17
|
+
onBlur();
|
|
18
|
+
then?.(event);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One channel of a colour as a number: the value converted into
|
|
23
|
+
* `colorSpace`, the channel read in its own format and range, and a
|
|
24
|
+
* committed number written back into the colour. React Stately's
|
|
25
|
+
* `useColorChannelFieldState`, over src/number's number field state.
|
|
26
|
+
*/
|
|
27
|
+
function ChannelField(t0) {
|
|
28
|
+
const $ = c(19);
|
|
29
|
+
let channel;
|
|
30
|
+
let colorSpace;
|
|
31
|
+
let defaultValue;
|
|
32
|
+
let onChange;
|
|
33
|
+
let props;
|
|
34
|
+
let value;
|
|
35
|
+
if ($[0] !== t0) {
|
|
36
|
+
({channel, colorSpace, defaultValue, onChange, value, ...props} = t0);
|
|
37
|
+
$[0] = t0;
|
|
38
|
+
$[1] = channel;
|
|
39
|
+
$[2] = colorSpace;
|
|
40
|
+
$[3] = defaultValue;
|
|
41
|
+
$[4] = onChange;
|
|
42
|
+
$[5] = props;
|
|
43
|
+
$[6] = value;
|
|
44
|
+
} else {
|
|
45
|
+
channel = $[1];
|
|
46
|
+
colorSpace = $[2];
|
|
47
|
+
defaultValue = $[3];
|
|
48
|
+
onChange = $[4];
|
|
49
|
+
props = $[5];
|
|
50
|
+
value = $[6];
|
|
51
|
+
}
|
|
52
|
+
const locale = useLocaleOf(void 0);
|
|
53
|
+
let t1;
|
|
54
|
+
if ($[7] !== defaultValue) {
|
|
55
|
+
t1 = () => colorOrNull(defaultValue);
|
|
56
|
+
$[7] = defaultValue;
|
|
57
|
+
$[8] = t1;
|
|
58
|
+
} else t1 = $[8];
|
|
59
|
+
const [own, setOwn] = useState(t1);
|
|
60
|
+
const controlled = value !== void 0;
|
|
61
|
+
const current = controlled ? colorOrNull(value) : own;
|
|
62
|
+
const color = inSpace(current ?? BLACK, colorSpace);
|
|
63
|
+
const range = color.getChannelRange(channel);
|
|
64
|
+
const formatOptions = color.getChannelFormatOptions(channel);
|
|
65
|
+
const multiplier = formatOptions.style === "percent" && range.maxValue === 100 ? 100 : 1;
|
|
66
|
+
const state = useNumberFieldState({
|
|
67
|
+
formatOptions,
|
|
68
|
+
locale,
|
|
69
|
+
maxValue: range.maxValue / multiplier,
|
|
70
|
+
minValue: range.minValue / multiplier,
|
|
71
|
+
onChange: (next) => {
|
|
72
|
+
const changed = Number.isNaN(next) ? null : color.withChannelValue(channel, next * multiplier);
|
|
73
|
+
if (!controlled) setOwn(changed);
|
|
74
|
+
onChange?.(changed);
|
|
75
|
+
},
|
|
76
|
+
step: range.step / multiplier,
|
|
77
|
+
value: current === null ? NaN : color.getChannelValue(channel) / multiplier
|
|
78
|
+
});
|
|
79
|
+
let t2;
|
|
80
|
+
if ($[9] !== state.numberValue) {
|
|
81
|
+
t2 = Number.isNaN(state.numberValue);
|
|
82
|
+
$[9] = state.numberValue;
|
|
83
|
+
$[10] = t2;
|
|
84
|
+
} else t2 = $[10];
|
|
85
|
+
const empty = t2;
|
|
86
|
+
const T0 = FieldShell;
|
|
87
|
+
const t3 = keyboardFor(locale, formatOptions, range.minValue);
|
|
88
|
+
const t4 = empty ? "" : String(state.numberValue);
|
|
89
|
+
let t5;
|
|
90
|
+
if ($[11] !== T0 || $[12] !== current || $[13] !== empty || $[14] !== props || $[15] !== state || $[16] !== t3 || $[17] !== t4) {
|
|
91
|
+
t5 = /* @__PURE__ */ jsx(T0, {
|
|
92
|
+
...props,
|
|
93
|
+
color: current,
|
|
94
|
+
isEmpty: empty,
|
|
95
|
+
keyboardType: t3,
|
|
96
|
+
state,
|
|
97
|
+
submitted: t4
|
|
98
|
+
});
|
|
99
|
+
$[11] = T0;
|
|
100
|
+
$[12] = current;
|
|
101
|
+
$[13] = empty;
|
|
102
|
+
$[14] = props;
|
|
103
|
+
$[15] = state;
|
|
104
|
+
$[16] = t3;
|
|
105
|
+
$[17] = t4;
|
|
106
|
+
$[18] = t5;
|
|
107
|
+
} else t5 = $[18];
|
|
108
|
+
return t5;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A colour typed into a field, the text fields page's filled or outlined
|
|
112
|
+
* field. Pass `value` with `onChange` to control it, or `defaultValue` to
|
|
113
|
+
* let it keep its own, as a CSS colour string or a `Color` from
|
|
114
|
+
* `parseColor`, which this package re-exports; `onChange` is handed the
|
|
115
|
+
* `Color`, `null` for an empty field.
|
|
116
|
+
*
|
|
117
|
+
* ```tsx
|
|
118
|
+
* <ColorField defaultValue="#6750A4" label="Label" />
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* Without `channel` the field holds the whole colour as hex and reads what
|
|
122
|
+
* is typed once it loses focus; with one it holds that channel alone as a
|
|
123
|
+
* number. `colorSpace` decides which space a channel belongs to, the same as
|
|
124
|
+
* on `ColorSlider`.
|
|
125
|
+
*
|
|
126
|
+
* React Native's own `TextInput` props, the return key among them, reach the
|
|
127
|
+
* control; `style` and `ref` are the field as a whole, and `inputRef` the
|
|
128
|
+
* control.
|
|
129
|
+
*
|
|
130
|
+
* Inside a `ColorPicker` it takes the picker's colour where it is given no
|
|
131
|
+
* `value`, and reports a change to the picker before its own `onChange`.
|
|
132
|
+
*/
|
|
133
|
+
function ColorField(t0) {
|
|
134
|
+
const $ = c(10);
|
|
135
|
+
let channel;
|
|
136
|
+
let onChange;
|
|
137
|
+
let props;
|
|
138
|
+
let value;
|
|
139
|
+
if ($[0] !== t0) {
|
|
140
|
+
({channel, onChange, value, ...props} = t0);
|
|
141
|
+
$[0] = t0;
|
|
142
|
+
$[1] = channel;
|
|
143
|
+
$[2] = onChange;
|
|
144
|
+
$[3] = props;
|
|
145
|
+
$[4] = value;
|
|
146
|
+
} else {
|
|
147
|
+
channel = $[1];
|
|
148
|
+
onChange = $[2];
|
|
149
|
+
props = $[3];
|
|
150
|
+
value = $[4];
|
|
151
|
+
}
|
|
152
|
+
const picked = usePickedColor(value, onChange);
|
|
153
|
+
let t1;
|
|
154
|
+
if ($[5] !== channel || $[6] !== picked.onChange || $[7] !== picked.value || $[8] !== props) {
|
|
155
|
+
t1 = channel === void 0 ? /* @__PURE__ */ jsx(HexField, {
|
|
156
|
+
...props,
|
|
157
|
+
onChange: picked.onChange,
|
|
158
|
+
value: picked.value
|
|
159
|
+
}) : /* @__PURE__ */ jsx(ChannelField, {
|
|
160
|
+
...props,
|
|
161
|
+
channel,
|
|
162
|
+
onChange: picked.onChange,
|
|
163
|
+
value: picked.value
|
|
164
|
+
});
|
|
165
|
+
$[5] = channel;
|
|
166
|
+
$[6] = picked.onChange;
|
|
167
|
+
$[7] = picked.value;
|
|
168
|
+
$[8] = props;
|
|
169
|
+
$[9] = t1;
|
|
170
|
+
} else t1 = $[9];
|
|
171
|
+
return t1;
|
|
172
|
+
}
|
|
173
|
+
function colorOrNull(color) {
|
|
174
|
+
return color === null || color === void 0 ? null : colorOf(color);
|
|
175
|
+
}
|
|
176
|
+
function commitBefore(state, handler) {
|
|
177
|
+
return (event) => {
|
|
178
|
+
state.commit();
|
|
179
|
+
handler?.(event);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function editInto(state, onEdit) {
|
|
183
|
+
return (text) => {
|
|
184
|
+
if (state.validate(text)) {
|
|
185
|
+
state.setInputValue(text);
|
|
186
|
+
onEdit();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The box either kind of field draws: the label, the control holding the
|
|
192
|
+
* text, the icons at its ends and the line under it.
|
|
193
|
+
*/
|
|
194
|
+
function FieldShell(t0) {
|
|
195
|
+
const $ = c(87);
|
|
196
|
+
let color;
|
|
197
|
+
let description;
|
|
198
|
+
let error;
|
|
199
|
+
let inputRef;
|
|
200
|
+
let isEmpty;
|
|
201
|
+
let keyboardType;
|
|
202
|
+
let label;
|
|
203
|
+
let leadingIcon;
|
|
204
|
+
let name;
|
|
205
|
+
let onBlur;
|
|
206
|
+
let onFocus;
|
|
207
|
+
let onSubmitEditing;
|
|
208
|
+
let props;
|
|
209
|
+
let ref;
|
|
210
|
+
let state;
|
|
211
|
+
let style;
|
|
212
|
+
let submitted;
|
|
213
|
+
let t1;
|
|
214
|
+
let t2;
|
|
215
|
+
let t3;
|
|
216
|
+
let t4;
|
|
217
|
+
let t5;
|
|
218
|
+
let t6;
|
|
219
|
+
let trailingIcon;
|
|
220
|
+
let validate;
|
|
221
|
+
if ($[0] !== t0) {
|
|
222
|
+
({color, description, error, floatingLabel: t1, inputRef, isDisabled: t2, isEmpty, isReadOnly: t3, isRequired: t4, keyboardType, label, leadingIcon, name, onBlur, onFocus, onSubmitEditing, ref, returnKeyType: t5, state, style, submitted, trailingIcon, validate, variant: t6, ...props} = t0);
|
|
223
|
+
$[0] = t0;
|
|
224
|
+
$[1] = color;
|
|
225
|
+
$[2] = description;
|
|
226
|
+
$[3] = error;
|
|
227
|
+
$[4] = inputRef;
|
|
228
|
+
$[5] = isEmpty;
|
|
229
|
+
$[6] = keyboardType;
|
|
230
|
+
$[7] = label;
|
|
231
|
+
$[8] = leadingIcon;
|
|
232
|
+
$[9] = name;
|
|
233
|
+
$[10] = onBlur;
|
|
234
|
+
$[11] = onFocus;
|
|
235
|
+
$[12] = onSubmitEditing;
|
|
236
|
+
$[13] = props;
|
|
237
|
+
$[14] = ref;
|
|
238
|
+
$[15] = state;
|
|
239
|
+
$[16] = style;
|
|
240
|
+
$[17] = submitted;
|
|
241
|
+
$[18] = t1;
|
|
242
|
+
$[19] = t2;
|
|
243
|
+
$[20] = t3;
|
|
244
|
+
$[21] = t4;
|
|
245
|
+
$[22] = t5;
|
|
246
|
+
$[23] = t6;
|
|
247
|
+
$[24] = trailingIcon;
|
|
248
|
+
$[25] = validate;
|
|
249
|
+
} else {
|
|
250
|
+
color = $[1];
|
|
251
|
+
description = $[2];
|
|
252
|
+
error = $[3];
|
|
253
|
+
inputRef = $[4];
|
|
254
|
+
isEmpty = $[5];
|
|
255
|
+
keyboardType = $[6];
|
|
256
|
+
label = $[7];
|
|
257
|
+
leadingIcon = $[8];
|
|
258
|
+
name = $[9];
|
|
259
|
+
onBlur = $[10];
|
|
260
|
+
onFocus = $[11];
|
|
261
|
+
onSubmitEditing = $[12];
|
|
262
|
+
props = $[13];
|
|
263
|
+
ref = $[14];
|
|
264
|
+
state = $[15];
|
|
265
|
+
style = $[16];
|
|
266
|
+
submitted = $[17];
|
|
267
|
+
t1 = $[18];
|
|
268
|
+
t2 = $[19];
|
|
269
|
+
t3 = $[20];
|
|
270
|
+
t4 = $[21];
|
|
271
|
+
t5 = $[22];
|
|
272
|
+
t6 = $[23];
|
|
273
|
+
trailingIcon = $[24];
|
|
274
|
+
validate = $[25];
|
|
275
|
+
}
|
|
276
|
+
const floatingLabel = t1 === void 0 ? true : t1;
|
|
277
|
+
const isDisabled = t2 === void 0 ? false : t2;
|
|
278
|
+
const isReadOnly = t3 === void 0 ? false : t3;
|
|
279
|
+
const isRequired = t4 === void 0 ? false : t4;
|
|
280
|
+
const returnKeyType = t5 === void 0 ? "done" : t5;
|
|
281
|
+
const variant = t6 === void 0 ? "filled" : t6;
|
|
282
|
+
const id = useId();
|
|
283
|
+
const control = useRef(null);
|
|
284
|
+
let t7;
|
|
285
|
+
if ($[26] !== color || $[27] !== error || $[28] !== isDisabled || $[29] !== isEmpty || $[30] !== isReadOnly || $[31] !== isRequired || $[32] !== name || $[33] !== submitted || $[34] !== validate) {
|
|
286
|
+
t7 = {
|
|
287
|
+
control,
|
|
288
|
+
error,
|
|
289
|
+
isDisabled,
|
|
290
|
+
isEmpty,
|
|
291
|
+
isReadOnly,
|
|
292
|
+
isRequired,
|
|
293
|
+
name,
|
|
294
|
+
submitted,
|
|
295
|
+
validate,
|
|
296
|
+
value: color
|
|
297
|
+
};
|
|
298
|
+
$[26] = color;
|
|
299
|
+
$[27] = error;
|
|
300
|
+
$[28] = isDisabled;
|
|
301
|
+
$[29] = isEmpty;
|
|
302
|
+
$[30] = isReadOnly;
|
|
303
|
+
$[31] = isRequired;
|
|
304
|
+
$[32] = name;
|
|
305
|
+
$[33] = submitted;
|
|
306
|
+
$[34] = validate;
|
|
307
|
+
$[35] = t7;
|
|
308
|
+
} else t7 = $[35];
|
|
309
|
+
const validation = useFieldValidation(t7);
|
|
310
|
+
const shownError = validation.error;
|
|
311
|
+
let t8;
|
|
312
|
+
if ($[36] !== onBlur || $[37] !== state || $[38] !== validation.onBlur) {
|
|
313
|
+
t8 = commitBefore(state, blurThen(validation.onBlur, onBlur));
|
|
314
|
+
$[36] = onBlur;
|
|
315
|
+
$[37] = state;
|
|
316
|
+
$[38] = validation.onBlur;
|
|
317
|
+
$[39] = t8;
|
|
318
|
+
} else t8 = $[39];
|
|
319
|
+
let t9;
|
|
320
|
+
if ($[40] !== onFocus || $[41] !== t8) {
|
|
321
|
+
t9 = {
|
|
322
|
+
onBlur: t8,
|
|
323
|
+
onFocus
|
|
324
|
+
};
|
|
325
|
+
$[40] = onFocus;
|
|
326
|
+
$[41] = t8;
|
|
327
|
+
$[42] = t9;
|
|
328
|
+
} else t9 = $[42];
|
|
329
|
+
const focus = useFieldFocus(t9);
|
|
330
|
+
let t10;
|
|
331
|
+
let t11;
|
|
332
|
+
if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
|
|
333
|
+
t10 = () => control.current;
|
|
334
|
+
t11 = [];
|
|
335
|
+
$[43] = t10;
|
|
336
|
+
$[44] = t11;
|
|
337
|
+
} else {
|
|
338
|
+
t10 = $[43];
|
|
339
|
+
t11 = $[44];
|
|
340
|
+
}
|
|
341
|
+
useImperativeHandle(inputRef, t10, t11);
|
|
342
|
+
const t12 = focus.focused;
|
|
343
|
+
const t13 = shownError !== void 0;
|
|
344
|
+
const t14 = state.inputValue !== "";
|
|
345
|
+
const t15 = focus.handlers;
|
|
346
|
+
let t16;
|
|
347
|
+
if ($[45] !== description || $[46] !== id || $[47] !== shownError) {
|
|
348
|
+
t16 = describedBy(id, {
|
|
349
|
+
description,
|
|
350
|
+
error: shownError
|
|
351
|
+
});
|
|
352
|
+
$[45] = description;
|
|
353
|
+
$[46] = id;
|
|
354
|
+
$[47] = shownError;
|
|
355
|
+
$[48] = t16;
|
|
356
|
+
} else t16 = $[48];
|
|
357
|
+
const t17 = !isDisabled && !isReadOnly;
|
|
358
|
+
let t18;
|
|
359
|
+
if ($[49] !== state || $[50] !== validation.onEdit) {
|
|
360
|
+
t18 = editInto(state, validation.onEdit);
|
|
361
|
+
$[49] = state;
|
|
362
|
+
$[50] = validation.onEdit;
|
|
363
|
+
$[51] = t18;
|
|
364
|
+
} else t18 = $[51];
|
|
365
|
+
let t19;
|
|
366
|
+
if ($[52] !== onSubmitEditing || $[53] !== state) {
|
|
367
|
+
t19 = commitBefore(state, onSubmitEditing);
|
|
368
|
+
$[52] = onSubmitEditing;
|
|
369
|
+
$[53] = state;
|
|
370
|
+
$[54] = t19;
|
|
371
|
+
} else t19 = $[54];
|
|
372
|
+
let t20;
|
|
373
|
+
if ($[55] !== focus.handlers || $[56] !== keyboardType || $[57] !== label || $[58] !== props || $[59] !== returnKeyType || $[60] !== state.inputValue || $[61] !== t16 || $[62] !== t17 || $[63] !== t18 || $[64] !== t19) {
|
|
374
|
+
t20 = /* @__PURE__ */ jsx(FieldInput, {
|
|
375
|
+
...props,
|
|
376
|
+
...t15,
|
|
377
|
+
"aria-label": label,
|
|
378
|
+
autoCapitalize: "none",
|
|
379
|
+
autoComplete: "off",
|
|
380
|
+
autoCorrect: false,
|
|
381
|
+
described: t16,
|
|
382
|
+
editable: t17,
|
|
383
|
+
keyboardType,
|
|
384
|
+
onChangeText: t18,
|
|
385
|
+
onSubmitEditing: t19,
|
|
386
|
+
ref: control,
|
|
387
|
+
returnKeyType,
|
|
388
|
+
spellCheck: false,
|
|
389
|
+
value: state.inputValue
|
|
390
|
+
});
|
|
391
|
+
$[55] = focus.handlers;
|
|
392
|
+
$[56] = keyboardType;
|
|
393
|
+
$[57] = label;
|
|
394
|
+
$[58] = props;
|
|
395
|
+
$[59] = returnKeyType;
|
|
396
|
+
$[60] = state.inputValue;
|
|
397
|
+
$[61] = t16;
|
|
398
|
+
$[62] = t17;
|
|
399
|
+
$[63] = t18;
|
|
400
|
+
$[64] = t19;
|
|
401
|
+
$[65] = t20;
|
|
402
|
+
} else t20 = $[65];
|
|
403
|
+
let t21;
|
|
404
|
+
if ($[66] !== floatingLabel || $[67] !== focus.focused || $[68] !== isDisabled || $[69] !== isRequired || $[70] !== label || $[71] !== leadingIcon || $[72] !== t13 || $[73] !== t14 || $[74] !== t20 || $[75] !== trailingIcon || $[76] !== variant) {
|
|
405
|
+
t21 = /* @__PURE__ */ jsx(FieldBox, {
|
|
406
|
+
control,
|
|
407
|
+
floatingLabel,
|
|
408
|
+
isDisabled,
|
|
409
|
+
isFocused: t12,
|
|
410
|
+
isInvalid: t13,
|
|
411
|
+
isPopulated: t14,
|
|
412
|
+
isRequired,
|
|
413
|
+
label,
|
|
414
|
+
leading: leadingIcon,
|
|
415
|
+
trailing: trailingIcon,
|
|
416
|
+
variant,
|
|
417
|
+
children: t20
|
|
418
|
+
});
|
|
419
|
+
$[66] = floatingLabel;
|
|
420
|
+
$[67] = focus.focused;
|
|
421
|
+
$[68] = isDisabled;
|
|
422
|
+
$[69] = isRequired;
|
|
423
|
+
$[70] = label;
|
|
424
|
+
$[71] = leadingIcon;
|
|
425
|
+
$[72] = t13;
|
|
426
|
+
$[73] = t14;
|
|
427
|
+
$[74] = t20;
|
|
428
|
+
$[75] = trailingIcon;
|
|
429
|
+
$[76] = variant;
|
|
430
|
+
$[77] = t21;
|
|
431
|
+
} else t21 = $[77];
|
|
432
|
+
let t22;
|
|
433
|
+
if ($[78] !== description || $[79] !== id || $[80] !== shownError) {
|
|
434
|
+
t22 = /* @__PURE__ */ jsx(FieldMessage, {
|
|
435
|
+
description,
|
|
436
|
+
error: shownError,
|
|
437
|
+
id
|
|
438
|
+
});
|
|
439
|
+
$[78] = description;
|
|
440
|
+
$[79] = id;
|
|
441
|
+
$[80] = shownError;
|
|
442
|
+
$[81] = t22;
|
|
443
|
+
} else t22 = $[81];
|
|
444
|
+
let t23;
|
|
445
|
+
if ($[82] !== ref || $[83] !== style || $[84] !== t21 || $[85] !== t22) {
|
|
446
|
+
t23 = /* @__PURE__ */ jsxs(View, {
|
|
447
|
+
ref,
|
|
448
|
+
style,
|
|
449
|
+
children: [t21, t22]
|
|
450
|
+
});
|
|
451
|
+
$[82] = ref;
|
|
452
|
+
$[83] = style;
|
|
453
|
+
$[84] = t21;
|
|
454
|
+
$[85] = t22;
|
|
455
|
+
$[86] = t23;
|
|
456
|
+
} else t23 = $[86];
|
|
457
|
+
return t23;
|
|
458
|
+
}
|
|
459
|
+
/** The whole colour as hex, through React Stately's colour field state. */
|
|
460
|
+
function HexField(t0) {
|
|
461
|
+
const $ = c(13);
|
|
462
|
+
let defaultValue;
|
|
463
|
+
let onChange;
|
|
464
|
+
let props;
|
|
465
|
+
let value;
|
|
466
|
+
if ($[0] !== t0) {
|
|
467
|
+
({defaultValue, onChange, value, ...props} = t0);
|
|
468
|
+
$[0] = t0;
|
|
469
|
+
$[1] = defaultValue;
|
|
470
|
+
$[2] = onChange;
|
|
471
|
+
$[3] = props;
|
|
472
|
+
$[4] = value;
|
|
473
|
+
} else {
|
|
474
|
+
defaultValue = $[1];
|
|
475
|
+
onChange = $[2];
|
|
476
|
+
props = $[3];
|
|
477
|
+
value = $[4];
|
|
478
|
+
}
|
|
479
|
+
let t1;
|
|
480
|
+
if ($[5] !== defaultValue || $[6] !== onChange || $[7] !== value) {
|
|
481
|
+
t1 = {
|
|
482
|
+
defaultValue,
|
|
483
|
+
onChange,
|
|
484
|
+
value
|
|
485
|
+
};
|
|
486
|
+
$[5] = defaultValue;
|
|
487
|
+
$[6] = onChange;
|
|
488
|
+
$[7] = value;
|
|
489
|
+
$[8] = t1;
|
|
490
|
+
} else t1 = $[8];
|
|
491
|
+
const state = useColorFieldState(t1);
|
|
492
|
+
const t2 = state.colorValue === null;
|
|
493
|
+
let t3;
|
|
494
|
+
if ($[9] !== props || $[10] !== state || $[11] !== t2) {
|
|
495
|
+
t3 = /* @__PURE__ */ jsx(FieldShell, {
|
|
496
|
+
...props,
|
|
497
|
+
color: state.colorValue,
|
|
498
|
+
isEmpty: t2,
|
|
499
|
+
keyboardType: "default",
|
|
500
|
+
state,
|
|
501
|
+
submitted: state.inputValue
|
|
502
|
+
});
|
|
503
|
+
$[9] = props;
|
|
504
|
+
$[10] = state;
|
|
505
|
+
$[11] = t2;
|
|
506
|
+
$[12] = t3;
|
|
507
|
+
} else t3 = $[12];
|
|
508
|
+
return t3;
|
|
509
|
+
}
|
|
510
|
+
function inSpace(color, space) {
|
|
511
|
+
return space === void 0 ? color : color.toFormat(space);
|
|
512
|
+
}
|
|
513
|
+
//#endregion
|
|
514
|
+
export { ColorField };
|
|
515
|
+
|
|
516
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","BlurEvent","KeyboardTypeOptions","StyleProp","TextInput","TextInputProps","TextInputSubmitEditingEvent","ViewStyle","Color","ColorChannel","ColorSpace","useId","useImperativeHandle","useRef","useState","View","parseColor","useColorFieldState","FieldVariant","ValidationResult","describedBy","FieldBox","FieldInput","FieldMessage","useFieldFocus","useFieldValidation","useLocaleOf","keyboardFor","useNumberFieldState","colorOf","usePickedColor","ColorFieldProps","Omit","channel","colorSpace","defaultValue","description","error","floatingLabel","inputRef","isDisabled","isReadOnly","isRequired","label","leadingIcon","name","onChange","value","ref","style","trailingIcon","validate","variant","FieldShellProps","color","isEmpty","keyboardType","state","TextState","submitted","commit","inputValue","setInputValue","BLACK","blurThen","onBlur","then","event","ChannelField","t0","$","_c","props","locale","undefined","t1","colorOrNull","own","setOwn","controlled","current","inSpace","range","getChannelRange","formatOptions","getChannelFormatOptions","multiplier","maxValue","minValue","next","changed","Number","isNaN","withChannelValue","step","NaN","getChannelValue","t2","numberValue","empty","T0","FieldShell","t3","t4","String","t5","ColorField","picked","commitBefore","handler","Event","editInto","onEdit","text","onFocus","onSubmitEditing","t6","returnKeyType","id","control","t7","validation","shownError","t8","t9","focus","t10","t11","Symbol","for","t12","focused","t13","t14","t15","handlers","t16","t17","t18","t19","t20","t21","t22","t23","HexField","colorValue","space","toFormat","_c"],"sources":["../../../src/components/color-field/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n BlurEvent,\n KeyboardTypeOptions,\n StyleProp,\n TextInput,\n TextInputProps,\n TextInputSubmitEditingEvent,\n ViewStyle,\n} from 'react-native'\nimport type { Color, ColorChannel, ColorSpace } from 'react-stately'\n\nimport { useId, useImperativeHandle, useRef, useState } from 'react'\nimport { View } from 'react-native'\nimport { parseColor } from 'react-stately'\nimport { useColorFieldState } from 'react-stately/useColorFieldState'\n\nimport type { FieldVariant } from '../../field'\nimport type { ValidationResult } from '../../form'\n\nimport {\n describedBy,\n FieldBox,\n FieldInput,\n FieldMessage,\n useFieldFocus,\n} from '../../field'\nimport { useFieldValidation } from '../../form'\nimport { useLocaleOf } from '../../i18n/provider'\nimport { keyboardFor } from '../../number/keyboard'\nimport { useNumberFieldState } from '../../number/state'\nimport { colorOf, usePickedColor } from '../../swatch'\n\n// kanso-ui's ColorField: a colour typed rather than picked, in the text\n// fields page's box with nothing added, drawn through the field chrome in\n// src/field as TextField is. That is what makes a colour field on a form the\n// same shape as the field beside it.\n//\n// **`channel` turns it from a colour into a number.** Without one the field\n// holds the whole colour as hex, `#6750A4`, through React Stately's\n// `useColorFieldState`, which web's reads through React Aria: a keystroke is\n// kept only where the text could still be hex, and the text is read when the\n// field loses focus or the return key is pressed, then written back as the\n// colour's hex, or put back where it reads as no colour. With one it holds\n// that channel alone, as React Stately's `useColorChannelFieldState` does: a\n// number in the channel's own format, `256°` or `34%`, kept and read as\n// NumberField's value is, in the `I18nProvider`'s locale, and clamped to the\n// channel's range and snapped to its step. That is what a picker's boxes\n// beside a plane are.\n//\n// **A swatch is the natural leading icon.** The field's value is a colour,\n// and the chrome already has a slot for something at the box's leading end;\n// a `ColorSwatch` there is what makes the field show the colour it holds. It\n// is left to the call site rather than drawn here, since a field inside a\n// picker sits beside a swatch already.\n//\n// The keyboard is the one that types what the field holds: the default one\n// for hex, with no capitals, corrections or suggestions, and for a channel\n// the number pad, or the decimal pad where the channel's format shows a\n// fraction, since no channel reaches below zero.\n\ntype ColorFieldProps = Omit<\n TextInputProps,\n | 'accessibilityHint'\n | 'accessibilityLabel'\n | 'aria-disabled'\n | 'aria-label'\n | 'autoCapitalize'\n | 'autoComplete'\n | 'autoCorrect'\n | 'children'\n | 'cursorColor'\n | 'defaultValue'\n | 'editable'\n | 'inputMode'\n | 'keyboardType'\n | 'maxLength'\n | 'multiline'\n | 'numberOfLines'\n | 'onChange'\n | 'onChangeText'\n | 'placeholder'\n | 'placeholderTextColor'\n | 'readOnly'\n | 'selectionColor'\n | 'spellCheck'\n | 'style'\n | 'underlineColorAndroid'\n | 'value'\n> & {\n /**\n * The one channel the field holds, as a number in that channel's format,\n * in place of the whole colour as hex.\n */\n readonly channel?: ColorChannel\n /**\n * The space `channel` is read in, the value converted into it first, as on\n * `ColorSlider`. Left out, `channel` is one of the value's own space.\n */\n readonly colorSpace?: ColorSpace\n /**\n * The colour the field opens with, when it keeps its own: a CSS colour\n * string, or a `Color` from `parseColor`, which this package re-exports.\n * `null` opens it empty.\n */\n readonly defaultValue?: Color | null | string\n /**\n * A hint shown under the field. Replaced by `error` when there is one, so\n * the two never stack.\n */\n readonly description?: string\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the field in its error state: the message, the error colours, and the\n * invalid state a screen reader reads all follow from it. The line under\n * the field arrives with the message, so the field grows when this does,\n * unless it is inside a `Form`, which keeps the line drawn. It wins over\n * what `validate` and the form say, and holds a `native` form back.\n */\n readonly error?: string\n /**\n * Whether the label sits in the empty box and floats to the top once the\n * field is focused or holds a value, as the text fields page draws it.\n * `false` keeps it small at the top in every state.\n * @default true\n */\n readonly floatingLabel?: boolean\n /**\n * A ref to the field's own `TextInput`, which is what a call site moves\n * focus to, after a server's error, say. `ref` is the field as a whole.\n */\n readonly inputRef?: Ref<ComponentRef<typeof TextInput>>\n /**\n * Draws the field disabled: it takes no focus and no input.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * Shows the value and takes focus, but takes no input.\n * @default false\n */\n readonly isReadOnly?: boolean\n /**\n * Marks the label with an asterisk, as the text fields page marks a field\n * that must be filled.\n * @default false\n */\n readonly isRequired?: boolean\n /**\n * What the field is for, and the name a screen reader reads for it.\n * Required, since a field with no label is a box nobody can name.\n */\n readonly label: string\n /**\n * An icon at the start of the box, before the label and the value, in the\n * page's 24dp slot. A `ColorSwatch` there shows the value.\n */\n readonly leadingIcon?: ReactNode\n /**\n * The name the value is submitted under by the `Form` around the field,\n * and the key its `validationErrors` reach the field by. The form submits\n * what web's does: the hex the field shows, or the channel's number written\n * out, such as `0.6`, and `''` for an empty field.\n */\n readonly name?: string\n /**\n * Called with the colour once it is read from what was typed: for a\n * channel, the value with that channel changed. `null` is an empty field.\n */\n readonly onChange?: (value: Color | null) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n /** Positions and sizes the field as a whole. */\n readonly style?: StyleProp<ViewStyle>\n /**\n * An icon at the end of the box, after the value, in the page's 24dp slot:\n * the muted role, and the error role while the field has an error.\n */\n readonly trailingIcon?: ReactNode\n /**\n * Checks the colour, `null` for an empty field, and returns its problem in\n * words, or several, where there is one, and `true`, `null` or `undefined`\n * where there is none. Under the default `aria` validation the error shows\n * as the value changes; inside a `native` form it shows once a submission\n * is tried, or once the field loses focus after an edit, and holds the form\n * back.\n */\n readonly validate?: (value: Color | null) => ValidationResult\n /**\n * The colour, when the call site keeps it: a CSS colour string or a\n * `Color`. `null` is an empty field.\n */\n readonly value?: Color | null | string\n /**\n * The filled box, or the outlined one: no fill, an outline that thickens\n * and takes the primary role while focused, and the label cutting it once\n * it floats, the text fields page's two fields.\n * @default 'filled'\n */\n readonly variant?: FieldVariant\n}\n\n// What the box draws from either kind of field: the colour it is validated\n// on, what it submits, and the text it holds and how that text is kept.\ntype FieldShellProps = Omit<\n ColorFieldProps,\n 'channel' | 'colorSpace' | 'defaultValue' | 'onChange' | 'value'\n> & {\n readonly color: Color | null\n readonly isEmpty: boolean\n readonly keyboardType: KeyboardTypeOptions\n readonly state: TextState\n readonly submitted: string\n}\n\n// The text a field holds, which React Stately's colour field state and\n// src/number's number field state both keep.\ntype TextState = {\n /** Reads the text as the value and writes it back. */\n readonly commit: () => void\n readonly inputValue: string\n readonly setInputValue: (value: string) => void\n /** Whether the text could still become a value, as it is typed. */\n readonly validate: (value: string) => boolean\n}\n\n// What a channel field holds while it holds no colour: React Stately's.\nconst BLACK = parseColor('#000')\n\n// The field's own blur handling, then the call site's.\nfunction blurThen(\n onBlur: () => void,\n then: ((event: BlurEvent) => void) | undefined,\n) {\n return (event: BlurEvent) => {\n onBlur()\n then?.(event)\n }\n}\n\n/**\n * One channel of a colour as a number: the value converted into\n * `colorSpace`, the channel read in its own format and range, and a\n * committed number written back into the colour. React Stately's\n * `useColorChannelFieldState`, over src/number's number field state.\n */\nfunction ChannelField({\n channel,\n colorSpace,\n defaultValue,\n onChange,\n value,\n ...props\n}: Omit<ColorFieldProps, 'channel'> & { readonly channel: ColorChannel }) {\n const locale = useLocaleOf(undefined)\n const [own, setOwn] = useState(() => colorOrNull(defaultValue))\n const controlled = value !== undefined\n const current = controlled ? colorOrNull(value) : own\n const color = inSpace(current ?? BLACK, colorSpace)\n const range = color.getChannelRange(channel)\n const formatOptions = color.getChannelFormatOptions(channel)\n // A percentage of a channel running to 100 is read as a fraction, so 34\n // is written 34%.\n const multiplier =\n formatOptions.style === 'percent' && range.maxValue === 100 ? 100 : 1\n const state = useNumberFieldState({\n formatOptions,\n locale,\n maxValue: range.maxValue / multiplier,\n minValue: range.minValue / multiplier,\n onChange: (next) => {\n const changed = Number.isNaN(next)\n ? null\n : color.withChannelValue(channel, next * multiplier)\n if (!controlled) {\n setOwn(changed)\n }\n onChange?.(changed)\n },\n step: range.step / multiplier,\n value:\n current === null\n ? Number.NaN\n : color.getChannelValue(channel) / multiplier,\n })\n const empty = Number.isNaN(state.numberValue)\n\n return (\n <FieldShell\n {...props}\n color={current}\n isEmpty={empty}\n keyboardType={keyboardFor(locale, formatOptions, range.minValue)}\n state={state}\n submitted={empty ? '' : String(state.numberValue)}\n />\n )\n}\n\n/**\n * A colour typed into a field, the text fields page's filled or outlined\n * field. Pass `value` with `onChange` to control it, or `defaultValue` to\n * let it keep its own, as a CSS colour string or a `Color` from\n * `parseColor`, which this package re-exports; `onChange` is handed the\n * `Color`, `null` for an empty field.\n *\n * ```tsx\n * <ColorField defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * Without `channel` the field holds the whole colour as hex and reads what\n * is typed once it loses focus; with one it holds that channel alone as a\n * number. `colorSpace` decides which space a channel belongs to, the same as\n * on `ColorSlider`.\n *\n * React Native's own `TextInput` props, the return key among them, reach the\n * control; `style` and `ref` are the field as a whole, and `inputRef` the\n * control.\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 ColorField({ channel, onChange, value, ...props }: ColorFieldProps) {\n const picked = usePickedColor(value, onChange)\n\n return channel === undefined ? (\n <HexField {...props} onChange={picked.onChange} value={picked.value} />\n ) : (\n <ChannelField\n {...props}\n channel={channel}\n onChange={picked.onChange}\n value={picked.value}\n />\n )\n}\n\nfunction colorOrNull(color: Color | null | string | undefined) {\n return color === null || color === undefined ? null : colorOf(color)\n}\n\n// Reads the text as the field's value, then hands the event on.\nfunction commitBefore<Event>(\n state: TextState,\n handler: ((event: Event) => void) | undefined,\n) {\n return (event: Event) => {\n state.commit()\n handler?.(event)\n }\n}\n\n// The text typed, kept only where it could still become a value, and\n// reported to the field's validation as an edit.\nfunction editInto(state: TextState, onEdit: () => void) {\n return (text: string) => {\n if (state.validate(text)) {\n state.setInputValue(text)\n onEdit()\n }\n }\n}\n\n/**\n * The box either kind of field draws: the label, the control holding the\n * text, the icons at its ends and the line under it.\n */\nfunction FieldShell({\n color,\n description,\n error,\n floatingLabel = true,\n inputRef,\n isDisabled = false,\n isEmpty,\n isReadOnly = false,\n isRequired = false,\n keyboardType,\n label,\n leadingIcon,\n name,\n onBlur,\n onFocus,\n onSubmitEditing,\n ref,\n returnKeyType = 'done',\n state,\n style,\n submitted,\n trailingIcon,\n validate,\n variant = 'filled',\n ...props\n}: FieldShellProps) {\n const id = useId()\n const control = useRef<ComponentRef<typeof TextInput>>(null)\n const validation = useFieldValidation({\n control,\n error,\n isDisabled,\n isEmpty,\n isReadOnly,\n isRequired,\n name,\n submitted,\n validate,\n value: color,\n })\n const shownError = validation.error\n const focus = useFieldFocus({\n onBlur: commitBefore<BlurEvent>(state, blurThen(validation.onBlur, onBlur)),\n onFocus,\n })\n\n useImperativeHandle<\n ComponentRef<typeof TextInput> | null,\n ComponentRef<typeof TextInput> | null\n >(inputRef, () => control.current, [])\n\n return (\n <View ref={ref} style={style}>\n <FieldBox\n control={control}\n floatingLabel={floatingLabel}\n isDisabled={isDisabled}\n isFocused={focus.focused}\n isInvalid={shownError !== undefined}\n isPopulated={state.inputValue !== ''}\n isRequired={isRequired}\n label={label}\n leading={leadingIcon}\n trailing={trailingIcon}\n variant={variant}\n >\n <FieldInput\n {...props}\n {...focus.handlers}\n aria-label={label}\n autoCapitalize=\"none\"\n autoComplete=\"off\"\n autoCorrect={false}\n described={describedBy(id, { description, error: shownError })}\n editable={!isDisabled && !isReadOnly}\n keyboardType={keyboardType}\n onChangeText={editInto(state, validation.onEdit)}\n onSubmitEditing={commitBefore<TextInputSubmitEditingEvent>(\n state,\n onSubmitEditing,\n )}\n ref={control}\n returnKeyType={returnKeyType}\n spellCheck={false}\n value={state.inputValue}\n />\n </FieldBox>\n <FieldMessage description={description} error={shownError} id={id} />\n </View>\n )\n}\n\n/** The whole colour as hex, through React Stately's colour field state. */\nfunction HexField({\n defaultValue,\n onChange,\n value,\n ...props\n}: Omit<ColorFieldProps, 'channel'>) {\n const state = useColorFieldState({ defaultValue, onChange, value })\n\n return (\n <FieldShell\n {...props}\n color={state.colorValue}\n isEmpty={state.colorValue === null}\n keyboardType=\"default\"\n state={state}\n submitted={state.inputValue}\n />\n )\n}\n\nfunction inSpace(color: Color, space: ColorSpace | undefined) {\n return space === undefined ? color : color.toFormat(space)\n}\n\nexport { ColorField }\nexport type { ColorFieldProps }\n"],"mappings":";;;;;;;;;;;;;AAkOA,MA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AAnC,gBAAAmC,EAAA,OAAAxB,YAAAwB,EAAA,OAAAvB,OAAA;EACA4B,KAAA;GAAAxC;GAAAW;GAAAC;EAAgC;EAACuB,EAAA,KAAAnC;EAAAmC,EAAA,KAAAxB;EAAAwB,EAAA,KAAAvB;EAAAuB,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAlE,MAAAb,QAAcxC,mBAAmB0D,EAAiC;CAMrD,MAAAsB,KAAAxC,MAAKwF,eAAgB;CAAI,IAAA3C;CAAA,IAAAhC,EAAA,OAAAE,SAAAF,EAAA,QAAAb,SAAAa,EAAA,QAAA2B,IAAA;EAHpCK,KAAA,oBAAC,YAAD;GAAW,GACL9B;GACG,OAAAf,MAAKwF;GACH,SAAAhD;GACI,cAAA;GACNxC;GACI,WAAAA,MAAKI;EAAW,CAAA;EAC3BS,EAAA,KAAAE;EAAAF,EAAA,MAAAb;EAAAa,EAAA,MAAA2B;EAAA3B,EAAA,MAAAgC;CAAA,OAAAA,KAAAhC,EAAA;CAAA,OAPFgC;AAOE;AAIN,SAASrB,QAAQ3B,OAAc4F,OAA+B;CAC5D,OAAOA,UAAUxE,KAAAA,IAAYpB,QAAQA,MAAM6F,SAASD,KAAK;AAC3D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { StyleProp, View, ViewStyle } from "react-native";
|
|
2
|
+
import { ComponentRef, ReactNode, Ref } from "react";
|
|
3
|
+
import { Color } from "react-stately";
|
|
4
|
+
//#region src/components/color-picker/index.d.ts
|
|
5
|
+
type ColorPickerProps = {
|
|
6
|
+
/** Whether the alpha slider is drawn under the hue one. @default false */
|
|
7
|
+
readonly alpha?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Replaces everything on the surface, for a picker that arranges its own
|
|
10
|
+
* parts. The colour controls in it take the picker's value.
|
|
11
|
+
*/
|
|
12
|
+
readonly children?: ReactNode;
|
|
13
|
+
/** Whether the surface starts open, when the picker keeps its own open state. */
|
|
14
|
+
readonly defaultOpen?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The colour the picker holds at first, when it keeps its own: a CSS colour
|
|
17
|
+
* string, or a `Color` from `parseColor`.
|
|
18
|
+
* @default '#000000'
|
|
19
|
+
*/
|
|
20
|
+
readonly defaultValue?: Color | string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the whole picker is inert: the trigger, and the plane, sliders
|
|
23
|
+
* and field on the surface, which can be on screen while disabled since
|
|
24
|
+
* the surface opens independently of the trigger. An arrangement passed as
|
|
25
|
+
* `children` is the call site's own to disable.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
readonly isDisabled?: boolean;
|
|
29
|
+
/** Whether the surface is open, for a call site holding it with `onOpenChange`. */
|
|
30
|
+
readonly isOpen?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* What the trigger says beside its swatch. Required: it is the button's
|
|
33
|
+
* name, the surface's and the field's.
|
|
34
|
+
*/
|
|
35
|
+
readonly label: string;
|
|
36
|
+
/** Called with the colour each time a control on the surface changes it. */
|
|
37
|
+
readonly onChange?: (value: Color) => void;
|
|
38
|
+
/** Called when the surface opens or closes. */
|
|
39
|
+
readonly onOpenChange?: (isOpen: boolean) => void;
|
|
40
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
41
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
42
|
+
readonly testID?: string;
|
|
43
|
+
/** The colour, for a call site holding it itself with `onChange`. */
|
|
44
|
+
readonly value?: Color | string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A colour picked from a plane, a hue slider and a hex field, behind a
|
|
48
|
+
* trigger showing the colour. Pass `value` with `onChange` to control it, or
|
|
49
|
+
* `defaultValue`, as a CSS colour string or a `Color` from `parseColor`,
|
|
50
|
+
* which this package re-exports.
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <ColorPicker defaultValue="#6750A4" label="Label" />
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* `alpha` adds the transparency slider. From the medium window size up the
|
|
57
|
+
* surface is docked under the trigger; below it, it opens centred over a
|
|
58
|
+
* scrim, as a date picker's does. `defaultOpen`, `isOpen` and `onOpenChange`
|
|
59
|
+
* reach the surface.
|
|
60
|
+
*
|
|
61
|
+
* Every part on the surface is this package's own, `ColorArea`,
|
|
62
|
+
* `ColorSlider` and `ColorField`, and they share the picker's value rather
|
|
63
|
+
* than taking it as props. Passing `children` replaces all of them, and a
|
|
64
|
+
* `ColorArea`, `ColorField`, `ColorSlider`, `ColorSwatch`,
|
|
65
|
+
* `ColorSwatchPicker` or `ColorWheel` among them takes the picker's value
|
|
66
|
+
* where it is given none of its own.
|
|
67
|
+
*
|
|
68
|
+
* `style`, `ref` and `testID` land on the trigger, which is what a layout
|
|
69
|
+
* places.
|
|
70
|
+
*/
|
|
71
|
+
declare function ColorPicker({ alpha, children, defaultOpen, defaultValue, isDisabled, isOpen, label, onChange, onOpenChange, ref, style, testID, value }: ColorPickerProps): import("react").JSX.Element;
|
|
72
|
+
//#endregion
|
|
73
|
+
export { ColorPicker, type ColorPickerProps };
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|