@devalok/shilp-sutra 0.32.0 → 0.33.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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_chunks/date-time-picker.js +851 -0
  3. package/dist/_chunks/mention-suggestion.js +362 -0
  4. package/dist/_chunks/tiptap.js +11595 -7731
  5. package/dist/_chunks/use-calendar.js +115 -956
  6. package/dist/_chunks/vendor-client.js +1055 -894
  7. package/dist/composed/date-picker/index.js +9 -8
  8. package/dist/composed/emoji-picker.d.ts +8 -2
  9. package/dist/composed/emoji-picker.d.ts.map +1 -1
  10. package/dist/composed/emoji-picker.js +65 -56
  11. package/dist/composed/extensions/emoji-data.d.ts +35 -0
  12. package/dist/composed/extensions/emoji-data.d.ts.map +1 -0
  13. package/dist/composed/extensions/emoji-node.d.ts +11 -0
  14. package/dist/composed/extensions/emoji-node.d.ts.map +1 -0
  15. package/dist/composed/extensions/emoji-suggestion.d.ts +4 -6
  16. package/dist/composed/extensions/emoji-suggestion.d.ts.map +1 -1
  17. package/dist/composed/extensions/slash-command.d.ts +35 -0
  18. package/dist/composed/extensions/slash-command.d.ts.map +1 -0
  19. package/dist/composed/index.d.ts +7 -1
  20. package/dist/composed/index.d.ts.map +1 -1
  21. package/dist/composed/index.js +79 -70
  22. package/dist/composed/rich-chat-input/attachment-strip.d.ts +15 -0
  23. package/dist/composed/rich-chat-input/attachment-strip.d.ts.map +1 -0
  24. package/dist/composed/rich-chat-input/audio-player.d.ts +11 -0
  25. package/dist/composed/rich-chat-input/audio-player.d.ts.map +1 -0
  26. package/dist/composed/rich-chat-input/audio-waveform.d.ts +24 -0
  27. package/dist/composed/rich-chat-input/audio-waveform.d.ts.map +1 -0
  28. package/dist/composed/rich-chat-input/chat-toolbar.d.ts +51 -0
  29. package/dist/composed/rich-chat-input/chat-toolbar.d.ts.map +1 -0
  30. package/dist/composed/rich-chat-input/recording-overlay.d.ts +15 -0
  31. package/dist/composed/rich-chat-input/recording-overlay.d.ts.map +1 -0
  32. package/dist/composed/rich-chat-input/reply-banner.d.ts +8 -0
  33. package/dist/composed/rich-chat-input/reply-banner.d.ts.map +1 -0
  34. package/dist/composed/rich-chat-input/schedule-send.d.ts +22 -0
  35. package/dist/composed/rich-chat-input/schedule-send.d.ts.map +1 -0
  36. package/dist/composed/rich-chat-input/use-voice-recorder.d.ts +18 -0
  37. package/dist/composed/rich-chat-input/use-voice-recorder.d.ts.map +1 -0
  38. package/dist/composed/rich-chat-input.d.ts +91 -0
  39. package/dist/composed/rich-chat-input.d.ts.map +1 -0
  40. package/dist/composed/rich-chat-input.js +1861 -0
  41. package/dist/composed/rich-text-editor.d.ts +3 -0
  42. package/dist/composed/rich-text-editor.d.ts.map +1 -1
  43. package/dist/composed/rich-text-editor.js +278 -448
  44. package/dist/ui/button-group.d.ts +27 -37
  45. package/dist/ui/button-group.d.ts.map +1 -1
  46. package/dist/ui/button-group.js +95 -29
  47. package/dist/ui/button.d.ts.map +1 -1
  48. package/dist/ui/button.js +110 -106
  49. package/dist/ui/index.d.ts +1 -0
  50. package/dist/ui/index.d.ts.map +1 -1
  51. package/dist/ui/index.js +335 -333
  52. package/dist/ui/split-button.d.ts +45 -0
  53. package/dist/ui/split-button.d.ts.map +1 -0
  54. package/dist/ui/split-button.js +282 -0
  55. package/docs/components/composed/emoji-picker.md +9 -0
  56. package/docs/components/composed/rich-chat-input.md +88 -0
  57. package/docs/components/composed/rich-text-editor.md +5 -0
  58. package/docs/components/ui/button-group.md +9 -0
  59. package/docs/components/ui/button.md +4 -0
  60. package/docs/components/ui/split-button.md +41 -0
  61. package/llms-full.txt +157 -1
  62. package/llms.txt +22 -2
  63. package/package.json +30 -26
@@ -0,0 +1,362 @@
1
+ "use client";
2
+ import { jsx as i, jsxs as u } from "react/jsx-runtime";
3
+ import { N as v, R as w, m as N, f as g, g as $, h as S, j as R } from "./tiptap.js";
4
+ import { IconFile as I, IconDownload as A } from "@tabler/icons-react";
5
+ import { Icon as x } from "../ui/icon.js";
6
+ import * as d from "react";
7
+ import { createRoot as j } from "react-dom/client";
8
+ import { cn as k } from "../ui/lib/utils.js";
9
+ import { emojiDataLoaders as h } from "../composed/emoji-picker.js";
10
+ function L(e) {
11
+ return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
12
+ }
13
+ function z({ node: e }) {
14
+ const r = /^https?:\/\//.test(e.attrs.url) ? e.attrs.url : "#";
15
+ return /* @__PURE__ */ i(g, { className: "my-ds-02", children: /* @__PURE__ */ u(
16
+ "a",
17
+ {
18
+ href: r,
19
+ target: "_blank",
20
+ rel: "noopener noreferrer",
21
+ className: "inline-flex items-center gap-ds-03 rounded-ds-md border border-surface-border-strong bg-surface-raised px-ds-04 py-ds-03 text-ds-sm text-surface-fg transition-colors hover:border-surface-border-strong hover:bg-surface-raised-hover",
22
+ contentEditable: !1,
23
+ children: [
24
+ /* @__PURE__ */ i(x, { icon: I, size: "sm", className: "shrink-0 text-surface-fg-subtle" }),
25
+ /* @__PURE__ */ i("span", { className: "truncate", children: e.attrs.name }),
26
+ /* @__PURE__ */ u("span", { className: "shrink-0 text-surface-fg-subtle", children: [
27
+ "(",
28
+ L(e.attrs.size),
29
+ ")"
30
+ ] }),
31
+ /* @__PURE__ */ i(x, { icon: A, size: "sm", className: "shrink-0 text-surface-fg-subtle" })
32
+ ]
33
+ }
34
+ ) });
35
+ }
36
+ const O = v.create({
37
+ name: "fileAttachment",
38
+ group: "block",
39
+ atom: !0,
40
+ addAttributes() {
41
+ return {
42
+ url: { default: null },
43
+ name: { default: "Untitled" },
44
+ size: { default: 0 }
45
+ };
46
+ },
47
+ parseHTML() {
48
+ return [{ tag: "div[data-file-attachment]" }];
49
+ },
50
+ renderHTML({ HTMLAttributes: e }) {
51
+ return ["div", N({ "data-file-attachment": "" }, e)];
52
+ },
53
+ addNodeView() {
54
+ return w(z);
55
+ }
56
+ }), E = (e) => `https://cdn.jsdelivr.net/npm/emoji-datasource-${e}@15.0.1/img/${e}/sheets-256/64.png`, f = 61, m = 61;
57
+ let y = null, c = null;
58
+ async function D(e) {
59
+ if (y === e && c) return c;
60
+ const t = await (h[e] ?? h.native)();
61
+ return c = t.default ?? t, y = e, c;
62
+ }
63
+ function W(e, r) {
64
+ const t = e.emojis[r];
65
+ if (!t) return null;
66
+ const s = t.skins[0];
67
+ return s ? {
68
+ id: t.id,
69
+ name: t.name,
70
+ native: s.native,
71
+ x: s.x ?? 0,
72
+ y: s.y ?? 0
73
+ } : null;
74
+ }
75
+ function C(e, r, t = 8) {
76
+ const s = Object.values(e.emojis);
77
+ if (!r)
78
+ return s.slice(0, t).map((n) => ({
79
+ id: n.id,
80
+ name: n.name,
81
+ native: n.skins[0]?.native ?? "",
82
+ x: n.skins[0]?.x ?? 0,
83
+ y: n.skins[0]?.y ?? 0
84
+ }));
85
+ const a = r.toLowerCase(), o = [];
86
+ for (const n of s) {
87
+ if (o.length >= t) break;
88
+ (n.id.includes(a) || n.name.toLowerCase().includes(a) || n.keywords?.some((l) => l.includes(a))) && o.push({
89
+ id: n.id,
90
+ name: n.name,
91
+ native: n.skins[0]?.native ?? "",
92
+ x: n.skins[0]?.x ?? 0,
93
+ y: n.skins[0]?.y ?? 0
94
+ });
95
+ }
96
+ return o;
97
+ }
98
+ function H({ node: e }) {
99
+ const { native: r, set: t, x: s, y: a } = e.attrs;
100
+ if (t === "native")
101
+ return /* @__PURE__ */ i(g, { as: "span", className: "inline", children: /* @__PURE__ */ i("span", { children: r }) });
102
+ const o = `${100 * f}% ${100 * m}%`, n = `${100 / (f - 1) * s}% ${100 / (m - 1) * a}%`;
103
+ return /* @__PURE__ */ i(g, { as: "span", className: "inline", children: /* @__PURE__ */ i(
104
+ "span",
105
+ {
106
+ role: "img",
107
+ "aria-label": r,
108
+ className: "inline-block h-[1.2em] w-[1.2em] align-text-bottom",
109
+ style: {
110
+ backgroundImage: `url(${E(t)})`,
111
+ backgroundSize: o,
112
+ backgroundPosition: n
113
+ }
114
+ }
115
+ ) });
116
+ }
117
+ const q = v.create({
118
+ name: "emojiNode",
119
+ group: "inline",
120
+ inline: !0,
121
+ atom: !0,
122
+ selectable: !1,
123
+ addAttributes() {
124
+ return {
125
+ id: { default: null },
126
+ native: { default: null },
127
+ set: { default: "native" },
128
+ x: { default: 0 },
129
+ y: { default: 0 }
130
+ };
131
+ },
132
+ renderText({ node: e }) {
133
+ return e.attrs.native ?? "";
134
+ },
135
+ parseHTML() {
136
+ return [{
137
+ tag: "span[data-emoji-id]",
138
+ getAttrs: (e) => {
139
+ const r = e;
140
+ return {
141
+ id: r.getAttribute("data-emoji-id"),
142
+ set: r.getAttribute("data-emoji-set") ?? "native",
143
+ x: parseInt(r.getAttribute("data-emoji-x") ?? "0", 10),
144
+ y: parseInt(r.getAttribute("data-emoji-y") ?? "0", 10),
145
+ native: r.textContent ?? ""
146
+ };
147
+ }
148
+ }];
149
+ },
150
+ renderHTML({ node: e }) {
151
+ return ["span", {
152
+ "data-emoji-id": e.attrs.id,
153
+ "data-emoji-set": e.attrs.set,
154
+ "data-emoji-x": e.attrs.x,
155
+ "data-emoji-y": e.attrs.y,
156
+ role: "img",
157
+ "aria-label": e.attrs.native
158
+ }, e.attrs.native ?? ""];
159
+ },
160
+ addNodeView() {
161
+ return w(H);
162
+ }
163
+ });
164
+ function K({ emoji: e, set: r, size: t = "1.2em" }) {
165
+ return r === "native" ? /* @__PURE__ */ i("span", { style: { fontSize: t }, children: e.native }) : /* @__PURE__ */ i(
166
+ "span",
167
+ {
168
+ role: "img",
169
+ "aria-label": e.native,
170
+ className: "inline-block",
171
+ style: {
172
+ width: t,
173
+ height: t,
174
+ backgroundImage: `url(${E(r)})`,
175
+ backgroundSize: `${100 * f}% ${100 * m}%`,
176
+ backgroundPosition: `${100 / (f - 1) * e.x}% ${100 / (m - 1) * e.y}%`
177
+ }
178
+ }
179
+ );
180
+ }
181
+ const p = d.forwardRef(
182
+ ({ items: e, set: r, command: t }, s) => {
183
+ const [a, o] = d.useState(0);
184
+ return d.useEffect(() => o(0), [e]), d.useImperativeHandle(s, () => ({
185
+ onKeyDown: ({ event: n }) => n.key === "ArrowUp" ? (o((l) => (l + e.length - 1) % e.length), !0) : n.key === "ArrowDown" ? (o((l) => (l + 1) % e.length), !0) : n.key === "Enter" ? (e[a] && t(e[a]), !0) : !1
186
+ })), e.length ? /* @__PURE__ */ i("div", { role: "listbox", "aria-label": "Emoji suggestions", className: "z-popover max-h-[200px] overflow-x-hidden overflow-y-auto rounded-ds-md border border-surface-border-strong bg-surface-overlay shadow-raised-hover", children: e.map((n, l) => /* @__PURE__ */ u(
187
+ "button",
188
+ {
189
+ type: "button",
190
+ role: "option",
191
+ "aria-selected": l === a,
192
+ onClick: () => t(n),
193
+ className: k(
194
+ "flex w-full items-center gap-ds-03 px-ds-04 py-ds-02b text-left text-ds-sm",
195
+ l === a ? "bg-surface-raised text-surface-fg" : "text-surface-fg-muted hover:bg-surface-raised"
196
+ ),
197
+ children: [
198
+ /* @__PURE__ */ i(K, { emoji: n, set: r, size: "1.25em" }),
199
+ /* @__PURE__ */ u("span", { className: "truncate", children: [
200
+ ":",
201
+ n.id,
202
+ ":"
203
+ ] })
204
+ ]
205
+ },
206
+ n.id
207
+ )) }) : null;
208
+ }
209
+ );
210
+ p.displayName = "EmojiList";
211
+ function T(e) {
212
+ return () => {
213
+ let r = null, t = null, s = null;
214
+ return {
215
+ onStart: (a) => {
216
+ t = document.createElement("div"), t.style.position = "absolute", t.style.zIndex = "1400";
217
+ const o = a.clientRect?.();
218
+ o && (t.style.left = `${o.left}px`, t.style.top = `${o.bottom + 4}px`), document.body.appendChild(t), r = j(t), r.render(
219
+ /* @__PURE__ */ i(
220
+ p,
221
+ {
222
+ ref: (n) => {
223
+ s = n;
224
+ },
225
+ items: a.items,
226
+ set: e,
227
+ command: (n) => a.command(n)
228
+ }
229
+ )
230
+ );
231
+ },
232
+ onUpdate: (a) => {
233
+ if (!r || !t) return;
234
+ const o = a.clientRect?.();
235
+ o && (t.style.left = `${o.left}px`, t.style.top = `${o.bottom + 4}px`), r.render(
236
+ /* @__PURE__ */ i(
237
+ p,
238
+ {
239
+ ref: (n) => {
240
+ s = n;
241
+ },
242
+ items: a.items,
243
+ set: e,
244
+ command: (n) => a.command(n)
245
+ }
246
+ )
247
+ );
248
+ },
249
+ onKeyDown: (a) => a.event.key === "Escape" ? (t && (r?.unmount(), t.remove(), t = null, r = null), !0) : s?.onKeyDown(a) ?? !1,
250
+ onExit: () => {
251
+ t && (r?.unmount(), t.remove(), t = null, r = null);
252
+ }
253
+ };
254
+ };
255
+ }
256
+ function G(e = "native") {
257
+ return $.create({
258
+ name: "emojiSuggestion",
259
+ addProseMirrorPlugins() {
260
+ return [
261
+ S({
262
+ pluginKey: new R("emojiSuggestion"),
263
+ editor: this.editor,
264
+ char: ":",
265
+ items: async ({ query: r }) => {
266
+ const t = await D(e);
267
+ return C(t, r, 8);
268
+ },
269
+ command: ({ editor: r, range: t, props: s }) => {
270
+ const a = s;
271
+ r.chain().focus().deleteRange(t).insertContent({
272
+ type: "emojiNode",
273
+ attrs: { id: a.id, native: a.native, set: e, x: a.x, y: a.y }
274
+ }).run();
275
+ },
276
+ render: T(e)
277
+ })
278
+ ];
279
+ }
280
+ });
281
+ }
282
+ const b = d.forwardRef(
283
+ ({ items: e, command: r }, t) => {
284
+ const [s, a] = d.useState(0);
285
+ return d.useEffect(() => a(0), [e]), d.useImperativeHandle(t, () => ({
286
+ onKeyDown: ({ event: o }) => o.key === "ArrowUp" ? (a((n) => (n + e.length - 1) % e.length), !0) : o.key === "ArrowDown" ? (a((n) => (n + 1) % e.length), !0) : o.key === "Enter" ? (e[s] && r(e[s]), !0) : !1
287
+ })), e.length ? /* @__PURE__ */ i("div", { role: "listbox", "aria-label": "Mention suggestions", className: "z-popover overflow-hidden rounded-ds-md border border-surface-border-strong bg-surface-overlay shadow-raised-hover", children: e.map((o, n) => /* @__PURE__ */ u(
288
+ "button",
289
+ {
290
+ type: "button",
291
+ role: "option",
292
+ "aria-selected": n === s,
293
+ onClick: () => r(o),
294
+ className: k(
295
+ "flex w-full items-center gap-ds-03 px-ds-04 py-ds-02b text-left text-ds-sm",
296
+ n === s ? "bg-surface-raised text-surface-fg" : "text-surface-fg-muted hover:bg-surface-raised"
297
+ ),
298
+ children: [
299
+ o.avatar ? /* @__PURE__ */ i("img", { src: o.avatar, alt: "", className: "h-ico-md w-ico-md rounded-ds-full object-cover" }) : /* @__PURE__ */ i("span", { className: "flex h-ico-md w-ico-md items-center justify-center rounded-ds-full bg-accent-2 text-[10px] font-semibold text-accent-11", children: o.label.charAt(0).toUpperCase() }),
300
+ /* @__PURE__ */ i("span", { children: o.label })
301
+ ]
302
+ },
303
+ o.id
304
+ )) }) : null;
305
+ }
306
+ );
307
+ b.displayName = "MentionList";
308
+ function J(e) {
309
+ return () => {
310
+ let r = null, t = null, s = null;
311
+ return {
312
+ onStart: (a) => {
313
+ t = document.createElement("div"), t.style.position = "absolute", t.style.zIndex = "1400";
314
+ const o = a.clientRect?.();
315
+ o && (t.style.left = `${o.left}px`, t.style.top = `${o.bottom + 4}px`), document.body.appendChild(t), r = j(t), r.render(
316
+ /* @__PURE__ */ i(
317
+ b,
318
+ {
319
+ ref: (n) => {
320
+ s = n;
321
+ },
322
+ items: a.items,
323
+ command: (n) => {
324
+ a.command({ id: n.id, label: n.label }), e?.(n);
325
+ }
326
+ }
327
+ )
328
+ );
329
+ },
330
+ onUpdate: (a) => {
331
+ if (!r || !t) return;
332
+ const o = a.clientRect?.();
333
+ o && (t.style.left = `${o.left}px`, t.style.top = `${o.bottom + 4}px`), r.render(
334
+ /* @__PURE__ */ i(
335
+ b,
336
+ {
337
+ ref: (n) => {
338
+ s = n;
339
+ },
340
+ items: a.items,
341
+ command: (n) => {
342
+ a.command({ id: n.id, label: n.label }), e?.(n);
343
+ }
344
+ }
345
+ )
346
+ );
347
+ },
348
+ onKeyDown: (a) => a.event.key === "Escape" ? (t && (r?.unmount(), t.remove(), t = null, r = null), !0) : s?.onKeyDown(a) ?? !1,
349
+ onExit: () => {
350
+ t && (r?.unmount(), t.remove(), t = null, r = null);
351
+ }
352
+ };
353
+ };
354
+ }
355
+ export {
356
+ q as E,
357
+ O as F,
358
+ J as a,
359
+ W as b,
360
+ G as c,
361
+ D as l
362
+ };