@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,140 @@
|
|
|
1
|
+
// The structural sheet of ChipGroup: a `<fieldset>` of filter chips, each a label round its real checkbox (or radio),
|
|
2
|
+
// which lies over the whole chip at opacity 0 and takes the click, the keys and the focus. A chip that is on opens a
|
|
3
|
+
// column for its check before the words. Positioning only; the look is styles/form.css. Pure string. See ./CLAUDE.md.
|
|
4
|
+
import { LAYER_ORDER } from "../backgrounds/runtime/rootCss.js";
|
|
5
|
+
const CONTROL = "[data-sx-chip-control]";
|
|
6
|
+
const ON = `:has(${CONTROL}:checked)`;
|
|
7
|
+
// High contrast: the real checkbox comes back at the chip's start; the drawn check and the layers step aside.
|
|
8
|
+
export const CHIPS_CSS = `${LAYER_ORDER}
|
|
9
|
+
@layer components {
|
|
10
|
+
:where([data-sx-chips]) {
|
|
11
|
+
--sx-form-dir: 1;
|
|
12
|
+
--sx-chips-gap: 0.5rem;
|
|
13
|
+
min-inline-size: 0;
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
border: 0;
|
|
17
|
+
}
|
|
18
|
+
:where([data-sx-chips]:dir(rtl)) {
|
|
19
|
+
--sx-form-dir: -1;
|
|
20
|
+
}
|
|
21
|
+
:where([data-sx-chips-legend]) {
|
|
22
|
+
padding: 0;
|
|
23
|
+
margin-block-end: 0.5rem;
|
|
24
|
+
}
|
|
25
|
+
:where([data-sx-chips-description]) {
|
|
26
|
+
margin: 0 0 0.5rem;
|
|
27
|
+
}
|
|
28
|
+
:where([data-sx-chips-options]) {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-wrap: wrap;
|
|
31
|
+
gap: var(--sx-chips-gap);
|
|
32
|
+
}
|
|
33
|
+
:where([data-sx-chip-option]) {
|
|
34
|
+
position: relative;
|
|
35
|
+
isolation: isolate;
|
|
36
|
+
display: inline-grid;
|
|
37
|
+
grid-template-columns: minmax(0, 0fr) auto;
|
|
38
|
+
align-items: center;
|
|
39
|
+
min-block-size: 2rem;
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
padding-inline: 0.75rem;
|
|
42
|
+
border-radius: 999px;
|
|
43
|
+
line-height: 1.25;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
user-select: none;
|
|
46
|
+
-webkit-tap-highlight-color: transparent;
|
|
47
|
+
}
|
|
48
|
+
:where([data-sx-chip-option]${ON}) {
|
|
49
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
50
|
+
}
|
|
51
|
+
:where([data-sx-chip-check]) {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
min-inline-size: 0;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
}
|
|
57
|
+
:where([data-sx-chip-check] > svg) {
|
|
58
|
+
flex: none;
|
|
59
|
+
inline-size: 1em;
|
|
60
|
+
block-size: 1em;
|
|
61
|
+
margin-inline-end: 0.375rem;
|
|
62
|
+
overflow: visible;
|
|
63
|
+
fill: none;
|
|
64
|
+
stroke: currentColor;
|
|
65
|
+
stroke-width: 2.5;
|
|
66
|
+
stroke-linecap: round;
|
|
67
|
+
stroke-linejoin: round;
|
|
68
|
+
}
|
|
69
|
+
:where([data-sx-chip-check] path) {
|
|
70
|
+
stroke-dasharray: 1 2;
|
|
71
|
+
stroke-dashoffset: 1.01;
|
|
72
|
+
}
|
|
73
|
+
:where([data-sx-chip-option]${ON} [data-sx-chip-check] path) {
|
|
74
|
+
stroke-dashoffset: 0;
|
|
75
|
+
}
|
|
76
|
+
:where(${CONTROL}) {
|
|
77
|
+
position: absolute;
|
|
78
|
+
inset: 0;
|
|
79
|
+
z-index: 1;
|
|
80
|
+
inline-size: 100%;
|
|
81
|
+
block-size: 100%;
|
|
82
|
+
margin: 0;
|
|
83
|
+
border-radius: inherit;
|
|
84
|
+
opacity: 0;
|
|
85
|
+
cursor: inherit;
|
|
86
|
+
appearance: none;
|
|
87
|
+
}
|
|
88
|
+
:where([data-sx-chip-option]:has(${CONTROL}:focus-visible)) {
|
|
89
|
+
outline: 2px solid var(--color-sx-primary, currentColor);
|
|
90
|
+
outline-offset: 2px;
|
|
91
|
+
}
|
|
92
|
+
:where([data-sx-chip-option]:has(${CONTROL}:disabled)) {
|
|
93
|
+
opacity: 0.55;
|
|
94
|
+
cursor: not-allowed;
|
|
95
|
+
}
|
|
96
|
+
:where([data-sx-chips] [data-sx-chip-layer]) {
|
|
97
|
+
position: absolute;
|
|
98
|
+
z-index: -1;
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
}
|
|
101
|
+
:where([data-sx-chips-message]) {
|
|
102
|
+
display: grid;
|
|
103
|
+
grid-template-rows: 0fr;
|
|
104
|
+
}
|
|
105
|
+
:where([data-sx-chips-message]:has([data-sx-chips-says])) {
|
|
106
|
+
grid-template-rows: 1fr;
|
|
107
|
+
}
|
|
108
|
+
:where([data-sx-chips-error]) {
|
|
109
|
+
min-block-size: 0;
|
|
110
|
+
margin: 0;
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
}
|
|
113
|
+
:where([data-sx-chips-says]) {
|
|
114
|
+
display: block;
|
|
115
|
+
padding-block-start: 0.375rem;
|
|
116
|
+
}
|
|
117
|
+
@media (prefers-reduced-motion: reduce) {
|
|
118
|
+
:where([data-sx-chips] [data-sx-chip-layer]:not([data-sx-chip-keep])) {
|
|
119
|
+
display: none;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
@media (forced-colors: active) {
|
|
123
|
+
:where([data-sx-chip-option]) {
|
|
124
|
+
grid-template-columns: auto auto;
|
|
125
|
+
column-gap: 0.375rem;
|
|
126
|
+
border: 1px solid ButtonText;
|
|
127
|
+
}
|
|
128
|
+
:where(${CONTROL}) {
|
|
129
|
+
position: static;
|
|
130
|
+
grid-area: 1 / 1;
|
|
131
|
+
inline-size: 1em;
|
|
132
|
+
block-size: 1em;
|
|
133
|
+
opacity: 1;
|
|
134
|
+
appearance: auto;
|
|
135
|
+
}
|
|
136
|
+
:where([data-sx-chip-check], [data-sx-chips] [data-sx-chip-layer]) {
|
|
137
|
+
display: none;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CHOICE_BASE_CSS = "@layer theme, base, components, utilities;\n@layer components {\n :where([data-sx-choice], [data-sx-group]) {\n --sx-form-dir: 1;\n }\n :where([data-sx-choice]:dir(rtl), [data-sx-group]:dir(rtl)) {\n --sx-form-dir: -1;\n }\n :where([data-sx-choice]) {\n --sx-choice-size: 1.25em;\n --sx-choice-gap: 0.625rem;\n position: relative;\n min-inline-size: 0;\n }\n :where([data-sx-choice-row]) {\n position: relative;\n isolation: isolate;\n display: grid;\n grid-template-columns: var(--sx-choice-size) minmax(0, 1fr);\n column-gap: var(--sx-choice-gap);\n align-items: start;\n min-block-size: 1.5rem;\n line-height: 1.5;\n cursor: pointer;\n }\n :where([data-sx-choice-row] > :is([data-sx-choice-box], [data-sx-choice-control])) {\n grid-area: 1 / 1;\n }\n :where([data-sx-choice-box], [data-sx-choice-control]) {\n inline-size: var(--sx-choice-size);\n block-size: var(--sx-choice-size);\n margin: calc((1.5em - var(--sx-choice-size)) / 2) 0 0;\n box-sizing: border-box;\n }\n :where([data-sx-choice-box]) {\n position: relative;\n display: grid;\n place-items: center;\n pointer-events: none;\n }\n :where([data-sx-choice-control]) {\n position: relative;\n z-index: 1;\n padding: 0;\n opacity: 0;\n cursor: inherit;\n accent-color: var(--color-sx-primary, auto);\n }\n :where([data-sx-choice-text]) {\n grid-area: 1 / 2;\n position: relative;\n min-inline-size: 0;\n }\n :where([data-sx-choice-description]) {\n grid-area: 2 / 2;\n margin: 0;\n }\n :where([data-sx-choice]:has([data-sx-choice-control]:focus-visible) [data-sx-choice-box]) {\n outline: 2px solid var(--color-sx-primary, currentColor);\n outline-offset: 2px;\n }\n :where([data-sx-choice-mark]) {\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n overflow: visible;\n fill: none;\n stroke: currentColor;\n stroke-width: 3;\n stroke-linecap: round;\n stroke-linejoin: round;\n }\n :where([data-sx-mark]) {\n stroke-dasharray: 1 2;\n stroke-dashoffset: 1.01;\n transform-box: fill-box;\n transform-origin: center;\n }\n :where([data-sx-choice]:has([data-sx-choice-control]:checked):not(:is(:has([data-sx-choice-control]:indeterminate), [data-sx-mixed])) [data-sx-mark=\"tick\"], [data-sx-choice]:is(:has([data-sx-choice-control]:indeterminate), [data-sx-mixed]) [data-sx-mark=\"dash\"]) {\n stroke-dashoffset: 0;\n }\n :where([data-sx-mark=\"dot\"]) {\n inline-size: 50%;\n block-size: 50%;\n border-radius: 50%;\n background: currentColor;\n scale: 0;\n }\n :where([data-sx-choice]:has([data-sx-choice-control]:checked) [data-sx-mark=\"dot\"]) {\n scale: 1;\n }\n :where(:is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer]) {\n position: absolute;\n inset: 0;\n border-radius: inherit;\n pointer-events: none;\n }\n :where([data-sx-choice-row] > [data-sx-choice-slot=\"halo\"]) {\n inset: auto;\n inset-block-start: calc((1.5em - var(--sx-choice-size)) / 2 - var(--sx-choice-size) / 2);\n inset-inline-start: calc(var(--sx-choice-size) / -2);\n z-index: -1;\n inline-size: calc(var(--sx-choice-size) * 2);\n block-size: calc(var(--sx-choice-size) * 2);\n border-radius: 50%;\n }\n :where([data-sx-choice-row] > [data-sx-choice-slot=\"row\"]) {\n z-index: -1;\n }\n :where(:is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer] > svg) {\n position: absolute;\n inset: 0;\n display: block;\n inline-size: 100%;\n block-size: 100%;\n overflow: visible;\n }\n :where([data-sx-choice-sr]) {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n :where([data-sx-choice-message]) {\n display: grid;\n grid-template-rows: 0fr;\n }\n :where([data-sx-choice] > [data-sx-choice-message]) {\n padding-inline-start: calc(var(--sx-choice-size) + var(--sx-choice-gap));\n }\n :where([data-sx-choice-message]:has(> [data-sx-choice-error]:not(:empty))) {\n grid-template-rows: 1fr;\n }\n :where([data-sx-choice-error]) {\n min-block-size: 0;\n margin: 0;\n overflow: hidden;\n }\n :where([data-sx-choice-says]) {\n display: block;\n padding-block-start: 0.375rem;\n }\n :where([data-sx-native] [data-sx-choice-box]) {\n display: none;\n }\n :where([data-sx-native] [data-sx-choice-control]) {\n opacity: 1;\n }\n :where([data-sx-group]) {\n min-inline-size: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n :where([data-sx-group-legend]) {\n padding: 0;\n margin-block-end: 0.5rem;\n }\n :where([data-sx-group-description]) {\n margin: -0.25rem 0 0.5rem;\n }\n :where([data-sx-group-options]) {\n position: relative;\n isolation: isolate;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n }\n :where([data-sx-orientation=\"horizontal\"] > [data-sx-group-options]) {\n flex-direction: row;\n flex-wrap: wrap;\n gap: 0.5rem 1.25rem;\n }\n :where([data-sx-group-options] > [data-sx-choice-layer]) {\n z-index: -1;\n }\n :where([data-sx-group-count]) {\n margin: 0.5rem 0 0;\n }\n :where([data-sx-group] > [data-sx-choice-message]) {\n padding-inline-start: 0;\n }\n @media (forced-colors: active) {\n :where([data-sx-choice-box], :is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer]) {\n display: none;\n }\n :where([data-sx-choice-control]) {\n opacity: 1;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n :where(:is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer]:not([data-sx-choice-keep])) {\n display: none;\n }\n }\n}";
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// The structural sheet of checkboxes and radios, and of the groups that hold them: the drawn box with the real input
|
|
2
|
+
// on top of it at opacity 0, the mark, the option's words and help, the layers' slots, the error row, the group's
|
|
3
|
+
// frame. Positioning only, no colours of its own (the look is styles/form.css). Pure string. See ./CLAUDE.md.
|
|
4
|
+
// Its layer rules key on a choice's own root: a Range and the pickers render the same layer spans, and a checkbox on the
|
|
5
|
+
// same page must not pin, round or hide theirs.
|
|
6
|
+
import { LAYER_ORDER } from "../backgrounds/runtime/rootCss.js";
|
|
7
|
+
const CONTROL = "[data-sx-choice-control]";
|
|
8
|
+
const ON = `:has(${CONTROL}:checked)`;
|
|
9
|
+
const MIXED = `:is(:has(${CONTROL}:indeterminate), [data-sx-mixed])`;
|
|
10
|
+
export const CHOICE_BASE_CSS = `${LAYER_ORDER}
|
|
11
|
+
@layer components {
|
|
12
|
+
:where([data-sx-choice], [data-sx-group]) {
|
|
13
|
+
--sx-form-dir: 1;
|
|
14
|
+
}
|
|
15
|
+
:where([data-sx-choice]:dir(rtl), [data-sx-group]:dir(rtl)) {
|
|
16
|
+
--sx-form-dir: -1;
|
|
17
|
+
}
|
|
18
|
+
:where([data-sx-choice]) {
|
|
19
|
+
--sx-choice-size: 1.25em;
|
|
20
|
+
--sx-choice-gap: 0.625rem;
|
|
21
|
+
position: relative;
|
|
22
|
+
min-inline-size: 0;
|
|
23
|
+
}
|
|
24
|
+
:where([data-sx-choice-row]) {
|
|
25
|
+
position: relative;
|
|
26
|
+
isolation: isolate;
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: var(--sx-choice-size) minmax(0, 1fr);
|
|
29
|
+
column-gap: var(--sx-choice-gap);
|
|
30
|
+
align-items: start;
|
|
31
|
+
min-block-size: 1.5rem;
|
|
32
|
+
line-height: 1.5;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
:where([data-sx-choice-row] > :is([data-sx-choice-box], ${CONTROL})) {
|
|
36
|
+
grid-area: 1 / 1;
|
|
37
|
+
}
|
|
38
|
+
:where([data-sx-choice-box], ${CONTROL}) {
|
|
39
|
+
inline-size: var(--sx-choice-size);
|
|
40
|
+
block-size: var(--sx-choice-size);
|
|
41
|
+
margin: calc((1.5em - var(--sx-choice-size)) / 2) 0 0;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
}
|
|
44
|
+
:where([data-sx-choice-box]) {
|
|
45
|
+
position: relative;
|
|
46
|
+
display: grid;
|
|
47
|
+
place-items: center;
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
}
|
|
50
|
+
:where(${CONTROL}) {
|
|
51
|
+
position: relative;
|
|
52
|
+
z-index: 1;
|
|
53
|
+
padding: 0;
|
|
54
|
+
opacity: 0;
|
|
55
|
+
cursor: inherit;
|
|
56
|
+
accent-color: var(--color-sx-primary, auto);
|
|
57
|
+
}
|
|
58
|
+
:where([data-sx-choice-text]) {
|
|
59
|
+
grid-area: 1 / 2;
|
|
60
|
+
position: relative;
|
|
61
|
+
min-inline-size: 0;
|
|
62
|
+
}
|
|
63
|
+
:where([data-sx-choice-description]) {
|
|
64
|
+
grid-area: 2 / 2;
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
67
|
+
:where([data-sx-choice]${`:has(${CONTROL}:focus-visible)`} [data-sx-choice-box]) {
|
|
68
|
+
outline: 2px solid var(--color-sx-primary, currentColor);
|
|
69
|
+
outline-offset: 2px;
|
|
70
|
+
}
|
|
71
|
+
:where([data-sx-choice-mark]) {
|
|
72
|
+
position: absolute;
|
|
73
|
+
inset: 0;
|
|
74
|
+
inline-size: 100%;
|
|
75
|
+
block-size: 100%;
|
|
76
|
+
overflow: visible;
|
|
77
|
+
fill: none;
|
|
78
|
+
stroke: currentColor;
|
|
79
|
+
stroke-width: 3;
|
|
80
|
+
stroke-linecap: round;
|
|
81
|
+
stroke-linejoin: round;
|
|
82
|
+
}
|
|
83
|
+
:where([data-sx-mark]) {
|
|
84
|
+
stroke-dasharray: 1 2;
|
|
85
|
+
stroke-dashoffset: 1.01;
|
|
86
|
+
transform-box: fill-box;
|
|
87
|
+
transform-origin: center;
|
|
88
|
+
}
|
|
89
|
+
:where([data-sx-choice]${ON}:not(${MIXED}) [data-sx-mark="tick"], [data-sx-choice]${MIXED} [data-sx-mark="dash"]) {
|
|
90
|
+
stroke-dashoffset: 0;
|
|
91
|
+
}
|
|
92
|
+
:where([data-sx-mark="dot"]) {
|
|
93
|
+
inline-size: 50%;
|
|
94
|
+
block-size: 50%;
|
|
95
|
+
border-radius: 50%;
|
|
96
|
+
background: currentColor;
|
|
97
|
+
scale: 0;
|
|
98
|
+
}
|
|
99
|
+
:where([data-sx-choice]${ON} [data-sx-mark="dot"]) {
|
|
100
|
+
scale: 1;
|
|
101
|
+
}
|
|
102
|
+
:where(:is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer]) {
|
|
103
|
+
position: absolute;
|
|
104
|
+
inset: 0;
|
|
105
|
+
border-radius: inherit;
|
|
106
|
+
pointer-events: none;
|
|
107
|
+
}
|
|
108
|
+
:where([data-sx-choice-row] > [data-sx-choice-slot="halo"]) {
|
|
109
|
+
inset: auto;
|
|
110
|
+
inset-block-start: calc((1.5em - var(--sx-choice-size)) / 2 - var(--sx-choice-size) / 2);
|
|
111
|
+
inset-inline-start: calc(var(--sx-choice-size) / -2);
|
|
112
|
+
z-index: -1;
|
|
113
|
+
inline-size: calc(var(--sx-choice-size) * 2);
|
|
114
|
+
block-size: calc(var(--sx-choice-size) * 2);
|
|
115
|
+
border-radius: 50%;
|
|
116
|
+
}
|
|
117
|
+
:where([data-sx-choice-row] > [data-sx-choice-slot="row"]) {
|
|
118
|
+
z-index: -1;
|
|
119
|
+
}
|
|
120
|
+
:where(:is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer] > svg) {
|
|
121
|
+
position: absolute;
|
|
122
|
+
inset: 0;
|
|
123
|
+
display: block;
|
|
124
|
+
inline-size: 100%;
|
|
125
|
+
block-size: 100%;
|
|
126
|
+
overflow: visible;
|
|
127
|
+
}
|
|
128
|
+
:where([data-sx-choice-sr]) {
|
|
129
|
+
position: absolute;
|
|
130
|
+
inline-size: 1px;
|
|
131
|
+
block-size: 1px;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
clip-path: inset(50%);
|
|
134
|
+
white-space: nowrap;
|
|
135
|
+
}
|
|
136
|
+
:where([data-sx-choice-message]) {
|
|
137
|
+
display: grid;
|
|
138
|
+
grid-template-rows: 0fr;
|
|
139
|
+
}
|
|
140
|
+
:where([data-sx-choice] > [data-sx-choice-message]) {
|
|
141
|
+
padding-inline-start: calc(var(--sx-choice-size) + var(--sx-choice-gap));
|
|
142
|
+
}
|
|
143
|
+
:where([data-sx-choice-message]:has(> [data-sx-choice-error]:not(:empty))) {
|
|
144
|
+
grid-template-rows: 1fr;
|
|
145
|
+
}
|
|
146
|
+
:where([data-sx-choice-error]) {
|
|
147
|
+
min-block-size: 0;
|
|
148
|
+
margin: 0;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
}
|
|
151
|
+
:where([data-sx-choice-says]) {
|
|
152
|
+
display: block;
|
|
153
|
+
padding-block-start: 0.375rem;
|
|
154
|
+
}
|
|
155
|
+
:where([data-sx-native] [data-sx-choice-box]) {
|
|
156
|
+
display: none;
|
|
157
|
+
}
|
|
158
|
+
:where([data-sx-native] ${CONTROL}) {
|
|
159
|
+
opacity: 1;
|
|
160
|
+
}
|
|
161
|
+
:where([data-sx-group]) {
|
|
162
|
+
min-inline-size: 0;
|
|
163
|
+
margin: 0;
|
|
164
|
+
padding: 0;
|
|
165
|
+
border: 0;
|
|
166
|
+
}
|
|
167
|
+
:where([data-sx-group-legend]) {
|
|
168
|
+
padding: 0;
|
|
169
|
+
margin-block-end: 0.5rem;
|
|
170
|
+
}
|
|
171
|
+
:where([data-sx-group-description]) {
|
|
172
|
+
margin: -0.25rem 0 0.5rem;
|
|
173
|
+
}
|
|
174
|
+
:where([data-sx-group-options]) {
|
|
175
|
+
position: relative;
|
|
176
|
+
isolation: isolate;
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
gap: 0.5rem;
|
|
180
|
+
}
|
|
181
|
+
:where([data-sx-orientation="horizontal"] > [data-sx-group-options]) {
|
|
182
|
+
flex-direction: row;
|
|
183
|
+
flex-wrap: wrap;
|
|
184
|
+
gap: 0.5rem 1.25rem;
|
|
185
|
+
}
|
|
186
|
+
:where([data-sx-group-options] > [data-sx-choice-layer]) {
|
|
187
|
+
z-index: -1;
|
|
188
|
+
}
|
|
189
|
+
:where([data-sx-group-count]) {
|
|
190
|
+
margin: 0.5rem 0 0;
|
|
191
|
+
}
|
|
192
|
+
:where([data-sx-group] > [data-sx-choice-message]) {
|
|
193
|
+
padding-inline-start: 0;
|
|
194
|
+
}
|
|
195
|
+
@media (forced-colors: active) {
|
|
196
|
+
:where([data-sx-choice-box], :is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer]) {
|
|
197
|
+
display: none;
|
|
198
|
+
}
|
|
199
|
+
:where(${CONTROL}) {
|
|
200
|
+
opacity: 1;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
@media (prefers-reduced-motion: reduce) {
|
|
204
|
+
:where(:is([data-sx-choice], [data-sx-group]) [data-sx-choice-layer]:not([data-sx-choice-keep])) {
|
|
205
|
+
display: none;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}`;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import type { FormEffect } from "../types.js";
|
|
3
|
+
/** One checkbox of a group. */
|
|
4
|
+
export interface CheckOption {
|
|
5
|
+
readonly value: string;
|
|
6
|
+
readonly label: ReactNode;
|
|
7
|
+
readonly description?: ReactNode;
|
|
8
|
+
readonly disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface CheckGroupOwnProps {
|
|
11
|
+
/** The group's question: a real `<legend>`. */
|
|
12
|
+
readonly label?: ReactNode;
|
|
13
|
+
/** Help under the question, read with the group. */
|
|
14
|
+
readonly description?: ReactNode;
|
|
15
|
+
/** The error message. While set, every checkbox is `aria-invalid` and the group points at the message. */
|
|
16
|
+
readonly error?: ReactNode;
|
|
17
|
+
readonly invalid?: boolean;
|
|
18
|
+
readonly options: readonly CheckOption[];
|
|
19
|
+
/** The values that are on, when you hold them (with `onValueChange`). */
|
|
20
|
+
readonly value?: readonly string[];
|
|
21
|
+
/** The values on at first, when the browser holds them. */
|
|
22
|
+
readonly defaultValue?: readonly string[];
|
|
23
|
+
/** Called with the values that are on after each change. */
|
|
24
|
+
readonly onValueChange?: (values: string[]) => void;
|
|
25
|
+
/** A "select all" box above the options: on when all are, mixed when some are. Not submitted. */
|
|
26
|
+
readonly all?: boolean;
|
|
27
|
+
/** "3 selected" under the options, read out as it changes. */
|
|
28
|
+
readonly count?: boolean;
|
|
29
|
+
/** Shift-click a second checkbox to set every one between the two the same way. */
|
|
30
|
+
readonly shiftRange?: boolean;
|
|
31
|
+
/** Default `"vertical"`. */
|
|
32
|
+
readonly orientation?: "vertical" | "horizontal";
|
|
33
|
+
/** One effect or a list, worn by every checkbox. */
|
|
34
|
+
readonly effect?: FormEffect | readonly FormEffect[];
|
|
35
|
+
readonly native?: boolean;
|
|
36
|
+
readonly unstyled?: boolean;
|
|
37
|
+
/** The words, for your language. `{n}` is the number on. */
|
|
38
|
+
readonly labels?: {
|
|
39
|
+
readonly all?: string;
|
|
40
|
+
readonly count?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Goes on the options' box. */
|
|
43
|
+
readonly className?: string;
|
|
44
|
+
/** Goes on the `<fieldset>`. */
|
|
45
|
+
readonly rootClassName?: string;
|
|
46
|
+
/** Goes on the `<legend>`. */
|
|
47
|
+
readonly labelClassName?: string;
|
|
48
|
+
readonly style?: CSSProperties;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Every other prop goes on each checkbox, `ref` included: `name`, `onChange`, `onBlur`, `required`, `disabled`, so
|
|
52
|
+
* `{...register("toppings")}` spreads onto all of them (React Hook Form collects them as a list).
|
|
53
|
+
*/
|
|
54
|
+
export type CheckGroupProps = CheckGroupOwnProps & Omit<ComponentPropsWithRef<"input">, keyof CheckGroupOwnProps | "type" | "checked" | "defaultChecked">;
|
|
55
|
+
/**
|
|
56
|
+
* A group of checkboxes in a real `<fieldset>`. With `all`, a "select all" box leads them: on when every one is, mixed
|
|
57
|
+
* when some are, and a click sets them all. With `count`, "3 selected" follows them. With `shiftRange`, a shift-click
|
|
58
|
+
* sets a whole run at once. Each checkbox stays a real one with its name, so a plain form submit carries the values.
|
|
59
|
+
*
|
|
60
|
+
* ```tsx
|
|
61
|
+
* <CheckGroup label="Toppings" options={toppings} all count effect={checkDraw()} {...register("toppings")} />
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function CheckGroup(props: CheckGroupProps): import("react").JSX.Element;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { CHOICE_BASE_CSS } from "../choice.js";
|
|
5
|
+
import { fieldDescribedBy, fieldIds } from "../ids.js";
|
|
6
|
+
import { Checkbox } from "./Checkbox.js";
|
|
7
|
+
import { EffectSheets } from "./choiceParts.js";
|
|
8
|
+
import { filled } from "./shared.js";
|
|
9
|
+
/** The options' checkboxes, the "select all" box left out (it carries `data-sx-all` on its input). */
|
|
10
|
+
const OPTION = "[data-sx-group-options] [data-sx-choice-control]:not([data-sx-all])";
|
|
11
|
+
/**
|
|
12
|
+
* A group of checkboxes in a real `<fieldset>`. With `all`, a "select all" box leads them: on when every one is, mixed
|
|
13
|
+
* when some are, and a click sets them all. With `count`, "3 selected" follows them. With `shiftRange`, a shift-click
|
|
14
|
+
* sets a whole run at once. Each checkbox stays a real one with its name, so a plain form submit carries the values.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <CheckGroup label="Toppings" options={toppings} all count effect={checkDraw()} {...register("toppings")} />
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function CheckGroup(props) {
|
|
21
|
+
const { label, description, error, invalid, options, value, defaultValue, onValueChange, all, count, shiftRange, orientation = "vertical", effect, native, unstyled, labels, className, rootClassName, labelClassName, style, id: ownId, ...rest } = props;
|
|
22
|
+
const auto = useId().replace(/[^\w-]/g, "");
|
|
23
|
+
const idBase = ownId ?? `sx-checks${auto}`;
|
|
24
|
+
const ids = fieldIds(idBase);
|
|
25
|
+
const hasError = filled(error);
|
|
26
|
+
const isInvalid = hasError || invalid === true;
|
|
27
|
+
const describedBy = fieldDescribedBy(ids, { error: hasError, description: filled(description), own: rest["aria-describedby"] });
|
|
28
|
+
const { "aria-describedby": _own, onChange: ownChange, ...shared } = rest;
|
|
29
|
+
const controlled = value !== undefined;
|
|
30
|
+
const root = useRef(null);
|
|
31
|
+
const inputs = () => [...(root.current?.querySelectorAll(OPTION) ?? [])];
|
|
32
|
+
// the values that are on: yours when you hold them, else read from the checkboxes themselves (React Hook Form's
|
|
33
|
+
// register leaves them to the browser), after every change, every render and a form reset
|
|
34
|
+
const [picked, setPicked] = useState(() => defaultValue ?? []);
|
|
35
|
+
const on = controlled ? value : picked;
|
|
36
|
+
const read = () => {
|
|
37
|
+
if (controlled)
|
|
38
|
+
return;
|
|
39
|
+
const next = inputs().filter((i) => i.checked).map((i) => i.value);
|
|
40
|
+
setPicked((now) => (now.length === next.length && now.every((v, i) => v === next[i]) ? now : next));
|
|
41
|
+
};
|
|
42
|
+
useEffect(read);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const form = root.current?.form;
|
|
45
|
+
if (!form)
|
|
46
|
+
return;
|
|
47
|
+
const later = () => setTimeout(read);
|
|
48
|
+
form.addEventListener("reset", later);
|
|
49
|
+
return () => form.removeEventListener("reset", later);
|
|
50
|
+
}, [controlled]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
51
|
+
const values = options.map((o) => o.value);
|
|
52
|
+
const total = values.length;
|
|
53
|
+
const n = on.filter((v) => values.includes(v)).length;
|
|
54
|
+
const words = { all: "Select all", count: "{n} selected", ...labels };
|
|
55
|
+
const changed = (e) => {
|
|
56
|
+
ownChange?.(e);
|
|
57
|
+
if (controlled) {
|
|
58
|
+
const v = e.target.value;
|
|
59
|
+
onValueChange?.(e.target.checked ? [...value.filter((x) => x !== v), v] : value.filter((x) => x !== v));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
read();
|
|
63
|
+
onValueChange?.(inputs().filter((i) => i.checked).map((i) => i.value));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
// Set a run of checkboxes the way the user would: a click on each, so its change event reaches React Hook Form.
|
|
67
|
+
// Values you hold are set in one go instead.
|
|
68
|
+
const setAll = (targets, to) => {
|
|
69
|
+
if (controlled) {
|
|
70
|
+
const touched = targets.map((t) => t.value);
|
|
71
|
+
const rest = value.filter((v) => !touched.includes(v));
|
|
72
|
+
onValueChange?.(to ? [...rest, ...touched] : rest);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
for (const input of targets)
|
|
76
|
+
if (input.checked !== to && !input.disabled)
|
|
77
|
+
input.click();
|
|
78
|
+
};
|
|
79
|
+
const last = useRef(null);
|
|
80
|
+
const ranging = useRef(false);
|
|
81
|
+
const onClick = (e) => {
|
|
82
|
+
const input = e.target.closest?.("input");
|
|
83
|
+
const list = inputs();
|
|
84
|
+
const at = input ? list.indexOf(input) : -1;
|
|
85
|
+
if (at === -1 || ranging.current)
|
|
86
|
+
return;
|
|
87
|
+
if (shiftRange && e.shiftKey && last.current !== null && last.current !== at) {
|
|
88
|
+
const [from, to] = [Math.min(last.current, at), Math.max(last.current, at)];
|
|
89
|
+
ranging.current = true;
|
|
90
|
+
setAll(list.slice(from, to + 1).filter((_, i) => from + i !== at), input.checked);
|
|
91
|
+
ranging.current = false;
|
|
92
|
+
}
|
|
93
|
+
last.current = at;
|
|
94
|
+
};
|
|
95
|
+
const optionIds = options.map((_, i) => `${idBase}-${i}`);
|
|
96
|
+
return (_jsxs(_Fragment, { children: [_jsx(EffectSheets, { name: "form-choice", base: CHOICE_BASE_CSS, effects: [] }), _jsxs("fieldset", { ref: root, id: idBase, "data-sx-checks": "", "data-sx-group": "check", "data-sx-styled": unstyled ? undefined : "", "data-sx-orientation": orientation, "aria-describedby": describedBy, className: rootClassName, style: style, children: [filled(label) ? (_jsx("legend", { "data-sx-group-legend": "", className: labelClassName, children: label })) : null, filled(description) ? (_jsx("p", { "data-sx-group-description": "", id: ids.description, children: description })) : null, _jsxs("div", { "data-sx-group-options": "", className: className, onClick: onClick,
|
|
97
|
+
// a shift-click would select the words between the two: keep the selection, the click still goes through
|
|
98
|
+
onMouseDown: shiftRange ? (e) => e.shiftKey && e.preventDefault() : undefined, children: [all ? (_jsx(Checkbox, { "data-sx-all": "", label: words.all, checked: total > 0 && n === total, indeterminate: n > 0 && n < total, onChange: (e) => setAll(inputs(), e.target.checked), "aria-controls": optionIds.join(" "), effect: effect, native: native, unstyled: unstyled })) : null, options.map((o, i) => (_jsx(Checkbox, { ...shared, id: optionIds[i], value: o.value, label: o.label, description: o.description, disabled: o.disabled || shared.disabled, ...(controlled ? { checked: value.includes(o.value) } : { defaultChecked: defaultValue?.includes(o.value) }), onChange: changed, "aria-invalid": isInvalid || undefined, effect: effect, native: native, unstyled: unstyled, style: { "--sx-choice-i": i } }, o.value)))] }), count ? (_jsx("p", { "data-sx-group-count": "", role: "status", children: words.count.replace("{n}", String(n)) })) : null, _jsx("div", { "data-sx-choice-message": "", children: _jsx("p", { "data-sx-choice-error": "", id: ids.error, role: "alert", children: hasError ? (_jsx("span", { "data-sx-choice-says": "", children: error }, typeof error === "string" ? error : undefined)) : null }) })] })] }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import type { FormEffect } from "../types.js";
|
|
3
|
+
interface CheckboxOwnProps {
|
|
4
|
+
/** The words beside the box. The whole row is the label, so a click on the words toggles it too. */
|
|
5
|
+
readonly label?: ReactNode;
|
|
6
|
+
/** Help under the words, read as the checkbox's description. */
|
|
7
|
+
readonly description?: ReactNode;
|
|
8
|
+
/** The error message. While set, the checkbox is `aria-invalid` and screen readers read the message. */
|
|
9
|
+
readonly error?: ReactNode;
|
|
10
|
+
/** Invalid with no message of its own. */
|
|
11
|
+
readonly invalid?: boolean;
|
|
12
|
+
/** Neither on nor off: some of the things it stands for are on (a "select all" box). The browser's own property. */
|
|
13
|
+
readonly indeterminate?: boolean;
|
|
14
|
+
/** One effect or a list; they stack. */
|
|
15
|
+
readonly effect?: FormEffect | readonly FormEffect[];
|
|
16
|
+
/** The browser's own checkbox, coloured with `accent-color`, instead of the drawn box. Effects don't apply. */
|
|
17
|
+
readonly native?: boolean;
|
|
18
|
+
/** Drop the default look. */
|
|
19
|
+
readonly unstyled?: boolean;
|
|
20
|
+
/** Goes on the drawn box. */
|
|
21
|
+
readonly className?: string;
|
|
22
|
+
/** Goes on the outer element. */
|
|
23
|
+
readonly rootClassName?: string;
|
|
24
|
+
/** Goes on the words. */
|
|
25
|
+
readonly labelClassName?: string;
|
|
26
|
+
/** Goes on the outer element, beside the effects' variables. */
|
|
27
|
+
readonly style?: CSSProperties;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Every other prop goes on the real checkbox, `ref` included: `name`, `value`, `checked` / `defaultChecked`,
|
|
31
|
+
* `onChange`, `required`, `disabled`, so `{...register("terms")}` spreads straight onto it.
|
|
32
|
+
*/
|
|
33
|
+
export type CheckboxProps = CheckboxOwnProps & Omit<ComponentPropsWithRef<"input">, keyof CheckboxOwnProps | "type">;
|
|
34
|
+
/**
|
|
35
|
+
* A checkbox that wears any number of effects. The real checkbox sits on top of the drawn box at opacity 0, the same
|
|
36
|
+
* size: it takes the click, the keyboard and the focus, and the effects read its state from CSS.
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <Checkbox label="I agree to the terms" effect={[checkDraw(), checkPop()]} {...register("terms")} />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function Checkbox(props: CheckboxProps): import("react").JSX.Element;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef } from "react";
|
|
4
|
+
import { CHOICE_BASE_CSS } from "../choice.js";
|
|
5
|
+
import { fieldDescribedBy, fieldIds } from "../ids.js";
|
|
6
|
+
import { checkChoice } from "./choiceChecks.js";
|
|
7
|
+
import { ChoiceItem, EffectSheets, usePrograms } from "./choiceParts.js";
|
|
8
|
+
import { effectList, filled, withUid } from "./shared.js";
|
|
9
|
+
/**
|
|
10
|
+
* A checkbox that wears any number of effects. The real checkbox sits on top of the drawn box at opacity 0, the same
|
|
11
|
+
* size: it takes the click, the keyboard and the focus, and the effects read its state from CSS.
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Checkbox label="I agree to the terms" effect={[checkDraw(), checkPop()]} {...register("terms")} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function Checkbox(props) {
|
|
18
|
+
const { label, description, error, invalid, indeterminate, effect, native, unstyled, className, rootClassName, labelClassName, style, id: ownId, ...rest } = props;
|
|
19
|
+
const effects = native ? [] : effectList(effect);
|
|
20
|
+
const auto = useId();
|
|
21
|
+
const id = ownId ?? `sx-check${auto.replace(/[^\w-]/g, "")}`;
|
|
22
|
+
const uid = `sx${auto.replace(/[^\w-]/g, "")}`;
|
|
23
|
+
const ids = fieldIds(id);
|
|
24
|
+
const hasError = filled(error);
|
|
25
|
+
const ownInvalid = rest["aria-invalid"];
|
|
26
|
+
const isInvalid = hasError || invalid === true || ownInvalid === true || ownInvalid === "true";
|
|
27
|
+
const describedBy = fieldDescribedBy(ids, { error: hasError, description: filled(description), own: rest["aria-describedby"] });
|
|
28
|
+
if (process.env.NODE_ENV !== "production") {
|
|
29
|
+
checkChoice({
|
|
30
|
+
control: "checkbox",
|
|
31
|
+
effects,
|
|
32
|
+
labelled: filled(label) || !!rest["aria-label"] || !!rest["aria-labelledby"],
|
|
33
|
+
nativeWithEffects: !!native && !!effect && effectList(effect).length > 0,
|
|
34
|
+
invalidWithoutWords: invalid === true && !hasError,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const root = useRef(null);
|
|
38
|
+
// `indeterminate` is a property, not an attribute: set it once the input exists. Until then (the server's HTML),
|
|
39
|
+
// `data-sx-mixed` shows the dash; it goes as soon as the property is set, so a click that clears the property isn't
|
|
40
|
+
// undone by a stale attribute.
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const el = root.current;
|
|
43
|
+
const input = el?.querySelector("[data-sx-choice-control]");
|
|
44
|
+
if (!el || !input)
|
|
45
|
+
return;
|
|
46
|
+
input.indeterminate = indeterminate === true;
|
|
47
|
+
el.removeAttribute("data-sx-mixed");
|
|
48
|
+
}, [indeterminate]);
|
|
49
|
+
usePrograms(root, effects);
|
|
50
|
+
const vars = { ...withUid(Object.assign({}, ...effects.map((e) => e.vars)), uid), ...style };
|
|
51
|
+
return (_jsxs(_Fragment, { children: [_jsx(EffectSheets, { name: "form-choice", base: CHOICE_BASE_CSS, effects: effects }), _jsx(ChoiceItem, { kind: "checkbox", effects: effects, uid: uid, label: label, description: description, descriptionId: ids.description, boxClassName: className, labelClassName: labelClassName, root: {
|
|
52
|
+
ref: root,
|
|
53
|
+
"data-sx-choice": effects.map((e) => e.id).join(" "),
|
|
54
|
+
"data-sx-kind": "checkbox",
|
|
55
|
+
"data-sx-styled": unstyled ? undefined : "",
|
|
56
|
+
"data-sx-native": native ? "" : undefined,
|
|
57
|
+
"data-sx-mixed": indeterminate ? "" : undefined,
|
|
58
|
+
className: rootClassName,
|
|
59
|
+
style: vars,
|
|
60
|
+
}, control: {
|
|
61
|
+
...rest,
|
|
62
|
+
id,
|
|
63
|
+
type: "checkbox",
|
|
64
|
+
"aria-invalid": isInvalid || undefined,
|
|
65
|
+
"aria-describedby": describedBy,
|
|
66
|
+
}, children: _jsx("div", { "data-sx-choice-message": "", children: _jsx("p", { "data-sx-choice-error": "", id: ids.error, role: "alert", children: hasError ? (_jsx("span", { "data-sx-choice-says": "", children: error }, typeof error === "string" ? error : undefined)) : null }) }) })] }));
|
|
67
|
+
}
|