tinacms 2.7.5 → 2.7.6
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/index.js +2095 -2095
- package/dist/index.mjs +2095 -2095
- package/dist/toolkit/tina-cms.d.ts +3 -3
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -8724,6 +8724,73 @@ class GlobalFormPlugin {
|
|
|
8724
8724
|
};
|
|
8725
8725
|
}
|
|
8726
8726
|
}
|
|
8727
|
+
let Alerts$1 = class Alerts {
|
|
8728
|
+
constructor(events, map = {}) {
|
|
8729
|
+
this.events = events;
|
|
8730
|
+
this.map = map;
|
|
8731
|
+
this.alerts = /* @__PURE__ */ new Map();
|
|
8732
|
+
this.mapEventToAlert = (event) => {
|
|
8733
|
+
const toAlert = this.map[event.type];
|
|
8734
|
+
if (toAlert) {
|
|
8735
|
+
let getArgs;
|
|
8736
|
+
if (typeof toAlert === "function") {
|
|
8737
|
+
getArgs = toAlert;
|
|
8738
|
+
} else {
|
|
8739
|
+
getArgs = () => toAlert;
|
|
8740
|
+
}
|
|
8741
|
+
const { level, message, timeout } = getArgs(event);
|
|
8742
|
+
this.add(level, message, timeout);
|
|
8743
|
+
}
|
|
8744
|
+
};
|
|
8745
|
+
this.events.subscribe("*", this.mapEventToAlert);
|
|
8746
|
+
}
|
|
8747
|
+
setMap(eventsToAlerts) {
|
|
8748
|
+
this.map = {
|
|
8749
|
+
...this.map,
|
|
8750
|
+
...eventsToAlerts
|
|
8751
|
+
};
|
|
8752
|
+
}
|
|
8753
|
+
add(level, message, timeout = 4e3) {
|
|
8754
|
+
const alert = {
|
|
8755
|
+
level,
|
|
8756
|
+
message,
|
|
8757
|
+
timeout,
|
|
8758
|
+
id: `${message}|${Date.now()}`
|
|
8759
|
+
};
|
|
8760
|
+
this.alerts.set(alert.id, alert);
|
|
8761
|
+
this.events.dispatch({ type: "alerts:add", alert });
|
|
8762
|
+
let timeoutId = null;
|
|
8763
|
+
const dismiss = () => {
|
|
8764
|
+
clearTimeout(timeoutId);
|
|
8765
|
+
this.dismiss(alert);
|
|
8766
|
+
};
|
|
8767
|
+
timeoutId = level !== "error" ? setTimeout(dismiss, alert.timeout) : null;
|
|
8768
|
+
return dismiss;
|
|
8769
|
+
}
|
|
8770
|
+
dismiss(alert) {
|
|
8771
|
+
this.alerts.delete(alert.id);
|
|
8772
|
+
this.events.dispatch({ type: "alerts:remove", alert });
|
|
8773
|
+
}
|
|
8774
|
+
subscribe(cb) {
|
|
8775
|
+
const unsub = this.events.subscribe("alerts", cb);
|
|
8776
|
+
return () => unsub();
|
|
8777
|
+
}
|
|
8778
|
+
get all() {
|
|
8779
|
+
return Array.from(this.alerts.values());
|
|
8780
|
+
}
|
|
8781
|
+
info(message, timeout) {
|
|
8782
|
+
return this.add("info", message, timeout);
|
|
8783
|
+
}
|
|
8784
|
+
success(message, timeout) {
|
|
8785
|
+
return this.add("success", message, timeout);
|
|
8786
|
+
}
|
|
8787
|
+
warn(message, timeout) {
|
|
8788
|
+
return this.add("warn", message, timeout);
|
|
8789
|
+
}
|
|
8790
|
+
error(message, timeout) {
|
|
8791
|
+
return this.add("error", message, timeout);
|
|
8792
|
+
}
|
|
8793
|
+
};
|
|
8727
8794
|
class PluginTypeManager {
|
|
8728
8795
|
constructor(events) {
|
|
8729
8796
|
this.events = events;
|
|
@@ -9568,128 +9635,42 @@ const _CMS = class _CMS2 {
|
|
|
9568
9635
|
_CMS.ENABLED = { type: "cms:enable" };
|
|
9569
9636
|
_CMS.DISABLED = { type: "cms:disable" };
|
|
9570
9637
|
let CMS = _CMS;
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
const toAlert = this.map[event.type];
|
|
9578
|
-
if (toAlert) {
|
|
9579
|
-
let getArgs;
|
|
9580
|
-
if (typeof toAlert === "function") {
|
|
9581
|
-
getArgs = toAlert;
|
|
9582
|
-
} else {
|
|
9583
|
-
getArgs = () => toAlert;
|
|
9584
|
-
}
|
|
9585
|
-
const { level, message, timeout } = getArgs(event);
|
|
9586
|
-
this.add(level, message, timeout);
|
|
9587
|
-
}
|
|
9588
|
-
};
|
|
9589
|
-
this.events.subscribe("*", this.mapEventToAlert);
|
|
9590
|
-
}
|
|
9591
|
-
setMap(eventsToAlerts) {
|
|
9592
|
-
this.map = {
|
|
9593
|
-
...this.map,
|
|
9594
|
-
...eventsToAlerts
|
|
9595
|
-
};
|
|
9596
|
-
}
|
|
9597
|
-
add(level, message, timeout = 4e3) {
|
|
9598
|
-
const alert = {
|
|
9599
|
-
level,
|
|
9600
|
-
message,
|
|
9601
|
-
timeout,
|
|
9602
|
-
id: `${message}|${Date.now()}`
|
|
9603
|
-
};
|
|
9604
|
-
this.alerts.set(alert.id, alert);
|
|
9605
|
-
this.events.dispatch({ type: "alerts:add", alert });
|
|
9606
|
-
let timeoutId = null;
|
|
9607
|
-
const dismiss = () => {
|
|
9608
|
-
clearTimeout(timeoutId);
|
|
9609
|
-
this.dismiss(alert);
|
|
9610
|
-
};
|
|
9611
|
-
timeoutId = level !== "error" ? setTimeout(dismiss, alert.timeout) : null;
|
|
9612
|
-
return dismiss;
|
|
9613
|
-
}
|
|
9614
|
-
dismiss(alert) {
|
|
9615
|
-
this.alerts.delete(alert.id);
|
|
9616
|
-
this.events.dispatch({ type: "alerts:remove", alert });
|
|
9617
|
-
}
|
|
9618
|
-
subscribe(cb) {
|
|
9619
|
-
const unsub = this.events.subscribe("alerts", cb);
|
|
9620
|
-
return () => unsub();
|
|
9621
|
-
}
|
|
9622
|
-
get all() {
|
|
9623
|
-
return Array.from(this.alerts.values());
|
|
9624
|
-
}
|
|
9625
|
-
info(message, timeout) {
|
|
9626
|
-
return this.add("info", message, timeout);
|
|
9627
|
-
}
|
|
9628
|
-
success(message, timeout) {
|
|
9629
|
-
return this.add("success", message, timeout);
|
|
9630
|
-
}
|
|
9631
|
-
warn(message, timeout) {
|
|
9632
|
-
return this.add("warn", message, timeout);
|
|
9633
|
-
}
|
|
9634
|
-
error(message, timeout) {
|
|
9635
|
-
return this.add("error", message, timeout);
|
|
9636
|
-
}
|
|
9638
|
+
const MarkdownFieldPlaceholder = {
|
|
9639
|
+
__type: "field",
|
|
9640
|
+
name: "markdown",
|
|
9641
|
+
Component: createPlaceholder(
|
|
9642
|
+
"Markdown"
|
|
9643
|
+
)
|
|
9637
9644
|
};
|
|
9638
|
-
const
|
|
9639
|
-
"
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
this.loadingPlaceholder = options.placeholder || SidebarLoadingPlaceholder;
|
|
9668
|
-
if ((_a = options.buttons) == null ? void 0 : _a.save) {
|
|
9669
|
-
this.buttons.save = options.buttons.save;
|
|
9670
|
-
}
|
|
9671
|
-
if ((_b = options.buttons) == null ? void 0 : _b.reset) {
|
|
9672
|
-
this.buttons.reset = options.buttons.reset;
|
|
9673
|
-
}
|
|
9674
|
-
}
|
|
9675
|
-
get isOpen() {
|
|
9676
|
-
return this._isOpen;
|
|
9677
|
-
}
|
|
9678
|
-
set isOpen(nextValue) {
|
|
9679
|
-
if (this._isOpen === nextValue) {
|
|
9680
|
-
return;
|
|
9681
|
-
}
|
|
9682
|
-
this._isOpen = nextValue;
|
|
9683
|
-
if (nextValue) {
|
|
9684
|
-
this.events.dispatch({ type: "sidebar:opened" });
|
|
9685
|
-
} else {
|
|
9686
|
-
this.events.dispatch({ type: "sidebar:closed" });
|
|
9687
|
-
}
|
|
9688
|
-
}
|
|
9689
|
-
subscribe(callback) {
|
|
9690
|
-
const unsub = this.events.subscribe("sidebar", callback);
|
|
9691
|
-
return () => unsub();
|
|
9692
|
-
}
|
|
9645
|
+
const HtmlFieldPlaceholder = {
|
|
9646
|
+
__type: "field",
|
|
9647
|
+
name: "html",
|
|
9648
|
+
Component: createPlaceholder(
|
|
9649
|
+
"HTML"
|
|
9650
|
+
)
|
|
9651
|
+
};
|
|
9652
|
+
function createPlaceholder(name, _pr) {
|
|
9653
|
+
return (props) => {
|
|
9654
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
9655
|
+
FieldMeta,
|
|
9656
|
+
{
|
|
9657
|
+
name: props.input.name,
|
|
9658
|
+
label: `${name} Field not Registered`,
|
|
9659
|
+
tinaForm: props.tinaForm
|
|
9660
|
+
},
|
|
9661
|
+
/* @__PURE__ */ React__default.createElement("p", { className: "whitespace-normal text-[15px] mt-2" }, "The ", name, " field is not registered. Some built-in field types are not bundled by default in an effort to control bundle size. Consult the Tina docs to learn how to use this field type."),
|
|
9662
|
+
/* @__PURE__ */ React__default.createElement("p", { className: "whitespace-normal text-[15px] mt-2" }, /* @__PURE__ */ React__default.createElement(
|
|
9663
|
+
"a",
|
|
9664
|
+
{
|
|
9665
|
+
className: "text-blue-500 underline",
|
|
9666
|
+
href: "https://tina.io/docs/editing/markdown/#registering-the-field-plugins",
|
|
9667
|
+
target: "_blank",
|
|
9668
|
+
rel: "noreferrer noopener"
|
|
9669
|
+
},
|
|
9670
|
+
"Tina Docs: Registering Field Plugins"
|
|
9671
|
+
))
|
|
9672
|
+
);
|
|
9673
|
+
};
|
|
9693
9674
|
}
|
|
9694
9675
|
function createScreen({
|
|
9695
9676
|
Component,
|
|
@@ -9738,2209 +9719,2228 @@ const ModalLayout = ({ children, name, close: close2, layout }) => {
|
|
|
9738
9719
|
children
|
|
9739
9720
|
)));
|
|
9740
9721
|
};
|
|
9741
|
-
function
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 18 16" }, "child": [{ "tag": "path", "attr": { "d": "M12 12.041v-0.825c1.102-0.621 2-2.168 2-3.716 0-2.485 0-4.5-3-4.5s-3 2.015-3 4.5c0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h14c0-2.015-2.608-3.682-6-3.959z" }, "child": [] }, { "tag": "path", "attr": { "d": "M5.112 12.427c0.864-0.565 1.939-0.994 3.122-1.256-0.235-0.278-0.449-0.588-0.633-0.922-0.475-0.863-0.726-1.813-0.726-2.748 0-1.344 0-2.614 0.478-3.653 0.464-1.008 1.299-1.633 2.488-1.867-0.264-1.195-0.968-1.98-2.841-1.98-3 0-3 2.015-3 4.5 0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h4.359c0.227-0.202 0.478-0.393 0.753-0.573z" }, "child": [] }] })(props);
|
|
9722
|
+
function dirname(path) {
|
|
9723
|
+
var _a, _b;
|
|
9724
|
+
const pattern = new RegExp("(?<prevDir>.*)/");
|
|
9725
|
+
return (_b = (_a = path.match(pattern)) == null ? void 0 : _a.groups) == null ? void 0 : _b.prevDir;
|
|
9746
9726
|
}
|
|
9747
|
-
const
|
|
9748
|
-
|
|
9749
|
-
|
|
9727
|
+
const BreadcrumbButton = ({ className = "", ...props }) => /* @__PURE__ */ React__default.createElement(
|
|
9728
|
+
"button",
|
|
9729
|
+
{
|
|
9730
|
+
className: "capitalize transition-colors duration-150 border-0 bg-transparent hover:text-blue-500 " + className,
|
|
9731
|
+
...props
|
|
9732
|
+
}
|
|
9733
|
+
);
|
|
9734
|
+
function Breadcrumb$1({ directory = "", setDirectory }) {
|
|
9735
|
+
directory = directory.replace(/^\/|\/$/g, "");
|
|
9736
|
+
let prevDir = dirname(directory) || "";
|
|
9737
|
+
if (prevDir === ".") {
|
|
9738
|
+
prevDir = "";
|
|
9739
|
+
}
|
|
9740
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex items-center text-[16px] text-gray-300" }, directory !== "" && /* @__PURE__ */ React__default.createElement(
|
|
9741
|
+
IconButton,
|
|
9750
9742
|
{
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9743
|
+
variant: "ghost",
|
|
9744
|
+
className: "mr-2",
|
|
9745
|
+
onClick: () => setDirectory(prevDir)
|
|
9754
9746
|
},
|
|
9755
|
-
/* @__PURE__ */
|
|
9747
|
+
/* @__PURE__ */ React__default.createElement(
|
|
9748
|
+
LeftArrowIcon,
|
|
9749
|
+
{
|
|
9750
|
+
className: `w-7 h-auto fill-gray-300 hover:fill-gray-900 transition duration-150 ease-out`
|
|
9751
|
+
}
|
|
9752
|
+
)
|
|
9753
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
9754
|
+
BreadcrumbButton,
|
|
9755
|
+
{
|
|
9756
|
+
onClick: () => setDirectory(""),
|
|
9757
|
+
className: directory === "" ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"
|
|
9758
|
+
},
|
|
9759
|
+
"Media"
|
|
9760
|
+
), directory && directory.split("/").map((part, index, parts) => {
|
|
9761
|
+
const currentDir = parts.slice(0, index + 1).join("/");
|
|
9762
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
9763
|
+
BreadcrumbButton,
|
|
9764
|
+
{
|
|
9765
|
+
className: "pl-1.5 " + (index + 1 === parts.length ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"),
|
|
9766
|
+
key: currentDir,
|
|
9767
|
+
onClick: () => {
|
|
9768
|
+
setDirectory(currentDir);
|
|
9769
|
+
}
|
|
9770
|
+
},
|
|
9771
|
+
part
|
|
9772
|
+
);
|
|
9773
|
+
}));
|
|
9774
|
+
}
|
|
9775
|
+
const CopyField = ({ label, description, value }) => {
|
|
9776
|
+
const [copied, setCopied] = React__default.useState(false);
|
|
9777
|
+
const [fadeOut, setFadeOut] = React__default.useState(false);
|
|
9778
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full" }, label && /* @__PURE__ */ React__default.createElement("label", { className: "w-full mb-1 block flex-1 text-sm font-bold leading-5 text-gray-700" }, label), /* @__PURE__ */ React__default.createElement(
|
|
9779
|
+
"span",
|
|
9780
|
+
{
|
|
9781
|
+
onClick: () => {
|
|
9782
|
+
if (copied === true)
|
|
9783
|
+
return;
|
|
9784
|
+
setCopied(true);
|
|
9785
|
+
setTimeout(() => {
|
|
9786
|
+
setFadeOut(true);
|
|
9787
|
+
}, 2500);
|
|
9788
|
+
setTimeout(() => {
|
|
9789
|
+
setCopied(false);
|
|
9790
|
+
setFadeOut(false);
|
|
9791
|
+
}, 3e3);
|
|
9792
|
+
navigator.clipboard.writeText(value);
|
|
9793
|
+
},
|
|
9794
|
+
className: `shadow-inner text-base leading-5 whitespace-normal break-all px-3 py-2 text-gray-600 w-full bg-gray-50 border border-gray-200 transition-all ease-out duration-150 rounded-md relative overflow-hidden appearance-none flex items-center w-full cursor-pointer hover:bg-white hover:text-blue-500 ${copied ? `pointer-events-none` : ``}`
|
|
9795
|
+
},
|
|
9796
|
+
/* @__PURE__ */ React__default.createElement(BiCopyAlt, { className: "relative text-blue-500 shrink-0 w-5 h-auto mr-1.5 -ml-0.5 z-20" }),
|
|
9756
9797
|
" ",
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9798
|
+
value,
|
|
9799
|
+
" ",
|
|
9800
|
+
copied && /* @__PURE__ */ React__default.createElement(
|
|
9801
|
+
"span",
|
|
9802
|
+
{
|
|
9803
|
+
className: `${fadeOut ? `opacity-0` : `opacity-100`} text-blue-500 transition-opacity duration-500 absolute right-0 w-full h-full px-3 py-2 bg-white bg-opacity-90 flex items-center justify-center text-center tracking-wide font-medium z-10`
|
|
9804
|
+
},
|
|
9805
|
+
/* @__PURE__ */ React__default.createElement("span", null, "Copied to clipboard!")
|
|
9806
|
+
)
|
|
9807
|
+
), description && /* @__PURE__ */ React__default.createElement("p", { className: "mt-2 text-sm text-gray-500" }, description));
|
|
9760
9808
|
};
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
null
|
|
9768
|
-
);
|
|
9769
|
-
React.useEffect(() => {
|
|
9770
|
-
const fetchBillingState = async () => {
|
|
9771
|
-
if (typeof (api == null ? void 0 : api.getBillingState) !== "function")
|
|
9772
|
-
return;
|
|
9773
|
-
const billingRes = await (api == null ? void 0 : api.getBillingState());
|
|
9774
|
-
setBillingState(billingRes);
|
|
9775
|
-
};
|
|
9776
|
-
if (!isCustomContentApi)
|
|
9777
|
-
fetchBillingState();
|
|
9778
|
-
}, []);
|
|
9779
|
-
if (isCustomContentApi || !billingState || billingState.billingState === "current") {
|
|
9780
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
9809
|
+
function ListMediaItem({ item, onClick, active }) {
|
|
9810
|
+
let FileIcon = BiFile;
|
|
9811
|
+
if (item.type === "dir") {
|
|
9812
|
+
FileIcon = BiFolder;
|
|
9813
|
+
} else if (isVideo(item.src)) {
|
|
9814
|
+
FileIcon = BiMovie;
|
|
9781
9815
|
}
|
|
9782
|
-
|
|
9783
|
-
|
|
9816
|
+
const thumbnail = (item.thumbnails || {})["75x75"];
|
|
9817
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
9818
|
+
"li",
|
|
9784
9819
|
{
|
|
9785
|
-
className:
|
|
9786
|
-
|
|
9787
|
-
|
|
9820
|
+
className: `group relative flex shrink-0 items-center transition duration-150 ease-out cursor-pointer border-b border-gray-150 ${active ? "bg-gradient-to-r from-white to-gray-50/50 text-blue-500 hover:bg-gray-50" : "bg-white hover:bg-gray-50/50 hover:text-blue-500"}`,
|
|
9821
|
+
onClick: () => {
|
|
9822
|
+
if (!active) {
|
|
9823
|
+
onClick(item);
|
|
9824
|
+
} else {
|
|
9825
|
+
onClick(false);
|
|
9826
|
+
}
|
|
9827
|
+
}
|
|
9788
9828
|
},
|
|
9789
|
-
"
|
|
9790
|
-
/* @__PURE__ */
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
function FiMoreVertical(props) {
|
|
9797
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "circle", "attr": { "cx": "12", "cy": "12", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "5", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "19", "r": "1" }, "child": [] }] })(props);
|
|
9798
|
-
}
|
|
9799
|
-
function VscNewFile(props) {
|
|
9800
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M9.5 1.1l3.4 3.5.1.4v2h-1V6H8V2H3v11h4v1H2.5l-.5-.5v-12l.5-.5h6.7l.3.1zM9 2v3h2.9L9 2zm4 14h-1v-3H9v-1h3V9h1v3h3v1h-3v3z" }, "child": [] }] })(props);
|
|
9801
|
-
}
|
|
9802
|
-
const FormModal = ({ plugin, close: close2 }) => {
|
|
9803
|
-
const cms = useCMS$1();
|
|
9804
|
-
const form = useMemo(
|
|
9805
|
-
() => new Form({
|
|
9806
|
-
id: "create-form-id",
|
|
9807
|
-
label: "create-form",
|
|
9808
|
-
fields: plugin.fields,
|
|
9809
|
-
actions: plugin.actions,
|
|
9810
|
-
buttons: plugin.buttons,
|
|
9811
|
-
initialValues: plugin.initialValues || {},
|
|
9812
|
-
reset: plugin.reset,
|
|
9813
|
-
onChange: plugin.onChange,
|
|
9814
|
-
onSubmit: async (values) => {
|
|
9815
|
-
await plugin.onSubmit(values, cms).then(() => {
|
|
9816
|
-
close2();
|
|
9817
|
-
});
|
|
9829
|
+
item.new && /* @__PURE__ */ React__default.createElement("span", { className: "absolute top-1.5 left-1.5 rounded-full shadow bg-green-100 border border-green-200 text-[10px] tracking-wide font-bold text-green-600 px-1.5 py-0.5 z-10" }, "NEW"),
|
|
9830
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "w-16 h-16 bg-gray-50 border-r border-gray-150 overflow-hidden flex justify-center flex-shrink-0" }, isImage(thumbnail) ? /* @__PURE__ */ React__default.createElement(
|
|
9831
|
+
"img",
|
|
9832
|
+
{
|
|
9833
|
+
className: "object-contain object-center w-full h-full origin-center transition-all duration-150 ease-out group-hover:scale-110",
|
|
9834
|
+
src: thumbnail,
|
|
9835
|
+
alt: item.filename
|
|
9818
9836
|
}
|
|
9819
|
-
}),
|
|
9820
|
-
|
|
9837
|
+
) : /* @__PURE__ */ React__default.createElement(FileIcon, { className: "w-1/2 h-full fill-gray-300" })),
|
|
9838
|
+
/* @__PURE__ */ React__default.createElement(
|
|
9839
|
+
"span",
|
|
9840
|
+
{
|
|
9841
|
+
className: "text-base flex-grow w-full break-words truncate px-3 py-2"
|
|
9842
|
+
},
|
|
9843
|
+
item.filename
|
|
9844
|
+
)
|
|
9821
9845
|
);
|
|
9822
|
-
return /* @__PURE__ */ React.createElement(Modal, { id: "content-creator-modal", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, plugin.name), /* @__PURE__ */ React.createElement(ModalBody, null, /* @__PURE__ */ React.createElement(FormBuilder, { form: { tinaForm: form } }))));
|
|
9823
|
-
};
|
|
9824
|
-
function HiOutlineClipboardList(props) {
|
|
9825
|
-
return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }, "child": [] }] })(props);
|
|
9826
9846
|
}
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
}
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
// 30 seconds
|
|
9849
|
-
);
|
|
9850
|
-
console.error(error2);
|
|
9851
|
-
setEvents(void 0);
|
|
9852
|
-
setError(error2);
|
|
9853
|
-
}
|
|
9854
|
-
setLoading(false);
|
|
9855
|
-
}
|
|
9856
|
-
};
|
|
9857
|
-
setLoading(true);
|
|
9858
|
-
fetchEvents();
|
|
9859
|
-
}, [cms, cursor]);
|
|
9860
|
-
return { events, cursor: nextCursor, loading, error };
|
|
9861
|
-
};
|
|
9862
|
-
function useSyncStatus$1(cms) {
|
|
9863
|
-
var _a, _b;
|
|
9864
|
-
const [syncStatus, setSyncStatus] = useState({ state: "loading", message: "Loading..." });
|
|
9865
|
-
React.useEffect(() => {
|
|
9866
|
-
const interval = setInterval(async () => {
|
|
9867
|
-
var _a2, _b2, _c, _d, _e;
|
|
9868
|
-
let doFetchEvents = false;
|
|
9869
|
-
if (!((_b2 = (_a2 = cms.api) == null ? void 0 : _a2.tina) == null ? void 0 : _b2.isCustomContentApi)) {
|
|
9870
|
-
doFetchEvents = await ((_e = (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.authProvider) == null ? void 0 : _e.isAuthenticated());
|
|
9871
|
-
}
|
|
9872
|
-
if (doFetchEvents) {
|
|
9873
|
-
const { events } = await cms.api.tina.fetchEvents();
|
|
9874
|
-
if (events.length === 0) {
|
|
9875
|
-
setSyncStatus({ state: "success", message: "No Events" });
|
|
9876
|
-
} else {
|
|
9877
|
-
if (events[0].isError) {
|
|
9878
|
-
setSyncStatus({
|
|
9879
|
-
state: "error",
|
|
9880
|
-
message: `Sync Failure ${events[0].message}`
|
|
9881
|
-
});
|
|
9847
|
+
function GridMediaItem({ item, active, onClick }) {
|
|
9848
|
+
let FileIcon = BiFile;
|
|
9849
|
+
if (item.type === "dir") {
|
|
9850
|
+
FileIcon = BiFolder;
|
|
9851
|
+
} else if (isVideo(item.src)) {
|
|
9852
|
+
FileIcon = BiMovie;
|
|
9853
|
+
}
|
|
9854
|
+
const thumbnail = (item.thumbnails || {})["400x400"];
|
|
9855
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
9856
|
+
"li",
|
|
9857
|
+
{
|
|
9858
|
+
className: `relative pb-[100%] h-0 block border border-gray-100 rounded-md overflow-hidden flex justify-center shrink-0 w-full transition duration-150 ease-out ${active ? "shadow-outline" : "shadow hover:shadow-md hover:scale-103 hover:border-gray-150"} ${item.type === "dir" ? "cursor-pointer" : ""}`
|
|
9859
|
+
},
|
|
9860
|
+
item.new && /* @__PURE__ */ React__default.createElement("span", { className: "absolute top-1.5 left-1.5 rounded-full shadow bg-green-100 border border-green-200 text-[10px] tracking-wide font-bold text-green-600 px-1.5 py-0.5 z-10" }, "NEW"),
|
|
9861
|
+
/* @__PURE__ */ React__default.createElement(
|
|
9862
|
+
"button",
|
|
9863
|
+
{
|
|
9864
|
+
className: "absolute w-full h-full flex items-center justify-center bg-white",
|
|
9865
|
+
onClick: () => {
|
|
9866
|
+
if (!active) {
|
|
9867
|
+
onClick(item);
|
|
9882
9868
|
} else {
|
|
9883
|
-
|
|
9869
|
+
onClick(false);
|
|
9884
9870
|
}
|
|
9885
9871
|
}
|
|
9886
|
-
}
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9872
|
+
},
|
|
9873
|
+
isImage(thumbnail) ? /* @__PURE__ */ React__default.createElement(
|
|
9874
|
+
"img",
|
|
9875
|
+
{
|
|
9876
|
+
className: "object-contain object-center w-full h-full",
|
|
9877
|
+
src: thumbnail,
|
|
9878
|
+
alt: item.filename
|
|
9879
|
+
}
|
|
9880
|
+
) : /* @__PURE__ */ React__default.createElement("div", { className: "p-4 w-full flex flex-col gap-4 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(FileIcon, { className: "w-[30%] h-auto fill-gray-300" }), /* @__PURE__ */ React__default.createElement("span", { className: "block text-base text-gray-600 w-full break-words truncate" }, item.filename))
|
|
9881
|
+
)
|
|
9882
|
+
);
|
|
9893
9883
|
}
|
|
9894
|
-
const
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9884
|
+
const DeleteModal$1 = ({
|
|
9885
|
+
close: close2,
|
|
9886
|
+
deleteFunc,
|
|
9887
|
+
filename
|
|
9888
|
+
}) => {
|
|
9889
|
+
const [processing, setProcessing] = React__default.useState(false);
|
|
9890
|
+
return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", null, "Are you sure you want to delete ", /* @__PURE__ */ React__default.createElement("strong", null, filename), "?")), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, disabled: processing, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
|
|
9891
|
+
Button$1,
|
|
9901
9892
|
{
|
|
9902
|
-
|
|
9903
|
-
|
|
9893
|
+
style: { flexGrow: 3 },
|
|
9894
|
+
disabled: processing,
|
|
9895
|
+
variant: "danger",
|
|
9896
|
+
onClick: async () => {
|
|
9897
|
+
setProcessing(true);
|
|
9898
|
+
try {
|
|
9899
|
+
await deleteFunc();
|
|
9900
|
+
} catch (e) {
|
|
9901
|
+
console.error(e);
|
|
9902
|
+
} finally {
|
|
9903
|
+
close2();
|
|
9904
|
+
}
|
|
9905
|
+
}
|
|
9904
9906
|
},
|
|
9905
|
-
/* @__PURE__ */
|
|
9906
|
-
|
|
9907
|
+
/* @__PURE__ */ React__default.createElement("span", { className: "mr-1" }, "Delete"),
|
|
9908
|
+
processing && /* @__PURE__ */ React__default.createElement(LoadingDots, null)
|
|
9909
|
+
))));
|
|
9907
9910
|
};
|
|
9908
|
-
const
|
|
9909
|
-
const [
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
const time = new Date(event.timestamp).toTimeString();
|
|
9920
|
-
return /* @__PURE__ */ React.createElement("tr", { className: index % 2 === 0 ? "" : "bg-gray-50" }, event.isError ? /* @__PURE__ */ React.createElement(
|
|
9921
|
-
"td",
|
|
9922
|
-
{
|
|
9923
|
-
key: `${event.id}_error_icon`,
|
|
9924
|
-
className: "py-3 pl-4 pr-0 w-0"
|
|
9925
|
-
},
|
|
9926
|
-
/* @__PURE__ */ React.createElement(BsExclamationOctagonFill, { className: "text-red-500 fill-current w-5 h-auto" })
|
|
9927
|
-
) : /* @__PURE__ */ React.createElement(
|
|
9928
|
-
"td",
|
|
9929
|
-
{
|
|
9930
|
-
key: `${event.id}_ok_icon`,
|
|
9931
|
-
className: "py-3 pl-4 pr-0 w-0"
|
|
9932
|
-
},
|
|
9933
|
-
/* @__PURE__ */ React.createElement(BsCheckCircleFill, { className: "text-green-500 fill-current w-5 h-auto" })
|
|
9934
|
-
), /* @__PURE__ */ React.createElement(
|
|
9935
|
-
"td",
|
|
9936
|
-
{
|
|
9937
|
-
key: `${event.id}_msg`,
|
|
9938
|
-
className: "whitespace-nowrap p-3 text-base text-gray-500"
|
|
9939
|
-
},
|
|
9940
|
-
event.message,
|
|
9941
|
-
event.isError && /* @__PURE__ */ React.createElement("div", { className: "w-full text-gray-300 text-xs mt-0.5" }, event.id)
|
|
9942
|
-
), /* @__PURE__ */ React.createElement(
|
|
9943
|
-
"td",
|
|
9944
|
-
{
|
|
9945
|
-
key: `${event.id}_ts`,
|
|
9946
|
-
className: "whitespace-nowrap py-3 pl-3 pr-4 text-sm text-gray-500"
|
|
9947
|
-
},
|
|
9948
|
-
date,
|
|
9949
|
-
/* @__PURE__ */ React.createElement("span", { className: "w-full block text-gray-300 text-xs mt-0.5" }, time)
|
|
9950
|
-
));
|
|
9951
|
-
}).flat())), loading && /* @__PURE__ */ React.createElement("div", { className: "text-sm text-gray-400 text-center" }, "Loading..."), error && /* @__PURE__ */ React.createElement("div", null, "Error: ", error.message), /* @__PURE__ */ React.createElement("div", { className: "text-center flex-1" }, /* @__PURE__ */ React.createElement(
|
|
9911
|
+
const NewFolderModal = ({ onSubmit, close: close2 }) => {
|
|
9912
|
+
const [folderName, setFolderName] = React__default.useState("");
|
|
9913
|
+
return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "New Folder"), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", { className: "text-base text-gray-700 mb-2" }, "Please provide a name for your folder."), /* @__PURE__ */ React__default.createElement("p", { className: "text-sm text-gray-500 mb-4 italic" }, /* @__PURE__ */ React__default.createElement("span", { className: "font-bold" }, "Note"), " – If you navigate away before uploading a media item, the folder will disappear."), /* @__PURE__ */ React__default.createElement(
|
|
9914
|
+
Input,
|
|
9915
|
+
{
|
|
9916
|
+
value: folderName,
|
|
9917
|
+
placeholder: "Folder Name",
|
|
9918
|
+
required: true,
|
|
9919
|
+
onChange: (e) => setFolderName(e.target.value)
|
|
9920
|
+
}
|
|
9921
|
+
)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
|
|
9952
9922
|
Button$1,
|
|
9953
9923
|
{
|
|
9924
|
+
disabled: !folderName,
|
|
9925
|
+
style: { flexGrow: 3 },
|
|
9926
|
+
variant: "primary",
|
|
9954
9927
|
onClick: () => {
|
|
9955
|
-
|
|
9956
|
-
|
|
9928
|
+
if (!folderName)
|
|
9929
|
+
return;
|
|
9930
|
+
onSubmit(folderName);
|
|
9931
|
+
close2();
|
|
9957
9932
|
}
|
|
9958
9933
|
},
|
|
9959
|
-
"
|
|
9960
|
-
)));
|
|
9934
|
+
"Create New Folder"
|
|
9935
|
+
))));
|
|
9961
9936
|
};
|
|
9962
|
-
const
|
|
9963
|
-
const
|
|
9964
|
-
|
|
9965
|
-
const
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9937
|
+
const { useDropzone } = dropzone;
|
|
9938
|
+
const join = function(...parts) {
|
|
9939
|
+
const [first, last, slash] = [0, parts.length - 1, "/"];
|
|
9940
|
+
const matchLeadingSlash = new RegExp("^" + slash);
|
|
9941
|
+
const matchTrailingSlash = new RegExp(slash + "$");
|
|
9942
|
+
parts = parts.map(function(part, index) {
|
|
9943
|
+
if (index === first && part === "file://")
|
|
9944
|
+
return part;
|
|
9945
|
+
if (index > first)
|
|
9946
|
+
part = part.replace(matchLeadingSlash, "");
|
|
9947
|
+
if (index < last)
|
|
9948
|
+
part = part.replace(matchTrailingSlash, "");
|
|
9949
|
+
return part;
|
|
9950
|
+
});
|
|
9951
|
+
return parts.join(slash);
|
|
9952
|
+
};
|
|
9953
|
+
function MediaManager2() {
|
|
9954
|
+
const cms = useCMS();
|
|
9955
|
+
const [request, setRequest] = useState();
|
|
9956
|
+
useEffect(() => {
|
|
9957
|
+
return cms.events.subscribe("media:open", ({ type, ...request2 }) => {
|
|
9958
|
+
setRequest(request2);
|
|
9959
|
+
});
|
|
9960
|
+
}, []);
|
|
9961
|
+
if (!request)
|
|
9970
9962
|
return null;
|
|
9971
|
-
|
|
9972
|
-
return /* @__PURE__ */
|
|
9973
|
-
"
|
|
9963
|
+
const close2 = () => setRequest(void 0);
|
|
9964
|
+
return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(FullscreenModal, null, /* @__PURE__ */ React__default.createElement("div", { className: "w-full bg-gray-50 flex items-center justify-between px-5 pt-3 m-0" }, /* @__PURE__ */ React__default.createElement("h2", { className: "text-gray-500 font-sans font-medium text-base leading-none m-0 block truncate" }, "Media Manager"), /* @__PURE__ */ React__default.createElement(
|
|
9965
|
+
"div",
|
|
9974
9966
|
{
|
|
9975
|
-
|
|
9976
|
-
|
|
9967
|
+
onClick: close2,
|
|
9968
|
+
className: "flex items-center fill-gray-400 cursor-pointer transition-colors duration-100 ease-out hover:fill-gray-700"
|
|
9977
9969
|
},
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
screens,
|
|
9991
|
-
cloudConfigs,
|
|
9992
|
-
contentCreators,
|
|
9993
|
-
sidebarWidth,
|
|
9994
|
-
RenderNavSite,
|
|
9995
|
-
RenderNavCloud,
|
|
9996
|
-
RenderNavCollection,
|
|
9997
|
-
AuthRenderNavCollection,
|
|
9970
|
+
/* @__PURE__ */ React__default.createElement(CloseIcon, { className: "w-6 h-auto" })
|
|
9971
|
+
)), /* @__PURE__ */ React__default.createElement(ModalBody, { className: "flex h-full flex-col" }, /* @__PURE__ */ React__default.createElement(MediaPicker, { ...request, close: close2 }))));
|
|
9972
|
+
}
|
|
9973
|
+
const defaultListError = new MediaListError({
|
|
9974
|
+
title: "Error fetching media",
|
|
9975
|
+
message: "Something went wrong while requesting the resource.",
|
|
9976
|
+
docsLink: "https://tina.io/docs/media/#media-store"
|
|
9977
|
+
});
|
|
9978
|
+
function MediaPicker({
|
|
9979
|
+
allowDelete,
|
|
9980
|
+
onSelect,
|
|
9981
|
+
close: close2,
|
|
9998
9982
|
...props
|
|
9999
|
-
})
|
|
10000
|
-
|
|
10001
|
-
const
|
|
10002
|
-
const
|
|
10003
|
-
(
|
|
10004
|
-
|
|
10005
|
-
|
|
9983
|
+
}) {
|
|
9984
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9985
|
+
const cms = useCMS();
|
|
9986
|
+
const [listState, setListState] = useState(() => {
|
|
9987
|
+
if (cms.media.isConfigured)
|
|
9988
|
+
return "loading";
|
|
9989
|
+
return "not-configured";
|
|
9990
|
+
});
|
|
9991
|
+
const [deleteModalOpen, setDeleteModalOpen] = React__default.useState(false);
|
|
9992
|
+
const [newFolderModalOpen, setNewFolderModalOpen] = React__default.useState(false);
|
|
9993
|
+
const [listError, setListError] = useState(defaultListError);
|
|
9994
|
+
const [directory, setDirectory] = useState(
|
|
9995
|
+
props.directory
|
|
9996
|
+
);
|
|
9997
|
+
const [list, setList] = useState({
|
|
9998
|
+
items: [],
|
|
9999
|
+
nextOffset: void 0
|
|
10000
|
+
});
|
|
10001
|
+
const resetList = () => setList({
|
|
10002
|
+
items: [],
|
|
10003
|
+
nextOffset: void 0
|
|
10004
|
+
});
|
|
10005
|
+
const [viewMode, setViewMode] = useState("grid");
|
|
10006
|
+
const [activeItem, setActiveItem] = useState(false);
|
|
10007
|
+
const closePreview = () => setActiveItem(false);
|
|
10008
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
10009
|
+
const [loadFolders, setLoadFolders] = useState(true);
|
|
10010
|
+
const [offsetHistory, setOffsetHistory] = useState([]);
|
|
10011
|
+
const offset2 = offsetHistory[offsetHistory.length - 1];
|
|
10012
|
+
const resetOffset = () => setOffsetHistory([]);
|
|
10013
|
+
async function loadMedia(loadFolders2 = true) {
|
|
10014
|
+
setListState("loading");
|
|
10015
|
+
try {
|
|
10016
|
+
const _list = await cms.media.list({
|
|
10017
|
+
offset: offset2,
|
|
10018
|
+
limit: cms.media.pageSize,
|
|
10019
|
+
directory,
|
|
10020
|
+
thumbnailSizes: [
|
|
10021
|
+
{ w: 75, h: 75 },
|
|
10022
|
+
{ w: 400, h: 400 },
|
|
10023
|
+
{ w: 1e3, h: 1e3 }
|
|
10024
|
+
],
|
|
10025
|
+
filesOnly: !loadFolders2
|
|
10026
|
+
});
|
|
10027
|
+
setList({
|
|
10028
|
+
items: [...list.items, ..._list.items],
|
|
10029
|
+
nextOffset: _list.nextOffset
|
|
10030
|
+
});
|
|
10031
|
+
setListState("loaded");
|
|
10032
|
+
} catch (e) {
|
|
10033
|
+
console.error(e);
|
|
10034
|
+
if (e.ERR_TYPE === "MediaListError") {
|
|
10035
|
+
setListError(e);
|
|
10006
10036
|
} else {
|
|
10007
|
-
|
|
10037
|
+
setListError(defaultListError);
|
|
10008
10038
|
}
|
|
10009
|
-
|
|
10010
|
-
},
|
|
10011
|
-
{
|
|
10012
|
-
contentCollections: []
|
|
10039
|
+
setListState("error");
|
|
10013
10040
|
}
|
|
10014
|
-
);
|
|
10015
|
-
function closeEventsModal() {
|
|
10016
|
-
setEventsOpen(false);
|
|
10017
10041
|
}
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
(
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
return
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10042
|
+
useEffect(() => {
|
|
10043
|
+
if (!refreshing)
|
|
10044
|
+
return;
|
|
10045
|
+
loadMedia();
|
|
10046
|
+
setRefreshing(false);
|
|
10047
|
+
}, [refreshing]);
|
|
10048
|
+
useEffect(() => {
|
|
10049
|
+
if (!cms.media.isConfigured)
|
|
10050
|
+
return;
|
|
10051
|
+
if (refreshing)
|
|
10052
|
+
return;
|
|
10053
|
+
loadMedia(loadFolders);
|
|
10054
|
+
if (loadFolders)
|
|
10055
|
+
setLoadFolders(false);
|
|
10056
|
+
return cms.events.subscribe(
|
|
10057
|
+
["media:delete:success", "media:pageSize"],
|
|
10058
|
+
() => {
|
|
10059
|
+
setRefreshing(true);
|
|
10060
|
+
resetOffset();
|
|
10061
|
+
resetList();
|
|
10062
|
+
}
|
|
10063
|
+
);
|
|
10064
|
+
}, [offset2, directory, cms.media.isConfigured]);
|
|
10065
|
+
const onClickMediaItem = (item) => {
|
|
10066
|
+
if (!item) {
|
|
10067
|
+
setActiveItem(false);
|
|
10068
|
+
} else if (item.type === "dir") {
|
|
10069
|
+
setDirectory(
|
|
10070
|
+
item.directory === "." || item.directory === "" ? item.filename : join(item.directory, item.filename)
|
|
10071
|
+
);
|
|
10072
|
+
setLoadFolders(true);
|
|
10073
|
+
resetOffset();
|
|
10074
|
+
resetList();
|
|
10075
|
+
setActiveItem(false);
|
|
10076
|
+
} else {
|
|
10077
|
+
setActiveItem(item);
|
|
10078
|
+
}
|
|
10079
|
+
};
|
|
10080
|
+
let deleteMediaItem;
|
|
10081
|
+
if (allowDelete) {
|
|
10082
|
+
deleteMediaItem = async (item) => {
|
|
10083
|
+
await cms.media.delete(item);
|
|
10084
|
+
};
|
|
10085
|
+
}
|
|
10086
|
+
let selectMediaItem;
|
|
10087
|
+
if (onSelect) {
|
|
10088
|
+
selectMediaItem = (item) => {
|
|
10089
|
+
onSelect(item);
|
|
10090
|
+
if (close2)
|
|
10091
|
+
close2();
|
|
10092
|
+
};
|
|
10093
|
+
}
|
|
10094
|
+
const [uploading, setUploading] = useState(false);
|
|
10095
|
+
const accept = Array.isArray(
|
|
10096
|
+
(_c = (_b = (_a = cms.api.tina.schema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.media) == null ? void 0 : _c.accept
|
|
10097
|
+
) ? (_f = (_e = (_d = cms.api.tina.schema.schema) == null ? void 0 : _d.config) == null ? void 0 : _e.media) == null ? void 0 : _f.accept.join(",") : (_i = (_h = (_g = cms.api.tina.schema.schema) == null ? void 0 : _g.config) == null ? void 0 : _h.media) == null ? void 0 : _i.accept;
|
|
10098
|
+
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
10099
|
+
accept: dropzoneAcceptFromString(
|
|
10100
|
+
accept || cms.media.accept || DEFAULT_MEDIA_UPLOAD_TYPES
|
|
10101
|
+
),
|
|
10102
|
+
maxSize: cms.media.maxSize,
|
|
10103
|
+
multiple: true,
|
|
10104
|
+
onDrop: async (files, fileRejections) => {
|
|
10105
|
+
try {
|
|
10106
|
+
setUploading(true);
|
|
10107
|
+
const mediaItems = await cms.media.persist(
|
|
10108
|
+
files.map((file) => {
|
|
10109
|
+
return {
|
|
10110
|
+
directory: directory || "/",
|
|
10111
|
+
file
|
|
10112
|
+
};
|
|
10113
|
+
})
|
|
10114
|
+
);
|
|
10115
|
+
const errorCodes = {
|
|
10116
|
+
"file-invalid-type": "Invalid file type",
|
|
10117
|
+
"file-too-large": "File too large",
|
|
10118
|
+
"file-too-small": "File too small",
|
|
10119
|
+
"too-many-files": "Too many files"
|
|
10120
|
+
};
|
|
10121
|
+
const printError = (error) => {
|
|
10122
|
+
const message = errorCodes[error.code];
|
|
10123
|
+
if (message) {
|
|
10124
|
+
return message;
|
|
10125
|
+
}
|
|
10126
|
+
console.error(error);
|
|
10127
|
+
return "Unknown error";
|
|
10128
|
+
};
|
|
10129
|
+
if (fileRejections.length > 0) {
|
|
10130
|
+
const messages = [];
|
|
10131
|
+
fileRejections.map((fileRejection) => {
|
|
10132
|
+
messages.push(
|
|
10133
|
+
`${fileRejection.file.name}: ${fileRejection.errors.map((error) => printError(error)).join(", ")}`
|
|
10134
|
+
);
|
|
10135
|
+
});
|
|
10136
|
+
cms.alerts.error(() => {
|
|
10137
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, "Upload Failed. ", /* @__PURE__ */ React__default.createElement("br", null), messages.join(". "), ".");
|
|
10138
|
+
});
|
|
10058
10139
|
}
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10140
|
+
if (mediaItems.length !== 0) {
|
|
10141
|
+
setActiveItem(mediaItems[0]);
|
|
10142
|
+
setList((mediaList) => {
|
|
10143
|
+
return {
|
|
10144
|
+
items: [
|
|
10145
|
+
// all the newly added items are new
|
|
10146
|
+
...mediaItems.map((x) => ({ ...x, new: true })),
|
|
10147
|
+
...mediaList.items
|
|
10148
|
+
],
|
|
10149
|
+
nextOffset: mediaList.nextOffset
|
|
10150
|
+
};
|
|
10151
|
+
});
|
|
10152
|
+
}
|
|
10153
|
+
} catch {
|
|
10154
|
+
}
|
|
10155
|
+
setUploading(false);
|
|
10156
|
+
}
|
|
10157
|
+
});
|
|
10158
|
+
const { onClick, ...rootProps } = getRootProps();
|
|
10159
|
+
function disableScrollBody() {
|
|
10160
|
+
const body = document == null ? void 0 : document.body;
|
|
10161
|
+
body.style.overflow = "hidden";
|
|
10162
|
+
return () => {
|
|
10163
|
+
body.style.overflow = "auto";
|
|
10164
|
+
};
|
|
10165
|
+
}
|
|
10166
|
+
useEffect(disableScrollBody, []);
|
|
10167
|
+
const loaderRef = useRef(null);
|
|
10168
|
+
useEffect(() => {
|
|
10169
|
+
const observer = new IntersectionObserver((entries) => {
|
|
10170
|
+
const target = entries[0];
|
|
10171
|
+
if (target.isIntersecting && list.nextOffset) {
|
|
10172
|
+
setOffsetHistory((offsetHistory2) => [
|
|
10173
|
+
...offsetHistory2,
|
|
10174
|
+
list.nextOffset
|
|
10175
|
+
]);
|
|
10176
|
+
}
|
|
10177
|
+
});
|
|
10178
|
+
if (loaderRef.current) {
|
|
10179
|
+
observer.observe(loaderRef.current);
|
|
10180
|
+
}
|
|
10181
|
+
return () => {
|
|
10182
|
+
if (loaderRef.current) {
|
|
10183
|
+
observer.unobserve(loaderRef.current);
|
|
10184
|
+
}
|
|
10185
|
+
};
|
|
10186
|
+
}, [list.nextOffset, loaderRef.current]);
|
|
10187
|
+
if (listState === "loading" && !((_j = list == null ? void 0 : list.items) == null ? void 0 : _j.length) || uploading) {
|
|
10188
|
+
return /* @__PURE__ */ React__default.createElement(LoadingMediaList, null);
|
|
10189
|
+
}
|
|
10190
|
+
if (listState === "not-configured") {
|
|
10191
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
10192
|
+
DocsLink,
|
|
10062
10193
|
{
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10194
|
+
title: "No Media Store Configured",
|
|
10195
|
+
message: "To use the media manager, you need to configure a Media Store.",
|
|
10196
|
+
docsLink: "https://tina.io/docs/reference/media/overview/"
|
|
10197
|
+
}
|
|
10198
|
+
);
|
|
10199
|
+
}
|
|
10200
|
+
if (listState === "error") {
|
|
10201
|
+
const { title, message, docsLink } = listError;
|
|
10202
|
+
return /* @__PURE__ */ React__default.createElement(DocsLink, { title, message, docsLink });
|
|
10203
|
+
}
|
|
10204
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, deleteModalOpen && /* @__PURE__ */ React__default.createElement(
|
|
10205
|
+
DeleteModal$1,
|
|
10206
|
+
{
|
|
10207
|
+
filename: activeItem ? activeItem.filename : "",
|
|
10208
|
+
deleteFunc: async () => {
|
|
10209
|
+
if (activeItem) {
|
|
10210
|
+
await deleteMediaItem(activeItem);
|
|
10211
|
+
setActiveItem(false);
|
|
10212
|
+
}
|
|
10069
10213
|
},
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
try {
|
|
10082
|
-
if ((_c = (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.authProvider) == null ? void 0 : _c.logout) {
|
|
10083
|
-
await ((_d = cms.api.tina) == null ? void 0 : _d.authProvider.logout());
|
|
10084
|
-
if ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout) {
|
|
10085
|
-
await ((_h = (_g = cms == null ? void 0 : cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.onLogout());
|
|
10086
|
-
await new Promise(
|
|
10087
|
-
(resolve) => setTimeout(resolve, 500)
|
|
10088
|
-
);
|
|
10089
|
-
}
|
|
10090
|
-
window.location.href = new URL(
|
|
10091
|
-
window.location.href
|
|
10092
|
-
).pathname;
|
|
10093
|
-
}
|
|
10094
|
-
} catch (e) {
|
|
10095
|
-
cms.alerts.error(`Error logging out: ${e}`);
|
|
10096
|
-
console.error("Unexpected error calling logout");
|
|
10097
|
-
console.error(e);
|
|
10098
|
-
}
|
|
10214
|
+
close: () => setDeleteModalOpen(false)
|
|
10215
|
+
}
|
|
10216
|
+
), newFolderModalOpen && /* @__PURE__ */ React__default.createElement(
|
|
10217
|
+
NewFolderModal,
|
|
10218
|
+
{
|
|
10219
|
+
onSubmit: (name) => {
|
|
10220
|
+
setDirectory((oldDir) => {
|
|
10221
|
+
if (oldDir) {
|
|
10222
|
+
return join(oldDir, name);
|
|
10223
|
+
} else {
|
|
10224
|
+
return name;
|
|
10099
10225
|
}
|
|
10100
|
-
}
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10226
|
+
});
|
|
10227
|
+
resetOffset();
|
|
10228
|
+
resetList();
|
|
10229
|
+
},
|
|
10230
|
+
close: () => setNewFolderModalOpen(false)
|
|
10231
|
+
}
|
|
10232
|
+
), /* @__PURE__ */ React__default.createElement(MediaPickerWrap, null, /* @__PURE__ */ React__default.createElement(SyncStatusContainer, null, /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-wrap items-center bg-gray-50 border-b border-gray-150 gap-4 py-3 px-5 shadow-sm flex-shrink-0" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-1 items-center gap-4" }, /* @__PURE__ */ React__default.createElement(ViewModeToggle, { viewMode, setViewMode }), /* @__PURE__ */ React__default.createElement(
|
|
10233
|
+
Breadcrumb$1,
|
|
10234
|
+
{
|
|
10235
|
+
directory,
|
|
10236
|
+
setDirectory: (dir) => {
|
|
10237
|
+
setDirectory(dir);
|
|
10238
|
+
setLoadFolders(true);
|
|
10239
|
+
resetOffset();
|
|
10240
|
+
resetList();
|
|
10241
|
+
setActiveItem(false);
|
|
10242
|
+
}
|
|
10243
|
+
}
|
|
10244
|
+
)), cms.media.store.isStatic ? null : /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-wrap items-center gap-4" }, /* @__PURE__ */ React__default.createElement(
|
|
10245
|
+
Button$1,
|
|
10246
|
+
{
|
|
10247
|
+
busy: false,
|
|
10248
|
+
variant: "white",
|
|
10249
|
+
onClick: () => {
|
|
10250
|
+
setRefreshing(true);
|
|
10251
|
+
resetOffset();
|
|
10252
|
+
resetList();
|
|
10253
|
+
setActiveItem(false);
|
|
10254
|
+
},
|
|
10255
|
+
className: "whitespace-nowrap"
|
|
10256
|
+
},
|
|
10257
|
+
"Refresh",
|
|
10258
|
+
/* @__PURE__ */ React__default.createElement(IoMdRefresh, { className: "w-6 h-full ml-2 opacity-70 text-blue-500" })
|
|
10259
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
10260
|
+
Button$1,
|
|
10261
|
+
{
|
|
10262
|
+
busy: false,
|
|
10263
|
+
variant: "white",
|
|
10264
|
+
onClick: () => {
|
|
10265
|
+
setNewFolderModalOpen(true);
|
|
10266
|
+
},
|
|
10267
|
+
className: "whitespace-nowrap"
|
|
10268
|
+
},
|
|
10269
|
+
"New Folder",
|
|
10270
|
+
/* @__PURE__ */ React__default.createElement(BiFolder, { className: "w-6 h-full ml-2 opacity-70 text-blue-500" })
|
|
10271
|
+
), /* @__PURE__ */ React__default.createElement(UploadButton, { onClick, uploading }))), /* @__PURE__ */ React__default.createElement("div", { className: "flex h-full overflow-hidden bg-white" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-full flex-col h-full @container" }, /* @__PURE__ */ React__default.createElement(
|
|
10272
|
+
"ul",
|
|
10273
|
+
{
|
|
10274
|
+
...rootProps,
|
|
10275
|
+
className: `h-full grow overflow-y-auto transition duration-150 ease-out bg-gradient-to-b from-gray-50/50 to-gray-50 ${list.items.length === 0 || viewMode === "list" && "w-full flex flex-1 flex-col justify-start -mb-px"} ${list.items.length > 0 && viewMode === "grid" && "w-full p-4 gap-4 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 4xl:grid-cols-6 6xl:grid-cols-9 auto-rows-auto content-start justify-start"} ${isDragActive ? `border-2 border-blue-500 rounded-lg` : ``}`
|
|
10276
|
+
},
|
|
10277
|
+
/* @__PURE__ */ React__default.createElement("input", { ...getInputProps() }),
|
|
10278
|
+
listState === "loaded" && list.items.length === 0 && /* @__PURE__ */ React__default.createElement(EmptyMediaList, null),
|
|
10279
|
+
viewMode === "list" && list.items.map((item) => /* @__PURE__ */ React__default.createElement(
|
|
10280
|
+
ListMediaItem,
|
|
10281
|
+
{
|
|
10282
|
+
key: item.id,
|
|
10283
|
+
item,
|
|
10284
|
+
onClick: onClickMediaItem,
|
|
10285
|
+
active: activeItem && activeItem.id === item.id
|
|
10286
|
+
}
|
|
10287
|
+
)),
|
|
10288
|
+
viewMode === "grid" && list.items.map((item) => /* @__PURE__ */ React__default.createElement(
|
|
10289
|
+
GridMediaItem,
|
|
10290
|
+
{
|
|
10291
|
+
key: item.id,
|
|
10292
|
+
item,
|
|
10293
|
+
onClick: onClickMediaItem,
|
|
10294
|
+
active: activeItem && activeItem.id === item.id
|
|
10295
|
+
}
|
|
10296
|
+
)),
|
|
10297
|
+
!!list.nextOffset && /* @__PURE__ */ React__default.createElement(LoadingMediaList, { ref: loaderRef })
|
|
10298
|
+
)), /* @__PURE__ */ React__default.createElement(
|
|
10299
|
+
ActiveItemPreview,
|
|
10300
|
+
{
|
|
10301
|
+
activeItem,
|
|
10302
|
+
close: closePreview,
|
|
10303
|
+
selectMediaItem,
|
|
10304
|
+
allowDelete: cms.media.store.isStatic ? false : allowDelete,
|
|
10305
|
+
deleteMediaItem: () => {
|
|
10306
|
+
setDeleteModalOpen(true);
|
|
10307
|
+
}
|
|
10308
|
+
}
|
|
10309
|
+
)))));
|
|
10310
|
+
}
|
|
10311
|
+
const ActiveItemPreview = ({
|
|
10312
|
+
activeItem,
|
|
10313
|
+
close: close2,
|
|
10314
|
+
selectMediaItem,
|
|
10315
|
+
deleteMediaItem,
|
|
10316
|
+
allowDelete
|
|
10317
|
+
}) => {
|
|
10318
|
+
const thumbnail = activeItem ? (activeItem.thumbnails || {})["1000x1000"] : "";
|
|
10319
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
10320
|
+
"div",
|
|
10321
|
+
{
|
|
10322
|
+
className: `shrink-0 h-full flex flex-col items-start gap-3 overflow-y-auto bg-white border-l border-gray-100 bg-white shadow-md transition ease-out duration-150 ${activeItem ? `p-4 opacity-100 w-[35%] max-w-[560px] min-w-[240px]` : `translate-x-8 opacity-0 w-[0px]`}`
|
|
10323
|
+
},
|
|
10324
|
+
activeItem && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "flex grow-0 shrink-0 gap-2 w-full items-center justify-between" }, /* @__PURE__ */ React__default.createElement("h3", { className: "text-lg text-gray-600 w-full max-w-full break-words block truncate flex-1" }, activeItem.filename), /* @__PURE__ */ React__default.createElement(
|
|
10325
|
+
IconButton,
|
|
10115
10326
|
{
|
|
10116
|
-
|
|
10117
|
-
|
|
10327
|
+
variant: "ghost",
|
|
10328
|
+
className: "group grow-0 shrink-0",
|
|
10329
|
+
onClick: close2
|
|
10118
10330
|
},
|
|
10119
|
-
/* @__PURE__ */
|
|
10120
|
-
|
|
10121
|
-
|
|
10331
|
+
/* @__PURE__ */ React__default.createElement(
|
|
10332
|
+
BiX,
|
|
10333
|
+
{
|
|
10334
|
+
className: `w-7 h-auto text-gray-500 opacity-50 group-hover:opacity-100 transition duration-150 ease-out`
|
|
10335
|
+
}
|
|
10336
|
+
)
|
|
10337
|
+
)), isImage(thumbnail) ? /* @__PURE__ */ React__default.createElement("div", { className: "w-full max-h-[75%]" }, /* @__PURE__ */ React__default.createElement(
|
|
10338
|
+
"img",
|
|
10122
10339
|
{
|
|
10123
|
-
|
|
10124
|
-
|
|
10340
|
+
className: "block border border-gray-100 rounded-md overflow-hidden object-center object-contain max-w-full max-h-full m-auto shadow",
|
|
10341
|
+
src: thumbnail,
|
|
10342
|
+
alt: activeItem.filename
|
|
10125
10343
|
}
|
|
10126
|
-
))
|
|
10127
|
-
|
|
10128
|
-
}), contentCreators.map((plugin, idx) => {
|
|
10129
|
-
return /* @__PURE__ */ React.createElement(CreateContentNavItem, { key: `plugin-${idx}`, plugin });
|
|
10130
|
-
}), authCollection && /* @__PURE__ */ React.createElement(
|
|
10131
|
-
CollectionsList,
|
|
10344
|
+
)) : /* @__PURE__ */ React__default.createElement("span", { className: "p-3 border border-gray-100 rounded-md overflow-hidden bg-gray-50 shadow" }, /* @__PURE__ */ React__default.createElement(BiFile, { className: "w-14 h-auto fill-gray-300" })), /* @__PURE__ */ React__default.createElement("div", { className: "grow h-full w-full shrink flex flex-col gap-3 items-start justify-start" }, /* @__PURE__ */ React__default.createElement(CopyField, { value: absoluteImgURL(activeItem.src), label: "URL" })), /* @__PURE__ */ React__default.createElement("div", { className: "shrink-0 w-full flex flex-col justify-end items-start" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-full gap-3" }, selectMediaItem && /* @__PURE__ */ React__default.createElement(
|
|
10345
|
+
Button$1,
|
|
10132
10346
|
{
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10347
|
+
size: "medium",
|
|
10348
|
+
variant: "primary",
|
|
10349
|
+
className: "grow",
|
|
10350
|
+
onClick: () => selectMediaItem(activeItem)
|
|
10351
|
+
},
|
|
10352
|
+
"Insert",
|
|
10353
|
+
/* @__PURE__ */ React__default.createElement(BiArrowToBottom, { className: "ml-1 -mr-0.5 w-6 h-auto text-white opacity-70" })
|
|
10354
|
+
), allowDelete && /* @__PURE__ */ React__default.createElement(
|
|
10355
|
+
Button$1,
|
|
10356
|
+
{
|
|
10357
|
+
variant: "white",
|
|
10358
|
+
size: "medium",
|
|
10359
|
+
className: "grow max-w-[40%]",
|
|
10360
|
+
onClick: deleteMediaItem
|
|
10361
|
+
},
|
|
10362
|
+
"Delete",
|
|
10363
|
+
/* @__PURE__ */ React__default.createElement(TrashIcon, { className: "ml-1 -mr-0.5 w-6 h-auto text-red-500 opacity-70" })
|
|
10364
|
+
))))
|
|
10145
10365
|
);
|
|
10146
10366
|
};
|
|
10147
|
-
const
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
}) => {
|
|
10151
|
-
if (collections.length === 0) {
|
|
10152
|
-
return /* @__PURE__ */ React.createElement("div", null, "No collections found");
|
|
10153
|
-
}
|
|
10154
|
-
return /* @__PURE__ */ React.createElement("ul", { className: "flex flex-col gap-4" }, collections.map((collection) => {
|
|
10155
|
-
return /* @__PURE__ */ React.createElement("li", { key: `nav-collection-${collection.name}` }, /* @__PURE__ */ React.createElement(RenderNavCollection, { collection }));
|
|
10156
|
-
}));
|
|
10157
|
-
};
|
|
10158
|
-
const CreateContentNavItem = ({ plugin }) => {
|
|
10159
|
-
const [open2, setOpen] = React.useState(false);
|
|
10160
|
-
return /* @__PURE__ */ React.createElement("li", { key: plugin.name }, /* @__PURE__ */ React.createElement(
|
|
10161
|
-
"button",
|
|
10367
|
+
const UploadButton = ({ onClick, uploading }) => {
|
|
10368
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
10369
|
+
Button$1,
|
|
10162
10370
|
{
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10371
|
+
variant: "primary",
|
|
10372
|
+
size: "custom",
|
|
10373
|
+
className: "text-sm h-10 px-6",
|
|
10374
|
+
busy: uploading,
|
|
10375
|
+
onClick
|
|
10167
10376
|
},
|
|
10168
|
-
/* @__PURE__ */
|
|
10169
|
-
|
|
10170
|
-
plugin.name
|
|
10171
|
-
), open2 && /* @__PURE__ */ React.createElement(FormModal, { plugin, close: () => setOpen(false) }));
|
|
10377
|
+
uploading ? /* @__PURE__ */ React__default.createElement(LoadingDots, null) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, "Upload ", /* @__PURE__ */ React__default.createElement(BiCloudUpload, { className: "w-6 h-full ml-2 opacity-70" }))
|
|
10378
|
+
);
|
|
10172
10379
|
};
|
|
10173
|
-
const
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10380
|
+
const LoadingMediaList = forwardRef(
|
|
10381
|
+
(props, ref) => {
|
|
10382
|
+
const { extraText, ...rest } = props;
|
|
10383
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
10384
|
+
"div",
|
|
10385
|
+
{
|
|
10386
|
+
ref,
|
|
10387
|
+
className: "w-full h-full flex flex-col items-center justify-center",
|
|
10388
|
+
...rest
|
|
10389
|
+
},
|
|
10390
|
+
extraText && /* @__PURE__ */ React__default.createElement("p", null, extraText),
|
|
10391
|
+
/* @__PURE__ */ React__default.createElement(LoadingDots, { color: "var(--tina-color-primary)" })
|
|
10392
|
+
);
|
|
10393
|
+
}
|
|
10394
|
+
);
|
|
10395
|
+
const MediaPickerWrap = ({ children }) => {
|
|
10396
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "h-full flex-1 text-gray-700 flex flex-col relative bg-gray-50 outline-none active:outline-none focus:outline-none" }, children);
|
|
10397
|
+
};
|
|
10398
|
+
const SyncStatusContext = createContext(
|
|
10399
|
+
void 0
|
|
10400
|
+
);
|
|
10401
|
+
const SyncStatusContainer = ({ children }) => {
|
|
10402
|
+
var _a, _b, _c;
|
|
10403
|
+
const cms = useCMS();
|
|
10404
|
+
const isLocal = cms.api.tina.isLocalMode;
|
|
10405
|
+
const tinaMedia = (_c = (_b = (_a = cms.api.tina.schema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.media) == null ? void 0 : _c.tina;
|
|
10406
|
+
const hasTinaMedia = !!((tinaMedia == null ? void 0 : tinaMedia.mediaRoot) || (tinaMedia == null ? void 0 : tinaMedia.publicFolder));
|
|
10407
|
+
const doCheckSyncStatus = hasTinaMedia && !isLocal;
|
|
10408
|
+
const [syncStatus, setSyncStatus] = useState(doCheckSyncStatus ? "loading" : "synced");
|
|
10409
|
+
useEffect(() => {
|
|
10410
|
+
const checkSyncStatus = async () => {
|
|
10411
|
+
if (doCheckSyncStatus) {
|
|
10412
|
+
const project = await cms.api.tina.getProject();
|
|
10413
|
+
setSyncStatus(project.mediaBranch ? "synced" : "needs-sync");
|
|
10414
|
+
}
|
|
10186
10415
|
};
|
|
10416
|
+
if (!cms.media.store.isStatic) {
|
|
10417
|
+
checkSyncStatus();
|
|
10418
|
+
}
|
|
10187
10419
|
}, []);
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
const maxWidth = window.innerWidth - 8;
|
|
10193
|
-
if (newWidth < minSidebarWidth) {
|
|
10194
|
-
return minSidebarWidth;
|
|
10195
|
-
} else if (newWidth > maxWidth) {
|
|
10196
|
-
return maxWidth;
|
|
10197
|
-
} else {
|
|
10198
|
-
return newWidth;
|
|
10199
|
-
}
|
|
10200
|
-
});
|
|
10201
|
-
};
|
|
10202
|
-
if (resizingSidebar) {
|
|
10203
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
10204
|
-
document.body.classList.add("select-none");
|
|
10420
|
+
return syncStatus == "needs-sync" ? /* @__PURE__ */ React__default.createElement("div", { className: "h-full flex items-center justify-center p-6 bg-gradient-to-t from-gray-200 to-transparent" }, /* @__PURE__ */ React__default.createElement("div", { className: "rounded-lg border shadow-sm px-4 lg:px-6 py-3 lg:py-4 bg-gradient-to-r from-yellow-50 to-yellow-100 border-yellow-200 mx-auto mb-12" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-start sm:items-center gap-2" }, /* @__PURE__ */ React__default.createElement(
|
|
10421
|
+
BiError,
|
|
10422
|
+
{
|
|
10423
|
+
className: `w-7 h-auto flex-shrink-0 text-yellow-400 -mt-px`
|
|
10205
10424
|
}
|
|
10206
|
-
|
|
10207
|
-
window.removeEventListener("mousemove", handleMouseMove);
|
|
10208
|
-
document.body.classList.remove("select-none");
|
|
10209
|
-
};
|
|
10210
|
-
}, [resizingSidebar]);
|
|
10211
|
-
const handleresizingSidebar = () => setResizingSidebar(true);
|
|
10212
|
-
if (fullscreen) {
|
|
10213
|
-
return null;
|
|
10214
|
-
}
|
|
10215
|
-
return /* @__PURE__ */ React.createElement(
|
|
10425
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
10216
10426
|
"div",
|
|
10217
10427
|
{
|
|
10218
|
-
|
|
10219
|
-
className: `z-100 absolute top-1/2 right-px w-2 h-32 bg-white rounded-r-md border border-gray-150 shadow-sm hover:shadow-md origin-left transition-all duration-150 ease-out transform translate-x-full -translate-y-1/2 group hover:bg-gray-50 ${displayState !== "closed" ? `opacity-100` : `opacity-0`} ${resizingSidebar ? `scale-110` : `scale-90 hover:scale-100`}`,
|
|
10220
|
-
style: { cursor: "grab" }
|
|
10221
|
-
},
|
|
10222
|
-
/* @__PURE__ */ React.createElement("span", { className: "absolute top-1/2 left-1/2 h-4/6 w-px bg-gray-200 transform -translate-y-1/2 -translate-x-1/2 opacity-30 transition-opacity duration-150 ease-out group-hover:opacity-100" })
|
|
10223
|
-
);
|
|
10224
|
-
};
|
|
10225
|
-
const Item = ({
|
|
10226
|
-
item,
|
|
10227
|
-
depth,
|
|
10228
|
-
setActiveFormId
|
|
10229
|
-
}) => {
|
|
10230
|
-
const cms = useCMS();
|
|
10231
|
-
const depths = ["pl-6", "pl-10", "pl-14"];
|
|
10232
|
-
const form = React.useMemo(
|
|
10233
|
-
() => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
|
|
10234
|
-
[item.formId]
|
|
10235
|
-
);
|
|
10236
|
-
return /* @__PURE__ */ React.createElement(
|
|
10237
|
-
"button",
|
|
10238
|
-
{
|
|
10239
|
-
type: "button",
|
|
10240
|
-
key: item.path,
|
|
10241
|
-
onClick: () => setActiveFormId(item.formId),
|
|
10242
|
-
className: `${depths[depth] || "pl-12"} pr-6 py-3 w-full h-full bg-transparent border-none text-lg text-gray-700 group hover:bg-gray-50 transition-all ease-out duration-150 flex items-center justify-between gap-2`
|
|
10428
|
+
className: `flex-1 flex flex-col items-start gap-0.5 text-base text-yellow-700`
|
|
10243
10429
|
},
|
|
10244
|
-
|
|
10245
|
-
/* @__PURE__ */
|
|
10246
|
-
|
|
10430
|
+
"Media needs to be turned on for this project.",
|
|
10431
|
+
/* @__PURE__ */ React__default.createElement(
|
|
10432
|
+
"a",
|
|
10433
|
+
{
|
|
10434
|
+
className: "transition-all duration-150 ease-out text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 font-medium flex items-center justify-start gap-1",
|
|
10435
|
+
target: "_blank",
|
|
10436
|
+
href: `${cms.api.tina.appDashboardLink}/media`
|
|
10437
|
+
},
|
|
10438
|
+
"Sync Your Media In TinaCloud.",
|
|
10439
|
+
/* @__PURE__ */ React__default.createElement(BiLinkExternal, { className: `w-5 h-auto flex-shrink-0` })
|
|
10440
|
+
)
|
|
10441
|
+
)))) : /* @__PURE__ */ React__default.createElement(SyncStatusContext.Provider, { value: { syncStatus } }, children);
|
|
10247
10442
|
};
|
|
10248
|
-
const
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
}
|
|
10253
|
-
|
|
10254
|
-
return /* @__PURE__ */ React.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
|
|
10255
|
-
if (subItem.type === "document") {
|
|
10256
|
-
return /* @__PURE__ */ React.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React.createElement(
|
|
10257
|
-
Item,
|
|
10258
|
-
{
|
|
10259
|
-
setActiveFormId,
|
|
10260
|
-
depth: depth + 1,
|
|
10261
|
-
item: subItem
|
|
10262
|
-
}
|
|
10263
|
-
));
|
|
10264
|
-
}
|
|
10265
|
-
})));
|
|
10443
|
+
const useSyncStatus$1 = () => {
|
|
10444
|
+
const context = useContext(SyncStatusContext);
|
|
10445
|
+
if (!context) {
|
|
10446
|
+
throw new Error("useSyncStatus must be used within a SyncStatusProvider");
|
|
10447
|
+
}
|
|
10448
|
+
return context;
|
|
10266
10449
|
};
|
|
10267
|
-
const
|
|
10268
|
-
const
|
|
10269
|
-
return /* @__PURE__ */
|
|
10270
|
-
|
|
10450
|
+
const EmptyMediaList = () => {
|
|
10451
|
+
const { syncStatus } = useSyncStatus$1();
|
|
10452
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: `p-12 text-xl opacity-50 text-center` }, syncStatus == "synced" ? "Drag and drop assets here" : "Loading...");
|
|
10453
|
+
};
|
|
10454
|
+
const DocsLink = ({ title, message, docsLink, ...props }) => {
|
|
10455
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "h-3/4 text-center flex flex-col justify-center", ...props }, /* @__PURE__ */ React__default.createElement("h2", { className: "mb-3 text-xl text-gray-600" }, title), /* @__PURE__ */ React__default.createElement("div", { className: "mb-3 text-base text-gray-700" }, message), /* @__PURE__ */ React__default.createElement(
|
|
10456
|
+
"a",
|
|
10271
10457
|
{
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
enterFrom: "opacity-0 -translate-x-1/2",
|
|
10277
|
-
enterTo: "opacity-100",
|
|
10278
|
-
leave: "transition-all ease-out duration-150",
|
|
10279
|
-
leaveFrom: "opacity-100",
|
|
10280
|
-
leaveTo: "opacity-0 -translate-x-1/2"
|
|
10458
|
+
href: docsLink,
|
|
10459
|
+
target: "_blank",
|
|
10460
|
+
rel: "noreferrer noopener",
|
|
10461
|
+
className: "font-bold text-blue-500 hover:text-blue-600 hover:underline transition-all ease-out duration-150"
|
|
10281
10462
|
},
|
|
10282
|
-
|
|
10283
|
-
|
|
10463
|
+
"Learn More"
|
|
10464
|
+
));
|
|
10465
|
+
};
|
|
10466
|
+
const ViewModeToggle = ({ viewMode, setViewMode }) => {
|
|
10467
|
+
const toggleClasses = {
|
|
10468
|
+
base: "relative whitespace-nowrap flex items-center justify-center flex-1 block font-medium text-base py-1 transition-all ease-out duration-150 border",
|
|
10469
|
+
active: "bg-white text-blue-500 shadow-inner border-gray-50 border-t-gray-100",
|
|
10470
|
+
inactive: "bg-gray-50 text-gray-400 shadow border-gray-100 border-t-white"
|
|
10471
|
+
};
|
|
10472
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
10473
|
+
"div",
|
|
10474
|
+
{
|
|
10475
|
+
className: `grow-0 flex justify-between rounded-md border border-gray-100`
|
|
10476
|
+
},
|
|
10477
|
+
/* @__PURE__ */ React__default.createElement(
|
|
10478
|
+
"button",
|
|
10284
10479
|
{
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
}
|
|
10289
|
-
|
|
10290
|
-
}
|
|
10291
|
-
)
|
|
10480
|
+
className: `${toggleClasses.base} px-2.5 rounded-l-md ${viewMode === "grid" ? toggleClasses.active : toggleClasses.inactive}`,
|
|
10481
|
+
onClick: () => {
|
|
10482
|
+
setViewMode("grid");
|
|
10483
|
+
}
|
|
10484
|
+
},
|
|
10485
|
+
/* @__PURE__ */ React__default.createElement(BiGridAlt, { className: "w-6 h-full opacity-70" })
|
|
10486
|
+
),
|
|
10487
|
+
/* @__PURE__ */ React__default.createElement(
|
|
10488
|
+
"button",
|
|
10489
|
+
{
|
|
10490
|
+
className: `${toggleClasses.base} px-2 rounded-r-md ${viewMode === "list" ? toggleClasses.active : toggleClasses.inactive}`,
|
|
10491
|
+
onClick: () => {
|
|
10492
|
+
setViewMode("list");
|
|
10493
|
+
}
|
|
10494
|
+
},
|
|
10495
|
+
/* @__PURE__ */ React__default.createElement(BiListUl, { className: "w-8 h-full opacity-70" })
|
|
10496
|
+
)
|
|
10292
10497
|
);
|
|
10293
10498
|
};
|
|
10294
|
-
const
|
|
10295
|
-
|
|
10296
|
-
|
|
10499
|
+
const MediaManagerScreenPlugin = createScreen({
|
|
10500
|
+
name: "Media Manager",
|
|
10501
|
+
Component: MediaPicker,
|
|
10502
|
+
Icon: MdOutlinePhotoLibrary,
|
|
10503
|
+
layout: "fullscreen",
|
|
10504
|
+
props: {
|
|
10505
|
+
allowDelete: true
|
|
10506
|
+
}
|
|
10507
|
+
});
|
|
10508
|
+
function UpdatePassword(props) {
|
|
10509
|
+
const cms = useCMS$1();
|
|
10510
|
+
const client = cms.api.tina;
|
|
10511
|
+
const [password, setPassword] = useState("");
|
|
10512
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
10513
|
+
const [dirty, setDirty] = useState(false);
|
|
10514
|
+
const [result, setResult] = useState(null);
|
|
10515
|
+
const [formState, setFormState] = useState("idle");
|
|
10516
|
+
const [passwordChangeRequired, setPasswordChangeRequired] = useState(false);
|
|
10517
|
+
useEffect(() => {
|
|
10297
10518
|
var _a;
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10519
|
+
(_a = client == null ? void 0 : client.authProvider) == null ? void 0 : _a.getUser().then(
|
|
10520
|
+
(user) => setPasswordChangeRequired((user == null ? void 0 : user.passwordChangeRequired) ?? false)
|
|
10521
|
+
);
|
|
10522
|
+
}, []);
|
|
10523
|
+
let err = null;
|
|
10524
|
+
if (dirty && password !== confirmPassword) {
|
|
10525
|
+
err = "Passwords do not match";
|
|
10526
|
+
}
|
|
10527
|
+
if (dirty && !password) {
|
|
10528
|
+
err = "Please enter a password";
|
|
10529
|
+
}
|
|
10530
|
+
const updatePassword = async () => {
|
|
10531
|
+
var _a;
|
|
10532
|
+
setResult(null);
|
|
10533
|
+
setFormState("busy");
|
|
10534
|
+
const res = await cms.api.tina.request(
|
|
10535
|
+
`mutation($password: String!) { updatePassword(password: $password) }`,
|
|
10536
|
+
{
|
|
10537
|
+
variables: {
|
|
10538
|
+
password
|
|
10310
10539
|
}
|
|
10311
|
-
} else {
|
|
10312
|
-
orderedListItems.push(item);
|
|
10313
10540
|
}
|
|
10314
|
-
|
|
10315
|
-
if ((
|
|
10316
|
-
|
|
10541
|
+
);
|
|
10542
|
+
if (!(res == null ? void 0 : res.updatePassword)) {
|
|
10543
|
+
setResult("Error updating password");
|
|
10544
|
+
} else {
|
|
10545
|
+
setDirty(false);
|
|
10546
|
+
setPassword("");
|
|
10547
|
+
setConfirmPassword("");
|
|
10548
|
+
setResult("Password updated");
|
|
10549
|
+
setPasswordChangeRequired(false);
|
|
10550
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
10551
|
+
(_a = client == null ? void 0 : client.authProvider) == null ? void 0 : _a.logout().then(async () => {
|
|
10552
|
+
if (typeof (client == null ? void 0 : client.onLogout) === "function") {
|
|
10553
|
+
await client.onLogout();
|
|
10554
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
10555
|
+
}
|
|
10556
|
+
window.location.href = new URL(window.location.href).pathname;
|
|
10557
|
+
}).catch((e) => console.error(e));
|
|
10317
10558
|
}
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10559
|
+
setFormState("idle");
|
|
10560
|
+
};
|
|
10561
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-center items-center h-full" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col space-y-8 p-6" }, passwordChangeRequired && /* @__PURE__ */ React__default.createElement("div", { className: "text-center text-red-500" }, "Your password has expired. Please update your password."), /* @__PURE__ */ React__default.createElement("label", { className: "block" }, /* @__PURE__ */ React__default.createElement("span", { className: "text-gray-700" }, "New Password"), /* @__PURE__ */ React__default.createElement(
|
|
10562
|
+
BaseTextField,
|
|
10563
|
+
{
|
|
10564
|
+
type: "password",
|
|
10565
|
+
name: "password",
|
|
10566
|
+
id: "password",
|
|
10567
|
+
placeholder: "Enter password",
|
|
10568
|
+
className: err ? "border-red-500" : "border-gray-300 focus:ring-indigo-500 focus:border-indigo-500",
|
|
10569
|
+
value: password,
|
|
10570
|
+
onKeyDown: () => {
|
|
10571
|
+
setDirty(true);
|
|
10572
|
+
setResult(null);
|
|
10573
|
+
},
|
|
10574
|
+
onChange: (e) => setPassword(e.target.value),
|
|
10575
|
+
required: true
|
|
10321
10576
|
}
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
},
|
|
10338
|
-
item.label
|
|
10339
|
-
)
|
|
10340
|
-
);
|
|
10577
|
+
)), /* @__PURE__ */ React__default.createElement("label", { className: "block" }, /* @__PURE__ */ React__default.createElement("span", { className: "text-gray-700" }, "Confirm New Password"), /* @__PURE__ */ React__default.createElement(
|
|
10578
|
+
BaseTextField,
|
|
10579
|
+
{
|
|
10580
|
+
type: "password",
|
|
10581
|
+
name: "confirmPassword",
|
|
10582
|
+
id: "confirmPassword",
|
|
10583
|
+
placeholder: "Confirm password",
|
|
10584
|
+
className: err ? "border-red-500" : "border-gray-300 focus:ring-indigo-500 focus:border-indigo-500",
|
|
10585
|
+
value: confirmPassword,
|
|
10586
|
+
onKeyDown: () => {
|
|
10587
|
+
setDirty(true);
|
|
10588
|
+
setResult(null);
|
|
10589
|
+
},
|
|
10590
|
+
onChange: (e) => setConfirmPassword(e.target.value),
|
|
10591
|
+
required: true
|
|
10341
10592
|
}
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
}
|
|
10353
|
-
const
|
|
10593
|
+
)), result && /* @__PURE__ */ React__default.createElement("div", { className: "text-center text-sm text-gray-500" }, result), err && /* @__PURE__ */ React__default.createElement("div", { className: "text-center text-sm text-red-500" }, err), /* @__PURE__ */ React__default.createElement(
|
|
10594
|
+
Button$1,
|
|
10595
|
+
{
|
|
10596
|
+
onClick: updatePassword,
|
|
10597
|
+
disabled: err,
|
|
10598
|
+
variant: "primary",
|
|
10599
|
+
busy: formState === "busy"
|
|
10600
|
+
},
|
|
10601
|
+
"Update"
|
|
10602
|
+
))));
|
|
10603
|
+
}
|
|
10604
|
+
const PasswordScreenPlugin = createScreen({
|
|
10605
|
+
name: "Change Password",
|
|
10606
|
+
Component: UpdatePassword,
|
|
10607
|
+
Icon: MdVpnKey,
|
|
10608
|
+
layout: "fullscreen",
|
|
10609
|
+
navCategory: "Account"
|
|
10610
|
+
});
|
|
10611
|
+
function createCloudConfig({
|
|
10612
|
+
...options
|
|
10613
|
+
}) {
|
|
10614
|
+
return {
|
|
10615
|
+
__type: "cloud-config",
|
|
10616
|
+
Icon: MdOutlineCloud,
|
|
10617
|
+
...options
|
|
10618
|
+
};
|
|
10619
|
+
}
|
|
10620
|
+
const SidebarLoadingPlaceholder = () => /* @__PURE__ */ React.createElement(
|
|
10354
10621
|
"div",
|
|
10355
10622
|
{
|
|
10356
10623
|
className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
|
|
10357
10624
|
style: {
|
|
10358
10625
|
animationName: "fade-in",
|
|
10359
10626
|
animationDelay: "300ms",
|
|
10360
|
-
animationTimingFunction: "ease-out",
|
|
10361
|
-
animationIterationCount: 1,
|
|
10362
|
-
animationFillMode: "both",
|
|
10363
|
-
animationDuration: "150ms"
|
|
10364
|
-
}
|
|
10365
|
-
},
|
|
10366
|
-
/* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "
|
|
10367
|
-
/* @__PURE__ */ React.createElement(
|
|
10368
|
-
Button$1,
|
|
10369
|
-
{
|
|
10370
|
-
href: "https://tina.io/docs/contextual-editing/overview",
|
|
10371
|
-
target: "_blank",
|
|
10372
|
-
as: "a"
|
|
10373
|
-
},
|
|
10374
|
-
/* @__PURE__ */ React.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
|
|
10375
|
-
" Contextual Editing Docs"
|
|
10376
|
-
))
|
|
10627
|
+
animationTimingFunction: "ease-out",
|
|
10628
|
+
animationIterationCount: 1,
|
|
10629
|
+
animationFillMode: "both",
|
|
10630
|
+
animationDuration: "150ms"
|
|
10631
|
+
}
|
|
10632
|
+
},
|
|
10633
|
+
/* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Please wait while TinaCMS", /* @__PURE__ */ React.createElement("br", null), "loads your content"),
|
|
10634
|
+
/* @__PURE__ */ React.createElement(LoadingDots, { color: "var(--tina-color-primary)" })
|
|
10377
10635
|
);
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10636
|
+
class SidebarState {
|
|
10637
|
+
constructor(events, options = {}) {
|
|
10638
|
+
var _a, _b;
|
|
10639
|
+
this.events = events;
|
|
10640
|
+
this._isOpen = false;
|
|
10641
|
+
this.position = "displace";
|
|
10642
|
+
this.renderNav = true;
|
|
10643
|
+
this.buttons = {
|
|
10644
|
+
save: "Save",
|
|
10645
|
+
reset: "Reset"
|
|
10646
|
+
};
|
|
10647
|
+
this.position = options.position || "displace";
|
|
10648
|
+
this.renderNav = options.renderNav || true;
|
|
10649
|
+
this.loadingPlaceholder = options.placeholder || SidebarLoadingPlaceholder;
|
|
10650
|
+
if ((_a = options.buttons) == null ? void 0 : _a.save) {
|
|
10651
|
+
this.buttons.save = options.buttons.save;
|
|
10652
|
+
}
|
|
10653
|
+
if ((_b = options.buttons) == null ? void 0 : _b.reset) {
|
|
10654
|
+
this.buttons.reset = options.buttons.reset;
|
|
10655
|
+
}
|
|
10383
10656
|
}
|
|
10384
|
-
)
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
if (
|
|
10393
|
-
|
|
10394
|
-
const timer = setTimeout(() => {
|
|
10395
|
-
if (!cms.state.isLoadingContent) {
|
|
10396
|
-
setIsShowingLoading(false);
|
|
10397
|
-
setInitialLoadComplete(true);
|
|
10398
|
-
}
|
|
10399
|
-
}, minimumTimeToShowLoadingIndicator);
|
|
10400
|
-
return () => clearTimeout(timer);
|
|
10657
|
+
get isOpen() {
|
|
10658
|
+
return this._isOpen;
|
|
10659
|
+
}
|
|
10660
|
+
set isOpen(nextValue) {
|
|
10661
|
+
if (this._isOpen === nextValue) {
|
|
10662
|
+
return;
|
|
10663
|
+
}
|
|
10664
|
+
this._isOpen = nextValue;
|
|
10665
|
+
if (nextValue) {
|
|
10666
|
+
this.events.dispatch({ type: "sidebar:opened" });
|
|
10401
10667
|
} else {
|
|
10402
|
-
|
|
10403
|
-
setIsShowingLoading(false);
|
|
10404
|
-
setInitialLoadComplete(true);
|
|
10405
|
-
}, minimumTimeToShowLoadingIndicator);
|
|
10406
|
-
return () => clearTimeout(timer);
|
|
10668
|
+
this.events.dispatch({ type: "sidebar:closed" });
|
|
10407
10669
|
}
|
|
10408
|
-
}, [cms.state.isLoadingContent]);
|
|
10409
|
-
if (isShowingLoading || !initialLoadComplete) {
|
|
10410
|
-
const LoadingPlaceholder = loadingPlaceholder || SidebarLoadingPlaceholder;
|
|
10411
|
-
return /* @__PURE__ */ React.createElement(LoadingPlaceholder, null);
|
|
10412
|
-
}
|
|
10413
|
-
if (!cms.state.formLists.length) {
|
|
10414
|
-
return /* @__PURE__ */ React.createElement(SidebarNoFormsPlaceholder, null);
|
|
10415
10670
|
}
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
(
|
|
10419
|
-
);
|
|
10420
|
-
const isEditing = !!activeForm;
|
|
10421
|
-
if (isMultiform && !activeForm) {
|
|
10422
|
-
return /* @__PURE__ */ React.createElement(FormLists, { isEditing });
|
|
10671
|
+
subscribe(callback) {
|
|
10672
|
+
const unsub = this.events.subscribe("sidebar", callback);
|
|
10673
|
+
return () => unsub();
|
|
10423
10674
|
}
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
};
|
|
10427
|
-
|
|
10675
|
+
}
|
|
10676
|
+
function ImFilesEmpty(props) {
|
|
10677
|
+
return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 16 16" }, "child": [{ "tag": "path", "attr": { "d": "M14.341 5.579c-0.347-0.473-0.831-1.027-1.362-1.558s-1.085-1.015-1.558-1.362c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.689 0.561 1.25 1.25 1.25h9.5c0.689 0 1.25-0.561 1.25-1.25v-7.75c0-0.224-0.068-0.615-0.659-1.421zM12.271 4.729c0.48 0.48 0.856 0.912 1.134 1.271h-2.406v-2.405c0.359 0.278 0.792 0.654 1.271 1.134v0zM14 14.75c0 0.136-0.114 0.25-0.25 0.25h-9.5c-0.136 0-0.25-0.114-0.25-0.25v-11.5c0-0.135 0.114-0.25 0.25-0.25 0 0 5.749-0 5.75 0v3.5c0 0.276 0.224 0.5 0.5 0.5h3.5v7.75z" }, "child": [] }, { "tag": "path", "attr": { "d": "M9.421 0.659c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.604 0.43 1.109 1 1.225v-12.725c0-0.135 0.115-0.25 0.25-0.25h7.607c-0.151-0.124-0.297-0.238-0.437-0.341z" }, "child": [] }] })(props);
|
|
10678
|
+
}
|
|
10679
|
+
function ImUsers(props) {
|
|
10680
|
+
return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 18 16" }, "child": [{ "tag": "path", "attr": { "d": "M12 12.041v-0.825c1.102-0.621 2-2.168 2-3.716 0-2.485 0-4.5-3-4.5s-3 2.015-3 4.5c0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h14c0-2.015-2.608-3.682-6-3.959z" }, "child": [] }, { "tag": "path", "attr": { "d": "M5.112 12.427c0.864-0.565 1.939-0.994 3.122-1.256-0.235-0.278-0.449-0.588-0.633-0.922-0.475-0.863-0.726-1.813-0.726-2.748 0-1.344 0-2.614 0.478-3.653 0.464-1.008 1.299-1.633 2.488-1.867-0.264-1.195-0.968-1.98-2.841-1.98-3 0-3 2.015-3 4.5 0 1.548 0.898 3.095 2 3.716v0.825c-3.392 0.277-6 1.944-6 3.959h4.359c0.227-0.202 0.478-0.393 0.753-0.573z" }, "child": [] }] })(props);
|
|
10681
|
+
}
|
|
10682
|
+
const LocalWarning = () => {
|
|
10428
10683
|
return /* @__PURE__ */ React.createElement(
|
|
10429
|
-
"
|
|
10684
|
+
"a",
|
|
10430
10685
|
{
|
|
10431
|
-
className: "flex-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
animationName: "fly-in-left",
|
|
10435
|
-
animationDuration: "150ms",
|
|
10436
|
-
animationDelay: "0",
|
|
10437
|
-
animationIterationCount: 1,
|
|
10438
|
-
animationTimingFunction: "ease-out"
|
|
10439
|
-
} : {
|
|
10440
|
-
transform: "translate3d(100%, 0, 0)"
|
|
10441
|
-
}
|
|
10686
|
+
className: "flex-grow-0 flex w-full text-xs items-center py-1 px-4 text-yellow-600 bg-gradient-to-r from-yellow-50 to-yellow-100 border-b border-gray-150 shadow-sm",
|
|
10687
|
+
href: "https://tina.io/docs/tina-cloud/",
|
|
10688
|
+
target: "_blank"
|
|
10442
10689
|
},
|
|
10443
|
-
|
|
10690
|
+
/* @__PURE__ */ React.createElement(AiFillWarning, { className: "w-5 h-auto inline-block mr-1 opacity-70 text-yellow-600" }),
|
|
10691
|
+
" ",
|
|
10692
|
+
"You are currently in",
|
|
10693
|
+
/* @__PURE__ */ React.createElement("strong", { className: "ml-1 font-bold text-yellow-700" }, "Local Mode")
|
|
10444
10694
|
);
|
|
10445
10695
|
};
|
|
10446
|
-
const
|
|
10447
|
-
|
|
10448
|
-
}) => {
|
|
10696
|
+
const BillingWarning = () => {
|
|
10697
|
+
var _a;
|
|
10449
10698
|
const cms = useCMS$1();
|
|
10450
|
-
const
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
|
|
10455
|
-
},
|
|
10456
|
-
/* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
|
|
10457
|
-
"button",
|
|
10458
|
-
{
|
|
10459
|
-
type: "button",
|
|
10460
|
-
className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
|
|
10461
|
-
onClick: () => {
|
|
10462
|
-
const state = activeForm.tinaForm.finalForm.getState();
|
|
10463
|
-
if (state.invalid === true) {
|
|
10464
|
-
cms.alerts.error("Cannot navigate away from an invalid form.");
|
|
10465
|
-
} else {
|
|
10466
|
-
cms.dispatch({ type: "forms:set-active-form-id", value: null });
|
|
10467
|
-
}
|
|
10468
|
-
}
|
|
10469
|
-
},
|
|
10470
|
-
/* @__PURE__ */ React.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
|
|
10471
|
-
), /* @__PURE__ */ React.createElement(
|
|
10472
|
-
"button",
|
|
10473
|
-
{
|
|
10474
|
-
type: "button",
|
|
10475
|
-
className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
|
|
10476
|
-
onClick: () => {
|
|
10477
|
-
const collectionName = cms.api.tina.schema.getCollectionByFullPath(
|
|
10478
|
-
cms.state.activeFormId
|
|
10479
|
-
).name;
|
|
10480
|
-
window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
|
|
10481
|
-
}
|
|
10482
|
-
},
|
|
10483
|
-
/* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
|
|
10484
|
-
), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
|
|
10699
|
+
const api = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina;
|
|
10700
|
+
const isCustomContentApi = (api == null ? void 0 : api.isCustomContentApi) || false;
|
|
10701
|
+
const [billingState, setBillingState] = React.useState(
|
|
10702
|
+
null
|
|
10485
10703
|
);
|
|
10486
|
-
|
|
10487
|
-
const
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10704
|
+
React.useEffect(() => {
|
|
10705
|
+
const fetchBillingState = async () => {
|
|
10706
|
+
if (typeof (api == null ? void 0 : api.getBillingState) !== "function")
|
|
10707
|
+
return;
|
|
10708
|
+
const billingRes = await (api == null ? void 0 : api.getBillingState());
|
|
10709
|
+
setBillingState(billingRes);
|
|
10710
|
+
};
|
|
10711
|
+
if (!isCustomContentApi)
|
|
10712
|
+
fetchBillingState();
|
|
10713
|
+
}, []);
|
|
10714
|
+
if (isCustomContentApi || !billingState || billingState.billingState === "current") {
|
|
10715
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
10716
|
+
}
|
|
10717
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex-grow-0 flex flex-wrap w-full text-xs items-center justify-between gap-1.5 py-1.5 px-3 text-red-700 bg-gradient-to-br from-white via-red-50 to-red-100 border-b border-red-200" }, /* @__PURE__ */ React.createElement("span", { className: "flex items-center gap-1 font-bold" }, /* @__PURE__ */ React.createElement(BiError, { className: "w-5 h-auto flex-shrink-0 flex-grow-0 inline-block opacity-70 text-red-600" }), /* @__PURE__ */ React.createElement("span", { className: "flex whitespace-nowrap" }, "There is an issue with your billing.")), /* @__PURE__ */ React.createElement(
|
|
10718
|
+
"a",
|
|
10493
10719
|
{
|
|
10494
|
-
className: "
|
|
10720
|
+
className: "text-xs text-blue-600 underline decoration-blue-200 hover:text-blue-500 hover:decoration-blue-500 transition-all ease-out duration-150 flex items-center gap-1 self-end",
|
|
10721
|
+
href: `https://app.tina.io/projects/${billingState.clientId}/billing`,
|
|
10722
|
+
target: "_blank"
|
|
10495
10723
|
},
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
type: "button",
|
|
10500
|
-
className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
|
|
10501
|
-
onClick: () => {
|
|
10502
|
-
const collectionName = cms.api.tina.schema.getCollectionByFullPath(
|
|
10503
|
-
cms.state.activeFormId
|
|
10504
|
-
).name;
|
|
10505
|
-
window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
|
|
10506
|
-
}
|
|
10507
|
-
},
|
|
10508
|
-
/* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
|
|
10509
|
-
), shortFormLabel && /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
|
|
10510
|
-
);
|
|
10511
|
-
};
|
|
10512
|
-
const SidebarContext = React.createContext(null);
|
|
10513
|
-
const minPreviewWidth = 440;
|
|
10514
|
-
const minSidebarWidth = 360;
|
|
10515
|
-
const navBreakpoint = 1279;
|
|
10516
|
-
const LOCALSTATEKEY = "tina.sidebarState";
|
|
10517
|
-
const LOCALWIDTHKEY = "tina.sidebarWidth";
|
|
10518
|
-
const defaultSidebarWidth = 440;
|
|
10519
|
-
const defaultSidebarPosition = "displace";
|
|
10520
|
-
const defaultSidebarState = "open";
|
|
10521
|
-
function SidebarProvider({
|
|
10522
|
-
position = defaultSidebarPosition,
|
|
10523
|
-
resizingSidebar,
|
|
10524
|
-
setResizingSidebar,
|
|
10525
|
-
defaultWidth = defaultSidebarWidth,
|
|
10526
|
-
sidebar
|
|
10527
|
-
}) {
|
|
10528
|
-
var _a, _b, _c;
|
|
10529
|
-
useSubscribable(sidebar);
|
|
10530
|
-
const cms = useCMS$1();
|
|
10531
|
-
if (!cms.enabled)
|
|
10532
|
-
return null;
|
|
10533
|
-
return /* @__PURE__ */ React.createElement(
|
|
10534
|
-
Sidebar$1,
|
|
10535
|
-
{
|
|
10536
|
-
position: ((_a = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _a.position) || position,
|
|
10537
|
-
defaultWidth: ((_b = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _b.defaultWidth) || defaultWidth,
|
|
10538
|
-
resizingSidebar,
|
|
10539
|
-
setResizingSidebar,
|
|
10540
|
-
renderNav: (
|
|
10541
|
-
// @ts-ignore
|
|
10542
|
-
typeof ((_c = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _c.renderNav) !== "undefined" ? (
|
|
10543
|
-
// @ts-ignore
|
|
10544
|
-
cms.sidebar.renderNav
|
|
10545
|
-
) : true
|
|
10546
|
-
),
|
|
10547
|
-
sidebar
|
|
10548
|
-
}
|
|
10549
|
-
);
|
|
10550
|
-
}
|
|
10551
|
-
const useFetchCollections = (cms) => {
|
|
10552
|
-
return { collections: cms.api.admin.fetchCollections(), loading: false };
|
|
10724
|
+
"Visit Billing Page",
|
|
10725
|
+
/* @__PURE__ */ React.createElement(BiRightArrowAlt, { className: "w-5 h-full opacity-70" })
|
|
10726
|
+
));
|
|
10553
10727
|
};
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
}
|
|
10563
|
-
|
|
10728
|
+
function FiInfo(props) {
|
|
10729
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "circle", "attr": { "cx": "12", "cy": "12", "r": "10" }, "child": [] }, { "tag": "line", "attr": { "x1": "12", "y1": "16", "x2": "12", "y2": "12" }, "child": [] }, { "tag": "line", "attr": { "x1": "12", "y1": "8", "x2": "12.01", "y2": "8" }, "child": [] }] })(props);
|
|
10730
|
+
}
|
|
10731
|
+
function FiMoreVertical(props) {
|
|
10732
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "circle", "attr": { "cx": "12", "cy": "12", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "5", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "19", "r": "1" }, "child": [] }] })(props);
|
|
10733
|
+
}
|
|
10734
|
+
function VscNewFile(props) {
|
|
10735
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M9.5 1.1l3.4 3.5.1.4v2h-1V6H8V2H3v11h4v1H2.5l-.5-.5v-12l.5-.5h6.7l.3.1zM9 2v3h2.9L9 2zm4 14h-1v-3H9v-1h3V9h1v3h3v1h-3v3z" }, "child": [] }] })(props);
|
|
10736
|
+
}
|
|
10737
|
+
const FormModal = ({ plugin, close: close2 }) => {
|
|
10564
10738
|
const cms = useCMS$1();
|
|
10565
|
-
const
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10739
|
+
const form = useMemo(
|
|
10740
|
+
() => new Form({
|
|
10741
|
+
id: "create-form-id",
|
|
10742
|
+
label: "create-form",
|
|
10743
|
+
fields: plugin.fields,
|
|
10744
|
+
actions: plugin.actions,
|
|
10745
|
+
buttons: plugin.buttons,
|
|
10746
|
+
initialValues: plugin.initialValues || {},
|
|
10747
|
+
reset: plugin.reset,
|
|
10748
|
+
onChange: plugin.onChange,
|
|
10749
|
+
onSubmit: async (values) => {
|
|
10750
|
+
await plugin.onSubmit(values, cms).then(() => {
|
|
10751
|
+
close2();
|
|
10752
|
+
});
|
|
10573
10753
|
}
|
|
10574
|
-
})
|
|
10575
|
-
|
|
10576
|
-
const screens = cms.plugins.getType("screen");
|
|
10577
|
-
const cloudConfigs = cms.plugins.getType("cloud-config");
|
|
10578
|
-
useSubscribable(sidebar);
|
|
10579
|
-
useSubscribable(screens);
|
|
10580
|
-
const allScreens = screens.all();
|
|
10581
|
-
const allConfigs = cloudConfigs.all();
|
|
10582
|
-
const [menuIsOpen, setMenuIsOpen] = useState(false);
|
|
10583
|
-
const [activeScreen, setActiveView] = useState(null);
|
|
10584
|
-
const [sidebarWidth, setSidebarWidth] = React.useState(defaultWidth);
|
|
10585
|
-
const [formIsPristine, setFormIsPristine] = React.useState(true);
|
|
10586
|
-
const activeScreens = allScreens.filter(
|
|
10587
|
-
(screen) => {
|
|
10588
|
-
var _a2, _b2;
|
|
10589
|
-
return screen.navCategory !== "Account" || ((_b2 = (_a2 = cms.api.tina) == null ? void 0 : _a2.authProvider) == null ? void 0 : _b2.getLoginStrategy()) === "UsernamePassword";
|
|
10590
|
-
}
|
|
10754
|
+
}),
|
|
10755
|
+
[close2, cms, plugin]
|
|
10591
10756
|
);
|
|
10592
|
-
|
|
10593
|
-
|
|
10757
|
+
return /* @__PURE__ */ React.createElement(Modal, { id: "content-creator-modal", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, plugin.name), /* @__PURE__ */ React.createElement(ModalBody, null, /* @__PURE__ */ React.createElement(FormBuilder, { form: { tinaForm: form } }))));
|
|
10758
|
+
};
|
|
10759
|
+
function HiOutlineClipboardList(props) {
|
|
10760
|
+
return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }, "child": [] }] })(props);
|
|
10761
|
+
}
|
|
10762
|
+
const useGetEvents = (cms, cursor, existingEvents) => {
|
|
10763
|
+
const [events, setEvents] = useState([]);
|
|
10764
|
+
const [nextCursor, setNextCursor] = useState(void 0);
|
|
10765
|
+
const [loading, setLoading] = useState(true);
|
|
10766
|
+
const [error, setError] = useState(void 0);
|
|
10594
10767
|
React.useEffect(() => {
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
if (
|
|
10599
|
-
|
|
10768
|
+
const fetchEvents = async () => {
|
|
10769
|
+
var _a, _b, _c, _d, _e;
|
|
10770
|
+
let doFetchEvents = false;
|
|
10771
|
+
if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi)) {
|
|
10772
|
+
doFetchEvents = await ((_e = (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.authProvider) == null ? void 0 : _e.isAuthenticated());
|
|
10600
10773
|
}
|
|
10601
|
-
if (
|
|
10602
|
-
|
|
10774
|
+
if (doFetchEvents) {
|
|
10775
|
+
try {
|
|
10776
|
+
const { events: nextEvents, cursor: nextCursor2 } = await cms.api.tina.fetchEvents(15, cursor);
|
|
10777
|
+
setEvents([...existingEvents, ...nextEvents]);
|
|
10778
|
+
setNextCursor(nextCursor2);
|
|
10779
|
+
} catch (error2) {
|
|
10780
|
+
cms.alerts.error(
|
|
10781
|
+
`[${error2.name}] GetEvents failed: ${error2.message}`,
|
|
10782
|
+
30 * 1e3
|
|
10783
|
+
// 30 seconds
|
|
10784
|
+
);
|
|
10785
|
+
console.error(error2);
|
|
10786
|
+
setEvents(void 0);
|
|
10787
|
+
setError(error2);
|
|
10788
|
+
}
|
|
10789
|
+
setLoading(false);
|
|
10603
10790
|
}
|
|
10604
|
-
}
|
|
10605
|
-
|
|
10791
|
+
};
|
|
10792
|
+
setLoading(true);
|
|
10793
|
+
fetchEvents();
|
|
10794
|
+
}, [cms, cursor]);
|
|
10795
|
+
return { events, cursor: nextCursor, loading, error };
|
|
10796
|
+
};
|
|
10797
|
+
function useSyncStatus(cms) {
|
|
10798
|
+
var _a, _b;
|
|
10799
|
+
const [syncStatus, setSyncStatus] = useState({ state: "loading", message: "Loading..." });
|
|
10606
10800
|
React.useEffect(() => {
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10801
|
+
const interval = setInterval(async () => {
|
|
10802
|
+
var _a2, _b2, _c, _d, _e;
|
|
10803
|
+
let doFetchEvents = false;
|
|
10804
|
+
if (!((_b2 = (_a2 = cms.api) == null ? void 0 : _a2.tina) == null ? void 0 : _b2.isCustomContentApi)) {
|
|
10805
|
+
doFetchEvents = await ((_e = (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.authProvider) == null ? void 0 : _e.isAuthenticated());
|
|
10611
10806
|
}
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
setDisplayState("open");
|
|
10629
|
-
} else {
|
|
10630
|
-
setDisplayState("fullscreen");
|
|
10631
|
-
}
|
|
10632
|
-
};
|
|
10633
|
-
const toggleSidebarOpen = () => {
|
|
10634
|
-
cms.dispatch({ type: "toggle-edit-state" });
|
|
10635
|
-
};
|
|
10636
|
-
const toggleMenu = () => {
|
|
10637
|
-
setMenuIsOpen((menuIsOpen2) => !menuIsOpen2);
|
|
10638
|
-
};
|
|
10639
|
-
React.useEffect(() => {
|
|
10640
|
-
const updateLayout = () => {
|
|
10641
|
-
if (displayState === "fullscreen") {
|
|
10642
|
-
return;
|
|
10807
|
+
if (doFetchEvents) {
|
|
10808
|
+
const { events } = await cms.api.tina.fetchEvents();
|
|
10809
|
+
if (events.length === 0) {
|
|
10810
|
+
setSyncStatus({ state: "success", message: "No Events" });
|
|
10811
|
+
} else {
|
|
10812
|
+
if (events[0].isError) {
|
|
10813
|
+
setSyncStatus({
|
|
10814
|
+
state: "error",
|
|
10815
|
+
message: `Sync Failure ${events[0].message}`
|
|
10816
|
+
});
|
|
10817
|
+
} else {
|
|
10818
|
+
setSyncStatus({ state: "success", message: "Sync Successful" });
|
|
10819
|
+
}
|
|
10820
|
+
}
|
|
10821
|
+
} else {
|
|
10822
|
+
setSyncStatus({ state: "unauthorized", message: "Not Authenticated" });
|
|
10643
10823
|
}
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
window.removeEventListener("resize", updateLayout);
|
|
10655
|
-
};
|
|
10656
|
-
}, [displayState, position, sidebarWidth, resizingSidebar]);
|
|
10657
|
-
const windowWidth = useWindowWidth();
|
|
10658
|
-
const displayNav = renderNav && (sidebarWidth > navBreakpoint && windowWidth > navBreakpoint || displayState === "fullscreen" && windowWidth > navBreakpoint);
|
|
10659
|
-
const renderMobileNav = renderNav && (sidebarWidth < navBreakpoint + 1 || windowWidth < navBreakpoint + 1);
|
|
10824
|
+
}, 5e3);
|
|
10825
|
+
return () => clearInterval(interval);
|
|
10826
|
+
}, [(_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi]);
|
|
10827
|
+
return syncStatus;
|
|
10828
|
+
}
|
|
10829
|
+
const SyncErrorWidget = ({ cms }) => {
|
|
10830
|
+
const syncStatus = useSyncStatus(cms);
|
|
10831
|
+
if (syncStatus.state !== "error") {
|
|
10832
|
+
return null;
|
|
10833
|
+
}
|
|
10660
10834
|
return /* @__PURE__ */ React.createElement(
|
|
10661
|
-
|
|
10835
|
+
"div",
|
|
10662
10836
|
{
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
setSidebarWidth,
|
|
10666
|
-
displayState,
|
|
10667
|
-
setDisplayState,
|
|
10668
|
-
position,
|
|
10669
|
-
toggleFullscreen,
|
|
10670
|
-
toggleSidebarOpen,
|
|
10671
|
-
resizingSidebar,
|
|
10672
|
-
setResizingSidebar,
|
|
10673
|
-
menuIsOpen,
|
|
10674
|
-
setMenuIsOpen,
|
|
10675
|
-
toggleMenu,
|
|
10676
|
-
setActiveView,
|
|
10677
|
-
formIsPristine,
|
|
10678
|
-
setFormIsPristine
|
|
10679
|
-
}
|
|
10837
|
+
title: syncStatus.message,
|
|
10838
|
+
className: "flex-grow-0 flex text-xs items-center"
|
|
10680
10839
|
},
|
|
10681
|
-
/* @__PURE__ */ React.createElement(
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
}
|
|
10699
|
-
}
|
|
10700
|
-
),
|
|
10701
|
-
RenderNavCloud: ({ config }) => /* @__PURE__ */ React.createElement(SidebarCloudLink$1, { config }),
|
|
10702
|
-
RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
10703
|
-
SidebarCollectionLink,
|
|
10704
|
-
{
|
|
10705
|
-
onClick: () => {
|
|
10706
|
-
setMenuIsOpen(false);
|
|
10707
|
-
},
|
|
10708
|
-
collection
|
|
10709
|
-
}
|
|
10710
|
-
),
|
|
10711
|
-
AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
10712
|
-
SidebarCollectionLink,
|
|
10713
|
-
{
|
|
10714
|
-
onClick: () => {
|
|
10715
|
-
setMenuIsOpen(false);
|
|
10716
|
-
},
|
|
10717
|
-
collection,
|
|
10718
|
-
Icon: ImUsers
|
|
10719
|
-
}
|
|
10720
|
-
)
|
|
10721
|
-
}
|
|
10722
|
-
), /* @__PURE__ */ React.createElement(SidebarBody, null, /* @__PURE__ */ React.createElement(
|
|
10723
|
-
SidebarHeader,
|
|
10840
|
+
/* @__PURE__ */ React.createElement(MdSyncProblem, { className: "w-6 h-full ml-2 text-red-500 fill-current" })
|
|
10841
|
+
);
|
|
10842
|
+
};
|
|
10843
|
+
const EventsList = ({ cms }) => {
|
|
10844
|
+
const [cursor, setCursor] = React.useState(void 0);
|
|
10845
|
+
const [existingEvents, setExistingEvents] = React.useState([]);
|
|
10846
|
+
const {
|
|
10847
|
+
events,
|
|
10848
|
+
cursor: nextCursor,
|
|
10849
|
+
loading,
|
|
10850
|
+
error
|
|
10851
|
+
} = useGetEvents(cms, cursor, existingEvents);
|
|
10852
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-4 w-full h-full grow-0" }, events.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "shrink grow-0 overflow-scroll w-full rounded-md shadow ring-1 ring-black ring-opacity-5" }, /* @__PURE__ */ React.createElement("table", { className: "w-full divide-y divide-gray-100" }, events.map((event, index) => {
|
|
10853
|
+
const date = new Date(event.timestamp).toDateString();
|
|
10854
|
+
const time = new Date(event.timestamp).toTimeString();
|
|
10855
|
+
return /* @__PURE__ */ React.createElement("tr", { className: index % 2 === 0 ? "" : "bg-gray-50" }, event.isError ? /* @__PURE__ */ React.createElement(
|
|
10856
|
+
"td",
|
|
10724
10857
|
{
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
ScreenPluginModal,
|
|
10858
|
+
key: `${event.id}_error_icon`,
|
|
10859
|
+
className: "py-3 pl-4 pr-0 w-0"
|
|
10860
|
+
},
|
|
10861
|
+
/* @__PURE__ */ React.createElement(BsExclamationOctagonFill, { className: "text-red-500 fill-current w-5 h-auto" })
|
|
10862
|
+
) : /* @__PURE__ */ React.createElement(
|
|
10863
|
+
"td",
|
|
10732
10864
|
{
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
}
|
|
10736
|
-
|
|
10737
|
-
|
|
10865
|
+
key: `${event.id}_ok_icon`,
|
|
10866
|
+
className: "py-3 pl-4 pr-0 w-0"
|
|
10867
|
+
},
|
|
10868
|
+
/* @__PURE__ */ React.createElement(BsCheckCircleFill, { className: "text-green-500 fill-current w-5 h-auto" })
|
|
10869
|
+
), /* @__PURE__ */ React.createElement(
|
|
10870
|
+
"td",
|
|
10738
10871
|
{
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
enterTo: "opacity-100 translate-x-0",
|
|
10742
|
-
leave: "transform transition-all ease-in duration-200",
|
|
10743
|
-
leaveFrom: "opacity-100 translate-x-0",
|
|
10744
|
-
leaveTo: "opacity-0 -translate-x-full"
|
|
10872
|
+
key: `${event.id}_msg`,
|
|
10873
|
+
className: "whitespace-nowrap p-3 text-base text-gray-500"
|
|
10745
10874
|
},
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
{
|
|
10749
|
-
isLocalMode: (_f = (_e = cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode,
|
|
10750
|
-
className: "rounded-r-md",
|
|
10751
|
-
showCollections: isTinaAdminEnabled,
|
|
10752
|
-
collectionsInfo,
|
|
10753
|
-
screens: activeScreens,
|
|
10754
|
-
cloudConfigs: allConfigs,
|
|
10755
|
-
contentCreators,
|
|
10756
|
-
sidebarWidth,
|
|
10757
|
-
RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(
|
|
10758
|
-
SidebarSiteLink,
|
|
10759
|
-
{
|
|
10760
|
-
view,
|
|
10761
|
-
onClick: () => {
|
|
10762
|
-
setActiveView(view);
|
|
10763
|
-
setMenuIsOpen(false);
|
|
10764
|
-
}
|
|
10765
|
-
}
|
|
10766
|
-
),
|
|
10767
|
-
RenderNavCloud: ({ config }) => /* @__PURE__ */ React.createElement(SidebarCloudLink$1, { config }),
|
|
10768
|
-
RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
10769
|
-
SidebarCollectionLink,
|
|
10770
|
-
{
|
|
10771
|
-
onClick: () => {
|
|
10772
|
-
setMenuIsOpen(false);
|
|
10773
|
-
},
|
|
10774
|
-
collection
|
|
10775
|
-
}
|
|
10776
|
-
),
|
|
10777
|
-
AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
10778
|
-
SidebarCollectionLink,
|
|
10779
|
-
{
|
|
10780
|
-
onClick: () => {
|
|
10781
|
-
setMenuIsOpen(false);
|
|
10782
|
-
},
|
|
10783
|
-
collection,
|
|
10784
|
-
Icon: ImUsers
|
|
10785
|
-
}
|
|
10786
|
-
)
|
|
10787
|
-
},
|
|
10788
|
-
/* @__PURE__ */ React.createElement("div", { className: "absolute top-8 right-0 transform translate-x-full overflow-hidden" }, /* @__PURE__ */ React.createElement(
|
|
10789
|
-
Button$1,
|
|
10790
|
-
{
|
|
10791
|
-
rounded: "right",
|
|
10792
|
-
variant: "secondary",
|
|
10793
|
-
onClick: () => {
|
|
10794
|
-
setMenuIsOpen(false);
|
|
10795
|
-
},
|
|
10796
|
-
className: "transition-opacity duration-150 ease-out"
|
|
10797
|
-
},
|
|
10798
|
-
/* @__PURE__ */ React.createElement(IoMdClose, { className: "h-5 w-auto text-blue-500" })
|
|
10799
|
-
))
|
|
10800
|
-
))
|
|
10875
|
+
event.message,
|
|
10876
|
+
event.isError && /* @__PURE__ */ React.createElement("div", { className: "w-full text-gray-300 text-xs mt-0.5" }, event.id)
|
|
10801
10877
|
), /* @__PURE__ */ React.createElement(
|
|
10802
|
-
|
|
10878
|
+
"td",
|
|
10803
10879
|
{
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
enterTo: "opacity-80",
|
|
10807
|
-
entered: "opacity-80",
|
|
10808
|
-
leave: "ease-in duration-200",
|
|
10809
|
-
leaveFrom: "opacity-80",
|
|
10810
|
-
leaveTo: "opacity-0"
|
|
10880
|
+
key: `${event.id}_ts`,
|
|
10881
|
+
className: "whitespace-nowrap py-3 pl-3 pr-4 text-sm text-gray-500"
|
|
10811
10882
|
},
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
setMenuIsOpen(false);
|
|
10817
|
-
},
|
|
10818
|
-
className: "fixed z-menu inset-0 bg-gradient-to-br from-gray-800 via-gray-900 to-black"
|
|
10819
|
-
}
|
|
10820
|
-
)
|
|
10821
|
-
)))
|
|
10822
|
-
);
|
|
10823
|
-
};
|
|
10824
|
-
const updateBodyDisplacement = ({
|
|
10825
|
-
position = "overlay",
|
|
10826
|
-
displayState,
|
|
10827
|
-
sidebarWidth,
|
|
10828
|
-
resizingSidebar
|
|
10829
|
-
}) => {
|
|
10830
|
-
const body = document.getElementsByTagName("body")[0];
|
|
10831
|
-
const windowWidth = window.innerWidth;
|
|
10832
|
-
if (position === "displace") {
|
|
10833
|
-
body.style.transition = resizingSidebar ? "" : displayState === "fullscreen" ? "padding 0ms 150ms" : displayState === "closed" ? "padding 0ms 0ms" : "padding 0ms 300ms";
|
|
10834
|
-
if (displayState === "open") {
|
|
10835
|
-
const bodyDisplacement = Math.min(
|
|
10836
|
-
sidebarWidth,
|
|
10837
|
-
windowWidth - minPreviewWidth
|
|
10838
|
-
);
|
|
10839
|
-
body.style.paddingLeft = `${bodyDisplacement}px`;
|
|
10840
|
-
} else {
|
|
10841
|
-
body.style.paddingLeft = "0";
|
|
10842
|
-
}
|
|
10843
|
-
} else {
|
|
10844
|
-
body.style.transition = "";
|
|
10845
|
-
body.style.paddingLeft = "0";
|
|
10846
|
-
}
|
|
10847
|
-
};
|
|
10848
|
-
const SidebarHeader = ({
|
|
10849
|
-
branchingEnabled,
|
|
10850
|
-
renderNav,
|
|
10851
|
-
displayNav,
|
|
10852
|
-
isLocalMode
|
|
10853
|
-
}) => {
|
|
10854
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
10855
|
-
const { toggleFullscreen, displayState, setMenuIsOpen, toggleSidebarOpen } = React.useContext(SidebarContext);
|
|
10856
|
-
const displayMenuButton = renderNav && !displayNav;
|
|
10857
|
-
const cms = useCMS$1();
|
|
10858
|
-
const previewFunction = (_f = (_e = (_d = (_c = (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.schema) == null ? void 0 : _c.config) == null ? void 0 : _d.config) == null ? void 0 : _e.ui) == null ? void 0 : _f.previewUrl;
|
|
10859
|
-
const branch = (_h = (_g = cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.branch;
|
|
10860
|
-
const previewUrl = typeof previewFunction === "function" ? (_i = previewFunction({ branch })) == null ? void 0 : _i.url : null;
|
|
10861
|
-
return /* @__PURE__ */ React.createElement("div", { className: "flex-grow-0 w-full overflow-visible z-20" }, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), !isLocalMode && /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", { className: "mt-4 -mb-14 w-full flex gap-3 items-center justify-between pointer-events-none" }, displayMenuButton && /* @__PURE__ */ React.createElement(
|
|
10883
|
+
date,
|
|
10884
|
+
/* @__PURE__ */ React.createElement("span", { className: "w-full block text-gray-300 text-xs mt-0.5" }, time)
|
|
10885
|
+
));
|
|
10886
|
+
}).flat())), loading && /* @__PURE__ */ React.createElement("div", { className: "text-sm text-gray-400 text-center" }, "Loading..."), error && /* @__PURE__ */ React.createElement("div", null, "Error: ", error.message), /* @__PURE__ */ React.createElement("div", { className: "text-center flex-1" }, /* @__PURE__ */ React.createElement(
|
|
10862
10887
|
Button$1,
|
|
10863
10888
|
{
|
|
10864
|
-
rounded: "right",
|
|
10865
|
-
variant: "white",
|
|
10866
10889
|
onClick: () => {
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10890
|
+
setExistingEvents(events);
|
|
10891
|
+
setCursor(nextCursor);
|
|
10892
|
+
}
|
|
10870
10893
|
},
|
|
10871
|
-
|
|
10872
|
-
)
|
|
10894
|
+
"Load More Events"
|
|
10895
|
+
)));
|
|
10896
|
+
};
|
|
10897
|
+
const SyncStatusModal = ({ closeEventsModal, cms }) => /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(FullscreenModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: closeEventsModal }, "Event Log"), /* @__PURE__ */ React.createElement(ModalBody, { className: "flex h-full flex-col", padded: true }, /* @__PURE__ */ React.createElement(EventsList, { cms }))));
|
|
10898
|
+
const SyncStatus = ({ cms, setEventsOpen }) => {
|
|
10899
|
+
var _a, _b;
|
|
10900
|
+
const syncStatus = useSyncStatus(cms);
|
|
10901
|
+
function openEventsModal() {
|
|
10902
|
+
setEventsOpen(true);
|
|
10903
|
+
}
|
|
10904
|
+
if ((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi) {
|
|
10905
|
+
return null;
|
|
10906
|
+
}
|
|
10907
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
10873
10908
|
"button",
|
|
10874
10909
|
{
|
|
10875
|
-
className:
|
|
10876
|
-
onClick:
|
|
10877
|
-
|
|
10910
|
+
className: `text-lg px-4 py-2 first:pt-3 last:pb-3 tracking-wide whitespace-nowrap flex items-center opacity-80 text-gray-600 hover:text-blue-400 hover:bg-gray-50 hover:opacity-100`,
|
|
10911
|
+
onClick: openEventsModal
|
|
10912
|
+
},
|
|
10913
|
+
syncStatus.state !== "error" ? /* @__PURE__ */ React.createElement(HiOutlineClipboardList, { className: "w-6 h-auto mr-2 text-blue-400" }) : /* @__PURE__ */ React.createElement(MdSyncProblem, { className: "w-6 h-auto mr-2 text-red-400" }),
|
|
10914
|
+
" ",
|
|
10915
|
+
"Event Log"
|
|
10916
|
+
));
|
|
10917
|
+
};
|
|
10918
|
+
const version = "2.7.6";
|
|
10919
|
+
const Nav = ({
|
|
10920
|
+
isLocalMode,
|
|
10921
|
+
className = "",
|
|
10922
|
+
children,
|
|
10923
|
+
showCollections,
|
|
10924
|
+
collectionsInfo,
|
|
10925
|
+
screens,
|
|
10926
|
+
cloudConfigs,
|
|
10927
|
+
contentCreators,
|
|
10928
|
+
sidebarWidth,
|
|
10929
|
+
RenderNavSite,
|
|
10930
|
+
RenderNavCloud,
|
|
10931
|
+
RenderNavCollection,
|
|
10932
|
+
AuthRenderNavCollection,
|
|
10933
|
+
...props
|
|
10934
|
+
}) => {
|
|
10935
|
+
const cms = useCMS$1();
|
|
10936
|
+
const [eventsOpen, setEventsOpen] = React.useState(false);
|
|
10937
|
+
const { contentCollections, authCollection } = collectionsInfo.collections.reduce(
|
|
10938
|
+
(acc, collection) => {
|
|
10939
|
+
if (collection.isAuthCollection) {
|
|
10940
|
+
acc.authCollection = collection;
|
|
10941
|
+
} else {
|
|
10942
|
+
acc.contentCollections.push(collection);
|
|
10878
10943
|
}
|
|
10944
|
+
return acc;
|
|
10879
10945
|
},
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10946
|
+
{
|
|
10947
|
+
contentCollections: []
|
|
10948
|
+
}
|
|
10949
|
+
);
|
|
10950
|
+
function closeEventsModal() {
|
|
10951
|
+
setEventsOpen(false);
|
|
10952
|
+
}
|
|
10953
|
+
const WrappedSyncStatus = React.forwardRef(
|
|
10954
|
+
(props2, ref) => /* @__PURE__ */ React.createElement(SyncStatus, { ...props2 })
|
|
10955
|
+
);
|
|
10956
|
+
const screenCategories = screens.reduce(
|
|
10957
|
+
(acc, screen) => {
|
|
10958
|
+
const category = screen.navCategory || "Site";
|
|
10959
|
+
acc[category] = acc[category] || [];
|
|
10960
|
+
acc[category].push(screen);
|
|
10961
|
+
return acc;
|
|
10962
|
+
},
|
|
10963
|
+
{ Site: [] }
|
|
10964
|
+
);
|
|
10965
|
+
return /* @__PURE__ */ React.createElement(
|
|
10883
10966
|
"div",
|
|
10884
10967
|
{
|
|
10885
|
-
className:
|
|
10968
|
+
className: `relative z-30 flex flex-col bg-white border-r border-gray-200 w-96 h-full ${className}`,
|
|
10969
|
+
style: { maxWidth: `${sidebarWidth}px` },
|
|
10970
|
+
...props
|
|
10886
10971
|
},
|
|
10887
|
-
/* @__PURE__ */ React.createElement(
|
|
10888
|
-
|
|
10972
|
+
/* @__PURE__ */ React.createElement("div", { className: "border-b border-gray-200" }, /* @__PURE__ */ React.createElement(Menu, { as: "div", className: "relative block" }, ({ open: open2 }) => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
|
|
10973
|
+
MenuButton,
|
|
10889
10974
|
{
|
|
10890
|
-
|
|
10891
|
-
variant: "white",
|
|
10892
|
-
onClick: toggleSidebarOpen,
|
|
10893
|
-
"aria-label": "closes cms sidebar",
|
|
10894
|
-
className: "-mr-px"
|
|
10975
|
+
className: `group w-full px-6 py-3 gap-2 flex justify-between items-center transition-colors duration-150 ease-out ${open2 ? "bg-gray-50" : "bg-transparent"}`
|
|
10895
10976
|
},
|
|
10896
|
-
/* @__PURE__ */ React.createElement(
|
|
10897
|
-
),
|
|
10898
|
-
/* @__PURE__ */ React.createElement(Button$1, { rounded: "custom", variant: "white", onClick: toggleFullscreen }, displayState === "fullscreen" ? (
|
|
10899
|
-
// BiCollapseAlt
|
|
10900
|
-
/* @__PURE__ */ React.createElement(
|
|
10977
|
+
/* @__PURE__ */ React.createElement("span", { className: "text-left inline-flex items-center text-xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out" }, /* @__PURE__ */ React.createElement(
|
|
10901
10978
|
"svg",
|
|
10902
10979
|
{
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
viewBox: "0 0 24 24",
|
|
10908
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
10980
|
+
viewBox: "0 0 32 32",
|
|
10981
|
+
fill: "#EC4815",
|
|
10982
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
10983
|
+
className: "w-10 h-auto -ml-1"
|
|
10909
10984
|
},
|
|
10910
|
-
/* @__PURE__ */ React.createElement("path", { d: "
|
|
10985
|
+
/* @__PURE__ */ React.createElement("path", { d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z" }),
|
|
10986
|
+
/* @__PURE__ */ React.createElement("path", { d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z" })
|
|
10987
|
+
), /* @__PURE__ */ React.createElement("span", null, "Tina")),
|
|
10988
|
+
/* @__PURE__ */ React.createElement(SyncErrorWidget, { cms }),
|
|
10989
|
+
/* @__PURE__ */ React.createElement(
|
|
10990
|
+
FiMoreVertical,
|
|
10991
|
+
{
|
|
10992
|
+
className: `flex-0 w-6 h-full inline-block group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open2 ? "opacity-100 text-blue-400" : "text-gray-400 opacity-50 hover:opacity-70"}`
|
|
10993
|
+
}
|
|
10911
10994
|
)
|
|
10912
|
-
)
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
className: "
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10995
|
+
), /* @__PURE__ */ React.createElement("div", { className: "transform translate-y-full absolute bottom-3 right-5 z-50" }, /* @__PURE__ */ React.createElement(
|
|
10996
|
+
Transition,
|
|
10997
|
+
{
|
|
10998
|
+
enter: "transition duration-150 ease-out",
|
|
10999
|
+
enterFrom: "transform opacity-0 -translate-y-2",
|
|
11000
|
+
enterTo: "transform opacity-100 translate-y-0",
|
|
11001
|
+
leave: "transition duration-75 ease-in",
|
|
11002
|
+
leaveFrom: "transform opacity-100 translate-y-0",
|
|
11003
|
+
leaveTo: "transform opacity-0 -translate-y-2"
|
|
11004
|
+
},
|
|
11005
|
+
/* @__PURE__ */ React.createElement(MenuItems, { className: "bg-white border border-gray-150 rounded-lg shadow-lg flex flex-col items-stretch overflow-hidden" }, /* @__PURE__ */ React.createElement(MenuItem, null, /* @__PURE__ */ React.createElement(
|
|
11006
|
+
"button",
|
|
11007
|
+
{
|
|
11008
|
+
className: `text-lg px-4 py-2 first:pt-3 last:pb-3 tracking-wide whitespace-nowrap flex items-center opacity-80 text-gray-600 hover:text-blue-400 hover:bg-gray-50 hover:opacity-100`,
|
|
11009
|
+
onClick: async () => {
|
|
11010
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
11011
|
+
updateBodyDisplacement({
|
|
11012
|
+
displayState: "closed",
|
|
11013
|
+
sidebarWidth: null,
|
|
11014
|
+
resizingSidebar: false
|
|
11015
|
+
});
|
|
11016
|
+
try {
|
|
11017
|
+
if ((_c = (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.authProvider) == null ? void 0 : _c.logout) {
|
|
11018
|
+
await ((_d = cms.api.tina) == null ? void 0 : _d.authProvider.logout());
|
|
11019
|
+
if ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout) {
|
|
11020
|
+
await ((_h = (_g = cms == null ? void 0 : cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.onLogout());
|
|
11021
|
+
await new Promise(
|
|
11022
|
+
(resolve) => setTimeout(resolve, 500)
|
|
11023
|
+
);
|
|
11024
|
+
}
|
|
11025
|
+
window.location.href = new URL(
|
|
11026
|
+
window.location.href
|
|
11027
|
+
).pathname;
|
|
11028
|
+
}
|
|
11029
|
+
} catch (e) {
|
|
11030
|
+
cms.alerts.error(`Error logging out: ${e}`);
|
|
11031
|
+
console.error("Unexpected error calling logout");
|
|
11032
|
+
console.error(e);
|
|
11033
|
+
}
|
|
11034
|
+
}
|
|
11035
|
+
},
|
|
11036
|
+
/* @__PURE__ */ React.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
|
|
11037
|
+
" Log Out"
|
|
11038
|
+
)), /* @__PURE__ */ React.createElement(MenuItem, null, /* @__PURE__ */ React.createElement(
|
|
11039
|
+
WrappedSyncStatus,
|
|
11040
|
+
{
|
|
11041
|
+
cms,
|
|
11042
|
+
setEventsOpen
|
|
11043
|
+
}
|
|
11044
|
+
)))
|
|
11045
|
+
))))),
|
|
11046
|
+
eventsOpen && /* @__PURE__ */ React.createElement(SyncStatusModal, { cms, closeEventsModal }),
|
|
11047
|
+
children,
|
|
11048
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex flex-col px-6 flex-1 overflow-auto" }, showCollections && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", { className: "flex space-x-1 justify-items-start uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, /* @__PURE__ */ React.createElement("span", null, "Collections"), isLocalMode && /* @__PURE__ */ React.createElement("span", { className: "flex items-center" }, /* @__PURE__ */ React.createElement(
|
|
10934
11049
|
"a",
|
|
10935
11050
|
{
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
href: config.link.href
|
|
11051
|
+
href: "https://tina.io/docs/schema/#defining-collections",
|
|
11052
|
+
target: "_blank"
|
|
10939
11053
|
},
|
|
10940
|
-
|
|
10941
|
-
))
|
|
10942
|
-
|
|
10943
|
-
|
|
11054
|
+
/* @__PURE__ */ React.createElement(FiInfo, null)
|
|
11055
|
+
))), /* @__PURE__ */ React.createElement(
|
|
11056
|
+
CollectionsList,
|
|
11057
|
+
{
|
|
11058
|
+
RenderNavCollection,
|
|
11059
|
+
collections: contentCollections
|
|
11060
|
+
}
|
|
11061
|
+
)), (screenCategories.Site.length > 0 || contentCreators.length) > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Site"), /* @__PURE__ */ React.createElement("ul", { className: "flex flex-col gap-4" }, screenCategories.Site.map((view) => {
|
|
11062
|
+
return /* @__PURE__ */ React.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React.createElement(RenderNavSite, { view }));
|
|
11063
|
+
}), contentCreators.map((plugin, idx) => {
|
|
11064
|
+
return /* @__PURE__ */ React.createElement(CreateContentNavItem, { key: `plugin-${idx}`, plugin });
|
|
11065
|
+
}), authCollection && /* @__PURE__ */ React.createElement(
|
|
11066
|
+
CollectionsList,
|
|
11067
|
+
{
|
|
11068
|
+
RenderNavCollection: AuthRenderNavCollection,
|
|
11069
|
+
collections: [authCollection]
|
|
11070
|
+
}
|
|
11071
|
+
))), Object.entries(screenCategories).map(([category, screens2]) => {
|
|
11072
|
+
if (category !== "Site") {
|
|
11073
|
+
return /* @__PURE__ */ React.createElement("div", { key: category }, /* @__PURE__ */ React.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, category), /* @__PURE__ */ React.createElement("ul", { className: "flex flex-col gap-4" }, screens2.map((view) => {
|
|
11074
|
+
return /* @__PURE__ */ React.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React.createElement(RenderNavSite, { view }));
|
|
11075
|
+
})));
|
|
11076
|
+
}
|
|
11077
|
+
}), !!(cloudConfigs == null ? void 0 : cloudConfigs.length) && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Cloud"), /* @__PURE__ */ React.createElement("ul", { className: "flex flex-col gap-4" }, cloudConfigs.map((config) => {
|
|
11078
|
+
return /* @__PURE__ */ React.createElement("li", { key: `nav-site-${config.name}` }, /* @__PURE__ */ React.createElement(RenderNavCloud, { config }));
|
|
11079
|
+
}))), /* @__PURE__ */ React.createElement("div", { className: "grow" }), /* @__PURE__ */ React.createElement("span", { className: "font-sans font-light text-xs mb-3 mt-8 text-gray-500" }, "v", version))
|
|
11080
|
+
);
|
|
10944
11081
|
};
|
|
10945
|
-
const
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
onClick
|
|
11082
|
+
const CollectionsList = ({
|
|
11083
|
+
collections,
|
|
11084
|
+
RenderNavCollection
|
|
10949
11085
|
}) => {
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
11086
|
+
if (collections.length === 0) {
|
|
11087
|
+
return /* @__PURE__ */ React.createElement("div", null, "No collections found");
|
|
11088
|
+
}
|
|
11089
|
+
return /* @__PURE__ */ React.createElement("ul", { className: "flex flex-col gap-4" }, collections.map((collection) => {
|
|
11090
|
+
return /* @__PURE__ */ React.createElement("li", { key: `nav-collection-${collection.name}` }, /* @__PURE__ */ React.createElement(RenderNavCollection, { collection }));
|
|
11091
|
+
}));
|
|
11092
|
+
};
|
|
11093
|
+
const CreateContentNavItem = ({ plugin }) => {
|
|
11094
|
+
const [open2, setOpen] = React.useState(false);
|
|
11095
|
+
return /* @__PURE__ */ React.createElement("li", { key: plugin.name }, /* @__PURE__ */ React.createElement(
|
|
11096
|
+
"button",
|
|
10954
11097
|
{
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
11098
|
+
className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100",
|
|
11099
|
+
onClick: () => {
|
|
11100
|
+
setOpen(true);
|
|
11101
|
+
}
|
|
10958
11102
|
},
|
|
10959
|
-
/* @__PURE__ */ React.createElement(
|
|
11103
|
+
/* @__PURE__ */ React.createElement(VscNewFile, { className: "mr-3 h-6 opacity-80 w-auto" }),
|
|
10960
11104
|
" ",
|
|
10961
|
-
|
|
10962
|
-
);
|
|
11105
|
+
plugin.name
|
|
11106
|
+
), open2 && /* @__PURE__ */ React.createElement(FormModal, { plugin, close: () => setOpen(false) }));
|
|
10963
11107
|
};
|
|
10964
|
-
const
|
|
10965
|
-
const {
|
|
11108
|
+
const ResizeHandle = () => {
|
|
11109
|
+
const {
|
|
11110
|
+
resizingSidebar,
|
|
11111
|
+
setResizingSidebar,
|
|
11112
|
+
fullscreen,
|
|
11113
|
+
setSidebarWidth,
|
|
11114
|
+
displayState
|
|
11115
|
+
} = React.useContext(SidebarContext);
|
|
11116
|
+
React.useEffect(() => {
|
|
11117
|
+
const handleMouseUp = () => setResizingSidebar(false);
|
|
11118
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
11119
|
+
return () => {
|
|
11120
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
11121
|
+
};
|
|
11122
|
+
}, []);
|
|
11123
|
+
React.useEffect(() => {
|
|
11124
|
+
const handleMouseMove = (e) => {
|
|
11125
|
+
setSidebarWidth((sidebarWidth) => {
|
|
11126
|
+
const newWidth = sidebarWidth + e.movementX;
|
|
11127
|
+
const maxWidth = window.innerWidth - 8;
|
|
11128
|
+
if (newWidth < minSidebarWidth) {
|
|
11129
|
+
return minSidebarWidth;
|
|
11130
|
+
} else if (newWidth > maxWidth) {
|
|
11131
|
+
return maxWidth;
|
|
11132
|
+
} else {
|
|
11133
|
+
return newWidth;
|
|
11134
|
+
}
|
|
11135
|
+
});
|
|
11136
|
+
};
|
|
11137
|
+
if (resizingSidebar) {
|
|
11138
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
11139
|
+
document.body.classList.add("select-none");
|
|
11140
|
+
}
|
|
11141
|
+
return () => {
|
|
11142
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
11143
|
+
document.body.classList.remove("select-none");
|
|
11144
|
+
};
|
|
11145
|
+
}, [resizingSidebar]);
|
|
11146
|
+
const handleresizingSidebar = () => setResizingSidebar(true);
|
|
11147
|
+
if (fullscreen) {
|
|
11148
|
+
return null;
|
|
11149
|
+
}
|
|
10966
11150
|
return /* @__PURE__ */ React.createElement(
|
|
10967
|
-
|
|
11151
|
+
"div",
|
|
10968
11152
|
{
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
onClick: toggleSidebarOpen,
|
|
10973
|
-
className: `z-chrome absolute top-6 right-0 translate-x-full text-sm h-10 pl-3 pr-4 transition-all duration-300 ${displayState !== "closed" ? "opacity-0 ease-in pointer-events-none" : "ease-out pointer-events-auto"}`,
|
|
10974
|
-
"aria-label": "opens cms sidebar"
|
|
11153
|
+
onMouseDown: handleresizingSidebar,
|
|
11154
|
+
className: `z-100 absolute top-1/2 right-px w-2 h-32 bg-white rounded-r-md border border-gray-150 shadow-sm hover:shadow-md origin-left transition-all duration-150 ease-out transform translate-x-full -translate-y-1/2 group hover:bg-gray-50 ${displayState !== "closed" ? `opacity-100` : `opacity-0`} ${resizingSidebar ? `scale-110` : `scale-90 hover:scale-100`}`,
|
|
11155
|
+
style: { cursor: "grab" }
|
|
10975
11156
|
},
|
|
10976
|
-
/* @__PURE__ */ React.createElement(
|
|
11157
|
+
/* @__PURE__ */ React.createElement("span", { className: "absolute top-1/2 left-1/2 h-4/6 w-px bg-gray-200 transform -translate-y-1/2 -translate-x-1/2 opacity-30 transition-opacity duration-150 ease-out group-hover:opacity-100" })
|
|
10977
11158
|
);
|
|
10978
11159
|
};
|
|
10979
|
-
const
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
className: `relative h-dvh transform flex ${displayState !== "closed" ? "" : "-translate-x-full"} ${resizingSidebar ? "transition-none" : displayState === "closed" ? "transition-all duration-300 ease-in" : displayState === "fullscreen" ? "transition-all duration-150 ease-out" : "transition-all duration-300 ease-out"}`,
|
|
10990
|
-
style: {
|
|
10991
|
-
width: displayState === "fullscreen" ? "100vw" : `${sidebarWidth}px`,
|
|
10992
|
-
maxWidth: displayState === "fullscreen" ? "100vw" : "calc(100vw - 8px)",
|
|
10993
|
-
minWidth: "360px"
|
|
10994
|
-
}
|
|
10995
|
-
},
|
|
10996
|
-
children
|
|
10997
|
-
)
|
|
11160
|
+
const Item = ({
|
|
11161
|
+
item,
|
|
11162
|
+
depth,
|
|
11163
|
+
setActiveFormId
|
|
11164
|
+
}) => {
|
|
11165
|
+
const cms = useCMS();
|
|
11166
|
+
const depths = ["pl-6", "pl-10", "pl-14"];
|
|
11167
|
+
const form = React.useMemo(
|
|
11168
|
+
() => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
|
|
11169
|
+
[item.formId]
|
|
10998
11170
|
);
|
|
10999
|
-
};
|
|
11000
|
-
const SidebarBody = ({ children }) => {
|
|
11001
11171
|
return /* @__PURE__ */ React.createElement(
|
|
11002
|
-
"
|
|
11172
|
+
"button",
|
|
11003
11173
|
{
|
|
11004
|
-
|
|
11174
|
+
type: "button",
|
|
11175
|
+
key: item.path,
|
|
11176
|
+
onClick: () => setActiveFormId(item.formId),
|
|
11177
|
+
className: `${depths[depth] || "pl-12"} pr-6 py-3 w-full h-full bg-transparent border-none text-lg text-gray-700 group hover:bg-gray-50 transition-all ease-out duration-150 flex items-center justify-between gap-2`
|
|
11005
11178
|
},
|
|
11006
|
-
|
|
11179
|
+
/* @__PURE__ */ React.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
|
|
11180
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex-1 flex flex-col gap-0.5 items-start" }, /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 font-sans text-xs font-semibold text-gray-700 whitespace-normal" }, form.tinaForm.label), /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 text-base truncate leading-tight text-gray-600" }, form.tinaForm.id))
|
|
11007
11181
|
);
|
|
11008
11182
|
};
|
|
11009
|
-
const
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
}
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
Component: createPlaceholder(
|
|
11020
|
-
"HTML"
|
|
11021
|
-
)
|
|
11022
|
-
};
|
|
11023
|
-
function createPlaceholder(name, _pr) {
|
|
11024
|
-
return (props) => {
|
|
11025
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
11026
|
-
FieldMeta,
|
|
11027
|
-
{
|
|
11028
|
-
name: props.input.name,
|
|
11029
|
-
label: `${name} Field not Registered`,
|
|
11030
|
-
tinaForm: props.tinaForm
|
|
11031
|
-
},
|
|
11032
|
-
/* @__PURE__ */ React__default.createElement("p", { className: "whitespace-normal text-[15px] mt-2" }, "The ", name, " field is not registered. Some built-in field types are not bundled by default in an effort to control bundle size. Consult the Tina docs to learn how to use this field type."),
|
|
11033
|
-
/* @__PURE__ */ React__default.createElement("p", { className: "whitespace-normal text-[15px] mt-2" }, /* @__PURE__ */ React__default.createElement(
|
|
11034
|
-
"a",
|
|
11183
|
+
const FormListItem = ({
|
|
11184
|
+
item,
|
|
11185
|
+
depth,
|
|
11186
|
+
setActiveFormId
|
|
11187
|
+
}) => {
|
|
11188
|
+
var _a;
|
|
11189
|
+
return /* @__PURE__ */ React.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
|
|
11190
|
+
if (subItem.type === "document") {
|
|
11191
|
+
return /* @__PURE__ */ React.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React.createElement(
|
|
11192
|
+
Item,
|
|
11035
11193
|
{
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
const pattern = new RegExp("(?<prevDir>.*)/");
|
|
11049
|
-
return (_b = (_a = path.match(pattern)) == null ? void 0 : _a.groups) == null ? void 0 : _b.prevDir;
|
|
11050
|
-
}
|
|
11051
|
-
const BreadcrumbButton = ({ className = "", ...props }) => /* @__PURE__ */ React__default.createElement(
|
|
11052
|
-
"button",
|
|
11053
|
-
{
|
|
11054
|
-
className: "capitalize transition-colors duration-150 border-0 bg-transparent hover:text-blue-500 " + className,
|
|
11055
|
-
...props
|
|
11056
|
-
}
|
|
11057
|
-
);
|
|
11058
|
-
function Breadcrumb$1({ directory = "", setDirectory }) {
|
|
11059
|
-
directory = directory.replace(/^\/|\/$/g, "");
|
|
11060
|
-
let prevDir = dirname(directory) || "";
|
|
11061
|
-
if (prevDir === ".") {
|
|
11062
|
-
prevDir = "";
|
|
11063
|
-
}
|
|
11064
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex items-center text-[16px] text-gray-300" }, directory !== "" && /* @__PURE__ */ React__default.createElement(
|
|
11065
|
-
IconButton,
|
|
11194
|
+
setActiveFormId,
|
|
11195
|
+
depth: depth + 1,
|
|
11196
|
+
item: subItem
|
|
11197
|
+
}
|
|
11198
|
+
));
|
|
11199
|
+
}
|
|
11200
|
+
})));
|
|
11201
|
+
};
|
|
11202
|
+
const FormLists = (props) => {
|
|
11203
|
+
const cms = useCMS();
|
|
11204
|
+
return /* @__PURE__ */ React.createElement(
|
|
11205
|
+
Transition,
|
|
11066
11206
|
{
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11207
|
+
appear: true,
|
|
11208
|
+
show: true,
|
|
11209
|
+
as: "div",
|
|
11210
|
+
enter: "transition-all ease-out duration-150",
|
|
11211
|
+
enterFrom: "opacity-0 -translate-x-1/2",
|
|
11212
|
+
enterTo: "opacity-100",
|
|
11213
|
+
leave: "transition-all ease-out duration-150",
|
|
11214
|
+
leaveFrom: "opacity-100",
|
|
11215
|
+
leaveTo: "opacity-0 -translate-x-1/2"
|
|
11070
11216
|
},
|
|
11071
|
-
/* @__PURE__ */
|
|
11072
|
-
|
|
11217
|
+
cms.state.formLists.map((formList, index) => /* @__PURE__ */ React.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React.createElement(
|
|
11218
|
+
FormList,
|
|
11073
11219
|
{
|
|
11074
|
-
|
|
11220
|
+
isEditing: props.isEditing,
|
|
11221
|
+
setActiveFormId: (id) => {
|
|
11222
|
+
cms.dispatch({ type: "forms:set-active-form-id", value: id });
|
|
11223
|
+
},
|
|
11224
|
+
formList
|
|
11075
11225
|
}
|
|
11076
|
-
)
|
|
11077
|
-
)
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
const
|
|
11086
|
-
|
|
11087
|
-
|
|
11088
|
-
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11226
|
+
)))
|
|
11227
|
+
);
|
|
11228
|
+
};
|
|
11229
|
+
const FormList = (props) => {
|
|
11230
|
+
const cms = useCMS();
|
|
11231
|
+
const listItems = React.useMemo(() => {
|
|
11232
|
+
var _a;
|
|
11233
|
+
const orderedListItems = [];
|
|
11234
|
+
const globalItems = [];
|
|
11235
|
+
const topItems = [];
|
|
11236
|
+
props.formList.items.forEach((item) => {
|
|
11237
|
+
if (item.type === "document") {
|
|
11238
|
+
const form = cms.state.forms.find(
|
|
11239
|
+
({ tinaForm }) => tinaForm.id === item.formId
|
|
11240
|
+
);
|
|
11241
|
+
if (form.tinaForm.global) {
|
|
11242
|
+
globalItems.push(item);
|
|
11243
|
+
} else {
|
|
11244
|
+
orderedListItems.push(item);
|
|
11093
11245
|
}
|
|
11094
|
-
}
|
|
11095
|
-
|
|
11246
|
+
} else {
|
|
11247
|
+
orderedListItems.push(item);
|
|
11248
|
+
}
|
|
11249
|
+
});
|
|
11250
|
+
if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
|
|
11251
|
+
topItems.push({ type: "list", label: "Documents" });
|
|
11252
|
+
}
|
|
11253
|
+
let extra = [];
|
|
11254
|
+
if (globalItems.length) {
|
|
11255
|
+
extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
|
|
11256
|
+
}
|
|
11257
|
+
return [...topItems, ...orderedListItems, ...extra];
|
|
11258
|
+
}, [JSON.stringify(props.formList.items)]);
|
|
11259
|
+
return /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
|
|
11260
|
+
if (item.type === "list") {
|
|
11261
|
+
return /* @__PURE__ */ React.createElement(
|
|
11262
|
+
"div",
|
|
11263
|
+
{
|
|
11264
|
+
key: item.label,
|
|
11265
|
+
className: `relative group text-left w-full bg-white shadow-sm
|
|
11266
|
+
border-gray-100 px-6 -mt-px pb-3 ${index > 0 ? "pt-6 bg-gradient-to-b from-gray-50 via-white to-white" : "pt-3"}`
|
|
11267
|
+
},
|
|
11268
|
+
/* @__PURE__ */ React.createElement(
|
|
11269
|
+
"span",
|
|
11270
|
+
{
|
|
11271
|
+
className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
|
|
11272
|
+
},
|
|
11273
|
+
item.label
|
|
11274
|
+
)
|
|
11275
|
+
);
|
|
11276
|
+
}
|
|
11277
|
+
return /* @__PURE__ */ React.createElement(
|
|
11278
|
+
FormListItem,
|
|
11279
|
+
{
|
|
11280
|
+
setActiveFormId: (id) => props.setActiveFormId(id),
|
|
11281
|
+
key: item.formId,
|
|
11282
|
+
item,
|
|
11283
|
+
depth: 0
|
|
11284
|
+
}
|
|
11096
11285
|
);
|
|
11097
|
-
}));
|
|
11098
|
-
}
|
|
11099
|
-
const
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11286
|
+
})));
|
|
11287
|
+
};
|
|
11288
|
+
const SidebarNoFormsPlaceholder = () => /* @__PURE__ */ React.createElement(
|
|
11289
|
+
"div",
|
|
11290
|
+
{
|
|
11291
|
+
className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
|
|
11292
|
+
style: {
|
|
11293
|
+
animationName: "fade-in",
|
|
11294
|
+
animationDelay: "300ms",
|
|
11295
|
+
animationTimingFunction: "ease-out",
|
|
11296
|
+
animationIterationCount: 1,
|
|
11297
|
+
animationFillMode: "both",
|
|
11298
|
+
animationDuration: "150ms"
|
|
11299
|
+
}
|
|
11300
|
+
},
|
|
11301
|
+
/* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Looks like there's ", /* @__PURE__ */ React.createElement("br", null), "nothing to edit on ", /* @__PURE__ */ React.createElement("br", null), "this page."),
|
|
11302
|
+
/* @__PURE__ */ React.createElement("p", { className: "block pt-5" }, /* @__PURE__ */ React.createElement(
|
|
11303
|
+
Button$1,
|
|
11104
11304
|
{
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
setCopied(true);
|
|
11109
|
-
setTimeout(() => {
|
|
11110
|
-
setFadeOut(true);
|
|
11111
|
-
}, 2500);
|
|
11112
|
-
setTimeout(() => {
|
|
11113
|
-
setCopied(false);
|
|
11114
|
-
setFadeOut(false);
|
|
11115
|
-
}, 3e3);
|
|
11116
|
-
navigator.clipboard.writeText(value);
|
|
11117
|
-
},
|
|
11118
|
-
className: `shadow-inner text-base leading-5 whitespace-normal break-all px-3 py-2 text-gray-600 w-full bg-gray-50 border border-gray-200 transition-all ease-out duration-150 rounded-md relative overflow-hidden appearance-none flex items-center w-full cursor-pointer hover:bg-white hover:text-blue-500 ${copied ? `pointer-events-none` : ``}`
|
|
11305
|
+
href: "https://tina.io/docs/contextual-editing/overview",
|
|
11306
|
+
target: "_blank",
|
|
11307
|
+
as: "a"
|
|
11119
11308
|
},
|
|
11120
|
-
/* @__PURE__ */
|
|
11121
|
-
" "
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
/* @__PURE__ */ React__default.createElement("span", null, "Copied to clipboard!")
|
|
11130
|
-
)
|
|
11131
|
-
), description && /* @__PURE__ */ React__default.createElement("p", { className: "mt-2 text-sm text-gray-500" }, description));
|
|
11132
|
-
};
|
|
11133
|
-
function ListMediaItem({ item, onClick, active }) {
|
|
11134
|
-
let FileIcon = BiFile;
|
|
11135
|
-
if (item.type === "dir") {
|
|
11136
|
-
FileIcon = BiFolder;
|
|
11137
|
-
} else if (isVideo(item.src)) {
|
|
11138
|
-
FileIcon = BiMovie;
|
|
11309
|
+
/* @__PURE__ */ React.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
|
|
11310
|
+
" Contextual Editing Docs"
|
|
11311
|
+
))
|
|
11312
|
+
);
|
|
11313
|
+
const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React.createElement(
|
|
11314
|
+
"span",
|
|
11315
|
+
{
|
|
11316
|
+
className: `text-[24px] leading-none inline-block ${className}`,
|
|
11317
|
+
...props
|
|
11139
11318
|
}
|
|
11140
|
-
|
|
11141
|
-
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11319
|
+
);
|
|
11320
|
+
const minimumTimeToShowLoadingIndicator = 1e3;
|
|
11321
|
+
const FormsView = ({ loadingPlaceholder } = {}) => {
|
|
11322
|
+
const cms = useCMS$1();
|
|
11323
|
+
const { setFormIsPristine } = React.useContext(SidebarContext);
|
|
11324
|
+
const [isShowingLoading, setIsShowingLoading] = React.useState(true);
|
|
11325
|
+
const [initialLoadComplete, setInitialLoadComplete] = React.useState(false);
|
|
11326
|
+
React.useEffect(() => {
|
|
11327
|
+
if (cms.state.isLoadingContent) {
|
|
11328
|
+
setIsShowingLoading(true);
|
|
11329
|
+
const timer = setTimeout(() => {
|
|
11330
|
+
if (!cms.state.isLoadingContent) {
|
|
11331
|
+
setIsShowingLoading(false);
|
|
11332
|
+
setInitialLoadComplete(true);
|
|
11150
11333
|
}
|
|
11334
|
+
}, minimumTimeToShowLoadingIndicator);
|
|
11335
|
+
return () => clearTimeout(timer);
|
|
11336
|
+
} else {
|
|
11337
|
+
const timer = setTimeout(() => {
|
|
11338
|
+
setIsShowingLoading(false);
|
|
11339
|
+
setInitialLoadComplete(true);
|
|
11340
|
+
}, minimumTimeToShowLoadingIndicator);
|
|
11341
|
+
return () => clearTimeout(timer);
|
|
11342
|
+
}
|
|
11343
|
+
}, [cms.state.isLoadingContent]);
|
|
11344
|
+
if (isShowingLoading || !initialLoadComplete) {
|
|
11345
|
+
const LoadingPlaceholder = loadingPlaceholder || SidebarLoadingPlaceholder;
|
|
11346
|
+
return /* @__PURE__ */ React.createElement(LoadingPlaceholder, null);
|
|
11347
|
+
}
|
|
11348
|
+
if (!cms.state.formLists.length) {
|
|
11349
|
+
return /* @__PURE__ */ React.createElement(SidebarNoFormsPlaceholder, null);
|
|
11350
|
+
}
|
|
11351
|
+
const isMultiform = cms.state.forms.length > 1;
|
|
11352
|
+
const activeForm = cms.state.forms.find(
|
|
11353
|
+
({ tinaForm }) => tinaForm.id === cms.state.activeFormId
|
|
11354
|
+
);
|
|
11355
|
+
const isEditing = !!activeForm;
|
|
11356
|
+
if (isMultiform && !activeForm) {
|
|
11357
|
+
return /* @__PURE__ */ React.createElement(FormLists, { isEditing });
|
|
11358
|
+
}
|
|
11359
|
+
const formMetas = cms.plugins.all("form:meta");
|
|
11360
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, activeForm && /* @__PURE__ */ React.createElement(FormWrapper$1, { isEditing, isMultiform }, isMultiform && /* @__PURE__ */ React.createElement(MultiformFormHeader, { activeForm }), !isMultiform && /* @__PURE__ */ React.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React.createElement(React.Fragment, { key: meta.name }, /* @__PURE__ */ React.createElement(meta.Component, null))), /* @__PURE__ */ React.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
|
|
11361
|
+
};
|
|
11362
|
+
const FormWrapper$1 = ({ isEditing, children }) => {
|
|
11363
|
+
return /* @__PURE__ */ React.createElement(
|
|
11364
|
+
"div",
|
|
11365
|
+
{
|
|
11366
|
+
className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
|
|
11367
|
+
style: isEditing ? {
|
|
11368
|
+
transform: "none",
|
|
11369
|
+
animationName: "fly-in-left",
|
|
11370
|
+
animationDuration: "150ms",
|
|
11371
|
+
animationDelay: "0",
|
|
11372
|
+
animationIterationCount: 1,
|
|
11373
|
+
animationTimingFunction: "ease-out"
|
|
11374
|
+
} : {
|
|
11375
|
+
transform: "translate3d(100%, 0, 0)"
|
|
11151
11376
|
}
|
|
11152
11377
|
},
|
|
11153
|
-
|
|
11154
|
-
/* @__PURE__ */ React__default.createElement("div", { className: "w-16 h-16 bg-gray-50 border-r border-gray-150 overflow-hidden flex justify-center flex-shrink-0" }, isImage(thumbnail) ? /* @__PURE__ */ React__default.createElement(
|
|
11155
|
-
"img",
|
|
11156
|
-
{
|
|
11157
|
-
className: "object-contain object-center w-full h-full origin-center transition-all duration-150 ease-out group-hover:scale-110",
|
|
11158
|
-
src: thumbnail,
|
|
11159
|
-
alt: item.filename
|
|
11160
|
-
}
|
|
11161
|
-
) : /* @__PURE__ */ React__default.createElement(FileIcon, { className: "w-1/2 h-full fill-gray-300" })),
|
|
11162
|
-
/* @__PURE__ */ React__default.createElement(
|
|
11163
|
-
"span",
|
|
11164
|
-
{
|
|
11165
|
-
className: "text-base flex-grow w-full break-words truncate px-3 py-2"
|
|
11166
|
-
},
|
|
11167
|
-
item.filename
|
|
11168
|
-
)
|
|
11378
|
+
children
|
|
11169
11379
|
);
|
|
11170
|
-
}
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
}
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
const thumbnail = (item.thumbnails || {})["400x400"];
|
|
11179
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
11180
|
-
"li",
|
|
11380
|
+
};
|
|
11381
|
+
const MultiformFormHeader = ({
|
|
11382
|
+
activeForm
|
|
11383
|
+
}) => {
|
|
11384
|
+
const cms = useCMS$1();
|
|
11385
|
+
const { formIsPristine } = React.useContext(SidebarContext);
|
|
11386
|
+
return /* @__PURE__ */ React.createElement(
|
|
11387
|
+
"div",
|
|
11181
11388
|
{
|
|
11182
|
-
className:
|
|
11389
|
+
className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
|
|
11183
11390
|
},
|
|
11184
|
-
|
|
11185
|
-
/* @__PURE__ */ React__default.createElement(
|
|
11391
|
+
/* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
|
|
11186
11392
|
"button",
|
|
11187
11393
|
{
|
|
11188
|
-
|
|
11394
|
+
type: "button",
|
|
11395
|
+
className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
|
|
11189
11396
|
onClick: () => {
|
|
11190
|
-
|
|
11191
|
-
|
|
11397
|
+
const state = activeForm.tinaForm.finalForm.getState();
|
|
11398
|
+
if (state.invalid === true) {
|
|
11399
|
+
cms.alerts.error("Cannot navigate away from an invalid form.");
|
|
11192
11400
|
} else {
|
|
11193
|
-
|
|
11401
|
+
cms.dispatch({ type: "forms:set-active-form-id", value: null });
|
|
11194
11402
|
}
|
|
11195
11403
|
}
|
|
11196
11404
|
},
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11405
|
+
/* @__PURE__ */ React.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
|
|
11406
|
+
), /* @__PURE__ */ React.createElement(
|
|
11407
|
+
"button",
|
|
11408
|
+
{
|
|
11409
|
+
type: "button",
|
|
11410
|
+
className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
|
|
11411
|
+
onClick: () => {
|
|
11412
|
+
const collectionName = cms.api.tina.schema.getCollectionByFullPath(
|
|
11413
|
+
cms.state.activeFormId
|
|
11414
|
+
).name;
|
|
11415
|
+
window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
|
|
11203
11416
|
}
|
|
11204
|
-
|
|
11205
|
-
|
|
11417
|
+
},
|
|
11418
|
+
/* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
|
|
11419
|
+
), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
|
|
11206
11420
|
);
|
|
11207
|
-
}
|
|
11208
|
-
const DeleteModal$1 = ({
|
|
11209
|
-
close: close2,
|
|
11210
|
-
deleteFunc,
|
|
11211
|
-
filename
|
|
11212
|
-
}) => {
|
|
11213
|
-
const [processing, setProcessing] = React__default.useState(false);
|
|
11214
|
-
return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(PopupModal, null, /* @__PURE__ */ React__default.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React__default.createElement("p", null, "Are you sure you want to delete ", /* @__PURE__ */ React__default.createElement("strong", null, filename), "?")), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, disabled: processing, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
|
|
11215
|
-
Button$1,
|
|
11216
|
-
{
|
|
11217
|
-
style: { flexGrow: 3 },
|
|
11218
|
-
disabled: processing,
|
|
11219
|
-
variant: "danger",
|
|
11220
|
-
onClick: async () => {
|
|
11221
|
-
setProcessing(true);
|
|
11222
|
-
try {
|
|
11223
|
-
await deleteFunc();
|
|
11224
|
-
} catch (e) {
|
|
11225
|
-
console.error(e);
|
|
11226
|
-
} finally {
|
|
11227
|
-
close2();
|
|
11228
|
-
}
|
|
11229
|
-
}
|
|
11230
|
-
},
|
|
11231
|
-
/* @__PURE__ */ React__default.createElement("span", { className: "mr-1" }, "Delete"),
|
|
11232
|
-
processing && /* @__PURE__ */ React__default.createElement(LoadingDots, null)
|
|
11233
|
-
))));
|
|
11234
11421
|
};
|
|
11235
|
-
const
|
|
11236
|
-
const
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
placeholder: "Folder Name",
|
|
11242
|
-
required: true,
|
|
11243
|
-
onChange: (e) => setFolderName(e.target.value)
|
|
11244
|
-
}
|
|
11245
|
-
)), /* @__PURE__ */ React__default.createElement(ModalActions, null, /* @__PURE__ */ React__default.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React__default.createElement(
|
|
11246
|
-
Button$1,
|
|
11422
|
+
const FormHeader = ({ activeForm }) => {
|
|
11423
|
+
const { formIsPristine } = React.useContext(SidebarContext);
|
|
11424
|
+
const cms = useCMS$1();
|
|
11425
|
+
const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
|
|
11426
|
+
return /* @__PURE__ */ React.createElement(
|
|
11427
|
+
"div",
|
|
11247
11428
|
{
|
|
11248
|
-
|
|
11249
|
-
style: { flexGrow: 3 },
|
|
11250
|
-
variant: "primary",
|
|
11251
|
-
onClick: () => {
|
|
11252
|
-
if (!folderName)
|
|
11253
|
-
return;
|
|
11254
|
-
onSubmit(folderName);
|
|
11255
|
-
close2();
|
|
11256
|
-
}
|
|
11429
|
+
className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
|
|
11257
11430
|
},
|
|
11258
|
-
"
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
return part;
|
|
11274
|
-
});
|
|
11275
|
-
return parts.join(slash);
|
|
11431
|
+
/* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
|
|
11432
|
+
"button",
|
|
11433
|
+
{
|
|
11434
|
+
type: "button",
|
|
11435
|
+
className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
|
|
11436
|
+
onClick: () => {
|
|
11437
|
+
const collectionName = cms.api.tina.schema.getCollectionByFullPath(
|
|
11438
|
+
cms.state.activeFormId
|
|
11439
|
+
).name;
|
|
11440
|
+
window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
|
|
11441
|
+
}
|
|
11442
|
+
},
|
|
11443
|
+
/* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
|
|
11444
|
+
), shortFormLabel && /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
|
|
11445
|
+
);
|
|
11276
11446
|
};
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11447
|
+
const SidebarContext = React.createContext(null);
|
|
11448
|
+
const minPreviewWidth = 440;
|
|
11449
|
+
const minSidebarWidth = 360;
|
|
11450
|
+
const navBreakpoint = 1279;
|
|
11451
|
+
const LOCALSTATEKEY = "tina.sidebarState";
|
|
11452
|
+
const LOCALWIDTHKEY = "tina.sidebarWidth";
|
|
11453
|
+
const defaultSidebarWidth = 440;
|
|
11454
|
+
const defaultSidebarPosition = "displace";
|
|
11455
|
+
const defaultSidebarState = "open";
|
|
11456
|
+
function SidebarProvider({
|
|
11457
|
+
position = defaultSidebarPosition,
|
|
11458
|
+
resizingSidebar,
|
|
11459
|
+
setResizingSidebar,
|
|
11460
|
+
defaultWidth = defaultSidebarWidth,
|
|
11461
|
+
sidebar
|
|
11462
|
+
}) {
|
|
11463
|
+
var _a, _b, _c;
|
|
11464
|
+
useSubscribable(sidebar);
|
|
11465
|
+
const cms = useCMS$1();
|
|
11466
|
+
if (!cms.enabled)
|
|
11286
11467
|
return null;
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
"div",
|
|
11468
|
+
return /* @__PURE__ */ React.createElement(
|
|
11469
|
+
Sidebar$1,
|
|
11290
11470
|
{
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11471
|
+
position: ((_a = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _a.position) || position,
|
|
11472
|
+
defaultWidth: ((_b = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _b.defaultWidth) || defaultWidth,
|
|
11473
|
+
resizingSidebar,
|
|
11474
|
+
setResizingSidebar,
|
|
11475
|
+
renderNav: (
|
|
11476
|
+
// @ts-ignore
|
|
11477
|
+
typeof ((_c = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _c.renderNav) !== "undefined" ? (
|
|
11478
|
+
// @ts-ignore
|
|
11479
|
+
cms.sidebar.renderNav
|
|
11480
|
+
) : true
|
|
11481
|
+
),
|
|
11482
|
+
sidebar
|
|
11483
|
+
}
|
|
11484
|
+
);
|
|
11296
11485
|
}
|
|
11297
|
-
const
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
const
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
});
|
|
11315
|
-
const [deleteModalOpen, setDeleteModalOpen] = React__default.useState(false);
|
|
11316
|
-
const [newFolderModalOpen, setNewFolderModalOpen] = React__default.useState(false);
|
|
11317
|
-
const [listError, setListError] = useState(defaultListError);
|
|
11318
|
-
const [directory, setDirectory] = useState(
|
|
11319
|
-
props.directory
|
|
11486
|
+
const useFetchCollections = (cms) => {
|
|
11487
|
+
return { collections: cms.api.admin.fetchCollections(), loading: false };
|
|
11488
|
+
};
|
|
11489
|
+
const Sidebar$1 = ({
|
|
11490
|
+
sidebar,
|
|
11491
|
+
defaultWidth,
|
|
11492
|
+
// defaultState,
|
|
11493
|
+
position,
|
|
11494
|
+
renderNav,
|
|
11495
|
+
resizingSidebar,
|
|
11496
|
+
setResizingSidebar
|
|
11497
|
+
}) => {
|
|
11498
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11499
|
+
const cms = useCMS$1();
|
|
11500
|
+
const collectionsInfo = useFetchCollections(cms);
|
|
11501
|
+
const [branchingEnabled, setBranchingEnabled] = React.useState(
|
|
11502
|
+
() => cms.flags.get("branch-switcher")
|
|
11320
11503
|
);
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
const resetList = () => setList({
|
|
11326
|
-
items: [],
|
|
11327
|
-
nextOffset: void 0
|
|
11328
|
-
});
|
|
11329
|
-
const [viewMode, setViewMode] = useState("grid");
|
|
11330
|
-
const [activeItem, setActiveItem] = useState(false);
|
|
11331
|
-
const closePreview = () => setActiveItem(false);
|
|
11332
|
-
const [refreshing, setRefreshing] = useState(false);
|
|
11333
|
-
const [loadFolders, setLoadFolders] = useState(true);
|
|
11334
|
-
const [offsetHistory, setOffsetHistory] = useState([]);
|
|
11335
|
-
const offset2 = offsetHistory[offsetHistory.length - 1];
|
|
11336
|
-
const resetOffset = () => setOffsetHistory([]);
|
|
11337
|
-
async function loadMedia(loadFolders2 = true) {
|
|
11338
|
-
setListState("loading");
|
|
11339
|
-
try {
|
|
11340
|
-
const _list = await cms.media.list({
|
|
11341
|
-
offset: offset2,
|
|
11342
|
-
limit: cms.media.pageSize,
|
|
11343
|
-
directory,
|
|
11344
|
-
thumbnailSizes: [
|
|
11345
|
-
{ w: 75, h: 75 },
|
|
11346
|
-
{ w: 400, h: 400 },
|
|
11347
|
-
{ w: 1e3, h: 1e3 }
|
|
11348
|
-
],
|
|
11349
|
-
filesOnly: !loadFolders2
|
|
11350
|
-
});
|
|
11351
|
-
setList({
|
|
11352
|
-
items: [...list.items, ..._list.items],
|
|
11353
|
-
nextOffset: _list.nextOffset
|
|
11354
|
-
});
|
|
11355
|
-
setListState("loaded");
|
|
11356
|
-
} catch (e) {
|
|
11357
|
-
console.error(e);
|
|
11358
|
-
if (e.ERR_TYPE === "MediaListError") {
|
|
11359
|
-
setListError(e);
|
|
11360
|
-
} else {
|
|
11361
|
-
setListError(defaultListError);
|
|
11504
|
+
React.useEffect(() => {
|
|
11505
|
+
cms.events.subscribe("flag:set", ({ key, value }) => {
|
|
11506
|
+
if (key === "branch-switcher") {
|
|
11507
|
+
setBranchingEnabled(value);
|
|
11362
11508
|
}
|
|
11363
|
-
|
|
11509
|
+
});
|
|
11510
|
+
}, [cms.events]);
|
|
11511
|
+
const screens = cms.plugins.getType("screen");
|
|
11512
|
+
const cloudConfigs = cms.plugins.getType("cloud-config");
|
|
11513
|
+
useSubscribable(sidebar);
|
|
11514
|
+
useSubscribable(screens);
|
|
11515
|
+
const allScreens = screens.all();
|
|
11516
|
+
const allConfigs = cloudConfigs.all();
|
|
11517
|
+
const [menuIsOpen, setMenuIsOpen] = useState(false);
|
|
11518
|
+
const [activeScreen, setActiveView] = useState(null);
|
|
11519
|
+
const [sidebarWidth, setSidebarWidth] = React.useState(defaultWidth);
|
|
11520
|
+
const [formIsPristine, setFormIsPristine] = React.useState(true);
|
|
11521
|
+
const activeScreens = allScreens.filter(
|
|
11522
|
+
(screen) => {
|
|
11523
|
+
var _a2, _b2;
|
|
11524
|
+
return screen.navCategory !== "Account" || ((_b2 = (_a2 = cms.api.tina) == null ? void 0 : _a2.authProvider) == null ? void 0 : _b2.getLoginStrategy()) === "UsernamePassword";
|
|
11364
11525
|
}
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
loadMedia(loadFolders);
|
|
11378
|
-
if (loadFolders)
|
|
11379
|
-
setLoadFolders(false);
|
|
11380
|
-
return cms.events.subscribe(
|
|
11381
|
-
["media:delete:success", "media:pageSize"],
|
|
11382
|
-
() => {
|
|
11383
|
-
setRefreshing(true);
|
|
11384
|
-
resetOffset();
|
|
11385
|
-
resetList();
|
|
11526
|
+
);
|
|
11527
|
+
const setDisplayState = (value) => cms.dispatch({ type: "sidebar:set-display-state", value });
|
|
11528
|
+
const displayState = cms.state.sidebarDisplayState;
|
|
11529
|
+
React.useEffect(() => {
|
|
11530
|
+
if (typeof window !== "undefined") {
|
|
11531
|
+
const localSidebarState = window.localStorage.getItem(LOCALSTATEKEY);
|
|
11532
|
+
const localSidebarWidth = window.localStorage.getItem(LOCALWIDTHKEY);
|
|
11533
|
+
if (localSidebarState !== null) {
|
|
11534
|
+
setDisplayState(JSON.parse(localSidebarState));
|
|
11535
|
+
}
|
|
11536
|
+
if (localSidebarWidth !== null) {
|
|
11537
|
+
setSidebarWidth(JSON.parse(localSidebarWidth));
|
|
11386
11538
|
}
|
|
11387
|
-
);
|
|
11388
|
-
}, [offset2, directory, cms.media.isConfigured]);
|
|
11389
|
-
const onClickMediaItem = (item) => {
|
|
11390
|
-
if (!item) {
|
|
11391
|
-
setActiveItem(false);
|
|
11392
|
-
} else if (item.type === "dir") {
|
|
11393
|
-
setDirectory(
|
|
11394
|
-
item.directory === "." || item.directory === "" ? item.filename : join(item.directory, item.filename)
|
|
11395
|
-
);
|
|
11396
|
-
setLoadFolders(true);
|
|
11397
|
-
resetOffset();
|
|
11398
|
-
resetList();
|
|
11399
|
-
setActiveItem(false);
|
|
11400
|
-
} else {
|
|
11401
|
-
setActiveItem(item);
|
|
11402
11539
|
}
|
|
11403
|
-
};
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
}
|
|
11410
|
-
let selectMediaItem;
|
|
11411
|
-
if (onSelect) {
|
|
11412
|
-
selectMediaItem = (item) => {
|
|
11413
|
-
onSelect(item);
|
|
11414
|
-
if (close2)
|
|
11415
|
-
close2();
|
|
11416
|
-
};
|
|
11417
|
-
}
|
|
11418
|
-
const [uploading, setUploading] = useState(false);
|
|
11419
|
-
const accept = Array.isArray(
|
|
11420
|
-
(_c = (_b = (_a = cms.api.tina.schema.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.media) == null ? void 0 : _c.accept
|
|
11421
|
-
) ? (_f = (_e = (_d = cms.api.tina.schema.schema) == null ? void 0 : _d.config) == null ? void 0 : _e.media) == null ? void 0 : _f.accept.join(",") : (_i = (_h = (_g = cms.api.tina.schema.schema) == null ? void 0 : _g.config) == null ? void 0 : _h.media) == null ? void 0 : _i.accept;
|
|
11422
|
-
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
11423
|
-
accept: dropzoneAcceptFromString(
|
|
11424
|
-
accept || cms.media.accept || DEFAULT_MEDIA_UPLOAD_TYPES
|
|
11425
|
-
),
|
|
11426
|
-
maxSize: cms.media.maxSize,
|
|
11427
|
-
multiple: true,
|
|
11428
|
-
onDrop: async (files, fileRejections) => {
|
|
11429
|
-
try {
|
|
11430
|
-
setUploading(true);
|
|
11431
|
-
const mediaItems = await cms.media.persist(
|
|
11432
|
-
files.map((file) => {
|
|
11433
|
-
return {
|
|
11434
|
-
directory: directory || "/",
|
|
11435
|
-
file
|
|
11436
|
-
};
|
|
11437
|
-
})
|
|
11438
|
-
);
|
|
11439
|
-
const errorCodes = {
|
|
11440
|
-
"file-invalid-type": "Invalid file type",
|
|
11441
|
-
"file-too-large": "File too large",
|
|
11442
|
-
"file-too-small": "File too small",
|
|
11443
|
-
"too-many-files": "Too many files"
|
|
11444
|
-
};
|
|
11445
|
-
const printError = (error) => {
|
|
11446
|
-
const message = errorCodes[error.code];
|
|
11447
|
-
if (message) {
|
|
11448
|
-
return message;
|
|
11449
|
-
}
|
|
11450
|
-
console.error(error);
|
|
11451
|
-
return "Unknown error";
|
|
11452
|
-
};
|
|
11453
|
-
if (fileRejections.length > 0) {
|
|
11454
|
-
const messages = [];
|
|
11455
|
-
fileRejections.map((fileRejection) => {
|
|
11456
|
-
messages.push(
|
|
11457
|
-
`${fileRejection.file.name}: ${fileRejection.errors.map((error) => printError(error)).join(", ")}`
|
|
11458
|
-
);
|
|
11459
|
-
});
|
|
11460
|
-
cms.alerts.error(() => {
|
|
11461
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, "Upload Failed. ", /* @__PURE__ */ React__default.createElement("br", null), messages.join(". "), ".");
|
|
11462
|
-
});
|
|
11463
|
-
}
|
|
11464
|
-
if (mediaItems.length !== 0) {
|
|
11465
|
-
setActiveItem(mediaItems[0]);
|
|
11466
|
-
setList((mediaList) => {
|
|
11467
|
-
return {
|
|
11468
|
-
items: [
|
|
11469
|
-
// all the newly added items are new
|
|
11470
|
-
...mediaItems.map((x) => ({ ...x, new: true })),
|
|
11471
|
-
...mediaList.items
|
|
11472
|
-
],
|
|
11473
|
-
nextOffset: mediaList.nextOffset
|
|
11474
|
-
};
|
|
11475
|
-
});
|
|
11476
|
-
}
|
|
11477
|
-
} catch {
|
|
11540
|
+
}, []);
|
|
11541
|
+
React.useEffect(() => {
|
|
11542
|
+
if (typeof window !== "undefined") {
|
|
11543
|
+
const localSidebarState = window.localStorage.getItem(LOCALSTATEKEY);
|
|
11544
|
+
if (localSidebarState === null) {
|
|
11545
|
+
setDisplayState(defaultSidebarState);
|
|
11478
11546
|
}
|
|
11479
|
-
setUploading(false);
|
|
11480
11547
|
}
|
|
11481
|
-
});
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11548
|
+
}, [defaultSidebarState]);
|
|
11549
|
+
React.useEffect(() => {
|
|
11550
|
+
if (typeof window !== "undefined" && cms.enabled) {
|
|
11551
|
+
window.localStorage.setItem(LOCALSTATEKEY, JSON.stringify(displayState));
|
|
11552
|
+
}
|
|
11553
|
+
}, [displayState, cms]);
|
|
11554
|
+
React.useEffect(() => {
|
|
11555
|
+
if (resizingSidebar) {
|
|
11556
|
+
window.localStorage.setItem(LOCALWIDTHKEY, JSON.stringify(sidebarWidth));
|
|
11557
|
+
}
|
|
11558
|
+
}, [sidebarWidth, resizingSidebar]);
|
|
11559
|
+
const isTinaAdminEnabled = cms.flags.get("tina-admin") === false ? false : true;
|
|
11560
|
+
const contentCreators = isTinaAdminEnabled ? [] : cms.plugins.getType("content-creator").all();
|
|
11561
|
+
const toggleFullscreen = () => {
|
|
11562
|
+
if (displayState === "fullscreen") {
|
|
11563
|
+
setDisplayState("open");
|
|
11564
|
+
} else {
|
|
11565
|
+
setDisplayState("fullscreen");
|
|
11566
|
+
}
|
|
11567
|
+
};
|
|
11568
|
+
const toggleSidebarOpen = () => {
|
|
11569
|
+
cms.dispatch({ type: "toggle-edit-state" });
|
|
11570
|
+
};
|
|
11571
|
+
const toggleMenu = () => {
|
|
11572
|
+
setMenuIsOpen((menuIsOpen2) => !menuIsOpen2);
|
|
11573
|
+
};
|
|
11574
|
+
React.useEffect(() => {
|
|
11575
|
+
const updateLayout = () => {
|
|
11576
|
+
if (displayState === "fullscreen") {
|
|
11577
|
+
return;
|
|
11578
|
+
}
|
|
11579
|
+
updateBodyDisplacement({
|
|
11580
|
+
position,
|
|
11581
|
+
displayState,
|
|
11582
|
+
sidebarWidth,
|
|
11583
|
+
resizingSidebar
|
|
11584
|
+
});
|
|
11585
|
+
};
|
|
11586
|
+
updateLayout();
|
|
11587
|
+
window.addEventListener("resize", updateLayout);
|
|
11486
11588
|
return () => {
|
|
11487
|
-
|
|
11589
|
+
window.removeEventListener("resize", updateLayout);
|
|
11488
11590
|
};
|
|
11489
|
-
}
|
|
11490
|
-
|
|
11491
|
-
const
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11591
|
+
}, [displayState, position, sidebarWidth, resizingSidebar]);
|
|
11592
|
+
const windowWidth = useWindowWidth();
|
|
11593
|
+
const displayNav = renderNav && (sidebarWidth > navBreakpoint && windowWidth > navBreakpoint || displayState === "fullscreen" && windowWidth > navBreakpoint);
|
|
11594
|
+
const renderMobileNav = renderNav && (sidebarWidth < navBreakpoint + 1 || windowWidth < navBreakpoint + 1);
|
|
11595
|
+
return /* @__PURE__ */ React.createElement(
|
|
11596
|
+
SidebarContext.Provider,
|
|
11597
|
+
{
|
|
11598
|
+
value: {
|
|
11599
|
+
sidebarWidth,
|
|
11600
|
+
setSidebarWidth,
|
|
11601
|
+
displayState,
|
|
11602
|
+
setDisplayState,
|
|
11603
|
+
position,
|
|
11604
|
+
toggleFullscreen,
|
|
11605
|
+
toggleSidebarOpen,
|
|
11606
|
+
resizingSidebar,
|
|
11607
|
+
setResizingSidebar,
|
|
11608
|
+
menuIsOpen,
|
|
11609
|
+
setMenuIsOpen,
|
|
11610
|
+
toggleMenu,
|
|
11611
|
+
setActiveView,
|
|
11612
|
+
formIsPristine,
|
|
11613
|
+
setFormIsPristine
|
|
11500
11614
|
}
|
|
11501
|
-
}
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11615
|
+
},
|
|
11616
|
+
/* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SidebarWrapper, null, /* @__PURE__ */ React.createElement(EditButton, null), displayNav && /* @__PURE__ */ React.createElement(
|
|
11617
|
+
Nav,
|
|
11618
|
+
{
|
|
11619
|
+
isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode,
|
|
11620
|
+
showCollections: isTinaAdminEnabled,
|
|
11621
|
+
collectionsInfo,
|
|
11622
|
+
screens: activeScreens,
|
|
11623
|
+
cloudConfigs: allConfigs,
|
|
11624
|
+
contentCreators,
|
|
11625
|
+
sidebarWidth,
|
|
11626
|
+
RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(
|
|
11627
|
+
SidebarSiteLink,
|
|
11628
|
+
{
|
|
11629
|
+
view,
|
|
11630
|
+
onClick: () => {
|
|
11631
|
+
setActiveView(view);
|
|
11632
|
+
setMenuIsOpen(false);
|
|
11633
|
+
}
|
|
11634
|
+
}
|
|
11635
|
+
),
|
|
11636
|
+
RenderNavCloud: ({ config }) => /* @__PURE__ */ React.createElement(SidebarCloudLink$1, { config }),
|
|
11637
|
+
RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
11638
|
+
SidebarCollectionLink,
|
|
11639
|
+
{
|
|
11640
|
+
onClick: () => {
|
|
11641
|
+
setMenuIsOpen(false);
|
|
11642
|
+
},
|
|
11643
|
+
collection
|
|
11644
|
+
}
|
|
11645
|
+
),
|
|
11646
|
+
AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
11647
|
+
SidebarCollectionLink,
|
|
11648
|
+
{
|
|
11649
|
+
onClick: () => {
|
|
11650
|
+
setMenuIsOpen(false);
|
|
11651
|
+
},
|
|
11652
|
+
collection,
|
|
11653
|
+
Icon: ImUsers
|
|
11654
|
+
}
|
|
11655
|
+
)
|
|
11508
11656
|
}
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
if (listState === "loading" && !((_j = list == null ? void 0 : list.items) == null ? void 0 : _j.length) || uploading) {
|
|
11512
|
-
return /* @__PURE__ */ React__default.createElement(LoadingMediaList, null);
|
|
11513
|
-
}
|
|
11514
|
-
if (listState === "not-configured") {
|
|
11515
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
11516
|
-
DocsLink,
|
|
11657
|
+
), /* @__PURE__ */ React.createElement(SidebarBody, null, /* @__PURE__ */ React.createElement(
|
|
11658
|
+
SidebarHeader,
|
|
11517
11659
|
{
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11660
|
+
displayNav,
|
|
11661
|
+
renderNav,
|
|
11662
|
+
isLocalMode: (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isLocalMode,
|
|
11663
|
+
branchingEnabled
|
|
11521
11664
|
}
|
|
11522
|
-
)
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11665
|
+
), /* @__PURE__ */ React.createElement(FormsView, { loadingPlaceholder: sidebar.loadingPlaceholder }), activeScreen && /* @__PURE__ */ React.createElement(
|
|
11666
|
+
ScreenPluginModal,
|
|
11667
|
+
{
|
|
11668
|
+
screen: activeScreen,
|
|
11669
|
+
close: () => setActiveView(null)
|
|
11670
|
+
}
|
|
11671
|
+
)), /* @__PURE__ */ React.createElement(ResizeHandle, null)), renderMobileNav && /* @__PURE__ */ React.createElement(Transition, { show: menuIsOpen, as: "div" }, /* @__PURE__ */ React.createElement(
|
|
11672
|
+
TransitionChild,
|
|
11673
|
+
{
|
|
11674
|
+
enter: "transform transition-all ease-out duration-300",
|
|
11675
|
+
enterFrom: "opacity-0 -translate-x-full",
|
|
11676
|
+
enterTo: "opacity-100 translate-x-0",
|
|
11677
|
+
leave: "transform transition-all ease-in duration-200",
|
|
11678
|
+
leaveFrom: "opacity-100 translate-x-0",
|
|
11679
|
+
leaveTo: "opacity-0 -translate-x-full"
|
|
11537
11680
|
},
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
}
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11681
|
+
/* @__PURE__ */ React.createElement("div", { className: "fixed left-0 top-0 z-overlay h-full transform" }, /* @__PURE__ */ React.createElement(
|
|
11682
|
+
Nav,
|
|
11683
|
+
{
|
|
11684
|
+
isLocalMode: (_f = (_e = cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode,
|
|
11685
|
+
className: "rounded-r-md",
|
|
11686
|
+
showCollections: isTinaAdminEnabled,
|
|
11687
|
+
collectionsInfo,
|
|
11688
|
+
screens: activeScreens,
|
|
11689
|
+
cloudConfigs: allConfigs,
|
|
11690
|
+
contentCreators,
|
|
11691
|
+
sidebarWidth,
|
|
11692
|
+
RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(
|
|
11693
|
+
SidebarSiteLink,
|
|
11694
|
+
{
|
|
11695
|
+
view,
|
|
11696
|
+
onClick: () => {
|
|
11697
|
+
setActiveView(view);
|
|
11698
|
+
setMenuIsOpen(false);
|
|
11699
|
+
}
|
|
11700
|
+
}
|
|
11701
|
+
),
|
|
11702
|
+
RenderNavCloud: ({ config }) => /* @__PURE__ */ React.createElement(SidebarCloudLink$1, { config }),
|
|
11703
|
+
RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
11704
|
+
SidebarCollectionLink,
|
|
11705
|
+
{
|
|
11706
|
+
onClick: () => {
|
|
11707
|
+
setMenuIsOpen(false);
|
|
11708
|
+
},
|
|
11709
|
+
collection
|
|
11710
|
+
}
|
|
11711
|
+
),
|
|
11712
|
+
AuthRenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(
|
|
11713
|
+
SidebarCollectionLink,
|
|
11714
|
+
{
|
|
11715
|
+
onClick: () => {
|
|
11716
|
+
setMenuIsOpen(false);
|
|
11717
|
+
},
|
|
11718
|
+
collection,
|
|
11719
|
+
Icon: ImUsers
|
|
11720
|
+
}
|
|
11721
|
+
)
|
|
11722
|
+
},
|
|
11723
|
+
/* @__PURE__ */ React.createElement("div", { className: "absolute top-8 right-0 transform translate-x-full overflow-hidden" }, /* @__PURE__ */ React.createElement(
|
|
11724
|
+
Button$1,
|
|
11725
|
+
{
|
|
11726
|
+
rounded: "right",
|
|
11727
|
+
variant: "secondary",
|
|
11728
|
+
onClick: () => {
|
|
11729
|
+
setMenuIsOpen(false);
|
|
11730
|
+
},
|
|
11731
|
+
className: "transition-opacity duration-150 ease-out"
|
|
11732
|
+
},
|
|
11733
|
+
/* @__PURE__ */ React.createElement(IoMdClose, { className: "h-5 w-auto text-blue-500" })
|
|
11734
|
+
))
|
|
11735
|
+
))
|
|
11736
|
+
), /* @__PURE__ */ React.createElement(
|
|
11737
|
+
TransitionChild,
|
|
11738
|
+
{
|
|
11739
|
+
enter: "ease-out duration-300",
|
|
11740
|
+
enterFrom: "opacity-0",
|
|
11741
|
+
enterTo: "opacity-80",
|
|
11742
|
+
entered: "opacity-80",
|
|
11743
|
+
leave: "ease-in duration-200",
|
|
11744
|
+
leaveFrom: "opacity-80",
|
|
11745
|
+
leaveTo: "opacity-0"
|
|
11553
11746
|
},
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11747
|
+
/* @__PURE__ */ React.createElement(
|
|
11748
|
+
"div",
|
|
11749
|
+
{
|
|
11750
|
+
onClick: () => {
|
|
11751
|
+
setMenuIsOpen(false);
|
|
11752
|
+
},
|
|
11753
|
+
className: "fixed z-menu inset-0 bg-gradient-to-br from-gray-800 via-gray-900 to-black"
|
|
11754
|
+
}
|
|
11755
|
+
)
|
|
11756
|
+
)))
|
|
11757
|
+
);
|
|
11758
|
+
};
|
|
11759
|
+
const updateBodyDisplacement = ({
|
|
11760
|
+
position = "overlay",
|
|
11761
|
+
displayState,
|
|
11762
|
+
sidebarWidth,
|
|
11763
|
+
resizingSidebar
|
|
11764
|
+
}) => {
|
|
11765
|
+
const body = document.getElementsByTagName("body")[0];
|
|
11766
|
+
const windowWidth = window.innerWidth;
|
|
11767
|
+
if (position === "displace") {
|
|
11768
|
+
body.style.transition = resizingSidebar ? "" : displayState === "fullscreen" ? "padding 0ms 150ms" : displayState === "closed" ? "padding 0ms 0ms" : "padding 0ms 300ms";
|
|
11769
|
+
if (displayState === "open") {
|
|
11770
|
+
const bodyDisplacement = Math.min(
|
|
11771
|
+
sidebarWidth,
|
|
11772
|
+
windowWidth - minPreviewWidth
|
|
11773
|
+
);
|
|
11774
|
+
body.style.paddingLeft = `${bodyDisplacement}px`;
|
|
11775
|
+
} else {
|
|
11776
|
+
body.style.paddingLeft = "0";
|
|
11567
11777
|
}
|
|
11568
|
-
|
|
11778
|
+
} else {
|
|
11779
|
+
body.style.transition = "";
|
|
11780
|
+
body.style.paddingLeft = "0";
|
|
11781
|
+
}
|
|
11782
|
+
};
|
|
11783
|
+
const SidebarHeader = ({
|
|
11784
|
+
branchingEnabled,
|
|
11785
|
+
renderNav,
|
|
11786
|
+
displayNav,
|
|
11787
|
+
isLocalMode
|
|
11788
|
+
}) => {
|
|
11789
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
11790
|
+
const { toggleFullscreen, displayState, setMenuIsOpen, toggleSidebarOpen } = React.useContext(SidebarContext);
|
|
11791
|
+
const displayMenuButton = renderNav && !displayNav;
|
|
11792
|
+
const cms = useCMS$1();
|
|
11793
|
+
const previewFunction = (_f = (_e = (_d = (_c = (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.schema) == null ? void 0 : _c.config) == null ? void 0 : _d.config) == null ? void 0 : _e.ui) == null ? void 0 : _f.previewUrl;
|
|
11794
|
+
const branch = (_h = (_g = cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.branch;
|
|
11795
|
+
const previewUrl = typeof previewFunction === "function" ? (_i = previewFunction({ branch })) == null ? void 0 : _i.url : null;
|
|
11796
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex-grow-0 w-full overflow-visible z-20" }, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), !isLocalMode && /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", { className: "mt-4 -mb-14 w-full flex gap-3 items-center justify-between pointer-events-none" }, displayMenuButton && /* @__PURE__ */ React.createElement(
|
|
11569
11797
|
Button$1,
|
|
11570
11798
|
{
|
|
11571
|
-
|
|
11799
|
+
rounded: "right",
|
|
11572
11800
|
variant: "white",
|
|
11573
11801
|
onClick: () => {
|
|
11574
|
-
|
|
11575
|
-
resetOffset();
|
|
11576
|
-
resetList();
|
|
11577
|
-
setActiveItem(false);
|
|
11802
|
+
setMenuIsOpen(true);
|
|
11578
11803
|
},
|
|
11579
|
-
className: "
|
|
11804
|
+
className: "pointer-events-auto -ml-px"
|
|
11580
11805
|
},
|
|
11581
|
-
"
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
Button$1,
|
|
11806
|
+
/* @__PURE__ */ React.createElement(BiMenu, { className: "h-6 w-auto text-blue-500" })
|
|
11807
|
+
), /* @__PURE__ */ React.createElement("div", { className: "flex-1 flex gap-3 items-center shrink min-w-0" }, branchingEnabled && !isLocalMode && /* @__PURE__ */ React.createElement(BranchButton, null), branchingEnabled && !isLocalMode && previewUrl && /* @__PURE__ */ React.createElement(
|
|
11808
|
+
"button",
|
|
11585
11809
|
{
|
|
11586
|
-
|
|
11587
|
-
variant: "white",
|
|
11810
|
+
className: "pointer-events-auto flex min-w-0 shrink gap-1 items-center justify-between form-select text-sm h-10 px-4 shadow text-gray-500 hover:text-blue-500 bg-white hover:bg-gray-50 border border-gray-100 transition-color duration-150 ease-out rounded-full focus:outline-none focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out text-[12px] leading-tight min-w-[5rem]",
|
|
11588
11811
|
onClick: () => {
|
|
11589
|
-
|
|
11590
|
-
},
|
|
11591
|
-
className: "whitespace-nowrap"
|
|
11592
|
-
},
|
|
11593
|
-
"New Folder",
|
|
11594
|
-
/* @__PURE__ */ React__default.createElement(BiFolder, { className: "w-6 h-full ml-2 opacity-70 text-blue-500" })
|
|
11595
|
-
), /* @__PURE__ */ React__default.createElement(UploadButton, { onClick, uploading }))), /* @__PURE__ */ React__default.createElement("div", { className: "flex h-full overflow-hidden bg-white" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-full flex-col h-full @container" }, /* @__PURE__ */ React__default.createElement(
|
|
11596
|
-
"ul",
|
|
11597
|
-
{
|
|
11598
|
-
...rootProps,
|
|
11599
|
-
className: `h-full grow overflow-y-auto transition duration-150 ease-out bg-gradient-to-b from-gray-50/50 to-gray-50 ${list.items.length === 0 || viewMode === "list" && "w-full flex flex-1 flex-col justify-start -mb-px"} ${list.items.length > 0 && viewMode === "grid" && "w-full p-4 gap-4 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 4xl:grid-cols-6 6xl:grid-cols-9 auto-rows-auto content-start justify-start"} ${isDragActive ? `border-2 border-blue-500 rounded-lg` : ``}`
|
|
11600
|
-
},
|
|
11601
|
-
/* @__PURE__ */ React__default.createElement("input", { ...getInputProps() }),
|
|
11602
|
-
listState === "loaded" && list.items.length === 0 && /* @__PURE__ */ React__default.createElement(EmptyMediaList, null),
|
|
11603
|
-
viewMode === "list" && list.items.map((item) => /* @__PURE__ */ React__default.createElement(
|
|
11604
|
-
ListMediaItem,
|
|
11605
|
-
{
|
|
11606
|
-
key: item.id,
|
|
11607
|
-
item,
|
|
11608
|
-
onClick: onClickMediaItem,
|
|
11609
|
-
active: activeItem && activeItem.id === item.id
|
|
11610
|
-
}
|
|
11611
|
-
)),
|
|
11612
|
-
viewMode === "grid" && list.items.map((item) => /* @__PURE__ */ React__default.createElement(
|
|
11613
|
-
GridMediaItem,
|
|
11614
|
-
{
|
|
11615
|
-
key: item.id,
|
|
11616
|
-
item,
|
|
11617
|
-
onClick: onClickMediaItem,
|
|
11618
|
-
active: activeItem && activeItem.id === item.id
|
|
11619
|
-
}
|
|
11620
|
-
)),
|
|
11621
|
-
!!list.nextOffset && /* @__PURE__ */ React__default.createElement(LoadingMediaList, { ref: loaderRef })
|
|
11622
|
-
)), /* @__PURE__ */ React__default.createElement(
|
|
11623
|
-
ActiveItemPreview,
|
|
11624
|
-
{
|
|
11625
|
-
activeItem,
|
|
11626
|
-
close: closePreview,
|
|
11627
|
-
selectMediaItem,
|
|
11628
|
-
allowDelete: cms.media.store.isStatic ? false : allowDelete,
|
|
11629
|
-
deleteMediaItem: () => {
|
|
11630
|
-
setDeleteModalOpen(true);
|
|
11812
|
+
window.open(previewUrl, "_blank");
|
|
11631
11813
|
}
|
|
11632
|
-
}
|
|
11633
|
-
|
|
11634
|
-
}
|
|
11635
|
-
|
|
11636
|
-
activeItem,
|
|
11637
|
-
close: close2,
|
|
11638
|
-
selectMediaItem,
|
|
11639
|
-
deleteMediaItem,
|
|
11640
|
-
allowDelete
|
|
11641
|
-
}) => {
|
|
11642
|
-
const thumbnail = activeItem ? (activeItem.thumbnails || {})["1000x1000"] : "";
|
|
11643
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
11814
|
+
},
|
|
11815
|
+
/* @__PURE__ */ React.createElement(BiLinkExternal, { className: "flex-shrink-0 w-4 h-auto text-blue-500/70 mr-1" }),
|
|
11816
|
+
/* @__PURE__ */ React.createElement("span", { className: "truncate max-w-full min-w-0 shrink" }, "Preview")
|
|
11817
|
+
)), /* @__PURE__ */ React.createElement(
|
|
11644
11818
|
"div",
|
|
11645
11819
|
{
|
|
11646
|
-
className:
|
|
11820
|
+
className: "flex items-center pointer-events-auto transition-opacity duration-150 ease-in-out -mr-px"
|
|
11647
11821
|
},
|
|
11648
|
-
|
|
11649
|
-
IconButton,
|
|
11650
|
-
{
|
|
11651
|
-
variant: "ghost",
|
|
11652
|
-
className: "group grow-0 shrink-0",
|
|
11653
|
-
onClick: close2
|
|
11654
|
-
},
|
|
11655
|
-
/* @__PURE__ */ React__default.createElement(
|
|
11656
|
-
BiX,
|
|
11657
|
-
{
|
|
11658
|
-
className: `w-7 h-auto text-gray-500 opacity-50 group-hover:opacity-100 transition duration-150 ease-out`
|
|
11659
|
-
}
|
|
11660
|
-
)
|
|
11661
|
-
)), isImage(thumbnail) ? /* @__PURE__ */ React__default.createElement("div", { className: "w-full max-h-[75%]" }, /* @__PURE__ */ React__default.createElement(
|
|
11662
|
-
"img",
|
|
11663
|
-
{
|
|
11664
|
-
className: "block border border-gray-100 rounded-md overflow-hidden object-center object-contain max-w-full max-h-full m-auto shadow",
|
|
11665
|
-
src: thumbnail,
|
|
11666
|
-
alt: activeItem.filename
|
|
11667
|
-
}
|
|
11668
|
-
)) : /* @__PURE__ */ React__default.createElement("span", { className: "p-3 border border-gray-100 rounded-md overflow-hidden bg-gray-50 shadow" }, /* @__PURE__ */ React__default.createElement(BiFile, { className: "w-14 h-auto fill-gray-300" })), /* @__PURE__ */ React__default.createElement("div", { className: "grow h-full w-full shrink flex flex-col gap-3 items-start justify-start" }, /* @__PURE__ */ React__default.createElement(CopyField, { value: absoluteImgURL(activeItem.src), label: "URL" })), /* @__PURE__ */ React__default.createElement("div", { className: "shrink-0 w-full flex flex-col justify-end items-start" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-full gap-3" }, selectMediaItem && /* @__PURE__ */ React__default.createElement(
|
|
11669
|
-
Button$1,
|
|
11670
|
-
{
|
|
11671
|
-
size: "medium",
|
|
11672
|
-
variant: "primary",
|
|
11673
|
-
className: "grow",
|
|
11674
|
-
onClick: () => selectMediaItem(activeItem)
|
|
11675
|
-
},
|
|
11676
|
-
"Insert",
|
|
11677
|
-
/* @__PURE__ */ React__default.createElement(BiArrowToBottom, { className: "ml-1 -mr-0.5 w-6 h-auto text-white opacity-70" })
|
|
11678
|
-
), allowDelete && /* @__PURE__ */ React__default.createElement(
|
|
11822
|
+
/* @__PURE__ */ React.createElement(
|
|
11679
11823
|
Button$1,
|
|
11680
11824
|
{
|
|
11825
|
+
rounded: "left",
|
|
11681
11826
|
variant: "white",
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
},
|
|
11686
|
-
"Delete",
|
|
11687
|
-
/* @__PURE__ */ React__default.createElement(TrashIcon, { className: "ml-1 -mr-0.5 w-6 h-auto text-red-500 opacity-70" })
|
|
11688
|
-
))))
|
|
11689
|
-
);
|
|
11690
|
-
};
|
|
11691
|
-
const UploadButton = ({ onClick, uploading }) => {
|
|
11692
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
11693
|
-
Button$1,
|
|
11694
|
-
{
|
|
11695
|
-
variant: "primary",
|
|
11696
|
-
size: "custom",
|
|
11697
|
-
className: "text-sm h-10 px-6",
|
|
11698
|
-
busy: uploading,
|
|
11699
|
-
onClick
|
|
11700
|
-
},
|
|
11701
|
-
uploading ? /* @__PURE__ */ React__default.createElement(LoadingDots, null) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, "Upload ", /* @__PURE__ */ React__default.createElement(BiCloudUpload, { className: "w-6 h-full ml-2 opacity-70" }))
|
|
11702
|
-
);
|
|
11703
|
-
};
|
|
11704
|
-
const LoadingMediaList = forwardRef(
|
|
11705
|
-
(props, ref) => {
|
|
11706
|
-
const { extraText, ...rest } = props;
|
|
11707
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
11708
|
-
"div",
|
|
11709
|
-
{
|
|
11710
|
-
ref,
|
|
11711
|
-
className: "w-full h-full flex flex-col items-center justify-center",
|
|
11712
|
-
...rest
|
|
11827
|
+
onClick: toggleSidebarOpen,
|
|
11828
|
+
"aria-label": "closes cms sidebar",
|
|
11829
|
+
className: "-mr-px"
|
|
11713
11830
|
},
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
};
|
|
11740
|
-
if (!cms.media.store.isStatic) {
|
|
11741
|
-
checkSyncStatus();
|
|
11742
|
-
}
|
|
11743
|
-
}, []);
|
|
11744
|
-
return syncStatus == "needs-sync" ? /* @__PURE__ */ React__default.createElement("div", { className: "h-full flex items-center justify-center p-6 bg-gradient-to-t from-gray-200 to-transparent" }, /* @__PURE__ */ React__default.createElement("div", { className: "rounded-lg border shadow-sm px-4 lg:px-6 py-3 lg:py-4 bg-gradient-to-r from-yellow-50 to-yellow-100 border-yellow-200 mx-auto mb-12" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-start sm:items-center gap-2" }, /* @__PURE__ */ React__default.createElement(
|
|
11745
|
-
BiError,
|
|
11746
|
-
{
|
|
11747
|
-
className: `w-7 h-auto flex-shrink-0 text-yellow-400 -mt-px`
|
|
11748
|
-
}
|
|
11749
|
-
), /* @__PURE__ */ React__default.createElement(
|
|
11750
|
-
"div",
|
|
11831
|
+
/* @__PURE__ */ React.createElement(MdOutlineArrowBackIos, { className: "h-[18px] w-auto -mr-1 text-blue-500" })
|
|
11832
|
+
),
|
|
11833
|
+
/* @__PURE__ */ React.createElement(Button$1, { rounded: "custom", variant: "white", onClick: toggleFullscreen }, displayState === "fullscreen" ? (
|
|
11834
|
+
// BiCollapseAlt
|
|
11835
|
+
/* @__PURE__ */ React.createElement(
|
|
11836
|
+
"svg",
|
|
11837
|
+
{
|
|
11838
|
+
className: "h-5 w-auto -mx-1 text-blue-500",
|
|
11839
|
+
stroke: "currentColor",
|
|
11840
|
+
fill: "currentColor",
|
|
11841
|
+
strokeWidth: "0",
|
|
11842
|
+
viewBox: "0 0 24 24",
|
|
11843
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
11844
|
+
},
|
|
11845
|
+
/* @__PURE__ */ React.createElement("path", { d: "M2 15h7v7h2v-9H2v2zM15 2h-2v9h9V9h-7V2z" })
|
|
11846
|
+
)
|
|
11847
|
+
) : /* @__PURE__ */ React.createElement(BiExpandAlt, { className: "h-5 -mx-1 w-auto text-blue-500" }))
|
|
11848
|
+
)));
|
|
11849
|
+
};
|
|
11850
|
+
const SidebarSiteLink = ({
|
|
11851
|
+
view,
|
|
11852
|
+
onClick
|
|
11853
|
+
}) => {
|
|
11854
|
+
return /* @__PURE__ */ React.createElement(
|
|
11855
|
+
"button",
|
|
11751
11856
|
{
|
|
11752
|
-
className:
|
|
11857
|
+
className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100",
|
|
11858
|
+
value: view.name,
|
|
11859
|
+
onClick
|
|
11753
11860
|
},
|
|
11754
|
-
|
|
11755
|
-
|
|
11861
|
+
/* @__PURE__ */ React.createElement(view.Icon, { className: "mr-2 h-6 opacity-80 w-auto" }),
|
|
11862
|
+
" ",
|
|
11863
|
+
view.name
|
|
11864
|
+
);
|
|
11865
|
+
};
|
|
11866
|
+
const SidebarCloudLink$1 = ({ config }) => {
|
|
11867
|
+
if (config.text) {
|
|
11868
|
+
return /* @__PURE__ */ React.createElement("span", { className: "text-base tracking-wide text-gray-500 flex items-center opacity-90" }, config.text, " ", /* @__PURE__ */ React.createElement(
|
|
11756
11869
|
"a",
|
|
11757
11870
|
{
|
|
11758
|
-
className: "transition-all duration-150 ease-out text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 font-medium flex items-center justify-start gap-1",
|
|
11759
11871
|
target: "_blank",
|
|
11760
|
-
|
|
11872
|
+
className: "ml-1 text-blue-600 hover:opacity-60",
|
|
11873
|
+
href: config.link.href
|
|
11761
11874
|
},
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
)
|
|
11765
|
-
)))) : /* @__PURE__ */ React__default.createElement(SyncStatusContext.Provider, { value: { syncStatus } }, children);
|
|
11766
|
-
};
|
|
11767
|
-
const useSyncStatus = () => {
|
|
11768
|
-
const context = useContext(SyncStatusContext);
|
|
11769
|
-
if (!context) {
|
|
11770
|
-
throw new Error("useSyncStatus must be used within a SyncStatusProvider");
|
|
11875
|
+
config.link.text
|
|
11876
|
+
));
|
|
11771
11877
|
}
|
|
11772
|
-
return
|
|
11773
|
-
};
|
|
11774
|
-
const EmptyMediaList = () => {
|
|
11775
|
-
const { syncStatus } = useSyncStatus();
|
|
11776
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: `p-12 text-xl opacity-50 text-center` }, syncStatus == "synced" ? "Drag and drop assets here" : "Loading...");
|
|
11878
|
+
return /* @__PURE__ */ React.createElement("span", { className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100" }, /* @__PURE__ */ React.createElement(config.Icon, { className: "mr-2 h-6 opacity-80 w-auto" }), /* @__PURE__ */ React.createElement("a", { target: "_blank", href: config.link.href }, config.link.text));
|
|
11777
11879
|
};
|
|
11778
|
-
const
|
|
11779
|
-
|
|
11880
|
+
const SidebarCollectionLink = ({
|
|
11881
|
+
Icon = ImFilesEmpty,
|
|
11882
|
+
collection,
|
|
11883
|
+
onClick
|
|
11884
|
+
}) => {
|
|
11885
|
+
const cms = useCMS$1();
|
|
11886
|
+
const tinaPreview = cms.flags.get("tina-preview") || false;
|
|
11887
|
+
return /* @__PURE__ */ React.createElement(
|
|
11780
11888
|
"a",
|
|
11781
11889
|
{
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
className: "font-bold text-blue-500 hover:text-blue-600 hover:underline transition-all ease-out duration-150"
|
|
11890
|
+
onClick,
|
|
11891
|
+
href: `${tinaPreview ? `/${tinaPreview}/index.html#` : "/admin#"}/collections/${collection.name}/~`,
|
|
11892
|
+
className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100"
|
|
11786
11893
|
},
|
|
11787
|
-
"
|
|
11788
|
-
|
|
11894
|
+
/* @__PURE__ */ React.createElement(Icon, { className: "mr-2 h-6 opacity-80 w-auto" }),
|
|
11895
|
+
" ",
|
|
11896
|
+
collection.label ? collection.label : collection.name
|
|
11897
|
+
);
|
|
11789
11898
|
};
|
|
11790
|
-
const
|
|
11791
|
-
const
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11899
|
+
const EditButton = ({}) => {
|
|
11900
|
+
const { displayState, toggleSidebarOpen } = React.useContext(SidebarContext);
|
|
11901
|
+
return /* @__PURE__ */ React.createElement(
|
|
11902
|
+
Button$1,
|
|
11903
|
+
{
|
|
11904
|
+
rounded: "right",
|
|
11905
|
+
variant: "primary",
|
|
11906
|
+
size: "custom",
|
|
11907
|
+
onClick: toggleSidebarOpen,
|
|
11908
|
+
className: `z-chrome absolute top-6 right-0 translate-x-full text-sm h-10 pl-3 pr-4 transition-all duration-300 ${displayState !== "closed" ? "opacity-0 ease-in pointer-events-none" : "ease-out pointer-events-auto"}`,
|
|
11909
|
+
"aria-label": "opens cms sidebar"
|
|
11910
|
+
},
|
|
11911
|
+
/* @__PURE__ */ React.createElement(BiPencil, { className: "h-6 w-auto" })
|
|
11912
|
+
);
|
|
11913
|
+
};
|
|
11914
|
+
const SidebarWrapper = ({ children }) => {
|
|
11915
|
+
const { displayState, sidebarWidth, resizingSidebar } = React.useContext(SidebarContext);
|
|
11916
|
+
return /* @__PURE__ */ React.createElement(
|
|
11797
11917
|
"div",
|
|
11798
11918
|
{
|
|
11799
|
-
className: `
|
|
11919
|
+
className: `fixed top-0 left-0 h-dvh z-base ${displayState === "closed" ? "pointer-events-none" : ""}`
|
|
11800
11920
|
},
|
|
11801
|
-
/* @__PURE__ */
|
|
11802
|
-
"
|
|
11803
|
-
{
|
|
11804
|
-
className: `${toggleClasses.base} px-2.5 rounded-l-md ${viewMode === "grid" ? toggleClasses.active : toggleClasses.inactive}`,
|
|
11805
|
-
onClick: () => {
|
|
11806
|
-
setViewMode("grid");
|
|
11807
|
-
}
|
|
11808
|
-
},
|
|
11809
|
-
/* @__PURE__ */ React__default.createElement(BiGridAlt, { className: "w-6 h-full opacity-70" })
|
|
11810
|
-
),
|
|
11811
|
-
/* @__PURE__ */ React__default.createElement(
|
|
11812
|
-
"button",
|
|
11921
|
+
/* @__PURE__ */ React.createElement(
|
|
11922
|
+
"div",
|
|
11813
11923
|
{
|
|
11814
|
-
className:
|
|
11815
|
-
|
|
11816
|
-
|
|
11924
|
+
className: `relative h-dvh transform flex ${displayState !== "closed" ? "" : "-translate-x-full"} ${resizingSidebar ? "transition-none" : displayState === "closed" ? "transition-all duration-300 ease-in" : displayState === "fullscreen" ? "transition-all duration-150 ease-out" : "transition-all duration-300 ease-out"}`,
|
|
11925
|
+
style: {
|
|
11926
|
+
width: displayState === "fullscreen" ? "100vw" : `${sidebarWidth}px`,
|
|
11927
|
+
maxWidth: displayState === "fullscreen" ? "100vw" : "calc(100vw - 8px)",
|
|
11928
|
+
minWidth: "360px"
|
|
11817
11929
|
}
|
|
11818
11930
|
},
|
|
11819
|
-
|
|
11931
|
+
children
|
|
11820
11932
|
)
|
|
11821
11933
|
);
|
|
11822
11934
|
};
|
|
11823
|
-
const
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
Icon: MdOutlinePhotoLibrary,
|
|
11827
|
-
layout: "fullscreen",
|
|
11828
|
-
props: {
|
|
11829
|
-
allowDelete: true
|
|
11830
|
-
}
|
|
11831
|
-
});
|
|
11832
|
-
function UpdatePassword(props) {
|
|
11833
|
-
const cms = useCMS$1();
|
|
11834
|
-
const client = cms.api.tina;
|
|
11835
|
-
const [password, setPassword] = useState("");
|
|
11836
|
-
const [confirmPassword, setConfirmPassword] = useState("");
|
|
11837
|
-
const [dirty, setDirty] = useState(false);
|
|
11838
|
-
const [result, setResult] = useState(null);
|
|
11839
|
-
const [formState, setFormState] = useState("idle");
|
|
11840
|
-
const [passwordChangeRequired, setPasswordChangeRequired] = useState(false);
|
|
11841
|
-
useEffect(() => {
|
|
11842
|
-
var _a;
|
|
11843
|
-
(_a = client == null ? void 0 : client.authProvider) == null ? void 0 : _a.getUser().then(
|
|
11844
|
-
(user) => setPasswordChangeRequired((user == null ? void 0 : user.passwordChangeRequired) ?? false)
|
|
11845
|
-
);
|
|
11846
|
-
}, []);
|
|
11847
|
-
let err = null;
|
|
11848
|
-
if (dirty && password !== confirmPassword) {
|
|
11849
|
-
err = "Passwords do not match";
|
|
11850
|
-
}
|
|
11851
|
-
if (dirty && !password) {
|
|
11852
|
-
err = "Please enter a password";
|
|
11853
|
-
}
|
|
11854
|
-
const updatePassword = async () => {
|
|
11855
|
-
var _a;
|
|
11856
|
-
setResult(null);
|
|
11857
|
-
setFormState("busy");
|
|
11858
|
-
const res = await cms.api.tina.request(
|
|
11859
|
-
`mutation($password: String!) { updatePassword(password: $password) }`,
|
|
11860
|
-
{
|
|
11861
|
-
variables: {
|
|
11862
|
-
password
|
|
11863
|
-
}
|
|
11864
|
-
}
|
|
11865
|
-
);
|
|
11866
|
-
if (!(res == null ? void 0 : res.updatePassword)) {
|
|
11867
|
-
setResult("Error updating password");
|
|
11868
|
-
} else {
|
|
11869
|
-
setDirty(false);
|
|
11870
|
-
setPassword("");
|
|
11871
|
-
setConfirmPassword("");
|
|
11872
|
-
setResult("Password updated");
|
|
11873
|
-
setPasswordChangeRequired(false);
|
|
11874
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
11875
|
-
(_a = client == null ? void 0 : client.authProvider) == null ? void 0 : _a.logout().then(async () => {
|
|
11876
|
-
if (typeof (client == null ? void 0 : client.onLogout) === "function") {
|
|
11877
|
-
await client.onLogout();
|
|
11878
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
11879
|
-
}
|
|
11880
|
-
window.location.href = new URL(window.location.href).pathname;
|
|
11881
|
-
}).catch((e) => console.error(e));
|
|
11882
|
-
}
|
|
11883
|
-
setFormState("idle");
|
|
11884
|
-
};
|
|
11885
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-center items-center h-full" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col space-y-8 p-6" }, passwordChangeRequired && /* @__PURE__ */ React__default.createElement("div", { className: "text-center text-red-500" }, "Your password has expired. Please update your password."), /* @__PURE__ */ React__default.createElement("label", { className: "block" }, /* @__PURE__ */ React__default.createElement("span", { className: "text-gray-700" }, "New Password"), /* @__PURE__ */ React__default.createElement(
|
|
11886
|
-
BaseTextField,
|
|
11887
|
-
{
|
|
11888
|
-
type: "password",
|
|
11889
|
-
name: "password",
|
|
11890
|
-
id: "password",
|
|
11891
|
-
placeholder: "Enter password",
|
|
11892
|
-
className: err ? "border-red-500" : "border-gray-300 focus:ring-indigo-500 focus:border-indigo-500",
|
|
11893
|
-
value: password,
|
|
11894
|
-
onKeyDown: () => {
|
|
11895
|
-
setDirty(true);
|
|
11896
|
-
setResult(null);
|
|
11897
|
-
},
|
|
11898
|
-
onChange: (e) => setPassword(e.target.value),
|
|
11899
|
-
required: true
|
|
11900
|
-
}
|
|
11901
|
-
)), /* @__PURE__ */ React__default.createElement("label", { className: "block" }, /* @__PURE__ */ React__default.createElement("span", { className: "text-gray-700" }, "Confirm New Password"), /* @__PURE__ */ React__default.createElement(
|
|
11902
|
-
BaseTextField,
|
|
11903
|
-
{
|
|
11904
|
-
type: "password",
|
|
11905
|
-
name: "confirmPassword",
|
|
11906
|
-
id: "confirmPassword",
|
|
11907
|
-
placeholder: "Confirm password",
|
|
11908
|
-
className: err ? "border-red-500" : "border-gray-300 focus:ring-indigo-500 focus:border-indigo-500",
|
|
11909
|
-
value: confirmPassword,
|
|
11910
|
-
onKeyDown: () => {
|
|
11911
|
-
setDirty(true);
|
|
11912
|
-
setResult(null);
|
|
11913
|
-
},
|
|
11914
|
-
onChange: (e) => setConfirmPassword(e.target.value),
|
|
11915
|
-
required: true
|
|
11916
|
-
}
|
|
11917
|
-
)), result && /* @__PURE__ */ React__default.createElement("div", { className: "text-center text-sm text-gray-500" }, result), err && /* @__PURE__ */ React__default.createElement("div", { className: "text-center text-sm text-red-500" }, err), /* @__PURE__ */ React__default.createElement(
|
|
11918
|
-
Button$1,
|
|
11935
|
+
const SidebarBody = ({ children }) => {
|
|
11936
|
+
return /* @__PURE__ */ React.createElement(
|
|
11937
|
+
"div",
|
|
11919
11938
|
{
|
|
11920
|
-
|
|
11921
|
-
disabled: err,
|
|
11922
|
-
variant: "primary",
|
|
11923
|
-
busy: formState === "busy"
|
|
11939
|
+
className: "relative left-0 w-full h-full flex flex-col items-stretch bg-white border-r border-gray-200 overflow-hidden"
|
|
11924
11940
|
},
|
|
11925
|
-
|
|
11926
|
-
)
|
|
11927
|
-
}
|
|
11928
|
-
const PasswordScreenPlugin = createScreen({
|
|
11929
|
-
name: "Change Password",
|
|
11930
|
-
Component: UpdatePassword,
|
|
11931
|
-
Icon: MdVpnKey,
|
|
11932
|
-
layout: "fullscreen",
|
|
11933
|
-
navCategory: "Account"
|
|
11934
|
-
});
|
|
11935
|
-
function createCloudConfig({
|
|
11936
|
-
...options
|
|
11937
|
-
}) {
|
|
11938
|
-
return {
|
|
11939
|
-
__type: "cloud-config",
|
|
11940
|
-
Icon: MdOutlineCloud,
|
|
11941
|
-
...options
|
|
11942
|
-
};
|
|
11943
|
-
}
|
|
11941
|
+
children
|
|
11942
|
+
);
|
|
11943
|
+
};
|
|
11944
11944
|
const DEFAULT_FIELDS = [
|
|
11945
11945
|
TextFieldPlugin,
|
|
11946
11946
|
TextareaFieldPlugin,
|
|
@@ -12028,7 +12028,7 @@ class TinaCMS extends CMS {
|
|
|
12028
12028
|
name: "Support",
|
|
12029
12029
|
link: {
|
|
12030
12030
|
text: "Support",
|
|
12031
|
-
href: "https
|
|
12031
|
+
href: "https://tina.io/docs/support"
|
|
12032
12032
|
},
|
|
12033
12033
|
Icon: MdOutlineHelpOutline
|
|
12034
12034
|
})
|