@webority/ui-elements 0.121.0 → 0.124.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.
- package/dist/WuiAutocomplete-DE9q2G-l.js +13 -0
- package/dist/{WuiCarousel-BbO8AoM6.js → WuiCarousel-C2NWcFxr.js} +1 -1
- package/dist/WuiCodeBlock-DafK2Kgc.js +1 -0
- package/dist/{WuiCommandPalette-DdL68m66.js → WuiCommandPalette-CiEj7qnn.js} +2 -2
- package/dist/WuiCommentThread-CjbH1bTm.js +1 -0
- package/dist/WuiConsentBanner-BF5ymoH5.js +1 -0
- package/dist/WuiContextMenu-C_u0AVna.js +1 -0
- package/dist/{WuiCountrySelect-CuZpXHoS.js → WuiCountrySelect-kgShmlip.js} +1 -1
- package/dist/WuiDataTable-BICQ8DT7.js +1 -0
- package/dist/WuiDatePicker-CkBUk76L.js +31 -0
- package/dist/WuiDateRange-3NYNJiIa.js +25 -0
- package/dist/WuiDrawer-CCrbNdBV.js +1 -0
- package/dist/{WuiHoverCard-CKAPuJSF.js → WuiHoverCard-sq6EZZYD.js} +1 -1
- package/dist/{WuiImageCrop-CvXh791S.js → WuiImageCrop-DzzzPagi.js} +2 -2
- package/dist/WuiInlineEdit-CN0-5kdq.js +1 -0
- package/dist/WuiLightbox-D_7mpvkt.js +1 -0
- package/dist/WuiMarkdown-BxmKHb3T.js +4 -0
- package/dist/WuiMentionInput-46BVSsH_.js +1 -0
- package/dist/WuiMultiSelect-Brdm5tAI.js +25 -0
- package/dist/WuiNotificationCenter-DBSXYFYm.js +1 -0
- package/dist/{WuiOtp-DfhXc829.js → WuiOtp-Hw6srogj.js} +1 -1
- package/dist/WuiOverflow-Bn68qgAQ.js +1 -0
- package/dist/WuiPhone-DuMF_Dzx.js +16 -0
- package/dist/{WuiRecordPager-DRSJg2o9.js → WuiRecordPager-BOaFcs_W.js} +1 -1
- package/dist/WuiRelativeTime-9u8XG-nr.js +1 -0
- package/dist/{WuiResizable-CtwCQUWR.js → WuiResizable-mt9EMhjQ.js} +1 -1
- package/dist/WuiRollingNumber-C72xBgyG.js +1 -0
- package/dist/WuiSavedViews-DrJWvWuf.js +1 -0
- package/dist/WuiSelect-Bma_H42p.js +15 -0
- package/dist/WuiShortcuts-Cerbe67I.js +1 -0
- package/dist/WuiSlider-DXJGSJHP.js +48 -0
- package/dist/WuiSortable-r5iZtzM1.js +1 -0
- package/dist/WuiTagInput-C38b3LfS.js +6 -0
- package/dist/{WuiTimePicker-PB0UN3eA.js → WuiTimePicker-Bw5BKBCD.js} +3 -3
- package/dist/WuiTour-DjR-6kr5.js +1 -0
- package/dist/WuiTree-BN-o92yj.js +1 -0
- package/dist/{WuiTruncate-Cxujs1Xt.js → WuiTruncate-DyDQWMBu.js} +1 -1
- package/dist/WuiWhatsNew-Biolggw8.js +1 -0
- package/dist/WuiWizardStep-DkEdAXc8.js +1 -0
- package/dist/dataTable-4RjZ1c5V.js +1 -0
- package/dist/elements/autocomplete.js +1 -1
- package/dist/elements/carousel.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/consent-banner.js +1 -1
- package/dist/elements/context-menu.js +1 -1
- package/dist/elements/country-select.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/drawer.js +1 -1
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/image-crop.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/multiselect.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/otp.js +1 -1
- package/dist/elements/overflow.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/record-pager.js +1 -1
- package/dist/elements/relative-time.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/rolling-number.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/shortcuts.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/sortable.js +1 -1
- package/dist/elements/taginput.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/truncate.js +1 -1
- package/dist/elements/whats-new.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/fileViewerImage-Bn5HCF30.js +3 -0
- package/dist/fileViewerMedia-zSDnvCSa.js +1 -0
- package/dist/{fileViewerPdf-CFQj8r_-.js → fileViewerPdf-C1QZnzCq.js} +10 -7
- package/dist/fileViewerUi-CHY-0j9d.js +1 -0
- package/dist/filterPopover-C8MVAfyI.js +1 -0
- package/dist/focusOrigin-BPTN3GY3.js +1 -0
- package/dist/{formMirror-BgY7zkC3.js → formMirror-BMQTenSi.js} +1 -1
- package/dist/formatters-7rx97Lnm.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/iconGlyphs.g-CQcMoS6_.js +1 -0
- package/dist/kanban-B4bOs1tX.js +1 -0
- package/dist/{max-CNrKnpEj.js → max-ByBKGsXq.js} +49 -13
- package/dist/notificationDays-CZNthz7L.js +1 -0
- package/dist/{optionLabel-aV6M6_a-.js → optionLabel-BaLjjB-0.js} +1 -1
- package/dist/shortcutKeys-CvxSh3bV.js +1 -0
- package/dist/themeTransition-lIK8WDpA.js +1 -0
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-chart.global.js +11 -11
- package/dist/ui-chart.js +11 -11
- package/dist/ui-chat.global.js +6 -5
- package/dist/ui-chat.js +6 -5
- package/dist/ui-consent-banner.global.js +1 -1
- package/dist/ui-elements/autocomplete.global.js +6 -6
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +2 -2
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +2 -2
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +2 -2
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +3 -3
- package/dist/ui-elements/multiselect.global.js +15 -15
- package/dist/ui-elements/phone.global.js +2 -2
- package/dist/ui-elements/resizable.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/slider.global.js +2 -2
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -1
- package/dist/ui-elements/taginput.global.js +3 -3
- package/dist/ui-elements/timepicker.global.js +2 -2
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +23 -23
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +9 -9
- package/dist/ui-file-viewer.js +1 -1
- package/dist/ui-phone.global.js +6 -6
- package/dist/ui-rich-text.global.js +30 -30
- package/dist/ui-rich-text.js +32 -32
- package/dist/ui-tour.global.js +1 -1
- package/dist/wuiHttp-CHYHtqMj.js +1 -0
- package/package.json +6 -7
- package/dist/WuiAutocomplete-Bol_8H76.js +0 -13
- package/dist/WuiCodeBlock-C6OjA3tc.js +0 -1
- package/dist/WuiCommentThread-Cov5ym1G.js +0 -1
- package/dist/WuiConsentBanner-hpbfnzFw.js +0 -1
- package/dist/WuiContextMenu-DT_dPAuA.js +0 -1
- package/dist/WuiDataTable-CoxLsrAF.js +0 -1
- package/dist/WuiDatePicker-D5ArlyfO.js +0 -31
- package/dist/WuiDateRange-zBX7UxAi.js +0 -25
- package/dist/WuiDrawer-BDPrSmML.js +0 -1
- package/dist/WuiInlineEdit-BNtLomtk.js +0 -1
- package/dist/WuiLightbox-B0HZefpp.js +0 -1
- package/dist/WuiMarkdown-DdsyCxS8.js +0 -4
- package/dist/WuiMentionInput-BfU34T2S.js +0 -1
- package/dist/WuiMultiSelect-COHA1_cK.js +0 -25
- package/dist/WuiNotificationCenter-o7tGbnb1.js +0 -1
- package/dist/WuiOverflow-i_dzzIuJ.js +0 -1
- package/dist/WuiPhone-BAEXxhPv.js +0 -16
- package/dist/WuiRelativeTime-B5I84Rkz.js +0 -1
- package/dist/WuiRollingNumber-BVwFF7Ha.js +0 -1
- package/dist/WuiSavedViews-CYtzjqya.js +0 -1
- package/dist/WuiSelect-DhrTajiM.js +0 -15
- package/dist/WuiShortcuts-BpR8npaI.js +0 -1
- package/dist/WuiSlider-IOqadOtK.js +0 -48
- package/dist/WuiSortable-CugtxycN.js +0 -1
- package/dist/WuiTagInput-Dg0Y-pa5.js +0 -6
- package/dist/WuiTour-BMGg8CQx.js +0 -1
- package/dist/WuiTree-0sPEmeDM.js +0 -1
- package/dist/WuiWhatsNew-DkI69gjR.js +0 -1
- package/dist/WuiWizardStep-Dd_6ruDG.js +0 -1
- package/dist/dataTable-SKMmByaz.js +0 -1
- package/dist/fileViewerImage-Q4ILIc5S.js +0 -3
- package/dist/fileViewerMedia-CvyJKkAx.js +0 -1
- package/dist/fileViewerUi-uUZ6lfhT.js +0 -1
- package/dist/filterPopover-pkhDKdKR.js +0 -1
- package/dist/focusOrigin-2imUSs-u.js +0 -1
- package/dist/formatters-6DhcQIjT.js +0 -1
- package/dist/iconGlyphs.g-CrodCkbV.js +0 -1
- package/dist/kanban-yDMAPkmx.js +0 -1
- package/dist/notificationDays-DOIBIwN5.js +0 -1
- package/dist/shortcutKeys-DdQ_0ops.js +0 -1
- package/dist/themeTransition-BY52mM_w.js +0 -1
- package/dist/types/chatClient.d.ts +0 -208
- package/dist/types/chatCore.d.ts +0 -21
- package/dist/types/chatLabels.d.ts +0 -70
- package/dist/types/sse.d.ts +0 -33
- package/dist/ui-chat-core.js +0 -7
- package/dist/wuiHttp-XeYjnOdx.js +0 -1
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A failed chat request. `message` is written for the person and is safe to show as-is.
|
|
3
|
-
*/
|
|
4
|
-
export declare class ChatApiError extends Error {
|
|
5
|
-
code: string;
|
|
6
|
-
status: number | undefined;
|
|
7
|
-
resetsAtUtc: string | null;
|
|
8
|
-
/**
|
|
9
|
-
* @param {string} code Machine-readable reason: the server's code (`daily_limit`,
|
|
10
|
-
* `assistant_unavailable`, ...), "network" when no response arrived, "aborted" when the
|
|
11
|
-
* request was cancelled, or "unknown".
|
|
12
|
-
* @param {string} message The sentence to show the person.
|
|
13
|
-
* @param {number} [status] HTTP status, when a response arrived.
|
|
14
|
-
* @param {string|null} [resetsAtUtc] For `daily_limit`: when the allowance comes back, in UTC.
|
|
15
|
-
*/
|
|
16
|
-
constructor(code: string, message: string, status?: number, resetsAtUtc?: string | null);
|
|
17
|
-
}
|
|
18
|
-
export type ChatHttp = {
|
|
19
|
-
get: (url: string, config?: object) => Promise<{
|
|
20
|
-
data: any;
|
|
21
|
-
}>;
|
|
22
|
-
post: (url: string, data?: any, config?: object) => Promise<{
|
|
23
|
-
data: any;
|
|
24
|
-
}>;
|
|
25
|
-
put: (url: string, data?: any, config?: object) => Promise<{
|
|
26
|
-
data: any;
|
|
27
|
-
}>;
|
|
28
|
-
delete: (url: string, config?: object) => Promise<{
|
|
29
|
-
data: any;
|
|
30
|
-
}>;
|
|
31
|
-
};
|
|
32
|
-
export type SupportAction = {
|
|
33
|
-
/**
|
|
34
|
-
* Sent back by the confirm button; nothing happens without it.
|
|
35
|
-
*/
|
|
36
|
-
token: string;
|
|
37
|
-
kind: "RaiseTicket" | "Reply" | "Reopen";
|
|
38
|
-
ticketId: string | null;
|
|
39
|
-
ticketNumber: string | null;
|
|
40
|
-
category: string | null;
|
|
41
|
-
subject: string | null;
|
|
42
|
-
body: string | null;
|
|
43
|
-
expiresDateTimeUtc: string;
|
|
44
|
-
};
|
|
45
|
-
export type ChatTurnInput = {
|
|
46
|
-
/**
|
|
47
|
-
* The person's question.
|
|
48
|
-
*/
|
|
49
|
-
message: string;
|
|
50
|
-
/**
|
|
51
|
-
* The conversation to continue; left out to start one.
|
|
52
|
-
*/
|
|
53
|
-
conversationId?: string | null;
|
|
54
|
-
/**
|
|
55
|
-
* Product-defined context about the screen, passed through as-is.
|
|
56
|
-
*/
|
|
57
|
-
pageContext?: any;
|
|
58
|
-
};
|
|
59
|
-
export type ChatStreamOptions = {
|
|
60
|
-
/**
|
|
61
|
-
* Cancels the request.
|
|
62
|
-
*/
|
|
63
|
-
signal?: AbortSignal;
|
|
64
|
-
/**
|
|
65
|
-
* Called for each event
|
|
66
|
-
* before the end of the turn: `delta { text }` to append, `reset {}` to discard what was shown,
|
|
67
|
-
* `tool { toolName }` when the assistant starts a tool (the name only), `actions { actions }` for support cards.
|
|
68
|
-
*/
|
|
69
|
-
onEvent?: (name: "delta" | "reset" | "tool" | "actions", data: any) => void;
|
|
70
|
-
};
|
|
71
|
-
export type ChatTurnResult = {
|
|
72
|
-
conversationId: string;
|
|
73
|
-
/**
|
|
74
|
-
* The stored reply's id, for rating; null when storing failed.
|
|
75
|
-
*/
|
|
76
|
-
messageId: string | null;
|
|
77
|
-
/**
|
|
78
|
-
* The reply of record. It replaces whatever was streamed.
|
|
79
|
-
*/
|
|
80
|
-
reply: string;
|
|
81
|
-
/**
|
|
82
|
-
* Null when the person has no daily limit.
|
|
83
|
-
*/
|
|
84
|
-
messagesLeftToday: number | null;
|
|
85
|
-
};
|
|
86
|
-
export type ConversationSummary = {
|
|
87
|
-
publicId: string;
|
|
88
|
-
title: string | null;
|
|
89
|
-
createdDateTimeUtc: string;
|
|
90
|
-
lastMessageDateTimeUtc: string;
|
|
91
|
-
};
|
|
92
|
-
export type ConversationMessage = {
|
|
93
|
-
publicId: string;
|
|
94
|
-
role: "User" | "Assistant";
|
|
95
|
-
content: string;
|
|
96
|
-
/**
|
|
97
|
-
* The support actions offered with an assistant reply, as a JSON array.
|
|
98
|
-
*/
|
|
99
|
-
actionsJson: string | null;
|
|
100
|
-
rating: "Up" | "Down" | null;
|
|
101
|
-
ratingNote: string | null;
|
|
102
|
-
createdDateTimeUtc: string;
|
|
103
|
-
};
|
|
104
|
-
export type Conversation = {
|
|
105
|
-
publicId: string;
|
|
106
|
-
title: string | null;
|
|
107
|
-
messages: ConversationMessage[];
|
|
108
|
-
};
|
|
109
|
-
export type ChatClient = {
|
|
110
|
-
sendMessage: (input: ChatTurnInput, options?: ChatStreamOptions) => Promise<ChatTurnResult>;
|
|
111
|
-
getAllowance: () => Promise<{
|
|
112
|
-
messagesLeftToday: number | null;
|
|
113
|
-
}>;
|
|
114
|
-
listConversations: (query?: {
|
|
115
|
-
skip?: number;
|
|
116
|
-
take?: number;
|
|
117
|
-
}) => Promise<ConversationSummary[]>;
|
|
118
|
-
getConversation: (id: string) => Promise<Conversation>;
|
|
119
|
-
deleteConversation: (id: string) => Promise<void>;
|
|
120
|
-
rateMessage: (conversationId: string, messageId: string, input: {
|
|
121
|
-
rating: "Up" | "Down";
|
|
122
|
-
note?: string | null;
|
|
123
|
-
}) => Promise<void>;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* @typedef {object} ChatHttp An axios instance (or axios-compatible) that already carries the
|
|
127
|
-
* bearer token, tenant headers and refresh. The streamed turn needs axios's XHR adapter (the
|
|
128
|
-
* browser default) to read the reply as it arrives.
|
|
129
|
-
* @property {(url: string, config?: object) => Promise<{ data: any }>} get
|
|
130
|
-
* @property {(url: string, data?: any, config?: object) => Promise<{ data: any }>} post
|
|
131
|
-
* @property {(url: string, data?: any, config?: object) => Promise<{ data: any }>} put
|
|
132
|
-
* @property {(url: string, config?: object) => Promise<{ data: any }>} delete
|
|
133
|
-
*/
|
|
134
|
-
/**
|
|
135
|
-
* @typedef {object} SupportAction An action the assistant prepared for the person to confirm.
|
|
136
|
-
* @property {string} token Sent back by the confirm button; nothing happens without it.
|
|
137
|
-
* @property {"RaiseTicket"|"Reply"|"Reopen"} kind
|
|
138
|
-
* @property {string|null} ticketId
|
|
139
|
-
* @property {string|null} ticketNumber
|
|
140
|
-
* @property {string|null} category
|
|
141
|
-
* @property {string|null} subject
|
|
142
|
-
* @property {string|null} body
|
|
143
|
-
* @property {string} expiresDateTimeUtc
|
|
144
|
-
*/
|
|
145
|
-
/**
|
|
146
|
-
* @typedef {object} ChatTurnInput
|
|
147
|
-
* @property {string} message The person's question.
|
|
148
|
-
* @property {string|null} [conversationId] The conversation to continue; left out to start one.
|
|
149
|
-
* @property {any} [pageContext] Product-defined context about the screen, passed through as-is.
|
|
150
|
-
*/
|
|
151
|
-
/**
|
|
152
|
-
* @typedef {object} ChatStreamOptions
|
|
153
|
-
* @property {AbortSignal} [signal] Cancels the request.
|
|
154
|
-
* @property {(name: "delta"|"reset"|"tool"|"actions", data: any) => void} [onEvent] Called for each event
|
|
155
|
-
* before the end of the turn: `delta { text }` to append, `reset {}` to discard what was shown,
|
|
156
|
-
* `tool { toolName }` when the assistant starts a tool (the name only), `actions { actions }` for support cards.
|
|
157
|
-
*/
|
|
158
|
-
/**
|
|
159
|
-
* @typedef {object} ChatTurnResult The `done` event: the turn's outcome of record.
|
|
160
|
-
* @property {string} conversationId
|
|
161
|
-
* @property {string|null} messageId The stored reply's id, for rating; null when storing failed.
|
|
162
|
-
* @property {string} reply The reply of record. It replaces whatever was streamed.
|
|
163
|
-
* @property {number|null} messagesLeftToday Null when the person has no daily limit.
|
|
164
|
-
*/
|
|
165
|
-
/**
|
|
166
|
-
* @typedef {object} ConversationSummary
|
|
167
|
-
* @property {string} publicId
|
|
168
|
-
* @property {string|null} title
|
|
169
|
-
* @property {string} createdDateTimeUtc
|
|
170
|
-
* @property {string} lastMessageDateTimeUtc
|
|
171
|
-
*/
|
|
172
|
-
/**
|
|
173
|
-
* @typedef {object} ConversationMessage
|
|
174
|
-
* @property {string} publicId
|
|
175
|
-
* @property {"User"|"Assistant"} role
|
|
176
|
-
* @property {string} content
|
|
177
|
-
* @property {string|null} actionsJson The support actions offered with an assistant reply, as a JSON array.
|
|
178
|
-
* @property {"Up"|"Down"|null} rating
|
|
179
|
-
* @property {string|null} ratingNote
|
|
180
|
-
* @property {string} createdDateTimeUtc
|
|
181
|
-
*/
|
|
182
|
-
/**
|
|
183
|
-
* @typedef {object} Conversation
|
|
184
|
-
* @property {string} publicId
|
|
185
|
-
* @property {string|null} title
|
|
186
|
-
* @property {ConversationMessage[]} messages
|
|
187
|
-
*/
|
|
188
|
-
/**
|
|
189
|
-
* @typedef {object} ChatClient
|
|
190
|
-
* @property {(input: ChatTurnInput, options?: ChatStreamOptions) => Promise<ChatTurnResult>} sendMessage
|
|
191
|
-
* @property {() => Promise<{ messagesLeftToday: number|null }>} getAllowance
|
|
192
|
-
* @property {(query?: { skip?: number, take?: number }) => Promise<ConversationSummary[]>} listConversations
|
|
193
|
-
* @property {(id: string) => Promise<Conversation>} getConversation
|
|
194
|
-
* @property {(id: string) => Promise<void>} deleteConversation
|
|
195
|
-
* @property {(conversationId: string, messageId: string, input: { rating: "Up"|"Down", note?: string|null }) => Promise<void>} rateMessage
|
|
196
|
-
*/
|
|
197
|
-
/**
|
|
198
|
-
* Binds the chat HTTP contract to the product's own authenticated axios instance. The package
|
|
199
|
-
* never handles auth: tokens, tenant headers and refresh stay in the instance.
|
|
200
|
-
*
|
|
201
|
-
* @param {ChatHttp} http
|
|
202
|
-
* @param {{ base: string }} options `base` is the prefix the API maps the chat endpoints under,
|
|
203
|
-
* e.g. "/api/assistant" for `POST /api/assistant/chat`.
|
|
204
|
-
* @returns {ChatClient}
|
|
205
|
-
*/
|
|
206
|
-
export declare function createChatClient(http: ChatHttp, { base }: {
|
|
207
|
-
base: string;
|
|
208
|
-
}): ChatClient;
|
package/dist/types/chatCore.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { ChatApiError, createChatClient } from "./chatClient.js";
|
|
2
|
-
export { DEFAULT_CHAT_LABELS, mergeLabels } from "./chatLabels.js";
|
|
3
|
-
export { createSseParser } from "./sse.js";
|
|
4
|
-
export type ChatHttp = import("./chatClient.js").ChatHttp;
|
|
5
|
-
export type SupportAction = import("./chatClient.js").SupportAction;
|
|
6
|
-
export type ChatTurnInput = import("./chatClient.js").ChatTurnInput;
|
|
7
|
-
export type ChatStreamOptions = import("./chatClient.js").ChatStreamOptions;
|
|
8
|
-
export type ChatTurnResult = import("./chatClient.js").ChatTurnResult;
|
|
9
|
-
export type ConversationSummary = import("./chatClient.js").ConversationSummary;
|
|
10
|
-
export type ConversationMessage = import("./chatClient.js").ConversationMessage;
|
|
11
|
-
export type Conversation = import("./chatClient.js").Conversation;
|
|
12
|
-
export type ChatClient = import("./chatClient.js").ChatClient;
|
|
13
|
-
/** @typedef {import("./chatClient.js").ChatHttp} ChatHttp */
|
|
14
|
-
/** @typedef {import("./chatClient.js").SupportAction} SupportAction */
|
|
15
|
-
/** @typedef {import("./chatClient.js").ChatTurnInput} ChatTurnInput */
|
|
16
|
-
/** @typedef {import("./chatClient.js").ChatStreamOptions} ChatStreamOptions */
|
|
17
|
-
/** @typedef {import("./chatClient.js").ChatTurnResult} ChatTurnResult */
|
|
18
|
-
/** @typedef {import("./chatClient.js").ConversationSummary} ConversationSummary */
|
|
19
|
-
/** @typedef {import("./chatClient.js").ConversationMessage} ConversationMessage */
|
|
20
|
-
/** @typedef {import("./chatClient.js").Conversation} Conversation */
|
|
21
|
-
/** @typedef {import("./chatClient.js").ChatClient} ChatClient */
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Every word the chat components show, in English. Pass a `labels` object with any subset to a
|
|
3
|
-
* component to change its wording; the rest keep these defaults. The few that take a value are
|
|
4
|
-
* functions.
|
|
5
|
-
*/
|
|
6
|
-
export declare const DEFAULT_CHAT_LABELS: Readonly<{
|
|
7
|
-
launcher: "Ask the assistant";
|
|
8
|
-
panelTitle: "Assistant";
|
|
9
|
-
newChat: "New chat";
|
|
10
|
-
close: "Close";
|
|
11
|
-
thread: "Conversation";
|
|
12
|
-
you: "You";
|
|
13
|
-
assistant: "Assistant";
|
|
14
|
-
thinking: "Thinking";
|
|
15
|
-
emptyTitle: "How can I help?";
|
|
16
|
-
emptyText: "Ask a question about what you see on this page.";
|
|
17
|
-
composer: "Your question";
|
|
18
|
-
placeholder: "Ask a question";
|
|
19
|
-
send: "Send";
|
|
20
|
-
composerHint: "Press Enter to send, Shift and Enter for a new line.";
|
|
21
|
-
/** @type {(count: number) => string} */
|
|
22
|
-
allowance: (count: number) => string;
|
|
23
|
-
disclaimer: "Answers are written by AI and can be wrong. Check anything important.";
|
|
24
|
-
loadingConversation: "Loading the conversation";
|
|
25
|
-
rateUp: "Helpful";
|
|
26
|
-
rateDown: "Not helpful";
|
|
27
|
-
rated: "Thanks for the feedback.";
|
|
28
|
-
ratingNote: "What was wrong with this answer?";
|
|
29
|
-
ratingNoteHint: "Optional.";
|
|
30
|
-
ratingNoteSend: "Send";
|
|
31
|
-
ratingNoteSkip: "Skip";
|
|
32
|
-
ratingFailed: "Your rating did not save. Please try again.";
|
|
33
|
-
actionRaiseTicket: "New support ticket";
|
|
34
|
-
/** @type {(ticketNumber: string) => string} */
|
|
35
|
-
actionReply: (ticketNumber: string) => string;
|
|
36
|
-
/** @type {(ticketNumber: string) => string} */
|
|
37
|
-
actionReopen: (ticketNumber: string) => string;
|
|
38
|
-
actionNote: "Nothing is sent until you confirm.";
|
|
39
|
-
actionConfirm: "Confirm";
|
|
40
|
-
actionDismiss: "Not now";
|
|
41
|
-
actionDismissed: "Not sent.";
|
|
42
|
-
actionExpired: "This request expired and was not sent. Ask again if you still need it.";
|
|
43
|
-
actionFailed: "We could not send this. Please try again.";
|
|
44
|
-
actionDone: "Done.";
|
|
45
|
-
/** @type {(ticketNumber: string) => string} */
|
|
46
|
-
actionDoneRaiseTicket: (ticketNumber: string) => string;
|
|
47
|
-
/** @type {(ticketNumber: string) => string} */
|
|
48
|
-
actionDoneReply: (ticketNumber: string) => string;
|
|
49
|
-
/** @type {(ticketNumber: string) => string} */
|
|
50
|
-
actionDoneReopen: (ticketNumber: string) => string;
|
|
51
|
-
viewTicket: "View ticket";
|
|
52
|
-
conversations: "Past chats";
|
|
53
|
-
conversationsEmptyTitle: "No past chats";
|
|
54
|
-
conversationsEmptyText: "Your conversations with the assistant show here.";
|
|
55
|
-
untitled: "Untitled chat";
|
|
56
|
-
deleteConversation: "Delete chat";
|
|
57
|
-
deleteConfirmTitle: "Delete this chat?";
|
|
58
|
-
deleteConfirmMessage: "The conversation is removed for good.";
|
|
59
|
-
deleteConfirm: "Delete";
|
|
60
|
-
deleteFailed: "We could not delete this chat. Please try again.";
|
|
61
|
-
cancel: "Cancel";
|
|
62
|
-
loadMore: "Show more";
|
|
63
|
-
loadFailed: "We could not load your chats. Please try again.";
|
|
64
|
-
retry: "Try again";
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* @param {Partial<typeof DEFAULT_CHAT_LABELS>} [labels]
|
|
68
|
-
* @returns {typeof DEFAULT_CHAT_LABELS}
|
|
69
|
-
*/
|
|
70
|
-
export declare function mergeLabels(labels?: Partial<typeof DEFAULT_CHAT_LABELS>): typeof DEFAULT_CHAT_LABELS;
|
package/dist/types/sse.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {object} SseEvent
|
|
3
|
-
* @property {string} name The `event:` field, or "message" when the block names none.
|
|
4
|
-
* @property {any} data The `data:` lines joined by newlines and parsed as JSON.
|
|
5
|
-
*/
|
|
6
|
-
export type SseEvent = {
|
|
7
|
-
/**
|
|
8
|
-
* The `event:` field, or "message" when the block names none.
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
/**
|
|
12
|
-
* The `data:` lines joined by newlines and parsed as JSON.
|
|
13
|
-
*/
|
|
14
|
-
data: any;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* An incremental reader for a `text/event-stream` body that arrives in pieces. Each `push` takes
|
|
18
|
-
* the next piece of text; only complete events (ended by a blank line) are handed on, and the
|
|
19
|
-
* incomplete tail waits for the next piece. `end` flushes a final event the stream closed
|
|
20
|
-
* without a blank line after.
|
|
21
|
-
*
|
|
22
|
-
* Line endings may be `\n`, `\r\n` or `\r`, and a `\r\n` pair may be split across two pieces.
|
|
23
|
-
* Comment lines (`:`), `id` and `retry` are ignored. A block whose data is not JSON is reported
|
|
24
|
-
* as an `error` event with the code `invalid-response`, so a caller ends the turn instead of
|
|
25
|
-
* hanging on it.
|
|
26
|
-
*
|
|
27
|
-
* @param {(event: SseEvent) => void} onEvent
|
|
28
|
-
* @returns {{ push: (text: string) => void, end: () => void }}
|
|
29
|
-
*/
|
|
30
|
-
export declare function createSseParser(onEvent: (event: SseEvent) => void): {
|
|
31
|
-
push: (text: string) => void;
|
|
32
|
-
end: () => void;
|
|
33
|
-
};
|
package/dist/ui-chat-core.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
function e(e){let t=``;function n(t){let n=`message`,r=[];for(let e of t.split(`
|
|
2
|
-
`)){if(e===``||e.startsWith(`:`))continue;let t=e.indexOf(`:`),i=t===-1?e:e.slice(0,t),a=t===-1?``:e.slice(t+1);a.startsWith(` `)&&(a=a.slice(1)),i===`event`?n=a:i===`data`&&r.push(a)}if(r.length===0)return;let i;try{i=JSON.parse(r.join(`
|
|
3
|
-
`))}catch{e({name:`error`,data:{code:`invalid-response`,message:null}});return}e({name:n,data:i})}return{push(e){if(!e)return;t=(t+e).replace(/\r\n/g,`
|
|
4
|
-
`).replace(/\r(?!$)/g,`
|
|
5
|
-
`);let r=t.split(`
|
|
6
|
-
|
|
7
|
-
`);t=r.pop();for(let e of r)n(e)},end(){let e=t.replace(/\r$/,``);t=``,e.trim()&&n(e)}}}var t=`Something went wrong. Please try again.`,n=class extends Error{constructor(e,t,n,r=null){super(t),this.name=`ChatApiError`,this.code=e,this.status=n,this.resetsAtUtc=r}};function r(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}function i(e,t){return t?.aborted||e?.code===`ERR_CANCELED`||e?.name===`CanceledError`||e?.name===`AbortError`}function a(e,a){if(e instanceof n)return e;if(i(e,a))return new n(`aborted`,`The request was cancelled.`);let o=e?.response;if(!o)return new n(`network`,t);let s=r(o.data),c=typeof s?.code==`string`&&s.code?s.code:`unknown`,l=typeof s?.message==`string`&&s.message?s.message:t,u=typeof s?.resetsAtUtc==`string`?s.resetsAtUtc:null;return new n(c,l,o.status,u)}async function o(e){try{return(await e()).data}catch(e){throw a(e)}}function s(e){let t=e?.event?.target;if(!(!t||typeof t.responseText!=`string`)&&!(typeof t.status==`number`&&(t.status<200||t.status>=300)))return t.responseText}function c(r,{base:i}){if(typeof i!=`string`||i.trim()===``)throw TypeError(`createChatClient needs a base path, e.g. { base: "/api/assistant" }.`);let c=i.replace(/\/+$/,``),l=e=>`${c}/conversations/${encodeURIComponent(e)}`;async function u({message:i,conversationId:o,pageContext:l},{signal:u,onEvent:d}={}){let f=null,p=null,m=e(({name:e,data:t})=>{f||p||(e===`done`?f=t:e===`error`?p=t:(e===`delta`||e===`reset`||e===`tool`||e===`actions`)&&d?.(e,t))}),h=0,g=e=>{typeof e!=`string`||e.length<=h||(m.push(e.slice(h)),h=e.length)},_={message:i};o&&(_.conversationId=o),l!=null&&(_.pageContext=l);let v;try{v=await r.post(`${c}/chat`,_,{responseType:`text`,headers:{Accept:`text/event-stream`},signal:u,onDownloadProgress:e=>g(s(e))})}catch(e){throw a(e,u)}if(g(v.data),m.end(),p)throw new n(p.code||`unknown`,p.message||t);if(!f)throw new n(`invalid-response`,t,v.status);return f}return{sendMessage:u,getAllowance:()=>o(()=>r.get(`${c}/allowance`)),listConversations:({skip:e,take:t}={})=>{let n=new URLSearchParams;e!=null&&n.append(`skip`,String(e)),t!=null&&n.append(`take`,String(t));let i=n.toString();return o(()=>r.get(`${c}/conversations${i?`?${i}`:``}`))},getConversation:e=>o(()=>r.get(l(e))),deleteConversation:async e=>{await o(()=>r.delete(l(e)))},rateMessage:async(e,t,{rating:n,note:i})=>{let a=typeof i==`string`?i.trim():``;await o(()=>r.put(`${l(e)}/messages/${encodeURIComponent(t)}/rating`,{rating:n,note:a||null}))}}}var l=Object.freeze({launcher:`Ask the assistant`,panelTitle:`Assistant`,newChat:`New chat`,close:`Close`,thread:`Conversation`,you:`You`,assistant:`Assistant`,thinking:`Thinking`,emptyTitle:`How can I help?`,emptyText:`Ask a question about what you see on this page.`,composer:`Your question`,placeholder:`Ask a question`,send:`Send`,composerHint:`Press Enter to send, Shift and Enter for a new line.`,allowance:e=>e===0?`You have no questions left today.`:e===1?`You have 1 question left today.`:`You have ${e} questions left today.`,disclaimer:`Answers are written by AI and can be wrong. Check anything important.`,loadingConversation:`Loading the conversation`,rateUp:`Helpful`,rateDown:`Not helpful`,rated:`Thanks for the feedback.`,ratingNote:`What was wrong with this answer?`,ratingNoteHint:`Optional.`,ratingNoteSend:`Send`,ratingNoteSkip:`Skip`,ratingFailed:`Your rating did not save. Please try again.`,actionRaiseTicket:`New support ticket`,actionReply:e=>`Reply on ${e}`,actionReopen:e=>`Reopen ${e}`,actionNote:`Nothing is sent until you confirm.`,actionConfirm:`Confirm`,actionDismiss:`Not now`,actionDismissed:`Not sent.`,actionExpired:`This request expired and was not sent. Ask again if you still need it.`,actionFailed:`We could not send this. Please try again.`,actionDone:`Done.`,actionDoneRaiseTicket:e=>`Ticket ${e} raised.`,actionDoneReply:e=>`Your reply was added to ${e}.`,actionDoneReopen:e=>`${e} is open again.`,viewTicket:`View ticket`,conversations:`Past chats`,conversationsEmptyTitle:`No past chats`,conversationsEmptyText:`Your conversations with the assistant show here.`,untitled:`Untitled chat`,deleteConversation:`Delete chat`,deleteConfirmTitle:`Delete this chat?`,deleteConfirmMessage:`The conversation is removed for good.`,deleteConfirm:`Delete`,deleteFailed:`We could not delete this chat. Please try again.`,cancel:`Cancel`,loadMore:`Show more`,loadFailed:`We could not load your chats. Please try again.`,retry:`Try again`});function u(e){return e?{...l,...e}:l}export{n as ChatApiError,l as DEFAULT_CHAT_LABELS,c as createChatClient,e as createSseParser,u as mergeLabels};
|
package/dist/wuiHttp-XeYjnOdx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./devWarn-DXdRWZs3.js";import{n,t as r}from"./buttonClass-FD57QNey.js";import{E as i,k as a,r as o,w as s,y as c}from"./dataTable-SKMmByaz.js";import{t as l}from"./iconGlyphs.g-CrodCkbV.js";var u=`Select all rows`,d=`Select row`,f=`wui-select-cell`,p=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function m(e=document){let t=e.createElement(`th`);return t.className=f,t.appendChild(p(e,u)),t}function h(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=f;let r=p(e,d);return r.disabled=t,n.appendChild(r),n}function g(e=document){let t=e.createElement(`td`);return t.className=f,t}var _=e=>e.firstElementChild?.classList.contains(f),v=e=>e.matches(`.wui-group-row, .wui-virtual-spacer`);function y(e){for(let t of e){if(_(t)||v(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(h(t.ownerDocument,{disabled:e}),t.firstChild)}}function ee(e){let t=e.querySelector(`thead tr`);if(!t)return null;_(t)||t.insertBefore(m(e.ownerDocument),t.firstChild),y(e.querySelectorAll(`tbody tr`));for(let t of e.querySelectorAll(`tfoot tr`))_(t)||t.insertBefore(g(e.ownerDocument),t.firstChild);return t.querySelector(`.${f} .wui-check`)}function b(e){let t=e.querySelector(`thead .${f} .wui-check`),n=[...e.querySelectorAll(`tbody tr .wui-check:not(:disabled)`)],r=n.length,i=n.filter(e=>e.checked).length;t&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of e.querySelectorAll(`tbody tr`))t.classList.toggle(`is-selected`,!!t.querySelector(`.wui-check`)?.checked);return{selected:i,total:r}}var x=`tbody .${f} .wui-check:not(:disabled)`;function te(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .wui-check:not(:disabled)`)&&!!e.closest(`tbody`);e.addEventListener(`mousedown`,e=>{e.shiftKey&&r(e.target)&&e.preventDefault()}),e.addEventListener(`click`,i=>{let a=i.target;if(r(a)){if(i.shiftKey&&n?.isConnected&&n!==a){let r=[...e.querySelectorAll(x)],i=r.indexOf(n),o=r.indexOf(a);if(i>=0&&o>=0){let e=[];for(let t of r.slice(Math.min(i,o),Math.max(i,o)+1))t===a||t.checked===a.checked||(t.checked=a.checked,e.push(t));e.length&&t?.(e,a.checked)}}n=a}})}var ne=Object.freeze([`page`,`pageSize`,`sortBy`,`sortOrder`]),S=`search`,C=Object.freeze({loading:`Loading rows`,error:`These rows did not load. Try again.`,network:`The connection dropped before the rows loaded. Check it and try again.`,forbidden:`You do not have access to these rows.`,retry:`Retry`,actionFailed:`That did not work. Try again.`,actionForbidden:`You do not have permission to do that.`,empty:`No rows`}),re=5,w=new WeakMap,T=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ie=e=>({total:T(e.dataset.total,0),page:T(e.dataset.page,1),pageSize:T(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`}),ae=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},E=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>e.type!==`hidden`||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!ne.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of e.querySelectorAll(`[data-wui-filter-clear]`))t.hidden=!r},D=new Intl.NumberFormat(`en-IN`),oe=(e,t)=>{let n=e.closest(`.wui-list-card`)?.querySelector(`.wui-list-card-count`);n&&(n.textContent=D.format(t))};function O(e=document){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-server]`)]:[];e instanceof Element&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t)w.has(e)||w.set(e,A(e))}function k(e){let t=e instanceof Element?e.closest(`[data-wui-server]`):null;return t&&w.get(t)||null}function A(u){let d=u.querySelector(`.table-wrap`),p=d?.querySelector(`:scope > table`),m=u.dataset.src;if(!p||!m)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let h=d.querySelector(`:scope > [data-wui-table-state]`),g=u.querySelector(`[data-wui-table-pager]`),_=u.querySelector(`[data-wui-table-status]`),v={urlState:u.dataset.urlState!==`false`,refreshOnSuccess:u.dataset.refreshOnSuccess!==`false`,filtersForm:u.dataset.filtersForm||null,filtersRegion:u.dataset.filtersRegion||null,searchInput:u.dataset.searchInput||null,loadingText:u.dataset.loadingText||C.loading,errorText:u.dataset.errorText||C.error},x=new URL(m,window.location.href),w=new Set(x.searchParams.keys()),T=p.hasAttribute(`data-app-datatable-selectable`),D=new Set,O=!1,k=le(),A=new AbortController,j={signal:A.signal},M=p.querySelector(`:scope > tbody[data-wui-rows]`);if(!M)throw Error(`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`);let N=ie(M),P=null,F=null,L=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))w.has(n)||t.append(n,r);return t},R=e=>L(new URL(e,window.location.href).search),z=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},se=e=>{let t=new URL(x.href);for(let[n,r]of e)w.has(n)||t.searchParams.append(n,r);return t.origin===window.location.origin?`${t.pathname}${t.search}`:t.href},B=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},V=B(v.urlState?L(window.location.search):new URLSearchParams,N);v.urlState&&z(V)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,z(V));let H=(e,t)=>d.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),U=e=>{_&&(_.textContent=e)},ce=e=>{if(e.total===0)return C.empty;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1;return`Page ${e.page} of ${t}, ${e.total} ${e.total===1?`row`:`rows`}`},W=()=>[...p.querySelectorAll(`:scope > thead > tr:first-child > th`)],G=e=>{if(T&&[...e.querySelectorAll(`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`)].some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},K=e=>{let t=u.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},J=e=>{if(T){y(e);for(let t of e){let e=t.querySelector(`.${f} .wui-check:not(:disabled)`);e&&(O&&D.add(t.dataset.rowKey),e.checked=D.has(t.dataset.rowKey))}b(p)}K(e);let t=W();if(p.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},ue=e=>J([...e.querySelectorAll(`:scope > tr`)]),de=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},Y=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),fe=(e,t)=>{if(!h)return;let n=e.querySelector(`:scope > template[data-wui-empty]`);Y(h),t.total===0&&n?(h.replaceChildren(n.content.cloneNode(!0)),h.hidden=!1):(h.replaceChildren(),h.hidden=!0)},pe=e=>{let t=ie(e),n=t.sortBy!==N.sortBy||t.sortOrder!==N.sortOrder?c(M.rows):null;if(g){let t=e.querySelector(`:scope > template[data-wui-pager]`);Y(g),g.replaceChildren(...t?[t.content.cloneNode(!0)]:[]),g.hidden=!1}fe(e,t);let r=e.querySelector(`:scope > template[data-wui-filters]`),i=v.filtersRegion&&r?document.querySelector(v.filtersRegion):null;i&&(Y(i),i.replaceChildren(r.content.cloneNode(!0))),de(e),Y(M),p.replaceChild(e,M),M=e;let a=O&&t.total!==N.total;return N=t,a&&(O=!1),d.removeAttribute(`data-wui-table-error`),ue(e),Ce(),s(e.rows,n),a&&Z(),i},me=e=>{let t=document.createElement(`template`);t.innerHTML=`<table>${e}</table>`;let n=t.content.querySelector(`tbody[data-wui-rows]`);return n&&G(n),n?document.importNode(n,!0):null},he=e=>{let t=document.createElement(`tr`);for(let n=0;n<e;n++){let e=document.createElement(`td`),r=document.createElement(`span`);r.className=`skeleton`,r.setAttribute(`aria-hidden`,`true`),r.style.cssText=`display:block;width:${n===0?70:50}%;height:12px;border-radius:6px`,e.append(r),t.append(e)}return t},ge=()=>{if(M.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,W().length);M.replaceChildren(...Array.from({length:re},()=>{let t=he(e);return t.setAttribute(`data-wui-skeleton`,``),t})),d.removeAttribute(`data-wui-table-error`),h&&(h.hidden=!0)},_e=e=>{e?(d.setAttribute(`aria-busy`,`true`),ge()):d.removeAttribute(`aria-busy`)},ve=e=>e===`forbidden`?C.forbidden:e===`network`?C.network:v.errorText,ye=e=>{let t=ve(e);if(d.setAttribute(`data-wui-table-error`,e),g&&(g.hidden=!0),h){let i=document.createElement(`div`);i.className=`empty-state wui-empty-state-table wui-table-error`,i.setAttribute(`role`,`alert`);let a=document.createElement(`span`);a.className=`empty-state-icon`,a.innerHTML=l(e===`forbidden`?`lock`:`alert-circle`,{size:24});let o=document.createElement(`div`);o.className=`empty-state-title`,o.textContent=t;let s=document.createElement(`div`);s.className=`empty-state-action`;let c=document.createElement(`button`);c.type=`button`,c.className=n(`outline`,`sm`),c.dataset.wui=r,c.setAttribute(`data-wui-table-retry`,``),c.textContent=C.retry,s.append(c),i.append(a,o,s),Y(h),h.replaceChildren(i),h.hidden=!1}U(t)},be=()=>v.filtersForm?document.querySelector(v.filtersForm):null,X=async(n,r=`none`,{quiet:i=!1}={})=>{let a=new URLSearchParams(n);i||(P={query:a,mode:r},_e(!0),U(v.loadingText)),H(`wui:table:loading`,{query:a.toString()});let o=await k.run(se(a));if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;i||_e(!1);let s=null,c=o.ok?null:o.kind;if(o.ok){try{s=me(o.html)}catch(e){t(e)}s||(c=`server`)}if(c)return i?e(`A quiet server table refresh failed; the rows on screen are kept.`,c):ye(c),H(`wui:table:error`,{status:o.status,kind:c,message:ve(c)}),o;let l=pe(s);return V=B(a,N),E(be(),V),v.urlState&&r===`push`?window.history.pushState(window.history.state,``,z(V)):v.urlState&&r===`replace`&&window.history.replaceState(window.history.state,``,z(V)),i||U(ce(N)),window.WUI?.refresh?.(d),l&&window.WUI?.refresh?.(l),oe(u,N.total),H(`wui:table:loaded`,{...N,query:V.toString()}),o},xe=e=>(e.delete(`page`),e),Se=()=>[...p.querySelectorAll(`:scope > thead th[data-sort-key]`)],Ce=()=>{for(let e of Se()){let t=e.dataset.sortKey===N.sortBy;e.setAttribute(`aria-sort`,t?N.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of Se())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`,n.innerHTML=l(`chevrons-up-down`,{size:14}),t?e.prepend(n):e.append(n)}let we=e=>{let t=xe(new URLSearchParams(V)),n=N.sortBy===e&&N.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),X(t,`push`)};p.addEventListener(`click`,e=>{let t=e.target.closest(`th[data-sort-key]`);t&&p.tHead?.contains(t)&&we(t.dataset.sortKey)}),p.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target.closest?.(`th[data-sort-key]`);!t||!p.tHead?.contains(t)||(e.preventDefault(),we(t.dataset.sortKey))});let Z=()=>{b(p);let e=O?{selected:N.total,total:N.total,allMatching:O}:{selected:D.size,total:N.total};p.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};T&&(te(p,(e,t)=>{for(let n of e){let e=n.closest(`tr`)?.dataset.rowKey;e&&(t?D.add(e):D.delete(e))}t||(O=!1)}),p.addEventListener(`change`,e=>{let t=e.target;if(t.matches?.(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(O=!1),p.tHead?.contains(t))for(let e of M.querySelectorAll(`:scope > tr`)){let n=e.querySelector(`.${f} .wui-check:not(:disabled)`);n&&(n.checked=t.checked,t.checked?D.add(e.dataset.rowKey):D.delete(e.dataset.rowKey))}else{let e=t.closest(`tr`)?.dataset.rowKey;if(!e)return;t.checked?D.add(e):D.delete(e)}Z()}})),g&&(g.addEventListener(`click`,e=>{let t=e.target.closest(`a[href]`);!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),X(R(t.getAttribute(`href`)),`push`))}),g.addEventListener(`change`,e=>{!e.target.classList?.contains(`tpg-select`)||!e.target.value||(e.stopPropagation(),X(R(e.target.value),`push`))}));let Q=()=>{if(!v.searchInput)return null;let e=document.querySelector(v.searchInput);return e&&(e.matches(`input, textarea`)?e:e.querySelector(`input`))},$=()=>u.isConnected?!0:(A.abort(),clearTimeout(F),!1),Te=(e,t)=>{let n=new Set;for(let t of e.elements)t.name&&t.type!==`hidden`&&n.add(t.name);let r=[];for(let t of e.elements)if(!(!t.name||t.disabled)){if(t.matches(`input[type="hidden"][data-wui-carried]`))n.has(t.name)||r.push([t.name,t.value]);else if(t.matches(`input[type=checkbox], input[type=radio]`))t.checked&&r.push([t.name,t.value]);else if(t.matches(`input, textarea`))t.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||r.push([t.name,t.value]);else if(t.localName===`select`)for(let e of t.selectedOptions)r.push([t.name,e.value])}return t?.name&&!t.disabled&&r.push([t.name,t.value]),r},Ee=(e,t)=>{let n=new Set([...e.elements].map(e=>e.name).filter(Boolean)),r=new URLSearchParams;for(let[e,t]of V)e!==`page`&&(ne.includes(e)||!n.has(e))&&r.append(e,t);for(let[n,i]of Te(e,t))i===``||ne.includes(n)||w.has(n)||r.append(n,i);let i=Q();if(i){r.delete(S);let e=i.value.trim();e&&r.set(S,e)}return X(r,`push`)},De=e=>v.filtersForm&&e.closest?.(v.filtersForm)||v.filtersRegion&&e.closest?.(v.filtersRegion)||null;document.addEventListener(`submit`,e=>{!$()||!v.filtersForm||!(e.target instanceof HTMLFormElement)||!e.target.matches(v.filtersForm)||(e.preventDefault(),Ee(e.target,e.submitter))},j),document.addEventListener(`change`,e=>{if(!$()||!v.filtersForm)return;let t=e.target.closest?.(v.filtersForm);!t||e.target===Q()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest?.(`wui-filter-popover`)||Ee(t)},j);let Oe=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of e.querySelectorAll(`input[name]:not([type=hidden])`))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of e.querySelectorAll(`select[name]`))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let t of e.querySelectorAll(`wui-select[name]`))t.value=n(t.getAttribute(`name`));for(let n of e.querySelectorAll(`wui-multiselect[name]`))n.values=t.getAll(n.getAttribute(`name`));for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`)||t.getAttribute(`name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!$())return;let t=e.target.closest?.(`a[href]`);if(!t||!De(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`),window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=xe(R(n.href));Oe(t.closest(`form`),r),E(t.closest(`form`),r),X(r,`push`)},j),document.addEventListener(`input`,e=>{if(!$())return;let t=Q();!t||e.target!==t||(clearTimeout(F),F=setTimeout(()=>{let e=xe(new URLSearchParams(V)),n=t.value.trim();n?e.set(S,n):e.delete(S),e.toString()!==V.toString()&&X(e,`replace`)},300))},j),v.urlState&&window.addEventListener(`popstate`,()=>{if(!$())return;let e=L(window.location.search),t=Q();t&&(t.value=e.get(`search`)??``),E(be(),e),X(e,`none`)},j),document.addEventListener(`wui:modal:success`,()=>{$()&&v.refreshOnSuccess&&X(V,`none`)},j),h?.addEventListener(`click`,e=>{e.target.closest(`[data-wui-table-retry]`)&&P&&X(P.query,P.mode)});let ke=e=>[...M.rows].find(t=>t.dataset.rowKey===e)??null,Ae=e=>{if(!e?.trim())return null;let t=document.createElement(`template`);if(t.innerHTML=`<table><tbody>${e}</tbody></table>`,t.content.querySelector(`tbody[data-wui-rows]`))return null;let n=[...t.content.querySelectorAll(`table > tbody > tr[data-row-key]`)];return n.length?n.map(e=>document.importNode(e,!0)):null},je=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:ke(n.dataset.rowKey);e&&(Y(e),e.replaceWith(n),i.push(n))}return J(i),window.WUI?.refresh?.(d),r},Me=e=>e.message||(e.kind===`forbidden`?C.actionForbidden:C.actionFailed),Ne=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&a(e,null)},Pe=e=>{if(e instanceof HTMLTableRowElement)return e;let t=document.createElement(`template`);t.innerHTML=`<table><tbody>${String(e)}</tbody></table>`;let n=t.content.querySelector(`table > tbody > tr`);if(!n)throw Error("saveRow's `row` is the row as it will read: a <tr> element or its HTML.");return document.importNode(n,!0)},Fe=async({url:e,method:t=`POST`,body:n,key:r,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let c=r==null,l=c?null:ke(String(r));if(!c&&!l)throw Error(`saveRow found no row with data-row-key="${r}" on this page.`);let u=W().filter(e=>!e.classList.contains(f)).length,p=s?Pe(s):l??he(Math.max(1,u));l&&p!==l?l.replaceWith(p):l||M.insertBefore(p,M.firstChild),p!==l&&J([p]),h&&!d.hasAttribute(`data-wui-table-error`)&&(h.hidden=!0),a(p,`saving`);let m=i(p),g=await q(e,{method:t.toUpperCase(),body:n});if(g.kind===`session`)return!1;if(g.ok){let e=Ae(g.html),t=e&&p.isConnected?je(e,p,c):null;return t?U(o.saved(i(t)||m)):(await X(V,`none`),Ne(p)),I(g,g.toastVariant||`success`),H(`wui:table:saved`,{key:t?.dataset.rowKey??(c?null:String(r)),added:c,status:g.status}),!0}let _=Me(g),v=p;return l&&p!==l&&p.isConnected?(p.replaceWith(l),v=l):c&&!s&&(p.remove(),v=null,h?.childElementCount&&!M.querySelector(`:scope > tr`)&&(h.hidden=!1)),v?.isConnected&&a(v,`error`,_),g.kind!==`aborted`&&ae(_,`danger`),U(o.notSaved(m,_)),H(`wui:table:failed`,{key:c?null:String(r),added:c,status:g.status,kind:g.kind,message:_}),!1},Ie=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let n=e.closest(`tr`),r=n?.dataset.rowKey??null,s=e.dataset.wuiRowAction||``,c=n?i(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&a(n,`saving`);let l=await q(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),l.kind===`session`||l.kind===`aborted`){Ne(n);return}if(l.ok){I(l,l.toastVariant||`success`);let e=n?.isConnected?Ae(l.html):null,t=e?je(e,n,!1):null;t?U(o.saved(i(t)||c)):(await X(V,`none`),Ne(n))}else{let e=Me(l);ae(e,`danger`),n?.isConnected&&a(n,`error`,e),U(o.notSaved(c,e))}H(`wui:table:action`,{action:s,key:r,ok:l.ok,status:l.status})};return p.addEventListener(`click`,e=>{let t=e.target.closest(`[data-wui-row-action]`);!t||!M.contains(t)||t.disabled||(e.preventDefault(),Ie(t))}),G(M),de(M),T&&ee(p),ue(M),Ce(),{el:u,reload:async e=>{let t=e?.quiet===!0;return t&&d.getAttribute(`aria-busy`)===`true`?null:X(V,`none`,{quiet:t})},query:()=>new URLSearchParams(V),setQuery:e=>{let t=new URLSearchParams(V);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return(!e||!(`page`in e))&&t.delete(`page`),X(t,`push`)},saveRow:Fe,setActiveRow:e=>{u.dataset.activeRowKey=e==null?``:String(e),K([...M.querySelectorAll(`:scope > tr`)])},selection:{keys:()=>[...D],count:()=>O?N.total:D.size,allMatching:()=>O,selectAllMatching:()=>{O=!0;for(let e of M.querySelectorAll(`:scope > tr`)){let t=e.querySelector(`.${f} .wui-check`);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&D.add(e.dataset.rowKey))}Z()},clear:()=>{O=!1,D.clear();for(let e of M.querySelectorAll(`:scope > tr > .${f} .wui-check:not(:disabled)`))e.checked=!1;Z()}}}}var j=8e3,M=Object.freeze([`POST`,`PUT`,`PATCH`,`DELETE`]),N=`That did not work. Try again.`,P=t=>(e(`[@webority/ui-elements] Wui-Toast-Action: ${t}; the toast shows no action.`),null);function F(e){if(e==null||e===``)return null;let t;try{t=JSON.parse(e)}catch{return P(`the value is not JSON`)}let n=t?.label,r=t?.url,i=String(t?.method??`POST`).toUpperCase();return typeof n!=`string`||n===``||typeof r!=`string`||r===``?P(`label and url must be non-empty strings`):M.includes(i)?{label:n,url:r,method:i}:P(`method must be one of ${M.join(`, `)}`)}function I(e,t=`success`){if(!e?.message)return;let n=e.toastAction;if(!n){window.WUI?.toast?.(e.message,{variant:t});return}window.WUI?.toast?.(e.message,{variant:t,duration:j,action:{label:n.label,onClick:()=>L(n)}})}async function L(e){let t=await q(e.url,{method:e.method});if(!(t.kind===`session`||t.kind===`aborted`)){if(t.ok){I(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e.dataset.refreshOnSuccess!==`false`&&k(e)?.reload();return}window.WUI?.toast?.(t.message||N,{variant:`danger`})}}var R=`wui-csrf`,z=`RequestVerificationToken`,se=`Wui-Request`,B=Object.freeze({fragment:`Wui-Fragment`,message:`Wui-Message`,redirect:`Wui-Redirect`,result:`Wui-Result`,keepOpen:`Wui-Keep-Open`,toastVariant:`Wui-Toast-Variant`,toastAction:`Wui-Toast-Action`,data:`Wui-Data`,next:`Wui-Next`}),V=Object.freeze([`ok`,`validation`,`forbidden`,`client`,`server`,`network`,`aborted`,`stale`,`session`]),H=new Set([`GET`,`HEAD`]);function U(e=document){let t=e.querySelector(`meta[name="${R}"]`),n=t?.getAttribute(`content`);return n?{header:t.getAttribute(`data-header`)||`RequestVerificationToken`,token:n}:null}var ce=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function W(e){return e>=200&&e<300?`ok`:e===401?`session`:e===403?`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var G=e=>e?.name===`AbortError`,K=e=>{if(e==null||e===``)return null;try{return JSON.parse(e)}catch{return t(`Wui-Data is not JSON; it was ignored.`),null}};async function q(e,t={}){let n=(t.method||`GET`).toUpperCase(),r=t.navigate||(e=>window.location.assign(e)),i={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,[se]:`1`,...t.headers};if(!H.has(n)&&ce(e)){let e=U();e&&(i[e.header]=e.token)}let a=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},o=(e,t=null,n=``)=>{let r=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:n,response:t,message:a(r(B.message)),redirect:r(B.redirect),result:r(B.result),keepOpen:r(B.keepOpen)===`1`,toastVariant:r(B.toastVariant),toastAction:F(r(B.toastAction)),fragment:r(B.fragment)===`1`,data:K(a(r(B.data))),next:r(B.next)}},s;try{s=await fetch(e,{method:n,body:t.body,headers:i,signal:t.signal,credentials:`same-origin`})}catch(e){return o(G(e)||t.signal?.aborted?`aborted`:`network`)}let c=W(s.status);if(c===`ok`&&s.redirected&&s.headers.get(B.fragment)!==`1`&&(c=`session`),c===`session`)return r(s.status===401?s.headers.get(`Location`)||window.location.href:s.url),o(c,s);let l=``;if(c===`ok`||c===`validation`)try{l=await s.text()}catch(e){return o(G(e)||t.signal?.aborted?`aborted`:`network`,s)}return o(c,s,l)}function le(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s=await q(n,{...r,signal:i.signal});return e===i&&(e=null),a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{h as C,m as S,b as T,f as _,W as a,ee as b,q as c,F as d,L as f,u as g,O as h,B as i,M as l,k as m,z as n,le as o,I as p,V as r,U as s,R as t,j as u,d as v,g as w,te as x,y};
|