react-aria-components 1.17.0 → 1.18.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/dist/exports/Autocomplete.cjs.map +1 -1
- package/dist/exports/Autocomplete.js.map +1 -1
- package/dist/exports/Autocomplete.mjs.map +1 -1
- package/dist/exports/Calendar.cjs +3 -0
- package/dist/exports/Calendar.cjs.map +1 -1
- package/dist/exports/Calendar.js +2 -2
- package/dist/exports/Calendar.js.map +1 -1
- package/dist/exports/Calendar.mjs +2 -2
- package/dist/exports/Calendar.mjs.map +1 -1
- package/dist/exports/Checkbox.cjs +8 -0
- package/dist/exports/Checkbox.cjs.map +1 -1
- package/dist/exports/Checkbox.js +6 -2
- package/dist/exports/Checkbox.js.map +1 -1
- package/dist/exports/Checkbox.mjs +6 -2
- package/dist/exports/Checkbox.mjs.map +1 -1
- package/dist/exports/CheckboxGroup.cjs.map +1 -1
- package/dist/exports/CheckboxGroup.js.map +1 -1
- package/dist/exports/CheckboxGroup.mjs.map +1 -1
- package/dist/exports/CollectionBuilder.cjs.map +1 -1
- package/dist/exports/CollectionBuilder.js.map +1 -1
- package/dist/exports/CollectionBuilder.mjs.map +1 -1
- package/dist/exports/ColorArea.cjs.map +1 -1
- package/dist/exports/ColorArea.js.map +1 -1
- package/dist/exports/ColorArea.mjs.map +1 -1
- package/dist/exports/ColorField.cjs.map +1 -1
- package/dist/exports/ColorField.js.map +1 -1
- package/dist/exports/ColorField.mjs.map +1 -1
- package/dist/exports/ColorPicker.cjs.map +1 -1
- package/dist/exports/ColorPicker.js.map +1 -1
- package/dist/exports/ColorPicker.mjs.map +1 -1
- package/dist/exports/ColorSlider.cjs.map +1 -1
- package/dist/exports/ColorSlider.js.map +1 -1
- package/dist/exports/ColorSlider.mjs.map +1 -1
- package/dist/exports/ColorSwatch.cjs.map +1 -1
- package/dist/exports/ColorSwatch.js.map +1 -1
- package/dist/exports/ColorSwatch.mjs.map +1 -1
- package/dist/exports/ColorSwatchPicker.cjs.map +1 -1
- package/dist/exports/ColorSwatchPicker.js.map +1 -1
- package/dist/exports/ColorSwatchPicker.mjs.map +1 -1
- package/dist/exports/ColorThumb.cjs.map +1 -1
- package/dist/exports/ColorThumb.js.map +1 -1
- package/dist/exports/ColorThumb.mjs.map +1 -1
- package/dist/exports/ColorWheel.cjs.map +1 -1
- package/dist/exports/ColorWheel.js.map +1 -1
- package/dist/exports/ColorWheel.mjs.map +1 -1
- package/dist/exports/ComboBox.cjs.map +1 -1
- package/dist/exports/ComboBox.js.map +1 -1
- package/dist/exports/ComboBox.mjs.map +1 -1
- package/dist/exports/DateField.cjs.map +1 -1
- package/dist/exports/DateField.js.map +1 -1
- package/dist/exports/DateField.mjs.map +1 -1
- package/dist/exports/DatePicker.cjs.map +1 -1
- package/dist/exports/DatePicker.js.map +1 -1
- package/dist/exports/DatePicker.mjs.map +1 -1
- package/dist/exports/DateRangePicker.cjs.map +1 -1
- package/dist/exports/DateRangePicker.js.map +1 -1
- package/dist/exports/DateRangePicker.mjs.map +1 -1
- package/dist/exports/Disclosure.cjs.map +1 -1
- package/dist/exports/Disclosure.js.map +1 -1
- package/dist/exports/Disclosure.mjs.map +1 -1
- package/dist/exports/DisclosureGroup.cjs.map +1 -1
- package/dist/exports/DisclosureGroup.js.map +1 -1
- package/dist/exports/DisclosureGroup.mjs.map +1 -1
- package/dist/exports/GridList.cjs.map +1 -1
- package/dist/exports/GridList.js.map +1 -1
- package/dist/exports/GridList.mjs.map +1 -1
- package/dist/exports/ListBox.cjs.map +1 -1
- package/dist/exports/ListBox.js.map +1 -1
- package/dist/exports/ListBox.mjs.map +1 -1
- package/dist/exports/Menu.cjs.map +1 -1
- package/dist/exports/Menu.js.map +1 -1
- package/dist/exports/Menu.mjs.map +1 -1
- package/dist/exports/RadioGroup.cjs +3 -0
- package/dist/exports/RadioGroup.cjs.map +1 -1
- package/dist/exports/RadioGroup.js +2 -2
- package/dist/exports/RadioGroup.js.map +1 -1
- package/dist/exports/RadioGroup.mjs +2 -2
- package/dist/exports/RadioGroup.mjs.map +1 -1
- package/dist/exports/RangeCalendar.cjs +3 -0
- package/dist/exports/RangeCalendar.cjs.map +1 -1
- package/dist/exports/RangeCalendar.js +2 -2
- package/dist/exports/RangeCalendar.js.map +1 -1
- package/dist/exports/RangeCalendar.mjs +2 -2
- package/dist/exports/RangeCalendar.mjs.map +1 -1
- package/dist/exports/Select.cjs.map +1 -1
- package/dist/exports/Select.js.map +1 -1
- package/dist/exports/Select.mjs.map +1 -1
- package/dist/exports/SharedElementTransition.cjs.map +1 -1
- package/dist/exports/SharedElementTransition.js.map +1 -1
- package/dist/exports/SharedElementTransition.mjs.map +1 -1
- package/dist/exports/Slider.cjs +2 -0
- package/dist/exports/Slider.cjs.map +1 -1
- package/dist/exports/Slider.js +2 -2
- package/dist/exports/Slider.js.map +1 -1
- package/dist/exports/Slider.mjs +2 -2
- package/dist/exports/Slider.mjs.map +1 -1
- package/dist/exports/Switch.cjs +8 -0
- package/dist/exports/Switch.cjs.map +1 -1
- package/dist/exports/Switch.js +6 -2
- package/dist/exports/Switch.js.map +1 -1
- package/dist/exports/Switch.mjs +6 -2
- package/dist/exports/Switch.mjs.map +1 -1
- package/dist/exports/Table.cjs +1 -0
- package/dist/exports/Table.cjs.map +1 -1
- package/dist/exports/Table.js +2 -2
- package/dist/exports/Table.js.map +1 -1
- package/dist/exports/Table.mjs +2 -2
- package/dist/exports/Table.mjs.map +1 -1
- package/dist/exports/Tabs.cjs.map +1 -1
- package/dist/exports/Tabs.js.map +1 -1
- package/dist/exports/Tabs.mjs.map +1 -1
- package/dist/exports/TagGroup.cjs.map +1 -1
- package/dist/exports/TagGroup.js.map +1 -1
- package/dist/exports/TagGroup.mjs.map +1 -1
- package/dist/exports/TimeField.cjs.map +1 -1
- package/dist/exports/TimeField.js.map +1 -1
- package/dist/exports/TimeField.mjs.map +1 -1
- package/dist/exports/Toast.cjs.map +1 -1
- package/dist/exports/Toast.js.map +1 -1
- package/dist/exports/Toast.mjs.map +1 -1
- package/dist/exports/ToggleButtonGroup.cjs.map +1 -1
- package/dist/exports/ToggleButtonGroup.js.map +1 -1
- package/dist/exports/ToggleButtonGroup.mjs.map +1 -1
- package/dist/exports/Tree.cjs.map +1 -1
- package/dist/exports/Tree.js.map +1 -1
- package/dist/exports/Tree.mjs.map +1 -1
- package/dist/exports/Virtualizer.cjs.map +1 -1
- package/dist/exports/Virtualizer.js.map +1 -1
- package/dist/exports/Virtualizer.mjs.map +1 -1
- package/dist/exports/index.cjs +19 -1
- package/dist/exports/index.cjs.map +1 -1
- package/dist/exports/index.js +11 -8
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/index.mjs +11 -8
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/useAsyncList.cjs.map +1 -1
- package/dist/exports/useAsyncList.js.map +1 -1
- package/dist/exports/useAsyncList.mjs.map +1 -1
- package/dist/exports/useDragAndDrop.cjs.map +1 -1
- package/dist/exports/useDragAndDrop.js.map +1 -1
- package/dist/exports/useDragAndDrop.mjs.map +1 -1
- package/dist/exports/useDrop.cjs.map +1 -1
- package/dist/exports/useDrop.js.map +1 -1
- package/dist/exports/useDrop.mjs.map +1 -1
- package/dist/private/Autocomplete.cjs.map +1 -1
- package/dist/private/Autocomplete.js.map +1 -1
- package/dist/private/Autocomplete.mjs.map +1 -1
- package/dist/private/Breadcrumbs.cjs.map +1 -1
- package/dist/private/Breadcrumbs.js.map +1 -1
- package/dist/private/Breadcrumbs.mjs.map +1 -1
- package/dist/private/Button.cjs.map +1 -1
- package/dist/private/Button.js.map +1 -1
- package/dist/private/Button.mjs.map +1 -1
- package/dist/private/Calendar.cjs +34 -2
- package/dist/private/Calendar.cjs.map +1 -1
- package/dist/private/Calendar.js +34 -5
- package/dist/private/Calendar.js.map +1 -1
- package/dist/private/Calendar.mjs +34 -5
- package/dist/private/Calendar.mjs.map +1 -1
- package/dist/private/Checkbox.cjs +104 -17
- package/dist/private/Checkbox.cjs.map +1 -1
- package/dist/private/Checkbox.js +102 -18
- package/dist/private/Checkbox.js.map +1 -1
- package/dist/private/Checkbox.mjs +102 -18
- package/dist/private/Checkbox.mjs.map +1 -1
- package/dist/private/Collection.cjs.map +1 -1
- package/dist/private/Collection.js.map +1 -1
- package/dist/private/Collection.mjs.map +1 -1
- package/dist/private/ColorArea.cjs.map +1 -1
- package/dist/private/ColorArea.js.map +1 -1
- package/dist/private/ColorArea.mjs.map +1 -1
- package/dist/private/ColorField.cjs.map +1 -1
- package/dist/private/ColorField.js.map +1 -1
- package/dist/private/ColorField.mjs.map +1 -1
- package/dist/private/ColorPicker.cjs.map +1 -1
- package/dist/private/ColorPicker.js.map +1 -1
- package/dist/private/ColorPicker.mjs.map +1 -1
- package/dist/private/ColorSlider.cjs.map +1 -1
- package/dist/private/ColorSlider.js.map +1 -1
- package/dist/private/ColorSlider.mjs.map +1 -1
- package/dist/private/ColorSwatch.cjs.map +1 -1
- package/dist/private/ColorSwatch.js.map +1 -1
- package/dist/private/ColorSwatch.mjs.map +1 -1
- package/dist/private/ColorSwatchPicker.cjs.map +1 -1
- package/dist/private/ColorSwatchPicker.js.map +1 -1
- package/dist/private/ColorSwatchPicker.mjs.map +1 -1
- package/dist/private/ColorThumb.cjs.map +1 -1
- package/dist/private/ColorThumb.js.map +1 -1
- package/dist/private/ColorThumb.mjs.map +1 -1
- package/dist/private/ColorWheel.cjs.map +1 -1
- package/dist/private/ColorWheel.js.map +1 -1
- package/dist/private/ColorWheel.mjs.map +1 -1
- package/dist/private/ComboBox.cjs +15 -3
- package/dist/private/ComboBox.cjs.map +1 -1
- package/dist/private/ComboBox.js +16 -4
- package/dist/private/ComboBox.js.map +1 -1
- package/dist/private/ComboBox.mjs +16 -4
- package/dist/private/ComboBox.mjs.map +1 -1
- package/dist/private/DateField.cjs.map +1 -1
- package/dist/private/DateField.js.map +1 -1
- package/dist/private/DateField.mjs.map +1 -1
- package/dist/private/DatePicker.cjs +0 -26
- package/dist/private/DatePicker.cjs.map +1 -1
- package/dist/private/DatePicker.js +1 -27
- package/dist/private/DatePicker.js.map +1 -1
- package/dist/private/DatePicker.mjs +1 -27
- package/dist/private/DatePicker.mjs.map +1 -1
- package/dist/private/Dialog.cjs +1 -17
- package/dist/private/Dialog.cjs.map +1 -1
- package/dist/private/Dialog.js +2 -18
- package/dist/private/Dialog.js.map +1 -1
- package/dist/private/Dialog.mjs +2 -18
- package/dist/private/Dialog.mjs.map +1 -1
- package/dist/private/Disclosure.cjs.map +1 -1
- package/dist/private/Disclosure.js.map +1 -1
- package/dist/private/Disclosure.mjs.map +1 -1
- package/dist/private/DragAndDrop.cjs +3 -3
- package/dist/private/DragAndDrop.cjs.map +1 -1
- package/dist/private/DragAndDrop.js +3 -3
- package/dist/private/DragAndDrop.js.map +1 -1
- package/dist/private/DragAndDrop.mjs +3 -3
- package/dist/private/DragAndDrop.mjs.map +1 -1
- package/dist/private/DropZone.cjs.map +1 -1
- package/dist/private/DropZone.js.map +1 -1
- package/dist/private/DropZone.mjs.map +1 -1
- package/dist/private/FieldError.cjs.map +1 -1
- package/dist/private/FieldError.js.map +1 -1
- package/dist/private/FieldError.mjs.map +1 -1
- package/dist/private/FileTrigger.cjs.map +1 -1
- package/dist/private/FileTrigger.js.map +1 -1
- package/dist/private/FileTrigger.mjs.map +1 -1
- package/dist/private/Form.cjs.map +1 -1
- package/dist/private/Form.js.map +1 -1
- package/dist/private/Form.mjs.map +1 -1
- package/dist/private/GridLayout.cjs +37 -0
- package/dist/private/GridLayout.cjs.map +1 -0
- package/dist/private/GridLayout.js +32 -0
- package/dist/private/GridLayout.js.map +1 -0
- package/dist/private/GridLayout.mjs +32 -0
- package/dist/private/GridLayout.mjs.map +1 -0
- package/dist/private/GridList.cjs +19 -2
- package/dist/private/GridList.cjs.map +1 -1
- package/dist/private/GridList.js +20 -3
- package/dist/private/GridList.js.map +1 -1
- package/dist/private/GridList.mjs +20 -3
- package/dist/private/GridList.mjs.map +1 -1
- package/dist/private/Group.cjs.map +1 -1
- package/dist/private/Group.js.map +1 -1
- package/dist/private/Group.mjs.map +1 -1
- package/dist/private/Header.cjs.map +1 -1
- package/dist/private/Header.js.map +1 -1
- package/dist/private/Header.mjs.map +1 -1
- package/dist/private/Heading.cjs.map +1 -1
- package/dist/private/Heading.js.map +1 -1
- package/dist/private/Heading.mjs.map +1 -1
- package/dist/private/HiddenDateInput.cjs +3 -3
- package/dist/private/HiddenDateInput.cjs.map +1 -1
- package/dist/private/HiddenDateInput.js +3 -3
- package/dist/private/HiddenDateInput.js.map +1 -1
- package/dist/private/HiddenDateInput.mjs +3 -3
- package/dist/private/HiddenDateInput.mjs.map +1 -1
- package/dist/private/Input.cjs.map +1 -1
- package/dist/private/Input.js.map +1 -1
- package/dist/private/Input.mjs.map +1 -1
- package/dist/private/Keyboard.cjs.map +1 -1
- package/dist/private/Keyboard.js.map +1 -1
- package/dist/private/Keyboard.mjs.map +1 -1
- package/dist/private/Label.cjs.map +1 -1
- package/dist/private/Label.js.map +1 -1
- package/dist/private/Label.mjs.map +1 -1
- package/dist/private/Link.cjs.map +1 -1
- package/dist/private/Link.js.map +1 -1
- package/dist/private/Link.mjs.map +1 -1
- package/dist/private/ListBox.cjs +6 -5
- package/dist/private/ListBox.cjs.map +1 -1
- package/dist/private/ListBox.js +6 -5
- package/dist/private/ListBox.js.map +1 -1
- package/dist/private/ListBox.mjs +6 -5
- package/dist/private/ListBox.mjs.map +1 -1
- package/dist/private/Menu.cjs +5 -15
- package/dist/private/Menu.cjs.map +1 -1
- package/dist/private/Menu.js +6 -16
- package/dist/private/Menu.js.map +1 -1
- package/dist/private/Menu.mjs +6 -16
- package/dist/private/Menu.mjs.map +1 -1
- package/dist/private/Meter.cjs.map +1 -1
- package/dist/private/Meter.js.map +1 -1
- package/dist/private/Meter.mjs.map +1 -1
- package/dist/private/Modal.cjs.map +1 -1
- package/dist/private/Modal.js.map +1 -1
- package/dist/private/Modal.mjs.map +1 -1
- package/dist/private/NumberField.cjs.map +1 -1
- package/dist/private/NumberField.js.map +1 -1
- package/dist/private/NumberField.mjs.map +1 -1
- package/dist/private/OverlayArrow.cjs.map +1 -1
- package/dist/private/OverlayArrow.js.map +1 -1
- package/dist/private/OverlayArrow.mjs.map +1 -1
- package/dist/private/Popover.cjs +17 -1
- package/dist/private/Popover.cjs.map +1 -1
- package/dist/private/Popover.js +19 -2
- package/dist/private/Popover.js.map +1 -1
- package/dist/private/Popover.mjs +18 -2
- package/dist/private/Popover.mjs.map +1 -1
- package/dist/private/ProgressBar.cjs.map +1 -1
- package/dist/private/ProgressBar.js.map +1 -1
- package/dist/private/ProgressBar.mjs.map +1 -1
- package/dist/private/RadioGroup.cjs +87 -7
- package/dist/private/RadioGroup.cjs.map +1 -1
- package/dist/private/RadioGroup.js +86 -9
- package/dist/private/RadioGroup.js.map +1 -1
- package/dist/private/RadioGroup.mjs +86 -9
- package/dist/private/RadioGroup.mjs.map +1 -1
- package/dist/private/SearchField.cjs.map +1 -1
- package/dist/private/SearchField.js.map +1 -1
- package/dist/private/SearchField.mjs.map +1 -1
- package/dist/private/Select.cjs +1 -17
- package/dist/private/Select.cjs.map +1 -1
- package/dist/private/Select.js +2 -18
- package/dist/private/Select.js.map +1 -1
- package/dist/private/Select.mjs +2 -18
- package/dist/private/Select.mjs.map +1 -1
- package/dist/private/SelectionIndicator.cjs.map +1 -1
- package/dist/private/SelectionIndicator.js.map +1 -1
- package/dist/private/SelectionIndicator.mjs.map +1 -1
- package/dist/private/Separator.cjs.map +1 -1
- package/dist/private/Separator.js.map +1 -1
- package/dist/private/Separator.mjs.map +1 -1
- package/dist/private/SharedElementTransition.cjs.map +1 -1
- package/dist/private/SharedElementTransition.js.map +1 -1
- package/dist/private/SharedElementTransition.mjs.map +1 -1
- package/dist/private/Slider.cjs +51 -1
- package/dist/private/Slider.cjs.map +1 -1
- package/dist/private/Slider.js +50 -2
- package/dist/private/Slider.js.map +1 -1
- package/dist/private/Slider.mjs +50 -2
- package/dist/private/Slider.mjs.map +1 -1
- package/dist/private/Switch.cjs +118 -4
- package/dist/private/Switch.cjs.map +1 -1
- package/dist/private/Switch.js +119 -7
- package/dist/private/Switch.js.map +1 -1
- package/dist/private/Switch.mjs +118 -7
- package/dist/private/Switch.mjs.map +1 -1
- package/dist/private/Table.cjs +115 -24
- package/dist/private/Table.cjs.map +1 -1
- package/dist/private/Table.js +116 -26
- package/dist/private/Table.js.map +1 -1
- package/dist/private/Table.mjs +116 -26
- package/dist/private/Table.mjs.map +1 -1
- package/dist/private/TableLayout.cjs.map +1 -1
- package/dist/private/TableLayout.js.map +1 -1
- package/dist/private/TableLayout.mjs.map +1 -1
- package/dist/private/Tabs.cjs +4 -3
- package/dist/private/Tabs.cjs.map +1 -1
- package/dist/private/Tabs.js +4 -3
- package/dist/private/Tabs.js.map +1 -1
- package/dist/private/Tabs.mjs +4 -3
- package/dist/private/Tabs.mjs.map +1 -1
- package/dist/private/TagGroup.cjs.map +1 -1
- package/dist/private/TagGroup.js.map +1 -1
- package/dist/private/TagGroup.mjs.map +1 -1
- package/dist/private/Text.cjs.map +1 -1
- package/dist/private/Text.js.map +1 -1
- package/dist/private/Text.mjs.map +1 -1
- package/dist/private/TextArea.cjs.map +1 -1
- package/dist/private/TextArea.js.map +1 -1
- package/dist/private/TextArea.mjs.map +1 -1
- package/dist/private/TextField.cjs.map +1 -1
- package/dist/private/TextField.js.map +1 -1
- package/dist/private/TextField.mjs.map +1 -1
- package/dist/private/Toast.cjs +2 -1
- package/dist/private/Toast.cjs.map +1 -1
- package/dist/private/Toast.js +2 -1
- package/dist/private/Toast.js.map +1 -1
- package/dist/private/Toast.mjs +2 -1
- package/dist/private/Toast.mjs.map +1 -1
- package/dist/private/ToggleButton.cjs.map +1 -1
- package/dist/private/ToggleButton.js.map +1 -1
- package/dist/private/ToggleButton.mjs.map +1 -1
- package/dist/private/ToggleButtonGroup.cjs.map +1 -1
- package/dist/private/ToggleButtonGroup.js.map +1 -1
- package/dist/private/ToggleButtonGroup.mjs.map +1 -1
- package/dist/private/Toolbar.cjs.map +1 -1
- package/dist/private/Toolbar.js.map +1 -1
- package/dist/private/Toolbar.mjs.map +1 -1
- package/dist/private/Tooltip.cjs.map +1 -1
- package/dist/private/Tooltip.js.map +1 -1
- package/dist/private/Tooltip.mjs.map +1 -1
- package/dist/private/Tree.cjs +18 -6
- package/dist/private/Tree.cjs.map +1 -1
- package/dist/private/Tree.js +19 -7
- package/dist/private/Tree.js.map +1 -1
- package/dist/private/Tree.mjs +19 -7
- package/dist/private/Tree.mjs.map +1 -1
- package/dist/private/TreeDropTargetDelegate.cjs +9 -4
- package/dist/private/TreeDropTargetDelegate.cjs.map +1 -1
- package/dist/private/TreeDropTargetDelegate.js +10 -4
- package/dist/private/TreeDropTargetDelegate.js.map +1 -1
- package/dist/private/TreeDropTargetDelegate.mjs +9 -4
- package/dist/private/TreeDropTargetDelegate.mjs.map +1 -1
- package/dist/private/Virtualizer.cjs.map +1 -1
- package/dist/private/Virtualizer.js.map +1 -1
- package/dist/private/Virtualizer.mjs.map +1 -1
- package/dist/private/useDragAndDrop.cjs.map +1 -1
- package/dist/private/useDragAndDrop.js.map +1 -1
- package/dist/private/useDragAndDrop.mjs.map +1 -1
- package/dist/private/utils.cjs.map +1 -1
- package/dist/private/utils.js.map +1 -1
- package/dist/private/utils.mjs.map +1 -1
- package/dist/types/exports/Calendar.d.ts +4 -3
- package/dist/types/exports/Checkbox.d.ts +7 -2
- package/dist/types/exports/RadioGroup.d.ts +2 -2
- package/dist/types/exports/RangeCalendar.d.ts +3 -2
- package/dist/types/exports/Slider.d.ts +2 -2
- package/dist/types/exports/Switch.d.ts +7 -2
- package/dist/types/exports/Table.d.ts +2 -2
- package/dist/types/exports/index.d.ts +15 -13
- package/dist/types/exports/useDragAndDrop.d.ts +1 -1
- package/dist/types/src/Autocomplete.d.ts +1 -1
- package/dist/types/src/Breadcrumbs.d.ts +13 -4
- package/dist/types/src/Button.d.ts +9 -1
- package/dist/types/src/Calendar.d.ts +93 -33
- package/dist/types/src/Checkbox.d.ts +93 -2
- package/dist/types/src/Collection.d.ts +17 -4
- package/dist/types/src/ColorArea.d.ts +6 -2
- package/dist/types/src/ColorField.d.ts +8 -1
- package/dist/types/src/ColorPicker.d.ts +4 -1
- package/dist/types/src/ColorSlider.d.ts +5 -1
- package/dist/types/src/ColorSwatch.d.ts +3 -1
- package/dist/types/src/ColorSwatchPicker.d.ts +7 -2
- package/dist/types/src/ColorThumb.d.ts +10 -2
- package/dist/types/src/ColorWheel.d.ts +7 -2
- package/dist/types/src/ComboBox.d.ts +24 -11
- package/dist/types/src/DateField.d.ts +29 -4
- package/dist/types/src/DatePicker.d.ts +15 -3
- package/dist/types/src/Dialog.d.ts +3 -1
- package/dist/types/src/Disclosure.d.ts +21 -5
- package/dist/types/src/DragAndDrop.d.ts +6 -2
- package/dist/types/src/DropZone.d.ts +8 -1
- package/dist/types/src/FieldError.d.ts +4 -1
- package/dist/types/src/FileTrigger.d.ts +2 -1
- package/dist/types/src/Form.d.ts +4 -1
- package/dist/types/src/GridLayout.d.ts +5 -0
- package/dist/types/src/GridList.d.ts +44 -13
- package/dist/types/src/Group.d.ts +9 -1
- package/dist/types/src/Heading.d.ts +12 -0
- package/dist/types/src/HiddenDateInput.d.ts +2 -1
- package/dist/types/src/Input.d.ts +8 -1
- package/dist/types/src/Link.d.ts +9 -1
- package/dist/types/src/ListBox.d.ts +35 -12
- package/dist/types/src/Menu.d.ts +22 -10
- package/dist/types/src/Meter.d.ts +4 -1
- package/dist/types/src/Modal.d.ts +9 -3
- package/dist/types/src/NumberField.d.ts +9 -2
- package/dist/types/src/OverlayArrow.d.ts +4 -1
- package/dist/types/src/Popover.d.ts +12 -3
- package/dist/types/src/ProgressBar.d.ts +5 -1
- package/dist/types/src/RadioGroup.d.ts +88 -2
- package/dist/types/src/SearchField.d.ts +8 -1
- package/dist/types/src/Select.d.ts +19 -6
- package/dist/types/src/SelectionIndicator.d.ts +7 -2
- package/dist/types/src/Separator.d.ts +5 -2
- package/dist/types/src/SharedElementTransition.d.ts +2 -0
- package/dist/types/src/Slider.d.ts +48 -4
- package/dist/types/src/Switch.d.ts +100 -3
- package/dist/types/src/Table.d.ts +138 -31
- package/dist/types/src/Tabs.d.ts +37 -12
- package/dist/types/src/TagGroup.d.ts +18 -7
- package/dist/types/src/TextArea.d.ts +3 -1
- package/dist/types/src/TextField.d.ts +7 -1
- package/dist/types/src/Toast.d.ts +13 -3
- package/dist/types/src/ToggleButton.d.ts +10 -3
- package/dist/types/src/ToggleButtonGroup.d.ts +7 -2
- package/dist/types/src/Toolbar.d.ts +6 -3
- package/dist/types/src/Tooltip.d.ts +13 -4
- package/dist/types/src/Tree.d.ts +52 -16
- package/dist/types/src/useDragAndDrop.d.ts +10 -4
- package/dist/types/src/utils.d.ts +109 -17
- package/package.json +9 -7
package/dist/private/Slider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {dom as $b7b7a92703138c9b$export$df3a06d6289f983e, Provider as $b7b7a92703138c9b$export$2881499e37b75b9a, useContextProps as $b7b7a92703138c9b$export$29f1550f4b0d4415, useRenderProps as $b7b7a92703138c9b$export$4d86445c2cf5e3, useSlot as $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8, useSlottedContext as $b7b7a92703138c9b$export$fabf2dc03a41866e} from "./utils.js";
|
|
2
2
|
import {LabelContext as $3e4839e5b30e7b17$export$75b6ee27786ba447} from "./Label.js";
|
|
3
3
|
import {useSlider as $1WDuc$useSlider, useSliderThumb as $1WDuc$useSliderThumb} from "react-aria/useSlider";
|
|
4
|
+
import {clamp as $1WDuc$clamp} from "react-stately/private/utils/number";
|
|
4
5
|
import {filterDOMProps as $1WDuc$filterDOMProps} from "react-aria/filterDOMProps";
|
|
5
6
|
import {mergeProps as $1WDuc$mergeProps} from "react-aria/mergeProps";
|
|
6
7
|
import $1WDuc$react, {createContext as $1WDuc$createContext, forwardRef as $1WDuc$forwardRef, useRef as $1WDuc$useRef, useContext as $1WDuc$useContext} from "react";
|
|
@@ -31,9 +32,11 @@ import {VisuallyHidden as $1WDuc$VisuallyHidden} from "react-aria/VisuallyHidden
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
const $5f6ec8ec99e46675$export$e99164f0030f3bff = /*#__PURE__*/ (0, $1WDuc$createContext)(null);
|
|
35
37
|
const $5f6ec8ec99e46675$export$1e7083018727fa60 = /*#__PURE__*/ (0, $1WDuc$createContext)(null);
|
|
36
38
|
const $5f6ec8ec99e46675$export$f1fce0420cc6d8ee = /*#__PURE__*/ (0, $1WDuc$createContext)(null);
|
|
39
|
+
const $5f6ec8ec99e46675$export$7ed6e0ce9ec48be7 = /*#__PURE__*/ (0, $1WDuc$createContext)(null);
|
|
37
40
|
const $5f6ec8ec99e46675$export$6189c2744041d8f8 = /*#__PURE__*/ (0, $1WDuc$createContext)(null);
|
|
38
41
|
const $5f6ec8ec99e46675$export$472062a354075cee = /*#__PURE__*/ (0, $1WDuc$forwardRef)(function Slider(props, ref) {
|
|
39
42
|
[props, ref] = (0, $b7b7a92703138c9b$export$29f1550f4b0d4415)(props, ref, $5f6ec8ec99e46675$export$e99164f0030f3bff);
|
|
@@ -103,7 +106,7 @@ const $5f6ec8ec99e46675$export$a590f758a961cb5b = /*#__PURE__*/ (0, $1WDuc$forwa
|
|
|
103
106
|
style: style,
|
|
104
107
|
children: children,
|
|
105
108
|
render: render,
|
|
106
|
-
defaultChildren: state.
|
|
109
|
+
defaultChildren: state.getFormattedValue(),
|
|
107
110
|
defaultClassName: 'react-aria-SliderOutput',
|
|
108
111
|
values: {
|
|
109
112
|
orientation: state.orientation,
|
|
@@ -208,7 +211,52 @@ const $5f6ec8ec99e46675$export$2c1b491743890dec = /*#__PURE__*/ (0, $1WDuc$forwa
|
|
|
208
211
|
]
|
|
209
212
|
}, renderProps.children));
|
|
210
213
|
});
|
|
214
|
+
const $5f6ec8ec99e46675$export$2ede0a3f7b0c0db = /*#__PURE__*/ (0, $1WDuc$forwardRef)(function SliderFill(props, ref) {
|
|
215
|
+
[props, ref] = (0, $b7b7a92703138c9b$export$29f1550f4b0d4415)(props, ref, $5f6ec8ec99e46675$export$7ed6e0ce9ec48be7);
|
|
216
|
+
let state = (0, $1WDuc$useContext)($5f6ec8ec99e46675$export$1e7083018727fa60);
|
|
217
|
+
let { onHoverStart: onHoverStart, onHoverEnd: onHoverEnd, onHoverChange: onHoverChange, ...otherProps } = props;
|
|
218
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $1WDuc$useHover)({
|
|
219
|
+
onHoverStart: onHoverStart,
|
|
220
|
+
onHoverEnd: onHoverEnd,
|
|
221
|
+
onHoverChange: onHoverChange
|
|
222
|
+
});
|
|
223
|
+
let offset = props.offset != null ? (0, $1WDuc$clamp)(props.offset, state.getThumbMinValue(0), state.getThumbMaxValue(0)) : state.getThumbMinValue(0);
|
|
224
|
+
let start = state.values.length > 1 ? state.getThumbPercent(0) * 100 : state.getValuePercent(offset) * 100;
|
|
225
|
+
let end = state.values.length > 0 ? state.getThumbPercent(state.values.length - 1) * 100 : 0;
|
|
226
|
+
let startPercent = Math.min(start, end);
|
|
227
|
+
let endPercent = Math.max(start, end);
|
|
228
|
+
let sizePercent = Math.max(0, endPercent - startPercent);
|
|
229
|
+
let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
|
|
230
|
+
...props,
|
|
231
|
+
defaultClassName: 'react-aria-SliderFill',
|
|
232
|
+
defaultStyle: state.orientation === 'vertical' ? {
|
|
233
|
+
position: 'absolute',
|
|
234
|
+
bottom: `${startPercent}%`,
|
|
235
|
+
height: `${sizePercent}%`,
|
|
236
|
+
width: '100%'
|
|
237
|
+
} : {
|
|
238
|
+
position: 'absolute',
|
|
239
|
+
insetInlineStart: `${startPercent}%`,
|
|
240
|
+
width: `${sizePercent}%`,
|
|
241
|
+
height: '100%'
|
|
242
|
+
},
|
|
243
|
+
values: {
|
|
244
|
+
orientation: state.orientation,
|
|
245
|
+
isDisabled: state.isDisabled,
|
|
246
|
+
isHovered: isHovered,
|
|
247
|
+
state: state
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
return /*#__PURE__*/ (0, $1WDuc$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).div, {
|
|
251
|
+
...(0, $1WDuc$mergeProps)(otherProps, hoverProps),
|
|
252
|
+
...renderProps,
|
|
253
|
+
ref: ref,
|
|
254
|
+
"data-hovered": isHovered || undefined,
|
|
255
|
+
"data-orientation": state.orientation || undefined,
|
|
256
|
+
"data-disabled": state.isDisabled || undefined
|
|
257
|
+
});
|
|
258
|
+
});
|
|
211
259
|
|
|
212
260
|
|
|
213
|
-
export {$5f6ec8ec99e46675$export$e99164f0030f3bff as SliderContext, $5f6ec8ec99e46675$export$1e7083018727fa60 as SliderStateContext, $5f6ec8ec99e46675$export$f1fce0420cc6d8ee as SliderTrackContext, $5f6ec8ec99e46675$export$6189c2744041d8f8 as SliderOutputContext, $5f6ec8ec99e46675$export$472062a354075cee as Slider, $5f6ec8ec99e46675$export$a590f758a961cb5b as SliderOutput, $5f6ec8ec99e46675$export$105594979f116971 as SliderTrack, $5f6ec8ec99e46675$export$2c1b491743890dec as SliderThumb};
|
|
261
|
+
export {$5f6ec8ec99e46675$export$e99164f0030f3bff as SliderContext, $5f6ec8ec99e46675$export$1e7083018727fa60 as SliderStateContext, $5f6ec8ec99e46675$export$f1fce0420cc6d8ee as SliderTrackContext, $5f6ec8ec99e46675$export$7ed6e0ce9ec48be7 as SliderFillContext, $5f6ec8ec99e46675$export$6189c2744041d8f8 as SliderOutputContext, $5f6ec8ec99e46675$export$472062a354075cee as Slider, $5f6ec8ec99e46675$export$a590f758a961cb5b as SliderOutput, $5f6ec8ec99e46675$export$105594979f116971 as SliderTrack, $5f6ec8ec99e46675$export$2c1b491743890dec as SliderThumb, $5f6ec8ec99e46675$export$2ede0a3f7b0c0db as SliderFill};
|
|
214
262
|
//# sourceMappingURL=Slider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
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AC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW;IAC9C,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;mBACN;uBACA;wBACA;uBACA;4BACA;wBACA;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAElB,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,WAAW;QAC/C,GAAG,WAAW;QACf,KAAK;QACL,OAAO;YAAC,GAAG,WAAW,KAAK;YAAE,GAAG,YAAY,KAAK;QAAA;QACjD,gBAAc,aAAa;QAC3B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa,uBACZ,gCAAC;QAAM,KAAK;QAAW,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;uBAE9D,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;SAC/C;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/Slider.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSliderProps, AriaSliderThumbProps, useSlider, useSliderThumb} from 'react-aria/useSlider';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents, Orientation} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, OutputHTMLAttributes, useContext, useRef} from 'react';\nimport {SliderState, useSliderState} from 'react-stately/useSliderState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useNumberFormatter} from 'react-aria/useNumberFormatter';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SliderProps<T = number | number[]> extends Omit<AriaSliderProps<T>, 'label'>, RenderProps<SliderRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-Slider'\n */\n className?: ClassNameOrFunction<SliderRenderProps>,\n /**\n * The display format of the value label.\n */\n formatOptions?: Intl.NumberFormatOptions\n}\n\nexport const SliderContext = createContext<ContextValue<SliderProps, HTMLDivElement>>(null);\nexport const SliderStateContext = createContext<SliderState | null>(null);\nexport const SliderTrackContext = createContext<ContextValue<SliderTrackContextValue, HTMLDivElement>>(null);\nexport const SliderOutputContext = createContext<ContextValue<SliderOutputContextValue, HTMLOutputElement>>(null);\n\nexport interface SliderRenderProps {\n /**\n * The orientation of the slider.\n * @selector [data-orientation=\"horizontal | vertical\"]\n */\n orientation: Orientation,\n /**\n * Whether the slider is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the slider.\n */\n state: SliderState\n}\n\n/**\n * A slider allows a user to select one or more values within a range.\n */\nexport const Slider = /*#__PURE__*/ (forwardRef as forwardRefType)(function Slider<T extends number | number[]>(props: SliderProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SliderContext);\n let trackRef = useRef<HTMLDivElement>(null);\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let state = useSliderState({...props, numberFormatter});\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {\n groupProps,\n trackProps,\n labelProps,\n outputProps\n } = useSlider({...props, label}, state, trackRef);\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n },\n defaultClassName: 'react-aria-Slider'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <Provider\n values={[\n [SliderStateContext, state],\n [SliderTrackContext, {...trackProps, ref: trackRef}],\n [SliderOutputContext, outputProps],\n [LabelContext, {...labelProps, ref: labelRef}]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-orientation={state.orientation}\n data-disabled={state.isDisabled || undefined} />\n </Provider>\n );\n});\n\nexport interface SliderOutputProps extends RenderProps<SliderRenderProps, 'output'>, GlobalDOMAttributes<HTMLOutputElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SliderOutput'\n */\n className?: ClassNameOrFunction<SliderRenderProps>\n}\ninterface SliderOutputContextValue extends Omit<OutputHTMLAttributes<HTMLOutputElement>, 'children' | 'className' | 'style'>, SliderOutputProps {}\n\n/**\n * A slider output displays the current value of a slider as text.\n */\nexport const SliderOutput = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderOutput(props: SliderOutputProps, ref: ForwardedRef<HTMLOutputElement>) {\n [props, ref] = useContextProps(props, ref, SliderOutputContext);\n let {children, style, className, render, ...otherProps} = props;\n let state = useContext(SliderStateContext)!;\n let renderProps = useRenderProps({\n className,\n style,\n children,\n render,\n defaultChildren: state.getThumbValueLabel(0),\n defaultClassName: 'react-aria-SliderOutput',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n }\n });\n\n return (\n <dom.output\n {...otherProps}\n {...renderProps}\n ref={ref}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined} />\n );\n});\n\nexport interface SliderTrackRenderProps extends SliderRenderProps {\n /**\n * Whether the slider track is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean\n}\n\nexport interface SliderTrackProps extends HoverEvents, RenderProps<SliderTrackRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SliderTrack'\n */\n className?: ClassNameOrFunction<SliderTrackRenderProps>\n}\ninterface SliderTrackContextValue extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'style'>, SliderTrackProps {}\n\n/**\n * A slider track is a container for one or more slider thumbs.\n */\nexport const SliderTrack = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderTrack(props: SliderTrackProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SliderTrackContext);\n let state = useContext(SliderStateContext)!;\n let {onHoverStart, onHoverEnd, onHoverChange, ...otherProps} = props;\n let {hoverProps, isHovered} = useHover({onHoverStart, onHoverEnd, onHoverChange});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderTrack',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n isHovered,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(otherProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-hovered={isHovered || undefined}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined} />\n );\n});\n\nexport interface SliderThumbRenderProps {\n /**\n * State of the slider.\n */\n state: SliderState,\n /**\n * Whether this thumb is currently being dragged.\n * @selector [data-dragging]\n */\n isDragging: boolean,\n /**\n * Whether the thumb is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean,\n /**\n * Whether the thumb is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the thumb is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the thumb is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean\n}\n\nexport interface SliderThumbProps extends Omit<AriaSliderThumbProps, 'label' | 'validationState'>, HoverEvents, RenderProps<SliderThumbRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SliderThumb'\n */\n className?: ClassNameOrFunction<SliderThumbRenderProps>,\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>\n}\n\n/**\n * A slider thumb represents an individual value that the user can adjust within a slider track.\n */\nexport const SliderThumb = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderThumb(props: SliderThumbProps, ref: ForwardedRef<HTMLDivElement>) {\n let {\n inputRef: userInputRef = null\n } = props;\n let state = useContext(SliderStateContext)!;\n let {ref: trackRef} = useSlottedContext(SliderTrackContext)!;\n let {index = 0} = props;\n let defaultInputRef = useRef<HTMLInputElement>(null);\n let inputRef = userInputRef || defaultInputRef;\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {thumbProps, inputProps, labelProps, isDragging, isFocused, isDisabled} = useSliderThumb({\n ...props,\n index,\n trackRef: trackRef as RefObject<HTMLDivElement | null>,\n inputRef,\n label\n }, state);\n\n let {focusProps, isFocusVisible} = useFocusRing();\n let {hoverProps, isHovered} = useHover(props);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderThumb',\n values: {\n state,\n isHovered,\n isDragging,\n isFocused,\n isFocusVisible,\n isDisabled\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, thumbProps, hoverProps)}\n {...renderProps}\n ref={ref}\n style={{...thumbProps.style, ...renderProps.style}}\n data-hovered={isHovered || undefined}\n data-dragging={isDragging || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}>\n <VisuallyHidden>\n <input ref={inputRef} {...mergeProps(inputProps, focusProps)} />\n </VisuallyHidden>\n <Provider\n values={[\n [LabelContext, {...labelProps, ref: labelRef}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"Slider.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA6DM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAA6C;AAC/E,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAAsB;AAC7D,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAyD;AAChE,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAiD;AACvF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAA6D;AAwBpE,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,OAE1E,KAAqB,EAAE,GAAiC;IACxD,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,WAAW,CAAA,GAAA,aAAK,EAAkB;IACtC,IAAI,kBAAkB,CAAA,GAAA,yBAAiB,EAAE,MAAM,aAAa;IAC5D,IAAI,QAAQ,CAAA,GAAA,qBAAa,EAAE;QAAC,GAAG,KAAK;yBAAE;IAAe;IACrD,IAAI,CA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AI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,cACE,MAAM,WAAW,KAAK,aAClB;YACE,UAAU;YACV,QAAQ,GAAG,aAAa,CAAC,CAAC;YAC1B,QAAQ,GAAG,YAAY,CAAC,CAAC;YACzB,OAAO;QACT,IACA;YACE,UAAU;YACV,kBAAkB,GAAG,aAAa,CAAC,CAAC;YACpC,OAAO,GAAG,YAAY,CAAC,CAAC;YACxB,QAAQ;QACV;QACN,QAAQ;YACN,aAAa,MAAM,WAAW;YAC9B,YAAY,MAAM,UAAU;uBAC5B;mBACA;QACF;IACF;IAEA,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QACrC,GAAG,WAAW;QACf,KAAK;QACL,gBAAc,aAAa;QAC3B,oBAAkB,MAAM,WAAW,IAAI;QACvC,iBAAe,MAAM,UAAU,IAAI;;AAGzC","sources":["packages/react-aria-components/src/Slider.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AriaSliderProps,\n AriaSliderThumbProps,\n useSlider,\n useSliderThumb\n} from 'react-aria/useSlider';\n\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents, Orientation} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n HTMLAttributes,\n OutputHTMLAttributes,\n useContext,\n useRef\n} from 'react';\nimport {SliderState, useSliderState} from 'react-stately/useSliderState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useNumberFormatter} from 'react-aria/useNumberFormatter';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SliderProps<T = number | number[]>\n extends\n Omit<AriaSliderProps<T>, 'label'>,\n RenderProps<SliderRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Slider'\n */\n className?: ClassNameOrFunction<SliderRenderProps>;\n /**\n * The display format of the value label.\n */\n formatOptions?: Intl.NumberFormatOptions;\n}\n\nexport const SliderContext = createContext<ContextValue<SliderProps, HTMLDivElement>>(null);\nexport const SliderStateContext = createContext<SliderState | null>(null);\nexport const SliderTrackContext =\n createContext<ContextValue<SliderTrackContextValue, HTMLDivElement>>(null);\nexport const SliderFillContext = createContext<ContextValue<SliderFillProps, HTMLDivElement>>(null);\nexport const SliderOutputContext =\n createContext<ContextValue<SliderOutputContextValue, HTMLOutputElement>>(null);\n\nexport interface SliderRenderProps {\n /**\n * The orientation of the slider.\n *\n * @selector [data-orientation=\"horizontal | vertical\"]\n */\n orientation: Orientation;\n /**\n * Whether the slider is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * State of the slider.\n */\n state: SliderState;\n}\n\n/**\n * A slider allows a user to select one or more values within a range.\n */\nexport const Slider = /*#__PURE__*/ (forwardRef as forwardRefType)(function Slider<\n T extends number | number[]\n>(props: SliderProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SliderContext);\n let trackRef = useRef<HTMLDivElement>(null);\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let state = useSliderState({...props, numberFormatter});\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {groupProps, trackProps, labelProps, outputProps} = useSlider(\n {...props, label},\n state,\n trackRef\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n },\n defaultClassName: 'react-aria-Slider'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <Provider\n values={[\n [SliderStateContext, state],\n [SliderTrackContext, {...trackProps, ref: trackRef}],\n [SliderOutputContext, outputProps],\n [LabelContext, {...labelProps, ref: labelRef}]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-orientation={state.orientation}\n data-disabled={state.isDisabled || undefined}\n />\n </Provider>\n );\n});\n\nexport interface SliderOutputProps\n extends RenderProps<SliderRenderProps, 'output'>, GlobalDOMAttributes<HTMLOutputElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderOutput'\n */\n className?: ClassNameOrFunction<SliderRenderProps>;\n}\ninterface SliderOutputContextValue\n extends\n Omit<OutputHTMLAttributes<HTMLOutputElement>, 'children' | 'className' | 'style'>,\n SliderOutputProps {}\n\n/**\n * A slider output displays the current value of a slider as text.\n */\nexport const SliderOutput = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderOutput(\n props: SliderOutputProps,\n ref: ForwardedRef<HTMLOutputElement>\n) {\n [props, ref] = useContextProps(props, ref, SliderOutputContext);\n let {children, style, className, render, ...otherProps} = props;\n let state = useContext(SliderStateContext)!;\n let renderProps = useRenderProps({\n className,\n style,\n children,\n render,\n defaultChildren: state.getFormattedValue(),\n defaultClassName: 'react-aria-SliderOutput',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n }\n });\n\n return (\n <dom.output\n {...otherProps}\n {...renderProps}\n ref={ref}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined}\n />\n );\n});\n\nexport interface SliderTrackRenderProps extends SliderRenderProps {\n /**\n * Whether the slider track is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n}\n\nexport interface SliderTrackProps\n extends HoverEvents, RenderProps<SliderTrackRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderTrack'\n */\n className?: ClassNameOrFunction<SliderTrackRenderProps>;\n}\ninterface SliderTrackContextValue\n extends\n Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'style'>,\n SliderTrackProps {}\n\n/**\n * A slider track is a container for one or more slider thumbs.\n */\nexport const SliderTrack = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderTrack(\n props: SliderTrackProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, SliderTrackContext);\n let state = useContext(SliderStateContext)!;\n let {onHoverStart, onHoverEnd, onHoverChange, ...otherProps} = props;\n let {hoverProps, isHovered} = useHover({onHoverStart, onHoverEnd, onHoverChange});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderTrack',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n isHovered,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(otherProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-hovered={isHovered || undefined}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined}\n />\n );\n});\n\nexport interface SliderThumbRenderProps {\n /**\n * State of the slider.\n */\n state: SliderState;\n /**\n * Whether this thumb is currently being dragged.\n *\n * @selector [data-dragging]\n */\n isDragging: boolean;\n /**\n * Whether the thumb is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the thumb is currently focused.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the thumb is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the thumb is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n}\n\nexport interface SliderThumbProps\n extends\n Omit<AriaSliderThumbProps, 'label' | 'validationState'>,\n HoverEvents,\n RenderProps<SliderThumbRenderProps>,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderThumb'\n */\n className?: ClassNameOrFunction<SliderThumbRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\n/**\n * A slider thumb represents an individual value that the user can adjust within a slider track.\n */\nexport const SliderThumb = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderThumb(\n props: SliderThumbProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userInputRef = null} = props;\n let state = useContext(SliderStateContext)!;\n let {ref: trackRef} = useSlottedContext(SliderTrackContext)!;\n let {index = 0} = props;\n let defaultInputRef = useRef<HTMLInputElement>(null);\n let inputRef = userInputRef || defaultInputRef;\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {thumbProps, inputProps, labelProps, isDragging, isFocused, isDisabled} = useSliderThumb(\n {\n ...props,\n index,\n trackRef: trackRef as RefObject<HTMLDivElement | null>,\n inputRef,\n label\n },\n state\n );\n\n let {focusProps, isFocusVisible} = useFocusRing();\n let {hoverProps, isHovered} = useHover(props);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderThumb',\n values: {\n state,\n isHovered,\n isDragging,\n isFocused,\n isFocusVisible,\n isDisabled\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, thumbProps, hoverProps)}\n {...renderProps}\n ref={ref}\n style={{...thumbProps.style, ...renderProps.style}}\n data-hovered={isHovered || undefined}\n data-dragging={isDragging || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}>\n <VisuallyHidden>\n <input ref={inputRef} {...mergeProps(inputProps, focusProps)} />\n </VisuallyHidden>\n <Provider values={[[LabelContext, {...labelProps, ref: labelRef}]]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\nexport interface SliderFillRenderProps extends SliderRenderProps {\n /**\n * Whether the slider fill is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n}\n\nexport interface SliderFillProps\n extends HoverEvents, RenderProps<SliderFillRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The offset from which to start the fill.\n *\n * @default 0\n */\n offset?: number;\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderFill'\n */\n className?: ClassNameOrFunction<SliderFillRenderProps>;\n}\n\n/**\n * Displays the selected range.\n */\nexport const SliderFill = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderFill(\n props: SliderFillProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, SliderFillContext);\n let state = useContext(SliderStateContext)!;\n let {onHoverStart, onHoverEnd, onHoverChange, ...otherProps} = props;\n let {hoverProps, isHovered} = useHover({onHoverStart, onHoverEnd, onHoverChange});\n\n let offset =\n props.offset != null\n ? clamp(props.offset, state.getThumbMinValue(0), state.getThumbMaxValue(0))\n : state.getThumbMinValue(0);\n let start =\n state.values.length > 1 ? state.getThumbPercent(0) * 100 : state.getValuePercent(offset) * 100;\n let end = state.values.length > 0 ? state.getThumbPercent(state.values.length - 1) * 100 : 0;\n let startPercent = Math.min(start, end);\n let endPercent = Math.max(start, end);\n let sizePercent = Math.max(0, endPercent - startPercent);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderFill',\n defaultStyle:\n state.orientation === 'vertical'\n ? {\n position: 'absolute',\n bottom: `${startPercent}%`,\n height: `${sizePercent}%`,\n width: '100%'\n }\n : {\n position: 'absolute',\n insetInlineStart: `${startPercent}%`,\n width: `${sizePercent}%`,\n height: '100%'\n },\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n isHovered,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(otherProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-hovered={isHovered || undefined}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"Slider.js.map"}
|
package/dist/private/Slider.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {dom as $7230ffa83bc0c2cf$export$df3a06d6289f983e, Provider as $7230ffa83bc0c2cf$export$2881499e37b75b9a, useContextProps as $7230ffa83bc0c2cf$export$29f1550f4b0d4415, useRenderProps as $7230ffa83bc0c2cf$export$4d86445c2cf5e3, useSlot as $7230ffa83bc0c2cf$export$9d4c57ee4c6ffdd8, useSlottedContext as $7230ffa83bc0c2cf$export$fabf2dc03a41866e} from "./utils.mjs";
|
|
2
2
|
import {LabelContext as $43a3b93638fe5db9$export$75b6ee27786ba447} from "./Label.mjs";
|
|
3
3
|
import {useSlider as $270k0$useSlider, useSliderThumb as $270k0$useSliderThumb} from "react-aria/useSlider";
|
|
4
|
+
import {clamp as $270k0$clamp} from "react-stately/private/utils/number";
|
|
4
5
|
import {filterDOMProps as $270k0$filterDOMProps} from "react-aria/filterDOMProps";
|
|
5
6
|
import {mergeProps as $270k0$mergeProps} from "react-aria/mergeProps";
|
|
6
7
|
import $270k0$react, {createContext as $270k0$createContext, forwardRef as $270k0$forwardRef, useRef as $270k0$useRef, useContext as $270k0$useContext} from "react";
|
|
@@ -31,9 +32,11 @@ import {VisuallyHidden as $270k0$VisuallyHidden} from "react-aria/VisuallyHidden
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
const $806e559d0c2c64a0$export$e99164f0030f3bff = /*#__PURE__*/ (0, $270k0$createContext)(null);
|
|
35
37
|
const $806e559d0c2c64a0$export$1e7083018727fa60 = /*#__PURE__*/ (0, $270k0$createContext)(null);
|
|
36
38
|
const $806e559d0c2c64a0$export$f1fce0420cc6d8ee = /*#__PURE__*/ (0, $270k0$createContext)(null);
|
|
39
|
+
const $806e559d0c2c64a0$export$7ed6e0ce9ec48be7 = /*#__PURE__*/ (0, $270k0$createContext)(null);
|
|
37
40
|
const $806e559d0c2c64a0$export$6189c2744041d8f8 = /*#__PURE__*/ (0, $270k0$createContext)(null);
|
|
38
41
|
const $806e559d0c2c64a0$export$472062a354075cee = /*#__PURE__*/ (0, $270k0$forwardRef)(function Slider(props, ref) {
|
|
39
42
|
[props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(props, ref, $806e559d0c2c64a0$export$e99164f0030f3bff);
|
|
@@ -103,7 +106,7 @@ const $806e559d0c2c64a0$export$a590f758a961cb5b = /*#__PURE__*/ (0, $270k0$forwa
|
|
|
103
106
|
style: style,
|
|
104
107
|
children: children,
|
|
105
108
|
render: render,
|
|
106
|
-
defaultChildren: state.
|
|
109
|
+
defaultChildren: state.getFormattedValue(),
|
|
107
110
|
defaultClassName: 'react-aria-SliderOutput',
|
|
108
111
|
values: {
|
|
109
112
|
orientation: state.orientation,
|
|
@@ -208,7 +211,52 @@ const $806e559d0c2c64a0$export$2c1b491743890dec = /*#__PURE__*/ (0, $270k0$forwa
|
|
|
208
211
|
]
|
|
209
212
|
}, renderProps.children));
|
|
210
213
|
});
|
|
214
|
+
const $806e559d0c2c64a0$export$2ede0a3f7b0c0db = /*#__PURE__*/ (0, $270k0$forwardRef)(function SliderFill(props, ref) {
|
|
215
|
+
[props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(props, ref, $806e559d0c2c64a0$export$7ed6e0ce9ec48be7);
|
|
216
|
+
let state = (0, $270k0$useContext)($806e559d0c2c64a0$export$1e7083018727fa60);
|
|
217
|
+
let { onHoverStart: onHoverStart, onHoverEnd: onHoverEnd, onHoverChange: onHoverChange, ...otherProps } = props;
|
|
218
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $270k0$useHover)({
|
|
219
|
+
onHoverStart: onHoverStart,
|
|
220
|
+
onHoverEnd: onHoverEnd,
|
|
221
|
+
onHoverChange: onHoverChange
|
|
222
|
+
});
|
|
223
|
+
let offset = props.offset != null ? (0, $270k0$clamp)(props.offset, state.getThumbMinValue(0), state.getThumbMaxValue(0)) : state.getThumbMinValue(0);
|
|
224
|
+
let start = state.values.length > 1 ? state.getThumbPercent(0) * 100 : state.getValuePercent(offset) * 100;
|
|
225
|
+
let end = state.values.length > 0 ? state.getThumbPercent(state.values.length - 1) * 100 : 0;
|
|
226
|
+
let startPercent = Math.min(start, end);
|
|
227
|
+
let endPercent = Math.max(start, end);
|
|
228
|
+
let sizePercent = Math.max(0, endPercent - startPercent);
|
|
229
|
+
let renderProps = (0, $7230ffa83bc0c2cf$export$4d86445c2cf5e3)({
|
|
230
|
+
...props,
|
|
231
|
+
defaultClassName: 'react-aria-SliderFill',
|
|
232
|
+
defaultStyle: state.orientation === 'vertical' ? {
|
|
233
|
+
position: 'absolute',
|
|
234
|
+
bottom: `${startPercent}%`,
|
|
235
|
+
height: `${sizePercent}%`,
|
|
236
|
+
width: '100%'
|
|
237
|
+
} : {
|
|
238
|
+
position: 'absolute',
|
|
239
|
+
insetInlineStart: `${startPercent}%`,
|
|
240
|
+
width: `${sizePercent}%`,
|
|
241
|
+
height: '100%'
|
|
242
|
+
},
|
|
243
|
+
values: {
|
|
244
|
+
orientation: state.orientation,
|
|
245
|
+
isDisabled: state.isDisabled,
|
|
246
|
+
isHovered: isHovered,
|
|
247
|
+
state: state
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
return /*#__PURE__*/ (0, $270k0$react).createElement((0, $7230ffa83bc0c2cf$export$df3a06d6289f983e).div, {
|
|
251
|
+
...(0, $270k0$mergeProps)(otherProps, hoverProps),
|
|
252
|
+
...renderProps,
|
|
253
|
+
ref: ref,
|
|
254
|
+
"data-hovered": isHovered || undefined,
|
|
255
|
+
"data-orientation": state.orientation || undefined,
|
|
256
|
+
"data-disabled": state.isDisabled || undefined
|
|
257
|
+
});
|
|
258
|
+
});
|
|
211
259
|
|
|
212
260
|
|
|
213
|
-
export {$806e559d0c2c64a0$export$e99164f0030f3bff as SliderContext, $806e559d0c2c64a0$export$1e7083018727fa60 as SliderStateContext, $806e559d0c2c64a0$export$f1fce0420cc6d8ee as SliderTrackContext, $806e559d0c2c64a0$export$6189c2744041d8f8 as SliderOutputContext, $806e559d0c2c64a0$export$472062a354075cee as Slider, $806e559d0c2c64a0$export$a590f758a961cb5b as SliderOutput, $806e559d0c2c64a0$export$105594979f116971 as SliderTrack, $806e559d0c2c64a0$export$2c1b491743890dec as SliderThumb};
|
|
261
|
+
export {$806e559d0c2c64a0$export$e99164f0030f3bff as SliderContext, $806e559d0c2c64a0$export$1e7083018727fa60 as SliderStateContext, $806e559d0c2c64a0$export$f1fce0420cc6d8ee as SliderTrackContext, $806e559d0c2c64a0$export$7ed6e0ce9ec48be7 as SliderFillContext, $806e559d0c2c64a0$export$6189c2744041d8f8 as SliderOutputContext, $806e559d0c2c64a0$export$472062a354075cee as Slider, $806e559d0c2c64a0$export$a590f758a961cb5b as SliderOutput, $806e559d0c2c64a0$export$105594979f116971 as SliderTrack, $806e559d0c2c64a0$export$2c1b491743890dec as SliderThumb, $806e559d0c2c64a0$export$2ede0a3f7b0c0db as SliderFill};
|
|
214
262
|
//# sourceMappingURL=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,UAAU;kBACV;eACA;IACF,GAAG;IAEH,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW;IAC9C,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;mBACN;uBACA;wBACA;uBACA;4BACA;wBACA;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAElB,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY,WAAW;QAC/C,GAAG,WAAW;QACf,KAAK;QACL,OAAO;YAAC,GAAG,WAAW,KAAK;YAAE,GAAG,YAAY,KAAK;QAAA;QACjD,gBAAc,aAAa;QAC3B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa,uBACZ,gCAAC;QAAM,KAAK;QAAW,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;uBAE9D,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;SAC/C;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/Slider.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSliderProps, AriaSliderThumbProps, useSlider, useSliderThumb} from 'react-aria/useSlider';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents, Orientation} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, OutputHTMLAttributes, useContext, useRef} from 'react';\nimport {SliderState, useSliderState} from 'react-stately/useSliderState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useNumberFormatter} from 'react-aria/useNumberFormatter';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SliderProps<T = number | number[]> extends Omit<AriaSliderProps<T>, 'label'>, RenderProps<SliderRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-Slider'\n */\n className?: ClassNameOrFunction<SliderRenderProps>,\n /**\n * The display format of the value label.\n */\n formatOptions?: Intl.NumberFormatOptions\n}\n\nexport const SliderContext = createContext<ContextValue<SliderProps, HTMLDivElement>>(null);\nexport const SliderStateContext = createContext<SliderState | null>(null);\nexport const SliderTrackContext = createContext<ContextValue<SliderTrackContextValue, HTMLDivElement>>(null);\nexport const SliderOutputContext = createContext<ContextValue<SliderOutputContextValue, HTMLOutputElement>>(null);\n\nexport interface SliderRenderProps {\n /**\n * The orientation of the slider.\n * @selector [data-orientation=\"horizontal | vertical\"]\n */\n orientation: Orientation,\n /**\n * Whether the slider is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the slider.\n */\n state: SliderState\n}\n\n/**\n * A slider allows a user to select one or more values within a range.\n */\nexport const Slider = /*#__PURE__*/ (forwardRef as forwardRefType)(function Slider<T extends number | number[]>(props: SliderProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SliderContext);\n let trackRef = useRef<HTMLDivElement>(null);\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let state = useSliderState({...props, numberFormatter});\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {\n groupProps,\n trackProps,\n labelProps,\n outputProps\n } = useSlider({...props, label}, state, trackRef);\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n },\n defaultClassName: 'react-aria-Slider'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <Provider\n values={[\n [SliderStateContext, state],\n [SliderTrackContext, {...trackProps, ref: trackRef}],\n [SliderOutputContext, outputProps],\n [LabelContext, {...labelProps, ref: labelRef}]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-orientation={state.orientation}\n data-disabled={state.isDisabled || undefined} />\n </Provider>\n );\n});\n\nexport interface SliderOutputProps extends RenderProps<SliderRenderProps, 'output'>, GlobalDOMAttributes<HTMLOutputElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SliderOutput'\n */\n className?: ClassNameOrFunction<SliderRenderProps>\n}\ninterface SliderOutputContextValue extends Omit<OutputHTMLAttributes<HTMLOutputElement>, 'children' | 'className' | 'style'>, SliderOutputProps {}\n\n/**\n * A slider output displays the current value of a slider as text.\n */\nexport const SliderOutput = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderOutput(props: SliderOutputProps, ref: ForwardedRef<HTMLOutputElement>) {\n [props, ref] = useContextProps(props, ref, SliderOutputContext);\n let {children, style, className, render, ...otherProps} = props;\n let state = useContext(SliderStateContext)!;\n let renderProps = useRenderProps({\n className,\n style,\n children,\n render,\n defaultChildren: state.getThumbValueLabel(0),\n defaultClassName: 'react-aria-SliderOutput',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n }\n });\n\n return (\n <dom.output\n {...otherProps}\n {...renderProps}\n ref={ref}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined} />\n );\n});\n\nexport interface SliderTrackRenderProps extends SliderRenderProps {\n /**\n * Whether the slider track is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean\n}\n\nexport interface SliderTrackProps extends HoverEvents, RenderProps<SliderTrackRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SliderTrack'\n */\n className?: ClassNameOrFunction<SliderTrackRenderProps>\n}\ninterface SliderTrackContextValue extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'style'>, SliderTrackProps {}\n\n/**\n * A slider track is a container for one or more slider thumbs.\n */\nexport const SliderTrack = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderTrack(props: SliderTrackProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SliderTrackContext);\n let state = useContext(SliderStateContext)!;\n let {onHoverStart, onHoverEnd, onHoverChange, ...otherProps} = props;\n let {hoverProps, isHovered} = useHover({onHoverStart, onHoverEnd, onHoverChange});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderTrack',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n isHovered,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(otherProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-hovered={isHovered || undefined}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined} />\n );\n});\n\nexport interface SliderThumbRenderProps {\n /**\n * State of the slider.\n */\n state: SliderState,\n /**\n * Whether this thumb is currently being dragged.\n * @selector [data-dragging]\n */\n isDragging: boolean,\n /**\n * Whether the thumb is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean,\n /**\n * Whether the thumb is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the thumb is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the thumb is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean\n}\n\nexport interface SliderThumbProps extends Omit<AriaSliderThumbProps, 'label' | 'validationState'>, HoverEvents, RenderProps<SliderThumbRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-SliderThumb'\n */\n className?: ClassNameOrFunction<SliderThumbRenderProps>,\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>\n}\n\n/**\n * A slider thumb represents an individual value that the user can adjust within a slider track.\n */\nexport const SliderThumb = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderThumb(props: SliderThumbProps, ref: ForwardedRef<HTMLDivElement>) {\n let {\n inputRef: userInputRef = null\n } = props;\n let state = useContext(SliderStateContext)!;\n let {ref: trackRef} = useSlottedContext(SliderTrackContext)!;\n let {index = 0} = props;\n let defaultInputRef = useRef<HTMLInputElement>(null);\n let inputRef = userInputRef || defaultInputRef;\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let {thumbProps, inputProps, labelProps, isDragging, isFocused, isDisabled} = useSliderThumb({\n ...props,\n index,\n trackRef: trackRef as RefObject<HTMLDivElement | null>,\n inputRef,\n label\n }, state);\n\n let {focusProps, isFocusVisible} = useFocusRing();\n let {hoverProps, isHovered} = useHover(props);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderThumb',\n values: {\n state,\n isHovered,\n isDragging,\n isFocused,\n isFocusVisible,\n isDisabled\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, thumbProps, hoverProps)}\n {...renderProps}\n ref={ref}\n style={{...thumbProps.style, ...renderProps.style}}\n data-hovered={isHovered || undefined}\n data-dragging={isDragging || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}>\n <VisuallyHidden>\n <input ref={inputRef} {...mergeProps(inputProps, focusProps)} />\n </VisuallyHidden>\n <Provider\n values={[\n [LabelContext, {...labelProps, ref: labelRef}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"Slider.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA6DM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAA6C;AAC/E,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAAsB;AAC7D,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAyD;AAChE,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAiD;AACvF,MAAM,0DACX,CAAA,GAAA,oBAAY,EAA6D;AAwBpE,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,OAE1E,KAAqB,EAAE,GAAiC;IACxD,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,WAAW,CAAA,GAAA,aAAK,EAAkB;IACtC,IAAI,kBAAkB,CAAA,GAAA,yBAAiB,EAAE,MAAM,aAAa;IAC5D,IAAI,QAAQ,CAAA,GAAA,qBAAa,EAAE;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cAAc,KAAK,GAAG,CAAC,GAAG,aAAa;IAE3C,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,cACE,MAAM,WAAW,KAAK,aAClB;YACE,UAAU;YACV,QAAQ,GAAG,aAAa,CAAC,CAAC;YAC1B,QAAQ,GAAG,YAAY,CAAC,CAAC;YACzB,OAAO;QACT,IACA;YACE,UAAU;YACV,kBAAkB,GAAG,aAAa,CAAC,CAAC;YACpC,OAAO,GAAG,YAAY,CAAC,CAAC;YACxB,QAAQ;QACV;QACN,QAAQ;YACN,aAAa,MAAM,WAAW;YAC9B,YAAY,MAAM,UAAU;uBAC5B;mBACA;QACF;IACF;IAEA,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,WAAW;QACrC,GAAG,WAAW;QACf,KAAK;QACL,gBAAc,aAAa;QAC3B,oBAAkB,MAAM,WAAW,IAAI;QACvC,iBAAe,MAAM,UAAU,IAAI;;AAGzC","sources":["packages/react-aria-components/src/Slider.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AriaSliderProps,\n AriaSliderThumbProps,\n useSlider,\n useSliderThumb\n} from 'react-aria/useSlider';\n\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents, Orientation} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n HTMLAttributes,\n OutputHTMLAttributes,\n useContext,\n useRef\n} from 'react';\nimport {SliderState, useSliderState} from 'react-stately/useSliderState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useNumberFormatter} from 'react-aria/useNumberFormatter';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SliderProps<T = number | number[]>\n extends\n Omit<AriaSliderProps<T>, 'label'>,\n RenderProps<SliderRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Slider'\n */\n className?: ClassNameOrFunction<SliderRenderProps>;\n /**\n * The display format of the value label.\n */\n formatOptions?: Intl.NumberFormatOptions;\n}\n\nexport const SliderContext = createContext<ContextValue<SliderProps, HTMLDivElement>>(null);\nexport const SliderStateContext = createContext<SliderState | null>(null);\nexport const SliderTrackContext =\n createContext<ContextValue<SliderTrackContextValue, HTMLDivElement>>(null);\nexport const SliderFillContext = createContext<ContextValue<SliderFillProps, HTMLDivElement>>(null);\nexport const SliderOutputContext =\n createContext<ContextValue<SliderOutputContextValue, HTMLOutputElement>>(null);\n\nexport interface SliderRenderProps {\n /**\n * The orientation of the slider.\n *\n * @selector [data-orientation=\"horizontal | vertical\"]\n */\n orientation: Orientation;\n /**\n * Whether the slider is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * State of the slider.\n */\n state: SliderState;\n}\n\n/**\n * A slider allows a user to select one or more values within a range.\n */\nexport const Slider = /*#__PURE__*/ (forwardRef as forwardRefType)(function Slider<\n T extends number | number[]\n>(props: SliderProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SliderContext);\n let trackRef = useRef<HTMLDivElement>(null);\n let numberFormatter = useNumberFormatter(props.formatOptions);\n let state = useSliderState({...props, numberFormatter});\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {groupProps, trackProps, labelProps, outputProps} = useSlider(\n {...props, label},\n state,\n trackRef\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n },\n defaultClassName: 'react-aria-Slider'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <Provider\n values={[\n [SliderStateContext, state],\n [SliderTrackContext, {...trackProps, ref: trackRef}],\n [SliderOutputContext, outputProps],\n [LabelContext, {...labelProps, ref: labelRef}]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, groupProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-orientation={state.orientation}\n data-disabled={state.isDisabled || undefined}\n />\n </Provider>\n );\n});\n\nexport interface SliderOutputProps\n extends RenderProps<SliderRenderProps, 'output'>, GlobalDOMAttributes<HTMLOutputElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderOutput'\n */\n className?: ClassNameOrFunction<SliderRenderProps>;\n}\ninterface SliderOutputContextValue\n extends\n Omit<OutputHTMLAttributes<HTMLOutputElement>, 'children' | 'className' | 'style'>,\n SliderOutputProps {}\n\n/**\n * A slider output displays the current value of a slider as text.\n */\nexport const SliderOutput = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderOutput(\n props: SliderOutputProps,\n ref: ForwardedRef<HTMLOutputElement>\n) {\n [props, ref] = useContextProps(props, ref, SliderOutputContext);\n let {children, style, className, render, ...otherProps} = props;\n let state = useContext(SliderStateContext)!;\n let renderProps = useRenderProps({\n className,\n style,\n children,\n render,\n defaultChildren: state.getFormattedValue(),\n defaultClassName: 'react-aria-SliderOutput',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n state\n }\n });\n\n return (\n <dom.output\n {...otherProps}\n {...renderProps}\n ref={ref}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined}\n />\n );\n});\n\nexport interface SliderTrackRenderProps extends SliderRenderProps {\n /**\n * Whether the slider track is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n}\n\nexport interface SliderTrackProps\n extends HoverEvents, RenderProps<SliderTrackRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderTrack'\n */\n className?: ClassNameOrFunction<SliderTrackRenderProps>;\n}\ninterface SliderTrackContextValue\n extends\n Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'style'>,\n SliderTrackProps {}\n\n/**\n * A slider track is a container for one or more slider thumbs.\n */\nexport const SliderTrack = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderTrack(\n props: SliderTrackProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, SliderTrackContext);\n let state = useContext(SliderStateContext)!;\n let {onHoverStart, onHoverEnd, onHoverChange, ...otherProps} = props;\n let {hoverProps, isHovered} = useHover({onHoverStart, onHoverEnd, onHoverChange});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderTrack',\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n isHovered,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(otherProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-hovered={isHovered || undefined}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined}\n />\n );\n});\n\nexport interface SliderThumbRenderProps {\n /**\n * State of the slider.\n */\n state: SliderState;\n /**\n * Whether this thumb is currently being dragged.\n *\n * @selector [data-dragging]\n */\n isDragging: boolean;\n /**\n * Whether the thumb is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the thumb is currently focused.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the thumb is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the thumb is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n}\n\nexport interface SliderThumbProps\n extends\n Omit<AriaSliderThumbProps, 'label' | 'validationState'>,\n HoverEvents,\n RenderProps<SliderThumbRenderProps>,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderThumb'\n */\n className?: ClassNameOrFunction<SliderThumbRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\n/**\n * A slider thumb represents an individual value that the user can adjust within a slider track.\n */\nexport const SliderThumb = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderThumb(\n props: SliderThumbProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userInputRef = null} = props;\n let state = useContext(SliderStateContext)!;\n let {ref: trackRef} = useSlottedContext(SliderTrackContext)!;\n let {index = 0} = props;\n let defaultInputRef = useRef<HTMLInputElement>(null);\n let inputRef = userInputRef || defaultInputRef;\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {thumbProps, inputProps, labelProps, isDragging, isFocused, isDisabled} = useSliderThumb(\n {\n ...props,\n index,\n trackRef: trackRef as RefObject<HTMLDivElement | null>,\n inputRef,\n label\n },\n state\n );\n\n let {focusProps, isFocusVisible} = useFocusRing();\n let {hoverProps, isHovered} = useHover(props);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderThumb',\n values: {\n state,\n isHovered,\n isDragging,\n isFocused,\n isFocusVisible,\n isDisabled\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, thumbProps, hoverProps)}\n {...renderProps}\n ref={ref}\n style={{...thumbProps.style, ...renderProps.style}}\n data-hovered={isHovered || undefined}\n data-dragging={isDragging || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}>\n <VisuallyHidden>\n <input ref={inputRef} {...mergeProps(inputProps, focusProps)} />\n </VisuallyHidden>\n <Provider values={[[LabelContext, {...labelProps, ref: labelRef}]]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\nexport interface SliderFillRenderProps extends SliderRenderProps {\n /**\n * Whether the slider fill is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n}\n\nexport interface SliderFillProps\n extends HoverEvents, RenderProps<SliderFillRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The offset from which to start the fill.\n *\n * @default 0\n */\n offset?: number;\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SliderFill'\n */\n className?: ClassNameOrFunction<SliderFillRenderProps>;\n}\n\n/**\n * Displays the selected range.\n */\nexport const SliderFill = /*#__PURE__*/ (forwardRef as forwardRefType)(function SliderFill(\n props: SliderFillProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, SliderFillContext);\n let state = useContext(SliderStateContext)!;\n let {onHoverStart, onHoverEnd, onHoverChange, ...otherProps} = props;\n let {hoverProps, isHovered} = useHover({onHoverStart, onHoverEnd, onHoverChange});\n\n let offset =\n props.offset != null\n ? clamp(props.offset, state.getThumbMinValue(0), state.getThumbMaxValue(0))\n : state.getThumbMinValue(0);\n let start =\n state.values.length > 1 ? state.getThumbPercent(0) * 100 : state.getValuePercent(offset) * 100;\n let end = state.values.length > 0 ? state.getThumbPercent(state.values.length - 1) * 100 : 0;\n let startPercent = Math.min(start, end);\n let endPercent = Math.max(start, end);\n let sizePercent = Math.max(0, endPercent - startPercent);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SliderFill',\n defaultStyle:\n state.orientation === 'vertical'\n ? {\n position: 'absolute',\n bottom: `${startPercent}%`,\n height: `${sizePercent}%`,\n width: '100%'\n }\n : {\n position: 'absolute',\n insetInlineStart: `${startPercent}%`,\n width: `${sizePercent}%`,\n height: '100%'\n },\n values: {\n orientation: state.orientation,\n isDisabled: state.isDisabled,\n isHovered,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(otherProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-hovered={isHovered || undefined}\n data-orientation={state.orientation || undefined}\n data-disabled={state.isDisabled || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"Slider.mjs.map"}
|
package/dist/private/Switch.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
var $048d76b84370f141$exports = require("./utils.cjs");
|
|
2
|
+
var $862aa7df04d8fa76$exports = require("./FieldError.cjs");
|
|
3
|
+
var $5adc12e2ce73be8f$exports = require("./Form.cjs");
|
|
4
|
+
var $cab7d9a238d19c33$exports = require("./Text.cjs");
|
|
2
5
|
var $goUg1$reactariauseSwitch = require("react-aria/useSwitch");
|
|
3
6
|
var $goUg1$reactariafilterDOMProps = require("react-aria/filterDOMProps");
|
|
4
7
|
var $goUg1$reactariamergeProps = require("react-aria/mergeProps");
|
|
@@ -20,7 +23,10 @@ function $parcel$export(e, n, v, s) {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
$parcel$export(module.exports, "SwitchContext", function () { return $f78e777132fa7bc2$export$8699e3b644d5a28a; });
|
|
26
|
+
$parcel$export(module.exports, "SwitchFieldContext", function () { return $f78e777132fa7bc2$export$3e1405298f0cafda; });
|
|
23
27
|
$parcel$export(module.exports, "Switch", function () { return $f78e777132fa7bc2$export$b5d5cf8927ab7262; });
|
|
28
|
+
$parcel$export(module.exports, "SwitchButton", function () { return $f78e777132fa7bc2$export$72111f742dee7cb8; });
|
|
29
|
+
$parcel$export(module.exports, "SwitchField", function () { return $f78e777132fa7bc2$export$208c2e617baf9fc3; });
|
|
24
30
|
/*
|
|
25
31
|
* Copyright 2022 Adobe. All rights reserved.
|
|
26
32
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -42,26 +48,130 @@ $parcel$export(module.exports, "Switch", function () { return $f78e777132fa7bc2$
|
|
|
42
48
|
|
|
43
49
|
|
|
44
50
|
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
45
54
|
const $f78e777132fa7bc2$export$8699e3b644d5a28a = /*#__PURE__*/ (0, $goUg1$react.createContext)(null);
|
|
55
|
+
const $f78e777132fa7bc2$export$3e1405298f0cafda = /*#__PURE__*/ (0, $goUg1$react.createContext)(null);
|
|
56
|
+
const $f78e777132fa7bc2$export$5cc1518e1ec171c = /*#__PURE__*/ (0, $goUg1$react.createContext)(null);
|
|
46
57
|
const $f78e777132fa7bc2$export$b5d5cf8927ab7262 = /*#__PURE__*/ (0, $goUg1$react.forwardRef)(function Switch(props, ref) {
|
|
47
58
|
let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
|
|
48
59
|
[props, ref] = (0, $048d76b84370f141$exports.useContextProps)(otherProps, ref, $f78e777132fa7bc2$export$8699e3b644d5a28a);
|
|
49
60
|
let inputRef = (0, $goUg1$reactariauseObjectRef.useObjectRef)((0, $goUg1$reactariamergeRefs.mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
|
|
50
61
|
let state = (0, $goUg1$reactstatelyuseToggleState.useToggleState)(props);
|
|
51
|
-
let
|
|
62
|
+
let aria = (0, $goUg1$reactariauseSwitch.useSwitch)({
|
|
52
63
|
...(0, $048d76b84370f141$exports.removeDataAttributes)(props),
|
|
53
64
|
// ReactNode type doesn't allow function children.
|
|
54
65
|
children: typeof props.children === 'function' ? true : props.children
|
|
55
66
|
}, state, inputRef);
|
|
67
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement((0, $048d76b84370f141$exports.Provider), {
|
|
68
|
+
values: [
|
|
69
|
+
[
|
|
70
|
+
$f78e777132fa7bc2$export$5cc1518e1ec171c,
|
|
71
|
+
state
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
$f78e777132fa7bc2$var$InternalSwitchContext,
|
|
75
|
+
{
|
|
76
|
+
...aria,
|
|
77
|
+
inputRef: inputRef,
|
|
78
|
+
defaultClassName: 'react-aria-Switch'
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
]
|
|
82
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement($f78e777132fa7bc2$export$72111f742dee7cb8, {
|
|
83
|
+
...props,
|
|
84
|
+
ref: ref
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
const $f78e777132fa7bc2$var$InternalSwitchContext = /*#__PURE__*/ (0, $goUg1$react.createContext)(null);
|
|
88
|
+
const $f78e777132fa7bc2$export$208c2e617baf9fc3 = /*#__PURE__*/ (0, $goUg1$react.forwardRef)(function Switch(props, ref) {
|
|
89
|
+
let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
|
|
90
|
+
[props, ref] = (0, $048d76b84370f141$exports.useContextProps)(otherProps, ref, $f78e777132fa7bc2$export$3e1405298f0cafda);
|
|
91
|
+
let { validationBehavior: formValidationBehavior } = (0, $048d76b84370f141$exports.useSlottedContext)((0, $5adc12e2ce73be8f$exports.FormContext)) || {};
|
|
92
|
+
let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';
|
|
93
|
+
let inputRef = (0, $goUg1$reactariauseObjectRef.useObjectRef)((0, $goUg1$reactariamergeRefs.mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
|
|
94
|
+
let state = (0, $goUg1$reactstatelyuseToggleState.useToggleState)(props);
|
|
95
|
+
let aria = (0, $goUg1$reactariauseSwitch.useSwitch)({
|
|
96
|
+
...(0, $048d76b84370f141$exports.removeDataAttributes)(props),
|
|
97
|
+
// ReactNode type doesn't allow function children.
|
|
98
|
+
children: typeof props.children === 'function' ? true : props.children,
|
|
99
|
+
validationBehavior: validationBehavior
|
|
100
|
+
}, state, inputRef);
|
|
101
|
+
let { descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, isSelected: isSelected, isDisabled: isDisabled, isReadOnly: isReadOnly, isInvalid: isInvalid, validationDetails: validationDetails, validationErrors: validationErrors } = aria;
|
|
102
|
+
let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
|
|
103
|
+
...props,
|
|
104
|
+
defaultClassName: 'react-aria-SwitchField',
|
|
105
|
+
values: {
|
|
106
|
+
isSelected: isSelected,
|
|
107
|
+
isDisabled: isDisabled,
|
|
108
|
+
isReadOnly: isReadOnly,
|
|
109
|
+
isInvalid: isInvalid,
|
|
110
|
+
isRequired: props.isRequired || false,
|
|
111
|
+
state: state
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
let DOMProps = (0, $goUg1$reactariafilterDOMProps.filterDOMProps)(props, {
|
|
115
|
+
global: true
|
|
116
|
+
});
|
|
117
|
+
delete DOMProps.id;
|
|
118
|
+
delete DOMProps.onClick;
|
|
119
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
|
|
120
|
+
...(0, $goUg1$reactariamergeProps.mergeProps)(DOMProps, renderProps),
|
|
121
|
+
ref: ref,
|
|
122
|
+
slot: props.slot || undefined,
|
|
123
|
+
"data-selected": isSelected || undefined,
|
|
124
|
+
"data-disabled": isDisabled || undefined,
|
|
125
|
+
"data-readonly": isReadOnly || undefined,
|
|
126
|
+
"data-invalid": isInvalid || undefined,
|
|
127
|
+
"data-required": props.isRequired || undefined
|
|
128
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement((0, $048d76b84370f141$exports.Provider), {
|
|
129
|
+
values: [
|
|
130
|
+
[
|
|
131
|
+
$f78e777132fa7bc2$export$5cc1518e1ec171c,
|
|
132
|
+
state
|
|
133
|
+
],
|
|
134
|
+
[
|
|
135
|
+
$f78e777132fa7bc2$var$InternalSwitchContext,
|
|
136
|
+
{
|
|
137
|
+
...aria,
|
|
138
|
+
inputRef: inputRef,
|
|
139
|
+
defaultClassName: 'react-aria-SwitchButton',
|
|
140
|
+
isRequired: props.isRequired
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
(0, $cab7d9a238d19c33$exports.TextContext),
|
|
145
|
+
{
|
|
146
|
+
slots: {
|
|
147
|
+
description: descriptionProps,
|
|
148
|
+
errorMessage: errorMessageProps
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
(0, $862aa7df04d8fa76$exports.FieldErrorContext),
|
|
154
|
+
{
|
|
155
|
+
isInvalid: isInvalid,
|
|
156
|
+
validationDetails: validationDetails,
|
|
157
|
+
validationErrors: validationErrors
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
]
|
|
161
|
+
}, renderProps.children));
|
|
162
|
+
});
|
|
163
|
+
const $f78e777132fa7bc2$export$72111f742dee7cb8 = /*#__PURE__*/ (0, $goUg1$react.forwardRef)(function SwitchButton(props, ref) {
|
|
164
|
+
let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isDisabled: isDisabled, isReadOnly: isReadOnly, isPressed: isPressed, isInvalid: isInvalid, inputRef: inputRef, defaultClassName: defaultClassName, isRequired: isRequired } = (0, $goUg1$react.useContext)($f78e777132fa7bc2$var$InternalSwitchContext);
|
|
56
165
|
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $goUg1$reactariauseFocusRing.useFocusRing)();
|
|
57
|
-
let isInteractionDisabled =
|
|
166
|
+
let isInteractionDisabled = isDisabled || isReadOnly;
|
|
167
|
+
let state = (0, $goUg1$react.useContext)($f78e777132fa7bc2$export$5cc1518e1ec171c);
|
|
58
168
|
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $goUg1$reactariauseHover.useHover)({
|
|
59
169
|
...props,
|
|
60
170
|
isDisabled: isInteractionDisabled
|
|
61
171
|
});
|
|
62
172
|
let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
|
|
63
173
|
...props,
|
|
64
|
-
defaultClassName:
|
|
174
|
+
defaultClassName: defaultClassName,
|
|
65
175
|
values: {
|
|
66
176
|
isSelected: isSelected,
|
|
67
177
|
isPressed: isPressed,
|
|
@@ -70,6 +180,8 @@ const $f78e777132fa7bc2$export$b5d5cf8927ab7262 = /*#__PURE__*/ (0, $goUg1$react
|
|
|
70
180
|
isFocusVisible: isFocusVisible,
|
|
71
181
|
isDisabled: isDisabled,
|
|
72
182
|
isReadOnly: isReadOnly,
|
|
183
|
+
isInvalid: isInvalid,
|
|
184
|
+
isRequired: isRequired || false,
|
|
73
185
|
state: state
|
|
74
186
|
}
|
|
75
187
|
});
|
|
@@ -88,7 +200,9 @@ const $f78e777132fa7bc2$export$b5d5cf8927ab7262 = /*#__PURE__*/ (0, $goUg1$react
|
|
|
88
200
|
"data-focused": isFocused || undefined,
|
|
89
201
|
"data-focus-visible": isFocusVisible || undefined,
|
|
90
202
|
"data-disabled": isDisabled || undefined,
|
|
91
|
-
"data-readonly": isReadOnly || undefined
|
|
203
|
+
"data-readonly": isReadOnly || undefined,
|
|
204
|
+
"data-invalid": isInvalid || undefined,
|
|
205
|
+
"data-required": isRequired || undefined
|
|
92
206
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement((0, $goUg1$reactariaVisuallyHidden.VisuallyHidden), {
|
|
93
207
|
elementType: "span"
|
|
94
208
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($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W,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,qCAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;qBAC7B,0DAAC,CAAA,GAAA,6CAAa;QAAE,aAAY;qBAC1B,0DAAC;QAAO,GAAG,CAAA,GAAA,qCAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps extends Omit<AriaSwitchProps, 'children'>, HoverEvents, RenderProps<SwitchRenderProps, 'label'>, SlotProps, Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>,\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n * @selector [data-selected]\n */\n isSelected: boolean,\n /**\n * Whether the switch is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean,\n /**\n * Whether the switch is currently in a pressed state.\n * @selector [data-pressed]\n */\n isPressed: boolean,\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the switch is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the switch is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the switch is read only.\n * @selector [data-readonly]\n */\n isReadOnly: boolean,\n /**\n * State of the switch.\n */\n state: ToggleState\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(props: SwitchProps, ref: ForwardedRef<HTMLLabelElement>) {\n let {\n inputRef: userProvidedInputRef = null,\n ...otherProps\n } = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));\n let state = useToggleState(props);\n let {labelProps, inputProps, isSelected, isDisabled, isReadOnly, isPressed} = useSwitch({\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n }, state, inputRef);\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = props.isDisabled || props.isReadOnly;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Switch',\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwMM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAA+C;AACjF,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAkD;AACzD,MAAM,yDAAqB,CAAA,GAAA,0BAAY,EAAsB;AAO7D,MAAM,4CAAuB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,OAC1E,KAAkB,EAClB,GAAmC;IAEnC,IAAI,E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,GAAG,CAAA,GAAA,qCAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSwitchProps, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\nimport {TextContext} from './Text';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps\n extends\n Omit<\n AriaSwitchProps,\n | 'children'\n | 'validationState'\n | 'validationBehavior'\n | 'isRequired'\n | 'isInvalid'\n | 'validate'\n >,\n HoverEvents,\n RenderProps<SwitchRenderProps, 'label'>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Switch'\n */\n className?: ClassNameOrFunction<SwitchRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchFieldProps\n extends\n Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n RACValidation,\n RenderProps<SwitchFieldRenderProps>,\n SlotProps,\n Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchField'\n */\n className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n /**\n * A ref for the HTML input element.\n */\n inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n extends\n HoverEvents,\n RenderProps<SwitchButtonRenderProps, 'label'>,\n SlotProps,\n GlobalDOMAttributes<HTMLLabelElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SwitchButton'\n */\n className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is currently hovered with a mouse.\n *\n * @selector [data-hovered]\n */\n isHovered: boolean;\n /**\n * Whether the switch is currently in a pressed state.\n *\n * @selector [data-pressed]\n */\n isPressed: boolean;\n /**\n * Whether the switch is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the switch is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n /**\n * Whether the switch is selected.\n *\n * @selector [data-selected]\n */\n isSelected: boolean;\n /**\n * Whether the switch is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the switch is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n /**\n * Whether the switch invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the switch is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * State of the switch.\n */\n state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children\n },\n state,\n inputRef\n );\n\n return (\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-Switch'\n }\n ]\n ]}>\n <SwitchButton {...props} ref={ref} />\n </Provider>\n );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n inputRef: RefObject<HTMLInputElement | null>;\n defaultClassName: string;\n isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n props: SwitchFieldProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useObjectRef(\n mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n );\n let state = useToggleState(props);\n let aria = useSwitch(\n {\n ...removeDataAttributes(props),\n // ReactNode type doesn't allow function children.\n children: typeof props.children === 'function' ? true : props.children,\n validationBehavior\n },\n state,\n inputRef\n );\n let {\n descriptionProps,\n errorMessageProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationDetails,\n validationErrors\n } = aria;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-SwitchField',\n values: {\n isSelected,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: props.isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [ToggleStateContext, state],\n [\n InternalSwitchContext,\n {\n ...aria,\n inputRef,\n defaultClassName: 'react-aria-SwitchButton',\n isRequired: props.isRequired\n }\n ],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n props: SwitchButtonProps,\n ref: ForwardedRef<HTMLLabelElement>\n) {\n let {\n labelProps,\n inputProps,\n isSelected,\n isDisabled,\n isReadOnly,\n isPressed,\n isInvalid,\n inputRef,\n defaultClassName,\n isRequired\n } = useContext(InternalSwitchContext)!;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n let isInteractionDisabled = isDisabled || isReadOnly;\n let state = useContext(ToggleStateContext)!;\n\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: isInteractionDisabled\n });\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName,\n values: {\n isSelected,\n isPressed,\n isHovered,\n isFocused,\n isFocusVisible,\n isDisabled,\n isReadOnly,\n isInvalid,\n isRequired: isRequired || false,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <dom.label\n {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-selected={isSelected || undefined}\n data-pressed={isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-disabled={isDisabled || undefined}\n data-readonly={isReadOnly || undefined}\n data-invalid={isInvalid || undefined}\n data-required={isRequired || undefined}>\n <VisuallyHidden elementType=\"span\">\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n {renderProps.children}\n </dom.label>\n );\n});\n"],"names":[],"version":3,"file":"Switch.cjs.map"}
|