@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.mjs CHANGED
@@ -4721,6 +4721,50 @@ function chromeItemHref(item) {
4721
4721
  return item.hrefEnabled === "false" ? void 0 : safeCmsTextHref(item.href);
4722
4722
  }
4723
4723
 
4724
+ // src/shared/button-links.ts
4725
+ function isCmsHeaderButtonField(field) {
4726
+ return /^(vi|en)\.header\.(login|register)$/.test(field);
4727
+ }
4728
+ function safeCmsButtonHref(value4, type) {
4729
+ const href = safeCmsTextHref(value4);
4730
+ if (!href) return void 0;
4731
+ return (type === "external" ? /^https?:\/\//i : /^(?:\/(?!\/)|#)/).test(href) ? href : void 0;
4732
+ }
4733
+ function getCmsButtonLink(content, field) {
4734
+ const type = content[`${field}LinkType`] === "external" ? "external" : "internal";
4735
+ const value4 = String(content[`${field}Href`] ?? (field.endsWith(".register") ? "/#register" : ""));
4736
+ return { type, value: value4, href: safeCmsButtonHref(value4, type) };
4737
+ }
4738
+ var cmsHeaderButtonLinkFields = ["vi", "en"].flatMap(
4739
+ (language) => ["login", "register"].flatMap((action) => {
4740
+ const field = `${language}.header.${action}`;
4741
+ const label = action === "login" ? "\u0110\u0103ng nh\u1EADp" : "M\u1EDF T\xE0i kho\u1EA3n";
4742
+ const group = language === "vi" ? "Ti\u1EBFng Vi\u1EC7t" : "English";
4743
+ return [
4744
+ {
4745
+ key: `${field}LinkType`,
4746
+ label: `${label} \u2014 lo\u1EA1i li\xEAn k\u1EBFt`,
4747
+ type: "select",
4748
+ group,
4749
+ options: [{ value: "internal", label: "Internal \u2014 trong website" }, { value: "external", label: "External \u2014 website kh\xE1c (tab m\u1EDBi)" }]
4750
+ },
4751
+ {
4752
+ key: `${field}Href`,
4753
+ label: `${label} \u2014 \u0111\u01B0\u1EDDng d\u1EABn`,
4754
+ type: "link",
4755
+ group,
4756
+ helperText: "Internal: /duong-dan/ ho\u1EB7c #muc. External: https://\u2026 M\u1EDF trong tab m\u1EDBi."
4757
+ }
4758
+ ];
4759
+ })
4760
+ );
4761
+ var cmsHeaderButtonLinkDefaults = Object.fromEntries(["vi", "en"].flatMap(
4762
+ (language) => ["login", "register"].flatMap((action) => [
4763
+ [`${language}.header.${action}LinkType`, "internal"],
4764
+ [`${language}.header.${action}Href`, action === "register" ? "/#register" : ""]
4765
+ ])
4766
+ ));
4767
+
4724
4768
  // src/shared/exact-text.tsx
4725
4769
  import { createContext as createContext4, createElement as createElement2, isValidElement as isValidElement3, useContext as useContext4, useMemo as useMemo3 } from "react";
4726
4770
  import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
@@ -5059,7 +5103,7 @@ function WebglBorder(props) {
5059
5103
  useEffect3(() => {
5060
5104
  const fx = fxRef.current;
5061
5105
  const button = fx?.parentElement;
5062
- if (!fx || !(button instanceof HTMLButtonElement)) return;
5106
+ if (!fx || !(button instanceof HTMLButtonElement || button instanceof HTMLAnchorElement)) return;
5063
5107
  const effectElement = fx;
5064
5108
  ensurePoolLifecycle();
5065
5109
  let slot = null;
@@ -5306,15 +5350,27 @@ var SpecularButton = ({
5306
5350
  className = "",
5307
5351
  type = "button",
5308
5352
  ariaHidden,
5309
- tabIndex
5353
+ tabIndex,
5354
+ href,
5355
+ target,
5356
+ rel,
5357
+ labelField,
5358
+ "data-cms-button-field": buttonField
5310
5359
  }) => {
5311
5360
  const animationDuration = Math.max(Math.PI * 2 / Math.max(speed, 0.01), 1.2);
5361
+ const Tag = href ? "a" : "button";
5312
5362
  return /* @__PURE__ */ jsxs7(
5313
- "button",
5363
+ Tag,
5314
5364
  {
5315
- type,
5316
- disabled,
5317
- onClick,
5365
+ ...href ? { href, target, rel, "aria-disabled": disabled || void 0 } : { type, disabled },
5366
+ "data-cms-button-field": buttonField,
5367
+ onClick: (event) => {
5368
+ if (disabled) {
5369
+ event.preventDefault();
5370
+ return;
5371
+ }
5372
+ onClick?.(event);
5373
+ },
5318
5374
  "aria-hidden": ariaHidden,
5319
5375
  tabIndex,
5320
5376
  className: `specular-button specular-button--${size}${className ? ` ${className}` : ""}`,
@@ -5349,7 +5405,7 @@ var SpecularButton = ({
5349
5405
  autoAnimate
5350
5406
  }
5351
5407
  ),
5352
- /* @__PURE__ */ jsx10(ExactText, { cmsAs: "span", className: "specular-button__label", children })
5408
+ /* @__PURE__ */ jsx10(ExactText, { cmsAs: "span", cmsField: labelField, className: "specular-button__label", children })
5353
5409
  ]
5354
5410
  }
5355
5411
  );
@@ -5376,48 +5432,48 @@ var dropOut = keyframes([
5376
5432
  `from{opacity:1;transform:translateY(0);}to{opacity:0;transform:translateY(-12px);}`
5377
5433
  ]);
5378
5434
  var HeaderShell = styled3.header.withConfig({
5379
- componentId: "sc-5ada3506-0"
5435
+ componentId: "sc-4d456d17-0"
5380
5436
  })([
5381
5437
  `position:sticky;top:0;z-index:100;display:flex;height:64px;padding:12px 20px;align-items:center;justify-content:center;background:`,
5382
5438
  `;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%);}`
5383
5439
  ], ({ theme }) => theme.colors.background.canvas);
5384
5440
  var HeaderInner = styled3.div.withConfig({
5385
- componentId: "sc-5ada3506-1"
5441
+ componentId: "sc-4d456d17-1"
5386
5442
  })([
5387
5443
  `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;}`
5388
5444
  ]);
5389
5445
  var BrandGroup = styled3.div.withConfig({
5390
- componentId: "sc-5ada3506-2"
5446
+ componentId: "sc-4d456d17-2"
5391
5447
  })([
5392
5448
  `display:flex;flex:0 0 auto;align-items:center;gap:16px;`
5393
5449
  ]);
5394
5450
  var WikiBrand = styled3(Link3).withConfig({
5395
- componentId: "sc-5ada3506-3"
5451
+ componentId: "sc-4d456d17-3"
5396
5452
  })([
5397
5453
  `display:inline-flex;flex:0 0 auto;align-items:center;`
5398
5454
  ]);
5399
5455
  var WikiLogo = styled3(Image).withConfig({
5400
- componentId: "sc-5ada3506-4"
5456
+ componentId: "sc-4d456d17-4"
5401
5457
  })([
5402
5458
  `display:block;width:142px;height:auto;@media (max-width:620px){width:84px;}`
5403
5459
  ]);
5404
5460
  var PartnerBrand = styled3.a.withConfig({
5405
- componentId: "sc-5ada3506-5"
5461
+ componentId: "sc-4d456d17-5"
5406
5462
  })([
5407
5463
  `display:inline-flex;align-items:center;gap:7.2px;color:#009ee3;@media (max-width:767px){display:inline-flex;}`
5408
5464
  ]);
5409
5465
  var MxvLogo = styled3(Image).withConfig({
5410
- componentId: "sc-5ada3506-6"
5466
+ componentId: "sc-4d456d17-6"
5411
5467
  })([
5412
5468
  `display:block;width:95px;height:auto;:root[data-theme="dark"] &{filter:brightness(0) invert(1);}@media (max-width:620px){width:95px;}`
5413
5469
  ]);
5414
5470
  var DesktopNavigation = styled3.nav.withConfig({
5415
- componentId: "sc-5ada3506-7"
5471
+ componentId: "sc-4d456d17-7"
5416
5472
  })([
5417
5473
  `display:flex;align-items:center;gap:16px;@media (max-width:1279px){display:none;}`
5418
5474
  ]);
5419
5475
  var NavigationLink = styled3(Link3).withConfig({
5420
- componentId: "sc-5ada3506-8"
5476
+ componentId: "sc-4d456d17-8"
5421
5477
  })([
5422
5478
  `position:relative;color:`,
5423
5479
  `;font-size:14px;font-weight:700;line-height:18px;white-space:nowrap;transition:color 160ms ease;&:hover,&:focus-visible{color:`,
@@ -5425,14 +5481,14 @@ var NavigationLink = styled3(Link3).withConfig({
5425
5481
  `;}@media (min-width:1280px) and (max-width:1439px){font-size:11px;}`
5426
5482
  ], ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
5427
5483
  var ProductsMenuTrigger = styled3.button.withConfig({
5428
- componentId: "sc-5ada3506-9"
5484
+ componentId: "sc-4d456d17-9"
5429
5485
  })([
5430
5486
  `display:inline-flex;align-items:center;gap:4px;padding:0;border:0;color:`,
5431
5487
  `;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:`,
5432
5488
  `;}&: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;}}`
5433
5489
  ], ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.accent.primary);
5434
5490
  var ProductsMenuContent = styled3(DropdownMenu.Content).withConfig({
5435
- componentId: "sc-5ada3506-10"
5491
+ componentId: "sc-4d456d17-10"
5436
5492
  })([
5437
5493
  `z-index:300;width:206px;max-width:var(--radix-dropdown-menu-content-available-width);padding:8px;border:1px solid `,
5438
5494
  `;border-radius:8px;color:`,
@@ -5442,42 +5498,42 @@ var ProductsMenuContent = styled3(DropdownMenu.Content).withConfig({
5442
5498
  `;}`
5443
5499
  ], ({ 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);
5444
5500
  var ProductsMenuItem = styled3(DropdownMenu.Item).withConfig({
5445
- componentId: "sc-5ada3506-11"
5501
+ componentId: "sc-4d456d17-11"
5446
5502
  })([
5447
5503
  `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:`,
5448
5504
  `;background:transparent;outline:none;}`
5449
5505
  ], ({ theme }) => theme.colors.accent.primary);
5450
5506
  var MobileNavigation2 = styled3.div.withConfig({
5451
- componentId: "sc-5ada3506-12"
5507
+ componentId: "sc-4d456d17-12"
5452
5508
  })([
5453
5509
  `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;}`
5454
5510
  ]);
5455
5511
  var MobileThemeToggle = styled3.div.withConfig({
5456
- componentId: "sc-5ada3506-13"
5512
+ componentId: "sc-4d456d17-13"
5457
5513
  })([
5458
5514
  `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;}}}`
5459
5515
  ]);
5460
5516
  var MobileLanguageToggle = styled3.div.withConfig({
5461
- componentId: "sc-5ada3506-14"
5517
+ componentId: "sc-4d456d17-14"
5462
5518
  })([
5463
5519
  `display:none;align-items:center;@media (max-width:767px){display:flex;}`
5464
5520
  ]);
5465
5521
  var MobileMenuTrigger = styled3.button.withConfig({
5466
- componentId: "sc-5ada3506-15"
5522
+ componentId: "sc-4d456d17-15"
5467
5523
  })([
5468
5524
  `display:inline-flex;width:42px;height:42px;align-items:center;justify-content:center;border:0;border-radius:9999px;color:`,
5469
5525
  `;background:transparent;cursor:pointer;transition:background-color 160ms ease;&:hover,&[data-state="open"]{background:`,
5470
5526
  `;}@media (max-width:620px){width:24px;height:24px;border-radius:4px;svg{flex-shrink:0;}}`
5471
5527
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover);
5472
5528
  var MobileDrawerOverlay = styled3(Dialog.Overlay).withConfig({
5473
- componentId: "sc-5ada3506-16"
5529
+ componentId: "sc-4d456d17-16"
5474
5530
  })([
5475
5531
  `position:fixed;z-index:200;inset:0;background:rgb(0 0 0 / 48%);backdrop-filter:blur(2px);&[data-state="open"]{animation:`,
5476
5532
  ` 220ms ease-out;}&[data-state="closed"]{animation:`,
5477
5533
  ` 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);}`
5478
5534
  ], fadeIn, fadeOut);
5479
5535
  var MobileDrawerContent = styled3(Dialog.Content).withConfig({
5480
- componentId: "sc-5ada3506-17"
5536
+ componentId: "sc-4d456d17-17"
5481
5537
  })([
5482
5538
  `position:fixed;z-index:201;top:0;right:0;width:320px;max-width:calc(100% - 24px);height:100vh;padding:20px;overflow-y:auto;color:`,
5483
5539
  `;background:`,
@@ -5488,29 +5544,29 @@ var MobileDrawerContent = styled3(Dialog.Content).withConfig({
5488
5544
  ` 180ms ease-in;}}`
5489
5545
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.canvas, slideIn, slideOut, dropIn, dropOut);
5490
5546
  var MobileDrawerHeader = styled3.div.withConfig({
5491
- componentId: "sc-5ada3506-18"
5547
+ componentId: "sc-4d456d17-18"
5492
5548
  })([
5493
5549
  `display:flex;min-height:44px;margin-bottom:24px;align-items:center;justify-content:space-between;gap:16px;@media (max-width:767px){display:none;}`
5494
5550
  ]);
5495
5551
  var MobileDrawerTitle = styled3(Dialog.Title).withConfig({
5496
- componentId: "sc-5ada3506-19"
5552
+ componentId: "sc-4d456d17-19"
5497
5553
  })([
5498
5554
  `margin:0;font-size:20px;font-weight:700;line-height:28px;`
5499
5555
  ]);
5500
5556
  var MobileDrawerClose = styled3(Dialog.Close).withConfig({
5501
- componentId: "sc-5ada3506-20"
5557
+ componentId: "sc-4d456d17-20"
5502
5558
  })([
5503
5559
  `display:inline-flex;width:40px;height:40px;flex:0 0 40px;align-items:center;justify-content:center;border:0;border-radius:50%;color:`,
5504
5560
  `;background:transparent;cursor:pointer;&:hover{background:`,
5505
5561
  `;}`
5506
5562
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover);
5507
5563
  var MobileDrawerActions = styled3.div.withConfig({
5508
- componentId: "sc-5ada3506-21"
5564
+ componentId: "sc-4d456d17-21"
5509
5565
  })([
5510
5566
  `display:none;@media (max-width:767px){display:grid;width:100%;margin-bottom:8px;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}`
5511
5567
  ]);
5512
5568
  var MobileMenuPanel = styled3.nav.withConfig({
5513
- componentId: "sc-5ada3506-22"
5569
+ componentId: "sc-4d456d17-22"
5514
5570
  })([
5515
5571
  `display:flex;flex-direction:column;gap:6px;a,button{width:100%;border:0;display:flex;border-radius:8px;padding:14px 12px;color:`,
5516
5572
  `;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:`,
@@ -5519,72 +5575,72 @@ var MobileMenuPanel = styled3.nav.withConfig({
5519
5575
  `;}.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;}}`
5520
5576
  ], ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover, ({ theme }) => theme.colors.accent.primary);
5521
5577
  var RightActions = styled3.div.withConfig({
5522
- componentId: "sc-5ada3506-23"
5578
+ componentId: "sc-4d456d17-23"
5523
5579
  })([
5524
5580
  `display:flex;margin-left:auto;align-items:center;gap:12px;& > div{display:flex;align-items:center;gap:8px;}@media (max-width:1279px){display:none;}`
5525
5581
  ]);
5526
5582
  var IconButton2 = styled3.button.withConfig({
5527
- componentId: "sc-5ada3506-24"
5583
+ componentId: "sc-4d456d17-24"
5528
5584
  })([
5529
5585
  `display:inline-flex;width:36px;height:36px;flex:0 0 auto;align-items:center;justify-content:center;border:0;border-radius:8px;color:`,
5530
5586
  `;background:transparent;cursor:pointer;transition:background-color 160ms ease;svg{width:24px;height:24px;}&:hover{background:`,
5531
5587
  `;}@media (max-width:480px){display:none;}`
5532
5588
  ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover);
5533
5589
  var LanguageTrigger = styled3(IconButton2).withConfig({
5534
- componentId: "sc-5ada3506-25"
5590
+ componentId: "sc-4d456d17-25"
5535
5591
  })([
5536
5592
  `&[data-state="open"]{color:#f9bb3a;background:`,
5537
5593
  `;}@media (max-width:767px){display:inline-flex;}@media (max-width:620px){border-radius:4px;svg{width:20px;height:20px;flex-shrink:0;}}`
5538
5594
  ], ({ theme }) => theme.colors.background.hover);
5539
5595
  var LanguageMenuContent = styled3(DropdownMenu.Content).withConfig({
5540
- componentId: "sc-5ada3506-26"
5596
+ componentId: "sc-4d456d17-26"
5541
5597
  })([
5542
5598
  `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:`,
5543
5599
  ` 140ms ease-out;}&[data-state="closed"]{animation:`,
5544
5600
  ` 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;}`
5545
5601
  ], fadeIn, fadeOut);
5546
5602
  var LanguageMenuItem = styled3(DropdownMenu.RadioItem).withConfig({
5547
- componentId: "sc-5ada3506-27"
5603
+ componentId: "sc-4d456d17-27"
5548
5604
  })([
5549
5605
  `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;}`,
5550
5606
  `[data-compact="true"] &{height:40px;padding:10px 6px;font-size:14px;line-height:18px;}`
5551
5607
  ], LanguageMenuContent);
5552
5608
  var LanguageFlag = styled3.span.withConfig({
5553
- componentId: "sc-5ada3506-28"
5609
+ componentId: "sc-4d456d17-28"
5554
5610
  })([
5555
5611
  `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;}`
5556
5612
  ]);
5557
5613
  var LanguageItemIndicator = styled3(DropdownMenu.ItemIndicator).withConfig({
5558
- componentId: "sc-5ada3506-29"
5614
+ componentId: "sc-4d456d17-29"
5559
5615
  })([
5560
5616
  `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;}`,
5561
5617
  `[data-compact="true"] &,`,
5562
5618
  `[data-compact="true"] & img{width:16px;height:16px;flex-basis:16px;}`
5563
5619
  ], LanguageMenuContent, LanguageMenuContent);
5564
5620
  var ActionDivider = styled3.span.withConfig({
5565
- componentId: "sc-5ada3506-30"
5621
+ componentId: "sc-4d456d17-30"
5566
5622
  })([
5567
5623
  `width:1px;height:16px;background:`,
5568
5624
  `;@media (max-width:608px){display:none;}`
5569
5625
  ], ({ theme }) => theme.colors.border.line);
5570
- var LoginLink = styled3.button.withConfig({
5571
- componentId: "sc-5ada3506-31"
5626
+ var LoginLink = styled3.a.withConfig({
5627
+ componentId: "sc-4d456d17-31"
5572
5628
  })([
5573
- `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:`,
5574
- `;}&:disabled{cursor:not-allowed;opacity:0.55;}@media (max-width:608px){display:none;}`
5629
+ `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:`,
5630
+ `;}&[aria-disabled="true"]{cursor:not-allowed;opacity:0.55;}@media (max-width:608px){display:none;}`
5575
5631
  ], ({ theme }) => theme.colors.background.hover);
5576
5632
  var OpenAccountButton = styled3(Button_default).withConfig({
5577
- componentId: "sc-5ada3506-32"
5633
+ componentId: "sc-4d456d17-32"
5578
5634
  })([
5579
5635
  `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;}`
5580
5636
  ]);
5581
5637
  var MobileDrawerLoginButton = styled3(LoginLink).withConfig({
5582
- componentId: "sc-5ada3506-33"
5638
+ componentId: "sc-4d456d17-33"
5583
5639
  })([
5584
5640
  `display:none;@media (max-width:767px){display:inline-flex;width:100%;min-width:0;padding-inline:12px;&:disabled{opacity:1;}}`
5585
5641
  ]);
5586
5642
  var MobileDrawerOpenAccountButton = styled3(OpenAccountButton).withConfig({
5587
- componentId: "sc-5ada3506-34"
5643
+ componentId: "sc-4d456d17-34"
5588
5644
  })([
5589
5645
  `display:none;@media (max-width:767px){display:flex;width:100%;min-width:0;}`
5590
5646
  ]);
@@ -12864,7 +12920,41 @@ function Header() {
12864
12920
  const homeUrl = useCmsLink("headerHomeUrl", "/");
12865
12921
  const mxvUrl = useCmsLink("headerMxvUrl", "https://mxv.com.vn");
12866
12922
  const content = useCmsElementContent();
12867
- const editable = useCmsElementEditing()?.editable;
12923
+ const editing = useCmsElementEditing();
12924
+ const editable = editing?.editable;
12925
+ const loginField = `${language}.header.login`;
12926
+ const registerField = `${language}.header.register`;
12927
+ const loginLink = getCmsButtonLink(content ?? {}, loginField);
12928
+ const registerLink = getCmsButtonLink(content ?? {}, registerField);
12929
+ const linkProps = (link2, field) => ({
12930
+ href: link2.href,
12931
+ target: link2.href && link2.type === "external" ? "_blank" : void 0,
12932
+ rel: link2.href && link2.type === "external" ? "noopener noreferrer" : void 0,
12933
+ "data-cms-button-field": field,
12934
+ "aria-disabled": !link2.href || void 0,
12935
+ tabIndex: !link2.href && !editable ? -1 : void 0
12936
+ });
12937
+ const handleActionClick = (event, field, mobile = false) => {
12938
+ if (editable) {
12939
+ event.preventDefault();
12940
+ event.stopPropagation();
12941
+ const text2 = event.currentTarget.querySelector("[data-cms-text-field]") ?? event.currentTarget;
12942
+ text2.focus();
12943
+ editing.onSelectText?.({ field, currentColor: text2.ownerDocument.defaultView?.getComputedStyle(text2).color ?? "" });
12944
+ return;
12945
+ }
12946
+ const link2 = field === loginField ? loginLink : registerLink;
12947
+ if (!link2.href) {
12948
+ event.preventDefault();
12949
+ return;
12950
+ }
12951
+ if (link2.type === "internal" && link2.href === "/#register" && pathname === "/" && document.getElementById("register")) {
12952
+ event.preventDefault();
12953
+ if (mobile) pendingMobileSectionRef.current = "register";
12954
+ else scrollPageTo(document.getElementById("register"));
12955
+ }
12956
+ if (mobile) setIsMenuOpen(false);
12957
+ };
12868
12958
  const keepEditorToolbarOpen = (event) => {
12869
12959
  const target = event.detail.originalEvent.target;
12870
12960
  if (editable && target?.closest?.("[data-cms-text-resize-controls],[data-cms-element-controls],.MuiPopover-root")) event.preventDefault();
@@ -13079,9 +13169,11 @@ function Header() {
13079
13169
  ExactText,
13080
13170
  {
13081
13171
  cmsAs: MobileDrawerLoginButton,
13082
- type: "button",
13083
- disabled: true,
13084
- title: t("header.loginUnavailable"),
13172
+ cmsField: "header.login",
13173
+ as: "a",
13174
+ ...linkProps(loginLink, loginField),
13175
+ title: !loginLink.href && !editable ? t("header.loginUnavailable") : void 0,
13176
+ onClick: (event) => handleActionClick(event, loginField, true),
13085
13177
  children: t("header.login")
13086
13178
  }
13087
13179
  ),
@@ -13089,10 +13181,10 @@ function Header() {
13089
13181
  ExactText,
13090
13182
  {
13091
13183
  cmsAs: MobileDrawerOpenAccountButton,
13092
- onClick: () => {
13093
- pendingMobileSectionRef.current = "register";
13094
- setIsMenuOpen(false);
13095
- },
13184
+ labelField: "header.register",
13185
+ ...linkProps(registerLink, registerField),
13186
+ disabled: !registerLink.href && !editable,
13187
+ onClick: (event) => handleActionClick(event, registerField, true),
13096
13188
  size: "sm",
13097
13189
  radius: 6,
13098
13190
  tint: "#F9BB3A",
@@ -13206,11 +13298,12 @@ function Header() {
13206
13298
  /* @__PURE__ */ jsx35(Dialog5.Close, { asChild: true, children: /* @__PURE__ */ jsx35(
13207
13299
  ExactText,
13208
13300
  {
13209
- cmsAs: "button",
13301
+ cmsAs: "a",
13302
+ cmsField: "header.login",
13210
13303
  className: "mobile-menu-login",
13211
- type: "button",
13212
- disabled: true,
13213
- title: t("header.loginUnavailable"),
13304
+ ...linkProps(loginLink, loginField),
13305
+ title: !loginLink.href && !editable ? t("header.loginUnavailable") : void 0,
13306
+ onClick: (event) => handleActionClick(event, loginField, true),
13214
13307
  children: t("header.login")
13215
13308
  }
13216
13309
  ) })
@@ -13238,9 +13331,11 @@ function Header() {
13238
13331
  ExactText,
13239
13332
  {
13240
13333
  cmsAs: LoginLink,
13241
- type: "button",
13242
- disabled: true,
13243
- title: t("header.loginUnavailable"),
13334
+ cmsField: "header.login",
13335
+ as: "a",
13336
+ ...linkProps(loginLink, loginField),
13337
+ title: !loginLink.href && !editable ? t("header.loginUnavailable") : void 0,
13338
+ onClick: (event) => handleActionClick(event, loginField),
13244
13339
  children: t("header.login")
13245
13340
  }
13246
13341
  ),
@@ -13248,10 +13343,10 @@ function Header() {
13248
13343
  ExactText,
13249
13344
  {
13250
13345
  cmsAs: OpenAccountButton,
13251
- onClick: () => {
13252
- const target = document.getElementById("register");
13253
- if (target) scrollPageTo(target);
13254
- },
13346
+ labelField: "header.register",
13347
+ ...linkProps(registerLink, registerField),
13348
+ disabled: !registerLink.href && !editable,
13349
+ onClick: (event) => handleActionClick(event, registerField),
13255
13350
  size: "sm",
13256
13351
  radius: 6,
13257
13352
  tint: "#F9BB3A",
@@ -16438,8 +16533,8 @@ var header = exactBlock(
16438
16533
  name: "Header Wikex Commodity \u2014 b\u1EA3n g\u1ED1c",
16439
16534
  description: "Header nguy\xEAn b\u1EA3n t\u1EEB wikex-commodity-frontend.",
16440
16535
  prefixes: ["header.", "language.", "theme."],
16441
- fields: headerLinkFields,
16442
- defaults: headerLinkDefaults,
16536
+ fields: [...headerLinkFields, ...cmsHeaderButtonLinkFields],
16537
+ defaults: { ...headerLinkDefaults, ...cmsHeaderButtonLinkDefaults },
16443
16538
  images: headerImages,
16444
16539
  placement: "header",
16445
16540
  icon: "solar:menu-dots-bold-duotone"
@@ -17006,6 +17101,107 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
17006
17101
  );
17007
17102
  }
17008
17103
 
17104
+ // src/shared/button-link-control.tsx
17105
+ import { useState as useState18 } from "react";
17106
+ import { Box as Box9, Button as Button10, IconButton as IconButton4, MenuItem as MenuItem5, Popover, Stack as Stack6, SvgIcon as SvgIcon2, TextField as TextField5, Typography as Typography5 } from "@mui/material";
17107
+ import { Fragment as Fragment13, jsx as jsx49, jsxs as jsxs42 } from "react/jsx-runtime";
17108
+ function CmsButtonLinkControl({ field, content, onChange }) {
17109
+ const [anchor, setAnchor] = useState18(null);
17110
+ const [href, setHref] = useState18("");
17111
+ const [type, setType] = useState18("internal");
17112
+ const [error, setError] = useState18("");
17113
+ if (!isCmsHeaderButtonField(field)) return null;
17114
+ const apply = (value4) => {
17115
+ onChange({ [`${field}Href`]: value4, [`${field}LinkType`]: type });
17116
+ setAnchor(null);
17117
+ };
17118
+ return /* @__PURE__ */ jsxs42(Fragment13, { children: [
17119
+ /* @__PURE__ */ jsx49(
17120
+ IconButton4,
17121
+ {
17122
+ size: "small",
17123
+ "aria-label": "Li\xEAn k\u1EBFt n\xFAt",
17124
+ title: "S\u1EEDa li\xEAn k\u1EBFt c\u1EE7a n\xFAt",
17125
+ sx: { width: 30, height: 30 },
17126
+ onMouseDown: (event) => event.preventDefault(),
17127
+ onClick: (event) => {
17128
+ const current = getCmsButtonLink(content, field);
17129
+ setHref(current.value);
17130
+ setType(current.type);
17131
+ setError("");
17132
+ setAnchor(event.currentTarget);
17133
+ },
17134
+ children: /* @__PURE__ */ jsx49(SvgIcon2, { sx: { fontSize: 19 }, children: /* @__PURE__ */ jsx49("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" }) })
17135
+ }
17136
+ ),
17137
+ /* @__PURE__ */ jsx49(
17138
+ Popover,
17139
+ {
17140
+ open: Boolean(anchor),
17141
+ anchorEl: anchor,
17142
+ container: anchor?.ownerDocument.body,
17143
+ disableScrollLock: true,
17144
+ sx: { zIndex: 1600 },
17145
+ onClose: () => setAnchor(null),
17146
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
17147
+ slotProps: { paper: { sx: { p: 1.5, width: 320, maxWidth: "calc(100% - 32px)" } } },
17148
+ children: /* @__PURE__ */ jsx49(Box9, { component: "form", onSubmit: (event) => {
17149
+ event.preventDefault();
17150
+ const value4 = href.trim();
17151
+ if (value4 && !safeCmsButtonHref(value4, type)) {
17152
+ 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 #.");
17153
+ return;
17154
+ }
17155
+ apply(value4);
17156
+ }, children: /* @__PURE__ */ jsxs42(Stack6, { spacing: 1.5, children: [
17157
+ /* @__PURE__ */ jsxs42(Typography5, { variant: "subtitle2", children: [
17158
+ "Li\xEAn k\u1EBFt n\xFAt ",
17159
+ field.endsWith(".login") ? "\u0110\u0103ng nh\u1EADp" : "M\u1EDF T\xE0i kho\u1EA3n"
17160
+ ] }),
17161
+ /* @__PURE__ */ jsxs42(
17162
+ TextField5,
17163
+ {
17164
+ select: true,
17165
+ size: "small",
17166
+ label: "Lo\u1EA1i li\xEAn k\u1EBFt",
17167
+ value: type,
17168
+ onChange: (event) => {
17169
+ setType(event.target.value);
17170
+ setError("");
17171
+ },
17172
+ slotProps: { select: { MenuProps: { disableScrollLock: true, container: anchor?.ownerDocument.body, sx: { zIndex: 1700 } } } },
17173
+ children: [
17174
+ /* @__PURE__ */ jsx49(MenuItem5, { value: "internal", children: "Internal \u2014 trong website" }),
17175
+ /* @__PURE__ */ jsx49(MenuItem5, { value: "external", children: "External \u2014 website kh\xE1c" })
17176
+ ]
17177
+ }
17178
+ ),
17179
+ /* @__PURE__ */ jsx49(
17180
+ TextField5,
17181
+ {
17182
+ autoFocus: true,
17183
+ size: "small",
17184
+ label: "\u0110\u01B0\u1EDDng d\u1EABn c\u1EE7a n\xFAt",
17185
+ value: href,
17186
+ onChange: (event) => {
17187
+ setHref(event.target.value);
17188
+ setError("");
17189
+ },
17190
+ error: Boolean(error),
17191
+ placeholder: type === "external" ? "https://example.com/" : "/lien-he/ ho\u1EB7c #register",
17192
+ 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.")
17193
+ }
17194
+ ),
17195
+ /* @__PURE__ */ jsxs42(Stack6, { direction: "row", justifyContent: "space-between", children: [
17196
+ /* @__PURE__ */ jsx49(Button10, { size: "small", color: "inherit", onClick: () => apply(""), children: "B\u1ECF li\xEAn k\u1EBFt" }),
17197
+ /* @__PURE__ */ jsx49(Button10, { size: "small", variant: "contained", type: "submit", children: "\xC1p d\u1EE5ng" })
17198
+ ] })
17199
+ ] }) })
17200
+ }
17201
+ )
17202
+ ] });
17203
+ }
17204
+
17009
17205
  // src/index.ts
17010
17206
  var minimalUiComponents = [
17011
17207
  ...minimalUiBlocks,
@@ -17042,12 +17238,15 @@ export {
17042
17238
  CMS_LIST_MARKERS,
17043
17239
  CMS_TEXT_FONTS,
17044
17240
  CMS_TEXT_LAYOUT_SUFFIX,
17241
+ CmsButtonLinkControl,
17045
17242
  CmsTextToolbar,
17046
17243
  FeesTable,
17047
17244
  applyCmsTextLayout,
17048
17245
  cmsListAnchor,
17049
17246
  cmsListMarkerType,
17050
17247
  cmsTextLayoutStyle,
17248
+ getCmsButtonLink,
17249
+ isCmsHeaderButtonField,
17051
17250
  migrateWikexChromeContent,
17052
17251
  minimalMarketingBlocks,
17053
17252
  minimalUiBlocks,
@@ -17060,6 +17259,7 @@ export {
17060
17259
  rebaseCmsRichText,
17061
17260
  rebaseCmsTextLayouts,
17062
17261
  renderCmsRichText,
17262
+ safeCmsButtonHref,
17063
17263
  safeCmsTextHref,
17064
17264
  siteChromeBlocks,
17065
17265
  wikexCmsBlocks,