@ankhorage/zora 28.8.3 → 28.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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/capabilities/index.js +133 -5
- package/dist/capabilities/index.js.map +8 -7
- package/dist/constants/authoring.d.ts +4 -3
- package/dist/constants/authoring.d.ts.map +1 -1
- package/dist/constants/authoring.js +3 -0
- package/dist/constants/authoring.js.map +1 -1
- package/dist/features/accordion/accordionItemMeta.d.ts +1 -1
- package/dist/features/bottom-sheet/bottomSheetMeta.d.ts +1 -1
- package/dist/features/calendar/adapters/inbound/Calendar.d.ts +1 -1
- package/dist/features/calendar/adapters/inbound/Calendar.d.ts.map +1 -1
- package/dist/features/calendar/adapters/inbound/Calendar.js +207 -75
- package/dist/features/calendar/adapters/inbound/Calendar.js.map +1 -1
- package/dist/features/calendar/calendarMeta.d.ts +106 -4
- package/dist/features/calendar/calendarMeta.d.ts.map +1 -1
- package/dist/features/calendar/calendarMeta.js +44 -4
- package/dist/features/calendar/calendarMeta.js.map +1 -1
- package/dist/features/calendar/public.d.ts +1 -1
- package/dist/features/calendar/public.d.ts.map +1 -1
- package/dist/features/calendar/public.js.map +1 -1
- package/dist/features/card/cardMeta.d.ts +1 -1
- package/dist/features/card/mediaCardMeta.d.ts +1 -1
- package/dist/features/card/postCardMeta.d.ts +1 -1
- package/dist/features/chat/messageBubbleMeta.d.ts +1 -1
- package/dist/features/data-table/dataTableMeta.d.ts +10 -0
- package/dist/features/data-table/dataTableMeta.d.ts.map +1 -1
- package/dist/features/data-table/dataTableMeta.js +7 -0
- package/dist/features/data-table/dataTableMeta.js.map +1 -1
- package/dist/features/dialog/dialogMeta.d.ts +2 -2
- package/dist/features/gradient/gradientMeta.d.ts +1 -1
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +1 -1
- package/dist/features/layout/gridMeta.d.ts +1 -1
- package/dist/features/layout/screenMeta.d.ts +1 -1
- package/dist/features/layout/scrollViewMeta.d.ts +1 -1
- package/dist/features/layout/viewMeta.d.ts +1 -1
- package/dist/features/list/flatListMeta.d.ts +1 -1
- package/dist/features/list/sectionListMeta.d.ts +1 -1
- package/dist/features/master-detail/masterDetailMeta.d.ts +1 -1
- package/dist/features/popover/adapters/inbound/Popover.js +6 -3
- package/dist/features/popover/adapters/inbound/Popover.js.map +1 -1
- package/dist/features/popover/popoverMeta.d.ts +101 -0
- package/dist/features/popover/popoverMeta.d.ts.map +1 -0
- package/dist/features/popover/popoverMeta.js +78 -0
- package/dist/features/popover/popoverMeta.js.map +1 -0
- package/dist/features/reader/meta.d.ts +2 -2
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.d.ts.map +1 -1
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js +2 -0
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js.map +1 -1
- package/dist/features/registry/bindableComponentMeta.d.ts +2 -2
- package/dist/features/registry/componentMeta.d.ts.map +1 -1
- package/dist/features/registry/componentMeta.js +2 -0
- package/dist/features/registry/componentMeta.js.map +1 -1
- package/dist/features/scanner/meta.d.ts +2 -2
- package/dist/features/section/screenSectionMeta.d.ts +1 -1
- package/dist/features/surface/surfaceMeta.d.ts +1 -1
- package/dist/features/tabs/tabPanelMeta.d.ts +1 -1
- package/dist/readerFree.d.ts +1 -0
- package/dist/readerFree.d.ts.map +1 -1
- package/dist/readerFree.js +1 -0
- package/dist/readerFree.js.map +1 -1
- package/dist/types/calendar.d.ts +40 -19
- package/dist/types/calendar.d.ts.map +1 -1
- package/dist/types/calendar.js.map +1 -1
- package/dist/types/popover.d.ts +4 -1
- package/dist/types/popover.d.ts.map +1 -1
- package/dist/types/popover.js.map +1 -1
- package/package.json +102 -1
- package/src/constants/authoring.ts +3 -0
- package/src/features/calendar/adapters/inbound/Calendar.interaction.test.tsx +95 -0
- package/src/features/calendar/adapters/inbound/Calendar.tsx +425 -135
- package/src/features/calendar/calendarMeta.ts +44 -4
- package/src/features/calendar/public.test.ts +8 -5
- package/src/features/calendar/public.ts +4 -0
- package/src/features/data-table/adapters/inbound/DataTable.test.tsx +52 -1
- package/src/features/data-table/dataTableMeta.test.ts +8 -1
- package/src/features/data-table/dataTableMeta.ts +7 -0
- package/src/features/popover/adapters/inbound/Popover.tsx +17 -2
- package/src/features/popover/manifest.test.tsx +153 -0
- package/src/features/popover/popoverMeta.ts +79 -0
- package/src/features/popover/public.test.ts +2 -1
- package/src/features/registry/ZORA_BASE_COMPONENT_REGISTRY.ts +2 -0
- package/src/features/registry/componentMeta.test.ts +2 -0
- package/src/features/registry/componentMeta.ts +2 -0
- package/src/features/registry/featureManifest.test.ts +11 -0
- package/src/readerFree.ts +6 -0
- package/src/types/calendar.ts +44 -19
- package/src/types/popover.ts +5 -1
- package/src/webPackageExports.test.ts +1 -0
- package/web-dist/chunks/Accordion-59x6e7bs.js +200 -0
- package/web-dist/chunks/Accordion-q2yxtdzc.js +426 -0
- package/web-dist/components/calendar/Calendar.d.ts +2 -2
- package/web-dist/components/calendar/Calendar.dependency-2.d.ts +165 -0
- package/web-dist/components/calendar/Calendar.js +2 -1
- package/web-dist/components/calendar/Calendar.types-0.d.ts +45 -19
- package/web-dist/components/calendar/index.d.ts +1 -1
- package/web-dist/components/date-picker/DatePicker.js +2 -1
- package/web-dist/components/popover/Popover.js +10 -2
- package/web-dist/components/popover/Popover.types-0.d.ts +4 -1
- package/web-dist/components/time-grid/TimeGrid.js +4 -198
- package/web-dist/manifest.json +6 -2
- package/web-dist/chunks/Accordion-v3bmbnfh.js +0 -237
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import {
|
|
3
|
-
withZoraThemeScope
|
|
4
|
-
} from "./Accordion-zhgty1ae.js";
|
|
5
|
-
import {
|
|
6
|
-
Button2
|
|
7
|
-
} from "./Accordion-e6ettgh0.js";
|
|
8
|
-
import {
|
|
9
|
-
View2
|
|
10
|
-
} from "./Accordion-k9n1yse4.js";
|
|
11
|
-
import {
|
|
12
|
-
GridView2
|
|
13
|
-
} from "./Accordion-0zk0xp73.js";
|
|
14
|
-
import {
|
|
15
|
-
Text2
|
|
16
|
-
} from "./Accordion-6gc0jw1n.js";
|
|
17
|
-
|
|
18
|
-
// src/features/calendar/adapters/inbound/Calendar.tsx
|
|
19
|
-
import React from "react";
|
|
20
|
-
|
|
21
|
-
// src/features/calendar/application/createCalendarMonth.ts
|
|
22
|
-
function createCalendarMonth(month, weekStartsOn) {
|
|
23
|
-
const firstDay = startOfLocalMonth(month);
|
|
24
|
-
const leadingDays = (firstDay.getDay() - weekStartsOn + 7) % 7;
|
|
25
|
-
return Array.from({ length: 42 }, (_, index) => {
|
|
26
|
-
const date = new Date(firstDay.getFullYear(), firstDay.getMonth(), index - leadingDays + 1);
|
|
27
|
-
return {
|
|
28
|
-
date,
|
|
29
|
-
id: formatLocalDate(date),
|
|
30
|
-
inDisplayedMonth: date.getMonth() === firstDay.getMonth()
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function formatLocalDate(value) {
|
|
35
|
-
const year = String(value.getFullYear()).padStart(4, "0");
|
|
36
|
-
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
37
|
-
const day = String(value.getDate()).padStart(2, "0");
|
|
38
|
-
return `${year}-${month}-${day}`;
|
|
39
|
-
}
|
|
40
|
-
function startOfLocalMonth(value) {
|
|
41
|
-
return new Date(value.getFullYear(), value.getMonth(), 1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/features/calendar/application/isCalendarDateDisabled.ts
|
|
45
|
-
function isCalendarDateDisabled({
|
|
46
|
-
date,
|
|
47
|
-
disabledDateIds,
|
|
48
|
-
isDateDisabled,
|
|
49
|
-
maxDate,
|
|
50
|
-
minDate
|
|
51
|
-
}) {
|
|
52
|
-
return minDate !== undefined && compareLocalDates(date, minDate) < 0 || maxDate !== undefined && compareLocalDates(date, maxDate) > 0 || disabledDateIds.has(formatCalendarDate(date)) || isDateDisabled?.(date) === true;
|
|
53
|
-
}
|
|
54
|
-
function compareLocalDates(left, right) {
|
|
55
|
-
return startOfLocalDay(left).getTime() - startOfLocalDay(right).getTime();
|
|
56
|
-
}
|
|
57
|
-
function startOfLocalDay(value) {
|
|
58
|
-
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
59
|
-
}
|
|
60
|
-
function formatCalendarDate(value) {
|
|
61
|
-
const year = String(value.getFullYear()).padStart(4, "0");
|
|
62
|
-
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
63
|
-
const day = String(value.getDate()).padStart(2, "0");
|
|
64
|
-
return `${year}-${month}-${day}`;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/features/calendar/adapters/inbound/Calendar.tsx
|
|
68
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
69
|
-
var GRID_COLUMNS = 7;
|
|
70
|
-
var GRID_ROWS = 6;
|
|
71
|
-
var Calendar2 = withZoraThemeScope(CalendarInner);
|
|
72
|
-
function CalendarInner({
|
|
73
|
-
defaultDisplayedMonth,
|
|
74
|
-
density = "regular",
|
|
75
|
-
disabledDates = [],
|
|
76
|
-
displayedMonth: controlledDisplayedMonth,
|
|
77
|
-
interactionPolicy,
|
|
78
|
-
isDateDisabled,
|
|
79
|
-
locale,
|
|
80
|
-
maxDate,
|
|
81
|
-
minDate,
|
|
82
|
-
onDisplayedMonthChange,
|
|
83
|
-
onSelectedDateChange,
|
|
84
|
-
selectedDate,
|
|
85
|
-
testID,
|
|
86
|
-
weekStartsOn = 0
|
|
87
|
-
}) {
|
|
88
|
-
const [uncontrolledDisplayedMonth, setUncontrolledDisplayedMonth] = React.useState(() => startOfLocalMonth2(defaultDisplayedMonth ?? selectedDate ?? minDate ?? new Date));
|
|
89
|
-
const displayedMonth = startOfLocalMonth2(controlledDisplayedMonth ?? uncontrolledDisplayedMonth);
|
|
90
|
-
const cellSize = density === "compact" ? 42 : 48;
|
|
91
|
-
const gridWidth = cellSize * GRID_COLUMNS;
|
|
92
|
-
const gridHeight = cellSize * GRID_ROWS;
|
|
93
|
-
const cells = React.useMemo(() => createCalendarMonth(displayedMonth, weekStartsOn), [displayedMonth, weekStartsOn]);
|
|
94
|
-
const gridItems = React.useMemo(() => cells.map((cell, index) => ({
|
|
95
|
-
height: cellSize,
|
|
96
|
-
id: cell.id,
|
|
97
|
-
width: cellSize,
|
|
98
|
-
x: index % GRID_COLUMNS * cellSize,
|
|
99
|
-
y: Math.floor(index / GRID_COLUMNS) * cellSize
|
|
100
|
-
})), [cellSize, cells]);
|
|
101
|
-
const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);
|
|
102
|
-
const disabledDateIds = React.useMemo(() => new Set(disabledDates.map(formatCalendarDate2)), [disabledDates]);
|
|
103
|
-
const weekdays = React.useMemo(() => createWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);
|
|
104
|
-
const setDisplayedMonth = React.useCallback((month) => {
|
|
105
|
-
const nextMonth = startOfLocalMonth2(month);
|
|
106
|
-
if (controlledDisplayedMonth === undefined)
|
|
107
|
-
setUncontrolledDisplayedMonth(nextMonth);
|
|
108
|
-
onDisplayedMonthChange?.(nextMonth);
|
|
109
|
-
}, [controlledDisplayedMonth, onDisplayedMonthChange]);
|
|
110
|
-
const previousMonth = addMonths(displayedMonth, -1);
|
|
111
|
-
const nextMonth = addMonths(displayedMonth, 1);
|
|
112
|
-
return /* @__PURE__ */ jsxs(View2, {
|
|
113
|
-
accessibilityLabel: "Calendar",
|
|
114
|
-
gap: density === "compact" ? "s" : "m",
|
|
115
|
-
testID,
|
|
116
|
-
children: [
|
|
117
|
-
/* @__PURE__ */ jsxs(View2, {
|
|
118
|
-
align: "center",
|
|
119
|
-
direction: "row",
|
|
120
|
-
justify: "space-between",
|
|
121
|
-
children: [
|
|
122
|
-
/* @__PURE__ */ jsx(Button2, {
|
|
123
|
-
disabled: !monthIntersectsRange(previousMonth, minDate, maxDate),
|
|
124
|
-
interactionPolicy,
|
|
125
|
-
onPress: () => setDisplayedMonth(previousMonth),
|
|
126
|
-
size: "s",
|
|
127
|
-
variant: "ghost",
|
|
128
|
-
children: "Previous"
|
|
129
|
-
}),
|
|
130
|
-
/* @__PURE__ */ jsx(Text2, {
|
|
131
|
-
accessibilityRole: "header",
|
|
132
|
-
align: "center",
|
|
133
|
-
variant: "label",
|
|
134
|
-
weight: "semiBold",
|
|
135
|
-
children: formatMonthLabel(displayedMonth, locale)
|
|
136
|
-
}),
|
|
137
|
-
/* @__PURE__ */ jsx(Button2, {
|
|
138
|
-
disabled: !monthIntersectsRange(nextMonth, minDate, maxDate),
|
|
139
|
-
interactionPolicy,
|
|
140
|
-
onPress: () => setDisplayedMonth(nextMonth),
|
|
141
|
-
size: "s",
|
|
142
|
-
variant: "ghost",
|
|
143
|
-
children: "Next"
|
|
144
|
-
})
|
|
145
|
-
]
|
|
146
|
-
}),
|
|
147
|
-
/* @__PURE__ */ jsx(View2, {
|
|
148
|
-
direction: "row",
|
|
149
|
-
children: weekdays.map((weekday) => /* @__PURE__ */ jsx(View2, {
|
|
150
|
-
width: cellSize,
|
|
151
|
-
children: /* @__PURE__ */ jsx(Text2, {
|
|
152
|
-
align: "center",
|
|
153
|
-
emphasis: "muted",
|
|
154
|
-
variant: "caption",
|
|
155
|
-
weight: "semiBold",
|
|
156
|
-
children: weekday.label
|
|
157
|
-
})
|
|
158
|
-
}, weekday.id))
|
|
159
|
-
}),
|
|
160
|
-
/* @__PURE__ */ jsx(GridView2, {
|
|
161
|
-
contentHeight: gridHeight,
|
|
162
|
-
contentWidth: gridWidth,
|
|
163
|
-
height: gridHeight,
|
|
164
|
-
interactionPolicy,
|
|
165
|
-
items: gridItems,
|
|
166
|
-
overscanPixels: 0,
|
|
167
|
-
renderItem: (item) => {
|
|
168
|
-
const cell = cellsById.get(item.id);
|
|
169
|
-
if (!cell)
|
|
170
|
-
return null;
|
|
171
|
-
const selected = selectedDate !== null && selectedDate !== undefined && isSameLocalDay(selectedDate, cell.date);
|
|
172
|
-
const disabled = isCalendarDateDisabled({
|
|
173
|
-
date: cell.date,
|
|
174
|
-
disabledDateIds,
|
|
175
|
-
isDateDisabled,
|
|
176
|
-
maxDate,
|
|
177
|
-
minDate
|
|
178
|
-
});
|
|
179
|
-
const selectCell = () => {
|
|
180
|
-
if (!cell.inDisplayedMonth)
|
|
181
|
-
setDisplayedMonth(cell.date);
|
|
182
|
-
onSelectedDateChange?.(cell.date);
|
|
183
|
-
};
|
|
184
|
-
return /* @__PURE__ */ jsx(Button2, {
|
|
185
|
-
accessibilityState: { disabled, selected },
|
|
186
|
-
color: selected ? "primary" : "neutral",
|
|
187
|
-
disabled,
|
|
188
|
-
interactionPolicy,
|
|
189
|
-
onPress: selectCell,
|
|
190
|
-
size: "s",
|
|
191
|
-
testID: testID ? `${testID}-day-${cell.id}` : undefined,
|
|
192
|
-
variant: selected ? "solid" : cell.inDisplayedMonth ? "ghost" : "outline",
|
|
193
|
-
children: cell.date.getDate()
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
testID: testID ? `${testID}-grid` : undefined,
|
|
197
|
-
viewportInteraction: "locked",
|
|
198
|
-
width: gridWidth
|
|
199
|
-
})
|
|
200
|
-
]
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
function createWeekdayLabels(locale, weekStartsOn) {
|
|
204
|
-
const formatter = new Intl.DateTimeFormat(locale, { weekday: "short" });
|
|
205
|
-
const sunday = new Date(2023, 0, 1);
|
|
206
|
-
return Array.from({ length: GRID_COLUMNS }, (_, index) => {
|
|
207
|
-
const day = new Date(sunday.getFullYear(), sunday.getMonth(), sunday.getDate() + (weekStartsOn + index) % GRID_COLUMNS);
|
|
208
|
-
return { id: String(index), label: formatter.format(day) };
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
function addMonths(month, count) {
|
|
212
|
-
return new Date(month.getFullYear(), month.getMonth() + count, 1);
|
|
213
|
-
}
|
|
214
|
-
function startOfLocalMonth2(value) {
|
|
215
|
-
return new Date(value.getFullYear(), value.getMonth(), 1);
|
|
216
|
-
}
|
|
217
|
-
function formatCalendarDate2(value) {
|
|
218
|
-
const year = String(value.getFullYear()).padStart(4, "0");
|
|
219
|
-
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
220
|
-
const day = String(value.getDate()).padStart(2, "0");
|
|
221
|
-
return `${year}-${month}-${day}`;
|
|
222
|
-
}
|
|
223
|
-
function compareLocalDates2(left, right) {
|
|
224
|
-
return formatCalendarDate2(left).localeCompare(formatCalendarDate2(right));
|
|
225
|
-
}
|
|
226
|
-
function monthIntersectsRange(month, minDate, maxDate) {
|
|
227
|
-
const first = startOfLocalMonth2(month);
|
|
228
|
-
const last = new Date(first.getFullYear(), first.getMonth() + 1, 0);
|
|
229
|
-
return (!minDate || compareLocalDates2(last, minDate) >= 0) && (!maxDate || compareLocalDates2(first, maxDate) <= 0);
|
|
230
|
-
}
|
|
231
|
-
function isSameLocalDay(left, right) {
|
|
232
|
-
return formatCalendarDate2(left) === formatCalendarDate2(right);
|
|
233
|
-
}
|
|
234
|
-
function formatMonthLabel(value, locale) {
|
|
235
|
-
return new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(value);
|
|
236
|
-
}
|
|
237
|
-
export { Calendar2 };
|