@scality/core-ui 0.121.0 → 0.123.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/.storybook/preview.js +29 -8
- package/dist/components/card/Card.component.d.ts.map +1 -1
- package/dist/components/card/Card.component.js +7 -5
- package/dist/components/checkbox/Checkbox.component.d.ts +7 -0
- package/dist/components/checkbox/Checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.component.js +2 -0
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +1 -4
- package/dist/components/emptystate/Emptystate.component.d.ts +11 -1
- package/dist/components/emptystate/Emptystate.component.d.ts.map +1 -1
- package/dist/components/emptystate/Emptystate.component.js +9 -4
- package/dist/components/icon/Icon.component.d.ts +2 -2
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts +1 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessageUtils.js +5 -4
- package/dist/components/layout/v2/AppContainer.js +1 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +1 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.js +1 -2
- package/dist/components/navbar/Navbar.component.d.ts.map +1 -1
- package/dist/components/navbar/Navbar.component.js +1 -0
- package/dist/components/searchinput/SearchInput.component.d.ts +2 -1
- package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.js +10 -7
- package/dist/components/sidebar/Sidebar.component.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.component.js +2 -1
- package/dist/components/steppers/Steppers.component.d.ts.map +1 -1
- package/dist/components/steppers/Steppers.component.js +9 -3
- package/dist/components/tablev2/MultiSelectableContent.d.ts +1 -2
- package/dist/components/tablev2/MultiSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/MultiSelectableContent.js +9 -24
- package/dist/components/tablev2/Search.d.ts +0 -6
- package/dist/components/tablev2/Search.d.ts.map +1 -1
- package/dist/components/tablev2/Search.js +3 -4
- package/dist/components/tablev2/SingleSelectableContent.d.ts +4 -5
- package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/SingleSelectableContent.js +9 -23
- package/dist/components/tablev2/TableCommon.d.ts +15 -3
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.js +37 -2
- package/dist/components/tablev2/TableUtils.d.ts +11 -0
- package/dist/components/tablev2/TableUtils.d.ts.map +1 -1
- package/dist/components/tablev2/TableUtils.js +23 -0
- package/dist/components/tablev2/Tablestyle.d.ts +6 -3
- package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.js +29 -36
- package/dist/components/tablev2/Tablev2.component.d.ts +24 -3
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
- package/dist/components/tablev2/Tablev2.component.js +3 -1
- package/dist/components/tabsv2/StyledTabs.d.ts.map +1 -1
- package/dist/components/tabsv2/StyledTabs.js +14 -14
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/Toast.component.js +1 -1
- package/dist/components/toast/useMutationsHandler.d.ts +1 -1
- package/dist/components/toast/useMutationsHandler.d.ts.map +1 -1
- package/dist/components/toast/useMutationsHandler.js +8 -6
- package/dist/components/vegachartv2/VegaChartV2.component.js +1 -1
- package/dist/organisms/attachments/AttachmentConfirmationModal.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentConfirmationModal.js +1 -1
- package/dist/organisms/attachments/AttachmentTable.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentTable.js +15 -12
- package/package.json +5 -3
- package/src/lib/components/card/Card.component.tsx +7 -6
- package/src/lib/components/checkbox/Checkbox.component.tsx +3 -1
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +1 -4
- package/src/lib/components/emptystate/Emptystate.component.tsx +34 -10
- package/src/lib/components/icon/Icon.component.tsx +2 -2
- package/src/lib/components/infomessage/InfoMessageUtils.ts +39 -33
- package/src/lib/components/layout/v2/AppContainer.tsx +1 -1
- package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +1 -2
- package/src/lib/components/navbar/Navbar.component.tsx +1 -0
- package/src/lib/components/searchinput/SearchInput.component.tsx +1 -0
- package/src/lib/components/selectv2/Selectv2.component.tsx +12 -8
- package/src/lib/components/selectv2/selectv2.test.tsx +193 -5
- package/src/lib/components/sidebar/Sidebar.component.tsx +3 -2
- package/src/lib/components/steppers/Steppers.component.tsx +13 -3
- package/src/lib/components/tablev2/MultiSelectableContent.tsx +13 -63
- package/src/lib/components/tablev2/Search.tsx +13 -24
- package/src/lib/components/tablev2/SingleSelectableContent.tsx +18 -71
- package/src/lib/components/tablev2/TableCommon.tsx +100 -1
- package/src/lib/components/tablev2/TableUtils.ts +37 -0
- package/src/lib/components/tablev2/Tablestyle.tsx +30 -37
- package/src/lib/components/tablev2/Tablev2.component.tsx +14 -0
- package/src/lib/components/tablev2/Tablev2.test.tsx +0 -3
- package/src/lib/components/tabsv2/StyledTabs.ts +16 -14
- package/src/lib/components/toast/Toast.component.tsx +1 -0
- package/src/lib/components/toast/useMutationsHandler.ts +4 -2
- package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +1 -1
- package/src/lib/organisms/attachments/AttachmentConfirmationModal.tsx +0 -1
- package/src/lib/organisms/attachments/AttachmentTable.tsx +25 -16
- package/stories/Checkbox/checkbox.guideline.mdx +55 -0
- package/stories/Checkbox/checkbox.stories.tsx +173 -0
- package/stories/Hooks/useMutationsHandler.mdx +121 -0
- package/stories/attachment.stories.tsx +78 -0
- package/stories/common.tsx +12 -6
- package/stories/emptystate.stories.tsx +1 -2
- package/stories/form.stories.tsx +1 -3
- package/stories/modal.stories.tsx +0 -2
- package/stories/tablev2.stories.tsx +131 -52
- package/stories/checkbox.stories.tsx +0 -63
|
@@ -101,6 +101,6 @@ function Toast({ open, message, onClose, position = 'top-right', status = 'info'
|
|
|
101
101
|
display: 'flex',
|
|
102
102
|
borderRadius: '4px',
|
|
103
103
|
position: 'relative',
|
|
104
|
-
}, children: [_jsx(IconContainer, { bgColor: rgbBgColor, children: icon }), _jsx(ContentContainer, { children: _jsx(BasicText, { children: message }) }), _jsx(Box, { display: "flex", alignItems: "center", alignSelf: "stretch", children: _jsx(Button, { icon: _jsx(Icon, { name: "Close", size: "lg", color: "textSecondary" }), onClick: params === null || params === void 0 ? void 0 : params.onClose, "aria-label": "Close" }) })] }, "toast"), withProgressBar && (_jsx(DurationBasedProgressBar, { duration: autoDismiss ? duration : null, color: bgColor }))] }));
|
|
104
|
+
}, children: [_jsx(IconContainer, { bgColor: rgbBgColor, children: icon }), _jsx(ContentContainer, { children: _jsx(BasicText, { children: message }) }), _jsx(Box, { display: "flex", alignItems: "center", alignSelf: "stretch", children: _jsx(Button, { icon: _jsx(Icon, { name: "Close", size: "lg", color: "textSecondary" }), onClick: params === null || params === void 0 ? void 0 : params.onClose, "aria-label": "Close", tooltip: { overlay: 'Close', placement: 'top' } }) })] }, "toast"), withProgressBar && (_jsx(DurationBasedProgressBar, { duration: autoDismiss ? duration : null, color: bgColor }))] }));
|
|
105
105
|
}
|
|
106
106
|
export { Toast };
|
|
@@ -34,7 +34,7 @@ type Props<MainMutationType, T extends any[]> = {
|
|
|
34
34
|
onAllMutationsSuccess?: () => void;
|
|
35
35
|
onMainMutationSuccess?: never;
|
|
36
36
|
});
|
|
37
|
-
type MinimalMutationResult<TData, TError> = Pick<UseMutationResult<TData, TError, unknown, unknown>, 'isError' | 'isIdle' | 'isSuccess' | 'isLoading' | 'error' | 'data'>;
|
|
37
|
+
export type MinimalMutationResult<TData, TError> = Pick<UseMutationResult<TData, TError, unknown, unknown>, 'isError' | 'isIdle' | 'isSuccess' | 'isLoading' | 'error' | 'data'>;
|
|
38
38
|
export declare const useMutationsHandler: <MainMutationType extends MinimalMutationResult<unknown, unknown>, T extends any[] | []>({ mainMutation, dependantMutations, messageDescriptionBuilder, toastProps, ...rest }: Props<MainMutationType, T>) => void;
|
|
39
39
|
export {};
|
|
40
40
|
//# sourceMappingURL=useMutationsHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutationsHandler.d.ts","sourceRoot":"","sources":["../../../src/lib/components/toast/useMutationsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0B,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAY,MAAM,iBAAiB,CAAC;AAE9D,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,CAAC,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,OAAO,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,cAAc,CACnD,qBAAqB,CAAC,MAAM,KAAK,EAAE,MAAM,MAAM,CAAC,CACjD,GACG,cAAc,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,GACpD,CAAC,SAAS,qBAAqB,CAAC,MAAM,KAAK,EAAE,MAAM,MAAM,CAAC,GAC1D,cAAc,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,GACpD,cAAc,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAE5D,OAAO,MAAM,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,cAAc,CAC9D,qBAAqB,CAAC,MAAM,KAAK,EAAE,MAAM,MAAM,CAAC,CACjD,GACG,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,GACjC,CAAC,SAAS,cAAc,CAAC,kBAAkB,CAA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C,EAAE,CAAC;IAC9D,yBAAyB,EAAE,CACzB,SAAS,EAAE,CAAC,SAAS,EAAE,GACnB,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,GACzC,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,KACrE,SAAS,CAAC;IACf,UAAU,CAAC,EAAE,IAAI,CACf,iBAAiB,EACjB,OAAO,GAAG,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,iBAAiB,CACtE,CAAC;CACH,GAAG,CACA;IAAE,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;IAAC,qBAAqB,CAAC,EAAE,KAAK,CAAA;CAAE,GACrE;IAAE,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;IAAC,qBAAqB,CAAC,EAAE,KAAK,CAAA;CAAE,CACxE,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,KAAK,EAAE,MAAM,IAAI,IAAI,CACrD,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAClD,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CACpE,CAAC;AAEF,eAAO,MAAM,mBAAmB,oNAgF/B,CAAC"}
|
|
@@ -12,14 +12,16 @@ export const useMutationsHandler = ({ mainMutation, dependantMutations, messageD
|
|
|
12
12
|
...(dependantMutations ? dependantMutations : []),
|
|
13
13
|
];
|
|
14
14
|
const handleMutationsCompletion = useCallback(async () => {
|
|
15
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16
16
|
const results = await Promise.all(mutations.map((m) => m.mutation));
|
|
17
17
|
const loadingMutations = mutations.filter((_, index) => results[index].isLoading);
|
|
18
18
|
const successMutations = mutations.filter((_, index) => results[index].isSuccess);
|
|
19
19
|
const errorMutations = mutations.filter((_, index) => results[index].isError);
|
|
20
20
|
const mainMutationDesc = {
|
|
21
21
|
data: (_a = mainMutation.mutation) === null || _a === void 0 ? void 0 : _a.data,
|
|
22
|
-
status:
|
|
22
|
+
status: ((_b = mainMutation.mutation) === null || _b === void 0 ? void 0 : _b.isSuccess)
|
|
23
|
+
? DescriptionBuilderStatus.Success
|
|
24
|
+
: DescriptionBuilderStatus.Error,
|
|
23
25
|
name: mainMutation.name,
|
|
24
26
|
};
|
|
25
27
|
const descriptionBuilders = [
|
|
@@ -35,8 +37,8 @@ export const useMutationsHandler = ({ mainMutation, dependantMutations, messageD
|
|
|
35
37
|
];
|
|
36
38
|
if (loadingMutations.length === 0) {
|
|
37
39
|
if (errorMutations.length > 0) {
|
|
38
|
-
if ((
|
|
39
|
-
'onMainMutationSuccess' in rest && ((
|
|
40
|
+
if ((_c = mainMutation.mutation) === null || _c === void 0 ? void 0 : _c.isSuccess) {
|
|
41
|
+
'onMainMutationSuccess' in rest && ((_d = rest === null || rest === void 0 ? void 0 : rest.onMainMutationSuccess) === null || _d === void 0 ? void 0 : _d.call(rest));
|
|
40
42
|
}
|
|
41
43
|
showToast({
|
|
42
44
|
open: true,
|
|
@@ -47,9 +49,9 @@ export const useMutationsHandler = ({ mainMutation, dependantMutations, messageD
|
|
|
47
49
|
return;
|
|
48
50
|
}
|
|
49
51
|
else if (successMutations.length > 0) {
|
|
50
|
-
'onMainMutationSuccess' in rest && ((
|
|
52
|
+
'onMainMutationSuccess' in rest && ((_e = rest === null || rest === void 0 ? void 0 : rest.onMainMutationSuccess) === null || _e === void 0 ? void 0 : _e.call(rest));
|
|
51
53
|
if (successMutations.length === mutations.length) {
|
|
52
|
-
'onAllMutationsSuccess' in rest && ((
|
|
54
|
+
'onAllMutationsSuccess' in rest && ((_f = rest === null || rest === void 0 ? void 0 : rest.onAllMutationsSuccess) === null || _f === void 0 ? void 0 : _f.call(rest));
|
|
53
55
|
}
|
|
54
56
|
showToast({
|
|
55
57
|
open: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentConfirmationModal.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/attachments/AttachmentConfirmationModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAY,MAAM,OAAO,CAAC;AAGhD,OAAO,EAAe,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ1E,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,aAAa,EAAE,EACtE,oBAAoB,EACpB,4BAA4B,EAC5B,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,QAAQ,EACR,MAAM,GACP,EAAE;IACD,oBAAoB,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC;IACzD,4BAA4B,EAAE,MAAM,kBAAkB,CACpD,OAAO,EACP,OAAO,EACP;QACE,MAAM,EAAE,gBAAgB,CAAC;QACzB,IAAI,EAAE,WAAW,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;KACZ,CACF,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,aAAa,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CAAA;KAAE,CAAC,CAAC;IACjE,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,CACP,qBAAqB,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,EACzD,gBAAgB,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KACjD,IAAI,CAAC;CACX,
|
|
1
|
+
{"version":3,"file":"AttachmentConfirmationModal.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/attachments/AttachmentConfirmationModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAY,MAAM,OAAO,CAAC;AAGhD,OAAO,EAAe,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ1E,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,aAAa,EAAE,EACtE,oBAAoB,EACpB,4BAA4B,EAC5B,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,QAAQ,EACR,MAAM,GACP,EAAE;IACD,oBAAoB,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC;IACzD,4BAA4B,EAAE,MAAM,kBAAkB,CACpD,OAAO,EACP,OAAO,EACP;QACE,MAAM,EAAE,gBAAgB,CAAC;QACzB,IAAI,EAAE,WAAW,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;KACZ,CACF,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,aAAa,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CAAA;KAAE,CAAC,CAAC;IACjE,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,CACP,qBAAqB,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,EACzD,gBAAgB,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,KACjD,IAAI,CAAC;CACX,eAyQA"}
|
|
@@ -127,7 +127,7 @@ export function AttachmentConfirmationModal({ attachmentOperations, getAttachmen
|
|
|
127
127
|
},
|
|
128
128
|
},
|
|
129
129
|
];
|
|
130
|
-
return (_jsxs("div", { style: { height: '25rem', width: '50rem' }, children: [_jsx("div", { children: "The following entities will be attached or detached: " }), _jsxs(Box, { display: "flex", gap: 24, alignItems: "center", children: [_jsx(SecondaryText, { children: _jsx(EntityIcon, { type: resourceType }) }), _jsx("p", { children: resourceName })] }), _jsx(Table, { columns: columns, data: attachmentOperationsFlat, defaultSortingKey: 'entityName', children: _jsx(Table.SingleSelectableContent, { rowHeight: "h32", separationLineVariant: "backgroundLevel3",
|
|
130
|
+
return (_jsxs("div", { style: { height: '25rem', width: '50rem' }, children: [_jsx("div", { children: "The following entities will be attached or detached: " }), _jsxs(Box, { display: "flex", gap: 24, alignItems: "center", children: [_jsx(SecondaryText, { children: _jsx(EntityIcon, { type: resourceType }) }), _jsx("p", { children: resourceName })] }), _jsx(Table, { columns: columns, data: attachmentOperationsFlat, defaultSortingKey: 'entityName', children: _jsx(Table.SingleSelectableContent, { rowHeight: "h32", separationLineVariant: "backgroundLevel3", children: (Rows) => {
|
|
131
131
|
return _jsx(_Fragment, { children: Rows });
|
|
132
132
|
} }) })] }));
|
|
133
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentTable.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/attachments/AttachmentTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAef,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"AttachmentTable.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/attachments/AttachmentTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAef,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,eAAe,EAAE,MAAM,aAAa,CAAC;AAQxD,MAAM,MAAM,oBAAoB,CAAC,WAAW,IAAI;IAC9C,yBAAyB,EAAE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@@ -8,6 +8,7 @@ import { spacing, Stack, Wrap } from '../../spacing';
|
|
|
8
8
|
import { AttachmentAction, } from './AttachmentTypes';
|
|
9
9
|
import { useQuery } from 'react-query';
|
|
10
10
|
import { EmptyCell } from '../../components/tablev2/Tablev2.component';
|
|
11
|
+
import { tableRowHeight } from '../../components/tablev2/TableUtils';
|
|
11
12
|
const rowHeight = 'h48';
|
|
12
13
|
const MenuContainer = styled.ul `
|
|
13
14
|
background-color: ${(props) => props.theme.backgroundLevel1};
|
|
@@ -43,11 +44,7 @@ const MenuContainer = styled.ul `
|
|
|
43
44
|
}
|
|
44
45
|
`;
|
|
45
46
|
const SearchBoxContainer = styled.div `
|
|
46
|
-
|
|
47
|
-
width: 78%;
|
|
48
|
-
.sc-tooltip {
|
|
49
|
-
width: 100%;
|
|
50
|
-
}
|
|
47
|
+
padding: ${spacing.r16};
|
|
51
48
|
`;
|
|
52
49
|
const StyledSearchInput = styled(SearchInput) `
|
|
53
50
|
flex-grow: 1;
|
|
@@ -69,6 +66,7 @@ const StyledTable = styled.div `
|
|
|
69
66
|
const CenterredSecondaryText = styled(SecondaryText) `
|
|
70
67
|
display: block;
|
|
71
68
|
text-align: center;
|
|
69
|
+
line-height: ${tableRowHeight[rowHeight]}rem;
|
|
72
70
|
`;
|
|
73
71
|
const PrivateAttachmentContext = createContext(null);
|
|
74
72
|
const AttachmentContext = createContext(null);
|
|
@@ -264,10 +262,12 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
|
|
|
264
262
|
const [searchWidth, setSearchWidth] = useState('0px');
|
|
265
263
|
const [searchInputIsFocused, setSearchInputIsFocused] = useState(false);
|
|
266
264
|
return (_jsxs(AttachmentTableContainer, { children: [_jsx(SearchBoxContainer, { ref: (element) => {
|
|
267
|
-
if (element) {
|
|
268
|
-
setSearchWidth(element.getBoundingClientRect().width -
|
|
265
|
+
if (element === null || element === void 0 ? void 0 : element.firstElementChild) {
|
|
266
|
+
setSearchWidth(element.firstElementChild.getBoundingClientRect().width -
|
|
267
|
+
2 +
|
|
268
|
+
'px');
|
|
269
269
|
}
|
|
270
|
-
}, children: filteredEntities.status === 'error' ? (_jsx(Tooltip, { overlay: _jsx(_Fragment, { children: "We failed to load the entities, hence search is disabled" }), children: _jsxs(
|
|
270
|
+
}, children: filteredEntities.status === 'error' ? (_jsx(Tooltip, { overlay: _jsx(_Fragment, { children: "We failed to load the entities, hence search is disabled" }), children: _jsxs(Stack, { children: [_jsx(StyledSearchInput, { placeholder: searchEntityPlaceholder, ...getInputProps({
|
|
271
271
|
ref: (element) => {
|
|
272
272
|
if (element)
|
|
273
273
|
searchInputRef.current = element;
|
|
@@ -305,7 +305,7 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
|
|
|
305
305
|
filteredEntities.status === 'success' &&
|
|
306
306
|
((_k = filteredEntities.data) === null || _k === void 0 ? void 0 : _k.entities.length) === 0 && (_jsx("li", { children: _jsxs(Text, { isGentleEmphazed: true, color: "textSecondary", children: ["No ", entityName.plural, " found matching your search."] }) }))] }), _jsx(StyledTable, { children: _jsx(Table, { columns: [
|
|
307
307
|
{
|
|
308
|
-
Header:
|
|
308
|
+
Header: 'Name',
|
|
309
309
|
accessor: 'name',
|
|
310
310
|
cellStyle: {
|
|
311
311
|
flex: 1.5,
|
|
@@ -337,7 +337,7 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
|
|
|
337
337
|
},
|
|
338
338
|
},
|
|
339
339
|
{
|
|
340
|
-
Header:
|
|
340
|
+
Header: 'Attachment',
|
|
341
341
|
accessor: 'isPending',
|
|
342
342
|
cellStyle: {
|
|
343
343
|
flex: 0.5,
|
|
@@ -370,6 +370,9 @@ export const AttachmentTable = ({ initiallyAttachedEntities, initiallyAttachedEn
|
|
|
370
370
|
...entity,
|
|
371
371
|
isPending: entity.isPending || false,
|
|
372
372
|
action: null,
|
|
373
|
-
})), defaultSortingKey: "name", children: _jsx(Table.SingleSelectableContent, {
|
|
374
|
-
initiallyAttachedEntitiesStatus === 'loading' ? (_jsxs(Wrap, { children: [_jsx("p", {}), _jsxs(Stack, { children: [_jsx(Loader, {}), _jsxs(Text, { children: ["Loading ", entityName.plural, "..."] })] }), _jsx("p", {})] })) : initiallyAttachedEntitiesStatus === 'error' ? (_jsxs(
|
|
373
|
+
})), defaultSortingKey: "name", children: _jsx(Table.SingleSelectableContent, { rowHeight: rowHeight, separationLineVariant: "backgroundLevel2", children: (rows) => (_jsxs(_Fragment, { children: [initiallyAttachedEntitiesStatus === 'idle' ||
|
|
374
|
+
initiallyAttachedEntitiesStatus === 'loading' ? (_jsxs(Wrap, { style: { height: `${tableRowHeight[rowHeight]}rem` }, children: [_jsx("p", {}), _jsxs(Stack, { children: [_jsx(Loader, {}), _jsxs(Text, { children: ["Loading ", entityName.plural, "..."] })] }), _jsx("p", {})] })) : initiallyAttachedEntitiesStatus === 'error' ? (_jsxs(Stack, { style: {
|
|
375
|
+
justifyContent: 'center',
|
|
376
|
+
height: `${tableRowHeight[rowHeight]}rem`,
|
|
377
|
+
}, children: [_jsx(Icon, { name: "Exclamation-circle", color: "statusWarning" }), _jsxs(Text, { color: "textSecondary", children: ["Failed to load attached ", entityName.plural, "."] })] })) : (desiredAttachedEntities.length === 0 && (_jsxs(CenterredSecondaryText, { children: ["No ", entityName.plural, " attached"] }))), desiredAttachedEntities.length > 0 && rows] })) }) }) })] }));
|
|
375
378
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scality/core-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.123.0",
|
|
4
4
|
"description": "Scality common React component library",
|
|
5
5
|
"author": "Scality Engineering",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"storybook": "storybook dev -p 3000",
|
|
20
20
|
"build-storybook": "storybook build",
|
|
21
|
-
"storybook:deploy": "storybook-to-ghpages"
|
|
21
|
+
"storybook:deploy": "storybook-to-ghpages",
|
|
22
|
+
"preview": "jest-preview"
|
|
22
23
|
},
|
|
23
24
|
"keywords": [],
|
|
24
25
|
"browserslist": [
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
"identity-obj-proxy": "^3.0.0",
|
|
72
73
|
"jest": "^26.6.3",
|
|
73
74
|
"jest-canvas-mock": "^2.3.1",
|
|
75
|
+
"jest-preview": "^0.3.1",
|
|
74
76
|
"plop": "^2.4.0",
|
|
75
77
|
"regenerator-runtime": "^0.13.7",
|
|
76
78
|
"rimraf": "^3.0.0",
|
|
@@ -101,10 +103,10 @@
|
|
|
101
103
|
"@fortawesome/react-fontawesome": "^0.1.14",
|
|
102
104
|
"@js-temporal/polyfill": "^0.4.4",
|
|
103
105
|
"@storybook/preview-api": "^7.6.17",
|
|
106
|
+
"downshift": "^7.0.5",
|
|
104
107
|
"framer-motion": "^4.1.17",
|
|
105
108
|
"polished": "3.4.1",
|
|
106
109
|
"pretty-bytes": "^5.6.0",
|
|
107
|
-
"downshift": "^7.0.5",
|
|
108
110
|
"react": "^17.0.2",
|
|
109
111
|
"react-debounce-input": "3.2.2",
|
|
110
112
|
"react-dom": "^17.0.2",
|
|
@@ -3,6 +3,7 @@ import { HTMLProps } from 'react';
|
|
|
3
3
|
import { createContext } from 'react';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
5
|
import { FocusVisibleStyle } from '../buttonv2/Buttonv2.component';
|
|
6
|
+
import { hex2RGB } from '../../utils';
|
|
6
7
|
const CardContext = createContext(null);
|
|
7
8
|
type CardElementProps = {
|
|
8
9
|
children: React.ReactNode;
|
|
@@ -85,9 +86,10 @@ const StyledCard = styled.div<{
|
|
|
85
86
|
${StyledCardHeader} {
|
|
86
87
|
color: ${(props) => props.theme.textPrimary};
|
|
87
88
|
background: ${(props) =>
|
|
88
|
-
props.
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
props.colorStatus
|
|
90
|
+
? `rgba(${hex2RGB(props.theme[props.colorStatus]).join(',')}, 0.7)`
|
|
91
|
+
: props.theme[props.headerBackgroundColor]};
|
|
92
|
+
|
|
91
93
|
${(props) => props.disabled && 'opacity: 0.3;'}
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -140,9 +142,8 @@ function Card({
|
|
|
140
142
|
|
|
141
143
|
if (status) {
|
|
142
144
|
colorStatus =
|
|
143
|
-
status
|
|
144
|
-
|
|
145
|
-
: 'status' + status.replace(/^\w/, (c) => c.toUpperCase());
|
|
145
|
+
status != 'healthy' &&
|
|
146
|
+
'status' + status.replace(/^\w/, (c) => c.toUpperCase());
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
return (
|
|
@@ -5,7 +5,7 @@ import { spacing, Stack } from '../../spacing';
|
|
|
5
5
|
import { Text } from '../text/Text.component';
|
|
6
6
|
import { FocusVisibleStyle } from '../buttonv2/Buttonv2.component';
|
|
7
7
|
|
|
8
|
-
type Props = {
|
|
8
|
+
export type Props = {
|
|
9
9
|
label?: string;
|
|
10
10
|
value?: string;
|
|
11
11
|
checked?: boolean;
|
|
@@ -53,6 +53,8 @@ const StyledCheckbox = styled.label<{
|
|
|
53
53
|
color: ${(props) => props.theme.textPrimary};
|
|
54
54
|
vertical-align: middle;
|
|
55
55
|
-webkit-appearance: none;
|
|
56
|
+
-moz-appearance: none;
|
|
57
|
+
appearance: none;
|
|
56
58
|
background: none;
|
|
57
59
|
border: 0;
|
|
58
60
|
outline: 0;
|
|
@@ -4,17 +4,30 @@ import { spacing } from '../../spacing';
|
|
|
4
4
|
import { Button } from '../buttonv2/Buttonv2.component';
|
|
5
5
|
import { Icon, IconName } from '../icon/Icon.component';
|
|
6
6
|
import { LargeText } from '../text/Text.component';
|
|
7
|
+
import { CoreUITheme } from '../../style/theme';
|
|
7
8
|
type Props = {
|
|
8
|
-
|
|
9
|
+
listedResource: {
|
|
10
|
+
singular: string;
|
|
11
|
+
plural: string;
|
|
12
|
+
};
|
|
9
13
|
icon: IconName;
|
|
10
14
|
link?: string;
|
|
11
15
|
history?: Record<string, any>;
|
|
16
|
+
backgroundColor?: keyof CoreUITheme;
|
|
17
|
+
/**
|
|
18
|
+
* The resource to create before browsing the listed resource
|
|
19
|
+
* Only used when resource to create is different from listed resource
|
|
20
|
+
*/
|
|
21
|
+
resourceToCreate?: string;
|
|
12
22
|
};
|
|
13
|
-
const EmptystateContainer = styled.div
|
|
23
|
+
const EmptystateContainer = styled.div<{ backgroundColor?: keyof CoreUITheme }>`
|
|
14
24
|
${(props) => {
|
|
15
|
-
const
|
|
25
|
+
const { theme, backgroundColor } = props;
|
|
16
26
|
return css`
|
|
17
|
-
color: ${
|
|
27
|
+
color: ${theme.textSecondary};
|
|
28
|
+
background-color: ${backgroundColor
|
|
29
|
+
? theme[backgroundColor]
|
|
30
|
+
: 'transparent'};
|
|
18
31
|
`;
|
|
19
32
|
}}
|
|
20
33
|
display: flex;
|
|
@@ -33,25 +46,36 @@ export const ActionWrapper = styled.div`
|
|
|
33
46
|
`;
|
|
34
47
|
|
|
35
48
|
function EmptyState(props: Props) {
|
|
36
|
-
const {
|
|
49
|
+
const {
|
|
50
|
+
icon,
|
|
51
|
+
listedResource,
|
|
52
|
+
link,
|
|
53
|
+
history,
|
|
54
|
+
resourceToCreate,
|
|
55
|
+
backgroundColor,
|
|
56
|
+
} = props;
|
|
37
57
|
return (
|
|
38
|
-
<EmptystateContainer
|
|
58
|
+
<EmptystateContainer
|
|
59
|
+
className="sc-emptystate"
|
|
60
|
+
backgroundColor={backgroundColor}
|
|
61
|
+
>
|
|
39
62
|
<EmptyStateRow>
|
|
40
63
|
<Icon name={icon} color="infoPrimary" size="5x" withWrapper />
|
|
41
64
|
</EmptyStateRow>
|
|
42
65
|
<EmptyStateRow>
|
|
43
|
-
<LargeText>A list of {
|
|
66
|
+
<LargeText>{`A list of ${listedResource.plural} will appear here.`}</LargeText>
|
|
44
67
|
</EmptyStateRow>
|
|
45
68
|
<EmptyStateRow>
|
|
46
69
|
<LargeText>
|
|
47
|
-
|
|
48
|
-
|
|
70
|
+
{!resourceToCreate
|
|
71
|
+
? `There are no ${listedResource.plural} created yet, let's create your first ${listedResource.singular}.`
|
|
72
|
+
: `Before browsing your ${listedResource.plural}, create your first ${resourceToCreate}.`}
|
|
49
73
|
</LargeText>
|
|
50
74
|
</EmptyStateRow>
|
|
51
75
|
{history && (
|
|
52
76
|
<ActionWrapper>
|
|
53
77
|
<Button
|
|
54
|
-
label={`Create ${
|
|
78
|
+
label={`Create ${resourceToCreate || listedResource.singular}`}
|
|
55
79
|
icon={<Icon name="Create-add" />}
|
|
56
80
|
type="button"
|
|
57
81
|
variant="primary"
|
|
@@ -6,7 +6,7 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import styled, { css } from 'styled-components';
|
|
9
|
-
import {
|
|
9
|
+
import { CoreUITheme } from '../../style/theme';
|
|
10
10
|
|
|
11
11
|
import { Loader } from '../loader/Loader.component';
|
|
12
12
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
@@ -142,7 +142,7 @@ const IconStyled = styled(FontAwesomeIcon)`
|
|
|
142
142
|
`;
|
|
143
143
|
|
|
144
144
|
export type IconName = keyof typeof iconTable;
|
|
145
|
-
export type IconColor = keyof
|
|
145
|
+
export type IconColor = keyof CoreUITheme;
|
|
146
146
|
type Props = {
|
|
147
147
|
name: IconName;
|
|
148
148
|
size?: SizeProp;
|
|
@@ -1,39 +1,45 @@
|
|
|
1
|
-
import { DefaultTheme, useTheme } from
|
|
2
|
-
import { hex2RGB } from
|
|
3
|
-
import { useEffect, useRef, useState } from
|
|
1
|
+
import { DefaultTheme, useTheme } from 'styled-components';
|
|
2
|
+
import { hex2RGB } from '../../utils';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
export const useComputeBackgroundColor = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
8
|
+
const [backgroundColor, setBackgroundColor] = useState('');
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
containerRef.current &&
|
|
12
|
+
setBackgroundColor(getBackgroundColor(containerRef.current, theme));
|
|
13
|
+
}, [containerRef, theme]);
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
containerRef,
|
|
17
|
+
backgroundColor,
|
|
19
18
|
};
|
|
19
|
+
};
|
|
20
20
|
|
|
21
|
-
export const getBackgroundColor = (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
export const getBackgroundColor = (
|
|
22
|
+
element: HTMLElement,
|
|
23
|
+
theme: DefaultTheme,
|
|
24
|
+
) => {
|
|
25
|
+
if (element.parentElement) {
|
|
26
|
+
const parentElementBackgroundColor = window.getComputedStyle(
|
|
27
|
+
element.parentElement,
|
|
28
|
+
)['background-color'];
|
|
29
|
+
if (
|
|
30
|
+
/rgba\([0-9]+, [0-9]+, [0-9]+, 0\)/.test(parentElementBackgroundColor) ||
|
|
31
|
+
!window.getComputedStyle(element.parentElement)['background-color']
|
|
32
|
+
) {
|
|
33
|
+
return getBackgroundColor(element.parentElement, theme);
|
|
34
|
+
} else {
|
|
35
|
+
const rgbArray = hex2RGB(theme.backgroundLevel2);
|
|
36
|
+
if (
|
|
37
|
+
`rgb(${rgbArray[0]}, ${rgbArray[1]}, ${rgbArray[2]})` ===
|
|
38
|
+
parentElementBackgroundColor
|
|
39
|
+
) {
|
|
40
|
+
return theme.backgroundLevel3;
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
}
|
|
44
|
+
return theme.backgroundLevel2;
|
|
45
|
+
};
|
|
@@ -53,7 +53,7 @@ const OverallSummaryContainer = styled.div<{
|
|
|
53
53
|
background?: ThemeColors;
|
|
54
54
|
}>`
|
|
55
55
|
background: ${(props) => props.theme[props.background || 'backgroundLevel2']};
|
|
56
|
-
height: 6rem;
|
|
56
|
+
min-height: 6rem;
|
|
57
57
|
padding: ${({ noPadding }) => (noPadding ? '0' : '0 1rem')};
|
|
58
58
|
margin-bottom: ${({ noBottomMargin }) =>
|
|
59
59
|
noBottomMargin ? '0' : sectionDistance};
|
|
@@ -24,7 +24,7 @@ export type OptionProps = {
|
|
|
24
24
|
icon?: React.ReactNode;
|
|
25
25
|
children?: React.ReactNode;
|
|
26
26
|
value: string;
|
|
27
|
-
disabledReason?:
|
|
27
|
+
disabledReason?: React.ReactNode;
|
|
28
28
|
};
|
|
29
29
|
const usePreviousValue = (value) => {
|
|
30
30
|
const ref = useRef(null);
|
|
@@ -79,12 +79,7 @@ export function Option({
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const Input = (props) => {
|
|
82
|
-
|
|
83
|
-
role: props.selectProps.isSearchable ? 'combobox' : 'listbox',
|
|
84
|
-
'aria-expanded': props.selectProps.menuIsOpen,
|
|
85
|
-
'aria-autocomplete': 'list',
|
|
86
|
-
};
|
|
87
|
-
return <components.Input {...props} {...ariaProps} />;
|
|
82
|
+
return <components.Input {...props} />;
|
|
88
83
|
};
|
|
89
84
|
|
|
90
85
|
const selectDropdownIndicator = (
|
|
@@ -285,8 +280,17 @@ const MenuList = (props) => {
|
|
|
285
280
|
const ValueContainer = ({ children, ...props }) => {
|
|
286
281
|
const selectedOption = props.selectProps.selectedOption;
|
|
287
282
|
const icon = selectedOption ? selectedOption.icon : null;
|
|
283
|
+
const ariaProps = {
|
|
284
|
+
innerProps: {
|
|
285
|
+
role: props.selectProps.isSearchable ? 'combobox' : 'listbox',
|
|
286
|
+
'aria-expanded': props.selectProps.menuIsOpen,
|
|
287
|
+
'aria-autocomplete': 'list',
|
|
288
|
+
'aria-label': props.selectProps.placeholder,
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
|
|
288
292
|
return (
|
|
289
|
-
<components.ValueContainer {...props}>
|
|
293
|
+
<components.ValueContainer {...props} {...ariaProps}>
|
|
290
294
|
{icon ? <div className="value-container-icon">{icon}</div> : null}
|
|
291
295
|
<div>{children}</div>
|
|
292
296
|
</components.ValueContainer>
|