@configura/web-ui 1.3.0-alpha.4 → 1.3.0-alpha.5

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 (79) hide show
  1. package/.postcssrc.json +8 -8
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/components/CanvasWrapper.d.ts +9 -9
  5. package/dist/components/CanvasWrapper.js +8 -8
  6. package/dist/components/ConfigurationActionsButtonRow.d.ts +11 -11
  7. package/dist/components/ConfigurationActionsButtonRow.js +13 -13
  8. package/dist/components/Configurator.d.ts +12 -12
  9. package/dist/components/Configurator.js +15 -15
  10. package/dist/components/ConfiguratorWrapper.d.ts +8 -8
  11. package/dist/components/ConfiguratorWrapper.js +5 -5
  12. package/dist/components/CurrencyPrice.d.ts +9 -9
  13. package/dist/components/CurrencyPrice.js +7 -7
  14. package/dist/components/ExpandableHeadingRow.d.ts +15 -15
  15. package/dist/components/ExpandableHeadingRow.js +21 -21
  16. package/dist/components/Loading.d.ts +13 -13
  17. package/dist/components/Loading.js +20 -20
  18. package/dist/components/ProductInformation.d.ts +10 -10
  19. package/dist/components/ProductInformation.js +23 -23
  20. package/dist/components/icons/Checkmark.d.ts +5 -5
  21. package/dist/components/icons/Checkmark.js +12 -12
  22. package/dist/components/icons/Chevron.d.ts +6 -6
  23. package/dist/components/icons/Chevron.js +18 -18
  24. package/dist/components/productConfiguration/CfgAdditionalProductView.d.ts +3 -3
  25. package/dist/components/productConfiguration/CfgAdditionalProductView.js +28 -28
  26. package/dist/components/productConfiguration/CfgCheckboxView.d.ts +18 -18
  27. package/dist/components/productConfiguration/CfgCheckboxView.js +22 -22
  28. package/dist/components/productConfiguration/CfgCheckboxesView.d.ts +12 -12
  29. package/dist/components/productConfiguration/CfgCheckboxesView.js +18 -18
  30. package/dist/components/productConfiguration/CfgDropdownOptionView.d.ts +18 -18
  31. package/dist/components/productConfiguration/CfgDropdownOptionView.js +35 -33
  32. package/dist/components/productConfiguration/CfgDropdownView.d.ts +12 -12
  33. package/dist/components/productConfiguration/CfgDropdownView.js +20 -20
  34. package/dist/components/productConfiguration/CfgFeatureView.d.ts +27 -27
  35. package/dist/components/productConfiguration/CfgFeatureView.js +34 -34
  36. package/dist/components/productConfiguration/CfgGroupView.d.ts +4 -4
  37. package/dist/components/productConfiguration/CfgGroupView.js +13 -13
  38. package/dist/components/productConfiguration/CfgOptionFeaturesView.d.ts +6 -6
  39. package/dist/components/productConfiguration/CfgOptionFeaturesView.js +13 -13
  40. package/dist/components/productConfiguration/CfgOptionNumericView.d.ts +28 -0
  41. package/dist/components/productConfiguration/CfgOptionNumericView.js +116 -0
  42. package/dist/components/productConfiguration/CfgOptionPriceView.d.ts +9 -9
  43. package/dist/components/productConfiguration/CfgOptionPriceView.js +29 -29
  44. package/dist/components/productConfiguration/CfgProductConfigurationView.d.ts +18 -18
  45. package/dist/components/productConfiguration/CfgProductConfigurationView.js +45 -37
  46. package/dist/css/web-ui.css +1 -1
  47. package/dist/css/web-ui.css.map +1 -1
  48. package/dist/index.d.ts +20 -20
  49. package/dist/index.js +20 -20
  50. package/dist/scss/_button.scss +36 -36
  51. package/dist/scss/_configurator.scss +67 -67
  52. package/dist/scss/_expandable.scss +37 -37
  53. package/dist/scss/_feature-item.scss +124 -124
  54. package/dist/scss/_hr.scss +16 -16
  55. package/dist/scss/_loading.scss +98 -98
  56. package/dist/scss/_mixins.scss +56 -56
  57. package/dist/scss/_option-tree.scss +29 -29
  58. package/dist/scss/_product-information.scss +49 -49
  59. package/dist/scss/_range-view.scss +20 -0
  60. package/dist/scss/_slider.scss +70 -70
  61. package/dist/scss/_themed.scss +124 -123
  62. package/dist/scss/_utilities.scss +21 -17
  63. package/dist/scss/_variables.scss +6 -6
  64. package/dist/scss/icons/_checkmark.scss +46 -46
  65. package/dist/scss/icons/_chevron.scss +62 -62
  66. package/dist/scss/web-ui.scss +11 -11
  67. package/dist/useObservable.d.ts +4 -4
  68. package/dist/useObservable.js +18 -18
  69. package/dist/useRerender.d.ts +1 -1
  70. package/dist/useRerender.js +5 -5
  71. package/dist/useResize.d.ts +6 -6
  72. package/dist/useResize.js +47 -47
  73. package/dist/useSelected.d.ts +2 -2
  74. package/dist/useSelected.js +13 -13
  75. package/dist/useUniqueId.d.ts +1 -1
  76. package/dist/useUniqueId.js +7 -7
  77. package/dist/utilities.d.ts +5 -5
  78. package/dist/utilities.js +1 -1
  79. package/package.json +3 -3
@@ -1,33 +1,35 @@
1
- import React from "react";
2
- import { useUuid } from "../../useUniqueId.js";
3
- import { Checkmark } from "../icons/Checkmark.js";
4
- import { forwardProps, } from "./CfgFeatureView.js";
5
- import { CfgOptionFeaturesView } from "./CfgOptionFeaturesView.js";
6
- import { CfgOptionPriceView } from "./CfgOptionPriceView.js";
7
- export const CfgDropdownOptionView = (props) => {
8
- const { option, upchargeDisplayMode } = props;
9
- const { code, thumbnail, description, selected } = option;
10
- const optionClasses = selected ? "cfgFeatureItemOption--checked" : "";
11
- const uniqueId = useUuid();
12
- return (React.createElement("li", { className: `cfgFeatureItem cfgMb1 ${props.className || ""}`, style: props.style },
13
- React.createElement("label", { className: `cfgFeatureItemOption ${optionClasses}`, htmlFor: uniqueId },
14
- React.createElement("input", { checked: selected, className: "cfgFeatureItem__hiddenInput", id: uniqueId, name: uniqueId, onChange: () => {
15
- option.setSelected(true);
16
- }, onClick: () => {
17
- // As a convenience for when wanting to re-select something already
18
- // selected to use the propagation side effects we have added this
19
- // which will trigger a setSelected even though this is strictly not
20
- // a change.
21
- if (selected) {
22
- option.setSelected(true);
23
- }
24
- }, type: "radio", value: code }),
25
- React.createElement("div", { className: "cfgFeatureItem__radio" }, selected && React.createElement(Checkmark, null)),
26
- thumbnail && (React.createElement("img", { alt: `Thumbnail for ${description}`, className: "cfgThumbnailImage cfgMl1", src: thumbnail })),
27
- React.createElement("div", { className: "cfgFeatureItemOption__titleWrapper" },
28
- React.createElement("div", { className: "cfgFeatureItemOption__title" },
29
- description || code,
30
- React.createElement(CfgOptionPriceView, { option: option, upchargeDisplayMode: upchargeDisplayMode })))),
31
- React.createElement(CfgOptionFeaturesView, Object.assign({ option: option }, forwardProps(props)))));
32
- };
33
- export const CfgDropdownOptionViewMemo = React.memo(CfgDropdownOptionView);
1
+ import React from "react";
2
+ import { useUuid } from "../../useUniqueId.js";
3
+ import { Checkmark } from "../icons/Checkmark.js";
4
+ import { forwardProps, } from "./CfgFeatureView.js";
5
+ import { CfgOptionFeaturesView } from "./CfgOptionFeaturesView.js";
6
+ import { CfgOptionNumericView } from "./CfgOptionNumericView.js";
7
+ import { CfgOptionPriceView } from "./CfgOptionPriceView.js";
8
+ export const CfgDropdownOptionView = (props) => {
9
+ const { option, upchargeDisplayMode } = props;
10
+ const { code, thumbnail, description, selected } = option;
11
+ const optionClasses = selected ? "cfgFeatureItemOption--checked" : "";
12
+ const uniqueId = useUuid();
13
+ return (React.createElement("li", { className: `cfgFeatureItem cfgMb1 ${props.className || ""}`, style: props.style },
14
+ React.createElement("label", { className: `cfgFeatureItemOption ${optionClasses}`, htmlFor: uniqueId },
15
+ React.createElement("input", { checked: selected, className: "cfgFeatureItem__hiddenInput", id: uniqueId, name: uniqueId, onChange: () => {
16
+ option.setSelected(true);
17
+ }, onClick: () => {
18
+ // As a convenience for when wanting to re-select something already
19
+ // selected to use the propagation side effects we have added this
20
+ // which will trigger a setSelected even though this is strictly not
21
+ // a change.
22
+ if (selected) {
23
+ option.setSelected(true);
24
+ }
25
+ }, type: "radio", value: code }),
26
+ React.createElement("div", { className: "cfgFeatureItem__radio" }, selected && React.createElement(Checkmark, null)),
27
+ thumbnail && (React.createElement("img", { alt: `Thumbnail for ${description}`, className: "cfgThumbnailImage cfgMl1", src: thumbnail })),
28
+ React.createElement("div", { className: "cfgFeatureItemOption__titleWrapper" },
29
+ React.createElement("div", { className: "cfgFeatureItemOption__title" },
30
+ description || code,
31
+ React.createElement(CfgOptionPriceView, { option: option, upchargeDisplayMode: upchargeDisplayMode })))),
32
+ selected && React.createElement(CfgOptionNumericView, { option: option }),
33
+ React.createElement(CfgOptionFeaturesView, Object.assign({ option: option }, forwardProps(props)))));
34
+ };
35
+ export const CfgDropdownOptionViewMemo = React.memo(CfgDropdownOptionView);
@@ -1,13 +1,13 @@
1
- import React from "react";
2
- import { CssProps } from "../../utilities.js";
3
- import { CfgFeatureViewProps } from "./CfgFeatureView.js";
4
- export declare const CfgDropdownView: React.FC<CfgFeatureViewProps & CssProps>;
5
- export declare const CfgDropdownViewMemo: React.NamedExoticComponent<import("./CfgProductConfigurationView.js").PassthroughProps & {
6
- additionalProductComponent?: React.ComponentType<import("./CfgFeatureView.js").CfgAdditionalProductViewProps> | undefined;
7
- featureGroupComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
8
- featureSelectManyComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
9
- featureSelectOneComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
10
- } & {
11
- feature: import("@configura/web-api").CfgFeature;
12
- } & CssProps>;
1
+ import React from "react";
2
+ import { CssProps } from "../../utilities.js";
3
+ import { CfgFeatureViewProps } from "./CfgFeatureView.js";
4
+ export declare const CfgDropdownView: React.FC<CfgFeatureViewProps & CssProps>;
5
+ export declare const CfgDropdownViewMemo: React.NamedExoticComponent<import("./CfgProductConfigurationView.js").PassthroughProps & {
6
+ additionalProductComponent?: React.ComponentType<import("./CfgFeatureView.js").CfgAdditionalProductViewProps> | undefined;
7
+ featureGroupComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
8
+ featureSelectManyComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
9
+ featureSelectOneComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
10
+ } & {
11
+ feature: import("@configura/web-api").CfgFeature;
12
+ } & CssProps>;
13
13
  //# sourceMappingURL=CfgDropdownView.d.ts.map
@@ -1,20 +1,20 @@
1
- import { SelectionType } from "@configura/web-api";
2
- import React, { useState } from "react";
3
- import { ExpandableHeadingRow } from "../ExpandableHeadingRow.js";
4
- import { CfgDropdownOptionViewMemo } from "./CfgDropdownOptionView.js";
5
- import { forwardProps } from "./CfgFeatureView.js";
6
- export const CfgDropdownView = (props) => {
7
- const { feature } = props;
8
- if (feature.selectionType !== SelectionType.SelectOne) {
9
- throw Error(`Unsupported selection type expected: ${SelectionType.SelectOne}, got: ${feature.selectionType}`);
10
- }
11
- const { description, preview, options } = feature;
12
- const [open, setOpen] = useState(false);
13
- return (React.createElement("li", { className: `cfgFeatureItem ${props.className || ""}`, style: props.style },
14
- React.createElement(ExpandableHeadingRow, { heading: description, open: open, onClick: () => setOpen((prev) => !prev) }, preview && (React.createElement("div", { className: "cfgThumbnailPlaceholder" },
15
- React.createElement("img", { alt: `Preview for ${description}`, className: "cfgThumbnailImage", src: preview })))),
16
- React.createElement("div", { className: "cfgFeatureItem__subTree" },
17
- open && (React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--subLevel ${preview ? "cfgOptionTree--compThumb" : ""}` }, options.map((option) => (React.createElement(CfgDropdownOptionViewMemo, Object.assign({ key: option.key, option: option }, forwardProps(props))))))),
18
- React.createElement("hr", { className: "cfgFeatureItem__hr cfgHr" }))));
19
- };
20
- export const CfgDropdownViewMemo = React.memo(CfgDropdownView);
1
+ import { SelectionType } from "@configura/web-api";
2
+ import React, { useState } from "react";
3
+ import { ExpandableHeadingRow } from "../ExpandableHeadingRow.js";
4
+ import { CfgDropdownOptionViewMemo } from "./CfgDropdownOptionView.js";
5
+ import { forwardProps } from "./CfgFeatureView.js";
6
+ export const CfgDropdownView = (props) => {
7
+ const { feature } = props;
8
+ if (feature.selectionType !== SelectionType.SelectOne) {
9
+ throw Error(`Unsupported selection type expected: ${SelectionType.SelectOne}, got: ${feature.selectionType}`);
10
+ }
11
+ const { description, preview, options } = feature;
12
+ const [open, setOpen] = useState(false);
13
+ return (React.createElement("li", { className: `cfgFeatureItem ${props.className || ""}`, style: props.style },
14
+ React.createElement(ExpandableHeadingRow, { heading: description, open: open, onClick: () => setOpen((prev) => !prev) }, preview && (React.createElement("div", { className: "cfgThumbnailPlaceholder" },
15
+ React.createElement("img", { alt: `Preview for ${description}`, className: "cfgThumbnailImage", src: preview })))),
16
+ React.createElement("div", { className: "cfgFeatureItem__subTree" },
17
+ open && (React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--subLevel ${preview ? "cfgOptionTree--compThumb" : ""}` }, options.map((option) => (React.createElement(CfgDropdownOptionViewMemo, Object.assign({ key: option.key, option: option }, forwardProps(props))))))),
18
+ React.createElement("hr", { className: "cfgFeatureItem__hr cfgHr" }))));
19
+ };
20
+ export const CfgDropdownViewMemo = React.memo(CfgDropdownView);
@@ -1,28 +1,28 @@
1
- import { CfgFeature, CfgProduct } from "@configura/web-api";
2
- import React from "react";
3
- import { CssProps } from "../../utilities.js";
4
- import { PassthroughProps } from "./CfgProductConfigurationView.js";
5
- export declare type CfgFeatureViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
6
- feature: CfgFeature;
7
- };
8
- export declare type CfgAdditionalProductViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
9
- product: CfgProduct;
10
- permanentlyExpandedLevels: number;
11
- };
12
- export declare type CfgProductConfigurationComponentAndPassthroughProps = PassthroughProps & {
13
- additionalProductComponent?: React.ComponentType<CfgAdditionalProductViewProps>;
14
- featureGroupComponent?: React.ComponentType<CfgFeatureViewProps>;
15
- featureSelectManyComponent?: React.ComponentType<CfgFeatureViewProps>;
16
- featureSelectOneComponent?: React.ComponentType<CfgFeatureViewProps>;
17
- };
18
- export declare const forwardProps: (props: CfgProductConfigurationComponentAndPassthroughProps) => CfgProductConfigurationComponentAndPassthroughProps;
19
- export declare const CfgFeatureView: React.FC<CfgFeatureViewProps & CssProps>;
20
- export declare const CfgFeatureViewMemo: React.NamedExoticComponent<PassthroughProps & {
21
- additionalProductComponent?: React.ComponentType<CfgAdditionalProductViewProps> | undefined;
22
- featureGroupComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
23
- featureSelectManyComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
24
- featureSelectOneComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
25
- } & {
26
- feature: CfgFeature;
27
- } & CssProps>;
1
+ import { CfgFeature, CfgProduct } from "@configura/web-api";
2
+ import React from "react";
3
+ import { CssProps } from "../../utilities.js";
4
+ import { PassthroughProps } from "./CfgProductConfigurationView.js";
5
+ export declare type CfgFeatureViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
6
+ feature: CfgFeature;
7
+ };
8
+ export declare type CfgAdditionalProductViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
9
+ product: CfgProduct;
10
+ permanentlyExpandedLevels: number;
11
+ };
12
+ export declare type CfgProductConfigurationComponentAndPassthroughProps = PassthroughProps & {
13
+ additionalProductComponent?: React.ComponentType<CfgAdditionalProductViewProps>;
14
+ featureGroupComponent?: React.ComponentType<CfgFeatureViewProps>;
15
+ featureSelectManyComponent?: React.ComponentType<CfgFeatureViewProps>;
16
+ featureSelectOneComponent?: React.ComponentType<CfgFeatureViewProps>;
17
+ };
18
+ export declare const forwardProps: (props: CfgProductConfigurationComponentAndPassthroughProps) => CfgProductConfigurationComponentAndPassthroughProps;
19
+ export declare const CfgFeatureView: React.FC<CfgFeatureViewProps & CssProps>;
20
+ export declare const CfgFeatureViewMemo: React.NamedExoticComponent<PassthroughProps & {
21
+ additionalProductComponent?: React.ComponentType<CfgAdditionalProductViewProps> | undefined;
22
+ featureGroupComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
23
+ featureSelectManyComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
24
+ featureSelectOneComponent?: React.ComponentType<CfgFeatureViewProps> | undefined;
25
+ } & {
26
+ feature: CfgFeature;
27
+ } & CssProps>;
28
28
  //# sourceMappingURL=CfgFeatureView.d.ts.map
@@ -1,34 +1,34 @@
1
- import { SelectionType } from "@configura/web-api";
2
- import React from "react";
3
- import { CfgCheckboxesViewMemo } from "./CfgCheckboxesView.js";
4
- import { CfgDropdownViewMemo } from "./CfgDropdownView.js";
5
- import { CfgGroupViewMemo } from "./CfgGroupView.js";
6
- export const forwardProps = (props) => {
7
- return {
8
- upchargeDisplayMode: props.upchargeDisplayMode,
9
- additionalProductComponent: props.additionalProductComponent,
10
- featureGroupComponent: props.featureGroupComponent,
11
- featureSelectManyComponent: props.featureSelectManyComponent,
12
- featureSelectOneComponent: props.featureSelectOneComponent,
13
- };
14
- };
15
- export const CfgFeatureView = (props) => {
16
- const { feature } = props;
17
- if (!feature.visible) {
18
- return null;
19
- }
20
- const GroupComponent = props.featureGroupComponent || CfgGroupViewMemo;
21
- const SelectManyComponent = props.featureSelectManyComponent || CfgCheckboxesViewMemo;
22
- const SelectOneComponent = props.featureSelectOneComponent || CfgDropdownViewMemo;
23
- switch (feature.selectionType) {
24
- case SelectionType.Group:
25
- return React.createElement(GroupComponent, Object.assign({}, props));
26
- case SelectionType.SelectMany:
27
- return React.createElement(SelectManyComponent, Object.assign({}, props));
28
- case SelectionType.SelectOne:
29
- return React.createElement(SelectOneComponent, Object.assign({}, props));
30
- default:
31
- throw Error("Unsupported viewType");
32
- }
33
- };
34
- export const CfgFeatureViewMemo = React.memo(CfgFeatureView);
1
+ import { SelectionType } from "@configura/web-api";
2
+ import React from "react";
3
+ import { CfgCheckboxesViewMemo } from "./CfgCheckboxesView.js";
4
+ import { CfgDropdownViewMemo } from "./CfgDropdownView.js";
5
+ import { CfgGroupViewMemo } from "./CfgGroupView.js";
6
+ export const forwardProps = (props) => {
7
+ return {
8
+ upchargeDisplayMode: props.upchargeDisplayMode,
9
+ additionalProductComponent: props.additionalProductComponent,
10
+ featureGroupComponent: props.featureGroupComponent,
11
+ featureSelectManyComponent: props.featureSelectManyComponent,
12
+ featureSelectOneComponent: props.featureSelectOneComponent,
13
+ };
14
+ };
15
+ export const CfgFeatureView = (props) => {
16
+ const { feature } = props;
17
+ if (!feature.visible) {
18
+ return null;
19
+ }
20
+ const GroupComponent = props.featureGroupComponent || CfgGroupViewMemo;
21
+ const SelectManyComponent = props.featureSelectManyComponent || CfgCheckboxesViewMemo;
22
+ const SelectOneComponent = props.featureSelectOneComponent || CfgDropdownViewMemo;
23
+ switch (feature.selectionType) {
24
+ case SelectionType.Group:
25
+ return React.createElement(GroupComponent, Object.assign({}, props));
26
+ case SelectionType.SelectMany:
27
+ return React.createElement(SelectManyComponent, Object.assign({}, props));
28
+ case SelectionType.SelectOne:
29
+ return React.createElement(SelectOneComponent, Object.assign({}, props));
30
+ default:
31
+ throw Error("Unsupported viewType");
32
+ }
33
+ };
34
+ export const CfgFeatureViewMemo = React.memo(CfgFeatureView);
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { CfgFeatureViewProps } from "./CfgFeatureView.js";
3
- export declare const CfgGroupView: React.FC<CfgFeatureViewProps>;
4
- export declare const CfgGroupViewMemo: React.NamedExoticComponent<CfgFeatureViewProps>;
1
+ import React from "react";
2
+ import { CfgFeatureViewProps } from "./CfgFeatureView.js";
3
+ export declare const CfgGroupView: React.FC<CfgFeatureViewProps>;
4
+ export declare const CfgGroupViewMemo: React.NamedExoticComponent<CfgFeatureViewProps>;
5
5
  //# sourceMappingURL=CfgGroupView.d.ts.map
@@ -1,13 +1,13 @@
1
- import { SelectionType } from "@configura/web-api";
2
- import React from "react";
3
- import { CfgFeatureViewMemo, forwardProps } from "./CfgFeatureView.js";
4
- export const CfgGroupView = (props) => {
5
- const { feature } = props;
6
- if (feature.selectionType !== SelectionType.Group) {
7
- throw Error(`Unsupported selection type expected: ${SelectionType.Group}, got: ${feature.selectionType}`);
8
- }
9
- return (React.createElement(React.Fragment, null, feature.options.map((o) => {
10
- return o.features.map((f) => (React.createElement(CfgFeatureViewMemo, Object.assign({ key: f.key, feature: f }, forwardProps(props)))));
11
- })));
12
- };
13
- export const CfgGroupViewMemo = React.memo(CfgGroupView);
1
+ import { SelectionType } from "@configura/web-api";
2
+ import React from "react";
3
+ import { CfgFeatureViewMemo, forwardProps } from "./CfgFeatureView.js";
4
+ export const CfgGroupView = (props) => {
5
+ const { feature } = props;
6
+ if (feature.selectionType !== SelectionType.Group) {
7
+ throw Error(`Unsupported selection type expected: ${SelectionType.Group}, got: ${feature.selectionType}`);
8
+ }
9
+ return (React.createElement(React.Fragment, null, feature.options.map((o) => {
10
+ return o.features.map((f) => (React.createElement(CfgFeatureViewMemo, Object.assign({ key: f.key, feature: f }, forwardProps(props)))));
11
+ })));
12
+ };
13
+ export const CfgGroupViewMemo = React.memo(CfgGroupView);
@@ -1,7 +1,7 @@
1
- import { CfgOption } from "@configura/web-api";
2
- import React from "react";
3
- import { PassthroughProps } from "./CfgProductConfigurationView.js";
4
- export declare const CfgOptionFeaturesView: React.FC<{
5
- option: CfgOption;
6
- } & PassthroughProps>;
1
+ import { CfgOption } from "@configura/web-api";
2
+ import React from "react";
3
+ import { PassthroughProps } from "./CfgProductConfigurationView.js";
4
+ export declare const CfgOptionFeaturesView: React.FC<{
5
+ option: CfgOption;
6
+ } & PassthroughProps>;
7
7
  //# sourceMappingURL=CfgOptionFeaturesView.d.ts.map
@@ -1,13 +1,13 @@
1
- import React from "react";
2
- import { CfgFeatureView, forwardProps } from "./CfgFeatureView.js";
3
- export const CfgOptionFeaturesView = (props) => {
4
- const { option } = props;
5
- const { features, selected } = option;
6
- if (!selected) {
7
- return null;
8
- }
9
- if (features.length === 0) {
10
- return null;
11
- }
12
- return (React.createElement("ul", { className: "cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent" }, features.map((f) => (React.createElement(CfgFeatureView, Object.assign({ feature: f, key: f.key }, forwardProps(props)))))));
13
- };
1
+ import React from "react";
2
+ import { CfgFeatureView, forwardProps } from "./CfgFeatureView.js";
3
+ export const CfgOptionFeaturesView = (props) => {
4
+ const { option } = props;
5
+ const { features, selected } = option;
6
+ if (!selected) {
7
+ return null;
8
+ }
9
+ if (features.length === 0) {
10
+ return null;
11
+ }
12
+ return (React.createElement("ul", { className: "cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent" }, features.map((f) => (React.createElement(CfgFeatureView, Object.assign({ feature: f, key: f.key }, forwardProps(props)))))));
13
+ };
@@ -0,0 +1,28 @@
1
+ import { CfgOption, NumericValueDiscrete, NumericValueRangeDefinition } from "@configura/web-api";
2
+ import { LengthUnit } from "@configura/web-utilities";
3
+ import React from "react";
4
+ import { CssProps } from "../../utilities.js";
5
+ export declare const CfgOptionNumericView: React.FC<{
6
+ option: CfgOption;
7
+ } & CssProps>;
8
+ /**
9
+ * Displays GUI for selecting in one "range". Please note that the range
10
+ * parameter can also be a discrete value.
11
+ */
12
+ export declare const NumericValueView: React.FC<{
13
+ currentValue: number;
14
+ unit: LengthUnit;
15
+ range: NumericValueRangeDefinition | NumericValueDiscrete;
16
+ updateValue: (val: number, commit: boolean) => void;
17
+ hasNoSiblings: boolean;
18
+ }>;
19
+ export declare const RangeView: React.FC<{
20
+ currentValue: number;
21
+ unit: LengthUnit;
22
+ range: NumericValueRangeDefinition;
23
+ inputValue: number;
24
+ onChange: (val: number, instantUpdate: boolean) => void;
25
+ onCommit: () => void;
26
+ showRangeError: boolean;
27
+ } & CssProps>;
28
+ //# sourceMappingURL=CfgOptionNumericView.d.ts.map
@@ -0,0 +1,116 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { NumericValueDiscrete, NumericValueRangeDefinition } from "@configura/web-api";
11
+ import React, { useEffect, useState } from "react";
12
+ import { useRerender } from "../../useRerender.js";
13
+ import { useUuid } from "../../useUniqueId.js";
14
+ import { Checkmark } from "../icons/Checkmark.js";
15
+ export const CfgOptionNumericView = (props) => {
16
+ const { option } = props;
17
+ const { isUseNumericValue } = option;
18
+ // Contrary to most other components this one has its own connection to the
19
+ // option that is backing it. This is for it to be able to "live" update
20
+ // as we drag sliders. The value is not "commited" at immediate drag, and so
21
+ // the full machinery of validations and such is not run until later.
22
+ const rerender = useRerender();
23
+ useEffect(() => {
24
+ option.listenForChange(rerender);
25
+ return () => {
26
+ option.stopListenForChange(rerender);
27
+ };
28
+ }, [option, rerender]);
29
+ if (!isUseNumericValue) {
30
+ return null;
31
+ }
32
+ const { allowedNumericValues, numericValue, unit } = option;
33
+ if (allowedNumericValues === undefined) {
34
+ throw new Error("AllowedNumericValues undefined for numeric option");
35
+ }
36
+ if (numericValue === undefined) {
37
+ throw new Error("Numeric value not set for numeric option");
38
+ }
39
+ const { ranges } = allowedNumericValues;
40
+ const isSingleRange = ranges.length === 1;
41
+ if (isSingleRange && ranges[0] instanceof NumericValueDiscrete) {
42
+ return null;
43
+ }
44
+ return (React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent ${props.className || ""}`, style: props.style }, ranges.map((range) => (React.createElement(NumericValueView, { currentValue: numericValue, unit: unit, range: range, key: range.first, hasNoSiblings: isSingleRange, updateValue: (value, commit) => __awaiter(void 0, void 0, void 0, function* () { return yield option.setNumericValue(value, commit); }) })))));
45
+ };
46
+ /**
47
+ * Displays GUI for selecting in one "range". Please note that the range
48
+ * parameter can also be a discrete value.
49
+ */
50
+ export const NumericValueView = (props) => {
51
+ const { range, currentValue, updateValue, hasNoSiblings } = props;
52
+ const { legend, first } = range;
53
+ const selected = range.includesValue(currentValue);
54
+ const optionClasses = selected ? "cfgFeatureItemOption--checked" : "";
55
+ const uniqueId = useUuid();
56
+ const [inputValue, setInputValue] = useState(first);
57
+ const [inputCommited, setInputCommited] = useState(true);
58
+ const [showRangeError, setShowRangeError] = useState(false);
59
+ if (inputCommited && inputValue !== currentValue && range.includesValue(currentValue)) {
60
+ setInputValue(currentValue);
61
+ }
62
+ function isAcceptableValue(value) {
63
+ return !isNaN(value) && range.includesValue(value);
64
+ }
65
+ return (React.createElement("li", { className: `cfgFeatureItem cfgMb1 ${hasNoSiblings ? "" : "cfgMt1"}` },
66
+ !hasNoSiblings && (React.createElement("label", { className: `cfgFeatureItemOption ${optionClasses}`, htmlFor: uniqueId },
67
+ React.createElement("input", { checked: selected, className: "cfgFeatureItem__hiddenInput", id: uniqueId, name: uniqueId, onChange: (event) => {
68
+ if (event.target.checked) {
69
+ updateValue(inputValue, true);
70
+ }
71
+ }, type: "radio", value: first }),
72
+ React.createElement("div", { className: "cfgFeatureItem__radio" }, selected && React.createElement(Checkmark, null)),
73
+ React.createElement("div", { className: "cfgFeatureItemOption__titleWrapper" },
74
+ React.createElement("div", { className: "cfgFeatureItemOption__title" }, legend)))),
75
+ selected && range instanceof NumericValueRangeDefinition && (React.createElement(RangeView, Object.assign({}, props, { className: hasNoSiblings ? undefined : "cfgOptionTree--indent", range: range, onChange: (val, instantUpdate) => {
76
+ setInputValue(val);
77
+ if (!isAcceptableValue(inputValue)) {
78
+ return;
79
+ }
80
+ if (instantUpdate) {
81
+ updateValue(val, false);
82
+ }
83
+ setShowRangeError(false);
84
+ setInputCommited(false);
85
+ }, onCommit: () => {
86
+ if (inputCommited) {
87
+ return;
88
+ }
89
+ if (!isAcceptableValue(inputValue)) {
90
+ setShowRangeError(true);
91
+ return;
92
+ }
93
+ updateValue(inputValue, true);
94
+ setShowRangeError(false);
95
+ setInputCommited(true);
96
+ }, inputValue: inputValue, showRangeError: showRangeError })))));
97
+ };
98
+ export const RangeView = (props) => {
99
+ const { currentValue, unit, inputValue, range, onChange, onCommit, showRangeError } = props;
100
+ const { minValue, maxValue, increment, legend } = range;
101
+ const getOnChange = (instant) => (event) => onChange(event.currentTarget.valueAsNumber, instant);
102
+ const inputProps = {
103
+ min: minValue,
104
+ max: maxValue,
105
+ step: increment || Math.pow(10, Math.round(Math.log10(maxValue - minValue)) - 3),
106
+ onBlur: onCommit,
107
+ onMouseUp: onCommit,
108
+ };
109
+ return (React.createElement("div", { className: `cfgRangeView cfgMt1 ${props.className || ""}`, style: props.style },
110
+ React.createElement("input", Object.assign({}, inputProps, { type: "number", value: isNaN(inputValue) ? "" : inputValue, onChange: getOnChange(false), className: "cfgRangeView__number-input" })),
111
+ React.createElement("span", { className: "cfgRangeView__unit-label" }, unit),
112
+ React.createElement("input", Object.assign({}, inputProps, { type: "range", className: "cfgSlider cfgRangeView__slider-input", value: currentValue, onChange: getOnChange(true) })),
113
+ showRangeError && React.createElement("div", null,
114
+ "Value not allowed, allowed values are ",
115
+ legend)));
116
+ };
@@ -1,10 +1,10 @@
1
- import { CfgOption } from "@configura/web-api";
2
- import React from "react";
3
- import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
4
- declare type Props = {
5
- option: CfgOption;
6
- upchargeDisplayMode: UpchargeDisplayMode | undefined;
7
- };
8
- export declare const CfgOptionPriceView: React.FC<Props>;
9
- export {};
1
+ import { CfgOption } from "@configura/web-api";
2
+ import React from "react";
3
+ import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
4
+ declare type Props = {
5
+ option: CfgOption;
6
+ upchargeDisplayMode: UpchargeDisplayMode | undefined;
7
+ };
8
+ export declare const CfgOptionPriceView: React.FC<Props>;
9
+ export {};
10
10
  //# sourceMappingURL=CfgOptionPriceView.d.ts.map
@@ -1,29 +1,29 @@
1
- import React from "react";
2
- import { CurrencyPrice } from "../CurrencyPrice.js";
3
- import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
4
- export const CfgOptionPriceView = (props) => {
5
- const { option, upchargeDisplayMode } = props;
6
- const { currency, fractionDigits, lang } = option.parentProduct;
7
- if (currency === "") {
8
- return null;
9
- }
10
- switch (upchargeDisplayMode) {
11
- case UpchargeDisplayMode.None:
12
- return null;
13
- case UpchargeDisplayMode.Price:
14
- const { upcharge } = option;
15
- if (upcharge === undefined || upcharge === 0) {
16
- return null;
17
- }
18
- return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
19
- React.createElement(CurrencyPrice, { currency: currency, language: lang, price: upcharge, fractionDigits: fractionDigits })));
20
- default:
21
- const { priceChangeAtSelectChange } = option;
22
- if (priceChangeAtSelectChange === undefined || priceChangeAtSelectChange === 0) {
23
- return null;
24
- }
25
- return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
26
- priceChangeAtSelectChange < 0 ? "-" : "+",
27
- React.createElement(CurrencyPrice, { currency: currency, language: lang, price: Math.abs(priceChangeAtSelectChange), fractionDigits: fractionDigits })));
28
- }
29
- };
1
+ import React from "react";
2
+ import { CurrencyPrice } from "../CurrencyPrice.js";
3
+ import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
4
+ export const CfgOptionPriceView = (props) => {
5
+ const { option, upchargeDisplayMode } = props;
6
+ const { currency, fractionDigits, lang } = option.parentProduct;
7
+ if (currency === "") {
8
+ return null;
9
+ }
10
+ switch (upchargeDisplayMode) {
11
+ case UpchargeDisplayMode.None:
12
+ return null;
13
+ case UpchargeDisplayMode.Price:
14
+ const { upcharge } = option;
15
+ if (upcharge === undefined || upcharge === 0) {
16
+ return null;
17
+ }
18
+ return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
19
+ React.createElement(CurrencyPrice, { currency: currency, language: lang, price: upcharge, fractionDigits: fractionDigits })));
20
+ default:
21
+ const { priceChangeAtSelectChange } = option;
22
+ if (priceChangeAtSelectChange === undefined || priceChangeAtSelectChange === 0) {
23
+ return null;
24
+ }
25
+ return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
26
+ priceChangeAtSelectChange < 0 ? "-" : "+",
27
+ React.createElement(CurrencyPrice, { currency: currency, language: lang, price: Math.abs(priceChangeAtSelectChange), fractionDigits: fractionDigits })));
28
+ }
29
+ };
@@ -1,19 +1,19 @@
1
- import { CfgProduct, CfgProductConfiguration } from "@configura/web-api";
2
- import React from "react";
3
- import { CssProps } from "../../utilities.js";
4
- import { CfgProductConfigurationComponentAndPassthroughProps } from "./CfgFeatureView.js";
5
- export declare enum UpchargeDisplayMode {
6
- SelectionImpact = 0,
7
- None = 1,
8
- Price = 2
9
- }
10
- export declare type PassthroughProps = {
11
- upchargeDisplayMode?: UpchargeDisplayMode;
12
- };
13
- declare type Props = PassthroughProps & {
14
- productOrConfiguration: CfgProductConfiguration | CfgProduct;
15
- permanentlyExpandedAdditionalProductLevels?: number;
16
- };
17
- export declare const CfgProductConfigurationView: React.FC<Props & CfgProductConfigurationComponentAndPassthroughProps & CssProps>;
18
- export {};
1
+ import { CfgProduct, CfgProductConfiguration } from "@configura/web-api";
2
+ import React from "react";
3
+ import { CssProps } from "../../utilities.js";
4
+ import { CfgProductConfigurationComponentAndPassthroughProps } from "./CfgFeatureView.js";
5
+ export declare enum UpchargeDisplayMode {
6
+ SelectionImpact = 0,
7
+ None = 1,
8
+ Price = 2
9
+ }
10
+ export declare type PassthroughProps = {
11
+ upchargeDisplayMode?: UpchargeDisplayMode;
12
+ };
13
+ declare type Props = PassthroughProps & {
14
+ productOrConfiguration: CfgProductConfiguration | CfgProduct;
15
+ permanentlyExpandedAdditionalProductLevels?: number;
16
+ };
17
+ export declare const CfgProductConfigurationView: React.FC<Props & CfgProductConfigurationComponentAndPassthroughProps & CssProps>;
18
+ export {};
19
19
  //# sourceMappingURL=CfgProductConfigurationView.d.ts.map