@upbound/monarch-blocks 0.1.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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/dist/cel-filter-bar.d.ts +187 -0
  4. package/dist/cel-filter-bar.js +1850 -0
  5. package/dist/cel-filter-bar.js.map +1 -0
  6. package/dist/chart.d.ts +52 -0
  7. package/dist/chart.js +332 -0
  8. package/dist/chart.js.map +1 -0
  9. package/dist/chat-interface.d.ts +143 -0
  10. package/dist/chat-interface.js +676 -0
  11. package/dist/chat-interface.js.map +1 -0
  12. package/dist/code-block.d.ts +21 -0
  13. package/dist/code-block.js +201 -0
  14. package/dist/code-block.js.map +1 -0
  15. package/dist/data-table.d.ts +505 -0
  16. package/dist/data-table.js +4725 -0
  17. package/dist/data-table.js.map +1 -0
  18. package/dist/filter-bar.d.ts +80 -0
  19. package/dist/filter-bar.js +590 -0
  20. package/dist/filter-bar.js.map +1 -0
  21. package/dist/floating-widget.d.ts +36 -0
  22. package/dist/floating-widget.js +218 -0
  23. package/dist/floating-widget.js.map +1 -0
  24. package/dist/index.d.ts +18 -0
  25. package/dist/index.js +6217 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/page-header.d.ts +12 -0
  28. package/dist/page-header.js +120 -0
  29. package/dist/page-header.js.map +1 -0
  30. package/dist/relative-time.d.ts +60 -0
  31. package/dist/relative-time.js +328 -0
  32. package/dist/relative-time.js.map +1 -0
  33. package/dist/section-header.d.ts +11 -0
  34. package/dist/section-header.js +123 -0
  35. package/dist/section-header.js.map +1 -0
  36. package/dist/section-nav.d.ts +50 -0
  37. package/dist/section-nav.js +143 -0
  38. package/dist/section-nav.js.map +1 -0
  39. package/dist/timeline.d.ts +8 -0
  40. package/dist/timeline.js +95 -0
  41. package/dist/timeline.js.map +1 -0
  42. package/dist/types-BULiU2qC.d.ts +170 -0
  43. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Upbound
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # @upbound/monarch-blocks
2
+
3
+ Upbound's design system — composed components: `Chart`, `DataTable`, `FilterBar`, `CelFilterBar`, `ChatInterface`,
4
+ `Timeline`, and more. Built on [`@upbound/monarch-core`](https://www.npmjs.com/package/@upbound/monarch-core)'s
5
+ primitives, with real dependencies of their own (charting, table state, CEL filter expression compiling) that
6
+ `monarch-core` deliberately stays free of.
7
+
8
+ Kept as a separate package from `monarch-core` on purpose: installing it always pulls in `@upbound/monarch-core` as a
9
+ real dependency, but installing `monarch-core` alone never pulls in this package's heavier dependency tree.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @upbound/monarch-blocks
15
+ ```
16
+
17
+ Peer dependencies: `react` and `react-dom` (`^18.3.0 || ^19.0.0`), `tailwindcss` (`^4.0.0`). `@upbound/monarch-core`
18
+ installs automatically as a transitive dependency.
19
+
20
+ ## Set up the theme
21
+
22
+ This package ships no CSS of its own — it reuses `@upbound/monarch-core`'s tokens and utility classes. Set up
23
+ `monarch-core`'s theme as documented in
24
+ [its README](https://www.npmjs.com/package/@upbound/monarch-core#set-up-the-theme); `monarch-blocks` needs the same
25
+ `@import` and `@source` lines, with one addition — extend the `@source` glob to cover this package's compiled files too:
26
+
27
+ ```css
28
+ @import 'tailwindcss';
29
+ @import '@upbound/monarch-core/theme.css';
30
+ @source '../../node_modules/@upbound/monarch-core/dist/*.js';
31
+ @source '../../node_modules/@upbound/monarch-blocks/dist/*.js';
32
+ ```
33
+
34
+ (Path assumes a Next.js `--src-dir` layout — see `@upbound/monarch-core`'s README for why `dist/*.js`, not a recursive
35
+ glob, and why the path climbs two directories.)
36
+
37
+ ## Use a component
38
+
39
+ ```tsx
40
+ import { DataTable } from '@upbound/monarch-blocks';
41
+ ```
42
+
43
+ Or import a single component's own subpath, same as `monarch-core`:
44
+
45
+ ```tsx
46
+ import { DataTable } from '@upbound/monarch-blocks/data-table';
47
+ ```
48
+
49
+ ### Server Components
50
+
51
+ Same caveat as `monarch-core`: the root barrel bundles every component into one file and is a client boundary
52
+ unconditionally. Import a component's own subpath if you need it in a context where that matters.
53
+
54
+ ## Not part of the shadcn registry
55
+
56
+ Unlike `@upbound/monarch-core`, these components are **not** available through `npx shadcn add @monarch/...` — the
57
+ registry intentionally sources from `monarch-core` only, so a consumer using the shadcn CLI path never pulls in this
58
+ package's heavier dependencies. npm install is the only distribution channel for `monarch-blocks`.
@@ -0,0 +1,187 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { k as CompileResult, t as CelValidationMeta, d as CelFilterCondition, f as CelFilterSchema, V as ValidationIssue, g as CelFilterTree, P as PillActiveSurface, u as CelFilterType, h as CelOperator, v as CelFilterShape, C as CelColumnDefinition, w as CelEmitOn, D as DateCelValue, M as MapKeyCelValue, l as MultiTextCelValue, m as RelativeDurationPreset, c as CelFilterBarProps } from './types-BULiU2qC.js';
3
+ export { a as CelColumnOption, b as CelConditionValue, e as CelFilterGroup, i as CelRestrictedOptionSelectPayload, j as CheckboxCelValue, R as RadioCelValue, n as isCelFilterCondition, o as isCelFilterGroup, p as isCheckboxCelValue, q as isDateCelValue, r as isMapKeyCelValue, s as isMultiTextCelValue } from './types-BULiU2qC.js';
4
+
5
+ /**
6
+ * Applies draft/commit display rules to a raw compile result.
7
+ *
8
+ * Validation timing: a condition's issues are surfaced on its pill and in the
9
+ * global panel only once it has been committed (popover closed) and is not
10
+ * currently being edited. Group-level issues (e.g. nesting depth) always show.
11
+ *
12
+ * `isEmitReady` on the returned object is always `false` here — it is a
13
+ * placeholder that `CelFilterBar` overrides via `computeIsEmitReady` before
14
+ * calling `onCompileResultChange`. This is the single source of truth for the gate.
15
+ */
16
+
17
+ declare function applyDisplayRules(raw: CompileResult, meta: CelValidationMeta): CompileResult;
18
+
19
+ /**
20
+ * Validates a single condition against the provided schema. Returns an empty
21
+ * array when the condition is complete and compilable.
22
+ */
23
+ declare function validateCondition(condition: CelFilterCondition, schema: CelFilterSchema): ValidationIssue[];
24
+
25
+ type ComputeIsEmitReadyMeta = {
26
+ activeSurface: PillActiveSurface | null;
27
+ committedConditionIds: Set<string>;
28
+ };
29
+ /**
30
+ * Gates API emission while a commit-mode condition is mid-edit. Only the
31
+ * actively edited condition matters — one popover at a time.
32
+ */
33
+ declare function computeIsEmitReady(raw: CompileResult, editingConditionId: string | null, schema: CelFilterSchema, tree: CelFilterTree, meta: ComputeIsEmitReadyMeta): boolean;
34
+
35
+ /**
36
+ * Walks the tree, joins root children with ` && `, and emits a CEL string when
37
+ * everything is complete and valid. An empty root compiles to `""` with status
38
+ * `valid` (the API treats an empty filter as no filter).
39
+ */
40
+ declare function compileCelFilterTree(tree: CelFilterTree, schema: CelFilterSchema): CompileResult;
41
+
42
+ /**
43
+ * Instant helpers for the CEL date filter.
44
+ *
45
+ * Stored values are RFC3339 UTC strings, and everything here manipulates them as
46
+ * text rather than through `Date`, so a filter can never drift into the viewer's
47
+ * local timezone. Tables render timestamps in UTC, so a UTC filter is what
48
+ * agrees with the times shown in the table.
49
+ */
50
+ /** Which end of a day/minute an instant represents. */
51
+ type DateBoundary = 'start' | 'end';
52
+ declare function calendarDayStartInstant(instant: string): string;
53
+ /**
54
+ * True when the date portion names a day that exists. `Date` rolls impossible
55
+ * days over silently — Feb 31 becomes Mar 3 rather than failing — so a
56
+ * round-trip through UTC is what separates a real day from a rolled-over one.
57
+ */
58
+ declare function isRealCalendarDay(instant: string): boolean;
59
+ /** Reads the `HH:mm` an `input[type="time"]` displays for a stored instant. */
60
+ declare function readTimeOfDay(instant: string | undefined): string;
61
+ /** Replaces the time portion of an instant. Seconds are zeroed — the input is minute-granular. */
62
+ declare function withTimeOfDay(instant: string, timeOfDay: string): string;
63
+ /**
64
+ * Stamps a picked calendar day as a UTC instant. The picker hands back a local
65
+ * `Date` whose Y/M/D is the day that was clicked; that day is stored as the
66
+ * matching UTC day so the filter lines up with the UTC timestamps in the table.
67
+ */
68
+ declare function formatCalendarDateUtc(date: Date, boundary: DateBoundary): string;
69
+ /** Parses a stored RFC3339 string back into a local Date carrying the calendar day. */
70
+ declare function parseCalendarDate(value: string | undefined): Date | undefined;
71
+ /**
72
+ * Locale date for display, plus the UTC time when the instant carries a
73
+ * user-picked one. `locale` defaults to the runtime's own locale (matching
74
+ * plain `toLocaleDateString()`) — callers rendered during SSR should pass a
75
+ * fixed locale explicitly (see `cel-filter-bar.tsx`'s `useMounted()` gating)
76
+ * so the server-rendered/first-paint value doesn't hydration-mismatch against
77
+ * the viewer's actual browser locale.
78
+ */
79
+ declare function formatInstantLabel(instant: string | undefined, { withTime, locale }?: {
80
+ withTime?: boolean;
81
+ locale?: string;
82
+ }): string;
83
+
84
+ /**
85
+ * Operator metadata and CEL fragment generation.
86
+ *
87
+ * This is the single place that knows how `condition.operator` + value map to CEL
88
+ * output. UI components never hand-write CEL — they read/write tree state and the
89
+ * compiler walks it through here.
90
+ */
91
+
92
+ /**
93
+ * Returns the operators allowed for a column. `allowedOperators` on a column
94
+ * definition overrides the default set derived from its filter type.
95
+ */
96
+ declare function getAllowedOperators(columnDef?: CelColumnDefinition): CelOperator[];
97
+ declare function isDateRelativeOperator(operator: CelOperator): boolean;
98
+ /** True for the date operators that match a whole calendar day and so take no time. */
99
+ declare function isDateWindowOperator(operator: CelOperator): boolean;
100
+ /** True for the date operators whose value is a `range` rather than an `instant`. */
101
+ declare function isDateRangeOperator(operator: CelOperator): boolean;
102
+ /**
103
+ * Which day boundary a date comparator compares against, and therefore the time
104
+ * its input prefills with until the user edits it.
105
+ */
106
+ declare function dateBoundaryForOperator(operator: CelOperator): DateBoundary;
107
+ declare function resolveColumnDefinition(condition: Pick<CelFilterCondition, 'columnId'>, schema: CelFilterSchema): CelColumnDefinition | undefined;
108
+ /** Resolves the value/operator shape for a condition, or `undefined` for an unknown column. */
109
+ declare function resolveFilterShape(condition: Pick<CelFilterCondition, 'columnId' | 'value'>, schema: CelFilterSchema): CelFilterShape | undefined;
110
+ declare function getOperatorLabel(operator: CelOperator): string;
111
+ declare function getQuantifierLabel(quantifier: 'any' | 'all'): string;
112
+ declare function allowsMultipleConditions(filterType: CelFilterType): boolean;
113
+ declare function getDefaultOperator(filterType: CelFilterType): CelOperator;
114
+ /**
115
+ * Applies the minimal value-retention rules when the operator changes on an
116
+ * existing condition. Returns a new condition; does not mutate the input.
117
+ *
118
+ * For dates, the clearing rules here are the enforcement half of the date state
119
+ * machine the date editor implements: clear when the value shape changes (range
120
+ * operators vs single-instant ones), or when a relative value would become
121
+ * illegal under `is`/`is_not`, and drop a picked time when moving to a
122
+ * whole-day operator. Keep both in sync.
123
+ */
124
+ declare function applyOperatorChange(condition: CelFilterCondition, newOperator: CelOperator, shape: CelFilterShape | undefined): CelFilterCondition;
125
+ /** Maps parsed CEL aliases back to schema column ids when building the filter tree. */
126
+ declare function denormalizeColumnIdWithReservedNames(columnId: string): string;
127
+
128
+ /**
129
+ * Escapes a user-provided string literal for safe embedding inside a CEL
130
+ * double-quoted string. Callers wrap the result in `"..."` at the use site
131
+ * (e.g. `column == "${escapeCelString(value)}"`).
132
+ *
133
+ * CEL generated output uses double-quoted strings only, so single quotes are
134
+ * left untouched.
135
+ */
136
+ declare function escapeCelString(input: string): string;
137
+ /** Convenience helper that escapes and wraps a value in double quotes. */
138
+ declare function celStringLiteral(input: string): string;
139
+
140
+ /** Generates a stable unique id, falling back when `crypto.randomUUID` is unavailable. */
141
+ declare function createCelNodeId(): string;
142
+ /** Creates an empty tree whose root is a depth-0 `and` group with no children. */
143
+ declare function createEmptyCelFilterTree(): CelFilterTree;
144
+ type CreateDefaultConditionParams = {
145
+ schema: CelFilterSchema;
146
+ columnId: string;
147
+ };
148
+ /**
149
+ * Creates a new condition with the default operator for its column and an
150
+ * undefined value (filled in by the user in the popover).
151
+ */
152
+ declare function createDefaultCondition({ schema, columnId }: CreateDefaultConditionParams): CelFilterCondition;
153
+ /** Appends a condition to the root group's children. */
154
+ declare function appendCondition(tree: CelFilterTree, condition: CelFilterCondition): CelFilterTree;
155
+ /** Replaces a root-level condition by id, applying `updater` to the existing condition. Root-level only — v1's UI never produces nested groups. */
156
+ declare function replaceCondition(tree: CelFilterTree, conditionId: string, updater: (condition: CelFilterCondition) => CelFilterCondition): CelFilterTree;
157
+ /** Removes a root-level condition by id. */
158
+ declare function removeConditionById(tree: CelFilterTree, conditionId: string): CelFilterTree;
159
+
160
+ /** Upserts (or unions, for checkbox) an externally-provided value into the tree by column type. */
161
+ declare function mergeContextualIntoCelTree(tree: CelFilterTree, schema: CelFilterSchema, columnId: string, values: string[]): CelFilterTree;
162
+
163
+ declare function isMultiTextColumn(columnId: string, schema: CelFilterSchema): boolean;
164
+ /** Returns when a column's valid value may be emitted; explicit `emitOn` overrides filterType defaults. */
165
+ declare function getColumnEmitOn(columnDef: CelColumnDefinition): CelEmitOn;
166
+
167
+ /** Relative when a preset is set; preset and absolute fields are mutually exclusive. */
168
+ declare function isRelativeDateCelValue(value: DateCelValue): boolean;
169
+ declare function readDateCelValue(value: unknown): DateCelValue;
170
+ declare function readMapKeyCelValue(value: unknown): MapKeyCelValue;
171
+ declare function readMultiTextCelValue(value: unknown): MultiTextCelValue;
172
+
173
+ /**
174
+ * Shared limits and defaults for the CEL filter builder. Values mirror the API
175
+ * constraints (`maxNestingDepth = 50`, `maxRegexLen = 1000`).
176
+ */
177
+
178
+ /**
179
+ * Trusted relative date presets emitted as fixed `duration(...)` literals in
180
+ * compiled CEL. Hours only — `duration()` rejects a `d` unit.
181
+ */
182
+ declare const RELATIVE_DURATION_PRESET_VALUES: readonly ["24h", "168h", "720h"];
183
+ declare function isRelativeDurationPreset(value: string): value is RelativeDurationPreset;
184
+
185
+ declare function CelFilterBar({ tree, onChange, schema, onCompileResultChange, onRestrictedOptionSelect, showClearButton, className, }: CelFilterBarProps): react_jsx_runtime.JSX.Element;
186
+
187
+ export { CelColumnDefinition, CelFilterBar, CelFilterBarProps, CelFilterCondition, CelFilterSchema, CelFilterTree, CelOperator, CompileResult, DateCelValue, MapKeyCelValue, MultiTextCelValue, PillActiveSurface, RELATIVE_DURATION_PRESET_VALUES, RelativeDurationPreset, ValidationIssue, allowsMultipleConditions, appendCondition, applyDisplayRules, applyOperatorChange, calendarDayStartInstant, celStringLiteral, compileCelFilterTree, computeIsEmitReady, createCelNodeId, createDefaultCondition, createEmptyCelFilterTree, dateBoundaryForOperator, denormalizeColumnIdWithReservedNames, escapeCelString, formatCalendarDateUtc, formatInstantLabel, getAllowedOperators, getColumnEmitOn, getDefaultOperator, getOperatorLabel, getQuantifierLabel, isDateRangeOperator, isDateRelativeOperator, isDateWindowOperator, isMultiTextColumn, isRealCalendarDay, isRelativeDateCelValue, isRelativeDurationPreset, mergeContextualIntoCelTree, parseCalendarDate, readDateCelValue, readMapKeyCelValue, readMultiTextCelValue, readTimeOfDay, removeConditionById, replaceCondition, resolveColumnDefinition, resolveFilterShape, validateCondition, withTimeOfDay };