@cntrl-site/components 1.0.100 → 1.0.102
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/README.md +25 -1
- package/dist/Burger-C6jI6C1c.js +661 -0
- package/dist/Burger-EMSn7TPB.mjs +1807 -0
- package/dist/ClickGallerie-D_O1XhAO.mjs +270 -0
- package/dist/ClickGallerie-M9xdGR1G.js +36 -0
- package/dist/Components/Burger/BurgerComponent.d.ts +0 -1
- package/dist/Components/ClickGallerie/ClickGallerieComponent.d.ts +0 -1
- package/dist/Components/FAQ/FAQComponent.d.ts +0 -1
- package/dist/Components/Form/FormComponent.d.ts +0 -1
- package/dist/Components/Grid/GridComponent.d.ts +0 -1
- package/dist/Components/Helix/HelixComponent.d.ts +0 -1
- package/dist/Components/Hive/HiveComponent.d.ts +0 -1
- package/dist/Components/LightboxJournal/LightboxJournalComponent.d.ts +0 -1
- package/dist/Components/LightboxStrip/LightboxStripComponent.d.ts +0 -1
- package/dist/Components/List/ListComponent.d.ts +0 -1
- package/dist/Components/Marquee/MarqueeComponent.d.ts +0 -1
- package/dist/Components/MarqueeText/MarqueeTextComponent.d.ts +0 -1
- package/dist/Components/Mercury/MercuryComponent.d.ts +0 -1
- package/dist/Components/OnelinerForm/OnelinerFormComponent.d.ts +0 -1
- package/dist/Components/Pretext/PretextComponent.d.ts +0 -1
- package/dist/Components/Scale/ScaleComponent.d.ts +0 -1
- package/dist/Components/SimpleButton/SimpleButtonComponent.d.ts +0 -1
- package/dist/Components/Slider20/Slider20Component.d.ts +0 -1
- package/dist/Components/TestimonialGrid/TestimonialGridComponent.d.ts +0 -1
- package/dist/Components/TestimonialSingle/TestimonialSingleComponent.d.ts +0 -1
- package/dist/Components/Waterfall/WaterfallComponent.d.ts +0 -1
- package/dist/ControlSlider-SiOt22l_.js +1 -0
- package/dist/ControlSlider-pZv7H6BU.mjs +334 -0
- package/dist/FAQ-C7823fyi.js +166 -0
- package/dist/FAQ-CZ39u4m8.mjs +588 -0
- package/dist/Form-BX5_41nb.mjs +472 -0
- package/dist/Form-Dn-6A1He.js +153 -0
- package/dist/Grid-CemGhf3F.js +374 -0
- package/dist/Grid-cfQsXW3b.mjs +1553 -0
- package/dist/Helix-2Vr-9WBa.js +43 -0
- package/dist/Helix-BmkAKT1G.mjs +315 -0
- package/dist/Hive-BC6zQBsv.js +321 -0
- package/dist/Hive-BGMWinrW.mjs +1425 -0
- package/dist/HiveLightboxTitles-DhEeFKWs.mjs +507 -0
- package/dist/HiveLightboxTitles-DlyptAaK.js +1 -0
- package/dist/ImageRevealSlider-BBWtFjUF.js +1 -0
- package/dist/ImageRevealSlider-BdFGyVEP.mjs +184 -0
- package/dist/Lightbox-CIss_nOG.js +1 -0
- package/dist/Lightbox-eP9qAZzL.mjs +665 -0
- package/dist/LightboxJournal-D59ex6wH.mjs +1613 -0
- package/dist/LightboxJournal-DAEZOPDi.js +523 -0
- package/dist/LightboxStrip-BDjI1jyH.js +386 -0
- package/dist/LightboxStrip-YspzBP8N.mjs +1574 -0
- package/dist/List-C32WImI3.js +377 -0
- package/dist/List-DW7fyJbf.mjs +1891 -0
- package/dist/Marquee-BYClHHws.mjs +551 -0
- package/dist/Marquee-vmHaTGIP.js +133 -0
- package/dist/MarqueeText-4Rip_sQX.mjs +515 -0
- package/dist/MarqueeText-E6OubMOG.js +132 -0
- package/dist/Mercury-BwF_XW2w.js +267 -0
- package/dist/Mercury-DuKJQ1Zo.mjs +1701 -0
- package/dist/OnelinerForm-BEu7_sho.mjs +434 -0
- package/dist/OnelinerForm-C2Y_XMCY.js +194 -0
- package/dist/Pretext-10CcyP1E.mjs +2762 -0
- package/dist/Pretext-DvQ3xsni.js +231 -0
- package/dist/PretextComponent-C3YFICy8.js +1 -0
- package/dist/PretextComponent-Ct0newmn.mjs +11624 -0
- package/dist/RichTextRenderer-B6WtTYlR.mjs +32 -0
- package/dist/RichTextRenderer-CIy6yI8U.js +1 -0
- package/dist/Scale-976sjO8e.js +111 -0
- package/dist/Scale-rLNT4KAk.mjs +345 -0
- package/dist/SimpleButton-C-o2W9bS.mjs +451 -0
- package/dist/SimpleButton-nGEcO2gB.js +243 -0
- package/dist/Slider20-C9o2REDl.js +272 -0
- package/dist/Slider20-Dm8BeCli.mjs +851 -0
- package/dist/SvgImage-B5mR9y6q.mjs +51 -0
- package/dist/SvgImage-DFlmxAoL.js +1 -0
- package/dist/TestimonialGrid-CPu4qQ6B.mjs +492 -0
- package/dist/TestimonialGrid-D4ieiz9e.js +90 -0
- package/dist/TestimonialSingle-CVu15ZtV.js +125 -0
- package/dist/TestimonialSingle-DLdnAVF7.mjs +391 -0
- package/dist/Waterfall-A0FjM2my.mjs +1400 -0
- package/dist/Waterfall-DnPDHbCL.js +287 -0
- package/dist/buildColorVars-CE2D5cQV.js +1 -0
- package/dist/buildColorVars-CLyWQm5K.mjs +21 -0
- package/dist/components-OE3ac1dr.js +1 -0
- package/dist/components-w-jHX-2U.mjs +2053 -0
- package/dist/components.css +1 -1
- package/dist/elements.d.ts +7 -0
- package/dist/elements.js +1 -0
- package/dist/elements.mjs +63 -0
- package/dist/elements.node.d.ts +6 -0
- package/dist/elements.node.js +1 -0
- package/dist/elements.node.mjs +21 -0
- package/dist/forking.d.ts +1 -0
- package/dist/formFieldValidation-DZl2KVaF.js +1 -0
- package/dist/formFieldValidation-DvihFrq5.mjs +21 -0
- package/dist/getColorAlpha-BVBY0N5x.mjs +39 -0
- package/dist/getColorAlpha-CoSseoCn.js +1 -0
- package/dist/getImageRect-BQhQXvT8.js +1 -0
- package/dist/getImageRect-CBMhFNHM.mjs +109 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -28866
- package/dist/index.mjs +16 -62477
- package/dist/loadSvgMaskUrl-DfF7ay6h.js +1 -0
- package/dist/loadSvgMaskUrl-xHgGYgPe.mjs +20 -0
- package/dist/panelAvailability-D179wwJx.mjs +27 -0
- package/dist/panelAvailability-DnOe0rQ4.js +1 -0
- package/dist/react-splide.esm-CabaEmHi.js +6 -0
- package/dist/react-splide.esm-DQqds4PL.mjs +1750 -0
- package/dist/readTestimonialTextMeasure-BIXpGFEt.mjs +13 -0
- package/dist/readTestimonialTextMeasure-CEPaB4Sy.js +1 -0
- package/dist/scalingValue-C9JH5L6O.mjs +6 -0
- package/dist/scalingValue-CSHYgTZl.js +1 -0
- package/dist/sources.d.ts +1 -0
- package/dist/sources.js +23753 -0
- package/dist/sources.mjs +23779 -0
- package/dist/textStylesToCss-05Mn6I_2.mjs +32 -0
- package/dist/textStylesToCss-CNN3zZTV.js +1 -0
- package/dist/types/Component.d.ts +0 -1
- package/dist/useLightboxScrollLock-Hf16Eq4g.js +1 -0
- package/dist/useLightboxScrollLock-VQ07s7EJ.mjs +18 -0
- package/dist/useLightboxSwipeDismiss-Br9uE5G0.js +1 -0
- package/dist/useLightboxSwipeDismiss-SGv6Ra33.mjs +95 -0
- package/dist/useScopedStyles-Bf6yohVQ.js +1 -0
- package/dist/useScopedStyles-DhBG3557.mjs +11 -0
- package/dist/utils-033j3qNL.js +1 -0
- package/dist/utils-FxC9rcxw.mjs +247 -0
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +17 -11
- package/package.json +31 -2
- package/dist/index-2JTNRDR1.js +0 -1
- package/dist/index-DA8t6EZ4.mjs +0 -255
- package/dist/panelAvailability-CgSic84c.mjs +0 -126
- package/dist/panelAvailability-D8c7cdbu.js +0 -1
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { jsxs as W, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import Po, { useState as R, useMemo as or } from "react";
|
|
3
|
+
import { s as n } from "./scalingValue-C9JH5L6O.mjs";
|
|
4
|
+
import { b as rr } from "./buildColorVars-CLyWQm5K.mjs";
|
|
5
|
+
import { g as lo } from "./formFieldValidation-DvihFrq5.mjs";
|
|
6
|
+
import { u as tr } from "./useScopedStyles-DhBG3557.mjs";
|
|
7
|
+
import { o as O, t as L } from "./textStylesToCss-05Mn6I_2.mjs";
|
|
8
|
+
function N(o) {
|
|
9
|
+
return `calc(var(--cntrl-article-width, 100vw) * ${o / 1440})`;
|
|
10
|
+
}
|
|
11
|
+
function er(o) {
|
|
12
|
+
return `
|
|
13
|
+
.${o}-wrapper {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
width: 100%;
|
|
17
|
+
min-height: ${N(48)};
|
|
18
|
+
}
|
|
19
|
+
.${o}-wrapper.${o}-type-C .${o}-input:focus-visible,
|
|
20
|
+
.${o}-wrapper.${o}-type-C .${o}-button:focus-visible {
|
|
21
|
+
outline: none;
|
|
22
|
+
}
|
|
23
|
+
.${o}-form {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
width: 100%;
|
|
27
|
+
}
|
|
28
|
+
.${o}-fields {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
flex: 1;
|
|
32
|
+
min-width: 0;
|
|
33
|
+
}
|
|
34
|
+
.${o}-field-group {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
flex: 1;
|
|
38
|
+
min-width: 0;
|
|
39
|
+
}
|
|
40
|
+
.${o}-field-group.${o}-labeled {
|
|
41
|
+
gap: ${N(4)};
|
|
42
|
+
}
|
|
43
|
+
.${o}-field-label {
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
color: var(--${o}-label-text-color);
|
|
46
|
+
}
|
|
47
|
+
.${o}-input {
|
|
48
|
+
width: 100%;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
outline: none;
|
|
51
|
+
-webkit-tap-highlight-color: transparent;
|
|
52
|
+
background-color: var(--${o}-input-color);
|
|
53
|
+
color: var(--${o}-input-text-color);
|
|
54
|
+
border-color: var(--${o}-input-border-color);
|
|
55
|
+
transition: color 250ms, border-color 250ms, background-color 250ms;
|
|
56
|
+
}
|
|
57
|
+
.${o}-input::placeholder {
|
|
58
|
+
color: var(--${o}-placeholder-color);
|
|
59
|
+
opacity: 1;
|
|
60
|
+
transition: color 250ms, opacity 250ms;
|
|
61
|
+
}
|
|
62
|
+
.${o}-input:hover {
|
|
63
|
+
background-color: var(--${o}-hover-input-color, var(--${o}-input-color));
|
|
64
|
+
color: var(--${o}-hover-input-text-color, var(--${o}-input-text-color));
|
|
65
|
+
border-color: var(--${o}-hover-input-border-color, var(--${o}-input-border-color));
|
|
66
|
+
}
|
|
67
|
+
.${o}-wrapper.${o}-state-hover .${o}-input {
|
|
68
|
+
background-color: var(--${o}-hover-input-color, var(--${o}-input-color));
|
|
69
|
+
color: var(--${o}-hover-input-text-color, var(--${o}-input-text-color));
|
|
70
|
+
border-color: var(--${o}-hover-input-border-color, var(--${o}-input-border-color));
|
|
71
|
+
}
|
|
72
|
+
.${o}-input:focus,
|
|
73
|
+
.${o}-input:focus-visible,
|
|
74
|
+
.${o}-wrapper.${o}-state-focus .${o}-input {
|
|
75
|
+
background-color: var(--${o}-focus-input-color, var(--${o}-input-color));
|
|
76
|
+
color: var(--${o}-focus-input-text-color, var(--${o}-input-text-color));
|
|
77
|
+
border-color: var(--${o}-focus-input-border-color, var(--${o}-input-border-color));
|
|
78
|
+
}
|
|
79
|
+
.${o}-input[data-filled="true"] {
|
|
80
|
+
background-color: var(--${o}-filled-input-color, var(--${o}-input-color));
|
|
81
|
+
color: var(--${o}-filled-input-text-color, var(--${o}-input-text-color));
|
|
82
|
+
border-color: var(--${o}-filled-input-border-color, var(--${o}-input-border-color));
|
|
83
|
+
}
|
|
84
|
+
.${o}-wrapper.${o}-state-filled .${o}-button {
|
|
85
|
+
background-color: var(--${o}-filled-button-color, var(--${o}-button-color));
|
|
86
|
+
color: var(--${o}-filled-button-text-color, var(--${o}-button-text-color));
|
|
87
|
+
border-color: var(--${o}-filled-button-border-color, var(--${o}-button-border-color));
|
|
88
|
+
}
|
|
89
|
+
.${o}-wrapper.${o}-state-success .${o}-input,
|
|
90
|
+
.${o}-wrapper.${o}-state-success .${o}-button {
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
}
|
|
93
|
+
.${o}-wrapper.${o}-state-error .${o}-input {
|
|
94
|
+
}
|
|
95
|
+
.${o}-input[data-field-type="textarea"] {
|
|
96
|
+
resize: vertical;
|
|
97
|
+
}
|
|
98
|
+
.${o}-input:disabled {
|
|
99
|
+
cursor: not-allowed;
|
|
100
|
+
}
|
|
101
|
+
.${o}-button {
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
white-space: nowrap;
|
|
104
|
+
box-sizing: border-box;
|
|
105
|
+
outline: none;
|
|
106
|
+
background-color: var(--${o}-button-color);
|
|
107
|
+
color: var(--${o}-button-text-color);
|
|
108
|
+
border-color: var(--${o}-button-border-color);
|
|
109
|
+
transition: color 250ms, background-color 250ms, border-color 250ms;
|
|
110
|
+
}
|
|
111
|
+
.${o}-button:hover {
|
|
112
|
+
background-color: var(--${o}-hover-button-color, var(--${o}-button-color));
|
|
113
|
+
color: var(--${o}-hover-button-text-color, var(--${o}-button-text-color));
|
|
114
|
+
border-color: var(--${o}-hover-button-border-color, var(--${o}-button-border-color));
|
|
115
|
+
}
|
|
116
|
+
.${o}-wrapper.${o}-state-hover .${o}-button {
|
|
117
|
+
background-color: var(--${o}-hover-button-color, var(--${o}-button-color));
|
|
118
|
+
color: var(--${o}-hover-button-text-color, var(--${o}-button-text-color));
|
|
119
|
+
border-color: var(--${o}-hover-button-border-color, var(--${o}-button-border-color));
|
|
120
|
+
}
|
|
121
|
+
.${o}-button:focus,
|
|
122
|
+
.${o}-button:focus-visible,
|
|
123
|
+
.${o}-wrapper.${o}-state-focus .${o}-button {
|
|
124
|
+
background-color: var(--${o}-focus-button-color, var(--${o}-button-color));
|
|
125
|
+
color: var(--${o}-focus-button-text-color, var(--${o}-button-text-color));
|
|
126
|
+
border-color: var(--${o}-focus-button-border-color, var(--${o}-button-border-color));
|
|
127
|
+
}
|
|
128
|
+
.${o}-input:focus-visible,
|
|
129
|
+
.${o}-wrapper.${o}-state-focus .${o}-input {
|
|
130
|
+
outline: none;
|
|
131
|
+
}
|
|
132
|
+
.${o}-button:focus-visible,
|
|
133
|
+
.${o}-wrapper.${o}-state-focus .${o}-button {
|
|
134
|
+
outline: none;
|
|
135
|
+
}
|
|
136
|
+
.${o}-success {
|
|
137
|
+
margin-top: ${N(8)};
|
|
138
|
+
color: var(--${o}-success-success-color, var(--${o}-success-color));
|
|
139
|
+
}
|
|
140
|
+
.${o}-error {
|
|
141
|
+
margin-top: ${N(8)};
|
|
142
|
+
color: var(--${o}-error-error-color, var(--${o}-error-color));
|
|
143
|
+
}
|
|
144
|
+
.${o}-overlay-anchor {
|
|
145
|
+
position: relative;
|
|
146
|
+
height: auto;
|
|
147
|
+
}
|
|
148
|
+
.${o}-control {
|
|
149
|
+
position: relative;
|
|
150
|
+
z-index: 2;
|
|
151
|
+
width: 100%;
|
|
152
|
+
}
|
|
153
|
+
.${o}-control::before {
|
|
154
|
+
content: "";
|
|
155
|
+
position: absolute;
|
|
156
|
+
top: 0;
|
|
157
|
+
left: 0;
|
|
158
|
+
width: 100%;
|
|
159
|
+
height: 100%;
|
|
160
|
+
min-height: 20px;
|
|
161
|
+
pointer-events: auto;
|
|
162
|
+
z-index: 10;
|
|
163
|
+
}
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
function dr({ settings: o, isEditor: t, isEditMode: no, isPreviewMode: ao, metadata: H, activeEvent: b }) {
|
|
167
|
+
const S = !!no, z = ao && t || !t, { prefix: e } = tr(), {
|
|
168
|
+
type: g = "A",
|
|
169
|
+
fieldsToShow: co = 2,
|
|
170
|
+
textareaRows: V = 1,
|
|
171
|
+
fields: j = [],
|
|
172
|
+
buttonLabel: so,
|
|
173
|
+
gap: io,
|
|
174
|
+
fieldsGap: uo,
|
|
175
|
+
buttonCorners: po,
|
|
176
|
+
buttonStroke: bo,
|
|
177
|
+
buttonPadding: a,
|
|
178
|
+
isButtonFullWidth: F,
|
|
179
|
+
inputCorners: $o,
|
|
180
|
+
inputStroke: A,
|
|
181
|
+
inputPadding: l,
|
|
182
|
+
inputColor: ho,
|
|
183
|
+
inputTextColor: _,
|
|
184
|
+
inputBorderColor: mo,
|
|
185
|
+
placeholderColor: w,
|
|
186
|
+
buttonColor: fo,
|
|
187
|
+
buttonTextColor: I,
|
|
188
|
+
buttonBorderColor: vo,
|
|
189
|
+
labelTextColor: q,
|
|
190
|
+
successColor: G,
|
|
191
|
+
errorColor: go,
|
|
192
|
+
fontFamily: C,
|
|
193
|
+
inputFontSettings: d,
|
|
194
|
+
inputFontSize: U,
|
|
195
|
+
inputLineHeight: D,
|
|
196
|
+
inputLetterSpacing: xo,
|
|
197
|
+
inputWordSpacing: yo,
|
|
198
|
+
inputTextAppearance: So,
|
|
199
|
+
buttonFontSettings: h,
|
|
200
|
+
buttonFontSize: wo,
|
|
201
|
+
buttonLineHeight: Co,
|
|
202
|
+
buttonLetterSpacing: To,
|
|
203
|
+
buttonWordSpacing: ko,
|
|
204
|
+
buttonTextAppearance: Wo,
|
|
205
|
+
labelFontSettings: m,
|
|
206
|
+
labelFontSize: Lo,
|
|
207
|
+
labelLineHeight: No,
|
|
208
|
+
labelLetterSpacing: Ho,
|
|
209
|
+
labelWordSpacing: zo,
|
|
210
|
+
labelTextAppearance: Ao,
|
|
211
|
+
statusFontSettings: f,
|
|
212
|
+
statusFontSize: Bo,
|
|
213
|
+
statusLineHeight: Mo,
|
|
214
|
+
statusLetterSpacing: Ro,
|
|
215
|
+
statusWordSpacing: Oo,
|
|
216
|
+
statusTextAppearance: Vo,
|
|
217
|
+
successMessage: jo,
|
|
218
|
+
errorMessage: J,
|
|
219
|
+
stateOverrides: Fo
|
|
220
|
+
} = o, K = g === "B", p = j.slice(0, Math.min(co, j.length)), _o = {
|
|
221
|
+
fontSettings: {
|
|
222
|
+
fontFamily: C,
|
|
223
|
+
fontWeight: (d == null ? void 0 : d.fontWeight) ?? 400,
|
|
224
|
+
fontStyle: (d == null ? void 0 : d.fontStyle) ?? "normal"
|
|
225
|
+
},
|
|
226
|
+
fontSize: U ?? 0.01,
|
|
227
|
+
lineHeight: D,
|
|
228
|
+
letterSpacing: xo ?? 0,
|
|
229
|
+
wordSpacing: yo ?? 0,
|
|
230
|
+
textAppearance: So,
|
|
231
|
+
color: _
|
|
232
|
+
}, Io = O(L(_o, t)), Y = n(A ?? 0, t), Q = (r) => n(
|
|
233
|
+
(D ?? U ?? 0.01) * r + ((l == null ? void 0 : l.top) ?? 0) + ((l == null ? void 0 : l.bottom) ?? 0) + (g === "C" ? A ?? 0 : (A ?? 0) * 2),
|
|
234
|
+
t
|
|
235
|
+
), X = Q(1), Z = Q(Math.max(1, V)), E = {
|
|
236
|
+
...Io,
|
|
237
|
+
borderStyle: "solid",
|
|
238
|
+
borderRadius: g === "C" ? 0 : n($o ?? 0, t),
|
|
239
|
+
...g === "C" ? {
|
|
240
|
+
borderTopWidth: 0,
|
|
241
|
+
borderRightWidth: 0,
|
|
242
|
+
borderBottomWidth: Y,
|
|
243
|
+
borderLeftWidth: 0
|
|
244
|
+
} : { borderWidth: Y },
|
|
245
|
+
paddingTop: n((l == null ? void 0 : l.top) ?? 0, t),
|
|
246
|
+
paddingRight: n((l == null ? void 0 : l.right) ?? 0, t),
|
|
247
|
+
paddingBottom: n((l == null ? void 0 : l.bottom) ?? 0, t),
|
|
248
|
+
paddingLeft: n((l == null ? void 0 : l.left) ?? 0, t),
|
|
249
|
+
height: X,
|
|
250
|
+
minHeight: X
|
|
251
|
+
}, qo = {
|
|
252
|
+
fontSettings: {
|
|
253
|
+
fontFamily: C,
|
|
254
|
+
fontWeight: (h == null ? void 0 : h.fontWeight) ?? 400,
|
|
255
|
+
fontStyle: (h == null ? void 0 : h.fontStyle) ?? "normal"
|
|
256
|
+
},
|
|
257
|
+
fontSize: wo ?? 0.01,
|
|
258
|
+
lineHeight: Co,
|
|
259
|
+
letterSpacing: To ?? 0,
|
|
260
|
+
wordSpacing: ko ?? 0,
|
|
261
|
+
textAppearance: Wo,
|
|
262
|
+
color: I
|
|
263
|
+
}, Go = O(L(qo, t)), Uo = n(bo ?? 0, t), Do = {
|
|
264
|
+
fontSettings: {
|
|
265
|
+
fontFamily: C,
|
|
266
|
+
fontWeight: (m == null ? void 0 : m.fontWeight) ?? 400,
|
|
267
|
+
fontStyle: (m == null ? void 0 : m.fontStyle) ?? "normal"
|
|
268
|
+
},
|
|
269
|
+
fontSize: Lo ?? 0.01,
|
|
270
|
+
lineHeight: No,
|
|
271
|
+
letterSpacing: Ho ?? 0,
|
|
272
|
+
wordSpacing: zo ?? 0,
|
|
273
|
+
textAppearance: Ao,
|
|
274
|
+
color: q
|
|
275
|
+
}, B = L(Do, t), Jo = {
|
|
276
|
+
fontSettings: {
|
|
277
|
+
fontFamily: C,
|
|
278
|
+
fontWeight: (f == null ? void 0 : f.fontWeight) ?? 400,
|
|
279
|
+
fontStyle: (f == null ? void 0 : f.fontStyle) ?? "normal"
|
|
280
|
+
},
|
|
281
|
+
fontSize: Bo ?? 0.01,
|
|
282
|
+
lineHeight: Mo,
|
|
283
|
+
letterSpacing: Ro ?? 0,
|
|
284
|
+
wordSpacing: Oo ?? 0,
|
|
285
|
+
textAppearance: Vo,
|
|
286
|
+
color: G
|
|
287
|
+
}, P = O(L(Jo, t)), Ko = rr(e, {
|
|
288
|
+
inputColor: ho,
|
|
289
|
+
inputTextColor: _,
|
|
290
|
+
inputBorderColor: mo,
|
|
291
|
+
placeholderColor: w != null && w.trim() ? w : "#cccccc",
|
|
292
|
+
buttonColor: fo,
|
|
293
|
+
buttonTextColor: I,
|
|
294
|
+
buttonBorderColor: vo,
|
|
295
|
+
labelTextColor: q,
|
|
296
|
+
successColor: G,
|
|
297
|
+
errorColor: go
|
|
298
|
+
}, lr, nr, Fo), [$, oo] = R(
|
|
299
|
+
() => Object.fromEntries(p.map((r) => [r.name, ""]))
|
|
300
|
+
), [ro, x] = R("idle"), [Yo, T] = R(null), M = b === "success" ? "success" : b === "error" ? "error" : ro, Qo = b === "error" ? J : Yo, k = b === "filled", y = or(() => {
|
|
301
|
+
if (!k) return $;
|
|
302
|
+
let r = null;
|
|
303
|
+
for (const i of p)
|
|
304
|
+
($[i.name] ?? "").trim().length > 0 || (r = r ?? { ...$ }, r[i.name] = "Filled");
|
|
305
|
+
return r ?? $;
|
|
306
|
+
}, [$, k, p]), Xo = M === "error" ? lo(p, y) : null, Zo = `${b && b !== "default" ? `${e}-state-${b}` : ""}`.trim(), to = H == null ? void 0 : H.submitUrl, eo = (r, i) => {
|
|
307
|
+
oo((u) => ({ ...u, [r]: i }));
|
|
308
|
+
}, Eo = async (r) => {
|
|
309
|
+
if (r.preventDefault(), !z) return;
|
|
310
|
+
const i = Object.fromEntries(
|
|
311
|
+
p.map((s) => {
|
|
312
|
+
var v;
|
|
313
|
+
return [s.name, ((v = $[s.name]) == null ? void 0 : v.trim()) ?? ""];
|
|
314
|
+
}).filter(([, s]) => s)
|
|
315
|
+
);
|
|
316
|
+
if (!to) {
|
|
317
|
+
x("error"), T("No integrations were found for this form.");
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (Object.keys(i).length === 0) return;
|
|
321
|
+
const u = lo(p, $);
|
|
322
|
+
if (u) {
|
|
323
|
+
x("error"), T(u);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
x("submitting"), T(null);
|
|
327
|
+
try {
|
|
328
|
+
const s = await fetch(to, {
|
|
329
|
+
method: "POST",
|
|
330
|
+
headers: { "Content-Type": "application/json" },
|
|
331
|
+
body: JSON.stringify(i)
|
|
332
|
+
});
|
|
333
|
+
if (!s.ok) {
|
|
334
|
+
const v = await s.text();
|
|
335
|
+
throw new Error(v || `Request failed: ${s.status}`);
|
|
336
|
+
}
|
|
337
|
+
x("success"), oo(Object.fromEntries(p.map((v) => [v.name, ""])));
|
|
338
|
+
} catch (s) {
|
|
339
|
+
x("error"), T(s instanceof Error ? s.message : "Something went wrong");
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
return /* @__PURE__ */ W("div", { className: `${e}-wrapper ${e}-type-${g} ${Zo}`.trim(), style: Ko, children: [
|
|
343
|
+
/* @__PURE__ */ c("style", { dangerouslySetInnerHTML: { __html: er(e) } }),
|
|
344
|
+
/* @__PURE__ */ W(
|
|
345
|
+
"form",
|
|
346
|
+
{
|
|
347
|
+
onSubmit: Eo,
|
|
348
|
+
className: `${e}-form`,
|
|
349
|
+
children: [
|
|
350
|
+
/* @__PURE__ */ c("div", { className: `${e}-fields`, children: p.map((r, i) => /* @__PURE__ */ W(Po.Fragment, { children: [
|
|
351
|
+
i > 0 && /* @__PURE__ */ c(
|
|
352
|
+
"div",
|
|
353
|
+
{
|
|
354
|
+
"data-controls": S ? "fieldsGap" : void 0,
|
|
355
|
+
className: S ? `${e}-control` : void 0,
|
|
356
|
+
style: { height: n(uo ?? 0, t) }
|
|
357
|
+
}
|
|
358
|
+
),
|
|
359
|
+
/* @__PURE__ */ W("div", { className: `${e}-field-group${K ? ` ${e}-labeled` : ""}`, children: [
|
|
360
|
+
K && /* @__PURE__ */ c("span", { className: `${e}-field-label`, style: B ? { ...B, lineHeight: B.fontSize } : void 0, children: r.label || r.name }),
|
|
361
|
+
r.type === "textarea" ? /* @__PURE__ */ c(
|
|
362
|
+
"textarea",
|
|
363
|
+
{
|
|
364
|
+
name: r.name,
|
|
365
|
+
autoComplete: "off",
|
|
366
|
+
value: y[r.name] ?? "",
|
|
367
|
+
onChange: (u) => eo(r.name, u.target.value),
|
|
368
|
+
placeholder: r.placeholder,
|
|
369
|
+
className: `${e}-input`,
|
|
370
|
+
style: { ...E, height: Z, minHeight: Z },
|
|
371
|
+
rows: V,
|
|
372
|
+
"data-filled": k || (y[r.name] ?? "").trim().length > 0,
|
|
373
|
+
"data-field-type": "textarea"
|
|
374
|
+
}
|
|
375
|
+
) : /* @__PURE__ */ c(
|
|
376
|
+
"input",
|
|
377
|
+
{
|
|
378
|
+
type: r.type === "phone" ? "tel" : r.type === "email" ? "email" : "text",
|
|
379
|
+
name: r.name,
|
|
380
|
+
autoComplete: "off",
|
|
381
|
+
value: y[r.name] ?? "",
|
|
382
|
+
onChange: (u) => eo(r.name, u.target.value),
|
|
383
|
+
placeholder: r.placeholder,
|
|
384
|
+
required: r.isRequired ?? r.type === "email",
|
|
385
|
+
className: `${e}-input`,
|
|
386
|
+
style: E,
|
|
387
|
+
"data-filled": k || (y[r.name] ?? "").trim().length > 0
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
] })
|
|
391
|
+
] }, i)) }),
|
|
392
|
+
/* @__PURE__ */ c(
|
|
393
|
+
"div",
|
|
394
|
+
{
|
|
395
|
+
"data-controls": S ? "gap" : void 0,
|
|
396
|
+
className: S ? `${e}-control` : void 0,
|
|
397
|
+
style: { height: n(io ?? 0, t) }
|
|
398
|
+
}
|
|
399
|
+
),
|
|
400
|
+
/* @__PURE__ */ c("div", { className: `${e}-overlay-anchor`, children: /* @__PURE__ */ c(
|
|
401
|
+
"button",
|
|
402
|
+
{
|
|
403
|
+
type: z ? "submit" : "button",
|
|
404
|
+
className: `${e}-button`,
|
|
405
|
+
style: {
|
|
406
|
+
borderStyle: "solid",
|
|
407
|
+
borderRadius: n(po ?? 0, t),
|
|
408
|
+
borderWidth: Uo,
|
|
409
|
+
paddingTop: n((a == null ? void 0 : a.top) ?? 0, t),
|
|
410
|
+
paddingRight: n((a == null ? void 0 : a.right) ?? 0, t),
|
|
411
|
+
paddingBottom: n((a == null ? void 0 : a.bottom) ?? 0, t),
|
|
412
|
+
paddingLeft: n((a == null ? void 0 : a.left) ?? 0, t),
|
|
413
|
+
pointerEvents: z ? "auto" : void 0,
|
|
414
|
+
...Go,
|
|
415
|
+
...F ? {
|
|
416
|
+
width: "100%",
|
|
417
|
+
textAlign: "center",
|
|
418
|
+
whiteSpace: "normal"
|
|
419
|
+
} : {}
|
|
420
|
+
},
|
|
421
|
+
children: /* @__PURE__ */ c(
|
|
422
|
+
"span",
|
|
423
|
+
{
|
|
424
|
+
className: `${e}-overlay-anchor`,
|
|
425
|
+
style: F ? {
|
|
426
|
+
display: "inline-block",
|
|
427
|
+
maxWidth: "100%",
|
|
428
|
+
whiteSpace: "normal",
|
|
429
|
+
textAlign: "center"
|
|
430
|
+
} : void 0,
|
|
431
|
+
children: ro === "submitting" ? "..." : so
|
|
432
|
+
}
|
|
433
|
+
)
|
|
434
|
+
}
|
|
435
|
+
) })
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
),
|
|
439
|
+
M === "success" && /* @__PURE__ */ c(
|
|
440
|
+
"p",
|
|
441
|
+
{
|
|
442
|
+
className: `${e}-success`,
|
|
443
|
+
style: { ...P },
|
|
444
|
+
children: jo
|
|
445
|
+
}
|
|
446
|
+
),
|
|
447
|
+
M === "error" && /* @__PURE__ */ c(
|
|
448
|
+
"p",
|
|
449
|
+
{
|
|
450
|
+
className: `${e}-error`,
|
|
451
|
+
style: { ...P },
|
|
452
|
+
role: "alert",
|
|
453
|
+
children: Xo ?? Qo ?? J
|
|
454
|
+
}
|
|
455
|
+
)
|
|
456
|
+
] });
|
|
457
|
+
}
|
|
458
|
+
const lr = {
|
|
459
|
+
inputColor: "input-color",
|
|
460
|
+
inputTextColor: "input-text-color",
|
|
461
|
+
inputBorderColor: "input-border-color",
|
|
462
|
+
placeholderColor: "placeholder-color",
|
|
463
|
+
buttonColor: "button-color",
|
|
464
|
+
buttonTextColor: "button-text-color",
|
|
465
|
+
buttonBorderColor: "button-border-color",
|
|
466
|
+
labelTextColor: "label-text-color",
|
|
467
|
+
successColor: "success-color",
|
|
468
|
+
errorColor: "error-color"
|
|
469
|
+
}, nr = ["hover", "focus", "filled", "success", "error"];
|
|
470
|
+
export {
|
|
471
|
+
dr as Form
|
|
472
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),C=require("react"),a=require("./scalingValue-CSHYgTZl.js"),Zo=require("./buildColorVars-CE2D5cQV.js"),ro=require("./formFieldValidation-DZl2KVaF.js"),Eo=require("./useScopedStyles-Bf6yohVQ.js"),$=require("./textStylesToCss-CNN3zZTV.js");function W(o){return`calc(var(--cntrl-article-width, 100vw) * ${o/1440})`}function Po(o){return`
|
|
2
|
+
.${o}-wrapper {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
width: 100%;
|
|
6
|
+
min-height: ${W(48)};
|
|
7
|
+
}
|
|
8
|
+
.${o}-wrapper.${o}-type-C .${o}-input:focus-visible,
|
|
9
|
+
.${o}-wrapper.${o}-type-C .${o}-button:focus-visible {
|
|
10
|
+
outline: none;
|
|
11
|
+
}
|
|
12
|
+
.${o}-form {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
17
|
+
.${o}-fields {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
flex: 1;
|
|
21
|
+
min-width: 0;
|
|
22
|
+
}
|
|
23
|
+
.${o}-field-group {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
flex: 1;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
}
|
|
29
|
+
.${o}-field-group.${o}-labeled {
|
|
30
|
+
gap: ${W(4)};
|
|
31
|
+
}
|
|
32
|
+
.${o}-field-label {
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
color: var(--${o}-label-text-color);
|
|
35
|
+
}
|
|
36
|
+
.${o}-input {
|
|
37
|
+
width: 100%;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
outline: none;
|
|
40
|
+
-webkit-tap-highlight-color: transparent;
|
|
41
|
+
background-color: var(--${o}-input-color);
|
|
42
|
+
color: var(--${o}-input-text-color);
|
|
43
|
+
border-color: var(--${o}-input-border-color);
|
|
44
|
+
transition: color 250ms, border-color 250ms, background-color 250ms;
|
|
45
|
+
}
|
|
46
|
+
.${o}-input::placeholder {
|
|
47
|
+
color: var(--${o}-placeholder-color);
|
|
48
|
+
opacity: 1;
|
|
49
|
+
transition: color 250ms, opacity 250ms;
|
|
50
|
+
}
|
|
51
|
+
.${o}-input:hover {
|
|
52
|
+
background-color: var(--${o}-hover-input-color, var(--${o}-input-color));
|
|
53
|
+
color: var(--${o}-hover-input-text-color, var(--${o}-input-text-color));
|
|
54
|
+
border-color: var(--${o}-hover-input-border-color, var(--${o}-input-border-color));
|
|
55
|
+
}
|
|
56
|
+
.${o}-wrapper.${o}-state-hover .${o}-input {
|
|
57
|
+
background-color: var(--${o}-hover-input-color, var(--${o}-input-color));
|
|
58
|
+
color: var(--${o}-hover-input-text-color, var(--${o}-input-text-color));
|
|
59
|
+
border-color: var(--${o}-hover-input-border-color, var(--${o}-input-border-color));
|
|
60
|
+
}
|
|
61
|
+
.${o}-input:focus,
|
|
62
|
+
.${o}-input:focus-visible,
|
|
63
|
+
.${o}-wrapper.${o}-state-focus .${o}-input {
|
|
64
|
+
background-color: var(--${o}-focus-input-color, var(--${o}-input-color));
|
|
65
|
+
color: var(--${o}-focus-input-text-color, var(--${o}-input-text-color));
|
|
66
|
+
border-color: var(--${o}-focus-input-border-color, var(--${o}-input-border-color));
|
|
67
|
+
}
|
|
68
|
+
.${o}-input[data-filled="true"] {
|
|
69
|
+
background-color: var(--${o}-filled-input-color, var(--${o}-input-color));
|
|
70
|
+
color: var(--${o}-filled-input-text-color, var(--${o}-input-text-color));
|
|
71
|
+
border-color: var(--${o}-filled-input-border-color, var(--${o}-input-border-color));
|
|
72
|
+
}
|
|
73
|
+
.${o}-wrapper.${o}-state-filled .${o}-button {
|
|
74
|
+
background-color: var(--${o}-filled-button-color, var(--${o}-button-color));
|
|
75
|
+
color: var(--${o}-filled-button-text-color, var(--${o}-button-text-color));
|
|
76
|
+
border-color: var(--${o}-filled-button-border-color, var(--${o}-button-border-color));
|
|
77
|
+
}
|
|
78
|
+
.${o}-wrapper.${o}-state-success .${o}-input,
|
|
79
|
+
.${o}-wrapper.${o}-state-success .${o}-button {
|
|
80
|
+
pointer-events: none;
|
|
81
|
+
}
|
|
82
|
+
.${o}-wrapper.${o}-state-error .${o}-input {
|
|
83
|
+
}
|
|
84
|
+
.${o}-input[data-field-type="textarea"] {
|
|
85
|
+
resize: vertical;
|
|
86
|
+
}
|
|
87
|
+
.${o}-input:disabled {
|
|
88
|
+
cursor: not-allowed;
|
|
89
|
+
}
|
|
90
|
+
.${o}-button {
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
white-space: nowrap;
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
outline: none;
|
|
95
|
+
background-color: var(--${o}-button-color);
|
|
96
|
+
color: var(--${o}-button-text-color);
|
|
97
|
+
border-color: var(--${o}-button-border-color);
|
|
98
|
+
transition: color 250ms, background-color 250ms, border-color 250ms;
|
|
99
|
+
}
|
|
100
|
+
.${o}-button:hover {
|
|
101
|
+
background-color: var(--${o}-hover-button-color, var(--${o}-button-color));
|
|
102
|
+
color: var(--${o}-hover-button-text-color, var(--${o}-button-text-color));
|
|
103
|
+
border-color: var(--${o}-hover-button-border-color, var(--${o}-button-border-color));
|
|
104
|
+
}
|
|
105
|
+
.${o}-wrapper.${o}-state-hover .${o}-button {
|
|
106
|
+
background-color: var(--${o}-hover-button-color, var(--${o}-button-color));
|
|
107
|
+
color: var(--${o}-hover-button-text-color, var(--${o}-button-text-color));
|
|
108
|
+
border-color: var(--${o}-hover-button-border-color, var(--${o}-button-border-color));
|
|
109
|
+
}
|
|
110
|
+
.${o}-button:focus,
|
|
111
|
+
.${o}-button:focus-visible,
|
|
112
|
+
.${o}-wrapper.${o}-state-focus .${o}-button {
|
|
113
|
+
background-color: var(--${o}-focus-button-color, var(--${o}-button-color));
|
|
114
|
+
color: var(--${o}-focus-button-text-color, var(--${o}-button-text-color));
|
|
115
|
+
border-color: var(--${o}-focus-button-border-color, var(--${o}-button-border-color));
|
|
116
|
+
}
|
|
117
|
+
.${o}-input:focus-visible,
|
|
118
|
+
.${o}-wrapper.${o}-state-focus .${o}-input {
|
|
119
|
+
outline: none;
|
|
120
|
+
}
|
|
121
|
+
.${o}-button:focus-visible,
|
|
122
|
+
.${o}-wrapper.${o}-state-focus .${o}-button {
|
|
123
|
+
outline: none;
|
|
124
|
+
}
|
|
125
|
+
.${o}-success {
|
|
126
|
+
margin-top: ${W(8)};
|
|
127
|
+
color: var(--${o}-success-success-color, var(--${o}-success-color));
|
|
128
|
+
}
|
|
129
|
+
.${o}-error {
|
|
130
|
+
margin-top: ${W(8)};
|
|
131
|
+
color: var(--${o}-error-error-color, var(--${o}-error-color));
|
|
132
|
+
}
|
|
133
|
+
.${o}-overlay-anchor {
|
|
134
|
+
position: relative;
|
|
135
|
+
height: auto;
|
|
136
|
+
}
|
|
137
|
+
.${o}-control {
|
|
138
|
+
position: relative;
|
|
139
|
+
z-index: 2;
|
|
140
|
+
width: 100%;
|
|
141
|
+
}
|
|
142
|
+
.${o}-control::before {
|
|
143
|
+
content: "";
|
|
144
|
+
position: absolute;
|
|
145
|
+
top: 0;
|
|
146
|
+
left: 0;
|
|
147
|
+
width: 100%;
|
|
148
|
+
height: 100%;
|
|
149
|
+
min-height: 20px;
|
|
150
|
+
pointer-events: auto;
|
|
151
|
+
z-index: 10;
|
|
152
|
+
}
|
|
153
|
+
`}function oe({settings:o,isEditor:r,isEditMode:to,isPreviewMode:lo,metadata:L,activeEvent:b}){const w=!!to,N=lo&&r||!r,{prefix:t}=Eo.useScopedStyles(),{type:x="A",fieldsToShow:no=2,textareaRows:B=1,fields:M=[],buttonLabel:ao,gap:co,fieldsGap:so,buttonCorners:io,buttonStroke:uo,buttonPadding:c,isButtonFullWidth:R,inputCorners:po,inputStroke:H,inputPadding:l,inputColor:bo,inputTextColor:q,inputBorderColor:$o,placeholderColor:T,buttonColor:ho,buttonTextColor:F,buttonBorderColor:vo,labelTextColor:O,successColor:_,errorColor:mo,fontFamily:V,inputFontSettings:h,inputFontSize:I,inputLineHeight:G,inputLetterSpacing:go,inputWordSpacing:fo,inputTextAppearance:xo,buttonFontSettings:v,buttonFontSize:yo,buttonLineHeight:So,buttonLetterSpacing:Co,buttonWordSpacing:wo,buttonTextAppearance:To,labelFontSettings:m,labelFontSize:Vo,labelLineHeight:jo,labelLetterSpacing:ko,labelWordSpacing:Wo,labelTextAppearance:Lo,statusFontSettings:g,statusFontSize:No,statusLineHeight:Ho,statusLetterSpacing:zo,statusWordSpacing:Ao,statusTextAppearance:Bo,successMessage:Mo,errorMessage:U,stateOverrides:Ro}=o,D=x==="B",p=M.slice(0,Math.min(no,M.length)),qo={fontSettings:{fontFamily:V,fontWeight:(h==null?void 0:h.fontWeight)??400,fontStyle:(h==null?void 0:h.fontStyle)??"normal"},fontSize:I??.01,lineHeight:G,letterSpacing:go??0,wordSpacing:fo??0,textAppearance:xo,color:q},Fo=$.omitTextColors($.textStylesToCss(qo,r)),J=a.scalingValue(H??0,r),K=e=>a.scalingValue((G??I??.01)*e+((l==null?void 0:l.top)??0)+((l==null?void 0:l.bottom)??0)+(x==="C"?H??0:(H??0)*2),r),Y=K(1),Q=K(Math.max(1,B)),X={...Fo,borderStyle:"solid",borderRadius:x==="C"?0:a.scalingValue(po??0,r),...x==="C"?{borderTopWidth:0,borderRightWidth:0,borderBottomWidth:J,borderLeftWidth:0}:{borderWidth:J},paddingTop:a.scalingValue((l==null?void 0:l.top)??0,r),paddingRight:a.scalingValue((l==null?void 0:l.right)??0,r),paddingBottom:a.scalingValue((l==null?void 0:l.bottom)??0,r),paddingLeft:a.scalingValue((l==null?void 0:l.left)??0,r),height:Y,minHeight:Y},Oo={fontSettings:{fontFamily:V,fontWeight:(v==null?void 0:v.fontWeight)??400,fontStyle:(v==null?void 0:v.fontStyle)??"normal"},fontSize:yo??.01,lineHeight:So,letterSpacing:Co??0,wordSpacing:wo??0,textAppearance:To,color:F},_o=$.omitTextColors($.textStylesToCss(Oo,r)),Io=a.scalingValue(uo??0,r),Go={fontSettings:{fontFamily:V,fontWeight:(m==null?void 0:m.fontWeight)??400,fontStyle:(m==null?void 0:m.fontStyle)??"normal"},fontSize:Vo??.01,lineHeight:jo,letterSpacing:ko??0,wordSpacing:Wo??0,textAppearance:Lo,color:O},z=$.textStylesToCss(Go,r),Uo={fontSettings:{fontFamily:V,fontWeight:(g==null?void 0:g.fontWeight)??400,fontStyle:(g==null?void 0:g.fontStyle)??"normal"},fontSize:No??.01,lineHeight:Ho,letterSpacing:zo??0,wordSpacing:Ao??0,textAppearance:Bo,color:_},Z=$.omitTextColors($.textStylesToCss(Uo,r)),Do=Zo.buildColorVars(t,{inputColor:bo,inputTextColor:q,inputBorderColor:$o,placeholderColor:T!=null&&T.trim()?T:"#cccccc",buttonColor:ho,buttonTextColor:F,buttonBorderColor:vo,labelTextColor:O,successColor:_,errorColor:mo},ee,re,Ro),[d,E]=C.useState(()=>Object.fromEntries(p.map(e=>[e.name,""]))),[P,y]=C.useState("idle"),[Jo,j]=C.useState(null),A=b==="success"?"success":b==="error"?"error":P,Ko=b==="error"?U:Jo,k=b==="filled",S=C.useMemo(()=>{if(!k)return d;let e=null;for(const i of p)(d[i.name]??"").trim().length>0||(e=e??{...d},e[i.name]="Filled");return e??d},[d,k,p]),Yo=A==="error"?ro.getFormFieldValidationError(p,S):null,Qo=`${b&&b!=="default"?`${t}-state-${b}`:""}`.trim(),oo=L==null?void 0:L.submitUrl,eo=(e,i)=>{E(u=>({...u,[e]:i}))},Xo=async e=>{if(e.preventDefault(),!N)return;const i=Object.fromEntries(p.map(s=>{var f;return[s.name,((f=d[s.name])==null?void 0:f.trim())??""]}).filter(([,s])=>s));if(!oo){y("error"),j("No integrations were found for this form.");return}if(Object.keys(i).length===0)return;const u=ro.getFormFieldValidationError(p,d);if(u){y("error"),j(u);return}y("submitting"),j(null);try{const s=await fetch(oo,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const f=await s.text();throw new Error(f||`Request failed: ${s.status}`)}y("success"),E(Object.fromEntries(p.map(f=>[f.name,""])))}catch(s){y("error"),j(s instanceof Error?s.message:"Something went wrong")}};return n.jsxs("div",{className:`${t}-wrapper ${t}-type-${x} ${Qo}`.trim(),style:Do,children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:Po(t)}}),n.jsxs("form",{onSubmit:Xo,className:`${t}-form`,children:[n.jsx("div",{className:`${t}-fields`,children:p.map((e,i)=>n.jsxs(C.Fragment,{children:[i>0&&n.jsx("div",{"data-controls":w?"fieldsGap":void 0,className:w?`${t}-control`:void 0,style:{height:a.scalingValue(so??0,r)}}),n.jsxs("div",{className:`${t}-field-group${D?` ${t}-labeled`:""}`,children:[D&&n.jsx("span",{className:`${t}-field-label`,style:z?{...z,lineHeight:z.fontSize}:void 0,children:e.label||e.name}),e.type==="textarea"?n.jsx("textarea",{name:e.name,autoComplete:"off",value:S[e.name]??"",onChange:u=>eo(e.name,u.target.value),placeholder:e.placeholder,className:`${t}-input`,style:{...X,height:Q,minHeight:Q},rows:B,"data-filled":k||(S[e.name]??"").trim().length>0,"data-field-type":"textarea"}):n.jsx("input",{type:e.type==="phone"?"tel":e.type==="email"?"email":"text",name:e.name,autoComplete:"off",value:S[e.name]??"",onChange:u=>eo(e.name,u.target.value),placeholder:e.placeholder,required:e.isRequired??e.type==="email",className:`${t}-input`,style:X,"data-filled":k||(S[e.name]??"").trim().length>0})]})]},i))}),n.jsx("div",{"data-controls":w?"gap":void 0,className:w?`${t}-control`:void 0,style:{height:a.scalingValue(co??0,r)}}),n.jsx("div",{className:`${t}-overlay-anchor`,children:n.jsx("button",{type:N?"submit":"button",className:`${t}-button`,style:{borderStyle:"solid",borderRadius:a.scalingValue(io??0,r),borderWidth:Io,paddingTop:a.scalingValue((c==null?void 0:c.top)??0,r),paddingRight:a.scalingValue((c==null?void 0:c.right)??0,r),paddingBottom:a.scalingValue((c==null?void 0:c.bottom)??0,r),paddingLeft:a.scalingValue((c==null?void 0:c.left)??0,r),pointerEvents:N?"auto":void 0,..._o,...R?{width:"100%",textAlign:"center",whiteSpace:"normal"}:{}},children:n.jsx("span",{className:`${t}-overlay-anchor`,style:R?{display:"inline-block",maxWidth:"100%",whiteSpace:"normal",textAlign:"center"}:void 0,children:P==="submitting"?"...":ao})})})]}),A==="success"&&n.jsx("p",{className:`${t}-success`,style:{...Z},children:Mo}),A==="error"&&n.jsx("p",{className:`${t}-error`,style:{...Z},role:"alert",children:Yo??Ko??U})]})}const ee={inputColor:"input-color",inputTextColor:"input-text-color",inputBorderColor:"input-border-color",placeholderColor:"placeholder-color",buttonColor:"button-color",buttonTextColor:"button-text-color",buttonBorderColor:"button-border-color",labelTextColor:"label-text-color",successColor:"success-color",errorColor:"error-color"},re=["hover","focus","filled","success","error"];exports.Form=oe;
|