@economic/taco 2.22.1 → 2.23.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/OverflowGroup/OverflowGroup.d.ts +1 -1
- package/dist/components/Report/Report.d.ts +2 -0
- package/dist/components/Report/components/Body/EmptyStateBody.d.ts +7 -0
- package/dist/components/Report/components/Cell/util.d.ts +1 -1
- package/dist/components/Report/types.d.ts +2 -0
- package/dist/components/Report/useReport.d.ts +1 -0
- package/dist/components/Select2/components/Trigger.d.ts +1 -0
- package/dist/components/Truncate/Truncate.d.ts +2 -2
- package/dist/esm/index.css +73 -75
- package/dist/esm/packages/taco/src/components/Card/Card.js +6 -3
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js +4 -15
- package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +2 -2
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -1
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js +13 -6
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/Report.js +9 -6
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js +18 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js +6 -2
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +3 -2
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +1 -0
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +9 -4
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js +4 -3
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +34 -0
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +1 -0
- package/dist/esm/packages/taco/src/index.js +1 -0
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +48 -6
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +4 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js +5 -5
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js +14 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +127 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +4 -4
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -1
- package/dist/index.css +73 -75
- package/dist/index.d.ts +1 -0
- package/dist/primitives/Table/types.d.ts +13 -1
- package/dist/primitives/Table/useTable/features/useTableSettings.d.ts +2 -2
- package/dist/primitives/Table/useTable/useTable.d.ts +1 -0
- package/dist/taco.cjs.development.js +306 -71
- 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/dist/utils/hooks/useTruncated.d.ts +1 -1
- package/package.json +2 -2
- package/types.json +8672 -8382
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Report.js","sources":["../../../../../../../src/components/Report/Report.tsx"],"sourcesContent":["import React from 'react';\nimport { FocusScope } from '@react-aria/focus';\nimport { fixedForwardRef } from '../../types';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useReport } from './useReport';\nimport { ReportColumnProps, ReportGroupProps, ReportProps } from './types';\nimport { Header } from './components/Header/Header';\nimport { Body } from './components/Body/Body';\nimport { Footer } from './components/Footer/Footer';\nimport { Summary } from './components/Footer/Summary';\nimport { Toolbar } from './components/Toolbar/Toolbar';\nimport { TableRef } from '../../primitives/Table/types';\nimport { useStylesheet } from './styles/useStylesheet';\nimport { useTableRenderer } from './util/useTableRenderer';\nimport { useTableGlobalShortcuts } from './util/useTableGlobalShortcuts';\nimport './style.css';\n\nfunction Column<TType = unknown>(_: ReportColumnProps<TType>) {\n return null;\n}\n\nfunction Group(_: ReportGroupProps) {\n return null;\n}\n\nexport const Report = fixedForwardRef<TableRef, ReportProps>(function Report<TType = unknown>(\n props: ReportProps<TType>,\n ref: React.Ref<TableRef>\n) {\n const tableRef = useMergedRef<TableRef>(ref);\n const report = useReport<TType>(props, tableRef);\n const renderer = useTableRenderer(report.instance, tableRef, props.defaultRowActiveIndex);\n const stylesheet = useStylesheet(
|
1
|
+
{"version":3,"file":"Report.js","sources":["../../../../../../../src/components/Report/Report.tsx"],"sourcesContent":["import React from 'react';\nimport { FocusScope } from '@react-aria/focus';\nimport { fixedForwardRef } from '../../types';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useReport } from './useReport';\nimport { ReportColumnProps, ReportGroupProps, ReportProps } from './types';\nimport { Header } from './components/Header/Header';\nimport { Body } from './components/Body/Body';\nimport { Footer } from './components/Footer/Footer';\nimport { Summary } from './components/Footer/Summary';\nimport { Toolbar } from './components/Toolbar/Toolbar';\nimport { TableRef } from '../../primitives/Table/types';\nimport { useStylesheet } from './styles/useStylesheet';\nimport { useTableRenderer } from './util/useTableRenderer';\nimport { useTableGlobalShortcuts } from './util/useTableGlobalShortcuts';\nimport { EmptyStateBody } from './components/Body/EmptyStateBody';\nimport './style.css';\n\nfunction Column<TType = unknown>(_: ReportColumnProps<TType>) {\n return null;\n}\n\nfunction Group(_: ReportGroupProps) {\n return null;\n}\n\nexport const Report = fixedForwardRef<TableRef, ReportProps>(function Report<TType = unknown>(\n props: ReportProps<TType>,\n ref: React.Ref<TableRef>\n) {\n const tableRef = useMergedRef<TableRef>(ref);\n const report = useReport<TType>(props, tableRef);\n const renderer = useTableRenderer<TType>(report.instance, tableRef, props.defaultRowActiveIndex);\n const stylesheet = useStylesheet(report.id, report.instance);\n useTableGlobalShortcuts(report.instance, tableRef, renderer.scrollToIndex);\n\n const handleFocus =\n report.meta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n report.meta.rowActive.handleFocus(event, report.length, renderer.scrollToIndex);\n }\n : undefined;\n\n return (\n <>\n {stylesheet}\n <Toolbar\n customSettings={props.customSettings}\n left={props.toolbarLeft}\n length={report.length}\n right={props.toolbarRight}\n scrollToIndex={renderer.scrollToIndex}\n table={report.instance}\n tableId={report.id}\n tableRef={tableRef}\n />\n {props.toolbarPanel ? <div className=\"mb-4\">{props.toolbarPanel}</div> : undefined}\n <FocusScope>\n <table\n id={report.id}\n data-taco=\"report\"\n data-table-font-size={report.meta.fontSize.size}\n data-table-horizontally-scrolled={report.meta.columnFreezing.isHorizontallyScrolled ? true : undefined}\n data-table-pause-hover={report.meta.rowActive.isHoverStatePaused ? true : undefined}\n data-table-resizing={report.state.columnSizingInfo.isResizingColumn ? true : undefined}\n data-table-row-height={report.meta.rowHeight.height}\n data-table-grouped={!!report.state.grouping?.length}\n onFocus={handleFocus}\n onScroll={report.meta.columnFreezing.handleScroll}\n ref={tableRef}\n tabIndex={-1}>\n <thead>\n {report.instance.getHeaderGroups().map(headerGroup => (\n <tr key={headerGroup.id}>{headerGroup.headers.map(Header)}</tr>\n ))}\n </thead>\n {renderer.rows?.length ? (\n <>\n <Body length={report.length} table={report.instance} style={renderer.style}>\n {renderer.rows}\n </Body>\n {report.meta.footer.isEnabled ? (\n <tfoot>\n <tr>{report.instance.getFooterGroups()[0].headers.map(Footer)}</tr>\n </tfoot>\n ) : null}\n </>\n ) : (\n <EmptyStateBody emptyState={props.emptyState} />\n )}\n </table>\n {report.meta.footer.isEnabled ? <Summary length={report.length} table={report.instance} /> : null}\n </FocusScope>\n </>\n );\n}) as (<TType = unknown>(props: ReportProps<TType> & React.RefAttributes<TableRef>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\nReport.Column = Column;\nReport.Group = Group;\n\nexport * from './types';\n"],"names":["Column","_","Group","Report","fixedForwardRef","props","ref","tableRef","useMergedRef","report","useReport","renderer","useTableRenderer","instance","defaultRowActiveIndex","stylesheet","useStylesheet","id","useTableGlobalShortcuts","scrollToIndex","handleFocus","meta","rowActive","rowActiveIndex","undefined","event","length","React","Toolbar","customSettings","left","toolbarLeft","right","toolbarRight","table","tableId","toolbarPanel","className","FocusScope","fontSize","size","columnFreezing","isHorizontallyScrolled","isHoverStatePaused","state","columnSizingInfo","isResizingColumn","rowHeight","height","_report$state$groupin","grouping","onFocus","onScroll","handleScroll","tabIndex","getHeaderGroups","map","headerGroup","key","headers","Header","_renderer$rows","rows","Body","style","footer","isEnabled","getFooterGroups","Footer","EmptyStateBody","emptyState","Summary"],"mappings":";;;;;;;;;;;;;;;AAkBA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AAEA,SAASC,KAAKA,CAACD,CAAmB;EAC9B,OAA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I,QAAQ,CAACsD,eAAe,EAAE,CAAC,CAAC,CAAC,CAACR,OAAO,CAACH,GAAG,CAACY,MAAM,CAAC,CAAM,CAC/D,IACR,IAAI,CACT,mBAEHzC,6BAAC0C,cAAc;IAACC,UAAU,EAAEjE,KAAK,CAACiE;IAAc,CACnD,CACG,EACP7D,MAAM,CAACY,IAAI,CAAC4C,MAAM,CAACC,SAAS,gBAAGvC,6BAAC4C,OAAO;IAAC7C,MAAM,EAAEjB,MAAM,CAACiB,MAAM;IAAEQ,KAAK,EAAEzB,MAAM,CAACI;IAAY,GAAG,IAAI,CACxF,CACd;AAEX,CAAC;AAIDV,MAAM,CAACH,MAAM,GAAGA,MAAM;AACtBG,MAAM,CAACD,KAAK,GAAGA,KAAK;;;;"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
|
3
|
+
function EmptyStateBody(props) {
|
4
|
+
const {
|
5
|
+
emptyState: Placeholder = null,
|
6
|
+
...attributes
|
7
|
+
} = props;
|
8
|
+
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
9
|
+
className: "!auto-rows-fr"
|
10
|
+
}), /*#__PURE__*/React__default.createElement("tr", {
|
11
|
+
className: "!auto-rows-fr"
|
12
|
+
}, /*#__PURE__*/React__default.createElement("td", {
|
13
|
+
className: "col-span-full !border-0 !p-0 hover:!bg-white"
|
14
|
+
}, Placeholder ? /*#__PURE__*/React__default.createElement(Placeholder, null) : null)));
|
15
|
+
}
|
16
|
+
|
17
|
+
export { EmptyStateBody };
|
18
|
+
//# sourceMappingURL=EmptyStateBody.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EmptyStateBody.js","sources":["../../../../../../../../../src/components/Report/components/Body/EmptyStateBody.tsx"],"sourcesContent":["import React from 'react';\nimport { ReportEmptyStateRenderer } from '../../types';\n\ntype EmptyStateProps = React.HTMLAttributes<HTMLTableSectionElement> & {\n emptyState?: ReportEmptyStateRenderer;\n};\n\nexport function EmptyStateBody(props: EmptyStateProps) {\n const { emptyState: Placeholder = null, ...attributes } = props;\n\n return (\n <tbody {...attributes} className=\"!auto-rows-fr\">\n <tr className=\"!auto-rows-fr\">\n <td className=\"col-span-full !border-0 !p-0 hover:!bg-white\">{Placeholder ? <Placeholder /> : null}</td>\n </tr>\n </tbody>\n );\n}\n"],"names":["EmptyStateBody","props","emptyState","Placeholder","attributes","React","className"],"mappings":";;SAOgBA,cAAcA,CAACC,KAAsB;EACjD,MAAM;IAAEC,UAAU,EAAEC,WAAW,GAAG,IAAI;IAAE,GAAGC;GAAY,GAAGH,KAAK;EAE/D,oBACII,wDAAWD,UAAU;IAAEE,SAAS,EAAC;mBAC7BD;IAAIC,SAAS,EAAC;kBACVD;IAAIC,SAAS,EAAC;KAAgDH,WAAW,gBAAGE,6BAACF,WAAW,OAAG,GAAG,IAAI,CAAM,CACvG,CACD;AAEhB;;;;"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { isInternalColumn, isCellHighlighted } from '../../../../primitives/Table/useTable/util/columns.js';
|
3
|
+
import { RowContext } from '../Row/RowContext.js';
|
3
4
|
|
4
5
|
function getCellAttributes(cell, isHighlighted) {
|
5
6
|
const columnMeta = cell.column.columnDef.meta;
|
@@ -18,7 +19,10 @@ function getCellAttributes(cell, isHighlighted) {
|
|
18
19
|
}
|
19
20
|
return attributes;
|
20
21
|
}
|
21
|
-
function useSearchHighlighting(cell,
|
22
|
+
function useSearchHighlighting(cell, cellIndex, ref) {
|
23
|
+
const {
|
24
|
+
rowIndex
|
25
|
+
} = React__default.useContext(RowContext);
|
22
26
|
const context = cell.getContext();
|
23
27
|
const tableMeta = context.table.options.meta;
|
24
28
|
const columnMeta = cell.column.columnDef.meta;
|
@@ -34,7 +38,7 @@ function useSearchHighlighting(cell, index, ref) {
|
|
34
38
|
return undefined;
|
35
39
|
}
|
36
40
|
const [rowActiveIndex, currentColumnIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];
|
37
|
-
if (rowActiveIndex ===
|
41
|
+
if (rowActiveIndex === rowIndex && currentColumnIndex === cellIndex) {
|
38
42
|
return 'current';
|
39
43
|
}
|
40
44
|
return true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../../../../../../../../src/components/Report/components/Cell/util.ts"],"sourcesContent":["import React from 'react';\nimport { Cell as ReactTableCell, ColumnMeta as ReactTableColumnMeta, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isCellHighlighted, isInternalColumn } from '../../../../primitives/Table/useTable/util/columns';\n\nexport type DisplayCellProps<TType = unknown> = {\n index: number;\n cell: ReactTableCell<TType, unknown>;\n};\n\nexport function getCellAttributes<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n isHighlighted: true | 'current' | undefined\n) {\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n const isPinned = cell.column.getIsPinned();\n const attributes = {\n 'data-cell-align': columnMeta?.align,\n 'data-cell-highlighted': isHighlighted,\n 'data-cell-id': cell.column.id,\n 'data-cell-pinned': isPinned ? true : undefined,\n 'data-cell-truncate': columnMeta.enableTruncate ? true : undefined,\n className: typeof columnMeta.className === 'function' ? columnMeta.className(cell.row.original) : columnMeta.className,\n style: {},\n };\n\n if (isPinned) {\n attributes.style[isPinned] = `${cell.column.getStart(isPinned)}px`;\n }\n\n return attributes;\n}\n\nexport function useSearchHighlighting<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../../../../../../src/components/Report/components/Cell/util.ts"],"sourcesContent":["import React from 'react';\nimport { Cell as ReactTableCell, ColumnMeta as ReactTableColumnMeta, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isCellHighlighted, isInternalColumn } from '../../../../primitives/Table/useTable/util/columns';\nimport { RowContext } from '../Row/RowContext';\n\nexport type DisplayCellProps<TType = unknown> = {\n index: number;\n cell: ReactTableCell<TType, unknown>;\n};\n\nexport function getCellAttributes<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n isHighlighted: true | 'current' | undefined\n) {\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n const isPinned = cell.column.getIsPinned();\n const attributes = {\n 'data-cell-align': columnMeta?.align,\n 'data-cell-highlighted': isHighlighted,\n 'data-cell-id': cell.column.id,\n 'data-cell-pinned': isPinned ? true : undefined,\n 'data-cell-truncate': columnMeta.enableTruncate ? true : undefined,\n className: typeof columnMeta.className === 'function' ? columnMeta.className(cell.row.original) : columnMeta.className,\n style: {},\n };\n\n if (isPinned) {\n attributes.style[isPinned] = `${cell.column.getStart(isPinned)}px`;\n }\n\n return attributes;\n}\n\nexport function useSearchHighlighting<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n cellIndex: number,\n ref: React.RefObject<HTMLTableCellElement>\n) {\n const { rowIndex } = React.useContext(RowContext);\n const context = cell.getContext();\n const tableMeta = context.table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n const isHighlighted: 'current' | boolean | undefined = React.useMemo(() => {\n if (\n !cell.column.columnDef.enableGlobalFilter ||\n isInternalColumn(cell.column.id) ||\n cell.getIsAggregated() ||\n cell.getIsPlaceholder()\n ) {\n return undefined;\n }\n\n let isHighlighted = false;\n\n if (context.table.getState().globalFilter) {\n isHighlighted = isCellHighlighted(context.table.getState().globalFilter, cell.getValue(), columnMeta.dataType);\n }\n\n if (!isHighlighted || tableMeta.search.currentHighlightColumnIndex === undefined) {\n return undefined;\n }\n\n const [rowActiveIndex, currentColumnIndex] =\n tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (rowActiveIndex === rowIndex && currentColumnIndex === cellIndex) {\n return 'current';\n }\n\n return true;\n }, [\n cell.getValue(),\n context.table.getState().globalFilter,\n tableMeta.search.highlightedColumnIndexes.length,\n tableMeta.search.currentHighlightColumnIndex,\n ]);\n\n React.useEffect(() => {\n if (ref.current && isHighlighted === 'current') {\n ref.current.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n\n setTimeout(() => {\n if (ref.current) {\n const tableEl = ref.current.closest('table[data-taco=\"report\"]');\n\n setTimeout(() => {\n const pinnedColumns = tableEl?.querySelectorAll('thead tr:last-child th[data-cell-pinned=\"left\"]');\n\n if (pinnedColumns?.length) {\n const lastFrozenRect = pinnedColumns.item(pinnedColumns.length - 1)?.getBoundingClientRect();\n\n if (lastFrozenRect && cell.column.getStart() < lastFrozenRect.right) {\n tableEl?.scrollTo(cell.column.getStart() - lastFrozenRect.right, tableEl.scrollTop);\n }\n }\n }, 1);\n }\n }, 1);\n }\n }, [isHighlighted]);\n\n return isHighlighted;\n}\n\nexport function getCurrentRowCellElement(index: number, tableEl: HTMLElement) {\n const cellSelector = `[data-current=\"true\"] [data-column-index=\"${index}\"`;\n return tableEl.querySelector(cellSelector);\n}\n\nexport function scrollColumnIntoView(columnIndex: number, frozenColumnIndex: number, column: HTMLElement, tableEl: HTMLElement) {\n if (frozenColumnIndex !== undefined && columnIndex > frozenColumnIndex) {\n const lastFrozenColumnElement = getCurrentRowCellElement(frozenColumnIndex, tableEl);\n const highlightRef = column?.getBoundingClientRect();\n const lastFrozenRect = lastFrozenColumnElement?.getBoundingClientRect();\n\n // offset the width of frozen columns so that the column being scrolled to is not hidden behind them\n if (highlightRef && lastFrozenRect && highlightRef.left < lastFrozenRect.left + lastFrozenRect.width) {\n const pinnedColumnsWidth = lastFrozenRect.left + lastFrozenRect.width;\n tableEl?.scrollTo(highlightRef.left - pinnedColumnsWidth, tableEl.scrollTop);\n }\n } else {\n column.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n}\n"],"names":["getCellAttributes","cell","isHighlighted","columnMeta","column","columnDef","meta","isPinned","getIsPinned","attributes","align","id","undefined","enableTruncate","className","row","original","style","getStart","useSearchHighlighting","cellIndex","ref","rowIndex","React","useContext","RowContext","context","getContext","tableMeta","table","options","useMemo","enableGlobalFilter","isInternalColumn","getIsAggregated","getIsPlaceholder","getState","globalFilter","isCellHighlighted","getValue","dataType","search","currentHighlightColumnIndex","rowActiveIndex","currentColumnIndex","highlightedColumnIndexes","length","useEffect","current","scrollIntoView","block","inline","setTimeout","tableEl","closest","pinnedColumns","querySelectorAll","_pinnedColumns$item","lastFrozenRect","item","getBoundingClientRect","right","scrollTo","scrollTop"],"mappings":";;;;SAUgBA,iBAAiBA,CAC7BC,IAAoC,EACpCC,aAA2C;EAE3C,MAAMC,UAAU,GAAGF,IAAI,CAACG,MAAM,CAACC,SAAS,CAACC,IAA4C;EAErF,MAAMC,QAAQ,GAAGN,IAAI,CAACG,MAAM,CAACI,WAAW,EAAE;EAC1C,MAAMC,UAAU,GAAG;IACf,iBAAiB,EAAEN,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEO,KAAK;IACpC,uBAAuB,EAAER,aAAa;IACtC,cAAc,EAAED,IAAI,CAACG,MAAM,CAACO,EAAE;IAC9B,kBAAkB,EAAEJ,QAAQ,GAAG,IAAI,GAAGK,SAAS;IAC/C,oBAAoB,EAAET,UAAU,CAACU,cAAc,GAAG,IAAI,GAAGD,SAAS;IAClEE,SAAS,EAAE,OAAOX,UAAU,CAACW,SAAS,KAAK,UAAU,GAAGX,UAAU,CAACW,SAAS,CAACb,IAAI,CAACc,GAAG,CAACC,QAAQ,CAAC,GAAGb,UAAU,CAACW,SAAS;IACtHG,KAAK,EAAE;GACV;EAED,IAAIV,QAAQ,EAAE;IACVE,UAAU,CAACQ,KAAK,CAACV,QAAQ,CAAC,MAAMN,IAAI,CAACG,MAAM,CAACc,QAAQ,CAACX,QAAQ,KAAK;;EAGtE,OAAOE,UAAU;AACrB;SAEgBU,qBAAqBA,CACjClB,IAAoC,EACpCmB,SAAiB,EACjBC,GAA0C;EAE1C,MAAM;IAAEC;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EAC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Columns();
|
7
7
|
const columnSizing = table.getState().columnSizing;
|
8
8
|
const globalMinSize = getCellMinWidth(fontSize);
|
9
|
-
|
9
|
+
// header body ?footer
|
10
|
+
const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';
|
10
11
|
return React__default.useMemo(() => {
|
11
12
|
let printGridTemplateColumns = '';
|
12
13
|
const printHiddenColumns = [];
|
@@ -46,7 +47,7 @@ function useCssGridStylesheet(tableId, table, fontSize) {
|
|
46
47
|
// we have to be specific so that nested tables don't inherit the same css
|
47
48
|
const hiddenColumns = printHiddenColumns.map(id => `table[data-taco='report']#${tableId} > thead > tr > th[data-cell-id='${id}']\n,table[data-taco='report']#${tableId} > tbody > tr > td[data-cell-id='${id}']\n`).join(',');
|
48
49
|
return `table[data-taco='report']#${tableId} { grid-template-columns: ${gridTemplateColumns}; grid-template-rows: ${gridTemplateRows}; }
|
49
|
-
@media print { table[data-taco='report']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns} { display: none; } }`;
|
50
|
+
@media print { table[data-taco='report']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''} }`;
|
50
51
|
}, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);
|
51
52
|
}
|
52
53
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCssGridStylesheet.js","sources":["../../../../../../../../src/components/Report/styles/useCssGridStylesheet.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableFontSize } from '../../../primitives/Table/types';\nimport { getCellMinWidth } from '../../../primitives/Table/useTable/util/columns';\n\nexport function useCssGridStylesheet<TType = unknown>(\n tableId: string,\n table: ReactTable<TType>,\n fontSize: TableFontSize\n): string {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const globalMinSize = getCellMinWidth(fontSize);\n\n const gridTemplateRows = 'min-content 1fr min-content'
|
1
|
+
{"version":3,"file":"useCssGridStylesheet.js","sources":["../../../../../../../../src/components/Report/styles/useCssGridStylesheet.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableFontSize } from '../../../primitives/Table/types';\nimport { getCellMinWidth } from '../../../primitives/Table/useTable/util/columns';\n\nexport function useCssGridStylesheet<TType = unknown>(\n tableId: string,\n table: ReactTable<TType>,\n fontSize: TableFontSize\n): string {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const globalMinSize = getCellMinWidth(fontSize);\n\n // header body ?footer\n const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';\n\n return React.useMemo(() => {\n let printGridTemplateColumns = '';\n const printHiddenColumns: string[] = [];\n\n const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {\n if (table.options.enableGrouping && column.getIsGrouped()) {\n return accum;\n }\n\n const minSize = column.columnDef.minSize ?? globalMinSize;\n const width = columnSizing[column.id] as number | 'grow';\n\n let size;\n let printSize;\n\n if (column.id === '__actions') {\n const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */\n size = `minmax(${minWidth}px, auto)`;\n } else if (width !== undefined) {\n const isLastColumn = index === allVisibleColumns.length - 1;\n\n if (isLastColumn) {\n size = `minmax(${minSize}px, auto)`;\n } else if (width === 'grow' || Number.isNaN(width)) {\n size = `minmax(${minSize}px, 1fr)`;\n } else {\n size = `${width < minSize ? minSize : width}px`;\n }\n } else {\n size = `minmax(${minSize}px, auto)`;\n }\n\n if (column.columnDef.meta?.enablePrinting === false) {\n printSize = '';\n printHiddenColumns.push(column.id);\n } else {\n printSize = 'auto';\n }\n\n printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();\n\n return `${accum} ${size}`.trim();\n }, '');\n\n // we have to be specific so that nested tables don't inherit the same css\n const hiddenColumns = printHiddenColumns\n .map(\n id =>\n `table[data-taco='report']#${tableId} > thead > tr > th[data-cell-id='${id}']\\n,table[data-taco='report']#${tableId} > tbody > tr > td[data-cell-id='${id}']\\n`\n )\n .join(',');\n\n return `table[data-taco='report']#${tableId} { grid-template-columns: ${gridTemplateColumns}; grid-template-rows: ${gridTemplateRows}; }\n@media print { table[data-taco='report']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${\n hiddenColumns ? `${hiddenColumns} { display: none; }` : ''\n } }`;\n }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);\n}\n"],"names":["useCssGridStylesheet","tableId","table","fontSize","tableMeta","options","meta","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","globalMinSize","getCellMinWidth","gridTemplateRows","getRowModel","rows","length","React","useMemo","printGridTemplateColumns","printHiddenColumns","gridTemplateColumns","reduce","accum","column","index","enableGrouping","getIsGrouped","minSize","_column$columnDef$min","columnDef","width","id","size","printSize","minWidth","rowActions","rowActionsLength","undefined","isLastColumn","Number","isNaN","_column$columnDef$met","enablePrinting","push","trim","hiddenColumns","map","join"],"mappings":";;;SAKgBA,oBAAoBA,CAChCC,OAAe,EACfC,KAAwB,EACxBC,QAAuB;EAEvB,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,qBAAqB,EAAE;EACvD,MAAMC,YAAY,GAAGP,KAAK,CAACQ,QAAQ,EAAE,CAACD,YAAY;EAClD,MAAME,aAAa,GAAGC,eAAe,CAACT,QAAQ,CAAC;;EAG/C,MAAMU,gBAAgB,GAAGX,KAAK,CAACY,WAAW,EAAE,CAACC,IAAI,CAACC,MAAM,GAAG,6BAA6B,GAAG,iBAAiB;EAE5G,OAAOC,cAAK,CAACC,OAAO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EAAE;QACdd,kBAAkB,CAACwB,IAAI,CAACpB,MAAM,CAACQ,EAAE,CAAC;OACrC,MAAM;QACHE,SAAS,GAAG,MAAM;;MAGtBf,wBAAwB,MAAMA,4BAA4Be,WAAW,CAACW,IAAI,EAAE;MAE5E,UAAUtB,SAASU,MAAM,CAACY,IAAI,EAAE;KACnC,EAAE,EAAE,CAAC;;IAGN,MAAMC,aAAa,GAAG1B,kBAAkB,CACnC2B,GAAG,CACAf,EAAE,iCAC+B/B,2CAA2C+B,oCAAoC/B,2CAA2C+B,QAAQ,CACtK,CACAgB,IAAI,CAAC,GAAG,CAAC;IAEd,oCAAoC/C,oCAAoCoB,4CAA4CR;2CACjFZ,oCAAoCkB,+BACnE2B,aAAa,MAAMA,kCAAkC,GAAG,MACxD;GACP,EAAE,CAACvC,iBAAiB,EAAEE,YAAY,EAAEE,aAAa,EAAEP,SAAS,CAACgC,UAAU,CAACC,gBAAgB,CAAC,CAAC;AAC/F;;;;"}
|
@@ -198,6 +198,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
198
198
|
onBlur: handleBlur,
|
199
199
|
onKeyDown: handleKeyDown,
|
200
200
|
ref: internalRef,
|
201
|
+
fontSize: fontSize,
|
201
202
|
placeholder: placeholder
|
202
203
|
}), flattenedChildren)), /*#__PURE__*/React__default.createElement(Portal, null, /*#__PURE__*/React__default.createElement(Content, {
|
203
204
|
asChild: true,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement } from '../../utils/dom';\nimport { FontSize } from '../../types';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n autoFocus?: boolean;\n children: Select2Children;\n defaultValue?: Select2Value;\n emptyValue?: Select2OptionValue;\n disabled?: boolean;\n highlighted?: boolean;\n invalid?: boolean;\n multiple?: boolean;\n name?: string;\n onChange?: (value: Select2Value) => void;\n onCreate?: Select2CreateHandler;\n onDelete?: Select2DeleteHandler;\n onEdit?: Select2EditHandler;\n readOnly?: boolean;\n required?: boolean;\n tags?: boolean;\n value?: Select2Value;\n fontSize?: FontSize;\n placeholder?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n placeholder,\n highlighted = false,\n invalid = false,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n readOnly = false,\n tags = false,\n value: prop,\n fontSize,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [tabTriggeredClose, setTabTriggeredClose] = React.useState(false);\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n\n if (tabTriggeredClose) {\n const nextFocussableElement = getNextFocussableElement(internalRef.current);\n\n if (nextFocussableElement) {\n // UX requirement: move focus to the next focussable element when tab key is pressed to select the value\n nextFocussableElement.focus();\n // Reset the tabTriggeredClose state\n setTabTriggeredClose(false);\n }\n } else {\n internalRef.current?.focus();\n }\n };\n\n const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none', createCollectionClassName());\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}\n placeholder={placeholder}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={handleCloseAutoFocus}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n onTabKeyPress={() => setTabTriggeredClose(true)}\n />\n ) : null}\n {flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n No results found...\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n tabIndex={-1}\n value={value}>\n {searchQuery === '' ? (\n <Collection>{initialChildren}</Collection>\n ) : (\n <Collection>{filteredChildren}</Collection>\n )}\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\nconst ControlledHiddenField = props => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","placeholder","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","fontSize","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","tabTriggeredClose","setTabTriggeredClose","useState","open","setOpen","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","handleKeyDown","event","preventDefault","ctrlKey","metaKey","test","_listboxRef$current","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","currentTarget","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","map","child","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current2","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","length","Search","select2","searchOrCreate","search","onTabKeyPress","role","customSelector","Collection","Create","Group","Title","isFormControl","useIsFormControl","bubbleValue","Array","isArray","String","BubbleSelect","option","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2EMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAOA,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,YAAY;IACtBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,WAAW;IACXC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,QAAQ,GAAG,KAAK;IAChBC,IAAI;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,KAAK,EAAEC,IAAI;IACXC,QAAQ;IACR,GAAGC;GACN,GAAGvB,KAAK;EAET,MAAMwB,WAAW,GAAuD1B,cAAK,CAAC2B,OAAO,CAAC;IAClF,IAAIlB,UAAU,KAAKC,SAAS,IAAI,CAACI,QAAQ,EAAE;;MAEvC,oBAAOd,6BAAC4B,MAAM;QAACC,GAAG,EAAC,SAAS;QAACzB,QAAQ,EAAC,EAAE;QAACkB,KAAK,EAAEb,UAAU;QAAEqB,SAAS,EAAC;QAAQ;;IAElF;GACH,EAAE,CAACrB,UAAU,EAAEK,QAAQ,CAAC,CAAC;EAE1B,MAAMiB,eAAe,GAAG/B,cAAK,CAAC2B,OAAO,CAAC;IAClC,IAAID,WAAW,EAAE;MACb,OAAO,CAACA,WAAW,EAAE,GAAGrB,YAAY,CAAoB;;IAE5D,OAAOA,YAAY;GACtB,EAAE,CAACqB,WAAW,EAAErB,YAAY,CAAC,CAAC;;EAG/B,MAAM2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EA,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEO,KAAK,EAAE0G;OACtFvH,UAAU,KAAKC,SAAS,gBAAGV;MAAQsB,KAAK,EAAEb;MAAc,GAAG,IAAI,EAC/DyF,OAAO,CAACC,GAAG,CAACkC,MAAM,mBACfrI;MAAQ6B,GAAG,EAAEsG,MAAM,CAACE,MAAM,CAAC;MAAE/G,KAAK,EAAE6G,MAAM,CAACE,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDtI,OAAO,CAACuI,WAAW,GAAG,SAAS;;;;"}
|
1
|
+
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement } from '../../utils/dom';\nimport { FontSize } from '../../types';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n autoFocus?: boolean;\n children: Select2Children;\n defaultValue?: Select2Value;\n emptyValue?: Select2OptionValue;\n disabled?: boolean;\n highlighted?: boolean;\n invalid?: boolean;\n multiple?: boolean;\n name?: string;\n onChange?: (value: Select2Value) => void;\n onCreate?: Select2CreateHandler;\n onDelete?: Select2DeleteHandler;\n onEdit?: Select2EditHandler;\n readOnly?: boolean;\n required?: boolean;\n tags?: boolean;\n value?: Select2Value;\n fontSize?: FontSize;\n placeholder?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n placeholder,\n highlighted = false,\n invalid = false,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n readOnly = false,\n tags = false,\n value: prop,\n fontSize,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [tabTriggeredClose, setTabTriggeredClose] = React.useState(false);\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n\n if (tabTriggeredClose) {\n const nextFocussableElement = getNextFocussableElement(internalRef.current);\n\n if (nextFocussableElement) {\n // UX requirement: move focus to the next focussable element when tab key is pressed to select the value\n nextFocussableElement.focus();\n // Reset the tabTriggeredClose state\n setTabTriggeredClose(false);\n }\n } else {\n internalRef.current?.focus();\n }\n };\n\n const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none', createCollectionClassName());\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}\n fontSize={fontSize}\n placeholder={placeholder}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={handleCloseAutoFocus}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n onTabKeyPress={() => setTabTriggeredClose(true)}\n />\n ) : null}\n {flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n No results found...\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n tabIndex={-1}\n value={value}>\n {searchQuery === '' ? (\n <Collection>{initialChildren}</Collection>\n ) : (\n <Collection>{filteredChildren}</Collection>\n )}\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\nconst ControlledHiddenField = props => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","placeholder","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","fontSize","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","tabTriggeredClose","setTabTriggeredClose","useState","open","setOpen","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","handleKeyDown","event","preventDefault","ctrlKey","metaKey","test","_listboxRef$current","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","currentTarget","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","map","child","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current2","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","length","Search","select2","searchOrCreate","search","onTabKeyPress","role","customSelector","Collection","Create","Group","Title","isFormControl","useIsFormControl","bubbleValue","Array","isArray","String","BubbleSelect","option","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2EMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAOA,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,YAAY;IACtBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,WAAW;IACXC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,QAAQ,GAAG,KAA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
import { getInputClasses } from '../../Input/util.js';
|
9
9
|
import { ScrollArea } from '../../ScrollArea/ScrollArea.js';
|
10
|
+
import { FontSizes } from '../../../types.js';
|
10
11
|
import { Tag } from '../../Tag/Tag.js';
|
11
12
|
import { useSelect2Context } from './Context.js';
|
12
13
|
|
@@ -33,6 +34,7 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Select2TriggerBut
|
|
33
34
|
children,
|
34
35
|
onClick,
|
35
36
|
tabIndex = 0,
|
37
|
+
fontSize,
|
36
38
|
...otherProps
|
37
39
|
} = props;
|
38
40
|
const {
|
@@ -42,14 +44,17 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Select2TriggerBut
|
|
42
44
|
open,
|
43
45
|
readOnly
|
44
46
|
} = useSelect2Context();
|
45
|
-
const className = cn('cursor-pointer
|
47
|
+
const className = cn('cursor-pointer px-1.5 h-fit', getInputClasses({
|
46
48
|
...props,
|
47
49
|
disabled,
|
48
50
|
highlighted,
|
49
51
|
invalid,
|
50
52
|
readOnly
|
51
|
-
}).replace('w-full', ''), {
|
52
|
-
'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-'))
|
53
|
+
}).replace('w-full', '').replace('px-2', ''), {
|
54
|
+
'w-full': !((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('w-')),
|
55
|
+
'text-xs': fontSize === FontSizes.small,
|
56
|
+
'text-sm': fontSize === FontSizes.medium,
|
57
|
+
'text-base': fontSize === FontSizes.large
|
53
58
|
}, props.className);
|
54
59
|
const handleClick = event => {
|
55
60
|
if (disabled || readOnly) {
|
@@ -143,7 +148,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
143
148
|
className
|
144
149
|
} = buttonProps;
|
145
150
|
if (open) {
|
146
|
-
className = cn('!absolute z-20', buttonProps.className);
|
151
|
+
className = cn('!absolute z-20 !h-fit', buttonProps.className);
|
147
152
|
content = /*#__PURE__*/React__default.createElement(ScrollArea, {
|
148
153
|
className: "my-1 flex max-h-[5.5rem] flex-col"
|
149
154
|
}, /*#__PURE__*/React__default.createElement("div", {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer !px-1 h-fit',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly }).replace('w-full', ''),\n { 'w-full': !props.className?.includes('w-') },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.prefix}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.prefix ? (\n typeof currentValue.props.prefix === 'string' ? (\n <Icon name={currentValue.props.prefix} className=\"mr-1 !h-5 !w-5\" />\n ) : (\n currentValue.props.prefix\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className=\"relative inline-flex h-fit flex-grow\"\n data-taco=\"select2-container\"\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","_props$className","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","prefix","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;MAoBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,EAAEA;OAAU;;EAG5D,oBAAOV,6BAACa,MAAM,oBAAKV,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEE,KAAK,EAAEA;KAAS;AACxD,CAAC;AAKD,MAAMQ,MAAM,gBAAGd,cAAK,CAACC,UAAU,CAAiC,SAASc,oBAAoBA,CAACZ,KAAK,EAAEC,GAAG;;EACpG,MAAM;IAAEY,QAAQ;IAAEC,OAAO;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGhB,KAAK;EAChE,MAAM;IAAEiB,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEC,IAAI;IAAEC;GAAU,GAAGjB,iBAAiB,EAAE;EAE9E,MAAMkB,SAAS,GAAGC,EAAE,CAChB,4BAA4B,EAC5BC,eAAe,CAAC;IAAE,GAAGxB,KAAK;IAAEiB,QAAQ;I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K,CAAC7D,KAAK,CAACG,KAAK,CAAC,GAAGK,SAAS;MAClEa,QAAQ,EAAEA;OACTwC,KAAK,CAAC7D,KAAK,CAACa,QAAQ,CAE5B;IAED,IAAImE,KAAK,KAAKL,aAAa,EAAE;MACzB,oBACI9E,6BAACuF,OAAO;QAACtB,GAAG,EAAEC,MAAM,CAACF,KAAK,CAAC7D,KAAK,CAACG,KAAK,CAAC;QAAEkF,KAAK,EAAEtB,MAAM,CAACF,KAAK,CAAC7D,KAAK,CAACa,QAAQ;SACtEoE,GAAG,CACE;;IAIlB,OAAOA,GAAG;GACb,CACJ,CACC,EACLN,aAAa,KAAKnE,SAAS,IAAImE,aAAa,KAAK,IAAI,IAAIA,aAAa,GAAGrB,gBAAgB,CAACM,MAAM,GAAG,CAAC,kBACjG/D,6BAACuF,OAAO;IACJC,KAAK,EAAE/B,gBAAgB,CAClBgC,KAAK,CAACX,aAAa,GAAG,CAAC,CAAC,CACxBpB,GAAG,CAACM,KAAK,IAAKA,KAAK,GAAGE,MAAM,CAACF,KAAK,CAAC7D,KAAK,CAACa,QAAQ,CAAC,GAAG,EAAG,CAAC,CACzD0E,IAAI,CAAC,IAAI;kBACd1F,6BAAC2F,KAAK;IAAClE,SAAS,EAAC;UAAkBgC,gBAAgB,CAACM,MAAM,IAAIe,aAAa,GAAG,CAAC,CAAC,CAAS,CACnF,IACV,IAAI,CACN;AAEd,CAAC;AAED,MAAMhC,YAAY,GAAIxC,KAA8B,IAAM0D,KAA8B;EACpF,IAAIxD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACwB,QAAQ,CAACkC,KAAK,CAAC7D,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAO0D,KAAK,CAAC7D,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { FontSize, FontSizes } from '../../../types';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n fontSize?: FontSize;\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, fontSize, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer px-1.5 h-fit',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly })\n .replace('w-full', '')\n .replace('px-2', ''),\n {\n 'w-full': !props.className?.includes('w-'),\n 'text-xs': fontSize === FontSizes.small,\n 'text-sm': fontSize === FontSizes.medium,\n 'text-base': fontSize === FontSizes.large,\n },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.prefix}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.prefix ? (\n typeof currentValue.props.prefix === 'string' ? (\n <Icon name={currentValue.props.prefix} className=\"mr-1 !h-5 !w-5\" />\n ) : (\n currentValue.props.prefix\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20 !h-fit', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className=\"relative inline-flex h-fit flex-grow\"\n data-taco=\"select2-container\"\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","fontSize","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","_props$className","includes","FontSizes","small","medium","large","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","prefix","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;;MAsBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,EAAEA;OAAU;;EAG5D,oBAAOV,6BAACa,MAAM,oBAAKV,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEE,KAAK,EAAEA;KAAS;AACxD,CAAC;AAKD,MAAMQ,MAAM,gBAAGd,cAAK,CAACC,UAAU,CAAiC,SAASc,oBAAoBA,CAACZ,KAAK,EAAEC,GAAG;;EACpG,MAAM;IAAEY,QAAQ;IAAEC,OAAO;IAAEC,QAAQ,GAAG,CAAC;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGjB,KAAK;EAC1E,MAAM;IAAEkB,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEC,IAAI;IAAEC;GAAU,GAAGlB,iBAAiB,EAAE;EAE9E,MAAMmB,SAAS,GAAGC,EAAE,CAChB,6BAA6B,EAC7BC,eAAe,CAAC;IAAE,GAAGzB,KAAK;I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CAAClE,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAO+D,KAAK,CAAClE,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
@@ -28,7 +28,7 @@ function EditingCell(props) {
|
|
28
28
|
}));
|
29
29
|
}
|
30
30
|
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
31
|
-
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$rowAc, _column$columnDef$met;
|
31
|
+
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$rowAc, _column$columnDef$met, _column$columnDef$met2;
|
32
32
|
const {
|
33
33
|
cell,
|
34
34
|
column,
|
@@ -163,7 +163,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
163
163
|
}));
|
164
164
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && !error ? ( /*#__PURE__*/React__default.createElement(Indicator, {
|
165
165
|
reason: moveReason,
|
166
|
-
columnName: String(
|
166
|
+
columnName: String((_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.header),
|
167
167
|
mountNode: mountNode,
|
168
168
|
validationErrors: []
|
169
169
|
})) : null, /*#__PURE__*/React__default.createElement("div", {
|