@k2b/ui 0.19.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 (82) 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 +471 -0
  8. package/dist/browser/actions/GestureMenu.js.map +1 -0
  9. package/dist/browser/actions/index.js +1 -0
  10. package/dist/browser/actions/index.js.map +1 -1
  11. package/dist/browser/chat/ChatComposer.js +3 -41
  12. package/dist/browser/chat/ChatComposer.js.map +1 -1
  13. package/dist/browser/chat/ChatPrimitives.js +9 -3
  14. package/dist/browser/chat/ChatPrimitives.js.map +1 -1
  15. package/dist/browser/chat/ChatTimeline.js +19 -1
  16. package/dist/browser/chat/ChatTimeline.js.map +1 -1
  17. package/dist/browser/content/Calendar.js +1951 -565
  18. package/dist/browser/content/Calendar.js.map +1 -1
  19. package/dist/browser/content/MessageRow.js +2 -2
  20. package/dist/browser/content/MessageRow.js.map +1 -1
  21. package/dist/browser/content/calendar-messages.js +83 -0
  22. package/dist/browser/content/calendar-messages.js.map +1 -0
  23. package/dist/browser/content/calendar-month-layout.js +108 -0
  24. package/dist/browser/content/calendar-month-layout.js.map +1 -0
  25. package/dist/browser/content/index.js.map +1 -1
  26. package/dist/browser/inputs/DatePicker.js +46 -10
  27. package/dist/browser/inputs/DatePicker.js.map +1 -1
  28. package/dist/browser/inputs/TextInput.js +13 -1
  29. package/dist/browser/inputs/TextInput.js.map +1 -1
  30. package/dist/browser/inputs/date-picker.js +24 -0
  31. package/dist/browser/inputs/date-picker.js.map +1 -1
  32. package/dist/browser/inputs/markdown/actions.js +0 -42
  33. package/dist/browser/inputs/markdown/actions.js.map +1 -1
  34. package/dist/browser/intl/messages.js +6 -6
  35. package/dist/browser/intl/messages.js.map +1 -1
  36. package/dist/ssr/actions/Button.js +21 -32
  37. package/dist/ssr/actions/Button.js.map +1 -1
  38. package/dist/ssr/actions/ContextMenu.js +7 -3
  39. package/dist/ssr/actions/ContextMenu.js.map +1 -1
  40. package/dist/ssr/actions/CopyButton.js +9 -7
  41. package/dist/ssr/actions/CopyButton.js.map +1 -1
  42. package/dist/ssr/actions/GestureMenu.js +415 -0
  43. package/dist/ssr/actions/GestureMenu.js.map +1 -0
  44. package/dist/ssr/actions/index.js +1 -0
  45. package/dist/ssr/actions/index.js.map +1 -1
  46. package/dist/ssr/chat/ChatComposer.js +3 -41
  47. package/dist/ssr/chat/ChatComposer.js.map +1 -1
  48. package/dist/ssr/chat/ChatPrimitives.js +9 -3
  49. package/dist/ssr/chat/ChatPrimitives.js.map +1 -1
  50. package/dist/ssr/chat/ChatTimeline.js +19 -1
  51. package/dist/ssr/chat/ChatTimeline.js.map +1 -1
  52. package/dist/ssr/content/Calendar.js +1223 -105
  53. package/dist/ssr/content/Calendar.js.map +1 -1
  54. package/dist/ssr/content/MessageRow.js +2 -2
  55. package/dist/ssr/content/MessageRow.js.map +1 -1
  56. package/dist/ssr/content/calendar-messages.js +83 -0
  57. package/dist/ssr/content/calendar-messages.js.map +1 -0
  58. package/dist/ssr/content/calendar-month-layout.js +108 -0
  59. package/dist/ssr/content/calendar-month-layout.js.map +1 -0
  60. package/dist/ssr/content/index.js.map +1 -1
  61. package/dist/ssr/inputs/DatePicker.js +34 -4
  62. package/dist/ssr/inputs/DatePicker.js.map +1 -1
  63. package/dist/ssr/inputs/TextInput.js +13 -1
  64. package/dist/ssr/inputs/TextInput.js.map +1 -1
  65. package/dist/ssr/inputs/date-picker.js +24 -0
  66. package/dist/ssr/inputs/date-picker.js.map +1 -1
  67. package/dist/ssr/inputs/markdown/actions.js +0 -42
  68. package/dist/ssr/inputs/markdown/actions.js.map +1 -1
  69. package/dist/ssr/intl/messages.js +6 -6
  70. package/dist/ssr/intl/messages.js.map +1 -1
  71. package/dist/styles.css +1 -1
  72. package/dist/types/actions/GestureMenu.d.ts +37 -0
  73. package/dist/types/actions/index.d.ts +2 -0
  74. package/dist/types/chat/ChatComposer.d.ts +4 -1
  75. package/dist/types/content/Calendar.d.ts +32 -0
  76. package/dist/types/content/calendar-messages.d.ts +41 -0
  77. package/dist/types/content/calendar-month-layout.d.ts +52 -0
  78. package/dist/types/content/index.d.ts +1 -1
  79. package/dist/types/inputs/date-picker.d.ts +7 -0
  80. package/dist/types/inputs/markdown/actions.d.ts +0 -2
  81. package/dist/types/intl/messages.d.ts +3 -3
  82. package/package.json +2 -2
@@ -0,0 +1,37 @@
1
+ import { type JSX } from "solid-js";
2
+ import { type DropdownAction, type DropdownActionBase, type DropdownChoice, type DropdownSection } from "./Dropdown";
3
+ export type GestureKind = "swipe-right" | "swipe-left" | "double-tap";
4
+ /** A menu action that a gesture runs as well. */
5
+ export type GestureMenuAction = DropdownActionBase & {
6
+ action: () => void;
7
+ /** The gesture that runs this action. Give each gesture to at most one item; a disabled item disables its gesture. */
8
+ gesture?: GestureKind;
9
+ };
10
+ export type GestureMenuSection = Omit<DropdownSection, "items"> & {
11
+ items: readonly (GestureMenuAction | DropdownAction | DropdownChoice)[];
12
+ };
13
+ export type GestureMenuItem = GestureMenuAction | DropdownAction | DropdownChoice | GestureMenuSection;
14
+ export type GestureMenuProps = {
15
+ /**
16
+ * The menu. A long press opens it as a bottom sheet, a right-click, the Context Menu key, or Shift+F10 as a menu.
17
+ * An item with `gesture` is also run by that gesture, so every gesture has its entry here.
18
+ */
19
+ items: readonly GestureMenuItem[];
20
+ /** Names the element and its menu, for example "Message from Nora, 10:42". */
21
+ label: string;
22
+ children: JSX.Element;
23
+ /** Shown above the menu in the long-press sheet, for example a row of quick reactions. `close` closes the sheet. */
24
+ sheetTop?: (close: () => void) => JSX.Element;
25
+ /** Tab order of the element. A list that moves focus between its rows itself passes -1. */
26
+ tabIndex?: number;
27
+ /** Runs before the menu or the sheet shows its items, for example to select what was pressed. */
28
+ onOpen?: () => void;
29
+ class?: string;
30
+ };
31
+ /**
32
+ * Touch gestures for an element, each the shortcut of an entry in its menu: a horizontal swipe, a double tap, and a
33
+ * long press that opens the whole menu as a `BottomSheet`. A mouse double-click runs the double-tap action; a
34
+ * right-click and the keyboard open the menu beside the element. Vertical scrolling never turns into a swipe.
35
+ */
36
+ export declare function GestureMenu(props: GestureMenuProps): JSX.Element;
37
+ export default GestureMenu;
@@ -10,6 +10,8 @@ export type { DropdownAction, DropdownActionBase, DropdownChoice, DropdownItemPr
10
10
  export { Dropdown, DropdownItem, dropdownPosition } from "./Dropdown";
11
11
  export type { FilterChipOption, FilterChipProps, FilterChipSection } from "./FilterChip";
12
12
  export { FilterChip } from "./FilterChip";
13
+ export type { GestureKind, GestureMenuAction, GestureMenuItem, GestureMenuProps, GestureMenuSection } from "./GestureMenu";
14
+ export { GestureMenu } from "./GestureMenu";
13
15
  export type { RemoveButtonProps } from "./RemoveButton";
14
16
  export { RemoveButton } from "./RemoveButton";
15
17
  export type { SegmentedControlProps, SegmentOption } from "./SegmentedControl";
@@ -86,7 +86,10 @@ export type ChatComposerProps = {
86
86
  variant?: "default" | "conversation";
87
87
  /** `"enter"` (default): Enter sends and Shift+Enter breaks the line. `"mod-enter"`: Enter breaks the line. Ctrl/⌘+Enter always sends. */
88
88
  sendKey?: "enter" | "mod-enter";
89
- /** Adds "Aa", which opens one row of Markdown formatting buttons above the field; the field and its controls stay put. */
89
+ /**
90
+ * Adds "Aa", which opens one row above the field with Bold, Italic and Bullet list (Ctrl/⌘+B, Ctrl/⌘+I, Ctrl/⌘+Shift+8);
91
+ * the field and its controls stay put. Other Markdown is typed by hand.
92
+ */
90
93
  formatting?: boolean;
91
94
  /** An emoji button at a fixed place. Touch-only devices hide it; their keyboard has emoji. */
92
95
  emoji?: ChatComposerEmoji;
@@ -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;
@@ -6,7 +6,5 @@ export declare const toggleInlineMarker: (textarea: HTMLTextAreaElement, marker:
6
6
  export declare const insertLink: (textarea: HTMLTextAreaElement, url?: string) => void;
7
7
  export declare const toggleHeading: (textarea: HTMLTextAreaElement, level: 1 | 2 | 3) => void;
8
8
  export declare const toggleBulletList: (textarea: HTMLTextAreaElement) => void;
9
- /** Puts the selected lines between ``` fences. Inside a fenced block, from its opening line on, it removes that block's fences. */
10
- export declare const toggleCodeBlock: (textarea: HTMLTextAreaElement) => void;
11
9
  export declare const toggleQuote: (textarea: HTMLTextAreaElement) => void;
12
10
  export declare const toggleNumberedList: (textarea: HTMLTextAreaElement) => void;
@@ -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;
@@ -456,9 +459,6 @@ declare const uiMessages: import("@k2b/stdlib").Catalog<{
456
459
  writeMessage: string;
457
460
  writeConversationMessage: string;
458
461
  composerFormatting: string;
459
- strikethroughShortcut: string;
460
- codeBlock: string;
461
- insertLink: string;
462
462
  insertEmoji: string;
463
463
  emojiSuggestions: string;
464
464
  dictate: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k2b/ui",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "Production-ready components for SolidJS applications.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  "fixture:build": "bun run build && NODE_ENV=production bun run fixture/scripts/build.ts",
39
39
  "fixture:typecheck": "tsc -p fixture/tsconfig.json --noEmit --pretty false",
40
40
  "test": "bun run build && bun test --path-ignore-patterns '**/*.behavior.test.*' src scripts && bun run scripts/check-packed-consumer.ts",
41
- "typecheck": "tsc -p tsconfig.json --noEmit --pretty false && bun run check:declarations && bun run typecheck:dom",
41
+ "typecheck": "tsc --checkers 2 -p tsconfig.json --noEmit --pretty false && bun run check:declarations && bun run typecheck:dom",
42
42
  "typecheck:dom": "tsc -p test/tsconfig.json --noEmit --pretty false",
43
43
  "prepack": "bun run build"
44
44
  },