@lilydesignsystem/svelte-headless 0.6.1 → 0.6.2
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 +6 -1
- package/LICENSE.md +8 -8
- package/README.md +453 -0
- package/dist/components/AccordionLink/AccordionLink.svelte +12 -2
- package/dist/components/AccordionLink/AccordionLink.svelte.d.ts +4 -0
- package/dist/components/ActionBar/ActionBar.svelte +2 -2
- package/dist/components/ActionGroup/ActionGroup.svelte +31 -7
- package/dist/components/ActionGroup/ActionGroup.svelte.d.ts +4 -4
- package/dist/components/AddressographBox/AddressographBox.svelte +5 -1
- package/dist/components/AiLabel/AiLabel.svelte +2 -2
- package/dist/components/Alert/Alert.svelte +1 -3
- package/dist/components/AlertDialog/AlertDialog.svelte +2 -3
- package/dist/components/Answer/Answer.svelte +5 -1
- package/dist/components/AreaChart/AreaChart.svelte +5 -1
- package/dist/components/AsSaudiyahRaqmAlHuwiyahAlWataniyahInput/AsSaudiyahRaqmAlHuwiyahAlWataniyahInput.svelte +55 -0
- package/dist/components/AsSaudiyahRaqmAlHuwiyahAlWataniyahInput/AsSaudiyahRaqmAlHuwiyahAlWataniyahInput.svelte.d.ts +10 -0
- package/dist/components/AsSaudiyahRaqmAlHuwiyahAlWataniyahView/AsSaudiyahRaqmAlHuwiyahAlWataniyahView.svelte +40 -0
- package/dist/components/AsSaudiyahRaqmAlHuwiyahAlWataniyahView/AsSaudiyahRaqmAlHuwiyahAlWataniyahView.svelte.d.ts +8 -0
- package/dist/components/AustraliaTaxFileNumberInput/AustraliaTaxFileNumberInput.svelte +55 -0
- package/dist/components/AustraliaTaxFileNumberInput/AustraliaTaxFileNumberInput.svelte.d.ts +10 -0
- package/dist/components/AustraliaTaxFileNumberView/AustraliaTaxFileNumberView.svelte +40 -0
- package/dist/components/AustraliaTaxFileNumberView/AustraliaTaxFileNumberView.svelte.d.ts +8 -0
- package/dist/components/Autosuggest/Autosuggest.svelte +175 -8
- package/dist/components/Autosuggest/Autosuggest.svelte.d.ts +18 -4
- package/dist/components/AvatarGroup/AvatarGroup.svelte +5 -1
- package/dist/components/BarChart/BarChart.svelte +5 -1
- package/dist/components/BarcodeImage/BarcodeImage.svelte +7 -1
- package/dist/components/BreadcrumbLink/BreadcrumbLink.svelte +12 -2
- package/dist/components/BreadcrumbLink/BreadcrumbLink.svelte.d.ts +4 -0
- package/dist/components/Byline/Byline.svelte +4 -1
- package/dist/components/CandlestickChart/CandlestickChart.svelte +5 -1
- package/dist/components/Caption/Caption.svelte +1 -0
- package/dist/components/CareCard/CareCard.svelte +1 -0
- package/dist/components/Cascader/Cascader.svelte +7 -1
- package/dist/components/ChatComposer/ChatComposer.svelte +6 -3
- package/dist/components/ChatList/ChatList.svelte +6 -2
- package/dist/components/ChatListItem/ChatListItem.svelte +10 -2
- package/dist/components/ChatListItem/ChatListItem.svelte.d.ts +2 -0
- package/dist/components/ChatMessage/ChatMessage.svelte +6 -2
- package/dist/components/ChatNav/ChatNav.svelte +6 -2
- package/dist/components/CheckListItem/CheckListItem.svelte +4 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.svelte +1 -0
- package/dist/components/ChoroplethChart/ChoroplethChart.svelte +5 -1
- package/dist/components/Citation/Citation.svelte +6 -2
- package/dist/components/Coachmark/Coachmark.svelte +20 -10
- package/dist/components/Code/Code.svelte +6 -2
- package/dist/components/CodeBlock/CodeBlock.svelte +6 -2
- package/dist/components/CollectionListItem/CollectionListItem.svelte +1 -1
- package/dist/components/ColombiaCedulaDeCiudadaniaInput/ColombiaCedulaDeCiudadaniaInput.svelte +55 -0
- package/dist/components/ColombiaCedulaDeCiudadaniaInput/ColombiaCedulaDeCiudadaniaInput.svelte.d.ts +10 -0
- package/dist/components/ColombiaCedulaDeCiudadaniaView/ColombiaCedulaDeCiudadaniaView.svelte +40 -0
- package/dist/components/ColombiaCedulaDeCiudadaniaView/ColombiaCedulaDeCiudadaniaView.svelte.d.ts +8 -0
- package/dist/components/ColumnChart/ColumnChart.svelte +5 -1
- package/dist/components/Combobox/Combobox.svelte +11 -9
- package/dist/components/Comment/Comment.svelte +5 -1
- package/dist/components/ComposedChart/ComposedChart.svelte +5 -1
- package/dist/components/ContentsListItem/ContentsListItem.svelte +4 -1
- package/dist/components/ContentsNav/ContentsNav.svelte +56 -36
- package/dist/components/ContextMenu/ContextMenu.svelte +19 -17
- package/dist/components/ContextualHelp/ContextualHelp.svelte +55 -26
- package/dist/components/ContextualHelp/ContextualHelp.svelte.d.ts +4 -2
- package/dist/components/ConvertDiv/ConvertDiv.svelte +3 -1
- package/dist/components/ConvertFromDiv/ConvertFromDiv.svelte +0 -1
- package/dist/components/ConvertFromUnitDiv/ConvertFromUnitDiv.svelte +0 -1
- package/dist/components/ConvertFromValueDiv/ConvertFromValueDiv.svelte +0 -1
- package/dist/components/ConvertIntoDiv/ConvertIntoDiv.svelte +0 -1
- package/dist/components/ConvertIntoUnitDiv/ConvertIntoUnitDiv.svelte +0 -1
- package/dist/components/ConvertIntoValueDiv/ConvertIntoValueDiv.svelte +0 -1
- package/dist/components/CurrencyInput/CurrencyInput.svelte +61 -8
- package/dist/components/CurrencyInput/CurrencyInput.svelte.d.ts +9 -4
- package/dist/components/DateTimeNowInput/DateTimeNowInput.svelte +18 -16
- package/dist/components/DateTimeNowInput/DateTimeNowInput.svelte.d.ts +3 -3
- package/dist/components/DescriptionList/DescriptionList.svelte +0 -2
- package/dist/components/DescriptionListItem/DescriptionListItem.svelte +0 -2
- package/dist/components/DialGroup/DialGroup.svelte +5 -1
- package/dist/components/Dialog/Dialog.svelte +2 -2
- package/dist/components/Diff/Diff.svelte +5 -1
- package/dist/components/DigitalObjectIdentifierLink/DigitalObjectIdentifierLink.svelte +16 -7
- package/dist/components/DigitalObjectIdentifierLink/DigitalObjectIdentifierLink.svelte.d.ts +4 -2
- package/dist/components/DocumentList/DocumentList.svelte +0 -1
- package/dist/components/DocumentListItem/DocumentListItem.svelte +0 -2
- package/dist/components/Drawer/Drawer.svelte +35 -12
- package/dist/components/DropdownMenu/DropdownMenu.svelte +27 -16
- package/dist/components/EcuadorCedulaDeIdentidadInput/EcuadorCedulaDeIdentidadInput.svelte +55 -0
- package/dist/components/EcuadorCedulaDeIdentidadInput/EcuadorCedulaDeIdentidadInput.svelte.d.ts +10 -0
- package/dist/components/EcuadorCedulaDeIdentidadView/EcuadorCedulaDeIdentidadView.svelte +40 -0
- package/dist/components/EcuadorCedulaDeIdentidadView/EcuadorCedulaDeIdentidadView.svelte.d.ts +8 -0
- package/dist/components/EireIndividualHealthIdentifierView/EireIndividualHealthIdentifierView.svelte +2 -1
- package/dist/components/EspanaTarjetaSanitariaIndividualView/EspanaTarjetaSanitariaIndividualView.svelte +2 -1
- package/dist/components/Event/Event.svelte +6 -2
- package/dist/components/FeatureCard/FeatureCard.svelte +5 -1
- package/dist/components/FeaturePhoto/FeaturePhoto.svelte +4 -1
- package/dist/components/FileTree/FileTree.svelte +20 -5
- package/dist/components/FiveFaceRatingPicker/FiveFaceRatingPicker.svelte +3 -1
- package/dist/components/FiveFaceRatingPickerButton/FiveFaceRatingPickerButton.svelte +2 -2
- package/dist/components/FiveStarRatingPicker/FiveStarRatingPicker.svelte +3 -1
- package/dist/components/FiveStarRatingPickerButton/FiveStarRatingPickerButton.svelte +2 -2
- package/dist/components/FlexStack/FlexStack.svelte +3 -1
- package/dist/components/FloatingPanel/FloatingPanel.svelte +15 -13
- package/dist/components/FunnelChart/FunnelChart.svelte +5 -1
- package/dist/components/GaugeChart/GaugeChart.svelte +5 -1
- package/dist/components/GoToNextSection/GoToNextSection.svelte +2 -3
- package/dist/components/GoToPreviousSection/GoToPreviousSection.svelte +2 -3
- package/dist/components/GoToTop/GoToTop.svelte +0 -2
- package/dist/components/GrailLayoutBottomFooter/GrailLayoutBottomFooter.svelte +4 -1
- package/dist/components/GrailLayoutCenterMain/GrailLayoutCenterMain.svelte +4 -1
- package/dist/components/GrailLayoutLeftAside/GrailLayoutLeftAside.svelte +4 -1
- package/dist/components/GrailLayoutRightAside/GrailLayoutRightAside.svelte +4 -1
- package/dist/components/GrailLayoutTopHeader/GrailLayoutTopHeader.svelte +4 -1
- package/dist/components/GraphicBlock/GraphicBlock.svelte +1 -1
- package/dist/components/Grid/Grid.svelte +12 -3
- package/dist/components/Grid/Grid.svelte.d.ts +2 -0
- package/dist/components/Headline/Headline.svelte +4 -1
- package/dist/components/HeatmapChart/HeatmapChart.svelte +5 -1
- package/dist/components/HeatmapChartWithYearOfDays/HeatmapChartWithYearOfDays.svelte +5 -1
- package/dist/components/Hero/Hero.svelte +6 -2
- package/dist/components/HongKongIdentityCardInput/HongKongIdentityCardInput.svelte +55 -0
- package/dist/components/HongKongIdentityCardInput/HongKongIdentityCardInput.svelte.d.ts +10 -0
- package/dist/components/HongKongIdentityCardView/HongKongIdentityCardView.svelte +40 -0
- package/dist/components/HongKongIdentityCardView/HongKongIdentityCardView.svelte.d.ts +8 -0
- package/dist/components/HorizontalScroller/HorizontalScroller.svelte +1 -0
- package/dist/components/HoverCard/HoverCard.svelte +14 -13
- package/dist/components/IconListItem/IconListItem.svelte +4 -1
- package/dist/components/InputWithMask/InputWithMask.svelte +4 -1
- package/dist/components/IranKodEMelliInput/IranKodEMelliInput.svelte +55 -0
- package/dist/components/IranKodEMelliInput/IranKodEMelliInput.svelte.d.ts +10 -0
- package/dist/components/IranKodEMelliView/IranKodEMelliView.svelte +40 -0
- package/dist/components/IranKodEMelliView/IranKodEMelliView.svelte.d.ts +8 -0
- package/dist/components/Kbd/Kbd.svelte +5 -1
- package/dist/components/KbdShortcut/KbdShortcut.svelte +9 -2
- package/dist/components/LineChart/LineChart.svelte +5 -1
- package/dist/components/Listbox/Listbox.svelte +22 -117
- package/dist/components/Listbox/listbox-machine.d.ts +81 -0
- package/dist/components/Listbox/listbox-machine.js +116 -0
- package/dist/components/Listbox/search-text.d.ts +22 -0
- package/dist/components/Listbox/search-text.js +56 -0
- package/dist/components/Listbox/typeahead.d.ts +19 -0
- package/dist/components/Listbox/typeahead.js +39 -0
- package/dist/components/Loading/Loading.svelte +5 -1
- package/dist/components/MalaysiaKadPengenalanInput/MalaysiaKadPengenalanInput.svelte +55 -0
- package/dist/components/MalaysiaKadPengenalanInput/MalaysiaKadPengenalanInput.svelte.d.ts +10 -0
- package/dist/components/MalaysiaKadPengenalanView/MalaysiaKadPengenalanView.svelte +40 -0
- package/dist/components/MalaysiaKadPengenalanView/MalaysiaKadPengenalanView.svelte.d.ts +8 -0
- package/dist/components/Mark/Mark.svelte +0 -2
- package/dist/components/MentionsInput/MentionsInput.svelte +14 -2
- package/dist/components/Menu/Menu.svelte +1 -3
- package/dist/components/MenuBar/MenuBar.svelte +1 -3
- package/dist/components/MenuGroup/MenuGroup.svelte +6 -1
- package/dist/components/MiddleTruncation/MiddleTruncation.svelte +13 -3
- package/dist/components/MockupBrowser/MockupBrowser.svelte +5 -1
- package/dist/components/MockupLaptop/MockupLaptop.svelte +5 -1
- package/dist/components/MockupPhonePortrait/MockupPhonePortrait.svelte +5 -1
- package/dist/components/MockupShell/MockupShell.svelte +5 -1
- package/dist/components/MockupTabletLandscape/MockupTabletLandscape.svelte +5 -1
- package/dist/components/MockupTabletPortrait/MockupTabletPortrait.svelte +5 -1
- package/dist/components/MockupWatch/MockupWatch.svelte +5 -1
- package/dist/components/MockupWindow/MockupWindow.svelte +5 -1
- package/dist/components/MutuallyExclusive/MutuallyExclusive.svelte +0 -1
- package/dist/components/NavigationMenu/NavigationMenu.svelte +51 -3
- package/dist/components/NavigationMenu/NavigationMenu.svelte.d.ts +4 -0
- package/dist/components/NavigationMenu/overflow-navigation.d.ts +35 -0
- package/dist/components/NavigationMenu/overflow-navigation.js +133 -0
- package/dist/components/NetPromoterScorePicker/NetPromoterScorePicker.svelte +3 -1
- package/dist/components/NetPromoterScorePickerButton/NetPromoterScorePickerButton.svelte +2 -2
- package/dist/components/NigeriaNationalIdentificationNumberInput/NigeriaNationalIdentificationNumberInput.svelte +55 -0
- package/dist/components/NigeriaNationalIdentificationNumberInput/NigeriaNationalIdentificationNumberInput.svelte.d.ts +10 -0
- package/dist/components/NigeriaNationalIdentificationNumberView/NigeriaNationalIdentificationNumberView.svelte +40 -0
- package/dist/components/NigeriaNationalIdentificationNumberView/NigeriaNationalIdentificationNumberView.svelte.d.ts +8 -0
- package/dist/components/Organization/Organization.svelte +6 -2
- package/dist/components/PaginationLink/PaginationLink.svelte +12 -2
- package/dist/components/PaginationLink/PaginationLink.svelte.d.ts +4 -0
- package/dist/components/PakistanComputerizedNationalIdentityCardInput/PakistanComputerizedNationalIdentityCardInput.svelte +55 -0
- package/dist/components/PakistanComputerizedNationalIdentityCardInput/PakistanComputerizedNationalIdentityCardInput.svelte.d.ts +10 -0
- package/dist/components/PakistanComputerizedNationalIdentityCardView/PakistanComputerizedNationalIdentityCardView.svelte +40 -0
- package/dist/components/PakistanComputerizedNationalIdentityCardView/PakistanComputerizedNationalIdentityCardView.svelte.d.ts +8 -0
- package/dist/components/Person/Person.svelte +6 -2
- package/dist/components/PhaseBanner/PhaseBanner.svelte +0 -1
- package/dist/components/Pictogram/Pictogram.svelte +4 -1
- package/dist/components/Picture/Picture.svelte +27 -0
- package/dist/components/Picture/Picture.svelte.d.ts +9 -0
- package/dist/components/PieChart/PieChart.svelte +5 -1
- package/dist/components/Place/Place.svelte +6 -2
- package/dist/components/PopconfirmDialog/PopconfirmDialog.svelte +16 -3
- package/dist/components/Popover/Popover.svelte +39 -24
- package/dist/components/Popover/popover.d.ts +9 -0
- package/dist/components/Popover/popover.js +50 -0
- package/dist/components/Popup/Popup.svelte +40 -25
- package/dist/components/ProductCard/ProductCard.svelte +5 -1
- package/dist/components/ProgressBar/ProgressBar.svelte +0 -1
- package/dist/components/Question/Question.svelte +5 -1
- package/dist/components/RadarChart/RadarChart.svelte +5 -1
- package/dist/components/RedAmberGreenPickerButton/RedAmberGreenPickerButton.svelte +2 -2
- package/dist/components/RedOrangeYellowGreenBluePickerButton/RedOrangeYellowGreenBluePickerButton.svelte +2 -2
- package/dist/components/RelatedContent/RelatedContent.svelte +0 -1
- package/dist/components/Resizable/Resizable.svelte +1 -0
- package/dist/components/RingChart/RingChart.svelte +5 -1
- package/dist/components/SankeyChart/SankeyChart.svelte +5 -1
- package/dist/components/ScatterChart/ScatterChart.svelte +5 -1
- package/dist/components/ScreenReaderSpan/ScreenReaderSpan.svelte +6 -2
- package/dist/components/ScrollArea/ScrollArea.svelte +1 -0
- package/dist/components/ScrollBar/ScrollBar.svelte +78 -16
- package/dist/components/ScrollBar/ScrollBar.svelte.d.ts +13 -1
- package/dist/components/Scroller/Scroller.svelte +4 -1
- package/dist/components/ScrollerBase/ScrollerBase.svelte +1 -1
- package/dist/components/SectionLink/SectionLink.svelte +0 -2
- package/dist/components/SectionList/SectionList.svelte +0 -2
- package/dist/components/SectionListItem/SectionListItem.svelte +0 -2
- package/dist/components/SectionNav/SectionNav.svelte +0 -1
- package/dist/components/Separator/Separator.svelte +1 -0
- package/dist/components/Sheet/Sheet.svelte +32 -11
- package/dist/components/ShowMore/ShowMore.svelte +9 -2
- package/dist/components/SlideOutDrawer/SlideOutDrawer.svelte +33 -10
- package/dist/components/SliderButton/SliderButton.svelte +64 -6
- package/dist/components/SliderButton/SliderButton.svelte.d.ts +8 -2
- package/dist/components/SplitButton/SplitButton.svelte +29 -5
- package/dist/components/SplitButton/SplitButton.svelte.d.ts +3 -3
- package/dist/components/SplitView/SplitView.svelte +1 -0
- package/dist/components/Splitter/Splitter.svelte +1 -0
- package/dist/components/StatusLight/StatusLight.svelte +5 -8
- package/dist/components/StickyPromoBanner/StickyPromoBanner.svelte +1 -0
- package/dist/components/SunburstChart/SunburstChart.svelte +5 -1
- package/dist/components/SuperBanner/SuperBanner.svelte +5 -1
- package/dist/components/TabBar/TabBar.svelte +1 -3
- package/dist/components/Tag/Tag.svelte +10 -2
- package/dist/components/TaiwanGuominShenfenzhengTongyiBianhaoInput/TaiwanGuominShenfenzhengTongyiBianhaoInput.svelte +55 -0
- package/dist/components/TaiwanGuominShenfenzhengTongyiBianhaoInput/TaiwanGuominShenfenzhengTongyiBianhaoInput.svelte.d.ts +10 -0
- package/dist/components/TaiwanGuominShenfenzhengTongyiBianhaoView/TaiwanGuominShenfenzhengTongyiBianhaoView.svelte +40 -0
- package/dist/components/TaiwanGuominShenfenzhengTongyiBianhaoView/TaiwanGuominShenfenzhengTongyiBianhaoView.svelte.d.ts +8 -0
- package/dist/components/TaskBar/TaskBar.svelte +1 -3
- package/dist/components/TextAreaInput/TextAreaInput.svelte +1 -2
- package/dist/components/TextAreaInputWithCharacterCounter/TextAreaInputWithCharacterCounter.svelte +4 -3
- package/dist/components/ThemeProvider/ThemeProvider.svelte +3 -3
- package/dist/components/Tile/Tile.svelte +5 -1
- package/dist/components/TimerButton/TimerButton.svelte +55 -7
- package/dist/components/TimerButton/TimerButton.svelte.d.ts +9 -3
- package/dist/components/ToolBar/ToolBar.svelte +1 -3
- package/dist/components/ToolCallError/ToolCallError.svelte +0 -1
- package/dist/components/ToolCallName/ToolCallName.svelte +0 -2
- package/dist/components/Tooltip/Tooltip.svelte +14 -12
- package/dist/components/Tour/Tour.svelte +5 -4
- package/dist/components/TourList/TourList.svelte +10 -9
- package/dist/components/TourList/TourList.svelte.d.ts +2 -0
- package/dist/components/TransferList/TransferList.svelte +8 -2
- package/dist/components/TreeLink/TreeLink.svelte +12 -2
- package/dist/components/TreeLink/TreeLink.svelte.d.ts +4 -0
- package/dist/components/TreeList/TreeList.svelte +3 -3
- package/dist/components/TreeListItem/TreeListItem.svelte +9 -1
- package/dist/components/TreeMenu/TreeMenu.svelte +40 -1
- package/dist/components/TreeSelect/TreeSelect.svelte +10 -3
- package/dist/components/TuaisceartEireannHealthAndCareNumberView/TuaisceartEireannHealthAndCareNumberView.svelte +2 -1
- package/dist/components/UruguayCedulaDeIdentidadInput/UruguayCedulaDeIdentidadInput.svelte +55 -0
- package/dist/components/UruguayCedulaDeIdentidadInput/UruguayCedulaDeIdentidadInput.svelte.d.ts +10 -0
- package/dist/components/UruguayCedulaDeIdentidadView/UruguayCedulaDeIdentidadView.svelte +40 -0
- package/dist/components/UruguayCedulaDeIdentidadView/UruguayCedulaDeIdentidadView.svelte.d.ts +8 -0
- package/dist/components/VideoPlayer/VideoPlayer.svelte +6 -2
- package/dist/components/VietNamCanCuocCongDanInput/VietNamCanCuocCongDanInput.svelte +55 -0
- package/dist/components/VietNamCanCuocCongDanInput/VietNamCanCuocCongDanInput.svelte.d.ts +10 -0
- package/dist/components/VietNamCanCuocCongDanView/VietNamCanCuocCongDanView.svelte +40 -0
- package/dist/components/VietNamCanCuocCongDanView/VietNamCanCuocCongDanView.svelte.d.ts +8 -0
- package/dist/components/Visible/Visible.svelte +1 -1
- package/dist/components/WarningText/WarningText.svelte +48 -0
- package/dist/components/WarningText/WarningText.svelte.d.ts +13 -0
- package/dist/components/WheelPicker/WheelPicker.svelte +18 -4
- package/dist/components/WheelPicker/wheel-picker.js +18 -3
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/index.md +4 -4
- package/package.json +5 -5
|
@@ -2,19 +2,27 @@
|
|
|
2
2
|
// ScrollBar component
|
|
3
3
|
//
|
|
4
4
|
// A headless scrollbar track element that provides the ARIA scrollbar role
|
|
5
|
-
// and value attributes for a custom scrollbar control. Renders a
|
|
6
|
-
// orientation, value range, and accessible labeling
|
|
7
|
-
//
|
|
5
|
+
// and value attributes for a custom scrollbar control. Renders a focusable
|
|
6
|
+
// <div> with orientation, value range, and accessible labeling, and owns the
|
|
7
|
+
// keyboard: the keys move the bindable value. The consumer provides the
|
|
8
|
+
// visual thumb element as children, scrolls its content to the value, and
|
|
9
|
+
// implements drag handling.
|
|
8
10
|
//
|
|
9
11
|
// Props:
|
|
10
12
|
// className — string, optional. CSS class name.
|
|
11
13
|
// orientation — "vertical" | "horizontal", default "vertical". The scrollbar direction.
|
|
14
|
+
// value — number, default 0. Bindable. The scroll position, reflected in aria-valuenow.
|
|
15
|
+
// min — number, default 0. The start of the range.
|
|
16
|
+
// max — number, default 100. The end of the range.
|
|
17
|
+
// step — number, default 1. The arrow-key increment.
|
|
18
|
+
// pageStep — number, default 10. The Page Up / Page Down increment.
|
|
19
|
+
// controls — string, optional. The id of the scrolled element, via aria-controls.
|
|
12
20
|
// label — string, required. Accessible name for the scrollbar via aria-label.
|
|
13
21
|
// children — Snippet, required. ScrollBar content, typically the draggable thumb element.
|
|
14
22
|
// ...restProps — additional HTML attributes spread onto the <div>.
|
|
15
23
|
//
|
|
16
24
|
// Syntax:
|
|
17
|
-
// <ScrollBar orientation="vertical" label="Scroll">
|
|
25
|
+
// <ScrollBar orientation="vertical" label="Scroll" controls="messages" bind:value={position}>
|
|
18
26
|
// <div>thumb</div>
|
|
19
27
|
// </ScrollBar>
|
|
20
28
|
//
|
|
@@ -24,17 +32,18 @@
|
|
|
24
32
|
// <div class="thumb"></div>
|
|
25
33
|
// </ScrollBar>
|
|
26
34
|
//
|
|
27
|
-
// <!-- Vertical scrollbar
|
|
28
|
-
// <ScrollBar orientation="vertical" label="Page scroll"
|
|
35
|
+
// <!-- Vertical scrollbar bound to the consumer's scroll position -->
|
|
36
|
+
// <ScrollBar orientation="vertical" label="Page scroll" bind:value={scrollPos}>
|
|
29
37
|
// <div class="thumb"></div>
|
|
30
38
|
// </ScrollBar>
|
|
31
39
|
//
|
|
32
40
|
// Keyboard:
|
|
33
|
-
// - Arrow Up/Left:
|
|
34
|
-
// - Arrow Down/Right:
|
|
35
|
-
// - Page Up/Down:
|
|
36
|
-
// - Home:
|
|
37
|
-
// - End:
|
|
41
|
+
// - Arrow Up/Left: decrease value by step
|
|
42
|
+
// - Arrow Down/Right: increase value by step
|
|
43
|
+
// - Page Up/Down: decrease/increase value by pageStep
|
|
44
|
+
// - Home: value to min
|
|
45
|
+
// - End: value to max
|
|
46
|
+
// The value is clamped to [min, max].
|
|
38
47
|
//
|
|
39
48
|
// Accessibility:
|
|
40
49
|
// - role="scrollbar" identifies the element as a scrollbar control
|
|
@@ -47,8 +56,8 @@
|
|
|
47
56
|
//
|
|
48
57
|
// Claude rules:
|
|
49
58
|
// - Headless: no CSS, no styles — consumer provides all styling
|
|
50
|
-
// -
|
|
51
|
-
//
|
|
59
|
+
// - The component moves the value on keys; the consumer scrolls its content to
|
|
60
|
+
// the value, writes the value back as the content scrolls, and handles drag
|
|
52
61
|
//
|
|
53
62
|
// References:
|
|
54
63
|
// - WAI-ARIA scrollbar role: https://www.w3.org/TR/wai-aria-1.2/#scrollbar
|
|
@@ -58,18 +67,68 @@
|
|
|
58
67
|
let {
|
|
59
68
|
class: className = "",
|
|
60
69
|
orientation = "vertical",
|
|
70
|
+
value = $bindable(0),
|
|
71
|
+
min = 0,
|
|
72
|
+
max = 100,
|
|
73
|
+
step = 1,
|
|
74
|
+
pageStep = 10,
|
|
75
|
+
controls = undefined,
|
|
61
76
|
label,
|
|
62
77
|
children,
|
|
63
78
|
...restProps
|
|
64
79
|
}: {
|
|
65
80
|
/** ScrollBar orientation. */
|
|
66
81
|
orientation?: "vertical" | "horizontal";
|
|
82
|
+
/** Scroll position. Bindable. */
|
|
83
|
+
value?: number;
|
|
84
|
+
/** Start of the range. */
|
|
85
|
+
min?: number;
|
|
86
|
+
/** End of the range. */
|
|
87
|
+
max?: number;
|
|
88
|
+
/** Arrow-key increment. */
|
|
89
|
+
step?: number;
|
|
90
|
+
/** Page Up / Page Down increment. */
|
|
91
|
+
pageStep?: number;
|
|
92
|
+
/** Id of the scrolled element. */
|
|
93
|
+
controls?: string;
|
|
67
94
|
/** Accessible label. */
|
|
68
95
|
label: string;
|
|
69
96
|
/** ScrollBar content. */
|
|
70
97
|
children: Snippet;
|
|
71
98
|
[key: string]: unknown;
|
|
72
99
|
} = $props();
|
|
100
|
+
|
|
101
|
+
function clamp(v: number): number {
|
|
102
|
+
return Math.min(max, Math.max(min, v));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function onkeydown(event: KeyboardEvent) {
|
|
106
|
+
switch (event.key) {
|
|
107
|
+
case "ArrowUp":
|
|
108
|
+
case "ArrowLeft":
|
|
109
|
+
value = clamp(value - step);
|
|
110
|
+
break;
|
|
111
|
+
case "ArrowDown":
|
|
112
|
+
case "ArrowRight":
|
|
113
|
+
value = clamp(value + step);
|
|
114
|
+
break;
|
|
115
|
+
case "PageUp":
|
|
116
|
+
value = clamp(value - pageStep);
|
|
117
|
+
break;
|
|
118
|
+
case "PageDown":
|
|
119
|
+
value = clamp(value + pageStep);
|
|
120
|
+
break;
|
|
121
|
+
case "Home":
|
|
122
|
+
value = min;
|
|
123
|
+
break;
|
|
124
|
+
case "End":
|
|
125
|
+
value = max;
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
}
|
|
73
132
|
</script>
|
|
74
133
|
|
|
75
134
|
<!-- ScrollBar.svelte -->
|
|
@@ -78,9 +137,12 @@
|
|
|
78
137
|
role="scrollbar"
|
|
79
138
|
aria-label={label}
|
|
80
139
|
aria-orientation={orientation}
|
|
81
|
-
aria-
|
|
82
|
-
aria-
|
|
83
|
-
aria-
|
|
140
|
+
aria-controls={controls}
|
|
141
|
+
aria-valuenow={value}
|
|
142
|
+
aria-valuemin={min}
|
|
143
|
+
aria-valuemax={max}
|
|
144
|
+
tabindex="0"
|
|
145
|
+
{onkeydown}
|
|
84
146
|
{...restProps}
|
|
85
147
|
>
|
|
86
148
|
{@render children?.()}
|
|
@@ -2,12 +2,24 @@ import type { Snippet } from "svelte";
|
|
|
2
2
|
type $$ComponentProps = {
|
|
3
3
|
/** ScrollBar orientation. */
|
|
4
4
|
orientation?: "vertical" | "horizontal";
|
|
5
|
+
/** Scroll position. Bindable. */
|
|
6
|
+
value?: number;
|
|
7
|
+
/** Start of the range. */
|
|
8
|
+
min?: number;
|
|
9
|
+
/** End of the range. */
|
|
10
|
+
max?: number;
|
|
11
|
+
/** Arrow-key increment. */
|
|
12
|
+
step?: number;
|
|
13
|
+
/** Page Up / Page Down increment. */
|
|
14
|
+
pageStep?: number;
|
|
15
|
+
/** Id of the scrolled element. */
|
|
16
|
+
controls?: string;
|
|
5
17
|
/** Accessible label. */
|
|
6
18
|
label: string;
|
|
7
19
|
/** ScrollBar content. */
|
|
8
20
|
children: Snippet;
|
|
9
21
|
[key: string]: unknown;
|
|
10
22
|
};
|
|
11
|
-
declare const ScrollBar: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
23
|
+
declare const ScrollBar: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
12
24
|
type ScrollBar = ReturnType<typeof ScrollBar>;
|
|
13
25
|
export default ScrollBar;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// Sheet component
|
|
3
3
|
//
|
|
4
4
|
// A headless sliding panel overlay that appears from an edge of the viewport,
|
|
5
|
-
// functioning as a modal dialog
|
|
6
|
-
// with
|
|
5
|
+
// functioning as a modal dialog: while open it renders a native <dialog> opened
|
|
6
|
+
// with showModal() (see ../Dialog/modal.ts), so the page behind it is inert, Tab
|
|
7
|
+
// stays inside it, and focus returns to the opener when it closes.
|
|
8
|
+
// Conditionally rendered based on the open state, with Escape key to dismiss. Commonly used for navigation menus, settings panels,
|
|
7
9
|
// detail views, or filter interfaces that slide in from the top, right, bottom, or left.
|
|
8
10
|
//
|
|
9
11
|
// Props:
|
|
@@ -12,7 +14,7 @@
|
|
|
12
14
|
// open — boolean, default false. Whether the sheet is visible; bindable via bind:open.
|
|
13
15
|
// side — "left" | "right" | "top" | "bottom", default "right". Which edge the sheet appears from.
|
|
14
16
|
// children — Snippet, required. Content to render inside the sheet.
|
|
15
|
-
// ...restProps — additional HTML attributes spread onto the <
|
|
17
|
+
// ...restProps — additional HTML attributes spread onto the <dialog>.
|
|
16
18
|
//
|
|
17
19
|
// Syntax:
|
|
18
20
|
// <Sheet label="Settings" bind:open side="right">
|
|
@@ -32,13 +34,14 @@
|
|
|
32
34
|
// </Sheet>
|
|
33
35
|
//
|
|
34
36
|
// Keyboard:
|
|
35
|
-
// - Escape: closes the sheet by setting open to false
|
|
36
|
-
// - Tab: moves focus between focusable elements within the sheet
|
|
37
|
+
// - Escape: closes the sheet by setting open to false (also the native cancel event)
|
|
38
|
+
// - Tab: moves focus between focusable elements within the sheet; showModal() keeps it inside
|
|
37
39
|
//
|
|
38
40
|
// Accessibility:
|
|
39
|
-
// - role="dialog"
|
|
41
|
+
// - role="dialog" provided natively by the <dialog> element
|
|
40
42
|
// - aria-label provides an accessible name for the dialog
|
|
41
|
-
// - aria-modal="true"
|
|
43
|
+
// - aria-modal="true" is true: showModal() makes the content behind inert
|
|
44
|
+
// - focus moves into the sheet on open and returns to the opener on close
|
|
42
45
|
// - tabindex="-1" allows programmatic focus on the dialog container
|
|
43
46
|
// - data-side attribute exposes the side for CSS targeting
|
|
44
47
|
//
|
|
@@ -48,13 +51,15 @@
|
|
|
48
51
|
// Claude rules:
|
|
49
52
|
// - Headless: no CSS, no styles — consumer provides all styling
|
|
50
53
|
// - Open uses $bindable() for two-way binding with bind:open
|
|
51
|
-
// -
|
|
54
|
+
// - Focus trapping comes from showModal() via ../Dialog/modal.ts (open-attribute fallback where it is
|
|
55
|
+
// missing, e.g. jsdom); consumer implements slide-in animations via CSS
|
|
52
56
|
// - Completely removed from DOM when closed ({#if open})
|
|
53
57
|
//
|
|
54
58
|
// References:
|
|
55
59
|
// - WAI-ARIA Dialog (Modal) Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
56
60
|
|
|
57
61
|
import type { Snippet } from "svelte";
|
|
62
|
+
import { modalDialog } from "../Dialog/modal.js";
|
|
58
63
|
|
|
59
64
|
let {
|
|
60
65
|
class: className = "",
|
|
@@ -81,20 +86,36 @@
|
|
|
81
86
|
open = false;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
89
|
+
function oncancel(event: Event) {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
open = false;
|
|
92
|
+
}
|
|
93
|
+
function onclose() {
|
|
94
|
+
open = false;
|
|
95
|
+
}
|
|
96
|
+
// Open as a real modal, then make sure focus is inside: showModal() already moves it in a browser, the
|
|
97
|
+
// open-attribute fallback does not.
|
|
98
|
+
function modal(node: HTMLDialogElement) {
|
|
99
|
+
const action = modalDialog(node, true);
|
|
100
|
+
if (!node.contains(document.activeElement)) node.focus();
|
|
101
|
+
return action;
|
|
102
|
+
}
|
|
84
103
|
</script>
|
|
85
104
|
|
|
86
105
|
<!-- Sheet.svelte -->
|
|
87
106
|
{#if open}
|
|
88
|
-
<
|
|
107
|
+
<dialog
|
|
89
108
|
class={`sheet ${className}`}
|
|
90
|
-
role="dialog"
|
|
91
109
|
aria-label={label}
|
|
92
110
|
aria-modal="true"
|
|
93
111
|
tabindex="-1"
|
|
94
112
|
data-side={side}
|
|
113
|
+
use:modal
|
|
95
114
|
{onkeydown}
|
|
115
|
+
{oncancel}
|
|
116
|
+
{onclose}
|
|
96
117
|
{...restProps}
|
|
97
118
|
>
|
|
98
119
|
{@render children?.()}
|
|
99
|
-
</
|
|
120
|
+
</dialog>
|
|
100
121
|
{/if}
|
|
@@ -48,8 +48,15 @@
|
|
|
48
48
|
</script>
|
|
49
49
|
|
|
50
50
|
<!-- ShowMore.svelte -->
|
|
51
|
-
<div
|
|
52
|
-
|
|
51
|
+
<div
|
|
52
|
+
class={`show-more ${className}`}
|
|
53
|
+
{...restProps}
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
class="show-more-content"
|
|
57
|
+
id={contentId}
|
|
58
|
+
data-expanded={expanded}
|
|
59
|
+
>
|
|
53
60
|
{@render children?.()}
|
|
54
61
|
</div>
|
|
55
62
|
<button
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// SlideOutDrawer component
|
|
3
3
|
//
|
|
4
4
|
// A headless slide-out drawer that renders a modal dialog container which
|
|
5
|
-
// slides in from the side of the screen.
|
|
5
|
+
// slides in from the side of the screen. The container is a native <dialog>
|
|
6
|
+
// opened with showModal() (see ../Dialog/modal.ts): the page behind it is inert,
|
|
7
|
+
// Tab stays inside it, and focus returns to the opener when it closes. When open, it can be dismissed with
|
|
6
8
|
// the Escape key. Commonly used for navigation menus, filters, settings panels,
|
|
7
9
|
// or secondary content in mobile and web applications.
|
|
8
10
|
//
|
|
@@ -11,7 +13,7 @@
|
|
|
11
13
|
// label — string, required. Accessible label for the dialog via aria-label.
|
|
12
14
|
// open — boolean, default false. Whether the drawer is visible; bindable via bind:open.
|
|
13
15
|
// children — Snippet, required. The drawer content.
|
|
14
|
-
// ...restProps — additional HTML attributes spread onto the <
|
|
16
|
+
// ...restProps — additional HTML attributes spread onto the <dialog>.
|
|
15
17
|
//
|
|
16
18
|
// Syntax:
|
|
17
19
|
// <SlideOutDrawer label="Menu" bind:open={isOpen}>
|
|
@@ -34,12 +36,14 @@
|
|
|
34
36
|
// </SlideOutDrawer>
|
|
35
37
|
//
|
|
36
38
|
// Keyboard:
|
|
37
|
-
// - Escape: closes the drawer by setting open to false
|
|
39
|
+
// - Escape: closes the drawer by setting open to false (also the native cancel event)
|
|
40
|
+
// - Tab: stays inside the drawer while it is open
|
|
38
41
|
//
|
|
39
42
|
// Accessibility:
|
|
40
|
-
// - role="dialog"
|
|
43
|
+
// - role="dialog" provided natively by the <dialog> element
|
|
41
44
|
// - aria-label describes the drawer purpose
|
|
42
|
-
// - aria-modal="true"
|
|
45
|
+
// - aria-modal="true" is true: showModal() makes the content behind inert
|
|
46
|
+
// - focus moves into the drawer on open and returns to the opener on close
|
|
43
47
|
// - tabindex="-1" allows the dialog to receive programmatic focus
|
|
44
48
|
// - WCAG 2.2 AAA: properly labeled modal with keyboard dismissal
|
|
45
49
|
//
|
|
@@ -51,13 +55,15 @@
|
|
|
51
55
|
// - Headless: no CSS, no styles — consumer provides all styling
|
|
52
56
|
// - Open uses $bindable() for two-way binding with bind:open
|
|
53
57
|
// - Completely removed from DOM when closed ({#if open})
|
|
54
|
-
// -
|
|
58
|
+
// - Focus trapping comes from showModal() via ../Dialog/modal.ts (open-attribute fallback where it is
|
|
59
|
+
// missing, e.g. jsdom); consumer implements slide animations via CSS
|
|
55
60
|
//
|
|
56
61
|
// References:
|
|
57
62
|
// - WAI-ARIA Dialog (Modal) Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
58
63
|
// - WAI-ARIA dialog role: https://www.w3.org/TR/wai-aria-1.2/#dialog
|
|
59
64
|
|
|
60
65
|
import type { Snippet } from "svelte";
|
|
66
|
+
import { modalDialog } from "../Dialog/modal.js";
|
|
61
67
|
|
|
62
68
|
let {
|
|
63
69
|
class: className = "",
|
|
@@ -79,22 +85,39 @@
|
|
|
79
85
|
// Escape key closes the drawer, matching standard dialog behavior.
|
|
80
86
|
function handleKeydown(event: KeyboardEvent) {
|
|
81
87
|
if (event.key === "Escape") {
|
|
88
|
+
event.preventDefault();
|
|
82
89
|
open = false;
|
|
83
90
|
}
|
|
84
91
|
}
|
|
92
|
+
function oncancel(event: Event) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
open = false;
|
|
95
|
+
}
|
|
96
|
+
function onclose() {
|
|
97
|
+
open = false;
|
|
98
|
+
}
|
|
99
|
+
// Open as a real modal, then make sure focus is inside: showModal() already moves it in a browser, the
|
|
100
|
+
// open-attribute fallback does not.
|
|
101
|
+
function modal(node: HTMLDialogElement) {
|
|
102
|
+
const action = modalDialog(node, true);
|
|
103
|
+
if (!node.contains(document.activeElement)) node.focus();
|
|
104
|
+
return action;
|
|
105
|
+
}
|
|
85
106
|
</script>
|
|
86
107
|
|
|
87
|
-
<!-- SlideOutDrawer: a modal dialog
|
|
108
|
+
<!-- SlideOutDrawer: a modal <dialog>, conditionally rendered and opened with showModal() -->
|
|
88
109
|
{#if open}
|
|
89
|
-
<
|
|
110
|
+
<dialog
|
|
90
111
|
class={`slide-out-drawer ${className}`}
|
|
91
|
-
role="dialog"
|
|
92
112
|
aria-label={label}
|
|
93
113
|
aria-modal="true"
|
|
94
114
|
tabindex="-1"
|
|
115
|
+
use:modal
|
|
95
116
|
onkeydown={handleKeydown}
|
|
117
|
+
{oncancel}
|
|
118
|
+
{onclose}
|
|
96
119
|
{...restProps}
|
|
97
120
|
>
|
|
98
121
|
{@render children?.()}
|
|
99
|
-
</
|
|
122
|
+
</dialog>
|
|
100
123
|
{/if}
|
|
@@ -1,18 +1,76 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
// SliderButton: a slide-to-confirm control. A <button role="slider"> whose aria-valuenow is the position, 0 to
|
|
3
|
+
// 100. ArrowRight/ArrowLeft move it by `step`; Home returns it to 0; End, Enter or Space complete it (the
|
|
4
|
+
// keyboard fallback for the drag). Reaching 100 calls `onconfirm` and resets to 0. The consumer draws the track
|
|
5
|
+
// and thumb from aria-valuenow, and wires pointer drag through the same position if it wants one.
|
|
2
6
|
import type { Snippet } from "svelte";
|
|
3
7
|
let {
|
|
4
8
|
class: className = "",
|
|
5
|
-
label
|
|
6
|
-
|
|
9
|
+
label,
|
|
10
|
+
step = 10,
|
|
11
|
+
disabled = false,
|
|
12
|
+
onconfirm = undefined,
|
|
13
|
+
children = undefined,
|
|
7
14
|
...restProps
|
|
8
15
|
}: {
|
|
9
|
-
label
|
|
10
|
-
|
|
16
|
+
/** Accessible label describing the confirmation action. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** How far one arrow press moves the slider, in percent. */
|
|
19
|
+
step?: number;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Called when the slider reaches 100%. */
|
|
22
|
+
onconfirm?: () => void;
|
|
23
|
+
children?: Snippet;
|
|
11
24
|
[key: string]: unknown;
|
|
12
25
|
} = $props();
|
|
26
|
+
|
|
27
|
+
let position = $state(0);
|
|
28
|
+
|
|
29
|
+
function moveTo(next: number) {
|
|
30
|
+
if (next >= 100) {
|
|
31
|
+
position = 0;
|
|
32
|
+
onconfirm?.();
|
|
33
|
+
} else {
|
|
34
|
+
position = Math.max(0, next);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function onkeydown(event: KeyboardEvent) {
|
|
39
|
+
if (disabled) return;
|
|
40
|
+
switch (event.key) {
|
|
41
|
+
case "ArrowRight":
|
|
42
|
+
moveTo(position + step);
|
|
43
|
+
break;
|
|
44
|
+
case "ArrowLeft":
|
|
45
|
+
moveTo(position - step);
|
|
46
|
+
break;
|
|
47
|
+
case "Home":
|
|
48
|
+
moveTo(0);
|
|
49
|
+
break;
|
|
50
|
+
case "End":
|
|
51
|
+
case "Enter":
|
|
52
|
+
case " ":
|
|
53
|
+
moveTo(100);
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
}
|
|
13
60
|
</script>
|
|
14
61
|
|
|
15
62
|
<!-- SliderButton.svelte -->
|
|
16
|
-
<
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
role="slider"
|
|
66
|
+
class={`slider-button ${className}`}
|
|
67
|
+
aria-label={label}
|
|
68
|
+
aria-valuenow={position}
|
|
69
|
+
aria-valuemin={0}
|
|
70
|
+
aria-valuemax={100}
|
|
71
|
+
{disabled}
|
|
72
|
+
{onkeydown}
|
|
73
|
+
{...restProps}
|
|
74
|
+
>
|
|
17
75
|
{@render children?.()}
|
|
18
|
-
</
|
|
76
|
+
</button>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
2
|
type $$ComponentProps = {
|
|
3
|
-
label
|
|
4
|
-
|
|
3
|
+
/** Accessible label describing the confirmation action. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** How far one arrow press moves the slider, in percent. */
|
|
6
|
+
step?: number;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** Called when the slider reaches 100%. */
|
|
9
|
+
onconfirm?: () => void;
|
|
10
|
+
children?: Snippet;
|
|
5
11
|
[key: string]: unknown;
|
|
6
12
|
};
|
|
7
13
|
declare const SliderButton: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
@@ -52,13 +52,14 @@
|
|
|
52
52
|
// - WAI-ARIA Menu Button: https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/
|
|
53
53
|
|
|
54
54
|
import type { Snippet } from "svelte";
|
|
55
|
+
import { popoverState, popoverSupported, toggleOpened } from "../Popover/popover.js";
|
|
55
56
|
|
|
56
57
|
let {
|
|
57
58
|
class: className = "",
|
|
58
59
|
label,
|
|
59
60
|
primaryLabel,
|
|
60
61
|
menuLabel,
|
|
61
|
-
menuOpen = false,
|
|
62
|
+
menuOpen = $bindable(false),
|
|
62
63
|
disabled = false,
|
|
63
64
|
onprimaryclick = undefined,
|
|
64
65
|
onmenutoggle = undefined,
|
|
@@ -71,18 +72,30 @@
|
|
|
71
72
|
primaryLabel: string;
|
|
72
73
|
/** Accessible label for the menu trigger (required) */
|
|
73
74
|
menuLabel: string;
|
|
74
|
-
/** Whether the dropdown menu is open */
|
|
75
|
+
/** Whether the dropdown menu is open. Bindable: the browser opens and light-dismisses it. */
|
|
75
76
|
menuOpen?: boolean;
|
|
76
77
|
/** Whether both buttons are disabled */
|
|
77
78
|
disabled?: boolean;
|
|
78
79
|
/** Primary action handler */
|
|
79
80
|
onprimaryclick?: (event: MouseEvent) => void;
|
|
80
|
-
/** Menu toggle handler */
|
|
81
|
+
/** Menu toggle handler; call preventDefault() to keep the menu as it is */
|
|
81
82
|
onmenutoggle?: (event: MouseEvent) => void;
|
|
82
83
|
/** The menu content */
|
|
83
84
|
children: Snippet;
|
|
84
85
|
[key: string]: unknown;
|
|
85
86
|
} = $props();
|
|
87
|
+
|
|
88
|
+
const uid = $props.id();
|
|
89
|
+
const menuId = `split-button-menu-${uid}`;
|
|
90
|
+
let menu: HTMLDivElement | undefined = $state();
|
|
91
|
+
|
|
92
|
+
// With the Popover API the trigger's command="toggle-popover" opens and closes the menu and the toggle event
|
|
93
|
+
// writes `menuOpen` back; without it, the click toggles `menuOpen` and popoverState sets `hidden`.
|
|
94
|
+
function toggle(event: MouseEvent) {
|
|
95
|
+
onmenutoggle?.(event);
|
|
96
|
+
if (event.defaultPrevented) return;
|
|
97
|
+
if (menu && !popoverSupported(menu)) menuOpen = !menuOpen;
|
|
98
|
+
}
|
|
86
99
|
</script>
|
|
87
100
|
|
|
88
101
|
<!-- SplitButton.svelte -->
|
|
@@ -107,9 +120,20 @@
|
|
|
107
120
|
aria-haspopup="menu"
|
|
108
121
|
aria-expanded={menuOpen}
|
|
109
122
|
aria-label={menuLabel}
|
|
110
|
-
|
|
123
|
+
aria-controls={menuId}
|
|
124
|
+
command="toggle-popover"
|
|
125
|
+
commandfor={menuId}
|
|
126
|
+
popovertarget={menuId}
|
|
127
|
+
onclick={toggle}
|
|
111
128
|
></button>
|
|
112
|
-
<div
|
|
129
|
+
<div
|
|
130
|
+
bind:this={menu}
|
|
131
|
+
class="split-button-menu"
|
|
132
|
+
id={menuId}
|
|
133
|
+
popover="auto"
|
|
134
|
+
use:popoverState={menuOpen}
|
|
135
|
+
ontoggle={(event) => (menuOpen = toggleOpened(event))}
|
|
136
|
+
>
|
|
113
137
|
{@render children?.()}
|
|
114
138
|
</div>
|
|
115
139
|
</div>
|
|
@@ -6,18 +6,18 @@ type $$ComponentProps = {
|
|
|
6
6
|
primaryLabel: string;
|
|
7
7
|
/** Accessible label for the menu trigger (required) */
|
|
8
8
|
menuLabel: string;
|
|
9
|
-
/** Whether the dropdown menu is open */
|
|
9
|
+
/** Whether the dropdown menu is open. Bindable: the browser opens and light-dismisses it. */
|
|
10
10
|
menuOpen?: boolean;
|
|
11
11
|
/** Whether both buttons are disabled */
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
/** Primary action handler */
|
|
14
14
|
onprimaryclick?: (event: MouseEvent) => void;
|
|
15
|
-
/** Menu toggle handler */
|
|
15
|
+
/** Menu toggle handler; call preventDefault() to keep the menu as it is */
|
|
16
16
|
onmenutoggle?: (event: MouseEvent) => void;
|
|
17
17
|
/** The menu content */
|
|
18
18
|
children: Snippet;
|
|
19
19
|
[key: string]: unknown;
|
|
20
20
|
};
|
|
21
|
-
declare const SplitButton: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
21
|
+
declare const SplitButton: import("svelte").Component<$$ComponentProps, {}, "menuOpen">;
|
|
22
22
|
type SplitButton = ReturnType<typeof SplitButton>;
|
|
23
23
|
export default SplitButton;
|