@astra-kit/ui 0.0.0-stage → 0.0.0
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/CHANGELOG.md +15 -0
- package/LICENSE.md +21 -0
- package/README.md +384 -2
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/assets/fonts/geist-LICENSE.txt +93 -0
- package/assets/fonts/geist-latin-variable.woff2 +0 -0
- package/assets/fonts/ibm-plex-mono-latin-400.woff2 +0 -0
- package/assets/fonts/ibm-plex-mono-latin-500.woff2 +0 -0
- package/assets/fonts/ibmplexmono-LICENSE.txt +93 -0
- package/assets/fonts/inter-LICENSE.txt +93 -0
- package/assets/fonts/inter-latin-variable.woff2 +0 -0
- package/dist/adapters/unpic-image.d.ts +3 -0
- package/dist/adapters/unpic-image.js +98 -0
- package/dist/components/account-menu.d.ts +67 -0
- package/dist/components/account-menu.js +440 -0
- package/dist/components/action-button.d.ts +25 -0
- package/dist/components/action-button.js +264 -0
- package/dist/components/alert.d.ts +31 -0
- package/dist/components/alert.js +503 -0
- package/dist/components/animated-collapse.d.ts +19 -0
- package/dist/components/animated-collapse.js +170 -0
- package/dist/components/animated-count.d.ts +13 -0
- package/dist/components/animated-count.js +105 -0
- package/dist/components/animated-list-item.d.ts +25 -0
- package/dist/components/animated-list-item.js +134 -0
- package/dist/components/animated-theme-toggler.d.ts +12 -0
- package/dist/components/animated-theme-toggler.js +200 -0
- package/dist/components/avatar.d.ts +65 -0
- package/dist/components/avatar.js +463 -0
- package/dist/components/badge.d.ts +21 -0
- package/dist/components/badge.js +297 -0
- package/dist/components/button-interaction.d.ts +23 -0
- package/dist/components/button-interaction.js +22 -0
- package/dist/components/button-label.d.ts +8 -0
- package/dist/components/button-label.js +203 -0
- package/dist/components/button.d.ts +23 -0
- package/dist/components/button.js +145 -0
- package/dist/components/calendar.d.ts +47 -0
- package/dist/components/calendar.js +155 -0
- package/dist/components/card.d.ts +38 -0
- package/dist/components/card.js +904 -0
- package/dist/components/carousel.d.ts +71 -0
- package/dist/components/carousel.js +585 -0
- package/dist/components/checkbox.d.ts +15 -0
- package/dist/components/checkbox.js +324 -0
- package/dist/components/control-button.d.ts +16 -0
- package/dist/components/control-button.js +215 -0
- package/dist/components/data-table.d.ts +118 -0
- package/dist/components/data-table.js +895 -0
- package/dist/components/dialog-surface.d.ts +49 -0
- package/dist/components/dialog-surface.js +220 -0
- package/dist/components/dialog.d.ts +92 -0
- package/dist/components/dialog.js +320 -0
- package/dist/components/dropdown-menu.d.ts +57 -0
- package/dist/components/dropdown-menu.js +107 -0
- package/dist/components/field.d.ts +53 -0
- package/dist/components/field.js +710 -0
- package/dist/components/file-upload.d.ts +88 -0
- package/dist/components/file-upload.js +776 -0
- package/dist/components/filter-presets-bar.d.ts +73 -0
- package/dist/components/filter-presets-bar.js +510 -0
- package/dist/components/filter-query-bar.d.ts +21 -0
- package/dist/components/filter-query-bar.js +881 -0
- package/dist/components/filter-query-grammar.d.ts +188 -0
- package/dist/components/filter-query-grammar.js +875 -0
- package/dist/components/form.d.ts +29 -0
- package/dist/components/form.js +330 -0
- package/dist/components/highlighter.d.ts +15 -0
- package/dist/components/highlighter.js +152 -0
- package/dist/components/hover-card.d.ts +50 -0
- package/dist/components/hover-card.js +80 -0
- package/dist/components/input-group.d.ts +16 -0
- package/dist/components/input-group.js +277 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +120 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +43 -0
- package/dist/components/link.d.ts +9 -0
- package/dist/components/link.js +43 -0
- package/dist/components/morph-text.d.ts +14 -0
- package/dist/components/morph-text.js +210 -0
- package/dist/components/pagination.d.ts +59 -0
- package/dist/components/pagination.js +190 -0
- package/dist/components/popover.d.ts +17 -0
- package/dist/components/popover.js +40 -0
- package/dist/components/presence-swap.d.ts +22 -0
- package/dist/components/presence-swap.js +209 -0
- package/dist/components/primitives/alert-dialog.d.ts +68 -0
- package/dist/components/primitives/alert-dialog.js +629 -0
- package/dist/components/primitives/avatar.d.ts +46 -0
- package/dist/components/primitives/avatar.js +265 -0
- package/dist/components/primitives/calendar.d.ts +37 -0
- package/dist/components/primitives/calendar.js +1250 -0
- package/dist/components/primitives/carousel.d.ts +106 -0
- package/dist/components/primitives/carousel.js +928 -0
- package/dist/components/primitives/dialog.d.ts +62 -0
- package/dist/components/primitives/dialog.js +490 -0
- package/dist/components/primitives/dropdown-menu-items.d.ts +59 -0
- package/dist/components/primitives/dropdown-menu-items.js +265 -0
- package/dist/components/primitives/dropdown-menu.d.ts +64 -0
- package/dist/components/primitives/dropdown-menu.js +560 -0
- package/dist/components/primitives/hover-card.d.ts +50 -0
- package/dist/components/primitives/hover-card.js +507 -0
- package/dist/components/primitives/pagination.d.ts +65 -0
- package/dist/components/primitives/pagination.js +373 -0
- package/dist/components/primitives/popover.d.ts +22 -0
- package/dist/components/primitives/popover.js +213 -0
- package/dist/components/primitives/select.d.ts +37 -0
- package/dist/components/primitives/select.js +428 -0
- package/dist/components/primitives/tooltip.d.ts +30 -0
- package/dist/components/primitives/tooltip.js +277 -0
- package/dist/components/progress-ring.d.ts +20 -0
- package/dist/components/progress-ring.js +53 -0
- package/dist/components/radio-group.d.ts +34 -0
- package/dist/components/radio-group.js +392 -0
- package/dist/components/reaction-button.d.ts +30 -0
- package/dist/components/reaction-button.js +189 -0
- package/dist/components/rich-link-editor.d.ts +25 -0
- package/dist/components/rich-link-editor.js +320 -0
- package/dist/components/rich-markdown-content.d.ts +10 -0
- package/dist/components/rich-markdown-content.js +56 -0
- package/dist/components/rich-text-content.d.ts +19 -0
- package/dist/components/rich-text-content.js +26 -0
- package/dist/components/select.d.ts +55 -0
- package/dist/components/select.js +188 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/sheet.d.ts +19 -0
- package/dist/components/sheet.js +420 -0
- package/dist/components/sidebar-panel-context.d.ts +17 -0
- package/dist/components/sidebar-panel-context.js +14 -0
- package/dist/components/sidebar.d.ts +195 -0
- package/dist/components/sidebar.js +2041 -0
- package/dist/components/skeleton.d.ts +23 -0
- package/dist/components/skeleton.js +334 -0
- package/dist/components/split-button.d.ts +36 -0
- package/dist/components/split-button.js +306 -0
- package/dist/components/svgs/whatsappIcon.d.ts +3 -0
- package/dist/components/svgs/whatsappIcon.js +14 -0
- package/dist/components/switch.d.ts +13 -0
- package/dist/components/switch.js +444 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +298 -0
- package/dist/components/tabs.d.ts +36 -0
- package/dist/components/tabs.js +636 -0
- package/dist/components/textarea.d.ts +16 -0
- package/dist/components/textarea.js +111 -0
- package/dist/components/themed-toaster.d.ts +7 -0
- package/dist/components/themed-toaster.js +86 -0
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.js +62 -0
- package/dist/components/tooltip.d.ts +43 -0
- package/dist/components/tooltip.js +65 -0
- package/dist/components/typing-animation.d.ts +34 -0
- package/dist/components/typing-animation.js +389 -0
- package/dist/constants/action-button.d.ts +20 -0
- package/dist/constants/action-button.js +17 -0
- package/dist/constants/alert.d.ts +16 -0
- package/dist/constants/alert.js +13 -0
- package/dist/constants/avatar.d.ts +38 -0
- package/dist/constants/avatar.js +32 -0
- package/dist/constants/badge.d.ts +6 -0
- package/dist/constants/badge.js +6 -0
- package/dist/constants/button.d.ts +16 -0
- package/dist/constants/button.js +16 -0
- package/dist/constants/calendar.d.ts +36 -0
- package/dist/constants/calendar.js +34 -0
- package/dist/constants/card.d.ts +23 -0
- package/dist/constants/card.js +20 -0
- package/dist/constants/carousel.d.ts +55 -0
- package/dist/constants/carousel.js +74 -0
- package/dist/constants/checkbox.d.ts +17 -0
- package/dist/constants/checkbox.js +17 -0
- package/dist/constants/dialog.d.ts +11 -0
- package/dist/constants/dialog.js +10 -0
- package/dist/constants/dropdown-menu.d.ts +10 -0
- package/dist/constants/dropdown-menu.js +37 -0
- package/dist/constants/field.d.ts +24 -0
- package/dist/constants/field.js +24 -0
- package/dist/constants/hover-card.d.ts +37 -0
- package/dist/constants/hover-card.js +85 -0
- package/dist/constants/morph-text.d.ts +13 -0
- package/dist/constants/morph-text.js +13 -0
- package/dist/constants/motion.d.ts +12 -0
- package/dist/constants/motion.js +12 -0
- package/dist/constants/pagination.d.ts +20 -0
- package/dist/constants/pagination.js +20 -0
- package/dist/constants/popover.d.ts +7 -0
- package/dist/constants/popover.js +33 -0
- package/dist/constants/radio-group.d.ts +10 -0
- package/dist/constants/radio-group.js +10 -0
- package/dist/constants/select.d.ts +7 -0
- package/dist/constants/select.js +34 -0
- package/dist/constants/sidebar.d.ts +9 -0
- package/dist/constants/sidebar.js +17 -0
- package/dist/constants/skeleton.d.ts +17 -0
- package/dist/constants/skeleton.js +17 -0
- package/dist/constants/split-button.d.ts +7 -0
- package/dist/constants/split-button.js +5 -0
- package/dist/constants/switch.d.ts +33 -0
- package/dist/constants/switch.js +41 -0
- package/dist/constants/tabs.d.ts +17 -0
- package/dist/constants/tabs.js +17 -0
- package/dist/constants/toast.d.ts +3 -0
- package/dist/constants/toast.js +3 -0
- package/dist/constants/tooltip.d.ts +13 -0
- package/dist/constants/tooltip.js +52 -0
- package/dist/hooks/use-horizontal-swipe.d.ts +23 -0
- package/dist/hooks/use-horizontal-swipe.js +80 -0
- package/dist/hooks/use-is-hydrated.d.ts +6 -0
- package/dist/hooks/use-is-hydrated.js +20 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +19 -0
- package/dist/hooks/use-prefers-reduced-motion.d.ts +2 -0
- package/dist/hooks/use-prefers-reduced-motion.js +27 -0
- package/dist/hooks/use-rich-link-editor.d.ts +55 -0
- package/dist/hooks/use-rich-link-editor.js +515 -0
- package/dist/hooks/use-sidebar-persistence.d.ts +6 -0
- package/dist/hooks/use-sidebar-persistence.js +52 -0
- package/dist/hooks/use-today.d.ts +7 -0
- package/dist/hooks/use-today.js +50 -0
- package/dist/hooks/use-viewer-time-zone.d.ts +6 -0
- package/dist/hooks/use-viewer-time-zone.js +20 -0
- package/dist/hooks.d.ts +11 -0
- package/dist/hooks.js +11 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +69 -0
- package/dist/lib/browser-clipboard.d.ts +13 -0
- package/dist/lib/browser-clipboard.js +48 -0
- package/dist/lib/column-filter-value.d.ts +12 -0
- package/dist/lib/column-filter-value.js +52 -0
- package/dist/lib/file-acceptance.d.ts +43 -0
- package/dist/lib/file-acceptance.js +107 -0
- package/dist/lib/format-file-size.d.ts +16 -0
- package/dist/lib/format-file-size.js +34 -0
- package/dist/lib/fuzzy-search.d.ts +17 -0
- package/dist/lib/fuzzy-search.js +183 -0
- package/dist/lib/horizontal-swipe.d.ts +23 -0
- package/dist/lib/horizontal-swipe.js +29 -0
- package/dist/lib/image-dimensions.d.ts +2 -0
- package/dist/lib/image-dimensions.js +7 -0
- package/dist/lib/name-initials.d.ts +7 -0
- package/dist/lib/name-initials.js +11 -0
- package/dist/lib/rich-text/link-markdown-constants.d.ts +147 -0
- package/dist/lib/rich-text/link-markdown-constants.js +458 -0
- package/dist/lib/rich-text/link-markdown-types.d.ts +53 -0
- package/dist/lib/rich-text/link-markdown-types.js +1 -0
- package/dist/lib/rich-text/link-markdown.d.ts +193 -0
- package/dist/lib/rich-text/link-markdown.js +592 -0
- package/dist/lib/rich-text/rich-markdown.d.ts +41 -0
- package/dist/lib/rich-text/rich-markdown.js +105 -0
- package/dist/lib/rich-text/rich-text-editor-dom.d.ts +26 -0
- package/dist/lib/rich-text/rich-text-editor-dom.js +79 -0
- package/dist/lib/toast-layer.d.ts +24 -0
- package/dist/lib/toast-layer.js +76 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +2 -0
- package/dist/lib/year-month-filter.d.ts +16 -0
- package/dist/lib/year-month-filter.js +46 -0
- package/dist/motion/arc-floating-slot.d.ts +40 -0
- package/dist/motion/arc-floating-slot.js +177 -0
- package/dist/motion/arc-press.d.ts +6 -0
- package/dist/motion/arc-press.js +59 -0
- package/dist/motion/arc-swap.d.ts +22 -0
- package/dist/motion/arc-swap.js +49 -0
- package/dist/motion/arc-tokens.d.ts +53 -0
- package/dist/motion/arc-tokens.js +73 -0
- package/dist/motion/glide-indicator.d.ts +69 -0
- package/dist/motion/glide-indicator.js +309 -0
- package/dist/motion/glide-slot.d.ts +9 -0
- package/dist/motion/glide-slot.js +71 -0
- package/dist/motion/motion-slot.d.ts +12 -0
- package/dist/motion/motion-slot.js +376 -0
- package/dist/motion/overlay-warmth.d.ts +24 -0
- package/dist/motion/overlay-warmth.js +70 -0
- package/dist/motion/presence.d.ts +40 -0
- package/dist/motion/presence.js +101 -0
- package/dist/motion/surface-keyframes.d.ts +24 -0
- package/dist/motion/surface-keyframes.js +141 -0
- package/dist/motion/tokens.d.ts +81 -0
- package/dist/motion/tokens.js +67 -0
- package/dist/motion/use-attached-element.d.ts +7 -0
- package/dist/motion/use-attached-element.js +22 -0
- package/dist/motion/use-morph-width.d.ts +13 -0
- package/dist/motion/use-morph-width.js +59 -0
- package/dist/next.d.ts +14 -0
- package/dist/next.js +79 -0
- package/dist/providers/astra-ui-provider.d.ts +27 -0
- package/dist/providers/astra-ui-provider.js +100 -0
- package/dist/providers/native-provider.d.ts +4 -0
- package/dist/providers/native-provider.js +45 -0
- package/dist/sonner.d.ts +7 -0
- package/dist/sonner.js +8 -0
- package/dist/styles.css +2 -0
- package/dist/tanstack.d.ts +11 -0
- package/dist/tanstack.js +50 -0
- package/dist/theme.d.ts +3 -0
- package/dist/theme.js +1 -0
- package/dist/types/data-table.d.ts +27 -0
- package/dist/types/data-table.js +1 -0
- package/fonts.css +5 -0
- package/package.json +450 -4
- package/styles.css +4 -0
- package/theme.css +248 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/** `contentEditable` editor for plain text with markdown links, driven by `useRichLinkEditor`. */
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
import { RICH_LINK_POPOVER_MODE, RICH_TEXT_EDITOR_KEY, RICH_TEXT_SEGMENT_TYPE } from "../lib/rich-text/link-markdown-constants.js";
|
|
7
|
+
import { ControlButton } from "./control-button.js";
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./primitives/popover.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const BUTTON_TYPE = "button";
|
|
11
|
+
const BUTTON_VARIANT = {
|
|
12
|
+
ghost: "ghost",
|
|
13
|
+
outline: "outline"
|
|
14
|
+
};
|
|
15
|
+
const URL_INPUT_TYPE = "url";
|
|
16
|
+
const LINK_TARGET = "_blank";
|
|
17
|
+
const LINK_REL = "noreferrer";
|
|
18
|
+
/**
|
|
19
|
+
* Presentation of each part. iOS Safari zooms the page when a focused editable region renders
|
|
20
|
+
* text below 16px, so the editor and the inputs are pinned to 1rem on phones.
|
|
21
|
+
*/
|
|
22
|
+
const RICH_LINK_EDITOR_CLASS_NAMES = {
|
|
23
|
+
editor: "min-h-28 w-full cursor-text border-0 bg-transparent p-0 leading-[1.65] whitespace-pre-wrap text-foreground [font:inherit] [overflow-wrap:anywhere] focus:outline-0 empty:before:pointer-events-none empty:before:text-muted-foreground/75 empty:before:content-[attr(data-placeholder)] max-md:text-base",
|
|
24
|
+
editorInvalid: "rounded-[0.35rem] shadow-[inset_0_-2px_0_var(--destructive)] outline-0",
|
|
25
|
+
editorLink: "cursor-pointer rounded-[0.2rem] font-medium text-primary underline decoration-[0.08em] underline-offset-[0.18em] transition-colors hover:text-[color-mix(in_oklab,var(--primary)_72%,var(--foreground))] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",
|
|
26
|
+
popover: "gap-3",
|
|
27
|
+
editForm: "grid gap-3 animate-in fade-in slide-in-from-bottom-1 duration-(--duration-standard) ease-(--ease-enter)",
|
|
28
|
+
actions: "flex flex-wrap items-center gap-2",
|
|
29
|
+
label: "grid gap-[0.35rem] text-[0.85rem] font-medium text-muted-foreground",
|
|
30
|
+
input: "min-h-8 rounded-lg border border-border/80 bg-background px-[0.65rem] font-normal text-foreground outline-0 transition-[border-color,box-shadow] [font:inherit] focus-visible:border-ring focus-visible:shadow-[0_0_0_3px_color-mix(in_oklab,var(--ring)_35%,transparent)] aria-invalid:border-destructive aria-invalid:focus-visible:shadow-[0_0_0_3px_color-mix(in_oklab,var(--destructive)_25%,transparent)] max-md:text-base"
|
|
31
|
+
};
|
|
32
|
+
const RICH_LINK_EDITOR_DEFAULT_COPY = {
|
|
33
|
+
editAction: "Editar",
|
|
34
|
+
editCancel: "Cancelar",
|
|
35
|
+
editSave: "Guardar",
|
|
36
|
+
popoverTextLabel: "Texto",
|
|
37
|
+
popoverUrlLabel: "Enlace",
|
|
38
|
+
removeAction: "Quitar enlace"
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* `contentEditable` rich link editor: renders the controller's preview segments,
|
|
42
|
+
* turning each link into a popover that edits or removes it. All state lives in
|
|
43
|
+
* the `useRichLinkEditor` controller; this component is presentation only.
|
|
44
|
+
*/
|
|
45
|
+
export function RichLinkEditor(t0) {
|
|
46
|
+
const $ = _c(50);
|
|
47
|
+
const { ariaDescribedBy, ariaLabel, copy: copyOverrides, editor, isDisabled: t1, isInvalid: t2, placeholder } = t0;
|
|
48
|
+
const isDisabled = t1 === undefined ? false : t1;
|
|
49
|
+
const isInvalid = t2 === undefined ? false : t2;
|
|
50
|
+
const { activeLink, closeLinkPopover, handleBeforeInput, handleInput, handleKeyDown, handlePaste, hasContent, hasInvalidLinkUrl, isLinkEditValid, linkTextInput, linkUrlInput, openLinkPopover, popoverMode, removeLink, saveLinkEdit, segments, setEditorElement, setLinkTextInput, setLinkUrlInput, setPopoverMode } = editor;
|
|
51
|
+
let t3;
|
|
52
|
+
if ($[0] !== copyOverrides) {
|
|
53
|
+
t3 = {
|
|
54
|
+
...RICH_LINK_EDITOR_DEFAULT_COPY,
|
|
55
|
+
...copyOverrides
|
|
56
|
+
};
|
|
57
|
+
$[0] = copyOverrides;
|
|
58
|
+
$[1] = t3;
|
|
59
|
+
} else {
|
|
60
|
+
t3 = $[1];
|
|
61
|
+
}
|
|
62
|
+
const copy = t3;
|
|
63
|
+
const linkTextInputRef = useRef(null);
|
|
64
|
+
const isEditingLink = popoverMode === RICH_LINK_POPOVER_MODE.edit;
|
|
65
|
+
const t4 = isInvalid && RICH_LINK_EDITOR_CLASS_NAMES.editorInvalid;
|
|
66
|
+
let t5;
|
|
67
|
+
if ($[2] !== t4) {
|
|
68
|
+
t5 = cn(RICH_LINK_EDITOR_CLASS_NAMES.editor, t4);
|
|
69
|
+
$[2] = t4;
|
|
70
|
+
$[3] = t5;
|
|
71
|
+
} else {
|
|
72
|
+
t5 = $[3];
|
|
73
|
+
}
|
|
74
|
+
const editorClassName = t5;
|
|
75
|
+
let t6;
|
|
76
|
+
let t7;
|
|
77
|
+
if ($[4] !== closeLinkPopover || $[5] !== isDisabled) {
|
|
78
|
+
t6 = () => {
|
|
79
|
+
if (isDisabled) {
|
|
80
|
+
closeLinkPopover();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
t7 = [closeLinkPopover, isDisabled];
|
|
84
|
+
$[4] = closeLinkPopover;
|
|
85
|
+
$[5] = isDisabled;
|
|
86
|
+
$[6] = t6;
|
|
87
|
+
$[7] = t7;
|
|
88
|
+
} else {
|
|
89
|
+
t6 = $[6];
|
|
90
|
+
t7 = $[7];
|
|
91
|
+
}
|
|
92
|
+
useEffect(t6, t7);
|
|
93
|
+
let t8;
|
|
94
|
+
if ($[8] !== isEditingLink) {
|
|
95
|
+
t8 = () => {
|
|
96
|
+
if (isEditingLink) {
|
|
97
|
+
linkTextInputRef.current?.focus();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
$[8] = isEditingLink;
|
|
101
|
+
$[9] = t8;
|
|
102
|
+
} else {
|
|
103
|
+
t8 = $[9];
|
|
104
|
+
}
|
|
105
|
+
const t9 = activeLink?.key;
|
|
106
|
+
let t10;
|
|
107
|
+
if ($[10] !== isEditingLink || $[11] !== t9) {
|
|
108
|
+
t10 = [isEditingLink, t9];
|
|
109
|
+
$[10] = isEditingLink;
|
|
110
|
+
$[11] = t9;
|
|
111
|
+
$[12] = t10;
|
|
112
|
+
} else {
|
|
113
|
+
t10 = $[12];
|
|
114
|
+
}
|
|
115
|
+
useEffect(t8, t10);
|
|
116
|
+
let t11;
|
|
117
|
+
if ($[13] !== activeLink || $[14] !== isLinkEditValid || $[15] !== saveLinkEdit) {
|
|
118
|
+
t11 = (event) => {
|
|
119
|
+
if (event.key !== RICH_TEXT_EDITOR_KEY.enter) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
if (activeLink && isLinkEditValid) {
|
|
124
|
+
saveLinkEdit(activeLink);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
$[13] = activeLink;
|
|
128
|
+
$[14] = isLinkEditValid;
|
|
129
|
+
$[15] = saveLinkEdit;
|
|
130
|
+
$[16] = t11;
|
|
131
|
+
} else {
|
|
132
|
+
t11 = $[16];
|
|
133
|
+
}
|
|
134
|
+
const handleEditFieldKeyDown = t11;
|
|
135
|
+
const t12 = !isDisabled;
|
|
136
|
+
let t13;
|
|
137
|
+
if ($[17] !== activeLink || $[18] !== closeLinkPopover || $[19] !== copy || $[20] !== handleEditFieldKeyDown || $[21] !== hasContent || $[22] !== hasInvalidLinkUrl || $[23] !== isDisabled || $[24] !== isLinkEditValid || $[25] !== linkTextInput || $[26] !== linkUrlInput || $[27] !== openLinkPopover || $[28] !== popoverMode || $[29] !== removeLink || $[30] !== saveLinkEdit || $[31] !== segments || $[32] !== setLinkTextInput || $[33] !== setLinkUrlInput || $[34] !== setPopoverMode) {
|
|
138
|
+
t13 = hasContent ? segments.map((segment) => segment.type === RICH_TEXT_SEGMENT_TYPE.link ? isDisabled ? /* @__PURE__ */ _jsx("a", {
|
|
139
|
+
"aria-disabled": true,
|
|
140
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.editorLink,
|
|
141
|
+
href: segment.url,
|
|
142
|
+
onClick: _temp,
|
|
143
|
+
rel: LINK_REL,
|
|
144
|
+
tabIndex: -1,
|
|
145
|
+
target: LINK_TARGET,
|
|
146
|
+
children: segment.text
|
|
147
|
+
}, segment.key) : /* @__PURE__ */ _jsxs(Popover, {
|
|
148
|
+
onOpenChange: (isOpen) => {
|
|
149
|
+
if (isOpen) {
|
|
150
|
+
openLinkPopover(segment);
|
|
151
|
+
} else {
|
|
152
|
+
if (activeLink?.key === segment.key) {
|
|
153
|
+
closeLinkPopover();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
open: activeLink?.key === segment.key,
|
|
158
|
+
children: [/* @__PURE__ */ _jsx(PopoverTrigger, {
|
|
159
|
+
asChild: true,
|
|
160
|
+
children: /* @__PURE__ */ _jsx("a", {
|
|
161
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.editorLink,
|
|
162
|
+
href: segment.url,
|
|
163
|
+
onClick: (event_1) => {
|
|
164
|
+
event_1.preventDefault();
|
|
165
|
+
openLinkPopover(segment);
|
|
166
|
+
},
|
|
167
|
+
rel: LINK_REL,
|
|
168
|
+
target: LINK_TARGET,
|
|
169
|
+
children: segment.text
|
|
170
|
+
})
|
|
171
|
+
}), /* @__PURE__ */ _jsx(PopoverContent, {
|
|
172
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.popover,
|
|
173
|
+
onBeforeInput: _temp2,
|
|
174
|
+
onInput: _temp3,
|
|
175
|
+
onKeyDown: _temp4,
|
|
176
|
+
onPaste: _temp5,
|
|
177
|
+
children: popoverMode === RICH_LINK_POPOVER_MODE.actions ? /* @__PURE__ */ _jsxs("div", {
|
|
178
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.actions,
|
|
179
|
+
children: [/* @__PURE__ */ _jsx(ControlButton, {
|
|
180
|
+
onClick: () => {
|
|
181
|
+
setPopoverMode(RICH_LINK_POPOVER_MODE.edit);
|
|
182
|
+
},
|
|
183
|
+
type: BUTTON_TYPE,
|
|
184
|
+
variant: BUTTON_VARIANT.ghost,
|
|
185
|
+
children: copy.editAction
|
|
186
|
+
}), /* @__PURE__ */ _jsx(ControlButton, {
|
|
187
|
+
onClick: () => {
|
|
188
|
+
removeLink(segment);
|
|
189
|
+
},
|
|
190
|
+
type: BUTTON_TYPE,
|
|
191
|
+
variant: BUTTON_VARIANT.ghost,
|
|
192
|
+
children: copy.removeAction
|
|
193
|
+
})]
|
|
194
|
+
}) : /* @__PURE__ */ _jsxs("div", {
|
|
195
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.editForm,
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ _jsxs("label", {
|
|
198
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.label,
|
|
199
|
+
children: [/* @__PURE__ */ _jsx("span", { children: copy.popoverTextLabel }), /* @__PURE__ */ _jsx("input", {
|
|
200
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.input,
|
|
201
|
+
onChange: (event_6) => {
|
|
202
|
+
setLinkTextInput(event_6.currentTarget.value);
|
|
203
|
+
},
|
|
204
|
+
onKeyDown: handleEditFieldKeyDown,
|
|
205
|
+
ref: linkTextInputRef,
|
|
206
|
+
value: linkTextInput
|
|
207
|
+
})]
|
|
208
|
+
}),
|
|
209
|
+
/* @__PURE__ */ _jsxs("label", {
|
|
210
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.label,
|
|
211
|
+
children: [/* @__PURE__ */ _jsx("span", { children: copy.popoverUrlLabel }), /* @__PURE__ */ _jsx("input", {
|
|
212
|
+
"aria-invalid": hasInvalidLinkUrl,
|
|
213
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.input,
|
|
214
|
+
onChange: (event_7) => {
|
|
215
|
+
setLinkUrlInput(event_7.currentTarget.value);
|
|
216
|
+
},
|
|
217
|
+
onKeyDown: handleEditFieldKeyDown,
|
|
218
|
+
type: URL_INPUT_TYPE,
|
|
219
|
+
value: linkUrlInput
|
|
220
|
+
})]
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ _jsxs("div", {
|
|
223
|
+
className: RICH_LINK_EDITOR_CLASS_NAMES.actions,
|
|
224
|
+
children: [/* @__PURE__ */ _jsx(ControlButton, {
|
|
225
|
+
disabled: !isLinkEditValid,
|
|
226
|
+
onClick: () => {
|
|
227
|
+
if (activeLink) {
|
|
228
|
+
saveLinkEdit(activeLink);
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
type: BUTTON_TYPE,
|
|
232
|
+
children: copy.editSave
|
|
233
|
+
}), /* @__PURE__ */ _jsx(ControlButton, {
|
|
234
|
+
onClick: closeLinkPopover,
|
|
235
|
+
type: BUTTON_TYPE,
|
|
236
|
+
variant: BUTTON_VARIANT.outline,
|
|
237
|
+
children: copy.editCancel
|
|
238
|
+
})]
|
|
239
|
+
})
|
|
240
|
+
]
|
|
241
|
+
})
|
|
242
|
+
})]
|
|
243
|
+
}, segment.key) : segment.text) : null;
|
|
244
|
+
$[17] = activeLink;
|
|
245
|
+
$[18] = closeLinkPopover;
|
|
246
|
+
$[19] = copy;
|
|
247
|
+
$[20] = handleEditFieldKeyDown;
|
|
248
|
+
$[21] = hasContent;
|
|
249
|
+
$[22] = hasInvalidLinkUrl;
|
|
250
|
+
$[23] = isDisabled;
|
|
251
|
+
$[24] = isLinkEditValid;
|
|
252
|
+
$[25] = linkTextInput;
|
|
253
|
+
$[26] = linkUrlInput;
|
|
254
|
+
$[27] = openLinkPopover;
|
|
255
|
+
$[28] = popoverMode;
|
|
256
|
+
$[29] = removeLink;
|
|
257
|
+
$[30] = saveLinkEdit;
|
|
258
|
+
$[31] = segments;
|
|
259
|
+
$[32] = setLinkTextInput;
|
|
260
|
+
$[33] = setLinkUrlInput;
|
|
261
|
+
$[34] = setPopoverMode;
|
|
262
|
+
$[35] = t13;
|
|
263
|
+
} else {
|
|
264
|
+
t13 = $[35];
|
|
265
|
+
}
|
|
266
|
+
let t14;
|
|
267
|
+
if ($[36] !== ariaDescribedBy || $[37] !== ariaLabel || $[38] !== editorClassName || $[39] !== handleBeforeInput || $[40] !== handleInput || $[41] !== handleKeyDown || $[42] !== handlePaste || $[43] !== isDisabled || $[44] !== isInvalid || $[45] !== placeholder || $[46] !== setEditorElement || $[47] !== t12 || $[48] !== t13) {
|
|
268
|
+
t14 = /* @__PURE__ */ _jsx("div", {
|
|
269
|
+
"aria-describedby": ariaDescribedBy,
|
|
270
|
+
"aria-disabled": isDisabled,
|
|
271
|
+
"aria-invalid": isInvalid,
|
|
272
|
+
"aria-label": ariaLabel,
|
|
273
|
+
"aria-multiline": true,
|
|
274
|
+
className: editorClassName,
|
|
275
|
+
"data-slot": "rich-link-editor",
|
|
276
|
+
contentEditable: t12,
|
|
277
|
+
"data-placeholder": placeholder,
|
|
278
|
+
onBeforeInput: handleBeforeInput,
|
|
279
|
+
onInput: handleInput,
|
|
280
|
+
onKeyDown: handleKeyDown,
|
|
281
|
+
onPaste: handlePaste,
|
|
282
|
+
ref: setEditorElement,
|
|
283
|
+
role: "textbox",
|
|
284
|
+
suppressContentEditableWarning: true,
|
|
285
|
+
children: t13
|
|
286
|
+
});
|
|
287
|
+
$[36] = ariaDescribedBy;
|
|
288
|
+
$[37] = ariaLabel;
|
|
289
|
+
$[38] = editorClassName;
|
|
290
|
+
$[39] = handleBeforeInput;
|
|
291
|
+
$[40] = handleInput;
|
|
292
|
+
$[41] = handleKeyDown;
|
|
293
|
+
$[42] = handlePaste;
|
|
294
|
+
$[43] = isDisabled;
|
|
295
|
+
$[44] = isInvalid;
|
|
296
|
+
$[45] = placeholder;
|
|
297
|
+
$[46] = setEditorElement;
|
|
298
|
+
$[47] = t12;
|
|
299
|
+
$[48] = t13;
|
|
300
|
+
$[49] = t14;
|
|
301
|
+
} else {
|
|
302
|
+
t14 = $[49];
|
|
303
|
+
}
|
|
304
|
+
return t14;
|
|
305
|
+
}
|
|
306
|
+
function _temp5(event_5) {
|
|
307
|
+
event_5.stopPropagation();
|
|
308
|
+
}
|
|
309
|
+
function _temp4(event_4) {
|
|
310
|
+
event_4.stopPropagation();
|
|
311
|
+
}
|
|
312
|
+
function _temp3(event_3) {
|
|
313
|
+
event_3.stopPropagation();
|
|
314
|
+
}
|
|
315
|
+
function _temp2(event_2) {
|
|
316
|
+
event_2.stopPropagation();
|
|
317
|
+
}
|
|
318
|
+
function _temp(event_0) {
|
|
319
|
+
event_0.preventDefault();
|
|
320
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RichMarkdownContentProps {
|
|
2
|
+
content: string;
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parses and renders the content as paragraphs and lists.
|
|
7
|
+
* @param props - Stored content and optional class name.
|
|
8
|
+
* @returns The rendered blocks.
|
|
9
|
+
*/
|
|
10
|
+
export declare function RichMarkdownContent({ content, className }: RichMarkdownContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders long-form content with a safe markdown subset: paragraphs, unordered lists, inline
|
|
3
|
+
* bold and the shared link syntax. Raw HTML in the content is never interpreted as markup.
|
|
4
|
+
*/
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
import { RICH_MARKDOWN_BLOCK_TYPE, RICH_MARKDOWN_INLINE_TYPE, parseRichMarkdownBlocks } from "../lib/rich-text/rich-markdown.js";
|
|
7
|
+
import { RICH_TEXT_LINK_CLASS_NAME } from "./rich-text-content.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const LINK_TARGET = "_blank";
|
|
10
|
+
const LINK_REL = "noreferrer";
|
|
11
|
+
/**
|
|
12
|
+
* Renders the inline pieces of a paragraph or list item.
|
|
13
|
+
* @param segments - Parsed inline segments.
|
|
14
|
+
* @returns Text, bold runs and links.
|
|
15
|
+
*/
|
|
16
|
+
function renderInlineSegments(segments) {
|
|
17
|
+
return segments.map((segment, segmentIndex) => {
|
|
18
|
+
const segmentKey = segment.type + String(segmentIndex);
|
|
19
|
+
if (segment.type === RICH_MARKDOWN_INLINE_TYPE.link) {
|
|
20
|
+
return /* @__PURE__ */ _jsx("a", {
|
|
21
|
+
"data-slot": "rich-text-link",
|
|
22
|
+
className: RICH_TEXT_LINK_CLASS_NAME,
|
|
23
|
+
href: segment.url,
|
|
24
|
+
rel: LINK_REL,
|
|
25
|
+
target: LINK_TARGET,
|
|
26
|
+
children: segment.text
|
|
27
|
+
}, segmentKey);
|
|
28
|
+
}
|
|
29
|
+
if (segment.type === RICH_MARKDOWN_INLINE_TYPE.bold) {
|
|
30
|
+
return /* @__PURE__ */ _jsx("strong", { children: segment.text }, segmentKey);
|
|
31
|
+
}
|
|
32
|
+
return segment.text;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parses and renders the content as paragraphs and lists.
|
|
37
|
+
* @param props - Stored content and optional class name.
|
|
38
|
+
* @returns The rendered blocks.
|
|
39
|
+
*/
|
|
40
|
+
export function RichMarkdownContent({ content, className }) {
|
|
41
|
+
const blocks = parseRichMarkdownBlocks(content);
|
|
42
|
+
return /* @__PURE__ */ _jsx("div", {
|
|
43
|
+
"data-slot": "rich-markdown-content",
|
|
44
|
+
className: cn("grid gap-[0.9rem]", className),
|
|
45
|
+
children: blocks.map((block, blockIndex) => block.type === RICH_MARKDOWN_BLOCK_TYPE.list ? /* @__PURE__ */ _jsx("ul", {
|
|
46
|
+
className: "m-0 grid list-disc gap-[0.35rem] pl-[1.4rem]",
|
|
47
|
+
children: block.items.map((itemSegments, itemIndex) => /* @__PURE__ */ _jsx("li", {
|
|
48
|
+
className: "leading-[1.7] [overflow-wrap:anywhere] marker:text-muted-foreground",
|
|
49
|
+
children: renderInlineSegments(itemSegments)
|
|
50
|
+
}, block.type + String(blockIndex) + String(itemIndex)))
|
|
51
|
+
}, block.type + String(blockIndex)) : /* @__PURE__ */ _jsx("p", {
|
|
52
|
+
className: "m-0 leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]",
|
|
53
|
+
children: renderInlineSegments(block.segments)
|
|
54
|
+
}, block.type + String(blockIndex)))
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders persisted rich text (markdown links plus auto-detected URLs) as plain text interleaved
|
|
3
|
+
* with safe `<a>` links. Raw HTML in the content is never interpreted as markup.
|
|
4
|
+
*/
|
|
5
|
+
import type { MouseEvent } from "react";
|
|
6
|
+
/** Shared look of links inside rendered rich text. */
|
|
7
|
+
export declare const RICH_TEXT_LINK_CLASS_NAME = "rounded-[0.2rem] text-primary underline decoration-primary/45 underline-offset-[0.18em] transition-[color,text-decoration-color] [word-break:break-word] hover:text-[color-mix(in_oklab,var(--primary)_72%,var(--foreground))] hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";
|
|
8
|
+
export interface RichTextContentProps {
|
|
9
|
+
content: string;
|
|
10
|
+
onLinkClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
11
|
+
linkClassName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Renders an inline fragment instead of a wrapper element, so it composes inside any container
|
|
15
|
+
* without altering layout-sensitive behavior such as `line-clamp` on an ancestor.
|
|
16
|
+
* @param props - Stored content, optional link click handler and link class name.
|
|
17
|
+
* @returns Text and links.
|
|
18
|
+
*/
|
|
19
|
+
export declare function RichTextContent({ content, onLinkClick, linkClassName }: RichTextContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { RICH_TEXT_SEGMENT_TYPE } from "../lib/rich-text/link-markdown-constants.js";
|
|
3
|
+
import { parseRichTextSegments } from "../lib/rich-text/link-markdown.js";
|
|
4
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
|
+
const LINK_TARGET = "_blank";
|
|
6
|
+
const LINK_REL = "noreferrer";
|
|
7
|
+
/** Shared look of links inside rendered rich text. */
|
|
8
|
+
export const RICH_TEXT_LINK_CLASS_NAME = "rounded-[0.2rem] text-primary underline decoration-primary/45 underline-offset-[0.18em] transition-[color,text-decoration-color] [word-break:break-word] hover:text-[color-mix(in_oklab,var(--primary)_72%,var(--foreground))] hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";
|
|
9
|
+
/**
|
|
10
|
+
* Renders an inline fragment instead of a wrapper element, so it composes inside any container
|
|
11
|
+
* without altering layout-sensitive behavior such as `line-clamp` on an ancestor.
|
|
12
|
+
* @param props - Stored content, optional link click handler and link class name.
|
|
13
|
+
* @returns Text and links.
|
|
14
|
+
*/
|
|
15
|
+
export function RichTextContent({ content, onLinkClick, linkClassName }) {
|
|
16
|
+
const segments = parseRichTextSegments(content);
|
|
17
|
+
return /* @__PURE__ */ _jsx(_Fragment, { children: segments.map((segment, segmentIndex) => segment.type === RICH_TEXT_SEGMENT_TYPE.link ? /* @__PURE__ */ _jsx("a", {
|
|
18
|
+
"data-slot": "rich-text-link",
|
|
19
|
+
className: cn(RICH_TEXT_LINK_CLASS_NAME, "font-medium decoration-[0.08em]", linkClassName),
|
|
20
|
+
href: segment.url,
|
|
21
|
+
onClick: onLinkClick,
|
|
22
|
+
rel: LINK_REL,
|
|
23
|
+
target: LINK_TARGET,
|
|
24
|
+
children: segment.text
|
|
25
|
+
}, segment.type + String(segmentIndex)) : segment.text) });
|
|
26
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arc's Select (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md): a labelled choice field whose trigger
|
|
3
|
+
* answers hover, press and open in color only, so the anchored list never shifts, and whose raised list matches the
|
|
4
|
+
* trigger width, with option rows and an end check. It follows Arc's closed API (`label`, `options`, `placeholder`,
|
|
5
|
+
* `description` and Radix's root props) and shares the label, helper and error rows of `Input`.
|
|
6
|
+
*/
|
|
7
|
+
import type { AriaAttributes, ComponentProps, Ref } from "react";
|
|
8
|
+
import { Select as SelectRoot } from "./primitives/select.js";
|
|
9
|
+
/** One choice of a `Select`. */
|
|
10
|
+
export type SelectOption = {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** Height of the trigger: `default` matches `Input` and `Button`, `sm` their small size. */
|
|
16
|
+
export type SelectSize = "default" | "sm";
|
|
17
|
+
export type SelectProps = Omit<ComponentProps<typeof SelectRoot>, "children"> & {
|
|
18
|
+
/** Visible label, tied to the trigger with `htmlFor`. */
|
|
19
|
+
label: string;
|
|
20
|
+
/** Choices, in list order. Readonly arrays, such as lists declared `as const`, are accepted as they are. */
|
|
21
|
+
options: readonly SelectOption[];
|
|
22
|
+
/** Shown while no option is chosen. Defaults to "Seleccioná una opción". */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/** Helper copy under the trigger, linked through `aria-describedby`. */
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Error copy: marks the trigger invalid and renders in a `role="alert"` row, as in `Input`. */
|
|
27
|
+
error?: string;
|
|
28
|
+
/** Trigger id, so an external `<label htmlFor>` can point at it. Generated when omitted. */
|
|
29
|
+
id?: string;
|
|
30
|
+
/** Class on the field that wraps the label, the trigger and the helper rows. */
|
|
31
|
+
className?: string;
|
|
32
|
+
/** Keeps `label` for assistive technology only, for layouts that already show their own label. */
|
|
33
|
+
hideLabel?: boolean;
|
|
34
|
+
/** Height of the trigger. Defaults to `default`. */
|
|
35
|
+
size?: SelectSize;
|
|
36
|
+
/** Class on the trigger. */
|
|
37
|
+
triggerClassName?: string;
|
|
38
|
+
/** Marks the trigger invalid without an error message. `error` sets it too. */
|
|
39
|
+
"aria-invalid"?: AriaAttributes["aria-invalid"];
|
|
40
|
+
/**
|
|
41
|
+
* Ids of external elements that describe the trigger. They are combined with the ids of `description` and
|
|
42
|
+
* `error`, which follow them.
|
|
43
|
+
*/
|
|
44
|
+
"aria-describedby"?: string;
|
|
45
|
+
/** The trigger button. */
|
|
46
|
+
ref?: Ref<HTMLButtonElement>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A compact choice field with a keyboard friendly list, controlled with `value` and `onValueChange` or uncontrolled
|
|
50
|
+
* with `defaultValue`; pass `name` to submit it with a form.
|
|
51
|
+
* @param props - Label, options, optional copy and layout, and Radix select root properties.
|
|
52
|
+
* @returns The labelled field.
|
|
53
|
+
*/
|
|
54
|
+
declare function Select({ label, options, placeholder, description, error, id, className, hideLabel, size, triggerClassName, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedBy, ref, ...rootProps }: SelectProps): import("react").JSX.Element;
|
|
55
|
+
export { Select };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
import { SELECT_DEFAULT_PLACEHOLDER } from "../constants/select.js";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import { Field, useFieldAria } from "./field.js";
|
|
6
|
+
import { Select as SelectRoot, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./primitives/select.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* A compact choice field with a keyboard friendly list, controlled with `value` and `onValueChange` or uncontrolled
|
|
10
|
+
* with `defaultValue`; pass `name` to submit it with a form.
|
|
11
|
+
* @param props - Label, options, optional copy and layout, and Radix select root properties.
|
|
12
|
+
* @returns The labelled field.
|
|
13
|
+
*/
|
|
14
|
+
function Select(t0) {
|
|
15
|
+
const $ = _c(49);
|
|
16
|
+
let ariaDescribedBy;
|
|
17
|
+
let ariaInvalid;
|
|
18
|
+
let className;
|
|
19
|
+
let description;
|
|
20
|
+
let error;
|
|
21
|
+
let id;
|
|
22
|
+
let label;
|
|
23
|
+
let options;
|
|
24
|
+
let ref;
|
|
25
|
+
let rootProps;
|
|
26
|
+
let size;
|
|
27
|
+
let t1;
|
|
28
|
+
let t2;
|
|
29
|
+
let triggerClassName;
|
|
30
|
+
if ($[0] !== t0) {
|
|
31
|
+
({label, options, placeholder: t1, description, error, id, className, hideLabel: t2, size, triggerClassName, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedBy, ref, ...rootProps} = t0);
|
|
32
|
+
$[0] = t0;
|
|
33
|
+
$[1] = ariaDescribedBy;
|
|
34
|
+
$[2] = ariaInvalid;
|
|
35
|
+
$[3] = className;
|
|
36
|
+
$[4] = description;
|
|
37
|
+
$[5] = error;
|
|
38
|
+
$[6] = id;
|
|
39
|
+
$[7] = label;
|
|
40
|
+
$[8] = options;
|
|
41
|
+
$[9] = ref;
|
|
42
|
+
$[10] = rootProps;
|
|
43
|
+
$[11] = size;
|
|
44
|
+
$[12] = t1;
|
|
45
|
+
$[13] = t2;
|
|
46
|
+
$[14] = triggerClassName;
|
|
47
|
+
} else {
|
|
48
|
+
ariaDescribedBy = $[1];
|
|
49
|
+
ariaInvalid = $[2];
|
|
50
|
+
className = $[3];
|
|
51
|
+
description = $[4];
|
|
52
|
+
error = $[5];
|
|
53
|
+
id = $[6];
|
|
54
|
+
label = $[7];
|
|
55
|
+
options = $[8];
|
|
56
|
+
ref = $[9];
|
|
57
|
+
rootProps = $[10];
|
|
58
|
+
size = $[11];
|
|
59
|
+
t1 = $[12];
|
|
60
|
+
t2 = $[13];
|
|
61
|
+
triggerClassName = $[14];
|
|
62
|
+
}
|
|
63
|
+
const placeholder = t1 === undefined ? SELECT_DEFAULT_PLACEHOLDER : t1;
|
|
64
|
+
const hideLabel = t2 === undefined ? false : t2;
|
|
65
|
+
let t3;
|
|
66
|
+
if ($[15] !== ariaDescribedBy || $[16] !== ariaInvalid || $[17] !== description || $[18] !== error || $[19] !== id) {
|
|
67
|
+
t3 = {
|
|
68
|
+
id,
|
|
69
|
+
description,
|
|
70
|
+
error,
|
|
71
|
+
"aria-invalid": ariaInvalid,
|
|
72
|
+
"aria-describedby": ariaDescribedBy
|
|
73
|
+
};
|
|
74
|
+
$[15] = ariaDescribedBy;
|
|
75
|
+
$[16] = ariaInvalid;
|
|
76
|
+
$[17] = description;
|
|
77
|
+
$[18] = error;
|
|
78
|
+
$[19] = id;
|
|
79
|
+
$[20] = t3;
|
|
80
|
+
} else {
|
|
81
|
+
t3 = $[20];
|
|
82
|
+
}
|
|
83
|
+
const aria = useFieldAria(t3);
|
|
84
|
+
const t4 = aria.controlId;
|
|
85
|
+
let t5;
|
|
86
|
+
if ($[21] !== triggerClassName) {
|
|
87
|
+
t5 = cn("w-full min-w-0", triggerClassName);
|
|
88
|
+
$[21] = triggerClassName;
|
|
89
|
+
$[22] = t5;
|
|
90
|
+
} else {
|
|
91
|
+
t5 = $[22];
|
|
92
|
+
}
|
|
93
|
+
const t6 = aria["aria-describedby"];
|
|
94
|
+
const t7 = aria["aria-invalid"];
|
|
95
|
+
let t8;
|
|
96
|
+
if ($[23] !== placeholder) {
|
|
97
|
+
t8 = /* @__PURE__ */ _jsx(SelectValue, { placeholder });
|
|
98
|
+
$[23] = placeholder;
|
|
99
|
+
$[24] = t8;
|
|
100
|
+
} else {
|
|
101
|
+
t8 = $[24];
|
|
102
|
+
}
|
|
103
|
+
let t9;
|
|
104
|
+
if ($[25] !== aria.controlId || $[26] !== ref || $[27] !== size || $[28] !== t5 || $[29] !== t6 || $[30] !== t7 || $[31] !== t8) {
|
|
105
|
+
t9 = /* @__PURE__ */ _jsx(SelectTrigger, {
|
|
106
|
+
ref,
|
|
107
|
+
id: t4,
|
|
108
|
+
size,
|
|
109
|
+
className: t5,
|
|
110
|
+
"aria-describedby": t6,
|
|
111
|
+
"aria-invalid": t7,
|
|
112
|
+
children: t8
|
|
113
|
+
});
|
|
114
|
+
$[25] = aria.controlId;
|
|
115
|
+
$[26] = ref;
|
|
116
|
+
$[27] = size;
|
|
117
|
+
$[28] = t5;
|
|
118
|
+
$[29] = t6;
|
|
119
|
+
$[30] = t7;
|
|
120
|
+
$[31] = t8;
|
|
121
|
+
$[32] = t9;
|
|
122
|
+
} else {
|
|
123
|
+
t9 = $[32];
|
|
124
|
+
}
|
|
125
|
+
let t10;
|
|
126
|
+
if ($[33] !== options) {
|
|
127
|
+
t10 = options.map(_temp);
|
|
128
|
+
$[33] = options;
|
|
129
|
+
$[34] = t10;
|
|
130
|
+
} else {
|
|
131
|
+
t10 = $[34];
|
|
132
|
+
}
|
|
133
|
+
let t11;
|
|
134
|
+
if ($[35] !== t10) {
|
|
135
|
+
t11 = /* @__PURE__ */ _jsx(SelectContent, {
|
|
136
|
+
position: "popper",
|
|
137
|
+
children: t10
|
|
138
|
+
});
|
|
139
|
+
$[35] = t10;
|
|
140
|
+
$[36] = t11;
|
|
141
|
+
} else {
|
|
142
|
+
t11 = $[36];
|
|
143
|
+
}
|
|
144
|
+
let t12;
|
|
145
|
+
if ($[37] !== rootProps || $[38] !== t11 || $[39] !== t9) {
|
|
146
|
+
t12 = /* @__PURE__ */ _jsxs(SelectRoot, {
|
|
147
|
+
...rootProps,
|
|
148
|
+
children: [t9, t11]
|
|
149
|
+
});
|
|
150
|
+
$[37] = rootProps;
|
|
151
|
+
$[38] = t11;
|
|
152
|
+
$[39] = t9;
|
|
153
|
+
$[40] = t12;
|
|
154
|
+
} else {
|
|
155
|
+
t12 = $[40];
|
|
156
|
+
}
|
|
157
|
+
let t13;
|
|
158
|
+
if ($[41] !== aria || $[42] !== className || $[43] !== description || $[44] !== error || $[45] !== hideLabel || $[46] !== label || $[47] !== t12) {
|
|
159
|
+
t13 = /* @__PURE__ */ _jsx(Field, {
|
|
160
|
+
label,
|
|
161
|
+
hideLabel,
|
|
162
|
+
description,
|
|
163
|
+
error,
|
|
164
|
+
aria,
|
|
165
|
+
className,
|
|
166
|
+
children: t12
|
|
167
|
+
});
|
|
168
|
+
$[41] = aria;
|
|
169
|
+
$[42] = className;
|
|
170
|
+
$[43] = description;
|
|
171
|
+
$[44] = error;
|
|
172
|
+
$[45] = hideLabel;
|
|
173
|
+
$[46] = label;
|
|
174
|
+
$[47] = t12;
|
|
175
|
+
$[48] = t13;
|
|
176
|
+
} else {
|
|
177
|
+
t13 = $[48];
|
|
178
|
+
}
|
|
179
|
+
return t13;
|
|
180
|
+
}
|
|
181
|
+
function _temp(option) {
|
|
182
|
+
return /* @__PURE__ */ _jsx(SelectItem, {
|
|
183
|
+
value: option.value,
|
|
184
|
+
disabled: option.disabled,
|
|
185
|
+
children: option.label
|
|
186
|
+
}, option.value);
|
|
187
|
+
}
|
|
188
|
+
export { Select };
|