umwd-components 0.1.770 → 0.1.771

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.
@@ -4,19 +4,42 @@
4
4
  * @license MIT
5
5
  */
6
6
 
7
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
+ import { jsxs, jsx } from 'react/jsx-runtime';
8
8
  import { useState } from 'react';
9
9
  import Autocomplete from '@mui/material/Autocomplete';
10
+ import Box from '@mui/material/Box';
10
11
  import TextField from '@mui/material/TextField';
11
12
 
12
- const CategorySelector = ({ categories, currentValue, }) => {
13
- console.log("CategorySelector props", { categories, currentValue });
13
+ const CategorySelector = ({ name = "categories", categories, currentValue, sx, multiple = true, onChangeCallback, }) => {
14
14
  const [selectedValues, setSelectedValues] = useState(currentValue || []);
15
15
  const handleCategoryChange = (event, value) => {
16
- value.map((category) => category.documentId);
17
- setSelectedValues(value.map((category) => category.documentId));
16
+ if (!value) {
17
+ setSelectedValues([]);
18
+ if (onChangeCallback)
19
+ onChangeCallback([]);
20
+ return;
21
+ }
22
+ if (multiple === true && Array.isArray(value)) {
23
+ const ids = value.map((category) => category.documentId);
24
+ setSelectedValues(ids);
25
+ if (onChangeCallback)
26
+ onChangeCallback(ids);
27
+ }
28
+ else if (value && !Array.isArray(value)) {
29
+ setSelectedValues([value.documentId]);
30
+ if (onChangeCallback)
31
+ onChangeCallback([value.documentId]);
32
+ }
33
+ else {
34
+ setSelectedValues([]);
35
+ if (onChangeCallback)
36
+ onChangeCallback([]);
37
+ }
18
38
  };
19
- return (jsxs(Fragment, { children: [jsx(Autocomplete, { multiple: true, options: categories, getOptionLabel: (option) => option.title, filterSelectedOptions: true, onChange: handleCategoryChange, renderInput: (params) => jsx(TextField, { ...params, label: "Category" }), value: categories.filter((category) => selectedValues.includes(category.documentId)) }), jsx("input", { type: "hidden", name: "categories", value: JSON.stringify(selectedValues) || "" })] }));
39
+ return (jsxs(Box, { sx: [
40
+ // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
41
+ ...(Array.isArray(sx) ? sx : [sx]),
42
+ ], children: [jsx(Autocomplete, { multiple: true, options: categories, getOptionLabel: (option) => option.title, filterSelectedOptions: true, onChange: handleCategoryChange, renderInput: (params) => jsx(TextField, { ...params, label: "Category" }), value: categories.filter((category) => selectedValues.includes(category.documentId)) }), jsx("input", { type: "hidden", name: name, value: JSON.stringify(selectedValues) || "" })] }));
20
43
  };
21
44
 
22
45
  export { CategorySelector as default };
@@ -10,16 +10,22 @@ import Autocomplete from '@mui/material/Autocomplete';
10
10
  import Box from '@mui/material/Box';
11
11
  import TextField from '@mui/material/TextField';
12
12
 
13
- const ProductSelector = ({ productNames, currentValue, sx, multiple = true, onChangeCallback, }) => {
13
+ const ProductSelector = ({ name = "products", productNames, currentValue, sx, multiple = true, onChangeCallback, }) => {
14
14
  const [selectedValues, setSelectedValues] = useState(currentValue || []);
15
15
  const handleProductChange = (event, value) => {
16
- if (multiple === true) {
16
+ if (!value) {
17
+ setSelectedValues([]);
18
+ if (onChangeCallback)
19
+ onChangeCallback([]);
20
+ return;
21
+ }
22
+ if (multiple === true && Array.isArray(value)) {
17
23
  const ids = value.map((product) => product.documentId);
18
24
  setSelectedValues(ids);
19
25
  if (onChangeCallback)
20
26
  onChangeCallback(ids);
21
27
  }
22
- else if (value) {
28
+ else if (value && !Array.isArray(value)) {
23
29
  setSelectedValues([value.documentId]);
24
30
  if (onChangeCallback)
25
31
  onChangeCallback([value.documentId]);
@@ -35,9 +41,7 @@ const ProductSelector = ({ productNames, currentValue, sx, multiple = true, onCh
35
41
  ...(Array.isArray(sx) ? sx : [sx]),
36
42
  ], children: [jsx(Autocomplete, { multiple: multiple, options: productNames, getOptionLabel: (option) => {
37
43
  return `${option.product_number} | ${option.title}`;
38
- }, filterSelectedOptions: true, onChange: handleProductChange, renderInput: (params) => jsx(TextField, { ...params, label: "Products" }), defaultValue: multiple
39
- ? productNames.filter((productName) => selectedValues.includes(productName.documentId))
40
- : productNames.find((productName) => productName.documentId === selectedValues[0]) || null }), jsx("input", { type: "hidden", name: "products", value: JSON.stringify(selectedValues) })] }));
44
+ }, filterSelectedOptions: true, onChange: handleProductChange, renderInput: (params) => jsx(TextField, { ...params, label: "Products" }), value: productNames.filter((productName) => selectedValues.includes(productName.documentId)) }), jsx("input", { type: "hidden", name: name, value: JSON.stringify(selectedValues) })] }));
41
45
  };
42
46
 
43
47
  export { ProductSelector as default };
@@ -19,63 +19,85 @@ async function getSinglePage(slug) {
19
19
  url.search = qs.stringify({
20
20
  populate: {
21
21
  blocks: {
22
- populate: "*",
23
- /* {
24
- logoImage: {
25
- populate: true,
26
- // fields: ["url", "alternativeText"],
27
- },
28
- bgImage: {
29
- populate: true,
30
- // fields: ["url", "alternativeText"],
31
- },
32
- image: {
33
- populate: true,
34
- // fields: ["url", "alternativeText"],
35
- },
36
- link: {
37
- populate: true,
38
- },
39
- feature: {
40
- populate: true,
41
- },
42
- icon: {
43
- populate: true,
44
- },
45
- airplane: {
46
- populate: {
47
- floorplan: true,
22
+ on: {
23
+ "page-elements.features-section": {
24
+ populate: {
25
+ feature: {
26
+ populate: "*",
27
+ },
28
+ },
29
+ },
30
+ "page-elements.hero-section": {
31
+ populate: { bgImage: "*", link: "*", logoImage: "*" },
32
+ },
33
+ "page-elements.review-section": {
34
+ populate: {
35
+ review: {
36
+ populate: "*",
37
+ },
38
+ },
39
+ },
40
+ "page-elements.text-image-section": {
41
+ populate: { image: "*" },
48
42
  },
49
- },
50
- column: {
51
- populate: true,
52
- },
53
- partner: {
54
- populate: {
55
- text: true,
56
- photo: true,
57
- links: true,
43
+ "page-elements.icon-section": {
44
+ populate: {
45
+ icon: {
46
+ populate: "*",
47
+ },
48
+ },
58
49
  },
59
- },
60
- pictures: true,
61
- companies: {
62
- populate: {
63
- logo: true,
50
+ "page-elements.contact-section": {
51
+ populate: "*",
52
+ },
53
+ "page-elements.fleet-section": {
54
+ populate: {
55
+ airplane: {
56
+ populate: {
57
+ floorplan: "*",
58
+ },
59
+ },
60
+ },
61
+ },
62
+ "page-elements.columns-section": {
63
+ populate: {
64
+ column: "*",
65
+ },
66
+ },
67
+ "page-elements.personalia-section": {
68
+ populate: {
69
+ partner: "*",
70
+ },
71
+ },
72
+ "page-elements.picture-bar-section": {
73
+ populate: {
74
+ pictures: "*",
75
+ },
76
+ },
77
+ "page-elements.logo-bar-section": {
78
+ populate: {
79
+ companies: {
80
+ populate: "*",
81
+ },
82
+ },
83
+ },
84
+ "page-elements.category-block": {
85
+ populate: {
86
+ category: "*",
87
+ },
64
88
  },
65
- },
66
- textV2: true,
67
- category: {
68
- populate: {
69
- products: {
89
+ "page-elements.product-block": {
70
90
  populate: {
71
- image: true,
72
- price: true,
91
+ product: "*",
73
92
  },
74
- },
75
93
  },
76
- },
77
- }, */
94
+ },
78
95
  },
96
+ /*{
97
+ populate: {
98
+
99
+
100
+ },*/
79
101
  },
80
102
  });
81
103
  console.log(url.href);