@sharedex/ui 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -2
- package/dist/backgrounds/hosts/CssHost.d.ts +2 -6
- package/dist/backgrounds/hosts/CssHost.js +3 -17
- package/dist/backgrounds/hosts/styleHref.d.ts +6 -0
- package/dist/backgrounds/hosts/styleHref.js +20 -0
- package/dist/buttons/pick.d.ts +9 -3
- package/dist/buttons/pick.js +4 -1
- package/dist/forms/base.d.ts +1 -0
- package/dist/forms/base.js +224 -0
- package/dist/forms/buddy.d.ts +6 -0
- package/dist/forms/buddy.js +150 -0
- package/dist/forms/chips.d.ts +1 -0
- package/dist/forms/chips.js +140 -0
- package/dist/forms/choice.d.ts +1 -0
- package/dist/forms/choice.js +208 -0
- package/dist/forms/controls/CheckGroup.d.ts +65 -0
- package/dist/forms/controls/CheckGroup.js +99 -0
- package/dist/forms/controls/Checkbox.d.ts +43 -0
- package/dist/forms/controls/Checkbox.js +67 -0
- package/dist/forms/controls/ChipGroup.d.ts +50 -0
- package/dist/forms/controls/ChipGroup.js +56 -0
- package/dist/forms/controls/Combobox.d.ts +75 -0
- package/dist/forms/controls/Combobox.js +249 -0
- package/dist/forms/controls/ErrorSummary.d.ts +29 -0
- package/dist/forms/controls/ErrorSummary.js +79 -0
- package/dist/forms/controls/Field.d.ts +92 -0
- package/dist/forms/controls/Field.js +219 -0
- package/dist/forms/controls/FileDrop.d.ts +81 -0
- package/dist/forms/controls/FileDrop.js +328 -0
- package/dist/forms/controls/FormBuddy.d.ts +22 -0
- package/dist/forms/controls/FormBuddy.js +143 -0
- package/dist/forms/controls/FormReveal.d.ts +21 -0
- package/dist/forms/controls/FormReveal.js +19 -0
- package/dist/forms/controls/FormSteps.d.ts +75 -0
- package/dist/forms/controls/FormSteps.js +205 -0
- package/dist/forms/controls/FormSwap.d.ts +27 -0
- package/dist/forms/controls/FormSwap.js +38 -0
- package/dist/forms/controls/InlineEdit.d.ts +50 -0
- package/dist/forms/controls/InlineEdit.js +136 -0
- package/dist/forms/controls/NumberField.d.ts +43 -0
- package/dist/forms/controls/NumberField.js +205 -0
- package/dist/forms/controls/OtpField.d.ts +46 -0
- package/dist/forms/controls/OtpField.js +195 -0
- package/dist/forms/controls/PasswordRules.d.ts +31 -0
- package/dist/forms/controls/PasswordRules.js +85 -0
- package/dist/forms/controls/RadioGroup.d.ts +69 -0
- package/dist/forms/controls/RadioGroup.js +95 -0
- package/dist/forms/controls/Range.d.ts +60 -0
- package/dist/forms/controls/Range.js +169 -0
- package/dist/forms/controls/SaveStatus.d.ts +25 -0
- package/dist/forms/controls/SaveStatus.js +88 -0
- package/dist/forms/controls/Select.d.ts +46 -0
- package/dist/forms/controls/Select.js +35 -0
- package/dist/forms/controls/Switch.d.ts +54 -0
- package/dist/forms/controls/Switch.js +91 -0
- package/dist/forms/controls/TagsField.d.ts +68 -0
- package/dist/forms/controls/TagsField.js +0 -0
- package/dist/forms/controls/choiceChecks.d.ts +11 -0
- package/dist/forms/controls/choiceChecks.js +19 -0
- package/dist/forms/controls/choiceParts.d.ts +40 -0
- package/dist/forms/controls/choiceParts.js +49 -0
- package/dist/forms/controls/fieldChecks.d.ts +17 -0
- package/dist/forms/controls/fieldChecks.js +34 -0
- package/dist/forms/controls/fieldTools.d.ts +62 -0
- package/dist/forms/controls/fieldTools.js +54 -0
- package/dist/forms/controls/pickerChecks.d.ts +10 -0
- package/dist/forms/controls/pickerChecks.js +27 -0
- package/dist/forms/controls/rangeChecks.d.ts +11 -0
- package/dist/forms/controls/rangeChecks.js +23 -0
- package/dist/forms/controls/shared.d.ts +8 -0
- package/dist/forms/controls/shared.js +18 -0
- package/dist/forms/effects/cards.d.ts +11 -0
- package/dist/forms/effects/cards.js +52 -0
- package/dist/forms/effects/check/checkCard.d.ts +10 -0
- package/dist/forms/effects/check/checkCard.js +15 -0
- package/dist/forms/effects/check/checkCard.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkCard.schema.js +9 -0
- package/dist/forms/effects/check/checkConfetti.d.ts +18 -0
- package/dist/forms/effects/check/checkConfetti.js +38 -0
- package/dist/forms/effects/check/checkConfetti.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkConfetti.schema.js +13 -0
- package/dist/forms/effects/check/checkDraw.d.ts +7 -0
- package/dist/forms/effects/check/checkDraw.js +12 -0
- package/dist/forms/effects/check/checkDraw.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkDraw.schema.js +9 -0
- package/dist/forms/effects/check/checkHeart.d.ts +9 -0
- package/dist/forms/effects/check/checkHeart.js +84 -0
- package/dist/forms/effects/check/checkHeart.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkHeart.schema.js +10 -0
- package/dist/forms/effects/check/checkJelly.d.ts +9 -0
- package/dist/forms/effects/check/checkJelly.js +23 -0
- package/dist/forms/effects/check/checkJelly.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkJelly.schema.js +10 -0
- package/dist/forms/effects/check/checkMerge.d.ts +9 -0
- package/dist/forms/effects/check/checkMerge.js +37 -0
- package/dist/forms/effects/check/checkMerge.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkMerge.schema.js +10 -0
- package/dist/forms/effects/check/checkMixed.d.ts +7 -0
- package/dist/forms/effects/check/checkMixed.js +25 -0
- package/dist/forms/effects/check/checkMixed.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkMixed.schema.js +9 -0
- package/dist/forms/effects/check/checkMorph.d.ts +9 -0
- package/dist/forms/effects/check/checkMorph.js +53 -0
- package/dist/forms/effects/check/checkMorph.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkMorph.schema.js +10 -0
- package/dist/forms/effects/check/checkPop.d.ts +9 -0
- package/dist/forms/effects/check/checkPop.js +27 -0
- package/dist/forms/effects/check/checkPop.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkPop.schema.js +10 -0
- package/dist/forms/effects/check/checkRipple.d.ts +7 -0
- package/dist/forms/effects/check/checkRipple.js +33 -0
- package/dist/forms/effects/check/checkRipple.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkRipple.schema.js +9 -0
- package/dist/forms/effects/check/checkScribble.d.ts +11 -0
- package/dist/forms/effects/check/checkScribble.js +42 -0
- package/dist/forms/effects/check/checkScribble.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkScribble.schema.js +11 -0
- package/dist/forms/effects/check/checkStrike.d.ts +9 -0
- package/dist/forms/effects/check/checkStrike.js +54 -0
- package/dist/forms/effects/check/checkStrike.schema.d.ts +1 -0
- package/dist/forms/effects/check/checkStrike.schema.js +10 -0
- package/dist/forms/effects/chip/chipCheck.d.ts +7 -0
- package/dist/forms/effects/chip/chipCheck.js +26 -0
- package/dist/forms/effects/chip/chipCheck.schema.d.ts +1 -0
- package/dist/forms/effects/chip/chipCheck.schema.js +9 -0
- package/dist/forms/effects/chip/chipMerge.d.ts +9 -0
- package/dist/forms/effects/chip/chipMerge.js +63 -0
- package/dist/forms/effects/chip/chipMerge.schema.d.ts +1 -0
- package/dist/forms/effects/chip/chipMerge.schema.js +10 -0
- package/dist/forms/effects/file/fileButton.d.ts +7 -0
- package/dist/forms/effects/file/fileButton.js +28 -0
- package/dist/forms/effects/file/fileButton.schema.d.ts +1 -0
- package/dist/forms/effects/file/fileButton.schema.js +9 -0
- package/dist/forms/effects/file/fileCards.d.ts +7 -0
- package/dist/forms/effects/file/fileCards.js +38 -0
- package/dist/forms/effects/file/fileCards.schema.d.ts +1 -0
- package/dist/forms/effects/file/fileCards.schema.js +9 -0
- package/dist/forms/effects/file/fileDrag.d.ts +9 -0
- package/dist/forms/effects/file/fileDrag.js +45 -0
- package/dist/forms/effects/file/fileDrag.schema.d.ts +1 -0
- package/dist/forms/effects/file/fileDrag.schema.js +10 -0
- package/dist/forms/effects/file/filePage.d.ts +7 -0
- package/dist/forms/effects/file/filePage.js +46 -0
- package/dist/forms/effects/file/filePage.schema.d.ts +1 -0
- package/dist/forms/effects/file/filePage.schema.js +9 -0
- package/dist/forms/effects/file/filePreview.d.ts +7 -0
- package/dist/forms/effects/file/filePreview.js +17 -0
- package/dist/forms/effects/file/filePreview.schema.d.ts +1 -0
- package/dist/forms/effects/file/filePreview.schema.js +9 -0
- package/dist/forms/effects/file/fileProgress.d.ts +9 -0
- package/dist/forms/effects/file/fileProgress.js +92 -0
- package/dist/forms/effects/file/fileProgress.schema.d.ts +1 -0
- package/dist/forms/effects/file/fileProgress.schema.js +10 -0
- package/dist/forms/effects/file/fileReject.d.ts +7 -0
- package/dist/forms/effects/file/fileReject.js +24 -0
- package/dist/forms/effects/file/fileReject.schema.d.ts +1 -0
- package/dist/forms/effects/file/fileReject.schema.js +9 -0
- package/dist/forms/effects/input/inputAside.d.ts +11 -0
- package/dist/forms/effects/input/inputAside.js +42 -0
- package/dist/forms/effects/input/inputAside.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputAside.schema.js +11 -0
- package/dist/forms/effects/input/inputBeam.d.ts +14 -0
- package/dist/forms/effects/input/inputBeam.js +51 -0
- package/dist/forms/effects/input/inputBeam.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputBeam.schema.js +18 -0
- package/dist/forms/effects/input/inputCaret.d.ts +13 -0
- package/dist/forms/effects/input/inputCaret.js +33 -0
- package/dist/forms/effects/input/inputCaret.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputCaret.schema.js +26 -0
- package/dist/forms/effects/input/inputCounter.d.ts +16 -0
- package/dist/forms/effects/input/inputCounter.js +84 -0
- package/dist/forms/effects/input/inputCounter.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputCounter.schema.js +12 -0
- package/dist/forms/effects/input/inputCycle.d.ts +19 -0
- package/dist/forms/effects/input/inputCycle.js +93 -0
- package/dist/forms/effects/input/inputCycle.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputCycle.schema.js +11 -0
- package/dist/forms/effects/input/inputDepth.d.ts +11 -0
- package/dist/forms/effects/input/inputDepth.js +31 -0
- package/dist/forms/effects/input/inputDepth.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputDepth.schema.js +11 -0
- package/dist/forms/effects/input/inputDraw.d.ts +13 -0
- package/dist/forms/effects/input/inputDraw.js +27 -0
- package/dist/forms/effects/input/inputDraw.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputDraw.schema.js +12 -0
- package/dist/forms/effects/input/inputFlap.d.ts +9 -0
- package/dist/forms/effects/input/inputFlap.js +24 -0
- package/dist/forms/effects/input/inputFlap.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputFlap.schema.js +10 -0
- package/dist/forms/effects/input/inputFloat.d.ts +12 -0
- package/dist/forms/effects/input/inputFloat.js +46 -0
- package/dist/forms/effects/input/inputFloat.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputFloat.schema.js +10 -0
- package/dist/forms/effects/input/inputFlood.d.ts +11 -0
- package/dist/forms/effects/input/inputFlood.js +30 -0
- package/dist/forms/effects/input/inputFlood.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputFlood.schema.js +11 -0
- package/dist/forms/effects/input/inputFrame.d.ts +18 -0
- package/dist/forms/effects/input/inputFrame.js +77 -0
- package/dist/forms/effects/input/inputFrame.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputFrame.schema.js +13 -0
- package/dist/forms/effects/input/inputIcon.d.ts +11 -0
- package/dist/forms/effects/input/inputIcon.js +18 -0
- package/dist/forms/effects/input/inputIcon.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputIcon.schema.js +11 -0
- package/dist/forms/effects/input/inputNotch.d.ts +9 -0
- package/dist/forms/effects/input/inputNotch.js +70 -0
- package/dist/forms/effects/input/inputNotch.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputNotch.schema.js +10 -0
- package/dist/forms/effects/input/inputReveal.d.ts +15 -0
- package/dist/forms/effects/input/inputReveal.js +56 -0
- package/dist/forms/effects/input/inputReveal.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputReveal.schema.js +16 -0
- package/dist/forms/effects/input/inputRing.d.ts +13 -0
- package/dist/forms/effects/input/inputRing.js +27 -0
- package/dist/forms/effects/input/inputRing.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputRing.schema.js +12 -0
- package/dist/forms/effects/input/inputRise.d.ts +9 -0
- package/dist/forms/effects/input/inputRise.js +22 -0
- package/dist/forms/effects/input/inputRise.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputRise.schema.js +10 -0
- package/dist/forms/effects/input/inputSearch.d.ts +9 -0
- package/dist/forms/effects/input/inputSearch.js +37 -0
- package/dist/forms/effects/input/inputSearch.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputSearch.schema.js +10 -0
- package/dist/forms/effects/input/inputSkeleton.d.ts +7 -0
- package/dist/forms/effects/input/inputSkeleton.js +41 -0
- package/dist/forms/effects/input/inputSkeleton.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputSkeleton.schema.js +9 -0
- package/dist/forms/effects/input/inputSpotlight.d.ts +9 -0
- package/dist/forms/effects/input/inputSpotlight.js +20 -0
- package/dist/forms/effects/input/inputSpotlight.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputSpotlight.schema.js +10 -0
- package/dist/forms/effects/input/inputStrength.d.ts +9 -0
- package/dist/forms/effects/input/inputStrength.js +29 -0
- package/dist/forms/effects/input/inputStrength.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputStrength.schema.js +10 -0
- package/dist/forms/effects/input/inputSwap.d.ts +11 -0
- package/dist/forms/effects/input/inputSwap.js +39 -0
- package/dist/forms/effects/input/inputSwap.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputSwap.schema.js +11 -0
- package/dist/forms/effects/input/inputUnderline.d.ts +13 -0
- package/dist/forms/effects/input/inputUnderline.js +36 -0
- package/dist/forms/effects/input/inputUnderline.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputUnderline.schema.js +18 -0
- package/dist/forms/effects/input/inputWave.d.ts +11 -0
- package/dist/forms/effects/input/inputWave.js +23 -0
- package/dist/forms/effects/input/inputWave.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputWave.schema.js +11 -0
- package/dist/forms/effects/input/inputWavy.d.ts +11 -0
- package/dist/forms/effects/input/inputWavy.js +53 -0
- package/dist/forms/effects/input/inputWavy.schema.d.ts +1 -0
- package/dist/forms/effects/input/inputWavy.schema.js +11 -0
- package/dist/forms/effects/kit.d.ts +213 -0
- package/dist/forms/effects/kit.js +226 -0
- package/dist/forms/effects/picker/chipPop.d.ts +7 -0
- package/dist/forms/effects/picker/chipPop.js +28 -0
- package/dist/forms/effects/picker/chipPop.schema.d.ts +1 -0
- package/dist/forms/effects/picker/chipPop.schema.js +9 -0
- package/dist/forms/effects/picker/listHighlight.d.ts +9 -0
- package/dist/forms/effects/picker/listHighlight.js +42 -0
- package/dist/forms/effects/picker/listHighlight.schema.d.ts +1 -0
- package/dist/forms/effects/picker/listHighlight.schema.js +10 -0
- package/dist/forms/effects/picker/listMatch.d.ts +7 -0
- package/dist/forms/effects/picker/listMatch.js +21 -0
- package/dist/forms/effects/picker/listMatch.schema.d.ts +1 -0
- package/dist/forms/effects/picker/listMatch.schema.js +9 -0
- package/dist/forms/effects/picker/pickerArrow.d.ts +9 -0
- package/dist/forms/effects/picker/pickerArrow.js +17 -0
- package/dist/forms/effects/picker/pickerArrow.schema.d.ts +1 -0
- package/dist/forms/effects/picker/pickerArrow.schema.js +10 -0
- package/dist/forms/effects/picker/pickerCheck.d.ts +7 -0
- package/dist/forms/effects/picker/pickerCheck.js +31 -0
- package/dist/forms/effects/picker/pickerCheck.schema.d.ts +1 -0
- package/dist/forms/effects/picker/pickerCheck.schema.js +9 -0
- package/dist/forms/effects/picker/pickerOpen.d.ts +12 -0
- package/dist/forms/effects/picker/pickerOpen.js +34 -0
- package/dist/forms/effects/picker/pickerOpen.schema.d.ts +1 -0
- package/dist/forms/effects/picker/pickerOpen.schema.js +16 -0
- package/dist/forms/effects/picker/pickerSheet.d.ts +9 -0
- package/dist/forms/effects/picker/pickerSheet.js +47 -0
- package/dist/forms/effects/picker/pickerSheet.schema.d.ts +1 -0
- package/dist/forms/effects/picker/pickerSheet.schema.js +10 -0
- package/dist/forms/effects/picker/pickerStagger.d.ts +9 -0
- package/dist/forms/effects/picker/pickerStagger.js +31 -0
- package/dist/forms/effects/picker/pickerStagger.schema.d.ts +1 -0
- package/dist/forms/effects/picker/pickerStagger.schema.js +10 -0
- package/dist/forms/effects/radio/radioCard.d.ts +10 -0
- package/dist/forms/effects/radio/radioCard.js +15 -0
- package/dist/forms/effects/radio/radioCard.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioCard.schema.js +9 -0
- package/dist/forms/effects/radio/radioCircle.d.ts +9 -0
- package/dist/forms/effects/radio/radioCircle.js +49 -0
- package/dist/forms/effects/radio/radioCircle.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioCircle.schema.js +10 -0
- package/dist/forms/effects/radio/radioDot.d.ts +7 -0
- package/dist/forms/effects/radio/radioDot.js +10 -0
- package/dist/forms/effects/radio/radioDot.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioDot.schema.js +9 -0
- package/dist/forms/effects/radio/radioEmoji.d.ts +9 -0
- package/dist/forms/effects/radio/radioEmoji.js +94 -0
- package/dist/forms/effects/radio/radioEmoji.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioEmoji.schema.js +10 -0
- package/dist/forms/effects/radio/radioPulse.d.ts +9 -0
- package/dist/forms/effects/radio/radioPulse.js +24 -0
- package/dist/forms/effects/radio/radioPulse.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioPulse.schema.js +10 -0
- package/dist/forms/effects/radio/radioScale.d.ts +9 -0
- package/dist/forms/effects/radio/radioScale.js +73 -0
- package/dist/forms/effects/radio/radioScale.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioScale.schema.js +10 -0
- package/dist/forms/effects/radio/radioSegment.d.ts +7 -0
- package/dist/forms/effects/radio/radioSegment.js +52 -0
- package/dist/forms/effects/radio/radioSegment.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioSegment.schema.js +9 -0
- package/dist/forms/effects/radio/radioStars.d.ts +15 -0
- package/dist/forms/effects/radio/radioStars.js +125 -0
- package/dist/forms/effects/radio/radioStars.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioStars.schema.js +13 -0
- package/dist/forms/effects/radio/radioTravel.d.ts +9 -0
- package/dist/forms/effects/radio/radioTravel.js +49 -0
- package/dist/forms/effects/radio/radioTravel.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioTravel.schema.js +10 -0
- package/dist/forms/effects/radio/radioUnderline.d.ts +9 -0
- package/dist/forms/effects/radio/radioUnderline.js +61 -0
- package/dist/forms/effects/radio/radioUnderline.schema.d.ts +1 -0
- package/dist/forms/effects/radio/radioUnderline.schema.js +10 -0
- package/dist/forms/effects/radio/shape.d.ts +13 -0
- package/dist/forms/effects/radio/shape.js +61 -0
- package/dist/forms/effects/range/rangeBubble.d.ts +9 -0
- package/dist/forms/effects/range/rangeBubble.js +54 -0
- package/dist/forms/effects/range/rangeBubble.schema.d.ts +1 -0
- package/dist/forms/effects/range/rangeBubble.schema.js +10 -0
- package/dist/forms/effects/range/rangeElastic.d.ts +9 -0
- package/dist/forms/effects/range/rangeElastic.js +101 -0
- package/dist/forms/effects/range/rangeElastic.schema.d.ts +1 -0
- package/dist/forms/effects/range/rangeElastic.schema.js +10 -0
- package/dist/forms/effects/range/rangeFace.d.ts +11 -0
- package/dist/forms/effects/range/rangeFace.js +68 -0
- package/dist/forms/effects/range/rangeFace.schema.d.ts +1 -0
- package/dist/forms/effects/range/rangeFace.schema.js +11 -0
- package/dist/forms/effects/range/rangeFill.d.ts +7 -0
- package/dist/forms/effects/range/rangeFill.js +29 -0
- package/dist/forms/effects/range/rangeFill.schema.d.ts +1 -0
- package/dist/forms/effects/range/rangeFill.schema.js +9 -0
- package/dist/forms/effects/range/rangeHistogram.d.ts +14 -0
- package/dist/forms/effects/range/rangeHistogram.js +65 -0
- package/dist/forms/effects/range/rangeHistogram.schema.d.ts +1 -0
- package/dist/forms/effects/range/rangeHistogram.schema.js +11 -0
- package/dist/forms/effects/range/rangeThumb.d.ts +9 -0
- package/dist/forms/effects/range/rangeThumb.js +39 -0
- package/dist/forms/effects/range/rangeThumb.schema.d.ts +1 -0
- package/dist/forms/effects/range/rangeThumb.schema.js +10 -0
- package/dist/forms/effects/range/rangeTicks.d.ts +9 -0
- package/dist/forms/effects/range/rangeTicks.js +44 -0
- package/dist/forms/effects/range/rangeTicks.schema.d.ts +1 -0
- package/dist/forms/effects/range/rangeTicks.schema.js +18 -0
- package/dist/forms/effects/ring.d.ts +5 -0
- package/dist/forms/effects/ring.js +12 -0
- package/dist/forms/effects/step/stepProgress.d.ts +9 -0
- package/dist/forms/effects/step/stepProgress.js +35 -0
- package/dist/forms/effects/step/stepProgress.schema.d.ts +1 -0
- package/dist/forms/effects/step/stepProgress.schema.js +10 -0
- package/dist/forms/effects/step/stepSlide.d.ts +9 -0
- package/dist/forms/effects/step/stepSlide.js +50 -0
- package/dist/forms/effects/step/stepSlide.schema.d.ts +1 -0
- package/dist/forms/effects/step/stepSlide.schema.js +10 -0
- package/dist/forms/effects/switch/switchBulb.d.ts +9 -0
- package/dist/forms/effects/switch/switchBulb.js +70 -0
- package/dist/forms/effects/switch/switchBulb.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchBulb.schema.js +10 -0
- package/dist/forms/effects/switch/switchDayNight.d.ts +15 -0
- package/dist/forms/effects/switch/switchDayNight.js +96 -0
- package/dist/forms/effects/switch/switchDayNight.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchDayNight.schema.js +13 -0
- package/dist/forms/effects/switch/switchFace.d.ts +7 -0
- package/dist/forms/effects/switch/switchFace.js +75 -0
- package/dist/forms/effects/switch/switchFace.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchFace.schema.js +9 -0
- package/dist/forms/effects/switch/switchFlip.d.ts +7 -0
- package/dist/forms/effects/switch/switchFlip.js +45 -0
- package/dist/forms/effects/switch/switchFlip.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchFlip.schema.js +9 -0
- package/dist/forms/effects/switch/switchGoo.d.ts +7 -0
- package/dist/forms/effects/switch/switchGoo.js +95 -0
- package/dist/forms/effects/switch/switchGoo.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchGoo.schema.js +9 -0
- package/dist/forms/effects/switch/switchIcon.d.ts +9 -0
- package/dist/forms/effects/switch/switchIcon.js +63 -0
- package/dist/forms/effects/switch/switchIcon.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchIcon.schema.js +10 -0
- package/dist/forms/effects/switch/switchLabels.d.ts +11 -0
- package/dist/forms/effects/switch/switchLabels.js +55 -0
- package/dist/forms/effects/switch/switchLabels.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchLabels.schema.js +11 -0
- package/dist/forms/effects/switch/switchMorph.d.ts +9 -0
- package/dist/forms/effects/switch/switchMorph.js +22 -0
- package/dist/forms/effects/switch/switchMorph.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchMorph.schema.js +10 -0
- package/dist/forms/effects/switch/switchNeon.d.ts +11 -0
- package/dist/forms/effects/switch/switchNeon.js +53 -0
- package/dist/forms/effects/switch/switchNeon.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchNeon.schema.js +11 -0
- package/dist/forms/effects/switch/switchSlide.d.ts +7 -0
- package/dist/forms/effects/switch/switchSlide.js +11 -0
- package/dist/forms/effects/switch/switchSlide.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchSlide.schema.js +9 -0
- package/dist/forms/effects/switch/switchStretch.d.ts +9 -0
- package/dist/forms/effects/switch/switchStretch.js +21 -0
- package/dist/forms/effects/switch/switchStretch.schema.d.ts +1 -0
- package/dist/forms/effects/switch/switchStretch.schema.js +10 -0
- package/dist/forms/effects/valid/validAsync.d.ts +7 -0
- package/dist/forms/effects/valid/validAsync.js +36 -0
- package/dist/forms/effects/valid/validAsync.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validAsync.schema.js +9 -0
- package/dist/forms/effects/valid/validBubble.d.ts +7 -0
- package/dist/forms/effects/valid/validBubble.js +61 -0
- package/dist/forms/effects/valid/validBubble.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validBubble.schema.js +9 -0
- package/dist/forms/effects/valid/validCheck.d.ts +9 -0
- package/dist/forms/effects/valid/validCheck.js +50 -0
- package/dist/forms/effects/valid/validCheck.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validCheck.schema.js +10 -0
- package/dist/forms/effects/valid/validColor.d.ts +11 -0
- package/dist/forms/effects/valid/validColor.js +28 -0
- package/dist/forms/effects/valid/validColor.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validColor.schema.js +11 -0
- package/dist/forms/effects/valid/validFlash.d.ts +9 -0
- package/dist/forms/effects/valid/validFlash.js +36 -0
- package/dist/forms/effects/valid/validFlash.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validFlash.schema.js +10 -0
- package/dist/forms/effects/valid/validMessage.d.ts +7 -0
- package/dist/forms/effects/valid/validMessage.js +24 -0
- package/dist/forms/effects/valid/validMessage.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validMessage.schema.js +9 -0
- package/dist/forms/effects/valid/validShake.d.ts +9 -0
- package/dist/forms/effects/valid/validShake.js +37 -0
- package/dist/forms/effects/valid/validShake.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validShake.schema.js +10 -0
- package/dist/forms/effects/valid/validSwap.d.ts +7 -0
- package/dist/forms/effects/valid/validSwap.js +33 -0
- package/dist/forms/effects/valid/validSwap.schema.d.ts +1 -0
- package/dist/forms/effects/valid/validSwap.schema.js +9 -0
- package/dist/forms/errors.d.ts +12 -0
- package/dist/forms/errors.js +20 -0
- package/dist/forms/file.d.ts +1 -0
- package/dist/forms/file.js +268 -0
- package/dist/forms/files.d.ts +7 -0
- package/dist/forms/files.js +29 -0
- package/dist/forms/formSteps.d.ts +9 -0
- package/dist/forms/formSteps.js +6 -0
- package/dist/forms/ids.d.ts +17 -0
- package/dist/forms/ids.js +13 -0
- package/dist/forms/inline.d.ts +3 -0
- package/dist/forms/inline.js +128 -0
- package/dist/forms/number.d.ts +1 -0
- package/dist/forms/number.js +67 -0
- package/dist/forms/otp.d.ts +4 -0
- package/dist/forms/otp.js +171 -0
- package/dist/forms/picker.d.ts +1 -0
- package/dist/forms/picker.js +303 -0
- package/dist/forms/range.d.ts +3 -0
- package/dist/forms/range.js +223 -0
- package/dist/forms/registry.d.ts +4 -0
- package/dist/forms/registry.js +133 -0
- package/dist/forms/reveal.d.ts +6 -0
- package/dist/forms/reveal.js +51 -0
- package/dist/forms/runtime/focus.d.ts +16 -0
- package/dist/forms/runtime/focus.js +55 -0
- package/dist/forms/runtime/listMatch.d.ts +2 -0
- package/dist/forms/runtime/listMatch.js +33 -0
- package/dist/forms/runtime/origin.d.ts +10 -0
- package/dist/forms/runtime/origin.js +25 -0
- package/dist/forms/runtime/placePopup.d.ts +10 -0
- package/dist/forms/runtime/placePopup.js +55 -0
- package/dist/forms/runtime/useFlip.d.ts +7 -0
- package/dist/forms/runtime/useFlip.js +38 -0
- package/dist/forms/runtime/useMorph.d.ts +8 -0
- package/dist/forms/runtime/useMorph.js +56 -0
- package/dist/forms/runtime/useOffScreen.d.ts +3 -0
- package/dist/forms/runtime/useOffScreen.js +16 -0
- package/dist/forms/runtime/useSwitchDrag.d.ts +8 -0
- package/dist/forms/runtime/useSwitchDrag.js +83 -0
- package/dist/forms/runtime/vanish.d.ts +6 -0
- package/dist/forms/runtime/vanish.js +185 -0
- package/dist/forms/steps.d.ts +1 -0
- package/dist/forms/steps.js +149 -0
- package/dist/forms/swap.d.ts +7 -0
- package/dist/forms/swap.js +149 -0
- package/dist/forms/switch.d.ts +1 -0
- package/dist/forms/switch.js +99 -0
- package/dist/forms/tools.d.ts +3 -0
- package/dist/forms/tools.js +248 -0
- package/dist/forms/types.d.ts +161 -0
- package/dist/forms/types.js +5 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.js +119 -0
- package/dist/schema/forms.d.ts +3 -0
- package/dist/schema/forms.js +194 -0
- package/dist/schema/index.d.ts +2 -1
- package/dist/schema/index.js +3 -1
- package/dist/schema/types.d.ts +2 -2
- package/dist/schema/types.js +1 -0
- package/guides/README.md +62 -61
- package/guides/contact.md +100 -77
- package/guides/forms.md +105 -0
- package/package.json +1 -1
- package/styles/form.css +594 -0
- package/theme.css +6 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CHANGED, CHECKED, ITEM, MARK, OPTIONS, SPRING, at, choiceLayer, defineForm, inItem, radiosOf, v, varName, whenItemHover } from "../kit.js";
|
|
2
|
+
import { quietWords } from "./shape.js";
|
|
3
|
+
const ID = "radioEmoji";
|
|
4
|
+
const ROOT = radiosOf(ID);
|
|
5
|
+
const FACE = choiceLayer(ID, "face");
|
|
6
|
+
const svg = (part) => `${FACE} [data-sx-choice-svg="${part}"]`;
|
|
7
|
+
/** Five mouths, from a deep frown to a wide smile: our own faces, a circle, two eyes and a line. */
|
|
8
|
+
const MOUTHS = ["M8 17.2q4-4.4 8 0", "M8.5 16.5q3.5-2.2 7 0", "M8.5 15.6h7", "M8.5 14.6q3.5 2.4 7 0", "M8 14q4 5.2 8 0"];
|
|
9
|
+
// A rating in faces: give it five options ("Very unhappy" … "Very happy": their words are the radios' names, read but
|
|
10
|
+
// not shown). Option n wears mouth n. The faces wait grey; the chosen one takes the colour and grows a little (a state:
|
|
11
|
+
// it holds under reduced motion); chosen by hand, it wobbles once.
|
|
12
|
+
const STATE = `${quietWords(ROOT)}
|
|
13
|
+
${at(`${ROOT} > ${OPTIONS}`)} {
|
|
14
|
+
flex-direction: row;
|
|
15
|
+
gap: 0.375rem;
|
|
16
|
+
}
|
|
17
|
+
${at(`${ROOT} ${ITEM}`)} {
|
|
18
|
+
--sx-choice-size: 2.25em;
|
|
19
|
+
--sx-choice-edge: transparent;
|
|
20
|
+
--sx-choice-bg: transparent;
|
|
21
|
+
}
|
|
22
|
+
${at(`${ROOT} ${MARK}, ${ROOT} [data-sx-mark]`)} {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
${at(svg("face"))} {
|
|
26
|
+
fill: color-mix(in oklab, var(--color-sx-ink) 6%, transparent);
|
|
27
|
+
stroke: var(--color-sx-muted, currentColor);
|
|
28
|
+
stroke-width: 1.4;
|
|
29
|
+
}
|
|
30
|
+
${at(svg("eyes"))} {
|
|
31
|
+
fill: var(--color-sx-muted, currentColor);
|
|
32
|
+
}
|
|
33
|
+
${at(`${FACE} [data-sx-choice-svg^="m"]`)} {
|
|
34
|
+
display: none;
|
|
35
|
+
fill: none;
|
|
36
|
+
stroke: var(--color-sx-muted, currentColor);
|
|
37
|
+
stroke-width: 1.6;
|
|
38
|
+
stroke-linecap: round;
|
|
39
|
+
}
|
|
40
|
+
${MOUTHS.map((_, i) => ` ${at(`${ROOT} ${ITEM}:nth-child(${i + 1} of ${ITEM}) ${svg(`m${i + 1}`)}`)} { display: inline; }`).join("\n")}
|
|
41
|
+
${at(inItem(ROOT, CHECKED, svg("face")))} {
|
|
42
|
+
fill: ${v(ID, "color")};
|
|
43
|
+
stroke: var(--color-sx-ink, currentColor);
|
|
44
|
+
}
|
|
45
|
+
${at(`${inItem(ROOT, CHECKED, svg("eyes"))}, ${inItem(ROOT, CHECKED, `${FACE} [data-sx-choice-svg^="m"]`)}`)} {
|
|
46
|
+
fill: var(--color-sx-ink, currentColor);
|
|
47
|
+
stroke: var(--color-sx-ink, currentColor);
|
|
48
|
+
}
|
|
49
|
+
${at(inItem(ROOT, CHECKED, `${FACE} [data-sx-choice-svg^="m"]`))} {
|
|
50
|
+
fill: none;
|
|
51
|
+
}
|
|
52
|
+
${at(inItem(ROOT, CHECKED, FACE))} {
|
|
53
|
+
scale: 1.12;
|
|
54
|
+
}`;
|
|
55
|
+
const CSS = ` ${at(FACE)} {
|
|
56
|
+
transition: scale ${v(ID, "time")} ${SPRING};
|
|
57
|
+
}
|
|
58
|
+
${at(svg("face"))} {
|
|
59
|
+
transition: fill ${v(ID, "time")}, stroke ${v(ID, "time")};
|
|
60
|
+
}
|
|
61
|
+
${whenItemHover(ROOT, FACE, "scale: 1.08;")}
|
|
62
|
+
${at(inItem(ROOT, `${CHECKED}${CHANGED}`, FACE))} {
|
|
63
|
+
animation: sx-form-radioEmoji calc(${v(ID, "time")} * 2) ease-in-out;
|
|
64
|
+
}
|
|
65
|
+
@keyframes sx-form-radioEmoji {
|
|
66
|
+
0%, 100% { rotate: 0deg; }
|
|
67
|
+
25% { rotate: -12deg; }
|
|
68
|
+
50% { rotate: 10deg; }
|
|
69
|
+
75% { rotate: -5deg; }
|
|
70
|
+
}`;
|
|
71
|
+
/** A rating in five faces, frown to smile: the chosen face lights up and wobbles. */
|
|
72
|
+
export function radioEmoji(options = {}) {
|
|
73
|
+
return defineForm(ID, CSS, {
|
|
74
|
+
fits: ["radio"],
|
|
75
|
+
state: STATE,
|
|
76
|
+
vars: { [varName(ID, "color")]: options.color ?? "var(--color-sx-accent)", [varName(ID, "time")]: `${options.duration ?? 0.25}s` },
|
|
77
|
+
layers: [
|
|
78
|
+
{
|
|
79
|
+
slot: "box",
|
|
80
|
+
part: "face",
|
|
81
|
+
keep: true,
|
|
82
|
+
svg: {
|
|
83
|
+
viewBox: "0 0 24 24",
|
|
84
|
+
children: [
|
|
85
|
+
{ tag: "circle", part: "face", attrs: { cx: 12, cy: 12, r: 10 } },
|
|
86
|
+
{ tag: "path", part: "eyes", attrs: { d: "M9 10.2a1.2 1.2 0 1 0 0-.01zM15 10.2a1.2 1.2 0 1 0 0-.01z" } },
|
|
87
|
+
...MOUTHS.map((d, i) => ({ tag: "path", part: `m${i + 1}`, attrs: { d } })),
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
claims: ["mark"],
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RADIO_EMOJI_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RADIO_EMOJI_SCHEMA = defineSchema()({
|
|
3
|
+
id: "radioEmoji",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "radioEmoji",
|
|
6
|
+
fields: {
|
|
7
|
+
color: { kind: "color", label: "Chosen face", default: "var(--color-sx-accent)" },
|
|
8
|
+
duration: { kind: "number", label: "Duration", min: 0.1, max: 0.6, step: 0.05, unit: "s", default: 0.25 },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RadioPulseOptions {
|
|
3
|
+
/** The ring's colour. Default `var(--color-sx-primary)`. */
|
|
4
|
+
readonly color?: string;
|
|
5
|
+
/** Seconds the ring takes to spread and fade. Default `0.6`. */
|
|
6
|
+
readonly duration?: number;
|
|
7
|
+
}
|
|
8
|
+
/** A ring pulses out once from the radio the user chose. */
|
|
9
|
+
export declare function radioPulse(options?: RadioPulseOptions): FormEffect;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CHANGED, CHECKED, at, choiceLayer, defineForm, inItem, radiosOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "radioPulse";
|
|
3
|
+
const RING = choiceLayer(ID);
|
|
4
|
+
// A ring leaves the radio the user chose, once: it spreads and fades. Never on load (CHANGED), and never on a loop:
|
|
5
|
+
// one pulse says "this one", a looping one would only nag (and need a pause control, WCAG 2.2.2).
|
|
6
|
+
const CSS = ` ${at(RING)} {
|
|
7
|
+
border: 2px solid ${v(ID, "color")};
|
|
8
|
+
opacity: 0;
|
|
9
|
+
}
|
|
10
|
+
${at(inItem(radiosOf(ID), `${CHECKED}${CHANGED}`, RING))} {
|
|
11
|
+
animation: sx-form-radioPulse ${v(ID, "time")} ease-out;
|
|
12
|
+
}
|
|
13
|
+
@keyframes sx-form-radioPulse {
|
|
14
|
+
0% { scale: 0.55; opacity: 0.7; }
|
|
15
|
+
100% { scale: 1.5; opacity: 0; }
|
|
16
|
+
}`;
|
|
17
|
+
/** A ring pulses out once from the radio the user chose. */
|
|
18
|
+
export function radioPulse(options = {}) {
|
|
19
|
+
return defineForm(ID, CSS, {
|
|
20
|
+
fits: ["radio"],
|
|
21
|
+
vars: { [varName(ID, "color")]: options.color ?? "var(--color-sx-primary)", [varName(ID, "time")]: `${options.duration ?? 0.6}s` },
|
|
22
|
+
layers: [{ slot: "halo" }],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RADIO_PULSE_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RADIO_PULSE_SCHEMA = defineSchema()({
|
|
3
|
+
id: "radioPulse",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "radioPulse",
|
|
6
|
+
fields: {
|
|
7
|
+
color: { kind: "color", label: "Ring colour", default: "var(--color-sx-primary)" },
|
|
8
|
+
duration: { kind: "number", label: "Duration", min: 0.3, max: 1.2, step: 0.05, unit: "s", default: 0.6 },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RadioScaleOptions {
|
|
3
|
+
/** A bar under each number in its group's colour: 0-6 red, 7-8 amber, 9-10 green (a Net Promoter Score). Default `true`. */
|
|
4
|
+
readonly tint?: boolean;
|
|
5
|
+
/** Seconds each change takes. Default `0.2`. */
|
|
6
|
+
readonly duration?: number;
|
|
7
|
+
}
|
|
8
|
+
/** A 0-10 scale of numbered cells (a Net Promoter Score): the chosen number fills, groups marked by a quiet bar. */
|
|
9
|
+
export declare function radioScale(options?: RadioScaleOptions): FormEffect;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CHANGED, CHECKED, ITEM, OPTIONS, ROW, SPRING, at, choiceLayer, defineForm, inItem, radiosOf, v, varName, whenItemHover } from "../kit.js";
|
|
2
|
+
import { bareOptions } from "./shape.js";
|
|
3
|
+
const ID = "radioScale";
|
|
4
|
+
const ROOT = radiosOf(ID);
|
|
5
|
+
const CELL = choiceLayer(ID, "cell");
|
|
6
|
+
const FILL = `${CELL} > [data-sx-choice-part="fill"]`;
|
|
7
|
+
// A 0-10 scale (give it eleven options): each number a square cell, the chosen one filled. The fill is a layer that
|
|
8
|
+
// fades, so no background colour is animated; the number's colour follows. The bars only say which group a number is
|
|
9
|
+
// in (the numbers themselves say everything), so they stay quiet, under the cell.
|
|
10
|
+
const STATE = `${bareOptions(ROOT)}
|
|
11
|
+
${at(`${ROOT} > ${OPTIONS}`)} {
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
gap: 0.25rem;
|
|
15
|
+
}
|
|
16
|
+
${at(`${ROOT} ${ROW}`)} {
|
|
17
|
+
place-items: center;
|
|
18
|
+
inline-size: 2.5rem;
|
|
19
|
+
block-size: 2.5rem;
|
|
20
|
+
min-block-size: 0;
|
|
21
|
+
font-variant-numeric: tabular-nums;
|
|
22
|
+
}
|
|
23
|
+
${at(inItem(ROOT, "", CELL))} {
|
|
24
|
+
border: 1px solid var(--color-sx-border, currentColor);
|
|
25
|
+
border-radius: var(--radius-sx-control, 0.375rem);
|
|
26
|
+
background: var(--color-sx-secondary, Canvas);
|
|
27
|
+
box-shadow: inset 0 calc(-3px * ${v(ID, "tint")}) 0 var(--sx-radios-tint, transparent);
|
|
28
|
+
}
|
|
29
|
+
${at(`${ROOT} ${ITEM}:nth-child(-n + 7 of ${ITEM})`)} {
|
|
30
|
+
--sx-radios-tint: var(--color-sx-danger);
|
|
31
|
+
}
|
|
32
|
+
${at(`${ROOT} ${ITEM}:nth-child(n + 8 of ${ITEM}):nth-child(-n + 9 of ${ITEM})`)} {
|
|
33
|
+
--sx-radios-tint: color-mix(in oklab, var(--color-sx-danger) 50%, var(--color-sx-success));
|
|
34
|
+
}
|
|
35
|
+
${at(`${ROOT} ${ITEM}:nth-child(n + 10 of ${ITEM})`)} {
|
|
36
|
+
--sx-radios-tint: var(--color-sx-success);
|
|
37
|
+
}
|
|
38
|
+
${at(inItem(ROOT, "", FILL))} {
|
|
39
|
+
position: absolute;
|
|
40
|
+
inset: -1px;
|
|
41
|
+
border-radius: inherit;
|
|
42
|
+
background: var(--color-sx-primary, Highlight);
|
|
43
|
+
opacity: 0;
|
|
44
|
+
}
|
|
45
|
+
${at(inItem(ROOT, CHECKED))} {
|
|
46
|
+
--sx-choice-text: var(--color-sx-on-primary);
|
|
47
|
+
}
|
|
48
|
+
${at(inItem(ROOT, CHECKED, FILL))} {
|
|
49
|
+
opacity: 1;
|
|
50
|
+
}`;
|
|
51
|
+
const CSS = ` ${at(inItem(ROOT, "", FILL))} {
|
|
52
|
+
transition: opacity ${v(ID, "time")} ease-out;
|
|
53
|
+
}
|
|
54
|
+
${at(inItem(ROOT, "", ROW))} {
|
|
55
|
+
transition: translate ${v(ID, "time")} ease-out;
|
|
56
|
+
}
|
|
57
|
+
${whenItemHover(ROOT, ROW, "translate: 0 -2px;")}
|
|
58
|
+
${at(inItem(ROOT, `${CHECKED}${CHANGED}`, CELL))} {
|
|
59
|
+
animation: sx-form-radioScale calc(${v(ID, "time")} * 2) ${SPRING};
|
|
60
|
+
}
|
|
61
|
+
@keyframes sx-form-radioScale {
|
|
62
|
+
0% { scale: 0.85; }
|
|
63
|
+
100% { scale: 1; }
|
|
64
|
+
}`;
|
|
65
|
+
/** A 0-10 scale of numbered cells (a Net Promoter Score): the chosen number fills, groups marked by a quiet bar. */
|
|
66
|
+
export function radioScale(options = {}) {
|
|
67
|
+
return defineForm(ID, CSS, {
|
|
68
|
+
fits: ["radio"],
|
|
69
|
+
state: STATE,
|
|
70
|
+
vars: { [varName(ID, "tint")]: options.tint === false ? 0 : 1, [varName(ID, "time")]: `${options.duration ?? 0.2}s` },
|
|
71
|
+
layers: [{ slot: "row", part: "cell", children: ["fill"], keep: true }],
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RADIO_SCALE_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RADIO_SCALE_SCHEMA = defineSchema()({
|
|
3
|
+
id: "radioScale",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "radioScale",
|
|
6
|
+
fields: {
|
|
7
|
+
tint: { kind: "boolean", label: "Group bars (red, amber, green)", default: true },
|
|
8
|
+
duration: { kind: "number", label: "Duration", min: 0.05, max: 0.6, step: 0.05, unit: "s", default: 0.2 },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RadioSegmentOptions {
|
|
3
|
+
/** Seconds the thumb takes to slide. Default `0.3`. */
|
|
4
|
+
readonly duration?: number;
|
|
5
|
+
}
|
|
6
|
+
/** A segmented control: options in a tray, a thumb sliding under the chosen one (up to 12 options). */
|
|
7
|
+
export declare function radioSegment(options?: RadioSegmentOptions): FormEffect;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CHOICE, DIR, ITEM, OPTIONS, ROW, at, choiceLayer, defineForm, radiosOf, v, varName } from "../kit.js";
|
|
2
|
+
import { bareOptions } from "./shape.js";
|
|
3
|
+
const ID = "radioSegment";
|
|
4
|
+
const ROOT = radiosOf(ID);
|
|
5
|
+
const THUMB = choiceLayer(ID, "thumb");
|
|
6
|
+
/** Groups of up to this many options get a thumb that knows its place. */
|
|
7
|
+
const MOST = 12;
|
|
8
|
+
// A segmented control: the options share a tray in equal columns, and one thumb slides under the chosen one. Equal
|
|
9
|
+
// columns let the thumb's place come from CSS alone (`:nth-child(n of …)` sets `--sx-radios-at`) and move by
|
|
10
|
+
// `translate`, so nothing is measured and nothing re-lays out. The thumb is the state: it holds under reduced motion.
|
|
11
|
+
const STATE = `${bareOptions(ROOT)}
|
|
12
|
+
${at(`${ROOT} > ${OPTIONS}`)} {
|
|
13
|
+
display: grid;
|
|
14
|
+
grid-auto-flow: column;
|
|
15
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
16
|
+
gap: 0;
|
|
17
|
+
padding: 0.25rem;
|
|
18
|
+
border-radius: var(--radius-sx-control, 0.5rem);
|
|
19
|
+
background: color-mix(in oklab, var(--color-sx-ink) 7%, var(--color-sx-secondary));
|
|
20
|
+
}
|
|
21
|
+
${at(`${ROOT} ${ROW}`)} {
|
|
22
|
+
justify-items: center;
|
|
23
|
+
padding: 0.375rem 0.75rem;
|
|
24
|
+
border-radius: calc(var(--radius-sx-control, 0.5rem) - 0.125rem);
|
|
25
|
+
text-align: center;
|
|
26
|
+
}
|
|
27
|
+
${at(THUMB)} {
|
|
28
|
+
inset-block: 0.25rem;
|
|
29
|
+
inset-inline: 0.25rem auto;
|
|
30
|
+
inline-size: calc((100% - 0.5rem) / var(--sx-radios-n, 1));
|
|
31
|
+
border-radius: calc(var(--radius-sx-control, 0.5rem) - 0.125rem);
|
|
32
|
+
background: var(--color-sx-secondary, Canvas);
|
|
33
|
+
box-shadow: 0 1px 3px color-mix(in oklab, var(--color-sx-ink) 22%, transparent);
|
|
34
|
+
translate: calc(var(--sx-radios-at, 0) * 100% * ${DIR}) 0;
|
|
35
|
+
opacity: 0;
|
|
36
|
+
}
|
|
37
|
+
${at(`${ROOT}:has(${CHOICE}:checked) ${THUMB}`)} {
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
${Array.from({ length: MOST }, (_, i) => ` ${at(`${ROOT}:has(${ITEM}:nth-child(${i + 1} of ${ITEM}) ${CHOICE}:checked)`)} { --sx-radios-at: ${i}; }`).join("\n")}`;
|
|
41
|
+
const CSS = ` ${at(THUMB)} {
|
|
42
|
+
transition: translate ${v(ID, "time")} var(--ease-sx-out, ease-out), opacity ${v(ID, "time")};
|
|
43
|
+
}`;
|
|
44
|
+
/** A segmented control: options in a tray, a thumb sliding under the chosen one (up to 12 options). */
|
|
45
|
+
export function radioSegment(options = {}) {
|
|
46
|
+
return defineForm(ID, CSS, {
|
|
47
|
+
fits: ["radio"],
|
|
48
|
+
state: STATE,
|
|
49
|
+
vars: { [varName(ID, "time")]: `${options.duration ?? 0.3}s` },
|
|
50
|
+
layers: [{ slot: "track", part: "thumb", keep: true }],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RADIO_SEGMENT_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RADIO_SEGMENT_SCHEMA = defineSchema()({
|
|
3
|
+
id: "radioSegment",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "radioSegment",
|
|
6
|
+
fields: {
|
|
7
|
+
duration: { kind: "number", label: "Duration", min: 0.1, max: 0.8, step: 0.05, unit: "s", default: 0.3 },
|
|
8
|
+
},
|
|
9
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RadioStarsOptions {
|
|
3
|
+
/** The stars' colour. Default `var(--color-sx-accent)` (pass a gold, say, for the classic look). */
|
|
4
|
+
readonly color?: string;
|
|
5
|
+
/** Half stars: give it ten options (0.5, 1 … 5); each is one half of a star. Default `false`. */
|
|
6
|
+
readonly half?: boolean;
|
|
7
|
+
/** Under the mouse, the stars up to the pointer rise one after another, a wave toward it. Default `false`. */
|
|
8
|
+
readonly wave?: boolean;
|
|
9
|
+
/** A ring of sparks leaves the star the user chose. Default `false`. */
|
|
10
|
+
readonly burst?: boolean;
|
|
11
|
+
/** Seconds each change takes. Default `0.25`. */
|
|
12
|
+
readonly duration?: number;
|
|
13
|
+
}
|
|
14
|
+
/** A star rating whose stars fill up to the choice; with half stars, a wave under the mouse, or a burst of sparks. */
|
|
15
|
+
export declare function radioStars(options?: RadioStarsOptions): FormEffect;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { BOX, CHANGED, CHECKED, CHOICE, ITEM, MARK, OPTIONS, ROW, SPRING, at, choiceLayer, defineForm, inItem, radiosOf, v, varName } from "../kit.js";
|
|
2
|
+
import { UP_TO_CHOSEN, quietWords } from "./shape.js";
|
|
3
|
+
const ID = "radioStars";
|
|
4
|
+
const ROOT = radiosOf(ID);
|
|
5
|
+
const STAR = choiceLayer(ID, "star");
|
|
6
|
+
const SHAPE = `${STAR} [data-sx-choice-svg="star"]`;
|
|
7
|
+
const SPARKS = choiceLayer(ID, "sparks");
|
|
8
|
+
const SPARK = `${SPARKS} > [data-sx-choice-part]`;
|
|
9
|
+
const ANGLES = [-90, -30, 30, 90, 150, 210];
|
|
10
|
+
const HALF = v(ID, "half");
|
|
11
|
+
// A star rating: give it options 1 to 5 ("1 star" … "5 stars": their words are the radios' names, read but not
|
|
12
|
+
// shown). The chosen star and every one before it fill; under the mouse, the ones up to the pointer fill instead.
|
|
13
|
+
// Half stars: ten options, each box half a star wide, each showing its own half (logical sides, so a right-to-left
|
|
14
|
+
// page fills from the right). Only half stars are clipped to their box, so a whole star can grow past it. The arrow
|
|
15
|
+
// keys move along the stars, as with any radios.
|
|
16
|
+
const STATE = `${quietWords(ROOT)}
|
|
17
|
+
${at(`${ROOT} > ${OPTIONS}`)} {
|
|
18
|
+
flex-direction: row;
|
|
19
|
+
gap: calc(0.125rem * (1 - ${HALF}));
|
|
20
|
+
}
|
|
21
|
+
${at(`${ROOT} ${ITEM}`)} {
|
|
22
|
+
--sx-choice-size: 1.75em;
|
|
23
|
+
--sx-choice-edge: transparent;
|
|
24
|
+
--sx-choice-bg: transparent;
|
|
25
|
+
}
|
|
26
|
+
${at(`${ROOT} ${ROW}`)} {
|
|
27
|
+
grid-template-columns: calc(var(--sx-choice-size) * (1 - 0.5 * ${HALF})) 0;
|
|
28
|
+
}
|
|
29
|
+
${at(`${ROOT} :is(${BOX}, ${CHOICE})`)} {
|
|
30
|
+
inline-size: calc(var(--sx-choice-size) * (1 - 0.5 * ${HALF}));
|
|
31
|
+
}
|
|
32
|
+
${at(`${ROOT} ${BOX}`)} {
|
|
33
|
+
border-radius: 0;
|
|
34
|
+
clip-path: inset(calc(-60% * (1 - ${HALF})));
|
|
35
|
+
}
|
|
36
|
+
${at(`${ROOT} ${MARK}, ${ROOT} [data-sx-mark]`)} {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
39
|
+
${at(STAR)} {
|
|
40
|
+
inset-block: 0;
|
|
41
|
+
inset-inline: 0 auto;
|
|
42
|
+
inline-size: var(--sx-choice-size);
|
|
43
|
+
}
|
|
44
|
+
${at(`${ROOT} ${ITEM}:nth-child(even of ${ITEM}) ${STAR}`)} {
|
|
45
|
+
inset-inline-start: calc(var(--sx-choice-size) * -0.5 * ${HALF});
|
|
46
|
+
}
|
|
47
|
+
${at(SHAPE)} {
|
|
48
|
+
fill: color-mix(in oklab, var(--color-sx-ink) 16%, transparent);
|
|
49
|
+
}
|
|
50
|
+
${at(UP_TO_CHOSEN(ROOT, SHAPE))} {
|
|
51
|
+
fill: ${v(ID, "color")};
|
|
52
|
+
}
|
|
53
|
+
@media (hover: hover) and (pointer: fine) {
|
|
54
|
+
${at(`${ROOT} ${ITEM}:hover ${SHAPE}, ${ROOT} ${ITEM}:has(~ ${ITEM}:hover) ${SHAPE}`)} {
|
|
55
|
+
fill: ${v(ID, "color")};
|
|
56
|
+
}
|
|
57
|
+
${at(`${ROOT} ${ITEM}:hover ~ ${ITEM} ${SHAPE}`)} {
|
|
58
|
+
fill: color-mix(in oklab, var(--color-sx-ink) 16%, transparent);
|
|
59
|
+
}
|
|
60
|
+
}`;
|
|
61
|
+
const CSS = ` ${at(SHAPE)} {
|
|
62
|
+
transition: fill ${v(ID, "time")} ease-out;
|
|
63
|
+
}
|
|
64
|
+
${at(STAR)} {
|
|
65
|
+
transition: scale ${v(ID, "time")} ${SPRING};
|
|
66
|
+
transition-delay: calc(var(--sx-choice-i, 0) * 35ms * ${v(ID, "wave")});
|
|
67
|
+
}
|
|
68
|
+
@media (hover: hover) and (pointer: fine) {
|
|
69
|
+
${at(`${ROOT} ${ITEM}:hover ${STAR}, ${ROOT} ${ITEM}:has(~ ${ITEM}:hover) ${STAR}`)} {
|
|
70
|
+
scale: calc(1 + 0.18 * ${v(ID, "wave")});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
${at(inItem(ROOT, `${CHECKED}${CHANGED}`, STAR))} {
|
|
74
|
+
animation: sx-form-radioStars calc(${v(ID, "time")} * 1.6) ${SPRING};
|
|
75
|
+
}
|
|
76
|
+
${at(SPARK)} {
|
|
77
|
+
position: absolute;
|
|
78
|
+
inset-block-start: 50%;
|
|
79
|
+
inset-inline-start: 50%;
|
|
80
|
+
inline-size: 0.2em;
|
|
81
|
+
block-size: 0.2em;
|
|
82
|
+
margin: -0.1em;
|
|
83
|
+
border-radius: 50%;
|
|
84
|
+
background: ${v(ID, "color")};
|
|
85
|
+
opacity: 0;
|
|
86
|
+
}
|
|
87
|
+
${ANGLES.map((a, i) => ` ${at(`${SPARKS} > [data-sx-choice-part="s${i + 1}"]`)} { --sx-form-radioStars-a: ${a}deg; }`).join("\n")}
|
|
88
|
+
${at(inItem(ROOT, `${CHECKED}${CHANGED}`, SPARK))} {
|
|
89
|
+
animation: sx-form-radioStars-burst calc(${v(ID, "time")} * 2) ease-out;
|
|
90
|
+
}
|
|
91
|
+
@keyframes sx-form-radioStars {
|
|
92
|
+
0% { scale: 0.7; }
|
|
93
|
+
60% { scale: 1.3; }
|
|
94
|
+
100% { scale: 1; }
|
|
95
|
+
}
|
|
96
|
+
@keyframes sx-form-radioStars-burst {
|
|
97
|
+
0% { translate: 0 0; opacity: 1; }
|
|
98
|
+
100% { translate: calc(cos(var(--sx-form-radioStars-a)) * 1.3em) calc(sin(var(--sx-form-radioStars-a)) * 1.3em); opacity: 0; }
|
|
99
|
+
}`;
|
|
100
|
+
/** A star rating whose stars fill up to the choice; with half stars, a wave under the mouse, or a burst of sparks. */
|
|
101
|
+
export function radioStars(options = {}) {
|
|
102
|
+
return defineForm(ID, CSS, {
|
|
103
|
+
fits: ["radio"],
|
|
104
|
+
state: STATE,
|
|
105
|
+
vars: {
|
|
106
|
+
[varName(ID, "color")]: options.color ?? "var(--color-sx-accent)",
|
|
107
|
+
[varName(ID, "half")]: options.half ? 1 : 0,
|
|
108
|
+
[varName(ID, "wave")]: options.wave ? 1 : 0,
|
|
109
|
+
[varName(ID, "time")]: `${options.duration ?? 0.25}s`,
|
|
110
|
+
},
|
|
111
|
+
layers: [
|
|
112
|
+
{
|
|
113
|
+
slot: "box",
|
|
114
|
+
part: "star",
|
|
115
|
+
keep: true,
|
|
116
|
+
svg: {
|
|
117
|
+
viewBox: "0 0 24 24",
|
|
118
|
+
children: [{ tag: "path", part: "star", attrs: { d: "M12 2.4l2.95 6.1 6.7.95-4.85 4.7 1.15 6.65L12 17.65 6.05 20.8 7.2 14.15 2.35 9.45l6.7-.95z" } }],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
...(options.burst ? [{ slot: "halo", part: "sparks", children: ANGLES.map((_, i) => `s${i + 1}`) }] : []),
|
|
122
|
+
],
|
|
123
|
+
claims: ["mark"],
|
|
124
|
+
});
|
|
125
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RADIO_STARS_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RADIO_STARS_SCHEMA = defineSchema()({
|
|
3
|
+
id: "radioStars",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "radioStars",
|
|
6
|
+
fields: {
|
|
7
|
+
color: { kind: "color", label: "Colour", default: "var(--color-sx-accent)" },
|
|
8
|
+
half: { kind: "boolean", label: "Half stars (ten options)", default: false },
|
|
9
|
+
wave: { kind: "boolean", label: "Wave under the mouse", default: false },
|
|
10
|
+
burst: { kind: "boolean", label: "Burst of sparks", default: false },
|
|
11
|
+
duration: { kind: "number", label: "Duration", min: 0.1, max: 0.6, step: 0.05, unit: "s", default: 0.25 },
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RadioTravelOptions {
|
|
3
|
+
/** The dot's colour. Default `var(--color-sx-primary)`. */
|
|
4
|
+
readonly color?: string;
|
|
5
|
+
/** Seconds the dot takes to travel. Default `0.4`. */
|
|
6
|
+
readonly duration?: number;
|
|
7
|
+
}
|
|
8
|
+
/** One dot travels from the old choice to the new one. */
|
|
9
|
+
export declare function radioTravel(options?: RadioTravelOptions): FormEffect;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BOX, CHECKED, CHOICE, SPRING, at, choiceLayer, defineForm, inItem, radiosOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "radioTravel";
|
|
3
|
+
const ROOT = radiosOf(ID);
|
|
4
|
+
const DOT = choiceLayer(ID, "dot");
|
|
5
|
+
// One dot for the whole group, travelling from the old choice to the new one instead of one dot fading and another
|
|
6
|
+
// appearing. Anchor positioning sets it in the chosen circle's centre; Chromium and WebKit glide it there with a little
|
|
7
|
+
// overshoot, Firefox moves it at once. Without anchor positioning each circle keeps its own dot. The dot is the state:
|
|
8
|
+
// it holds under reduced motion.
|
|
9
|
+
const STATE = ` ${at(DOT)} {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
@supports (anchor-name: --a) {
|
|
13
|
+
${at(`${ROOT} [data-sx-mark="dot"]`)} {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
}
|
|
16
|
+
${at(inItem(ROOT, CHECKED, BOX))} {
|
|
17
|
+
anchor-name: ${v(ID, "anchor")};
|
|
18
|
+
}
|
|
19
|
+
${at(`${ROOT}:has(${CHOICE}:checked) ${DOT}`)} {
|
|
20
|
+
display: block;
|
|
21
|
+
position-anchor: ${v(ID, "anchor")};
|
|
22
|
+
inset: auto;
|
|
23
|
+
inset-block-start: anchor(center);
|
|
24
|
+
inset-inline-start: anchor(center);
|
|
25
|
+
inline-size: 0.625em;
|
|
26
|
+
block-size: 0.625em;
|
|
27
|
+
margin-block-start: -0.3125em;
|
|
28
|
+
margin-inline-start: -0.3125em;
|
|
29
|
+
border-radius: 50%;
|
|
30
|
+
background: ${v(ID, "color")};
|
|
31
|
+
z-index: 1;
|
|
32
|
+
}
|
|
33
|
+
}`;
|
|
34
|
+
const CSS = ` ${at(DOT)} {
|
|
35
|
+
transition: inset-block-start ${v(ID, "time")} ${SPRING}, inset-inline-start ${v(ID, "time")} ${SPRING};
|
|
36
|
+
}`;
|
|
37
|
+
/** One dot travels from the old choice to the new one. */
|
|
38
|
+
export function radioTravel(options = {}) {
|
|
39
|
+
return defineForm(ID, CSS, {
|
|
40
|
+
fits: ["radio"],
|
|
41
|
+
state: STATE,
|
|
42
|
+
vars: {
|
|
43
|
+
[varName(ID, "color")]: options.color ?? "var(--color-sx-primary)",
|
|
44
|
+
[varName(ID, "anchor")]: "--{uid}-dot",
|
|
45
|
+
[varName(ID, "time")]: `${options.duration ?? 0.4}s`,
|
|
46
|
+
},
|
|
47
|
+
layers: [{ slot: "track", part: "dot", keep: true }],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RADIO_TRAVEL_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RADIO_TRAVEL_SCHEMA = defineSchema()({
|
|
3
|
+
id: "radioTravel",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "radioTravel",
|
|
6
|
+
fields: {
|
|
7
|
+
color: { kind: "color", label: "Dot colour", default: "var(--color-sx-primary)" },
|
|
8
|
+
duration: { kind: "number", label: "Duration", min: 0.1, max: 1, step: 0.05, unit: "s", default: 0.4 },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RadioUnderlineOptions {
|
|
3
|
+
/** The line's colour. Default `var(--color-sx-primary)`. */
|
|
4
|
+
readonly color?: string;
|
|
5
|
+
/** Seconds it takes to follow. Default `0.3`. */
|
|
6
|
+
readonly duration?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Tabs: the options in a row, an underline following the chosen one from tab to tab. */
|
|
9
|
+
export declare function radioUnderline(options?: RadioUnderlineOptions): FormEffect;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CHECKED, CHOICE, OPTIONS, ROW, at, choiceLayer, defineForm, inItem, radiosOf, v, varName } from "../kit.js";
|
|
2
|
+
import { bareOptions } from "./shape.js";
|
|
3
|
+
const ID = "radioUnderline";
|
|
4
|
+
const ROOT = radiosOf(ID);
|
|
5
|
+
const LINE = choiceLayer(ID, "line");
|
|
6
|
+
// Tabs: options in a row over a hairline, one line under the chosen one, as wide as it. Anchor positioning ties the
|
|
7
|
+
// line to the chosen option (its anchor name moves with `:checked`), so options of any width work; Chromium and WebKit
|
|
8
|
+
// glide it across, Firefox moves it at once. A browser without anchor positioning underlines the chosen option itself.
|
|
9
|
+
// The line is the state: it holds under reduced motion.
|
|
10
|
+
const STATE = `${bareOptions(ROOT)}
|
|
11
|
+
${at(`${ROOT} > ${OPTIONS}`)} {
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
gap: 0 1.25rem;
|
|
15
|
+
border-block-end: 1px solid var(--color-sx-border, currentColor);
|
|
16
|
+
}
|
|
17
|
+
${at(`${ROOT} ${ROW}`)} {
|
|
18
|
+
padding: 0.5rem 0.125rem;
|
|
19
|
+
}
|
|
20
|
+
${at(LINE)} {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
@supports (anchor-name: --a) {
|
|
24
|
+
${at(inItem(ROOT, CHECKED, ROW))} {
|
|
25
|
+
anchor-name: ${v(ID, "anchor")};
|
|
26
|
+
}
|
|
27
|
+
${at(`${ROOT}:has(${CHOICE}:checked) ${LINE}`)} {
|
|
28
|
+
display: block;
|
|
29
|
+
position-anchor: ${v(ID, "anchor")};
|
|
30
|
+
inset: auto;
|
|
31
|
+
inset-inline-start: anchor(start);
|
|
32
|
+
inset-inline-end: anchor(end);
|
|
33
|
+
inset-block-start: anchor(end);
|
|
34
|
+
block-size: 2px;
|
|
35
|
+
margin-block-start: -1px;
|
|
36
|
+
border-radius: 1px;
|
|
37
|
+
background: ${v(ID, "color")};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
@supports not (anchor-name: --a) {
|
|
41
|
+
${at(inItem(ROOT, CHECKED, ROW))} {
|
|
42
|
+
box-shadow: inset 0 -2px 0 ${v(ID, "color")};
|
|
43
|
+
}
|
|
44
|
+
}`;
|
|
45
|
+
const CSS = ` ${at(LINE)} {
|
|
46
|
+
transition: inset-inline-start ${v(ID, "time")} var(--ease-sx-out, ease-out), inset-inline-end ${v(ID, "time")} var(--ease-sx-out, ease-out);
|
|
47
|
+
}`;
|
|
48
|
+
/** Tabs: the options in a row, an underline following the chosen one from tab to tab. */
|
|
49
|
+
export function radioUnderline(options = {}) {
|
|
50
|
+
return defineForm(ID, CSS, {
|
|
51
|
+
fits: ["radio"],
|
|
52
|
+
state: STATE,
|
|
53
|
+
vars: {
|
|
54
|
+
[varName(ID, "color")]: options.color ?? "var(--color-sx-primary)",
|
|
55
|
+
// one anchor name per group: `{uid}` becomes the group's own id
|
|
56
|
+
[varName(ID, "anchor")]: "--{uid}-tab",
|
|
57
|
+
[varName(ID, "time")]: `${options.duration ?? 0.3}s`,
|
|
58
|
+
},
|
|
59
|
+
layers: [{ slot: "track", part: "line", keep: true }],
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RADIO_UNDERLINE_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RADIO_UNDERLINE_SCHEMA = defineSchema()({
|
|
3
|
+
id: "radioUnderline",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "radioUnderline",
|
|
6
|
+
fields: {
|
|
7
|
+
color: { kind: "color", label: "Line colour", default: "var(--color-sx-primary)" },
|
|
8
|
+
duration: { kind: "number", label: "Duration", min: 0.1, max: 0.8, step: 0.05, unit: "s", default: 0.3 },
|
|
9
|
+
},
|
|
10
|
+
});
|