@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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options with no circle: the box goes and its column closes, the words take the row. The focus ring moves to the
|
|
3
|
+
* option itself, and the words read quiet until chosen. The real radio stays in the label, so a click anywhere on the
|
|
4
|
+
* option still chooses it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bareOptions(root: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The words leave the screen but stay for screen readers (a star's "4 stars", a face's "Happy"): the option's name is
|
|
9
|
+
* still its words. Under forced colours they come back beside the browser's own radio.
|
|
10
|
+
*/
|
|
11
|
+
export declare function quietWords(root: string): string;
|
|
12
|
+
/** The option chosen, and every one before it in the group (a rating fills up to the choice). */
|
|
13
|
+
export declare const UP_TO_CHOSEN: (root: string, target: string) => string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// What several radio group effects share: options with no drawn circle (a segment, a tab, a number cell), and words
|
|
2
|
+
// only screen readers read (a star, a face). Under forced colours both give the browser's own radio and words back.
|
|
3
|
+
import { BOX, CHECKED, CHOICE, ITEM, KEYED, ROW, TEXT, at, inItem } from "../kit.js";
|
|
4
|
+
/**
|
|
5
|
+
* Options with no circle: the box goes and its column closes, the words take the row. The focus ring moves to the
|
|
6
|
+
* option itself, and the words read quiet until chosen. The real radio stays in the label, so a click anywhere on the
|
|
7
|
+
* option still chooses it.
|
|
8
|
+
*/
|
|
9
|
+
export function bareOptions(root) {
|
|
10
|
+
return ` ${at(`${root} ${ITEM}`)} {
|
|
11
|
+
--sx-choice-size: 0px;
|
|
12
|
+
--sx-choice-gap: 0px;
|
|
13
|
+
--sx-choice-text: var(--color-sx-muted);
|
|
14
|
+
}
|
|
15
|
+
${at(inItem(root, CHECKED))} {
|
|
16
|
+
--sx-choice-text: var(--color-sx-ink);
|
|
17
|
+
}
|
|
18
|
+
${at(`${root} ${BOX}`)} {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
|
+
${at(inItem(root, KEYED, ROW))} {
|
|
22
|
+
outline: 2px solid var(--color-sx-primary, currentColor);
|
|
23
|
+
outline-offset: 2px;
|
|
24
|
+
}
|
|
25
|
+
@media (forced-colors: active) {
|
|
26
|
+
${at(`${root} ${ITEM}`)} {
|
|
27
|
+
--sx-choice-size: 1.25em;
|
|
28
|
+
--sx-choice-gap: 0.5rem;
|
|
29
|
+
}
|
|
30
|
+
}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The words leave the screen but stay for screen readers (a star's "4 stars", a face's "Happy"): the option's name is
|
|
34
|
+
* still its words. Under forced colours they come back beside the browser's own radio.
|
|
35
|
+
*/
|
|
36
|
+
export function quietWords(root) {
|
|
37
|
+
return ` ${at(`${root} ${TEXT}`)} {
|
|
38
|
+
position: absolute;
|
|
39
|
+
inline-size: 1px;
|
|
40
|
+
block-size: 1px;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
clip-path: inset(50%);
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
}
|
|
45
|
+
${at(`${root} ${ITEM}`)} {
|
|
46
|
+
--sx-choice-gap: 0px;
|
|
47
|
+
}
|
|
48
|
+
@media (forced-colors: active) {
|
|
49
|
+
${at(`${root} ${TEXT}`)} {
|
|
50
|
+
position: static;
|
|
51
|
+
inline-size: auto;
|
|
52
|
+
block-size: auto;
|
|
53
|
+
clip-path: none;
|
|
54
|
+
}
|
|
55
|
+
${at(`${root} ${ITEM}`)} {
|
|
56
|
+
--sx-choice-gap: 0.5rem;
|
|
57
|
+
}
|
|
58
|
+
}`;
|
|
59
|
+
}
|
|
60
|
+
/** The option chosen, and every one before it in the group (a rating fills up to the choice). */
|
|
61
|
+
export const UP_TO_CHOSEN = (root, target) => `${root} ${ITEM}${CHECKED} ${target}, ${root} ${ITEM}:has(~ ${ITEM} ${CHOICE}:checked) ${target}`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RangeBubbleOptions {
|
|
3
|
+
/** When the bubble shows: `"drag"` while a thumb is dragged or has the keyboard's focus, or `"always"`. Default `"drag"`. */
|
|
4
|
+
readonly show?: "drag" | "always";
|
|
5
|
+
/** Seconds it takes to pop up. Default `0.2`. */
|
|
6
|
+
readonly duration?: number;
|
|
7
|
+
}
|
|
8
|
+
/** A bubble above the thumb shows the value while you drag (or always). */
|
|
9
|
+
export declare function rangeBubble(options?: RangeBubbleOptions): FormEffect;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SPRING, at, defineForm, draggedKnob, keyedKnob, rangeOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "rangeBubble";
|
|
3
|
+
const ROOT = rangeOf(ID);
|
|
4
|
+
const SAYS = "[data-sx-range-says]";
|
|
5
|
+
// Each thumb carries its value's words (`[data-sx-range-says]`, hidden by the base sheet); this shows them in a bubble
|
|
6
|
+
// above the thumb (beside it, upright), the value as the Range formats it. Whether it shows is the state; the pop is the
|
|
7
|
+
// motion.
|
|
8
|
+
const STATE = ` ${at(`${ROOT} ${SAYS}`)} {
|
|
9
|
+
display: block;
|
|
10
|
+
position: absolute;
|
|
11
|
+
inset-block-end: calc(100% + 0.5rem);
|
|
12
|
+
inset-inline-start: 50%;
|
|
13
|
+
translate: calc(-50% * var(--sx-form-dir)) 0;
|
|
14
|
+
padding: 0.125rem 0.5rem;
|
|
15
|
+
border-radius: 0.375rem;
|
|
16
|
+
background: var(--color-sx-ink, CanvasText);
|
|
17
|
+
color: var(--color-sx-secondary, Canvas);
|
|
18
|
+
font-size: 0.75rem;
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
font-variant-numeric: tabular-nums;
|
|
22
|
+
transform-origin: 50% 100%;
|
|
23
|
+
opacity: ${v(ID, "rest")};
|
|
24
|
+
}
|
|
25
|
+
${at(`${ROOT}[data-sx-vertical] ${SAYS}`)} {
|
|
26
|
+
inset-block-end: auto;
|
|
27
|
+
inset-block-start: 50%;
|
|
28
|
+
inset-inline-start: calc(100% + 0.5rem);
|
|
29
|
+
translate: 0 -50%;
|
|
30
|
+
transform-origin: 0 50%;
|
|
31
|
+
}
|
|
32
|
+
${at(`${draggedKnob(ROOT, SAYS)}, ${keyedKnob(ROOT, SAYS)}`)} {
|
|
33
|
+
opacity: 1;
|
|
34
|
+
}`;
|
|
35
|
+
const CSS = ` ${at(`${ROOT} ${SAYS}`)} {
|
|
36
|
+
scale: ${v(ID, "from")};
|
|
37
|
+
transition: opacity ${v(ID, "time")} var(--ease-sx-out, ease-out), scale ${v(ID, "time")} ${SPRING};
|
|
38
|
+
}
|
|
39
|
+
${at(`${draggedKnob(ROOT, SAYS)}, ${keyedKnob(ROOT, SAYS)}`)} {
|
|
40
|
+
scale: 1;
|
|
41
|
+
}`;
|
|
42
|
+
/** A bubble above the thumb shows the value while you drag (or always). */
|
|
43
|
+
export function rangeBubble(options = {}) {
|
|
44
|
+
const always = options.show === "always";
|
|
45
|
+
return defineForm(ID, CSS, {
|
|
46
|
+
fits: ["range"],
|
|
47
|
+
state: STATE,
|
|
48
|
+
vars: {
|
|
49
|
+
[varName(ID, "rest")]: always ? 1 : 0,
|
|
50
|
+
[varName(ID, "from")]: always ? 1 : 0.6,
|
|
51
|
+
[varName(ID, "time")]: `${options.duration ?? 0.2}s`,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RANGE_BUBBLE_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RANGE_BUBBLE_SCHEMA = defineSchema()({
|
|
3
|
+
id: "rangeBubble",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "rangeBubble",
|
|
6
|
+
fields: {
|
|
7
|
+
show: { kind: "choice", label: "Shows", values: ["drag", "always"], labels: { drag: "While dragged or focused", always: "Always" }, default: "drag" },
|
|
8
|
+
duration: { kind: "number", label: "Duration", min: 0.1, max: 0.4, step: 0.05, unit: "s", default: 0.2 },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RangeElasticOptions {
|
|
3
|
+
/** How far the rail may stretch past its end, as a share of its length. Default `0.12`. */
|
|
4
|
+
readonly stretch?: number;
|
|
5
|
+
/** How springy the way back is: 0 settles at once, 1 wobbles. Default `0.5`. */
|
|
6
|
+
readonly bounce?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Pull past the end and the rail stretches after the finger, then springs back. Runs code: the page needs "use client". */
|
|
9
|
+
export declare function rangeElastic(options?: RangeElasticOptions): FormEffect;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { stillMotion } from "../../../buttons/runtime/press.js";
|
|
2
|
+
import { KNOB, RAIL, at, defineForm, rangeOf } from "../kit.js";
|
|
3
|
+
const ID = "rangeElastic";
|
|
4
|
+
const ROOT = rangeOf(ID);
|
|
5
|
+
// Pull a thumb past the end and the rail stretches after the finger, thinning a little as it goes, with the thumb on
|
|
6
|
+
// its end; let go and it springs back. The program writes `--sx-range-stretch` (the rail's scale) and `--sx-range-origin`
|
|
7
|
+
// (the end that stays put) on the rail, and `--sx-range-pull` (px) on the thumb, which the base sheet adds to its place.
|
|
8
|
+
const CSS = ` ${at(`${ROOT} ${RAIL}`)} {
|
|
9
|
+
scale: var(--sx-range-stretch, 1) calc(2 - var(--sx-range-stretch, 1));
|
|
10
|
+
transform-origin: var(--sx-range-origin, 50%) 50%;
|
|
11
|
+
}
|
|
12
|
+
${at(`${ROOT}[data-sx-vertical] ${RAIL}`)} {
|
|
13
|
+
scale: calc(2 - var(--sx-range-stretch, 1)) var(--sx-range-stretch, 1);
|
|
14
|
+
transform-origin: 50% var(--sx-range-origin, 50%);
|
|
15
|
+
}`;
|
|
16
|
+
/** The program: the stretch follows the finger past the end, then a small spring of our own brings it back. */
|
|
17
|
+
function elastic(stretch, bounce) {
|
|
18
|
+
return {
|
|
19
|
+
signature: JSON.stringify({ stretch, bounce }),
|
|
20
|
+
attach: (root) => {
|
|
21
|
+
const box = root.querySelector("[data-sx-range-box]");
|
|
22
|
+
const rail = root.querySelector(RAIL);
|
|
23
|
+
if (!box || !rail)
|
|
24
|
+
return () => { };
|
|
25
|
+
let pull = 0;
|
|
26
|
+
let speed = 0;
|
|
27
|
+
let frame = 0;
|
|
28
|
+
let knob = null;
|
|
29
|
+
const upright = () => root.hasAttribute("data-sx-vertical");
|
|
30
|
+
const length = () => (upright() ? rail.offsetHeight : rail.offsetWidth) || 1;
|
|
31
|
+
const write = () => {
|
|
32
|
+
const s = 1 + Math.abs(pull) / length();
|
|
33
|
+
const rtl = getComputedStyle(root).direction === "rtl";
|
|
34
|
+
// the end away from the pull stays put
|
|
35
|
+
const towardStart = pull < 0;
|
|
36
|
+
const origin = upright() ? (towardStart ? "0%" : "100%") : towardStart !== rtl ? "100%" : "0%";
|
|
37
|
+
rail.style.setProperty("--sx-range-stretch", String(s));
|
|
38
|
+
rail.style.setProperty("--sx-range-origin", origin);
|
|
39
|
+
knob?.style.setProperty("--sx-range-pull", `${pull}px`);
|
|
40
|
+
};
|
|
41
|
+
const clear = () => {
|
|
42
|
+
rail.style.removeProperty("--sx-range-stretch");
|
|
43
|
+
rail.style.removeProperty("--sx-range-origin");
|
|
44
|
+
knob?.style.removeProperty("--sx-range-pull");
|
|
45
|
+
};
|
|
46
|
+
const move = (e) => {
|
|
47
|
+
const which = root.getAttribute("data-sx-dragging");
|
|
48
|
+
if (!which || stillMotion())
|
|
49
|
+
return;
|
|
50
|
+
knob = root.querySelector(`${KNOB}[data-sx-thumb="${which}"]`);
|
|
51
|
+
const place = Number(knob?.style.getPropertyValue("--sx-at") || 0);
|
|
52
|
+
const r = box.getBoundingClientRect();
|
|
53
|
+
const rtl = getComputedStyle(root).direction === "rtl";
|
|
54
|
+
const along = upright() ? r.bottom - e.clientY : rtl ? r.right - e.clientX : e.clientX - r.left;
|
|
55
|
+
const end = upright() ? r.height : r.width;
|
|
56
|
+
// only past the end the thumb already sits on
|
|
57
|
+
const over = along > end && place >= 0.999 ? along - end : along < 0 && place <= 0.001 ? along : 0;
|
|
58
|
+
const most = stretch * length();
|
|
59
|
+
cancelAnimationFrame(frame);
|
|
60
|
+
pull = Math.sign(over) * most * (1 - Math.exp(-Math.abs(over) / most));
|
|
61
|
+
speed = 0;
|
|
62
|
+
write();
|
|
63
|
+
};
|
|
64
|
+
const release = () => {
|
|
65
|
+
if (pull === 0)
|
|
66
|
+
return;
|
|
67
|
+
const k = 420;
|
|
68
|
+
const damping = 2 * Math.sqrt(k) * (1 - 0.7 * Math.min(1, Math.max(0, bounce)));
|
|
69
|
+
let last = performance.now();
|
|
70
|
+
const step = (now) => {
|
|
71
|
+
const dt = Math.min(0.032, (now - last) / 1000);
|
|
72
|
+
last = now;
|
|
73
|
+
speed += (-k * pull - damping * speed) * dt;
|
|
74
|
+
pull += speed * dt;
|
|
75
|
+
if (Math.abs(pull) < 0.2 && Math.abs(speed) < 2) {
|
|
76
|
+
pull = 0;
|
|
77
|
+
clear();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
write();
|
|
81
|
+
frame = requestAnimationFrame(step);
|
|
82
|
+
};
|
|
83
|
+
frame = requestAnimationFrame(step);
|
|
84
|
+
};
|
|
85
|
+
addEventListener("pointermove", move);
|
|
86
|
+
addEventListener("pointerup", release);
|
|
87
|
+
addEventListener("pointercancel", release);
|
|
88
|
+
return () => {
|
|
89
|
+
cancelAnimationFrame(frame);
|
|
90
|
+
removeEventListener("pointermove", move);
|
|
91
|
+
removeEventListener("pointerup", release);
|
|
92
|
+
removeEventListener("pointercancel", release);
|
|
93
|
+
clear();
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** Pull past the end and the rail stretches after the finger, then springs back. Runs code: the page needs "use client". */
|
|
99
|
+
export function rangeElastic(options = {}) {
|
|
100
|
+
return defineForm(ID, CSS, { fits: ["range"], program: elastic(options.stretch ?? 0.12, options.bounce ?? 0.5) });
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RANGE_ELASTIC_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RANGE_ELASTIC_SCHEMA = defineSchema()({
|
|
3
|
+
id: "rangeElastic",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "rangeElastic",
|
|
6
|
+
fields: {
|
|
7
|
+
stretch: { kind: "number", label: "Stretch", min: 0.04, max: 0.3, step: 0.01, default: 0.12, help: "How far past its end the rail may stretch, as a share of its length." },
|
|
8
|
+
bounce: { kind: "number", label: "Bounce", min: 0, max: 1, step: 0.1, default: 0.5 },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RangeFaceOptions {
|
|
3
|
+
/** The face's size, rem: the thumb grows to it. Default `2`. */
|
|
4
|
+
readonly size?: number;
|
|
5
|
+
/** The face's colour at the low end. Default `var(--color-sx-danger)`. */
|
|
6
|
+
readonly low?: string;
|
|
7
|
+
/** Its colour at the high end. Default `var(--color-sx-success)`. */
|
|
8
|
+
readonly high?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The thumb is a face that frowns at the low end and smiles at the high end. */
|
|
11
|
+
export declare function rangeFace(options?: RangeFaceOptions): FormEffect;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { KNOB, at, choiceLayer, defineForm, rangeOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "rangeFace";
|
|
3
|
+
const ROOT = rangeOf(ID);
|
|
4
|
+
const FACE = choiceLayer(ID, "face");
|
|
5
|
+
const PART = (part) => `${FACE} [data-sx-choice-svg="${part}"]`;
|
|
6
|
+
// The thumb is a face, our own drawing, that frowns at the low end and smiles at the high end. The mouth is one curve
|
|
7
|
+
// scaled upside down and back by the thumb's place (`--sx-at`), never quite flat to nothing (a scale of 0 draws nothing);
|
|
8
|
+
// its line keeps its width at any scale. The colour mixes from `low` to `high` the same way. It shows the value: it
|
|
9
|
+
// holds under reduced motion.
|
|
10
|
+
const STATE = ` ${at(ROOT)} {
|
|
11
|
+
--sx-range-thumb: ${v(ID, "size")};
|
|
12
|
+
--sx-range-knob: transparent;
|
|
13
|
+
}
|
|
14
|
+
${at(`${ROOT} ${KNOB}`)} {
|
|
15
|
+
box-shadow: none;
|
|
16
|
+
}
|
|
17
|
+
${at(`${ROOT} ${FACE}`)} {
|
|
18
|
+
inset: 0;
|
|
19
|
+
}
|
|
20
|
+
${at(`${ROOT} ${FACE} > svg`)} {
|
|
21
|
+
display: block;
|
|
22
|
+
inline-size: 100%;
|
|
23
|
+
block-size: 100%;
|
|
24
|
+
overflow: visible;
|
|
25
|
+
}
|
|
26
|
+
${at(`${ROOT} ${PART("head")}`)} {
|
|
27
|
+
fill: color-mix(in oklab, ${v(ID, "high")} calc(var(--sx-at) * 100%), ${v(ID, "low")});
|
|
28
|
+
}
|
|
29
|
+
${at(`${ROOT} ${PART("eyes")}`)} {
|
|
30
|
+
fill: var(--color-sx-ink, currentColor);
|
|
31
|
+
}
|
|
32
|
+
${at(`${ROOT} ${PART("mouth")}`)} {
|
|
33
|
+
fill: none;
|
|
34
|
+
stroke: var(--color-sx-ink, currentColor);
|
|
35
|
+
stroke-width: 2;
|
|
36
|
+
stroke-linecap: round;
|
|
37
|
+
vector-effect: non-scaling-stroke;
|
|
38
|
+
transform-box: fill-box;
|
|
39
|
+
transform-origin: center;
|
|
40
|
+
scale: 1 calc(var(--sx-at) * 2 - 0.999);
|
|
41
|
+
}`;
|
|
42
|
+
/** The thumb is a face that frowns at the low end and smiles at the high end. */
|
|
43
|
+
export function rangeFace(options = {}) {
|
|
44
|
+
return defineForm(ID, "", {
|
|
45
|
+
fits: ["range"],
|
|
46
|
+
state: STATE,
|
|
47
|
+
vars: {
|
|
48
|
+
[varName(ID, "size")]: `${options.size ?? 2}rem`,
|
|
49
|
+
[varName(ID, "low")]: options.low ?? "var(--color-sx-danger)",
|
|
50
|
+
[varName(ID, "high")]: options.high ?? "var(--color-sx-success)",
|
|
51
|
+
},
|
|
52
|
+
layers: [
|
|
53
|
+
{
|
|
54
|
+
slot: "thumb",
|
|
55
|
+
part: "face",
|
|
56
|
+
keep: true,
|
|
57
|
+
svg: {
|
|
58
|
+
viewBox: "0 0 24 24",
|
|
59
|
+
children: [
|
|
60
|
+
{ tag: "circle", part: "head", attrs: { cx: 12, cy: 12, r: 11 } },
|
|
61
|
+
{ tag: "path", part: "eyes", attrs: { d: "M8.5 10a1.4 1.4 0 1 0 0-.01zM15.5 10a1.4 1.4 0 1 0 0-.01z" } },
|
|
62
|
+
{ tag: "path", part: "mouth", attrs: { d: "M8 15q4 3.5 8 0" } },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RANGE_FACE_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RANGE_FACE_SCHEMA = defineSchema()({
|
|
3
|
+
id: "rangeFace",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "rangeFace",
|
|
6
|
+
fields: {
|
|
7
|
+
size: { kind: "number", label: "Size", min: 1.5, max: 3, step: 0.25, unit: "rem", default: 2 },
|
|
8
|
+
low: { kind: "color", label: "Low colour", default: "var(--color-sx-danger)" },
|
|
9
|
+
high: { kind: "color", label: "High colour", default: "var(--color-sx-success)" },
|
|
10
|
+
},
|
|
11
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RangeFillOptions {
|
|
3
|
+
/** The filled part's colour. Default `var(--color-sx-primary)`. */
|
|
4
|
+
readonly color?: string;
|
|
5
|
+
}
|
|
6
|
+
/** The rail fills up to the thumb, or between the two thumbs. */
|
|
7
|
+
export declare function rangeFill(options?: RangeFillOptions): FormEffect;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RAIL, at, choiceLayer, defineForm, rangeOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "rangeFill";
|
|
3
|
+
const ROOT = rangeOf(ID);
|
|
4
|
+
const FILL = `${RAIL} > ${choiceLayer(ID, "fill")}`;
|
|
5
|
+
// The rail fills from its start to the thumb (between the two thumbs with two). The fill is the whole rail, scaled to
|
|
6
|
+
// the filled share from the start side and moved to the low thumb (`--sx-range-from` / `-to`): a transform, so it glides
|
|
7
|
+
// with the thumbs (the base sheet's transition). It shows the value: it holds under reduced motion.
|
|
8
|
+
const STATE = ` ${at(`${ROOT} ${FILL}`)} {
|
|
9
|
+
inset: 0;
|
|
10
|
+
border-radius: inherit;
|
|
11
|
+
background: ${v(ID, "color")};
|
|
12
|
+
transform-origin: calc(50% - 50% * var(--sx-form-dir)) 50%;
|
|
13
|
+
translate: calc(var(--sx-range-from) * 100% * var(--sx-form-dir)) 0;
|
|
14
|
+
scale: calc(var(--sx-range-to) - var(--sx-range-from)) 1;
|
|
15
|
+
}
|
|
16
|
+
${at(`${ROOT}[data-sx-vertical] ${FILL}`)} {
|
|
17
|
+
transform-origin: 50% 100%;
|
|
18
|
+
translate: 0 calc(var(--sx-range-from) * -100%);
|
|
19
|
+
scale: 1 calc(var(--sx-range-to) - var(--sx-range-from));
|
|
20
|
+
}`;
|
|
21
|
+
/** The rail fills up to the thumb, or between the two thumbs. */
|
|
22
|
+
export function rangeFill(options = {}) {
|
|
23
|
+
return defineForm(ID, "", {
|
|
24
|
+
fits: ["range"],
|
|
25
|
+
state: STATE,
|
|
26
|
+
vars: { [varName(ID, "color")]: options.color ?? "var(--color-sx-primary)" },
|
|
27
|
+
layers: [{ slot: "track", part: "fill", keep: true }],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RANGE_FILL_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RANGE_FILL_SCHEMA = defineSchema()({
|
|
3
|
+
id: "rangeFill",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "rangeFill",
|
|
6
|
+
fields: {
|
|
7
|
+
color: { kind: "color", label: "Fill colour", default: "var(--color-sx-primary)" },
|
|
8
|
+
},
|
|
9
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SvgElement } from "../../../backgrounds/types.js";
|
|
2
|
+
import type { FormEffect } from "../../types.js";
|
|
3
|
+
export interface RangeHistogramOptions {
|
|
4
|
+
/** One bar per value, left to right (the lowest values first): how many items each stretch holds. Default a sample bell. */
|
|
5
|
+
readonly values?: readonly number[];
|
|
6
|
+
/** The bars' height, rem. Default `2.5`. */
|
|
7
|
+
readonly height?: number;
|
|
8
|
+
/** The colour of the bars inside the chosen stretch. Default `var(--color-sx-primary)`. */
|
|
9
|
+
readonly color?: string;
|
|
10
|
+
}
|
|
11
|
+
/** The bars as SVG rectangles in a box `values.length` wide and 100 tall, tallest at the top. */
|
|
12
|
+
export declare function histogramBars(values: readonly number[]): SvgElement[];
|
|
13
|
+
/** Bars above the rail show how the values spread; the ones inside the chosen stretch light up. */
|
|
14
|
+
export declare function rangeHistogram(options?: RangeHistogramOptions): FormEffect;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RAIL, at, choiceLayer, defineForm, rangeOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "rangeHistogram";
|
|
3
|
+
const ROOT = rangeOf(ID);
|
|
4
|
+
const BARS = `${RAIL} > ${choiceLayer(ID, "bars")}`;
|
|
5
|
+
const LIT = `${RAIL} > ${choiceLayer(ID, "lit")}`;
|
|
6
|
+
/** A sample to show the effect before real data arrives: a gentle bell with a second hump. */
|
|
7
|
+
const SAMPLE = [2, 3, 5, 8, 12, 17, 22, 26, 28, 27, 23, 19, 15, 13, 14, 16, 15, 12, 9, 6, 4, 3, 2, 1];
|
|
8
|
+
/** The bars as SVG rectangles in a box `values.length` wide and 100 tall, tallest at the top. */
|
|
9
|
+
export function histogramBars(values) {
|
|
10
|
+
const top = Math.max(1, ...values.map((n) => (Number.isFinite(n) && n > 0 ? n : 0)));
|
|
11
|
+
return values.map((n, i) => {
|
|
12
|
+
const h = Math.max(0, Math.min(100, ((Number.isFinite(n) && n > 0 ? n : 0) / top) * 100));
|
|
13
|
+
return { tag: "rect", attrs: { x: i + 0.12, y: 100 - h, width: 0.76, height: h } };
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
// The spread of what the slider filters (prices, sizes), as bars above the rail: two copies, a quiet one, and a lit one
|
|
17
|
+
// clipped to the chosen stretch (`--sx-range-from` / `-to`, mirrored right to left), which glides with the thumbs. The
|
|
18
|
+
// bars show data: they hold under reduced motion. Across only: an upright Range hides them.
|
|
19
|
+
const STATE = ` ${at(`${ROOT} [data-sx-range-box]`)} {
|
|
20
|
+
margin-block-start: calc(${v(ID, "height")} + 0.5rem);
|
|
21
|
+
}
|
|
22
|
+
${at(`${ROOT} ${BARS}, ${ROOT} ${LIT}`)} {
|
|
23
|
+
inset-inline: 0;
|
|
24
|
+
inset-block-end: calc(100% + (max(1.5rem, var(--sx-range-thumb)) - var(--sx-range-h)) / 2 + 0.25rem);
|
|
25
|
+
block-size: ${v(ID, "height")};
|
|
26
|
+
}
|
|
27
|
+
${at(`${ROOT} ${BARS} > svg, ${ROOT} ${LIT} > svg`)} {
|
|
28
|
+
display: block;
|
|
29
|
+
inline-size: 100%;
|
|
30
|
+
block-size: 100%;
|
|
31
|
+
fill: currentColor;
|
|
32
|
+
}
|
|
33
|
+
${at(`${ROOT}:dir(rtl) ${BARS} > svg, ${ROOT}:dir(rtl) ${LIT} > svg`)} {
|
|
34
|
+
scale: -1 1;
|
|
35
|
+
}
|
|
36
|
+
${at(`${ROOT} ${BARS}`)} {
|
|
37
|
+
color: color-mix(in oklab, var(--color-sx-muted, currentColor) 35%, transparent);
|
|
38
|
+
}
|
|
39
|
+
${at(`${ROOT} ${LIT}`)} {
|
|
40
|
+
color: ${v(ID, "color")};
|
|
41
|
+
clip-path: inset(0 calc((1 - var(--sx-range-to)) * 100%) 0 calc(var(--sx-range-from) * 100%));
|
|
42
|
+
}
|
|
43
|
+
${at(`${ROOT}:dir(rtl) ${LIT}`)} {
|
|
44
|
+
clip-path: inset(0 calc(var(--sx-range-from) * 100%) 0 calc((1 - var(--sx-range-to)) * 100%));
|
|
45
|
+
}
|
|
46
|
+
${at(`${ROOT}[data-sx-vertical] ${BARS}, ${ROOT}[data-sx-vertical] ${LIT}`)} {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
${at(`${ROOT}[data-sx-vertical] [data-sx-range-box]`)} {
|
|
50
|
+
margin-block-start: 0;
|
|
51
|
+
}`;
|
|
52
|
+
/** Bars above the rail show how the values spread; the ones inside the chosen stretch light up. */
|
|
53
|
+
export function rangeHistogram(options = {}) {
|
|
54
|
+
const bars = histogramBars(options.values ?? SAMPLE);
|
|
55
|
+
const svg = { viewBox: `0 0 ${Math.max(1, bars.length)} 100`, preserveAspectRatio: "none", children: bars };
|
|
56
|
+
return defineForm(ID, "", {
|
|
57
|
+
fits: ["range"],
|
|
58
|
+
state: STATE,
|
|
59
|
+
vars: { [varName(ID, "height")]: `${options.height ?? 2.5}rem`, [varName(ID, "color")]: options.color ?? "var(--color-sx-primary)" },
|
|
60
|
+
layers: [
|
|
61
|
+
{ slot: "track", part: "bars", keep: true, svg },
|
|
62
|
+
{ slot: "track", part: "lit", keep: true, svg },
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RANGE_HISTOGRAM_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RANGE_HISTOGRAM_SCHEMA = defineSchema()({
|
|
3
|
+
id: "rangeHistogram",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "rangeHistogram",
|
|
6
|
+
fields: {
|
|
7
|
+
height: { kind: "number", label: "Height", min: 1.5, max: 5, step: 0.25, unit: "rem", default: 2.5 },
|
|
8
|
+
color: { kind: "color", label: "Lit colour", default: "var(--color-sx-primary)" },
|
|
9
|
+
},
|
|
10
|
+
code: ["values"],
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RangeThumbOptions {
|
|
3
|
+
/** How big the thumb grows while dragged. Default `1.3`. */
|
|
4
|
+
readonly scale?: number;
|
|
5
|
+
/** The halo's colour around a dragged thumb. Default the primary colour, faint. */
|
|
6
|
+
readonly color?: string;
|
|
7
|
+
}
|
|
8
|
+
/** The thumb grows under the finger, with a soft halo round it. */
|
|
9
|
+
export declare function rangeThumb(options?: RangeThumbOptions): FormEffect;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { KNOB, at, choiceLayer, defineForm, draggedKnob, rangeOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "rangeThumb";
|
|
3
|
+
const ROOT = rangeOf(ID);
|
|
4
|
+
const HALO = choiceLayer(ID, "halo");
|
|
5
|
+
// The thumb grows under the finger (a third of the way on a mouse's hover) and a soft halo opens round it, so you see
|
|
6
|
+
// what you hold. The base sheet owns the transition (`--sx-range-grow`); this only says how big. All motion: under
|
|
7
|
+
// reduced motion the thumb stays its size, and its place still shows the value.
|
|
8
|
+
const CSS = ` ${at(`${ROOT} ${HALO}`)} {
|
|
9
|
+
inset: -0.5rem;
|
|
10
|
+
z-index: -1;
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
background: ${v(ID, "color")};
|
|
13
|
+
scale: 0.5;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
transition: scale 0.2s var(--ease-sx-out, ease-out), opacity 0.2s var(--ease-sx-out, ease-out);
|
|
16
|
+
}
|
|
17
|
+
@media (hover: hover) and (pointer: fine) {
|
|
18
|
+
${at(`${ROOT}:not(:has(:disabled)) [data-sx-range-box]:hover ${KNOB}`)} {
|
|
19
|
+
scale: calc(1 + (${v(ID, "scale")} - 1) / 3);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
${at(draggedKnob(ROOT))} {
|
|
23
|
+
scale: ${v(ID, "scale")};
|
|
24
|
+
}
|
|
25
|
+
${at(draggedKnob(ROOT, HALO))} {
|
|
26
|
+
scale: 1;
|
|
27
|
+
opacity: 1;
|
|
28
|
+
}`;
|
|
29
|
+
/** The thumb grows under the finger, with a soft halo round it. */
|
|
30
|
+
export function rangeThumb(options = {}) {
|
|
31
|
+
return defineForm(ID, CSS, {
|
|
32
|
+
fits: ["range"],
|
|
33
|
+
vars: {
|
|
34
|
+
[varName(ID, "scale")]: options.scale ?? 1.3,
|
|
35
|
+
[varName(ID, "color")]: options.color ?? "color-mix(in oklab, var(--color-sx-primary) 20%, transparent)",
|
|
36
|
+
},
|
|
37
|
+
layers: [{ slot: "thumb", part: "halo" }],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RANGE_THUMB_SCHEMA: import("../../../schema/types.js").Schema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineSchema } from "../../../schema/define.js";
|
|
2
|
+
export const RANGE_THUMB_SCHEMA = defineSchema()({
|
|
3
|
+
id: "rangeThumb",
|
|
4
|
+
family: "form",
|
|
5
|
+
factory: "rangeThumb",
|
|
6
|
+
fields: {
|
|
7
|
+
scale: { kind: "number", label: "Grow to", min: 1, max: 1.8, step: 0.05, unit: "×", default: 1.3 },
|
|
8
|
+
color: { kind: "color", label: "Halo colour", default: "color-mix(in oklab, var(--color-sx-primary) 20%, transparent)" },
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormEffect } from "../../types.js";
|
|
2
|
+
export interface RangeTicksOptions {
|
|
3
|
+
/** How many gaps between ticks. Default: every step up to 20 steps, else the most up to 20 that land on steps. */
|
|
4
|
+
readonly count?: number;
|
|
5
|
+
/** The ticks' colour. Default `var(--color-sx-muted)`. */
|
|
6
|
+
readonly color?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Ticks under the rail, one per step; the thumb springs from tick to tick. */
|
|
9
|
+
export declare function rangeTicks(options?: RangeTicksOptions): FormEffect;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RAIL, at, choiceLayer, defineForm, rangeOf, v, varName } from "../kit.js";
|
|
2
|
+
const ID = "rangeTicks";
|
|
3
|
+
const ROOT = rangeOf(ID);
|
|
4
|
+
const TICKS = `${RAIL} > ${choiceLayer(ID, "ticks")}`;
|
|
5
|
+
const COUNT = `var(${varName(ID, "count")}, var(--sx-range-ticks, 10))`;
|
|
6
|
+
// A row of ticks under the rail, one per step (the Range writes the count it suits, `--sx-range-ticks`), drawn as one
|
|
7
|
+
// repeating gradient, so a hundred ticks cost one layer. The ticks are the state; the motion is the thumb springing
|
|
8
|
+
// from tick to tick while dragged (the base sheet's glide, switched on during a drag).
|
|
9
|
+
const STATE = ` ${at(`${ROOT} [data-sx-range-box]`)} {
|
|
10
|
+
margin-block-end: 0.75rem;
|
|
11
|
+
}
|
|
12
|
+
${at(`${ROOT} ${TICKS}`)} {
|
|
13
|
+
inset-inline: 0 -1px;
|
|
14
|
+
inset-block-start: calc(100% + 0.375rem);
|
|
15
|
+
block-size: 0.375rem;
|
|
16
|
+
color: ${v(ID, "color")};
|
|
17
|
+
background: repeating-linear-gradient(to right, currentColor 0 1px, transparent 1px calc((100% - 1px) / ${COUNT}));
|
|
18
|
+
}
|
|
19
|
+
${at(`${ROOT}[data-sx-vertical] [data-sx-range-box]`)} {
|
|
20
|
+
margin-block-end: 0;
|
|
21
|
+
margin-inline-end: 0.75rem;
|
|
22
|
+
}
|
|
23
|
+
${at(`${ROOT}[data-sx-vertical] ${TICKS}`)} {
|
|
24
|
+
inset-inline: calc(100% + 0.375rem) auto;
|
|
25
|
+
inset-block: -1px 0;
|
|
26
|
+
inline-size: 0.375rem;
|
|
27
|
+
block-size: auto;
|
|
28
|
+
background: repeating-linear-gradient(to top, currentColor 0 1px, transparent 1px calc((100% - 1px) / ${COUNT}));
|
|
29
|
+
}`;
|
|
30
|
+
const CSS = ` ${at(ROOT)} {
|
|
31
|
+
--sx-range-drag-glide: 0.12s;
|
|
32
|
+
}`;
|
|
33
|
+
/** Ticks under the rail, one per step; the thumb springs from tick to tick. */
|
|
34
|
+
export function rangeTicks(options = {}) {
|
|
35
|
+
return defineForm(ID, CSS, {
|
|
36
|
+
fits: ["range"],
|
|
37
|
+
state: STATE,
|
|
38
|
+
vars: {
|
|
39
|
+
[varName(ID, "color")]: options.color ?? "var(--color-sx-muted)",
|
|
40
|
+
...(options.count === undefined ? {} : { [varName(ID, "count")]: Math.max(1, Math.round(options.count)) }),
|
|
41
|
+
},
|
|
42
|
+
layers: [{ slot: "track", part: "ticks", keep: true }],
|
|
43
|
+
});
|
|
44
|
+
}
|