@enyxs/wikex-components 0.11.27 → 0.11.28

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.js CHANGED
@@ -34,12 +34,15 @@ __export(index_exports, {
34
34
  CMS_LIST_MARKERS: () => CMS_LIST_MARKERS,
35
35
  CMS_TEXT_FONTS: () => CMS_TEXT_FONTS,
36
36
  CMS_TEXT_LAYOUT_SUFFIX: () => CMS_TEXT_LAYOUT_SUFFIX,
37
+ CmsButtonLinkControl: () => CmsButtonLinkControl,
37
38
  CmsTextToolbar: () => CmsTextToolbar,
38
39
  FeesTable: () => FeesTable,
39
40
  applyCmsTextLayout: () => applyCmsTextLayout,
40
41
  cmsListAnchor: () => cmsListAnchor,
41
42
  cmsListMarkerType: () => cmsListMarkerType,
42
43
  cmsTextLayoutStyle: () => cmsTextLayoutStyle,
44
+ getCmsButtonLink: () => getCmsButtonLink,
45
+ isCmsHeaderButtonField: () => isCmsHeaderButtonField,
43
46
  migrateWikexChromeContent: () => migrateWikexChromeContent,
44
47
  minimalMarketingBlocks: () => minimalMarketingBlocks,
45
48
  minimalUiBlocks: () => minimalUiBlocks,
@@ -52,6 +55,7 @@ __export(index_exports, {
52
55
  rebaseCmsRichText: () => rebaseCmsRichText,
53
56
  rebaseCmsTextLayouts: () => rebaseCmsTextLayouts,
54
57
  renderCmsRichText: () => renderCmsRichText,
58
+ safeCmsButtonHref: () => safeCmsButtonHref,
55
59
  safeCmsTextHref: () => safeCmsTextHref,
56
60
  siteChromeBlocks: () => siteChromeBlocks,
57
61
  wikexCmsBlocks: () => wikexCmsBlocks,
@@ -61,7 +65,7 @@ __export(index_exports, {
61
65
  wikexComponents: () => wikexComponents
62
66
  });
63
67
  module.exports = __toCommonJS(index_exports);
64
- var import_react39 = require("react");
68
+ var import_react40 = require("react");
65
69
 
66
70
  // src/minimal-ui/blocks.tsx
67
71
  var import_react5 = require("react");
@@ -4783,6 +4787,50 @@ function chromeItemHref(item) {
4783
4787
  return item.hrefEnabled === "false" ? void 0 : safeCmsTextHref(item.href);
4784
4788
  }
4785
4789
 
4790
+ // src/shared/button-links.ts
4791
+ function isCmsHeaderButtonField(field) {
4792
+ return /^(vi|en)\.header\.(login|register)$/.test(field);
4793
+ }
4794
+ function safeCmsButtonHref(value4, type) {
4795
+ const href = safeCmsTextHref(value4);
4796
+ if (!href) return void 0;
4797
+ return (type === "external" ? /^https?:\/\//i : /^(?:\/(?!\/)|#)/).test(href) ? href : void 0;
4798
+ }
4799
+ function getCmsButtonLink(content, field) {
4800
+ const type = content[`${field}LinkType`] === "external" ? "external" : "internal";
4801
+ const value4 = String(content[`${field}Href`] ?? (field.endsWith(".register") ? "/#register" : ""));
4802
+ return { type, value: value4, href: safeCmsButtonHref(value4, type) };
4803
+ }
4804
+ var cmsHeaderButtonLinkFields = ["vi", "en"].flatMap(
4805
+ (language) => ["login", "register"].flatMap((action) => {
4806
+ const field = `${language}.header.${action}`;
4807
+ const label = action === "login" ? "\u0110\u0103ng nh\u1EADp" : "M\u1EDF T\xE0i kho\u1EA3n";
4808
+ const group = language === "vi" ? "Ti\u1EBFng Vi\u1EC7t" : "English";
4809
+ return [
4810
+ {
4811
+ key: `${field}LinkType`,
4812
+ label: `${label} \u2014 lo\u1EA1i li\xEAn k\u1EBFt`,
4813
+ type: "select",
4814
+ group,
4815
+ options: [{ value: "internal", label: "Internal \u2014 trong website" }, { value: "external", label: "External \u2014 website kh\xE1c (tab m\u1EDBi)" }]
4816
+ },
4817
+ {
4818
+ key: `${field}Href`,
4819
+ label: `${label} \u2014 \u0111\u01B0\u1EDDng d\u1EABn`,
4820
+ type: "link",
4821
+ group,
4822
+ helperText: "Internal: /duong-dan/ ho\u1EB7c #muc. External: https://\u2026 M\u1EDF trong tab m\u1EDBi."
4823
+ }
4824
+ ];
4825
+ })
4826
+ );
4827
+ var cmsHeaderButtonLinkDefaults = Object.fromEntries(["vi", "en"].flatMap(
4828
+ (language) => ["login", "register"].flatMap((action) => [
4829
+ [`${language}.header.${action}LinkType`, "internal"],
4830
+ [`${language}.header.${action}Href`, action === "register" ? "/#register" : ""]
4831
+ ])
4832
+ ));
4833
+
4786
4834
  // src/shared/exact-text.tsx
4787
4835
  var import_react9 = require("react");
4788
4836
  var import_jsx_runtime9 = require("react/jsx-runtime");
@@ -5116,7 +5164,7 @@ function WebglBorder(props) {
5116
5164
  (0, import_react10.useEffect)(() => {
5117
5165
  const fx = fxRef.current;
5118
5166
  const button = fx?.parentElement;
5119
- if (!fx || !(button instanceof HTMLButtonElement)) return;
5167
+ if (!fx || !(button instanceof HTMLButtonElement || button instanceof HTMLAnchorElement)) return;
5120
5168
  const effectElement = fx;
5121
5169
  ensurePoolLifecycle();
5122
5170
  let slot = null;
@@ -5363,15 +5411,27 @@ var SpecularButton = ({
5363
5411
  className = "",
5364
5412
  type = "button",
5365
5413
  ariaHidden,
5366
- tabIndex
5414
+ tabIndex,
5415
+ href,
5416
+ target,
5417
+ rel,
5418
+ labelField,
5419
+ "data-cms-button-field": buttonField
5367
5420
  }) => {
5368
5421
  const animationDuration = Math.max(Math.PI * 2 / Math.max(speed, 0.01), 1.2);
5422
+ const Tag = href ? "a" : "button";
5369
5423
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
5370
- "button",
5424
+ Tag,
5371
5425
  {
5372
- type,
5373
- disabled,
5374
- onClick,
5426
+ ...href ? { href, target, rel, "aria-disabled": disabled || void 0 } : { type, disabled },
5427
+ "data-cms-button-field": buttonField,
5428
+ onClick: (event) => {
5429
+ if (disabled) {
5430
+ event.preventDefault();
5431
+ return;
5432
+ }
5433
+ onClick?.(event);
5434
+ },
5375
5435
  "aria-hidden": ariaHidden,
5376
5436
  tabIndex,
5377
5437
  className: `specular-button specular-button--${size}${className ? ` ${className}` : ""}`,
@@ -5406,7 +5466,7 @@ var SpecularButton = ({
5406
5466
  autoAnimate
5407
5467
  }
5408
5468
  ),
5409
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ExactText, { cmsAs: "span", className: "specular-button__label", children })
5469
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ExactText, { cmsAs: "span", cmsField: labelField, className: "specular-button__label", children })
5410
5470
  ]
5411
5471
  }
5412
5472
  );
@@ -5433,48 +5493,48 @@ var dropOut = (0, import_styled_components3.keyframes)([
5433
5493
  `from{opacity:1;transform:translateY(0);}to{opacity:0;transform:translateY(-12px);}`
5434
5494
  ]);
5435
5495
  var HeaderShell = import_styled_components3.default.header.withConfig({
5436
- componentId: "sc-5ada3506-0"
5496
+ componentId: "sc-4d456d17-0"
5437
5497
  })([
5438
5498
  `position:sticky;top:0;z-index:100;display:flex;height:64px;padding:12px 20px;align-items:center;justify-content:center;background:`,
5439
5499
  `;box-shadow:0 1px 12px rgb(0 0 0 / 4%);:root[data-theme="dark"] &{background:#18181a;}@media (max-width:768px){padding-inline:15px;}@media (max-width:620px){height:62px;padding:16px 16px 12px;box-shadow:0 1px 0 rgb(5 8 15 / 8%);}`
5440
5500
  ], ({ theme }) => theme.colors.background.canvas);
5441
5501
  var HeaderInner = import_styled_components3.default.div.withConfig({
5442
- componentId: "sc-5ada3506-1"
5502
+ componentId: "sc-4d456d17-1"
5443
5503
  })([
5444
5504
  `display:flex;width:100%;max-width:1560px;height:40px;margin:0 auto;align-items:center;gap:32px;@media (max-width:1279px){justify-content:space-between;}@media only screen and (max-width:767px){gap:0;}@media (max-width:620px){height:34px;justify-content:space-between;}`
5445
5505
  ]);
5446
5506
  var BrandGroup = import_styled_components3.default.div.withConfig({
5447
- componentId: "sc-5ada3506-2"
5507
+ componentId: "sc-4d456d17-2"
5448
5508
  })([
5449
5509
  `display:flex;flex:0 0 auto;align-items:center;gap:16px;`
5450
5510
  ]);
5451
5511
  var WikiBrand = (0, import_styled_components3.default)(import_link.default).withConfig({
5452
- componentId: "sc-5ada3506-3"
5512
+ componentId: "sc-4d456d17-3"
5453
5513
  })([
5454
5514
  `display:inline-flex;flex:0 0 auto;align-items:center;`
5455
5515
  ]);
5456
5516
  var WikiLogo = (0, import_styled_components3.default)(import_image.default).withConfig({
5457
- componentId: "sc-5ada3506-4"
5517
+ componentId: "sc-4d456d17-4"
5458
5518
  })([
5459
5519
  `display:block;width:142px;height:auto;@media (max-width:620px){width:84px;}`
5460
5520
  ]);
5461
5521
  var PartnerBrand = import_styled_components3.default.a.withConfig({
5462
- componentId: "sc-5ada3506-5"
5522
+ componentId: "sc-4d456d17-5"
5463
5523
  })([
5464
5524
  `display:inline-flex;align-items:center;gap:7.2px;color:#009ee3;@media (max-width:767px){display:inline-flex;}`
5465
5525
  ]);
5466
5526
  var MxvLogo = (0, import_styled_components3.default)(import_image.default).withConfig({
5467
- componentId: "sc-5ada3506-6"
5527
+ componentId: "sc-4d456d17-6"
5468
5528
  })([
5469
5529
  `display:block;width:95px;height:auto;:root[data-theme="dark"] &{filter:brightness(0) invert(1);}@media (max-width:620px){width:95px;}`
5470
5530
  ]);
5471
5531
  var DesktopNavigation = import_styled_components3.default.nav.withConfig({
5472
- componentId: "sc-5ada3506-7"
5532
+ componentId: "sc-4d456d17-7"
5473
5533
  })([
5474
5534
  `display:flex;align-items:center;gap:16px;@media (max-width:1279px){display:none;}`
5475
5535
  ]);
5476
5536
  var NavigationLink = (0, import_styled_components3.default)(import_link.default).withConfig({
5477
- componentId: "sc-5ada3506-8"
5537
+ componentId: "sc-4d456d17-8"
5478
5538
  })([
5479
5539
  `position:relative;color:`,
5480
5540
  `;font-size:14px;font-weight:700;line-height:18px;white-space:nowrap;transition:color 160ms ease;&:hover,&:focus-visible{color:`,
@@ -5482,14 +5542,14 @@ var NavigationLink = (0, import_styled_components3.default)(import_link.default)
5482
5542
  `;}@media (min-width:1280px) and (max-width:1439px){font-size:11px;}`
5483
5543
  ], ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
5484
5544
  var ProductsMenuTrigger = import_styled_components3.default.button.withConfig({
5485
- componentId: "sc-5ada3506-9"
5545
+ componentId: "sc-4d456d17-9"
5486
5546
  })([
5487
5547
  `display:inline-flex;align-items:center;gap:4px;padding:0;border:0;color:`,
5488
5548
  `;background:transparent;cursor:pointer;font-family:inherit;font-size:14px;font-weight:700;line-height:18px;white-space:nowrap;&[data-state="open"],&[data-active="true"],&:hover,&:focus-visible{color:`,
5489
5549
  `;}&:focus-visible{outline:none;}&::after{content:"";border-inline:3px solid transparent;border-top:4px solid currentColor;transition:transform 160ms ease;}&[data-state="open"]::after{transform:rotate(180deg);}@media (min-width:1280px) and (max-width:1439px){font-size:11px;}@media (prefers-reduced-motion:reduce){&::after{transition:none;}}`
5490
5550
  ], ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.accent.primary);
5491
5551
  var ProductsMenuContent = (0, import_styled_components3.default)(import_radix_ui.DropdownMenu.Content).withConfig({
5492
- componentId: "sc-5ada3506-10"
5552
+ componentId: "sc-4d456d17-10"
5493
5553
  })([
5494
5554
  `z-index:300;width:206px;max-width:var(--radix-dropdown-menu-content-available-width);padding:8px;border:1px solid `,
5495
5555
  `;border-radius:8px;color:`,
@@ -5499,42 +5559,42 @@ var ProductsMenuContent = (0, import_styled_components3.default)(import_radix_ui
5499
5559
  `;}`
5500
5560
  ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.popup, ({ theme }) => theme.colors.effect.popupShadow, ({ theme }) => theme.colors.border.subtle);
5501
5561
  var ProductsMenuItem = (0, import_styled_components3.default)(import_radix_ui.DropdownMenu.Item).withConfig({
5502
- componentId: "sc-5ada3506-11"
5562
+ componentId: "sc-4d456d17-11"
5503
5563
  })([
5504
5564
  `display:flex;height:44px;align-items:center;padding:12px 8px;border-radius:4px;cursor:pointer;font-size:14px;font-weight:400;line-height:18px;outline:none;color:inherit;text-decoration:none;&[aria-current="page"],&[data-highlighted],&:focus-visible{color:`,
5505
5565
  `;background:transparent;outline:none;}`
5506
5566
  ], ({ theme }) => theme.colors.accent.primary);
5507
5567
  var MobileNavigation2 = import_styled_components3.default.div.withConfig({
5508
- componentId: "sc-5ada3506-12"
5568
+ componentId: "sc-4d456d17-12"
5509
5569
  })([
5510
5570
  `position:relative;display:none;align-items:center;gap:8px;@media (max-width:1279px){display:flex;}@media (max-width:767px){order:3;margin-left:auto;}@media (max-width:620px){gap:2px;}`
5511
5571
  ]);
5512
5572
  var MobileThemeToggle = import_styled_components3.default.div.withConfig({
5513
- componentId: "sc-5ada3506-13"
5573
+ componentId: "sc-4d456d17-13"
5514
5574
  })([
5515
5575
  `display:none;align-items:center;@media (max-width:767px){display:flex;}@media (max-width:620px){&& .theme-toggle--header{border-radius:4px;svg{width:20px;height:20px;}}}`
5516
5576
  ]);
5517
5577
  var MobileLanguageToggle = import_styled_components3.default.div.withConfig({
5518
- componentId: "sc-5ada3506-14"
5578
+ componentId: "sc-4d456d17-14"
5519
5579
  })([
5520
5580
  `display:none;align-items:center;@media (max-width:767px){display:flex;}`
5521
5581
  ]);
5522
5582
  var MobileMenuTrigger = import_styled_components3.default.button.withConfig({
5523
- componentId: "sc-5ada3506-15"
5583
+ componentId: "sc-4d456d17-15"
5524
5584
  })([
5525
5585
  `display:inline-flex;width:42px;height:42px;align-items:center;justify-content:center;border:0;border-radius:9999px;color:`,
5526
5586
  `;background:transparent;cursor:pointer;transition:background-color 160ms ease;&:hover,&[data-state="open"]{background:`,
5527
5587
  `;}@media (max-width:620px){width:24px;height:24px;border-radius:4px;svg{flex-shrink:0;}}`
5528
5588
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover);
5529
5589
  var MobileDrawerOverlay = (0, import_styled_components3.default)(import_radix_ui.Dialog.Overlay).withConfig({
5530
- componentId: "sc-5ada3506-16"
5590
+ componentId: "sc-4d456d17-16"
5531
5591
  })([
5532
5592
  `position:fixed;z-index:200;inset:0;background:rgb(0 0 0 / 48%);backdrop-filter:blur(2px);&[data-state="open"]{animation:`,
5533
5593
  ` 220ms ease-out;}&[data-state="closed"]{animation:`,
5534
5594
  ` 180ms ease-in;}@media (prefers-reduced-motion:reduce){animation:none;}@media (max-width:767px){top:var(--header-height);background:rgb(5 8 16 / 40%);backdrop-filter:blur(5px);}`
5535
5595
  ], fadeIn, fadeOut);
5536
5596
  var MobileDrawerContent = (0, import_styled_components3.default)(import_radix_ui.Dialog.Content).withConfig({
5537
- componentId: "sc-5ada3506-17"
5597
+ componentId: "sc-4d456d17-17"
5538
5598
  })([
5539
5599
  `position:fixed;z-index:201;top:0;right:0;width:320px;max-width:calc(100% - 24px);height:100vh;padding:20px;overflow-y:auto;color:`,
5540
5600
  `;background:`,
@@ -5545,29 +5605,29 @@ var MobileDrawerContent = (0, import_styled_components3.default)(import_radix_ui
5545
5605
  ` 180ms ease-in;}}`
5546
5606
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.canvas, slideIn, slideOut, dropIn, dropOut);
5547
5607
  var MobileDrawerHeader = import_styled_components3.default.div.withConfig({
5548
- componentId: "sc-5ada3506-18"
5608
+ componentId: "sc-4d456d17-18"
5549
5609
  })([
5550
5610
  `display:flex;min-height:44px;margin-bottom:24px;align-items:center;justify-content:space-between;gap:16px;@media (max-width:767px){display:none;}`
5551
5611
  ]);
5552
5612
  var MobileDrawerTitle = (0, import_styled_components3.default)(import_radix_ui.Dialog.Title).withConfig({
5553
- componentId: "sc-5ada3506-19"
5613
+ componentId: "sc-4d456d17-19"
5554
5614
  })([
5555
5615
  `margin:0;font-size:20px;font-weight:700;line-height:28px;`
5556
5616
  ]);
5557
5617
  var MobileDrawerClose = (0, import_styled_components3.default)(import_radix_ui.Dialog.Close).withConfig({
5558
- componentId: "sc-5ada3506-20"
5618
+ componentId: "sc-4d456d17-20"
5559
5619
  })([
5560
5620
  `display:inline-flex;width:40px;height:40px;flex:0 0 40px;align-items:center;justify-content:center;border:0;border-radius:50%;color:`,
5561
5621
  `;background:transparent;cursor:pointer;&:hover{background:`,
5562
5622
  `;}`
5563
5623
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover);
5564
5624
  var MobileDrawerActions = import_styled_components3.default.div.withConfig({
5565
- componentId: "sc-5ada3506-21"
5625
+ componentId: "sc-4d456d17-21"
5566
5626
  })([
5567
5627
  `display:none;@media (max-width:767px){display:grid;width:100%;margin-bottom:8px;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}`
5568
5628
  ]);
5569
5629
  var MobileMenuPanel = import_styled_components3.default.nav.withConfig({
5570
- componentId: "sc-5ada3506-22"
5630
+ componentId: "sc-4d456d17-22"
5571
5631
  })([
5572
5632
  `display:flex;flex-direction:column;gap:6px;a,button{width:100%;border:0;display:flex;border-radius:8px;padding:14px 12px;color:`,
5573
5633
  `;background:transparent;cursor:pointer;font-family:inherit;font-size:14px;font-weight:600;text-align:left;transition:color 160ms ease,background-color 160ms ease;}a:hover,a:focus-visible,button:not(:disabled):hover,button:not(:disabled):focus-visible{color:`,
@@ -5576,72 +5636,72 @@ var MobileMenuPanel = import_styled_components3.default.nav.withConfig({
5576
5636
  `;}.mobile-menu-submenu a{padding-left:28px;font-size:13px;font-weight:500;}.mobile-products-chevron{display:inline-flex;transition:transform 160ms ease;}.mobile-menu-accordion-trigger[aria-expanded="true"] .mobile-products-chevron{transform:rotate(180deg);}@media (max-width:767px){gap:0;a,button{display:flex;min-height:42px;align-items:center;justify-content:space-between;padding:12px 0;font-weight:700;line-height:18px;}a[data-accent="true"]{color:#f9bb3a;}.mobile-menu-submenu a{min-height:34px;padding:7px 0 7px 20px;font-size:14px;font-weight:500;}.mobile-menu-login{display:none;}svg{width:18px;height:18px;flex:0 0 18px;}}@media (prefers-reduced-motion:reduce){.mobile-products-chevron{transition:none;}}`
5577
5637
  ], ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover, ({ theme }) => theme.colors.accent.primary);
5578
5638
  var RightActions = import_styled_components3.default.div.withConfig({
5579
- componentId: "sc-5ada3506-23"
5639
+ componentId: "sc-4d456d17-23"
5580
5640
  })([
5581
5641
  `display:flex;margin-left:auto;align-items:center;gap:12px;& > div{display:flex;align-items:center;gap:8px;}@media (max-width:1279px){display:none;}`
5582
5642
  ]);
5583
5643
  var IconButton2 = import_styled_components3.default.button.withConfig({
5584
- componentId: "sc-5ada3506-24"
5644
+ componentId: "sc-4d456d17-24"
5585
5645
  })([
5586
5646
  `display:inline-flex;width:36px;height:36px;flex:0 0 auto;align-items:center;justify-content:center;border:0;border-radius:8px;color:`,
5587
5647
  `;background:transparent;cursor:pointer;transition:background-color 160ms ease;svg{width:24px;height:24px;}&:hover{background:`,
5588
5648
  `;}@media (max-width:480px){display:none;}`
5589
5649
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover);
5590
5650
  var LanguageTrigger = (0, import_styled_components3.default)(IconButton2).withConfig({
5591
- componentId: "sc-5ada3506-25"
5651
+ componentId: "sc-4d456d17-25"
5592
5652
  })([
5593
5653
  `&[data-state="open"]{color:#f9bb3a;background:`,
5594
5654
  `;}@media (max-width:767px){display:inline-flex;}@media (max-width:620px){border-radius:4px;svg{width:20px;height:20px;flex-shrink:0;}}`
5595
5655
  ], ({ theme }) => theme.colors.background.hover);
5596
5656
  var LanguageMenuContent = (0, import_styled_components3.default)(import_radix_ui.DropdownMenu.Content).withConfig({
5597
- componentId: "sc-5ada3506-26"
5657
+ componentId: "sc-4d456d17-26"
5598
5658
  })([
5599
5659
  `z-index:300;width:180px;padding:8px;border:1px solid #e6e7ea;border-radius:12px;color:#05080f;background:#f9fafb;box-shadow:0 4px 8px rgb(5 8 16 / 5%);outline:none;transform-origin:var(--radix-dropdown-menu-content-transform-origin);&[data-state="open"]{animation:`,
5600
5660
  ` 140ms ease-out;}&[data-state="closed"]{animation:`,
5601
5661
  ` 100ms ease-in;}:root[data-theme="dark"] &{border-color:#48484a;color:#f2f2f7;background:#2c2c2e;box-shadow:0 4px 12px rgb(0 0 0 / 24%);}&[data-compact="true"]{width:148px;padding:6px;}@media (prefers-reduced-motion:reduce){animation:none;}`
5602
5662
  ], fadeIn, fadeOut);
5603
5663
  var LanguageMenuItem = (0, import_styled_components3.default)(import_radix_ui.DropdownMenu.RadioItem).withConfig({
5604
- componentId: "sc-5ada3506-27"
5664
+ componentId: "sc-4d456d17-27"
5605
5665
  })([
5606
5666
  `display:flex;width:100%;height:46px;padding:12px 8px;align-items:center;gap:8px;border-radius:8px;cursor:pointer;font-size:16px;font-weight:500;line-height:22px;outline:none;user-select:none;&[data-highlighted]{background:#f1f2f4;}:root[data-theme="dark"] &[data-highlighted]{background:#3a3a3c;}`,
5607
5667
  `[data-compact="true"] &{height:40px;padding:10px 6px;font-size:14px;line-height:18px;}`
5608
5668
  ], LanguageMenuContent);
5609
5669
  var LanguageFlag = import_styled_components3.default.span.withConfig({
5610
- componentId: "sc-5ada3506-28"
5670
+ componentId: "sc-4d456d17-28"
5611
5671
  })([
5612
5672
  `display:inline-flex;width:20px;height:20px;flex:0 0 20px;overflow:hidden;align-items:center;justify-content:center;border-radius:50%;img{width:100%;height:100%;max-width:none;object-fit:cover;}`
5613
5673
  ]);
5614
5674
  var LanguageItemIndicator = (0, import_styled_components3.default)(import_radix_ui.DropdownMenu.ItemIndicator).withConfig({
5615
- componentId: "sc-5ada3506-29"
5675
+ componentId: "sc-4d456d17-29"
5616
5676
  })([
5617
5677
  `display:inline-flex;width:18px;height:18px;margin-left:auto;flex:0 0 18px;align-items:center;justify-content:center;img{display:block;width:18px;height:18px;}`,
5618
5678
  `[data-compact="true"] &,`,
5619
5679
  `[data-compact="true"] & img{width:16px;height:16px;flex-basis:16px;}`
5620
5680
  ], LanguageMenuContent, LanguageMenuContent);
5621
5681
  var ActionDivider = import_styled_components3.default.span.withConfig({
5622
- componentId: "sc-5ada3506-30"
5682
+ componentId: "sc-4d456d17-30"
5623
5683
  })([
5624
5684
  `width:1px;height:16px;background:`,
5625
5685
  `;@media (max-width:608px){display:none;}`
5626
5686
  ], ({ theme }) => theme.colors.border.line);
5627
- var LoginLink = import_styled_components3.default.button.withConfig({
5628
- componentId: "sc-5ada3506-31"
5687
+ var LoginLink = import_styled_components3.default.a.withConfig({
5688
+ componentId: "sc-4d456d17-31"
5629
5689
  })([
5630
- `display:inline-flex;height:40px;align-items:center;justify-content:center;border:1px solid #d2d5da;border-radius:6px;padding:0 16px;color:#05080f;background:transparent;font-size:14px;font-weight:700;line-height:18px;white-space:nowrap;transition:background-color 160ms ease,border-color 160ms ease;:root[data-theme="dark"] &{color:#fafafa;}&:not(:disabled):hover{background:`,
5631
- `;}&:disabled{cursor:not-allowed;opacity:0.55;}@media (max-width:608px){display:none;}`
5690
+ `display:inline-flex;text-decoration:none;height:40px;align-items:center;justify-content:center;border:1px solid #d2d5da;border-radius:6px;padding:0 16px;color:#05080f;background:transparent;font-size:14px;font-weight:700;line-height:18px;white-space:nowrap;transition:background-color 160ms ease,border-color 160ms ease;:root[data-theme="dark"] &{color:#fafafa;}&:not([aria-disabled="true"]):hover{background:`,
5691
+ `;}&[aria-disabled="true"]{cursor:not-allowed;opacity:0.55;}@media (max-width:608px){display:none;}`
5632
5692
  ], ({ theme }) => theme.colors.background.hover);
5633
5693
  var OpenAccountButton = (0, import_styled_components3.default)(Button_default).withConfig({
5634
- componentId: "sc-5ada3506-32"
5694
+ componentId: "sc-4d456d17-32"
5635
5695
  })([
5636
5696
  `width:120px;height:40px;min-height:40px;border-radius:6px;padding:0;box-shadow:0 1px 20px rgb(249 187 58 / 60%);font-family:var(--font-inter),sans-serif;font-size:14px;font-weight:600;line-height:22px;white-space:nowrap;&:hover{&::before{opacity:0.8;}}&::before{content:"";position:absolute;left:50%;bottom:0;margin-left:-49px;width:98px;height:22px;background:#ffe492;filter:blur(10px);pointer-events:none;opacity:0;transition:opacity 0.15s linear;}@media (max-width:767px){display:none;}`
5637
5697
  ]);
5638
5698
  var MobileDrawerLoginButton = (0, import_styled_components3.default)(LoginLink).withConfig({
5639
- componentId: "sc-5ada3506-33"
5699
+ componentId: "sc-4d456d17-33"
5640
5700
  })([
5641
5701
  `display:none;@media (max-width:767px){display:inline-flex;width:100%;min-width:0;padding-inline:12px;&:disabled{opacity:1;}}`
5642
5702
  ]);
5643
5703
  var MobileDrawerOpenAccountButton = (0, import_styled_components3.default)(OpenAccountButton).withConfig({
5644
- componentId: "sc-5ada3506-34"
5704
+ componentId: "sc-4d456d17-34"
5645
5705
  })([
5646
5706
  `display:none;@media (max-width:767px){display:flex;width:100%;min-width:0;}`
5647
5707
  ]);
@@ -12913,7 +12973,41 @@ function Header() {
12913
12973
  const homeUrl = useCmsLink("headerHomeUrl", "/");
12914
12974
  const mxvUrl = useCmsLink("headerMxvUrl", "https://mxv.com.vn");
12915
12975
  const content = useCmsElementContent();
12916
- const editable = useCmsElementEditing()?.editable;
12976
+ const editing = useCmsElementEditing();
12977
+ const editable = editing?.editable;
12978
+ const loginField = `${language}.header.login`;
12979
+ const registerField = `${language}.header.register`;
12980
+ const loginLink = getCmsButtonLink(content ?? {}, loginField);
12981
+ const registerLink = getCmsButtonLink(content ?? {}, registerField);
12982
+ const linkProps = (link2, field) => ({
12983
+ href: link2.href,
12984
+ target: link2.href && link2.type === "external" ? "_blank" : void 0,
12985
+ rel: link2.href && link2.type === "external" ? "noopener noreferrer" : void 0,
12986
+ "data-cms-button-field": field,
12987
+ "aria-disabled": !link2.href || void 0,
12988
+ tabIndex: !link2.href && !editable ? -1 : void 0
12989
+ });
12990
+ const handleActionClick = (event, field, mobile = false) => {
12991
+ if (editable) {
12992
+ event.preventDefault();
12993
+ event.stopPropagation();
12994
+ const text2 = event.currentTarget.querySelector("[data-cms-text-field]") ?? event.currentTarget;
12995
+ text2.focus();
12996
+ editing.onSelectText?.({ field, currentColor: text2.ownerDocument.defaultView?.getComputedStyle(text2).color ?? "" });
12997
+ return;
12998
+ }
12999
+ const link2 = field === loginField ? loginLink : registerLink;
13000
+ if (!link2.href) {
13001
+ event.preventDefault();
13002
+ return;
13003
+ }
13004
+ if (link2.type === "internal" && link2.href === "/#register" && pathname === "/" && document.getElementById("register")) {
13005
+ event.preventDefault();
13006
+ if (mobile) pendingMobileSectionRef.current = "register";
13007
+ else scrollPageTo(document.getElementById("register"));
13008
+ }
13009
+ if (mobile) setIsMenuOpen(false);
13010
+ };
12917
13011
  const keepEditorToolbarOpen = (event) => {
12918
13012
  const target = event.detail.originalEvent.target;
12919
13013
  if (editable && target?.closest?.("[data-cms-text-resize-controls],[data-cms-element-controls],.MuiPopover-root")) event.preventDefault();
@@ -13128,9 +13222,11 @@ function Header() {
13128
13222
  ExactText,
13129
13223
  {
13130
13224
  cmsAs: MobileDrawerLoginButton,
13131
- type: "button",
13132
- disabled: true,
13133
- title: t("header.loginUnavailable"),
13225
+ cmsField: "header.login",
13226
+ as: "a",
13227
+ ...linkProps(loginLink, loginField),
13228
+ title: !loginLink.href && !editable ? t("header.loginUnavailable") : void 0,
13229
+ onClick: (event) => handleActionClick(event, loginField, true),
13134
13230
  children: t("header.login")
13135
13231
  }
13136
13232
  ),
@@ -13138,10 +13234,10 @@ function Header() {
13138
13234
  ExactText,
13139
13235
  {
13140
13236
  cmsAs: MobileDrawerOpenAccountButton,
13141
- onClick: () => {
13142
- pendingMobileSectionRef.current = "register";
13143
- setIsMenuOpen(false);
13144
- },
13237
+ labelField: "header.register",
13238
+ ...linkProps(registerLink, registerField),
13239
+ disabled: !registerLink.href && !editable,
13240
+ onClick: (event) => handleActionClick(event, registerField, true),
13145
13241
  size: "sm",
13146
13242
  radius: 6,
13147
13243
  tint: "#F9BB3A",
@@ -13255,11 +13351,12 @@ function Header() {
13255
13351
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_radix_ui4.Dialog.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
13256
13352
  ExactText,
13257
13353
  {
13258
- cmsAs: "button",
13354
+ cmsAs: "a",
13355
+ cmsField: "header.login",
13259
13356
  className: "mobile-menu-login",
13260
- type: "button",
13261
- disabled: true,
13262
- title: t("header.loginUnavailable"),
13357
+ ...linkProps(loginLink, loginField),
13358
+ title: !loginLink.href && !editable ? t("header.loginUnavailable") : void 0,
13359
+ onClick: (event) => handleActionClick(event, loginField, true),
13263
13360
  children: t("header.login")
13264
13361
  }
13265
13362
  ) })
@@ -13287,9 +13384,11 @@ function Header() {
13287
13384
  ExactText,
13288
13385
  {
13289
13386
  cmsAs: LoginLink,
13290
- type: "button",
13291
- disabled: true,
13292
- title: t("header.loginUnavailable"),
13387
+ cmsField: "header.login",
13388
+ as: "a",
13389
+ ...linkProps(loginLink, loginField),
13390
+ title: !loginLink.href && !editable ? t("header.loginUnavailable") : void 0,
13391
+ onClick: (event) => handleActionClick(event, loginField),
13293
13392
  children: t("header.login")
13294
13393
  }
13295
13394
  ),
@@ -13297,10 +13396,10 @@ function Header() {
13297
13396
  ExactText,
13298
13397
  {
13299
13398
  cmsAs: OpenAccountButton,
13300
- onClick: () => {
13301
- const target = document.getElementById("register");
13302
- if (target) scrollPageTo(target);
13303
- },
13399
+ labelField: "header.register",
13400
+ ...linkProps(registerLink, registerField),
13401
+ disabled: !registerLink.href && !editable,
13402
+ onClick: (event) => handleActionClick(event, registerField),
13304
13403
  size: "sm",
13305
13404
  radius: 6,
13306
13405
  tint: "#F9BB3A",
@@ -16487,8 +16586,8 @@ var header = exactBlock(
16487
16586
  name: "Header Wikex Commodity \u2014 b\u1EA3n g\u1ED1c",
16488
16587
  description: "Header nguy\xEAn b\u1EA3n t\u1EEB wikex-commodity-frontend.",
16489
16588
  prefixes: ["header.", "language.", "theme."],
16490
- fields: headerLinkFields,
16491
- defaults: headerLinkDefaults,
16589
+ fields: [...headerLinkFields, ...cmsHeaderButtonLinkFields],
16590
+ defaults: { ...headerLinkDefaults, ...cmsHeaderButtonLinkDefaults },
16492
16591
  images: headerImages,
16493
16592
  placement: "header",
16494
16593
  icon: "solar:menu-dots-bold-duotone"
@@ -17055,6 +17154,107 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
17055
17154
  );
17056
17155
  }
17057
17156
 
17157
+ // src/shared/button-link-control.tsx
17158
+ var import_react39 = require("react");
17159
+ var import_material3 = require("@mui/material");
17160
+ var import_jsx_runtime58 = require("react/jsx-runtime");
17161
+ function CmsButtonLinkControl({ field, content, onChange }) {
17162
+ const [anchor, setAnchor] = (0, import_react39.useState)(null);
17163
+ const [href, setHref] = (0, import_react39.useState)("");
17164
+ const [type, setType] = (0, import_react39.useState)("internal");
17165
+ const [error, setError] = (0, import_react39.useState)("");
17166
+ if (!isCmsHeaderButtonField(field)) return null;
17167
+ const apply = (value4) => {
17168
+ onChange({ [`${field}Href`]: value4, [`${field}LinkType`]: type });
17169
+ setAnchor(null);
17170
+ };
17171
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
17172
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
17173
+ import_material3.IconButton,
17174
+ {
17175
+ size: "small",
17176
+ "aria-label": "Li\xEAn k\u1EBFt n\xFAt",
17177
+ title: "S\u1EEDa li\xEAn k\u1EBFt c\u1EE7a n\xFAt",
17178
+ sx: { width: 30, height: 30 },
17179
+ onMouseDown: (event) => event.preventDefault(),
17180
+ onClick: (event) => {
17181
+ const current = getCmsButtonLink(content, field);
17182
+ setHref(current.value);
17183
+ setType(current.type);
17184
+ setError("");
17185
+ setAnchor(event.currentTarget);
17186
+ },
17187
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_material3.SvgIcon, { sx: { fontSize: 19 }, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M3.9 12a4.1 4.1 0 0 1 4.1-4.1h4V6H8a6 6 0 0 0 0 12h4v-1.9H8A4.1 4.1 0 0 1 3.9 12ZM9 13h6v-2H9v2Zm7-7h-4v1.9h4a4.1 4.1 0 0 1 0 8.2h-4V18h4a6 6 0 0 0 0-12Z" }) })
17188
+ }
17189
+ ),
17190
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
17191
+ import_material3.Popover,
17192
+ {
17193
+ open: Boolean(anchor),
17194
+ anchorEl: anchor,
17195
+ container: anchor?.ownerDocument.body,
17196
+ disableScrollLock: true,
17197
+ sx: { zIndex: 1600 },
17198
+ onClose: () => setAnchor(null),
17199
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
17200
+ slotProps: { paper: { sx: { p: 1.5, width: 320, maxWidth: "calc(100% - 32px)" } } },
17201
+ children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_material3.Box, { component: "form", onSubmit: (event) => {
17202
+ event.preventDefault();
17203
+ const value4 = href.trim();
17204
+ if (value4 && !safeCmsButtonHref(value4, type)) {
17205
+ setError(type === "external" ? "Nh\u1EADp URL b\u1EAFt \u0111\u1EA7u b\u1EB1ng https:// ho\u1EB7c http://." : "Nh\u1EADp \u0111\u01B0\u1EDDng d\u1EABn b\u1EAFt \u0111\u1EA7u b\u1EB1ng / ho\u1EB7c #.");
17206
+ return;
17207
+ }
17208
+ apply(value4);
17209
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_material3.Stack, { spacing: 1.5, children: [
17210
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_material3.Typography, { variant: "subtitle2", children: [
17211
+ "Li\xEAn k\u1EBFt n\xFAt ",
17212
+ field.endsWith(".login") ? "\u0110\u0103ng nh\u1EADp" : "M\u1EDF T\xE0i kho\u1EA3n"
17213
+ ] }),
17214
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
17215
+ import_material3.TextField,
17216
+ {
17217
+ select: true,
17218
+ size: "small",
17219
+ label: "Lo\u1EA1i li\xEAn k\u1EBFt",
17220
+ value: type,
17221
+ onChange: (event) => {
17222
+ setType(event.target.value);
17223
+ setError("");
17224
+ },
17225
+ slotProps: { select: { MenuProps: { disableScrollLock: true, container: anchor?.ownerDocument.body, sx: { zIndex: 1700 } } } },
17226
+ children: [
17227
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_material3.MenuItem, { value: "internal", children: "Internal \u2014 trong website" }),
17228
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_material3.MenuItem, { value: "external", children: "External \u2014 website kh\xE1c" })
17229
+ ]
17230
+ }
17231
+ ),
17232
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
17233
+ import_material3.TextField,
17234
+ {
17235
+ autoFocus: true,
17236
+ size: "small",
17237
+ label: "\u0110\u01B0\u1EDDng d\u1EABn c\u1EE7a n\xFAt",
17238
+ value: href,
17239
+ onChange: (event) => {
17240
+ setHref(event.target.value);
17241
+ setError("");
17242
+ },
17243
+ error: Boolean(error),
17244
+ placeholder: type === "external" ? "https://example.com/" : "/lien-he/ ho\u1EB7c #register",
17245
+ helperText: error || (type === "external" ? "M\u1EDF li\xEAn k\u1EBFt trong tab m\u1EDBi." : "M\u1EDF li\xEAn k\u1EBFt trong tab hi\u1EC7n t\u1EA1i.")
17246
+ }
17247
+ ),
17248
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_material3.Stack, { direction: "row", justifyContent: "space-between", children: [
17249
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_material3.Button, { size: "small", color: "inherit", onClick: () => apply(""), children: "B\u1ECF li\xEAn k\u1EBFt" }),
17250
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_material3.Button, { size: "small", variant: "contained", type: "submit", children: "\xC1p d\u1EE5ng" })
17251
+ ] })
17252
+ ] }) })
17253
+ }
17254
+ )
17255
+ ] });
17256
+ }
17257
+
17058
17258
  // src/index.ts
17059
17259
  var minimalUiComponents = [
17060
17260
  ...minimalUiBlocks,
@@ -17074,7 +17274,7 @@ var wikexCmsBlocks = sourceCmsBlocks.map((block) => {
17074
17274
  const Renderer2 = cmsBlock.Renderer;
17075
17275
  return {
17076
17276
  ...cmsBlock,
17077
- Renderer: (props) => (0, import_react39.createElement)(
17277
+ Renderer: (props) => (0, import_react40.createElement)(
17078
17278
  CmsTextColorProvider,
17079
17279
  {
17080
17280
  content: props.content,
@@ -17082,7 +17282,7 @@ var wikexCmsBlocks = sourceCmsBlocks.map((block) => {
17082
17282
  onSelectText: props.onSelectText,
17083
17283
  selectedTextField: props.selectedTextField
17084
17284
  },
17085
- (0, import_react39.createElement)(CmsElementProvider, { ...props, children: (0, import_react39.createElement)(Renderer2, props) })
17285
+ (0, import_react40.createElement)(CmsElementProvider, { ...props, children: (0, import_react40.createElement)(Renderer2, props) })
17086
17286
  )
17087
17287
  };
17088
17288
  });
@@ -17092,12 +17292,15 @@ var wikexCmsBlocks = sourceCmsBlocks.map((block) => {
17092
17292
  CMS_LIST_MARKERS,
17093
17293
  CMS_TEXT_FONTS,
17094
17294
  CMS_TEXT_LAYOUT_SUFFIX,
17295
+ CmsButtonLinkControl,
17095
17296
  CmsTextToolbar,
17096
17297
  FeesTable,
17097
17298
  applyCmsTextLayout,
17098
17299
  cmsListAnchor,
17099
17300
  cmsListMarkerType,
17100
17301
  cmsTextLayoutStyle,
17302
+ getCmsButtonLink,
17303
+ isCmsHeaderButtonField,
17101
17304
  migrateWikexChromeContent,
17102
17305
  minimalMarketingBlocks,
17103
17306
  minimalUiBlocks,
@@ -17110,6 +17313,7 @@ var wikexCmsBlocks = sourceCmsBlocks.map((block) => {
17110
17313
  rebaseCmsRichText,
17111
17314
  rebaseCmsTextLayouts,
17112
17315
  renderCmsRichText,
17316
+ safeCmsButtonHref,
17113
17317
  safeCmsTextHref,
17114
17318
  siteChromeBlocks,
17115
17319
  wikexCmsBlocks,