@cimpress-ui/react 0.0.1 → 0.2.1
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/LICENSE +201 -0
- package/README.md +5 -1
- package/dist/commonjs/components/breadcrumbs/breadcrumbs.d.ts +22 -0
- package/dist/commonjs/components/breadcrumbs/breadcrumbs.d.ts.map +1 -0
- package/dist/commonjs/components/breadcrumbs/breadcrumbs.js +37 -0
- package/dist/commonjs/components/breadcrumbs/breadcrumbs.js.map +1 -0
- package/dist/commonjs/components/button/button.d.ts +1 -1
- package/dist/commonjs/components/button/button.js +2 -2
- package/dist/commonjs/components/button/button.js.map +1 -1
- package/dist/commonjs/components/button/icon-button.d.ts +1 -1
- package/dist/commonjs/components/button/icon-button.js +2 -2
- package/dist/commonjs/components/button/icon-button.js.map +1 -1
- package/dist/commonjs/components/button/icon-link-button.d.ts +2 -2
- package/dist/commonjs/components/button/icon-link-button.d.ts.map +1 -1
- package/dist/commonjs/components/button/icon-link-button.js +1 -1
- package/dist/commonjs/components/button/icon-link-button.js.map +1 -1
- package/dist/commonjs/components/button/link-button.d.ts +2 -2
- package/dist/commonjs/components/button/link-button.d.ts.map +1 -1
- package/dist/commonjs/components/button/link-button.js +1 -1
- package/dist/commonjs/components/button/link-button.js.map +1 -1
- package/dist/commonjs/components/button/types.d.ts +1 -1
- package/dist/commonjs/components/button/types.d.ts.map +1 -1
- package/dist/commonjs/components/button/types.js.map +1 -1
- package/dist/commonjs/components/card/card-context.d.ts +4 -0
- package/dist/commonjs/components/card/card-context.d.ts.map +1 -0
- package/dist/commonjs/components/card/card-context.js +6 -0
- package/dist/commonjs/components/card/card-context.js.map +1 -0
- package/dist/commonjs/components/card/card.d.ts +15 -0
- package/dist/commonjs/components/card/card.d.ts.map +1 -0
- package/dist/commonjs/components/card/card.js +24 -0
- package/dist/commonjs/components/card/card.js.map +1 -0
- package/dist/commonjs/components/checkbox/checkbox-group.d.ts +1 -1
- package/dist/commonjs/components/checkbox/checkbox-group.js +1 -1
- package/dist/commonjs/components/checkbox/checkbox-group.js.map +1 -1
- package/dist/commonjs/components/checkbox/checkbox.d.ts +2 -2
- package/dist/commonjs/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/commonjs/components/checkbox/checkbox.js +1 -1
- package/dist/commonjs/components/checkbox/checkbox.js.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.d.ts +8 -4
- package/dist/commonjs/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.js +7 -7
- package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
- package/dist/commonjs/components/disclosure/disclosure-group.d.ts +10 -0
- package/dist/commonjs/components/disclosure/disclosure-group.d.ts.map +1 -0
- package/dist/commonjs/components/disclosure/disclosure-group.js +18 -0
- package/dist/commonjs/components/disclosure/disclosure-group.js.map +1 -0
- package/dist/commonjs/components/disclosure/disclosure.d.ts +14 -0
- package/dist/commonjs/components/disclosure/disclosure.d.ts.map +1 -0
- package/dist/commonjs/components/disclosure/disclosure.js +20 -0
- package/dist/commonjs/components/disclosure/disclosure.js.map +1 -0
- package/dist/commonjs/components/internal/collapsible-list/collapsible-list.d.ts +0 -14
- package/dist/commonjs/components/internal/collapsible-list/collapsible-list.d.ts.map +1 -1
- package/dist/commonjs/components/internal/collapsible-list/collapsible-list.js +2 -4
- package/dist/commonjs/components/internal/collapsible-list/collapsible-list.js.map +1 -1
- package/dist/commonjs/components/internal/form-field/form-field.d.ts +1 -28
- package/dist/commonjs/components/internal/form-field/form-field.d.ts.map +1 -1
- package/dist/commonjs/components/internal/form-field/form-field.js +10 -0
- package/dist/commonjs/components/internal/form-field/form-field.js.map +1 -1
- package/dist/commonjs/components/internal/spinner/spinner.d.ts +0 -16
- package/dist/commonjs/components/internal/spinner/spinner.d.ts.map +1 -1
- package/dist/commonjs/components/menu/menu.d.ts +5 -4
- package/dist/commonjs/components/menu/menu.d.ts.map +1 -1
- package/dist/commonjs/components/menu/menu.js +3 -3
- package/dist/commonjs/components/menu/menu.js.map +1 -1
- package/dist/commonjs/components/modal/modal.d.ts +19 -0
- package/dist/commonjs/components/modal/modal.d.ts.map +1 -0
- package/dist/commonjs/components/modal/modal.js +25 -0
- package/dist/commonjs/components/modal/modal.js.map +1 -0
- package/dist/commonjs/components/nav-tabs/nav-tabs.d.ts +23 -0
- package/dist/commonjs/components/nav-tabs/nav-tabs.d.ts.map +1 -0
- package/dist/commonjs/components/nav-tabs/nav-tabs.js +27 -0
- package/dist/commonjs/components/nav-tabs/nav-tabs.js.map +1 -0
- package/dist/commonjs/components/number-field/number-field.d.ts +10 -0
- package/dist/commonjs/components/number-field/number-field.d.ts.map +1 -0
- package/dist/commonjs/components/number-field/number-field.js +32 -0
- package/dist/commonjs/components/number-field/number-field.js.map +1 -0
- package/dist/commonjs/components/pagination/pagination.d.ts +14 -0
- package/dist/commonjs/components/pagination/pagination.d.ts.map +1 -0
- package/dist/commonjs/components/pagination/pagination.js +69 -0
- package/dist/commonjs/components/pagination/pagination.js.map +1 -0
- package/dist/commonjs/components/radio/radio-group.d.ts +1 -1
- package/dist/commonjs/components/radio/radio-group.js +1 -1
- package/dist/commonjs/components/radio/radio-group.js.map +1 -1
- package/dist/commonjs/components/radio/radio.d.ts +2 -2
- package/dist/commonjs/components/radio/radio.d.ts.map +1 -1
- package/dist/commonjs/components/radio/radio.js +1 -1
- package/dist/commonjs/components/radio/radio.js.map +1 -1
- package/dist/commonjs/components/select/select.d.ts +4 -4
- package/dist/commonjs/components/select/select.d.ts.map +1 -1
- package/dist/commonjs/components/select/select.js +3 -3
- package/dist/commonjs/components/select/select.js.map +1 -1
- package/dist/commonjs/components/spinner/spinner.d.ts +5 -1
- package/dist/commonjs/components/spinner/spinner.d.ts.map +1 -1
- package/dist/commonjs/components/spinner/spinner.js +5 -2
- package/dist/commonjs/components/spinner/spinner.js.map +1 -1
- package/dist/commonjs/components/table/contexts/focus.d.ts +13 -0
- package/dist/commonjs/components/table/contexts/focus.d.ts.map +1 -0
- package/dist/commonjs/components/table/contexts/focus.js +51 -0
- package/dist/commonjs/components/table/contexts/focus.js.map +1 -0
- package/dist/commonjs/components/table/contexts/row-state.d.ts +10 -0
- package/dist/commonjs/components/table/contexts/row-state.d.ts.map +1 -0
- package/dist/commonjs/components/table/contexts/row-state.js +22 -0
- package/dist/commonjs/components/table/contexts/row-state.js.map +1 -0
- package/dist/commonjs/components/table/hooks/use-table-cell.d.ts +7 -0
- package/dist/commonjs/components/table/hooks/use-table-cell.d.ts.map +1 -0
- package/dist/commonjs/components/table/hooks/use-table-cell.js +125 -0
- package/dist/commonjs/components/table/hooks/use-table-cell.js.map +1 -0
- package/dist/commonjs/components/table/hooks/use-table.d.ts +7 -0
- package/dist/commonjs/components/table/hooks/use-table.d.ts.map +1 -0
- package/dist/commonjs/components/table/hooks/use-table.js +142 -0
- package/dist/commonjs/components/table/hooks/use-table.js.map +1 -0
- package/dist/commonjs/components/table/table-body-cell.d.ts +26 -0
- package/dist/commonjs/components/table/table-body-cell.d.ts.map +1 -0
- package/dist/commonjs/components/table/table-body-cell.js +17 -0
- package/dist/commonjs/components/table/table-body-cell.js.map +1 -0
- package/dist/commonjs/components/table/table-body.d.ts +8 -0
- package/dist/commonjs/components/table/table-body.d.ts.map +1 -0
- package/dist/commonjs/components/table/table-body.js +11 -0
- package/dist/commonjs/components/table/table-body.js.map +1 -0
- package/dist/commonjs/components/table/table-container.d.ts +8 -0
- package/dist/commonjs/components/table/table-container.d.ts.map +1 -0
- package/dist/commonjs/components/table/table-container.js +40 -0
- package/dist/commonjs/components/table/table-container.js.map +1 -0
- package/dist/commonjs/components/table/table-header-cell.d.ts +26 -0
- package/dist/commonjs/components/table/table-header-cell.d.ts.map +1 -0
- package/dist/commonjs/components/table/table-header-cell.js +17 -0
- package/dist/commonjs/components/table/table-header-cell.js.map +1 -0
- package/dist/commonjs/components/table/table-header.d.ts +8 -0
- package/dist/commonjs/components/table/table-header.d.ts.map +1 -0
- package/dist/commonjs/components/table/table-header.js +11 -0
- package/dist/commonjs/components/table/table-header.js.map +1 -0
- package/dist/commonjs/components/table/table-row.d.ts +21 -0
- package/dist/commonjs/components/table/table-row.d.ts.map +1 -0
- package/dist/commonjs/components/table/table-row.js +14 -0
- package/dist/commonjs/components/table/table-row.js.map +1 -0
- package/dist/commonjs/components/table/table.d.ts +26 -0
- package/dist/commonjs/components/table/table.d.ts.map +1 -0
- package/dist/commonjs/components/table/table.js +27 -0
- package/dist/commonjs/components/table/table.js.map +1 -0
- package/dist/commonjs/components/table/utils/focus-table-child.d.ts +4 -0
- package/dist/commonjs/components/table/utils/focus-table-child.d.ts.map +1 -0
- package/dist/commonjs/components/table/utils/focus-table-child.js +14 -0
- package/dist/commonjs/components/table/utils/focus-table-child.js.map +1 -0
- package/dist/commonjs/components/tag/tag-group.d.ts +18 -0
- package/dist/commonjs/components/tag/tag-group.d.ts.map +1 -0
- package/dist/commonjs/components/tag/tag-group.js +27 -0
- package/dist/commonjs/components/tag/tag-group.js.map +1 -0
- package/dist/commonjs/components/tag/tag.d.ts +17 -0
- package/dist/commonjs/components/tag/tag.d.ts.map +1 -0
- package/dist/commonjs/components/tag/tag.js +20 -0
- package/dist/commonjs/components/tag/tag.js.map +1 -0
- package/dist/commonjs/components/text-inputs/text-area.d.ts +1 -1
- package/dist/commonjs/components/text-inputs/text-area.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-area.js +1 -1
- package/dist/commonjs/components/text-inputs/text-area.js.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.d.ts +2 -2
- package/dist/commonjs/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js +2 -2
- package/dist/commonjs/components/text-inputs/text-field.js.map +1 -1
- package/dist/commonjs/components/tooltip/tooltip.d.ts +9 -0
- package/dist/commonjs/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/commonjs/components/tooltip/tooltip.js +15 -0
- package/dist/commonjs/components/tooltip/tooltip.js.map +1 -0
- package/dist/commonjs/components/types.d.ts +32 -6
- package/dist/commonjs/components/types.d.ts.map +1 -1
- package/dist/commonjs/components/types.js.map +1 -1
- package/dist/commonjs/components/typography/link.d.ts +7 -3
- package/dist/commonjs/components/typography/link.d.ts.map +1 -1
- package/dist/commonjs/components/typography/link.js +8 -4
- package/dist/commonjs/components/typography/link.js.map +1 -1
- package/dist/commonjs/components/typography/text.d.ts +5 -1
- package/dist/commonjs/components/typography/text.d.ts.map +1 -1
- package/dist/commonjs/components/typography/text.js +5 -2
- package/dist/commonjs/components/typography/text.js.map +1 -1
- package/dist/commonjs/components/typography/types.d.ts +3 -2
- package/dist/commonjs/components/typography/types.d.ts.map +1 -1
- package/dist/commonjs/components/typography/types.js.map +1 -1
- package/dist/commonjs/components/typography/utils.d.ts.map +1 -1
- package/dist/commonjs/components/typography/utils.js +2 -2
- package/dist/commonjs/components/typography/utils.js.map +1 -1
- package/dist/commonjs/components/visually-hidden/visually-hidden.d.ts +17 -0
- package/dist/commonjs/components/visually-hidden/visually-hidden.d.ts.map +1 -0
- package/dist/commonjs/components/visually-hidden/visually-hidden.js +20 -0
- package/dist/commonjs/components/visually-hidden/visually-hidden.js.map +1 -0
- package/dist/commonjs/icons/accounting-document.d.ts +8 -0
- package/dist/commonjs/icons/accounting-document.d.ts.map +1 -0
- package/dist/commonjs/icons/accounting-document.js +24 -0
- package/dist/commonjs/icons/accounting-document.js.map +1 -0
- package/dist/commonjs/icons/add-circle-fill.d.ts +8 -0
- package/dist/commonjs/icons/add-circle-fill.d.ts.map +1 -0
- package/dist/commonjs/icons/add-circle-fill.js +24 -0
- package/dist/commonjs/icons/add-circle-fill.js.map +1 -0
- package/dist/commonjs/icons/add-circle.d.ts +8 -0
- package/dist/commonjs/icons/add-circle.d.ts.map +1 -0
- package/dist/commonjs/icons/add-circle.js +24 -0
- package/dist/commonjs/icons/add-circle.js.map +1 -0
- package/dist/commonjs/icons/add.d.ts +1 -1
- package/dist/commonjs/icons/add.d.ts.map +1 -1
- package/dist/commonjs/icons/add.js +6 -3
- package/dist/commonjs/icons/add.js.map +1 -1
- package/dist/commonjs/icons/alert-triangle.d.ts +1 -1
- package/dist/commonjs/icons/alert-triangle.d.ts.map +1 -1
- package/dist/commonjs/icons/alert-triangle.js +6 -3
- package/dist/commonjs/icons/alert-triangle.js.map +1 -1
- package/dist/commonjs/icons/calculator-alt.d.ts +8 -0
- package/dist/commonjs/icons/calculator-alt.d.ts.map +1 -0
- package/dist/commonjs/icons/calculator-alt.js +24 -0
- package/dist/commonjs/icons/calculator-alt.js.map +1 -0
- package/dist/commonjs/icons/calculator.d.ts +8 -0
- package/dist/commonjs/icons/calculator.d.ts.map +1 -0
- package/dist/commonjs/icons/calculator.js +24 -0
- package/dist/commonjs/icons/calculator.js.map +1 -0
- package/dist/commonjs/icons/checkmark-circle-fill.d.ts +1 -1
- package/dist/commonjs/icons/checkmark-circle-fill.d.ts.map +1 -1
- package/dist/commonjs/icons/checkmark-circle-fill.js +6 -3
- package/dist/commonjs/icons/checkmark-circle-fill.js.map +1 -1
- package/dist/commonjs/icons/checkmark-circle.d.ts +8 -0
- package/dist/commonjs/icons/checkmark-circle.d.ts.map +1 -0
- package/dist/commonjs/icons/checkmark-circle.js +24 -0
- package/dist/commonjs/icons/checkmark-circle.js.map +1 -0
- package/dist/commonjs/icons/checkmark-small.d.ts +1 -1
- package/dist/commonjs/icons/checkmark-small.d.ts.map +1 -1
- package/dist/commonjs/icons/checkmark-small.js +6 -3
- package/dist/commonjs/icons/checkmark-small.js.map +1 -1
- package/dist/commonjs/icons/checkmark.d.ts +1 -1
- package/dist/commonjs/icons/checkmark.d.ts.map +1 -1
- package/dist/commonjs/icons/checkmark.js +6 -3
- package/dist/commonjs/icons/checkmark.js.map +1 -1
- package/dist/commonjs/icons/chevron-down-fill.d.ts +1 -1
- package/dist/commonjs/icons/chevron-down-fill.d.ts.map +1 -1
- package/dist/commonjs/icons/chevron-down-fill.js +6 -3
- package/dist/commonjs/icons/chevron-down-fill.js.map +1 -1
- package/dist/commonjs/icons/error-circle-fill.d.ts +1 -1
- package/dist/commonjs/icons/error-circle-fill.d.ts.map +1 -1
- package/dist/commonjs/icons/error-circle-fill.js +6 -3
- package/dist/commonjs/icons/error-circle-fill.js.map +1 -1
- package/dist/commonjs/icons/index.d.ts +14 -0
- package/dist/commonjs/icons/index.d.ts.map +1 -1
- package/dist/commonjs/icons/index.js +29 -1
- package/dist/commonjs/icons/index.js.map +1 -1
- package/dist/commonjs/icons/info-circle-fill.d.ts +8 -0
- package/dist/commonjs/icons/info-circle-fill.d.ts.map +1 -0
- package/dist/commonjs/icons/info-circle-fill.js +24 -0
- package/dist/commonjs/icons/info-circle-fill.js.map +1 -0
- package/dist/commonjs/icons/minus-small.d.ts +1 -1
- package/dist/commonjs/icons/minus-small.d.ts.map +1 -1
- package/dist/commonjs/icons/minus-small.js +6 -3
- package/dist/commonjs/icons/minus-small.js.map +1 -1
- package/dist/commonjs/icons/minus.d.ts +8 -0
- package/dist/commonjs/icons/minus.d.ts.map +1 -0
- package/dist/commonjs/icons/minus.js +24 -0
- package/dist/commonjs/icons/minus.js.map +1 -0
- package/dist/commonjs/icons/unstable-chevron-left-fill.d.ts +8 -0
- package/dist/commonjs/icons/unstable-chevron-left-fill.d.ts.map +1 -0
- package/dist/commonjs/icons/unstable-chevron-left-fill.js +24 -0
- package/dist/commonjs/icons/unstable-chevron-left-fill.js.map +1 -0
- package/dist/commonjs/icons/unstable-chevron-right-fill.d.ts +8 -0
- package/dist/commonjs/icons/unstable-chevron-right-fill.d.ts.map +1 -0
- package/dist/commonjs/icons/unstable-chevron-right-fill.js +24 -0
- package/dist/commonjs/icons/unstable-chevron-right-fill.js.map +1 -0
- package/dist/commonjs/icons/unstable-close.d.ts +8 -0
- package/dist/commonjs/icons/unstable-close.d.ts.map +1 -0
- package/dist/commonjs/icons/unstable-close.js +24 -0
- package/dist/commonjs/icons/unstable-close.js.map +1 -0
- package/dist/commonjs/icons/unstable-info-circle.d.ts +8 -0
- package/dist/commonjs/icons/unstable-info-circle.d.ts.map +1 -0
- package/dist/commonjs/icons/unstable-info-circle.js +24 -0
- package/dist/commonjs/icons/unstable-info-circle.js.map +1 -0
- package/dist/commonjs/icons/unstable-placeholder.d.ts +8 -0
- package/dist/commonjs/icons/unstable-placeholder.d.ts.map +1 -0
- package/dist/commonjs/icons/unstable-placeholder.js +24 -0
- package/dist/commonjs/icons/unstable-placeholder.js.map +1 -0
- package/dist/commonjs/icons/warning-circle-fill.d.ts +8 -0
- package/dist/commonjs/icons/warning-circle-fill.d.ts.map +1 -0
- package/dist/commonjs/icons/warning-circle-fill.js +24 -0
- package/dist/commonjs/icons/warning-circle-fill.js.map +1 -0
- package/dist/commonjs/index.d.ts +21 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +19 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/utils/style/tone.d.ts +3 -0
- package/dist/commonjs/utils/style/tone.d.ts.map +1 -0
- package/dist/commonjs/utils/style/tone.js +7 -0
- package/dist/commonjs/utils/style/tone.js.map +1 -0
- package/dist/commonjs/utils/style/types.d.ts +2 -0
- package/dist/commonjs/utils/style/types.d.ts.map +1 -0
- package/dist/commonjs/utils/style/types.js +3 -0
- package/dist/commonjs/utils/style/types.js.map +1 -0
- package/dist/commonjs/with-style-props.d.ts +1 -1
- package/dist/commonjs/with-style-props.d.ts.map +1 -1
- package/dist/commonjs/with-style-props.js.map +1 -1
- package/dist/esm/components/breadcrumbs/breadcrumbs.d.ts +22 -0
- package/dist/esm/components/breadcrumbs/breadcrumbs.d.ts.map +1 -0
- package/dist/esm/components/breadcrumbs/breadcrumbs.js +30 -0
- package/dist/esm/components/breadcrumbs/breadcrumbs.js.map +1 -0
- package/dist/esm/components/button/button.d.ts +1 -1
- package/dist/esm/components/button/button.js +2 -2
- package/dist/esm/components/button/button.js.map +1 -1
- package/dist/esm/components/button/icon-button.d.ts +1 -1
- package/dist/esm/components/button/icon-button.js +2 -2
- package/dist/esm/components/button/icon-button.js.map +1 -1
- package/dist/esm/components/button/icon-link-button.d.ts +2 -2
- package/dist/esm/components/button/icon-link-button.d.ts.map +1 -1
- package/dist/esm/components/button/icon-link-button.js +1 -1
- package/dist/esm/components/button/icon-link-button.js.map +1 -1
- package/dist/esm/components/button/link-button.d.ts +2 -2
- package/dist/esm/components/button/link-button.d.ts.map +1 -1
- package/dist/esm/components/button/link-button.js +1 -1
- package/dist/esm/components/button/link-button.js.map +1 -1
- package/dist/esm/components/button/types.d.ts +1 -1
- package/dist/esm/components/button/types.d.ts.map +1 -1
- package/dist/esm/components/button/types.js.map +1 -1
- package/dist/esm/components/card/card-context.d.ts +4 -0
- package/dist/esm/components/card/card-context.d.ts.map +1 -0
- package/dist/esm/components/card/card-context.js +3 -0
- package/dist/esm/components/card/card-context.js.map +1 -0
- package/dist/esm/components/card/card.d.ts +15 -0
- package/dist/esm/components/card/card.d.ts.map +1 -0
- package/dist/esm/components/card/card.js +17 -0
- package/dist/esm/components/card/card.js.map +1 -0
- package/dist/esm/components/checkbox/checkbox-group.d.ts +1 -1
- package/dist/esm/components/checkbox/checkbox-group.js +1 -1
- package/dist/esm/components/checkbox/checkbox-group.js.map +1 -1
- package/dist/esm/components/checkbox/checkbox.d.ts +2 -2
- package/dist/esm/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/esm/components/checkbox/checkbox.js +1 -1
- package/dist/esm/components/checkbox/checkbox.js.map +1 -1
- package/dist/esm/components/combo-box/combo-box.d.ts +8 -4
- package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/esm/components/combo-box/combo-box.js +8 -8
- package/dist/esm/components/combo-box/combo-box.js.map +1 -1
- package/dist/esm/components/disclosure/disclosure-group.d.ts +10 -0
- package/dist/esm/components/disclosure/disclosure-group.d.ts.map +1 -0
- package/dist/esm/components/disclosure/disclosure-group.js +12 -0
- package/dist/esm/components/disclosure/disclosure-group.js.map +1 -0
- package/dist/esm/components/disclosure/disclosure.d.ts +14 -0
- package/dist/esm/components/disclosure/disclosure.d.ts.map +1 -0
- package/dist/esm/components/disclosure/disclosure.js +14 -0
- package/dist/esm/components/disclosure/disclosure.js.map +1 -0
- package/dist/esm/components/internal/collapsible-list/collapsible-list.d.ts +0 -14
- package/dist/esm/components/internal/collapsible-list/collapsible-list.d.ts.map +1 -1
- package/dist/esm/components/internal/collapsible-list/collapsible-list.js +2 -4
- package/dist/esm/components/internal/collapsible-list/collapsible-list.js.map +1 -1
- package/dist/esm/components/internal/form-field/form-field.d.ts +1 -28
- package/dist/esm/components/internal/form-field/form-field.d.ts.map +1 -1
- package/dist/esm/components/internal/form-field/form-field.js +10 -1
- package/dist/esm/components/internal/form-field/form-field.js.map +1 -1
- package/dist/esm/components/internal/spinner/spinner.d.ts +0 -16
- package/dist/esm/components/internal/spinner/spinner.d.ts.map +1 -1
- package/dist/esm/components/menu/menu.d.ts +5 -4
- package/dist/esm/components/menu/menu.d.ts.map +1 -1
- package/dist/esm/components/menu/menu.js +3 -3
- package/dist/esm/components/menu/menu.js.map +1 -1
- package/dist/esm/components/modal/modal.d.ts +19 -0
- package/dist/esm/components/modal/modal.d.ts.map +1 -0
- package/dist/esm/components/modal/modal.js +18 -0
- package/dist/esm/components/modal/modal.js.map +1 -0
- package/dist/esm/components/nav-tabs/nav-tabs.d.ts +23 -0
- package/dist/esm/components/nav-tabs/nav-tabs.d.ts.map +1 -0
- package/dist/esm/components/nav-tabs/nav-tabs.js +20 -0
- package/dist/esm/components/nav-tabs/nav-tabs.js.map +1 -0
- package/dist/esm/components/number-field/number-field.d.ts +10 -0
- package/dist/esm/components/number-field/number-field.d.ts.map +1 -0
- package/dist/esm/components/number-field/number-field.js +26 -0
- package/dist/esm/components/number-field/number-field.js.map +1 -0
- package/dist/esm/components/pagination/pagination.d.ts +14 -0
- package/dist/esm/components/pagination/pagination.d.ts.map +1 -0
- package/dist/esm/components/pagination/pagination.js +66 -0
- package/dist/esm/components/pagination/pagination.js.map +1 -0
- package/dist/esm/components/radio/radio-group.d.ts +1 -1
- package/dist/esm/components/radio/radio-group.js +1 -1
- package/dist/esm/components/radio/radio-group.js.map +1 -1
- package/dist/esm/components/radio/radio.d.ts +2 -2
- package/dist/esm/components/radio/radio.d.ts.map +1 -1
- package/dist/esm/components/radio/radio.js +1 -1
- package/dist/esm/components/radio/radio.js.map +1 -1
- package/dist/esm/components/select/select.d.ts +4 -4
- package/dist/esm/components/select/select.d.ts.map +1 -1
- package/dist/esm/components/select/select.js +3 -3
- package/dist/esm/components/select/select.js.map +1 -1
- package/dist/esm/components/spinner/spinner.d.ts +5 -1
- package/dist/esm/components/spinner/spinner.d.ts.map +1 -1
- package/dist/esm/components/spinner/spinner.js +5 -2
- package/dist/esm/components/spinner/spinner.js.map +1 -1
- package/dist/esm/components/table/contexts/focus.d.ts +13 -0
- package/dist/esm/components/table/contexts/focus.d.ts.map +1 -0
- package/dist/esm/components/table/contexts/focus.js +47 -0
- package/dist/esm/components/table/contexts/focus.js.map +1 -0
- package/dist/esm/components/table/contexts/row-state.d.ts +10 -0
- package/dist/esm/components/table/contexts/row-state.d.ts.map +1 -0
- package/dist/esm/components/table/contexts/row-state.js +18 -0
- package/dist/esm/components/table/contexts/row-state.js.map +1 -0
- package/dist/esm/components/table/hooks/use-table-cell.d.ts +7 -0
- package/dist/esm/components/table/hooks/use-table-cell.d.ts.map +1 -0
- package/dist/esm/components/table/hooks/use-table-cell.js +122 -0
- package/dist/esm/components/table/hooks/use-table-cell.js.map +1 -0
- package/dist/esm/components/table/hooks/use-table.d.ts +7 -0
- package/dist/esm/components/table/hooks/use-table.d.ts.map +1 -0
- package/dist/esm/components/table/hooks/use-table.js +139 -0
- package/dist/esm/components/table/hooks/use-table.js.map +1 -0
- package/dist/esm/components/table/table-body-cell.d.ts +26 -0
- package/dist/esm/components/table/table-body-cell.d.ts.map +1 -0
- package/dist/esm/components/table/table-body-cell.js +14 -0
- package/dist/esm/components/table/table-body-cell.js.map +1 -0
- package/dist/esm/components/table/table-body.d.ts +8 -0
- package/dist/esm/components/table/table-body.d.ts.map +1 -0
- package/dist/esm/components/table/table-body.js +8 -0
- package/dist/esm/components/table/table-body.js.map +1 -0
- package/dist/esm/components/table/table-container.d.ts +8 -0
- package/dist/esm/components/table/table-container.d.ts.map +1 -0
- package/dist/esm/components/table/table-container.js +34 -0
- package/dist/esm/components/table/table-container.js.map +1 -0
- package/dist/esm/components/table/table-header-cell.d.ts +26 -0
- package/dist/esm/components/table/table-header-cell.d.ts.map +1 -0
- package/dist/esm/components/table/table-header-cell.js +14 -0
- package/dist/esm/components/table/table-header-cell.js.map +1 -0
- package/dist/esm/components/table/table-header.d.ts +8 -0
- package/dist/esm/components/table/table-header.d.ts.map +1 -0
- package/dist/esm/components/table/table-header.js +8 -0
- package/dist/esm/components/table/table-header.js.map +1 -0
- package/dist/esm/components/table/table-row.d.ts +21 -0
- package/dist/esm/components/table/table-row.d.ts.map +1 -0
- package/dist/esm/components/table/table-row.js +11 -0
- package/dist/esm/components/table/table-row.js.map +1 -0
- package/dist/esm/components/table/table.d.ts +26 -0
- package/dist/esm/components/table/table.d.ts.map +1 -0
- package/dist/esm/components/table/table.js +24 -0
- package/dist/esm/components/table/table.js.map +1 -0
- package/dist/esm/components/table/utils/focus-table-child.d.ts +4 -0
- package/dist/esm/components/table/utils/focus-table-child.d.ts.map +1 -0
- package/dist/esm/components/table/utils/focus-table-child.js +11 -0
- package/dist/esm/components/table/utils/focus-table-child.js.map +1 -0
- package/dist/esm/components/tag/tag-group.d.ts +18 -0
- package/dist/esm/components/tag/tag-group.d.ts.map +1 -0
- package/dist/esm/components/tag/tag-group.js +21 -0
- package/dist/esm/components/tag/tag-group.js.map +1 -0
- package/dist/esm/components/tag/tag.d.ts +17 -0
- package/dist/esm/components/tag/tag.d.ts.map +1 -0
- package/dist/esm/components/tag/tag.js +14 -0
- package/dist/esm/components/tag/tag.js.map +1 -0
- package/dist/esm/components/text-inputs/text-area.d.ts +1 -1
- package/dist/esm/components/text-inputs/text-area.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-area.js +3 -3
- package/dist/esm/components/text-inputs/text-area.js.map +1 -1
- package/dist/esm/components/text-inputs/text-field.d.ts +2 -2
- package/dist/esm/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-field.js +4 -4
- package/dist/esm/components/text-inputs/text-field.js.map +1 -1
- package/dist/esm/components/tooltip/tooltip.d.ts +9 -0
- package/dist/esm/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/esm/components/tooltip/tooltip.js +9 -0
- package/dist/esm/components/tooltip/tooltip.js.map +1 -0
- package/dist/esm/components/types.d.ts +32 -6
- package/dist/esm/components/types.d.ts.map +1 -1
- package/dist/esm/components/types.js.map +1 -1
- package/dist/esm/components/typography/link.d.ts +7 -3
- package/dist/esm/components/typography/link.d.ts.map +1 -1
- package/dist/esm/components/typography/link.js +8 -4
- package/dist/esm/components/typography/link.js.map +1 -1
- package/dist/esm/components/typography/text.d.ts +5 -1
- package/dist/esm/components/typography/text.d.ts.map +1 -1
- package/dist/esm/components/typography/text.js +5 -2
- package/dist/esm/components/typography/text.js.map +1 -1
- package/dist/esm/components/typography/types.d.ts +3 -2
- package/dist/esm/components/typography/types.d.ts.map +1 -1
- package/dist/esm/components/typography/types.js.map +1 -1
- package/dist/esm/components/typography/utils.d.ts.map +1 -1
- package/dist/esm/components/typography/utils.js +2 -2
- package/dist/esm/components/typography/utils.js.map +1 -1
- package/dist/esm/components/visually-hidden/visually-hidden.d.ts +17 -0
- package/dist/esm/components/visually-hidden/visually-hidden.d.ts.map +1 -0
- package/dist/esm/components/visually-hidden/visually-hidden.js +14 -0
- package/dist/esm/components/visually-hidden/visually-hidden.js.map +1 -0
- package/dist/esm/icons/accounting-document.d.ts +8 -0
- package/dist/esm/icons/accounting-document.d.ts.map +1 -0
- package/dist/esm/icons/accounting-document.js +19 -0
- package/dist/esm/icons/accounting-document.js.map +1 -0
- package/dist/esm/icons/add-circle-fill.d.ts +8 -0
- package/dist/esm/icons/add-circle-fill.d.ts.map +1 -0
- package/dist/esm/icons/add-circle-fill.js +19 -0
- package/dist/esm/icons/add-circle-fill.js.map +1 -0
- package/dist/esm/icons/add-circle.d.ts +8 -0
- package/dist/esm/icons/add-circle.d.ts.map +1 -0
- package/dist/esm/icons/add-circle.js +19 -0
- package/dist/esm/icons/add-circle.js.map +1 -0
- package/dist/esm/icons/add.d.ts +1 -1
- package/dist/esm/icons/add.d.ts.map +1 -1
- package/dist/esm/icons/add.js +6 -3
- package/dist/esm/icons/add.js.map +1 -1
- package/dist/esm/icons/alert-triangle.d.ts +1 -1
- package/dist/esm/icons/alert-triangle.d.ts.map +1 -1
- package/dist/esm/icons/alert-triangle.js +6 -3
- package/dist/esm/icons/alert-triangle.js.map +1 -1
- package/dist/esm/icons/calculator-alt.d.ts +8 -0
- package/dist/esm/icons/calculator-alt.d.ts.map +1 -0
- package/dist/esm/icons/calculator-alt.js +19 -0
- package/dist/esm/icons/calculator-alt.js.map +1 -0
- package/dist/esm/icons/calculator.d.ts +8 -0
- package/dist/esm/icons/calculator.d.ts.map +1 -0
- package/dist/esm/icons/calculator.js +19 -0
- package/dist/esm/icons/calculator.js.map +1 -0
- package/dist/esm/icons/checkmark-circle-fill.d.ts +1 -1
- package/dist/esm/icons/checkmark-circle-fill.d.ts.map +1 -1
- package/dist/esm/icons/checkmark-circle-fill.js +6 -3
- package/dist/esm/icons/checkmark-circle-fill.js.map +1 -1
- package/dist/esm/icons/checkmark-circle.d.ts +8 -0
- package/dist/esm/icons/checkmark-circle.d.ts.map +1 -0
- package/dist/esm/icons/checkmark-circle.js +19 -0
- package/dist/esm/icons/checkmark-circle.js.map +1 -0
- package/dist/esm/icons/checkmark-small.d.ts +1 -1
- package/dist/esm/icons/checkmark-small.d.ts.map +1 -1
- package/dist/esm/icons/checkmark-small.js +6 -3
- package/dist/esm/icons/checkmark-small.js.map +1 -1
- package/dist/esm/icons/checkmark.d.ts +1 -1
- package/dist/esm/icons/checkmark.d.ts.map +1 -1
- package/dist/esm/icons/checkmark.js +6 -3
- package/dist/esm/icons/checkmark.js.map +1 -1
- package/dist/esm/icons/chevron-down-fill.d.ts +1 -1
- package/dist/esm/icons/chevron-down-fill.d.ts.map +1 -1
- package/dist/esm/icons/chevron-down-fill.js +6 -3
- package/dist/esm/icons/chevron-down-fill.js.map +1 -1
- package/dist/esm/icons/error-circle-fill.d.ts +1 -1
- package/dist/esm/icons/error-circle-fill.d.ts.map +1 -1
- package/dist/esm/icons/error-circle-fill.js +7 -4
- package/dist/esm/icons/error-circle-fill.js.map +1 -1
- package/dist/esm/icons/index.d.ts +14 -0
- package/dist/esm/icons/index.d.ts.map +1 -1
- package/dist/esm/icons/index.js +14 -0
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/icons/info-circle-fill.d.ts +8 -0
- package/dist/esm/icons/info-circle-fill.d.ts.map +1 -0
- package/dist/esm/icons/info-circle-fill.js +19 -0
- package/dist/esm/icons/info-circle-fill.js.map +1 -0
- package/dist/esm/icons/minus-small.d.ts +1 -1
- package/dist/esm/icons/minus-small.d.ts.map +1 -1
- package/dist/esm/icons/minus-small.js +6 -3
- package/dist/esm/icons/minus-small.js.map +1 -1
- package/dist/esm/icons/minus.d.ts +8 -0
- package/dist/esm/icons/minus.d.ts.map +1 -0
- package/dist/esm/icons/minus.js +19 -0
- package/dist/esm/icons/minus.js.map +1 -0
- package/dist/esm/icons/unstable-chevron-left-fill.d.ts +8 -0
- package/dist/esm/icons/unstable-chevron-left-fill.d.ts.map +1 -0
- package/dist/esm/icons/unstable-chevron-left-fill.js +19 -0
- package/dist/esm/icons/unstable-chevron-left-fill.js.map +1 -0
- package/dist/esm/icons/unstable-chevron-right-fill.d.ts +8 -0
- package/dist/esm/icons/unstable-chevron-right-fill.d.ts.map +1 -0
- package/dist/esm/icons/unstable-chevron-right-fill.js +19 -0
- package/dist/esm/icons/unstable-chevron-right-fill.js.map +1 -0
- package/dist/esm/icons/unstable-close.d.ts +8 -0
- package/dist/esm/icons/unstable-close.d.ts.map +1 -0
- package/dist/esm/icons/unstable-close.js +19 -0
- package/dist/esm/icons/unstable-close.js.map +1 -0
- package/dist/esm/icons/unstable-info-circle.d.ts +8 -0
- package/dist/esm/icons/unstable-info-circle.d.ts.map +1 -0
- package/dist/esm/icons/unstable-info-circle.js +19 -0
- package/dist/esm/icons/unstable-info-circle.js.map +1 -0
- package/dist/esm/icons/unstable-placeholder.d.ts +8 -0
- package/dist/esm/icons/unstable-placeholder.d.ts.map +1 -0
- package/dist/esm/icons/unstable-placeholder.js +19 -0
- package/dist/esm/icons/unstable-placeholder.js.map +1 -0
- package/dist/esm/icons/warning-circle-fill.d.ts +8 -0
- package/dist/esm/icons/warning-circle-fill.d.ts.map +1 -0
- package/dist/esm/icons/warning-circle-fill.js +19 -0
- package/dist/esm/icons/warning-circle-fill.js.map +1 -0
- package/dist/esm/index.d.ts +21 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +19 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/style/tone.d.ts +3 -0
- package/dist/esm/utils/style/tone.d.ts.map +1 -0
- package/dist/esm/utils/style/tone.js +4 -0
- package/dist/esm/utils/style/tone.js.map +1 -0
- package/dist/esm/utils/style/types.d.ts +2 -0
- package/dist/esm/utils/style/types.d.ts.map +1 -0
- package/dist/esm/utils/style/types.js +2 -0
- package/dist/esm/utils/style/types.js.map +1 -0
- package/dist/esm/with-style-props.d.ts +1 -1
- package/dist/esm/with-style-props.d.ts.map +1 -1
- package/dist/esm/with-style-props.js.map +1 -1
- package/dist-styles/styles.css +1 -1
- package/package.json +28 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../../src/components/spinner/spinner.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIhE,MAAM,WAAW,YAAa,SAAQ,WAAW,EAAE,eAAe;IAChE;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../../src/components/spinner/spinner.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIhE,MAAM,WAAW,YAAa,SAAQ,WAAW,EAAE,eAAe;IAChE;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AA8BD;;;;GAIG;AACH,QAAA,MAAM,QAAQ,8JAAiD,CAAC;AAEhE,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -28,8 +28,11 @@ function Spinner({ size = 'medium', label, ...props }, ref) {
|
|
|
28
28
|
}, [label, ariaLabel, ariaLabelledBy]);
|
|
29
29
|
return ((0, jsx_runtime_1.jsx)(spinner_js_1.InternalSpinner, { ...props, size: ringSizes[size], spinnerRef: ref, children: label && (0, jsx_runtime_1.jsx)(react_aria_components_1.Label, { className: (0, utils_js_1.textStyle)({ variant: labelVariants[size], tone: 'title' }), children: label }) }));
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Displays a loading indicator to represent an ongoing operation.
|
|
33
|
+
*
|
|
34
|
+
* See [spinner usage guidelines](https://ui.cimpress.io/components/spinner/).
|
|
35
|
+
*/
|
|
33
36
|
const _Spinner = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(Spinner), 'Spinner');
|
|
34
37
|
exports.Spinner = _Spinner;
|
|
35
38
|
//# sourceMappingURL=spinner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../../../src/components/spinner/spinner.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AA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;AAGjE,qDAAmD;AAUnD,MAAM,SAAS,GAAsD;IACnE,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,MAAM;CACd,CAAC;AAEF,MAAM,aAAa,GAA2E;IAC5F,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,MAAM;CACd,CAAC;AAEF,SAAS,OAAO,CAAC,EAAE,IAAI,GAAG,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAgB,EAAE,GAAiC;IACpG,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAE7E,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;QACjG,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAEvC,OAAO,CACL,uBAAC,4BAAe,OAAK,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,YAC/D,KAAK,IAAI,uBAAC,6BAAQ,IAAC,SAAS,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,YAAG,KAAK,GAAY,GAC7F,CACnB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,QAAQ,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;AAE3C,2BAAO","sourcesContent":["'use client';\n\nimport { useEffect, type ForwardedRef } from 'react';\nimport { Label as RACLabel } from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { InternalSpinner } from '../internal/spinner/spinner.js';\nimport type { CommonProps, LabellableProps } from '../types.js';\nimport type { TextStyleOptions } from '../typography/types.js';\nimport { textStyle } from '../typography/utils.js';\n\nexport interface SpinnerProps extends CommonProps, LabellableProps {\n /**\n * Determines the size of the spinner.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n}\n\nconst ringSizes: Record<NonNullable<SpinnerProps['size']>, string> = {\n small: '24px',\n medium: '48px',\n large: '80px',\n};\n\nconst labelVariants: Record<NonNullable<SpinnerProps['size']>, TextStyleOptions['variant']> = {\n small: 'small',\n medium: 'medium',\n large: 'body',\n};\n\nfunction Spinner({ size = 'medium', label, ...props }: SpinnerProps, ref: ForwardedRef<HTMLDivElement>) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useEffect(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('Spinner requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n return (\n <InternalSpinner {...props} size={ringSizes[size]} spinnerRef={ref}>\n {label && <RACLabel className={textStyle({ variant: labelVariants[size], tone: 'title' })}>{label}</RACLabel>}\n </InternalSpinner>\n );\n}\n\n/**\n * Displays a loading indicator to represent an ongoing operation.\n *\n * See [spinner usage guidelines](https://ui.cimpress.io/components/spinner/).\n */\nconst _Spinner = withStyleProps(forwardRef(Spinner), 'Spinner');\n\nexport { _Spinner as Spinner };\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface TableFocus {
|
|
3
|
+
focusedRowKey: string;
|
|
4
|
+
focusedColumnKey: string;
|
|
5
|
+
childFocusStrategy: ChildFocusStrategy;
|
|
6
|
+
setFocus: (rowKey: string, columnKey: string, childFocusStrategy?: ChildFocusStrategy) => void;
|
|
7
|
+
}
|
|
8
|
+
export type ChildFocusStrategy = 'first' | 'last';
|
|
9
|
+
export declare function TableFocusProvider({ children }: {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function useTableFocus(): TableFocus;
|
|
13
|
+
//# sourceMappingURL=focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../../../../src/components/table/contexts/focus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAyC,MAAM,OAAO,CAAC;AAE7F,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAChG;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAC;AAIlD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAwCvE;AAGD,wBAAgB,aAAa,IAAI,UAAU,CAO1C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableFocusProvider = TableFocusProvider;
|
|
4
|
+
exports.useTableFocus = useTableFocus;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const TableFocusContext = (0, react_1.createContext)(null);
|
|
8
|
+
function TableFocusProvider({ children }) {
|
|
9
|
+
// When table focus is updated, we want to trigger a re-render,
|
|
10
|
+
// but we also want immediate access to the new values.
|
|
11
|
+
// Hence why they are stored as both a ref and a state.
|
|
12
|
+
const focusedRowKeyRef = (0, react_1.useRef)('');
|
|
13
|
+
const [_focusedRowKey, setFocusedRowKey] = (0, react_1.useState)('');
|
|
14
|
+
const focusedColumnKeyRef = (0, react_1.useRef)('');
|
|
15
|
+
const [_focusedColumnKey, setFocusedColumnKey] = (0, react_1.useState)('');
|
|
16
|
+
const childFocusStrategyRef = (0, react_1.useRef)('first');
|
|
17
|
+
const [_childFocusStrategy, setChildFocusStrategy] = (0, react_1.useState)('first');
|
|
18
|
+
const tableFocus = (0, react_1.useMemo)(() => ({
|
|
19
|
+
get focusedRowKey() {
|
|
20
|
+
return focusedRowKeyRef.current;
|
|
21
|
+
},
|
|
22
|
+
get focusedColumnKey() {
|
|
23
|
+
return focusedColumnKeyRef.current;
|
|
24
|
+
},
|
|
25
|
+
get childFocusStrategy() {
|
|
26
|
+
return childFocusStrategyRef.current;
|
|
27
|
+
},
|
|
28
|
+
setFocus: (rowKey, columnKey, childFocusStrategy) => {
|
|
29
|
+
focusedRowKeyRef.current = rowKey;
|
|
30
|
+
setFocusedRowKey(rowKey);
|
|
31
|
+
focusedColumnKeyRef.current = columnKey;
|
|
32
|
+
setFocusedColumnKey(columnKey);
|
|
33
|
+
if (childFocusStrategy) {
|
|
34
|
+
childFocusStrategyRef.current = childFocusStrategy;
|
|
35
|
+
setChildFocusStrategy(childFocusStrategy);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
[_focusedRowKey, _focusedColumnKey, _childFocusStrategy]);
|
|
41
|
+
return (0, jsx_runtime_1.jsx)(TableFocusContext.Provider, { value: tableFocus, children: children });
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
44
|
+
function useTableFocus() {
|
|
45
|
+
const tableFocus = (0, react_1.useContext)(TableFocusContext);
|
|
46
|
+
if (!tableFocus) {
|
|
47
|
+
throw new Error('Cannot use table focus outside of a table');
|
|
48
|
+
}
|
|
49
|
+
return tableFocus;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.js","sourceRoot":"","sources":["../../../../../src/components/table/contexts/focus.tsx"],"names":[],"mappings":";;AAaA,gDAwCC;AAGD,sCAOC;;AA/DD,iCAA6F;AAW7F,MAAM,iBAAiB,GAAG,IAAA,qBAAa,EAAoB,IAAI,CAAC,CAAC;AAEjE,SAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAA2B;IACtE,+DAA+D;IAC/D,uDAAuD;IACvD,uDAAuD;IACvD,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAS,EAAE,CAAC,CAAC;IAC5C,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IAChE,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAAS,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACtE,MAAM,qBAAqB,GAAG,IAAA,cAAM,EAAqB,OAAO,CAAC,CAAC;IAClE,MAAM,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,GAAG,IAAA,gBAAQ,EAAqB,OAAO,CAAC,CAAC;IAE3F,MAAM,UAAU,GAAe,IAAA,eAAO,EACpC,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,aAAa;YACf,OAAO,gBAAgB,CAAC,OAAO,CAAC;QAClC,CAAC;QACD,IAAI,gBAAgB;YAClB,OAAO,mBAAmB,CAAC,OAAO,CAAC;QACrC,CAAC;QACD,IAAI,kBAAkB;YACpB,OAAO,qBAAqB,CAAC,OAAO,CAAC;QACvC,CAAC;QACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE;YAClD,gBAAgB,CAAC,OAAO,GAAG,MAAM,CAAC;YAClC,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAEzB,mBAAmB,CAAC,OAAO,GAAG,SAAS,CAAC;YACxC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAE/B,IAAI,kBAAkB,EAAE,CAAC;gBACvB,qBAAqB,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBACnD,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;KACF,CAAC;IACF,uDAAuD;IACvD,CAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CACzD,CAAC;IAEF,OAAO,uBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,YAAG,QAAQ,GAA8B,CAAC;AAChG,CAAC;AAED,gEAAgE;AAChE,SAAgB,aAAa;IAC3B,MAAM,UAAU,GAAG,IAAA,kBAAU,EAAC,iBAAiB,CAAC,CAAC;IACjD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import { createContext, type ReactNode, useContext, useMemo, useRef, useState } from 'react';\n\nexport interface TableFocus {\n focusedRowKey: string;\n focusedColumnKey: string;\n childFocusStrategy: ChildFocusStrategy;\n setFocus: (rowKey: string, columnKey: string, childFocusStrategy?: ChildFocusStrategy) => void;\n}\n\nexport type ChildFocusStrategy = 'first' | 'last';\n\nconst TableFocusContext = createContext<TableFocus | null>(null);\n\nexport function TableFocusProvider({ children }: { children: ReactNode }) {\n // When table focus is updated, we want to trigger a re-render,\n // but we also want immediate access to the new values.\n // Hence why they are stored as both a ref and a state.\n const focusedRowKeyRef = useRef<string>('');\n const [_focusedRowKey, setFocusedRowKey] = useState<string>('');\n const focusedColumnKeyRef = useRef<string>('');\n const [_focusedColumnKey, setFocusedColumnKey] = useState<string>('');\n const childFocusStrategyRef = useRef<ChildFocusStrategy>('first');\n const [_childFocusStrategy, setChildFocusStrategy] = useState<ChildFocusStrategy>('first');\n\n const tableFocus: TableFocus = useMemo(\n () => ({\n get focusedRowKey() {\n return focusedRowKeyRef.current;\n },\n get focusedColumnKey() {\n return focusedColumnKeyRef.current;\n },\n get childFocusStrategy() {\n return childFocusStrategyRef.current;\n },\n setFocus: (rowKey, columnKey, childFocusStrategy) => {\n focusedRowKeyRef.current = rowKey;\n setFocusedRowKey(rowKey);\n\n focusedColumnKeyRef.current = columnKey;\n setFocusedColumnKey(columnKey);\n\n if (childFocusStrategy) {\n childFocusStrategyRef.current = childFocusStrategy;\n setChildFocusStrategy(childFocusStrategy);\n }\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [_focusedRowKey, _focusedColumnKey, _childFocusStrategy],\n );\n\n return <TableFocusContext.Provider value={tableFocus}>{children}</TableFocusContext.Provider>;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport function useTableFocus(): TableFocus {\n const tableFocus = useContext(TableFocusContext);\n if (!tableFocus) {\n throw new Error('Cannot use table focus outside of a table');\n }\n\n return tableFocus;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface TableRowState {
|
|
3
|
+
rowKey: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function TableRowStateProvider({ children, rowKey }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
rowKey: string;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function useTableRowState(): TableRowState;
|
|
10
|
+
//# sourceMappingURL=row-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-state.d.ts","sourceRoot":"","sources":["../../../../../src/components/table/contexts/row-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAE3E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,wBAAgB,qBAAqB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,2CASlG;AAGD,wBAAgB,gBAAgB,IAAI,aAAa,CAOhD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableRowStateProvider = TableRowStateProvider;
|
|
4
|
+
exports.useTableRowState = useTableRowState;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const TableRowStateContext = (0, react_1.createContext)(null);
|
|
8
|
+
function TableRowStateProvider({ children, rowKey }) {
|
|
9
|
+
const tableRowState = (0, react_1.useMemo)(() => ({
|
|
10
|
+
rowKey,
|
|
11
|
+
}), [rowKey]);
|
|
12
|
+
return (0, jsx_runtime_1.jsx)(TableRowStateContext.Provider, { value: tableRowState, children: children });
|
|
13
|
+
}
|
|
14
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
15
|
+
function useTableRowState() {
|
|
16
|
+
const tableRowState = (0, react_1.useContext)(TableRowStateContext);
|
|
17
|
+
if (!tableRowState) {
|
|
18
|
+
throw new Error('Cannot use table row state outside of a table row');
|
|
19
|
+
}
|
|
20
|
+
return tableRowState;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=row-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-state.js","sourceRoot":"","sources":["../../../../../src/components/table/contexts/row-state.tsx"],"names":[],"mappings":";;AAQA,sDASC;AAGD,4CAOC;;AA3BD,iCAA2E;AAM3E,MAAM,oBAAoB,GAAG,IAAA,qBAAa,EAAuB,IAAI,CAAC,CAAC;AAEvE,SAAgB,qBAAqB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAA2C;IACjG,MAAM,aAAa,GAAkB,IAAA,eAAO,EAC1C,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;KACP,CAAC,EACF,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,uBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAAG,QAAQ,GAAiC,CAAC;AACzG,CAAC;AAED,gEAAgE;AAChE,SAAgB,gBAAgB;IAC9B,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,oBAAoB,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { createContext, type ReactNode, useContext, useMemo } from 'react';\n\nexport interface TableRowState {\n rowKey: string;\n}\n\nconst TableRowStateContext = createContext<TableRowState | null>(null);\n\nexport function TableRowStateProvider({ children, rowKey }: { children: ReactNode; rowKey: string }) {\n const tableRowState: TableRowState = useMemo(\n () => ({\n rowKey,\n }),\n [rowKey],\n );\n\n return <TableRowStateContext.Provider value={tableRowState}>{children}</TableRowStateContext.Provider>;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport function useTableRowState(): TableRowState {\n const tableRowState = useContext(TableRowStateContext);\n if (!tableRowState) {\n throw new Error('Cannot use table row state outside of a table row');\n }\n\n return tableRowState;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { NativeElementProps } from '../../types.js';
|
|
3
|
+
export interface UseTableCell {
|
|
4
|
+
cellProps: NativeElementProps<HTMLTableCellElement>;
|
|
5
|
+
}
|
|
6
|
+
export declare function useTableCell(ref: RefObject<HTMLTableCellElement>, rowKey: string, columnKey: string): UseTableCell;
|
|
7
|
+
//# sourceMappingURL=use-table-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-table-cell.d.ts","sourceRoot":"","sources":["../../../../../src/components/table/hooks/use-table-cell.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3G,OAAO,KAAK,EAAoB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAI3E,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;CACrD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY,CA6HlH"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTableCell = useTableCell;
|
|
4
|
+
const focus_1 = require("@react-aria/focus");
|
|
5
|
+
const interactions_1 = require("@react-aria/interactions");
|
|
6
|
+
const utils_1 = require("@react-aria/utils");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const focus_js_1 = require("../contexts/focus.js");
|
|
9
|
+
const focus_table_child_js_1 = require("../utils/focus-table-child.js");
|
|
10
|
+
function useTableCell(ref, rowKey, columnKey) {
|
|
11
|
+
const tableFocus = (0, focus_js_1.useTableFocus)();
|
|
12
|
+
const isTabbable = rowKey === tableFocus.focusedRowKey && columnKey === tableFocus.focusedColumnKey;
|
|
13
|
+
// Handles focusing the cell.
|
|
14
|
+
// If there is a focusable child, it is focused, otherwise the cell itself is focused.
|
|
15
|
+
const focusCell = () => {
|
|
16
|
+
if (!ref.current) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// If focus is already on a focusable child within the cell, early return so we don't shift focus
|
|
20
|
+
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const treeWalker = (0, focus_1.getFocusableTreeWalker)(ref.current);
|
|
24
|
+
const focusable = tableFocus.childFocusStrategy === 'last' ? treeWalker.lastChild() : treeWalker.firstChild();
|
|
25
|
+
if (focusable) {
|
|
26
|
+
// Cell has focusable children, focus the child
|
|
27
|
+
(0, focus_table_child_js_1.focusTableChild)(focusable);
|
|
28
|
+
}
|
|
29
|
+
else if (!ref.current.contains(document.activeElement)) {
|
|
30
|
+
// Cell has no focusable children and current focus is outside of the cell, focus the cell itself
|
|
31
|
+
(0, focus_table_child_js_1.focusTableChild)(ref.current);
|
|
32
|
+
}
|
|
33
|
+
else if (ref.current === document.activeElement && !isTabbable) {
|
|
34
|
+
// Focus is on the current cell, but table focus is elsewhere, update table focus state
|
|
35
|
+
tableFocus.setFocus(rowKey, columnKey);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// Focus the cell DOM node when table focus moves to this cell
|
|
39
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
40
|
+
if (isTabbable && !ref.current.contains(document.activeElement)) {
|
|
41
|
+
focusCell();
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
}, [ref, isTabbable]);
|
|
45
|
+
const onFocus = (e) => {
|
|
46
|
+
// Ignore focus events bubbling through portals
|
|
47
|
+
if (!e.currentTarget.contains(e.target)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// If cell is already focused, return early
|
|
51
|
+
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (e.target !== ref.current) {
|
|
55
|
+
// If a child element of the cell receives focus, there are 3 scenarios:
|
|
56
|
+
// - focus happens through a press, we need to update table focus state to the current cell
|
|
57
|
+
// - focus happens through arrow key navigation within the table,
|
|
58
|
+
// we do nothing as table focus state would have already been updated earlier
|
|
59
|
+
// - focus happens through tabbing into the table from outside,
|
|
60
|
+
// we do nothing because we want to restore focus to the previously focused cell,
|
|
61
|
+
// and overriding table focus state would make that impossible
|
|
62
|
+
if (!(0, interactions_1.isFocusVisible)()) {
|
|
63
|
+
tableFocus.setFocus(rowKey, columnKey);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// If the cell itself receives focus, wait a frame so that focus finishes propagating
|
|
68
|
+
// up to the tree, and move focus to a focusable child if possible.
|
|
69
|
+
requestAnimationFrame(() => {
|
|
70
|
+
if (document.activeElement === ref.current) {
|
|
71
|
+
focusCell();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// Handles keyboard navigation between focusable children within the cell.
|
|
77
|
+
const onKeyDownCapture = (e) => {
|
|
78
|
+
// Ignore keyboard events bubbling through portals
|
|
79
|
+
if (!e.currentTarget.contains(e.target) || !ref.current || !document.activeElement) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const walker = (0, focus_1.getFocusableTreeWalker)(ref.current);
|
|
83
|
+
walker.currentNode = document.activeElement;
|
|
84
|
+
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
85
|
+
// Move to the previous/next focusable element within the cell
|
|
86
|
+
const childElementToFocus = e.key === 'ArrowLeft' ? walker.previousNode() : walker.nextNode();
|
|
87
|
+
if (childElementToFocus && childElementToFocus !== ref.current) {
|
|
88
|
+
(0, focus_table_child_js_1.focusTableChild)(childElementToFocus);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// If there is no previous/next focusable element within the current cell, focus should move to the previous/next cell.
|
|
92
|
+
// This is handled by `useTable`, so we need to let the event bubble up to it.
|
|
93
|
+
// But we also don't want this event to reach children of the current cell, as arrow keys should be used exclusively for table navigation.
|
|
94
|
+
// Solution: re-dispatch the event from a parent element of the current cell.
|
|
95
|
+
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
99
|
+
// Move to the previous/next cell in the current column.
|
|
100
|
+
// This is handled by `useTable`, so we need to let the event bubble up to it.
|
|
101
|
+
// But we also don't want this event to reach children of the current cell, as arrow keys should be used exclusively for table navigation.
|
|
102
|
+
// Solution: re-dispatch the event from a parent element of the current cell.
|
|
103
|
+
ref.current.parentElement?.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// if we didn't handle anything, return early so we don't stop propagation and preventDefault
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
e.stopPropagation();
|
|
111
|
+
};
|
|
112
|
+
const { focusProps, isFocused } = (0, focus_1.useFocusRing)();
|
|
113
|
+
const customProps = {
|
|
114
|
+
tabIndex: isTabbable ? 0 : -1,
|
|
115
|
+
onFocus,
|
|
116
|
+
onKeyDownCapture,
|
|
117
|
+
'data-cell-row-key': rowKey,
|
|
118
|
+
'data-cell-column-key': columnKey,
|
|
119
|
+
'data-focused': isFocused || undefined,
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
cellProps: (0, utils_1.mergeProps)(focusProps, customProps),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=use-table-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-table-cell.js","sourceRoot":"","sources":["../../../../../src/components/table/hooks/use-table-cell.ts"],"names":[],"mappings":";;AAYA,oCA6HC;AAzID,6CAAyE;AACzE,2DAA0D;AAC1D,6CAA+C;AAC/C,iCAA2G;AAE3G,mDAAqD;AACrD,wEAAgE;AAMhE,SAAgB,YAAY,CAAC,GAAoC,EAAE,MAAc,EAAE,SAAiB;IAClG,MAAM,UAAU,GAAG,IAAA,wBAAa,GAAE,CAAC;IAEnC,MAAM,UAAU,GAAG,MAAM,KAAK,UAAU,CAAC,aAAa,IAAI,SAAS,KAAK,UAAU,CAAC,gBAAgB,CAAC;IAEpG,6BAA6B;IAC7B,sFAAsF;IACtF,MAAM,SAAS,GAAG,GAAG,EAAE;QACr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AO;QACP,gBAAgB;QAChB,mBAAmB,EAAE,MAAM;QAC3B,sBAAsB,EAAE,SAAS;QACjC,cAAc,EAAE,SAAS,IAAI,SAAS;KACvC,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,IAAA,kBAAU,EAAC,UAAU,EAAE,WAAW,CAAC;KAC/C,CAAC;AACJ,CAAC","sourcesContent":["import { getFocusableTreeWalker, useFocusRing } from '@react-aria/focus';\nimport { isFocusVisible } from '@react-aria/interactions';\nimport { mergeProps } from '@react-aria/utils';\nimport { type KeyboardEventHandler, useLayoutEffect, type FocusEventHandler, type RefObject } from 'react';\nimport type { FocusableElement, NativeElementProps } from '../../types.js';\nimport { useTableFocus } from '../contexts/focus.js';\nimport { focusTableChild } from '../utils/focus-table-child.js';\n\nexport interface UseTableCell {\n cellProps: NativeElementProps<HTMLTableCellElement>;\n}\n\nexport function useTableCell(ref: RefObject<HTMLTableCellElement>, rowKey: string, columnKey: string): UseTableCell {\n const tableFocus = useTableFocus();\n\n const isTabbable = rowKey === tableFocus.focusedRowKey && columnKey === tableFocus.focusedColumnKey;\n\n // Handles focusing the cell.\n // If there is a focusable child, it is focused, otherwise the cell itself is focused.\n const focusCell = () => {\n if (!ref.current) {\n return;\n }\n\n // If focus is already on a focusable child within the cell, early return so we don't shift focus\n if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {\n return;\n }\n\n const treeWalker = getFocusableTreeWalker(ref.current);\n const focusable = tableFocus.childFocusStrategy === 'last' ? treeWalker.lastChild() : treeWalker.firstChild();\n\n if (focusable) {\n // Cell has focusable children, focus the child\n focusTableChild(focusable as FocusableElement);\n } else if (!ref.current.contains(document.activeElement)) {\n // Cell has no focusable children and current focus is outside of the cell, focus the cell itself\n focusTableChild(ref.current);\n } else if (ref.current === document.activeElement && !isTabbable) {\n // Focus is on the current cell, but table focus is elsewhere, update table focus state\n tableFocus.setFocus(rowKey, columnKey);\n }\n };\n\n // Focus the cell DOM node when table focus moves to this cell\n useLayoutEffect(() => {\n if (isTabbable && !ref.current!.contains(document.activeElement)) {\n focusCell();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ref, isTabbable]);\n\n const onFocus: FocusEventHandler = (e) => {\n // Ignore focus events bubbling through portals\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n // If cell is already focused, return early\n if (e.currentTarget.contains(e.relatedTarget)) {\n return;\n }\n\n if (e.target !== ref.current) {\n // If a child element of the cell receives focus, there are 3 scenarios:\n // - focus happens through a press, we need to update table focus state to the current cell\n // - focus happens through arrow key navigation within the table,\n // we do nothing as table focus state would have already been updated earlier\n // - focus happens through tabbing into the table from outside,\n // we do nothing because we want to restore focus to the previously focused cell,\n // and overriding table focus state would make that impossible\n if (!isFocusVisible()) {\n tableFocus.setFocus(rowKey, columnKey);\n }\n } else {\n // If the cell itself receives focus, wait a frame so that focus finishes propagating\n // up to the tree, and move focus to a focusable child if possible.\n requestAnimationFrame(() => {\n if (document.activeElement === ref.current) {\n focusCell();\n }\n });\n }\n };\n\n // Handles keyboard navigation between focusable children within the cell.\n const onKeyDownCapture: KeyboardEventHandler = (e) => {\n // Ignore keyboard events bubbling through portals\n if (!e.currentTarget.contains(e.target as Element) || !ref.current || !document.activeElement) {\n return;\n }\n\n const walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n // Move to the previous/next focusable element within the cell\n const childElementToFocus = e.key === 'ArrowLeft' ? walker.previousNode() : walker.nextNode();\n\n if (childElementToFocus && childElementToFocus !== ref.current) {\n focusTableChild(childElementToFocus as FocusableElement);\n } else {\n // If there is no previous/next focusable element within the current cell, focus should move to the previous/next cell.\n // This is handled by `useTable`, so we need to let the event bubble up to it.\n // But we also don't want this event to reach children of the current cell, as arrow keys should be used exclusively for table navigation.\n // Solution: re-dispatch the event from a parent element of the current cell.\n ref.current.parentElement!.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));\n }\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n // Move to the previous/next cell in the current column.\n // This is handled by `useTable`, so we need to let the event bubble up to it.\n // But we also don't want this event to reach children of the current cell, as arrow keys should be used exclusively for table navigation.\n // Solution: re-dispatch the event from a parent element of the current cell.\n ref.current.parentElement?.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));\n } else {\n // if we didn't handle anything, return early so we don't stop propagation and preventDefault\n return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n };\n\n const { focusProps, isFocused } = useFocusRing();\n\n const customProps: NativeElementProps<HTMLTableCellElement> = {\n tabIndex: isTabbable ? 0 : -1,\n onFocus,\n onKeyDownCapture,\n 'data-cell-row-key': rowKey,\n 'data-cell-column-key': columnKey,\n 'data-focused': isFocused || undefined,\n };\n\n return {\n cellProps: mergeProps(focusProps, customProps),\n };\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { NativeElementProps } from '../../types.js';
|
|
3
|
+
export interface UseTable {
|
|
4
|
+
tableProps: NativeElementProps<HTMLTableElement>;
|
|
5
|
+
}
|
|
6
|
+
export declare function useTable(ref: RefObject<HTMLTableElement>): UseTable;
|
|
7
|
+
//# sourceMappingURL=use-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-table.d.ts","sourceRoot":"","sources":["../../../../../src/components/table/hooks/use-table.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAoB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAI3E,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;CAClD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAsJnE"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTable = useTable;
|
|
4
|
+
const focus_1 = require("@react-aria/focus");
|
|
5
|
+
const interactions_1 = require("@react-aria/interactions");
|
|
6
|
+
const utils_1 = require("@react-aria/utils");
|
|
7
|
+
const focus_js_1 = require("../contexts/focus.js");
|
|
8
|
+
const focus_table_child_js_1 = require("../utils/focus-table-child.js");
|
|
9
|
+
function useTable(ref) {
|
|
10
|
+
const tableFocus = (0, focus_js_1.useTableFocus)();
|
|
11
|
+
const restoreCellFocus = (e) => {
|
|
12
|
+
if (!tableFocus.focusedRowKey || !tableFocus.focusedColumnKey) {
|
|
13
|
+
// User hasn't interacted with the table yet.
|
|
14
|
+
// Focus the first or last cell, depending on which direction the user is tabbing from.
|
|
15
|
+
const lastFocusedElement = e.relatedTarget;
|
|
16
|
+
const cellElements = e.currentTarget.querySelectorAll('[data-cell-row-key][data-cell-column-key]');
|
|
17
|
+
let cellElementToFocus;
|
|
18
|
+
if (lastFocusedElement &&
|
|
19
|
+
e.currentTarget.compareDocumentPosition(lastFocusedElement) & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
20
|
+
cellElementToFocus = cellElements[cellElements.length - 1];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
cellElementToFocus = cellElements[0];
|
|
24
|
+
}
|
|
25
|
+
const { cellRowKey, cellColumnKey } = cellElementToFocus.dataset;
|
|
26
|
+
// We know the keys are defined, because we queried the DOM for elements that have them
|
|
27
|
+
tableFocus.setFocus(cellRowKey, cellColumnKey);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const element = e.currentTarget.querySelector(`[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'][data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']`);
|
|
31
|
+
if (element) {
|
|
32
|
+
// If focus is already within the cell, don't refocus
|
|
33
|
+
if (!element.contains(document.activeElement)) {
|
|
34
|
+
(0, focus_table_child_js_1.focusTableChild)(element);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const { focusableProps } = (0, focus_1.useFocusable)({
|
|
40
|
+
onFocus: (e) => {
|
|
41
|
+
// Ignore focus events bubbling through portals
|
|
42
|
+
if (!e.currentTarget.contains(e.target)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
restoreCellFocus(e);
|
|
46
|
+
},
|
|
47
|
+
}, ref);
|
|
48
|
+
const { keyboardProps } = (0, interactions_1.useKeyboard)({
|
|
49
|
+
onKeyDown: (e) => {
|
|
50
|
+
// Ignore keyboard events bubbling through portals
|
|
51
|
+
if (!e.currentTarget.contains(e.target)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const focusedCellElement = e.currentTarget.querySelector(`[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'][data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']`);
|
|
55
|
+
let cellElementToFocus = null;
|
|
56
|
+
let newChildFocusStrategy;
|
|
57
|
+
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
58
|
+
// Focus previous/next cell in the same row
|
|
59
|
+
const selector = `[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}']:not([data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}'])`;
|
|
60
|
+
const walker = (0, focus_1.getFocusableTreeWalker)(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
61
|
+
walker.currentNode = focusedCellElement;
|
|
62
|
+
cellElementToFocus = e.key === 'ArrowLeft' ? walker.previousNode() : walker.nextNode();
|
|
63
|
+
newChildFocusStrategy = e.key === 'ArrowLeft' ? 'last' : 'first';
|
|
64
|
+
}
|
|
65
|
+
else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
66
|
+
// Focus previous/next cell in the same column
|
|
67
|
+
const selector = `[data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']:not([data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'])`;
|
|
68
|
+
const walker = (0, focus_1.getFocusableTreeWalker)(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
69
|
+
walker.currentNode = focusedCellElement;
|
|
70
|
+
cellElementToFocus = e.key === 'ArrowUp' ? walker.previousNode() : walker.nextNode();
|
|
71
|
+
}
|
|
72
|
+
else if (e.key === 'PageUp' || e.key === 'PageDown') {
|
|
73
|
+
// Move focus up/down by 5 rows
|
|
74
|
+
const selector = `[data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']:not([data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'])`;
|
|
75
|
+
const walker = (0, focus_1.getFocusableTreeWalker)(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
76
|
+
walker.currentNode = focusedCellElement;
|
|
77
|
+
const advance = e.key === 'PageUp' ? walker.previousNode.bind(walker) : walker.nextNode.bind(walker);
|
|
78
|
+
// `advance()` will do nothing if there's no appropriate node found, so it's safe to just call it 5 times
|
|
79
|
+
for (let i = 0; i < 5; i++) {
|
|
80
|
+
advance();
|
|
81
|
+
}
|
|
82
|
+
cellElementToFocus = walker.currentNode;
|
|
83
|
+
}
|
|
84
|
+
else if (e.key === 'Home' || e.key === 'End') {
|
|
85
|
+
// If Ctrl/Cmd is pressed, move focus to the first/last cell of the table;
|
|
86
|
+
// otherwise, move focus to the first/last cell of the current row
|
|
87
|
+
const selector = '[data-cell-row-key][data-cell-column-key]';
|
|
88
|
+
const walker = (0, focus_1.getFocusableTreeWalker)(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
89
|
+
walker.currentNode = isCtrlKeyPressed(e) ? e.currentTarget : focusedCellElement.parentElement;
|
|
90
|
+
cellElementToFocus = e.key === 'Home' ? walker.firstChild() : walker.lastChild();
|
|
91
|
+
newChildFocusStrategy = e.key === 'Home' ? 'first' : 'last';
|
|
92
|
+
}
|
|
93
|
+
else if (e.key === 'Tab') {
|
|
94
|
+
// Table is supposed to be a single Tab stop, but cells may contain elements that are tabbable (checkboxes, buttons, menus, etc.).
|
|
95
|
+
// We don't control the rendering of these elements, so we can't override their tabIndex to prevent tabbing.
|
|
96
|
+
// Instead, we detect when Tab key is pressed, and move focus manually to the guard element before/after the table,
|
|
97
|
+
// so that the browser default behavior will apply starting from that element rather than the currently focused one.
|
|
98
|
+
const tableElement = e.currentTarget;
|
|
99
|
+
const guardElement = e.shiftKey ? tableElement.previousElementSibling : tableElement.nextElementSibling;
|
|
100
|
+
if (guardElement) {
|
|
101
|
+
(0, focus_table_child_js_1.focusTableChild)(guardElement);
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// if we didn't handle anything, return early so we don't preventDefault
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (cellElementToFocus) {
|
|
110
|
+
const { cellRowKey, cellColumnKey } = cellElementToFocus.dataset;
|
|
111
|
+
// We know the keys are defined, because we queried the DOM for elements that have them
|
|
112
|
+
tableFocus.setFocus(cellRowKey, cellColumnKey, newChildFocusStrategy);
|
|
113
|
+
}
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
const customProps = {
|
|
118
|
+
role: 'grid',
|
|
119
|
+
// If no cell is tabbable within the table, make the table itself tabbable,
|
|
120
|
+
// otherwise the Tab key will just skip it
|
|
121
|
+
tabIndex: tableFocus.focusedRowKey && tableFocus.focusedColumnKey ? -1 : 0,
|
|
122
|
+
onFocusCapture: (e) => {
|
|
123
|
+
// If we're navigating into the table with a keyboard, focus the last focused cell instead of the first tabbable element
|
|
124
|
+
if ((0, interactions_1.getInteractionModality)() === 'keyboard' &&
|
|
125
|
+
!e.currentTarget.contains(e.relatedTarget) &&
|
|
126
|
+
e.currentTarget.contains(e.target)) {
|
|
127
|
+
restoreCellFocus(e);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
tableProps: (0, utils_1.mergeProps)(focusableProps, keyboardProps, customProps),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// TODO: use `isCtrlKeyPressed` from `@react-aria/utils` after version upgrade
|
|
136
|
+
function isCtrlKeyPressed(e) {
|
|
137
|
+
if ((0, utils_1.isMac)()) {
|
|
138
|
+
return e.metaKey;
|
|
139
|
+
}
|
|
140
|
+
return e.ctrlKey;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=use-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-table.js","sourceRoot":"","sources":["../../../../../src/components/table/hooks/use-table.ts"],"names":[],"mappings":";;AAYA,4BAsJC;AAlKD,6CAAyE;AACzE,2DAA+E;AAC/E,6CAAsD;AAGtD,mDAA8E;AAC9E,wEAAgE;AAMhE,SAAgB,QAAQ,CAAC,GAAgC;IACvD,MAAM,UAAU,GAAG,IAAA,wBAAa,GAAE,CAAC;IAEnC,MAAM,gBAAgB,GAAsB,CAAC,CAAC,EAAE,EAAE;QAChD,IAAI,CAAC,UAAU,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC;YAC9D,6CAA6C;YAC7C,uFAAuF;YACvF,MAAM,kBAAkB,GAAG,CAAC,CAAC,aAAwB,CAAC;YACtD,MAAM,YAAY,GAAG,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAAC,2CAA2C,CAAC,CAAC;YACnG,IAAI,kBAAuC,CAAC;YAE5C,IACE,kBAAkB;gBAClB,CAAC,CAAC,aAAa,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,2BAA2B,EAC9F,CAAC;gBACD,kBAAkB,GAAG,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAC7D,CAAC;iBAAM,CAAC;gBACN,kBAAkB,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YACvC,CA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AAa,EAAE,GAAI,kBAA2C,CAAC,OAAO,CAAC;gBAE3F,uFAAuF;gBACvF,UAAU,CAAC,QAAQ,CAAC,UAAW,EAAE,aAAc,EAAE,qBAAqB,CAAC,CAAC;YAC1E,CAAC;YAED,CAAC,CAAC,cAAc,EAAE,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,WAAW,GAAyC;QACxD,IAAI,EAAE,MAAM;QACZ,2EAA2E;QAC3E,0CAA0C;QAC1C,QAAQ,EAAE,UAAU,CAAC,aAAa,IAAI,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;YACpB,wHAAwH;YACxH,IACE,IAAA,qCAAsB,GAAE,KAAK,UAAU;gBACvC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC;gBAC1C,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAClC,CAAC;gBACD,gBAAgB,CAAC,CAAC,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;KACF,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,IAAA,kBAAU,EAAC,cAAc,EAAE,aAAa,EAAE,WAAW,CAAC;KACnE,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,SAAS,gBAAgB,CAAC,CAAyC;IACjE,IAAI,IAAA,aAAK,GAAE,EAAE,CAAC;QACZ,OAAO,CAAC,CAAC,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,CAAC,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { getFocusableTreeWalker, useFocusable } from '@react-aria/focus';\nimport { getInteractionModality, useKeyboard } from '@react-aria/interactions';\nimport { isMac, mergeProps } from '@react-aria/utils';\nimport type { FocusEventHandler, RefObject } from 'react';\nimport type { FocusableElement, NativeElementProps } from '../../types.js';\nimport { type ChildFocusStrategy, useTableFocus } from '../contexts/focus.js';\nimport { focusTableChild } from '../utils/focus-table-child.js';\n\nexport interface UseTable {\n tableProps: NativeElementProps<HTMLTableElement>;\n}\n\nexport function useTable(ref: RefObject<HTMLTableElement>): UseTable {\n const tableFocus = useTableFocus();\n\n const restoreCellFocus: FocusEventHandler = (e) => {\n if (!tableFocus.focusedRowKey || !tableFocus.focusedColumnKey) {\n // User hasn't interacted with the table yet.\n // Focus the first or last cell, depending on which direction the user is tabbing from.\n const lastFocusedElement = e.relatedTarget as Element;\n const cellElements = e.currentTarget.querySelectorAll('[data-cell-row-key][data-cell-column-key]');\n let cellElementToFocus: Element | undefined;\n\n if (\n lastFocusedElement &&\n e.currentTarget.compareDocumentPosition(lastFocusedElement) & Node.DOCUMENT_POSITION_FOLLOWING\n ) {\n cellElementToFocus = cellElements[cellElements.length - 1];\n } else {\n cellElementToFocus = cellElements[0];\n }\n\n const { cellRowKey, cellColumnKey } = (cellElementToFocus as HTMLTableCellElement).dataset;\n\n // We know the keys are defined, because we queried the DOM for elements that have them\n tableFocus.setFocus(cellRowKey!, cellColumnKey!);\n } else {\n const element = e.currentTarget.querySelector(\n `[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'][data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']`,\n ) as HTMLTableCellElement;\n\n if (element) {\n // If focus is already within the cell, don't refocus\n if (!element.contains(document.activeElement)) {\n focusTableChild(element);\n }\n }\n }\n };\n\n const { focusableProps } = useFocusable(\n {\n onFocus: (e) => {\n // Ignore focus events bubbling through portals\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n restoreCellFocus(e);\n },\n },\n ref,\n );\n\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n // Ignore keyboard events bubbling through portals\n if (!e.currentTarget.contains(e.target)) {\n return;\n }\n\n const focusedCellElement = e.currentTarget.querySelector(\n `[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'][data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']`,\n ) as HTMLTableCellElement;\n\n let cellElementToFocus: Node | null = null;\n let newChildFocusStrategy: ChildFocusStrategy | undefined;\n\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n // Focus previous/next cell in the same row\n const selector = `[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}']:not([data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}'])`;\n const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });\n walker.currentNode = focusedCellElement;\n cellElementToFocus = e.key === 'ArrowLeft' ? walker.previousNode() : walker.nextNode();\n newChildFocusStrategy = e.key === 'ArrowLeft' ? 'last' : 'first';\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n // Focus previous/next cell in the same column\n const selector = `[data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']:not([data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'])`;\n const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });\n walker.currentNode = focusedCellElement;\n cellElementToFocus = e.key === 'ArrowUp' ? walker.previousNode() : walker.nextNode();\n } else if (e.key === 'PageUp' || e.key === 'PageDown') {\n // Move focus up/down by 5 rows\n const selector = `[data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']:not([data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'])`;\n const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });\n walker.currentNode = focusedCellElement;\n\n const advance = e.key === 'PageUp' ? walker.previousNode.bind(walker) : walker.nextNode.bind(walker);\n\n // `advance()` will do nothing if there's no appropriate node found, so it's safe to just call it 5 times\n for (let i = 0; i < 5; i++) {\n advance();\n }\n\n cellElementToFocus = walker.currentNode;\n } else if (e.key === 'Home' || e.key === 'End') {\n // If Ctrl/Cmd is pressed, move focus to the first/last cell of the table;\n // otherwise, move focus to the first/last cell of the current row\n const selector = '[data-cell-row-key][data-cell-column-key]';\n const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });\n walker.currentNode = isCtrlKeyPressed(e) ? e.currentTarget : focusedCellElement.parentElement!;\n cellElementToFocus = e.key === 'Home' ? walker.firstChild() : walker.lastChild();\n newChildFocusStrategy = e.key === 'Home' ? 'first' : 'last';\n } else if (e.key === 'Tab') {\n // Table is supposed to be a single Tab stop, but cells may contain elements that are tabbable (checkboxes, buttons, menus, etc.).\n // We don't control the rendering of these elements, so we can't override their tabIndex to prevent tabbing.\n // Instead, we detect when Tab key is pressed, and move focus manually to the guard element before/after the table,\n // so that the browser default behavior will apply starting from that element rather than the currently focused one.\n const tableElement = e.currentTarget as HTMLTableElement;\n const guardElement = e.shiftKey ? tableElement.previousElementSibling : tableElement.nextElementSibling;\n\n if (guardElement) {\n focusTableChild(guardElement as FocusableElement);\n }\n\n return;\n } else {\n // if we didn't handle anything, return early so we don't preventDefault\n return;\n }\n\n if (cellElementToFocus) {\n const { cellRowKey, cellColumnKey } = (cellElementToFocus as HTMLTableCellElement).dataset;\n\n // We know the keys are defined, because we queried the DOM for elements that have them\n tableFocus.setFocus(cellRowKey!, cellColumnKey!, newChildFocusStrategy);\n }\n\n e.preventDefault();\n },\n });\n\n const customProps: NativeElementProps<HTMLTableElement> = {\n role: 'grid',\n // If no cell is tabbable within the table, make the table itself tabbable,\n // otherwise the Tab key will just skip it\n tabIndex: tableFocus.focusedRowKey && tableFocus.focusedColumnKey ? -1 : 0,\n onFocusCapture: (e) => {\n // If we're navigating into the table with a keyboard, focus the last focused cell instead of the first tabbable element\n if (\n getInteractionModality() === 'keyboard' &&\n !e.currentTarget.contains(e.relatedTarget) &&\n e.currentTarget.contains(e.target)\n ) {\n restoreCellFocus(e);\n }\n },\n };\n\n return {\n tableProps: mergeProps(focusableProps, keyboardProps, customProps),\n };\n}\n\n// TODO: use `isCtrlKeyPressed` from `@react-aria/utils` after version upgrade\nfunction isCtrlKeyPressed(e: { ctrlKey: boolean; metaKey: boolean }): boolean {\n if (isMac()) {\n return e.metaKey;\n }\n\n return e.ctrlKey;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { CommonProps } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_TableBodyCellProps extends CommonProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* A unique identifier for the column that this cell belongs to.
|
|
7
|
+
* Cells that belong to the same column must have the same `columnKey`.
|
|
8
|
+
*/
|
|
9
|
+
columnKey: string;
|
|
10
|
+
/**
|
|
11
|
+
* The position of the column that this cell belongs to within the full dataset.
|
|
12
|
+
*
|
|
13
|
+
* Provide this value if your table presents a subset of columns, such as when the user toggles column visibility.
|
|
14
|
+
*
|
|
15
|
+
* This number must be:
|
|
16
|
+
* - greater than or equal to `1`
|
|
17
|
+
* - greater than the `columnNumber` of any previous cells in the current row
|
|
18
|
+
* - less than or equal to the `totalColumnCount` of the parent `Table`
|
|
19
|
+
*
|
|
20
|
+
* Use together with `totalColumnCount` on the `Table` component.
|
|
21
|
+
*/
|
|
22
|
+
columnNumber?: number;
|
|
23
|
+
}
|
|
24
|
+
declare const _UNSTABLE_TableBodyCell: (props: UNSTABLE_TableBodyCellProps & import("react").RefAttributes<HTMLTableCellElement>) => import("react").JSX.Element | null;
|
|
25
|
+
export { _UNSTABLE_TableBodyCell as UNSTABLE_TableBodyCell };
|
|
26
|
+
//# sourceMappingURL=table-body-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-body-cell.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-body-cell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,WAAW,2BAA4B,SAAQ,WAAW;IAC9D,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAuBD,QAAA,MAAM,uBAAuB,kIAAsD,CAAC;AAEpF,OAAO,EAAE,uBAAuB,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNSTABLE_TableBodyCell = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const utils_1 = require("@react-aria/utils");
|
|
6
|
+
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
7
|
+
const row_state_js_1 = require("./contexts/row-state.js");
|
|
8
|
+
const use_table_cell_js_1 = require("./hooks/use-table-cell.js");
|
|
9
|
+
function UNSTABLE_TableBodyCell({ children, UNSAFE_className, UNSAFE_style, columnKey, columnNumber, ...props }, ref) {
|
|
10
|
+
const cellRef = (0, utils_1.useObjectRef)(ref);
|
|
11
|
+
const { rowKey } = (0, row_state_js_1.useTableRowState)();
|
|
12
|
+
const { cellProps } = (0, use_table_cell_js_1.useTableCell)(cellRef, rowKey, columnKey);
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("td", { ...(0, utils_1.mergeProps)(props, cellProps), ref: cellRef, className: UNSAFE_className, style: UNSAFE_style, "aria-colindex": columnNumber, children: children }));
|
|
14
|
+
}
|
|
15
|
+
const _UNSTABLE_TableBodyCell = (0, forward_ref_js_1.forwardRef)(UNSTABLE_TableBodyCell, 'TableBodyCell');
|
|
16
|
+
exports.UNSTABLE_TableBodyCell = _UNSTABLE_TableBodyCell;
|
|
17
|
+
//# sourceMappingURL=table-body-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-body-cell.js","sourceRoot":"","sources":["../../../../src/components/table/table-body-cell.tsx"],"names":[],"mappings":";;;;AAAA,6CAA6D;AAE7D,yDAAkD;AAElD,0DAA2D;AAC3D,iEAAyD;AAwBzD,SAAS,sBAAsB,CAC7B,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,KAAK,EAA+B,EAC5G,GAAuC;IAEvC,MAAM,OAAO,GAAG,IAAA,oBAAY,EAAC,GAAG,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,+BAAgB,GAAE,CAAC;IACtC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,gCAAY,EAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAE/D,OAAO,CACL,kCACM,IAAA,kBAAU,EAAC,KAAK,EAAE,SAAS,CAAC,EAChC,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,YAAY,mBACJ,YAAY,YAE1B,QAAQ,GACN,CACN,CAAC;AACJ,CAAC;AAED,MAAM,uBAAuB,GAAG,IAAA,2BAAU,EAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;AAEhD,yDAAsB","sourcesContent":["import { mergeProps, useObjectRef } from '@react-aria/utils';\nimport type { ForwardedRef, ReactNode } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport type { CommonProps } from '../types.js';\nimport { useTableRowState } from './contexts/row-state.js';\nimport { useTableCell } from './hooks/use-table-cell.js';\n\nexport interface UNSTABLE_TableBodyCellProps extends CommonProps {\n children: ReactNode;\n /**\n * A unique identifier for the column that this cell belongs to.\n * Cells that belong to the same column must have the same `columnKey`.\n */\n columnKey: string;\n /**\n * The position of the column that this cell belongs to within the full dataset.\n *\n * Provide this value if your table presents a subset of columns, such as when the user toggles column visibility.\n *\n * This number must be:\n * - greater than or equal to `1`\n * - greater than the `columnNumber` of any previous cells in the current row\n * - less than or equal to the `totalColumnCount` of the parent `Table`\n *\n * Use together with `totalColumnCount` on the `Table` component.\n */\n columnNumber?: number;\n}\n\nfunction UNSTABLE_TableBodyCell(\n { children, UNSAFE_className, UNSAFE_style, columnKey, columnNumber, ...props }: UNSTABLE_TableBodyCellProps,\n ref: ForwardedRef<HTMLTableCellElement>,\n) {\n const cellRef = useObjectRef(ref);\n const { rowKey } = useTableRowState();\n const { cellProps } = useTableCell(cellRef, rowKey, columnKey);\n\n return (\n <td\n {...mergeProps(props, cellProps)}\n ref={cellRef}\n className={UNSAFE_className}\n style={UNSAFE_style}\n aria-colindex={columnNumber}\n >\n {children}\n </td>\n );\n}\n\nconst _UNSTABLE_TableBodyCell = forwardRef(UNSTABLE_TableBodyCell, 'TableBodyCell');\n\nexport { _UNSTABLE_TableBodyCell as UNSTABLE_TableBodyCell };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { CommonProps } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_TableBodyProps extends CommonProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare const _UNSTABLE_TableBody: (props: UNSTABLE_TableBodyProps & import("react").RefAttributes<HTMLTableSectionElement>) => import("react").JSX.Element | null;
|
|
7
|
+
export { _UNSTABLE_TableBody as UNSTABLE_TableBody };
|
|
8
|
+
//# sourceMappingURL=table-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-body.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-body.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,QAAQ,EAAE,SAAS,CAAC;CACrB;AAaD,QAAA,MAAM,mBAAmB,iIAA8C,CAAC;AAExE,OAAO,EAAE,mBAAmB,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNSTABLE_TableBody = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
6
|
+
function UNSTABLE_TableBody({ children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)("tbody", { ...props, ref: ref, className: UNSAFE_className, style: UNSAFE_style, children: children }));
|
|
8
|
+
}
|
|
9
|
+
const _UNSTABLE_TableBody = (0, forward_ref_js_1.forwardRef)(UNSTABLE_TableBody, 'TableBody');
|
|
10
|
+
exports.UNSTABLE_TableBody = _UNSTABLE_TableBody;
|
|
11
|
+
//# sourceMappingURL=table-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-body.js","sourceRoot":"","sources":["../../../../src/components/table/table-body.tsx"],"names":[],"mappings":";;;;AACA,yDAAkD;AAOlD,SAAS,kBAAkB,CACzB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAA2B,EAC/E,GAA0C;IAE1C,OAAO,CACL,qCAAW,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,YACzE,QAAQ,GACH,CACT,CAAC;AACJ,CAAC;AAED,MAAM,mBAAmB,GAAG,IAAA,2BAAU,EAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAExC,iDAAkB","sourcesContent":["import type { ForwardedRef, ReactNode } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport type { CommonProps } from '../types.js';\n\nexport interface UNSTABLE_TableBodyProps extends CommonProps {\n children: ReactNode;\n}\n\nfunction UNSTABLE_TableBody(\n { children, UNSAFE_className, UNSAFE_style, ...props }: UNSTABLE_TableBodyProps,\n ref: ForwardedRef<HTMLTableSectionElement>,\n) {\n return (\n <tbody {...props} ref={ref} className={UNSAFE_className} style={UNSAFE_style}>\n {children}\n </tbody>\n );\n}\n\nconst _UNSTABLE_TableBody = forwardRef(UNSTABLE_TableBody, 'TableBody');\n\nexport { _UNSTABLE_TableBody as UNSTABLE_TableBody };\n"]}
|