@drawnagency/primitives 0.1.60 → 0.1.62
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/chunk-2BHPWO7M.js +558 -0
- package/dist/chunk-4E66N6UV.js +10 -0
- package/dist/{chunk-RFZNNCAS.js → chunk-53DKVAB6.js} +1 -61
- package/dist/chunk-5THS4K5D.js +123 -0
- package/dist/chunk-677NTHAZ.js +27 -0
- package/dist/{chunk-TG43X7JO.js → chunk-75P6HWPN.js} +29 -5
- package/dist/chunk-7EOSDFS3.js +10 -0
- package/dist/{chunk-ODCJQOVO.js → chunk-7IMQVDDJ.js} +1 -1
- package/dist/chunk-FJBDGYHE.js +782 -0
- package/dist/chunk-I5737FJY.js +62 -0
- package/dist/chunk-JRT4KWHU.js +1201 -0
- package/dist/chunk-QWDOJUUO.js +648 -0
- package/dist/{chunk-BT7STGDW.js → chunk-TEYTLQVH.js} +0 -15
- package/dist/chunk-WDSVHKAH.js +54 -0
- package/dist/{chunk-Q5EEYBMJ.js → chunk-ZYXLNJ5M.js} +6 -30
- package/dist/components/brandguide/ColorSwatchSettings.d.ts +1 -1
- package/dist/components/brandguide/ColorSwatchSettings.d.ts.map +1 -1
- package/dist/components/brandguide/Colors.d.ts +1 -1
- package/dist/components/brandguide/Colors.d.ts.map +1 -1
- package/dist/components/editor/index.js +642 -0
- package/dist/components/primitives/IconPicker.d.ts +1 -7
- package/dist/components/primitives/IconPicker.d.ts.map +1 -1
- package/dist/components/primitives/index.d.ts +10 -0
- package/dist/components/primitives/index.d.ts.map +1 -0
- package/dist/components/primitives/index.js +169 -0
- package/dist/components/sections/Colors/index.d.ts.map +1 -1
- package/dist/components/sections/Colors/schema.d.ts +19 -0
- package/dist/components/sections/Colors/schema.d.ts.map +1 -0
- package/dist/components/sections/DoDontMedia/DoDontMediaBlock.d.ts +20 -0
- package/dist/components/sections/DoDontMedia/DoDontMediaBlock.d.ts.map +1 -0
- package/dist/components/sections/DoDontMedia/index.d.ts +45 -0
- package/dist/components/sections/DoDontMedia/index.d.ts.map +1 -0
- package/dist/components/sections/IconList/DoDontToggle.d.ts +14 -0
- package/dist/components/sections/IconList/DoDontToggle.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -1
- package/dist/components/sections/IconList/index.d.ts.map +1 -1
- package/dist/components/sections/Media/MediaBlock.d.ts +1 -3
- package/dist/components/sections/Media/MediaBlock.d.ts.map +1 -1
- package/dist/components/sections/Media/index.d.ts +0 -1
- package/dist/components/sections/Media/index.d.ts.map +1 -1
- package/dist/components/sections/all-sections.d.ts +54 -18
- package/dist/components/sections/all-sections.d.ts.map +1 -1
- package/dist/components/sections/brand-guide.d.ts +84 -0
- package/dist/components/sections/brand-guide.d.ts.map +1 -0
- package/dist/components/sections/brand-guide.js +21 -0
- package/dist/components/sections/core-sections.d.ts +93 -0
- package/dist/components/sections/core-sections.d.ts.map +1 -0
- package/dist/components/sections/register-schemas.js +240 -3353
- package/dist/index.js +48 -46
- package/dist/lib/index.js +17 -11
- package/dist/lib/loader.d.ts.map +1 -1
- package/dist/lib/migrate-sections-transform.d.ts.map +1 -1
- package/dist/lib/migrate-sections-transform.js +1 -1
- package/dist/lib/registry.d.ts +6 -1
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/media/index.js +1 -1
- package/dist/schemas/index.js +9 -13
- package/dist/schemas/link.js +13 -0
- package/dist/schemas/shared.d.ts +0 -17
- package/dist/schemas/shared.d.ts.map +1 -1
- package/package.json +13 -1
- package/src/components/brandguide/ColorSwatchSettings.tsx +1 -1
- package/src/components/brandguide/Colors.tsx +1 -1
- package/src/components/primitives/IconPicker.tsx +27 -119
- package/src/components/primitives/index.ts +11 -0
- package/src/components/sections/Colors/index.tsx +2 -1
- package/src/components/sections/Colors/schema.ts +24 -0
- package/src/components/sections/DoDontMedia/DoDontMediaBlock.tsx +35 -0
- package/src/components/sections/DoDontMedia/index.tsx +84 -0
- package/src/components/sections/IconList/DoDontToggle.tsx +76 -0
- package/src/components/sections/IconList/IconList.tsx +24 -14
- package/src/components/sections/IconList/index.tsx +1 -0
- package/src/components/sections/Media/MediaBlock.tsx +1 -11
- package/src/components/sections/Media/index.tsx +0 -15
- package/src/components/sections/all-sections.ts +7 -35
- package/src/components/sections/brand-guide.ts +13 -0
- package/src/components/sections/core-sections.ts +26 -0
- package/src/lib/loader.ts +10 -4
- package/src/lib/migrate-sections-transform.ts +33 -5
- package/src/lib/registry.ts +6 -1
- package/src/schemas/shared.ts +0 -18
- /package/dist/{chunk-ZU2MKPTG.js → chunk-3DCG4DNU.js} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-7EOSDFS3.js";
|
|
4
|
+
|
|
5
|
+
// src/components/shared/FormLabel.tsx
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function FormLabel({ htmlFor, children, className }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
"label",
|
|
10
|
+
{
|
|
11
|
+
htmlFor,
|
|
12
|
+
className: cn("mb-1.5 block text-sm font-medium text-base-contrast", className),
|
|
13
|
+
children
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/components/shared/Input.tsx
|
|
19
|
+
import { forwardRef, useId } from "react";
|
|
20
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
21
|
+
var Input = forwardRef(function Input2({ label, value, onChange, type = "text", className, disabled, error, ...rest }, ref) {
|
|
22
|
+
const id = useId();
|
|
23
|
+
const errorId = `${id}-error`;
|
|
24
|
+
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
25
|
+
/* @__PURE__ */ jsx2(FormLabel, { htmlFor: id, children: label }),
|
|
26
|
+
/* @__PURE__ */ jsx2(
|
|
27
|
+
"input",
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
id,
|
|
31
|
+
type,
|
|
32
|
+
value,
|
|
33
|
+
onChange: (e) => onChange(e.target.value),
|
|
34
|
+
disabled,
|
|
35
|
+
"aria-invalid": error ? true : void 0,
|
|
36
|
+
"aria-describedby": error ? errorId : void 0,
|
|
37
|
+
className: cn(
|
|
38
|
+
"w-full rounded border bg-base px-3 py-2 text-sm text-base-contrast focus:outline-none focus:ring-1",
|
|
39
|
+
error ? "border-red-600 focus:border-red-600 focus:ring-red-600" : "border-base-200 focus:border-base-contrast focus:ring-base-contrast",
|
|
40
|
+
disabled && "cursor-not-allowed opacity-50"
|
|
41
|
+
),
|
|
42
|
+
...rest
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
error && /* @__PURE__ */ jsx2("p", { id: errorId, className: "mt-1 text-xs text-red-600", children: error })
|
|
46
|
+
] });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/components/shared/Checkbox.tsx
|
|
50
|
+
import { useId as useId2 } from "react";
|
|
51
|
+
import { Check } from "lucide-react";
|
|
52
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
53
|
+
function Checkbox({
|
|
54
|
+
checked,
|
|
55
|
+
onChange,
|
|
56
|
+
label,
|
|
57
|
+
description,
|
|
58
|
+
disabled,
|
|
59
|
+
className,
|
|
60
|
+
startAdornment,
|
|
61
|
+
align = "start"
|
|
62
|
+
}) {
|
|
63
|
+
const id = useId2();
|
|
64
|
+
return /* @__PURE__ */ jsxs2(
|
|
65
|
+
"label",
|
|
66
|
+
{
|
|
67
|
+
htmlFor: id,
|
|
68
|
+
className: cn(
|
|
69
|
+
"flex cursor-pointer gap-3 select-none hover:opacity-80",
|
|
70
|
+
align === "start" ? "items-start" : "items-center",
|
|
71
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
72
|
+
className
|
|
73
|
+
),
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsxs2(
|
|
76
|
+
"span",
|
|
77
|
+
{
|
|
78
|
+
className: cn(
|
|
79
|
+
"relative flex h-5 w-5 shrink-0 items-center justify-center",
|
|
80
|
+
align === "start" && "mt-0.5"
|
|
81
|
+
),
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsx3(
|
|
84
|
+
"input",
|
|
85
|
+
{
|
|
86
|
+
id,
|
|
87
|
+
type: "checkbox",
|
|
88
|
+
checked,
|
|
89
|
+
disabled,
|
|
90
|
+
onChange: (e) => onChange(e.target.checked),
|
|
91
|
+
className: "sr-only"
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsx3(
|
|
95
|
+
"span",
|
|
96
|
+
{
|
|
97
|
+
"aria-hidden": "true",
|
|
98
|
+
className: cn(
|
|
99
|
+
"flex h-5 w-5 items-center justify-center rounded border transition-colors",
|
|
100
|
+
checked ? "border-primary bg-primary text-primary-contrast" : "border-base-300 bg-base hover:border-primary",
|
|
101
|
+
disabled && "pointer-events-none"
|
|
102
|
+
),
|
|
103
|
+
children: checked && /* @__PURE__ */ jsx3(Check, { size: 14, strokeWidth: 3 })
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
startAdornment,
|
|
110
|
+
/* @__PURE__ */ jsxs2("div", { className: "text-sm", children: [
|
|
111
|
+
/* @__PURE__ */ jsx3("span", { className: "font-medium text-base-contrast", children: label }),
|
|
112
|
+
description && /* @__PURE__ */ jsx3("span", { className: "block text-base-contrast-light", children: description })
|
|
113
|
+
] })
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
FormLabel,
|
|
121
|
+
Input,
|
|
122
|
+
Checkbox
|
|
123
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/lib/events.ts
|
|
2
|
+
function createEvent(name) {
|
|
3
|
+
return {
|
|
4
|
+
dispatch(detail) {
|
|
5
|
+
window.dispatchEvent(new CustomEvent(name, { detail }));
|
|
6
|
+
},
|
|
7
|
+
listen(callback) {
|
|
8
|
+
const handler = (e) => callback(e.detail);
|
|
9
|
+
window.addEventListener(name, handler);
|
|
10
|
+
return () => window.removeEventListener(name, handler);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
var editModeEvent = createEvent("editmodechange");
|
|
15
|
+
var navChangeEvent = createEvent("sitenavchange");
|
|
16
|
+
var darkModeEvent = createEvent("sitedarkmode");
|
|
17
|
+
var siteNameChangeEvent = createEvent("sitenamechange");
|
|
18
|
+
var historySelectEvent = createEvent("history-select");
|
|
19
|
+
var siteNavChangeEvent = createEvent("sitenavchange-v2");
|
|
20
|
+
var pageSelectEvent = createEvent("pageselect");
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
createEvent,
|
|
24
|
+
editModeEvent,
|
|
25
|
+
navChangeEvent,
|
|
26
|
+
darkModeEvent
|
|
27
|
+
};
|
|
@@ -3,11 +3,31 @@ var RETIRED = /* @__PURE__ */ new Set(["split_content", "media_grid", "do_dont_g
|
|
|
3
3
|
function upgradeLegacySection(raw) {
|
|
4
4
|
if (!raw || typeof raw !== "object") return raw;
|
|
5
5
|
const section = raw;
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
if (
|
|
6
|
+
const type = section.type;
|
|
7
|
+
if (type === "media" && hasDoDont(section)) return { ...section, type: "dodont_media" };
|
|
8
|
+
if (type === "container") return upgradeContainerChildren(section);
|
|
9
|
+
if (!RETIRED.has(type)) return raw;
|
|
10
|
+
if (type === "split_content") return upgradeSplitContent(section);
|
|
11
|
+
if (type === "do_dont") return upgradeDoDont(section);
|
|
9
12
|
return upgradeGrid(section);
|
|
10
13
|
}
|
|
14
|
+
function hasDoDont(section) {
|
|
15
|
+
const content = section.content;
|
|
16
|
+
return !!content && typeof content === "object" && content.dodont != null;
|
|
17
|
+
}
|
|
18
|
+
function upgradeContainerChildren(section) {
|
|
19
|
+
const content = section.content;
|
|
20
|
+
const children = content && Array.isArray(content.children) ? content.children : null;
|
|
21
|
+
if (!children) return section;
|
|
22
|
+
let changed = false;
|
|
23
|
+
const mapped = children.map((child) => {
|
|
24
|
+
const up = upgradeLegacySection(child);
|
|
25
|
+
if (up !== child) changed = true;
|
|
26
|
+
return up;
|
|
27
|
+
});
|
|
28
|
+
if (!changed) return section;
|
|
29
|
+
return { ...section, content: { ...content, children: mapped } };
|
|
30
|
+
}
|
|
11
31
|
function buildRef(item, forceImage) {
|
|
12
32
|
const type = forceImage ? "image" : item.type;
|
|
13
33
|
const ref = { type, imageId: item.imageId ?? "" };
|
|
@@ -26,16 +46,20 @@ function buildRef(item, forceImage) {
|
|
|
26
46
|
}
|
|
27
47
|
function mapRefItem(item, parentId, index) {
|
|
28
48
|
const content = {};
|
|
49
|
+
let type = "media";
|
|
29
50
|
if (item.type === "linkedImage") {
|
|
30
51
|
content.ref = buildRef(item, true);
|
|
31
52
|
content.link = { kind: "external", href: item.href ?? "", target: item.target === "_blank" ? "_blank" : "_self" };
|
|
32
53
|
} else if (item.type === "doDontImage") {
|
|
33
54
|
content.ref = buildRef(item, true);
|
|
34
|
-
if (item.doDont !== void 0)
|
|
55
|
+
if (item.doDont !== void 0) {
|
|
56
|
+
content.dodont = item.doDont;
|
|
57
|
+
type = "dodont_media";
|
|
58
|
+
}
|
|
35
59
|
} else {
|
|
36
60
|
content.ref = buildRef(item, false);
|
|
37
61
|
}
|
|
38
|
-
return { id: `${parentId}__media_${index}`, type
|
|
62
|
+
return { id: `${parentId}__media_${index}`, type, content, options: {} };
|
|
39
63
|
}
|
|
40
64
|
function upgradeGrid(section) {
|
|
41
65
|
const id = section.id;
|