@drawnagency/primitives 0.1.56 → 0.1.57

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 (153) hide show
  1. package/dist/{chunk-KGYWQDBB.js → chunk-ICLXLWQ5.js} +9 -72
  2. package/dist/chunk-NSCT3AMV.js +32 -0
  3. package/dist/{chunk-EU6NZ4GS.js → chunk-PRKUXM7E.js} +23 -9
  4. package/dist/{chunk-7IAWF7LE.js → chunk-PYWS3MOJ.js} +12 -2
  5. package/dist/chunk-TG43X7JO.js +123 -0
  6. package/dist/chunk-VKAGMEKE.js +90 -0
  7. package/dist/components/editor/ChildBlockWrapper.d.ts +19 -0
  8. package/dist/components/editor/ChildBlockWrapper.d.ts.map +1 -0
  9. package/dist/components/editor/ColSpanControl.d.ts +9 -0
  10. package/dist/components/editor/ColSpanControl.d.ts.map +1 -0
  11. package/dist/components/editor/SectionWrapper.d.ts +1 -1
  12. package/dist/components/editor/SectionWrapper.d.ts.map +1 -1
  13. package/dist/components/editor/SettingsForm.d.ts +5 -1
  14. package/dist/components/editor/SettingsForm.d.ts.map +1 -1
  15. package/dist/components/primitives/EditableGrid.d.ts.map +1 -1
  16. package/dist/components/primitives/IconPicker.d.ts +7 -1
  17. package/dist/components/primitives/IconPicker.d.ts.map +1 -1
  18. package/dist/components/sections/Container/Container.d.ts +20 -0
  19. package/dist/components/sections/Container/Container.d.ts.map +1 -0
  20. package/dist/components/sections/Container/ContainerSettingsForm.d.ts +17 -0
  21. package/dist/components/sections/Container/ContainerSettingsForm.d.ts.map +1 -0
  22. package/dist/components/sections/Container/index.d.ts +11 -0
  23. package/dist/components/sections/Container/index.d.ts.map +1 -0
  24. package/dist/components/sections/IconList/IconList.d.ts +1 -0
  25. package/dist/components/sections/IconList/IconList.d.ts.map +1 -1
  26. package/dist/components/sections/IconList/IconListSettings.d.ts +3 -4
  27. package/dist/components/sections/IconList/IconListSettings.d.ts.map +1 -1
  28. package/dist/components/sections/IconList/index.d.ts +1 -0
  29. package/dist/components/sections/IconList/index.d.ts.map +1 -1
  30. package/dist/components/sections/Media/MediaBlock.d.ts +19 -0
  31. package/dist/components/sections/Media/MediaBlock.d.ts.map +1 -0
  32. package/dist/components/sections/{MediaGrid → Media}/index.d.ts +15 -25
  33. package/dist/components/sections/Media/index.d.ts.map +1 -0
  34. package/dist/components/sections/Prose/index.d.ts.map +1 -1
  35. package/dist/components/sections/Spacer/Spacer.d.ts +2 -0
  36. package/dist/components/sections/Spacer/Spacer.d.ts.map +1 -0
  37. package/dist/components/sections/Spacer/index.d.ts +6 -0
  38. package/dist/components/sections/Spacer/index.d.ts.map +1 -0
  39. package/dist/components/sections/all-sections.d.ts +29 -103
  40. package/dist/components/sections/all-sections.d.ts.map +1 -1
  41. package/dist/components/sections/register-schemas.d.ts.map +1 -1
  42. package/dist/components/shared/Tabs.d.ts +24 -0
  43. package/dist/components/shared/Tabs.d.ts.map +1 -0
  44. package/dist/components/shell/EditorShell.d.ts.map +1 -1
  45. package/dist/components/shell/SiteSettingsModal.d.ts.map +1 -1
  46. package/dist/components/shell/blockMoveDispatch.d.ts +21 -0
  47. package/dist/components/shell/blockMoveDispatch.d.ts.map +1 -0
  48. package/dist/hooks/useBlockDnd.d.ts +48 -0
  49. package/dist/hooks/useBlockDnd.d.ts.map +1 -0
  50. package/dist/index.js +56 -48
  51. package/dist/lib/block-dnd.d.ts +42 -0
  52. package/dist/lib/block-dnd.d.ts.map +1 -0
  53. package/dist/lib/block-move.d.ts +31 -0
  54. package/dist/lib/block-move.d.ts.map +1 -0
  55. package/dist/lib/container-grid.d.ts +29 -0
  56. package/dist/lib/container-grid.d.ts.map +1 -0
  57. package/dist/lib/container-ops.d.ts +44 -0
  58. package/dist/lib/container-ops.d.ts.map +1 -0
  59. package/dist/lib/dexie.d.ts.map +1 -1
  60. package/dist/lib/dexie.js +13 -0
  61. package/dist/lib/index.js +10 -7
  62. package/dist/lib/loader.d.ts.map +1 -1
  63. package/dist/lib/migrate-sections-transform.d.ts +12 -0
  64. package/dist/lib/migrate-sections-transform.d.ts.map +1 -0
  65. package/dist/lib/migrate-sections-transform.js +6 -0
  66. package/dist/lib/registry.d.ts +39 -0
  67. package/dist/lib/registry.d.ts.map +1 -1
  68. package/dist/lib/registry.js +26 -0
  69. package/dist/schemas/block.d.ts +20 -0
  70. package/dist/schemas/block.d.ts.map +1 -0
  71. package/dist/schemas/block.js +14 -0
  72. package/dist/schemas/index.js +8 -2
  73. package/dist/schemas/link.d.ts +7 -0
  74. package/dist/schemas/link.d.ts.map +1 -1
  75. package/dist/schemas/rich-text.d.ts +9 -0
  76. package/dist/schemas/rich-text.d.ts.map +1 -0
  77. package/dist/schemas/sections.d.ts +2 -0
  78. package/dist/schemas/sections.d.ts.map +1 -1
  79. package/dist/schemas/shared.d.ts +30 -0
  80. package/dist/schemas/shared.d.ts.map +1 -1
  81. package/package.json +13 -1
  82. package/src/components/brandguide/Colors.tsx +35 -33
  83. package/src/components/editor/ChildBlockWrapper.tsx +108 -0
  84. package/src/components/editor/ColSpanControl.tsx +56 -0
  85. package/src/components/editor/SectionWrapper.tsx +44 -20
  86. package/src/components/editor/SettingsForm.tsx +100 -73
  87. package/src/components/primitives/EditableGrid.tsx +40 -36
  88. package/src/components/primitives/IconPicker.tsx +116 -26
  89. package/src/components/sections/Container/Container.tsx +354 -0
  90. package/src/components/sections/Container/ContainerSettingsForm.tsx +113 -0
  91. package/src/components/sections/Container/index.tsx +51 -0
  92. package/src/components/sections/IconList/IconList.tsx +113 -43
  93. package/src/components/sections/IconList/IconListSettings.tsx +2 -2
  94. package/src/components/sections/IconList/index.tsx +1 -1
  95. package/src/components/sections/Media/MediaBlock.tsx +103 -0
  96. package/src/components/sections/Media/index.tsx +85 -0
  97. package/src/components/sections/Prose/index.tsx +1 -0
  98. package/src/components/sections/Spacer/Spacer.tsx +6 -0
  99. package/src/components/sections/Spacer/index.tsx +18 -0
  100. package/src/components/sections/all-sections.ts +10 -8
  101. package/src/components/sections/register-schemas.ts +5 -2
  102. package/src/components/shared/Tabs.tsx +63 -0
  103. package/src/components/shell/EditorShell.tsx +105 -13
  104. package/src/components/shell/SiteSettingsModal.tsx +41 -51
  105. package/src/components/shell/blockMoveDispatch.ts +40 -0
  106. package/src/hooks/useBlockDnd.ts +144 -0
  107. package/src/lib/block-dnd.ts +58 -0
  108. package/src/lib/block-move.ts +236 -0
  109. package/src/lib/container-grid.ts +58 -0
  110. package/src/lib/container-ops.ts +159 -0
  111. package/src/lib/dexie.ts +22 -0
  112. package/src/lib/loader.ts +16 -4
  113. package/src/lib/migrate-sections-transform.ts +147 -0
  114. package/src/lib/registry.ts +48 -0
  115. package/src/schemas/block.ts +40 -0
  116. package/src/schemas/link.ts +19 -1
  117. package/src/schemas/rich-text.ts +11 -0
  118. package/src/schemas/sections.ts +5 -1
  119. package/src/schemas/shared.ts +6 -0
  120. package/dist/components/brandguide/DoDontList.d.ts +0 -16
  121. package/dist/components/brandguide/DoDontList.d.ts.map +0 -1
  122. package/dist/components/brandguide/DoDontMediaGrid.d.ts +0 -16
  123. package/dist/components/brandguide/DoDontMediaGrid.d.ts.map +0 -1
  124. package/dist/components/primitives/MediaSettingsForms.d.ts +0 -23
  125. package/dist/components/primitives/MediaSettingsForms.d.ts.map +0 -1
  126. package/dist/components/sections/DoDontList/index.d.ts +0 -21
  127. package/dist/components/sections/DoDontList/index.d.ts.map +0 -1
  128. package/dist/components/sections/DoDontMediaGrid/index.d.ts +0 -55
  129. package/dist/components/sections/DoDontMediaGrid/index.d.ts.map +0 -1
  130. package/dist/components/sections/MediaGrid/MediaGrid.d.ts +0 -17
  131. package/dist/components/sections/MediaGrid/MediaGrid.d.ts.map +0 -1
  132. package/dist/components/sections/MediaGrid/index.d.ts.map +0 -1
  133. package/dist/components/sections/SplitContent/SplitContent.d.ts +0 -14
  134. package/dist/components/sections/SplitContent/SplitContent.d.ts.map +0 -1
  135. package/dist/components/sections/SplitContent/index.d.ts +0 -13
  136. package/dist/components/sections/SplitContent/index.d.ts.map +0 -1
  137. package/src/components/brandguide/DoDontList.d.ts.map +0 -1
  138. package/src/components/brandguide/DoDontList.tsx +0 -67
  139. package/src/components/brandguide/DoDontMediaGrid.d.ts.map +0 -1
  140. package/src/components/brandguide/DoDontMediaGrid.tsx +0 -19
  141. package/src/components/primitives/MediaSettingsForms.tsx +0 -128
  142. package/src/components/sections/DoDontList/index.d.ts.map +0 -1
  143. package/src/components/sections/DoDontList/index.tsx +0 -45
  144. package/src/components/sections/DoDontMediaGrid/index.d.ts.map +0 -1
  145. package/src/components/sections/DoDontMediaGrid/index.tsx +0 -63
  146. package/src/components/sections/MediaGrid/MediaGrid.d.ts.map +0 -1
  147. package/src/components/sections/MediaGrid/MediaGrid.tsx +0 -239
  148. package/src/components/sections/MediaGrid/index.d.ts.map +0 -1
  149. package/src/components/sections/MediaGrid/index.tsx +0 -57
  150. package/src/components/sections/SplitContent/SplitContent.d.ts.map +0 -1
  151. package/src/components/sections/SplitContent/SplitContent.tsx +0 -84
  152. package/src/components/sections/SplitContent/index.d.ts.map +0 -1
  153. package/src/components/sections/SplitContent/index.tsx +0 -55
@@ -1,84 +0,0 @@
1
- import { cn } from "../../../lib/cn";
2
- import { sanitizeHtml } from "../../../lib/sanitize";
3
- import { ResolvedMedia } from "../../primitives/ResolvedMedia";
4
- import { EditableRichText } from "../../primitives/EditableRichText";
5
- import { IconButton } from "../../shared/IconButton";
6
- import { ImageDropZone } from "../../primitives/ImageDropZone";
7
- import type { SectionContent } from "../../../schemas/sections";
8
- import { useMediaLibrary } from "../../shell/MediaLibraryContext";
9
- import { ImageIcon } from "lucide-react";
10
-
11
- interface Props {
12
- imageId: string | undefined;
13
- src?: string;
14
- srcset?: string;
15
- alt?: string;
16
- body: string;
17
- border?: boolean;
18
- imagePosition?: "left" | "right";
19
- onChange?: (content: SectionContent) => void;
20
- }
21
-
22
- export default function SplitContent({ imageId, src, srcset, alt, body, border, imagePosition = "left", onChange }: Props) {
23
- const mediaLibrary = useMediaLibrary();
24
-
25
- const handleImageChange = (newImageId: string) => {
26
- onChange?.({
27
- type: "split_content",
28
- content: { imageId: newImageId, body },
29
- options: { border, imagePosition },
30
- });
31
- };
32
-
33
- const handleBodyChange = (html: string) => {
34
- onChange?.({
35
- type: "split_content",
36
- content: { imageId, body: html, src, srcset, alt },
37
- options: { border, imagePosition },
38
- });
39
- };
40
-
41
- const handleImageClick = () => {
42
- mediaLibrary?.openSelectModal(handleImageChange);
43
- };
44
-
45
- return (
46
- <div className={cn(
47
- "flex flex-col gap-6 lg:flex-row lg:items-start",
48
- imagePosition === "right" && "lg:flex-row-reverse",
49
- )}>
50
- <div className={cn("group/img relative flex-shrink-0 lg:w-1/2", border && "overflow-hidden rounded-md border border-base-200")}>
51
- {onChange && mediaLibrary ? (
52
- <ImageDropZone onImageSelected={handleImageChange}>
53
- <ResolvedMedia imageId={imageId} src={src} srcset={srcset} alt={alt} className="w-full" />
54
- </ImageDropZone>
55
- ) : (
56
- <ResolvedMedia imageId={imageId} src={src} srcset={srcset} alt={alt} className="w-full" />
57
- )}
58
- {onChange && mediaLibrary && (
59
- <div className="absolute top-1.5 right-1.5 z-10 opacity-0 transition-opacity group-hover/img:opacity-100">
60
- <IconButton
61
- icon={<ImageIcon size={16} />}
62
- label="Change image"
63
- onClick={handleImageClick}
64
- className="bg-base/80 shadow-sm"
65
- />
66
- </div>
67
- )}
68
- </div>
69
- <div className="prose-content lg:w-1/2">
70
- {onChange ? (
71
- <EditableRichText
72
- value={body}
73
- onChange={handleBodyChange}
74
- isEditMode={true}
75
- preset="rich"
76
- />
77
- ) : (
78
- // eslint-disable-next-line react/no-danger
79
- <div dangerouslySetInnerHTML={{ __html: sanitizeHtml(body) }} />
80
- )}
81
- </div>
82
- </div>
83
- );
84
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAiBA,wBAkBG"}
@@ -1,55 +0,0 @@
1
- import { defineSection } from "../../../lib/registry";
2
- import { z } from "zod";
3
- import { Columns2 } from "lucide-react";
4
- import SplitContent from "./SplitContent";
5
- import { stripHtmlToPlainText, truncate } from "../../../lib/text";
6
-
7
- const schema = z.object({
8
- type: z.literal("split_content"),
9
- content: z.object({
10
- imageId: z.string().optional(),
11
- body: z.string(),
12
- }),
13
- options: z.object({
14
- border: z.boolean().optional(),
15
- imagePosition: z.enum(["left", "right"]).optional(),
16
- }).optional(),
17
- });
18
-
19
- export default defineSection({
20
- type: "split_content",
21
- label: "Split Content",
22
- icon: <Columns2 size={18} />,
23
- schema,
24
- component: ({ content, options, onChange }) => (
25
- <SplitContent
26
- imageId={content.content.imageId as string | undefined}
27
- src={(content.content as Record<string, unknown>).src as string | undefined}
28
- srcset={(content.content as Record<string, unknown>).srcset as string | undefined}
29
- alt={(content.content as Record<string, unknown>).alt as string | undefined}
30
- body={content.content.body as string}
31
- border={options?.border as boolean}
32
- imagePosition={options?.imagePosition as "left" | "right"}
33
- onChange={onChange ? (c) => onChange(c as typeof content) : undefined}
34
- />
35
- ),
36
- defaults: () => ({
37
- type: "split_content" as const,
38
- content: { imageId: undefined, body: "<p></p>" },
39
- }),
40
- settings: {
41
- imagePosition: {
42
- type: "select",
43
- label: "Image Position",
44
- default: "left",
45
- options: [
46
- { label: "Left", value: "left" },
47
- { label: "Right", value: "right" },
48
- ],
49
- },
50
- border: { type: "checkbox", label: "Show border", default: false },
51
- },
52
- getLabel: (content) => truncate(stripHtmlToPlainText(content.content.body), 60),
53
- getThumbnails: (content) =>
54
- content.content.imageId ? [{ type: "image" as const, src: content.content.imageId }] : [],
55
- });