@riboseinc/paneron-registry-kit 2.2.20 → 2.2.22
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/package.json +2 -2
- package/types/proposal.d.ts +27 -7
- package/types/proposal.js +61 -4
- package/types/proposal.js.map +1 -1
- package/views/FilterCriteria/criteriaToNodes.js +5 -5
- package/views/FilterCriteria/criteriaToNodes.js.map +1 -1
- package/views/FilterCriteria/mutateGroup.d.ts +9 -2
- package/views/FilterCriteria/mutateGroup.js +27 -5
- package/views/FilterCriteria/mutateGroup.js.map +1 -1
- package/views/ProposalHistoryDrawer.d.ts +12 -0
- package/views/ProposalHistoryDrawer.js +107 -0
- package/views/ProposalHistoryDrawer.js.map +1 -0
- package/views/SearchQuery.js +2 -2
- package/views/SearchQuery.js.map +1 -1
- package/views/change-request/Proposals.d.ts +3 -0
- package/views/change-request/Proposals.js +6 -5
- package/views/change-request/Proposals.js.map +1 -1
- package/views/detail/RegisterItem/index.js +16 -3
- package/views/detail/RegisterItem/index.js.map +1 -1
- package/views/sidebar/Registration/index.d.ts +5 -0
- package/views/sidebar/Registration/index.js +7 -3
- package/views/sidebar/Registration/index.js.map +1 -1
- package/views/sidebar/Search/index.js +3 -3
- package/views/sidebar/Search/index.js.map +1 -1
- package/views/util.js +3 -1
- package/views/util.js.map +1 -1
package/views/util.js
CHANGED
|
@@ -252,7 +252,8 @@ const TabContentsWithHeader = function ({
|
|
|
252
252
|
if (props.hasOwnProperty('length') && props.length !== undefined) {
|
|
253
253
|
return (0, _react2.jsx)(_core.ButtonGroup, {
|
|
254
254
|
key: idx
|
|
255
|
-
}, props.map(p => (0, _react2.jsx)(Action, { ...p
|
|
255
|
+
}, props.map((p, idx) => (0, _react2.jsx)(Action, { ...p,
|
|
256
|
+
key: idx
|
|
256
257
|
})));
|
|
257
258
|
} else {
|
|
258
259
|
return (0, _react2.jsx)(Action, {
|
|
@@ -282,6 +283,7 @@ const Action = function ({
|
|
|
282
283
|
|
|
283
284
|
if (popup && !props.disabled) {
|
|
284
285
|
return (0, _react2.jsx)(_popover.Popover2, {
|
|
286
|
+
key: props.key,
|
|
285
287
|
content: popup,
|
|
286
288
|
placement: "top",
|
|
287
289
|
minimal: true,
|
package/views/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/views/util.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,iCAAiC;AACjC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAc,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,MAAM,EAAoB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,IAAI,EACJ,OAAO,EACP,SAAS,EACT,EAAE,EAAE,EAAE,EACN,MAAM,IAAI,UAAU,EACpB,WAAW,EACX,GAAG,EACH,MAAM,GACP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,WAAsC,MAAM,sDAAsD,CAAC;AAE1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,YAAoB,EAAE;IAEtB,OAAO,GAAG,CAAC,MAAM,GAAG,SAAS;QAC3B,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;QAC/B,CAAC,CAAC,GAAG,CAAC;AACV,CAAC;AAGD,MAAM,CAAC,MAAM,cAAc,GAA0B,IAAI,CAAC,UAAU,KAAK;IACvE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,UA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C;AACJ,CAAC,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\n//import log from 'electron-log';\nimport format from 'date-fns/format';\nimport React, { memo, useContext } from 'react';\nimport { Helmet, type HelmetProps } from 'react-helmet';\nimport { css, jsx } from '@emotion/react';\nimport {\n Card, type CardProps,\n Classes,\n FormGroup, type FormGroupProps,\n H2, H4,\n Button as BaseButton, type ButtonProps,\n ButtonGroup,\n Tag, type TagProps,\n Colors,\n} from '@blueprintjs/core';\nimport { Popover2 as Popover } from '@blueprintjs/popover2';\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport HelpTooltip, { type HelpTooltipProps } from '@riboseinc/paneron-extension-kit/widgets/HelpTooltip';\nimport type { ItemClassConfiguration, RelatedItemClassConfiguration } from '../types';\nexport { GenericRelatedItemView } from './GenericRelatedItemView';\n\n\n/**\n * Get give string truncated & with ellipsis appended\n * if its length exceeds given number of characters.\n */\nexport function maybeEllipsizeString(\n str: string,\n maxLength: number = 20,\n): string {\n return str.length > maxLength\n ? `${str.slice(0, maxLength)}…`\n : str;\n}\n\n\nexport const RegisterHelmet: React.FC<HelmetProps> = memo(function (props) {\n const { title: datasetTitle } = useContext(DatasetContext);\n\n return (\n <Helmet\n titleTemplate={`%s in ${datasetTitle} register`}\n defaultTitle={`${datasetTitle} register`}>\n {props.children}\n </Helmet>\n );\n});\n\n\n/**\n * A wrapper to show property data with its label(s).\n */\nexport const PropertyDetailView: React.FC<FormGroupProps & {\n /** @deprecated use `label` instead */\n title?: FormGroupProps[\"label\"]\n /** @deprecated use `labelInfo` instead */\n secondaryTitle?: FormGroupProps[\"labelInfo\"]\n}> = function ({\n label, labelInfo,\n title, secondaryTitle,\n ...props }) {\n return (\n <FormGroup\n label={label || title ? `${label ?? title}:` : undefined}\n labelInfo={labelInfo ?? secondaryTitle}\n css={css`\n &, &.bp4-inline {\n label.bp4-label {\n /*\n * Since it’s in flex container, label expands to fill its width,\n * and due to the mechanics of how labels work (?)\n * any button (e.g., for deletion) within labelInfo\n * would responds to events of the entire label\n * (meaning you can hover space to the right of the label and labelInfo\n * and the button would still be clickable).\n * This makes the label not fill flex container width.\n */\n align-self: flex-start;\n\n font-weight: bold;\n line-height: unset;\n text-transform: capitalize;\n .bp4-text-muted {\n text-transform: none;\n }\n }\n }\n `}\n {...props}\n />\n );\n};\n\n\n/** Formats given date as a span with tooltip set to full ISO date & time. */\nexport const Datestamp: React.FC<{\n date: Date\n title?: string\n className?: string\n}> = function ({ date, title, className }) {\n const asString = formatDate(date);\n return <span\n className={className}\n title={`${title ? `${title}: ` : ''}${date?.toString() ?? 'N/A'}`}>\n {asString}\n </span>;\n};\n\n\n/** Foramts given date as plain text. */\nexport function formatDate(date: Date): string {\n try {\n return format(date, 'yyyy-MM-dd');\n } catch (e) {\n return `Invalid date (${e})`;\n }\n}\n\n\nexport const _getRelatedClass = (classes: Record<string, ItemClassConfiguration<any>>) => {\n return (clsID: string): RelatedItemClassConfiguration => {\n const cfg = classes[clsID];\n return {\n title: cfg.meta.title,\n // TODO: The itemView/listItemView inconsistency is annoying\n itemView: cfg.views.listItemView,\n };\n };\n};\n\n\n// /**\n// * Suitable for use as tab contents for TabbedWorkspace.\n// * Provides top bar with actions and main content.\n// */\n// export const TabContentsWithActions: React.FC<{\n// actions: JSX.Element;\n// main: JSX.Element;\n// gapPx?: number;\n// className?: string;\n// }> = function ({ actions, gapPx: _gapPx, main, className }) {\n// const gapPx = _gapPx ?? 10;\n// return (\n// <div css={css`\n// position: absolute; inset: 0;\n// display: flex; flex-flow: column nowrap;\n// `} className={className}>\n// <div css={css`flex: 0; padding: ${gapPx}px; display: flex; flex-flow: row wrap; gap: ${gapPx}px;`}>\n// {actions}\n// </div>\n// <div css={css`\n// position: relative;\n// flex: 1;\n// padding: ${gapPx}px;\n// overflow-y: auto;\n// background: ${Colors.GRAY5};\n// .bp4-dark & { background: ${Colors.DARK_GRAY2}; }\n// `}>\n// {main}\n// </div>\n// </div>\n// );\n// };\n\n\nexport type ClassificationEntry = TagProps & { tooltip?: HelpTooltipProps };\nexport interface TabContentsWithHeaderProps {\n title: JSX.Element | string\n smallTitle?: boolean\n classification?: ClassificationEntry[]\n actions?: (ActionProps | ActionProps[])[]\n tooltip?: HelpTooltipProps\n className?: string\n\n /**\n * CSS to apply to child contents wrapper div.\n *\n * If 'card-grid', children would be expected to be cards\n * (e.g., `FormGroupAsCardInGrid` or `CardInGrid`)\n *\n * 'card-grid' implies 'scrollable'.\n */\n layout?: undefined | 'card-grid' | 'scrollable'\n layoutOptions?: Record<string, unknown>\n}\ninterface Grid extends TabContentsWithHeaderProps {\n layout: 'card-grid'\n layoutOptions?: {\n gapPx?: number\n stretch?: boolean\n }\n}\ninterface Scrollable extends TabContentsWithHeaderProps {\n layout: 'scrollable'\n layoutOptions?: never\n}\ninterface NoLayout extends TabContentsWithHeaderProps {\n layout?: undefined\n layoutOptions?: never\n}\nconst paddingPx = 11;\nfunction findEnabledActions\n<T extends ButtonProps | ButtonProps[] = ButtonProps | ButtonProps[]>\n(props: T[]): ButtonProps[] {\n return props.map(props =>\n (props as ButtonProps[]).length !== undefined\n ? (props as ButtonProps[]).filter(p => !p.disabled)\n : !(props as ButtonProps).disabled\n ? props\n : []\n ).flat();\n}\nexport const TabContentsWithHeader: React.FC<Grid | Scrollable | NoLayout> =\nfunction ({ title, smallTitle, classification, actions, layout, layoutOptions, className, children }) {\n const hasClassification = (classification ?? []).length > 0;\n\n const enabledActions = actions ? findEnabledActions(actions) : [];\n const hasActions = enabledActions.length > 0;\n\n // if (enabledActions.length === 1 && !enabledActions[0].intent) {\n // enabledActions[0].intent = 'primary';\n // }\n\n return (\n <div css={css`\n position: absolute; inset: 0;\n padding-top: ${paddingPx}px;\n ${hasActions ? `padding-bottom: ${paddingPx}px;` : ''}\n display: flex; flex-flow: column nowrap;\n gap: ${paddingPx}px;\n `} className={className}>\n {smallTitle\n ? <H4 css={css`margin: 0 ${paddingPx}px;`}>{title}</H4>\n : <H2 css={css`margin: 0 ${paddingPx}px;`}>{title}</H2>}\n {hasClassification\n ? <div css={css`\n flex: 0;\n margin: 0 ${paddingPx}px;\n display: flex;\n flex-flow: row wrap;\n gap: ${paddingPx}px;\n `}>\n {classification!.map((p, idx) =>\n <Tag\n key={idx}\n minimal\n {...p}\n large={!smallTitle}\n rightIcon={p.tooltip\n ? <HelpTooltip {...p.tooltip} />\n : undefined}\n />\n )}\n </div>\n : null}\n <div css={css`\n position: relative;\n flex: 1;\n overflow-y: auto;\n\n ${layout === undefined\n ? `\n > :only-child { position: absolute; inset: 0 }\n box-shadow: black 0 0 20px -10px;\n `\n : `\n padding: 0 10px;\n &::after, &::before {\n pointer-events: none;\n content: \" \";\n display: block;\n position: sticky;\n width: 100%;\n height: 1px;\n background: ${Colors.GRAY5};\n .bp4-dark & { background: ${Colors.DARK_GRAY2}; }\n z-index: 10;\n }\n &::before {\n top: 0;\n box-shadow: ${Colors.GRAY5} 0 -20px 20px 20px;\n .bp4-dark & {\n box-shadow: ${Colors.DARK_GRAY2} 0 -20px 20px 20px;\n }\n }\n &::after {\n bottom: 0;\n box-shadow: ${Colors.GRAY5} 0 20px 20px 20px;\n .bp4-dark & {\n box-shadow: ${Colors.DARK_GRAY2} 0 20px 20px 20px;\n }\n }\n `}\n\n ${layout === 'scrollable' || layout === 'card-grid'\n ? `\n background: ${Colors.GRAY5};\n .bp4-dark & { background: ${Colors.DARK_GRAY2}; }\n `\n : ''}\n\n ${layout === 'card-grid'\n ? `\n display: flex;\n flex-flow: row wrap;\n align-content: flex-start;\n ${layoutOptions?.stretch\n ? 'align-items: stretch;'\n : 'align-items: flex-start;'}\n gap: ${layoutOptions?.gapPx ?? 10}px;\n `\n : ''}\n `}>\n {children}\n </div>\n\n {hasActions\n ? <div css={css`\n margin: 0 ${paddingPx}px;\n flex: 0; display: flex; flex-flow: row wrap; gap: ${paddingPx}px;\n `}>\n {actions!.map((props, idx) => {\n if (props.hasOwnProperty('length') && (props as ButtonProps[]).length !== undefined) {\n return (\n <ButtonGroup key={idx}>\n {(props as ButtonProps[]).map(p =>\n <Action {...p} />\n )}\n </ButtonGroup>\n );\n } else {\n return <Action key={idx} {...(props as ButtonProps)} />;\n }\n })}\n </div>\n : null}\n </div>\n );\n};\n\n\nexport type ActionProps = ButtonProps & ({ popup?: JSX.Element, tooltip?: string });\n/** Mostly a button, but with an optional popup. */\nconst Action: React.FC<ActionProps> = function ({ popup, tooltip, ...props }) {\n const btn = <BaseButton\n {...props}\n intent={props.disabled ? undefined : props.intent}\n onClick={props.disabled ? undefined : props.onClick}\n disabled={props.active ? false : props.disabled}\n title={tooltip}\n rightIcon={popup ? 'more' : undefined}\n />;\n\n if (popup && !props.disabled) {\n return (\n <Popover content={popup} placement=\"top\" minimal interactionKind=\"click\">\n {btn}\n </Popover>\n );\n } else {\n return btn;\n }\n};\n\n\nexport const CardInGrid: React.FC<{ description: string } & CardProps> =\nfunction ({ description, className, ...props }) {\n return (\n <Card\n css={css`border-radius: 5px;`}\n title={description}\n className={!props.interactive\n ? `${Classes.ELEVATION_3} ${className ?? ''}`\n : className}\n {...props}\n />\n );\n};\n\n\n/** Useful in case of tab “card-grid” layout. */\nexport const FormGroupAsCardInGrid: React.FC<FormGroupProps & { paddingPx?: number }> =\nfunction ({ paddingPx, ...props }) {\n const paddingPx_ = paddingPx ?? 11;\n return (\n <FormGroup\n {...props}\n css={css`\n margin: 0;\n\n border-radius: 5px;\n padding: ${paddingPx_}px;\n\n > label.bp4-label {\n font-weight: bold;\n margin-bottom: ${paddingPx_}px;\n }\n > .bp4-form-content {\n display: flex;\n flex-flow: column nowrap;\n gap: ${paddingPx_}px;\n\n > .bp4-form-group {\n margin: 0;\n }\n }\n\n /* Note: these colors are picked to work with some form widgets, date input widget specifically. */\n background: ${Colors.WHITE};\n .bp4-dark & { background: ${Colors.DARK_GRAY3}; }\n `}\n className={Classes.ELEVATION_3}\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/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CAAC,KAAK,CAAC,QAAQ,EAAE;QAC5B,OAAO,CACL,IAAC,OAAO,IAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAC,KAAK,EAAC,OAAO,QAAC,eAAe,EAAC,OAAO,IACrF,GAAG,CACI,CACX,CAAC;KACH;SAAM;QACL,OAAO,GAAG,CAAC;KACZ;AACH,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,UAAU,GACvB,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE;IAC5C,OAAO,CACL,IAAC,IAAI,IACH,GAAG,EAAE,GAAG,CAAA,qBAAqB,EAC7B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,CAAC,KAAK,CAAC,WAAW;YAC3B,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,IAAI,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,EAAE;YAC7C,CAAC,CAAC,SAAS,KACT,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAGF,gDAAgD;AAChD,MAAM,CAAC,MAAM,qBAAqB,GAClC,UAAU,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE;IAC/B,MAAM,UAAU,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;IACnC,OAAO,CACL,IAAC,SAAS,OACJ,KAAK,EACT,GAAG,EAAE,GAAG,CAAA;;;;mBAIK,UAAU;;;;2BAIF,UAAU;;;;;iBAKpB,UAAU;;;;;;;;sBAQL,MAAM,CAAC,KAAK;oCACE,MAAM,CAAC,UAAU;OAC9C,EACD,SAAS,EAAE,OAAO,CAAC,WAAW,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\n//import log from 'electron-log';\nimport format from 'date-fns/format';\nimport React, { memo, useContext } from 'react';\nimport { Helmet, type HelmetProps } from 'react-helmet';\nimport { css, jsx } from '@emotion/react';\nimport {\n Card, type CardProps,\n Classes,\n FormGroup, type FormGroupProps,\n H2, H4,\n Button as BaseButton, type ButtonProps,\n ButtonGroup,\n Tag, type TagProps,\n Colors,\n} from '@blueprintjs/core';\nimport { Popover2 as Popover } from '@blueprintjs/popover2';\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport HelpTooltip, { type HelpTooltipProps } from '@riboseinc/paneron-extension-kit/widgets/HelpTooltip';\nimport type { ItemClassConfiguration, RelatedItemClassConfiguration } from '../types';\nexport { GenericRelatedItemView } from './GenericRelatedItemView';\n\n\n/**\n * Get give string truncated & with ellipsis appended\n * if its length exceeds given number of characters.\n */\nexport function maybeEllipsizeString(\n str: string,\n maxLength: number = 20,\n): string {\n return str.length > maxLength\n ? `${str.slice(0, maxLength)}…`\n : str;\n}\n\n\nexport const RegisterHelmet: React.FC<HelmetProps> = memo(function (props) {\n const { title: datasetTitle } = useContext(DatasetContext);\n\n return (\n <Helmet\n titleTemplate={`%s in ${datasetTitle} register`}\n defaultTitle={`${datasetTitle} register`}>\n {props.children}\n </Helmet>\n );\n});\n\n\n/**\n * A wrapper to show property data with its label(s).\n */\nexport const PropertyDetailView: React.FC<FormGroupProps & {\n /** @deprecated use `label` instead */\n title?: FormGroupProps[\"label\"]\n /** @deprecated use `labelInfo` instead */\n secondaryTitle?: FormGroupProps[\"labelInfo\"]\n}> = function ({\n label, labelInfo,\n title, secondaryTitle,\n ...props }) {\n return (\n <FormGroup\n label={label || title ? `${label ?? title}:` : undefined}\n labelInfo={labelInfo ?? secondaryTitle}\n css={css`\n &, &.bp4-inline {\n label.bp4-label {\n /*\n * Since it’s in flex container, label expands to fill its width,\n * and due to the mechanics of how labels work (?)\n * any button (e.g., for deletion) within labelInfo\n * would responds to events of the entire label\n * (meaning you can hover space to the right of the label and labelInfo\n * and the button would still be clickable).\n * This makes the label not fill flex container width.\n */\n align-self: flex-start;\n\n font-weight: bold;\n line-height: unset;\n text-transform: capitalize;\n .bp4-text-muted {\n text-transform: none;\n }\n }\n }\n `}\n {...props}\n />\n );\n};\n\n\n/** Formats given date as a span with tooltip set to full ISO date & time. */\nexport const Datestamp: React.FC<{\n date: Date\n title?: string\n className?: string\n}> = function ({ date, title, className }) {\n const asString = formatDate(date);\n return <span\n className={className}\n title={`${title ? `${title}: ` : ''}${date?.toString() ?? 'N/A'}`}>\n {asString}\n </span>;\n};\n\n\n/** Foramts given date as plain text. */\nexport function formatDate(date: Date): string {\n try {\n return format(date, 'yyyy-MM-dd');\n } catch (e) {\n return `Invalid date (${e})`;\n }\n}\n\n\nexport const _getRelatedClass = (classes: Record<string, ItemClassConfiguration<any>>) => {\n return (clsID: string): RelatedItemClassConfiguration => {\n const cfg = classes[clsID];\n return {\n title: cfg.meta.title,\n // TODO: The itemView/listItemView inconsistency is annoying\n itemView: cfg.views.listItemView,\n };\n };\n};\n\n\n// /**\n// * Suitable for use as tab contents for TabbedWorkspace.\n// * Provides top bar with actions and main content.\n// */\n// export const TabContentsWithActions: React.FC<{\n// actions: JSX.Element;\n// main: JSX.Element;\n// gapPx?: number;\n// className?: string;\n// }> = function ({ actions, gapPx: _gapPx, main, className }) {\n// const gapPx = _gapPx ?? 10;\n// return (\n// <div css={css`\n// position: absolute; inset: 0;\n// display: flex; flex-flow: column nowrap;\n// `} className={className}>\n// <div css={css`flex: 0; padding: ${gapPx}px; display: flex; flex-flow: row wrap; gap: ${gapPx}px;`}>\n// {actions}\n// </div>\n// <div css={css`\n// position: relative;\n// flex: 1;\n// padding: ${gapPx}px;\n// overflow-y: auto;\n// background: ${Colors.GRAY5};\n// .bp4-dark & { background: ${Colors.DARK_GRAY2}; }\n// `}>\n// {main}\n// </div>\n// </div>\n// );\n// };\n\n\nexport type ClassificationEntry = TagProps & { tooltip?: HelpTooltipProps };\nexport interface TabContentsWithHeaderProps {\n title: JSX.Element | string\n smallTitle?: boolean\n classification?: ClassificationEntry[]\n actions?: (ActionProps | ActionProps[])[]\n tooltip?: HelpTooltipProps\n className?: string\n\n /**\n * CSS to apply to child contents wrapper div.\n *\n * If 'card-grid', children would be expected to be cards\n * (e.g., `FormGroupAsCardInGrid` or `CardInGrid`)\n *\n * 'card-grid' implies 'scrollable'.\n */\n layout?: undefined | 'card-grid' | 'scrollable'\n layoutOptions?: Record<string, unknown>\n}\ninterface Grid extends TabContentsWithHeaderProps {\n layout: 'card-grid'\n layoutOptions?: {\n gapPx?: number\n stretch?: boolean\n }\n}\ninterface Scrollable extends TabContentsWithHeaderProps {\n layout: 'scrollable'\n layoutOptions?: never\n}\ninterface NoLayout extends TabContentsWithHeaderProps {\n layout?: undefined\n layoutOptions?: never\n}\nconst paddingPx = 11;\nfunction findEnabledActions\n<T extends ButtonProps | ButtonProps[] = ButtonProps | ButtonProps[]>\n(props: T[]): ButtonProps[] {\n return props.map(props =>\n (props as ButtonProps[]).length !== undefined\n ? (props as ButtonProps[]).filter(p => !p.disabled)\n : !(props as ButtonProps).disabled\n ? props\n : []\n ).flat();\n}\nexport const TabContentsWithHeader: React.FC<Grid | Scrollable | NoLayout> =\nfunction ({ title, smallTitle, classification, actions, layout, layoutOptions, className, children }) {\n const hasClassification = (classification ?? []).length > 0;\n\n const enabledActions = actions ? findEnabledActions(actions) : [];\n const hasActions = enabledActions.length > 0;\n\n // if (enabledActions.length === 1 && !enabledActions[0].intent) {\n // enabledActions[0].intent = 'primary';\n // }\n\n return (\n <div css={css`\n position: absolute; inset: 0;\n padding-top: ${paddingPx}px;\n ${hasActions ? `padding-bottom: ${paddingPx}px;` : ''}\n display: flex; flex-flow: column nowrap;\n gap: ${paddingPx}px;\n `} className={className}>\n {smallTitle\n ? <H4 css={css`margin: 0 ${paddingPx}px;`}>{title}</H4>\n : <H2 css={css`margin: 0 ${paddingPx}px;`}>{title}</H2>}\n {hasClassification\n ? <div css={css`\n flex: 0;\n margin: 0 ${paddingPx}px;\n display: flex;\n flex-flow: row wrap;\n gap: ${paddingPx}px;\n `}>\n {classification!.map((p, idx) =>\n <Tag\n key={idx}\n minimal\n {...p}\n large={!smallTitle}\n rightIcon={p.tooltip\n ? <HelpTooltip {...p.tooltip} />\n : undefined}\n />\n )}\n </div>\n : null}\n <div css={css`\n position: relative;\n flex: 1;\n overflow-y: auto;\n\n ${layout === undefined\n ? `\n > :only-child { position: absolute; inset: 0 }\n box-shadow: black 0 0 20px -10px;\n `\n : `\n padding: 0 10px;\n &::after, &::before {\n pointer-events: none;\n content: \" \";\n display: block;\n position: sticky;\n width: 100%;\n height: 1px;\n background: ${Colors.GRAY5};\n .bp4-dark & { background: ${Colors.DARK_GRAY2}; }\n z-index: 10;\n }\n &::before {\n top: 0;\n box-shadow: ${Colors.GRAY5} 0 -20px 20px 20px;\n .bp4-dark & {\n box-shadow: ${Colors.DARK_GRAY2} 0 -20px 20px 20px;\n }\n }\n &::after {\n bottom: 0;\n box-shadow: ${Colors.GRAY5} 0 20px 20px 20px;\n .bp4-dark & {\n box-shadow: ${Colors.DARK_GRAY2} 0 20px 20px 20px;\n }\n }\n `}\n\n ${layout === 'scrollable' || layout === 'card-grid'\n ? `\n background: ${Colors.GRAY5};\n .bp4-dark & { background: ${Colors.DARK_GRAY2}; }\n `\n : ''}\n\n ${layout === 'card-grid'\n ? `\n display: flex;\n flex-flow: row wrap;\n align-content: flex-start;\n ${layoutOptions?.stretch\n ? 'align-items: stretch;'\n : 'align-items: flex-start;'}\n gap: ${layoutOptions?.gapPx ?? 10}px;\n `\n : ''}\n `}>\n {children}\n </div>\n\n {hasActions\n ? <div css={css`\n margin: 0 ${paddingPx}px;\n flex: 0; display: flex; flex-flow: row wrap; gap: ${paddingPx}px;\n `}>\n {actions!.map((props, idx) => {\n if (props.hasOwnProperty('length') && (props as ButtonProps[]).length !== undefined) {\n return (\n <ButtonGroup key={idx}>\n {(props as ButtonProps[]).map((p, idx) =>\n <Action {...p} key={idx} />\n )}\n </ButtonGroup>\n );\n } else {\n return <Action key={idx} {...(props as ButtonProps)} />;\n }\n })}\n </div>\n : null}\n </div>\n );\n};\n\n\nexport type ActionProps = ButtonProps & ({ popup?: JSX.Element, tooltip?: string });\n/** Mostly a button, but with an optional popup. */\nconst Action: React.FC<ActionProps & { key?: number | string }> = function ({ popup, tooltip, ...props }) {\n const btn = <BaseButton\n {...props}\n intent={props.disabled ? undefined : props.intent}\n onClick={props.disabled ? undefined : props.onClick}\n disabled={props.active ? false : props.disabled}\n title={tooltip}\n rightIcon={popup ? 'more' : undefined}\n />;\n\n if (popup && !props.disabled) {\n return (\n <Popover key={props.key} content={popup} placement=\"top\" minimal interactionKind=\"click\">\n {btn}\n </Popover>\n );\n } else {\n return btn;\n }\n};\n\n\nexport const CardInGrid: React.FC<{ description: string } & CardProps> =\nfunction ({ description, className, ...props }) {\n return (\n <Card\n css={css`border-radius: 5px;`}\n title={description}\n className={!props.interactive\n ? `${Classes.ELEVATION_3} ${className ?? ''}`\n : className}\n {...props}\n />\n );\n};\n\n\n/** Useful in case of tab “card-grid” layout. */\nexport const FormGroupAsCardInGrid: React.FC<FormGroupProps & { paddingPx?: number }> =\nfunction ({ paddingPx, ...props }) {\n const paddingPx_ = paddingPx ?? 11;\n return (\n <FormGroup\n {...props}\n css={css`\n margin: 0;\n\n border-radius: 5px;\n padding: ${paddingPx_}px;\n\n > label.bp4-label {\n font-weight: bold;\n margin-bottom: ${paddingPx_}px;\n }\n > .bp4-form-content {\n display: flex;\n flex-flow: column nowrap;\n gap: ${paddingPx_}px;\n\n > .bp4-form-group {\n margin: 0;\n }\n }\n\n /* Note: these colors are picked to work with some form widgets, date input widget specifically. */\n background: ${Colors.WHITE};\n .bp4-dark & { background: ${Colors.DARK_GRAY3}; }\n `}\n className={Classes.ELEVATION_3}\n />\n );\n};\n"]}
|