synapse-react-client 3.1.18 → 3.1.19
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/containers/CopyToClipboardString.d.ts +11 -0
- package/dist/containers/CopyToClipboardString.js +30 -0
- package/dist/containers/CopyToClipboardString.js.map +1 -0
- package/dist/containers/FilePreview/HtmlPreview/HtmlPreview.js +2 -2
- package/dist/containers/FilePreview/HtmlPreview/HtmlPreview.js.map +1 -1
- package/dist/containers/FullWidthAlert.d.ts +1 -1
- package/dist/containers/TermsAndConditions.d.ts +1 -0
- package/dist/containers/TermsAndConditions.js +12 -6
- package/dist/containers/TermsAndConditions.js.map +1 -1
- package/dist/containers/access_requirements/AddConditionsForUseButton.d.ts +6 -0
- package/dist/containers/access_requirements/AddConditionsForUseButton.js +41 -0
- package/dist/containers/access_requirements/AddConditionsForUseButton.js.map +1 -0
- package/dist/containers/access_requirements/ImposeRestrictionDialog.d.ts +7 -0
- package/dist/containers/access_requirements/ImposeRestrictionDialog.js +67 -0
- package/dist/containers/access_requirements/ImposeRestrictionDialog.js.map +1 -0
- package/dist/containers/entity/metadata/MetadataTable.js +8 -11
- package/dist/containers/entity/metadata/MetadataTable.js.map +1 -1
- package/dist/containers/entity/page/title_bar/EntityPageTitleBar.d.ts +13 -0
- package/dist/containers/entity/page/title_bar/EntityPageTitleBar.js +51 -0
- package/dist/containers/entity/page/title_bar/EntityPageTitleBar.js.map +1 -0
- package/dist/containers/entity/page/title_bar/EntityTitleBarVersionInfo.d.ts +16 -0
- package/dist/containers/entity/page/title_bar/EntityTitleBarVersionInfo.js +64 -0
- package/dist/containers/entity/page/title_bar/EntityTitleBarVersionInfo.js.map +1 -0
- package/dist/containers/entity/page/title_bar/TitleBarProperties.d.ts +10 -0
- package/dist/containers/entity/page/title_bar/TitleBarProperties.js +58 -0
- package/dist/containers/entity/page/title_bar/TitleBarProperties.js.map +1 -0
- package/dist/containers/entity/page/title_bar/useGetEntityTitleBarProperties.d.ts +13 -0
- package/dist/containers/entity/page/title_bar/useGetEntityTitleBarProperties.js +136 -0
- package/dist/containers/entity/page/title_bar/useGetEntityTitleBarProperties.js.map +1 -0
- package/dist/containers/favorites/FavoriteButton.d.ts +9 -0
- package/dist/containers/favorites/FavoriteButton.js +42 -0
- package/dist/containers/favorites/FavoriteButton.js.map +1 -0
- package/dist/containers/utils/ConditionalWrapper.d.ts +9 -0
- package/dist/containers/utils/ConditionalWrapper.js +10 -0
- package/dist/containers/utils/ConditionalWrapper.js.map +1 -0
- package/dist/containers/widgets/RadioGroup.d.ts +6 -6
- package/dist/containers/widgets/RadioGroup.js +6 -6
- package/dist/containers/widgets/RadioGroup.js.map +1 -1
- package/dist/umd/synapse-react-client.development.js +8930 -7896
- package/dist/umd/synapse-react-client.development.js.map +4 -4
- package/dist/umd/synapse-react-client.production.min.js +74 -74
- package/dist/umd.index.d.ts +2 -0
- package/dist/umd.index.js +2 -0
- package/dist/umd.index.js.map +1 -1
- package/dist/utils/APIConstants.d.ts +2 -0
- package/dist/utils/APIConstants.js +3 -1
- package/dist/utils/APIConstants.js.map +1 -1
- package/dist/utils/SynapseClient.d.ts +22 -1
- package/dist/utils/SynapseClient.js +36 -1
- package/dist/utils/SynapseClient.js.map +1 -1
- package/dist/utils/functions/FileHandleUtils.d.ts +25 -2
- package/dist/utils/functions/FileHandleUtils.js +95 -5
- package/dist/utils/functions/FileHandleUtils.js.map +1 -1
- package/dist/utils/hooks/SynapseAPI/doi/useDOI.d.ts +4 -0
- package/dist/utils/hooks/SynapseAPI/doi/useDOI.js +15 -0
- package/dist/utils/hooks/SynapseAPI/doi/useDOI.js.map +1 -0
- package/dist/utils/hooks/SynapseAPI/file/useUploadDestination.d.ts +4 -0
- package/dist/utils/hooks/SynapseAPI/file/useUploadDestination.js +13 -0
- package/dist/utils/hooks/SynapseAPI/file/useUploadDestination.js.map +1 -0
- package/dist/utils/synapseTypes/File/UploadDestination.d.ts +102 -0
- package/dist/utils/synapseTypes/File/UploadDestination.js +21 -0
- package/dist/utils/synapseTypes/File/UploadDestination.js.map +1 -0
- package/package.json +1 -1
- package/dist/containers/FilePreview/HtmlPreview/SanitizedWarning.d.ts +0 -5
- package/dist/containers/FilePreview/HtmlPreview/SanitizedWarning.js +0 -28
- package/dist/containers/FilePreview/HtmlPreview/SanitizedWarning.js.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type EntityProperty = {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
value: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* This hook fetches all the entity metadata shown on the Entity page, and transforms the data into an ordered list of
|
|
9
|
+
* render-able key-value pairs.
|
|
10
|
+
* @param entityId
|
|
11
|
+
* @param versionNumber
|
|
12
|
+
*/
|
|
13
|
+
export declare function useGetEntityTitleBarProperties(entityId: string, versionNumber?: number): EntityProperty[];
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGetEntityTitleBarProperties = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
var SynapseAPI_1 = require("../../../../utils/hooks/SynapseAPI");
|
|
7
|
+
var synapseTypes_1 = require("../../../../utils/synapseTypes");
|
|
8
|
+
var EntityTypeUtils_1 = require("../../../../utils/functions/EntityTypeUtils");
|
|
9
|
+
var useUploadDestination_1 = require("../../../../utils/hooks/SynapseAPI/file/useUploadDestination");
|
|
10
|
+
var FileHandleUtils_1 = require("../../../../utils/functions/FileHandleUtils");
|
|
11
|
+
var calculateFriendlyFileSize_1 = require("../../../../utils/functions/calculateFriendlyFileSize");
|
|
12
|
+
var material_1 = require("@mui/material");
|
|
13
|
+
var HasAccessV2_1 = require("../../../access_requirements/HasAccessV2");
|
|
14
|
+
var CopyToClipboardString_1 = tslib_1.__importDefault(require("../../../CopyToClipboardString"));
|
|
15
|
+
var useDOI_1 = require("../../../../utils/hooks/SynapseAPI/doi/useDOI");
|
|
16
|
+
/**
|
|
17
|
+
* This hook fetches all the entity metadata shown on the Entity page, and transforms the data into an ordered list of
|
|
18
|
+
* render-able key-value pairs.
|
|
19
|
+
* @param entityId
|
|
20
|
+
* @param versionNumber
|
|
21
|
+
*/
|
|
22
|
+
function useGetEntityTitleBarProperties(entityId, versionNumber) {
|
|
23
|
+
var _a;
|
|
24
|
+
var bundle = (0, SynapseAPI_1.useGetEntityBundle)(entityId, versionNumber).data;
|
|
25
|
+
var entityChildrenResponse = (0, SynapseAPI_1.useGetEntityChildren)({
|
|
26
|
+
parentId: entityId,
|
|
27
|
+
includeTypes: Object.values(synapseTypes_1.EntityType),
|
|
28
|
+
includeTotalChildCount: true,
|
|
29
|
+
}, { enabled: !!((bundle === null || bundle === void 0 ? void 0 : bundle.entityType) && (0, EntityTypeUtils_1.isContainerType)(bundle.entityType)) }).data;
|
|
30
|
+
var uploadDestination = (0, useUploadDestination_1.useGetDefaultUploadDestination)(entityId, {
|
|
31
|
+
enabled: !!((bundle === null || bundle === void 0 ? void 0 : bundle.entityType) && (0, EntityTypeUtils_1.isContainerType)(bundle.entityType)),
|
|
32
|
+
}).data;
|
|
33
|
+
// If this is the latest entity version, show the "versionless" DOI if it exists.
|
|
34
|
+
var useFallbackVersionlessDOI = bundle &&
|
|
35
|
+
!bundle.doiAssociation &&
|
|
36
|
+
(0, EntityTypeUtils_1.isVersionableEntity)(bundle.entity) &&
|
|
37
|
+
bundle.entity.isLatestVersion;
|
|
38
|
+
var versionlessDOIAssociation = (0, useDOI_1.useGetDOIAssociation)(entityId, undefined, 'ENTITY', {
|
|
39
|
+
enabled: useFallbackVersionlessDOI,
|
|
40
|
+
}).data;
|
|
41
|
+
var dataFileHandle = bundle && (0, FileHandleUtils_1.getDataFileHandle)(bundle);
|
|
42
|
+
var size = (dataFileHandle === null || dataFileHandle === void 0 ? void 0 : dataFileHandle.contentSize) &&
|
|
43
|
+
(0, calculateFriendlyFileSize_1.calculateFriendlyFileSize)(dataFileHandle.contentSize);
|
|
44
|
+
var fileHandleStorageInfo = dataFileHandle && (0, FileHandleUtils_1.getFileHandleStorageInfo)(dataFileHandle);
|
|
45
|
+
var storageLocation = fileHandleStorageInfo &&
|
|
46
|
+
'location' in fileHandleStorageInfo &&
|
|
47
|
+
fileHandleStorageInfo.location;
|
|
48
|
+
var endpoint = fileHandleStorageInfo &&
|
|
49
|
+
'endpoint' in fileHandleStorageInfo &&
|
|
50
|
+
fileHandleStorageInfo.endpoint;
|
|
51
|
+
var bucket = fileHandleStorageInfo &&
|
|
52
|
+
'bucket' in fileHandleStorageInfo &&
|
|
53
|
+
fileHandleStorageInfo.bucket;
|
|
54
|
+
var fileKey = fileHandleStorageInfo &&
|
|
55
|
+
'fileKey' in fileHandleStorageInfo &&
|
|
56
|
+
fileHandleStorageInfo.fileKey;
|
|
57
|
+
var externalUrl = fileHandleStorageInfo &&
|
|
58
|
+
'url' in fileHandleStorageInfo &&
|
|
59
|
+
fileHandleStorageInfo.url;
|
|
60
|
+
var md5 = dataFileHandle === null || dataFileHandle === void 0 ? void 0 : dataFileHandle.contentMd5;
|
|
61
|
+
var downloadAlias = (bundle === null || bundle === void 0 ? void 0 : bundle.entity.name) != (bundle === null || bundle === void 0 ? void 0 : bundle.fileName) && (bundle === null || bundle === void 0 ? void 0 : bundle.fileName);
|
|
62
|
+
var uploadDestinationString = uploadDestination && (0, FileHandleUtils_1.getUploadDestinationString)(uploadDestination);
|
|
63
|
+
// If there is no version-specific DOI, fall back to the versionless DOI
|
|
64
|
+
var doiAssociation = useFallbackVersionlessDOI
|
|
65
|
+
? versionlessDOIAssociation
|
|
66
|
+
: bundle === null || bundle === void 0 ? void 0 : bundle.doiAssociation;
|
|
67
|
+
var doi = doiAssociation && "https://doi.org/".concat(doiAssociation === null || doiAssociation === void 0 ? void 0 : doiAssociation.doiUri);
|
|
68
|
+
var containerItems = entityChildrenResponse === null || entityChildrenResponse === void 0 ? void 0 : entityChildrenResponse.totalChildCount;
|
|
69
|
+
var datasetItems = (bundle === null || bundle === void 0 ? void 0 : bundle.entity) && (0, EntityTypeUtils_1.isEntityRefCollectionView)(bundle.entity)
|
|
70
|
+
? ((_a = (bundle === null || bundle === void 0 ? void 0 : bundle.entity).items) !== null && _a !== void 0 ? _a : []).length
|
|
71
|
+
: null;
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
key: 'id',
|
|
75
|
+
title: 'SynID',
|
|
76
|
+
value: react_1.default.createElement(CopyToClipboardString_1.default, { value: entityId }),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: 'access',
|
|
80
|
+
title: 'Access',
|
|
81
|
+
value: react_1.default.createElement(HasAccessV2_1.HasAccessV2, { entityId: entityId }),
|
|
82
|
+
},
|
|
83
|
+
size && { key: 'fileSize', title: 'Size', value: size },
|
|
84
|
+
containerItems != null && {
|
|
85
|
+
key: 'containerItems',
|
|
86
|
+
title: 'Items',
|
|
87
|
+
value: containerItems.toLocaleString(),
|
|
88
|
+
},
|
|
89
|
+
datasetItems != null && {
|
|
90
|
+
key: 'entityRefCollectionItems',
|
|
91
|
+
title: 'Items',
|
|
92
|
+
value: datasetItems.toLocaleString(),
|
|
93
|
+
},
|
|
94
|
+
doi && {
|
|
95
|
+
key: 'doi',
|
|
96
|
+
title: 'DOI',
|
|
97
|
+
value: (react_1.default.createElement(material_1.Link, { href: doi, rel: 'noopener noreferrer', target: '_blank' }, doi)),
|
|
98
|
+
},
|
|
99
|
+
md5 && {
|
|
100
|
+
key: 'fileMd5',
|
|
101
|
+
title: 'MD5',
|
|
102
|
+
value: react_1.default.createElement(CopyToClipboardString_1.default, { value: md5 }),
|
|
103
|
+
},
|
|
104
|
+
storageLocation && {
|
|
105
|
+
key: 'fileStorageLocation',
|
|
106
|
+
title: 'Storage Location',
|
|
107
|
+
value: storageLocation,
|
|
108
|
+
},
|
|
109
|
+
uploadDestinationString && {
|
|
110
|
+
key: 'uploadDestination',
|
|
111
|
+
title: 'Storage Location',
|
|
112
|
+
value: uploadDestinationString,
|
|
113
|
+
},
|
|
114
|
+
endpoint && {
|
|
115
|
+
key: 'externalFileEndpoint',
|
|
116
|
+
title: 'Endpoint',
|
|
117
|
+
value: endpoint,
|
|
118
|
+
},
|
|
119
|
+
externalUrl && {
|
|
120
|
+
key: 'externalUrl',
|
|
121
|
+
title: 'URL',
|
|
122
|
+
value: externalUrl,
|
|
123
|
+
},
|
|
124
|
+
bucket && { key: 'externalFileBucket', title: 'Bucket', value: bucket },
|
|
125
|
+
fileKey && { key: 'externalFileKey', title: 'File Key', value: fileKey },
|
|
126
|
+
downloadAlias && {
|
|
127
|
+
key: 'fileAlias',
|
|
128
|
+
title: 'Alias',
|
|
129
|
+
value: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
130
|
+
'Name when downloaded will be: ',
|
|
131
|
+
react_1.default.createElement(material_1.Box, { sx: { display: 'inline', fontFamily: 'monospace' } }, downloadAlias))),
|
|
132
|
+
},
|
|
133
|
+
].filter(function (item) { return !!item; });
|
|
134
|
+
}
|
|
135
|
+
exports.useGetEntityTitleBarProperties = useGetEntityTitleBarProperties;
|
|
136
|
+
//# sourceMappingURL=useGetEntityTitleBarProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetEntityTitleBarProperties.js","sourceRoot":"","sources":["../../../../../src/lib/containers/entity/page/title_bar/useGetEntityTitleBarProperties.tsx"],"names":[],"mappings":";;;;AAAA,wDAAyB;AACzB,iEAG2C;AAC3C,+DAGuC;AACvC,+EAIoD;AACpD,qGAA6G;AAC7G,+EAIoD;AACpD,mGAAiG;AACjG,0CAAyC;AACzC,wEAAsE;AACtE,iGAAkE;AAClE,wEAAoF;AAQpF;;;;;GAKG;AACH,SAAgB,8BAA8B,CAC5C,QAAgB,EAChB,aAAsB;;IAEd,IAAM,MAAM,GAAK,I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D,uBAAuB,IAAI;YACzB,GAAG,EAAE,mBAAmB;YACxB,KAAK,EAAE,kBAAkB;YACzB,KAAK,EAAE,uBAAuB;SAC/B;QACD,QAAQ,IAAI;YACV,GAAG,EAAE,sBAAsB;YAC3B,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,QAAQ;SAChB;QACD,WAAW,IAAI;YACb,GAAG,EAAE,aAAa;YAClB,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,WAAW;SACnB;QACD,MAAM,IAAI,EAAE,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE;QACvE,OAAO,IAAI,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE;QACxE,aAAa,IAAI;YACf,GAAG,EAAE,WAAW;YAChB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,CACL;gBACG,gCAAgC;gBACjC,8BAAC,cAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,IACpD,aAAa,CACV,CACL,CACJ;SACF;KACF,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,IAAI,EAAN,CAAM,CAAqB,CAAA;AAC9C,CAAC;AAzJD,wEAyJC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type FavoriteButtonProps = {
|
|
3
|
+
entityId: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Renders a button that indicates if an entity is favorited by the logged-in user. When clicked, the entity is
|
|
7
|
+
* added to/removed from their favorites
|
|
8
|
+
*/
|
|
9
|
+
export default function FavoriteButton(props: FavoriteButtonProps): JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
var IconSvg_1 = tslib_1.__importDefault(require("../IconSvg"));
|
|
6
|
+
var material_1 = require("@mui/material");
|
|
7
|
+
var SynapseAPI_1 = require("../../utils/hooks/SynapseAPI");
|
|
8
|
+
var SynapseContext_1 = require("../../utils/SynapseContext");
|
|
9
|
+
var ConditionalWrapper_1 = tslib_1.__importDefault(require("../utils/ConditionalWrapper"));
|
|
10
|
+
/**
|
|
11
|
+
* Renders a button that indicates if an entity is favorited by the logged-in user. When clicked, the entity is
|
|
12
|
+
* added to/removed from their favorites
|
|
13
|
+
*/
|
|
14
|
+
function FavoriteButton(props) {
|
|
15
|
+
var entityId = props.entityId;
|
|
16
|
+
var accessToken = (0, SynapseContext_1.useSynapseContext)().accessToken;
|
|
17
|
+
var isSignedIn = !!accessToken;
|
|
18
|
+
var _a = (0, SynapseAPI_1.useIsFavorite)(entityId), isFavorite = _a.isFavorite, isLoading = _a.isLoading;
|
|
19
|
+
var _b = (0, SynapseAPI_1.useAddFavorite)(), onAddFavorite = _b.mutate, isAddingFavorite = _b.isLoading;
|
|
20
|
+
var _c = (0, SynapseAPI_1.useRemoveFavorite)(), onRemoveFavorite = _c.mutate, isRemovingFavorite = _c.isLoading;
|
|
21
|
+
var disableButton = isLoading || isAddingFavorite || isRemovingFavorite || !isSignedIn;
|
|
22
|
+
var tooltipText = 'Add to Favorites';
|
|
23
|
+
if (!isSignedIn) {
|
|
24
|
+
tooltipText = 'Sign in to add this to your favorites';
|
|
25
|
+
}
|
|
26
|
+
else if (isFavorite) {
|
|
27
|
+
tooltipText = 'Remove from Favorites';
|
|
28
|
+
}
|
|
29
|
+
return (react_1.default.createElement(ConditionalWrapper_1.default, { condition: isLoading, wrapper: material_1.Skeleton },
|
|
30
|
+
react_1.default.createElement(material_1.Tooltip, { title: tooltipText, placement: 'top' },
|
|
31
|
+
react_1.default.createElement("span", null,
|
|
32
|
+
react_1.default.createElement(material_1.IconButton, { size: 'small', disabled: disableButton, onClick: function () {
|
|
33
|
+
isFavorite ? onRemoveFavorite(entityId) : onAddFavorite(entityId);
|
|
34
|
+
}, sx: { padding: '2px' } },
|
|
35
|
+
react_1.default.createElement(IconSvg_1.default, { icon: isFavorite ? 'fav' : 'favOutline', sx: {
|
|
36
|
+
color: 'tertiary.main',
|
|
37
|
+
width: '21px',
|
|
38
|
+
height: '21px',
|
|
39
|
+
}, wrap: false }))))));
|
|
40
|
+
}
|
|
41
|
+
exports.default = FavoriteButton;
|
|
42
|
+
//# sourceMappingURL=FavoriteButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FavoriteButton.js","sourceRoot":"","sources":["../../../src/lib/containers/favorites/FavoriteButton.tsx"],"names":[],"mappings":";;;AAAA,wDAAyB;AACzB,+DAAgC;AAChC,0CAA6D;AAC7D,2DAIqC;AACrC,6DAA8D;AAC9D,2FAA4D;AAO5D;;;GAGG;AACH,SAAwB,cAAc,CAAC,KAA0B;IACvD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAU;IAClB,IAAA,WAAW,GAAK,IAAA,kCAAiB,GAAE,YAAxB,CAAwB;IAC3C,IAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAA;IAC1B,IAAA,KAA4B,IAAA,0BAAa,EAAC,QAAQ,CAAC,EAAjD,UAAU,gBAAA,EAAE,SAAS,eAA4B,CAAA;IACnD,IAAA,KACJ,IAAA,2BAAc,GAAE,EADF,aAAa,YAAA,EAAa,gBAAgB,eACxC,CAAA;IACZ,IAAA,KACJ,IAAA,8BAAiB,GAAE,EADL,gBAAgB,YAAA,EAAa,kBAAkB,eAC1C,CAAA;IAErB,IAAM,aAAa,GACjB,SAAS,IAAI,gBAAgB,IAAI,kBAAkB,IAAI,CAAC,UAAU,CAAA;IAEpE,IAAI,WAAW,GAAG,kBAAkB,CAAA;IACpC,IAAI,CAAC,UAAU,EAAE;QACf,WAAW,GAAG,uCAAuC,CAAA;KACtD;SAAM,IAAI,UAAU,EAAE;QACrB,WAAW,GAAG,uBAAuB,CAAA;KACtC;IACD,OAAO,CACL,8BAAC,4BAAkB,IAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAQ;QACzD,8BAAC,kBAAO,IAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK;YAC3C;gBACE,8BAAC,qBAAU,IACT,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE;wBACP,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;oBACnE,CAAC,EACD,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;oBAEtB,8BAAC,iBAAO,IACN,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,EACvC,EAAE,EAAE;4BACF,KAAK,EAAE,eAAe;4BACtB,KAAK,EAAE,MAAM;4BACb,MAAM,EAAE,MAAM;yBACf,EACD,IAAI,EAAE,KAAK,GACX,CACS,CACR,CACC,CACS,CACtB,CAAA;AACH,CAAC;AA7CD,iCA6CC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type ConditionalWrapperProps<TWrapper extends React.ComponentType<React.PropsWithChildren> = React.ComponentType<React.PropsWithChildren>> = {
|
|
3
|
+
condition: boolean;
|
|
4
|
+
wrapper: TWrapper;
|
|
5
|
+
wrapperProps?: Omit<React.ComponentProps<TWrapper>, 'children'>;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export default function ConditionalWrapper(props: ConditionalWrapperProps): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
function ConditionalWrapper(props) {
|
|
6
|
+
var condition = props.condition, Wrapper = props.wrapper, wrapperProps = props.wrapperProps, children = props.children;
|
|
7
|
+
return condition ? (react_1.default.createElement(Wrapper, tslib_1.__assign({}, wrapperProps), children)) : (react_1.default.createElement(react_1.default.Fragment, null, children));
|
|
8
|
+
}
|
|
9
|
+
exports.default = ConditionalWrapper;
|
|
10
|
+
//# sourceMappingURL=ConditionalWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionalWrapper.js","sourceRoot":"","sources":["../../../src/lib/containers/utils/ConditionalWrapper.tsx"],"names":[],"mappings":";;;AAAA,wDAAyB;AAWzB,SAAwB,kBAAkB,CAAC,KAA8B;IAC/D,IAAA,SAAS,GAA+C,KAAK,UAApD,EAAW,OAAO,GAA6B,KAAK,QAAlC,EAAE,YAAY,GAAe,KAAK,aAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAU;IAErE,OAAO,SAAS,CAAC,CAAC,CAAC,CACjB,8BAAC,OAAO,uBAAK,YAAY,GAAG,QAAQ,CAAW,CAChD,CAAC,CAAC,CAAC,CACF,8DAAG,QAAQ,CAAI,CAChB,CAAA;AACH,CAAC;AARD,qCAQC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type RadioGroupProps = {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type RadioGroupProps<T extends string | boolean | number = string> = {
|
|
3
3
|
options: {
|
|
4
4
|
label: string;
|
|
5
|
-
value:
|
|
5
|
+
value: T;
|
|
6
6
|
}[];
|
|
7
7
|
id: string;
|
|
8
8
|
className?: string;
|
|
9
|
-
value?:
|
|
10
|
-
onChange: (value:
|
|
9
|
+
value?: T;
|
|
10
|
+
onChange: (value: T) => void;
|
|
11
11
|
};
|
|
12
|
-
export declare
|
|
12
|
+
export declare function RadioGroup<T extends string | boolean | number = string>(props: RadioGroupProps<T>): JSX.Element;
|
|
@@ -4,19 +4,19 @@ exports.RadioGroup = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
var lodash_es_1 = require("lodash-es");
|
|
7
|
-
|
|
7
|
+
function RadioGroup(props) {
|
|
8
8
|
var className = props.className
|
|
9
9
|
? "radiogroup ".concat(props.className)
|
|
10
10
|
: "radiogroup";
|
|
11
|
-
return (react_1.default.createElement("div", { className: className, role: "radiogroup" }, props.options.map(function (option) { return (react_1.default.createElement(RadioOption, {
|
|
12
|
-
}
|
|
11
|
+
return (react_1.default.createElement("div", { className: className, role: "radiogroup" }, props.options.map(function (option, index) { return (react_1.default.createElement(RadioOption, { key: index.toString(), groupId: props.id, label: option.label, value: option.value, currentValue: props.value, onChange: props.onChange })); })));
|
|
12
|
+
}
|
|
13
13
|
exports.RadioGroup = RadioGroup;
|
|
14
|
-
|
|
14
|
+
function RadioOption(props) {
|
|
15
15
|
var uniqueId = (0, react_1.useState)((0, lodash_es_1.uniqueId)('src-radio-'))[0];
|
|
16
16
|
return (react_1.default.createElement("div", { onClick: function () { return props.onChange(props.value); } },
|
|
17
17
|
react_1.default.createElement("input", { id: uniqueId, type: "radio", onChange: function () {
|
|
18
18
|
// no-op -- change is handled by the div
|
|
19
|
-
}, checked: props.currentValue === props.value, value: props.value }),
|
|
19
|
+
}, checked: props.currentValue === props.value, value: props.value.toString() }),
|
|
20
20
|
react_1.default.createElement("label", { htmlFor: uniqueId }, props.label)));
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../../src/lib/containers/widgets/RadioGroup.tsx"],"names":[],"mappings":";;;;AAAA,qDAAuC;AACvC,uCAAiD;
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sourceRoot":"","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