@expo/styleguide-search-ui 1.0.0-alpha.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Expo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @expo/styleguide-search-ui
2
+
3
+ Expo's common search component for use on the web.
4
+
5
+ ## Usage
6
+
7
+ 1. Install Expo Search UI package:
8
+ ```shell
9
+ yarn add @expo/styleguide-search-ui
10
+ ```
11
+ 2. Import global CSS files from the package in your JS(X)/TS(X) code:
12
+ ```jsx
13
+ import "@expo/styleguide-search-ui/dist/expo-search-ui.css";
14
+ ```
15
+ or import it the main stylesheet file:
16
+ ```css
17
+ @import "@expo/styleguide-search-ui/dist/expo-search-ui.css";
18
+ ```
19
+ 3. Add `'./node_modules/@expo/styleguide-search-ui/dist/**/*.{js,ts,jsx,tsx}'` to the Tailwind `content` paths.
20
+
21
+ ## Development
22
+
23
+ ### Get started
24
+
25
+ 1. Install dependencies with `yarn`.
26
+ 2. Build everything with `yarn build`.
27
+ 3. Develop with `yarn dev`.
@@ -0,0 +1,212 @@
1
+ @keyframes searchUIBarLoader {
2
+ 0% {
3
+ width: 0;
4
+ }
5
+ 80% {
6
+ width: 100%;
7
+ opacity: 1;
8
+ }
9
+ 100% {
10
+ width: 100%;
11
+ opacity: 0;
12
+ }
13
+ }
14
+
15
+ #__next[aria-hidden] {
16
+ filter: blur(3.33px);
17
+ }
18
+
19
+ [cmdk-overlay] {
20
+ background-color: rgba(0, 0, 0, 0.33);
21
+ height: 100vh;
22
+ left: 0;
23
+ position: fixed;
24
+ top: 0;
25
+ width: 100vw;
26
+ z-index: 200;
27
+ }
28
+
29
+ @media screen and (max-width: 788px) {
30
+ [cmdk-overlay] {
31
+ display: none;
32
+ }
33
+ }
34
+
35
+ [cmdk-root] {
36
+ position: fixed;
37
+ top: 45%;
38
+ left: 50%;
39
+ transform: translate(-50%, -50%);
40
+ min-height: 75vh;
41
+ max-height: 75vh;
42
+ background: var(--expo-theme-background-default);
43
+ border-radius: 10px;
44
+ box-shadow: var(--expo-theme-shadows-sm);
45
+ width: 40vw;
46
+ min-width: 680px;
47
+ border: 1px solid var(--expo-theme-border-default);
48
+ z-index: 1001;
49
+ }
50
+
51
+ @media screen and (max-width: 788px) {
52
+ [cmdk-root] {
53
+ top: 50%;
54
+ width: 96vw;
55
+ min-width: 96vw;
56
+ min-height: 96dvh;
57
+ max-height: 96dvh;
58
+ }
59
+ }
60
+
61
+ [cmdk-root] kbd, #cmdk-trigger kbd {
62
+ font-size: 0.8125rem;
63
+ line-height: 19px;
64
+ letter-spacing: -0.003rem;
65
+ background-color: var(--expo-theme-background-subtle);
66
+ border: 1px solid var(--expo-theme-border-default);
67
+ white-space: pre-wrap;
68
+ font-weight: 500;
69
+ color: var(--expo-theme-text-secondary);
70
+ padding: 0 4px;
71
+ box-shadow: 0 0.1rem 0 1px var(--expo-theme-border-default);
72
+ border-radius: 4px;
73
+ position: relative;
74
+ display: inline-flex;
75
+ min-width: 22px;
76
+ justify-content: center;
77
+ top: -1px;
78
+ }
79
+
80
+ [cmdk-input] {
81
+ appearance: none;
82
+ background: transparent;
83
+ color: var(--expo-theme-text-default);
84
+ flex: 1;
85
+ font: inherit;
86
+ height: 100%;
87
+ outline: none;
88
+ padding: 12px 44px;
89
+ margin: 16px 16px 0;
90
+ border: 1px solid var(--expo-theme-border-default);
91
+ border-radius: 6px;
92
+ width: calc(100% - 32px);
93
+ box-sizing: border-box;
94
+ box-shadow: var(--expo-theme-shadows-xs);
95
+ }
96
+
97
+ [cmdk-input]::placeholder {
98
+ color: var(--expo-theme-icon-secondary);
99
+ }
100
+
101
+ [cmdk-item] {
102
+ content-visibility: auto;
103
+ cursor: pointer;
104
+ min-height: 52px;
105
+ border-radius: 6px;
106
+ display: flex;
107
+ flex-direction: column;
108
+ justify-content: center;
109
+ padding: 4px 12px;
110
+ color: var(--expo-theme-text-default);
111
+ user-select: none;
112
+ will-change: background, color;
113
+ transition: all 150ms ease;
114
+ transition-property: none;
115
+ }
116
+
117
+ [cmdk-item][aria-selected='true'],
118
+ [cmdk-item]:active {
119
+ background: var(--expo-theme-background-element);
120
+ color: var(--expo-theme-text-default);
121
+ }
122
+
123
+ [cmdk-item][aria-disabled='true'] {
124
+ color: var(--expo-theme-icon-secondary);
125
+ cursor: not-allowed;
126
+ }
127
+
128
+ [cmdk-item] + [cmdk-item] {
129
+ margin-top: 4px;
130
+ }
131
+
132
+ [cmdk-item][data-nested] + [cmdk-item] {
133
+ margin-top: 8px;
134
+ }
135
+
136
+ [cmdk-item] mark {
137
+ color: var(--blue12);
138
+ background: var(--blue4);
139
+ border-radius: 2px;
140
+ opacity: 0.85;
141
+ }
142
+
143
+ [cmdk-list] {
144
+ height: calc(75vh - 50px - 50px - 20px);
145
+ max-height: calc(75vh - 50px - 50px - 20px);
146
+ overflow: auto;
147
+ overscroll-behavior: contain;
148
+ border-top: 1px solid var(--expo-theme-border-default);
149
+ border-bottom: 1px solid var(--expo-theme-border-default);
150
+ padding: 0 16px;
151
+ margin: 12px 0 0;
152
+ }
153
+
154
+ @media screen and (max-width: 788px) {
155
+ [cmdk-list] {
156
+ height: calc(96dvh - 50px - 50px - 20px);
157
+ max-height: calc(96dvh - 50px - 50px - 20px);
158
+ }
159
+ }
160
+
161
+ [cmdk-separator] {
162
+ height: 1px;
163
+ width: 100%;
164
+ background: var(--expo-theme-border-default);
165
+ margin: 4px 0;
166
+ }
167
+
168
+ [cmdk-group-heading] {
169
+ font-size: 0.75rem;
170
+ line-height: 1.58;
171
+ user-select: none;
172
+ color: var(--expo-theme-text-secondary);
173
+ padding: 16px 8px 8px;
174
+ display: flex;
175
+ align-items: center;
176
+ gap: 4px;
177
+ margin: 0 2px;
178
+ }
179
+
180
+ [cmdk-empty] {
181
+ display: flex;
182
+ align-items: center;
183
+ justify-content: center;
184
+ white-space: pre-wrap;
185
+ padding: 32px 0;
186
+ }
187
+
188
+ html.dark-theme [cmdk-item] mark {
189
+ background: var(--blue6);
190
+ }
191
+
192
+ html.dark-theme [cmdk-item][data-selected='true'] mark {
193
+ background: var(--blue7);
194
+ }
195
+
196
+ [cmdk-list]::-webkit-scrollbar {
197
+ width: 6px;
198
+ }
199
+
200
+ [cmdk-list]::-webkit-scrollbar-track {
201
+ background-color: transparent;
202
+ cursor: pointer;
203
+ }
204
+
205
+ [cmdk-list]::-webkit-scrollbar-thumb {
206
+ background-color: var(--slate5);
207
+ border-radius: 10px;
208
+ }
209
+
210
+ [cmdk-list]::-webkit-scrollbar-thumb:hover {
211
+ background-color: var(--slate6);
212
+ }
@@ -0,0 +1,5 @@
1
+ export { CommandMenu } from './src/components/CommandMenu';
2
+ export { CommandMenuTrigger } from './src/components/CommandMenuTrigger';
3
+ export { CommandItemBase } from './src/components/CommandItemBase';
4
+ export { addHighlight } from './src/utils';
5
+ export * from './src/types';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@expo/styleguide-icons"),t=require("cmdk"),n=require("lodash.groupby"),r=require("react"),a=require("@expo/styleguide"),l=function(){return l=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},l.apply(this,arguments)};function c(e,t,n,r){return new(n||(n=Promise))((function(a,l){function c(e){try{s(r.next(e))}catch(e){l(e)}}function o(e){try{s(r.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,o)}s((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,a,l,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return l={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function o(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;l&&(l=0,o[0]&&(c=0)),c;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,r=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(a=c.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){c.label=o[1];break}if(6===o[0]&&c.label<a[1]){c.label=a[1],a=o;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(o);break}a[2]&&c.ops.pop(),c.trys.pop();continue}o=t.call(e,c)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}"function"==typeof SuppressedError&&SuppressedError;var s=function(e){var t=e.isLoading;return r.createElement("div",{className:a.mergeClasses("bg-palette-blue9 h-0.5 absolute mt-[11px] left-px",t&&"animate-[searchUIBarLoader_2s_infinite_ease-in-out]")})};function i(){return r.createElement(e.ChevronRightIcon,{className:"icon-xs text-icon-quaternary inline-block relative mx-1 -top-px"})}var m=function(){return r.createElement(e.ArrowUpRightIcon,{className:"text-icon-tertiary self-center ml-auto shrink-0"})},u=function(e){var t=e.className;return r.createElement("svg",{viewBox:"-11.5 -10.23174 23 20.46348",className:a.mergeClasses("icon-md text-icon-secondary",t)},r.createElement("circle",{cx:"0",cy:"0",r:"2.05",fill:"currentColor"}),r.createElement("g",{stroke:"currentColor",strokeWidth:"1",fill:"none"},r.createElement("ellipse",{rx:"11",ry:"4.2"}),r.createElement("ellipse",{rx:"11",ry:"4.2",transform:"rotate(60)"}),r.createElement("ellipse",{rx:"11",ry:"4.2",transform:"rotate(120)"})))},d=function(){return r.createElement("svg",{width:"77",height:"19","aria-label":"Algolia",role:"img"},r.createElement("path",{d:"M2.5067 0h14.0245c1.384.001 2.5058 1.1205 2.5068 2.5017V16.5c-.0014 1.3808-1.1232 2.4995-2.5068 2.5H2.5067C1.1232 18.9995.0014 17.8808 0 16.5V2.4958A2.495 2.495 0 01.735.7294 2.505 2.505 0 012.5068 0zM37.95 15.0695c-3.7068.0168-3.7068-2.986-3.7068-3.4634L34.2372.3576 36.498 0v11.1794c0 .2715 0 1.9889 1.452 1.994v1.8961zm-9.1666-1.8388c.694 0 1.2086-.0397 1.5678-.1088v-2.2934a5.3639 5.3639 0 00-1.3303-.1679 4.8283 4.8283 0 00-.758.0582 2.2845 2.2845 0 00-.688.2024c-.2029.0979-.371.2362-.4919.4142-.1268.1788-.185.2826-.185.5533 0 .5297.185.8359.5205 1.0375.3355.2016.7928.3053 1.365.3053v-.0008zm-.1969-8.1817c.7463 0 1.3768.092 1.8856.2767.5088.1838.9195.4428 1.2204.7717.3068.334.5147.7777.6423 1.251.1327.4723.196.991.196 1.5603v5.798c-.5235.1036-1.05.192-1.5787.2649-.7048.1037-1.4976.156-2.3774.156-.5832 0-1.1215-.0582-1.6016-.167a3.385 3.385 0 01-1.2432-.5364 2.6034 2.6034 0 01-.8037-.9565c-.191-.3922-.29-.9447-.29-1.5208 0-.5533.11-.905.3246-1.2863a2.7351 2.7351 0 01.8849-.9329c.376-.242.8029-.415 1.2948-.5187a7.4517 7.4517 0 011.5381-.156 7.1162 7.1162 0 011.6667.2024V8.886c0-.259-.0296-.5061-.093-.7372a1.5847 1.5847 0 00-.3245-.6158 1.5079 1.5079 0 00-.6119-.4158 2.6788 2.6788 0 00-.966-.173c-.5206 0-.9948.0634-1.4283.1384a6.5481 6.5481 0 00-1.065.259l-.2712-1.849c.2831-.0986.7048-.1964 1.2491-.2943a9.2979 9.2979 0 011.752-.1501v.0008zm44.6597 8.1193c.6947 0 1.2086-.0405 1.567-.1097v-2.2942a5.3743 5.3743 0 00-1.3303-.1679c-.2485 0-.503.0177-.7573.0582a2.2853 2.2853 0 00-.688.2024 1.2333 1.2333 0 00-.4918.4142c-.1268.1788-.1843.2826-.1843.5533 0 .5297.1843.8359.5198 1.0375.3414.2066.7927.3053 1.365.3053v.0009zm-.191-8.1767c.7463 0 1.3768.0912 1.8856.2759.5087.1847.9195.4436 1.2204.7717.3.329.5147.7786.6414 1.251a5.7248 5.7248 0 01.197 1.562v5.7972c-.3466.0742-.874.1602-1.5788.2648-.7049.1038-1.4976.1552-2.3774.1552-.5832 0-1.1215-.0573-1.6016-.167a3.385 3.385 0 01-1.2432-.5356 2.6034 2.6034 0 01-.8038-.9565c-.191-.3922-.2898-.9447-.2898-1.5216 0-.5533.1098-.905.3245-1.2854a2.7373 2.7373 0 01.8849-.9338c.376-.2412.8029-.4141 1.2947-.5178a7.4545 7.4545 0 012.325-.1097c.2781.0287.5672.081.879.156v-.3686a2.7781 2.7781 0 00-.092-.738 1.5788 1.5788 0 00-.3246-.6166 1.5079 1.5079 0 00-.612-.415 2.6797 2.6797 0 00-.966-.1729c-.5205 0-.9947.0633-1.4282.1384a6.5608 6.5608 0 00-1.065.259l-.2712-1.8498c.283-.0979.7048-.1957 1.2491-.2935a9.8597 9.8597 0 011.752-.1494zm-6.79-1.072c-.7576.001-1.373-.6103-1.3759-1.3664 0-.755.6128-1.3664 1.376-1.3664.764 0 1.3775.6115 1.3775 1.3664s-.6195 1.3664-1.3776 1.3664zm1.1393 11.1507h-2.2726V5.3409l2.2734-.3568v10.0845l-.0008.0017zm-3.984 0c-3.707.0168-3.707-2.986-3.707-3.4642L59.7069.3576 61.9685 0v11.1794c0 .2715 0 1.9889 1.452 1.994V15.0703zm-7.3512-4.979c0-.975-.2138-1.7873-.6305-2.3516-.4167-.571-.9998-.852-1.747-.852-.7454 0-1.3302.281-1.7452.852-.4166.5702-.6195 1.3765-.6195 2.3516 0 .9851.208 1.6473.6254 2.2183.4158.576.9998.8587 1.7461.8587.7454 0 1.3303-.2885 1.747-.8595.4158-.5761.6237-1.2315.6237-2.2184v.0009zm2.3132-.006c0 .7609-.1099 1.3361-.3356 1.9654a4.654 4.654 0 01-.9533 1.6076A4.214 4.214 0 0155.613 14.69c-.579.2412-1.4697.3795-1.9143.3795-.4462-.005-1.3303-.1324-1.9033-.3795a4.307 4.307 0 01-1.474-1.0316c-.4115-.4445-.7293-.9801-.9609-1.6076a5.3423 5.3423 0 01-.3465-1.9653c0-.7608.104-1.493.3356-2.1155a4.683 4.683 0 01.9719-1.5958 4.3383 4.3383 0 011.479-1.0257c.5739-.242 1.2043-.3567 1.8864-.3567.6829 0 1.3125.1197 1.8906.3567a4.1245 4.1245 0 011.4816 1.0257 4.7587 4.7587 0 01.9592 1.5958c.2426.6225.3643 1.3547.3643 2.1155zm-17.0198 0c0 .9448.208 1.9932.6238 2.431.4166.4386.955.6579 1.6142.6579.3584 0 .6998-.0523 1.0176-.1502.3186-.0978.5721-.2134.775-.3517V7.0784a8.8706 8.8706 0 00-1.4926-.1906c-.8206-.0236-1.4452.312-1.8847.8468-.4335.5365-.6533 1.476-.6533 2.3516v-.0008zm6.2863 4.4485c0 1.5385-.3938 2.662-1.1866 3.3773-.791.7136-2.0005 1.0712-3.6308 1.0712-.5958 0-1.834-.1156-2.8228-.334l.3643-1.7865c.8282.173 1.9202.2193 2.4932.2193.9077 0 1.555-.1847 1.943-.5533.388-.3686.578-.916.578-1.643v-.3687a6.8289 6.8289 0 01-.8848.3349c-.3634.1096-.786.167-1.261.167-.6246 0-1.1917-.0979-1.7055-.2944a3.5554 3.5554 0 01-1.3244-.8645c-.3642-.3796-.6541-.8579-.8561-1.4289-.2028-.571-.3068-1.59-.3068-2.339 0-.7034.1099-1.5856.3245-2.1735.2198-.5871.5316-1.0949.9542-1.515.4167-.42.9255-.743 1.5213-.98a5.5923 5.5923 0 012.052-.3855c.7353 0 1.4114.092 2.0707.2024.6592.1088 1.2204.2236 1.6776.35v8.945-.0008zM11.5026 4.2418v-.6511c-.0005-.4553-.3704-.8241-.8266-.8241H8.749c-.4561 0-.826.3688-.8265.824v.669c0 .0742.0693.1264.1445.1096a6.0346 6.0346 0 011.6768-.2362 6.125 6.125 0 011.6202.2185.1116.1116 0 00.1386-.1097zm-5.2806.852l-.3296-.3282a.8266.8266 0 00-1.168 0l-.393.3922a.8199.8199 0 000 1.164l.3237.323c.0524.0515.1268.0397.1733-.0117.191-.259.3989-.507.6305-.7372.2374-.2362.48-.4437.7462-.6335.0575-.0354.0634-.1155.017-.1687zm3.5159 2.069v2.818c0 .081.0879.1392.1622.0987l2.5102-1.2964c.0574-.0287.0752-.0987.0464-.1552a3.1237 3.1237 0 00-2.603-1.574c-.0575 0-.115.0456-.115.1097l-.0008-.0009zm.0008 6.789c-2.0933.0005-3.7915-1.6912-3.7947-3.7804C5.9468 8.0821 7.6452 6.39 9.7387 6.391c2.0932-.0005 3.7911 1.6914 3.794 3.7804a3.7783 3.7783 0 01-1.1124 2.675 3.7936 3.7936 0 01-2.6824 1.1054h.0008zM9.738 4.8002c-1.9218 0-3.6975 1.0232-4.6584 2.6841a5.359 5.359 0 000 5.3683c.9609 1.661 2.7366 2.6841 4.6584 2.6841a5.3891 5.3891 0 003.8073-1.5725 5.3675 5.3675 0 001.578-3.7987 5.3574 5.3574 0 00-1.5771-3.797A5.379 5.379 0 009.7387 4.801l-.0008-.0008z",fill:"currentColor",fillRule:"evenodd"}))},v=function(){return r.createElement("div",{className:"flex gap-4 px-4 h-11 items-center"},r.createElement("p",{className:"text-3xs text-tertiary inline-flex gap-2 items-center max-md-gutters:hidden"},r.createElement("kbd",null,"↵"),r.createElement("span",null,"to select")),r.createElement("p",{className:"text-3xs text-tertiary inline-flex gap-2 items-center max-md-gutters:hidden"},r.createElement("kbd",null,"↑"),r.createElement("kbd",null,"↓"),r.createElement("span",null,"to navigate")),r.createElement("p",{className:"text-3xs text-tertiary inline-flex gap-2 items-center max-md-gutters:hidden"},r.createElement("kbd",null,"esc"),r.createElement("span",null,"to close")),r.createElement("p",{className:"text-3xs text-tertiary inline-flex gap-2 items-center ml-auto"},r.createElement("span",null,"Search by"),r.createElement(d,null)))},f=function(e,t,n,r){return c(void 0,void 0,void 0,(function(){var a,l,c;return o(this,(function(o){switch(o.label){case 0:return[4,t(e,r).then((function(e){return e.json()}))];case 1:return a=o.sent(),l=a.hits,c=a.libraries,n(l||c||[]),[2]}}))}))},p=function(e,t,n,r,a,c){return void 0===c&&(c={}),["https://".concat(t,"-dsn.algolia.net/1/indexes/").concat(r,"/query"),{method:"POST",headers:{"X-Algolia-Application-Id":t,"X-Algolia-API-Key":n},body:JSON.stringify(l({params:"query=".concat(e,"&hitsPerPage=").concat(a),highlightPreTag:"<mark>",highlightPostTag:"</mark>"},c))}]},E=function(e,t){return fetch.apply(void 0,p(e,"QEX7PB7D46","6652d26570e8628af4601e1d78ad456b","expo",20,{facetFilters:[["version:none","version:".concat(t)]]}))},g=function(e){return fetch.apply(void 0,p(e,"8TDSE0OHGQ","c9c791d9d5fd7f315d7f3859b32c1f3b","react-native-v2",5,{facetFilters:[["version:current"]]}))},x=function(e){return fetch("https://reactnative.directory/api/libraries?search=".concat(encodeURI(e),"&limit=5"))},h=function(e,t){var n;return{dangerouslySetInnerHTML:{__html:(null===(n=e._highlightResult.hierarchy["".concat(t)])||void 0===n?void 0:n.value)||""}}},y=function(e,t){if(void 0===t&&(t=36),!e||!e.length)return"";var n=Math.max(e.indexOf("<mark>")-t,0),r=Math.min(e.indexOf("</mark>")+t+6,e.length);return"".concat(0!==n?"…":"").concat(e.substring(n,r).trim()).concat(r!==e.length?"…":"")},N=function(e,t){var n,r,a;return void 0===t&&(t=!1),t?{}:{dangerouslySetInnerHTML:{__html:(null===(n=e._highlightResult.content)||void 0===n?void 0:n.value)?y(null===(r=e._highlightResult.content)||void 0===r?void 0:r.value):y((null===(a=e._highlightResult.hierarchy.lvl1)||void 0===a?void 0:a.value)||"",82)}}},b=["/versions/","/more/"],k=function(e){return b.some((function(t){return e.includes(t)}))},C=["/app-signing/","/build/","/build-reference/","/development/","/eas/","/eas/metadata/","/eas-update/","/submit/"],S=function(e){return C.some((function(t){return e.includes(t)}))},I=["/get-started/","/develop/","/deploy/","/faq/","/core-concepts/","/debugging/","/config-plugins/"],w=function(e){return I.some((function(t){return e.includes(t)}))},q=["/tutorial","/ui-programming/","/additional-resources/"],z=function(e){return q.some((function(t){return e.includes(t)}))},L=function(e,t){var n=e.toLowerCase().indexOf(t.toLowerCase());if(-1===n)return e;var r=n+t.length;return e.substring(0,n)+"<mark>"+e.substring(n,r)+"</mark>"+e.substring(r)},K=function(e){var n=e.children,l=e.url,c=e.isExternalLink,o=e.isNested,s=e.onSelect,i=e.className,m=e.value,u=r.useState(!1),d=u[0],v=u[1];return r.createElement(t.Command.Item,{className:a.mergeClasses("relative",i),value:m,"data-nested":!!o||void 0,onMouseUp:function(e){1!==e.button&&2!==e.button||function(){var e;null===(e=navigator.clipboard)||void 0===e||e.writeText(l),v(!0),setTimeout((function(){return v(!1)}),1500)}()},onSelect:function(){!function(e,t){void 0===t&&(t=!1);var n=document.createElement("a");t&&(n.target="_blank",n.rel="noopener noreferrer"),n.href=e,n.click()}(l,c),s&&s()},onContextMenu:function(e){e.preventDefault()}},n,d&&r.createElement("div",{className:"text-2xs font-medium absolute rounded-full px-2 right-2.5 top-[calc(50%-13px)] border-secondary bg-info text-info"},"Copied!"))},P=new Intl.NumberFormat,F=function(t){var n=t.item,a=t.onSelect,l=t.query;return r.createElement(K,{value:"rnd-".concat(n.npmPkg),url:n.githubUrl,isExternalLink:!0,onSelect:a},r.createElement("div",{className:"inline-flex gap-3 items-center"},r.createElement(e.GithubIcon,{className:"text-icon-secondary"}),r.createElement("div",null,r.createElement("p",{className:"text-xs font-medium",dangerouslySetInnerHTML:{__html:L(n.npmPkg,l)}}),r.createElement("p",{className:"text-3xs text-quaternary"},P.format(n.github.stats.stars)," stars · ",P.format(n.npm.downloads)," downloads")),r.createElement(m,null)))},M=function(e){var t=e.item,n=e.levelKey,a=void 0===n?"lvl0":n;return t.hierarchy[a]?r.createElement(r.Fragment,null,r.createElement(i,null),r.createElement("span",l({},h(t,a)))):null},A=function(e){var t=e.item,n=e.onSelect,a=t.hierarchy,c=a.lvl0,o=a.lvl1,s=a.lvl2,i=a.lvl3,d=a.lvl4;return r.createElement(K,{value:"rn-".concat(t.objectID),url:t.url,isExternalLink:!0,onSelect:n},r.createElement("div",{className:"inline-flex gap-3 items-center"},r.createElement(u,{className:"shrink-0"}),r.createElement("div",null,d&&r.createElement(r.Fragment,null,r.createElement("p",l({className:"text-xs font-medium"},h(t,"lvl4"))),r.createElement("p",{className:"text-3xs text-quaternary"},r.createElement("span",l({},h(t,"lvl0"))),r.createElement(M,{item:t,levelKey:"lvl1"}),r.createElement(M,{item:t,levelKey:"lvl2"}),r.createElement(M,{item:t,levelKey:"lvl3"}))),!d&&i&&r.createElement(r.Fragment,null,r.createElement("p",l({className:"text-xs font-medium"},h(t,"lvl3"))),r.createElement("p",{className:"text-3xs text-quaternary"},r.createElement("span",l({},h(t,"lvl0"))),r.createElement(M,{item:t,levelKey:"lvl1"}),r.createElement(M,{item:t,levelKey:"lvl2"}))),!i&&s&&r.createElement(r.Fragment,null,r.createElement("p",l({className:"text-xs font-medium"},h(t,"lvl2"))),r.createElement("p",{className:"text-3xs text-quaternary"},r.createElement("span",l({},h(t,"lvl0"))),r.createElement(M,{item:t,levelKey:"lvl1"}))),!i&&!s&&o&&r.createElement(r.Fragment,null,r.createElement("p",l({className:"text-xs font-medium"},h(t,"lvl1"))),r.createElement("p",l({className:"text-3xs text-quaternary"},h(t,"lvl0")))),!i&&!s&&!o&&c&&r.createElement("p",l({className:"text-xs font-medium"},h(t,"lvl0"))),r.createElement("p",l({className:"text-2xs text-secondary"},N(t,!0)))),r.createElement(m,null)))},O=function(t){var n=t.url,l=t.className;return t.isNested?r.createElement(e.Hash02Icon,{className:a.mergeClasses("icon-sm text-icon-quaternary",l)}):k(n)?r.createElement(a.DocsLogo,{className:a.mergeClasses("text-icon-secondary",l)}):S(n)?r.createElement(e.PlanEnterpriseIcon,{className:a.mergeClasses("text-icon-secondary",l)}):w(n)?r.createElement(e.Home02Icon,{className:a.mergeClasses("text-icon-secondary",l)}):z(n)?r.createElement(e.GraduationHat02Icon,{className:a.mergeClasses("text-icon-secondary",l)}):r.createElement(e.BookOpen02Icon,{className:a.mergeClasses("text-icon-secondary",l)})},T=function(e){return k(e)?"Reference":S(e)?"Expo Application Services":w(e)?"Home":z(e)?"Learn":"Guides"},_=function(e){var t=e.url,n=e.isNested;return void 0!==n&&n?r.createElement(r.Fragment,null,r.createElement("span",{className:"text-3xs text-quaternary"},T(t)),r.createElement(i,null)):r.createElement("p",{className:"text-3xs text-quaternary"},T(t))},U=function(e){var t=e.item,n=e.onSelect,c=e.isNested,o=e.transformUrl,s=void 0===o?function(e){return e}:o,i=t.hierarchy,m=i.lvl0,u=i.lvl2,d=i.lvl3,v=i.lvl4,f=i.lvl6,p=a.mergeClasses(c?"text-2xs":"text-xs font-medium"),E=a.mergeClasses("text-3xs text-quaternary",c&&"hidden");return r.createElement(K,{className:a.mergeClasses(c&&"ml-8 mt-0.5 min-h-[32px]"),value:"expodocs-".concat(t.objectID),onSelect:n,url:s(t.url),isNested:c},r.createElement("div",{className:a.mergeClasses("inline-flex items-center gap-3 break-words")},r.createElement(O,{url:t.url,isNested:c,className:"shrink-0"}),r.createElement("div",null,f&&r.createElement(r.Fragment,null,r.createElement("p",l({className:p},h(t,"lvl6"))),!c&&r.createElement("p",{className:"text-3xs text-quaternary"},r.createElement(_,{url:t.url,isNested:!0}),r.createElement("span",l({},h(t,"lvl0"))),r.createElement(M,{item:t,levelKey:"lvl2"}),r.createElement(M,{item:t,levelKey:"lvl3"}),r.createElement(M,{item:t,levelKey:"lvl4"}))),!f&&v&&r.createElement(r.Fragment,null,r.createElement("p",l({className:p},h(t,"lvl4"))),!c&&r.createElement("p",{className:E},r.createElement(_,{url:t.url,isNested:!0}),r.createElement("span",l({},h(t,"lvl0"))),r.createElement(M,{item:t,levelKey:"lvl2"}),r.createElement(M,{item:t,levelKey:"lvl3"}))),!f&&!v&&d&&r.createElement(r.Fragment,null,r.createElement("p",l({className:p},h(t,"lvl3"))),!c&&r.createElement("p",{className:E},r.createElement(_,{url:t.url,isNested:!0}),r.createElement("span",l({},h(t,"lvl0"))),r.createElement(M,{item:t,levelKey:"lvl2"}))),!f&&!v&&!d&&u&&r.createElement(r.Fragment,null,r.createElement("p",l({className:p},h(t,"lvl2"))),!c&&r.createElement("p",{className:E},r.createElement(_,{url:t.url,isNested:!0}),r.createElement("span",l({},h(t,"lvl0"))))),!f&&!v&&!d&&!u&&m&&r.createElement(r.Fragment,null,r.createElement("p",l({className:p},h(t,"lvl0"))),r.createElement(_,{url:t.url})),(!c||t.content)&&r.createElement("p",l({className:a.mergeClasses("text-secondary",c?"text-3xs":"text-2xs")},N(t))))))};exports.CommandItemBase=K,exports.CommandMenu=function(a){var i=a.config,m=i.docsVersion,u=i.docsTransformUrl,d=a.open,p=a.setOpen,h=a.customSections,y=void 0===h?[]:h,N=r.useState(!1),b=N[0],k=N[1],C=r.useState(!0),S=C[0],I=C[1],w=r.useState(""),q=w[0],z=w[1],L=r.useState([]),K=L[0],P=L[1],M=r.useState([]),O=M[0],T=M[1],_=r.useState([]),D=_[0],H=_[1],R=function(){return p(!1)},G=function(e){Promise.all(function(e,t,n){if(n||2===arguments.length)for(var r,a=0,l=t.length;a<l;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}([c(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,f(q,E,P,m)]}))})),c(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,f(q,g,T)]}))})),c(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,f(q,x,H)]}))}))],y.map((function(e){return e.getItemsAsync(q)})),!0)).then(e)};r.useEffect((function(){d&&!b&&G((function(){k(!0),I(!1)}))}),[d]),r.useEffect((function(){if(d){I(!0);var e=setTimeout((function(){return G((function(){return I(!1)}))}),150);return function(){return clearTimeout(e)}}}),[q]);var j=K.length+O.length+D.length+y.reduce((function(e,t){return e+t.items.length}),0),V=n(K.map((function(e){return l(l({},e),{baseUrl:e.url.replace(/#.+/,"")})})),"baseUrl"),B=[K.length>0&&r.createElement(t.Command.Group,{heading:"Expo documentation"},Object.values(V).map((function(e){return e.sort((function(e,t){return e.url.localeCompare(e.baseUrl)-t.url.localeCompare(t.baseUrl)})).slice(0,6).map((function(e,t){return r.createElement(U,{isNested:0!==t,item:e,onSelect:R,key:"hit-expo-docs-".concat(e.objectID),transformUrl:u})}))}))),O.length>0&&r.createElement(t.Command.Group,{heading:"React Native documentation"},O.map((function(e){return r.createElement(A,{item:e,onSelect:R,key:"hit-rn-docs-".concat(e.objectID)})}))),D.length>0&&r.createElement(t.Command.Group,{heading:"React Native directory"},D.map((function(e){return r.createElement(F,{item:e,onSelect:R,key:"hit-rn-dir-".concat(e.npmPkg),query:q})}))),!S&&0===j&&r.createElement(t.Command.Empty,null,r.createElement("p",{className:"text-secondary text-xs"},"No results found."))];return null==y||y.forEach((function(e){var n=e.items,a=e.heading,l=e.sectionIndex;return n.length>0&&B.splice(l,0,r.createElement(t.Command.Group,{heading:a,key:a},n))})),r.createElement(t.Command.Dialog,{open:d,onOpenChange:p,label:"Search Menu",shouldFilter:!1},r.createElement(e.SearchSmIcon,{className:"text-icon-secondary absolute top-[29px] left-[29px] transition-opacity duration-200"}),r.createElement("div",{className:"absolute top-[25px] right-[25px] cursor-pointer p-1 rounded-sm hocus:bg-element"},r.createElement(e.XIcon,{className:"text-icon-secondary",onClick:function(){return p(!1)}})),r.createElement(t.Command.Input,{value:q,onValueChange:z,placeholder:"Search…"}),r.createElement(s,{isLoading:S}),r.createElement(t.Command.List,null,b&&B),r.createElement(v,null))},exports.CommandMenuTrigger=function(t){var n=t.setOpen,l=t.className,c=r.useState(null),o=c[0],s=c[1];return r.useEffect((function(){s("undefined"!=typeof navigator&&function(){var e,t,n;return/(Mac|iPhone|iPod|iPad)/i.test(null!==(n=null!==(e=null===navigator||void 0===navigator?void 0:navigator.platform)&&void 0!==e?e:null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.platform)&&void 0!==n?n:"")}())}),[]),r.useEffect((function(){if(null!==o){var e=function(e){"k"===e.key&&(o?e.metaKey:e.ctrlKey)&&(e.preventDefault(),n((function(e){return!e})))};return document.addEventListener("keydown",e,!1),function(){return document.removeEventListener("keydown",e)}}}),[o]),r.createElement(a.Button,{id:"cmdk-trigger",theme:"secondary",leftSlot:r.createElement(e.SearchSmIcon,{className:"icon-md text-icon-secondary"}),rightSlot:null!==o?r.createElement("div",{className:"ml-auto max-lg-gutters:hidden"},r.createElement("kbd",{className:"!h-5 !leading-[19px]"},o?"⌘":"Ctrl")," ",r.createElement("kbd",{className:"!h-5 !leading-[19px]"},"K")):void 0,className:a.mergeClasses("bg-default pl-2.5 pr-3 border border-default shadow-xs min-h-[40px]",l),onClick:function(){return n(!0)}},r.createElement("p",{className:"text-secondary text-xs"},"Search"))},exports.addHighlight=L;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { AlgoliaItemType } from '../types';
3
+ type Props = {
4
+ item: AlgoliaItemType;
5
+ onSelect?: () => void;
6
+ isNested?: boolean;
7
+ transformUrl?: (url: string) => string;
8
+ };
9
+ export declare const ExpoDocsItem: ({ item, onSelect, isNested, transformUrl }: Props) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { AlgoliaItemHierarchy, AlgoliaItemType } from '../types';
3
+ export declare const FootnoteSection: ({ item, levelKey, }: {
4
+ item: AlgoliaItemType;
5
+ levelKey: keyof AlgoliaItemHierarchy<string>;
6
+ }) => React.JSX.Element | null;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { RNDirectoryItemType } from '../types';
3
+ type Props = {
4
+ item: RNDirectoryItemType;
5
+ query: string;
6
+ onSelect?: () => void;
7
+ };
8
+ export declare const RNDirectoryItem: ({ item, onSelect, query }: Props) => React.JSX.Element;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { AlgoliaItemType } from '../types';
3
+ type Props = {
4
+ item: AlgoliaItemType;
5
+ onSelect?: () => void;
6
+ };
7
+ export declare const RNDocsItem: ({ item, onSelect }: Props) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,5 @@
1
+ import React, { HTMLAttributes } from 'react';
2
+ export declare function FootnoteArrowIcon(): React.JSX.Element;
3
+ export declare const ExternalLinkIcon: () => React.JSX.Element;
4
+ export declare const ReactIcon: ({ className }: HTMLAttributes<SVGSVGElement>) => React.JSX.Element;
5
+ export declare const AlgoliaLogo: () => React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ export { RNDirectoryItem } from './RNDirectoryItem';
2
+ export { RNDocsItem } from './RNDocsItem';
3
+ export { ExpoDocsItem } from './ExpoDocsItem';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ type Props = {
3
+ isLoading?: boolean;
4
+ };
5
+ export declare const BarLoader: ({ isLoading }: Props) => React.JSX.Element;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const CommandFooter: () => React.JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ type Props = PropsWithChildren<{
3
+ url: string;
4
+ onSelect?: () => void;
5
+ isExternalLink?: boolean;
6
+ isNested?: boolean;
7
+ className?: string;
8
+ value?: string;
9
+ }>;
10
+ /**
11
+ * Wrapper for Command.Item that adds copy link on right/middle click + visual copy indicator.
12
+ */
13
+ export declare const CommandItemBase: ({ children, url, isExternalLink, isNested, onSelect, className, value }: Props) => React.JSX.Element;
14
+ export {};
@@ -0,0 +1,10 @@
1
+ import React, { Dispatch, SetStateAction } from 'react';
2
+ import type { CommandMenuConfig, CommandMenuSection } from '../types';
3
+ type Props = {
4
+ open: boolean;
5
+ setOpen: Dispatch<SetStateAction<boolean>>;
6
+ config: CommandMenuConfig;
7
+ customSections?: CommandMenuSection[];
8
+ };
9
+ export declare const CommandMenu: ({ config: { docsVersion, docsTransformUrl }, open, setOpen, customSections, }: Props) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ import React, { Dispatch, SetStateAction } from 'react';
2
+ type Props = {
3
+ setOpen: Dispatch<SetStateAction<boolean>>;
4
+ className?: string;
5
+ };
6
+ export declare const CommandMenuTrigger: ({ setOpen, className }: Props) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { ReactNode } from 'react';
2
+ export type CommandMenuConfig = {
3
+ docsVersion: string;
4
+ docsTransformUrl?: (url: string) => string;
5
+ disableDashboardSection?: boolean;
6
+ };
7
+ export type CommandMenuSection = {
8
+ heading: string;
9
+ getItemsAsync: (query: string) => Promise<void>;
10
+ items: ReactNode[];
11
+ sectionIndex: number;
12
+ };
13
+ export type AlgoliaHighlight = {
14
+ value: string;
15
+ };
16
+ export type AlgoliaItemHierarchy<T> = {
17
+ lvl0?: T | null;
18
+ lvl1?: T | null;
19
+ lvl2?: T | null;
20
+ lvl3?: T | null;
21
+ lvl4?: T | null;
22
+ lvl5?: T | null;
23
+ lvl6?: T | null;
24
+ };
25
+ export type AlgoliaItemType = {
26
+ url: string;
27
+ objectID: string;
28
+ anchor: string | null;
29
+ content: string | null;
30
+ hierarchy: AlgoliaItemHierarchy<string>;
31
+ _highlightResult: {
32
+ content: AlgoliaHighlight | null;
33
+ hierarchy: AlgoliaItemHierarchy<AlgoliaHighlight>;
34
+ };
35
+ };
36
+ export type RNDirectoryItemType = {
37
+ npmPkg: string;
38
+ githubUrl: string;
39
+ npm: {
40
+ downloads: number;
41
+ };
42
+ github: {
43
+ stats: {
44
+ stars: number;
45
+ };
46
+ };
47
+ };
@@ -0,0 +1,25 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ import type { AlgoliaItemHierarchy, AlgoliaItemType } from './types';
3
+ export declare const getItemsAsync: <T>(query: string, fetcher: (query: string, version?: string) => Promise<Response>, setter: Dispatch<SetStateAction<T[]>>, version?: string) => Promise<void>;
4
+ export declare const getExpoDocsResults: (query: string, version?: string) => Promise<Response>;
5
+ export declare const getRNDocsResults: (query: string) => Promise<Response>;
6
+ export declare const getDirectoryResults: (query: string) => Promise<Response>;
7
+ export declare const getHighlightHTML: (item: AlgoliaItemType, tag: keyof AlgoliaItemHierarchy<string>) => {
8
+ dangerouslySetInnerHTML: {
9
+ __html: string;
10
+ };
11
+ };
12
+ export declare const getContentHighlightHTML: (item: AlgoliaItemType, skipDescription?: boolean) => {
13
+ dangerouslySetInnerHTML?: undefined;
14
+ } | {
15
+ dangerouslySetInnerHTML: {
16
+ __html: string;
17
+ };
18
+ };
19
+ export declare const openLink: (url: string, isExternal?: boolean) => void;
20
+ export declare const isReferencePath: (url: string) => boolean;
21
+ export declare const isEASPath: (url: string) => boolean;
22
+ export declare const isHomePath: (url: string) => boolean;
23
+ export declare const isLearnPath: (url: string) => boolean;
24
+ export declare const isAppleDevice: () => boolean;
25
+ export declare const addHighlight: (content: string, query: string) => string;
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@expo/styleguide-search-ui",
3
+ "version": "1.0.0-alpha.2",
4
+ "description": "Expo's common search component for use on the web.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "clean": "rimraf dist",
12
+ "bundle": "rollup --config",
13
+ "build": "run-s clean bundle",
14
+ "dev": "rollup --config --watch"
15
+ },
16
+ "homepage": "https://github.com/expo/styleguide",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/expo/styleguide.git",
20
+ "directory": "packages/search-ui"
21
+ },
22
+ "keywords": [
23
+ "expo"
24
+ ],
25
+ "author": "Expo",
26
+ "license": "MIT",
27
+ "bugs": {
28
+ "url": "https://github.com/expo/styleguide/issues"
29
+ },
30
+ "dependencies": {
31
+ "@expo/styleguide": "^8.1.0",
32
+ "@expo/styleguide-icons": "^1.0.3",
33
+ "cmdk": "^0.2.0",
34
+ "lodash.groupby": "^4.6.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/lodash.groupby": "^4.6.9",
38
+ "tailwindcss": "^3.3.2",
39
+ "user-agent-data-types": "^0.4.2"
40
+ },
41
+ "peerDependencies": {
42
+ "next": ">= 13",
43
+ "react": ">= 16"
44
+ },
45
+ "eslintConfig": {
46
+ "extends": "universe/web"
47
+ },
48
+ "gitHead": "570f462ea35909d938adea1df5206fa130932155"
49
+ }