@wp-playground/components 3.0.14 → 3.0.15
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/FilePickerTree/index.d.ts +1 -0
- package/e2e-harnesses/file-picker-tree-harness.d.ts +2 -0
- package/icons.d.ts +4 -1
- package/index.cjs +10 -10
- package/index.cjs.map +1 -1
- package/index.js +951 -901
- package/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -23,6 +23,7 @@ export type FilePickerTreeProps = {
|
|
|
23
23
|
root?: string;
|
|
24
24
|
initialSelectedPath?: string;
|
|
25
25
|
onSelect?: (path: string | null) => void;
|
|
26
|
+
onDoubleClickFile?: (path: string) => void;
|
|
26
27
|
};
|
|
27
28
|
export type FilePickerTreeHandle = {
|
|
28
29
|
focusPath: (path: string, options?: {
|
package/icons.d.ts
CHANGED
|
@@ -10,4 +10,7 @@ export declare function getLogoDataURL(logo: {
|
|
|
10
10
|
mime: string;
|
|
11
11
|
data: string;
|
|
12
12
|
}): string;
|
|
13
|
-
export declare function SiteManagerIcon(
|
|
13
|
+
export declare function SiteManagerIcon({ size, sidebarActive, }: {
|
|
14
|
+
size?: number;
|
|
15
|
+
sidebarActive?: boolean;
|
|
16
|
+
}): React.JSX.Element;
|
package/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),ie=require("@wordpress/components"),mt=require("classnames"),X=require("@php-wasm/util"),Xe=require("@wordpress/element"),Tt=require("clsx"),Pt=l=>i.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},i.createElement("rect",{width:"10.4176",height:"10.4176",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 7.45703 24.1775)",stroke:"white",strokeWidth:"0.965644"}),i.createElement("rect",{width:"13.2346",height:"13.2346",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 5.0918 18.9934)",stroke:"white",strokeWidth:"1.44847"}),i.createElement("rect",{width:"17.451",height:"17.451",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 1.55371 11.6099)",stroke:"white",strokeWidth:"1.93129"})),kt=l=>i.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},i.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 15C4.41015 15 1.5 12.0899 1.5 8.5C1.5 4.91015 4.41015 2 8 2C11.5899 2 14.5 4.91015 14.5 8.5C14.5 12.0899 11.5899 15 8 15ZM0 8.5C0 4.08172 3.58172 0.5 8 0.5C12.4183 0.5 16 4.08172 16 8.5C16 12.9183 12.4183 16.5 8 16.5C3.58172 16.5 0 12.9183 0 8.5ZM9 9.5V4.5H7.5V8H5.5V9.5H9Z",fill:"#949494"})),St=l=>i.createElement("svg",{width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},i.createElement("path",{d:"M20 10.5C20 4.99 15.51 0.5 10 0.5C4.48 0.5 0 4.99 0 10.5C0 16.02 4.48 20.5 10 20.5C15.51 20.5 20 16.02 20 10.5ZM7.78 15.87L4.37 6.72C4.92 6.7 5.54 6.64 5.54 6.64C6.04 6.58 5.98 5.51 5.48 5.53C5.48 5.53 4.03 5.64 3.11 5.64C2.93 5.64 2.74 5.64 2.53 5.63C4.12 3.19 6.87 1.61 10 1.61C12.33 1.61 14.45 2.48 16.05 3.95C15.37 3.84 14.4 4.34 14.4 5.53C14.4 6.27 14.85 6.89 15.3 7.63C15.65 8.24 15.85 8.99 15.85 10.09C15.85 11.58 14.45 15.09 14.45 15.09L11.42 6.72C11.96 6.7 12.24 6.55 12.24 6.55C12.74 6.5 12.68 5.3 12.18 5.33C12.18 5.33 10.74 5.45 9.8 5.45C8.93 5.45 7.47 5.33 7.47 5.33C6.97 5.3 6.91 6.53 7.41 6.55L8.33 6.63L9.59 10.04L7.78 15.87ZM17.41 10.5C17.65 9.86 18.15 8.63 17.84 6.25C18.54 7.54 18.89 8.96 18.89 10.5C18.89 13.79 17.16 16.74 14.49 18.28C15.46 15.69 16.43 13.08 17.41 10.5ZM6.1 18.59C3.12 17.15 1.11 14.03 1.11 10.5C1.11 9.2 1.34 8.02 1.83 6.91C3.25 10.8 4.67 14.7 6.1 18.59ZM10.13 11.96L12.71 18.94C11.85 19.23 10.95 19.39 10 19.39C9.21 19.39 8.43 19.28 7.71 19.06C8.52 16.68 9.33 14.32 10.13 11.96Z",fill:"#ffffff"})),yt=i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none"},i.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.59196 3.59524L6.77745 1.96623C6.70755 1.82641 6.56464 1.7381 6.40832 1.7381H1.65079C1.42287 1.7381 1.2381 1.92287 1.2381 2.15079V11.8492C1.2381 12.0771 1.42287 12.2619 1.65079 12.2619H13.2063C13.4343 12.2619 13.619 12.0771 13.619 11.8492V4.00794C13.619 3.78001 13.4343 3.59524 13.2063 3.59524H7.59196ZM8.35714 2.35714L7.88484 1.41254C7.60521 0.853274 7.0336 0.5 6.40832 0.5H1.65079C0.739085 0.5 0 1.23909 0 2.15079V11.8492C0 12.7609 0.739085 13.5 1.65079 13.5H13.2063C14.1181 13.5 14.8571 12.7609 14.8571 11.8492V4.00794C14.8571 3.09623 14.1181 2.35714 13.2063 2.35714H8.35714Z"})),vt=i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"bi bi-file-earmark",viewBox:"0 0 16 16"},i.createElement("path",{d:"M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"})),Ot=l=>i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",...l},i.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12.6875C3.85888 12.6875 1.3125 10.1411 1.3125 7C1.3125 3.85888 3.85888 1.3125 7 1.3125C10.1411 1.3125 12.6875 3.85888 12.6875 7C12.6875 10.1411 10.1411 12.6875 7 12.6875ZM0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7ZM7.875 7.875V3.5H6.5625V6.5625H4.8125V7.875H7.875Z",fill:"#949494"})),jt=i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},i.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.25 1.3125H1.75C1.50838 1.3125 1.3125 1.50838 1.3125 1.75V4.37495H12.6875V1.75C12.6875 1.50837 12.4916 1.3125 12.25 1.3125ZM12.6875 5.68745H5.25003V12.6875H12.25C12.4916 12.6875 12.6875 12.4916 12.6875 12.25V5.68745ZM3.93753 5.68745H1.3125V12.25C1.3125 12.4916 1.50837 12.6875 1.75 12.6875H3.93753L3.93753 5.68745ZM1.75 0H12.25C13.2165 0 14 0.783502 14 1.75V12.25C14 13.2165 13.2165 14 12.25 14H1.75C0.783502 14 0 13.2165 0 12.25V1.75C0 0.783502 0.783502 0 1.75 0Z",fill:"#949494"}));function Dt(l){return`data:${l.mime};base64,${l.data}`}function Ft({size:l=24,sidebarActive:c=!1}){return i.createElement("svg",{width:l,height:l,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},i.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c?i.createElement("rect",{x:"3",y:"3",width:"7",height:"18",rx:"2",ry:"2",fill:"currentColor"}):i.createElement("rect",{x:"3",y:"3",width:"8",height:"18",rx:"2",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"2"}))}const ht=Xe.forwardRef(({icon:l,size:c=24,...E},g)=>Xe.cloneElement(l,{width:c,height:c,...E,ref:g}));var ft={exports:{}},We={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var pt;function At(){if(pt)return We;pt=1;var l=i,c=Symbol.for("react.element"),E=Symbol.for("react.fragment"),g=Object.prototype.hasOwnProperty,P=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,R={key:!0,ref:!0,__self:!0,__source:!0};function M(k,S,I){var _,x={},L=null,ee=null;I!==void 0&&(L=""+I),S.key!==void 0&&(L=""+S.key),S.ref!==void 0&&(ee=S.ref);for(_ in S)g.call(S,_)&&!R.hasOwnProperty(_)&&(x[_]=S[_]);if(k&&k.defaultProps)for(_ in S=k.defaultProps,S)x[_]===void 0&&(x[_]=S[_]);return{$$typeof:c,type:k,key:L,ref:ee,props:x,_owner:P.current}}return We.Fragment=E,We.jsx=M,We.jsxs=M,We}var Be={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var wt;function $t(){return wt||(wt=1,process.env.NODE_ENV!=="production"&&function(){var l=i,c=Symbol.for("react.element"),E=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),k=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),$=Symbol.iterator,U="@@iterator";function he(e){if(e===null||typeof e!="object")return null;var s=$&&e[$]||e[U];return typeof s=="function"?s:null}var D=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(e){{for(var s=arguments.length,u=new Array(s>1?s-1:0),w=1;w<s;w++)u[w-1]=arguments[w];ue("error",e,u)}}function ue(e,s,u){{var w=D.ReactDebugCurrentFrame,b=w.getStackAddendum();b!==""&&(s+="%s",u=u.concat([b]));var C=u.map(function(v){return String(v)});C.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,C)}}var pe=!1,ye=!1,Z=!1,B=!1,ve=!1,te;te=Symbol.for("react.module.reference");function m(e){return!!(typeof e=="string"||typeof e=="function"||e===g||e===R||ve||e===P||e===I||e===_||B||e===ee||pe||ye||Z||typeof e=="object"&&e!==null&&(e.$$typeof===L||e.$$typeof===x||e.$$typeof===M||e.$$typeof===k||e.$$typeof===S||e.$$typeof===te||e.getModuleId!==void 0))}function H(e,s,u){var w=e.displayName;if(w)return w;var b=s.displayName||s.name||"";return b!==""?u+"("+b+")":u}function oe(e){return e.displayName||"Context"}function Y(e){if(e==null)return null;if(typeof e.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case g:return"Fragment";case E:return"Portal";case R:return"Profiler";case P:return"StrictMode";case I:return"Suspense";case _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case k:var s=e;return oe(s)+".Consumer";case M:var u=e;return oe(u._context)+".Provider";case S:return H(e,e.render,"ForwardRef");case x:var w=e.displayName||null;return w!==null?w:Y(e.type)||"Memo";case L:{var b=e,C=b._payload,v=b._init;try{return Y(v(C))}catch{return null}}}return null}var K=Object.assign,V=0,re,xe,Te,Ee,fe,G,q;function se(){}se.__reactDisabledLog=!0;function le(){{if(V===0){re=console.log,xe=console.info,Te=console.warn,Ee=console.error,fe=console.group,G=console.groupCollapsed,q=console.groupEnd;var e={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}V++}}function _e(){{if(V--,V===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},e,{value:re}),info:K({},e,{value:xe}),warn:K({},e,{value:Te}),error:K({},e,{value:Ee}),group:K({},e,{value:fe}),groupCollapsed:K({},e,{value:G}),groupEnd:K({},e,{value:q})})}V<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=D.ReactCurrentDispatcher,we;function W(e,s,u){{if(we===void 0)try{throw Error()}catch(b){var w=b.stack.trim().match(/\n( *(at )?)/);we=w&&w[1]||""}return`
|
|
18
|
+
`+we+e}}var j=!1,ne;{var d=typeof WeakMap=="function"?WeakMap:Map;ne=new d}function F(e,s){if(!e||j)return"";{var u=ne.get(e);if(u!==void 0)return u}var w;j=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var C;C=de.current,de.current=null,le();try{if(s){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(J){w=J}Reflect.construct(e,[],v)}else{try{v.call()}catch(J){w=J}e.call(v.prototype)}}else{try{throw Error()}catch(J){w=J}e()}}catch(J){if(J&&w&&typeof J.stack=="string"){for(var y=J.stack.split(`
|
|
19
|
+
`),z=w.stack.split(`
|
|
20
|
+
`),A=y.length-1,N=z.length-1;A>=1&&N>=0&&y[A]!==z[N];)N--;for(;A>=1&&N>=0;A--,N--)if(y[A]!==z[N]){if(A!==1||N!==1)do if(A--,N--,N<0||y[A]!==z[N]){var ce=`
|
|
21
|
+
`+y[A].replace(" at new "," at ");return e.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",e.displayName)),typeof e=="function"&&ne.set(e,ce),ce}while(A>=1&&N>=0);break}}}finally{j=!1,de.current=C,_e(),Error.prepareStackTrace=b}var Fe=e?e.displayName||e.name:"",Oe=Fe?W(Fe):"";return typeof e=="function"&&ne.set(e,Oe),Oe}function ae(e,s,u){return F(e,!1)}function be(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function Pe(e,s,u){if(e==null)return"";if(typeof e=="function")return F(e,be(e));if(typeof e=="string")return W(e);switch(e){case I:return W("Suspense");case _:return W("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case S:return ae(e.render);case x:return Pe(e.type,s,u);case L:{var w=e,b=w._payload,C=w._init;try{return Pe(C(b),s,u)}catch{}}}return""}var me=Object.prototype.hasOwnProperty,$e={},Ye=D.ReactDebugCurrentFrame;function Re(e){if(e){var s=e._owner,u=Pe(e.type,e._source,s?s.type:null);Ye.setExtraStackFrame(u)}else Ye.setExtraStackFrame(null)}function Qe(e,s,u,w,b){{var C=Function.call.bind(me);for(var v in e)if(C(e,v)){var y=void 0;try{if(typeof e[v]!="function"){var z=Error((w||"React class")+": "+u+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw z.name="Invariant Violation",z}y=e[v](s,v,w,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(A){y=A}y&&!(y instanceof Error)&&(Re(b),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",w||"React class",u,v,typeof y),Re(null)),y instanceof Error&&!(y.message in $e)&&($e[y.message]=!0,Re(b),T("Failed %s type: %s",u,y.message),Re(null))}}}var Ne=Array.isArray;function Me(e){return Ne(e)}function et(e){{var s=typeof Symbol=="function"&&Symbol.toStringTag,u=s&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function tt(e){try{return qe(e),!1}catch{return!0}}function qe(e){return""+e}function ze(e){if(tt(e))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",et(e)),qe(e)}var Ue=D.ReactCurrentOwner,rt={key:!0,ref:!0,__self:!0,__source:!0},ke,Se;function nt(e){if(me.call(e,"ref")){var s=Object.getOwnPropertyDescriptor(e,"ref").get;if(s&&s.isReactWarning)return!1}return e.ref!==void 0}function at(e){if(me.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function it(e,s){typeof e.ref=="string"&&Ue.current}function ot(e,s){{var u=function(){ke||(ke=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function st(e,s){{var u=function(){Se||(Se=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var Ze=function(e,s,u,w,b,C,v){var y={$$typeof:c,type:e,key:s,ref:u,props:v,_owner:C};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function Ke(e,s,u,w,b){{var C,v={},y=null,z=null;u!==void 0&&(ze(u),y=""+u),at(s)&&(ze(s.key),y=""+s.key),nt(s)&&(z=s.ref,it(s,b));for(C in s)me.call(s,C)&&!rt.hasOwnProperty(C)&&(v[C]=s[C]);if(e&&e.defaultProps){var A=e.defaultProps;for(C in A)v[C]===void 0&&(v[C]=A[C])}if(y||z){var N=typeof e=="function"?e.displayName||e.name||"Unknown":e;y&&ot(v,N),z&&st(v,N)}return Ze(e,y,z,b,w,Ue.current,v)}}var je=D.ReactCurrentOwner,Ge=D.ReactDebugCurrentFrame;function Ce(e){if(e){var s=e._owner,u=Pe(e.type,e._source,s?s.type:null);Ge.setExtraStackFrame(u)}else Ge.setExtraStackFrame(null)}var Ie;Ie=!1;function Le(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function Je(){{if(je.current){var e=Y(je.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function t(e){return""}var r={};function n(e){{var s=Je();if(!s){var u=typeof e=="string"?e:e.displayName||e.name;u&&(s=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+u+">.")}return s}}function
|
|
25
|
+
Check the top-level render call using <`+u+">.")}return s}}function o(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=n(s);if(r[u])return;r[u]=!0;var w="";e&&e._owner&&e._owner!==je.current&&(w=" It was passed a child from "+Y(e._owner.type)+"."),Ce(e),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,w),Ce(null)}}function a(e,s){{if(typeof e!="object")return;if(Me(e))for(var u=0;u<e.length;u++){var w=e[u];Le(w)&&o(w,s)}else if(Le(e))e._store&&(e._store.validated=!0);else if(e){var b=he(e);if(typeof b=="function"&&b!==e.entries)for(var C=b.call(e),v;!(v=C.next()).done;)Le(v.value)&&o(v.value,s)}}}function h(e){{var s=e.type;if(s==null||typeof s=="string")return;var u;if(typeof s=="function")u=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===S||s.$$typeof===x))u=s.propTypes;else return;if(u){var w=Y(s);Qe(u,e.props,"prop",w,e)}else if(s.PropTypes!==void 0&&!Ie){Ie=!0;var b=Y(s);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function f(e){{for(var s=Object.keys(e.props),u=0;u<s.length;u++){var w=s[u];if(w!=="children"&&w!=="key"){Ce(e),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",w),Ce(null);break}}e.ref!==null&&(Ce(e),T("Invalid attribute `ref` supplied to `React.Fragment`."),Ce(null))}}var p={};function O(e,s,u,w,b,C){{var v=m(e);if(!v){var y="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var z=t();z?y+=z:y+=Je();var A;e===null?A="null":Me(e)?A="array":e!==void 0&&e.$$typeof===c?(A="<"+(Y(e.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):A=typeof e,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",A,y)}var N=Ke(e,s,u,b,C);if(N==null)return N;if(v){var ce=s.children;if(ce!==void 0)if(w)if(Me(ce)){for(var Fe=0;Fe<ce.length;Fe++)a(ce[Fe],e);Object.freeze&&Object.freeze(ce)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else a(ce,e)}if(me.call(s,"key")){var Oe=Y(e),J=Object.keys(s).filter(function(xt){return xt!=="key"}),lt=J.length>0?"{key: someKey, "+J.join(": ..., ")+": ...}":"{key: someKey}";if(!p[Oe+lt]){var Ct=J.length>0?"{"+J.join(": ..., ")+": ...}":"{}";T(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,st,Te,Rt,Te),V[Te+st]=!0}}return e===p?g(M):d(M),M}}function Je(e,s,u){return xe(e,s,u,!0)}function Xe(e,s,u){return xe(e,s,u,!1)}var bt=Xe,_t=Je;Ie.Fragment=p,Ie.jsx=bt,Ie.jsxs=_t}()),Ie}process.env.NODE_ENV==="production"?ut.exports=At():ut.exports=Mt();var He=ut.exports;const yt=l=>Qe.createElement("path",l),ft=Qe.forwardRef(({className:l,isPressed:c,...C},p)=>{const x={...C,className:Tt(l,{"is-pressed":c})||void 0,"aria-hidden":!0,focusable:!1};return He.jsx("svg",{...x,ref:p})});ft.displayName="SVG";const Vt=He.jsx(ft,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:He.jsx(yt,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),Nt=He.jsx(ft,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:He.jsx(yt,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),$t="_file-picker-tree_3rwm2_1",It="_file-node-button_3rwm2_17",Ht="_selected_3rwm2_53",Lt="_focused_3rwm2_65",Bt="_dropTarget_3rwm2_70",Wt="_dropTargetInvalid_3rwm2_79",Zt="_renaming_3rwm2_88",Yt="_renameInput_3rwm2_93",zt="_file-name_3rwm2_108",Q={filePickerTree:$t,fileNodeButton:It,selected:Ht,focused:Lt,dropTarget:Bt,dropTargetInvalid:Wt,renaming:Zt,renameInput:Yt,fileName:zt};function lt(l){if(!l)return[];const c=l.replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/").replace(/\/$/,"")||l,C=c.startsWith("/"),p=c.split("/").filter(Boolean),x=[];let P=C?"/":"";C&&x.push("/");for(const T of p)!P||P==="/"?P=P==="/"?`/${T}`:T:P=`${P}/${T}`,x.push(P);return x}function qt(l,c){if(!l||!c||l===c)return!1;const C=l==="/"?"/":l.replace(/\/{2,}/g,"/"),p=c.replace(/\/{2,}/g,"/");return C==="/"?p.startsWith("/")&&p!=="/":p.startsWith(`${C}/`)}function ct(l,c,C){return l&&(l===c?C:l.startsWith(c==="/"?"/":`${c}/`)?C+l.slice(c.length):l)}const Et=o.forwardRef(function({filesystem:c,root:C="/wordpress",initialSelectedPath:p,onSelect:x=()=>{}},P){const T=o.useMemo(()=>{let t=(C||"/").replace(/\\+/g,"/");return t.startsWith("/")||(t=`/${t}`),t=t.replace(/\/{2,}/g,"/"),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"},[C]),I=t=>!t||t==="."||t===".."?!1:!/[\\/]/.test(t),[k,O]=o.useState(()=>{if(!p)return{};const t={};for(const r of lt(p))t[r]=!0;return t}),[y,H]=o.useState(()=>p??null),[N,F]=o.useState(()=>p??null),[te,U]=o.useState({}),[he,S]=o.useState({}),[R,se]=o.useState(null),[pe,K]=o.useState(null),W=o.useRef({}),ie=o.useRef(!1),le=o.useRef(null),w=o.useRef(null),G=o.useRef(he),ne=o.useRef(te),ce=()=>{for(const t of Object.keys(W.current))clearTimeout(W.current[t]),delete W.current[t]},Z=t=>{const r=W.current[t];r&&(clearTimeout(r),delete W.current[t])};o.useEffect(()=>{G.current=he},[he]),o.useEffect(()=>{ne.current=te},[te]);const j=t=>{var n;const r=(n=le.current)==null?void 0:n.querySelector(`[data-path="${t}"]`);r&&typeof r.focus=="function"&&r.focus()},L=(t,r="")=>(r?`${r}/${t.name}`:t.name).replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/"),Ce=(t,r)=>t.children?t.children:te[r],be=async(t,r)=>{const n=await t.listFiles(r),i=[];for(const a of n){const m=r==="/"?`/${a}`:`${r}/${a}`,d=await t.isDir(m);i.push({name:a,type:d?"folder":"file"})}return i.sort((a,m)=>a.type!==m.type?a.type==="folder"?-1:1:a.name.localeCompare(m.name)),i},we=async t=>await be(c,t),oe=(t,r)=>{if(r.type!=="folder")return r.children;const n=r.children??ne.current[t];return n||G.current[t]?n:(S(i=>({...i,[t]:!0})),new Promise(i=>{we(t).then(a=>{U(m=>({...m,[t]:a??[]})),i(a??[])}).catch(()=>{i([])}).finally(()=>{S(a=>{const m={...a};return delete m[t],m})})}))},ge=(t,r)=>{r.type==="folder"&&(typeof window>"u"||W.current[t]||(W.current[t]=window.setTimeout(()=>{O(n=>n[t]?n:{...n,[t]:!0}),oe(t,r),delete W.current[t]},600)))},A=t=>(S(r=>({...r,[t]:!0})),new Promise(r=>{we(t).then(n=>{U(i=>({...i,[t]:n??[]})),r(n??[])}).catch(()=>{r([])}).finally(()=>{S(n=>{const i={...n};return delete i[t],i})})})),ve=(t,r,n)=>{O(i=>({...i,[t]:n})),n?oe(t,r):U(i=>{if(i[t]===void 0)return i;const a={...i};return delete a[t],a})},ae=async t=>{if(!t)return;const r=lt(t);if(r.length===0)return;O(a=>{const m={...a};for(const d of r)m[d]=!0;return m});let n=[{name:T,type:"folder"}],i="";for(const a of r){const m=n==null?void 0:n.find(g=>L(g,i)===a);if(!m||m.type!=="folder"){i=a,n=[];continue}n=await oe(a,m)??ne.current[a],i=a}},ue=(t,r)=>{if(!t||!r||t===r)return;const n=t==="/"?"/":`${t}/`,i=a=>a===t?r:a.startsWith(n)?r+a.slice(t.length):null;O(a=>{let m=!1;const d={...a};for(const g of Object.keys(a)){const V=i(g);V&&V!==g&&(d[V]=a[g],delete d[g],m=!0)}return m?d:a}),U(a=>{let m=!1;const d={...a};for(const g of Object.keys(a)){const V=i(g);V&&V!==g&&(d[V]=a[g],delete d[g],m=!0)}return m?d:a}),H(a=>a&&(i(a)??a)),F(a=>a&&(i(a)??a))},_e=()=>{se(null),K(null),ce()},fe=(t,r=!0)=>{H(t),r&&x(t)},B=o.useMemo(()=>[{name:T,type:"folder"}],[T]),[f,$]=o.useState(null),[de,Y]=o.useState(null),z=o.useRef(null),Pe=de;o.useImperativeHandle(P,()=>({focusPath:(t,r={})=>{if(!t)return;const{select:n=!0,domFocus:i=!0,notify:a=!1}=r;n&&fe(t,a),F(t),i&&j(t)},selectPath:t=>{t&&(fe(t),F(t),j(t))},getSelectedPath:()=>y,expandToPath:async t=>await ae(t),refresh:async t=>await A(t),remapPath:ue,createFile:async t=>{await Re(t,"file","untitled.php")},createFolder:async t=>{await Re(t,"folder","New Folder")}}),[y,A,ue,ae]);const Le=o.useRef(!1),me=o.useRef(p??null),ye=o.useRef(p);o.useEffect(()=>{ie.current=!1},[T]),o.useEffect(()=>{p&&p!==ye.current?me.current=p:p||(me.current=null),ye.current=p},[p]),o.useEffect(()=>{if(!p||Le.current)return;Le.current=!0;const t=lt(p);O(n=>{const i={...n};for(const a of t)i[a]=!0;return i});const r=t[t.length-1]||p;F(r),H(r),ae(p)},[p,ae]),o.useEffect(()=>{const t=me.current;!t||B.length===0||(me.current=null,ae(t))},[B,ae]),o.useEffect(()=>{if(!N){if(B.length>0){const t=L(B[0]);F(t)}return}Pe&&Pe===N||j(N)},[B,N,L,Pe,j]),o.useEffect(()=>{if(B.length===0)return;const t=B[0];if((t==null?void 0:t.type)!=="folder"||ie.current)return;const r=t.name;ie.current=!0,O(n=>n[r]?n:{...n,[r]:!0}),!ne.current[r]&&!G.current[r]&&oe(r,t)},[B,oe,T]),o.useEffect(()=>()=>{w.current&&clearTimeout(w.current),ce()},[]);const[Be,ke]=o.useState(""),Se=(t,r)=>{if(t.type==="folder")return r;const n=X.dirname(r);return n&&n||"/"},je=(t,r,n)=>{const i=Se(t,r);if(!i)return{allowed:!1,state:"invalid",destination:null};if(n){if(i===n)return{allowed:!1,state:"invalid",destination:null};if(qt(n,i))return{allowed:!1,state:"invalid",destination:null}}return{allowed:!0,state:"valid",destination:i}},et=(t,r,n)=>{r.type!=="folder"&&r.type!=="file"||(se(n),K(null),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-wp-playground-path",n),t.dataTransfer.setData("text/plain",n)))},Ae=()=>{_e()},tt=(t,r,n)=>{const i=je(r,n,R);i.allowed&&r.type==="folder"&&ge(n,r),K(a=>(a==null?void 0:a.path)===n&&a.state===i.state?a:{path:n,state:i.state})},rt=(t,r,n)=>{const i=je(r,n,R);i.allowed&&i.destination?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=R?"move":"copy"),r.type==="folder"&&ge(n,r),K(a=>(a==null?void 0:a.path)===n&&a.state===i.state?a:{path:n,state:i.state})):(t.dataTransfer&&(t.dataTransfer.dropEffect="none"),Z(n),K(a=>(a==null?void 0:a.path)===n&&a.state==="invalid"?a:{path:n,state:"invalid"}))},We=(t,r,n)=>{Z(n);const i=t.relatedTarget;i&&t.currentTarget.contains(i)||K(a=>(a==null?void 0:a.path)===n?null:a)},Ze=async(t,r,n)=>{const i=R,a=je(r,n,i);if(!a.allowed||!a.destination){_e();return}t.preventDefault(),t.stopPropagation(),Z(n),K(null);try{i?await at(i,a.destination):await Me(t,a.destination)}finally{_e()}},Ye=(t,r,n)=>{t.preventDefault(),t.stopPropagation(),Y(null),$({absPath:n,type:r.type,x:t.clientX,y:t.clientY})},Oe=async(t,r)=>{let n=r,i=0;const a=d=>{const g=d.lastIndexOf(".");return g>0?{stem:d.slice(0,g),ext:d.slice(g)}:{stem:d,ext:""}},m=t==="/"?"":t;for(;await(c==null?void 0:c.fileExists(`${m}/${n}`))||await(c==null?void 0:c.isDir(`${m}/${n}`));){i+=1;const{stem:d,ext:g}=a(r);n=`${d} (${i})${g}`}return n},Re=async(t,r,n)=>{if(!c)return;let i=t||y||T;try{await c.isDir(i)||(i=X.dirname(i))}catch{i=X.dirname(i)}const a=i,m=await Oe(a,n),d=X.joinPaths(a,m);r==="folder"?await c.mkdir(d):await c.writeFile(d,""),z.current={type:r,tempPath:d},Y(d),await A(a),setTimeout(()=>{F(d),j(d)},0)},ze=async t=>{if(!c)return!1;try{if(await c.fileExists(t))return!0}catch{}try{if(await c.isDir(t))return!0}catch{}return!1},nt=async t=>{if(c)try{await c.mkdir(t)}catch(r){if(!await c.isDir(t).catch(()=>!1))throw r}},at=async(t,r)=>{if(!c)return;const n=X.basename(t),i=X.joinPaths(r,n);if(i===t||await ze(i))return;const a=X.dirname(t);try{await c.mv(t,i),ue(t,i);const m=ct(y,t,i);y&&(y===t||y.startsWith(`${t}/`))&&x(m),F(d=>ct(d,t,i)),O(d=>({...d,[r]:!0})),await Promise.all([A(a),A(r)]),H(d=>ct(d,t,i)),j(i)}catch{}},it=t=>{const r=t;return r.webkitGetAsEntry?r.webkitGetAsEntry():null},ot=t=>new Promise((r,n)=>{t.file(r,n)}),qe=async(t,r)=>{if(!c)return;const n=t.name||"untitled",i=await Oe(r,n),a=X.joinPaths(r,i),m=new Uint8Array(await t.arrayBuffer());await c.writeFile(a,m)},Ue=async(t,r)=>{const n=await ot(t);await qe(n,r)},Ke=async(t,r)=>{const n=await Oe(r,t.name||"New Folder"),i=X.joinPaths(r,n);await nt(i);const a=t.createReader(),m=()=>new Promise((d,g)=>{a.readEntries(V=>d(Array.from(V)),g)});for(;;){const d=await m();if(!d.length)break;for(const g of d)g.isFile?await Ue(g,i):g.isDirectory&&await Ke(g,i)}},Me=async(t,r)=>{var a,m;if(!c)return;const i=((a=t.dataTransfer)!=null&&a.items?Array.from(t.dataTransfer.items):[]).filter(d=>d.kind==="file").map(d=>it(d)).filter(d=>!!d);if(i.length>0)for(const d of i)d.isFile?await Ue(d,r):d.isDirectory&&await Ke(d,r);else{const d=(m=t.dataTransfer)!=null&&m.files?Array.from(t.dataTransfer.files):[];for(const g of d)await qe(g,r)}await A(r),O(d=>({...d,[r]:!0}))},Ge=async(t,r)=>{if(!c)return;const n=t;$(null);try{r==="folder"?await c.rmdir(n,{recursive:!0}):await c.unlink(n)}catch{}finally{Y(null);const i=X.dirname(n);await A(i),y&&(y===n||y.startsWith(`${n}/`))&&x(null)}},Ee=t=>{var r;if(t.key.length===1&&t.key.match(/\S/)){const n=Be+t.key.toLowerCase();if(ke(n),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{ke("")},1e3),!le.current)return;const i=Array.from(le.current.querySelectorAll(".file-node-button")),a=document.activeElement;let m=0;a&&i.includes(a)&&(m=i.indexOf(a));for(let d=0;d<i.length;d++){const g=(m+d)%i.length,V=i[g];if((r=V.textContent)!=null&&r.toLowerCase().trim().startsWith(n)){V.focus();const xe=V.getAttribute("data-path");xe&&F(xe);break}}}else ke(""),w.current&&clearTimeout(w.current)},Ve=async(t,r)=>{const n=z.current,i=(n==null?void 0:n.tempPath)===t,a=X.dirname(t),m=(r||"").trim();if(!I(m)){if(i){try{n.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}z.current=null}Y(i?null:t);return}let d=X.joinPaths(a,m),g=d;if(g===t){Y(null),i&&(z.current=null),setTimeout(()=>{F(g),j(g)},0);return}const V=await c.fileExists(g),xe=await c.isDir(g);if((V||xe)&&g!==t)if(i)try{const Xe=await Oe(a==="/"?"/":a,m);d=X.joinPaths(a,Xe),g=d}catch{}else{Y(t);return}let Je=(n==null?void 0:n.type)==="folder";try{await c.mv(t,d),n||(Je=await c.isDir(d)),Je&&ue(t,g),y===t&&x(g),await A(a),F(g),j(g)}catch{if(i)try{(n==null?void 0:n.type)==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}}finally{z.current=null,Y(null)}},Ne=async t=>{const r=z.current;if(!c||(r==null?void 0:r.tempPath)!==t){Y(i=>i===t?null:i);return}try{r.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}z.current=null,Y(null);const n=X.dirname(t);await A(n),F(n),j(n)};return o.createElement("div",{onKeyDown:Ee,ref:le},o.createElement(ee.__experimentalTreeGrid,{className:Q.filePickerTree},B.map((t,r)=>o.createElement(Ct,{key:t.name,node:t,level:0,position:r+1,setSize:B.length,expandedNodePaths:k,onToggle:ve,selectedNode:y,focusPath:n=>F(n),focusedNode:N,selectPath:fe,generatePath:L,getChildren:Ce,onContextMenu:Ye,renamingPath:Pe,onRename:Ve,onRenameCancel:Ne,dropIndicator:pe,onDragStart:et,onDragEnd:Ae,onDragEnter:tt,onDragOver:rt,onDragLeave:We,onDrop:Ze,rootPath:T}))),f&&o.createElement(ee.Popover,{placement:"bottom-start",onClose:()=>$(null),anchor:{getBoundingClientRect:()=>({x:f.x,y:f.y,width:0,height:0,top:f.y,left:f.x,right:f.x,bottom:f.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},o.createElement(ee.NavigableMenu,{role:"menu"},f.type==="folder"&&o.createElement(ee.MenuItem,{role:"menuitem",onClick:async()=>{$(null),await Re(f.absPath,"file","untitled.php")}},"Create file"),f.type==="folder"&&o.createElement(ee.MenuItem,{role:"menuitem",onClick:async()=>{$(null),await Re(f.absPath,"folder","New Folder")}},"Create directory"),o.createElement(ee.MenuItem,{role:"menuitem",onClick:()=>{$(null),Y(f.absPath)}},"Rename"),o.createElement(ee.MenuItem,{role:"menuitem",onClick:()=>Ge(f.absPath,f.type)},"Delete"))))}),Ct=({node:l,level:c,position:C,setSize:p,expandedNodePaths:x,onToggle:P,selectedNode:T,focusPath:I,focusedNode:k,selectPath:O,generatePath:y,getChildren:H,onContextMenu:N,renamingPath:F,onRename:te,onRenameCancel:U,parentPath:he="",dropIndicator:S,onDragStart:R,onDragEnd:se,onDragEnter:pe,onDragOver:K,onDragLeave:W,onDrop:ie,rootPath:le})=>{const w=y(l,he),G=x[w],ne=F===w,ce=o.useRef(null),[Z,j]=o.useState(l.name),L=o.useRef(!1),Ce=(S==null?void 0:S.path)===w,be=Ce&&(S==null?void 0:S.state)==="valid",we=Ce&&(S==null?void 0:S.state)==="invalid",oe=!ne&&w!==le,ge={onDragEnter:f=>pe==null?void 0:pe(f,l,w),onDragOver:f=>K==null?void 0:K(f,l,w),onDragLeave:f=>W==null?void 0:W(f,l,w),onDrop:f=>ie==null?void 0:ie(f,l,w)},A=H(l,w)??[];o.useEffect(()=>{var f;ne?(j(l.name),L.current=!1,typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(()=>{var $;($=ce.current)==null||$.select()}):(f=ce.current)==null||f.select()):L.current=!1},[ne,l.name]);const ve=()=>{l.type==="folder"&&P(w,l,!G)},ae=f=>{var $,de,Y;if(f.key==="ArrowLeft")G?ve():($=document.querySelector(`[data-path="${he}"]`))==null||$.focus(),f.preventDefault(),f.stopPropagation();else if(f.key==="ArrowRight"){if(G){if(A!=null&&A.length){const z=y(A[0],w);(de=document.querySelector(`[data-path="${z}"]`))==null||de.focus()}}else ve();f.preventDefault(),f.stopPropagation()}else if(f.key===" "||f.key==="Space"||f.key==="Spacebar")l.type==="folder"&&P(w,l,!G),f.preventDefault();else if(f.key==="Enter"){O(w),I(w);const z=(Y=f.currentTarget)==null?void 0:Y.closest("form");z&&setTimeout(()=>{z.dispatchEvent(new Event("submit",{bubbles:!0}))})}},ue=f=>{N==null||N(f,l,w)},_e=f=>{f.preventDefault(),L.current=!0,te==null||te(w,Z.trim())},fe=f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),L.current=!0,U==null||U(w);return}(f.key==="ArrowLeft"||f.key==="ArrowRight"||f.key==="ArrowUp"||f.key==="ArrowDown")&&f.stopPropagation()},B=()=>{L.current||U==null||U(w),L.current=!1};return o.createElement(o.Fragment,null,o.createElement(ee.__experimentalTreeGridRow,{level:c,positionInSet:C,setSize:p},o.createElement(ee.__experimentalTreeGridCell,null,()=>o.createElement(o.Fragment,null,ne?o.createElement("form",{onSubmit:_e,className:dt(Q.fileNodeButton,Q.renaming,"file-node-button",{[Q.selected]:T===w,[Q.focused]:k===w,[Q.dropTarget]:be,[Q.dropTargetInvalid]:we}),"data-path":w,onContextMenu:ue,...ge},o.createElement(wt,{node:l,isOpen:l.type==="folder"&&G,level:c,hideName:!0}),o.createElement("input",{ref:ce,className:Q.renameInput,value:Z,onChange:f=>j(f.target.value),onBlur:B,onFocus:()=>I(w),onKeyDown:fe})):o.createElement(ee.Button,{...ge,draggable:oe,onDragStart:f=>R==null?void 0:R(f,l,w),onDragEnd:f=>se==null?void 0:se(f,l,w),onClick:()=>{l.type==="folder"&&ve(),O(w),I(w)},onKeyDown:ae,onFocus:()=>{I(w)},onContextMenu:ue,className:dt(Q.fileNodeButton,{[Q.selected]:T===w,[Q.focused]:k===w,[Q.dropTarget]:be,[Q.dropTargetInvalid]:we}),"data-path":w,"data-expanded":G?"true":"false"},o.createElement(wt,{node:l,isOpen:l.type==="folder"&&G,level:c}))))),G&&A&&A.map((f,$)=>o.createElement(Ct,{key:f.name,node:f,level:c+1,position:$+1,setSize:A.length,expandedNodePaths:x,onToggle:P,selectedNode:T,focusPath:I,focusedNode:k,selectPath:O,generatePath:y,getChildren:H,onContextMenu:N,renamingPath:F,onRename:te,onRenameCancel:U,parentPath:w,dropIndicator:S,onDragStart:R,onDragEnd:se,onDragEnter:pe,onDragOver:K,onDragLeave:W,onDrop:ie,rootPath:le})))},wt=({node:l,level:c,isOpen:C,hideName:p=!1})=>{const x=[];for(let P=0;P<c;P++)x.push(" ");return o.createElement(o.Fragment,null,o.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:x.join("")}}),l.type==="folder"?o.createElement(mt,{width:16,icon:C?Vt:Nt}):o.createElement("div",{style:{width:16}}," "),o.createElement(mt,{width:16,icon:l.type==="folder"?gt:vt}),!p&&o.createElement("span",{className:Q.fileName},l.name))},Ut="_control_kp9d9_1",Kt="_browse-label_kp9d9_11",Gt="_path-preview_kp9d9_37",Jt="_modal_kp9d9_43",Xt="_modal-footer_kp9d9_48",Fe={control:Ut,browseLabel:Kt,pathPreview:Gt,modal:Jt,modalFooter:Xt};function Qt({path:l}){if(!l)return o.createElement("div",{className:Fe.pathPreview},o.createElement("i",null,"Select a path"));const c=l.split("/");let C=(c.length>2?"/":"")+c.pop();C.length>10&&(C=C.substring(C.length-10));const p=l.substring(0,l.length-C.length);return o.createElement("div",{className:Fe.pathPreview,"data-content-start":p,"data-content-end":C})}function er({value:l="",onChange:c,filesystem:C}){const[p,x]=o.useState(!1),P=()=>x(!0),T=()=>x(!1),[I,k]=o.useState(l||null);function O(y){y==null||y.preventDefault(),c(I||""),T()}return o.createElement(o.Fragment,null,o.createElement(ee.Button,{variant:"tertiary",className:Fe.control,onClick:P},o.createElement("span",{className:Fe.browseLabel},"Browse"),o.createElement(Qt,{path:l||""})),p&&o.createElement(ee.Modal,{title:"Select a path ",onRequestClose:T,className:Fe.modal},o.createElement("form",{onSubmit:O},o.createElement(Et,{filesystem:C,initialSelectedPath:l,onSelect:k}),o.createElement("div",{className:Fe.modalFooter},o.createElement(ee.Button,{type:"submit",variant:"primary"},"Select Path")))))}exports.ClockIcon=Ot;exports.FilePickerControl=er;exports.FilePickerTree=Et;exports.SiteManagerIcon=jt;exports.WordPressIcon=St;exports.file=vt;exports.folder=gt;exports.getLogoDataURL=Ft;exports.layout=Dt;exports.playgroundLogo=Pt;exports.temporaryStorage=kt;
|
|
30
|
+
<%s key={someKey} {...props} />`,lt,Oe,Ct,Oe),p[Oe+lt]=!0}}return e===g?f(N):h(N),N}}function ge(e,s,u){return O(e,s,u,!0)}function Ve(e,s,u){return O(e,s,u,!1)}var De=Ve,Rt=ge;Be.Fragment=g,Be.jsx=De,Be.jsxs=Rt}()),Be}process.env.NODE_ENV==="production"?ft.exports=At():ft.exports=$t();var He=ft.exports;const Et=l=>Xe.createElement("path",l),dt=Xe.forwardRef(({className:l,isPressed:c,...E},g)=>{const P={...E,className:Tt(l,{"is-pressed":c})||void 0,"aria-hidden":!0,focusable:!1};return He.jsx("svg",{...P,ref:g})});dt.displayName="SVG";const Nt=He.jsx(dt,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:He.jsx(Et,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),Mt=He.jsx(dt,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:He.jsx(Et,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),It="_file-picker-tree_3rwm2_1",Lt="_file-node-button_3rwm2_17",Vt="_selected_3rwm2_53",Wt="_focused_3rwm2_65",Bt="_dropTarget_3rwm2_70",Ht="_dropTargetInvalid_3rwm2_79",Yt="_renaming_3rwm2_88",qt="_renameInput_3rwm2_93",zt="_file-name_3rwm2_108",Q={filePickerTree:It,fileNodeButton:Lt,selected:Vt,focused:Wt,dropTarget:Bt,dropTargetInvalid:Ht,renaming:Yt,renameInput:qt,fileName:zt};function ct(l){if(!l)return[];const c=l.replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/").replace(/\/$/,"")||l,E=c.startsWith("/"),g=c.split("/").filter(Boolean),P=[];let R=E?"/":"";E&&P.push("/");for(const M of g)!R||R==="/"?R=R==="/"?`/${M}`:M:R=`${R}/${M}`,P.push(R);return P}function Ut(l,c){if(!l||!c||l===c)return!1;const E=l==="/"?"/":l.replace(/\/{2,}/g,"/"),g=c.replace(/\/{2,}/g,"/");return E==="/"?g.startsWith("/")&&g!=="/":g.startsWith(`${E}/`)}function ut(l,c,E){return l&&(l===c?E:l.startsWith(c==="/"?"/":`${c}/`)?E+l.slice(c.length):l)}const _t=i.forwardRef(function({filesystem:c,root:E="/wordpress",initialSelectedPath:g,onSelect:P=()=>{},onDoubleClickFile:R},M){const k=i.useMemo(()=>{let t=(E||"/").replace(/\\+/g,"/");return t.startsWith("/")||(t=`/${t}`),t=t.replace(/\/{2,}/g,"/"),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"},[E]),S=t=>!t||t==="."||t===".."?!1:!/[\\/]/.test(t),[I,_]=i.useState(()=>{if(!g)return{};const t={};for(const r of ct(g))t[r]=!0;return t}),[x,L]=i.useState(()=>g??null),[ee,$]=i.useState(()=>g??null),[U,he]=i.useState({}),[D,T]=i.useState({}),[ue,pe]=i.useState(null),[ye,Z]=i.useState(null),B=i.useRef({}),ve=i.useRef(!1),te=i.useRef(null),m=i.useRef(null),H=i.useRef(D),oe=i.useRef(U),Y=()=>{for(const t of Object.keys(B.current))clearTimeout(B.current[t]),delete B.current[t]},K=t=>{const r=B.current[t];r&&(clearTimeout(r),delete B.current[t])};i.useEffect(()=>{H.current=D},[D]),i.useEffect(()=>{oe.current=U},[U]);const V=t=>{var n;const r=(n=te.current)==null?void 0:n.querySelector(`[data-path="${t}"]`);r&&typeof r.focus=="function"&&(r.focus(),r.scrollIntoView({behavior:"smooth",block:"nearest"}))},re=(t,r="")=>(r?`${r}/${t.name}`:t.name).replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/"),xe=(t,r)=>t.children?t.children:U[r],Te=async(t,r)=>{const n=await t.listFiles(r),o=[];for(const a of n){const h=r==="/"?`/${a}`:`${r}/${a}`,f=await t.isDir(h);o.push({name:a,type:f?"folder":"file"})}return o.sort((a,h)=>{var ge;if(a.type!==h.type)return a.type==="folder"?-1:1;const f=r==="/"?`/${a.name}`:`${r}/${a.name}`,p=r==="/"?`/${h.name}`:`${r}/${h.name}`,O=(ge=ae.current)==null?void 0:ge.tempPath;if(O){if(f===O)return-1;if(p===O)return 1}return a.name.localeCompare(h.name)}),o},Ee=async t=>await Te(c,t),fe=(t,r)=>{if(r.type!=="folder")return r.children;const n=r.children??oe.current[t];return n||H.current[t]?n:(T(o=>({...o,[t]:!0})),new Promise(o=>{Ee(t).then(a=>{he(h=>({...h,[t]:a??[]})),o(a??[])}).catch(()=>{o([])}).finally(()=>{T(a=>{const h={...a};return delete h[t],h})})}))},G=(t,r)=>{r.type==="folder"&&(typeof window>"u"||B.current[t]||(B.current[t]=window.setTimeout(()=>{_(n=>n[t]?n:{...n,[t]:!0}),fe(t,r),delete B.current[t]},600)))},q=t=>(T(r=>({...r,[t]:!0})),new Promise(r=>{Ee(t).then(n=>{he(o=>({...o,[t]:n??[]})),r(n??[])}).catch(()=>{r([])}).finally(()=>{T(n=>{const o={...n};return delete o[t],o})})})),se=(t,r,n)=>{_(o=>({...o,[t]:n})),n?fe(t,r):he(o=>{if(o[t]===void 0)return o;const a={...o};return delete a[t],a})},le=async t=>{if(!t)return;const r=ct(t);if(r.length===0)return;_(a=>{const h={...a};for(const f of r)h[f]=!0;return h});let n=[{name:k,type:"folder"}],o="";for(const a of r){const h=n==null?void 0:n.find(p=>re(p,o)===a);if(!h||h.type!=="folder"){o=a,n=[];continue}n=await fe(a,h)??oe.current[a],o=a}},_e=(t,r)=>{if(!t||!r||t===r)return;const n=t==="/"?"/":`${t}/`,o=a=>a===t?r:a.startsWith(n)?r+a.slice(t.length):null;_(a=>{let h=!1;const f={...a};for(const p of Object.keys(a)){const O=o(p);O&&O!==p&&(f[O]=a[p],delete f[p],h=!0)}return h?f:a}),he(a=>{let h=!1;const f={...a};for(const p of Object.keys(a)){const O=o(p);O&&O!==p&&(f[O]=a[p],delete f[p],h=!0)}return h?f:a}),L(a=>a&&(o(a)??a)),$(a=>a&&(o(a)??a))},de=()=>{pe(null),Z(null),Y()},we=(t,r=!0)=>{L(t),r&&P(t)},W=i.useMemo(()=>[{name:k,type:"folder"}],[k]),[j,ne]=i.useState(null),[d,F]=i.useState(null),ae=i.useRef(null),be=d;i.useImperativeHandle(M,()=>({focusPath:(t,r={})=>{if(!t)return;const{select:n=!0,domFocus:o=!0,notify:a=!1}=r;n&&we(t,a),$(t),o&&V(t)},selectPath:t=>{t&&(we(t),$(t),V(t))},getSelectedPath:()=>x,expandToPath:async t=>await le(t),refresh:async t=>await q(t),remapPath:_e,createFile:async t=>{await Se(t,"file","untitled.php")},createFolder:async t=>{await Se(t,"folder","New Folder")}}),[x,q,_e,le]);const Pe=i.useRef(!1),me=i.useRef(g??null),$e=i.useRef(g);i.useEffect(()=>{ve.current=!1},[k]),i.useEffect(()=>{g&&g!==$e.current?me.current=g:g||(me.current=null),$e.current=g},[g]),i.useEffect(()=>{if(!g||Pe.current)return;Pe.current=!0;const t=ct(g);_(n=>{const o={...n};for(const a of t)o[a]=!0;return o});const r=t[t.length-1]||g;$(r),L(r),le(g)},[g,le]),i.useEffect(()=>{const t=me.current;!t||W.length===0||(me.current=null,le(t))},[W,le]),i.useEffect(()=>{if(!ee){if(W.length>0){const t=re(W[0]);$(t)}return}be&&be===ee||V(ee)},[W,ee,be]),i.useEffect(()=>{if(W.length===0)return;const t=W[0];if((t==null?void 0:t.type)!=="folder"||ve.current)return;const r=t.name;ve.current=!0,_(n=>n[r]?n:{...n,[r]:!0}),!oe.current[r]&&!H.current[r]&&fe(r,t)},[W,fe,k]),i.useEffect(()=>()=>{m.current&&clearTimeout(m.current),Y()},[]),i.useEffect(()=>{j&&setTimeout(()=>{const t=document.querySelector('[role="menu"] [role="menuitem"]');t&&typeof t.focus=="function"&&t.focus()},0)},[j]);const[Ye,Re]=i.useState(""),Qe=(t,r)=>{if(t.type==="folder")return r;const n=X.dirname(r);return n&&n||"/"},Ne=(t,r,n)=>{const o=Qe(t,r);if(!o)return{allowed:!1,state:"invalid",destination:null};if(n){if(o===n)return{allowed:!1,state:"invalid",destination:null};if(Ut(n,o))return{allowed:!1,state:"invalid",destination:null}}return{allowed:!0,state:"valid",destination:o}},Me=(t,r,n)=>{r.type!=="folder"&&r.type!=="file"||(pe(n),Z(null),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-wp-playground-path",n),t.dataTransfer.setData("text/plain",n)))},et=()=>{de()},tt=(t,r,n)=>{const o=Ne(r,n,ue);o.allowed&&r.type==="folder"&&G(n,r),Z(a=>(a==null?void 0:a.path)===n&&a.state===o.state?a:{path:n,state:o.state})},qe=(t,r,n)=>{const o=Ne(r,n,ue);o.allowed&&o.destination?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=ue?"move":"copy"),r.type==="folder"&&G(n,r),Z(a=>(a==null?void 0:a.path)===n&&a.state===o.state?a:{path:n,state:o.state})):(t.dataTransfer&&(t.dataTransfer.dropEffect="none"),K(n),Z(a=>(a==null?void 0:a.path)===n&&a.state==="invalid"?a:{path:n,state:"invalid"}))},ze=(t,r,n)=>{K(n);const o=t.relatedTarget;o&&t.currentTarget.contains(o)||Z(a=>(a==null?void 0:a.path)===n?null:a)},Ue=async(t,r,n)=>{const o=ue,a=Ne(r,n,o);if(!a.allowed||!a.destination){de();return}t.preventDefault(),t.stopPropagation(),K(n),Z(null);try{o?await it(o,a.destination):await Ge(t,a.destination)}finally{de()}},rt=(t,r,n)=>{t.preventDefault(),t.stopPropagation(),F(null),ne({absPath:n,type:r.type,x:t.clientX,y:t.clientY})},ke=async(t,r)=>{let n=r,o=0;const a=f=>{const p=f.lastIndexOf(".");return p>0?{stem:f.slice(0,p),ext:f.slice(p)}:{stem:f,ext:""}},h=t==="/"?"":t;for(;await(c==null?void 0:c.fileExists(`${h}/${n}`))||await(c==null?void 0:c.isDir(`${h}/${n}`));){o+=1;const{stem:f,ext:p}=a(r);n=`${f} (${o})${p}`}return n},Se=async(t,r,n)=>{if(!c)return;let o=t||x||k;try{await c.isDir(o)||(o=X.dirname(o))}catch{o=X.dirname(o)}const a=o,h=await ke(a,n),f=X.joinPaths(a,h);r==="folder"?await c.mkdir(f):await c.writeFile(f,""),ae.current={type:r,tempPath:f},F(f),await q(a),setTimeout(()=>{$(f),V(f)},0)},nt=async t=>{if(!c)return!1;try{if(await c.fileExists(t))return!0}catch{}try{if(await c.isDir(t))return!0}catch{}return!1},at=async t=>{if(c)try{await c.mkdir(t)}catch(r){if(!await c.isDir(t).catch(()=>!1))throw r}},it=async(t,r)=>{if(!c)return;const n=X.basename(t),o=X.joinPaths(r,n);if(o===t||await nt(o))return;const a=X.dirname(t);try{await c.mv(t,o),_e(t,o);const h=ut(x,t,o);x&&(x===t||x.startsWith(`${t}/`))&&P(h),$(f=>ut(f,t,o)),_(f=>({...f,[r]:!0})),await Promise.all([q(a),q(r)]),L(f=>ut(f,t,o)),V(o)}catch{}},ot=t=>{const r=t;return r.webkitGetAsEntry?r.webkitGetAsEntry():null},st=t=>new Promise((r,n)=>{t.file(r,n)}),Ze=async(t,r)=>{if(!c)return;const n=t.name||"untitled",o=await ke(r,n),a=X.joinPaths(r,o),h=new Uint8Array(await t.arrayBuffer());await c.writeFile(a,h)},Ke=async(t,r)=>{const n=await st(t);await Ze(n,r)},je=async(t,r)=>{const n=await ke(r,t.name||"New Folder"),o=X.joinPaths(r,n);await at(o);const a=t.createReader(),h=()=>new Promise((f,p)=>{a.readEntries(O=>f(Array.from(O)),p)});for(;;){const f=await h();if(!f.length)break;for(const p of f)p.isFile?await Ke(p,o):p.isDirectory&&await je(p,o)}},Ge=async(t,r)=>{var a,h;if(!c)return;const o=((a=t.dataTransfer)!=null&&a.items?Array.from(t.dataTransfer.items):[]).filter(f=>f.kind==="file").map(f=>ot(f)).filter(f=>!!f);if(o.length>0)for(const f of o)f.isFile?await Ke(f,r):f.isDirectory&&await je(f,r);else{const f=(h=t.dataTransfer)!=null&&h.files?Array.from(t.dataTransfer.files):[];for(const p of f)await Ze(p,r)}await q(r),_(f=>({...f,[r]:!0}))},Ce=async(t,r)=>{if(!c)return;const n=t;ne(null);try{r==="folder"?await c.rmdir(n,{recursive:!0}):await c.unlink(n)}catch{}finally{F(null);const o=X.dirname(n);await q(o),x&&(x===n||x.startsWith(`${n}/`))&&P(null)}},Ie=t=>{var r;if(!d)if(t.key.length===1&&t.key.match(/\S/)){const n=Ye+t.key.toLowerCase();if(Re(n),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{Re("")},1e3),!te.current)return;const o=Array.from(te.current.querySelectorAll(".file-node-button")),a=document.activeElement;let h=0;a&&o.includes(a)&&(h=o.indexOf(a));for(let f=0;f<o.length;f++){const p=(h+f)%o.length,O=o[p];if((r=O.textContent)!=null&&r.toLowerCase().trim().startsWith(n)){O.focus();const ge=O.getAttribute("data-path");ge&&$(ge);break}}}else Re(""),m.current&&clearTimeout(m.current)},Le=async(t,r)=>{const n=ae.current,o=(n==null?void 0:n.tempPath)===t,a=X.dirname(t),h=(r||"").trim();if(!S(h)){if(o){try{n.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}ae.current=null}F(o?null:t);return}let f=X.joinPaths(a,h),p=f;if(p===t){F(null);const De=o&&(n==null?void 0:n.type)==="file";o&&(ae.current=null),setTimeout(()=>{$(p),V(p),De&&R&&R(p)},0);return}const O=await c.fileExists(p),ge=await c.isDir(p);if((O||ge)&&p!==t)if(o)try{const De=await ke(a==="/"?"/":a,h);f=X.joinPaths(a,De),p=f}catch{}else{F(t);return}let Ve=(n==null?void 0:n.type)==="folder";try{await c.mv(t,f),n||(Ve=await c.isDir(f)),Ve&&_e(t,p),x===t&&P(p),await q(a),$(p),V(p),o&&!Ve&&R&&R(p)}catch{if(o)try{(n==null?void 0:n.type)==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}}finally{ae.current=null,F(null)}},Je=async t=>{const r=ae.current;if(!c||(r==null?void 0:r.tempPath)!==t){F(o=>o===t?null:o);return}try{r.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}ae.current=null,F(null);const n=X.dirname(t);await q(n),$(n),V(n)};return i.createElement("div",{onKeyDown:Ie,ref:te},i.createElement(ie.__experimentalTreeGrid,{className:Q.filePickerTree},W.map((t,r)=>i.createElement(bt,{key:t.name,node:t,level:0,position:r+1,setSize:W.length,expandedNodePaths:I,onToggle:se,selectedNode:x,focusPath:n=>$(n),focusedNode:ee,selectPath:we,generatePath:re,getChildren:xe,onContextMenu:rt,renamingPath:be,onRename:Le,onRenameCancel:Je,dropIndicator:ye,onDragStart:Me,onDragEnd:et,onDragEnter:tt,onDragOver:qe,onDragLeave:ze,onDrop:Ue,rootPath:k,onDoubleClickFile:R}))),j&&i.createElement(ie.Popover,{placement:"bottom-start",onClose:()=>ne(null),anchor:{getBoundingClientRect:()=>({x:j.x,y:j.y,width:0,height:0,top:j.y,left:j.x,right:j.x,bottom:j.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},i.createElement(ie.NavigableMenu,{role:"menu"},j.type==="folder"&&i.createElement(ie.MenuItem,{role:"menuitem",onClick:async()=>{ne(null),await Se(j.absPath,"file","untitled.php")}},"Create file"),j.type==="folder"&&i.createElement(ie.MenuItem,{role:"menuitem",onClick:async()=>{ne(null),await Se(j.absPath,"folder","New Folder")}},"Create directory"),i.createElement(ie.MenuItem,{role:"menuitem",onClick:()=>{ne(null),F(j.absPath)}},"Rename"),i.createElement(ie.MenuItem,{role:"menuitem",onClick:()=>Ce(j.absPath,j.type)},"Delete"))))}),bt=({node:l,level:c,position:E,setSize:g,expandedNodePaths:P,onToggle:R,selectedNode:M,focusPath:k,focusedNode:S,selectPath:I,generatePath:_,getChildren:x,onContextMenu:L,renamingPath:ee,onRename:$,onRenameCancel:U,parentPath:he="",dropIndicator:D,onDragStart:T,onDragEnd:ue,onDragEnter:pe,onDragOver:ye,onDragLeave:Z,onDrop:B,rootPath:ve,onDoubleClickFile:te})=>{const m=_(l,he),H=P[m],oe=ee===m,Y=i.useRef(null),[K,V]=i.useState(l.name),re=i.useRef(!1),xe=(D==null?void 0:D.path)===m,Te=xe&&(D==null?void 0:D.state)==="valid",Ee=xe&&(D==null?void 0:D.state)==="invalid",fe=!oe&&m!==ve,G=i.useRef(null),q={onDragEnter:d=>pe==null?void 0:pe(d,l,m),onDragOver:d=>ye==null?void 0:ye(d,l,m),onDragLeave:d=>Z==null?void 0:Z(d,l,m),onDrop:d=>B==null?void 0:B(d,l,m)},se=x(l,m)??[];i.useEffect(()=>{var d;oe?(V(l.name),re.current=!1,typeof window<"u"&&requestAnimationFrame?requestAnimationFrame(()=>{var F;(F=Y.current)==null||F.select()}):(d=Y.current)==null||d.select()):re.current=!1},[oe,l.name]);const le=()=>{l.type==="folder"&&R(m,l,!H)},_e=d=>{var F,ae;if(d.key==="ArrowLeft")H?le():(F=document.querySelector(`[data-path="${he}"]`))==null||F.focus(),d.preventDefault(),d.stopPropagation();else if(d.key==="ArrowRight"){if(H){if(se!=null&&se.length){const be=_(se[0],m);(ae=document.querySelector(`[data-path="${be}"]`))==null||ae.focus()}}else le();d.preventDefault(),d.stopPropagation()}else d.key===" "||d.key==="Space"||d.key==="Spacebar"?(l.type==="folder"&&R(m,l,!H),d.preventDefault()):d.key==="Enter"&&(l.type==="folder"?R(m,l,!H):(I(m,!1),k(m),te?te(m):I(m,!0)),d.preventDefault())},de=d=>{L==null||L(d,l,m)},we=d=>{d.preventDefault(),re.current=!0,$==null||$(m,K.trim())},W=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),re.current=!0,U==null||U(m);return}(d.key==="ArrowLeft"||d.key==="ArrowRight"||d.key==="ArrowUp"||d.key==="ArrowDown")&&d.stopPropagation()},j=()=>{re.current||U==null||U(m),re.current=!1},ne=()=>{if(l.type==="folder"){le(),I(m),k(m);return}const d=G.current!==null;if(d&&G.current&&clearTimeout(G.current),G.current=null,d){te?te(m):I(m,!0);return}I(m,!1),k(m),I(m,!0),G.current=window.setTimeout(()=>{G.current=null},300)};return i.useEffect(()=>()=>{G.current!==null&&typeof window<"u"&&clearTimeout(G.current)},[]),i.createElement(i.Fragment,null,i.createElement(ie.__experimentalTreeGridRow,{level:c,positionInSet:E,setSize:g},i.createElement(ie.__experimentalTreeGridCell,null,()=>i.createElement(i.Fragment,null,oe?i.createElement("form",{onSubmit:we,className:mt(Q.fileNodeButton,Q.renaming,"file-node-button",{[Q.selected]:M===m,[Q.focused]:S===m,[Q.dropTarget]:Te,[Q.dropTargetInvalid]:Ee}),"data-path":m,onContextMenu:de,...q},i.createElement(gt,{node:l,isOpen:l.type==="folder"&&H,level:c,hideName:!0}),i.createElement("input",{ref:Y,className:Q.renameInput,value:K,onChange:d=>V(d.target.value),onBlur:j,onFocus:()=>k(m),onKeyDown:W})):i.createElement(ie.Button,{...q,draggable:fe,onDragStart:d=>T==null?void 0:T(d,l,m),onDragEnd:d=>ue==null?void 0:ue(d,l,m),onClick:ne,onKeyDown:_e,onFocus:()=>{k(m)},onContextMenu:de,className:mt(Q.fileNodeButton,"file-node-button",{[Q.selected]:M===m,[Q.focused]:S===m,[Q.dropTarget]:Te,[Q.dropTargetInvalid]:Ee}),"data-path":m,"data-expanded":H?"true":"false"},i.createElement(gt,{node:l,isOpen:l.type==="folder"&&H,level:c}))))),H&&se&&se.map((d,F)=>i.createElement(bt,{key:d.name,node:d,level:c+1,position:F+1,setSize:se.length,expandedNodePaths:P,onToggle:R,selectedNode:M,focusPath:k,focusedNode:S,selectPath:I,generatePath:_,getChildren:x,onContextMenu:L,renamingPath:ee,onRename:$,onRenameCancel:U,parentPath:m,dropIndicator:D,onDragStart:T,onDragEnd:ue,onDragEnter:pe,onDragOver:ye,onDragLeave:Z,onDrop:B,rootPath:ve,onDoubleClickFile:te})))},gt=({node:l,level:c,isOpen:E,hideName:g=!1})=>{const P=[];for(let R=0;R<c;R++)P.push(" ");return i.createElement(i.Fragment,null,i.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:P.join("")}}),l.type==="folder"?i.createElement(ht,{width:16,icon:E?Nt:Mt}):i.createElement("div",{style:{width:16}}," "),i.createElement(ht,{width:16,icon:l.type==="folder"?yt:vt}),!g&&i.createElement("span",{className:Q.fileName},l.name))},Zt="_control_kp9d9_1",Kt="_browse-label_kp9d9_11",Gt="_path-preview_kp9d9_37",Jt="_modal_kp9d9_43",Xt="_modal-footer_kp9d9_48",Ae={control:Zt,browseLabel:Kt,pathPreview:Gt,modal:Jt,modalFooter:Xt};function Qt({path:l}){if(!l)return i.createElement("div",{className:Ae.pathPreview},i.createElement("i",null,"Select a path"));const c=l.split("/");let E=(c.length>2?"/":"")+c.pop();E.length>10&&(E=E.substring(E.length-10));const g=l.substring(0,l.length-E.length);return i.createElement("div",{className:Ae.pathPreview,"data-content-start":g,"data-content-end":E})}function er({value:l="",onChange:c,filesystem:E}){const[g,P]=i.useState(!1),R=()=>P(!0),M=()=>P(!1),[k,S]=i.useState(l||null);function I(_){_==null||_.preventDefault(),c(k||""),M()}return i.createElement(i.Fragment,null,i.createElement(ie.Button,{variant:"tertiary",className:Ae.control,onClick:R},i.createElement("span",{className:Ae.browseLabel},"Browse"),i.createElement(Qt,{path:l||""})),g&&i.createElement(ie.Modal,{title:"Select a path ",onRequestClose:M,className:Ae.modal},i.createElement("form",{onSubmit:I},i.createElement(_t,{filesystem:E,initialSelectedPath:l,onSelect:S}),i.createElement("div",{className:Ae.modalFooter},i.createElement(ie.Button,{type:"submit",variant:"primary"},"Select Path")))))}exports.ClockIcon=Ot;exports.FilePickerControl=er;exports.FilePickerTree=_t;exports.SiteManagerIcon=Ft;exports.WordPressIcon=St;exports.file=vt;exports.folder=yt;exports.getLogoDataURL=Dt;exports.layout=jt;exports.playgroundLogo=Pt;exports.temporaryStorage=kt;
|
|
31
31
|
//# sourceMappingURL=index.cjs.map
|