@ordergroove/offers 2.28.9 → 2.28.11-alpha-PR-703-17.87
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 +11 -0
- package/README.md +1 -0
- package/dist/bundle-report.html +48 -45
- package/dist/examples.js +261 -105
- package/dist/examples.js.map +2 -2
- package/dist/offers.js +69 -35
- package/dist/offers.js.map +3 -3
- package/examples/index.js +213 -217
- package/package.json +2 -2
- package/src/components/Modal.js +3 -3
- package/src/components/PrepaidToggle.js +100 -0
- package/src/components/Select.js +1 -1
- package/src/components/__tests__/PrepaidToggle.spec.js +113 -0
- package/src/core/__tests__/descriptors.spec.js +56 -0
- package/src/core/__tests__/reducer.spec.js +79 -0
- package/src/core/actions.js +5 -0
- package/src/core/constants.js +1 -0
- package/src/core/descriptors.js +7 -1
- package/src/core/reducer.js +19 -12
- package/src/core/selectors.js +13 -0
- package/src/core/utils.ts +16 -0
- package/src/make-api.js +2 -0
- package/src/shopify/__tests__/shopifyReducer.spec.js +113 -0
- package/src/shopify/shopifyMiddleware.ts +3 -0
- package/src/shopify/shopifyReducer.js +58 -6
package/examples/index.js
CHANGED
|
@@ -63,162 +63,158 @@ const textCopy = {
|
|
|
63
63
|
defaultFrequencyCopy: '(Recommended)'
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...settings,
|
|
93
|
-
offerType: 'toggle'
|
|
94
|
-
},
|
|
95
|
-
textCopy: {
|
|
96
|
-
...textCopy
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'select',
|
|
102
|
-
selector: 'og-offer[location="initial-select"]',
|
|
103
|
-
id: '4',
|
|
104
|
-
config: {
|
|
105
|
-
settings: {
|
|
106
|
-
...settings,
|
|
107
|
-
offerType: 'select'
|
|
108
|
-
},
|
|
109
|
-
textCopy: { ...textCopy }
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: 'cart',
|
|
114
|
-
selector: 'og-offer[location="cart"]',
|
|
115
|
-
id: '5',
|
|
116
|
-
defaultPreviewMode: 'subscribed',
|
|
117
|
-
config: {
|
|
118
|
-
settings: {
|
|
119
|
-
...settings,
|
|
120
|
-
offerType: 'cart'
|
|
121
|
-
},
|
|
122
|
-
textCopy: { ...textCopy }
|
|
66
|
+
const offersExamples = [
|
|
67
|
+
{
|
|
68
|
+
name: 'empty',
|
|
69
|
+
selector: 'og-offer:not([location])'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'built-in',
|
|
73
|
+
selector: 'og-offer[location="initial"]',
|
|
74
|
+
config: {
|
|
75
|
+
settings: {
|
|
76
|
+
...settings,
|
|
77
|
+
offerType: 'radio'
|
|
78
|
+
},
|
|
79
|
+
textCopy: { ...textCopy }
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'checkbox',
|
|
84
|
+
selector: 'og-offer[location="initial-checkbox"]',
|
|
85
|
+
config: {
|
|
86
|
+
settings: {
|
|
87
|
+
...settings,
|
|
88
|
+
offerType: 'toggle'
|
|
89
|
+
},
|
|
90
|
+
textCopy: {
|
|
91
|
+
...textCopy
|
|
123
92
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'select',
|
|
97
|
+
selector: 'og-offer[location="initial-select"]',
|
|
98
|
+
config: {
|
|
99
|
+
settings: {
|
|
100
|
+
...settings,
|
|
101
|
+
offerType: 'select'
|
|
102
|
+
},
|
|
103
|
+
textCopy: { ...textCopy }
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'cart',
|
|
108
|
+
selector: 'og-offer[location="cart"]',
|
|
109
|
+
defaultPreviewMode: 'subscribed',
|
|
110
|
+
config: {
|
|
111
|
+
settings: {
|
|
112
|
+
...settings,
|
|
113
|
+
offerType: 'cart'
|
|
114
|
+
},
|
|
115
|
+
textCopy: { ...textCopy }
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'side-by-side',
|
|
120
|
+
selector: 'og-offer[location="side-by-side"]',
|
|
121
|
+
config: {
|
|
122
|
+
settings: {
|
|
123
|
+
...settings,
|
|
124
|
+
offerType: 'side-by-side'
|
|
125
|
+
},
|
|
126
|
+
textCopy: { ...textCopy },
|
|
127
|
+
styles: {
|
|
128
|
+
primaryColor: 'navy',
|
|
129
|
+
defaultColor: 'pink'
|
|
139
130
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'read-only',
|
|
135
|
+
selector: 'og-offer[location="read-only"]',
|
|
136
|
+
defaultPreviewMode: 'subscribed',
|
|
137
|
+
config: {
|
|
138
|
+
settings: {
|
|
139
|
+
...settings,
|
|
140
|
+
offerType: 'read-only'
|
|
141
|
+
},
|
|
142
|
+
textCopy: { ...textCopy },
|
|
143
|
+
styles: {
|
|
144
|
+
primaryColor: 'navy',
|
|
145
|
+
defaultColor: 'pink'
|
|
156
146
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'buttons',
|
|
151
|
+
selector: 'og-offer[location="buttons"]',
|
|
152
|
+
config: {
|
|
153
|
+
settings: {
|
|
154
|
+
...settings,
|
|
155
|
+
offerType: 'buttons'
|
|
156
|
+
},
|
|
157
|
+
textCopy: { ...textCopy },
|
|
158
|
+
styles: {
|
|
159
|
+
primaryColor: 'navy',
|
|
160
|
+
defaultColor: 'pink'
|
|
172
161
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
settings
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'Prepaid',
|
|
166
|
+
selector: 'og-offer[location="initial"]',
|
|
167
|
+
config: {
|
|
168
|
+
settings: {
|
|
169
|
+
...settings,
|
|
170
|
+
offerType: 'prepaid-enabled-radio'
|
|
171
|
+
},
|
|
172
|
+
textCopy: { ...textCopy }
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'first-test',
|
|
177
|
+
selector: 'og-offer[location="first-test"]',
|
|
178
|
+
config: {
|
|
179
|
+
settings: {
|
|
180
|
+
...settings,
|
|
181
|
+
offerType: 'toggle'
|
|
182
|
+
},
|
|
183
|
+
textCopy: {
|
|
184
|
+
...textCopy,
|
|
185
|
+
offerOptOutLabel: '1st offerOptOutLabel'
|
|
188
186
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: 'second-test no tooltip',
|
|
191
|
+
selector: 'og-offer[location="second-test"]',
|
|
192
|
+
config: {
|
|
193
|
+
settings: {
|
|
194
|
+
...settings,
|
|
195
|
+
offerType: 'radio'
|
|
196
|
+
},
|
|
197
|
+
textCopy: {
|
|
198
|
+
...textCopy,
|
|
199
|
+
showTooltip: false,
|
|
200
|
+
offerOptOutLabel: '2st offerOptOutLabel'
|
|
204
201
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'Select mode',
|
|
206
|
+
selector: 'og-offer[location="select1"]',
|
|
207
|
+
markup: `
|
|
211
208
|
<og-optin-select>
|
|
212
209
|
<option value="optedOut">Buy one time</option>
|
|
213
210
|
<option value="2w" selected>2 weeks (recomended)</option>
|
|
214
211
|
<option value="1m">1 month </option>
|
|
215
212
|
</og-optin-select>`
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
markup: `
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'Custom markup',
|
|
216
|
+
selector: 'og-offer[location="custom1"]',
|
|
217
|
+
markup: `
|
|
222
218
|
<og-when test="regularEligible">
|
|
223
219
|
<p>
|
|
224
220
|
<og-optout-button>Buy one time</og-optout-button>
|
|
@@ -266,13 +262,12 @@ Add item to order on
|
|
|
266
262
|
<span slot="cancel">cancel</span>
|
|
267
263
|
</og-upsell-modal>
|
|
268
264
|
</og-when>`
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
markup: `
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: 'Upsell modal - radio',
|
|
268
|
+
defaultPreviewMode: 'upsell',
|
|
269
|
+
selector: 'og-offer[location="upsell-radio"]',
|
|
270
|
+
markup: `
|
|
276
271
|
<og-when test="upsellEligible">
|
|
277
272
|
<og-upsell-button target="#upsell-radio">
|
|
278
273
|
<a href="#">Add item to next order via radio</a>
|
|
@@ -291,13 +286,12 @@ Add item to order on
|
|
|
291
286
|
</p>
|
|
292
287
|
</og-upsell-modal>
|
|
293
288
|
</og-when>`
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
markup: `
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: 'Upsell modal - select',
|
|
292
|
+
defaultPreviewMode: 'upsell',
|
|
293
|
+
selector: 'og-offer[location="upsell-select"]',
|
|
294
|
+
markup: `
|
|
301
295
|
<og-when test="upsellEligible">
|
|
302
296
|
<og-upsell-button target="#upsell-select">
|
|
303
297
|
<a href="#">Add item to next order via select</a>
|
|
@@ -306,13 +300,12 @@ Add item to order on
|
|
|
306
300
|
<og-optin-select></og-optin-select>
|
|
307
301
|
</og-upsell-modal>
|
|
308
302
|
</og-when>`
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
markup: `
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: 'Upsell modal - toggle',
|
|
306
|
+
defaultPreviewMode: 'upsell',
|
|
307
|
+
selector: 'og-offer[location="upsell-toggle"]',
|
|
308
|
+
markup: `
|
|
316
309
|
<og-when test="upsellEligible">
|
|
317
310
|
<og-upsell-button target="#upsell-toggle">
|
|
318
311
|
<a href="#">Add item to next order via toggle</a>
|
|
@@ -325,13 +318,12 @@ Add item to order on
|
|
|
325
318
|
<span slot="cancel">Nope</span>
|
|
326
319
|
</og-upsell-modal>
|
|
327
320
|
</og-when>
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
markup: `
|
|
321
|
+
`
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: 'Product-specific default frequencies',
|
|
325
|
+
selector: 'og-offer[location="psdf"]',
|
|
326
|
+
markup: `
|
|
335
327
|
<og-when test="regularEligible">
|
|
336
328
|
<og-select-frequency default-text=" Most common!">
|
|
337
329
|
<option value="1w">1 week</option>
|
|
@@ -339,56 +331,60 @@ Add item to order on
|
|
|
339
331
|
<option value="3w">3 weeks</option>
|
|
340
332
|
</og-select-frequency>
|
|
341
333
|
</og-when>
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
markup: `
|
|
334
|
+
`
|
|
335
|
+
}
|
|
336
|
+
];
|
|
337
|
+
|
|
338
|
+
const componentExamples = [
|
|
339
|
+
{
|
|
340
|
+
name: 'og-optin-button',
|
|
341
|
+
selector: 'og-offer[location=og-optin-button]',
|
|
342
|
+
markup: `
|
|
352
343
|
<og-optin-button>
|
|
353
344
|
I want to subscribe to this product
|
|
354
345
|
</og-optin-button>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
markup: `
|
|
346
|
+
`
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: 'Frequency Status',
|
|
350
|
+
selector: 'og-offer[location="frequency"]',
|
|
351
|
+
markup: `
|
|
362
352
|
<og-frequency-status>
|
|
363
353
|
<span slot="not-subscribed">you are not subscribed </span>
|
|
364
354
|
</og-frequency-status>`
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
it
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: 'Tooltip',
|
|
358
|
+
selector: 'og-offer[location="tooltip-placement"]',
|
|
359
|
+
markup: [
|
|
360
|
+
['top-left', 'top', 'top-right'],
|
|
361
|
+
['left', '', 'right'],
|
|
362
|
+
['bottom-left', 'bottom', 'bottom-right']
|
|
363
|
+
]
|
|
364
|
+
.map(options =>
|
|
365
|
+
options
|
|
366
|
+
.map(
|
|
367
|
+
it =>
|
|
368
|
+
`<span class="tooltip-example">${
|
|
369
|
+
it
|
|
370
|
+
? `<og-tooltip placement="${it}" style="width:100%">
|
|
371
|
+
<div slot="trigger">${it}</div>
|
|
372
|
+
<div slot="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
|
|
373
|
+
</og-tooltip>`
|
|
374
|
+
: ' '
|
|
375
|
+
}</span>`
|
|
376
|
+
)
|
|
377
|
+
.join('\n')
|
|
378
|
+
)
|
|
379
|
+
.join('<br>\n')
|
|
380
|
+
}
|
|
381
|
+
];
|
|
382
|
+
|
|
383
|
+
const exampleTemplates = [
|
|
384
|
+
['Offers example', ...offersExamples.map((x, idx) => ({ ...x, id: idx.toString() }))],
|
|
385
|
+
[
|
|
386
|
+
'Individual components',
|
|
387
|
+
...componentExamples.map((x, idx) => ({ ...x, id: (idx + offersExamples.length).toString() }))
|
|
392
388
|
]
|
|
393
389
|
];
|
|
394
390
|
function updateTemplate(target) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.28.
|
|
3
|
+
"version": "2.28.11-alpha-PR-703-17.87+e0434fb5",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@ordergroove/offers-templates": "^0.4.20"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "e0434fb512e57c225bc1a957163e8a57bbda1418"
|
|
51
51
|
}
|
package/src/components/Modal.js
CHANGED
|
@@ -51,11 +51,11 @@ export class Modal extends LitElement {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
.og-modal__container {
|
|
54
|
-
background-color: #fff;
|
|
55
|
-
padding: 30px;
|
|
54
|
+
background-color: var(--og-modal-background-color, #fff);
|
|
55
|
+
padding: var(--og-modal-padding, 30px);
|
|
56
56
|
max-width: 500px;
|
|
57
57
|
max-height: 100vh;
|
|
58
|
-
border-radius: 4px;
|
|
58
|
+
border-radius: var(--og-modal-border-radius, 4px);
|
|
59
59
|
box-sizing: border-box;
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit-element';
|
|
2
|
+
import { connect } from '../core/connect';
|
|
3
|
+
import { makeProductPrepaidShipmentsSelector } from '../core/selectors';
|
|
4
|
+
import { productChangePrepaidShipments } from '../core/actions';
|
|
5
|
+
import { withProduct } from '../core/resolveProperties';
|
|
6
|
+
|
|
7
|
+
export class PrepaidToggle extends withProduct(LitElement) {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this._selectedOption = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static get properties() {
|
|
14
|
+
return {
|
|
15
|
+
shipments: { type: Number }
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// copied from SelectFrequency
|
|
20
|
+
static get styles() {
|
|
21
|
+
return css`
|
|
22
|
+
og-select {
|
|
23
|
+
display: inline-block;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
background-color: #fff;
|
|
26
|
+
border: var(--og-select-border, 1px solid #aaa);
|
|
27
|
+
border-width: var(--og-select-border-width, 1px);
|
|
28
|
+
box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.04);
|
|
29
|
+
z-index: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
input {
|
|
33
|
+
width: 1.2em;
|
|
34
|
+
height: 1.2em;
|
|
35
|
+
accent-color: black;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get childOptions() {
|
|
42
|
+
const options = Array.from(this.querySelectorAll('option'));
|
|
43
|
+
return options.map(option => ({
|
|
44
|
+
value: +option.value,
|
|
45
|
+
text: option.text || `${option.value} shipments`
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get checked() {
|
|
50
|
+
return this.shipments > 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
handleChange(e) {
|
|
54
|
+
if (e.target.checked) {
|
|
55
|
+
const selectedShipments = this._selectedOption || +this.querySelector('option').value;
|
|
56
|
+
this.productChangePrepaidShipments(this.product, selectedShipments, this.offer);
|
|
57
|
+
} else {
|
|
58
|
+
this.productChangePrepaidShipments(this.product, null, this.offer);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
handleSelect({ target: { value } }) {
|
|
63
|
+
const valueAsNumber = +value;
|
|
64
|
+
// keep track of selected option so that checking the checkbox opts them into the currently selected value in the dropdown
|
|
65
|
+
// this only happens if they opt-out then opt back in.
|
|
66
|
+
this._selectedOption = valueAsNumber;
|
|
67
|
+
this.productChangePrepaidShipments(this.product, valueAsNumber, this.offer);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
render() {
|
|
71
|
+
return html`
|
|
72
|
+
<div>
|
|
73
|
+
<input id="cbx" type="checkbox" .checked=${this.checked} @change=${this.handleChange} />
|
|
74
|
+
<label for="cbx">
|
|
75
|
+
<slot name="label">Prepay for</slot>
|
|
76
|
+
${this.childOptions.length > 1
|
|
77
|
+
? html`
|
|
78
|
+
<og-select
|
|
79
|
+
.options=${this.childOptions}
|
|
80
|
+
.selected=${this._selectedOption || this.shipments}
|
|
81
|
+
.onChange="${e => this.handleSelect(e)}"
|
|
82
|
+
></og-select>
|
|
83
|
+
`
|
|
84
|
+
: html`
|
|
85
|
+
<span>${this.childOptions[0].text}</span>
|
|
86
|
+
`}
|
|
87
|
+
<slot name="append"></slot>
|
|
88
|
+
</label>
|
|
89
|
+
</div>
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const mapStateToProps = (state, ownProps) => ({
|
|
95
|
+
shipments: makeProductPrepaidShipmentsSelector(ownProps.product)(state)
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const ConnectedPrepaidToggle = connect(mapStateToProps, { productChangePrepaidShipments })(PrepaidToggle);
|
|
99
|
+
|
|
100
|
+
export { ConnectedPrepaidToggle };
|
package/src/components/Select.js
CHANGED
|
@@ -70,7 +70,7 @@ export class Select extends LitElement {
|
|
|
70
70
|
<select @change="${handleOnChange}">
|
|
71
71
|
${this.options.map(
|
|
72
72
|
option => html`
|
|
73
|
-
<option value="${option.value}"
|
|
73
|
+
<option value="${option.value}" .selected=${option.value === this.selected}>${option.text}</option>
|
|
74
74
|
`
|
|
75
75
|
)}
|
|
76
76
|
</select>
|