@aceshooting/lyra-ui 1.0.1 → 1.2.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 (150) hide show
  1. package/README.md +9 -10
  2. package/custom-elements.json +15118 -8342
  3. package/dist/components/chart/chart.d.ts +57 -1
  4. package/dist/components/chart/chart.js +202 -12
  5. package/dist/components/chart/chart.stories.d.ts +32 -0
  6. package/dist/components/chart/chart.stories.js +141 -0
  7. package/dist/components/chart/chart.styles.js +16 -0
  8. package/dist/components/chart/histogram.d.ts +2 -0
  9. package/dist/components/chart/histogram.js +18 -2
  10. package/dist/components/chart/line-chart.stories.d.ts +17 -0
  11. package/dist/components/chart/line-chart.stories.js +75 -0
  12. package/dist/components/chart/lite-chart.d.ts +83 -0
  13. package/dist/components/chart/lite-chart.js +424 -0
  14. package/dist/components/chart/lite-chart.stories.d.ts +14 -0
  15. package/dist/components/chart/lite-chart.stories.js +114 -0
  16. package/dist/components/chart/lite-chart.styles.d.ts +1 -0
  17. package/dist/components/chart/lite-chart.styles.js +83 -0
  18. package/dist/components/combobox/combobox.d.ts +9 -0
  19. package/dist/components/combobox/combobox.js +76 -13
  20. package/dist/components/combobox/combobox.stories.d.ts +18 -0
  21. package/dist/components/combobox/combobox.stories.js +75 -0
  22. package/dist/components/date-picker/calendar-core.js +13 -2
  23. package/dist/components/date-picker/date-input.d.ts +9 -1
  24. package/dist/components/date-picker/date-input.js +55 -7
  25. package/dist/components/date-picker/date-input.stories.d.ts +5 -0
  26. package/dist/components/date-picker/date-input.stories.js +36 -0
  27. package/dist/components/date-picker/date-picker.d.ts +11 -3
  28. package/dist/components/date-picker/date-picker.js +87 -37
  29. package/dist/components/date-picker/date-picker.stories.d.ts +4 -0
  30. package/dist/components/date-picker/date-picker.stories.js +12 -0
  31. package/dist/components/date-picker/date-picker.styles.js +1 -1
  32. package/dist/components/empty/empty.d.ts +12 -1
  33. package/dist/components/empty/empty.js +20 -3
  34. package/dist/components/empty/empty.stories.d.ts +2 -0
  35. package/dist/components/empty/empty.stories.js +20 -0
  36. package/dist/components/empty/empty.styles.js +11 -0
  37. package/dist/components/export-button/csv.js +6 -2
  38. package/dist/components/export-button/export-button.d.ts +15 -1
  39. package/dist/components/export-button/export-button.js +89 -12
  40. package/dist/components/export-button/export-button.stories.d.ts +1 -0
  41. package/dist/components/export-button/export-button.stories.js +5 -0
  42. package/dist/components/export-button/export-button.styles.js +11 -3
  43. package/dist/components/file-input/accept.d.ts +8 -2
  44. package/dist/components/file-input/accept.js +9 -3
  45. package/dist/components/file-input/file-input.d.ts +5 -2
  46. package/dist/components/file-input/file-input.js +23 -8
  47. package/dist/components/file-input/file-input.stories.d.ts +2 -0
  48. package/dist/components/file-input/file-input.stories.js +9 -0
  49. package/dist/components/flag/flag.d.ts +69 -3
  50. package/dist/components/flag/flag.js +107 -30
  51. package/dist/components/flag/flag.stories.d.ts +1 -0
  52. package/dist/components/flag/flag.stories.js +14 -0
  53. package/dist/components/flag/flag.styles.js +1 -1
  54. package/dist/components/flag/language-map.d.ts +11 -0
  55. package/dist/components/flag/language-map.js +12 -1
  56. package/dist/components/gauge/gauge.d.ts +2 -0
  57. package/dist/components/gauge/gauge.js +19 -5
  58. package/dist/components/gauge/gauge.stories.d.ts +2 -0
  59. package/dist/components/gauge/gauge.stories.js +6 -0
  60. package/dist/components/graph/graph-loader.d.ts +28 -0
  61. package/dist/components/graph/graph-loader.js +44 -0
  62. package/dist/components/graph/graph.d.ts +41 -15
  63. package/dist/components/graph/graph.js +146 -71
  64. package/dist/components/graph/graph.stories.d.ts +3 -0
  65. package/dist/components/graph/graph.stories.js +38 -0
  66. package/dist/components/graph/graph.styles.js +6 -1
  67. package/dist/components/heatmap/calendar-grid.d.ts +7 -0
  68. package/dist/components/heatmap/calendar-grid.js +27 -10
  69. package/dist/components/heatmap/heatmap.d.ts +149 -12
  70. package/dist/components/heatmap/heatmap.js +445 -28
  71. package/dist/components/heatmap/heatmap.stories.d.ts +22 -0
  72. package/dist/components/heatmap/heatmap.stories.js +155 -0
  73. package/dist/components/heatmap/heatmap.styles.js +60 -2
  74. package/dist/components/map/map.d.ts +17 -1
  75. package/dist/components/map/map.js +68 -21
  76. package/dist/components/map/map.stories.d.ts +10 -0
  77. package/dist/components/map/map.stories.js +107 -12
  78. package/dist/components/map/map.styles.js +2 -2
  79. package/dist/components/playback/playback.d.ts +6 -2
  80. package/dist/components/playback/playback.js +36 -12
  81. package/dist/components/playback/playback.stories.d.ts +2 -0
  82. package/dist/components/playback/playback.stories.js +6 -0
  83. package/dist/components/playback/playback.styles.js +10 -2
  84. package/dist/components/select/select.d.ts +125 -0
  85. package/dist/components/select/select.js +480 -0
  86. package/dist/components/select/select.stories.d.ts +21 -0
  87. package/dist/components/select/select.stories.js +91 -0
  88. package/dist/components/select/select.styles.d.ts +1 -0
  89. package/dist/components/select/select.styles.js +212 -0
  90. package/dist/components/skeleton/skeleton.js +4 -7
  91. package/dist/components/sparkline/sparkline.d.ts +1 -1
  92. package/dist/components/sparkline/sparkline.js +40 -13
  93. package/dist/components/sparkline/sparkline.stories.d.ts +4 -0
  94. package/dist/components/sparkline/sparkline.stories.js +22 -0
  95. package/dist/components/split/split.d.ts +24 -3
  96. package/dist/components/split/split.js +155 -31
  97. package/dist/components/split/split.stories.d.ts +2 -0
  98. package/dist/components/split/split.stories.js +20 -0
  99. package/dist/components/stat/stat.d.ts +43 -1
  100. package/dist/components/stat/stat.js +97 -4
  101. package/dist/components/stat/stat.stories.d.ts +4 -0
  102. package/dist/components/stat/stat.stories.js +66 -1
  103. package/dist/components/stat/stat.styles.js +64 -0
  104. package/dist/components/table/table.d.ts +64 -2
  105. package/dist/components/table/table.js +213 -17
  106. package/dist/components/table/table.stories.d.ts +6 -0
  107. package/dist/components/table/table.stories.js +45 -0
  108. package/dist/components/table/table.styles.js +51 -4
  109. package/dist/components/time-range/time-range.d.ts +34 -5
  110. package/dist/components/time-range/time-range.js +217 -36
  111. package/dist/components/time-range/time-range.stories.d.ts +2 -0
  112. package/dist/components/time-range/time-range.stories.js +13 -0
  113. package/dist/components/time-range/time-range.styles.js +44 -2
  114. package/dist/components/toast/toast-item.d.ts +14 -2
  115. package/dist/components/toast/toast-item.js +134 -17
  116. package/dist/components/toast/toast-item.styles.js +28 -2
  117. package/dist/components/toast/toast.stories.d.ts +3 -0
  118. package/dist/components/toast/toast.stories.js +41 -1
  119. package/dist/components/toast/toast.styles.js +11 -11
  120. package/dist/components/toast/toaster.d.ts +1 -1
  121. package/dist/components/toast/toaster.js +13 -6
  122. package/dist/components/tree/tree-node.d.ts +13 -7
  123. package/dist/components/tree/tree-node.js +24 -10
  124. package/dist/components/tree/tree.d.ts +64 -15
  125. package/dist/components/tree/tree.js +113 -22
  126. package/dist/components/tree/tree.stories.d.ts +4 -0
  127. package/dist/components/tree/tree.stories.js +31 -1
  128. package/dist/components/tree/update-cascade.d.ts +13 -0
  129. package/dist/components/tree/update-cascade.js +13 -0
  130. package/dist/components/widget/widget.d.ts +25 -1
  131. package/dist/components/widget/widget.js +164 -6
  132. package/dist/components/widget/widget.stories.d.ts +3 -0
  133. package/dist/components/widget/widget.stories.js +43 -0
  134. package/dist/components/widget/widget.styles.js +20 -3
  135. package/dist/components/word-cloud/word-cloud-layout.d.ts +63 -0
  136. package/dist/components/word-cloud/word-cloud-layout.js +145 -0
  137. package/dist/components/word-cloud/word-cloud.d.ts +65 -0
  138. package/dist/components/word-cloud/word-cloud.js +255 -0
  139. package/dist/components/word-cloud/word-cloud.stories.d.ts +10 -0
  140. package/dist/components/word-cloud/word-cloud.stories.js +55 -0
  141. package/dist/components/word-cloud/word-cloud.styles.d.ts +1 -0
  142. package/dist/components/word-cloud/word-cloud.styles.js +55 -0
  143. package/dist/internal/a11y.js +2 -1
  144. package/dist/internal/rtl.d.ts +7 -0
  145. package/dist/internal/rtl.js +9 -0
  146. package/dist/lyra.d.ts +9 -1
  147. package/dist/lyra.js +6 -0
  148. package/llms-full.txt +962 -276
  149. package/llms.txt +12 -9
  150. package/package.json +6 -4
@@ -1,6 +1,29 @@
1
- import { type TemplateResult } from 'lit';
1
+ import { type PropertyValues, type TemplateResult } from 'lit';
2
2
  import { LyraElement } from '../../internal/lyra-element.js';
3
3
  import { type CalendarDay } from './calendar-grid.js';
4
+ /** A cell cursor in matrix mode. */
5
+ export interface MatrixCellPos {
6
+ row: number;
7
+ col: number;
8
+ }
9
+ /** A cell cursor in calendar mode — a grid position, not necessarily one with
10
+ * a matching entry in `days` (see `calendarCellAt()`). */
11
+ export interface CalendarCellPos {
12
+ week: number;
13
+ weekday: number;
14
+ }
15
+ /**
16
+ * A marker drawn as a stroked ring over a matching cell (matrix mode:
17
+ * `row`/`col`; calendar mode: `date` — whichever pair matches the active
18
+ * `mode`; the other fields are simply ignored). An optional `label`
19
+ * additionally surfaces the annotation in the legend.
20
+ */
21
+ export interface HeatmapAnnotation {
22
+ row?: number;
23
+ col?: number;
24
+ date?: string;
25
+ label?: string;
26
+ }
4
27
  /**
5
28
  * Parses a strict `#rgb` or `#rrggbb` hex string into an `[r, g, b]` triple,
6
29
  * or `null` if `hex` isn't one (rather than silently coercing an unparsable
@@ -25,16 +48,44 @@ export declare function resolveRgb(color: string, fallbackHex: string): [number,
25
48
  /** Linearly interpolates between two CSS colors (any valid syntax) at `t` in `[0, 1]`. */
26
49
  export declare function mixColor(fromColor: string, toColor: string, t: number): string;
27
50
  /**
28
- * `<lyra-heatmap>` — a Canvas matrix heatmap with a DPR-aware, resize-aware
29
- * redraw loop. `-1` cells are treated as "no data". The sequential color
30
- * ramp's endpoints are read from the `--lyra-heatmap-scale-lo`/`-hi` custom
31
- * properties (declared in `heatmap.styles.ts`) so hosts can retheme it
32
- * canvas can't consume `var()` directly, so they're resolved once per draw
33
- * via `getComputedStyle`, then normalized to RGB by `resolveRgb()` (any
34
- * valid CSS color syntax, not just hex see its doc comment).
51
+ * `<lyra-heatmap>` — a Canvas heatmap with a DPR-aware, resize-aware redraw
52
+ * loop, in one of two `mode`s:
53
+ *
54
+ * - `"matrix"` (default): a `rowLabels` x `colLabels` grid of `values`. `-1`
55
+ * (or any non-finite value) is treated as "no data". `scale="sqrt"`
56
+ * compresses the ramp via `sqrtStep()` so one heavy cell doesn't wash out
57
+ * the rest; the default `"linear"` scale maps linearly instead. `scale`
58
+ * only affects matrix mode — calendar mode always buckets by quartile.
59
+ * - `"calendar"`: a GitHub-style Sunday-Saturday x week grid built from
60
+ * `days`, colored by `quartileBucket()` into `bucketCount` buckets. As in
61
+ * matrix mode, a cell whose `value` is negative or non-finite is treated
62
+ * as "no data" rather than being bucketed.
63
+ *
64
+ * The sequential color ramp's endpoints are read from the
65
+ * `--lyra-heatmap-scale-lo`/`-hi` custom properties (declared in
66
+ * `heatmap.styles.ts`) so hosts can retheme it — canvas can't consume
67
+ * `var()` directly, so they're resolved once per draw via
68
+ * `getComputedStyle`, then normalized to RGB by `resolveRgb()` (any valid
69
+ * CSS color syntax, not just hex — see its doc comment).
70
+ *
71
+ * Every cell is independently addressable: a `pointermove` hit test over the
72
+ * canvas shows `[part="tooltip"]` with that cell's label + value (hidden on
73
+ * `pointerleave`); the canvas is `tabindex="0"` with arrow-key roving focus
74
+ * (a stroked ring redrawn over the focused cell on every draw, plus a
75
+ * visually-hidden `aria-live="polite"` status announcement — avoids a
76
+ * DOM-node-per-cell overlay, which would be hundreds of nodes for a year
77
+ * calendar); and a click, or Enter/Space on the focused cell, fires
78
+ * `lyra-cell-click`. `annotations` additionally strokes a ring around
79
+ * specific cells (e.g. to call out an anomaly), each one optionally
80
+ * surfaced in the legend too via `[part="legend-annotation"]`.
35
81
  *
36
82
  * @customElement lyra-heatmap
37
- * @csspart base, canvas, legend
83
+ * @event lyra-cell-click - Fired on click, or Enter/Space on the
84
+ * focused/hovered cell. `detail: { row, col, value }` in matrix mode,
85
+ * `detail: { date, value }` in calendar mode. `cellText` overrides the
86
+ * built-in English "Row X, Col Y: value" / "Mon DD: value" template used for
87
+ * both the hover tooltip and the keyboard live-region announcement.
88
+ * @csspart base, canvas, tooltip, live-region, legend, legend-lo, legend-hi, legend-annotation
38
89
  */
39
90
  export declare class LyraHeatmap extends LyraElement {
40
91
  static styles: import("lit").CSSResultGroup[];
@@ -56,26 +107,112 @@ export declare class LyraHeatmap extends LyraElement {
56
107
  mode: 'matrix' | 'calendar';
57
108
  days: CalendarDay[];
58
109
  bucketCount: number;
110
+ /** Cells to ring-highlight — `row`/`col` in matrix mode, `date` in calendar mode. See `HeatmapAnnotation`. */
111
+ annotations: HeatmapAnnotation[];
112
+ /** Formats the per-cell tooltip and keyboard live-region text — receives the cell position
113
+ * (`MatrixCellPos` in matrix mode, `CalendarCellPos` in calendar mode) and its value. Falls back to
114
+ * the built-in English "Row X, Col Y: value" / "Mon DD: value" template when unset. */
115
+ cellText?: (pos: MatrixCellPos | CalendarCellPos, value: number) => string;
59
116
  private canvas?;
60
117
  private resizeObserver?;
61
118
  private dprQuery?;
119
+ /** The current value range, refreshed once per update cycle by `willUpdate()`. See `computeValueRange()`. */
120
+ private cachedValueRange;
121
+ /** The cell currently under the pointer (`null` when not hovering one) — drives `[part="tooltip"]`. */
122
+ private hoverCell;
123
+ /** The roving keyboard-focus cell cursor, moved by arrow keys — drives the
124
+ * canvas-drawn focus ring and the `[part="live-region"]` announcement. */
125
+ private focusedCell;
126
+ /** Text of the visually-hidden `aria-live="polite"` status announcement, refreshed on every focus move. */
127
+ private liveText;
62
128
  connectedCallback(): void;
63
129
  disconnectedCallback(): void;
64
130
  private watchDpr;
65
131
  private onDprChange;
66
- protected willUpdate(): void;
67
- /** The real (non-no-data) value range across `values` (or `days` in calendar mode), or `null` if there is none. Shared by `willUpdate()`, `draw()`, and the legend. */
68
- private valueRange;
132
+ protected willUpdate(changed: PropertyValues): void;
133
+ /**
134
+ * The real (non-no-data) value range across `values` (or `days` in
135
+ * calendar mode), or `null` if there is none. Only called from
136
+ * `willUpdate()`, which caches the result in `cachedValueRange` for
137
+ * `render()` and `drawMatrix()` to reuse — `willUpdate()`, `render()`, and
138
+ * `updated()` (which triggers `draw()`) all run within the same Lit update
139
+ * cycle against the same `values`/`days`, so a single scan per cycle
140
+ * suffices instead of one per consumer.
141
+ */
142
+ private computeValueRange;
69
143
  protected updated(): void;
70
144
  /** Reads the customizable ramp endpoints off the host's computed style. */
71
145
  private scaleEndpoints;
72
146
  /** Resolves the `--lyra-color-text-quiet` chrome token for axis labels. */
73
147
  private labelColor;
148
+ /** Reads the customizable canvas axis/label font off the host's computed style. */
149
+ private labelFont;
74
150
  /** Reads the customizable no-data cell fill off the host's computed style. */
75
151
  private noDataFill;
152
+ /** Reads the customizable canvas-drawn keyboard-focus-ring stroke color off the host's computed style. */
153
+ private focusRingColor;
154
+ /** Reads the customizable canvas-drawn annotation-ring stroke color off the host's computed style. */
155
+ private annotationColor;
76
156
  private draw;
77
157
  private drawCalendar;
158
+ /**
159
+ * Effective per-cell size in matrix mode — `fitToWidth` derives it from
160
+ * the host's measured width, otherwise it's the fixed `cellSize`
161
+ * property. Shared by `drawMatrix()` and the pointer/keyboard hit-testing
162
+ * below (`hitTestMatrix()`, `cellRect()`) so they always agree on exactly
163
+ * the same geometry as what's actually painted.
164
+ */
165
+ private matrixCellSize;
78
166
  private drawMatrix;
167
+ /**
168
+ * Maps a pointer position, in canvas-local CSS px (e.g.
169
+ * `PointerEvent.offsetX/offsetY`), to the cell underneath it — or `null`
170
+ * if the pointer is outside the grid. Dispatches on `mode` so callers
171
+ * don't have to.
172
+ */
173
+ private hitTest;
174
+ private hitTestMatrix;
175
+ private hitTestCalendar;
176
+ /**
177
+ * Resolves a (week, weekday) grid position to its real calendar date and
178
+ * value. Computed from grid geometry (`firstWeekStart` + offset), not
179
+ * just looked up in `cells` — so a position with no matching entry in
180
+ * `days` (a gap in a sparse calendar) still resolves to a real ISO date,
181
+ * with a `-1` "no data" sentinel value (the same convention `values`' `-1`
182
+ * sentinel uses in matrix mode), instead of being unresolvable.
183
+ */
184
+ private calendarCellAt;
185
+ /**
186
+ * Pixel rect (canvas-local CSS px) of a cell — shared by `tooltipStyle()`
187
+ * so the tooltip's position always agrees with the same geometry
188
+ * `drawMatrix()`/`drawCalendar()`/`hitTest*()` use.
189
+ */
190
+ private cellRect;
191
+ /**
192
+ * Human-readable "<label>: <value>" text for a cell — shared by the hover
193
+ * tooltip and the keyboard-focus live-region announcement, so both always
194
+ * describe a cell the same way. This is the built-in English fallback used
195
+ * when `cellText` isn't set — see `resolveCellText()`.
196
+ */
197
+ private defaultCellText;
198
+ private matrixCellText;
199
+ private calendarCellText;
200
+ /** The raw numeric value at a cell position, in either mode — shared by `resolveCellText()`
201
+ * so a custom `cellText` formatter receives the same value the built-in template would use. */
202
+ private valueAt;
203
+ /** Dispatches to the host-provided `cellText` formatter when set, otherwise the built-in template. */
204
+ private resolveCellText;
205
+ /** Refreshes the visually-hidden live-region text for a newly-focused cell. */
206
+ private announce;
207
+ private emitCellClick;
208
+ /** Inline `style` for `[part="tooltip"]`, centered above the given cell. */
209
+ private tooltipStyle;
210
+ private onPointerMove;
211
+ private onPointerLeave;
212
+ private onCanvasClick;
213
+ private onKeyDown;
214
+ private onMatrixKeyDown;
215
+ private onCalendarKeyDown;
79
216
  render(): TemplateResult;
80
217
  }
81
218
  declare global {