bitsnap-automations 0.1.0 → 0.1.1
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 +23 -0
- package/chunks/{logic-C_-LFO2j.js → logic-DYkm-4Pc.js} +63 -4
- package/index.js +597 -259
- package/logic.js +1 -1
- package/messages/en.json +41 -1
- package/messages/pl.json +41 -1
- package/messages.js +82 -2
- package/package.json +2 -2
- package/styles.css +1 -1
- package/types/components/ScenarioEditor.d.ts +11 -4
- package/types/labels.d.ts +50 -2
- package/types/logic/catalog.d.ts +1 -1
- package/types/logic/scenario.d.ts +39 -1
- package/types/types.d.ts +30 -0
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { A as
|
|
2
|
+
import { $ as actionDefinition, A as sameEmailTemplateRef, B as ruleDestination, C as parseFieldPath, D as productNameFrom, E as placeholderErrorFromDetail, F as validateScenarioDraft, G as DELAY_MIN_SECONDS, H as ACTION_CATALOG, I as withNegativePersonaRule, J as MAX_ACTIONS_PER_SCENARIO, K as EVENT_GROUP_ORDER, L as withTriggerEvent, M as unknownActionDraft, N as urlHost, O as rootProductId, P as validateDelay, Q as actionApp, R as AI_DECISION_MODES, S as ownTextFromTemplate, T as picksNegativePersona, U as ACTION_KINDS, V as validateAiDecisionConfig, W as DELAY_MAX_SECONDS, X as RUN_STATUSES, Y as PICKER_APPS, Z as RUN_STATUS_FILTERS, _ as firstActionWithError, a as presentCategories, b as insertAt, c as templatesInCategory, d as baseProductName, f as delayFromSeconds, g as eventHasForm, h as emptyScenarioDraft, i as hasActiveFilters, j as unitSeconds, k as sameDraft, l as actionErrors, m as emptyActionDraft, n as createLabelDateFormat, o as templateMatches, p as delayToSeconds, q as FILTER_APPS, r as DEFAULT_SCENARIO_FILTERS, s as templateRequirements, t as createAutomationsLabels, u as availablePlaceholders, v as groupEvents, w as parsePlaceholderError, x as moveItem, y as groupProductResults, z as learningProgressKey } from "./chunks/logic-DYkm-4Pc.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { createContext, createElement, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -11969,6 +11969,56 @@ function VariantMultiField({ id, options, value, onChange, showProduct, disabled
|
|
|
11969
11969
|
})
|
|
11970
11970
|
});
|
|
11971
11971
|
}
|
|
11972
|
+
function OptionMultiField({ id, options, value, onChange, disabled, describedBy, invalid, texts }) {
|
|
11973
|
+
const [open, setOpen] = useState(false);
|
|
11974
|
+
const byId = new Map(options.map((option) => [option.id, option]));
|
|
11975
|
+
const toggle = (optionId) => onChange(value.includes(optionId) ? value.filter((v) => v !== optionId) : [...value, optionId]);
|
|
11976
|
+
const offered = options.filter((option) => !option.hidden);
|
|
11977
|
+
return /* @__PURE__ */ jsx(ChipField, {
|
|
11978
|
+
id,
|
|
11979
|
+
describedBy,
|
|
11980
|
+
invalid,
|
|
11981
|
+
disabled,
|
|
11982
|
+
placeholder: texts.all,
|
|
11983
|
+
placeholderAsChip: true,
|
|
11984
|
+
chips: value.map((optionId) => {
|
|
11985
|
+
const option = byId.get(optionId);
|
|
11986
|
+
return {
|
|
11987
|
+
id: optionId,
|
|
11988
|
+
label: option ? option.chip ?? option.name : texts.unknown
|
|
11989
|
+
};
|
|
11990
|
+
}),
|
|
11991
|
+
removeLabel: texts.remove,
|
|
11992
|
+
onRemove: (optionId) => onChange(value.filter((v) => v !== optionId)),
|
|
11993
|
+
renderTrigger: (trigger) => /* @__PURE__ */ jsxs(Popover, {
|
|
11994
|
+
open,
|
|
11995
|
+
onOpenChange: setOpen,
|
|
11996
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
11997
|
+
asChild: true,
|
|
11998
|
+
disabled,
|
|
11999
|
+
children: trigger
|
|
12000
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
12001
|
+
className: "w-[min(22rem,calc(100vw-2rem))] p-0",
|
|
12002
|
+
align: "end",
|
|
12003
|
+
children: /* @__PURE__ */ jsxs(Command, { children: [/* @__PURE__ */ jsx(CommandInput, { placeholder: texts.search }), /* @__PURE__ */ jsxs(CommandList, { children: [/* @__PURE__ */ jsx(CommandEmpty, { children: texts.none }), /* @__PURE__ */ jsx(CommandGroup, { children: offered.map((option) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
12004
|
+
value: `${option.name} ${option.detail ?? ""} ${option.id}`,
|
|
12005
|
+
onSelect: () => toggle(option.id),
|
|
12006
|
+
children: [
|
|
12007
|
+
value.includes(option.id) ? /* @__PURE__ */ jsx(Check, { className: "size-4" }) : /* @__PURE__ */ jsx("span", { className: "size-4" }),
|
|
12008
|
+
/* @__PURE__ */ jsx("span", {
|
|
12009
|
+
className: "line-clamp-1 min-w-0 flex-1",
|
|
12010
|
+
children: option.name
|
|
12011
|
+
}),
|
|
12012
|
+
option.detail && /* @__PURE__ */ jsx("span", {
|
|
12013
|
+
className: "text-muted-foreground shrink-0 text-xs",
|
|
12014
|
+
children: option.detail
|
|
12015
|
+
})
|
|
12016
|
+
]
|
|
12017
|
+
}, option.id)) })] })] })
|
|
12018
|
+
})]
|
|
12019
|
+
})
|
|
12020
|
+
});
|
|
12021
|
+
}
|
|
11972
12022
|
function groupBy(items, key) {
|
|
11973
12023
|
const map = /* @__PURE__ */ new Map();
|
|
11974
12024
|
for (const item of items) {
|
|
@@ -11977,13 +12027,14 @@ function groupBy(items, key) {
|
|
|
11977
12027
|
}
|
|
11978
12028
|
return [...map.entries()];
|
|
11979
12029
|
}
|
|
11980
|
-
function ChipField({ id, chips, placeholder, placeholderAsChip, removeLabel, onRemove, renderTrigger, disabled, describedBy }) {
|
|
12030
|
+
function ChipField({ id, chips, placeholder, placeholderAsChip, removeLabel, onRemove, renderTrigger, disabled, describedBy, invalid }) {
|
|
11981
12031
|
const triggerRef = useRef(null);
|
|
11982
12032
|
const trigger = /* @__PURE__ */ jsxs("button", {
|
|
11983
12033
|
ref: triggerRef,
|
|
11984
12034
|
id,
|
|
11985
12035
|
type: "button",
|
|
11986
12036
|
"aria-describedby": describedBy,
|
|
12037
|
+
"aria-invalid": invalid || void 0,
|
|
11987
12038
|
disabled,
|
|
11988
12039
|
className: "text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 flex h-9 shrink-0 items-center rounded-md px-2 outline-none focus-visible:ring-[3px] disabled:pointer-events-none",
|
|
11989
12040
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -11999,7 +12050,7 @@ function ChipField({ id, chips, placeholder, placeholderAsChip, removeLabel, onR
|
|
|
11999
12050
|
if (disabled || event.target.closest("button")) return;
|
|
12000
12051
|
triggerRef.current?.click();
|
|
12001
12052
|
},
|
|
12002
|
-
className: cn("border-input bg-background flex min-h-9 w-full cursor-pointer items-start gap-1 rounded-md border shadow-xs", disabled && "cursor-default opacity-60"),
|
|
12053
|
+
className: cn("border-input bg-background flex min-h-9 w-full cursor-pointer items-start gap-1 rounded-md border shadow-xs", invalid && "border-destructive", disabled && "cursor-default opacity-60"),
|
|
12003
12054
|
children: [/* @__PURE__ */ jsx("div", {
|
|
12004
12055
|
className: "flex min-w-0 flex-1 flex-wrap items-center gap-1 py-1 pl-1.5",
|
|
12005
12056
|
children: chips.length === 0 ? placeholderAsChip ? /* @__PURE__ */ jsx(Badge, {
|
|
@@ -13369,6 +13420,209 @@ async function settle(promise) {
|
|
|
13369
13420
|
function failureMessage(result) {
|
|
13370
13421
|
return result.status === "error" ? result.message : void 0;
|
|
13371
13422
|
}
|
|
13423
|
+
var __defProp$1 = Object.defineProperty;
|
|
13424
|
+
var __name$1 = (target, value) => __defProp$1(target, "name", {
|
|
13425
|
+
value,
|
|
13426
|
+
configurable: true
|
|
13427
|
+
});
|
|
13428
|
+
var CHECKBOX_NAME = "Checkbox";
|
|
13429
|
+
var [createCheckboxContext, createCheckboxScope] = /* @__PURE__ */ createContextScope(CHECKBOX_NAME);
|
|
13430
|
+
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
|
13431
|
+
function CheckboxProvider(props) {
|
|
13432
|
+
const { __scopeCheckbox, checked: checkedProp, children, defaultChecked, disabled, form, name, onCheckedChange, required, value = "on", internal_do_not_use_render } = props;
|
|
13433
|
+
const [checked, setChecked] = useControllableState({
|
|
13434
|
+
prop: checkedProp,
|
|
13435
|
+
defaultProp: defaultChecked ?? false,
|
|
13436
|
+
onChange: onCheckedChange,
|
|
13437
|
+
caller: CHECKBOX_NAME
|
|
13438
|
+
});
|
|
13439
|
+
const [control, setControl] = React.useState(null);
|
|
13440
|
+
const [bubbleInput, setBubbleInput] = React.useState(null);
|
|
13441
|
+
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
13442
|
+
const [userInteractionCount, onUserInteraction] = React.useReducer((count) => count + 1, 0);
|
|
13443
|
+
const isFormControl = control ? !!form || !!control.closest("form") : true;
|
|
13444
|
+
const context = {
|
|
13445
|
+
checked,
|
|
13446
|
+
disabled,
|
|
13447
|
+
setChecked,
|
|
13448
|
+
control,
|
|
13449
|
+
setControl,
|
|
13450
|
+
name,
|
|
13451
|
+
form,
|
|
13452
|
+
value,
|
|
13453
|
+
hasConsumerStoppedPropagationRef,
|
|
13454
|
+
userInteractionCount,
|
|
13455
|
+
onUserInteraction,
|
|
13456
|
+
required,
|
|
13457
|
+
defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
|
|
13458
|
+
isFormControl,
|
|
13459
|
+
bubbleInput,
|
|
13460
|
+
setBubbleInput
|
|
13461
|
+
};
|
|
13462
|
+
return /* @__PURE__ */ jsx(CheckboxProviderImpl, {
|
|
13463
|
+
scope: __scopeCheckbox,
|
|
13464
|
+
...context,
|
|
13465
|
+
children: isFunction$1(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
13466
|
+
});
|
|
13467
|
+
}
|
|
13468
|
+
__name$1(CheckboxProvider, "CheckboxProvider");
|
|
13469
|
+
var TRIGGER_NAME$1 = "CheckboxTrigger";
|
|
13470
|
+
var CheckboxTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1(function CheckboxTrigger2({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) {
|
|
13471
|
+
const { control, value, disabled, checked, required, setControl, setChecked, hasConsumerStoppedPropagationRef, onUserInteraction, isFormControl, bubbleInput } = useCheckboxContext(TRIGGER_NAME$1, __scopeCheckbox);
|
|
13472
|
+
const composedRefs = useComposedRefs(forwardedRef, setControl);
|
|
13473
|
+
const initialCheckedStateRef = React.useRef(checked);
|
|
13474
|
+
React.useEffect(() => {
|
|
13475
|
+
const form = control?.form;
|
|
13476
|
+
if (form) {
|
|
13477
|
+
const reset = /* @__PURE__ */ __name$1(() => setChecked(initialCheckedStateRef.current), "reset");
|
|
13478
|
+
form.addEventListener("reset", reset);
|
|
13479
|
+
return () => form.removeEventListener("reset", reset);
|
|
13480
|
+
}
|
|
13481
|
+
}, [control, setChecked]);
|
|
13482
|
+
return /* @__PURE__ */ jsx(Primitive.button, {
|
|
13483
|
+
type: "button",
|
|
13484
|
+
role: "checkbox",
|
|
13485
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
13486
|
+
"aria-required": required,
|
|
13487
|
+
"data-state": getState$1(checked),
|
|
13488
|
+
"data-disabled": disabled ? "" : void 0,
|
|
13489
|
+
disabled,
|
|
13490
|
+
value,
|
|
13491
|
+
...checkboxProps,
|
|
13492
|
+
ref: composedRefs,
|
|
13493
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
13494
|
+
if (event.key === "Enter") event.preventDefault();
|
|
13495
|
+
}),
|
|
13496
|
+
onClick: composeEventHandlers(onClick, (event) => {
|
|
13497
|
+
onUserInteraction();
|
|
13498
|
+
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
|
13499
|
+
if (bubbleInput && isFormControl) {
|
|
13500
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
13501
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
13502
|
+
}
|
|
13503
|
+
})
|
|
13504
|
+
});
|
|
13505
|
+
}, "CheckboxTrigger"));
|
|
13506
|
+
var Checkbox$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1(function Checkbox2(props, forwardedRef) {
|
|
13507
|
+
const { __scopeCheckbox, name, checked, defaultChecked, required, disabled, value, onCheckedChange, form, ...checkboxProps } = props;
|
|
13508
|
+
return /* @__PURE__ */ jsx(CheckboxProvider, {
|
|
13509
|
+
__scopeCheckbox,
|
|
13510
|
+
checked,
|
|
13511
|
+
defaultChecked,
|
|
13512
|
+
disabled,
|
|
13513
|
+
required,
|
|
13514
|
+
onCheckedChange,
|
|
13515
|
+
name,
|
|
13516
|
+
form,
|
|
13517
|
+
value,
|
|
13518
|
+
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CheckboxTrigger, {
|
|
13519
|
+
...checkboxProps,
|
|
13520
|
+
ref: forwardedRef,
|
|
13521
|
+
__scopeCheckbox
|
|
13522
|
+
}), isFormControl && /* @__PURE__ */ jsx(CheckboxBubbleInput, { __scopeCheckbox })] })
|
|
13523
|
+
});
|
|
13524
|
+
}, "Checkbox"));
|
|
13525
|
+
var INDICATOR_NAME$1 = "CheckboxIndicator";
|
|
13526
|
+
var CheckboxIndicator = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1(function CheckboxIndicator2(props, forwardedRef) {
|
|
13527
|
+
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
|
13528
|
+
const context = useCheckboxContext(INDICATOR_NAME$1, __scopeCheckbox);
|
|
13529
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
13530
|
+
present: forceMount || isIndeterminate(context.checked) || context.checked === true,
|
|
13531
|
+
children: /* @__PURE__ */ jsx(Primitive.span, {
|
|
13532
|
+
"data-state": getState$1(context.checked),
|
|
13533
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
13534
|
+
...indicatorProps,
|
|
13535
|
+
ref: forwardedRef,
|
|
13536
|
+
style: {
|
|
13537
|
+
pointerEvents: "none",
|
|
13538
|
+
...props.style
|
|
13539
|
+
}
|
|
13540
|
+
})
|
|
13541
|
+
});
|
|
13542
|
+
}, "CheckboxIndicator"));
|
|
13543
|
+
var BUBBLE_INPUT_NAME$1 = "CheckboxBubbleInput";
|
|
13544
|
+
var CheckboxBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1(function CheckboxBubbleInput2({ __scopeCheckbox, onClick, ...props }, forwardedRef) {
|
|
13545
|
+
const { control, hasConsumerStoppedPropagationRef, userInteractionCount, checked, defaultChecked, required, disabled, name, value, form, bubbleInput, setBubbleInput } = useCheckboxContext(BUBBLE_INPUT_NAME$1, __scopeCheckbox);
|
|
13546
|
+
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
|
|
13547
|
+
const controlSize = useSize(control);
|
|
13548
|
+
const shouldStopClickPropagationRef = React.useRef(false);
|
|
13549
|
+
const prevCheckedRef = React.useRef(checked);
|
|
13550
|
+
const prevUserInteractionCountRef = React.useRef(userInteractionCount);
|
|
13551
|
+
React.useEffect(() => {
|
|
13552
|
+
const input = bubbleInput;
|
|
13553
|
+
if (!input) return;
|
|
13554
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
13555
|
+
const setChecked = Object.getOwnPropertyDescriptor(inputProto, "checked").set;
|
|
13556
|
+
const isUserInteraction = userInteractionCount !== prevUserInteractionCountRef.current;
|
|
13557
|
+
prevUserInteractionCountRef.current = userInteractionCount;
|
|
13558
|
+
const checkedChanged = prevCheckedRef.current !== checked;
|
|
13559
|
+
prevCheckedRef.current = checked;
|
|
13560
|
+
const bubbles = !(isUserInteraction && hasConsumerStoppedPropagationRef.current);
|
|
13561
|
+
if (checkedChanged && setChecked) {
|
|
13562
|
+
shouldStopClickPropagationRef.current = !isUserInteraction;
|
|
13563
|
+
const event = new Event("click", { bubbles });
|
|
13564
|
+
input.indeterminate = isIndeterminate(checked);
|
|
13565
|
+
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
|
13566
|
+
input.dispatchEvent(event);
|
|
13567
|
+
shouldStopClickPropagationRef.current = false;
|
|
13568
|
+
}
|
|
13569
|
+
}, [
|
|
13570
|
+
bubbleInput,
|
|
13571
|
+
checked,
|
|
13572
|
+
hasConsumerStoppedPropagationRef,
|
|
13573
|
+
userInteractionCount
|
|
13574
|
+
]);
|
|
13575
|
+
const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
|
|
13576
|
+
return /* @__PURE__ */ jsx(Primitive.input, {
|
|
13577
|
+
type: "checkbox",
|
|
13578
|
+
"aria-hidden": true,
|
|
13579
|
+
defaultChecked: defaultChecked ?? defaultCheckedRef.current,
|
|
13580
|
+
required,
|
|
13581
|
+
disabled,
|
|
13582
|
+
name,
|
|
13583
|
+
value,
|
|
13584
|
+
form,
|
|
13585
|
+
...props,
|
|
13586
|
+
tabIndex: -1,
|
|
13587
|
+
ref: composedRefs,
|
|
13588
|
+
onClick: composeEventHandlers(onClick, (event) => {
|
|
13589
|
+
if (shouldStopClickPropagationRef.current) event.stopPropagation();
|
|
13590
|
+
}),
|
|
13591
|
+
style: {
|
|
13592
|
+
...props.style,
|
|
13593
|
+
...controlSize,
|
|
13594
|
+
position: "absolute",
|
|
13595
|
+
pointerEvents: "none",
|
|
13596
|
+
opacity: 0,
|
|
13597
|
+
margin: 0,
|
|
13598
|
+
transform: "translateX(-100%)"
|
|
13599
|
+
}
|
|
13600
|
+
});
|
|
13601
|
+
}, "CheckboxBubbleInput"));
|
|
13602
|
+
function isFunction$1(value) {
|
|
13603
|
+
return typeof value === "function";
|
|
13604
|
+
}
|
|
13605
|
+
__name$1(isFunction$1, "isFunction");
|
|
13606
|
+
function isIndeterminate(checked) {
|
|
13607
|
+
return checked === "indeterminate";
|
|
13608
|
+
}
|
|
13609
|
+
__name$1(isIndeterminate, "isIndeterminate");
|
|
13610
|
+
function getState$1(checked) {
|
|
13611
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
13612
|
+
}
|
|
13613
|
+
__name$1(getState$1, "getState");
|
|
13614
|
+
function Checkbox({ className, ...props }) {
|
|
13615
|
+
return /* @__PURE__ */ jsx(Checkbox$1, {
|
|
13616
|
+
"data-slot": "checkbox",
|
|
13617
|
+
className: cn("peer border-input dark:bg-field data-[state=checked]:bg-control data-[state=checked]:text-control-foreground dark:data-[state=checked]:bg-control data-[state=checked]:border-control focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
13618
|
+
...props,
|
|
13619
|
+
children: /* @__PURE__ */ jsx(CheckboxIndicator, {
|
|
13620
|
+
"data-slot": "checkbox-indicator",
|
|
13621
|
+
className: "flex items-center justify-center text-current transition-none",
|
|
13622
|
+
children: /* @__PURE__ */ jsx(Check, { className: "size-3.5" })
|
|
13623
|
+
})
|
|
13624
|
+
});
|
|
13625
|
+
}
|
|
13372
13626
|
const MIN_DOCKED_WIDTH_PX = 320;
|
|
13373
13627
|
const CENTER_THRESHOLD_RATIO = .72;
|
|
13374
13628
|
const CENTER_THRESHOLD_MAX_PX = 1040;
|
|
@@ -13570,8 +13824,8 @@ function SheetDescription({ className, ...props }) {
|
|
|
13570
13824
|
...props
|
|
13571
13825
|
});
|
|
13572
13826
|
}
|
|
13573
|
-
var __defProp
|
|
13574
|
-
var __name
|
|
13827
|
+
var __defProp = Object.defineProperty;
|
|
13828
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
13575
13829
|
value,
|
|
13576
13830
|
configurable: true
|
|
13577
13831
|
});
|
|
@@ -13599,24 +13853,24 @@ function RadioProvider(props) {
|
|
|
13599
13853
|
isFormControl: control ? !!form || !!control.closest("form") : true,
|
|
13600
13854
|
bubbleInput,
|
|
13601
13855
|
setBubbleInput,
|
|
13602
|
-
onCheck: /* @__PURE__ */ __name
|
|
13856
|
+
onCheck: /* @__PURE__ */ __name(() => onCheck?.(), "onCheck")
|
|
13603
13857
|
};
|
|
13604
13858
|
return /* @__PURE__ */ jsx(RadioProviderImpl, {
|
|
13605
13859
|
scope: __scopeRadio,
|
|
13606
13860
|
...context,
|
|
13607
|
-
children: isFunction
|
|
13861
|
+
children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
13608
13862
|
});
|
|
13609
13863
|
}
|
|
13610
|
-
__name
|
|
13611
|
-
var TRIGGER_NAME
|
|
13612
|
-
var RadioTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
13613
|
-
const { checked, disabled, value, setControl, onCheck, hasConsumerStoppedPropagationRef, onUserInteraction, isFormControl, bubbleInput } = useRadioContext(TRIGGER_NAME
|
|
13864
|
+
__name(RadioProvider, "RadioProvider");
|
|
13865
|
+
var TRIGGER_NAME = "RadioTrigger";
|
|
13866
|
+
var RadioTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioTrigger2({ __scopeRadio, onClick, ...radioProps }, forwardedRef) {
|
|
13867
|
+
const { checked, disabled, value, setControl, onCheck, hasConsumerStoppedPropagationRef, onUserInteraction, isFormControl, bubbleInput } = useRadioContext(TRIGGER_NAME, __scopeRadio);
|
|
13614
13868
|
const composedRefs = useComposedRefs(forwardedRef, setControl);
|
|
13615
13869
|
return /* @__PURE__ */ jsx(Primitive.button, {
|
|
13616
13870
|
type: "button",
|
|
13617
13871
|
role: "radio",
|
|
13618
13872
|
"aria-checked": checked,
|
|
13619
|
-
"data-state": getState
|
|
13873
|
+
"data-state": getState(checked),
|
|
13620
13874
|
"data-disabled": disabled ? "" : void 0,
|
|
13621
13875
|
disabled,
|
|
13622
13876
|
value,
|
|
@@ -13634,23 +13888,23 @@ var RadioTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1(fun
|
|
|
13634
13888
|
})
|
|
13635
13889
|
});
|
|
13636
13890
|
}, "RadioTrigger"));
|
|
13637
|
-
var INDICATOR_NAME
|
|
13638
|
-
var RadioIndicator = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
13891
|
+
var INDICATOR_NAME = "RadioIndicator";
|
|
13892
|
+
var RadioIndicator = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioIndicator2(props, forwardedRef) {
|
|
13639
13893
|
const { __scopeRadio, forceMount, ...indicatorProps } = props;
|
|
13640
|
-
const context = useRadioContext(INDICATOR_NAME
|
|
13894
|
+
const context = useRadioContext(INDICATOR_NAME, __scopeRadio);
|
|
13641
13895
|
return /* @__PURE__ */ jsx(Presence, {
|
|
13642
13896
|
present: forceMount || context.checked,
|
|
13643
13897
|
children: /* @__PURE__ */ jsx(Primitive.span, {
|
|
13644
|
-
"data-state": getState
|
|
13898
|
+
"data-state": getState(context.checked),
|
|
13645
13899
|
"data-disabled": context.disabled ? "" : void 0,
|
|
13646
13900
|
...indicatorProps,
|
|
13647
13901
|
ref: forwardedRef
|
|
13648
13902
|
})
|
|
13649
13903
|
});
|
|
13650
13904
|
}, "RadioIndicator"));
|
|
13651
|
-
var BUBBLE_INPUT_NAME
|
|
13652
|
-
var RadioBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
13653
|
-
const { control, checked, required, disabled, name, value, form, bubbleInput, setBubbleInput, hasConsumerStoppedPropagationRef, userInteractionCount } = useRadioContext(BUBBLE_INPUT_NAME
|
|
13905
|
+
var BUBBLE_INPUT_NAME = "RadioBubbleInput";
|
|
13906
|
+
var RadioBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioBubbleInput2({ __scopeRadio, onClick, ...props }, forwardedRef) {
|
|
13907
|
+
const { control, checked, required, disabled, name, value, form, bubbleInput, setBubbleInput, hasConsumerStoppedPropagationRef, userInteractionCount } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);
|
|
13654
13908
|
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
|
|
13655
13909
|
const controlSize = useSize(control);
|
|
13656
13910
|
const shouldStopClickPropagationRef = React.useRef(false);
|
|
@@ -13706,14 +13960,14 @@ var RadioBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1
|
|
|
13706
13960
|
}
|
|
13707
13961
|
});
|
|
13708
13962
|
}, "RadioBubbleInput"));
|
|
13709
|
-
function isFunction
|
|
13963
|
+
function isFunction(value) {
|
|
13710
13964
|
return typeof value === "function";
|
|
13711
13965
|
}
|
|
13712
|
-
__name
|
|
13713
|
-
function getState
|
|
13966
|
+
__name(isFunction, "isFunction");
|
|
13967
|
+
function getState(checked) {
|
|
13714
13968
|
return checked ? "checked" : "unchecked";
|
|
13715
13969
|
}
|
|
13716
|
-
__name
|
|
13970
|
+
__name(getState, "getState");
|
|
13717
13971
|
var ARROW_KEYS = [
|
|
13718
13972
|
"ArrowUp",
|
|
13719
13973
|
"ArrowDown",
|
|
@@ -13725,7 +13979,7 @@ var [createRadioGroupContext, createRadioGroupScope] = /* @__PURE__ */ createCon
|
|
|
13725
13979
|
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
13726
13980
|
var useRadioScope = createRadioScope();
|
|
13727
13981
|
var [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
|
|
13728
|
-
var RadioGroup$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
13982
|
+
var RadioGroup$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioGroup2(props, forwardedRef) {
|
|
13729
13983
|
const { __scopeRadioGroup, name, form, defaultValue, value: valueProp, required = false, disabled = false, orientation, dir, loop = true, onValueChange, ...groupProps } = props;
|
|
13730
13984
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
|
|
13731
13985
|
const direction = useDirection(dir);
|
|
@@ -13741,7 +13995,7 @@ var RadioGroup$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1(fun
|
|
|
13741
13995
|
React.useEffect(() => {
|
|
13742
13996
|
const associatedForm = form ? control?.ownerDocument.getElementById(form) : control?.closest("form");
|
|
13743
13997
|
if (associatedForm instanceof HTMLFormElement) {
|
|
13744
|
-
const reset = /* @__PURE__ */ __name
|
|
13998
|
+
const reset = /* @__PURE__ */ __name(() => setValue(initialValueRef.current), "reset");
|
|
13745
13999
|
associatedForm.addEventListener("reset", reset);
|
|
13746
14000
|
return () => associatedForm.removeEventListener("reset", reset);
|
|
13747
14001
|
}
|
|
@@ -13796,8 +14050,8 @@ function RadioGroupItemProvider(props) {
|
|
|
13796
14050
|
children
|
|
13797
14051
|
});
|
|
13798
14052
|
}
|
|
13799
|
-
__name
|
|
13800
|
-
var RadioGroupItemTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
14053
|
+
__name(RadioGroupItemProvider, "RadioGroupItemProvider");
|
|
14054
|
+
var RadioGroupItemTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioGroupItemTrigger2(props, forwardedRef) {
|
|
13801
14055
|
const { __scopeRadioGroup, ...triggerProps } = props;
|
|
13802
14056
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
|
|
13803
14057
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
@@ -13806,10 +14060,10 @@ var RadioGroupItemTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __n
|
|
|
13806
14060
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
13807
14061
|
const isArrowKeyPressedRef = React.useRef(false);
|
|
13808
14062
|
React.useEffect(() => {
|
|
13809
|
-
const handleKeyDown = /* @__PURE__ */ __name
|
|
14063
|
+
const handleKeyDown = /* @__PURE__ */ __name((event) => {
|
|
13810
14064
|
if (ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
|
|
13811
14065
|
}, "handleKeyDown");
|
|
13812
|
-
const handleKeyUp = /* @__PURE__ */ __name
|
|
14066
|
+
const handleKeyUp = /* @__PURE__ */ __name(() => isArrowKeyPressedRef.current = false, "handleKeyUp");
|
|
13813
14067
|
document.addEventListener("keydown", handleKeyDown);
|
|
13814
14068
|
document.addEventListener("keyup", handleKeyUp);
|
|
13815
14069
|
return () => {
|
|
@@ -13835,7 +14089,7 @@ var RadioGroupItemTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __n
|
|
|
13835
14089
|
})
|
|
13836
14090
|
});
|
|
13837
14091
|
}, "RadioGroupItemTrigger"));
|
|
13838
|
-
var RadioGroupItem$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
14092
|
+
var RadioGroupItem$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioGroupItem2(props, forwardedRef) {
|
|
13839
14093
|
const { __scopeRadioGroup, value, disabled, ...itemProps } = props;
|
|
13840
14094
|
return /* @__PURE__ */ jsx(RadioGroupItemProvider, {
|
|
13841
14095
|
__scopeRadioGroup,
|
|
@@ -13848,7 +14102,7 @@ var RadioGroupItem$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name$1
|
|
|
13848
14102
|
}), isFormControl && /* @__PURE__ */ jsx(RadioGroupItemBubbleInput, { __scopeRadioGroup })] })
|
|
13849
14103
|
});
|
|
13850
14104
|
}, "RadioGroupItem"));
|
|
13851
|
-
var RadioGroupItemBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
14105
|
+
var RadioGroupItemBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioGroupItemBubbleInput2(props, forwardedRef) {
|
|
13852
14106
|
const { __scopeRadioGroup, ...bubbleProps } = props;
|
|
13853
14107
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
13854
14108
|
return /* @__PURE__ */ jsx(RadioBubbleInput, {
|
|
@@ -13857,7 +14111,7 @@ var RadioGroupItemBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */
|
|
|
13857
14111
|
ref: forwardedRef
|
|
13858
14112
|
});
|
|
13859
14113
|
}, "RadioGroupItemBubbleInput"));
|
|
13860
|
-
var RadioGroupIndicator = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name
|
|
14114
|
+
var RadioGroupIndicator = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function RadioGroupIndicator2(props, forwardedRef) {
|
|
13861
14115
|
const { __scopeRadioGroup, ...indicatorProps } = props;
|
|
13862
14116
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
13863
14117
|
return /* @__PURE__ */ jsx(RadioIndicator, {
|
|
@@ -14136,6 +14390,55 @@ function AiSimulation({ config, labels, simulate }) {
|
|
|
14136
14390
|
})]
|
|
14137
14391
|
});
|
|
14138
14392
|
}
|
|
14393
|
+
const SHEET_FILTER_LABEL_DEFAULTS = {
|
|
14394
|
+
forms: "Formularz",
|
|
14395
|
+
formsAll: "Wszystkie formularze",
|
|
14396
|
+
formsHint: "Jeśli nie wybierzesz formularza, scenariusz uruchomi się dla zgłoszeń z każdego.",
|
|
14397
|
+
formSearch: "Szukaj formularza…",
|
|
14398
|
+
formNone: "Brak pasujących formularzy.",
|
|
14399
|
+
formRemove: (name) => `Usuń ${name}`,
|
|
14400
|
+
formsLoadFailed: "Nie udało się wczytać formularzy.",
|
|
14401
|
+
formDeleted: "Usunięty formularz",
|
|
14402
|
+
personas: "Persona",
|
|
14403
|
+
personasAll: "Bez filtra persony",
|
|
14404
|
+
personasHint: "Jeśli wybierzesz persony, scenariusz uruchomi się tylko dla klientów z jedną z nich.",
|
|
14405
|
+
personasRulesOnly: "Przy nowym zgłoszeniu persona pochodzi tylko z reguł, w chwili zgłoszenia. Personę przypisaną później, ręcznie albo po potwierdzeniu, łapie zdarzenie „Klient dostał personę”.",
|
|
14406
|
+
personaSearch: "Szukaj persony…",
|
|
14407
|
+
personaNone: "Brak pasujących person.",
|
|
14408
|
+
personaRemove: (name) => `Usuń ${name}`,
|
|
14409
|
+
personasLoadFailed: "Nie udało się wczytać person.",
|
|
14410
|
+
personasEmpty: "Nie masz jeszcze person. Opisz grupy klientów, a każdej wyślesz inną wiadomość.",
|
|
14411
|
+
personasEmptyLink: "Dodaj persony",
|
|
14412
|
+
personaNegative: "negatywna",
|
|
14413
|
+
personaInactive: (name) => `${name} (nieaktywna)`,
|
|
14414
|
+
personaDeleted: "Usunięta persona",
|
|
14415
|
+
skipNegative: "Pomiń personę negatywną",
|
|
14416
|
+
skipNegativeHint: (name) => `Klienci z personą „${name}” nie dostaną tej automatyzacji.`,
|
|
14417
|
+
skipNegativePicked: (name) => `Filtr wybiera personę „${name}”, więc scenariusz jej nie pomija. Usuń ją z filtra, aby znów ją pominąć.`
|
|
14418
|
+
};
|
|
14419
|
+
const SEND_EMAIL_LABEL_DEFAULTS = {
|
|
14420
|
+
insertPersona: "Persona",
|
|
14421
|
+
insertPersonaHint: "Klient zobaczy to, co wstawisz. Nazwa persony jest zwykle tylko dla Ciebie i zespołu, więc w mailu do klienta lepiej sprawdzi się opis.",
|
|
14422
|
+
insertAnswers: "Odpowiedzi z formularza",
|
|
14423
|
+
insertAnswersNeedForm: "Wybierz formularz w filtrach wyżej, a wstawisz odpowiedzi z niego, np. formę działalności.",
|
|
14424
|
+
insertAnswersFailed: "Nie udało się wczytać pytań formularza.",
|
|
14425
|
+
insertAnswersHint: "Długie odpowiedzi skracamy do 200 znaków."
|
|
14426
|
+
};
|
|
14427
|
+
const FILTER_ERROR_LABEL_DEFAULTS = {
|
|
14428
|
+
formsNotApplicable: "To zdarzenie nie dotyczy formularzy. Usuń wybrane formularze albo zmień zdarzenie.",
|
|
14429
|
+
formsInvalid: "Wybrano za dużo formularzy (najwyżej 50) albo formularz ma zły identyfikator.",
|
|
14430
|
+
formUnknown: "Jednego z wybranych formularzy już nie ma. Usuń go z filtra.",
|
|
14431
|
+
personasInvalid: "Wybrano za dużo person (najwyżej 20) albo persona ma zły identyfikator.",
|
|
14432
|
+
personaUnknown: "Jednej z wybranych person już nie ma. Usuń ją z filtra."
|
|
14433
|
+
};
|
|
14434
|
+
function withLabelDefaults(labels, defaults) {
|
|
14435
|
+
const out = {
|
|
14436
|
+
...defaults,
|
|
14437
|
+
...labels
|
|
14438
|
+
};
|
|
14439
|
+
for (const key of Object.keys(defaults)) if (labels[key] === void 0) out[key] = defaults[key];
|
|
14440
|
+
return out;
|
|
14441
|
+
}
|
|
14139
14442
|
function isConnected(def, apps) {
|
|
14140
14443
|
if (!def.requiresApp) return true;
|
|
14141
14444
|
const app = apps.get(def.requiresApp);
|
|
@@ -15040,7 +15343,36 @@ function OwnEmailFields({ action, errors, onChange, readOnly, context }) {
|
|
|
15040
15343
|
value: action.body,
|
|
15041
15344
|
onChange: (e) => onChange({ body: e.target.value }),
|
|
15042
15345
|
className: "leading-relaxed"
|
|
15043
|
-
}), !readOnly && context.placeholders && /* @__PURE__ */
|
|
15346
|
+
}), !readOnly && context.placeholders && /* @__PURE__ */ jsx(PlaceholderChips, {
|
|
15347
|
+
placeholders,
|
|
15348
|
+
labels,
|
|
15349
|
+
answersNeedForm: context.answersNeedForm === true,
|
|
15350
|
+
answersFailed: context.answersFailed === true,
|
|
15351
|
+
onInsert: insert
|
|
15352
|
+
})]
|
|
15353
|
+
})
|
|
15354
|
+
})] });
|
|
15355
|
+
}
|
|
15356
|
+
function PlaceholderChips({ placeholders, labels: hostLabels, answersNeedForm, answersFailed, onInsert }) {
|
|
15357
|
+
const labels = withLabelDefaults(hostLabels, SEND_EMAIL_LABEL_DEFAULTS);
|
|
15358
|
+
const own = placeholders.filter((placeholder) => !placeholder.group);
|
|
15359
|
+
const persona = placeholders.filter((placeholder) => placeholder.group === "persona");
|
|
15360
|
+
const answers = placeholders.filter((placeholder) => placeholder.group === "answers");
|
|
15361
|
+
const chip = (placeholder) => {
|
|
15362
|
+
const token = `{{${placeholder.key}}}`;
|
|
15363
|
+
return /* @__PURE__ */ jsx("button", {
|
|
15364
|
+
type: "button",
|
|
15365
|
+
title: token,
|
|
15366
|
+
"aria-label": labels.insertLabel(token),
|
|
15367
|
+
onClick: () => onInsert(token),
|
|
15368
|
+
className: "bg-muted hover:bg-accent focus-visible:ring-ring/50 max-w-full truncate rounded px-1.5 py-0.5 text-xs outline-none focus-visible:ring-2",
|
|
15369
|
+
children: placeholder.label
|
|
15370
|
+
}, placeholder.key);
|
|
15371
|
+
};
|
|
15372
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
15373
|
+
className: "space-y-2",
|
|
15374
|
+
children: [
|
|
15375
|
+
/* @__PURE__ */ jsxs("div", {
|
|
15044
15376
|
className: "flex flex-wrap items-center gap-1",
|
|
15045
15377
|
children: [
|
|
15046
15378
|
/* @__PURE__ */ jsx("span", {
|
|
@@ -15051,21 +15383,52 @@ function OwnEmailFields({ action, errors, onChange, readOnly, context }) {
|
|
|
15051
15383
|
className: "text-muted-foreground text-xs",
|
|
15052
15384
|
children: labels.insertNone
|
|
15053
15385
|
}),
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15386
|
+
own.map(chip)
|
|
15387
|
+
]
|
|
15388
|
+
}),
|
|
15389
|
+
persona.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
15390
|
+
className: "space-y-1",
|
|
15391
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
15392
|
+
className: "flex flex-wrap items-center gap-1",
|
|
15393
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
15394
|
+
className: "text-muted-foreground mr-1 text-xs",
|
|
15395
|
+
children: labels.insertPersona
|
|
15396
|
+
}), persona.map(chip)]
|
|
15397
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
15398
|
+
className: "text-muted-foreground text-xs text-pretty",
|
|
15399
|
+
children: labels.insertPersonaHint
|
|
15400
|
+
})]
|
|
15401
|
+
}),
|
|
15402
|
+
(answers.length > 0 || answersNeedForm || answersFailed) && /* @__PURE__ */ jsxs("div", {
|
|
15403
|
+
className: "space-y-1",
|
|
15404
|
+
children: [
|
|
15405
|
+
/* @__PURE__ */ jsxs("div", {
|
|
15406
|
+
className: "flex flex-wrap items-center gap-1",
|
|
15407
|
+
children: [
|
|
15408
|
+
/* @__PURE__ */ jsx("span", {
|
|
15409
|
+
className: "text-muted-foreground mr-1 text-xs",
|
|
15410
|
+
children: labels.insertAnswers
|
|
15411
|
+
}),
|
|
15412
|
+
answers.map(chip),
|
|
15413
|
+
answers.length === 0 && answersNeedForm && /* @__PURE__ */ jsx("span", {
|
|
15414
|
+
className: "text-muted-foreground text-xs text-pretty",
|
|
15415
|
+
children: labels.insertAnswersNeedForm
|
|
15416
|
+
})
|
|
15417
|
+
]
|
|
15418
|
+
}),
|
|
15419
|
+
answersFailed && /* @__PURE__ */ jsx("p", {
|
|
15420
|
+
role: "status",
|
|
15421
|
+
className: "text-destructive-text text-xs text-pretty",
|
|
15422
|
+
children: labels.insertAnswersFailed
|
|
15423
|
+
}),
|
|
15424
|
+
answers.length > 0 && /* @__PURE__ */ jsx("p", {
|
|
15425
|
+
className: "text-muted-foreground text-xs text-pretty",
|
|
15426
|
+
children: labels.insertAnswersHint
|
|
15064
15427
|
})
|
|
15065
15428
|
]
|
|
15066
|
-
})
|
|
15067
|
-
|
|
15068
|
-
})
|
|
15429
|
+
})
|
|
15430
|
+
]
|
|
15431
|
+
});
|
|
15069
15432
|
}
|
|
15070
15433
|
function DelayFields({ action, error, onChange, labels, errorText }) {
|
|
15071
15434
|
const id = useId();
|
|
@@ -15126,209 +15489,6 @@ function DelayFields({ action, error, onChange, labels, errorText }) {
|
|
|
15126
15489
|
]
|
|
15127
15490
|
});
|
|
15128
15491
|
}
|
|
15129
|
-
var __defProp = Object.defineProperty;
|
|
15130
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
15131
|
-
value,
|
|
15132
|
-
configurable: true
|
|
15133
|
-
});
|
|
15134
|
-
var CHECKBOX_NAME = "Checkbox";
|
|
15135
|
-
var [createCheckboxContext, createCheckboxScope] = /* @__PURE__ */ createContextScope(CHECKBOX_NAME);
|
|
15136
|
-
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
|
15137
|
-
function CheckboxProvider(props) {
|
|
15138
|
-
const { __scopeCheckbox, checked: checkedProp, children, defaultChecked, disabled, form, name, onCheckedChange, required, value = "on", internal_do_not_use_render } = props;
|
|
15139
|
-
const [checked, setChecked] = useControllableState({
|
|
15140
|
-
prop: checkedProp,
|
|
15141
|
-
defaultProp: defaultChecked ?? false,
|
|
15142
|
-
onChange: onCheckedChange,
|
|
15143
|
-
caller: CHECKBOX_NAME
|
|
15144
|
-
});
|
|
15145
|
-
const [control, setControl] = React.useState(null);
|
|
15146
|
-
const [bubbleInput, setBubbleInput] = React.useState(null);
|
|
15147
|
-
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
15148
|
-
const [userInteractionCount, onUserInteraction] = React.useReducer((count) => count + 1, 0);
|
|
15149
|
-
const isFormControl = control ? !!form || !!control.closest("form") : true;
|
|
15150
|
-
const context = {
|
|
15151
|
-
checked,
|
|
15152
|
-
disabled,
|
|
15153
|
-
setChecked,
|
|
15154
|
-
control,
|
|
15155
|
-
setControl,
|
|
15156
|
-
name,
|
|
15157
|
-
form,
|
|
15158
|
-
value,
|
|
15159
|
-
hasConsumerStoppedPropagationRef,
|
|
15160
|
-
userInteractionCount,
|
|
15161
|
-
onUserInteraction,
|
|
15162
|
-
required,
|
|
15163
|
-
defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
|
|
15164
|
-
isFormControl,
|
|
15165
|
-
bubbleInput,
|
|
15166
|
-
setBubbleInput
|
|
15167
|
-
};
|
|
15168
|
-
return /* @__PURE__ */ jsx(CheckboxProviderImpl, {
|
|
15169
|
-
scope: __scopeCheckbox,
|
|
15170
|
-
...context,
|
|
15171
|
-
children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
15172
|
-
});
|
|
15173
|
-
}
|
|
15174
|
-
__name(CheckboxProvider, "CheckboxProvider");
|
|
15175
|
-
var TRIGGER_NAME = "CheckboxTrigger";
|
|
15176
|
-
var CheckboxTrigger = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function CheckboxTrigger2({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) {
|
|
15177
|
-
const { control, value, disabled, checked, required, setControl, setChecked, hasConsumerStoppedPropagationRef, onUserInteraction, isFormControl, bubbleInput } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
|
|
15178
|
-
const composedRefs = useComposedRefs(forwardedRef, setControl);
|
|
15179
|
-
const initialCheckedStateRef = React.useRef(checked);
|
|
15180
|
-
React.useEffect(() => {
|
|
15181
|
-
const form = control?.form;
|
|
15182
|
-
if (form) {
|
|
15183
|
-
const reset = /* @__PURE__ */ __name(() => setChecked(initialCheckedStateRef.current), "reset");
|
|
15184
|
-
form.addEventListener("reset", reset);
|
|
15185
|
-
return () => form.removeEventListener("reset", reset);
|
|
15186
|
-
}
|
|
15187
|
-
}, [control, setChecked]);
|
|
15188
|
-
return /* @__PURE__ */ jsx(Primitive.button, {
|
|
15189
|
-
type: "button",
|
|
15190
|
-
role: "checkbox",
|
|
15191
|
-
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
15192
|
-
"aria-required": required,
|
|
15193
|
-
"data-state": getState(checked),
|
|
15194
|
-
"data-disabled": disabled ? "" : void 0,
|
|
15195
|
-
disabled,
|
|
15196
|
-
value,
|
|
15197
|
-
...checkboxProps,
|
|
15198
|
-
ref: composedRefs,
|
|
15199
|
-
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
15200
|
-
if (event.key === "Enter") event.preventDefault();
|
|
15201
|
-
}),
|
|
15202
|
-
onClick: composeEventHandlers(onClick, (event) => {
|
|
15203
|
-
onUserInteraction();
|
|
15204
|
-
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
|
15205
|
-
if (bubbleInput && isFormControl) {
|
|
15206
|
-
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
15207
|
-
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
15208
|
-
}
|
|
15209
|
-
})
|
|
15210
|
-
});
|
|
15211
|
-
}, "CheckboxTrigger"));
|
|
15212
|
-
var Checkbox$1 = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function Checkbox2(props, forwardedRef) {
|
|
15213
|
-
const { __scopeCheckbox, name, checked, defaultChecked, required, disabled, value, onCheckedChange, form, ...checkboxProps } = props;
|
|
15214
|
-
return /* @__PURE__ */ jsx(CheckboxProvider, {
|
|
15215
|
-
__scopeCheckbox,
|
|
15216
|
-
checked,
|
|
15217
|
-
defaultChecked,
|
|
15218
|
-
disabled,
|
|
15219
|
-
required,
|
|
15220
|
-
onCheckedChange,
|
|
15221
|
-
name,
|
|
15222
|
-
form,
|
|
15223
|
-
value,
|
|
15224
|
-
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CheckboxTrigger, {
|
|
15225
|
-
...checkboxProps,
|
|
15226
|
-
ref: forwardedRef,
|
|
15227
|
-
__scopeCheckbox
|
|
15228
|
-
}), isFormControl && /* @__PURE__ */ jsx(CheckboxBubbleInput, { __scopeCheckbox })] })
|
|
15229
|
-
});
|
|
15230
|
-
}, "Checkbox"));
|
|
15231
|
-
var INDICATOR_NAME = "CheckboxIndicator";
|
|
15232
|
-
var CheckboxIndicator = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function CheckboxIndicator2(props, forwardedRef) {
|
|
15233
|
-
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
|
15234
|
-
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
|
15235
|
-
return /* @__PURE__ */ jsx(Presence, {
|
|
15236
|
-
present: forceMount || isIndeterminate(context.checked) || context.checked === true,
|
|
15237
|
-
children: /* @__PURE__ */ jsx(Primitive.span, {
|
|
15238
|
-
"data-state": getState(context.checked),
|
|
15239
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
15240
|
-
...indicatorProps,
|
|
15241
|
-
ref: forwardedRef,
|
|
15242
|
-
style: {
|
|
15243
|
-
pointerEvents: "none",
|
|
15244
|
-
...props.style
|
|
15245
|
-
}
|
|
15246
|
-
})
|
|
15247
|
-
});
|
|
15248
|
-
}, "CheckboxIndicator"));
|
|
15249
|
-
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
|
|
15250
|
-
var CheckboxBubbleInput = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function CheckboxBubbleInput2({ __scopeCheckbox, onClick, ...props }, forwardedRef) {
|
|
15251
|
-
const { control, hasConsumerStoppedPropagationRef, userInteractionCount, checked, defaultChecked, required, disabled, name, value, form, bubbleInput, setBubbleInput } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
|
|
15252
|
-
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
|
|
15253
|
-
const controlSize = useSize(control);
|
|
15254
|
-
const shouldStopClickPropagationRef = React.useRef(false);
|
|
15255
|
-
const prevCheckedRef = React.useRef(checked);
|
|
15256
|
-
const prevUserInteractionCountRef = React.useRef(userInteractionCount);
|
|
15257
|
-
React.useEffect(() => {
|
|
15258
|
-
const input = bubbleInput;
|
|
15259
|
-
if (!input) return;
|
|
15260
|
-
const inputProto = window.HTMLInputElement.prototype;
|
|
15261
|
-
const setChecked = Object.getOwnPropertyDescriptor(inputProto, "checked").set;
|
|
15262
|
-
const isUserInteraction = userInteractionCount !== prevUserInteractionCountRef.current;
|
|
15263
|
-
prevUserInteractionCountRef.current = userInteractionCount;
|
|
15264
|
-
const checkedChanged = prevCheckedRef.current !== checked;
|
|
15265
|
-
prevCheckedRef.current = checked;
|
|
15266
|
-
const bubbles = !(isUserInteraction && hasConsumerStoppedPropagationRef.current);
|
|
15267
|
-
if (checkedChanged && setChecked) {
|
|
15268
|
-
shouldStopClickPropagationRef.current = !isUserInteraction;
|
|
15269
|
-
const event = new Event("click", { bubbles });
|
|
15270
|
-
input.indeterminate = isIndeterminate(checked);
|
|
15271
|
-
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
|
15272
|
-
input.dispatchEvent(event);
|
|
15273
|
-
shouldStopClickPropagationRef.current = false;
|
|
15274
|
-
}
|
|
15275
|
-
}, [
|
|
15276
|
-
bubbleInput,
|
|
15277
|
-
checked,
|
|
15278
|
-
hasConsumerStoppedPropagationRef,
|
|
15279
|
-
userInteractionCount
|
|
15280
|
-
]);
|
|
15281
|
-
const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
|
|
15282
|
-
return /* @__PURE__ */ jsx(Primitive.input, {
|
|
15283
|
-
type: "checkbox",
|
|
15284
|
-
"aria-hidden": true,
|
|
15285
|
-
defaultChecked: defaultChecked ?? defaultCheckedRef.current,
|
|
15286
|
-
required,
|
|
15287
|
-
disabled,
|
|
15288
|
-
name,
|
|
15289
|
-
value,
|
|
15290
|
-
form,
|
|
15291
|
-
...props,
|
|
15292
|
-
tabIndex: -1,
|
|
15293
|
-
ref: composedRefs,
|
|
15294
|
-
onClick: composeEventHandlers(onClick, (event) => {
|
|
15295
|
-
if (shouldStopClickPropagationRef.current) event.stopPropagation();
|
|
15296
|
-
}),
|
|
15297
|
-
style: {
|
|
15298
|
-
...props.style,
|
|
15299
|
-
...controlSize,
|
|
15300
|
-
position: "absolute",
|
|
15301
|
-
pointerEvents: "none",
|
|
15302
|
-
opacity: 0,
|
|
15303
|
-
margin: 0,
|
|
15304
|
-
transform: "translateX(-100%)"
|
|
15305
|
-
}
|
|
15306
|
-
});
|
|
15307
|
-
}, "CheckboxBubbleInput"));
|
|
15308
|
-
function isFunction(value) {
|
|
15309
|
-
return typeof value === "function";
|
|
15310
|
-
}
|
|
15311
|
-
__name(isFunction, "isFunction");
|
|
15312
|
-
function isIndeterminate(checked) {
|
|
15313
|
-
return checked === "indeterminate";
|
|
15314
|
-
}
|
|
15315
|
-
__name(isIndeterminate, "isIndeterminate");
|
|
15316
|
-
function getState(checked) {
|
|
15317
|
-
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
15318
|
-
}
|
|
15319
|
-
__name(getState, "getState");
|
|
15320
|
-
function Checkbox({ className, ...props }) {
|
|
15321
|
-
return /* @__PURE__ */ jsx(Checkbox$1, {
|
|
15322
|
-
"data-slot": "checkbox",
|
|
15323
|
-
className: cn("peer border-input dark:bg-field data-[state=checked]:bg-control data-[state=checked]:text-control-foreground dark:data-[state=checked]:bg-control data-[state=checked]:border-control focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
15324
|
-
...props,
|
|
15325
|
-
children: /* @__PURE__ */ jsx(CheckboxIndicator, {
|
|
15326
|
-
"data-slot": "checkbox-indicator",
|
|
15327
|
-
className: "flex items-center justify-center text-current transition-none",
|
|
15328
|
-
children: /* @__PURE__ */ jsx(Check, { className: "size-3.5" })
|
|
15329
|
-
})
|
|
15330
|
-
});
|
|
15331
|
-
}
|
|
15332
15492
|
function SaveScenarioTemplateDialog(props) {
|
|
15333
15493
|
const { open, onOpenChange } = props;
|
|
15334
15494
|
return /* @__PURE__ */ jsx(Dialog, {
|
|
@@ -15525,7 +15685,8 @@ function SaveTemplateForm({ onOpenChange, defaultName, ownTemplates, labels, err
|
|
|
15525
15685
|
function errorMessage(labels, code) {
|
|
15526
15686
|
const placeholder = parsePlaceholderError(code);
|
|
15527
15687
|
if (placeholder) return labels.placeholder(placeholder.code, placeholder.token);
|
|
15528
|
-
|
|
15688
|
+
if (code.startsWith("server:")) return labels.server(code.slice(7));
|
|
15689
|
+
return labels[code] ?? FILTER_ERROR_LABEL_DEFAULTS[code] ?? code;
|
|
15529
15690
|
}
|
|
15530
15691
|
function asErrorText(code) {
|
|
15531
15692
|
return code;
|
|
@@ -15683,8 +15844,18 @@ const TOP_LEVEL_FIELDS = [
|
|
|
15683
15844
|
"trigger_event",
|
|
15684
15845
|
"product_ids",
|
|
15685
15846
|
"variant_ids",
|
|
15847
|
+
"form_ids",
|
|
15848
|
+
"persona_ids",
|
|
15686
15849
|
"actions"
|
|
15687
15850
|
];
|
|
15851
|
+
const NO_IDS = [];
|
|
15852
|
+
const DRAFT_FIELDS = {
|
|
15853
|
+
triggerEvent: "trigger_event",
|
|
15854
|
+
products: "product_ids",
|
|
15855
|
+
variantIds: "variant_ids",
|
|
15856
|
+
formIds: "form_ids",
|
|
15857
|
+
personaIds: "persona_ids"
|
|
15858
|
+
};
|
|
15688
15859
|
function ScenarioForm({ formId, initial, readOnly, editor, onDirtyChange, onSavingChange, onDraftChange, onSaved }) {
|
|
15689
15860
|
const { labels, notify = sonnerNotify } = editor;
|
|
15690
15861
|
const t = labels.sheet;
|
|
@@ -15702,10 +15873,20 @@ function ScenarioForm({ formId, initial, readOnly, editor, onDirtyChange, onSavi
|
|
|
15702
15873
|
useEffect(() => onDirtyChange(dirty), [dirty, onDirtyChange]);
|
|
15703
15874
|
useEffect(() => onSavingChange(saving), [saving, onSavingChange]);
|
|
15704
15875
|
useEffect(() => onDraftChange(draft), [draft, onDraftChange]);
|
|
15876
|
+
const hostDraftChange = editor.onDraftChange;
|
|
15877
|
+
useEffect(() => hostDraftChange?.(draft), [draft, hostDraftChange]);
|
|
15705
15878
|
const placeholderSource = editor.placeholders;
|
|
15706
|
-
const
|
|
15879
|
+
const formIds = draft.formIds ?? NO_IDS;
|
|
15880
|
+
const formIdsKey = formIds.join(",");
|
|
15881
|
+
const personaLoad = editor.filters?.personas;
|
|
15882
|
+
const negativePersonaIds = useMemo(() => personaLoad?.status === "ready" ? personaLoad.value.filter((persona) => persona.isNegative).map((persona) => persona.id) : NO_IDS, [personaLoad]);
|
|
15883
|
+
const placeholders = useMemo(() => placeholderSource && draft.triggerEvent ? placeholderSource(draft.triggerEvent, { formIds }) : void 0, [
|
|
15884
|
+
placeholderSource,
|
|
15885
|
+
draft.triggerEvent,
|
|
15886
|
+
formIdsKey
|
|
15887
|
+
]);
|
|
15707
15888
|
const checkSource = editor.checkEmailText;
|
|
15708
|
-
const validate = useCallback((next) => validateScenarioDraft(next, { checkEmailText: checkSource && next.triggerEvent ? (text, field) => checkSource(text, field, next.triggerEvent) : void 0 }), [checkSource]);
|
|
15889
|
+
const validate = useCallback((next) => validateScenarioDraft(next, { checkEmailText: checkSource && next.triggerEvent ? (text, field) => checkSource(text, field, next.triggerEvent, { formIds: next.formIds ?? NO_IDS }) : void 0 }), [checkSource]);
|
|
15709
15890
|
const placeholderErrors = useMemo(() => placeholderOnly(validate(draft)), [validate, draft]);
|
|
15710
15891
|
const shownErrors = useMemo(() => ({
|
|
15711
15892
|
...placeholderErrors,
|
|
@@ -15726,13 +15907,14 @@ function ScenarioForm({ formId, initial, readOnly, editor, onDirtyChange, onSavi
|
|
|
15726
15907
|
]);
|
|
15727
15908
|
function set(key, value) {
|
|
15728
15909
|
setFormError(void 0);
|
|
15729
|
-
setDraft((current) => ({
|
|
15910
|
+
setDraft((current) => key === "triggerEvent" ? withTriggerEvent(current, value, editor.events) : withNegativePersonaRule({
|
|
15730
15911
|
...current,
|
|
15731
15912
|
[key]: value
|
|
15732
|
-
}));
|
|
15913
|
+
}, negativePersonaIds));
|
|
15733
15914
|
setErrors((current) => {
|
|
15734
|
-
const field = key
|
|
15735
|
-
|
|
15915
|
+
const field = DRAFT_FIELDS[key] ?? key;
|
|
15916
|
+
const code = current[field];
|
|
15917
|
+
if (code === void 0 || !isServerFieldError(code)) return current;
|
|
15736
15918
|
const next = { ...current };
|
|
15737
15919
|
delete next[field];
|
|
15738
15920
|
return next;
|
|
@@ -15768,7 +15950,7 @@ function ScenarioForm({ formId, initial, readOnly, editor, onDirtyChange, onSavi
|
|
|
15768
15950
|
setSaving(true);
|
|
15769
15951
|
let result;
|
|
15770
15952
|
try {
|
|
15771
|
-
result = await editor.onSave(draft);
|
|
15953
|
+
result = await editor.onSave(withNegativePersonaRule(draft, negativePersonaIds));
|
|
15772
15954
|
} catch {
|
|
15773
15955
|
result = {
|
|
15774
15956
|
status: "error",
|
|
@@ -15791,10 +15973,15 @@ function ScenarioForm({ formId, initial, readOnly, editor, onDirtyChange, onSavi
|
|
|
15791
15973
|
notify.error(t.saveFailed);
|
|
15792
15974
|
}
|
|
15793
15975
|
const events = editor.events.filter((candidate) => candidate.available);
|
|
15976
|
+
const filters = editor.filters;
|
|
15977
|
+
const hasForm = eventHasForm(event);
|
|
15978
|
+
const showForms = !!filters?.forms && hasForm;
|
|
15794
15979
|
const context = {
|
|
15795
15980
|
...editor,
|
|
15796
15981
|
errorText,
|
|
15797
|
-
placeholders
|
|
15982
|
+
placeholders,
|
|
15983
|
+
answersNeedForm: showForms && formIds.length === 0,
|
|
15984
|
+
answersFailed: showForms && formIds.length > 0 && filters?.answersFailed?.(formIds) === true
|
|
15798
15985
|
};
|
|
15799
15986
|
const showVariants = appliesToProducts && draft.products.length > 0 && variants.options.length > 0;
|
|
15800
15987
|
const registerField = (field) => (element) => {
|
|
@@ -15918,6 +16105,20 @@ function ScenarioForm({ formId, initial, readOnly, editor, onDirtyChange, onSavi
|
|
|
15918
16105
|
onChange: (next) => set("variantIds", next)
|
|
15919
16106
|
})
|
|
15920
16107
|
}),
|
|
16108
|
+
filters && /* @__PURE__ */ jsx(ScenarioFilterFields, {
|
|
16109
|
+
ids,
|
|
16110
|
+
draft,
|
|
16111
|
+
filters,
|
|
16112
|
+
showForms,
|
|
16113
|
+
hasEvent: !!event,
|
|
16114
|
+
hasForm,
|
|
16115
|
+
readOnly,
|
|
16116
|
+
labels,
|
|
16117
|
+
errors,
|
|
16118
|
+
errorText,
|
|
16119
|
+
registerField,
|
|
16120
|
+
set
|
|
16121
|
+
}),
|
|
15921
16122
|
/* @__PURE__ */ jsxs("div", {
|
|
15922
16123
|
className: "flex items-start justify-between gap-4",
|
|
15923
16124
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -15976,6 +16177,143 @@ function ScenarioForm({ formId, initial, readOnly, editor, onDirtyChange, onSavi
|
|
|
15976
16177
|
});
|
|
15977
16178
|
}
|
|
15978
16179
|
const NO_PRODUCTS = [];
|
|
16180
|
+
const SERVER_FIELD_CODES = /* @__PURE__ */ new Set([
|
|
16181
|
+
"formsNotApplicable",
|
|
16182
|
+
"formsInvalid",
|
|
16183
|
+
"formUnknown",
|
|
16184
|
+
"personasInvalid",
|
|
16185
|
+
"personaUnknown"
|
|
16186
|
+
]);
|
|
16187
|
+
function isServerFieldError(code) {
|
|
16188
|
+
return code.startsWith("server:") || SERVER_FIELD_CODES.has(code);
|
|
16189
|
+
}
|
|
16190
|
+
function ScenarioFilterFields({ ids, draft, filters, showForms, hasEvent, hasForm, readOnly, labels, errors, errorText, registerField, set }) {
|
|
16191
|
+
const t = withLabelDefaults(labels.sheet, SHEET_FILTER_LABEL_DEFAULTS);
|
|
16192
|
+
const forms = filters.forms;
|
|
16193
|
+
const personas = filters.personas;
|
|
16194
|
+
const personaIds = draft.personaIds ?? NO_IDS;
|
|
16195
|
+
const activePersonas = personas?.status === "ready" ? personas.value.filter((persona) => persona.active) : [];
|
|
16196
|
+
const negative = activePersonas.find((persona) => persona.isNegative);
|
|
16197
|
+
const noPersonas = personas?.status === "ready" && activePersonas.length === 0 && personaIds.length === 0;
|
|
16198
|
+
const negativePicked = !!negative && picksNegativePersona(draft, [negative.id]);
|
|
16199
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16200
|
+
showForms && forms && /* @__PURE__ */ jsx(FormRow, {
|
|
16201
|
+
ref: registerField("form_ids"),
|
|
16202
|
+
id: `${ids}-forms`,
|
|
16203
|
+
label: t.forms,
|
|
16204
|
+
hint: t.formsHint,
|
|
16205
|
+
error: errors.form_ids && errorText(errors.form_ids),
|
|
16206
|
+
children: (describedBy) => /* @__PURE__ */ jsx(LoadedField, {
|
|
16207
|
+
load: forms,
|
|
16208
|
+
failed: t.formsLoadFailed,
|
|
16209
|
+
retry: labels.common.tryAgain,
|
|
16210
|
+
children: (options) => /* @__PURE__ */ jsx(OptionMultiField, {
|
|
16211
|
+
id: `${ids}-forms`,
|
|
16212
|
+
describedBy,
|
|
16213
|
+
invalid: !!errors.form_ids,
|
|
16214
|
+
disabled: readOnly,
|
|
16215
|
+
options,
|
|
16216
|
+
value: draft.formIds ?? NO_IDS,
|
|
16217
|
+
onChange: (next) => set("formIds", next),
|
|
16218
|
+
texts: {
|
|
16219
|
+
all: t.formsAll,
|
|
16220
|
+
search: t.formSearch,
|
|
16221
|
+
none: t.formNone,
|
|
16222
|
+
remove: t.formRemove,
|
|
16223
|
+
unknown: t.formDeleted
|
|
16224
|
+
}
|
|
16225
|
+
})
|
|
16226
|
+
})
|
|
16227
|
+
}),
|
|
16228
|
+
personas && hasEvent && (noPersonas ? /* @__PURE__ */ jsxs("div", {
|
|
16229
|
+
className: "space-y-1.5",
|
|
16230
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
16231
|
+
className: "text-sm leading-none font-medium",
|
|
16232
|
+
children: t.personas
|
|
16233
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
16234
|
+
className: "text-muted-foreground text-xs text-pretty",
|
|
16235
|
+
children: [
|
|
16236
|
+
t.personasEmpty,
|
|
16237
|
+
" ",
|
|
16238
|
+
filters.personasHref && /* @__PURE__ */ jsx("a", {
|
|
16239
|
+
href: filters.personasHref,
|
|
16240
|
+
className: "text-foreground font-medium underline underline-offset-2",
|
|
16241
|
+
children: t.personasEmptyLink
|
|
16242
|
+
})
|
|
16243
|
+
]
|
|
16244
|
+
})]
|
|
16245
|
+
}) : /* @__PURE__ */ jsx(FormRow, {
|
|
16246
|
+
ref: registerField("persona_ids"),
|
|
16247
|
+
id: `${ids}-personas`,
|
|
16248
|
+
label: t.personas,
|
|
16249
|
+
hint: hasForm ? t.personasRulesOnly : t.personasHint,
|
|
16250
|
+
error: errors.persona_ids && errorText(errors.persona_ids),
|
|
16251
|
+
children: (describedBy) => /* @__PURE__ */ jsx(LoadedField, {
|
|
16252
|
+
load: personas,
|
|
16253
|
+
failed: t.personasLoadFailed,
|
|
16254
|
+
retry: labels.common.tryAgain,
|
|
16255
|
+
children: (options) => /* @__PURE__ */ jsx(OptionMultiField, {
|
|
16256
|
+
id: `${ids}-personas`,
|
|
16257
|
+
describedBy,
|
|
16258
|
+
invalid: !!errors.persona_ids,
|
|
16259
|
+
disabled: readOnly,
|
|
16260
|
+
options: options.map((persona) => ({
|
|
16261
|
+
id: persona.id,
|
|
16262
|
+
name: persona.name,
|
|
16263
|
+
detail: persona.isNegative ? t.personaNegative : void 0,
|
|
16264
|
+
chip: persona.active ? void 0 : t.personaInactive(persona.name),
|
|
16265
|
+
hidden: !persona.active
|
|
16266
|
+
})),
|
|
16267
|
+
value: personaIds,
|
|
16268
|
+
onChange: (next) => set("personaIds", next),
|
|
16269
|
+
texts: {
|
|
16270
|
+
all: t.personasAll,
|
|
16271
|
+
search: t.personaSearch,
|
|
16272
|
+
none: t.personaNone,
|
|
16273
|
+
remove: t.personaRemove,
|
|
16274
|
+
unknown: t.personaDeleted
|
|
16275
|
+
}
|
|
16276
|
+
})
|
|
16277
|
+
})
|
|
16278
|
+
})),
|
|
16279
|
+
negative && hasEvent && /* @__PURE__ */ jsxs("div", {
|
|
16280
|
+
className: "flex items-start gap-3",
|
|
16281
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
16282
|
+
id: `${ids}-skip-negative`,
|
|
16283
|
+
"aria-describedby": `${ids}-skip-negative-hint`,
|
|
16284
|
+
checked: !negativePicked && draft.skipNegativePersona === true,
|
|
16285
|
+
disabled: readOnly || negativePicked,
|
|
16286
|
+
onCheckedChange: (checked) => set("skipNegativePersona", checked === true),
|
|
16287
|
+
className: "mt-0.5"
|
|
16288
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
16289
|
+
className: "min-w-0",
|
|
16290
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
16291
|
+
htmlFor: `${ids}-skip-negative`,
|
|
16292
|
+
children: t.skipNegative
|
|
16293
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
16294
|
+
id: `${ids}-skip-negative-hint`,
|
|
16295
|
+
className: "text-muted-foreground mt-0.5 text-xs text-pretty",
|
|
16296
|
+
children: negativePicked ? t.skipNegativePicked(negative.name) : t.skipNegativeHint(negative.name)
|
|
16297
|
+
})]
|
|
16298
|
+
})]
|
|
16299
|
+
})
|
|
16300
|
+
] });
|
|
16301
|
+
}
|
|
16302
|
+
function LoadedField({ load, failed, retry, children }) {
|
|
16303
|
+
if (load.status === "loading") return /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-full" });
|
|
16304
|
+
if (load.status === "error") return /* @__PURE__ */ jsxs("div", {
|
|
16305
|
+
role: "alert",
|
|
16306
|
+
className: "flex flex-wrap items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm",
|
|
16307
|
+
children: [/* @__PURE__ */ jsx("span", { children: load.message ?? failed }), load.retry && /* @__PURE__ */ jsx(Button$1, {
|
|
16308
|
+
type: "button",
|
|
16309
|
+
variant: "outline",
|
|
16310
|
+
size: "sm",
|
|
16311
|
+
onClick: load.retry,
|
|
16312
|
+
children: retry
|
|
16313
|
+
})]
|
|
16314
|
+
});
|
|
16315
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children(load.value) });
|
|
16316
|
+
}
|
|
15979
16317
|
function placeholderOnly(errors) {
|
|
15980
16318
|
return Object.fromEntries(Object.entries(errors).filter(([, code]) => code.startsWith("placeholder:")));
|
|
15981
16319
|
}
|
|
@@ -19924,4 +20262,4 @@ function AiLearningPanel({ state: load, labels, canControl, outcomes = [], compa
|
|
|
19924
20262
|
]
|
|
19925
20263
|
});
|
|
19926
20264
|
}
|
|
19927
|
-
export { ACTION_CATALOG, ACTION_KINDS, AI_DECISION_MODES, ActionChips, AiLearningPanel, AppIcon, BitsnapUiRoot as AutomationsRoot, DEFAULT_SCENARIO_FILTERS, DELAY_MAX_SECONDS, DELAY_MIN_SECONDS, EVENT_GROUP_ORDER, FILTER_APPS, MAX_ACTIONS_PER_SCENARIO, OutcomeCards, PICKER_APPS, RUNS_PAGE_SIZE, RUN_STATUSES, RUN_STATUS_FILTERS, RunHistory, SCENARIO_PAGE_SIZES, SaveScenarioTemplateDialog, ScenarioEditor, ScenarioList, ScenarioTemplateList, actionApp, actionDefinition, actionErrors, availablePlaceholders, baseProductName, createAutomationsLabels, createLabelDateFormat, delayFromSeconds, delayToSeconds, emptyActionDraft, emptyScenarioDraft, firstActionWithError, groupEvents, groupProductResults, hasActiveFilters, insertAt, learningProgressKey, moveItem, ownTextFromTemplate, parseFieldPath, parsePlaceholderError, placeholderErrorFromDetail, presentCategories, productNameFrom, rootProductId, ruleDestination, sameDraft, sameEmailTemplateRef, templateMatches, templateRequirements, templatesInCategory, unitSeconds, unknownActionDraft, urlHost, validateAiDecisionConfig, validateDelay, validateScenarioDraft };
|
|
20265
|
+
export { ACTION_CATALOG, ACTION_KINDS, AI_DECISION_MODES, ActionChips, AiLearningPanel, AppIcon, BitsnapUiRoot as AutomationsRoot, DEFAULT_SCENARIO_FILTERS, DELAY_MAX_SECONDS, DELAY_MIN_SECONDS, EVENT_GROUP_ORDER, FILTER_APPS, MAX_ACTIONS_PER_SCENARIO, OutcomeCards, PICKER_APPS, RUNS_PAGE_SIZE, RUN_STATUSES, RUN_STATUS_FILTERS, RunHistory, SCENARIO_PAGE_SIZES, SaveScenarioTemplateDialog, ScenarioEditor, ScenarioList, ScenarioTemplateList, actionApp, actionDefinition, actionErrors, availablePlaceholders, baseProductName, createAutomationsLabels, createLabelDateFormat, delayFromSeconds, delayToSeconds, emptyActionDraft, emptyScenarioDraft, eventHasForm, firstActionWithError, groupEvents, groupProductResults, hasActiveFilters, insertAt, learningProgressKey, moveItem, ownTextFromTemplate, parseFieldPath, parsePlaceholderError, picksNegativePersona, placeholderErrorFromDetail, presentCategories, productNameFrom, rootProductId, ruleDestination, sameDraft, sameEmailTemplateRef, templateMatches, templateRequirements, templatesInCategory, unitSeconds, unknownActionDraft, urlHost, validateAiDecisionConfig, validateDelay, validateScenarioDraft, withNegativePersonaRule, withTriggerEvent };
|