@youcan/celeste 0.6.30 → 0.6.31
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/celeste.css +293 -74
- package/dist/cjs/alert.js +2 -2
- package/dist/cjs/chunks/index.js +229 -2
- package/dist/cjs/chunks/index2.js +1457 -0
- package/dist/cjs/chunks/index3.js +16457 -0
- package/dist/cjs/chunks/sonner.js +1153 -0
- package/dist/cjs/config.js +136 -0
- package/dist/cjs/extra-settings.js +155 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/label.js +2 -2
- package/dist/cjs/link-bubble.js +228 -0
- package/dist/cjs/link-button.js +2 -2
- package/dist/cjs/rich-editor.js +4996 -0
- package/dist/cjs/select-icon.js +2 -2
- package/dist/cjs/sonner-alert.js +41 -0
- package/dist/cjs/sonner.js +3 -0
- package/dist/cjs/text-input-affix.js +2 -2
- package/dist/cjs/types.js +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/rich-editor/config.d.ts +33 -0
- package/dist/components/rich-editor/extra-settings.d.ts +6 -0
- package/dist/components/rich-editor/index.d.ts +2 -0
- package/dist/components/rich-editor/link-bubble.d.ts +11 -0
- package/dist/components/rich-editor/rich-editor.d.ts +55 -0
- package/dist/components/rich-editor/types.d.ts +19 -0
- package/dist/components/sonner/index.d.ts +4 -0
- package/dist/components/sonner/sonner-alert.d.ts +13 -0
- package/dist/components/sonner/sonner.d.ts +5 -0
- package/dist/es/alert.js +2 -2
- package/dist/es/checkbox-label.js +1 -1
- package/dist/es/chunks/index.js +277 -50
- package/dist/es/chunks/index2.js +1457 -0
- package/dist/es/chunks/index3.js +16458 -0
- package/dist/es/chunks/sonner.js +1154 -0
- package/dist/es/combobox-group.js +1 -1
- package/dist/es/combobox-input.js +1 -1
- package/dist/es/combobox-item.js +1 -1
- package/dist/es/combobox-list.js +1 -1
- package/dist/es/combobox-root.js +1 -1
- package/dist/es/combobox-separator.js +1 -1
- package/dist/es/combobox-trigger.js +1 -1
- package/dist/es/command-group.js +1 -1
- package/dist/es/command-input.js +1 -1
- package/dist/es/command-item.js +1 -1
- package/dist/es/command-list.js +1 -1
- package/dist/es/command-root.js +1 -1
- package/dist/es/command-separator.js +1 -1
- package/dist/es/config.js +136 -0
- package/dist/es/dropdown-menu-group.js +1 -1
- package/dist/es/dropdown-menu-item.js +1 -1
- package/dist/es/dropdown-menu-label.js +1 -1
- package/dist/es/dropdown-menu-separator.js +1 -1
- package/dist/es/dropdown-menu-trigger.js +1 -1
- package/dist/es/dropdown-menu.js +1 -1
- package/dist/es/dropdown.js +1 -1
- package/dist/es/extra-settings.js +156 -0
- package/dist/es/index.js +27 -18
- package/dist/es/label.js +3 -3
- package/dist/es/link-bubble.js +229 -0
- package/dist/es/link-button.js +2 -2
- package/dist/es/modal-content.js +1 -1
- package/dist/es/modal-header.js +1 -1
- package/dist/es/popover-content.js +1 -1
- package/dist/es/popover-trigger.js +1 -1
- package/dist/es/rich-editor.js +4997 -0
- package/dist/es/scroll-bar.js +1 -1
- package/dist/es/segmented-control-item.js +1 -1
- package/dist/es/segmented-control.js +1 -1
- package/dist/es/select-content.js +1 -1
- package/dist/es/select-icon.js +2 -2
- package/dist/es/select-item.js +1 -1
- package/dist/es/select-trigger.js +1 -1
- package/dist/es/select-value.js +1 -1
- package/dist/es/sonner-alert.js +42 -0
- package/dist/es/sonner.js +4 -0
- package/dist/es/tab-menu-content.js +1 -1
- package/dist/es/tab-menu-item.js +1 -1
- package/dist/es/tab-menu-list.js +1 -1
- package/dist/es/tab-menu.js +1 -1
- package/dist/es/text-input-affix.js +2 -2
- package/dist/es/tooltip.js +1 -1
- package/dist/es/types.js +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/sonner.d.ts +19 -0
- package/package.json +15 -4
- package/src/components/index.ts +2 -0
- package/src/components/rich-editor/config.ts +150 -0
- package/src/components/rich-editor/extra-settings.vue +151 -0
- package/src/components/rich-editor/index.ts +2 -0
- package/src/components/rich-editor/link-bubble.vue +288 -0
- package/src/components/rich-editor/rich-editor.vue +428 -0
- package/src/components/rich-editor/stories/rich-editor.stories.ts +87 -0
- package/src/components/rich-editor/types.ts +21 -0
- package/src/components/sonner/index.ts +5 -0
- package/src/components/sonner/sonner-alert.vue +54 -0
- package/src/components/sonner/sonner.vue +13 -0
- package/src/components/sonner/stories/sonner.stories.ts +194 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/sonner.ts +72 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { defineComponent, defineAsyncComponent, ref, computed, onMounted, onUnmounted, openBlock, createBlock, unref, withCtx, createElementBlock, createElementVNode, createVNode, withKeys, createTextVNode, toDisplayString, createCommentVNode } from "vue";
|
|
2
|
+
import Button from "./button.js";
|
|
3
|
+
import CompactButton from "./compact-button.js";
|
|
4
|
+
import LinkButton from "./link-button.js";
|
|
5
|
+
import Label from "./label.js";
|
|
6
|
+
import { _ as _sfc_main$1 } from "./chunks/switch.vue_vue_type_style_index_0_lang.js";
|
|
7
|
+
import TextInputAffix from "./text-input-affix.js";
|
|
8
|
+
import TextInput from "./text-input.js";
|
|
9
|
+
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
10
|
+
const _hoisted_1 = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "set-mode"
|
|
13
|
+
};
|
|
14
|
+
const _hoisted_2 = { class: "set-link" };
|
|
15
|
+
const _hoisted_3 = { class: "switch-button-box" };
|
|
16
|
+
const _hoisted_4 = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "edit-mode"
|
|
19
|
+
};
|
|
20
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
21
|
+
__name: "link-bubble",
|
|
22
|
+
props: {
|
|
23
|
+
editor: {},
|
|
24
|
+
showSetLinkFromToolbar: { type: Boolean }
|
|
25
|
+
},
|
|
26
|
+
emits: ["set-link-closed"],
|
|
27
|
+
setup(__props, { emit: __emit }) {
|
|
28
|
+
const props = __props;
|
|
29
|
+
const emit = __emit;
|
|
30
|
+
const BubbleMenu = defineAsyncComponent(
|
|
31
|
+
() => import("./chunks/index2.js").then((m) => m.BubbleMenu)
|
|
32
|
+
);
|
|
33
|
+
const href = ref("");
|
|
34
|
+
const openInNewTab = ref(false);
|
|
35
|
+
const editing = ref(false);
|
|
36
|
+
const isTextSelected = () => props.editor.state.selection.from !== props.editor.state.selection.to;
|
|
37
|
+
const showBubble = computed(() => {
|
|
38
|
+
return editing.value || props.editor.isActive("link") || props.showSetLinkFromToolbar && isTextSelected();
|
|
39
|
+
});
|
|
40
|
+
function startEdit() {
|
|
41
|
+
editing.value = true;
|
|
42
|
+
const attrs = props.editor.getAttributes("link");
|
|
43
|
+
href.value = attrs.href || "";
|
|
44
|
+
openInNewTab.value = attrs.target === "_blank";
|
|
45
|
+
}
|
|
46
|
+
function removeLink() {
|
|
47
|
+
props.editor.chain().focus().unsetLink().run();
|
|
48
|
+
reset();
|
|
49
|
+
}
|
|
50
|
+
function reset() {
|
|
51
|
+
editing.value = false;
|
|
52
|
+
href.value = "";
|
|
53
|
+
openInNewTab.value = false;
|
|
54
|
+
emit("set-link-closed");
|
|
55
|
+
}
|
|
56
|
+
function truncateMiddleUrl(str) {
|
|
57
|
+
const maxLength = 40;
|
|
58
|
+
if (str.length <= maxLength) {
|
|
59
|
+
return str;
|
|
60
|
+
}
|
|
61
|
+
const startChars = Math.ceil((maxLength - 3) / 2);
|
|
62
|
+
const endChars = Math.floor((maxLength - 3) / 2);
|
|
63
|
+
return `${str.slice(0, startChars)}...${str.slice(-endChars)}`;
|
|
64
|
+
}
|
|
65
|
+
function isAllowedUri() {
|
|
66
|
+
const url = href.value.trim();
|
|
67
|
+
if (!url || url.includes(" ")) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (url.startsWith("/")) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (url.startsWith("./") || url.startsWith("../")) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const allowedProtocols = /^(?:https?:|mailto:)/i;
|
|
77
|
+
const disallowedProtocols = /^(?:javascript:|data:)/i;
|
|
78
|
+
if (disallowedProtocols.test(url)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (allowedProtocols.test(url)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
const isValidUrl = computed(() => isAllowedUri());
|
|
87
|
+
function applyLink() {
|
|
88
|
+
if (!href.value || !isValidUrl.value) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
props.editor.chain().focus().extendMarkRange("link").setLink({
|
|
92
|
+
href: href.value,
|
|
93
|
+
target: openInNewTab.value ? "_blank" : null
|
|
94
|
+
}).run();
|
|
95
|
+
reset();
|
|
96
|
+
}
|
|
97
|
+
const bubbleRef = ref(null);
|
|
98
|
+
function handleClickOutside(event) {
|
|
99
|
+
const target = event.target;
|
|
100
|
+
if (!bubbleRef.value) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (bubbleRef.value && bubbleRef.value.contains(target)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (target.closest(".i-celeste-link")) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
emit("set-link-closed");
|
|
110
|
+
}
|
|
111
|
+
onMounted(() => {
|
|
112
|
+
props.editor.on("selectionUpdate", () => {
|
|
113
|
+
if (props.editor.isActive("link") || props.showSetLinkFromToolbar) {
|
|
114
|
+
const attrs = props.editor.getAttributes("link");
|
|
115
|
+
href.value = attrs.href || "";
|
|
116
|
+
openInNewTab.value = attrs.target === "_blank";
|
|
117
|
+
} else {
|
|
118
|
+
reset();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
document.addEventListener("click", handleClickOutside);
|
|
122
|
+
});
|
|
123
|
+
onUnmounted(() => {
|
|
124
|
+
document.removeEventListener("click", handleClickOutside);
|
|
125
|
+
});
|
|
126
|
+
return (_ctx, _cache) => {
|
|
127
|
+
return openBlock(), createBlock(unref(BubbleMenu), {
|
|
128
|
+
"should-show": () => true,
|
|
129
|
+
editor: _ctx.editor,
|
|
130
|
+
options: {
|
|
131
|
+
placement: "bottom",
|
|
132
|
+
offset: {
|
|
133
|
+
mainAxis: 0,
|
|
134
|
+
crossAxis: 12
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
default: withCtx(() => [
|
|
139
|
+
showBubble.value ? (openBlock(), createElementBlock("div", {
|
|
140
|
+
key: 0,
|
|
141
|
+
ref_key: "bubbleRef",
|
|
142
|
+
ref: bubbleRef,
|
|
143
|
+
class: "link-bubble"
|
|
144
|
+
}, [
|
|
145
|
+
editing.value || props.showSetLinkFromToolbar && isTextSelected() ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
146
|
+
createElementVNode("div", _hoisted_2, [
|
|
147
|
+
createVNode(TextInput, {
|
|
148
|
+
modelValue: href.value,
|
|
149
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => href.value = $event),
|
|
150
|
+
type: "url",
|
|
151
|
+
size: "xs",
|
|
152
|
+
placeholder: "Paste or type a link",
|
|
153
|
+
class: "link-input",
|
|
154
|
+
onKeydown: [
|
|
155
|
+
withKeys(applyLink, ["enter"]),
|
|
156
|
+
withKeys(reset, ["esc"])
|
|
157
|
+
]
|
|
158
|
+
}, {
|
|
159
|
+
leadingNode: withCtx(() => [
|
|
160
|
+
createVNode(TextInputAffix, null, {
|
|
161
|
+
default: withCtx(() => _cache[2] || (_cache[2] = [
|
|
162
|
+
createElementVNode("i", { class: "i-celeste-link" }, null, -1)
|
|
163
|
+
])),
|
|
164
|
+
_: 1
|
|
165
|
+
})
|
|
166
|
+
]),
|
|
167
|
+
_: 1
|
|
168
|
+
}, 8, ["modelValue"]),
|
|
169
|
+
createVNode(Button, {
|
|
170
|
+
intent: "neutral",
|
|
171
|
+
size: "xs",
|
|
172
|
+
variant: "stroke",
|
|
173
|
+
disabled: !isValidUrl.value,
|
|
174
|
+
onClick: applyLink
|
|
175
|
+
}, {
|
|
176
|
+
default: withCtx(() => _cache[3] || (_cache[3] = [
|
|
177
|
+
createTextVNode(" Set link ")
|
|
178
|
+
])),
|
|
179
|
+
_: 1
|
|
180
|
+
}, 8, ["disabled"])
|
|
181
|
+
]),
|
|
182
|
+
createElementVNode("div", _hoisted_3, [
|
|
183
|
+
createVNode(Label, { for: "open-in-new-tab" }, {
|
|
184
|
+
default: withCtx(() => _cache[4] || (_cache[4] = [
|
|
185
|
+
createTextVNode(" Open in new tab ")
|
|
186
|
+
])),
|
|
187
|
+
_: 1
|
|
188
|
+
}),
|
|
189
|
+
createVNode(_sfc_main$1, {
|
|
190
|
+
id: "open-in-new-tab",
|
|
191
|
+
checked: openInNewTab.value,
|
|
192
|
+
"onUpdate:checked": _cache[1] || (_cache[1] = ($event) => openInNewTab.value = $event)
|
|
193
|
+
}, null, 8, ["checked"])
|
|
194
|
+
])
|
|
195
|
+
])) : props.editor.isActive("link") ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
196
|
+
createVNode(LinkButton, {
|
|
197
|
+
href: _ctx.editor.getAttributes("link").href,
|
|
198
|
+
target: _ctx.editor.getAttributes("link").target
|
|
199
|
+
}, {
|
|
200
|
+
default: withCtx(() => [
|
|
201
|
+
createTextVNode(toDisplayString(truncateMiddleUrl(_ctx.editor.getAttributes("link").href)), 1)
|
|
202
|
+
]),
|
|
203
|
+
_: 1
|
|
204
|
+
}, 8, ["href", "target"]),
|
|
205
|
+
_cache[5] || (_cache[5] = createElementVNode("div", { class: "divider" }, null, -1)),
|
|
206
|
+
createVNode(CompactButton, {
|
|
207
|
+
icon: "i-celeste-edit-line",
|
|
208
|
+
size: "lg",
|
|
209
|
+
variant: "ghost",
|
|
210
|
+
onClick: startEdit
|
|
211
|
+
}),
|
|
212
|
+
createVNode(CompactButton, {
|
|
213
|
+
icon: "i-celeste-delete-bin-line",
|
|
214
|
+
size: "lg",
|
|
215
|
+
variant: "ghost",
|
|
216
|
+
onClick: removeLink
|
|
217
|
+
})
|
|
218
|
+
])) : createCommentVNode("", true)
|
|
219
|
+
], 512)) : createCommentVNode("", true)
|
|
220
|
+
]),
|
|
221
|
+
_: 1
|
|
222
|
+
}, 8, ["editor"]);
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
const LinkBubble = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c63c1d92"]]);
|
|
227
|
+
export {
|
|
228
|
+
LinkBubble as default
|
|
229
|
+
};
|
package/dist/es/link-button.js
CHANGED
|
@@ -39,7 +39,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
const
|
|
42
|
+
const LinkButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-82b3b1ab"]]);
|
|
43
43
|
export {
|
|
44
|
-
|
|
44
|
+
LinkButton as default
|
|
45
45
|
};
|
package/dist/es/modal-content.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, Transition, mergeProps, renderSlot } from "vue";
|
|
2
2
|
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
3
3
|
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
-
import { x as xe,
|
|
4
|
+
import { x as xe, aa as Dv, ab as Eu, ac as xu } from "./chunks/index.js";
|
|
5
5
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
7
|
__name: "modal-content",
|
package/dist/es/modal-header.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, createCommentVNode, createBlock, withCtx, toDisplayString, createVNode } from "vue";
|
|
2
2
|
import CompactButton from "./compact-button.js";
|
|
3
3
|
import { c as clsx } from "./chunks/clsx.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ad as Pu, ae as Du, a as Gl } from "./chunks/index.js";
|
|
5
5
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
6
6
|
const _hoisted_1 = ["data-dismissible", "data-alignment", "data-type"];
|
|
7
7
|
const _hoisted_2 = {
|
|
@@ -2,7 +2,7 @@ import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, m
|
|
|
2
2
|
import CompactButton from "./compact-button.js";
|
|
3
3
|
import { useDelegatedProps } from "./use-delegated-props.js";
|
|
4
4
|
import { c as clsx } from "./chunks/clsx.js";
|
|
5
|
-
import { x as xe,
|
|
5
|
+
import { x as xe, af as bs, ag as ws, ah as _s, ai as xs } from "./chunks/index.js";
|
|
6
6
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
7
7
|
const _hoisted_1 = ["data-icon-size"];
|
|
8
8
|
const _hoisted_2 = { class: "celeste-popover-title" };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { aj as gs } from "./chunks/index.js";
|
|
3
3
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
4
4
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
5
|
__name: "popover-trigger",
|