@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
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { useTheme } from "../../theme/scope.js";
|
|
2
1
|
import { composeStyles } from "../../theme/styles.js";
|
|
3
2
|
import { useLocaleOf } from "../../i18n/provider.js";
|
|
4
|
-
import {
|
|
5
|
-
import { CalendarFrame, visibleMonthOf } from "../../calendar/index.js";
|
|
3
|
+
import { CalendarFrame, useRootStyle, visibleRangeOf } from "../../calendar/index.js";
|
|
6
4
|
import { c } from "react/compiler-runtime";
|
|
7
5
|
import { View } from "react-native";
|
|
8
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -27,7 +25,7 @@ import { useCalendarState } from "react-stately/useCalendarState";
|
|
|
27
25
|
* `style`, `ref` and `testID` land on the container.
|
|
28
26
|
*/
|
|
29
27
|
function Calendar(t0) {
|
|
30
|
-
const $ = c(
|
|
28
|
+
const $ = c(33);
|
|
31
29
|
let ariaLabel;
|
|
32
30
|
let locale;
|
|
33
31
|
let props;
|
|
@@ -35,8 +33,9 @@ function Calendar(t0) {
|
|
|
35
33
|
let style;
|
|
36
34
|
let t1;
|
|
37
35
|
let testID;
|
|
36
|
+
let visibleDuration;
|
|
38
37
|
if ($[0] !== t0) {
|
|
39
|
-
({"aria-label": ariaLabel, locale, ref, showMonthYearMenus: t1, style, testID, ...props} = t0);
|
|
38
|
+
({"aria-label": ariaLabel, locale, ref, showMonthYearMenus: t1, style, testID, visibleDuration, ...props} = t0);
|
|
40
39
|
$[0] = t0;
|
|
41
40
|
$[1] = ariaLabel;
|
|
42
41
|
$[2] = locale;
|
|
@@ -45,6 +44,7 @@ function Calendar(t0) {
|
|
|
45
44
|
$[5] = style;
|
|
46
45
|
$[6] = t1;
|
|
47
46
|
$[7] = testID;
|
|
47
|
+
$[8] = visibleDuration;
|
|
48
48
|
} else {
|
|
49
49
|
ariaLabel = $[1];
|
|
50
50
|
locale = $[2];
|
|
@@ -53,66 +53,81 @@ function Calendar(t0) {
|
|
|
53
53
|
style = $[5];
|
|
54
54
|
t1 = $[6];
|
|
55
55
|
testID = $[7];
|
|
56
|
+
visibleDuration = $[8];
|
|
56
57
|
}
|
|
57
58
|
const showMonthYearMenus = t1 === void 0 ? false : t1;
|
|
58
59
|
const writtenIn = useLocaleOf(locale);
|
|
59
|
-
const
|
|
60
|
+
const months = Math.max(1, visibleDuration?.months ?? 1);
|
|
61
|
+
const rootStyle = useRootStyle(months);
|
|
60
62
|
let t2;
|
|
61
|
-
if ($[
|
|
62
|
-
t2 = {
|
|
63
|
-
|
|
64
|
-
createCalendar,
|
|
65
|
-
locale: writtenIn
|
|
66
|
-
};
|
|
67
|
-
$[8] = props;
|
|
68
|
-
$[9] = writtenIn;
|
|
63
|
+
if ($[9] !== months) {
|
|
64
|
+
t2 = { months };
|
|
65
|
+
$[9] = months;
|
|
69
66
|
$[10] = t2;
|
|
70
67
|
} else t2 = $[10];
|
|
71
|
-
const state = useCalendarState(t2);
|
|
72
68
|
let t3;
|
|
73
|
-
if ($[11] !==
|
|
74
|
-
t3 =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
if ($[11] !== props || $[12] !== t2 || $[13] !== writtenIn) {
|
|
70
|
+
t3 = {
|
|
71
|
+
...props,
|
|
72
|
+
createCalendar,
|
|
73
|
+
locale: writtenIn,
|
|
74
|
+
visibleDuration: t2
|
|
75
|
+
};
|
|
76
|
+
$[11] = props;
|
|
77
|
+
$[12] = t2;
|
|
78
|
+
$[13] = writtenIn;
|
|
79
|
+
$[14] = t3;
|
|
80
|
+
} else t3 = $[14];
|
|
81
|
+
const state = useCalendarState(t3);
|
|
82
|
+
let t4;
|
|
83
|
+
if ($[15] !== state || $[16] !== writtenIn) {
|
|
84
|
+
t4 = visibleRangeOf(state, writtenIn, true);
|
|
85
|
+
$[15] = state;
|
|
86
|
+
$[16] = writtenIn;
|
|
87
|
+
$[17] = t4;
|
|
88
|
+
} else t4 = $[17];
|
|
89
|
+
const month = t4;
|
|
90
|
+
const t5 = ariaLabel === void 0 ? month : `${ariaLabel}, ${month}`;
|
|
91
|
+
let t6;
|
|
92
|
+
if ($[18] !== rootStyle || $[19] !== style) {
|
|
93
|
+
t6 = composeStyles(rootStyle, style);
|
|
94
|
+
$[18] = rootStyle;
|
|
95
|
+
$[19] = style;
|
|
96
|
+
$[20] = t6;
|
|
97
|
+
} else t6 = $[20];
|
|
84
98
|
let t7;
|
|
85
|
-
if ($[
|
|
99
|
+
if ($[21] !== months || $[22] !== props.firstDayOfWeek || $[23] !== showMonthYearMenus || $[24] !== state || $[25] !== writtenIn) {
|
|
86
100
|
t7 = /* @__PURE__ */ jsx(CalendarFrame, {
|
|
87
101
|
firstDayOfWeek: props.firstDayOfWeek,
|
|
88
102
|
locale: writtenIn,
|
|
103
|
+
months,
|
|
89
104
|
showMonthYearMenus,
|
|
90
105
|
state
|
|
91
106
|
});
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
|
|
107
|
+
$[21] = months;
|
|
108
|
+
$[22] = props.firstDayOfWeek;
|
|
109
|
+
$[23] = showMonthYearMenus;
|
|
110
|
+
$[24] = state;
|
|
111
|
+
$[25] = writtenIn;
|
|
112
|
+
$[26] = t7;
|
|
113
|
+
} else t7 = $[26];
|
|
98
114
|
let t8;
|
|
99
|
-
if ($[
|
|
100
|
-
t8 = /* @__PURE__ */ jsx(
|
|
101
|
-
"aria-label":
|
|
115
|
+
if ($[27] !== ref || $[28] !== t5 || $[29] !== t6 || $[30] !== t7 || $[31] !== testID) {
|
|
116
|
+
t8 = /* @__PURE__ */ jsx(View, {
|
|
117
|
+
"aria-label": t5,
|
|
102
118
|
ref,
|
|
103
|
-
role:
|
|
119
|
+
role: "group",
|
|
104
120
|
style: t6,
|
|
105
121
|
testID,
|
|
106
122
|
children: t7
|
|
107
123
|
});
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
|
|
115
|
-
} else t8 = $[25];
|
|
124
|
+
$[27] = ref;
|
|
125
|
+
$[28] = t5;
|
|
126
|
+
$[29] = t6;
|
|
127
|
+
$[30] = t7;
|
|
128
|
+
$[31] = testID;
|
|
129
|
+
$[32] = t8;
|
|
130
|
+
} else t8 = $[32];
|
|
116
131
|
return t8;
|
|
117
132
|
}
|
|
118
133
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
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;C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;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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DateDuration","ComponentRef","Ref","StyleProp","ViewStyle","DateValue","CalendarProps","StatelyCalendarProps","createCalendar","View","useCalendarState","CalendarFrame","useRootStyle","visibleRangeOf","useLocaleOf","composeStyles","Pick","T","locale","ref","showMonthYearMenus","style","testID","visibleDuration","Calendar","t0","$","_c","ariaLabel","props","t1","undefined","writtenIn","months","Math","max","rootStyle","t2","t3","state","t4","month","t5","t6","t7","firstDayOfWeek","t8","_c"],"sources":["../../../src/components/calendar/index.tsx"],"sourcesContent":["import type { DateDuration } from '@internationalized/date'\nimport 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, useRootStyle, visibleRangeOf } from '../../calendar'\nimport { useLocaleOf } from '../../i18n/provider'\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// **`visibleDuration` shows more than one month**, each in a grid of its own,\n// side by side from the expanded window size up and one under another below\n// it, as web's sit, since two side by side come to 720dp with the padding.\n// The container widens to hold them. Only its `months` is read, as web draws\n// whole months alone, and with more than one the header is the plain one\n// whatever `showMonthYearMenus` says, since the menus name the first month\n// alone.\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, or the months, is added to it, as\n * React Aria adds 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 * How many months the calendar shows at once, and moves by: side by side\n * from the expanded window size up, one under another below it. Only\n * `months` is read.\n * @default { months: 1 }\n */\n readonly visibleDuration?: DateDuration\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 visibleDuration,\n ...props\n}: CalendarProps<T>) {\n const writtenIn = useLocaleOf(locale)\n const months = Math.max(1, visibleDuration?.months ?? 1)\n const rootStyle = useRootStyle(months)\n const state = useCalendarState<T>({\n ...props,\n createCalendar,\n locale: writtenIn,\n visibleDuration: { months },\n })\n const month = visibleRangeOf(state, writtenIn, true)\n\n return (\n <View\n aria-label={ariaLabel === undefined ? month : `${ariaLabel}, ${month}`}\n ref={ref}\n role=\"group\"\n style={composeStyles<ViewStyle>(rootStyle, style)}\n testID={testID}\n >\n <CalendarFrame\n firstDayOfWeek={props.firstDayOfWeek}\n locale={writtenIn}\n months={months}\n showMonthYearMenus={showMonthYearMenus}\n state={state}\n />\n </View>\n )\n}\n\nexport type { CalendarProps }\n\nexport { Calendar }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqJA,SAAAwB,SAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAV;CAAA,IAAAW;CAAA,IAAAV;CAAA,IAAAE;CAAA,IAAAS;CAAA,IAAAR;CAAA,IAAAC;CAAA,IAAAG,EAAA,OAAAD,IAAA;EAAmD,CAAA,CAAA,cAAAG,WAAAV,QAAAC,KAAAC,oBAAAU,IAAAT,OAAAC,QAAAC,iBAAA,GAAAM,SAAAJ;EAShCC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAR;EAAAQ,EAAA,KAAAG;EAAAH,EAAA,KAAAP;EAAAO,EAAA,KAAAL;EAAAK,EAAA,KAAAI;EAAAJ,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;CAAA,OAAA;EAAAK,YAAAF,EAAA;EAAAR,SAAAQ,EAAA;EAAAG,QAAAH,EAAA;EAAAP,MAAAO,EAAA;EAAAL,QAAAK,EAAA;EAAAI,KAAAJ,EAAA;EAAAJ,SAAAI,EAAA;EAAAH,kBAAAG,EAAA;CAAA;CALjB,MAAAN,qBAAAU,OAAAC,KAAAA,IAAA,QAAAD;CAMA,MAAAE,YAAkBlB,YAAYI,MAAM;CACpC,MAA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GACYb;GACbmB;EAAK,CAAA;EACZb,EAAA,MAAAO;EAAAP,EAAA,MAAAG,MAAAgB;EAAAnB,EAAA,MAAAN;EAAAM,EAAA,MAAAa;EAAAb,EAAA,MAAAM;EAAAN,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,IAAAoB;CAAA,IAAApB,EAAA,QAAAP,OAAAO,EAAA,QAAAgB,MAAAhB,EAAA,QAAAiB,MAAAjB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAJ,QAAA;EAbJwB,KAAA,oBAAC,MAAD;GACc,cAAAJ;GACPvB;GACA,MAAA;GACE,OAAAwB;GACCrB;GAERsB,UAAAA;EAPG,CAAA;EAcElB,EAAA,MAAAP;EAAAO,EAAA,MAAAgB;EAAAhB,EAAA,MAAAiB;EAAAjB,EAAA,MAAAkB;EAAAlB,EAAA,MAAAJ;EAAAI,EAAA,MAAAoB;CAAA,OAAAA,KAAApB,EAAA;CAAA,OAdPoB;AAcO"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CarouselLayout } from "../../carousel/arrangement.js";
|
|
2
|
+
import { View, ViewProps } from "react-native";
|
|
3
|
+
import { ComponentRef, ReactNode, Ref } from "react";
|
|
4
|
+
//#region src/components/carousel/index.d.ts
|
|
5
|
+
type CarouselItemProps = Omit<ViewProps, 'children'> & {
|
|
6
|
+
/** What the item shows: usually an image, which the item masks. */
|
|
7
|
+
readonly children?: ReactNode;
|
|
8
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
9
|
+
};
|
|
10
|
+
type CarouselProps = Omit<ViewProps, 'children'> & {
|
|
11
|
+
/** The items: `Carousel.Item` for each. */
|
|
12
|
+
readonly children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* The large item's preferred width, in dp. Multi-browse lays out as many
|
|
15
|
+
* as fit and narrows them where they do not; uncontained draws every item
|
|
16
|
+
* at it; hero takes its large item's width from the carousel's.
|
|
17
|
+
* @default 240
|
|
18
|
+
*/
|
|
19
|
+
readonly itemSize?: number;
|
|
20
|
+
/**
|
|
21
|
+
* What the carousel shows, for a screen reader. Required rather than
|
|
22
|
+
* optional: a carousel is a region, and a region with no name is one a
|
|
23
|
+
* screen reader cannot introduce.
|
|
24
|
+
*/
|
|
25
|
+
readonly label: string;
|
|
26
|
+
/**
|
|
27
|
+
* Which of the page's layouts the carousel draws.
|
|
28
|
+
* @default 'multi-browse'
|
|
29
|
+
*/
|
|
30
|
+
readonly layout?: CarouselLayout;
|
|
31
|
+
/**
|
|
32
|
+
* What the next button is called. Left out, the library names it in the
|
|
33
|
+
* reader's locale — "Next slide" in English.
|
|
34
|
+
*/
|
|
35
|
+
readonly nextLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* What the previous button is called. Left out, the library names it in
|
|
38
|
+
* the reader's locale — "Previous slide" in English.
|
|
39
|
+
*/
|
|
40
|
+
readonly previousLabel?: string;
|
|
41
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A row of items that scrolls on and off the screen, in the carousel page's
|
|
45
|
+
* multi-browse, hero or uncontained layout. Name it with `label`, and give it
|
|
46
|
+
* a `Carousel.Item` for each item.
|
|
47
|
+
*
|
|
48
|
+
* ```tsx
|
|
49
|
+
* <Carousel label="Label">
|
|
50
|
+
* <Carousel.Item><Image alt="First item" source={first} /></Carousel.Item>
|
|
51
|
+
* <Carousel.Item><Image alt="Second item" source={second} /></Carousel.Item>
|
|
52
|
+
* </Carousel>
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* `style`, `ref` and `testID` land on the carousel as a whole, which is the
|
|
56
|
+
* view a layout positions, and a `style` there applies over its own.
|
|
57
|
+
*/
|
|
58
|
+
declare function Carousel({ children, itemSize, label, layout, nextLabel, previousLabel, style, ...props }: CarouselProps): import("react").JSX.Element;
|
|
59
|
+
declare namespace Carousel {
|
|
60
|
+
var Item: typeof CarouselItem;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One item. It is named by which of how many it is — "2 of 6" — unless it is
|
|
64
|
+
* given an `aria-label` of its own.
|
|
65
|
+
*
|
|
66
|
+
* `style`, `ref` and `testID` land on the item, the view with the corner that
|
|
67
|
+
* cuts what it holds to the width it is drawn at.
|
|
68
|
+
*/
|
|
69
|
+
declare function CarouselItem({ children, style, ...props }: CarouselItemProps): import("react").JSX.Element;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { Carousel, CarouselItem, type CarouselItemProps, type CarouselLayout, type CarouselProps };
|
|
72
|
+
//# sourceMappingURL=index.d.ts.map
|