@wikex/admin-kit 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/admin/before-login.d.ts +5 -0
  3. package/dist/admin/before-login.js +26 -0
  4. package/dist/admin/brand.d.ts +19 -0
  5. package/dist/admin/brand.js +15 -0
  6. package/dist/admin/header.d.ts +5 -0
  7. package/dist/admin/header.js +87 -0
  8. package/dist/admin/logout-button.d.ts +8 -0
  9. package/dist/admin/logout-button.js +7 -0
  10. package/dist/admin/nav.d.ts +19 -0
  11. package/dist/admin/nav.js +285 -0
  12. package/dist/admin/theme-toggle.d.ts +5 -0
  13. package/dist/admin/theme-toggle.js +7 -0
  14. package/dist/admin/view-site.d.ts +5 -0
  15. package/dist/admin/view-site.js +6 -0
  16. package/dist/chunk-7FEACJUN.js +151 -0
  17. package/dist/chunk-BUD6BMFV.js +117 -0
  18. package/dist/chunk-GGSOO4FQ.js +27 -0
  19. package/dist/chunk-IL2CUCDG.js +2062 -0
  20. package/dist/chunk-JJLHSZ3T.js +40 -0
  21. package/dist/chunk-LC2CP5SR.js +13 -0
  22. package/dist/chunk-LP22Y3NO.js +61 -0
  23. package/dist/chunk-MDMKKWPU.js +12 -0
  24. package/dist/chunk-W4ZKDOWJ.js +37 -0
  25. package/dist/chunk-XGKGKCQ6.js +50 -0
  26. package/dist/chunk-YMBJCWN3.js +73 -0
  27. package/dist/index.d.ts +26 -0
  28. package/dist/index.js +44 -0
  29. package/dist/live-preview.d.ts +50 -0
  30. package/dist/live-preview.js +19 -0
  31. package/dist/project.d.ts +34 -0
  32. package/dist/project.js +8 -0
  33. package/dist/rich-text-client.d.ts +5 -0
  34. package/dist/rich-text-client.js +165 -0
  35. package/dist/rich-text.d.ts +5 -0
  36. package/dist/rich-text.js +6 -0
  37. package/dist/runtimeConfig-BwjQepcW.d.ts +30 -0
  38. package/dist/starter-client.d.ts +15 -0
  39. package/dist/starter-client.js +25 -0
  40. package/dist/starter.d.ts +40 -0
  41. package/dist/starter.js +62 -0
  42. package/dist/text-style-runtime.d.ts +5 -0
  43. package/dist/text-style-runtime.js +8 -0
  44. package/dist/text-styles.d.ts +86 -0
  45. package/dist/text-styles.js +22 -0
  46. package/package.json +23 -19
  47. package/src/TextStyleRuntime.tsx +0 -90
  48. package/src/admin/BeforeLogin.tsx +0 -19
  49. package/src/admin/Brand.tsx +0 -74
  50. package/src/admin/Header.tsx +0 -87
  51. package/src/admin/LogoutButton.tsx +0 -41
  52. package/src/admin/Nav.tsx +0 -35
  53. package/src/admin/NavClient.tsx +0 -288
  54. package/src/admin/ThemeToggle.tsx +0 -31
  55. package/src/admin/ViewSite.tsx +0 -11
  56. package/src/admin/useAdminBrand.ts +0 -81
  57. package/src/adminExperience.ts +0 -117
  58. package/src/index.ts +0 -11
  59. package/src/live-preview/GlobalInlineInspector.tsx +0 -334
  60. package/src/live-preview/LivePreviewEditor.tsx +0 -2088
  61. package/src/live-preview/TextStyleInspector.tsx +0 -289
  62. package/src/live-preview/index.ts +0 -23
  63. package/src/live-preview/runtimeConfig.ts +0 -52
  64. package/src/plugin.ts +0 -70
  65. package/src/project.ts +0 -82
  66. package/src/rich-text/client.tsx +0 -202
  67. package/src/rich-text/index.ts +0 -10
  68. package/src/starter/client.tsx +0 -22
  69. package/src/starter.ts +0 -95
  70. package/src/textStyles.ts +0 -161
@@ -0,0 +1,117 @@
1
+ // src/textStyles.ts
2
+ var TEXT_FONT_OPTIONS = [
3
+ { css: "", label: "M\u1EB7c \u0111\u1ECBnh", value: "default" },
4
+ { css: "var(--font-manrope), sans-serif", label: "Manrope", value: "manrope" },
5
+ { css: "var(--font-inter), sans-serif", label: "Inter", value: "inter" },
6
+ { css: "var(--font-roboto), sans-serif", label: "Roboto", value: "roboto" },
7
+ { css: "var(--font-montserrat), sans-serif", label: "Montserrat", value: "montserrat" },
8
+ { css: "var(--font-lora), serif", label: "Lora", value: "lora" },
9
+ {
10
+ css: "var(--font-playfair-display), serif",
11
+ label: "Playfair Display",
12
+ value: "playfair-display"
13
+ }
14
+ ];
15
+ var TEXT_LINE_HEIGHT_OPTIONS = [
16
+ { css: "", label: "M\u1EB7c \u0111\u1ECBnh", value: "default" },
17
+ { css: "0.9", label: "R\u1EA5t ch\u1EB7t \xB7 0.9", value: "0.9" },
18
+ { css: "1", label: "Ch\u1EB7t \xB7 1.0", value: "1" },
19
+ { css: "1.15", label: "G\u1ECDn \xB7 1.15", value: "1.15" },
20
+ { css: "1.35", label: "Ti\xEAu chu\u1EA9n \xB7 1.35", value: "1.35" },
21
+ { css: "1.5", label: "Tho\xE1ng \xB7 1.5", value: "1.5" },
22
+ { css: "1.7", label: "R\u1ED9ng \xB7 1.7", value: "1.7" }
23
+ ];
24
+ var EDITABLE_INTERACTIVE_SELECTOR = [
25
+ "a",
26
+ "button",
27
+ 'input:not([type="hidden"])',
28
+ "select",
29
+ "textarea",
30
+ '[role="button"]',
31
+ '[role="link"]',
32
+ '[tabindex]:not([tabindex="-1"])'
33
+ ].join(",");
34
+ var EDITABLE_PREVIEW_SELECTOR = [
35
+ "h1",
36
+ "h2",
37
+ "h3",
38
+ "h4",
39
+ "h5",
40
+ "h6",
41
+ "p",
42
+ "li",
43
+ "span",
44
+ "strong",
45
+ EDITABLE_INTERACTIVE_SELECTOR
46
+ ].join(",");
47
+ var isSyntheticElementStyleKey = (value) => value.startsWith("@element:");
48
+ var getEditableElementStyleKey = (element) => {
49
+ const scopedRoot = element.closest("[data-wikex-scope]");
50
+ const root = scopedRoot ?? element.ownerDocument.body;
51
+ const scope = scopedRoot?.dataset.wikexScope || "body";
52
+ const segments = [];
53
+ let current = element;
54
+ while (current && current !== root) {
55
+ const parentElement = current.parentElement;
56
+ if (!parentElement) break;
57
+ const tagName = current.tagName.toLowerCase();
58
+ const sameTagSiblings = Array.from(parentElement.children).filter(
59
+ (sibling) => sibling.tagName === current?.tagName
60
+ );
61
+ const index = sameTagSiblings.indexOf(current) + 1;
62
+ segments.push(`${tagName}:nth-of-type(${Math.max(index, 1)})`);
63
+ current = parentElement;
64
+ }
65
+ return `@element:${scope}:${segments.reverse().join(">")}`;
66
+ };
67
+ var fontValues = new Set(TEXT_FONT_OPTIONS.map((option) => option.value));
68
+ var lineHeightValues = new Set(TEXT_LINE_HEIGHT_OPTIONS.map((option) => option.value));
69
+ var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
70
+ var normalizeTextStyleValue = (value) => {
71
+ if (!isRecord(value)) return {};
72
+ const fontFamily = typeof value.fontFamily === "string" && fontValues.has(value.fontFamily) ? value.fontFamily : void 0;
73
+ const lineHeight = typeof value.lineHeight === "string" && lineHeightValues.has(value.lineHeight) ? value.lineHeight : void 0;
74
+ const legacyWidth = typeof value.width === "string" && /^\d+(?:\.\d+)?%$/.test(value.width) ? Number.parseFloat(value.width) : void 0;
75
+ const widthValue = typeof value.width === "number" ? value.width : legacyWidth;
76
+ const width = typeof widthValue === "number" && Number.isFinite(widthValue) ? Math.min(100, Math.max(5, widthValue)) : void 0;
77
+ const widthOffset = typeof value.widthOffset === "number" && Number.isFinite(value.widthOffset) ? Math.min(width ? 100 - width : 95, Math.max(0, value.widthOffset)) : void 0;
78
+ return { fontFamily, lineHeight, width, widthOffset };
79
+ };
80
+ var normalizeTextStyleMap = (value) => {
81
+ if (!isRecord(value)) return {};
82
+ return Object.fromEntries(
83
+ Object.entries(value).map(([fieldPath, fieldStyle]) => [
84
+ fieldPath,
85
+ normalizeTextStyleValue(fieldStyle)
86
+ ])
87
+ );
88
+ };
89
+ var getTextStyleCSS = (value) => {
90
+ const fontFamily = TEXT_FONT_OPTIONS.find((option) => option.value === value.fontFamily)?.css;
91
+ const lineHeight = TEXT_LINE_HEIGHT_OPTIONS.find(
92
+ (option) => option.value === value.lineHeight
93
+ )?.css;
94
+ const width = typeof value.width === "number" ? `${value.width}%` : void 0;
95
+ const widthOffset = typeof value.widthOffset === "number" ? `${value.widthOffset}%` : void 0;
96
+ return {
97
+ boxSizing: width ? "border-box" : void 0,
98
+ fontFamily: fontFamily || void 0,
99
+ lineHeight: lineHeight || void 0,
100
+ marginLeft: width ? widthOffset || "0%" : void 0,
101
+ marginRight: width ? "auto" : void 0,
102
+ maxWidth: width ? "none" : void 0,
103
+ width
104
+ };
105
+ };
106
+
107
+ export {
108
+ TEXT_FONT_OPTIONS,
109
+ TEXT_LINE_HEIGHT_OPTIONS,
110
+ EDITABLE_INTERACTIVE_SELECTOR,
111
+ EDITABLE_PREVIEW_SELECTOR,
112
+ isSyntheticElementStyleKey,
113
+ getEditableElementStyleKey,
114
+ normalizeTextStyleValue,
115
+ normalizeTextStyleMap,
116
+ getTextStyleCSS
117
+ };
@@ -0,0 +1,27 @@
1
+ // src/admin/ThemeToggle.tsx
2
+ import { useTheme } from "@payloadcms/ui";
3
+ import { Moon, Sun } from "lucide-react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ var AdminThemeToggle = () => {
6
+ const { setTheme, theme } = useTheme();
7
+ const isDark = theme === "dark";
8
+ const label = isDark ? "Chuy\u1EC3n sang giao di\u1EC7n s\xE1ng" : "Chuy\u1EC3n sang giao di\u1EC7n t\u1ED1i";
9
+ return /* @__PURE__ */ jsx(
10
+ "button",
11
+ {
12
+ "aria-checked": isDark,
13
+ "aria-label": label,
14
+ className: "admin-theme-toggle",
15
+ onClick: () => setTheme(isDark ? "light" : "dark"),
16
+ role: "switch",
17
+ title: label,
18
+ type: "button",
19
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "admin-theme-toggle__track", children: /* @__PURE__ */ jsx("span", { className: "admin-theme-toggle__thumb", children: isDark ? /* @__PURE__ */ jsx(Moon, { strokeWidth: 2.2 }) : /* @__PURE__ */ jsx(Sun, { strokeWidth: 2.2 }) }) })
20
+ }
21
+ );
22
+ };
23
+ var ThemeToggle_default = AdminThemeToggle;
24
+
25
+ export {
26
+ ThemeToggle_default
27
+ };