pxd 0.1.7 → 0.1.8
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/components/_internal/mention-editor.d.vue.ts +23 -14
- package/dist/components/_internal/mention-editor.vue +78 -10
- package/dist/components/_internal/tree-node.d.vue.ts +2 -2
- package/dist/components/_internal/tree-node.vue +1 -1
- package/dist/components/active-graph/index.vue +3 -3
- package/dist/components/approval-card/index.d.vue.ts +11 -1
- package/dist/components/approval-card/index.vue +28 -8
- package/dist/components/approval-card/types.d.ts +5 -6
- package/dist/components/avatar/index.vue +1 -1
- package/dist/components/backtop/index.vue +32 -10
- package/dist/components/badge/index.vue +2 -2
- package/dist/components/book/index.vue +1 -1
- package/dist/components/book/types.d.ts +2 -2
- package/dist/components/breadcrumb-item/index.vue +1 -1
- package/dist/components/browser/index.vue +1 -1
- package/dist/components/bubble/index.vue +6 -6
- package/dist/components/bubble/types.d.ts +1 -1
- package/dist/components/bubble-group/index.d.vue.ts +1 -0
- package/dist/components/bubble-group/index.vue +10 -18
- package/dist/components/button/index.vue +2 -2
- package/dist/components/button/types.d.ts +2 -2
- package/dist/components/button-group/types.d.ts +2 -2
- package/dist/components/calendar/index.vue +4 -4
- package/dist/components/carousel/types.d.ts +2 -2
- package/dist/components/checkbox/types.d.ts +2 -2
- package/dist/components/checkerboard/index.vue +1 -1
- package/dist/components/chip/index.vue +1 -1
- package/dist/components/chip/types.d.ts +2 -2
- package/dist/components/choicebox/types.d.ts +2 -2
- package/dist/components/choicebox-item/types.d.ts +2 -2
- package/dist/components/code-block/index.vue +9 -9
- package/dist/components/code-block/types.d.ts +2 -2
- package/dist/components/collapse/index.vue +2 -2
- package/dist/components/collapse/types.d.ts +2 -2
- package/dist/components/collapse-group/index.vue +6 -6
- package/dist/components/command-menu/index.d.vue.ts +1 -1
- package/dist/components/command-menu/index.vue +17 -5
- package/dist/components/command-menu/types.d.ts +8 -1
- package/dist/components/config-provider/index.d.vue.ts +3 -0
- package/dist/components/confirm-popover/index.vue +1 -1
- package/dist/components/confirm-popover/types.d.ts +5 -5
- package/dist/components/context-usage/index.vue +13 -6
- package/dist/components/copy-button/index.d.vue.ts +2 -0
- package/dist/components/copy-button/index.vue +7 -3
- package/dist/components/copy-button/types.d.ts +3 -2
- package/dist/components/countdown/index.d.vue.ts +1 -1
- package/dist/components/countdown/index.vue +1 -1
- package/dist/components/description/types.d.ts +2 -2
- package/dist/components/drawer/index.vue +4 -1
- package/dist/components/drawer/types.d.ts +4 -4
- package/dist/components/effort-slider/index.vue +13 -16
- package/dist/components/ellipsis-text/types.d.ts +3 -3
- package/dist/components/empty-state/index.vue +1 -1
- package/dist/components/empty-state/types.d.ts +2 -2
- package/dist/components/error/index.vue +2 -2
- package/dist/components/error/types.d.ts +2 -2
- package/dist/components/feedback-bar/index.vue +4 -4
- package/dist/components/gauge/index.vue +3 -3
- package/dist/components/hint/index.vue +2 -2
- package/dist/components/hold-button/index.d.vue.ts +2 -4
- package/dist/components/hold-button/index.vue +9 -13
- package/dist/components/hold-button/types.d.ts +2 -4
- package/dist/components/hue-text/types.d.ts +2 -2
- package/dist/components/image-preview/index.vue +6 -6
- package/dist/components/input/index.d.vue.ts +6 -6
- package/dist/components/input/index.vue +5 -5
- package/dist/components/kbd/index.vue +1 -1
- package/dist/components/kbd/types.d.ts +2 -2
- package/dist/components/link-button/types.d.ts +1 -1
- package/dist/components/list/index.d.vue.ts +1 -0
- package/dist/components/list/index.vue +8 -2
- package/dist/components/list/types.d.ts +16 -8
- package/dist/components/list-group/index.vue +1 -7
- package/dist/components/list-group/types.d.ts +1 -1
- package/dist/components/list-item/index.d.vue.ts +2 -2
- package/dist/components/list-item/index.vue +16 -3
- package/dist/components/list-item/types.d.ts +1 -0
- package/dist/components/loading-mask/types.d.ts +1 -1
- package/dist/components/marching-ants/index.vue +2 -2
- package/dist/components/marquee/types.d.ts +2 -2
- package/dist/components/mention/index.d.vue.ts +26 -8
- package/dist/components/mention/index.vue +92 -11
- package/dist/components/mention/types.d.ts +37 -5
- package/dist/components/message/index.d.vue.ts +3 -3
- package/dist/components/message/index.vue +3 -3
- package/dist/components/message-item/index.vue +1 -1
- package/dist/components/modal/index.vue +5 -2
- package/dist/components/modal/types.d.ts +4 -4
- package/dist/components/more-button/types.d.ts +2 -2
- package/dist/components/note/index.vue +3 -3
- package/dist/components/note/types.d.ts +3 -3
- package/dist/components/number-input/index.d.vue.ts +4 -4
- package/dist/components/page-number/index.vue +2 -2
- package/dist/components/pagination/index.vue +2 -2
- package/dist/components/pin-input/index.vue +1 -1
- package/dist/components/popover/index.vue +111 -100
- package/dist/components/popover/types.d.ts +0 -2
- package/dist/components/progress/index.d.vue.ts +1 -1
- package/dist/components/project-banner/index.vue +3 -3
- package/dist/components/project-banner/types.d.ts +2 -2
- package/dist/components/questionnaire/index.d.vue.ts +1 -1
- package/dist/components/questionnaire/index.vue +93 -36
- package/dist/components/questionnaire/types.d.ts +5 -1
- package/dist/components/radio/types.d.ts +2 -2
- package/dist/components/rating/index.d.vue.ts +1 -1
- package/dist/components/rating/index.vue +1 -0
- package/dist/components/rating/types.d.ts +2 -2
- package/dist/components/reasoning/index.vue +4 -4
- package/dist/components/reasoning/types.d.ts +2 -2
- package/dist/components/resizable/index.d.vue.ts +1 -1
- package/dist/components/resizable/index.vue +34 -30
- package/dist/components/reveal/index.vue +2 -2
- package/dist/components/rolling-number/index.d.vue.ts +1 -1
- package/dist/components/rolling-number/index.vue +6 -6
- package/dist/components/rolling-number/types.d.ts +1 -1
- package/dist/components/scroll-text/index.vue +3 -2
- package/dist/components/scroll-text/types.d.ts +2 -2
- package/dist/components/scrollable/index.vue +1 -6
- package/dist/components/scrollable/types.d.ts +0 -2
- package/dist/components/search-input/index.d.vue.ts +14 -14
- package/dist/components/search-input/index.vue +2 -2
- package/dist/components/select/index.vue +16 -6
- package/dist/components/select/types.d.ts +9 -1
- package/dist/components/shimmer-text/index.d.vue.ts +1 -1
- package/dist/components/shimmer-text/index.vue +2 -2
- package/dist/components/shimmer-text/types.d.ts +4 -2
- package/dist/components/slider/index.d.vue.ts +1 -1
- package/dist/components/slider/index.vue +34 -2
- package/dist/components/snippet/index.d.vue.ts +2 -0
- package/dist/components/snippet/index.vue +6 -2
- package/dist/components/snippet/types.d.ts +3 -2
- package/dist/components/split-button/index.d.vue.ts +9 -7
- package/dist/components/split-button/index.vue +21 -6
- package/dist/components/split-button/types.d.ts +3 -1
- package/dist/components/status-dot/types.d.ts +2 -2
- package/dist/components/steps/types.d.ts +3 -3
- package/dist/components/stick-to-bottom/index.vue +9 -12
- package/dist/components/stick-to-bottom/types.d.ts +0 -2
- package/dist/components/switch/index.vue +1 -1
- package/dist/components/switch-item/types.d.ts +2 -2
- package/dist/components/tabs/index.vue +3 -3
- package/dist/components/teleport/index.vue +6 -3
- package/dist/components/text/index.vue +1 -1
- package/dist/components/text/types.d.ts +1 -1
- package/dist/components/textarea/index.d.vue.ts +6 -6
- package/dist/components/textarea/index.vue +1 -1
- package/dist/components/textarea/types.d.ts +2 -2
- package/dist/components/time-picker/index.vue +4 -4
- package/dist/components/toc/index.vue +7 -2
- package/dist/components/toc/types.d.ts +1 -0
- package/dist/components/todo-list/index.d.vue.ts +1 -1
- package/dist/components/todo-list/index.vue +138 -103
- package/dist/components/todo-list/types.d.ts +7 -5
- package/dist/components/toggle/index.vue +1 -1
- package/dist/components/toggle-button/index.vue +11 -9
- package/dist/components/toggle-button/types.d.ts +3 -3
- package/dist/components/toggle-button-group/index.vue +2 -1
- package/dist/components/toggle-button-group/types.d.ts +2 -2
- package/dist/components/tool-call/index.vue +31 -35
- package/dist/components/tool-call/types.d.ts +2 -2
- package/dist/components/tour/index.d.vue.ts +1 -1
- package/dist/components/tour/index.vue +1 -1
- package/dist/components/tour/types.d.ts +4 -4
- package/dist/components/tree/index.vue +5 -4
- package/dist/components/tree/types.d.ts +4 -5
- package/dist/components/virtual-list/types.d.ts +3 -3
- package/dist/composables/_internal/use-details-collapse.js +28 -3
- package/dist/composables/_internal/use-list-search.d.ts +15 -0
- package/dist/composables/_internal/use-list-search.js +50 -0
- package/dist/composables/_internal/use-mention-editor.d.ts +10 -5
- package/dist/composables/_internal/use-mention-editor.js +180 -140
- package/dist/composables/_internal/use-mention-suggest.d.ts +10 -8
- package/dist/composables/_internal/use-mention-suggest.js +39 -25
- package/dist/composables/_internal/use-message-group.js +6 -6
- package/dist/composables/_internal/use-popover-responsive.d.ts +1 -1
- package/dist/composables/_internal/use-popover-responsive.js +1 -1
- package/dist/composables/_internal/use-remote-search.d.ts +17 -0
- package/dist/composables/_internal/use-remote-search.js +58 -0
- package/dist/composables/_internal/use-tree.d.ts +2 -2
- package/dist/composables/_internal/use-tree.js +7 -52
- package/dist/composables/_internal/use-word-limit.d.ts +2 -2
- package/dist/composables/use-backoff-retry.d.ts +2 -35
- package/dist/composables/use-backoff-retry.js +5 -98
- package/dist/composables/use-copy-click.js +14 -13
- package/dist/composables/use-countdown.d.ts +1 -1
- package/dist/composables/use-countdown.js +4 -4
- package/dist/composables/use-delay-destroy.js +8 -6
- package/dist/composables/use-message.d.ts +1 -1
- package/dist/composables/use-message.js +1 -1
- package/dist/composables/use-repeat-action.d.ts +1 -1
- package/dist/composables/use-repeat-action.js +3 -3
- package/dist/composables/use-stick-to-bottom.d.ts +4 -21
- package/dist/composables/use-stick-to-bottom.js +138 -24
- package/dist/composables/use-view-transition.d.ts +23 -9
- package/dist/constants/tooltip-variants.d.ts +1 -1
- package/dist/constants/tooltip-variants.js +1 -1
- package/dist/locales/en-us.d.ts +3 -0
- package/dist/locales/en-us.js +4 -1
- package/dist/locales/zh-cn.d.ts +3 -0
- package/dist/locales/zh-cn.js +4 -1
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +5 -14
- package/dist/types/shared/props.d.ts +5 -2
- package/dist/utils/_internal/mention-html.d.ts +1 -0
- package/dist/utils/_internal/mention-html.js +6 -4
- package/dist/utils/_internal/observer.js +3 -3
- package/dist/utils/backoff-retry.d.ts +15 -0
- package/dist/utils/backoff-retry.js +94 -0
- package/dist/utils/mention-html.d.ts +14 -0
- package/dist/utils/mention-html.js +71 -0
- package/package.json +2 -9
- package/dist/composables/_internal/use-list-filter.d.ts +0 -15
- package/dist/composables/_internal/use-list-filter.js +0 -48
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const MENTION_TAG = "MENTION";
|
|
2
2
|
export declare const MENTION_TAG_LOWER: string;
|
|
3
|
+
export declare const BLOCK_TAGS: Set<string>;
|
|
3
4
|
/** The trigger a chip falls back to when its markup carries no `trigger` attribute. */
|
|
4
5
|
export declare const DEFAULT_TRIGGER = "@";
|
|
5
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const MENTION_TAG = "MENTION";
|
|
2
2
|
export const MENTION_TAG_LOWER = MENTION_TAG.toLowerCase();
|
|
3
|
-
const BLOCK_TAGS = /* @__PURE__ */ new Set(["DIV", "P", "LI", "PRE"]);
|
|
3
|
+
export const BLOCK_TAGS = /* @__PURE__ */ new Set(["DIV", "P", "LI", "PRE"]);
|
|
4
4
|
export const DEFAULT_TRIGGER = "@";
|
|
5
5
|
export const CARET_ANCHOR = "\u200B";
|
|
6
6
|
export function createCaretAnchor() {
|
|
@@ -46,7 +46,9 @@ export function serializeMentionHtml(root) {
|
|
|
46
46
|
}
|
|
47
47
|
function walk(node) {
|
|
48
48
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
49
|
-
result += (
|
|
49
|
+
result += escapeMentionText(
|
|
50
|
+
(node.textContent ?? "").replace(/\u00A0/g, " ").replace(/\u200B/g, "")
|
|
51
|
+
);
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
54
|
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
@@ -77,7 +79,7 @@ export function serializeMentionHtml(root) {
|
|
|
77
79
|
}
|
|
78
80
|
return result === "\n" ? "" : result;
|
|
79
81
|
}
|
|
80
|
-
function
|
|
82
|
+
function parseMentionFragment(html) {
|
|
81
83
|
const fragment = document.createDocumentFragment();
|
|
82
84
|
if (!html) {
|
|
83
85
|
return fragment;
|
|
@@ -139,7 +141,7 @@ function appendPlainText(target, text) {
|
|
|
139
141
|
}
|
|
140
142
|
export function setMentionEditorContent(root, html) {
|
|
141
143
|
root.replaceChildren();
|
|
142
|
-
root.appendChild(
|
|
144
|
+
root.appendChild(parseMentionFragment(html));
|
|
143
145
|
if (!root.childNodes.length) {
|
|
144
146
|
root.appendChild(document.createElement("br"));
|
|
145
147
|
}
|
|
@@ -37,10 +37,10 @@ export function createObserver(spec) {
|
|
|
37
37
|
spec.sync(pool.observer, [el], [], pool.options);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function dispatch(items) {
|
|
40
|
+
function dispatch(targets, items) {
|
|
41
41
|
const batches = /* @__PURE__ */ new Map();
|
|
42
42
|
for (const entry of items) {
|
|
43
|
-
const subs =
|
|
43
|
+
const subs = targets.get(entry.target);
|
|
44
44
|
if (!subs) {
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
@@ -60,7 +60,7 @@ export function createObserver(spec) {
|
|
|
60
60
|
function acquire(key, value) {
|
|
61
61
|
let entry = pools.get(key);
|
|
62
62
|
if (!entry) {
|
|
63
|
-
const created = spec.create(dispatch, value);
|
|
63
|
+
const created = spec.create((items) => dispatch(entry.targets, items), value);
|
|
64
64
|
if (!created) {
|
|
65
65
|
return void 0;
|
|
66
66
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface BackoffRetryConfig {
|
|
2
|
+
/** @default 3 */
|
|
3
|
+
maxRetries?: number;
|
|
4
|
+
/** @default 500 */
|
|
5
|
+
baseDelay?: number;
|
|
6
|
+
/** @default 10000 */
|
|
7
|
+
maxDelay?: number;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
/** Defaults to `isRetryableError`; native fetch does not reject on 4xx/5xx, so throw for status rules to apply. */
|
|
10
|
+
retryable?: (error: unknown) => boolean;
|
|
11
|
+
onRetry?: (attempt: number, delay: number, error: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
14
|
+
/** Vue-free (Node / Electron main safe); map any failure domain to a throw inside `fn` and decide via `retryable`. */
|
|
15
|
+
export declare function backoffRetry<T>(fn: (signal: AbortSignal) => Promise<T>, config?: BackoffRetryConfig): Promise<T>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
2
|
+
"ECONNRESET",
|
|
3
|
+
"ETIMEDOUT",
|
|
4
|
+
"ENOTFOUND",
|
|
5
|
+
"ECONNABORTED",
|
|
6
|
+
"EAI_AGAIN"
|
|
7
|
+
]);
|
|
8
|
+
export function isRetryableError(error) {
|
|
9
|
+
if (typeof error !== "object" || error === null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const err = error;
|
|
13
|
+
const status = err.status ?? err.statusCode ?? err.response?.status;
|
|
14
|
+
if (typeof status === "number") {
|
|
15
|
+
return status === 429 || status === 408 || status >= 500 && status < 600;
|
|
16
|
+
}
|
|
17
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
18
|
+
for (let e = err; e && typeof e === "object"; e = e.cause) {
|
|
19
|
+
if (seen.has(e)) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
seen.add(e);
|
|
23
|
+
if (typeof e.code === "string" && NETWORK_ERROR_CODES.has(e.code)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (err.code === "ERR_NETWORK" || err.code === "ERR_BAD_RESPONSE") {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
const msg = typeof err.message === "string" ? err.message : "";
|
|
31
|
+
if (err instanceof TypeError && /failed to fetch|networkerror|network error|load failed/i.test(msg)) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
function sleep(ms, signal) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
if (signal?.aborted) {
|
|
39
|
+
reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const onAbort = () => {
|
|
43
|
+
clearTimeout(timer);
|
|
44
|
+
reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
|
|
45
|
+
};
|
|
46
|
+
const timer = setTimeout(() => {
|
|
47
|
+
signal?.removeEventListener("abort", onAbort);
|
|
48
|
+
resolve();
|
|
49
|
+
}, ms);
|
|
50
|
+
signal?.addEventListener("abort", onAbort);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function attachAttempts(error, attempts) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
;
|
|
56
|
+
error.attempts = attempts;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (error !== null && typeof error === "object") {
|
|
60
|
+
;
|
|
61
|
+
error.attempts = attempts;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export async function backoffRetry(fn, config = {}) {
|
|
65
|
+
const { baseDelay = 500, maxDelay = 1e4, retryable = isRetryableError, onRetry } = config;
|
|
66
|
+
const maxRetries = Math.max(0, config.maxRetries ?? 3);
|
|
67
|
+
const signal = config.signal ?? new AbortController().signal;
|
|
68
|
+
let lastError;
|
|
69
|
+
let attempts = 0;
|
|
70
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
71
|
+
signal.throwIfAborted();
|
|
72
|
+
try {
|
|
73
|
+
return await fn(signal);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
lastError = error;
|
|
76
|
+
attempts = attempt + 1;
|
|
77
|
+
if (attempt === maxRetries) {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (!retryable(error)) {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
const exponential = Math.min(baseDelay * 2 ** attempt, maxDelay);
|
|
84
|
+
const delay = Math.round(Math.random() * exponential);
|
|
85
|
+
try {
|
|
86
|
+
onRetry?.(attempt + 1, delay, error);
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
await sleep(delay, signal);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
attachAttempts(lastError, attempts);
|
|
93
|
+
throw lastError;
|
|
94
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MentionHtmlToTextOptions, MentionHtmlToken } from '../components/mention/types';
|
|
2
|
+
export type { MentionHtmlToken, MentionHtmlToTextOptions } from '../components/mention/types';
|
|
3
|
+
export { escapePlainTextAsHtml } from './_internal/mention-html.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parse the public mention HTML contract (text + legal `<mention>` only) into a
|
|
6
|
+
* flat token list. Blocks and `<br>` become `\n` text, so joining the text
|
|
7
|
+
* tokens matches the plain-text form of the value.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseMentionHtml(html: string): MentionHtmlToken[];
|
|
10
|
+
/**
|
|
11
|
+
* Plain text of a mention HTML value: chips render as `${trigger}${label}`,
|
|
12
|
+
* or through `chipText` for custom output.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mentionHtmlToText(html: string, options?: MentionHtmlToTextOptions): string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BLOCK_TAGS,
|
|
3
|
+
DEFAULT_TRIGGER,
|
|
4
|
+
getMentionLabel,
|
|
5
|
+
isMentionElement,
|
|
6
|
+
MENTION_TAG_LOWER
|
|
7
|
+
} from "./_internal/mention-html.js";
|
|
8
|
+
export { escapePlainTextAsHtml } from "./_internal/mention-html.js";
|
|
9
|
+
export function parseMentionHtml(html) {
|
|
10
|
+
const tokens = [];
|
|
11
|
+
if (!html) {
|
|
12
|
+
return tokens;
|
|
13
|
+
}
|
|
14
|
+
const doc = new DOMParser().parseFromString(`<body>${html}</body>`, "text/html");
|
|
15
|
+
function appendText(text) {
|
|
16
|
+
if (!text) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const last = tokens[tokens.length - 1];
|
|
20
|
+
if (last?.type === "text") {
|
|
21
|
+
last.text += text;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
tokens.push({ type: "text", text });
|
|
25
|
+
}
|
|
26
|
+
function walk(node) {
|
|
27
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
28
|
+
appendText((node.textContent ?? "").replace(/\u00A0/g, " ").replace(/\u200B/g, ""));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const el = node;
|
|
35
|
+
if (isMentionElement(el)) {
|
|
36
|
+
tokens.push({
|
|
37
|
+
type: "mention",
|
|
38
|
+
key: el.getAttribute("key") ?? "",
|
|
39
|
+
label: getMentionLabel(el),
|
|
40
|
+
trigger: el.getAttribute("trigger") || DEFAULT_TRIGGER
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (el.tagName === "BR") {
|
|
45
|
+
appendText("\n");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (BLOCK_TAGS.has(el.tagName) && (el.textContent || el.querySelector(MENTION_TAG_LOWER))) {
|
|
49
|
+
if (tokens.length && tokens[tokens.length - 1].type === "mention") {
|
|
50
|
+
tokens.push({ type: "text", text: "\n" });
|
|
51
|
+
} else {
|
|
52
|
+
const last = tokens[tokens.length - 1];
|
|
53
|
+
if (last?.type === "text" && !last.text.endsWith("\n")) {
|
|
54
|
+
last.text += "\n";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const child of Array.from(el.childNodes)) {
|
|
59
|
+
walk(child);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const child of Array.from(doc.body.childNodes)) {
|
|
63
|
+
walk(child);
|
|
64
|
+
}
|
|
65
|
+
return tokens;
|
|
66
|
+
}
|
|
67
|
+
export function mentionHtmlToText(html, options) {
|
|
68
|
+
return parseMentionHtml(html).map(
|
|
69
|
+
(token) => token.type === "text" ? token.text : options?.chipText?.(token) ?? `${token.trigger}${token.label}`
|
|
70
|
+
).join("");
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pxd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "A universal Vue 2.7 & 3.2 component library built from one codebase. Built-in light/dark theme. PC & mobile ready. Animation-free mode supported.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component-library",
|
|
@@ -109,18 +109,11 @@
|
|
|
109
109
|
"unplugin-vue-components": "^32.1.0",
|
|
110
110
|
"vite-plus": "^1.4.0",
|
|
111
111
|
"vue": "^3.5.44",
|
|
112
|
-
"vue-router": "4.6.4",
|
|
113
112
|
"vue-sfc-transformer": "^0.3.1",
|
|
114
113
|
"vue-tsc": "^3.3.13"
|
|
115
114
|
},
|
|
116
115
|
"peerDependencies": {
|
|
117
|
-
"vue": ">=2.7.0 <3.0.0 || >=3.2.0"
|
|
118
|
-
"vue-router": ">=3.5.0"
|
|
119
|
-
},
|
|
120
|
-
"peerDependenciesMeta": {
|
|
121
|
-
"vue-router": {
|
|
122
|
-
"optional": true
|
|
123
|
-
}
|
|
116
|
+
"vue": ">=2.7.0 <3.0.0 || >=3.2.0"
|
|
124
117
|
},
|
|
125
118
|
"scripts": {
|
|
126
119
|
"dev": "run-s dev:lib dev:docs",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ListOptions } from '../../components/list/types';
|
|
2
|
-
import type { MaybeRefOrGetter, ComputedRef } from 'vue';
|
|
3
|
-
export type ListFilterFn = (text: string, search: string, keywords: string[]) => boolean;
|
|
4
|
-
export interface UseListFilterOptions {
|
|
5
|
-
filter?: ListFilterFn;
|
|
6
|
-
}
|
|
7
|
-
export interface UseListFilterReturn {
|
|
8
|
-
filteredOptions: ComputedRef<ListOptions>;
|
|
9
|
-
visibleCount: ComputedRef<number>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Pure filter over list options. Groups with no matching children are dropped.
|
|
13
|
-
*/
|
|
14
|
-
export declare function filterListOptions(options: ListOptions, query: string, filter?: ListFilterFn): ListOptions;
|
|
15
|
-
export declare function useListFilter(options: MaybeRefOrGetter<ListOptions>, keyword: MaybeRefOrGetter<string>, { filter }?: UseListFilterOptions): UseListFilterReturn;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
import { isFuzzyMatch } from "../../utils/fuzzy-match.js";
|
|
3
|
-
import { toValue } from "../../utils/helper.js";
|
|
4
|
-
import { isListOptionGroup } from "./use-selected-list-item.js";
|
|
5
|
-
function getOptionText(option) {
|
|
6
|
-
return `${String(option.label ?? "")}${String(option.description ?? "")}`.trim();
|
|
7
|
-
}
|
|
8
|
-
function countListOptions(options) {
|
|
9
|
-
let count = 0;
|
|
10
|
-
for (const entry of options) {
|
|
11
|
-
if (isListOptionGroup(entry)) {
|
|
12
|
-
count += entry.options.length;
|
|
13
|
-
} else {
|
|
14
|
-
count += 1;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return count;
|
|
18
|
-
}
|
|
19
|
-
export function filterListOptions(options, query, filter = isFuzzyMatch) {
|
|
20
|
-
const needle = query.trim();
|
|
21
|
-
if (!needle) {
|
|
22
|
-
return options;
|
|
23
|
-
}
|
|
24
|
-
const result = [];
|
|
25
|
-
for (const entry of options) {
|
|
26
|
-
if (isListOptionGroup(entry)) {
|
|
27
|
-
const matched = entry.options.filter(
|
|
28
|
-
(item) => filter(getOptionText(item), needle, item.keywords ?? [])
|
|
29
|
-
);
|
|
30
|
-
if (matched.length) {
|
|
31
|
-
result.push({ ...entry, options: matched });
|
|
32
|
-
}
|
|
33
|
-
} else if (filter(getOptionText(entry), needle, entry.keywords ?? [])) {
|
|
34
|
-
result.push(entry);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
export function useListFilter(options, keyword, { filter = isFuzzyMatch } = {}) {
|
|
40
|
-
const filteredOptions = computed(
|
|
41
|
-
() => filterListOptions(toValue(options) ?? [], toValue(keyword) ?? "", filter)
|
|
42
|
-
);
|
|
43
|
-
const visibleCount = computed(() => countListOptions(filteredOptions.value));
|
|
44
|
-
return {
|
|
45
|
-
filteredOptions,
|
|
46
|
-
visibleCount
|
|
47
|
-
};
|
|
48
|
-
}
|