Repository navigation
slab-elements@0.2.0
Minor Changes
-
#63
95ef80aThanks @ynotdraw! - Color Picker's thumbs each hold a visually hidden range input, which is what's focused and what screenreaders read, so screenreaders on phones can adjust them with a swipe up or down. The area has a second one for its brightness, "Brightness" afterlabel, left out of the tab order. The thumbs are no longer[role=slider]s themselves, and since they aren't focused, they don't match:focus-visible: style a thumb's focus ring through its newfocus-visiblepart, as in::part(hue-thumb focus-visible). -
#62
ac4b5b8Thanks @ynotdraw! - Range Slider's thumbs each hold a visually hidden range input, which is what's focused and what screenreaders read, so screenreaders on phones can adjust them with a swipe up or down. The thumbs are no longer[role=slider]s themselves, and since they aren't focused, they don't match:focus-visible: style a thumb's focus ring through its newfocus-visiblepart, as in::part(start focus-visible).
Patch Changes
-
#61
62c9ae5Thanks @ynotdraw! - Combobox now tells screenreaders how many Options are left once typing pauses ("No results", "1 result", "3 results"), and which tag was removed whenmultipleis set. Before, filtering and removing a tag happened silently. Both messages can be replaced, throughresultsLabelandremovedLabel. -
#52
03477ceThanks @ynotdraw! -aria-*attributes on a component's host now reach the element a screenreader reads, such as Text Field's<input>or Disclosure's<summary>, in Checkbox, Color Picker, Combobox, Date Field, Disclosure, File Drop, Number, Pin Input, Range Slider, Slider, Switch, Text Field, Textarea and Time Field. Before, anaria-labeloraria-describedbyyou put on the host went unread, and so did the description Tooltip gives its anchor and thearia-expandedPopover and Menu give theirs when the anchor was one of these. ID references, such asaria-describedby, are resolved where the host is and kept in step as they change. -
#53
e959074Thanks @ynotdraw! - Carousel'sautoplayno longer rotates when the user prefers reduced motion, and it stops for good once focus moves into the carousel, as the APG's carousel does, rather than starting again when focus leaves. The rotation button starts it in either case. -
#45
956ac66Thanks @ynotdraw! - Adds Command Palette,slab-command-palette: a modal search for commands. It's Dialog, with a Combobox's<input role="combobox">and a listbox of slotted Options inside, so it has Dialog'sopen,show(),close(),closedby, label, focus trap and "cancel" and "close". Opening it empties the input and focuses it. Typing filters the Options byfilter, a case-insensitive substring of their text by default, and makes the first match active, so Enter runs the best one. Up and Down move the active Option. Enter or a click closes the palette with the chosen Option'svalueasreturnValue. A Close button beside the input closes it without choosing, which matters on phones whereclosedby="any"isn't supported, and thecloseslot changes what it says. Closing it any way other than choosing leavesreturnValueempty.queryis what's been typed, and the input's "input" leaves the host, for fetching results as the user types. When nothing matches, the listbox is hidden, the host matches:state(empty), and theemptyslot is shown in a status region. Style it through::part(dialog),::part(label),::part(input),::part(close),::part(listbox)and::part(empty). -
#42
79651cbThanks @ynotdraw! - Adds Copy Button,slab-copy-button: a native<button>that writes text to the clipboard when it's pressed. It copiesvalue, or, withfrom, thevalueor rendered text of the element with thatidat the moment it's pressed, so a code block or an input can be copied without keepingvaluein step. Once copied,copied-label("Copied") is announced from a status beside the button, the host matches:state(copied)forfeedback-duration(2000ms by default), and "copied" is dispatched. When the clipboard refuses, as it does in a page that isn't served securely,failed-labelis announced, the host matches:state(failed), and "copy-error" is dispatched instead. Style it through::part(button),:state(copied)and:state(failed). -
#36
837aa4eThanks @ynotdraw! - Adds Date Range Field,slab-date-range-field: two native date inputs, a start and an end, for picking the first and last days of a range. Each input's bound is the other's value, so a browser's picker won't offer an end before the start, and an end typed before it israngeUnderflowandrangeOverflow, as a date outsideminandmaxis on a single input.start-valueandend-valueare ISO "yyyy-mm-dd" strings, and the form gets both undername, the start and then the end. The group is named bylabel, and each input by it andstart-labelorend-label, "Start" and "End" unless you set them. Style it through its parts and:state(disabled),:state(error),:state(readonly)and:state(required). -
#41
d257c59Thanks @ynotdraw! - Adds Editable,slab-editable: text that's edited in place, such as a title or a name. It's a native button showing the value, named bylabeland then the value, that becomes a native input when it's pressed, with the text selected. Enter commits what's typed and Escape discards it, and both put focus back on the button. Moving focus away commits it too.valueis the last committed value, and it's what the form gets undername. "change" is dispatched when an edit is committed with a different value.edit(),commit()andcancel()do what the keys do, andeditingsays which is showing. While it's empty, the button showsplaceholder. Style it through::part(preview),::part(input),::part(label)and::part(description), and:state(disabled),:state(editing)and:state(empty). -
#40
5b24c72Thanks @ynotdraw! - Adds Feed,slab-feed: the APG's feed, a[role=feed]of articles that grows as the user scrolls, like a timeline. Each slotted element is an article, put in the tab sequence and givenaria-posinsetandaria-setsize, so a screenreader says where it is. It's a[role=article]unless it's an<article>or has a role, and it's named by its first heading unless it has a name. Page Down and Page Up move focus to the next and previous article from anywhere in one, and Control+End and Control+Home move focus to what's after and before the feed. Loading is yours: add articles and setbusywhile you do.totalis how many articles there are in all, or -1 when that's unknown, and the number there are now when unset. The feed is named bylabel. Style it through::part(feed). -
#54
b03c6abThanks @ynotdraw! - Field now describes its control by what's slotted intodescription, through the control'saria-describedby, after any IDs it already has, and sets the control'saria-invalidwhileerroris set. Before, a screenreader read neither the hint nor the error, nor that the control was invalid. -
#51
57f1c76Thanks @ynotdraw! - Color Picker keeps the colors being picked from in forced colors, such as Windows' contrast themes. Before, the browser painted the area, the hue and alpha sliders and every swatch in the user's background color, so there was nothing to pick from. -
#56
e61e570Thanks @ynotdraw! - Checkbox Group and Radio Group now tell screenreaders when they're invalid. Radio Group setsaria-invalidon its radiogroup. A group role can't takearia-invalid, so Checkbox Group sets it on each of its Checkboxes instead. Both follow the Group's validity feedback, so they're marked once its validity is reported and cleared once it's valid. -
#35
7faf8caThanks @ynotdraw! - Adds Hover Card,slab-hover-card: a preview of what a link leads to, slotted beside itsanchorin a native[popover]in the top layer. It opens when the anchor is hovered or focused by keyboard, afteropen-delay(700ms by default), and closes when the pointer leaves, afterclose-delay(300ms), when focus leaves it, and on Escape. Unlike Tooltip's, its content can hold links and buttons, which follow the anchor in the focus order, so Tab moves into the card. A touch doesn't open it.placementpicks the side it opens on, and it flips when there's no room. Style it through::part(card)and:state(open). -
#48
8d51eeaThanks @ynotdraw! - Text Field, Number, Pin Input and Combobox now leave Enter to an input method while it's composing, such as one for Japanese or Chinese. Before, the Enter that confirms a conversion submitted the form, or chose the active Option in Combobox. Safari's composition-ending Enter, which doesn't setisComposing, is recognized too. -
#58
cf80b53Thanks @ynotdraw! - Menu Item has atypeofcheckboxorradio, which makes it amenuitemcheckboxormenuitemradiowitharia-checked,checked, and:state(checked). A click checks it before any "click" listener hears it. The new Menu Group,slab-menu-group, is a named[role=group]for a set of radio Menu Items in a Menu or Context Menu. Its Menu Items are still the Menu's, so the arrow keys and typeahead move through them as through the rest. -
#38
10d2892Thanks @ynotdraw! - Adds Navigation Menu,slab-navigation-menu, and Navigation Menu Item,slab-navigation-menu-item, for a site's navigation. It's the APG's disclosure navigation rather than a[role=menu]: a<nav>named bylabel, around a<ul>with an<li>for each link and Item. Each Item is a<button>witharia-expanded, named by itslabel, that shows and hides a list of links of its own. Opening one Item closes the others, and Escape, a click outside an Item, or focus leaving it closes it. Tab goes through every link and button. Left and Right move along the row, Down on an Item's button opens it at its first link, and Up and Down move between its links. An Item's content is in the flow below its button, anddisplay: nonewhile closed, so a design positions it. Items haveopen,show(),hide(),toggle()and a "toggle" event. Style them through::part(nav),::part(list),::part(item),::part(trigger)and::part(content). -
#59
bdeed2aThanks @ynotdraw! - The new Option Group,slab-option-group, is a named[role=group]of Options for Listbox, Select and Combobox. Its Options are still the Listbox's, Select's or Combobox's, so the arrow keys, typeahead and selection work across groups as across the rest. Combobox hides an Option Group while its filter hides every Option in it. -
#44
8352c2aThanks @ynotdraw! - Adds Password Field,slab-password-field: a native password input with a button that shows and hides the password. The button is a toggle button named bytoggle-label("Show password" by default) whosearia-pressedfollowsrevealed, and it fires "toggle" when pressed. While the password shows the input is a text input, with spellcheck, autocorrect and autocapitalize off.revealedworks likevalue, so the attribute is the default and a form reset hides the password again. It's form-associated with Text Field's API:required,minlength,maxlength,pattern,autocomplete,setCustomValidity(),setValidity()and a validity message. Style it through::part(control),::part(input),::part(toggle-button)and:state(disabled),:state(error),:state(readonly),:state(required)and:state(revealed). -
#49
94b23a4Thanks @ynotdraw! - Left and Right now follow the reading direction in Tabs, Toolbar, Toggle Group, Radio Group, Menubar, Tree, Calendar, Color Picker's swatches and Combobox's tags. In a right-to-left page, Left moves to the next item, as it does for native radios, Tree expands with Left and collapses with Right, Calendar moves forward a day with Left, and Combobox moves from the start of its input to its tags with Right. -
#60
4614a25Thanks @ynotdraw! - A click on Select's or Listbox's label now focuses it, as a click on a native select's label does. Nothing happens while it's disabled. -
#43
7d5e115Thanks @ynotdraw! - Adds Steps,slab-steps, and Step,slab-steps-step, for showing where the user is in a task of several steps, such as a checkout or a setup wizard. It's an<ol>named bylabel, with an<li>for each Step. The Steps beforestepare complete, the one at it is current and hasaria-current="step", and the rest are upcoming. Past the last Step, every one is complete. Each Step shows its number, its label from the default slot, and adescriptionslot, and a complete one hascomplete-label("Completed" by default) after its label, hidden visually, for screenreaders. Withnavigable, each Step is a<button>, and clicking one setsstepand dispatches "change";disabledkeeps the user off Steps they can't go to yet.next()andprevious()move it along from your own buttons. Style it through::part(list)and::part(item), and each Step through::part(step),::part(indicator),::part(label),::part(status),::part(description)and:state(complete),:state(current),:state(upcoming)and:state(navigable). -
#64
8b513a6Thanks @ynotdraw! - AddsregisterStrings(), fromslab-elements/strings.js, for translating the words Slab's elements say on their own, such as Alert's "Dismiss", Pagination's "Page 3" or Carousel's "Next slide". An element uses the strings registered for its nearestlang, then for that language without its region, and then English. An attribute or property set on the element still wins. Calendar also numbers its days in its language's digits, such as Arabic-Indic ones underlang="ar-EG". -
#55
0b5d55bThanks @ynotdraw! - Switch now shows when it's invalid, the way Checkbox does. Before, a required Switch left off blocked submission without saying why. Once its validity is reported it setsaria-invalidand:state(error)and shows avalidity-messagepart, worded by the browser unless you give it one. It also hasvalidationMessage,willValidate,setCustomValidity(),setValidity(), andresetValidityFeedback(). -
#37
09721c6Thanks @ynotdraw! - Adds Tags Input,slab-tags-input: a native text input that turns what's typed into tags, for values with no list to pick from. Enter adds what's typed as a tag, and so does typingdelimiter(a comma by default), so a pasted list becomes several tags. Tags are trimmed and not repeated,maxcaps how many the user can add, and what's typed is added when focus leaves. Each tag is a<button>that removes it, named byremoveLabel, and the keyboard is Combobox's withmultiple: Backspace in an empty input removes the last tag, and Left moves to the tags.valueslists the tags, each submitted as its own entry, and thevalueattribute is the starting tags separated by commas. It's form-associated, withrequired,setCustomValidity(),setValidity()and a validity message. Style it through::part(tag),::part(tags),::part(input)and:state(disabled),:state(empty),:state(error),:state(full)and:state(required). -
#57
d31553cThanks @ynotdraw! - Toast no longer dismisses itself on a timer when it has something to act on, such as an Undo button or a link, whateverdurationsays (WCAG 2.2.1). F6 now moves focus to the open toast shown most recently, and F6 from inside it moves focus back, as react-aria's toasts do. Dismissing a toast with focus in it moves focus back too. -
#50
5173ac2Thanks @ynotdraw! - Text Field, Textarea, Number, Date Field, Time Field, File Drop, Checkbox, Checkbox Group, Radio Group, Listbox, Select, Combobox, Rating and Pin Input now show the browser's own validity message, in the browser's language, when one fails a built-in constraint and you haven't given it avalidity-message. Before, a required field left empty was invalid but said nothing, so a screenreader user wasn't told why the form wouldn't submit. Each also hasvalidationMessageandwillValidate, as a native control does.