@astryxdesign/core 0.4.0 → 0.4.1-canary.1ce0b4c
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 +39 -0
- package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
- package/dist/AspectRatio/AspectRatio.js +1 -2
- package/dist/AspectRatio/index.d.ts.map +1 -1
- package/dist/AspectRatio/index.js +1 -2
- package/dist/Badge/Badge.d.ts.map +1 -1
- package/dist/Badge/Badge.js +1 -2
- package/dist/Badge/index.d.ts.map +1 -1
- package/dist/Badge/index.js +1 -2
- package/dist/Banner/Banner.d.ts +3 -0
- package/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +17 -3
- package/dist/Blockquote/Blockquote.d.ts.map +1 -1
- package/dist/Blockquote/Blockquote.js +1 -2
- package/dist/Blockquote/index.d.ts.map +1 -1
- package/dist/Blockquote/index.js +1 -2
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +11 -9
- package/dist/Card/Card.d.ts.map +1 -1
- package/dist/Card/Card.js +1 -2
- package/dist/Card/index.d.ts.map +1 -1
- package/dist/Card/index.js +1 -2
- package/dist/Center/Center.d.ts.map +1 -1
- package/dist/Center/Center.js +1 -2
- package/dist/Center/index.d.ts.map +1 -1
- package/dist/Center/index.js +1 -2
- package/dist/Code/Code.d.ts.map +1 -1
- package/dist/Code/Code.js +1 -2
- package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPalette.js +5 -0
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +7 -8
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +23 -10
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +44 -16
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +32 -13
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioGroup.js +10 -3
- package/dist/Field/PanelSearchInput.d.ts +81 -0
- package/dist/Field/PanelSearchInput.d.ts.map +1 -0
- package/dist/Field/PanelSearchInput.js +151 -0
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +21 -10
- package/dist/Grid/Grid.d.ts.map +1 -1
- package/dist/Grid/Grid.js +1 -2
- package/dist/Grid/index.d.ts.map +1 -1
- package/dist/Grid/index.js +1 -2
- package/dist/HoverCard/HoverCard.d.ts +1 -1
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/HoverCard.js +5 -13
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +6 -5
- package/dist/Icon/globalIconRegistry.d.ts +5 -4
- package/dist/Icon/globalIconRegistry.d.ts.map +1 -1
- package/dist/Icon/globalIconRegistry.js +5 -4
- package/dist/Indicator/index.d.ts +1 -1
- package/dist/Indicator/index.d.ts.map +1 -1
- package/dist/Indicator/types.d.ts +10 -0
- package/dist/Indicator/types.d.ts.map +1 -1
- package/dist/InputGroup/groupStyles.d.ts.map +1 -1
- package/dist/InputGroup/groupStyles.js +7 -2
- package/dist/Layer/layerHost.d.ts +24 -0
- package/dist/Layer/layerHost.d.ts.map +1 -0
- package/dist/Layer/layerHost.js +79 -0
- package/dist/Layer/useLayer.d.ts +14 -6
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +155 -29
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +24 -50
- package/dist/MultiSelector/MultiSelector.d.ts +8 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +134 -102
- package/dist/NavItem/navItemStyles.stylex.d.ts +17 -5
- package/dist/NavItem/navItemStyles.stylex.d.ts.map +1 -1
- package/dist/NavItem/navItemStyles.stylex.js +11 -5
- package/dist/Popover/usePopover.d.ts +15 -0
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +14 -2
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +2 -3
- package/dist/Section/Section.d.ts.map +1 -1
- package/dist/Section/Section.js +1 -2
- package/dist/Section/index.d.ts.map +1 -1
- package/dist/Section/index.js +1 -2
- package/dist/Selector/Selector.d.ts +10 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +135 -95
- package/dist/SideNav/SideNav.d.ts +7 -9
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +32 -5
- package/dist/SideNav/SideNavCollapseButton.d.ts +25 -9
- package/dist/SideNav/SideNavCollapseButton.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseButton.js +39 -15
- package/dist/SideNav/SideNavCollapseContext.d.ts +21 -0
- package/dist/SideNav/SideNavCollapseContext.d.ts.map +1 -1
- package/dist/SideNav/SideNavCollapseContext.js +16 -2
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +70 -24
- package/dist/SideNav/SideNavItem.d.ts +7 -2
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +114 -75
- package/dist/SideNav/SideNavSection.d.ts.map +1 -1
- package/dist/SideNav/SideNavSection.js +7 -16
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.d.ts.map +1 -1
- package/dist/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/Skeleton/Skeleton.js +1 -2
- package/dist/Skeleton/index.d.ts.map +1 -1
- package/dist/Skeleton/index.js +1 -2
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +2 -6
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +3 -3
- package/dist/Table/TableRow.d.ts +1 -1
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js +4 -2
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +7 -2
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +14 -3
- package/dist/Timestamp/formatInstant.d.ts +11 -1
- package/dist/Timestamp/formatInstant.d.ts.map +1 -1
- package/dist/Timestamp/formatInstant.js +3 -1
- package/dist/TopNav/TopNavMegaMenu.js +1 -1
- package/dist/TopNav/TopNavMegaMenuItem.js +1 -1
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +2 -2
- package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.js +1 -2
- package/dist/VisuallyHidden/index.d.ts.map +1 -1
- package/dist/VisuallyHidden/index.js +1 -2
- package/dist/astryx.css +23 -24
- package/dist/astryx.umd.js +48 -48
- package/dist/astryx.umd.js.map +4 -4
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +16 -2
- package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
- package/dist/hooks/useInputStatusIcon.js +17 -4
- package/dist/theme/defineTheme.d.ts +2 -2
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +2 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/tokens.stylex.d.ts +12 -0
- package/dist/theme/tokens.stylex.d.ts.map +1 -1
- package/dist/theme/tokens.stylex.js +23 -0
- package/dist/utils/focusOutline.stylex.d.ts +34 -19
- package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
- package/dist/utils/focusOutline.stylex.js +46 -33
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/interactionModality.d.ts +34 -0
- package/dist/utils/interactionModality.d.ts.map +1 -0
- package/dist/utils/interactionModality.js +70 -0
- package/locales/en.json +44 -0
- package/locales/pseudo.json +33 -0
- package/package.json +3 -3
- package/src/AppShell/AppShell.doc.mjs +3 -0
- package/src/AspectRatio/AspectRatio.tsx +0 -2
- package/src/AspectRatio/index.ts +0 -2
- package/src/Badge/Badge.tsx +0 -2
- package/src/Badge/index.ts +0 -2
- package/src/Banner/Banner.test.tsx +58 -1
- package/src/Banner/Banner.tsx +24 -5
- package/src/Blockquote/Blockquote.tsx +0 -2
- package/src/Blockquote/index.ts +0 -2
- package/src/Button/Button.doc.mjs +2 -2
- package/src/Button/Button.tsx +10 -7
- package/src/ButtonGroup/ButtonGroup.test.tsx +7 -4
- package/src/Card/Card.tsx +0 -2
- package/src/Card/index.ts +0 -2
- package/src/Center/Center.tsx +0 -2
- package/src/Center/index.ts +0 -2
- package/src/CheckboxInput/CheckboxInput.test.tsx +8 -3
- package/src/Code/Code.tsx +0 -2
- package/src/CommandPalette/CommandPalette.test.tsx +54 -0
- package/src/CommandPalette/CommandPalette.tsx +5 -0
- package/src/ComplexSelector/ComplexSelector.test.tsx +15 -6
- package/src/ComplexSelector/ComplexSelector.tsx +6 -10
- package/src/DateInput/DateInput.test.tsx +19 -0
- package/src/DateInput/DateInput.tsx +3 -6
- package/src/DateRangeInput/DateRangeInput.tsx +3 -9
- package/src/DateTimeInput/DateTimeInput.test.tsx +79 -1
- package/src/DateTimeInput/DateTimeInput.tsx +23 -9
- package/src/DropdownMenu/DropdownMenuRadioGroup.tsx +2 -1
- package/src/Field/PanelSearchInput.tsx +271 -0
- package/src/FileInput/FileInput.tsx +21 -8
- package/src/Grid/Grid.tsx +0 -2
- package/src/Grid/index.ts +0 -2
- package/src/HoverCard/HoverCard.doc.mjs +3 -3
- package/src/HoverCard/HoverCard.test.tsx +283 -55
- package/src/HoverCard/HoverCard.tsx +5 -13
- package/src/HoverCard/useHoverCard.tsx +8 -11
- package/src/Icon/globalIconRegistry.tsx +5 -4
- package/src/Indicator/Indicator.doc.mjs +1 -1
- package/src/Indicator/index.ts +1 -0
- package/src/Indicator/types.ts +11 -0
- package/src/InputGroup/groupStyles.ts +7 -8
- package/src/Layer/layerHost.test.ts +99 -0
- package/src/Layer/layerHost.ts +141 -0
- package/src/Layer/useLayer.doc.mjs +14 -4
- package/src/Layer/useLayer.test.tsx +318 -7
- package/src/Layer/useLayer.tsx +229 -35
- package/src/Lightbox/Lightbox.tsx +2 -11
- package/src/MultiSelector/MultiSelector.doc.mjs +9 -0
- package/src/MultiSelector/MultiSelector.test.tsx +135 -5
- package/src/MultiSelector/MultiSelector.tsx +170 -127
- package/src/NavItem/navItemStyles.stylex.ts +31 -5
- package/src/Popover/Popover.doc.mjs +2 -0
- package/src/Popover/usePopover.tsx +37 -4
- package/src/ProgressBar/ProgressBar.tsx +2 -8
- package/src/Section/Section.tsx +0 -2
- package/src/Section/index.ts +0 -2
- package/src/Selector/Selector.doc.mjs +10 -0
- package/src/Selector/Selector.test.tsx +386 -2
- package/src/Selector/Selector.tsx +182 -122
- package/src/SideNav/SideNav.doc.mjs +13 -4
- package/src/SideNav/SideNav.test.tsx +771 -2
- package/src/SideNav/SideNav.tsx +37 -16
- package/src/SideNav/SideNavCollapseButton.doc.mjs +28 -6
- package/src/SideNav/SideNavCollapseButton.tsx +67 -15
- package/src/SideNav/SideNavCollapseContext.ts +29 -9
- package/src/SideNav/SideNavHeading.tsx +28 -10
- package/src/SideNav/SideNavItem.doc.mjs +13 -0
- package/src/SideNav/SideNavItem.tsx +92 -84
- package/src/SideNav/SideNavSection.tsx +6 -20
- package/src/SideNav/index.ts +2 -0
- package/src/Skeleton/Skeleton.tsx +0 -2
- package/src/Skeleton/index.ts +0 -2
- package/src/Slider/Slider.tsx +2 -11
- package/src/Switch/Switch.tsx +10 -2
- package/src/Table/Table.test.tsx +31 -0
- package/src/Table/TableRow.tsx +6 -0
- package/src/Text/Text.doc.mjs +1 -1
- package/src/TimeInput/TimeInput.test.tsx +54 -0
- package/src/TimeInput/TimeInput.tsx +17 -2
- package/src/Timestamp/Timestamp.test.tsx +125 -30
- package/src/Timestamp/Timestamp.tsx +14 -2
- package/src/Timestamp/formatInstant.ts +16 -1
- package/src/Toolbar/Toolbar.test.tsx +14 -14
- package/src/TopNav/TopNavMegaMenu.doc.mjs +5 -0
- package/src/TopNav/TopNavMegaMenu.test.tsx +43 -0
- package/src/TopNav/TopNavMegaMenu.tsx +4 -1
- package/src/TopNav/TopNavMegaMenuItem.tsx +1 -1
- package/src/TopNav/TopNavMenu.test.tsx +41 -0
- package/src/TopNav/TopNavMenu.tsx +8 -2
- package/src/TreeList/TreeList.test.tsx +3 -2
- package/src/VisuallyHidden/VisuallyHidden.tsx +0 -2
- package/src/VisuallyHidden/index.ts +0 -2
- package/src/hooks/index.ts +5 -1
- package/src/hooks/useFocusTrap.test.tsx +16 -0
- package/src/hooks/useFocusTrap.ts +20 -2
- package/src/hooks/useInputStatusIcon.tsx +8 -8
- package/src/serverSafeComponents.test.ts +665 -0
- package/src/theme/defineTheme.ts +3 -0
- package/src/theme/generateThemeRules.test.ts +17 -0
- package/src/theme/index.ts +2 -0
- package/src/theme/themingTargets.test.ts +152 -26
- package/src/theme/tokens.stylex.ts +18 -0
- package/src/theme/tokens.test.ts +37 -0
- package/src/utils/focusOutline.stylex.ts +37 -23
- package/src/utils/index.ts +4 -0
- package/src/utils/interactionModality.ts +74 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file PanelSearchInput.tsx
|
|
7
|
+
* @input Uses React, StyleX, Icon, InputClearButton, theme tokens
|
|
8
|
+
* @output Exports PanelSearchInput — the search row that sits at the top of a
|
|
9
|
+
* dropdown panel
|
|
10
|
+
* @position Shared internal primitive; used by Selector and MultiSelector
|
|
11
|
+
*
|
|
12
|
+
* A dropdown panel is already a bordered, elevated surface. Nesting a bordered
|
|
13
|
+
* TextInput inside it draws a second box within that box, so the field reads as
|
|
14
|
+
* a control dropped into the menu rather than part of it. This row is the
|
|
15
|
+
* seamless alternative — magnifier, borderless input, clear button — separated
|
|
16
|
+
* from the options by a divider the panel owns.
|
|
17
|
+
*
|
|
18
|
+
* The field is shaped like the option rows under it rather than like a form
|
|
19
|
+
* input: same inset from the panel edge, same `--radius-element` corners, same
|
|
20
|
+
* height. The focus ring is drawn on that rounded box, so focus reads as "this
|
|
21
|
+
* row of the panel" — the same visual language as an item's highlight — instead
|
|
22
|
+
* of ringing the whole panel header. It appears for keyboard focus only; see
|
|
23
|
+
* `fieldKeyboardFocus` for why `:focus-visible` alone does not mean that.
|
|
24
|
+
*
|
|
25
|
+
* ┌─ panel ──────────────────┐
|
|
26
|
+
* │ ┌──────────────────────┐ │ ← field: rounded, inset, item-sized
|
|
27
|
+
* │ │ ⌕ Search… ✕ │ │
|
|
28
|
+
* │ └──────────────────────┘ │
|
|
29
|
+
* ├──────────────────────────┤ ← divider (full-bleed)
|
|
30
|
+
* │ ┌──────────────────────┐ │
|
|
31
|
+
* │ │ Apple │ │ ← option row: same box
|
|
32
|
+
*
|
|
33
|
+
* The clear button is the shared `InputClearButton`, so the affordance and its
|
|
34
|
+
* ghost-button behavior match every other input's clear. It renders AFTER the
|
|
35
|
+
* input in DOM order: the selector components' Tab handling depends on that
|
|
36
|
+
* order to keep the popup open while focus moves onto it.
|
|
37
|
+
*
|
|
38
|
+
* Not exported from the package: it is an implementation detail of the panels
|
|
39
|
+
* that use it, not public API.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
import {useCallback, useEffect, useState, type Ref} from 'react';
|
|
43
|
+
import * as stylex from '@stylexjs/stylex';
|
|
44
|
+
import {Icon} from '../Icon';
|
|
45
|
+
import {InputClearButton} from './InputClearButton';
|
|
46
|
+
import {mergeProps} from '../utils';
|
|
47
|
+
import {
|
|
48
|
+
getInteractionModality,
|
|
49
|
+
trackInteractionModality,
|
|
50
|
+
} from '../utils/interactionModality';
|
|
51
|
+
import {
|
|
52
|
+
colorVars,
|
|
53
|
+
durationVars,
|
|
54
|
+
easeVars,
|
|
55
|
+
radiusVars,
|
|
56
|
+
spacingVars,
|
|
57
|
+
typeScaleVars,
|
|
58
|
+
typographyVars,
|
|
59
|
+
} from '../theme/tokens.stylex';
|
|
60
|
+
import type {BaseProps} from '../BaseProps';
|
|
61
|
+
|
|
62
|
+
const styles = stylex.create({
|
|
63
|
+
// Gutter only. Matches the option list's own padding so the field below
|
|
64
|
+
// lines up with the option rows rather than with the panel edge.
|
|
65
|
+
wrapper: {
|
|
66
|
+
paddingBlock: spacingVars['--spacing-1'],
|
|
67
|
+
paddingInline: spacingVars['--spacing-1'],
|
|
68
|
+
},
|
|
69
|
+
// The field proper — the same box an option row draws: `--radius-element`
|
|
70
|
+
// corners and, at md, a 6/8 padding pair that lands it on the option row's
|
|
71
|
+
// 32px height. Focus rings THIS, not the full-width row.
|
|
72
|
+
field: {
|
|
73
|
+
boxSizing: 'border-box',
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
gap: spacingVars['--spacing-2'],
|
|
77
|
+
width: '100%',
|
|
78
|
+
paddingBlock: spacingVars['--spacing-1-5'],
|
|
79
|
+
paddingInline: spacingVars['--spacing-2'],
|
|
80
|
+
borderRadius: radiusVars['--radius-element'],
|
|
81
|
+
transitionProperty: 'box-shadow',
|
|
82
|
+
transitionDuration: {
|
|
83
|
+
default: durationVars['--duration-fast'],
|
|
84
|
+
'@media (prefers-reduced-motion: reduce)': '0s',
|
|
85
|
+
},
|
|
86
|
+
transitionTimingFunction: easeVars['--ease-standard'],
|
|
87
|
+
},
|
|
88
|
+
// The focus ring, applied only while focus was taken by keyboard (see
|
|
89
|
+
// `isKeyboardFocus`). `:has(input:focus-visible)` stays the CSS condition —
|
|
90
|
+
// the browser's heuristic still decides, this only narrows it — and rings
|
|
91
|
+
// the field rather than the bare <input> so the magnifier and the clear
|
|
92
|
+
// button sit inside it, and so tabbing ONTO the clear button does not
|
|
93
|
+
// re-ring the field.
|
|
94
|
+
//
|
|
95
|
+
// Inset, not the shared 3px-offset outline: the field is inset 4-5px from
|
|
96
|
+
// the panel edge, so an outline at that offset would land on the panel's own
|
|
97
|
+
// border and the divider. Measured, not guessed.
|
|
98
|
+
fieldKeyboardFocus: {
|
|
99
|
+
boxShadow: {
|
|
100
|
+
default: 'none',
|
|
101
|
+
':has(input:focus-visible)': `inset 0 0 0 2px ${colorVars['--color-accent']}`,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
// The icon span needs explicit flex centering to avoid a line-height offset.
|
|
105
|
+
icon: {
|
|
106
|
+
display: 'flex',
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
flexShrink: 0,
|
|
109
|
+
},
|
|
110
|
+
input: {
|
|
111
|
+
flexGrow: 1,
|
|
112
|
+
flexShrink: 1,
|
|
113
|
+
minWidth: 0,
|
|
114
|
+
padding: 0,
|
|
115
|
+
margin: 0,
|
|
116
|
+
borderWidth: 0,
|
|
117
|
+
borderStyle: 'none',
|
|
118
|
+
backgroundColor: 'transparent',
|
|
119
|
+
color: colorVars['--color-text-primary'],
|
|
120
|
+
fontFamily: typographyVars['--font-family-body'],
|
|
121
|
+
// Matches the option rows below it, so the query reads as the first line of
|
|
122
|
+
// the list. The coarse-pointer floor keeps iOS from zooming on focus.
|
|
123
|
+
fontSize: {
|
|
124
|
+
default: typeScaleVars['--text-label-size'],
|
|
125
|
+
'@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--text-label-size']})`,
|
|
126
|
+
},
|
|
127
|
+
lineHeight: typeScaleVars['--text-label-leading'],
|
|
128
|
+
// The field draws the focus ring (see `field`), so the bare input must not
|
|
129
|
+
// draw a second one inside it.
|
|
130
|
+
outline: 'none',
|
|
131
|
+
'::placeholder': {
|
|
132
|
+
color: colorVars['--color-text-secondary'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export interface PanelSearchInputProps extends Omit<
|
|
138
|
+
BaseProps<HTMLInputElement>,
|
|
139
|
+
'onChange'
|
|
140
|
+
> {
|
|
141
|
+
/** Ref forwarded to the input element (for focus management). */
|
|
142
|
+
ref?: Ref<HTMLInputElement>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Accessible name for the input. Rendered as `aria-label`: the panel has no
|
|
146
|
+
* visible label for the field, and a placeholder is not a reliable name.
|
|
147
|
+
*/
|
|
148
|
+
label: string;
|
|
149
|
+
|
|
150
|
+
/** Accessible name for the clear (✕) button, e.g. `Clear Search options`. */
|
|
151
|
+
clearLabel: string;
|
|
152
|
+
|
|
153
|
+
/** Placeholder text shown while the query is empty. */
|
|
154
|
+
placeholder?: string;
|
|
155
|
+
|
|
156
|
+
/** The current query. */
|
|
157
|
+
value: string;
|
|
158
|
+
|
|
159
|
+
/** Called with the next query on every keystroke and on clear. */
|
|
160
|
+
onValueChange: (value: string) => void;
|
|
161
|
+
|
|
162
|
+
/** Key handler for the input itself. */
|
|
163
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
164
|
+
|
|
165
|
+
/** Focus handler for the input; runs after the ring's own bookkeeping. */
|
|
166
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
167
|
+
|
|
168
|
+
/** Blur handler for the input; runs after the ring's own bookkeeping. */
|
|
169
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Key handler for the row. Events from the input are handled by `onKeyDown`;
|
|
173
|
+
* this one exists for keys pressed on the clear button, which has no other
|
|
174
|
+
* handler of its own.
|
|
175
|
+
*/
|
|
176
|
+
onContainerKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Search row for the top of a dropdown panel: magnifier, borderless input, and
|
|
181
|
+
* a clear button once a query is typed, in a rounded box shaped like the
|
|
182
|
+
* option rows beneath it.
|
|
183
|
+
*
|
|
184
|
+
* `className`/`style`/`xstyle` apply to the outer row (use them to match the
|
|
185
|
+
* option list's inline padding); every other prop (`role`, `aria-*`, `id`, …)
|
|
186
|
+
* passes through to the `<input>`, so the caller owns the combobox wiring.
|
|
187
|
+
*/
|
|
188
|
+
export function PanelSearchInput({
|
|
189
|
+
ref,
|
|
190
|
+
label,
|
|
191
|
+
clearLabel,
|
|
192
|
+
placeholder,
|
|
193
|
+
value,
|
|
194
|
+
onValueChange,
|
|
195
|
+
onKeyDown,
|
|
196
|
+
onFocus,
|
|
197
|
+
onBlur,
|
|
198
|
+
onContainerKeyDown,
|
|
199
|
+
xstyle,
|
|
200
|
+
className,
|
|
201
|
+
style,
|
|
202
|
+
...props
|
|
203
|
+
}: PanelSearchInputProps) {
|
|
204
|
+
// `:focus-visible` matches a text input focused by POINTER as well (CSS
|
|
205
|
+
// Selectors 4, verified in Chromium), so it cannot express "keyboard focus"
|
|
206
|
+
// by itself. Gate it on how the user last interacted; the CSS condition
|
|
207
|
+
// stays `:focus-visible`, this only narrows it.
|
|
208
|
+
const [isKeyboardFocus, setIsKeyboardFocus] = useState(false);
|
|
209
|
+
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
trackInteractionModality();
|
|
212
|
+
}, []);
|
|
213
|
+
|
|
214
|
+
const handleFocus = useCallback(
|
|
215
|
+
(e: React.FocusEvent<HTMLInputElement>) => {
|
|
216
|
+
setIsKeyboardFocus(getInteractionModality() === 'keyboard');
|
|
217
|
+
onFocus?.(e);
|
|
218
|
+
},
|
|
219
|
+
[onFocus],
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const handleBlur = useCallback(
|
|
223
|
+
(e: React.FocusEvent<HTMLInputElement>) => {
|
|
224
|
+
setIsKeyboardFocus(false);
|
|
225
|
+
onBlur?.(e);
|
|
226
|
+
},
|
|
227
|
+
[onBlur],
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const handleClear = useCallback(() => {
|
|
231
|
+
onValueChange('');
|
|
232
|
+
// Clearing puts the caret back where the user was typing, matching
|
|
233
|
+
// TextInput's built-in clear.
|
|
234
|
+
if (typeof ref === 'object' && ref?.current) {
|
|
235
|
+
ref.current.focus();
|
|
236
|
+
}
|
|
237
|
+
}, [onValueChange, ref]);
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<div
|
|
241
|
+
onKeyDown={onContainerKeyDown}
|
|
242
|
+
{...mergeProps(stylex.props(styles.wrapper, xstyle), className, style)}>
|
|
243
|
+
<div
|
|
244
|
+
data-keyboard-focus={isKeyboardFocus ? 'true' : undefined}
|
|
245
|
+
{...stylex.props(
|
|
246
|
+
styles.field,
|
|
247
|
+
isKeyboardFocus && styles.fieldKeyboardFocus,
|
|
248
|
+
)}>
|
|
249
|
+
<Icon icon="search" size="sm" color="secondary" xstyle={styles.icon} />
|
|
250
|
+
<input
|
|
251
|
+
ref={ref}
|
|
252
|
+
type="text"
|
|
253
|
+
aria-label={label}
|
|
254
|
+
placeholder={placeholder}
|
|
255
|
+
value={value}
|
|
256
|
+
onChange={e => onValueChange(e.target.value)}
|
|
257
|
+
onKeyDown={onKeyDown}
|
|
258
|
+
onFocus={handleFocus}
|
|
259
|
+
onBlur={handleBlur}
|
|
260
|
+
{...stylex.props(styles.input)}
|
|
261
|
+
{...props}
|
|
262
|
+
/>
|
|
263
|
+
{value !== '' && (
|
|
264
|
+
<InputClearButton label={clearLabel} onClick={handleClear} />
|
|
265
|
+
)}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
PanelSearchInput.displayName = 'PanelSearchInput';
|
|
@@ -59,6 +59,7 @@ import type {BaseProps} from '../BaseProps';
|
|
|
59
59
|
import type {SizeValue} from '../utils/types';
|
|
60
60
|
import {themeProps} from '../utils/themeProps';
|
|
61
61
|
import {useTranslator} from '../i18n';
|
|
62
|
+
import type {TranslatorFn} from '../i18n';
|
|
62
63
|
|
|
63
64
|
function formatFileSize(bytes: number): string {
|
|
64
65
|
if (bytes < 1024) {
|
|
@@ -76,12 +77,13 @@ function validateFiles(
|
|
|
76
77
|
maxSize: number | undefined,
|
|
77
78
|
maxFiles: number | undefined,
|
|
78
79
|
isMultiple: boolean,
|
|
80
|
+
t: TranslatorFn,
|
|
79
81
|
): {valid: File[]; errors: string[]} {
|
|
80
82
|
const errors: string[] = [];
|
|
81
83
|
let valid = files;
|
|
82
84
|
|
|
83
85
|
if (accept) {
|
|
84
|
-
const acceptedTypes = accept.split(',').map(
|
|
86
|
+
const acceptedTypes = accept.split(',').map(s => s.trim().toLowerCase());
|
|
85
87
|
valid = valid.filter(file => {
|
|
86
88
|
const matches = acceptedTypes.some(type => {
|
|
87
89
|
if (type.startsWith('.')) {
|
|
@@ -93,7 +95,9 @@ function validateFiles(
|
|
|
93
95
|
return file.type.toLowerCase() === type;
|
|
94
96
|
});
|
|
95
97
|
if (!matches) {
|
|
96
|
-
errors.push(
|
|
98
|
+
errors.push(
|
|
99
|
+
t('@astryx.fileInput.errorInvalidType', {fileName: file.name}),
|
|
100
|
+
);
|
|
97
101
|
}
|
|
98
102
|
return matches;
|
|
99
103
|
});
|
|
@@ -102,7 +106,12 @@ function validateFiles(
|
|
|
102
106
|
if (maxSize != null) {
|
|
103
107
|
valid = valid.filter(file => {
|
|
104
108
|
if (file.size > maxSize) {
|
|
105
|
-
errors.push(
|
|
109
|
+
errors.push(
|
|
110
|
+
t('@astryx.fileInput.errorMaxSize', {
|
|
111
|
+
fileName: file.name,
|
|
112
|
+
maxSize: formatFileSize(maxSize),
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
106
115
|
return false;
|
|
107
116
|
}
|
|
108
117
|
return true;
|
|
@@ -110,7 +119,7 @@ function validateFiles(
|
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
if (isMultiple && maxFiles != null && valid.length > maxFiles) {
|
|
113
|
-
errors.push(
|
|
122
|
+
errors.push(t('@astryx.fileInput.errorMaxFiles', {maxFiles}));
|
|
114
123
|
valid = valid.slice(0, maxFiles);
|
|
115
124
|
}
|
|
116
125
|
|
|
@@ -488,7 +497,9 @@ export function FileInput({
|
|
|
488
497
|
.filter(Boolean)
|
|
489
498
|
.join(' ') || undefined;
|
|
490
499
|
|
|
491
|
-
const defaultPlaceholder = isMultiple
|
|
500
|
+
const defaultPlaceholder = isMultiple
|
|
501
|
+
? t('@astryx.fileInput.placeholderMultiple')
|
|
502
|
+
: t('@astryx.fileInput.placeholder');
|
|
492
503
|
const displayPlaceholder = placeholder ?? defaultPlaceholder;
|
|
493
504
|
|
|
494
505
|
const handleFiles = useCallback(
|
|
@@ -503,6 +514,7 @@ export function FileInput({
|
|
|
503
514
|
maxSize,
|
|
504
515
|
maxFiles,
|
|
505
516
|
isMultiple,
|
|
517
|
+
t,
|
|
506
518
|
);
|
|
507
519
|
|
|
508
520
|
if (errors.length > 0) {
|
|
@@ -526,8 +538,8 @@ export function FileInput({
|
|
|
526
538
|
if (errors.length === 0) {
|
|
527
539
|
announce(
|
|
528
540
|
valid.length === 1
|
|
529
|
-
?
|
|
530
|
-
:
|
|
541
|
+
? t('@astryx.fileInput.fileSelected', {fileName: valid[0].name})
|
|
542
|
+
: t('@astryx.fileInput.filesSelected', {count: valid.length}),
|
|
531
543
|
);
|
|
532
544
|
}
|
|
533
545
|
|
|
@@ -547,6 +559,7 @@ export function FileInput({
|
|
|
547
559
|
changeAction,
|
|
548
560
|
startTransition,
|
|
549
561
|
announce,
|
|
562
|
+
t,
|
|
550
563
|
],
|
|
551
564
|
);
|
|
552
565
|
|
|
@@ -679,7 +692,7 @@ export function FileInput({
|
|
|
679
692
|
<>
|
|
680
693
|
<Icon icon="arrowUp" size="md" color="secondary" />
|
|
681
694
|
<span {...stylex.props(styles.placeholderText)}>
|
|
682
|
-
{isDragOver ? '
|
|
695
|
+
{isDragOver ? t('@astryx.fileInput.dropHint') : displayPlaceholder}
|
|
683
696
|
</span>
|
|
684
697
|
</>
|
|
685
698
|
);
|
package/src/Grid/Grid.tsx
CHANGED
package/src/Grid/index.ts
CHANGED
|
@@ -114,7 +114,7 @@ export const docs = {
|
|
|
114
114
|
{ guidance: false, description: 'Place critical actions or required information inside a hover card; users may miss content that only appears on hover.' },
|
|
115
115
|
{ guidance: false, description: 'Use a hover card when a simple Tooltip or Popover would suffice.' },
|
|
116
116
|
{ guidance: false, description: 'Use a HoverCard for content the user must interact with; it disappears when the cursor leaves.' },
|
|
117
|
-
{ guidance:
|
|
117
|
+
{ guidance: true, description: 'Prefer placing HoverCard in a block context rather than directly in a <p>, heading, or link. Those placements are supported when necessary through a corrective portal, but the DOM and tab order may differ.' },
|
|
118
118
|
],
|
|
119
119
|
anatomy: [
|
|
120
120
|
{name: 'Trigger', required: true, description: 'The element that opens the hover card on hover or focus: a button, link, or inline text.'},
|
|
@@ -229,7 +229,7 @@ export const docsZh = {
|
|
|
229
229
|
{ guidance: false, description: 'Place critical actions or required information inside a hover card; users may miss content that only appears on hover.' },
|
|
230
230
|
{ guidance: false, description: 'Use a hover card when a simple Tooltip or Popover would suffice.' },
|
|
231
231
|
{ guidance: false, description: 'Use a HoverCard for content the user must interact with; it disappears when the cursor leaves.' },
|
|
232
|
-
{ guidance:
|
|
232
|
+
{ guidance: true, description: 'Prefer placing HoverCard in a block context rather than directly in a <p>, heading, or link. Those placements are supported when necessary through a corrective portal, but the DOM and tab order may differ.' },
|
|
233
233
|
],
|
|
234
234
|
},
|
|
235
235
|
};
|
|
@@ -247,7 +247,7 @@ export const docsDense = {
|
|
|
247
247
|
{ guidance: false, description: 'Place critical actions or required information inside a hover card; users may miss content that only appears on hover.' },
|
|
248
248
|
{ guidance: false, description: 'Use a hover card when a simple Tooltip or Popover would suffice.' },
|
|
249
249
|
{ guidance: false, description: 'Use a HoverCard for content the user must interact with; it disappears when the cursor leaves.' },
|
|
250
|
-
{ guidance:
|
|
250
|
+
{ guidance: true, description: 'Prefer a block context over a direct <p>, heading, or link placement. Those placements work when necessary through a corrective portal, but DOM/tab order may differ.' },
|
|
251
251
|
],
|
|
252
252
|
},
|
|
253
253
|
components: [
|