@propeller-commerce/propeller-v2-react-ui 0.8.0 → 0.9.0
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.
- package/CHANGELOG.md +14 -0
- package/dist/index.cjs +31 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +31 -31
- package/dist/index.js.map +1 -1
- package/dist/pure.cjs +4 -4
- package/dist/pure.cjs.map +1 -1
- package/dist/pure.d.cts +2 -2
- package/dist/pure.d.ts +2 -2
- package/dist/pure.js +4 -4
- package/dist/pure.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -737,8 +737,8 @@ declare function useCheckout(options: UseCheckoutOptions): UseCheckoutReturn;
|
|
|
737
737
|
|
|
738
738
|
/** A cluster-config setting resolved against the current product set and selections. */
|
|
739
739
|
interface ConfiguredSetting {
|
|
740
|
-
/** Setting id from the cluster config. */
|
|
741
|
-
id:
|
|
740
|
+
/** Setting id (uuid) from the cluster config. */
|
|
741
|
+
id: string;
|
|
742
742
|
/** Raw attribute name this setting selects on. */
|
|
743
743
|
name: string;
|
|
744
744
|
/** Display widget hint (e.g. dropdown, swatch). */
|
|
@@ -3535,12 +3535,12 @@ declare function CategoryDescription(props: CategoryDescriptionProps): React$1.J
|
|
|
3535
3535
|
interface CategoryShortDescriptionProps {
|
|
3536
3536
|
/**
|
|
3537
3537
|
* Language code used to resolve the correct localised short description
|
|
3538
|
-
* from `category.
|
|
3538
|
+
* from `category.shortDescriptions`.
|
|
3539
3539
|
*/
|
|
3540
3540
|
language: string;
|
|
3541
3541
|
/**
|
|
3542
3542
|
* Propeller Category object.
|
|
3543
|
-
* The component reads `category.
|
|
3543
|
+
* The component reads `category.shortDescriptions` (an array of LocalizedString)
|
|
3544
3544
|
* and renders the matching language entry as HTML.
|
|
3545
3545
|
*/
|
|
3546
3546
|
category?: Category;
|
package/dist/index.d.ts
CHANGED
|
@@ -737,8 +737,8 @@ declare function useCheckout(options: UseCheckoutOptions): UseCheckoutReturn;
|
|
|
737
737
|
|
|
738
738
|
/** A cluster-config setting resolved against the current product set and selections. */
|
|
739
739
|
interface ConfiguredSetting {
|
|
740
|
-
/** Setting id from the cluster config. */
|
|
741
|
-
id:
|
|
740
|
+
/** Setting id (uuid) from the cluster config. */
|
|
741
|
+
id: string;
|
|
742
742
|
/** Raw attribute name this setting selects on. */
|
|
743
743
|
name: string;
|
|
744
744
|
/** Display widget hint (e.g. dropdown, swatch). */
|
|
@@ -3535,12 +3535,12 @@ declare function CategoryDescription(props: CategoryDescriptionProps): React$1.J
|
|
|
3535
3535
|
interface CategoryShortDescriptionProps {
|
|
3536
3536
|
/**
|
|
3537
3537
|
* Language code used to resolve the correct localised short description
|
|
3538
|
-
* from `category.
|
|
3538
|
+
* from `category.shortDescriptions`.
|
|
3539
3539
|
*/
|
|
3540
3540
|
language: string;
|
|
3541
3541
|
/**
|
|
3542
3542
|
* Propeller Category object.
|
|
3543
|
-
* The component reads `category.
|
|
3543
|
+
* The component reads `category.shortDescriptions` (an array of LocalizedString)
|
|
3544
3544
|
* and renders the matching language entry as HTML.
|
|
3545
3545
|
*/
|
|
3546
3546
|
category?: Category;
|
package/dist/index.js
CHANGED
|
@@ -1107,7 +1107,7 @@ function useClusterConfigurator(options) {
|
|
|
1107
1107
|
const previousSelections = {};
|
|
1108
1108
|
for (let i = 0; i < settingIndex; i++) {
|
|
1109
1109
|
const prev = sortedSettings[i];
|
|
1110
|
-
if (selections[prev.
|
|
1110
|
+
if (selections[prev.attributeName]) previousSelections[prev.attributeName] = selections[prev.attributeName];
|
|
1111
1111
|
}
|
|
1112
1112
|
const matching = filterProductsBySelections(products, previousSelections);
|
|
1113
1113
|
return collectAttributeValues(matching, attributeName);
|
|
@@ -1116,43 +1116,43 @@ function useClusterConfigurator(options) {
|
|
|
1116
1116
|
const sortedSettings = getSortedSettings();
|
|
1117
1117
|
const sel = selectedAttributes;
|
|
1118
1118
|
return sortedSettings.map((setting, index) => {
|
|
1119
|
-
const availableValues = getAvailableValuesForIndexWithSelections(setting.
|
|
1120
|
-
const selectedValue = sel[setting.
|
|
1121
|
-
const isPreviousMissing = index > 0 && sortedSettings.slice(0, index).some((prev) => !sel[prev.
|
|
1119
|
+
const availableValues = getAvailableValuesForIndexWithSelections(setting.attributeName, index, sel);
|
|
1120
|
+
const selectedValue = sel[setting.attributeName] || "";
|
|
1121
|
+
const isPreviousMissing = index > 0 && sortedSettings.slice(0, index).some((prev) => !sel[prev.attributeName]);
|
|
1122
1122
|
const isDisabled = availableValues.length === 0 || isPreviousMissing;
|
|
1123
|
-
let displayName = setting.
|
|
1123
|
+
let displayName = setting.attributeName;
|
|
1124
1124
|
let attributeType;
|
|
1125
1125
|
for (const product of products) {
|
|
1126
1126
|
const items = product.attributes?.items;
|
|
1127
1127
|
if (!items) continue;
|
|
1128
|
-
const match = items.find((a) => attributeNameMatches(a, setting.
|
|
1128
|
+
const match = items.find((a) => attributeNameMatches(a, setting.attributeName));
|
|
1129
1129
|
if (!match) continue;
|
|
1130
|
-
displayName = getAttributeDisplayName(match, language) || setting.
|
|
1130
|
+
displayName = getAttributeDisplayName(match, language) || setting.attributeName;
|
|
1131
1131
|
attributeType = match.attributeDescription?.type ?? void 0;
|
|
1132
1132
|
break;
|
|
1133
1133
|
}
|
|
1134
|
-
return { id: setting.
|
|
1134
|
+
return { id: setting.uuid, name: setting.attributeName, displayType: setting.displayType, attributeType, priority: setting.priority, displayName, availableValues, selectedValue, disabled: isDisabled };
|
|
1135
1135
|
});
|
|
1136
1136
|
}, [products, config, selectedAttributes, language]);
|
|
1137
1137
|
const handleAttributeSelect = useCallback(
|
|
1138
1138
|
(settingName, value) => {
|
|
1139
1139
|
const sortedSettings = getSortedSettings();
|
|
1140
|
-
const changedIndex = sortedSettings.findIndex((s) => s.
|
|
1140
|
+
const changedIndex = sortedSettings.findIndex((s) => s.attributeName === settingName);
|
|
1141
1141
|
if (changedIndex < 0) return;
|
|
1142
1142
|
const newSelections = { ...selectedAttributes };
|
|
1143
1143
|
newSelections[settingName] = value;
|
|
1144
|
-
for (let i = changedIndex + 1; i < sortedSettings.length; i++) delete newSelections[sortedSettings[i].
|
|
1144
|
+
for (let i = changedIndex + 1; i < sortedSettings.length; i++) delete newSelections[sortedSettings[i].attributeName];
|
|
1145
1145
|
for (let i = changedIndex + 1; i < sortedSettings.length; i++) {
|
|
1146
1146
|
const next = sortedSettings[i];
|
|
1147
|
-
const available = getAvailableValuesForIndexWithSelections(next.
|
|
1147
|
+
const available = getAvailableValuesForIndexWithSelections(next.attributeName, i, newSelections);
|
|
1148
1148
|
if (available.length > 0) {
|
|
1149
|
-
newSelections[next.
|
|
1149
|
+
newSelections[next.attributeName] = available[0];
|
|
1150
1150
|
} else {
|
|
1151
1151
|
break;
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
setSelectedAttributes(newSelections);
|
|
1155
|
-
const allSelected = sortedSettings.every((s) => !!newSelections[s.
|
|
1155
|
+
const allSelected = sortedSettings.every((s) => !!newSelections[s.attributeName]);
|
|
1156
1156
|
if (allSelected) {
|
|
1157
1157
|
const matching = filterProductsBySelections(products, newSelections);
|
|
1158
1158
|
if (matching.length > 0 && onConfigurationChange) onConfigurationChange(matching[0]);
|
|
@@ -1168,15 +1168,15 @@ function useClusterConfigurator(options) {
|
|
|
1168
1168
|
if (!attrItems) return;
|
|
1169
1169
|
const initial = {};
|
|
1170
1170
|
for (const setting of sortedSettings) {
|
|
1171
|
-
const match = attrItems.find((a) => attributeNameMatches(a, setting.
|
|
1171
|
+
const match = attrItems.find((a) => attributeNameMatches(a, setting.attributeName));
|
|
1172
1172
|
if (match) {
|
|
1173
1173
|
const values = extractAttributeValues(match);
|
|
1174
|
-
if (values.length) initial[setting.
|
|
1174
|
+
if (values.length) initial[setting.attributeName] = values[0];
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
1177
1177
|
if (!Object.keys(initial).length) return;
|
|
1178
1178
|
setSelectedAttributes(initial);
|
|
1179
|
-
const allSelected = sortedSettings.every((s) => !!initial[s.
|
|
1179
|
+
const allSelected = sortedSettings.every((s) => !!initial[s.attributeName]);
|
|
1180
1180
|
if (allSelected && onConfigurationChange) {
|
|
1181
1181
|
const matching = filterProductsBySelections(products, initial);
|
|
1182
1182
|
if (matching.length > 0) onConfigurationChange(matching[0]);
|
|
@@ -1512,15 +1512,15 @@ function buildCategoriesQuery(depth) {
|
|
|
1512
1512
|
categories {
|
|
1513
1513
|
categoryId
|
|
1514
1514
|
hidden
|
|
1515
|
-
|
|
1516
|
-
|
|
1515
|
+
names(language: $language) { value language }
|
|
1516
|
+
slugs(language: $language) { value }
|
|
1517
1517
|
${buildCategoriesQuery(depth - 1)}
|
|
1518
1518
|
}
|
|
1519
1519
|
`;
|
|
1520
1520
|
}
|
|
1521
1521
|
function mapCategory(raw, language) {
|
|
1522
|
-
const nameEntry = raw.
|
|
1523
|
-
const slugEntry = raw.
|
|
1522
|
+
const nameEntry = raw.names?.find((n) => n.language === language) ?? raw.names?.[0];
|
|
1523
|
+
const slugEntry = raw.slugs?.[0];
|
|
1524
1524
|
return {
|
|
1525
1525
|
categoryId: raw.categoryId,
|
|
1526
1526
|
name: nameEntry?.value ?? "",
|
|
@@ -1600,8 +1600,8 @@ function useMenu(options) {
|
|
|
1600
1600
|
category(categoryId: $categoryId) {
|
|
1601
1601
|
categoryId
|
|
1602
1602
|
hidden
|
|
1603
|
-
|
|
1604
|
-
|
|
1603
|
+
names(language: $language) { value language }
|
|
1604
|
+
slugs(language: $language) { value }
|
|
1605
1605
|
${buildCategoriesQuery(depth)}
|
|
1606
1606
|
}
|
|
1607
1607
|
}
|
|
@@ -2060,7 +2060,7 @@ function useProductInfo(options) {
|
|
|
2060
2060
|
const service = createServices(graphqlClient).cluster;
|
|
2061
2061
|
const clusterConfig = await service.getClusterConfig(clusterId);
|
|
2062
2062
|
const attributeNames = (clusterConfig?.config?.settings ?? []).map(
|
|
2063
|
-
(setting) => setting.
|
|
2063
|
+
(setting) => setting.attributeName
|
|
2064
2064
|
);
|
|
2065
2065
|
const variables = {
|
|
2066
2066
|
clusterId,
|
|
@@ -6155,8 +6155,8 @@ function Breadcrumbs(props) {
|
|
|
6155
6155
|
}
|
|
6156
6156
|
const displayItems = props.showCurrent === false && items.length > 0 ? items.slice(0, items.length - 1) : items;
|
|
6157
6157
|
function getCategoryName(cat) {
|
|
6158
|
-
const match = cat.
|
|
6159
|
-
return match?.value || cat.
|
|
6158
|
+
const match = cat.names?.find((n) => n.language === lang);
|
|
6159
|
+
return match?.value || cat.names?.[0]?.value || "";
|
|
6160
6160
|
}
|
|
6161
6161
|
function getCategoryUrl(cat, index) {
|
|
6162
6162
|
if (props.getUrl) return props.getUrl(cat, index);
|
|
@@ -6164,7 +6164,7 @@ function Breadcrumbs(props) {
|
|
|
6164
6164
|
if (urls && typeof urls.getCategoryUrl === "function") {
|
|
6165
6165
|
return urls.getCategoryUrl(cat, props.language);
|
|
6166
6166
|
}
|
|
6167
|
-
const slug = cat.
|
|
6167
|
+
const slug = cat.slugs?.find((s) => s.language === lang)?.value || cat.slugs?.[0]?.value || "";
|
|
6168
6168
|
return `/category/${cat.categoryId}/${slug}`;
|
|
6169
6169
|
}
|
|
6170
6170
|
function isCurrentItem(index) {
|
|
@@ -7854,7 +7854,7 @@ function CartSummary(rawProps) {
|
|
|
7854
7854
|
var CartSummary_default = CartSummary;
|
|
7855
7855
|
function CategoryDescription(props) {
|
|
7856
7856
|
const [expanded, setExpanded] = useState(false);
|
|
7857
|
-
const match = props.category?.
|
|
7857
|
+
const match = props.category?.descriptions?.find(
|
|
7858
7858
|
(d) => d.language === props.language
|
|
7859
7859
|
);
|
|
7860
7860
|
const html = match?.value || "";
|
|
@@ -7895,7 +7895,7 @@ function CategoryDescription(props) {
|
|
|
7895
7895
|
}
|
|
7896
7896
|
var CategoryDescription_default = CategoryDescription;
|
|
7897
7897
|
function CategoryShortDescription(props) {
|
|
7898
|
-
const match = props.category?.
|
|
7898
|
+
const match = props.category?.shortDescriptions?.find(
|
|
7899
7899
|
(d) => d.language === props.language
|
|
7900
7900
|
);
|
|
7901
7901
|
const html = match?.value || "";
|
|
@@ -12788,7 +12788,7 @@ function Menu(rawProps) {
|
|
|
12788
12788
|
const lang = props.language || "NL";
|
|
12789
12789
|
const category = {
|
|
12790
12790
|
categoryId: cat.categoryId,
|
|
12791
|
-
|
|
12791
|
+
slugs: [{ value: cat.slug, language: lang }]
|
|
12792
12792
|
};
|
|
12793
12793
|
if (props.getUrl) return props.getUrl(category);
|
|
12794
12794
|
return props.configuration.urls.getCategoryUrl(category, lang);
|
|
@@ -12802,8 +12802,8 @@ function Menu(rawProps) {
|
|
|
12802
12802
|
const lang = props.language || "NL";
|
|
12803
12803
|
props.onMenuItemClick({
|
|
12804
12804
|
categoryId: cat.categoryId,
|
|
12805
|
-
|
|
12806
|
-
|
|
12805
|
+
names: [{ value: cat.name, language: lang }],
|
|
12806
|
+
slugs: [{ value: cat.slug, language: lang }]
|
|
12807
12807
|
});
|
|
12808
12808
|
}
|
|
12809
12809
|
}
|