@riboseinc/paneron-registry-kit 2.2.36 → 2.2.37
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/proposals/ListItem.d.ts +1 -0
- package/proposals/ListItem.js +4 -1
- package/proposals/ListItem.js.map +1 -1
- package/proposals/MetaProperties.d.ts +4 -3
- package/proposals/MetaProperties.js +26 -19
- package/proposals/MetaProperties.js.map +1 -1
- package/proposals/ProposalTab.d.ts +2 -0
- package/proposals/ProposalTab.js +12 -1
- package/proposals/ProposalTab.js.map +1 -1
- package/proposals/ProposalWorkspace.d.ts +3 -1
- package/proposals/ProposalWorkspace.js +9 -7
- package/proposals/ProposalWorkspace.js.map +1 -1
- package/proposals/TransitionHistory.js +10 -4
- package/proposals/TransitionHistory.js.map +1 -1
- package/proposals/actionableGroups/Tree.js +15 -0
- package/proposals/actionableGroups/Tree.js.map +1 -1
- package/proposals/actionableGroups/treeNodes.js +9 -5
- package/proposals/actionableGroups/treeNodes.js.map +1 -1
- package/views/detail/AllItems.d.ts +8 -0
- package/views/detail/AllItems.js +45 -0
- package/views/detail/AllItems.js.map +1 -0
- package/views/detail/ProposalWork.js +3 -1
- package/views/detail/ProposalWork.js.map +1 -1
- package/views/detail/RegisterHome/ActiveProposalDetails.js +6 -1
- package/views/detail/RegisterHome/ActiveProposalDetails.js.map +1 -1
- package/views/detail/RegisterHome2/index.js +11 -2
- package/views/detail/RegisterHome2/index.js.map +1 -1
- package/views/sidebar/Search/index.d.ts +2 -0
- package/views/sidebar/Search/index.js +14 -2
- package/views/sidebar/Search/index.js.map +1 -1
- package/views/sidebar/index.js +9 -3
- package/views/sidebar/index.js.map +1 -1
- package/views/util.d.ts +8 -0
- package/views/util.js +10 -3
- package/views/util.js.map +1 -1
package/views/util.js
CHANGED
|
@@ -119,6 +119,7 @@ const Datestamp = function ({
|
|
|
119
119
|
date,
|
|
120
120
|
useUTC,
|
|
121
121
|
showTime,
|
|
122
|
+
showTimeIfNonZero,
|
|
122
123
|
title,
|
|
123
124
|
className
|
|
124
125
|
}) {
|
|
@@ -126,7 +127,8 @@ const Datestamp = function ({
|
|
|
126
127
|
|
|
127
128
|
const asString = formatDate(date, {
|
|
128
129
|
useUTC,
|
|
129
|
-
showTime
|
|
130
|
+
showTime,
|
|
131
|
+
showTimeIfNonZero
|
|
130
132
|
});
|
|
131
133
|
return (0, _react2.jsx)("span", {
|
|
132
134
|
className: className,
|
|
@@ -141,14 +143,19 @@ function formatInTimeZone(date, fmt, tz) {
|
|
|
141
143
|
timeZone: tz
|
|
142
144
|
});
|
|
143
145
|
}
|
|
146
|
+
|
|
147
|
+
function timeIsNonZero(date) {
|
|
148
|
+
return date.getMilliseconds() === 0 && date.getSeconds() === 0 && date.getMinutes() === 0 && date.getHours() === 0;
|
|
149
|
+
}
|
|
144
150
|
/** Foramts given date as plain text. */
|
|
145
151
|
|
|
146
152
|
|
|
147
153
|
function formatDate(date, opts) {
|
|
148
|
-
const
|
|
154
|
+
const showTime = (opts === null || opts === void 0 ? void 0 : opts.showTime) || (opts === null || opts === void 0 ? void 0 : opts.showTimeIfNonZero) && timeIsNonZero(date);
|
|
155
|
+
const fmt = showTime ? 'yyyy-MM-dd HH:mm:ss' : 'yyyy-MM-dd';
|
|
149
156
|
|
|
150
157
|
try {
|
|
151
|
-
return (opts === null || opts === void 0 ? void 0 : opts.useUTC) ? `${formatInTimeZone(date, fmt, 'UTC')}${
|
|
158
|
+
return (opts === null || opts === void 0 ? void 0 : opts.useUTC) ? `${formatInTimeZone(date, fmt, 'UTC')}${showTime ? ' UTC' : ''}` : (0, _format.default)(date, fmt);
|
|
152
159
|
} catch (e) {
|
|
153
160
|
console.error("Failed to format date", date, typeof date);
|
|
154
161
|
return `Invalid date (${e})`;
|
package/views/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/views/util.tsx"],"names":[],"mappings":"AAAA,eA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C,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAGrB,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE;IACnC,OAAO,CACL,IAAC,IAAI;QACH,IAAC,WAAW,IAAC,KAAK,EAAC,kBAAkB,GAAG;QACxC,IAAC,QAAQ,IAAC,SAAS,QAAC,QAAQ,QAAC,GAAG,EAAE,GAAG,CAAA,kBAAkB,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,GAAI;QACtF,QAAQ;YACP,CAAC,CAAC;gBACE,IAAC,WAAW,IAAC,KAAK,EAAC,eAAe,GAAG;gBACrC,IAAC,QAAQ,IACP,IAAI,EAAC,aAAa,EAClB,MAAM,EAAC,SAAS,EAChB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAC,MAAM,GAC9B,CACD;YACL,CAAC,CAAC,IAAI,CACH,CACR,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\n//import log from 'electron-log';\nimport format from 'date-fns/format';\nimport { format as formatTZ, utcToZonedTime } from 'date-fns-tz';\n\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 H3, H4,\n Button as BaseButton, type ButtonProps,\n Menu, MenuDivider, MenuItem,\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 { BrowserCtx } from './BrowserCtx';\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 const { registerMetadata } = useContext(BrowserCtx);\n\n return (\n <Helmet\n titleTemplate={`%s in ${registerMetadata?.name ?? datasetTitle}`}\n defaultTitle={`${registerMetadata?.name ?? datasetTitle}`}>\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 useUTC?: boolean\n showTime?: boolean\n title?: string\n className?: string\n}> = function ({ date, useUTC, showTime, title, className }) {\n const asString = formatDate(date, { useUTC, showTime });\n return <span\n className={className}\n title={`${title ? `${title}: ` : ''}${date?.toString() ?? 'N/A'}`}>\n {asString}\n </span>;\n};\n\n\nfunction formatInTimeZone(date: Date, fmt: string, tz: string) {\n return formatTZ(\n utcToZonedTime(date, tz), \n fmt, \n { timeZone: tz });\n}\n\n\n/** Foramts given date as plain text. */\nexport function formatDate(\n date: Date,\n opts?: { useUTC?: boolean, showTime?: boolean },\n): string {\n const fmt = opts?.showTime\n ? 'yyyy-MM-dd HH:mm:ss'\n : 'yyyy-MM-dd';\n try {\n return opts?.useUTC\n ? `${formatInTimeZone(date, fmt, 'UTC')}${opts?.showTime ? ' UTC' : ''}`\n : format(date, fmt);\n } catch (e) {\n console.error(\"Failed to format date\", date, typeof date);\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 : <H3 css={css`margin: 0 ${paddingPx}px;`}>{title}</H3>}\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} ${props.className}`}\n />\n );\n};\n\n\nexport const MoreMenu: React.FC<Record<never, never>> = memo(function ({ children }) {\n return (\n <Popover minimal content={<>{children}</>}>\n <BaseButton icon=\"more\" small minimal />\n </Popover>\n );\n});\n\n\nexport const ItemClassMenu: React.FC<{\n cfg: ItemClassConfiguration<any>;\n onCreate?: () => void;\n}> = memo(function ({ cfg, onCreate }) {\n return (\n <Menu>\n <MenuDivider title=\"About this class\" />\n <MenuItem multiline disabled css={css`max-width: 400px`} text={cfg.meta.description} />\n {onCreate\n ? <>\n <MenuDivider title=\"Quick actions\" />\n <MenuItem\n text=\"Propose new\"\n intent=\"primary\"\n onClick={onCreate} icon=\"plus\"\n />\n </>\n : null}\n </Menu>\n );\n});\n"]}
|
|
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,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,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,IAAI,EAAE,WAAW,EAAE,QAAQ,EAC3B,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;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,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,GA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ACJ,CAAC,CAAC,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\n//import log from 'electron-log';\nimport format from 'date-fns/format';\nimport { format as formatTZ, utcToZonedTime } from 'date-fns-tz';\n\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 H3, H4,\n Button as BaseButton, type ButtonProps,\n Menu, MenuDivider, MenuItem,\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 { BrowserCtx } from './BrowserCtx';\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 const { registerMetadata } = useContext(BrowserCtx);\n\n return (\n <Helmet\n titleTemplate={`%s in ${registerMetadata?.name ?? datasetTitle}`}\n defaultTitle={`${registerMetadata?.name ?? datasetTitle}`}>\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 /** See formatDate(). */\n useUTC?: boolean\n /** See formatDate(). */\n showTime?: boolean\n /** See formatDate(). */\n showTimeIfNonZero?: boolean\n title?: string\n className?: string\n}> = function ({ date, useUTC, showTime, showTimeIfNonZero, title, className }) {\n const asString = formatDate(date, { useUTC, showTime, showTimeIfNonZero });\n return <span\n className={className}\n title={`${title ? `${title}: ` : ''}${date?.toString() ?? 'N/A'}`}>\n {asString}\n </span>;\n};\n\n\nfunction formatInTimeZone(date: Date, fmt: string, tz: string) {\n return formatTZ(\n utcToZonedTime(date, tz), \n fmt, \n { timeZone: tz });\n}\n\nfunction timeIsNonZero(date: Date): boolean {\n return (\n date.getMilliseconds() === 0 &&\n date.getSeconds() === 0 &&\n date.getMinutes() === 0 &&\n date.getHours() === 0);\n}\n\n\n/** Foramts given date as plain text. */\nexport function formatDate(\n date: Date,\n opts?: {\n /** Show time in UTC. Will add the “UTC”, unless time is shown. */\n useUTC?: boolean\n /** Show date along with full time, to seconds. */\n showTime?: boolean\n /** Show time, unless it’s 00:00:00 on the day. */\n showTimeIfNonZero?: boolean\n },\n): string {\n const showTime = opts?.showTime || (opts?.showTimeIfNonZero && timeIsNonZero(date));\n const fmt = showTime\n ? 'yyyy-MM-dd HH:mm:ss'\n : 'yyyy-MM-dd';\n try {\n return opts?.useUTC\n ? `${formatInTimeZone(date, fmt, 'UTC')}${showTime ? ' UTC' : ''}`\n : format(date, fmt);\n } catch (e) {\n console.error(\"Failed to format date\", date, typeof date);\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 : <H3 css={css`margin: 0 ${paddingPx}px;`}>{title}</H3>}\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} ${props.className}`}\n />\n );\n};\n\n\nexport const MoreMenu: React.FC<Record<never, never>> = memo(function ({ children }) {\n return (\n <Popover minimal content={<>{children}</>}>\n <BaseButton icon=\"more\" small minimal />\n </Popover>\n );\n});\n\n\nexport const ItemClassMenu: React.FC<{\n cfg: ItemClassConfiguration<any>;\n onCreate?: () => void;\n}> = memo(function ({ cfg, onCreate }) {\n return (\n <Menu>\n <MenuDivider title=\"About this class\" />\n <MenuItem multiline disabled css={css`max-width: 400px`} text={cfg.meta.description} />\n {onCreate\n ? <>\n <MenuDivider title=\"Quick actions\" />\n <MenuItem\n text=\"Propose new\"\n intent=\"primary\"\n onClick={onCreate} icon=\"plus\"\n />\n </>\n : null}\n </Menu>\n );\n});\n"]}
|