@nuralyui/grid 0.0.4 → 0.0.5
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/bundle.js +193 -3
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,12 +1,202 @@
|
|
|
1
|
-
import{css as t,LitElement as a,html as s}from"lit";import{property as e,state as o,customElement as r}from"lit/decorators.js";import{NuralyUIBaseMixin as i}from"@nuralyui/common/mixins";const d=t
|
|
1
|
+
import{css as t,LitElement as a,html as s}from"lit";import{property as e,state as o,customElement as r}from"lit/decorators.js";import{NuralyUIBaseMixin as i}from"@nuralyui/common/mixins";const d=t`
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.nr-row {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-flow: row wrap;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
|
|
12
|
+
/* Theme-aware */
|
|
13
|
+
color: var(--nuraly-color-text);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* Wrap control */
|
|
17
|
+
.nr-row[data-wrap="false"] {
|
|
18
|
+
flex-wrap: nowrap;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Horizontal alignment (justify-content) */
|
|
22
|
+
.nr-row[data-justify="start"] {
|
|
23
|
+
justify-content: flex-start;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.nr-row[data-justify="end"] {
|
|
27
|
+
justify-content: flex-end;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.nr-row[data-justify="center"] {
|
|
31
|
+
justify-content: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.nr-row[data-justify="space-around"] {
|
|
35
|
+
justify-content: space-around;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nr-row[data-justify="space-between"] {
|
|
39
|
+
justify-content: space-between;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.nr-row[data-justify="space-evenly"] {
|
|
43
|
+
justify-content: space-evenly;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Vertical alignment (align-items) */
|
|
47
|
+
.nr-row[data-align="top"] {
|
|
48
|
+
align-items: flex-start;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.nr-row[data-align="middle"] {
|
|
52
|
+
align-items: center;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.nr-row[data-align="bottom"] {
|
|
56
|
+
align-items: flex-end;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nr-row[data-align="stretch"] {
|
|
60
|
+
align-items: stretch;
|
|
61
|
+
}
|
|
62
|
+
`,h="",n={xs:0,sm:576,md:768,lg:992,xl:1200,xxl:1600};
|
|
2
63
|
/**
|
|
3
64
|
* @license
|
|
4
65
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
5
66
|
* SPDX-License-Identifier: MIT
|
|
6
67
|
*/
|
|
7
|
-
var l=function(t,a,s,e){for(var o,r=arguments.length,i=r<3?a:null===e?e=Object.getOwnPropertyDescriptor(a,s):e,d=t.length-1;d>=0;d--)(o=t[d])&&(i=(r<3?o(i):r>3?o(a,s,i):o(a,s))||i);return r>3&&i&&Object.defineProperty(a,s,i),i};let f=class extends(i(a)){constructor(){super(...arguments),this.align="",this.justify="",this.gutter=0,this.wrap=!0,this.currentBreakpoint="xs"}connectedCallback(){super.connectedCallback(),this.setupResponsiveGutter()}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this.resizeObserver)||void 0===t||t.disconnect()}setupResponsiveGutter(){"object"!=typeof this.gutter||Array.isArray(this.gutter)||(this.updateBreakpoint(),this.resizeObserver=new ResizeObserver((()=>{this.updateBreakpoint()})),this.resizeObserver.observe(document.documentElement))}updateBreakpoint(){const t=window.innerWidth;this.currentBreakpoint=t>=n.xxl?"xxl":t>=n.xl?"xl":t>=n.lg?"lg":t>=n.md?"md":t>=n.sm?"sm":"xs"}getGutterValues(){if("number"==typeof this.gutter)return[this.gutter,this.gutter];if(Array.isArray(this.gutter))return this.gutter;const t=[this.currentBreakpoint,"xl","lg","md","sm","xs"];for(const a of t){const t=this.gutter[a];if(void 0!==t)return"number"==typeof t?[t,t]:t}return[0,0]}getRowStyle(){const[t,a]=this.getGutterValues(),s={};return t>0&&(s["margin-left"]=`-${t/2}px`,s["margin-right"]=`-${t/2}px`),a>0&&(s["row-gap"]=`${a}px`),s}getGutterContext(){const[t]=this.getGutterValues();return t}render(){const t=this.getRowStyle(),a=this.getGutterContext();return s
|
|
68
|
+
var l=function(t,a,s,e){for(var o,r=arguments.length,i=r<3?a:null===e?e=Object.getOwnPropertyDescriptor(a,s):e,d=t.length-1;d>=0;d--)(o=t[d])&&(i=(r<3?o(i):r>3?o(a,s,i):o(a,s))||i);return r>3&&i&&Object.defineProperty(a,s,i),i};let f=class extends(i(a)){constructor(){super(...arguments),this.align="",this.justify="",this.gutter=0,this.wrap=!0,this.currentBreakpoint="xs"}connectedCallback(){super.connectedCallback(),this.setupResponsiveGutter()}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this.resizeObserver)||void 0===t||t.disconnect()}setupResponsiveGutter(){"object"!=typeof this.gutter||Array.isArray(this.gutter)||(this.updateBreakpoint(),this.resizeObserver=new ResizeObserver((()=>{this.updateBreakpoint()})),this.resizeObserver.observe(document.documentElement))}updateBreakpoint(){const t=window.innerWidth;this.currentBreakpoint=t>=n.xxl?"xxl":t>=n.xl?"xl":t>=n.lg?"lg":t>=n.md?"md":t>=n.sm?"sm":"xs"}getGutterValues(){if("number"==typeof this.gutter)return[this.gutter,this.gutter];if(Array.isArray(this.gutter))return this.gutter;const t=[this.currentBreakpoint,"xl","lg","md","sm","xs"];for(const a of t){const t=this.gutter[a];if(void 0!==t)return"number"==typeof t?[t,t]:t}return[0,0]}getRowStyle(){const[t,a]=this.getGutterValues(),s={};return t>0&&(s["margin-left"]=`-${t/2}px`,s["margin-right"]=`-${t/2}px`),a>0&&(s["row-gap"]=`${a}px`),s}getGutterContext(){const[t]=this.getGutterValues();return t}render(){const t=this.getRowStyle(),a=this.getGutterContext();return s`
|
|
69
|
+
<div
|
|
70
|
+
class="nr-row"
|
|
71
|
+
data-align="${this.align}"
|
|
72
|
+
data-justify="${this.justify}"
|
|
73
|
+
data-wrap="${this.wrap}"
|
|
74
|
+
data-theme="${this.currentTheme}"
|
|
75
|
+
style="${Object.entries(t).map((([t,a])=>`${t}: ${a}`)).join("; ")}"
|
|
76
|
+
data-gutter="${a}"
|
|
77
|
+
>
|
|
78
|
+
<slot></slot>
|
|
79
|
+
</div>
|
|
80
|
+
`}};f.styles=d,l([e({type:String})],f.prototype,"align",void 0),l([e({type:String})],f.prototype,"justify",void 0),l([e({type:Object})],f.prototype,"gutter",void 0),l([e({type:Boolean})],f.prototype,"wrap",void 0),l([o()],f.prototype,"currentBreakpoint",void 0),f=l([r("nr-row")],f);const p=t`
|
|
81
|
+
:host {
|
|
82
|
+
display: block;
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.nr-col {
|
|
88
|
+
position: relative;
|
|
89
|
+
box-sizing: border-box;
|
|
90
|
+
width: 100%;
|
|
91
|
+
height: 100%;
|
|
92
|
+
|
|
93
|
+
/* Theme-aware */
|
|
94
|
+
color: var(--nuraly-color-text);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* Column spans (1-24) - Apply flex to :host */
|
|
98
|
+
:host([data-span="1"]) { flex: 0 0 4.16666667%; max-width: 4.16666667%; }
|
|
99
|
+
:host([data-span="2"]) { flex: 0 0 8.33333333%; max-width: 8.33333333%; }
|
|
100
|
+
:host([data-span="3"]) { flex: 0 0 12.5%; max-width: 12.5%; }
|
|
101
|
+
:host([data-span="4"]) { flex: 0 0 16.66666667%; max-width: 16.66666667%; }
|
|
102
|
+
:host([data-span="5"]) { flex: 0 0 20.83333333%; max-width: 20.83333333%; }
|
|
103
|
+
:host([data-span="6"]) { flex: 0 0 25%; max-width: 25%; }
|
|
104
|
+
:host([data-span="7"]) { flex: 0 0 29.16666667%; max-width: 29.16666667%; }
|
|
105
|
+
:host([data-span="8"]) { flex: 0 0 33.33333333%; max-width: 33.33333333%; }
|
|
106
|
+
:host([data-span="9"]) { flex: 0 0 37.5%; max-width: 37.5%; }
|
|
107
|
+
:host([data-span="10"]) { flex: 0 0 41.66666667%; max-width: 41.66666667%; }
|
|
108
|
+
:host([data-span="11"]) { flex: 0 0 45.83333333%; max-width: 45.83333333%; }
|
|
109
|
+
:host([data-span="12"]) { flex: 0 0 50%; max-width: 50%; }
|
|
110
|
+
:host([data-span="13"]) { flex: 0 0 54.16666667%; max-width: 54.16666667%; }
|
|
111
|
+
:host([data-span="14"]) { flex: 0 0 58.33333333%; max-width: 58.33333333%; }
|
|
112
|
+
:host([data-span="15"]) { flex: 0 0 62.5%; max-width: 62.5%; }
|
|
113
|
+
:host([data-span="16"]) { flex: 0 0 66.66666667%; max-width: 66.66666667%; }
|
|
114
|
+
:host([data-span="17"]) { flex: 0 0 70.83333333%; max-width: 70.83333333%; }
|
|
115
|
+
:host([data-span="18"]) { flex: 0 0 75%; max-width: 75%; }
|
|
116
|
+
:host([data-span="19"]) { flex: 0 0 79.16666667%; max-width: 79.16666667%; }
|
|
117
|
+
:host([data-span="20"]) { flex: 0 0 83.33333333%; max-width: 83.33333333%; }
|
|
118
|
+
:host([data-span="21"]) { flex: 0 0 87.5%; max-width: 87.5%; }
|
|
119
|
+
:host([data-span="22"]) { flex: 0 0 91.66666667%; max-width: 91.66666667%; }
|
|
120
|
+
:host([data-span="23"]) { flex: 0 0 95.83333333%; max-width: 95.83333333%; }
|
|
121
|
+
:host([data-span="24"]) { flex: 0 0 100%; max-width: 100%; }
|
|
122
|
+
|
|
123
|
+
/* Column offsets (0-24) - Apply to :host */
|
|
124
|
+
:host([data-offset="0"]) { margin-left: 0; }
|
|
125
|
+
:host([data-offset="1"]) { margin-left: 4.16666667%; }
|
|
126
|
+
:host([data-offset="2"]) { margin-left: 8.33333333%; }
|
|
127
|
+
:host([data-offset="3"]) { margin-left: 12.5%; }
|
|
128
|
+
:host([data-offset="4"]) { margin-left: 16.66666667%; }
|
|
129
|
+
:host([data-offset="5"]) { margin-left: 20.83333333%; }
|
|
130
|
+
:host([data-offset="6"]) { margin-left: 25%; }
|
|
131
|
+
:host([data-offset="7"]) { margin-left: 29.16666667%; }
|
|
132
|
+
:host([data-offset="8"]) { margin-left: 33.33333333%; }
|
|
133
|
+
:host([data-offset="9"]) { margin-left: 37.5%; }
|
|
134
|
+
:host([data-offset="10"]) { margin-left: 41.66666667%; }
|
|
135
|
+
:host([data-offset="11"]) { margin-left: 45.83333333%; }
|
|
136
|
+
:host([data-offset="12"]) { margin-left: 50%; }
|
|
137
|
+
:host([data-offset="13"]) { margin-left: 54.16666667%; }
|
|
138
|
+
:host([data-offset="14"]) { margin-left: 58.33333333%; }
|
|
139
|
+
:host([data-offset="15"]) { margin-left: 62.5%; }
|
|
140
|
+
:host([data-offset="16"]) { margin-left: 66.66666667%; }
|
|
141
|
+
:host([data-offset="17"]) { margin-left: 70.83333333%; }
|
|
142
|
+
:host([data-offset="18"]) { margin-left: 75%; }
|
|
143
|
+
:host([data-offset="19"]) { margin-left: 79.16666667%; }
|
|
144
|
+
:host([data-offset="20"]) { margin-left: 83.33333333%; }
|
|
145
|
+
:host([data-offset="21"]) { margin-left: 87.5%; }
|
|
146
|
+
:host([data-offset="22"]) { margin-left: 91.66666667%; }
|
|
147
|
+
:host([data-offset="23"]) { margin-left: 95.83333333%; }
|
|
148
|
+
|
|
149
|
+
/* Order - Apply to :host */
|
|
150
|
+
:host([data-order="1"]) { order: 1; }
|
|
151
|
+
:host([data-order="2"]) { order: 2; }
|
|
152
|
+
:host([data-order="3"]) { order: 3; }
|
|
153
|
+
:host([data-order="4"]) { order: 4; }
|
|
154
|
+
:host([data-order="5"]) { order: 5; }
|
|
155
|
+
:host([data-order="6"]) { order: 6; }
|
|
156
|
+
:host([data-order="7"]) { order: 7; }
|
|
157
|
+
:host([data-order="8"]) { order: 8; }
|
|
158
|
+
:host([data-order="9"]) { order: 9; }
|
|
159
|
+
:host([data-order="10"]) { order: 10; }
|
|
160
|
+
|
|
161
|
+
/* Pull (right positioning) - Apply to :host */
|
|
162
|
+
:host([data-pull="0"]) { right: auto; }
|
|
163
|
+
:host([data-pull="1"]) { right: 4.16666667%; }
|
|
164
|
+
:host([data-pull="2"]) { right: 8.33333333%; }
|
|
165
|
+
:host([data-pull="3"]) { right: 12.5%; }
|
|
166
|
+
:host([data-pull="4"]) { right: 16.66666667%; }
|
|
167
|
+
:host([data-pull="5"]) { right: 20.83333333%; }
|
|
168
|
+
:host([data-pull="6"]) { right: 25%; }
|
|
169
|
+
:host([data-pull="7"]) { right: 29.16666667%; }
|
|
170
|
+
:host([data-pull="8"]) { right: 33.33333333%; }
|
|
171
|
+
:host([data-pull="9"]) { right: 37.5%; }
|
|
172
|
+
:host([data-pull="10"]) { right: 41.66666667%; }
|
|
173
|
+
:host([data-pull="11"]) { right: 45.83333333%; }
|
|
174
|
+
:host([data-pull="12"]) { right: 50%; }
|
|
175
|
+
|
|
176
|
+
/* Push (left positioning) - Apply to :host */
|
|
177
|
+
:host([data-push="0"]) { left: auto; }
|
|
178
|
+
:host([data-push="1"]) { left: 4.16666667%; }
|
|
179
|
+
:host([data-push="2"]) { left: 8.33333333%; }
|
|
180
|
+
:host([data-push="3"]) { left: 12.5%; }
|
|
181
|
+
:host([data-push="4"]) { left: 16.66666667%; }
|
|
182
|
+
:host([data-push="5"]) { left: 20.83333333%; }
|
|
183
|
+
:host([data-push="6"]) { left: 25%; }
|
|
184
|
+
:host([data-push="7"]) { left: 29.16666667%; }
|
|
185
|
+
:host([data-push="8"]) { left: 33.33333333%; }
|
|
186
|
+
:host([data-push="9"]) { left: 37.5%; }
|
|
187
|
+
:host([data-push="10"]) { left: 41.66666667%; }
|
|
188
|
+
:host([data-push="11"]) { left: 45.83333333%; }
|
|
189
|
+
:host([data-push="12"]) { left: 50%; }
|
|
190
|
+
`
|
|
8
191
|
/**
|
|
9
192
|
* @license
|
|
10
193
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
11
194
|
* SPDX-License-Identifier: MIT
|
|
12
|
-
*/;var u=function(t,a,s,e){for(var o,r=arguments.length,i=r<3?a:null===e?e=Object.getOwnPropertyDescriptor(a,s):e,d=t.length-1;d>=0;d--)(o=t[d])&&(i=(r<3?o(i):r>3?o(a,s,i):o(a,s))||i);return r>3&&i&&Object.defineProperty(a,s,i),i};let
|
|
195
|
+
*/;var u=function(t,a,s,e){for(var o,r=arguments.length,i=r<3?a:null===e?e=Object.getOwnPropertyDescriptor(a,s):e,d=t.length-1;d>=0;d--)(o=t[d])&&(i=(r<3?o(i):r>3?o(a,s,i):o(a,s))||i);return r>3&&i&&Object.defineProperty(a,s,i),i};let m=class extends(i(a)){constructor(){super(...arguments),this.offset=0,this.pull=0,this.push=0,this.flex="",this.currentBreakpoint="xs"}connectedCallback(){super.connectedCallback(),this.setupResponsive()}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this.resizeObserver)||void 0===t||t.disconnect()}setupResponsive(){this.updateBreakpoint(),this.resizeObserver=new ResizeObserver((()=>{this.updateBreakpoint()})),this.resizeObserver.observe(document.documentElement)}updateBreakpoint(){const t=window.innerWidth;let a;a=t>=n.xxl?"xxl":t>=n.xl?"xl":t>=n.lg?"lg":t>=n.md?"md":t>=n.sm?"sm":"xs",a!==this.currentBreakpoint&&(this.currentBreakpoint=a)}getResponsiveConfig(){const t=[this.currentBreakpoint,"xl","lg","md","sm","xs"];for(const a of t){const t=this[a];if(void 0!==t)return"number"==typeof t?{span:t}:t}return{}}getColProperties(){var t,a,s,e,o;const r=this.getResponsiveConfig();return{span:null!==(t=r.span)&&void 0!==t?t:this.span,offset:null!==(a=r.offset)&&void 0!==a?a:this.offset,order:null!==(s=r.order)&&void 0!==s?s:this.order,pull:null!==(e=r.pull)&&void 0!==e?e:this.pull,push:null!==(o=r.push)&&void 0!==o?o:this.push}}getGutterFromParent(){const t=this.closest("nr-row");if(t){const a=t.getAttribute("data-gutter");return a?parseInt(a,10):0}return 0}getColStyle(){const t={},a=this.getGutterFromParent();return a>0&&(t["padding-left"]=a/2+"px",t["padding-right"]=a/2+"px"),this.flex&&("auto"===this.flex?t.flex="1 1 auto":"none"===this.flex?t.flex="0 0 auto":"number"==typeof this.flex?t.flex=`${this.flex} ${this.flex} auto`:t.flex=this.flex),t}render(){var t;const a=this.getColStyle(),e=this.getColProperties();return this.setAttribute("data-span",(null===(t=e.span)||void 0===t?void 0:t.toString())||""),this.setAttribute("data-offset",e.offset.toString()),void 0!==e.order?this.setAttribute("data-order",e.order.toString()):this.removeAttribute("data-order"),this.setAttribute("data-pull",e.pull.toString()),this.setAttribute("data-push",e.push.toString()),this.setAttribute("data-theme",this.currentTheme),s`
|
|
196
|
+
<div
|
|
197
|
+
class="nr-col"
|
|
198
|
+
style="${Object.entries(a).map((([t,a])=>`${t}: ${a}`)).join("; ")}"
|
|
199
|
+
>
|
|
200
|
+
<slot></slot>
|
|
201
|
+
</div>
|
|
202
|
+
`}};m.styles=p,u([e({type:Number})],m.prototype,"span",void 0),u([e({type:Number})],m.prototype,"offset",void 0),u([e({type:Number})],m.prototype,"order",void 0),u([e({type:Number})],m.prototype,"pull",void 0),u([e({type:Number})],m.prototype,"push",void 0),u([e({type:String})],m.prototype,"flex",void 0),u([e({type:Object})],m.prototype,"xs",void 0),u([e({type:Object})],m.prototype,"sm",void 0),u([e({type:Object})],m.prototype,"md",void 0),u([e({type:Object})],m.prototype,"lg",void 0),u([e({type:Object})],m.prototype,"xl",void 0),u([e({type:Object})],m.prototype,"xxl",void 0),u([o()],m.prototype,"currentBreakpoint",void 0),m=u([r("nr-col")],m);export{n as BREAKPOINTS,h as EMPTY_STRING,m as NrColElement,f as NrRowElement};
|