@etsoo/materialui 1.6.4 → 1.6.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.
@@ -27,10 +27,11 @@ it("Render ComboBox", async () => {
27
27
  });
28
28
 
29
29
  await waitFor(async () => {
30
- const button = await screen.findByRole("button");
30
+ const button = document.querySelector("button");
31
+ expect(button).toBeTruthy();
31
32
 
32
33
  // Act, click the list
33
- const clicked = fireEvent.click(button);
34
+ const clicked = fireEvent.click(button!);
34
35
  expect(clicked).toBeTruthy();
35
36
 
36
37
  // Get list item
@@ -20,7 +20,7 @@ function TagList(props) {
20
20
  const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
21
21
  const moreLabel = more + "...";
22
22
  // Destruct
23
- const { renderOption = ({ key, ...props }, option, { selected }) => ((0, jsx_runtime_1.jsxs)("li", { ...props, children: [(0, jsx_runtime_1.jsx)(Checkbox_1.default, { icon: (0, jsx_runtime_1.jsx)(CheckBoxOutlineBlank_1.default, { fontSize: "small" }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_1.default, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), option] }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
23
+ const { getOptionLabel = (option) => option, renderOption = ({ key, ...props }, option, { selected }) => ((0, jsx_runtime_1.jsxs)("li", { ...props, children: [(0, jsx_runtime_1.jsx)(Checkbox_1.default, { icon: (0, jsx_runtime_1.jsx)(CheckBoxOutlineBlank_1.default, { fontSize: "small" }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_1.default, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getOptionLabel(option)] }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
24
24
  const { key, ...rest } = getTagProps({ index });
25
25
  return (0, jsx_runtime_1.jsx)(Chip_1.default, { variant: "outlined", label: option, ...rest }, key);
26
26
  }), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
@@ -20,11 +20,10 @@ function TagListPro(props) {
20
20
  // Labels
21
21
  const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
22
22
  const moreLabel = more + "...";
23
- const getLabel = (item) => shared_1.DataTypes.getListItemLabel(item);
24
23
  // Destruct
25
- const { getOptionKey = (option) => typeof option === "string" ? option : option.id, renderOption = ({ key, ...props }, option, { selected }) => ((0, jsx_runtime_1.jsx)("li", { ...props, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Checkbox_1.default, { icon: (0, jsx_runtime_1.jsx)(CheckBoxOutlineBlank_1.default, { fontSize: "small" }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_1.default, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getLabel(option)] }) }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
24
+ const { getOptionKey = (option) => typeof option === "string" ? option : option.id, getOptionLabel = (option) => shared_1.DataTypes.getListItemLabel(option), renderOption = ({ key, ...props }, option, { selected }) => ((0, jsx_runtime_1.jsx)("li", { ...props, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Checkbox_1.default, { icon: (0, jsx_runtime_1.jsx)(CheckBoxOutlineBlank_1.default, { fontSize: "small" }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_1.default, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getOptionLabel(option)] }) }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
26
25
  const { key, ...rest } = getTagProps({ index });
27
- return ((0, jsx_runtime_1.jsx)(Chip_1.default, { variant: "outlined", label: getLabel(option), ...rest }, key));
26
+ return ((0, jsx_runtime_1.jsx)(Chip_1.default, { variant: "outlined", label: getOptionLabel(option), ...rest }, key));
28
27
  }), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, loadIdValue, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
29
28
  const [open, setOpen] = react_1.default.useState(false);
30
29
  const [options, setOptions] = react_1.default.useState([]);
@@ -75,8 +74,9 @@ function TagListPro(props) {
75
74
  }, ...inputProps, ...params })), getOptionDisabled: (item) => {
76
75
  return (typeof item.id === "number" &&
77
76
  item.id < 0 &&
78
- getLabel(item) === moreLabel);
79
- }, getOptionLabel: (item) => getLabel(item), getOptionKey: getOptionKey, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
77
+ "name" in item &&
78
+ item["name"] === moreLabel);
79
+ }, getOptionKey: getOptionKey, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
80
80
  currentValue.current = value;
81
81
  if (onChange)
82
82
  onChange(event, value, reason, details);
@@ -14,7 +14,7 @@ export function TagList(props) {
14
14
  const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
15
15
  const moreLabel = more + "...";
16
16
  // Destruct
17
- const { renderOption = ({ key, ...props }, option, { selected }) => (_jsxs("li", { ...props, children: [_jsx(Checkbox, { icon: _jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" }), checkedIcon: _jsx(CheckBoxIcon, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), option] }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
17
+ const { getOptionLabel = (option) => option, renderOption = ({ key, ...props }, option, { selected }) => (_jsxs("li", { ...props, children: [_jsx(Checkbox, { icon: _jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" }), checkedIcon: _jsx(CheckBoxIcon, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getOptionLabel(option)] }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
18
18
  const { key, ...rest } = getTagProps({ index });
19
19
  return _jsx(Chip, { variant: "outlined", label: option, ...rest }, key);
20
20
  }), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
@@ -14,11 +14,10 @@ export function TagListPro(props) {
14
14
  // Labels
15
15
  const { noOptions, loading: loadingLabel, more = "More", open: openDefault } = app?.getLabels("noOptions", "loading", "more", "open") ?? {};
16
16
  const moreLabel = more + "...";
17
- const getLabel = (item) => DataTypes.getListItemLabel(item);
18
17
  // Destruct
19
- const { getOptionKey = (option) => typeof option === "string" ? option : option.id, renderOption = ({ key, ...props }, option, { selected }) => (_jsx("li", { ...props, children: _jsxs(_Fragment, { children: [_jsx(Checkbox, { icon: _jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" }), checkedIcon: _jsx(CheckBoxIcon, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getLabel(option)] }) }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
18
+ const { getOptionKey = (option) => typeof option === "string" ? option : option.id, getOptionLabel = (option) => DataTypes.getListItemLabel(option), renderOption = ({ key, ...props }, option, { selected }) => (_jsx("li", { ...props, children: _jsxs(_Fragment, { children: [_jsx(Checkbox, { icon: _jsx(CheckBoxOutlineBlankIcon, { fontSize: "small" }), checkedIcon: _jsx(CheckBoxIcon, { fontSize: "small" }), style: { marginRight: 8 }, checked: selected }), getOptionLabel(option)] }) }, key)), renderValue = (value, getTagProps) => value.map((option, index) => {
20
19
  const { key, ...rest } = getTagProps({ index });
21
- return (_jsx(Chip, { variant: "outlined", label: getLabel(option), ...rest }, key));
20
+ return (_jsx(Chip, { variant: "outlined", label: getOptionLabel(option), ...rest }, key));
22
21
  }), noOptionsText = noOptions, loadingText = loadingLabel, openText = openDefault, loadData, loadIdValue, maxItems = 16, disableCloseOnSelect = true, openOnFocus = true, label, inputProps, onChange, value, ...rest } = props;
23
22
  const [open, setOpen] = React.useState(false);
24
23
  const [options, setOptions] = React.useState([]);
@@ -69,8 +68,9 @@ export function TagListPro(props) {
69
68
  }, ...inputProps, ...params })), getOptionDisabled: (item) => {
70
69
  return (typeof item.id === "number" &&
71
70
  item.id < 0 &&
72
- getLabel(item) === moreLabel);
73
- }, getOptionLabel: (item) => getLabel(item), getOptionKey: getOptionKey, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
71
+ "name" in item &&
72
+ item["name"] === moreLabel);
73
+ }, getOptionKey: getOptionKey, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, value: valueState, onChange: (event, value, reason, details) => {
74
74
  currentValue.current = value;
75
75
  if (onChange)
76
76
  onChange(event, value, reason, details);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
package/src/TagList.tsx CHANGED
@@ -51,6 +51,7 @@ export function TagList(props: TagListProps) {
51
51
 
52
52
  // Destruct
53
53
  const {
54
+ getOptionLabel = (option) => option,
54
55
  renderOption = ({ key, ...props }, option, { selected }) => (
55
56
  <li key={key} {...props}>
56
57
  <Checkbox
@@ -59,7 +60,7 @@ export function TagList(props: TagListProps) {
59
60
  style={{ marginRight: 8 }}
60
61
  checked={selected}
61
62
  />
62
- {option}
63
+ {getOptionLabel(option)}
63
64
  </li>
64
65
  ),
65
66
  renderValue = (value: readonly string[], getTagProps) =>
@@ -57,12 +57,11 @@ export function TagListPro<D extends ListType2 = ListType2>(
57
57
 
58
58
  const moreLabel = more + "...";
59
59
 
60
- const getLabel = (item: D) => DataTypes.getListItemLabel(item);
61
-
62
60
  // Destruct
63
61
  const {
64
62
  getOptionKey = (option) =>
65
63
  typeof option === "string" ? option : option.id,
64
+ getOptionLabel = (option) => DataTypes.getListItemLabel(option),
66
65
  renderOption = ({ key, ...props }, option, { selected }) => (
67
66
  <li key={key} {...props}>
68
67
  <>
@@ -72,7 +71,7 @@ export function TagListPro<D extends ListType2 = ListType2>(
72
71
  style={{ marginRight: 8 }}
73
72
  checked={selected}
74
73
  />
75
- {getLabel(option)}
74
+ {getOptionLabel(option)}
76
75
  </>
77
76
  </li>
78
77
  ),
@@ -83,7 +82,7 @@ export function TagListPro<D extends ListType2 = ListType2>(
83
82
  <Chip
84
83
  variant="outlined"
85
84
  key={key}
86
- label={getLabel(option)}
85
+ label={getOptionLabel(option)}
87
86
  {...rest}
88
87
  />
89
88
  );
@@ -179,11 +178,12 @@ export function TagListPro<D extends ListType2 = ListType2>(
179
178
  return (
180
179
  typeof item.id === "number" &&
181
180
  item.id < 0 &&
182
- getLabel(item) === moreLabel
181
+ "name" in item &&
182
+ item["name"] === moreLabel
183
183
  );
184
184
  }}
185
- getOptionLabel={(item) => getLabel(item)}
186
185
  getOptionKey={getOptionKey}
186
+ getOptionLabel={getOptionLabel}
187
187
  isOptionEqualToValue={(option, value) => option.id === value.id}
188
188
  noOptionsText={noOptionsText}
189
189
  loadingText={loadingText}