@astronox/core 0.1.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/LICENSE +21 -0
- package/README.md +66 -0
- package/package.json +77 -0
- package/src/client/clipboard.ts +7 -0
- package/src/client/focus.ts +17 -0
- package/src/client/index.ts +3 -0
- package/src/client/scroll.ts +15 -0
- package/src/components/actions/ActionListItem/ActionListItem.astro +78 -0
- package/src/components/actions/ActionListItem/ActionListItem.css +43 -0
- package/src/components/actions/Button/Button.astro +100 -0
- package/src/components/actions/Button/Button.css +165 -0
- package/src/components/actions/CardAction/CardAction.astro +97 -0
- package/src/components/actions/CardAction/CardAction.css +188 -0
- package/src/components/actions/MediaTrigger/MediaTrigger.astro +55 -0
- package/src/components/actions/MediaTrigger/MediaTrigger.css +175 -0
- package/src/components/actions/ScrollToTop/ScrollToTop.astro +36 -0
- package/src/components/actions/ScrollToTop/ScrollToTop.css +19 -0
- package/src/components/actions/ScrollToTop/scrollToTopController.ts +32 -0
- package/src/components/content/CardBody/CardBody.astro +31 -0
- package/src/components/content/CardBody/CardBody.css +74 -0
- package/src/components/content/CardFooter/CardFooter.astro +58 -0
- package/src/components/content/CardFooter/CardFooter.css +102 -0
- package/src/components/content/CardHeader/CardHeader.astro +96 -0
- package/src/components/content/CardHeader/CardHeader.css +164 -0
- package/src/components/content/CardLink/CardLink.astro +138 -0
- package/src/components/content/CardLink/CardLink.css +362 -0
- package/src/components/content/CodeBlock/CodeBlock.astro +102 -0
- package/src/components/content/CodeBlock/CodeBlock.css +85 -0
- package/src/components/content/CodeBlock/codeBlockController.ts +60 -0
- package/src/components/content/CodeBlock/contracts.ts +8 -0
- package/src/components/content/InlineDefinition/InlineDefinition.astro +31 -0
- package/src/components/content/InlineDefinition/InlineDefinition.css +9 -0
- package/src/components/content/MarkdownContent/MarkdownContent.astro +32 -0
- package/src/components/content/MarkdownContent/MarkdownContent.css +358 -0
- package/src/components/content/MarkdownContent/MarkdownInline.astro +44 -0
- package/src/components/content/MarkdownContent/MarkdownNode.astro +280 -0
- package/src/components/content/MarkdownContent/MarkdownSymbol.astro +47 -0
- package/src/components/content/MarkdownContent/contracts.ts +181 -0
- package/src/components/data-display/BadgeList/BadgeList.astro +54 -0
- package/src/components/data-display/BadgeList/BadgeList.css +29 -0
- package/src/components/data-display/IconList/IconList.astro +64 -0
- package/src/components/data-display/IconList/IconList.css +55 -0
- package/src/components/data-display/MetricTile/MetricTile.astro +68 -0
- package/src/components/data-display/MetricTile/MetricTile.css +103 -0
- package/src/components/data-display/MetricTile/MetricTileContent.astro +70 -0
- package/src/components/data-display/MetricTile/metricTileController.ts +9 -0
- package/src/components/data-display/Tag/Tag.astro +67 -0
- package/src/components/data-display/Tag/Tag.css +134 -0
- package/src/components/data-display/Tag/TagAffix.astro +33 -0
- package/src/components/data-display/TextPair/TextPair.astro +63 -0
- package/src/components/data-display/TextPair/TextPair.css +99 -0
- package/src/components/feedback/Spinner/Spinner.astro +32 -0
- package/src/components/feedback/Spinner/Spinner.css +37 -0
- package/src/components/feedback/Tooltip/Tooltip.astro +66 -0
- package/src/components/feedback/Tooltip/Tooltip.css +67 -0
- package/src/components/feedback/Tooltip/tooltipController.ts +371 -0
- package/src/components/forms/FieldError/FieldError.astro +31 -0
- package/src/components/forms/FieldError/FieldError.css +12 -0
- package/src/components/forms/FieldError/fieldErrorState.ts +21 -0
- package/src/components/forms/FieldLabel/FieldLabel.astro +32 -0
- package/src/components/forms/FieldLabel/FieldLabel.css +17 -0
- package/src/components/forms/TextInput/TextInput.astro +79 -0
- package/src/components/forms/TextInput/TextInput.css +121 -0
- package/src/components/forms/TextInput/textInputController.ts +53 -0
- package/src/components/icons/ArrowDownIcon.astro +26 -0
- package/src/components/icons/ArrowLeftIcon.astro +26 -0
- package/src/components/icons/ArrowRightIcon.astro +26 -0
- package/src/components/icons/ArrowUpDownIcon.astro +26 -0
- package/src/components/icons/ArrowUpIcon.astro +26 -0
- package/src/components/icons/BulletIcon.astro +21 -0
- package/src/components/icons/BurnIcon.astro +24 -0
- package/src/components/icons/CircleSymbolIcon.css +66 -0
- package/src/components/icons/ClearIcon.astro +28 -0
- package/src/components/icons/CloseIcon.astro +21 -0
- package/src/components/icons/CopyIcon.astro +30 -0
- package/src/components/icons/CurrencyIcon.css +9 -0
- package/src/components/icons/DayIcon.astro +33 -0
- package/src/components/icons/DollarIcon.astro +28 -0
- package/src/components/icons/DownloadIcon.astro +22 -0
- package/src/components/icons/EnterFullscreenIcon.astro +22 -0
- package/src/components/icons/EqualIcon.astro +25 -0
- package/src/components/icons/ExitFullscreenIcon.astro +22 -0
- package/src/components/icons/ExternalLinkIcon.astro +22 -0
- package/src/components/icons/FieldIcon.astro +28 -0
- package/src/components/icons/GrassIcon.astro +29 -0
- package/src/components/icons/InfoIcon.astro +24 -0
- package/src/components/icons/MinusIcon.astro +21 -0
- package/src/components/icons/MountainIcon.astro +31 -0
- package/src/components/icons/NightIcon.astro +32 -0
- package/src/components/icons/PlayIcon.astro +22 -0
- package/src/components/icons/PlusIcon.astro +21 -0
- package/src/components/icons/PoisonIcon.astro +24 -0
- package/src/components/icons/RibbonIcon.astro +25 -0
- package/src/components/icons/SlashIcon.astro +22 -0
- package/src/components/icons/SlowIcon.astro +25 -0
- package/src/components/icons/StarIcon.astro +28 -0
- package/src/components/icons/StunIcon.astro +22 -0
- package/src/components/icons/TableSortIcon.astro +34 -0
- package/src/components/icons/WaterIcon.astro +30 -0
- package/src/components/index.ts +83 -0
- package/src/components/media/CanvasFrame/CanvasFrame.astro +130 -0
- package/src/components/media/CanvasFrame/CanvasFrame.css +59 -0
- package/src/components/media/CanvasFrame/canvasFrameController.ts +104 -0
- package/src/components/media/EmbedFrame/EmbedFrame.astro +147 -0
- package/src/components/media/EmbedFrame/EmbedFrame.css +51 -0
- package/src/components/media/EmbedFrame/embedFrameController.ts +66 -0
- package/src/components/media/MediaFrame/MediaFrame.astro +34 -0
- package/src/components/media/MediaFrame/MediaFrame.css +66 -0
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.astro +55 -0
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.css +89 -0
- package/src/components/navigation/DesktopNavigation.astro +92 -0
- package/src/components/navigation/DesktopNavigation.css +99 -0
- package/src/components/navigation/Header.astro +73 -0
- package/src/components/navigation/Header.css +20 -0
- package/src/components/navigation/MobileNavigation.astro +124 -0
- package/src/components/navigation/MobileNavigation.css +177 -0
- package/src/components/navigation/NavigationBrand.astro +63 -0
- package/src/components/navigation/NavigationBrand.css +52 -0
- package/src/components/navigation/NavigationControl.css +166 -0
- package/src/components/navigation/NavigationItemContent.astro +24 -0
- package/src/components/navigation/NavigationLink.astro +121 -0
- package/src/components/navigation/NavigationLinks.astro +27 -0
- package/src/components/navigation/NavigationMenuList.astro +37 -0
- package/src/components/navigation/NavigationMenuList.css +6 -0
- package/src/components/navigation/SkipLink/SkipLink.astro +18 -0
- package/src/components/navigation/SkipLink/SkipLink.css +26 -0
- package/src/components/navigation/SubNavigation/SubNavigation.astro +124 -0
- package/src/components/navigation/SubNavigation/SubNavigation.css +211 -0
- package/src/components/navigation/mobileNavigationController.ts +122 -0
- package/src/components/navigation/navigationState.ts +35 -0
- package/src/components/navigation/navigationTypes.ts +18 -0
- package/src/components/seo/SeoHead.astro +194 -0
- package/src/components/widgetTypes.ts +3 -0
- package/src/composition/Grid/Grid.astro +82 -0
- package/src/composition/Grid/Grid.css +314 -0
- package/src/composition/GridItem/GridItem.astro +50 -0
- package/src/composition/GridItem/GridItem.css +95 -0
- package/src/composition/Inline/Inline.astro +48 -0
- package/src/composition/Inline/Inline.css +65 -0
- package/src/composition/Stack/Stack.astro +37 -0
- package/src/composition/Stack/Stack.css +31 -0
- package/src/composition/SurfaceGroup/SurfaceGroup.astro +44 -0
- package/src/composition/SurfaceGroup/SurfaceGroup.css +76 -0
- package/src/composition/SurfaceGroup/stickySurfaceGroupController.ts +89 -0
- package/src/composition/index.ts +6 -0
- package/src/config/index.ts +2 -0
- package/src/config/pageMeta.ts +55 -0
- package/src/config/siteConfig.ts +90 -0
- package/src/data/collectionValidation.ts +61 -0
- package/src/data/index.ts +1 -0
- package/src/display/contracts.ts +284 -0
- package/src/display/index.ts +1 -0
- package/src/index.ts +6 -0
- package/src/layouts/BaseLayout.astro +74 -0
- package/src/layouts/PageSurface.astro +15 -0
- package/src/layouts/PageSurface.css +24 -0
- package/src/layouts/index.ts +2 -0
- package/src/patterns/CircuitPuzzle/CircuitPuzzle.astro +93 -0
- package/src/patterns/CircuitPuzzle/CircuitPuzzle.css +118 -0
- package/src/patterns/CircuitPuzzle/circuitPuzzleController.ts +205 -0
- package/src/patterns/CircuitPuzzle/contracts.ts +42 -0
- package/src/patterns/Combobox/Combobox.astro +462 -0
- package/src/patterns/Combobox/Combobox.css +403 -0
- package/src/patterns/Combobox/comboboxController.ts +788 -0
- package/src/patterns/Combobox/contracts.ts +18 -0
- package/src/patterns/Dropdown/Dropdown.astro +127 -0
- package/src/patterns/Dropdown/Dropdown.css +100 -0
- package/src/patterns/Dropdown/dropdownController.ts +157 -0
- package/src/patterns/Fullscreen/FullscreenControl.astro +103 -0
- package/src/patterns/Fullscreen/FullscreenControl.css +49 -0
- package/src/patterns/Fullscreen/fullscreenController.ts +73 -0
- package/src/patterns/GlitchOverlay/GlitchOverlay.astro +50 -0
- package/src/patterns/GlitchOverlay/GlitchOverlay.css +234 -0
- package/src/patterns/GlitchOverlay/glitchOverlayController.ts +152 -0
- package/src/patterns/GuidedFlow/GuidedFlow.astro +60 -0
- package/src/patterns/GuidedFlow/GuidedFlow.css +82 -0
- package/src/patterns/GuidedFlow/contracts.ts +3 -0
- package/src/patterns/GuidedFlow/guidedFlowController.ts +49 -0
- package/src/patterns/MagneticFieldPuzzle/MagneticFieldPuzzle.astro +217 -0
- package/src/patterns/MagneticFieldPuzzle/MagneticFieldPuzzle.css +383 -0
- package/src/patterns/MagneticFieldPuzzle/contracts.ts +81 -0
- package/src/patterns/MagneticFieldPuzzle/magneticFieldPuzzleController.ts +802 -0
- package/src/patterns/MagneticFieldPuzzle/simulation.ts +244 -0
- package/src/patterns/MapViewport/MapViewport.astro +296 -0
- package/src/patterns/MapViewport/MapViewport.css +257 -0
- package/src/patterns/MapViewport/contracts.ts +79 -0
- package/src/patterns/MapViewport/geometry.ts +80 -0
- package/src/patterns/MapViewport/mapViewportController.ts +636 -0
- package/src/patterns/Modal/Modal.astro +64 -0
- package/src/patterns/Modal/Modal.css +87 -0
- package/src/patterns/Modal/ModalClose.astro +37 -0
- package/src/patterns/Modal/ModalOpen.astro +36 -0
- package/src/patterns/Modal/modalController.ts +118 -0
- package/src/patterns/PuzzleGrid/PuzzleGrid.astro +22 -0
- package/src/patterns/PuzzleGrid/PuzzleGrid.css +149 -0
- package/src/patterns/PuzzleGrid/contracts.ts +2 -0
- package/src/patterns/PuzzleGrid/selectionDismissal.ts +27 -0
- package/src/patterns/PuzzleGrid/state.ts +25 -0
- package/src/patterns/SpriteProjectilePreview/SpriteProjectilePreview.astro +65 -0
- package/src/patterns/SpriteProjectilePreview/SpriteProjectilePreview.css +35 -0
- package/src/patterns/SpriteProjectilePreview/contracts.ts +33 -0
- package/src/patterns/SpriteProjectilePreview/spriteProjectilePreviewController.ts +586 -0
- package/src/patterns/StageFlow/StageFlow.astro +57 -0
- package/src/patterns/StageFlow/StageFlow.css +54 -0
- package/src/patterns/StageFlow/StageFlowAlternative.astro +23 -0
- package/src/patterns/StageFlow/StageFlowArrow.astro +22 -0
- package/src/patterns/StageFlow/StageFlowConnector.astro +7 -0
- package/src/patterns/StageFlow/StageFlowConnector.css +4 -0
- package/src/patterns/StageFlow/StageFlowStage.astro +51 -0
- package/src/patterns/StageFlow/StageFlowStage.css +106 -0
- package/src/patterns/StageFlow/StageFlowStep.astro +24 -0
- package/src/patterns/StageFlow/StageFlowStep.css +19 -0
- package/src/patterns/StageFlow/StageFlowSymbol.css +28 -0
- package/src/patterns/Table/Table.astro +176 -0
- package/src/patterns/Table/Table.css +70 -0
- package/src/patterns/Table/TableBody.astro +185 -0
- package/src/patterns/Table/TableBody.css +262 -0
- package/src/patterns/Table/TableCell.astro +59 -0
- package/src/patterns/Table/TableCell.css +99 -0
- package/src/patterns/Table/TableCellValue.astro +86 -0
- package/src/patterns/Table/TableFooter.astro +32 -0
- package/src/patterns/Table/TableFooter.css +31 -0
- package/src/patterns/Table/TableHeader.astro +118 -0
- package/src/patterns/Table/TableHeader.css +209 -0
- package/src/patterns/Table/TablePagination.astro +70 -0
- package/src/patterns/Table/TablePagination.css +133 -0
- package/src/patterns/Table/TableSkeleton.astro +36 -0
- package/src/patterns/Table/TableSkeleton.css +81 -0
- package/src/patterns/Table/tableCellController.ts +11 -0
- package/src/patterns/Table/tableFilterController.ts +206 -0
- package/src/patterns/Table/tableHeaderOverflowController.ts +105 -0
- package/src/patterns/Table/tableLayout.ts +113 -0
- package/src/patterns/Table/tableProgressiveController.ts +319 -0
- package/src/patterns/Table/tableRowNavigationController.ts +91 -0
- package/src/patterns/Table/tableScrollController.ts +192 -0
- package/src/patterns/Table/tableSortController.ts +272 -0
- package/src/patterns/index.ts +46 -0
- package/src/primitives/index.ts +4 -0
- package/src/primitives/layout/Separator/Separator.astro +29 -0
- package/src/primitives/layout/Separator/Separator.css +20 -0
- package/src/primitives/media/AmbientAudio/AmbientAudio.astro +28 -0
- package/src/primitives/media/Media/Media.astro +122 -0
- package/src/primitives/media/Media/Media.css +161 -0
- package/src/primitives/text/TextBlock/TextBlock.astro +46 -0
- package/src/primitives/text/TextBlock/TextBlock.css +21 -0
- package/src/seo/StaticRedirect.astro +32 -0
- package/src/seo/index.ts +6 -0
- package/src/seo/pageSeo.ts +99 -0
- package/src/seo/robots.ts +16 -0
- package/src/seo/sitemap.ts +38 -0
- package/src/seo/structuredData.ts +133 -0
- package/src/seo/url.ts +64 -0
- package/src/styles/base.css +148 -0
- package/src/styles/interaction.css +108 -0
- package/src/styles/style.css +93 -0
- package/src/styles/tokens.css +256 -0
- package/src/theme/contracts.ts +7 -0
- package/src/theme/index.ts +1 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
const initializedAttribute = 'data-tooltip-initialized';
|
|
2
|
+
const generatedIdAttribute = 'data-tooltip-generated-id';
|
|
3
|
+
const hideDelayMs = 80;
|
|
4
|
+
const noop = (): void => undefined;
|
|
5
|
+
|
|
6
|
+
let nextTooltipId = 0;
|
|
7
|
+
|
|
8
|
+
function getTrigger(root: HTMLElement): HTMLElement | null {
|
|
9
|
+
if (root.dataset.tooltipTriggerScope === 'ancestor') {
|
|
10
|
+
return (
|
|
11
|
+
root.parentElement?.closest<HTMLElement>('[data-tooltip-trigger]') ?? null
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const explicitTrigger = root.querySelector<HTMLElement>(
|
|
16
|
+
':scope > [data-tooltip-trigger]',
|
|
17
|
+
);
|
|
18
|
+
if (explicitTrigger) return explicitTrigger;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
Array.from(root.children).find(
|
|
22
|
+
(child): child is HTMLElement =>
|
|
23
|
+
child instanceof HTMLElement && !child.matches('[data-tooltip-panel]'),
|
|
24
|
+
) ?? null
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isNaturallyFocusable(element: HTMLElement): boolean {
|
|
29
|
+
return element.matches(
|
|
30
|
+
'a[href], button, input, select, textarea, summary, [contenteditable="true"]',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getCssLength(
|
|
35
|
+
element: HTMLElement,
|
|
36
|
+
property: string,
|
|
37
|
+
fallback: number,
|
|
38
|
+
): number {
|
|
39
|
+
const value = Number.parseFloat(
|
|
40
|
+
window.getComputedStyle(element).getPropertyValue(property),
|
|
41
|
+
);
|
|
42
|
+
return Number.isFinite(value) ? value : fallback;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getViewportBounds() {
|
|
46
|
+
const viewport = window.visualViewport;
|
|
47
|
+
const left = viewport?.offsetLeft ?? 0;
|
|
48
|
+
const top = viewport?.offsetTop ?? 0;
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
left,
|
|
52
|
+
top,
|
|
53
|
+
right: left + (viewport?.width ?? document.documentElement.clientWidth),
|
|
54
|
+
bottom: top + (viewport?.height ?? document.documentElement.clientHeight),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function appendDescriptionId(
|
|
59
|
+
currentValue: string | null,
|
|
60
|
+
panelId: string,
|
|
61
|
+
): string {
|
|
62
|
+
return [...new Set([...(currentValue?.split(/\s+/) ?? []), panelId])]
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.join(' ');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function initTooltip(root: HTMLElement): () => void {
|
|
68
|
+
if (root.getAttribute(initializedAttribute) === 'true') return noop;
|
|
69
|
+
|
|
70
|
+
const trigger = getTrigger(root);
|
|
71
|
+
const panel = root.querySelector<HTMLElement>(
|
|
72
|
+
':scope > [data-tooltip-panel]',
|
|
73
|
+
);
|
|
74
|
+
if (!trigger || !panel) return noop;
|
|
75
|
+
|
|
76
|
+
const hoverOnly = root.dataset.tooltipActivation === 'hover';
|
|
77
|
+
root.setAttribute(initializedAttribute, 'true');
|
|
78
|
+
const hadTriggerAttribute = trigger.hasAttribute('data-tooltip-trigger');
|
|
79
|
+
trigger.setAttribute('data-tooltip-trigger', '');
|
|
80
|
+
|
|
81
|
+
const previousTabIndex = trigger.getAttribute('tabindex');
|
|
82
|
+
const previousDescription = trigger.getAttribute('aria-describedby');
|
|
83
|
+
const previousPanelId = panel.id;
|
|
84
|
+
|
|
85
|
+
if (
|
|
86
|
+
!hoverOnly &&
|
|
87
|
+
!isNaturallyFocusable(trigger) &&
|
|
88
|
+
previousTabIndex === null
|
|
89
|
+
) {
|
|
90
|
+
trigger.tabIndex = 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!panel.id) {
|
|
94
|
+
nextTooltipId += 1;
|
|
95
|
+
panel.id = `nox-tooltip-${nextTooltipId}`;
|
|
96
|
+
panel.setAttribute(generatedIdAttribute, 'true');
|
|
97
|
+
}
|
|
98
|
+
trigger.setAttribute(
|
|
99
|
+
'aria-describedby',
|
|
100
|
+
appendDescriptionId(previousDescription, panel.id),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
let closeTimer: number | undefined;
|
|
104
|
+
let positionFrame: number | undefined;
|
|
105
|
+
let hoveredTrigger = false;
|
|
106
|
+
let hoveredPanel = false;
|
|
107
|
+
let openListenersActive = false;
|
|
108
|
+
let pinned = false;
|
|
109
|
+
|
|
110
|
+
const isOpen = (): boolean => panel.matches(':popover-open');
|
|
111
|
+
|
|
112
|
+
const cancelScheduledClose = (): void => {
|
|
113
|
+
if (closeTimer === undefined) return;
|
|
114
|
+
window.clearTimeout(closeTimer);
|
|
115
|
+
closeTimer = undefined;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const position = (): void => {
|
|
119
|
+
if (!isOpen()) return;
|
|
120
|
+
|
|
121
|
+
const viewport = getViewportBounds();
|
|
122
|
+
const viewportGap = getCssLength(panel, '--tooltip-viewport-gap', 8);
|
|
123
|
+
const triggerGap = getCssLength(panel, '--tooltip-trigger-gap', 8);
|
|
124
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
125
|
+
const boundary =
|
|
126
|
+
root.dataset.tooltipAlignTo === 'boundary'
|
|
127
|
+
? root.closest<HTMLElement>('[data-tooltip-boundary]')
|
|
128
|
+
: null;
|
|
129
|
+
const boundaryRect = boundary?.getBoundingClientRect();
|
|
130
|
+
const horizontalLeft = Math.max(
|
|
131
|
+
viewport.left + viewportGap,
|
|
132
|
+
boundaryRect?.left ?? viewport.left + viewportGap,
|
|
133
|
+
);
|
|
134
|
+
const horizontalRight = Math.min(
|
|
135
|
+
viewport.right - viewportGap,
|
|
136
|
+
boundaryRect?.right ?? viewport.right - viewportGap,
|
|
137
|
+
);
|
|
138
|
+
const maximumInlineSize = Math.max(
|
|
139
|
+
0,
|
|
140
|
+
horizontalRight - horizontalLeft,
|
|
141
|
+
);
|
|
142
|
+
const maximumBlockSize = Math.max(
|
|
143
|
+
0,
|
|
144
|
+
viewport.bottom - viewport.top - viewportGap * 2,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
panel.style.maxInlineSize = `${Math.floor(maximumInlineSize)}px`;
|
|
148
|
+
panel.style.maxBlockSize = `${Math.floor(maximumBlockSize)}px`;
|
|
149
|
+
panel.style.visibility = 'hidden';
|
|
150
|
+
panel.style.left = `${Math.round(horizontalLeft)}px`;
|
|
151
|
+
panel.style.top = `${Math.round(viewport.top + viewportGap)}px`;
|
|
152
|
+
|
|
153
|
+
const measuredPanel = panel.getBoundingClientRect();
|
|
154
|
+
const availableAbove =
|
|
155
|
+
triggerRect.top - viewport.top - viewportGap - triggerGap;
|
|
156
|
+
const availableBelow =
|
|
157
|
+
viewport.bottom - triggerRect.bottom - viewportGap - triggerGap;
|
|
158
|
+
const placement =
|
|
159
|
+
measuredPanel.height <= availableAbove || availableAbove >= availableBelow
|
|
160
|
+
? 'top'
|
|
161
|
+
: 'bottom';
|
|
162
|
+
const availableBlockSize = Math.max(
|
|
163
|
+
0,
|
|
164
|
+
placement === 'top' ? availableAbove : availableBelow,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
panel.style.maxBlockSize = `${Math.floor(availableBlockSize)}px`;
|
|
168
|
+
const panelRect = panel.getBoundingClientRect();
|
|
169
|
+
const horizontalAnchor = boundaryRect ?? triggerRect;
|
|
170
|
+
const centeredLeft =
|
|
171
|
+
horizontalAnchor.left + (horizontalAnchor.width - panelRect.width) / 2;
|
|
172
|
+
const left = Math.min(
|
|
173
|
+
horizontalRight - panelRect.width,
|
|
174
|
+
Math.max(horizontalLeft, centeredLeft),
|
|
175
|
+
);
|
|
176
|
+
const top =
|
|
177
|
+
placement === 'top'
|
|
178
|
+
? triggerRect.top - triggerGap - panelRect.height
|
|
179
|
+
: triggerRect.bottom + triggerGap;
|
|
180
|
+
|
|
181
|
+
panel.style.left = `${Math.round(left)}px`;
|
|
182
|
+
panel.style.top = `${Math.round(top)}px`;
|
|
183
|
+
panel.style.removeProperty('visibility');
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const requestPosition = (): void => {
|
|
187
|
+
if (!isOpen() || positionFrame !== undefined) return;
|
|
188
|
+
positionFrame = window.requestAnimationFrame(() => {
|
|
189
|
+
positionFrame = undefined;
|
|
190
|
+
position();
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const hide = (): void => {
|
|
195
|
+
cancelScheduledClose();
|
|
196
|
+
removeOpenListeners();
|
|
197
|
+
if (!isOpen()) return;
|
|
198
|
+
|
|
199
|
+
panel.hidePopover();
|
|
200
|
+
panel.hidden = true;
|
|
201
|
+
panel.style.removeProperty('left');
|
|
202
|
+
panel.style.removeProperty('top');
|
|
203
|
+
panel.style.removeProperty('max-inline-size');
|
|
204
|
+
panel.style.removeProperty('max-block-size');
|
|
205
|
+
panel.style.removeProperty('visibility');
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const close = (): void => {
|
|
209
|
+
pinned = false;
|
|
210
|
+
hide();
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const show = (): void => {
|
|
214
|
+
cancelScheduledClose();
|
|
215
|
+
if (isOpen()) {
|
|
216
|
+
requestPosition();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
document.dispatchEvent(
|
|
221
|
+
new CustomEvent('tooltip:open', { detail: { root } }),
|
|
222
|
+
);
|
|
223
|
+
panel.hidden = false;
|
|
224
|
+
panel.showPopover();
|
|
225
|
+
position();
|
|
226
|
+
addOpenListeners();
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const scheduleClose = (): void => {
|
|
230
|
+
cancelScheduledClose();
|
|
231
|
+
closeTimer = window.setTimeout(() => {
|
|
232
|
+
closeTimer = undefined;
|
|
233
|
+
if (
|
|
234
|
+
!pinned &&
|
|
235
|
+
!hoveredTrigger &&
|
|
236
|
+
!hoveredPanel &&
|
|
237
|
+
!trigger.matches(':focus-within')
|
|
238
|
+
) {
|
|
239
|
+
hide();
|
|
240
|
+
}
|
|
241
|
+
}, hideDelayMs);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const handleTriggerPointerEnter = (event: PointerEvent): void => {
|
|
245
|
+
if (hoverOnly && event.pointerType === 'touch') return;
|
|
246
|
+
hoveredTrigger = true;
|
|
247
|
+
show();
|
|
248
|
+
};
|
|
249
|
+
const handleTriggerPointerLeave = (event: PointerEvent): void => {
|
|
250
|
+
if (hoverOnly && event.pointerType === 'touch') return;
|
|
251
|
+
hoveredTrigger = false;
|
|
252
|
+
|
|
253
|
+
if (hoverOnly) {
|
|
254
|
+
if (!trigger.matches(':focus-within')) hide();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
scheduleClose();
|
|
259
|
+
};
|
|
260
|
+
const handlePanelPointerEnter = (): void => {
|
|
261
|
+
hoveredPanel = true;
|
|
262
|
+
cancelScheduledClose();
|
|
263
|
+
};
|
|
264
|
+
const handlePanelPointerLeave = (): void => {
|
|
265
|
+
hoveredPanel = false;
|
|
266
|
+
scheduleClose();
|
|
267
|
+
};
|
|
268
|
+
const handleFocusIn = (): void => {
|
|
269
|
+
if (
|
|
270
|
+
hoverOnly &&
|
|
271
|
+
!trigger.matches(':focus-visible') &&
|
|
272
|
+
!trigger.querySelector(':focus-visible')
|
|
273
|
+
) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
show();
|
|
278
|
+
};
|
|
279
|
+
const handleFocusOut = (): void => scheduleClose();
|
|
280
|
+
const handleTriggerClick = (): void => {
|
|
281
|
+
if (pinned) {
|
|
282
|
+
close();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
pinned = true;
|
|
287
|
+
show();
|
|
288
|
+
};
|
|
289
|
+
const handleDocumentPointerDown = (event: PointerEvent): void => {
|
|
290
|
+
if (
|
|
291
|
+
event.target instanceof Node &&
|
|
292
|
+
(root.contains(event.target) || trigger.contains(event.target))
|
|
293
|
+
) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
close();
|
|
297
|
+
};
|
|
298
|
+
const handleDocumentKeyDown = (event: KeyboardEvent): void => {
|
|
299
|
+
if (event.key === 'Escape' && isOpen()) close();
|
|
300
|
+
};
|
|
301
|
+
const handleOtherTooltipOpen = (event: Event): void => {
|
|
302
|
+
if (!(event instanceof CustomEvent) || event.detail?.root === root) return;
|
|
303
|
+
close();
|
|
304
|
+
};
|
|
305
|
+
function addOpenListeners(): void {
|
|
306
|
+
if (openListenersActive) return;
|
|
307
|
+
openListenersActive = true;
|
|
308
|
+
document.addEventListener('pointerdown', handleDocumentPointerDown);
|
|
309
|
+
document.addEventListener('keydown', handleDocumentKeyDown);
|
|
310
|
+
document.addEventListener('tooltip:open', handleOtherTooltipOpen);
|
|
311
|
+
window.addEventListener('resize', requestPosition);
|
|
312
|
+
window.addEventListener('scroll', requestPosition, true);
|
|
313
|
+
window.visualViewport?.addEventListener('resize', requestPosition);
|
|
314
|
+
window.visualViewport?.addEventListener('scroll', requestPosition);
|
|
315
|
+
}
|
|
316
|
+
function removeOpenListeners(): void {
|
|
317
|
+
if (!openListenersActive) return;
|
|
318
|
+
openListenersActive = false;
|
|
319
|
+
document.removeEventListener('pointerdown', handleDocumentPointerDown);
|
|
320
|
+
document.removeEventListener('keydown', handleDocumentKeyDown);
|
|
321
|
+
document.removeEventListener('tooltip:open', handleOtherTooltipOpen);
|
|
322
|
+
window.removeEventListener('resize', requestPosition);
|
|
323
|
+
window.removeEventListener('scroll', requestPosition, true);
|
|
324
|
+
window.visualViewport?.removeEventListener('resize', requestPosition);
|
|
325
|
+
window.visualViewport?.removeEventListener('scroll', requestPosition);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
trigger.addEventListener('pointerenter', handleTriggerPointerEnter);
|
|
329
|
+
trigger.addEventListener('pointerleave', handleTriggerPointerLeave);
|
|
330
|
+
trigger.addEventListener('focusin', handleFocusIn);
|
|
331
|
+
trigger.addEventListener('focusout', handleFocusOut);
|
|
332
|
+
if (!hoverOnly) trigger.addEventListener('click', handleTriggerClick);
|
|
333
|
+
if (!hoverOnly) {
|
|
334
|
+
panel.addEventListener('pointerenter', handlePanelPointerEnter);
|
|
335
|
+
panel.addEventListener('pointerleave', handlePanelPointerLeave);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return () => {
|
|
339
|
+
close();
|
|
340
|
+
cancelScheduledClose();
|
|
341
|
+
if (positionFrame !== undefined) {
|
|
342
|
+
window.cancelAnimationFrame(positionFrame);
|
|
343
|
+
}
|
|
344
|
+
trigger.removeEventListener('pointerenter', handleTriggerPointerEnter);
|
|
345
|
+
trigger.removeEventListener('pointerleave', handleTriggerPointerLeave);
|
|
346
|
+
trigger.removeEventListener('focusin', handleFocusIn);
|
|
347
|
+
trigger.removeEventListener('focusout', handleFocusOut);
|
|
348
|
+
if (!hoverOnly) trigger.removeEventListener('click', handleTriggerClick);
|
|
349
|
+
if (!hoverOnly) {
|
|
350
|
+
panel.removeEventListener('pointerenter', handlePanelPointerEnter);
|
|
351
|
+
panel.removeEventListener('pointerleave', handlePanelPointerLeave);
|
|
352
|
+
}
|
|
353
|
+
removeOpenListeners();
|
|
354
|
+
|
|
355
|
+
if (previousTabIndex === null) trigger.removeAttribute('tabindex');
|
|
356
|
+
else trigger.setAttribute('tabindex', previousTabIndex);
|
|
357
|
+
|
|
358
|
+
if (previousDescription === null) {
|
|
359
|
+
trigger.removeAttribute('aria-describedby');
|
|
360
|
+
} else {
|
|
361
|
+
trigger.setAttribute('aria-describedby', previousDescription);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (!hadTriggerAttribute) trigger.removeAttribute('data-tooltip-trigger');
|
|
365
|
+
if (panel.hasAttribute(generatedIdAttribute)) {
|
|
366
|
+
panel.removeAttribute(generatedIdAttribute);
|
|
367
|
+
panel.id = previousPanelId;
|
|
368
|
+
}
|
|
369
|
+
root.removeAttribute(initializedAttribute);
|
|
370
|
+
};
|
|
371
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
import type { Tone } from '../../../theme/contracts';
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<'p'> & {
|
|
6
|
+
text?: string;
|
|
7
|
+
tone?: Tone;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
class: className,
|
|
12
|
+
'data-tone': dataTone,
|
|
13
|
+
hidden,
|
|
14
|
+
text = '',
|
|
15
|
+
tone = 'danger',
|
|
16
|
+
...attrs
|
|
17
|
+
}: Props = Astro.props;
|
|
18
|
+
const resolvedTone = dataTone ?? tone;
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<p
|
|
22
|
+
{...attrs}
|
|
23
|
+
class:list={['field-error', className]}
|
|
24
|
+
data-tone={resolvedTone}
|
|
25
|
+
data-widget="field-error"
|
|
26
|
+
role="status"
|
|
27
|
+
aria-live="polite"
|
|
28
|
+
hidden={hidden ?? text.length === 0}
|
|
29
|
+
>
|
|
30
|
+
{text}
|
|
31
|
+
</p>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function setFieldError(
|
|
2
|
+
control: HTMLElement,
|
|
3
|
+
error: HTMLElement,
|
|
4
|
+
message: string,
|
|
5
|
+
): void {
|
|
6
|
+
const invalid = message.length > 0;
|
|
7
|
+
|
|
8
|
+
control.toggleAttribute('data-invalid', invalid);
|
|
9
|
+
if (invalid) control.setAttribute('aria-invalid', 'true');
|
|
10
|
+
else control.removeAttribute('aria-invalid');
|
|
11
|
+
|
|
12
|
+
error.textContent = message;
|
|
13
|
+
error.hidden = !invalid;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function clearFieldError(
|
|
17
|
+
control: HTMLElement,
|
|
18
|
+
error: HTMLElement,
|
|
19
|
+
): void {
|
|
20
|
+
setFieldError(control, error, '');
|
|
21
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
import type { Tone } from '../../../theme/contracts';
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<'label'> & {
|
|
6
|
+
for: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
tone?: Tone;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
class: className,
|
|
13
|
+
'data-tone': dataTone,
|
|
14
|
+
disabled = false,
|
|
15
|
+
for: htmlFor,
|
|
16
|
+
tone,
|
|
17
|
+
...attrs
|
|
18
|
+
}: Props = Astro.props;
|
|
19
|
+
const resolvedTone = tone ?? dataTone;
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
<label
|
|
23
|
+
{...attrs}
|
|
24
|
+
class:list={['field-label', className]}
|
|
25
|
+
for={htmlFor}
|
|
26
|
+
data-widget="field-label"
|
|
27
|
+
data-disabled={disabled ? true : undefined}
|
|
28
|
+
data-tone={resolvedTone}
|
|
29
|
+
aria-disabled={disabled ? 'true' : undefined}
|
|
30
|
+
>
|
|
31
|
+
<slot />
|
|
32
|
+
</label>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.field-label {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
min-width: 0;
|
|
4
|
+
align-items: center;
|
|
5
|
+
color: var(--nox-tone-text);
|
|
6
|
+
font-size: var(--nox-font-size-sm);
|
|
7
|
+
font-weight: var(--nox-font-weight-strong);
|
|
8
|
+
letter-spacing: var(--nox-letter-spacing-wide);
|
|
9
|
+
line-height: 1.25;
|
|
10
|
+
overflow-wrap: anywhere;
|
|
11
|
+
text-transform: uppercase;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.field-label[data-disabled] {
|
|
15
|
+
color: var(--nox-text-disabled);
|
|
16
|
+
cursor: not-allowed;
|
|
17
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
+
import type { Tone } from '../../../theme/contracts';
|
|
4
|
+
import CloseIcon from '../../icons/CloseIcon.astro';
|
|
5
|
+
|
|
6
|
+
type TextInputFraming = 'embedded' | 'standalone';
|
|
7
|
+
type TextInputType = 'search' | 'text';
|
|
8
|
+
type TextInputAutofocus = boolean | 'desktop';
|
|
9
|
+
|
|
10
|
+
type Props = Omit<HTMLAttributes<'input'>, 'autofocus' | 'type'> & {
|
|
11
|
+
autofocus?: TextInputAutofocus;
|
|
12
|
+
clearable?: boolean;
|
|
13
|
+
clearLabel?: string;
|
|
14
|
+
framing?: TextInputFraming;
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
tone?: Tone;
|
|
17
|
+
type?: TextInputType;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
'aria-invalid': ariaInvalid,
|
|
22
|
+
autofocus = false,
|
|
23
|
+
class: className,
|
|
24
|
+
clearable: requestedClearable,
|
|
25
|
+
clearLabel = 'Effacer le champ',
|
|
26
|
+
'data-tone': dataTone,
|
|
27
|
+
framing = 'standalone',
|
|
28
|
+
invalid = false,
|
|
29
|
+
tone,
|
|
30
|
+
type = 'text',
|
|
31
|
+
...attrs
|
|
32
|
+
}: Props = Astro.props;
|
|
33
|
+
const clearable = requestedClearable ?? type === 'search';
|
|
34
|
+
const resolvedInvalid =
|
|
35
|
+
invalid || ariaInvalid === true || ariaInvalid === 'true';
|
|
36
|
+
const resolvedTone = tone ?? dataTone;
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
<span
|
|
40
|
+
class="text-input-field"
|
|
41
|
+
data-clearable={clearable ? true : undefined}
|
|
42
|
+
data-framing={framing}
|
|
43
|
+
data-tone={resolvedTone}
|
|
44
|
+
data-text-input-autofocus={autofocus === 'desktop' ? 'desktop' : undefined}
|
|
45
|
+
data-text-input-field
|
|
46
|
+
>
|
|
47
|
+
<input
|
|
48
|
+
{...attrs}
|
|
49
|
+
class:list={['text-input', className]}
|
|
50
|
+
type={type}
|
|
51
|
+
autofocus={autofocus === true}
|
|
52
|
+
data-widget="text-input"
|
|
53
|
+
data-framing={framing}
|
|
54
|
+
data-invalid={resolvedInvalid ? true : undefined}
|
|
55
|
+
aria-invalid={resolvedInvalid ? 'true' : ariaInvalid}
|
|
56
|
+
data-text-input-control
|
|
57
|
+
/>
|
|
58
|
+
{
|
|
59
|
+
clearable ? (
|
|
60
|
+
<button
|
|
61
|
+
class="text-input__clear"
|
|
62
|
+
type="button"
|
|
63
|
+
aria-label={clearLabel}
|
|
64
|
+
data-text-input-clear
|
|
65
|
+
hidden
|
|
66
|
+
>
|
|
67
|
+
<CloseIcon />
|
|
68
|
+
</button>
|
|
69
|
+
) : null
|
|
70
|
+
}
|
|
71
|
+
</span>
|
|
72
|
+
|
|
73
|
+
<script>
|
|
74
|
+
import { initTextInput } from './textInputController';
|
|
75
|
+
|
|
76
|
+
for (const root of document.querySelectorAll('[data-text-input-field]')) {
|
|
77
|
+
if (root instanceof HTMLElement) initTextInput(root);
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
.text-input-field {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: grid;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
color: var(--nox-field-color);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.text-input {
|
|
9
|
+
display: block;
|
|
10
|
+
width: 100%;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
min-height: var(--nox-field-control-block-size);
|
|
13
|
+
padding: 0 var(--nox-field-control-padding-inline);
|
|
14
|
+
border: var(--nox-border-width) solid var(--nox-field-border);
|
|
15
|
+
border-radius: var(--nox-radius-sm);
|
|
16
|
+
outline: 0;
|
|
17
|
+
background: var(--nox-field-background);
|
|
18
|
+
color: var(--nox-field-color);
|
|
19
|
+
font-family: inherit;
|
|
20
|
+
font-size: var(--nox-field-control-font-size);
|
|
21
|
+
font-weight: var(--nox-font-weight-regular);
|
|
22
|
+
letter-spacing: 0;
|
|
23
|
+
line-height: 1.35;
|
|
24
|
+
text-align: start;
|
|
25
|
+
transition:
|
|
26
|
+
border-color var(--nox-motion-duration-sm) var(--nox-motion-easing-standard),
|
|
27
|
+
box-shadow var(--nox-motion-duration-sm) var(--nox-motion-easing-standard);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.text-input-field[data-clearable] .text-input {
|
|
31
|
+
padding-inline-end: calc(var(--nox-field-control-padding-inline) + 1.25rem);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.text-input[type='search'] {
|
|
35
|
+
appearance: textfield;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.text-input[type='search']::-webkit-search-cancel-button {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.text-input::placeholder {
|
|
43
|
+
color: var(--nox-field-placeholder);
|
|
44
|
+
opacity: 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.text-input[data-framing='embedded'] {
|
|
48
|
+
border: 0;
|
|
49
|
+
border-radius: 0;
|
|
50
|
+
background: transparent;
|
|
51
|
+
box-shadow: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.text-input-field:focus-within .text-input,
|
|
55
|
+
.text-input:focus {
|
|
56
|
+
border-color: var(--nox-field-border-active);
|
|
57
|
+
box-shadow: var(--nox-field-focus-shadow);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.text-input-field[data-framing='embedded']:focus-within .text-input,
|
|
61
|
+
.text-input[data-framing='embedded']:focus {
|
|
62
|
+
box-shadow: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.text-input[data-invalid] {
|
|
66
|
+
border-color: var(--nox-field-border-invalid);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.text-input:disabled {
|
|
70
|
+
background: var(--nox-field-background-disabled);
|
|
71
|
+
color: var(--nox-text-disabled);
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.text-input:disabled::placeholder {
|
|
76
|
+
color: var(--nox-text-disabled);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.text-input__clear {
|
|
80
|
+
position: absolute;
|
|
81
|
+
inset-block: 0;
|
|
82
|
+
inset-inline-end: var(--nox-space-2);
|
|
83
|
+
display: grid;
|
|
84
|
+
inline-size: 1.5rem;
|
|
85
|
+
padding: 0;
|
|
86
|
+
place-items: center;
|
|
87
|
+
border: 0;
|
|
88
|
+
background: transparent;
|
|
89
|
+
color: var(--nox-tone-color);
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.text-input__clear[hidden] {
|
|
94
|
+
display: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.text-input__clear svg {
|
|
98
|
+
inline-size: 0.875rem;
|
|
99
|
+
block-size: 0.875rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.text-input__clear:focus-visible {
|
|
103
|
+
outline: 0;
|
|
104
|
+
color: var(--nox-tone-text);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (hover: hover) and (pointer: fine) {
|
|
108
|
+
.text-input:not(:disabled):not(:focus):not([data-invalid]):hover {
|
|
109
|
+
border-color: var(--nox-field-border-hover);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.text-input__clear:hover {
|
|
113
|
+
color: var(--nox-tone-text);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@media (width < 48rem), (hover: none) and (pointer: coarse) {
|
|
118
|
+
.text-input {
|
|
119
|
+
font-size: var(--nox-font-size-md);
|
|
120
|
+
}
|
|
121
|
+
}
|