@payloadcms/ui 3.6.1-canary.5e04db9 → 3.6.1-canary.ca44922
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/elements/Button/index.d.ts +1 -1
- package/dist/elements/Button/index.d.ts.map +1 -1
- package/dist/elements/Button/index.js +4 -3
- package/dist/elements/Button/index.js.map +1 -1
- package/dist/elements/Button/types.d.ts +1 -0
- package/dist/elements/Button/types.d.ts.map +1 -1
- package/dist/elements/Button/types.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js +5 -5
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/index.d.ts +1 -1
- package/dist/elements/DocumentDrawer/index.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/index.js +3 -3
- package/dist/elements/DocumentDrawer/index.js.map +1 -1
- package/dist/elements/EditUpload/index.d.ts.map +1 -1
- package/dist/elements/EditUpload/index.js +4 -3
- package/dist/elements/EditUpload/index.js.map +1 -1
- package/dist/elements/EmailAndUsername/index.d.ts.map +1 -1
- package/dist/elements/EmailAndUsername/index.js +3 -0
- package/dist/elements/EmailAndUsername/index.js.map +1 -1
- package/dist/elements/Gutter/index.d.ts +2 -1
- package/dist/elements/Gutter/index.d.ts.map +1 -1
- package/dist/elements/Gutter/index.js +4 -3
- package/dist/elements/Gutter/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.scss +16 -0
- package/dist/exports/client/index.d.ts +8 -2
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +2 -2
- package/dist/fields/Tabs/index.d.ts +0 -15
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +2 -2
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/forms/Submit/index.d.ts +1 -1
- package/dist/forms/Submit/index.d.ts.map +1 -1
- package/dist/forms/Submit/index.js +5 -4
- package/dist/forms/Submit/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +1 -0
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/getClientConfig.d.ts.map +1 -1
- package/dist/utilities/getClientConfig.js.map +1 -1
- package/dist/utilities/groupNavItems.d.ts.map +1 -1
- package/dist/utilities/groupNavItems.js +4 -0
- package/dist/utilities/groupNavItems.js.map +1 -1
- package/package.json +4 -4
|
@@ -7,5 +7,5 @@ export declare const ButtonContents: ({ children, icon, showTooltip, tooltip }:
|
|
|
7
7
|
showTooltip: any;
|
|
8
8
|
tooltip: any;
|
|
9
9
|
}) => React.JSX.Element;
|
|
10
|
-
export declare const Button: React.
|
|
10
|
+
export declare const Button: React.FC<Props>;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Button/index.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Button/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmC,MAAM,OAAO,CAAA;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAUvC,OAAO,cAAc,CAAA;AAarB,eAAO,MAAM,cAAc;;;;;uBAqB1B,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAqJlC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { Fragment, isValidElement } from 'react';
|
|
5
5
|
import { ChevronIcon } from '../../icons/Chevron/index.js';
|
|
6
6
|
import { EditIcon } from '../../icons/Edit/index.js';
|
|
7
7
|
import { LinkIcon } from '../../icons/Link/index.js';
|
|
@@ -44,7 +44,7 @@ export const ButtonContents = ({
|
|
|
44
44
|
})]
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
-
export const Button =
|
|
47
|
+
export const Button = props => {
|
|
48
48
|
const {
|
|
49
49
|
id,
|
|
50
50
|
type = 'button',
|
|
@@ -61,6 +61,7 @@ export const Button = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
61
61
|
newTab,
|
|
62
62
|
onClick,
|
|
63
63
|
onMouseDown,
|
|
64
|
+
ref,
|
|
64
65
|
round,
|
|
65
66
|
size = 'medium',
|
|
66
67
|
SubMenuPopupContent,
|
|
@@ -172,5 +173,5 @@ export const Button = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
172
173
|
});
|
|
173
174
|
}
|
|
174
175
|
return buttonElement;
|
|
175
|
-
}
|
|
176
|
+
};
|
|
176
177
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","forwardRef","Fragment","isValidElement","ChevronIcon","EditIcon","LinkIcon","PlusIcon","SwapIcon","XIcon","Popup","Tooltip","icons","chevron","edit","link","plus","swap","x","baseClass","ButtonContents","children","icon","showTooltip","tooltip","BuiltInIcon","_jsxs","_jsx","className","show","Button","props","ref","id","type","ariaLabel","buttonStyle","disabled","el","iconPosition","iconStyle","Link","newTab","onClick","onMouseDown","round","size","SubMenuPopupContent","to","url","setShowTooltip","useState","classes","filter","Boolean","join","handleClick","event","preventDefault","styleClasses","buttonProps","undefined","onPointerEnter","onPointerLeave","rel","target","buttonElement","prefetch","href","console","error","LinkTag","Tag","button","buttonSize","horizontalAlign","noBackground","render","close","verticalAlign"],"sources":["../../../src/elements/Button/index.tsx"],"sourcesContent":["'use client'\nimport React, { forwardRef, Fragment, isValidElement } from 'react'\n\nimport type { Props } from './types.js'\n\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { EditIcon } from '../../icons/Edit/index.js'\nimport { LinkIcon } from '../../icons/Link/index.js'\nimport { PlusIcon } from '../../icons/Plus/index.js'\nimport { SwapIcon } from '../../icons/Swap/index.js'\nimport { XIcon } from '../../icons/X/index.js'\nimport { Popup } from '../Popup/index.js'\nimport { Tooltip } from '../Tooltip/index.js'\nimport './index.scss'\n\nconst icons = {\n chevron: ChevronIcon,\n edit: EditIcon,\n link: LinkIcon,\n plus: PlusIcon,\n swap: SwapIcon,\n x: XIcon,\n}\n\nconst baseClass = 'btn'\n\nexport const ButtonContents = ({ children, icon, showTooltip, tooltip }) => {\n const BuiltInIcon = icons[icon]\n\n return (\n <Fragment>\n {tooltip && (\n <Tooltip className={`${baseClass}__tooltip`} show={showTooltip}>\n {tooltip}\n </Tooltip>\n )}\n <span className={`${baseClass}__content`}>\n {children && <span className={`${baseClass}__label`}>{children}</span>}\n {icon && (\n <span className={`${baseClass}__icon`}>\n {isValidElement(icon) && icon}\n {BuiltInIcon && <BuiltInIcon />}\n </span>\n )}\n </span>\n </Fragment>\n )\n}\n\nexport const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, Props>((props, ref) => {\n const {\n id,\n type = 'button',\n 'aria-label': ariaLabel,\n buttonStyle = 'primary',\n children,\n className,\n disabled,\n el = 'button',\n icon,\n iconPosition = 'right',\n iconStyle = 'without-border',\n Link,\n newTab,\n onClick,\n onMouseDown,\n round,\n size = 'medium',\n SubMenuPopupContent,\n to,\n tooltip,\n url,\n } = props\n\n const [showTooltip, setShowTooltip] = React.useState(false)\n\n const classes = [\n baseClass,\n className && className,\n icon && `${baseClass}--icon`,\n iconStyle && `${baseClass}--icon-style-${iconStyle}`,\n icon && !children && `${baseClass}--icon-only`,\n size && `${baseClass}--size-${size}`,\n icon && iconPosition && `${baseClass}--icon-position-${iconPosition}`,\n tooltip && `${baseClass}--has-tooltip`,\n !SubMenuPopupContent && `${baseClass}--withoutPopup`,\n ]\n .filter(Boolean)\n .join(' ')\n\n function handleClick(event) {\n setShowTooltip(false)\n if (type !== 'submit' && onClick) {\n event.preventDefault()\n }\n if (onClick) {\n onClick(event)\n }\n }\n\n const styleClasses = [\n buttonStyle && `${baseClass}--style-${buttonStyle}`,\n disabled && `${baseClass}--disabled`,\n round && `${baseClass}--round`,\n SubMenuPopupContent ? `${baseClass}--withPopup` : `${baseClass}--withoutPopup`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const buttonProps = {\n id,\n type,\n 'aria-disabled': disabled,\n 'aria-label': ariaLabel,\n className: !SubMenuPopupContent ? [classes, styleClasses].join(' ') : classes,\n disabled,\n onClick: !disabled ? handleClick : undefined,\n onMouseDown: !disabled ? onMouseDown : undefined,\n onPointerEnter: tooltip ? () => setShowTooltip(true) : undefined,\n onPointerLeave: tooltip ? () => setShowTooltip(false) : undefined,\n rel: newTab ? 'noopener noreferrer' : undefined,\n target: newTab ? '_blank' : undefined,\n }\n\n let buttonElement\n let prefetch\n\n switch (el) {\n case 'anchor':\n buttonElement = (\n <a\n {...buttonProps}\n href={!disabled ? url : undefined}\n ref={ref as React.Ref<HTMLAnchorElement>}\n >\n <ButtonContents icon={icon} showTooltip={showTooltip} tooltip={tooltip}>\n {children}\n </ButtonContents>\n </a>\n )\n break\n\n case 'link':\n if (!Link) {\n console.error('Link is required when using el=\"link\"', children)\n return null\n }\n\n let LinkTag = Link // eslint-disable-line no-case-declarations\n\n if (disabled) {\n LinkTag = 'div'\n } else {\n prefetch = false\n }\n\n buttonElement = (\n <LinkTag {...buttonProps} href={to || url} prefetch={prefetch} to={to || url}>\n <ButtonContents icon={icon} showTooltip={showTooltip} tooltip={tooltip}>\n {children}\n </ButtonContents>\n </LinkTag>\n )\n break\n\n default:\n const Tag = el // eslint-disable-line no-case-declarations\n\n buttonElement = (\n <Tag ref={ref} type=\"submit\" {...buttonProps}>\n <ButtonContents icon={icon} showTooltip={showTooltip} tooltip={tooltip}>\n {children}\n </ButtonContents>\n </Tag>\n )\n break\n }\n if (SubMenuPopupContent) {\n return (\n <div className={styleClasses}>\n {buttonElement}\n <Popup\n button={<ChevronIcon />}\n buttonSize={size}\n className={disabled ? `${baseClass}--popup-disabled` : ''}\n disabled={disabled}\n horizontalAlign=\"right\"\n noBackground\n render={({ close }) => SubMenuPopupContent({ close: () => close() })}\n size=\"large\"\n verticalAlign=\"bottom\"\n />\n </div>\n )\n }\n\n return buttonElement\n})\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,UAAU,EAAEC,QAAQ,EAAEC,cAAc,QAAQ;AAI5D,SAASC,WAAW,QAAQ;AAC5B,SAASC,QAAQ,QAAQ;AACzB,SAASC,QAAQ,QAAQ;AACzB,SAASC,QAAQ,QAAQ;AACzB,SAASC,QAAQ,QAAQ;AACzB,SAASC,KAAK,QAAQ;AACtB,SAASC,KAAK,QAAQ;AACtB,SAASC,OAAO,QAAQ;AACxB,OAAO;AAEP,MAAMC,KAAA,GAAQ;EACZC,OAAA,EAAST,WAAA;EACTU,IAAA,EAAMT,QAAA;EACNU,IAAA,EAAMT,QAAA;EACNU,IAAA,EAAMT,QAAA;EACNU,IAAA,EAAMT,QAAA;EACNU,CAAA,EAAGT;AACL;AAEA,MAAMU,SAAA,GAAY;AAElB,OAAO,MAAMC,cAAA,GAAiBA,CAAC;EAAEC,QAAQ;EAAEC,IAAI;EAAEC,WAAW;EAAEC;AAAO,CAAE;EACrE,MAAMC,WAAA,GAAcb,KAAK,CAACU,IAAA,CAAK;EAE/B,oBACEI,KAAA,CAACxB,QAAA;eACEsB,OAAA,iBACCG,IAAA,CAAChB,OAAA;MAAQiB,SAAA,EAAW,GAAGT,SAAA,WAAoB;MAAEU,IAAA,EAAMN,WAAA;gBAChDC;qBAGLE,KAAA,CAAC;MAAKE,SAAA,EAAW,GAAGT,SAAA,WAAoB;iBACrCE,QAAA,iBAAYM,IAAA,CAAC;QAAKC,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,GAAG;QACvDkB,QAAA,EAAUA,QAAA;QACVsC,eAAA,EAAgB;QAChBC,YAAY;QACZC,MAAA,EAAQA,CAAC;UAAEC;QAAK,CAAE,KAAK/B,mBAAA,CAAoB;UAAE+B,KAAA,EAAOA,CAAA,KAAMA,KAAA;QAAQ;QAClEhC,IAAA,EAAK;QACLiC,aAAA,EAAc;;;EAItB;EAEA,OAAOb,aAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","Fragment","isValidElement","ChevronIcon","EditIcon","LinkIcon","PlusIcon","SwapIcon","XIcon","Popup","Tooltip","icons","chevron","edit","link","plus","swap","x","baseClass","ButtonContents","children","icon","showTooltip","tooltip","BuiltInIcon","_jsxs","_jsx","className","show","Button","props","id","type","ariaLabel","buttonStyle","disabled","el","iconPosition","iconStyle","Link","newTab","onClick","onMouseDown","ref","round","size","SubMenuPopupContent","to","url","setShowTooltip","useState","classes","filter","Boolean","join","handleClick","event","preventDefault","styleClasses","buttonProps","undefined","onPointerEnter","onPointerLeave","rel","target","buttonElement","prefetch","href","console","error","LinkTag","Tag","button","buttonSize","horizontalAlign","noBackground","render","close","verticalAlign"],"sources":["../../../src/elements/Button/index.tsx"],"sourcesContent":["'use client'\nimport React, { Fragment, isValidElement } from 'react'\n\nimport type { Props } from './types.js'\n\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { EditIcon } from '../../icons/Edit/index.js'\nimport { LinkIcon } from '../../icons/Link/index.js'\nimport { PlusIcon } from '../../icons/Plus/index.js'\nimport { SwapIcon } from '../../icons/Swap/index.js'\nimport { XIcon } from '../../icons/X/index.js'\nimport { Popup } from '../Popup/index.js'\nimport { Tooltip } from '../Tooltip/index.js'\nimport './index.scss'\n\nconst icons = {\n chevron: ChevronIcon,\n edit: EditIcon,\n link: LinkIcon,\n plus: PlusIcon,\n swap: SwapIcon,\n x: XIcon,\n}\n\nconst baseClass = 'btn'\n\nexport const ButtonContents = ({ children, icon, showTooltip, tooltip }) => {\n const BuiltInIcon = icons[icon]\n\n return (\n <Fragment>\n {tooltip && (\n <Tooltip className={`${baseClass}__tooltip`} show={showTooltip}>\n {tooltip}\n </Tooltip>\n )}\n <span className={`${baseClass}__content`}>\n {children && <span className={`${baseClass}__label`}>{children}</span>}\n {icon && (\n <span className={`${baseClass}__icon`}>\n {isValidElement(icon) && icon}\n {BuiltInIcon && <BuiltInIcon />}\n </span>\n )}\n </span>\n </Fragment>\n )\n}\n\nexport const Button: React.FC<Props> = (props) => {\n const {\n id,\n type = 'button',\n 'aria-label': ariaLabel,\n buttonStyle = 'primary',\n children,\n className,\n disabled,\n el = 'button',\n icon,\n iconPosition = 'right',\n iconStyle = 'without-border',\n Link,\n newTab,\n onClick,\n onMouseDown,\n ref,\n round,\n size = 'medium',\n SubMenuPopupContent,\n to,\n tooltip,\n url,\n } = props\n\n const [showTooltip, setShowTooltip] = React.useState(false)\n\n const classes = [\n baseClass,\n className && className,\n icon && `${baseClass}--icon`,\n iconStyle && `${baseClass}--icon-style-${iconStyle}`,\n icon && !children && `${baseClass}--icon-only`,\n size && `${baseClass}--size-${size}`,\n icon && iconPosition && `${baseClass}--icon-position-${iconPosition}`,\n tooltip && `${baseClass}--has-tooltip`,\n !SubMenuPopupContent && `${baseClass}--withoutPopup`,\n ]\n .filter(Boolean)\n .join(' ')\n\n function handleClick(event) {\n setShowTooltip(false)\n if (type !== 'submit' && onClick) {\n event.preventDefault()\n }\n if (onClick) {\n onClick(event)\n }\n }\n\n const styleClasses = [\n buttonStyle && `${baseClass}--style-${buttonStyle}`,\n disabled && `${baseClass}--disabled`,\n round && `${baseClass}--round`,\n SubMenuPopupContent ? `${baseClass}--withPopup` : `${baseClass}--withoutPopup`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const buttonProps = {\n id,\n type,\n 'aria-disabled': disabled,\n 'aria-label': ariaLabel,\n className: !SubMenuPopupContent ? [classes, styleClasses].join(' ') : classes,\n disabled,\n onClick: !disabled ? handleClick : undefined,\n onMouseDown: !disabled ? onMouseDown : undefined,\n onPointerEnter: tooltip ? () => setShowTooltip(true) : undefined,\n onPointerLeave: tooltip ? () => setShowTooltip(false) : undefined,\n rel: newTab ? 'noopener noreferrer' : undefined,\n target: newTab ? '_blank' : undefined,\n }\n\n let buttonElement\n let prefetch\n\n switch (el) {\n case 'anchor':\n buttonElement = (\n <a\n {...buttonProps}\n href={!disabled ? url : undefined}\n ref={ref as React.RefObject<HTMLAnchorElement>}\n >\n <ButtonContents icon={icon} showTooltip={showTooltip} tooltip={tooltip}>\n {children}\n </ButtonContents>\n </a>\n )\n break\n\n case 'link':\n if (!Link) {\n console.error('Link is required when using el=\"link\"', children)\n return null\n }\n\n let LinkTag = Link // eslint-disable-line no-case-declarations\n\n if (disabled) {\n LinkTag = 'div'\n } else {\n prefetch = false\n }\n\n buttonElement = (\n <LinkTag {...buttonProps} href={to || url} prefetch={prefetch} to={to || url}>\n <ButtonContents icon={icon} showTooltip={showTooltip} tooltip={tooltip}>\n {children}\n </ButtonContents>\n </LinkTag>\n )\n break\n\n default:\n const Tag = el // eslint-disable-line no-case-declarations\n\n buttonElement = (\n <Tag ref={ref} type=\"submit\" {...buttonProps}>\n <ButtonContents icon={icon} showTooltip={showTooltip} tooltip={tooltip}>\n {children}\n </ButtonContents>\n </Tag>\n )\n break\n }\n if (SubMenuPopupContent) {\n return (\n <div className={styleClasses}>\n {buttonElement}\n <Popup\n button={<ChevronIcon />}\n buttonSize={size}\n className={disabled ? `${baseClass}--popup-disabled` : ''}\n disabled={disabled}\n horizontalAlign=\"right\"\n noBackground\n render={({ close }) => SubMenuPopupContent({ close: () => close() })}\n size=\"large\"\n verticalAlign=\"bottom\"\n />\n </div>\n )\n }\n\n return buttonElement\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,QAAQ,EAAEC,cAAc,QAAQ;AAIhD,SAASC,WAAW,QAAQ;AAC5B,SAASC,QAAQ,QAAQ;AACzB,SAASC,QAAQ,QAAQ;AACzB,SAASC,Q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AAA,EAAIA,EAAA,IAAMC,GAAA;kBACvE,aAAAtB,IAAA,CAACP,cAAA;UAAeE,IAAA,EAAMA,IAAA;UAAMC,WAAA,EAAaA,WAAA;UAAaC,OAAA,EAASA,OAAA;oBAC5DH;;;MAIP;IAEF;MACE,MAAMmD,GAAA,GAAMnC,EAAA,CAAG;MAAA;MAEf6B,aAAA,gBACEvC,IAAA,CAAC6C,GAAA;QAAI5B,GAAA,EAAKA,GAAA;QAAKX,IAAA,EAAK;QAAU,GAAG2B,WAAW;kBAC1C,aAAAjC,IAAA,CAACP,cAAA;UAAeE,IAAA,EAAMA,IAAA;UAAMC,WAAA,EAAaA,WAAA;UAAaC,OAAA,EAASA,OAAA;oBAC5DH;;;MAIP;EACJ;EACA,IAAI0B,mBAAA,EAAqB;IACvB,oBACErB,KAAA,CAAC;MAAIE,SAAA,EAAW+B,YAAA;iBACbO,aAAA,E,aACDvC,IAAA,CAACjB,KAAA;QACC+D,MAAA,eAAQ9C,IAAA,CAACvB,WAAA;QACTsE,UAAA,EAAY5B,IAAA;QACZlB,SAAA,EAAWQ,QAAA,GAAW,GAAGjB,SAAA,kBAA2B,GAAG;QACvDiB,QAAA,EAAUA,QAAA;QACVuC,eAAA,EAAgB;QAChBC,YAAY;QACZC,MAAA,EAAQA,CAAC;UAAEC;QAAK,CAAE,KAAK/B,mBAAA,CAAoB;UAAE+B,KAAA,EAAOA,CAAA,KAAMA,KAAA;QAAQ;QAClEhC,IAAA,EAAK;QACLiC,aAAA,EAAc;;;EAItB;EAEA,OAAOb,aAAA;AACT","ignoreList":[]}
|
|
@@ -28,6 +28,7 @@ export type Props = {
|
|
|
28
28
|
* @default false
|
|
29
29
|
*/
|
|
30
30
|
programmaticSubmit?: boolean;
|
|
31
|
+
ref?: React.RefObject<HTMLAnchorElement | HTMLButtonElement | null>;
|
|
31
32
|
round?: boolean;
|
|
32
33
|
secondaryActions?: secondaryAction | secondaryAction[];
|
|
33
34
|
size?: 'large' | 'medium' | 'small';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/elements/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACrC,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/elements/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,aAAa,CAAA;IAChG,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACpC,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAA;IAC5D,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,gBAAgB,CAAA;IACrD,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACxB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACzC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,iBAAiB,GAAG,IAAI,CAAC,CAAA;IACnE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,gBAAgB,CAAC,EAAE,eAAe,GAAG,eAAe,EAAE,CAAA;IACtD,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IACnC,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAA;IACvE,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/elements/Button/types.ts"],"sourcesContent":["import type { ElementType, MouseEvent } from 'react'\nimport type React from 'react'\n\ntype secondaryAction = {\n label: string\n onClick: (event: MouseEvent) => void\n}\nexport type Props = {\n 'aria-label'?: string\n buttonId?: string\n buttonStyle?: 'error' | 'icon-label' | 'none' | 'pill' | 'primary' | 'secondary' | 'transparent'\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n el?: 'anchor' | 'link' | ElementType\n icon?: ['chevron' | 'edit' | 'plus' | 'x'] | React.ReactNode\n iconPosition?: 'left' | 'right'\n iconStyle?: 'none' | 'with-border' | 'without-border'\n id?: string\n Link?: React.ElementType\n newTab?: boolean\n onClick?: (event: MouseEvent) => void\n onMouseDown?: (event: MouseEvent) => void\n /**\n * Enables form submission via an onClick handler. This is only needed if\n * type=\"submit\" does not trigger form submission, e.g. if the button DOM\n * element is not a direct child of the form element.\n *\n * @default false\n */\n programmaticSubmit?: boolean\n round?: boolean\n secondaryActions?: secondaryAction | secondaryAction[]\n size?: 'large' | 'medium' | 'small'\n SubMenuPopupContent?: (props: { close: () => void }) => React.ReactNode\n to?: string\n tooltip?: string\n type?: 'button' | 'submit'\n url?: string\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/elements/Button/types.ts"],"sourcesContent":["import type { ElementType, MouseEvent } from 'react'\nimport type React from 'react'\n\ntype secondaryAction = {\n label: string\n onClick: (event: MouseEvent) => void\n}\n\nexport type Props = {\n 'aria-label'?: string\n buttonId?: string\n buttonStyle?: 'error' | 'icon-label' | 'none' | 'pill' | 'primary' | 'secondary' | 'transparent'\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n el?: 'anchor' | 'link' | ElementType\n icon?: ['chevron' | 'edit' | 'plus' | 'x'] | React.ReactNode\n iconPosition?: 'left' | 'right'\n iconStyle?: 'none' | 'with-border' | 'without-border'\n id?: string\n Link?: React.ElementType\n newTab?: boolean\n onClick?: (event: MouseEvent) => void\n onMouseDown?: (event: MouseEvent) => void\n /**\n * Enables form submission via an onClick handler. This is only needed if\n * type=\"submit\" does not trigger form submission, e.g. if the button DOM\n * element is not a direct child of the form element.\n *\n * @default false\n */\n programmaticSubmit?: boolean\n ref?: React.RefObject<HTMLAnchorElement | HTMLButtonElement | null>\n round?: boolean\n secondaryActions?: secondaryAction | secondaryAction[]\n size?: 'large' | 'medium' | 'small'\n SubMenuPopupContent?: (props: { close: () => void }) => React.ReactNode\n to?: string\n tooltip?: string\n type?: 'button' | 'submit'\n url?: string\n}\n"],"mappings":"AAQA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/DocumentDrawer/DrawerHeader/index.tsx"],"names":[],"mappings":"AAUA,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,UAAU,EAAE,MAAM,CAAA;CACnB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/DocumentDrawer/DrawerHeader/index.tsx"],"names":[],"mappings":"AAUA,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,UAAU,EAAE,MAAM,CAAA;CACnB,CAsBA,CAAA"}
|
|
@@ -9,7 +9,7 @@ import { XIcon } from '../../../icons/X/index.js';
|
|
|
9
9
|
import { useDocumentInfo } from '../../../providers/DocumentInfo/index.js';
|
|
10
10
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
11
11
|
import { IDLabel } from '../../IDLabel/index.js';
|
|
12
|
-
import {
|
|
12
|
+
import { documentDrawerBaseClass } from '../index.js';
|
|
13
13
|
import './index.scss';
|
|
14
14
|
export const DocumentDrawerHeader = t0 => {
|
|
15
15
|
const $ = _c(7);
|
|
@@ -34,17 +34,17 @@ export const DocumentDrawerHeader = t0 => {
|
|
|
34
34
|
t2 = $[6];
|
|
35
35
|
}
|
|
36
36
|
t1 = _jsxs(Gutter, {
|
|
37
|
-
className: `${
|
|
37
|
+
className: `${documentDrawerBaseClass}__header`,
|
|
38
38
|
children: [_jsxs("div", {
|
|
39
|
-
className: `${
|
|
39
|
+
className: `${documentDrawerBaseClass}__header-content`,
|
|
40
40
|
children: [_jsx("h2", {
|
|
41
|
-
className: `${
|
|
41
|
+
className: `${documentDrawerBaseClass}__header-text`,
|
|
42
42
|
children: _jsx(RenderTitle, {
|
|
43
43
|
element: "span"
|
|
44
44
|
})
|
|
45
45
|
}), _jsx("button", {
|
|
46
46
|
"aria-label": t("general:close"),
|
|
47
|
-
className: `${
|
|
47
|
+
className: `${documentDrawerBaseClass}__header-close`,
|
|
48
48
|
onClick: t2,
|
|
49
49
|
type: "button",
|
|
50
50
|
children: _jsx(XIcon, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","Gutter","useModal","RenderTitle","XIcon","useDocumentInfo","useTranslation","IDLabel","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","Gutter","useModal","RenderTitle","XIcon","useDocumentInfo","useTranslation","IDLabel","documentDrawerBaseClass","DocumentDrawerHeader","t0","$","drawerSlug","closeModal","t","t1","t2","_jsxs","className","children","_jsx","element","onClick","type","DocumentTitle","id","title","toString"],"sources":["../../../../src/elements/DocumentDrawer/DrawerHeader/index.tsx"],"sourcesContent":["'use client'\n\nimport { Gutter } from '../../../elements/Gutter/index.js'\nimport { useModal } from '../../../elements/Modal/index.js'\nimport { RenderTitle } from '../../../elements/RenderTitle/index.js'\nimport { XIcon } from '../../../icons/X/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { IDLabel } from '../../IDLabel/index.js'\nimport { documentDrawerBaseClass } from '../index.js'\nimport './index.scss'\n\nexport const DocumentDrawerHeader: React.FC<{\n drawerSlug: string\n}> = ({ drawerSlug }) => {\n const { closeModal } = useModal()\n const { t } = useTranslation()\n\n return (\n <Gutter className={`${documentDrawerBaseClass}__header`}>\n <div className={`${documentDrawerBaseClass}__header-content`}>\n <h2 className={`${documentDrawerBaseClass}__header-text`}>\n {<RenderTitle element=\"span\" />}\n </h2>\n <button\n aria-label={t('general:close')}\n className={`${documentDrawerBaseClass}__header-close`}\n onClick={() => closeModal(drawerSlug)}\n type=\"button\"\n >\n <XIcon />\n </button>\n </div>\n <DocumentTitle />\n </Gutter>\n )\n}\n\nconst DocumentTitle: React.FC = () => {\n const { id, title } = useDocumentInfo()\n return id && id !== title ? <IDLabel id={id.toString()} /> : null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,MAAM,QAAQ;AACvB,SAASC,QAAQ,QAAQ;AACzB,SAASC,WAAW,QAAQ;AAC5B,SAASC,KAAK,QAAQ;AACtB,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,OAAO,QAAQ;AACxB,SAASC,uBAAuB,QAAQ;AACxC,OAAO;AAEP,OAAO,MAAMC,oBAAA,GAERC,EAAA;EAAA,MAAAC,CAAA,GAAAX,EAAA;EAAC;IAAAY;EAAA,IAAAF,EAAc;EAClB;IAAAG;EAAA,IAAuBX,QAAA;EACvB;IAAAY;EAAA,IAAcR,cAAA;EAAA,IAAAS,EAAA;EAAA,IAAAJ,CAAA,QAAAE,UAAA,IAAAF,CAAA,QAAAC,UAAA,IAAAD,CAAA,QAAAG,CAAA;IAAA,IAAAE,EAAA;IAAA,IAAAL,CAAA,QAAAE,UAAA,IAAAF,CAAA,QAAAC,UAAA;MAWGI,EAAA,GAAAA,CAAA,KAAMH,UAAA,CAAWD,UAAA;MAAAD,CAAA,MAAAE,UAAA;MAAAF,CAAA,MAAAC,UAAA;MAAAD,CAAA,MAAAK,EAAA;IAAA;MAAAA,EAAA,GAAAL,CAAA;IAAA;IARhCI,EAAA,GAAAE,KAAA,CAAAhB,MAAA;MAAAiB,SAAA,EAAmB,GAAAV,uBAAA,UAAoC;MAAAW,QAAA,GACrDF,KAAA,CAAC;QAAAC,SAAA,EAAe,GAAAV,uBAAA,kBAA4C;QAAAW,QAAA,GAC1DC,IAAA,CAAC;UAAAF,SAAA,EAAc,GAAAV,uBAAA,eAAyC;UAAAW,QAAA,EACrDC,IAAA,CAAAjB,WAAA;YAAAkB,OAAA,EAAqB;UAAA,C;YAExBD,IAAA,CAAC;UAAA,cACaN,CAAA,CAAE;UAAAI,SAAA,EACH,GAAAV,uBAAA,gBAA0C;UAAAc,OAAA,EAC5CN,EAAiB;UAAAO,IAAA,EACrB;UAAAJ,QAAA,EAELC,IAAA,CAAAhB,KAAA,IAAC;QAAA,C;UAGLgB,IAAA,CAAAI,aAAA,IAAC;IAAA,C;;;;;;;;SAdHT,E;CAiBJ;AAEA,MAAMS,aAAA,GAA0BA,CAAA;EAAA,MAAAb,CAAA,GAAAX,EAAA;EAC9B;IAAAyB,EAAA;IAAAC;EAAA,IAAsBrB,eAAA;EAAA,IAAAK,EAAA;EAAA,IAAAC,CAAA,QAAAc,EAAA,IAAAd,CAAA,QAAAe,KAAA;IACfhB,EAAA,GAAAe,EAAA,IAAMA,EAAA,KAAOC,KAAA,GAAQN,IAAA,CAAAb,OAAA;MAAAkB,EAAA,EAAaA,EAAA,CAAAE,QAAA,CAAW;IAAA,C,QAAS;IAAAhB,CAAA,MAAAc,EAAA;IAAAd,CAAA,MAAAe,KAAA;IAAAf,CAAA,MAAAD,EAAA;EAAA;IAAAA,EAAA,GAAAC,CAAA;EAAA;EAAA,OAAtDD,EAAsD;AAAA,CAC/D","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DocumentDrawerProps, DocumentTogglerProps, UseDocumentDrawer } from './types.js';
|
|
3
3
|
import './index.scss';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const documentDrawerBaseClass = "doc-drawer";
|
|
5
5
|
export declare const DocumentDrawerToggler: React.FC<DocumentTogglerProps>;
|
|
6
6
|
export declare const DocumentDrawer: React.FC<DocumentDrawerProps>;
|
|
7
7
|
export declare const useDocumentDrawer: UseDocumentDrawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/DocumentDrawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2D,MAAM,OAAO,CAAA;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAO9F,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/DocumentDrawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2D,MAAM,OAAO,CAAA;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAO9F,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,uBAAuB,eAAe,CAAA;AAcnD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2BhE,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAQxD,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,iBAsE/B,CAAA"}
|
|
@@ -11,7 +11,7 @@ import { useRelatedCollections } from '../AddNewRelation/useRelatedCollections.j
|
|
|
11
11
|
import { Drawer, DrawerToggler } from '../Drawer/index.js';
|
|
12
12
|
import { DocumentDrawerContent } from './DrawerContent.js';
|
|
13
13
|
import './index.scss';
|
|
14
|
-
export const
|
|
14
|
+
export const documentDrawerBaseClass = 'doc-drawer';
|
|
15
15
|
const formatDocumentDrawerSlug = ({
|
|
16
16
|
id,
|
|
17
17
|
collectionSlug,
|
|
@@ -71,7 +71,7 @@ export const DocumentDrawerToggler = t0 => {
|
|
|
71
71
|
});
|
|
72
72
|
let t5;
|
|
73
73
|
if ($[19] !== className) {
|
|
74
|
-
t5 = [className, `${
|
|
74
|
+
t5 = [className, `${documentDrawerBaseClass}__toggler`].filter(Boolean);
|
|
75
75
|
$[19] = className;
|
|
76
76
|
$[20] = t5;
|
|
77
77
|
} else {
|
|
@@ -106,7 +106,7 @@ export const DocumentDrawer = props => {
|
|
|
106
106
|
drawerSlug
|
|
107
107
|
} = props;
|
|
108
108
|
return /*#__PURE__*/_jsx(Drawer, {
|
|
109
|
-
className:
|
|
109
|
+
className: documentDrawerBaseClass,
|
|
110
110
|
gutter: false,
|
|
111
111
|
Header: null,
|
|
112
112
|
slug: drawerSlug,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useModal","React","useCallback","useEffect","useId","useMemo","useState","useEditDepth","useTranslation","useRelatedCollections","Drawer","DrawerToggler","DocumentDrawerContent","baseClass","formatDocumentDrawerSlug","id","collectionSlug","depth","uuid","DocumentDrawerToggler","t0","$","children","className","disabled","drawerSlug","onClick","rest","t","collectionConfig","t1","t2","labels","singular","t3","t4","label","t5","filter","Boolean","_jsx","join","slug","DocumentDrawer","props","gutter","Header","useDocumentDrawer","overrideEntityVisibility","editDepth","closeModal","modalState","openModal","toggleModal","isOpen","setIsOpen","toggleDrawer","closeDrawer","t6","openDrawer","t7","t8","_createElement","key","MemoizedDrawer","t9","t10","props_0","MemoizedDrawerToggler","t11","t12","drawerDepth","isDrawerOpen","MemoizedDrawerState","t13"],"sources":["../../../src/elements/DocumentDrawer/index.tsx"],"sourcesContent":["'use client'\nimport { useModal } from '@faceless-ui/modal'\nimport React, { useCallback, useEffect, useId, useMemo, useState } from 'react'\n\nimport type { DocumentDrawerProps, DocumentTogglerProps, UseDocumentDrawer } from './types.js'\n\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useRelatedCollections } from '../AddNewRelation/useRelatedCollections.js'\nimport { Drawer, DrawerToggler } from '../Drawer/index.js'\nimport { DocumentDrawerContent } from './DrawerContent.js'\nimport './index.scss'\n\nexport const baseClass = 'doc-drawer'\n\nconst formatDocumentDrawerSlug = ({\n id,\n collectionSlug,\n depth,\n uuid,\n}: {\n collectionSlug: string\n depth: number\n id: number | string\n uuid: string // supply when creating a new document and no id is available\n}) => `doc-drawer_${collectionSlug}_${depth}${id ? `_${id}` : ''}_${uuid}`\n\nexport const DocumentDrawerToggler: React.FC<DocumentTogglerProps> = ({\n id,\n children,\n className,\n collectionSlug,\n disabled,\n drawerSlug,\n onClick,\n ...rest\n}) => {\n const { t } = useTranslation()\n const [collectionConfig] = useRelatedCollections(collectionSlug)\n\n return (\n <DrawerToggler\n aria-label={t(!id ? 'fields:addNewLabel' : 'general:editLabel', {\n label: collectionConfig?.labels.singular,\n })}\n className={[className, `${baseClass}__toggler`].filter(Boolean).join(' ')}\n disabled={disabled}\n onClick={onClick}\n slug={drawerSlug}\n {...rest}\n >\n {children}\n </DrawerToggler>\n )\n}\n\nexport const DocumentDrawer: React.FC<DocumentDrawerProps> = (props) => {\n const { drawerSlug } = props\n\n return (\n <Drawer className={baseClass} gutter={false} Header={null} slug={drawerSlug}>\n <DocumentDrawerContent {...props} />\n </Drawer>\n )\n}\n\nexport const useDocumentDrawer: UseDocumentDrawer = ({\n id,\n collectionSlug,\n overrideEntityVisibility,\n}) => {\n const editDepth = useEditDepth()\n const uuid = useId()\n const { closeModal, modalState, openModal, toggleModal } = useModal()\n const [isOpen, setIsOpen] = useState(false)\n\n const drawerSlug = formatDocumentDrawerSlug({\n id,\n collectionSlug,\n depth: editDepth,\n uuid,\n })\n\n useEffect(() => {\n setIsOpen(Boolean(modalState[drawerSlug]?.isOpen))\n }, [modalState, drawerSlug])\n\n const toggleDrawer = useCallback(() => {\n toggleModal(drawerSlug)\n }, [toggleModal, drawerSlug])\n\n const closeDrawer = useCallback(() => {\n closeModal(drawerSlug)\n }, [closeModal, drawerSlug])\n\n const openDrawer = useCallback(() => {\n openModal(drawerSlug)\n }, [openModal, drawerSlug])\n\n const MemoizedDrawer = useMemo(() => {\n return (props) => (\n <DocumentDrawer\n {...props}\n collectionSlug={collectionSlug}\n drawerSlug={drawerSlug}\n id={id}\n key={drawerSlug}\n overrideEntityVisibility={overrideEntityVisibility}\n />\n )\n }, [id, drawerSlug, collectionSlug, overrideEntityVisibility])\n\n const MemoizedDrawerToggler = useMemo(() => {\n return (props) => (\n <DocumentDrawerToggler\n {...props}\n collectionSlug={collectionSlug}\n drawerSlug={drawerSlug}\n id={id}\n />\n )\n }, [id, drawerSlug, collectionSlug])\n\n const MemoizedDrawerState = useMemo(\n () => ({\n closeDrawer,\n drawerDepth: editDepth,\n drawerSlug,\n isDrawerOpen: isOpen,\n openDrawer,\n toggleDrawer,\n }),\n [editDepth, drawerSlug, isOpen, toggleDrawer, closeDrawer, openDrawer],\n )\n\n return [MemoizedDrawer, MemoizedDrawerToggler, MemoizedDrawerState]\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;;AACA,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAIxE,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,MAAM,EAAEC,aAAa,QAAQ;AACtC,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,OAAO,MAAMC,SAAA,GAAY;AAEzB,MAAMC,wBAAA,GAA2BA,CAAC;EAChCC,EAAE;EACFC,cAAc;EACdC,KAAK;EACLC;AAAI,CAML,KAAK,cAAcF,cAAA,IAAkBC,KAAA,GAAQF,EAAA,GAAK,IAAIA,EAAA,EAAI,GAAG,MAAMG,IAAA,EAAM;AAE1E,OAAO,MAAMC,qBAAA,GAAwDC,EAAA;EAAA,MAAAC,CAAA,GAAAtB,EAAA;EAAA,IAAAuB,QAAA;EAAA,IAAAC,SAAA;EAAA,IAAAP,cAAA;EAAA,IAAAQ,QAAA;EAAA,IAAAC,UAAA;EAAA,IAAAV,EAAA;EAAA,IAAAW,OAAA;EAAA,IAAAC,IAAA;EAAA,IAAAN,CAAA,QAAAD,EAAA;IAAC;MAAAL,EAAA;MAAAO,QAAA;MAAAC,SAAA;MAAAP,cAAA;MAAAQ,QAAA;MAAAC,UAAA;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+C,YAAA,EAEClB,MAAA;MAAAK,UAAA;MAAAH;IAAA;IAGhBnC,CAAA,OAAAoC,WAAA;IAAApC,CAAA,OAAAI,UAAA;IAAAJ,CAAA,OAAA4B,SAAA;IAAA5B,CAAA,OAAAiC,MAAA;IAAAjC,CAAA,OAAAsC,UAAA;IAAAtC,CAAA,OAAAmC,YAAA;IAAAnC,CAAA,OAAAiD,GAAA;EAAA;IAAAA,GAAA,GAAAjD,CAAA;EAAA;EAAAgD,GAAA,GAPOC,GAOP;EARF,MAAAG,mBAAA,GAA4BJ,GAS4C;EAAA,IAAAK,GAAA;EAAA,IAAArD,CAAA,SAAA2C,cAAA,IAAA3C,CAAA,SAAAoD,mBAAA,IAAApD,CAAA,SAAA+C,qBAAA;IAGjEM,GAAA,IAACV,cAAA,EAAgBI,qBAAA,EAAuBK,mBAAA;IAAoBpD,CAAA,OAAA2C,cAAA;IAAA3C,CAAA,OAAAoD,mBAAA;IAAApD,CAAA,OAAA+C,qBAAA;IAAA/C,CAAA,OAAAqD,GAAA;EAAA;IAAAA,GAAA,GAAArD,CAAA;EAAA;EAAA,OAA5DqD,GAA4D;AAAA,CACrE","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useModal","React","useCallback","useEffect","useId","useMemo","useState","useEditDepth","useTranslation","useRelatedCollections","Drawer","DrawerToggler","DocumentDrawerContent","documentDrawerBaseClass","formatDocumentDrawerSlug","id","collectionSlug","depth","uuid","DocumentDrawerToggler","t0","$","children","className","disabled","drawerSlug","onClick","rest","t","collectionConfig","t1","t2","labels","singular","t3","t4","label","t5","filter","Boolean","_jsx","join","slug","DocumentDrawer","props","gutter","Header","useDocumentDrawer","overrideEntityVisibility","editDepth","closeModal","modalState","openModal","toggleModal","isOpen","setIsOpen","toggleDrawer","closeDrawer","t6","openDrawer","t7","t8","_createElement","key","MemoizedDrawer","t9","t10","props_0","MemoizedDrawerToggler","t11","t12","drawerDepth","isDrawerOpen","MemoizedDrawerState","t13"],"sources":["../../../src/elements/DocumentDrawer/index.tsx"],"sourcesContent":["'use client'\nimport { useModal } from '@faceless-ui/modal'\nimport React, { useCallback, useEffect, useId, useMemo, useState } from 'react'\n\nimport type { DocumentDrawerProps, DocumentTogglerProps, UseDocumentDrawer } from './types.js'\n\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useRelatedCollections } from '../AddNewRelation/useRelatedCollections.js'\nimport { Drawer, DrawerToggler } from '../Drawer/index.js'\nimport { DocumentDrawerContent } from './DrawerContent.js'\nimport './index.scss'\n\nexport const documentDrawerBaseClass = 'doc-drawer'\n\nconst formatDocumentDrawerSlug = ({\n id,\n collectionSlug,\n depth,\n uuid,\n}: {\n collectionSlug: string\n depth: number\n id: number | string\n uuid: string // supply when creating a new document and no id is available\n}) => `doc-drawer_${collectionSlug}_${depth}${id ? `_${id}` : ''}_${uuid}`\n\nexport const DocumentDrawerToggler: React.FC<DocumentTogglerProps> = ({\n id,\n children,\n className,\n collectionSlug,\n disabled,\n drawerSlug,\n onClick,\n ...rest\n}) => {\n const { t } = useTranslation()\n const [collectionConfig] = useRelatedCollections(collectionSlug)\n\n return (\n <DrawerToggler\n aria-label={t(!id ? 'fields:addNewLabel' : 'general:editLabel', {\n label: collectionConfig?.labels.singular,\n })}\n className={[className, `${documentDrawerBaseClass}__toggler`].filter(Boolean).join(' ')}\n disabled={disabled}\n onClick={onClick}\n slug={drawerSlug}\n {...rest}\n >\n {children}\n </DrawerToggler>\n )\n}\n\nexport const DocumentDrawer: React.FC<DocumentDrawerProps> = (props) => {\n const { drawerSlug } = props\n\n return (\n <Drawer className={documentDrawerBaseClass} gutter={false} Header={null} slug={drawerSlug}>\n <DocumentDrawerContent {...props} />\n </Drawer>\n )\n}\n\nexport const useDocumentDrawer: UseDocumentDrawer = ({\n id,\n collectionSlug,\n overrideEntityVisibility,\n}) => {\n const editDepth = useEditDepth()\n const uuid = useId()\n const { closeModal, modalState, openModal, toggleModal } = useModal()\n const [isOpen, setIsOpen] = useState(false)\n\n const drawerSlug = formatDocumentDrawerSlug({\n id,\n collectionSlug,\n depth: editDepth,\n uuid,\n })\n\n useEffect(() => {\n setIsOpen(Boolean(modalState[drawerSlug]?.isOpen))\n }, [modalState, drawerSlug])\n\n const toggleDrawer = useCallback(() => {\n toggleModal(drawerSlug)\n }, [toggleModal, drawerSlug])\n\n const closeDrawer = useCallback(() => {\n closeModal(drawerSlug)\n }, [closeModal, drawerSlug])\n\n const openDrawer = useCallback(() => {\n openModal(drawerSlug)\n }, [openModal, drawerSlug])\n\n const MemoizedDrawer = useMemo(() => {\n return (props) => (\n <DocumentDrawer\n {...props}\n collectionSlug={collectionSlug}\n drawerSlug={drawerSlug}\n id={id}\n key={drawerSlug}\n overrideEntityVisibility={overrideEntityVisibility}\n />\n )\n }, [id, drawerSlug, collectionSlug, overrideEntityVisibility])\n\n const MemoizedDrawerToggler = useMemo(() => {\n return (props) => (\n <DocumentDrawerToggler\n {...props}\n collectionSlug={collectionSlug}\n drawerSlug={drawerSlug}\n id={id}\n />\n )\n }, [id, drawerSlug, collectionSlug])\n\n const MemoizedDrawerState = useMemo(\n () => ({\n closeDrawer,\n drawerDepth: editDepth,\n drawerSlug,\n isDrawerOpen: isOpen,\n openDrawer,\n toggleDrawer,\n }),\n [editDepth, drawerSlug, isOpen, toggleDrawer, closeDrawer, openDrawer],\n )\n\n return [MemoizedDrawer, MemoizedDrawerToggler, MemoizedDrawerState]\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;;AACA,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAIxE,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,MAAM,EAAEC,aAAa,QAAQ;AACtC,SAASC,qBAAqB,QA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A;EAAA;IAAAA,GAAA,GAAArD,CAAA;EAAA;EAAA,OAA5DqD,GAA4D;AAAA,CACrE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/EditUpload/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/EditUpload/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,OAAO,qCAAqC,CAAA;AAM5C,OAAO,cAAc,CAAA;AA4BrB,KAAK,aAAa,GAAG;IACnB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACjC,iBAAiB,CAAC,EAAE,aAAa,CAAA;IACjC,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAUD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA6QhD,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useModal } from '@faceless-ui/modal';
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useRef, useState } from 'react';
|
|
6
6
|
import ReactCrop from 'react-image-crop';
|
|
7
7
|
import 'react-image-crop/dist/ReactCrop.css';
|
|
8
8
|
import { editDrawerSlug } from '../../elements/Upload/index.js';
|
|
@@ -11,10 +11,11 @@ import { useTranslation } from '../../providers/Translation/index.js';
|
|
|
11
11
|
import { Button } from '../Button/index.js';
|
|
12
12
|
import './index.scss';
|
|
13
13
|
const baseClass = 'edit-upload';
|
|
14
|
-
const Input =
|
|
14
|
+
const Input = props => {
|
|
15
15
|
const {
|
|
16
16
|
name,
|
|
17
17
|
onChange,
|
|
18
|
+
ref,
|
|
18
19
|
value
|
|
19
20
|
} = props;
|
|
20
21
|
return /*#__PURE__*/_jsxs("div", {
|
|
@@ -27,7 +28,7 @@ const Input = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27
28
|
value: value
|
|
28
29
|
})]
|
|
29
30
|
});
|
|
30
|
-
}
|
|
31
|
+
};
|
|
31
32
|
const defaultCrop = {
|
|
32
33
|
height: 100,
|
|
33
34
|
unit: '%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useModal","React","forwardRef","useRef","useState","ReactCrop","editDrawerSlug","PlusIcon","useTranslation","Button","baseClass","Input","props","ref","name","onChange","value","_jsxs","className","_jsx","e","target","type","defaultCrop","height","unit","width","x","y","EditUpload","fileName","fileSrc","imageCacheTag","initialCrop","initialFocalPoint","onSave","showCrop","showFocalPoint","closeModal","t","crop","setCrop","defaultFocalPosition","focalPosition","setFocalPosition","checkBounds","setCheckBounds","uncroppedPixelHeight","setUncroppedPixelHeight","uncroppedPixelWidth","setUncroppedPixelWidth","focalWrapRef","undefined","imageRef","cropRef","heightInputRef","widthInputRef","imageLoaded","setImageLoaded","onImageLoad","currentTarget","naturalHeight","naturalWidth","fineTuneCrop","dimension","intValue","parseInt","percentage","fineTuneFocalPosition","coordinate","prevPosition","saveEdits","focalPoint","heightInPixels","Number","current","widthInPixels","onDragEnd","useCallback","centerFocalPoint","containerRect","getBoundingClientRect","boundsRect","xCenter","left","yCenter","top","fileSrcToUse","title","buttonStyle","onClick","disabled","style","aspectRatio","_","c","onComplete","renderSelectionAddon","alt","onLoad","src","DraggableElement","boundsRef","containerRef","initialPosition","toFixed","children","position","setPosition","isDragging","setIsDragging","dragRef","getCoordinates","mouseXArg","mouseYArg","recenter","mouseX","mouseY","xOutOfBounds","right","yOutOfBounds","bottom","handleMouseDown","event","preventDefault","handleMouseMove","clientX","clientY","onDrop","useEffect","filter","Boolean","join","onMouseMove","onMouseDown","onMouseUp"],"sources":["../../../src/elements/EditUpload/index.tsx"],"sourcesContent":["'use client'\n\nimport type { UploadEdits } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport React, { forwardRef, useRef, useState } from 'react'\nimport ReactCrop from 'react-image-crop'\nimport 'react-image-crop/dist/ReactCrop.css'\n\nimport { editDrawerSlug } from '../../elements/Upload/index.js'\nimport { PlusIcon } from '../../icons/Plus/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Button } from '../Button/index.js'\nimport './index.scss'\n\nconst baseClass = 'edit-upload'\n\ntype Props = {\n name: string\n onChange: (value: string) => void\n value: string\n}\n\nconst Input = forwardRef<HTMLInputElement, Props>((props, ref) => {\n const { name, onChange, value } = props\n\n return (\n <div className={`${baseClass}__input`}>\n {name}\n <input\n name={name}\n onChange={(e) => onChange(e.target.value)}\n ref={ref}\n type=\"number\"\n value={value}\n />\n </div>\n )\n})\n\ntype FocalPosition = {\n x: number\n y: number\n}\n\nexport type EditUploadProps = {\n fileName: string\n fileSrc: string\n imageCacheTag?: string\n initialCrop?: UploadEdits['crop']\n initialFocalPoint?: FocalPosition\n onSave?: (uploadEdits: UploadEdits) => void\n showCrop?: boolean\n showFocalPoint?: boolean\n}\n\nconst defaultCrop: UploadEdits['crop'] = {\n height: 100,\n unit: '%',\n width: 100,\n x: 0,\n y: 0,\n}\n\nexport const EditUpload: React.FC<EditUploadProps> = ({\n fileName,\n fileSrc,\n imageCacheTag,\n initialCrop,\n initialFocalPoint,\n onSave,\n showCrop,\n showFocalPoint,\n}) => {\n const { closeModal } = useModal()\n const { t } = useTranslation()\n\n const [crop, setCrop] = useState<UploadEdits['crop']>(() => ({\n ...defaultCrop,\n ...(initialCrop || {}),\n }))\n\n const defaultFocalPosition: FocalPosition = {\n x: 50,\n y: 50,\n }\n\n const [focalPosition, setFocalPosition] = useState<FocalPosition>(() => ({\n ...defaultFocalPosition,\n ...initialFocalPoint,\n }))\n\n const [checkBounds, setCheckBounds] = useState<boolean>(false)\n const [uncroppedPixelHeight, setUncroppedPixelHeight] = useState<number>(0)\n const [uncroppedPixelWidth, setUncroppedPixelWidth] = useState<number>(0)\n\n const focalWrapRef = useRef<HTMLDivElement | undefined>(undefined)\n const imageRef = useRef<HTMLImageElement | undefined>(undefined)\n const cropRef = useRef<HTMLDivElement | undefined>(undefined)\n\n const heightInputRef = useRef<HTMLInputElement | null>(null)\n const widthInputRef = useRef<HTMLInputElement | null>(null)\n\n const [imageLoaded, setImageLoaded] = useState<boolean>(false)\n\n const onImageLoad = (e) => {\n // set the default image height/width on load\n setUncroppedPixelHeight(e.currentTarget.naturalHeight)\n setUncroppedPixelWidth(e.currentTarget.naturalWidth)\n setImageLoaded(true)\n }\n\n const fineTuneCrop = ({ dimension, value }: { dimension: 'height' | 'width'; value: string }) => {\n const intValue = parseInt(value)\n if (dimension === 'width' && intValue >= uncroppedPixelWidth) {\n return null\n }\n if (dimension === 'height' && intValue >= uncroppedPixelHeight) {\n return null\n }\n\n const percentage =\n 100 * (intValue / (dimension === 'width' ? uncroppedPixelWidth : uncroppedPixelHeight))\n\n if (percentage === 100 || percentage === 0) {\n return null\n }\n\n setCrop({\n ...crop,\n [dimension]: percentage,\n })\n }\n\n const fineTuneFocalPosition = ({\n coordinate,\n value,\n }: {\n coordinate: 'x' | 'y'\n value: string\n }) => {\n const intValue = parseInt(value)\n if (intValue >= 0 && intValue <= 100) {\n setFocalPosition((prevPosition) => ({ ...prevPosition, [coordinate]: intValue }))\n }\n }\n\n const saveEdits = () => {\n if (typeof onSave === 'function') {\n onSave({\n crop: crop ? crop : undefined,\n focalPoint: focalPosition,\n heightInPixels: Number(heightInputRef?.current?.value ?? uncroppedPixelHeight),\n widthInPixels: Number(widthInputRef?.current?.value ?? uncroppedPixelWidth),\n })\n }\n closeModal(editDrawerSlug)\n }\n\n const onDragEnd = React.useCallback(({ x, y }) => {\n setFocalPosition({ x, y })\n setCheckBounds(false)\n }, [])\n\n const centerFocalPoint = () => {\n const containerRect = focalWrapRef.current.getBoundingClientRect()\n const boundsRect = showCrop\n ? cropRef.current.getBoundingClientRect()\n : imageRef.current.getBoundingClientRect()\n const xCenter =\n ((boundsRect.left - containerRect.left + boundsRect.width / 2) / containerRect.width) * 100\n const yCenter =\n ((boundsRect.top - containerRect.top + boundsRect.height / 2) / containerRect.height) * 100\n setFocalPosition({ x: xCenter, y: yCenter })\n }\n\n const fileSrcToUse = imageCacheTag ? `${fileSrc}?${imageCacheTag}` : fileSrc\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__header`}>\n <h2 title={`${t('general:editing')} ${fileName}`}>\n {t('general:editing')} {fileName}\n </h2>\n <div className={`${baseClass}__actions`}>\n <Button\n aria-label={t('general:cancel')}\n buttonStyle=\"secondary\"\n className={`${baseClass}__cancel`}\n onClick={() => closeModal(editDrawerSlug)}\n >\n {t('general:cancel')}\n </Button>\n <Button\n aria-label={t('general:applyChanges')}\n buttonStyle=\"primary\"\n className={`${baseClass}__save`}\n disabled={!imageLoaded}\n onClick={saveEdits}\n >\n {t('general:applyChanges')}\n </Button>\n </div>\n </div>\n <div className={`${baseClass}__toolWrap`}>\n <div className={`${baseClass}__crop`}>\n <div\n className={`${baseClass}__focal-wrapper`}\n ref={focalWrapRef}\n style={{\n aspectRatio: `${uncroppedPixelWidth / uncroppedPixelHeight}`,\n }}\n >\n {showCrop ? (\n <ReactCrop\n className={`${baseClass}__reactCrop`}\n crop={crop}\n onChange={(_, c) => setCrop(c)}\n onComplete={() => setCheckBounds(true)}\n renderSelectionAddon={() => {\n return <div className={`${baseClass}__crop-window`} ref={cropRef} />\n }}\n >\n <img\n alt={t('upload:setCropArea')}\n onLoad={onImageLoad}\n ref={imageRef}\n src={fileSrcToUse}\n />\n </ReactCrop>\n ) : (\n <img\n alt={t('upload:setFocalPoint')}\n onLoad={onImageLoad}\n ref={imageRef}\n src={fileSrcToUse}\n />\n )}\n {showFocalPoint && (\n <DraggableElement\n boundsRef={showCrop ? cropRef : imageRef}\n checkBounds={showCrop ? checkBounds : false}\n className={`${baseClass}__focalPoint`}\n containerRef={focalWrapRef}\n initialPosition={focalPosition}\n onDragEnd={onDragEnd}\n setCheckBounds={showCrop ? setCheckBounds : false}\n >\n <PlusIcon />\n </DraggableElement>\n )}\n </div>\n </div>\n {(showCrop || showFocalPoint) && (\n <div className={`${baseClass}__sidebar`}>\n {showCrop && (\n <div className={`${baseClass}__groupWrap`}>\n <div>\n <div className={`${baseClass}__titleWrap`}>\n <h3>{t('upload:crop')}</h3>\n <Button\n buttonStyle=\"none\"\n className={`${baseClass}__reset`}\n onClick={() =>\n setCrop({\n height: 100,\n unit: '%',\n width: 100,\n x: 0,\n y: 0,\n })\n }\n >\n {t('general:reset')}\n </Button>\n </div>\n </div>\n <span className={`${baseClass}__description`}>\n {t('upload:cropToolDescription')}\n </span>\n <div className={`${baseClass}__inputsWrap`}>\n <Input\n name={`${t('upload:width')} (px)`}\n onChange={(value) => fineTuneCrop({ dimension: 'width', value })}\n ref={widthInputRef}\n value={((crop.width / 100) * uncroppedPixelWidth).toFixed(0)}\n />\n <Input\n name={`${t('upload:height')} (px)`}\n onChange={(value) => fineTuneCrop({ dimension: 'height', value })}\n ref={heightInputRef}\n value={((crop.height / 100) * uncroppedPixelHeight).toFixed(0)}\n />\n </div>\n </div>\n )}\n\n {showFocalPoint && (\n <div className={`${baseClass}__groupWrap`}>\n <div>\n <div className={`${baseClass}__titleWrap`}>\n <h3>{t('upload:focalPoint')}</h3>\n <Button\n buttonStyle=\"none\"\n className={`${baseClass}__reset`}\n onClick={centerFocalPoint}\n >\n {t('general:reset')}\n </Button>\n </div>\n </div>\n <span className={`${baseClass}__description`}>\n {t('upload:focalPointDescription')}\n </span>\n <div className={`${baseClass}__inputsWrap`}>\n <Input\n name=\"X %\"\n onChange={(value) => fineTuneFocalPosition({ coordinate: 'x', value })}\n value={focalPosition.x.toFixed(0)}\n />\n <Input\n name=\"Y %\"\n onChange={(value) => fineTuneFocalPosition({ coordinate: 'y', value })}\n value={focalPosition.y.toFixed(0)}\n />\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n )\n}\n\nconst DraggableElement = ({\n boundsRef,\n checkBounds,\n children,\n className,\n containerRef,\n initialPosition = { x: 50, y: 50 },\n onDragEnd,\n setCheckBounds,\n}) => {\n const [position, setPosition] = useState({ x: initialPosition.x, y: initialPosition.y })\n const [isDragging, setIsDragging] = useState(false)\n const dragRef = useRef<HTMLButtonElement | undefined>(undefined)\n\n const getCoordinates = React.useCallback(\n (mouseXArg?: number, mouseYArg?: number, recenter?: boolean) => {\n const containerRect = containerRef.current.getBoundingClientRect()\n const boundsRect = boundsRef.current.getBoundingClientRect()\n const mouseX = mouseXArg ?? boundsRect.left\n const mouseY = mouseYArg ?? boundsRect.top\n\n const xOutOfBounds = mouseX < boundsRect.left || mouseX > boundsRect.right\n const yOutOfBounds = mouseY < boundsRect.top || mouseY > boundsRect.bottom\n\n let x = ((mouseX - containerRect.left) / containerRect.width) * 100\n let y = ((mouseY - containerRect.top) / containerRect.height) * 100\n const xCenter =\n ((boundsRect.left - containerRect.left + boundsRect.width / 2) / containerRect.width) * 100\n const yCenter =\n ((boundsRect.top - containerRect.top + boundsRect.height / 2) / containerRect.height) * 100\n if (xOutOfBounds || yOutOfBounds) {\n setIsDragging(false)\n if (mouseX < boundsRect.left) {\n x = ((boundsRect.left - containerRect.left) / containerRect.width) * 100\n } else if (mouseX > boundsRect.right) {\n x =\n ((containerRect.width - (containerRect.right - boundsRect.right)) /\n containerRect.width) *\n 100\n }\n\n if (mouseY < boundsRect.top) {\n y = ((boundsRect.top - containerRect.top) / containerRect.height) * 100\n } else if (mouseY > boundsRect.bottom) {\n y =\n ((containerRect.height - (containerRect.bottom - boundsRect.bottom)) /\n containerRect.height) *\n 100\n }\n\n if (recenter) {\n x = xOutOfBounds ? xCenter : x\n y = yOutOfBounds ? yCenter : y\n }\n }\n\n return { x, y }\n },\n [boundsRef, containerRef],\n )\n\n const handleMouseDown = (event) => {\n event.preventDefault()\n setIsDragging(true)\n }\n\n const handleMouseMove = (event) => {\n if (!isDragging) {\n return null\n }\n const { x, y } = getCoordinates(event.clientX, event.clientY)\n\n setPosition({ x, y })\n }\n\n const onDrop = () => {\n setIsDragging(false)\n onDragEnd(position)\n }\n\n React.useEffect(() => {\n if (isDragging || !dragRef.current) {\n return\n }\n if (checkBounds) {\n const { height, left, top, width } = dragRef.current.getBoundingClientRect()\n const { x, y } = getCoordinates(left + width / 2, top + height / 2, true)\n onDragEnd({ x, y })\n setPosition({ x, y })\n setCheckBounds(false)\n return\n }\n }, [getCoordinates, isDragging, checkBounds, setCheckBounds, position.x, position.y, onDragEnd])\n\n React.useEffect(() => {\n setPosition({ x: initialPosition.x, y: initialPosition.y })\n }, [initialPosition.x, initialPosition.y])\n\n return (\n <div\n className={[\n `${baseClass}__draggable-container`,\n isDragging && `${baseClass}__draggable-container--dragging`,\n ]\n .filter(Boolean)\n .join(' ')}\n onMouseMove={handleMouseMove}\n >\n <button\n className={[`${baseClass}__draggable`, className].filter(Boolean).join(' ')}\n onMouseDown={handleMouseDown}\n onMouseUp={onDrop}\n ref={dragRef}\n style={{ left: `${position.x}%`, top: `${position.y}%` }}\n type=\"button\"\n >\n {children}\n </button>\n <div />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACpD,OAAOC,SAAA,MAAe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IAAA,CAAC;MACCD,SAAA,EAAW,CAAC,GAAGR,SAAA,aAAsB,EAAEQ,SAAA,CAAU,CAACgH,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;MACvEE,WAAA,EAAaZ,eAAA;MACba,SAAA,EAAWP,MAAA;MACXnH,GAAA,EAAKkG,OAAA;MACLnB,KAAA,EAAO;QAAER,IAAA,EAAM,GAAGuB,QAAA,CAAShF,CAAC,GAAG;QAAE2D,GAAA,EAAK,GAAGqB,QAAA,CAAS/E,CAAC;MAAI;MACvDN,IAAA,EAAK;gBAEJoF;qBAEHvF,IAAA,CAAC;;AAGP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useModal","React","useRef","useState","ReactCrop","editDrawerSlug","PlusIcon","useTranslation","Button","baseClass","Input","props","name","onChange","ref","value","_jsxs","className","_jsx","e","target","type","defaultCrop","height","unit","width","x","y","EditUpload","fileName","fileSrc","imageCacheTag","initialCrop","initialFocalPoint","onSave","showCrop","showFocalPoint","closeModal","t","crop","setCrop","defaultFocalPosition","focalPosition","setFocalPosition","checkBounds","setCheckBounds","uncroppedPixelHeight","setUncroppedPixelHeight","uncroppedPixelWidth","setUncroppedPixelWidth","focalWrapRef","undefined","imageRef","cropRef","heightInputRef","widthInputRef","imageLoaded","setImageLoaded","onImageLoad","currentTarget","naturalHeight","naturalWidth","fineTuneCrop","dimension","intValue","parseInt","percentage","fineTuneFocalPosition","coordinate","prevPosition","saveEdits","focalPoint","heightInPixels","Number","current","widthInPixels","onDragEnd","useCallback","centerFocalPoint","containerRect","getBoundingClientRect","boundsRect","xCenter","left","yCenter","top","fileSrcToUse","title","buttonStyle","onClick","disabled","style","aspectRatio","_","c","onComplete","renderSelectionAddon","alt","onLoad","src","DraggableElement","boundsRef","containerRef","initialPosition","toFixed","children","position","setPosition","isDragging","setIsDragging","dragRef","getCoordinates","mouseXArg","mouseYArg","recenter","mouseX","mouseY","xOutOfBounds","right","yOutOfBounds","bottom","handleMouseDown","event","preventDefault","handleMouseMove","clientX","clientY","onDrop","useEffect","filter","Boolean","join","onMouseMove","onMouseDown","onMouseUp"],"sources":["../../../src/elements/EditUpload/index.tsx"],"sourcesContent":["'use client'\n\nimport type { UploadEdits } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport React, { useRef, useState } from 'react'\nimport ReactCrop from 'react-image-crop'\nimport 'react-image-crop/dist/ReactCrop.css'\n\nimport { editDrawerSlug } from '../../elements/Upload/index.js'\nimport { PlusIcon } from '../../icons/Plus/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Button } from '../Button/index.js'\nimport './index.scss'\n\nconst baseClass = 'edit-upload'\n\ntype Props = {\n name: string\n onChange: (value: string) => void\n ref?: React.RefObject<HTMLInputElement>\n value: string\n}\n\nconst Input: React.FC<Props> = (props) => {\n const { name, onChange, ref, value } = props\n\n return (\n <div className={`${baseClass}__input`}>\n {name}\n <input\n name={name}\n onChange={(e) => onChange(e.target.value)}\n ref={ref}\n type=\"number\"\n value={value}\n />\n </div>\n )\n}\n\ntype FocalPosition = {\n x: number\n y: number\n}\n\nexport type EditUploadProps = {\n fileName: string\n fileSrc: string\n imageCacheTag?: string\n initialCrop?: UploadEdits['crop']\n initialFocalPoint?: FocalPosition\n onSave?: (uploadEdits: UploadEdits) => void\n showCrop?: boolean\n showFocalPoint?: boolean\n}\n\nconst defaultCrop: UploadEdits['crop'] = {\n height: 100,\n unit: '%',\n width: 100,\n x: 0,\n y: 0,\n}\n\nexport const EditUpload: React.FC<EditUploadProps> = ({\n fileName,\n fileSrc,\n imageCacheTag,\n initialCrop,\n initialFocalPoint,\n onSave,\n showCrop,\n showFocalPoint,\n}) => {\n const { closeModal } = useModal()\n const { t } = useTranslation()\n\n const [crop, setCrop] = useState<UploadEdits['crop']>(() => ({\n ...defaultCrop,\n ...(initialCrop || {}),\n }))\n\n const defaultFocalPosition: FocalPosition = {\n x: 50,\n y: 50,\n }\n\n const [focalPosition, setFocalPosition] = useState<FocalPosition>(() => ({\n ...defaultFocalPosition,\n ...initialFocalPoint,\n }))\n\n const [checkBounds, setCheckBounds] = useState<boolean>(false)\n const [uncroppedPixelHeight, setUncroppedPixelHeight] = useState<number>(0)\n const [uncroppedPixelWidth, setUncroppedPixelWidth] = useState<number>(0)\n\n const focalWrapRef = useRef<HTMLDivElement | undefined>(undefined)\n const imageRef = useRef<HTMLImageElement | undefined>(undefined)\n const cropRef = useRef<HTMLDivElement | undefined>(undefined)\n\n const heightInputRef = useRef<HTMLInputElement | null>(null)\n const widthInputRef = useRef<HTMLInputElement | null>(null)\n\n const [imageLoaded, setImageLoaded] = useState<boolean>(false)\n\n const onImageLoad = (e) => {\n // set the default image height/width on load\n setUncroppedPixelHeight(e.currentTarget.naturalHeight)\n setUncroppedPixelWidth(e.currentTarget.naturalWidth)\n setImageLoaded(true)\n }\n\n const fineTuneCrop = ({ dimension, value }: { dimension: 'height' | 'width'; value: string }) => {\n const intValue = parseInt(value)\n if (dimension === 'width' && intValue >= uncroppedPixelWidth) {\n return null\n }\n if (dimension === 'height' && intValue >= uncroppedPixelHeight) {\n return null\n }\n\n const percentage =\n 100 * (intValue / (dimension === 'width' ? uncroppedPixelWidth : uncroppedPixelHeight))\n\n if (percentage === 100 || percentage === 0) {\n return null\n }\n\n setCrop({\n ...crop,\n [dimension]: percentage,\n })\n }\n\n const fineTuneFocalPosition = ({\n coordinate,\n value,\n }: {\n coordinate: 'x' | 'y'\n value: string\n }) => {\n const intValue = parseInt(value)\n if (intValue >= 0 && intValue <= 100) {\n setFocalPosition((prevPosition) => ({ ...prevPosition, [coordinate]: intValue }))\n }\n }\n\n const saveEdits = () => {\n if (typeof onSave === 'function') {\n onSave({\n crop: crop ? crop : undefined,\n focalPoint: focalPosition,\n heightInPixels: Number(heightInputRef?.current?.value ?? uncroppedPixelHeight),\n widthInPixels: Number(widthInputRef?.current?.value ?? uncroppedPixelWidth),\n })\n }\n closeModal(editDrawerSlug)\n }\n\n const onDragEnd = React.useCallback(({ x, y }) => {\n setFocalPosition({ x, y })\n setCheckBounds(false)\n }, [])\n\n const centerFocalPoint = () => {\n const containerRect = focalWrapRef.current.getBoundingClientRect()\n const boundsRect = showCrop\n ? cropRef.current.getBoundingClientRect()\n : imageRef.current.getBoundingClientRect()\n const xCenter =\n ((boundsRect.left - containerRect.left + boundsRect.width / 2) / containerRect.width) * 100\n const yCenter =\n ((boundsRect.top - containerRect.top + boundsRect.height / 2) / containerRect.height) * 100\n setFocalPosition({ x: xCenter, y: yCenter })\n }\n\n const fileSrcToUse = imageCacheTag ? `${fileSrc}?${imageCacheTag}` : fileSrc\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__header`}>\n <h2 title={`${t('general:editing')} ${fileName}`}>\n {t('general:editing')} {fileName}\n </h2>\n <div className={`${baseClass}__actions`}>\n <Button\n aria-label={t('general:cancel')}\n buttonStyle=\"secondary\"\n className={`${baseClass}__cancel`}\n onClick={() => closeModal(editDrawerSlug)}\n >\n {t('general:cancel')}\n </Button>\n <Button\n aria-label={t('general:applyChanges')}\n buttonStyle=\"primary\"\n className={`${baseClass}__save`}\n disabled={!imageLoaded}\n onClick={saveEdits}\n >\n {t('general:applyChanges')}\n </Button>\n </div>\n </div>\n <div className={`${baseClass}__toolWrap`}>\n <div className={`${baseClass}__crop`}>\n <div\n className={`${baseClass}__focal-wrapper`}\n ref={focalWrapRef}\n style={{\n aspectRatio: `${uncroppedPixelWidth / uncroppedPixelHeight}`,\n }}\n >\n {showCrop ? (\n <ReactCrop\n className={`${baseClass}__reactCrop`}\n crop={crop}\n onChange={(_, c) => setCrop(c)}\n onComplete={() => setCheckBounds(true)}\n renderSelectionAddon={() => {\n return <div className={`${baseClass}__crop-window`} ref={cropRef} />\n }}\n >\n <img\n alt={t('upload:setCropArea')}\n onLoad={onImageLoad}\n ref={imageRef}\n src={fileSrcToUse}\n />\n </ReactCrop>\n ) : (\n <img\n alt={t('upload:setFocalPoint')}\n onLoad={onImageLoad}\n ref={imageRef}\n src={fileSrcToUse}\n />\n )}\n {showFocalPoint && (\n <DraggableElement\n boundsRef={showCrop ? cropRef : imageRef}\n checkBounds={showCrop ? checkBounds : false}\n className={`${baseClass}__focalPoint`}\n containerRef={focalWrapRef}\n initialPosition={focalPosition}\n onDragEnd={onDragEnd}\n setCheckBounds={showCrop ? setCheckBounds : false}\n >\n <PlusIcon />\n </DraggableElement>\n )}\n </div>\n </div>\n {(showCrop || showFocalPoint) && (\n <div className={`${baseClass}__sidebar`}>\n {showCrop && (\n <div className={`${baseClass}__groupWrap`}>\n <div>\n <div className={`${baseClass}__titleWrap`}>\n <h3>{t('upload:crop')}</h3>\n <Button\n buttonStyle=\"none\"\n className={`${baseClass}__reset`}\n onClick={() =>\n setCrop({\n height: 100,\n unit: '%',\n width: 100,\n x: 0,\n y: 0,\n })\n }\n >\n {t('general:reset')}\n </Button>\n </div>\n </div>\n <span className={`${baseClass}__description`}>\n {t('upload:cropToolDescription')}\n </span>\n <div className={`${baseClass}__inputsWrap`}>\n <Input\n name={`${t('upload:width')} (px)`}\n onChange={(value) => fineTuneCrop({ dimension: 'width', value })}\n ref={widthInputRef}\n value={((crop.width / 100) * uncroppedPixelWidth).toFixed(0)}\n />\n <Input\n name={`${t('upload:height')} (px)`}\n onChange={(value) => fineTuneCrop({ dimension: 'height', value })}\n ref={heightInputRef}\n value={((crop.height / 100) * uncroppedPixelHeight).toFixed(0)}\n />\n </div>\n </div>\n )}\n\n {showFocalPoint && (\n <div className={`${baseClass}__groupWrap`}>\n <div>\n <div className={`${baseClass}__titleWrap`}>\n <h3>{t('upload:focalPoint')}</h3>\n <Button\n buttonStyle=\"none\"\n className={`${baseClass}__reset`}\n onClick={centerFocalPoint}\n >\n {t('general:reset')}\n </Button>\n </div>\n </div>\n <span className={`${baseClass}__description`}>\n {t('upload:focalPointDescription')}\n </span>\n <div className={`${baseClass}__inputsWrap`}>\n <Input\n name=\"X %\"\n onChange={(value) => fineTuneFocalPosition({ coordinate: 'x', value })}\n value={focalPosition.x.toFixed(0)}\n />\n <Input\n name=\"Y %\"\n onChange={(value) => fineTuneFocalPosition({ coordinate: 'y', value })}\n value={focalPosition.y.toFixed(0)}\n />\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n )\n}\n\nconst DraggableElement = ({\n boundsRef,\n checkBounds,\n children,\n className,\n containerRef,\n initialPosition = { x: 50, y: 50 },\n onDragEnd,\n setCheckBounds,\n}) => {\n const [position, setPosition] = useState({ x: initialPosition.x, y: initialPosition.y })\n const [isDragging, setIsDragging] = useState(false)\n const dragRef = useRef<HTMLButtonElement | undefined>(undefined)\n\n const getCoordinates = React.useCallback(\n (mouseXArg?: number, mouseYArg?: number, recenter?: boolean) => {\n const containerRect = containerRef.current.getBoundingClientRect()\n const boundsRect = boundsRef.current.getBoundingClientRect()\n const mouseX = mouseXArg ?? boundsRect.left\n const mouseY = mouseYArg ?? boundsRect.top\n\n const xOutOfBounds = mouseX < boundsRect.left || mouseX > boundsRect.right\n const yOutOfBounds = mouseY < boundsRect.top || mouseY > boundsRect.bottom\n\n let x = ((mouseX - containerRect.left) / containerRect.width) * 100\n let y = ((mouseY - containerRect.top) / containerRect.height) * 100\n const xCenter =\n ((boundsRect.left - containerRect.left + boundsRect.width / 2) / containerRect.width) * 100\n const yCenter =\n ((boundsRect.top - containerRect.top + boundsRect.height / 2) / containerRect.height) * 100\n if (xOutOfBounds || yOutOfBounds) {\n setIsDragging(false)\n if (mouseX < boundsRect.left) {\n x = ((boundsRect.left - containerRect.left) / containerRect.width) * 100\n } else if (mouseX > boundsRect.right) {\n x =\n ((containerRect.width - (containerRect.right - boundsRect.right)) /\n containerRect.width) *\n 100\n }\n\n if (mouseY < boundsRect.top) {\n y = ((boundsRect.top - containerRect.top) / containerRect.height) * 100\n } else if (mouseY > boundsRect.bottom) {\n y =\n ((containerRect.height - (containerRect.bottom - boundsRect.bottom)) /\n containerRect.height) *\n 100\n }\n\n if (recenter) {\n x = xOutOfBounds ? xCenter : x\n y = yOutOfBounds ? yCenter : y\n }\n }\n\n return { x, y }\n },\n [boundsRef, containerRef],\n )\n\n const handleMouseDown = (event) => {\n event.preventDefault()\n setIsDragging(true)\n }\n\n const handleMouseMove = (event) => {\n if (!isDragging) {\n return null\n }\n const { x, y } = getCoordinates(event.clientX, event.clientY)\n\n setPosition({ x, y })\n }\n\n const onDrop = () => {\n setIsDragging(false)\n onDragEnd(position)\n }\n\n React.useEffect(() => {\n if (isDragging || !dragRef.current) {\n return\n }\n if (checkBounds) {\n const { height, left, top, width } = dragRef.current.getBoundingClientRect()\n const { x, y } = getCoordinates(left + width / 2, top + height / 2, true)\n onDragEnd({ x, y })\n setPosition({ x, y })\n setCheckBounds(false)\n return\n }\n }, [getCoordinates, isDragging, checkBounds, setCheckBounds, position.x, position.y, onDragEnd])\n\n React.useEffect(() => {\n setPosition({ x: initialPosition.x, y: initialPosition.y })\n }, [initialPosition.x, initialPosition.y])\n\n return (\n <div\n className={[\n `${baseClass}__draggable-container`,\n isDragging && `${baseClass}__draggable-container--dragging`,\n ]\n .filter(Boolean)\n .join(' ')}\n onMouseMove={handleMouseMove}\n >\n <button\n className={[`${baseClass}__draggable`, className].filter(Boolean).join(' ')}\n onMouseDown={handleMouseDown}\n onMouseUp={onDrop}\n ref={dragRef}\n style={{ left: `${position.x}%`, top: `${position.y}%` }}\n type=\"button\"\n >\n {children}\n </button>\n <div />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,MAAM,EAAEC,QAAQ,QAAQ;AACxC,OAAOC,SAAA,MAAe;AACtB,OAAO;AAEP,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,OAAO;AAEP,MAAMC,SAAA,GAAY;AASlB,MAAMC,KAAA,GAA0BC,KAAA;EAC9B,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,GAAG;IAAEC;EAAK,CA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D,GAAA,EAAK,GAAGqB,QAAA,CAAS/E,CAAC;MAAI;MACvDN,IAAA,EAAK;gBAEJoF;qBAEHvF,IAAA,CAAC;;AAGP","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/EmailAndUsername/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAGlF,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,KAAK,iCAAiC,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,KAAK,GAAG,wBAAwB,CAAA;IACpD,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,WAAW,CAAC,EACR;QACE,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB,CAAA;KAC/C,GACD,IAAI,CAAA;IACR,QAAQ,EAAE,OAAO,CAAA;IACjB,CAAC,EAAE,SAAS,CAAA;CACb,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,iCAAiC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/EmailAndUsername/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAGlF,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,KAAK,iCAAiC,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,KAAK,GAAG,wBAAwB,CAAA;IACpD,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,WAAW,CAAC,EACR;QACE,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB,CAAA;KAC/C,GACD,IAAI,CAAA;IACR,QAAQ,EAAE,OAAO,CAAA;IACjB,CAAC,EAAE,SAAS,CAAA;CACb,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,iCAAiC,qBAyC9E"}
|
|
@@ -9,6 +9,7 @@ export function EmailAndUsernameFields(props) {
|
|
|
9
9
|
const {
|
|
10
10
|
className,
|
|
11
11
|
loginWithUsername,
|
|
12
|
+
readOnly,
|
|
12
13
|
t
|
|
13
14
|
} = props;
|
|
14
15
|
const showEmailField = !loginWithUsername || loginWithUsername?.requireEmail || loginWithUsername?.allowEmailLogin;
|
|
@@ -25,6 +26,7 @@ export function EmailAndUsernameFields(props) {
|
|
|
25
26
|
required: !loginWithUsername || loginWithUsername && loginWithUsername.requireEmail
|
|
26
27
|
},
|
|
27
28
|
path: "email",
|
|
29
|
+
readOnly: readOnly,
|
|
28
30
|
schemaPath: "email",
|
|
29
31
|
validate: email
|
|
30
32
|
}) : null, showUsernameField && /*#__PURE__*/_jsx(TextField, {
|
|
@@ -34,6 +36,7 @@ export function EmailAndUsernameFields(props) {
|
|
|
34
36
|
required: loginWithUsername && loginWithUsername.requireUsername
|
|
35
37
|
},
|
|
36
38
|
path: "username",
|
|
39
|
+
readOnly: readOnly,
|
|
37
40
|
schemaPath: "username",
|
|
38
41
|
validate: username
|
|
39
42
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["email","username","React","EmailField","TextField","EmailAndUsernameFields","props","className","loginWithUsername","t","showEmailField","requireEmail","allowEmailLogin","showUsernameField","Boolean","_jsxs","_jsx","field","name","admin","autoComplete","label","required","path","schemaPath","validate","requireUsername"],"sources":["../../../src/elements/EmailAndUsername/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TFunction } from '@payloadcms/translations'\nimport type { LoginWithUsernameOptions, SanitizedFieldPermissions } from 'payload'\n\nimport { email, username } from 'payload/shared'\nimport React from 'react'\n\nimport { EmailField } from '../../fields/Email/index.js'\nimport { TextField } from '../../fields/Text/index.js'\n\ntype RenderEmailAndUsernameFieldsProps = {\n className?: string\n loginWithUsername?: false | LoginWithUsernameOptions\n operation?: 'create' | 'update'\n permissions?:\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n readOnly: boolean\n t: TFunction\n}\n\nexport function EmailAndUsernameFields(props: RenderEmailAndUsernameFieldsProps) {\n const { className, loginWithUsername, t } = props\n\n const showEmailField =\n !loginWithUsername || loginWithUsername?.requireEmail || loginWithUsername?.allowEmailLogin\n\n const showUsernameField = Boolean(loginWithUsername)\n\n return (\n <div className={className}>\n {showEmailField ? (\n <EmailField\n field={{\n name: 'email',\n admin: {\n autoComplete: 'off',\n },\n label: t('general:email'),\n required: !loginWithUsername || (loginWithUsername && loginWithUsername.requireEmail),\n }}\n path=\"email\"\n schemaPath=\"email\"\n validate={email}\n />\n ) : null}\n {showUsernameField && (\n <TextField\n field={{\n name: 'username',\n label: t('authentication:username'),\n required: loginWithUsername && loginWithUsername.requireUsername,\n }}\n path=\"username\"\n schemaPath=\"username\"\n validate={username}\n />\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,KAAK,EAAEC,QAAQ,QAAQ;AAChC,OAAOC,KAAA,MAAW;AAElB,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAe1B,OAAO,SAASC,uBAAuBC,KAAwC;EAC7E,MAAM;IAAEC,SAAS;IAAEC,iBAAiB;IAAEC;EAAC,CAAE,
|
|
1
|
+
{"version":3,"file":"index.js","names":["email","username","React","EmailField","TextField","EmailAndUsernameFields","props","className","loginWithUsername","readOnly","t","showEmailField","requireEmail","allowEmailLogin","showUsernameField","Boolean","_jsxs","_jsx","field","name","admin","autoComplete","label","required","path","schemaPath","validate","requireUsername"],"sources":["../../../src/elements/EmailAndUsername/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TFunction } from '@payloadcms/translations'\nimport type { LoginWithUsernameOptions, SanitizedFieldPermissions } from 'payload'\n\nimport { email, username } from 'payload/shared'\nimport React from 'react'\n\nimport { EmailField } from '../../fields/Email/index.js'\nimport { TextField } from '../../fields/Text/index.js'\n\ntype RenderEmailAndUsernameFieldsProps = {\n className?: string\n loginWithUsername?: false | LoginWithUsernameOptions\n operation?: 'create' | 'update'\n permissions?:\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n readOnly: boolean\n t: TFunction\n}\n\nexport function EmailAndUsernameFields(props: RenderEmailAndUsernameFieldsProps) {\n const { className, loginWithUsername, readOnly, t } = props\n\n const showEmailField =\n !loginWithUsername || loginWithUsername?.requireEmail || loginWithUsername?.allowEmailLogin\n\n const showUsernameField = Boolean(loginWithUsername)\n\n return (\n <div className={className}>\n {showEmailField ? (\n <EmailField\n field={{\n name: 'email',\n admin: {\n autoComplete: 'off',\n },\n label: t('general:email'),\n required: !loginWithUsername || (loginWithUsername && loginWithUsername.requireEmail),\n }}\n path=\"email\"\n readOnly={readOnly}\n schemaPath=\"email\"\n validate={email}\n />\n ) : null}\n {showUsernameField && (\n <TextField\n field={{\n name: 'username',\n label: t('authentication:username'),\n required: loginWithUsername && loginWithUsername.requireUsername,\n }}\n path=\"username\"\n readOnly={readOnly}\n schemaPath=\"username\"\n validate={username}\n />\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,KAAK,EAAEC,QAAQ,QAAQ;AAChC,OAAOC,KAAA,MAAW;AAElB,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAe1B,OAAO,SAASC,uBAAuBC,KAAwC;EAC7E,MAAM;IAAEC,SAAS;IAAEC,iBAAiB;IAAEC,QAAQ;IAAEC;EAAC,CAAE,GAAGJ,KAAA;EAEtD,MAAMK,cAAA,GACJ,CAACH,iBAAA,IAAqBA,iBAAA,EAAmBI,YAAA,IAAgBJ,iBAAA,EAAmBK,eAAA;EAE9E,MAAMC,iBAAA,GAAoBC,OAAA,CAAQP,iBAAA;EAElC,oBACEQ,KAAA,CAAC;IAAIT,SAAA,EAAWA,SAAA;eACbI,cAAA,gBACCM,IAAA,CAACd,UAAA;MACCe,KAAA,EAAO;QACLC,IAAA,EAAM;QACNC,KAAA,EAAO;UACLC,YAAA,EAAc;QAChB;QACAC,KAAA,EAAOZ,CAAA,CAAE;QACTa,QAAA,EAAU,CAACf,iBAAA,IAAsBA,iBAAA,IAAqBA,iBAAA,CAAkBI;MAC1E;MACAY,IAAA,EAAK;MACLf,QAAA,EAAUA,QAAA;MACVgB,UAAA,EAAW;MACXC,QAAA,EAAU1B;SAEV,MACHc,iBAAA,iBACCG,IAAA,CAACb,SAAA;MACCc,KAAA,EAAO;QACLC,IAAA,EAAM;QACNG,KAAA,EAAOZ,CAAA,CAAE;QACTa,QAAA,EAAUf,iBAAA,IAAqBA,iBAAA,CAAkBmB;MACnD;MACAH,IAAA,EAAK;MACLf,QAAA,EAAUA,QAAA;MACVgB,UAAA,EAAW;MACXC,QAAA,EAAUzB;;;AAKpB","ignoreList":[]}
|
|
@@ -6,7 +6,8 @@ export type GutterProps = {
|
|
|
6
6
|
left?: boolean;
|
|
7
7
|
negativeLeft?: boolean;
|
|
8
8
|
negativeRight?: boolean;
|
|
9
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
9
10
|
right?: boolean;
|
|
10
11
|
};
|
|
11
|
-
export declare const Gutter: React.
|
|
12
|
+
export declare const Gutter: React.FC<GutterProps>;
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Gutter/index.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Gutter/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IACrC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAID,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA8BxC,CAAA"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import React
|
|
4
|
+
import React from 'react';
|
|
5
5
|
import './index.scss';
|
|
6
6
|
const baseClass = 'gutter';
|
|
7
|
-
export const Gutter =
|
|
7
|
+
export const Gutter = props => {
|
|
8
8
|
const {
|
|
9
9
|
children,
|
|
10
10
|
className,
|
|
11
11
|
left = true,
|
|
12
12
|
negativeLeft = false,
|
|
13
13
|
negativeRight = false,
|
|
14
|
+
ref,
|
|
14
15
|
right = true
|
|
15
16
|
} = props;
|
|
16
17
|
const shouldPadLeft = left && !negativeLeft;
|
|
@@ -20,6 +21,6 @@ export const Gutter = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
20
21
|
ref: ref,
|
|
21
22
|
children: children
|
|
22
23
|
});
|
|
23
|
-
}
|
|
24
|
+
};
|
|
24
25
|
Gutter.displayName = 'Gutter';
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","baseClass","Gutter","props","children","className","left","negativeLeft","negativeRight","ref","right","shouldPadLeft","shouldPadRight","_jsx","filter","Boolean","join","displayName"],"sources":["../../../src/elements/Gutter/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport './index.scss'\n\nexport type GutterProps = {\n children: React.ReactNode\n className?: string\n left?: boolean\n negativeLeft?: boolean\n negativeRight?: boolean\n ref?: React.RefObject<HTMLDivElement>\n right?: boolean\n}\n\nconst baseClass = 'gutter'\n\nexport const Gutter: React.FC<GutterProps> = (props) => {\n const {\n children,\n className,\n left = true,\n negativeLeft = false,\n negativeRight = false,\n ref,\n right = true,\n } = props\n\n const shouldPadLeft = left && !negativeLeft\n const shouldPadRight = right && !negativeRight\n\n return (\n <div\n className={[\n shouldPadLeft && `${baseClass}--left`,\n shouldPadRight && `${baseClass}--right`,\n negativeLeft && `${baseClass}--negative-left`,\n negativeRight && `${baseClass}--negative-right`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={ref}\n >\n {children}\n </div>\n )\n}\n\nGutter.displayName = 'Gutter'\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,OAAO;AAYP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,MAAA,GAAiCC,KAAA;EAC5C,MAAM;IACJC,QAAQ;IACRC,SAAS;IACTC,IAAA,GAAO,IAAI;IACXC,YAAA,GAAe,KAAK;IACpBC,aAAA,GAAgB,KAAK;IACrBC,GAAG;IACHC,KAAA,GAAQ;EAAI,CACb,GAAGP,KAAA;EAEJ,MAAMQ,aAAA,GAAgBL,IAAA,IAAQ,CAACC,YAAA;EAC/B,MAAMK,cAAA,GAAiBF,KAAA,IAAS,CAACF,aAAA;EAEjC,oBACEK,IAAA,CAAC;IACCR,SAAA,EAAW,CACTM,aAAA,IAAiB,GAAGV,SAAA,QAAiB,EACrCW,cAAA,IAAkB,GAAGX,SAAA,SAAkB,EACvCM,YAAA,IAAgB,GAAGN,SAAA,iBAA0B,EAC7CO,aAAA,IAAiB,GAAGP,SAAA,kBAA2B,EAC/CI,SAAA,CACD,CACES,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;IACRP,GAAA,EAAKA,GAAA;cAEJL;;AAGP;AAEAF,MAAA,CAAOe,WAAW,GAAG","ignoreList":[]}
|