@eldrajs/ui 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1724 -0
- package/LICENSE +21 -0
- package/README.md +3177 -2
- package/dist/VariantPicker-CKw8hmxt.js +9009 -0
- package/dist/componentNames.d.ts +19 -0
- package/dist/components/accordion/Accordion.vue.d.ts +18 -0
- package/dist/components/accordion/AccordionItem.vue.d.ts +26 -0
- package/dist/components/accordion/context.d.ts +20 -0
- package/dist/components/accordion/detailsExclusivity.d.ts +3 -0
- package/dist/components/accordion/heightTransition.d.ts +59 -0
- package/dist/components/accordion/types.d.ts +40 -0
- package/dist/components/avatar/Avatar.vue.d.ts +10 -0
- package/dist/components/avatar/AvatarGroup.vue.d.ts +7 -0
- package/dist/components/avatar/types.d.ts +61 -0
- package/dist/components/badge/Badge.vue.d.ts +24 -0
- package/dist/components/badge/StockBadge.vue.d.ts +10 -0
- package/dist/components/badge/types.d.ts +79 -0
- package/dist/components/breadcrumb/Breadcrumb.vue.d.ts +10 -0
- package/dist/components/breadcrumb/types.d.ts +53 -0
- package/dist/components/button/Button.vue.d.ts +37 -0
- package/dist/components/button/ButtonGroup.vue.d.ts +17 -0
- package/dist/components/button/types.d.ts +68 -0
- package/dist/components/card/ContentCard.vue.d.ts +36 -0
- package/dist/components/card/FeatureCard.vue.d.ts +27 -0
- package/dist/components/card/cueArrow.d.ts +10 -0
- package/dist/components/card/stretchedLink.d.ts +45 -0
- package/dist/components/card/types.d.ts +92 -0
- package/dist/components/carousel/Carousel.vue.d.ts +39 -0
- package/dist/components/carousel/types.d.ts +75 -0
- package/dist/components/carousel/useCarousel.d.ts +152 -0
- package/dist/components/checkbox/Checkbox.vue.d.ts +36 -0
- package/dist/components/checkbox/CheckboxGroup.vue.d.ts +16 -0
- package/dist/components/checkbox/types.d.ts +78 -0
- package/dist/components/chip/Chip.vue.d.ts +37 -0
- package/dist/components/chip/ChipGroup.vue.d.ts +21 -0
- package/dist/components/chip/context.d.ts +22 -0
- package/dist/components/chip/types.d.ts +84 -0
- package/dist/components/container/Container.vue.d.ts +18 -0
- package/dist/components/container/types.d.ts +17 -0
- package/dist/components/currency-input/CurrencyInput.vue.d.ts +17 -0
- package/dist/components/currency-input/types.d.ts +8 -0
- package/dist/components/dialog/Dialog.vue.d.ts +34 -0
- package/dist/components/dialog/types.d.ts +25 -0
- package/dist/components/drawer/Drawer.vue.d.ts +36 -0
- package/dist/components/drawer/types.d.ts +30 -0
- package/dist/components/empty-state/EditorPlaceholder.vue.d.ts +9 -0
- package/dist/components/empty-state/EmptyState.vue.d.ts +28 -0
- package/dist/components/empty-state/types.d.ts +59 -0
- package/dist/components/field-wrapper/FieldError.vue.d.ts +37 -0
- package/dist/components/field-wrapper/FieldWrapper.vue.d.ts +30 -0
- package/dist/components/field-wrapper/context.d.ts +44 -0
- package/dist/components/field-wrapper/types.d.ts +38 -0
- package/dist/components/filter-panel/FilterGroup.vue.d.ts +48 -0
- package/dist/components/filter-panel/FilterPanel.vue.d.ts +77 -0
- package/dist/components/filter-panel/Histogram.vue.d.ts +15 -0
- package/dist/components/filter-panel/facets/ColourFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/ListFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/RangeFacet.vue.d.ts +20 -0
- package/dist/components/filter-panel/facets/SizeFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/ToggleFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/shared.d.ts +39 -0
- package/dist/components/filter-panel/northwind.d.ts +32 -0
- package/dist/components/filter-panel/swatchInk.d.ts +50 -0
- package/dist/components/filter-panel/types.d.ts +183 -0
- package/dist/components/filter-panel/useFilterPanel.d.ts +230 -0
- package/dist/components/form-layout/FormLayout.vue.d.ts +36 -0
- package/dist/components/form-layout/context.d.ts +33 -0
- package/dist/components/form-layout/focusInvalid.d.ts +18 -0
- package/dist/components/form-layout/types.d.ts +52 -0
- package/dist/components/icon/Icon.vue.d.ts +8 -0
- package/dist/components/icon/types.d.ts +29 -0
- package/dist/components/image/Image.vue.d.ts +21 -0
- package/dist/components/image/types.d.ts +81 -0
- package/dist/components/input/Input.vue.d.ts +47 -0
- package/dist/components/input/classes.d.ts +110 -0
- package/dist/components/input/types.d.ts +55 -0
- package/dist/components/internal/ValueText.vue.d.ts +7 -0
- package/dist/components/lightbox/Lightbox.vue.d.ts +19 -0
- package/dist/components/lightbox/types.d.ts +47 -0
- package/dist/components/link/Link.vue.d.ts +23 -0
- package/dist/components/link/types.d.ts +40 -0
- package/dist/components/load-more/LoadMore.vue.d.ts +12 -0
- package/dist/components/load-more/types.d.ts +21 -0
- package/dist/components/logo-item/LogoItem.vue.d.ts +10 -0
- package/dist/components/logo-item/types.d.ts +37 -0
- package/dist/components/pagination/Pagination.vue.d.ts +15 -0
- package/dist/components/pagination/types.d.ts +51 -0
- package/dist/components/popover/Popover.vue.d.ts +31 -0
- package/dist/components/popover/types.d.ts +53 -0
- package/dist/components/price/Price.vue.d.ts +25 -0
- package/dist/components/price/types.d.ts +104 -0
- package/dist/components/product-card/ProductCard.vue.d.ts +22 -0
- package/dist/components/product-card/types.d.ts +123 -0
- package/dist/components/quantity-stepper/QuantityStepper.vue.d.ts +26 -0
- package/dist/components/quantity-stepper/types.d.ts +35 -0
- package/dist/components/radio/RadioGroup.vue.d.ts +38 -0
- package/dist/components/radio/types.d.ts +39 -0
- package/dist/components/range-slider/RangeSlider.vue.d.ts +70 -0
- package/dist/components/range-slider/types.d.ts +151 -0
- package/dist/components/range-slider/useRangeSlider.d.ts +106 -0
- package/dist/components/rating/Rating.vue.d.ts +22 -0
- package/dist/components/rating/RatingStars.vue.d.ts +16 -0
- package/dist/components/rating/types.d.ts +45 -0
- package/dist/components/search-bar/SearchBar.vue.d.ts +47 -0
- package/dist/components/search-bar/SearchResultsPanel.vue.d.ts +93 -0
- package/dist/components/search-bar/shortcutOwner.d.ts +39 -0
- package/dist/components/search-bar/types.d.ts +122 -0
- package/dist/components/search-modal/SearchModal.vue.d.ts +53 -0
- package/dist/components/search-modal/types.d.ts +59 -0
- package/dist/components/section/Section.vue.d.ts +21 -0
- package/dist/components/section/context.d.ts +23 -0
- package/dist/components/section/types.d.ts +34 -0
- package/dist/components/select/MultiSelect.vue.d.ts +62 -0
- package/dist/components/select/Select.vue.d.ts +57 -0
- package/dist/components/select/SelectPanel.vue.d.ts +97 -0
- package/dist/components/select/openRegistry.d.ts +11 -0
- package/dist/components/select/panelParts.d.ts +91 -0
- package/dist/components/select/types.d.ts +129 -0
- package/dist/components/select/useListbox.d.ts +106 -0
- package/dist/components/select/useOptionList.d.ts +61 -0
- package/dist/components/select/usePopover.d.ts +147 -0
- package/dist/components/skeleton/Skeleton.vue.d.ts +12 -0
- package/dist/components/skeleton/types.d.ts +38 -0
- package/dist/components/spinner/Spinner.vue.d.ts +3 -0
- package/dist/components/switch/Switch.vue.d.ts +30 -0
- package/dist/components/switch/types.d.ts +20 -0
- package/dist/components/tabs/Tab.vue.d.ts +17 -0
- package/dist/components/tabs/TabPanel.vue.d.ts +16 -0
- package/dist/components/tabs/Tabs.vue.d.ts +28 -0
- package/dist/components/tabs/context.d.ts +48 -0
- package/dist/components/tabs/types.d.ts +63 -0
- package/dist/components/textarea/Textarea.vue.d.ts +27 -0
- package/dist/components/textarea/supportsFieldSizing.d.ts +10 -0
- package/dist/components/textarea/types.d.ts +32 -0
- package/dist/components/toast/Toast.vue.d.ts +16 -0
- package/dist/components/toast/Toaster.vue.d.ts +13 -0
- package/dist/components/toast/types.d.ts +44 -0
- package/dist/components/tooltip/Tooltip.vue.d.ts +9 -0
- package/dist/components/tooltip/supportsFocusVisible.d.ts +17 -0
- package/dist/components/tooltip/types.d.ts +46 -0
- package/dist/components/unit-input/UnitInput.vue.d.ts +55 -0
- package/dist/components/unit-input/types.d.ts +68 -0
- package/dist/components/unit-input/undo-redo.d.ts +6 -0
- package/dist/components/variant-picker/VariantPicker.vue.d.ts +15 -0
- package/dist/components/variant-picker/types.d.ts +49 -0
- package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +18 -0
- package/dist/components/visually-hidden/types.d.ts +14 -0
- package/dist/composables/dialogStack.d.ts +52 -0
- package/dist/composables/teleportTarget.d.ts +79 -0
- package/dist/composables/useControllableModel.d.ts +16 -0
- package/dist/composables/useDialog.d.ts +84 -0
- package/dist/composables/useFloating.d.ts +82 -0
- package/dist/composables/useHeadingTag.d.ts +24 -0
- package/dist/composables/useLocale.d.ts +81 -0
- package/dist/composables/useMessages.d.ts +30 -0
- package/dist/composables/useOverlay.d.ts +88 -0
- package/dist/composables/useSlotPresence.d.ts +29 -0
- package/dist/composables/useToast.d.ts +53 -0
- package/dist/icons/paths.d.ts +10 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.js +12586 -0
- package/dist/listFormat-1UrH38f2.js +39 -0
- package/dist/messages/en-US.d.ts +485 -0
- package/dist/messages/index.d.ts +2 -0
- package/dist/messages/is-IS.d.ts +16 -0
- package/dist/messages/is-IS.js +169 -0
- package/dist/resolver.d.ts +43 -0
- package/dist/resolver.js +121 -0
- package/dist/style.css +5251 -0
- package/dist/tailwind.css +2057 -0
- package/dist/tokens.css +134 -0
- package/dist/utils/avatar.d.ts +15 -0
- package/dist/utils/color.d.ts +11 -0
- package/dist/utils/cssTiming.d.ts +40 -0
- package/dist/utils/cx.d.ts +31 -0
- package/dist/utils/date.d.ts +45 -0
- package/dist/utils/id.d.ts +36 -0
- package/dist/utils/listFormat.d.ts +22 -0
- package/dist/utils/mask.d.ts +48 -0
- package/dist/utils/number-format.d.ts +250 -0
- package/dist/utils/numeric-input.d.ts +42 -0
- package/dist/utils/rating.d.ts +26 -0
- package/dist/utils/ratio.d.ts +18 -0
- package/dist/utils/tagRecipe.d.ts +24 -0
- package/dist/utils/valueFade.d.ts +42 -0
- package/dist/vee-validate/FieldCheckbox.vue.d.ts +14 -0
- package/dist/vee-validate/FieldCheckboxGroup.vue.d.ts +14 -0
- package/dist/vee-validate/FieldCurrencyInput.vue.d.ts +14 -0
- package/dist/vee-validate/FieldInput.vue.d.ts +14 -0
- package/dist/vee-validate/FieldMultiSelect.vue.d.ts +14 -0
- package/dist/vee-validate/FieldQuantityStepper.vue.d.ts +14 -0
- package/dist/vee-validate/FieldRadioGroup.vue.d.ts +14 -0
- package/dist/vee-validate/FieldSearchBar.vue.d.ts +14 -0
- package/dist/vee-validate/FieldSelect.vue.d.ts +14 -0
- package/dist/vee-validate/FieldSwitch.vue.d.ts +14 -0
- package/dist/vee-validate/FieldTextarea.vue.d.ts +14 -0
- package/dist/vee-validate/FieldUnitInput.vue.d.ts +14 -0
- package/dist/vee-validate/FieldVariantPicker.vue.d.ts +14 -0
- package/dist/vee-validate/Form.vue.d.ts +27 -0
- package/dist/vee-validate/context.d.ts +48 -0
- package/dist/vee-validate/index.d.ts +27 -0
- package/dist/vee-validate/types.d.ts +115 -0
- package/dist/vee-validate/useFieldControl.d.ts +67 -0
- package/dist/vee-validate.js +1154 -0
- package/package.json +99 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { RangeSliderThumb, RangeSliderValue } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The range slider's arithmetic: value to percent, a pointer position to a value, the step grid,
|
|
4
|
+
* the clamp of each thumb against the other, and the keyboard transitions.
|
|
5
|
+
*
|
|
6
|
+
* Every function here is pure — no reactivity, no DOM beyond the two numbers of a rect — so each
|
|
7
|
+
* rule can be tested on its own (`__tests__/useRangeSlider.spec.ts`) rather than only through a
|
|
8
|
+
* mounted component, which is how the float-accumulation rule below is provable at all. The file
|
|
9
|
+
* is named for the component it belongs to rather than exporting a `useRangeSlider()` composable:
|
|
10
|
+
* the control's state is two numbers the component already owns through `useControllableModel`,
|
|
11
|
+
* so a composable wrapping it would only hand that state back again.
|
|
12
|
+
*/
|
|
13
|
+
/** The numbers every rule here needs: the bounds and the two step sizes. */
|
|
14
|
+
export interface RangeSliderMath {
|
|
15
|
+
min: number;
|
|
16
|
+
max: number;
|
|
17
|
+
step: number;
|
|
18
|
+
largeStep: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* How many fraction digits a number is written with, exponent form included (`1e-7` is 7).
|
|
22
|
+
*
|
|
23
|
+
* This is what keeps a fractional step from drifting: `0.1` added twenty times is
|
|
24
|
+
* `1.9999999999999998` in binary floating point, and a slider that reports that as its value
|
|
25
|
+
* reports it to the page, to `aria-valuenow` and to the field beside it. Rounding every result to
|
|
26
|
+
* the number of digits the inputs are written with is the standard answer, and it needs to know
|
|
27
|
+
* how many that is.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fractionDigits(value: number): number;
|
|
30
|
+
/** How many fraction digits the grid `math` describes can land on. */
|
|
31
|
+
export declare function rangeStepDigits(math: Pick<RangeSliderMath, 'min' | 'step'>): number;
|
|
32
|
+
/**
|
|
33
|
+
* The nearest stop to `value`: a multiple of the step counted from `min`, or either bound.
|
|
34
|
+
*
|
|
35
|
+
* The two bounds are stops in their own right, which matters whenever `max` is not itself on the
|
|
36
|
+
* grid — a price filter's bounds are the catalogue's own lowest and highest price, and those owe
|
|
37
|
+
* the step nothing. With a step of 3 over `[0, 10]` the stops are 0, 3, 6, 9 and 10, so the top of
|
|
38
|
+
* the range can actually be chosen; snapping to the grid alone would make a drag to the far end
|
|
39
|
+
* land on 9 and leave the most expensive product permanently filtered out.
|
|
40
|
+
*
|
|
41
|
+
* A non-positive `step` has no grid at all (a consumer passing `0`), so the value is only clamped.
|
|
42
|
+
*/
|
|
43
|
+
export declare function snapToRangeStep(value: number, math: Pick<RangeSliderMath, 'min' | 'max' | 'step'>): number;
|
|
44
|
+
/** Where a value sits along the track, as a percentage of the bounds. */
|
|
45
|
+
export declare function rangeValueToPercent(value: number, math: Pick<RangeSliderMath, 'min' | 'max'>): number;
|
|
46
|
+
/**
|
|
47
|
+
* The value under a pointer, snapped to the grid.
|
|
48
|
+
*
|
|
49
|
+
* `rect` is the track's own box, so the caller passes `getBoundingClientRect()` and nothing here
|
|
50
|
+
* touches the DOM. A press before the start or past the end resolves to that end rather than to
|
|
51
|
+
* a value outside the bounds, which is what makes a drag that leaves the rail keep working.
|
|
52
|
+
*/
|
|
53
|
+
export declare function rangePositionToValue(clientX: number, rect: {
|
|
54
|
+
left: number;
|
|
55
|
+
width: number;
|
|
56
|
+
}, math: Pick<RangeSliderMath, 'min' | 'max' | 'step'>): number;
|
|
57
|
+
/**
|
|
58
|
+
* How far one thumb may travel: out to the bound on its own side, and up to *the other thumb's
|
|
59
|
+
* current value* on the other. This is the clamp that stops the two crossing, and it is also what
|
|
60
|
+
* `aria-valuemin` / `aria-valuemax` report, so the limit a screen reader announces is the limit
|
|
61
|
+
* the thumb actually has.
|
|
62
|
+
*/
|
|
63
|
+
export declare function rangeThumbLimits(thumb: RangeSliderThumb, value: RangeSliderValue, math: Pick<RangeSliderMath, 'min' | 'max'>): {
|
|
64
|
+
lo: number;
|
|
65
|
+
hi: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A candidate value for one thumb, snapped to the grid and then clamped against both its bound
|
|
69
|
+
* and the other thumb.
|
|
70
|
+
*
|
|
71
|
+
* Clamping after snapping is deliberate: the other thumb's value need not be on the grid (a
|
|
72
|
+
* consumer's starting value, a bound that moved), and the dragged thumb has to be able to park
|
|
73
|
+
* exactly on it rather than on the nearest grid point before it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function clampRangeThumb(next: number, thumb: RangeSliderThumb, value: RangeSliderValue, math: Pick<RangeSliderMath, 'min' | 'max' | 'step'>): number;
|
|
76
|
+
/**
|
|
77
|
+
* A `modelValue` as this control will treat it: both ends snapped into the bounds, lowest first.
|
|
78
|
+
*
|
|
79
|
+
* A consumer can pass `[4800, 1200]`, a pair outside the bounds, or a pair from before `min`/`max`
|
|
80
|
+
* changed. Rendering that as given would draw a negative range and report a maximum below the
|
|
81
|
+
* minimum, so every read goes through here instead of trusting the prop.
|
|
82
|
+
*/
|
|
83
|
+
export declare function normalizeRangeValue(value: RangeSliderValue, math: Pick<RangeSliderMath, 'min' | 'max' | 'step'>): RangeSliderValue;
|
|
84
|
+
/**
|
|
85
|
+
* Which thumb a press at `target` should move: the nearer one.
|
|
86
|
+
*
|
|
87
|
+
* With both thumbs on the same value the distances tie, and the tie is broken by direction — the
|
|
88
|
+
* minimum thumb takes a press below them and the maximum thumb one above — so a collapsed range
|
|
89
|
+
* can always be opened again from either side. (A press exactly halfway between two distinct
|
|
90
|
+
* thumbs is the other tie, and either answer is correct; it goes to the maximum.)
|
|
91
|
+
*/
|
|
92
|
+
export declare function nearestRangeThumb(target: number, value: RangeSliderValue): RangeSliderThumb;
|
|
93
|
+
/**
|
|
94
|
+
* The value a key press moves a thumb to, or `null` for a key this control does not own (so the
|
|
95
|
+
* caller leaves the event alone rather than swallowing `Tab`).
|
|
96
|
+
*
|
|
97
|
+
* Spec "Range slider" → Keyboard: `ArrowRight`/`ArrowUp` and `ArrowLeft`/`ArrowDown` by `step`,
|
|
98
|
+
* the same four with `Shift` — and `PageUp`/`PageDown` — by `largeStep`, `Home`/`End` to the
|
|
99
|
+
* thumb's own limits. A stepped result is snapped and clamped, and may equal the value it started
|
|
100
|
+
* from (a thumb against its neighbour), which the caller reads as "nothing moved".
|
|
101
|
+
*
|
|
102
|
+
* `Home`/`End` return the limit itself, unsnapped: the limit on the inner side is the other
|
|
103
|
+
* thumb's value, which need not be on the grid, and "go to your own highest value" has to land on
|
|
104
|
+
* it exactly rather than on the nearest grid point before it.
|
|
105
|
+
*/
|
|
106
|
+
export declare function rangeKeyTransition(key: string, shiftKey: boolean, thumb: RangeSliderThumb, value: RangeSliderValue, math: RangeSliderMath): number | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RatingProps } from './types.js';
|
|
2
|
+
declare var __VLS_17: {};
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
emptyAction?: (props: typeof __VLS_17) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<RatingProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<RatingProps> & Readonly<{}>, {
|
|
7
|
+
size: import('./types.js').RatingSize;
|
|
8
|
+
classes: Partial<Record<import('./types.js').RatingPart, string>>;
|
|
9
|
+
href: string | null;
|
|
10
|
+
as: string | import('vue').Component;
|
|
11
|
+
count: number;
|
|
12
|
+
showValue: boolean;
|
|
13
|
+
showCount: boolean;
|
|
14
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
18
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
19
|
+
new (): {
|
|
20
|
+
$slots: S;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RatingPart, RatingSize } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The five-star row (spec "Rating" → Anatomy, part 1), factored out of `Rating.vue` because the
|
|
4
|
+
* markup is rendered from three different branches there (static, no-reviews, linked) and the two
|
|
5
|
+
* SVGs per star make inlining it three times a maintenance hazard rather than a real duplication
|
|
6
|
+
* saving. Not exported from the package: it is `Rating`'s own implementation detail, the same way
|
|
7
|
+
* `Select`'s option row is not a component of its own either.
|
|
8
|
+
*/
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
value: number;
|
|
11
|
+
size: RatingSize;
|
|
12
|
+
classes?: Partial<Record<RatingPart, string>>;
|
|
13
|
+
};
|
|
14
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
/** The design spec's two sizes (spec "Rating" → Sizes): the star and gap grow, the value/count
|
|
3
|
+
* text stays 0.875rem at both. */
|
|
4
|
+
export type RatingSize = 'md' | 'lg';
|
|
5
|
+
/**
|
|
6
|
+
* The parts a consumer can restyle through `classes`, named as the spec's anatomy names them, plus
|
|
7
|
+
* two structural parts the anatomy diagram does not number: `empty` (the no-reviews text) and
|
|
8
|
+
* `link` (the anchor the linked variant wraps its content in — see `Rating.vue`'s own comment on
|
|
9
|
+
* why that is a second element rather than the root itself changing tag).
|
|
10
|
+
*/
|
|
11
|
+
export type RatingPart = 'root' | 'stars' | 'star' | 'value' | 'count' | 'empty' | 'link';
|
|
12
|
+
export interface RatingProps {
|
|
13
|
+
/**
|
|
14
|
+
* Average rating, 0–5. Rounded to the nearest half star for both the stars and the visible
|
|
15
|
+
* value (spec "Rating" → Properties). Out of range input is clamped rather than rejected — see
|
|
16
|
+
* `roundRatingToHalf` (`src/utils/rating.ts`).
|
|
17
|
+
*/
|
|
18
|
+
value: number;
|
|
19
|
+
/** Number of reviews. `0` renders the no-reviews state instead of a "0.0" rating. */
|
|
20
|
+
count?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Shows the numeric value ("4.5"). Purely visual: the one accessible sentence always states the
|
|
23
|
+
* value regardless of this prop (spec "Rating" → Variants, "Stars only" row: "still carries the
|
|
24
|
+
* full accessible name").
|
|
25
|
+
*/
|
|
26
|
+
showValue?: boolean;
|
|
27
|
+
/** Shows the review count. Purely visual, same accessible-name rule as `showValue`. */
|
|
28
|
+
showCount?: boolean;
|
|
29
|
+
/** Star and gap size. Value/count text stays 0.875rem at both sizes. */
|
|
30
|
+
size?: RatingSize;
|
|
31
|
+
/**
|
|
32
|
+
* Renders the linked variant: the whole rating becomes one link to the reviews (e.g.
|
|
33
|
+
* `"#reviews"`). Ignored while `count` is `0` — there is nothing to jump to, and nesting an `<a>`
|
|
34
|
+
* around the no-reviews state would collide with that state's own `emptyAction` slot, which is
|
|
35
|
+
* free to render its own link.
|
|
36
|
+
*/
|
|
37
|
+
href?: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Render the linked variant's anchor as a different component (e.g. a router link), which
|
|
40
|
+
* receives the destination as `to` instead of `href` — the same contract as `Link`'s `as`.
|
|
41
|
+
*/
|
|
42
|
+
as?: string | Component;
|
|
43
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
44
|
+
classes?: Partial<Record<RatingPart, string>>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SearchBarPart, SearchBarProps, SearchBarSize, SearchResultItem, SearchResultType, SearchSelectType } from './types.js';
|
|
2
|
+
declare var __VLS_24: {
|
|
3
|
+
item: SearchResultItem;
|
|
4
|
+
type: SearchResultType | undefined;
|
|
5
|
+
}, __VLS_27: {};
|
|
6
|
+
type __VLS_Slots = {} & {
|
|
7
|
+
item?: (props: typeof __VLS_24) => any;
|
|
8
|
+
} & {
|
|
9
|
+
empty?: (props: typeof __VLS_27) => any;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: import('vue').DefineComponent<SearchBarProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
12
|
+
select: (item: SearchResultItem, type: SearchSelectType) => any;
|
|
13
|
+
"update:modelValue": (value: string) => any;
|
|
14
|
+
clearRecent: () => any;
|
|
15
|
+
submit: (query: string) => any;
|
|
16
|
+
}, string, import('vue').PublicProps, Readonly<SearchBarProps> & Readonly<{
|
|
17
|
+
onSelect?: ((item: SearchResultItem, type: SearchSelectType) => any) | undefined;
|
|
18
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
19
|
+
onClearRecent?: (() => any) | undefined;
|
|
20
|
+
onSubmit?: ((query: string) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
size: SearchBarSize;
|
|
23
|
+
label: string;
|
|
24
|
+
classes: Partial<Record<SearchBarPart, string>>;
|
|
25
|
+
modelValue: string;
|
|
26
|
+
placeholder: string;
|
|
27
|
+
results: import('./types.js').SearchResults;
|
|
28
|
+
loading: boolean;
|
|
29
|
+
pill: boolean;
|
|
30
|
+
messages: Partial<import('../../index.js').UiMessages>;
|
|
31
|
+
action: string;
|
|
32
|
+
teleport: boolean | string;
|
|
33
|
+
recent: string[];
|
|
34
|
+
popular: string[];
|
|
35
|
+
showRecent: boolean;
|
|
36
|
+
resultTypes: SearchResultType[];
|
|
37
|
+
shortcut: boolean;
|
|
38
|
+
autofocus: boolean;
|
|
39
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
40
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
41
|
+
declare const _default: typeof __VLS_export;
|
|
42
|
+
export default _default;
|
|
43
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
44
|
+
new (): {
|
|
45
|
+
$slots: S;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { MatchParts } from '../select/useOptionList.js';
|
|
2
|
+
import { SearchBarPart, SearchRow, SearchSection } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `SearchBar`'s results panel: the non-modal popup below the field.
|
|
5
|
+
*
|
|
6
|
+
* It is deliberately **not** `SelectPanel`. A select's panel is one flat kind of row; this one draws
|
|
7
|
+
* four different views (idle, results, none, loading), rich rows with a thumbnail and a price, chips,
|
|
8
|
+
* a "See all" footer row and a no-results message — and it has no search field of its own, because
|
|
9
|
+
* the search field *is* the control. What the two share is the part that is genuinely the same: the
|
|
10
|
+
* keyboard and the active row (`useListbox`), the open/close wiring (`usePopover`) and the
|
|
11
|
+
* highlight arithmetic (`matchRange`), all of which live outside both panels.
|
|
12
|
+
*
|
|
13
|
+
* Everything here is a prop. The panel owns no state beyond the DOM it draws: the panel element,
|
|
14
|
+
* which `useFloating` positions and `useOverlay` measures "inside" against, the press guard that
|
|
15
|
+
* keeps a press on a row from blurring the field, and scrolling the active row into view.
|
|
16
|
+
*/
|
|
17
|
+
type Classes = Partial<Record<SearchBarPart, string>>;
|
|
18
|
+
type __VLS_Props = {
|
|
19
|
+
/**
|
|
20
|
+
* The panel element's own id, which is also its `data-eldra-overlay-owner`. `useOverlay`
|
|
21
|
+
* reads that attribute to recognise parts of an overlay that are not inside its content
|
|
22
|
+
* element — and, since this panel is normally teleported to `body`, it is what marks anything
|
|
23
|
+
* a consumer teleports out of the panel's own slots as still belonging to the overlay.
|
|
24
|
+
*/
|
|
25
|
+
panelId: string;
|
|
26
|
+
/** The listbox's id — what the field's `aria-controls` points at. */
|
|
27
|
+
listboxId: string;
|
|
28
|
+
/** Which of the spec's four views is showing. Exactly one at a time. */
|
|
29
|
+
view: 'idle' | 'results' | 'none' | 'loading';
|
|
30
|
+
/** The groups to draw, in order. */
|
|
31
|
+
sections: SearchSection[];
|
|
32
|
+
/** The chips of the `none` view, which belong to no group. */
|
|
33
|
+
looseChips: SearchRow[];
|
|
34
|
+
/** The "See all N results" row, when there is one. Always the last option. */
|
|
35
|
+
viewAll?: SearchRow;
|
|
36
|
+
/**
|
|
37
|
+
* The element id of a row, which is what `aria-activedescendant` points at — `undefined` for a
|
|
38
|
+
* value with no row of its own, which is an id the panel then does not write.
|
|
39
|
+
*/
|
|
40
|
+
optionId: (value: string) => string | undefined;
|
|
41
|
+
/** The active row's value, or `undefined`. */
|
|
42
|
+
activeValue?: string;
|
|
43
|
+
/** Per row value, where the query matched its title. */
|
|
44
|
+
highlights: Map<string, MatchParts | null>;
|
|
45
|
+
/** The listbox's accessible name ("Search suggestions"). */
|
|
46
|
+
listboxLabel: string;
|
|
47
|
+
/** The `none` view's title and the line under it. */
|
|
48
|
+
emptyTitle: string;
|
|
49
|
+
emptyAdvice: string;
|
|
50
|
+
/** Inline position from `useFloating`, and the placement it resolved to. */
|
|
51
|
+
panelStyle?: Record<string, string>;
|
|
52
|
+
placement?: string;
|
|
53
|
+
classes?: Classes;
|
|
54
|
+
/**
|
|
55
|
+
* Renders the panel **flat**: no floating position, no border/shadow/radius, no popover
|
|
56
|
+
* entrance — it fills its parent instead (`SearchModal`, whose own frame already draws those).
|
|
57
|
+
* `false` (the default) is `SearchBar`'s own popup box, unchanged.
|
|
58
|
+
*/
|
|
59
|
+
flat?: boolean;
|
|
60
|
+
};
|
|
61
|
+
declare var __VLS_1: {}, __VLS_3: {
|
|
62
|
+
item: import('./types.js').SearchResultItem;
|
|
63
|
+
type: import('./types.js').SearchResultType | undefined;
|
|
64
|
+
};
|
|
65
|
+
type __VLS_Slots = {} & {
|
|
66
|
+
empty?: (props: typeof __VLS_1) => any;
|
|
67
|
+
} & {
|
|
68
|
+
item?: (props: typeof __VLS_3) => any;
|
|
69
|
+
};
|
|
70
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {
|
|
71
|
+
root: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
72
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
73
|
+
select: (row: SearchRow, event: MouseEvent) => any;
|
|
74
|
+
activate: (value: string) => any;
|
|
75
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
76
|
+
onSelect?: ((row: SearchRow, event: MouseEvent) => any) | undefined;
|
|
77
|
+
onActivate?: ((value: string) => any) | undefined;
|
|
78
|
+
}>, {
|
|
79
|
+
classes: Classes;
|
|
80
|
+
flat: boolean;
|
|
81
|
+
panelStyle: Record<string, string>;
|
|
82
|
+
placement: string;
|
|
83
|
+
activeValue: string;
|
|
84
|
+
viewAll: SearchRow;
|
|
85
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
86
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
87
|
+
declare const _default: typeof __VLS_export;
|
|
88
|
+
export default _default;
|
|
89
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
90
|
+
new (): {
|
|
91
|
+
$slots: S;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who owns a global shortcut key.
|
|
3
|
+
*
|
|
4
|
+
* The design spec's Search bar → Behaviour says "`/` anywhere on the page … focuses the header
|
|
5
|
+
* search" — *the* header search, singular. A page can hold more than one search bar (a header one
|
|
6
|
+
* and the Search page's own lg field, a collection toolbar), and each listens on `document`, so
|
|
7
|
+
* without an owner every one of them would answer the same keystroke: the last listener to run
|
|
8
|
+
* would win the focus and the others would have already called `preventDefault()`, which is a
|
|
9
|
+
* shortcut that lands somewhere unpredictable. The Search modal (spec "Search modal" → Behaviour)
|
|
10
|
+
* shares the exact same `/` rule with `SearchBar` — "If the page uses SearchModal instead, it opens
|
|
11
|
+
* that" — so it claims the identical queue below rather than a queue of its own: whichever of them
|
|
12
|
+
* mounted first (with its own shortcut turned on) owns the key, which is what "`/` opens it only
|
|
13
|
+
* when no SearchBar currently owns the `/` shortcut" reduces to.
|
|
14
|
+
*
|
|
15
|
+
* `⌘K`/`Ctrl+K` is a second, independent key: the spec's own "Only one search modal on a page may
|
|
16
|
+
* enable it" rule needs a queue that a `SearchBar` never joins (it has no `⌘K` shortcut of its
|
|
17
|
+
* own), so contenders are grouped by `kind` rather than kept in one list. `'/'` is the default, so
|
|
18
|
+
* every existing call site (`claimShortcut(token)`, with no second argument) keeps claiming exactly
|
|
19
|
+
* the queue it always has.
|
|
20
|
+
*
|
|
21
|
+
* That is cross-component state — instances know nothing about each other — so it lives in one
|
|
22
|
+
* module-level list per kind rather than in a provider, exactly as `openRegistry` does for "only one
|
|
23
|
+
* open at a time". Each list is **ordered by claim**, so the first instance mounted with its
|
|
24
|
+
* shortcut on owns that key and the others stand behind it; when the owner unmounts (or its
|
|
25
|
+
* shortcut prop goes off), it drops out and the next in line owns it without anything having to be
|
|
26
|
+
* re-mounted.
|
|
27
|
+
*
|
|
28
|
+
* Ownership is read at keystroke time, never cached, so a claim or a release takes effect on the
|
|
29
|
+
* very next keystroke with no reactivity involved.
|
|
30
|
+
*/
|
|
31
|
+
export type ShortcutKind = '/' | 'modal';
|
|
32
|
+
/** Claim a shortcut. Claiming twice is a no-op, so a re-run watcher cannot jump the queue. */
|
|
33
|
+
export declare function claimShortcut(token: object, kind?: ShortcutKind): void;
|
|
34
|
+
/** Give it up. Safe to call for a token that never claimed it. */
|
|
35
|
+
export declare function releaseShortcut(token: object, kind?: ShortcutKind): void;
|
|
36
|
+
/** Whether this token is the one that should answer this kind of shortcut. */
|
|
37
|
+
export declare function ownsShortcut(token: object, kind?: ShortcutKind): boolean;
|
|
38
|
+
/** The current owner of a kind, or `null`. Exposed for tests. */
|
|
39
|
+
export declare function shortcutOwner(kind?: ShortcutKind): object | null;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { UiMessages } from '../../composables/useMessages.js';
|
|
2
|
+
/** One row of a search results panel. Only products carry a price and a thumbnail. */
|
|
3
|
+
export interface SearchResultItem {
|
|
4
|
+
/** Stable per row: the key Vue renders it with, and part of its element id. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** The row's own text. The part of it the query matched is marked. */
|
|
7
|
+
title: string;
|
|
8
|
+
/** Where the row goes. Rows are real links, so a click, a middle click and Enter all work. */
|
|
9
|
+
href: string;
|
|
10
|
+
/** A product's price, already formatted by the store ("$96.00"). */
|
|
11
|
+
price?: string;
|
|
12
|
+
/** A product's thumbnail. */
|
|
13
|
+
image?: string;
|
|
14
|
+
/** The thumbnail's alt text. Empty (or absent) marks it decorative beside the title. */
|
|
15
|
+
imageAlt?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A predictive-search response (spec "Search bar" → Properties, `results`).
|
|
19
|
+
*
|
|
20
|
+
* `total` is the *whole* result count, not the number of rows here: the panel shows at most 4
|
|
21
|
+
* products, 3 collections and 3 journal-and-help rows, and the "See all N results" row carries
|
|
22
|
+
* `total`.
|
|
23
|
+
*/
|
|
24
|
+
export interface SearchResults {
|
|
25
|
+
products: SearchResultItem[];
|
|
26
|
+
collections: SearchResultItem[];
|
|
27
|
+
articles: SearchResultItem[];
|
|
28
|
+
pages: SearchResultItem[];
|
|
29
|
+
total: number;
|
|
30
|
+
}
|
|
31
|
+
/** The four result groups a store can turn on (spec "Search bar" → Properties, `resultTypes`). */
|
|
32
|
+
export type SearchResultType = 'products' | 'collections' | 'articles' | 'pages';
|
|
33
|
+
/**
|
|
34
|
+
* What the `select` event carries alongside the chosen item: one of the four result types, or
|
|
35
|
+
* `viewAll` for the last row, which is also a link and also worth knowing about.
|
|
36
|
+
*/
|
|
37
|
+
export type SearchSelectType = SearchResultType | 'viewAll';
|
|
38
|
+
/**
|
|
39
|
+
* The parts a consumer can restyle through `classes`, named as the spec's anatomy names them.
|
|
40
|
+
*
|
|
41
|
+
* Four are not in the API contract's list but are in the spec's own anatomy, and a part the component
|
|
42
|
+
* draws and a consumer cannot reach is not a part: `listbox` (the panel is the popup box; the
|
|
43
|
+
* listbox is the element inside it that owns the options, so the no-results message and the
|
|
44
|
+
* loading rows can be siblings of it rather than invalid children), `chip` (anatomy item 9),
|
|
45
|
+
* `clearRecent` (the idle view's "Clear recent searches" row) and `liveRegion` (anatomy item 11).
|
|
46
|
+
* `itemArrow` is the Sizes table's "Active arrow".
|
|
47
|
+
*/
|
|
48
|
+
export type SearchBarPart = 'root' | 'form' | 'field' | 'leadingIcon' | 'clearButton' | 'busy' | 'shortcutHint' | 'panel' | 'listbox' | 'section' | 'sectionHeading' | 'item' | 'itemImage' | 'itemTitle' | 'itemMeta' | 'itemArrow' | 'recent' | 'clearRecent' | 'popular' | 'chip' | 'viewAll' | 'loading' | 'empty' | 'liveRegion';
|
|
49
|
+
/** The spec's two search-bar sizes: 2.5rem in a header or toolbar, 3rem on the Search page. */
|
|
50
|
+
export type SearchBarSize = 'md' | 'lg';
|
|
51
|
+
export interface SearchBarProps {
|
|
52
|
+
/** The query (two-way). */
|
|
53
|
+
modelValue?: string;
|
|
54
|
+
/** `md` in the header and toolbars, `lg` on the Search page. */
|
|
55
|
+
size?: SearchBarSize;
|
|
56
|
+
/** Fully rounded field, for a header. */
|
|
57
|
+
pill?: boolean;
|
|
58
|
+
/** The form's action. The query is submitted as `q`. Defaults to `/search`. */
|
|
59
|
+
action?: string;
|
|
60
|
+
/** The field's accessible name. Defaults to `messages.searchTheShop`. */
|
|
61
|
+
label?: string;
|
|
62
|
+
/** The placeholder. Defaults to the label. */
|
|
63
|
+
placeholder?: string;
|
|
64
|
+
/** The predictive-search response. */
|
|
65
|
+
results?: SearchResults;
|
|
66
|
+
/** A request is in flight. The loading view shows only after 300ms. */
|
|
67
|
+
loading?: boolean;
|
|
68
|
+
/** Up to 5 recent queries. Read from browser storage when this is not given. */
|
|
69
|
+
recent?: string[];
|
|
70
|
+
/** Popular searches, max 6. Also the suggestions under "No results". */
|
|
71
|
+
popular?: string[];
|
|
72
|
+
/** Shows the recent-searches list. Defaults to `true`. */
|
|
73
|
+
showRecent?: boolean;
|
|
74
|
+
/** Which groups appear, in the spec's fixed order. Defaults to all four. */
|
|
75
|
+
resultTypes?: SearchResultType[];
|
|
76
|
+
/** Enables the `/` shortcut and its hint. Defaults to `true`. */
|
|
77
|
+
shortcut?: boolean;
|
|
78
|
+
/** Focus the field on mount. Only on the Search page itself. */
|
|
79
|
+
autofocus?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Where the results panel is rendered. `true` (default) teleports it to `document.body` — or to
|
|
82
|
+
* the open native `<dialog>` the field sits in, which renders in the browser's top layer and
|
|
83
|
+
* would otherwise cover it. A string is a CSS selector for your own target. `false` keeps the
|
|
84
|
+
* panel inside the control, which is only right when nothing above it clips or stacks over it;
|
|
85
|
+
* a search bar usually lives in a header, which is exactly such an ancestor.
|
|
86
|
+
*
|
|
87
|
+
* Read once, like every positioning option.
|
|
88
|
+
*/
|
|
89
|
+
teleport?: boolean | string;
|
|
90
|
+
/** Message overrides for this control alone. */
|
|
91
|
+
messages?: Partial<UiMessages>;
|
|
92
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
93
|
+
classes?: Partial<Record<SearchBarPart, string>>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* One navigable row of the panel, for the panel component and for `useListbox`.
|
|
97
|
+
*
|
|
98
|
+
* Every row is an option — the spec's Accessibility notes say so ("Every row, chip and 'See all' is
|
|
99
|
+
* an `<a role="option">`") — and `kind` is what choosing one does: follow a link (`result`,
|
|
100
|
+
* `viewAll`), fill the field and search (`recent`, `chip`), or empty the history (`clearRecent`).
|
|
101
|
+
*/
|
|
102
|
+
export interface SearchRow {
|
|
103
|
+
/** Unique within the panel. `useListbox` moves between rows by this, and ids are built from it. */
|
|
104
|
+
value: string;
|
|
105
|
+
/** The row's text. Also `useListbox`'s label. */
|
|
106
|
+
label: string;
|
|
107
|
+
kind: 'result' | 'recent' | 'chip' | 'viewAll' | 'clearRecent';
|
|
108
|
+
/** Which group a `result` row came from. */
|
|
109
|
+
type?: SearchResultType;
|
|
110
|
+
/** The item a `result` row draws, and what the `item` slot and the `select` event carry. */
|
|
111
|
+
item?: SearchResultItem;
|
|
112
|
+
/** Where a link row goes. `recent`, `chip` and `clearRecent` rows have none: they never navigate. */
|
|
113
|
+
href?: string;
|
|
114
|
+
}
|
|
115
|
+
/** One block of the panel: a heading and the rows under it. */
|
|
116
|
+
export interface SearchSection {
|
|
117
|
+
key: string;
|
|
118
|
+
kind: 'result' | 'recent' | 'popular';
|
|
119
|
+
heading: string;
|
|
120
|
+
headingId: string;
|
|
121
|
+
rows: SearchRow[];
|
|
122
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SearchModalPart, SearchModalProps, SearchResultItem, SearchResultType, SearchSelectType } from './types.js';
|
|
2
|
+
declare var __VLS_16: {
|
|
3
|
+
item: SearchResultItem;
|
|
4
|
+
type: SearchResultType | undefined;
|
|
5
|
+
}, __VLS_19: {};
|
|
6
|
+
type __VLS_Slots = {} & {
|
|
7
|
+
item?: (props: typeof __VLS_16) => any;
|
|
8
|
+
} & {
|
|
9
|
+
empty?: (props: typeof __VLS_19) => any;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: import('vue').DefineComponent<SearchModalProps, {
|
|
12
|
+
close: (returnValue?: string) => void;
|
|
13
|
+
isTop: import('vue').ComputedRef<boolean>;
|
|
14
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
15
|
+
select: (item: SearchResultItem, type: SearchSelectType) => any;
|
|
16
|
+
"update:modelValue": (value: boolean) => any;
|
|
17
|
+
close: (reason: string) => any;
|
|
18
|
+
cancel: () => any;
|
|
19
|
+
clearRecent: () => any;
|
|
20
|
+
submit: (query: string) => any;
|
|
21
|
+
"update:query": (value: string) => any;
|
|
22
|
+
}, string, import('vue').PublicProps, Readonly<SearchModalProps> & Readonly<{
|
|
23
|
+
onSelect?: ((item: SearchResultItem, type: SearchSelectType) => any) | undefined;
|
|
24
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
25
|
+
onClose?: ((reason: string) => any) | undefined;
|
|
26
|
+
onCancel?: (() => any) | undefined;
|
|
27
|
+
onClearRecent?: (() => any) | undefined;
|
|
28
|
+
onSubmit?: ((query: string) => any) | undefined;
|
|
29
|
+
"onUpdate:query"?: ((value: string) => any) | undefined;
|
|
30
|
+
}>, {
|
|
31
|
+
classes: Partial<Record<SearchModalPart, string>>;
|
|
32
|
+
modelValue: boolean;
|
|
33
|
+
placeholder: string;
|
|
34
|
+
results: import('./types.js').SearchResults;
|
|
35
|
+
loading: boolean;
|
|
36
|
+
ariaLabel: string;
|
|
37
|
+
messages: Partial<import('../../index.js').UiMessages>;
|
|
38
|
+
query: string;
|
|
39
|
+
action: string;
|
|
40
|
+
recent: string[];
|
|
41
|
+
popular: string[];
|
|
42
|
+
showRecent: boolean;
|
|
43
|
+
resultTypes: SearchResultType[];
|
|
44
|
+
shortcut: boolean;
|
|
45
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
46
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
47
|
+
declare const _default: typeof __VLS_export;
|
|
48
|
+
export default _default;
|
|
49
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
50
|
+
new (): {
|
|
51
|
+
$slots: S;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { UiMessages } from '../../composables/useMessages.js';
|
|
2
|
+
import { SearchBarPart, SearchResultItem, SearchResultType, SearchResults, SearchRow, SearchSection, SearchSelectType } from '../search-bar/types.js';
|
|
3
|
+
export type { SearchResultItem, SearchResultType, SearchResults, SearchRow, SearchSection, SearchSelectType, };
|
|
4
|
+
/**
|
|
5
|
+
* The parts a consumer can restyle through `classes`. The seven the modal's own frame draws
|
|
6
|
+
* (`root`, `form`, `field`, `leadingIcon`, `clear`, `close`, `results`, `footer`), plus every part
|
|
7
|
+
* of the reused `SearchResultsPanel` (`panel`, `listbox`, `section`, … `liveRegion`) — `classes` is
|
|
8
|
+
* forwarded straight into that child, so a consumer restyles the frame and the rows through one
|
|
9
|
+
* prop, the rows named exactly as `SearchBar`'s own anatomy already names them (controller decision:
|
|
10
|
+
* "align with SearchBar's part names where the same thing is meant").
|
|
11
|
+
*
|
|
12
|
+
* `results` is the frame's own bounding box around the reused panel (`min-h-0 flex-1 overflow-
|
|
13
|
+
* hidden`) — distinct from that panel's own `panel` part, which is the scrollable box inside it and
|
|
14
|
+
* is the exact same element `SearchBar`'s popup uses, just drawn `flat` (see `SearchResultsPanel`'s
|
|
15
|
+
* own `flat` prop).
|
|
16
|
+
*/
|
|
17
|
+
export type SearchModalPart = 'root' | 'form' | 'field' | 'leadingIcon' | 'clear' | 'close' | 'results' | 'footer' | SearchBarPart;
|
|
18
|
+
export interface SearchModalProps {
|
|
19
|
+
/** Shows the modal with `showModal()` when `true`, closes it when `false` (two-way). */
|
|
20
|
+
modelValue?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The query (two-way, its own named `v-model:query` rather than `modelValue` — this component
|
|
23
|
+
* already uses `modelValue` for its open/closed state, the way every other modal surface in this
|
|
24
|
+
* package does). Reset to `""` whenever the modal closes, by any route.
|
|
25
|
+
*/
|
|
26
|
+
query?: string;
|
|
27
|
+
/** The dialog's accessible name (package rule: the accessible-name-only prop is always
|
|
28
|
+
* `ariaLabel`, never a bare noun — see `Drawer`'s own `ariaLabel`). Defaults to
|
|
29
|
+
* `messages.search` ("Search"), the spec's own `<dialog aria-label="Search">`. */
|
|
30
|
+
ariaLabel?: string;
|
|
31
|
+
/** The predictive-search response, as `SearchBar`'s. */
|
|
32
|
+
results?: SearchResults;
|
|
33
|
+
/** A request is in flight. The loading view shows only after 300ms, as `SearchBar`'s. */
|
|
34
|
+
loading?: boolean;
|
|
35
|
+
/** Up to 5 recent queries. Read from browser storage — the same key `SearchBar` reads — when
|
|
36
|
+
* this is not given. */
|
|
37
|
+
recent?: string[];
|
|
38
|
+
/** Popular searches, max 6. Also the suggestions under "No results". */
|
|
39
|
+
popular?: string[];
|
|
40
|
+
/** Shows the recent-searches list. Defaults to `true`. */
|
|
41
|
+
showRecent?: boolean;
|
|
42
|
+
/** Which result groups appear, in the spec's fixed order. Defaults to all four. */
|
|
43
|
+
resultTypes?: SearchResultType[];
|
|
44
|
+
/** The field's placeholder. Defaults to `messages.searchTheShop`. */
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
/** The form's action. The query is submitted as `q`. Defaults to `/search`. */
|
|
47
|
+
action?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Enables the `/` and `⌘K`/`Ctrl+K` shortcuts (spec: "Only one search modal on a page may enable
|
|
50
|
+
* it"). `/` opens this modal only while no `SearchBar` on the page currently owns that key (see
|
|
51
|
+
* `shortcutOwner.ts`); `⌘K`/`Ctrl+K` always opens it, from anywhere. Defaults to `true`.
|
|
52
|
+
*/
|
|
53
|
+
shortcut?: boolean;
|
|
54
|
+
/** Message overrides for this control alone. */
|
|
55
|
+
messages?: Partial<UiMessages>;
|
|
56
|
+
/** Per-part class overrides, merged with `tailwind-merge`. Forwarded to the reused
|
|
57
|
+
* `SearchResultsPanel` for every part that is its own. */
|
|
58
|
+
classes?: Partial<Record<SearchModalPart, string>>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SectionBackground, SectionProps, SectionSpacing } from './types.js';
|
|
2
|
+
declare var __VLS_8: {};
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
default?: (props: typeof __VLS_8) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<SectionProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SectionProps> & Readonly<{}>, {
|
|
7
|
+
spacing: SectionSpacing;
|
|
8
|
+
classes: Partial<Record<import('./types.js').SectionPart, string>>;
|
|
9
|
+
as: string;
|
|
10
|
+
ariaLabel: string | null;
|
|
11
|
+
background: SectionBackground;
|
|
12
|
+
labelledBy: string | null;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
18
|
+
new (): {
|
|
19
|
+
$slots: S;
|
|
20
|
+
};
|
|
21
|
+
};
|