@bettercms-ai/kit 4.0.0 → 4.1.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 (125) hide show
  1. package/dist/adapters/lossy.d.ts +4 -0
  2. package/dist/adapters/lossy.js +4 -0
  3. package/dist/adapters/lossy.js.map +1 -1
  4. package/dist/adapters/prod-types.d.ts +4 -0
  5. package/dist/adapters/prod-types.js +4 -1
  6. package/dist/adapters/prod-types.js.map +1 -1
  7. package/dist/adapters/schema.js +7 -0
  8. package/dist/adapters/schema.js.map +1 -1
  9. package/dist/context.d.ts +83 -0
  10. package/dist/context.js +58 -1
  11. package/dist/context.js.map +1 -1
  12. package/dist/controls/choice.d.ts +1 -1
  13. package/dist/controls/choice.js +21 -2
  14. package/dist/controls/choice.js.map +1 -1
  15. package/dist/controls/index.d.ts +1 -0
  16. package/dist/controls/index.js +3 -2
  17. package/dist/controls/index.js.map +1 -1
  18. package/dist/controls/link.d.ts +23 -2
  19. package/dist/controls/link.js +456 -4
  20. package/dist/controls/link.js.map +1 -1
  21. package/dist/controls/media-v16.d.ts +27 -0
  22. package/dist/controls/media-v16.js +261 -0
  23. package/dist/controls/media-v16.js.map +1 -0
  24. package/dist/controls/media.js +63 -1
  25. package/dist/controls/media.js.map +1 -1
  26. package/dist/controls/reference-services.d.ts +8 -0
  27. package/dist/controls/reference.js +78 -2
  28. package/dist/controls/reference.js.map +1 -1
  29. package/dist/controls/rich-text/ai-runs.d.ts +13 -0
  30. package/dist/controls/rich-text/ai-runs.js +71 -0
  31. package/dist/controls/rich-text/ai-runs.js.map +1 -0
  32. package/dist/controls/rich-text/block-tool.d.ts +31 -0
  33. package/dist/controls/rich-text/block-tool.js +62 -0
  34. package/dist/controls/rich-text/block-tool.js.map +1 -0
  35. package/dist/controls/rich-text/blocks.d.ts +6 -1
  36. package/dist/controls/rich-text/blocks.js +404 -24
  37. package/dist/controls/rich-text/blocks.js.map +1 -1
  38. package/dist/controls/rich-text/catalog.d.ts +21 -6
  39. package/dist/controls/rich-text/catalog.js +312 -23
  40. package/dist/controls/rich-text/catalog.js.map +1 -1
  41. package/dist/controls/rich-text/code-head.d.ts +30 -0
  42. package/dist/controls/rich-text/code-head.js +230 -0
  43. package/dist/controls/rich-text/code-head.js.map +1 -0
  44. package/dist/controls/rich-text/codec.d.ts +1 -1
  45. package/dist/controls/rich-text/codec.js +3 -1
  46. package/dist/controls/rich-text/codec.js.map +1 -1
  47. package/dist/controls/rich-text/dom.d.ts +27 -0
  48. package/dist/controls/rich-text/dom.js +69 -4
  49. package/dist/controls/rich-text/dom.js.map +1 -1
  50. package/dist/controls/rich-text/editor.js +212 -50
  51. package/dist/controls/rich-text/editor.js.map +1 -1
  52. package/dist/controls/rich-text/ops.js +1 -0
  53. package/dist/controls/rich-text/ops.js.map +1 -1
  54. package/dist/controls/rich-text/slash-preview.d.ts +8 -0
  55. package/dist/controls/rich-text/slash-preview.js +287 -0
  56. package/dist/controls/rich-text/slash-preview.js.map +1 -0
  57. package/dist/controls/rich-text/table-grid.d.ts +22 -0
  58. package/dist/controls/rich-text/table-grid.js +1052 -0
  59. package/dist/controls/rich-text/table-grid.js.map +1 -0
  60. package/dist/controls/rich-text/toolbar.js +60 -18
  61. package/dist/controls/rich-text/toolbar.js.map +1 -1
  62. package/dist/controls/text.d.ts +6 -0
  63. package/dist/controls/text.js +95 -5
  64. package/dist/controls/text.js.map +1 -1
  65. package/dist/core/facets.d.ts +1 -0
  66. package/dist/core/facets.js +1 -0
  67. package/dist/core/facets.js.map +1 -1
  68. package/dist/engine/array.d.ts +7 -0
  69. package/dist/engine/array.js +164 -45
  70. package/dist/engine/array.js.map +1 -1
  71. package/dist/engine/field-shell.d.ts +12 -0
  72. package/dist/engine/field-shell.js +217 -63
  73. package/dist/engine/field-shell.js.map +1 -1
  74. package/dist/engine/frame.js +39 -2
  75. package/dist/engine/frame.js.map +1 -1
  76. package/dist/engine/grouping.d.ts +71 -10
  77. package/dist/engine/grouping.js +223 -26
  78. package/dist/engine/grouping.js.map +1 -1
  79. package/dist/engine/kit-field.js +38 -4
  80. package/dist/engine/kit-field.js.map +1 -1
  81. package/dist/engine/schema-form.js +7 -2
  82. package/dist/engine/schema-form.js.map +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.js +13 -6
  85. package/dist/index.js.map +1 -1
  86. package/dist/kit.css +85 -0
  87. package/dist/schema/table.d.ts +2 -1
  88. package/dist/schema/table.js +5 -0
  89. package/dist/schema/table.js.map +1 -1
  90. package/dist/schema/types.d.ts +6 -0
  91. package/dist/schema/types.js.map +1 -1
  92. package/dist/styles.css +1 -1
  93. package/dist/theme.css +115 -0
  94. package/dist/tokens.css +268 -0
  95. package/dist/ui/block-icon-picker.d.ts +38 -0
  96. package/dist/ui/block-icon-picker.js +141 -0
  97. package/dist/ui/block-icon-picker.js.map +1 -0
  98. package/dist/ui/button.js +1 -0
  99. package/dist/ui/button.js.map +1 -1
  100. package/dist/ui/code-language-menu.d.ts +24 -0
  101. package/dist/ui/code-language-menu.js +123 -0
  102. package/dist/ui/code-language-menu.js.map +1 -0
  103. package/dist/ui/content-fields.d.ts +47 -0
  104. package/dist/ui/content-fields.js +278 -0
  105. package/dist/ui/content-fields.js.map +1 -0
  106. package/dist/ui/foundations.d.ts +118 -0
  107. package/dist/ui/foundations.js +564 -0
  108. package/dist/ui/foundations.js.map +1 -0
  109. package/dist/ui/index.d.ts +6 -0
  110. package/dist/ui/index.js +7 -1
  111. package/dist/ui/inspector.d.ts +394 -0
  112. package/dist/ui/inspector.js +1173 -0
  113. package/dist/ui/inspector.js.map +1 -0
  114. package/dist/ui/overlay.d.ts +7 -2
  115. package/dist/ui/overlay.js +55 -20
  116. package/dist/ui/overlay.js.map +1 -1
  117. package/dist/ui/shortcut-hint.js +1 -1
  118. package/dist/ui/shortcut-hint.js.map +1 -1
  119. package/dist/ui/toast.d.ts +5 -3
  120. package/dist/ui/toast.js +83 -11
  121. package/dist/ui/toast.js.map +1 -1
  122. package/dist/ui/tooltip-card.d.ts +45 -0
  123. package/dist/ui/tooltip-card.js +135 -0
  124. package/dist/ui/tooltip-card.js.map +1 -0
  125. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { TableControl, TableFrame, TableFullScreenAction } from "./table/table.j
4
4
  import { CodeControl, CodeDialogField, CodeSurface, UnreadableValue, jsonProblem } from "./code.js";
5
5
  import { JsonControl } from "./json.js";
6
6
  import { CONTROLS } from "../engine/kit-field.js";
7
- import { EmailControl, SlugControl, SlugGenerate, StringControl, TEXT_FOCUS, TextControl, UrlControl, slugSource, slugTidy, slugTyping, str } from "./text.js";
7
+ import { EmailControl, PrefixedInput, SlugControl, SlugGenerate, StringControl, TEXT_FOCUS, TextControl, UrlControl, V16_TEXT_SURFACE, slugSource, slugTidy, slugTyping, str } from "./text.js";
8
8
  import { ColorControl, HEX_COLOR, pickerHex } from "./color.js";
9
9
  import { NUMBER_SCALE, NumberControl, PlainNumber, RatingControl, ratingScale, snapRating, toNum, ungroupNumber } from "./number.js";
10
10
  import { C1_ACTIONS, C1_CONTROLS, registerC1Controls } from "./c1.js";
@@ -17,6 +17,7 @@ import { RefThumb, ReferenceControl, ReferencesControl, referenceNoun, useRefere
17
17
  import { FormPickerControl, isFormOnly } from "./form-picker.js";
18
18
  import { IconControl, IconPicker, IconValueGlyph } from "./icon.js";
19
19
  import { LocationControl, locationFromDraft } from "./location.js";
20
+ import { V16ImageField, V16_IMAGE_ACCEPT } from "./media-v16.js";
20
21
  import { FileControl, GalleryControl, ImageControl, ImageDetails, MediaPicker, NO_CROP_OUTSIDE_LIBRARY, VideoControl, VideoPreview, acceptsFile, cropChoice, fileNameFromUrl, formatBytes, fromAsset, isVideoUrl, normImage, useUpload, videoProvider, withCrop, youTubeId } from "./media.js";
21
22
  import { ComponentSlotControl, SlotDepthContext, SlotPicker } from "./slot.js";
22
23
  import { RT_PROSE, RichTextEditor } from "./rich-text/editor.js";
@@ -34,6 +35,6 @@ function registerKitControls() {
34
35
  CONTROLS.button = ButtonControl;
35
36
  }
36
37
  //#endregion
37
- export { BUTTON_ICONS, BooleanControl, ButtonControl, ButtonIconPicker, ButtonLinkEditor, ButtonPreview, ButtonScreen, ButtonStyleGrid, C1_ACTIONS, C1_CONTROLS, C2_CONTROLS, CodeControl, CodeDialogField, CodeSurface, ColorControl, ComponentSlotControl, DateControl, EmailControl, FileControl, FormPickerControl, GalleryControl, HEX_COLOR, IconControl, IconPicker, IconValueGlyph, ImageControl, ImageDetails, JsonControl, LINK_TYPES, LinkControl, LinkField, LinkForm, LinkLine, LinkOptions, LinkPicker, LinkPopoverBody, LinkQuickEdit, LocationControl, MediaPicker, MiniCalendar, MultiSelectControl, NO_CROP_OUTSIDE_LIBRARY, NUMBER_SCALE, NumberControl, PlainNumber, REL_ITEMS, RT_PROSE, RatingControl, RefThumb, ReferenceControl, ReferencesControl, RichTextControl, RichTextEditor, RichTextExpandAction, STYLE_ITEMS, ScaleControl, ScaleSlider, SectionAnchorsProvider, SelectControl, SlotDepthContext, SlotPicker, SlugControl, SlugGenerate, StringControl, StyleGlyph, TARGET_KEYS, TEXT_FOCUS, TableControl, TableFrame, TableFullScreenAction, TagsControl, TextControl, UnknownValueNote, UnreadableValue, UrlControl, VideoControl, VideoPreview, acceptsFile, cropChoice, describeLink, detectType, fileNameFromUrl, fileTarget, finalizeLink, findTarget, formatBytes, fromAsset, hasLink, hrefOf, isFormOnly, isVideoUrl, jsonProblem, linkIcon, linkProblem, linkShapeOf, linkText, locationFromDraft, lookLabel, lookOf, nextButton, normImage, normLink, optionIcons, pickerHex, ratingScale, referenceNoun, registerC1Controls, registerC2Controls, registerKitControls, slugSource, slugTidy, slugTyping, snapRating, storedLink, str, tagRefusal, toNum, ungroupNumber, useLinkTargets, useOwnDescription, useReferenceRecords, useUpload, videoProvider, withCrop, withTarget, withText, youTubeId };
38
+ export { BUTTON_ICONS, BooleanControl, ButtonControl, ButtonIconPicker, ButtonLinkEditor, ButtonPreview, ButtonScreen, ButtonStyleGrid, C1_ACTIONS, C1_CONTROLS, C2_CONTROLS, CodeControl, CodeDialogField, CodeSurface, ColorControl, ComponentSlotControl, DateControl, EmailControl, FileControl, FormPickerControl, GalleryControl, HEX_COLOR, IconControl, IconPicker, IconValueGlyph, ImageControl, ImageDetails, JsonControl, LINK_TYPES, LinkControl, LinkField, LinkForm, LinkLine, LinkOptions, LinkPicker, LinkPopoverBody, LinkQuickEdit, LocationControl, MediaPicker, MiniCalendar, MultiSelectControl, NO_CROP_OUTSIDE_LIBRARY, NUMBER_SCALE, NumberControl, PlainNumber, PrefixedInput, REL_ITEMS, RT_PROSE, RatingControl, RefThumb, ReferenceControl, ReferencesControl, RichTextControl, RichTextEditor, RichTextExpandAction, STYLE_ITEMS, ScaleControl, ScaleSlider, SectionAnchorsProvider, SelectControl, SlotDepthContext, SlotPicker, SlugControl, SlugGenerate, StringControl, StyleGlyph, TARGET_KEYS, TEXT_FOCUS, TableControl, TableFrame, TableFullScreenAction, TagsControl, TextControl, UnknownValueNote, UnreadableValue, UrlControl, V16ImageField, V16_IMAGE_ACCEPT, V16_TEXT_SURFACE, VideoControl, VideoPreview, acceptsFile, cropChoice, describeLink, detectType, fileNameFromUrl, fileTarget, finalizeLink, findTarget, formatBytes, fromAsset, hasLink, hrefOf, isFormOnly, isVideoUrl, jsonProblem, linkIcon, linkProblem, linkShapeOf, linkText, locationFromDraft, lookLabel, lookOf, nextButton, normImage, normLink, optionIcons, pickerHex, ratingScale, referenceNoun, registerC1Controls, registerC2Controls, registerKitControls, slugSource, slugTidy, slugTyping, snapRating, storedLink, str, tagRefusal, toNum, ungroupNumber, useLinkTargets, useOwnDescription, useReferenceRecords, useUpload, videoProvider, withCrop, withTarget, withText, youTubeId };
38
39
 
39
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/controls/index.ts"],"sourcesContent":["/**\n * The ported kit controls, and the one call that puts them in the engine's CONTROLS / ACTIONS tables (and the scale\n * capsule into the number control). A registered type stops drawing the host's legacy control; a type nobody\n * registers keeps it. The kit barrel calls `registerKitControls()` once, so every host that imports the kit gets them.\n */\nimport { ButtonControl } from \"./button\";\nimport { LinkControl } from \"./link\";\nimport { registerC1Controls } from \"./c1\";\nimport { registerC2Controls } from \"./c2\";\nimport { CONTROLS } from \"../engine/kit-field\";\n\nexport * from \"./c1\";\nexport * from \"./c2\";\nexport * from \"./text\";\nexport * from \"./number\";\nexport * from \"./choice\";\nexport * from \"./color\";\nexport * from \"./date\";\nexport * from \"./icon\";\nexport * from \"./code\";\nexport * from \"./json\";\nexport * from \"./location\";\nexport * from \"./media\";\nexport * from \"./reference\";\nexport * from \"./form-picker\";\nexport * from \"./scale\";\nexport * from \"./slot\";\nexport * from \"./unknown-value\";\nexport * from \"./link\";\nexport * from \"./button\";\nexport { RichTextControl, RichTextExpandAction } from \"./rich-text/control\";\nexport { RichTextEditor, RT_PROSE } from \"./rich-text/editor\";\nexport { TableControl, TableFullScreenAction, TableFrame } from \"./table/table\";\n\nexport function registerKitControls() {\n registerC1Controls();\n registerC2Controls();\n CONTROLS.link = LinkControl;\n CONTROLS.button = ButtonControl;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,sBAAsB;CACpC,mBAAmB;CACnB,mBAAmB;CACnB,SAAS,OAAO;CAChB,SAAS,SAAS;AACpB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/controls/index.ts"],"sourcesContent":["/**\n * The ported kit controls, and the one call that puts them in the engine's CONTROLS / ACTIONS tables (and the scale\n * capsule into the number control). A registered type stops drawing the host's legacy control; a type nobody\n * registers keeps it. The kit barrel calls `registerKitControls()` once, so every host that imports the kit gets them.\n */\nimport { ButtonControl } from \"./button\";\nimport { LinkControl } from \"./link\";\nimport { registerC1Controls } from \"./c1\";\nimport { registerC2Controls } from \"./c2\";\nimport { CONTROLS } from \"../engine/kit-field\";\n\nexport * from \"./c1\";\nexport * from \"./c2\";\nexport * from \"./text\";\nexport * from \"./number\";\nexport * from \"./choice\";\nexport * from \"./color\";\nexport * from \"./date\";\nexport * from \"./icon\";\nexport * from \"./code\";\nexport * from \"./json\";\nexport * from \"./location\";\nexport * from \"./media\";\nexport * from \"./media-v16\";\nexport * from \"./reference\";\nexport * from \"./form-picker\";\nexport * from \"./scale\";\nexport * from \"./slot\";\nexport * from \"./unknown-value\";\nexport * from \"./link\";\nexport * from \"./button\";\nexport { RichTextControl, RichTextExpandAction } from \"./rich-text/control\";\nexport { RichTextEditor, RT_PROSE } from \"./rich-text/editor\";\nexport { TableControl, TableFullScreenAction, TableFrame } from \"./table/table\";\n\nexport function registerKitControls() {\n registerC1Controls();\n registerC2Controls();\n CONTROLS.link = LinkControl;\n CONTROLS.button = ButtonControl;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,sBAAsB;CACpC,mBAAmB;CACnB,mBAAmB;CACnB,SAAS,OAAO;CAChB,SAAS,SAAS;AACpB"}
@@ -215,7 +215,20 @@ export declare function LinkForm({ value, onChange, onEnter, hideOptions, hideNe
215
215
  readOnly?: boolean;
216
216
  className?: string;
217
217
  }): import("react/jsx-runtime").JSX.Element;
218
- export declare function LinkPopoverBody({ initial, onSave, onDetach, onCancel, hideOptions, hideNewTab, types, dirty, }: {
218
+ export declare function LinkPopoverBody({ initial, onSave, onDetach, onCancel, hideOptions, hideNewTab, types, dirty, hideRel, pages, sections, flush, }: LinkPopoverBodyProps): import("react/jsx-runtime").JSX.Element;
219
+ /** A page the v16 link panel lists, when the host hands the list in (else `KitServices.useLinkTargets`). */
220
+ export interface LinkPopoverPage {
221
+ title: string;
222
+ /** "/pricing" */
223
+ path: string;
224
+ }
225
+ /** A section of the page being edited, when the host hands the list in (else `SectionAnchorsProvider`). */
226
+ export interface LinkPopoverSection {
227
+ name: string;
228
+ /** "#faq" */
229
+ href: string;
230
+ }
231
+ export interface LinkPopoverBodyProps {
219
232
  initial: LinkValue;
220
233
  onSave: (v: LinkValue) => void;
221
234
  onDetach?: () => void;
@@ -228,7 +241,15 @@ export declare function LinkPopoverBody({ initial, onSave, onDetach, onCancel, h
228
241
  types?: LinkType[];
229
242
  /** something the host draws beside the form changed (a button's label), so Apply has something to save */
230
243
  dirty?: boolean;
231
- }): import("react/jsx-runtime").JSX.Element;
244
+ /** look "v16": no "Search engines" choice here (a field whose link stores no rel) */
245
+ hideRel?: boolean;
246
+ /** look "v16": the pages to suggest, instead of the host's link targets service */
247
+ pages?: LinkPopoverPage[];
248
+ /** look "v16": this page's sections to suggest, instead of the SectionAnchorsProvider's */
249
+ sections?: LinkPopoverSection[];
250
+ /** look "v16": the popover around the panel has no padding (the kit's own popovers pad 12, which the panel pulls out of) */
251
+ flush?: boolean;
252
+ }
232
253
  export declare function LinkQuickEdit({ value, onCommit, onDone, ariaLabel, size, bare, types, }: {
233
254
  value: LinkValue;
234
255
  /** null = cleared */
@@ -1,15 +1,16 @@
1
1
  import { isObj } from "../lib/path.js";
2
2
  import { cn } from "../lib/cn.js";
3
- import { useKitEnv, useKitServices } from "../context.js";
3
+ import { useKitEnv, useKitLook, useKitServices } from "../context.js";
4
4
  import { Button, IconButton } from "../ui/button.js";
5
5
  import { Switch } from "../ui/controls.js";
6
6
  import { Menu, MenuContent, MenuItem, MenuTrigger, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Tooltip } from "../ui/overlay.js";
7
+ import { InspectorSwitch } from "../ui/inspector.js";
7
8
  import { Input } from "../ui/input.js";
8
9
  import { Select } from "../ui/select.js";
9
10
  import { Autocomplete } from "../ui/autocomplete.js";
10
11
  import * as React from "react";
11
- import { jsx, jsxs } from "react/jsx-runtime";
12
- import { IconAdjustmentsHorizontal, IconArrowUpRight, IconAt, IconCheck, IconChevronDown, IconExternalLink, IconFile, IconFileDatabase, IconFolderOpen, IconHash, IconLink, IconMail, IconPaperclip, IconPhone, IconWorld, IconX } from "@tabler/icons-react";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import { IconAdjustmentsHorizontal, IconArrowUpRight, IconAt, IconCheck, IconChevronDown, IconExternalLink, IconFile, IconFileDatabase, IconFolderOpen, IconHash, IconLink, IconMail, IconPaperclip, IconPhone, IconSearch, IconWorld, IconX } from "@tabler/icons-react";
13
14
  //#region src/controls/link.tsx
14
15
  /**
15
16
  * LINK — the ONE link element of the product (V2 HEAD kit/controls/link.tsx, DESIGN §8.7, CPO D43 · D48 · D57).
@@ -859,7 +860,32 @@ function LinkForm({ value, onChange, onEnter, hideOptions, hideNewTab, types, au
859
860
  ]
860
861
  });
861
862
  }
862
- function LinkPopoverBody({ initial, onSave, onDetach, onCancel, hideOptions, hideNewTab, types, dirty = false }) {
863
+ function LinkPopoverBody({ initial, onSave, onDetach, onCancel, hideOptions, hideNewTab, types, dirty = false, hideRel, pages, sections, flush }) {
864
+ if (useKitLook() === "v16") return /* @__PURE__ */ jsx(LinkPopoverV16, {
865
+ initial,
866
+ onSave,
867
+ onDetach,
868
+ onCancel,
869
+ hideOptions,
870
+ hideNewTab,
871
+ hideRel,
872
+ types,
873
+ pages,
874
+ sections,
875
+ flush
876
+ });
877
+ return /* @__PURE__ */ jsx(LinkPopoverV2, {
878
+ initial,
879
+ onSave,
880
+ onDetach,
881
+ onCancel,
882
+ hideOptions,
883
+ hideNewTab,
884
+ types,
885
+ dirty
886
+ });
887
+ }
888
+ function LinkPopoverV2({ initial, onSave, onDetach, onCancel, hideOptions, hideNewTab, types, dirty = false }) {
863
889
  const start = normLink(initial);
864
890
  const [v, setV] = React.useState(start);
865
891
  const { targets } = useLinkTargets();
@@ -937,6 +963,432 @@ function LinkPopoverBody({ initial, onSave, onDetach, onCancel, hideOptions, hid
937
963
  ]
938
964
  });
939
965
  }
966
+ var V16_ICON = {
967
+ page: IconFile,
968
+ section: IconHash,
969
+ url: IconWorld,
970
+ email: IconMail,
971
+ phone: IconPhone,
972
+ file: IconPaperclip
973
+ };
974
+ var V16_EMAIL = /^[^\s@:/]+@[^\s@]+\.[^\s@]+$/;
975
+ var V16_PHONE = /^\+?[\d\s().-]{6,}$/;
976
+ var V16_RELS = [
977
+ {
978
+ value: "follow",
979
+ label: "Do-follow",
980
+ description: "Search engines follow the link"
981
+ },
982
+ {
983
+ value: "nofollow",
984
+ label: "No-follow",
985
+ description: "Ask search engines not to follow it"
986
+ },
987
+ {
988
+ value: "sponsored",
989
+ label: "Sponsored",
990
+ description: "Paid or affiliate link"
991
+ },
992
+ {
993
+ value: "ugc",
994
+ label: "UGC",
995
+ description: "User-generated content"
996
+ }
997
+ ];
998
+ var v16Kind = (v) => v.type === "entry" || !v.type ? "page" : v.type;
999
+ var v16Path = (path) => path === "/" ? "/home" : path;
1000
+ var v16Mail = (v) => (v.email ?? v.href).replace(/^mailto:/i, "").replace(/\?.*$/, "");
1001
+ var v16Phone = (v) => (v.phone ?? v.href).replace(/^tel:/i, "");
1002
+ /** What the field says for a link that is already set. */
1003
+ function v16Query(v, t) {
1004
+ const k = v16Kind(v);
1005
+ if (k === "email") return v16Mail(v);
1006
+ if (k === "phone") return v16Phone(v);
1007
+ if (k === "url") return v.href;
1008
+ return t?.title ?? v.title ?? v.href;
1009
+ }
1010
+ /** The destination card's two lines. */
1011
+ function v16Dest(v, t) {
1012
+ const k = v16Kind(v);
1013
+ if (k === "email") return {
1014
+ title: v16Mail(v),
1015
+ line: "Opens the visitor’s email app"
1016
+ };
1017
+ if (k === "phone") return {
1018
+ title: v16Phone(v),
1019
+ line: "Calls from phones · tel: link"
1020
+ };
1021
+ if (k === "url") return {
1022
+ title: v.href.replace(/^https?:\/\//, "").replace(/\/$/, ""),
1023
+ line: "External site"
1024
+ };
1025
+ if (k === "section") return {
1026
+ title: t?.title ?? v.title ?? v.href,
1027
+ line: `Section on this page · ${v.href.startsWith("#") ? v.href : `#${v.href}`}`
1028
+ };
1029
+ if (k === "file") return {
1030
+ title: t?.title ?? v.title ?? fileName(v.href),
1031
+ line: "File on this site"
1032
+ };
1033
+ return {
1034
+ title: t?.title ?? v.title ?? v.href,
1035
+ line: `Page on this site · ${v16Path(v.href)}`
1036
+ };
1037
+ }
1038
+ var V16_FIELD_RING = "shadow-[inset_0_0_0_1px_var(--kit-insp-accent),0_0_0_3px_color-mix(in_srgb,var(--kit-insp-accent)_15%,transparent)]";
1039
+ function LinkPopoverV16({ initial, onSave, onDetach, onCancel, hideOptions, hideNewTab, hideRel, types, pages, sections, flush }) {
1040
+ const services = useKitServices();
1041
+ const host = useLinkTargets();
1042
+ const anchors = useSectionTargets();
1043
+ const targets = React.useMemo(() => {
1044
+ const p = pages ? pages.map((x) => ({
1045
+ id: `path:${x.path}`,
1046
+ title: x.title,
1047
+ href: x.path,
1048
+ kind: "page",
1049
+ group: "Pages"
1050
+ })) : host.targets.filter((t) => t.kind !== "section");
1051
+ const s = sections ? sections.map((x) => ({
1052
+ id: `section:${x.href}`,
1053
+ title: x.name,
1054
+ href: x.href,
1055
+ kind: "section",
1056
+ group: "On this page"
1057
+ })) : anchors;
1058
+ const typeOf = (t) => t.kind === "entry" ? "entry" : t.kind === "file" ? "file" : t.kind === "section" ? "section" : "page";
1059
+ return [...p, ...s].filter((t) => !types || types.includes(typeOf(t)));
1060
+ }, [
1061
+ pages,
1062
+ sections,
1063
+ host.targets,
1064
+ anchors,
1065
+ types
1066
+ ]);
1067
+ const [start] = React.useState(() => normLink(initial));
1068
+ const existing = hasLink(start);
1069
+ const [v, setV] = React.useState(start);
1070
+ const [picked, setPicked] = React.useState(existing);
1071
+ const [q, setQ] = React.useState(() => existing ? v16Query(start, findTarget(targets, start)) : "");
1072
+ const [hi, setHi] = React.useState(0);
1073
+ /** why Apply did nothing, when the host has no toaster to say it */
1074
+ const [problem, setProblem] = React.useState(null);
1075
+ const listId = React.useId();
1076
+ const allow = (k) => !types || types.includes(k);
1077
+ const list = React.useMemo(() => {
1078
+ if (picked) return [];
1079
+ const needle = q.trim().toLowerCase().replace(/^#/, "");
1080
+ const take = needle ? 6 : 4;
1081
+ const groups = [];
1082
+ for (const t of targets) {
1083
+ if (needle && !`${t.title} ${t.href}`.toLowerCase().includes(needle)) continue;
1084
+ let g = groups.find((x) => x.name === t.group);
1085
+ if (!g) groups.push(g = {
1086
+ name: t.group,
1087
+ rows: []
1088
+ });
1089
+ if (g.rows.length < take) g.rows.push(t);
1090
+ }
1091
+ return groups.flatMap((g) => g.rows);
1092
+ }, [
1093
+ targets,
1094
+ q,
1095
+ picked
1096
+ ]);
1097
+ const typeQ = (text) => {
1098
+ setQ(text);
1099
+ setProblem(null);
1100
+ const t = text.trim();
1101
+ const mail = t.replace(/^mailto:/i, "");
1102
+ const detected = V16_EMAIL.test(mail) && allow("email") ? ["email", mail] : (/^tel:/i.test(t) || V16_PHONE.test(t) && t.replace(/\D/g, "").length >= 7) && allow("phone") ? ["phone", t.replace(/^tel:/i, "")] : (/^(https?:\/\/|www\.)/i.test(t) || /^[^\s/]+\.[a-z]{2,}(\/\S*)?$/i.test(t)) && allow("url") ? ["url", /^https?:\/\//i.test(t) ? t : `https://${t}`] : /^\/\S*$/.test(t) && allow("page") ? ["page", t] : null;
1103
+ if (detected) {
1104
+ setV((x) => withText(x, detected[1], detected[0]));
1105
+ setPicked(true);
1106
+ return;
1107
+ }
1108
+ setPicked(false);
1109
+ setHi(0);
1110
+ };
1111
+ const pick = (t) => {
1112
+ t.onChoose?.();
1113
+ setV((x) => {
1114
+ const n = withTarget(x, t);
1115
+ if (pages && t.kind === "page") n.pageId = void 0;
1116
+ return n;
1117
+ });
1118
+ setQ(t.title);
1119
+ setPicked(true);
1120
+ setProblem(null);
1121
+ };
1122
+ const clear = () => {
1123
+ setQ("");
1124
+ setPicked(false);
1125
+ setHi(0);
1126
+ setProblem(null);
1127
+ setV((x) => ({
1128
+ ...x,
1129
+ ...TARGET_KEYS,
1130
+ href: "",
1131
+ email: void 0,
1132
+ phone: void 0
1133
+ }));
1134
+ };
1135
+ const apply = () => {
1136
+ if (!picked) return;
1137
+ const out = finalizeLink(v);
1138
+ if (!out || !hasLink(out) || linkProblem(out)) {
1139
+ const k = v16Kind(v);
1140
+ const say = k === "email" ? "Enter an email address" : k === "phone" ? "Enter a phone number" : "Enter a URL";
1141
+ if (services.toast) services.toast(say);
1142
+ else setProblem(say);
1143
+ return;
1144
+ }
1145
+ onSave(out);
1146
+ };
1147
+ const keys = (e) => {
1148
+ if (e.key === "ArrowDown" && list.length) {
1149
+ e.preventDefault();
1150
+ setHi((h) => Math.min(h + 1, list.length - 1));
1151
+ } else if (e.key === "ArrowUp" && list.length) {
1152
+ e.preventDefault();
1153
+ setHi((h) => Math.max(h - 1, 0));
1154
+ } else if (e.key === "Enter") {
1155
+ e.preventDefault();
1156
+ e.stopPropagation();
1157
+ if (!picked && list.length) pick(list[Math.min(hi, list.length - 1)]);
1158
+ else apply();
1159
+ } else if (e.key === "Escape" && onCancel) {
1160
+ e.preventDefault();
1161
+ e.stopPropagation();
1162
+ onCancel();
1163
+ }
1164
+ };
1165
+ const kind = v16Kind(v);
1166
+ const target = picked ? findTarget(targets, v) : void 0;
1167
+ const dest = picked ? v16Dest(v, target) : null;
1168
+ const FieldIcon = picked ? V16_ICON[kind] : IconSearch;
1169
+ const DestIcon = V16_ICON[kind];
1170
+ const showTab = !hideOptions && !hideNewTab && (kind === "page" || kind === "url" || kind === "file");
1171
+ const showRel = !hideOptions && !hideRel && kind === "url";
1172
+ const rel = V16_RELS.find((r) => r.value === (v.rel ?? "follow")) ?? V16_RELS[0];
1173
+ return /* @__PURE__ */ jsxs("div", {
1174
+ role: "group",
1175
+ "aria-label": "Link",
1176
+ "data-kit-link-v16": "",
1177
+ className: cn("flex flex-col text-[13px] text-kit-insp-tip-title", !flush && "-mx-3 -mb-3 first:-mt-3"),
1178
+ children: [
1179
+ /* @__PURE__ */ jsx("div", {
1180
+ className: "p-2",
1181
+ children: /* @__PURE__ */ jsxs("label", {
1182
+ className: cn("flex h-9 items-center gap-2 rounded-[6px] bg-kit-insp-tip-bg pl-2.5 pr-1.5 text-kit-group-sub", V16_FIELD_RING),
1183
+ children: [
1184
+ /* @__PURE__ */ jsx(FieldIcon, {
1185
+ className: "size-4 shrink-0",
1186
+ stroke: 1.75,
1187
+ "aria-hidden": true
1188
+ }),
1189
+ /* @__PURE__ */ jsx("input", {
1190
+ autoFocus: true,
1191
+ value: q,
1192
+ placeholder: "Search pages or paste a link",
1193
+ "aria-label": "Link to",
1194
+ role: "combobox",
1195
+ "aria-expanded": !picked,
1196
+ "aria-controls": listId,
1197
+ "aria-activedescendant": !picked && list.length ? `${listId}-${Math.min(hi, list.length - 1)}` : void 0,
1198
+ "aria-autocomplete": "list",
1199
+ spellCheck: false,
1200
+ onChange: (e) => typeQ(e.target.value),
1201
+ onKeyDown: keys,
1202
+ className: "min-w-0 flex-1 border-0 bg-transparent text-[13px] text-kit-insp-tip-title outline-none placeholder:text-kit-insp-faint focus-visible:shadow-none"
1203
+ }),
1204
+ q ? /* @__PURE__ */ jsx("button", {
1205
+ type: "button",
1206
+ "aria-label": "Clear",
1207
+ onClick: clear,
1208
+ className: "grid size-6 shrink-0 place-items-center rounded-[4px] text-kit-insp-faint outline-none hover:bg-kit-insp-card hover:text-kit-insp-label focus-visible:shadow-[0_0_0_2px_var(--kit-focus-ring)]",
1209
+ children: /* @__PURE__ */ jsx(IconX, {
1210
+ className: "size-3.5",
1211
+ stroke: 1.75,
1212
+ "aria-hidden": true
1213
+ })
1214
+ }) : null
1215
+ ]
1216
+ })
1217
+ }),
1218
+ picked ? null : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
1219
+ id: listId,
1220
+ role: "listbox",
1221
+ "aria-label": "Pages and sections",
1222
+ className: "max-h-[280px] overflow-auto px-1 pb-1",
1223
+ children: [list.length === 0 ? /* @__PURE__ */ jsx("div", {
1224
+ className: "px-2 pb-2.5 pt-2 text-[12px] leading-4 text-kit-group-sub",
1225
+ children: host.loading && !pages ? "Loading pages…" : "No pages or sections match. Paste a full web address, email or phone number."
1226
+ }) : null, list.map((t, i) => {
1227
+ const RowIcon = V16_ICON[t.kind === "entry" ? "page" : t.kind];
1228
+ const on = i === Math.min(hi, list.length - 1);
1229
+ return /* @__PURE__ */ jsxs("div", {
1230
+ role: "presentation",
1231
+ children: [i === 0 || list[i - 1].group !== t.group ? /* @__PURE__ */ jsx("div", {
1232
+ className: "px-2 pb-1 pt-1.5 text-[12px] font-medium leading-4 text-kit-group-sub",
1233
+ children: t.group
1234
+ }) : null, /* @__PURE__ */ jsxs("button", {
1235
+ type: "button",
1236
+ role: "option",
1237
+ id: `${listId}-${i}`,
1238
+ "aria-selected": on,
1239
+ tabIndex: -1,
1240
+ onMouseDown: (e) => e.preventDefault(),
1241
+ onMouseEnter: () => setHi(i),
1242
+ onClick: () => pick(t),
1243
+ className: cn("flex h-8 w-full items-center gap-2.5 rounded-[6px] px-2 text-left outline-none", on && "bg-kit-insp-card"),
1244
+ children: [
1245
+ /* @__PURE__ */ jsx(RowIcon, {
1246
+ className: "size-4 shrink-0 text-kit-insp-label",
1247
+ stroke: 1.75,
1248
+ "aria-hidden": true
1249
+ }),
1250
+ /* @__PURE__ */ jsx("span", {
1251
+ className: "min-w-0 flex-1 truncate text-[13px] text-kit-insp-tip-title",
1252
+ children: t.title
1253
+ }),
1254
+ /* @__PURE__ */ jsx("small", {
1255
+ className: "whitespace-nowrap text-[12px] text-kit-insp-faint",
1256
+ children: t.kind === "page" || t.kind === "entry" ? v16Path(t.href) : t.kind === "file" ? t.meta ?? "" : t.href
1257
+ })
1258
+ ]
1259
+ })]
1260
+ }, t.id);
1261
+ })]
1262
+ }), /* @__PURE__ */ jsxs("div", {
1263
+ className: "flex items-center gap-1.5 border-t border-kit-insp-divider px-3 py-2 text-[12px] text-kit-group-sub",
1264
+ children: [/* @__PURE__ */ jsx(IconLink, {
1265
+ className: "size-3.5 shrink-0 text-kit-insp-faint",
1266
+ stroke: 1.75,
1267
+ "aria-hidden": true
1268
+ }), "Paste a web address, email or phone number"]
1269
+ })] }),
1270
+ dest ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
1271
+ className: "mx-2 mb-1 flex items-center gap-2.5 rounded-[8px] bg-kit-insp-card p-2",
1272
+ children: [/* @__PURE__ */ jsx("span", {
1273
+ className: "grid size-8 shrink-0 place-items-center rounded-[8px] bg-kit-insp-tip-bg shadow-[inset_0_0_0_1px_var(--kit-insp-line)]",
1274
+ children: /* @__PURE__ */ jsx(DestIcon, {
1275
+ className: "size-4 text-kit-insp-label",
1276
+ stroke: 1.75,
1277
+ "aria-hidden": true
1278
+ })
1279
+ }), /* @__PURE__ */ jsxs("span", {
1280
+ className: "flex min-w-0 flex-1 flex-col gap-px",
1281
+ children: [/* @__PURE__ */ jsx("b", {
1282
+ className: "truncate text-[13px] font-medium leading-[18px] text-kit-insp-tip-title",
1283
+ children: dest.title
1284
+ }), /* @__PURE__ */ jsx("small", {
1285
+ className: "truncate text-[12px] leading-4 text-kit-group-sub",
1286
+ children: dest.line
1287
+ })]
1288
+ })]
1289
+ }), showTab || showRel || kind === "email" ? /* @__PURE__ */ jsxs("div", {
1290
+ className: "flex flex-col gap-1 px-2 pb-2 pt-1",
1291
+ children: [
1292
+ showTab ? /* @__PURE__ */ jsxs("div", {
1293
+ className: "flex h-8 items-center justify-between gap-3 pl-2",
1294
+ children: [/* @__PURE__ */ jsx("span", {
1295
+ className: "text-[13px] font-medium text-kit-insp-tip-body",
1296
+ children: "Open in a new tab"
1297
+ }), /* @__PURE__ */ jsx(InspectorSwitch, {
1298
+ on: !!v.newTab,
1299
+ label: "Open in a new tab",
1300
+ onChange: (on) => setV((x) => ({
1301
+ ...x,
1302
+ newTab: on
1303
+ }))
1304
+ })]
1305
+ }) : null,
1306
+ showRel ? /* @__PURE__ */ jsxs("div", {
1307
+ className: "flex h-8 items-center justify-between gap-3 pl-2",
1308
+ children: [/* @__PURE__ */ jsx("span", {
1309
+ className: "text-[13px] font-medium text-kit-insp-tip-body",
1310
+ children: "Search engines"
1311
+ }), /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsxs(MenuTrigger, {
1312
+ "aria-label": `Search engines: ${rel.label}`,
1313
+ className: "inline-flex h-7 items-center gap-1.5 rounded-[6px] bg-kit-insp-card pl-2.5 pr-2 text-[13px] text-kit-insp-tip-title outline-none hover:bg-kit-insp-divider focus-visible:shadow-[0_0_0_2px_var(--kit-focus-ring)] data-[popup-open]:bg-kit-insp-divider",
1314
+ children: [rel.label, /* @__PURE__ */ jsx(IconChevronDown, {
1315
+ className: "size-3.5",
1316
+ stroke: 1.75,
1317
+ "aria-hidden": true
1318
+ })]
1319
+ }), /* @__PURE__ */ jsx(MenuContent, {
1320
+ align: "end",
1321
+ className: "w-[228px] min-w-[228px]",
1322
+ children: V16_RELS.map((r) => /* @__PURE__ */ jsx(MenuItem, {
1323
+ className: "h-auto items-start py-1.5",
1324
+ onClick: () => setV((x) => ({
1325
+ ...x,
1326
+ rel: r.value
1327
+ })),
1328
+ children: /* @__PURE__ */ jsxs("span", {
1329
+ className: "flex w-full items-start gap-2",
1330
+ children: [/* @__PURE__ */ jsxs("span", {
1331
+ className: "flex min-w-0 flex-1 flex-col",
1332
+ children: [/* @__PURE__ */ jsx("span", {
1333
+ className: "truncate",
1334
+ children: r.label
1335
+ }), /* @__PURE__ */ jsx("span", {
1336
+ className: "truncate text-[12px] leading-4 text-kit-group-sub",
1337
+ children: r.description
1338
+ })]
1339
+ }), r.value === rel.value ? /* @__PURE__ */ jsx(IconCheck, {
1340
+ className: "mt-0.5 size-3.5 shrink-0",
1341
+ stroke: 2,
1342
+ "aria-hidden": true
1343
+ }) : null]
1344
+ })
1345
+ }, r.value))
1346
+ })] })]
1347
+ }) : null,
1348
+ kind === "email" ? /* @__PURE__ */ jsx("input", {
1349
+ value: v.subject ?? "",
1350
+ placeholder: "Subject (optional)",
1351
+ "aria-label": "Subject",
1352
+ onChange: (e) => setV((x) => ({
1353
+ ...x,
1354
+ subject: e.target.value || void 0
1355
+ })),
1356
+ onKeyDown: keys,
1357
+ className: "h-8 rounded-[6px] border-0 bg-kit-insp-card px-2.5 text-[13px] text-kit-insp-tip-title outline-none placeholder:text-kit-insp-faint focus:bg-kit-insp-tip-bg focus:shadow-[inset_0_0_0_1px_var(--kit-insp-accent),0_0_0_3px_color-mix(in_srgb,var(--kit-insp-accent)_15%,transparent)]"
1358
+ }) : null
1359
+ ]
1360
+ }) : null] }) : null,
1361
+ problem ? /* @__PURE__ */ jsx("p", {
1362
+ role: "alert",
1363
+ className: "px-3 pb-2 text-[12px] leading-4 text-kit-insp-count-over",
1364
+ children: problem
1365
+ }) : null,
1366
+ /* @__PURE__ */ jsxs("div", {
1367
+ className: "flex items-center gap-2 border-t border-kit-insp-divider p-2",
1368
+ children: [
1369
+ onDetach ? /* @__PURE__ */ jsx("button", {
1370
+ type: "button",
1371
+ onClick: onDetach,
1372
+ className: "h-[30px] rounded-[6px] px-2 text-[13px] font-medium text-kit-insp-btool-danger outline-none hover:bg-kit-insp-delete-bg focus-visible:shadow-[0_0_0_2px_var(--kit-focus-ring)]",
1373
+ children: "Remove link"
1374
+ }) : null,
1375
+ /* @__PURE__ */ jsx("span", { className: "flex-1" }),
1376
+ picked ? /* @__PURE__ */ jsx("span", {
1377
+ className: "text-[12px] text-kit-insp-faint",
1378
+ children: "↵ to apply"
1379
+ }) : null,
1380
+ /* @__PURE__ */ jsx("button", {
1381
+ type: "button",
1382
+ disabled: !picked,
1383
+ onClick: apply,
1384
+ className: "h-[30px] rounded-[6px] bg-kit-insp-tip-title px-3 text-[13px] font-medium text-kit-insp-tip-bg outline-none hover:bg-kit-insp-ink focus-visible:shadow-[0_0_0_2px_var(--kit-focus-ring)] disabled:bg-kit-insp-line disabled:text-kit-insp-faint",
1385
+ children: existing ? "Save" : "Apply"
1386
+ })
1387
+ ]
1388
+ })
1389
+ ]
1390
+ });
1391
+ }
940
1392
  function LinkQuickEdit({ value, onCommit, onDone, ariaLabel, size, bare, types }) {
941
1393
  const [draft, setDraft] = React.useState(value);
942
1394
  const [problem, setProblem] = React.useState();