umwd-components 0.1.769 → 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.
Files changed (28) hide show
  1. package/dist/cjs/src/components/common/markdown/MarkdownDisplay.js +1 -1
  2. package/dist/cjs/src/components/common/markdown/MarkdownTextField.js +6 -0
  3. package/dist/cjs/src/components/e-commerce/categories/CategorySelectorV2.js +1 -1
  4. package/dist/cjs/src/components/e-commerce/products/ProductSelector.js +1 -1
  5. package/dist/cjs/src/components/page-builder/PBCategoryBlock.js +1 -2
  6. package/dist/cjs/src/components/page-builder/PageBuilder.js +1 -1
  7. package/dist/cjs/src/data/loaders/page-elements/getSinglePage.js +1 -1
  8. package/dist/cjs/src/index.js +1 -1
  9. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  10. package/dist/esm/src/components/common/markdown/MarkdownDisplay.js +6 -2
  11. package/dist/esm/src/components/common/markdown/MarkdownTextField.js +32 -0
  12. package/dist/esm/src/components/e-commerce/categories/CategorySelectorV2.js +29 -6
  13. package/dist/esm/src/components/e-commerce/products/ProductSelector.js +10 -6
  14. package/dist/esm/src/components/page-builder/PBCategoryBlock.js +16 -11
  15. package/dist/esm/src/components/page-builder/PageBuilder.js +1 -1
  16. package/dist/esm/src/data/loaders/page-elements/getSinglePage.js +72 -50
  17. package/dist/esm/src/index.js +1 -0
  18. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  19. package/dist/esm/types/components/common/markdown/MarkdownDisplay.d.ts +4 -1
  20. package/dist/esm/types/components/common/markdown/MarkdownTextField.d.ts +10 -0
  21. package/dist/esm/types/components/e-commerce/categories/CategorySelectorV2.d.ts +1 -1
  22. package/dist/esm/types/components/e-commerce/products/ProductSelector.d.ts +1 -1
  23. package/dist/esm/types/components/page-builder/PBCategoryBlock.d.ts +22 -21
  24. package/dist/esm/types/components/page-builder/PBFeaturesSection.d.ts +4 -4
  25. package/dist/esm/types/index.d.ts +1 -0
  26. package/dist/esm/types/types/e-commerce/category/types.d.ts +4 -0
  27. package/dist/esm/types/types/e-commerce/product/types.d.ts +1 -0
  28. package/package.json +1 -1
@@ -7,9 +7,13 @@
7
7
 
8
8
  import { jsx } from 'react/jsx-runtime';
9
9
  import MuiMarkdown from 'mui-markdown';
10
+ import { Box } from '@mui/material';
10
11
 
11
- function MarkdownDisplay({ children, props, }) {
12
- return jsx(MuiMarkdown, { ...props, children: children });
12
+ function MarkdownDisplay({ children, props, onClickCallback, sx, }) {
13
+ return (jsx(Box, { onClick: onClickCallback, sx: [
14
+ // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
15
+ ...(Array.isArray(sx) ? sx : [sx]),
16
+ ], children: jsx(MuiMarkdown, { ...props, children: children }) }));
13
17
  }
14
18
 
15
19
  export { MarkdownDisplay as default };
@@ -0,0 +1,32 @@
1
+ /*
2
+ * UMWD-Components
3
+ * @copyright Jelle Paulus
4
+ * @license MIT
5
+ */
6
+
7
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
8
+ import { useState } from 'react';
9
+ import TextField from '@mui/material/TextField';
10
+ import MarkdownDisplay from './MarkdownDisplay.js';
11
+
12
+ function MarkdownTextField({ id, name, label, defaultValue = "", sx, onChangeCallback, }) {
13
+ const [isFocused, setIsFocused] = useState(false);
14
+ const [value, setValue] = useState(defaultValue);
15
+ const handleChange = (event) => {
16
+ const newValue = event.target.value;
17
+ setValue(newValue);
18
+ if (onChangeCallback) {
19
+ onChangeCallback(newValue);
20
+ }
21
+ };
22
+ return (jsxs(Fragment, { children: [jsx(TextField, { id: id, name: name, label: label, value: value, variant: "standard", fullWidth: true, multiline: true, onChange: handleChange, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), sx: {
23
+ display: isFocused ? "block" : "none",
24
+ "& .MuiInputBase-input": {
25
+ color: "inherit",
26
+ padding: 0,
27
+ },
28
+ ...sx,
29
+ } }), !isFocused && value && (jsx(MarkdownDisplay, { onClickCallback: () => setIsFocused(true), sx: { cursor: "pointer" }, children: value }))] }));
30
+ }
31
+
32
+ export { MarkdownTextField as default };
@@ -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 };
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  /*
3
2
  * UMWD-Components
4
3
  * @copyright Jelle Paulus
@@ -13,23 +12,29 @@ import Stack from '@mui/material/Stack';
13
12
  import Divider from '@mui/material/Divider';
14
13
  import Button from '@mui/material/Button';
15
14
  import Typography from '@mui/material/Typography';
15
+ import Box from '@mui/material/Box';
16
+ import TextField from '@mui/material/TextField';
16
17
  import { useTheme } from '@mui/material/styles';
17
18
  import { setOpacity } from '../../lib/utils.js';
18
19
  import ProductCard from '../e-commerce/products/ProductCard.js';
19
20
  import MarkdownDisplay from '../common/markdown/MarkdownDisplay.js';
20
21
 
21
- function PBCategoryBlock({ data, }) {
22
+ function PBCategoryBlock({ data, index, }) {
22
23
  const { maxWidth = "lg", sx = {}, glass = false, previewAmount = 3 } = data;
23
24
  const theme = useTheme();
24
- return (jsx(Container, { maxWidth: maxWidth, sx: { my: 1, ...sx }, children: jsx(Grid, { container: true, spacing: 2, children: jsx(Grid, { size: 12, children: jsx(Paper, { sx: {
25
- p: 2,
26
- backdropFilter: "blur(3px)",
27
- backgroundColor: setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
28
- border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none",
29
- }, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h4", component: "a", href: `/shop/categories/${data.category.slug}`, sx: { textDecoration: "none", color: "inherit" }, children: data.category.title }), data.category?.description &&
30
- typeof data.category.description === "string" && (jsx(MarkdownDisplay, { children: data.category.description.substring(0, 150) + "..." })), jsx(Button, { variant: "contained", href: `/shop/categories/${data.category.slug}`, children: "Learn More" }), data.category?.products?.data != undefined && (jsxs(Fragment, { children: [jsx(Divider, { sx: { my: 2 } }), jsx(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, justifyContent: "space-around", sx: { pt: 2 }, children: data.category.products.data
31
- .slice(0, previewAmount)
32
- .map((product) => (jsx(ProductCard, { product: product }, product.documentId))) })] })), jsx(Typography, { variant: "body2", component: "a", href: `/shop/categories/${data.category.slug}`, sx: { textDecoration: "none", color: "inherit" }, children: "Show all" })] }) }) }) }) }));
25
+ return (jsx(Container, { maxWidth: maxWidth || "lg", sx: { my: 1, ...sx }, children: jsx(Box, { sx: { p: 1, border: `1px dashed ${theme.palette.primary.main}` }, children: jsx(Grid, { container: true, spacing: 2, children: jsx(Grid, { size: 12, children: jsx(Paper, { sx: {
26
+ p: 2,
27
+ backdropFilter: "blur(3px)",
28
+ backgroundColor: setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
29
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none",
30
+ }, children: jsxs(Stack, { spacing: 2, children: [jsx(TextField, { id: "title", name: "title", label: "Title", defaultValue: data.category.title, variant: "outlined", fullWidth: true, InputProps: {
31
+ readOnly: true,
32
+ }, sx: { mb: 2 } }), jsx(TextField, { id: "description", name: "description", label: "Description", defaultValue: data.category.description, variant: "outlined", fullWidth: true, InputProps: {
33
+ readOnly: true,
34
+ } }), data.category?.description &&
35
+ typeof data.category.description === "string" && (jsx(MarkdownDisplay, { children: data.category.description.substring(0, 150) + "..." })), jsx(Button, { variant: "contained", href: `/shop/categories/${data.category.slug}`, children: "Learn More" }), data.category?.products?.data != undefined && (jsxs(Fragment, { children: [jsx(Divider, { sx: { my: 2 } }), jsx(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, justifyContent: "space-around", sx: { pt: 2 }, children: data.category.products.data
36
+ .slice(0, previewAmount)
37
+ .map((product) => (jsx(ProductCard, { product: product }, product.documentId))) })] })), jsx(Typography, { variant: "body2", component: "a", href: `/shop/categories/${data.category.slug}`, sx: { textDecoration: "none", color: "inherit" }, children: "Show all" })] }) }) }) }) }) }));
33
38
  }
34
39
 
35
40
  export { PBCategoryBlock };
@@ -62,7 +62,7 @@ function blockRenderer(block, index) {
62
62
  case "page-elements.product-block":
63
63
  return (jsx(PBProductBlock, { data: block }, `${block.id}-${block.__component}`));
64
64
  case "page-elements.category-block":
65
- return (jsx(PBCategoryBlock, { data: block }, `${block.id}-${block.__component}`));
65
+ return (jsx(PBCategoryBlock, { data: block, index: index }, `${block.id}-${block.__component}`));
66
66
  default:
67
67
  return null;
68
68
  }
@@ -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);
@@ -90,6 +90,7 @@ export { StrapiErrors } from './components/StrapiErrors.js';
90
90
  export { SubmitButton } from './components/SubmitButton.js';
91
91
  export { default as MarkdownDisplay } from './components/common/markdown/MarkdownDisplay.js';
92
92
  export { default as MarkdownEditor } from './components/common/markdown/MarkdownEditor.js';
93
+ export { default as MarkdownTextField } from './components/common/markdown/MarkdownTextField.js';
93
94
  export { areBusinessCredentailsComplete } from './lib/areBusinessCredentialsComplete.js';
94
95
  export { isCustomerProfileComplete } from './lib/isCustomerProfileComplete.js';
95
96
  export { isCustomerProfileCompleteV2 } from './lib/isCustomerProfileCompleteV2.js';