@dbcdk/react-components 0.0.7 → 0.0.8
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.
|
@@ -14,8 +14,9 @@ export type SelectProps<T> = Omit<InputContainerProps, 'children' | 'htmlFor' |
|
|
|
14
14
|
onClear?: () => void;
|
|
15
15
|
datakey?: string;
|
|
16
16
|
dataCy?: string;
|
|
17
|
+
disabled?: boolean;
|
|
17
18
|
tooltip?: React.ReactNode;
|
|
18
19
|
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
19
20
|
};
|
|
20
|
-
export declare function Select<T extends string | number | Record<string, any>>({ label, error, helpText, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, id, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, }: SelectProps<T>): React.ReactNode;
|
|
21
|
+
export declare function Select<T extends string | number | Record<string, any>>({ label, error, helpText, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, id, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, disabled, }: SelectProps<T>): React.ReactNode;
|
|
21
22
|
export {};
|
|
@@ -10,11 +10,9 @@ import { Popover } from '../../popover/Popover';
|
|
|
10
10
|
import { InputContainer } from '../input-container/InputContainer';
|
|
11
11
|
export function Select({
|
|
12
12
|
// InputContainer props
|
|
13
|
-
label, error, helpText, orientation = 'vertical', labelWidth = '120px', fullWidth = true, required,
|
|
14
|
-
// ✅ tooltip props
|
|
15
|
-
tooltip, tooltipPlacement = 'right',
|
|
13
|
+
label, error, helpText, orientation = 'vertical', labelWidth = '120px', fullWidth = true, required, tooltip, tooltipPlacement = 'right',
|
|
16
14
|
// Select props
|
|
17
|
-
id, options, selectedValue, onChange, placeholder = 'Vælg', size, variant = 'outlined', onClear, datakey, dataCy, }) {
|
|
15
|
+
id, options, selectedValue, onChange, placeholder = 'Vælg', size, variant = 'outlined', onClear, datakey, dataCy, disabled, }) {
|
|
18
16
|
const generatedId = useId();
|
|
19
17
|
const controlId = id !== null && id !== void 0 ? id : `select-${generatedId}`;
|
|
20
18
|
const describedById = `${controlId}-desc`;
|
|
@@ -74,10 +72,7 @@ id, options, selectedValue, onChange, placeholder = 'Vælg', size, variant = 'ou
|
|
|
74
72
|
ids.push(tooltipId);
|
|
75
73
|
return ids.length ? ids.join(' ') : undefined;
|
|
76
74
|
})();
|
|
77
|
-
return (_jsxs(InputContainer, { label: label, htmlFor: controlId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, children: [_jsx(Popover, { ref: popoverRef, trigger: (onClick, icon) => (_jsx(Button
|
|
78
|
-
// IMPORTANT: keep triggerProps last for events, but let our aria-describedby win
|
|
79
|
-
// We'll spread triggerProps and then override aria-describedby to include both.
|
|
80
|
-
, { ...(tooltipEnabled ? triggerProps : {}), id: controlId, "data-cy": dataCy !== null && dataCy !== void 0 ? dataCy : 'select-button', onKeyDown: handleKeyDown, fullWidth: fullWidth, variant: variant, onClick: e => {
|
|
75
|
+
return (_jsxs(InputContainer, { label: label, htmlFor: controlId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, children: [_jsx(Popover, { ref: popoverRef, trigger: (onClick, icon) => (_jsx(Button, { disabled: disabled, ...(tooltipEnabled ? triggerProps : {}), id: controlId, "data-cy": dataCy !== null && dataCy !== void 0 ? dataCy : 'select-button', onKeyDown: handleKeyDown, fullWidth: fullWidth, variant: variant, onClick: e => {
|
|
81
76
|
setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
|
|
82
77
|
onClick(e);
|
|
83
78
|
}, size: size, type: "button", "aria-haspopup": "listbox", "aria-invalid": Boolean(error) || undefined, "aria-describedby": describedBy, children: _jsxs("span", { className: "dbc-flex dbc-justify-between dbc-items-center dbc-gap-xxs", style: { width: '100%' }, children: [_jsx("span", { children: selected ? selected.label : placeholder }), onClear && selected && _jsx(ClearButton, { onClick: onClear }), icon] }) })), children: _jsx(Menu, { onKeyDown: handleKeyDown, role: "listbox", children: options.map((opt, index) => {
|
|
@@ -82,7 +82,7 @@ export function TanstackTable(props) {
|
|
|
82
82
|
},
|
|
83
83
|
});
|
|
84
84
|
const columnItems = React.useMemo(() => mapDefsToColumnItems(columns), [columns]);
|
|
85
|
-
const visibleData =
|
|
85
|
+
const visibleData = table.getRowModel().rows.map(r => r.original);
|
|
86
86
|
const s = (_a = table.getState().sorting) === null || _a === void 0 ? void 0 : _a[0];
|
|
87
87
|
const sortById = (_b = s === null || s === void 0 ? void 0 : s.id) !== null && _b !== void 0 ? _b : undefined;
|
|
88
88
|
const sortDirection = s ? (s.desc ? 'desc' : 'asc') : null;
|