@nuralyui/flex 0.0.1
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 +163 -0
- package/flex.component.d.ts +89 -0
- package/flex.component.js +178 -0
- package/flex.component.js.map +1 -0
- package/flex.style.d.ts +6 -0
- package/flex.style.js +101 -0
- package/flex.style.js.map +1 -0
- package/flex.types.d.ts +63 -0
- package/flex.types.js +5 -0
- package/flex.types.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/package.json +49 -0
- package/react.d.ts +3 -0
- package/react.js +10 -0
- package/react.js.map +1 -0
package/bundle.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const t=window,i=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),e=new WeakMap;class n{constructor(t,i,e){if(this._$cssResult$=!0,e!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const s=this.t;if(i&&void 0===t){const i=void 0!==s&&1===s.length;i&&(t=e.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&e.set(s,t))}return t}toString(){return this.cssText}}const o=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let i="";for(const s of t.cssRules)i+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(i)})(t):t
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2017 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/;var r;const h=window,l=h.trustedTypes,a=l?l.emptyScript:"",d=h.reactiveElementPolyfillSupport,c={toAttribute(t,i){switch(i){case Boolean:t=t?a:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},u=(t,i)=>i!==t&&(i==i||t==t),v={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:u},f="finalized";class p extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),(null!==(i=this.h)&&void 0!==i?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,s)=>{const e=this._$Ep(s,i);void 0!==e&&(this._$Ev.set(e,s),t.push(e))})),t}static createProperty(t,i=v){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e)}}static getPropertyDescriptor(t,i,s){return{get(){return this[i]},set(e){const n=this[t];this[i]=e,this.requestUpdate(t,n,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||v}static finalize(){if(this.hasOwnProperty(f))return!1;this[f]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const s of i)this.createProperty(s,t[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)i.unshift(o(t))}else void 0!==t&&i.push(o(t));return i}static _$Ep(t,i){const s=i.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var i,s;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.call(t))}removeController(t){var i;null===(i=this._$ES)||void 0===i||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])}))}createRenderRoot(){var s;const e=null!==(s=this.shadowRoot)&&void 0!==s?s:this.attachShadow(this.constructor.shadowRootOptions);return((s,e)=>{i?s.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((i=>{const e=document.createElement("style"),n=t.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=i.cssText,s.appendChild(e)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}))}attributeChangedCallback(t,i,s){this._$AK(t,s)}_$EO(t,i,s=v){var e;const n=this.constructor._$Ep(t,s);if(void 0!==n&&!0===s.reflect){const o=(void 0!==(null===(e=s.converter)||void 0===e?void 0:e.toAttribute)?s.converter:c).toAttribute(i,s.type);this._$El=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$El=null}}_$AK(t,i){var s;const e=this.constructor,n=e._$Ev.get(t);if(void 0!==n&&this._$El!==n){const t=e.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(s=t.converter)||void 0===s?void 0:s.fromAttribute)?t.converter:c;this._$El=n,this[n]=o.fromAttribute(i,t.type),this._$El=null}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||u)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):e=!1),!this.isUpdatePending&&e&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,i)=>this[i]=t)),this._$Ei=void 0);let i=!1;const s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(s)):this._$Ek()}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(s)}willUpdate(t){}_$AE(t){var i;null===(i=this._$ES)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$EO(i,this[i],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2017 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
var g;p[f]=!0,p.elementProperties=new Map,p.elementStyles=[],p.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:p}),(null!==(r=h.reactiveElementVersions)&&void 0!==r?r:h.reactiveElementVersions=[]).push("1.6.3");const y=window,m=y.trustedTypes,w=m?m.createPolicy("lit-html",{createHTML:t=>t}):void 0,b="$lit$",x=`lit$${(Math.random()+"").slice(9)}$`,$="?"+x,S=`<${$}>`,A=document,j=()=>A.createComment(""),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,_=Array.isArray,C="[ \t\n\f\r]",k=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,T=/>/g,U=RegExp(`>|${C}(?:([^\\s"'>=/]+)(${C}*=${C}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),M=/'/g,R=/"/g,N=/^(?:script|style|textarea|title)$/i,D=Symbol.for("lit-noChange"),z=Symbol.for("lit-nothing"),I=new WeakMap,P=A.createTreeWalker(A,129,null,!1);function F(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(i):i}class L{constructor({strings:t,_$litType$:i},s){let e;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[l,a]=((t,i)=>{const s=t.length-1,e=[];let n,o=2===i?"<svg>":"",r=k;for(let i=0;i<s;i++){const s=t[i];let h,l,a=-1,d=0;for(;d<s.length&&(r.lastIndex=d,l=r.exec(s),null!==l);)d=r.lastIndex,r===k?"!--"===l[1]?r=O:void 0!==l[1]?r=T:void 0!==l[2]?(N.test(l[2])&&(n=RegExp("</"+l[2],"g")),r=U):void 0!==l[3]&&(r=U):r===U?">"===l[0]?(r=null!=n?n:k,a=-1):void 0===l[1]?a=-2:(a=r.lastIndex-l[2].length,h=l[1],r=void 0===l[3]?U:'"'===l[3]?R:M):r===R||r===M?r=U:r===O||r===T?r=k:(r=U,n=void 0);const c=r===U&&t[i+1].startsWith("/>")?" ":"";o+=r===k?s+S:a>=0?(e.push(h),s.slice(0,a)+b+s.slice(a)+x+c):s+x+(-2===a?(e.push(void 0),i):c)}return[F(t,o+(t[s]||"<?>")+(2===i?"</svg>":"")),e]})(t,i);if(this.el=L.createElement(l,s),P.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=P.nextNode())&&h.length<r;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith(b)||i.startsWith(x)){const s=a[o++];if(t.push(i),void 0!==s){const t=e.getAttribute(s.toLowerCase()+b).split(x),i=/([.?@])?(.*)/.exec(s);h.push({type:1,index:n,name:i[2],strings:t,ctor:"."===i[1]?W:"?"===i[1]?Z:"@"===i[1]?J:H})}else h.push({type:6,index:n})}for(const i of t)e.removeAttribute(i)}if(N.test(e.tagName)){const t=e.textContent.split(x),i=t.length-1;if(i>0){e.textContent=m?m.emptyScript:"";for(let s=0;s<i;s++)e.append(t[s],j()),P.nextNode(),h.push({type:2,index:++n});e.append(t[i],j())}}}else if(8===e.nodeType)if(e.data===$)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=e.data.indexOf(x,t+1));)h.push({type:7,index:n}),t+=x.length-1}n++}}static createElement(t,i){const s=A.createElement("template");return s.innerHTML=t,s}}function K(t,i,s=t,e){var n,o,r,h;if(i===D)return i;let l=void 0!==e?null===(n=s._$Co)||void 0===n?void 0:n[e]:s._$Cl;const a=E(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==a&&(null===(o=null==l?void 0:l._$AO)||void 0===o||o.call(l,!1),void 0===a?l=void 0:(l=new a(t),l._$AT(t,s,e)),void 0!==e?(null!==(r=(h=s)._$Co)&&void 0!==r?r:h._$Co=[])[e]=l:s._$Cl=l),void 0!==l&&(i=K(t,l._$AS(t,i.values),l,e)),i}class V{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;const{el:{content:s},parts:e}=this._$AD,n=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:A).importNode(s,!0);P.currentNode=n;let o=P.nextNode(),r=0,h=0,l=e[0];for(;void 0!==l;){if(r===l.index){let i;2===l.type?i=new q(o,o.nextSibling,this,t):1===l.type?i=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(i=new G(o,this,t)),this._$AV.push(i),l=e[++h]}r!==(null==l?void 0:l.index)&&(o=P.nextNode(),r++)}return P.currentNode=A,n}v(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class q{constructor(t,i,s,e){var n;this.type=2,this._$AH=z,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cp=null===(n=null==e?void 0:e.isConnected)||void 0===n||n}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===(null==t?void 0:t.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=K(this,t,i),E(t)?t===z||null==t||""===t?(this._$AH!==z&&this._$AR(),this._$AH=z):t!==this._$AH&&t!==D&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>_(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==z&&E(this._$AH)?this._$AA.nextSibling.data=t:this.$(A.createTextNode(t)),this._$AH=t}g(t){var i;const{values:s,_$litType$:e}=t,n="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=L.createElement(F(e.h,e.h[0]),this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===n)this._$AH.v(s);else{const t=new V(n,this),i=t.u(this.options);t.v(s),this.$(i),this._$AH=t}}_$AC(t){let i=I.get(t.strings);return void 0===i&&I.set(t.strings,i=new L(t)),i}T(t){_(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const n of t)e===i.length?i.push(s=new q(this.k(j()),this.k(j()),this,this.options)):s=i[e],s._$AI(n),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cp=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class H{constructor(t,i,s,e,n){this.type=1,this._$AH=z,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=z}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const n=this.strings;let o=!1;if(void 0===n)t=K(this,t,i,0),o=!E(t)||t!==this._$AH&&t!==D,o&&(this._$AH=t);else{const e=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=K(this,e[s+r],i,r),h===D&&(h=this._$AH[r]),o||(o=!E(h)||h!==this._$AH[r]),h===z?t=z:t!==z&&(t+=(null!=h?h:"")+n[r+1]),this._$AH[r]=h}o&&!e&&this.j(t)}j(t){t===z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class W extends H{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===z?void 0:t}}const B=m?m.emptyScript:"";class Z extends H{constructor(){super(...arguments),this.type=4}j(t){t&&t!==z?this.element.setAttribute(this.name,B):this.element.removeAttribute(this.name)}}class J extends H{constructor(t,i,s,e,n){super(t,i,s,e,n),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=K(this,t,i,0))&&void 0!==s?s:z)===D)return;const e=this._$AH,n=t===z&&e!==z||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,o=t!==z&&(e===z||n);n&&this.element.removeEventListener(this.name,this,e),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class G{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){K(this,t)}}const Q=y.litHtmlPolyfillSupport;
|
|
18
|
+
/**
|
|
19
|
+
* @license
|
|
20
|
+
* Copyright 2017 Google LLC
|
|
21
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
+
*/
|
|
23
|
+
var X;null==Q||Q(L,q),(null!==(g=y.litHtmlVersions)&&void 0!==g?g:y.litHtmlVersions=[]).push("2.8.0");const Y=window,tt=Y.trustedTypes,it=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,st="$lit$",et=`lit$${(Math.random()+"").slice(9)}$`,nt="?"+et,ot=`<${nt}>`,rt=document,ht=()=>rt.createComment(""),lt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,at=Array.isArray,dt="[ \t\n\f\r]",ct=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ut=/-->/g,vt=/>/g,ft=RegExp(`>|${dt}(?:([^\\s"'>=/]+)(${dt}*=${dt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),pt=/'/g,gt=/"/g,yt=/^(?:script|style|textarea|title)$/i,mt=(t=>(i,...s)=>({_$litType$:t,strings:i,values:s}))(1),wt=Symbol.for("lit-noChange"),bt=Symbol.for("lit-nothing"),xt=new WeakMap,$t=rt.createTreeWalker(rt,129,null,!1);function St(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==it?it.createHTML(i):i}const At=(t,i)=>{const s=t.length-1,e=[];let n,o=2===i?"<svg>":"",r=ct;for(let i=0;i<s;i++){const s=t[i];let h,l,a=-1,d=0;for(;d<s.length&&(r.lastIndex=d,l=r.exec(s),null!==l);)d=r.lastIndex,r===ct?"!--"===l[1]?r=ut:void 0!==l[1]?r=vt:void 0!==l[2]?(yt.test(l[2])&&(n=RegExp("</"+l[2],"g")),r=ft):void 0!==l[3]&&(r=ft):r===ft?">"===l[0]?(r=null!=n?n:ct,a=-1):void 0===l[1]?a=-2:(a=r.lastIndex-l[2].length,h=l[1],r=void 0===l[3]?ft:'"'===l[3]?gt:pt):r===gt||r===pt?r=ft:r===ut||r===vt?r=ct:(r=ft,n=void 0);const c=r===ft&&t[i+1].startsWith("/>")?" ":"";o+=r===ct?s+ot:a>=0?(e.push(h),s.slice(0,a)+st+s.slice(a)+et+c):s+et+(-2===a?(e.push(void 0),i):c)}return[St(t,o+(t[s]||"<?>")+(2===i?"</svg>":"")),e]};class jt{constructor({strings:t,_$litType$:i},s){let e;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[l,a]=At(t,i);if(this.el=jt.createElement(l,s),$t.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=$t.nextNode())&&h.length<r;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith(st)||i.startsWith(et)){const s=a[o++];if(t.push(i),void 0!==s){const t=e.getAttribute(s.toLowerCase()+st).split(et),i=/([.?@])?(.*)/.exec(s);h.push({type:1,index:n,name:i[2],strings:t,ctor:"."===i[1]?Ot:"?"===i[1]?Ut:"@"===i[1]?Mt:kt})}else h.push({type:6,index:n})}for(const i of t)e.removeAttribute(i)}if(yt.test(e.tagName)){const t=e.textContent.split(et),i=t.length-1;if(i>0){e.textContent=tt?tt.emptyScript:"";for(let s=0;s<i;s++)e.append(t[s],ht()),$t.nextNode(),h.push({type:2,index:++n});e.append(t[i],ht())}}}else if(8===e.nodeType)if(e.data===nt)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=e.data.indexOf(et,t+1));)h.push({type:7,index:n}),t+=et.length-1}n++}}static createElement(t,i){const s=rt.createElement("template");return s.innerHTML=t,s}}function Et(t,i,s=t,e){var n,o,r,h;if(i===wt)return i;let l=void 0!==e?null===(n=s._$Co)||void 0===n?void 0:n[e]:s._$Cl;const a=lt(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==a&&(null===(o=null==l?void 0:l._$AO)||void 0===o||o.call(l,!1),void 0===a?l=void 0:(l=new a(t),l._$AT(t,s,e)),void 0!==e?(null!==(r=(h=s)._$Co)&&void 0!==r?r:h._$Co=[])[e]=l:s._$Cl=l),void 0!==l&&(i=Et(t,l._$AS(t,i.values),l,e)),i}class _t{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;const{el:{content:s},parts:e}=this._$AD,n=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:rt).importNode(s,!0);$t.currentNode=n;let o=$t.nextNode(),r=0,h=0,l=e[0];for(;void 0!==l;){if(r===l.index){let i;2===l.type?i=new Ct(o,o.nextSibling,this,t):1===l.type?i=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(i=new Rt(o,this,t)),this._$AV.push(i),l=e[++h]}r!==(null==l?void 0:l.index)&&(o=$t.nextNode(),r++)}return $t.currentNode=rt,n}v(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class Ct{constructor(t,i,s,e){var n;this.type=2,this._$AH=bt,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cp=null===(n=null==e?void 0:e.isConnected)||void 0===n||n}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===(null==t?void 0:t.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=Et(this,t,i),lt(t)?t===bt||null==t||""===t?(this._$AH!==bt&&this._$AR(),this._$AH=bt):t!==this._$AH&&t!==wt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>at(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==bt&<(this._$AH)?this._$AA.nextSibling.data=t:this.$(rt.createTextNode(t)),this._$AH=t}g(t){var i;const{values:s,_$litType$:e}=t,n="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=jt.createElement(St(e.h,e.h[0]),this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===n)this._$AH.v(s);else{const t=new _t(n,this),i=t.u(this.options);t.v(s),this.$(i),this._$AH=t}}_$AC(t){let i=xt.get(t.strings);return void 0===i&&xt.set(t.strings,i=new jt(t)),i}T(t){at(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const n of t)e===i.length?i.push(s=new Ct(this.k(ht()),this.k(ht()),this,this.options)):s=i[e],s._$AI(n),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cp=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class kt{constructor(t,i,s,e,n){this.type=1,this._$AH=bt,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=bt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const n=this.strings;let o=!1;if(void 0===n)t=Et(this,t,i,0),o=!lt(t)||t!==this._$AH&&t!==wt,o&&(this._$AH=t);else{const e=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=Et(this,e[s+r],i,r),h===wt&&(h=this._$AH[r]),o||(o=!lt(h)||h!==this._$AH[r]),h===bt?t=bt:t!==bt&&(t+=(null!=h?h:"")+n[r+1]),this._$AH[r]=h}o&&!e&&this.j(t)}j(t){t===bt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Ot extends kt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===bt?void 0:t}}const Tt=tt?tt.emptyScript:"";class Ut extends kt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==bt?this.element.setAttribute(this.name,Tt):this.element.removeAttribute(this.name)}}class Mt extends kt{constructor(t,i,s,e,n){super(t,i,s,e,n),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=Et(this,t,i,0))&&void 0!==s?s:bt)===wt)return;const e=this._$AH,n=t===bt&&e!==bt||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,o=t!==bt&&(e===bt||n);n&&this.element.removeEventListener(this.name,this,e),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class Rt{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Et(this,t)}}const Nt=Y.litHtmlPolyfillSupport;null==Nt||Nt(jt,Ct),(null!==(X=Y.litHtmlVersions)&&void 0!==X?X:Y.litHtmlVersions=[]).push("2.8.0");
|
|
24
|
+
/**
|
|
25
|
+
* @license
|
|
26
|
+
* Copyright 2017 Google LLC
|
|
27
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
+
*/
|
|
29
|
+
var Dt,zt;class It extends p{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;const s=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=s.firstChild),s}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,i,s)=>{var e,n;const o=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:i;let r=o._$litPart$;if(void 0===r){const t=null!==(n=null==s?void 0:s.renderBefore)&&void 0!==n?n:null;o._$litPart$=r=new Ct(i.insertBefore(ht(),t),t,void 0,null!=s?s:{})}return r._$AI(t),r})(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return wt}}It.finalized=!0,It._$litElement$=!0,null===(Dt=globalThis.litElementHydrateSupport)||void 0===Dt||Dt.call(globalThis,{LitElement:It});const Pt=globalThis.litElementPolyfillSupport;null==Pt||Pt({LitElement:It}),(null!==(zt=globalThis.litElementVersions)&&void 0!==zt?zt:globalThis.litElementVersions=[]).push("3.3.3");
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2017 Google LLC
|
|
33
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
+
*/
|
|
35
|
+
const Ft=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(s){s.createProperty(i.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:i.key,initializer(){"function"==typeof i.initializer&&(this[i.key]=i.initializer.call(this))},finisher(s){s.createProperty(i.key,t)}};
|
|
36
|
+
/**
|
|
37
|
+
* @license
|
|
38
|
+
* Copyright 2017 Google LLC
|
|
39
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
40
|
+
*/function Lt(t){return(i,s)=>void 0!==s?((t,i,s)=>{i.constructor.createProperty(s,t)})(t,i,s):Ft(t,i)
|
|
41
|
+
/**
|
|
42
|
+
* @license
|
|
43
|
+
* Copyright 2021 Google LLC
|
|
44
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
45
|
+
*/}var Kt;null===(Kt=window.HTMLSlotElement)||void 0===Kt||Kt.prototype.assignedElements;const Vt=((t,...i)=>{const e=1===t.length?t[0]:i.reduce(((i,s,e)=>i+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[e+1]),t[0]);return new n(e,t,s)})`
|
|
46
|
+
:host {
|
|
47
|
+
display: block;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.nr-flex {
|
|
52
|
+
display: flex;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
|
|
55
|
+
/* Theme-aware */
|
|
56
|
+
color: var(--nuraly-color-text);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Inline flex */
|
|
60
|
+
.nr-flex[data-inline="true"] {
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Flex direction */
|
|
65
|
+
.nr-flex[data-direction="row"] {
|
|
66
|
+
flex-direction: row;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.nr-flex[data-direction="row-reverse"] {
|
|
70
|
+
flex-direction: row-reverse;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.nr-flex[data-direction="column"] {
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.nr-flex[data-direction="column-reverse"] {
|
|
78
|
+
flex-direction: column-reverse;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Flex wrap */
|
|
82
|
+
.nr-flex[data-wrap="nowrap"] {
|
|
83
|
+
flex-wrap: nowrap;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.nr-flex[data-wrap="wrap"] {
|
|
87
|
+
flex-wrap: wrap;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.nr-flex[data-wrap="wrap-reverse"] {
|
|
91
|
+
flex-wrap: wrap-reverse;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Justify content */
|
|
95
|
+
.nr-flex[data-justify="flex-start"] {
|
|
96
|
+
justify-content: flex-start;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.nr-flex[data-justify="flex-end"] {
|
|
100
|
+
justify-content: flex-end;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.nr-flex[data-justify="center"] {
|
|
104
|
+
justify-content: center;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.nr-flex[data-justify="space-between"] {
|
|
108
|
+
justify-content: space-between;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.nr-flex[data-justify="space-around"] {
|
|
112
|
+
justify-content: space-around;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.nr-flex[data-justify="space-evenly"] {
|
|
116
|
+
justify-content: space-evenly;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Align items */
|
|
120
|
+
.nr-flex[data-align="flex-start"] {
|
|
121
|
+
align-items: flex-start;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.nr-flex[data-align="flex-end"] {
|
|
125
|
+
align-items: flex-end;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.nr-flex[data-align="center"] {
|
|
129
|
+
align-items: center;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.nr-flex[data-align="baseline"] {
|
|
133
|
+
align-items: baseline;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.nr-flex[data-align="stretch"] {
|
|
137
|
+
align-items: stretch;
|
|
138
|
+
}
|
|
139
|
+
`
|
|
140
|
+
/**
|
|
141
|
+
* @license
|
|
142
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
143
|
+
* SPDX-License-Identifier: MIT
|
|
144
|
+
*/,qt=t=>class extends t{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var t,i,s;super.disconnectedCallback(),null===(t=this.themeObserver)||void 0===t||t.disconnect(),null===(i=this.designSystemObserver)||void 0===i||i.disconnect(),null===(s=this.mediaQuery)||void 0===s||s.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var t,i;const s=(null===(t=this.closest("[data-theme]"))||void 0===t?void 0:t.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return s||((null===(i=window.matchMedia)||void 0===i?void 0:i.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var t;const i=(null===(t=this.closest("[design-system]"))||void 0===t?void 0:t.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===i?i:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver((()=>{this.requestUpdate()})),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver((()=>{this.requestUpdate()})),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},Ht=()=>{var t;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(t=process.env)||void 0===t?void 0:t.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},Wt=t=>class extends t{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(Ht())for(const t of this.requiredComponents)if(!this.isComponentAvailable(t))throw new Error(`Required component "${t}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${t}';`)}validateDependenciesWithHandler(t){if(!Ht())return!0;let i=!0;for(const s of this.requiredComponents)if(!this.isComponentAvailable(s)){i=!1;const e=new Error(`Required component "${s}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);t?t(s,e):console.error(e.message)}return i}isComponentAvailable(t){return!!customElements.get(t)}getMissingDependencies(){return this.requiredComponents.filter((t=>!this.isComponentAvailable(t)))}areDependenciesAvailable(){return this.requiredComponents.every((t=>this.isComponentAvailable(t)))}addRequiredComponent(t){this.requiredComponents.includes(t)||this.requiredComponents.push(t)}removeRequiredComponent(t){const i=this.requiredComponents.indexOf(t);i>-1&&this.requiredComponents.splice(i,1)}},Bt=t=>class extends t{dispatchCustomEvent(t,i){this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(t,i){var s;const e=Object.assign(Object.assign({},i),{timestamp:Date.now(),componentName:(null===(s=this.tagName)||void 0===s?void 0:s.toLowerCase())||"unknown"});this.dispatchCustomEvent(t,e)}dispatchInputEvent(t,i){const s=Object.assign({target:i.target||this,value:i.value,originalEvent:i.originalEvent},i);this.dispatchCustomEvent(t,s)}dispatchFocusEvent(t,i){const s=Object.assign({target:i.target||this,value:i.value,focused:i.focused,cursorPosition:i.cursorPosition,selectedText:i.selectedText},i);this.dispatchCustomEvent(t,s)}dispatchValidationEvent(t,i){var s;const e=Object.assign({target:i.target||this,value:i.value,isValid:null!==(s=i.isValid)&&void 0!==s&&s,error:i.error},i);this.dispatchCustomEvent(t,e)}dispatchActionEvent(t,i){const s=Object.assign({target:i.target||this,action:i.action,previousValue:i.previousValue,newValue:i.newValue},i);this.dispatchCustomEvent(t,s)}isReadonlyKeyAllowed(t){if(t.ctrlKey||t.metaKey){return["KeyA","KeyC"].includes(t.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)}isActivationKey(t){return"Enter"===t.key||" "===t.key}},Zt="";
|
|
145
|
+
/**
|
|
146
|
+
* @license
|
|
147
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
148
|
+
* SPDX-License-Identifier: MIT
|
|
149
|
+
*/
|
|
150
|
+
var Jt=function(t,i,s,e){for(var n,o=arguments.length,r=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,h=t.length-1;h>=0;h--)(n=t[h])&&(r=(o<3?n(r):o>3?n(i,s,r):n(i,s))||r);return o>3&&r&&Object.defineProperty(i,s,r),r};let Gt=class extends((t=>Wt(qt(Bt(t))))(It)){constructor(){super(...arguments),this.direction="row",this.vertical=!1,this.wrap="nowrap",this.justify="",this.align="",this.gap=0,this.inline=!1,this.flex=""}getFlexDirection(){return this.vertical?"column":this.direction}getGapValue(t){if("number"==typeof t)return`${t}px`;if("string"==typeof t)switch(t){case"small":return"var(--nuraly-spacing-2, 8px)";case"medium":return"var(--nuraly-spacing-3, 16px)";case"large":return"var(--nuraly-spacing-4, 24px)";default:return t}return"0"}getGapStyles(){const t={};if(Array.isArray(this.gap)){const[i,s]=this.gap;t["column-gap"]=this.getGapValue(i),t["row-gap"]=this.getGapValue(s)}else this.gap&&(t.gap=this.getGapValue(this.gap));return t}getFlexStyles(){const t=Object.assign({},this.getGapStyles());return this.flex&&(t.flex=this.flex),Object.entries(t).map((([t,i])=>`${t}: ${i}`)).join("; ")}render(){const t=this.getFlexDirection(),i=this.getFlexStyles();return mt`
|
|
151
|
+
<div
|
|
152
|
+
class="nr-flex"
|
|
153
|
+
data-direction="${t}"
|
|
154
|
+
data-wrap="${this.wrap}"
|
|
155
|
+
data-justify="${this.justify}"
|
|
156
|
+
data-align="${this.align}"
|
|
157
|
+
data-inline="${this.inline}"
|
|
158
|
+
data-theme="${this.currentTheme}"
|
|
159
|
+
style="${i}"
|
|
160
|
+
>
|
|
161
|
+
<slot></slot>
|
|
162
|
+
</div>
|
|
163
|
+
`}};Gt.styles=Vt,Jt([Lt({type:String})],Gt.prototype,"direction",void 0),Jt([Lt({type:Boolean})],Gt.prototype,"vertical",void 0),Jt([Lt({type:String})],Gt.prototype,"wrap",void 0),Jt([Lt({type:String})],Gt.prototype,"justify",void 0),Jt([Lt({type:String})],Gt.prototype,"align",void 0),Jt([Lt({type:Object})],Gt.prototype,"gap",void 0),Jt([Lt({type:Boolean})],Gt.prototype,"inline",void 0),Jt([Lt({type:String})],Gt.prototype,"flex",void 0),Gt=Jt([(t=>i=>"function"==typeof i?((t,i)=>(customElements.define(t,i),i))(t,i):((t,i)=>{const{kind:s,elements:e}=i;return{kind:s,elements:e,finisher(i){customElements.define(t,i)}}})(t,i))("nr-flex")],Gt);export{Zt as EMPTY_STRING,Gt as NrFlexElement};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { FlexDirection, FlexWrap, FlexJustify, FlexAlign, Gap } from './flex.types.js';
|
|
8
|
+
declare const NrFlexElement_base: (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & (new (...args: any[]) => import("../../shared/event-handler-mixin.js").EventHandlerCapable) & typeof LitElement;
|
|
9
|
+
/**
|
|
10
|
+
* Flex layout component for flexible box layouts
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```html
|
|
14
|
+
* <!-- Basic flex -->
|
|
15
|
+
* <nr-flex>
|
|
16
|
+
* <div>Item 1</div>
|
|
17
|
+
* <div>Item 2</div>
|
|
18
|
+
* <div>Item 3</div>
|
|
19
|
+
* </nr-flex>
|
|
20
|
+
*
|
|
21
|
+
* <!-- Flex with gap -->
|
|
22
|
+
* <nr-flex gap="medium">
|
|
23
|
+
* <div>Item 1</div>
|
|
24
|
+
* <div>Item 2</div>
|
|
25
|
+
* </nr-flex>
|
|
26
|
+
*
|
|
27
|
+
* <!-- Centered flex -->
|
|
28
|
+
* <nr-flex justify="center" align="center">
|
|
29
|
+
* <div>Centered content</div>
|
|
30
|
+
* </nr-flex>
|
|
31
|
+
*
|
|
32
|
+
* <!-- Column layout with gap -->
|
|
33
|
+
* <nr-flex vertical gap="16">
|
|
34
|
+
* <div>Item 1</div>
|
|
35
|
+
* <div>Item 2</div>
|
|
36
|
+
* </nr-flex>
|
|
37
|
+
*
|
|
38
|
+
* <!-- Responsive gap -->
|
|
39
|
+
* <nr-flex .gap=${[16, 24]}>
|
|
40
|
+
* <div>Item 1</div>
|
|
41
|
+
* <div>Item 2</div>
|
|
42
|
+
* </nr-flex>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @slot default - Flex items
|
|
46
|
+
*/
|
|
47
|
+
export declare class NrFlexElement extends NrFlexElement_base {
|
|
48
|
+
static styles: import("lit").CSSResult;
|
|
49
|
+
/** Flex direction (shorthand: use vertical prop for column) */
|
|
50
|
+
direction: FlexDirection;
|
|
51
|
+
/** Shorthand for flex-direction: column */
|
|
52
|
+
vertical: boolean;
|
|
53
|
+
/** Flex wrap behavior */
|
|
54
|
+
wrap: FlexWrap;
|
|
55
|
+
/** Justify content alignment */
|
|
56
|
+
justify: FlexJustify | '';
|
|
57
|
+
/** Align items alignment */
|
|
58
|
+
align: FlexAlign | '';
|
|
59
|
+
/** Gap between flex items - can be preset string, number (px), or [horizontal, vertical] */
|
|
60
|
+
gap: Gap;
|
|
61
|
+
/** Make flex container inline */
|
|
62
|
+
inline: boolean;
|
|
63
|
+
/** Custom flex CSS value (e.g., "1", "auto", "none") */
|
|
64
|
+
flex: string | '';
|
|
65
|
+
/**
|
|
66
|
+
* Get computed flex direction
|
|
67
|
+
*/
|
|
68
|
+
private getFlexDirection;
|
|
69
|
+
/**
|
|
70
|
+
* Convert gap value to CSS value
|
|
71
|
+
*/
|
|
72
|
+
private getGapValue;
|
|
73
|
+
/**
|
|
74
|
+
* Get gap styles for flex container
|
|
75
|
+
*/
|
|
76
|
+
private getGapStyles;
|
|
77
|
+
/**
|
|
78
|
+
* Get all inline styles for flex container
|
|
79
|
+
*/
|
|
80
|
+
private getFlexStyles;
|
|
81
|
+
render(): import("lit").TemplateResult<1>;
|
|
82
|
+
}
|
|
83
|
+
declare global {
|
|
84
|
+
interface HTMLElementTagNameMap {
|
|
85
|
+
'nr-flex': NrFlexElement;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=flex.component.d.ts.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
import { html, LitElement } from 'lit';
|
|
13
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
+
import { styles } from './flex.style.js';
|
|
15
|
+
import { NuralyUIBaseMixin } from '../../shared/base-mixin.js';
|
|
16
|
+
import { EMPTY_STRING } from './flex.types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Flex layout component for flexible box layouts
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```html
|
|
22
|
+
* <!-- Basic flex -->
|
|
23
|
+
* <nr-flex>
|
|
24
|
+
* <div>Item 1</div>
|
|
25
|
+
* <div>Item 2</div>
|
|
26
|
+
* <div>Item 3</div>
|
|
27
|
+
* </nr-flex>
|
|
28
|
+
*
|
|
29
|
+
* <!-- Flex with gap -->
|
|
30
|
+
* <nr-flex gap="medium">
|
|
31
|
+
* <div>Item 1</div>
|
|
32
|
+
* <div>Item 2</div>
|
|
33
|
+
* </nr-flex>
|
|
34
|
+
*
|
|
35
|
+
* <!-- Centered flex -->
|
|
36
|
+
* <nr-flex justify="center" align="center">
|
|
37
|
+
* <div>Centered content</div>
|
|
38
|
+
* </nr-flex>
|
|
39
|
+
*
|
|
40
|
+
* <!-- Column layout with gap -->
|
|
41
|
+
* <nr-flex vertical gap="16">
|
|
42
|
+
* <div>Item 1</div>
|
|
43
|
+
* <div>Item 2</div>
|
|
44
|
+
* </nr-flex>
|
|
45
|
+
*
|
|
46
|
+
* <!-- Responsive gap -->
|
|
47
|
+
* <nr-flex .gap=${[16, 24]}>
|
|
48
|
+
* <div>Item 1</div>
|
|
49
|
+
* <div>Item 2</div>
|
|
50
|
+
* </nr-flex>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @slot default - Flex items
|
|
54
|
+
*/
|
|
55
|
+
let NrFlexElement = class NrFlexElement extends NuralyUIBaseMixin(LitElement) {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
/** Flex direction (shorthand: use vertical prop for column) */
|
|
59
|
+
this.direction = "row" /* FlexDirection.Row */;
|
|
60
|
+
/** Shorthand for flex-direction: column */
|
|
61
|
+
this.vertical = false;
|
|
62
|
+
/** Flex wrap behavior */
|
|
63
|
+
this.wrap = "nowrap" /* FlexWrap.NoWrap */;
|
|
64
|
+
/** Justify content alignment */
|
|
65
|
+
this.justify = EMPTY_STRING;
|
|
66
|
+
/** Align items alignment */
|
|
67
|
+
this.align = EMPTY_STRING;
|
|
68
|
+
/** Gap between flex items - can be preset string, number (px), or [horizontal, vertical] */
|
|
69
|
+
this.gap = 0;
|
|
70
|
+
/** Make flex container inline */
|
|
71
|
+
this.inline = false;
|
|
72
|
+
/** Custom flex CSS value (e.g., "1", "auto", "none") */
|
|
73
|
+
this.flex = EMPTY_STRING;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get computed flex direction
|
|
77
|
+
*/
|
|
78
|
+
getFlexDirection() {
|
|
79
|
+
return this.vertical ? "column" /* FlexDirection.Column */ : this.direction;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Convert gap value to CSS value
|
|
83
|
+
*/
|
|
84
|
+
getGapValue(value) {
|
|
85
|
+
if (typeof value === 'number') {
|
|
86
|
+
return `${value}px`;
|
|
87
|
+
}
|
|
88
|
+
if (typeof value === 'string') {
|
|
89
|
+
// Check if it's a preset
|
|
90
|
+
switch (value) {
|
|
91
|
+
case "small" /* FlexGap.Small */:
|
|
92
|
+
return 'var(--nuraly-spacing-2, 8px)';
|
|
93
|
+
case "medium" /* FlexGap.Medium */:
|
|
94
|
+
return 'var(--nuraly-spacing-3, 16px)';
|
|
95
|
+
case "large" /* FlexGap.Large */:
|
|
96
|
+
return 'var(--nuraly-spacing-4, 24px)';
|
|
97
|
+
default:
|
|
98
|
+
return value; // Use as-is (could be CSS variable or custom value)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return '0';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get gap styles for flex container
|
|
105
|
+
*/
|
|
106
|
+
getGapStyles() {
|
|
107
|
+
const styles = {};
|
|
108
|
+
if (Array.isArray(this.gap)) {
|
|
109
|
+
const [horizontal, vertical] = this.gap;
|
|
110
|
+
styles['column-gap'] = this.getGapValue(horizontal);
|
|
111
|
+
styles['row-gap'] = this.getGapValue(vertical);
|
|
112
|
+
}
|
|
113
|
+
else if (this.gap) {
|
|
114
|
+
styles['gap'] = this.getGapValue(this.gap);
|
|
115
|
+
}
|
|
116
|
+
return styles;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get all inline styles for flex container
|
|
120
|
+
*/
|
|
121
|
+
getFlexStyles() {
|
|
122
|
+
const styles = Object.assign({}, this.getGapStyles());
|
|
123
|
+
if (this.flex) {
|
|
124
|
+
styles['flex'] = this.flex;
|
|
125
|
+
}
|
|
126
|
+
return Object.entries(styles)
|
|
127
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
128
|
+
.join('; ');
|
|
129
|
+
}
|
|
130
|
+
render() {
|
|
131
|
+
const flexDirection = this.getFlexDirection();
|
|
132
|
+
const flexStyles = this.getFlexStyles();
|
|
133
|
+
return html `
|
|
134
|
+
<div
|
|
135
|
+
class="nr-flex"
|
|
136
|
+
data-direction="${flexDirection}"
|
|
137
|
+
data-wrap="${this.wrap}"
|
|
138
|
+
data-justify="${this.justify}"
|
|
139
|
+
data-align="${this.align}"
|
|
140
|
+
data-inline="${this.inline}"
|
|
141
|
+
data-theme="${this.currentTheme}"
|
|
142
|
+
style="${flexStyles}"
|
|
143
|
+
>
|
|
144
|
+
<slot></slot>
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
NrFlexElement.styles = styles;
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: String })
|
|
152
|
+
], NrFlexElement.prototype, "direction", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: Boolean })
|
|
155
|
+
], NrFlexElement.prototype, "vertical", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ type: String })
|
|
158
|
+
], NrFlexElement.prototype, "wrap", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
property({ type: String })
|
|
161
|
+
], NrFlexElement.prototype, "justify", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
property({ type: String })
|
|
164
|
+
], NrFlexElement.prototype, "align", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
property({ type: Object })
|
|
167
|
+
], NrFlexElement.prototype, "gap", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
property({ type: Boolean })
|
|
170
|
+
], NrFlexElement.prototype, "inline", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
property({ type: String })
|
|
173
|
+
], NrFlexElement.prototype, "flex", void 0);
|
|
174
|
+
NrFlexElement = __decorate([
|
|
175
|
+
customElement('nr-flex')
|
|
176
|
+
], NrFlexElement);
|
|
177
|
+
export { NrFlexElement };
|
|
178
|
+
//# sourceMappingURL=flex.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flex.component.js","sourceRoot":"","sources":["../../../src/components/flex/flex.component.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { styles } from './flex.style.js';\nimport { NuralyUIBaseMixin } from '../../shared/base-mixin.js';\nimport {\n FlexDirection,\n FlexWrap,\n FlexJustify,\n FlexAlign,\n FlexGap,\n Gap,\n EMPTY_STRING\n} from './flex.types.js';\n\n/**\n * Flex layout component for flexible box layouts\n * \n * @example\n * ```html\n * <!-- Basic flex -->\n * <nr-flex>\n * <div>Item 1</div>\n * <div>Item 2</div>\n * <div>Item 3</div>\n * </nr-flex>\n * \n * <!-- Flex with gap -->\n * <nr-flex gap=\"medium\">\n * <div>Item 1</div>\n * <div>Item 2</div>\n * </nr-flex>\n * \n * <!-- Centered flex -->\n * <nr-flex justify=\"center\" align=\"center\">\n * <div>Centered content</div>\n * </nr-flex>\n * \n * <!-- Column layout with gap -->\n * <nr-flex vertical gap=\"16\">\n * <div>Item 1</div>\n * <div>Item 2</div>\n * </nr-flex>\n * \n * <!-- Responsive gap -->\n * <nr-flex .gap=${[16, 24]}>\n * <div>Item 1</div>\n * <div>Item 2</div>\n * </nr-flex>\n * ```\n * \n * @slot default - Flex items\n */\n@customElement('nr-flex')\nexport class NrFlexElement extends NuralyUIBaseMixin(LitElement) {\n static override styles = styles;\n\n /** Flex direction (shorthand: use vertical prop for column) */\n @property({ type: String })\n direction: FlexDirection = FlexDirection.Row;\n\n /** Shorthand for flex-direction: column */\n @property({ type: Boolean })\n vertical = false;\n\n /** Flex wrap behavior */\n @property({ type: String })\n wrap: FlexWrap = FlexWrap.NoWrap;\n\n /** Justify content alignment */\n @property({ type: String })\n justify: FlexJustify | '' = EMPTY_STRING;\n\n /** Align items alignment */\n @property({ type: String })\n align: FlexAlign | '' = EMPTY_STRING;\n\n /** Gap between flex items - can be preset string, number (px), or [horizontal, vertical] */\n @property({ type: Object })\n gap: Gap = 0;\n\n /** Make flex container inline */\n @property({ type: Boolean })\n inline = false;\n\n /** Custom flex CSS value (e.g., \"1\", \"auto\", \"none\") */\n @property({ type: String })\n flex: string | '' = EMPTY_STRING;\n\n /**\n * Get computed flex direction\n */\n private getFlexDirection(): FlexDirection {\n return this.vertical ? FlexDirection.Column : this.direction;\n }\n\n /**\n * Convert gap value to CSS value\n */\n private getGapValue(value: Gap): string {\n if (typeof value === 'number') {\n return `${value}px`;\n }\n \n if (typeof value === 'string') {\n // Check if it's a preset\n switch (value) {\n case FlexGap.Small:\n return 'var(--nuraly-spacing-2, 8px)';\n case FlexGap.Medium:\n return 'var(--nuraly-spacing-3, 16px)';\n case FlexGap.Large:\n return 'var(--nuraly-spacing-4, 24px)';\n default:\n return value; // Use as-is (could be CSS variable or custom value)\n }\n }\n \n return '0';\n }\n\n /**\n * Get gap styles for flex container\n */\n private getGapStyles(): Record<string, string> {\n const styles: Record<string, string> = {};\n \n if (Array.isArray(this.gap)) {\n const [horizontal, vertical] = this.gap;\n styles['column-gap'] = this.getGapValue(horizontal);\n styles['row-gap'] = this.getGapValue(vertical);\n } else if (this.gap) {\n styles['gap'] = this.getGapValue(this.gap);\n }\n \n return styles;\n }\n\n /**\n * Get all inline styles for flex container\n */\n private getFlexStyles(): string {\n const styles: Record<string, string> = {\n ...this.getGapStyles()\n };\n \n if (this.flex) {\n styles['flex'] = this.flex;\n }\n \n return Object.entries(styles)\n .map(([key, value]) => `${key}: ${value}`)\n .join('; ');\n }\n\n override render() {\n const flexDirection = this.getFlexDirection();\n const flexStyles = this.getFlexStyles();\n\n return html`\n <div\n class=\"nr-flex\"\n data-direction=\"${flexDirection}\"\n data-wrap=\"${this.wrap}\"\n data-justify=\"${this.justify}\"\n data-align=\"${this.align}\"\n data-inline=\"${this.inline}\"\n data-theme=\"${this.currentTheme}\"\n style=\"${flexStyles}\"\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nr-flex': NrFlexElement;\n }\n}\n"]}
|
package/flex.style.d.ts
ADDED
package/flex.style.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Flex component styles
|
|
4
|
+
* Using shared CSS variables from /src/shared/themes/
|
|
5
|
+
*/
|
|
6
|
+
export const styles = css `
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.nr-flex {
|
|
13
|
+
display: flex;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
|
|
16
|
+
/* Theme-aware */
|
|
17
|
+
color: var(--nuraly-color-text);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Inline flex */
|
|
21
|
+
.nr-flex[data-inline="true"] {
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Flex direction */
|
|
26
|
+
.nr-flex[data-direction="row"] {
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.nr-flex[data-direction="row-reverse"] {
|
|
31
|
+
flex-direction: row-reverse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.nr-flex[data-direction="column"] {
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nr-flex[data-direction="column-reverse"] {
|
|
39
|
+
flex-direction: column-reverse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Flex wrap */
|
|
43
|
+
.nr-flex[data-wrap="nowrap"] {
|
|
44
|
+
flex-wrap: nowrap;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nr-flex[data-wrap="wrap"] {
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.nr-flex[data-wrap="wrap-reverse"] {
|
|
52
|
+
flex-wrap: wrap-reverse;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Justify content */
|
|
56
|
+
.nr-flex[data-justify="flex-start"] {
|
|
57
|
+
justify-content: flex-start;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.nr-flex[data-justify="flex-end"] {
|
|
61
|
+
justify-content: flex-end;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.nr-flex[data-justify="center"] {
|
|
65
|
+
justify-content: center;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.nr-flex[data-justify="space-between"] {
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.nr-flex[data-justify="space-around"] {
|
|
73
|
+
justify-content: space-around;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.nr-flex[data-justify="space-evenly"] {
|
|
77
|
+
justify-content: space-evenly;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Align items */
|
|
81
|
+
.nr-flex[data-align="flex-start"] {
|
|
82
|
+
align-items: flex-start;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.nr-flex[data-align="flex-end"] {
|
|
86
|
+
align-items: flex-end;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.nr-flex[data-align="center"] {
|
|
90
|
+
align-items: center;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.nr-flex[data-align="baseline"] {
|
|
94
|
+
align-items: baseline;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.nr-flex[data-align="stretch"] {
|
|
98
|
+
align-items: stretch;
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
//# sourceMappingURL=flex.style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flex.style.js","sourceRoot":"","sources":["../../../src/components/flex/flex.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FxB,CAAC","sourcesContent":["import { css } from 'lit';\n\n/**\n * Flex component styles\n * Using shared CSS variables from /src/shared/themes/\n */\nexport const styles = css`\n :host {\n display: block;\n box-sizing: border-box;\n }\n\n .nr-flex {\n display: flex;\n box-sizing: border-box;\n \n /* Theme-aware */\n color: var(--nuraly-color-text);\n }\n\n /* Inline flex */\n .nr-flex[data-inline=\"true\"] {\n display: inline-flex;\n }\n\n /* Flex direction */\n .nr-flex[data-direction=\"row\"] {\n flex-direction: row;\n }\n\n .nr-flex[data-direction=\"row-reverse\"] {\n flex-direction: row-reverse;\n }\n\n .nr-flex[data-direction=\"column\"] {\n flex-direction: column;\n }\n\n .nr-flex[data-direction=\"column-reverse\"] {\n flex-direction: column-reverse;\n }\n\n /* Flex wrap */\n .nr-flex[data-wrap=\"nowrap\"] {\n flex-wrap: nowrap;\n }\n\n .nr-flex[data-wrap=\"wrap\"] {\n flex-wrap: wrap;\n }\n\n .nr-flex[data-wrap=\"wrap-reverse\"] {\n flex-wrap: wrap-reverse;\n }\n\n /* Justify content */\n .nr-flex[data-justify=\"flex-start\"] {\n justify-content: flex-start;\n }\n\n .nr-flex[data-justify=\"flex-end\"] {\n justify-content: flex-end;\n }\n\n .nr-flex[data-justify=\"center\"] {\n justify-content: center;\n }\n\n .nr-flex[data-justify=\"space-between\"] {\n justify-content: space-between;\n }\n\n .nr-flex[data-justify=\"space-around\"] {\n justify-content: space-around;\n }\n\n .nr-flex[data-justify=\"space-evenly\"] {\n justify-content: space-evenly;\n }\n\n /* Align items */\n .nr-flex[data-align=\"flex-start\"] {\n align-items: flex-start;\n }\n\n .nr-flex[data-align=\"flex-end\"] {\n align-items: flex-end;\n }\n\n .nr-flex[data-align=\"center\"] {\n align-items: center;\n }\n\n .nr-flex[data-align=\"baseline\"] {\n align-items: baseline;\n }\n\n .nr-flex[data-align=\"stretch\"] {\n align-items: stretch;\n }\n`;\n"]}
|
package/flex.types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flex component types and constants
|
|
3
|
+
*/
|
|
4
|
+
export declare const EMPTY_STRING = "";
|
|
5
|
+
/**
|
|
6
|
+
* Flex direction
|
|
7
|
+
*/
|
|
8
|
+
export declare const enum FlexDirection {
|
|
9
|
+
Row = "row",
|
|
10
|
+
RowReverse = "row-reverse",
|
|
11
|
+
Column = "column",
|
|
12
|
+
ColumnReverse = "column-reverse"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Flex wrap behavior
|
|
16
|
+
*/
|
|
17
|
+
export declare const enum FlexWrap {
|
|
18
|
+
NoWrap = "nowrap",
|
|
19
|
+
Wrap = "wrap",
|
|
20
|
+
WrapReverse = "wrap-reverse"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Justify content alignment
|
|
24
|
+
*/
|
|
25
|
+
export declare const enum FlexJustify {
|
|
26
|
+
FlexStart = "flex-start",
|
|
27
|
+
FlexEnd = "flex-end",
|
|
28
|
+
Center = "center",
|
|
29
|
+
SpaceBetween = "space-between",
|
|
30
|
+
SpaceAround = "space-around",
|
|
31
|
+
SpaceEvenly = "space-evenly"
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Align items alignment
|
|
35
|
+
*/
|
|
36
|
+
export declare const enum FlexAlign {
|
|
37
|
+
FlexStart = "flex-start",
|
|
38
|
+
FlexEnd = "flex-end",
|
|
39
|
+
Center = "center",
|
|
40
|
+
Baseline = "baseline",
|
|
41
|
+
Stretch = "stretch"
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gap size presets
|
|
45
|
+
*/
|
|
46
|
+
export declare const enum FlexGap {
|
|
47
|
+
Small = "small",
|
|
48
|
+
Medium = "medium",
|
|
49
|
+
Large = "large"
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Gap configuration - can be string preset, number (px), or array [horizontal, vertical]
|
|
53
|
+
*/
|
|
54
|
+
export declare type Gap = FlexGap | number | string | [number | string, number | string];
|
|
55
|
+
/**
|
|
56
|
+
* Flex item configuration
|
|
57
|
+
*/
|
|
58
|
+
export interface FlexItemConfig {
|
|
59
|
+
flex?: string | number;
|
|
60
|
+
order?: number;
|
|
61
|
+
alignSelf?: FlexAlign | 'auto';
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=flex.types.d.ts.map
|
package/flex.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flex.types.js","sourceRoot":"","sources":["../../../src/components/flex/flex.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC","sourcesContent":["/**\n * Flex component types and constants\n */\n\nexport const EMPTY_STRING = '';\n\n/**\n * Flex direction\n */\nexport const enum FlexDirection {\n Row = 'row',\n RowReverse = 'row-reverse',\n Column = 'column',\n ColumnReverse = 'column-reverse'\n}\n\n/**\n * Flex wrap behavior\n */\nexport const enum FlexWrap {\n NoWrap = 'nowrap',\n Wrap = 'wrap',\n WrapReverse = 'wrap-reverse'\n}\n\n/**\n * Justify content alignment\n */\nexport const enum FlexJustify {\n FlexStart = 'flex-start',\n FlexEnd = 'flex-end',\n Center = 'center',\n SpaceBetween = 'space-between',\n SpaceAround = 'space-around',\n SpaceEvenly = 'space-evenly'\n}\n\n/**\n * Align items alignment\n */\nexport const enum FlexAlign {\n FlexStart = 'flex-start',\n FlexEnd = 'flex-end',\n Center = 'center',\n Baseline = 'baseline',\n Stretch = 'stretch'\n}\n\n/**\n * Gap size presets\n */\nexport const enum FlexGap {\n Small = 'small',\n Medium = 'medium',\n Large = 'large'\n}\n\n/**\n * Gap configuration - can be string preset, number (px), or array [horizontal, vertical]\n */\nexport type Gap = FlexGap | number | string | [number | string, number | string];\n\n/**\n * Flex item configuration\n */\nexport interface FlexItemConfig {\n flex?: string | number;\n order?: number;\n alignSelf?: FlexAlign | 'auto';\n}\n"]}
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/flex/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './flex.component.js';\nexport * from './flex.types.js';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuralyui/flex",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Flex layout component for NuralyUI library",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./bundle": {
|
|
12
|
+
"import": "./bundle.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"*.js",
|
|
17
|
+
"*.d.ts",
|
|
18
|
+
"*.js.map",
|
|
19
|
+
"flex.bundled.js",
|
|
20
|
+
"bundle.js"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/NuralyUI/NuralyUI.git",
|
|
28
|
+
"directory": "src/components/flex"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"flex",
|
|
32
|
+
"flexbox",
|
|
33
|
+
"layout",
|
|
34
|
+
"container",
|
|
35
|
+
"web-components",
|
|
36
|
+
"lit-element",
|
|
37
|
+
"nuralyui",
|
|
38
|
+
"ui-components"
|
|
39
|
+
],
|
|
40
|
+
"author": "Nuraly, Laabidi Aymen",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/NuralyUI/NuralyUI/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/NuralyUI/NuralyUI#readme",
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/react.d.ts
ADDED
package/react.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createComponent } from '@lit-labs/react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { NrFlexElement } from './flex.component.js';
|
|
4
|
+
export const NrFlex = createComponent({
|
|
5
|
+
tagName: 'nr-flex',
|
|
6
|
+
elementClass: NrFlexElement,
|
|
7
|
+
react: React,
|
|
8
|
+
events: {},
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=react.js.map
|
package/react.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/components/flex/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CAAC;IACpC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,aAAa;IAC3B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,EAAE;CACX,CAAC,CAAC","sourcesContent":["import { createComponent } from '@lit-labs/react';\nimport * as React from 'react';\nimport { NrFlexElement } from './flex.component.js';\nexport const NrFlex = createComponent({\n tagName: 'nr-flex',\n elementClass: NrFlexElement,\n react: React,\n events: {},\n});\n"]}
|