@economic/taco 1.0.8 → 1.1.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/dist/components/Menu/Context.d.ts +0 -5
- package/dist/components/Menu/Menu.d.ts +0 -3
- package/dist/components/Table/hooks/useTable.d.ts +3 -0
- package/dist/components/Table/types.d.ts +3 -0
- package/dist/esm/components/Button/util.js +6 -6
- package/dist/esm/components/Button/util.js.map +1 -1
- package/dist/esm/components/Menu/Context.js.map +1 -1
- package/dist/esm/components/Menu/Menu.js +9 -18
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/Menu/components/Content.js +1 -22
- package/dist/esm/components/Menu/components/Content.js.map +1 -1
- package/dist/esm/components/Menu/components/Header.js +1 -21
- package/dist/esm/components/Menu/components/Header.js.map +1 -1
- package/dist/esm/components/Menu/components/Item.js +2 -50
- package/dist/esm/components/Menu/components/Item.js.map +1 -1
- package/dist/esm/components/Menu/components/Separator.js +1 -25
- package/dist/esm/components/Menu/components/Separator.js.map +1 -1
- package/dist/esm/components/Menu/components/Trigger.js +1 -13
- package/dist/esm/components/Menu/components/Trigger.js.map +1 -1
- package/dist/esm/components/Table/components/WindowedTable.js +16 -10
- package/dist/esm/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js +8 -3
- package/dist/esm/components/Table/hooks/useTableKeyboardNavigation.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +1 -1
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/index.css +2 -2
- package/dist/index.css +2 -2
- package/dist/taco.cjs.development.js +46 -167
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +3 -2
- package/types.json +390 -346
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"WindowedTable.js","sources":["../../../../../src/components/Table/components/WindowedTable.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { PluginHook } from 'react-table';\nimport { areEqual, VariableSizeList } from 'react-window';\nimport InfiniteLoader from 'react-window-infinite-loader';\nimport { TableProps, ForwardedGenericTableWithStatics, TableRef } from '../types';\nimport { useTable } from '../hooks/useTable';\nimport { useBoundingClientRectListener } from '../../../utils/hooks/useBoundingClientRectListener';\nimport { useProxiedRef } from '../../../utils/hooks/useProxiedRef';\nimport { Row } from '../util/renderRow';\nimport { DefaultEmptyState, BaseTable } from './BaseTable';\nimport { useLocalization } from '../../Provider/Provider';\n\nconst ROW_HEIGHT = 40;\n\nconst VariableRow = React.memo(({ data, index, style: { height: _, ...style } }: any) => {\n const { texts } = useLocalization();\n const { rows, setRowHeight, rowProps, tableProps, instance, prepareRow, rowHeights } = data;\n const row = rows[index];\n const ref = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (ref?.current) {\n setRowHeight(index, ref.current.getBoundingClientRect().height);\n }\n }, [rowHeights[index]]);\n\n if (row) {\n prepareRow(row, index);\n\n return (\n <Row\n {...rowProps}\n style={style}\n key={index}\n index={index}\n row={row}\n instance={instance}\n headerGroups={tableProps.headerGroups}\n setRowHeight={setRowHeight}\n ref={ref}\n />\n );\n }\n\n return (\n <div className=\"yt-table__row\" role=\"row\" style={style}>\n <div className=\"yt-table__cell text-grey-dark\">{texts.table.loading}</div>\n </div>\n );\n}, areEqual);\n\nconst getAverageRowHeight = (rowHeights = {}) => {\n const keys = Object.keys(rowHeights);\n const estimatedHeight = keys.reduce((p, i) => p + rowHeights[i], 0);\n return estimatedHeight / keys.length;\n};\n\nexport const WindowedTable = React.forwardRef(function WindowedTable<T>(\n props: TableProps<T> & { plugins: PluginHook<{}>[] },\n ref: React.Ref<TableRef>\n) {\n const tableRef: any = useProxiedRef<HTMLDivElement>(ref);\n const { emptyStateRenderer = DefaultEmptyState, length, loadMore, ...otherProps } = props;\n const { rowProps, tableProps, rows, prepareRow, instance, state } = useTable<T>({ ...otherProps, windowed: true }, tableRef);\n\n // determine heights for windowing calculations\n const headerRef = React.useRef<HTMLDivElement>(null);\n const rowsRef = React.useRef<any>(null);\n const tableDimensions = useBoundingClientRectListener(tableRef);\n const headerDimensions = useBoundingClientRectListener(headerRef);\n const height = tableDimensions && headerDimensions ? tableDimensions.height - headerDimensions.height : null;\n\n // variable row height calculations\n const estimatedRowHeight = rowProps.rowHeight || ROW_HEIGHT;\n const rowHeights = React.useRef<Record<string, number>>({});\n const setRowHeight = React.useCallback((index: number, size: number) => {\n if (rowHeights.current[index] !== size) {\n rowHeights.current = {\n ...rowHeights.current,\n [index]: size,\n };\n\n if (rowsRef.current) {\n rowsRef.current.resetAfterIndex(0);\n }\n }\n }, []);\n const getRowHeight = React.useCallback(index => rowHeights.current[index] || estimatedRowHeight, []);\n\n React.useEffect(() => {\n if (rowsRef && rowsRef.current && rowProps.activeIndex !== undefined) {\n rowsRef.current.scrollToItem(rowProps.activeIndex);\n }\n }, [rowProps.activeIndex]);\n\n // trigger recalculation of variable row heights if the data changes\n React.useEffect(() => {\n rowHeights.current = {};\n\n if (rowsRef.current) {\n rowsRef.current.resetAfterIndex(0);\n }\n }, [rows.length]);\n\n const contentHeight = estimatedRowHeight * props.data.length || 0;\n const isScrollbarVisible = height !== null ? contentHeight > height : false;\n\n const className = cn(tableProps.className, 'yt-table--windowed', { 'table-with-scrollbar': isScrollbarVisible });\n\n let list;\n\n const itemData = {\n rows,\n setRowHeight,\n rowProps,\n tableProps,\n instance,\n prepareRow,\n state,\n rowHeights: rowHeights.current,\n };\n\n if (height && rows.length) {\n const listProps = {\n height,\n itemData,\n estimatedItemSize: getAverageRowHeight(rowHeights.current),\n itemSize: getRowHeight,\n width: '100%',\n };\n\n if (loadMore && length) {\n const isLoaded = (index: number) => !!rows[index];\n\n list = (\n <InfiniteLoader isItemLoaded={isLoaded} itemCount={length} loadMoreItems={loadMore as any}>\n {({ onItemsRendered, ref }: any) => (\n <VariableSizeList\n {...listProps}\n itemCount={length}\n onItemsRendered={onItemsRendered}\n ref={list => {\n ref(list);\n rowsRef.current = list;\n }}\n >\n {VariableRow}\n </VariableSizeList>\n )}\n </InfiniteLoader>\n );\n } else {\n list = (\n <VariableSizeList {...listProps} itemCount={rows.length} ref={rowsRef}>\n {VariableRow}\n </VariableSizeList>\n );\n }\n }\n\n return (\n <BaseTable {...tableProps} className={className} headerRef={headerRef} ref={tableRef}>\n {list ? list : emptyStateRenderer()}\n </BaseTable>\n );\n}) as ForwardedGenericTableWithStatics;\n\nWindowedTable.Column = () => null;\nWindowedTable.Group = () => null;\n"],"names":["ROW_HEIGHT","VariableRow","React","memo","data","index","style","useLocalization","texts","rows","setRowHeight","rowProps","tableProps","instance","prepareRow","rowHeights","row","ref","useRef","useEffect","current","getBoundingClientRect","height","Row","key","headerGroups","className","role","table","loading","areEqual","getAverageRowHeight","keys","Object","estimatedHeight","reduce","p","i","length","WindowedTable","forwardRef","props","tableRef","useProxiedRef","emptyStateRenderer","DefaultEmptyState","loadMore","otherProps","useTable","windowed","state","headerRef","rowsRef","tableDimensions","useBoundingClientRectListener","headerDimensions","estimatedRowHeight","rowHeight","useCallback","size","resetAfterIndex","getRowHeight","activeIndex","undefined","scrollToItem","contentHeight","isScrollbarVisible","cn","list","itemData","listProps","estimatedItemSize","itemSize","width","isLoaded","InfiniteLoader","isItemLoaded","itemCount","loadMoreItems","onItemsRendered","VariableSizeList","BaseTable","Column","Group"],"mappings":";;;;;;;;;;;;;;AAaA,IAAMA,UAAU,GAAG,EAAnB;AAEA,IAAMC,WAAW,gBAAGC,cAAK,CAACC,IAAN,CAAW;MAAGC,YAAAA;MAAMC,aAAAA;wBAAOC;MAAuBA;;AAClE,yBAAkBC,eAAe,EAAjC;AAAA,MAAQC,KAAR,oBAAQA,KAAR;;AACA,MAAQC,IAAR,GAAuFL,IAAvF,CAAQK,IAAR;AAAA,MAAcC,YAAd,GAAuFN,IAAvF,CAAcM,YAAd;AAAA,MAA4BC,QAA5B,GAAu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AAG,SAAXA,QAAW,CAACrE,KAAD;AAAA,eAAmB,CAAC,CAACI,IAAI,CAACJ,KAAD,CAAzB;AAAA,OAAjB;;AAEA+D,MAAAA,IAAI,GACAlE,4BAAA,CAACyE,cAAD;AAAgBC,QAAAA,YAAY,EAAEF;AAAUG,QAAAA,SAAS,EAAEvC;AAAQwC,QAAAA,aAAa,EAAEhC;OAA1E,EACK;AAAA,YAAGiC,eAAH,SAAGA,eAAH;AAAA,YAAoB9D,KAApB,SAAoBA,GAApB;AAAA,eACGf,4BAAA,CAAC8E,gBAAD,oBACQV;AACJO,UAAAA,SAAS,EAAEvC;AACXyC,UAAAA,eAAe,EAAEA;AACjB9D,UAAAA,GAAG,EAAE,aAAAmD,IAAI;AACLnD,YAAAA,KAAG,CAACmD,IAAD,CAAH;;AACAhB,YAAAA,OAAO,CAAChC,OAAR,GAAkBgD,IAAlB;AACH;UAPL,EASKnE,WATL,CADH;AAAA,OADL,CADJ;AAiBH,KApBD,MAoBO;AACHmE,MAAAA,IAAI,GACAlE,4BAAA,CAAC8E,gBAAD,oBAAsBV;AAAWO,QAAAA,SAAS,EAAEpE,IAAI,CAAC6B;AAAQrB,QAAAA,GAAG,EAAEmC;QAA9D,EACKnD,WADL,CADJ;AAKH;AACJ;;AAED,SACIC,4BAAA,CAAC+E,SAAD,oBAAerE;AAAYc,IAAAA,SAAS,EAAEA;AAAWyB,IAAAA,SAAS,EAAEA;AAAWlC,IAAAA,GAAG,EAAEyB;IAA5E,EACK0B,IAAI,GAAGA,IAAH,GAAUxB,kBAAkB,EADrC,CADJ;AAKH,CA5G4B;;AA8G7BL,aAAa,CAAC2C,MAAd,GAAuB;AAAA,SAAM,IAAN;AAAA,CAAvB;;AACA3C,aAAa,CAAC4C,KAAd,GAAsB;AAAA,SAAM,IAAN;AAAA,CAAtB;;;;"}
|
1
|
+
{"version":3,"file":"WindowedTable.js","sources":["../../../../../src/components/Table/components/WindowedTable.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { PluginHook } from 'react-table';\nimport { areEqual, VariableSizeList } from 'react-window';\nimport InfiniteLoader from 'react-window-infinite-loader';\nimport { TableProps, ForwardedGenericTableWithStatics, TableRef } from '../types';\nimport { useTable } from '../hooks/useTable';\nimport { useBoundingClientRectListener } from '../../../utils/hooks/useBoundingClientRectListener';\nimport { useProxiedRef } from '../../../utils/hooks/useProxiedRef';\nimport { Row } from '../util/renderRow';\nimport { DefaultEmptyState, BaseTable } from './BaseTable';\nimport { useLocalization } from '../../Provider/Provider';\n\nconst ROW_HEIGHT = 40;\n\nconst VariableRow = React.memo(({ data, index, style: { height: _, ...style } }: any) => {\n const { texts } = useLocalization();\n const { rows, setRowHeight, rowProps, tableProps, instance, prepareRow, rowHeights } = data;\n const row = rows[index];\n const ref = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (ref?.current) {\n setRowHeight(index, ref.current.getBoundingClientRect().height);\n }\n }, [rowHeights[index]]);\n\n if (row) {\n prepareRow(row, index);\n\n return (\n <Row\n {...rowProps}\n style={style}\n key={index}\n index={index}\n row={row}\n instance={instance}\n headerGroups={tableProps.headerGroups}\n setRowHeight={setRowHeight}\n ref={ref}\n />\n );\n }\n\n return (\n <div className=\"yt-table__row\" role=\"row\" style={style}>\n <div className=\"yt-table__cell text-grey-dark\">{texts.table.loading}</div>\n </div>\n );\n}, areEqual);\n\nconst getAverageRowHeight = (rowHeights = {}) => {\n const keys = Object.keys(rowHeights);\n const estimatedHeight = keys.reduce((p, i) => p + rowHeights[i], 0);\n return estimatedHeight / keys.length;\n};\n\nexport const WindowedTable = React.forwardRef(function WindowedTable<T>(\n props: TableProps<T> & { plugins: PluginHook<{}>[] },\n ref: React.Ref<TableRef>\n) {\n const tableRef: any = useProxiedRef<HTMLDivElement>(ref);\n const { emptyStateRenderer = DefaultEmptyState, length, loadMore, ...otherProps } = props;\n const { rowProps, tableProps, rows, prepareRow, instance, state } = useTable<T>({ ...otherProps, windowed: true }, tableRef);\n\n // determine heights for windowing calculations\n const headerRef = React.useRef<HTMLDivElement>(null);\n const [rowsRef, setRowsRef] = React.useState<any>(null);\n const tableDimensions = useBoundingClientRectListener(tableRef);\n const headerDimensions = useBoundingClientRectListener(headerRef);\n const height = tableDimensions && headerDimensions ? tableDimensions.height - headerDimensions.height : null;\n\n // variable row height calculations\n const estimatedRowHeight = rowProps.rowHeight || ROW_HEIGHT;\n const rowHeights = React.useRef<Record<string, number>>({});\n const setRowHeight = React.useCallback((index: number, size: number) => {\n if (rowHeights.current[index] !== size) {\n rowHeights.current = {\n ...rowHeights.current,\n [index]: size,\n };\n\n if (rowsRef) {\n rowsRef.resetAfterIndex(0);\n }\n }\n }, []);\n const getRowHeight = React.useCallback(index => rowHeights.current[index] || estimatedRowHeight, []);\n\n React.useEffect(() => {\n if (rowsRef && rowProps.activeIndex !== undefined) {\n rowsRef.scrollToItem(rowProps.activeIndex, 'start');\n }\n }, [rowsRef, rowProps.activeIndex]);\n\n // trigger recalculation of variable row heights if the data changes\n React.useEffect(() => {\n rowHeights.current = {};\n\n if (rowsRef) {\n rowsRef.resetAfterIndex(0);\n }\n }, [rows.length]);\n\n const contentHeight = estimatedRowHeight * props.data.length || 0;\n const isScrollbarVisible = height !== null ? contentHeight > height : false;\n\n const className = cn(tableProps.className, 'yt-table--windowed', { 'table-with-scrollbar': isScrollbarVisible });\n\n let list;\n\n const itemData = {\n rows,\n setRowHeight,\n rowProps,\n tableProps,\n instance,\n prepareRow,\n state,\n rowHeights: rowHeights.current,\n };\n\n if (height && rows.length) {\n const listProps = {\n height,\n itemData,\n estimatedItemSize: getAverageRowHeight(rowHeights.current),\n itemSize: getRowHeight,\n width: '100%',\n };\n\n if (loadMore && length) {\n const isLoaded = (index: number) => !!rows[index];\n\n list = (\n <InfiniteLoader isItemLoaded={isLoaded} itemCount={length} loadMoreItems={loadMore as any}>\n {({ onItemsRendered, ref }: any) => (\n <VariableSizeList\n {...listProps}\n itemCount={length}\n onItemsRendered={onItemsRendered}\n ref={list => {\n ref(list);\n setRowsRef(list);\n }}\n >\n {VariableRow}\n </VariableSizeList>\n )}\n </InfiniteLoader>\n );\n } else {\n list = (\n <VariableSizeList\n {...listProps}\n itemCount={rows.length}\n ref={ref => {\n setRowsRef(ref);\n }}\n >\n {VariableRow}\n </VariableSizeList>\n );\n }\n }\n\n return (\n <BaseTable {...tableProps} className={className} headerRef={headerRef} ref={tableRef}>\n {list ? list : emptyStateRenderer()}\n </BaseTable>\n );\n}) as ForwardedGenericTableWithStatics;\n\nWindowedTable.Column = () => null;\nWindowedTable.Group = () => null;\n"],"names":["ROW_HEIGHT","VariableRow","React","memo","data","index","style","useLocalization","texts","rows","setRowHeight","rowProps","tableProps","instance","prepareRow","rowHeights","row","ref","useRef","useEffect","current","getBoundingClientRect","height","Row","key","headerGroups","className","role","table","loading","areEqual","getAverageRowHeight","keys","Object","estimatedHeight","reduce","p","i","length","WindowedTable","forwardRef","props","tableRef","useProxiedRef","emptyStateRenderer","DefaultEmptyState","loadMore","otherProps","useTable","windowed","state","headerRef","useState","rowsRef","setRowsRef","tableDimensions","useBoundingClientRectListener","headerDimensions","estimatedRowHeight","rowHeight","useCallback","size","resetAfterIndex","getRowHeight","activeIndex","undefined","scrollToItem","contentHeight","isScrollbarVisible","cn","list","itemData","listProps","estimatedItemSize","itemSize","width","isLoaded","InfiniteLoader","isItemLoaded","itemCount","loadMoreItems","onItemsRendered","VariableSizeList","BaseTable","Column","Group"],"mappings":";;;;;;;;;;;;;;AAaA,IAAMA,UAAU,GAAG,EAAnB;AAEA,IAAMC,WAAW,gBAAGC,cAAK,CAACC,IAAN,CAAW;MAAGC,YAAAA;MAAMC,aAAAA;wBAAOC;MAAuBA;;AAClE,yBAAkBC,eAAe,EAAjC;AAAA,MAAQC,KAAR,oBAAQA,KAAR;;AACA,MAAQC,IAAR,GAAuFL,IAAvF,CAAQK,IAAR;AAAA,MAAcC,YAAd,GAAuFN,IAAvF,CAAcM,YAAd;AAAA,MAA4BC,QAA5B,GAAu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ACI,IAAI,CAACJ,KAAD,CAAzB;AAAA,OAAjB;;AAEAiE,MAAAA,IAAI,GACApE,4BAAA,CAAC2E,cAAD;AAAgBC,QAAAA,YAAY,EAAEF;AAAUG,QAAAA,SAAS,EAAEzC;AAAQ0C,QAAAA,aAAa,EAAElC;OAA1E,EACK;AAAA,YAAGmC,eAAH,SAAGA,eAAH;AAAA,YAAoBhE,KAApB,SAAoBA,GAApB;AAAA,eACGf,4BAAA,CAACgF,gBAAD,oBACQV;AACJO,UAAAA,SAAS,EAAEzC;AACX2C,UAAAA,eAAe,EAAEA;AACjBhE,UAAAA,GAAG,EAAE,aAAAqD,IAAI;AACLrD,YAAAA,KAAG,CAACqD,IAAD,CAAH;;AACAhB,YAAAA,UAAU,CAACgB,IAAD,CAAV;AACH;UAPL,EASKrE,WATL,CADH;AAAA,OADL,CADJ;AAiBH,KApBD,MAoBO;AACHqE,MAAAA,IAAI,GACApE,4BAAA,CAACgF,gBAAD,oBACQV;AACJO,QAAAA,SAAS,EAAEtE,IAAI,CAAC6B;AAChBrB,QAAAA,GAAG,EAAE,aAAAA,KAAG;AACJqC,UAAAA,UAAU,CAACrC,KAAD,CAAV;AACH;QALL,EAOKhB,WAPL,CADJ;AAWH;AACJ;;AAED,SACIC,4BAAA,CAACiF,SAAD,oBAAevE;AAAYc,IAAAA,SAAS,EAAEA;AAAWyB,IAAAA,SAAS,EAAEA;AAAWlC,IAAAA,GAAG,EAAEyB;IAA5E,EACK4B,IAAI,GAAGA,IAAH,GAAU1B,kBAAkB,EADrC,CADJ;AAKH,CAlH4B;;AAoH7BL,aAAa,CAAC6C,MAAd,GAAuB;AAAA,SAAM,IAAN;AAAA,CAAvB;;AACA7C,aAAa,CAAC8C,KAAd,GAAsB;AAAA,SAAM,IAAN;AAAA,CAAtB;;;;"}
|
@@ -2,13 +2,18 @@ import React__default from 'react';
|
|
2
2
|
import keycode from 'keycode';
|
3
3
|
import { getNextIndexFromKeycode } from '../../../utils/hooks/useListKeyboardNavigation.js';
|
4
4
|
import { sanitizeRowProps } from '../util.js';
|
5
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
5
6
|
|
6
7
|
var useTableKeyboardNavigation = function useTableKeyboardNavigation(props, rows, rowProps, ref) {
|
7
8
|
var useGlobalKeyboardNavigation = props.dangerouslyHijackGlobalKeyboardNavigation;
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
|
10
|
+
var _useControllableState = useControllableState({
|
11
|
+
prop: props.activeIndex,
|
12
|
+
defaultProp: props.defaultActiveIndex !== undefined ? props.defaultActiveIndex : useGlobalKeyboardNavigation ? 0 : undefined,
|
13
|
+
onChange: props.onChangeActiveIndex
|
14
|
+
}),
|
15
|
+
activeIndex = _useControllableState[0],
|
16
|
+
setActiveIndex = _useControllableState[1];
|
12
17
|
|
13
18
|
var onKeyDown = function onKeyDown(event) {
|
14
19
|
var _document$activeEleme;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableKeyboardNavigation.js","sources":["../../../../../src/components/Table/hooks/useTableKeyboardNavigation.ts"],"sourcesContent":["import React from 'react';\nimport keycode from 'keycode';\nimport { getNextIndexFromKeycode } from '../../../utils/hooks/useListKeyboardNavigation';\nimport { sanitizeRowProps } from '../util';\nimport { TableProps } from '../types';\n\nexport const useTableKeyboardNavigation = <T extends {}>(\n props: TableProps<T>,\n rows: any[],\n rowProps: any,\n ref: React.RefObject<HTMLDivElement>\n): [\n number | undefined,\n (index: number) => void,\n (event: React.KeyboardEvent<HTMLElement>) => void,\n (event: React.FocusEvent<HTMLElement>) => void\n] => {\n const useGlobalKeyboardNavigation = props.dangerouslyHijackGlobalKeyboardNavigation;\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>(useGlobalKeyboardNavigation ? 0 : undefined);\n\n const onKeyDown = (event: KeyboardEvent): void => {\n const isModifierKeyPressed = event.metaKey || event.ctrlKey || event.altKey || event.shiftKey;\n\n if (\n useGlobalKeyboardNavigation &&\n document.activeElement !== ref.current &&\n document.activeElement?.getAttribute('type') !== 'search' &&\n document.activeElement !== document.body\n ) {\n return;\n }\n // abort key handling if other elements inside table are focused and we don't use global keyboard navigation\n if (!useGlobalKeyboardNavigation && document.activeElement !== ref.current) {\n return;\n }\n\n if (activeIndex !== undefined) {\n const currentRow = rows[activeIndex];\n\n if (currentRow) {\n const sanitizedRow = sanitizeRowProps(currentRow, rowProps.rowExpansionRenderer);\n\n if (rowProps.onRowClick && event.keyCode === keycode('enter')) {\n event.preventDefault();\n rowProps.onRowClick(sanitizedRow);\n return;\n }\n\n if (currentRow.toggleRowSelected && event.keyCode === keycode('space')) {\n event.preventDefault();\n currentRow.toggleRowSelected();\n return;\n }\n\n if (currentRow.toggleRowExpanded) {\n if (currentRow.isExpanded && event.keyCode === keycode('left')) {\n event.preventDefault();\n currentRow.toggleRowExpanded();\n return;\n } else if (!currentRow.isExpanded && event.keyCode === keycode('right')) {\n event.preventDefault();\n currentRow.toggleRowExpanded();\n return;\n }\n }\n\n // inline editing\n if (currentRow.toggleRowEditing) {\n if (currentRow.canEdit && !currentRow.isEditing) {\n if (rowProps.onRowCreate && event.shiftKey && event.keyCode === keycode('n')) {\n event.preventDefault();\n\n if (!currentRow.isExpanded) {\n currentRow.toggleRowExpanded();\n }\n\n rowProps.onRowCreate(sanitizedRow, event);\n return;\n }\n\n if (event.keyCode === keycode('e')) {\n event.preventDefault();\n currentRow.toggleRowEditing();\n return;\n }\n }\n }\n\n if (rowProps.onRowEdit && event.keyCode === keycode('e') && !isModifierKeyPressed) {\n event.preventDefault();\n rowProps.onRowEdit(sanitizedRow, event);\n return;\n }\n\n if (rowProps.onRowCopy && event.keyCode === keycode('c') && !isModifierKeyPressed) {\n event.preventDefault();\n rowProps.onRowCopy(sanitizedRow, event);\n return;\n }\n\n if (rowProps.onRowDelete && event.keyCode === keycode('delete') && !isModifierKeyPressed) {\n event.preventDefault();\n rowProps.onRowDelete(sanitizedRow, event);\n return;\n }\n }\n }\n\n const nextIndex = getNextIndexFromKeycode(event.keyCode, rows.length, activeIndex);\n\n if (nextIndex !== undefined) {\n event.preventDefault();\n setActiveIndex(nextIndex);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n if (!useGlobalKeyboardNavigation) {\n onKeyDown(event.nativeEvent);\n }\n };\n\n React.useEffect(() => {\n if (useGlobalKeyboardNavigation) {\n window.addEventListener('keydown', onKeyDown);\n }\n\n return () => {\n if (useGlobalKeyboardNavigation) {\n window.removeEventListener('keydown', onKeyDown);\n }\n };\n }, [onKeyDown]);\n\n const handleFocus = (): void => {\n if (activeIndex === undefined && rows.length) {\n setActiveIndex(0);\n }\n };\n\n return [activeIndex, setActiveIndex, handleKeyDown, handleFocus];\n};\n"],"names":["useTableKeyboardNavigation","props","rows","rowProps","ref","useGlobalKeyboardNavigation","dangerouslyHijackGlobalKeyboardNavigation","React","useState","undefined","activeIndex","setActiveIndex","onKeyDown","event","isModifierKeyPressed","metaKey","ctrlKey","altKey","shiftKey","document","activeElement","current","getAttribute","body","currentRow","sanitizedRow","sanitizeRowProps","rowExpansionRenderer","onRowClick","keyCode","keycode","preventDefault","toggleRowSelected","toggleRowExpanded","isExpanded","toggleRowEditing","canEdit","isEditing","onRowCreate","onRowEdit","onRowCopy","onRowDelete","nextIndex","getNextIndexFromKeycode","length","handleKeyDown","nativeEvent","useEffect","window","addEventListener","removeEventListener","handleFocus"],"mappings":";;;;;IAMaA,0BAA0B,GAAG,SAA7BA,0BAA6B,CACtCC,KADsC,EAEtCC,IAFsC,EAGtCC,QAHsC,EAItCC,GAJsC;AAWtC,MAAMC,2BAA2B,GAAGJ,KAAK,CAACK,yCAA1C;;AACA,wBAAsCC,cAAK,CAACC,QAAN,CAAmCH,2BAA2B,GAAG,CAAH,GAAOI,SAArE,CAAtC;AAAA,MAAOC,WAAP;AAAA,MAAoBC,cAApB;;AAEA,MAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD;;;AACd,QAAMC,oBAAoB,GAAGD,KAAK,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AcC,cAAd,EAA8BkC,aAA9B,EAA6CM,WAA7C,CAAP;AACH;;;;"}
|
1
|
+
{"version":3,"file":"useTableKeyboardNavigation.js","sources":["../../../../../src/components/Table/hooks/useTableKeyboardNavigation.ts"],"sourcesContent":["import React from 'react';\nimport keycode from 'keycode';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { getNextIndexFromKeycode } from '../../../utils/hooks/useListKeyboardNavigation';\nimport { sanitizeRowProps } from '../util';\nimport { TableProps } from '../types';\n\nexport const useTableKeyboardNavigation = <T extends {}>(\n props: TableProps<T>,\n rows: any[],\n rowProps: any,\n ref: React.RefObject<HTMLDivElement>\n): [\n number | undefined,\n (index: number) => void,\n (event: React.KeyboardEvent<HTMLElement>) => void,\n (event: React.FocusEvent<HTMLElement>) => void\n] => {\n const useGlobalKeyboardNavigation = props.dangerouslyHijackGlobalKeyboardNavigation;\n\n const [activeIndex, setActiveIndex] = useControllableState<number | undefined>({\n prop: props.activeIndex,\n defaultProp:\n props.defaultActiveIndex !== undefined ? props.defaultActiveIndex : useGlobalKeyboardNavigation ? 0 : undefined,\n onChange: props.onChangeActiveIndex,\n });\n\n const onKeyDown = (event: KeyboardEvent): void => {\n const isModifierKeyPressed = event.metaKey || event.ctrlKey || event.altKey || event.shiftKey;\n\n if (\n useGlobalKeyboardNavigation &&\n document.activeElement !== ref.current &&\n document.activeElement?.getAttribute('type') !== 'search' &&\n document.activeElement !== document.body\n ) {\n return;\n }\n // abort key handling if other elements inside table are focused and we don't use global keyboard navigation\n if (!useGlobalKeyboardNavigation && document.activeElement !== ref.current) {\n return;\n }\n\n if (activeIndex !== undefined) {\n const currentRow = rows[activeIndex];\n\n if (currentRow) {\n const sanitizedRow = sanitizeRowProps(currentRow, rowProps.rowExpansionRenderer);\n\n if (rowProps.onRowClick && event.keyCode === keycode('enter')) {\n event.preventDefault();\n rowProps.onRowClick(sanitizedRow);\n return;\n }\n\n if (currentRow.toggleRowSelected && event.keyCode === keycode('space')) {\n event.preventDefault();\n currentRow.toggleRowSelected();\n return;\n }\n\n if (currentRow.toggleRowExpanded) {\n if (currentRow.isExpanded && event.keyCode === keycode('left')) {\n event.preventDefault();\n currentRow.toggleRowExpanded();\n return;\n } else if (!currentRow.isExpanded && event.keyCode === keycode('right')) {\n event.preventDefault();\n currentRow.toggleRowExpanded();\n return;\n }\n }\n\n // inline editing\n if (currentRow.toggleRowEditing) {\n if (currentRow.canEdit && !currentRow.isEditing) {\n if (rowProps.onRowCreate && event.shiftKey && event.keyCode === keycode('n')) {\n event.preventDefault();\n\n if (!currentRow.isExpanded) {\n currentRow.toggleRowExpanded();\n }\n\n rowProps.onRowCreate(sanitizedRow, event);\n return;\n }\n\n if (event.keyCode === keycode('e')) {\n event.preventDefault();\n currentRow.toggleRowEditing();\n return;\n }\n }\n }\n\n if (rowProps.onRowEdit && event.keyCode === keycode('e') && !isModifierKeyPressed) {\n event.preventDefault();\n rowProps.onRowEdit(sanitizedRow, event);\n return;\n }\n\n if (rowProps.onRowCopy && event.keyCode === keycode('c') && !isModifierKeyPressed) {\n event.preventDefault();\n rowProps.onRowCopy(sanitizedRow, event);\n return;\n }\n\n if (rowProps.onRowDelete && event.keyCode === keycode('delete') && !isModifierKeyPressed) {\n event.preventDefault();\n rowProps.onRowDelete(sanitizedRow, event);\n return;\n }\n }\n }\n\n const nextIndex = getNextIndexFromKeycode(event.keyCode, rows.length, activeIndex);\n\n if (nextIndex !== undefined) {\n event.preventDefault();\n setActiveIndex(nextIndex);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n if (!useGlobalKeyboardNavigation) {\n onKeyDown(event.nativeEvent);\n }\n };\n\n React.useEffect(() => {\n if (useGlobalKeyboardNavigation) {\n window.addEventListener('keydown', onKeyDown);\n }\n\n return () => {\n if (useGlobalKeyboardNavigation) {\n window.removeEventListener('keydown', onKeyDown);\n }\n };\n }, [onKeyDown]);\n\n const handleFocus = (): void => {\n if (activeIndex === undefined && rows.length) {\n setActiveIndex(0);\n }\n };\n\n return [activeIndex, setActiveIndex, handleKeyDown, handleFocus];\n};\n"],"names":["useTableKeyboardNavigation","props","rows","rowProps","ref","useGlobalKeyboardNavigation","dangerouslyHijackGlobalKeyboardNavigation","useControllableState","prop","activeIndex","defaultProp","defaultActiveIndex","undefined","onChange","onChangeActiveIndex","setActiveIndex","onKeyDown","event","isModifierKeyPressed","metaKey","ctrlKey","altKey","shiftKey","document","activeElement","current","getAttribute","body","currentRow","sanitizedRow","sanitizeRowProps","rowExpansionRenderer","onRowClick","keyCode","keycode","preventDefault","toggleRowSelected","toggleRowExpanded","isExpanded","toggleRowEditing","canEdit","isEditing","onRowCreate","onRowEdit","onRowCopy","onRowDelete","nextIndex","getNextIndexFromKeycode","length","handleKeyDown","nativeEvent","React","useEffect","window","addEventListener","removeEventListener","handleFocus"],"mappings":";;;;;;IAOaA,0BAA0B,GAAG,SAA7BA,0BAA6B,CACtCC,KADsC,EAEtCC,IAFsC,EAGtCC,QAHsC,EAItCC,GAJsC;AAWtC,MAAMC,2BAA2B,GAAGJ,KAAK,CAACK,yCAA1C;;AAEA,8BAAsCC,oBAAoB,CAAqB;AAC3EC,IAAAA,IAAI,EAAEP,KAAK,CAACQ,WAD+D;AAE3EC,IAAAA,WAAW,EACPT,KAAK,CAACU,kBAAN,KAA6BC,SAA7B,GAAyCX,KAAK,CAACU,kBAA/C,GAAoEN,2BAA2B,GAAG,CAAH,GAAOO,SAH/B;AAI3EC,IAAAA,QAAQ,EAAEZ,KAAK,CAACa;AAJ2D,GAArB,CAA1D;AAAA,MAAOL,WAAP;AAAA,MAAoBM,cAApB;;AAOA,MAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD;;;AACd,QAAMC,oBAAoB,GAAGD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,OAAvB,IAAkCH,KAAK,CAACI,MAAxC,IAAkDJ,KAAK,CAACK,QAArF;;AAEA,QACIjB,2BAA2B,IAC3BkB,QAAQ,CAACC,a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|
disabled = props.disabled,
|
42
42
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
43
43
|
|
44
|
-
var className = cn('yt-tab bg-transparent border-b-2 border-transparent text-grey-darkest m-0 py-2 px-4', disabled ? 'cursor-not-allowed !text-grey' : 'cursor-pointer rounded-t hover:border-grey-light hover:text-black active:yt-focus active:border-blue focus:yt-focus focus:border-blue', props.className);
|
44
|
+
var className = cn('yt-tab bg-transparent border-b-2 border-transparent text-grey-darkest m-0 py-2 px-4', disabled ? 'cursor-not-allowed !text-grey-darker' : 'cursor-pointer rounded-t hover:border-grey-dark aria-selected:border-blue aria-selected:text-black aria-selected:hover:border-blue-light hover:text-black active:yt-focus active:border-blue focus:yt-focus focus:border-blue', props.className);
|
45
45
|
return createElement(Trigger, Object.assign({}, otherProps, {
|
46
46
|
className: className,
|
47
47
|
disabled: disabled,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\n\nimport { Orientation } from '../../types';\nimport './Tabs.css';\n\nexport type TabsProps = React.HTMLAttributes<HTMLDivElement> & {\n /**\n * The controlled value of the tab to activate. Should be used in conjunction with `onChange`.\n */\n id?: string;\n /**\n * Set which tab is selected on mount.\n * This has to be one of the existing ids provided for tabs\n */\n defaultId?: string;\n /**\n * Content should be one or an array of `Tabs.Trigger` components inside `Tabs.List` and then\n * followed by one or an array of `Tabs.Content`.\n * *Note* that there can also be tabs that are rendered conditionally.\n */\n children: React.ReactNode;\n /**\n * Define orientation of tabs.\n * @defaultValue horizontal\n */\n orientation?: Orientation;\n /**\n * Callback that is called when tab is changed.\n */\n onChange?: (id: string) => void;\n};\n\nexport type TabListProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport type TabTriggerProps = React.HTMLAttributes<HTMLButtonElement> & {\n /**\n * A unique value that associates the trigger with a content.\n */\n id: string;\n /**\n * When true, prevents the user from interacting with the tab.\n */\n disabled?: boolean;\n};\n\nexport type TabContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /**\n * A unique value that associates the content with a trigger.\n */\n id: string;\n};\n\nexport type ForwardedTabsWithStatics = React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>> & {\n /** Tab list component containing all tab triggers, rendered in a `Tabs` group component */\n List: React.ForwardRefExoticComponent<TabListProps & React.RefAttributes<HTMLDivElement>>;\n /** Tab trigger component rendered in a `Tabs.List` component */\n Trigger: React.ForwardRefExoticComponent<TabTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n /** Tab content component rendered in a `Tabs` group component */\n Content: React.ForwardRefExoticComponent<TabContentProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nexport const Tabs = React.forwardRef(function Tabs(props: TabsProps, ref: React.Ref<HTMLDivElement>) {\n const { id, defaultId, children, onChange, orientation = 'horizontal', ...otherProps } = props;\n const className = cn(\n 'yt-tabs',\n `yt-tabs--${orientation}`,\n {\n 'flex w-full': orientation === 'vertical',\n },\n props.className\n );\n\n return (\n <TabsPrimitive.Root\n {...otherProps}\n className={className}\n data-taco=\"tabs\"\n defaultValue={defaultId}\n dir=\"ltr\"\n onValueChange={onChange}\n orientation={orientation}\n ref={ref}\n value={id}\n >\n {children}\n </TabsPrimitive.Root>\n );\n}) as ForwardedTabsWithStatics;\n\nconst TabList = React.forwardRef(function Tab(props: TabListProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn('yt-tab__list border-b border-grey-light flex flex-row m-0 mb-4', props.className);\n\n return <TabsPrimitive.List {...props} className={className} ref={ref} />;\n});\n\nconst TabTrigger = React.forwardRef(function Tab(props: TabTriggerProps, ref: React.Ref<HTMLButtonElement>) {\n const { id, disabled, ...otherProps } = props;\n const className = cn(\n 'yt-tab bg-transparent border-b-2 border-transparent text-grey-darkest m-0 py-2 px-4',\n disabled\n ? 'cursor-not-allowed !text-grey'\n : 'cursor-pointer rounded-t hover:border-grey-light hover:text-black active:yt-focus active:border-blue focus:yt-focus focus:border-blue',\n props.className\n );\n\n return (\n <TabsPrimitive.Trigger\n {...otherProps}\n className={className}\n disabled={disabled}\n ref={ref}\n style={{\n transition: 'border 0.2s ease-in',\n }}\n value={id}\n />\n );\n});\n\nconst TabContent = React.forwardRef(function Tab(props: TabContentProps, ref: React.Ref<HTMLDivElement>) {\n const { id, ...otherProps } = props;\n const className = cn('yt-tab__panel outline-none', props.className);\n\n return <TabsPrimitive.Content {...otherProps} className={className} ref={ref} value={id} />;\n});\n\nTabs.List = TabList;\nTabs.Trigger = TabTrigger;\nTabs.Content = TabContent;\n"],"names":["Tabs","React","props","ref","id","defaultId","children","onChange","orientation","otherProps","className","cn","TabsPrimitive","defaultValue","dir","onValueChange","value","TabList","Tab","TabTrigger","disabled","style","transition","TabContent","List","Trigger","Content"],"mappings":";;;;;;;;IA+DaA,IAAI,gBAAGC,UAAA,CAAiB,SAASD,IAAT,CAAcE,KAAd,EAAgCC,GAAhC;AACjC,MAAQC,EAAR,GAAyFF,KAAzF,CAAQE,EAAR;AAAA,MAAYC,SAAZ,GAAyFH,KAAzF,CAAYG,SAAZ;AAAA,MAAuBC,QAAvB,GAAyFJ,KAAzF,CAAuBI,QAAvB;AAAA,MAAiCC,QAAjC,GAAyFL,KAAzF,CAAiCK,QAAjC;AAAA,2BAAyFL,KAAzF,CAA2CM,WAA3C;AAAA,MAA2CA,WAA3C,mCAAyD,YAAzD;AAAA,MAA0EC,UAA1E,iCAAyFP,KAAzF;;AACA,MAAMQ,SAAS,GAAGC,EAAE,CAChB,SADgB,gBAEJH,WAFI,EAGhB;AACI,mBAAeA,WAAW,KAAK;AADnC,GAHgB,EAMhBN,KAAK,CAACQ,SANU,CAApB;AASA,SACIT,aAAA,CAACW,IAAD,oBACQH;AACJC,IAAAA,SAAS,EAAEA;iBACD;AACVG,IAAAA,YAAY,EAAER;AACdS,IAAAA,GAAG,EAAC;AACJC,IAAAA,aAAa,EAAER;AACfC,IAAAA,WAAW,EAAEA;AACbL,IAAAA,GAAG,EAAEA;AACLa,IAAAA,KAAK,EAAEZ;IATX,EAWKE,QAXL,CADJ;AAeH,CA1BmB;AA4BpB,IAAMW,OAAO,gBAAGhB,UAAA,CAAiB,SAASiB,GAAT,CAAahB,KAAb,EAAkCC,GAAlC;AAC7B,MAAMO,SAAS,GAAGC,EAAE,CAAC,gEAAD,EAAmET,KAAK,CAACQ,SAAzE,CAApB;AAEA,SAAOT,aAAA,CAACW,IAAD,oBAAwBV;AAAOQ,IAAAA,SAAS,EAAEA;AAAWP,IAAAA,GAAG,EAAEA;IAA1D,CAAP;AACH,CAJe,CAAhB;AAMA,IAAMgB,UAAU,gBAAGlB,UAAA,CAAiB,SAASiB,GAAT,CAAahB,KAAb,EAAqCC,GAArC;AAChC,MAAQC,EAAR,GAAwCF,KAAxC,CAAQE,EAAR;AAAA,MAAYgB,QAAZ,GAAwClB,KAAxC,CAAYkB,QAAZ;AAAA,MAAyBX,UAAzB,iCAAwCP,KAAxC;;AACA,MAAMQ,SAAS,GAAGC,EAAE,CAChB,qFADgB,EAEhBS,QAAQ,GACF
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\n\nimport { Orientation } from '../../types';\nimport './Tabs.css';\n\nexport type TabsProps = React.HTMLAttributes<HTMLDivElement> & {\n /**\n * The controlled value of the tab to activate. Should be used in conjunction with `onChange`.\n */\n id?: string;\n /**\n * Set which tab is selected on mount.\n * This has to be one of the existing ids provided for tabs\n */\n defaultId?: string;\n /**\n * Content should be one or an array of `Tabs.Trigger` components inside `Tabs.List` and then\n * followed by one or an array of `Tabs.Content`.\n * *Note* that there can also be tabs that are rendered conditionally.\n */\n children: React.ReactNode;\n /**\n * Define orientation of tabs.\n * @defaultValue horizontal\n */\n orientation?: Orientation;\n /**\n * Callback that is called when tab is changed.\n */\n onChange?: (id: string) => void;\n};\n\nexport type TabListProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport type TabTriggerProps = React.HTMLAttributes<HTMLButtonElement> & {\n /**\n * A unique value that associates the trigger with a content.\n */\n id: string;\n /**\n * When true, prevents the user from interacting with the tab.\n */\n disabled?: boolean;\n};\n\nexport type TabContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /**\n * A unique value that associates the content with a trigger.\n */\n id: string;\n};\n\nexport type ForwardedTabsWithStatics = React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>> & {\n /** Tab list component containing all tab triggers, rendered in a `Tabs` group component */\n List: React.ForwardRefExoticComponent<TabListProps & React.RefAttributes<HTMLDivElement>>;\n /** Tab trigger component rendered in a `Tabs.List` component */\n Trigger: React.ForwardRefExoticComponent<TabTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n /** Tab content component rendered in a `Tabs` group component */\n Content: React.ForwardRefExoticComponent<TabContentProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nexport const Tabs = React.forwardRef(function Tabs(props: TabsProps, ref: React.Ref<HTMLDivElement>) {\n const { id, defaultId, children, onChange, orientation = 'horizontal', ...otherProps } = props;\n const className = cn(\n 'yt-tabs',\n `yt-tabs--${orientation}`,\n {\n 'flex w-full': orientation === 'vertical',\n },\n props.className\n );\n\n return (\n <TabsPrimitive.Root\n {...otherProps}\n className={className}\n data-taco=\"tabs\"\n defaultValue={defaultId}\n dir=\"ltr\"\n onValueChange={onChange}\n orientation={orientation}\n ref={ref}\n value={id}\n >\n {children}\n </TabsPrimitive.Root>\n );\n}) as ForwardedTabsWithStatics;\n\nconst TabList = React.forwardRef(function Tab(props: TabListProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn('yt-tab__list border-b border-grey-light flex flex-row m-0 mb-4', props.className);\n\n return <TabsPrimitive.List {...props} className={className} ref={ref} />;\n});\n\nconst TabTrigger = React.forwardRef(function Tab(props: TabTriggerProps, ref: React.Ref<HTMLButtonElement>) {\n const { id, disabled, ...otherProps } = props;\n const className = cn(\n 'yt-tab bg-transparent border-b-2 border-transparent text-grey-darkest m-0 py-2 px-4',\n disabled\n ? 'cursor-not-allowed !text-grey-darker'\n : 'cursor-pointer rounded-t hover:border-grey-dark aria-selected:border-blue aria-selected:text-black aria-selected:hover:border-blue-light hover:text-black active:yt-focus active:border-blue focus:yt-focus focus:border-blue',\n props.className\n );\n\n return (\n <TabsPrimitive.Trigger\n {...otherProps}\n className={className}\n disabled={disabled}\n ref={ref}\n style={{\n transition: 'border 0.2s ease-in',\n }}\n value={id}\n />\n );\n});\n\nconst TabContent = React.forwardRef(function Tab(props: TabContentProps, ref: React.Ref<HTMLDivElement>) {\n const { id, ...otherProps } = props;\n const className = cn('yt-tab__panel outline-none', props.className);\n\n return <TabsPrimitive.Content {...otherProps} className={className} ref={ref} value={id} />;\n});\n\nTabs.List = TabList;\nTabs.Trigger = TabTrigger;\nTabs.Content = TabContent;\n"],"names":["Tabs","React","props","ref","id","defaultId","children","onChange","orientation","otherProps","className","cn","TabsPrimitive","defaultValue","dir","onValueChange","value","TabList","Tab","TabTrigger","disabled","style","transition","TabContent","List","Trigger","Content"],"mappings":";;;;;;;;IA+DaA,IAAI,gBAAGC,UAAA,CAAiB,SAASD,IAAT,CAAcE,KAAd,EAAgCC,GAAhC;AACjC,MAAQC,EAAR,GAAyFF,KAAzF,CAAQE,EAAR;AAAA,MAAYC,SAAZ,GAAyFH,KAAzF,CAAYG,SAAZ;AAAA,MAAuBC,QAAvB,GAAyFJ,KAAzF,CAAuBI,QAAvB;AAAA,MAAiCC,QAAjC,GAAyFL,KAAzF,CAAiCK,QAAjC;AAAA,2BAAyFL,KAAzF,CAA2CM,WAA3C;AAAA,MAA2CA,WAA3C,mCAAyD,YAAzD;AAAA,MAA0EC,UAA1E,iCAAyFP,KAAzF;;AACA,MAAMQ,SAAS,GAAGC,EAAE,CAChB,SADgB,gBAEJH,WAFI,EAGhB;AACI,mBAAeA,WAA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CAAiB,SAASiB,GAAT,CAAahB,KAAb,EAAqCC,GAArC;AAChC,MAAQC,EAAR,GAA8BF,KAA9B,CAAQE,EAAR;AAAA,MAAeK,UAAf,iCAA8BP,KAA9B;;AACA,MAAMQ,SAAS,GAAGC,EAAE,CAAC,4BAAD,EAA+BT,KAAK,CAACQ,SAArC,CAApB;AAEA,SAAOT,aAAA,CAACW,OAAD,oBAA2BH;AAAYC,IAAAA,SAAS,EAAEA;AAAWP,IAAAA,GAAG,EAAEA;AAAKa,IAAAA,KAAK,EAAEZ;IAA9E,CAAP;AACH,CALkB,CAAnB;AAOAJ,IAAI,CAACwB,IAAL,GAAYP,OAAZ;AACAjB,IAAI,CAACyB,OAAL,GAAeN,UAAf;AACAnB,IAAI,CAAC0B,OAAL,GAAeH,UAAf;;;;"}
|
package/dist/esm/index.css
CHANGED
@@ -644,8 +644,8 @@
|
|
644
644
|
@apply m-0 mr-4 flex-col border-0 border-r;
|
645
645
|
}
|
646
646
|
|
647
|
-
.yt-tabs .yt-tab__list
|
648
|
-
@apply
|
647
|
+
.yt-tabs .yt-tab__list[aria-orientation='vertical'] .yt-tab {
|
648
|
+
@apply h-8 py-0;
|
649
649
|
}
|
650
650
|
|
651
651
|
.yt-tabs.yt-tabs--vertical .yt-tab__list {
|
package/dist/index.css
CHANGED
@@ -644,8 +644,8 @@
|
|
644
644
|
@apply m-0 mr-4 flex-col border-0 border-r;
|
645
645
|
}
|
646
646
|
|
647
|
-
.yt-tabs .yt-tab__list
|
648
|
-
@apply
|
647
|
+
.yt-tabs .yt-tab__list[aria-orientation='vertical'] .yt-tab {
|
648
|
+
@apply h-8 py-0;
|
649
649
|
}
|
650
650
|
|
651
651
|
.yt-tabs.yt-tabs--vertical .yt-tab__list {
|
@@ -24,6 +24,7 @@ var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
24
24
|
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
25
25
|
var reactTable = require('react-table');
|
26
26
|
var reactIntersectionObserver = require('react-intersection-observer');
|
27
|
+
var reactUseControllableState = require('@radix-ui/react-use-controllable-state');
|
27
28
|
var focus = require('@react-aria/focus');
|
28
29
|
var reactWindow = require('react-window');
|
29
30
|
var InfiniteLoader = _interopDefault(require('react-window-infinite-loader'));
|
@@ -3404,7 +3405,7 @@ var Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(props, ref) {
|
|
3404
3405
|
|
3405
3406
|
var _excluded$5 = ["dialog", "hanger", "menu", "popover", "tooltip"];
|
3406
3407
|
var getButtonClasses = function getButtonClasses() {
|
3407
|
-
return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center
|
3408
|
+
return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center';
|
3408
3409
|
};
|
3409
3410
|
var getAppearanceClasses = function getAppearanceClasses(value, icon) {
|
3410
3411
|
if (icon === void 0) {
|
@@ -3413,13 +3414,13 @@ var getAppearanceClasses = function getAppearanceClasses(value, icon) {
|
|
3413
3414
|
|
3414
3415
|
switch (value) {
|
3415
3416
|
case 'primary':
|
3416
|
-
return "yt-blue-solid
|
3417
|
+
return "yt-blue-solid focus:bg-blue focus:text-white focus:yt-focus active:bg-blue-dark active:text-white hover:bg-blue-light hover:text-white hover:focus:bg-blue-light hover:focus:border-blue-light hover:focus:text-white disabled:hover:yt-blue-solid disabled:hover:hover:border-blue";
|
3417
3418
|
|
3418
3419
|
case 'danger':
|
3419
|
-
return "yt-red-solid
|
3420
|
+
return "yt-red-solid focus:bg-red focus:text-white focus:yt-focus-red active:bg-red-dark active:text-white hover:bg-red-light hover:text-white hover:focus:bg-red-light hover:focus:text-white disabled:hover:yt-red-solid";
|
3420
3421
|
|
3421
3422
|
case 'ghost':
|
3422
|
-
return "
|
3423
|
+
return "bg-white shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT)] text-blue focus:bg-transparent focus:text-blue active:bg-blue-lightest focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.DEFAULT),0_0_0_2px_rgba(0,99,255,0.25)] active:text-blue-dark hover:bg-blue-lightest hover:shadow-[inset_0_0_0_1px_theme(colors.blue.light)] hover:text-blue-light hover:focus:bg-blue-lightest hover:focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.light),0_0_0_2px_rgba(0,99,255,0.25)] hover:focus:text-blue-light";
|
3423
3424
|
|
3424
3425
|
case 'discrete':
|
3425
3426
|
{
|
@@ -3427,11 +3428,11 @@ var getAppearanceClasses = function getAppearanceClasses(value, icon) {
|
|
3427
3428
|
return "bg-transparent text-black border-transparent focus:text-black focus:yt-focus active:text-black hover:text-grey-darkest hover:focus:text-grey-darkest disabled:hover:text-black ";
|
3428
3429
|
}
|
3429
3430
|
|
3430
|
-
return "yt-transparent
|
3431
|
+
return "yt-transparent focus:text-blue focus:yt-focus active:text-blue-dark hover:text-blue-light hover:focus:text-blue-light disabled:hover:yt-transparent";
|
3431
3432
|
}
|
3432
3433
|
|
3433
3434
|
default:
|
3434
|
-
return "yt-grey-solid
|
3435
|
+
return "yt-grey-solid focus:bg-grey focus:yt-focus active:bg-grey-dark active:text-black hover:bg-grey-light hover:text-grey-darkest hover:focus:bg-grey-light hover:focus:text-grey-darkest disabled:hover:yt-grey-solid";
|
3435
3436
|
}
|
3436
3437
|
};
|
3437
3438
|
var createButton = function createButton(props, className, ref) {
|
@@ -6633,27 +6634,6 @@ var MultiListbox = /*#__PURE__*/React.forwardRef(function Listbox(props, ref) {
|
|
6633
6634
|
});
|
6634
6635
|
|
6635
6636
|
var _excluded$w = ["children", "placement"];
|
6636
|
-
|
6637
|
-
var getAppearanceClasses$1 = function getAppearanceClasses(appearance) {
|
6638
|
-
switch (appearance) {
|
6639
|
-
case 'primary':
|
6640
|
-
return 'wcag-blue border-blue';
|
6641
|
-
|
6642
|
-
case 'danger':
|
6643
|
-
return 'wcag-red border-red';
|
6644
|
-
|
6645
|
-
case 'ghost':
|
6646
|
-
return 'bg-white text-blue border-blue yt-shadow-blue';
|
6647
|
-
|
6648
|
-
case 'discrete':
|
6649
|
-
return 'wcag-white border-grey yt-shadow';
|
6650
|
-
|
6651
|
-
case 'default':
|
6652
|
-
default:
|
6653
|
-
return 'wcag-grey-light border-grey';
|
6654
|
-
}
|
6655
|
-
};
|
6656
|
-
|
6657
6637
|
var Content$5 = /*#__PURE__*/React.forwardRef(function MenuContent(props, ref) {
|
6658
6638
|
var internalRef = useProxiedRef(ref);
|
6659
6639
|
var menu = useCurrentMenu();
|
@@ -6662,7 +6642,7 @@ var Content$5 = /*#__PURE__*/React.forwardRef(function MenuContent(props, ref) {
|
|
6662
6642
|
side = props.placement,
|
6663
6643
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$w);
|
6664
6644
|
|
6665
|
-
var className = cn('border rounded block outline-none p-1
|
6645
|
+
var className = cn('border rounded block outline-none p-1 wcag-white border-grey yt-shadow', props.className);
|
6666
6646
|
return React.createElement(DropdownMenuPrimitive.Content, Object.assign({}, otherProps, {
|
6667
6647
|
align: "start",
|
6668
6648
|
className: className,
|
@@ -6686,27 +6666,6 @@ var Icon$1 = function Icon$1(_ref) {
|
|
6686
6666
|
name: name
|
6687
6667
|
}));
|
6688
6668
|
};
|
6689
|
-
|
6690
|
-
var getAppearanceClasses$2 = function getAppearanceClasses(appearance) {
|
6691
|
-
switch (appearance) {
|
6692
|
-
case 'primary':
|
6693
|
-
return 'wcag-blue aria-disabled:text-blue-dark hover:wcag-blue-light focus:wcag-blue-light';
|
6694
|
-
|
6695
|
-
case 'danger':
|
6696
|
-
return 'wcag-red aria-disabled:text-red-dark hover:wcag-red-light focus:wcag-red-light';
|
6697
|
-
|
6698
|
-
case 'ghost':
|
6699
|
-
return 'text-blue aria-disabled:text-grey hover:wcag-blue focus:wcag-blue';
|
6700
|
-
|
6701
|
-
case 'discrete':
|
6702
|
-
return 'text-black aria-disabled:text-grey hover:wcag-blue-lightest focus:wcag-blue-lightest';
|
6703
|
-
|
6704
|
-
case 'default':
|
6705
|
-
default:
|
6706
|
-
return 'wcag-grey-light aria-disabled:text-grey-darker hover:wcag-grey-dark focus:wcag-grey-dark';
|
6707
|
-
}
|
6708
|
-
};
|
6709
|
-
|
6710
6669
|
var useItemStyling = function useItemStyling(_ref2) {
|
6711
6670
|
var disabled = _ref2.disabled,
|
6712
6671
|
indented = _ref2.indented,
|
@@ -6717,7 +6676,7 @@ var useItemStyling = function useItemStyling(_ref2) {
|
|
6717
6676
|
menu === null || menu === void 0 ? void 0 : menu.registerIndentation();
|
6718
6677
|
}
|
6719
6678
|
}, [indented]);
|
6720
|
-
return cn('flex items-center justify-start h-
|
6679
|
+
return cn('flex items-center justify-start h-8 pr-1.5 relative rounded w-full focus:outline-none group', 'text-black aria-disabled:text-grey hover:bg-grey-light hover:text-black', {
|
6721
6680
|
'pl-7': menu === null || menu === void 0 ? void 0 : menu.indented,
|
6722
6681
|
'pl-1.5': !(menu !== null && menu !== void 0 && menu.indented),
|
6723
6682
|
'cursor-pointer': !disabled,
|
@@ -6725,35 +6684,8 @@ var useItemStyling = function useItemStyling(_ref2) {
|
|
6725
6684
|
}, className);
|
6726
6685
|
};
|
6727
6686
|
var Shortcut = function Shortcut(props) {
|
6728
|
-
var menu = useCurrentMenu();
|
6729
|
-
var appearance;
|
6730
|
-
|
6731
|
-
switch (menu === null || menu === void 0 ? void 0 : menu.appearance) {
|
6732
|
-
case 'primary':
|
6733
|
-
appearance = 'text-blue-lightest group-focus:text-black';
|
6734
|
-
break;
|
6735
|
-
|
6736
|
-
case 'danger':
|
6737
|
-
appearance = 'text-red-lightest group-focus:text-white';
|
6738
|
-
break;
|
6739
|
-
|
6740
|
-
case 'ghost':
|
6741
|
-
appearance = 'text-blue-light group-focus:text-blue-lightest';
|
6742
|
-
break;
|
6743
|
-
|
6744
|
-
case 'discrete':
|
6745
|
-
appearance = 'text-grey-darker group-focus:text-blue-light';
|
6746
|
-
break;
|
6747
|
-
|
6748
|
-
case 'default':
|
6749
|
-
default:
|
6750
|
-
appearance = 'text-grey-darkest';
|
6751
|
-
break;
|
6752
|
-
}
|
6753
|
-
|
6754
|
-
var className = cn('ml-auto pl-3', appearance);
|
6755
6687
|
return React.createElement("span", Object.assign({}, props, {
|
6756
|
-
className:
|
6688
|
+
className: "text-grey-darkest ml-auto pl-3"
|
6757
6689
|
}));
|
6758
6690
|
};
|
6759
6691
|
var Item$1 = /*#__PURE__*/React.forwardRef(function MenuItem(props, ref) {
|
@@ -6841,25 +6773,13 @@ var Link = /*#__PURE__*/React.forwardRef(function MenuLink(props, ref) {
|
|
6841
6773
|
});
|
6842
6774
|
|
6843
6775
|
var Trigger$4 = /*#__PURE__*/React.forwardRef(function MenuTrigger(props, ref) {
|
6844
|
-
var _props$children3, _props$children3$prop;
|
6845
|
-
|
6846
6776
|
var menu = useCurrentMenu();
|
6847
6777
|
var internalRef = useProxiedRef(ref);
|
6848
6778
|
React.useEffect(function () {
|
6849
6779
|
if (internalRef.current) {
|
6850
6780
|
menu === null || menu === void 0 ? void 0 : menu.setMinWidth(internalRef.current.getBoundingClientRect().width);
|
6851
6781
|
}
|
6852
|
-
}, [internalRef]);
|
6853
|
-
|
6854
|
-
React.useEffect(function () {
|
6855
|
-
var _props$children, _props$children$props;
|
6856
|
-
|
6857
|
-
if ((_props$children = props.children) !== null && _props$children !== void 0 && (_props$children$props = _props$children.props) !== null && _props$children$props !== void 0 && _props$children$props.appearance) {
|
6858
|
-
var _props$children2, _props$children2$prop;
|
6859
|
-
|
6860
|
-
menu === null || menu === void 0 ? void 0 : menu.setAppearance((_props$children2 = props.children) === null || _props$children2 === void 0 ? void 0 : (_props$children2$prop = _props$children2.props) === null || _props$children2$prop === void 0 ? void 0 : _props$children2$prop.appearance);
|
6861
|
-
}
|
6862
|
-
}, [(_props$children3 = props.children) === null || _props$children3 === void 0 ? void 0 : (_props$children3$prop = _props$children3.props) === null || _props$children3$prop === void 0 ? void 0 : _props$children3$prop.appearance]);
|
6782
|
+
}, [internalRef]);
|
6863
6783
|
return React.createElement(DropdownMenuPrimitive.Trigger, Object.assign({}, props, {
|
6864
6784
|
asChild: true,
|
6865
6785
|
ref: internalRef
|
@@ -7043,57 +6963,15 @@ var RadioGroup$1 = function RadioGroup(props) {
|
|
7043
6963
|
};
|
7044
6964
|
RadioGroup$1.Item = RadioItem;
|
7045
6965
|
|
7046
|
-
var getAppearanceClasses$3 = function getAppearanceClasses(appearance) {
|
7047
|
-
switch (appearance) {
|
7048
|
-
case 'primary':
|
7049
|
-
return 'bg-blue-lighe';
|
7050
|
-
|
7051
|
-
case 'danger':
|
7052
|
-
return 'bg-red-light';
|
7053
|
-
|
7054
|
-
case 'ghost':
|
7055
|
-
return 'bg-blue-light';
|
7056
|
-
|
7057
|
-
case 'discrete':
|
7058
|
-
return 'bg-grey-dark';
|
7059
|
-
|
7060
|
-
case 'default':
|
7061
|
-
default:
|
7062
|
-
return 'bg-grey-dark';
|
7063
|
-
}
|
7064
|
-
};
|
7065
|
-
|
7066
6966
|
var Separator = function Separator() {
|
7067
|
-
var menu = useCurrentMenu();
|
7068
|
-
var className = cn('h-px my-1', getAppearanceClasses$3(menu === null || menu === void 0 ? void 0 : menu.appearance));
|
7069
6967
|
return React.createElement(DropdownMenuPrimitive.Separator, {
|
7070
|
-
className:
|
6968
|
+
className: "bg-grey-dark my-1 h-px"
|
7071
6969
|
});
|
7072
6970
|
};
|
7073
6971
|
|
7074
|
-
var getAppearanceClasses$4 = function getAppearanceClasses(appearance) {
|
7075
|
-
switch (appearance) {
|
7076
|
-
case 'primary':
|
7077
|
-
return 'text-blue-lighest';
|
7078
|
-
|
7079
|
-
case 'danger':
|
7080
|
-
return 'text-red-lightest';
|
7081
|
-
|
7082
|
-
case 'ghost':
|
7083
|
-
return 'text-blue-light';
|
7084
|
-
|
7085
|
-
case 'discrete':
|
7086
|
-
return 'text-grey-darkest';
|
7087
|
-
|
7088
|
-
case 'default':
|
7089
|
-
default:
|
7090
|
-
return 'text-grey-darkest';
|
7091
|
-
}
|
7092
|
-
};
|
7093
|
-
|
7094
6972
|
var Header = function Header(props) {
|
7095
6973
|
var menu = useCurrentMenu();
|
7096
|
-
var className = cn('flex items-center justify-start h-
|
6974
|
+
var className = cn('flex items-center justify-start h-7 pr-1.5 text-xs text-grey-darkest', {
|
7097
6975
|
'pl-7': menu === null || menu === void 0 ? void 0 : menu.indented,
|
7098
6976
|
'pl-1.5': !(menu !== null && menu !== void 0 && menu.indented)
|
7099
6977
|
}, props.className);
|
@@ -7102,10 +6980,9 @@ var Header = function Header(props) {
|
|
7102
6980
|
}));
|
7103
6981
|
};
|
7104
6982
|
|
7105
|
-
var _excluded$C = ["
|
6983
|
+
var _excluded$C = ["children", "trigger"];
|
7106
6984
|
var Menu = function Menu(externalProps) {
|
7107
|
-
var
|
7108
|
-
children = externalProps.children,
|
6985
|
+
var children = externalProps.children,
|
7109
6986
|
trigger = externalProps.trigger,
|
7110
6987
|
props = _objectWithoutPropertiesLoose(externalProps, _excluded$C);
|
7111
6988
|
|
@@ -7113,24 +6990,16 @@ var Menu = function Menu(externalProps) {
|
|
7113
6990
|
open = _React$useState[0],
|
7114
6991
|
setOpen = _React$useState[1];
|
7115
6992
|
|
7116
|
-
var _React$useState2 = React.useState(
|
7117
|
-
|
7118
|
-
|
7119
|
-
|
7120
|
-
var _React$useState3 = React.useState(false),
|
7121
|
-
indented = _React$useState3[0],
|
7122
|
-
setIndented = _React$useState3[1];
|
6993
|
+
var _React$useState2 = React.useState(false),
|
6994
|
+
indented = _React$useState2[0],
|
6995
|
+
setIndented = _React$useState2[1];
|
7123
6996
|
|
7124
|
-
var _React$
|
7125
|
-
minWidth = _React$
|
7126
|
-
_setMinWidth = _React$
|
6997
|
+
var _React$useState3 = React.useState(undefined),
|
6998
|
+
minWidth = _React$useState3[0],
|
6999
|
+
_setMinWidth = _React$useState3[1];
|
7127
7000
|
|
7128
7001
|
var context = React.useMemo(function () {
|
7129
7002
|
return {
|
7130
|
-
appearance: appearance,
|
7131
|
-
setAppearance: function setAppearance(appearance) {
|
7132
|
-
return _setAppearance(appearance);
|
7133
|
-
},
|
7134
7003
|
indented: indented,
|
7135
7004
|
registerIndentation: function registerIndentation() {
|
7136
7005
|
return setIndented(true);
|
@@ -7143,7 +7012,7 @@ var Menu = function Menu(externalProps) {
|
|
7143
7012
|
return setOpen(false);
|
7144
7013
|
}
|
7145
7014
|
};
|
7146
|
-
}, [indented, minWidth
|
7015
|
+
}, [indented, minWidth]);
|
7147
7016
|
return React.createElement(MenuContext.Provider, {
|
7148
7017
|
value: context
|
7149
7018
|
}, React.createElement(DropdownMenuPrimitive.Root, Object.assign({}, props, {
|
@@ -8610,9 +8479,13 @@ var useRowSelect = function useRowSelect(onSelectedRows) {
|
|
8610
8479
|
var useTableKeyboardNavigation = function useTableKeyboardNavigation(props, rows, rowProps, ref) {
|
8611
8480
|
var useGlobalKeyboardNavigation = props.dangerouslyHijackGlobalKeyboardNavigation;
|
8612
8481
|
|
8613
|
-
var
|
8614
|
-
|
8615
|
-
|
8482
|
+
var _useControllableState = reactUseControllableState.useControllableState({
|
8483
|
+
prop: props.activeIndex,
|
8484
|
+
defaultProp: props.defaultActiveIndex !== undefined ? props.defaultActiveIndex : useGlobalKeyboardNavigation ? 0 : undefined,
|
8485
|
+
onChange: props.onChangeActiveIndex
|
8486
|
+
}),
|
8487
|
+
activeIndex = _useControllableState[0],
|
8488
|
+
setActiveIndex = _useControllableState[1];
|
8616
8489
|
|
8617
8490
|
var onKeyDown = function onKeyDown(event) {
|
8618
8491
|
var _document$activeEleme;
|
@@ -9418,7 +9291,11 @@ var WindowedTable = /*#__PURE__*/React__default.forwardRef(function WindowedTabl
|
|
9418
9291
|
|
9419
9292
|
|
9420
9293
|
var headerRef = React__default.useRef(null);
|
9421
|
-
|
9294
|
+
|
9295
|
+
var _React$useState = React__default.useState(null),
|
9296
|
+
rowsRef = _React$useState[0],
|
9297
|
+
setRowsRef = _React$useState[1];
|
9298
|
+
|
9422
9299
|
var tableDimensions = useBoundingClientRectListener(tableRef);
|
9423
9300
|
var headerDimensions = useBoundingClientRectListener(headerRef);
|
9424
9301
|
var height = tableDimensions && headerDimensions ? tableDimensions.height - headerDimensions.height : null; // variable row height calculations
|
@@ -9431,8 +9308,8 @@ var WindowedTable = /*#__PURE__*/React__default.forwardRef(function WindowedTabl
|
|
9431
9308
|
|
9432
9309
|
rowHeights.current = _extends({}, rowHeights.current, (_extends2 = {}, _extends2[index] = size, _extends2));
|
9433
9310
|
|
9434
|
-
if (rowsRef
|
9435
|
-
rowsRef.
|
9311
|
+
if (rowsRef) {
|
9312
|
+
rowsRef.resetAfterIndex(0);
|
9436
9313
|
}
|
9437
9314
|
}
|
9438
9315
|
}, []);
|
@@ -9440,16 +9317,16 @@ var WindowedTable = /*#__PURE__*/React__default.forwardRef(function WindowedTabl
|
|
9440
9317
|
return rowHeights.current[index] || estimatedRowHeight;
|
9441
9318
|
}, []);
|
9442
9319
|
React__default.useEffect(function () {
|
9443
|
-
if (rowsRef &&
|
9444
|
-
rowsRef.
|
9320
|
+
if (rowsRef && rowProps.activeIndex !== undefined) {
|
9321
|
+
rowsRef.scrollToItem(rowProps.activeIndex, 'start');
|
9445
9322
|
}
|
9446
|
-
}, [rowProps.activeIndex]); // trigger recalculation of variable row heights if the data changes
|
9323
|
+
}, [rowsRef, rowProps.activeIndex]); // trigger recalculation of variable row heights if the data changes
|
9447
9324
|
|
9448
9325
|
React__default.useEffect(function () {
|
9449
9326
|
rowHeights.current = {};
|
9450
9327
|
|
9451
|
-
if (rowsRef
|
9452
|
-
rowsRef.
|
9328
|
+
if (rowsRef) {
|
9329
|
+
rowsRef.resetAfterIndex(0);
|
9453
9330
|
}
|
9454
9331
|
}, [rows.length]);
|
9455
9332
|
var contentHeight = estimatedRowHeight * props.data.length || 0;
|
@@ -9496,14 +9373,16 @@ var WindowedTable = /*#__PURE__*/React__default.forwardRef(function WindowedTabl
|
|
9496
9373
|
ref: function ref(list) {
|
9497
9374
|
_ref3(list);
|
9498
9375
|
|
9499
|
-
|
9376
|
+
setRowsRef(list);
|
9500
9377
|
}
|
9501
9378
|
}), VariableRow);
|
9502
9379
|
});
|
9503
9380
|
} else {
|
9504
9381
|
list = React__default.createElement(reactWindow.VariableSizeList, Object.assign({}, listProps, {
|
9505
9382
|
itemCount: rows.length,
|
9506
|
-
ref:
|
9383
|
+
ref: function ref(_ref4) {
|
9384
|
+
setRowsRef(_ref4);
|
9385
|
+
}
|
9507
9386
|
}), VariableRow);
|
9508
9387
|
}
|
9509
9388
|
}
|
@@ -9745,7 +9624,7 @@ var TabTrigger = /*#__PURE__*/React.forwardRef(function Tab(props, ref) {
|
|
9745
9624
|
disabled = props.disabled,
|
9746
9625
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded2$9);
|
9747
9626
|
|
9748
|
-
var className = cn('yt-tab bg-transparent border-b-2 border-transparent text-grey-darkest m-0 py-2 px-4', disabled ? 'cursor-not-allowed !text-grey' : 'cursor-pointer rounded-t hover:border-grey-light hover:text-black active:yt-focus active:border-blue focus:yt-focus focus:border-blue', props.className);
|
9627
|
+
var className = cn('yt-tab bg-transparent border-b-2 border-transparent text-grey-darkest m-0 py-2 px-4', disabled ? 'cursor-not-allowed !text-grey-darker' : 'cursor-pointer rounded-t hover:border-grey-dark aria-selected:border-blue aria-selected:text-black aria-selected:hover:border-blue-light hover:text-black active:yt-focus active:border-blue focus:yt-focus focus:border-blue', props.className);
|
9749
9628
|
return React.createElement(TabsPrimitive.Trigger, Object.assign({}, otherProps, {
|
9750
9629
|
className: className,
|
9751
9630
|
disabled: disabled,
|