@verbb/plugin-kit-web 2.0.11 → 2.0.12
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/CHANGELOG.md
CHANGED
|
@@ -56,6 +56,7 @@ var getErrorMessage = function(error, maxTraceLines = 5) {
|
|
|
56
56
|
};
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region ../plugin-kit-core/dist/utils/connect.js
|
|
59
|
+
var craftWindow = () => window;
|
|
59
60
|
var DEFAULT_FORM_SELECTOR = "#main-form";
|
|
60
61
|
var resolveCpForm = ({ formSelector = DEFAULT_FORM_SELECTOR, host } = {}) => {
|
|
61
62
|
if (formSelector) {
|
|
@@ -68,13 +69,15 @@ var resolveCpForm = ({ formSelector = DEFAULT_FORM_SELECTOR, host } = {}) => {
|
|
|
68
69
|
};
|
|
69
70
|
/** Escape text for CP dialog markup; prefers `Craft.escapeHtml` when available. */
|
|
70
71
|
var escapeCpHtml = (value) => {
|
|
71
|
-
|
|
72
|
+
const craft = craftWindow().Craft;
|
|
73
|
+
if (craft?.escapeHtml) return craft.escapeHtml(value);
|
|
72
74
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
73
75
|
};
|
|
74
76
|
/** POST a credentials connect/check controller action from the CP. */
|
|
75
77
|
var sendCpConnectRequest = (action, data) => {
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
+
const craft = craftWindow().Craft;
|
|
79
|
+
if (!craft?.sendActionRequest) return Promise.reject(/* @__PURE__ */ new Error("Craft.sendActionRequest is unavailable."));
|
|
80
|
+
return craft.sendActionRequest("POST", action, { data });
|
|
78
81
|
};
|
|
79
82
|
/**
|
|
80
83
|
* Serialize named CP form controls into a flat key → value map.
|
|
@@ -102,7 +105,7 @@ var buildConnectPayload = (values, options = {}) => {
|
|
|
102
105
|
const idParam = options.idParam ?? "sourceId";
|
|
103
106
|
const payload = { type };
|
|
104
107
|
payload[idParam] = values[idParam] ?? values.sourceId ?? values.id ?? options.sourceId;
|
|
105
|
-
const csrfTokenName = typeof window !== "undefined" ?
|
|
108
|
+
const csrfTokenName = typeof window !== "undefined" ? craftWindow().Craft?.csrfTokenName : void 0;
|
|
106
109
|
if (csrfTokenName && values[csrfTokenName]) payload[csrfTokenName] = values[csrfTokenName];
|
|
107
110
|
if (includeTypeNamespace && type) {
|
|
108
111
|
const prefix = `types[${type}]`;
|
|
@@ -161,8 +164,7 @@ var submitCpFormAction = ({ formSelector = DEFAULT_FORM_SELECTOR, host, action,
|
|
|
161
164
|
formSelector,
|
|
162
165
|
host
|
|
163
166
|
});
|
|
164
|
-
const craft =
|
|
165
|
-
const $ = window.$;
|
|
167
|
+
const { Craft: craft, $ } = craftWindow();
|
|
166
168
|
if (!form || typeof craft?.submitForm !== "function" || !$) return;
|
|
167
169
|
const params = {};
|
|
168
170
|
if (paramName && paramValue) params[paramName] = paramValue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as r, d as i, l as n, p as b, u as customElement } from "../../chunks/lit-DpLik9Rf.js";
|
|
2
2
|
import { c as __decorate } from "../../chunks/pk-base-B21zXxSo.js";
|
|
3
3
|
import "../../chunks/pk-button-Dh4gjLHw.js";
|
|
4
|
-
import { c as watchCpFormDirty, s as submitCpFormAction, t as pkConnectStyles } from "../../chunks/pk-connect.styles-
|
|
4
|
+
import { c as watchCpFormDirty, s as submitCpFormAction, t as pkConnectStyles } from "../../chunks/pk-connect.styles-Bfgwu0VH.js";
|
|
5
5
|
import "../../chunks/pk-status-BRIVW7EH.js";
|
|
6
6
|
//#region src/components/connect/pk-connect-oauth.ts
|
|
7
7
|
var PkConnectOauth = class PkConnectOauth extends i {
|
|
@@ -3,7 +3,7 @@ import { c as __decorate } from "../../chunks/pk-base-B21zXxSo.js";
|
|
|
3
3
|
import "../../chunks/pk-icon-B-OBmJ3K.js";
|
|
4
4
|
import "../../chunks/pk-button-Dh4gjLHw.js";
|
|
5
5
|
import "../../chunks/pk-dialog-BpPRqFMm.js";
|
|
6
|
-
import { a as sendCpConnectRequest, c as watchCpFormDirty, i as resolveConnectError, n as buildConnectPayload, o as serializeCpForm, r as escapeCpHtml, t as pkConnectStyles } from "../../chunks/pk-connect.styles-
|
|
6
|
+
import { a as sendCpConnectRequest, c as watchCpFormDirty, i as resolveConnectError, n as buildConnectPayload, o as serializeCpForm, r as escapeCpHtml, t as pkConnectStyles } from "../../chunks/pk-connect.styles-Bfgwu0VH.js";
|
|
7
7
|
import "../../chunks/pk-status-BRIVW7EH.js";
|
|
8
8
|
//#region src/components/connect/pk-connect.ts
|
|
9
9
|
var pkStatusForState = (status) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbb/plugin-kit-web",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Plugin Kit web components (shadow DOM, Craft design system)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -982,18 +982,18 @@
|
|
|
982
982
|
},
|
|
983
983
|
"peerDependencies": {
|
|
984
984
|
"@floating-ui/dom": "^1.7.3",
|
|
985
|
-
"@verbb/plugin-kit-core": "^2.0.
|
|
986
|
-
"@verbb/plugin-kit-icons": "^2.0.
|
|
985
|
+
"@verbb/plugin-kit-core": "^2.0.12",
|
|
986
|
+
"@verbb/plugin-kit-icons": "^2.0.12",
|
|
987
987
|
"lit": "^3.3.0"
|
|
988
988
|
},
|
|
989
989
|
"license": "MIT",
|
|
990
990
|
"dependencies": {
|
|
991
991
|
"@floating-ui/dom": "^1.7.3",
|
|
992
992
|
"@tiptap/core": "^3.22.4",
|
|
993
|
-
"@verbb/plugin-kit-codemirror-core": "2.0.
|
|
994
|
-
"@verbb/plugin-kit-core": "^2.0.
|
|
995
|
-
"@verbb/plugin-kit-icons": "^2.0.
|
|
996
|
-
"@verbb/plugin-kit-tiptap-core": "^2.0.
|
|
993
|
+
"@verbb/plugin-kit-codemirror-core": "2.0.12",
|
|
994
|
+
"@verbb/plugin-kit-core": "^2.0.12",
|
|
995
|
+
"@verbb/plugin-kit-icons": "^2.0.12",
|
|
996
|
+
"@verbb/plugin-kit-tiptap-core": "^2.0.12",
|
|
997
997
|
"composed-offset-position": "^0.0.6",
|
|
998
998
|
"lit": "^3.3.0"
|
|
999
999
|
},
|