@cntrl-site/components 1.0.118-alpha.9 → 1.0.119

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.
@@ -0,0 +1,289 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),ge=require("react"),xe=require("./SvgImage-DFlmxAoL.js"),t=require("./scalingValue-CSHYgTZl.js"),me=require("./buildColorVars-CE2D5cQV.js"),we=require("./useScopedStyles-Bf6yohVQ.js"),_=require("./textStylesToCss-CNN3zZTV.js"),ye={backgroundColor:"background-color",textColor:"text-color",borderColor:"border-color",iconColor:"icon-color",boxShadowColor:"box-shadow-color",innerBoxShadowColor:"inner-box-shadow-color"},ke=["hover","active"],Ce=e=>!!e&&e.includes("gradient("),T={left:"flex-start",center:"center",right:"flex-end"};function Se(e,o){const a=e.currentTarget,l=a.getBoundingClientRect(),i=e.clientY-l.top>l.height/2;a.classList.toggle(`${o}-reveal-from-bottom`,i)}function Ve(e,o){const a=e.currentTarget,l=a.getBoundingClientRect(),i=e.clientY<l.top+l.height/2;a.classList.toggle(`${o}-reveal-from-bottom`,i)}function je(e){const o=`var(--${e}-box-shadow-x, 0) var(--${e}-box-shadow-y, 0) var(--${e}-box-shadow-blur, 0) var(--${e}-box-shadow-spread, 0) var(--${e}-box-shadow-color, transparent)`,a=`inset var(--${e}-inner-box-shadow-x, 0) var(--${e}-inner-box-shadow-y, 0) var(--${e}-inner-box-shadow-blur, 0) var(--${e}-inner-box-shadow-spread, 0) var(--${e}-inner-box-shadow-color, transparent)`,l=`${o}, ${a}`,i=`var(--${e}-box-shadow-x, 0) var(--${e}-box-shadow-y, 0) var(--${e}-box-shadow-blur, 0) var(--${e}-box-shadow-spread, 0) var(--${e}-hover-box-shadow-color, var(--${e}-box-shadow-color, transparent))`,r=`inset var(--${e}-inner-box-shadow-x, 0) var(--${e}-inner-box-shadow-y, 0) var(--${e}-inner-box-shadow-blur, 0) var(--${e}-inner-box-shadow-spread, 0) var(--${e}-hover-inner-box-shadow-color, var(--${e}-inner-box-shadow-color, transparent))`,$=`${i}, ${r}`,s=`var(--${e}-box-shadow-x, 0) var(--${e}-box-shadow-y, 0) var(--${e}-box-shadow-blur, 0) var(--${e}-box-shadow-spread, 0) var(--${e}-active-box-shadow-color, var(--${e}-box-shadow-color, transparent))`,b=`inset var(--${e}-inner-box-shadow-x, 0) var(--${e}-inner-box-shadow-y, 0) var(--${e}-inner-box-shadow-blur, 0) var(--${e}-inner-box-shadow-spread, 0) var(--${e}-active-inner-box-shadow-color, var(--${e}-inner-box-shadow-color, transparent))`,g=`${s}, ${b}`,m=`0 4px 12px rgba(0, 0, 0, 0.15), ${a}`,S=`.${e}-button:focus-visible, a:focus-visible .${e}-button`,V=`.${e}-button:hover, ${S}`,d=h=>`.${e}-hover-effect-${h}:hover, .${e}-hover-effect-${h}:focus-visible, a:focus-visible .${e}-hover-effect-${h}`;return`
2
+ .${e}-root {
3
+ line-height: 0;
4
+ }
5
+ .${e}-wrapper {
6
+ display: inline-flex;
7
+ vertical-align: top;
8
+ pointer-events: none;
9
+ }
10
+ .${e}-button {
11
+ display: inline-flex;
12
+ align-items: center;
13
+ box-sizing: border-box;
14
+ border-style: solid;
15
+ border-color: var(--${e}-border-color);
16
+ background: var(--${e}-background-color);
17
+ color: var(--${e}-text-color);
18
+ -webkit-backdrop-filter: var(--${e}-backdrop-blur, none);
19
+ backdrop-filter: var(--${e}-backdrop-blur, none);
20
+ cursor: pointer;
21
+ font: inherit;
22
+ white-space: pre-wrap;
23
+ overflow-wrap: anywhere;
24
+ word-break: break-word;
25
+ user-select: none;
26
+ pointer-events: auto;
27
+ transition: color 250ms, background-color 250ms, border-color 250ms, transform 250ms, box-shadow 250ms, backdrop-filter 250ms;
28
+ box-shadow: ${l};
29
+ }
30
+ .${e}-wrapper.${e}-editing .${e}-button {
31
+ transition: color 250ms, background-color 250ms, border-color 250ms, transform 250ms;
32
+ }
33
+ ${d("scale-up")},
34
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-scale-up {
35
+ transform: scale(1.05);
36
+ }
37
+ ${d("lift")},
38
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-lift {
39
+ transform: translateY(-2px);
40
+ box-shadow: ${m};
41
+ }
42
+ .${e}-hover-effect-reveal,
43
+ .${e}-hover-effect-swipe {
44
+ position: relative;
45
+ overflow: hidden;
46
+ }
47
+ .${e}-hover-effect-reveal .${e}-button-inner,
48
+ .${e}-hover-effect-reveal .${e}-text,
49
+ .${e}-hover-effect-reveal .${e}-icon,
50
+ .${e}-hover-effect-swipe .${e}-button-inner,
51
+ .${e}-hover-effect-swipe .${e}-text,
52
+ .${e}-hover-effect-swipe .${e}-icon {
53
+ position: relative;
54
+ z-index: 1;
55
+ }
56
+ .${e}-hover-effect-reveal::before {
57
+ content: '';
58
+ position: absolute;
59
+ inset: 0;
60
+ background: var(--${e}-hover-background-color, var(--${e}-background-color));
61
+ pointer-events: none;
62
+ z-index: 0;
63
+ transform: scaleY(0);
64
+ transform-origin: bottom center;
65
+ transition: transform 120ms;
66
+ }
67
+ .${e}-hover-effect-reveal:hover::before,
68
+ .${e}-hover-effect-reveal:focus-visible::before,
69
+ a:focus-visible .${e}-hover-effect-reveal::before,
70
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-reveal::before {
71
+ transform: scaleY(1);
72
+ transform-origin: top center;
73
+ }
74
+ .${e}-hover-effect-reveal.${e}-reveal-from-bottom::before {
75
+ transform-origin: top center;
76
+ }
77
+ .${e}-hover-effect-reveal.${e}-reveal-from-bottom:hover::before,
78
+ .${e}-hover-effect-reveal.${e}-reveal-from-bottom:focus-visible::before,
79
+ a:focus-visible .${e}-hover-effect-reveal.${e}-reveal-from-bottom::before,
80
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-reveal.${e}-reveal-from-bottom::before {
81
+ transform-origin: bottom center;
82
+ }
83
+ .${e}-hover-effect-swipe::before {
84
+ content: '';
85
+ position: absolute;
86
+ inset: 0;
87
+ background: var(--${e}-hover-background-color, var(--${e}-background-color));
88
+ pointer-events: none;
89
+ z-index: 0;
90
+ transform: translateX(-100%);
91
+ transition: transform 250ms;
92
+ }
93
+ .${e}-hover-effect-swipe:hover::before,
94
+ .${e}-hover-effect-swipe:focus-visible::before,
95
+ a:focus-visible .${e}-hover-effect-swipe::before,
96
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-swipe::before {
97
+ transform: translateX(0);
98
+ }
99
+ ${d("reveal")},
100
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-reveal,
101
+ ${d("swipe")},
102
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-swipe {
103
+ background: var(--${e}-background-color);
104
+ }
105
+ .${e}-hover-effect-content-roll {
106
+ position: relative;
107
+ overflow: hidden;
108
+ align-items: stretch;
109
+ }
110
+ .${e}-content-roll-wrap {
111
+ position: relative;
112
+ align-self: stretch;
113
+ min-width: 0;
114
+ }
115
+ .${e}-content-roll-wrap.${e}-icon-text-roll {
116
+ flex: 1;
117
+ width: 100%;
118
+ }
119
+ .${e}-content-roll-wrap.${e}-icon-roll,
120
+ .${e}-content-roll-wrap.${e}-label-roll {
121
+ display: inline-block;
122
+ flex: 1;
123
+ }
124
+ .${e}-content-roll-spacer {
125
+ visibility: hidden;
126
+ pointer-events: none;
127
+ }
128
+ .${e}-content-roll-viewport {
129
+ position: absolute;
130
+ inset: 0;
131
+ pointer-events: none;
132
+ }
133
+ .${e}-content-roll-layer {
134
+ position: absolute;
135
+ left: 0;
136
+ right: 0;
137
+ top: 50%;
138
+ transform: translateY(-50%);
139
+ transition: transform 250ms ease, opacity 250ms ease, top 250ms ease;
140
+ opacity: 1;
141
+ pointer-events: none;
142
+ }
143
+ .${e}-content-roll-layer-hover {
144
+ top: 0;
145
+ transform: translateY(-100%);
146
+ opacity: 0;
147
+ }
148
+ .${e}-hover-effect-content-roll:hover .${e}-content-roll-layer:not(.${e}-content-roll-layer-hover),
149
+ .${e}-hover-effect-content-roll:focus-visible .${e}-content-roll-layer:not(.${e}-content-roll-layer-hover),
150
+ a:focus-visible .${e}-hover-effect-content-roll .${e}-content-roll-layer:not(.${e}-content-roll-layer-hover),
151
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-content-roll .${e}-content-roll-layer:not(.${e}-content-roll-layer-hover) {
152
+ top: 100%;
153
+ transform: translateY(0);
154
+ opacity: 0;
155
+ }
156
+ .${e}-hover-effect-content-roll:hover .${e}-content-roll-layer-hover,
157
+ .${e}-hover-effect-content-roll:focus-visible .${e}-content-roll-layer-hover,
158
+ a:focus-visible .${e}-hover-effect-content-roll .${e}-content-roll-layer-hover,
159
+ .${e}-wrapper.${e}-state-hover .${e}-hover-effect-content-roll .${e}-content-roll-layer-hover {
160
+ top: 50%;
161
+ transform: translateY(-50%);
162
+ opacity: 1;
163
+ }
164
+ ${V} {
165
+ background: var(--${e}-hover-background-color, var(--${e}-background-color));
166
+ color: var(--${e}-hover-text-color, var(--${e}-text-color));
167
+ border-color: var(--${e}-hover-border-color, var(--${e}-border-color));
168
+ --${e}-border-fill: var(--${e}-hover-border-color, var(--${e}-border-color));
169
+ box-shadow: ${$};
170
+ }
171
+ .${e}-wrapper.${e}-state-hover .${e}-button {
172
+ background: var(--${e}-hover-background-color, var(--${e}-background-color));
173
+ color: var(--${e}-hover-text-color, var(--${e}-text-color));
174
+ border-color: var(--${e}-hover-border-color, var(--${e}-border-color));
175
+ --${e}-border-fill: var(--${e}-hover-border-color, var(--${e}-border-color));
176
+ box-shadow: ${$};
177
+ }
178
+ .${e}-button:focus,
179
+ .${e}-button:focus-visible,
180
+ a:focus:has(.${e}-button),
181
+ a:focus-visible:has(.${e}-button) {
182
+ outline: none;
183
+ }
184
+ .${e}-button:active,
185
+ a:active .${e}-button {
186
+ background: var(--${e}-active-background-color, var(--${e}-background-color));
187
+ color: var(--${e}-active-text-color, var(--${e}-text-color));
188
+ border-color: var(--${e}-active-border-color, var(--${e}-border-color));
189
+ --${e}-border-fill: var(--${e}-active-border-color, var(--${e}-border-color));
190
+ box-shadow: ${g};
191
+ }
192
+ .${e}-wrapper.${e}-state-active .${e}-button {
193
+ background: var(--${e}-active-background-color, var(--${e}-background-color));
194
+ color: var(--${e}-active-text-color, var(--${e}-text-color));
195
+ border-color: var(--${e}-active-border-color, var(--${e}-border-color));
196
+ --${e}-border-fill: var(--${e}-active-border-color, var(--${e}-border-color));
197
+ box-shadow: ${g};
198
+ }
199
+ /* Gradient border: CSS borders can't take gradients with radius, so the transparent border is covered by a masked ring. */
200
+ .${e}-border-gradient {
201
+ position: relative;
202
+ }
203
+ .${e}-border-gradient::after {
204
+ content: '';
205
+ position: absolute;
206
+ inset: calc(var(--${e}-stroke) * -1);
207
+ padding: var(--${e}-stroke);
208
+ border-radius: inherit;
209
+ background: var(--${e}-border-fill, var(--${e}-border-color));
210
+ -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
211
+ -webkit-mask-composite: xor;
212
+ mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
213
+ pointer-events: none;
214
+ z-index: 2;
215
+ }
216
+ /* overflow would clip the ring, so these effects clip their moving parts instead */
217
+ .${e}-border-gradient.${e}-hover-effect-reveal,
218
+ .${e}-border-gradient.${e}-hover-effect-swipe,
219
+ .${e}-border-gradient.${e}-hover-effect-content-roll {
220
+ overflow: visible;
221
+ }
222
+ .${e}-border-gradient.${e}-hover-effect-reveal::before,
223
+ .${e}-border-gradient.${e}-hover-effect-swipe::before {
224
+ border-radius: max(0px, calc(var(--${e}-radius) - var(--${e}-stroke)));
225
+ }
226
+ .${e}-border-gradient.${e}-hover-effect-swipe::before {
227
+ transform: none;
228
+ clip-path: inset(0 100% 0 0);
229
+ transition: clip-path 250ms;
230
+ }
231
+ .${e}-border-gradient.${e}-hover-effect-swipe:hover::before,
232
+ .${e}-border-gradient.${e}-hover-effect-swipe:focus-visible::before,
233
+ a:focus-visible .${e}-border-gradient.${e}-hover-effect-swipe::before,
234
+ .${e}-wrapper.${e}-state-hover .${e}-border-gradient.${e}-hover-effect-swipe::before {
235
+ clip-path: inset(0);
236
+ }
237
+ /* clip the roll at the padding edge, where the button itself would have clipped it */
238
+ .${e}-border-gradient .${e}-content-roll-viewport {
239
+ clip-path: var(--${e}-roll-clip);
240
+ }
241
+ .${e}-text {
242
+ display: block;
243
+ flex: 1;
244
+ min-width: 0;
245
+ }
246
+ .${e}-icon {
247
+ display: block;
248
+ flex-shrink: 0;
249
+ position: relative;
250
+ }
251
+ .${e}-icon-image {
252
+ transition: background-color 250ms;
253
+ }
254
+ .${e}-button:hover .${e}-icon-image,
255
+ .${e}-button:focus-visible .${e}-icon-image,
256
+ a:focus-visible .${e}-button .${e}-icon-image,
257
+ .${e}-wrapper.${e}-state-hover .${e}-icon-image {
258
+ --fill: var(--${e}-hover-icon-color, var(--${e}-icon-color)) !important;
259
+ --hover-fill: var(--${e}-hover-icon-color, var(--${e}-icon-color)) !important;
260
+ }
261
+ .${e}-button:active .${e}-icon-image,
262
+ a:active .${e}-button .${e}-icon-image,
263
+ .${e}-wrapper.${e}-state-active .${e}-icon-image {
264
+ --fill: var(--${e}-active-icon-color, var(--${e}-icon-color)) !important;
265
+ --hover-fill: var(--${e}-active-icon-color, var(--${e}-icon-color)) !important;
266
+ }
267
+ .${e}-icon .${e}-icon-image {
268
+ width: 100%;
269
+ height: 100%;
270
+ }
271
+ .${e}-icon-fill {
272
+ max-width: 100%;
273
+ width: 100%;
274
+ height: auto;
275
+ }
276
+ .${e}-icon-fill .${e}-icon-image {
277
+ position: relative;
278
+ top: auto;
279
+ left: auto;
280
+ transform: none;
281
+ width: 100%;
282
+ height: auto;
283
+ }
284
+ .${e}-icon-inline {
285
+ display: inline-block;
286
+ height: calc(1em * var(--${e}-icon-scale, 1));
287
+ width: calc(1em * var(--${e}-icon-scale, 1));
288
+ }
289
+ `}function R(e,o,a="",l,i){const r=o();return n.jsxs("span",{className:`${e}-content-roll-wrap ${a}`.trim(),style:l,children:[n.jsx("span",{className:`${e}-content-roll-spacer`,"aria-hidden":"true",style:i,children:r}),n.jsxs("span",{className:`${e}-content-roll-viewport`,children:[n.jsx("span",{className:`${e}-content-roll-layer`,style:i,children:o()}),n.jsx("span",{className:`${e}-content-roll-layer ${e}-content-roll-layer-hover`,"aria-hidden":"true",style:i,children:o()})]})]})}function G(e,o,a="fill",l=100,i=0,r){if(!o)return null;const $=n.jsx(xe.SvgImage,{url:o,fill:`var(--${e}-icon-color)`,hoverFill:`var(--${e}-icon-color)`,className:`${e}-icon-image`});if(a==="inline")return n.jsx("span",{className:`${e}-icon ${e}-icon-inline`,style:{[`--${e}-icon-scale`]:l/100},"aria-hidden":"true",children:$});if(a==="fixed"&&i>0){const s=t.scalingValue(i,r);return n.jsx("span",{className:`${e}-icon`,style:{width:s,height:s},"aria-hidden":"true",children:$})}return n.jsx("span",{className:`${e}-icon ${e}-icon-fill`,"aria-hidden":"true",children:$})}function Ne({settings:e,isEditor:o,isPreviewMode:a,activeEvent:l,hasLink:i}){const{prefix:r}=we.useScopedStyles(),$=ge.useMemo(()=>je(r),[r]),{type:s="a",label:b="Button",icon:g,alignment:m="center",alignA:S,order:V="text-icon",gap:d=0,iconSize:h=0,iconWidthC:A=0,dimensions:D=!1,padding:v={top:0,right:0,bottom:0,left:0},cornerRadius:B=0,boxShadow:w={top:0,left:0,right:0,bottom:0},boxShadowColor:X="rgba(0, 0, 0, 0)",innerBoxShadow:y={top:0,left:0,right:0,bottom:0},innerBoxShadowColor:K="rgba(0, 0, 0, 0)",stroke:I=0,blur:L=0,backgroundColor:J="#000000",textColor:F="#ffffff",borderColor:O="#ffffff",iconColor:Q="#ffffff",hoverEffect:f="none",fontFamily:U,fontSettings:p,fontSize:Z,lineHeight:E,letterSpacing:P=0,wordSpacing:ee=0,textAppearance:oe,stateOverrides:Y,minWidth:re=0,minHeight:te=0,width:ne=0,height:ae=0}=e,le=me.buildColorVars(r,{backgroundColor:J,textColor:F,borderColor:O,iconColor:Q,boxShadowColor:X,innerBoxShadowColor:K},ye,ke,Y),ce=l&&l!=="default"?`${r}-state-${l}`:"",ie=o&&!a?`${r}-editing`:"",se=f!=="none"&&(!o||a||l==="hover")?`${r}-hover-effect-${f}`:"",$e=f==="reveal"||f==="swipe",k=f==="content-roll",M=f==="reveal"&&(!o||a),j=I>0&&[O,...Object.values(Y??{}).map(c=>c==null?void 0:c.borderColor)].some(Ce),ve=j?`${r}-border-gradient`:"",z=t.scalingValue(I,o),q=`max(1px, round(down, ${z}, 1px))`,de=D===!0,u=s==="a"?S??m:m,x=s==="c",be=s!=="b",he={fontSettings:{fontFamily:U,fontWeight:(p==null?void 0:p.fontWeight)??400,fontStyle:(p==null?void 0:p.fontStyle)??"normal"},fontSize:Z??.01,lineHeight:E,letterSpacing:P,wordSpacing:ee,textAppearance:oe,color:F},fe={...be?_.omitTextColors(_.textStylesToCss(he,o)):{},[`--${r}-box-shadow-x`]:t.scalingValue(w.left,o),[`--${r}-box-shadow-y`]:t.scalingValue(w.top,o),[`--${r}-box-shadow-blur`]:t.scalingValue(w.right,o),[`--${r}-box-shadow-spread`]:t.scalingValue(w.bottom,o),[`--${r}-inner-box-shadow-x`]:t.scalingValue(y.left,o),[`--${r}-inner-box-shadow-y`]:t.scalingValue(y.top,o),[`--${r}-inner-box-shadow-blur`]:t.scalingValue(y.right,o),[`--${r}-inner-box-shadow-spread`]:t.scalingValue(y.bottom,o),[`--${r}-backdrop-blur`]:L>0?`blur(${t.scalingValue(L,o)})`:void 0,paddingTop:t.scalingValue(v.top,o),paddingRight:t.scalingValue(v.right,o),paddingBottom:t.scalingValue(v.bottom,o),paddingLeft:t.scalingValue(v.left,o),borderRadius:t.scalingValue(B,o),borderWidth:j?q:z,...j?{[`--${r}-stroke`]:q,[`--${r}-radius`]:t.scalingValue(B,o),[`--${r}-roll-clip`]:`inset(${[v.top,v.right,v.bottom,v.left].map(c=>`calc(${t.scalingValue(c,o)} * -1)`).join(" ")})`,borderColor:"transparent",backgroundClip:"padding-box"}:{backgroundOrigin:"border-box"},...x?{}:{justifyContent:T[u],textAlign:u},...x&&!k?{gap:t.scalingValue(d,o)}:{},...de?{width:t.scalingValue(ne,o),height:t.scalingValue(ae,o)}:{minWidth:t.scalingValue(re,o),minHeight:t.scalingValue(te,o),...x?{width:"100%"}:{}}};let C;const N={display:"inline-flex",alignItems:"center",justifyContent:x?T[u]:T[s==="a"?u:"center"],gap:x?t.scalingValue(d,o):void 0,width:"100%",height:"100%",...s==="a"?{textAlign:u}:{}};if(s==="b"){const c=()=>G(r,g,h>0?"fixed":"fill",100,h,o);C=k?R(r,c,`${r}-icon-roll`,void 0,N):c()}else if(s==="c"){const c=()=>{const H=n.jsx("span",{className:`${r}-text`,style:{textAlign:u},children:b}),W=G(r,g,A>0?"fixed":"fill",100,A,o);return V==="icon-text"?n.jsxs(n.Fragment,{children:[W,H]}):n.jsxs(n.Fragment,{children:[H,W]})};C=k?R(r,c,`${r}-icon-text-roll`,void 0,N):c()}else C=k?R(r,()=>b,`${r}-label-roll`,void 0,N):$e?n.jsx("span",{className:`${r}-button-inner`,children:b}):b;const pe=M?c=>Se(c,r):void 0,ue=M?c=>Ve(c,r):void 0;return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:$}}),n.jsx("div",{className:`${r}-root`,style:le,children:n.jsx("div",{className:`${r}-wrapper ${ce} ${ie}`.trim(),children:n.jsx("div",{className:`${r}-button ${se} ${ve}`.trim(),style:fe,onMouseEnter:pe,onMouseLeave:ue,role:"button",tabIndex:i||o&&!a?void 0:0,children:C})})})]})}exports.SimpleButton=Ne;