@astra-kit/ui 0.0.0-stage → 1.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 +21 -0
- package/LICENSE.md +21 -0
- package/README.md +330 -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 +58 -0
- package/dist/components/dropdown-menu.js +135 -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 +17 -0
- package/dist/constants/dropdown-menu.js +48 -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,34 @@
|
|
|
1
|
+
import { ARC_DURATION, ARC_EASE } from "../motion/arc-tokens.js";
|
|
2
|
+
/** Minimum distance, in pixels, the option list keeps from the viewport edges. */
|
|
3
|
+
export const SELECT_COLLISION_PADDING_PX = 12;
|
|
4
|
+
/** Default Spanish placeholder, shown while no option is chosen. Arc's English default is "Select an option". */
|
|
5
|
+
export const SELECT_DEFAULT_PLACEHOLDER = "Seleccioná una opción";
|
|
6
|
+
const SELECT_ENTER_TWEEN = {
|
|
7
|
+
duration: ARC_DURATION.standard,
|
|
8
|
+
ease: [...ARC_EASE.enter]
|
|
9
|
+
};
|
|
10
|
+
const SELECT_EXIT_TWEEN = {
|
|
11
|
+
duration: ARC_DURATION.instant,
|
|
12
|
+
ease: [...ARC_EASE.standard]
|
|
13
|
+
};
|
|
14
|
+
/** Arc's option list: it grows 6px from the trigger edge at .97 and leaves halfway back at .98, both as tweens. */
|
|
15
|
+
export const SELECT_MOTION = {
|
|
16
|
+
enterFrom: {
|
|
17
|
+
travel: 6,
|
|
18
|
+
scale: .97,
|
|
19
|
+
opacity: 0
|
|
20
|
+
},
|
|
21
|
+
enter: {
|
|
22
|
+
transform: SELECT_ENTER_TWEEN,
|
|
23
|
+
opacity: SELECT_ENTER_TWEEN
|
|
24
|
+
},
|
|
25
|
+
exitTo: {
|
|
26
|
+
travel: 3,
|
|
27
|
+
scale: .98,
|
|
28
|
+
opacity: 0
|
|
29
|
+
},
|
|
30
|
+
exit: {
|
|
31
|
+
transform: SELECT_EXIT_TWEEN,
|
|
32
|
+
opacity: SELECT_EXIT_TWEEN
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Defines the cookie contract shared by the UI and server-side consumers. */
|
|
2
|
+
/** Stable cookie key read by server entrypoints and written by the sidebar. */
|
|
3
|
+
export declare const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
4
|
+
/** Serialized value representing expanded navigation. */
|
|
5
|
+
export declare const SIDEBAR_COOKIE_OPEN_VALUE = "true";
|
|
6
|
+
/** Serialized value representing collapsed navigation. */
|
|
7
|
+
export declare const SIDEBAR_COOKIE_COLLAPSED_VALUE = "false";
|
|
8
|
+
/** Preference lifetime in seconds, as required by the cookie max-age field. */
|
|
9
|
+
export declare const SIDEBAR_COOKIE_MAX_AGE: number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Defines the cookie contract shared by the UI and server-side consumers. */
|
|
2
|
+
/** Number of days the navigation preference remains valid. */
|
|
3
|
+
const SIDEBAR_COOKIE_MAX_AGE_DAYS = 7;
|
|
4
|
+
/** Converts preference days into hours. */
|
|
5
|
+
const SIDEBAR_COOKIE_MAX_AGE_HOURS_PER_DAY = 24;
|
|
6
|
+
/** Converts preference hours into minutes. */
|
|
7
|
+
const SIDEBAR_COOKIE_MAX_AGE_MINUTES_PER_HOUR = 60;
|
|
8
|
+
/** Converts preference minutes into cookie max-age seconds. */
|
|
9
|
+
const SIDEBAR_COOKIE_MAX_AGE_SECONDS_PER_MINUTE = 60;
|
|
10
|
+
/** Stable cookie key read by server entrypoints and written by the sidebar. */
|
|
11
|
+
export const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
12
|
+
/** Serialized value representing expanded navigation. */
|
|
13
|
+
export const SIDEBAR_COOKIE_OPEN_VALUE = "true";
|
|
14
|
+
/** Serialized value representing collapsed navigation. */
|
|
15
|
+
export const SIDEBAR_COOKIE_COLLAPSED_VALUE = "false";
|
|
16
|
+
/** Preference lifetime in seconds, as required by the cookie max-age field. */
|
|
17
|
+
export const SIDEBAR_COOKIE_MAX_AGE = SIDEBAR_COOKIE_MAX_AGE_SECONDS_PER_MINUTE * SIDEBAR_COOKIE_MAX_AGE_MINUTES_PER_HOUR * SIDEBAR_COOKIE_MAX_AGE_HOURS_PER_DAY * SIDEBAR_COOKIE_MAX_AGE_DAYS;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Defaults and tuning of Arc's Skeleton placeholder. */
|
|
2
|
+
/** Default Spanish label announced while the composed placeholder is busy. */
|
|
3
|
+
export declare const SKELETON_DEFAULT_LABEL = "Cargando contenido";
|
|
4
|
+
/** Text lines the composed placeholder draws when `lines` is not set. */
|
|
5
|
+
export declare const SKELETON_DEFAULT_LINES = 3;
|
|
6
|
+
/** Bounds of `lines`, so a placeholder never collapses or turns into a wall of bars. */
|
|
7
|
+
export declare const SKELETON_LINE_LIMITS: {
|
|
8
|
+
readonly min: 1;
|
|
9
|
+
readonly max: 6;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* After loading flips, resizes inside this window spring to the new height; later resizes (a font swap, a parent
|
|
13
|
+
* reflow) follow at once.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SKELETON_MORPH_WINDOW_MS = 120;
|
|
16
|
+
/** Vertical travel, in pixels, of revealed content rising into place. */
|
|
17
|
+
export declare const SKELETON_REVEAL_OFFSET_PX = 4;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Defaults and tuning of Arc's Skeleton placeholder. */
|
|
2
|
+
/** Default Spanish label announced while the composed placeholder is busy. */
|
|
3
|
+
export const SKELETON_DEFAULT_LABEL = "Cargando contenido";
|
|
4
|
+
/** Text lines the composed placeholder draws when `lines` is not set. */
|
|
5
|
+
export const SKELETON_DEFAULT_LINES = 3;
|
|
6
|
+
/** Bounds of `lines`, so a placeholder never collapses or turns into a wall of bars. */
|
|
7
|
+
export const SKELETON_LINE_LIMITS = {
|
|
8
|
+
min: 1,
|
|
9
|
+
max: 6
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* After loading flips, resizes inside this window spring to the new height; later resizes (a font swap, a parent
|
|
13
|
+
* reflow) follow at once.
|
|
14
|
+
*/
|
|
15
|
+
export const SKELETON_MORPH_WINDOW_MS = 120;
|
|
16
|
+
/** Vertical travel, in pixels, of revealed content rising into place. */
|
|
17
|
+
export const SKELETON_REVEAL_OFFSET_PX = 4;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** `primary` for the main action of a surface, `secondary` for a quieter, smaller one. */
|
|
2
|
+
export type SplitButtonVariant = "primary" | "secondary";
|
|
3
|
+
/** Height of both halves for each variant: the secondary split button is compact, as in Arc. */
|
|
4
|
+
export declare const SPLIT_BUTTON_SIZE_BY_VARIANT: {
|
|
5
|
+
readonly primary: "md";
|
|
6
|
+
readonly secondary: "sm";
|
|
7
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Tuning of Arc's Switch thumb, adapted from Arc (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md). */
|
|
2
|
+
/**
|
|
3
|
+
* Thumb geometry on Arc's 42 by 24 track, in pixels: its resting width and how far it travels, which is the track's
|
|
4
|
+
* inner width minus the thumb. Keep in sync with the track and thumb sizes in `switch.tsx`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SWITCH_THUMB_GEOMETRY_PX: {
|
|
7
|
+
readonly size: 18;
|
|
8
|
+
readonly travel: 18;
|
|
9
|
+
};
|
|
10
|
+
/** How far, in pixels, the thumb widens toward the other side while it is held down. */
|
|
11
|
+
export declare const SWITCH_PRESS_STRETCH_PX = 5;
|
|
12
|
+
/** Critically damped glide: the thumb lands on its end without overshooting the state it reports. */
|
|
13
|
+
export declare const SWITCH_THUMB_GLIDE_SPRING: {
|
|
14
|
+
readonly type: "spring";
|
|
15
|
+
readonly visualDuration: 0.3;
|
|
16
|
+
readonly bounce: 0;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Brief horizontal stretch played when the state changes without a press (a controlled update or a label click), so
|
|
20
|
+
* the thumb reads as moving mass rather than a sliding dot.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SWITCH_CHANGE_STRETCH: {
|
|
23
|
+
readonly scaleX: readonly [1, 1.16, 1];
|
|
24
|
+
readonly duration: 0.34;
|
|
25
|
+
readonly times: readonly [0, 0.4, 1];
|
|
26
|
+
readonly ease: readonly ["easeOut", "easeInOut"];
|
|
27
|
+
};
|
|
28
|
+
/** Window, in milliseconds, after a pointer or Space release in which a state change counts as caused by that press. */
|
|
29
|
+
export declare const SWITCH_PRESS_RELEASE_WINDOW_MS = 250;
|
|
30
|
+
/** Key that toggles a focused switch and stretches its thumb while held. */
|
|
31
|
+
export declare const SWITCH_TOGGLE_KEY = " ";
|
|
32
|
+
/** Mouse button that presses the switch: the primary one. */
|
|
33
|
+
export declare const SWITCH_PRIMARY_POINTER_BUTTON = 0;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Tuning of Arc's Switch thumb, adapted from Arc (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md). */
|
|
2
|
+
/**
|
|
3
|
+
* Thumb geometry on Arc's 42 by 24 track, in pixels: its resting width and how far it travels, which is the track's
|
|
4
|
+
* inner width minus the thumb. Keep in sync with the track and thumb sizes in `switch.tsx`.
|
|
5
|
+
*/
|
|
6
|
+
export const SWITCH_THUMB_GEOMETRY_PX = {
|
|
7
|
+
size: 18,
|
|
8
|
+
travel: 18
|
|
9
|
+
};
|
|
10
|
+
/** How far, in pixels, the thumb widens toward the other side while it is held down. */
|
|
11
|
+
export const SWITCH_PRESS_STRETCH_PX = 5;
|
|
12
|
+
/** Critically damped glide: the thumb lands on its end without overshooting the state it reports. */
|
|
13
|
+
export const SWITCH_THUMB_GLIDE_SPRING = {
|
|
14
|
+
type: "spring",
|
|
15
|
+
visualDuration: .3,
|
|
16
|
+
bounce: 0
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Brief horizontal stretch played when the state changes without a press (a controlled update or a label click), so
|
|
20
|
+
* the thumb reads as moving mass rather than a sliding dot.
|
|
21
|
+
*/
|
|
22
|
+
export const SWITCH_CHANGE_STRETCH = {
|
|
23
|
+
scaleX: [
|
|
24
|
+
1,
|
|
25
|
+
1.16,
|
|
26
|
+
1
|
|
27
|
+
],
|
|
28
|
+
duration: .34,
|
|
29
|
+
times: [
|
|
30
|
+
0,
|
|
31
|
+
.4,
|
|
32
|
+
1
|
|
33
|
+
],
|
|
34
|
+
ease: ["easeOut", "easeInOut"]
|
|
35
|
+
};
|
|
36
|
+
/** Window, in milliseconds, after a pointer or Space release in which a state change counts as caused by that press. */
|
|
37
|
+
export const SWITCH_PRESS_RELEASE_WINDOW_MS = 250;
|
|
38
|
+
/** Key that toggles a focused switch and stretches its thumb while held. */
|
|
39
|
+
export const SWITCH_TOGGLE_KEY = " ";
|
|
40
|
+
/** Mouse button that presses the switch: the primary one. */
|
|
41
|
+
export const SWITCH_PRIMARY_POINTER_BUTTON = 0;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Tuning of Arc's Tabs: directional panel motion, height morph and active-tab reveal. */
|
|
2
|
+
/** Sign of the travel between two tabs: forward when the new tab sits after the previous one. */
|
|
3
|
+
export declare const TABS_DIRECTION: {
|
|
4
|
+
readonly forward: 1;
|
|
5
|
+
readonly backward: -1;
|
|
6
|
+
};
|
|
7
|
+
/** Distance, in px, an entering panel slides in from and a leaving panel slides out to. */
|
|
8
|
+
export declare const TABS_PANEL_OFFSET_PX: {
|
|
9
|
+
readonly enter: 8;
|
|
10
|
+
readonly exit: 6;
|
|
11
|
+
};
|
|
12
|
+
/** Fade-out, in seconds, of a leaving panel when motion is reduced. */
|
|
13
|
+
export declare const TABS_PANEL_REDUCED_EXIT_DURATION_S = 0.1;
|
|
14
|
+
/** Height differences up to this many px between panels jump instead of morphing. */
|
|
15
|
+
export declare const TABS_PANEL_HEIGHT_TOLERANCE_PX = 1;
|
|
16
|
+
/** Space, in px, kept between a revealed tab and the scrolled list edge: the list padding. */
|
|
17
|
+
export declare const TABS_REVEAL_MARGIN_PX = 4;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Tuning of Arc's Tabs: directional panel motion, height morph and active-tab reveal. */
|
|
2
|
+
/** Sign of the travel between two tabs: forward when the new tab sits after the previous one. */
|
|
3
|
+
export const TABS_DIRECTION = {
|
|
4
|
+
forward: 1,
|
|
5
|
+
backward: -1
|
|
6
|
+
};
|
|
7
|
+
/** Distance, in px, an entering panel slides in from and a leaving panel slides out to. */
|
|
8
|
+
export const TABS_PANEL_OFFSET_PX = {
|
|
9
|
+
enter: 8,
|
|
10
|
+
exit: 6
|
|
11
|
+
};
|
|
12
|
+
/** Fade-out, in seconds, of a leaving panel when motion is reduced. */
|
|
13
|
+
export const TABS_PANEL_REDUCED_EXIT_DURATION_S = .1;
|
|
14
|
+
/** Height differences up to this many px between panels jump instead of morphing. */
|
|
15
|
+
export const TABS_PANEL_HEIGHT_TOLERANCE_PX = 1;
|
|
16
|
+
/** Space, in px, kept between a revealed tab and the scrolled list edge: the list padding. */
|
|
17
|
+
export const TABS_REVEAL_MARGIN_PX = 4;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ArcFloatingMotion } from "../motion/arc-floating-slot.js";
|
|
2
|
+
/** Milliseconds of hover or focus before the first tooltip opens. */
|
|
3
|
+
export declare const TOOLTIP_OPEN_DELAY_MS = 250;
|
|
4
|
+
/** While a tooltip is open, and this many milliseconds after the last one closes, the next opens at once and only fades. */
|
|
5
|
+
export declare const TOOLTIP_SKIP_WINDOW_MS = 300;
|
|
6
|
+
/** Gap, in px, between the bubble and its trigger. */
|
|
7
|
+
export declare const TOOLTIP_SIDE_OFFSET_PX = 8;
|
|
8
|
+
/** Distance, in px, the bubble keeps from the viewport edges before it flips or shifts. */
|
|
9
|
+
export declare const TOOLTIP_COLLISION_PADDING_PX = 12;
|
|
10
|
+
/** The first tooltip rises 3px from its trigger while it scales up from .97. */
|
|
11
|
+
export declare const TOOLTIP_MOTION: ArcFloatingMotion;
|
|
12
|
+
/** Within the skip window the next tooltip only fades in, on the instant timing. */
|
|
13
|
+
export declare const TOOLTIP_INSTANT_MOTION: ArcFloatingMotion;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ARC_DURATION, ARC_EASE } from "../motion/arc-tokens.js";
|
|
2
|
+
/** Milliseconds of hover or focus before the first tooltip opens. */
|
|
3
|
+
export const TOOLTIP_OPEN_DELAY_MS = 250;
|
|
4
|
+
/** While a tooltip is open, and this many milliseconds after the last one closes, the next opens at once and only fades. */
|
|
5
|
+
export const TOOLTIP_SKIP_WINDOW_MS = 300;
|
|
6
|
+
/** Gap, in px, between the bubble and its trigger. */
|
|
7
|
+
export const TOOLTIP_SIDE_OFFSET_PX = 8;
|
|
8
|
+
/** Distance, in px, the bubble keeps from the viewport edges before it flips or shifts. */
|
|
9
|
+
export const TOOLTIP_COLLISION_PADDING_PX = 12;
|
|
10
|
+
const enterTween = {
|
|
11
|
+
duration: ARC_DURATION.fast,
|
|
12
|
+
ease: [...ARC_EASE.enter]
|
|
13
|
+
};
|
|
14
|
+
const instantTween = {
|
|
15
|
+
duration: ARC_DURATION.instant,
|
|
16
|
+
ease: [...ARC_EASE.standard]
|
|
17
|
+
};
|
|
18
|
+
/** The first tooltip rises 3px from its trigger while it scales up from .97. */
|
|
19
|
+
export const TOOLTIP_MOTION = {
|
|
20
|
+
enterFrom: {
|
|
21
|
+
travel: 3,
|
|
22
|
+
scale: .97,
|
|
23
|
+
opacity: 0
|
|
24
|
+
},
|
|
25
|
+
enter: {
|
|
26
|
+
transform: enterTween,
|
|
27
|
+
opacity: enterTween
|
|
28
|
+
},
|
|
29
|
+
exitTo: {
|
|
30
|
+
travel: 0,
|
|
31
|
+
scale: .98,
|
|
32
|
+
opacity: 0
|
|
33
|
+
},
|
|
34
|
+
exit: {
|
|
35
|
+
transform: instantTween,
|
|
36
|
+
opacity: instantTween
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/** Within the skip window the next tooltip only fades in, on the instant timing. */
|
|
40
|
+
export const TOOLTIP_INSTANT_MOTION = {
|
|
41
|
+
enterFrom: {
|
|
42
|
+
travel: 0,
|
|
43
|
+
scale: 1,
|
|
44
|
+
opacity: 0
|
|
45
|
+
},
|
|
46
|
+
enter: {
|
|
47
|
+
transform: instantTween,
|
|
48
|
+
opacity: instantTween
|
|
49
|
+
},
|
|
50
|
+
exitTo: TOOLTIP_MOTION.exitTo,
|
|
51
|
+
exit: TOOLTIP_MOTION.exit
|
|
52
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Recognizes one-finger horizontal swipes on touch surfaces such as pagers and calendars. */
|
|
2
|
+
import { type TouchEvent } from "react";
|
|
3
|
+
import { type HorizontalSwipeDirection } from "../lib/horizontal-swipe.js";
|
|
4
|
+
/**
|
|
5
|
+
* Touch handlers to spread on the swipe surface.
|
|
6
|
+
*/
|
|
7
|
+
export type HorizontalSwipeHandlers = {
|
|
8
|
+
onTouchCancel: () => void;
|
|
9
|
+
onTouchEnd: (event: TouchEvent<HTMLElement>) => void;
|
|
10
|
+
onTouchStart: (event: TouchEvent<HTMLElement>) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Detects horizontal one-finger swipes. Touch events are used instead of
|
|
14
|
+
* Pointer Events because browsers fire `pointercancel` as soon as they start
|
|
15
|
+
* scrolling, and WebKit (iOS Safari and every iOS browser) has only partial
|
|
16
|
+
* `touch-action` support to prevent it, while `touchend` is delivered on
|
|
17
|
+
* both engines. The handlers never call `preventDefault`, so native vertical
|
|
18
|
+
* scrolling and pinch-zoom keep working; mouse drags never trigger a swipe.
|
|
19
|
+
*
|
|
20
|
+
* @param onSwipe - Called once per recognised swipe.
|
|
21
|
+
* @returns Handlers for the swipe surface.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useHorizontalSwipe(onSwipe: (direction: HorizontalSwipeDirection) => void): HorizontalSwipeHandlers;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/** Recognizes one-finger horizontal swipes on touch surfaces such as pagers and calendars. */
|
|
4
|
+
import { useRef } from "react";
|
|
5
|
+
import { resolveHorizontalSwipe } from "../lib/horizontal-swipe.js";
|
|
6
|
+
/**
|
|
7
|
+
* Detects horizontal one-finger swipes. Touch events are used instead of
|
|
8
|
+
* Pointer Events because browsers fire `pointercancel` as soon as they start
|
|
9
|
+
* scrolling, and WebKit (iOS Safari and every iOS browser) has only partial
|
|
10
|
+
* `touch-action` support to prevent it, while `touchend` is delivered on
|
|
11
|
+
* both engines. The handlers never call `preventDefault`, so native vertical
|
|
12
|
+
* scrolling and pinch-zoom keep working; mouse drags never trigger a swipe.
|
|
13
|
+
*
|
|
14
|
+
* @param onSwipe - Called once per recognised swipe.
|
|
15
|
+
* @returns Handlers for the swipe surface.
|
|
16
|
+
*/
|
|
17
|
+
export function useHorizontalSwipe(onSwipe) {
|
|
18
|
+
const $ = _c(6);
|
|
19
|
+
const swipeStartRef = useRef(null);
|
|
20
|
+
let t0;
|
|
21
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t0 = () => {
|
|
23
|
+
swipeStartRef.current = null;
|
|
24
|
+
};
|
|
25
|
+
$[0] = t0;
|
|
26
|
+
} else {
|
|
27
|
+
t0 = $[0];
|
|
28
|
+
}
|
|
29
|
+
let t1;
|
|
30
|
+
if ($[1] !== onSwipe) {
|
|
31
|
+
t1 = (event) => {
|
|
32
|
+
const swipeStart = swipeStartRef.current;
|
|
33
|
+
const endTouch = swipeStart ? Array.from(event.changedTouches).find((touch) => touch.identifier === swipeStart.identifier) : undefined;
|
|
34
|
+
swipeStartRef.current = null;
|
|
35
|
+
if (!swipeStart || !endTouch) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const direction = resolveHorizontalSwipe({
|
|
39
|
+
deltaX: endTouch.clientX - swipeStart.x,
|
|
40
|
+
deltaY: endTouch.clientY - swipeStart.y,
|
|
41
|
+
durationMs: event.timeStamp - swipeStart.startTime
|
|
42
|
+
});
|
|
43
|
+
if (direction) {
|
|
44
|
+
onSwipe(direction);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
$[1] = onSwipe;
|
|
48
|
+
$[2] = t1;
|
|
49
|
+
} else {
|
|
50
|
+
t1 = $[2];
|
|
51
|
+
}
|
|
52
|
+
let t2;
|
|
53
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
54
|
+
t2 = (event_0) => {
|
|
55
|
+
const [firstTouch] = Array.from(event_0.touches);
|
|
56
|
+
swipeStartRef.current = event_0.touches.length === 1 && firstTouch ? {
|
|
57
|
+
identifier: firstTouch.identifier,
|
|
58
|
+
startTime: event_0.timeStamp,
|
|
59
|
+
x: firstTouch.clientX,
|
|
60
|
+
y: firstTouch.clientY
|
|
61
|
+
} : null;
|
|
62
|
+
};
|
|
63
|
+
$[3] = t2;
|
|
64
|
+
} else {
|
|
65
|
+
t2 = $[3];
|
|
66
|
+
}
|
|
67
|
+
let t3;
|
|
68
|
+
if ($[4] !== t1) {
|
|
69
|
+
t3 = {
|
|
70
|
+
onTouchCancel: t0,
|
|
71
|
+
onTouchEnd: t1,
|
|
72
|
+
onTouchStart: t2
|
|
73
|
+
};
|
|
74
|
+
$[4] = t1;
|
|
75
|
+
$[5] = t3;
|
|
76
|
+
} else {
|
|
77
|
+
t3 = $[5];
|
|
78
|
+
}
|
|
79
|
+
return t3;
|
|
80
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hydration store: the server snapshot is `false` and the client snapshot is
|
|
3
|
+
* `true`, so the first client render still matches the server markup and the
|
|
4
|
+
* component learns it is hydrated on the very next render without an effect.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useIsHydrated(): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/** Tells hydrated client renders apart from server and hydration renders without an effect. */
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
function subscribeToNothing() {
|
|
5
|
+
return () => undefined;
|
|
6
|
+
}
|
|
7
|
+
function getHydratedSnapshot() {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
function getServerHydratedSnapshot() {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hydration store: the server snapshot is `false` and the client snapshot is
|
|
15
|
+
* `true`, so the first client render still matches the server markup and the
|
|
16
|
+
* component learns it is hydrated on the very next render without an effect.
|
|
17
|
+
*/
|
|
18
|
+
export function useIsHydrated() {
|
|
19
|
+
return useSyncExternalStore(subscribeToNothing, getHydratedSnapshot, getServerHydratedSnapshot);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsMobile(): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** Viewport width in CSS pixels at which desktop navigation begins. */
|
|
3
|
+
const MOBILE_BREAKPOINT = 768;
|
|
4
|
+
function subscribeToMobileBreakpoint(onStoreChange) {
|
|
5
|
+
const mediaQueryList = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
6
|
+
mediaQueryList.addEventListener("change", onStoreChange);
|
|
7
|
+
return () => {
|
|
8
|
+
mediaQueryList.removeEventListener("change", onStoreChange);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function getMobileSnapshot() {
|
|
12
|
+
return window.innerWidth < MOBILE_BREAKPOINT;
|
|
13
|
+
}
|
|
14
|
+
function getServerMobileSnapshot() {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
export function useIsMobile() {
|
|
18
|
+
return React.useSyncExternalStore(subscribeToMobileBreakpoint, getMobileSnapshot, getServerMobileSnapshot);
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/** Reads motion preferences without changing the initial server/hydration markup. */
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
import { REDUCED_MOTION_QUERY } from "../constants/motion.js";
|
|
5
|
+
/** Subscribes to preference changes, including browsers exposing the legacy media API. */
|
|
6
|
+
function subscribe(onChange) {
|
|
7
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return () => {};
|
|
8
|
+
const query = window.matchMedia(REDUCED_MOTION_QUERY);
|
|
9
|
+
if (typeof query.addEventListener === "function") {
|
|
10
|
+
query.addEventListener("change", onChange);
|
|
11
|
+
return () => query.removeEventListener("change", onChange);
|
|
12
|
+
}
|
|
13
|
+
query.addListener?.(onChange);
|
|
14
|
+
return () => query.removeListener?.(onChange);
|
|
15
|
+
}
|
|
16
|
+
/** Resolves the current browser setting while tolerating non-browser test environments. */
|
|
17
|
+
function getSnapshot() {
|
|
18
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(REDUCED_MOTION_QUERY).matches;
|
|
19
|
+
}
|
|
20
|
+
/** Keeps the initial client tree consistent with the server-rendered tree. */
|
|
21
|
+
function getServerSnapshot() {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
/** Returns a live preference for animations that cannot be controlled with CSS alone. */
|
|
25
|
+
export function usePrefersReducedMotion() {
|
|
26
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
27
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Owns the state of `RichLinkEditor`: content, tracked links, popover and selection. */
|
|
2
|
+
import { type ClipboardEvent, type FormEvent, type KeyboardEvent } from "react";
|
|
3
|
+
import { RICH_LINK_POPOVER_MODE } from "../lib/rich-text/link-markdown-constants.js";
|
|
4
|
+
import type { ActiveRichPreviewLink, RichLink, RichPreviewSegment } from "../lib/rich-text/link-markdown-types.js";
|
|
5
|
+
type RichLinkPopoverMode = (typeof RICH_LINK_POPOVER_MODE)[keyof typeof RICH_LINK_POPOVER_MODE];
|
|
6
|
+
/** Plain-text content plus tracked links, used to snapshot/restore the editor. */
|
|
7
|
+
export type RichLinkEditorDisplayState = {
|
|
8
|
+
content: string;
|
|
9
|
+
links: RichLink[];
|
|
10
|
+
};
|
|
11
|
+
type UseRichLinkEditorOptions = {
|
|
12
|
+
/** Persisted markdown loaded as the initial editor value. */
|
|
13
|
+
initialMarkdown?: string;
|
|
14
|
+
/** Called whenever the author changes the content (e.g. to clear errors). */
|
|
15
|
+
onContentChange?: () => void;
|
|
16
|
+
};
|
|
17
|
+
/** Imperative + reactive API exposed by `useRichLinkEditor` to the editor UI. */
|
|
18
|
+
export type RichLinkEditorController = {
|
|
19
|
+
setEditorElement: (node: HTMLDivElement | null) => void;
|
|
20
|
+
segments: RichPreviewSegment[];
|
|
21
|
+
hasContent: boolean;
|
|
22
|
+
content: string;
|
|
23
|
+
activeLink: ActiveRichPreviewLink | null;
|
|
24
|
+
linkTextInput: string;
|
|
25
|
+
linkUrlInput: string;
|
|
26
|
+
popoverMode: RichLinkPopoverMode;
|
|
27
|
+
/** Whether the popover draft has visible text and an http(s) URL, so it can be saved. */
|
|
28
|
+
isLinkEditValid: boolean;
|
|
29
|
+
/** Whether the author typed a URL that cannot become a safe http(s) link. */
|
|
30
|
+
hasInvalidLinkUrl: boolean;
|
|
31
|
+
setLinkTextInput: (value: string) => void;
|
|
32
|
+
setLinkUrlInput: (value: string) => void;
|
|
33
|
+
setPopoverMode: (mode: RichLinkPopoverMode) => void;
|
|
34
|
+
handleBeforeInput: (event: FormEvent<HTMLDivElement>) => void;
|
|
35
|
+
handleInput: (event: FormEvent<HTMLDivElement>) => void;
|
|
36
|
+
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
37
|
+
handlePaste: (event: ClipboardEvent<HTMLDivElement>) => void;
|
|
38
|
+
openLinkPopover: (segment: ActiveRichPreviewLink) => void;
|
|
39
|
+
closeLinkPopover: () => void;
|
|
40
|
+
removeLink: (segment: ActiveRichPreviewLink) => void;
|
|
41
|
+
saveLinkEdit: (segment: ActiveRichPreviewLink) => void;
|
|
42
|
+
serialize: () => string;
|
|
43
|
+
reset: (markdown?: string) => void;
|
|
44
|
+
getDisplayState: () => RichLinkEditorDisplayState;
|
|
45
|
+
loadFromDisplay: (state: RichLinkEditorDisplayState) => void;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Controls a rich link editor backed by a `contentEditable` element: it owns the
|
|
49
|
+
* plain-text content, the tracked explicit/suppressed links, the link popover
|
|
50
|
+
* state, and the selection bookkeeping, and exposes serialize/reset/snapshot
|
|
51
|
+
* helpers so a feature can persist or restore the value. The DOM rendering lives
|
|
52
|
+
* in `RichLinkEditor`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function useRichLinkEditor(options?: UseRichLinkEditorOptions): RichLinkEditorController;
|
|
55
|
+
export {};
|