@expo/styleguide-search-ui 8.0.0 → 8.0.1

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.
@@ -0,0 +1 @@
1
+ "use strict";var t=require("react/compiler-runtime"),e=require("@expo/styleguide"),i=require("@expo/styleguide-icons/outline/SearchSmIcon"),r=require("react"),o=require("@sanity/client"),n=require("react/jsx-runtime");const s="image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg";function a(t){return`image-${t.split("/").slice(-1)[0]}`.replace(/\.([a-z]+)$/,"-$1")}const h=[["width","w"],["height","h"],["format","fm"],["download","dl"],["blur","blur"],["sharpen","sharp"],["invert","invert"],["orientation","or"],["minHeight","min-h"],["maxHeight","max-h"],["minWidth","min-w"],["maxWidth","max-w"],["quality","q"],["fit","fit"],["crop","crop"],["saturation","sat"],["auto","auto"],["dpr","dpr"],["pad","pad"],["frame","frame"]];function p(t){let e={...t||{}};const i=e.source;delete e.source;const r=function(t){if(!t)return null;let e;if("string"==typeof t&&/^https?:\/\//.test(`${t}`))e={asset:{_ref:a(t)}};else if("string"==typeof t)e={asset:{_ref:t}};else if((i=t)&&"string"==typeof i._ref)e={asset:t};else if((t=>!!t&&"string"==typeof t._id)(t))e={asset:{_ref:t._id||""}};else if((t=>{const e=t;return!(!e||!e.asset)&&"string"==typeof e.asset.url})(t))e={asset:{_ref:a(t.asset.url)}};else{if("object"!=typeof t.asset)return null;e={...t}}var i;const r=t;return r.crop&&(e.crop=r.crop),r.hotspot&&(e.hotspot=r.hotspot),function(t){if(t.crop&&t.hotspot)return t;const e={...t};return e.crop||(e.crop={left:0,top:0,bottom:0,right:0}),e.hotspot||(e.hotspot={x:.5,y:.5,height:1,width:1}),e}(e)}(i);if(!r){if(i&&(t=>{if("object"==typeof t&&null!==t){const e=t;return e._upload&&(!e.asset||!e.asset._ref)}return!1})(i))return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8HwQACfsD/QNViZkAAAAASUVORK5CYII=";throw new Error(`Unable to resolve image URL from source (${JSON.stringify(i)})`)}const o=function(t){const[,e,i,r]=t.split("-");if(!e||!i||!r)throw new Error(`Malformed asset _ref '${t}'. Expected an id like "${s}".`);const[o,n]=i.split("x"),a=+o,h=+n;if(!isFinite(a)||!isFinite(h))throw new Error(`Malformed asset _ref '${t}'. Expected an id like "${s}".`);return{id:e,width:a,height:h,format:r}}(r.asset._ref||r.asset._id||""),n=Math.round(r.crop.left*o.width),p=Math.round(r.crop.top*o.height),c={left:n,top:p,width:Math.round(o.width-r.crop.right*o.width-n),height:Math.round(o.height-r.crop.bottom*o.height-p)},d=r.hotspot.height*o.height/2,u=r.hotspot.width*o.width/2,f=r.hotspot.x*o.width,m=r.hotspot.y*o.height,g={left:f-u,top:m-d,right:f+u,bottom:m+d};return e.rect||e.focalPoint||e.ignoreImageParams||e.crop||(e={...e,...l({crop:c,hotspot:g},e)}),function(t){const e=(t.baseUrl||"https://cdn.sanity.io").replace(/\/+$/,""),i=t.vanityName?`/${t.vanityName}`:"",r=`${t.asset.id}-${t.asset.width}x${t.asset.height}.${t.asset.format}${i}`,o=t.mediaLibraryId?`${e}/media-libraries/${t.mediaLibraryId}/images/${r}`:`${e}/images/${t.projectId}/${t.dataset}/${r}`,n=[];if(t.rect){const{left:e,top:i,width:r,height:o}=t.rect;(0!==e||0!==i||o!==t.asset.height||r!==t.asset.width)&&n.push(`rect=${e},${i},${r},${o}`)}t.bg&&n.push(`bg=${t.bg}`),t.focalPoint&&(n.push(`fp-x=${t.focalPoint.x}`),n.push(`fp-y=${t.focalPoint.y}`));const s=[t.flipHorizontal&&"h",t.flipVertical&&"v"].filter(Boolean).join("");return s&&n.push(`flip=${s}`),h.forEach((e=>{const[i,r]=e;typeof t[i]<"u"?n.push(`${r}=${encodeURIComponent(t[i])}`):typeof t[r]<"u"&&n.push(`${r}=${encodeURIComponent(t[r])}`)})),0===n.length?o:`${o}?${n.join("&")}`}({...e,asset:o})}function l(t,e){let i;const r=e.width,o=e.height;if(!r||!o)return{width:r,height:o,rect:t.crop};const n=t.crop,s=t.hotspot,a=r/o;if(n.width/n.height>a){const t=Math.round(n.height),e=Math.round(t*a),r=Math.max(0,Math.round(n.top)),o=Math.round((s.right-s.left)/2+s.left);let h=Math.max(0,Math.round(o-e/2));h<n.left?h=n.left:h+e>n.left+n.width&&(h=n.left+n.width-e),i={left:h,top:r,width:e,height:t}}else{const t=n.width,e=Math.round(t/a),r=Math.max(0,Math.round(n.left)),o=Math.round((s.bottom-s.top)/2+s.top);let h=Math.max(0,Math.round(o-e/2));h<n.top?h=n.top:h+e>n.top+n.height&&(h=n.top+n.height-e),i={left:r,top:h,width:t,height:e}}return{width:r,height:o,rect:i}}const c=["clip","crop","fill","fillmax","max","scale","min"],d=["top","bottom","left","right","center","focalpoint","entropy"],u=["format"];function f(t){const{apiHost:e,projectId:i,dataset:r}=t,o={baseUrl:(e||"https://api.sanity.io").replace(/^https:\/\/api\./,"https://cdn.")},n=t["~experimental_resource"];if("media-library"===n?.type){if("string"!=typeof n.id||0===n.id.length)throw new Error('Media library clients must include an id in "~experimental_resource"');return{...o,mediaLibraryId:n.id}}return{...o,projectId:i,dataset:r}}function m(t){const e=h;for(const i of e){const[e,r]=i;if(t===e||t===r)return e}return t}function g(t){let e={};return e=function(t){return!(!t||!("config"in t))&&"function"==typeof t.config}(t)?f(t.config()):function(t){return!(!t||!("clientConfig"in t))&&"object"==typeof t.clientConfig}(t)?f(t.clientConfig):t||{},e}class w{constructor(t,e){this.options=t?{...t.options||{},...e||{}}:{...e||{}}}withOptions(t){const e=function(t,e){const i=e.baseUrl||t.baseUrl,r={baseUrl:i};for(const t in e)e.hasOwnProperty(t)&&(r[m(t)]=e[t]);return{baseUrl:i,...r}}(this.options,t);return new w(this,e)}image(t){return this.withOptions({source:t})}dataset(t){return this.withOptions({dataset:t})}projectId(t){return this.withOptions({projectId:t})}withClient(t){const e=g(t),i={...this.options};return delete i.baseUrl,delete i.projectId,delete i.dataset,delete i.mediaLibraryId,new w(null,{...e,...i})}bg(t){return this.withOptions({bg:t})}dpr(t){return this.withOptions(t&&1!==t?{dpr:t}:{})}width(t){return this.withOptions({width:t})}height(t){return this.withOptions({height:t})}focalPoint(t,e){return this.withOptions({focalPoint:{x:t,y:e}})}maxWidth(t){return this.withOptions({maxWidth:t})}minWidth(t){return this.withOptions({minWidth:t})}maxHeight(t){return this.withOptions({maxHeight:t})}minHeight(t){return this.withOptions({minHeight:t})}size(t,e){return this.withOptions({width:t,height:e})}blur(t){return this.withOptions({blur:t})}sharpen(t){return this.withOptions({sharpen:t})}rect(t,e,i,r){return this.withOptions({rect:{left:t,top:e,width:i,height:r}})}format(t){return this.withOptions({format:t})}invert(t){return this.withOptions({invert:t})}orientation(t){return this.withOptions({orientation:t})}quality(t){return this.withOptions({quality:t})}forceDownload(t){return this.withOptions({download:t})}flipHorizontal(){return this.withOptions({flipHorizontal:!0})}flipVertical(){return this.withOptions({flipVertical:!0})}ignoreImageParams(){return this.withOptions({ignoreImageParams:!0})}fit(t){if(-1===c.indexOf(t))throw new Error(`Invalid fit mode "${t}"`);return this.withOptions({fit:t})}crop(t){if(-1===d.indexOf(t))throw new Error(`Invalid crop mode "${t}"`);return this.withOptions({crop:t})}saturation(t){return this.withOptions({saturation:t})}auto(t){if(-1===u.indexOf(t))throw new Error(`Invalid auto mode "${t}"`);return this.withOptions({auto:t})}pad(t){return this.withOptions({pad:t})}vanityName(t){return this.withOptions({vanityName:t})}frame(t){if(1!==t)throw new Error(`Invalid frame value "${t}"`);return this.withOptions({frame:t})}url(){return p(this.options)}toString(){return this.url()}}const x="9r24npb8",y="production";o.createClient({projectId:x,dataset:y,useCdn:!0,apiVersion:"v2025-02-19"}),new w(null,g({projectId:x,dataset:y}));exports.CommandMenuTrigger=o=>{const s=t.c(14),{setOpen:a,className:h}=o,[p,l]=r.useState(null);let c,d,u,f,m,g,w,x;return s[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{l("undefined"!=typeof navigator&&/(Mac|iPhone|iPod|iPad)/i.test(navigator?.platform??navigator?.userAgentData?.platform??""))},d=[],s[0]=c,s[1]=d):(c=s[0],d=s[1]),r.useEffect(c,d),s[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(i.SearchSmIcon,{className:"icon-md text-icon-secondary"}),s[2]=u):u=s[2],s[3]!==p?(f=null!==p?n.jsxs("div",{className:"ml-auto max-md-gutters:hidden",children:[n.jsx("kbd",{className:"h-5! leading-[19px]!",children:p?"⌘":"Ctrl"})," ",n.jsx("kbd",{className:"h-5! leading-[19px]!",children:"K"})]}):void 0,s[3]=p,s[4]=f):f=s[4],s[5]!==h?(m=e.mergeClasses("cmdk-trigger bg-default pl-2.5 pr-3 border border-default shadow-xs min-h-[40px]",h),s[5]=h,s[6]=m):m=s[6],s[7]!==a?(g=()=>a(!0),s[7]=a,s[8]=g):g=s[8],s[9]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx("p",{className:"text-secondary font-normal leading-normal text-sm",children:"Search or Ask AI"}),s[9]=w):w=s[9],s[10]!==f||s[11]!==m||s[12]!==g?(x=n.jsx(e.Button,{theme:"secondary",leftSlot:u,rightSlot:f,className:m,onClick:g,children:w}),s[10]=f,s[11]=m,s[12]=g,s[13]=x):x=s[13],x};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/styleguide-search-ui",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Expo's common search component for use on the web.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "./trigger": {
16
16
  "types": "./dist/trigger.d.ts",
17
- "default": "./dist/trigger.js"
17
+ "default": "./dist/trigger.cjs"
18
18
  },
19
19
  "./dist/expo-search-ui.css": "./dist/expo-search-ui.css"
20
20
  },
@@ -71,5 +71,5 @@
71
71
  "eslintConfig": {
72
72
  "extends": "universe/web"
73
73
  },
74
- "gitHead": "c2a7fe8cdcba55617c299d460c29235b2a5dbf24"
74
+ "gitHead": "dbfe634ed91850a162a4bba97fec47faa6427189"
75
75
  }
package/dist/trigger.js DELETED
@@ -1 +0,0 @@
1
- import{c as t}from"react/compiler-runtime";import{mergeClasses as e,Button as i}from"@expo/styleguide";import{SearchSmIcon as r}from"@expo/styleguide-icons/outline/SearchSmIcon";import{useState as o,useEffect as n}from"react";import{createClient as s}from"@sanity/client";import{jsx as a,jsxs as h}from"react/jsx-runtime";const p="image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg";function l(t){return`image-${t.split("/").slice(-1)[0]}`.replace(/\.([a-z]+)$/,"-$1")}const c=[["width","w"],["height","h"],["format","fm"],["download","dl"],["blur","blur"],["sharpen","sharp"],["invert","invert"],["orientation","or"],["minHeight","min-h"],["maxHeight","max-h"],["minWidth","min-w"],["maxWidth","max-w"],["quality","q"],["fit","fit"],["crop","crop"],["saturation","sat"],["auto","auto"],["dpr","dpr"],["pad","pad"],["frame","frame"]];function d(t){let e={...t||{}};const i=e.source;delete e.source;const r=function(t){if(!t)return null;let e;if("string"==typeof t&&/^https?:\/\//.test(`${t}`))e={asset:{_ref:l(t)}};else if("string"==typeof t)e={asset:{_ref:t}};else if((i=t)&&"string"==typeof i._ref)e={asset:t};else if((t=>!!t&&"string"==typeof t._id)(t))e={asset:{_ref:t._id||""}};else if((t=>{const e=t;return!(!e||!e.asset)&&"string"==typeof e.asset.url})(t))e={asset:{_ref:l(t.asset.url)}};else{if("object"!=typeof t.asset)return null;e={...t}}var i;const r=t;return r.crop&&(e.crop=r.crop),r.hotspot&&(e.hotspot=r.hotspot),function(t){if(t.crop&&t.hotspot)return t;const e={...t};return e.crop||(e.crop={left:0,top:0,bottom:0,right:0}),e.hotspot||(e.hotspot={x:.5,y:.5,height:1,width:1}),e}(e)}(i);if(!r){if(i&&(t=>{if("object"==typeof t&&null!==t){const e=t;return e._upload&&(!e.asset||!e.asset._ref)}return!1})(i))return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8HwQACfsD/QNViZkAAAAASUVORK5CYII=";throw new Error(`Unable to resolve image URL from source (${JSON.stringify(i)})`)}const o=function(t){const[,e,i,r]=t.split("-");if(!e||!i||!r)throw new Error(`Malformed asset _ref '${t}'. Expected an id like "${p}".`);const[o,n]=i.split("x"),s=+o,a=+n;if(!isFinite(s)||!isFinite(a))throw new Error(`Malformed asset _ref '${t}'. Expected an id like "${p}".`);return{id:e,width:s,height:a,format:r}}(r.asset._ref||r.asset._id||""),n=Math.round(r.crop.left*o.width),s=Math.round(r.crop.top*o.height),a={left:n,top:s,width:Math.round(o.width-r.crop.right*o.width-n),height:Math.round(o.height-r.crop.bottom*o.height-s)},h=r.hotspot.height*o.height/2,d=r.hotspot.width*o.width/2,u=r.hotspot.x*o.width,m=r.hotspot.y*o.height,w={left:u-d,top:m-h,right:u+d,bottom:m+h};return e.rect||e.focalPoint||e.ignoreImageParams||e.crop||(e={...e,...f({crop:a,hotspot:w},e)}),function(t){const e=(t.baseUrl||"https://cdn.sanity.io").replace(/\/+$/,""),i=t.vanityName?`/${t.vanityName}`:"",r=`${t.asset.id}-${t.asset.width}x${t.asset.height}.${t.asset.format}${i}`,o=t.mediaLibraryId?`${e}/media-libraries/${t.mediaLibraryId}/images/${r}`:`${e}/images/${t.projectId}/${t.dataset}/${r}`,n=[];if(t.rect){const{left:e,top:i,width:r,height:o}=t.rect;(0!==e||0!==i||o!==t.asset.height||r!==t.asset.width)&&n.push(`rect=${e},${i},${r},${o}`)}t.bg&&n.push(`bg=${t.bg}`),t.focalPoint&&(n.push(`fp-x=${t.focalPoint.x}`),n.push(`fp-y=${t.focalPoint.y}`));const s=[t.flipHorizontal&&"h",t.flipVertical&&"v"].filter(Boolean).join("");return s&&n.push(`flip=${s}`),c.forEach((e=>{const[i,r]=e;typeof t[i]<"u"?n.push(`${r}=${encodeURIComponent(t[i])}`):typeof t[r]<"u"&&n.push(`${r}=${encodeURIComponent(t[r])}`)})),0===n.length?o:`${o}?${n.join("&")}`}({...e,asset:o})}function f(t,e){let i;const r=e.width,o=e.height;if(!r||!o)return{width:r,height:o,rect:t.crop};const n=t.crop,s=t.hotspot,a=r/o;if(n.width/n.height>a){const t=Math.round(n.height),e=Math.round(t*a),r=Math.max(0,Math.round(n.top)),o=Math.round((s.right-s.left)/2+s.left);let h=Math.max(0,Math.round(o-e/2));h<n.left?h=n.left:h+e>n.left+n.width&&(h=n.left+n.width-e),i={left:h,top:r,width:e,height:t}}else{const t=n.width,e=Math.round(t/a),r=Math.max(0,Math.round(n.left)),o=Math.round((s.bottom-s.top)/2+s.top);let h=Math.max(0,Math.round(o-e/2));h<n.top?h=n.top:h+e>n.top+n.height&&(h=n.top+n.height-e),i={left:r,top:h,width:t,height:e}}return{width:r,height:o,rect:i}}const u=["clip","crop","fill","fillmax","max","scale","min"],m=["top","bottom","left","right","center","focalpoint","entropy"],w=["format"];function g(t){const{apiHost:e,projectId:i,dataset:r}=t,o={baseUrl:(e||"https://api.sanity.io").replace(/^https:\/\/api\./,"https://cdn.")},n=t["~experimental_resource"];if("media-library"===n?.type){if("string"!=typeof n.id||0===n.id.length)throw new Error('Media library clients must include an id in "~experimental_resource"');return{...o,mediaLibraryId:n.id}}return{...o,projectId:i,dataset:r}}function y(t){const e=c;for(const i of e){const[e,r]=i;if(t===e||t===r)return e}return t}function b(t){let e={};return e=(i=t)&&"config"in i&&"function"==typeof i.config?g(t.config()):function(t){return!(!t||!("clientConfig"in t))&&"object"==typeof t.clientConfig}(t)?g(t.clientConfig):t||{},e;var i}class x{constructor(t,e){this.options=t?{...t.options||{},...e||{}}:{...e||{}}}withOptions(t){const e=function(t,e){const i=e.baseUrl||t.baseUrl,r={baseUrl:i};for(const t in e)e.hasOwnProperty(t)&&(r[y(t)]=e[t]);return{baseUrl:i,...r}}(this.options,t);return new x(this,e)}image(t){return this.withOptions({source:t})}dataset(t){return this.withOptions({dataset:t})}projectId(t){return this.withOptions({projectId:t})}withClient(t){const e=b(t),i={...this.options};return delete i.baseUrl,delete i.projectId,delete i.dataset,delete i.mediaLibraryId,new x(null,{...e,...i})}bg(t){return this.withOptions({bg:t})}dpr(t){return this.withOptions(t&&1!==t?{dpr:t}:{})}width(t){return this.withOptions({width:t})}height(t){return this.withOptions({height:t})}focalPoint(t,e){return this.withOptions({focalPoint:{x:t,y:e}})}maxWidth(t){return this.withOptions({maxWidth:t})}minWidth(t){return this.withOptions({minWidth:t})}maxHeight(t){return this.withOptions({maxHeight:t})}minHeight(t){return this.withOptions({minHeight:t})}size(t,e){return this.withOptions({width:t,height:e})}blur(t){return this.withOptions({blur:t})}sharpen(t){return this.withOptions({sharpen:t})}rect(t,e,i,r){return this.withOptions({rect:{left:t,top:e,width:i,height:r}})}format(t){return this.withOptions({format:t})}invert(t){return this.withOptions({invert:t})}orientation(t){return this.withOptions({orientation:t})}quality(t){return this.withOptions({quality:t})}forceDownload(t){return this.withOptions({download:t})}flipHorizontal(){return this.withOptions({flipHorizontal:!0})}flipVertical(){return this.withOptions({flipVertical:!0})}ignoreImageParams(){return this.withOptions({ignoreImageParams:!0})}fit(t){if(-1===u.indexOf(t))throw new Error(`Invalid fit mode "${t}"`);return this.withOptions({fit:t})}crop(t){if(-1===m.indexOf(t))throw new Error(`Invalid crop mode "${t}"`);return this.withOptions({crop:t})}saturation(t){return this.withOptions({saturation:t})}auto(t){if(-1===w.indexOf(t))throw new Error(`Invalid auto mode "${t}"`);return this.withOptions({auto:t})}pad(t){return this.withOptions({pad:t})}vanityName(t){return this.withOptions({vanityName:t})}frame(t){if(1!==t)throw new Error(`Invalid frame value "${t}"`);return this.withOptions({frame:t})}url(){return d(this.options)}toString(){return this.url()}}const $="9r24npb8",O="production";s({projectId:$,dataset:O,useCdn:!0,apiVersion:"v2025-02-19"}),new x(null,b({projectId:$,dataset:O}));const A=s=>{const p=t(14),{setOpen:l,className:c}=s,[d,f]=o(null);let u,m,w,g,y,b,x,$;return p[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{f("undefined"!=typeof navigator&&/(Mac|iPhone|iPod|iPad)/i.test(navigator?.platform??navigator?.userAgentData?.platform??""))},m=[],p[0]=u,p[1]=m):(u=p[0],m=p[1]),n(u,m),p[2]===Symbol.for("react.memo_cache_sentinel")?(w=a(r,{className:"icon-md text-icon-secondary"}),p[2]=w):w=p[2],p[3]!==d?(g=null!==d?h("div",{className:"ml-auto max-md-gutters:hidden",children:[a("kbd",{className:"h-5! leading-[19px]!",children:d?"⌘":"Ctrl"})," ",a("kbd",{className:"h-5! leading-[19px]!",children:"K"})]}):void 0,p[3]=d,p[4]=g):g=p[4],p[5]!==c?(y=e("cmdk-trigger bg-default pl-2.5 pr-3 border border-default shadow-xs min-h-[40px]",c),p[5]=c,p[6]=y):y=p[6],p[7]!==l?(b=()=>l(!0),p[7]=l,p[8]=b):b=p[8],p[9]===Symbol.for("react.memo_cache_sentinel")?(x=a("p",{className:"text-secondary font-normal leading-normal text-sm",children:"Search or Ask AI"}),p[9]=x):x=p[9],p[10]!==g||p[11]!==y||p[12]!==b?($=a(i,{theme:"secondary",leftSlot:w,rightSlot:g,className:y,onClick:b,children:x}),p[10]=g,p[11]=y,p[12]=b,p[13]=$):$=p[13],$};export{A as CommandMenuTrigger};