@kywi-software/js 0.6.1 → 0.6.3
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/audience/dom-patcher.d.ts.map +1 -1
- package/dist/audience/selfid-widget.d.ts +13 -2
- package/dist/audience/selfid-widget.d.ts.map +1 -1
- package/dist/kywi.esm.js +24 -4
- package/dist/kywi.esm.js.map +3 -3
- package/dist/kywi.js +24 -4
- package/dist/kywi.js.map +3 -3
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-patcher.d.ts","sourceRoot":"","sources":["../../src/audience/dom-patcher.ts"],"names":[],"mappings":"AACA,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"dom-patcher.d.ts","sourceRoot":"","sources":["../../src/audience/dom-patcher.ts"],"names":[],"mappings":"AACA,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAiC7E"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { Audience } from '@kywi-software/core/audiences/types';
|
|
2
|
+
/** A picklist option: the value submitted, and the label shown to the visitor. */
|
|
3
|
+
export interface SelfIdFieldOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
2
7
|
export interface SelfIdFieldConfig {
|
|
3
8
|
id: string;
|
|
4
9
|
label: string;
|
|
5
10
|
type: 'text' | 'select' | 'email';
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Either `{value, label}` pairs (current server shape — see
|
|
13
|
+
* resolveSelfIdWidget in the create-kywi-app scaffold) or bare strings (older
|
|
14
|
+
* config shape, kept for backward compatibility). A bare string is treated as
|
|
15
|
+
* both its own value and its own label.
|
|
16
|
+
*/
|
|
17
|
+
options?: Array<string | SelfIdFieldOption>;
|
|
7
18
|
required?: boolean;
|
|
8
19
|
}
|
|
9
20
|
/** When the widget is shown, once frequency allows. Defaults to immediate. */
|
|
@@ -24,7 +35,7 @@ export interface SelfIdWidgetConfig {
|
|
|
24
35
|
subheadline?: string;
|
|
25
36
|
submitLabel?: string;
|
|
26
37
|
skipLabel?: string;
|
|
27
|
-
displayMode?: 'modal' | 'inline' | 'slide-in';
|
|
38
|
+
displayMode?: 'modal' | 'inline' | 'slide-in' | 'hello_bar_top' | 'hello_bar_bottom' | 'drawer';
|
|
28
39
|
frequency?: 'once' | 'session' | 'daily' | 'always';
|
|
29
40
|
trigger?: SelfIdWidgetTrigger;
|
|
30
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selfid-widget.d.ts","sourceRoot":"","sources":["../../src/audience/selfid-widget.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"selfid-widget.d.ts","sourceRoot":"","sources":["../../src/audience/selfid-widget.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AAQnE,kFAAkF;AAClF,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IACjC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAA;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAOD,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAEtB,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,eAAe,GAAG,kBAAkB,GAAG,QAAQ,CAAA;IAC/F,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAA;IACnD,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,IAAI,OAAO,CAAA;IACrB,SAAS,IAAI,IAAI,CAAA;IACjB,MAAM,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAA;IACpC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;CACtD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAyJ3E"}
|
package/dist/kywi.esm.js
CHANGED
|
@@ -683,13 +683,15 @@ function patchVariantContainers(winningAudienceId) {
|
|
|
683
683
|
const containers = document.querySelectorAll(".kywi-variant-container");
|
|
684
684
|
for (const container of Array.from(containers)) {
|
|
685
685
|
const el = container;
|
|
686
|
+
const arms = Array.from(el.querySelectorAll("[data-kywi-variant]"));
|
|
687
|
+
if (arms.length === 0) continue;
|
|
686
688
|
el.classList.remove("kywi-variant-loading");
|
|
687
689
|
el.removeAttribute("aria-busy");
|
|
688
690
|
const skeleton = el.querySelector(".kywi-variant-skeleton");
|
|
689
691
|
if (skeleton) skeleton.remove();
|
|
690
692
|
const target = winningAudienceId ?? "default";
|
|
691
693
|
el.setAttribute("data-variant", target);
|
|
692
|
-
for (const child of
|
|
694
|
+
for (const child of arms) {
|
|
693
695
|
const h = child;
|
|
694
696
|
h.style.display = h.getAttribute("data-kywi-variant") === target ? "" : "none";
|
|
695
697
|
}
|
|
@@ -1015,6 +1017,10 @@ function handleSelfIdSubmit(responses, audiences, currentPath) {
|
|
|
1015
1017
|
// src/audience/selfid-widget.ts
|
|
1016
1018
|
var SHOWN_KEY = "kywi_selfid_shown";
|
|
1017
1019
|
var MS_PER_DAY = 864e5;
|
|
1020
|
+
var DISMISSIBLE_MODES = /* @__PURE__ */ new Set(["hello_bar_top", "hello_bar_bottom", "drawer"]);
|
|
1021
|
+
function normalizeOption(opt) {
|
|
1022
|
+
return typeof opt === "string" ? { value: opt, label: opt } : opt;
|
|
1023
|
+
}
|
|
1018
1024
|
function createSelfIdWidget(config) {
|
|
1019
1025
|
const frequency = config.frequency ?? "once";
|
|
1020
1026
|
const displayMode = config.displayMode ?? "inline";
|
|
@@ -1040,7 +1046,20 @@ function createSelfIdWidget(config) {
|
|
|
1040
1046
|
}
|
|
1041
1047
|
function render(container) {
|
|
1042
1048
|
container.replaceChildren();
|
|
1043
|
-
|
|
1049
|
+
const displayModeClass = displayMode.replace(/_/g, "-");
|
|
1050
|
+
container.className = `kywi-selfid-widget kywi-selfid-${displayModeClass}`;
|
|
1051
|
+
if (DISMISSIBLE_MODES.has(displayMode)) {
|
|
1052
|
+
const dismissBtn = document.createElement("button");
|
|
1053
|
+
dismissBtn.type = "button";
|
|
1054
|
+
dismissBtn.className = "kywi-selfid-dismiss";
|
|
1055
|
+
dismissBtn.setAttribute("aria-label", "Dismiss");
|
|
1056
|
+
dismissBtn.textContent = "\xD7";
|
|
1057
|
+
dismissBtn.addEventListener("click", () => {
|
|
1058
|
+
markShown();
|
|
1059
|
+
container.replaceChildren();
|
|
1060
|
+
});
|
|
1061
|
+
container.appendChild(dismissBtn);
|
|
1062
|
+
}
|
|
1044
1063
|
if (config.headline) {
|
|
1045
1064
|
const h = document.createElement("h3");
|
|
1046
1065
|
h.className = "kywi-selfid-headline";
|
|
@@ -1074,9 +1093,10 @@ function createSelfIdWidget(config) {
|
|
|
1074
1093
|
placeholder.textContent = "";
|
|
1075
1094
|
select.appendChild(placeholder);
|
|
1076
1095
|
for (const opt of field.options) {
|
|
1096
|
+
const { value, label: label2 } = normalizeOption(opt);
|
|
1077
1097
|
const option = document.createElement("option");
|
|
1078
|
-
option.value =
|
|
1079
|
-
option.textContent =
|
|
1098
|
+
option.value = value;
|
|
1099
|
+
option.textContent = label2;
|
|
1080
1100
|
select.appendChild(option);
|
|
1081
1101
|
}
|
|
1082
1102
|
}
|