@kanso-labs/react-native-kanso-ui 0.7.0 → 0.9.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 +37 -0
- package/dist/badge/index.js +9 -68
- package/dist/badge/index.js.map +1 -1
- package/dist/button/index.d.ts +2 -1
- package/dist/button/index.js +1 -1
- package/dist/button/index.js.map +1 -1
- package/dist/button/palettes.d.ts +2 -0
- package/dist/button/pending.js +17 -21
- package/dist/button/pending.js.map +1 -1
- package/dist/calendar/index.js +1 -1
- package/dist/components/autocomplete/index.js +28 -26
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/avatar/index.js +2 -2
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/index.d.ts +48 -0
- package/dist/components/badge/index.js +122 -0
- package/dist/components/badge/index.js.map +1 -0
- package/dist/{badge → components/badge}/styles.js +10 -6
- package/dist/components/badge/styles.js.map +1 -0
- package/dist/components/breadcrumbs/index.d.ts +66 -0
- package/dist/components/breadcrumbs/index.js +285 -0
- package/dist/components/breadcrumbs/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +1 -1
- package/dist/components/calendar/index.js +77 -38
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +7 -1
- package/dist/components/checkbox/index.js +183 -138
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.d.ts +93 -0
- package/dist/components/checkbox-group/index.js +306 -0
- package/dist/components/checkbox-group/index.js.map +1 -0
- package/dist/components/chip-group/index.d.ts +4 -3
- package/dist/components/chip-group/index.js +47 -45
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/code/index.d.ts +25 -0
- package/dist/components/code/index.js +87 -0
- package/dist/components/code/index.js.map +1 -0
- package/dist/components/container/index.d.ts +47 -0
- package/dist/components/container/index.js +85 -0
- package/dist/components/container/index.js.map +1 -0
- package/dist/components/copy-field/index.d.ts +5 -5
- package/dist/components/copy-field/index.js +30 -28
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/currency/index.d.ts +2 -2
- package/dist/components/currency/index.js +3 -1
- package/dist/components/currency/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +80 -0
- package/dist/components/fab/index.js +231 -0
- package/dist/components/fab/index.js.map +1 -0
- package/dist/components/fab-menu/index.d.ts +120 -0
- package/dist/components/fab-menu/index.js +640 -0
- package/dist/components/fab-menu/index.js.map +1 -0
- package/dist/components/feed/index.d.ts +57 -0
- package/dist/components/feed/index.js +167 -0
- package/dist/components/feed/index.js.map +1 -0
- package/dist/components/keycap/index.d.ts +27 -0
- package/dist/components/keycap/index.js +136 -0
- package/dist/components/keycap/index.js.map +1 -0
- package/dist/components/list/index.d.ts +6 -5
- package/dist/components/list/index.js +97 -106
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +4 -3
- package/dist/components/menu/index.js +33 -40
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +2 -1
- package/dist/components/meter/index.js +9 -7
- package/dist/components/meter/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +7 -3
- package/dist/components/number-field/index.js +214 -192
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/product-icon/index.d.ts +2 -2
- package/dist/components/product-icon/index.js +2 -2
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +2 -1
- package/dist/components/progress-indicator/index.js +15 -13
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +3 -3
- package/dist/components/search-field/index.js +105 -104
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/separator/index.d.ts +3 -2
- package/dist/components/separator/index.js +29 -26
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.d.ts +2 -2
- package/dist/components/sheet/index.js +22 -26
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +3 -3
- package/dist/components/snackbar/index.js +36 -34
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/supporting-pane/index.d.ts +44 -0
- package/dist/components/supporting-pane/index.js +109 -0
- package/dist/components/supporting-pane/index.js.map +1 -0
- package/dist/components/tag/index.d.ts +58 -0
- package/dist/components/tag/index.js +205 -0
- package/dist/components/tag/index.js.map +1 -0
- package/dist/components/text/index.d.ts +1 -1
- package/dist/components/text/index.js +49 -21
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/text-area/index.d.ts +145 -0
- package/dist/components/text-area/index.js +231 -0
- package/dist/components/text-area/index.js.map +1 -0
- package/dist/components/text-field/index.d.ts +6 -3
- package/dist/components/text-field/index.js +3 -0
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/toolbar/index.d.ts +53 -0
- package/dist/components/toolbar/index.js +185 -0
- package/dist/components/toolbar/index.js.map +1 -0
- package/dist/control/group.js +23 -0
- package/dist/control/group.js.map +1 -0
- package/dist/fab/index.d.ts +19 -0
- package/dist/fab/index.js +147 -0
- package/dist/fab/index.js.map +1 -0
- package/dist/field/index.js +123 -79
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +18 -0
- package/dist/field/styles.js.map +1 -1
- package/dist/form/index.d.ts +1 -2
- package/dist/form/index.js +1 -1
- package/dist/form/index.js.map +1 -1
- package/dist/i18n/index.js +12 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +367 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/i18n/provider.d.ts +53 -0
- package/dist/i18n/provider.js +96 -0
- package/dist/i18n/provider.js.map +1 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +17 -3
- package/dist/indicator/index.js +1 -2
- package/dist/indicator/index.js.map +1 -1
- package/dist/mark/index.js +77 -117
- package/dist/mark/index.js.map +1 -1
- package/dist/mark/initials.js.map +1 -1
- package/dist/modal/index.js +59 -46
- package/dist/modal/index.js.map +1 -1
- package/dist/navigation/index.js +8 -5
- package/dist/navigation/index.js.map +1 -1
- package/dist/number/count.js +15 -0
- package/dist/number/count.js.map +1 -0
- package/dist/number/locale.js.map +1 -1
- package/dist/overlay/host.js +30 -21
- package/dist/overlay/host.js.map +1 -1
- package/dist/overlay/placement.js +3 -1
- package/dist/overlay/placement.js.map +1 -1
- package/dist/separator/index.js +7 -0
- package/dist/separator/index.js.map +1 -0
- package/dist/typography/size.js +14 -0
- package/dist/typography/size.js.map +1 -0
- package/package.json +1 -1
- package/dist/badge/styles.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTheme } from "../../theme/scope.js";
|
|
2
2
|
import { composeStyles } from "../../theme/styles.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useLocaleOf } from "../../i18n/provider.js";
|
|
4
4
|
import { stylesOf } from "../../calendar/styles.js";
|
|
5
5
|
import { CalendarFrame, visibleMonthOf } from "../../calendar/index.js";
|
|
6
6
|
import { c } from "react/compiler-runtime";
|
|
@@ -27,54 +27,93 @@ import { useCalendarState } from "react-stately/useCalendarState";
|
|
|
27
27
|
* `style`, `ref` and `testID` land on the container.
|
|
28
28
|
*/
|
|
29
29
|
function Calendar(t0) {
|
|
30
|
-
const $ = c(
|
|
31
|
-
|
|
30
|
+
const $ = c(26);
|
|
31
|
+
let ariaLabel;
|
|
32
|
+
let locale;
|
|
33
|
+
let props;
|
|
34
|
+
let ref;
|
|
35
|
+
let style;
|
|
36
|
+
let t1;
|
|
37
|
+
let testID;
|
|
38
|
+
if ($[0] !== t0) {
|
|
39
|
+
({"aria-label": ariaLabel, locale, ref, showMonthYearMenus: t1, style, testID, ...props} = t0);
|
|
40
|
+
$[0] = t0;
|
|
41
|
+
$[1] = ariaLabel;
|
|
42
|
+
$[2] = locale;
|
|
43
|
+
$[3] = props;
|
|
44
|
+
$[4] = ref;
|
|
45
|
+
$[5] = style;
|
|
46
|
+
$[6] = t1;
|
|
47
|
+
$[7] = testID;
|
|
48
|
+
} else {
|
|
49
|
+
ariaLabel = $[1];
|
|
50
|
+
locale = $[2];
|
|
51
|
+
props = $[3];
|
|
52
|
+
ref = $[4];
|
|
53
|
+
style = $[5];
|
|
54
|
+
t1 = $[6];
|
|
55
|
+
testID = $[7];
|
|
56
|
+
}
|
|
32
57
|
const showMonthYearMenus = t1 === void 0 ? false : t1;
|
|
33
|
-
const writtenIn =
|
|
58
|
+
const writtenIn = useLocaleOf(locale);
|
|
34
59
|
const own = stylesOf(useTheme());
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
60
|
+
let t2;
|
|
61
|
+
if ($[8] !== props || $[9] !== writtenIn) {
|
|
62
|
+
t2 = {
|
|
63
|
+
...props,
|
|
64
|
+
createCalendar,
|
|
65
|
+
locale: writtenIn
|
|
66
|
+
};
|
|
67
|
+
$[8] = props;
|
|
68
|
+
$[9] = writtenIn;
|
|
69
|
+
$[10] = t2;
|
|
70
|
+
} else t2 = $[10];
|
|
71
|
+
const state = useCalendarState(t2);
|
|
72
|
+
let t3;
|
|
73
|
+
if ($[11] !== state || $[12] !== writtenIn) {
|
|
74
|
+
t3 = visibleMonthOf(state, writtenIn);
|
|
75
|
+
$[11] = state;
|
|
76
|
+
$[12] = writtenIn;
|
|
77
|
+
$[13] = t3;
|
|
78
|
+
} else t3 = $[13];
|
|
79
|
+
const month = t3;
|
|
41
80
|
const T0 = View;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
if ($[
|
|
47
|
-
|
|
81
|
+
const t4 = ariaLabel === void 0 ? month : `${ariaLabel}, ${month}`;
|
|
82
|
+
const t5 = "group";
|
|
83
|
+
const t6 = composeStyles(own.root, style);
|
|
84
|
+
let t7;
|
|
85
|
+
if ($[14] !== props.firstDayOfWeek || $[15] !== showMonthYearMenus || $[16] !== state || $[17] !== writtenIn) {
|
|
86
|
+
t7 = /* @__PURE__ */ jsx(CalendarFrame, {
|
|
48
87
|
firstDayOfWeek: props.firstDayOfWeek,
|
|
49
88
|
locale: writtenIn,
|
|
50
89
|
showMonthYearMenus,
|
|
51
90
|
state
|
|
52
91
|
});
|
|
53
|
-
$[
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
} else
|
|
59
|
-
let
|
|
60
|
-
if ($[
|
|
61
|
-
|
|
62
|
-
"aria-label":
|
|
92
|
+
$[14] = props.firstDayOfWeek;
|
|
93
|
+
$[15] = showMonthYearMenus;
|
|
94
|
+
$[16] = state;
|
|
95
|
+
$[17] = writtenIn;
|
|
96
|
+
$[18] = t7;
|
|
97
|
+
} else t7 = $[18];
|
|
98
|
+
let t8;
|
|
99
|
+
if ($[19] !== T0 || $[20] !== ref || $[21] !== t4 || $[22] !== t6 || $[23] !== t7 || $[24] !== testID) {
|
|
100
|
+
t8 = /* @__PURE__ */ jsx(T0, {
|
|
101
|
+
"aria-label": t4,
|
|
63
102
|
ref,
|
|
64
|
-
role:
|
|
65
|
-
style:
|
|
103
|
+
role: t5,
|
|
104
|
+
style: t6,
|
|
66
105
|
testID,
|
|
67
|
-
children:
|
|
106
|
+
children: t7
|
|
68
107
|
});
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
} else
|
|
77
|
-
return
|
|
108
|
+
$[19] = T0;
|
|
109
|
+
$[20] = ref;
|
|
110
|
+
$[21] = t4;
|
|
111
|
+
$[22] = t6;
|
|
112
|
+
$[23] = t7;
|
|
113
|
+
$[24] = testID;
|
|
114
|
+
$[25] = t8;
|
|
115
|
+
} else t8 = $[25];
|
|
116
|
+
return t8;
|
|
78
117
|
}
|
|
79
118
|
//#endregion
|
|
80
119
|
export { Calendar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ComponentRef","Ref","StyleProp","ViewStyle","DateValue","CalendarProps","StatelyCalendarProps","createCalendar","View","useCalendarState","CalendarFrame","visibleMonthOf","stylesOf","
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","Ref","StyleProp","ViewStyle","DateValue","CalendarProps","StatelyCalendarProps","createCalendar","View","useCalendarState","CalendarFrame","visibleMonthOf","stylesOf","useLocaleOf","useTheme","composeStyles","Pick","T","locale","ref","showMonthYearMenus","style","testID","Calendar","t0","$","_c","ariaLabel","props","t1","undefined","writtenIn","own","t2","state","t3","month","T0","t4","t5","t6","root","t7","firstDayOfWeek","t8","_c"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["import type { ComponentRef, Ref } from 'react'\nimport type { StyleProp, ViewStyle } from 'react-native'\nimport type {\n DateValue,\n CalendarProps as StatelyCalendarProps,\n} from 'react-stately/useCalendarState'\n\nimport { createCalendar } from '@internationalized/date'\nimport { View } from 'react-native'\nimport { useCalendarState } from 'react-stately/useCalendarState'\n\nimport { CalendarFrame, visibleMonthOf } from '../../calendar'\nimport { stylesOf } from '../../calendar/styles'\nimport { useLocaleOf } from '../../i18n/provider'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles } from '../../theme/styles'\n\n// kanso-ui's Calendar, the date pickers page's docked calendar: a month grid\n// with a circle on the selected date and an outline on today. Its values are\n// that page's: a 360dp container on the high surface container, 48dp date\n// cells with a 40dp state layer inside them, body large for both the weekday\n// row and the dates, and primary for the selected circle and for today's\n// outline. The parts are in src/calendar.\n//\n// The state is React Stately's `useCalendarState`, which web's React Aria\n// calendar is built on, over `@internationalized/date`, so the selection,\n// the bounds and the locale's calendar, first day of the week and digits\n// behave as they do on web.\n//\n// The page's container is 456dp tall, which this does not take: that height\n// is a picker's, counting a headline and an action row the calendar itself\n// does not draw. What is held instead is the grid, at six weeks, the most any\n// month occupies, so the calendar keeps its height as the month moves and a\n// shorter month leaves its last rows empty.\n//\n// `showMonthYearMenus` draws the page's docked header instead of one heading:\n// the month's menu button between the chevrons that step it and the year's\n// after them, each opening its list where the grid was, as web's does. The\n// page draws the lists there, and a calendar inside a picker is already in\n// a panel, so a menu over it would be a panel over a panel.\n//\n// Five things are this component's own, as on web.\n//\n// **The year menu has no chevrons of its own.** The page draws a pair either\n// side of it that step a year; the year list reaches any year within a\n// century of the one shown in one press, or any the bounds allow where they\n// are closer.\n//\n// **The cell is a circle in a square.** The page gives the date a 48dp\n// container and a 40dp state layer, which is a 40dp circle with 4dp of room\n// around it. The circle is the pressable, centred in a 48dp column and a 48dp\n// row, and its `hitSlop` reaches the 4dp past it on every side, so the whole\n// square takes the press. The chevrons and the menu buttons reach a 48dp\n// target the same way.\n//\n// **It narrows to its container.** The page's docked calendar is 360dp, and\n// a compact window leaves 328dp between its margins, so the calendar is 360\n// at most and the columns share whatever is left below that.\n//\n// **A date from the month either side is faded because it is disabled**, as\n// React Aria disables those dates: the page's 38% either way. A date\n// `isDateUnavailable` rules out is struck through at full contrast instead,\n// since a reader can still land on it and has to read it.\n//\n// **Today reads as today whether or not it is selected.** The page gives it\n// an outline and the primary label; selected gives it a filled circle and\n// the on-primary label. A selected today takes the fill.\n//\n// Web's month changes at once. Here **the weeks slide in** from the side the\n// new month comes from, Material Design's shared axis transition, and change\n// at once under reduced motion.\n//\n// **The locale is the `I18nProvider`'s**, as web reads it from React Aria's,\n// unless the `locale` prop names another, and the device's under neither. The\n// words the calendar writes, its chevrons' names and its dates', are React\n// Aria's in that locale.\n\ntype CalendarProps<T extends DateValue = DateValue> = Pick<\n StatelyCalendarProps<T>,\n | 'defaultFocusedValue'\n | 'defaultValue'\n | 'firstDayOfWeek'\n | 'focusedValue'\n | 'isDateUnavailable'\n | 'isDisabled'\n | 'isReadOnly'\n | 'maxValue'\n | 'minValue'\n | 'onChange'\n | 'onFocusChange'\n | 'value'\n> & {\n /**\n * The calendar's name. The month shown is added to it, as React Aria adds\n * it on web.\n */\n readonly 'aria-label'?: string\n /**\n * The BCP 47 locale the calendar is written in: its month and weekday\n * names, its digits, its first day of the week and its calendar system.\n * Defaults to the `I18nProvider`'s, or the device's outside one.\n */\n readonly locale?: string\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * Whether the header draws the month and the year as menu buttons, each\n * opening a list of them in the grid's place, as the docked date picker's\n * header does, rather than one heading between the chevrons. For a date\n * far from the one shown, such as a date of birth: the year list runs a\n * century either side of the year shown, or to `minValue` and `maxValue`\n * where they are closer.\n * @default false\n */\n readonly showMonthYearMenus?: boolean\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\n/**\n * A month calendar for picking a date. The value is an\n * `@internationalized/date` value, as on web: pass `value` with `onChange` to\n * control it, or `defaultValue` to let it keep its own.\n *\n * ```tsx\n * import { getLocalTimeZone, today } from '@internationalized/date'\n *\n * <Calendar aria-label=\"Label\" defaultValue={today(getLocalTimeZone())} />\n * ```\n *\n * `minValue` and `maxValue` bound it, and `isDateUnavailable` rules\n * individual dates out. Name it with `aria-label`; the month shown is added\n * to the name.\n *\n * `style`, `ref` and `testID` land on the container.\n */\nfunction Calendar<T extends DateValue = DateValue>({\n 'aria-label': ariaLabel,\n locale,\n ref,\n showMonthYearMenus = false,\n style,\n testID,\n ...props\n}: CalendarProps<T>) {\n const writtenIn = useLocaleOf(locale)\n const own = stylesOf(useTheme())\n const state = useCalendarState<T>({\n ...props,\n createCalendar,\n locale: writtenIn,\n })\n const month = visibleMonthOf(state, writtenIn)\n\n return (\n <View\n aria-label={ariaLabel === undefined ? month : `${ariaLabel}, ${month}`}\n ref={ref}\n role=\"group\"\n style={composeStyles<ViewStyle>(own.root, style)}\n testID={testID}\n >\n <CalendarFrame\n firstDayOfWeek={props.firstDayOfWeek}\n locale={writtenIn}\n showMonthYearMenus={showMonthYearMenus}\n state={state}\n />\n </View>\n )\n}\n\nexport type { CalendarProps }\n\nexport { Calendar }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuIA,SAAAuB,SAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAT;CAAA,IAAAU;CAAA,IAAAT;CAAA,IAAAE;CAAA,IAAAQ;CAAA,IAAAP;CAAA,IAAAG,EAAA,OAAAD,IAAA;EAAmD,CAAA,CAAA,cAAAG,WAAAT,QAAAC,KAAAC,oBAAAS,IAAAR,OAAAC,QAAA,GAAAM,SAAAJ;EAQhCC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAP;EAAAO,EAAA,KAAAG;EAAAH,EAAA,KAAAN;EAAAM,EAAA,KAAAJ;EAAAI,EAAA,KAAAI;EAAAJ,EAAA,KAAAH;CAAA,OAAA;EAAAK,YAAAF,EAAA;EAAAP,SAAAO,EAAA;EAAAG,QAAAH,EAAA;EAAAN,MAAAM,EAAA;EAAAJ,QAAAI,EAAA;EAAAI,KAAAJ,EAAA;EAAAH,SAAAG,EAAA;CAAA;CAJjB,MAAAL,qBAAAS,OAAAC,KAAAA,IAAA,QAAAD;CAKA,MAAAE,YAAkBlB,YAAYK,MAAM;CACpC,MAAAc,MAAYpB,SAASE,SAAS,CAAC;CAAC,IAAAmB;CAAA,IAAAR,EAAA,OAAAG,SAAAH,EAAA,OAAAM,WAAA;EACEE,KAAA;GAAA,GAC7BL;GAAKrB;GAAAW,QAEAa;EACV;EAACN,EAAA,KAAAG;EAAAH,EAAA,KAAAM;EAAAN,EAAA,MAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAJD,MAAAS,QAAczB,iBAAoBwB,EAIjC;CAAC,IAAAE;CAAA,IAAAV,EAAA,QAAAS,SAAAT,EAAA,QAAAM,WAAA;EACYI,KAAAxB,eAAeuB,OAAOH,SAAS;EAACN,EAAA,MAAAS;EAAAT,EAAA,MAAAM;EAAAN,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAA9C,MAAAW,QAAcD;CAGX,MAAAE,KAAA7B;CACa,MAAA8B,KAAAX,cAAcG,KAAAA,IAAdM,QAAA,GAAqCT,UAAS,IAAKS;CAE1D,MAAAG,KAAA;CACE,MAAAC,KAAAzB,cAAyBiB,IAAGS,MAAOpB,KAAK;CAAC,IAAAqB;CAAA,IAAAjB,EAAA,QAAAG,MAAAe,kBAAAlB,EAAA,QAAAL,sBAAAK,EAAA,QAAAS,SAAAT,EAAA,QAAAM,WAAA;EAGhDW,KAAA,oBAAC,eAAD;GACkB,gBAAAd,MAAKe;GACbZ,QAAAA;GACYX;GACbc;EAAK,CAAA;EACZT,EAAA,MAAAG,MAAAe;EAAAlB,EAAA,MAAAL;EAAAK,EAAA,MAAAS;EAAAT,EAAA,MAAAM;EAAAN,EAAA,MAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,IAAAmB;CAAA,IAAAnB,EAAA,QAAAY,MAAAZ,EAAA,QAAAN,OAAAM,EAAA,QAAAa,MAAAb,EAAA,QAAAe,MAAAf,EAAA,QAAAiB,MAAAjB,EAAA,QAAAH,QAAA;EAZJsB,KAAA,oBAAC,IAAD;GACc,cAAAN;GACPnB;GACA,MAAAoB;GACE,OAAAC;GACClB;GAERoB,UAAAA;EAPG,CAAA;EAaEjB,EAAA,MAAAY;EAAAZ,EAAA,MAAAN;EAAAM,EAAA,MAAAa;EAAAb,EAAA,MAAAe;EAAAf,EAAA,MAAAiB;EAAAjB,EAAA,MAAAH;EAAAG,EAAA,MAAAmB;CAAA,OAAAA,KAAAnB,EAAA;CAAA,OAbPmB;AAaO"}
|
|
@@ -49,6 +49,12 @@ type CheckboxProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
|
49
49
|
readonly onChange?: (isSelected: boolean) => void;
|
|
50
50
|
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
51
51
|
readonly style?: StyleProp<ViewStyle>;
|
|
52
|
+
/**
|
|
53
|
+
* The entry this checkbox stands for inside a `CheckboxGroup`, which the
|
|
54
|
+
* group's value holds while it is selected. Required there, and unused
|
|
55
|
+
* outside one.
|
|
56
|
+
*/
|
|
57
|
+
readonly value?: string;
|
|
52
58
|
};
|
|
53
59
|
/**
|
|
54
60
|
* A checkbox with its label, and optionally a description or an error under
|
|
@@ -70,7 +76,7 @@ type CheckboxProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
|
70
76
|
* holding the row and the line under it, which is the element a layout
|
|
71
77
|
* positions.
|
|
72
78
|
*/
|
|
73
|
-
declare function Checkbox({ 'aria-label': ariaLabel, children, defaultSelected, description, error, isDisabled, isIndeterminate, isReadOnly, isSelected, onChange, style, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
79
|
+
declare function Checkbox({ 'aria-label': ariaLabel, children, defaultSelected, description, error, isDisabled: ownDisabled, isIndeterminate, isReadOnly: ownReadOnly, isSelected, onChange, style, value, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
74
80
|
//#endregion
|
|
75
81
|
export { Checkbox, type CheckboxProps };
|
|
76
82
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,9 +4,10 @@ import { hitSlop, usePressFeedback } from "../../press/index.js";
|
|
|
4
4
|
import { controlStylesOf } from "../../control/styles.js";
|
|
5
5
|
import { ControlLabel, ControlMessage, describedBy, messageOf } from "../../control/index.js";
|
|
6
6
|
import { CheckboxBox } from "../../control/checkbox-box.js";
|
|
7
|
+
import { CheckboxGroupContext } from "../../control/group.js";
|
|
7
8
|
import { c } from "react/compiler-runtime";
|
|
8
9
|
import { Pressable, View } from "react-native";
|
|
9
|
-
import { useId } from "react";
|
|
10
|
+
import { use, useEffect, useId, useRef } from "react";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { useToggleState } from "react-stately/useToggleState";
|
|
12
13
|
//#region src/components/checkbox/index.tsx
|
|
@@ -45,7 +46,7 @@ const LAYERS = {
|
|
|
45
46
|
* positions.
|
|
46
47
|
*/
|
|
47
48
|
function Checkbox(t0) {
|
|
48
|
-
const $ = c(
|
|
49
|
+
const $ = c(76);
|
|
49
50
|
let ariaLabel;
|
|
50
51
|
let children;
|
|
51
52
|
let defaultSelected;
|
|
@@ -58,8 +59,9 @@ function Checkbox(t0) {
|
|
|
58
59
|
let t1;
|
|
59
60
|
let t2;
|
|
60
61
|
let t3;
|
|
62
|
+
let value;
|
|
61
63
|
if ($[0] !== t0) {
|
|
62
|
-
({"aria-label": ariaLabel, children, defaultSelected, description, error, isDisabled: t1, isIndeterminate: t2, isReadOnly: t3, isSelected, onChange, style, ...props} = t0);
|
|
64
|
+
({"aria-label": ariaLabel, children, defaultSelected, description, error, isDisabled: t1, isIndeterminate: t2, isReadOnly: t3, isSelected, onChange, style, value, ...props} = t0);
|
|
63
65
|
$[0] = t0;
|
|
64
66
|
$[1] = ariaLabel;
|
|
65
67
|
$[2] = children;
|
|
@@ -73,6 +75,7 @@ function Checkbox(t0) {
|
|
|
73
75
|
$[10] = t1;
|
|
74
76
|
$[11] = t2;
|
|
75
77
|
$[12] = t3;
|
|
78
|
+
$[13] = value;
|
|
76
79
|
} else {
|
|
77
80
|
ariaLabel = $[1];
|
|
78
81
|
children = $[2];
|
|
@@ -86,95 +89,126 @@ function Checkbox(t0) {
|
|
|
86
89
|
t1 = $[10];
|
|
87
90
|
t2 = $[11];
|
|
88
91
|
t3 = $[12];
|
|
92
|
+
value = $[13];
|
|
89
93
|
}
|
|
90
|
-
const
|
|
94
|
+
const ownDisabled = t1 === void 0 ? false : t1;
|
|
91
95
|
const isIndeterminate = t2 === void 0 ? false : t2;
|
|
92
|
-
const
|
|
96
|
+
const ownReadOnly = t3 === void 0 ? false : t3;
|
|
93
97
|
const theme = useTheme();
|
|
98
|
+
const group = use(CheckboxGroupContext);
|
|
99
|
+
const messageId = useId();
|
|
100
|
+
const control = useRef(null);
|
|
101
|
+
const members = group?.members;
|
|
102
|
+
if (group !== null && value === void 0) throw new Error("A Checkbox inside a CheckboxGroup names the entry it stands for with `value`.");
|
|
103
|
+
const isDisabled = ownDisabled || (group?.isDisabled ?? false);
|
|
104
|
+
const isReadOnly = ownReadOnly || (group?.isReadOnly ?? false);
|
|
94
105
|
let t4;
|
|
95
|
-
if ($[
|
|
96
|
-
t4 = {
|
|
106
|
+
if ($[14] !== defaultSelected || $[15] !== group || $[16] !== isReadOnly || $[17] !== isSelected || $[18] !== onChange || $[19] !== value) {
|
|
107
|
+
t4 = group === null || value === void 0 ? {
|
|
97
108
|
defaultSelected,
|
|
98
109
|
isReadOnly,
|
|
99
110
|
isSelected,
|
|
100
111
|
onChange
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
|
|
112
|
+
} : memberOf(group, value, {
|
|
113
|
+
isReadOnly,
|
|
114
|
+
onChange
|
|
115
|
+
});
|
|
116
|
+
$[14] = defaultSelected;
|
|
117
|
+
$[15] = group;
|
|
118
|
+
$[16] = isReadOnly;
|
|
119
|
+
$[17] = isSelected;
|
|
120
|
+
$[18] = onChange;
|
|
121
|
+
$[19] = value;
|
|
122
|
+
$[20] = t4;
|
|
123
|
+
} else t4 = $[20];
|
|
108
124
|
const state = useToggleState(t4);
|
|
109
|
-
|
|
125
|
+
let t5;
|
|
126
|
+
let t6;
|
|
127
|
+
if ($[21] !== members || $[22] !== messageId) {
|
|
128
|
+
t5 = () => {
|
|
129
|
+
members?.add(messageId, control);
|
|
130
|
+
return () => {
|
|
131
|
+
members?.remove(messageId);
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
t6 = [members, messageId];
|
|
135
|
+
$[21] = members;
|
|
136
|
+
$[22] = messageId;
|
|
137
|
+
$[23] = t5;
|
|
138
|
+
$[24] = t6;
|
|
139
|
+
} else {
|
|
140
|
+
t5 = $[23];
|
|
141
|
+
t6 = $[24];
|
|
142
|
+
}
|
|
143
|
+
useEffect(t5, t6);
|
|
110
144
|
const { colors, radii } = theme;
|
|
111
145
|
const marked = state.isSelected || isIndeterminate;
|
|
112
146
|
const interactive = !isDisabled && !isReadOnly;
|
|
113
|
-
const tone = error
|
|
114
|
-
const
|
|
115
|
-
let
|
|
116
|
-
if ($[
|
|
117
|
-
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
} else
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
let
|
|
124
|
-
if ($[
|
|
125
|
-
|
|
126
|
-
color:
|
|
127
|
-
corners:
|
|
128
|
-
disabled:
|
|
147
|
+
const tone = error !== void 0 || (group?.isInvalid ?? false) ? "error" : marked ? "marked" : "unmarked";
|
|
148
|
+
const t7 = colors[LAYERS[tone].hover];
|
|
149
|
+
let t8;
|
|
150
|
+
if ($[25] !== radii.circle) {
|
|
151
|
+
t8 = { borderRadius: radii.circle };
|
|
152
|
+
$[25] = radii.circle;
|
|
153
|
+
$[26] = t8;
|
|
154
|
+
} else t8 = $[26];
|
|
155
|
+
const t9 = !interactive;
|
|
156
|
+
const t10 = colors[LAYERS[tone].pressed];
|
|
157
|
+
let t11;
|
|
158
|
+
if ($[27] !== t10 || $[28] !== t7 || $[29] !== t8 || $[30] !== t9) {
|
|
159
|
+
t11 = {
|
|
160
|
+
color: t7,
|
|
161
|
+
corners: t8,
|
|
162
|
+
disabled: t9,
|
|
129
163
|
disc: 40,
|
|
130
|
-
pressedColor:
|
|
164
|
+
pressedColor: t10
|
|
131
165
|
};
|
|
132
|
-
$[
|
|
133
|
-
$[
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
} else
|
|
138
|
-
const feedback = usePressFeedback(
|
|
166
|
+
$[27] = t10;
|
|
167
|
+
$[28] = t7;
|
|
168
|
+
$[29] = t8;
|
|
169
|
+
$[30] = t9;
|
|
170
|
+
$[31] = t11;
|
|
171
|
+
} else t11 = $[31];
|
|
172
|
+
const feedback = usePressFeedback(t11);
|
|
139
173
|
const active = feedback.hovered || feedback.pressed || feedback.ring !== void 0;
|
|
140
|
-
const
|
|
141
|
-
let t11;
|
|
142
|
-
if ($[25] !== description || $[26] !== error || $[27] !== messageId) {
|
|
143
|
-
t11 = describedBy(messageId, messageOf(description, error));
|
|
144
|
-
$[25] = description;
|
|
145
|
-
$[26] = error;
|
|
146
|
-
$[27] = messageId;
|
|
147
|
-
$[28] = t11;
|
|
148
|
-
} else t11 = $[28];
|
|
149
|
-
const t12 = feedback.handlers;
|
|
174
|
+
const t12 = isIndeterminate ? "mixed" : state.isSelected;
|
|
150
175
|
let t13;
|
|
151
|
-
if ($[
|
|
152
|
-
t13 =
|
|
153
|
-
$[
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
$[31] = t14;
|
|
160
|
-
} else t14 = $[31];
|
|
176
|
+
if ($[32] !== description || $[33] !== error || $[34] !== messageId) {
|
|
177
|
+
t13 = describedBy(messageId, messageOf(description, error));
|
|
178
|
+
$[32] = description;
|
|
179
|
+
$[33] = error;
|
|
180
|
+
$[34] = messageId;
|
|
181
|
+
$[35] = t13;
|
|
182
|
+
} else t13 = $[35];
|
|
183
|
+
const t14 = feedback.handlers;
|
|
161
184
|
let t15;
|
|
162
|
-
if ($[
|
|
163
|
-
t15 =
|
|
164
|
-
$[
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
185
|
+
if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
|
|
186
|
+
t15 = hitSlop(40, 40);
|
|
187
|
+
$[36] = t15;
|
|
188
|
+
} else t15 = $[36];
|
|
189
|
+
let t16;
|
|
190
|
+
if ($[37] !== state) {
|
|
191
|
+
t16 = toggleOf(state);
|
|
192
|
+
$[37] = state;
|
|
193
|
+
$[38] = t16;
|
|
194
|
+
} else t16 = $[38];
|
|
168
195
|
let t17;
|
|
169
|
-
if ($[
|
|
170
|
-
t17 =
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
let
|
|
176
|
-
if ($[
|
|
177
|
-
|
|
196
|
+
if ($[39] !== theme) {
|
|
197
|
+
t17 = controlStylesOf(theme);
|
|
198
|
+
$[39] = theme;
|
|
199
|
+
$[40] = t17;
|
|
200
|
+
} else t17 = $[40];
|
|
201
|
+
const t18 = t17.row;
|
|
202
|
+
let t19;
|
|
203
|
+
if ($[41] !== feedback.ring || $[42] !== theme) {
|
|
204
|
+
t19 = composeStyles(controlStylesOf(theme).disc, feedback.ring);
|
|
205
|
+
$[41] = feedback.ring;
|
|
206
|
+
$[42] = theme;
|
|
207
|
+
$[43] = t19;
|
|
208
|
+
} else t19 = $[43];
|
|
209
|
+
let t20;
|
|
210
|
+
if ($[44] !== active || $[45] !== isDisabled || $[46] !== isIndeterminate || $[47] !== state.isSelected || $[48] !== tone) {
|
|
211
|
+
t20 = /* @__PURE__ */ jsx(CheckboxBox, {
|
|
178
212
|
active,
|
|
179
213
|
isDisabled,
|
|
180
214
|
isIndeterminate,
|
|
@@ -182,85 +216,96 @@ function Checkbox(t0) {
|
|
|
182
216
|
tone,
|
|
183
217
|
within: 40
|
|
184
218
|
});
|
|
185
|
-
$[
|
|
186
|
-
$[
|
|
187
|
-
$[
|
|
188
|
-
$[
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
} else
|
|
192
|
-
let
|
|
193
|
-
if ($[
|
|
194
|
-
|
|
195
|
-
style:
|
|
196
|
-
children: [feedback.layer,
|
|
219
|
+
$[44] = active;
|
|
220
|
+
$[45] = isDisabled;
|
|
221
|
+
$[46] = isIndeterminate;
|
|
222
|
+
$[47] = state.isSelected;
|
|
223
|
+
$[48] = tone;
|
|
224
|
+
$[49] = t20;
|
|
225
|
+
} else t20 = $[49];
|
|
226
|
+
let t21;
|
|
227
|
+
if ($[50] !== feedback.layer || $[51] !== t19 || $[52] !== t20) {
|
|
228
|
+
t21 = /* @__PURE__ */ jsxs(View, {
|
|
229
|
+
style: t19,
|
|
230
|
+
children: [feedback.layer, t20]
|
|
197
231
|
});
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
} else
|
|
203
|
-
let
|
|
204
|
-
if ($[
|
|
205
|
-
|
|
232
|
+
$[50] = feedback.layer;
|
|
233
|
+
$[51] = t19;
|
|
234
|
+
$[52] = t20;
|
|
235
|
+
$[53] = t21;
|
|
236
|
+
} else t21 = $[53];
|
|
237
|
+
let t22;
|
|
238
|
+
if ($[54] !== children || $[55] !== isDisabled) {
|
|
239
|
+
t22 = /* @__PURE__ */ jsx(ControlLabel, {
|
|
206
240
|
isDisabled,
|
|
207
241
|
children
|
|
208
242
|
});
|
|
209
|
-
$[
|
|
210
|
-
$[
|
|
211
|
-
$[
|
|
212
|
-
} else
|
|
213
|
-
let
|
|
214
|
-
if ($[
|
|
215
|
-
|
|
216
|
-
"aria-checked":
|
|
243
|
+
$[54] = children;
|
|
244
|
+
$[55] = isDisabled;
|
|
245
|
+
$[56] = t22;
|
|
246
|
+
} else t22 = $[56];
|
|
247
|
+
let t23;
|
|
248
|
+
if ($[57] !== ariaLabel || $[58] !== feedback.handlers || $[59] !== isDisabled || $[60] !== t12 || $[61] !== t13 || $[62] !== t16 || $[63] !== t17.row || $[64] !== t21 || $[65] !== t22) {
|
|
249
|
+
t23 = /* @__PURE__ */ jsxs(Pressable, {
|
|
250
|
+
"aria-checked": t12,
|
|
217
251
|
"aria-label": ariaLabel,
|
|
218
252
|
role: "checkbox",
|
|
219
|
-
...
|
|
220
|
-
...
|
|
253
|
+
...t13,
|
|
254
|
+
...t14,
|
|
221
255
|
disabled: isDisabled,
|
|
222
|
-
hitSlop:
|
|
223
|
-
onPress:
|
|
224
|
-
|
|
225
|
-
|
|
256
|
+
hitSlop: t15,
|
|
257
|
+
onPress: t16,
|
|
258
|
+
ref: control,
|
|
259
|
+
style: t18,
|
|
260
|
+
children: [t21, t22]
|
|
226
261
|
});
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
$[
|
|
237
|
-
} else
|
|
238
|
-
let
|
|
239
|
-
if ($[
|
|
240
|
-
|
|
262
|
+
$[57] = ariaLabel;
|
|
263
|
+
$[58] = feedback.handlers;
|
|
264
|
+
$[59] = isDisabled;
|
|
265
|
+
$[60] = t12;
|
|
266
|
+
$[61] = t13;
|
|
267
|
+
$[62] = t16;
|
|
268
|
+
$[63] = t17.row;
|
|
269
|
+
$[64] = t21;
|
|
270
|
+
$[65] = t22;
|
|
271
|
+
$[66] = t23;
|
|
272
|
+
} else t23 = $[66];
|
|
273
|
+
let t24;
|
|
274
|
+
if ($[67] !== description || $[68] !== error || $[69] !== messageId) {
|
|
275
|
+
t24 = /* @__PURE__ */ jsx(ControlMessage, {
|
|
241
276
|
description,
|
|
242
277
|
error,
|
|
243
278
|
id: messageId
|
|
244
279
|
});
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
} else
|
|
250
|
-
let
|
|
251
|
-
if ($[
|
|
252
|
-
|
|
280
|
+
$[67] = description;
|
|
281
|
+
$[68] = error;
|
|
282
|
+
$[69] = messageId;
|
|
283
|
+
$[70] = t24;
|
|
284
|
+
} else t24 = $[70];
|
|
285
|
+
let t25;
|
|
286
|
+
if ($[71] !== props || $[72] !== style || $[73] !== t23 || $[74] !== t24) {
|
|
287
|
+
t25 = /* @__PURE__ */ jsxs(View, {
|
|
253
288
|
...props,
|
|
254
289
|
style,
|
|
255
|
-
children: [
|
|
290
|
+
children: [t23, t24]
|
|
256
291
|
});
|
|
257
|
-
$[
|
|
258
|
-
$[
|
|
259
|
-
$[
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
} else
|
|
263
|
-
return
|
|
292
|
+
$[71] = props;
|
|
293
|
+
$[72] = style;
|
|
294
|
+
$[73] = t23;
|
|
295
|
+
$[74] = t24;
|
|
296
|
+
$[75] = t25;
|
|
297
|
+
} else t25 = $[75];
|
|
298
|
+
return t25;
|
|
299
|
+
}
|
|
300
|
+
function memberOf(group, value, { isReadOnly, onChange }) {
|
|
301
|
+
return {
|
|
302
|
+
isReadOnly,
|
|
303
|
+
isSelected: group.isSelected(value),
|
|
304
|
+
onChange: (isSelected) => {
|
|
305
|
+
group.set(value, isSelected);
|
|
306
|
+
onChange?.(isSelected);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
264
309
|
}
|
|
265
310
|
function toggleOf(state) {
|
|
266
311
|
return () => {
|