@rnaga/wp-next-ui 1.0.10 → 1.0.12

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 +1 @@
1
- {"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../src/Accordion.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,IAAI,YAAY,EACzB,gBAAgB,IAAI,mBAAmB,EACxC,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,SAAS,GAAI,OAAO,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,4CAgBlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAO,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,4CAOjD,CAAC"}
1
+ {"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../src/Accordion.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,IAAI,YAAY,EACzB,gBAAgB,IAAI,mBAAmB,EACxC,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,SAAS,GAAI,OAAO,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,4CAmBlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAO,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,4CAOjD,CAAC"}
package/Accordion.js CHANGED
@@ -5,6 +5,9 @@ export const Accordion = (props) => {
5
5
  return (_jsx(MuiAccordion, { disableGutters: true, elevation: 0, square: true, sx: {
6
6
  backgroundColor: "transparent",
7
7
  my: 0,
8
+ "& .MuiAccordionDetails-root": {
9
+ px: 0.5,
10
+ },
8
11
  ...props.sx,
9
12
  }, ...props, children: props.children }));
10
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DraggableBox.d.ts","sourceRoot":"","sources":["../src/DraggableBox.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO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) => {
264
264
  display: "flex",
265
265
  alignItems: "center",
266
266
  justifyContent: "space-between",
267
+ backgroundColor: "#dedede",
268
+ mb: 1,
267
269
  ...slotSxProps?.header,
268
270
  }, onMouseDown: handleMouseDown, children: [_jsx(Typography, { size: size, sx: {
269
- p: 0.5,
271
+ p: 1,
270
272
  flexGrow: 1,
271
273
  ...slotSxProps?.title,
272
274
  }, bold: true, children: title }), _jsx(IconButton, { size: "small", onClick: (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"InputColor.d.ts","sourceRoot":"","sources":["../src/InputColor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAO,OAAO,EAAE,MAAM,eAAe,CAAC;AAK7C,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,OAUzC,CAAC;AA2IJ,eAAO,MAAM,UAAU,GACrB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG;IAC/C,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,aAAa,CAAC;KACvB,CAAC;CACH,4CA6DF,CAAC"}
1
+ {"version":3,"file":"InputColor.d.ts","sourceRoot":"","sources":["../src/InputColor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA+B,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAO,OAAO,EAAE,MAAM,eAAe,CAAC;AAK7C,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,OAUzC,CAAC;AA2IJ,eAAO,MAAM,UAAU,GACrB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG;IAC/C,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,aAAa,CAAC;KACvB,CAAC;CACH,4CAiEF,CAAC"}
package/InputColor.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef, useState } from "react";
2
+ import { useEffect, useRef, useState } from "react";
3
3
  import { Input } from "./Input";
4
4
  import { Box } from "@mui/material";
5
5
  export const isColorString = (src) => /^#([\da-f]{3}|[\da-f]{6})$/i.test(src) ||
@@ -117,6 +117,9 @@ export const InputColor = (props) => {
117
117
  setValue(value);
118
118
  onBlur(value);
119
119
  };
120
+ useEffect(() => {
121
+ setValue(`${props.value ?? ""}`);
122
+ }, [props.value]);
120
123
  return (_jsxs(Box, { sx: { display: "flex", gap: 1, alignItems: "center", ...sx }, children: [_jsx(Input, { size: size, onChange: (value) => {
121
124
  handleChange(value);
122
125
  }, onBlur: (value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"InputMultiple.d.ts","sourceRoot":"","sources":["../src/InputMultiple.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,OAAO,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAgC,MAAM,OAAO,CAAC;AAMrE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC,eAAO,MAAM,aAAa,GAAI,OAAO;IACnC,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B,QAAQ,EAAE,CACR,MAAM,EAAE,iBAAiB,EAAE,EAC3B,CAAC,EAAE,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,KAC9B,IAAI,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,4CAiGA,CAAC"}
1
+ {"version":3,"file":"InputMultiple.d.ts","sourceRoot":"","sources":["../src/InputMultiple.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,OAAO,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAgC,MAAM,OAAO,CAAC;AAMrE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC,eAAO,MAAM,aAAa,GAAI,OAAO;IACnC,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B,QAAQ,EAAE,CACR,MAAM,EAAE,iBAAiB,EAAE,EAC3B,CAAC,EAAE,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,KAC9B,IAAI,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,4CAuGA,CAAC"}
package/InputMultiple.js CHANGED
@@ -43,7 +43,13 @@ export const InputMultiple = (props) => {
43
43
  size: size ?? "small",
44
44
  sx: {
45
45
  zIndex: 9999,
46
- height: size == "medium" ? 32 : 24,
46
+ minHeight: size == "medium" ? 32 : 24,
47
+ "& .MuiInputBase-input": {
48
+ cursor: "text",
49
+ },
50
+ "& .MuiAutocomplete-input": {
51
+ cursor: "text",
52
+ },
47
53
  ...slotSxProps?.input,
48
54
  },
49
55
  ...sx,
package/ListBase.js CHANGED
@@ -96,7 +96,7 @@ export const ListBase = (props) => {
96
96
  onClick: onClick || itemEventHandlers?.onClick,
97
97
  onMouseDown: onMouseDown || itemEventHandlers?.onMouseDown,
98
98
  };
99
- return (_jsx(ListContext.Provider, { value: {
99
+ return (_jsx(ListContext, { value: {
100
100
  items: listItems,
101
101
  displayType,
102
102
  renderItem: renderItem,
package/Modal.d.ts CHANGED
@@ -6,6 +6,8 @@ export declare const Modal: (props: ModalParameters) => import("react/jsx-runtim
6
6
  export declare const ModalContent: (props: {
7
7
  sx?: SxProps;
8
8
  children: React.ReactNode;
9
- } & Omit<Parameters<typeof Box>[0], "children" | "sx">) => import("react/jsx-runtime").JSX.Element;
9
+ hideCloseButton?: boolean;
10
+ loading?: boolean;
11
+ } & Omit<Parameters<typeof Box>[0], "children" | "sx" | "hideCloseButton" | "loading">) => import("react/jsx-runtime").JSX.Element;
10
12
  export {};
11
13
  //# sourceMappingURL=Modal.d.ts.map
package/Modal.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,GAAG,EAEH,KAAK,IAAI,QAAQ,EACjB,OAAO,EAER,MAAM,eAAe,CAAC;AAIvB,KAAK,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;IACvE,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAQF,eAAO,MAAM,KAAK,GAAI,OAAO,eAAe,4CAkB3C,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,OAAO;IACL,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,4CAkEvD,CAAC"}
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,GAAG,EAGH,KAAK,IAAI,QAAQ,EACjB,OAAO,EAER,MAAM,eAAe,CAAC;AAIvB,KAAK,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;IACvE,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAQF,eAAO,MAAM,KAAK,GAAI,OAAO,eAAe,4CAkB3C,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,OAAO;IACL,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,IAAI,CACN,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,EACzB,UAAU,GAAG,IAAI,GAAG,iBAAiB,GAAG,SAAS,CAClD,4CAiFF,CAAC"}
package/Modal.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useContext, useEffect, useState } from "react";
3
3
  import { Close } from "@mui/icons-material";
4
- import { Box, IconButton, Modal as MuiModal, } from "@mui/material";
4
+ import { Box, CircularProgress, IconButton, Modal as MuiModal, } from "@mui/material";
5
5
  import { useWPTheme } from "./ThemeRegistry";
6
6
  import { useWP } from "@rnaga/wp-next-core/client/wp";
7
7
  const Context = createContext({});
@@ -18,7 +18,7 @@ export const Modal = (props) => {
18
18
  return (_jsx(MuiModal, { open: open, onClose: handleClose, ...rest, children: _jsx(Context, { value: { open, setOpen, onClose }, children: children }) }));
19
19
  };
20
20
  export const ModalContent = (props) => {
21
- const { sx, ...rest } = props;
21
+ const { sx, hideCloseButton, loading, ...rest } = props;
22
22
  const { setOpen, onClose } = useContext(Context);
23
23
  const [isFullscreen, setIsFullscreen] = useState(false);
24
24
  const { wpTheme } = useWPTheme();
@@ -48,7 +48,7 @@ export const ModalContent = (props) => {
48
48
  ...sx,
49
49
  }, ...rest, children: _jsxs(Box, { sx: {
50
50
  position: "relative",
51
- }, children: [_jsx(IconButton, { size: "small", onClick: (e) => {
51
+ }, children: [!hideCloseButton && (_jsx(IconButton, { size: "small", onClick: (e) => {
52
52
  setOpen(false);
53
53
  onClose();
54
54
  }, sx: {
@@ -61,5 +61,10 @@ export const ModalContent = (props) => {
61
61
  ":hover": {
62
62
  bgcolor: wpTheme.background.hoverColor,
63
63
  },
64
- }, children: _jsx(Close, { fontSize: "small" }) }), props.children] }) }));
64
+ }, children: _jsx(Close, { fontSize: "small" }) })), loading ? (_jsx(Box, { sx: {
65
+ display: "flex",
66
+ justifyContent: "center",
67
+ alignItems: "center",
68
+ minHeight: 200,
69
+ }, children: _jsx(CircularProgress, {}) })) : (props.children)] }) }));
65
70
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ModalConfirm.d.ts","sourceRoot":"","sources":["../src/ModalConfirm.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,GAAI,OAAO;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,4CA0GA,CAAC"}
1
+ {"version":3,"file":"ModalConfirm.d.ts","sourceRoot":"","sources":["../src/ModalConfirm.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,GAAI,OAAO;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,4CAwGA,CAAC"}
package/ModalConfirm.js CHANGED
@@ -11,13 +11,11 @@ export const ModalConfirm = (props) => {
11
11
  const { viewport } = useWP();
12
12
  const [open, setOpen] = useState(props.open);
13
13
  useEffect(() => {
14
- console.log("changing open state to", props.open);
15
14
  if (props.open !== open) {
16
15
  setOpen(props.open);
17
16
  }
18
17
  }, [props.open]);
19
18
  return (_jsx(Modal, { open: open, onClose: () => {
20
- console.log("ConfirmModal onClose called, but no action taken");
21
19
  setOpen(false);
22
20
  onClose?.();
23
21
  }, children: _jsxs(ModalContent, { "aria-labelledby": "nested-modal-title", "aria-describedby": "nested-modal-description", sx: {
@@ -0,0 +1,16 @@
1
+ import { SxProps } from "@mui/material";
2
+ import { type SlotSxProps } from "./SelectAutocomplete";
3
+ type Item = {
4
+ label: string;
5
+ value: string | number;
6
+ };
7
+ export declare const SelectFreeSoloAutocomplete: (props: {
8
+ onChange: (value: string, item: Item) => void;
9
+ size?: "small" | "medium";
10
+ slotSxProps?: SlotSxProps;
11
+ items: Item[];
12
+ value?: string;
13
+ sx?: SxProps;
14
+ }) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=SelectFreeSoloAutocomplete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectFreeSoloAutocomplete.d.ts","sourceRoot":"","sources":["../src/SelectFreeSoloAutocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0B,OAAO,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAO5E,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO;IAChD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9C,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,4CAuGA,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Autocomplete, ListItem } from "@mui/material";
3
+ import { useMemo, useState } from "react";
4
+ import { SelectAutocomplete } from "./SelectAutocomplete";
5
+ import { Typography } from "./Typography";
6
+ const sxSelectAutocomplete = SelectAutocomplete.sx;
7
+ const SelectAutocompleteTextField = SelectAutocomplete.TextField;
8
+ const Wrapper = SelectAutocomplete.Wrapper;
9
+ export const SelectFreeSoloAutocomplete = (props) => {
10
+ const { onChange, size, items, value, slotSxProps, sx } = props;
11
+ const [inputValue, setInputValue] = useState("");
12
+ const currentValue = useMemo(() => {
13
+ if (!value) {
14
+ return undefined;
15
+ }
16
+ const item = items.find((item) => item.value == value);
17
+ return item
18
+ ? { label: item.label, id: `${item.value}` }
19
+ : { label: `${value}`, id: `${value}` };
20
+ }, [value, items]);
21
+ return (_jsx(Wrapper, { size: size, slotSxProps: slotSxProps, children: _jsx(Autocomplete, { size: "small", freeSolo: true, value: currentValue ?? { label: "", id: "" }, inputValue: inputValue !== "" ? inputValue : currentValue?.label ?? "", options: items.map((item) => ({
22
+ label: item.label,
23
+ id: `${item.value}`,
24
+ })), onInputChange: (_, newInputValue, reason) => {
25
+ if (reason === "input") {
26
+ setInputValue(newInputValue);
27
+ }
28
+ else {
29
+ setInputValue("");
30
+ }
31
+ }, onChange: (_, newValue, reason) => {
32
+ if (reason === "createOption" && typeof newValue === "string") {
33
+ const item = { label: newValue, value: newValue };
34
+ onChange(newValue, item);
35
+ setInputValue("");
36
+ }
37
+ else if (reason === "selectOption" &&
38
+ typeof newValue === "object" &&
39
+ newValue !== null) {
40
+ const item = {
41
+ label: newValue.label,
42
+ value: newValue.id,
43
+ };
44
+ onChange(newValue.id, item);
45
+ setInputValue("");
46
+ }
47
+ }, getOptionLabel: (option) => {
48
+ if (typeof option === "string") {
49
+ return option;
50
+ }
51
+ return option.label;
52
+ }, renderInput: (params) => (_jsx(SelectAutocompleteTextField, { params: params, size: size, sx: slotSxProps?.textField })), sx: sxSelectAutocomplete({
53
+ size: size ?? "small",
54
+ sx: slotSxProps?.input ?? sx,
55
+ }), renderOption: (props, option, state) => {
56
+ const { key, ...restProps } = props;
57
+ if (state.selected) {
58
+ return null;
59
+ }
60
+ return (_jsx(ListItem, { ...restProps, onClick: (e) => {
61
+ const item = {
62
+ label: option.label,
63
+ value: option.id,
64
+ };
65
+ onChange(option.id, item);
66
+ setInputValue("");
67
+ restProps?.onClick && restProps.onClick(e);
68
+ }, children: _jsx(Typography, { size: size, sx: slotSxProps?.options, children: option.label }) }, key));
69
+ }, disableClearable: true }) }));
70
+ };
package/Textarea.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { TextareaAutosize } from "@mui/material";
2
+ export declare const Textarea: (props: {
3
+ value: string;
4
+ onChange?: (value: string) => void;
5
+ onBlur?: (value: string) => void;
6
+ style?: React.CSSProperties;
7
+ } & Omit<Parameters<typeof TextareaAutosize>[0], "onChange" | "value" | "onBlur">) => import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=Textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../src/Textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAY,MAAM,eAAe,CAAC;AAE3D,eAAO,MAAM,QAAQ,GACnB,OAAO;IACL,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,GAAG,IAAI,CACN,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,EACtC,UAAU,GAAG,OAAO,GAAG,QAAQ,CAChC,4CA0CF,CAAC"}
package/Textarea.js ADDED
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TextareaAutosize, useTheme } from "@mui/material";
3
+ export const Textarea = (props) => {
4
+ const { value, onChange, onBlur, style, ...rest } = props;
5
+ const theme = useTheme();
6
+ const styleBorder = `1px solid ${theme.palette.grey[400]}`;
7
+ const styleBorderFocus = `1px solid ${theme.palette.primary.main}`;
8
+ const handleChange = (value) => {
9
+ onChange && onChange(value);
10
+ };
11
+ const handleBlur = (value) => {
12
+ onBlur && onBlur(value);
13
+ };
14
+ return (_jsx(TextareaAutosize, { minRows: 3, style: {
15
+ border: styleBorder,
16
+ borderRadius: 4,
17
+ outline: "none",
18
+ width: "100%",
19
+ maxWidth: "100%",
20
+ ...style,
21
+ }, value: value, onFocus: (e) => {
22
+ e.target.style.border = styleBorderFocus;
23
+ }, onBlur: (e) => {
24
+ e.target.style.border = styleBorder;
25
+ handleBlur(value);
26
+ }, onChange: (e) => {
27
+ const value = e.target.value;
28
+ handleChange(value);
29
+ }, ...rest }));
30
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnaga/wp-next-ui",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "scripts": {
5
5
  "build": "node ../../scripts/build-ui.mjs",
6
6
  "release-old": "node ../../scripts/release.mjs",