@foodpilot/foods 2.11.47 → 2.11.48

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,9 +1,20 @@
1
- import { StyledComponent } from '@emotion/styled';
2
- import { MUIStyledCommonProps } from '@mui/system';
3
- import { Theme } from '@mui/material';
1
+ import { FocusEvent } from 'react';
2
+ type Variant = "primary" | "secondary" | "tertiary" | "disabled";
4
3
  export type TextareaProps = {
5
- content: string;
6
- variant?: "primary" | "secondary" | "tertiary" | "disabled";
4
+ value?: string;
5
+ onChange?: (newValue: string) => void;
6
+ onBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;
7
+ onFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;
8
+ placeholder?: string;
9
+ variant?: Variant;
7
10
  disabled?: boolean;
11
+ error?: boolean;
12
+ errorMessage?: string;
13
+ maxLength?: number;
14
+ minRows?: number;
15
+ maxRows?: number;
16
+ /** @deprecated Use `value` (controlled) instead. Kept for backward compatibility. */
17
+ content?: string;
8
18
  };
9
- export declare const Textarea: StyledComponent<TextareaProps & MUIStyledCommonProps<Theme>, {}, {}>;
19
+ export declare const Textarea: (props: TextareaProps) => import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -1,2 +1,7 @@
1
- import{jsx as o}from"react/jsx-runtime";import{styled as r,useTheme as e,TextareaAutosize as a}from"@mui/material";import{greyTheme as t}from"../../themes/common/colors.js";const i=r(r=>{const a=e(),{variant:t="primary",content:i,disabled:d}=r;let m;switch(t){case"primary":default:m=l;break;case"secondary":m=s;break;case"tertiary":m=c;break;case"disabled":m=n}/* @__PURE__ */
2
- return o(m,{defaultValue:i,disabled:d,maxRows:14,theme:a,...r})})({}),d=r(a)(({theme:o})=>({width:"100%",lineHeight:"22px",padding:"20px 24px 60px 24px",borderRadius:"12px",resize:"none",...o.typography.body,color:t[2800],borderColor:t[500],"&:focus-visible":{outline:"0"}})),l=r(d)({backgroundColor:t[100]}),s=r(d)({backgroundColor:t[300]}),c=r(d)({borderColor:t[2800],backgroundColor:t[100]}),n=r(d)({color:t[2e3],backgroundColor:t[500]});export{i as Textarea};
1
+ import{jsxs as r,jsx as o}from"react/jsx-runtime";import{useTheme as e,Stack as a,Typography as n,styled as l,TextareaAutosize as i}from"@mui/material";import{redTheme as t,greyTheme as s}from"../../themes/common/colors.js";const d=l=>{const i=e(),{value:d,onChange:u,onBlur:h,onFocus:p,placeholder:m,variant:g="primary",disabled:b=!1,error:x=!1,errorMessage:v,maxLength:C,minRows:w,maxRows:f=14,content:y}=l,E=void 0!==d,$=E?d.length:0,k=void 0!==C&&$>C,R=x||k,j=void 0!==C||void 0!==v,F=E?{value:d,onChange:r=>u?.(r.currentTarget.value)}:{defaultValue:y};/* @__PURE__ */
2
+ return r(a,{gap:i.spacing(.5),width:"100%",children:[c(g,b,{...F,onBlur:h,onFocus:p,placeholder:m,disabled:b,minRows:w,maxRows:f,maxLength:C,$hasError:R}),j&&/* @__PURE__ */r(a,{flexDirection:"row",justifyContent:"space-between",gap:i.spacing(1),px:i.spacing(2.5),children:[
3
+ /* @__PURE__ */o(n,{variant:"small-regular",color:R?t[600]:"transparent",sx:{minHeight:"1em"},children:R&&v?v:" "}),void 0!==C&&/* @__PURE__ */r(n,{variant:"small-regular",color:k?t[600]:s[1500],children:[$," / ",C]})]})]})},c=(r,e,a)=>{if(e)/* @__PURE__ */return o(g,{...a});switch(r){case"secondary":/* @__PURE__ */
4
+ return o(p,{...a});case"tertiary":/* @__PURE__ */
5
+ return o(m,{...a});case"disabled":/* @__PURE__ */
6
+ return o(g,{...a});default:/* @__PURE__ */
7
+ return o(h,{...a})}},u=l(i,{shouldForwardProp:r=>"$hasError"!==r})(({theme:r,$hasError:o})=>({width:"100%",lineHeight:"22px",padding:"20px 24px 60px 24px",borderRadius:"12px",resize:"none",...r.typography.body,color:s[2800],borderColor:o?t[600]:s[500],"&:focus-visible":{outline:"0",borderColor:o?t[600]:s[2800]},...o&&{backgroundColor:t[100],color:t[600]}})),h=l(u)(({$hasError:r})=>({backgroundColor:r?t[100]:s[100]})),p=l(u)(({$hasError:r})=>({backgroundColor:r?t[100]:s[300]})),m=l(u)(({$hasError:r})=>({borderColor:r?t[600]:s[2800],backgroundColor:r?t[100]:s[100]})),g=l(u)({color:s[2e3],backgroundColor:s[500]});export{d as Textarea};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foodpilot/foods",
3
3
  "private": false,
4
- "version": "2.11.47",
4
+ "version": "2.11.48",
5
5
  "type": "module",
6
6
  "main": "./dist/main.js",
7
7
  "module": "./dist/main.js",