@tristan2828/ui-foundation 4.93.0 → 4.95.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.
@@ -28,8 +28,22 @@ export type EqualItem = {
28
28
  title: string;
29
29
  /** A small status, as a badge: words alone are a neutral one. */
30
30
  state?: string | EqualItemState;
31
- /** Its details, in order. None reads as `noFieldsText`. */
31
+ /** Its details, in order. None (and no `content`) reads as `noFieldsText`. */
32
32
  fields?: readonly EqualItemField[];
33
+ /**
34
+ * Anything of the app's, under the fields at the item's full width (an
35
+ * editor of several fields, a note): never squeezed into the label/value
36
+ * grid. In the `table` look, a row of its own under the item's.
37
+ */
38
+ content?: ReactNode;
39
+ /**
40
+ * The item's own buttons (Edit, Remove), small and named for the item
41
+ * ("Edit Phase 2"): at the end of its title line, beside a featured
42
+ * toggle's button (never inside it), or the `table` look's last column.
43
+ */
44
+ actions?: ReactNode;
45
+ /** The whole row in the `cards` and `panels` looks (an editor open in it). */
46
+ wide?: boolean;
33
47
  };
34
48
  export type EqualItemsProps = {
35
49
  items: readonly EqualItem[];
@@ -53,6 +67,8 @@ export type EqualItemsProps = {
53
67
  titleColumn?: string;
54
68
  /** For `look="table"`: the state column's heading. Defaults to "Status". */
55
69
  stateColumn?: string;
70
+ /** For `look="table"`: the actions column's heading, for screen readers. Defaults to "Actions". */
71
+ actionsColumn?: string;
56
72
  /** What no items says. Defaults to "Nothing yet". */
57
73
  emptyText?: string;
58
74
  /** What an item with no fields says. Defaults to "No details". */
@@ -79,6 +95,8 @@ export type EqualItemsProps = {
79
95
  * `cards` for a few things with little to say about each, `table` for
80
96
  * things compared on the same values, `featured` when one is current or
81
97
  * best, `panels` when each has several details and must read as separate
82
- * (design-language.md "A few equal things").
98
+ * (design-language.md "A few equal things"). An item's own `content` (an
99
+ * editor) goes under its fields at full width, its `actions` (Edit, Remove)
100
+ * at its title line's end; `wide` gives it the whole row of cards or panels.
83
101
  */
84
- export declare function EqualItems({ items, look, featuredId, defaultOpenIds, label, headingLevel, titleColumn, stateColumn, emptyText, noFieldsText, className, }: EqualItemsProps): import("react").JSX.Element;
102
+ export declare function EqualItems({ items, look, featuredId, defaultOpenIds, label, headingLevel, titleColumn, stateColumn, actionsColumn, emptyText, noFieldsText, className, }: EqualItemsProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  // A few equal things in a record (record page standard R10): the phases of
3
3
  // a plan, the stores a price is compared at, a handful of options. One data
4
4
  // shape, four looks, each the record picks for what it shows:
@@ -22,7 +22,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
22
  // value is the record's dash, read as "Not set". It owns its empty states:
23
23
  // no items reads `emptyText` ("Nothing yet"), an item with no fields
24
24
  // `noFieldsText` ("No details").
25
- import { useState } from 'react';
25
+ //
26
+ // An item can carry its own parts too (4.94): `content`, anything of the
27
+ // app's (an editor of several fields, a note, a chart), drawn under its
28
+ // fields at the item's full width, never in the label/value grid; and
29
+ // `actions`, its own buttons (Edit, Remove), at the end of its title line,
30
+ // or the table's last column. `wide` gives an item the whole row in
31
+ // `cards` and `panels`, for content that needs it (an editor open).
32
+ import { Fragment, useState } from 'react';
26
33
  import { ChevronDownIcon } from 'lucide-react';
27
34
  import { cn } from 'cn';
28
35
  import { Badge } from '../ui/badge.js';
@@ -62,31 +69,51 @@ function Fields({ fields, noFieldsText, rows, }) {
62
69
  }
63
70
  return (_jsx("dl", { "data-slot": "equal-item-fields", className: "@container/fields flex flex-col divide-y divide-border", children: fields.map((field, index) => (_jsxs("div", { className: cn(FIELD_ROW_BASE, rows === 'beside' && FIELD_ROW.railBeside), children: [_jsx("dt", { className: FIELD_LABEL, children: field.label }), _jsx("dd", { className: FIELD_VALUE, children: _jsx(Value, { value: field.value }) })] }, `${field.label}-${index}`))) }));
64
71
  }
72
+ const hasPart = (part) => part !== undefined && part !== null && part !== false;
73
+ function Actions({ actions, className }) {
74
+ if (!hasPart(actions))
75
+ return null;
76
+ return (_jsx("div", { "data-slot": "equal-item-actions", className: cn('flex shrink-0 flex-wrap items-center justify-end gap-1', className), children: actions }));
77
+ }
78
+ // The title and its state, then the item's actions at the line's end.
65
79
  function Title({ item, level, className }) {
66
80
  const Heading = `h${level}`;
67
- return (_jsxs("div", { className: cn('flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1', className), children: [_jsx(Heading, { className: "min-w-0 type-body font-semibold break-words text-foreground", children: item.title }), _jsx(StateBadge, { state: item.state })] }));
81
+ const withActions = hasPart(item.actions);
82
+ const heading = (_jsxs("div", { className: cn('flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1', withActions ? 'flex-1' : className), children: [_jsx(Heading, { className: "min-w-0 type-body font-semibold break-words text-foreground", children: item.title }), _jsx(StateBadge, { state: item.state })] }));
83
+ if (!withActions)
84
+ return heading;
85
+ return (_jsxs("div", { className: cn('flex min-w-0 items-start gap-2', className), children: [heading, _jsx(Actions, { actions: item.actions, className: "-my-1" })] }));
86
+ }
87
+ // An item's body: its fields, then its own content at full width. Content
88
+ // alone needs no fields, and reads no "No details".
89
+ function Body({ item, noFieldsText, rows, }) {
90
+ if (!hasPart(item.content))
91
+ return _jsx(Fields, { fields: item.fields, noFieldsText: noFieldsText, rows: rows });
92
+ return (_jsxs(_Fragment, { children: [item.fields && item.fields.length > 0 && _jsx(Fields, { fields: item.fields, noFieldsText: noFieldsText, rows: rows }), _jsx("div", { "data-slot": "equal-item-content", className: "min-w-0", children: item.content })] }));
68
93
  }
69
94
  function Cards({ items, label, level, noFieldsText }) {
70
- return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-[repeat(auto-fill,minmax(min(100%,14rem),1fr))] gap-3", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", className: "flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-4 text-card-foreground", children: [_jsx(Title, { item: item, level: level }), _jsx(Fields, { fields: item.fields, noFieldsText: noFieldsText, rows: "compact" })] }, item.id))) }));
95
+ return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-[repeat(auto-fill,minmax(min(100%,14rem),1fr))] gap-3", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", "data-wide": item.wide ? '' : undefined, className: cn('flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-4 text-card-foreground', item.wide && 'col-span-full'), children: [_jsx(Title, { item: item, level: level }), _jsx(Body, { item: item, noFieldsText: noFieldsText, rows: "compact" })] }, item.id))) }));
71
96
  }
72
97
  function Panels({ items, label, level, noFieldsText }) {
73
- return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-1 gap-3 sm:grid-cols-[repeat(auto-fit,minmax(14rem,1fr))]", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", className: "flex min-w-0 flex-col overflow-hidden rounded-lg border border-border bg-card text-card-foreground", children: [_jsx(Title, { item: item, level: level, className: "border-b border-border bg-muted/40 px-4 py-3" }), _jsx("div", { className: "px-4 py-3", children: _jsx(Fields, { fields: item.fields, noFieldsText: noFieldsText, rows: "stacked" }) })] }, item.id))) }));
98
+ return (_jsx("ul", { "aria-label": label, className: "grid grid-cols-1 gap-3 sm:grid-cols-[repeat(auto-fit,minmax(14rem,1fr))]", children: items.map((item) => (_jsxs("li", { "data-slot": "equal-item", "data-wide": item.wide ? '' : undefined, className: cn('flex min-w-0 flex-col overflow-hidden rounded-lg border border-border bg-card text-card-foreground', item.wide && 'col-span-full'), children: [_jsx(Title, { item: item, level: level, className: "border-b border-border bg-muted/40 px-4 py-3" }), _jsx("div", { className: "flex flex-col gap-3 px-4 py-3", children: _jsx(Body, { item: item, noFieldsText: noFieldsText, rows: "stacked" }) })] }, item.id))) }));
74
99
  }
75
100
  // One column per field label, in the order the items first give them; an
76
101
  // item without one reads as a dash there. The title is each row's header.
77
- function ItemsTable({ items, label, titleColumn, stateColumn, }) {
102
+ function ItemsTable({ items, label, titleColumn, stateColumn, actionsColumn, }) {
78
103
  const columns = [];
79
104
  for (const item of items)
80
105
  for (const field of item.fields ?? [])
81
106
  if (!columns.includes(field.label))
82
107
  columns.push(field.label);
83
108
  const hasState = items.some((item) => stateOf(item.state));
84
- return (_jsx("div", { "data-slot": "equal-items-table", className: "rounded-lg border border-border bg-card text-card-foreground", children: _jsxs(Table, { children: [_jsx("caption", { className: "sr-only", children: label }), _jsx(TableHeader, { children: _jsxs(TableRow, { className: "hover:bg-transparent", children: [_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: titleColumn }), hasState && (_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: stateColumn })), columns.map((column) => (_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: column }, column)))] }) }), _jsx(TableBody, { className: "[&_tr:nth-child(even)]:bg-transparent", children: items.map((item) => (_jsxs(TableRow, { "data-slot": "equal-item", children: [_jsx(TableHead, { scope: "row", className: "h-auto min-w-28 py-(--table-cell-py) font-semibold sm:min-w-40 break-words whitespace-normal", children: item.title }), hasState && (_jsx(TableCell, { children: stateOf(item.state) ? _jsx(StateBadge, { state: item.state }) : _jsx(EmptyText, { text: EMPTY_DASH }) })), columns.map((column) => (_jsx(TableCell, { className: "type-body tabular-nums", children: _jsx(Value, { value: item.fields?.find((field) => field.label === column)?.value }) }, column)))] }, item.id))) })] }) }));
109
+ const hasActions = items.some((item) => hasPart(item.actions));
110
+ const span = 1 + (hasState ? 1 : 0) + columns.length + (hasActions ? 1 : 0);
111
+ return (_jsx("div", { "data-slot": "equal-items-table", className: "@container/equal-table rounded-lg border border-border bg-card text-card-foreground", children: _jsxs(Table, { children: [_jsx("caption", { className: "sr-only", children: label }), _jsx(TableHeader, { children: _jsxs(TableRow, { className: "hover:bg-transparent", children: [_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: titleColumn }), hasState && (_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: stateColumn })), columns.map((column) => (_jsx(TableHead, { scope: "col", className: "type-label text-muted-foreground", children: column }, column))), hasActions && (_jsx(TableHead, { scope: "col", children: _jsx("span", { className: "sr-only", children: actionsColumn }) }))] }) }), _jsx(TableBody, { className: "[&_tr:nth-child(even)]:bg-transparent", children: items.map((item) => (_jsxs(Fragment, { children: [_jsxs(TableRow, { "data-slot": "equal-item", className: cn(hasPart(item.content) && 'border-b-0'), children: [_jsx(TableHead, { scope: "row", className: "h-auto min-w-28 py-(--table-cell-py) font-semibold sm:min-w-40 break-words whitespace-normal", children: item.title }), hasState && (_jsx(TableCell, { children: stateOf(item.state) ? _jsx(StateBadge, { state: item.state }) : _jsx(EmptyText, { text: EMPTY_DASH }) })), columns.map((column) => (_jsx(TableCell, { className: "type-body tabular-nums", children: _jsx(Value, { value: item.fields?.find((field) => field.label === column)?.value }) }, column))), hasActions && (_jsx(TableCell, { className: "w-0 py-1", children: _jsx(Actions, { actions: item.actions, className: "flex-nowrap" }) }))] }), hasPart(item.content) && (_jsx(TableRow, { "data-slot": "equal-item-content-row", className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: span, className: "pt-0 whitespace-normal", children: _jsx("div", { "data-slot": "equal-item-content", className: "sticky left-(--table-cell-px) w-[calc(100cqw-var(--table-cell-px)*2)] min-w-0", children: item.content }) }) }))] }, item.id))) })] }) }));
85
112
  }
86
113
  function Featured({ items, label, level, noFieldsText, featuredId, defaultOpenIds, }) {
87
114
  const featured = items.find((item) => item.id === featuredId) ?? items[0];
88
115
  const rest = items.filter((item) => item !== featured);
89
- return (_jsxs("div", { role: "group", "aria-label": label, className: "flex flex-col gap-3", children: [_jsxs("section", { "data-slot": "equal-item", "data-featured": "", "aria-label": featured.title, className: "flex min-w-0 flex-col gap-3 rounded-lg border border-primary bg-card p-4 text-card-foreground", children: [_jsx(Title, { item: featured, level: level }), _jsx(Fields, { fields: featured.fields, noFieldsText: noFieldsText, rows: "beside" })] }), rest.length > 0 && (_jsx("ul", { className: "flex flex-col divide-y divide-border rounded-lg border border-border bg-card text-card-foreground", children: rest.map((item) => (_jsx(FeaturedToggle, { item: item, level: level, noFieldsText: noFieldsText, defaultOpen: defaultOpenIds?.includes(item.id) ?? false }, item.id))) }))] }));
116
+ return (_jsxs("div", { role: "group", "aria-label": label, className: "flex flex-col gap-3", children: [_jsxs("section", { "data-slot": "equal-item", "data-featured": "", "aria-label": featured.title, className: "flex min-w-0 flex-col gap-3 rounded-lg border border-primary bg-card p-4 text-card-foreground", children: [_jsx(Title, { item: featured, level: level }), _jsx(Body, { item: featured, noFieldsText: noFieldsText, rows: "beside" })] }), rest.length > 0 && (_jsx("ul", { className: "flex flex-col divide-y divide-border rounded-lg border border-border bg-card text-card-foreground", children: rest.map((item) => (_jsx(FeaturedToggle, { item: item, level: level, noFieldsText: noFieldsText, defaultOpen: defaultOpenIds?.includes(item.id) ?? false }, item.id))) }))] }));
90
117
  }
91
118
  // A heading holding its button (the disclosure pattern): Enter and Space
92
119
  // open and close it, Tab moves on to the next, and the button says
@@ -94,7 +121,7 @@ function Featured({ items, label, level, noFieldsText, featuredId, defaultOpenId
94
121
  function FeaturedToggle({ item, level, noFieldsText, defaultOpen, }) {
95
122
  const [open, setOpen] = useState(defaultOpen);
96
123
  const Heading = `h${level}`;
97
- return (_jsx("li", { "data-slot": "equal-item", children: _jsxs(Collapsible, { open: open, onOpenChange: setOpen, children: [_jsx(Heading, { className: "m-0", children: _jsxs(CollapsibleTrigger, { "data-slot": "equal-item-toggle", className: "flex min-h-11 w-full items-center gap-2 px-4 py-2 text-left outline-none hover:bg-muted/50 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset", children: [_jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('size-4 shrink-0 text-muted-foreground transition-transform', !open && '-rotate-90') }), _jsxs("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [_jsx("span", { className: "min-w-0 type-body font-semibold break-words text-foreground", children: item.title }), _jsx(StateBadge, { state: item.state })] })] }) }), _jsx(CollapsibleContent, { className: "px-4 pt-1 pb-4 pl-10", children: _jsx(Fields, { fields: item.fields, noFieldsText: noFieldsText, rows: "beside" }) })] }) }));
124
+ return (_jsx("li", { "data-slot": "equal-item", children: _jsxs(Collapsible, { open: open, onOpenChange: setOpen, children: [_jsxs("div", { className: "flex min-w-0 items-center", children: [_jsx(Heading, { className: "m-0 min-w-0 flex-1", children: _jsxs(CollapsibleTrigger, { "data-slot": "equal-item-toggle", className: "flex min-h-11 w-full items-center gap-2 px-4 py-2 text-left outline-none hover:bg-muted/50 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset", children: [_jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('size-4 shrink-0 text-muted-foreground transition-transform', !open && '-rotate-90') }), _jsxs("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [_jsx("span", { className: "min-w-0 type-body font-semibold break-words text-foreground", children: item.title }), _jsx(StateBadge, { state: item.state })] })] }) }), _jsx(Actions, { actions: item.actions, className: "pr-4" })] }), _jsx(CollapsibleContent, { className: "flex flex-col gap-3 px-4 pt-1 pb-4 pl-10", children: _jsx(Body, { item: item, noFieldsText: noFieldsText, rows: "beside" }) })] }) }));
98
125
  }
99
126
  /**
100
127
  * A few equal, related things inside a record view (record page standard
@@ -116,12 +143,14 @@ function FeaturedToggle({ item, level, noFieldsText, defaultOpen, }) {
116
143
  * `cards` for a few things with little to say about each, `table` for
117
144
  * things compared on the same values, `featured` when one is current or
118
145
  * best, `panels` when each has several details and must read as separate
119
- * (design-language.md "A few equal things").
146
+ * (design-language.md "A few equal things"). An item's own `content` (an
147
+ * editor) goes under its fields at full width, its `actions` (Edit, Remove)
148
+ * at its title line's end; `wide` gives it the whole row of cards or panels.
120
149
  */
121
- export function EqualItems({ items, look = 'cards', featuredId, defaultOpenIds, label, headingLevel = 3, titleColumn = 'Name', stateColumn = 'Status', emptyText = 'Nothing yet', noFieldsText = 'No details', className, }) {
150
+ export function EqualItems({ items, look = 'cards', featuredId, defaultOpenIds, label, headingLevel = 3, titleColumn = 'Name', stateColumn = 'Status', actionsColumn = 'Actions', emptyText = 'Nothing yet', noFieldsText = 'No details', className, }) {
122
151
  if (items.length === 0) {
123
152
  return (_jsx("p", { "data-slot": "equal-items", "data-look": look, "data-state": "empty", className: cn('type-body text-muted-foreground', className), children: emptyText }));
124
153
  }
125
154
  const shared = { items, label, level: headingLevel, noFieldsText };
126
- return (_jsx("div", { "data-slot": "equal-items", "data-look": look, className: cn('min-w-0', className), children: look === 'table' ? (_jsx(ItemsTable, { items: items, label: label, titleColumn: titleColumn, stateColumn: stateColumn })) : look === 'featured' ? (_jsx(Featured, { ...shared, featuredId: featuredId, defaultOpenIds: defaultOpenIds })) : look === 'panels' ? (_jsx(Panels, { ...shared })) : (_jsx(Cards, { ...shared })) }));
155
+ return (_jsx("div", { "data-slot": "equal-items", "data-look": look, className: cn('min-w-0', className), children: look === 'table' ? (_jsx(ItemsTable, { items: items, label: label, titleColumn: titleColumn, stateColumn: stateColumn, actionsColumn: actionsColumn })) : look === 'featured' ? (_jsx(Featured, { ...shared, featuredId: featuredId, defaultOpenIds: defaultOpenIds })) : look === 'panels' ? (_jsx(Panels, { ...shared })) : (_jsx(Cards, { ...shared })) }));
127
156
  }
@@ -0,0 +1,36 @@
1
+ import { type Recurrence } from '../../lib/recurrence.js';
2
+ export type RecurrenceFieldProps = {
3
+ /** The phrase box's id, for the field's `<FieldLabel htmlFor>`. */
4
+ id?: string;
5
+ /** The repeat, or `null` for none. */
6
+ value: Recurrence | null;
7
+ /** Called with each readable repeat, or `null` when the box is emptied or can't be read. */
8
+ onChange: (value: Recurrence | null) => void;
9
+ /** The IANA zone a new repeat is read in. Defaults to the value's, else the browser's. */
10
+ timeZone?: string;
11
+ /** The times a new repeat starts with when the phrase has none. Defaults to the value's, else 09:00. */
12
+ defaultTimes?: string[];
13
+ /** Today, `'YYYY-MM-DD'`: where a phrase's days count from. Defaults to today in the zone. */
14
+ today?: string;
15
+ /** What "now" is for the preview's next occurrences. Defaults to the clock. */
16
+ now?: Date;
17
+ /** How many next occurrences the preview lists. Defaults to 5; 0 hides the list. */
18
+ previewCount?: number;
19
+ /** Show the preset buttons (the default). */
20
+ presets?: boolean;
21
+ locale?: string;
22
+ /** The value was refused: `aria-invalid` on the box. */
23
+ invalid?: boolean;
24
+ readOnly?: boolean;
25
+ /**
26
+ * Told when the phrase can't be read (with why), and `null` once it can:
27
+ * editing in place gives it to `onProblem`, so the field won't save.
28
+ */
29
+ onProblem?: (message: string | null) => void;
30
+ /** Called when the box is left, for a form's `onBlur`. */
31
+ onBlur?: () => void;
32
+ className?: string;
33
+ 'aria-label'?: string;
34
+ 'aria-describedby'?: string;
35
+ };
36
+ export declare function RecurrenceField({ id, value, onChange, timeZone, defaultTimes, today, now, previewCount, presets, locale, invalid, readOnly, onProblem, onBlur, className, 'aria-label': ariaLabel, 'aria-describedby': describedBy, }: RecurrenceFieldProps): import("react").JSX.Element;
@@ -0,0 +1,143 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // How something repeats (#326): a reminder's or a task's schedule. The
3
+ // value is the contract's `Recurrence` (`lib/recurrence.ts`), or `null`
4
+ // for none.
5
+ //
6
+ // Three parts, one under the other:
7
+ // - **Presets**, a row of toggle buttons: Daily, Weekdays, Weekly on Thu,
8
+ // Monthly on the 12th, Monthly on the 2nd Thu, Yearly on Nov 12 (each
9
+ // from the start day) and Custom. The one the value is stays pressed;
10
+ // Custom is pressed for anything else, and moves to the phrase box.
11
+ // - **The phrase box**, read as you type (`parseRecurrencePhrase`): "every
12
+ // 2nd tue at 9am", "every! 3 days", "every jan 1 until mar 1". What it
13
+ // can't read is said under it, and the field gives `null`, so a form
14
+ // never keeps the rule it had before (DateField does the same).
15
+ // - **The preview**: the rule's label ("Every 2nd Tue at 9:00 AM") and its
16
+ // next five occurrences, in the rule's zone, or why it can't be read.
17
+ //
18
+ // One control for the form (a react-hook-form `Controller`) and for
19
+ // editing in place (`inPlace.recurrence`: Enter in the box or leaving the
20
+ // field saves). The box is the field's labelled control (`id`); the
21
+ // presets name themselves "Presets".
22
+ import { useId, useRef, useState } from 'react';
23
+ import { RepeatIcon } from 'lucide-react';
24
+ import { cn } from 'cn';
25
+ import { Input } from '../ui/input.js';
26
+ import { ToggleGroup, ToggleGroupItem } from '../ui/toggle-group.js';
27
+ import { formatOccurrence, formatRecurrence, todayIn } from '../../lib/recurrence-format.js';
28
+ import { ordinalWord, parseRecurrencePhrase, recurrencePhrase } from '../../lib/recurrence-phrase.js';
29
+ import { nextOccurrences, normalizeRecurrence, recurrenceProblem, WEEKDAY_CODES } from '../../lib/recurrence.js';
30
+ function weekdayOf(day) {
31
+ return (new Date(`${day}T00:00:00Z`).getUTCDay() + 6) % 7;
32
+ }
33
+ function dayName(day, locale) {
34
+ return new Intl.DateTimeFormat(locale, { weekday: 'short', timeZone: 'UTC' }).format(Date.UTC(2024, 0, 1 + day));
35
+ }
36
+ /** The presets for a start day: each a rule built from that day. */
37
+ function presetsFor(start, locale) {
38
+ const [year, month, date] = start.split('-').map(Number);
39
+ const weekday = weekdayOf(start);
40
+ const lastOfMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();
41
+ // The 2nd Thu; the last one when it's the month's last (a 5th, or a 4th with no 5th).
42
+ const nth = date + 7 > lastOfMonth ? -1 : Math.ceil(date / 7);
43
+ const code = WEEKDAY_CODES[weekday];
44
+ const yearDay = new Intl.DateTimeFormat(locale, { month: 'short', day: 'numeric', timeZone: 'UTC' }).format(Date.UTC(2024, month - 1, date));
45
+ return [
46
+ { id: 'daily', label: 'Daily', rule: 'FREQ=DAILY' },
47
+ { id: 'weekdays', label: 'Weekdays', rule: 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR' },
48
+ { id: 'weekly', label: `Weekly on ${dayName(weekday, locale)}`, rule: `FREQ=WEEKLY;BYDAY=${code}` },
49
+ { id: 'monthly', label: `Monthly on the ${ordinalWord(date)}`, rule: `FREQ=MONTHLY;BYMONTHDAY=${date}` },
50
+ {
51
+ id: 'nth',
52
+ label: `Monthly on the ${nth === -1 ? 'last' : ordinalWord(nth)} ${dayName(weekday, locale)}`,
53
+ rule: `FREQ=MONTHLY;BYDAY=${nth}${code}`,
54
+ },
55
+ { id: 'yearly', label: `Yearly on ${yearDay}`, rule: `FREQ=YEARLY;BYMONTH=${month};BYMONTHDAY=${date}` },
56
+ { id: 'custom', label: 'Custom', rule: null },
57
+ ];
58
+ }
59
+ function browserZone() {
60
+ try {
61
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
62
+ }
63
+ catch {
64
+ return 'UTC';
65
+ }
66
+ }
67
+ const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
68
+ export function RecurrenceField({ id, value, onChange, timeZone, defaultTimes, today, now, previewCount = 5, presets = true, locale, invalid = false, readOnly = false, onProblem, onBlur, className, 'aria-label': ariaLabel, 'aria-describedby': describedBy, }) {
69
+ const zone = value?.timeZone ?? timeZone ?? browserZone();
70
+ const day = today ?? todayIn(zone, now);
71
+ const ownId = useId();
72
+ const boxId = id ?? `${ownId}-phrase`;
73
+ const messageId = `${ownId}-message`;
74
+ const previewId = `${ownId}-preview`;
75
+ const box = useRef(null);
76
+ // The box's text, and the value it last read (or was given). A new value
77
+ // from outside (a preset, the form's reset) is written back as its phrase.
78
+ const [text, setText] = useState(() => (value ? (recurrencePhrase(value, day) ?? '') : ''));
79
+ const [problem, setProblem] = useState(null);
80
+ const [known, setKnown] = useState(value);
81
+ if (!same(known, value)) {
82
+ setKnown(value);
83
+ if (value !== null || problem === null) {
84
+ setText(value ? (recurrencePhrase(value, day) ?? '') : '');
85
+ setProblem(null);
86
+ }
87
+ }
88
+ const emit = (next, why) => {
89
+ setKnown(next);
90
+ setProblem(why);
91
+ onProblem?.(why);
92
+ onChange(next);
93
+ };
94
+ const read = (phrase) => {
95
+ setText(phrase);
96
+ if (phrase.trim() === '') {
97
+ emit(null, null);
98
+ return;
99
+ }
100
+ const result = parseRecurrencePhrase(phrase, {
101
+ today: day,
102
+ timeZone: zone,
103
+ times: value?.times ?? defaultTimes,
104
+ start: value?.start,
105
+ });
106
+ if (result.ok)
107
+ emit(result.value, null);
108
+ else
109
+ emit(null, result.error);
110
+ };
111
+ const start = value?.start ?? day;
112
+ const options = presetsFor(start, locale);
113
+ const pressed = value ? (options.find((option) => option.rule === value.rule)?.id ?? 'custom') : null;
114
+ const pick = (preset) => {
115
+ if (preset.rule === null) {
116
+ box.current?.focus();
117
+ return;
118
+ }
119
+ const next = normalizeRecurrence({
120
+ rule: preset.rule,
121
+ start,
122
+ times: value?.times ?? defaultTimes ?? ['09:00'],
123
+ timeZone: zone,
124
+ fromCompletion: false,
125
+ });
126
+ setText(recurrencePhrase(next, day) ?? '');
127
+ emit(next, null);
128
+ };
129
+ // A press on a preset is its own: Enter there mustn't also reach editing
130
+ // in place's Enter-saves (it would save the draft from before the press).
131
+ const keepEnter = (event) => {
132
+ if (event.key === 'Enter')
133
+ event.stopPropagation();
134
+ };
135
+ const stored = value ? recurrenceProblem(value) : null;
136
+ const shownProblem = problem ?? stored;
137
+ const upcoming = value && !shownProblem && previewCount > 0 ? nextOccurrences(value, now ?? new Date(), previewCount) : [];
138
+ return (_jsxs("div", { "data-slot": "recurrence-field", className: cn('flex min-w-0 flex-col gap-2', className), children: [presets && (_jsx(ToggleGroup, { "data-slot": "recurrence-presets", variant: "outline", spacing: 1, "aria-label": "Presets", value: pressed ? [pressed] : [], onValueChange: (next) => {
139
+ const chosen = options.find((option) => option.id === (next[0] ?? pressed));
140
+ if (chosen)
141
+ pick(chosen);
142
+ }, onKeyDown: keepEnter, disabled: readOnly, className: "max-w-full flex-wrap", children: options.map((option) => (_jsx(ToggleGroupItem, { value: option.id, className: "h-(--control-height,--spacing(8)) px-3 font-normal text-muted-foreground aria-pressed:font-medium aria-pressed:text-foreground", children: option.label }, option.id))) })), _jsxs("div", { className: "relative", children: [_jsx(RepeatIcon, { "aria-hidden": "true", className: "pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { ref: box, id: boxId, value: text, onChange: (event) => read(event.target.value), onBlur: onBlur, readOnly: readOnly, placeholder: "every 2nd tue at 9am", autoComplete: "off", spellCheck: false, className: "pl-8", "aria-label": ariaLabel, "aria-invalid": invalid || !!shownProblem || undefined, "aria-describedby": [shownProblem ? messageId : previewId, describedBy].filter(Boolean).join(' ') || undefined })] }), _jsx("div", { "data-slot": "recurrence-preview", "aria-live": "polite", className: "text-sm", children: shownProblem ? (_jsx("p", { id: messageId, className: "text-destructive-text", children: shownProblem })) : value ? (_jsxs("div", { id: previewId, children: [_jsx("p", { className: "font-medium text-foreground", children: formatRecurrence(value, { locale }) }), previewCount > 0 && (_jsx(_Fragment, { children: upcoming.length ? (_jsx("ol", { "aria-label": "Next", className: "mt-1 flex flex-col gap-0.5 text-muted-foreground tabular-nums", children: upcoming.map((moment) => (_jsx("li", { children: formatOccurrence(moment, value.timeZone, { locale, now }) }, moment.getTime()))) })) : (_jsx("p", { className: "mt-1 text-muted-foreground", children: "No more to come." })) }))] })) : (_jsx("p", { id: previewId, className: "text-muted-foreground", children: "Doesn\u2019t repeat. Pick a preset or type how it repeats." })) })] }));
143
+ }
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ export { JobStatus, type JobProgress, type JobStatusProps } from './components/a
37
37
  export { OfflineNotice, type OfflineNoticeProps } from './components/app/offline-notice.js';
38
38
  export { useOffline } from './lib/connection.js';
39
39
  export { editInPlace, type EditControlProps, type EditInPlace, type EditInPlaceList, type EditInPlaceListOptions, type EditInPlaceOptions, type EditKind, type EditListAddProps, type EditListItemProps, } from './components/app/edit-in-place.js';
40
- export { inPlace, type InPlaceDateConfig, type InPlaceFieldsOptions, type InPlaceLinkConfig, type InPlaceLinkValue, type InPlaceMoneyConfig, type InPlaceMonthDayConfig, type InPlaceNumberConfig, type InPlaceOption, type InPlacePart, type InPlaceRecord, type InPlaceReferenceConfig, type InPlaceSaved, type InPlaceSelectConfig, type InPlaceTextConfig, } from './components/app/edit-in-place-presets.js';
40
+ export { inPlace, type InPlaceDateConfig, type InPlaceFieldsOptions, type InPlaceLinkConfig, type InPlaceLinkValue, type InPlaceMoneyConfig, type InPlaceMonthDayConfig, type InPlaceNumberConfig, type InPlaceOption, type InPlacePart, type InPlaceRecord, type InPlaceRecurrenceConfig, type InPlaceReferenceConfig, type InPlaceSaved, type InPlaceSelectConfig, type InPlaceTextConfig, } from './components/app/edit-in-place-presets.js';
41
41
  export { linkHost, linkHref, linkRule } from './lib/link-href.js';
42
42
  export { DataEnvironmentBanner } from './components/app/data-environment-banner.js';
43
43
  export { EditableValue, type EditableValueProps } from './components/app/editable-value.js';
@@ -89,6 +89,10 @@ export { ImageField, type ImageFieldProps } from './components/app/image-field.j
89
89
  export { DEFAULT_IMAGE_TYPES, type ImageUpload, type ImageUploadResult } from './lib/image-file.js';
90
90
  export { formatPlainDate, parsePlainDate, plainDateExamples, unreadableDateMessage, type ParsePlainDateOptions, type PlainDate, } from './lib/plain-date.js';
91
91
  export { formatMonthDay, isMonthDay, monthDayProblem, type MonthDay } from './lib/month-day.js';
92
+ export { RecurrenceField, type RecurrenceFieldProps } from './components/app/recurrence-field.js';
93
+ export { atLocal, formatRule, nextAfterCompletion, nextOccurrence, nextOccurrences, normalizeRecurrence, parseRule, RecurrenceError, recurrenceFromWeekdays, recurrenceProblem, type Recurrence, type RuleParts, } from './lib/recurrence.js';
94
+ export { parseRecurrencePhrase, recurrencePhrase, type PhraseOptions, type PhraseResult, } from './lib/recurrence-phrase.js';
95
+ export { formatOccurrence, formatRecurrence, todayIn, type OccurrenceFormatOptions, type RecurrenceFormatOptions, } from './lib/recurrence-format.js';
92
96
  export { ChoiceCell, LinkCell, LinkOut, NameCell, type ChoiceCellProps, type LinkCellProps, type NameCellProps, } from './components/app/row-edit-cells.js';
93
97
  export { ModuleCard, ModuleStrip, type CategorySlot, type ModuleCardLink, type ModuleCardPlace, type ModuleCardProps, type ModuleStripMobile, type ModuleStripProps, } from './components/app/module-card.js';
94
98
  export { WidgetCard, WidgetCardGroup, WidgetList, WidgetListItem, type WidgetCardGroupProps, type WidgetCardLink, type WidgetCardProps, type WidgetListItemProps, } from './components/app/widget-card.js';
package/dist/index.js CHANGED
@@ -93,6 +93,10 @@ export { ImageField } from './components/app/image-field.js';
93
93
  export { DEFAULT_IMAGE_TYPES } from './lib/image-file.js';
94
94
  export { formatPlainDate, parsePlainDate, plainDateExamples, unreadableDateMessage, } from './lib/plain-date.js';
95
95
  export { formatMonthDay, isMonthDay, monthDayProblem } from './lib/month-day.js';
96
+ export { RecurrenceField } from './components/app/recurrence-field.js';
97
+ export { atLocal, formatRule, nextAfterCompletion, nextOccurrence, nextOccurrences, normalizeRecurrence, parseRule, RecurrenceError, recurrenceFromWeekdays, recurrenceProblem, } from './lib/recurrence.js';
98
+ export { parseRecurrencePhrase, recurrencePhrase, } from './lib/recurrence-phrase.js';
99
+ export { formatOccurrence, formatRecurrence, todayIn, } from './lib/recurrence-format.js';
96
100
  export { ChoiceCell, LinkCell, LinkOut, NameCell, } from './components/app/row-edit-cells.js';
97
101
  export { ModuleCard, ModuleStrip, } from './components/app/module-card.js';
98
102
  export { WidgetCard, WidgetCardGroup, WidgetList, WidgetListItem, } from './components/app/widget-card.js';
@@ -0,0 +1,26 @@
1
+ import { type Recurrence } from './recurrence.js';
2
+ export type RecurrenceFormatOptions = {
3
+ locale?: string;
4
+ /** Leave the times out ("Every 2nd Tue"), for a cell beside a separate time. */
5
+ times?: boolean;
6
+ };
7
+ /**
8
+ * The repeat's label: its days, "after done" when it repeats from
9
+ * completion, its times, and how it ends. "Every 2nd Tue at 9:00 AM",
10
+ * "Every 3 days after done, at 9:00 AM", "Every weekday at 8:00 AM and
11
+ * 5:30 PM, until Mar 1, 2027", "Every day at 9:00 AM, 10 times". A rule
12
+ * it can't read shows as stored.
13
+ */
14
+ export declare function formatRecurrence(value: Recurrence, options?: RecurrenceFormatOptions): string;
15
+ export type OccurrenceFormatOptions = {
16
+ locale?: string;
17
+ /** What "now" is, for leaving out this year. Defaults to the clock. */
18
+ now?: Date;
19
+ };
20
+ /**
21
+ * One occurrence's day and time in the rule's zone: "Tue, Dec 8, 9:00 AM",
22
+ * with the year when it isn't this year's.
23
+ */
24
+ export declare function formatOccurrence(moment: Date, timeZone: string, options?: OccurrenceFormatOptions): string;
25
+ /** Today's date in `timeZone`, `'YYYY-MM-DD'`: where a phrase's days count from. */
26
+ export declare function todayIn(timeZone: string, now?: Date): string;
@@ -0,0 +1,139 @@
1
+ // A repeat in words (#326): its label for a list's Repeats cell and the
2
+ // field's preview ("Every 2nd Tue at 9:00 AM"), and an occurrence's
3
+ // date and time for a Next cell ("Tue, Dec 8, 9:00 AM"), both read in the
4
+ // rule's own zone. Day and month names and times come from Intl, in the
5
+ // locale given (the browser's when left out); the words around them are
6
+ // English, like the rest of the package.
7
+ import { listWords, ordinalWord } from './recurrence-phrase.js';
8
+ import { parseRule, wallClock } from './recurrence.js';
9
+ const WEEKDAYS_MO_FR = [0, 1, 2, 3, 4];
10
+ function dayName(day, locale, width = 'short') {
11
+ // 2024-01-01 was a Monday.
12
+ return new Intl.DateTimeFormat(locale, { weekday: width, timeZone: 'UTC' }).format(Date.UTC(2024, 0, 1 + day));
13
+ }
14
+ function monthDay(month, day, locale) {
15
+ return new Intl.DateTimeFormat(locale, { month: 'short', day: 'numeric', timeZone: 'UTC' }).format(Date.UTC(2024, month - 1, day));
16
+ }
17
+ function plainDay(value, locale) {
18
+ return new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeZone: 'UTC' }).format(Date.parse(`${value}T00:00:00Z`));
19
+ }
20
+ function clock(time, locale) {
21
+ return new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit', timeZone: 'UTC' }).format(Date.parse(`2024-01-01T${time}:00Z`));
22
+ }
23
+ function every(parts, unit) {
24
+ if (parts.interval === 1)
25
+ return `Every ${unit}`;
26
+ if (parts.interval === 2)
27
+ return `Every other ${unit}`;
28
+ return `Every ${parts.interval} ${unit}s`;
29
+ }
30
+ function nthDay(nth, day, locale) {
31
+ return `${nth === -1 ? 'last' : nth < -1 ? `${ordinalWord(-nth)} to last` : ordinalWord(nth)} ${dayName(day, locale)}`;
32
+ }
33
+ function monthDayWord(day) {
34
+ return day === -1 ? 'last day' : day < -1 ? `${ordinalWord(-day)} to last day` : ordinalWord(day);
35
+ }
36
+ /** The days part: "Every 2nd Tue", "Every weekday", "Every 3 months on the 15th". */
37
+ function days(parts, start, locale) {
38
+ const [, startMonth, startDay] = start.split('-').map(Number);
39
+ const startWeekday = (new Date(`${start}T00:00:00Z`).getUTCDay() + 6) % 7;
40
+ const weekdays = parts.byDay.filter(({ nth }) => nth === null).map(({ day }) => day);
41
+ const nths = parts.byDay.filter(({ nth }) => nth !== null);
42
+ const inMonths = parts.byMonth.length && parts.freq !== 'YEARLY' ? ` in ${listWords(parts.byMonth.map((month) => monthName(month, locale)))}` : '';
43
+ switch (parts.freq) {
44
+ case 'DAILY':
45
+ return `${every(parts, 'day')}${inMonths}`;
46
+ case 'WEEKLY': {
47
+ const chosen = weekdays.length ? weekdays : [startWeekday];
48
+ const names = listWords(chosen.map((day) => dayName(day, locale)));
49
+ if (parts.interval === 1) {
50
+ if (chosen.join() === WEEKDAYS_MO_FR.join())
51
+ return `Every weekday${inMonths}`;
52
+ if (chosen.join() === '5,6')
53
+ return `Every weekend${inMonths}`;
54
+ return `Every ${names}${inMonths}`;
55
+ }
56
+ return `${every(parts, 'week')} on ${names}${inMonths}`;
57
+ }
58
+ case 'MONTHLY': {
59
+ const on = nths.length
60
+ ? listWords(nths.map(({ nth, day }) => nthDay(nth, day, locale)))
61
+ : parts.byMonthDay.length
62
+ ? listWords(parts.byMonthDay.map(monthDayWord))
63
+ : weekdays.length
64
+ ? `every ${listWords(weekdays.map((day) => dayName(day, locale)))}`
65
+ : ordinalWord(startDay);
66
+ if (parts.interval === 1) {
67
+ if (parts.byMonthDay.length === 1 && parts.byMonthDay[0] === -1 && !nths.length)
68
+ return `Every last day of the month${inMonths}`;
69
+ if (weekdays.length && !nths.length && !parts.byMonthDay.length)
70
+ return `Every ${listWords(weekdays.map((day) => dayName(day, locale)))}${inMonths}`;
71
+ return `Every ${on}${inMonths}`;
72
+ }
73
+ return `${every(parts, 'month')} on the ${on}${inMonths}`;
74
+ }
75
+ case 'YEARLY': {
76
+ const months = parts.byMonth.length ? parts.byMonth : [startMonth];
77
+ if (nths.length) {
78
+ const on = listWords(nths.map(({ nth, day }) => nthDay(nth, day, locale)));
79
+ const of = listWords(months.map((month) => monthName(month, locale)));
80
+ return parts.interval === 1 ? `Every ${on} of ${of}` : `${every(parts, 'year')} on the ${on} of ${of}`;
81
+ }
82
+ const monthDays = parts.byMonthDay.length ? parts.byMonthDay : [startDay];
83
+ const dates = months.flatMap((month) => monthDays.map((day) => (day > 0 ? monthDay(month, day, locale) : `the ${monthDayWord(day)} of ${monthName(month, locale)}`)));
84
+ return parts.interval === 1 ? `Every ${listWords(dates)}` : `${every(parts, 'year')} on ${listWords(dates)}`;
85
+ }
86
+ }
87
+ }
88
+ function monthName(month, locale) {
89
+ return new Intl.DateTimeFormat(locale, { month: 'short', timeZone: 'UTC' }).format(Date.UTC(2024, month - 1, 1));
90
+ }
91
+ /**
92
+ * The repeat's label: its days, "after done" when it repeats from
93
+ * completion, its times, and how it ends. "Every 2nd Tue at 9:00 AM",
94
+ * "Every 3 days after done, at 9:00 AM", "Every weekday at 8:00 AM and
95
+ * 5:30 PM, until Mar 1, 2027", "Every day at 9:00 AM, 10 times". A rule
96
+ * it can't read shows as stored.
97
+ */
98
+ export function formatRecurrence(value, options = {}) {
99
+ let parts;
100
+ try {
101
+ parts = parseRule(value.rule);
102
+ }
103
+ catch {
104
+ return value.rule;
105
+ }
106
+ const { locale } = options;
107
+ let label = days(parts, value.start, locale);
108
+ if (value.fromCompletion)
109
+ label += ' after done';
110
+ if (options.times !== false && value.times.length) {
111
+ label += `${value.fromCompletion ? ',' : ''} at ${listWords(value.times.map((time) => clock(time, locale)))}`;
112
+ }
113
+ if (parts.until)
114
+ label += `, until ${plainDay(parts.until, locale)}`;
115
+ if (parts.count !== null)
116
+ label += `, ${parts.count} ${parts.count === 1 ? 'time' : 'times'}`;
117
+ return label;
118
+ }
119
+ /**
120
+ * One occurrence's day and time in the rule's zone: "Tue, Dec 8, 9:00 AM",
121
+ * with the year when it isn't this year's.
122
+ */
123
+ export function formatOccurrence(moment, timeZone, options = {}) {
124
+ const thisYear = wallClock(options.now ?? new Date(), timeZone).day.slice(0, 4);
125
+ const year = wallClock(moment, timeZone).day.slice(0, 4);
126
+ return new Intl.DateTimeFormat(options.locale, {
127
+ timeZone,
128
+ weekday: 'short',
129
+ month: 'short',
130
+ day: 'numeric',
131
+ year: year === thisYear ? undefined : 'numeric',
132
+ hour: 'numeric',
133
+ minute: '2-digit',
134
+ }).format(moment);
135
+ }
136
+ /** Today's date in `timeZone`, `'YYYY-MM-DD'`: where a phrase's days count from. */
137
+ export function todayIn(timeZone, now = new Date()) {
138
+ return wallClock(now, timeZone).day;
139
+ }
@@ -0,0 +1,33 @@
1
+ import { type Recurrence } from './recurrence.js';
2
+ export type PhraseOptions = {
3
+ /** Today, `'YYYY-MM-DD'` in the rule's zone: where a day with no year counts from. */
4
+ today: string;
5
+ /** The IANA zone the rule is read in. */
6
+ timeZone: string;
7
+ /** The times when the phrase has no "at" (the field's current ones). Defaults to 09:00. */
8
+ times?: string[];
9
+ /** The start when the phrase has no "starting". Defaults to `today`. */
10
+ start?: string;
11
+ };
12
+ export type PhraseResult = {
13
+ ok: true;
14
+ value: Recurrence;
15
+ } | {
16
+ ok: false;
17
+ error: string;
18
+ };
19
+ /**
20
+ * Reads a phrase into a Recurrence, or says why it can't. Live as you
21
+ * type: call it on every change and show the result's label or its error.
22
+ */
23
+ export declare function parseRecurrencePhrase(text: string, options: PhraseOptions): PhraseResult;
24
+ declare const ordinal: (value: number) => string;
25
+ declare const listWords: (words: string[], and?: string) => string;
26
+ /**
27
+ * The Recurrence as a phrase parseRecurrencePhrase reads back to it
28
+ * ("every 2nd tue at 9am until mar 1"), or null for a rule it can't say
29
+ * (several month days, BYMONTH on a daily rule). The start is said only
30
+ * when it's after `today`.
31
+ */
32
+ export declare function recurrencePhrase(value: Recurrence, today?: string): string | null;
33
+ export { ordinal as ordinalWord, listWords };