histoire 0.3.1 → 0.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/bundled/BaseEmpty.js +13 -0
- package/dist/bundled/HomeView.js +23 -0
- package/dist/bundled/MobileOverlay.js +303 -0
- package/dist/bundled/SearchPane.js +504 -0
- package/dist/bundled/StoryView.js +2330 -0
- package/dist/bundled/api.js +32 -0
- package/dist/bundled/config.js +4 -0
- package/dist/bundled/const.js +5 -0
- package/dist/bundled/dark.js +4 -0
- package/dist/bundled/events.js +29 -0
- package/dist/bundled/global-components.js +203 -0
- package/dist/bundled/index.js +7 -0
- package/dist/bundled/index2.js +762 -0
- package/dist/bundled/reactivity.js +96 -0
- package/dist/bundled/sandbox.js +97 -0
- package/dist/bundled/search-docs-data.js +7 -0
- package/dist/bundled/story.js +59 -0
- package/dist/bundled/style.css +102 -0
- package/dist/client/app/App.vue +2 -2
- package/dist/client/app/api.d.ts +1 -0
- package/dist/client/app/api.js +1 -0
- package/dist/client/app/codegen/vue3.js +1 -2
- package/dist/client/app/components/HomeView.vue +1 -1
- package/dist/client/app/components/app/AppLogo.vue +1 -1
- package/dist/client/app/components/app/MobileOverlay.vue +0 -1
- package/dist/client/app/components/base/BaseEmpty.vue +1 -1
- package/dist/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/dist/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/dist/client/app/components/exposed/Story.vue +13 -2
- package/dist/client/app/components/exposed/Variant.vue +6 -0
- package/dist/client/app/components/panel/PaneTabs.vue +64 -0
- package/{src/client/app/components/story → dist/client/app/components/panel}/StoryControls.vue +1 -1
- package/dist/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/dist/client/app/components/{story → panel}/StoryEvent.vue +1 -0
- package/dist/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/dist/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/dist/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/dist/client/app/components/search/SearchItem.vue +1 -1
- package/dist/client/app/components/search/SearchPane.vue +108 -25
- package/dist/client/app/components/search/search-docs-data.d.ts +3 -0
- package/dist/client/app/components/search/{search-data.js → search-docs-data.js} +1 -1
- package/dist/client/app/components/search/search-title-data.d.ts +3 -0
- package/dist/client/app/components/search/search-title-data.js +7 -0
- package/dist/client/app/components/search/types.d.ts +7 -0
- package/dist/client/app/components/search/types.js +1 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +42 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/dist/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/dist/client/app/components/story/StoryView.vue +2 -2
- package/dist/client/app/components/story/StoryViewer.vue +2 -92
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantTitle.vue +1 -1
- package/dist/client/app/components/tree/StoryListItem.vue +1 -1
- package/dist/client/app/index.d.ts +1 -1
- package/dist/client/app/index.js +21 -18
- package/dist/client/app/sandbox.d.ts +1 -1
- package/dist/client/app/sandbox.js +0 -1
- package/dist/client/app/stores/events.js +1 -1
- package/dist/client/app/stores/story.d.ts +27 -0
- package/dist/client/app/style/transitions.pcss +13 -0
- package/dist/client/app/types.d.ts +3 -0
- package/dist/client/app/util/events.d.ts +1 -1
- package/dist/client/app/util/events.js +2 -2
- package/dist/client/app/util/mapping.js +2 -0
- package/dist/client/bundle-index.js +5 -0
- package/dist/client/bundle-main.js +5 -0
- package/dist/client/bundle-sandbox.js +3 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/server/vue3/Story.vue +1 -1
- package/dist/client/server/vue3/run.js +8 -0
- package/dist/node/alias.js +1 -1
- package/dist/node/build.js +4 -4
- package/dist/node/builtin-plugins/tailwind-tokens.js +1 -1
- package/dist/node/search.d.ts +15 -1
- package/dist/node/search.js +78 -32
- package/dist/node/server.js +2 -2
- package/dist/node/types.d.ts +1 -0
- package/dist/node/vite.d.ts +4 -2
- package/dist/node/vite.js +24 -28
- package/dist/style.css +93 -69
- package/package.json +10 -10
- package/src/client/app/App.vue +2 -2
- package/src/client/app/api.ts +1 -0
- package/src/client/app/codegen/vue3.ts +1 -2
- package/src/client/app/components/HomeView.vue +1 -1
- package/src/client/app/components/app/AppLogo.vue +1 -1
- package/src/client/app/components/app/MobileOverlay.vue +0 -1
- package/src/client/app/components/base/BaseEmpty.vue +1 -1
- package/src/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/src/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/src/client/app/components/exposed/Story.vue +13 -2
- package/src/client/app/components/exposed/Variant.vue +6 -0
- package/src/client/app/components/panel/PaneTabs.vue +64 -0
- package/{dist/client/app/components/story → src/client/app/components/panel}/StoryControls.vue +1 -1
- package/src/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/src/client/app/components/{story → panel}/StoryEvent.vue +1 -0
- package/src/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/src/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/src/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/src/client/app/components/search/SearchItem.vue +1 -1
- package/src/client/app/components/search/SearchPane.vue +108 -25
- package/src/client/app/components/search/search-docs-data.ts +10 -0
- package/src/client/app/components/search/search-title-data.ts +10 -0
- package/src/client/app/components/search/types.ts +4 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +42 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/src/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/src/client/app/components/story/StoryView.vue +2 -2
- package/src/client/app/components/story/StoryViewer.vue +2 -92
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantTitle.vue +1 -1
- package/src/client/app/components/tree/StoryListItem.vue +1 -1
- package/src/client/app/index.ts +23 -19
- package/src/client/app/sandbox.ts +1 -2
- package/src/client/app/stores/events.ts +1 -1
- package/src/client/app/style/transitions.pcss +13 -0
- package/src/client/app/types.ts +4 -0
- package/src/client/app/util/events.ts +2 -2
- package/src/client/app/util/mapping.ts +2 -0
- package/src/client/bundle-index.js +5 -0
- package/src/client/bundle-main.js +5 -0
- package/src/client/bundle-sandbox.js +3 -0
- package/src/client/index.ts +1 -1
- package/src/client/server/vue3/Story.vue +1 -1
- package/src/client/server/vue3/run.ts +11 -0
- package/src/node/alias.ts +1 -1
- package/src/node/build.ts +4 -4
- package/src/node/builtin-plugins/tailwind-tokens.ts +1 -1
- package/src/node/search.ts +87 -32
- package/src/node/server.ts +2 -2
- package/src/node/types.ts +1 -0
- package/src/node/vite.ts +24 -29
- package/vite.config.ts +46 -0
- package/dist/client/app/components/search/search-data.d.ts +0 -2
- package/src/client/app/components/search/search-data.ts +0 -9
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import { pushScopeId, popScopeId, defineComponent, useCssVars, ref, toRefs, openBlock, createElementBlock, unref, createVNode, withCtx, normalizeClass, createElementVNode, createTextVNode, toDisplayString, Fragment, renderList, createBlock, createCommentVNode, markRaw, watch, computed, withDirectives, withKeys, withModifiers, vModelText } from "vue";
|
|
2
|
+
import { useFocus, useDebounce } from "@vueuse/core";
|
|
3
|
+
import { Icon } from "@iconify/vue";
|
|
4
|
+
import flexsearch from "flexsearch";
|
|
5
|
+
import { u as useStoryStore } from "./story.js";
|
|
6
|
+
import { B as BaseEmpty } from "./BaseEmpty.js";
|
|
7
|
+
import { useRouter } from "vue-router";
|
|
8
|
+
import { o as onKeyboardShortcut } from "./index2.js";
|
|
9
|
+
import { u as useScrollOnActive, B as BaseListItemLink, _ as _export_sfc } from "./MobileOverlay.js";
|
|
10
|
+
import { searchData as searchData$1, onUpdate as onUpdate$1 } from "$histoire-search-title-data";
|
|
11
|
+
function IndexInterface() {
|
|
12
|
+
this.cache = null, this.matcher = null, this.stemmer = null, this.filter = null;
|
|
13
|
+
}
|
|
14
|
+
IndexInterface.prototype.add, IndexInterface.prototype.append, IndexInterface.prototype.search, IndexInterface.prototype.update, IndexInterface.prototype.remove;
|
|
15
|
+
function DocumentInterface() {
|
|
16
|
+
this.field = null, this.index = null;
|
|
17
|
+
}
|
|
18
|
+
function parse_option(a, b) {
|
|
19
|
+
return typeof a == "undefined" ? b : a;
|
|
20
|
+
}
|
|
21
|
+
function create_object_array(a) {
|
|
22
|
+
const b = Array(a);
|
|
23
|
+
for (let c = 0; c < a; c++)
|
|
24
|
+
b[c] = create_object();
|
|
25
|
+
return b;
|
|
26
|
+
}
|
|
27
|
+
function create_arrays(a) {
|
|
28
|
+
const b = Array(a);
|
|
29
|
+
for (let c = 0; c < a; c++)
|
|
30
|
+
b[c] = [];
|
|
31
|
+
return b;
|
|
32
|
+
}
|
|
33
|
+
function get_keys(a) {
|
|
34
|
+
return Object.keys(a);
|
|
35
|
+
}
|
|
36
|
+
function create_object() {
|
|
37
|
+
return /* @__PURE__ */ Object.create(null);
|
|
38
|
+
}
|
|
39
|
+
function concat(a) {
|
|
40
|
+
return [].concat.apply([], a);
|
|
41
|
+
}
|
|
42
|
+
function sort_by_length_down(c, a) {
|
|
43
|
+
return a.length - c.length;
|
|
44
|
+
}
|
|
45
|
+
function is_array(a) {
|
|
46
|
+
return a.constructor === Array;
|
|
47
|
+
}
|
|
48
|
+
function is_string(a) {
|
|
49
|
+
return typeof a == "string";
|
|
50
|
+
}
|
|
51
|
+
function is_object(a) {
|
|
52
|
+
return typeof a == "object";
|
|
53
|
+
}
|
|
54
|
+
function is_function(a) {
|
|
55
|
+
return typeof a == "function";
|
|
56
|
+
}
|
|
57
|
+
function pipeline(a, b, c, d) {
|
|
58
|
+
if (a && (b && (a = replace(a, b)), this.matcher && (a = replace(a, this.matcher)), this.stemmer && 1 < a.length && (a = replace(a, this.stemmer)), d && 1 < a.length && (a = collapse(a)), c || c === "")) {
|
|
59
|
+
const b2 = a.split(c);
|
|
60
|
+
return this.filter ? filter$1(b2, this.filter) : b2;
|
|
61
|
+
}
|
|
62
|
+
return a;
|
|
63
|
+
}
|
|
64
|
+
const regex_whitespace = /[\p{Z}\p{S}\p{P}\p{C}]+/u;
|
|
65
|
+
const regex_normalize = /[\u0300-\u036f]/g;
|
|
66
|
+
function normalize(a) {
|
|
67
|
+
return a.normalize && (a = a.normalize("NFD").replace(regex_normalize, "")), a;
|
|
68
|
+
}
|
|
69
|
+
function init_filter(a) {
|
|
70
|
+
const b = create_object();
|
|
71
|
+
for (let c = 0, d = a.length; c < d; c++)
|
|
72
|
+
b[a[c]] = 1;
|
|
73
|
+
return b;
|
|
74
|
+
}
|
|
75
|
+
function init_stemmer_or_matcher(a, b) {
|
|
76
|
+
const c = get_keys(a), d = c.length, e = [];
|
|
77
|
+
let f = "", g = 0;
|
|
78
|
+
for (let h, j, k = 0; k < d; k++)
|
|
79
|
+
h = c[k], j = a[h], j ? (e[g++] = regex(b ? "(?!\\b)" + h + "(\\b|_)" : h), e[g++] = j) : f += (f ? "|" : "") + h;
|
|
80
|
+
return f && (e[g++] = regex(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), e[g] = ""), e;
|
|
81
|
+
}
|
|
82
|
+
function replace(a, b) {
|
|
83
|
+
for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), !!a); c += 2)
|
|
84
|
+
;
|
|
85
|
+
return a;
|
|
86
|
+
}
|
|
87
|
+
function regex(a) {
|
|
88
|
+
return new RegExp(a, "g");
|
|
89
|
+
}
|
|
90
|
+
function collapse(a) {
|
|
91
|
+
let b = "", c = "";
|
|
92
|
+
for (let d, e = 0, f = a.length; e < f; e++)
|
|
93
|
+
(d = a[e]) !== c && (b += c = d);
|
|
94
|
+
return b;
|
|
95
|
+
}
|
|
96
|
+
function filter$1(a, b) {
|
|
97
|
+
const c = a.length, d = [];
|
|
98
|
+
for (let e = 0, f = 0; e < c; e++) {
|
|
99
|
+
const c2 = a[e];
|
|
100
|
+
c2 && !b[c2] && (d[f++] = c2);
|
|
101
|
+
}
|
|
102
|
+
return d;
|
|
103
|
+
}
|
|
104
|
+
const rtl$2 = false;
|
|
105
|
+
const tokenize$2 = "";
|
|
106
|
+
var simple = { encode: encode$2, rtl: false, tokenize: "" };
|
|
107
|
+
const regex_a = regex("[\xE0\xE1\xE2\xE3\xE4\xE5]"), regex_e = regex("[\xE8\xE9\xEA\xEB]"), regex_i = regex("[\xEC\xED\xEE\xEF]"), regex_o = regex("[\xF2\xF3\xF4\xF5\xF6\u0151]"), regex_u = regex("[\xF9\xFA\xFB\xFC\u0171]"), regex_y = regex("[\xFD\u0177\xFF]"), regex_n = regex("\xF1"), regex_c = regex("[\xE7c]"), regex_s = regex("\xDF"), regex_and = regex(" & "), pairs$1 = [regex_a, "a", regex_e, "e", regex_i, "i", regex_o, "o", regex_u, "u", regex_y, "y", regex_n, "n", regex_c, "k", regex_s, "s", regex_and, " and "];
|
|
108
|
+
function encode$2(a) {
|
|
109
|
+
return a = "" + a, pipeline.call(this, normalize(a).toLowerCase(), !a.normalize && pairs$1, regex_whitespace, false);
|
|
110
|
+
}
|
|
111
|
+
const rtl$1 = false;
|
|
112
|
+
const tokenize$1 = "strict";
|
|
113
|
+
var balance = { encode: encode$1, rtl: false, tokenize: "strict" };
|
|
114
|
+
const regex_strip = /[^a-z0-9]+/, soundex = { b: "p", v: "f", w: "f", z: "s", x: "s", \u00DF: "s", d: "t", n: "m", c: "k", g: "k", j: "k", q: "k", i: "e", y: "e", u: "o" };
|
|
115
|
+
function encode$1(a) {
|
|
116
|
+
a = encode$2.call(this, a).join(" ");
|
|
117
|
+
const b = [];
|
|
118
|
+
if (a) {
|
|
119
|
+
const c = a.split(regex_strip), d = c.length;
|
|
120
|
+
for (let e, f = 0, g = 0; f < d; f++)
|
|
121
|
+
if ((a = c[f]) && (!this.filter || !this.filter[a])) {
|
|
122
|
+
e = a[0];
|
|
123
|
+
let c2 = soundex[e] || e, d2 = c2;
|
|
124
|
+
for (let b2 = 1; b2 < a.length; b2++) {
|
|
125
|
+
e = a[b2];
|
|
126
|
+
const f2 = soundex[e] || e;
|
|
127
|
+
f2 && f2 !== d2 && (c2 += f2, d2 = f2);
|
|
128
|
+
}
|
|
129
|
+
b[g++] = c2;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return b;
|
|
133
|
+
}
|
|
134
|
+
const rtl = false;
|
|
135
|
+
const tokenize = "";
|
|
136
|
+
var charset = { encode, rtl: false, tokenize: "" };
|
|
137
|
+
const regex_ae = regex("ae"), regex_oe = regex("oe"), regex_sh = regex("sh"), regex_th = regex("th"), regex_ph = regex("ph"), regex_pf = regex("pf"), pairs = [regex_ae, "a", regex_oe, "o", regex_sh, "s", regex_th, "t", regex_ph, "f", regex_pf, "f", regex("(?![aeo])h(?![aeo])"), "", regex("(?!^[aeo])h(?!^[aeo])"), ""];
|
|
138
|
+
function encode(a, b) {
|
|
139
|
+
return a && (a = encode$1.call(this, a).join(" "), 2 < a.length && (a = replace(a, pairs)), !b && (1 < a.length && (a = collapse(a)), a && (a = a.split(" ")))), a;
|
|
140
|
+
}
|
|
141
|
+
const filter = ["a", "about", "above", "after", "again", "against", "all", "also", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "both", "but", "by", "can", "cannot", "can't", "come", "could", "couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "dont", "down", "during", "each", "even", "few", "first", "for", "from", "further", "get", "go", "had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "hed", "her", "here", "here's", "hers", "herself", "hes", "him", "himself", "his", "how", "how's", "i", "id", "if", "ill", "im", "in", "into", "is", "isn't", "it", "it's", "itself", "i've", "just", "know", "let's", "like", "make", "me", "more", "most", "mustn't", "my", "myself", "new", "no", "nor", "not", "now", "of", "off", "on", "once", "only", "or", "other", "ought", "our", "our's", "ourselves", "out", "over", "own", "same", "say", "see", "shan't", "she", "she'd", "shell", "shes", "should", "shouldn't", "so", "some", "such", "than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've", "this", "those", "through", "time", "to", "too", "until", "up", "us", "very", "want", "was", "wasn't", "way", "we", "wed", "well", "were", "weren't", "we've", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "whom", "who's", "why", "why's", "will", "with", "won't", "would", "wouldn't", "you", "you'd", "you'll", "your", "you're", "your's", "yourself", "yourselves", "you've"];
|
|
142
|
+
const stemmer = { ational: "ate", iveness: "ive", fulness: "ful", ousness: "ous", ization: "ize", tional: "tion", biliti: "ble", icate: "ic", ative: "", alize: "al", iciti: "ic", entli: "ent", ousli: "ous", alism: "al", ation: "ate", aliti: "al", iviti: "ive", ement: "", enci: "ence", anci: "ance", izer: "ize", alli: "al", ator: "ate", logi: "log", ical: "ic", ance: "", ence: "", ness: "", able: "", ible: "", ment: "", eli: "e", bli: "ble", ful: "", ant: "", ent: "", ism: "", ate: "", iti: "", ous: "", ive: "", ize: "", al: "", ou: "", er: "", ic: "" };
|
|
143
|
+
const matcher = {};
|
|
144
|
+
var language = { filter, stemmer, matcher };
|
|
145
|
+
var SearchItem_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
146
|
+
const _withScopeId = (n) => (pushScopeId("data-v-7856c5b0"), n = n(), popScopeId(), n);
|
|
147
|
+
const _hoisted_1$1 = ["data-selected"];
|
|
148
|
+
const _hoisted_2$1 = { class: "htw-flex-1" };
|
|
149
|
+
const _hoisted_3 = { class: "htw-flex" };
|
|
150
|
+
const _hoisted_4 = { class: "htw-ml-auto htw-opacity-40" };
|
|
151
|
+
const _hoisted_5 = {
|
|
152
|
+
key: 0,
|
|
153
|
+
class: "htw-flex htw-items-center htw-gap-0.5 htw-opacity-60"
|
|
154
|
+
};
|
|
155
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
156
|
+
props: {
|
|
157
|
+
result: {
|
|
158
|
+
type: Object,
|
|
159
|
+
required: true
|
|
160
|
+
},
|
|
161
|
+
selected: {
|
|
162
|
+
type: Boolean,
|
|
163
|
+
default: false
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
emits: {
|
|
167
|
+
close: () => true
|
|
168
|
+
},
|
|
169
|
+
setup(__props, { emit }) {
|
|
170
|
+
const props = __props;
|
|
171
|
+
useCssVars((_ctx) => ({
|
|
172
|
+
"0e1c785e": __props.result.iconColor
|
|
173
|
+
}));
|
|
174
|
+
const el = ref();
|
|
175
|
+
const { selected } = toRefs(props);
|
|
176
|
+
useScrollOnActive(selected, el);
|
|
177
|
+
const router = useRouter();
|
|
178
|
+
onKeyboardShortcut(["enter"], () => {
|
|
179
|
+
if (!props.selected)
|
|
180
|
+
return;
|
|
181
|
+
router.push(props.result.route);
|
|
182
|
+
emit("close");
|
|
183
|
+
});
|
|
184
|
+
const defaultIcons = {
|
|
185
|
+
story: "carbon:cube",
|
|
186
|
+
variant: "carbon:cube"
|
|
187
|
+
};
|
|
188
|
+
const kindLabels = {
|
|
189
|
+
story: "Story",
|
|
190
|
+
variant: "Variant"
|
|
191
|
+
};
|
|
192
|
+
return (_ctx, _cache) => {
|
|
193
|
+
return openBlock(), createElementBlock("div", {
|
|
194
|
+
ref_key: "el",
|
|
195
|
+
ref: el,
|
|
196
|
+
"data-test-id": "search-item",
|
|
197
|
+
"data-selected": unref(selected) ? "" : void 0
|
|
198
|
+
}, [
|
|
199
|
+
createVNode(BaseListItemLink, {
|
|
200
|
+
to: __props.result.route,
|
|
201
|
+
"is-active": unref(selected),
|
|
202
|
+
class: "htw-px-6 htw-py-4 htw-gap-4",
|
|
203
|
+
onNavigate: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
|
|
204
|
+
}, {
|
|
205
|
+
default: withCtx(() => {
|
|
206
|
+
var _a, _b;
|
|
207
|
+
return [
|
|
208
|
+
createVNode(unref(Icon), {
|
|
209
|
+
icon: (_a = __props.result.icon) != null ? _a : defaultIcons[__props.result.kind],
|
|
210
|
+
class: normalizeClass(["htw-w-4 htw-h-4", [
|
|
211
|
+
!unref(selected) ? [
|
|
212
|
+
__props.result.iconColor ? "bind-icon-color" : {
|
|
213
|
+
"htw-text-primary-500": __props.result.kind === "story",
|
|
214
|
+
"htw-text-gray-500": __props.result.kind === "variant"
|
|
215
|
+
}
|
|
216
|
+
] : []
|
|
217
|
+
]])
|
|
218
|
+
}, null, 8, ["icon", "class"]),
|
|
219
|
+
createElementVNode("div", _hoisted_2$1, [
|
|
220
|
+
createElementVNode("div", _hoisted_3, [
|
|
221
|
+
createTextVNode(toDisplayString(__props.result.title) + " ", 1),
|
|
222
|
+
createElementVNode("span", _hoisted_4, toDisplayString(kindLabels[__props.result.kind]), 1)
|
|
223
|
+
]),
|
|
224
|
+
((_b = __props.result.path) == null ? void 0 : _b.length) ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
225
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.result.path, (p, index) => {
|
|
226
|
+
return openBlock(), createElementBlock("div", {
|
|
227
|
+
key: index,
|
|
228
|
+
class: "htw-flex htw-items-center htw-gap-0.5"
|
|
229
|
+
}, [
|
|
230
|
+
index > 0 ? (openBlock(), createBlock(unref(Icon), {
|
|
231
|
+
key: 0,
|
|
232
|
+
icon: "carbon:chevron-right",
|
|
233
|
+
class: "htw-w-4 htw-h-4 htw-mt-0.5 htw-opacity-50"
|
|
234
|
+
})) : createCommentVNode("", true),
|
|
235
|
+
createElementVNode("span", null, toDisplayString(p), 1)
|
|
236
|
+
]);
|
|
237
|
+
}), 128))
|
|
238
|
+
])) : createCommentVNode("", true)
|
|
239
|
+
])
|
|
240
|
+
];
|
|
241
|
+
}),
|
|
242
|
+
_: 1
|
|
243
|
+
}, 8, ["to", "is-active"])
|
|
244
|
+
], 8, _hoisted_1$1);
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
var SearchItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-7856c5b0"]]);
|
|
249
|
+
const searchData = markRaw(searchData$1);
|
|
250
|
+
function onUpdate(cb) {
|
|
251
|
+
onUpdate$1(cb);
|
|
252
|
+
}
|
|
253
|
+
const _hoisted_1 = /* @__PURE__ */ createTextVNode(" No results ");
|
|
254
|
+
const _hoisted_2 = {
|
|
255
|
+
key: 1,
|
|
256
|
+
class: "htw-max-h-[400px] htw-overflow-y-auto htw-rounded-b-lg"
|
|
257
|
+
};
|
|
258
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
259
|
+
props: {
|
|
260
|
+
shown: {
|
|
261
|
+
type: Boolean,
|
|
262
|
+
default: false
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
emits: {
|
|
266
|
+
close: () => true
|
|
267
|
+
},
|
|
268
|
+
setup(__props, { emit }) {
|
|
269
|
+
const props = __props;
|
|
270
|
+
const DocSearchData = () => import("./search-docs-data.js");
|
|
271
|
+
function close() {
|
|
272
|
+
emit("close");
|
|
273
|
+
}
|
|
274
|
+
const input = ref();
|
|
275
|
+
const { focused } = useFocus(input, {
|
|
276
|
+
initialValue: true
|
|
277
|
+
});
|
|
278
|
+
watch(() => props.shown, (value) => {
|
|
279
|
+
if (value) {
|
|
280
|
+
requestAnimationFrame(() => {
|
|
281
|
+
focused.value = true;
|
|
282
|
+
input.value.select();
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
const searchInputText = ref("");
|
|
287
|
+
const rateLimitedSearch = useDebounce(searchInputText, 50);
|
|
288
|
+
const storyStore = useStoryStore();
|
|
289
|
+
let titleSearchIndex;
|
|
290
|
+
let titleIdMap;
|
|
291
|
+
function createIndex() {
|
|
292
|
+
return new flexsearch.Document({
|
|
293
|
+
preset: "match",
|
|
294
|
+
document: {
|
|
295
|
+
id: "id",
|
|
296
|
+
index: [
|
|
297
|
+
"text"
|
|
298
|
+
]
|
|
299
|
+
},
|
|
300
|
+
worker: true,
|
|
301
|
+
charset,
|
|
302
|
+
language,
|
|
303
|
+
tokenize: "forward"
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
async function loadSearchIndex(data) {
|
|
307
|
+
titleSearchIndex = createIndex();
|
|
308
|
+
for (const key of Object.keys(data.index)) {
|
|
309
|
+
await titleSearchIndex.import(key, data.index[key]);
|
|
310
|
+
}
|
|
311
|
+
titleIdMap = data.idMap;
|
|
312
|
+
}
|
|
313
|
+
loadSearchIndex(searchData);
|
|
314
|
+
onUpdate((searchData2) => {
|
|
315
|
+
loadSearchIndex(searchData2);
|
|
316
|
+
});
|
|
317
|
+
let docSearchIndex;
|
|
318
|
+
let docIdMap;
|
|
319
|
+
async function loadDocSearchIndex() {
|
|
320
|
+
async function load(data) {
|
|
321
|
+
docSearchIndex = createIndex();
|
|
322
|
+
for (const key of Object.keys(data.index)) {
|
|
323
|
+
await docSearchIndex.import(key, data.index[key]);
|
|
324
|
+
}
|
|
325
|
+
docIdMap = data.idMap;
|
|
326
|
+
if (rateLimitedSearch.value) {
|
|
327
|
+
searchOnDocField(rateLimitedSearch.value);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const searchDataModule = await DocSearchData();
|
|
331
|
+
load(searchDataModule.searchData);
|
|
332
|
+
searchDataModule.onUpdate((searchData2) => {
|
|
333
|
+
load(searchData2);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
loadDocSearchIndex();
|
|
337
|
+
const titleResults = ref([]);
|
|
338
|
+
watch(rateLimitedSearch, async (value) => {
|
|
339
|
+
const list = [];
|
|
340
|
+
const raw = await titleSearchIndex.search(value);
|
|
341
|
+
let rank = 0;
|
|
342
|
+
for (const field of raw) {
|
|
343
|
+
for (const id of field.result) {
|
|
344
|
+
const idMapData = titleIdMap[id];
|
|
345
|
+
if (!idMapData)
|
|
346
|
+
continue;
|
|
347
|
+
switch (idMapData.kind) {
|
|
348
|
+
case "story": {
|
|
349
|
+
list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank));
|
|
350
|
+
rank++;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case "variant": {
|
|
354
|
+
const [storyId] = idMapData.id.split(":");
|
|
355
|
+
const story = storyStore.getStoryById(storyId);
|
|
356
|
+
const variant = storyStore.getVariantById(idMapData.id);
|
|
357
|
+
list.push(variantResultFactory(story, variant, rank));
|
|
358
|
+
rank++;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
titleResults.value = list;
|
|
365
|
+
});
|
|
366
|
+
const docsResults = ref([]);
|
|
367
|
+
async function searchOnDocField(query) {
|
|
368
|
+
if (docSearchIndex) {
|
|
369
|
+
const list = [];
|
|
370
|
+
const raw = await docSearchIndex.search(query);
|
|
371
|
+
let rank = 0;
|
|
372
|
+
for (const field of raw) {
|
|
373
|
+
for (const id of field.result) {
|
|
374
|
+
const idMapData = docIdMap[id];
|
|
375
|
+
if (!idMapData)
|
|
376
|
+
continue;
|
|
377
|
+
switch (idMapData.kind) {
|
|
378
|
+
case "story": {
|
|
379
|
+
list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank));
|
|
380
|
+
rank++;
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
docsResults.value = list;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
watch(rateLimitedSearch, searchOnDocField);
|
|
390
|
+
function storyResultFactory(story, rank) {
|
|
391
|
+
return {
|
|
392
|
+
kind: "story",
|
|
393
|
+
rank,
|
|
394
|
+
id: `story:${story.id}`,
|
|
395
|
+
title: story.title,
|
|
396
|
+
route: {
|
|
397
|
+
name: "story",
|
|
398
|
+
params: {
|
|
399
|
+
storyId: story.id
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
path: story.file.path.slice(0, -1),
|
|
403
|
+
icon: story.icon,
|
|
404
|
+
iconColor: story.iconColor
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function variantResultFactory(story, variant, rank) {
|
|
408
|
+
var _a;
|
|
409
|
+
return {
|
|
410
|
+
kind: "variant",
|
|
411
|
+
rank,
|
|
412
|
+
id: `variant:${story.id}:${variant.id}`,
|
|
413
|
+
title: variant.title,
|
|
414
|
+
route: {
|
|
415
|
+
name: "story",
|
|
416
|
+
params: {
|
|
417
|
+
storyId: story.id
|
|
418
|
+
},
|
|
419
|
+
query: {
|
|
420
|
+
variantId: variant.id
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
path: [...(_a = story.file.path) != null ? _a : [], story.title],
|
|
424
|
+
icon: variant.icon,
|
|
425
|
+
iconColor: variant.iconColor
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
const results = computed(() => {
|
|
429
|
+
const list = [...titleResults.value];
|
|
430
|
+
const seen = {};
|
|
431
|
+
for (const r of titleResults.value) {
|
|
432
|
+
seen[r.id] = true;
|
|
433
|
+
}
|
|
434
|
+
for (const r of docsResults.value) {
|
|
435
|
+
if (!seen[r.id]) {
|
|
436
|
+
list.push(r);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return list;
|
|
440
|
+
});
|
|
441
|
+
const selectedIndex = ref(0);
|
|
442
|
+
watch(results, () => {
|
|
443
|
+
selectedIndex.value = 0;
|
|
444
|
+
});
|
|
445
|
+
function selectNext() {
|
|
446
|
+
selectedIndex.value++;
|
|
447
|
+
if (selectedIndex.value > results.value.length - 1) {
|
|
448
|
+
selectedIndex.value = 0;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function selectPrevious() {
|
|
452
|
+
selectedIndex.value--;
|
|
453
|
+
if (selectedIndex.value < 0) {
|
|
454
|
+
selectedIndex.value = results.value.length - 1;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return (_ctx, _cache) => {
|
|
458
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
459
|
+
createElementVNode("div", {
|
|
460
|
+
class: "htw-flex htw-items-center htw-gap-4 htw-pl-6 htw-border htw-border-transparent focus-visible:htw-border-primary-500",
|
|
461
|
+
onClick: _cache[4] || (_cache[4] = ($event) => focused.value = true)
|
|
462
|
+
}, [
|
|
463
|
+
createVNode(unref(Icon), {
|
|
464
|
+
icon: "carbon:search",
|
|
465
|
+
class: "flex-none htw-w-4 htw-h-4"
|
|
466
|
+
}),
|
|
467
|
+
withDirectives(createElementVNode("input", {
|
|
468
|
+
ref_key: "input",
|
|
469
|
+
ref: input,
|
|
470
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchInputText.value = $event),
|
|
471
|
+
placeholder: "Search for stories, variants...",
|
|
472
|
+
class: "htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none",
|
|
473
|
+
onKeydown: [
|
|
474
|
+
_cache[1] || (_cache[1] = withKeys(withModifiers(($event) => selectNext(), ["prevent"]), ["down"])),
|
|
475
|
+
_cache[2] || (_cache[2] = withKeys(withModifiers(($event) => selectPrevious(), ["prevent"]), ["up"])),
|
|
476
|
+
_cache[3] || (_cache[3] = withKeys(($event) => close(), ["escape"]))
|
|
477
|
+
]
|
|
478
|
+
}, null, 544), [
|
|
479
|
+
[vModelText, searchInputText.value]
|
|
480
|
+
])
|
|
481
|
+
]),
|
|
482
|
+
unref(rateLimitedSearch) && !unref(results).length ? (openBlock(), createBlock(BaseEmpty, {
|
|
483
|
+
key: 0,
|
|
484
|
+
class: "no-animation"
|
|
485
|
+
}, {
|
|
486
|
+
default: withCtx(() => [
|
|
487
|
+
_hoisted_1
|
|
488
|
+
]),
|
|
489
|
+
_: 1
|
|
490
|
+
})) : unref(results).length ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
491
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(results), (result, index) => {
|
|
492
|
+
return openBlock(), createBlock(SearchItem, {
|
|
493
|
+
key: result.id,
|
|
494
|
+
result,
|
|
495
|
+
selected: index === selectedIndex.value,
|
|
496
|
+
onClose: _cache[5] || (_cache[5] = ($event) => close())
|
|
497
|
+
}, null, 8, ["result", "selected"]);
|
|
498
|
+
}), 128))
|
|
499
|
+
])) : createCommentVNode("", true)
|
|
500
|
+
], 64);
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
export { _sfc_main as default };
|