@leav/ui 1.5.0-d52b4754 → 1.5.0-e0f0cfb7
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/Explorer/DataView.js +4 -3
- package/dist/components/Explorer/DataView.js.map +1 -1
- package/dist/components/Explorer/Explorer.js +1 -1
- package/dist/components/Explorer/Explorer.js.map +1 -1
- package/dist/components/Explorer/ExplorerFiltersAndSorts.d.ts +1 -0
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js +2 -2
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js.map +1 -1
- package/dist/components/Explorer/ExplorerToolbar.d.ts +1 -0
- package/dist/components/Explorer/ExplorerToolbar.js +2 -2
- package/dist/components/Explorer/ExplorerToolbar.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistory.js +11 -6
- package/dist/components/RecordHistory/RecordHistory.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js +13 -7
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
- package/package.json +4 -4
|
@@ -88,9 +88,10 @@ export const DataView = memo(({ dataGroupedFilteredSorted, attributesToDisplay,
|
|
|
88
88
|
title: attributeName === WHO_AM_I_COLUMN ? t('explorer.name') : attributesProperties[attributeName].label,
|
|
89
89
|
dataIndex: USELESS,
|
|
90
90
|
width: getFieldColumnWidth(attributesProperties[attributeName]),
|
|
91
|
-
shouldCellUpdate: (record, prevRecord) =>
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
shouldCellUpdate: (record, prevRecord) => isMassSelectionAll ||
|
|
92
|
+
(attributeName === WHO_AM_I_COLUMN
|
|
93
|
+
? record.whoAmI !== prevRecord.whoAmI
|
|
94
|
+
: record.propertiesById[attributeName] !== prevRecord.propertiesById[attributeName]),
|
|
94
95
|
render: (_, item) => attributeName === WHO_AM_I_COLUMN ? (_jsx(TableNameCell, { item: item, itemActions: itemActions })) : (_jsx(TableCell, { attributeProperties: attributesProperties[attributeName], values: item.propertiesById[attributeName] })),
|
|
95
96
|
}));
|
|
96
97
|
//TODO: test row click
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataView.js","sourceRoot":"","sources":["../../../src/components/Explorer/DataView.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAwD,IAAI,EAAC,MAAM,OAAO,CAAC;AAClF,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEnD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,uBAAuB,EAAE,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;0BAUnB,uBAAuB;;;;;;;;;;CAUhD,CAAC;AAEF,6DAA6D;AAC7D,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;;;;kBAIlB,cAAc;;;0BAGN,wBAAwB;;;;;;;;;;;;;;0BAcxB,cAAc;;;;;;;;;;CAUvC,CAAC;AAwBF,wKAAwK;AACxK,MAAM,aAAa,GAAG,CAAC,SAAyB,EAAE,SAAyB,EAAE,EAAE,CAC3E,OAA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B;iBAC7C,CAAC,EACF,UAAU,EAAE,yBAAyB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,eAAe,EACpE,OAAO,EAAE,OAAO,EAChB,WAAW,EAAC,OAAO,EACnB,MAAM,EAAE,EAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,EAAE,MAAM,EAAC,EAC/D,UAAU,EAAE,yBAAyB,EACrC,UAAU,EAAE,KAAK,EACjB,YAAY,EAAE,aAAa,EAC3B,KAAK,EAAE,CAAC,IAAe,EAAE,EAAE,CAAC,CAAC;oBACzB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAyB,EAAE,QAAQ,CAAC,IAAI,CAAC;iBAC3D,CAAC,GACJ,EACD,eAAe,IAAI,CAChB,cAAK,SAAS,EAAC,YAAY,YACvB,KAAC,aAAa,kBACC,YAAY,EACvB,eAAe,QACf,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAC7B,CAAC,CAAC,kCAAkC,EAAE,EAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,EAEnE,KAAK,EAAE,eAAe,CAAC,UAAU,EACjC,cAAc,EAAE,eAAe,CAAC,WAAW,EAC3C,eAAe,EAAE,eAAe,CAAC,QAAQ,EACzC,eAAe,EAAE,eAAe,CAAC,eAAe,EAChD,QAAQ,EAAE,eAAe,CAAC,UAAU,EACpC,gBAAgB,EAAE,eAAe,CAAC,cAAc,GAClD,GACA,CACT,IACwB,CAChC,CAAC;AACN,CAAC,EACD,aAAa,CAChB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ComponentProps, type FunctionComponent, type Key, memo} from 'react';\nimport {KitPagination, KitTable} from 'aristid-ds';\nimport {type KitTableColumnType} from 'aristid-ds/dist/Kit/DataDisplay/Table/types';\nimport styled from 'styled-components';\nimport isEqual from 'lodash/isEqual';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IExplorerData, type IItemAction, type IItemData} from './_types';\nimport {TableCell} from './TableCell';\nimport {defaultPaginationHeight, useTableScrollableHeight} from './useTableScrollableHeight';\nimport {useColumnWidth} from './useColumnWidth';\nimport {WHO_AM_I_COLUMN} from './_constants';\nimport {TableNameCell} from './TableNameCell';\nimport cn from 'classnames';\n\nconst USELESS = '';\n\nconst tableRowHeight = 56;\nconst tableHeaderMinLineHeight = 22;\n\nconst DataViewContainerDivStyled = styled.div`\n flex: 1 1 min-content;\n max-height: minmax(0, 1fr);\n overflow: hidden;\n\n &.headless {\n overflow-y: auto;\n }\n\n .kit-table {\n padding-bottom: ${defaultPaginationHeight}px;\n position: relative;\n }\n\n .pagination {\n flex: 0 0 auto;\n justify-content: center;\n display: flex;\n padding-top: calc(var(--general-spacing-xs) * 1px);\n }\n`;\n\n// TODO: Table component should be updated fix header display\nconst StyledTable = styled(KitTable)`\n .ant-table-thead > tr > th {\n padding-top: calc(var(--general-spacing-xxs) * 1px) !important;\n padding-bottom: calc(var(--general-spacing-xxs) * 1px) !important;\n height: ${tableRowHeight}px;\n\n .ant-table-cell {\n min-height: ${tableHeaderMinLineHeight}px;\n height: auto !important;\n padding: 0 calc(var(--general-spacing-s) * 1px) 0 0;\n }\n }\n\n .ant-table-tbody > tr:hover .ant-table-cell {\n .actions-list {\n display: inline-flex;\n }\n }\n\n .ant-table-tbody > tr {\n .ant-table-cell {\n min-height: ${tableRowHeight}px;\n height: auto !important;\n }\n }\n\n &.row-clickable {\n .ant-table-tbody > tr {\n cursor: pointer;\n }\n }\n`;\n\ninterface IDataViewProps {\n dataGroupedFilteredSorted: IItemData[];\n itemActions: IItemAction[];\n attributesProperties: IExplorerData['attributes'];\n attributesToDisplay: string[];\n paginationProps?: {\n pageSizeOptions: number[];\n totalCount: number;\n currentPage: number;\n pageSize: number;\n setNewPage: (page: number, pageSize: number) => void;\n setNewPageSize: (page: number, pageSize: number) => void;\n };\n selection: {\n onSelectionChange: null | ((keys: Key[]) => void);\n isMassSelectionAll: boolean;\n selectedKeys: Key[];\n mode?: 'simple' | 'multiple';\n };\n hideTableHeader: boolean;\n}\n\n// TODO: tests will fail if we don't check attributeToDisplay because we have a render with no attributes but data is present. We should check why there's this behavior\nconst arePropsEqual = (prevProps: IDataViewProps, nextProps: IDataViewProps) =>\n isEqual(\n {\n attributesToDisplay: prevProps.attributesToDisplay,\n data: prevProps.dataGroupedFilteredSorted,\n selectedKeys: prevProps.selection.selectedKeys,\n },\n {\n attributesToDisplay: nextProps.attributesToDisplay,\n data: nextProps.dataGroupedFilteredSorted,\n selectedKeys: nextProps.selection.selectedKeys,\n },\n );\n\nexport const DataView: FunctionComponent<IDataViewProps> = memo(\n ({\n dataGroupedFilteredSorted,\n attributesToDisplay,\n attributesProperties,\n paginationProps,\n itemActions,\n selection: {onSelectionChange, selectedKeys, isMassSelectionAll, mode},\n hideTableHeader = false,\n }) => {\n const {t} = useSharedTranslation();\n\n const {containerRef, scrollHeight} = useTableScrollableHeight(!!paginationProps);\n const {getFieldColumnWidth} = useColumnWidth();\n\n const columns = attributesToDisplay.map<KitTableColumnType<IItemData>>(attributeName => ({\n title: attributeName === WHO_AM_I_COLUMN ? t('explorer.name') : attributesProperties[attributeName].label,\n dataIndex: USELESS,\n width: getFieldColumnWidth(attributesProperties[attributeName]),\n shouldCellUpdate: (record, prevRecord) =>\n attributeName === WHO_AM_I_COLUMN\n ? record.whoAmI !== prevRecord.whoAmI\n : record.propertiesById[attributeName] !== prevRecord.propertiesById[attributeName],\n render: (_, item) =>\n attributeName === WHO_AM_I_COLUMN ? (\n <TableNameCell item={item} itemActions={itemActions} />\n ) : (\n <TableCell\n attributeProperties={attributesProperties[attributeName]}\n values={item.propertiesById[attributeName]}\n />\n ),\n }));\n\n //TODO: test row click\n const itemActionToUseOnRowClick = itemActions.find(itemAction => itemAction.useItemActionOnRowClick);\n\n const _rowSelection: ComponentProps<typeof KitTable>['rowSelection'] =\n onSelectionChange === null\n ? undefined\n : {\n type: mode === 'simple' ? 'radio' : 'checkbox',\n columnTitle: ' ', // blank string to hide select all checkbox from <KitTable />\n selectedRowKeys: selectedKeys,\n preserveSelectedRowKeys: true,\n // TODO: review types from antd directly\n onChange: (selectedRowKeys: Key[]) => onSelectionChange(selectedRowKeys),\n getCheckboxProps: isMassSelectionAll\n ? () => ({\n disabled: true,\n })\n : undefined,\n };\n\n // TODO: handle columns width based on attribute type/format\n return (\n <DataViewContainerDivStyled ref={containerRef} className={cn({headless: hideTableHeader})}>\n <StyledTable\n className={cn({\n 'row-clickable': itemActionToUseOnRowClick,\n })}\n showHeader={dataGroupedFilteredSorted.length > 0 && !hideTableHeader}\n columns={columns}\n tableLayout=\"fixed\"\n scroll={{y: hideTableHeader ? '100%' : scrollHeight, x: '100%'}}\n dataSource={dataGroupedFilteredSorted}\n pagination={false}\n rowSelection={_rowSelection}\n onRow={(item: IItemData) => ({\n onClick: () => itemActionToUseOnRowClick?.callback(item),\n })}\n />\n {paginationProps && (\n <div className=\"pagination\">\n <KitPagination\n aria-label=\"pagination\"\n showSizeChanger\n showTotal={(total, [from, to]) =>\n t('explorer.pagination-total-number', {from, to, count: total})\n }\n total={paginationProps.totalCount}\n defaultCurrent={paginationProps.currentPage}\n defaultPageSize={paginationProps.pageSize}\n pageSizeOptions={paginationProps.pageSizeOptions}\n onChange={paginationProps.setNewPage}\n onShowSizeChange={paginationProps.setNewPageSize}\n />\n </div>\n )}\n </DataViewContainerDivStyled>\n );\n },\n arePropsEqual,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"DataView.js","sourceRoot":"","sources":["../../../src/components/Explorer/DataView.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAwD,IAAI,EAAC,MAAM,OAAO,CAAC;AAClF,O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M,EAAC,EAC/D,UAAU,EAAE,yBAAyB,EACrC,UAAU,EAAE,KAAK,EACjB,YAAY,EAAE,aAAa,EAC3B,KAAK,EAAE,CAAC,IAAe,EAAE,EAAE,CAAC,CAAC;oBACzB,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAyB,EAAE,QAAQ,CAAC,IAAI,CAAC;iBAC3D,CAAC,GACJ,EACD,eAAe,IAAI,CAChB,cAAK,SAAS,EAAC,YAAY,YACvB,KAAC,aAAa,kBACC,YAAY,EACvB,eAAe,QACf,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAC7B,CAAC,CAAC,kCAAkC,EAAE,EAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,EAEnE,KAAK,EAAE,eAAe,CAAC,UAAU,EACjC,cAAc,EAAE,eAAe,CAAC,WAAW,EAC3C,eAAe,EAAE,eAAe,CAAC,QAAQ,EACzC,eAAe,EAAE,eAAe,CAAC,eAAe,EAChD,QAAQ,EAAE,eAAe,CAAC,UAAU,EACpC,gBAAgB,EAAE,eAAe,CAAC,cAAc,GAClD,GACA,CACT,IACwB,CAChC,CAAC;AACN,CAAC,EACD,aAAa,CAChB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ComponentProps, type FunctionComponent, type Key, memo} from 'react';\nimport {KitPagination, KitTable} from 'aristid-ds';\nimport {type KitTableColumnType} from 'aristid-ds/dist/Kit/DataDisplay/Table/types';\nimport styled from 'styled-components';\nimport isEqual from 'lodash/isEqual';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IExplorerData, type IItemAction, type IItemData} from './_types';\nimport {TableCell} from './TableCell';\nimport {defaultPaginationHeight, useTableScrollableHeight} from './useTableScrollableHeight';\nimport {useColumnWidth} from './useColumnWidth';\nimport {WHO_AM_I_COLUMN} from './_constants';\nimport {TableNameCell} from './TableNameCell';\nimport cn from 'classnames';\n\nconst USELESS = '';\n\nconst tableRowHeight = 56;\nconst tableHeaderMinLineHeight = 22;\n\nconst DataViewContainerDivStyled = styled.div`\n flex: 1 1 min-content;\n max-height: minmax(0, 1fr);\n overflow: hidden;\n\n &.headless {\n overflow-y: auto;\n }\n\n .kit-table {\n padding-bottom: ${defaultPaginationHeight}px;\n position: relative;\n }\n\n .pagination {\n flex: 0 0 auto;\n justify-content: center;\n display: flex;\n padding-top: calc(var(--general-spacing-xs) * 1px);\n }\n`;\n\n// TODO: Table component should be updated fix header display\nconst StyledTable = styled(KitTable)`\n .ant-table-thead > tr > th {\n padding-top: calc(var(--general-spacing-xxs) * 1px) !important;\n padding-bottom: calc(var(--general-spacing-xxs) * 1px) !important;\n height: ${tableRowHeight}px;\n\n .ant-table-cell {\n min-height: ${tableHeaderMinLineHeight}px;\n height: auto !important;\n padding: 0 calc(var(--general-spacing-s) * 1px) 0 0;\n }\n }\n\n .ant-table-tbody > tr:hover .ant-table-cell {\n .actions-list {\n display: inline-flex;\n }\n }\n\n .ant-table-tbody > tr {\n .ant-table-cell {\n min-height: ${tableRowHeight}px;\n height: auto !important;\n }\n }\n\n &.row-clickable {\n .ant-table-tbody > tr {\n cursor: pointer;\n }\n }\n`;\n\ninterface IDataViewProps {\n dataGroupedFilteredSorted: IItemData[];\n itemActions: IItemAction[];\n attributesProperties: IExplorerData['attributes'];\n attributesToDisplay: string[];\n paginationProps?: {\n pageSizeOptions: number[];\n totalCount: number;\n currentPage: number;\n pageSize: number;\n setNewPage: (page: number, pageSize: number) => void;\n setNewPageSize: (page: number, pageSize: number) => void;\n };\n selection: {\n onSelectionChange: null | ((keys: Key[]) => void);\n isMassSelectionAll: boolean;\n selectedKeys: Key[];\n mode?: 'simple' | 'multiple';\n };\n hideTableHeader: boolean;\n}\n\n// TODO: tests will fail if we don't check attributeToDisplay because we have a render with no attributes but data is present. We should check why there's this behavior\nconst arePropsEqual = (prevProps: IDataViewProps, nextProps: IDataViewProps) =>\n isEqual(\n {\n attributesToDisplay: prevProps.attributesToDisplay,\n data: prevProps.dataGroupedFilteredSorted,\n selectedKeys: prevProps.selection.selectedKeys,\n },\n {\n attributesToDisplay: nextProps.attributesToDisplay,\n data: nextProps.dataGroupedFilteredSorted,\n selectedKeys: nextProps.selection.selectedKeys,\n },\n );\n\nexport const DataView: FunctionComponent<IDataViewProps> = memo(\n ({\n dataGroupedFilteredSorted,\n attributesToDisplay,\n attributesProperties,\n paginationProps,\n itemActions,\n selection: {onSelectionChange, selectedKeys, isMassSelectionAll, mode},\n hideTableHeader = false,\n }) => {\n const {t} = useSharedTranslation();\n\n const {containerRef, scrollHeight} = useTableScrollableHeight(!!paginationProps);\n const {getFieldColumnWidth} = useColumnWidth();\n\n const columns = attributesToDisplay.map<KitTableColumnType<IItemData>>(attributeName => ({\n title: attributeName === WHO_AM_I_COLUMN ? t('explorer.name') : attributesProperties[attributeName].label,\n dataIndex: USELESS,\n width: getFieldColumnWidth(attributesProperties[attributeName]),\n shouldCellUpdate: (record, prevRecord) =>\n isMassSelectionAll ||\n (attributeName === WHO_AM_I_COLUMN\n ? record.whoAmI !== prevRecord.whoAmI\n : record.propertiesById[attributeName] !== prevRecord.propertiesById[attributeName]),\n render: (_, item) =>\n attributeName === WHO_AM_I_COLUMN ? (\n <TableNameCell item={item} itemActions={itemActions} />\n ) : (\n <TableCell\n attributeProperties={attributesProperties[attributeName]}\n values={item.propertiesById[attributeName]}\n />\n ),\n }));\n\n //TODO: test row click\n const itemActionToUseOnRowClick = itemActions.find(itemAction => itemAction.useItemActionOnRowClick);\n\n const _rowSelection: ComponentProps<typeof KitTable>['rowSelection'] =\n onSelectionChange === null\n ? undefined\n : {\n type: mode === 'simple' ? 'radio' : 'checkbox',\n columnTitle: ' ', // blank string to hide select all checkbox from <KitTable />\n selectedRowKeys: selectedKeys,\n preserveSelectedRowKeys: true,\n // TODO: review types from antd directly\n onChange: (selectedRowKeys: Key[]) => onSelectionChange(selectedRowKeys),\n getCheckboxProps: isMassSelectionAll\n ? () => ({\n disabled: true,\n })\n : undefined,\n };\n\n // TODO: handle columns width based on attribute type/format\n return (\n <DataViewContainerDivStyled ref={containerRef} className={cn({headless: hideTableHeader})}>\n <StyledTable\n className={cn({\n 'row-clickable': itemActionToUseOnRowClick,\n })}\n showHeader={dataGroupedFilteredSorted.length > 0 && !hideTableHeader}\n columns={columns}\n tableLayout=\"fixed\"\n scroll={{y: hideTableHeader ? '100%' : scrollHeight, x: '100%'}}\n dataSource={dataGroupedFilteredSorted}\n pagination={false}\n rowSelection={_rowSelection}\n onRow={(item: IItemData) => ({\n onClick: () => itemActionToUseOnRowClick?.callback(item),\n })}\n />\n {paginationProps && (\n <div className=\"pagination\">\n <KitPagination\n aria-label=\"pagination\"\n showSizeChanger\n showTotal={(total, [from, to]) =>\n t('explorer.pagination-total-number', {from, to, count: total})\n }\n total={paginationProps.totalCount}\n defaultCurrent={paginationProps.currentPage}\n defaultPageSize={paginationProps.pageSize}\n pageSizeOptions={paginationProps.pageSizeOptions}\n onChange={paginationProps.setNewPage}\n onShowSizeChange={paginationProps.setNewPageSize}\n />\n </div>\n )}\n </DataViewContainerDivStyled>\n );\n },\n arePropsEqual,\n);\n"]}
|
|
@@ -165,7 +165,7 @@ export const Explorer = forwardRef(({ entrypoint, itemActions = [], primaryActio
|
|
|
165
165
|
linkAction: linkPrimaryAction,
|
|
166
166
|
totalCount,
|
|
167
167
|
}), [createPrimaryAction?.disabled, linkPrimaryAction?.disabled, totalCount]);
|
|
168
|
-
return (_jsxs(_Fragment, { children: [_jsx(FiltersContext.Provider, { value: { filtersData, dispatch: filtersDispatch }, children: _jsxs(ViewSettingsContext.Provider, { value: { view, dispatch: viewSettingsDispatch }, children: [_jsxs(ExplorerPageDivStyled, { children: [showTitle && (_jsx(ExplorerHeaderDivStyled, { children: _jsx(KitTypography.Title, { level: "h3", children: !viewSettingsLoading && (_jsx(ExplorerTitle, { library: view.libraryId, title: title, entrypoint: entrypoint })) /*TODO: manage loading*/ }) })), _jsxs(ExplorerToolbar, { showFilters: showFilters, showSorts: showSorts, isMassSelectionAll: isMassSelectionAll, headless: hideTableHeader, selectAllButton: hideSelectAllAction ? null : selectAllButton, viewSettingsLoading: viewSettingsLoading, children: [view?.enableConfigureView ? viewListButton : null, showSearch ? searchInput : null, view?.enableConfigureView ? viewSettingsButton : null, hidePrimaryActions ? null : primaryButton] }), loadingData || viewSettingsLoading ? (_jsx(Loading, {})) : hasNoResults ? (_jsx(ExplorerEmptyDataStyled, { children: emptyPlaceholder || _jsx(KitEmpty, { title: t('explorer.empty-data') }) })) : (_jsx(DataView, { dataGroupedFilteredSorted: data?.records ?? emptyArray, attributesProperties: data?.attributes ?? emptyObject, attributesToDisplay: [WHO_AM_I_COLUMN, ...view.attributesIds], hideTableHeader: hideTableHeader, paginationProps: entrypoint.type === 'library' && !noPagination
|
|
168
|
+
return (_jsxs(_Fragment, { children: [_jsx(FiltersContext.Provider, { value: { filtersData, dispatch: filtersDispatch }, children: _jsxs(ViewSettingsContext.Provider, { value: { view, dispatch: viewSettingsDispatch }, children: [_jsxs(ExplorerPageDivStyled, { children: [showTitle && (_jsx(ExplorerHeaderDivStyled, { children: _jsx(KitTypography.Title, { level: "h3", children: !viewSettingsLoading && (_jsx(ExplorerTitle, { library: view.libraryId, title: title, entrypoint: entrypoint })) /*TODO: manage loading*/ }) })), _jsxs(ExplorerToolbar, { showFilters: showFilters, showSorts: showSorts, isMassSelectionAll: isMassSelectionAll, headless: hideTableHeader, canRemoveFilters: view?.enableConfigureView ?? false, selectAllButton: hideSelectAllAction ? null : selectAllButton, viewSettingsLoading: viewSettingsLoading, children: [view?.enableConfigureView ? viewListButton : null, showSearch ? searchInput : null, view?.enableConfigureView ? viewSettingsButton : null, hidePrimaryActions ? null : primaryButton] }), loadingData || viewSettingsLoading ? (_jsx(Loading, {})) : hasNoResults ? (_jsx(ExplorerEmptyDataStyled, { children: emptyPlaceholder || _jsx(KitEmpty, { title: t('explorer.empty-data') }) })) : (_jsx(DataView, { dataGroupedFilteredSorted: data?.records ?? emptyArray, attributesProperties: data?.attributes ?? emptyObject, attributesToDisplay: [WHO_AM_I_COLUMN, ...view.attributesIds], hideTableHeader: hideTableHeader, paginationProps: entrypoint.type === 'library' && !noPagination
|
|
169
169
|
? {
|
|
170
170
|
pageSizeOptions: defaultPageSizeOptions,
|
|
171
171
|
currentPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Explorer.js","sourceRoot":"","sources":["../../../src/components/Explorer/Explorer.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,UAAU,EAAkB,mBAAmB,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACxE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AASpE,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,uBAAuB,EAAC,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAC,uBAAuB,EAAC,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAC,sBAAsB,EAAC,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAC5E,OAAO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CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;4CAC5C,CAAC,CAAE,IAAI,CAAC,aAA0B;wCACtC,IAAI,EAAE,aAAa;qCACtB,GACH,CACL,IACmB,EACvB,oBAAoB,IAAI,YAAY,CAAC,KAAC,SAAS,KAAG,EAAE,oBAAoB,EAAE,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,EAC9F,gBAAgB,EAChB,WAAW,EACX,SAAS,IACiB,GACT,EAC1B,KAAC,mBAAmB,IAAC,EAAE,EAAE,oBAAoB,GAAI,IAClD,CACN,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {forwardRef, type ReactNode, useImperativeHandle, useMemo} from 'react';\nimport {createPortal} from 'react-dom';\nimport {KitEmpty, KitSnackBarProvider, KitTypography} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {Loading} from '_ui/components/Loading';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n type DefaultViewSettings,\n type Entrypoint,\n type IItemAction,\n type IMassActions,\n type IPrimaryAction,\n} from './_types';\nimport {useExplorerData} from './_queries/useExplorerData';\nimport {DataView} from './DataView';\nimport {ExplorerTitle} from './ExplorerTitle';\nimport {ExplorerToolbar} from './ExplorerToolbar';\nimport {useEditStatusItemAction} from './actions-item/useEditStatusItemAction';\nimport {usePrimaryActionsButton} from './actions-primary/usePrimaryActions';\nimport {useCreatePrimaryAction} from './actions-primary/useCreatePrimaryAction';\nimport {useLinkPrimaryAction} from './actions-primary/useLinkPrimaryAction';\nimport {useMassActions} from './actions-mass/useMassActions';\nimport {useDeactivateMassAction} from './actions-mass/useDeactivateMassAction';\nimport {\n defaultPageSizeOptions,\n SidePanel,\n useEditSettings,\n useOpenViewSettings,\n ViewSettingsContext,\n} from './manage-view-settings';\nimport {useSearchInput} from './useSearchInput';\nimport {usePagination} from './usePagination';\nimport {useViewSettingsReducer} from './useViewSettingsReducer';\nimport {MASS_SELECTION_ALL, SNACKBAR_MASS_ID, WHO_AM_I_COLUMN} from './_constants';\nimport {useDeleteLinkValues} from './actions-mass/useDeleteLinkValues';\nimport {useReplaceItemAction} from './actions-item/useReplaceItemAction';\nimport {type JoinLibraryContextFragment} from '_ui/_gqlTypes';\nimport {useFiltersReducer} from '_ui/components/Filters/context/useFiltersReducer';\nimport {FiltersContext} from '_ui/components/Filters/context/filtersContext';\nimport {useExportMassAction} from './actions-mass/useExportMassAction';\n\nconst isNotEmpty = <T extends unknown[]>(union: T): union is Exclude<T, []> => union.length > 0;\n\nconst emptyArray = [];\nconst emptyObject = {};\n\nconst ExplorerHeaderDivStyled = styled.div`\n display: flex;\n align-items: flex-start;\n padding: calc(var(--general-spacing-xs) * 1px);\n`;\n\nconst ExplorerPageDivStyled = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n`;\n\nconst ExplorerEmptyDataStyled = styled.div`\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n`;\n\nexport interface IExplorerProps {\n entrypoint: Entrypoint;\n noPagination?: true;\n itemActions?: IItemAction[];\n primaryActions?: IPrimaryAction[];\n massActions?: IMassActions[];\n title?: string;\n selectionMode?: 'multiple' | 'simple';\n emptyPlaceholder?: ReactNode;\n defaultActionsForItem?: Array<'replaceLink' | 'remove' | 'activate'>;\n defaultPrimaryActions?: Array<'create'>;\n defaultMassActions?: Array<'deactivate' | 'export'>;\n defaultViewSettings?: DefaultViewSettings;\n defaultCallbacks?: {\n item?: {\n edit?: IItemAction['callback'];\n replaceLink?: (replaceValuesResult: ISubmitMultipleResult) => void;\n remove?: IItemAction['callback'];\n };\n primary?: {\n create?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n link?: (saveValuesResult: ISubmitMultipleResult) => void;\n };\n mass?: {\n deactivate?: IMassActions['callback'];\n export?: IMassActions['callback'];\n };\n };\n showCreateOnNoResultOnly?: boolean;\n showFilters?: boolean;\n showSorts?: boolean;\n hideFirstActionLabel?: boolean;\n /**\n * Optional to `false` load the last added view when `props.defaultViewSettings.viewId` is `undefined`,\n * if set to `true` load default view.\n */\n ignoreViewByDefault?: boolean;\n showTitle?: boolean;\n showSearch?: boolean;\n disableSelection?: boolean;\n hideSelectAllAction?: boolean;\n hidePrimaryActions?: boolean;\n hideTableHeader?: boolean;\n creationFormId?: string;\n joinLibraryContext?: JoinLibraryContextFragment;\n}\n\nexport interface IExplorerRef {\n createAction: IPrimaryAction | null;\n linkAction: IPrimaryAction | null;\n totalCount: number;\n}\n\nexport const Explorer = forwardRef<IExplorerRef, IExplorerProps>(\n (\n {\n entrypoint,\n itemActions = [],\n primaryActions = [],\n massActions = [],\n title,\n selectionMode = 'multiple',\n emptyPlaceholder,\n noPagination,\n creationFormId,\n showCreateOnNoResultOnly = false,\n showFilters = false,\n showSorts = false,\n hideFirstActionLabel = false,\n disableSelection = false,\n hideSelectAllAction = false,\n showTitle = false,\n showSearch = false,\n hidePrimaryActions = false,\n hideTableHeader = false,\n ignoreViewByDefault = false,\n defaultActionsForItem = ['replaceLink', 'remove', 'activate'],\n defaultPrimaryActions = ['create'],\n defaultMassActions = ['deactivate'],\n defaultCallbacks,\n defaultViewSettings,\n joinLibraryContext,\n },\n ref,\n ) => {\n const {t} = useSharedTranslation();\n\n const {panelElement: settingsPanelElement} = useEditSettings();\n\n const {\n loading: viewSettingsLoading,\n view,\n dispatch: viewSettingsDispatch,\n } = useViewSettingsReducer(entrypoint, defaultViewSettings, ignoreViewByDefault);\n\n const {filtersData, dispatch: filtersDispatch} = useFiltersReducer({\n libraryId: view.libraryId,\n viewId: view.viewId ?? undefined,\n filters: defaultViewSettings?.filters ?? undefined,\n filtersOperator: defaultViewSettings?.filtersOperator ?? undefined,\n ignoreViewByDefault,\n skip: viewSettingsLoading,\n });\n\n const {currentPage, setNewPageSize, setNewPage} = usePagination(viewSettingsDispatch);\n\n const {\n data,\n isMultivalue,\n canEditLinkAttributeValues,\n loading: loadingData,\n refetch,\n } = useExplorerData({\n entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n sorts: view.sort,\n filters: filtersData.filters,\n filtersOperator: filtersData.filtersOperator,\n skip: viewSettingsLoading,\n }); // TODO: refresh when go back on page\n const isMassSelectionAll = view.massSelection === MASS_SELECTION_ALL;\n const isLink = entrypoint.type === 'link';\n\n const {editStatusItemAction} = useEditStatusItemAction({\n isEnabled:\n isNotEmpty(defaultActionsForItem) &&\n (defaultActionsForItem.includes('remove') || defaultActionsForItem.includes('activate')),\n onRemove: defaultCallbacks?.item?.remove,\n canDeleteLinkValues: canEditLinkAttributeValues,\n store: {view, dispatch: viewSettingsDispatch},\n entrypoint,\n });\n\n const {replaceItemAction, replaceItemModal} = useReplaceItemAction({\n isEnabled: isLink && isNotEmpty(defaultActionsForItem) && defaultActionsForItem.includes('replaceLink'),\n isMultivalue,\n onReplace: defaultCallbacks?.item?.replaceLink,\n canReplaceLinkValues: canEditLinkAttributeValues,\n });\n\n const totalCount = data?.totalCount ?? 0;\n\n const hasNoResults = data === null || data.totalCount === 0;\n\n const isAllowedFreeEntry = !(entrypoint.type === 'library' && !entrypoint.allowFreeEntry);\n\n const showCreatePrimaryButton = showCreateOnNoResultOnly\n ? !hidePrimaryActions && !loadingData && hasNoResults && isAllowedFreeEntry\n : true;\n\n const {createPrimaryAction, createModal} = useCreatePrimaryAction({\n isEnabled: isNotEmpty(defaultPrimaryActions) && defaultPrimaryActions.includes('create'),\n isVisible: showCreatePrimaryButton,\n libraryId: view.libraryId,\n canCreateAndLinkValue: canEditLinkAttributeValues,\n onCreate: defaultCallbacks?.primary?.create,\n joinLibraryContext,\n entrypoint,\n isMultivalue,\n totalCount,\n formId: creationFormId,\n refetch,\n });\n const {linkPrimaryAction, linkModal} = useLinkPrimaryAction({\n isEnabled: isLink,\n joinLibraryContext,\n isVisible: showCreatePrimaryButton,\n canAddLinkValue: canEditLinkAttributeValues,\n onLink: defaultCallbacks?.primary?.link,\n linkId: data?.totalCount === 0 ? undefined : data?.records[0]?.id_value,\n isMultivalue,\n maxItemsLeft: null, // TODO: use KitTable.row\n });\n\n const allVisibleKeys = data?.records.map(({key}) => key) ?? [];\n\n const {exportMassAction} = useExportMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('export'),\n store: {view, dispatch: viewSettingsDispatch},\n totalCount,\n onExport: defaultCallbacks?.mass?.export,\n });\n\n const {deactivateMassAction} = useDeactivateMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n allVisibleKeys,\n totalCount,\n onDeactivate: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const {unlinkMassAction} = useDeleteLinkValues({\n isEnabled: isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n allVisibleKeys,\n onDelete: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const _isSelectionDisable = disableSelection || (isLink && !isMultivalue && totalCount > 0);\n\n const massActionSnackbarId = useMemo(() => `${SNACKBAR_MASS_ID}_${Date.now()}`, []);\n\n const {setSelectedKeys, selectAllButton} = useMassActions({\n isEnabled:\n totalCount > 0 && !_isSelectionDisable && (isNotEmpty(defaultMassActions) || isNotEmpty(massActions)),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n totalCount,\n allVisibleKeys,\n massActions: [exportMassAction, deactivateMassAction, unlinkMassAction, ...massActions].filter(Boolean),\n snackbarId: massActionSnackbarId,\n });\n\n const {primaryButton} = usePrimaryActionsButton({\n view,\n actions: [createPrimaryAction, linkPrimaryAction, ...primaryActions].filter(Boolean),\n hideFirstActionLabel,\n });\n\n const {viewSettingsButton, viewListButton} = useOpenViewSettings({view, isEnabled: !isMassSelectionAll});\n\n const {searchInput} = useSearchInput({view, dispatch: viewSettingsDispatch, setNewPage});\n\n useImperativeHandle(\n ref,\n () => ({\n createAction: createPrimaryAction,\n linkAction: linkPrimaryAction,\n totalCount,\n }),\n [createPrimaryAction?.disabled, linkPrimaryAction?.disabled, totalCount],\n );\n\n return (\n <>\n <FiltersContext.Provider value={{filtersData, dispatch: filtersDispatch}}>\n <ViewSettingsContext.Provider value={{view, dispatch: viewSettingsDispatch}}>\n <ExplorerPageDivStyled>\n {showTitle && (\n <ExplorerHeaderDivStyled>\n <KitTypography.Title level=\"h3\">\n {\n !viewSettingsLoading && (\n <ExplorerTitle\n library={view.libraryId}\n title={title}\n entrypoint={entrypoint}\n />\n ) /*TODO: manage loading*/\n }\n </KitTypography.Title>\n </ExplorerHeaderDivStyled>\n )}\n <ExplorerToolbar\n showFilters={showFilters}\n showSorts={showSorts}\n isMassSelectionAll={isMassSelectionAll}\n headless={hideTableHeader}\n selectAllButton={hideSelectAllAction ? null : selectAllButton}\n viewSettingsLoading={viewSettingsLoading}\n >\n {view?.enableConfigureView ? viewListButton : null}\n {showSearch ? searchInput : null}\n {view?.enableConfigureView ? viewSettingsButton : null}\n {hidePrimaryActions ? null : primaryButton}\n </ExplorerToolbar>\n {loadingData || viewSettingsLoading ? (\n <Loading />\n ) : hasNoResults ? (\n <ExplorerEmptyDataStyled>\n {emptyPlaceholder || <KitEmpty title={t('explorer.empty-data')} />}\n </ExplorerEmptyDataStyled>\n ) : (\n <DataView\n dataGroupedFilteredSorted={data?.records ?? emptyArray}\n attributesProperties={data?.attributes ?? emptyObject}\n attributesToDisplay={[WHO_AM_I_COLUMN, ...view.attributesIds]}\n hideTableHeader={hideTableHeader}\n paginationProps={\n entrypoint.type === 'library' && !noPagination\n ? {\n pageSizeOptions: defaultPageSizeOptions,\n currentPage,\n pageSize: view.pageSize,\n setNewPageSize,\n setNewPage,\n totalCount,\n }\n : undefined\n }\n itemActions={[...itemActions, replaceItemAction, editStatusItemAction]\n .filter(Boolean)\n .map(action => ({\n ...action,\n disabled: isMassSelectionAll || action.disabled,\n }))}\n selection={{\n onSelectionChange: _isSelectionDisable ? null : setSelectedKeys,\n isMassSelectionAll,\n selectedKeys: isMassSelectionAll\n ? data?.records.map(({whoAmI}) => whoAmI.id)\n : (view.massSelection as string[]),\n mode: selectionMode,\n }}\n />\n )}\n </ExplorerPageDivStyled>\n {settingsPanelElement && createPortal(<SidePanel />, settingsPanelElement?.() ?? document.body)}\n {replaceItemModal}\n {createModal}\n {linkModal}\n </ViewSettingsContext.Provider>\n </FiltersContext.Provider>\n <KitSnackBarProvider id={massActionSnackbarId} />\n </>\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"file":"Explorer.js","sourceRoot":"","sources":["../../../src/components/Explorer/Explorer.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,UAAU,EAAkB,mBAAmB,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACxE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AASpE,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MA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E,iBAAiB,EAAE,oBAAoB,CAAC;yCACjE,MAAM,CAAC,OAAO,CAAC;yCACf,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;wCACZ,GAAG,MAAM;wCACT,QAAQ,EAAE,kBAAkB,IAAI,MAAM,CAAC,QAAQ;qCAClD,CAAC,CAAC,EACP,SAAS,EAAE;wCACP,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe;wCAC/D,kBAAkB;wCAClB,YAAY,EAAE,kBAAkB;4CAC5B,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;4CAC5C,CAAC,CAAE,IAAI,CAAC,aAA0B;wCACtC,IAAI,EAAE,aAAa;qCACtB,GACH,CACL,IACmB,EACvB,oBAAoB,IAAI,YAAY,CAAC,KAAC,SAAS,KAAG,EAAE,oBAAoB,EAAE,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,EAC9F,gBAAgB,EAChB,WAAW,EACX,SAAS,IACiB,GACT,EAC1B,KAAC,mBAAmB,IAAC,EAAE,EAAE,oBAAoB,GAAI,IAClD,CACN,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {forwardRef, type ReactNode, useImperativeHandle, useMemo} from 'react';\nimport {createPortal} from 'react-dom';\nimport {KitEmpty, KitSnackBarProvider, KitTypography} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {Loading} from '_ui/components/Loading';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {\n type DefaultViewSettings,\n type Entrypoint,\n type IItemAction,\n type IMassActions,\n type IPrimaryAction,\n} from './_types';\nimport {useExplorerData} from './_queries/useExplorerData';\nimport {DataView} from './DataView';\nimport {ExplorerTitle} from './ExplorerTitle';\nimport {ExplorerToolbar} from './ExplorerToolbar';\nimport {useEditStatusItemAction} from './actions-item/useEditStatusItemAction';\nimport {usePrimaryActionsButton} from './actions-primary/usePrimaryActions';\nimport {useCreatePrimaryAction} from './actions-primary/useCreatePrimaryAction';\nimport {useLinkPrimaryAction} from './actions-primary/useLinkPrimaryAction';\nimport {useMassActions} from './actions-mass/useMassActions';\nimport {useDeactivateMassAction} from './actions-mass/useDeactivateMassAction';\nimport {\n defaultPageSizeOptions,\n SidePanel,\n useEditSettings,\n useOpenViewSettings,\n ViewSettingsContext,\n} from './manage-view-settings';\nimport {useSearchInput} from './useSearchInput';\nimport {usePagination} from './usePagination';\nimport {useViewSettingsReducer} from './useViewSettingsReducer';\nimport {MASS_SELECTION_ALL, SNACKBAR_MASS_ID, WHO_AM_I_COLUMN} from './_constants';\nimport {useDeleteLinkValues} from './actions-mass/useDeleteLinkValues';\nimport {useReplaceItemAction} from './actions-item/useReplaceItemAction';\nimport {type JoinLibraryContextFragment} from '_ui/_gqlTypes';\nimport {useFiltersReducer} from '_ui/components/Filters/context/useFiltersReducer';\nimport {FiltersContext} from '_ui/components/Filters/context/filtersContext';\nimport {useExportMassAction} from './actions-mass/useExportMassAction';\n\nconst isNotEmpty = <T extends unknown[]>(union: T): union is Exclude<T, []> => union.length > 0;\n\nconst emptyArray = [];\nconst emptyObject = {};\n\nconst ExplorerHeaderDivStyled = styled.div`\n display: flex;\n align-items: flex-start;\n padding: calc(var(--general-spacing-xs) * 1px);\n`;\n\nconst ExplorerPageDivStyled = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n`;\n\nconst ExplorerEmptyDataStyled = styled.div`\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n`;\n\nexport interface IExplorerProps {\n entrypoint: Entrypoint;\n noPagination?: true;\n itemActions?: IItemAction[];\n primaryActions?: IPrimaryAction[];\n massActions?: IMassActions[];\n title?: string;\n selectionMode?: 'multiple' | 'simple';\n emptyPlaceholder?: ReactNode;\n defaultActionsForItem?: Array<'replaceLink' | 'remove' | 'activate'>;\n defaultPrimaryActions?: Array<'create'>;\n defaultMassActions?: Array<'deactivate' | 'export'>;\n defaultViewSettings?: DefaultViewSettings;\n defaultCallbacks?: {\n item?: {\n edit?: IItemAction['callback'];\n replaceLink?: (replaceValuesResult: ISubmitMultipleResult) => void;\n remove?: IItemAction['callback'];\n };\n primary?: {\n create?: ({\n recordIdCreated,\n saveValuesResultOnLink,\n }: {\n recordIdCreated: string;\n saveValuesResultOnLink?: ISubmitMultipleResult;\n }) => void;\n link?: (saveValuesResult: ISubmitMultipleResult) => void;\n };\n mass?: {\n deactivate?: IMassActions['callback'];\n export?: IMassActions['callback'];\n };\n };\n showCreateOnNoResultOnly?: boolean;\n showFilters?: boolean;\n showSorts?: boolean;\n hideFirstActionLabel?: boolean;\n /**\n * Optional to `false` load the last added view when `props.defaultViewSettings.viewId` is `undefined`,\n * if set to `true` load default view.\n */\n ignoreViewByDefault?: boolean;\n showTitle?: boolean;\n showSearch?: boolean;\n disableSelection?: boolean;\n hideSelectAllAction?: boolean;\n hidePrimaryActions?: boolean;\n hideTableHeader?: boolean;\n creationFormId?: string;\n joinLibraryContext?: JoinLibraryContextFragment;\n}\n\nexport interface IExplorerRef {\n createAction: IPrimaryAction | null;\n linkAction: IPrimaryAction | null;\n totalCount: number;\n}\n\nexport const Explorer = forwardRef<IExplorerRef, IExplorerProps>(\n (\n {\n entrypoint,\n itemActions = [],\n primaryActions = [],\n massActions = [],\n title,\n selectionMode = 'multiple',\n emptyPlaceholder,\n noPagination,\n creationFormId,\n showCreateOnNoResultOnly = false,\n showFilters = false,\n showSorts = false,\n hideFirstActionLabel = false,\n disableSelection = false,\n hideSelectAllAction = false,\n showTitle = false,\n showSearch = false,\n hidePrimaryActions = false,\n hideTableHeader = false,\n ignoreViewByDefault = false,\n defaultActionsForItem = ['replaceLink', 'remove', 'activate'],\n defaultPrimaryActions = ['create'],\n defaultMassActions = ['deactivate'],\n defaultCallbacks,\n defaultViewSettings,\n joinLibraryContext,\n },\n ref,\n ) => {\n const {t} = useSharedTranslation();\n\n const {panelElement: settingsPanelElement} = useEditSettings();\n\n const {\n loading: viewSettingsLoading,\n view,\n dispatch: viewSettingsDispatch,\n } = useViewSettingsReducer(entrypoint, defaultViewSettings, ignoreViewByDefault);\n\n const {filtersData, dispatch: filtersDispatch} = useFiltersReducer({\n libraryId: view.libraryId,\n viewId: view.viewId ?? undefined,\n filters: defaultViewSettings?.filters ?? undefined,\n filtersOperator: defaultViewSettings?.filtersOperator ?? undefined,\n ignoreViewByDefault,\n skip: viewSettingsLoading,\n });\n\n const {currentPage, setNewPageSize, setNewPage} = usePagination(viewSettingsDispatch);\n\n const {\n data,\n isMultivalue,\n canEditLinkAttributeValues,\n loading: loadingData,\n refetch,\n } = useExplorerData({\n entrypoint,\n libraryId: view.libraryId,\n attributeIds: view.attributesIds,\n fulltextSearch: view.fulltextSearch,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n sorts: view.sort,\n filters: filtersData.filters,\n filtersOperator: filtersData.filtersOperator,\n skip: viewSettingsLoading,\n }); // TODO: refresh when go back on page\n const isMassSelectionAll = view.massSelection === MASS_SELECTION_ALL;\n const isLink = entrypoint.type === 'link';\n\n const {editStatusItemAction} = useEditStatusItemAction({\n isEnabled:\n isNotEmpty(defaultActionsForItem) &&\n (defaultActionsForItem.includes('remove') || defaultActionsForItem.includes('activate')),\n onRemove: defaultCallbacks?.item?.remove,\n canDeleteLinkValues: canEditLinkAttributeValues,\n store: {view, dispatch: viewSettingsDispatch},\n entrypoint,\n });\n\n const {replaceItemAction, replaceItemModal} = useReplaceItemAction({\n isEnabled: isLink && isNotEmpty(defaultActionsForItem) && defaultActionsForItem.includes('replaceLink'),\n isMultivalue,\n onReplace: defaultCallbacks?.item?.replaceLink,\n canReplaceLinkValues: canEditLinkAttributeValues,\n });\n\n const totalCount = data?.totalCount ?? 0;\n\n const hasNoResults = data === null || data.totalCount === 0;\n\n const isAllowedFreeEntry = !(entrypoint.type === 'library' && !entrypoint.allowFreeEntry);\n\n const showCreatePrimaryButton = showCreateOnNoResultOnly\n ? !hidePrimaryActions && !loadingData && hasNoResults && isAllowedFreeEntry\n : true;\n\n const {createPrimaryAction, createModal} = useCreatePrimaryAction({\n isEnabled: isNotEmpty(defaultPrimaryActions) && defaultPrimaryActions.includes('create'),\n isVisible: showCreatePrimaryButton,\n libraryId: view.libraryId,\n canCreateAndLinkValue: canEditLinkAttributeValues,\n onCreate: defaultCallbacks?.primary?.create,\n joinLibraryContext,\n entrypoint,\n isMultivalue,\n totalCount,\n formId: creationFormId,\n refetch,\n });\n const {linkPrimaryAction, linkModal} = useLinkPrimaryAction({\n isEnabled: isLink,\n joinLibraryContext,\n isVisible: showCreatePrimaryButton,\n canAddLinkValue: canEditLinkAttributeValues,\n onLink: defaultCallbacks?.primary?.link,\n linkId: data?.totalCount === 0 ? undefined : data?.records[0]?.id_value,\n isMultivalue,\n maxItemsLeft: null, // TODO: use KitTable.row\n });\n\n const allVisibleKeys = data?.records.map(({key}) => key) ?? [];\n\n const {exportMassAction} = useExportMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('export'),\n store: {view, dispatch: viewSettingsDispatch},\n totalCount,\n onExport: defaultCallbacks?.mass?.export,\n });\n\n const {deactivateMassAction} = useDeactivateMassAction({\n isEnabled: !isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n allVisibleKeys,\n totalCount,\n onDeactivate: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const {unlinkMassAction} = useDeleteLinkValues({\n isEnabled: isLink && isNotEmpty(defaultMassActions) && defaultMassActions.includes('deactivate'),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n pagination: noPagination ? null : {limit: view.pageSize, offset: view.pageSize * (currentPage - 1)},\n allVisibleKeys,\n onDelete: defaultCallbacks?.mass?.deactivate,\n refetch,\n });\n\n const _isSelectionDisable = disableSelection || (isLink && !isMultivalue && totalCount > 0);\n\n const massActionSnackbarId = useMemo(() => `${SNACKBAR_MASS_ID}_${Date.now()}`, []);\n\n const {setSelectedKeys, selectAllButton} = useMassActions({\n isEnabled:\n totalCount > 0 && !_isSelectionDisable && (isNotEmpty(defaultMassActions) || isNotEmpty(massActions)),\n store: {view, dispatch: viewSettingsDispatch},\n filtersStore: filtersData,\n totalCount,\n allVisibleKeys,\n massActions: [exportMassAction, deactivateMassAction, unlinkMassAction, ...massActions].filter(Boolean),\n snackbarId: massActionSnackbarId,\n });\n\n const {primaryButton} = usePrimaryActionsButton({\n view,\n actions: [createPrimaryAction, linkPrimaryAction, ...primaryActions].filter(Boolean),\n hideFirstActionLabel,\n });\n\n const {viewSettingsButton, viewListButton} = useOpenViewSettings({view, isEnabled: !isMassSelectionAll});\n\n const {searchInput} = useSearchInput({view, dispatch: viewSettingsDispatch, setNewPage});\n\n useImperativeHandle(\n ref,\n () => ({\n createAction: createPrimaryAction,\n linkAction: linkPrimaryAction,\n totalCount,\n }),\n [createPrimaryAction?.disabled, linkPrimaryAction?.disabled, totalCount],\n );\n\n return (\n <>\n <FiltersContext.Provider value={{filtersData, dispatch: filtersDispatch}}>\n <ViewSettingsContext.Provider value={{view, dispatch: viewSettingsDispatch}}>\n <ExplorerPageDivStyled>\n {showTitle && (\n <ExplorerHeaderDivStyled>\n <KitTypography.Title level=\"h3\">\n {\n !viewSettingsLoading && (\n <ExplorerTitle\n library={view.libraryId}\n title={title}\n entrypoint={entrypoint}\n />\n ) /*TODO: manage loading*/\n }\n </KitTypography.Title>\n </ExplorerHeaderDivStyled>\n )}\n <ExplorerToolbar\n showFilters={showFilters}\n showSorts={showSorts}\n isMassSelectionAll={isMassSelectionAll}\n headless={hideTableHeader}\n canRemoveFilters={view?.enableConfigureView ?? false}\n selectAllButton={hideSelectAllAction ? null : selectAllButton}\n viewSettingsLoading={viewSettingsLoading}\n >\n {view?.enableConfigureView ? viewListButton : null}\n {showSearch ? searchInput : null}\n {view?.enableConfigureView ? viewSettingsButton : null}\n {hidePrimaryActions ? null : primaryButton}\n </ExplorerToolbar>\n {loadingData || viewSettingsLoading ? (\n <Loading />\n ) : hasNoResults ? (\n <ExplorerEmptyDataStyled>\n {emptyPlaceholder || <KitEmpty title={t('explorer.empty-data')} />}\n </ExplorerEmptyDataStyled>\n ) : (\n <DataView\n dataGroupedFilteredSorted={data?.records ?? emptyArray}\n attributesProperties={data?.attributes ?? emptyObject}\n attributesToDisplay={[WHO_AM_I_COLUMN, ...view.attributesIds]}\n hideTableHeader={hideTableHeader}\n paginationProps={\n entrypoint.type === 'library' && !noPagination\n ? {\n pageSizeOptions: defaultPageSizeOptions,\n currentPage,\n pageSize: view.pageSize,\n setNewPageSize,\n setNewPage,\n totalCount,\n }\n : undefined\n }\n itemActions={[...itemActions, replaceItemAction, editStatusItemAction]\n .filter(Boolean)\n .map(action => ({\n ...action,\n disabled: isMassSelectionAll || action.disabled,\n }))}\n selection={{\n onSelectionChange: _isSelectionDisable ? null : setSelectedKeys,\n isMassSelectionAll,\n selectedKeys: isMassSelectionAll\n ? data?.records.map(({whoAmI}) => whoAmI.id)\n : (view.massSelection as string[]),\n mode: selectionMode,\n }}\n />\n )}\n </ExplorerPageDivStyled>\n {settingsPanelElement && createPortal(<SidePanel />, settingsPanelElement?.() ?? document.body)}\n {replaceItemModal}\n {createModal}\n {linkModal}\n </ViewSettingsContext.Provider>\n </FiltersContext.Provider>\n <KitSnackBarProvider id={massActionSnackbarId} />\n </>\n );\n },\n);\n"]}
|
|
@@ -18,12 +18,12 @@ const DividerStyled = styled(KitDivider) `
|
|
|
18
18
|
height: 26px;
|
|
19
19
|
margin-inline: calc(var(--general-spacing-xxs) * 1px);
|
|
20
20
|
`;
|
|
21
|
-
export const ExplorerFiltersAndSorts = ({ isMassSelectionAll, showFilters, showSorts, selectAllButton }) => {
|
|
21
|
+
export const ExplorerFiltersAndSorts = ({ isMassSelectionAll, showFilters, showSorts, canRemoveFilters, selectAllButton }) => {
|
|
22
22
|
const { t } = useSharedTranslation();
|
|
23
23
|
const { view } = useViewSettingsContext();
|
|
24
24
|
const { sort } = view;
|
|
25
25
|
const { openSettingsPanel } = useOpenViewSettings({ view, isEnabled: true });
|
|
26
|
-
const { filtersProps } = useFilters();
|
|
26
|
+
const { filtersProps } = useFilters(!canRemoveFilters);
|
|
27
27
|
const { attributeDetailsById } = useAttributeDetailsData(view.libraryId);
|
|
28
28
|
// const visibleFilters = filters.filter(filterItem => !filterItem.hidden);
|
|
29
29
|
if (((filtersProps.length === 0 && sort.length === 0) || (!showFilters && !showSorts)) && !selectAllButton) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExplorerFiltersAndSorts.js","sourceRoot":"","sources":["../../../src/components/Explorer/ExplorerFiltersAndSorts.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAC,sBAAsB,EAAC,MAAM,mEAAmE,CAAC;AACzG,OAAO,EAAC,uBAAuB,EAAC,MAAM,wDAAwD,CAAC;AAC/F,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAA0B,MAAM,sDAAsD,CAAC;AAC/G,OAAO,EAAC,UAAU,EAAC,MAAM,mCAAmC,CAAC;AAE7D,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAA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AAS,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAC/E,KAAC,aAAa,IAAC,IAAI,EAAC,UAAU,GAAG,CACpC,IACF,CACN,EACA,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,CAC3B,8BACK,YAAY,CAAC,MAAM,GAAG,CAAC;wBACpB,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAC5B,uBACI,KAAC,gBAAgB,OACR,WAAkC,EACvC,QAAQ,EAAE,kBAAkB,GAC9B,IAJG,WAAW,CAAC,GAAG,CAKnB,CACR,CAAC,EACL,SAAS,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAC7B,uBACI,KAAC,YAAY,IACT,KAAK,EAAE,CAAC,CAAC,qBAAqB,CAAC,EAC/B,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,kBAAkB,GAC7B,GACD,CACR,IACF,CACN,IACF,CACN,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {SortOrder} from '_ui/_gqlTypes';\nimport {useViewSettingsContext} from './manage-view-settings/store-view-settings/useViewSettingsContext';\nimport {useAttributeDetailsData} from './manage-view-settings/_shared/useAttributeDetailsData';\nimport {useOpenViewSettings} from './manage-view-settings';\nimport {type ComponentProps, type FunctionComponent, type ReactNode} from 'react';\nimport {KitDivider, KitFilter} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {CommonFilterItem, type ICommonFilterProps} from '_ui/components/Filters/filter-items/CommonFilterItem';\nimport {useFilters} from '_ui/components/Filters/useFilters';\n\nconst FilterStyled = styled(KitFilter)`\n flex: 0 0 auto;\n`;\n\nconst DividerStyled = styled(KitDivider)`\n height: 26px;\n margin-inline: calc(var(--general-spacing-xxs) * 1px);\n`;\n\nexport const ExplorerFiltersAndSorts: FunctionComponent<{\n isMassSelectionAll: boolean;\n showFilters: boolean;\n showSorts: boolean;\n canRemoveFilters: boolean;\n selectAllButton: ReactNode | null;\n}> = ({isMassSelectionAll, showFilters, showSorts, canRemoveFilters, selectAllButton}) => {\n const {t} = useSharedTranslation();\n\n const {view} = useViewSettingsContext();\n const {sort} = view;\n\n const {openSettingsPanel} = useOpenViewSettings({view, isEnabled: true});\n const {filtersProps} = useFilters(!canRemoveFilters);\n\n const {attributeDetailsById} = useAttributeDetailsData(view.libraryId);\n // const visibleFilters = filters.filter(filterItem => !filterItem.hidden);\n\n if (((filtersProps.length === 0 && sort.length === 0) || (!showFilters && !showSorts)) && !selectAllButton) {\n return null;\n }\n\n const sortValues =\n sort.length === 0\n ? undefined\n : sort.map(\n ({field, order}) =>\n (attributeDetailsById?.[field]?.label ?? field) +\n ' ' +\n (order === SortOrder.asc ? t('explorer.sort-ascending') : t('explorer.sort-descending')),\n );\n\n const _handleClickOnSort: ComponentProps<typeof FilterStyled>['onClick'] = () =>\n isMassSelectionAll ? undefined : openSettingsPanel('sort-items');\n\n if (!Object.keys(attributeDetailsById).length) {\n return <></>;\n }\n return (\n <>\n {selectAllButton && (\n <>\n <li>{selectAllButton}</li>\n {((showFilters && filtersProps.length !== 0) || (showSorts && sort.length > 0)) && (\n <DividerStyled type=\"vertical\" />\n )}\n </>\n )}\n {(showFilters || showSorts) && (\n <>\n {filtersProps.length > 0 &&\n filtersProps.map(filterProps => (\n <li key={filterProps.key}>\n <CommonFilterItem\n {...(filterProps as ICommonFilterProps)}\n disabled={isMassSelectionAll}\n />\n </li>\n ))}\n {showSorts && sort.length > 0 && (\n <li>\n <FilterStyled\n label={t('explorer.sort-items')}\n values={sortValues}\n disabled={isMassSelectionAll}\n onClick={_handleClickOnSort}\n />\n </li>\n )}\n </>\n )}\n </>\n );\n};\n"]}
|
|
@@ -32,8 +32,8 @@ const Section = styled.div `
|
|
|
32
32
|
align-items: center;
|
|
33
33
|
gap: calc(var(--general-spacing-xxs) * 1px);
|
|
34
34
|
`;
|
|
35
|
-
export const ExplorerToolbar = ({ isMassSelectionAll, showFilters, showSorts, headless, selectAllButton, viewSettingsLoading, children }) => {
|
|
35
|
+
export const ExplorerToolbar = ({ isMassSelectionAll, showFilters, showSorts, headless, canRemoveFilters, selectAllButton, viewSettingsLoading, children, }) => {
|
|
36
36
|
const { t } = useSharedTranslation();
|
|
37
|
-
return (_jsxs(ExplorerToolbarListStyled, { "aria-label": t('explorer.toolbar'), className: headless ? 'headless' : '', children: [_jsx(Section, { children: !viewSettingsLoading && (_jsx(ExplorerFiltersAndSorts, { selectAllButton: selectAllButton, showFilters: showFilters, showSorts: showSorts, isMassSelectionAll: isMassSelectionAll })) }), _jsx(Section, { children: children })] }));
|
|
37
|
+
return (_jsxs(ExplorerToolbarListStyled, { "aria-label": t('explorer.toolbar'), className: headless ? 'headless' : '', children: [_jsx(Section, { children: !viewSettingsLoading && (_jsx(ExplorerFiltersAndSorts, { selectAllButton: selectAllButton, showFilters: showFilters, showSorts: showSorts, canRemoveFilters: canRemoveFilters, isMassSelectionAll: isMassSelectionAll })) }), _jsx(Section, { children: children })] }));
|
|
38
38
|
};
|
|
39
39
|
//# sourceMappingURL=ExplorerToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExplorerToolbar.js","sourceRoot":"","sources":["../../../src/components/Explorer/ExplorerToolbar.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,yBAAyB,GAAG,MAAM,CAAC,EAAE,CAAA;;;;;;;;;;;;;;;;;;;;;;;CAuB1C,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKzB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"ExplorerToolbar.js","sourceRoot":"","sources":["../../../src/components/Explorer/ExplorerToolbar.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,yBAAyB,GAAG,MAAM,CAAC,EAAE,CAAA;;;;;;;;;;;;;;;;;;;;;;;CAuB1C,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKzB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAQvB,CAAC,EACF,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,QAAQ,GACX,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO,CACH,MAAC,yBAAyB,kBAAa,CAAC,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,aAC/F,KAAC,OAAO,cACH,CAAC,mBAAmB,IAAI,CACrB,KAAC,uBAAuB,IACpB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,GACxC,CACL,GACK,EACV,KAAC,OAAO,cAAE,QAAQ,GAAW,IACL,CAC/B,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type ReactNode, type FunctionComponent} from 'react';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {ExplorerFiltersAndSorts} from './ExplorerFiltersAndSorts';\nimport styled from 'styled-components';\n\nconst ExplorerToolbarListStyled = styled.ul`\n padding: calc(var(--general-spacing-xs) * 1px);\n margin: 0;\n margin-bottom: calc(var(--general-spacing-s) * 1px);\n background: var(--general-colors-neutral-grey-100);\n border-radius: calc(var(--general-border-radius-s) * 1px);\n list-style: none;\n display: flex;\n overflow: auto;\n align-items: center;\n gap: calc(var(--general-spacing-xxs) * 1px);\n white-space: nowrap;\n min-height: 26px; // height of the filter chip\n justify-content: space-between;\n\n &.headless {\n margin-bottom: 0;\n }\n\n & > div:last-of-type {\n flex-shrink: 0;\n align-self: start;\n }\n`;\n\nconst Section = styled.div`\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: calc(var(--general-spacing-xxs) * 1px);\n`;\n\nexport const ExplorerToolbar: FunctionComponent<{\n isMassSelectionAll: boolean;\n showFilters: boolean;\n showSorts: boolean;\n headless: boolean;\n canRemoveFilters: boolean;\n selectAllButton: ReactNode | null;\n viewSettingsLoading: boolean;\n}> = ({\n isMassSelectionAll,\n showFilters,\n showSorts,\n headless,\n canRemoveFilters,\n selectAllButton,\n viewSettingsLoading,\n children,\n}) => {\n const {t} = useSharedTranslation();\n\n return (\n <ExplorerToolbarListStyled aria-label={t('explorer.toolbar')} className={headless ? 'headless' : ''}>\n <Section>\n {!viewSettingsLoading && (\n <ExplorerFiltersAndSorts\n selectAllButton={selectAllButton}\n showFilters={showFilters}\n showSorts={showSorts}\n canRemoveFilters={canRemoveFilters}\n isMassSelectionAll={isMassSelectionAll}\n />\n )}\n </Section>\n <Section>{children}</Section>\n </ExplorerToolbarListStyled>\n );\n};\n"]}
|
|
@@ -13,13 +13,16 @@ import { useFetchRecordHistory } from './hooks/useFetchRecordHistory';
|
|
|
13
13
|
import { RecordHistoryGoUpButton } from './RecordHistoryGoUpButton';
|
|
14
14
|
import { RecordHistoryLogEntry } from './RecordHistoryLogEntry';
|
|
15
15
|
const StyledDivContentWrapper = styled.div `
|
|
16
|
-
margin-top: calc(var(--general-spacing-
|
|
16
|
+
margin-top: calc(var(--general-spacing-xs) * 1px);
|
|
17
17
|
flex: 1 1 0;
|
|
18
18
|
overflow-y: auto;
|
|
19
19
|
`;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// TODO: This component should be moved to /apps/app-studio/src/modules/information-and-history/record-history/ when he will no longer be used by RecordSummary and ValuesSummary (those components will be removed in the future)
|
|
21
|
+
// Also when component will be moved
|
|
22
|
+
// - put together translations with information_and_history
|
|
23
|
+
// - remove usage of styled-components
|
|
24
|
+
// - instead of a record we could receive a recordId and a libraryId directly
|
|
25
|
+
// - remove styling of StyledDivContentWrapper that will no longer be necessary
|
|
23
26
|
export const RecordHistory = ({ record, attributeId }) => {
|
|
24
27
|
const { t } = useSharedTranslation();
|
|
25
28
|
const [showAllHistory, setShowAllHistory] = useState(false);
|
|
@@ -31,17 +34,19 @@ export const RecordHistory = ({ record, attributeId }) => {
|
|
|
31
34
|
attributeId,
|
|
32
35
|
});
|
|
33
36
|
if (loading && logs.length === 0) {
|
|
37
|
+
// TODO: Add a better loading state
|
|
34
38
|
return _jsx(Loading, {});
|
|
35
39
|
}
|
|
36
40
|
if (inError) {
|
|
41
|
+
//TODO: Add a better error state
|
|
37
42
|
return _jsx(ErrorDisplay, { message: t('record_history.error_fetching') });
|
|
38
43
|
}
|
|
39
44
|
if (logs.length === 0) {
|
|
40
45
|
return (_jsx(StyledDivContentWrapper, { children: _jsx(KitTypography.Text, { children: t('record_history.empty_history') }) }));
|
|
41
46
|
}
|
|
42
|
-
return (_jsx(StyledDivContentWrapper, { children: _jsx(RecordHistoryGoUpButton, { children: _jsxs(KitSpace, { size: "s", direction: "vertical", children: [total > 1 && (_jsx(
|
|
47
|
+
return (_jsx(StyledDivContentWrapper, { children: _jsx(RecordHistoryGoUpButton, { children: _jsxs(KitSpace, { size: "s", direction: "vertical", children: [showAllHistory && (_jsxs(_Fragment, { children: [logs.map((logEntry, index) => (_jsx(RecordHistoryLogEntry, { index: index, logEntry: logEntry }, index))), _jsx(ShowMore, { hasMore: hasMore, fetchMore: fetchMore })] })), !showAllHistory && _jsx(RecordHistoryLogEntry, { index: 0, logEntry: logs[0] }, 0), total > 1 && (_jsx(KitButton, { type: "secondary", size: "s", onClick: () => setShowAllHistory(!showAllHistory), children: showAllHistory
|
|
43
48
|
? t('record_history.hide_history', { total })
|
|
44
|
-
: t('record_history.show_history', { total }) }))
|
|
49
|
+
: t('record_history.show_history', { total }) }))] }) }) }));
|
|
45
50
|
};
|
|
46
51
|
export default RecordHistory;
|
|
47
52
|
//# sourceMappingURL=RecordHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordHistory.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistory.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAO9D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIzC,CAAC;AAEF,
|
|
1
|
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AAC,6BAA6B,EAAE,EAAC,KAAK,EAAC,CAAC;4BAC3C,CAAC,CAAC,CAAC,CAAC,6BAA6B,EAAE,EAAC,KAAK,EAAC,CAAC,GACvC,CACf,IACM,GACW,GACJ,CAC7B,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport {KitButton, KitSpace, KitTypography} from 'aristid-ds';\nimport {type FunctionComponent, useState} from 'react';\nimport styled from 'styled-components';\nimport {ErrorDisplay} from '../ErrorDisplay';\nimport {Loading} from '../Loading';\nimport {ShowMore} from '../ShowMore';\nimport {useFetchRecordHistory} from './hooks/useFetchRecordHistory';\nimport {RecordHistoryGoUpButton} from './RecordHistoryGoUpButton';\nimport {RecordHistoryLogEntry} from './RecordHistoryLogEntry';\n\ninterface IRecordHistoryProps {\n record: IRecordIdentityWhoAmI;\n attributeId?: string;\n}\n\nconst StyledDivContentWrapper = styled.div`\n margin-top: calc(var(--general-spacing-xs) * 1px);\n flex: 1 1 0;\n overflow-y: auto;\n`;\n\n// TODO: This component should be moved to /apps/app-studio/src/modules/information-and-history/record-history/ when he will no longer be used by RecordSummary and ValuesSummary (those components will be removed in the future)\n// Also when component will be moved\n// - put together translations with information_and_history\n// - remove usage of styled-components\n// - instead of a record we could receive a recordId and a libraryId directly\n// - remove styling of StyledDivContentWrapper that will no longer be necessary\nexport const RecordHistory: FunctionComponent<IRecordHistoryProps> = ({record, attributeId}) => {\n const {t} = useSharedTranslation();\n const [showAllHistory, setShowAllHistory] = useState<boolean>(false);\n const {loading, inError, logs, total, hasMore, fetchMore} = useFetchRecordHistory({\n record: {\n id: record.id,\n libraryId: record.library.id,\n },\n attributeId,\n });\n\n if (loading && logs.length === 0) {\n // TODO: Add a better loading state\n return <Loading />;\n }\n\n if (inError) {\n //TODO: Add a better error state\n return <ErrorDisplay message={t('record_history.error_fetching')} />;\n }\n\n if (logs.length === 0) {\n return (\n <StyledDivContentWrapper>\n <KitTypography.Text>{t('record_history.empty_history')}</KitTypography.Text>\n </StyledDivContentWrapper>\n );\n }\n\n return (\n <StyledDivContentWrapper>\n <RecordHistoryGoUpButton>\n <KitSpace size=\"s\" direction=\"vertical\">\n {showAllHistory && (\n <>\n {logs.map((logEntry, index) => (\n <RecordHistoryLogEntry key={index} index={index} logEntry={logEntry} />\n ))}\n <ShowMore hasMore={hasMore} fetchMore={fetchMore} />\n </>\n )}\n {!showAllHistory && <RecordHistoryLogEntry key={0} index={0} logEntry={logs[0]} />}\n {total > 1 && (\n <KitButton type=\"secondary\" size=\"s\" onClick={() => setShowAllHistory(!showAllHistory)}>\n {showAllHistory\n ? t('record_history.hide_history', {total})\n : t('record_history.show_history', {total})}\n </KitButton>\n )}\n </KitSpace>\n </RecordHistoryGoUpButton>\n </StyledDivContentWrapper>\n );\n};\n\nexport default RecordHistory;\n"]}
|
|
@@ -6,8 +6,14 @@ import { localizedTranslation } from '@leav/utils';
|
|
|
6
6
|
import { AttributeFormat, LogAction } from '../../_gqlTypes';
|
|
7
7
|
import { useLang } from '../../hooks';
|
|
8
8
|
import { useSharedTranslation } from '../../hooks/useSharedTranslation';
|
|
9
|
-
import { KitSpace, KitTypography } from 'aristid-ds';
|
|
9
|
+
import { KitButton, KitSpace, KitTypography } from 'aristid-ds';
|
|
10
10
|
import dayjs from 'dayjs';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
const StyledLinkButton = styled(KitButton) `
|
|
13
|
+
&[role='link'] {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
11
17
|
export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
12
18
|
const { t } = useSharedTranslation();
|
|
13
19
|
const { lang } = useLang();
|
|
@@ -18,7 +24,7 @@ export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
|
18
24
|
const hasAfter = hasValue(after);
|
|
19
25
|
const getUserString = () => {
|
|
20
26
|
const email = user?.properties[0]?.values[0]?.payload;
|
|
21
|
-
return email ? (_jsx("
|
|
27
|
+
return email ? (_jsx(StyledLinkButton, { type: "link", href: `mailto:${email}`, children: email })) : (user?.id || t('record_history.unknown_user'));
|
|
22
28
|
};
|
|
23
29
|
const getDateString = () => dayjs.unix(time).format('DD/MM/YYYY HH:mm:ss'); // Maybe use https://day.js.org/docs/en/display/format#localized-formats if needed
|
|
24
30
|
const getActionString = () => {
|
|
@@ -35,24 +41,24 @@ export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
|
35
41
|
const getAttributeLabel = () => localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');
|
|
36
42
|
const formatValue = (logData) => {
|
|
37
43
|
if (attribute?.format === AttributeFormat.rich_text) {
|
|
38
|
-
return (_jsx(KitTypography.AdvancedParagraph, { size: "
|
|
44
|
+
return (_jsx(KitTypography.AdvancedParagraph, { size: "fontSize5", ellipsis: { rows: 4, expandable: true }, children: logData.asString }));
|
|
39
45
|
}
|
|
40
|
-
return _jsx(KitTypography.Text, { size: "
|
|
46
|
+
return _jsx(KitTypography.Text, { size: "fontSize5", children: logData.asString });
|
|
41
47
|
};
|
|
42
48
|
const formatValueChange = () => {
|
|
43
|
-
const noValue = _jsx(KitTypography.Text, { size: "
|
|
49
|
+
const noValue = _jsx(KitTypography.Text, { size: "fontSize5", children: t('record_history.no_value') });
|
|
44
50
|
if (attribute?.multiple_values) {
|
|
45
51
|
const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;
|
|
46
52
|
if (uniqValue != null) {
|
|
47
53
|
return (_jsx(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: formatValue(uniqValue) }));
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
|
-
return (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [hasBefore ? formatValue(before) : noValue, _jsx(KitTypography.Text, { size: "
|
|
56
|
+
return (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [hasBefore ? formatValue(before) : noValue, _jsx(KitTypography.Text, { size: "fontSize5", children: " \u2192 " }), hasAfter ? formatValue(after) : noValue] }));
|
|
51
57
|
};
|
|
52
58
|
switch (action) {
|
|
53
59
|
case LogAction.VALUE_SAVE:
|
|
54
60
|
case LogAction.VALUE_DELETE:
|
|
55
|
-
return (_jsxs(KitSpace, { size: "
|
|
61
|
+
return (_jsxs(KitSpace, { size: "xxs", direction: "vertical", children: [_jsxs(KitTypography.Text, { size: "fontSize5", children: [getUserString(), " ", getActionString(), " ", _jsx("strong", { children: getAttributeLabel() })] }), _jsx(KitTypography.Text, { size: "fontSize5", children: getDateString() }), formatValueChange()] }, index));
|
|
56
62
|
}
|
|
57
63
|
};
|
|
58
64
|
export default RecordHistoryLogEntry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordHistoryLogEntry.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistoryLogEntry.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,eAAe,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"RecordHistoryLogEntry.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistoryLogEntry.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,O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Ae,EAAE,OAAE,2BAAS,iBAAiB,EAAE,GAAU,IAC3D,EACrB,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YAAE,aAAa,EAAE,GAAsB,EAC1E,iBAAiB,EAAE,KALT,KAAK,CAMT,CACd,CAAC;IACV,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {localizedTranslation} from '@leav/utils';\nimport {AttributeFormat, LogAction} from '_ui/_gqlTypes';\nimport {useLang} from '_ui/hooks';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitButton, KitSpace, KitTypography} from 'aristid-ds';\nimport dayjs from 'dayjs';\nimport {type FunctionComponent} from 'react';\nimport {type LogEntry, type LogEntryAttribute, type LogEntryData, type LogEntryValue} from './_types';\nimport styled from 'styled-components';\n\ninterface IRecordHistoryLogEntryProps {\n index: number;\n logEntry: LogEntry;\n}\n\nconst StyledLinkButton = styled(KitButton)`\n &[role='link'] {\n display: inline-flex;\n }\n`;\n\nexport const RecordHistoryLogEntry: FunctionComponent<IRecordHistoryLogEntryProps> = ({index, logEntry}) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n const {action, time, user, topic, before, after} = logEntry as LogEntryValue;\n const attribute: LogEntryAttribute | undefined = topic?.attribute;\n\n const hasValue = (value: LogEntryData) => value != null && 'asString' in value && value.asString != null;\n const hasBefore = hasValue(before);\n const hasAfter = hasValue(after);\n\n const getUserString = () => {\n const email = user?.properties[0]?.values[0]?.payload;\n return email ? (\n <StyledLinkButton type=\"link\" href={`mailto:${email}`}>\n {email}\n </StyledLinkButton>\n ) : (\n user?.id || t('record_history.unknown_user')\n );\n };\n const getDateString = () => dayjs.unix(time).format('DD/MM/YYYY HH:mm:ss'); // Maybe use https://day.js.org/docs/en/display/format#localized-formats if needed\n const getActionString = () => {\n if (attribute?.multiple_values) {\n if (!hasBefore && hasAfter) {\n return t('record_history.action.value_add');\n }\n if (hasBefore && !hasAfter) {\n return t('record_history.action.value_delete');\n }\n }\n return t('record_history.action.value_modify');\n };\n\n const getAttributeLabel = () =>\n localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');\n\n const formatValue = (logData: LogEntryData) => {\n if (attribute?.format === AttributeFormat.rich_text) {\n return (\n <KitTypography.AdvancedParagraph size=\"fontSize5\" ellipsis={{rows: 4, expandable: true}}>\n {logData.asString}\n </KitTypography.AdvancedParagraph>\n );\n }\n return <KitTypography.Text size=\"fontSize5\">{logData.asString}</KitTypography.Text>;\n };\n\n const formatValueChange = () => {\n const noValue = <KitTypography.Text size=\"fontSize5\">{t('record_history.no_value')}</KitTypography.Text>;\n\n if (attribute?.multiple_values) {\n const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;\n if (uniqValue != null) {\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {formatValue(uniqValue)}\n </KitSpace>\n );\n }\n }\n\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {hasBefore ? formatValue(before) : noValue}\n <KitTypography.Text size=\"fontSize5\"> → </KitTypography.Text>\n {hasAfter ? formatValue(after) : noValue}\n </KitSpace>\n );\n };\n\n switch (action) {\n case LogAction.VALUE_SAVE:\n case LogAction.VALUE_DELETE:\n return (\n <KitSpace key={index} size=\"xxs\" direction=\"vertical\">\n <KitTypography.Text size=\"fontSize5\">\n {getUserString()} {getActionString()} <strong>{getAttributeLabel()}</strong>\n </KitTypography.Text>\n <KitTypography.Text size=\"fontSize5\">{getDateString()}</KitTypography.Text>\n {formatValueChange()}\n </KitSpace>\n );\n }\n};\n\nexport default RecordHistoryLogEntry;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leav/ui",
|
|
3
|
-
"version": "1.5.0-
|
|
3
|
+
"version": "1.5.0-e0f0cfb7",
|
|
4
4
|
"description": "Shared React components and hooks",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "yarn build",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@types/react-table": "7.7.12",
|
|
45
45
|
"@types/uuid": "^9",
|
|
46
46
|
"antd": "5.22.2",
|
|
47
|
-
"aristid-ds": "14.0.0-
|
|
47
|
+
"aristid-ds": "14.0.0-cb7dc4f",
|
|
48
48
|
"babel-jest": "29.3.1",
|
|
49
49
|
"commander": "9.5.0",
|
|
50
|
-
"graphql": "16.
|
|
50
|
+
"graphql": "16.12.0",
|
|
51
51
|
"i18next": "22.5.0",
|
|
52
52
|
"jest": "29.0.3",
|
|
53
53
|
"jest-environment-jsdom": "29.3.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@ant-design/icons": ">=5.2",
|
|
67
67
|
"@apollo/client": ">=3.8.1",
|
|
68
68
|
"antd": "5.22.2",
|
|
69
|
-
"aristid-ds": "14.0.0-
|
|
69
|
+
"aristid-ds": "14.0.0-cb7dc4f",
|
|
70
70
|
"dayjs": "^1.11.13",
|
|
71
71
|
"i18next": "22.5",
|
|
72
72
|
"react": "18.2.0",
|