@rebuy/rebuy 3.22.0 → 3.23.0-rc.1
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/dist/index.cjs +78 -15
- package/dist/index.mjs +78 -15
- package/dist/schema/widgets/checkout-and-beyond/variables.d.ts +5 -3
- package/dist/server/index.cjs +78 -15
- package/dist/server/index.mjs +78 -15
- package/dist/transforms/index.cjs +78 -15
- package/dist/transforms/index.mjs +78 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4652,16 +4652,35 @@ var buildPrice = () => ({
|
|
|
4652
4652
|
content: { en: buildPriceContent() },
|
|
4653
4653
|
sectionType: "text"
|
|
4654
4654
|
});
|
|
4655
|
+
var HAS_VARIANT_TITLE = "hasVariantTitle";
|
|
4655
4656
|
var buildVariantTitle = (settings) => {
|
|
4656
4657
|
const show = settings.productOptions?.showVariantTitle;
|
|
4657
4658
|
if (!show || show === "hide") return [];
|
|
4658
4659
|
return [
|
|
4659
4660
|
{
|
|
4660
4661
|
content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
|
|
4661
|
-
|
|
4662
|
+
mutators: [
|
|
4663
|
+
{ effect: "set_false", variable: HAS_VARIANT_TITLE, when: { operator: "is_empty", type: "content" } },
|
|
4664
|
+
{
|
|
4665
|
+
effect: "set_true",
|
|
4666
|
+
variable: HAS_VARIANT_TITLE,
|
|
4667
|
+
when: { operator: "is_not_empty", type: "content" }
|
|
4668
|
+
}
|
|
4669
|
+
],
|
|
4670
|
+
sectionType: "text",
|
|
4671
|
+
visibility: { variable: HAS_VARIANT_TITLE, visibleWhen: true }
|
|
4662
4672
|
}
|
|
4663
4673
|
];
|
|
4664
4674
|
};
|
|
4675
|
+
var detailBlock = (sections, horizontal, hasVariantTitleLine) => ({
|
|
4676
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
4677
|
+
direction: "rows",
|
|
4678
|
+
name: "detail",
|
|
4679
|
+
sections,
|
|
4680
|
+
sectionType: "layout",
|
|
4681
|
+
spacing: "none",
|
|
4682
|
+
...hasVariantTitleLine && { variables: [{ defaultValue: false, name: HAS_VARIANT_TITLE }] }
|
|
4683
|
+
});
|
|
4665
4684
|
var SHOW_DESCRIPTION = "showDescription";
|
|
4666
4685
|
var HAS_DESCRIPTION = "hasDescription";
|
|
4667
4686
|
var buildDescription = (settings) => {
|
|
@@ -4704,6 +4723,14 @@ var buildDescription = (settings) => {
|
|
|
4704
4723
|
}
|
|
4705
4724
|
];
|
|
4706
4725
|
};
|
|
4726
|
+
var SHOW_VARIANTS = "showVariants";
|
|
4727
|
+
var REVEAL_PENDING = "revealPending";
|
|
4728
|
+
var revealsVariants = (settings) => settings.viewOptions?.displayActions !== false && settings.productOptions?.showVariantOptions === "default";
|
|
4729
|
+
var contentMutator = (effect, variable, operator) => ({
|
|
4730
|
+
effect,
|
|
4731
|
+
variable,
|
|
4732
|
+
when: { operator, type: "content" }
|
|
4733
|
+
});
|
|
4707
4734
|
var buildVariants = (settings) => {
|
|
4708
4735
|
if (settings.viewOptions?.displayActions === false) return [];
|
|
4709
4736
|
if (settings.productOptions?.showVariantOptions === "never") return [];
|
|
@@ -4711,8 +4738,16 @@ var buildVariants = (settings) => {
|
|
|
4711
4738
|
return [
|
|
4712
4739
|
{
|
|
4713
4740
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
4741
|
+
...revealsVariants(settings) && {
|
|
4742
|
+
mutators: [
|
|
4743
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
4744
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty")
|
|
4745
|
+
]
|
|
4746
|
+
},
|
|
4714
4747
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
4715
|
-
sectionType: "variants"
|
|
4748
|
+
sectionType: "variants",
|
|
4749
|
+
variantMode: "single",
|
|
4750
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
4716
4751
|
}
|
|
4717
4752
|
];
|
|
4718
4753
|
};
|
|
@@ -4769,8 +4804,25 @@ var buildSubscriptionButton = (settings) => {
|
|
|
4769
4804
|
];
|
|
4770
4805
|
};
|
|
4771
4806
|
var BUTTON_KINDS = ["plain", "primary", "secondary"];
|
|
4772
|
-
var
|
|
4807
|
+
var buttonKind = (settings) => {
|
|
4773
4808
|
const kind = settings.button?.kind;
|
|
4809
|
+
return BUTTON_KINDS.includes(kind) ? kind : "primary";
|
|
4810
|
+
};
|
|
4811
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
4812
|
+
{
|
|
4813
|
+
buttonStyle: buttonKind(settings),
|
|
4814
|
+
sections: [
|
|
4815
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
4816
|
+
],
|
|
4817
|
+
sectionType: "button",
|
|
4818
|
+
variableEffects: [
|
|
4819
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
4820
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
4821
|
+
],
|
|
4822
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
4823
|
+
}
|
|
4824
|
+
] : [];
|
|
4825
|
+
var buildAddButton = (settings) => {
|
|
4774
4826
|
const slot = (buttonField, override) => ({
|
|
4775
4827
|
buttonField,
|
|
4776
4828
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -4778,7 +4830,7 @@ var buildAddButton = (settings) => {
|
|
|
4778
4830
|
});
|
|
4779
4831
|
return {
|
|
4780
4832
|
action: "addToOrder",
|
|
4781
|
-
buttonStyle:
|
|
4833
|
+
buttonStyle: buttonKind(settings),
|
|
4782
4834
|
sections: [
|
|
4783
4835
|
slot("addToCart", settings.language?.addToCart),
|
|
4784
4836
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -4787,14 +4839,10 @@ var buildAddButton = (settings) => {
|
|
|
4787
4839
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
4788
4840
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
4789
4841
|
],
|
|
4790
|
-
sectionType: "button"
|
|
4842
|
+
sectionType: "button",
|
|
4843
|
+
...revealsVariants(settings) && { visibility: { variable: REVEAL_PENDING, visibleWhen: false } }
|
|
4791
4844
|
};
|
|
4792
4845
|
};
|
|
4793
|
-
var rowsLayout = (sections) => ({
|
|
4794
|
-
direction: "rows",
|
|
4795
|
-
sections,
|
|
4796
|
-
sectionType: "layout"
|
|
4797
|
-
});
|
|
4798
4846
|
var buildOfferCard = (settings, horizontal) => {
|
|
4799
4847
|
const image = buildImage(settings);
|
|
4800
4848
|
const title = buildTitle(settings);
|
|
@@ -4805,18 +4853,33 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
4805
4853
|
const variants = buildVariants(settings);
|
|
4806
4854
|
const quantity = buildQuantity(settings);
|
|
4807
4855
|
const subscription = buildSubscriptionButton(settings);
|
|
4856
|
+
const reveal = buildRevealButton(settings);
|
|
4808
4857
|
const addButton = buildAddButton(settings);
|
|
4809
4858
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
4810
|
-
|
|
4811
|
-
const
|
|
4812
|
-
|
|
4859
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
4860
|
+
const card = (sections) => [
|
|
4861
|
+
{
|
|
4862
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
4863
|
+
direction: "rows",
|
|
4864
|
+
name: "card",
|
|
4865
|
+
sections,
|
|
4866
|
+
sectionType: "layout",
|
|
4867
|
+
spacing: "base",
|
|
4868
|
+
...revealsVariants(settings) && {
|
|
4869
|
+
variables: [SHOW_VARIANTS, REVEAL_PENDING].map((name) => ({ defaultValue: false, name }))
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
];
|
|
4873
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
4874
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
4875
|
+
const row = {
|
|
4813
4876
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
4814
4877
|
direction: "grid",
|
|
4815
4878
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
4816
|
-
sections: [image, info,
|
|
4879
|
+
sections: [image, info, action],
|
|
4817
4880
|
sectionType: "layout"
|
|
4818
4881
|
};
|
|
4819
|
-
return [
|
|
4882
|
+
return card([row, ...controls]);
|
|
4820
4883
|
};
|
|
4821
4884
|
|
|
4822
4885
|
// src/transforms/offerV1/convertOfferToV2.ts
|
package/dist/index.mjs
CHANGED
|
@@ -4358,16 +4358,35 @@ var buildPrice = () => ({
|
|
|
4358
4358
|
content: { en: buildPriceContent() },
|
|
4359
4359
|
sectionType: "text"
|
|
4360
4360
|
});
|
|
4361
|
+
var HAS_VARIANT_TITLE = "hasVariantTitle";
|
|
4361
4362
|
var buildVariantTitle = (settings) => {
|
|
4362
4363
|
const show = settings.productOptions?.showVariantTitle;
|
|
4363
4364
|
if (!show || show === "hide") return [];
|
|
4364
4365
|
return [
|
|
4365
4366
|
{
|
|
4366
4367
|
content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
|
|
4367
|
-
|
|
4368
|
+
mutators: [
|
|
4369
|
+
{ effect: "set_false", variable: HAS_VARIANT_TITLE, when: { operator: "is_empty", type: "content" } },
|
|
4370
|
+
{
|
|
4371
|
+
effect: "set_true",
|
|
4372
|
+
variable: HAS_VARIANT_TITLE,
|
|
4373
|
+
when: { operator: "is_not_empty", type: "content" }
|
|
4374
|
+
}
|
|
4375
|
+
],
|
|
4376
|
+
sectionType: "text",
|
|
4377
|
+
visibility: { variable: HAS_VARIANT_TITLE, visibleWhen: true }
|
|
4368
4378
|
}
|
|
4369
4379
|
];
|
|
4370
4380
|
};
|
|
4381
|
+
var detailBlock = (sections, horizontal, hasVariantTitleLine) => ({
|
|
4382
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
4383
|
+
direction: "rows",
|
|
4384
|
+
name: "detail",
|
|
4385
|
+
sections,
|
|
4386
|
+
sectionType: "layout",
|
|
4387
|
+
spacing: "none",
|
|
4388
|
+
...hasVariantTitleLine && { variables: [{ defaultValue: false, name: HAS_VARIANT_TITLE }] }
|
|
4389
|
+
});
|
|
4371
4390
|
var SHOW_DESCRIPTION = "showDescription";
|
|
4372
4391
|
var HAS_DESCRIPTION = "hasDescription";
|
|
4373
4392
|
var buildDescription = (settings) => {
|
|
@@ -4410,6 +4429,14 @@ var buildDescription = (settings) => {
|
|
|
4410
4429
|
}
|
|
4411
4430
|
];
|
|
4412
4431
|
};
|
|
4432
|
+
var SHOW_VARIANTS = "showVariants";
|
|
4433
|
+
var REVEAL_PENDING = "revealPending";
|
|
4434
|
+
var revealsVariants = (settings) => settings.viewOptions?.displayActions !== false && settings.productOptions?.showVariantOptions === "default";
|
|
4435
|
+
var contentMutator = (effect, variable, operator) => ({
|
|
4436
|
+
effect,
|
|
4437
|
+
variable,
|
|
4438
|
+
when: { operator, type: "content" }
|
|
4439
|
+
});
|
|
4413
4440
|
var buildVariants = (settings) => {
|
|
4414
4441
|
if (settings.viewOptions?.displayActions === false) return [];
|
|
4415
4442
|
if (settings.productOptions?.showVariantOptions === "never") return [];
|
|
@@ -4417,8 +4444,16 @@ var buildVariants = (settings) => {
|
|
|
4417
4444
|
return [
|
|
4418
4445
|
{
|
|
4419
4446
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
4447
|
+
...revealsVariants(settings) && {
|
|
4448
|
+
mutators: [
|
|
4449
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
4450
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty")
|
|
4451
|
+
]
|
|
4452
|
+
},
|
|
4420
4453
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
4421
|
-
sectionType: "variants"
|
|
4454
|
+
sectionType: "variants",
|
|
4455
|
+
variantMode: "single",
|
|
4456
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
4422
4457
|
}
|
|
4423
4458
|
];
|
|
4424
4459
|
};
|
|
@@ -4475,8 +4510,25 @@ var buildSubscriptionButton = (settings) => {
|
|
|
4475
4510
|
];
|
|
4476
4511
|
};
|
|
4477
4512
|
var BUTTON_KINDS = ["plain", "primary", "secondary"];
|
|
4478
|
-
var
|
|
4513
|
+
var buttonKind = (settings) => {
|
|
4479
4514
|
const kind = settings.button?.kind;
|
|
4515
|
+
return BUTTON_KINDS.includes(kind) ? kind : "primary";
|
|
4516
|
+
};
|
|
4517
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
4518
|
+
{
|
|
4519
|
+
buttonStyle: buttonKind(settings),
|
|
4520
|
+
sections: [
|
|
4521
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
4522
|
+
],
|
|
4523
|
+
sectionType: "button",
|
|
4524
|
+
variableEffects: [
|
|
4525
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
4526
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
4527
|
+
],
|
|
4528
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
4529
|
+
}
|
|
4530
|
+
] : [];
|
|
4531
|
+
var buildAddButton = (settings) => {
|
|
4480
4532
|
const slot = (buttonField, override) => ({
|
|
4481
4533
|
buttonField,
|
|
4482
4534
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -4484,7 +4536,7 @@ var buildAddButton = (settings) => {
|
|
|
4484
4536
|
});
|
|
4485
4537
|
return {
|
|
4486
4538
|
action: "addToOrder",
|
|
4487
|
-
buttonStyle:
|
|
4539
|
+
buttonStyle: buttonKind(settings),
|
|
4488
4540
|
sections: [
|
|
4489
4541
|
slot("addToCart", settings.language?.addToCart),
|
|
4490
4542
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -4493,14 +4545,10 @@ var buildAddButton = (settings) => {
|
|
|
4493
4545
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
4494
4546
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
4495
4547
|
],
|
|
4496
|
-
sectionType: "button"
|
|
4548
|
+
sectionType: "button",
|
|
4549
|
+
...revealsVariants(settings) && { visibility: { variable: REVEAL_PENDING, visibleWhen: false } }
|
|
4497
4550
|
};
|
|
4498
4551
|
};
|
|
4499
|
-
var rowsLayout = (sections) => ({
|
|
4500
|
-
direction: "rows",
|
|
4501
|
-
sections,
|
|
4502
|
-
sectionType: "layout"
|
|
4503
|
-
});
|
|
4504
4552
|
var buildOfferCard = (settings, horizontal) => {
|
|
4505
4553
|
const image = buildImage(settings);
|
|
4506
4554
|
const title = buildTitle(settings);
|
|
@@ -4511,18 +4559,33 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
4511
4559
|
const variants = buildVariants(settings);
|
|
4512
4560
|
const quantity = buildQuantity(settings);
|
|
4513
4561
|
const subscription = buildSubscriptionButton(settings);
|
|
4562
|
+
const reveal = buildRevealButton(settings);
|
|
4514
4563
|
const addButton = buildAddButton(settings);
|
|
4515
4564
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
4516
|
-
|
|
4517
|
-
const
|
|
4518
|
-
|
|
4565
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
4566
|
+
const card = (sections) => [
|
|
4567
|
+
{
|
|
4568
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
4569
|
+
direction: "rows",
|
|
4570
|
+
name: "card",
|
|
4571
|
+
sections,
|
|
4572
|
+
sectionType: "layout",
|
|
4573
|
+
spacing: "base",
|
|
4574
|
+
...revealsVariants(settings) && {
|
|
4575
|
+
variables: [SHOW_VARIANTS, REVEAL_PENDING].map((name) => ({ defaultValue: false, name }))
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
];
|
|
4579
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
4580
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
4581
|
+
const row = {
|
|
4519
4582
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
4520
4583
|
direction: "grid",
|
|
4521
4584
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
4522
|
-
sections: [image, info,
|
|
4585
|
+
sections: [image, info, action],
|
|
4523
4586
|
sectionType: "layout"
|
|
4524
4587
|
};
|
|
4525
|
-
return [
|
|
4588
|
+
return card([row, ...controls]);
|
|
4526
4589
|
};
|
|
4527
4590
|
|
|
4528
4591
|
// src/transforms/offerV1/convertOfferToV2.ts
|
|
@@ -366,9 +366,11 @@ export type CABVisibility = z.infer<typeof CABVisibility>;
|
|
|
366
366
|
* Fires against the hosting section's OWN rendered copy — the buyer-language content after token
|
|
367
367
|
* interpolation and HTML stripping — so a section can publish "I have nothing to show" and a sibling
|
|
368
368
|
* control bound to the same variable hides with it (the offer card's `{{productDescription}}` line hiding
|
|
369
|
-
* its "Description" toggle on a product with no description).
|
|
370
|
-
*
|
|
371
|
-
*
|
|
369
|
+
* its "Description" toggle on a product with no description). Hosts: a `text` section (its interpolated
|
|
370
|
+
* copy) and a `variants` section, whose "content" is its selectable choices — empty when the product has
|
|
371
|
+
* fewer than two purchasable variants, so a card can hide a "choose options" control for a product with
|
|
372
|
+
* nothing to choose. On any other host the trigger parses but never fires. Content conditions are the
|
|
373
|
+
* mutators phase after count conditions.
|
|
372
374
|
*/
|
|
373
375
|
export declare const CABContentTrigger: z.ZodObject<{
|
|
374
376
|
operator: z.ZodDefault<z.ZodEnum<{
|
package/dist/server/index.cjs
CHANGED
|
@@ -3237,16 +3237,35 @@ var buildPrice = () => ({
|
|
|
3237
3237
|
content: { en: buildPriceContent() },
|
|
3238
3238
|
sectionType: "text"
|
|
3239
3239
|
});
|
|
3240
|
+
var HAS_VARIANT_TITLE = "hasVariantTitle";
|
|
3240
3241
|
var buildVariantTitle = (settings) => {
|
|
3241
3242
|
const show = settings.productOptions?.showVariantTitle;
|
|
3242
3243
|
if (!show || show === "hide") return [];
|
|
3243
3244
|
return [
|
|
3244
3245
|
{
|
|
3245
3246
|
content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
|
|
3246
|
-
|
|
3247
|
+
mutators: [
|
|
3248
|
+
{ effect: "set_false", variable: HAS_VARIANT_TITLE, when: { operator: "is_empty", type: "content" } },
|
|
3249
|
+
{
|
|
3250
|
+
effect: "set_true",
|
|
3251
|
+
variable: HAS_VARIANT_TITLE,
|
|
3252
|
+
when: { operator: "is_not_empty", type: "content" }
|
|
3253
|
+
}
|
|
3254
|
+
],
|
|
3255
|
+
sectionType: "text",
|
|
3256
|
+
visibility: { variable: HAS_VARIANT_TITLE, visibleWhen: true }
|
|
3247
3257
|
}
|
|
3248
3258
|
];
|
|
3249
3259
|
};
|
|
3260
|
+
var detailBlock = (sections, horizontal, hasVariantTitleLine) => ({
|
|
3261
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3262
|
+
direction: "rows",
|
|
3263
|
+
name: "detail",
|
|
3264
|
+
sections,
|
|
3265
|
+
sectionType: "layout",
|
|
3266
|
+
spacing: "none",
|
|
3267
|
+
...hasVariantTitleLine && { variables: [{ defaultValue: false, name: HAS_VARIANT_TITLE }] }
|
|
3268
|
+
});
|
|
3250
3269
|
var SHOW_DESCRIPTION = "showDescription";
|
|
3251
3270
|
var HAS_DESCRIPTION = "hasDescription";
|
|
3252
3271
|
var buildDescription = (settings) => {
|
|
@@ -3289,6 +3308,14 @@ var buildDescription = (settings) => {
|
|
|
3289
3308
|
}
|
|
3290
3309
|
];
|
|
3291
3310
|
};
|
|
3311
|
+
var SHOW_VARIANTS = "showVariants";
|
|
3312
|
+
var REVEAL_PENDING = "revealPending";
|
|
3313
|
+
var revealsVariants = (settings) => settings.viewOptions?.displayActions !== false && settings.productOptions?.showVariantOptions === "default";
|
|
3314
|
+
var contentMutator = (effect, variable, operator) => ({
|
|
3315
|
+
effect,
|
|
3316
|
+
variable,
|
|
3317
|
+
when: { operator, type: "content" }
|
|
3318
|
+
});
|
|
3292
3319
|
var buildVariants = (settings) => {
|
|
3293
3320
|
if (settings.viewOptions?.displayActions === false) return [];
|
|
3294
3321
|
if (settings.productOptions?.showVariantOptions === "never") return [];
|
|
@@ -3296,8 +3323,16 @@ var buildVariants = (settings) => {
|
|
|
3296
3323
|
return [
|
|
3297
3324
|
{
|
|
3298
3325
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3326
|
+
...revealsVariants(settings) && {
|
|
3327
|
+
mutators: [
|
|
3328
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3329
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty")
|
|
3330
|
+
]
|
|
3331
|
+
},
|
|
3299
3332
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3300
|
-
sectionType: "variants"
|
|
3333
|
+
sectionType: "variants",
|
|
3334
|
+
variantMode: "single",
|
|
3335
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3301
3336
|
}
|
|
3302
3337
|
];
|
|
3303
3338
|
};
|
|
@@ -3354,8 +3389,25 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3354
3389
|
];
|
|
3355
3390
|
};
|
|
3356
3391
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3357
|
-
var
|
|
3392
|
+
var buttonKind = (settings) => {
|
|
3358
3393
|
const kind = settings.button?.kind;
|
|
3394
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3395
|
+
};
|
|
3396
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3397
|
+
{
|
|
3398
|
+
buttonStyle: buttonKind(settings),
|
|
3399
|
+
sections: [
|
|
3400
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3401
|
+
],
|
|
3402
|
+
sectionType: "button",
|
|
3403
|
+
variableEffects: [
|
|
3404
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3405
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3406
|
+
],
|
|
3407
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3408
|
+
}
|
|
3409
|
+
] : [];
|
|
3410
|
+
var buildAddButton = (settings) => {
|
|
3359
3411
|
const slot = (buttonField, override) => ({
|
|
3360
3412
|
buttonField,
|
|
3361
3413
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3363,7 +3415,7 @@ var buildAddButton = (settings) => {
|
|
|
3363
3415
|
});
|
|
3364
3416
|
return {
|
|
3365
3417
|
action: "addToOrder",
|
|
3366
|
-
buttonStyle:
|
|
3418
|
+
buttonStyle: buttonKind(settings),
|
|
3367
3419
|
sections: [
|
|
3368
3420
|
slot("addToCart", settings.language?.addToCart),
|
|
3369
3421
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3372,14 +3424,10 @@ var buildAddButton = (settings) => {
|
|
|
3372
3424
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3373
3425
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3374
3426
|
],
|
|
3375
|
-
sectionType: "button"
|
|
3427
|
+
sectionType: "button",
|
|
3428
|
+
...revealsVariants(settings) && { visibility: { variable: REVEAL_PENDING, visibleWhen: false } }
|
|
3376
3429
|
};
|
|
3377
3430
|
};
|
|
3378
|
-
var rowsLayout = (sections) => ({
|
|
3379
|
-
direction: "rows",
|
|
3380
|
-
sections,
|
|
3381
|
-
sectionType: "layout"
|
|
3382
|
-
});
|
|
3383
3431
|
var buildOfferCard = (settings, horizontal) => {
|
|
3384
3432
|
const image = buildImage(settings);
|
|
3385
3433
|
const title = buildTitle(settings);
|
|
@@ -3390,18 +3438,33 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3390
3438
|
const variants = buildVariants(settings);
|
|
3391
3439
|
const quantity = buildQuantity(settings);
|
|
3392
3440
|
const subscription = buildSubscriptionButton(settings);
|
|
3441
|
+
const reveal = buildRevealButton(settings);
|
|
3393
3442
|
const addButton = buildAddButton(settings);
|
|
3394
3443
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3395
|
-
|
|
3396
|
-
const
|
|
3397
|
-
|
|
3444
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3445
|
+
const card = (sections) => [
|
|
3446
|
+
{
|
|
3447
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3448
|
+
direction: "rows",
|
|
3449
|
+
name: "card",
|
|
3450
|
+
sections,
|
|
3451
|
+
sectionType: "layout",
|
|
3452
|
+
spacing: "base",
|
|
3453
|
+
...revealsVariants(settings) && {
|
|
3454
|
+
variables: [SHOW_VARIANTS, REVEAL_PENDING].map((name) => ({ defaultValue: false, name }))
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
];
|
|
3458
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3459
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3460
|
+
const row = {
|
|
3398
3461
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3399
3462
|
direction: "grid",
|
|
3400
3463
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3401
|
-
sections: [image, info,
|
|
3464
|
+
sections: [image, info, action],
|
|
3402
3465
|
sectionType: "layout"
|
|
3403
3466
|
};
|
|
3404
|
-
return [
|
|
3467
|
+
return card([row, ...controls]);
|
|
3405
3468
|
};
|
|
3406
3469
|
|
|
3407
3470
|
// src/transforms/offerV1/convertOfferToV2.ts
|
package/dist/server/index.mjs
CHANGED
|
@@ -3186,16 +3186,35 @@ var buildPrice = () => ({
|
|
|
3186
3186
|
content: { en: buildPriceContent() },
|
|
3187
3187
|
sectionType: "text"
|
|
3188
3188
|
});
|
|
3189
|
+
var HAS_VARIANT_TITLE = "hasVariantTitle";
|
|
3189
3190
|
var buildVariantTitle = (settings) => {
|
|
3190
3191
|
const show = settings.productOptions?.showVariantTitle;
|
|
3191
3192
|
if (!show || show === "hide") return [];
|
|
3192
3193
|
return [
|
|
3193
3194
|
{
|
|
3194
3195
|
content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
|
|
3195
|
-
|
|
3196
|
+
mutators: [
|
|
3197
|
+
{ effect: "set_false", variable: HAS_VARIANT_TITLE, when: { operator: "is_empty", type: "content" } },
|
|
3198
|
+
{
|
|
3199
|
+
effect: "set_true",
|
|
3200
|
+
variable: HAS_VARIANT_TITLE,
|
|
3201
|
+
when: { operator: "is_not_empty", type: "content" }
|
|
3202
|
+
}
|
|
3203
|
+
],
|
|
3204
|
+
sectionType: "text",
|
|
3205
|
+
visibility: { variable: HAS_VARIANT_TITLE, visibleWhen: true }
|
|
3196
3206
|
}
|
|
3197
3207
|
];
|
|
3198
3208
|
};
|
|
3209
|
+
var detailBlock = (sections, horizontal, hasVariantTitleLine) => ({
|
|
3210
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3211
|
+
direction: "rows",
|
|
3212
|
+
name: "detail",
|
|
3213
|
+
sections,
|
|
3214
|
+
sectionType: "layout",
|
|
3215
|
+
spacing: "none",
|
|
3216
|
+
...hasVariantTitleLine && { variables: [{ defaultValue: false, name: HAS_VARIANT_TITLE }] }
|
|
3217
|
+
});
|
|
3199
3218
|
var SHOW_DESCRIPTION = "showDescription";
|
|
3200
3219
|
var HAS_DESCRIPTION = "hasDescription";
|
|
3201
3220
|
var buildDescription = (settings) => {
|
|
@@ -3238,6 +3257,14 @@ var buildDescription = (settings) => {
|
|
|
3238
3257
|
}
|
|
3239
3258
|
];
|
|
3240
3259
|
};
|
|
3260
|
+
var SHOW_VARIANTS = "showVariants";
|
|
3261
|
+
var REVEAL_PENDING = "revealPending";
|
|
3262
|
+
var revealsVariants = (settings) => settings.viewOptions?.displayActions !== false && settings.productOptions?.showVariantOptions === "default";
|
|
3263
|
+
var contentMutator = (effect, variable, operator) => ({
|
|
3264
|
+
effect,
|
|
3265
|
+
variable,
|
|
3266
|
+
when: { operator, type: "content" }
|
|
3267
|
+
});
|
|
3241
3268
|
var buildVariants = (settings) => {
|
|
3242
3269
|
if (settings.viewOptions?.displayActions === false) return [];
|
|
3243
3270
|
if (settings.productOptions?.showVariantOptions === "never") return [];
|
|
@@ -3245,8 +3272,16 @@ var buildVariants = (settings) => {
|
|
|
3245
3272
|
return [
|
|
3246
3273
|
{
|
|
3247
3274
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3275
|
+
...revealsVariants(settings) && {
|
|
3276
|
+
mutators: [
|
|
3277
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3278
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty")
|
|
3279
|
+
]
|
|
3280
|
+
},
|
|
3248
3281
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3249
|
-
sectionType: "variants"
|
|
3282
|
+
sectionType: "variants",
|
|
3283
|
+
variantMode: "single",
|
|
3284
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3250
3285
|
}
|
|
3251
3286
|
];
|
|
3252
3287
|
};
|
|
@@ -3303,8 +3338,25 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3303
3338
|
];
|
|
3304
3339
|
};
|
|
3305
3340
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3306
|
-
var
|
|
3341
|
+
var buttonKind = (settings) => {
|
|
3307
3342
|
const kind = settings.button?.kind;
|
|
3343
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3344
|
+
};
|
|
3345
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3346
|
+
{
|
|
3347
|
+
buttonStyle: buttonKind(settings),
|
|
3348
|
+
sections: [
|
|
3349
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3350
|
+
],
|
|
3351
|
+
sectionType: "button",
|
|
3352
|
+
variableEffects: [
|
|
3353
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3354
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3355
|
+
],
|
|
3356
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3357
|
+
}
|
|
3358
|
+
] : [];
|
|
3359
|
+
var buildAddButton = (settings) => {
|
|
3308
3360
|
const slot = (buttonField, override) => ({
|
|
3309
3361
|
buttonField,
|
|
3310
3362
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3312,7 +3364,7 @@ var buildAddButton = (settings) => {
|
|
|
3312
3364
|
});
|
|
3313
3365
|
return {
|
|
3314
3366
|
action: "addToOrder",
|
|
3315
|
-
buttonStyle:
|
|
3367
|
+
buttonStyle: buttonKind(settings),
|
|
3316
3368
|
sections: [
|
|
3317
3369
|
slot("addToCart", settings.language?.addToCart),
|
|
3318
3370
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3321,14 +3373,10 @@ var buildAddButton = (settings) => {
|
|
|
3321
3373
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3322
3374
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3323
3375
|
],
|
|
3324
|
-
sectionType: "button"
|
|
3376
|
+
sectionType: "button",
|
|
3377
|
+
...revealsVariants(settings) && { visibility: { variable: REVEAL_PENDING, visibleWhen: false } }
|
|
3325
3378
|
};
|
|
3326
3379
|
};
|
|
3327
|
-
var rowsLayout = (sections) => ({
|
|
3328
|
-
direction: "rows",
|
|
3329
|
-
sections,
|
|
3330
|
-
sectionType: "layout"
|
|
3331
|
-
});
|
|
3332
3380
|
var buildOfferCard = (settings, horizontal) => {
|
|
3333
3381
|
const image = buildImage(settings);
|
|
3334
3382
|
const title = buildTitle(settings);
|
|
@@ -3339,18 +3387,33 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3339
3387
|
const variants = buildVariants(settings);
|
|
3340
3388
|
const quantity = buildQuantity(settings);
|
|
3341
3389
|
const subscription = buildSubscriptionButton(settings);
|
|
3390
|
+
const reveal = buildRevealButton(settings);
|
|
3342
3391
|
const addButton = buildAddButton(settings);
|
|
3343
3392
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3344
|
-
|
|
3345
|
-
const
|
|
3346
|
-
|
|
3393
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3394
|
+
const card = (sections) => [
|
|
3395
|
+
{
|
|
3396
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3397
|
+
direction: "rows",
|
|
3398
|
+
name: "card",
|
|
3399
|
+
sections,
|
|
3400
|
+
sectionType: "layout",
|
|
3401
|
+
spacing: "base",
|
|
3402
|
+
...revealsVariants(settings) && {
|
|
3403
|
+
variables: [SHOW_VARIANTS, REVEAL_PENDING].map((name) => ({ defaultValue: false, name }))
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
];
|
|
3407
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3408
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3409
|
+
const row = {
|
|
3347
3410
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3348
3411
|
direction: "grid",
|
|
3349
3412
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3350
|
-
sections: [image, info,
|
|
3413
|
+
sections: [image, info, action],
|
|
3351
3414
|
sectionType: "layout"
|
|
3352
3415
|
};
|
|
3353
|
-
return [
|
|
3416
|
+
return card([row, ...controls]);
|
|
3354
3417
|
};
|
|
3355
3418
|
|
|
3356
3419
|
// src/transforms/offerV1/convertOfferToV2.ts
|
|
@@ -3052,16 +3052,35 @@ var buildPrice = () => ({
|
|
|
3052
3052
|
content: { en: buildPriceContent() },
|
|
3053
3053
|
sectionType: "text"
|
|
3054
3054
|
});
|
|
3055
|
+
var HAS_VARIANT_TITLE = "hasVariantTitle";
|
|
3055
3056
|
var buildVariantTitle = (settings) => {
|
|
3056
3057
|
const show = settings.productOptions?.showVariantTitle;
|
|
3057
3058
|
if (!show || show === "hide") return [];
|
|
3058
3059
|
return [
|
|
3059
3060
|
{
|
|
3060
3061
|
content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
|
|
3061
|
-
|
|
3062
|
+
mutators: [
|
|
3063
|
+
{ effect: "set_false", variable: HAS_VARIANT_TITLE, when: { operator: "is_empty", type: "content" } },
|
|
3064
|
+
{
|
|
3065
|
+
effect: "set_true",
|
|
3066
|
+
variable: HAS_VARIANT_TITLE,
|
|
3067
|
+
when: { operator: "is_not_empty", type: "content" }
|
|
3068
|
+
}
|
|
3069
|
+
],
|
|
3070
|
+
sectionType: "text",
|
|
3071
|
+
visibility: { variable: HAS_VARIANT_TITLE, visibleWhen: true }
|
|
3062
3072
|
}
|
|
3063
3073
|
];
|
|
3064
3074
|
};
|
|
3075
|
+
var detailBlock = (sections, horizontal, hasVariantTitleLine) => ({
|
|
3076
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3077
|
+
direction: "rows",
|
|
3078
|
+
name: "detail",
|
|
3079
|
+
sections,
|
|
3080
|
+
sectionType: "layout",
|
|
3081
|
+
spacing: "none",
|
|
3082
|
+
...hasVariantTitleLine && { variables: [{ defaultValue: false, name: HAS_VARIANT_TITLE }] }
|
|
3083
|
+
});
|
|
3065
3084
|
var SHOW_DESCRIPTION = "showDescription";
|
|
3066
3085
|
var HAS_DESCRIPTION = "hasDescription";
|
|
3067
3086
|
var buildDescription = (settings) => {
|
|
@@ -3104,6 +3123,14 @@ var buildDescription = (settings) => {
|
|
|
3104
3123
|
}
|
|
3105
3124
|
];
|
|
3106
3125
|
};
|
|
3126
|
+
var SHOW_VARIANTS = "showVariants";
|
|
3127
|
+
var REVEAL_PENDING = "revealPending";
|
|
3128
|
+
var revealsVariants = (settings) => settings.viewOptions?.displayActions !== false && settings.productOptions?.showVariantOptions === "default";
|
|
3129
|
+
var contentMutator = (effect, variable, operator) => ({
|
|
3130
|
+
effect,
|
|
3131
|
+
variable,
|
|
3132
|
+
when: { operator, type: "content" }
|
|
3133
|
+
});
|
|
3107
3134
|
var buildVariants = (settings) => {
|
|
3108
3135
|
if (settings.viewOptions?.displayActions === false) return [];
|
|
3109
3136
|
if (settings.productOptions?.showVariantOptions === "never") return [];
|
|
@@ -3111,8 +3138,16 @@ var buildVariants = (settings) => {
|
|
|
3111
3138
|
return [
|
|
3112
3139
|
{
|
|
3113
3140
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3141
|
+
...revealsVariants(settings) && {
|
|
3142
|
+
mutators: [
|
|
3143
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3144
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty")
|
|
3145
|
+
]
|
|
3146
|
+
},
|
|
3114
3147
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3115
|
-
sectionType: "variants"
|
|
3148
|
+
sectionType: "variants",
|
|
3149
|
+
variantMode: "single",
|
|
3150
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3116
3151
|
}
|
|
3117
3152
|
];
|
|
3118
3153
|
};
|
|
@@ -3169,8 +3204,25 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3169
3204
|
];
|
|
3170
3205
|
};
|
|
3171
3206
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3172
|
-
var
|
|
3207
|
+
var buttonKind = (settings) => {
|
|
3173
3208
|
const kind = settings.button?.kind;
|
|
3209
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3210
|
+
};
|
|
3211
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3212
|
+
{
|
|
3213
|
+
buttonStyle: buttonKind(settings),
|
|
3214
|
+
sections: [
|
|
3215
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3216
|
+
],
|
|
3217
|
+
sectionType: "button",
|
|
3218
|
+
variableEffects: [
|
|
3219
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3220
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3221
|
+
],
|
|
3222
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3223
|
+
}
|
|
3224
|
+
] : [];
|
|
3225
|
+
var buildAddButton = (settings) => {
|
|
3174
3226
|
const slot = (buttonField, override) => ({
|
|
3175
3227
|
buttonField,
|
|
3176
3228
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3178,7 +3230,7 @@ var buildAddButton = (settings) => {
|
|
|
3178
3230
|
});
|
|
3179
3231
|
return {
|
|
3180
3232
|
action: "addToOrder",
|
|
3181
|
-
buttonStyle:
|
|
3233
|
+
buttonStyle: buttonKind(settings),
|
|
3182
3234
|
sections: [
|
|
3183
3235
|
slot("addToCart", settings.language?.addToCart),
|
|
3184
3236
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3187,14 +3239,10 @@ var buildAddButton = (settings) => {
|
|
|
3187
3239
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3188
3240
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3189
3241
|
],
|
|
3190
|
-
sectionType: "button"
|
|
3242
|
+
sectionType: "button",
|
|
3243
|
+
...revealsVariants(settings) && { visibility: { variable: REVEAL_PENDING, visibleWhen: false } }
|
|
3191
3244
|
};
|
|
3192
3245
|
};
|
|
3193
|
-
var rowsLayout = (sections) => ({
|
|
3194
|
-
direction: "rows",
|
|
3195
|
-
sections,
|
|
3196
|
-
sectionType: "layout"
|
|
3197
|
-
});
|
|
3198
3246
|
var buildOfferCard = (settings, horizontal) => {
|
|
3199
3247
|
const image = buildImage(settings);
|
|
3200
3248
|
const title = buildTitle(settings);
|
|
@@ -3205,18 +3253,33 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3205
3253
|
const variants = buildVariants(settings);
|
|
3206
3254
|
const quantity = buildQuantity(settings);
|
|
3207
3255
|
const subscription = buildSubscriptionButton(settings);
|
|
3256
|
+
const reveal = buildRevealButton(settings);
|
|
3208
3257
|
const addButton = buildAddButton(settings);
|
|
3209
3258
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3210
|
-
|
|
3211
|
-
const
|
|
3212
|
-
|
|
3259
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3260
|
+
const card = (sections) => [
|
|
3261
|
+
{
|
|
3262
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3263
|
+
direction: "rows",
|
|
3264
|
+
name: "card",
|
|
3265
|
+
sections,
|
|
3266
|
+
sectionType: "layout",
|
|
3267
|
+
spacing: "base",
|
|
3268
|
+
...revealsVariants(settings) && {
|
|
3269
|
+
variables: [SHOW_VARIANTS, REVEAL_PENDING].map((name) => ({ defaultValue: false, name }))
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
];
|
|
3273
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3274
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3275
|
+
const row = {
|
|
3213
3276
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3214
3277
|
direction: "grid",
|
|
3215
3278
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3216
|
-
sections: [image, info,
|
|
3279
|
+
sections: [image, info, action],
|
|
3217
3280
|
sectionType: "layout"
|
|
3218
3281
|
};
|
|
3219
|
-
return [
|
|
3282
|
+
return card([row, ...controls]);
|
|
3220
3283
|
};
|
|
3221
3284
|
|
|
3222
3285
|
// src/transforms/offerV1/convertOfferToV2.ts
|
|
@@ -2993,16 +2993,35 @@ var buildPrice = () => ({
|
|
|
2993
2993
|
content: { en: buildPriceContent() },
|
|
2994
2994
|
sectionType: "text"
|
|
2995
2995
|
});
|
|
2996
|
+
var HAS_VARIANT_TITLE = "hasVariantTitle";
|
|
2996
2997
|
var buildVariantTitle = (settings) => {
|
|
2997
2998
|
const show = settings.productOptions?.showVariantTitle;
|
|
2998
2999
|
if (!show || show === "hide") return [];
|
|
2999
3000
|
return [
|
|
3000
3001
|
{
|
|
3001
3002
|
content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
|
|
3002
|
-
|
|
3003
|
+
mutators: [
|
|
3004
|
+
{ effect: "set_false", variable: HAS_VARIANT_TITLE, when: { operator: "is_empty", type: "content" } },
|
|
3005
|
+
{
|
|
3006
|
+
effect: "set_true",
|
|
3007
|
+
variable: HAS_VARIANT_TITLE,
|
|
3008
|
+
when: { operator: "is_not_empty", type: "content" }
|
|
3009
|
+
}
|
|
3010
|
+
],
|
|
3011
|
+
sectionType: "text",
|
|
3012
|
+
visibility: { variable: HAS_VARIANT_TITLE, visibleWhen: true }
|
|
3003
3013
|
}
|
|
3004
3014
|
];
|
|
3005
3015
|
};
|
|
3016
|
+
var detailBlock = (sections, horizontal, hasVariantTitleLine) => ({
|
|
3017
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3018
|
+
direction: "rows",
|
|
3019
|
+
name: "detail",
|
|
3020
|
+
sections,
|
|
3021
|
+
sectionType: "layout",
|
|
3022
|
+
spacing: "none",
|
|
3023
|
+
...hasVariantTitleLine && { variables: [{ defaultValue: false, name: HAS_VARIANT_TITLE }] }
|
|
3024
|
+
});
|
|
3006
3025
|
var SHOW_DESCRIPTION = "showDescription";
|
|
3007
3026
|
var HAS_DESCRIPTION = "hasDescription";
|
|
3008
3027
|
var buildDescription = (settings) => {
|
|
@@ -3045,6 +3064,14 @@ var buildDescription = (settings) => {
|
|
|
3045
3064
|
}
|
|
3046
3065
|
];
|
|
3047
3066
|
};
|
|
3067
|
+
var SHOW_VARIANTS = "showVariants";
|
|
3068
|
+
var REVEAL_PENDING = "revealPending";
|
|
3069
|
+
var revealsVariants = (settings) => settings.viewOptions?.displayActions !== false && settings.productOptions?.showVariantOptions === "default";
|
|
3070
|
+
var contentMutator = (effect, variable, operator) => ({
|
|
3071
|
+
effect,
|
|
3072
|
+
variable,
|
|
3073
|
+
when: { operator, type: "content" }
|
|
3074
|
+
});
|
|
3048
3075
|
var buildVariants = (settings) => {
|
|
3049
3076
|
if (settings.viewOptions?.displayActions === false) return [];
|
|
3050
3077
|
if (settings.productOptions?.showVariantOptions === "never") return [];
|
|
@@ -3052,8 +3079,16 @@ var buildVariants = (settings) => {
|
|
|
3052
3079
|
return [
|
|
3053
3080
|
{
|
|
3054
3081
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3082
|
+
...revealsVariants(settings) && {
|
|
3083
|
+
mutators: [
|
|
3084
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3085
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty")
|
|
3086
|
+
]
|
|
3087
|
+
},
|
|
3055
3088
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3056
|
-
sectionType: "variants"
|
|
3089
|
+
sectionType: "variants",
|
|
3090
|
+
variantMode: "single",
|
|
3091
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3057
3092
|
}
|
|
3058
3093
|
];
|
|
3059
3094
|
};
|
|
@@ -3110,8 +3145,25 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3110
3145
|
];
|
|
3111
3146
|
};
|
|
3112
3147
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3113
|
-
var
|
|
3148
|
+
var buttonKind = (settings) => {
|
|
3114
3149
|
const kind = settings.button?.kind;
|
|
3150
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3151
|
+
};
|
|
3152
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3153
|
+
{
|
|
3154
|
+
buttonStyle: buttonKind(settings),
|
|
3155
|
+
sections: [
|
|
3156
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3157
|
+
],
|
|
3158
|
+
sectionType: "button",
|
|
3159
|
+
variableEffects: [
|
|
3160
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3161
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3162
|
+
],
|
|
3163
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3164
|
+
}
|
|
3165
|
+
] : [];
|
|
3166
|
+
var buildAddButton = (settings) => {
|
|
3115
3167
|
const slot = (buttonField, override) => ({
|
|
3116
3168
|
buttonField,
|
|
3117
3169
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3119,7 +3171,7 @@ var buildAddButton = (settings) => {
|
|
|
3119
3171
|
});
|
|
3120
3172
|
return {
|
|
3121
3173
|
action: "addToOrder",
|
|
3122
|
-
buttonStyle:
|
|
3174
|
+
buttonStyle: buttonKind(settings),
|
|
3123
3175
|
sections: [
|
|
3124
3176
|
slot("addToCart", settings.language?.addToCart),
|
|
3125
3177
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3128,14 +3180,10 @@ var buildAddButton = (settings) => {
|
|
|
3128
3180
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3129
3181
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3130
3182
|
],
|
|
3131
|
-
sectionType: "button"
|
|
3183
|
+
sectionType: "button",
|
|
3184
|
+
...revealsVariants(settings) && { visibility: { variable: REVEAL_PENDING, visibleWhen: false } }
|
|
3132
3185
|
};
|
|
3133
3186
|
};
|
|
3134
|
-
var rowsLayout = (sections) => ({
|
|
3135
|
-
direction: "rows",
|
|
3136
|
-
sections,
|
|
3137
|
-
sectionType: "layout"
|
|
3138
|
-
});
|
|
3139
3187
|
var buildOfferCard = (settings, horizontal) => {
|
|
3140
3188
|
const image = buildImage(settings);
|
|
3141
3189
|
const title = buildTitle(settings);
|
|
@@ -3146,18 +3194,33 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3146
3194
|
const variants = buildVariants(settings);
|
|
3147
3195
|
const quantity = buildQuantity(settings);
|
|
3148
3196
|
const subscription = buildSubscriptionButton(settings);
|
|
3197
|
+
const reveal = buildRevealButton(settings);
|
|
3149
3198
|
const addButton = buildAddButton(settings);
|
|
3150
3199
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3151
|
-
|
|
3152
|
-
const
|
|
3153
|
-
|
|
3200
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3201
|
+
const card = (sections) => [
|
|
3202
|
+
{
|
|
3203
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3204
|
+
direction: "rows",
|
|
3205
|
+
name: "card",
|
|
3206
|
+
sections,
|
|
3207
|
+
sectionType: "layout",
|
|
3208
|
+
spacing: "base",
|
|
3209
|
+
...revealsVariants(settings) && {
|
|
3210
|
+
variables: [SHOW_VARIANTS, REVEAL_PENDING].map((name) => ({ defaultValue: false, name }))
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
];
|
|
3214
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3215
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3216
|
+
const row = {
|
|
3154
3217
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3155
3218
|
direction: "grid",
|
|
3156
3219
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3157
|
-
sections: [image, info,
|
|
3220
|
+
sections: [image, info, action],
|
|
3158
3221
|
sectionType: "layout"
|
|
3159
3222
|
};
|
|
3160
|
-
return [
|
|
3223
|
+
return card([row, ...controls]);
|
|
3161
3224
|
};
|
|
3162
3225
|
|
|
3163
3226
|
// src/transforms/offerV1/convertOfferToV2.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0-rc.1",
|
|
4
4
|
"description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rebuy, Inc.",
|