@rebuy/rebuy 3.22.0 → 3.23.0-rc.2
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 +84 -15
- package/dist/index.mjs +84 -15
- package/dist/schema/widgets/checkout-and-beyond/variables.d.ts +5 -3
- package/dist/server/index.cjs +84 -15
- package/dist/server/index.mjs +84 -15
- package/dist/transforms/index.cjs +84 -15
- package/dist/transforms/index.mjs +84 -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,18 @@ var buildVariants = (settings) => {
|
|
|
4711
4738
|
return [
|
|
4712
4739
|
{
|
|
4713
4740
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
4741
|
+
...revealsVariants(settings) && {
|
|
4742
|
+
mutators: [
|
|
4743
|
+
contentMutator("set_true", SHOW_VARIANTS, "is_empty"),
|
|
4744
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
4745
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty"),
|
|
4746
|
+
contentMutator("set_false", SHOW_VARIANTS, "is_not_empty")
|
|
4747
|
+
]
|
|
4748
|
+
},
|
|
4714
4749
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
4715
|
-
sectionType: "variants"
|
|
4750
|
+
sectionType: "variants",
|
|
4751
|
+
variantMode: "single",
|
|
4752
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
4716
4753
|
}
|
|
4717
4754
|
];
|
|
4718
4755
|
};
|
|
@@ -4769,8 +4806,26 @@ var buildSubscriptionButton = (settings) => {
|
|
|
4769
4806
|
];
|
|
4770
4807
|
};
|
|
4771
4808
|
var BUTTON_KINDS = ["plain", "primary", "secondary"];
|
|
4772
|
-
var
|
|
4809
|
+
var buttonKind = (settings) => {
|
|
4773
4810
|
const kind = settings.button?.kind;
|
|
4811
|
+
return BUTTON_KINDS.includes(kind) ? kind : "primary";
|
|
4812
|
+
};
|
|
4813
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
4814
|
+
{
|
|
4815
|
+
buttonStyle: buttonKind(settings),
|
|
4816
|
+
name: "reveal",
|
|
4817
|
+
sections: [
|
|
4818
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
4819
|
+
],
|
|
4820
|
+
sectionType: "button",
|
|
4821
|
+
variableEffects: [
|
|
4822
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
4823
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
4824
|
+
],
|
|
4825
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
4826
|
+
}
|
|
4827
|
+
] : [];
|
|
4828
|
+
var buildAddButton = (settings) => {
|
|
4774
4829
|
const slot = (buttonField, override) => ({
|
|
4775
4830
|
buttonField,
|
|
4776
4831
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -4778,7 +4833,7 @@ var buildAddButton = (settings) => {
|
|
|
4778
4833
|
});
|
|
4779
4834
|
return {
|
|
4780
4835
|
action: "addToOrder",
|
|
4781
|
-
buttonStyle:
|
|
4836
|
+
buttonStyle: buttonKind(settings),
|
|
4782
4837
|
sections: [
|
|
4783
4838
|
slot("addToCart", settings.language?.addToCart),
|
|
4784
4839
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -4787,14 +4842,10 @@ var buildAddButton = (settings) => {
|
|
|
4787
4842
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
4788
4843
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
4789
4844
|
],
|
|
4790
|
-
sectionType: "button"
|
|
4845
|
+
sectionType: "button",
|
|
4846
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
4791
4847
|
};
|
|
4792
4848
|
};
|
|
4793
|
-
var rowsLayout = (sections) => ({
|
|
4794
|
-
direction: "rows",
|
|
4795
|
-
sections,
|
|
4796
|
-
sectionType: "layout"
|
|
4797
|
-
});
|
|
4798
4849
|
var buildOfferCard = (settings, horizontal) => {
|
|
4799
4850
|
const image = buildImage(settings);
|
|
4800
4851
|
const title = buildTitle(settings);
|
|
@@ -4805,18 +4856,36 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
4805
4856
|
const variants = buildVariants(settings);
|
|
4806
4857
|
const quantity = buildQuantity(settings);
|
|
4807
4858
|
const subscription = buildSubscriptionButton(settings);
|
|
4859
|
+
const reveal = buildRevealButton(settings);
|
|
4808
4860
|
const addButton = buildAddButton(settings);
|
|
4809
4861
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
4810
|
-
|
|
4811
|
-
const
|
|
4812
|
-
|
|
4862
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
4863
|
+
const card = (sections) => [
|
|
4864
|
+
{
|
|
4865
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
4866
|
+
direction: "rows",
|
|
4867
|
+
name: "card",
|
|
4868
|
+
sections,
|
|
4869
|
+
sectionType: "layout",
|
|
4870
|
+
spacing: "base",
|
|
4871
|
+
...revealsVariants(settings) && {
|
|
4872
|
+
variables: [
|
|
4873
|
+
{ defaultValue: true, name: SHOW_VARIANTS },
|
|
4874
|
+
{ defaultValue: false, name: REVEAL_PENDING }
|
|
4875
|
+
]
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
];
|
|
4879
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
4880
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
4881
|
+
const row = {
|
|
4813
4882
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
4814
4883
|
direction: "grid",
|
|
4815
4884
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
4816
|
-
sections: [image, info,
|
|
4885
|
+
sections: [image, info, action],
|
|
4817
4886
|
sectionType: "layout"
|
|
4818
4887
|
};
|
|
4819
|
-
return [
|
|
4888
|
+
return card([row, ...controls]);
|
|
4820
4889
|
};
|
|
4821
4890
|
|
|
4822
4891
|
// 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,18 @@ var buildVariants = (settings) => {
|
|
|
4417
4444
|
return [
|
|
4418
4445
|
{
|
|
4419
4446
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
4447
|
+
...revealsVariants(settings) && {
|
|
4448
|
+
mutators: [
|
|
4449
|
+
contentMutator("set_true", SHOW_VARIANTS, "is_empty"),
|
|
4450
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
4451
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty"),
|
|
4452
|
+
contentMutator("set_false", SHOW_VARIANTS, "is_not_empty")
|
|
4453
|
+
]
|
|
4454
|
+
},
|
|
4420
4455
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
4421
|
-
sectionType: "variants"
|
|
4456
|
+
sectionType: "variants",
|
|
4457
|
+
variantMode: "single",
|
|
4458
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
4422
4459
|
}
|
|
4423
4460
|
];
|
|
4424
4461
|
};
|
|
@@ -4475,8 +4512,26 @@ var buildSubscriptionButton = (settings) => {
|
|
|
4475
4512
|
];
|
|
4476
4513
|
};
|
|
4477
4514
|
var BUTTON_KINDS = ["plain", "primary", "secondary"];
|
|
4478
|
-
var
|
|
4515
|
+
var buttonKind = (settings) => {
|
|
4479
4516
|
const kind = settings.button?.kind;
|
|
4517
|
+
return BUTTON_KINDS.includes(kind) ? kind : "primary";
|
|
4518
|
+
};
|
|
4519
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
4520
|
+
{
|
|
4521
|
+
buttonStyle: buttonKind(settings),
|
|
4522
|
+
name: "reveal",
|
|
4523
|
+
sections: [
|
|
4524
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
4525
|
+
],
|
|
4526
|
+
sectionType: "button",
|
|
4527
|
+
variableEffects: [
|
|
4528
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
4529
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
4530
|
+
],
|
|
4531
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
4532
|
+
}
|
|
4533
|
+
] : [];
|
|
4534
|
+
var buildAddButton = (settings) => {
|
|
4480
4535
|
const slot = (buttonField, override) => ({
|
|
4481
4536
|
buttonField,
|
|
4482
4537
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -4484,7 +4539,7 @@ var buildAddButton = (settings) => {
|
|
|
4484
4539
|
});
|
|
4485
4540
|
return {
|
|
4486
4541
|
action: "addToOrder",
|
|
4487
|
-
buttonStyle:
|
|
4542
|
+
buttonStyle: buttonKind(settings),
|
|
4488
4543
|
sections: [
|
|
4489
4544
|
slot("addToCart", settings.language?.addToCart),
|
|
4490
4545
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -4493,14 +4548,10 @@ var buildAddButton = (settings) => {
|
|
|
4493
4548
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
4494
4549
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
4495
4550
|
],
|
|
4496
|
-
sectionType: "button"
|
|
4551
|
+
sectionType: "button",
|
|
4552
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
4497
4553
|
};
|
|
4498
4554
|
};
|
|
4499
|
-
var rowsLayout = (sections) => ({
|
|
4500
|
-
direction: "rows",
|
|
4501
|
-
sections,
|
|
4502
|
-
sectionType: "layout"
|
|
4503
|
-
});
|
|
4504
4555
|
var buildOfferCard = (settings, horizontal) => {
|
|
4505
4556
|
const image = buildImage(settings);
|
|
4506
4557
|
const title = buildTitle(settings);
|
|
@@ -4511,18 +4562,36 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
4511
4562
|
const variants = buildVariants(settings);
|
|
4512
4563
|
const quantity = buildQuantity(settings);
|
|
4513
4564
|
const subscription = buildSubscriptionButton(settings);
|
|
4565
|
+
const reveal = buildRevealButton(settings);
|
|
4514
4566
|
const addButton = buildAddButton(settings);
|
|
4515
4567
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
4516
|
-
|
|
4517
|
-
const
|
|
4518
|
-
|
|
4568
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
4569
|
+
const card = (sections) => [
|
|
4570
|
+
{
|
|
4571
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
4572
|
+
direction: "rows",
|
|
4573
|
+
name: "card",
|
|
4574
|
+
sections,
|
|
4575
|
+
sectionType: "layout",
|
|
4576
|
+
spacing: "base",
|
|
4577
|
+
...revealsVariants(settings) && {
|
|
4578
|
+
variables: [
|
|
4579
|
+
{ defaultValue: true, name: SHOW_VARIANTS },
|
|
4580
|
+
{ defaultValue: false, name: REVEAL_PENDING }
|
|
4581
|
+
]
|
|
4582
|
+
}
|
|
4583
|
+
}
|
|
4584
|
+
];
|
|
4585
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
4586
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
4587
|
+
const row = {
|
|
4519
4588
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
4520
4589
|
direction: "grid",
|
|
4521
4590
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
4522
|
-
sections: [image, info,
|
|
4591
|
+
sections: [image, info, action],
|
|
4523
4592
|
sectionType: "layout"
|
|
4524
4593
|
};
|
|
4525
|
-
return [
|
|
4594
|
+
return card([row, ...controls]);
|
|
4526
4595
|
};
|
|
4527
4596
|
|
|
4528
4597
|
// 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,18 @@ var buildVariants = (settings) => {
|
|
|
3296
3323
|
return [
|
|
3297
3324
|
{
|
|
3298
3325
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3326
|
+
...revealsVariants(settings) && {
|
|
3327
|
+
mutators: [
|
|
3328
|
+
contentMutator("set_true", SHOW_VARIANTS, "is_empty"),
|
|
3329
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3330
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty"),
|
|
3331
|
+
contentMutator("set_false", SHOW_VARIANTS, "is_not_empty")
|
|
3332
|
+
]
|
|
3333
|
+
},
|
|
3299
3334
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3300
|
-
sectionType: "variants"
|
|
3335
|
+
sectionType: "variants",
|
|
3336
|
+
variantMode: "single",
|
|
3337
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3301
3338
|
}
|
|
3302
3339
|
];
|
|
3303
3340
|
};
|
|
@@ -3354,8 +3391,26 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3354
3391
|
];
|
|
3355
3392
|
};
|
|
3356
3393
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3357
|
-
var
|
|
3394
|
+
var buttonKind = (settings) => {
|
|
3358
3395
|
const kind = settings.button?.kind;
|
|
3396
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3397
|
+
};
|
|
3398
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3399
|
+
{
|
|
3400
|
+
buttonStyle: buttonKind(settings),
|
|
3401
|
+
name: "reveal",
|
|
3402
|
+
sections: [
|
|
3403
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3404
|
+
],
|
|
3405
|
+
sectionType: "button",
|
|
3406
|
+
variableEffects: [
|
|
3407
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3408
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3409
|
+
],
|
|
3410
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3411
|
+
}
|
|
3412
|
+
] : [];
|
|
3413
|
+
var buildAddButton = (settings) => {
|
|
3359
3414
|
const slot = (buttonField, override) => ({
|
|
3360
3415
|
buttonField,
|
|
3361
3416
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3363,7 +3418,7 @@ var buildAddButton = (settings) => {
|
|
|
3363
3418
|
});
|
|
3364
3419
|
return {
|
|
3365
3420
|
action: "addToOrder",
|
|
3366
|
-
buttonStyle:
|
|
3421
|
+
buttonStyle: buttonKind(settings),
|
|
3367
3422
|
sections: [
|
|
3368
3423
|
slot("addToCart", settings.language?.addToCart),
|
|
3369
3424
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3372,14 +3427,10 @@ var buildAddButton = (settings) => {
|
|
|
3372
3427
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3373
3428
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3374
3429
|
],
|
|
3375
|
-
sectionType: "button"
|
|
3430
|
+
sectionType: "button",
|
|
3431
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3376
3432
|
};
|
|
3377
3433
|
};
|
|
3378
|
-
var rowsLayout = (sections) => ({
|
|
3379
|
-
direction: "rows",
|
|
3380
|
-
sections,
|
|
3381
|
-
sectionType: "layout"
|
|
3382
|
-
});
|
|
3383
3434
|
var buildOfferCard = (settings, horizontal) => {
|
|
3384
3435
|
const image = buildImage(settings);
|
|
3385
3436
|
const title = buildTitle(settings);
|
|
@@ -3390,18 +3441,36 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3390
3441
|
const variants = buildVariants(settings);
|
|
3391
3442
|
const quantity = buildQuantity(settings);
|
|
3392
3443
|
const subscription = buildSubscriptionButton(settings);
|
|
3444
|
+
const reveal = buildRevealButton(settings);
|
|
3393
3445
|
const addButton = buildAddButton(settings);
|
|
3394
3446
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3395
|
-
|
|
3396
|
-
const
|
|
3397
|
-
|
|
3447
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3448
|
+
const card = (sections) => [
|
|
3449
|
+
{
|
|
3450
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3451
|
+
direction: "rows",
|
|
3452
|
+
name: "card",
|
|
3453
|
+
sections,
|
|
3454
|
+
sectionType: "layout",
|
|
3455
|
+
spacing: "base",
|
|
3456
|
+
...revealsVariants(settings) && {
|
|
3457
|
+
variables: [
|
|
3458
|
+
{ defaultValue: true, name: SHOW_VARIANTS },
|
|
3459
|
+
{ defaultValue: false, name: REVEAL_PENDING }
|
|
3460
|
+
]
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
];
|
|
3464
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3465
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3466
|
+
const row = {
|
|
3398
3467
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3399
3468
|
direction: "grid",
|
|
3400
3469
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3401
|
-
sections: [image, info,
|
|
3470
|
+
sections: [image, info, action],
|
|
3402
3471
|
sectionType: "layout"
|
|
3403
3472
|
};
|
|
3404
|
-
return [
|
|
3473
|
+
return card([row, ...controls]);
|
|
3405
3474
|
};
|
|
3406
3475
|
|
|
3407
3476
|
// 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,18 @@ var buildVariants = (settings) => {
|
|
|
3245
3272
|
return [
|
|
3246
3273
|
{
|
|
3247
3274
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3275
|
+
...revealsVariants(settings) && {
|
|
3276
|
+
mutators: [
|
|
3277
|
+
contentMutator("set_true", SHOW_VARIANTS, "is_empty"),
|
|
3278
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3279
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty"),
|
|
3280
|
+
contentMutator("set_false", SHOW_VARIANTS, "is_not_empty")
|
|
3281
|
+
]
|
|
3282
|
+
},
|
|
3248
3283
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3249
|
-
sectionType: "variants"
|
|
3284
|
+
sectionType: "variants",
|
|
3285
|
+
variantMode: "single",
|
|
3286
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3250
3287
|
}
|
|
3251
3288
|
];
|
|
3252
3289
|
};
|
|
@@ -3303,8 +3340,26 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3303
3340
|
];
|
|
3304
3341
|
};
|
|
3305
3342
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3306
|
-
var
|
|
3343
|
+
var buttonKind = (settings) => {
|
|
3307
3344
|
const kind = settings.button?.kind;
|
|
3345
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3346
|
+
};
|
|
3347
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3348
|
+
{
|
|
3349
|
+
buttonStyle: buttonKind(settings),
|
|
3350
|
+
name: "reveal",
|
|
3351
|
+
sections: [
|
|
3352
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3353
|
+
],
|
|
3354
|
+
sectionType: "button",
|
|
3355
|
+
variableEffects: [
|
|
3356
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3357
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3358
|
+
],
|
|
3359
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3360
|
+
}
|
|
3361
|
+
] : [];
|
|
3362
|
+
var buildAddButton = (settings) => {
|
|
3308
3363
|
const slot = (buttonField, override) => ({
|
|
3309
3364
|
buttonField,
|
|
3310
3365
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3312,7 +3367,7 @@ var buildAddButton = (settings) => {
|
|
|
3312
3367
|
});
|
|
3313
3368
|
return {
|
|
3314
3369
|
action: "addToOrder",
|
|
3315
|
-
buttonStyle:
|
|
3370
|
+
buttonStyle: buttonKind(settings),
|
|
3316
3371
|
sections: [
|
|
3317
3372
|
slot("addToCart", settings.language?.addToCart),
|
|
3318
3373
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3321,14 +3376,10 @@ var buildAddButton = (settings) => {
|
|
|
3321
3376
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3322
3377
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3323
3378
|
],
|
|
3324
|
-
sectionType: "button"
|
|
3379
|
+
sectionType: "button",
|
|
3380
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3325
3381
|
};
|
|
3326
3382
|
};
|
|
3327
|
-
var rowsLayout = (sections) => ({
|
|
3328
|
-
direction: "rows",
|
|
3329
|
-
sections,
|
|
3330
|
-
sectionType: "layout"
|
|
3331
|
-
});
|
|
3332
3383
|
var buildOfferCard = (settings, horizontal) => {
|
|
3333
3384
|
const image = buildImage(settings);
|
|
3334
3385
|
const title = buildTitle(settings);
|
|
@@ -3339,18 +3390,36 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3339
3390
|
const variants = buildVariants(settings);
|
|
3340
3391
|
const quantity = buildQuantity(settings);
|
|
3341
3392
|
const subscription = buildSubscriptionButton(settings);
|
|
3393
|
+
const reveal = buildRevealButton(settings);
|
|
3342
3394
|
const addButton = buildAddButton(settings);
|
|
3343
3395
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3344
|
-
|
|
3345
|
-
const
|
|
3346
|
-
|
|
3396
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3397
|
+
const card = (sections) => [
|
|
3398
|
+
{
|
|
3399
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3400
|
+
direction: "rows",
|
|
3401
|
+
name: "card",
|
|
3402
|
+
sections,
|
|
3403
|
+
sectionType: "layout",
|
|
3404
|
+
spacing: "base",
|
|
3405
|
+
...revealsVariants(settings) && {
|
|
3406
|
+
variables: [
|
|
3407
|
+
{ defaultValue: true, name: SHOW_VARIANTS },
|
|
3408
|
+
{ defaultValue: false, name: REVEAL_PENDING }
|
|
3409
|
+
]
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
];
|
|
3413
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3414
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3415
|
+
const row = {
|
|
3347
3416
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3348
3417
|
direction: "grid",
|
|
3349
3418
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3350
|
-
sections: [image, info,
|
|
3419
|
+
sections: [image, info, action],
|
|
3351
3420
|
sectionType: "layout"
|
|
3352
3421
|
};
|
|
3353
|
-
return [
|
|
3422
|
+
return card([row, ...controls]);
|
|
3354
3423
|
};
|
|
3355
3424
|
|
|
3356
3425
|
// 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,18 @@ var buildVariants = (settings) => {
|
|
|
3111
3138
|
return [
|
|
3112
3139
|
{
|
|
3113
3140
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3141
|
+
...revealsVariants(settings) && {
|
|
3142
|
+
mutators: [
|
|
3143
|
+
contentMutator("set_true", SHOW_VARIANTS, "is_empty"),
|
|
3144
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3145
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty"),
|
|
3146
|
+
contentMutator("set_false", SHOW_VARIANTS, "is_not_empty")
|
|
3147
|
+
]
|
|
3148
|
+
},
|
|
3114
3149
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3115
|
-
sectionType: "variants"
|
|
3150
|
+
sectionType: "variants",
|
|
3151
|
+
variantMode: "single",
|
|
3152
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3116
3153
|
}
|
|
3117
3154
|
];
|
|
3118
3155
|
};
|
|
@@ -3169,8 +3206,26 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3169
3206
|
];
|
|
3170
3207
|
};
|
|
3171
3208
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3172
|
-
var
|
|
3209
|
+
var buttonKind = (settings) => {
|
|
3173
3210
|
const kind = settings.button?.kind;
|
|
3211
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3212
|
+
};
|
|
3213
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3214
|
+
{
|
|
3215
|
+
buttonStyle: buttonKind(settings),
|
|
3216
|
+
name: "reveal",
|
|
3217
|
+
sections: [
|
|
3218
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3219
|
+
],
|
|
3220
|
+
sectionType: "button",
|
|
3221
|
+
variableEffects: [
|
|
3222
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3223
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3224
|
+
],
|
|
3225
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3226
|
+
}
|
|
3227
|
+
] : [];
|
|
3228
|
+
var buildAddButton = (settings) => {
|
|
3174
3229
|
const slot = (buttonField, override) => ({
|
|
3175
3230
|
buttonField,
|
|
3176
3231
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3178,7 +3233,7 @@ var buildAddButton = (settings) => {
|
|
|
3178
3233
|
});
|
|
3179
3234
|
return {
|
|
3180
3235
|
action: "addToOrder",
|
|
3181
|
-
buttonStyle:
|
|
3236
|
+
buttonStyle: buttonKind(settings),
|
|
3182
3237
|
sections: [
|
|
3183
3238
|
slot("addToCart", settings.language?.addToCart),
|
|
3184
3239
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3187,14 +3242,10 @@ var buildAddButton = (settings) => {
|
|
|
3187
3242
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3188
3243
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3189
3244
|
],
|
|
3190
|
-
sectionType: "button"
|
|
3245
|
+
sectionType: "button",
|
|
3246
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3191
3247
|
};
|
|
3192
3248
|
};
|
|
3193
|
-
var rowsLayout = (sections) => ({
|
|
3194
|
-
direction: "rows",
|
|
3195
|
-
sections,
|
|
3196
|
-
sectionType: "layout"
|
|
3197
|
-
});
|
|
3198
3249
|
var buildOfferCard = (settings, horizontal) => {
|
|
3199
3250
|
const image = buildImage(settings);
|
|
3200
3251
|
const title = buildTitle(settings);
|
|
@@ -3205,18 +3256,36 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3205
3256
|
const variants = buildVariants(settings);
|
|
3206
3257
|
const quantity = buildQuantity(settings);
|
|
3207
3258
|
const subscription = buildSubscriptionButton(settings);
|
|
3259
|
+
const reveal = buildRevealButton(settings);
|
|
3208
3260
|
const addButton = buildAddButton(settings);
|
|
3209
3261
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3210
|
-
|
|
3211
|
-
const
|
|
3212
|
-
|
|
3262
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3263
|
+
const card = (sections) => [
|
|
3264
|
+
{
|
|
3265
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3266
|
+
direction: "rows",
|
|
3267
|
+
name: "card",
|
|
3268
|
+
sections,
|
|
3269
|
+
sectionType: "layout",
|
|
3270
|
+
spacing: "base",
|
|
3271
|
+
...revealsVariants(settings) && {
|
|
3272
|
+
variables: [
|
|
3273
|
+
{ defaultValue: true, name: SHOW_VARIANTS },
|
|
3274
|
+
{ defaultValue: false, name: REVEAL_PENDING }
|
|
3275
|
+
]
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
];
|
|
3279
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3280
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3281
|
+
const row = {
|
|
3213
3282
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3214
3283
|
direction: "grid",
|
|
3215
3284
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3216
|
-
sections: [image, info,
|
|
3285
|
+
sections: [image, info, action],
|
|
3217
3286
|
sectionType: "layout"
|
|
3218
3287
|
};
|
|
3219
|
-
return [
|
|
3288
|
+
return card([row, ...controls]);
|
|
3220
3289
|
};
|
|
3221
3290
|
|
|
3222
3291
|
// 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,18 @@ var buildVariants = (settings) => {
|
|
|
3052
3079
|
return [
|
|
3053
3080
|
{
|
|
3054
3081
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3082
|
+
...revealsVariants(settings) && {
|
|
3083
|
+
mutators: [
|
|
3084
|
+
contentMutator("set_true", SHOW_VARIANTS, "is_empty"),
|
|
3085
|
+
contentMutator("set_false", REVEAL_PENDING, "is_empty"),
|
|
3086
|
+
contentMutator("set_true", REVEAL_PENDING, "is_not_empty"),
|
|
3087
|
+
contentMutator("set_false", SHOW_VARIANTS, "is_not_empty")
|
|
3088
|
+
]
|
|
3089
|
+
},
|
|
3055
3090
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
3056
|
-
sectionType: "variants"
|
|
3091
|
+
sectionType: "variants",
|
|
3092
|
+
variantMode: "single",
|
|
3093
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3057
3094
|
}
|
|
3058
3095
|
];
|
|
3059
3096
|
};
|
|
@@ -3110,8 +3147,26 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3110
3147
|
];
|
|
3111
3148
|
};
|
|
3112
3149
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3113
|
-
var
|
|
3150
|
+
var buttonKind = (settings) => {
|
|
3114
3151
|
const kind = settings.button?.kind;
|
|
3152
|
+
return BUTTON_KINDS2.includes(kind) ? kind : "primary";
|
|
3153
|
+
};
|
|
3154
|
+
var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
3155
|
+
{
|
|
3156
|
+
buttonStyle: buttonKind(settings),
|
|
3157
|
+
name: "reveal",
|
|
3158
|
+
sections: [
|
|
3159
|
+
{ buttonField: "buttonLabel", content: { en: "{{variantOptionsLabel}}" }, sectionType: "text" }
|
|
3160
|
+
],
|
|
3161
|
+
sectionType: "button",
|
|
3162
|
+
variableEffects: [
|
|
3163
|
+
{ effect: "set_false", variable: REVEAL_PENDING },
|
|
3164
|
+
{ effect: "set_true", variable: SHOW_VARIANTS }
|
|
3165
|
+
],
|
|
3166
|
+
visibility: { variable: REVEAL_PENDING, visibleWhen: true }
|
|
3167
|
+
}
|
|
3168
|
+
] : [];
|
|
3169
|
+
var buildAddButton = (settings) => {
|
|
3115
3170
|
const slot = (buttonField, override) => ({
|
|
3116
3171
|
buttonField,
|
|
3117
3172
|
content: localizedContent(OFFER_LABELS[buttonField], override, ADD_LABEL_TOKENS),
|
|
@@ -3119,7 +3174,7 @@ var buildAddButton = (settings) => {
|
|
|
3119
3174
|
});
|
|
3120
3175
|
return {
|
|
3121
3176
|
action: "addToOrder",
|
|
3122
|
-
buttonStyle:
|
|
3177
|
+
buttonStyle: buttonKind(settings),
|
|
3123
3178
|
sections: [
|
|
3124
3179
|
slot("addToCart", settings.language?.addToCart),
|
|
3125
3180
|
slot("addingToCart", settings.language?.addingToCart),
|
|
@@ -3128,14 +3183,10 @@ var buildAddButton = (settings) => {
|
|
|
3128
3183
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3129
3184
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3130
3185
|
],
|
|
3131
|
-
sectionType: "button"
|
|
3186
|
+
sectionType: "button",
|
|
3187
|
+
...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
|
|
3132
3188
|
};
|
|
3133
3189
|
};
|
|
3134
|
-
var rowsLayout = (sections) => ({
|
|
3135
|
-
direction: "rows",
|
|
3136
|
-
sections,
|
|
3137
|
-
sectionType: "layout"
|
|
3138
|
-
});
|
|
3139
3190
|
var buildOfferCard = (settings, horizontal) => {
|
|
3140
3191
|
const image = buildImage(settings);
|
|
3141
3192
|
const title = buildTitle(settings);
|
|
@@ -3146,18 +3197,36 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3146
3197
|
const variants = buildVariants(settings);
|
|
3147
3198
|
const quantity = buildQuantity(settings);
|
|
3148
3199
|
const subscription = buildSubscriptionButton(settings);
|
|
3200
|
+
const reveal = buildRevealButton(settings);
|
|
3149
3201
|
const addButton = buildAddButton(settings);
|
|
3150
3202
|
const controls = [...description, ...quantity, ...variants, ...subscription];
|
|
3151
|
-
|
|
3152
|
-
const
|
|
3153
|
-
|
|
3203
|
+
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3204
|
+
const card = (sections) => [
|
|
3205
|
+
{
|
|
3206
|
+
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
3207
|
+
direction: "rows",
|
|
3208
|
+
name: "card",
|
|
3209
|
+
sections,
|
|
3210
|
+
sectionType: "layout",
|
|
3211
|
+
spacing: "base",
|
|
3212
|
+
...revealsVariants(settings) && {
|
|
3213
|
+
variables: [
|
|
3214
|
+
{ defaultValue: true, name: SHOW_VARIANTS },
|
|
3215
|
+
{ defaultValue: false, name: REVEAL_PENDING }
|
|
3216
|
+
]
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
];
|
|
3220
|
+
if (!horizontal) return card([gridCardImage(image), info, ...controls, ...reveal, addButton]);
|
|
3221
|
+
const action = reveal.length ? { direction: "rows", name: "action", sections: [...reveal, addButton], sectionType: "layout" } : addButton;
|
|
3222
|
+
const row = {
|
|
3154
3223
|
alignment: { horizontal: "start", vertical: "middle" },
|
|
3155
3224
|
direction: "grid",
|
|
3156
3225
|
grid: { columns: [COMPACT_CARD_IMAGE_PX, "fill", "auto"], rows: ["auto"] },
|
|
3157
|
-
sections: [image, info,
|
|
3226
|
+
sections: [image, info, action],
|
|
3158
3227
|
sectionType: "layout"
|
|
3159
3228
|
};
|
|
3160
|
-
return [
|
|
3229
|
+
return card([row, ...controls]);
|
|
3161
3230
|
};
|
|
3162
3231
|
|
|
3163
3232
|
// 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.2",
|
|
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.",
|