@bedrock-layout/solid 0.7.2 → 0.10.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/lib/columns.d.ts +31 -0
- package/lib/cover.d.ts +15 -0
- package/lib/create-container-query.d.ts +2 -0
- package/lib/index.cjs.js +138 -31
- package/lib/index.d.ts +4 -0
- package/lib/index.m.js +297 -2
- package/lib/index.umd.js +131 -24
- package/lib/split.d.ts +15 -0
- package/lib/toPx.d.ts +4 -0
- package/package.json +5 -2
package/lib/columns.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Component, JSX } from "solid-js";
|
|
2
|
+
import { SpacingOptions } from "./spacing-constants";
|
|
3
|
+
import { StackProps } from "./stack";
|
|
4
|
+
interface ColumnsBaseProps {
|
|
5
|
+
gutter?: SpacingOptions;
|
|
6
|
+
columns?: number;
|
|
7
|
+
dense?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ColumnsProps extends StackProps, ColumnsBaseProps {
|
|
10
|
+
switchAt?: number | string;
|
|
11
|
+
as?: Component | keyof JSX.IntrinsicElements;
|
|
12
|
+
ref?: (ref: HTMLElement) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const Columns: Component<ColumnsProps>;
|
|
15
|
+
export interface ColumnProps {
|
|
16
|
+
colSpan?: number;
|
|
17
|
+
offsetStart?: number;
|
|
18
|
+
offsetEnd?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ColumnsProps passed twice to make propTypes work.
|
|
22
|
+
*
|
|
23
|
+
* span is remaped to colSpan due to span being an attribute that gets
|
|
24
|
+
* passed to the underlying element. This can cause issues with Grid layout.
|
|
25
|
+
*
|
|
26
|
+
* In a future breaking change, colSpan should be the public API.
|
|
27
|
+
* */
|
|
28
|
+
export declare const Column: ((props: ColumnProps & JSX.HTMLAttributes<HTMLDivElement>) => JSX.Element) & {
|
|
29
|
+
className: (props: ColumnProps & JSX.HTMLAttributes<HTMLDivElement>) => string;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
package/lib/cover.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, JSX, JSXElement } from "solid-js";
|
|
2
|
+
import { CSSLength, SpacingOptions } from "./spacing-constants";
|
|
3
|
+
declare type MinHeight = CSSLength | number;
|
|
4
|
+
interface CoverWrapperProps {
|
|
5
|
+
gutter?: SpacingOptions;
|
|
6
|
+
minHeight?: MinHeight;
|
|
7
|
+
stretchContent?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CoverProps extends CoverWrapperProps {
|
|
10
|
+
top?: JSXElement;
|
|
11
|
+
bottom?: JSXElement;
|
|
12
|
+
as?: Component | keyof JSX.IntrinsicElements;
|
|
13
|
+
}
|
|
14
|
+
export declare const Cover: Component<CoverProps>;
|
|
15
|
+
export {};
|
package/lib/index.cjs.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var L=Object.defineProperty,V=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var A=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))E.call(t,n)&&A(e,n,t[n]);if(y)for(var n of y(t))z.call(t,n)&&A(e,n,t[n]);return e},b=(e,t)=>V(e,D(t));var j=(e,t)=>{var n={};for(var r in e)E.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&y)for(var r of y(e))t.indexOf(r)<0&&z.call(e,r)&&(n[r]=e[r]);return n};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var c=require("solid-styled-components"),I=require("@bedrock-layout/register-resize-callback"),l=require("solid-js");function S(e){return typeof e!="string"?!1:[/^[0-9]{0,10000}\.?[0-9]{1,10000}(vmin|vmax|vh|vw|%|ch|ex|em|rem|in|cm|mm|pt|pc|px)$/,/^var\(--\D{1,100}\)$/].some(t=>t.test(e))}const $={none:"0px",xxs:"0.0625rem",xs:"0.125rem",sm:"0.25rem",md:"0.5rem",mdLg:"0.75rem",lg:"1rem",lgXl:"1.5rem",xl:"2rem",xlXXl:"3rem",xxl:"4rem"};function W(e){return e.reduce((t,[n,r])=>b(f({},t),{[n]:r}),{})}const u=(e,t)=>{var i,o;const n=(o=(i=t==null?void 0:t.space)!=null?i:t==null?void 0:t.spacing)!=null?o:$,a=W(Object.entries(n).map(([g,d])=>[g,typeof d=="number"?`${d}px`:d]))[e];return S(a)?a:void 0};function X(e){return e===void 0?"100%":typeof e=="number"?`${e}px`:e}const F=c.styled.div`
|
|
2
2
|
@property --maxWidth {
|
|
3
3
|
syntax: "<length-percentage>";
|
|
4
4
|
inherits: false;
|
|
5
5
|
initial-value: 100%;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
--maxWidth: ${
|
|
8
|
+
--maxWidth: ${e=>X(e.maxWidth)};
|
|
9
9
|
|
|
10
10
|
box-sizing: content-box;
|
|
11
11
|
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
|
|
18
18
|
max-inline-size: var(--maxWidth, 100%);
|
|
19
19
|
|
|
20
|
-
${
|
|
20
|
+
${e=>e.centerChildren?c.css`
|
|
21
21
|
display: flex;
|
|
22
22
|
flex-direction: column;
|
|
23
23
|
align-items: center;
|
|
24
24
|
`:""}
|
|
25
25
|
|
|
26
|
-
${
|
|
26
|
+
${e=>e.centerText?c.css`
|
|
27
27
|
text-align: center;
|
|
28
28
|
`:""}
|
|
29
|
-
`;function
|
|
29
|
+
`;function N(e){return e===void 0?"100%":typeof e=="number"?`${e}px`:e}const _=c.styled("div")`
|
|
30
30
|
@property --basis {
|
|
31
31
|
syntax: "<length-percentage>";
|
|
32
32
|
inherits: true;
|
|
@@ -39,29 +39,29 @@
|
|
|
39
39
|
initial-value: 0px;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
--basis: ${
|
|
43
|
-
--gutter: ${
|
|
42
|
+
--basis: ${e=>N(e.basis)};
|
|
43
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
44
44
|
|
|
45
45
|
box-sizing: border-box;
|
|
46
46
|
> * {
|
|
47
47
|
margin: 0;
|
|
48
48
|
flex-basis: var(--basis, 100%);
|
|
49
|
-
flex-grow: ${
|
|
49
|
+
flex-grow: ${e=>e.noStretchedColumns?"0":"1"};
|
|
50
50
|
flex-shrink: 1;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
display: flex;
|
|
54
54
|
flex-wrap: wrap;
|
|
55
55
|
gap: var(--gutter, 0px);
|
|
56
|
-
`;function
|
|
56
|
+
`;function w(e=1,t){if(t!==void 0&&t<=e)throw new Error(`The second width value, ${t}, is not larger than ${e}. Please provide a value greater than first width value`);const[n,r]=l.createSignal(!1),[a,s]=l.createSignal();return l.onMount(()=>{I.init()}),l.createEffect(()=>{const i=a();if(i==null)return;const o=I.registerCallback(i,g=>{var k,R;const d=(R=(k=g.borderBoxSize)==null?void 0:k.inlineSize)!=null?R:g.contentRect.width;if(d>0){const T=t===void 0?d<=e:d>=e&&d<=t;r(T)}});l.onCleanup(o)}),[n,s]}function q(e){return Array.isArray(e)&&e.length===2&&e.every(Number.isFinite)||typeof e=="string"&&/^\d{1,1000} {0,1}\/ {0,1}\d{1,1000}$/.test(e)}function G(e){return Array.isArray(e)?e.join("/"):e}function H(e){return q(e)?G(e):void 0}const Q=c.styled.div`
|
|
57
57
|
box-sizing: border-box;
|
|
58
58
|
display: block;
|
|
59
59
|
inline-size: 100%;
|
|
60
60
|
position: relative;
|
|
61
61
|
overflow: hidden;
|
|
62
62
|
|
|
63
|
-
${
|
|
64
|
-
aspect-ratio: ${
|
|
63
|
+
${e=>{const t=H(e.ratio);return t?c.css`
|
|
64
|
+
aspect-ratio: ${t};
|
|
65
65
|
`:""}};
|
|
66
66
|
|
|
67
67
|
> * {
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
size: 100%;
|
|
87
87
|
|
|
88
88
|
object-fit: cover;
|
|
89
|
-
object-position: ${
|
|
89
|
+
object-position: ${e=>typeof e.position=="string"?e.position:"50%"};
|
|
90
90
|
}
|
|
91
|
-
`,
|
|
91
|
+
`,U=c.styled("div")`
|
|
92
92
|
@property --gutter {
|
|
93
93
|
syntax: "<length-percentage>";
|
|
94
94
|
inherits: false;
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
initial-value: 639px;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
--gutter: ${
|
|
105
|
-
--minItemWidth: ${
|
|
104
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
105
|
+
--minItemWidth: ${e=>{var t;return typeof e.minItemWidth=="string"?e.minItemWidth:`${(t=e.minItemWidth)!=null?t:0}px`}};
|
|
106
106
|
|
|
107
107
|
box-sizing: border-box;
|
|
108
108
|
> * {
|
|
@@ -116,8 +116,8 @@
|
|
|
116
116
|
auto-fit,
|
|
117
117
|
minmax(min(var(--minItemWidth, 639px), 100%), 1fr)
|
|
118
118
|
);
|
|
119
|
-
`,
|
|
120
|
-
--gutter: ${
|
|
119
|
+
`,x={start:"flex-start",end:"flex-end",center:"center"},v=b(f({},x),{stretch:"stretch"}),O=c.styled.div`
|
|
120
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
121
121
|
|
|
122
122
|
box-sizing: border-box;
|
|
123
123
|
> * {
|
|
@@ -128,20 +128,20 @@
|
|
|
128
128
|
flex-wrap: wrap;
|
|
129
129
|
gap: var(--gutter, 0px);
|
|
130
130
|
|
|
131
|
-
justify-content: ${
|
|
131
|
+
justify-content: ${e=>typeof e.justify!="undefined"&&x[e.justify]?x[e.justify]:x.start};
|
|
132
132
|
|
|
133
|
-
align-items: ${
|
|
134
|
-
`;function
|
|
133
|
+
align-items: ${e=>typeof e.align!="undefined"&&v[e.align]?v[e.align]:v.start};
|
|
134
|
+
`;function J(e){return typeof e=="number"&&e>-1?!0:typeof e=="string"&&typeof CSS!==void 0?CSS.supports(`height: ${e}`):!1}const K=c.styled(O)`
|
|
135
135
|
@property --switchAt {
|
|
136
136
|
syntax: "<length-percentage>";
|
|
137
137
|
inherits: true;
|
|
138
138
|
initial-value: 0;
|
|
139
139
|
}
|
|
140
140
|
flex-wrap: nowrap;
|
|
141
|
-
${
|
|
141
|
+
${e=>e.stretch==="all"?"> * { flex: 1 }":e.stretch==="start"?"> :first-child { flex: 1 }":e.stretch==="end"?"> :last-child { flex: 1 }":typeof e.stretch=="number"?`> :nth-child(${e.stretch+1}) { flex: 1 }`:""}
|
|
142
142
|
|
|
143
|
-
${
|
|
144
|
-
--switchAt: ${typeof
|
|
143
|
+
${e=>J(e.switchAt)?`
|
|
144
|
+
--switchAt: ${typeof e.switchAt=="string"?e.switchAt:`${e.switchAt}px`};
|
|
145
145
|
flex-wrap: wrap;
|
|
146
146
|
> * {
|
|
147
147
|
min-inline-size: fit-content;
|
|
@@ -150,32 +150,32 @@
|
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
`:""}
|
|
153
|
-
`,
|
|
153
|
+
`,M=new Set(["left","right","top","bottom","inlineStart","inlineEnd","blockStart","blockEnd"]),Y=(e,t)=>({left:`padding-inline-start:${t};`,right:`padding-inline-end:${t};`,top:`padding-block-start:${t};`,bottom:`padding-block-end:${t};`,inlineStart:`padding-inline-start:${t};`,inlineEnd:`padding-inline-end:${t};`,blockStart:`padding-block-start:${t};`,blockEnd:`padding-block-end:${t};`})[e];function Z(e){return t=>{const n=u(t,e);return n!=null?n:"0px"}}function ee(e,t){var s;if(Array.isArray(t)&&t.length>4)throw new Error("padding arrays can only be 4 or less in length");const n=new Set(Object.keys((s=e==null?void 0:e.spacing)!=null?s:$));(()=>typeof t=="string"?!0:Array.isArray(t)?t.every(i=>n.has(i)):t&&Object.keys(t).every(i=>M.has(i))&&Object.values(t).every(i=>n.has(i)))()||console.error("Invalid padding Type");const a=Z(e);return typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((i,[o,g])=>M.has(o)?i+Y(o,a(g)):i,""):t!==void 0?`padding: ${Array.from(Array.isArray(t)?t:[t]).map(i=>a(i)).join(" ")};`:""}const te=c.styled.div`
|
|
154
154
|
box-sizing: border-box;
|
|
155
|
-
${
|
|
156
|
-
`,
|
|
155
|
+
${e=>ee(e.theme,e.padding)}
|
|
156
|
+
`,ne=c.styled.div`
|
|
157
157
|
box-sizing: border-box;
|
|
158
158
|
> * {
|
|
159
159
|
margin: 0;
|
|
160
160
|
scroll-snap-align: start;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
--gutter: ${
|
|
163
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
164
164
|
|
|
165
165
|
display: flex;
|
|
166
166
|
gap: var(--gutter, 0px);
|
|
167
167
|
|
|
168
168
|
overflow-x: scroll;
|
|
169
169
|
|
|
170
|
-
scroll-snap-type: ${({snapType:
|
|
171
|
-
`,
|
|
170
|
+
scroll-snap-type: ${({snapType:e="none"})=>{switch(e){case"none":return"none";case"proximity":return"x proximity";case"mandatory":return"x mandatory";default:return"none"}}};
|
|
171
|
+
`,C=c.styled("div")`
|
|
172
172
|
@property --gutter {
|
|
173
173
|
syntax: "<length-percentage>";
|
|
174
174
|
inherits: false;
|
|
175
175
|
initial-value: 0;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
--gutter: ${
|
|
178
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
179
179
|
box-sizing: border-box;
|
|
180
180
|
> * {
|
|
181
181
|
margin: 0;
|
|
@@ -189,4 +189,111 @@
|
|
|
189
189
|
& > [data-bedrock-column] {
|
|
190
190
|
grid-column: span 1 / auto;
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
`,m=96;function B(e){var r;e=String(e);const t=parseFloat(e),[,n]=(r=e.match(/[\d.\-+]*\s*(.*)/))!=null?r:["",""];return[t,n]}function h(e,t){if(!e)return null;const n=t!=null?t:document.body,r=(e!=null?e:"px").trim().toLowerCase();switch(r){case"vmin":case"vmax":case"vh":case"vw":case"%":return null;case"ch":case"ex":return re(r,n);case"em":return p(n,"font-size");case"rem":return p(document.body,"font-size");case"in":return m;case"cm":return m/2.54;case"mm":return m/25.4;case"pt":return m/72;case"pc":return m/6;case"px":return 1;default:{const[a,s]=B(r);if(isNaN(a))return null;if(!s)return a;const i=h(s,t);return typeof i=="number"?a*i:null}}}function p(e,t){var a;const[n,r]=B(getComputedStyle(e).getPropertyValue(t));return n*((a=h(r,e))!=null?a:1)}function re(e,t){const n=document.createElement("div");n.style.height="128"+e,t.appendChild(n);const r=p(n,"height")/128;return t.removeChild(n),r}const P={"1/4":"1fr 3fr","1/3":"1fr 2fr","1/2":"1fr 1fr","2/3":"2fr 1fr","3/4":"3fr 1fr","auto-start":"auto 1fr","auto-end":"1fr auto"},ie=c.styled.div`
|
|
193
|
+
box-sizing: border-box;
|
|
194
|
+
> * {
|
|
195
|
+
margin: 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
199
|
+
|
|
200
|
+
display: grid;
|
|
201
|
+
gap: var(--gutter, 0px);
|
|
202
|
+
grid-template-columns: ${({fraction:e="1/2"})=>{var t;return(t=P[e])!=null?t:P["1/2"]}}};
|
|
203
|
+
`,ae=e=>{const t=typeof e.switchAt=="string"?h(e.switchAt):e.switchAt,n=t&&t>-1?t:0;console.log(n);const[r,a]=w(n),s=i=>{var o;a(i),(o=e.ref)==null||o.call(e,i)};return React.createElement(l.Switch,null,React.createElement(l.Match,{when:r()===!1},React.createElement(ie,f({as:e.as,ref:s,fraction:e.fraction},e))),React.createElement(l.Match,{when:r()===!0},React.createElement(C,f({as:e.as,ref:s},e))))};function se(e){return typeof e=="number"?`${e}px`:e&&S(e)?e:"100vh"}const ce=c.styled.div`
|
|
204
|
+
@property --gutter {
|
|
205
|
+
syntax: "<length-percentage>";
|
|
206
|
+
inherits: false;
|
|
207
|
+
initial-value: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@property --minHeight {
|
|
211
|
+
syntax: "<length-percentage>";
|
|
212
|
+
inherits: false;
|
|
213
|
+
initial-value: 100vh;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
217
|
+
|
|
218
|
+
--minHeight: ${e=>se(e.minHeight)};
|
|
219
|
+
|
|
220
|
+
> * {
|
|
221
|
+
margin: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
display: flex;
|
|
225
|
+
flex-direction: column;
|
|
226
|
+
gap: var(--gutter, 0px);
|
|
227
|
+
|
|
228
|
+
min-block-size: var(--minHeight, 100vh);
|
|
229
|
+
|
|
230
|
+
> [data-bedrock-cover-centered] {
|
|
231
|
+
margin-block-start: auto;
|
|
232
|
+
margin-block-end: auto;
|
|
233
|
+
|
|
234
|
+
${({stretchContent:e})=>e===!0?`
|
|
235
|
+
flex: 1;
|
|
236
|
+
display: flex;
|
|
237
|
+
flex-direction: column;
|
|
238
|
+
> * {
|
|
239
|
+
flex: 1;
|
|
240
|
+
}
|
|
241
|
+
`:""};
|
|
242
|
+
}
|
|
243
|
+
`,oe=e=>{const s=e,{top:t,bottom:n,children:r}=s,a=j(s,["top","bottom","children"]);return React.createElement(ce,f({},a),e.top,React.createElement("div",{"data-bedrock-cover-centered":!0},e.children),e.bottom)},le=c.styled.div`
|
|
244
|
+
@property --gutter {
|
|
245
|
+
syntax: "<length-percentage>";
|
|
246
|
+
inherits: false;
|
|
247
|
+
initial-value: 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@property --columns {
|
|
251
|
+
syntax: "<number>";
|
|
252
|
+
inherits: true;
|
|
253
|
+
initial-value: 1;
|
|
254
|
+
}
|
|
255
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=u(e.gutter,e.theme))!=null?t:"0px"}};
|
|
256
|
+
|
|
257
|
+
--columns: ${e=>e.columns&&e.columns>0?e.columns:1};
|
|
258
|
+
|
|
259
|
+
box-sizing: border-box;
|
|
260
|
+
> * {
|
|
261
|
+
margin: 0;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
display: grid;
|
|
265
|
+
grid-template-columns: repeat(var(--columns, 1), 1fr);
|
|
266
|
+
gap: var(--gutter, 0px);
|
|
267
|
+
grid-auto-flow: row ${({dense:e=!1})=>e===!0?"dense":""};
|
|
268
|
+
`,ue=e=>{const t=typeof e.switchAt=="string"?h(e.switchAt):e.switchAt;console.log(t);const n=t&&t>-1?t:0;console.log(n);const[r,a]=w(n),s=i=>{var o;a(i),(o=e.ref)==null||o.call(e,i)};return React.createElement(l.Switch,null,React.createElement(l.Match,{when:r()===!1},React.createElement(le,f({as:e.as,ref:s,columns:e.columns},e))),React.createElement(l.Match,{when:r()===!0},React.createElement(C,f({as:e.as,ref:s},e))))},de=e=>typeof e=="number"?e:1,fe=c.styled.div`
|
|
269
|
+
@property --span {
|
|
270
|
+
syntax: "<number>";
|
|
271
|
+
inherits: true;
|
|
272
|
+
initial-value: 1;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
--span: ${e=>de(e.colSpan)};
|
|
276
|
+
|
|
277
|
+
grid-column: span min(var(--span, 1), var(--columns, 1));
|
|
278
|
+
|
|
279
|
+
${e=>e.offsetStart||e.offsetEnd?`
|
|
280
|
+
display: contents;
|
|
281
|
+
> * {
|
|
282
|
+
grid-column: span min(var(--span, 1), var(--columns, 1));
|
|
283
|
+
}
|
|
284
|
+
`:""}
|
|
285
|
+
|
|
286
|
+
${e=>e.offsetStart&&e.offsetStart>0?`
|
|
287
|
+
&::before {
|
|
288
|
+
content: "";
|
|
289
|
+
grid-column: span min(${e.offsetStart}, var(--columns, 1));
|
|
290
|
+
}
|
|
291
|
+
`:""}
|
|
292
|
+
|
|
293
|
+
${e=>e.offsetEnd&&e.offsetEnd>0?`
|
|
294
|
+
&::after {
|
|
295
|
+
content: "";
|
|
296
|
+
grid-column: span min(${e.offsetEnd}, var(--columns, 1));
|
|
297
|
+
}
|
|
298
|
+
`:""}
|
|
299
|
+
`;exports.Center=F;exports.Column=fe;exports.ColumnDrop=_;exports.Columns=ue;exports.Cover=oe;exports.Frame=Q;exports.Grid=U;exports.Inline=K;exports.InlineCluster=O;exports.PadBox=te;exports.Reel=ne;exports.Split=ae;exports.Stack=C;exports.checkIsCSSLength=S;exports.createContainerQuery=w;exports.getSpacingValue=u;exports.spacing=$;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export * from "./spacing-constants";
|
|
2
2
|
export * from "./center";
|
|
3
3
|
export * from "./column-drop";
|
|
4
|
+
export * from "./create-container-query";
|
|
4
5
|
export * from "./frame";
|
|
5
6
|
export * from "./grid";
|
|
6
7
|
export * from "./inline-cluster";
|
|
7
8
|
export * from "./inline";
|
|
8
9
|
export * from "./padbox";
|
|
9
10
|
export * from "./reel";
|
|
11
|
+
export * from "./split";
|
|
10
12
|
export * from "./stack";
|
|
13
|
+
export * from "./cover";
|
|
14
|
+
export * from "./columns";
|
package/lib/index.m.js
CHANGED
|
@@ -17,7 +17,21 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
20
32
|
import { styled, css } from "solid-styled-components";
|
|
33
|
+
import { init, registerCallback } from "@bedrock-layout/register-resize-callback";
|
|
34
|
+
import { createSignal, onMount, createEffect, onCleanup, Switch, Match } from "solid-js";
|
|
21
35
|
function checkIsCSSLength(str) {
|
|
22
36
|
if (typeof str !== "string")
|
|
23
37
|
return false;
|
|
@@ -129,6 +143,31 @@ const ColumnDrop = styled("div")`
|
|
|
129
143
|
flex-wrap: wrap;
|
|
130
144
|
gap: var(--gutter, 0px);
|
|
131
145
|
`;
|
|
146
|
+
function createContainerQuery(width = 1, maxWidth) {
|
|
147
|
+
if (maxWidth !== void 0 && maxWidth <= width) {
|
|
148
|
+
throw new Error(`The second width value, ${maxWidth}, is not larger than ${width}. Please provide a value greater than first width value`);
|
|
149
|
+
}
|
|
150
|
+
const [matches, setMatch] = createSignal(false);
|
|
151
|
+
const [node, nodeRef] = createSignal();
|
|
152
|
+
onMount(() => {
|
|
153
|
+
init();
|
|
154
|
+
});
|
|
155
|
+
createEffect(() => {
|
|
156
|
+
const ref = node();
|
|
157
|
+
if (ref === void 0 || ref === null)
|
|
158
|
+
return;
|
|
159
|
+
const cleanup = registerCallback(ref, (entry) => {
|
|
160
|
+
var _a, _b;
|
|
161
|
+
const nodeWidth = (_b = (_a = entry.borderBoxSize) == null ? void 0 : _a.inlineSize) != null ? _b : entry.contentRect.width;
|
|
162
|
+
if (nodeWidth > 0) {
|
|
163
|
+
const newMatch = maxWidth === void 0 ? nodeWidth <= width : nodeWidth >= width && nodeWidth <= maxWidth;
|
|
164
|
+
setMatch(newMatch);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
onCleanup(cleanup);
|
|
168
|
+
});
|
|
169
|
+
return [matches, nodeRef];
|
|
170
|
+
}
|
|
132
171
|
function checkIsRatio(ratio) {
|
|
133
172
|
const isCorrectArray = Array.isArray(ratio) && ratio.length === 2 && ratio.every(Number.isFinite);
|
|
134
173
|
return isCorrectArray || typeof ratio === "string" && /^\d{1,1000} {0,1}\/ {0,1}\d{1,1000}$/.test(ratio);
|
|
@@ -320,7 +359,7 @@ function paddingToString(theme, padding) {
|
|
|
320
359
|
console.error("Invalid padding Type");
|
|
321
360
|
}
|
|
322
361
|
const getPadding = paddingOrDefault(theme);
|
|
323
|
-
return typeof padding === "object" && !Array.isArray(padding) ? Object.entries(padding).reduce((acc, [key, val]) => validKeys.has(key) ? acc + keyToProperty(key, getPadding(val)) : acc, "") : padding ? `padding: ${Array.from(Array.isArray(padding) ? padding : [padding]).map((pad) => getPadding(pad)).join(" ")}
|
|
362
|
+
return typeof padding === "object" && !Array.isArray(padding) ? Object.entries(padding).reduce((acc, [key, val]) => validKeys.has(key) ? acc + keyToProperty(key, getPadding(val)) : acc, "") : padding !== void 0 ? `padding: ${Array.from(Array.isArray(padding) ? padding : [padding]).map((pad) => getPadding(pad)).join(" ")};` : "";
|
|
324
363
|
}
|
|
325
364
|
const PadBox = styled.div`
|
|
326
365
|
box-sizing: border-box;
|
|
@@ -385,4 +424,260 @@ const Stack = styled("div")`
|
|
|
385
424
|
grid-column: span 1 / auto;
|
|
386
425
|
}
|
|
387
426
|
`;
|
|
388
|
-
|
|
427
|
+
const PIXELS_PER_INCH = 96;
|
|
428
|
+
function parseUnit(str) {
|
|
429
|
+
var _a;
|
|
430
|
+
str = String(str);
|
|
431
|
+
const num = parseFloat(str);
|
|
432
|
+
const [, unit] = (_a = str.match(/[\d.\-+]*\s*(.*)/)) != null ? _a : ["", ""];
|
|
433
|
+
return [num, unit];
|
|
434
|
+
}
|
|
435
|
+
function toPX(str, element) {
|
|
436
|
+
if (!str)
|
|
437
|
+
return null;
|
|
438
|
+
const elementOrBody = element != null ? element : document.body;
|
|
439
|
+
const safeStr = (str != null ? str : "px").trim().toLowerCase();
|
|
440
|
+
switch (safeStr) {
|
|
441
|
+
case "vmin":
|
|
442
|
+
case "vmax":
|
|
443
|
+
case "vh":
|
|
444
|
+
case "vw":
|
|
445
|
+
case "%":
|
|
446
|
+
return null;
|
|
447
|
+
case "ch":
|
|
448
|
+
case "ex":
|
|
449
|
+
return getSizeBrutal(safeStr, elementOrBody);
|
|
450
|
+
case "em":
|
|
451
|
+
return getPropertyInPX(elementOrBody, "font-size");
|
|
452
|
+
case "rem":
|
|
453
|
+
return getPropertyInPX(document.body, "font-size");
|
|
454
|
+
case "in":
|
|
455
|
+
return PIXELS_PER_INCH;
|
|
456
|
+
case "cm":
|
|
457
|
+
return PIXELS_PER_INCH / 2.54;
|
|
458
|
+
case "mm":
|
|
459
|
+
return PIXELS_PER_INCH / 25.4;
|
|
460
|
+
case "pt":
|
|
461
|
+
return PIXELS_PER_INCH / 72;
|
|
462
|
+
case "pc":
|
|
463
|
+
return PIXELS_PER_INCH / 6;
|
|
464
|
+
case "px":
|
|
465
|
+
return 1;
|
|
466
|
+
default: {
|
|
467
|
+
const [value, units] = parseUnit(safeStr);
|
|
468
|
+
if (isNaN(value))
|
|
469
|
+
return null;
|
|
470
|
+
if (!units)
|
|
471
|
+
return value;
|
|
472
|
+
const px = toPX(units, element);
|
|
473
|
+
return typeof px === "number" ? value * px : null;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function getPropertyInPX(element, prop) {
|
|
478
|
+
var _a;
|
|
479
|
+
const [value, units] = parseUnit(getComputedStyle(element).getPropertyValue(prop));
|
|
480
|
+
return value * ((_a = toPX(units, element)) != null ? _a : 1);
|
|
481
|
+
}
|
|
482
|
+
function getSizeBrutal(unit, element) {
|
|
483
|
+
const testDIV = document.createElement("div");
|
|
484
|
+
testDIV.style["height"] = "128" + unit;
|
|
485
|
+
element.appendChild(testDIV);
|
|
486
|
+
const size = getPropertyInPX(testDIV, "height") / 128;
|
|
487
|
+
element.removeChild(testDIV);
|
|
488
|
+
return size;
|
|
489
|
+
}
|
|
490
|
+
const fractions = {
|
|
491
|
+
"1/4": "1fr 3fr",
|
|
492
|
+
"1/3": "1fr 2fr",
|
|
493
|
+
"1/2": "1fr 1fr",
|
|
494
|
+
"2/3": "2fr 1fr",
|
|
495
|
+
"3/4": "3fr 1fr",
|
|
496
|
+
"auto-start": `auto 1fr`,
|
|
497
|
+
"auto-end": `1fr auto`
|
|
498
|
+
};
|
|
499
|
+
const SplitBase = styled.div`
|
|
500
|
+
box-sizing: border-box;
|
|
501
|
+
> * {
|
|
502
|
+
margin: 0;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
--gutter: ${(props) => {
|
|
506
|
+
var _a;
|
|
507
|
+
return props.gutter ? (_a = getSpacingValue(props.gutter, props.theme)) != null ? _a : "0px" : "0px";
|
|
508
|
+
}};
|
|
509
|
+
|
|
510
|
+
display: grid;
|
|
511
|
+
gap: var(--gutter, 0px);
|
|
512
|
+
grid-template-columns: ${({ fraction = "1/2" }) => {
|
|
513
|
+
var _a;
|
|
514
|
+
return (_a = fractions[fraction]) != null ? _a : fractions["1/2"];
|
|
515
|
+
}}};
|
|
516
|
+
`;
|
|
517
|
+
const Split = (props) => {
|
|
518
|
+
const maybePx = typeof props.switchAt === "string" ? toPX(props.switchAt) : props.switchAt;
|
|
519
|
+
const widthToSwitchAt = maybePx && maybePx > -1 ? maybePx : 0;
|
|
520
|
+
console.log(widthToSwitchAt);
|
|
521
|
+
const [shouldSwitch, nodeRef] = createContainerQuery(widthToSwitchAt);
|
|
522
|
+
const combineRef = (ref) => {
|
|
523
|
+
var _a;
|
|
524
|
+
nodeRef(ref);
|
|
525
|
+
(_a = props.ref) == null ? void 0 : _a.call(props, ref);
|
|
526
|
+
};
|
|
527
|
+
return /* @__PURE__ */ React.createElement(Switch, null, /* @__PURE__ */ React.createElement(Match, {
|
|
528
|
+
when: shouldSwitch() === false
|
|
529
|
+
}, /* @__PURE__ */ React.createElement(SplitBase, __spreadValues({
|
|
530
|
+
as: props.as,
|
|
531
|
+
ref: combineRef,
|
|
532
|
+
fraction: props.fraction
|
|
533
|
+
}, props))), /* @__PURE__ */ React.createElement(Match, {
|
|
534
|
+
when: shouldSwitch() === true
|
|
535
|
+
}, /* @__PURE__ */ React.createElement(Stack, __spreadValues({
|
|
536
|
+
as: props.as,
|
|
537
|
+
ref: combineRef
|
|
538
|
+
}, props))));
|
|
539
|
+
};
|
|
540
|
+
function getSafeMinHeight(minHeight) {
|
|
541
|
+
if (typeof minHeight === "number")
|
|
542
|
+
return `${minHeight}px`;
|
|
543
|
+
return minHeight && checkIsCSSLength(minHeight) ? minHeight : "100vh";
|
|
544
|
+
}
|
|
545
|
+
const CoverWrapper = styled.div`
|
|
546
|
+
@property --gutter {
|
|
547
|
+
syntax: "<length-percentage>";
|
|
548
|
+
inherits: false;
|
|
549
|
+
initial-value: 0;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
@property --minHeight {
|
|
553
|
+
syntax: "<length-percentage>";
|
|
554
|
+
inherits: false;
|
|
555
|
+
initial-value: 100vh;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
--gutter: ${(props) => {
|
|
559
|
+
var _a;
|
|
560
|
+
return props.gutter ? (_a = getSpacingValue(props.gutter, props.theme)) != null ? _a : "0px" : "0px";
|
|
561
|
+
}};
|
|
562
|
+
|
|
563
|
+
--minHeight: ${(props) => getSafeMinHeight(props.minHeight)};
|
|
564
|
+
|
|
565
|
+
> * {
|
|
566
|
+
margin: 0;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
display: flex;
|
|
570
|
+
flex-direction: column;
|
|
571
|
+
gap: var(--gutter, 0px);
|
|
572
|
+
|
|
573
|
+
min-block-size: var(--minHeight, 100vh);
|
|
574
|
+
|
|
575
|
+
> [data-bedrock-cover-centered] {
|
|
576
|
+
margin-block-start: auto;
|
|
577
|
+
margin-block-end: auto;
|
|
578
|
+
|
|
579
|
+
${({ stretchContent }) => stretchContent === true ? `
|
|
580
|
+
flex: 1;
|
|
581
|
+
display: flex;
|
|
582
|
+
flex-direction: column;
|
|
583
|
+
> * {
|
|
584
|
+
flex: 1;
|
|
585
|
+
}
|
|
586
|
+
` : ""};
|
|
587
|
+
}
|
|
588
|
+
`;
|
|
589
|
+
const Cover = (props) => {
|
|
590
|
+
const _a = props, { top, bottom, children } = _a, rest = __objRest(_a, ["top", "bottom", "children"]);
|
|
591
|
+
return /* @__PURE__ */ React.createElement(CoverWrapper, __spreadValues({}, rest), props.top, /* @__PURE__ */ React.createElement("div", {
|
|
592
|
+
"data-bedrock-cover-centered": true
|
|
593
|
+
}, props.children), props.bottom);
|
|
594
|
+
};
|
|
595
|
+
const ColumnsBase = styled.div`
|
|
596
|
+
@property --gutter {
|
|
597
|
+
syntax: "<length-percentage>";
|
|
598
|
+
inherits: false;
|
|
599
|
+
initial-value: 0;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
@property --columns {
|
|
603
|
+
syntax: "<number>";
|
|
604
|
+
inherits: true;
|
|
605
|
+
initial-value: 1;
|
|
606
|
+
}
|
|
607
|
+
--gutter: ${(props) => {
|
|
608
|
+
var _a;
|
|
609
|
+
return props.gutter ? (_a = getSpacingValue(props.gutter, props.theme)) != null ? _a : "0px" : "0px";
|
|
610
|
+
}};
|
|
611
|
+
|
|
612
|
+
--columns: ${(props) => props.columns && props.columns > 0 ? props.columns : 1};
|
|
613
|
+
|
|
614
|
+
box-sizing: border-box;
|
|
615
|
+
> * {
|
|
616
|
+
margin: 0;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
display: grid;
|
|
620
|
+
grid-template-columns: repeat(var(--columns, 1), 1fr);
|
|
621
|
+
gap: var(--gutter, 0px);
|
|
622
|
+
grid-auto-flow: row ${({ dense = false }) => dense === true ? "dense" : ""};
|
|
623
|
+
`;
|
|
624
|
+
const Columns = (props) => {
|
|
625
|
+
const maybePx = typeof props.switchAt === "string" ? toPX(props.switchAt) : props.switchAt;
|
|
626
|
+
console.log(maybePx);
|
|
627
|
+
const widthToSwitchAt = maybePx && maybePx > -1 ? maybePx : 0;
|
|
628
|
+
console.log(widthToSwitchAt);
|
|
629
|
+
const [shouldSwitch, nodeRef] = createContainerQuery(widthToSwitchAt);
|
|
630
|
+
const combineRef = (ref) => {
|
|
631
|
+
var _a;
|
|
632
|
+
nodeRef(ref);
|
|
633
|
+
(_a = props.ref) == null ? void 0 : _a.call(props, ref);
|
|
634
|
+
};
|
|
635
|
+
return /* @__PURE__ */ React.createElement(Switch, null, /* @__PURE__ */ React.createElement(Match, {
|
|
636
|
+
when: shouldSwitch() === false
|
|
637
|
+
}, /* @__PURE__ */ React.createElement(ColumnsBase, __spreadValues({
|
|
638
|
+
as: props.as,
|
|
639
|
+
ref: combineRef,
|
|
640
|
+
columns: props.columns
|
|
641
|
+
}, props))), /* @__PURE__ */ React.createElement(Match, {
|
|
642
|
+
when: shouldSwitch() === true
|
|
643
|
+
}, /* @__PURE__ */ React.createElement(Stack, __spreadValues({
|
|
644
|
+
as: props.as,
|
|
645
|
+
ref: combineRef
|
|
646
|
+
}, props))));
|
|
647
|
+
};
|
|
648
|
+
const safeSpan = (span) => {
|
|
649
|
+
return typeof span === "number" ? span : 1;
|
|
650
|
+
};
|
|
651
|
+
const Column = styled.div`
|
|
652
|
+
@property --span {
|
|
653
|
+
syntax: "<number>";
|
|
654
|
+
inherits: true;
|
|
655
|
+
initial-value: 1;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
--span: ${(props) => safeSpan(props.colSpan)};
|
|
659
|
+
|
|
660
|
+
grid-column: span min(var(--span, 1), var(--columns, 1));
|
|
661
|
+
|
|
662
|
+
${(props) => props.offsetStart || props.offsetEnd ? `
|
|
663
|
+
display: contents;
|
|
664
|
+
> * {
|
|
665
|
+
grid-column: span min(var(--span, 1), var(--columns, 1));
|
|
666
|
+
}
|
|
667
|
+
` : ""}
|
|
668
|
+
|
|
669
|
+
${(props) => props.offsetStart && props.offsetStart > 0 ? `
|
|
670
|
+
&::before {
|
|
671
|
+
content: "";
|
|
672
|
+
grid-column: span min(${props.offsetStart}, var(--columns, 1));
|
|
673
|
+
}
|
|
674
|
+
` : ""}
|
|
675
|
+
|
|
676
|
+
${(props) => props.offsetEnd && props.offsetEnd > 0 ? `
|
|
677
|
+
&::after {
|
|
678
|
+
content: "";
|
|
679
|
+
grid-column: span min(${props.offsetEnd}, var(--columns, 1));
|
|
680
|
+
}
|
|
681
|
+
` : ""}
|
|
682
|
+
`;
|
|
683
|
+
export { Center, Column, ColumnDrop, Columns, Cover, Frame, Grid, Inline, InlineCluster, PadBox, Reel, Split, Stack, checkIsCSSLength, createContainerQuery, getSpacingValue, spacing };
|
package/lib/index.umd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var fe=Object.defineProperty,ge=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var P=(n,r,o)=>r in n?fe(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,m=(n,r)=>{for(var o in r||(r={}))T.call(r,o)&&P(n,o,r[o]);if(v)for(var o of v(r))O.call(r,o)&&P(n,o,r[o]);return n},E=(n,r)=>ge(n,de(r));var B=(n,r)=>{var o={};for(var s in n)T.call(n,s)&&r.indexOf(s)<0&&(o[s]=n[s]);if(n!=null&&v)for(var s of v(n))r.indexOf(s)<0&&O.call(n,s)&&(o[s]=n[s]);return o};(function(n,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("solid-styled-components"),require("@bedrock-layout/register-resize-callback"),require("solid-js")):typeof define=="function"&&define.amd?define(["exports","solid-styled-components","@bedrock-layout/register-resize-callback","solid-js"],r):(n=typeof globalThis!="undefined"?globalThis:n||self,r(n.solid={},n.solidStyledComponents,n.registerResizeCallback,n.solidJs))})(this,function(n,r,o,s){"use strict";function $(e){return typeof e!="string"?!1:[/^[0-9]{0,10000}\.?[0-9]{1,10000}(vmin|vmax|vh|vw|%|ch|ex|em|rem|in|cm|mm|pt|pc|px)$/,/^var\(--\D{1,100}\)$/].some(t=>t.test(e))}const w={none:"0px",xxs:"0.0625rem",xs:"0.125rem",sm:"0.25rem",md:"0.5rem",mdLg:"0.75rem",lg:"1rem",lgXl:"1.5rem",xl:"2rem",xlXXl:"3rem",xxl:"4rem"};function L(e){return e.reduce((t,[i,c])=>E(m({},t),{[i]:c}),{})}const g=(e,t)=>{var a,f;const i=(f=(a=t==null?void 0:t.space)!=null?a:t==null?void 0:t.spacing)!=null?f:w,l=L(Object.entries(i).map(([h,d])=>[h,typeof d=="number"?`${d}px`:d]))[e];return $(l)?l:void 0};function V(e){return e===void 0?"100%":typeof e=="number"?`${e}px`:e}const D=r.styled.div`
|
|
2
2
|
@property --maxWidth {
|
|
3
3
|
syntax: "<length-percentage>";
|
|
4
4
|
inherits: false;
|
|
5
5
|
initial-value: 100%;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
--maxWidth: ${e=>
|
|
8
|
+
--maxWidth: ${e=>V(e.maxWidth)};
|
|
9
9
|
|
|
10
10
|
box-sizing: content-box;
|
|
11
11
|
|
|
@@ -17,16 +17,16 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
17
17
|
|
|
18
18
|
max-inline-size: var(--maxWidth, 100%);
|
|
19
19
|
|
|
20
|
-
${e=>e.centerChildren?
|
|
20
|
+
${e=>e.centerChildren?r.css`
|
|
21
21
|
display: flex;
|
|
22
22
|
flex-direction: column;
|
|
23
23
|
align-items: center;
|
|
24
24
|
`:""}
|
|
25
25
|
|
|
26
|
-
${e=>e.centerText?
|
|
26
|
+
${e=>e.centerText?r.css`
|
|
27
27
|
text-align: center;
|
|
28
28
|
`:""}
|
|
29
|
-
`;function
|
|
29
|
+
`;function W(e){return e===void 0?"100%":typeof e=="number"?`${e}px`:e}const X=r.styled("div")`
|
|
30
30
|
@property --basis {
|
|
31
31
|
syntax: "<length-percentage>";
|
|
32
32
|
inherits: true;
|
|
@@ -39,8 +39,8 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
39
39
|
initial-value: 0px;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
--basis: ${e=>
|
|
43
|
-
--gutter: ${e=>{var t;return e.gutter&&(t=
|
|
42
|
+
--basis: ${e=>W(e.basis)};
|
|
43
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
44
44
|
|
|
45
45
|
box-sizing: border-box;
|
|
46
46
|
> * {
|
|
@@ -53,14 +53,14 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
53
53
|
display: flex;
|
|
54
54
|
flex-wrap: wrap;
|
|
55
55
|
gap: var(--gutter, 0px);
|
|
56
|
-
`;function I(e){return Array.isArray(e)&&e.length===2&&e.every(Number.isFinite)||typeof e=="string"&&/^\d{1,1000} {0,1}\/ {0,1}\d{1,1000}$/.test(e)}function
|
|
56
|
+
`;function S(e=1,t){if(t!==void 0&&t<=e)throw new Error(`The second width value, ${t}, is not larger than ${e}. Please provide a value greater than first width value`);const[i,c]=s.createSignal(!1),[l,u]=s.createSignal();return s.onMount(()=>{o.init()}),s.createEffect(()=>{const a=l();if(a==null)return;const f=o.registerCallback(a,h=>{var I,M;const d=(M=(I=h.borderBoxSize)==null?void 0:I.inlineSize)!=null?M:h.contentRect.width;if(d>0){const ue=t===void 0?d<=e:d>=e&&d<=t;c(ue)}});s.onCleanup(f)}),[i,u]}function F(e){return Array.isArray(e)&&e.length===2&&e.every(Number.isFinite)||typeof e=="string"&&/^\d{1,1000} {0,1}\/ {0,1}\d{1,1000}$/.test(e)}function N(e){return Array.isArray(e)?e.join("/"):e}function _(e){return F(e)?N(e):void 0}const q=r.styled.div`
|
|
57
57
|
box-sizing: border-box;
|
|
58
58
|
display: block;
|
|
59
59
|
inline-size: 100%;
|
|
60
60
|
position: relative;
|
|
61
61
|
overflow: hidden;
|
|
62
62
|
|
|
63
|
-
${e=>{const t=
|
|
63
|
+
${e=>{const t=_(e.ratio);return t?r.css`
|
|
64
64
|
aspect-ratio: ${t};
|
|
65
65
|
`:""}};
|
|
66
66
|
|
|
@@ -88,7 +88,7 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
88
88
|
object-fit: cover;
|
|
89
89
|
object-position: ${e=>typeof e.position=="string"?e.position:"50%"};
|
|
90
90
|
}
|
|
91
|
-
`,
|
|
91
|
+
`,G=r.styled("div")`
|
|
92
92
|
@property --gutter {
|
|
93
93
|
syntax: "<length-percentage>";
|
|
94
94
|
inherits: false;
|
|
@@ -101,7 +101,7 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
101
101
|
initial-value: 639px;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
--gutter: ${e=>{var t;return e.gutter&&(t=
|
|
104
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
105
105
|
--minItemWidth: ${e=>{var t;return typeof e.minItemWidth=="string"?e.minItemWidth:`${(t=e.minItemWidth)!=null?t:0}px`}};
|
|
106
106
|
|
|
107
107
|
box-sizing: border-box;
|
|
@@ -116,8 +116,8 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
116
116
|
auto-fit,
|
|
117
117
|
minmax(min(var(--minItemWidth, 639px), 100%), 1fr)
|
|
118
118
|
);
|
|
119
|
-
`,
|
|
120
|
-
--gutter: ${e=>{var t;return e.gutter&&(t=
|
|
119
|
+
`,x={start:"flex-start",end:"flex-end",center:"center"},p=E(m({},x),{stretch:"stretch"}),R=r.styled.div`
|
|
120
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
121
121
|
|
|
122
122
|
box-sizing: border-box;
|
|
123
123
|
> * {
|
|
@@ -128,10 +128,10 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
128
128
|
flex-wrap: wrap;
|
|
129
129
|
gap: var(--gutter, 0px);
|
|
130
130
|
|
|
131
|
-
justify-content: ${e=>typeof e.justify!="undefined"&&
|
|
131
|
+
justify-content: ${e=>typeof e.justify!="undefined"&&x[e.justify]?x[e.justify]:x.start};
|
|
132
132
|
|
|
133
|
-
align-items: ${e=>typeof e.align!="undefined"&&
|
|
134
|
-
`;function
|
|
133
|
+
align-items: ${e=>typeof e.align!="undefined"&&p[e.align]?p[e.align]:p.start};
|
|
134
|
+
`;function H(e){return typeof e=="number"&&e>-1?!0:typeof e=="string"&&typeof CSS!==void 0?CSS.supports(`height: ${e}`):!1}const Q=r.styled(R)`
|
|
135
135
|
@property --switchAt {
|
|
136
136
|
syntax: "<length-percentage>";
|
|
137
137
|
inherits: true;
|
|
@@ -140,7 +140,7 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
140
140
|
flex-wrap: nowrap;
|
|
141
141
|
${e=>e.stretch==="all"?"> * { flex: 1 }":e.stretch==="start"?"> :first-child { flex: 1 }":e.stretch==="end"?"> :last-child { flex: 1 }":typeof e.stretch=="number"?`> :nth-child(${e.stretch+1}) { flex: 1 }`:""}
|
|
142
142
|
|
|
143
|
-
${e=>
|
|
143
|
+
${e=>H(e.switchAt)?`
|
|
144
144
|
--switchAt: ${typeof e.switchAt=="string"?e.switchAt:`${e.switchAt}px`};
|
|
145
145
|
flex-wrap: wrap;
|
|
146
146
|
> * {
|
|
@@ -150,17 +150,17 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
`:""}
|
|
153
|
-
`,
|
|
153
|
+
`,z=new Set(["left","right","top","bottom","inlineStart","inlineEnd","blockStart","blockEnd"]),U=(e,t)=>({left:`padding-inline-start:${t};`,right:`padding-inline-end:${t};`,top:`padding-block-start:${t};`,bottom:`padding-block-end:${t};`,inlineStart:`padding-inline-start:${t};`,inlineEnd:`padding-inline-end:${t};`,blockStart:`padding-block-start:${t};`,blockEnd:`padding-block-end:${t};`})[e];function K(e){return t=>{const i=g(t,e);return i!=null?i:"0px"}}function Y(e,t){var u;if(Array.isArray(t)&&t.length>4)throw new Error("padding arrays can only be 4 or less in length");const i=new Set(Object.keys((u=e==null?void 0:e.spacing)!=null?u:w));(()=>typeof t=="string"?!0:Array.isArray(t)?t.every(a=>i.has(a)):t&&Object.keys(t).every(a=>z.has(a))&&Object.values(t).every(a=>i.has(a)))()||console.error("Invalid padding Type");const l=K(e);return typeof t=="object"&&!Array.isArray(t)?Object.entries(t).reduce((a,[f,h])=>z.has(f)?a+U(f,l(h)):a,""):t!==void 0?`padding: ${Array.from(Array.isArray(t)?t:[t]).map(a=>l(a)).join(" ")};`:""}const Z=r.styled.div`
|
|
154
154
|
box-sizing: border-box;
|
|
155
|
-
${e=>
|
|
156
|
-
`,
|
|
155
|
+
${e=>Y(e.theme,e.padding)}
|
|
156
|
+
`,J=r.styled.div`
|
|
157
157
|
box-sizing: border-box;
|
|
158
158
|
> * {
|
|
159
159
|
margin: 0;
|
|
160
160
|
scroll-snap-align: start;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
--gutter: ${e=>{var t;return e.gutter&&(t=
|
|
163
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
164
164
|
|
|
165
165
|
display: flex;
|
|
166
166
|
gap: var(--gutter, 0px);
|
|
@@ -168,14 +168,14 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
168
168
|
overflow-x: scroll;
|
|
169
169
|
|
|
170
170
|
scroll-snap-type: ${({snapType:e="none"})=>{switch(e){case"none":return"none";case"proximity":return"x proximity";case"mandatory":return"x mandatory";default:return"none"}}};
|
|
171
|
-
`,
|
|
171
|
+
`,k=r.styled("div")`
|
|
172
172
|
@property --gutter {
|
|
173
173
|
syntax: "<length-percentage>";
|
|
174
174
|
inherits: false;
|
|
175
175
|
initial-value: 0;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
--gutter: ${e=>{var t;return e.gutter&&(t=
|
|
178
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
179
179
|
box-sizing: border-box;
|
|
180
180
|
> * {
|
|
181
181
|
margin: 0;
|
|
@@ -189,4 +189,111 @@ var F=Object.defineProperty,X=Object.defineProperties;var G=Object.getOwnPropert
|
|
|
189
189
|
& > [data-bedrock-column] {
|
|
190
190
|
grid-column: span 1 / auto;
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
`,y=96;function j(e){var c;e=String(e);const t=parseFloat(e),[,i]=(c=e.match(/[\d.\-+]*\s*(.*)/))!=null?c:["",""];return[t,i]}function b(e,t){if(!e)return null;const i=t!=null?t:document.body,c=(e!=null?e:"px").trim().toLowerCase();switch(c){case"vmin":case"vmax":case"vh":case"vw":case"%":return null;case"ch":case"ex":return ee(c,i);case"em":return A(i,"font-size");case"rem":return A(document.body,"font-size");case"in":return y;case"cm":return y/2.54;case"mm":return y/25.4;case"pt":return y/72;case"pc":return y/6;case"px":return 1;default:{const[l,u]=j(c);if(isNaN(l))return null;if(!u)return l;const a=b(u,t);return typeof a=="number"?l*a:null}}}function A(e,t){var l;const[i,c]=j(getComputedStyle(e).getPropertyValue(t));return i*((l=b(c,e))!=null?l:1)}function ee(e,t){const i=document.createElement("div");i.style.height="128"+e,t.appendChild(i);const c=A(i,"height")/128;return t.removeChild(i),c}const C={"1/4":"1fr 3fr","1/3":"1fr 2fr","1/2":"1fr 1fr","2/3":"2fr 1fr","3/4":"3fr 1fr","auto-start":"auto 1fr","auto-end":"1fr auto"},te=r.styled.div`
|
|
193
|
+
box-sizing: border-box;
|
|
194
|
+
> * {
|
|
195
|
+
margin: 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
199
|
+
|
|
200
|
+
display: grid;
|
|
201
|
+
gap: var(--gutter, 0px);
|
|
202
|
+
grid-template-columns: ${({fraction:e="1/2"})=>{var t;return(t=C[e])!=null?t:C["1/2"]}}};
|
|
203
|
+
`,ne=e=>{const t=typeof e.switchAt=="string"?b(e.switchAt):e.switchAt,i=t&&t>-1?t:0;console.log(i);const[c,l]=S(i),u=a=>{var f;l(a),(f=e.ref)==null||f.call(e,a)};return React.createElement(s.Switch,null,React.createElement(s.Match,{when:c()===!1},React.createElement(te,m({as:e.as,ref:u,fraction:e.fraction},e))),React.createElement(s.Match,{when:c()===!0},React.createElement(k,m({as:e.as,ref:u},e))))};function re(e){return typeof e=="number"?`${e}px`:e&&$(e)?e:"100vh"}const ie=r.styled.div`
|
|
204
|
+
@property --gutter {
|
|
205
|
+
syntax: "<length-percentage>";
|
|
206
|
+
inherits: false;
|
|
207
|
+
initial-value: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@property --minHeight {
|
|
211
|
+
syntax: "<length-percentage>";
|
|
212
|
+
inherits: false;
|
|
213
|
+
initial-value: 100vh;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
217
|
+
|
|
218
|
+
--minHeight: ${e=>re(e.minHeight)};
|
|
219
|
+
|
|
220
|
+
> * {
|
|
221
|
+
margin: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
display: flex;
|
|
225
|
+
flex-direction: column;
|
|
226
|
+
gap: var(--gutter, 0px);
|
|
227
|
+
|
|
228
|
+
min-block-size: var(--minHeight, 100vh);
|
|
229
|
+
|
|
230
|
+
> [data-bedrock-cover-centered] {
|
|
231
|
+
margin-block-start: auto;
|
|
232
|
+
margin-block-end: auto;
|
|
233
|
+
|
|
234
|
+
${({stretchContent:e})=>e===!0?`
|
|
235
|
+
flex: 1;
|
|
236
|
+
display: flex;
|
|
237
|
+
flex-direction: column;
|
|
238
|
+
> * {
|
|
239
|
+
flex: 1;
|
|
240
|
+
}
|
|
241
|
+
`:""};
|
|
242
|
+
}
|
|
243
|
+
`,ae=e=>{const u=e,{top:t,bottom:i,children:c}=u,l=B(u,["top","bottom","children"]);return React.createElement(ie,m({},l),e.top,React.createElement("div",{"data-bedrock-cover-centered":!0},e.children),e.bottom)},ce=r.styled.div`
|
|
244
|
+
@property --gutter {
|
|
245
|
+
syntax: "<length-percentage>";
|
|
246
|
+
inherits: false;
|
|
247
|
+
initial-value: 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@property --columns {
|
|
251
|
+
syntax: "<number>";
|
|
252
|
+
inherits: true;
|
|
253
|
+
initial-value: 1;
|
|
254
|
+
}
|
|
255
|
+
--gutter: ${e=>{var t;return e.gutter&&(t=g(e.gutter,e.theme))!=null?t:"0px"}};
|
|
256
|
+
|
|
257
|
+
--columns: ${e=>e.columns&&e.columns>0?e.columns:1};
|
|
258
|
+
|
|
259
|
+
box-sizing: border-box;
|
|
260
|
+
> * {
|
|
261
|
+
margin: 0;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
display: grid;
|
|
265
|
+
grid-template-columns: repeat(var(--columns, 1), 1fr);
|
|
266
|
+
gap: var(--gutter, 0px);
|
|
267
|
+
grid-auto-flow: row ${({dense:e=!1})=>e===!0?"dense":""};
|
|
268
|
+
`,se=e=>{const t=typeof e.switchAt=="string"?b(e.switchAt):e.switchAt;console.log(t);const i=t&&t>-1?t:0;console.log(i);const[c,l]=S(i),u=a=>{var f;l(a),(f=e.ref)==null||f.call(e,a)};return React.createElement(s.Switch,null,React.createElement(s.Match,{when:c()===!1},React.createElement(ce,m({as:e.as,ref:u,columns:e.columns},e))),React.createElement(s.Match,{when:c()===!0},React.createElement(k,m({as:e.as,ref:u},e))))},le=e=>typeof e=="number"?e:1,oe=r.styled.div`
|
|
269
|
+
@property --span {
|
|
270
|
+
syntax: "<number>";
|
|
271
|
+
inherits: true;
|
|
272
|
+
initial-value: 1;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
--span: ${e=>le(e.colSpan)};
|
|
276
|
+
|
|
277
|
+
grid-column: span min(var(--span, 1), var(--columns, 1));
|
|
278
|
+
|
|
279
|
+
${e=>e.offsetStart||e.offsetEnd?`
|
|
280
|
+
display: contents;
|
|
281
|
+
> * {
|
|
282
|
+
grid-column: span min(var(--span, 1), var(--columns, 1));
|
|
283
|
+
}
|
|
284
|
+
`:""}
|
|
285
|
+
|
|
286
|
+
${e=>e.offsetStart&&e.offsetStart>0?`
|
|
287
|
+
&::before {
|
|
288
|
+
content: "";
|
|
289
|
+
grid-column: span min(${e.offsetStart}, var(--columns, 1));
|
|
290
|
+
}
|
|
291
|
+
`:""}
|
|
292
|
+
|
|
293
|
+
${e=>e.offsetEnd&&e.offsetEnd>0?`
|
|
294
|
+
&::after {
|
|
295
|
+
content: "";
|
|
296
|
+
grid-column: span min(${e.offsetEnd}, var(--columns, 1));
|
|
297
|
+
}
|
|
298
|
+
`:""}
|
|
299
|
+
`;n.Center=D,n.Column=oe,n.ColumnDrop=X,n.Columns=se,n.Cover=ae,n.Frame=q,n.Grid=G,n.Inline=Q,n.InlineCluster=R,n.PadBox=Z,n.Reel=J,n.Split=ne,n.Stack=k,n.checkIsCSSLength=$,n.createContainerQuery=S,n.getSpacingValue=g,n.spacing=w,Object.defineProperty(n,"__esModule",{value:!0}),n[Symbol.toStringTag]="Module"});
|
package/lib/split.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, JSX } from "solid-js";
|
|
2
|
+
import { CSSLength, SpacingOptions } from "./spacing-constants";
|
|
3
|
+
import { StackProps } from "./stack";
|
|
4
|
+
declare type FractionTypes = "auto-start" | "auto-end" | "1/4" | "1/3" | "1/2" | "2/3" | "3/4";
|
|
5
|
+
interface SplitBaseProps {
|
|
6
|
+
gutter?: SpacingOptions;
|
|
7
|
+
fraction?: FractionTypes;
|
|
8
|
+
}
|
|
9
|
+
export interface SplitProps extends StackProps, SplitBaseProps {
|
|
10
|
+
switchAt?: number | CSSLength;
|
|
11
|
+
as?: Component | keyof JSX.IntrinsicElements;
|
|
12
|
+
ref?: (ref: HTMLElement) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const Split: Component<SplitProps>;
|
|
15
|
+
export {};
|
package/lib/toPx.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrock-layout/solid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "solid.js port of bedrock-layout primitives",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"solid-js": "^1.3.7",
|
|
47
47
|
"solid-styled-components": "^0.27.4"
|
|
48
48
|
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@bedrock-layout/register-resize-callback": "^1.1.0"
|
|
51
|
+
},
|
|
49
52
|
"scripts": {
|
|
50
53
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
51
54
|
"lint": "eslint --ignore-path .gitignore .",
|
|
@@ -59,5 +62,5 @@
|
|
|
59
62
|
"bugs": {
|
|
60
63
|
"url": "https://github.com/Bedrock-Layouts/Solid-Bedrock/issues"
|
|
61
64
|
},
|
|
62
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "af80ca54feda5c1b9f0173c867802bc3a87ee259"
|
|
63
66
|
}
|