@payloadcms/ui 4.0.0-canary.2 → 4.0.0-internal.011fd46
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/css/colors.css +3 -0
- package/dist/css/design-tokens.css +5 -0
- package/dist/css/elevations.css +4 -0
- package/dist/elements/AppHeader/index.d.ts +3 -2
- package/dist/elements/AppHeader/index.d.ts.map +1 -1
- package/dist/elements/AppHeader/index.js +2 -2
- package/dist/elements/AppHeader/index.js.map +1 -1
- package/dist/elements/ColumnSelection/Popup.d.ts +12 -0
- package/dist/elements/ColumnSelection/Popup.d.ts.map +1 -0
- package/dist/elements/{ColumnSelector/index.js → ColumnSelection/Popup.js} +23 -12
- package/dist/elements/ColumnSelection/Popup.js.map +1 -0
- package/dist/elements/ColumnSelection/index.d.ts +10 -0
- package/dist/elements/ColumnSelection/index.d.ts.map +1 -0
- package/dist/elements/{ColumnsButton → ColumnSelection}/index.js +23 -17
- package/dist/elements/ColumnSelection/index.js.map +1 -0
- package/dist/elements/DocumentControls/index.css +7 -1
- package/dist/elements/DocumentControls/index.d.ts.map +1 -1
- package/dist/elements/DocumentControls/index.js +2 -2
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js +5 -3
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js.map +1 -1
- package/dist/elements/GroupBy/Popup.d.ts +21 -0
- package/dist/elements/GroupBy/Popup.d.ts.map +1 -0
- package/dist/elements/GroupBy/Popup.js +269 -0
- package/dist/elements/GroupBy/Popup.js.map +1 -0
- package/dist/elements/GroupBy/index.d.ts +12 -0
- package/dist/elements/GroupBy/index.d.ts.map +1 -0
- package/dist/elements/GroupBy/index.js +91 -0
- package/dist/elements/GroupBy/index.js.map +1 -0
- package/dist/elements/ListColumnSelectionButton/index.d.ts +11 -0
- package/dist/elements/ListColumnSelectionButton/index.d.ts.map +1 -0
- package/dist/elements/ListColumnSelectionButton/index.js +37 -0
- package/dist/elements/ListColumnSelectionButton/index.js.map +1 -0
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +7 -7
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListGroupByButton/index.d.ts +12 -0
- package/dist/elements/ListGroupByButton/index.d.ts.map +1 -0
- package/dist/elements/ListGroupByButton/index.js +55 -0
- package/dist/elements/ListGroupByButton/index.js.map +1 -0
- package/dist/elements/ListWhereBuilder/index.d.ts +16 -0
- package/dist/elements/ListWhereBuilder/index.d.ts.map +1 -0
- package/dist/elements/ListWhereBuilder/index.js +62 -0
- package/dist/elements/ListWhereBuilder/index.js.map +1 -0
- package/dist/elements/Popup/PopupButtonList/index.css +5 -0
- package/dist/elements/Popup/PopupGroupLabel/index.css +8 -5
- package/dist/elements/Popup/index.d.ts.map +1 -1
- package/dist/elements/Popup/index.js +42 -11
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PublishMany/DrawerContent.d.ts +2 -1
- package/dist/elements/PublishMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/PublishMany/DrawerContent.js.map +1 -1
- package/dist/elements/PublishMany/index.d.ts +2 -6
- package/dist/elements/PublishMany/index.d.ts.map +1 -1
- package/dist/elements/PublishMany/index.js +0 -38
- package/dist/elements/PublishMany/index.js.map +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/{index.scss → index.css} +1 -3
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.d.ts +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.js +1 -1
- package/dist/elements/QueryPresets/cells/ColumnsCell/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/ColumnsField/index.d.ts +1 -1
- package/dist/elements/QueryPresets/fields/ColumnsField/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/fields/ColumnsField/index.js +77 -48
- package/dist/elements/QueryPresets/fields/ColumnsField/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/GroupByField/index.d.ts +1 -1
- package/dist/elements/QueryPresets/fields/GroupByField/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/fields/GroupByField/index.js +12 -21
- package/dist/elements/QueryPresets/fields/GroupByField/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/Heading/index.css +52 -0
- package/dist/elements/QueryPresets/fields/Heading/index.d.ts +7 -0
- package/dist/elements/QueryPresets/fields/Heading/index.d.ts.map +1 -0
- package/dist/elements/QueryPresets/fields/Heading/index.js +31 -0
- package/dist/elements/QueryPresets/fields/Heading/index.js.map +1 -0
- package/dist/elements/QueryPresets/fields/WhereField/index.d.ts +1 -1
- package/dist/elements/QueryPresets/fields/WhereField/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/fields/WhereField/index.js +24 -23
- package/dist/elements/QueryPresets/fields/WhereField/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/fields.css +23 -0
- package/dist/elements/ReactSelect/getCaptureMenuScroll.d.ts +5 -0
- package/dist/elements/ReactSelect/getCaptureMenuScroll.d.ts.map +1 -0
- package/dist/elements/ReactSelect/getCaptureMenuScroll.js +10 -0
- package/dist/elements/ReactSelect/getCaptureMenuScroll.js.map +1 -0
- package/dist/elements/ReactSelect/getMenuListStyles.d.ts +6 -0
- package/dist/elements/ReactSelect/getMenuListStyles.d.ts.map +1 -0
- package/dist/elements/ReactSelect/getMenuListStyles.js +7 -0
- package/dist/elements/ReactSelect/getMenuListStyles.js.map +1 -0
- package/dist/elements/ReactSelect/index.css +0 -1
- package/dist/elements/ReactSelect/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/index.js +168 -148
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/ReactSelect/types.d.ts +1 -0
- package/dist/elements/ReactSelect/types.d.ts.map +1 -1
- package/dist/elements/ReactSelect/types.js.map +1 -1
- package/dist/elements/RelationshipTable/index.js +2 -2
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/SortColumn/index.css +1 -1
- package/dist/elements/Table/index.css +24 -2
- package/dist/elements/Toasts/fieldErrors.d.ts +1 -0
- package/dist/elements/Toasts/fieldErrors.d.ts.map +1 -1
- package/dist/elements/Toasts/fieldErrors.js +25 -9
- package/dist/elements/Toasts/fieldErrors.js.map +1 -1
- package/dist/elements/Toasts/index.css +5 -0
- package/dist/elements/UnpublishMany/DrawerContent.d.ts +2 -1
- package/dist/elements/UnpublishMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/DrawerContent.js.map +1 -1
- package/dist/elements/UnpublishMany/index.d.ts +2 -4
- package/dist/elements/UnpublishMany/index.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/index.js +0 -38
- package/dist/elements/UnpublishMany/index.js.map +1 -1
- package/dist/elements/UserMenu/LanguageMenu/index.js +1 -1
- package/dist/elements/UserMenu/LanguageMenu/index.js.map +1 -1
- package/dist/elements/UserMenu/SettingsMenu/index.d.ts +6 -2
- package/dist/elements/UserMenu/SettingsMenu/index.d.ts.map +1 -1
- package/dist/elements/UserMenu/SettingsMenu/index.js +15 -10
- package/dist/elements/UserMenu/SettingsMenu/index.js.map +1 -1
- package/dist/elements/UserMenu/ThemeMenu/index.js +1 -1
- package/dist/elements/UserMenu/ThemeMenu/index.js.map +1 -1
- package/dist/elements/UserMenu/index.d.ts +2 -1
- package/dist/elements/UserMenu/index.d.ts.map +1 -1
- package/dist/elements/UserMenu/index.js +8 -5
- package/dist/elements/UserMenu/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts +1 -0
- package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +17 -2
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.d.ts +4 -3
- package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/index.js +71 -62
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/elements/WhereBuilder/types.d.ts +6 -5
- package/dist/elements/WhereBuilder/types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/types.js.map +1 -1
- package/dist/exports/client/index.d.ts +2 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +26 -26
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/RadioGroup/index.css +6 -0
- package/dist/icons/Check/index.css +1 -2
- package/dist/icons/Check/index.js +1 -1
- package/dist/icons/Check/index.js.map +1 -1
- package/dist/icons/Warning/index.css +1 -7
- package/dist/icons/Warning/index.d.ts +1 -1
- package/dist/icons/Warning/index.d.ts.map +1 -1
- package/dist/icons/Warning/index.js +11 -16
- package/dist/icons/Warning/index.js.map +1 -1
- package/dist/providers/ToastContainer/index.css +208 -0
- package/dist/providers/ToastContainer/index.d.ts +1 -0
- package/dist/providers/ToastContainer/index.d.ts.map +1 -1
- package/dist/providers/ToastContainer/index.js +19 -6
- package/dist/providers/ToastContainer/index.js.map +1 -1
- package/dist/scss/app.scss +7 -2
- package/dist/styles.css +1 -1
- package/dist/templates/Default/index.d.ts.map +1 -1
- package/dist/templates/Default/index.js +51 -9
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/utilities/reduceFieldsToOptions.js +1 -1
- package/dist/utilities/reduceFieldsToOptions.js.map +1 -1
- package/dist/views/HierarchyList/DocumentListSelection/index.js +4 -4
- package/dist/views/HierarchyList/DocumentListSelection/index.js.map +1 -1
- package/dist/views/List/ListSelection/index.js +4 -4
- package/dist/views/List/ListSelection/index.js.map +1 -1
- package/dist/views/List/index.client.d.ts.map +1 -1
- package/dist/views/List/index.client.js +3 -3
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/views/List/renderListViewSlots.d.ts.map +1 -1
- package/dist/views/List/renderListViewSlots.js +9 -6
- package/dist/views/List/renderListViewSlots.js.map +1 -1
- package/dist/views/Logout/LogoutClient.js +1 -1
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Versions/index.css +0 -4
- package/package.json +5 -5
- package/dist/elements/ColumnSelector/index.d.ts +0 -9
- package/dist/elements/ColumnSelector/index.d.ts.map +0 -1
- package/dist/elements/ColumnSelector/index.js.map +0 -1
- package/dist/elements/ColumnsButton/index.d.ts +0 -7
- package/dist/elements/ColumnsButton/index.d.ts.map +0 -1
- package/dist/elements/ColumnsButton/index.js.map +0 -1
- package/dist/elements/GroupByBuilder/index.d.ts +0 -12
- package/dist/elements/GroupByBuilder/index.d.ts.map +0 -1
- package/dist/elements/GroupByBuilder/index.js +0 -164
- package/dist/elements/GroupByBuilder/index.js.map +0 -1
- package/dist/elements/GroupByBuilder/index.scss +0 -39
- package/dist/elements/GroupByControl/index.d.ts +0 -9
- package/dist/elements/GroupByControl/index.d.ts.map +0 -1
- package/dist/elements/GroupByControl/index.js +0 -254
- package/dist/elements/GroupByControl/index.js.map +0 -1
- package/dist/elements/QueryPresets/fields/ColumnsField/index.scss +0 -17
- package/dist/elements/QueryPresets/fields/GroupByField/index.scss +0 -17
- package/dist/elements/QueryPresets/fields/WhereField/index.scss +0 -23
- package/dist/scss/toasts.scss +0 -146
- /package/dist/elements/{ColumnSelector/index.css → ColumnSelection/Popup.css} +0 -0
- /package/dist/elements/{GroupByControl/index.css → GroupBy/Popup.css} +0 -0
|
@@ -120,6 +120,8 @@ export const DocumentDrawerHeader = ({
|
|
|
120
120
|
}
|
|
121
121
|
}, [isModified, openModal, closeModal, drawerSlug]);
|
|
122
122
|
const showLockedMetaIcon = user && readOnlyForIncomingUser;
|
|
123
|
+
const showBeforeMeta = Boolean(showLockedMetaIcon || BeforeDocumentMeta);
|
|
124
|
+
const showMeta = showBeforeMeta || showStatus || showUpdatedAt || showAutosave;
|
|
123
125
|
return /*#__PURE__*/_jsxs("div", {
|
|
124
126
|
className: `${documentDrawerBaseClass}__header`,
|
|
125
127
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -149,9 +151,9 @@ export const DocumentDrawerHeader = ({
|
|
|
149
151
|
className: `${documentDrawerBaseClass}__title`,
|
|
150
152
|
element: "h2",
|
|
151
153
|
renderAsLink: renderTitleAsLink
|
|
152
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
154
|
+
}), showMeta ? /*#__PURE__*/_jsxs("div", {
|
|
153
155
|
className: `${documentDrawerBaseClass}__meta`,
|
|
154
|
-
children: [
|
|
156
|
+
children: [showBeforeMeta && /*#__PURE__*/_jsxs("div", {
|
|
155
157
|
className: `${documentDrawerBaseClass}__before-meta`,
|
|
156
158
|
children: [showLockedMetaIcon && /*#__PURE__*/_jsx(Locked, {
|
|
157
159
|
className: `${documentDrawerBaseClass}__locked-controls`,
|
|
@@ -172,7 +174,7 @@ export const DocumentDrawerHeader = ({
|
|
|
172
174
|
id: id,
|
|
173
175
|
publishedDocUpdatedAt: data?.createdAt
|
|
174
176
|
}) : null]
|
|
175
|
-
}), AfterHeader ? /*#__PURE__*/_jsx("div", {
|
|
177
|
+
}) : null, AfterHeader ? /*#__PURE__*/_jsx("div", {
|
|
176
178
|
className: `${documentDrawerBaseClass}__after-header`,
|
|
177
179
|
children: AfterHeader
|
|
178
180
|
}) : null]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getTranslation","hasAutosaveEnabled","hasDraftsEnabled","useCallback","useEffect","useRef","useState","useModal","RenderTitle","useFormModified","ChevronIcon","useConfig","useDocumentInfo","useTranslation","formatDate","formatTimeToNow","Autosave","Button","LeaveWithoutSavingModal","Locked","RenderCustomComponent","Status","documentDrawerBaseClass","leaveWithoutSavingModalSlug","DocumentDrawerHeader","actions","AfterHeader","BeforeDocumentMeta","drawerSlug","readOnlyForIncomingUser","renderTitleAsLink","CustomStatus","user","closeModal","openModal","i18n","t","config","getEntityConfig","isModified","id","collectionSlug","data","globalSlug","hasSavePermission","isEditing","isTrashed","collectionConfig","globalConfig","collectionHasDraftsEnabled","globalHasDraftsEnabled","autosaveEnabled","unsavedDraftWithValidations","versions","drafts","validate","showStatus","Boolean","showAutosave","singularLabel","labels","singular","label","headerLabel","updatedAt","createdAt","admin","dateFormat","relativeTime","setRelativeTime","formattedUpdatedAt","setFormattedUpdatedAt","formattedCreatedAt","setFormattedCreatedAt","i18nRef","current","date","update","interval","setInterval","clearInterval","pattern","showUpdatedAt","timestamps","handleOnClose","showLockedMetaIcon","_jsxs","className","_jsx","buttonStyle","icon","direction","size","onClick","element","renderAsLink","CustomComponent","Fallback","title","undefined","distance","collection","global","publishedDocUpdatedAt","modalSlug","onConfirm"],"sources":["../../../../src/elements/DocumentDrawer/DrawerHeader/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientUser } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nimport { useModal } from '../../../elements/Modal/index.js'\nimport { RenderTitle } from '../../../elements/RenderTitle/index.js'\nimport { useFormModified } from '../../../forms/Form/index.js'\nimport { ChevronIcon } from '../../../icons/Chevron/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatDate, formatTimeToNow } from '../../../utilities/formatDocTitle/formatDateTitle.js'\nimport { Autosave } from '../../Autosave/index.js'\nimport { Button } from '../../Button/index.js'\nimport { LeaveWithoutSavingModal } from '../../LeaveWithoutSaving/index.js'\nimport { Locked } from '../../Locked/index.js'\nimport { RenderCustomComponent } from '../../RenderCustomComponent/index.js'\nimport { Status } from '../../Status/index.js'\nimport { documentDrawerBaseClass } from '../index.js'\nimport './index.css'\n\nconst leaveWithoutSavingModalSlug = 'leave-without-saving-doc-drawer'\n\nexport const DocumentDrawerHeader: React.FC<{\n actions?: React.ReactNode\n AfterHeader?: React.ReactNode\n BeforeDocumentMeta?: React.ReactNode\n drawerSlug: string\n readOnlyForIncomingUser?: boolean\n renderTitleAsLink?: boolean\n Status?: React.ReactNode\n user?: ClientUser\n}> = ({\n actions,\n AfterHeader,\n BeforeDocumentMeta,\n drawerSlug,\n readOnlyForIncomingUser,\n renderTitleAsLink = true,\n Status: CustomStatus,\n user,\n}) => {\n const { closeModal, openModal } = useModal()\n const { i18n, t } = useTranslation()\n const { config, getEntityConfig } = useConfig()\n const isModified = useFormModified()\n const { id, collectionSlug, data, globalSlug, hasSavePermission, isEditing, isTrashed } =\n useDocumentInfo()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n const collectionHasDraftsEnabled = hasDraftsEnabled(collectionConfig)\n const globalHasDraftsEnabled = hasDraftsEnabled(globalConfig)\n const autosaveEnabled = hasAutosaveEnabled(collectionConfig) || hasAutosaveEnabled(globalConfig)\n\n const unsavedDraftWithValidations =\n !id && collectionConfig?.versions?.drafts && collectionConfig.versions?.drafts.validate\n\n const showStatus =\n (collectionHasDraftsEnabled || globalHasDraftsEnabled) &&\n (Boolean(globalConfig) || (Boolean(collectionConfig) && isEditing))\n\n const showAutosave =\n (collectionHasDraftsEnabled || globalHasDraftsEnabled) &&\n hasSavePermission &&\n autosaveEnabled &&\n !unsavedDraftWithValidations &&\n !isTrashed\n\n const singularLabel = getTranslation(\n collectionConfig?.labels?.singular ?? globalConfig?.label ?? t('general:document'),\n i18n,\n )\n\n const headerLabel = id\n ? `${t('general:editing')} ${singularLabel}`\n : t('general:creatingNewLabel', { label: singularLabel })\n\n const updatedAt = data?.updatedAt\n const createdAt = data?.createdAt\n\n const {\n admin: { dateFormat },\n } = config\n\n const [relativeTime, setRelativeTime] = useState<string>('')\n const [formattedUpdatedAt, setFormattedUpdatedAt] = useState<string>('')\n const [formattedCreatedAt, setFormattedCreatedAt] = useState<string>('')\n\n const i18nRef = useRef(i18n)\n i18nRef.current = i18n\n\n useEffect(() => {\n const date = updatedAt || createdAt\n\n if (!date) {\n setRelativeTime('')\n return\n }\n\n const update = () => setRelativeTime(formatTimeToNow({ date, i18n: i18nRef.current }))\n\n update()\n const interval = setInterval(update, 60000)\n return () => clearInterval(interval)\n }, [updatedAt, createdAt])\n\n useEffect(() => {\n if (updatedAt) {\n setFormattedUpdatedAt(formatDate({ date: updatedAt, i18n, pattern: dateFormat }))\n }\n if (createdAt) {\n setFormattedCreatedAt(formatDate({ date: createdAt, i18n, pattern: dateFormat }))\n }\n }, [updatedAt, createdAt, i18n, dateFormat])\n\n const showUpdatedAt = Boolean(\n collectionConfig?.timestamps && isEditing && (updatedAt || createdAt),\n )\n\n const handleOnClose = useCallback(() => {\n if (isModified) {\n openModal(leaveWithoutSavingModalSlug)\n } else {\n closeModal(drawerSlug)\n }\n }, [isModified, openModal, closeModal, drawerSlug])\n\n const showLockedMetaIcon = user && readOnlyForIncomingUser\n\n return (\n <div className={`${documentDrawerBaseClass}__header`}>\n <div className={`${documentDrawerBaseClass}__header-bar`}>\n <div className={`${documentDrawerBaseClass}__header-content`}>\n <Button\n aria-label={t('general:close')}\n buttonStyle=\"ghost\"\n className={`${documentDrawerBaseClass}__header-close`}\n icon={<ChevronIcon direction=\"left\" size={24} />}\n onClick={handleOnClose}\n />\n <span className={`${documentDrawerBaseClass}__header-text`}>{headerLabel}</span>\n </div>\n {actions ? (\n <div className={`${documentDrawerBaseClass}__header-actions`}>{actions}</div>\n ) : null}\n </div>\n\n <div className={`${documentDrawerBaseClass}__title-bar`}>\n <RenderTitle\n className={`${documentDrawerBaseClass}__title`}\n element=\"h2\"\n renderAsLink={renderTitleAsLink}\n />\n <div className={`${documentDrawerBaseClass}__meta`}>\n {Boolean(showLockedMetaIcon || BeforeDocumentMeta) && (\n <div className={`${documentDrawerBaseClass}__before-meta`}>\n {showLockedMetaIcon && (\n <Locked className={`${documentDrawerBaseClass}__locked-controls`} user={user} />\n )}\n {BeforeDocumentMeta}\n </div>\n )}\n {showStatus ? (\n <RenderCustomComponent CustomComponent={CustomStatus} Fallback={<Status />} />\n ) : null}\n {showUpdatedAt ? (\n <span\n className={`${documentDrawerBaseClass}__updated-at`}\n title={formattedUpdatedAt || formattedCreatedAt || undefined}\n >\n {relativeTime\n ? t(isTrashed ? 'general:deletedAgo' : 'general:updatedAgo', {\n distance: relativeTime,\n })\n : `${t('general:loading')}...`}\n </span>\n ) : null}\n {showAutosave ? (\n <Autosave\n collection={collectionConfig}\n global={globalConfig}\n id={id}\n publishedDocUpdatedAt={data?.createdAt}\n />\n ) : null}\n </div>\n {AfterHeader ? (\n <div className={`${documentDrawerBaseClass}__after-header`}>{AfterHeader}</div>\n ) : null}\n </div>\n\n <LeaveWithoutSavingModal\n modalSlug={leaveWithoutSavingModalSlug}\n onConfirm={() => closeModal(drawerSlug)}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ;AACrD,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEzD,SAASC,QAAQ,QAAQ;AACzB,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,EAAEC,eAAe,QAAQ;AAC5C,SAASC,QAAQ,QAAQ;AACzB,SAASC,MAAM,QAAQ;AACvB,SAASC,uBAAuB,QAAQ;AACxC,SAASC,MAAM,QAAQ;AACvB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,MAAM,QAAQ;AACvB,SAASC,uBAAuB,QAAQ;AACxC,OAAO;AAEP,MAAMC,2BAAA,GAA8B;AAEpC,OAAO,MAAMC,oBAAA,GASRA,CAAC;EACJC,OAAO;EACPC,WAAW;EACXC,kBAAkB;EAClBC,UAAU;EACVC,uBAAuB;EACvBC,iBAAA,GAAoB,IAAI;EAC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AQ;QACRC,YAAA,EAAcjE;uBAEhBwD,KAAA,CAAC;QAAIC,SAAA,EAAW,GAAGjE,uBAAA,QAA+B;mBAC/CmC,OAAA,CAAQ4B,kBAAA,IAAsB1D,kBAAA,kBAC7B2D,KAAA,CAAC;UAAIC,SAAA,EAAW,GAAGjE,uBAAA,eAAsC;qBACtD+D,kBAAA,iBACCG,IAAA,CAACrE,MAAA;YAAOoE,SAAA,EAAW,GAAGjE,uBAAA,mBAA0C;YAAEU,IAAA,EAAMA;cAEzEL,kBAAA;YAGJ6B,UAAA,gBACCgC,IAAA,CAACpE,qBAAA;UAAsB4E,eAAA,EAAiBjE,YAAA;UAAckE,QAAA,eAAUT,IAAA,CAACnE,MAAA;aAC/D,MACH6D,aAAA,gBACCM,IAAA,CAAC;UACCD,SAAA,EAAW,GAAGjE,uBAAA,cAAqC;UACnD4E,KAAA,EAAO5B,kBAAA,IAAsBE,kBAAA,IAAsB2B,SAAA;oBAElD/B,YAAA,GACGhC,CAAA,CAAEU,SAAA,GAAY,uBAAuB,sBAAsB;YACzDsD,QAAA,EAAUhC;UACZ,KACA,GAAGhC,CAAA,CAAE;aAET,MACHsB,YAAA,gBACC8B,IAAA,CAACxE,QAAA;UACCqF,UAAA,EAAYtD,gBAAA;UACZuD,MAAA,EAAQtD,YAAA;UACRR,EAAA,EAAIA,EAAA;UACJ+D,qBAAA,EAAuB7D,IAAA,EAAMuB;aAE7B;UAELvC,WAAA,gBACC8D,IAAA,CAAC;QAAID,SAAA,EAAW,GAAGjE,uBAAA,gBAAuC;kBAAGI;WAC3D;qBAGN8D,IAAA,CAACtE,uBAAA;MACCsF,SAAA,EAAWjF,2BAAA;MACXkF,SAAA,EAAWA,CAAA,KAAMxE,UAAA,CAAWL,UAAA;;;AAIpC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","hasAutosaveEnabled","hasDraftsEnabled","useCallback","useEffect","useRef","useState","useModal","RenderTitle","useFormModified","ChevronIcon","useConfig","useDocumentInfo","useTranslation","formatDate","formatTimeToNow","Autosave","Button","LeaveWithoutSavingModal","Locked","RenderCustomComponent","Status","documentDrawerBaseClass","leaveWithoutSavingModalSlug","DocumentDrawerHeader","actions","AfterHeader","BeforeDocumentMeta","drawerSlug","readOnlyForIncomingUser","renderTitleAsLink","CustomStatus","user","closeModal","openModal","i18n","t","config","getEntityConfig","isModified","id","collectionSlug","data","globalSlug","hasSavePermission","isEditing","isTrashed","collectionConfig","globalConfig","collectionHasDraftsEnabled","globalHasDraftsEnabled","autosaveEnabled","unsavedDraftWithValidations","versions","drafts","validate","showStatus","Boolean","showAutosave","singularLabel","labels","singular","label","headerLabel","updatedAt","createdAt","admin","dateFormat","relativeTime","setRelativeTime","formattedUpdatedAt","setFormattedUpdatedAt","formattedCreatedAt","setFormattedCreatedAt","i18nRef","current","date","update","interval","setInterval","clearInterval","pattern","showUpdatedAt","timestamps","handleOnClose","showLockedMetaIcon","showBeforeMeta","showMeta","_jsxs","className","_jsx","buttonStyle","icon","direction","size","onClick","element","renderAsLink","CustomComponent","Fallback","title","undefined","distance","collection","global","publishedDocUpdatedAt","modalSlug","onConfirm"],"sources":["../../../../src/elements/DocumentDrawer/DrawerHeader/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientUser } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { hasAutosaveEnabled, hasDraftsEnabled } from 'payload/shared'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nimport { useModal } from '../../../elements/Modal/index.js'\nimport { RenderTitle } from '../../../elements/RenderTitle/index.js'\nimport { useFormModified } from '../../../forms/Form/index.js'\nimport { ChevronIcon } from '../../../icons/Chevron/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatDate, formatTimeToNow } from '../../../utilities/formatDocTitle/formatDateTitle.js'\nimport { Autosave } from '../../Autosave/index.js'\nimport { Button } from '../../Button/index.js'\nimport { LeaveWithoutSavingModal } from '../../LeaveWithoutSaving/index.js'\nimport { Locked } from '../../Locked/index.js'\nimport { RenderCustomComponent } from '../../RenderCustomComponent/index.js'\nimport { Status } from '../../Status/index.js'\nimport { documentDrawerBaseClass } from '../index.js'\nimport './index.css'\n\nconst leaveWithoutSavingModalSlug = 'leave-without-saving-doc-drawer'\n\nexport const DocumentDrawerHeader: React.FC<{\n actions?: React.ReactNode\n AfterHeader?: React.ReactNode\n BeforeDocumentMeta?: React.ReactNode\n drawerSlug: string\n readOnlyForIncomingUser?: boolean\n renderTitleAsLink?: boolean\n Status?: React.ReactNode\n user?: ClientUser\n}> = ({\n actions,\n AfterHeader,\n BeforeDocumentMeta,\n drawerSlug,\n readOnlyForIncomingUser,\n renderTitleAsLink = true,\n Status: CustomStatus,\n user,\n}) => {\n const { closeModal, openModal } = useModal()\n const { i18n, t } = useTranslation()\n const { config, getEntityConfig } = useConfig()\n const isModified = useFormModified()\n const { id, collectionSlug, data, globalSlug, hasSavePermission, isEditing, isTrashed } =\n useDocumentInfo()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n const collectionHasDraftsEnabled = hasDraftsEnabled(collectionConfig)\n const globalHasDraftsEnabled = hasDraftsEnabled(globalConfig)\n const autosaveEnabled = hasAutosaveEnabled(collectionConfig) || hasAutosaveEnabled(globalConfig)\n\n const unsavedDraftWithValidations =\n !id && collectionConfig?.versions?.drafts && collectionConfig.versions?.drafts.validate\n\n const showStatus =\n (collectionHasDraftsEnabled || globalHasDraftsEnabled) &&\n (Boolean(globalConfig) || (Boolean(collectionConfig) && isEditing))\n\n const showAutosave =\n (collectionHasDraftsEnabled || globalHasDraftsEnabled) &&\n hasSavePermission &&\n autosaveEnabled &&\n !unsavedDraftWithValidations &&\n !isTrashed\n\n const singularLabel = getTranslation(\n collectionConfig?.labels?.singular ?? globalConfig?.label ?? t('general:document'),\n i18n,\n )\n\n const headerLabel = id\n ? `${t('general:editing')} ${singularLabel}`\n : t('general:creatingNewLabel', { label: singularLabel })\n\n const updatedAt = data?.updatedAt\n const createdAt = data?.createdAt\n\n const {\n admin: { dateFormat },\n } = config\n\n const [relativeTime, setRelativeTime] = useState<string>('')\n const [formattedUpdatedAt, setFormattedUpdatedAt] = useState<string>('')\n const [formattedCreatedAt, setFormattedCreatedAt] = useState<string>('')\n\n const i18nRef = useRef(i18n)\n i18nRef.current = i18n\n\n useEffect(() => {\n const date = updatedAt || createdAt\n\n if (!date) {\n setRelativeTime('')\n return\n }\n\n const update = () => setRelativeTime(formatTimeToNow({ date, i18n: i18nRef.current }))\n\n update()\n const interval = setInterval(update, 60000)\n return () => clearInterval(interval)\n }, [updatedAt, createdAt])\n\n useEffect(() => {\n if (updatedAt) {\n setFormattedUpdatedAt(formatDate({ date: updatedAt, i18n, pattern: dateFormat }))\n }\n if (createdAt) {\n setFormattedCreatedAt(formatDate({ date: createdAt, i18n, pattern: dateFormat }))\n }\n }, [updatedAt, createdAt, i18n, dateFormat])\n\n const showUpdatedAt = Boolean(\n collectionConfig?.timestamps && isEditing && (updatedAt || createdAt),\n )\n\n const handleOnClose = useCallback(() => {\n if (isModified) {\n openModal(leaveWithoutSavingModalSlug)\n } else {\n closeModal(drawerSlug)\n }\n }, [isModified, openModal, closeModal, drawerSlug])\n\n const showLockedMetaIcon = user && readOnlyForIncomingUser\n\n const showBeforeMeta = Boolean(showLockedMetaIcon || BeforeDocumentMeta)\n const showMeta = showBeforeMeta || showStatus || showUpdatedAt || showAutosave\n\n return (\n <div className={`${documentDrawerBaseClass}__header`}>\n <div className={`${documentDrawerBaseClass}__header-bar`}>\n <div className={`${documentDrawerBaseClass}__header-content`}>\n <Button\n aria-label={t('general:close')}\n buttonStyle=\"ghost\"\n className={`${documentDrawerBaseClass}__header-close`}\n icon={<ChevronIcon direction=\"left\" size={24} />}\n onClick={handleOnClose}\n />\n <span className={`${documentDrawerBaseClass}__header-text`}>{headerLabel}</span>\n </div>\n {actions ? (\n <div className={`${documentDrawerBaseClass}__header-actions`}>{actions}</div>\n ) : null}\n </div>\n\n <div className={`${documentDrawerBaseClass}__title-bar`}>\n <RenderTitle\n className={`${documentDrawerBaseClass}__title`}\n element=\"h2\"\n renderAsLink={renderTitleAsLink}\n />\n {showMeta ? (\n <div className={`${documentDrawerBaseClass}__meta`}>\n {showBeforeMeta && (\n <div className={`${documentDrawerBaseClass}__before-meta`}>\n {showLockedMetaIcon && (\n <Locked className={`${documentDrawerBaseClass}__locked-controls`} user={user} />\n )}\n {BeforeDocumentMeta}\n </div>\n )}\n {showStatus ? (\n <RenderCustomComponent CustomComponent={CustomStatus} Fallback={<Status />} />\n ) : null}\n {showUpdatedAt ? (\n <span\n className={`${documentDrawerBaseClass}__updated-at`}\n title={formattedUpdatedAt || formattedCreatedAt || undefined}\n >\n {relativeTime\n ? t(isTrashed ? 'general:deletedAgo' : 'general:updatedAgo', {\n distance: relativeTime,\n })\n : `${t('general:loading')}...`}\n </span>\n ) : null}\n {showAutosave ? (\n <Autosave\n collection={collectionConfig}\n global={globalConfig}\n id={id}\n publishedDocUpdatedAt={data?.createdAt}\n />\n ) : null}\n </div>\n ) : null}\n {AfterHeader ? (\n <div className={`${documentDrawerBaseClass}__after-header`}>{AfterHeader}</div>\n ) : null}\n </div>\n\n <LeaveWithoutSavingModal\n modalSlug={leaveWithoutSavingModalSlug}\n onConfirm={() => closeModal(drawerSlug)}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ;AACrD,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEzD,SAASC,QAAQ,QAAQ;AACzB,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SA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hC,CAAA,CAAE;aAET,MACHsB,YAAA,gBACCgC,IAAA,CAAC1E,QAAA;UACCuF,UAAA,EAAYxD,gBAAA;UACZyD,MAAA,EAAQxD,YAAA;UACRR,EAAA,EAAIA,EAAA;UACJiE,qBAAA,EAAuB/D,IAAA,EAAMuB;aAE7B;WAEJ,MACHvC,WAAA,gBACCgE,IAAA,CAAC;QAAID,SAAA,EAAW,GAAGnE,uBAAA,gBAAuC;kBAAGI;WAC3D;qBAGNgE,IAAA,CAACxE,uBAAA;MACCwF,SAAA,EAAWnF,2BAAA;MACXoF,SAAA,EAAWA,CAAA,KAAM1E,UAAA,CAAWL,UAAA;;;AAIpC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ReducedField } from '../WhereBuilder/types.js';
|
|
3
|
+
import './Popup.css';
|
|
4
|
+
export type GroupByPopupProps = {
|
|
5
|
+
/** Closes the parent popup. */
|
|
6
|
+
readonly close: () => void;
|
|
7
|
+
/** The selectable, permission-filtered fields. */
|
|
8
|
+
readonly filteredFields: ReducedField[];
|
|
9
|
+
/** The currently selected field, if any. */
|
|
10
|
+
readonly groupByField?: ReducedField;
|
|
11
|
+
/** The selected field path with any leading `-` stripped. */
|
|
12
|
+
readonly groupByFieldName?: string;
|
|
13
|
+
/** Whether a field is currently selected. */
|
|
14
|
+
readonly isActive: boolean;
|
|
15
|
+
/** Called with the next `groupBy` value (prefixed with `-` for descending). */
|
|
16
|
+
readonly onChange: (groupBy: string) => void;
|
|
17
|
+
/** The current `groupBy` value (prefixed with `-` for descending). */
|
|
18
|
+
readonly value: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const GroupByPopup: React.FC<GroupByPopupProps>;
|
|
21
|
+
//# sourceMappingURL=Popup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["../../../src/elements/GroupBy/Popup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAQ5D,OAAO,aAAa,CAAA;AAEpB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,kDAAkD;IAClD,QAAQ,CAAC,cAAc,EAAE,YAAY,EAAE,CAAA;IACvC,4CAA4C;IAC5C,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAA;IACpC,6DAA6D;IAC7D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAID,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8JpD,CAAA"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
import { ChevronIcon } from '../../icons/Chevron/index.js';
|
|
7
|
+
import { TrashIcon } from '../../icons/Trash/index.js';
|
|
8
|
+
import { XIcon } from '../../icons/X/index.js';
|
|
9
|
+
import { useTranslation } from '../../providers/Translation/index.js';
|
|
10
|
+
import { Button } from '../Button/index.js';
|
|
11
|
+
import { Popup, PopupList } from '../Popup/index.js';
|
|
12
|
+
import './Popup.css';
|
|
13
|
+
const baseClass = 'group-by-control';
|
|
14
|
+
export const GroupByPopup = t0 => {
|
|
15
|
+
const $ = _c(35);
|
|
16
|
+
const {
|
|
17
|
+
close,
|
|
18
|
+
filteredFields,
|
|
19
|
+
groupByField,
|
|
20
|
+
groupByFieldName,
|
|
21
|
+
isActive,
|
|
22
|
+
onChange,
|
|
23
|
+
value
|
|
24
|
+
} = t0;
|
|
25
|
+
const {
|
|
26
|
+
t
|
|
27
|
+
} = useTranslation();
|
|
28
|
+
const directionValue = !value || typeof value !== "string" ? "asc" : value.startsWith("-") ? "desc" : "asc";
|
|
29
|
+
let t1;
|
|
30
|
+
if ($[0] !== onChange || $[1] !== value) {
|
|
31
|
+
t1 = fieldPath => {
|
|
32
|
+
onChange(value?.startsWith("-") ? `-${fieldPath}` : fieldPath);
|
|
33
|
+
};
|
|
34
|
+
$[0] = onChange;
|
|
35
|
+
$[1] = value;
|
|
36
|
+
$[2] = t1;
|
|
37
|
+
} else {
|
|
38
|
+
t1 = $[2];
|
|
39
|
+
}
|
|
40
|
+
const handleFieldSelect = t1;
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[3] !== close || $[4] !== onChange) {
|
|
43
|
+
t2 = () => {
|
|
44
|
+
onChange("");
|
|
45
|
+
close();
|
|
46
|
+
};
|
|
47
|
+
$[3] = close;
|
|
48
|
+
$[4] = onChange;
|
|
49
|
+
$[5] = t2;
|
|
50
|
+
} else {
|
|
51
|
+
t2 = $[5];
|
|
52
|
+
}
|
|
53
|
+
const handleClear = t2;
|
|
54
|
+
let t3;
|
|
55
|
+
if ($[6] !== groupByFieldName || $[7] !== onChange) {
|
|
56
|
+
t3 = direction => {
|
|
57
|
+
if (!groupByFieldName) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
onChange(direction === "asc" ? groupByFieldName : `-${groupByFieldName}`);
|
|
61
|
+
};
|
|
62
|
+
$[6] = groupByFieldName;
|
|
63
|
+
$[7] = onChange;
|
|
64
|
+
$[8] = t3;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[8];
|
|
67
|
+
}
|
|
68
|
+
const handleDirectionSelect = t3;
|
|
69
|
+
let t4;
|
|
70
|
+
if ($[9] !== close || $[10] !== directionValue || $[11] !== filteredFields || $[12] !== groupByField?.label || $[13] !== groupByFieldName || $[14] !== handleClear || $[15] !== handleDirectionSelect || $[16] !== handleFieldSelect || $[17] !== isActive || $[18] !== t) {
|
|
71
|
+
let t5;
|
|
72
|
+
if ($[20] !== filteredFields || $[21] !== groupByFieldName || $[22] !== handleFieldSelect) {
|
|
73
|
+
t5 = t6 => {
|
|
74
|
+
const {
|
|
75
|
+
close: closeFieldPopup
|
|
76
|
+
} = t6;
|
|
77
|
+
return _jsx(PopupList.RadioGroup, {
|
|
78
|
+
children: filteredFields.map((field, i) => _jsx(PopupList.RadioGroupItem, {
|
|
79
|
+
active: field.fieldPath === groupByFieldName,
|
|
80
|
+
onClick: () => {
|
|
81
|
+
handleFieldSelect(field.fieldPath);
|
|
82
|
+
closeFieldPopup();
|
|
83
|
+
},
|
|
84
|
+
children: field.label
|
|
85
|
+
}, i))
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
$[20] = filteredFields;
|
|
89
|
+
$[21] = groupByFieldName;
|
|
90
|
+
$[22] = handleFieldSelect;
|
|
91
|
+
$[23] = t5;
|
|
92
|
+
} else {
|
|
93
|
+
t5 = $[23];
|
|
94
|
+
}
|
|
95
|
+
let t6;
|
|
96
|
+
if ($[24] !== groupByField?.label || $[25] !== t) {
|
|
97
|
+
t6 = t7 => {
|
|
98
|
+
const {
|
|
99
|
+
active,
|
|
100
|
+
onClick,
|
|
101
|
+
onKeyDown
|
|
102
|
+
} = t7;
|
|
103
|
+
return _jsxs("button", {
|
|
104
|
+
className: `${baseClass}__select-trigger`,
|
|
105
|
+
onClick,
|
|
106
|
+
onKeyDown,
|
|
107
|
+
type: "button",
|
|
108
|
+
children: [_jsx("span", {
|
|
109
|
+
className: `${baseClass}__select-value`,
|
|
110
|
+
children: groupByField?.label || t("general:selectValue")
|
|
111
|
+
}), _jsx(ChevronIcon, {
|
|
112
|
+
direction: active ? "up" : "down",
|
|
113
|
+
size: 16
|
|
114
|
+
})]
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
$[24] = groupByField?.label;
|
|
118
|
+
$[25] = t;
|
|
119
|
+
$[26] = t6;
|
|
120
|
+
} else {
|
|
121
|
+
t6 = $[26];
|
|
122
|
+
}
|
|
123
|
+
let t7;
|
|
124
|
+
if ($[27] !== directionValue || $[28] !== handleDirectionSelect || $[29] !== t) {
|
|
125
|
+
t7 = t8 => {
|
|
126
|
+
const {
|
|
127
|
+
close: closeSortPopup
|
|
128
|
+
} = t8;
|
|
129
|
+
return _jsxs(PopupList.RadioGroup, {
|
|
130
|
+
children: [_jsx(PopupList.RadioGroupItem, {
|
|
131
|
+
active: directionValue === "desc",
|
|
132
|
+
onClick: () => {
|
|
133
|
+
handleDirectionSelect("desc");
|
|
134
|
+
closeSortPopup();
|
|
135
|
+
},
|
|
136
|
+
children: t("general:descending")
|
|
137
|
+
}), _jsx(PopupList.RadioGroupItem, {
|
|
138
|
+
active: directionValue === "asc",
|
|
139
|
+
onClick: () => {
|
|
140
|
+
handleDirectionSelect("asc");
|
|
141
|
+
closeSortPopup();
|
|
142
|
+
},
|
|
143
|
+
children: t("general:ascending")
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
$[27] = directionValue;
|
|
148
|
+
$[28] = handleDirectionSelect;
|
|
149
|
+
$[29] = t;
|
|
150
|
+
$[30] = t7;
|
|
151
|
+
} else {
|
|
152
|
+
t7 = $[30];
|
|
153
|
+
}
|
|
154
|
+
let t8;
|
|
155
|
+
if ($[31] !== directionValue || $[32] !== groupByFieldName || $[33] !== t) {
|
|
156
|
+
t8 = t9 => {
|
|
157
|
+
const {
|
|
158
|
+
active: active_0,
|
|
159
|
+
onClick: onClick_0,
|
|
160
|
+
onKeyDown: onKeyDown_0
|
|
161
|
+
} = t9;
|
|
162
|
+
return _jsxs("button", {
|
|
163
|
+
className: [`${baseClass}__select-trigger`, !groupByFieldName && `${baseClass}__select-trigger--disabled`].filter(Boolean).join(" "),
|
|
164
|
+
disabled: !groupByFieldName,
|
|
165
|
+
onClick: onClick_0,
|
|
166
|
+
onKeyDown: onKeyDown_0,
|
|
167
|
+
type: "button",
|
|
168
|
+
children: [_jsx("span", {
|
|
169
|
+
className: `${baseClass}__select-value`,
|
|
170
|
+
children: directionValue === "desc" ? t("general:descending") : t("general:ascending")
|
|
171
|
+
}), _jsx(ChevronIcon, {
|
|
172
|
+
direction: active_0 ? "up" : "down",
|
|
173
|
+
size: 16
|
|
174
|
+
})]
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
$[31] = directionValue;
|
|
178
|
+
$[32] = groupByFieldName;
|
|
179
|
+
$[33] = t;
|
|
180
|
+
$[34] = t8;
|
|
181
|
+
} else {
|
|
182
|
+
t8 = $[34];
|
|
183
|
+
}
|
|
184
|
+
t4 = _jsxs("div", {
|
|
185
|
+
className: `${baseClass}__content`,
|
|
186
|
+
children: [_jsxs("div", {
|
|
187
|
+
className: `${baseClass}__header`,
|
|
188
|
+
children: [_jsx("span", {
|
|
189
|
+
className: `${baseClass}__title`,
|
|
190
|
+
children: t("general:groupByLabel", {
|
|
191
|
+
label: ""
|
|
192
|
+
})
|
|
193
|
+
}), _jsxs("div", {
|
|
194
|
+
className: `${baseClass}__header-actions`,
|
|
195
|
+
children: [isActive && _jsx(Button, {
|
|
196
|
+
"aria-label": t("general:clear"),
|
|
197
|
+
buttonStyle: "ghost",
|
|
198
|
+
icon: _jsx(TrashIcon, {}),
|
|
199
|
+
onClick: handleClear,
|
|
200
|
+
round: true,
|
|
201
|
+
size: "medium"
|
|
202
|
+
}), _jsx(Button, {
|
|
203
|
+
"aria-label": t("general:close"),
|
|
204
|
+
buttonStyle: "ghost",
|
|
205
|
+
icon: _jsx(XIcon, {
|
|
206
|
+
size: 24
|
|
207
|
+
}),
|
|
208
|
+
onClick: close,
|
|
209
|
+
round: true,
|
|
210
|
+
size: "medium"
|
|
211
|
+
})]
|
|
212
|
+
})]
|
|
213
|
+
}), _jsxs("div", {
|
|
214
|
+
className: `${baseClass}__body`,
|
|
215
|
+
children: [_jsxs("div", {
|
|
216
|
+
className: `${baseClass}__row`,
|
|
217
|
+
children: [_jsx("label", {
|
|
218
|
+
className: `${baseClass}__label`,
|
|
219
|
+
children: t("general:field")
|
|
220
|
+
}), _jsx("div", {
|
|
221
|
+
className: `${baseClass}__input`,
|
|
222
|
+
"data-popup-prevent-close": true,
|
|
223
|
+
children: _jsx(Popup, {
|
|
224
|
+
className: `${baseClass}__select-popup`,
|
|
225
|
+
horizontalAlign: "right",
|
|
226
|
+
render: t5,
|
|
227
|
+
renderButton: t6,
|
|
228
|
+
size: "medium",
|
|
229
|
+
verticalAlign: "bottom"
|
|
230
|
+
})
|
|
231
|
+
})]
|
|
232
|
+
}), _jsxs("div", {
|
|
233
|
+
className: `${baseClass}__row`,
|
|
234
|
+
children: [_jsx("label", {
|
|
235
|
+
className: `${baseClass}__label`,
|
|
236
|
+
children: t("general:sort")
|
|
237
|
+
}), _jsx("div", {
|
|
238
|
+
className: `${baseClass}__input`,
|
|
239
|
+
"data-popup-prevent-close": true,
|
|
240
|
+
children: _jsx(Popup, {
|
|
241
|
+
className: `${baseClass}__select-popup`,
|
|
242
|
+
disabled: !groupByFieldName,
|
|
243
|
+
horizontalAlign: "right",
|
|
244
|
+
render: t7,
|
|
245
|
+
renderButton: t8,
|
|
246
|
+
size: "small",
|
|
247
|
+
verticalAlign: "bottom"
|
|
248
|
+
})
|
|
249
|
+
})]
|
|
250
|
+
})]
|
|
251
|
+
})]
|
|
252
|
+
});
|
|
253
|
+
$[9] = close;
|
|
254
|
+
$[10] = directionValue;
|
|
255
|
+
$[11] = filteredFields;
|
|
256
|
+
$[12] = groupByField?.label;
|
|
257
|
+
$[13] = groupByFieldName;
|
|
258
|
+
$[14] = handleClear;
|
|
259
|
+
$[15] = handleDirectionSelect;
|
|
260
|
+
$[16] = handleFieldSelect;
|
|
261
|
+
$[17] = isActive;
|
|
262
|
+
$[18] = t;
|
|
263
|
+
$[19] = t4;
|
|
264
|
+
} else {
|
|
265
|
+
t4 = $[19];
|
|
266
|
+
}
|
|
267
|
+
return t4;
|
|
268
|
+
};
|
|
269
|
+
//# sourceMappingURL=Popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popup.js","names":["c","_c","React","useCallback","ChevronIcon","TrashIcon","XIcon","useTranslation","Button","Popup","PopupList","baseClass","GroupByPopup","t0","$","close","filteredFields","groupByField","groupByFieldName","isActive","onChange","value","t","directionValue","startsWith","t1","fieldPath","handleFieldSelect","t2","handleClear","t3","direction","handleDirectionSelect","t4","label","t5","t6","closeFieldPopup","_jsx","RadioGroup","children","map","field","i","RadioGroupItem","active","onClick","t7","onKeyDown","_jsxs","className","type","size","t8","closeSortPopup","t9","active_0","onClick_0","onKeyDown_0","filter","Boolean","join","disabled","buttonStyle","icon","round","horizontalAlign","render","verticalAlign"],"sources":["../../../src/elements/GroupBy/Popup.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback } from 'react'\n\nimport type { ReducedField } from '../WhereBuilder/types.js'\n\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { TrashIcon } from '../../icons/Trash/index.js'\nimport { XIcon } from '../../icons/X/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Button } from '../Button/index.js'\nimport { Popup, PopupList } from '../Popup/index.js'\nimport './Popup.css'\n\nexport type GroupByPopupProps = {\n /** Closes the parent popup. */\n readonly close: () => void\n /** The selectable, permission-filtered fields. */\n readonly filteredFields: ReducedField[]\n /** The currently selected field, if any. */\n readonly groupByField?: ReducedField\n /** The selected field path with any leading `-` stripped. */\n readonly groupByFieldName?: string\n /** Whether a field is currently selected. */\n readonly isActive: boolean\n /** Called with the next `groupBy` value (prefixed with `-` for descending). */\n readonly onChange: (groupBy: string) => void\n /** The current `groupBy` value (prefixed with `-` for descending). */\n readonly value: string\n}\n\nconst baseClass = 'group-by-control'\n\nexport const GroupByPopup: React.FC<GroupByPopupProps> = ({\n close,\n filteredFields,\n groupByField,\n groupByFieldName,\n isActive,\n onChange,\n value,\n}) => {\n const { t } = useTranslation()\n\n const directionValue =\n !value || typeof value !== 'string' ? 'asc' : value.startsWith('-') ? 'desc' : 'asc'\n\n const handleFieldSelect = useCallback(\n (fieldPath: string) => {\n onChange(value?.startsWith('-') ? `-${fieldPath}` : fieldPath)\n },\n [onChange, value],\n )\n\n const handleClear = useCallback(() => {\n onChange('')\n close()\n }, [onChange, close])\n\n const handleDirectionSelect = useCallback(\n (direction: 'asc' | 'desc') => {\n if (!groupByFieldName) {\n return\n }\n onChange(direction === 'asc' ? groupByFieldName : `-${groupByFieldName}`)\n },\n [groupByFieldName, onChange],\n )\n\n return (\n <div className={`${baseClass}__content`}>\n <div className={`${baseClass}__header`}>\n <span className={`${baseClass}__title`}>{t('general:groupByLabel', { label: '' })}</span>\n <div className={`${baseClass}__header-actions`}>\n {isActive && (\n <Button\n aria-label={t('general:clear')}\n buttonStyle=\"ghost\"\n icon={<TrashIcon />}\n onClick={handleClear}\n round\n size=\"medium\"\n />\n )}\n <Button\n aria-label={t('general:close')}\n buttonStyle=\"ghost\"\n icon={<XIcon size={24} />}\n onClick={close}\n round\n size=\"medium\"\n />\n </div>\n </div>\n <div className={`${baseClass}__body`}>\n <div className={`${baseClass}__row`}>\n <label className={`${baseClass}__label`}>{t('general:field')}</label>\n <div className={`${baseClass}__input`} data-popup-prevent-close>\n <Popup\n className={`${baseClass}__select-popup`}\n horizontalAlign=\"right\"\n render={({ close: closeFieldPopup }) => (\n <PopupList.RadioGroup>\n {filteredFields.map((field, i) => (\n <PopupList.RadioGroupItem\n active={field.fieldPath === groupByFieldName}\n key={i}\n onClick={() => {\n handleFieldSelect(field.fieldPath)\n closeFieldPopup()\n }}\n >\n {field.label}\n </PopupList.RadioGroupItem>\n ))}\n </PopupList.RadioGroup>\n )}\n renderButton={({ active, onClick, onKeyDown }) => (\n <button\n className={`${baseClass}__select-trigger`}\n onClick={onClick}\n onKeyDown={onKeyDown}\n type=\"button\"\n >\n <span className={`${baseClass}__select-value`}>\n {groupByField?.label || t('general:selectValue')}\n </span>\n <ChevronIcon direction={active ? 'up' : 'down'} size={16} />\n </button>\n )}\n size=\"medium\"\n verticalAlign=\"bottom\"\n />\n </div>\n </div>\n <div className={`${baseClass}__row`}>\n <label className={`${baseClass}__label`}>{t('general:sort')}</label>\n <div className={`${baseClass}__input`} data-popup-prevent-close>\n <Popup\n className={`${baseClass}__select-popup`}\n disabled={!groupByFieldName}\n horizontalAlign=\"right\"\n render={({ close: closeSortPopup }) => (\n <PopupList.RadioGroup>\n <PopupList.RadioGroupItem\n active={directionValue === 'desc'}\n onClick={() => {\n handleDirectionSelect('desc')\n closeSortPopup()\n }}\n >\n {t('general:descending')}\n </PopupList.RadioGroupItem>\n <PopupList.RadioGroupItem\n active={directionValue === 'asc'}\n onClick={() => {\n handleDirectionSelect('asc')\n closeSortPopup()\n }}\n >\n {t('general:ascending')}\n </PopupList.RadioGroupItem>\n </PopupList.RadioGroup>\n )}\n renderButton={({ active, onClick, onKeyDown }) => (\n <button\n className={[\n `${baseClass}__select-trigger`,\n !groupByFieldName && `${baseClass}__select-trigger--disabled`,\n ]\n .filter(Boolean)\n .join(' ')}\n disabled={!groupByFieldName}\n onClick={onClick}\n onKeyDown={onKeyDown}\n type=\"button\"\n >\n <span className={`${baseClass}__select-value`}>\n {directionValue === 'desc' ? t('general:descending') : t('general:ascending')}\n </span>\n <ChevronIcon direction={active ? 'up' : 'down'} size={16} />\n </button>\n )}\n size=\"small\"\n verticalAlign=\"bottom\"\n />\n </div>\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,IAASC,WAAW,QAAQ;AAInC,SAASC,WAAW,QAAQ;AAC5B,SAASC,SAAS,QAAQ;AAC1B,SAASC,KAAK,QAAQ;AACtB,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jCF,IAAA,CAAC;YAAAY,SAAA,EAAiB,GAAAvC,SAAA,SAAqB;YAAA6B,QAAA,EAAGlB,CAAA,CAAE;UAAA,C,GAC5CgB,IAAA,CAAC;YAAAY,SAAA,EAAe,GAAAvC,SAAA,SAAqB;YAAA;YAAA6B,QAAA,EACnCF,IAAA,CAAA7B,KAAA;cAAAyC,SAAA,EACa,GAAAvC,SAAA,gBAA4B;cAAAuD,eAAA,EACvB;cAAAC,MAAA,EACRhC,E;4BAgBMC,E;oBAaT;cAAAgC,aAAA,EACS;YAAA,C;;YAIpBnB,KAAA,CAAC;UAAAC,SAAA,EAAe,GAAAvC,SAAA,OAAmB;UAAA6B,QAAA,GACjCF,IAAA,CAAC;YAAAY,SAAA,EAAiB,GAAAvC,SAAA,SAAqB;YAAA6B,QAAA,EAAGlB,CAAA,CAAE;UAAA,C,GAC5CgB,IAAA,CAAC;YAAAY,SAAA,EAAe,GAAAvC,SAAA,SAAqB;YAAA;YAAA6B,QAAA,EACnCF,IAAA,CAAA7B,KAAA;cAAAyC,SAAA,EACa,GAAAvC,SAAA,gBAA4B;cAAAmD,QAAA,GAC5B5C,gBAAA;cAAAgD,eAAA,EACK;cAAAC,MAAA,EACRpB,E;4BAsBMM,E;oBAmBT;cAAAe,aAAA,EACS;YAAA,C;;;;;;;;;;;;;;;;;;;SAlHxBnC,E;CAyHJ","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ClientField, SanitizedCollectionConfig } from 'payload';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type GroupByButtonProps = {
|
|
4
|
+
readonly collectionSlug: SanitizedCollectionConfig['slug'];
|
|
5
|
+
readonly fields: ClientField[];
|
|
6
|
+
/** Called with the next `groupBy` value (prefixed with `-` for descending). */
|
|
7
|
+
readonly onChange: (groupBy: string) => void;
|
|
8
|
+
/** The current `groupBy` value (prefixed with `-` for descending). */
|
|
9
|
+
readonly value: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const GroupByButton: React.FC<GroupByButtonProps>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/GroupBy/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAS,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAG5E,OAAO,KAAkB,MAAM,OAAO,CAAA;AAUtC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAC1D,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAoBD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAiFtD,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { isFieldDisabled } from 'payload/shared';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
import { ChevronIcon } from '../../icons/Chevron/index.js';
|
|
7
|
+
import { useAuth } from '../../providers/Auth/index.js';
|
|
8
|
+
import { useTranslation } from '../../providers/Translation/index.js';
|
|
9
|
+
import { reduceFieldsToOptions } from '../../utilities/reduceFieldsToOptions.js';
|
|
10
|
+
import { Button } from '../Button/index.js';
|
|
11
|
+
import { Popup } from '../Popup/index.js';
|
|
12
|
+
import { GroupByPopup } from './Popup.js';
|
|
13
|
+
const baseClass = 'group-by-control';
|
|
14
|
+
/**
|
|
15
|
+
* Supported field types for group by functionality.
|
|
16
|
+
*/
|
|
17
|
+
const supportedFieldTypes = ['text', 'textarea', 'number', 'select', 'relationship', 'date', 'checkbox', 'radio', 'email', 'upload'];
|
|
18
|
+
export const GroupByButton = ({
|
|
19
|
+
collectionSlug,
|
|
20
|
+
fields,
|
|
21
|
+
onChange,
|
|
22
|
+
value
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
i18n,
|
|
26
|
+
t
|
|
27
|
+
} = useTranslation();
|
|
28
|
+
const {
|
|
29
|
+
permissions
|
|
30
|
+
} = useAuth();
|
|
31
|
+
const groupByFieldName = value?.replace(/^-/, '');
|
|
32
|
+
const fieldPermissions = permissions?.collections?.[collectionSlug]?.fields;
|
|
33
|
+
const reducedFields = useMemo(() => reduceFieldsToOptions({
|
|
34
|
+
fieldPermissions,
|
|
35
|
+
fields,
|
|
36
|
+
i18n
|
|
37
|
+
}), [fields, fieldPermissions, i18n]);
|
|
38
|
+
const filteredFields = useMemo(() => reducedFields.filter(field => !isFieldDisabled(field.field, 'groupBy') && field.fieldPath !== 'id' && supportedFieldTypes.includes(field.field.type)), [reducedFields]);
|
|
39
|
+
const groupByField = reducedFields.find(field_0 => field_0.fieldPath === groupByFieldName);
|
|
40
|
+
const isActive = Boolean(groupByFieldName && groupByField);
|
|
41
|
+
if (filteredFields.length === 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const triggerLabel = isActive ? t('general:groupByLabel', {
|
|
45
|
+
label: groupByField?.label || ''
|
|
46
|
+
}) : t('general:groupByLabel', {
|
|
47
|
+
label: ''
|
|
48
|
+
});
|
|
49
|
+
return /*#__PURE__*/_jsx(Popup, {
|
|
50
|
+
className: baseClass,
|
|
51
|
+
horizontalAlign: "right",
|
|
52
|
+
portalClassName: `${baseClass}__popup`,
|
|
53
|
+
render: ({
|
|
54
|
+
close
|
|
55
|
+
}) => /*#__PURE__*/_jsx(GroupByPopup, {
|
|
56
|
+
close: close,
|
|
57
|
+
filteredFields: filteredFields,
|
|
58
|
+
groupByField: groupByField,
|
|
59
|
+
groupByFieldName: groupByFieldName,
|
|
60
|
+
isActive: isActive,
|
|
61
|
+
onChange: onChange,
|
|
62
|
+
value: value
|
|
63
|
+
}),
|
|
64
|
+
renderButton: ({
|
|
65
|
+
active,
|
|
66
|
+
onClick,
|
|
67
|
+
onKeyDown,
|
|
68
|
+
...ariaProps
|
|
69
|
+
}) => /*#__PURE__*/_jsx(Button, {
|
|
70
|
+
buttonStyle: "secondary",
|
|
71
|
+
className: `${baseClass}__trigger`,
|
|
72
|
+
extraButtonProps: {
|
|
73
|
+
onKeyDown
|
|
74
|
+
},
|
|
75
|
+
icon: /*#__PURE__*/_jsx(ChevronIcon, {
|
|
76
|
+
direction: active ? 'up' : 'down',
|
|
77
|
+
size: 16
|
|
78
|
+
}),
|
|
79
|
+
id: "toggle-group-by",
|
|
80
|
+
onClick: onClick,
|
|
81
|
+
selected: active || isActive,
|
|
82
|
+
size: "medium",
|
|
83
|
+
...ariaProps,
|
|
84
|
+
children: triggerLabel
|
|
85
|
+
}),
|
|
86
|
+
size: "large",
|
|
87
|
+
theme: "auto",
|
|
88
|
+
verticalAlign: "bottom"
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["isFieldDisabled","React","useMemo","ChevronIcon","useAuth","useTranslation","reduceFieldsToOptions","Button","Popup","GroupByPopup","baseClass","supportedFieldTypes","GroupByButton","collectionSlug","fields","onChange","value","i18n","t","permissions","groupByFieldName","replace","fieldPermissions","collections","reducedFields","filteredFields","filter","field","fieldPath","includes","type","groupByField","find","isActive","Boolean","length","triggerLabel","label","_jsx","className","horizontalAlign","portalClassName","render","close","renderButton","active","onClick","onKeyDown","ariaProps","buttonStyle","extraButtonProps","icon","direction","size","id","selected","theme","verticalAlign"],"sources":["../../../src/elements/GroupBy/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, Field, SanitizedCollectionConfig } from 'payload'\n\nimport { isFieldDisabled } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { reduceFieldsToOptions } from '../../utilities/reduceFieldsToOptions.js'\nimport { Button } from '../Button/index.js'\nimport { Popup } from '../Popup/index.js'\nimport { GroupByPopup } from './Popup.js'\n\nexport type GroupByButtonProps = {\n readonly collectionSlug: SanitizedCollectionConfig['slug']\n readonly fields: ClientField[]\n /** Called with the next `groupBy` value (prefixed with `-` for descending). */\n readonly onChange: (groupBy: string) => void\n /** The current `groupBy` value (prefixed with `-` for descending). */\n readonly value: string\n}\n\nconst baseClass = 'group-by-control'\n\n/**\n * Supported field types for group by functionality.\n */\nconst supportedFieldTypes: Field['type'][] = [\n 'text',\n 'textarea',\n 'number',\n 'select',\n 'relationship',\n 'date',\n 'checkbox',\n 'radio',\n 'email',\n 'upload',\n]\n\nexport const GroupByButton: React.FC<GroupByButtonProps> = ({\n collectionSlug,\n fields,\n onChange,\n value,\n}) => {\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n\n const groupByFieldName = value?.replace(/^-/, '')\n\n const fieldPermissions = permissions?.collections?.[collectionSlug]?.fields\n\n const reducedFields = useMemo(\n () =>\n reduceFieldsToOptions({\n fieldPermissions,\n fields,\n i18n,\n }),\n [fields, fieldPermissions, i18n],\n )\n\n const filteredFields = useMemo(\n () =>\n reducedFields.filter(\n (field) =>\n !isFieldDisabled(field.field, 'groupBy') &&\n field.fieldPath !== 'id' &&\n supportedFieldTypes.includes(field.field.type),\n ),\n [reducedFields],\n )\n\n const groupByField = reducedFields.find((field) => field.fieldPath === groupByFieldName)\n const isActive = Boolean(groupByFieldName && groupByField)\n\n if (filteredFields.length === 0) {\n return null\n }\n\n const triggerLabel = isActive\n ? t('general:groupByLabel', { label: groupByField?.label || '' })\n : t('general:groupByLabel', { label: '' })\n\n return (\n <Popup\n className={baseClass}\n horizontalAlign=\"right\"\n portalClassName={`${baseClass}__popup`}\n render={({ close }) => (\n <GroupByPopup\n close={close}\n filteredFields={filteredFields}\n groupByField={groupByField}\n groupByFieldName={groupByFieldName}\n isActive={isActive}\n onChange={onChange}\n value={value}\n />\n )}\n renderButton={({ active, onClick, onKeyDown, ...ariaProps }) => (\n <Button\n buttonStyle=\"secondary\"\n className={`${baseClass}__trigger`}\n extraButtonProps={{ onKeyDown }}\n icon={<ChevronIcon direction={active ? 'up' : 'down'} size={16} />}\n id=\"toggle-group-by\"\n onClick={onClick}\n selected={active || isActive}\n size=\"medium\"\n {...ariaProps}\n >\n {triggerLabel}\n </Button>\n )}\n size=\"large\"\n theme=\"auto\"\n verticalAlign=\"bottom\"\n />\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,eAAe,QAAQ;AAChC,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,WAAW,QAAQ;AAC5B,SAASC,OAAO,QAAQ;AACxB,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,MAAM,QAAQ;AACvB,SAASC,KAAK,QAAQ;AACtB,SAASC,YAAY,QAAQ;AAW7B,MAAMC,SAAA,GAAY;AAElB;;;AAGA,MAAMC,mBAAA,GAAuC,CAC3C,QACA,YACA,UACA,UACA,gBACA,QACA,YACA,SACA,SACA,SACD;AAED,OAAO,MAAMC,aAAA,GAA8CA,CAAC;EAC1DC,cAAc;EACdC,MAAM;EACNC,QAAQ;EACRC;AAAK,CACN;EACC,MAAM;IAAEC,IAAI;IAAEC;EAAC,CAAE,GAAGb,cAAA;EACpB,MAAM;IAAEc;EAAW,CAAE,GAAGf,OAAA;EAExB,MAAMgB,gBAAA,GAAmBJ,KAAA,EAAOK,OAAA,CAAQ,MAAM;EAE9C,MAAMC,gBAAA,GAAmBH,WAAA,EAAaI,WAAA,GAAcV,cAAA,CAAe,EAAEC,MAAA;EAErE,MAAMU,aAAA,GAAgBtB,OAAA,CACpB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GAAGC;IAAA,CAAW,kBACzDV,IAAA,CAAC/B,MAAA;MACC0C,WAAA,EAAY;MACZV,SAAA,EAAW,GAAG7B,SAAA,WAAoB;MAClCwC,gBAAA,EAAkB;QAAEH;MAAU;MAC9BI,IAAA,eAAMb,IAAA,CAACnC,WAAA;QAAYiD,SAAA,EAAWP,MAAA,GAAS,OAAO;QAAQQ,IAAA,EAAM;;MAC5DC,EAAA,EAAG;MACHR,OAAA,EAASA,OAAA;MACTS,QAAA,EAAUV,MAAA,IAAUZ,QAAA;MACpBoB,IAAA,EAAK;MACJ,GAAGL,SAAS;gBAEZZ;;IAGLiB,IAAA,EAAK;IACLG,KAAA,EAAM;IACNC,aAAA,EAAc;;AAGpB","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SanitizedCollectionConfig } from 'payload';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type ListColumnSelectionButtonProps = {
|
|
4
|
+
readonly collectionSlug: SanitizedCollectionConfig['slug'];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Connects the presentational {@link ColumnSelectionButton} to the table columns state, so the
|
|
8
|
+
* button itself stays unaware of where its column state is stored.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ListColumnSelectionButton: React.FC<ListColumnSelectionButtonProps>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ListColumnSelectionButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;CAC3D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,8BAA8B,CAY9E,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { useTableColumns } from '../../providers/TableColumns/index.js';
|
|
7
|
+
import { ColumnSelectionButton } from '../ColumnSelection/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Connects the presentational {@link ColumnSelectionButton} to the table columns state, so the
|
|
10
|
+
* button itself stays unaware of where its column state is stored.
|
|
11
|
+
*/
|
|
12
|
+
export const ListColumnSelectionButton = t0 => {
|
|
13
|
+
const $ = _c(4);
|
|
14
|
+
const {
|
|
15
|
+
collectionSlug
|
|
16
|
+
} = t0;
|
|
17
|
+
const {
|
|
18
|
+
columns,
|
|
19
|
+
setColumns
|
|
20
|
+
} = useTableColumns();
|
|
21
|
+
let t1;
|
|
22
|
+
if ($[0] !== collectionSlug || $[1] !== columns || $[2] !== setColumns) {
|
|
23
|
+
t1 = _jsx(ColumnSelectionButton, {
|
|
24
|
+
collectionSlug,
|
|
25
|
+
columns,
|
|
26
|
+
onChange: setColumns
|
|
27
|
+
});
|
|
28
|
+
$[0] = collectionSlug;
|
|
29
|
+
$[1] = columns;
|
|
30
|
+
$[2] = setColumns;
|
|
31
|
+
$[3] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t1 = $[3];
|
|
34
|
+
}
|
|
35
|
+
return t1;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","useTableColumns","ColumnSelectionButton","ListColumnSelectionButton","t0","$","collectionSlug","columns","setColumns","t1","_jsx","onChange"],"sources":["../../../src/elements/ListColumnSelectionButton/index.tsx"],"sourcesContent":["'use client'\n\nimport type { SanitizedCollectionConfig } from 'payload'\n\nimport React from 'react'\n\nimport { useTableColumns } from '../../providers/TableColumns/index.js'\nimport { ColumnSelectionButton } from '../ColumnSelection/index.js'\n\nexport type ListColumnSelectionButtonProps = {\n readonly collectionSlug: SanitizedCollectionConfig['slug']\n}\n\n/**\n * Connects the presentational {@link ColumnSelectionButton} to the table columns state, so the\n * button itself stays unaware of where its column state is stored.\n */\nexport const ListColumnSelectionButton: React.FC<ListColumnSelectionButtonProps> = ({\n collectionSlug,\n}) => {\n const { columns, setColumns } = useTableColumns()\n\n return (\n <ColumnSelectionButton\n collectionSlug={collectionSlug}\n columns={columns}\n onChange={setColumns}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,OAAOC,KAAA,MAAW;AAElB,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AAMtC;;;;AAIA,OAAO,MAAMC,yBAAA,GAAsEC,EAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAAC;IAAAO;EAAA,IAAAF,EAEnF;EACC;IAAAG,OAAA;IAAAC;EAAA,IAAgCP,eAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAJ,CAAA,QAAAC,cAAA,IAAAD,CAAA,QAAAE,OAAA,IAAAF,CAAA,QAAAG,UAAA;IAG9BC,EAAA,GAAAC,IAAA,CAAAR,qBAAA;MAAAI,cAAA;MAAAC,OAAA;MAAAI,QAAA,EAGYH;IAAA,C;;;;;;;;SAHZC,E;CAMJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ListControls/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgD,MAAM,OAAO,CAAA;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAanD,OAAO,aAAa,CAAA;AAIpB;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ListControls/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgD,MAAM,OAAO,CAAA;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAanD,OAAO,aAAa,CAAA;AAIpB;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA2JpD,CAAA"}
|