@equinor/apollo-components 3.2.1 → 3.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +47 -10
- package/dist/index.js +209 -100
- package/dist/index.mjs +196 -89
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-co
|
|
|
8
8
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
9
9
|
import { SetRequired } from 'type-fest';
|
|
10
10
|
import { TableOptions } from '@tanstack/table-core/build/lib/types';
|
|
11
|
+
import { Variants } from '@equinor/eds-core-react/dist/types/components/types';
|
|
12
|
+
import { FieldError } from 'react-hook-form';
|
|
11
13
|
|
|
12
14
|
interface AppShellProps {
|
|
13
15
|
children?: ReactNode;
|
|
@@ -161,7 +163,12 @@ interface DataTableProps<T> {
|
|
|
161
163
|
enableGlobalFilterInput?: boolean;
|
|
162
164
|
globalFilterPlaceholder?: string;
|
|
163
165
|
filterFromLeafRows?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use `customActionsLeft` instead
|
|
168
|
+
*/
|
|
164
169
|
customActions?: <T>(table: Table<T>) => ReactNode;
|
|
170
|
+
customActionsLeft?: <T>(table: Table<T>) => ReactNode;
|
|
171
|
+
customActionsRight?: <T>(table: Table<T>) => ReactNode;
|
|
165
172
|
/**
|
|
166
173
|
* Default 1rem
|
|
167
174
|
* Accepts any CSS padding value
|
|
@@ -239,32 +246,62 @@ declare function useSetFormMeta<T extends FormMeta>(): (newValues: Partial<T>) =
|
|
|
239
246
|
declare function removeFormMeta<T extends FormMeta>(withFormMeta: T): Omit<T, keyof FormMeta>;
|
|
240
247
|
declare function addFormMeta<T>(withoutFormMeta: T): T & FormMeta;
|
|
241
248
|
|
|
242
|
-
|
|
249
|
+
interface GetHelperTextPropsProps {
|
|
250
|
+
error?: {
|
|
251
|
+
message?: string;
|
|
252
|
+
};
|
|
253
|
+
warning?: {
|
|
254
|
+
message: string;
|
|
255
|
+
};
|
|
256
|
+
helperText?: string;
|
|
257
|
+
}
|
|
258
|
+
interface GetHelperTextProps {
|
|
259
|
+
variant?: Variants;
|
|
260
|
+
helperText?: string;
|
|
261
|
+
helperIcon: JSX.Element | null;
|
|
262
|
+
}
|
|
263
|
+
interface EditableCellBaseProps<T extends FormMeta, Value> extends CellContext<T, Value> {
|
|
264
|
+
/**
|
|
265
|
+
* FieldError object used to overwrite react-hook-form validation result. It is prioritized over
|
|
266
|
+
* react-hook-form's validation.
|
|
267
|
+
*/
|
|
268
|
+
error?: FieldError;
|
|
269
|
+
/**
|
|
270
|
+
* Custom `onChange` called on input change after react-hook-form's `onChange`. E.g. used to trigger actions on change.
|
|
271
|
+
*/
|
|
272
|
+
onChange?: (value: Value) => void;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
declare function EditableCheckboxCell<T extends FormMeta>({ onChange: onChangeFromProps, ...context }: EditableCellBaseProps<T, boolean>): JSX.Element;
|
|
243
276
|
|
|
244
|
-
interface EditableDateCellProps<T extends FormMeta> extends
|
|
277
|
+
interface EditableDateCellProps<T extends FormMeta> extends EditableCellBaseProps<T, string> {
|
|
245
278
|
dateStringFormatter?: (date: string) => string;
|
|
246
279
|
}
|
|
247
|
-
declare function EditableDateCell<T extends FormMeta>(
|
|
280
|
+
declare function EditableDateCell<T extends FormMeta>({ dateStringFormatter, error: errorFromProps, onChange: onChangeFromProps, ...context }: EditableDateCellProps<T>): JSX.Element;
|
|
248
281
|
|
|
249
282
|
interface Option {
|
|
250
283
|
label: string;
|
|
251
284
|
value: string;
|
|
252
285
|
}
|
|
253
|
-
interface EditableDropdownSingleCellProps<T extends FormMeta> extends
|
|
286
|
+
interface EditableDropdownSingleCellProps<T extends FormMeta> extends Omit<EditableCellBaseProps<T, unknown>, 'onChange'> {
|
|
254
287
|
/**
|
|
255
288
|
* `Option.value` is used internally to get and update selection state. `Option.label` is *only* for visual purposes.
|
|
256
289
|
*/
|
|
257
290
|
options: Option[];
|
|
291
|
+
onChange?: (value: Option) => void;
|
|
258
292
|
}
|
|
259
|
-
declare function EditableDropdownSingleCell<T extends FormMeta>(
|
|
293
|
+
declare function EditableDropdownSingleCell<T extends FormMeta>({ options, error: errorFromProps, onChange: onChangeFromProps, ...context }: EditableDropdownSingleCellProps<T>): JSX.Element;
|
|
260
294
|
|
|
261
|
-
declare function EditableNumberCell<T extends FormMeta>(context:
|
|
295
|
+
declare function EditableNumberCell<T extends FormMeta>({ error: errorFromProps, ...context }: EditableCellBaseProps<T, number>): JSX.Element;
|
|
262
296
|
|
|
263
|
-
interface EdtiableTextAreaProps<T extends FormMeta> extends
|
|
297
|
+
interface EdtiableTextAreaProps<T extends FormMeta> extends EditableCellBaseProps<T, string> {
|
|
264
298
|
title: string;
|
|
265
299
|
}
|
|
266
|
-
declare function EditableTextAreaCell<T extends FormMeta>(
|
|
300
|
+
declare function EditableTextAreaCell<T extends FormMeta>({ title, error: errorFromProps, onChange: onChangeFromProps, ...context }: EdtiableTextAreaProps<T>): JSX.Element;
|
|
301
|
+
|
|
302
|
+
declare function EditableTextFieldCell<T extends FormMeta>({ error: errorFromProps, ...context }: EditableCellBaseProps<T, string>): JSX.Element;
|
|
267
303
|
|
|
268
|
-
declare
|
|
304
|
+
declare const WARNING_PREFIX = "WARNING";
|
|
305
|
+
declare function getHelperTextProps({ error, warning, helperText, }: GetHelperTextPropsProps): GetHelperTextProps;
|
|
269
306
|
|
|
270
|
-
export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WithoutFormMeta, addFormMeta, capitalizeHeader, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
|
|
307
|
+
export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCellBaseProps, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, GetHelperTextProps, GetHelperTextPropsProps, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WARNING_PREFIX, WithoutFormMeta, addFormMeta, capitalizeHeader, getHelperTextProps, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
|
package/dist/index.js
CHANGED
|
@@ -2394,8 +2394,10 @@ __export(src_exports, {
|
|
|
2394
2394
|
StyledStickyCell: () => StyledStickyCell,
|
|
2395
2395
|
TableHeader: () => TableHeader,
|
|
2396
2396
|
TypographyCustom: () => TypographyCustom,
|
|
2397
|
+
WARNING_PREFIX: () => WARNING_PREFIX,
|
|
2397
2398
|
addFormMeta: () => addFormMeta,
|
|
2398
2399
|
capitalizeHeader: () => capitalizeHeader,
|
|
2400
|
+
getHelperTextProps: () => getHelperTextProps,
|
|
2399
2401
|
leftCellShadow: () => leftCellShadow,
|
|
2400
2402
|
prependSelectColumn: () => prependSelectColumn,
|
|
2401
2403
|
removeFormMeta: () => removeFormMeta,
|
|
@@ -3043,15 +3045,11 @@ var TableBody = (0, import_styled_components12.default)(import_eds_core_react13.
|
|
|
3043
3045
|
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
3044
3046
|
var import_styled_components13 = __toESM(require("styled-components"));
|
|
3045
3047
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3046
|
-
function TableRow({
|
|
3047
|
-
row,
|
|
3048
|
-
rowConfig,
|
|
3049
|
-
cellConfig,
|
|
3050
|
-
measureElement,
|
|
3051
|
-
index
|
|
3052
|
-
}) {
|
|
3048
|
+
function TableRow(props) {
|
|
3053
3049
|
var _a;
|
|
3050
|
+
const { row, rowConfig, cellConfig, measureElement, index } = props;
|
|
3054
3051
|
const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
|
|
3052
|
+
console.log("Hello");
|
|
3055
3053
|
const tableRowContent = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3056
3054
|
StyledTableRow,
|
|
3057
3055
|
{
|
|
@@ -3196,19 +3194,20 @@ function TableBanner({
|
|
|
3196
3194
|
tableCaption,
|
|
3197
3195
|
globalFilter
|
|
3198
3196
|
}) {
|
|
3199
|
-
var _a, _b;
|
|
3197
|
+
var _a, _b, _c, _d, _e;
|
|
3200
3198
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TableBannerWrapper, { className: "--table-caption", padding: bannerConfig == null ? void 0 : bannerConfig.padding, children: [
|
|
3201
3199
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(FilterContainer, { className: "--filter-container-left", children: [
|
|
3202
3200
|
(bannerConfig == null ? void 0 : bannerConfig.enableTableCaption) && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_eds_core_react17.Typography, { variant: "h3", as: "h2", children: tableCaption }),
|
|
3203
|
-
(_a = bannerConfig == null ? void 0 : bannerConfig.
|
|
3201
|
+
(_c = (_a = bannerConfig == null ? void 0 : bannerConfig.customActionsLeft) == null ? void 0 : _a.call(bannerConfig, table)) != null ? _c : (_b = bannerConfig == null ? void 0 : bannerConfig.customActions) == null ? void 0 : _b.call(bannerConfig, table)
|
|
3204
3202
|
] }),
|
|
3205
3203
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FilterContainer, { className: "--filter-container-right", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
3204
|
+
(_d = bannerConfig == null ? void 0 : bannerConfig.customActionsRight) == null ? void 0 : _d.call(bannerConfig, table),
|
|
3206
3205
|
(bannerConfig == null ? void 0 : bannerConfig.enableGlobalFilterInput) && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3207
3206
|
DebouncedInput,
|
|
3208
3207
|
{
|
|
3209
3208
|
value: globalFilter.state,
|
|
3210
3209
|
icon: import_eds_icons7.search,
|
|
3211
|
-
placeholder: (
|
|
3210
|
+
placeholder: (_e = bannerConfig.globalFilterPlaceholder) != null ? _e : "Search all columns",
|
|
3212
3211
|
onChange: (value) => globalFilter.onChange(String(value))
|
|
3213
3212
|
}
|
|
3214
3213
|
),
|
|
@@ -3545,7 +3544,12 @@ function addFormMeta(withoutFormMeta) {
|
|
|
3545
3544
|
|
|
3546
3545
|
// src/form-cells/EditableCheckboxCell.tsx
|
|
3547
3546
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3548
|
-
function EditableCheckboxCell(
|
|
3547
|
+
function EditableCheckboxCell(_a) {
|
|
3548
|
+
var _b = _a, {
|
|
3549
|
+
onChange: onChangeFromProps
|
|
3550
|
+
} = _b, context = __objRest(_b, [
|
|
3551
|
+
"onChange"
|
|
3552
|
+
]);
|
|
3549
3553
|
const editMode = useEditMode();
|
|
3550
3554
|
if (!editMode)
|
|
3551
3555
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
@@ -3562,9 +3566,21 @@ function EditableCheckboxCell(context) {
|
|
|
3562
3566
|
import_react_hook_form2.Controller,
|
|
3563
3567
|
{
|
|
3564
3568
|
name: context.column.id,
|
|
3565
|
-
render: (
|
|
3566
|
-
var { field:
|
|
3567
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3569
|
+
render: (_a2) => {
|
|
3570
|
+
var { field: _b2 } = _a2, _c = _b2, { value, onChange } = _c, field = __objRest(_c, ["value", "onChange"]);
|
|
3571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3572
|
+
import_eds_core_react20.Checkbox,
|
|
3573
|
+
__spreadProps(__spreadValues({
|
|
3574
|
+
enterKeyHint: "send",
|
|
3575
|
+
"aria-label": "editable",
|
|
3576
|
+
checked: value
|
|
3577
|
+
}, field), {
|
|
3578
|
+
onChange: (e) => {
|
|
3579
|
+
onChange(e);
|
|
3580
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(e.target.checked);
|
|
3581
|
+
}
|
|
3582
|
+
})
|
|
3583
|
+
);
|
|
3568
3584
|
}
|
|
3569
3585
|
}
|
|
3570
3586
|
);
|
|
@@ -3580,17 +3596,27 @@ var import_styled_components17 = __toESM(require("styled-components"));
|
|
|
3580
3596
|
var import_eds_core_react21 = require("@equinor/eds-core-react");
|
|
3581
3597
|
var import_eds_icons8 = require("@equinor/eds-icons");
|
|
3582
3598
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3599
|
+
var WARNING_PREFIX = "WARNING";
|
|
3583
3600
|
function getHelperTextProps({
|
|
3584
3601
|
error,
|
|
3585
3602
|
warning,
|
|
3586
3603
|
helperText
|
|
3587
3604
|
}) {
|
|
3588
|
-
|
|
3605
|
+
var _a;
|
|
3606
|
+
if (error) {
|
|
3607
|
+
if ((_a = error.message) == null ? void 0 : _a.startsWith(WARNING_PREFIX)) {
|
|
3608
|
+
return {
|
|
3609
|
+
variant: "warning",
|
|
3610
|
+
helperText: error.message.substring(WARNING_PREFIX.length - 1),
|
|
3611
|
+
helperIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_eds_core_react21.Icon, { data: import_eds_icons8.warning_filled, size: 16 })
|
|
3612
|
+
};
|
|
3613
|
+
}
|
|
3589
3614
|
return {
|
|
3590
3615
|
variant: "error",
|
|
3591
3616
|
helperText: error.message,
|
|
3592
3617
|
helperIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_eds_core_react21.Icon, { data: import_eds_icons8.error_filled, size: 16 })
|
|
3593
3618
|
};
|
|
3619
|
+
}
|
|
3594
3620
|
if (warning)
|
|
3595
3621
|
return {
|
|
3596
3622
|
variant: "warning",
|
|
@@ -3602,17 +3628,19 @@ function getHelperTextProps({
|
|
|
3602
3628
|
helperIcon: null
|
|
3603
3629
|
};
|
|
3604
3630
|
}
|
|
3605
|
-
function stopPropagation2(handler) {
|
|
3606
|
-
return (e) => {
|
|
3607
|
-
e.stopPropagation();
|
|
3608
|
-
handler(e);
|
|
3609
|
-
};
|
|
3610
|
-
}
|
|
3611
3631
|
|
|
3612
3632
|
// src/form-cells/EditableDateCell.tsx
|
|
3613
3633
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3614
|
-
function EditableDateCell(
|
|
3615
|
-
|
|
3634
|
+
function EditableDateCell(_a) {
|
|
3635
|
+
var _b = _a, {
|
|
3636
|
+
dateStringFormatter,
|
|
3637
|
+
error: errorFromProps,
|
|
3638
|
+
onChange: onChangeFromProps
|
|
3639
|
+
} = _b, context = __objRest(_b, [
|
|
3640
|
+
"dateStringFormatter",
|
|
3641
|
+
"error",
|
|
3642
|
+
"onChange"
|
|
3643
|
+
]);
|
|
3616
3644
|
const rawValue = context.getValue();
|
|
3617
3645
|
const editMode = useEditMode();
|
|
3618
3646
|
const formattedValue = (0, import_react8.useMemo)(
|
|
@@ -3628,8 +3656,8 @@ function EditableDateCell(props) {
|
|
|
3628
3656
|
import_react_hook_form3.Controller,
|
|
3629
3657
|
{
|
|
3630
3658
|
name: context.column.id,
|
|
3631
|
-
render: (
|
|
3632
|
-
var
|
|
3659
|
+
render: (_a2) => {
|
|
3660
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { value, onChange } = _d, field = __objRest(_d, ["value", "onChange"]), { fieldState: { error } } = _b2;
|
|
3633
3661
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3634
3662
|
InlineTextField,
|
|
3635
3663
|
__spreadValues(__spreadValues({
|
|
@@ -3637,8 +3665,12 @@ function EditableDateCell(props) {
|
|
|
3637
3665
|
type: "date",
|
|
3638
3666
|
autoComplete: "none",
|
|
3639
3667
|
value: value ? parseISODate(value) : "",
|
|
3640
|
-
onChange: (e) =>
|
|
3641
|
-
|
|
3668
|
+
onChange: (e) => {
|
|
3669
|
+
const newDateString = e.target.value ? parseISODate(e.target.value) : "";
|
|
3670
|
+
onChange(newDateString);
|
|
3671
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(newDateString);
|
|
3672
|
+
}
|
|
3673
|
+
}, getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error })), field)
|
|
3642
3674
|
);
|
|
3643
3675
|
}
|
|
3644
3676
|
}
|
|
@@ -3674,78 +3706,138 @@ var InlineTextField = (0, import_styled_components17.default)(import_eds_core_re
|
|
|
3674
3706
|
`;
|
|
3675
3707
|
|
|
3676
3708
|
// src/form-cells/EditableDropdownSingleCell.tsx
|
|
3677
|
-
var
|
|
3709
|
+
var import_eds_core_react24 = require("@equinor/eds-core-react");
|
|
3678
3710
|
var import_react_hook_form4 = require("react-hook-form");
|
|
3711
|
+
|
|
3712
|
+
// src/form-cells/FormHelperText.tsx
|
|
3713
|
+
var import_eds_core_react23 = require("@equinor/eds-core-react");
|
|
3714
|
+
var import_eds_tokens6 = require("@equinor/eds-tokens");
|
|
3679
3715
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3716
|
+
var colors = {
|
|
3717
|
+
error: import_eds_tokens6.tokens.colors.interactive.danger__text.hex,
|
|
3718
|
+
warning: import_eds_tokens6.tokens.colors.interactive.warning__text.hex,
|
|
3719
|
+
success: import_eds_tokens6.tokens.colors.interactive.success__text.hex
|
|
3720
|
+
};
|
|
3721
|
+
function HelperText({ helperText, variant, helperIcon }) {
|
|
3722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: helperText && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { style: { marginTop: "8px", marginLeft: "8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
3723
|
+
"div",
|
|
3724
|
+
{
|
|
3725
|
+
style: {
|
|
3726
|
+
display: "flex",
|
|
3727
|
+
alignItems: "flex-start",
|
|
3728
|
+
marginTop: "8px",
|
|
3729
|
+
color: variant ? colors[variant] : "inherit"
|
|
3730
|
+
},
|
|
3731
|
+
children: [
|
|
3732
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { style: { flexShrink: 0 }, children: helperIcon }),
|
|
3733
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3734
|
+
import_eds_core_react23.Typography,
|
|
3735
|
+
{
|
|
3736
|
+
style: {
|
|
3737
|
+
fontSize: "0.75rem",
|
|
3738
|
+
fontWeight: 500,
|
|
3739
|
+
lineHeight: "1.333em",
|
|
3740
|
+
letterSpacing: "0.013em",
|
|
3741
|
+
textAlign: "left",
|
|
3742
|
+
margin: "0 0 0 8px",
|
|
3743
|
+
color: "inherit"
|
|
3744
|
+
},
|
|
3745
|
+
children: helperText
|
|
3746
|
+
}
|
|
3747
|
+
)
|
|
3748
|
+
]
|
|
3749
|
+
}
|
|
3750
|
+
) }) });
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
// src/form-cells/EditableDropdownSingleCell.tsx
|
|
3754
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3680
3755
|
function buildEmptyOption() {
|
|
3681
3756
|
return { label: "", value: "" };
|
|
3682
3757
|
}
|
|
3683
|
-
function EditableDropdownSingleCell(
|
|
3684
|
-
|
|
3758
|
+
function EditableDropdownSingleCell(_a) {
|
|
3759
|
+
var _b = _a, {
|
|
3760
|
+
options,
|
|
3761
|
+
error: errorFromProps,
|
|
3762
|
+
onChange: onChangeFromProps
|
|
3763
|
+
} = _b, context = __objRest(_b, [
|
|
3764
|
+
"options",
|
|
3765
|
+
"error",
|
|
3766
|
+
"onChange"
|
|
3767
|
+
]);
|
|
3685
3768
|
const editMode = useEditMode();
|
|
3686
3769
|
if (!editMode)
|
|
3687
|
-
return /* @__PURE__ */ (0,
|
|
3688
|
-
return /* @__PURE__ */ (0,
|
|
3770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TypographyCustom, { truncate: true, children: context.getValue() });
|
|
3771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3689
3772
|
import_react_hook_form4.Controller,
|
|
3690
3773
|
{
|
|
3691
3774
|
name: context.column.id,
|
|
3692
|
-
render: (
|
|
3693
|
-
var { field: _c } =
|
|
3694
|
-
var
|
|
3695
|
-
const selectedOption = (
|
|
3696
|
-
return /* @__PURE__ */ (0,
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3775
|
+
render: (_a2) => {
|
|
3776
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { value, onChange } = _d, field = __objRest(_d, ["value", "onChange"]), { fieldState: { error } } = _b2;
|
|
3777
|
+
var _a3;
|
|
3778
|
+
const selectedOption = (_a3 = options.find((option) => option.value === value)) != null ? _a3 : buildEmptyOption();
|
|
3779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
3780
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3781
|
+
import_eds_core_react24.Autocomplete,
|
|
3782
|
+
__spreadValues({
|
|
3783
|
+
label: "",
|
|
3784
|
+
selectedOptions: selectedOption && [selectedOption],
|
|
3785
|
+
options,
|
|
3786
|
+
optionLabel: (option) => {
|
|
3787
|
+
var _a4;
|
|
3788
|
+
return (_a4 = option == null ? void 0 : option.label) != null ? _a4 : "";
|
|
3789
|
+
},
|
|
3790
|
+
"aria-required": true,
|
|
3791
|
+
hideClearButton: true,
|
|
3792
|
+
"aria-autocomplete": "none",
|
|
3793
|
+
onOptionsChange: (changes) => {
|
|
3794
|
+
const [change] = changes.selectedItems;
|
|
3795
|
+
onChange(change == null ? void 0 : change.value);
|
|
3796
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(change);
|
|
3797
|
+
}
|
|
3798
|
+
}, field)
|
|
3799
|
+
),
|
|
3800
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(HelperText, __spreadValues({}, getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error })))
|
|
3801
|
+
] });
|
|
3715
3802
|
}
|
|
3716
3803
|
}
|
|
3717
3804
|
);
|
|
3718
3805
|
}
|
|
3719
3806
|
|
|
3720
3807
|
// src/form-cells/EditableNumberCell.tsx
|
|
3721
|
-
var
|
|
3808
|
+
var import_eds_core_react25 = require("@equinor/eds-core-react");
|
|
3722
3809
|
var import_react_hook_form5 = require("react-hook-form");
|
|
3723
3810
|
var import_styled_components18 = __toESM(require("styled-components"));
|
|
3724
|
-
var
|
|
3725
|
-
function EditableNumberCell(
|
|
3811
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3812
|
+
function EditableNumberCell(_a) {
|
|
3813
|
+
var _b = _a, {
|
|
3814
|
+
error: errorFromProps
|
|
3815
|
+
} = _b, context = __objRest(_b, [
|
|
3816
|
+
"error"
|
|
3817
|
+
]);
|
|
3726
3818
|
const editMode = useEditMode();
|
|
3727
3819
|
if (!editMode)
|
|
3728
|
-
return /* @__PURE__ */ (0,
|
|
3729
|
-
return /* @__PURE__ */ (0,
|
|
3820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TypographyCustom, { truncate: true, children: context.getValue() });
|
|
3821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3730
3822
|
import_react_hook_form5.Controller,
|
|
3731
3823
|
{
|
|
3732
3824
|
name: context.column.id,
|
|
3733
|
-
render: (
|
|
3734
|
-
var
|
|
3735
|
-
return /* @__PURE__ */ (0,
|
|
3825
|
+
render: (_a2) => {
|
|
3826
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { onChange } = _d, field = __objRest(_d, ["onChange"]), { fieldState: { error } } = _b2;
|
|
3827
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3736
3828
|
InlineTextField2,
|
|
3737
3829
|
__spreadValues(__spreadValues({
|
|
3738
3830
|
id: context.column.id,
|
|
3739
3831
|
type: "number",
|
|
3740
3832
|
autoComplete: "none",
|
|
3741
3833
|
onChange: (e) => onChange(e.target.valueAsNumber)
|
|
3742
|
-
}, field), getHelperTextProps({ error }))
|
|
3834
|
+
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3743
3835
|
) });
|
|
3744
3836
|
}
|
|
3745
3837
|
}
|
|
3746
3838
|
);
|
|
3747
3839
|
}
|
|
3748
|
-
var InlineTextField2 = (0, import_styled_components18.default)(
|
|
3840
|
+
var InlineTextField2 = (0, import_styled_components18.default)(import_eds_core_react25.TextField)`
|
|
3749
3841
|
/*
|
|
3750
3842
|
TODO: Improve input based on feedback from UX
|
|
3751
3843
|
& > div {
|
|
@@ -3769,30 +3861,38 @@ var InlineTextField2 = (0, import_styled_components18.default)(import_eds_core_r
|
|
|
3769
3861
|
`;
|
|
3770
3862
|
|
|
3771
3863
|
// src/form-cells/EditableTextAreaCell.tsx
|
|
3772
|
-
var
|
|
3864
|
+
var import_eds_core_react26 = require("@equinor/eds-core-react");
|
|
3773
3865
|
var import_eds_icons9 = require("@equinor/eds-icons");
|
|
3774
3866
|
var import_react9 = require("react");
|
|
3775
3867
|
var import_react_hook_form6 = require("react-hook-form");
|
|
3776
3868
|
var import_styled_components19 = __toESM(require("styled-components"));
|
|
3777
|
-
var
|
|
3778
|
-
function EditableTextAreaCell(
|
|
3779
|
-
|
|
3869
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3870
|
+
function EditableTextAreaCell(_a) {
|
|
3871
|
+
var _b = _a, {
|
|
3872
|
+
title,
|
|
3873
|
+
error: errorFromProps,
|
|
3874
|
+
onChange: onChangeFromProps
|
|
3875
|
+
} = _b, context = __objRest(_b, [
|
|
3876
|
+
"title",
|
|
3877
|
+
"error",
|
|
3878
|
+
"onChange"
|
|
3879
|
+
]);
|
|
3780
3880
|
const [textareaValue, setTextareaValue] = (0, import_react9.useState)(context.getValue());
|
|
3781
3881
|
const [open, setOpen] = (0, import_react9.useState)(false);
|
|
3782
3882
|
const editMode = useEditMode();
|
|
3783
3883
|
const name = context.column.id;
|
|
3784
3884
|
if (!editMode)
|
|
3785
|
-
return /* @__PURE__ */ (0,
|
|
3885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PopoverCell, { id: name + "popover", value: context.getValue(), title });
|
|
3786
3886
|
const openDialog = () => setOpen(true);
|
|
3787
3887
|
const closeDialog = () => setOpen(false);
|
|
3788
|
-
return /* @__PURE__ */ (0,
|
|
3888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3789
3889
|
import_react_hook_form6.Controller,
|
|
3790
3890
|
{
|
|
3791
3891
|
name,
|
|
3792
|
-
render: (
|
|
3793
|
-
var
|
|
3794
|
-
return /* @__PURE__ */ (0,
|
|
3795
|
-
/* @__PURE__ */ (0,
|
|
3892
|
+
render: (_a2) => {
|
|
3893
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { onChange, ref } = _d, field = __objRest(_d, ["onChange", "ref"]), { fieldState: { error } } = _b2;
|
|
3894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
3895
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3796
3896
|
"div",
|
|
3797
3897
|
{
|
|
3798
3898
|
style: {
|
|
@@ -3801,32 +3901,33 @@ function EditableTextAreaCell(props) {
|
|
|
3801
3901
|
position: "relative"
|
|
3802
3902
|
},
|
|
3803
3903
|
children: [
|
|
3804
|
-
/* @__PURE__ */ (0,
|
|
3904
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3805
3905
|
StyledTextField,
|
|
3806
3906
|
__spreadValues(__spreadValues({
|
|
3807
3907
|
id: field.name,
|
|
3808
3908
|
onChange,
|
|
3809
3909
|
ref
|
|
3810
|
-
}, field), getHelperTextProps({ error }))
|
|
3910
|
+
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3811
3911
|
),
|
|
3812
|
-
/* @__PURE__ */ (0,
|
|
3912
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { variant: "ghost_icon", onClick: stopPropagation(openDialog), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_eds_core_react26.Icon, { data: import_eds_icons9.arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
|
|
3813
3913
|
]
|
|
3814
3914
|
}
|
|
3815
3915
|
),
|
|
3816
|
-
/* @__PURE__ */ (0,
|
|
3817
|
-
|
|
3916
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3917
|
+
import_eds_core_react26.Dialog,
|
|
3818
3918
|
{
|
|
3819
3919
|
open,
|
|
3820
3920
|
onClose: () => {
|
|
3821
3921
|
closeDialog();
|
|
3822
3922
|
onChange(textareaValue);
|
|
3923
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(textareaValue);
|
|
3823
3924
|
},
|
|
3824
3925
|
isDismissable: true,
|
|
3825
3926
|
style: { width: "min(50rem, calc(100vw - 4rem))" },
|
|
3826
3927
|
children: [
|
|
3827
|
-
/* @__PURE__ */ (0,
|
|
3828
|
-
/* @__PURE__ */ (0,
|
|
3829
|
-
|
|
3928
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_eds_core_react26.Dialog.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_eds_core_react26.Dialog.Title, { children: title }) }),
|
|
3929
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_eds_core_react26.Dialog.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3930
|
+
import_eds_core_react26.TextField,
|
|
3830
3931
|
{
|
|
3831
3932
|
style: {
|
|
3832
3933
|
maxWidth: "100%",
|
|
@@ -3842,19 +3943,20 @@ function EditableTextAreaCell(props) {
|
|
|
3842
3943
|
}
|
|
3843
3944
|
}
|
|
3844
3945
|
) }),
|
|
3845
|
-
/* @__PURE__ */ (0,
|
|
3846
|
-
/* @__PURE__ */ (0,
|
|
3847
|
-
|
|
3946
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_eds_core_react26.Dialog.Actions, { style: { display: "flex", gap: "1rem" }, children: [
|
|
3947
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3948
|
+
import_eds_core_react26.Button,
|
|
3848
3949
|
{
|
|
3849
3950
|
onClick: () => {
|
|
3850
3951
|
closeDialog();
|
|
3851
3952
|
onChange(textareaValue);
|
|
3953
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(textareaValue);
|
|
3852
3954
|
},
|
|
3853
3955
|
children: "Submit"
|
|
3854
3956
|
}
|
|
3855
3957
|
),
|
|
3856
|
-
/* @__PURE__ */ (0,
|
|
3857
|
-
|
|
3958
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3959
|
+
import_eds_core_react26.Button,
|
|
3858
3960
|
{
|
|
3859
3961
|
variant: "ghost",
|
|
3860
3962
|
onClick: () => {
|
|
@@ -3873,7 +3975,7 @@ function EditableTextAreaCell(props) {
|
|
|
3873
3975
|
}
|
|
3874
3976
|
);
|
|
3875
3977
|
}
|
|
3876
|
-
var StyledTextField = (0, import_styled_components19.default)(
|
|
3978
|
+
var StyledTextField = (0, import_styled_components19.default)(import_eds_core_react26.TextField)`
|
|
3877
3979
|
& input {
|
|
3878
3980
|
padding-right: 40px;
|
|
3879
3981
|
letter-spacing: 0;
|
|
@@ -3882,7 +3984,7 @@ var StyledTextField = (0, import_styled_components19.default)(import_eds_core_re
|
|
|
3882
3984
|
text-overflow: ellipsis;
|
|
3883
3985
|
}
|
|
3884
3986
|
`;
|
|
3885
|
-
var IconButton = (0, import_styled_components19.default)(
|
|
3987
|
+
var IconButton = (0, import_styled_components19.default)(import_eds_core_react26.Button)`
|
|
3886
3988
|
position: absolute;
|
|
3887
3989
|
height: 32px;
|
|
3888
3990
|
width: 32px;
|
|
@@ -3890,33 +3992,38 @@ var IconButton = (0, import_styled_components19.default)(import_eds_core_react25
|
|
|
3890
3992
|
`;
|
|
3891
3993
|
|
|
3892
3994
|
// src/form-cells/EditableTextFieldCell.tsx
|
|
3893
|
-
var
|
|
3995
|
+
var import_eds_core_react27 = require("@equinor/eds-core-react");
|
|
3894
3996
|
var import_react_hook_form7 = require("react-hook-form");
|
|
3895
3997
|
var import_styled_components20 = __toESM(require("styled-components"));
|
|
3896
|
-
var
|
|
3897
|
-
function EditableTextFieldCell(
|
|
3998
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3999
|
+
function EditableTextFieldCell(_a) {
|
|
4000
|
+
var _b = _a, {
|
|
4001
|
+
error: errorFromProps
|
|
4002
|
+
} = _b, context = __objRest(_b, [
|
|
4003
|
+
"error"
|
|
4004
|
+
]);
|
|
3898
4005
|
const editMode = useEditMode();
|
|
3899
4006
|
if (!editMode)
|
|
3900
|
-
return /* @__PURE__ */ (0,
|
|
3901
|
-
return /* @__PURE__ */ (0,
|
|
4007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TypographyCustom, { truncate: true, children: context.getValue() });
|
|
4008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3902
4009
|
import_react_hook_form7.Controller,
|
|
3903
4010
|
{
|
|
3904
4011
|
name: context.column.id,
|
|
3905
|
-
render: (
|
|
3906
|
-
var
|
|
3907
|
-
return /* @__PURE__ */ (0,
|
|
4012
|
+
render: (_a2) => {
|
|
4013
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { value } = _d, field = __objRest(_d, ["value"]), { fieldState: { error } } = _b2;
|
|
4014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3908
4015
|
InlineTextField3,
|
|
3909
4016
|
__spreadValues(__spreadValues({
|
|
3910
4017
|
id: context.column.id,
|
|
3911
4018
|
autoComplete: "none",
|
|
3912
4019
|
value: String(value != null ? value : "")
|
|
3913
|
-
}, field), getHelperTextProps({ error }))
|
|
4020
|
+
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3914
4021
|
);
|
|
3915
4022
|
}
|
|
3916
4023
|
}
|
|
3917
4024
|
);
|
|
3918
4025
|
}
|
|
3919
|
-
var InlineTextField3 = (0, import_styled_components20.default)(
|
|
4026
|
+
var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_react27.TextField)`
|
|
3920
4027
|
/*
|
|
3921
4028
|
TODO: Improve input based on feedback from UX
|
|
3922
4029
|
& > div {
|
|
@@ -3962,8 +4069,10 @@ var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_r
|
|
|
3962
4069
|
StyledStickyCell,
|
|
3963
4070
|
TableHeader,
|
|
3964
4071
|
TypographyCustom,
|
|
4072
|
+
WARNING_PREFIX,
|
|
3965
4073
|
addFormMeta,
|
|
3966
4074
|
capitalizeHeader,
|
|
4075
|
+
getHelperTextProps,
|
|
3967
4076
|
leftCellShadow,
|
|
3968
4077
|
prependSelectColumn,
|
|
3969
4078
|
removeFormMeta,
|
package/dist/index.mjs
CHANGED
|
@@ -3006,15 +3006,11 @@ var TableBody = styled12(Table6.Body)`
|
|
|
3006
3006
|
import { Table as Table7 } from "@equinor/eds-core-react";
|
|
3007
3007
|
import styled13 from "styled-components";
|
|
3008
3008
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
3009
|
-
function TableRow({
|
|
3010
|
-
row,
|
|
3011
|
-
rowConfig,
|
|
3012
|
-
cellConfig,
|
|
3013
|
-
measureElement,
|
|
3014
|
-
index
|
|
3015
|
-
}) {
|
|
3009
|
+
function TableRow(props) {
|
|
3016
3010
|
var _a;
|
|
3011
|
+
const { row, rowConfig, cellConfig, measureElement, index } = props;
|
|
3017
3012
|
const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
|
|
3013
|
+
console.log("Hello");
|
|
3018
3014
|
const tableRowContent = /* @__PURE__ */ jsx14(
|
|
3019
3015
|
StyledTableRow,
|
|
3020
3016
|
{
|
|
@@ -3159,19 +3155,20 @@ function TableBanner({
|
|
|
3159
3155
|
tableCaption,
|
|
3160
3156
|
globalFilter
|
|
3161
3157
|
}) {
|
|
3162
|
-
var _a, _b;
|
|
3158
|
+
var _a, _b, _c, _d, _e;
|
|
3163
3159
|
return /* @__PURE__ */ jsxs9(TableBannerWrapper, { className: "--table-caption", padding: bannerConfig == null ? void 0 : bannerConfig.padding, children: [
|
|
3164
3160
|
/* @__PURE__ */ jsxs9(FilterContainer, { className: "--filter-container-left", children: [
|
|
3165
3161
|
(bannerConfig == null ? void 0 : bannerConfig.enableTableCaption) && /* @__PURE__ */ jsx17(Typography3, { variant: "h3", as: "h2", children: tableCaption }),
|
|
3166
|
-
(_a = bannerConfig == null ? void 0 : bannerConfig.
|
|
3162
|
+
(_c = (_a = bannerConfig == null ? void 0 : bannerConfig.customActionsLeft) == null ? void 0 : _a.call(bannerConfig, table)) != null ? _c : (_b = bannerConfig == null ? void 0 : bannerConfig.customActions) == null ? void 0 : _b.call(bannerConfig, table)
|
|
3167
3163
|
] }),
|
|
3168
3164
|
/* @__PURE__ */ jsx17(FilterContainer, { className: "--filter-container-right", children: /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
3165
|
+
(_d = bannerConfig == null ? void 0 : bannerConfig.customActionsRight) == null ? void 0 : _d.call(bannerConfig, table),
|
|
3169
3166
|
(bannerConfig == null ? void 0 : bannerConfig.enableGlobalFilterInput) && /* @__PURE__ */ jsx17(
|
|
3170
3167
|
DebouncedInput,
|
|
3171
3168
|
{
|
|
3172
3169
|
value: globalFilter.state,
|
|
3173
3170
|
icon: search,
|
|
3174
|
-
placeholder: (
|
|
3171
|
+
placeholder: (_e = bannerConfig.globalFilterPlaceholder) != null ? _e : "Search all columns",
|
|
3175
3172
|
onChange: (value) => globalFilter.onChange(String(value))
|
|
3176
3173
|
}
|
|
3177
3174
|
),
|
|
@@ -3508,7 +3505,12 @@ function addFormMeta(withoutFormMeta) {
|
|
|
3508
3505
|
|
|
3509
3506
|
// src/form-cells/EditableCheckboxCell.tsx
|
|
3510
3507
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
3511
|
-
function EditableCheckboxCell(
|
|
3508
|
+
function EditableCheckboxCell(_a) {
|
|
3509
|
+
var _b = _a, {
|
|
3510
|
+
onChange: onChangeFromProps
|
|
3511
|
+
} = _b, context = __objRest(_b, [
|
|
3512
|
+
"onChange"
|
|
3513
|
+
]);
|
|
3512
3514
|
const editMode = useEditMode();
|
|
3513
3515
|
if (!editMode)
|
|
3514
3516
|
return /* @__PURE__ */ jsx21(
|
|
@@ -3525,9 +3527,21 @@ function EditableCheckboxCell(context) {
|
|
|
3525
3527
|
Controller,
|
|
3526
3528
|
{
|
|
3527
3529
|
name: context.column.id,
|
|
3528
|
-
render: (
|
|
3529
|
-
var { field:
|
|
3530
|
-
return /* @__PURE__ */ jsx21(
|
|
3530
|
+
render: (_a2) => {
|
|
3531
|
+
var { field: _b2 } = _a2, _c = _b2, { value, onChange } = _c, field = __objRest(_c, ["value", "onChange"]);
|
|
3532
|
+
return /* @__PURE__ */ jsx21(
|
|
3533
|
+
Checkbox4,
|
|
3534
|
+
__spreadProps(__spreadValues({
|
|
3535
|
+
enterKeyHint: "send",
|
|
3536
|
+
"aria-label": "editable",
|
|
3537
|
+
checked: value
|
|
3538
|
+
}, field), {
|
|
3539
|
+
onChange: (e) => {
|
|
3540
|
+
onChange(e);
|
|
3541
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(e.target.checked);
|
|
3542
|
+
}
|
|
3543
|
+
})
|
|
3544
|
+
);
|
|
3531
3545
|
}
|
|
3532
3546
|
}
|
|
3533
3547
|
);
|
|
@@ -3543,17 +3557,27 @@ import styled17 from "styled-components";
|
|
|
3543
3557
|
import { Icon as Icon7 } from "@equinor/eds-core-react";
|
|
3544
3558
|
import { error_filled, warning_filled } from "@equinor/eds-icons";
|
|
3545
3559
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
3560
|
+
var WARNING_PREFIX = "WARNING";
|
|
3546
3561
|
function getHelperTextProps({
|
|
3547
3562
|
error,
|
|
3548
3563
|
warning,
|
|
3549
3564
|
helperText
|
|
3550
3565
|
}) {
|
|
3551
|
-
|
|
3566
|
+
var _a;
|
|
3567
|
+
if (error) {
|
|
3568
|
+
if ((_a = error.message) == null ? void 0 : _a.startsWith(WARNING_PREFIX)) {
|
|
3569
|
+
return {
|
|
3570
|
+
variant: "warning",
|
|
3571
|
+
helperText: error.message.substring(WARNING_PREFIX.length - 1),
|
|
3572
|
+
helperIcon: /* @__PURE__ */ jsx22(Icon7, { data: warning_filled, size: 16 })
|
|
3573
|
+
};
|
|
3574
|
+
}
|
|
3552
3575
|
return {
|
|
3553
3576
|
variant: "error",
|
|
3554
3577
|
helperText: error.message,
|
|
3555
3578
|
helperIcon: /* @__PURE__ */ jsx22(Icon7, { data: error_filled, size: 16 })
|
|
3556
3579
|
};
|
|
3580
|
+
}
|
|
3557
3581
|
if (warning)
|
|
3558
3582
|
return {
|
|
3559
3583
|
variant: "warning",
|
|
@@ -3565,17 +3589,19 @@ function getHelperTextProps({
|
|
|
3565
3589
|
helperIcon: null
|
|
3566
3590
|
};
|
|
3567
3591
|
}
|
|
3568
|
-
function stopPropagation2(handler) {
|
|
3569
|
-
return (e) => {
|
|
3570
|
-
e.stopPropagation();
|
|
3571
|
-
handler(e);
|
|
3572
|
-
};
|
|
3573
|
-
}
|
|
3574
3592
|
|
|
3575
3593
|
// src/form-cells/EditableDateCell.tsx
|
|
3576
3594
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
3577
|
-
function EditableDateCell(
|
|
3578
|
-
|
|
3595
|
+
function EditableDateCell(_a) {
|
|
3596
|
+
var _b = _a, {
|
|
3597
|
+
dateStringFormatter,
|
|
3598
|
+
error: errorFromProps,
|
|
3599
|
+
onChange: onChangeFromProps
|
|
3600
|
+
} = _b, context = __objRest(_b, [
|
|
3601
|
+
"dateStringFormatter",
|
|
3602
|
+
"error",
|
|
3603
|
+
"onChange"
|
|
3604
|
+
]);
|
|
3579
3605
|
const rawValue = context.getValue();
|
|
3580
3606
|
const editMode = useEditMode();
|
|
3581
3607
|
const formattedValue = useMemo(
|
|
@@ -3591,8 +3617,8 @@ function EditableDateCell(props) {
|
|
|
3591
3617
|
Controller2,
|
|
3592
3618
|
{
|
|
3593
3619
|
name: context.column.id,
|
|
3594
|
-
render: (
|
|
3595
|
-
var
|
|
3620
|
+
render: (_a2) => {
|
|
3621
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { value, onChange } = _d, field = __objRest(_d, ["value", "onChange"]), { fieldState: { error } } = _b2;
|
|
3596
3622
|
return /* @__PURE__ */ jsx23(
|
|
3597
3623
|
InlineTextField,
|
|
3598
3624
|
__spreadValues(__spreadValues({
|
|
@@ -3600,8 +3626,12 @@ function EditableDateCell(props) {
|
|
|
3600
3626
|
type: "date",
|
|
3601
3627
|
autoComplete: "none",
|
|
3602
3628
|
value: value ? parseISODate(value) : "",
|
|
3603
|
-
onChange: (e) =>
|
|
3604
|
-
|
|
3629
|
+
onChange: (e) => {
|
|
3630
|
+
const newDateString = e.target.value ? parseISODate(e.target.value) : "";
|
|
3631
|
+
onChange(newDateString);
|
|
3632
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(newDateString);
|
|
3633
|
+
}
|
|
3634
|
+
}, getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error })), field)
|
|
3605
3635
|
);
|
|
3606
3636
|
}
|
|
3607
3637
|
}
|
|
@@ -3639,42 +3669,97 @@ var InlineTextField = styled17(TextField)`
|
|
|
3639
3669
|
// src/form-cells/EditableDropdownSingleCell.tsx
|
|
3640
3670
|
import { Autocomplete } from "@equinor/eds-core-react";
|
|
3641
3671
|
import { Controller as Controller3 } from "react-hook-form";
|
|
3642
|
-
|
|
3672
|
+
|
|
3673
|
+
// src/form-cells/FormHelperText.tsx
|
|
3674
|
+
import { Typography as Typography4 } from "@equinor/eds-core-react";
|
|
3675
|
+
import { tokens as tokens6 } from "@equinor/eds-tokens";
|
|
3676
|
+
import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3677
|
+
var colors = {
|
|
3678
|
+
error: tokens6.colors.interactive.danger__text.hex,
|
|
3679
|
+
warning: tokens6.colors.interactive.warning__text.hex,
|
|
3680
|
+
success: tokens6.colors.interactive.success__text.hex
|
|
3681
|
+
};
|
|
3682
|
+
function HelperText({ helperText, variant, helperIcon }) {
|
|
3683
|
+
return /* @__PURE__ */ jsx24(Fragment4, { children: helperText && /* @__PURE__ */ jsx24("div", { style: { marginTop: "8px", marginLeft: "8px" }, children: /* @__PURE__ */ jsxs12(
|
|
3684
|
+
"div",
|
|
3685
|
+
{
|
|
3686
|
+
style: {
|
|
3687
|
+
display: "flex",
|
|
3688
|
+
alignItems: "flex-start",
|
|
3689
|
+
marginTop: "8px",
|
|
3690
|
+
color: variant ? colors[variant] : "inherit"
|
|
3691
|
+
},
|
|
3692
|
+
children: [
|
|
3693
|
+
/* @__PURE__ */ jsx24("span", { style: { flexShrink: 0 }, children: helperIcon }),
|
|
3694
|
+
/* @__PURE__ */ jsx24(
|
|
3695
|
+
Typography4,
|
|
3696
|
+
{
|
|
3697
|
+
style: {
|
|
3698
|
+
fontSize: "0.75rem",
|
|
3699
|
+
fontWeight: 500,
|
|
3700
|
+
lineHeight: "1.333em",
|
|
3701
|
+
letterSpacing: "0.013em",
|
|
3702
|
+
textAlign: "left",
|
|
3703
|
+
margin: "0 0 0 8px",
|
|
3704
|
+
color: "inherit"
|
|
3705
|
+
},
|
|
3706
|
+
children: helperText
|
|
3707
|
+
}
|
|
3708
|
+
)
|
|
3709
|
+
]
|
|
3710
|
+
}
|
|
3711
|
+
) }) });
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
// src/form-cells/EditableDropdownSingleCell.tsx
|
|
3715
|
+
import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3643
3716
|
function buildEmptyOption() {
|
|
3644
3717
|
return { label: "", value: "" };
|
|
3645
3718
|
}
|
|
3646
|
-
function EditableDropdownSingleCell(
|
|
3647
|
-
|
|
3719
|
+
function EditableDropdownSingleCell(_a) {
|
|
3720
|
+
var _b = _a, {
|
|
3721
|
+
options,
|
|
3722
|
+
error: errorFromProps,
|
|
3723
|
+
onChange: onChangeFromProps
|
|
3724
|
+
} = _b, context = __objRest(_b, [
|
|
3725
|
+
"options",
|
|
3726
|
+
"error",
|
|
3727
|
+
"onChange"
|
|
3728
|
+
]);
|
|
3648
3729
|
const editMode = useEditMode();
|
|
3649
3730
|
if (!editMode)
|
|
3650
|
-
return /* @__PURE__ */
|
|
3651
|
-
return /* @__PURE__ */
|
|
3731
|
+
return /* @__PURE__ */ jsx25(TypographyCustom, { truncate: true, children: context.getValue() });
|
|
3732
|
+
return /* @__PURE__ */ jsx25(
|
|
3652
3733
|
Controller3,
|
|
3653
3734
|
{
|
|
3654
3735
|
name: context.column.id,
|
|
3655
|
-
render: (
|
|
3656
|
-
var { field: _c } =
|
|
3657
|
-
var
|
|
3658
|
-
const selectedOption = (
|
|
3659
|
-
return /* @__PURE__ */
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3736
|
+
render: (_a2) => {
|
|
3737
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { value, onChange } = _d, field = __objRest(_d, ["value", "onChange"]), { fieldState: { error } } = _b2;
|
|
3738
|
+
var _a3;
|
|
3739
|
+
const selectedOption = (_a3 = options.find((option) => option.value === value)) != null ? _a3 : buildEmptyOption();
|
|
3740
|
+
return /* @__PURE__ */ jsxs13(Fragment5, { children: [
|
|
3741
|
+
/* @__PURE__ */ jsx25(
|
|
3742
|
+
Autocomplete,
|
|
3743
|
+
__spreadValues({
|
|
3744
|
+
label: "",
|
|
3745
|
+
selectedOptions: selectedOption && [selectedOption],
|
|
3746
|
+
options,
|
|
3747
|
+
optionLabel: (option) => {
|
|
3748
|
+
var _a4;
|
|
3749
|
+
return (_a4 = option == null ? void 0 : option.label) != null ? _a4 : "";
|
|
3750
|
+
},
|
|
3751
|
+
"aria-required": true,
|
|
3752
|
+
hideClearButton: true,
|
|
3753
|
+
"aria-autocomplete": "none",
|
|
3754
|
+
onOptionsChange: (changes) => {
|
|
3755
|
+
const [change] = changes.selectedItems;
|
|
3756
|
+
onChange(change == null ? void 0 : change.value);
|
|
3757
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(change);
|
|
3758
|
+
}
|
|
3759
|
+
}, field)
|
|
3760
|
+
),
|
|
3761
|
+
/* @__PURE__ */ jsx25(HelperText, __spreadValues({}, getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error })))
|
|
3762
|
+
] });
|
|
3678
3763
|
}
|
|
3679
3764
|
}
|
|
3680
3765
|
);
|
|
@@ -3684,25 +3769,30 @@ function EditableDropdownSingleCell(props) {
|
|
|
3684
3769
|
import { TextField as TextField2 } from "@equinor/eds-core-react";
|
|
3685
3770
|
import { Controller as Controller4 } from "react-hook-form";
|
|
3686
3771
|
import styled18 from "styled-components";
|
|
3687
|
-
import { Fragment as
|
|
3688
|
-
function EditableNumberCell(
|
|
3772
|
+
import { Fragment as Fragment6, jsx as jsx26 } from "react/jsx-runtime";
|
|
3773
|
+
function EditableNumberCell(_a) {
|
|
3774
|
+
var _b = _a, {
|
|
3775
|
+
error: errorFromProps
|
|
3776
|
+
} = _b, context = __objRest(_b, [
|
|
3777
|
+
"error"
|
|
3778
|
+
]);
|
|
3689
3779
|
const editMode = useEditMode();
|
|
3690
3780
|
if (!editMode)
|
|
3691
|
-
return /* @__PURE__ */
|
|
3692
|
-
return /* @__PURE__ */
|
|
3781
|
+
return /* @__PURE__ */ jsx26(TypographyCustom, { truncate: true, children: context.getValue() });
|
|
3782
|
+
return /* @__PURE__ */ jsx26(
|
|
3693
3783
|
Controller4,
|
|
3694
3784
|
{
|
|
3695
3785
|
name: context.column.id,
|
|
3696
|
-
render: (
|
|
3697
|
-
var
|
|
3698
|
-
return /* @__PURE__ */
|
|
3786
|
+
render: (_a2) => {
|
|
3787
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { onChange } = _d, field = __objRest(_d, ["onChange"]), { fieldState: { error } } = _b2;
|
|
3788
|
+
return /* @__PURE__ */ jsx26(Fragment6, { children: /* @__PURE__ */ jsx26(
|
|
3699
3789
|
InlineTextField2,
|
|
3700
3790
|
__spreadValues(__spreadValues({
|
|
3701
3791
|
id: context.column.id,
|
|
3702
3792
|
type: "number",
|
|
3703
3793
|
autoComplete: "none",
|
|
3704
3794
|
onChange: (e) => onChange(e.target.valueAsNumber)
|
|
3705
|
-
}, field), getHelperTextProps({ error }))
|
|
3795
|
+
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3706
3796
|
) });
|
|
3707
3797
|
}
|
|
3708
3798
|
}
|
|
@@ -3737,25 +3827,33 @@ import { arrow_up } from "@equinor/eds-icons";
|
|
|
3737
3827
|
import { useState as useState7 } from "react";
|
|
3738
3828
|
import { Controller as Controller5 } from "react-hook-form";
|
|
3739
3829
|
import styled19 from "styled-components";
|
|
3740
|
-
import { Fragment as
|
|
3741
|
-
function EditableTextAreaCell(
|
|
3742
|
-
|
|
3830
|
+
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3831
|
+
function EditableTextAreaCell(_a) {
|
|
3832
|
+
var _b = _a, {
|
|
3833
|
+
title,
|
|
3834
|
+
error: errorFromProps,
|
|
3835
|
+
onChange: onChangeFromProps
|
|
3836
|
+
} = _b, context = __objRest(_b, [
|
|
3837
|
+
"title",
|
|
3838
|
+
"error",
|
|
3839
|
+
"onChange"
|
|
3840
|
+
]);
|
|
3743
3841
|
const [textareaValue, setTextareaValue] = useState7(context.getValue());
|
|
3744
3842
|
const [open, setOpen] = useState7(false);
|
|
3745
3843
|
const editMode = useEditMode();
|
|
3746
3844
|
const name = context.column.id;
|
|
3747
3845
|
if (!editMode)
|
|
3748
|
-
return /* @__PURE__ */
|
|
3846
|
+
return /* @__PURE__ */ jsx27(PopoverCell, { id: name + "popover", value: context.getValue(), title });
|
|
3749
3847
|
const openDialog = () => setOpen(true);
|
|
3750
3848
|
const closeDialog = () => setOpen(false);
|
|
3751
|
-
return /* @__PURE__ */
|
|
3849
|
+
return /* @__PURE__ */ jsx27(
|
|
3752
3850
|
Controller5,
|
|
3753
3851
|
{
|
|
3754
3852
|
name,
|
|
3755
|
-
render: (
|
|
3756
|
-
var
|
|
3757
|
-
return /* @__PURE__ */
|
|
3758
|
-
/* @__PURE__ */
|
|
3853
|
+
render: (_a2) => {
|
|
3854
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { onChange, ref } = _d, field = __objRest(_d, ["onChange", "ref"]), { fieldState: { error } } = _b2;
|
|
3855
|
+
return /* @__PURE__ */ jsxs14(Fragment7, { children: [
|
|
3856
|
+
/* @__PURE__ */ jsxs14(
|
|
3759
3857
|
"div",
|
|
3760
3858
|
{
|
|
3761
3859
|
style: {
|
|
@@ -3764,31 +3862,32 @@ function EditableTextAreaCell(props) {
|
|
|
3764
3862
|
position: "relative"
|
|
3765
3863
|
},
|
|
3766
3864
|
children: [
|
|
3767
|
-
/* @__PURE__ */
|
|
3865
|
+
/* @__PURE__ */ jsx27(
|
|
3768
3866
|
StyledTextField,
|
|
3769
3867
|
__spreadValues(__spreadValues({
|
|
3770
3868
|
id: field.name,
|
|
3771
3869
|
onChange,
|
|
3772
3870
|
ref
|
|
3773
|
-
}, field), getHelperTextProps({ error }))
|
|
3871
|
+
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3774
3872
|
),
|
|
3775
|
-
/* @__PURE__ */
|
|
3873
|
+
/* @__PURE__ */ jsx27(IconButton, { variant: "ghost_icon", onClick: stopPropagation(openDialog), children: /* @__PURE__ */ jsx27(Icon8, { data: arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
|
|
3776
3874
|
]
|
|
3777
3875
|
}
|
|
3778
3876
|
),
|
|
3779
|
-
/* @__PURE__ */
|
|
3877
|
+
/* @__PURE__ */ jsxs14(
|
|
3780
3878
|
EDS,
|
|
3781
3879
|
{
|
|
3782
3880
|
open,
|
|
3783
3881
|
onClose: () => {
|
|
3784
3882
|
closeDialog();
|
|
3785
3883
|
onChange(textareaValue);
|
|
3884
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(textareaValue);
|
|
3786
3885
|
},
|
|
3787
3886
|
isDismissable: true,
|
|
3788
3887
|
style: { width: "min(50rem, calc(100vw - 4rem))" },
|
|
3789
3888
|
children: [
|
|
3790
|
-
/* @__PURE__ */
|
|
3791
|
-
/* @__PURE__ */
|
|
3889
|
+
/* @__PURE__ */ jsx27(EDS.Header, { children: /* @__PURE__ */ jsx27(EDS.Title, { children: title }) }),
|
|
3890
|
+
/* @__PURE__ */ jsx27(EDS.Content, { children: /* @__PURE__ */ jsx27(
|
|
3792
3891
|
TextField3,
|
|
3793
3892
|
{
|
|
3794
3893
|
style: {
|
|
@@ -3805,18 +3904,19 @@ function EditableTextAreaCell(props) {
|
|
|
3805
3904
|
}
|
|
3806
3905
|
}
|
|
3807
3906
|
) }),
|
|
3808
|
-
/* @__PURE__ */
|
|
3809
|
-
/* @__PURE__ */
|
|
3907
|
+
/* @__PURE__ */ jsxs14(EDS.Actions, { style: { display: "flex", gap: "1rem" }, children: [
|
|
3908
|
+
/* @__PURE__ */ jsx27(
|
|
3810
3909
|
Button5,
|
|
3811
3910
|
{
|
|
3812
3911
|
onClick: () => {
|
|
3813
3912
|
closeDialog();
|
|
3814
3913
|
onChange(textareaValue);
|
|
3914
|
+
onChangeFromProps == null ? void 0 : onChangeFromProps(textareaValue);
|
|
3815
3915
|
},
|
|
3816
3916
|
children: "Submit"
|
|
3817
3917
|
}
|
|
3818
3918
|
),
|
|
3819
|
-
/* @__PURE__ */
|
|
3919
|
+
/* @__PURE__ */ jsx27(
|
|
3820
3920
|
Button5,
|
|
3821
3921
|
{
|
|
3822
3922
|
variant: "ghost",
|
|
@@ -3856,24 +3956,29 @@ var IconButton = styled19(Button5)`
|
|
|
3856
3956
|
import { TextField as TextField4 } from "@equinor/eds-core-react";
|
|
3857
3957
|
import { Controller as Controller6 } from "react-hook-form";
|
|
3858
3958
|
import styled20 from "styled-components";
|
|
3859
|
-
import { jsx as
|
|
3860
|
-
function EditableTextFieldCell(
|
|
3959
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3960
|
+
function EditableTextFieldCell(_a) {
|
|
3961
|
+
var _b = _a, {
|
|
3962
|
+
error: errorFromProps
|
|
3963
|
+
} = _b, context = __objRest(_b, [
|
|
3964
|
+
"error"
|
|
3965
|
+
]);
|
|
3861
3966
|
const editMode = useEditMode();
|
|
3862
3967
|
if (!editMode)
|
|
3863
|
-
return /* @__PURE__ */
|
|
3864
|
-
return /* @__PURE__ */
|
|
3968
|
+
return /* @__PURE__ */ jsx28(TypographyCustom, { truncate: true, children: context.getValue() });
|
|
3969
|
+
return /* @__PURE__ */ jsx28(
|
|
3865
3970
|
Controller6,
|
|
3866
3971
|
{
|
|
3867
3972
|
name: context.column.id,
|
|
3868
|
-
render: (
|
|
3869
|
-
var
|
|
3870
|
-
return /* @__PURE__ */
|
|
3973
|
+
render: (_a2) => {
|
|
3974
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { value } = _d, field = __objRest(_d, ["value"]), { fieldState: { error } } = _b2;
|
|
3975
|
+
return /* @__PURE__ */ jsx28(
|
|
3871
3976
|
InlineTextField3,
|
|
3872
3977
|
__spreadValues(__spreadValues({
|
|
3873
3978
|
id: context.column.id,
|
|
3874
3979
|
autoComplete: "none",
|
|
3875
3980
|
value: String(value != null ? value : "")
|
|
3876
|
-
}, field), getHelperTextProps({ error }))
|
|
3981
|
+
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3877
3982
|
);
|
|
3878
3983
|
}
|
|
3879
3984
|
}
|
|
@@ -3924,8 +4029,10 @@ export {
|
|
|
3924
4029
|
StyledStickyCell,
|
|
3925
4030
|
TableHeader,
|
|
3926
4031
|
TypographyCustom,
|
|
4032
|
+
WARNING_PREFIX,
|
|
3927
4033
|
addFormMeta,
|
|
3928
4034
|
capitalizeHeader,
|
|
4035
|
+
getHelperTextProps,
|
|
3929
4036
|
leftCellShadow,
|
|
3930
4037
|
prependSelectColumn,
|
|
3931
4038
|
removeFormMeta,
|