@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
|
@@ -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,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
const TableRowStateContext = createContext(null);
|
|
4
|
+
export function TableRowStateProvider({ children, rowKey }) {
|
|
5
|
+
const tableRowState = useMemo(() => ({
|
|
6
|
+
rowKey,
|
|
7
|
+
}), [rowKey]);
|
|
8
|
+
return _jsx(TableRowStateContext.Provider, { value: tableRowState, children: children });
|
|
9
|
+
}
|
|
10
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
11
|
+
export function useTableRowState() {
|
|
12
|
+
const tableRowState = useContext(TableRowStateContext);
|
|
13
|
+
if (!tableRowState) {
|
|
14
|
+
throw new Error('Cannot use table row state outside of a table row');
|
|
15
|
+
}
|
|
16
|
+
return tableRowState;
|
|
17
|
+
}
|
|
18
|
+
//# 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":";AAAA,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAM3E,MAAM,oBAAoB,GAAG,aAAa,CAAuB,IAAI,CAAC,CAAC;AAEvE,MAAM,UAAU,qBAAqB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAA2C;IACjG,MAAM,aAAa,GAAkB,OAAO,CAC1C,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;KACP,CAAC,EACF,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAAG,QAAQ,GAAiC,CAAC;AACzG,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,gBAAgB;IAC9B,MAAM,aAAa,GAAG,UAAU,CAAC,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,122 @@
|
|
|
1
|
+
import { getFocusableTreeWalker, useFocusRing } from '@react-aria/focus';
|
|
2
|
+
import { isFocusVisible } from '@react-aria/interactions';
|
|
3
|
+
import { mergeProps } from '@react-aria/utils';
|
|
4
|
+
import { useLayoutEffect } from 'react';
|
|
5
|
+
import { useTableFocus } from '../contexts/focus.js';
|
|
6
|
+
import { focusTableChild } from '../utils/focus-table-child.js';
|
|
7
|
+
export function useTableCell(ref, rowKey, columnKey) {
|
|
8
|
+
const tableFocus = useTableFocus();
|
|
9
|
+
const isTabbable = rowKey === tableFocus.focusedRowKey && columnKey === tableFocus.focusedColumnKey;
|
|
10
|
+
// Handles focusing the cell.
|
|
11
|
+
// If there is a focusable child, it is focused, otherwise the cell itself is focused.
|
|
12
|
+
const focusCell = () => {
|
|
13
|
+
if (!ref.current) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
// If focus is already on a focusable child within the cell, early return so we don't shift focus
|
|
17
|
+
if (ref.current.contains(document.activeElement) && ref.current !== document.activeElement) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const treeWalker = getFocusableTreeWalker(ref.current);
|
|
21
|
+
const focusable = tableFocus.childFocusStrategy === 'last' ? treeWalker.lastChild() : treeWalker.firstChild();
|
|
22
|
+
if (focusable) {
|
|
23
|
+
// Cell has focusable children, focus the child
|
|
24
|
+
focusTableChild(focusable);
|
|
25
|
+
}
|
|
26
|
+
else if (!ref.current.contains(document.activeElement)) {
|
|
27
|
+
// Cell has no focusable children and current focus is outside of the cell, focus the cell itself
|
|
28
|
+
focusTableChild(ref.current);
|
|
29
|
+
}
|
|
30
|
+
else if (ref.current === document.activeElement && !isTabbable) {
|
|
31
|
+
// Focus is on the current cell, but table focus is elsewhere, update table focus state
|
|
32
|
+
tableFocus.setFocus(rowKey, columnKey);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// Focus the cell DOM node when table focus moves to this cell
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
if (isTabbable && !ref.current.contains(document.activeElement)) {
|
|
38
|
+
focusCell();
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [ref, isTabbable]);
|
|
42
|
+
const onFocus = (e) => {
|
|
43
|
+
// Ignore focus events bubbling through portals
|
|
44
|
+
if (!e.currentTarget.contains(e.target)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// If cell is already focused, return early
|
|
48
|
+
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (e.target !== ref.current) {
|
|
52
|
+
// If a child element of the cell receives focus, there are 3 scenarios:
|
|
53
|
+
// - focus happens through a press, we need to update table focus state to the current cell
|
|
54
|
+
// - focus happens through arrow key navigation within the table,
|
|
55
|
+
// we do nothing as table focus state would have already been updated earlier
|
|
56
|
+
// - focus happens through tabbing into the table from outside,
|
|
57
|
+
// we do nothing because we want to restore focus to the previously focused cell,
|
|
58
|
+
// and overriding table focus state would make that impossible
|
|
59
|
+
if (!isFocusVisible()) {
|
|
60
|
+
tableFocus.setFocus(rowKey, columnKey);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// If the cell itself receives focus, wait a frame so that focus finishes propagating
|
|
65
|
+
// up to the tree, and move focus to a focusable child if possible.
|
|
66
|
+
requestAnimationFrame(() => {
|
|
67
|
+
if (document.activeElement === ref.current) {
|
|
68
|
+
focusCell();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
// Handles keyboard navigation between focusable children within the cell.
|
|
74
|
+
const onKeyDownCapture = (e) => {
|
|
75
|
+
// Ignore keyboard events bubbling through portals
|
|
76
|
+
if (!e.currentTarget.contains(e.target) || !ref.current || !document.activeElement) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const walker = getFocusableTreeWalker(ref.current);
|
|
80
|
+
walker.currentNode = document.activeElement;
|
|
81
|
+
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
82
|
+
// Move to the previous/next focusable element within the cell
|
|
83
|
+
const childElementToFocus = e.key === 'ArrowLeft' ? walker.previousNode() : walker.nextNode();
|
|
84
|
+
if (childElementToFocus && childElementToFocus !== ref.current) {
|
|
85
|
+
focusTableChild(childElementToFocus);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// If there is no previous/next focusable element within the current cell, focus should move to the previous/next cell.
|
|
89
|
+
// This is handled by `useTable`, so we need to let the event bubble up to it.
|
|
90
|
+
// 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.
|
|
91
|
+
// Solution: re-dispatch the event from a parent element of the current cell.
|
|
92
|
+
ref.current.parentElement.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
96
|
+
// Move to the previous/next cell in the current column.
|
|
97
|
+
// This is handled by `useTable`, so we need to let the event bubble up to it.
|
|
98
|
+
// 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.
|
|
99
|
+
// Solution: re-dispatch the event from a parent element of the current cell.
|
|
100
|
+
ref.current.parentElement?.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// if we didn't handle anything, return early so we don't stop propagation and preventDefault
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
};
|
|
109
|
+
const { focusProps, isFocused } = useFocusRing();
|
|
110
|
+
const customProps = {
|
|
111
|
+
tabIndex: isTabbable ? 0 : -1,
|
|
112
|
+
onFocus,
|
|
113
|
+
onKeyDownCapture,
|
|
114
|
+
'data-cell-row-key': rowKey,
|
|
115
|
+
'data-cell-column-key': columnKey,
|
|
116
|
+
'data-focused': isFocused || undefined,
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
cellProps: mergeProps(focusProps, customProps),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# 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":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAA6B,eAAe,EAA0C,MAAM,OAAO,CAAC;AAE3G,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhE,MAAM,UAAU,YAAY,CAAC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C,CAAC;IAEF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAAC;IAEjD,MAAM,WAAW,GAA6C;QAC5D,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO;QACP,gBAAgB;QAChB,mBAAmB,EAAE,MAAM;QAC3B,sBAAsB,EAAE,SAAS;QACjC,cAAc,EAAE,SAAS,IAAI,SAAS;KACvC,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,UAAU,CAAC,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,139 @@
|
|
|
1
|
+
import { getFocusableTreeWalker, useFocusable } from '@react-aria/focus';
|
|
2
|
+
import { getInteractionModality, useKeyboard } from '@react-aria/interactions';
|
|
3
|
+
import { isMac, mergeProps } from '@react-aria/utils';
|
|
4
|
+
import { useTableFocus } from '../contexts/focus.js';
|
|
5
|
+
import { focusTableChild } from '../utils/focus-table-child.js';
|
|
6
|
+
export function useTable(ref) {
|
|
7
|
+
const tableFocus = useTableFocus();
|
|
8
|
+
const restoreCellFocus = (e) => {
|
|
9
|
+
if (!tableFocus.focusedRowKey || !tableFocus.focusedColumnKey) {
|
|
10
|
+
// User hasn't interacted with the table yet.
|
|
11
|
+
// Focus the first or last cell, depending on which direction the user is tabbing from.
|
|
12
|
+
const lastFocusedElement = e.relatedTarget;
|
|
13
|
+
const cellElements = e.currentTarget.querySelectorAll('[data-cell-row-key][data-cell-column-key]');
|
|
14
|
+
let cellElementToFocus;
|
|
15
|
+
if (lastFocusedElement &&
|
|
16
|
+
e.currentTarget.compareDocumentPosition(lastFocusedElement) & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
17
|
+
cellElementToFocus = cellElements[cellElements.length - 1];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
cellElementToFocus = cellElements[0];
|
|
21
|
+
}
|
|
22
|
+
const { cellRowKey, cellColumnKey } = cellElementToFocus.dataset;
|
|
23
|
+
// We know the keys are defined, because we queried the DOM for elements that have them
|
|
24
|
+
tableFocus.setFocus(cellRowKey, cellColumnKey);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const element = e.currentTarget.querySelector(`[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'][data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']`);
|
|
28
|
+
if (element) {
|
|
29
|
+
// If focus is already within the cell, don't refocus
|
|
30
|
+
if (!element.contains(document.activeElement)) {
|
|
31
|
+
focusTableChild(element);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const { focusableProps } = useFocusable({
|
|
37
|
+
onFocus: (e) => {
|
|
38
|
+
// Ignore focus events bubbling through portals
|
|
39
|
+
if (!e.currentTarget.contains(e.target)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
restoreCellFocus(e);
|
|
43
|
+
},
|
|
44
|
+
}, ref);
|
|
45
|
+
const { keyboardProps } = useKeyboard({
|
|
46
|
+
onKeyDown: (e) => {
|
|
47
|
+
// Ignore keyboard events bubbling through portals
|
|
48
|
+
if (!e.currentTarget.contains(e.target)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const focusedCellElement = e.currentTarget.querySelector(`[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'][data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']`);
|
|
52
|
+
let cellElementToFocus = null;
|
|
53
|
+
let newChildFocusStrategy;
|
|
54
|
+
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
|
55
|
+
// Focus previous/next cell in the same row
|
|
56
|
+
const selector = `[data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}']:not([data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}'])`;
|
|
57
|
+
const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
58
|
+
walker.currentNode = focusedCellElement;
|
|
59
|
+
cellElementToFocus = e.key === 'ArrowLeft' ? walker.previousNode() : walker.nextNode();
|
|
60
|
+
newChildFocusStrategy = e.key === 'ArrowLeft' ? 'last' : 'first';
|
|
61
|
+
}
|
|
62
|
+
else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
63
|
+
// Focus previous/next cell in the same column
|
|
64
|
+
const selector = `[data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']:not([data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'])`;
|
|
65
|
+
const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
66
|
+
walker.currentNode = focusedCellElement;
|
|
67
|
+
cellElementToFocus = e.key === 'ArrowUp' ? walker.previousNode() : walker.nextNode();
|
|
68
|
+
}
|
|
69
|
+
else if (e.key === 'PageUp' || e.key === 'PageDown') {
|
|
70
|
+
// Move focus up/down by 5 rows
|
|
71
|
+
const selector = `[data-cell-column-key='${CSS.escape(tableFocus.focusedColumnKey)}']:not([data-cell-row-key='${CSS.escape(tableFocus.focusedRowKey)}'])`;
|
|
72
|
+
const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
73
|
+
walker.currentNode = focusedCellElement;
|
|
74
|
+
const advance = e.key === 'PageUp' ? walker.previousNode.bind(walker) : walker.nextNode.bind(walker);
|
|
75
|
+
// `advance()` will do nothing if there's no appropriate node found, so it's safe to just call it 5 times
|
|
76
|
+
for (let i = 0; i < 5; i++) {
|
|
77
|
+
advance();
|
|
78
|
+
}
|
|
79
|
+
cellElementToFocus = walker.currentNode;
|
|
80
|
+
}
|
|
81
|
+
else if (e.key === 'Home' || e.key === 'End') {
|
|
82
|
+
// If Ctrl/Cmd is pressed, move focus to the first/last cell of the table;
|
|
83
|
+
// otherwise, move focus to the first/last cell of the current row
|
|
84
|
+
const selector = '[data-cell-row-key][data-cell-column-key]';
|
|
85
|
+
const walker = getFocusableTreeWalker(e.currentTarget, { accept: (node) => node.matches(selector) });
|
|
86
|
+
walker.currentNode = isCtrlKeyPressed(e) ? e.currentTarget : focusedCellElement.parentElement;
|
|
87
|
+
cellElementToFocus = e.key === 'Home' ? walker.firstChild() : walker.lastChild();
|
|
88
|
+
newChildFocusStrategy = e.key === 'Home' ? 'first' : 'last';
|
|
89
|
+
}
|
|
90
|
+
else if (e.key === 'Tab') {
|
|
91
|
+
// Table is supposed to be a single Tab stop, but cells may contain elements that are tabbable (checkboxes, buttons, menus, etc.).
|
|
92
|
+
// We don't control the rendering of these elements, so we can't override their tabIndex to prevent tabbing.
|
|
93
|
+
// Instead, we detect when Tab key is pressed, and move focus manually to the guard element before/after the table,
|
|
94
|
+
// so that the browser default behavior will apply starting from that element rather than the currently focused one.
|
|
95
|
+
const tableElement = e.currentTarget;
|
|
96
|
+
const guardElement = e.shiftKey ? tableElement.previousElementSibling : tableElement.nextElementSibling;
|
|
97
|
+
if (guardElement) {
|
|
98
|
+
focusTableChild(guardElement);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// if we didn't handle anything, return early so we don't preventDefault
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (cellElementToFocus) {
|
|
107
|
+
const { cellRowKey, cellColumnKey } = cellElementToFocus.dataset;
|
|
108
|
+
// We know the keys are defined, because we queried the DOM for elements that have them
|
|
109
|
+
tableFocus.setFocus(cellRowKey, cellColumnKey, newChildFocusStrategy);
|
|
110
|
+
}
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
const customProps = {
|
|
115
|
+
role: 'grid',
|
|
116
|
+
// If no cell is tabbable within the table, make the table itself tabbable,
|
|
117
|
+
// otherwise the Tab key will just skip it
|
|
118
|
+
tabIndex: tableFocus.focusedRowKey && tableFocus.focusedColumnKey ? -1 : 0,
|
|
119
|
+
onFocusCapture: (e) => {
|
|
120
|
+
// If we're navigating into the table with a keyboard, focus the last focused cell instead of the first tabbable element
|
|
121
|
+
if (getInteractionModality() === 'keyboard' &&
|
|
122
|
+
!e.currentTarget.contains(e.relatedTarget) &&
|
|
123
|
+
e.currentTarget.contains(e.target)) {
|
|
124
|
+
restoreCellFocus(e);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
tableProps: mergeProps(focusableProps, keyboardProps, customProps),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// TODO: use `isCtrlKeyPressed` from `@react-aria/utils` after version upgrade
|
|
133
|
+
function isCtrlKeyPressed(e) {
|
|
134
|
+
if (isMac()) {
|
|
135
|
+
return e.metaKey;
|
|
136
|
+
}
|
|
137
|
+
return e.ctrlKey;
|
|
138
|
+
}
|
|
139
|
+
//# 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":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAA2B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhE,MAAM,UAAU,QAAQ,CAAC,GAAgC;IACvD,MAAM,UAAU,GAAG,aAAa,EAAE,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,2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;YACT,CAAC;iBAAM,CAAC;gBACN,wEAAwE;gBACxE,OAAO;YACT,CAAC;YAED,IAAI,kBAAkB,EAAE,CAAC;gBACvB,MAAM,EAAE,UAAU,EAAE,aAAa,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,sBAAsB,EAAE,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,UAAU,CAAC,cAAc,EAAE,aAAa,EAAE,WAAW,CAAC;KACnE,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,SAAS,gBAAgB,CAAC,CAAyC;IACjE,IAAI,KAAK,EAAE,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,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { mergeProps, useObjectRef } from '@react-aria/utils';
|
|
3
|
+
import { forwardRef } from '../../forward-ref.js';
|
|
4
|
+
import { useTableRowState } from './contexts/row-state.js';
|
|
5
|
+
import { useTableCell } from './hooks/use-table-cell.js';
|
|
6
|
+
function UNSTABLE_TableBodyCell({ children, UNSAFE_className, UNSAFE_style, columnKey, columnNumber, ...props }, ref) {
|
|
7
|
+
const cellRef = useObjectRef(ref);
|
|
8
|
+
const { rowKey } = useTableRowState();
|
|
9
|
+
const { cellProps } = useTableCell(cellRef, rowKey, columnKey);
|
|
10
|
+
return (_jsx("td", { ...mergeProps(props, cellProps), ref: cellRef, className: UNSAFE_className, style: UNSAFE_style, "aria-colindex": columnNumber, children: children }));
|
|
11
|
+
}
|
|
12
|
+
const _UNSTABLE_TableBodyCell = forwardRef(UNSTABLE_TableBodyCell, 'TableBodyCell');
|
|
13
|
+
export { _UNSTABLE_TableBodyCell as UNSTABLE_TableBodyCell };
|
|
14
|
+
//# 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,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;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,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACtC,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAE/D,OAAO,CACL,gBACM,UAAU,CAAC,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,UAAU,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;AAEpF,OAAO,EAAE,uBAAuB,IAAI,sBAAsB,EAAE,CAAC","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,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from '../../forward-ref.js';
|
|
3
|
+
function UNSTABLE_TableBody({ children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
4
|
+
return (_jsx("tbody", { ...props, ref: ref, className: UNSAFE_className, style: UNSAFE_style, children: children }));
|
|
5
|
+
}
|
|
6
|
+
const _UNSTABLE_TableBody = forwardRef(UNSTABLE_TableBody, 'TableBody');
|
|
7
|
+
export { _UNSTABLE_TableBody as UNSTABLE_TableBody };
|
|
8
|
+
//# 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,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAOlD,SAAS,kBAAkB,CACzB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAA2B,EAC/E,GAA0C;IAE1C,OAAO,CACL,mBAAW,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,YACzE,QAAQ,GACH,CACT,CAAC;AACJ,CAAC;AAED,MAAM,mBAAmB,GAAG,UAAU,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAExE,OAAO,EAAE,mBAAmB,IAAI,kBAAkB,EAAE,CAAC","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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { CommonProps, LabellableProps } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_TableContainerProps extends CommonProps, Omit<LabellableProps, 'label'> {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare const _UNSTABLE_TableContainer: (props: UNSTABLE_TableContainerProps & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
7
|
+
export { _UNSTABLE_TableContainer as UNSTABLE_TableContainer };
|
|
8
|
+
//# sourceMappingURL=table-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-container.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-container.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrF,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,4BAA6B,SAAQ,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC;IAC/F,QAAQ,EAAE,SAAS,CAAC;CACrB;AA+CD,QAAA,MAAM,wBAAwB,8KAAwE,CAAC;AAEvG,OAAO,EAAE,wBAAwB,IAAI,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFocusRing } from '@react-aria/focus';
|
|
3
|
+
import { mergeProps, useObjectRef } from '@react-aria/utils';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useLayoutEffect, useState } from 'react';
|
|
6
|
+
import { forwardRef } from '../../forward-ref.js';
|
|
7
|
+
import { withStyleProps } from '../../with-style-props.js';
|
|
8
|
+
function UNSTABLE_TableContainer({ children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
9
|
+
const containerRef = useObjectRef(ref);
|
|
10
|
+
const { focusProps, isFocusVisible } = useFocusRing();
|
|
11
|
+
const [isScrollable, setIsScrollable] = useState(false);
|
|
12
|
+
useLayoutEffect(() => {
|
|
13
|
+
const containerElement = containerRef.current;
|
|
14
|
+
const isSSR = typeof window === 'undefined';
|
|
15
|
+
let containerResizeObserver;
|
|
16
|
+
if (containerElement && !isSSR) {
|
|
17
|
+
containerResizeObserver = new window.ResizeObserver((entries) => {
|
|
18
|
+
if (entries[0]) {
|
|
19
|
+
setIsScrollable(entries[0].target.scrollWidth > entries[0].target.clientWidth);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
containerResizeObserver.observe(containerElement);
|
|
23
|
+
}
|
|
24
|
+
return () => {
|
|
25
|
+
if (containerElement && containerResizeObserver) {
|
|
26
|
+
containerResizeObserver.unobserve(containerElement);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}, [containerRef]);
|
|
30
|
+
return (_jsx("div", { ...mergeProps(props, focusProps), ref: containerRef, className: clsx('cim-table-container', UNSAFE_className), style: UNSAFE_style, tabIndex: isScrollable ? 0 : -1, "data-focus-visible": isFocusVisible || undefined, children: children }));
|
|
31
|
+
}
|
|
32
|
+
const _UNSTABLE_TableContainer = withStyleProps(forwardRef(UNSTABLE_TableContainer), 'TableContainer');
|
|
33
|
+
export { _UNSTABLE_TableContainer as UNSTABLE_TableContainer };
|
|
34
|
+
//# sourceMappingURL=table-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-container.js","sourceRoot":"","sources":["../../../../src/components/table/table-container.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,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ChD,uBAAuB,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,iBACM,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EACjC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,EACxD,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,wBACX,cAAc,IAAI,SAAS,YAE9C,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB,GAAG,cAAc,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,gBAAgB,CAAC,CAAC;AAEvG,OAAO,EAAE,wBAAwB,IAAI,uBAAuB,EAAE,CAAC","sourcesContent":["import { useFocusRing } from '@react-aria/focus';\nimport { mergeProps, useObjectRef } from '@react-aria/utils';\nimport clsx from 'clsx';\nimport { useLayoutEffect, useState, type ForwardedRef, type ReactNode } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { CommonProps, LabellableProps } from '../types.js';\n\nexport interface UNSTABLE_TableContainerProps extends CommonProps, Omit<LabellableProps, 'label'> {\n children: ReactNode;\n}\n\nfunction UNSTABLE_TableContainer(\n { children, UNSAFE_className, UNSAFE_style, ...props }: UNSTABLE_TableContainerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const containerRef = useObjectRef(ref);\n const { focusProps, isFocusVisible } = useFocusRing();\n const [isScrollable, setIsScrollable] = useState(false);\n\n useLayoutEffect(() => {\n const containerElement = containerRef.current;\n const isSSR = typeof window === 'undefined';\n\n let containerResizeObserver: ResizeObserver | undefined;\n\n if (containerElement && !isSSR) {\n containerResizeObserver = new window.ResizeObserver((entries) => {\n if (entries[0]) {\n setIsScrollable(entries[0].target.scrollWidth > entries[0].target.clientWidth);\n }\n });\n\n containerResizeObserver.observe(containerElement);\n }\n\n return () => {\n if (containerElement && containerResizeObserver) {\n containerResizeObserver.unobserve(containerElement);\n }\n };\n }, [containerRef]);\n\n return (\n <div\n {...mergeProps(props, focusProps)}\n ref={containerRef}\n className={clsx('cim-table-container', UNSAFE_className)}\n style={UNSAFE_style}\n tabIndex={isScrollable ? 0 : -1}\n data-focus-visible={isFocusVisible || undefined}\n >\n {children}\n </div>\n );\n}\n\nconst _UNSTABLE_TableContainer = withStyleProps(forwardRef(UNSTABLE_TableContainer), 'TableContainer');\n\nexport { _UNSTABLE_TableContainer as UNSTABLE_TableContainer };\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { CommonProps } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_TableHeaderCellProps 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_TableHeaderCell: (props: UNSTABLE_TableHeaderCellProps & import("react").RefAttributes<HTMLTableCellElement>) => import("react").JSX.Element | null;
|
|
25
|
+
export { _UNSTABLE_TableHeaderCell as UNSTABLE_TableHeaderCell };
|
|
26
|
+
//# sourceMappingURL=table-header-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-header-cell.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header-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,6BAA8B,SAAQ,WAAW;IAChE,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAwBD,QAAA,MAAM,yBAAyB,oIAA0D,CAAC;AAE1F,OAAO,EAAE,yBAAyB,IAAI,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { mergeProps, useObjectRef } from '@react-aria/utils';
|
|
3
|
+
import { forwardRef } from '../../forward-ref.js';
|
|
4
|
+
import { useTableRowState } from './contexts/row-state.js';
|
|
5
|
+
import { useTableCell } from './hooks/use-table-cell.js';
|
|
6
|
+
function UNSTABLE_TableHeaderCell({ children, UNSAFE_className, UNSAFE_style, columnKey, columnNumber, ...props }, ref) {
|
|
7
|
+
const cellRef = useObjectRef(ref);
|
|
8
|
+
const { rowKey } = useTableRowState();
|
|
9
|
+
const { cellProps } = useTableCell(cellRef, rowKey, columnKey);
|
|
10
|
+
return (_jsx("th", { ...mergeProps(props, cellProps), ref: cellRef, className: UNSAFE_className, style: UNSAFE_style, scope: "col", "aria-colindex": columnNumber, children: children }));
|
|
11
|
+
}
|
|
12
|
+
const _UNSTABLE_TableHeaderCell = forwardRef(UNSTABLE_TableHeaderCell, 'TableHeaderCell');
|
|
13
|
+
export { _UNSTABLE_TableHeaderCell as UNSTABLE_TableHeaderCell };
|
|
14
|
+
//# sourceMappingURL=table-header-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-header-cell.js","sourceRoot":"","sources":["../../../../src/components/table/table-header-cell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAwBzD,SAAS,wBAAwB,CAC/B,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,KAAK,EAAiC,EAC9G,GAAuC;IAEvC,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACtC,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAE/D,OAAO,CACL,gBACM,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,EAChC,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAC,KAAK,mBACI,YAAY,YAE1B,QAAQ,GACN,CACN,CAAC;AACJ,CAAC;AAED,MAAM,yBAAyB,GAAG,UAAU,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAAC;AAE1F,OAAO,EAAE,yBAAyB,IAAI,wBAAwB,EAAE,CAAC","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_TableHeaderCellProps 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_TableHeaderCell(\n { children, UNSAFE_className, UNSAFE_style, columnKey, columnNumber, ...props }: UNSTABLE_TableHeaderCellProps,\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 <th\n {...mergeProps(props, cellProps)}\n ref={cellRef}\n className={UNSAFE_className}\n style={UNSAFE_style}\n scope=\"col\"\n aria-colindex={columnNumber}\n >\n {children}\n </th>\n );\n}\n\nconst _UNSTABLE_TableHeaderCell = forwardRef(UNSTABLE_TableHeaderCell, 'TableHeaderCell');\n\nexport { _UNSTABLE_TableHeaderCell as UNSTABLE_TableHeaderCell };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { CommonProps } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_TableHeaderProps extends CommonProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare const _UNSTABLE_TableHeader: (props: UNSTABLE_TableHeaderProps & import("react").RefAttributes<HTMLTableSectionElement>) => import("react").JSX.Element | null;
|
|
7
|
+
export { _UNSTABLE_TableHeader as UNSTABLE_TableHeader };
|
|
8
|
+
//# sourceMappingURL=table-header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-header.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header.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,yBAA0B,SAAQ,WAAW;IAC5D,QAAQ,EAAE,SAAS,CAAC;CACrB;AAaD,QAAA,MAAM,qBAAqB,mIAAkD,CAAC;AAE9E,OAAO,EAAE,qBAAqB,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from '../../forward-ref.js';
|
|
3
|
+
function UNSTABLE_TableHeader({ children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
4
|
+
return (_jsx("thead", { ...props, ref: ref, className: UNSAFE_className, style: UNSAFE_style, children: children }));
|
|
5
|
+
}
|
|
6
|
+
const _UNSTABLE_TableHeader = forwardRef(UNSTABLE_TableHeader, 'TableHeader');
|
|
7
|
+
export { _UNSTABLE_TableHeader as UNSTABLE_TableHeader };
|
|
8
|
+
//# sourceMappingURL=table-header.js.map
|