@k2b/ui 0.20.0 → 0.21.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.
Files changed (51) hide show
  1. package/dist/browser/actions/Button.js +20 -31
  2. package/dist/browser/actions/Button.js.map +1 -1
  3. package/dist/browser/actions/ContextMenu.js +7 -3
  4. package/dist/browser/actions/ContextMenu.js.map +1 -1
  5. package/dist/browser/actions/CopyButton.js +10 -8
  6. package/dist/browser/actions/CopyButton.js.map +1 -1
  7. package/dist/browser/actions/GestureMenu.js +4 -0
  8. package/dist/browser/actions/GestureMenu.js.map +1 -1
  9. package/dist/browser/content/Calendar.js +1951 -565
  10. package/dist/browser/content/Calendar.js.map +1 -1
  11. package/dist/browser/content/calendar-messages.js +83 -0
  12. package/dist/browser/content/calendar-messages.js.map +1 -0
  13. package/dist/browser/content/calendar-month-layout.js +108 -0
  14. package/dist/browser/content/calendar-month-layout.js.map +1 -0
  15. package/dist/browser/content/index.js.map +1 -1
  16. package/dist/browser/inputs/DatePicker.js +46 -10
  17. package/dist/browser/inputs/DatePicker.js.map +1 -1
  18. package/dist/browser/inputs/date-picker.js +24 -0
  19. package/dist/browser/inputs/date-picker.js.map +1 -1
  20. package/dist/browser/intl/messages.js +6 -0
  21. package/dist/browser/intl/messages.js.map +1 -1
  22. package/dist/ssr/actions/Button.js +21 -32
  23. package/dist/ssr/actions/Button.js.map +1 -1
  24. package/dist/ssr/actions/ContextMenu.js +7 -3
  25. package/dist/ssr/actions/ContextMenu.js.map +1 -1
  26. package/dist/ssr/actions/CopyButton.js +9 -7
  27. package/dist/ssr/actions/CopyButton.js.map +1 -1
  28. package/dist/ssr/actions/GestureMenu.js +4 -0
  29. package/dist/ssr/actions/GestureMenu.js.map +1 -1
  30. package/dist/ssr/content/Calendar.js +1223 -105
  31. package/dist/ssr/content/Calendar.js.map +1 -1
  32. package/dist/ssr/content/calendar-messages.js +83 -0
  33. package/dist/ssr/content/calendar-messages.js.map +1 -0
  34. package/dist/ssr/content/calendar-month-layout.js +108 -0
  35. package/dist/ssr/content/calendar-month-layout.js.map +1 -0
  36. package/dist/ssr/content/index.js.map +1 -1
  37. package/dist/ssr/inputs/DatePicker.js +34 -4
  38. package/dist/ssr/inputs/DatePicker.js.map +1 -1
  39. package/dist/ssr/inputs/date-picker.js +24 -0
  40. package/dist/ssr/inputs/date-picker.js.map +1 -1
  41. package/dist/ssr/intl/messages.js +6 -0
  42. package/dist/ssr/intl/messages.js.map +1 -1
  43. package/dist/styles.css +1 -1
  44. package/dist/types/actions/GestureMenu.d.ts +2 -0
  45. package/dist/types/content/Calendar.d.ts +32 -0
  46. package/dist/types/content/calendar-messages.d.ts +41 -0
  47. package/dist/types/content/calendar-month-layout.d.ts +52 -0
  48. package/dist/types/content/index.d.ts +1 -1
  49. package/dist/types/inputs/date-picker.d.ts +7 -0
  50. package/dist/types/intl/messages.d.ts +3 -0
  51. package/package.json +1 -1
@@ -24,6 +24,8 @@ export type GestureMenuProps = {
24
24
  sheetTop?: (close: () => void) => JSX.Element;
25
25
  /** Tab order of the element. A list that moves focus between its rows itself passes -1. */
26
26
  tabIndex?: number;
27
+ /** Runs before the menu or the sheet shows its items, for example to select what was pressed. */
28
+ onOpen?: () => void;
27
29
  class?: string;
28
30
  };
29
31
  /**
@@ -1,6 +1,7 @@
1
1
  import { type LinkNavigateEvent } from "@k2b/ssr/nav";
2
2
  import { type DateContext } from "@k2b/stdlib";
3
3
  import type { JSX } from "solid-js";
4
+ import type { DropdownItem } from "../actions/Dropdown";
4
5
  export type CalendarView = "day" | "week" | "month" | "year" | "mobile-month";
5
6
  export type CalendarEventColor = "blue" | "emerald" | "amber" | "red" | "violet" | "cyan" | "zinc";
6
7
  export type CalendarEvent = {
@@ -63,6 +64,8 @@ export type CalendarEventRenderContext = {
63
64
  allDay: boolean;
64
65
  durationHours: number;
65
66
  timeLabel: string;
67
+ /** Month view: the start time to show before the title of a one-day timed entry; absent on bars and elsewhere. */
68
+ leadingTime?: string;
66
69
  };
67
70
  /** A view the application adds to the switcher; the calendar shows its header and toolbar, the application the body. */
68
71
  export type CalendarCustomView<V extends string = string> = {
@@ -116,10 +119,39 @@ export type CalendarProps<V extends string = never> = {
116
119
  onSlotActivate?: (slot: CalendarEventTimeChange) => void;
117
120
  /** Pointer gesture used for empty slots. Keyboard activation is always immediate. */
118
121
  slotActivation?: "single" | "double";
122
+ /**
123
+ * Month view: the selected days changed. `null` when no day is selected, for example after paging to another month
124
+ * or switching to another view.
125
+ */
126
+ onSelectionChange?: (range: CalendarEventTimeChange | null) => void;
127
+ /**
128
+ * Month view: the application's entries of the menu that a right-click, Shift+F10, or a long press opens on a day or
129
+ * on the selected days. The calendar heads them with the days and adds Open day, Open week, and Clear selection;
130
+ * without this prop the menu has only those. `quickCreate` opens the quick create at the days, passing `create` on to
131
+ * `renderQuickCreate`.
132
+ */
133
+ selectionMenu?: (range: CalendarEventTimeChange, controls: CalendarSelectionControls) => readonly DropdownItem[];
134
+ /**
135
+ * Month view: the content of the quick create at the selected days. It opens quietly after a click, keeping the
136
+ * focus in the grid until the person types or tabs into it (Space still lists the day), and with the focus after a
137
+ * drag, a double-click, Enter, N, or `quickCreate`.
138
+ */
139
+ renderQuickCreate?: (range: CalendarEventTimeChange, controls: CalendarQuickCreateControls) => JSX.Element;
119
140
  toolbarActions?: JSX.Element;
141
+ /** Application controls, such as filters, right after the period title. */
120
142
  toolbarContent?: JSX.Element;
121
143
  class?: string;
122
144
  };
145
+ export type CalendarSelectionControls = {
146
+ /** Opens the quick create at the days of the menu; `create` names what to create, as the application defines it. */
147
+ quickCreate: (create?: string) => void;
148
+ };
149
+ export type CalendarQuickCreateControls = {
150
+ /** What the person asked to create through `quickCreate`; absent after a click, a drag, or the keyboard. */
151
+ create?: string;
152
+ /** Closes the quick create and returns the focus to the selected day; once another quick create replaced it, nothing. */
153
+ close: () => void;
154
+ };
123
155
  export type CalendarEventTimeChange = {
124
156
  start: Date;
125
157
  end: Date;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The month view's own strings. They live beside the calendar instead of in the shared catalog, so applications that
3
+ * never render a calendar do not ship them.
4
+ */
5
+ declare const calendarMessages: import("@k2b/stdlib").Catalog<{
6
+ calendarMoreEvents: ({ count }: {
7
+ count: number;
8
+ }) => string;
9
+ calendarMoreEventsOn: ({ count, label }: {
10
+ count: number;
11
+ label: string;
12
+ }) => string;
13
+ calendarSelectionActions: string;
14
+ calendarQuickCreate: string;
15
+ calendarSelectedDays: ({ start, end, count }: {
16
+ start: string;
17
+ end: string;
18
+ count: number;
19
+ }) => string;
20
+ calendarOpenDay: string;
21
+ calendarOpenWeek: string;
22
+ calendarOpenWeekNumber: ({ week }: {
23
+ week: number;
24
+ }) => string;
25
+ calendarClearSelection: string;
26
+ calendarNewEvent: string;
27
+ calendarNothingPlanned: string;
28
+ calendarContinuesFrom: ({ day, month }: {
29
+ day: number;
30
+ month?: string;
31
+ }) => string;
32
+ calendarContinuesUntil: ({ day, month }: {
33
+ day: number;
34
+ month?: string;
35
+ }) => string;
36
+ }>;
37
+ export type CalendarMessages = ReturnType<(typeof calendarMessages)["resolve"]>["t"];
38
+ /** Resolved from the inherited render locale, like the rest of @k2b/ui. */
39
+ export declare const useCalendarMessages: () => (() => CalendarMessages);
40
+ export declare const checkCalendarMessages: () => import("@k2b/stdlib").CatalogIssue[];
41
+ export {};
@@ -0,0 +1,52 @@
1
+ /** One entry of a month week row, with its first and last day as `YYYY-MM-DD` keys. */
2
+ export type MonthEntry<T> = {
3
+ item: T;
4
+ /** The entry's first day, which may lie before the row. */
5
+ firstKey: string;
6
+ /** The entry's last day, which may lie after the row. */
7
+ lastKey: string;
8
+ /** All-day and multi-day entries are bars that keep a lane; the others stack in their day below the bars. */
9
+ bar: boolean;
10
+ };
11
+ /** The part of a bar inside one week row, from `startColumn` to `endColumn`, both inclusive. */
12
+ export type MonthBar<T> = {
13
+ item: T;
14
+ startColumn: number;
15
+ endColumn: number;
16
+ lane: number;
17
+ /** The entry began before this row: the bar's start is torn. */
18
+ continuesBefore: boolean;
19
+ /** The entry goes on after this row: the bar's end is torn. */
20
+ continuesAfter: boolean;
21
+ };
22
+ export type MonthWeekLayout<T> = {
23
+ bars: MonthBar<T>[];
24
+ /** Per column, the entries that are not bars, in the order the row lists them. */
25
+ singles: T[][];
26
+ };
27
+ /**
28
+ * Lays one week row out. Each bar is one piece over the days it covers in the row and keeps one lane on all of them,
29
+ * so a long entry never moves between its days: bars that start earlier come first, a longer bar before a shorter one
30
+ * with the same start, and otherwise the row's own order decides. Every lane is the lowest one free on all its days.
31
+ */
32
+ export declare const layoutMonthWeek: <T>(dayKeys: readonly string[], entries: readonly MonthEntry<T>[]) => MonthWeekLayout<T>;
33
+ /** What one day cell of a week row draws: its entries from row `top` on, and how many it counts as "+N" below them. */
34
+ export type MonthCellFit<T> = {
35
+ /** The first row below the bars drawn over this day. */
36
+ top: number;
37
+ shown: T[];
38
+ hidden: number;
39
+ };
40
+ export type MonthWeekFit<T> = {
41
+ /** The bars drawn whole; a bar that does not fit on one of its days is counted on each of them instead. */
42
+ bars: MonthBar<T>[];
43
+ cells: MonthCellFit<T>[];
44
+ };
45
+ /**
46
+ * Fits a week row into cells that have room for `capacity` rows each. A cell whose entries all fit draws them all;
47
+ * otherwise it gives its last row to "+N", which counts every entry of the day that is not drawn, hidden bars included.
48
+ * A bar is drawn only when it fits on every day it covers, so it is never cut off by a count.
49
+ */
50
+ export declare const fitMonthWeek: <T>(layout: MonthWeekLayout<T>, capacity: number) => MonthWeekFit<T>;
51
+ /** How many rows of `lane` height with `gap` between them fit into `height`. */
52
+ export declare const monthLaneCapacity: (height: number, lane: number, gap: number) => number;
@@ -1,4 +1,4 @@
1
- export type { CalendarAttendee, CalendarCustomView, CalendarDayBadge, CalendarEvent, CalendarEventColor, CalendarEventRenderContext, CalendarEventTimeChange, CalendarLabels, CalendarProps, CalendarRecurrence, CalendarResource, CalendarView, } from "./Calendar";
1
+ export type { CalendarAttendee, CalendarCustomView, CalendarDayBadge, CalendarEvent, CalendarEventColor, CalendarEventRenderContext, CalendarEventTimeChange, CalendarLabels, CalendarProps, CalendarQuickCreateControls, CalendarRecurrence, CalendarResource, CalendarSelectionControls, CalendarView, } from "./Calendar";
2
2
  export { default as Calendar } from "./Calendar";
3
3
  export type { ChartKind, ChartLabels, ChartProps, ChartRenderOptions } from "./Chart";
4
4
  export { default as Chart } from "./Chart";
@@ -23,6 +23,13 @@ export declare const yearMonth: (date: Date, context?: DateContext) => {
23
23
  month: number;
24
24
  };
25
25
  export declare const monthDate: (year: number, month: number, context?: DateContext) => Date;
26
+ /**
27
+ * Milliseconds from `now` until the next calendar day starts in the picker's
28
+ * time zone, so a panel left open past midnight moves its today mark on time.
29
+ * The next day's start is resolved from its date key: where a DST change skips
30
+ * or repeats midnight, the day starts at its first existing instant.
31
+ */
32
+ export declare const msUntilNextDay: (now: Date, context?: DateContext) => number;
26
33
  export declare const parseDateValue: (value: string | null | undefined, context?: DateContext) => Date;
27
34
  export declare const displayDate: (value: string | null | undefined, context?: DateContext) => string;
28
35
  export declare const dateTimeInput: (value: string | null | undefined, context?: DateContext) => string;
@@ -219,6 +219,9 @@ declare const uiMessages: import("@k2b/stdlib").Catalog<{
219
219
  time: string;
220
220
  }) => string;
221
221
  today: string;
222
+ todayDate: ({ date }: {
223
+ date: string;
224
+ }) => string;
222
225
  day: string;
223
226
  week: string;
224
227
  weekShort: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k2b/ui",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Production-ready components for SolidJS applications.",
5
5
  "repository": {
6
6
  "type": "git",