@adhese/sdk-devtools 0.11.5 → 0.12.0
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 +20 -0
- package/dist/AdheseContext.js +19 -0
- package/dist/AdheseContext.js.map +1 -0
- package/dist/Devtools.hooks.js +24 -0
- package/dist/Devtools.hooks.js.map +1 -0
- package/dist/Devtools.js +79 -0
- package/dist/Devtools.js.map +1 -0
- package/dist/cjs/AdheseContext.cjs +19 -0
- package/dist/cjs/AdheseContext.cjs.map +1 -0
- package/dist/cjs/Devtools.cjs +79 -0
- package/dist/cjs/Devtools.cjs.map +1 -0
- package/dist/cjs/Devtools.hooks.cjs +24 -0
- package/dist/cjs/Devtools.hooks.cjs.map +1 -0
- package/dist/cjs/components/badge.cjs +27 -0
- package/dist/cjs/components/badge.cjs.map +1 -0
- package/dist/cjs/components/button.cjs +49 -0
- package/dist/cjs/components/button.cjs.map +1 -0
- package/dist/cjs/components/editSlot.cjs +110 -0
- package/dist/cjs/components/editSlot.cjs.map +1 -0
- package/dist/cjs/components/form.cjs +110 -0
- package/dist/cjs/components/form.cjs.map +1 -0
- package/dist/cjs/components/fronttailSettings.cjs +94 -0
- package/dist/cjs/components/fronttailSettings.cjs.map +1 -0
- package/dist/cjs/components/input.cjs +22 -0
- package/dist/cjs/components/input.cjs.map +1 -0
- package/dist/cjs/components/label.cjs +38 -0
- package/dist/cjs/components/label.cjs.map +1 -0
- package/dist/cjs/components/logTable.cjs +67 -0
- package/dist/cjs/components/logTable.cjs.map +1 -0
- package/dist/cjs/components/parametersTable.cjs +40 -0
- package/dist/cjs/components/parametersTable.cjs.map +1 -0
- package/dist/cjs/components/previewButton.cjs +19 -0
- package/dist/cjs/components/previewButton.cjs.map +1 -0
- package/dist/cjs/components/settings.cjs +10 -0
- package/dist/cjs/components/settings.cjs.map +1 -0
- package/dist/cjs/components/sheet.cjs +118 -0
- package/dist/cjs/components/sheet.cjs.map +1 -0
- package/dist/cjs/components/slotsTable.cjs +230 -0
- package/dist/cjs/components/slotsTable.cjs.map +1 -0
- package/dist/cjs/components/switch.cjs +45 -0
- package/dist/cjs/components/switch.cjs.map +1 -0
- package/dist/cjs/components/table.cjs +91 -0
- package/dist/cjs/components/table.cjs.map +1 -0
- package/dist/cjs/components/tabs.cjs +65 -0
- package/dist/cjs/components/tabs.cjs.map +1 -0
- package/dist/cjs/devtools.composables.cjs +116 -0
- package/dist/cjs/devtools.composables.cjs.map +1 -0
- package/dist/cjs/main.cjs +16 -0
- package/dist/cjs/main.cjs.map +1 -0
- package/dist/cjs/modifiedSlots.store.cjs +63 -0
- package/dist/cjs/modifiedSlots.store.cjs.map +1 -0
- package/dist/cjs/package.json.cjs +7 -0
- package/dist/cjs/package.json.cjs.map +1 -0
- package/dist/cjs/sdkDevtools.cjs +17 -0
- package/dist/cjs/sdkDevtools.cjs.map +1 -0
- package/dist/cjs/utils.cjs +9 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/components/badge.js +27 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.js +49 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/editSlot.js +110 -0
- package/dist/components/editSlot.js.map +1 -0
- package/dist/components/form.js +110 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/fronttailSettings.js +94 -0
- package/dist/components/fronttailSettings.js.map +1 -0
- package/dist/components/input.js +22 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.js +21 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/logTable.js +67 -0
- package/dist/components/logTable.js.map +1 -0
- package/dist/components/parametersTable.js +40 -0
- package/dist/components/parametersTable.js.map +1 -0
- package/dist/components/previewButton.js +19 -0
- package/dist/components/previewButton.js.map +1 -0
- package/dist/components/settings.js +10 -0
- package/dist/components/settings.js.map +1 -0
- package/dist/components/sheet.js +101 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/slotsTable.js +230 -0
- package/dist/components/slotsTable.js.map +1 -0
- package/dist/components/switch.js +28 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +91 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.js +48 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/devtools.composables.js +116 -0
- package/dist/devtools.composables.js.map +1 -0
- package/dist/main.js +16 -0
- package/dist/main.js.map +1 -0
- package/dist/modifiedSlots.store.js +63 -0
- package/dist/modifiedSlots.store.js.map +1 -0
- package/dist/package.json.js +7 -0
- package/dist/package.json.js.map +1 -0
- package/dist/sdkDevtools.js +17 -0
- package/dist/sdkDevtools.js.map +1 -0
- package/dist/utils.js +9 -0
- package/dist/utils.js.map +1 -0
- package/package.json +12 -9
- package/dist/devtools-Cbms1xWf.cjs +0 -816
- package/dist/devtools-Cbms1xWf.cjs.map +0 -1
- package/dist/devtools-CjRcI3Xd.js +0 -797
- package/dist/devtools-CjRcI3Xd.js.map +0 -1
- package/dist/index.cjs +0 -47
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -47
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const sdkShared = require("@adhese/sdk-shared");
|
|
6
|
+
const validators = require("@adhese/sdk-shared/validators");
|
|
7
|
+
const reactHookForm = require("react-hook-form");
|
|
8
|
+
const zod = require("@hookform/resolvers/zod");
|
|
9
|
+
const reactIcons = require("@radix-ui/react-icons");
|
|
10
|
+
const AdheseContext = require("../AdheseContext.cjs");
|
|
11
|
+
const modifiedSlots_store = require("../modifiedSlots.store.cjs");
|
|
12
|
+
const sheet = require("./sheet.cjs");
|
|
13
|
+
const form = require("./form.cjs");
|
|
14
|
+
const input = require("./input.cjs");
|
|
15
|
+
const button = require("./button.cjs");
|
|
16
|
+
const slotSchema = validators.object({
|
|
17
|
+
format: validators.string().min(1),
|
|
18
|
+
slot: validators.string().optional()
|
|
19
|
+
});
|
|
20
|
+
function EditSlot({
|
|
21
|
+
id
|
|
22
|
+
}) {
|
|
23
|
+
const slot = useSlot(id);
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(sheet.Sheet, { children: [
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26
|
+
sheet.SheetTrigger,
|
|
27
|
+
{
|
|
28
|
+
"aria-label": "Edit slot",
|
|
29
|
+
className: button.buttonVariants({
|
|
30
|
+
variant: "ghost",
|
|
31
|
+
size: "sm"
|
|
32
|
+
}),
|
|
33
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.Pencil1Icon, {})
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ jsxRuntime.jsx(sheet.SheetContent, { children: slot && /* @__PURE__ */ jsxRuntime.jsx(EditSlotForm, { slot }) })
|
|
37
|
+
] });
|
|
38
|
+
}
|
|
39
|
+
function EditSlotForm({
|
|
40
|
+
slot
|
|
41
|
+
}) {
|
|
42
|
+
const modifiedSlots = modifiedSlots_store.useModifiedSlots();
|
|
43
|
+
const modifiedSlot = react.useMemo(() => modifiedSlots.slots.get((slot == null ? void 0 : slot.name) ?? ""), [modifiedSlots, slot]);
|
|
44
|
+
const defaultValues = react.useMemo(() => sdkShared.pick(modifiedSlot ?? {
|
|
45
|
+
format: slot.format,
|
|
46
|
+
slot: slot.slot ?? ""
|
|
47
|
+
}, ["format", "slot"]), [slot, modifiedSlot]);
|
|
48
|
+
const form$1 = reactHookForm.useForm({
|
|
49
|
+
resolver: zod.zodResolver(slotSchema),
|
|
50
|
+
defaultValues
|
|
51
|
+
});
|
|
52
|
+
const onSubmit = (data) => {
|
|
53
|
+
modifiedSlots.set(slot.name, sdkShared.pick({
|
|
54
|
+
...slot,
|
|
55
|
+
...data
|
|
56
|
+
}, ["format", "slot"]));
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsxs(sheet.SheetHeader, { className: "mb-8", children: [
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsx(sheet.SheetTitle, { children: "Edit slot" }),
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx(sheet.SheetDescription, { children: slot.name })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsx(form.Form, { ...form$1, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: form$1.handleSubmit(onSubmit), children: [
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
form.FormField,
|
|
66
|
+
{
|
|
67
|
+
control: form$1.control,
|
|
68
|
+
name: "format",
|
|
69
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(SlotFormItem, { label: "Format", children: /* @__PURE__ */ jsxRuntime.jsx(input.Input, { ...field }) })
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
73
|
+
form.FormField,
|
|
74
|
+
{
|
|
75
|
+
control: form$1.control,
|
|
76
|
+
name: "slot",
|
|
77
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(SlotFormItem, { label: "Slot", children: /* @__PURE__ */ jsxRuntime.jsx(input.Input, { ...field }) })
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsx(button.Button, { className: "w-full mt-10", children: "Edit" })
|
|
81
|
+
] }) })
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
function SlotFormItem({
|
|
85
|
+
label,
|
|
86
|
+
description,
|
|
87
|
+
children
|
|
88
|
+
}) {
|
|
89
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(form.FormItem, { className: "mb-3", children: [
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsx(form.FormLabel, { children: label }),
|
|
91
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(form.FormDescription, { children: description }),
|
|
92
|
+
/* @__PURE__ */ jsxRuntime.jsx(form.FormControl, { children }),
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx(form.FormMessage, {})
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
function useSlot(id) {
|
|
97
|
+
const adheseContext = AdheseContext.useAdheseContext();
|
|
98
|
+
const [slot, setSlot] = react.useState(adheseContext == null ? void 0 : adheseContext.slots.get(id));
|
|
99
|
+
react.useEffect(() => {
|
|
100
|
+
if (!adheseContext) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
return sdkShared.watch(() => adheseContext.slots, (slots) => {
|
|
104
|
+
setSlot(slots.get(id));
|
|
105
|
+
}, { immediate: true, deep: true });
|
|
106
|
+
}, [adheseContext, id]);
|
|
107
|
+
return slot;
|
|
108
|
+
}
|
|
109
|
+
exports.EditSlot = EditSlot;
|
|
110
|
+
//# sourceMappingURL=editSlot.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editSlot.cjs","sources":["../../../src/components/editSlot.tsx"],"sourcesContent":["import { type PropsWithChildren, type ReactElement, useEffect, useMemo, useState } from 'react';\nimport { pick, watch } from '@adhese/sdk-shared';\nimport type { AdheseSlot } from '@adhese/sdk';\nimport { type TypeOf, object, string } from '@adhese/sdk-shared/validators';\nimport { type SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Pencil1Icon } from '@radix-ui/react-icons';\nimport { useAdheseContext } from '../AdheseContext';\nimport { useModifiedSlots } from '../modifiedSlots.store';\nimport { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from './sheet';\nimport { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from './form';\nimport { Input } from './input';\nimport { Button, buttonVariants } from './button';\n\nconst slotSchema = object({\n format: string().min(1),\n slot: string().optional(),\n});\n\ntype SlotSchema = TypeOf<typeof slotSchema>;\n\n// eslint-disable-next-line ts/naming-convention\nexport function EditSlot({\n id,\n}: {\n id: string;\n}): ReactElement {\n const slot = useSlot(id);\n\n return (\n <Sheet>\n <SheetTrigger\n aria-label=\"Edit slot\"\n className={buttonVariants({\n variant: 'ghost',\n size: 'sm',\n })}\n >\n <Pencil1Icon />\n </SheetTrigger>\n <SheetContent>\n {slot && <EditSlotForm slot={slot} />}\n </SheetContent>\n </Sheet>\n );\n}\n\n// eslint-disable-next-line ts/naming-convention\nfunction EditSlotForm({\n slot,\n}: {\n slot: AdheseSlot;\n}): ReactElement {\n const modifiedSlots = useModifiedSlots();\n const modifiedSlot = useMemo(() => modifiedSlots.slots.get(slot?.name ?? ''), [modifiedSlots, slot]);\n\n const defaultValues = useMemo(() => pick(modifiedSlot ?? {\n format: slot.format,\n slot: slot.slot ?? '',\n }, ['format', 'slot']), [slot, modifiedSlot]);\n\n const form = useForm<SlotSchema>({\n resolver: zodResolver(slotSchema),\n defaultValues,\n });\n\n const onSubmit: SubmitHandler<SlotSchema> = (data) => {\n modifiedSlots.set(slot.name, pick({\n ...slot,\n ...data,\n }, ['format', 'slot']));\n };\n\n return (\n <>\n <SheetHeader className=\"mb-8\">\n <SheetTitle>\n Edit slot\n </SheetTitle>\n <SheetDescription>\n {slot.name}\n </SheetDescription>\n </SheetHeader>\n\n <Form {...form}>\n {/* eslint-disable-next-line ts/no-misused-promises */}\n <form onSubmit={form.handleSubmit(onSubmit)}>\n <FormField\n control={form.control}\n name=\"format\"\n render={({ field }) => (\n <SlotFormItem label=\"Format\">\n <Input {...field} />\n </SlotFormItem>\n )}\n />\n <FormField\n control={form.control}\n name=\"slot\"\n render={({ field }) => (\n <SlotFormItem label=\"Slot\">\n <Input {...field} />\n </SlotFormItem>\n )}\n />\n\n <Button className=\"w-full mt-10\">\n Edit\n </Button>\n </form>\n </Form>\n </>\n );\n}\n\n// eslint-disable-next-line ts/naming-convention\nfunction SlotFormItem({\n label,\n description,\n children,\n}: PropsWithChildren<{\n label: string;\n description?: string;\n}>): ReactElement {\n return (\n <FormItem className=\"mb-3\">\n <FormLabel>{label}</FormLabel>\n {description && <FormDescription>{description}</FormDescription>}\n <FormControl>\n {children}\n </FormControl>\n <FormMessage />\n </FormItem>\n );\n}\n\nfunction useSlot(id: string): AdheseSlot | undefined {\n const adheseContext = useAdheseContext();\n const [slot, setSlot] = useState(adheseContext?.slots.get(id));\n\n useEffect(() => {\n if (!adheseContext) {\n return;\n }\n\n return watch(() => adheseContext.slots, (slots) => {\n setSlot(slots.get(id));\n }, { immediate: true, deep: true });\n }, [adheseContext, id]);\n return slot;\n}\n"],"names":["object","string","Sheet","jsx","SheetTrigger","buttonVariants","Pencil1Icon","SheetContent","useModifiedSlots","useMemo","pick","form","useForm","zodResolver","jsxs","Fragment","SheetHeader","SheetTitle","SheetDescription","Form","FormField","Input","Button","FormItem","FormLabel","FormDescription","FormControl","FormMessage","useAdheseContext","useState","useEffect","watch"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAM,aAAaA,WAAAA,OAAO;AAAA,EACxB,QAAQC,WAAA,OAAA,EAAS,IAAI,CAAC;AAAA,EACtB,MAAMA,WAAAA,OAAO,EAAE,SAAS;AAC1B,CAAC;AAKM,SAAS,SAAS;AAAA,EACvB;AACF,GAEiB;AACT,QAAA,OAAO,QAAQ,EAAE;AAEvB,yCACGC,aACC,EAAA,UAAA;AAAA,IAAAC,2BAAA;AAAA,MAACC,MAAA;AAAA,MAAA;AAAA,QACC,cAAW;AAAA,QACX,WAAWC,OAAAA,eAAe;AAAA,UACxB,SAAS;AAAA,UACT,MAAM;AAAA,QAAA,CACP;AAAA,QAED,yCAACC,WAAY,aAAA,EAAA;AAAA,MAAA;AAAA,IACf;AAAA,mCACCC,MAAAA,cACE,EAAA,UAAA,QAASJ,2BAAA,IAAA,cAAA,EAAa,KAAY,CAAA,GACrC;AAAA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 -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
5
|
+
const reactHookForm = require("react-hook-form");
|
|
6
|
+
const react = require("react");
|
|
7
|
+
const utils = require("../utils.cjs");
|
|
8
|
+
const label = require("./label.cjs");
|
|
9
|
+
const Form = reactHookForm.FormProvider;
|
|
10
|
+
const FormFieldContext = react.createContext(
|
|
11
|
+
{}
|
|
12
|
+
);
|
|
13
|
+
function FormField({
|
|
14
|
+
...props
|
|
15
|
+
}) {
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
|
|
17
|
+
}
|
|
18
|
+
const FormItemContext = react.createContext(
|
|
19
|
+
{}
|
|
20
|
+
);
|
|
21
|
+
function useFormField() {
|
|
22
|
+
const fieldContext = react.useContext(FormFieldContext);
|
|
23
|
+
const itemContext = react.useContext(FormItemContext);
|
|
24
|
+
const { getFieldState, formState } = reactHookForm.useFormContext();
|
|
25
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
26
|
+
if (!fieldContext) {
|
|
27
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
28
|
+
}
|
|
29
|
+
const { id } = itemContext;
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
name: fieldContext.name,
|
|
33
|
+
formItemId: `${id}-form-item`,
|
|
34
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
35
|
+
formMessageId: `${id}-form-item-message`,
|
|
36
|
+
...fieldState
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const FormItem = react.forwardRef(({ className, ...props }, ref) => {
|
|
40
|
+
const id = react.useId();
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: utils.cn("space-y-2", className), ...props }) });
|
|
42
|
+
});
|
|
43
|
+
FormItem.displayName = "FormItem";
|
|
44
|
+
const FormLabel = react.forwardRef(({ className, ...props }, ref) => {
|
|
45
|
+
const { error, formItemId } = useFormField();
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
label.Label,
|
|
48
|
+
{
|
|
49
|
+
ref,
|
|
50
|
+
className: utils.cn(error && "text-destructive", className),
|
|
51
|
+
htmlFor: formItemId,
|
|
52
|
+
...props
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
FormLabel.displayName = "FormLabel";
|
|
57
|
+
const FormControl = react.forwardRef(({ ...props }, ref) => {
|
|
58
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
+
reactSlot.Slot,
|
|
61
|
+
{
|
|
62
|
+
ref,
|
|
63
|
+
id: formItemId,
|
|
64
|
+
"aria-describedby": error ? `${formDescriptionId} ${formMessageId}` : `${formDescriptionId}`,
|
|
65
|
+
"aria-invalid": !!error,
|
|
66
|
+
...props
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
FormControl.displayName = "FormControl";
|
|
71
|
+
const FormDescription = react.forwardRef(({ className, ...props }, ref) => {
|
|
72
|
+
const { formDescriptionId } = useFormField();
|
|
73
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
74
|
+
"p",
|
|
75
|
+
{
|
|
76
|
+
ref,
|
|
77
|
+
id: formDescriptionId,
|
|
78
|
+
className: utils.cn("text-[0.8rem] text-muted-foreground", className),
|
|
79
|
+
...props
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
FormDescription.displayName = "FormDescription";
|
|
84
|
+
const FormMessage = react.forwardRef(({ className, children, ...props }, ref) => {
|
|
85
|
+
const { error, formMessageId } = useFormField();
|
|
86
|
+
const body = error ? String(error == null ? void 0 : error.message) : children;
|
|
87
|
+
if (!body) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
+
"p",
|
|
92
|
+
{
|
|
93
|
+
ref,
|
|
94
|
+
id: formMessageId,
|
|
95
|
+
className: utils.cn("text-[0.8rem] font-medium text-destructive", className),
|
|
96
|
+
...props,
|
|
97
|
+
children: body
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
FormMessage.displayName = "FormMessage";
|
|
102
|
+
exports.Form = Form;
|
|
103
|
+
exports.FormControl = FormControl;
|
|
104
|
+
exports.FormDescription = FormDescription;
|
|
105
|
+
exports.FormField = FormField;
|
|
106
|
+
exports.FormItem = FormItem;
|
|
107
|
+
exports.FormLabel = FormLabel;
|
|
108
|
+
exports.FormMessage = FormMessage;
|
|
109
|
+
exports.useFormField = useFormField;
|
|
110
|
+
//# sourceMappingURL=form.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.cjs","sources":["../../../src/components/form.tsx"],"sourcesContent":["// eslint-disable-next-line ts/naming-convention\nimport type * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport {\n Controller,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n FormProvider,\n useFormContext,\n} from 'react-hook-form';\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n createContext,\n forwardRef,\n useContext,\n useId,\n} from 'react';\nimport { cn } from '../utils';\nimport { Label } from './label';\n\n// eslint-disable-next-line ts/naming-convention\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n T extends FieldValues = FieldValues,\n U extends FieldPath<T> = FieldPath<T>,\n> = {\n name: U;\n};\n\n// eslint-disable-next-line ts/naming-convention\nconst FormFieldContext = createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\n// eslint-disable-next-line ts/naming-convention,ts/explicit-function-return-type,ts/explicit-module-boundary-types\nfunction FormField<\n T extends FieldValues = FieldValues,\n U extends FieldPath<T> = FieldPath<T>,\n>({\n ...props\n}: ControllerProps<T, U>) {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n}\n\ntype FormItemContextValue = {\n id: string;\n};\n\n// eslint-disable-next-line ts/naming-convention\nconst FormItemContext = createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\n// eslint-disable-next-line ts/explicit-function-return-type,ts/explicit-module-boundary-types\nfunction useFormField() {\n const fieldContext = useContext(FormFieldContext);\n const itemContext = useContext(FormItemContext);\n const { getFieldState, formState } = useFormContext();\n\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error('useFormField should be used within <FormField>');\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n}\n\n// eslint-disable-next-line ts/naming-convention\nconst FormItem = forwardRef<\n HTMLDivElement,\n HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const id = useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn('space-y-2', className)} {...props} />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = 'FormItem';\n\n// eslint-disable-next-line ts/naming-convention\nconst FormLabel = forwardRef<\n ElementRef<typeof LabelPrimitive.Root>,\n ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n className={cn(error && 'text-destructive', className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = 'FormLabel';\n\n// eslint-disable-next-line ts/naming-convention\nconst FormControl = forwardRef<\n ElementRef<typeof Slot>,\n ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n error ? `${formDescriptionId} ${formMessageId}` : `${formDescriptionId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = 'FormControl';\n\n// eslint-disable-next-line ts/naming-convention\nconst FormDescription = forwardRef<\n HTMLParagraphElement,\n HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn('text-[0.8rem] text-muted-foreground', className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = 'FormDescription';\n\n// eslint-disable-next-line ts/naming-convention\nconst FormMessage = forwardRef<\n HTMLParagraphElement,\n HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message) : children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn('text-[0.8rem] font-medium text-destructive', className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = 'FormMessage';\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n"],"names":["FormProvider","createContext","jsx","Controller","useContext","useFormContext","forwardRef","useId","cn","Label","Slot"],"mappings":";;;;;;;;AAyBA,MAAM,OAAOA,cAAA;AAUb,MAAM,mBAAmBC,MAAA;AAAA,EACvB,CAAC;AACH;AAGA,SAAS,UAGP;AAAA,EACA,GAAG;AACL,GAA0B;AACxB,SACGC,2BAAAA,IAAA,iBAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAM,MAAM,KAAA,GAC9C,UAAAA,2BAAAA,IAACC,cAAY,YAAA,EAAA,GAAG,OAAO,EACzB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J,2BAAA;AAAA,IAACQ,UAAA;AAAA,IAAA;AAAA,MACC;AAAA,MACA,IAAI;AAAA,MACJ,oBACE,QAAQ,GAAG,iBAAiB,IAAI,aAAa,KAAK,GAAG,iBAAiB;AAAA,MAExE,gBAAc,CAAC,CAAC;AAAA,MACf,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD,YAAY,cAAc;AAGpB,MAAA,kBAAkBJ,iBAGtB,CAAC,EAAE,WAAW,GAAG,SAAS,QAAQ;AAC5B,QAAA,EAAE,sBAAsB;AAG5B,SAAAJ,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,IAAI;AAAA,MACJ,WAAWM,MAAAA,GAAG,uCAAuC,SAAS;AAAA,MAC7D,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD,gBAAgB,cAAc;AAGxB,MAAA,cAAcF,iBAGlB,CAAC,EAAE,WAAW,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC5C,QAAM,EAAE,OAAO,cAAc,IAAI,aAAa;AAC9C,QAAM,OAAO,QAAQ,OAAO,+BAAO,OAAO,IAAI;AAE9C,MAAI,CAAC,MAAM;AACF,WAAA;AAAA,EACT;AAGE,SAAAJ,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,IAAI;AAAA,MACJ,WAAWM,MAAAA,GAAG,8CAA8C,SAAS;AAAA,MACpE,GAAG;AAAA,MAEH,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;AACD,YAAY,cAAc;;;;;;;;;"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const sdkShared = require("@adhese/sdk-shared");
|
|
6
|
+
const utils = require("../utils.cjs");
|
|
7
|
+
const AdheseContext = require("../AdheseContext.cjs");
|
|
8
|
+
const _switch = require("./switch.cjs");
|
|
9
|
+
const label = require("./label.cjs");
|
|
10
|
+
const input = require("./input.cjs");
|
|
11
|
+
const button = require("./button.cjs");
|
|
12
|
+
const cookieKey = "debugKey";
|
|
13
|
+
function setDebugCookie(value) {
|
|
14
|
+
sdkShared.setCookie({
|
|
15
|
+
key: cookieKey,
|
|
16
|
+
value,
|
|
17
|
+
expires: new Date(Date.now() + 24 * 60 * 60 * 1e3)
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function simpleStringify(value) {
|
|
21
|
+
if (typeof value === "object")
|
|
22
|
+
return Object.values(value).map((nestedValue) => `${simpleStringify(nestedValue)}`).join("");
|
|
23
|
+
if (typeof value === "boolean")
|
|
24
|
+
return value ? "1" : "0";
|
|
25
|
+
return String(value);
|
|
26
|
+
}
|
|
27
|
+
function FronttailSettings({
|
|
28
|
+
className,
|
|
29
|
+
"aria-labelledby": ariaLabelledBy,
|
|
30
|
+
...props
|
|
31
|
+
}) {
|
|
32
|
+
const adheseContext = AdheseContext.useAdheseContext();
|
|
33
|
+
const autoGeneratedKey = react.useMemo(() => `adhese-${adheseContext.options.account}-${btoa(simpleStringify(adheseContext.options)).slice(0, 20)}`, [adheseContext.options]);
|
|
34
|
+
const [fronttailDebugKey, setFronttailDebugKey] = react.useState(sdkShared.getCookie(cookieKey) ?? autoGeneratedKey);
|
|
35
|
+
const [isFronttailEnabled, setIsFronttailEnabled] = react.useState(sdkShared.hasCookie(cookieKey));
|
|
36
|
+
const onFronttailDebugKeyChange = react.useCallback((event) => {
|
|
37
|
+
const { value } = event.target;
|
|
38
|
+
setFronttailDebugKey(value);
|
|
39
|
+
if (isFronttailEnabled && value.length > 4)
|
|
40
|
+
setDebugCookie(value);
|
|
41
|
+
}, [setDebugCookie, isFronttailEnabled]);
|
|
42
|
+
const onFrontailEnabledChange = react.useCallback(() => {
|
|
43
|
+
setIsFronttailEnabled((value) => {
|
|
44
|
+
if (value)
|
|
45
|
+
sdkShared.deleteCookie(cookieKey);
|
|
46
|
+
else
|
|
47
|
+
setDebugCookie(fronttailDebugKey);
|
|
48
|
+
return !value;
|
|
49
|
+
});
|
|
50
|
+
}, [setDebugCookie, fronttailDebugKey]);
|
|
51
|
+
const id = react.useId();
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: utils.cn("flex flex-col gap-6", className), "aria-labelledby": ariaLabelledBy ?? `fronttailHeading${id}`, ...props, children: [
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold", id: `fronttailHeading${id}`, children: "Fronttail settings" }),
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsx(_switch.Switch, { checked: isFronttailEnabled, onCheckedChange: onFrontailEnabledChange, id: `fronttailSwitch${id}` }),
|
|
56
|
+
/* @__PURE__ */ jsxRuntime.jsxs(label.Label, { htmlFor: `fronttailSwitch${id}`, children: [
|
|
57
|
+
"Enable Fronttail debugging",
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 font-normal", children: " – Cookie will expire automatically in 1 day" })
|
|
59
|
+
] })
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
62
|
+
/* @__PURE__ */ jsxRuntime.jsx(label.Label, { htmlFor: `fronttailDebugKey${id}`, children: "Debug key" }),
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
input.Input,
|
|
66
|
+
{
|
|
67
|
+
id: `fronttailDebugKey${id}`,
|
|
68
|
+
value: fronttailDebugKey,
|
|
69
|
+
onChange: onFronttailDebugKeyChange,
|
|
70
|
+
className: utils.cn("max-w-60", {
|
|
71
|
+
// eslint-disable-next-line ts/naming-convention
|
|
72
|
+
"border-destructive": fronttailDebugKey.length < 4
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
77
|
+
button.Button,
|
|
78
|
+
{
|
|
79
|
+
variant: "outline",
|
|
80
|
+
onClick: () => {
|
|
81
|
+
setFronttailDebugKey(autoGeneratedKey);
|
|
82
|
+
if (isFronttailEnabled)
|
|
83
|
+
setDebugCookie(autoGeneratedKey);
|
|
84
|
+
},
|
|
85
|
+
children: "Auto generate key"
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
] }),
|
|
89
|
+
fronttailDebugKey.length < 4 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-destructive", children: "Debug key must contain at least 4 characters" })
|
|
90
|
+
] })
|
|
91
|
+
] });
|
|
92
|
+
}
|
|
93
|
+
exports.FronttailSettings = FronttailSettings;
|
|
94
|
+
//# sourceMappingURL=fronttailSettings.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fronttailSettings.cjs","sources":["../../../src/components/fronttailSettings.tsx"],"sourcesContent":["import { type ChangeEventHandler, type HTMLAttributes, type ReactElement, useCallback, useId, useMemo, useState } from 'react';\nimport { deleteCookie, getCookie, hasCookie, setCookie } from '@adhese/sdk-shared';\nimport { cn } from '../utils';\nimport { useAdheseContext } from '../AdheseContext';\nimport { Switch } from './switch';\nimport { Label } from './label';\nimport { Input } from './input';\nimport { Button } from './button';\n\nconst cookieKey = 'debugKey';\n\nfunction setDebugCookie(value: string): void {\n setCookie({\n key: cookieKey,\n value,\n expires: new Date(Date.now() + 24 * 60 * 60 * 1000),\n });\n}\n\nfunction simpleStringify(value: unknown): string {\n if (typeof value === 'object')\n return Object.values(value as object).map(nestedValue => `${simpleStringify(nestedValue)}`).join('');\n\n if (typeof value === 'boolean')\n return value ? '1' : '0';\n\n return String(value);\n}\n\n// eslint-disable-next-line ts/naming-convention\nexport function FronttailSettings({\n className,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n}: HTMLAttributes<HTMLDivElement>): ReactElement {\n const adheseContext = useAdheseContext()!;\n\n const autoGeneratedKey = useMemo(() => `adhese-${adheseContext.options.account}-${btoa(simpleStringify(adheseContext.options)).slice(0, 20)}`, [adheseContext.options]);\n\n const [fronttailDebugKey, setFronttailDebugKey] = useState(getCookie(cookieKey) ?? autoGeneratedKey);\n const [isFronttailEnabled, setIsFronttailEnabled] = useState(hasCookie(cookieKey));\n\n const onFronttailDebugKeyChange = useCallback((event) => {\n const { value } = event.target;\n\n setFronttailDebugKey(value);\n\n if (isFronttailEnabled && value.length > 4)\n setDebugCookie(value);\n }, [setDebugCookie, isFronttailEnabled]) satisfies ChangeEventHandler<HTMLInputElement>;\n\n const onFrontailEnabledChange = useCallback(() => {\n setIsFronttailEnabled((value) => {\n if (value)\n deleteCookie(cookieKey);\n\n else\n setDebugCookie(fronttailDebugKey);\n\n return !value;\n });\n }, [setDebugCookie, fronttailDebugKey]);\n\n const id = useId();\n return (\n <section className={cn('flex flex-col gap-6', className)} aria-labelledby={ariaLabelledBy ?? `fronttailHeading${id}`} {...props}>\n <h2 className=\"text-lg font-semibold\" id={`fronttailHeading${id}`}>Fronttail settings</h2>\n\n <div className=\"flex items-center gap-4\">\n <Switch checked={isFronttailEnabled} onCheckedChange={onFrontailEnabledChange} id={`fronttailSwitch${id}`} />\n <Label htmlFor={`fronttailSwitch${id}`}>\n Enable Fronttail debugging\n <span className=\"text-gray-400 font-normal\"> – Cookie will expire automatically in 1 day</span>\n </Label>\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <Label htmlFor={`fronttailDebugKey${id}`}>\n Debug key\n </Label>\n <div className=\"flex items-center gap-4\">\n <Input\n id={`fronttailDebugKey${id}`}\n value={fronttailDebugKey}\n onChange={onFronttailDebugKeyChange}\n className={\n cn('max-w-60', {\n // eslint-disable-next-line ts/naming-convention\n 'border-destructive': fronttailDebugKey.length < 4,\n })\n }\n />\n\n <Button\n variant=\"outline\"\n onClick={() => {\n setFronttailDebugKey(autoGeneratedKey);\n\n if (isFronttailEnabled)\n setDebugCookie(autoGeneratedKey);\n }}\n >\n Auto generate key\n </Button>\n </div>\n {\n fronttailDebugKey.length < 4\n && <span className=\"text-sm text-destructive\">Debug key must contain at least 4 characters</span>\n }\n </div>\n </section>\n );\n}\n"],"names":["setCookie","useAdheseContext","useMemo","useState","getCookie","hasCookie","useCallback","deleteCookie","useId","jsxs","cn","jsx","Switch","Label","Input","Button"],"mappings":";;;;;;;;;;;AASA,MAAM,YAAY;AAElB,SAAS,eAAe,OAAqB;AACjCA,sBAAA;AAAA,IACR,KAAK;AAAA,IACL;AAAA,IACA,SAAS,IAAI,KAAK,KAAK,IAAQ,IAAA,KAAK,KAAK,KAAK,GAAI;AAAA,EAAA,CACnD;AACH;AAEA,SAAS,gBAAgB,OAAwB;AAC/C,MAAI,OAAO,UAAU;AACnB,WAAO,OAAO,OAAO,KAAe,EAAE,IAAI,CAAA,gBAAe,GAAG,gBAAgB,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE;AAErG,MAAI,OAAO,UAAU;AACnB,WAAO,QAAQ,MAAM;AAEvB,SAAO,OAAO,KAAK;AACrB;AAGO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,mBAAmB;AAAA,EACnB,GAAG;AACL,GAAiD;AAC/C,QAAM,gBAAgBC,cAAAA;AAEhB,QAAA,mBAAmBC,cAAQ,MAAM,UAAU,cAAc,QAAQ,OAAO,IAAI,KAAK,gBAAgB,cAAc,OAAO,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,OAAO,CAAC;AAEhK,QAAA,CAAC,mBAAmB,oBAAoB,IAAIC,MAAAA,SAASC,UAAAA,UAAU,SAAS,KAAK,gBAAgB;AACnG,QAAM,CAAC,oBAAoB,qBAAqB,IAAID,MAAS,SAAAE,UAAA,UAAU,SAAS,CAAC;AAE3E,QAAA,4BA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AAAA,UAACG,MAAA;AAAA,UAAA;AAAA,YACC,IAAI,oBAAoB,EAAE;AAAA,YAC1B,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WACEJ,SAAG,YAAY;AAAA;AAAA,cAEb,sBAAsB,kBAAkB,SAAS;AAAA,YAAA,CAClD;AAAA,UAAA;AAAA,QAEL;AAAA,QAEAC,2BAAA;AAAA,UAACI,OAAA;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,SAAS,MAAM;AACb,mCAAqB,gBAAgB;AAEjC,kBAAA;AACF,+BAAe,gBAAgB;AAAA,YACnC;AAAA,YACD,UAAA;AAAA,UAAA;AAAA,QAED;AAAA,MAAA,GACF;AAAA,MAEE,kBAAkB,SAAS,oCACvB,QAAK,EAAA,WAAU,4BAA2B,UAA4C,gDAAA;AAAA,IAAA,GAE9F;AAAA,EACF,EAAA,CAAA;AAEJ;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const utils = require("../utils.cjs");
|
|
6
|
+
const Input = react.forwardRef(
|
|
7
|
+
({ className, type, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8
|
+
"input",
|
|
9
|
+
{
|
|
10
|
+
type,
|
|
11
|
+
className: utils.cn(
|
|
12
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
13
|
+
className
|
|
14
|
+
),
|
|
15
|
+
ref,
|
|
16
|
+
...props
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
Input.displayName = "Input";
|
|
21
|
+
exports.Input = Input;
|
|
22
|
+
//# sourceMappingURL=input.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.cjs","sources":["../../../src/components/input.tsx"],"sourcesContent":["import { type InputHTMLAttributes, forwardRef } from 'react';\nimport { cn } from '../utils';\n\nexport interface InputProps\n extends InputHTMLAttributes<HTMLInputElement> {}\n\n// eslint-disable-next-line ts/naming-convention\nconst Input = forwardRef<HTMLInputElement, InputProps>(\n ({ className, type, ...props }, ref) => (\n <input\n type={type}\n className={cn(\n 'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',\n className,\n )}\n ref={ref}\n {...props}\n />\n ),\n);\nInput.displayName = 'Input';\n\nexport { Input };\n"],"names":["forwardRef","jsx","cn"],"mappings":";;;;;AAOA,MAAM,QAAQA,MAAA;AAAA,EACZ,CAAC,EAAE,WAAW,MAAM,GAAG,SAAS,QAC9BC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAWC,MAAA;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;AACA,MAAM,cAAc;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const LabelPrimitive = require("@radix-ui/react-label");
|
|
5
|
+
const classVarianceAuthority = require("class-variance-authority");
|
|
6
|
+
const react = require("react");
|
|
7
|
+
const utils = require("../utils.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const LabelPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(LabelPrimitive);
|
|
25
|
+
const labelVariants = classVarianceAuthority.cva(
|
|
26
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
27
|
+
);
|
|
28
|
+
const Label = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
29
|
+
LabelPrimitive__namespace.Root,
|
|
30
|
+
{
|
|
31
|
+
ref,
|
|
32
|
+
className: utils.cn(labelVariants(), className),
|
|
33
|
+
...props
|
|
34
|
+
}
|
|
35
|
+
));
|
|
36
|
+
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
37
|
+
exports.Label = Label;
|
|
38
|
+
//# sourceMappingURL=label.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.cjs","sources":["../../../src/components/label.tsx"],"sourcesContent":["// eslint-disable-next-line ts/naming-convention\nimport * as LabelPrimitive from '@radix-ui/react-label';\nimport { type VariantProps, cva } from 'class-variance-authority';\nimport { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from 'react';\nimport { cn } from '../utils';\n\nconst labelVariants = cva(\n 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n);\n\n// eslint-disable-next-line ts/naming-convention\nconst Label = forwardRef<\n ElementRef<typeof LabelPrimitive.Root>,\n ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root\n ref={ref}\n className={cn(labelVariants(), className)}\n {...props}\n />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n"],"names":["cva","forwardRef","jsx","LabelPrimitive","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,gBAAgBA,uBAAA;AAAA,EACpB;AACF;AAGM,MAAA,QAAQC,iBAIZ,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAA;AAAA,EAACC,0BAAe;AAAA,EAAf;AAAA,IACC;AAAA,IACA,WAAWC,MAAA,GAAG,cAAc,GAAG,SAAS;AAAA,IACvC,GAAG;AAAA,EAAA;AACN,CACD;AACD,MAAM,cAAcD,0BAAe,KAAK;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const AdheseContext = require("../AdheseContext.cjs");
|
|
6
|
+
const table = require("./table.cjs");
|
|
7
|
+
const badge = require("./badge.cjs");
|
|
8
|
+
const dateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
9
|
+
hour: "numeric",
|
|
10
|
+
minute: "numeric",
|
|
11
|
+
second: "numeric",
|
|
12
|
+
fractionalSecondDigits: 3,
|
|
13
|
+
hour12: false
|
|
14
|
+
});
|
|
15
|
+
const logTableRowClasses = {
|
|
16
|
+
error: "bg-red-100 text-red-900",
|
|
17
|
+
warn: "bg-amber-100 text-amber-900"
|
|
18
|
+
};
|
|
19
|
+
const logBadgeClasses = {
|
|
20
|
+
error: "bg-red-500 text-white",
|
|
21
|
+
warn: "bg-amber-500 text-white",
|
|
22
|
+
info: "bg-blue-500 text-white"
|
|
23
|
+
};
|
|
24
|
+
function LogTable() {
|
|
25
|
+
const [logs, setLogs] = react.useState([]);
|
|
26
|
+
const adheseContext = AdheseContext.useAdheseContext();
|
|
27
|
+
react.useEffect(() => {
|
|
28
|
+
var _a;
|
|
29
|
+
function onLogsChange() {
|
|
30
|
+
var _a2;
|
|
31
|
+
setLogs(
|
|
32
|
+
((_a2 = adheseContext == null ? void 0 : adheseContext.logger) == null ? void 0 : _a2.getLogs().toSorted(
|
|
33
|
+
(a, b) => b.timestamp - a.timestamp
|
|
34
|
+
)) ?? []
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
(_a = adheseContext == null ? void 0 : adheseContext.logger) == null ? void 0 : _a.events.log.addListener(onLogsChange);
|
|
38
|
+
onLogsChange();
|
|
39
|
+
return () => {
|
|
40
|
+
var _a2;
|
|
41
|
+
(_a2 = adheseContext == null ? void 0 : adheseContext.logger) == null ? void 0 : _a2.events.log.removeListener(onLogsChange);
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(table.Table, { children: [
|
|
45
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: "Time" }),
|
|
47
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: "Scope" }),
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: "Level" }),
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: "Message" })
|
|
50
|
+
] }) }),
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableBody, { children: logs.map((log) => /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { className: logTableRowClasses[log.level] ?? "", children: [
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: dateFormatter.format(new Date(log.timestamp)) }),
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: log.scope }),
|
|
54
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
+
badge.Badge,
|
|
56
|
+
{
|
|
57
|
+
variant: "secondary",
|
|
58
|
+
className: logBadgeClasses[log.level] ?? "",
|
|
59
|
+
children: log.level
|
|
60
|
+
}
|
|
61
|
+
) }),
|
|
62
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: log.message })
|
|
63
|
+
] }, log.id)) })
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
exports.LogTable = LogTable;
|
|
67
|
+
//# sourceMappingURL=logTable.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logTable.cjs","sources":["../../../src/components/logTable.tsx"],"sourcesContent":["import { type ReactElement, useEffect, useState } from 'react';\nimport type { Log } from '@adhese/sdk-shared';\nimport { useAdheseContext } from '../AdheseContext';\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './table';\nimport { Badge } from './badge';\n\nconst dateFormatter = new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n fractionalSecondDigits: 3,\n hour12: false,\n});\n\nconst logTableRowClasses: Record<string, string> = {\n error: 'bg-red-100 text-red-900',\n warn: 'bg-amber-100 text-amber-900',\n};\n\nconst logBadgeClasses: Record<string, string> = {\n error: 'bg-red-500 text-white',\n warn: 'bg-amber-500 text-white',\n info: 'bg-blue-500 text-white',\n};\n\n// eslint-disable-next-line ts/naming-convention\nexport function LogTable(): ReactElement {\n const [logs, setLogs] = useState<ReadonlyArray<Log<string>>>([]);\n\n const adheseContext = useAdheseContext();\n\n useEffect(() => {\n function onLogsChange(): void {\n setLogs(\n adheseContext?.logger?.getLogs().toSorted(\n (a, b) => b.timestamp - a.timestamp,\n ) ?? [],\n );\n }\n\n adheseContext?.logger?.events.log.addListener(onLogsChange);\n\n onLogsChange();\n\n return (): void => {\n adheseContext?.logger?.events.log.removeListener(onLogsChange);\n };\n }, []);\n\n return (\n <Table>\n <TableHeader>\n <TableRow>\n <TableHead>Time</TableHead>\n <TableHead>Scope</TableHead>\n <TableHead>Level</TableHead>\n <TableHead>Message</TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {logs.map(log => (\n <TableRow key={log.id} className={logTableRowClasses[log.level] ?? ''}>\n <TableCell>{dateFormatter.format(new Date(log.timestamp))}</TableCell>\n <TableCell>{log.scope}</TableCell>\n <TableCell>\n <Badge\n variant=\"secondary\"\n className={logBadgeClasses[log.level] ?? ''}\n >\n {log.level}\n </Badge>\n </TableCell>\n <TableCell>{log.message}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n}\n"],"names":["useState","useAdheseContext","useEffect","_a","Table","jsx","TableHeader","TableRow","TableHead","TableBody","jsxs","TableCell","Badge"],"mappings":";;;;;;;AAMA,MAAM,gBAAgB,IAAI,KAAK,eAAe,SAAS;AAAA,EACrD,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,wBAAwB;AAAA,EACxB,QAAQ;AACV,CAAC;AAED,MAAM,qBAA6C;AAAA,EACjD,OAAO;AAAA,EACP,MAAM;AACR;AAEA,MAAM,kBAA0C;AAAA,EAC9C,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AACR;AAGO,SAAS,WAAyB;AACvC,QAAM,CAAC,MAAM,OAAO,IAAIA,MAAA,SAAqC,CAAE,CAAA;AAE/D,QAAM,gBAAgBC,cAAAA;AAEtBC,QAAAA,UAAU,MAAM;;AACd,aAAS,eAAqB;;AAC5B;AAAA,UACEC,MAAA,+CAAe,WAAf,gBAAAA,IAAuB,UAAU;AAAA,UAC/B,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE;AAAA,cACvB,CAAC;AAAA,MAAA;AAAA,IAEV;AAEA,yDAAe,WAAf,mBAAuB,OAAO,IAAI,YAAY;AAEjC;AAEb,WAAO,MAAY;;AACjB,OA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ime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const sdkShared = require("@adhese/sdk-shared");
|
|
6
|
+
const AdheseContext = require("../AdheseContext.cjs");
|
|
7
|
+
const table = require("./table.cjs");
|
|
8
|
+
const badge = require("./badge.cjs");
|
|
9
|
+
function ParametersTable() {
|
|
10
|
+
const [parameters, setParameters] = react.useState([]);
|
|
11
|
+
const adheseContext = AdheseContext.useAdheseContext();
|
|
12
|
+
react.useEffect(() => {
|
|
13
|
+
if (!adheseContext)
|
|
14
|
+
return;
|
|
15
|
+
const disposeWatcher = sdkShared.watch(() => adheseContext.parameters, (newParameters) => {
|
|
16
|
+
setParameters(Array.from(newParameters.entries()).map(([name, value]) => ({
|
|
17
|
+
name,
|
|
18
|
+
value
|
|
19
|
+
})).filter(({ value }) => value).toSorted((a, b) => a.name.localeCompare(b.name)));
|
|
20
|
+
}, {
|
|
21
|
+
immediate: true,
|
|
22
|
+
deep: true
|
|
23
|
+
});
|
|
24
|
+
return () => {
|
|
25
|
+
disposeWatcher();
|
|
26
|
+
};
|
|
27
|
+
}, [adheseContext == null ? void 0 : adheseContext.parameters]);
|
|
28
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(table.Table, { children: [
|
|
29
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
|
|
30
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: "Parameter" }),
|
|
31
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: "Value" })
|
|
32
|
+
] }) }),
|
|
33
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableBody, { children: parameters.map((parameter) => /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
|
|
34
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "outline", children: parameter.name }) }),
|
|
35
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: Array.isArray(parameter.value) ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex gap-1", children: parameter.value.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "outline", children: item }) }, index)) }) : /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "outline", children: parameter.value }) })
|
|
36
|
+
] }, parameter.name)) })
|
|
37
|
+
] });
|
|
38
|
+
}
|
|
39
|
+
exports.ParametersTable = ParametersTable;
|
|
40
|
+
//# sourceMappingURL=parametersTable.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parametersTable.cjs","sources":["../../../src/components/parametersTable.tsx"],"sourcesContent":["import { type ReactElement, useEffect, useState } from 'react';\nimport { watch } from '@adhese/sdk-shared';\nimport { useAdheseContext } from '../AdheseContext';\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './table';\nimport { Badge } from './badge';\n\n// eslint-disable-next-line ts/naming-convention\nexport function ParametersTable(): ReactElement {\n const [parameters, setParameters] = useState<ReadonlyArray<{\n name: string;\n value: string | ReadonlyArray<string>;\n }>>([]);\n\n const adheseContext = useAdheseContext();\n\n useEffect(() => {\n if (!adheseContext)\n return;\n\n const disposeWatcher = watch(() => adheseContext.parameters, (newParameters) => {\n setParameters(Array.from(newParameters.entries())\n .map(([name, value]) => ({\n name,\n value,\n }))\n .filter(({ value }) => value)\n .toSorted((a, b) => a.name.localeCompare(b.name)));\n }, {\n immediate: true,\n deep: true,\n });\n\n return (): void => {\n disposeWatcher();\n };\n }, [adheseContext?.parameters]);\n\n return (\n <Table>\n <TableHeader>\n <TableRow>\n <TableHead>Parameter</TableHead>\n <TableHead>Value</TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {parameters.map(parameter => (\n <TableRow key={parameter.name}>\n <TableCell>\n <Badge variant=\"outline\">{parameter.name}</Badge>\n </TableCell>\n <TableCell>\n {\n Array.isArray(parameter.value)\n ? (\n <ul className=\"flex gap-1\">\n {parameter.value.map((item, index) => (\n <li key={index}>\n <Badge variant=\"outline\">{item}</Badge>\n </li>\n ))}\n </ul>\n )\n : <Badge variant=\"outline\">{parameter.value}</Badge>\n }\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n}\n"],"names":["useState","useAdheseContext","useEffect","watch","Table","jsx","TableHeader","TableRow","TableHead","TableBody","TableCell","Badge"],"mappings":";;;;;;;;AAOO,SAAS,kBAAgC;AAC9C,QAAM,CAAC,YAAY,aAAa,IAAIA,MAAA,SAGhC,CAAE,CAAA;AAEN,QAAM,gBAAgBC,cAAAA;AAEtBC,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC;AACH;AAEF,UAAM,iBAAiBC,UAAAA,MAAM,MAAM,cAAc,YAAY,CAAC,kBAAkB;AAChE,oBAAA,MAAM,KAAK,cAAc,QAAQ,CAAC,EAC7C,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO;AAAA,QACvB;AAAA,QACA;AAAA,MAAA,EACA,EACD,OAAO,CAAC,EAAE,MAAA,MAAY,KAAK,EAC3B,SAAS,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,CAAC;AAAA,IAAA,GAClD;AAAA,MACD,WAAW;AAAA,MACX,MAAM;AAAA,IAAA,CACP;AAED,WAAO,MAAY;AACF;IAAA;AAAA,EACjB,GACC,CAAC,+CAAe,UAAU,CAAC;AAE9B,yCACGC,aACC,EAAA,UAAA;AAAA,IAACC,2BAAA,IAAAC,MAAA,aAAA,EACC,0CAACC,MAAAA,UACC,EAAA,UAAA;AAAA,MAAAF,2BAAAA,IAACG,mBAAU,UAAS,YAAA,CAAA;AAAA,MACpBH,2BAAAA,IAACG,mBAAU,UAAK,QAAA,CAAA;AAAA,IAAA,EAAA,CAClB,EACF,CAAA;AAAA,mCACCC,MACE,WAAA,EAAA,UAAA,WAAW,IAAI,CAAA,8CACbF,gBACC,EAAA,UAAA;AAAA,MAAAF,2BAAAA,IAACK,MAAAA,aACC,UAACL,2BAAAA,IAAAM,MAAAA,OAAA,EAAM,SAAQ,WAAW,UAAA,UAAU,MAAK,EAC3C,CAAA;AAAA,MACCN,+BAAAK,MAAAA,WAAA,EAEG,UAAM,MAAA,QAAQ,UAAU,KAAK,IAExBL,2BAAAA,IAAA,MAAA,EAAG,WAAU,cACX,UAAA,UAAU,MAAM,IAAI,CAAC,MAAM,UACzBA,2BAAAA,IAAA,MAAA,EACC,yCAACM,aAAM,EAAA,SAAQ,WAAW,UAAA,KAAA,CAAK,KADxB,KAET,CACD,EACH,CAAA,mCAECA,aAAM,EAAA,SAAQ,WAAW,UAAA,UAAU,MAAM,CAAA,GAElD;AAAA,IAlBa,EAAA,GAAA,UAAU,IAmBzB,CACD,GACH;AAAA,EACF,EAAA,CAAA;AAEJ;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const button = require("./button.cjs");
|
|
5
|
+
function PreviewButton() {
|
|
6
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: window.location.search.includes("adhesePreviewCreativeId") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7
|
+
button.Button,
|
|
8
|
+
{
|
|
9
|
+
onClick: () => {
|
|
10
|
+
const currentUrl = new URL(window.location.href);
|
|
11
|
+
window.location.replace(`${currentUrl.origin}${currentUrl.pathname === "/" ? "" : currentUrl.pathname}`);
|
|
12
|
+
},
|
|
13
|
+
variant: "secondary",
|
|
14
|
+
children: "Disable preview mode"
|
|
15
|
+
}
|
|
16
|
+
) });
|
|
17
|
+
}
|
|
18
|
+
exports.PreviewButton = PreviewButton;
|
|
19
|
+
//# sourceMappingURL=previewButton.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"previewButton.cjs","sources":["../../../src/components/previewButton.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { Button } from './button';\n\n// eslint-disable-next-line ts/naming-convention\nexport function PreviewButton(): ReactElement {\n return (\n <>\n {\n window.location.search.includes('adhesePreviewCreativeId') && (\n <Button\n onClick={() => {\n const currentUrl = new URL(window.location.href);\n\n window.location.replace(`${currentUrl.origin}${currentUrl.pathname === '/' ? '' : currentUrl.pathname}`);\n }}\n variant=\"secondary\"\n >\n Disable preview mode\n </Button>\n )\n }\n </>\n );\n}\n"],"names":["jsx","Button"],"mappings":";;;;AAIO,SAAS,gBAA8B;AAC5C,+DAGE,UAAO,OAAA,SAAS,OAAO,SAAS,yBAAyB,KACvDA,2BAAA;AAAA,IAACC,OAAA;AAAA,IAAA;AAAA,MACC,SAAS,MAAM;AACb,cAAM,aAAa,IAAI,IAAI,OAAO,SAAS,IAAI;AAE/C,eAAO,SAAS,QAAQ,GAAG,WAAW,MAAM,GAAG,WAAW,aAAa,MAAM,KAAK,WAAW,QAAQ,EAAE;AAAA,MACzG;AAAA,MACA,SAAQ;AAAA,MACT,UAAA;AAAA,IAAA;AAAA,EAKH,EAAA,CAAA;AAEJ;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const fronttailSettings = require("./fronttailSettings.cjs");
|
|
5
|
+
const settingClasses = "border-solid border-b-2 border-accent pb-8 mb-8 last:mb-0 last:pb-0 last:border-0";
|
|
6
|
+
function Settings() {
|
|
7
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(fronttailSettings.FronttailSettings, { className: settingClasses }) });
|
|
8
|
+
}
|
|
9
|
+
exports.Settings = Settings;
|
|
10
|
+
//# sourceMappingURL=settings.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.cjs","sources":["../../../src/components/settings.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { FronttailSettings } from './fronttailSettings';\n\nconst settingClasses = 'border-solid border-b-2 border-accent pb-8 mb-8 last:mb-0 last:pb-0 last:border-0';\n\n// eslint-disable-next-line ts/naming-convention\nexport function Settings(): ReactElement {\n return (\n <div>\n <FronttailSettings className={settingClasses} />\n </div>\n );\n}\n"],"names":["jsx","FronttailSettings"],"mappings":";;;;AAGA,MAAM,iBAAiB;AAGhB,SAAS,WAAyB;AACvC,wCACG,OACC,EAAA,UAAAA,2BAAA,IAACC,qCAAkB,EAAA,WAAW,gBAAgB,EAChD,CAAA;AAEJ;;"}
|