@manakind/ui-core 0.14.0 → 0.15.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 +3 -1
- package/dist/calendar/calendar.css +153 -0
- package/dist/calendar/calendar.css.d.ts +2 -0
- package/dist/calendar/calendar.d.ts +115 -0
- package/dist/calendar/calendar.d.ts.map +1 -0
- package/dist/calendar/calendar.js +112 -0
- package/dist/calendar/calendar.js.map +1 -0
- package/dist/calendar/index.d.ts +2 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/index.js +2 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/date-input/date-input.d.ts.map +1 -1
- package/dist/date-input/date-input.js +2 -12
- package/dist/date-input/date-input.js.map +1 -1
- package/dist/fallback-glyphs.d.ts +1 -0
- package/dist/fallback-glyphs.d.ts.map +1 -1
- package/dist/fallback-glyphs.js +2 -0
- package/dist/fallback-glyphs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/iso-date.d.ts +10 -0
- package/dist/iso-date.d.ts.map +1 -0
- package/dist/iso-date.js +17 -0
- package/dist/iso-date.js.map +1 -0
- package/dist/popover/popover.d.ts +8 -1
- package/dist/popover/popover.d.ts.map +1 -1
- package/dist/popover/popover.js +2 -2
- package/dist/popover/popover.js.map +1 -1
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -56,10 +56,11 @@ separately, so an app can load only what it renders.
|
|
|
56
56
|
|
|
57
57
|
| Entry | Contents |
|
|
58
58
|
|---|---|
|
|
59
|
-
| `@manakind/ui-core` | Everything below, plus every prop type, the `cx` helper, and the built-in fallback glyphs (`FallbackChevronRight`, `FallbackCheck`, `FallbackCross`) for compositions that want the same defaults |
|
|
59
|
+
| `@manakind/ui-core` | Everything below, plus every prop type, the `cx` helper, and the built-in fallback glyphs (`FallbackChevronLeft`, `FallbackChevronRight`, `FallbackCheck`, `FallbackCross`) for compositions that want the same defaults |
|
|
60
60
|
| `@manakind/ui-core/alert` | `Alert` |
|
|
61
61
|
| `@manakind/ui-core/badge` | `Badge` |
|
|
62
62
|
| `@manakind/ui-core/button` | `Button` + `IconButton` |
|
|
63
|
+
| `@manakind/ui-core/calendar` | `Calendar` |
|
|
63
64
|
| `@manakind/ui-core/card` | `Card`, `CardHeader`, `CardTitle`, `CardLink`, `CardDescription`, `CardContent`, `CardFooter` |
|
|
64
65
|
| `@manakind/ui-core/dialog` | `Dialog` + `DialogClose` |
|
|
65
66
|
| `@manakind/ui-core/icon` | `Icon` |
|
|
@@ -77,6 +78,7 @@ separately, so an app can load only what it renders.
|
|
|
77
78
|
| `@manakind/ui-core/css/alert` | Alert structural CSS; its icon also needs `css/icon` |
|
|
78
79
|
| `@manakind/ui-core/css/badge` | Badge structural CSS |
|
|
79
80
|
| `@manakind/ui-core/css/button` | Button + IconButton structural CSS |
|
|
81
|
+
| `@manakind/ui-core/css/calendar` | Calendar structural CSS; its paging buttons also need `css/button` and `css/icon` |
|
|
80
82
|
| `@manakind/ui-core/css/card` | Card structural CSS |
|
|
81
83
|
| `@manakind/ui-core/css/dialog` | Dialog structural CSS; its close button also needs `css/button` and `css/icon` |
|
|
82
84
|
| `@manakind/ui-core/css/icon` | Icon structural CSS |
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.ds-calendar {
|
|
3
|
+
display: inline-block;
|
|
4
|
+
max-width: 100%;
|
|
5
|
+
overflow-wrap: anywhere;
|
|
6
|
+
color: var(--ds-calendar-day-text);
|
|
7
|
+
|
|
8
|
+
&[data-disabled] {
|
|
9
|
+
opacity: var(--ds-opacity-disabled);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
& .ds-calendar__content {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: var(--ds-calendar-gap);
|
|
16
|
+
outline: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* A grid rather than a flex row: the heading must stay between its two
|
|
21
|
+
* buttons on one line, and a word too long for it breaks inside its own
|
|
22
|
+
* column instead of squeezing the buttons.
|
|
23
|
+
*/
|
|
24
|
+
& .ds-calendar__header {
|
|
25
|
+
display: grid;
|
|
26
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: var(--ds-calendar-gap);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
& .ds-calendar__heading {
|
|
32
|
+
min-width: 0;
|
|
33
|
+
color: var(--ds-calendar-header-text);
|
|
34
|
+
font-size: var(--ds-calendar-header-font-size);
|
|
35
|
+
font-weight: var(--ds-calendar-header-font-weight);
|
|
36
|
+
text-align: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
& .ds-calendar__table {
|
|
40
|
+
border-collapse: separate;
|
|
41
|
+
border-spacing: 0;
|
|
42
|
+
table-layout: fixed;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
& .ds-calendar__weekday {
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
width: var(--ds-calendar-day-size);
|
|
48
|
+
padding: 0 0 var(--ds-calendar-day-padding);
|
|
49
|
+
color: var(--ds-calendar-weekday-text);
|
|
50
|
+
font-size: var(--ds-calendar-weekday-font-size);
|
|
51
|
+
font-weight: var(--ds-calendar-weekday-font-weight);
|
|
52
|
+
text-align: center;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
* The band between a range's two ends is drawn on the cells, edge to
|
|
57
|
+
* edge, so it reads as one stretch under the day fills; it rounds off
|
|
58
|
+
* at the ends of the range, at the ends of a hover preview, and at the
|
|
59
|
+
* ends of each row.
|
|
60
|
+
*/
|
|
61
|
+
& .ds-calendar__cell {
|
|
62
|
+
padding: 0;
|
|
63
|
+
|
|
64
|
+
&:has(.ds-calendar__day[data-in-range]) {
|
|
65
|
+
background-color: var(--ds-calendar-day-bg-range);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:first-child,
|
|
69
|
+
&:has([data-range-start]),
|
|
70
|
+
&:has([data-hover-range-start]) {
|
|
71
|
+
border-start-start-radius: var(--ds-calendar-day-radius);
|
|
72
|
+
border-end-start-radius: var(--ds-calendar-day-radius);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:last-child,
|
|
76
|
+
&:has([data-range-end]),
|
|
77
|
+
&:has([data-hover-range-end]) {
|
|
78
|
+
border-start-end-radius: var(--ds-calendar-day-radius);
|
|
79
|
+
border-end-end-radius: var(--ds-calendar-day-radius);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* The whole cell is the target; the fill sits inside it by the cell's
|
|
85
|
+
* padding. A focus ring (2px, 3px out) around the fill ends inside the
|
|
86
|
+
* neighbouring cell's padding, so it never crosses a chosen day's fill,
|
|
87
|
+
* where the products' rings would vanish.
|
|
88
|
+
*/
|
|
89
|
+
& .ds-calendar__day {
|
|
90
|
+
display: flex;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
width: var(--ds-calendar-day-size);
|
|
93
|
+
height: var(--ds-calendar-day-size);
|
|
94
|
+
padding: var(--ds-calendar-day-padding);
|
|
95
|
+
font-size: var(--ds-calendar-day-font-size);
|
|
96
|
+
font-variant-numeric: tabular-nums;
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
outline: none;
|
|
99
|
+
user-select: none;
|
|
100
|
+
|
|
101
|
+
&[data-outside-range] {
|
|
102
|
+
color: var(--ds-calendar-day-text-outside);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&[data-in-range] {
|
|
106
|
+
color: var(--ds-calendar-day-text-range);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&[data-disabled] {
|
|
110
|
+
cursor: default;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&:not([data-disabled]) .ds-calendar__day[data-disabled] {
|
|
115
|
+
opacity: var(--ds-opacity-disabled);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&[data-readonly] .ds-calendar__day {
|
|
119
|
+
cursor: default;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
& .ds-calendar__day-fill {
|
|
123
|
+
display: flex;
|
|
124
|
+
flex: 1;
|
|
125
|
+
align-items: center;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
box-sizing: border-box;
|
|
128
|
+
border-radius: var(--ds-calendar-day-radius);
|
|
129
|
+
transition: background-color 150ms cubic-bezier(0, 0, 0.2, 1);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&:not([data-readonly])
|
|
133
|
+
.ds-calendar__day:hover:not([data-disabled], [data-selected])
|
|
134
|
+
.ds-calendar__day-fill {
|
|
135
|
+
background-color: var(--ds-calendar-day-bg-hover);
|
|
136
|
+
color: var(--ds-calendar-day-text);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
& .ds-calendar__day[data-today] .ds-calendar__day-fill {
|
|
140
|
+
box-shadow: 0 0 0 1px var(--ds-calendar-day-border-today);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
& .ds-calendar__day[data-selected] .ds-calendar__day-fill {
|
|
144
|
+
background-color: var(--ds-calendar-day-bg-selected);
|
|
145
|
+
color: var(--ds-calendar-day-text-selected);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
& .ds-calendar__day:focus-visible .ds-calendar__day-fill {
|
|
149
|
+
outline: 2px solid var(--ds-calendar-focus-ring);
|
|
150
|
+
outline-offset: 3px;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import './calendar.css';
|
|
2
|
+
import type { IconSource } from '../icon/icon';
|
|
3
|
+
/**
|
|
4
|
+
* A stretch of days. Both ends are ISO calendar dates, `YYYY-MM-DD`; `end`
|
|
5
|
+
* is `null` while only the first day is chosen.
|
|
6
|
+
*/
|
|
7
|
+
export interface CalendarRange {
|
|
8
|
+
start: string;
|
|
9
|
+
end: string | null;
|
|
10
|
+
}
|
|
11
|
+
/** A day of the week as `Date#getDay()` counts them: 0 is Sunday, 1 is Monday. */
|
|
12
|
+
export type CalendarWeekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
13
|
+
interface CalendarCommonProps {
|
|
14
|
+
/**
|
|
15
|
+
* The calendar's name, saying which day is being chosen: "Scheduled day",
|
|
16
|
+
* "Target date". A calendar has no label of its own, and the month heading
|
|
17
|
+
* changes as the user pages.
|
|
18
|
+
*/
|
|
19
|
+
'aria-label': string;
|
|
20
|
+
/**
|
|
21
|
+
* BCP 47 tag that decides the month and weekday names and, unless
|
|
22
|
+
* `startOfWeek` says otherwise, the first day of the week. Defaults to
|
|
23
|
+
* `en-GB`: English names, Monday first. The products' own date format is
|
|
24
|
+
* not involved; the grid shows day numbers only.
|
|
25
|
+
*/
|
|
26
|
+
locale?: string;
|
|
27
|
+
/** The first column, `0` for Sunday through `6` for Saturday. Defaults to the locale's. */
|
|
28
|
+
startOfWeek?: CalendarWeekday;
|
|
29
|
+
/**
|
|
30
|
+
* The earliest day that can be chosen, `YYYY-MM-DD`. Earlier days are
|
|
31
|
+
* shown but cannot be chosen; a value outside the window is still shown
|
|
32
|
+
* as the value.
|
|
33
|
+
*/
|
|
34
|
+
min?: string;
|
|
35
|
+
/** The latest day that can be chosen, `YYYY-MM-DD`. */
|
|
36
|
+
max?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Any day of the month shown first when nothing is chosen yet,
|
|
39
|
+
* `YYYY-MM-DD`. Defaults to the month of the chosen day, else this month.
|
|
40
|
+
*/
|
|
41
|
+
defaultMonth?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Moves focus to the chosen day (else the first day shown by
|
|
44
|
+
* `defaultMonth`, else today) once the calendar is in the page. For a calendar opened in a popover, so
|
|
45
|
+
* the arrow keys work at once and a screen reader lands on a day.
|
|
46
|
+
*/
|
|
47
|
+
autoFocus?: boolean;
|
|
48
|
+
/** Dims the calendar; nothing in it can be focused or chosen. */
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
/** Shows the days and the choice, pages freely, but lets nothing be chosen. */
|
|
51
|
+
readOnly?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Glyph for the "previous month" button. Defaults to a plain built-in
|
|
54
|
+
* chevron so `@manakind/ui-core` renders on its own; products pass their
|
|
55
|
+
* own icon set.
|
|
56
|
+
*/
|
|
57
|
+
previousIcon?: IconSource;
|
|
58
|
+
/** Glyph for the "next month" button. Same defaulting rule as {@link CalendarCommonProps.previousIcon}. */
|
|
59
|
+
nextIcon?: IconSource;
|
|
60
|
+
/** Extra class names appended after `ds-calendar`. */
|
|
61
|
+
className?: string;
|
|
62
|
+
}
|
|
63
|
+
interface CalendarSingleProps {
|
|
64
|
+
/** One day at a time. The default. */
|
|
65
|
+
selectionMode?: 'single';
|
|
66
|
+
/** The chosen day, `YYYY-MM-DD`, or `null` for none. Leave undefined to let the calendar own it. */
|
|
67
|
+
value?: string | null;
|
|
68
|
+
/** The day chosen at first when uncontrolled, or `null` for none. */
|
|
69
|
+
defaultValue?: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Fired with the ISO date of the day the user chose. Choosing the chosen
|
|
72
|
+
* day again fires nothing, and the calendar never clears: a product that
|
|
73
|
+
* lets the user unschedule does it with a control of its own.
|
|
74
|
+
*/
|
|
75
|
+
onValueChange?: (value: string) => void;
|
|
76
|
+
}
|
|
77
|
+
interface CalendarRangeProps {
|
|
78
|
+
/**
|
|
79
|
+
* A first and a last day. The first click chooses the first day and fires
|
|
80
|
+
* with `end: null`; the second click chooses the last day, in either
|
|
81
|
+
* order, and fires with both; a third click starts a new range.
|
|
82
|
+
*/
|
|
83
|
+
selectionMode: 'range';
|
|
84
|
+
/** The chosen range, or `null` for none. Leave undefined to let the calendar own it. */
|
|
85
|
+
value?: CalendarRange | null;
|
|
86
|
+
/** The range chosen at first when uncontrolled, or `null` for none. */
|
|
87
|
+
defaultValue?: CalendarRange | null;
|
|
88
|
+
/** Fired with the range so far: `end` is `null` after the first click of a new range. */
|
|
89
|
+
onValueChange?: (value: CalendarRange) => void;
|
|
90
|
+
}
|
|
91
|
+
type CalendarSelection = CalendarSingleProps | CalendarRangeProps;
|
|
92
|
+
export type CalendarProps = CalendarCommonProps & CalendarSelection;
|
|
93
|
+
/**
|
|
94
|
+
* A month of days to choose from, built on Ark UI's DatePicker.
|
|
95
|
+
*
|
|
96
|
+
* The grid shows one month at a time with the weekdays across the top and
|
|
97
|
+
* a button pair to turn the page; the days of the neighbouring months fill
|
|
98
|
+
* the first and last rows, and every month has six rows, so the calendar
|
|
99
|
+
* keeps its height as the user pages. One day is chosen at a time, or a
|
|
100
|
+
* first and a last day with `selectionMode="range"`. The value in and out is
|
|
101
|
+
* an ISO calendar date, `YYYY-MM-DD`, as `DateInput` gives: a string a form
|
|
102
|
+
* library and a database both keep as is, with no time zone to get wrong.
|
|
103
|
+
*
|
|
104
|
+
* It is the grid alone. A product puts it in a `Popover` behind a button
|
|
105
|
+
* that shows the choice, or in the page, and gives it `aria-label`; the
|
|
106
|
+
* labels the grid speaks ("Choose Wednesday 12 June 2024", "Previous month")
|
|
107
|
+
* are English, as Ark's are.
|
|
108
|
+
*
|
|
109
|
+
* ```tsx
|
|
110
|
+
* <Calendar aria-label="Scheduled day" value={day} onValueChange={setDay} autoFocus />
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function Calendar({ 'aria-label': ariaLabel, locale, startOfWeek, min, max, defaultMonth, autoFocus, disabled, readOnly, previousIcon, nextIcon, className, ...selection }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
114
|
+
export {};
|
|
115
|
+
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/calendar/calendar.tsx"],"names":[],"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K,IAAI,CAAC;CACzC;AAED,UAAU,kBAAkB;IAC1B;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB,wFAAwF;IACxF,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,uEAAuE;IACvE,YAAY,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,yFAAyF;IACzF,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAChD;AAED,KAAK,iBAAiB,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AA2DpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,YAAY,EAAE,SAAS,EACvB,MAAgB,EAChB,WAAW,EACX,GAAG,EACH,GAAG,EACH,YAAY,EACZ,SAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,YAA0B,EAC1B,QAAuB,EACvB,SAAS,EACT,GAAG,SAAS,EACb,EAAE,aAAa,2CAwHf"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { DatePicker as ArkDatePicker } from '@ark-ui/react/date-picker';
|
|
3
|
+
import { getLocalTimeZone, today } from '@internationalized/date';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import './calendar.css';
|
|
6
|
+
import { IconButton } from '../button/icon-button';
|
|
7
|
+
import { cx } from '../cx';
|
|
8
|
+
import { ChevronLeft, ChevronRight } from '../fallback-glyphs';
|
|
9
|
+
import { parseIsoDate } from '../iso-date';
|
|
10
|
+
const parseIso = (iso, prop) => parseIsoDate(iso, `Calendar: ${prop}`);
|
|
11
|
+
const parseOptional = (iso, prop) => iso === undefined ? undefined : parseIso(iso, prop);
|
|
12
|
+
/*
|
|
13
|
+
* Zag keeps every selection as a list of dates: one for a day, up to two
|
|
14
|
+
* for a range. The product's typed shape is folded into that list on the
|
|
15
|
+
* way in and rebuilt on the way out.
|
|
16
|
+
*/
|
|
17
|
+
function toDateValues(selection, prop) {
|
|
18
|
+
const given = selection[prop];
|
|
19
|
+
if (given === undefined)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (given === null)
|
|
22
|
+
return [];
|
|
23
|
+
if (typeof given === 'string')
|
|
24
|
+
return [parseIso(given, prop)];
|
|
25
|
+
const dates = [parseIso(given.start, `${prop}.start`)];
|
|
26
|
+
if (given.end !== null)
|
|
27
|
+
dates.push(parseIso(given.end, `${prop}.end`));
|
|
28
|
+
return dates;
|
|
29
|
+
}
|
|
30
|
+
/*
|
|
31
|
+
* Zag's list can be sparse: a range cleared from outside between its two
|
|
32
|
+
* clicks keeps Zag waiting for an end date, and the next click lands at
|
|
33
|
+
* index 1 of an empty list. The dates that are there are the selection.
|
|
34
|
+
*/
|
|
35
|
+
function report(selection, dates) {
|
|
36
|
+
const [start, end] = dates.filter((date) => date !== undefined);
|
|
37
|
+
if (!start)
|
|
38
|
+
return;
|
|
39
|
+
if (selection.selectionMode === 'range') {
|
|
40
|
+
selection.onValueChange?.({ start: start.toString(), end: end?.toString() ?? null });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
selection.onValueChange?.(start.toString());
|
|
44
|
+
}
|
|
45
|
+
/*
|
|
46
|
+
* The day Zag's keyboard focus and the shown month follow. Zag moves it on
|
|
47
|
+
* its own events only, so a value the parent changes to another month
|
|
48
|
+
* would leave the grid on the old one: the calendar owns it, and moves it
|
|
49
|
+
* to the chosen day whenever the parent chooses a new one.
|
|
50
|
+
*/
|
|
51
|
+
function useFocusedDay(chosen, fallback) {
|
|
52
|
+
const chosenKey = chosen?.toString();
|
|
53
|
+
const [focused, setFocused] = useState(() => ({
|
|
54
|
+
key: chosenKey,
|
|
55
|
+
day: chosen ?? fallback ?? today(getLocalTimeZone()),
|
|
56
|
+
}));
|
|
57
|
+
if (chosenKey !== focused.key) {
|
|
58
|
+
setFocused({ key: chosenKey, day: chosen ?? focused.day });
|
|
59
|
+
}
|
|
60
|
+
const setDay = (day) => setFocused((state) => ({ ...state, day }));
|
|
61
|
+
return [focused.day, setDay];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A month of days to choose from, built on Ark UI's DatePicker.
|
|
65
|
+
*
|
|
66
|
+
* The grid shows one month at a time with the weekdays across the top and
|
|
67
|
+
* a button pair to turn the page; the days of the neighbouring months fill
|
|
68
|
+
* the first and last rows, and every month has six rows, so the calendar
|
|
69
|
+
* keeps its height as the user pages. One day is chosen at a time, or a
|
|
70
|
+
* first and a last day with `selectionMode="range"`. The value in and out is
|
|
71
|
+
* an ISO calendar date, `YYYY-MM-DD`, as `DateInput` gives: a string a form
|
|
72
|
+
* library and a database both keep as is, with no time zone to get wrong.
|
|
73
|
+
*
|
|
74
|
+
* It is the grid alone. A product puts it in a `Popover` behind a button
|
|
75
|
+
* that shows the choice, or in the page, and gives it `aria-label`; the
|
|
76
|
+
* labels the grid speaks ("Choose Wednesday 12 June 2024", "Previous month")
|
|
77
|
+
* are English, as Ark's are.
|
|
78
|
+
*
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <Calendar aria-label="Scheduled day" value={day} onValueChange={setDay} autoFocus />
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export function Calendar({ 'aria-label': ariaLabel, locale = 'en-GB', startOfWeek, min, max, defaultMonth, autoFocus = false, disabled, readOnly, previousIcon = ChevronLeft, nextIcon = ChevronRight, className, ...selection }) {
|
|
84
|
+
const rootRef = useRef(null);
|
|
85
|
+
const controlledDates = toDateValues(selection, 'value');
|
|
86
|
+
const initialDates = toDateValues(selection, 'defaultValue');
|
|
87
|
+
const [focusedDay, setFocusedDay] = useFocusedDay(controlledDates?.[0] ?? initialDates?.[0], parseOptional(defaultMonth, 'defaultMonth'));
|
|
88
|
+
const minDate = parseOptional(min, 'min');
|
|
89
|
+
const maxDate = parseOptional(max, 'max');
|
|
90
|
+
/*
|
|
91
|
+
* Passed as unavailable days rather than Zag's own `min`/`max`, which clamp
|
|
92
|
+
* a value outside them to the nearest allowed day and show that day as
|
|
93
|
+
* chosen while the parent holds another. Unavailable days are disabled and
|
|
94
|
+
* cannot be chosen, and a value outside the window stays the value.
|
|
95
|
+
*/
|
|
96
|
+
const isOutsideWindow = (date) => (minDate !== undefined && date.compare(minDate) < 0) ||
|
|
97
|
+
(maxDate !== undefined && date.compare(maxDate) > 0);
|
|
98
|
+
/*
|
|
99
|
+
* Zag gives the focused day `tabindex="0"` and every other day `-1`; the
|
|
100
|
+
* one day in the tab order is the one to land on. An effect, because the
|
|
101
|
+
* focus is the browser's.
|
|
102
|
+
*/
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!autoFocus)
|
|
105
|
+
return;
|
|
106
|
+
rootRef.current
|
|
107
|
+
?.querySelector('[data-part="table-cell-trigger"][tabindex="0"]')
|
|
108
|
+
?.focus({ preventScroll: true });
|
|
109
|
+
}, [autoFocus]);
|
|
110
|
+
return (_jsx(ArkDatePicker.Root, { ref: rootRef, className: cx('ds-calendar', className), inline: true, closeOnSelect: false, fixedWeeks: true, outsideDaySelectable: true, selectionMode: selection.selectionMode ?? 'single', value: controlledDates, defaultValue: initialDates, onValueChange: (details) => report(selection, details.value), focusedValue: focusedDay, onFocusChange: (details) => setFocusedDay(details.focusedValue), isDateUnavailable: minDate || maxDate ? isOutsideWindow : undefined, locale: locale, timeZone: getLocalTimeZone(), startOfWeek: startOfWeek, disabled: disabled, readOnly: readOnly, children: _jsx(ArkDatePicker.Content, { className: "ds-calendar__content", "aria-label": ariaLabel, "aria-disabled": disabled || undefined, children: _jsx(ArkDatePicker.View, { view: "day", children: _jsx(ArkDatePicker.Context, { children: (api) => (_jsxs(_Fragment, { children: [_jsxs(ArkDatePicker.ViewControl, { className: "ds-calendar__header", children: [_jsx(ArkDatePicker.PrevTrigger, { asChild: true, children: _jsx(IconButton, { variant: "tertiary", size: "sm", icon: previousIcon, "aria-label": "Previous month" }) }), _jsx(ArkDatePicker.RangeText, { className: "ds-calendar__heading", "aria-live": "polite" }), _jsx(ArkDatePicker.NextTrigger, { asChild: true, children: _jsx(IconButton, { variant: "tertiary", size: "sm", icon: nextIcon, "aria-label": "Next month" }) })] }), _jsxs(ArkDatePicker.Table, { className: "ds-calendar__table", children: [_jsx(ArkDatePicker.TableHead, { children: _jsx(ArkDatePicker.TableRow, { children: api.weekDays.map((weekDay) => (_jsx(ArkDatePicker.TableHeader, { className: "ds-calendar__weekday", children: weekDay.short }, weekDay.value.toString()))) }) }), _jsx(ArkDatePicker.TableBody, { children: api.weeks.map((week) => (_jsx(ArkDatePicker.TableRow, { children: week.map((day) => (_jsx(ArkDatePicker.TableCell, { value: day, className: "ds-calendar__cell", children: _jsx(ArkDatePicker.TableCellTrigger, { className: "ds-calendar__day", children: _jsx("span", { className: "ds-calendar__day-fill", children: day.day }) }) }, day.toString()))) }, week[0]?.toString()))) })] })] })) }) }) }) }));
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../src/calendar/calendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAkB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAA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BAAoB,aACjD,KAAC,aAAa,CAAC,SAAS,cACtB,KAAC,aAAa,CAAC,QAAQ,cACpB,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7B,KAAC,aAAa,CAAC,WAAW,IAExB,SAAS,EAAC,sBAAsB,YAE/B,OAAO,CAAC,KAAK,IAHT,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAIH,CAC7B,CAAC,GACqB,GACD,EAC1B,KAAC,aAAa,CAAC,SAAS,cACrB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACvB,KAAC,aAAa,CAAC,QAAQ,cACpB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,KAAC,aAAa,CAAC,SAAS,IAEtB,KAAK,EAAE,GAAG,EACV,SAAS,EAAC,mBAAmB,YAE7B,KAAC,aAAa,CAAC,gBAAgB,IAAC,SAAS,EAAC,kBAAkB,YAC1D,eAAM,SAAS,EAAC,uBAAuB,YAAE,GAAG,CAAC,GAAG,GAAQ,GACzB,IAN5B,GAAG,CAAC,QAAQ,EAAE,CAOK,CAC3B,CAAC,IAXyB,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAYvB,CAC1B,CAAC,GACsB,IACN,IACrB,CACJ,GACqB,GACL,GACC,GACL,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/calendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/calendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,GAIT,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-input.d.ts","sourceRoot":"","sources":["../../src/date-input/date-input.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-input.d.ts","sourceRoot":"","sources":["../../src/date-input/date-input.tsx"],"names":[],"mappings":"AAOA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,MAAM,MAAM,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAIzE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACnD;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,mEAAmE;IACnE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAgEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAa,EACb,kBAAkB,EAClB,SAA8B,EAC9B,IAAW,EACX,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,YAAY,EAAE,SAAS,EACvB,SAAS,GACV,EAAE,cAAc,2CAkDhB"}
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { DateInput as ArkDateInput, useDateInputContext, } from '@ark-ui/react/date-input';
|
|
3
|
-
import { parseDate } from '@internationalized/date';
|
|
4
3
|
import { useEffect, useMemo, useRef } from 'react';
|
|
5
4
|
import './date-input.css';
|
|
6
5
|
import { cx } from '../cx';
|
|
7
6
|
import { useFieldControl } from '../field/use-field-control';
|
|
7
|
+
import { parseIsoDate } from '../iso-date';
|
|
8
8
|
const ENGLISH_PART_NAMES = { day: 'Day', month: 'Month', year: 'Year' };
|
|
9
9
|
/*
|
|
10
10
|
* The value a form submits and `onValueChange` reports. Zag formats it for
|
|
11
11
|
* the locale by default, which is the display, not a date a database keeps.
|
|
12
12
|
*/
|
|
13
13
|
const toIso = (date) => date.toString();
|
|
14
|
-
/*
|
|
15
|
-
* A wrong shape throws, during render, where the product passed it: a
|
|
16
|
-
* timestamp or a locale string is a bug in the caller, and a control that
|
|
17
|
-
* showed something else would hide it.
|
|
18
|
-
*/
|
|
19
14
|
const toDateValue = (iso, prop) => {
|
|
20
15
|
if (iso === undefined)
|
|
21
16
|
return undefined;
|
|
22
17
|
if (iso === null || iso === '')
|
|
23
18
|
return [];
|
|
24
|
-
|
|
25
|
-
return [parseDate(iso)];
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
throw new Error(`DateInput: ${prop} must be an ISO calendar date (YYYY-MM-DD), got "${iso}"`);
|
|
29
|
-
}
|
|
19
|
+
return [parseIsoDate(iso, `DateInput: ${prop}`)];
|
|
30
20
|
};
|
|
31
21
|
/*
|
|
32
22
|
* A part's key is its type and its rank among parts of that type: the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-input.js","sourceRoot":"","sources":["../../src/date-input/date-input.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,IAAI,YAAY,EAGzB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"date-input.js","sourceRoot":"","sources":["../../src/date-input/date-input.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,IAAI,YAAY,EAGzB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAmB,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,MAAM,kBAAkB,GAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AA8DvF;;;GAGG;AACH,MAAM,KAAK,GAAG,CAAC,IAAe,EAAU,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAE3D,MAAM,WAAW,GAAG,CAAC,GAA8B,EAAE,IAAY,EAA2B,EAAE;IAC5F,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC1C,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,cAAc,IAAI,EAAE,C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kB,GAAI,IAC1D,GACP,EACvB,KAAC,YAAY,CAAC,WAAW,KAAG,IACV,CACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IconSource } from './icon/icon';
|
|
2
2
|
export declare const ChevronRight: IconSource;
|
|
3
|
+
export declare const ChevronLeft: IconSource;
|
|
3
4
|
export declare const Check: IconSource;
|
|
4
5
|
export declare const Cross: IconSource;
|
|
5
6
|
//# sourceMappingURL=fallback-glyphs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback-glyphs.d.ts","sourceRoot":"","sources":["../src/fallback-glyphs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsB9C,eAAO,MAAM,YAAY,EAAE,UAW1B,CAAC;AAGF,eAAO,MAAM,KAAK,EAAE,UAWnB,CAAC;AAGF,eAAO,MAAM,KAAK,EAAE,UAUnB,CAAC"}
|
|
1
|
+
{"version":3,"file":"fallback-glyphs.d.ts","sourceRoot":"","sources":["../src/fallback-glyphs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsB9C,eAAO,MAAM,YAAY,EAAE,UAW1B,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,UAWzB,CAAC;AAGF,eAAO,MAAM,KAAK,EAAE,UAWnB,CAAC;AAGF,eAAO,MAAM,KAAK,EAAE,UAUnB,CAAC"}
|
package/dist/fallback-glyphs.js
CHANGED
|
@@ -21,6 +21,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
21
21
|
*/
|
|
22
22
|
export const ChevronRight = (props) => (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", ...props, children: _jsx("path", { d: "m6 4 4 4-4 4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
23
23
|
ChevronRight.displayName = 'FallbackChevronRight';
|
|
24
|
+
export const ChevronLeft = (props) => (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", ...props, children: _jsx("path", { d: "M10 4 6 8l4 4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
25
|
+
ChevronLeft.displayName = 'FallbackChevronLeft';
|
|
24
26
|
export const Check = (props) => (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", ...props, children: _jsx("path", { d: "m3.5 8.5 3 3 6-6", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
25
27
|
Check.displayName = 'FallbackCheck';
|
|
26
28
|
export const Cross = (props) => (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", fill: "none", ...props, children: _jsx("path", { d: "m4 4 8 8m0-8-8 8", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback-glyphs.js","sourceRoot":"","sources":["../src/fallback-glyphs.tsx"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CACjD,6BAAiB,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,KAAK,KAAK,YAC/D,eACE,CAAC,EAAC,cAAc,EAChB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AACF,YAAY,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,KAAK,GAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1C,6BAAiB,MAAM,EAAC,OAA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K,YAC/D,eACE,CAAC,EAAC,eAAe,EACjB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AACF,WAAW,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAEhD,MAAM,CAAC,MAAM,KAAK,GAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1C,6BAAiB,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,KAAK,KAAK,YAC/D,eACE,CAAC,EAAC,kBAAkB,EACpB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,eAAe,CAAC;AAEpC,MAAM,CAAC,MAAM,KAAK,GAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1C,6BAAiB,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,KAAK,KAAK,YAC/D,eACE,CAAC,EAAC,kBAAkB,EACpB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,GACrB,GACE,CACP,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from './alert';
|
|
2
2
|
export * from './badge';
|
|
3
3
|
export * from './button';
|
|
4
|
+
export * from './calendar';
|
|
4
5
|
export * from './card';
|
|
5
6
|
export * from './checkbox';
|
|
6
7
|
export { cx } from './cx';
|
|
7
8
|
export * from './date-input';
|
|
8
9
|
export * from './dialog';
|
|
9
|
-
export { Check as FallbackCheck, ChevronRight as FallbackChevronRight, Cross as FallbackCross, } from './fallback-glyphs';
|
|
10
|
+
export { Check as FallbackCheck, ChevronLeft as FallbackChevronLeft, ChevronRight as FallbackChevronRight, Cross as FallbackCross, } from './fallback-glyphs';
|
|
10
11
|
export * from './field';
|
|
11
12
|
export * from './icon';
|
|
12
13
|
export * from './illustration';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from './alert';
|
|
2
2
|
export * from './badge';
|
|
3
3
|
export * from './button';
|
|
4
|
+
export * from './calendar';
|
|
4
5
|
export * from './card';
|
|
5
6
|
export * from './checkbox';
|
|
6
7
|
export { cx } from './cx';
|
|
7
8
|
export * from './date-input';
|
|
8
9
|
export * from './dialog';
|
|
9
|
-
export { Check as FallbackCheck, ChevronRight as FallbackChevronRight, Cross as FallbackCross, } from './fallback-glyphs';
|
|
10
|
+
export { Check as FallbackCheck, ChevronLeft as FallbackChevronLeft, ChevronRight as FallbackChevronRight, Cross as FallbackCross, } from './fallback-glyphs';
|
|
10
11
|
export * from './field';
|
|
11
12
|
export * from './icon';
|
|
12
13
|
export * from './illustration';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DateValue } from '@internationalized/date';
|
|
2
|
+
/**
|
|
3
|
+
* Parses the ISO calendar date, `YYYY-MM-DD`, that `DateInput` and
|
|
4
|
+
* `Calendar` take and give, or throws naming the prop. A wrong shape throws
|
|
5
|
+
* during render, where the product passed it: a timestamp or a locale
|
|
6
|
+
* string is a bug in the caller, and a control that showed something else
|
|
7
|
+
* would hide it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseIsoDate(iso: string, label: string): DateValue;
|
|
10
|
+
//# sourceMappingURL=iso-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iso-date.d.ts","sourceRoot":"","sources":["../src/iso-date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAMlE"}
|
package/dist/iso-date.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseDate } from '@internationalized/date';
|
|
2
|
+
/**
|
|
3
|
+
* Parses the ISO calendar date, `YYYY-MM-DD`, that `DateInput` and
|
|
4
|
+
* `Calendar` take and give, or throws naming the prop. A wrong shape throws
|
|
5
|
+
* during render, where the product passed it: a timestamp or a locale
|
|
6
|
+
* string is a bug in the caller, and a control that showed something else
|
|
7
|
+
* would hide it.
|
|
8
|
+
*/
|
|
9
|
+
export function parseIsoDate(iso, label) {
|
|
10
|
+
try {
|
|
11
|
+
return parseDate(iso);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
throw new Error(`${label} must be an ISO calendar date (YYYY-MM-DD), got "${iso}"`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=iso-date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iso-date.js","sourceRoot":"","sources":["../src/iso-date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,KAAa;IACrD,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oDAAoD,GAAG,GAAG,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -38,6 +38,13 @@ export interface PopoverProps {
|
|
|
38
38
|
* its content, up to the room beside the trigger.
|
|
39
39
|
*/
|
|
40
40
|
sameWidth?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Move focus to the first focusable thing in the panel when it opens.
|
|
43
|
+
* On by default. Turn it off when the content places focus itself, as a
|
|
44
|
+
* `Calendar` with `autoFocus` does on its chosen day: the popover would
|
|
45
|
+
* otherwise move it to the first button a frame later.
|
|
46
|
+
*/
|
|
47
|
+
autoFocus?: boolean;
|
|
41
48
|
/** Extra class names on the popover's panel. */
|
|
42
49
|
className?: string;
|
|
43
50
|
}
|
|
@@ -73,5 +80,5 @@ export interface PopoverProps {
|
|
|
73
80
|
* listbox and Menu's popup do, so it paints above the page or dialog it
|
|
74
81
|
* opens from.
|
|
75
82
|
*/
|
|
76
|
-
export declare function Popover({ trigger, label, children, open, defaultOpen, onOpenChange, placement, sameWidth, className, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export declare function Popover({ trigger, label, children, open, defaultOpen, onOpenChange, placement, sameWidth, autoFocus, className, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
77
84
|
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/popover/popover.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAGtE,OAAO,eAAe,CAAC;AAEvB,MAAM,MAAM,gBAAgB,GACxB,cAAc,GACd,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,KAAK,GACL,SAAS,CAAC;AAEd,MAAM,WAAW,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AAC;IACtB,gEAAgE;IAChE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,SAA0B,EAC1B,SAAiB,EACjB,SAAgB,EAChB,SAAS,GACV,EAAE,YAAY,2CA+Bd"}
|
package/dist/popover/popover.js
CHANGED
|
@@ -37,8 +37,8 @@ import './popover.css';
|
|
|
37
37
|
* listbox and Menu's popup do, so it paints above the page or dialog it
|
|
38
38
|
* opens from.
|
|
39
39
|
*/
|
|
40
|
-
export function Popover({ trigger, label, children, open, defaultOpen, onOpenChange, placement = 'bottom-start', sameWidth = false, className, }) {
|
|
40
|
+
export function Popover({ trigger, label, children, open, defaultOpen, onOpenChange, placement = 'bottom-start', sameWidth = false, autoFocus = true, className, }) {
|
|
41
41
|
const portalContainer = useContext(PortalContainerContext);
|
|
42
|
-
return (_jsxs(ArkPopover.Root, { lazyMount: true, unmountOnExit: true, open: open, defaultOpen: defaultOpen, onOpenChange: (details) => onOpenChange?.(details.open), positioning: { placement, sameWidth }, children: [_jsx(ArkPopover.Trigger, { asChild: true, children: trigger }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkPopover.Positioner, { children: _jsx(ArkPopover.Content, { className: cx('ds-popover__content', sameWidth && 'ds-popover__content--same-width', className), "aria-label": label, children: children }) }) })] }));
|
|
42
|
+
return (_jsxs(ArkPopover.Root, { lazyMount: true, unmountOnExit: true, open: open, defaultOpen: defaultOpen, onOpenChange: (details) => onOpenChange?.(details.open), positioning: { placement, sameWidth }, autoFocus: autoFocus, children: [_jsx(ArkPopover.Trigger, { asChild: true, children: trigger }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkPopover.Positioner, { children: _jsx(ArkPopover.Content, { className: cx('ds-popover__content', sameWidth && 'ds-popover__content--same-width', className), "aria-label": label, children: children }) }) })] }));
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sourceRoot":"","sources":["../../src/popover/popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAqC,UAAU,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"popover.js","sourceRoot":"","sources":["../../src/popover/popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAqC,UAAU,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,eAAe,CAAC;AA0DvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,SAAS,GAAG,cAAc,EAC1B,SAAS,GAAG,KAAK,EACjB,SAAS,GAAG,IAAI,EAChB,SAAS,GACI;IACb,MAAM,eAAe,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAE3D,OAAO,CACL,MAAC,UAAU,CAAC,IAAI,IACd,SAAS,QACT,aAAa,QACb,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EACvD,WAAW,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EACrC,SAAS,EAAE,SAAS,aAEpB,KAAC,UAAU,CAAC,OAAO,IAAC,OAAO,kBAAE,OAAO,GAAsB,EAE1D,KAAC,MAAM,IAAC,SAAS,EAAE,eAAe,YAChC,KAAC,UAAU,CAAC,UAAU,cACpB,KAAC,UAAU,CAAC,OAAO,IACjB,SAAS,EAAE,EAAE,CACX,qBAAqB,EACrB,SAAS,IAAI,iCAAiC,EAC9C,SAAS,CACV,gBACW,KAAK,YAEhB,QAAQ,GACU,GACC,GACjB,IACO,CACnB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manakind/ui-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"types": "./dist/button/index.d.ts",
|
|
37
37
|
"import": "./dist/button/index.js"
|
|
38
38
|
},
|
|
39
|
+
"./calendar": {
|
|
40
|
+
"types": "./dist/calendar/index.d.ts",
|
|
41
|
+
"import": "./dist/calendar/index.js"
|
|
42
|
+
},
|
|
39
43
|
"./card": {
|
|
40
44
|
"types": "./dist/card/index.d.ts",
|
|
41
45
|
"import": "./dist/card/index.js"
|
|
@@ -104,6 +108,10 @@
|
|
|
104
108
|
"types": "./dist/button/button.css.d.ts",
|
|
105
109
|
"default": "./dist/button/button.css"
|
|
106
110
|
},
|
|
111
|
+
"./css/calendar": {
|
|
112
|
+
"types": "./dist/calendar/calendar.css.d.ts",
|
|
113
|
+
"default": "./dist/calendar/calendar.css"
|
|
114
|
+
},
|
|
107
115
|
"./css/card": {
|
|
108
116
|
"types": "./dist/card/card.css.d.ts",
|
|
109
117
|
"default": "./dist/card/card.css"
|
|
@@ -179,7 +187,7 @@
|
|
|
179
187
|
},
|
|
180
188
|
"devDependencies": {
|
|
181
189
|
"@manakind/ds-config": "*",
|
|
182
|
-
"@manakind/manuia-tokens": "0.
|
|
190
|
+
"@manakind/manuia-tokens": "0.13.0",
|
|
183
191
|
"@testing-library/jest-dom": "^6.9.1",
|
|
184
192
|
"@testing-library/react": "^16.3.2",
|
|
185
193
|
"@testing-library/user-event": "^14.6.1",
|