react-aria-components 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Autocomplete.main.js +91 -0
- package/dist/Autocomplete.main.js.map +1 -0
- package/dist/Autocomplete.mjs +79 -0
- package/dist/Autocomplete.module.js +79 -0
- package/dist/Autocomplete.module.js.map +1 -0
- package/dist/Breadcrumbs.main.js +2 -5
- package/dist/Breadcrumbs.main.js.map +1 -1
- package/dist/Breadcrumbs.mjs +3 -6
- package/dist/Breadcrumbs.module.js +3 -6
- package/dist/Breadcrumbs.module.js.map +1 -1
- package/dist/Button.main.js +5 -5
- package/dist/Button.main.js.map +1 -1
- package/dist/Button.mjs +5 -5
- package/dist/Button.module.js +5 -5
- package/dist/Button.module.js.map +1 -1
- package/dist/Calendar.main.js +29 -28
- package/dist/Calendar.main.js.map +1 -1
- package/dist/Calendar.mjs +30 -29
- package/dist/Calendar.module.js +30 -29
- package/dist/Calendar.module.js.map +1 -1
- package/dist/Checkbox.main.js +6 -13
- package/dist/Checkbox.main.js.map +1 -1
- package/dist/Checkbox.mjs +7 -14
- package/dist/Checkbox.module.js +7 -14
- package/dist/Checkbox.module.js.map +1 -1
- package/dist/Collection.main.js.map +1 -1
- package/dist/Collection.module.js.map +1 -1
- package/dist/ColorArea.main.js +6 -9
- package/dist/ColorArea.main.js.map +1 -1
- package/dist/ColorArea.mjs +5 -8
- package/dist/ColorArea.module.js +5 -8
- package/dist/ColorArea.module.js.map +1 -1
- package/dist/ColorField.main.js +10 -15
- package/dist/ColorField.main.js.map +1 -1
- package/dist/ColorField.mjs +6 -11
- package/dist/ColorField.module.js +6 -11
- package/dist/ColorField.module.js.map +1 -1
- package/dist/ColorPicker.main.js +2 -2
- package/dist/ColorPicker.main.js.map +1 -1
- package/dist/ColorPicker.mjs +1 -1
- package/dist/ColorPicker.module.js +1 -1
- package/dist/ColorPicker.module.js.map +1 -1
- package/dist/ColorSlider.main.js +7 -12
- package/dist/ColorSlider.main.js.map +1 -1
- package/dist/ColorSlider.mjs +5 -10
- package/dist/ColorSlider.module.js +5 -10
- package/dist/ColorSlider.module.js.map +1 -1
- package/dist/ColorSwatch.main.js +4 -7
- package/dist/ColorSwatch.main.js.map +1 -1
- package/dist/ColorSwatch.mjs +3 -6
- package/dist/ColorSwatch.module.js +3 -6
- package/dist/ColorSwatch.module.js.map +1 -1
- package/dist/ColorSwatchPicker.main.js +7 -11
- package/dist/ColorSwatchPicker.main.js.map +1 -1
- package/dist/ColorSwatchPicker.mjs +6 -10
- package/dist/ColorSwatchPicker.module.js +6 -10
- package/dist/ColorSwatchPicker.module.js.map +1 -1
- package/dist/ColorThumb.main.js +4 -11
- package/dist/ColorThumb.main.js.map +1 -1
- package/dist/ColorThumb.mjs +4 -11
- package/dist/ColorThumb.module.js +4 -11
- package/dist/ColorThumb.module.js.map +1 -1
- package/dist/ColorWheel.main.js +9 -15
- package/dist/ColorWheel.main.js.map +1 -1
- package/dist/ColorWheel.mjs +8 -14
- package/dist/ColorWheel.module.js +8 -14
- package/dist/ColorWheel.module.js.map +1 -1
- package/dist/ComboBox.main.js +3 -6
- package/dist/ComboBox.main.js.map +1 -1
- package/dist/ComboBox.mjs +4 -7
- package/dist/ComboBox.module.js +4 -7
- package/dist/ComboBox.module.js.map +1 -1
- package/dist/DateField.main.js +12 -26
- package/dist/DateField.main.js.map +1 -1
- package/dist/DateField.mjs +13 -27
- package/dist/DateField.module.js +13 -27
- package/dist/DateField.module.js.map +1 -1
- package/dist/DatePicker.main.js +6 -13
- package/dist/DatePicker.main.js.map +1 -1
- package/dist/DatePicker.mjs +7 -14
- package/dist/DatePicker.module.js +7 -14
- package/dist/DatePicker.module.js.map +1 -1
- package/dist/Dialog.main.js +4 -6
- package/dist/Dialog.main.js.map +1 -1
- package/dist/Dialog.mjs +5 -7
- package/dist/Dialog.module.js +5 -7
- package/dist/Dialog.module.js.map +1 -1
- package/dist/Disclosure.main.js +11 -23
- package/dist/Disclosure.main.js.map +1 -1
- package/dist/Disclosure.mjs +8 -20
- package/dist/Disclosure.module.js +8 -20
- package/dist/Disclosure.module.js.map +1 -1
- package/dist/DragAndDrop.main.js +2 -5
- package/dist/DragAndDrop.main.js.map +1 -1
- package/dist/DragAndDrop.mjs +3 -6
- package/dist/DragAndDrop.module.js +3 -6
- package/dist/DragAndDrop.module.js.map +1 -1
- package/dist/DropZone.main.js +3 -8
- package/dist/DropZone.main.js.map +1 -1
- package/dist/DropZone.mjs +4 -9
- package/dist/DropZone.module.js +4 -9
- package/dist/DropZone.module.js.map +1 -1
- package/dist/FieldError.main.js +2 -5
- package/dist/FieldError.main.js.map +1 -1
- package/dist/FieldError.mjs +3 -6
- package/dist/FieldError.module.js +3 -6
- package/dist/FieldError.module.js.map +1 -1
- package/dist/FileTrigger.main.js +2 -5
- package/dist/FileTrigger.main.js.map +1 -1
- package/dist/FileTrigger.mjs +2 -5
- package/dist/FileTrigger.module.js +2 -5
- package/dist/FileTrigger.module.js.map +1 -1
- package/dist/Form.main.js +2 -6
- package/dist/Form.main.js.map +1 -1
- package/dist/Form.mjs +2 -6
- package/dist/Form.module.js +2 -6
- package/dist/Form.module.js.map +1 -1
- package/dist/GridList.main.js +2 -6
- package/dist/GridList.main.js.map +1 -1
- package/dist/GridList.mjs +3 -7
- package/dist/GridList.module.js +3 -7
- package/dist/GridList.module.js.map +1 -1
- package/dist/Group.main.js +2 -5
- package/dist/Group.main.js.map +1 -1
- package/dist/Group.mjs +2 -5
- package/dist/Group.module.js +2 -5
- package/dist/Group.module.js.map +1 -1
- package/dist/Heading.main.js +2 -3
- package/dist/Heading.main.js.map +1 -1
- package/dist/Heading.mjs +2 -3
- package/dist/Heading.module.js +2 -3
- package/dist/Heading.module.js.map +1 -1
- package/dist/Input.main.js +2 -5
- package/dist/Input.main.js.map +1 -1
- package/dist/Input.mjs +2 -5
- package/dist/Input.module.js +2 -5
- package/dist/Input.module.js.map +1 -1
- package/dist/Keyboard.main.js +2 -3
- package/dist/Keyboard.main.js.map +1 -1
- package/dist/Keyboard.mjs +2 -3
- package/dist/Keyboard.module.js +2 -3
- package/dist/Keyboard.module.js.map +1 -1
- package/dist/Label.main.js +2 -3
- package/dist/Label.main.js.map +1 -1
- package/dist/Label.mjs +2 -3
- package/dist/Label.module.js +2 -3
- package/dist/Label.module.js.map +1 -1
- package/dist/Link.main.js +2 -6
- package/dist/Link.main.js.map +1 -1
- package/dist/Link.mjs +2 -6
- package/dist/Link.module.js +2 -6
- package/dist/Link.module.js.map +1 -1
- package/dist/ListBox.main.js +23 -11
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +27 -15
- package/dist/ListBox.module.js +27 -15
- package/dist/ListBox.module.js.map +1 -1
- package/dist/Menu.main.js +56 -33
- package/dist/Menu.main.js.map +1 -1
- package/dist/Menu.mjs +58 -35
- package/dist/Menu.module.js +58 -35
- package/dist/Menu.module.js.map +1 -1
- package/dist/Meter.main.js +3 -6
- package/dist/Meter.main.js.map +1 -1
- package/dist/Meter.mjs +3 -6
- package/dist/Meter.module.js +3 -6
- package/dist/Meter.module.js.map +1 -1
- package/dist/Modal.main.js +7 -10
- package/dist/Modal.main.js.map +1 -1
- package/dist/Modal.mjs +10 -13
- package/dist/Modal.module.js +10 -13
- package/dist/Modal.module.js.map +1 -1
- package/dist/NumberField.main.js +6 -7
- package/dist/NumberField.main.js.map +1 -1
- package/dist/NumberField.mjs +7 -8
- package/dist/NumberField.module.js +7 -8
- package/dist/NumberField.module.js.map +1 -1
- package/dist/OverlayArrow.main.js +2 -6
- package/dist/OverlayArrow.main.js.map +1 -1
- package/dist/OverlayArrow.mjs +2 -6
- package/dist/OverlayArrow.module.js +2 -6
- package/dist/OverlayArrow.module.js.map +1 -1
- package/dist/Popover.main.js +71 -22
- package/dist/Popover.main.js.map +1 -1
- package/dist/Popover.mjs +75 -26
- package/dist/Popover.module.js +75 -26
- package/dist/Popover.module.js.map +1 -1
- package/dist/ProgressBar.main.js +3 -7
- package/dist/ProgressBar.main.js.map +1 -1
- package/dist/ProgressBar.mjs +3 -7
- package/dist/ProgressBar.module.js +3 -7
- package/dist/ProgressBar.module.js.map +1 -1
- package/dist/RadioGroup.main.js +5 -11
- package/dist/RadioGroup.main.js.map +1 -1
- package/dist/RadioGroup.mjs +5 -11
- package/dist/RadioGroup.module.js +5 -11
- package/dist/RadioGroup.module.js.map +1 -1
- package/dist/SearchField.main.js +9 -9
- package/dist/SearchField.main.js.map +1 -1
- package/dist/SearchField.mjs +11 -11
- package/dist/SearchField.module.js +11 -11
- package/dist/SearchField.module.js.map +1 -1
- package/dist/Select.main.js +9 -14
- package/dist/Select.main.js.map +1 -1
- package/dist/Select.mjs +10 -15
- package/dist/Select.module.js +10 -15
- package/dist/Select.module.js.map +1 -1
- package/dist/Slider.main.js +10 -22
- package/dist/Slider.main.js.map +1 -1
- package/dist/Slider.mjs +11 -23
- package/dist/Slider.module.js +11 -23
- package/dist/Slider.module.js.map +1 -1
- package/dist/Switch.main.js +2 -5
- package/dist/Switch.main.js.map +1 -1
- package/dist/Switch.mjs +2 -5
- package/dist/Switch.module.js +2 -5
- package/dist/Switch.module.js.map +1 -1
- package/dist/Table.main.js +21 -18
- package/dist/Table.main.js.map +1 -1
- package/dist/Table.mjs +22 -19
- package/dist/Table.module.js +22 -19
- package/dist/Table.module.js.map +1 -1
- package/dist/TableLayout.main.js.map +1 -1
- package/dist/TableLayout.module.js.map +1 -1
- package/dist/Tabs.main.js +12 -19
- package/dist/Tabs.main.js.map +1 -1
- package/dist/Tabs.mjs +15 -22
- package/dist/Tabs.module.js +15 -22
- package/dist/Tabs.module.js.map +1 -1
- package/dist/TagGroup.main.js +5 -11
- package/dist/TagGroup.main.js.map +1 -1
- package/dist/TagGroup.mjs +6 -12
- package/dist/TagGroup.module.js +6 -12
- package/dist/TagGroup.module.js.map +1 -1
- package/dist/Text.main.js +2 -3
- package/dist/Text.main.js.map +1 -1
- package/dist/Text.mjs +2 -3
- package/dist/Text.module.js +2 -3
- package/dist/Text.module.js.map +1 -1
- package/dist/TextArea.main.js +2 -5
- package/dist/TextArea.main.js.map +1 -1
- package/dist/TextArea.mjs +2 -5
- package/dist/TextArea.module.js +2 -5
- package/dist/TextArea.module.js.map +1 -1
- package/dist/TextField.main.js +12 -10
- package/dist/TextField.main.js.map +1 -1
- package/dist/TextField.mjs +14 -12
- package/dist/TextField.module.js +14 -12
- package/dist/TextField.module.js.map +1 -1
- package/dist/Toast.main.js +148 -0
- package/dist/Toast.main.js.map +1 -0
- package/dist/Toast.mjs +137 -0
- package/dist/Toast.module.js +137 -0
- package/dist/Toast.module.js.map +1 -0
- package/dist/ToggleButton.main.js +2 -5
- package/dist/ToggleButton.main.js.map +1 -1
- package/dist/ToggleButton.mjs +3 -6
- package/dist/ToggleButton.module.js +3 -6
- package/dist/ToggleButton.module.js.map +1 -1
- package/dist/ToggleButtonGroup.main.js +2 -5
- package/dist/ToggleButtonGroup.main.js.map +1 -1
- package/dist/ToggleButtonGroup.mjs +2 -5
- package/dist/ToggleButtonGroup.module.js +2 -5
- package/dist/ToggleButtonGroup.module.js.map +1 -1
- package/dist/Toolbar.main.js +2 -6
- package/dist/Toolbar.main.js.map +1 -1
- package/dist/Toolbar.mjs +2 -6
- package/dist/Toolbar.module.js +2 -6
- package/dist/Toolbar.module.js.map +1 -1
- package/dist/Tooltip.main.js +4 -7
- package/dist/Tooltip.main.js.map +1 -1
- package/dist/Tooltip.mjs +7 -10
- package/dist/Tooltip.module.js +7 -10
- package/dist/Tooltip.module.js.map +1 -1
- package/dist/Tree.main.js +39 -39
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +36 -36
- package/dist/Tree.module.js +36 -36
- package/dist/Tree.module.js.map +1 -1
- package/dist/Virtualizer.main.js +4 -1
- package/dist/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.mjs +4 -1
- package/dist/Virtualizer.module.js +4 -1
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/import.mjs +10 -6
- package/dist/main.js +34 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +10 -6
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +369 -259
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.main.js +9 -68
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +10 -67
- package/dist/utils.module.js +10 -67
- package/dist/utils.module.js.map +1 -1
- package/i18n/ar-AE.js +1 -1
- package/i18n/ar-AE.mjs +1 -1
- package/i18n/bg-BG.js +1 -1
- package/i18n/bg-BG.mjs +1 -1
- package/i18n/cs-CZ.js +1 -1
- package/i18n/cs-CZ.mjs +1 -1
- package/i18n/da-DK.js +1 -1
- package/i18n/da-DK.mjs +1 -1
- package/i18n/de-DE.js +1 -1
- package/i18n/de-DE.mjs +1 -1
- package/i18n/el-GR.js +1 -1
- package/i18n/el-GR.mjs +1 -1
- package/i18n/en-US.js +1 -1
- package/i18n/en-US.mjs +1 -1
- package/i18n/es-ES.js +1 -1
- package/i18n/es-ES.mjs +1 -1
- package/i18n/et-EE.js +1 -1
- package/i18n/et-EE.mjs +1 -1
- package/i18n/fi-FI.js +1 -1
- package/i18n/fi-FI.mjs +1 -1
- package/i18n/fr-FR.js +1 -1
- package/i18n/fr-FR.mjs +1 -1
- package/i18n/he-IL.js +1 -1
- package/i18n/he-IL.mjs +1 -1
- package/i18n/hr-HR.js +1 -1
- package/i18n/hr-HR.mjs +1 -1
- package/i18n/hu-HU.js +1 -1
- package/i18n/hu-HU.mjs +1 -1
- package/i18n/index.js +1 -1
- package/i18n/index.mjs +1 -1
- package/i18n/it-IT.js +1 -1
- package/i18n/it-IT.mjs +1 -1
- package/i18n/ja-JP.js +1 -1
- package/i18n/ja-JP.mjs +1 -1
- package/i18n/ko-KR.js +1 -1
- package/i18n/ko-KR.mjs +1 -1
- package/i18n/lt-LT.js +1 -1
- package/i18n/lt-LT.mjs +1 -1
- package/i18n/lv-LV.js +1 -1
- package/i18n/lv-LV.mjs +1 -1
- package/i18n/nb-NO.js +1 -1
- package/i18n/nb-NO.mjs +1 -1
- package/i18n/nl-NL.js +1 -1
- package/i18n/nl-NL.mjs +1 -1
- package/i18n/pl-PL.js +1 -1
- package/i18n/pl-PL.mjs +1 -1
- package/i18n/pt-BR.js +1 -1
- package/i18n/pt-BR.mjs +1 -1
- package/i18n/pt-PT.js +1 -1
- package/i18n/pt-PT.mjs +1 -1
- package/i18n/ro-RO.js +1 -1
- package/i18n/ro-RO.mjs +1 -1
- package/i18n/ru-RU.js +1 -1
- package/i18n/ru-RU.mjs +1 -1
- package/i18n/sk-SK.js +1 -1
- package/i18n/sk-SK.mjs +1 -1
- package/i18n/sl-SI.js +1 -1
- package/i18n/sl-SI.mjs +1 -1
- package/i18n/sr-SP.js +1 -1
- package/i18n/sr-SP.mjs +1 -1
- package/i18n/sv-SE.js +1 -1
- package/i18n/sv-SE.mjs +1 -1
- package/i18n/tr-TR.js +1 -1
- package/i18n/tr-TR.mjs +1 -1
- package/i18n/uk-UA.js +1 -1
- package/i18n/uk-UA.mjs +1 -1
- package/i18n/zh-CN.js +1 -1
- package/i18n/zh-CN.mjs +1 -1
- package/i18n/zh-TW.js +1 -1
- package/i18n/zh-TW.mjs +1 -1
- package/package.json +26 -29
- package/src/Autocomplete.tsx +75 -0
- package/src/Breadcrumbs.tsx +5 -8
- package/src/Button.tsx +8 -8
- package/src/Calendar.tsx +35 -39
- package/src/Checkbox.tsx +14 -18
- package/src/Collection.tsx +2 -2
- package/src/ColorArea.tsx +7 -11
- package/src/ColorField.tsx +13 -14
- package/src/ColorPicker.tsx +1 -2
- package/src/ColorSlider.tsx +10 -13
- package/src/ColorSwatch.tsx +7 -10
- package/src/ColorSwatchPicker.tsx +8 -14
- package/src/ColorThumb.tsx +7 -12
- package/src/ColorWheel.tsx +12 -18
- package/src/ComboBox.tsx +8 -9
- package/src/DateField.tsx +29 -36
- package/src/DatePicker.tsx +15 -17
- package/src/Dialog.tsx +11 -10
- package/src/Disclosure.tsx +18 -28
- package/src/DragAndDrop.tsx +5 -8
- package/src/DropZone.tsx +6 -10
- package/src/FieldError.tsx +5 -8
- package/src/FileTrigger.tsx +5 -8
- package/src/Form.tsx +6 -9
- package/src/GridList.tsx +11 -9
- package/src/Group.tsx +6 -8
- package/src/Heading.tsx +2 -5
- package/src/Input.tsx +5 -8
- package/src/Keyboard.tsx +2 -5
- package/src/Label.tsx +2 -5
- package/src/Link.tsx +6 -9
- package/src/ListBox.tsx +19 -16
- package/src/Menu.tsx +71 -42
- package/src/Meter.tsx +8 -9
- package/src/Modal.tsx +7 -10
- package/src/NumberField.tsx +16 -10
- package/src/OverlayArrow.tsx +6 -9
- package/src/Popover.tsx +84 -35
- package/src/ProgressBar.tsx +9 -10
- package/src/RadioGroup.tsx +13 -17
- package/src/SearchField.tsx +14 -14
- package/src/Select.tsx +17 -19
- package/src/Slider.tsx +26 -34
- package/src/Switch.tsx +5 -8
- package/src/Table.tsx +45 -34
- package/src/TableLayout.ts +1 -1
- package/src/Tabs.tsx +24 -28
- package/src/TagGroup.tsx +11 -15
- package/src/Text.tsx +2 -5
- package/src/TextArea.tsx +5 -7
- package/src/TextField.tsx +16 -16
- package/src/Toast.tsx +184 -0
- package/src/ToggleButton.tsx +5 -8
- package/src/ToggleButtonGroup.tsx +5 -8
- package/src/Toolbar.tsx +6 -9
- package/src/Tooltip.tsx +7 -10
- package/src/Tree.tsx +72 -57
- package/src/Virtualizer.tsx +18 -3
- package/src/index.ts +17 -15
- package/src/utils.tsx +8 -81
package/src/Table.tsx
CHANGED
|
@@ -41,8 +41,21 @@ class TableCollection<T> extends BaseCollection<T> implements ITableCollection<T
|
|
|
41
41
|
|
|
42
42
|
commit(firstKey: Key, lastKey: Key, isSSR = false) {
|
|
43
43
|
this.updateColumns(isSSR);
|
|
44
|
+
|
|
45
|
+
this.rows = [];
|
|
46
|
+
for (let row of this.getChildren(this.body.key)) {
|
|
47
|
+
let lastChildKey = (row as CollectionNode<T>).lastChildKey;
|
|
48
|
+
if (lastChildKey != null) {
|
|
49
|
+
let lastCell = this.getItem(lastChildKey) as GridNode<T>;
|
|
50
|
+
let numberOfCellsInRow = (lastCell.colIndex ?? lastCell.index) + (lastCell.colSpan ?? 1);
|
|
51
|
+
if (numberOfCellsInRow !== this.columns.length && !isSSR) {
|
|
52
|
+
throw new Error(`Cell count must match column count. Found ${numberOfCellsInRow} cells and ${this.columns.length} columns.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.rows.push(row);
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
super.commit(firstKey, lastKey, isSSR);
|
|
45
|
-
this.rows = [...this.getChildren(this.body.key)];
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
private updateColumns(isSSR: boolean) {
|
|
@@ -214,7 +227,7 @@ export interface ResizableTableContainerProps extends DOMProps, ScrollableProps<
|
|
|
214
227
|
onResizeEnd?: (widths: Map<Key, ColumnSize>) => void
|
|
215
228
|
}
|
|
216
229
|
|
|
217
|
-
function ResizableTableContainer(props: ResizableTableContainerProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
230
|
+
export const ResizableTableContainer = forwardRef(function ResizableTableContainer(props: ResizableTableContainerProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
218
231
|
let containerRef = useObjectRef(ref);
|
|
219
232
|
let tableRef = useRef<HTMLTableElement>(null);
|
|
220
233
|
let scrollRef = useRef<HTMLElement | null>(null);
|
|
@@ -267,10 +280,7 @@ function ResizableTableContainer(props: ResizableTableContainerProps, ref: Forwa
|
|
|
267
280
|
</ResizableTableContainerContext.Provider>
|
|
268
281
|
</div>
|
|
269
282
|
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const _ResizableTableContainer = forwardRef(ResizableTableContainer);
|
|
273
|
-
export {_ResizableTableContainer as ResizableTableContainer};
|
|
283
|
+
});
|
|
274
284
|
|
|
275
285
|
export const TableContext = createContext<ContextValue<TableProps, HTMLTableElement>>(null);
|
|
276
286
|
export const TableStateContext = createContext<TableState<any> | null>(null);
|
|
@@ -317,7 +327,11 @@ export interface TableProps extends Omit<SharedTableProps<any>, 'children'>, Sty
|
|
|
317
327
|
dragAndDropHooks?: DragAndDropHooks
|
|
318
328
|
}
|
|
319
329
|
|
|
320
|
-
|
|
330
|
+
/**
|
|
331
|
+
* A table displays data in rows and columns and enables a user to navigate its contents via directional navigation keys,
|
|
332
|
+
* and optionally supports row selection and sorting.
|
|
333
|
+
*/
|
|
334
|
+
export const Table = forwardRef(function Table(props: TableProps, ref: ForwardedRef<HTMLTableElement>) {
|
|
321
335
|
[props, ref] = useContextProps(props, ref, TableContext);
|
|
322
336
|
|
|
323
337
|
// Separate selection state so we have access to it from collection components via useTableOptions.
|
|
@@ -342,7 +356,7 @@ function Table(props: TableProps, ref: ForwardedRef<HTMLTableElement>) {
|
|
|
342
356
|
{collection => <TableInner props={props} forwardedRef={ref} selectionState={selectionState} collection={collection} />}
|
|
343
357
|
</CollectionBuilder>
|
|
344
358
|
);
|
|
345
|
-
}
|
|
359
|
+
});
|
|
346
360
|
|
|
347
361
|
interface TableInnerProps {
|
|
348
362
|
props: TableProps,
|
|
@@ -490,13 +504,6 @@ function TableInner({props, forwardedRef: ref, selectionState, collection}: Tabl
|
|
|
490
504
|
);
|
|
491
505
|
}
|
|
492
506
|
|
|
493
|
-
/**
|
|
494
|
-
* A table displays data in rows and columns and enables a user to navigate its contents via directional navigation keys,
|
|
495
|
-
* and optionally supports row selection and sorting.
|
|
496
|
-
*/
|
|
497
|
-
const _Table = forwardRef(Table);
|
|
498
|
-
export {_Table as Table};
|
|
499
|
-
|
|
500
507
|
function useElementType<E extends keyof JSX.IntrinsicElements>(element: E): E | 'div' {
|
|
501
508
|
let {isVirtualized} = useContext(CollectionRendererContext);
|
|
502
509
|
return isVirtualized ? 'div' : element;
|
|
@@ -532,11 +539,11 @@ export interface TableHeaderRenderProps {
|
|
|
532
539
|
|
|
533
540
|
export interface TableHeaderProps<T> extends StyleRenderProps<TableHeaderRenderProps>, HoverEvents {
|
|
534
541
|
/** A list of table columns. */
|
|
535
|
-
columns?: T
|
|
542
|
+
columns?: Iterable<T>,
|
|
536
543
|
/** A list of `Column(s)` or a function. If the latter, a list of columns must be provided using the `columns` prop. */
|
|
537
544
|
children?: ReactNode | ((item: T) => ReactElement),
|
|
538
545
|
/** Values that should invalidate the column cache when using dynamic collections. */
|
|
539
|
-
dependencies?: any
|
|
546
|
+
dependencies?: ReadonlyArray<any>
|
|
540
547
|
}
|
|
541
548
|
|
|
542
549
|
/**
|
|
@@ -743,7 +750,6 @@ export const Column = /*#__PURE__*/ createLeafComponent('column', (props: Column
|
|
|
743
750
|
{...mergeProps(filterDOMProps(props as any), columnHeaderProps, focusProps, hoverProps)}
|
|
744
751
|
{...renderProps}
|
|
745
752
|
style={style}
|
|
746
|
-
colSpan={column.colspan}
|
|
747
753
|
ref={ref}
|
|
748
754
|
data-hovered={isHovered || undefined}
|
|
749
755
|
data-focused={isFocused || undefined}
|
|
@@ -802,7 +808,7 @@ interface ColumnResizerContextValue {
|
|
|
802
808
|
|
|
803
809
|
const ColumnResizerContext = createContext<ColumnResizerContextValue | null>(null);
|
|
804
810
|
|
|
805
|
-
function ColumnResizer(props: ColumnResizerProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
811
|
+
export const ColumnResizer = forwardRef(function ColumnResizer(props: ColumnResizerProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
806
812
|
let layoutState = useContext(TableColumnResizeStateContext);
|
|
807
813
|
if (!layoutState) {
|
|
808
814
|
throw new Error('Wrap your <Table> in a <ResizableTableContainer> to enable column resizing');
|
|
@@ -891,10 +897,7 @@ function ColumnResizer(props: ColumnResizerProps, ref: ForwardedRef<HTMLDivEleme
|
|
|
891
897
|
{isResizing && isMouseDown && ReactDOM.createPortal(<div style={{position: 'fixed', top: 0, left: 0, bottom: 0, right: 0, cursor}} />, document.body)}
|
|
892
898
|
</div>
|
|
893
899
|
);
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
const _ColumnResizer = forwardRef(ColumnResizer);
|
|
897
|
-
export {_ColumnResizer as ColumnResizer};
|
|
900
|
+
});
|
|
898
901
|
|
|
899
902
|
export interface TableBodyRenderProps {
|
|
900
903
|
/**
|
|
@@ -985,12 +988,12 @@ export const TableBody = /*#__PURE__*/ createBranchComponent('tablebody', <T ext
|
|
|
985
988
|
|
|
986
989
|
export interface RowRenderProps extends ItemRenderProps {
|
|
987
990
|
/** Whether the row's children have keyboard focus. */
|
|
988
|
-
isFocusVisibleWithin: boolean
|
|
991
|
+
isFocusVisibleWithin: boolean,
|
|
992
|
+
/** The unique id of the row. */
|
|
993
|
+
id?: Key
|
|
989
994
|
}
|
|
990
995
|
|
|
991
996
|
export interface RowProps<T> extends StyleRenderProps<RowRenderProps>, LinkDOMProps, HoverEvents {
|
|
992
|
-
/** The unique id of the row. */
|
|
993
|
-
id?: Key,
|
|
994
997
|
/** A list of columns used when dynamically rendering cells. */
|
|
995
998
|
columns?: Iterable<T>,
|
|
996
999
|
/** The cells within the row. Supports static items or a function for dynamic rendering. */
|
|
@@ -998,7 +1001,7 @@ export interface RowProps<T> extends StyleRenderProps<RowRenderProps>, LinkDOMPr
|
|
|
998
1001
|
/** The object value that this row represents. When using dynamic collections, this is set automatically. */
|
|
999
1002
|
value?: T,
|
|
1000
1003
|
/** Values that should invalidate the cell cache when using dynamic collections. */
|
|
1001
|
-
dependencies?: any
|
|
1004
|
+
dependencies?: ReadonlyArray<any>,
|
|
1002
1005
|
/** A string representation of the row's contents, used for features like typeahead. */
|
|
1003
1006
|
textValue?: string,
|
|
1004
1007
|
/** Whether the row is disabled. */
|
|
@@ -1007,7 +1010,9 @@ export interface RowProps<T> extends StyleRenderProps<RowRenderProps>, LinkDOMPr
|
|
|
1007
1010
|
* Handler that is called when a user performs an action on the row. The exact user event depends on
|
|
1008
1011
|
* the collection's `selectionBehavior` prop and the interaction modality.
|
|
1009
1012
|
*/
|
|
1010
|
-
onAction?: () => void
|
|
1013
|
+
onAction?: () => void,
|
|
1014
|
+
/** The unique id of the row. */
|
|
1015
|
+
id?: Key
|
|
1011
1016
|
}
|
|
1012
1017
|
|
|
1013
1018
|
/**
|
|
@@ -1084,7 +1089,8 @@ export const Row = /*#__PURE__*/ createBranchComponent(
|
|
|
1084
1089
|
selectionBehavior: state.selectionManager.selectionBehavior,
|
|
1085
1090
|
isDragging,
|
|
1086
1091
|
isDropTarget: dropIndicator?.isDropTarget,
|
|
1087
|
-
isFocusVisibleWithin
|
|
1092
|
+
isFocusVisibleWithin,
|
|
1093
|
+
id: item.key
|
|
1088
1094
|
}
|
|
1089
1095
|
});
|
|
1090
1096
|
|
|
@@ -1175,14 +1181,18 @@ export interface CellRenderProps {
|
|
|
1175
1181
|
* Whether the cell is currently hovered with a mouse.
|
|
1176
1182
|
* @selector [data-hovered]
|
|
1177
1183
|
*/
|
|
1178
|
-
isHovered: boolean
|
|
1184
|
+
isHovered: boolean,
|
|
1185
|
+
/**
|
|
1186
|
+
* The unique id of the cell.
|
|
1187
|
+
**/
|
|
1188
|
+
id?: Key
|
|
1179
1189
|
}
|
|
1180
1190
|
|
|
1181
1191
|
export interface CellProps extends RenderProps<CellRenderProps> {
|
|
1182
|
-
/** The unique id of the cell. */
|
|
1183
|
-
id?: Key,
|
|
1184
1192
|
/** A string representation of the cell's contents, used for features like typeahead. */
|
|
1185
|
-
textValue?: string
|
|
1193
|
+
textValue?: string,
|
|
1194
|
+
/** Indicates how many columns the data cell spans. */
|
|
1195
|
+
colSpan?: number
|
|
1186
1196
|
}
|
|
1187
1197
|
|
|
1188
1198
|
/**
|
|
@@ -1212,7 +1222,8 @@ export const Cell = /*#__PURE__*/ createLeafComponent('cell', (props: CellProps,
|
|
|
1212
1222
|
isFocused,
|
|
1213
1223
|
isFocusVisible,
|
|
1214
1224
|
isPressed,
|
|
1215
|
-
isHovered
|
|
1225
|
+
isHovered,
|
|
1226
|
+
id: cell.key
|
|
1216
1227
|
}
|
|
1217
1228
|
});
|
|
1218
1229
|
|
package/src/TableLayout.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {LayoutOptionsDelegate} from './Virtualizer';
|
|
|
15
15
|
import {TableColumnResizeStateContext} from './Table';
|
|
16
16
|
import {useContext, useMemo} from 'react';
|
|
17
17
|
|
|
18
|
-
export class TableLayout<T> extends BaseTableLayout<T> implements LayoutOptionsDelegate<TableLayoutProps> {
|
|
18
|
+
export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> extends BaseTableLayout<T, O> implements LayoutOptionsDelegate<TableLayoutProps> {
|
|
19
19
|
// Invalidate the layout whenever the column widths change.
|
|
20
20
|
useLayoutOptions() {
|
|
21
21
|
// This is not a React class component, just a regular class.
|
package/src/Tabs.tsx
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
import {AriaLabelingProps, forwardRefType, HoverEvents, Key, LinkDOMProps, RefObject} from '@react-types/shared';
|
|
14
14
|
import {AriaTabListProps, AriaTabPanelProps, mergeProps, Orientation, useFocusRing, useHover, useTab, useTabList, useTabPanel} from 'react-aria';
|
|
15
15
|
import {Collection, CollectionBuilder, createHideableComponent, createLeafComponent} from '@react-aria/collections';
|
|
16
|
-
import {CollectionProps, CollectionRendererContext, usePersistedKeys} from './Collection';
|
|
16
|
+
import {CollectionProps, CollectionRendererContext, DefaultCollectionRenderer, usePersistedKeys} from './Collection';
|
|
17
17
|
import {ContextValue, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlottedContext} from './utils';
|
|
18
|
-
import {filterDOMProps, useObjectRef} from '@react-aria/utils';
|
|
18
|
+
import {filterDOMProps, inertValue, useObjectRef} from '@react-aria/utils';
|
|
19
19
|
import {Collection as ICollection, Node, TabListState, useTabListState} from 'react-stately';
|
|
20
20
|
import React, {createContext, ForwardedRef, forwardRef, JSX, useContext, useMemo} from 'react';
|
|
21
21
|
|
|
@@ -118,7 +118,10 @@ export interface TabPanelRenderProps {
|
|
|
118
118
|
export const TabsContext = createContext<ContextValue<TabsProps, HTMLDivElement>>(null);
|
|
119
119
|
export const TabListStateContext = createContext<TabListState<object> | null>(null);
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Tabs organize content into multiple sections and allow users to navigate between them.
|
|
123
|
+
*/
|
|
124
|
+
export const Tabs = /*#__PURE__*/ (forwardRef as forwardRefType)(function Tabs(props: TabsProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
122
125
|
[props, ref] = useContextProps(props, ref, TabsContext);
|
|
123
126
|
let {children, orientation = 'horizontal'} = props;
|
|
124
127
|
children = useMemo(() => (
|
|
@@ -132,7 +135,7 @@ function Tabs(props: TabsProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
132
135
|
{collection => <TabsInner props={props} collection={collection} tabsRef={ref} />}
|
|
133
136
|
</CollectionBuilder>
|
|
134
137
|
);
|
|
135
|
-
}
|
|
138
|
+
});
|
|
136
139
|
|
|
137
140
|
interface TabsInnerProps {
|
|
138
141
|
props: TabsProps,
|
|
@@ -182,17 +185,15 @@ function TabsInner({props, tabsRef: ref, collection}: TabsInnerProps) {
|
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
/**
|
|
185
|
-
*
|
|
188
|
+
* A TabList is used within Tabs to group tabs that a user can switch between.
|
|
189
|
+
* The ids of the items within the <TabList> must match up with a corresponding item inside the <TabPanels>.
|
|
186
190
|
*/
|
|
187
|
-
const
|
|
188
|
-
export {_Tabs as Tabs};
|
|
189
|
-
|
|
190
|
-
function TabList<T extends object>(props: TabListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {
|
|
191
|
+
export const TabList = /*#__PURE__*/ (forwardRef as forwardRefType)(function TabList<T extends object>(props: TabListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {
|
|
191
192
|
let state = useContext(TabListStateContext);
|
|
192
193
|
return state
|
|
193
194
|
? <TabListInner props={props} forwardedRef={ref} />
|
|
194
195
|
: <Collection {...props} />;
|
|
195
|
-
}
|
|
196
|
+
});
|
|
196
197
|
|
|
197
198
|
interface TabListInnerProps<T> {
|
|
198
199
|
props: TabListProps<T>,
|
|
@@ -236,13 +237,6 @@ function TabListInner<T extends object>({props, forwardedRef: ref}: TabListInner
|
|
|
236
237
|
);
|
|
237
238
|
}
|
|
238
239
|
|
|
239
|
-
/**
|
|
240
|
-
* A TabList is used within Tabs to group tabs that a user can switch between.
|
|
241
|
-
* The ids of the items within the <TabList> must match up with a corresponding item inside the <TabPanels>.
|
|
242
|
-
*/
|
|
243
|
-
const _TabList = /*#__PURE__*/ (forwardRef as forwardRefType)(TabList);
|
|
244
|
-
export {_TabList as TabList};
|
|
245
|
-
|
|
246
240
|
/**
|
|
247
241
|
* A Tab provides a title for an individual item within a TabList.
|
|
248
242
|
*/
|
|
@@ -261,6 +255,7 @@ export const Tab = /*#__PURE__*/ createLeafComponent('item', (props: TabProps, f
|
|
|
261
255
|
let renderProps = useRenderProps({
|
|
262
256
|
...props,
|
|
263
257
|
id: undefined,
|
|
258
|
+
children: item.rendered,
|
|
264
259
|
defaultClassName: 'react-aria-Tab',
|
|
265
260
|
values: {
|
|
266
261
|
isSelected,
|
|
@@ -283,11 +278,16 @@ export const Tab = /*#__PURE__*/ createLeafComponent('item', (props: TabProps, f
|
|
|
283
278
|
data-focused={isFocused || undefined}
|
|
284
279
|
data-focus-visible={isFocusVisible || undefined}
|
|
285
280
|
data-pressed={isPressed || undefined}
|
|
286
|
-
data-hovered={isHovered || undefined}
|
|
281
|
+
data-hovered={isHovered || undefined}>
|
|
282
|
+
{renderProps.children}
|
|
283
|
+
</ElementType>
|
|
287
284
|
);
|
|
288
285
|
});
|
|
289
286
|
|
|
290
|
-
|
|
287
|
+
/**
|
|
288
|
+
* A TabPanel provides the content for a tab.
|
|
289
|
+
*/
|
|
290
|
+
export const TabPanel = /*#__PURE__*/ createHideableComponent(function TabPanel(props: TabPanelProps, forwardedRef: ForwardedRef<HTMLDivElement>) {
|
|
291
291
|
const state = useContext(TabListStateContext)!;
|
|
292
292
|
let ref = useObjectRef<HTMLDivElement>(forwardedRef);
|
|
293
293
|
let {tabPanelProps} = useTabPanel(props, state, ref);
|
|
@@ -323,21 +323,17 @@ function TabPanel(props: TabPanelProps, forwardedRef: ForwardedRef<HTMLDivElemen
|
|
|
323
323
|
data-focused={isFocused || undefined}
|
|
324
324
|
data-focus-visible={isFocusVisible || undefined}
|
|
325
325
|
// @ts-ignore
|
|
326
|
-
inert={!isSelected
|
|
326
|
+
inert={inertValue(!isSelected)}
|
|
327
327
|
data-inert={!isSelected ? 'true' : undefined}>
|
|
328
328
|
<Provider
|
|
329
329
|
values={[
|
|
330
330
|
[TabsContext, null],
|
|
331
331
|
[TabListStateContext, null]
|
|
332
332
|
]}>
|
|
333
|
-
{
|
|
333
|
+
<CollectionRendererContext.Provider value={DefaultCollectionRenderer}>
|
|
334
|
+
{renderProps.children}
|
|
335
|
+
</CollectionRendererContext.Provider>
|
|
334
336
|
</Provider>
|
|
335
337
|
</div>
|
|
336
338
|
);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* A TabPanel provides the content for a tab.
|
|
341
|
-
*/
|
|
342
|
-
const _TabPanel = /*#__PURE__*/ createHideableComponent(TabPanel);
|
|
343
|
-
export {_TabPanel as TabPanel};
|
|
339
|
+
});
|
package/src/TagGroup.tsx
CHANGED
|
@@ -55,14 +55,17 @@ export interface TagListProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'
|
|
|
55
55
|
export const TagGroupContext = createContext<ContextValue<TagGroupProps, HTMLDivElement>>(null);
|
|
56
56
|
export const TagListContext = createContext<ContextValue<TagListProps<any>, HTMLDivElement>>(null);
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* A tag group is a focusable list of labels, categories, keywords, filters, or other items, with support for keyboard navigation, selection, and removal.
|
|
60
|
+
*/
|
|
61
|
+
export const TagGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagGroup(props: TagGroupProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
59
62
|
[props, ref] = useContextProps(props, ref, TagGroupContext);
|
|
60
63
|
return (
|
|
61
64
|
<CollectionBuilder content={props.children}>
|
|
62
65
|
{collection => <TagGroupInner props={props} forwardedRef={ref} collection={collection} />}
|
|
63
66
|
</CollectionBuilder>
|
|
64
67
|
);
|
|
65
|
-
}
|
|
68
|
+
});
|
|
66
69
|
|
|
67
70
|
interface TagGroupInnerProps {
|
|
68
71
|
props: TagGroupProps,
|
|
@@ -72,7 +75,9 @@ interface TagGroupInnerProps {
|
|
|
72
75
|
|
|
73
76
|
function TagGroupInner({props, forwardedRef: ref, collection}: TagGroupInnerProps) {
|
|
74
77
|
let tagListRef = useRef<HTMLDivElement>(null);
|
|
75
|
-
let [labelRef, label] = useSlot(
|
|
78
|
+
let [labelRef, label] = useSlot(
|
|
79
|
+
!props['aria-label'] && !props['aria-labelledby']
|
|
80
|
+
);
|
|
76
81
|
let state = useListState({
|
|
77
82
|
...props,
|
|
78
83
|
children: undefined,
|
|
@@ -119,17 +124,14 @@ function TagGroupInner({props, forwardedRef: ref, collection}: TagGroupInnerProp
|
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
/**
|
|
122
|
-
* A tag
|
|
127
|
+
* A tag list is a container for tags within a TagGroup.
|
|
123
128
|
*/
|
|
124
|
-
const
|
|
125
|
-
export {_TagGroup as TagGroup};
|
|
126
|
-
|
|
127
|
-
function TagList<T extends object>(props: TagListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {
|
|
129
|
+
export const TagList = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagList<T extends object>(props: TagListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {
|
|
128
130
|
let state = useContext(ListStateContext);
|
|
129
131
|
return state
|
|
130
132
|
? <TagListInner props={props} forwardedRef={ref} />
|
|
131
133
|
: <Collection {...props} />;
|
|
132
|
-
}
|
|
134
|
+
});
|
|
133
135
|
|
|
134
136
|
interface TagListInnerProps<T> {
|
|
135
137
|
props: TagListProps<T>,
|
|
@@ -174,12 +176,6 @@ function TagListInner<T extends object>({props, forwardedRef}: TagListInnerProps
|
|
|
174
176
|
);
|
|
175
177
|
}
|
|
176
178
|
|
|
177
|
-
/**
|
|
178
|
-
* A tag list is a container for tags within a TagGroup.
|
|
179
|
-
*/
|
|
180
|
-
const _TagList = /*#__PURE__*/ (forwardRef as forwardRefType)(TagList);
|
|
181
|
-
export {_TagList as TagList};
|
|
182
|
-
|
|
183
179
|
export interface TagRenderProps extends Omit<ItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'> {
|
|
184
180
|
/**
|
|
185
181
|
* Whether the tag group allows items to be removed.
|
package/src/Text.tsx
CHANGED
|
@@ -19,12 +19,9 @@ export interface TextProps extends HTMLAttributes<HTMLElement> {
|
|
|
19
19
|
|
|
20
20
|
export const TextContext = createContext<ContextValue<TextProps, HTMLElement>>({});
|
|
21
21
|
|
|
22
|
-
function Text(props: TextProps, ref: ForwardedRef<HTMLElement>) {
|
|
22
|
+
export const Text = forwardRef(function Text(props: TextProps, ref: ForwardedRef<HTMLElement>) {
|
|
23
23
|
[props, ref] = useContextProps(props, ref, TextContext);
|
|
24
24
|
let {elementType: ElementType = 'span', ...domProps} = props;
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
return <ElementType className="react-aria-Text" {...domProps} ref={ref} />;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const _Text = forwardRef(Text);
|
|
30
|
-
export {_Text as Text};
|
|
27
|
+
});
|
package/src/TextArea.tsx
CHANGED
|
@@ -13,7 +13,10 @@ let filterHoverProps = (props: TextAreaProps) => {
|
|
|
13
13
|
return otherProps;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* A textarea allows a user to input mult-line text.
|
|
18
|
+
*/
|
|
19
|
+
export const TextArea = forwardRef(function TextArea(props: TextAreaProps, ref: ForwardedRef<HTMLTextAreaElement>) {
|
|
17
20
|
[props, ref] = useContextProps(props, ref, TextAreaContext);
|
|
18
21
|
|
|
19
22
|
let {hoverProps, isHovered} = useHover(props);
|
|
@@ -46,9 +49,4 @@ function TextArea(props: TextAreaProps, ref: ForwardedRef<HTMLTextAreaElement>)
|
|
|
46
49
|
data-focus-visible={isFocusVisible || undefined}
|
|
47
50
|
data-invalid={isInvalid || undefined} />
|
|
48
51
|
);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* A textarea allows a user to input mult-line text.
|
|
52
|
-
*/
|
|
53
|
-
const _TextArea = forwardRef(TextArea);
|
|
54
|
-
export {_TextArea as TextArea};
|
|
52
|
+
});
|
package/src/TextField.tsx
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
import {AriaTextFieldProps, useTextField} from 'react-aria';
|
|
14
14
|
import {ContextValue, DOMProps, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';
|
|
15
|
+
import {createHideableComponent} from '@react-aria/collections';
|
|
15
16
|
import {FieldErrorContext} from './FieldError';
|
|
16
|
-
import {filterDOMProps} from '@react-aria/utils';
|
|
17
|
+
import {filterDOMProps, mergeProps} from '@react-aria/utils';
|
|
17
18
|
import {FormContext} from './Form';
|
|
18
|
-
import {forwardRefType} from '@react-types/shared';
|
|
19
19
|
import {InputContext} from './Input';
|
|
20
20
|
import {LabelContext} from './Label';
|
|
21
|
-
import React, {createContext, ForwardedRef,
|
|
21
|
+
import React, {createContext, ForwardedRef, useCallback, useRef, useState} from 'react';
|
|
22
22
|
import {TextAreaContext} from './TextArea';
|
|
23
23
|
import {TextContext} from './Text';
|
|
24
24
|
|
|
@@ -52,28 +52,34 @@ export interface TextFieldProps extends Omit<AriaTextFieldProps, 'label' | 'plac
|
|
|
52
52
|
|
|
53
53
|
export const TextFieldContext = createContext<ContextValue<TextFieldProps, HTMLDivElement>>(null);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* A text field allows a user to enter a plain text value with a keyboard.
|
|
57
|
+
*/
|
|
58
|
+
export const TextField = /*#__PURE__*/ createHideableComponent(function TextField(props: TextFieldProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
56
59
|
[props, ref] = useContextProps(props, ref, TextFieldContext);
|
|
57
60
|
let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};
|
|
58
61
|
let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';
|
|
59
62
|
let inputRef = useRef(null);
|
|
60
|
-
let [
|
|
63
|
+
let [inputContextProps, mergedInputRef] = useContextProps({}, inputRef, InputContext);
|
|
64
|
+
let [labelRef, label] = useSlot(
|
|
65
|
+
!props['aria-label'] && !props['aria-labelledby']
|
|
66
|
+
);
|
|
61
67
|
let [inputElementType, setInputElementType] = useState('input');
|
|
62
68
|
let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField<any>({
|
|
63
69
|
...removeDataAttributes(props),
|
|
64
70
|
inputElementType,
|
|
65
71
|
label,
|
|
66
72
|
validationBehavior
|
|
67
|
-
},
|
|
73
|
+
}, mergedInputRef);
|
|
68
74
|
|
|
69
75
|
// Intercept setting the input ref so we can determine what kind of element we have.
|
|
70
76
|
// useTextField uses this to determine what props to include.
|
|
71
77
|
let inputOrTextAreaRef = useCallback((el) => {
|
|
72
|
-
|
|
78
|
+
mergedInputRef.current = el;
|
|
73
79
|
if (el) {
|
|
74
80
|
setInputElementType(el instanceof HTMLTextAreaElement ? 'textarea' : 'input');
|
|
75
81
|
}
|
|
76
|
-
}, []);
|
|
82
|
+
}, [mergedInputRef]);
|
|
77
83
|
|
|
78
84
|
let renderProps = useRenderProps({
|
|
79
85
|
...props,
|
|
@@ -102,7 +108,7 @@ function TextField(props: TextFieldProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
102
108
|
<Provider
|
|
103
109
|
values={[
|
|
104
110
|
[LabelContext, {...labelProps, ref: labelRef}],
|
|
105
|
-
[InputContext, {...inputProps, ref: inputOrTextAreaRef}],
|
|
111
|
+
[InputContext, {...mergeProps(inputProps, inputContextProps), ref: inputOrTextAreaRef}],
|
|
106
112
|
[TextAreaContext, {...inputProps, ref: inputOrTextAreaRef}],
|
|
107
113
|
[TextContext, {
|
|
108
114
|
slots: {
|
|
@@ -116,10 +122,4 @@ function TextField(props: TextFieldProps, ref: ForwardedRef<HTMLDivElement>) {
|
|
|
116
122
|
</Provider>
|
|
117
123
|
</div>
|
|
118
124
|
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* A text field allows a user to enter a plain text value with a keyboard.
|
|
123
|
-
*/
|
|
124
|
-
const _TextField = /*#__PURE__*/ (forwardRef as forwardRefType)(TextField);
|
|
125
|
-
export {_TextField as TextField};
|
|
125
|
+
});
|