@kivacore/ui-pro-shared 0.0.9 → 0.0.11
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.
- package/package.json +167 -1
- package/src/.kiva/config.json +27 -0
- package/src/components/avatar-group.tsx +222 -0
- package/src/components/kiva/bulk-update-dialog/bulk-update-dialog.tsx +240 -0
- package/src/components/kiva/bulk-update-dialog/index.tsx +6 -0
- package/src/components/kiva/bulk-update-dialog/types.ts +33 -0
- package/src/components/kiva/calendar/animations.ts +40 -0
- package/src/components/kiva/calendar/calendar-body.tsx +106 -0
- package/src/components/kiva/calendar/calendar-sidebar.tsx +103 -0
- package/src/components/kiva/calendar/calendar.tsx +243 -0
- package/src/components/kiva/calendar/constants.ts +12 -0
- package/src/components/kiva/calendar/contexts/calendar-context.tsx +696 -0
- package/src/components/kiva/calendar/contexts/dnd-context.tsx +173 -0
- package/src/components/kiva/calendar/dialogs/add-edit-event-dialog.tsx +287 -0
- package/src/components/kiva/calendar/dialogs/delete-event-dialog.tsx +73 -0
- package/src/components/kiva/calendar/dialogs/event-details-dialog.tsx +163 -0
- package/src/components/kiva/calendar/dialogs/events-list-dialog.tsx +122 -0
- package/src/components/kiva/calendar/dnd/draggable-event.tsx +66 -0
- package/src/components/kiva/calendar/dnd/droppable-area.tsx +53 -0
- package/src/components/kiva/calendar/dnd/resizable-event.tsx +190 -0
- package/src/components/kiva/calendar/header/calendar-header.tsx +84 -0
- package/src/components/kiva/calendar/header/date-navigator.tsx +188 -0
- package/src/components/kiva/calendar/header/filter.tsx +80 -0
- package/src/components/kiva/calendar/header/today-button.tsx +49 -0
- package/src/components/kiva/calendar/header/user-select.tsx +111 -0
- package/src/components/kiva/calendar/header/view-tabs.tsx +144 -0
- package/src/components/kiva/calendar/helpers.ts +617 -0
- package/src/components/kiva/calendar/hooks/use-disclosure.ts +19 -0
- package/src/components/kiva/calendar/hooks/use-local-storage.ts +40 -0
- package/src/components/kiva/calendar/hooks/use-media-query.ts +25 -0
- package/src/components/kiva/calendar/hooks.ts +5 -0
- package/src/components/kiva/calendar/index.tsx +27 -0
- package/src/components/kiva/calendar/interfaces.ts +35 -0
- package/src/components/kiva/calendar/schemas.ts +20 -0
- package/src/components/kiva/calendar/settings/settings.tsx +116 -0
- package/src/components/kiva/calendar/skeletons/calendar-header-skeleton.tsx +27 -0
- package/src/components/kiva/calendar/skeletons/calendar-skeleton.tsx +19 -0
- package/src/components/kiva/calendar/skeletons/day-view-skeleton.tsx +40 -0
- package/src/components/kiva/calendar/skeletons/month-view-skeleton.tsx +36 -0
- package/src/components/kiva/calendar/skeletons/week-view-skeleton.tsx +48 -0
- package/src/components/kiva/calendar/skeletons/year-view-skeleton.tsx +42 -0
- package/src/components/kiva/calendar/types.ts +25 -0
- package/src/components/kiva/calendar/views/agenda-view/agenda-events.tsx +150 -0
- package/src/components/kiva/calendar/views/month-view/calendar-month-view.tsx +82 -0
- package/src/components/kiva/calendar/views/month-view/day-cell.tsx +218 -0
- package/src/components/kiva/calendar/views/month-view/event-bullet.tsx +46 -0
- package/src/components/kiva/calendar/views/month-view/month-event-badge.tsx +154 -0
- package/src/components/kiva/calendar/views/timeline/calendar-timeline-view.tsx +100 -0
- package/src/components/kiva/calendar/views/timeline/lib/timeline-layout.ts +130 -0
- package/src/components/kiva/calendar/views/timeline/lib/timeline-model.ts +504 -0
- package/src/components/kiva/calendar/views/timeline/timeline-event-bar.tsx +68 -0
- package/src/components/kiva/calendar/views/timeline/timeline-grid-header.tsx +125 -0
- package/src/components/kiva/calendar/views/timeline/timeline-row.tsx +159 -0
- package/src/components/kiva/calendar/views/timeline/timeline-section.tsx +61 -0
- package/src/components/kiva/calendar/views/timeline/use-timeline-sections.ts +278 -0
- package/src/components/kiva/calendar/views/week-and-day-view/calendar-day-view.tsx +277 -0
- package/src/components/kiva/calendar/views/week-and-day-view/calendar-time-line.tsx +47 -0
- package/src/components/kiva/calendar/views/week-and-day-view/calendar-week-view.tsx +229 -0
- package/src/components/kiva/calendar/views/week-and-day-view/day-view-multi-day-events-row.tsx +79 -0
- package/src/components/kiva/calendar/views/week-and-day-view/event-block.tsx +116 -0
- package/src/components/kiva/calendar/views/week-and-day-view/render-grouped-events.tsx +54 -0
- package/src/components/kiva/calendar/views/week-and-day-view/week-view-multi-day-events-row.tsx +159 -0
- package/src/components/kiva/calendar/views/year-view/calendar-year-view.tsx +159 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-active-chips.tsx +137 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-clear.tsx +34 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-search.tsx +67 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-section.tsx +77 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-async-options.tsx +354 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-boolean.tsx +66 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-checkbox-list.tsx +137 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-date-range.tsx +204 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-numeric-range.tsx +162 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-options-dropdown.tsx +191 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-text.tsx +53 -0
- package/src/components/kiva/data-table-side-filters/core/query-translator.ts +367 -0
- package/src/components/kiva/data-table-side-filters/core/types.ts +81 -0
- package/src/components/kiva/data-table-side-filters/data-table-side-filters.tsx +483 -0
- package/src/components/kiva/data-table-side-filters/hooks/use-data-table-side-filters.tsx +160 -0
- package/src/components/kiva/data-table-side-filters/hooks/use-show-more.tsx +62 -0
- package/src/components/kiva/data-table-side-filters/index.tsx +44 -0
- package/src/components/kiva/data-table-side-filters/lib/render-mode.ts +62 -0
- package/src/components/kiva/date-time-picker.tsx +163 -0
- package/src/components/kiva/editable-record-detail.tsx +809 -0
- package/src/components/kiva/enum-option-editor/enum-option-editor.tsx +891 -0
- package/src/components/kiva/enum-option-editor/index.tsx +26 -0
- package/src/components/kiva/enum-option-editor/kiva-enum-option-editor.tsx +320 -0
- package/src/components/kiva/enum-option-editor/types.ts +90 -0
- package/src/components/kiva/kanban.tsx +1376 -0
- package/src/components/kiva/kiva-data-export-menu.tsx +543 -0
- package/src/components/kiva/map.tsx +1631 -0
- package/src/components/kiva/pivot-calendar/components/group-sidebar.tsx +95 -0
- package/src/components/kiva/pivot-calendar/components/pivot-calendar-toolbar.tsx +113 -0
- package/src/components/kiva/pivot-calendar/components/stats-cell.tsx +126 -0
- package/src/components/kiva/pivot-calendar/helpers.ts +374 -0
- package/src/components/kiva/pivot-calendar/hooks/use-pivot-calendar.ts +222 -0
- package/src/components/kiva/pivot-calendar/index.tsx +32 -0
- package/src/components/kiva/pivot-calendar/pivot-calendar.tsx +107 -0
- package/src/components/kiva/pivot-calendar/types.ts +154 -0
- package/src/components/kiva/pivot-calendar/views/days-of-month-view.tsx +37 -0
- package/src/components/kiva/pivot-calendar/views/days-of-week-view.tsx +37 -0
- package/src/components/kiva/pivot-calendar/views/month-calendar-view.tsx +154 -0
- package/src/components/kiva/pivot-calendar/views/months-of-year-view.tsx +40 -0
- package/src/components/kiva/pivot-calendar/views/pivot-grid-view.tsx +251 -0
- package/src/components/kiva/pivot-filter/index.tsx +9 -0
- package/src/components/kiva/pivot-filter/pivot-filter-item.tsx +159 -0
- package/src/components/kiva/pivot-filter/pivot-filter-settings.tsx +161 -0
- package/src/components/kiva/pivot-filter/pivot-filter.tsx +187 -0
- package/src/components/kiva/pivot-filter/types.ts +82 -0
- package/src/components/kiva/pivot-grid/hooks/use-pivot-grid.ts +683 -0
- package/src/components/kiva/pivot-grid/index.tsx +23 -0
- package/src/components/kiva/pivot-grid/lib/pivot-grid-color-rules.ts +98 -0
- package/src/components/kiva/pivot-grid/lib/pivot-grid-export.ts +265 -0
- package/src/components/kiva/pivot-grid/lib/pivot-grid-model.ts +1110 -0
- package/src/components/kiva/pivot-grid/pivot-grid-demo-data.ts +200 -0
- package/src/components/kiva/pivot-grid/pivot-grid-export-menu.tsx +66 -0
- package/src/components/kiva/pivot-grid/pivot-grid-toolbar.tsx +85 -0
- package/src/components/kiva/pivot-grid/pivot-grid.tsx +601 -0
- package/src/components/kiva/pivot-grid/types.ts +195 -0
- package/src/components/kiva/place-autocomplete.tsx +484 -0
- package/src/components/kiva/record-delete-confirm-dialog/index.tsx +10 -0
- package/src/components/kiva/record-delete-confirm-dialog/record-delete-confirm-dialog.tsx +266 -0
- package/src/components/kiva/record-delete-confirm-dialog/types.ts +25 -0
- package/src/hooks/kiva/_internal/autonumber-setting.ts +112 -0
- package/src/hooks/kiva/_internal/form-layout-to-view.ts +665 -0
- package/src/hooks/kiva/_internal/kiva-hook-utils.ts +143 -0
- package/src/hooks/kiva/_internal/use-computed-field-evaluator.tsx +310 -0
- package/src/hooks/kiva/_internal/use-field-actions-evaluator.tsx +398 -0
- package/src/hooks/kiva/_internal/use-form-actions-evaluator.tsx +363 -0
- package/src/hooks/kiva/_internal/use-form-view-engine.tsx +2200 -0
- package/src/hooks/kiva/_internal/use-kiva-form-view-fields.tsx +190 -0
- package/src/hooks/kiva/_internal/use-kiva-kanban-cards.tsx +311 -0
- package/src/hooks/kiva/use-data-export.tsx +265 -0
- package/src/hooks/kiva/use-kiva-calendar.tsx +992 -0
- package/src/hooks/kiva/use-kiva-data-export.tsx +173 -0
- package/src/hooks/kiva/use-kiva-data-grid.tsx +4750 -0
- package/src/hooks/kiva/use-kiva-data-view-select.tsx +1273 -0
- package/src/hooks/kiva/use-kiva-form-view.tsx +1581 -0
- package/src/hooks/kiva/use-kiva-inventory.tsx +184 -0
- package/src/hooks/kiva/use-kiva-kanban.tsx +1750 -0
- package/src/hooks/kiva/use-kiva-map-view.tsx +2255 -0
- package/src/hooks/kiva/use-kiva-pivot-calendar.tsx +759 -0
- package/src/hooks/kiva/use-kiva-pivot-filter.tsx +1523 -0
- package/src/hooks/kiva/use-kiva-pivot-grid.tsx +543 -0
- package/src/hooks/kiva/use-kiva-tenant.tsx +313 -0
- package/src/hooks/kiva/use-parameter-persistence.ts +191 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { useCallback, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type RestApiClient } from '@kivacore/api-client';
|
|
8
|
+
import { type RuleGroupType } from 'react-querybuilder';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Body shape POSTed to the server-side export endpoint
|
|
12
|
+
* (`POST /v1/edge/run/query-export`). Mirrors the payload the legacy Vue
|
|
13
|
+
* frontend assembled in `exportToXlsxRemote`.
|
|
14
|
+
*/
|
|
15
|
+
export interface KivaDataExportPayload {
|
|
16
|
+
/** Target data source ID — required by the edge query. */
|
|
17
|
+
dataSourceId: string;
|
|
18
|
+
/**
|
|
19
|
+
* Columns to include in the export. Pass `'*'` (or omit) to let the server
|
|
20
|
+
* default to every exportable field, or an array of field slugs to project a
|
|
21
|
+
* specific subset. Slugs may carry inline projections such as
|
|
22
|
+
* `country(id,name,autonumber_id)`. The hook serializes the array into a
|
|
23
|
+
* comma-separated string before POSTing to the endpoint.
|
|
24
|
+
*/
|
|
25
|
+
columns?: '*' | ReadonlyArray<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Filter group applied to the underlying items query. Pass the same shape
|
|
28
|
+
* used by the items endpoint (combinator + rules).
|
|
29
|
+
*/
|
|
30
|
+
filters?: RuleGroupType | null;
|
|
31
|
+
/** Free-text keyword search forwarded to the server. */
|
|
32
|
+
filterKeyword?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Row order, in any shape the items endpoint takes: `autonumber_id desc`,
|
|
35
|
+
* `{ field, direction }`, or a list of those.
|
|
36
|
+
*/
|
|
37
|
+
orderBy?: string | { field: string; direction?: 'asc' | 'desc' } | Array<{ field: string; direction?: 'asc' | 'desc' }>;
|
|
38
|
+
/** Maximum number of rows to export. Defaults to the hook's `defaultLimit`. */
|
|
39
|
+
limit?: number;
|
|
40
|
+
/**
|
|
41
|
+
* File type: `xlsx` (the default) or `csv` (UTF-8 with a BOM). A server
|
|
42
|
+
* older than the `requested` layout ignores it and writes xlsx.
|
|
43
|
+
*/
|
|
44
|
+
format?: 'xlsx' | 'csv';
|
|
45
|
+
/**
|
|
46
|
+
* `'requested'` writes exactly the columns asked for: a bare relation, user
|
|
47
|
+
* or choice field becomes one label column, each projected sub-field (`id`
|
|
48
|
+
* and `autonumber_id` included) gets its own column, and no id column is
|
|
49
|
+
* added unless one is asked for. Needs explicit `columns` (not `'*'`).
|
|
50
|
+
* Without it the server keeps its older layout for older clients.
|
|
51
|
+
*/
|
|
52
|
+
layout?: 'requested';
|
|
53
|
+
/**
|
|
54
|
+
* Column headers keyed by the column's path as written in `columns`: `name`,
|
|
55
|
+
* `country.autonumber_id`, `country.region.name`. A column without an entry
|
|
56
|
+
* is headed by its field name.
|
|
57
|
+
*/
|
|
58
|
+
headers?: Record<string, string>;
|
|
59
|
+
/** Text for checkbox values. Defaults to the server's `YES` / `NO`. */
|
|
60
|
+
booleanLabels?: { true: string; false: string };
|
|
61
|
+
/** Free-form extras forwarded verbatim to the endpoint. */
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface UseKivaDataExportOptions {
|
|
66
|
+
/** Authenticated REST client used to POST the export request. */
|
|
67
|
+
client: RestApiClient;
|
|
68
|
+
/** Default row cap when `payload.limit` is omitted. Defaults to `10000`. */
|
|
69
|
+
defaultLimit?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Endpoint path. Defaults to `/v1/edge/run/query-export`. Override only when
|
|
72
|
+
* a deployment exposes the export edge function under a different route.
|
|
73
|
+
*/
|
|
74
|
+
endpoint?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface UseKivaDataExportResult {
|
|
78
|
+
/**
|
|
79
|
+
* Trigger a server-side export. The server responds with a binary file
|
|
80
|
+
* (xlsx by default) and the underlying `client.download` writes it straight
|
|
81
|
+
* to the user's browser using the Content-Disposition filename.
|
|
82
|
+
*/
|
|
83
|
+
exportData: (payload: KivaDataExportPayload) => Promise<void>;
|
|
84
|
+
/** True while a request is in flight. */
|
|
85
|
+
isExporting: boolean;
|
|
86
|
+
/** Last error thrown by `exportData` (cleared on every new attempt). */
|
|
87
|
+
error: Error | null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Hook that wraps the Kiva server-side export endpoint
|
|
92
|
+
* (`POST /v1/edge/run/query-export`).
|
|
93
|
+
*
|
|
94
|
+
* Unlike `useDataExport` (which projects already-loaded rows into a local
|
|
95
|
+
* file), this hook hands a query payload to the server and lets it stream back
|
|
96
|
+
* the full result set as an xlsx attachment — well-suited to exports that
|
|
97
|
+
* exceed the browser's working set.
|
|
98
|
+
*/
|
|
99
|
+
export function useKivaDataExport(
|
|
100
|
+
options: UseKivaDataExportOptions
|
|
101
|
+
): UseKivaDataExportResult {
|
|
102
|
+
const {
|
|
103
|
+
client,
|
|
104
|
+
defaultLimit = 10000,
|
|
105
|
+
endpoint = '/v1/edge/run/query-export'
|
|
106
|
+
} = options;
|
|
107
|
+
|
|
108
|
+
const [isExporting, setIsExporting] = useState(false);
|
|
109
|
+
const [error, setError] = useState<Error | null>(null);
|
|
110
|
+
|
|
111
|
+
const exportData = useCallback(
|
|
112
|
+
async (payload: KivaDataExportPayload) => {
|
|
113
|
+
setIsExporting(true);
|
|
114
|
+
setError(null);
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const body = buildExportBody(payload, defaultLimit);
|
|
118
|
+
|
|
119
|
+
await client.download(endpoint, body);
|
|
120
|
+
} catch (caught) {
|
|
121
|
+
const normalized = caught instanceof Error ? caught : new Error(String(caught));
|
|
122
|
+
|
|
123
|
+
setError(normalized);
|
|
124
|
+
throw normalized;
|
|
125
|
+
} finally {
|
|
126
|
+
setIsExporting(false);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
[client, defaultLimit, endpoint]
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return { exportData, isExporting, error };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function buildExportBody(
|
|
136
|
+
payload: KivaDataExportPayload,
|
|
137
|
+
defaultLimit: number
|
|
138
|
+
): Record<string, unknown> {
|
|
139
|
+
const {
|
|
140
|
+
dataSourceId,
|
|
141
|
+
columns,
|
|
142
|
+
filters,
|
|
143
|
+
filterKeyword,
|
|
144
|
+
limit,
|
|
145
|
+
...rest
|
|
146
|
+
} = payload;
|
|
147
|
+
|
|
148
|
+
const body: Record<string, unknown> = {
|
|
149
|
+
...rest,
|
|
150
|
+
dataSourceId,
|
|
151
|
+
columns: normalizeColumns(columns),
|
|
152
|
+
filters: filters && filters.rules.length > 0 ? filters : null,
|
|
153
|
+
limit: typeof limit === 'number' && limit > 0 ? limit : defaultLimit
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (filterKeyword && filterKeyword.length > 0) {
|
|
157
|
+
body.filterKeyword = filterKeyword;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return body;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function normalizeColumns(
|
|
164
|
+
columns: KivaDataExportPayload['columns']
|
|
165
|
+
): string {
|
|
166
|
+
if (!columns || columns === '*') return '*';
|
|
167
|
+
|
|
168
|
+
const list = Array.from(columns).filter(
|
|
169
|
+
(slug): slug is string => typeof slug === 'string' && slug.length > 0
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
return list.length > 0 ? list.join(',') : '*';
|
|
173
|
+
}
|