@devgateway/dvz-ui-react 1.6.19 → 1.6.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/commons.js +1 -1
- package/dist/cjs/embeddable/data/DataProvider.js +1 -1
- package/dist/cjs/embeddable/posts-filter/CategoricalFilter.js +1 -1
- package/dist/cjs/embeddable/reducers/data-api.js +1 -1
- package/dist/cjs/layout/PreviewComponent.js +1 -1
- package/dist/esm/api/commons.js +26 -17
- package/dist/esm/embeddable/data/DataProvider.js +52 -52
- package/dist/esm/embeddable/posts-filter/CategoricalFilter.js +18 -18
- package/dist/esm/embeddable/reducers/data-api.js +21 -16
- package/dist/esm/layout/PreviewComponent.js +23 -26
- package/dist/types/api/commons.d.ts +4 -1
- package/package.json +2 -2
package/dist/cjs/api/commons.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=(e,c,i=!1)=>new Promise((n,a)=>{fetch(e,{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST",body:JSON.stringify(c)}).then(function(t){t.status!==200&&a(t),i&&n(t.blob()),t.json().then(function(o){n(o)}).catch(()=>n(t.status))}).catch(function(t){a(t)})}),p=async(e,c={},i=!1)=>{try{const{headers:n,...a}=c,t=await fetch(e,{headers:{Accept:"application/json","Content-Type":"application/json",...n},...a});if(!t.ok)throw t;const o=await t.json();if(i){const s={};return t.headers.forEach((r,h)=>{s[h]=r}),{data:o,meta:s}}return o}catch(n){throw n}};exports.get=p;exports.post=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),x=require("react"),D=require("react-redux"),j=require("react-intl"),k=require("./DataContext.js"),m=require("../reducers/data.js"),g=require("semantic-ui-react");class C extends x.Component{constructor(){super(),this.state={showLoading:!1},this.checkLoadingTime=this.checkLoadingTime.bind(this)}componentDidMount(){const{app:e,source:i,store:a,params:t,csv:l,group:c,editing:s,waitForFilters:o=!1}=this.props;e==="csv"?this.props.onSetData({app:e,csv:l,store:a,params:t,group:c}):(this.setState({showLoading:!1}),!o||s?(console.log("loading -----"),this.props.onLoadData({app:e,source:i,store:a,params:t,group:c}),setTimeout(this.checkLoadingTime,100)):console.log("waiting for filters to be set before loading data",e,i,a,t,c)),!s&&o&&(this.fallbackTimeout=setTimeout(()=>{this.dataLoaded||(console.warn("Fallback loading triggered"),this.setState({showLoading:!1}),this.props.onLoadData({app:e,source:i,store:a,params:t,group:c}),setTimeout(this.checkLoadingTime,100))},1e3))}componentWillUnmount(){clearTimeout(this.fallbackTimeout),clearTimeout(this.debounceTimeout)}componentDidUpdate(e,i,a){const{app:t,filters:l,apply:c,source:s,store:o,params:r,csv:u,group:h,autoApply:L,editing:p,lastInitialFilterChange:T,lastUserFilterChange:S}=this.props,b=T!==e.lastInitialFilterChange,y=S!==e.lastUserFilterChange;let f=!1;c!=null&&c!=e.apply&&(f=!0),L!==!1?(l!=e.filters||JSON.stringify(r)!=JSON.stringify(e.params)||t!=e.app||JSON.stringify(e.source)!=JSON.stringify(s)||u!=e.csv)&&(t==="csv"?this.props.onSetData({app:t,csv:u,store:o,params:r,group:h}):(this.setState({showLoading:!0}),p&&this.props.onLoadData({app:t,source:s,store:o,params:r,group:h}),b&&this.props.waitForFilters?(console.log("initial filters has been updated",l,r),clearTimeout(this.debounceTimeout),clearTimeout(this.fallbackTimeout),this.debounceTimeout=setTimeout(()=>{this.dataLoaded=!0,this.setState({showLoading:!1}),console.log("Loading data "+t+" "+s),this.props.onLoadData({app:t,source:s,store:o,params:r,group:h}),setTimeout(this.checkLoadingTime,100)},100)):y?(console.log("filters has been updated",l,e.filters,r,e.params,t,s,o,h),this.setState({showLoading:!1}),console.log("filters has been updated",l),this.props.onLoadData({app:t,source:s,store:o,params:r,group:h}),setTimeout(this.checkLoadingTime,100)):!p&&(JSON.stringify(r)!==JSON.stringify(e.params)||t!==e.app||JSON.stringify(s)!==JSON.stringify(e.source))?(this.setState({showLoading:!1}),this.props.onLoadData({app:t,source:s,store:o,params:r,group:h}),setTimeout(this.checkLoadingTime,100)):console.log("no changes detected ............"))):f&&(console.log("reloading -----"),this.props.onLoadData({app:t,source:s,store:o,params:r,group:h}),this.setState({showLoading:!1}),setTimeout(this.checkLoadingTime,100))}checkLoadingTime(){const{data:e,loading:i,time:a,error:t}=this.props,l=Date.now()-a;i&&a&&l>1e3?this.setState({showLoading:!0}):i&&setTimeout(this.checkLoadingTime,100)}render(){const{data:e,style:i,loading:a,time:t,error:l,editing:c,isSvg:s}=this.props;if(a&&this.state.showLoading&&!c){const o={width:"100%",height:"100%",background:"transparent",verticalAlign:"middle",overflow:"hidden"},r=Object.assign({},i,{height:"90%",background:"transparent",textAlign:"center",margin:"30px"}),u=n.jsx(g.Segment,{basic:!0,padded:!0,style:r,children:n.jsx(g.Dimmer,{active:!0,inverted:!0,style:{background:"transparent"},children:n.jsx(g.Loader,{size:"medium",style:{background:"transparent"}})})});return s?n.jsx("foreignObject",{style:o,children:n.jsx(g.Container,{style:i,className:"loading",children:u})}):n.jsx(g.Container,{style:i,className:"loading",children:u})}else return l?l?n.jsxs(g.Segment,{color:"red",children:[n.jsx("h1",{children:"500"}),n.jsx("p",{children:"Wasn't able to load data"})]}):n.jsx(g.Container,{children:n.jsxs(g.Segment,{color:"red",children:[n.jsx("h1",{children:"404"}),n.jsx("p",{children:"Can't find this page"})]})}):n.jsx(k.DataContext.Provider,{value:e,children:this.props.children})}}const w=(d,e)=>{const{store:i,group:a,app:t}=e;return{lastUserFilterChange:d.getIn(["data","filters-settings",t,a,"lastUserFilterChange"]),lastInitialFilterChange:d.getIn(["data","filters-settings",t,a,"lastInitialFilterChange"]),data:d.getIn(["data",...i,"data"]),filters:d.getIn(["data","filters",t,a]),autoApply:d.getIn(["data","filters-settings",t,a,"autoApply"]),apply:d.getIn(["data","filters-settings",t,a,"apply"]),error:d.getIn(["data",...i,"error"]),loading:d.getIn(["data",...i,"loading"]),time:d.getIn(["data",...i,"time"])}},I={onSetData:m.setData,onLoadData:m.getData},F=D.connect(w,I)(j.injectIntl(C));exports.default=F;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("react/jsx-runtime"),i=require("react"),q=require("./PostsFilterDropdown.js"),A=require("../../conf/index.js"),R=l=>{const{taxonomy:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("react/jsx-runtime"),i=require("react"),q=require("./PostsFilterDropdown.js"),A=require("../../conf/index.js"),R=l=>{const{taxonomy:t,group:u,placeholder:c,allLabel:p,noneLabel:f,useSingleColumn:d,enableTextSearch:g,filterType:y,showNoDataOption:S,closeOnSelect:m,allNoneSameBehaviour:x,autoApply:O,alphabeticalSort:P,ascOrder:h,type:T,categories:s,onChange:b,...v}=l,[w,o]=i.useState([]),C=async()=>{if(!t||t==="none"){o([]);return}const a=await(await fetch(A.Config.REACT_APP_WP_API+"/wp/v2/"+t)).json();if(a){const r=a.map(e=>({key:e.id,value:e.id,text:e.name}));if(s){const e=r.filter(_=>s.indexOf(_.value.toString())>-1);o(e)}else o(r)}};return i.useEffect(()=>{let n=!1;return n||C(),()=>{n=!0}},[T,t]),j.jsx(q.default,{...v,group:u,placeholder:c,allLabel:p,noneLabel:f,useSingleColumn:d,enableTextSearch:g,filterType:y,showNoDataOption:S,closeOnSelect:m,allNoneSameBehaviour:x,autoApply:O,alphabeticalSort:P,ascOrder:h,options:w,onChange:b})};exports.default=R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../../conf/index.js"),y=require("../../api/commons.js");function l(n){return JSON.parse(JSON.stringify(n))}const g=process.env.VITE_REACT_APP_API_ROOT||C.Config.REACT_APP_API_ROOT||null,A=typeof window<"u"?window.location.origin:"",f={},p={},I=3*60*1e3;function O(n){return Object.keys(n).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(n[t])).join("&")}function T(n,t=!1){const e=n,i=Date.now();if(p[e]&&i-p[e].timestamp<I)return Promise.resolve(l(p[e].data));if(f[e])return f[e].then(l);const u=y.get(n,{},t).then(a=>(p[e]={data:a,timestamp:Date.now()},t?{data:l(a),meta:p[e].meta}:l(a))).finally(()=>{delete f[e]});return f[e]=u,u}const E=({app:n,params:t})=>{const e=`${g||A}/api/${n}/categories${t?"?"+O(t):""}`;return T(e)},U=({source:n,app:t,params:e})=>{const i=`${g||A}/api/${t}/stats/${n}${e?"?"+O(e):""}`;return T(i)},b=({postType:n,taxonomy:t,category:e,taxonomyFilters:i,before:u,perPage:a,page:h,locale:_,after:P,ordering:R,orderingDirection:$})=>{const q=`${C.Config.REACT_APP_WP_API}/wp/v2/${n}`,r=new URLSearchParams,d=new Map,S=(s,o)=>{if(!s||o==null)return;const c=d.get(s)||[];Array.isArray(o)?o.forEach(m=>{m!=null&&c.push(String(m))}):c.push(String(o)),d.set(s,c)};i&&i instanceof Map&&i.forEach((s,o)=>{S(o,s)}),t&&e!=null&&S(t,e),d.forEach((s,o)=>{const c=Array.from(new Set(s));c.length!==0&&r.set(o,c.join(","))}),u&&r.append("before",u.toISOString()),a&&r.append("per_page",a.toString()),r.append("page",h.toString()),r.append("locale",_),P&&r.append("after",P.toISOString()),r.append("orderby",R),r.append("order",$);const w=r.toString().replace(/%2C/g,",");return y.get(`${q}?${w}`,{headers:{"Content-Type":"application/json"},credentials:"include"},!0)};exports.getCategories=E;exports.getCustomPosts=b;exports.getData=U;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),r=require("react"),u=require("react-router"),m=require("semantic-ui-react"),w=require("@devgateway/wp-react-lib"),f=require("../embeddable/index.js"),P=()=>{const d=u.useParams(),[p]=u.useSearchParams(),[o]=r.useState(()=>f.getComponentByNameIgnoreCase(d.name??"")),[n,l]=r.useState(()=>Object.fromEntries(p.entries())),i=r.useRef(n);i.current=n;const a=r.useCallback(g=>{const t=g.data;if(t.messageType&&t.messageType==="component-attributes"){const c={...i.current};Object.keys(t).forEach(s=>{c["data-"+s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()]=typeof t[s]=="object"?JSON.stringify(t[s]):t[s]}),l(c)}},[]);return r.useEffect(()=>(window.addEventListener("message",a,!1),window.parent&&window.parent.postMessage({type:"componentReady",value:!0},"*"),window.top&&window.top.postMessage({type:"componentReady",value:!0},"*"),()=>{window.removeEventListener("message",a)}),[a]),e.jsx("div",{children:e.jsx(m.Container,{fluid:!0,className:"editing",children:o?e.jsx(o,{...n,editing:!0}):e.jsx(m.Segment.Group,{color:"red",textAlign:"center",children:e.jsx("h1",{children:"Wrong Component Name"})})})})},j=()=>e.jsx(w.SettingsConsumer,{children:e.jsx(P,{})});exports.default=j;
|
package/dist/esm/api/commons.js
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
const
|
|
2
|
-
fetch(
|
|
1
|
+
const f = (c, e, i = !1) => new Promise((n, a) => {
|
|
2
|
+
fetch(c, {
|
|
3
3
|
headers: {
|
|
4
4
|
Accept: "application/json",
|
|
5
5
|
"Content-Type": "application/json"
|
|
6
6
|
},
|
|
7
7
|
method: "POST",
|
|
8
|
-
body: JSON.stringify(
|
|
8
|
+
body: JSON.stringify(e)
|
|
9
9
|
}).then(
|
|
10
|
-
function(
|
|
11
|
-
|
|
12
|
-
o
|
|
13
|
-
}).catch(() =>
|
|
10
|
+
function(t) {
|
|
11
|
+
t.status !== 200 && a(t), i && n(t.blob()), t.json().then(function(o) {
|
|
12
|
+
n(o);
|
|
13
|
+
}).catch(() => n(t.status));
|
|
14
14
|
}
|
|
15
|
-
).catch(function(
|
|
16
|
-
|
|
15
|
+
).catch(function(t) {
|
|
16
|
+
a(t);
|
|
17
17
|
});
|
|
18
|
-
}), p = async (
|
|
18
|
+
}), p = async (c, e = {}, i = !1) => {
|
|
19
19
|
try {
|
|
20
|
-
const t = await fetch(
|
|
20
|
+
const { headers: n, ...a } = e, t = await fetch(c, {
|
|
21
21
|
headers: {
|
|
22
22
|
Accept: "application/json",
|
|
23
|
-
"Content-Type": "application/json"
|
|
24
|
-
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
...n
|
|
25
|
+
},
|
|
26
|
+
...a
|
|
25
27
|
});
|
|
26
28
|
if (!t.ok)
|
|
27
29
|
throw t;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const o = await t.json();
|
|
31
|
+
if (i) {
|
|
32
|
+
const s = {};
|
|
33
|
+
return t.headers.forEach((r, h) => {
|
|
34
|
+
s[h] = r;
|
|
35
|
+
}), { data: o, meta: s };
|
|
36
|
+
}
|
|
37
|
+
return o;
|
|
38
|
+
} catch (n) {
|
|
39
|
+
throw n;
|
|
31
40
|
}
|
|
32
41
|
};
|
|
33
42
|
export {
|
|
34
43
|
p as get,
|
|
35
|
-
|
|
44
|
+
f as post
|
|
36
45
|
};
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r, jsxs as L } from "react/jsx-runtime";
|
|
2
2
|
import k from "react";
|
|
3
3
|
import { connect as w } from "react-redux";
|
|
4
4
|
import { injectIntl as C } from "react-intl";
|
|
5
5
|
import { DataContext as I } from "./DataContext.js";
|
|
6
|
-
import { getData as F, setData as
|
|
7
|
-
import { Container as p, Segment as m, Dimmer as
|
|
8
|
-
class
|
|
6
|
+
import { getData as F, setData as O } from "../reducers/data.js";
|
|
7
|
+
import { Container as p, Segment as m, Dimmer as N, Loader as J } from "semantic-ui-react";
|
|
8
|
+
class x extends k.Component {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(), this.state = {
|
|
11
11
|
showLoading: !1
|
|
12
12
|
}, this.checkLoadingTime = this.checkLoadingTime.bind(this);
|
|
13
13
|
}
|
|
14
14
|
componentDidMount() {
|
|
15
|
-
const { app:
|
|
16
|
-
|
|
17
|
-
this.dataLoaded || (console.warn("Fallback loading triggered"), this.setState({ showLoading: !1 }), this.props.onLoadData({ app:
|
|
15
|
+
const { app: t, source: i, store: a, params: e, csv: l, group: c, editing: s, waitForFilters: o = !1 } = this.props;
|
|
16
|
+
t === "csv" ? this.props.onSetData({ app: t, csv: l, store: a, params: e, group: c }) : (this.setState({ showLoading: !1 }), !o || s ? (console.log("loading -----"), this.props.onLoadData({ app: t, source: i, store: a, params: e, group: c }), setTimeout(this.checkLoadingTime, 100)) : console.log("waiting for filters to be set before loading data", t, i, a, e, c)), !s && o && (this.fallbackTimeout = setTimeout(() => {
|
|
17
|
+
this.dataLoaded || (console.warn("Fallback loading triggered"), this.setState({ showLoading: !1 }), this.props.onLoadData({ app: t, source: i, store: a, params: e, group: c }), setTimeout(this.checkLoadingTime, 100));
|
|
18
18
|
}, 1e3));
|
|
19
19
|
}
|
|
20
20
|
componentWillUnmount() {
|
|
21
21
|
clearTimeout(this.fallbackTimeout), clearTimeout(this.debounceTimeout);
|
|
22
22
|
}
|
|
23
|
-
componentDidUpdate(
|
|
23
|
+
componentDidUpdate(t, i, a) {
|
|
24
24
|
const {
|
|
25
|
-
app:
|
|
26
|
-
filters:
|
|
27
|
-
apply:
|
|
28
|
-
source:
|
|
29
|
-
store:
|
|
30
|
-
params:
|
|
25
|
+
app: e,
|
|
26
|
+
filters: l,
|
|
27
|
+
apply: c,
|
|
28
|
+
source: s,
|
|
29
|
+
store: o,
|
|
30
|
+
params: n,
|
|
31
31
|
csv: g,
|
|
32
32
|
group: h,
|
|
33
|
-
autoApply:
|
|
34
|
-
editing:
|
|
35
|
-
lastInitialFilterChange:
|
|
36
|
-
lastUserFilterChange:
|
|
37
|
-
} = this.props,
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
this.dataLoaded = !0, this.setState({ showLoading: !1 }), console.log("Loading data " +
|
|
41
|
-
}, 100)) : D ? (console.log("filters has been updated",
|
|
33
|
+
autoApply: T,
|
|
34
|
+
editing: f,
|
|
35
|
+
lastInitialFilterChange: S,
|
|
36
|
+
lastUserFilterChange: y
|
|
37
|
+
} = this.props, b = S !== t.lastInitialFilterChange, D = y !== t.lastUserFilterChange;
|
|
38
|
+
let u = !1;
|
|
39
|
+
c != null && c != t.apply && (u = !0), T !== !1 ? (l != t.filters || JSON.stringify(n) != JSON.stringify(t.params) || e != t.app || JSON.stringify(t.source) != JSON.stringify(s) || g != t.csv) && (e === "csv" ? this.props.onSetData({ app: e, csv: g, store: o, params: n, group: h }) : (this.setState({ showLoading: !0 }), f && this.props.onLoadData({ app: e, source: s, store: o, params: n, group: h }), b && this.props.waitForFilters ? (console.log("initial filters has been updated", l, n), clearTimeout(this.debounceTimeout), clearTimeout(this.fallbackTimeout), this.debounceTimeout = setTimeout(() => {
|
|
40
|
+
this.dataLoaded = !0, this.setState({ showLoading: !1 }), console.log("Loading data " + e + " " + s), this.props.onLoadData({ app: e, source: s, store: o, params: n, group: h }), setTimeout(this.checkLoadingTime, 100);
|
|
41
|
+
}, 100)) : D ? (console.log("filters has been updated", l, t.filters, n, t.params, e, s, o, h), this.setState({ showLoading: !1 }), console.log("filters has been updated", l), this.props.onLoadData({ app: e, source: s, store: o, params: n, group: h }), setTimeout(this.checkLoadingTime, 100)) : !f && (JSON.stringify(n) !== JSON.stringify(t.params) || e !== t.app || JSON.stringify(s) !== JSON.stringify(t.source)) ? (this.setState({ showLoading: !1 }), this.props.onLoadData({ app: e, source: s, store: o, params: n, group: h }), setTimeout(this.checkLoadingTime, 100)) : console.log("no changes detected ............"))) : u && (console.log("reloading -----"), this.props.onLoadData({ app: e, source: s, store: o, params: n, group: h }), this.setState({ showLoading: !1 }), setTimeout(this.checkLoadingTime, 100));
|
|
42
42
|
}
|
|
43
43
|
checkLoadingTime() {
|
|
44
|
-
const { data:
|
|
45
|
-
i && a &&
|
|
44
|
+
const { data: t, loading: i, time: a, error: e } = this.props, l = Date.now() - a;
|
|
45
|
+
i && a && l > 1e3 ? this.setState({ showLoading: !0 }) : i && setTimeout(this.checkLoadingTime, 100);
|
|
46
46
|
}
|
|
47
47
|
render() {
|
|
48
|
-
const { data:
|
|
49
|
-
if (a && this.state.showLoading && !
|
|
50
|
-
const
|
|
48
|
+
const { data: t, style: i, loading: a, time: e, error: l, editing: c, isSvg: s } = this.props;
|
|
49
|
+
if (a && this.state.showLoading && !c) {
|
|
50
|
+
const o = {
|
|
51
51
|
width: "100%",
|
|
52
52
|
height: "100%",
|
|
53
53
|
background: "transparent",
|
|
54
54
|
verticalAlign: "middle",
|
|
55
55
|
overflow: "hidden"
|
|
56
|
-
},
|
|
56
|
+
}, n = Object.assign({}, i, {
|
|
57
57
|
height: "90%",
|
|
58
58
|
background: "transparent",
|
|
59
59
|
textAlign: "center",
|
|
60
60
|
margin: "30px"
|
|
61
|
-
}), g = /* @__PURE__ */
|
|
62
|
-
return
|
|
63
|
-
} else return
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */
|
|
66
|
-
] }) : /* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
] }) }) : /* @__PURE__ */
|
|
61
|
+
}), g = /* @__PURE__ */ r(m, { basic: !0, padded: !0, style: n, children: /* @__PURE__ */ r(N, { active: !0, inverted: !0, style: { background: "transparent" }, children: /* @__PURE__ */ r(J, { size: "medium", style: { background: "transparent" } }) }) });
|
|
62
|
+
return s ? /* @__PURE__ */ r("foreignObject", { style: o, children: /* @__PURE__ */ r(p, { style: i, className: "loading", children: g }) }) : /* @__PURE__ */ r(p, { style: i, className: "loading", children: g });
|
|
63
|
+
} else return l ? l ? /* @__PURE__ */ L(m, { color: "red", children: [
|
|
64
|
+
/* @__PURE__ */ r("h1", { children: "500" }),
|
|
65
|
+
/* @__PURE__ */ r("p", { children: "Wasn't able to load data" })
|
|
66
|
+
] }) : /* @__PURE__ */ r(p, { children: /* @__PURE__ */ L(m, { color: "red", children: [
|
|
67
|
+
/* @__PURE__ */ r("h1", { children: "404" }),
|
|
68
|
+
/* @__PURE__ */ r("p", { children: "Can't find this page" })
|
|
69
|
+
] }) }) : /* @__PURE__ */ r(I.Provider, { value: t, children: this.props.children });
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
const { store: i, group: a, app:
|
|
72
|
+
const A = (d, t) => {
|
|
73
|
+
const { store: i, group: a, app: e } = t;
|
|
74
74
|
return {
|
|
75
|
-
lastUserFilterChange:
|
|
76
|
-
lastInitialFilterChange:
|
|
77
|
-
data:
|
|
78
|
-
filters:
|
|
79
|
-
autoApply:
|
|
80
|
-
apply:
|
|
81
|
-
error:
|
|
82
|
-
loading:
|
|
83
|
-
time:
|
|
75
|
+
lastUserFilterChange: d.getIn(["data", "filters-settings", e, a, "lastUserFilterChange"]),
|
|
76
|
+
lastInitialFilterChange: d.getIn(["data", "filters-settings", e, a, "lastInitialFilterChange"]),
|
|
77
|
+
data: d.getIn(["data", ...i, "data"]),
|
|
78
|
+
filters: d.getIn(["data", "filters", e, a]),
|
|
79
|
+
autoApply: d.getIn(["data", "filters-settings", e, a, "autoApply"]),
|
|
80
|
+
apply: d.getIn(["data", "filters-settings", e, a, "apply"]),
|
|
81
|
+
error: d.getIn(["data", ...i, "error"]),
|
|
82
|
+
loading: d.getIn(["data", ...i, "loading"]),
|
|
83
|
+
time: d.getIn(["data", ...i, "time"])
|
|
84
84
|
};
|
|
85
|
-
},
|
|
86
|
-
onSetData:
|
|
85
|
+
}, j = {
|
|
86
|
+
onSetData: O,
|
|
87
87
|
onLoadData: F
|
|
88
|
-
}, q = w(
|
|
88
|
+
}, q = w(A, j)(C(x));
|
|
89
89
|
export {
|
|
90
90
|
q as default
|
|
91
91
|
};
|
|
@@ -4,7 +4,7 @@ import B from "./PostsFilterDropdown.js";
|
|
|
4
4
|
import { Config as D } from "../../conf/index.js";
|
|
5
5
|
const k = (i) => {
|
|
6
6
|
const {
|
|
7
|
-
taxonomy:
|
|
7
|
+
taxonomy: o,
|
|
8
8
|
group: l,
|
|
9
9
|
placeholder: p,
|
|
10
10
|
allLabel: c,
|
|
@@ -19,34 +19,34 @@ const k = (i) => {
|
|
|
19
19
|
alphabeticalSort: S,
|
|
20
20
|
ascOrder: h,
|
|
21
21
|
type: P,
|
|
22
|
-
categories:
|
|
22
|
+
categories: a,
|
|
23
23
|
onChange: T,
|
|
24
24
|
...w
|
|
25
|
-
} = i, [C,
|
|
26
|
-
if (!
|
|
27
|
-
|
|
25
|
+
} = i, [C, t] = _([]), b = async () => {
|
|
26
|
+
if (!o || o === "none") {
|
|
27
|
+
t([]);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const r = await (await fetch(D.REACT_APP_WP_API + "/wp/v2/" +
|
|
30
|
+
const r = await (await fetch(D.REACT_APP_WP_API + "/wp/v2/" + o)).json();
|
|
31
31
|
if (r) {
|
|
32
|
-
const s = r.map((
|
|
33
|
-
key:
|
|
34
|
-
value:
|
|
35
|
-
text:
|
|
32
|
+
const s = r.map((e) => ({
|
|
33
|
+
key: e.id,
|
|
34
|
+
value: e.id,
|
|
35
|
+
text: e.name
|
|
36
36
|
}));
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
37
|
+
if (a) {
|
|
38
|
+
const e = s.filter((v) => a.indexOf(v.value.toString()) > -1);
|
|
39
|
+
t(e);
|
|
40
40
|
} else
|
|
41
|
-
|
|
41
|
+
t(s);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
return j(() => {
|
|
45
|
-
let
|
|
46
|
-
return
|
|
47
|
-
|
|
45
|
+
let n = !1;
|
|
46
|
+
return n || b(), () => {
|
|
47
|
+
n = !0;
|
|
48
48
|
};
|
|
49
|
-
}, [P,
|
|
49
|
+
}, [P, o]), /* @__PURE__ */ A(
|
|
50
50
|
B,
|
|
51
51
|
{
|
|
52
52
|
...w,
|
|
@@ -4,28 +4,28 @@ function f(n) {
|
|
|
4
4
|
return JSON.parse(JSON.stringify(n));
|
|
5
5
|
}
|
|
6
6
|
const d = process.env.VITE_REACT_APP_API_ROOT || A.REACT_APP_API_ROOT || null, O = typeof window < "u" ? window.location.origin : "", l = {}, u = {}, q = 3 * 60 * 1e3;
|
|
7
|
-
function
|
|
7
|
+
function T(n) {
|
|
8
8
|
return Object.keys(n).map((t) => encodeURIComponent(t) + "=" + encodeURIComponent(n[t])).join("&");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function _(n, t = !1) {
|
|
11
11
|
const e = n, i = Date.now();
|
|
12
12
|
if (u[e] && i - u[e].timestamp < q)
|
|
13
13
|
return Promise.resolve(f(u[e].data));
|
|
14
14
|
if (l[e])
|
|
15
15
|
return l[e].then(f);
|
|
16
|
-
const p = h(n, {}).then((a) => (u[e] = { data: a, timestamp: Date.now() }, t ? { data: f(a), meta: u[e].meta } : f(a))).finally(() => {
|
|
16
|
+
const p = h(n, {}, t).then((a) => (u[e] = { data: a, timestamp: Date.now() }, t ? { data: f(a), meta: u[e].meta } : f(a))).finally(() => {
|
|
17
17
|
delete l[e];
|
|
18
18
|
});
|
|
19
19
|
return l[e] = p, p;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const e = `${d || O}/api/${n}/categories${t ? "?" +
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
const i = `${d || O}/api/${t}/stats/${n}${e ? "?" +
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
const
|
|
21
|
+
const j = ({ app: n, params: t }) => {
|
|
22
|
+
const e = `${d || O}/api/${n}/categories${t ? "?" + T(t) : ""}`;
|
|
23
|
+
return _(e);
|
|
24
|
+
}, D = ({ source: n, app: t, params: e }) => {
|
|
25
|
+
const i = `${d || O}/api/${t}/stats/${n}${e ? "?" + T(e) : ""}`;
|
|
26
|
+
return _(i);
|
|
27
|
+
}, b = ({ postType: n, taxonomy: t, category: e, taxonomyFilters: i, before: p, perPage: a, page: y, locale: C, after: m, ordering: R, orderingDirection: $ }) => {
|
|
28
|
+
const w = `${A.REACT_APP_WP_API}/wp/v2/${n}`, r = new URLSearchParams(), g = /* @__PURE__ */ new Map(), P = (s, o) => {
|
|
29
29
|
if (!s || o == null) return;
|
|
30
30
|
const c = g.get(s) || [];
|
|
31
31
|
Array.isArray(o) ? o.forEach((S) => {
|
|
@@ -37,12 +37,17 @@ const D = ({ app: n, params: t }) => {
|
|
|
37
37
|
}), t && e != null && P(t, e), g.forEach((s, o) => {
|
|
38
38
|
const c = Array.from(new Set(s));
|
|
39
39
|
c.length !== 0 && r.set(o, c.join(","));
|
|
40
|
-
}), p && r.append("before", p.toISOString()), a && r.append("per_page", a.toString()), r.append("page",
|
|
40
|
+
}), p && r.append("before", p.toISOString()), a && r.append("per_page", a.toString()), r.append("page", y.toString()), r.append("locale", C), m && r.append("after", m.toISOString()), r.append("orderby", R), r.append("order", $);
|
|
41
41
|
const I = r.toString().replace(/%2C/g, ",");
|
|
42
|
-
return h(`${
|
|
42
|
+
return h(`${w}?${I}`, {
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "application/json"
|
|
45
|
+
},
|
|
46
|
+
credentials: "include"
|
|
47
|
+
}, !0);
|
|
43
48
|
};
|
|
44
49
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
j as getCategories,
|
|
51
|
+
b as getCustomPosts,
|
|
52
|
+
D as getData
|
|
48
53
|
};
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useParams as
|
|
4
|
-
import { Container as y, Segment as
|
|
5
|
-
import { SettingsConsumer as
|
|
6
|
-
import { getComponentByNameIgnoreCase as
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}), i(s);
|
|
2
|
+
import { useState as i, useRef as f, useCallback as g, useEffect as l } from "react";
|
|
3
|
+
import { useParams as w, useSearchParams as P } from "react-router";
|
|
4
|
+
import { Container as y, Segment as C } from "semantic-ui-react";
|
|
5
|
+
import { SettingsConsumer as h } from "@devgateway/wp-react-lib";
|
|
6
|
+
import { getComponentByNameIgnoreCase as v } from "../embeddable/index.js";
|
|
7
|
+
const b = () => {
|
|
8
|
+
const p = w(), [c] = P(), [a] = i(() => v(p.name ?? "")), [o, d] = i(
|
|
9
|
+
() => Object.fromEntries(c.entries())
|
|
10
|
+
), s = f(o);
|
|
11
|
+
s.current = o;
|
|
12
|
+
const n = g((u) => {
|
|
13
|
+
const t = u.data;
|
|
14
|
+
if (t.messageType && t.messageType === "component-attributes") {
|
|
15
|
+
const m = { ...s.current };
|
|
16
|
+
Object.keys(t).forEach((r) => {
|
|
17
|
+
m["data-" + r.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()] = typeof t[r] == "object" ? JSON.stringify(t[r]) : t[r];
|
|
18
|
+
}), d(m);
|
|
20
19
|
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
window.removeEventListener("message",
|
|
24
|
-
}), []);
|
|
25
|
-
|
|
26
|
-
return /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(y, { fluid: !0, className: "editing", children: n ? /* @__PURE__ */ e(n, { ...p, editing: !0 }) : /* @__PURE__ */ e(P.Group, { color: "red", textAlign: "center", children: /* @__PURE__ */ e("h1", { children: "Wrong Component Name" }) }) }) });
|
|
27
|
-
}, N = () => /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(v, {}) });
|
|
20
|
+
}, []);
|
|
21
|
+
return l(() => (window.addEventListener("message", n, !1), window.parent && window.parent.postMessage({ type: "componentReady", value: !0 }, "*"), window.top && window.top.postMessage({ type: "componentReady", value: !0 }, "*"), () => {
|
|
22
|
+
window.removeEventListener("message", n);
|
|
23
|
+
}), [n]), /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(y, { fluid: !0, className: "editing", children: a ? /* @__PURE__ */ e(a, { ...o, editing: !0 }) : /* @__PURE__ */ e(C.Group, { color: "red", textAlign: "center", children: /* @__PURE__ */ e("h1", { children: "Wrong Component Name" }) }) }) });
|
|
24
|
+
}, L = () => /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(b, {}) });
|
|
28
25
|
export {
|
|
29
|
-
|
|
26
|
+
L as default
|
|
30
27
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const post: (url: string, params: Record<string, unknown>, isBlob?: boolean) => Promise<unknown>;
|
|
2
|
-
export declare const get: <T extends any>(url: string,
|
|
2
|
+
export declare const get: <T extends any>(url: string, fetchOptions?: RequestInit, withHeaders?: boolean) => Promise<T | {
|
|
3
|
+
data: T;
|
|
4
|
+
meta: Record<string, string>;
|
|
5
|
+
}>;
|
|
3
6
|
export declare const queryParams: (params: any) => string;
|
|
4
7
|
export declare const getAnaliticUserCode: () => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devgateway/dvz-ui-react",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.20",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"vite-plugin-env-compatible": "^2.0.1",
|
|
123
123
|
"vite-plugin-eslint": "^1.8.1",
|
|
124
124
|
"vite-tsconfig-paths": "^5.1.4",
|
|
125
|
-
"@devgateway/wp-react-lib": "0.
|
|
125
|
+
"@devgateway/wp-react-lib": "0.6.1"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
128
|
"react": "^18.3.1",
|