@soyfri/shared-library 1.0.5 → 1.0.6

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.cjs"),t=require("../../_virtual/jsx-runtime.cjs"),r=require("@mui/material");const a=a=>{var{value:i,onChange:n,type:s="text",variant:u="outlined",min:o,max:l,inputProps:p}=a,v=e.__rest(a,["value","onChange","type","variant","min","max","inputProps"]);const m=Object.assign({},p);return"number"===s&&(m.min=void 0!==o?o:Number.NEGATIVE_INFINITY,void 0!==l&&(m.max=l)),t.jsxRuntimeExports.jsx(r.TextField,Object.assign({value:i,onChange:e=>{const t=e.target.value;let r;if("number"===s)if(""===t||"-"===t)r=t;else{const e=parseFloat(t);r=isNaN(e)?t:e}else r=t;n(r)},type:s,variant:u,inputProps:m},v))};exports.Input=a,exports.default=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.cjs"),t=require("../../_virtual/jsx-runtime.cjs"),r=require("@mui/material");const i=i=>{var{value:a,onChange:n,type:s="text",variant:u="outlined",min:o,max:l,inputProps:p}=i,v=e.__rest(i,["value","onChange","type","variant","min","max","inputProps"]);const m=Object.assign({},p);return"number"===s&&(m.min=void 0!==o?o:Number.NEGATIVE_INFINITY,void 0!==l&&(m.max=l)),t.jsxRuntimeExports.jsx(r.TextField,Object.assign({fullWidth:!0,value:a,onChange:e=>{const t=e.target.value;let r;if("number"===s)if(""===t||"-"===t)r=t;else{const e=parseFloat(t);r=isNaN(e)?t:e}else r=t;n(r)},type:s,variant:u,inputProps:m},v))};exports.Input=i,exports.default=i;
2
2
  //# sourceMappingURL=Input.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/jsx-runtime.cjs"),t=require("react"),r=require("@mui/material"),l=require("../../node_modules/@mui/icons-material/esm/Clear.cjs");function s({label:s,options:i,value:a,defaultValue:n,onChange:o,size:u="medium",multiple:p=!1,filterable:x=!1,placeholder:d,children:c,maxHeight:m=300,maxWidth:h,maxChipsToShow:j=3,renderChipLabel:f}){const b=t.useMemo((()=>{var e;if(1===t.Children.count(c)){const r=t.Children.only(c);if(t.isValidElement(r)&&"Option"===(null===(e=r.type)||void 0===e?void 0:e.displayName))return r.props.children}return null}),[c]),[v,g]=t.useState(""),E=t.useMemo((()=>x&&v?i.filter((e=>e.label.toLowerCase().includes(v.toLowerCase()))):i),[v,x,i]),y=t.useMemo((()=>{const e={};return E.forEach((t=>{const r=t.group||"__default";e[r]||(e[r]=[]),e[r].push(t)})),e}),[E]),C=t.useMemo((()=>{const t=[];return x&&t.push(e.jsxRuntimeExports.jsx(r.ListSubheader,{sx:{px:2,pt:1,pb:1,backgroundColor:"background.paper",zIndex:1,position:"sticky",top:0},children:e.jsxRuntimeExports.jsx(r.TextField,{placeholder:"Buscar...",variant:"standard",size:"small",fullWidth:!0,value:v,onChange:e=>g(e.target.value),inputProps:{autoFocus:!0},onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation()})},"search-header")),Object.entries(y).forEach((([l,s])=>{"__default"!==l&&t.push(e.jsxRuntimeExports.jsx(r.ListSubheader,{disableSticky:!0,children:l},l)),s.forEach((l=>{t.push(e.jsxRuntimeExports.jsx(r.MenuItem,{value:l.value,disabled:l.disabled,children:b?b(l):l.label},l.value))}))})),t}),[y,b,x,v]);return e.jsxRuntimeExports.jsxs(r.FormControl,{fullWidth:!0,size:u,children:[s&&e.jsxRuntimeExports.jsx(r.InputLabel,{children:s}),e.jsxRuntimeExports.jsx(r.Select,{label:s,value:null!=a?a:p?[]:"",defaultValue:n,multiple:p,onChange:e=>{o(e.target.value)},renderValue:t=>{var s;if(!t||Array.isArray(t)&&0===t.length)return e.jsxRuntimeExports.jsx(r.Typography,{sx:{color:"text.disabled"},children:d||""});if(!p){const e=i.find((e=>e.value===t));return f&&e?f(e):null!==(s=null==e?void 0:e.label)&&void 0!==s?s:String(t)}const n=t,u=n.slice(0,j),x=n.length-j;return e.jsxRuntimeExports.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:[u.map((t=>{const s=i.find((e=>e.value===t));if(!s)return null;return e.jsxRuntimeExports.jsx(r.Chip,{label:f?f(s):s.label,avatar:s.img?e.jsxRuntimeExports.jsx(r.Avatar,{src:s.img}):void 0,onDelete:()=>(e=>{const t=a.filter((t=>t!==e));o(t)})(t),deleteIcon:e.jsxRuntimeExports.jsx(l,{})},t)})),x>0&&e.jsxRuntimeExports.jsx(r.Chip,{label:`+${x} más`,size:"small"})]})},displayEmpty:!0,input:e.jsxRuntimeExports.jsx(r.OutlinedInput,{label:s}),MenuProps:{PaperProps:{style:{maxHeight:m,maxWidth:h}}},children:C})]})}exports.Select=s,exports.default=s;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/jsx-runtime.cjs"),t=require("react"),r=require("@mui/material"),l=require("../../node_modules/@mui/icons-material/esm/Clear.cjs");function s(e){return null}function i({label:s,options:i,value:a,defaultValue:n,onChange:o,size:u="medium",multiple:p=!1,filterable:d=!1,placeholder:x,children:c,maxHeight:m=300,maxWidth:h,maxChipsToShow:j=3,renderChipLabel:f,chipVariant:v="outlined"}){const b=t.useMemo((()=>{var e;if(1===t.Children.count(c)){const r=t.Children.only(c);if(t.isValidElement(r)&&"Option"===(null===(e=r.type)||void 0===e?void 0:e.displayName))return r.props.children}return null}),[c]),[g,E]=t.useState(""),y=t.useMemo((()=>d&&g?i.filter((e=>e.label.toLowerCase().includes(g.toLowerCase()))):i),[g,d,i]),C=t.useMemo((()=>{const e={};return y.forEach((t=>{const r=t.group||"__default";e[r]||(e[r]=[]),e[r].push(t)})),e}),[y]),R=t.useMemo((()=>{const t=[];return d&&t.push(e.jsxRuntimeExports.jsx(r.ListSubheader,{sx:{px:2,pt:1,pb:1,backgroundColor:"background.paper",zIndex:1,position:"sticky",top:0},children:e.jsxRuntimeExports.jsx(r.TextField,{placeholder:"Buscar...",variant:"standard",size:"small",fullWidth:!0,value:g,onChange:e=>E(e.target.value),inputProps:{autoFocus:!0},onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation()})},"search-header")),Object.entries(C).forEach((([l,s])=>{"__default"!==l&&t.push(e.jsxRuntimeExports.jsx(r.ListSubheader,{disableSticky:!0,children:l},l)),s.forEach((l=>{t.push(e.jsxRuntimeExports.jsx(r.MenuItem,{value:l.value,disabled:l.disabled,children:b?b(l):l.label},l.value))}))})),t}),[C,b,d,g]);return e.jsxRuntimeExports.jsxs(r.FormControl,{fullWidth:!0,size:u,children:[s&&e.jsxRuntimeExports.jsx(r.InputLabel,{children:s}),e.jsxRuntimeExports.jsx(r.Select,{label:s,value:null!=a?a:p?[]:"",defaultValue:n,multiple:p,onChange:e=>{o(e.target.value)},renderValue:t=>{var s;if(!t||Array.isArray(t)&&0===t.length)return e.jsxRuntimeExports.jsx(r.Typography,{sx:{color:"text.disabled"},children:x||""});if(!p){const e=i.find((e=>e.value===t));return f&&e?f(e):null!==(s=null==e?void 0:e.label)&&void 0!==s?s:String(t)}const n=t,u=n.slice(0,j),d=n.length-j;return e.jsxRuntimeExports.jsxs(r.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:[u.map((t=>{const s=i.find((e=>e.value===t));if(!s)return null;return e.jsxRuntimeExports.jsx(r.Chip,{variant:v,color:"primary",label:f?f(s):s.label,avatar:s.img?e.jsxRuntimeExports.jsx(r.Avatar,{src:s.img}):void 0,onDelete:()=>(e=>{const t=a.filter((t=>t!==e));o(t)})(t),deleteIcon:e.jsxRuntimeExports.jsx(l,{})},t)})),d>0&&e.jsxRuntimeExports.jsx(r.Chip,{label:`+${d} más`,variant:v})]})},displayEmpty:!0,input:e.jsxRuntimeExports.jsx(r.OutlinedInput,{label:s}),MenuProps:{PaperProps:{style:{maxHeight:m,maxWidth:h}}},children:R})]})}s.displayName="Option",exports.Option=s,exports.Select=i,exports.default=i;
2
2
  //# sourceMappingURL=Select.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("./Select/Select.cjs");exports.Select=e.Select;
1
+ "use strict";var e=require("./Select/Select.cjs");exports.Option=e.Option,exports.Select=e.Select;
2
2
  //# sourceMappingURL=Select.cjs.map
@@ -1,2 +1,2 @@
1
- import{__rest as t}from"../../_virtual/_tslib.js";import{j as a}from"../../_virtual/jsx-runtime.js";import{TextField as e}from"@mui/material";const i=i=>{var{value:n,onChange:r,type:s="text",variant:o="outlined",min:m,max:u,inputProps:l}=i,p=t(i,["value","onChange","type","variant","min","max","inputProps"]);const v=Object.assign({},l);return"number"===s&&(v.min=void 0!==m?m:Number.NEGATIVE_INFINITY,void 0!==u&&(v.max=u)),a.jsx(e,Object.assign({value:n,onChange:t=>{const a=t.target.value;let e;if("number"===s)if(""===a||"-"===a)e=a;else{const t=parseFloat(a);e=isNaN(t)?a:t}else e=a;r(e)},type:s,variant:o,inputProps:v},p))};export{i as Input,i as default};
1
+ import{__rest as t}from"../../_virtual/_tslib.js";import{j as a}from"../../_virtual/jsx-runtime.js";import{TextField as e}from"@mui/material";const i=i=>{var{value:n,onChange:r,type:s="text",variant:o="outlined",min:m,max:u,inputProps:l}=i,p=t(i,["value","onChange","type","variant","min","max","inputProps"]);const v=Object.assign({},l);return"number"===s&&(v.min=void 0!==m?m:Number.NEGATIVE_INFINITY,void 0!==u&&(v.max=u)),a.jsx(e,Object.assign({fullWidth:!0,value:n,onChange:t=>{const a=t.target.value;let e;if("number"===s)if(""===a||"-"===a)e=a;else{const t=parseFloat(a);e=isNaN(t)?a:t}else e=a;r(e)},type:s,variant:o,inputProps:v},p))};export{i as Input,i as default};
2
2
  //# sourceMappingURL=Input.js.map
@@ -26,6 +26,7 @@ export interface SelectProps<TValue extends SelectOption['value'] = SelectOption
26
26
  maxWidth?: number | string;
27
27
  maxChipsToShow?: number;
28
28
  renderChipLabel?: RenderChipLabel;
29
+ chipVariant?: 'outlined' | 'filled';
29
30
  }
30
31
  export interface OptionProps {
31
32
  children: RenderOptionItem;
@@ -35,5 +36,5 @@ export declare namespace Option {
35
36
  var displayName: string;
36
37
  }
37
38
  export declare function Select<TValue extends SelectOption['value'] = SelectOption['value']>({ label, options, value, defaultValue, onChange, size, multiple, filterable, placeholder, children, maxHeight, maxWidth, maxChipsToShow, // Valor por defecto: mostrar 3 chips
38
- renderChipLabel, }: SelectProps<TValue>): import("react/jsx-runtime").JSX.Element;
39
+ renderChipLabel, chipVariant, }: SelectProps<TValue>): import("react/jsx-runtime").JSX.Element;
39
40
  export default Select;
@@ -1,2 +1,2 @@
1
- import{j as e}from"../../_virtual/jsx-runtime.js";import l,{useMemo as a,isValidElement as r,useState as t}from"react";import{ListSubheader as i,TextField as n,MenuItem as s,FormControl as o,InputLabel as u,Select as d,OutlinedInput as p,Typography as c,Box as h,Chip as m,Avatar as x}from"@mui/material";import f from"../../node_modules/@mui/icons-material/esm/Clear.js";function v({label:v,options:b,value:j,defaultValue:g,onChange:y,size:C="medium",multiple:P=!1,filterable:_=!1,placeholder:k,children:w,maxHeight:z=300,maxWidth:W,maxChipsToShow:E=3,renderChipLabel:S}){const L=a((()=>{var e;if(1===l.Children.count(w)){const a=l.Children.only(w);if(r(a)&&"Option"===(null===(e=a.type)||void 0===e?void 0:e.displayName))return a.props.children}return null}),[w]),[V,A]=t(""),D=a((()=>_&&V?b.filter((e=>e.label.toLowerCase().includes(V.toLowerCase()))):b),[V,_,b]),H=a((()=>{const e={};return D.forEach((l=>{const a=l.group||"__default";e[a]||(e[a]=[]),e[a].push(l)})),e}),[D]),I=a((()=>{const l=[];return _&&l.push(e.jsx(i,{sx:{px:2,pt:1,pb:1,backgroundColor:"background.paper",zIndex:1,position:"sticky",top:0},children:e.jsx(n,{placeholder:"Buscar...",variant:"standard",size:"small",fullWidth:!0,value:V,onChange:e=>A(e.target.value),inputProps:{autoFocus:!0},onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation()})},"search-header")),Object.entries(H).forEach((([a,r])=>{"__default"!==a&&l.push(e.jsx(i,{disableSticky:!0,children:a},a)),r.forEach((a=>{l.push(e.jsx(s,{value:a.value,disabled:a.disabled,children:L?L(a):a.label},a.value))}))})),l}),[H,L,_,V]);return e.jsxs(o,{fullWidth:!0,size:C,children:[v&&e.jsx(u,{children:v}),e.jsx(d,{label:v,value:null!=j?j:P?[]:"",defaultValue:g,multiple:P,onChange:e=>{y(e.target.value)},renderValue:l=>{var a;if(!l||Array.isArray(l)&&0===l.length)return e.jsx(c,{sx:{color:"text.disabled"},children:k||""});if(!P){const e=b.find((e=>e.value===l));return S&&e?S(e):null!==(a=null==e?void 0:e.label)&&void 0!==a?a:String(l)}const r=l,t=r.slice(0,E),i=r.length-E;return e.jsxs(h,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:[t.map((l=>{const a=b.find((e=>e.value===l));if(!a)return null;return e.jsx(m,{label:S?S(a):a.label,avatar:a.img?e.jsx(x,{src:a.img}):void 0,onDelete:()=>(e=>{const l=j.filter((l=>l!==e));y(l)})(l),deleteIcon:e.jsx(f,{})},l)})),i>0&&e.jsx(m,{label:`+${i} más`,size:"small"})]})},displayEmpty:!0,input:e.jsx(p,{label:v}),MenuProps:{PaperProps:{style:{maxHeight:z,maxWidth:W}}},children:I})]})}export{v as Select,v as default};
1
+ import{j as e}from"../../_virtual/jsx-runtime.js";import l,{useMemo as a,isValidElement as r,useState as t}from"react";import{ListSubheader as i,TextField as n,MenuItem as o,FormControl as s,InputLabel as u,Select as d,OutlinedInput as p,Typography as c,Box as h,Chip as m,Avatar as x}from"@mui/material";import f from"../../node_modules/@mui/icons-material/esm/Clear.js";function v(e){return null}function b({label:v,options:b,value:j,defaultValue:g,onChange:y,size:C="medium",multiple:P=!1,filterable:_=!1,placeholder:k,children:w,maxHeight:W=300,maxWidth:z,maxChipsToShow:E=3,renderChipLabel:S,chipVariant:V="outlined"}){const L=a((()=>{var e;if(1===l.Children.count(w)){const a=l.Children.only(w);if(r(a)&&"Option"===(null===(e=a.type)||void 0===e?void 0:e.displayName))return a.props.children}return null}),[w]),[O,A]=t(""),D=a((()=>_&&O?b.filter((e=>e.label.toLowerCase().includes(O.toLowerCase()))):b),[O,_,b]),H=a((()=>{const e={};return D.forEach((l=>{const a=l.group||"__default";e[a]||(e[a]=[]),e[a].push(l)})),e}),[D]),I=a((()=>{const l=[];return _&&l.push(e.jsx(i,{sx:{px:2,pt:1,pb:1,backgroundColor:"background.paper",zIndex:1,position:"sticky",top:0},children:e.jsx(n,{placeholder:"Buscar...",variant:"standard",size:"small",fullWidth:!0,value:O,onChange:e=>A(e.target.value),inputProps:{autoFocus:!0},onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation()})},"search-header")),Object.entries(H).forEach((([a,r])=>{"__default"!==a&&l.push(e.jsx(i,{disableSticky:!0,children:a},a)),r.forEach((a=>{l.push(e.jsx(o,{value:a.value,disabled:a.disabled,children:L?L(a):a.label},a.value))}))})),l}),[H,L,_,O]);return e.jsxs(s,{fullWidth:!0,size:C,children:[v&&e.jsx(u,{children:v}),e.jsx(d,{label:v,value:null!=j?j:P?[]:"",defaultValue:g,multiple:P,onChange:e=>{y(e.target.value)},renderValue:l=>{var a;if(!l||Array.isArray(l)&&0===l.length)return e.jsx(c,{sx:{color:"text.disabled"},children:k||""});if(!P){const e=b.find((e=>e.value===l));return S&&e?S(e):null!==(a=null==e?void 0:e.label)&&void 0!==a?a:String(l)}const r=l,t=r.slice(0,E),i=r.length-E;return e.jsxs(h,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:[t.map((l=>{const a=b.find((e=>e.value===l));if(!a)return null;return e.jsx(m,{variant:V,color:"primary",label:S?S(a):a.label,avatar:a.img?e.jsx(x,{src:a.img}):void 0,onDelete:()=>(e=>{const l=j.filter((l=>l!==e));y(l)})(l),deleteIcon:e.jsx(f,{})},l)})),i>0&&e.jsx(m,{label:`+${i} más`,variant:V})]})},displayEmpty:!0,input:e.jsx(p,{label:v}),MenuProps:{PaperProps:{style:{maxHeight:W,maxWidth:z}}},children:I})]})}v.displayName="Option";export{v as Option,b as Select,b as default};
2
2
  //# sourceMappingURL=Select.js.map
@@ -1 +1 @@
1
- export { default as Select } from './Select';
1
+ export { default as Select, Option } from './Select';
@@ -1,2 +1,2 @@
1
- export{Select}from"./Select/Select.js";
1
+ export{Option,Select}from"./Select/Select.js";
2
2
  //# sourceMappingURL=Select.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyfri/shared-library",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",