@usefragments/ui 1.3.3 → 1.4.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/assets/ui.css +1176 -766
- package/dist/chart.cjs +60 -24
- package/dist/chart.js +38 -24
- package/dist/colorpicker.cjs +56 -9
- package/dist/colorpicker.js +34 -9
- package/dist/components/Badge/Badge.module.scss.cjs +23 -16
- package/dist/components/Badge/Badge.module.scss.js +23 -16
- package/dist/components/Badge/index.cjs +8 -1
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +8 -1
- package/dist/components/Button/Button.module.scss.cjs +16 -13
- package/dist/components/Button/Button.module.scss.js +16 -13
- package/dist/components/Button/index.d.ts +2 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Chart/index.d.ts +3 -0
- package/dist/components/Chart/index.d.ts.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.module.scss.cjs +21 -21
- package/dist/components/CodeBlock/CodeBlock.module.scss.js +21 -21
- package/dist/components/ColorPicker/index.d.ts +4 -0
- package/dist/components/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/Combobox/Combobox.module.scss.cjs +23 -23
- package/dist/components/Combobox/Combobox.module.scss.js +23 -23
- package/dist/components/Command/Command.module.scss.cjs +11 -11
- package/dist/components/Command/Command.module.scss.js +11 -11
- package/dist/components/ConversationList/ConversationList.module.scss.cjs +13 -10
- package/dist/components/ConversationList/ConversationList.module.scss.js +14 -11
- package/dist/components/ConversationList/index.cjs +26 -22
- package/dist/components/ConversationList/index.d.ts +5 -1
- package/dist/components/ConversationList/index.d.ts.map +1 -1
- package/dist/components/ConversationList/index.js +27 -23
- package/dist/components/DataTable/index.d.ts +4 -1
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.d.ts +3 -0
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/Editor/index.d.ts +4 -1
- package/dist/components/Editor/index.d.ts.map +1 -1
- package/dist/components/Listbox/Listbox.module.scss.cjs +8 -8
- package/dist/components/Listbox/Listbox.module.scss.js +8 -8
- package/dist/components/Markdown/Markdown.module.scss.cjs +1 -1
- package/dist/components/Markdown/Markdown.module.scss.js +1 -1
- package/dist/components/Markdown/index.d.ts +16 -0
- package/dist/components/Markdown/index.d.ts.map +1 -1
- package/dist/components/Menu/Menu.module.scss.cjs +14 -14
- package/dist/components/Menu/Menu.module.scss.js +14 -14
- package/dist/components/Message/Message.module.scss.cjs +23 -20
- package/dist/components/Message/Message.module.scss.js +24 -21
- package/dist/components/Message/index.cjs +5 -1
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +5 -1
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.cjs +28 -28
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.js +28 -28
- package/dist/components/Pagination/Pagination.module.scss.cjs +7 -7
- package/dist/components/Pagination/Pagination.module.scss.js +7 -7
- package/dist/components/Prompt/Prompt.module.scss.cjs +52 -22
- package/dist/components/Prompt/Prompt.module.scss.js +52 -22
- package/dist/components/Prompt/index.cjs +197 -2
- package/dist/components/Prompt/index.d.ts +98 -3
- package/dist/components/Prompt/index.d.ts.map +1 -1
- package/dist/components/Prompt/index.js +198 -3
- package/dist/components/Select/Select.module.scss.cjs +29 -17
- package/dist/components/Select/Select.module.scss.js +30 -18
- package/dist/components/Select/index.cjs +45 -8
- package/dist/components/Select/index.d.ts +17 -2
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +45 -8
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +45 -42
- package/dist/components/Sidebar/Sidebar.module.scss.js +45 -42
- package/dist/components/Sidebar/index.cjs +2 -0
- package/dist/components/Sidebar/index.d.ts +6 -1
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +2 -0
- package/dist/components/Text/Text.module.scss.cjs +63 -51
- package/dist/components/Text/Text.module.scss.js +63 -51
- package/dist/components/Text/index.d.ts +4 -2
- package/dist/components/Text/index.d.ts.map +1 -1
- package/dist/data-table.cjs +210 -28
- package/dist/data-table.js +189 -29
- package/dist/datepicker.cjs +63 -14
- package/dist/datepicker.js +41 -14
- package/dist/editor.cjs +67 -16
- package/dist/editor.js +45 -16
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/markdown.cjs +63 -19
- package/dist/markdown.js +41 -19
- package/fragments.json +1 -1
- package/package.json +2 -2
- package/src/components/Badge/Badge.contract.json +28 -5
- package/src/components/Badge/Badge.module.scss +21 -0
- package/src/components/Badge/index.tsx +10 -1
- package/src/components/Button/Button.contract.json +9 -3
- package/src/components/Button/Button.module.scss +34 -0
- package/src/components/Button/index.tsx +11 -1
- package/src/components/Chart/Chart.contract.json +7 -0
- package/src/components/Chart/index.tsx +44 -27
- package/src/components/CodeBlock/CodeBlock.contract.json +7 -0
- package/src/components/CodeBlock/CodeBlock.module.scss +7 -2
- package/src/components/ColorPicker/ColorPicker.contract.json +9 -1
- package/src/components/ColorPicker/index.tsx +42 -12
- package/src/components/Combobox/Combobox.module.scss +4 -13
- package/src/components/ConversationList/ConversationList.contract.json +16 -1
- package/src/components/ConversationList/ConversationList.module.scss +12 -0
- package/src/components/ConversationList/index.tsx +40 -26
- package/src/components/DataTable/DataTable.contract.json +8 -1
- package/src/components/DataTable/index.tsx +282 -51
- package/src/components/DatePicker/DatePicker.contract.json +8 -1
- package/src/components/DatePicker/index.tsx +51 -22
- package/src/components/Editor/Editor.contract.json +19 -1
- package/src/components/Editor/index.tsx +67 -23
- package/src/components/Listbox/Listbox.module.scss +3 -11
- package/src/components/Markdown/Markdown.contract.json +15 -1
- package/src/components/Markdown/Markdown.module.scss +18 -1
- package/src/components/Markdown/index.tsx +58 -24
- package/src/components/Menu/Menu.module.scss +12 -2
- package/src/components/Message/Message.contract.json +3 -0
- package/src/components/Message/Message.module.scss +33 -4
- package/src/components/Message/index.tsx +7 -1
- package/src/components/Pagination/Pagination.contract.json +1 -0
- package/src/components/Pagination/Pagination.module.scss +5 -4
- package/src/components/Prompt/Prompt.contract.json +40 -1
- package/src/components/Prompt/Prompt.module.scss +351 -4
- package/src/components/Prompt/index.tsx +324 -0
- package/src/components/Select/Select.contract.json +11 -1
- package/src/components/Select/Select.module.scss +80 -13
- package/src/components/Select/index.tsx +73 -7
- package/src/components/Sidebar/Sidebar.contract.json +1 -0
- package/src/components/Sidebar/Sidebar.module.scss +10 -0
- package/src/components/Sidebar/index.tsx +7 -0
- package/src/components/Text/Text.contract.json +7 -4
- package/src/components/Text/Text.module.scss +18 -0
- package/src/components/Text/index.tsx +4 -2
- package/src/index.ts +1 -0
- package/src/tokens/_mixins.scss +39 -4
- package/src/tokens/_variables.scss +30 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const pagination = "
|
|
4
|
-
const list = "
|
|
5
|
-
const item = "
|
|
6
|
-
const itemActive = "
|
|
7
|
-
const itemDisabled = "
|
|
8
|
-
const navButton = "
|
|
9
|
-
const ellipsis = "
|
|
3
|
+
const pagination = "_pagination_lk556_1";
|
|
4
|
+
const list = "_list_lk556_7";
|
|
5
|
+
const item = "_item_lk556_16";
|
|
6
|
+
const itemActive = "_itemActive_lk556_57";
|
|
7
|
+
const itemDisabled = "_itemDisabled_lk556_66";
|
|
8
|
+
const navButton = "_navButton_lk556_72";
|
|
9
|
+
const ellipsis = "_ellipsis_lk556_77";
|
|
10
10
|
const styles = {
|
|
11
11
|
pagination,
|
|
12
12
|
list,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const pagination = "
|
|
2
|
-
const list = "
|
|
3
|
-
const item = "
|
|
4
|
-
const itemActive = "
|
|
5
|
-
const itemDisabled = "
|
|
6
|
-
const navButton = "
|
|
7
|
-
const ellipsis = "
|
|
1
|
+
const pagination = "_pagination_lk556_1";
|
|
2
|
+
const list = "_list_lk556_7";
|
|
3
|
+
const item = "_item_lk556_16";
|
|
4
|
+
const itemActive = "_itemActive_lk556_57";
|
|
5
|
+
const itemDisabled = "_itemDisabled_lk556_66";
|
|
6
|
+
const navButton = "_navButton_lk556_72";
|
|
7
|
+
const ellipsis = "_ellipsis_lk556_77";
|
|
8
8
|
const styles = {
|
|
9
9
|
pagination,
|
|
10
10
|
list,
|
|
@@ -1,51 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const prompt = "
|
|
4
|
-
const fixed = "
|
|
5
|
-
const sticky = "
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
3
|
+
const prompt = "_prompt_1wo4v_1";
|
|
4
|
+
const fixed = "_fixed_1wo4v_60";
|
|
5
|
+
const sticky = "_sticky_1wo4v_71";
|
|
6
|
+
const seamless = "_seamless_1wo4v_86";
|
|
7
|
+
const toolbar = "_toolbar_1wo4v_102";
|
|
8
|
+
const textarea = "_textarea_1wo4v_107";
|
|
9
|
+
const attachments = "_attachments_1wo4v_110";
|
|
10
|
+
const tabs = "_tabs_1wo4v_115";
|
|
11
|
+
const tabsInner = "_tabsInner_1wo4v_123";
|
|
12
|
+
const attach = "_attach_1wo4v_110";
|
|
13
|
+
const select = "_select_1wo4v_141";
|
|
14
|
+
const modeButton = "_modeButton_1wo4v_142";
|
|
15
|
+
const submit = "_submit_1wo4v_173";
|
|
16
|
+
const actionButton = "_actionButton_1wo4v_174";
|
|
17
|
+
const tabButton = "_tabButton_1wo4v_246";
|
|
18
|
+
const tabButtonActive = "_tabButtonActive_1wo4v_275";
|
|
19
|
+
const actions = "_actions_1wo4v_290";
|
|
20
|
+
const info = "_info_1wo4v_297";
|
|
21
|
+
const modeButtonActive = "_modeButtonActive_1wo4v_393";
|
|
22
|
+
const attachment = "_attachment_1wo4v_110";
|
|
23
|
+
const attachmentThumb = "_attachmentThumb_1wo4v_473";
|
|
24
|
+
const attachmentName = "_attachmentName_1wo4v_481";
|
|
25
|
+
const attachmentSize = "_attachmentSize_1wo4v_489";
|
|
26
|
+
const attachmentRemove = "_attachmentRemove_1wo4v_495";
|
|
27
|
+
const dragging = "_dragging_1wo4v_539";
|
|
28
|
+
const usage = "_usage_1wo4v_547";
|
|
29
|
+
const submitLoading = "_submitLoading_1wo4v_603";
|
|
30
|
+
const submitSpinner = "_submitSpinner_1wo4v_607";
|
|
21
31
|
const styles = {
|
|
22
32
|
prompt,
|
|
23
33
|
fixed,
|
|
24
34
|
sticky,
|
|
35
|
+
seamless,
|
|
36
|
+
toolbar,
|
|
25
37
|
textarea,
|
|
38
|
+
attachments,
|
|
26
39
|
tabs,
|
|
27
40
|
tabsInner,
|
|
41
|
+
attach,
|
|
42
|
+
select,
|
|
43
|
+
modeButton,
|
|
44
|
+
submit,
|
|
45
|
+
actionButton,
|
|
28
46
|
tabButton,
|
|
29
47
|
tabButtonActive,
|
|
30
|
-
toolbar,
|
|
31
48
|
actions,
|
|
32
49
|
info,
|
|
33
|
-
actionButton,
|
|
34
|
-
modeButton,
|
|
35
50
|
modeButtonActive,
|
|
51
|
+
attachment,
|
|
52
|
+
attachmentThumb,
|
|
53
|
+
attachmentName,
|
|
54
|
+
attachmentSize,
|
|
55
|
+
attachmentRemove,
|
|
56
|
+
dragging,
|
|
36
57
|
usage,
|
|
37
|
-
submit,
|
|
38
58
|
submitLoading,
|
|
39
59
|
submitSpinner
|
|
40
60
|
};
|
|
41
61
|
exports.actionButton = actionButton;
|
|
42
62
|
exports.actions = actions;
|
|
63
|
+
exports.attach = attach;
|
|
64
|
+
exports.attachment = attachment;
|
|
65
|
+
exports.attachmentName = attachmentName;
|
|
66
|
+
exports.attachmentRemove = attachmentRemove;
|
|
67
|
+
exports.attachmentSize = attachmentSize;
|
|
68
|
+
exports.attachmentThumb = attachmentThumb;
|
|
69
|
+
exports.attachments = attachments;
|
|
43
70
|
exports.default = styles;
|
|
71
|
+
exports.dragging = dragging;
|
|
44
72
|
exports.fixed = fixed;
|
|
45
73
|
exports.info = info;
|
|
46
74
|
exports.modeButton = modeButton;
|
|
47
75
|
exports.modeButtonActive = modeButtonActive;
|
|
48
76
|
exports.prompt = prompt;
|
|
77
|
+
exports.seamless = seamless;
|
|
78
|
+
exports.select = select;
|
|
49
79
|
exports.sticky = sticky;
|
|
50
80
|
exports.submit = submit;
|
|
51
81
|
exports.submitLoading = submitLoading;
|
|
@@ -1,50 +1,80 @@
|
|
|
1
|
-
const prompt = "
|
|
2
|
-
const fixed = "
|
|
3
|
-
const sticky = "
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
1
|
+
const prompt = "_prompt_1wo4v_1";
|
|
2
|
+
const fixed = "_fixed_1wo4v_60";
|
|
3
|
+
const sticky = "_sticky_1wo4v_71";
|
|
4
|
+
const seamless = "_seamless_1wo4v_86";
|
|
5
|
+
const toolbar = "_toolbar_1wo4v_102";
|
|
6
|
+
const textarea = "_textarea_1wo4v_107";
|
|
7
|
+
const attachments = "_attachments_1wo4v_110";
|
|
8
|
+
const tabs = "_tabs_1wo4v_115";
|
|
9
|
+
const tabsInner = "_tabsInner_1wo4v_123";
|
|
10
|
+
const attach = "_attach_1wo4v_110";
|
|
11
|
+
const select = "_select_1wo4v_141";
|
|
12
|
+
const modeButton = "_modeButton_1wo4v_142";
|
|
13
|
+
const submit = "_submit_1wo4v_173";
|
|
14
|
+
const actionButton = "_actionButton_1wo4v_174";
|
|
15
|
+
const tabButton = "_tabButton_1wo4v_246";
|
|
16
|
+
const tabButtonActive = "_tabButtonActive_1wo4v_275";
|
|
17
|
+
const actions = "_actions_1wo4v_290";
|
|
18
|
+
const info = "_info_1wo4v_297";
|
|
19
|
+
const modeButtonActive = "_modeButtonActive_1wo4v_393";
|
|
20
|
+
const attachment = "_attachment_1wo4v_110";
|
|
21
|
+
const attachmentThumb = "_attachmentThumb_1wo4v_473";
|
|
22
|
+
const attachmentName = "_attachmentName_1wo4v_481";
|
|
23
|
+
const attachmentSize = "_attachmentSize_1wo4v_489";
|
|
24
|
+
const attachmentRemove = "_attachmentRemove_1wo4v_495";
|
|
25
|
+
const dragging = "_dragging_1wo4v_539";
|
|
26
|
+
const usage = "_usage_1wo4v_547";
|
|
27
|
+
const submitLoading = "_submitLoading_1wo4v_603";
|
|
28
|
+
const submitSpinner = "_submitSpinner_1wo4v_607";
|
|
19
29
|
const styles = {
|
|
20
30
|
prompt,
|
|
21
31
|
fixed,
|
|
22
32
|
sticky,
|
|
33
|
+
seamless,
|
|
34
|
+
toolbar,
|
|
23
35
|
textarea,
|
|
36
|
+
attachments,
|
|
24
37
|
tabs,
|
|
25
38
|
tabsInner,
|
|
39
|
+
attach,
|
|
40
|
+
select,
|
|
41
|
+
modeButton,
|
|
42
|
+
submit,
|
|
43
|
+
actionButton,
|
|
26
44
|
tabButton,
|
|
27
45
|
tabButtonActive,
|
|
28
|
-
toolbar,
|
|
29
46
|
actions,
|
|
30
47
|
info,
|
|
31
|
-
actionButton,
|
|
32
|
-
modeButton,
|
|
33
48
|
modeButtonActive,
|
|
49
|
+
attachment,
|
|
50
|
+
attachmentThumb,
|
|
51
|
+
attachmentName,
|
|
52
|
+
attachmentSize,
|
|
53
|
+
attachmentRemove,
|
|
54
|
+
dragging,
|
|
34
55
|
usage,
|
|
35
|
-
submit,
|
|
36
56
|
submitLoading,
|
|
37
57
|
submitSpinner
|
|
38
58
|
};
|
|
39
59
|
export {
|
|
40
60
|
actionButton,
|
|
41
61
|
actions,
|
|
62
|
+
attach,
|
|
63
|
+
attachment,
|
|
64
|
+
attachmentName,
|
|
65
|
+
attachmentRemove,
|
|
66
|
+
attachmentSize,
|
|
67
|
+
attachmentThumb,
|
|
68
|
+
attachments,
|
|
42
69
|
styles as default,
|
|
70
|
+
dragging,
|
|
43
71
|
fixed,
|
|
44
72
|
info,
|
|
45
73
|
modeButton,
|
|
46
74
|
modeButtonActive,
|
|
47
75
|
prompt,
|
|
76
|
+
seamless,
|
|
77
|
+
select,
|
|
48
78
|
sticky,
|
|
49
79
|
submit,
|
|
50
80
|
submitLoading,
|
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const Prompt_module = require("./Prompt.module.scss.cjs");
|
|
7
7
|
const index = require("../Loading/index.cjs");
|
|
8
|
+
const index$1 = require("../Select/index.cjs");
|
|
8
9
|
function _interopNamespaceDefault(e) {
|
|
9
10
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
11
|
if (e) {
|
|
@@ -22,6 +23,34 @@ function _interopNamespaceDefault(e) {
|
|
|
22
23
|
return Object.freeze(n);
|
|
23
24
|
}
|
|
24
25
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
+
function PlusIcon() {
|
|
27
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
28
|
+
"svg",
|
|
29
|
+
{
|
|
30
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
31
|
+
width: "16",
|
|
32
|
+
height: "16",
|
|
33
|
+
viewBox: "0 0 256 256",
|
|
34
|
+
fill: "currentColor",
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z" })
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function CloseIcon() {
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
"svg",
|
|
43
|
+
{
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
width: "16",
|
|
46
|
+
height: "16",
|
|
47
|
+
viewBox: "0 0 256 256",
|
|
48
|
+
fill: "currentColor",
|
|
49
|
+
"aria-hidden": "true",
|
|
50
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z" })
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
25
54
|
function ArrowUpIcon() {
|
|
26
55
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
56
|
"svg",
|
|
@@ -73,10 +102,15 @@ function PromptRoot({
|
|
|
73
102
|
autoResize = true,
|
|
74
103
|
submitOnEnter = true,
|
|
75
104
|
variant = "default",
|
|
105
|
+
appearance = "panel",
|
|
106
|
+
onFiles,
|
|
107
|
+
accept,
|
|
76
108
|
className,
|
|
77
109
|
...htmlProps
|
|
78
110
|
}) {
|
|
79
111
|
const textareaRef = React__namespace.useRef(null);
|
|
112
|
+
const [dragging, setDragging] = React__namespace.useState(false);
|
|
113
|
+
const dragDepth = React__namespace.useRef(0);
|
|
80
114
|
const [value, setValue] = useControllableState(
|
|
81
115
|
controlledValue,
|
|
82
116
|
defaultValue,
|
|
@@ -86,6 +120,13 @@ function PromptRoot({
|
|
|
86
120
|
if (disabled || loading || !value.trim()) return;
|
|
87
121
|
onSubmit == null ? void 0 : onSubmit(value);
|
|
88
122
|
}, [disabled, loading, value, onSubmit]);
|
|
123
|
+
const acceptFiles = React__namespace.useCallback(
|
|
124
|
+
(files) => {
|
|
125
|
+
if (!onFiles || disabled || loading || files.length === 0) return;
|
|
126
|
+
onFiles(files);
|
|
127
|
+
},
|
|
128
|
+
[onFiles, disabled, loading]
|
|
129
|
+
);
|
|
89
130
|
const contextValue = {
|
|
90
131
|
value,
|
|
91
132
|
setValue,
|
|
@@ -97,12 +138,39 @@ function PromptRoot({
|
|
|
97
138
|
autoResize,
|
|
98
139
|
submitOnEnter,
|
|
99
140
|
handleSubmit,
|
|
100
|
-
textareaRef
|
|
141
|
+
textareaRef,
|
|
142
|
+
accept,
|
|
143
|
+
onFiles: onFiles ? acceptFiles : void 0
|
|
101
144
|
};
|
|
145
|
+
const dropHandlers = onFiles ? {
|
|
146
|
+
onDragEnter: (event) => {
|
|
147
|
+
if (!event.dataTransfer.types.includes("Files")) return;
|
|
148
|
+
dragDepth.current += 1;
|
|
149
|
+
setDragging(true);
|
|
150
|
+
},
|
|
151
|
+
onDragOver: (event) => {
|
|
152
|
+
if (!event.dataTransfer.types.includes("Files")) return;
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
event.dataTransfer.dropEffect = "copy";
|
|
155
|
+
},
|
|
156
|
+
onDragLeave: () => {
|
|
157
|
+
dragDepth.current = Math.max(0, dragDepth.current - 1);
|
|
158
|
+
if (dragDepth.current === 0) setDragging(false);
|
|
159
|
+
},
|
|
160
|
+
onDrop: (event) => {
|
|
161
|
+
if (!event.dataTransfer.types.includes("Files")) return;
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
dragDepth.current = 0;
|
|
164
|
+
setDragging(false);
|
|
165
|
+
acceptFiles(Array.from(event.dataTransfer.files));
|
|
166
|
+
}
|
|
167
|
+
} : null;
|
|
102
168
|
const classes = [
|
|
103
169
|
Prompt_module.default.prompt,
|
|
104
170
|
variant === "fixed" && Prompt_module.default.fixed,
|
|
105
171
|
variant === "sticky" && Prompt_module.default.sticky,
|
|
172
|
+
appearance === "seamless" && Prompt_module.default.seamless,
|
|
173
|
+
dragging && Prompt_module.default.dragging,
|
|
106
174
|
disabled && Prompt_module.default.disabled,
|
|
107
175
|
loading && Prompt_module.default.loading,
|
|
108
176
|
className
|
|
@@ -111,10 +179,13 @@ function PromptRoot({
|
|
|
111
179
|
"div",
|
|
112
180
|
{
|
|
113
181
|
...htmlProps,
|
|
182
|
+
...dropHandlers,
|
|
114
183
|
className: classes,
|
|
115
184
|
"data-disabled": disabled || void 0,
|
|
116
185
|
"data-loading": loading || void 0,
|
|
117
186
|
"data-variant": variant,
|
|
187
|
+
"data-appearance": appearance,
|
|
188
|
+
"data-dragging": dragging || void 0,
|
|
118
189
|
children
|
|
119
190
|
}
|
|
120
191
|
) });
|
|
@@ -124,6 +195,7 @@ function PromptTextarea({
|
|
|
124
195
|
className,
|
|
125
196
|
onChange,
|
|
126
197
|
onKeyDown,
|
|
198
|
+
onPaste,
|
|
127
199
|
"aria-label": ariaLabel,
|
|
128
200
|
...htmlProps
|
|
129
201
|
}) {
|
|
@@ -138,7 +210,8 @@ function PromptTextarea({
|
|
|
138
210
|
autoResize,
|
|
139
211
|
submitOnEnter,
|
|
140
212
|
handleSubmit,
|
|
141
|
-
textareaRef
|
|
213
|
+
textareaRef,
|
|
214
|
+
onFiles
|
|
142
215
|
} = usePromptContext();
|
|
143
216
|
const lineHeight = 1.5;
|
|
144
217
|
const padding = 12;
|
|
@@ -169,6 +242,20 @@ function PromptTextarea({
|
|
|
169
242
|
handleSubmit();
|
|
170
243
|
}
|
|
171
244
|
};
|
|
245
|
+
const handlePaste = (e) => {
|
|
246
|
+
onPaste == null ? void 0 : onPaste(e);
|
|
247
|
+
if (e.defaultPrevented || !onFiles) return;
|
|
248
|
+
const files = Array.from(e.clipboardData.files);
|
|
249
|
+
if (files.length === 0) return;
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
onFiles(
|
|
252
|
+
files.map(
|
|
253
|
+
(file, index2) => file.name && file.name !== "image.png" ? file : new File([file], `pasted-${index2 + 1}.${file.type.split("/")[1] || "png"}`, {
|
|
254
|
+
type: file.type
|
|
255
|
+
})
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
};
|
|
172
259
|
const classes = [Prompt_module.default.textarea, className].filter(Boolean).join(" ");
|
|
173
260
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
174
261
|
"textarea",
|
|
@@ -179,6 +266,7 @@ function PromptTextarea({
|
|
|
179
266
|
value,
|
|
180
267
|
onChange: handleChange,
|
|
181
268
|
onKeyDown: handleKeyDown,
|
|
269
|
+
onPaste: handlePaste,
|
|
182
270
|
placeholder: overridePlaceholder ?? placeholder,
|
|
183
271
|
disabled: disabled || loading,
|
|
184
272
|
rows: minRows,
|
|
@@ -259,6 +347,107 @@ function PromptModeButton({
|
|
|
259
347
|
}
|
|
260
348
|
);
|
|
261
349
|
}
|
|
350
|
+
function formatSize(bytes) {
|
|
351
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
352
|
+
const kb = bytes / 1024;
|
|
353
|
+
if (kb < 1024) return `${Math.round(kb)} KB`;
|
|
354
|
+
return `${(kb / 1024).toFixed(kb / 1024 < 10 ? 1 : 0)} MB`;
|
|
355
|
+
}
|
|
356
|
+
function PromptAttachments({ items, onRemove, className }) {
|
|
357
|
+
if (items.length === 0) return null;
|
|
358
|
+
const classes = [Prompt_module.default.attachments, className].filter(Boolean).join(" ");
|
|
359
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: classes, "aria-label": "Attachments", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: Prompt_module.default.attachment, children: [
|
|
360
|
+
item.previewUrl ? (
|
|
361
|
+
// Decorative: the filename beside it is the accessible name, and a
|
|
362
|
+
// thumbnail of a screenshot has no description worth inventing.
|
|
363
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: item.previewUrl, alt: "", className: Prompt_module.default.attachmentThumb })
|
|
364
|
+
) : null,
|
|
365
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: Prompt_module.default.attachmentName, title: item.name, children: item.name }),
|
|
366
|
+
item.size != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: Prompt_module.default.attachmentSize, children: formatSize(item.size) }),
|
|
367
|
+
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
368
|
+
"button",
|
|
369
|
+
{
|
|
370
|
+
type: "button",
|
|
371
|
+
className: Prompt_module.default.attachmentRemove,
|
|
372
|
+
onClick: () => onRemove(item.id),
|
|
373
|
+
"aria-label": `Remove ${item.name}`,
|
|
374
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
] }, item.id)) });
|
|
378
|
+
}
|
|
379
|
+
function PromptAttach({
|
|
380
|
+
"aria-label": ariaLabel = "Attach files",
|
|
381
|
+
children,
|
|
382
|
+
accept: acceptOverride,
|
|
383
|
+
multiple = true,
|
|
384
|
+
disabled: buttonDisabled,
|
|
385
|
+
className
|
|
386
|
+
}) {
|
|
387
|
+
const { disabled, loading, accept, onFiles } = usePromptContext();
|
|
388
|
+
const inputRef = React__namespace.useRef(null);
|
|
389
|
+
const isDisabled = disabled || loading || buttonDisabled || !onFiles;
|
|
390
|
+
const classes = [Prompt_module.default.attach, className].filter(Boolean).join(" ");
|
|
391
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
392
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
393
|
+
"button",
|
|
394
|
+
{
|
|
395
|
+
type: "button",
|
|
396
|
+
className: classes,
|
|
397
|
+
onClick: () => {
|
|
398
|
+
var _a;
|
|
399
|
+
return (_a = inputRef.current) == null ? void 0 : _a.click();
|
|
400
|
+
},
|
|
401
|
+
disabled: isDisabled,
|
|
402
|
+
"aria-label": ariaLabel,
|
|
403
|
+
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(PlusIcon, {})
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
407
|
+
"input",
|
|
408
|
+
{
|
|
409
|
+
ref: inputRef,
|
|
410
|
+
type: "file",
|
|
411
|
+
hidden: true,
|
|
412
|
+
accept: acceptOverride ?? accept,
|
|
413
|
+
multiple,
|
|
414
|
+
onChange: (event) => {
|
|
415
|
+
const files = Array.from(event.target.files ?? []);
|
|
416
|
+
event.target.value = "";
|
|
417
|
+
onFiles == null ? void 0 : onFiles(files);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
)
|
|
421
|
+
] });
|
|
422
|
+
}
|
|
423
|
+
function PromptSelect({
|
|
424
|
+
icon,
|
|
425
|
+
"aria-label": ariaLabel,
|
|
426
|
+
options,
|
|
427
|
+
children,
|
|
428
|
+
placeholder,
|
|
429
|
+
disabled: selectDisabled,
|
|
430
|
+
className,
|
|
431
|
+
...selectProps
|
|
432
|
+
}) {
|
|
433
|
+
const { disabled, loading } = usePromptContext();
|
|
434
|
+
const classes = [Prompt_module.default.select, className].filter(Boolean).join(" ");
|
|
435
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
436
|
+
index$1.Select,
|
|
437
|
+
{
|
|
438
|
+
...selectProps,
|
|
439
|
+
size: "sm",
|
|
440
|
+
variant: "ghost",
|
|
441
|
+
options,
|
|
442
|
+
placeholder,
|
|
443
|
+
disabled: disabled || loading || selectDisabled,
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ jsxRuntime.jsx(index$1.Select.Trigger, { className: classes, icon, "aria-label": ariaLabel }),
|
|
446
|
+
/* @__PURE__ */ jsxRuntime.jsx(index$1.Select.Content, { children })
|
|
447
|
+
]
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
}
|
|
262
451
|
function PromptUsage({ children, className }) {
|
|
263
452
|
const classes = [Prompt_module.default.usage, className].filter(Boolean).join(" ");
|
|
264
453
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: classes, children });
|
|
@@ -305,15 +494,21 @@ const Prompt = Object.assign(PromptRoot, {
|
|
|
305
494
|
Info: PromptInfo,
|
|
306
495
|
ActionButton: PromptActionButton,
|
|
307
496
|
ModeButton: PromptModeButton,
|
|
497
|
+
Select: PromptSelect,
|
|
498
|
+
Attach: PromptAttach,
|
|
499
|
+
Attachments: PromptAttachments,
|
|
308
500
|
Usage: PromptUsage,
|
|
309
501
|
Submit: PromptSubmit
|
|
310
502
|
});
|
|
311
503
|
exports.Prompt = Prompt;
|
|
312
504
|
exports.PromptActionButton = PromptActionButton;
|
|
313
505
|
exports.PromptActions = PromptActions;
|
|
506
|
+
exports.PromptAttach = PromptAttach;
|
|
507
|
+
exports.PromptAttachments = PromptAttachments;
|
|
314
508
|
exports.PromptInfo = PromptInfo;
|
|
315
509
|
exports.PromptModeButton = PromptModeButton;
|
|
316
510
|
exports.PromptRoot = PromptRoot;
|
|
511
|
+
exports.PromptSelect = PromptSelect;
|
|
317
512
|
exports.PromptSubmit = PromptSubmit;
|
|
318
513
|
exports.PromptTab = PromptTab;
|
|
319
514
|
exports.PromptTabs = PromptTabs;
|