@rnaga/wp-next-ui 1.0.10 → 1.0.11

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":"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) => {
package/InputMultiple.js CHANGED
@@ -43,7 +43,7 @@ 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
47
  ...slotSxProps?.input,
48
48
  },
49
49
  ...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/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.11",
4
4
  "scripts": {
5
5
  "build": "node ../../scripts/build-ui.mjs",
6
6
  "release-old": "node ../../scripts/release.mjs",