rift-ds 1.30.0 → 1.31.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 +6 -4
- package/behaviors/locale.d.ts +7 -0
- package/behaviors/locale.js +5 -0
- package/behaviors/shell.css +33 -0
- package/bin/rift-ds.mjs +35 -9
- package/bin/templates/blocks/app/planner/PlannerGrid.tsx +58 -0
- package/bin/templates/blocks/app/planner/Requests.tsx +42 -0
- package/bin/templates/blocks/app/planner/page.module.css +17 -0
- package/bin/templates/blocks/app/planner/page.tsx +32 -0
- package/bin/templates/blocks/registry.json +14 -0
- package/bin/templates/chat/app/api/chat/route.actions.ts +108 -0
- package/bin/templates/chat/components/chat/ChatMount.actions.tsx +55 -0
- package/bin/templates/chat/components/chat/ChatMount.tsx +14 -1
- package/bin/templates/chat/components/chat/proposals/ProposalCard.tsx +81 -0
- package/bin/templates/chat/components/chat/proposals/actions.ts +60 -0
- package/bin/templates/chat/components/chat/proposals/confirmation.ts +9 -0
- package/bin/templates/chat/components/chat/proposals/renderers.tsx +9 -0
- package/chat/ChatLauncher.d.ts +4 -1
- package/chat/ChatLauncher.js +6 -1
- package/chat/ChatProvider.d.ts +19 -2
- package/chat/ChatProvider.js +26 -3
- package/chat/ChatWidget.css +10 -0
- package/chat/ChatWidget.d.ts +2 -1
- package/chat/ChatWidget.js +8 -6
- package/chat/actions.d.ts +52 -6
- package/chat/actions.js +53 -5
- package/chat/contextSchema.d.ts +76 -0
- package/chat/contextSchema.js +58 -0
- package/chat/index.d.ts +2 -2
- package/chat/index.js +5 -1
- package/chat/registry.json.d.ts +2 -2
- package/chat/registry.json.js +1 -1
- package/chat/server.d.ts +18 -2
- package/chat/server.js +10 -1
- package/chat/suggestions.d.ts +7 -0
- package/chat/suggestions.js +13 -1
- package/chat/types.d.ts +23 -0
- package/chat/useChat.d.ts +2 -2
- package/chat/useChat.js +15 -1
- package/components/AppSidebar/AppSidebar.css +12 -0
- package/components/ButtonGroup/ButtonGroup.css +10 -1
- package/components/Chart/RadarChart.js +24 -10
- package/components/DataTable/DataTable.css +17 -2
- package/components/DataTable/DataTable.d.ts +14 -2
- package/components/DataTable/DataTable.js +13 -2
- package/components/DataTable/periodColumns.d.ts +37 -0
- package/components/DataTable/periodColumns.js +48 -0
- package/components/DatePicker/DatePicker.css +22 -6
- package/components/DatePicker/DatePicker.d.ts +2 -1
- package/components/DatePicker/DatePicker.js +2 -2
- package/components/DateRangePicker/DateRangePicker.js +2 -2
- package/components/DecisionRow/DecisionRow.css +46 -0
- package/components/DecisionRow/DecisionRow.d.ts +62 -0
- package/components/DecisionRow/DecisionRow.js +93 -0
- package/components/EventCalendar/EventCalendar.css +54 -0
- package/components/EventCalendar/EventCalendar.d.ts +27 -5
- package/components/EventCalendar/EventCalendar.js +50 -15
- package/components/FunnelChart/FunnelChart.js +33 -22
- package/components/Globe/Globe.css +7 -0
- package/components/Globe/Globe.js +1 -1
- package/components/Table/Table.css +7 -0
- package/components/Table/Table.js +1 -1
- package/components/Tabs/Tabs.css +21 -3
- package/components/Timeline/Timeline.css +8 -0
- package/components/Widget/Widget.css +2 -0
- package/components/WorldMap/WorldMap.css +15 -0
- package/components/WorldMap/WorldMap.js +56 -1
- package/components/registry.json +20 -3
- package/components/registry.json.d.ts +20 -3
- package/components/registry.json.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +6 -0
- package/package.json +1 -1
- package/tokens/presets/blueprint.css +9 -0
- package/tokens/presets/bubblegum.css +9 -0
- package/tokens/presets/contrast.css +3 -3
- package/tokens/presets/coral.css +3 -3
- package/tokens/presets/ember.css +9 -0
- package/tokens/presets/getaway.css +9 -0
- package/tokens/presets/gold.css +3 -3
- package/tokens/presets/mono.css +3 -3
- package/tokens/presets/pink.css +3 -3
- package/tokens/presets/plum.css +3 -3
- package/tokens/presets/signal.css +9 -0
- package/tokens/presets/smoke.css +9 -0
- package/tokens/presets/velvet.css +9 -0
- package/tokens/presets/violet.css +3 -3
- package/tokens/presets/volt.css +9 -0
- package/tokens/presets/warm.css +3 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DEFAULT_LOCALE } from "../../behaviors/locale.js";
|
|
2
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
3
|
+
const isoOf = (date) => `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
|
|
4
|
+
function parse(start) {
|
|
5
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(start);
|
|
6
|
+
if (!match) throw new Error(`periodColumns: start must be YYYY-MM-DD, got ${JSON.stringify(start)}.`);
|
|
7
|
+
return new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));
|
|
8
|
+
}
|
|
9
|
+
function step(date, unit, n) {
|
|
10
|
+
if (unit === "month") return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + n, 1));
|
|
11
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() + n * (unit === "week" ? 7 : 1)));
|
|
12
|
+
}
|
|
13
|
+
function periodsOf({ start, count, unit, keyPrefix = "" }) {
|
|
14
|
+
const first = unit === "month" ? step(parse(start), "month", 0) : parse(start);
|
|
15
|
+
return Array.from({ length: Math.max(0, Math.floor(count)) }, (_, i) => {
|
|
16
|
+
const date = isoOf(step(first, unit, i));
|
|
17
|
+
return { key: `${keyPrefix}${date}`, date };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function defaultHeader(locale) {
|
|
21
|
+
const day = new Intl.DateTimeFormat(locale, { weekday: "short", day: "numeric", timeZone: "UTC" });
|
|
22
|
+
const week = new Intl.DateTimeFormat(locale, { month: "short", day: "numeric", timeZone: "UTC" });
|
|
23
|
+
const month = new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" });
|
|
24
|
+
return (date, unit) => (unit === "day" ? day : unit === "week" ? week : month).format(date);
|
|
25
|
+
}
|
|
26
|
+
function periodColumns({
|
|
27
|
+
locale = DEFAULT_LOCALE,
|
|
28
|
+
header,
|
|
29
|
+
column,
|
|
30
|
+
...run
|
|
31
|
+
}) {
|
|
32
|
+
const write = header ?? defaultHeader(locale);
|
|
33
|
+
const first = run.unit === "month" ? null : parse(run.start);
|
|
34
|
+
return periodsOf(run).map(({ key, date }, i) => ({
|
|
35
|
+
...column,
|
|
36
|
+
key,
|
|
37
|
+
header: write(first ? step(first, run.unit, i) : parse(date), run.unit)
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
const totalOf = (keys) => (values) => keys.reduce((sum, key) => {
|
|
41
|
+
const value = values[key];
|
|
42
|
+
return typeof value === "number" && Number.isFinite(value) ? sum + value : sum;
|
|
43
|
+
}, 0);
|
|
44
|
+
export {
|
|
45
|
+
periodColumns,
|
|
46
|
+
periodsOf,
|
|
47
|
+
totalOf
|
|
48
|
+
};
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
border-radius: var(--radius-300); /* 12px */
|
|
13
13
|
background-color: var(--color-input-bg-primary);
|
|
14
14
|
user-select: none;
|
|
15
|
+
/* Never wider than its container: in a column narrower than seven full
|
|
16
|
+
days, the days shrink with it (below) rather than running off it. */
|
|
17
|
+
max-width: 100%;
|
|
18
|
+
box-sizing: border-box;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
/* ============================================
|
|
@@ -76,7 +80,7 @@
|
|
|
76
80
|
|
|
77
81
|
.ds-date-picker__grid {
|
|
78
82
|
display: grid;
|
|
79
|
-
grid-template-columns: repeat(7, 1fr);
|
|
83
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
80
84
|
gap: var(--gap-050); /* 2px */
|
|
81
85
|
}
|
|
82
86
|
|
|
@@ -90,7 +94,7 @@
|
|
|
90
94
|
.ds-date-picker__row {
|
|
91
95
|
display: grid;
|
|
92
96
|
grid-column: 1 / -1;
|
|
93
|
-
grid-template-columns: repeat(7, 1fr);
|
|
97
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
94
98
|
grid-template-columns: subgrid;
|
|
95
99
|
column-gap: var(--gap-050); /* 2px, the grid's own gap */
|
|
96
100
|
}
|
|
@@ -119,8 +123,12 @@
|
|
|
119
123
|
display: flex;
|
|
120
124
|
align-items: center;
|
|
121
125
|
justify-content: center;
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
/* The full 36px day, shrinking square with its column when the picker is
|
|
127
|
+
squeezed, so seven days always fit and never overlap. */
|
|
128
|
+
margin-inline: auto;
|
|
129
|
+
width: 100%;
|
|
130
|
+
max-width: 36px;
|
|
131
|
+
aspect-ratio: 1;
|
|
124
132
|
padding: 0;
|
|
125
133
|
border: none;
|
|
126
134
|
border-radius: var(--radius-pill);
|
|
@@ -198,11 +206,19 @@
|
|
|
198
206
|
}
|
|
199
207
|
|
|
200
208
|
.ds-date-picker--compact .ds-date-picker__cell {
|
|
201
|
-
width: 28px;
|
|
202
|
-
height: 28px;
|
|
209
|
+
max-width: 28px;
|
|
203
210
|
font-size: var(--font-caption-size);
|
|
204
211
|
}
|
|
205
212
|
|
|
213
|
+
/* On a phone the picker gives up some of its own padding before its days
|
|
214
|
+
give up size, so a squeezed picker keeps each day at least a 24px
|
|
215
|
+
target. */
|
|
216
|
+
@media (max-width: 480px) {
|
|
217
|
+
.ds-date-picker {
|
|
218
|
+
padding: var(--padding-300);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
206
222
|
/* ============================================
|
|
207
223
|
DISABLED STATE
|
|
208
224
|
============================================ */
|
|
@@ -32,7 +32,8 @@ type DatePickerOwnProps = {
|
|
|
32
32
|
/**
|
|
33
33
|
* The visible weekday column headers: seven entries, Sunday first, laid
|
|
34
34
|
* out from `weekStartsOn`. Defaults to the two-letter abbreviations ("Su"
|
|
35
|
-
* to "Sa") in English and the short weekday names in `locale` otherwise
|
|
35
|
+
* to "Sa") in English and the short weekday names in `locale` otherwise,
|
|
36
|
+
* or its narrow names where the short ones are whole words (Arabic); a
|
|
36
37
|
* list of any other length falls back to the default.
|
|
37
38
|
*/
|
|
38
39
|
weekdayLabels?: string[];
|
|
@@ -4,7 +4,7 @@ import React, { useMemo, useState, useRef, useEffect } from "react";
|
|
|
4
4
|
import "./DatePicker.css";
|
|
5
5
|
import "../../fonts/material-symbols.css";
|
|
6
6
|
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
7
|
-
import { weekStartOf, rotateWeek, isEnglish, weekdayNamesIn } from "../../behaviors/locale.js";
|
|
7
|
+
import { weekStartOf, rotateWeek, isEnglish, weekdayHeadersIn, weekdayNamesIn } from "../../behaviors/locale.js";
|
|
8
8
|
import { MonthGrid } from "./MonthGrid.js";
|
|
9
9
|
import { parseDate, monthLabelIn, dayLabelIn, weekdaysOr, EN_DAYS, formatDate, visuallyHidden, isSameDay, keyMove } from "./calendar.js";
|
|
10
10
|
const DatePicker = React.forwardRef(
|
|
@@ -36,7 +36,7 @@ const DatePicker = React.forwardRef(
|
|
|
36
36
|
const monthLabel = useMemo(() => monthLabelProp ?? monthLabelIn(locale), [monthLabelProp, locale]);
|
|
37
37
|
const dayLabel = useMemo(() => dayLabelProp ?? dayLabelIn(locale), [dayLabelProp, locale]);
|
|
38
38
|
const weekdays = rotateWeek(
|
|
39
|
-
weekdaysOr(weekdayLabels, isEnglish(locale) ? EN_DAYS :
|
|
39
|
+
weekdaysOr(weekdayLabels, isEnglish(locale) ? EN_DAYS : weekdayHeadersIn(locale)),
|
|
40
40
|
weekStart
|
|
41
41
|
);
|
|
42
42
|
const weekdayFullNames = rotateWeek(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useMemo, useRef, useEffect } from "react";
|
|
4
4
|
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
5
|
-
import { weekStartOf, rotateWeek, isEnglish, weekdayNamesIn } from "../../behaviors/locale.js";
|
|
5
|
+
import { weekStartOf, rotateWeek, isEnglish, weekdayHeadersIn, weekdayNamesIn } from "../../behaviors/locale.js";
|
|
6
6
|
import { MonthGrid } from "../DatePicker/MonthGrid.js";
|
|
7
7
|
import { parseDate, monthLabelIn, fullDateIn, weekdaysOr, EN_DAYS, formatDate, isSameDay, visuallyHidden, addMonths, keyMove, daysBetween } from "../DatePicker/calendar.js";
|
|
8
8
|
import { Chip } from "../Chip/Chip.js";
|
|
@@ -54,7 +54,7 @@ function DateRangePicker({
|
|
|
54
54
|
const monthLabel = useMemo(() => monthLabelProp ?? monthLabelIn(locale), [monthLabelProp, locale]);
|
|
55
55
|
const fullDate = useMemo(() => fullDateIn(locale), [locale]);
|
|
56
56
|
const weekdays = rotateWeek(
|
|
57
|
-
weekdaysOr(weekdayLabels, isEnglish(locale) ? EN_DAYS :
|
|
57
|
+
weekdaysOr(weekdayLabels, isEnglish(locale) ? EN_DAYS : weekdayHeadersIn(locale)),
|
|
58
58
|
weekStart
|
|
59
59
|
);
|
|
60
60
|
const weekdayFullNames = rotateWeek(weekdaysOr(weekdayNames, weekdayNamesIn(locale, "long")), weekStart);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DECISION ROW
|
|
3
|
+
WidgetRow with a decision's lifecycle: the row's own layout, faces and
|
|
4
|
+
gaps are WidgetRow's (Widget.css), so a decision sits in a Widget beside
|
|
5
|
+
plain rows with nothing restated here. This file only adds the root and
|
|
6
|
+
the focus ring the row takes when it settles with nowhere else for focus
|
|
7
|
+
to go.
|
|
8
|
+
============================================ */
|
|
9
|
+
|
|
10
|
+
/* Base */
|
|
11
|
+
|
|
12
|
+
.ds-decision-row {
|
|
13
|
+
display: block;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
border-radius: var(--radius-300);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* States */
|
|
19
|
+
|
|
20
|
+
/* A settled row with no Undo holds focus itself after the reader's press,
|
|
21
|
+
so the ring is the row's, in the focus colour every control uses. */
|
|
22
|
+
.ds-decision-row:focus-visible {
|
|
23
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
24
|
+
outline-offset: 2px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* The settled mark sits in the actions slot as one item. */
|
|
28
|
+
.ds-decision-row__outcome {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Narrow rows: the title keeps a floor, stated on the icon scale, and the
|
|
33
|
+
decision wraps to its own line under it, set to the row's end, rather
|
|
34
|
+
than squeezing the title to nothing and running off the edge. */
|
|
35
|
+
.ds-decision-row .ds-widget-row {
|
|
36
|
+
flex-wrap: wrap;
|
|
37
|
+
row-gap: var(--gap-200);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ds-decision-row .ds-widget-row__main {
|
|
41
|
+
flex-basis: calc(var(--icon-size-1200) * 3);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ds-decision-row .ds-widget-row__actions {
|
|
45
|
+
margin-inline-start: auto;
|
|
46
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Where a decision stands: waiting on the reader, or settled one way or the other. */
|
|
3
|
+
export type DecisionRowStatus = 'pending' | 'accepted' | 'declined';
|
|
4
|
+
/** Props owned by DecisionRow itself; everything else falls through to the row's root `<div>`. */
|
|
5
|
+
type DecisionRowOwnProps = {
|
|
6
|
+
/** What is waiting on a decision: who asked and for what. Collides with the native `title` tooltip attribute on purpose: the row shows it. */
|
|
7
|
+
title: string;
|
|
8
|
+
/** A quiet second line: the dates, the amount, the reason given. */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** A leading mark: an Avatar, a StatusDot, an icon. Decorative unless the element names itself. */
|
|
11
|
+
leading?: React.ReactNode;
|
|
12
|
+
/** A trailing fact before the decision: when it was asked, how long it has waited. */
|
|
13
|
+
meta?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Where the decision stands, for controlled use. Pair with `onStatusChange`. Unset, the row keeps its own, starting at `defaultStatus`.
|
|
16
|
+
* @default "pending"
|
|
17
|
+
*/
|
|
18
|
+
status?: DecisionRowStatus;
|
|
19
|
+
/** Where it stands to begin with, for uncontrolled use. */
|
|
20
|
+
defaultStatus?: DecisionRowStatus;
|
|
21
|
+
/** Fires with the new status when the reader accepts, declines or undoes. */
|
|
22
|
+
onStatusChange?: (status: DecisionRowStatus) => void;
|
|
23
|
+
/** Fires when the reader accepts. */
|
|
24
|
+
onAccept?: () => void;
|
|
25
|
+
/** Fires when the reader declines. */
|
|
26
|
+
onDecline?: () => void;
|
|
27
|
+
/** Offers Undo on a settled row, which returns it to pending and fires this. Leave it unset where a decision cannot be reversed. */
|
|
28
|
+
onUndo?: () => void;
|
|
29
|
+
/** The accept button's colour: `destructive` for a decision whose yes takes something away (remove a member, delete a draft), as ActionCard's `tone` does for a change. */
|
|
30
|
+
tone?: 'default' | 'destructive';
|
|
31
|
+
/** The accept button's words. */
|
|
32
|
+
acceptLabel?: string;
|
|
33
|
+
/** The decline button's words. */
|
|
34
|
+
declineLabel?: string;
|
|
35
|
+
/** The settled mark's words once accepted. */
|
|
36
|
+
acceptedLabel?: string;
|
|
37
|
+
/** The settled mark's words once declined. */
|
|
38
|
+
declinedLabel?: string;
|
|
39
|
+
/** The undo button's words. */
|
|
40
|
+
undoLabel?: string;
|
|
41
|
+
/** What is announced when the row settles, given its title and the settled mark's words: "Accepted: Room booking". */
|
|
42
|
+
settledAnnouncement?: (title: string, outcome: string) => string;
|
|
43
|
+
/** Additional CSS classes */
|
|
44
|
+
className?: string;
|
|
45
|
+
/** A ref onto the row's root `<div>`. */
|
|
46
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
47
|
+
};
|
|
48
|
+
export interface DecisionRowProps extends DecisionRowOwnProps, Omit<React.HTMLAttributes<HTMLDivElement>, keyof DecisionRowOwnProps> {
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* DecisionRow: one item waiting on a yes or a no, as a row in a list. While
|
|
52
|
+
* it is pending it offers two buttons in the host's words (Approve and Deny,
|
|
53
|
+
* Accept and Decline, Keep and Discard); once decided it settles to a mark
|
|
54
|
+
* saying which, with Undo while the host can reverse it. It is WidgetRow with
|
|
55
|
+
* that lifecycle, so it sits in a Widget beside plain rows.
|
|
56
|
+
*
|
|
57
|
+
* The buttons leave the row when it settles, so focus moves with them, to
|
|
58
|
+
* Undo when there is one and to the row otherwise, and the outcome is
|
|
59
|
+
* announced, so a keyboard or screen-reader user is never left on nothing.
|
|
60
|
+
*/
|
|
61
|
+
export declare function DecisionRow({ title, description, leading, meta, status: statusProp, defaultStatus, onStatusChange, onAccept, onDecline, onUndo, tone, acceptLabel, declineLabel, acceptedLabel, declinedLabel, undoLabel, settledAnnouncement, className, ref, ...rest }: DecisionRowProps): React.JSX.Element;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
|
+
import { Badge } from "../Badge/Badge.js";
|
|
5
|
+
import { Button } from "../Button/Button.js";
|
|
6
|
+
import { WidgetRow } from "../Widget/Widget.js";
|
|
7
|
+
import "../../behaviors/visually-hidden.css";
|
|
8
|
+
import "./DecisionRow.css";
|
|
9
|
+
function DecisionRow({
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
leading,
|
|
13
|
+
meta,
|
|
14
|
+
status: statusProp,
|
|
15
|
+
defaultStatus = "pending",
|
|
16
|
+
onStatusChange,
|
|
17
|
+
onAccept,
|
|
18
|
+
onDecline,
|
|
19
|
+
onUndo,
|
|
20
|
+
tone = "default",
|
|
21
|
+
acceptLabel = "Accept",
|
|
22
|
+
declineLabel = "Decline",
|
|
23
|
+
acceptedLabel = "Accepted",
|
|
24
|
+
declinedLabel = "Declined",
|
|
25
|
+
undoLabel = "Undo",
|
|
26
|
+
settledAnnouncement = (rowTitle, outcome) => `${outcome}: ${rowTitle}`,
|
|
27
|
+
className = "",
|
|
28
|
+
ref,
|
|
29
|
+
...rest
|
|
30
|
+
}) {
|
|
31
|
+
const baseClass = "ds-decision-row";
|
|
32
|
+
const [ownStatus, setOwnStatus] = useState(defaultStatus);
|
|
33
|
+
const status = statusProp ?? ownStatus;
|
|
34
|
+
const rootRef = useRef(null);
|
|
35
|
+
const movedByPress = useRef(false);
|
|
36
|
+
const setRef = (node) => {
|
|
37
|
+
rootRef.current = node;
|
|
38
|
+
if (typeof ref === "function") ref(node);
|
|
39
|
+
else if (ref) ref.current = node;
|
|
40
|
+
};
|
|
41
|
+
const decide = (next) => {
|
|
42
|
+
movedByPress.current = true;
|
|
43
|
+
if (statusProp === void 0) setOwnStatus(next);
|
|
44
|
+
onStatusChange?.(next);
|
|
45
|
+
if (next === "accepted") onAccept?.();
|
|
46
|
+
else if (next === "declined") onDecline?.();
|
|
47
|
+
else onUndo?.();
|
|
48
|
+
};
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!movedByPress.current) return;
|
|
51
|
+
movedByPress.current = false;
|
|
52
|
+
const root = rootRef.current;
|
|
53
|
+
if (!root) return;
|
|
54
|
+
const target = status === "pending" ? root.querySelector(`.${baseClass}__accept`) : root.querySelector(`.${baseClass}__undo`) ?? root;
|
|
55
|
+
target?.focus();
|
|
56
|
+
}, [status]);
|
|
57
|
+
const settled = status !== "pending";
|
|
58
|
+
const outcome = status === "accepted" ? acceptedLabel : declinedLabel;
|
|
59
|
+
const actions = settled ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__outcome`, "aria-hidden": "true", children: /* @__PURE__ */ jsx(Badge, { variant: status === "accepted" ? "positive" : "neutral", label: outcome }) }),
|
|
61
|
+
onUndo && /* @__PURE__ */ jsx(Button, { className: `${baseClass}__undo`, variant: "tertiary", size: "compact", iconLeft: "undo", label: undoLabel, onClick: () => decide("pending") })
|
|
62
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
Button,
|
|
65
|
+
{
|
|
66
|
+
className: `${baseClass}__accept`,
|
|
67
|
+
variant: "secondary",
|
|
68
|
+
tone,
|
|
69
|
+
size: "compact",
|
|
70
|
+
label: acceptLabel,
|
|
71
|
+
onClick: () => decide("accepted")
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", tone: "neutral", size: "compact", label: declineLabel, onClick: () => decide("declined") })
|
|
75
|
+
] });
|
|
76
|
+
return /* @__PURE__ */ jsxs(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
...rest,
|
|
80
|
+
ref: setRef,
|
|
81
|
+
tabIndex: settled && !onUndo ? -1 : rest.tabIndex,
|
|
82
|
+
className: [baseClass, settled ? `${baseClass}--settled` : "", className].filter(Boolean).join(" "),
|
|
83
|
+
"data-status": status,
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ jsx(WidgetRow, { title, description, leading, meta, actions }),
|
|
86
|
+
/* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", role: "status", children: settled ? settledAnnouncement(title, outcome) : "" })
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
DecisionRow
|
|
93
|
+
};
|
|
@@ -412,6 +412,28 @@ button.ds-event-calendar__more:focus-visible {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
+
/* On a phone a month cell is too narrow for any title: a pill cut to one
|
|
416
|
+
letter says nothing. The month grid draws each event as its dot, the
|
|
417
|
+
dots of a day wrapping in a row under the date, and a day's events read
|
|
418
|
+
in full from the selected-day panel or the pill's own name. The week
|
|
419
|
+
and day views have the room, and keep their pills. */
|
|
420
|
+
@media (max-width: 480px) {
|
|
421
|
+
.ds-event-calendar:not(.ds-event-calendar--week):not(.ds-event-calendar--day) .ds-event-calendar__events {
|
|
422
|
+
flex-direction: row;
|
|
423
|
+
flex-wrap: wrap;
|
|
424
|
+
justify-content: center;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.ds-event-calendar:not(.ds-event-calendar--week):not(.ds-event-calendar--day) .ds-event-calendar__event {
|
|
428
|
+
padding: var(--padding-050);
|
|
429
|
+
background-color: transparent;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.ds-event-calendar:not(.ds-event-calendar--week):not(.ds-event-calendar--day) .ds-event-calendar__event-title {
|
|
433
|
+
display: none;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
415
437
|
/* ============================================
|
|
416
438
|
WEEK VIEW — one week, every event shown
|
|
417
439
|
The cells take the room a week has to give,
|
|
@@ -422,3 +444,35 @@ button.ds-event-calendar__more:focus-visible {
|
|
|
422
444
|
.ds-event-calendar--week .ds-event-calendar__cell {
|
|
423
445
|
min-height: calc(var(--control-height-default) * 5);
|
|
424
446
|
}
|
|
447
|
+
|
|
448
|
+
/* ============================================
|
|
449
|
+
DAY VIEW — one day, the week view's cell alone
|
|
450
|
+
============================================ */
|
|
451
|
+
|
|
452
|
+
.ds-event-calendar--day .ds-event-calendar__grid {
|
|
453
|
+
grid-template-columns: 1fr;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/* ============================================
|
|
457
|
+
SELECTED DAY — the host's panel for the chosen day
|
|
458
|
+
============================================ */
|
|
459
|
+
|
|
460
|
+
.ds-event-calendar__selected-day {
|
|
461
|
+
margin-block-start: var(--gap-300);
|
|
462
|
+
padding-block-start: var(--padding-300);
|
|
463
|
+
border-block-start: var(--border-025) solid var(--color-divider);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/* A legend entry that switches its colour: the shared Chip, its dot in the
|
|
467
|
+
entry's accent (an uncoloured entry takes the neutral one, at no weight,
|
|
468
|
+
so the accent class on the chip always wins). */
|
|
469
|
+
:where(.ds-event-calendar__legend .ds-chip) {
|
|
470
|
+
--ds-event-accent: var(--color-status-neutral-border);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/* In a chip the dot is the entry's whole mark, so it takes the larger step. */
|
|
474
|
+
.ds-event-calendar__legend .ds-chip .ds-event-calendar__event-dot {
|
|
475
|
+
display: block;
|
|
476
|
+
width: var(--gap-200);
|
|
477
|
+
height: var(--gap-200);
|
|
478
|
+
}
|
|
@@ -51,12 +51,29 @@ type EventCalendarOwnProps = {
|
|
|
51
51
|
selectedDate?: string;
|
|
52
52
|
/** The date the calendar treats as today (`YYYY-MM-DD`): it carries the today chip and picks the month shown first. Defaults to the device's date; pin it for a demo, a test or a time zone the device is not in. */
|
|
53
53
|
today?: string;
|
|
54
|
-
/** What each event colour means, shown as a row of dots and labels under the grid.
|
|
54
|
+
/** What each event colour means, shown as a row of dots and labels under the grid. With `legendToggles`, each entry also shows and hides its colour's events. */
|
|
55
55
|
legend?: EventCalendarLegendItem[];
|
|
56
|
+
/** Makes each legend entry a selectable Chip that shows or hides the events of its colour, so a reader can narrow a busy calendar by kind. */
|
|
57
|
+
legendToggles?: boolean;
|
|
58
|
+
/** The colours whose events are hidden, for controlled use. Pair with `onHiddenColorsChange`. */
|
|
59
|
+
hiddenColors?: EventCalendarColor[];
|
|
60
|
+
/** The colours hidden to begin with, for uncontrolled use. */
|
|
61
|
+
defaultHiddenColors?: EventCalendarColor[];
|
|
62
|
+
/** Fires with the hidden colours after a legend entry is switched. */
|
|
63
|
+
onHiddenColorsChange?: (colors: EventCalendarColor[]) => void;
|
|
64
|
+
/** The name of the legend's set of toggles, when `legendToggles` is on. */
|
|
65
|
+
legendLabel?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Draws a panel for the selected day under the grid, in every view: handed
|
|
68
|
+
* the day (YYYY-MM-DD) and its events as shown, it returns what the panel
|
|
69
|
+
* holds (a list of the day's events, a form to add one). Shown only while
|
|
70
|
+
* `selectedDate` is set.
|
|
71
|
+
*/
|
|
72
|
+
renderSelectedDay?: (date: string, events: EventCalendarEvent[]) => React.ReactNode;
|
|
56
73
|
/** Trailing header slot, e.g. a "New event" Button. */
|
|
57
74
|
actions?: React.ReactNode;
|
|
58
|
-
/** `month` shows the whole month, a day's overflow folded behind "+N more"; `week` shows one week in tall cells with every event, stepping a week at a time from the selected day's week (else today's), which it keeps as its own state after mount. */
|
|
59
|
-
view?: 'month' | 'week';
|
|
75
|
+
/** `month` shows the whole month, a day's overflow folded behind "+N more"; `week` shows one week in tall cells with every event, stepping a week at a time from the selected day's week (else today's), which it keeps as its own state after mount; `day` shows that one day the same way, stepping a day at a time. */
|
|
76
|
+
view?: 'month' | 'week' | 'day';
|
|
60
77
|
/** Accessible name of the previous-month button. */
|
|
61
78
|
previousLabel?: string;
|
|
62
79
|
/** Accessible name of the next-month button. */
|
|
@@ -65,6 +82,10 @@ type EventCalendarOwnProps = {
|
|
|
65
82
|
previousWeekLabel?: string;
|
|
66
83
|
/** Accessible name of the next-week button, in the week view. */
|
|
67
84
|
nextWeekLabel?: string;
|
|
85
|
+
/** Accessible name of the previous-day button, in the day view. */
|
|
86
|
+
previousDayLabel?: string;
|
|
87
|
+
/** Accessible name of the next-day button, in the day view. */
|
|
88
|
+
nextDayLabel?: string;
|
|
68
89
|
/** The visible text of the control that folds an expanded day back, when a day's "+N more" opens it in place (with no `onDateClick`). */
|
|
69
90
|
showLessLabel?: string;
|
|
70
91
|
/**
|
|
@@ -89,8 +110,9 @@ type EventCalendarOwnProps = {
|
|
|
89
110
|
/**
|
|
90
111
|
* The weekday headers above the grid: seven entries, Sunday first, laid
|
|
91
112
|
* out from `weekStartsOn`. Defaults to the short weekday names in `locale`
|
|
92
|
-
* ("Sun" to "Sat" in `en-US`)
|
|
93
|
-
* the
|
|
113
|
+
* ("Sun" to "Sat" in `en-US`), or its narrow names where the short ones
|
|
114
|
+
* are whole words (Arabic); a list of any other length falls back to the
|
|
115
|
+
* default.
|
|
94
116
|
*/
|
|
95
117
|
weekdayLabels?: string[];
|
|
96
118
|
/**
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import React, { useMemo, useState } from "react";
|
|
4
|
+
import { Chip } from "../Chip/Chip.js";
|
|
4
5
|
import "./EventCalendar.css";
|
|
6
|
+
import "../../behaviors/visually-hidden.css";
|
|
5
7
|
import "../../fonts/material-symbols.css";
|
|
6
8
|
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
7
|
-
import { weekStartOf, weekdayOffset, rotateWeek,
|
|
9
|
+
import { weekStartOf, weekdayOffset, rotateWeek, weekdayHeadersIn } from "../../behaviors/locale.js";
|
|
8
10
|
function parseDay(str) {
|
|
9
11
|
const match = str ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(str) : null;
|
|
10
12
|
return match ? new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3])) : null;
|
|
11
13
|
}
|
|
12
14
|
const MAX_SPAN_DAYS = 366;
|
|
13
|
-
const weekdaysOr = (labels, locale) => labels && labels.length === 7 ? labels :
|
|
15
|
+
const weekdaysOr = (labels, locale) => labels && labels.length === 7 ? labels : weekdayHeadersIn(locale);
|
|
14
16
|
function parseMonth(str) {
|
|
15
17
|
const [y, m] = str.split("-").map(Number);
|
|
16
18
|
return [y, m - 1];
|
|
@@ -51,12 +53,20 @@ const EventCalendar = React.forwardRef(
|
|
|
51
53
|
selectedDate,
|
|
52
54
|
today: todayProp,
|
|
53
55
|
legend,
|
|
56
|
+
legendToggles = false,
|
|
57
|
+
hiddenColors: hiddenColorsProp,
|
|
58
|
+
defaultHiddenColors = [],
|
|
59
|
+
onHiddenColorsChange,
|
|
60
|
+
legendLabel = "Show events by kind",
|
|
61
|
+
renderSelectedDay,
|
|
54
62
|
actions,
|
|
55
63
|
view = "month",
|
|
56
64
|
previousLabel = "Previous month",
|
|
57
65
|
nextLabel = "Next month",
|
|
58
66
|
previousWeekLabel = "Previous week",
|
|
59
67
|
nextWeekLabel = "Next week",
|
|
68
|
+
previousDayLabel = "Previous day",
|
|
69
|
+
nextDayLabel = "Next day",
|
|
60
70
|
showLessLabel = "Show less",
|
|
61
71
|
monthLabel: monthLabelProp,
|
|
62
72
|
overflowLabel: overflowLabelProp,
|
|
@@ -90,15 +100,16 @@ const EventCalendar = React.forwardRef(
|
|
|
90
100
|
if (!isControlled) setUncontrolledMonth(value);
|
|
91
101
|
onMonthChange?.(value);
|
|
92
102
|
};
|
|
93
|
-
const
|
|
103
|
+
const isDay = view === "day";
|
|
104
|
+
const isWeek = view === "week" || isDay;
|
|
94
105
|
const [weekAnchor, setWeekAnchor] = useState(() => parseDay(selectedDate) ?? today);
|
|
95
|
-
const weekStartDate = new Date(
|
|
106
|
+
const weekStartDate = isDay ? weekAnchor : new Date(
|
|
96
107
|
weekAnchor.getFullYear(),
|
|
97
108
|
weekAnchor.getMonth(),
|
|
98
109
|
weekAnchor.getDate() - weekdayOffset(weekAnchor.getDay(), weekStart)
|
|
99
110
|
);
|
|
100
111
|
const stepWeek = (offset) => {
|
|
101
|
-
const next = new Date(weekAnchor.getFullYear(), weekAnchor.getMonth(), weekAnchor.getDate() + offset * 7);
|
|
112
|
+
const next = new Date(weekAnchor.getFullYear(), weekAnchor.getMonth(), weekAnchor.getDate() + offset * (isDay ? 1 : 7));
|
|
102
113
|
setWeekAnchor(next);
|
|
103
114
|
const value = formatMonth(next.getFullYear(), next.getMonth());
|
|
104
115
|
if (value !== formatMonth(weekAnchor.getFullYear(), weekAnchor.getMonth())) {
|
|
@@ -112,6 +123,13 @@ const EventCalendar = React.forwardRef(
|
|
|
112
123
|
const format = new Intl.DateTimeFormat(locale, { month: "long", day: "numeric", year: "numeric" });
|
|
113
124
|
return (start) => format.formatRange(start, new Date(start.getFullYear(), start.getMonth(), start.getDate() + 6));
|
|
114
125
|
}, [locale]);
|
|
126
|
+
const [ownHidden, setOwnHidden] = useState(defaultHiddenColors);
|
|
127
|
+
const hiddenColors = hiddenColorsProp ?? ownHidden;
|
|
128
|
+
const toggleColor = (color) => {
|
|
129
|
+
const next = hiddenColors.includes(color) ? hiddenColors.filter((c) => c !== color) : [...hiddenColors, color];
|
|
130
|
+
if (hiddenColorsProp === void 0) setOwnHidden(next);
|
|
131
|
+
onHiddenColorsChange?.(next);
|
|
132
|
+
};
|
|
115
133
|
const eventsByDate = useMemo(() => {
|
|
116
134
|
const map = /* @__PURE__ */ new Map();
|
|
117
135
|
const add = (day, event) => {
|
|
@@ -120,6 +138,7 @@ const EventCalendar = React.forwardRef(
|
|
|
120
138
|
map.set(day, list);
|
|
121
139
|
};
|
|
122
140
|
for (const event of events) {
|
|
141
|
+
if (hiddenColors.includes(event.color ?? "neutral")) continue;
|
|
123
142
|
const start = parseDay(event.date);
|
|
124
143
|
const end = parseDay(event.endDate);
|
|
125
144
|
if (!start || !end || end <= start) {
|
|
@@ -143,7 +162,7 @@ const EventCalendar = React.forwardRef(
|
|
|
143
162
|
});
|
|
144
163
|
}
|
|
145
164
|
return map;
|
|
146
|
-
}, [events, locale]);
|
|
165
|
+
}, [events, locale, hiddenColors]);
|
|
147
166
|
const formatSpan = useMemo(() => {
|
|
148
167
|
const format = new Intl.DateTimeFormat(locale, { month: "long", day: "numeric", year: "numeric" });
|
|
149
168
|
return (event) => {
|
|
@@ -157,7 +176,7 @@ const EventCalendar = React.forwardRef(
|
|
|
157
176
|
const weekCount = Math.ceil((firstDay + daysInMonth) / 7);
|
|
158
177
|
const cells = [];
|
|
159
178
|
if (isWeek) {
|
|
160
|
-
for (let i = 0; i < 7; i++) {
|
|
179
|
+
for (let i = 0; i < (isDay ? 1 : 7); i++) {
|
|
161
180
|
cells.push({
|
|
162
181
|
date: new Date(weekStartDate.getFullYear(), weekStartDate.getMonth(), weekStartDate.getDate() + i),
|
|
163
182
|
inMonth: true
|
|
@@ -169,8 +188,10 @@ const EventCalendar = React.forwardRef(
|
|
|
169
188
|
cells.push({ date, inMonth: date.getMonth() === viewMonth });
|
|
170
189
|
}
|
|
171
190
|
}
|
|
172
|
-
const classes = [baseClass, isWeek ? `${baseClass}--week` : "", className].filter(Boolean).join(" ");
|
|
173
|
-
const monthTitle = isWeek ? weekRangeLabel(weekStartDate) : monthLabel(new Date(viewYear, viewMonth, 1));
|
|
191
|
+
const classes = [baseClass, isWeek ? `${baseClass}--week` : "", isDay ? `${baseClass}--day` : "", className].filter(Boolean).join(" ");
|
|
192
|
+
const monthTitle = isDay ? formatDayLabel(weekStartDate) : isWeek ? weekRangeLabel(weekStartDate) : monthLabel(new Date(viewYear, viewMonth, 1));
|
|
193
|
+
const previousName = isDay ? previousDayLabel : isWeek ? previousWeekLabel : previousLabel;
|
|
194
|
+
const nextName = isDay ? nextDayLabel : isWeek ? nextWeekLabel : nextLabel;
|
|
174
195
|
return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
|
|
175
196
|
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
|
|
176
197
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__month`, children: monthTitle }),
|
|
@@ -181,7 +202,7 @@ const EventCalendar = React.forwardRef(
|
|
|
181
202
|
type: "button",
|
|
182
203
|
className: `${baseClass}__nav-btn material-symbols-rounded ds-mirror-rtl`,
|
|
183
204
|
onClick: () => isWeek ? stepWeek(-1) : navigate(-1),
|
|
184
|
-
"aria-label":
|
|
205
|
+
"aria-label": previousName,
|
|
185
206
|
children: "chevron_left"
|
|
186
207
|
}
|
|
187
208
|
),
|
|
@@ -191,14 +212,14 @@ const EventCalendar = React.forwardRef(
|
|
|
191
212
|
type: "button",
|
|
192
213
|
className: `${baseClass}__nav-btn material-symbols-rounded ds-mirror-rtl`,
|
|
193
214
|
onClick: () => isWeek ? stepWeek(1) : navigate(1),
|
|
194
|
-
"aria-label":
|
|
215
|
+
"aria-label": nextName,
|
|
195
216
|
children: "chevron_right"
|
|
196
217
|
}
|
|
197
218
|
)
|
|
198
219
|
] }),
|
|
199
220
|
actions && /* @__PURE__ */ jsx("div", { className: `${baseClass}__actions`, children: actions })
|
|
200
221
|
] }),
|
|
201
|
-
/* @__PURE__ */ jsx("div", { className: `${baseClass}__weekdays`, "aria-hidden": "true", children: rotateWeek(weekdaysOr(weekdayLabels, locale), weekStart).map((day, index) => /* @__PURE__ */ jsx("div", { className: `${baseClass}__weekday`, children: day }, index)) }),
|
|
222
|
+
!isDay && /* @__PURE__ */ jsx("div", { className: `${baseClass}__weekdays`, "aria-hidden": "true", children: rotateWeek(weekdaysOr(weekdayLabels, locale), weekStart).map((day, index) => /* @__PURE__ */ jsx("div", { className: `${baseClass}__weekday`, children: day }, index)) }),
|
|
202
223
|
/* @__PURE__ */ jsx(
|
|
203
224
|
"div",
|
|
204
225
|
{
|
|
@@ -262,8 +283,9 @@ const EventCalendar = React.forwardRef(
|
|
|
262
283
|
].filter(Boolean).join(" ");
|
|
263
284
|
const pillContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
264
285
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__event-dot`, "aria-hidden": "true" }),
|
|
265
|
-
/* @__PURE__ */ jsx("span", { className: `${baseClass}__event-title`, children: event.title }),
|
|
266
|
-
event.time && /* @__PURE__ */ jsx("span", { className: `${baseClass}__event-time`, children: event.time })
|
|
286
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__event-title`, "aria-hidden": "true", children: event.title }),
|
|
287
|
+
event.time && /* @__PURE__ */ jsx("span", { className: `${baseClass}__event-time`, "aria-hidden": "true", children: event.time }),
|
|
288
|
+
!onEventClick && /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", children: event.time ? `${event.title}, ${event.time}` : event.title })
|
|
267
289
|
] });
|
|
268
290
|
return onEventClick ? /* @__PURE__ */ jsx(
|
|
269
291
|
"button",
|
|
@@ -306,7 +328,20 @@ const EventCalendar = React.forwardRef(
|
|
|
306
328
|
})
|
|
307
329
|
}
|
|
308
330
|
),
|
|
309
|
-
|
|
331
|
+
selectedDate && renderSelectedDay && /* @__PURE__ */ jsx("div", { className: `${baseClass}__selected-day`, children: renderSelectedDay(selectedDate, eventsByDate.get(selectedDate) ?? []) }),
|
|
332
|
+
legend && legend.length > 0 && legendToggles && /* @__PURE__ */ jsx("div", { className: `${baseClass}__legend`, role: "group", "aria-label": legendLabel, children: legend.map((item) => /* @__PURE__ */ jsx(
|
|
333
|
+
Chip,
|
|
334
|
+
{
|
|
335
|
+
size: "compact",
|
|
336
|
+
className: `${baseClass}__event--${item.color}`,
|
|
337
|
+
icon: /* @__PURE__ */ jsx("span", { className: `${baseClass}__event-dot`, "aria-hidden": "true" }),
|
|
338
|
+
label: item.label,
|
|
339
|
+
selected: !hiddenColors.includes(item.color),
|
|
340
|
+
onClick: () => toggleColor(item.color)
|
|
341
|
+
},
|
|
342
|
+
`${item.color}-${item.label}`
|
|
343
|
+
)) }),
|
|
344
|
+
legend && legend.length > 0 && !legendToggles && /* @__PURE__ */ jsx("ul", { className: `${baseClass}__legend`, children: legend.map((item) => /* @__PURE__ */ jsxs("li", { className: `${baseClass}__legend-item ${baseClass}__event--${item.color}`, children: [
|
|
310
345
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__event-dot`, "aria-hidden": "true" }),
|
|
311
346
|
item.label
|
|
312
347
|
] }, `${item.color}-${item.label}`)) })
|