@sonic-equipment/ui 181.0.0 → 183.0.0
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/cards/data-card/data-card.d.ts +30 -18
- package/dist/cards/data-card/data-card.js +38 -6
- package/dist/cards/data-card/data-card.module.css.js +1 -1
- package/dist/collapsables/cascading-component/use-cascading-component-container.js +1 -0
- package/dist/collapsables/cascading-component/use-cascading-component.js +1 -0
- package/dist/collapsables/cascading-component/use-has-cascading-component-container.js +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +7 -0
- package/dist/exports.d.ts +18 -0
- package/dist/header/connected-header.js +1 -1
- package/dist/header/header.d.ts +3 -1
- package/dist/header/header.js +3 -2
- package/dist/icons/glyph/glyphs-chevrons-bold-up-icon.js +7 -0
- package/dist/index.js +17 -0
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/logging/use-log-error.js +1 -0
- package/dist/pages/my-sonic/widgets/components/address-data-card.d.ts +4 -4
- package/dist/shared/api/shared/hooks/use-awaitable-mutation.js +1 -0
- package/dist/shared/ga/use-data-layer.js +1 -0
- package/dist/shared/hooks/use-breakpoint.js +1 -0
- package/dist/shared/hooks/use-cookie.js +1 -0
- package/dist/shared/hooks/use-css-link.js +1 -0
- package/dist/shared/hooks/use-disclosure.js +1 -0
- package/dist/shared/hooks/use-global-disclosure.js +1 -0
- package/dist/shared/hooks/use-is-breakpoint.js +1 -0
- package/dist/shared/hooks/use-is-scrolled-beyond-element.js +1 -0
- package/dist/shared/hooks/use-local-storage.js +1 -0
- package/dist/shared/hooks/use-script.js +1 -0
- package/dist/shared/hooks/use-scroll-lock.js +1 -0
- package/dist/shared/hooks/use-session-storage.js +1 -0
- package/dist/shared/hooks/use-watch-css-property.js +1 -0
- package/dist/shared/utils/local-storage.js +1 -2
- package/dist/styles.css +416 -41
- package/dist/table/data-table.d.ts +19 -0
- package/dist/table/data-table.js +48 -0
- package/dist/table/data-table.module.css.js +3 -0
- package/dist/table/elements/col.d.ts +7 -0
- package/dist/table/elements/col.js +9 -0
- package/dist/table/elements/table-column-properties.d.ts +10 -0
- package/dist/table/elements/table-context.d.ts +18 -0
- package/dist/table/elements/table-context.js +21 -0
- package/dist/table/elements/table-provider.d.ts +22 -0
- package/dist/table/elements/table-provider.js +60 -0
- package/dist/table/elements/table-row-context.d.ts +14 -0
- package/dist/table/elements/table-row-context.js +17 -0
- package/dist/table/elements/table-row-provider.d.ts +4 -0
- package/dist/table/elements/table-row-provider.js +26 -0
- package/dist/table/elements/table-sort-button.d.ts +11 -0
- package/dist/table/elements/table-sort-button.js +18 -0
- package/dist/table/elements/table.d.ts +14 -0
- package/dist/table/elements/table.js +24 -0
- package/dist/table/elements/table.module.css.js +3 -0
- package/dist/table/elements/td.d.ts +6 -0
- package/dist/table/elements/td.js +13 -0
- package/dist/table/elements/th.d.ts +8 -0
- package/dist/table/elements/th.js +13 -0
- package/dist/table/elements/tr.d.ts +8 -0
- package/dist/table/elements/tr.js +13 -0
- package/dist/table/elements/use-table-row.d.ts +1 -0
- package/dist/table/elements/use-table-row.js +8 -0
- package/dist/table/elements/use-table.d.ts +2 -0
- package/dist/table/elements/use-table.js +13 -0
- package/dist/table/elements/use-td.d.ts +2 -0
- package/dist/table/elements/use-td.js +26 -0
- package/dist/table/elements/use-th.d.ts +2 -0
- package/dist/table/elements/use-th.js +22 -0
- package/dist/table/elements/use-tr.d.ts +2 -0
- package/dist/table/elements/use-tr.js +16 -0
- package/dist/text/truncated/truncated.d.ts +6 -0
- package/dist/text/truncated/truncated.js +9 -0
- package/dist/text/truncated/truncated.module.css.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef, useMemo } from 'react';
|
|
4
|
+
import { TableContext } from './table-context.js';
|
|
5
|
+
|
|
6
|
+
function TableProvider({ children, onColumnsChanged, }) {
|
|
7
|
+
const columnsRef = useRef([]);
|
|
8
|
+
const rowsRef = useRef([]);
|
|
9
|
+
const value = useMemo(() => ({
|
|
10
|
+
register: {
|
|
11
|
+
cell: (rowIndex, onColumnChanged) => {
|
|
12
|
+
const row = rowsRef.current[rowIndex];
|
|
13
|
+
if (!row)
|
|
14
|
+
throw new Error(`Row with index ${rowIndex} does not exist.`);
|
|
15
|
+
const cell = { index: -1, onColumnChanged };
|
|
16
|
+
cell.index = row.cells.push(cell) - 1;
|
|
17
|
+
return {
|
|
18
|
+
deregister: () => {
|
|
19
|
+
row.cells = row.cells.filter(c => c.index !== cell.index);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
column: (rowIndex, props) => {
|
|
24
|
+
const column = { index: -1, props, rowIndex };
|
|
25
|
+
column.index = columnsRef.current.push(column) - 1;
|
|
26
|
+
onColumnsChanged?.(columnsRef.current);
|
|
27
|
+
return {
|
|
28
|
+
deregister: () => {
|
|
29
|
+
columnsRef.current = columnsRef.current.filter(c => c.index !== column.index);
|
|
30
|
+
onColumnsChanged?.(columnsRef.current);
|
|
31
|
+
},
|
|
32
|
+
update: (props) => {
|
|
33
|
+
const updatedColumn = columnsRef.current.find(c => c.index === column.index);
|
|
34
|
+
if (!updatedColumn)
|
|
35
|
+
throw new Error(`Column with index ${column.index} does not exist.`);
|
|
36
|
+
updatedColumn.props = props;
|
|
37
|
+
rowsRef.current.forEach(row => row.cells
|
|
38
|
+
.find(cell => cell.index === column.index)
|
|
39
|
+
?.onColumnChanged(props));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
row: () => {
|
|
44
|
+
const row = { cells: [], index: -1 };
|
|
45
|
+
row.index = rowsRef.current.push(row) - 1;
|
|
46
|
+
return {
|
|
47
|
+
deregister: () => {
|
|
48
|
+
rowsRef.current = rowsRef.current.filter(r => r.index !== row.index);
|
|
49
|
+
},
|
|
50
|
+
index: row.index,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}), [onColumnsChanged]);
|
|
55
|
+
return (jsx(TableContext.Provider, { value: value, children: children instanceof Function
|
|
56
|
+
? children({ columnInfos: columnsRef.current })
|
|
57
|
+
: children }));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { TableProvider };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableColumnProperties } from './table-column-properties';
|
|
2
|
+
import { OnColumnChangedHandler } from './table-context';
|
|
3
|
+
export interface TableRowContextValue {
|
|
4
|
+
register: {
|
|
5
|
+
cell: (onColumnChanged: OnColumnChangedHandler) => {
|
|
6
|
+
deregister: VoidFunction;
|
|
7
|
+
};
|
|
8
|
+
column: (props: TableColumnProperties) => {
|
|
9
|
+
deregister: VoidFunction;
|
|
10
|
+
update: OnColumnChangedHandler;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const TableRowContext: React.Context<TableRowContextValue>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext } from 'react';
|
|
3
|
+
import { voidFunction } from '../../shared/model/defaults.js';
|
|
4
|
+
|
|
5
|
+
const TableRowContext = createContext({
|
|
6
|
+
register: {
|
|
7
|
+
cell: () => ({
|
|
8
|
+
deregister: voidFunction,
|
|
9
|
+
}),
|
|
10
|
+
column: () => ({
|
|
11
|
+
deregister: voidFunction,
|
|
12
|
+
update: voidFunction,
|
|
13
|
+
}),
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { TableRowContext };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
4
|
+
import { TableRowContext } from './table-row-context.js';
|
|
5
|
+
import { useTable } from './use-table.js';
|
|
6
|
+
|
|
7
|
+
function TableRowProvider({ children }) {
|
|
8
|
+
const { register } = useTable();
|
|
9
|
+
const [{ deregister, index }] = useState(() => register.row());
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
return deregister;
|
|
12
|
+
}, [deregister]);
|
|
13
|
+
const value = useMemo(() => ({
|
|
14
|
+
register: {
|
|
15
|
+
cell: onColumnChanged => {
|
|
16
|
+
return register.cell(index, onColumnChanged);
|
|
17
|
+
},
|
|
18
|
+
column: props => {
|
|
19
|
+
return register.column(index, props);
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}), [index, register]);
|
|
23
|
+
return (jsx(TableRowContext.Provider, { value: value, children: children }));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { TableRowProvider };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TableColumnAlignment } from './table-column-properties';
|
|
2
|
+
type SortDirection = 'ascending' | 'descending';
|
|
3
|
+
export interface TableSortButtonProps {
|
|
4
|
+
active?: boolean;
|
|
5
|
+
align?: TableColumnAlignment;
|
|
6
|
+
children: string;
|
|
7
|
+
direction?: SortDirection;
|
|
8
|
+
onClick: (direction: SortDirection) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function TableSortButton({ active, align, children, direction, onClick, }: TableSortButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { GlyphsChevronsBoldUpIcon } from '../../icons/glyph/glyphs-chevrons-bold-up-icon.js';
|
|
5
|
+
import { useFormattedMessage } from '../../intl/use-formatted-message.js';
|
|
6
|
+
import styles from './table.module.css.js';
|
|
7
|
+
|
|
8
|
+
function TableSortButton({ active, align = 'start', children, direction = 'descending', onClick, }) {
|
|
9
|
+
const t = useFormattedMessage();
|
|
10
|
+
const ariaLabel = `
|
|
11
|
+
${t('Sort by')}
|
|
12
|
+
${children}
|
|
13
|
+
${active && `(${t('active')}, ${t(direction)})`}
|
|
14
|
+
`;
|
|
15
|
+
return (jsxs("button", { "aria-label": ariaLabel, className: clsx(styles['table-sort-button'], active && styles['active'], styles[direction], styles[align]), onClick: () => onClick(direction), type: "button", children: [jsx("span", { className: styles['label'], children: children }), jsx(GlyphsChevronsBoldUpIcon, { "aria-label": t(direction), className: styles['icon'] })] }));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { TableSortButton };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface TableProps {
|
|
2
|
+
'aria-describedby'?: string;
|
|
3
|
+
'aria-label'?: string;
|
|
4
|
+
'aria-rowcount'?: number;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
cssColumns?: string;
|
|
8
|
+
'data-test-selector'?: string;
|
|
9
|
+
highlight?: 'row' | 'col' | 'both';
|
|
10
|
+
nowrap?: boolean;
|
|
11
|
+
stretch?: boolean;
|
|
12
|
+
thead?: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function Table({ 'aria-describedby': ariaDescribedBy, 'aria-label': ariaLabel, 'aria-rowcount': ariaRowCount, children, className, cssColumns, 'data-test-selector': dataTestSelector, highlight, nowrap, stretch, thead, }: TableProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef, useState, useCallback } from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { Col } from './col.js';
|
|
6
|
+
import { TableProvider } from './table-provider.js';
|
|
7
|
+
import styles from './table.module.css.js';
|
|
8
|
+
|
|
9
|
+
function Table({ 'aria-describedby': ariaDescribedBy, 'aria-label': ariaLabel, 'aria-rowcount': ariaRowCount, children, className, cssColumns, 'data-test-selector': dataTestSelector, highlight, nowrap, stretch, thead, }) {
|
|
10
|
+
const tableRef = useRef(null);
|
|
11
|
+
const [colgroup, setColgroup] = useState([]);
|
|
12
|
+
const onColumnsChanged = useCallback((columnInfos) => {
|
|
13
|
+
tableRef.current?.style.setProperty('--columns', columnInfos.length.toString());
|
|
14
|
+
setColgroup(columnInfos.map(col => {
|
|
15
|
+
return (jsx(Col, { selected: col.props.selected, span: col.props.colSpan, sticky: col.props.sticky }, col.index));
|
|
16
|
+
}));
|
|
17
|
+
}, []);
|
|
18
|
+
return (jsx("div", { className: styles['table-container'], children: jsx(TableProvider, { onColumnsChanged: onColumnsChanged, children: jsxs("table", { ref: tableRef, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-rowcount": ariaRowCount, className: clsx(styles['table'], stretch && styles.stretch, nowrap && styles['nowrap'], (highlight === 'row' || highlight === 'both') && styles['hl-row'], (highlight === 'col' || highlight === 'both') && styles['hl-col'], className), "data-test-selector": dataTestSelector, style: {
|
|
19
|
+
'--columns': 0,
|
|
20
|
+
'--grid-columns': cssColumns,
|
|
21
|
+
}, children: [colgroup && (jsx("colgroup", { className: styles['colgroup'], children: colgroup })), thead && jsx("thead", { className: styles['thead'], children: thead }), jsx("tbody", { className: styles['tbody'], children: children })] }) }) }));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Table };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var styles = {"table-container":"table-module-pevNG","table":"table-module-k47fT","colgroup":"table-module-1lgqE","col":"table-module-dISOo","selected":"table-module-WGz-I","sticky":"table-module-PQejy","th":"table-module-jRXnY","td":"table-module-wJwSq","start":"table-module-EWdty","end":"table-module-yJD74","center":"table-module-XAdfy","nowrap":"table-module-h7qdo","tr":"table-module-Nisf1","hl-row":"table-module-3zZB6","clickable":"table-module-qRfjM","thead":"table-module-DK-wn","tbody":"table-module-tygZb","stretch":"table-module-YnmWV","caption":"table-module-skhNZ","hl-col":"table-module-JEp5f","table-sort-button":"table-module-RtOV-","label":"table-module-ukG8s","icon":"table-module-QdiLJ","active":"table-module-gWy-a","ascending":"table-module-SjJ57","descending":"table-module--p8TF"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Truncated } from '../../text/truncated/truncated.js';
|
|
5
|
+
import { useTD } from './use-td.js';
|
|
6
|
+
import styles from './table.module.css.js';
|
|
7
|
+
|
|
8
|
+
function TD(props) {
|
|
9
|
+
const { align = 'start', children, className, colSpan, nowrap, rowSpan, sticky, truncated, } = useTD(props);
|
|
10
|
+
return (jsx("td", { className: clsx(styles['td'], styles[align], nowrap && styles['nowrap'], sticky && styles['sticky'], className), colSpan: colSpan, rowSpan: rowSpan, children: truncated ? (jsx(Truncated, { lines: typeof truncated === 'number' ? truncated : undefined, children: children })) : (children) }));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { TD };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TableColumnProperties } from './table-column-properties';
|
|
2
|
+
export interface THProps extends TableColumnProperties {
|
|
3
|
+
'aria-sort'?: 'ascending' | 'descending' | 'none' | 'other';
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
scope?: 'col' | 'row' | 'colgroup' | 'rowgroup';
|
|
7
|
+
}
|
|
8
|
+
export declare function TH(props: THProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Truncated } from '../../text/truncated/truncated.js';
|
|
5
|
+
import { useTH } from './use-th.js';
|
|
6
|
+
import styles from './table.module.css.js';
|
|
7
|
+
|
|
8
|
+
function TH(props) {
|
|
9
|
+
const { align = 'start', 'aria-sort': ariaSort, children, className, colSpan, nowrap, rowSpan, scope, sticky, truncated, } = useTH(props);
|
|
10
|
+
return (jsx("th", { "aria-sort": ariaSort, className: clsx(styles['th'], styles[align], nowrap && styles['nowrap'], sticky && styles['sticky'], className), colSpan: colSpan, rowSpan: rowSpan, scope: scope, children: truncated ? (jsx(Truncated, { lines: typeof truncated === 'number' ? truncated : undefined, children: children })) : (children) }));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { TH };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TableColumnProperties } from './table-column-properties';
|
|
3
|
+
export interface TRProps extends TableColumnProperties {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
onClick?: (event: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function TR(props: TRProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { TableRowProvider } from './table-row-provider.js';
|
|
5
|
+
import { useTR } from './use-tr.js';
|
|
6
|
+
import styles from './table.module.css.js';
|
|
7
|
+
|
|
8
|
+
function TR(props) {
|
|
9
|
+
const { children, className, onClick, selected } = useTR(props);
|
|
10
|
+
return (jsx(TableRowProvider, { children: jsx("tr", { "aria-selected": selected, className: clsx(styles['tr'], selected && styles['selected'], Boolean(onClick) && styles['clickable'], className), onClick: onClick, children: children }) }));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { TR };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useTableRow(): import("./table-row-context").TableRowContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { TableContext } from './table-context.js';
|
|
3
|
+
|
|
4
|
+
function useTable() {
|
|
5
|
+
const context = useContext(TableContext);
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error('useTable must be used within a TableProvider');
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { useTable };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { useTableRow } from './use-table-row.js';
|
|
3
|
+
|
|
4
|
+
function useTD(props) {
|
|
5
|
+
const [columnProps, setColumnProps] = useState(null);
|
|
6
|
+
const { register } = useTableRow();
|
|
7
|
+
const onColumnChanged = useCallback((columnProps) => {
|
|
8
|
+
setColumnProps(columnProps);
|
|
9
|
+
}, []);
|
|
10
|
+
const [{ deregister }] = useState(register.cell(onColumnChanged));
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
return deregister;
|
|
13
|
+
}, [deregister]);
|
|
14
|
+
return {
|
|
15
|
+
...props,
|
|
16
|
+
align: columnProps?.align ?? props.align ?? 'start',
|
|
17
|
+
colSpan: columnProps?.colSpan ?? props.colSpan ?? 1,
|
|
18
|
+
nowrap: columnProps?.nowrap ?? props.nowrap ?? false,
|
|
19
|
+
rowSpan: columnProps?.rowSpan ?? props.rowSpan ?? 1,
|
|
20
|
+
selected: columnProps?.selected ?? props.selected ?? false,
|
|
21
|
+
sticky: columnProps?.sticky ?? props.sticky ?? false,
|
|
22
|
+
truncated: columnProps?.truncated ?? props.truncated ?? false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { useTD };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { useTableRow } from './use-table-row.js';
|
|
3
|
+
|
|
4
|
+
function useTH(props) {
|
|
5
|
+
const { register } = useTableRow();
|
|
6
|
+
const updateRef = useRef();
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const { deregister, update } = register.column(props);
|
|
9
|
+
updateRef.current = update;
|
|
10
|
+
return () => {
|
|
11
|
+
deregister();
|
|
12
|
+
updateRef.current = undefined;
|
|
13
|
+
};
|
|
14
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
}, [register]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
updateRef.current?.(props);
|
|
18
|
+
}, [props]);
|
|
19
|
+
return props;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { useTH };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useTableRow } from './use-table-row.js';
|
|
3
|
+
|
|
4
|
+
function useTR(props) {
|
|
5
|
+
const { register } = useTableRow();
|
|
6
|
+
const [{ deregister, update }] = useState(register.column(props));
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
return deregister;
|
|
9
|
+
}, [deregister]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
update(props);
|
|
12
|
+
}, [props, update]);
|
|
13
|
+
return props;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { useTR };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import styles from './truncated.module.css.js';
|
|
4
|
+
|
|
5
|
+
function Truncated({ active = true, children, lines = 1, }) {
|
|
6
|
+
return (jsx("div", { className: clsx(styles['truncated'], active && styles['active']), style: { '--lines': lines }, title: children?.toString(), children: children }));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { Truncated };
|