@histoire/controls 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/histoire-dist/__sandbox.html +15 -0
  2. package/histoire-dist/assets/BaseEmpty.a84c14c8.js +1 -0
  3. package/histoire-dist/assets/HomeView.f524bd4b.js +1 -0
  4. package/histoire-dist/assets/HstCheckbox.story.9f622545.js +1 -0
  5. package/histoire-dist/assets/HstInput.story.945401ce.js +1 -0
  6. package/histoire-dist/assets/SearchModal.76c035f2.js +1 -0
  7. package/histoire-dist/assets/StoryView.e4c41518.js +15 -0
  8. package/histoire-dist/assets/global-components.84d0ab22.js +1 -0
  9. package/histoire-dist/assets/histoire-text-dark.a529813a.svg +89 -0
  10. package/histoire-dist/assets/histoire-text.1d4474b5.svg +89 -0
  11. package/{.histoire/dist/histoire.svg → histoire-dist/assets/histoire.8af7bd1f.svg} +0 -0
  12. package/histoire-dist/assets/index.58f51dd0.js +1 -0
  13. package/histoire-dist/assets/preview-settings.a634d101.js +1 -0
  14. package/histoire-dist/assets/sandbox.2c60450a.js +1 -0
  15. package/histoire-dist/assets/style.7657d2ac.css +1 -0
  16. package/histoire-dist/assets/vendor.70a554f6.js +9 -0
  17. package/histoire-dist/index.html +15 -0
  18. package/package.json +2 -2
  19. package/.histoire/dist/__sandbox.html +0 -16
  20. package/.histoire/dist/assets/BaseEmpty.d30f3079.js +0 -11
  21. package/.histoire/dist/assets/HomeView.8e044be6.js +0 -24
  22. package/.histoire/dist/assets/HstCheckbox.story.3d04d85b.js +0 -144
  23. package/.histoire/dist/assets/HstColorShades.story.68cf74d1.js +0 -532
  24. package/.histoire/dist/assets/HstCopyIcon.e40e725e.js +0 -51
  25. package/.histoire/dist/assets/HstNumber.story.1e1964ff.js +0 -160
  26. package/.histoire/dist/assets/HstSelect.story.04860383.js +0 -277
  27. package/.histoire/dist/assets/HstText.story.c915d831.js +0 -137
  28. package/.histoire/dist/assets/HstTextarea.story.802b9c26.js +0 -105
  29. package/.histoire/dist/assets/HstTokenGrid.story.025819d6.js +0 -148
  30. package/.histoire/dist/assets/HstTokenList.story.d3aa6575.js +0 -176
  31. package/.histoire/dist/assets/HstWrapper.246b6982.js +0 -56
  32. package/.histoire/dist/assets/SearchPane.daa2675c.js +0 -426
  33. package/.histoire/dist/assets/StoryView.2f64dad1.js +0 -2260
  34. package/.histoire/dist/assets/bundle-main.784e5bf7.js +0 -1156
  35. package/.histoire/dist/assets/bundle-sandbox.5e153933.js +0 -84
  36. package/.histoire/dist/assets/const.268165fd.js +0 -658
  37. package/.histoire/dist/assets/global-components.6736b2a9.js +0 -5722
  38. package/.histoire/dist/assets/search-docs-data.b9a75539.js +0 -6
  39. package/.histoire/dist/assets/style.04507241.css +0 -2504
  40. package/.histoire/dist/assets/vendor.2833ae3d.js +0 -28970
  41. package/.histoire/dist/index.html +0 -16
@@ -1,426 +0,0 @@
1
- import { _ as __vitePreload } from "./global-components.6736b2a9.js";
2
- import { a9 as markRaw, d as defineComponent, r as ref, ah as useFocus, w as watch, ai as refDebounced, c as computed, a as openBlock, b as createElementBlock, e as createBaseVNode, l as createVNode, i as unref, I as Icon, M as withDirectives, Z as vModelText, v as withKeys, g as withModifiers, j as createBlock, k as withCtx, F as Fragment, J as renderList, m as createCommentVNode, R as createTextVNode, aj as flexsearch, Q as useCssVars, ak as toRefs, al as useRouter, n as normalizeClass, t as toDisplayString } from "./vendor.2833ae3d.js";
3
- import { u as useStoryStore, _ as _export_sfc, a as useScrollOnActive, o as onKeyboardShortcut, B as BaseListItemLink } from "./bundle-main.784e5bf7.js";
4
- import { B as BaseEmpty } from "./BaseEmpty.d30f3079.js";
5
- let searchData$1 = { "index": { "reg": '{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1}', "text.cfg": '{"doc":0,"opt":1}', "text.map": '[{"s":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"st":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"t":[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"ta":[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"tal":[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"talf":[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"talfe":[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"talfem":[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"talfemt":[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42]},{"k":[0,1,2,3,4,5,6,7,8],"ke":[0,1],"kek":[0,1],"kekp":[0,1],"kekpo":[0,1],"kekpos":[0,1],"ko":[2,3,4,5,6,7,8],"kol":[2,3,4,5,6,7,8],"kolo":[2,3,4,5,6,7,8],"kolor":[2,3,4,5,6,7,8],"t":[9,10,11,12,21,22,23,24,25],"to":[9,10,11,12],"tok":[9,10,11,12],"toke":[9,10,11,12],"tokem":[9,10,11,12],"m":[13,14,31],"mo":[13,14],"mom":[13,14],"momp":[13,14],"mompe":[13,14],"momper":[13,14],"se":[15,16,17,18,19,20],"sel":[15,16,17,18,19,20],"sele":[15,16,17,18,19,20],"selek":[15,16,17,18,19,20],"selekt":[15,16,17,18,19,20],"te":[21,22,23,24,25,28],"tes":[21,22,23,24,25,28],"test":[21,22,23,24,25,28],"testa":[21,22],"testar":[21,22],"testare":[21,22],"testarea":[21,22],"p":[27,29,30,38,39],"pa":[27,30],"pak":[27],"pakr":[27],"pakro":[27],"pakrom":[27],"pakromt":[27],"po":[29,38,39],"por":[29,38,39],"port":[29,38,39],"porte":[29,38,39],"porter":[29,38,39],"pat":[30],"pate":[30],"patem":[30],"patemk":[30],"ma":[31],"mar":[31],"mark":[31],"marke":[31],"markem":[31],"f":[32,33,34,40,42],"fo":[32,33,34,42],"fom":[32,33,34],"fomt":[32,33,34],"l":[35,36],"le":[35,36],"let":[35],"lete":[35],"leter":[35],"lem":[36],"leme":[36],"tr":[37],"tro":[37],"trop":[37],"fe":[40],"fet":[40],"e":[41],"ek":[41],"ekt":[41],"fol":[42]},{"p":[1],"pl":[1],"pla":[1],"plak":[1],"plakr":[1],"plakro":[1],"plakrom":[1],"plakromt":[1],"sa":[2,3,4,5,6,7,8,37],"sat":[2,3,4,5,6,7,8,37],"sate":[2,3,4,5,6,7,8],"sates":[2,3,4,5,6,7,8],"k":[9,10,27,28,29,42],"kr":[9,10],"kre":[9,10],"kret":[9,10],"l":[11,12],"le":[11,12],"les":[11,12],"lest":[11,12],"t":[14,16],"te":[14,16],"tef":[14,16,22,24],"tefa":[14,16,22,24],"tefao":[14,16,22,24],"tefaol":[14,16,22,24],"tefaolt":[14,16,22,24],"m":[17,25],"mo":[17,25],"o":[18,19,20],"op":[18,19,20],"opt":[18,19,20],"opte":[18,19,20],"opteo":[18,19,20],"opteom":[18,19,20],"opteoms":[18,19,20],"ko":[27,28,29,42],"kol":[27,28,29],"kolo":[27,28,29],"kolor":[27,28,29],"s":[32,35,37],"se":[32],"ses":[32],"sese":[32],"fe":[33,39],"fek":[33],"fekt":[33],"fa":[34],"fam":[34],"fame":[34],"famel":[34],"famele":[34],"sp":[35],"spa":[35],"spak":[35],"spake":[35],"spakem":[35],"spakemk":[35],"e":[36],"ek":[36],"ekt":[36],"sato":[37],"satof":[37],"r":[38],"ra":[38],"rat":[38],"rate":[38],"rateo":[38],"rateos":[38],"f":[39],"fet":[39],"kom":[42],"komf":[42],"komfe":[42],"komfek":[42]},{"t":[3,5],"te":[3,5,10,12],"tef":[3,10,12],"tefa":[3,10,12],"tefao":[3,10,12],"tefaol":[3,10,12],"tefaolt":[3,10,12],"p":[4,6],"pa":[4],"pak":[4],"pakr":[4],"pakro":[4],"pakrom":[4],"pakromt":[4],"tes":[5],"test":[5],"po":[6],"por":[6],"port":[6],"porte":[6],"porter":[6],"f":[7],"fe":[7],"fet":[7],"l":[8,17,25],"lo":[8],"lom":[8],"lomk":[8],"la":[17,25],"lap":[17,25],"lape":[17,25],"lapel":[17,25],"a":[18,19,20],"as":[18,19,20]},{"se":[7],"sea":[7],"sear":[7],"seark":[7],"m":[8],"ma":[8],"mam":[8],"mame":[8],"mames":[8],"opk":[18],"opke":[18],"opkek":[18],"opkekt":[18],"ar":[19,20],"ara":[19,20]},{"of":[19,20]},{"opk":[19],"opke":[19],"opkek":[19],"opkekt":[19],"opkekts":[19],"str":[20],"stre":[20],"strem":[20],"stremk":[20],"stremks":[20]},{},{}]', "text.ctx": "[{}]" }, "idMap": { "0": { "id": "src-components-checkbox-hstcheckbox-story-vue", "kind": "story" }, "1": { "id": "src-components-checkbox-hstcheckbox-story-vue:src-components-checkbox-hstcheckbox-story-vue-0", "kind": "variant" }, "2": { "id": "src-components-design-tokens-hstcolorshades-story-vue", "kind": "story" }, "3": { "id": "src-components-design-tokens-hstcolorshades-story-vue:src-components-design-tokens-hstcolorshades-story-vue-0", "kind": "variant" }, "4": { "id": "src-components-design-tokens-hstcolorshades-story-vue:src-components-design-tokens-hstcolorshades-story-vue-1", "kind": "variant" }, "5": { "id": "src-components-design-tokens-hstcolorshades-story-vue:src-components-design-tokens-hstcolorshades-story-vue-2", "kind": "variant" }, "6": { "id": "src-components-design-tokens-hstcolorshades-story-vue:src-components-design-tokens-hstcolorshades-story-vue-3", "kind": "variant" }, "7": { "id": "src-components-design-tokens-hstcolorshades-story-vue:src-components-design-tokens-hstcolorshades-story-vue-4", "kind": "variant" }, "8": { "id": "src-components-design-tokens-hstcolorshades-story-vue:src-components-design-tokens-hstcolorshades-story-vue-5", "kind": "variant" }, "9": { "id": "src-components-design-tokens-hsttokengrid-story-vue", "kind": "story" }, "10": { "id": "src-components-design-tokens-hsttokengrid-story-vue:src-components-design-tokens-hsttokengrid-story-vue-0", "kind": "variant" }, "11": { "id": "src-components-design-tokens-hsttokenlist-story-vue", "kind": "story" }, "12": { "id": "src-components-design-tokens-hsttokenlist-story-vue:src-components-design-tokens-hsttokenlist-story-vue-0", "kind": "variant" }, "13": { "id": "src-components-number-hstnumber-story-vue", "kind": "story" }, "14": { "id": "src-components-number-hstnumber-story-vue:src-components-number-hstnumber-story-vue-0", "kind": "variant" }, "15": { "id": "src-components-select-hstselect-story-vue", "kind": "story" }, "16": { "id": "src-components-select-hstselect-story-vue:src-components-select-hstselect-story-vue-0", "kind": "variant" }, "17": { "id": "src-components-select-hstselect-story-vue:src-components-select-hstselect-story-vue-1", "kind": "variant" }, "18": { "id": "src-components-select-hstselect-story-vue:src-components-select-hstselect-story-vue-2", "kind": "variant" }, "19": { "id": "src-components-select-hstselect-story-vue:src-components-select-hstselect-story-vue-3", "kind": "variant" }, "20": { "id": "src-components-select-hstselect-story-vue:src-components-select-hstselect-story-vue-4", "kind": "variant" }, "21": { "id": "src-components-textarea-hsttextarea-story-vue", "kind": "story" }, "22": { "id": "src-components-textarea-hsttextarea-story-vue:src-components-textarea-hsttextarea-story-vue-0", "kind": "variant" }, "23": { "id": "src-components-text-hsttext-story-vue", "kind": "story" }, "24": { "id": "src-components-text-hsttext-story-vue:src-components-text-hsttext-story-vue-0", "kind": "variant" }, "25": { "id": "src-components-text-hsttext-story-vue:src-components-text-hsttext-story-vue-1", "kind": "variant" }, "26": { "id": "tailwind", "kind": "story" }, "27": { "id": "tailwind:background-color", "kind": "variant" }, "28": { "id": "tailwind:text-color", "kind": "variant" }, "29": { "id": "tailwind:border-color", "kind": "variant" }, "30": { "id": "tailwind:padding", "kind": "variant" }, "31": { "id": "tailwind:margin", "kind": "variant" }, "32": { "id": "tailwind:font-size", "kind": "variant" }, "33": { "id": "tailwind:font-weight", "kind": "variant" }, "34": { "id": "tailwind:font-family", "kind": "variant" }, "35": { "id": "tailwind:letter-spacing", "kind": "variant" }, "36": { "id": "tailwind:line-height", "kind": "variant" }, "37": { "id": "tailwind:drop-shadow", "kind": "variant" }, "38": { "id": "tailwind:border-radius", "kind": "variant" }, "39": { "id": "tailwind:border-width", "kind": "variant" }, "40": { "id": "tailwind:width", "kind": "variant" }, "41": { "id": "tailwind:height", "kind": "variant" }, "42": { "id": "tailwind:full-config", "kind": "variant" } } };
6
- function pipeline(a, b, c, d) {
7
- 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 === "")) {
8
- const b2 = a.split(c);
9
- return this.filter ? filter$1(b2, this.filter) : b2;
10
- }
11
- return a;
12
- }
13
- const regex_whitespace = /[\p{Z}\p{S}\p{P}\p{C}]+/u;
14
- const regex_normalize = /[\u0300-\u036f]/g;
15
- function normalize(a) {
16
- return a.normalize && (a = a.normalize("NFD").replace(regex_normalize, "")), a;
17
- }
18
- function replace(a, b) {
19
- for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), !!a); c += 2)
20
- ;
21
- return a;
22
- }
23
- function regex(a) {
24
- return new RegExp(a, "g");
25
- }
26
- function collapse(a) {
27
- let b = "", c = "";
28
- for (let d, e = 0, f = a.length; e < f; e++)
29
- (d = a[e]) !== c && (b += c = d);
30
- return b;
31
- }
32
- function filter$1(a, b) {
33
- const c = a.length, d = [];
34
- for (let e = 0, f = 0; e < c; e++) {
35
- const c2 = a[e];
36
- c2 && !b[c2] && (d[f++] = c2);
37
- }
38
- return d;
39
- }
40
- 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 "];
41
- function encode$2(a) {
42
- return a = "" + a, pipeline.call(this, normalize(a).toLowerCase(), !a.normalize && pairs$1, regex_whitespace, false);
43
- }
44
- 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" };
45
- function encode$1(a) {
46
- a = encode$2.call(this, a).join(" ");
47
- const b = [];
48
- if (a) {
49
- const c = a.split(regex_strip), d = c.length;
50
- for (let e, f = 0, g = 0; f < d; f++)
51
- if ((a = c[f]) && (!this.filter || !this.filter[a])) {
52
- e = a[0];
53
- let c2 = soundex[e] || e, d2 = c2;
54
- for (let b2 = 1; b2 < a.length; b2++) {
55
- e = a[b2];
56
- const f2 = soundex[e] || e;
57
- f2 && f2 !== d2 && (c2 += f2, d2 = f2);
58
- }
59
- b[g++] = c2;
60
- }
61
- }
62
- return b;
63
- }
64
- var charset = { encode, rtl: false, tokenize: "" };
65
- 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])"), ""];
66
- function encode(a, b) {
67
- 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;
68
- }
69
- 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"];
70
- 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: "" };
71
- const matcher = {};
72
- var language = { filter, stemmer, matcher };
73
- const _hoisted_1$1 = ["data-selected"];
74
- const _hoisted_2$1 = { class: "htw-flex-1" };
75
- const _hoisted_3 = { class: "htw-flex" };
76
- const _hoisted_4 = { class: "htw-ml-auto htw-opacity-40" };
77
- const _hoisted_5 = {
78
- key: 0,
79
- class: "htw-flex htw-items-center htw-gap-0.5 htw-opacity-60"
80
- };
81
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
82
- name: "SearchItem",
83
- props: {
84
- result: {
85
- type: Object,
86
- required: true
87
- },
88
- selected: {
89
- type: Boolean,
90
- default: false
91
- }
92
- },
93
- emits: {
94
- close: () => true
95
- },
96
- setup(__props, { emit }) {
97
- const props = __props;
98
- useCssVars((_ctx) => ({
99
- "0e1c785e": __props.result.iconColor
100
- }));
101
- const el = ref();
102
- const { selected } = toRefs(props);
103
- useScrollOnActive(selected, el);
104
- const router = useRouter();
105
- onKeyboardShortcut(["enter"], () => {
106
- if (!props.selected)
107
- return;
108
- router.push(props.result.route);
109
- emit("close");
110
- });
111
- const defaultIcons = {
112
- story: "carbon:cube",
113
- variant: "carbon:cube"
114
- };
115
- const kindLabels = {
116
- story: "Story",
117
- variant: "Variant"
118
- };
119
- return (_ctx, _cache) => {
120
- return openBlock(), createElementBlock("div", {
121
- ref_key: "el",
122
- ref: el,
123
- "data-test-id": "search-item",
124
- "data-selected": unref(selected) ? "" : void 0
125
- }, [
126
- createVNode(BaseListItemLink, {
127
- to: __props.result.route,
128
- "is-active": unref(selected),
129
- class: "htw-px-6 htw-py-4 htw-gap-4",
130
- onNavigate: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
131
- }, {
132
- default: withCtx(() => {
133
- var _a, _b;
134
- return [
135
- createVNode(unref(Icon), {
136
- icon: (_a = __props.result.icon) != null ? _a : defaultIcons[__props.result.kind],
137
- class: normalizeClass(["htw-w-4 htw-h-4", [
138
- !unref(selected) ? [
139
- __props.result.iconColor ? "bind-icon-color" : {
140
- "htw-text-primary-500": __props.result.kind === "story",
141
- "htw-text-gray-500": __props.result.kind === "variant"
142
- }
143
- ] : []
144
- ]])
145
- }, null, 8, ["icon", "class"]),
146
- createBaseVNode("div", _hoisted_2$1, [
147
- createBaseVNode("div", _hoisted_3, [
148
- createTextVNode(toDisplayString(__props.result.title) + " ", 1),
149
- createBaseVNode("span", _hoisted_4, toDisplayString(kindLabels[__props.result.kind]), 1)
150
- ]),
151
- ((_b = __props.result.path) == null ? void 0 : _b.length) ? (openBlock(), createElementBlock("div", _hoisted_5, [
152
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.result.path, (p, index) => {
153
- return openBlock(), createElementBlock("div", {
154
- key: index,
155
- class: "htw-flex htw-items-center htw-gap-0.5"
156
- }, [
157
- index > 0 ? (openBlock(), createBlock(unref(Icon), {
158
- key: 0,
159
- icon: "carbon:chevron-right",
160
- class: "htw-w-4 htw-h-4 htw-mt-0.5 htw-opacity-50"
161
- })) : createCommentVNode("", true),
162
- createBaseVNode("span", null, toDisplayString(p), 1)
163
- ]);
164
- }), 128))
165
- ])) : createCommentVNode("", true)
166
- ])
167
- ];
168
- }),
169
- _: 1
170
- }, 8, ["to", "is-active"])
171
- ], 8, _hoisted_1$1);
172
- };
173
- }
174
- });
175
- var SearchItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-7856c5b0"]]);
176
- const searchData = markRaw(searchData$1);
177
- const _hoisted_1 = /* @__PURE__ */ createTextVNode(" No results ");
178
- const _hoisted_2 = {
179
- key: 1,
180
- class: "htw-max-h-[400px] htw-overflow-y-auto htw-rounded-b-lg"
181
- };
182
- const _sfc_main = /* @__PURE__ */ defineComponent({
183
- name: "SearchPane",
184
- props: {
185
- shown: {
186
- type: Boolean,
187
- default: false
188
- }
189
- },
190
- emits: {
191
- close: () => true
192
- },
193
- setup(__props, { emit }) {
194
- const props = __props;
195
- const DocSearchData = () => __vitePreload(() => import("./search-docs-data.b9a75539.js"), true ? ["assets/search-docs-data.b9a75539.js","assets/vendor.2833ae3d.js"] : void 0);
196
- function close() {
197
- emit("close");
198
- }
199
- const input = ref();
200
- const { focused } = useFocus(input, {
201
- initialValue: true
202
- });
203
- watch(() => props.shown, (value) => {
204
- if (value) {
205
- requestAnimationFrame(() => {
206
- focused.value = true;
207
- input.value.select();
208
- });
209
- }
210
- });
211
- const searchInputText = ref("");
212
- const rateLimitedSearch = refDebounced(searchInputText, 50);
213
- const storyStore = useStoryStore();
214
- let titleSearchIndex;
215
- let titleIdMap;
216
- function createIndex() {
217
- return new flexsearch.Document({
218
- preset: "match",
219
- document: {
220
- id: "id",
221
- index: [
222
- "text"
223
- ]
224
- },
225
- worker: true,
226
- charset,
227
- language,
228
- tokenize: "forward"
229
- });
230
- }
231
- async function loadSearchIndex(data) {
232
- titleSearchIndex = createIndex();
233
- for (const key of Object.keys(data.index)) {
234
- await titleSearchIndex.import(key, data.index[key]);
235
- }
236
- titleIdMap = data.idMap;
237
- }
238
- loadSearchIndex(searchData);
239
- let docSearchIndex;
240
- let docIdMap;
241
- async function loadDocSearchIndex() {
242
- async function load(data) {
243
- docSearchIndex = createIndex();
244
- for (const key of Object.keys(data.index)) {
245
- await docSearchIndex.import(key, data.index[key]);
246
- }
247
- docIdMap = data.idMap;
248
- if (rateLimitedSearch.value) {
249
- searchOnDocField(rateLimitedSearch.value);
250
- }
251
- }
252
- const searchDataModule = await DocSearchData();
253
- load(searchDataModule.searchData);
254
- searchDataModule.onUpdate((searchData2) => {
255
- load(searchData2);
256
- });
257
- }
258
- loadDocSearchIndex();
259
- const titleResults = ref([]);
260
- watch(rateLimitedSearch, async (value) => {
261
- const list = [];
262
- const raw = await titleSearchIndex.search(value);
263
- let rank = 0;
264
- for (const field of raw) {
265
- for (const id of field.result) {
266
- const idMapData = titleIdMap[id];
267
- if (!idMapData)
268
- continue;
269
- switch (idMapData.kind) {
270
- case "story": {
271
- list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank));
272
- rank++;
273
- break;
274
- }
275
- case "variant": {
276
- const [storyId] = idMapData.id.split(":");
277
- const story = storyStore.getStoryById(storyId);
278
- const variant = storyStore.getVariantById(idMapData.id);
279
- list.push(variantResultFactory(story, variant, rank));
280
- rank++;
281
- break;
282
- }
283
- }
284
- }
285
- }
286
- titleResults.value = list;
287
- });
288
- const docsResults = ref([]);
289
- async function searchOnDocField(query) {
290
- if (docSearchIndex) {
291
- const list = [];
292
- const raw = await docSearchIndex.search(query);
293
- let rank = 0;
294
- for (const field of raw) {
295
- for (const id of field.result) {
296
- const idMapData = docIdMap[id];
297
- if (!idMapData)
298
- continue;
299
- switch (idMapData.kind) {
300
- case "story": {
301
- list.push(storyResultFactory(storyStore.getStoryById(idMapData.id), rank));
302
- rank++;
303
- break;
304
- }
305
- }
306
- }
307
- }
308
- docsResults.value = list;
309
- }
310
- }
311
- watch(rateLimitedSearch, searchOnDocField);
312
- function storyResultFactory(story, rank) {
313
- return {
314
- kind: "story",
315
- rank,
316
- id: `story:${story.id}`,
317
- title: story.title,
318
- route: {
319
- name: "story",
320
- params: {
321
- storyId: story.id
322
- }
323
- },
324
- path: story.file.path.slice(0, -1),
325
- icon: story.icon,
326
- iconColor: story.iconColor
327
- };
328
- }
329
- function variantResultFactory(story, variant, rank) {
330
- var _a;
331
- return {
332
- kind: "variant",
333
- rank,
334
- id: `variant:${story.id}:${variant.id}`,
335
- title: variant.title,
336
- route: {
337
- name: "story",
338
- params: {
339
- storyId: story.id
340
- },
341
- query: {
342
- variantId: variant.id
343
- }
344
- },
345
- path: [...(_a = story.file.path) != null ? _a : [], story.title],
346
- icon: variant.icon,
347
- iconColor: variant.iconColor
348
- };
349
- }
350
- const results = computed(() => {
351
- const list = [...titleResults.value];
352
- const seen = {};
353
- for (const r of titleResults.value) {
354
- seen[r.id] = true;
355
- }
356
- for (const r of docsResults.value) {
357
- if (!seen[r.id]) {
358
- list.push(r);
359
- }
360
- }
361
- return list;
362
- });
363
- const selectedIndex = ref(0);
364
- watch(results, () => {
365
- selectedIndex.value = 0;
366
- });
367
- function selectNext() {
368
- selectedIndex.value++;
369
- if (selectedIndex.value > results.value.length - 1) {
370
- selectedIndex.value = 0;
371
- }
372
- }
373
- function selectPrevious() {
374
- selectedIndex.value--;
375
- if (selectedIndex.value < 0) {
376
- selectedIndex.value = results.value.length - 1;
377
- }
378
- }
379
- return (_ctx, _cache) => {
380
- return openBlock(), createElementBlock(Fragment, null, [
381
- createBaseVNode("div", {
382
- class: "htw-flex htw-items-center htw-gap-4 htw-pl-6 htw-border htw-border-transparent focus-visible:htw-border-primary-500",
383
- onClick: _cache[4] || (_cache[4] = ($event) => focused.value = true)
384
- }, [
385
- createVNode(unref(Icon), {
386
- icon: "carbon:search",
387
- class: "flex-none htw-w-4 htw-h-4"
388
- }),
389
- withDirectives(createBaseVNode("input", {
390
- ref_key: "input",
391
- ref: input,
392
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchInputText.value = $event),
393
- placeholder: "Search for stories, variants...",
394
- class: "htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none",
395
- onKeydown: [
396
- _cache[1] || (_cache[1] = withKeys(withModifiers(($event) => selectNext(), ["prevent"]), ["down"])),
397
- _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => selectPrevious(), ["prevent"]), ["up"])),
398
- _cache[3] || (_cache[3] = withKeys(($event) => close(), ["escape"]))
399
- ]
400
- }, null, 544), [
401
- [vModelText, searchInputText.value]
402
- ])
403
- ]),
404
- unref(rateLimitedSearch) && !unref(results).length ? (openBlock(), createBlock(BaseEmpty, {
405
- key: 0,
406
- class: "no-animation"
407
- }, {
408
- default: withCtx(() => [
409
- _hoisted_1
410
- ]),
411
- _: 1
412
- })) : unref(results).length ? (openBlock(), createElementBlock("div", _hoisted_2, [
413
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(results), (result, index) => {
414
- return openBlock(), createBlock(SearchItem, {
415
- key: result.id,
416
- result,
417
- selected: index === selectedIndex.value,
418
- onClose: _cache[5] || (_cache[5] = ($event) => close())
419
- }, null, 8, ["result", "selected"]);
420
- }), 128))
421
- ])) : createCommentVNode("", true)
422
- ], 64);
423
- };
424
- }
425
- });
426
- export { _sfc_main as default };