@searchspring/snap-preact-components 0.67.5 → 0.69.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.
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ComponentProps } from '../../../types';
2
+ import { ComponentProps, ListOption } from '../../../types';
3
3
  import type { VariantSelection as VariantSelectionType } from '@searchspring/snap-store-mobx';
4
4
  export declare const VariantSelection: (properties: VariantSelectionProps) => JSX.Element;
5
5
  export interface VariantSelectionProps extends ComponentProps {
6
6
  selection: VariantSelectionType;
7
7
  type?: 'dropdown' | 'swatches' | 'list';
8
+ onSelect?: (e: React.MouseEvent<HTMLElement, MouseEvent>, option: ListOption) => void;
8
9
  }
9
10
  //# sourceMappingURL=VariantSelection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VariantSelection.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/VariantSelection/VariantSelection.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAqD9F,eAAO,MAAM,gBAAgB,eAAyB,qBAAqB,KAAG,WAkK5E,CAAC;AASH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC5D,SAAS,EAAE,oBAAoB,CAAC;IAChC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;CACxC"}
1
+ {"version":3,"file":"VariantSelection.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/VariantSelection/VariantSelection.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAc,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAqD9F,eAAO,MAAM,gBAAgB,eAAyB,qBAAqB,KAAG,WAyK5E,CAAC;AASH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC5D,SAAS,EAAE,oBAAoB,CAAC;IAChC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACtF"}
@@ -73,7 +73,13 @@ exports.VariantSelection = (0, mobx_react_1.observer)(function (properties) {
73
73
  var props = __assign(__assign(__assign({
74
74
  // default props
75
75
  type: 'dropdown' }, (_a = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _a === void 0 ? void 0 : _a.variantSelection), properties), (_c = (_b = properties.theme) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.variantSelection);
76
- var type = props.type, selection = props.selection, disableStyles = props.disableStyles, className = props.className, style = props.style;
76
+ var type = props.type, selection = props.selection, onSelect = props.onSelect, disableStyles = props.disableStyles, className = props.className, style = props.style;
77
+ var onSelectHandler = function (e, option) {
78
+ if (onSelect) {
79
+ onSelect(e, option);
80
+ }
81
+ selection.select(option.value);
82
+ };
77
83
  var subProps = {
78
84
  dropdown: __assign(__assign(__assign({ name: "ss__variant-selection__dropdown--".concat(selection.field), className: 'ss__variant-selection__dropdown', label: selection.label || selection.field }, (_d = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _d === void 0 ? void 0 : _d.dropdown), (0, utilities_1.defined)({
79
85
  disableStyles: disableStyles,
@@ -87,12 +93,12 @@ exports.VariantSelection = (0, mobx_react_1.observer)(function (properties) {
87
93
  })), {
88
94
  // component theme overrides
89
95
  theme: props === null || props === void 0 ? void 0 : props.theme }),
90
- list: __assign(__assign(__assign({ name: "ss__variant-selection__list--".concat(selection.field), titleText: selection.field, className: 'ss__variant-selection__list', multiSelect: false, hideOptionCheckboxes: true, onSelect: function (e, option) { return selection.select(option.value); }, selected: selection.selected }, (_f = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _f === void 0 ? void 0 : _f.list), (0, utilities_1.defined)({
96
+ list: __assign(__assign(__assign({ name: "ss__variant-selection__list--".concat(selection.field), titleText: selection.field, className: 'ss__variant-selection__list', multiSelect: false, hideOptionCheckboxes: true, onSelect: function (e, option) { return onSelectHandler(e, option); }, selected: selection.selected }, (_f = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _f === void 0 ? void 0 : _f.list), (0, utilities_1.defined)({
91
97
  disableStyles: disableStyles,
92
98
  })), {
93
99
  // component theme overrides
94
100
  theme: props === null || props === void 0 ? void 0 : props.theme }),
95
- swatches: __assign(__assign(__assign({ name: "ss__variant-selection__swatches--".concat(selection.field), className: 'ss__variant-selection__swatches', onSelect: function (e, option) { return selection.select(option.value); }, selected: selection.selected }, (_g = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _g === void 0 ? void 0 : _g.swatches), (0, utilities_1.defined)({
101
+ swatches: __assign(__assign(__assign({ name: "ss__variant-selection__swatches--".concat(selection.field), className: 'ss__variant-selection__swatches', onSelect: function (e, option) { return onSelectHandler(e, option); }, selected: selection.selected }, (_g = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _g === void 0 ? void 0 : _g.swatches), (0, utilities_1.defined)({
96
102
  disableStyles: disableStyles,
97
103
  })), {
98
104
  // component theme overrides
@@ -130,7 +136,7 @@ exports.VariantSelection = (0, mobx_react_1.observer)(function (properties) {
130
136
  'ss__variant-selection__option--selected': selected,
131
137
  'ss__variant-selection__option--disabled': val.disabled,
132
138
  'ss__variant-selection__option--unavailable': val.available === false,
133
- }), onClick: function () { return !val.disabled && selection.select(val.value); } }, val.label));
139
+ }), onClick: function (e) { return !val.disabled && onSelectHandler(e, val); } }, val.label));
134
140
  }))));
135
141
  })()));
136
142
  case 'list':
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ComponentProps } from '../../../types';
2
+ import { ComponentProps, ListOption } from '../../../types';
3
3
  import type { VariantSelection as VariantSelectionType } from '@searchspring/snap-store-mobx';
4
4
  export declare const VariantSelection: (properties: VariantSelectionProps) => JSX.Element;
5
5
  export interface VariantSelectionProps extends ComponentProps {
6
6
  selection: VariantSelectionType;
7
7
  type?: 'dropdown' | 'swatches' | 'list';
8
+ onSelect?: (e: React.MouseEvent<HTMLElement, MouseEvent>, option: ListOption) => void;
8
9
  }
9
10
  //# sourceMappingURL=VariantSelection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VariantSelection.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/VariantSelection/VariantSelection.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAqD9F,eAAO,MAAM,gBAAgB,eAAyB,qBAAqB,KAAG,WAkK5E,CAAC;AASH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC5D,SAAS,EAAE,oBAAoB,CAAC;IAChC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;CACxC"}
1
+ {"version":3,"file":"VariantSelection.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/VariantSelection/VariantSelection.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAc,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAqD9F,eAAO,MAAM,gBAAgB,eAAyB,qBAAqB,KAAG,WAyK5E,CAAC;AASH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC5D,SAAS,EAAE,oBAAoB,CAAC;IAChC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACtF"}
@@ -59,7 +59,13 @@ export const VariantSelection = observer((properties) => {
59
59
  ...properties,
60
60
  ...properties.theme?.components?.variantSelection,
61
61
  };
62
- const { type, selection, disableStyles, className, style } = props;
62
+ const { type, selection, onSelect, disableStyles, className, style } = props;
63
+ const onSelectHandler = (e, option) => {
64
+ if (onSelect) {
65
+ onSelect(e, option);
66
+ }
67
+ selection.select(option.value);
68
+ };
63
69
  const subProps = {
64
70
  dropdown: {
65
71
  name: `ss__variant-selection__dropdown--${selection.field}`,
@@ -94,7 +100,7 @@ export const VariantSelection = observer((properties) => {
94
100
  className: 'ss__variant-selection__list',
95
101
  multiSelect: false,
96
102
  hideOptionCheckboxes: true,
97
- onSelect: (e, option) => selection.select(option.value),
103
+ onSelect: (e, option) => onSelectHandler(e, option),
98
104
  selected: selection.selected,
99
105
  // global theme
100
106
  ...globalTheme?.components?.list,
@@ -108,7 +114,7 @@ export const VariantSelection = observer((properties) => {
108
114
  swatches: {
109
115
  name: `ss__variant-selection__swatches--${selection.field}`,
110
116
  className: 'ss__variant-selection__swatches',
111
- onSelect: (e, option) => selection.select(option.value),
117
+ onSelect: (e, option) => onSelectHandler(e, option),
112
118
  selected: selection.selected,
113
119
  // global theme
114
120
  ...globalTheme?.components?.swatches,
@@ -151,7 +157,7 @@ export const VariantSelection = observer((properties) => {
151
157
  'ss__variant-selection__option--selected': selected,
152
158
  'ss__variant-selection__option--disabled': val.disabled,
153
159
  'ss__variant-selection__option--unavailable': val.available === false,
154
- }), onClick: () => !val.disabled && selection.select(val.value) }, val.label));
160
+ }), onClick: (e) => !val.disabled && onSelectHandler(e, val) }, val.label));
155
161
  }))));
156
162
  })()));
157
163
  case 'list':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searchspring/snap-preact-components",
3
- "version": "0.67.5",
3
+ "version": "0.69.0",
4
4
  "description": "Snap Preact Component Library",
5
5
  "author": "Searchspring",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@cypress/react": "^8.0.0",
31
31
  "@emotion/react": "11.9.0",
32
- "@searchspring/snap-toolbox": "0.67.5",
32
+ "@searchspring/snap-toolbox": "0.69.0",
33
33
  "classnames": "^2.3.2",
34
34
  "cypress": "^13.7.1",
35
35
  "cypress-wait-until": "^1.7.2",
@@ -52,14 +52,14 @@
52
52
  "@babel/preset-env": "^7.21.4",
53
53
  "@babel/preset-react": "^7.18.6",
54
54
  "@babel/runtime": "^7.21.0",
55
- "@searchspring/snap-client": "0.67.5",
56
- "@searchspring/snap-controller": "0.67.5",
57
- "@searchspring/snap-event-manager": "0.67.5",
58
- "@searchspring/snap-logger": "0.67.5",
59
- "@searchspring/snap-profiler": "0.67.5",
60
- "@searchspring/snap-store-mobx": "0.67.5",
61
- "@searchspring/snap-tracker": "0.67.5",
62
- "@searchspring/snap-url-manager": "0.67.5",
55
+ "@searchspring/snap-client": "0.69.0",
56
+ "@searchspring/snap-controller": "0.69.0",
57
+ "@searchspring/snap-event-manager": "0.69.0",
58
+ "@searchspring/snap-logger": "0.69.0",
59
+ "@searchspring/snap-profiler": "0.69.0",
60
+ "@searchspring/snap-store-mobx": "0.69.0",
61
+ "@searchspring/snap-tracker": "0.69.0",
62
+ "@searchspring/snap-url-manager": "0.69.0",
63
63
  "@storybook/addon-actions": "6.4.22",
64
64
  "@storybook/addon-controls": "6.4.22",
65
65
  "@storybook/addon-docs": "6.4.22",
@@ -84,5 +84,5 @@
84
84
  "webpack-merge": "^5.8.0"
85
85
  },
86
86
  "sideEffects": false,
87
- "gitHead": "9d3779d4456c454bd73b5e601946298bd89089eb"
87
+ "gitHead": "446629f083776e15b1234fc36f597489795581ce"
88
88
  }