@blaze-cms/admin 0.146.0-node18-tooltips.56 → 0.146.0-node18-tooltips.57

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/blaze.config.js +2 -0
  3. package/lib/components/ConfirmAction/ConfirmAction.js +92 -0
  4. package/lib/components/ConfirmAction/ConfirmAction.js.map +1 -0
  5. package/lib/components/ConfirmAction/index.js +11 -0
  6. package/lib/components/ConfirmAction/index.js.map +1 -0
  7. package/lib/components/DeleteAction/DeleteAction.js +11 -15
  8. package/lib/components/DeleteAction/DeleteAction.js.map +1 -1
  9. package/lib/components/PageHeader/HeaderIconButton.js +38 -0
  10. package/lib/components/PageHeader/HeaderIconButton.js.map +1 -0
  11. package/lib/components/PageHeader/PageHeader.js +84 -13
  12. package/lib/components/PageHeader/PageHeader.js.map +1 -1
  13. package/lib/components/PageHeader/TitleEditor.js +107 -0
  14. package/lib/components/PageHeader/TitleEditor.js.map +1 -0
  15. package/lib/index.js +7 -0
  16. package/lib/index.js.map +1 -1
  17. package/lib-es/components/ConfirmAction/ConfirmAction.js +68 -0
  18. package/lib-es/components/ConfirmAction/ConfirmAction.js.map +1 -0
  19. package/lib-es/components/ConfirmAction/index.js +3 -0
  20. package/lib-es/components/ConfirmAction/index.js.map +1 -0
  21. package/lib-es/components/DeleteAction/DeleteAction.js +13 -19
  22. package/lib-es/components/DeleteAction/DeleteAction.js.map +1 -1
  23. package/lib-es/components/PageHeader/HeaderIconButton.js +32 -0
  24. package/lib-es/components/PageHeader/HeaderIconButton.js.map +1 -0
  25. package/lib-es/components/PageHeader/PageHeader.js +80 -24
  26. package/lib-es/components/PageHeader/PageHeader.js.map +1 -1
  27. package/lib-es/components/PageHeader/TitleEditor.js +79 -0
  28. package/lib-es/components/PageHeader/TitleEditor.js.map +1 -0
  29. package/lib-es/index.js +2 -1
  30. package/lib-es/index.js.map +1 -1
  31. package/package.json +14 -13
  32. package/src/components/ConfirmAction/ConfirmAction.js +72 -0
  33. package/src/components/ConfirmAction/index.js +3 -0
  34. package/src/components/DeleteAction/DeleteAction.js +16 -23
  35. package/src/components/PageHeader/HeaderIconButton.js +27 -0
  36. package/src/components/PageHeader/PageHeader.js +90 -19
  37. package/src/components/PageHeader/TitleEditor.js +87 -0
  38. package/src/index.js +2 -0
@@ -0,0 +1,68 @@
1
+ import React, { useId, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Modal from '@blaze-react/modal';
4
+ const normalise = value => value.replace(/[\s,]/g, '');
5
+
6
+ // with confirmPhrase, confirming only runs once the phrase has been typed, for large or irreversible actions
7
+ const ConfirmAction = ({
8
+ onClose,
9
+ onConfirm,
10
+ confirmLabel,
11
+ confirmPhrase,
12
+ children
13
+ }) => {
14
+ const phraseId = useId();
15
+ const [typed, setTyped] = useState('');
16
+ const [showHint, setShowHint] = useState(false);
17
+ const confirmed = !confirmPhrase || normalise(typed) === normalise(confirmPhrase);
18
+ const alertActions = [{
19
+ callback: event => {
20
+ event.stopPropagation();
21
+ if (!confirmed) {
22
+ setShowHint(true);
23
+ return;
24
+ }
25
+ onConfirm();
26
+ },
27
+ modifiers: confirmed ? ['small'] : ['small', 'disabled'],
28
+ textButton: confirmLabel
29
+ }];
30
+ return /*#__PURE__*/React.createElement(Modal, {
31
+ actions: alertActions,
32
+ onClose: onClose,
33
+ isAlert: true
34
+ }, children, confirmPhrase && /*#__PURE__*/React.createElement("div", {
35
+ className: "confirm-action__confirm"
36
+ }, /*#__PURE__*/React.createElement("label", {
37
+ htmlFor: phraseId
38
+ }, "Type ", /*#__PURE__*/React.createElement("strong", null, confirmPhrase), " to confirm"), /*#__PURE__*/React.createElement("input", {
39
+ id: phraseId,
40
+ type: "text",
41
+ inputMode: "numeric",
42
+ autoComplete: "off",
43
+ value: typed,
44
+ onChange: ({
45
+ target: {
46
+ value
47
+ }
48
+ }) => {
49
+ setTyped(value);
50
+ setShowHint(false);
51
+ }
52
+ }), showHint && /*#__PURE__*/React.createElement("p", {
53
+ role: "alert"
54
+ }, "Type ", confirmPhrase, " to ", confirmLabel.toLowerCase(), " them all")));
55
+ };
56
+ ConfirmAction.propTypes = {
57
+ onClose: PropTypes.func.isRequired,
58
+ onConfirm: PropTypes.func.isRequired,
59
+ confirmLabel: PropTypes.string.isRequired,
60
+ confirmPhrase: PropTypes.string,
61
+ children: PropTypes.node
62
+ };
63
+ ConfirmAction.defaultProps = {
64
+ confirmPhrase: null,
65
+ children: null
66
+ };
67
+ export default ConfirmAction;
68
+ //# sourceMappingURL=ConfirmAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmAction.js","names":["React","useId","useState","PropTypes","Modal","normalise","value","replace","ConfirmAction","onClose","onConfirm","confirmLabel","confirmPhrase","children","phraseId","typed","setTyped","showHint","setShowHint","confirmed","alertActions","callback","event","stopPropagation","modifiers","textButton","createElement","actions","isAlert","className","htmlFor","id","type","inputMode","autoComplete","onChange","target","role","toLowerCase","propTypes","func","isRequired","string","node","defaultProps"],"sources":["../../../src/components/ConfirmAction/ConfirmAction.js"],"sourcesContent":["import React, { useId, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport Modal from '@blaze-react/modal';\n\nconst normalise = value => value.replace(/[\\s,]/g, '');\n\n// with confirmPhrase, confirming only runs once the phrase has been typed, for large or irreversible actions\nconst ConfirmAction = ({ onClose, onConfirm, confirmLabel, confirmPhrase, children }) => {\n const phraseId = useId();\n const [typed, setTyped] = useState('');\n const [showHint, setShowHint] = useState(false);\n const confirmed = !confirmPhrase || normalise(typed) === normalise(confirmPhrase);\n\n const alertActions = [\n {\n callback: event => {\n event.stopPropagation();\n if (!confirmed) {\n setShowHint(true);\n return;\n }\n onConfirm();\n },\n modifiers: confirmed ? ['small'] : ['small', 'disabled'],\n textButton: confirmLabel\n }\n ];\n\n return (\n <Modal actions={alertActions} onClose={onClose} isAlert>\n {children}\n {confirmPhrase && (\n <div className=\"confirm-action__confirm\">\n <label htmlFor={phraseId}>\n Type <strong>{confirmPhrase}</strong> to confirm\n </label>\n <input\n id={phraseId}\n type=\"text\"\n inputMode=\"numeric\"\n autoComplete=\"off\"\n value={typed}\n onChange={({ target: { value } }) => {\n setTyped(value);\n setShowHint(false);\n }}\n />\n {showHint && (\n <p role=\"alert\">\n Type {confirmPhrase} to {confirmLabel.toLowerCase()} them all\n </p>\n )}\n </div>\n )}\n </Modal>\n );\n};\n\nConfirmAction.propTypes = {\n onClose: PropTypes.func.isRequired,\n onConfirm: PropTypes.func.isRequired,\n confirmLabel: PropTypes.string.isRequired,\n confirmPhrase: PropTypes.string,\n children: PropTypes.node\n};\n\nConfirmAction.defaultProps = {\n confirmPhrase: null,\n children: null\n};\n\nexport default ConfirmAction;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,KAAK,EAAEC,QAAQ,QAAQ,OAAO;AAC9C,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,oBAAoB;AAEtC,MAAMC,SAAS,GAAGC,KAAK,IAAIA,KAAK,CAACC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;;AAEtD;AACA,MAAMC,aAAa,GAAGA,CAAC;EAAEC,OAAO;EAAEC,SAAS;EAAEC,YAAY;EAAEC,aAAa;EAAEC;AAAS,CAAC,KAAK;EACvF,MAAMC,QAAQ,GAAGb,KAAK,CAAC,CAAC;EACxB,MAAM,CAACc,KAAK,EAAEC,QAAQ,CAAC,GAAGd,QAAQ,CAAC,EAAE,CAAC;EACtC,MAAM,CAACe,QAAQ,EAAEC,WAAW,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAMiB,SAAS,GAAG,CAACP,aAAa,IAAIP,SAAS,CAACU,KAAK,CAAC,KAAKV,SAAS,CAACO,aAAa,CAAC;EAEjF,MAAMQ,YAAY,GAAG,CACnB;IACEC,QAAQ,EAAEC,KAAK,IAAI;MACjBA,KAAK,CAACC,eAAe,CAAC,CAAC;MACvB,I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M,CAACD,UAAU;EACzC7B,aAAa,EAAET,SAAS,CAACuC,MAAM;EAC/B7B,QAAQ,EAAEV,SAAS,CAACwC;AACtB,CAAC;AAEDnC,aAAa,CAACoC,YAAY,GAAG;EAC3BhC,aAAa,EAAE,IAAI;EACnBC,QAAQ,EAAE;AACZ,CAAC;AAED,eAAeL,aAAa","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import ConfirmAction from './ConfirmAction';
2
+ export default ConfirmAction;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ConfirmAction"],"sources":["../../../src/components/ConfirmAction/index.js"],"sourcesContent":["import ConfirmAction from './ConfirmAction';\n\nexport default ConfirmAction;\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,iBAAiB;AAE3C,eAAeA,aAAa","ignoreList":[]}
@@ -1,32 +1,26 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import Modal from '@blaze-react/modal';
3
+ import ConfirmAction from '../ConfirmAction';
4
4
  const DeleteAction = ({
5
5
  onClose,
6
6
  deleteAction,
7
- itemName
8
- }) => {
9
- const alertActions = [{
10
- callback: event => {
11
- event.stopPropagation();
12
- deleteAction();
13
- },
14
- modifiers: ['small'],
15
- textButton: 'Delete'
16
- }];
17
- return /*#__PURE__*/React.createElement(Modal, {
18
- actions: alertActions,
19
- onClose: onClose,
20
- isAlert: true
21
- }, /*#__PURE__*/React.createElement("p", null, "You are about to delete: ", /*#__PURE__*/React.createElement("strong", null, itemName)));
22
- };
7
+ itemName,
8
+ confirmPhrase
9
+ }) => /*#__PURE__*/React.createElement(ConfirmAction, {
10
+ onClose: onClose,
11
+ onConfirm: deleteAction,
12
+ confirmLabel: "Delete",
13
+ confirmPhrase: confirmPhrase
14
+ }, /*#__PURE__*/React.createElement("p", null, "You are about to delete: ", /*#__PURE__*/React.createElement("strong", null, itemName)));
23
15
  DeleteAction.propTypes = {
24
16
  onClose: PropTypes.func.isRequired,
25
17
  deleteAction: PropTypes.func.isRequired,
26
- itemName: PropTypes.string
18
+ itemName: PropTypes.string,
19
+ confirmPhrase: PropTypes.string
27
20
  };
28
21
  DeleteAction.defaultProps = {
29
- itemName: ''
22
+ itemName: '',
23
+ confirmPhrase: null
30
24
  };
31
25
  export default DeleteAction;
32
26
  //# sourceMappingURL=DeleteAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteAction.js","names":["React","PropTypes","Modal","DeleteAction","onClose","deleteAction","itemName","alertActions","callback","event","stopPropagation","modifiers","textButton","createElement","actions","isAlert","propTypes","func","isRequired","string","defaultProps"],"sources":["../../../src/components/DeleteAction/DeleteAction.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Modal from '@blaze-react/modal';\n\nconst DeleteAction = ({ onClose, deleteAction, itemName }) => {\n const alertActions = [\n {\n callback: event => {\n event.stopPropagation();\n deleteAction();\n },\n modifiers: ['small'],\n textButton: 'Delete'\n }\n ];\n\n return (\n <Modal actions={alertActions} onClose={onClose} isAlert>\n <p>\n You are about to delete: <strong>{itemName}</strong>\n </p>\n </Modal>\n );\n};\n\nDeleteAction.propTypes = {\n onClose: PropTypes.func.isRequired,\n deleteAction: PropTypes.func.isRequired,\n itemName: PropTypes.string\n};\n\nDeleteAction.defaultProps = {\n itemName: ''\n};\n\nexport default DeleteAction;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,oBAAoB;AAEtC,MAAMC,YAAY,GAAGA,CAAC;EAAEC,OAAO;EAAEC,YAAY;EAAEC;AAAS,CAAC,KAAK;EAC5D,MAAMC,YAAY,GAAG,CACnB;IACEC,QAAQ,EAAEC,KAAK,IAAI;MACjBA,KAAK,CAACC,eAAe,CAAC,CAAC;MACvBL,YAAY,CAAC,CAAC;IAChB,CAAC;IACDM,SAAS,EAAE,CAAC,OAAO,CAAC;IACpBC,UAAU,EAAE;EACd,CAAC,CACF;EAED,oBACEZ,KAAA,CAAAa,aAAA,CAACX,KAAK;IAACY,OAAO,EAAEP,YAAa;IAACH,OAAO,EAAEA,OAAQ;IAACW,OAAO;EAAA,gBACrDf,KAAA,CAAAa,aAAA,YAAG,2BACwB,eAAAb,KAAA,CAAAa,aAAA,iBAASP,QAAiB,CAClD,CACE,CAAC;AAEZ,CAAC;AAEDH,YAAY,CAACa,SAAS,GAAG;EACvBZ,OAAO,EAAEH,SAAS,CAACgB,IAAI,CAACC,UAAU;EAClCb,YAAY,EAAEJ,SAAS,CAACgB,IAAI,CAACC,UAAU;EACvCZ,QAAQ,EAAEL,SAAS,CAACkB;AACtB,CAAC;AAEDhB,YAAY,CAACiB,YAAY,GAAG;EAC1Bd,QAAQ,EAAE;AACZ,CAAC;AAED,eAAeH,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"DeleteAction.js","names":["React","PropTypes","ConfirmAction","DeleteAction","onClose","deleteAction","itemName","confirmPhrase","createElement","onConfirm","confirmLabel","propTypes","func","isRequired","string","defaultProps"],"sources":["../../../src/components/DeleteAction/DeleteAction.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport ConfirmAction from '../ConfirmAction';\n\nconst DeleteAction = ({ onClose, deleteAction, itemName, confirmPhrase }) => (\n <ConfirmAction\n onClose={onClose}\n onConfirm={deleteAction}\n confirmLabel=\"Delete\"\n confirmPhrase={confirmPhrase}>\n <p>\n You are about to delete: <strong>{itemName}</strong>\n </p>\n </ConfirmAction>\n);\n\nDeleteAction.propTypes = {\n onClose: PropTypes.func.isRequired,\n deleteAction: PropTypes.func.isRequired,\n itemName: PropTypes.string,\n confirmPhrase: PropTypes.string\n};\n\nDeleteAction.defaultProps = {\n itemName: '',\n confirmPhrase: null\n};\n\nexport default DeleteAction;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,aAAa,MAAM,kBAAkB;AAE5C,MAAMC,YAAY,GAAGA,CAAC;EAAEC,OAAO;EAAEC,YAAY;EAAEC,QAAQ;EAAEC;AAAc,CAAC,kBACtEP,KAAA,CAAAQ,aAAA,CAACN,aAAa;EACZE,OAAO,EAAEA,OAAQ;EACjBK,SAAS,EAAEJ,YAAa;EACxBK,YAAY,EAAC,QAAQ;EACrBH,aAAa,EAAEA;AAAc,gBAC7BP,KAAA,CAAAQ,aAAA,YAAG,2BACwB,eAAAR,KAAA,CAAAQ,aAAA,iBAASF,QAAiB,CAClD,CACU,CAChB;AAEDH,YAAY,CAACQ,SAAS,GAAG;EACvBP,OAAO,EAAEH,SAAS,CAACW,IAAI,CAACC,UAAU;EAClCR,YAAY,EAAEJ,SAAS,CAACW,IAAI,CAACC,UAAU;EACvCP,QAAQ,EAAEL,SAAS,CAACa,MAAM;EAC1BP,aAAa,EAAEN,SAAS,CAACa;AAC3B,CAAC;AAEDX,YAAY,CAACY,YAAY,GAAG;EAC1BT,QAAQ,EAAE,EAAE;EACZC,aAAa,EAAE;AACjB,CAAC;AAED,eAAeJ,YAAY","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["icon", "label", "className"];
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ const HeaderIconButton = _ref => {
7
+ let {
8
+ icon,
9
+ label,
10
+ className
11
+ } = _ref,
12
+ rest = _objectWithoutProperties(_ref, _excluded);
13
+ return /*#__PURE__*/React.createElement("button", _extends({
14
+ type: "button",
15
+ className: `page-header__icon-button${className ? ` ${className}` : ''}`,
16
+ title: label,
17
+ "aria-label": label
18
+ }, rest), /*#__PURE__*/React.createElement("span", {
19
+ className: "material-icons",
20
+ "aria-hidden": "true"
21
+ }, icon));
22
+ };
23
+ HeaderIconButton.propTypes = {
24
+ icon: PropTypes.string.isRequired,
25
+ label: PropTypes.string.isRequired,
26
+ className: PropTypes.string
27
+ };
28
+ HeaderIconButton.defaultProps = {
29
+ className: ''
30
+ };
31
+ export default HeaderIconButton;
32
+ //# sourceMappingURL=HeaderIconButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderIconButton.js","names":["React","PropTypes","HeaderIconButton","_ref","icon","label","className","rest","_objectWithoutProperties","_excluded","createElement","_extends","type","title","propTypes","string","isRequired","defaultProps"],"sources":["../../../src/components/PageHeader/HeaderIconButton.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst HeaderIconButton = ({ icon, label, className, ...rest }) => (\n <button\n type=\"button\"\n className={`page-header__icon-button${className ? ` ${className}` : ''}`}\n title={label}\n aria-label={label}\n {...rest}>\n <span className=\"material-icons\" aria-hidden=\"true\">\n {icon}\n </span>\n </button>\n);\n\nHeaderIconButton.propTypes = {\n icon: PropTypes.string.isRequired,\n label: PropTypes.string.isRequired,\n className: PropTypes.string\n};\n\nHeaderIconButton.defaultProps = {\n className: ''\n};\n\nexport default HeaderIconButton;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,MAAMC,gBAAgB,GAAGC,IAAA;EAAA,IAAC;MAAEC,IAAI;MAAEC,KAAK;MAAEC;IAAmB,CAAC,GAAAH,IAAA;IAANI,IAAI,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAAA,oBACzDT,KAAA,CAAAU,aAAA,WAAAC,QAAA;IACEC,IAAI,EAAC,QAAQ;IACbN,SAAS,EAAE,2BAA2BA,SAAS,GAAG,IAAIA,SAAS,EAAE,GAAG,EAAE,EAAG;IACzEO,KAAK,EAAER,KAAM;IACb,cAAYA;EAAM,GACdE,IAAI,gBACRP,KAAA,CAAAU,aAAA;IAAMJ,SAAS,EAAC,gBAAgB;IAAC,eAAY;EAAM,GAChDF,IACG,CACA,CAAC;AAAA,CACV;AAEDF,gBAAgB,CAACY,SAAS,GAAG;EAC3BV,IAAI,EAAEH,SAAS,CAACc,MAAM,CAACC,UAAU;EACjCX,KAAK,EAAEJ,SAAS,CAACc,MAAM,CAACC,UAAU;EAClCV,SAAS,EAAEL,SAAS,CAACc;AACvB,CAAC;AAEDb,gBAAgB,CAACe,YAAY,GAAG;EAC9BX,SAAS,EAAE;AACb,CAAC;AAED,eAAeJ,gBAAgB","ignoreList":[]}
@@ -1,44 +1,99 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import MetaTitle from '../MetaTitle/MetaTitle';
4
+ import HeaderIconButton from './HeaderIconButton';
5
+ import TitleEditor from './TitleEditor';
4
6
  const PageHeader = ({
5
7
  title,
6
8
  subtitle,
7
9
  children,
8
10
  pageName,
9
- onViewUrl
10
- }) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MetaTitle, {
11
- title: title,
12
- pageName: pageName
13
- }), /*#__PURE__*/React.createElement("div", {
14
- className: "page-header--wrapper"
15
- }, /*#__PURE__*/React.createElement("div", {
16
- className: "page-header page-header--sticky"
17
- }, onViewUrl ? /*#__PURE__*/React.createElement("div", {
18
- className: "page-header__heading page-header__heading--active",
19
- onClick: onViewUrl,
20
- role: "button"
21
- }, title) : /*#__PURE__*/React.createElement("div", {
22
- className: "page-header__heading"
23
- }, title), /*#__PURE__*/React.createElement("div", {
24
- className: "page-header__button"
25
- }, children)), /*#__PURE__*/React.createElement("div", {
26
- className: "page-header page-header--base"
27
- }, /*#__PURE__*/React.createElement("div", {
28
- className: "page-header__subheading"
29
- }, subtitle))));
11
+ onViewUrl,
12
+ viewUrlDisabledReason,
13
+ onTitleChange,
14
+ titleActions
15
+ }) => {
16
+ const [isEditingTitle, setIsEditingTitle] = useState(false);
17
+ const isTitleEditable = typeof onTitleChange === 'function';
18
+ // A reason renders the button disabled instead of dropping it.
19
+ const showViewButton = !!onViewUrl || !!viewUrlDisabledReason;
20
+ const hasTitleActions = isTitleEditable || !!titleActions || showViewButton;
21
+ const startEditing = () => setIsEditingTitle(true);
22
+ const stopEditing = () => setIsEditingTitle(false);
23
+ const saveTitle = nextTitle => {
24
+ stopEditing();
25
+ onTitleChange(nextTitle);
26
+ };
27
+ const renderTitle = () => {
28
+ if (isEditingTitle) {
29
+ return /*#__PURE__*/React.createElement(TitleEditor, {
30
+ title: title,
31
+ onSave: saveTitle,
32
+ onCancel: stopEditing
33
+ });
34
+ }
35
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isTitleEditable ? /*#__PURE__*/React.createElement("div", {
36
+ className: "page-header__heading page-header__heading--editable",
37
+ onClick: startEditing,
38
+ title: "Edit title",
39
+ role: "button",
40
+ tabIndex: 0,
41
+ onKeyDown: ({
42
+ key
43
+ }) => key === 'Enter' && startEditing()
44
+ }, title) : /*#__PURE__*/React.createElement("div", {
45
+ className: "page-header__heading"
46
+ }, title), hasTitleActions && /*#__PURE__*/React.createElement("div", {
47
+ className: "page-header__title-actions"
48
+ }, isTitleEditable && /*#__PURE__*/React.createElement(HeaderIconButton, {
49
+ icon: "edit",
50
+ label: "Edit title",
51
+ onClick: startEditing,
52
+ "data-testid": "page-header-title-edit"
53
+ }), titleActions, showViewButton && /*#__PURE__*/React.createElement(HeaderIconButton, {
54
+ icon: "open_in_new",
55
+ label: viewUrlDisabledReason || 'View',
56
+ className: viewUrlDisabledReason ? 'page-header__icon-button--disabled' : '',
57
+ "aria-disabled": viewUrlDisabledReason ? 'true' : undefined,
58
+ onClick: viewUrlDisabledReason ? undefined : onViewUrl,
59
+ "data-testid": "page-header-view"
60
+ })));
61
+ };
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MetaTitle, {
63
+ title: title,
64
+ pageName: pageName
65
+ }), /*#__PURE__*/React.createElement("div", {
66
+ className: "page-header--wrapper"
67
+ }, /*#__PURE__*/React.createElement("div", {
68
+ className: "page-header page-header--sticky"
69
+ }, /*#__PURE__*/React.createElement("div", {
70
+ className: "page-header__title"
71
+ }, renderTitle()), /*#__PURE__*/React.createElement("div", {
72
+ className: "page-header__button"
73
+ }, children)), /*#__PURE__*/React.createElement("div", {
74
+ className: "page-header page-header--base"
75
+ }, /*#__PURE__*/React.createElement("div", {
76
+ className: "page-header__subheading"
77
+ }, subtitle))));
78
+ };
30
79
  PageHeader.propTypes = {
31
80
  title: PropTypes.string.isRequired,
32
81
  subtitle: PropTypes.string,
33
82
  children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),
34
83
  pageName: PropTypes.string,
35
- onViewUrl: PropTypes.func
84
+ onViewUrl: PropTypes.func,
85
+ viewUrlDisabledReason: PropTypes.string,
86
+ onTitleChange: PropTypes.func,
87
+ titleActions: PropTypes.node
36
88
  };
37
89
  PageHeader.defaultProps = {
38
90
  subtitle: '',
39
91
  children: '',
40
92
  pageName: '',
41
- onViewUrl: null
93
+ onViewUrl: null,
94
+ viewUrlDisabledReason: null,
95
+ onTitleChange: null,
96
+ titleActions: null
42
97
  };
43
98
  const PageHeaderActions = ({
44
99
  children
@@ -47,5 +102,6 @@ PageHeaderActions.propTypes = {
47
102
  children: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired
48
103
  };
49
104
  PageHeader.Actions = PageHeaderActions;
105
+ PageHeader.IconButton = HeaderIconButton;
50
106
  export default PageHeader;
51
107
  //# sourceMappingURL=PageHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PageHeader.js","names":["React","PropTypes","MetaTitle","PageHeader","title","subtitle","children","pageName","onViewUrl","createElement","Fragment","className","onClick","role","propTypes","string","isRequired","oneOfType","array","object","func","defaultProps","PageHeaderActions","Children","map","child","cloneElement","Actions"],"sources":["../../../src/components/PageHeader/PageHeader.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport MetaTitle from '../MetaTitle/MetaTitle';\n\nconst PageHeader = ({ title, subtitle, children, pageName, onViewUrl }) => (\n <>\n <MetaTitle title={title} pageName={pageName} />\n <div className=\"page-header--wrapper\">\n <div className=\"page-header page-header--sticky\">\n {onViewUrl ? (\n <div\n className=\"page-header__heading page-header__heading--active\"\n onClick={onViewUrl}\n role=\"button\">\n {title}\n </div>\n ) : (\n <div className=\"page-header__heading\">{title}</div>\n )}\n <div className=\"page-header__button\">{children}</div>\n </div>\n <div className=\"page-header page-header--base\">\n <div className=\"page-header__subheading\">{subtitle}</div>\n </div>\n </div>\n </>\n);\n\nPageHeader.propTypes = {\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),\n pageName: PropTypes.string,\n onViewUrl: PropTypes.func\n};\n\nPageHeader.defaultProps = {\n subtitle: '',\n children: '',\n pageName: '',\n onViewUrl: null\n};\n\nconst PageHeaderActions = ({ children }) => (\n <>{React.Children.map(children, child => child && React.cloneElement(child))}</>\n);\n\nPageHeaderActions.propTypes = {\n children: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired\n};\n\nPageHeader.Actions = PageHeaderActions;\n\nexport default PageHeader;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,SAAS,MAAM,wBAAwB;AAE9C,MAAMC,UAAU,GAAGA,CAAC;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,QAAQ;EAAEC,QAAQ;EAAEC;AAAU,CAAC,kBACpER,KAAA,CAAAS,aAAA,CAAAT,KAAA,CAAAU,QAAA,qBACEV,KAAA,CAAAS,aAAA,CAACP,SAAS;EAACE,KAAK,EAAEA,KAAM;EAACG,QAAQ,EAAEA;AAAS,CAAE,CAAC,eAC/CP,KAAA,CAAAS,aAAA;EAAKE,SAAS,EAAC;AAAsB,gBACnCX,KAAA,CAAAS,aAAA;EAAKE,SAAS,EAAC;AAAiC,GAC7CH,SAAS,gBACRR,KAAA,CAAAS,aAAA;EACEE,SAAS,EAAC,mDAAmD;EAC7DC,OAAO,EAAEJ,SAAU;EACnBK,IAAI,EAA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AAU,CAACwB,OAAO,GAAGL,iBAAiB;AAEtC,eAAenB,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"PageHeader.js","names":["React","useState","PropTypes","MetaTitle","HeaderIconButton","TitleEditor","PageHeader","title","subtitle","children","pageName","onViewUrl","viewUrlDisabledReason","onTitleChange","titleActions","isEditingTitle","setIsEditingTitle","isTitleEditable","showViewButton","hasTitleActions","startEditing","stopEditing","saveTitle","nextTitle","renderTitle","createElement","onSave","onCancel","Fragment","className","onClick","role","tabIndex","onKeyDown","key","icon","label","undefined","propTypes","string","isRequired","oneOfType","array","object","func","node","defaultProps","PageHeaderActions","Children","map","child","cloneElement","Actions","IconButton"],"sources":["../../../src/components/PageHeader/PageHeader.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport MetaTitle from '../MetaTitle/MetaTitle';\nimport HeaderIconButton from './HeaderIconButton';\nimport TitleEditor from './TitleEditor';\n\nconst PageHeader = ({\n title,\n subtitle,\n children,\n pageName,\n onViewUrl,\n viewUrlDisabledReason,\n onTitleChange,\n titleActions\n}) => {\n const [isEditingTitle, setIsEditingTitle] = useState(false);\n const isTitleEditable = typeof onTitleChange === 'function';\n // A reason renders the button disabled instead of dropping it.\n const showViewButton = !!onViewUrl || !!viewUrlDisabledReason;\n const hasTitleActions = isTitleEditable || !!titleActions || showViewButton;\n\n const startEditing = () => setIsEditingTitle(true);\n const stopEditing = () => setIsEditingTitle(false);\n const saveTitle = nextTitle => {\n stopEditing();\n onTitleChange(nextTitle);\n };\n\n const renderTitle = () => {\n if (isEditingTitle) {\n return <TitleEditor title={title} onSave={saveTitle} onCancel={stopEditing} />;\n }\n\n return (\n <>\n {isTitleEditable ? (\n <div\n className=\"page-header__heading page-header__heading--editable\"\n onClick={startEditing}\n title=\"Edit title\"\n role=\"button\"\n tabIndex={0}\n onKeyDown={({ key }) => key === 'Enter' && startEditing()}>\n {title}\n </div>\n ) : (\n <div className=\"page-header__heading\">{title}</div>\n )}\n {hasTitleActions && (\n <div className=\"page-header__title-actions\">\n {isTitleEditable && (\n <HeaderIconButton\n icon=\"edit\"\n label=\"Edit title\"\n onClick={startEditing}\n data-testid=\"page-header-title-edit\"\n />\n )}\n {titleActions}\n {showViewButton && (\n <HeaderIconButton\n icon=\"open_in_new\"\n label={viewUrlDisabledReason || 'View'}\n className={viewUrlDisabledReason ? 'page-header__icon-button--disabled' : ''}\n aria-disabled={viewUrlDisabledReason ? 'true' : undefined}\n onClick={viewUrlDisabledReason ? undefined : onViewUrl}\n data-testid=\"page-header-view\"\n />\n )}\n </div>\n )}\n </>\n );\n };\n\n return (\n <>\n <MetaTitle title={title} pageName={pageName} />\n <div className=\"page-header--wrapper\">\n <div className=\"page-header page-header--sticky\">\n <div className=\"page-header__title\">{renderTitle()}</div>\n <div className=\"page-header__button\">{children}</div>\n </div>\n <div className=\"page-header page-header--base\">\n <div className=\"page-header__subheading\">{subtitle}</div>\n </div>\n </div>\n </>\n );\n};\n\nPageHeader.propTypes = {\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),\n pageName: PropTypes.string,\n onViewUrl: PropTypes.func,\n viewUrlDisabledReason: PropTypes.string,\n onTitleChange: PropTypes.func,\n titleActions: PropTypes.node\n};\n\nPageHeader.defaultProps = {\n subtitle: '',\n children: '',\n pageName: '',\n onViewUrl: null,\n viewUrlDisabledReason: null,\n onTitleChange: null,\n titleActions: null\n};\n\nconst PageHeaderActions = ({ children }) => (\n <>{React.Children.map(children, child => child && React.cloneElement(child))}</>\n);\n\nPageHeaderActions.propTypes = {\n children: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired\n};\n\nPageHeader.Actions = PageHeaderActions;\nPageHeader.IconButton = HeaderIconButton;\n\nexport default PageHeader;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,SA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H;AACrE,CAAC;AAEDlC,UAAU,CAAC8C,OAAO,GAAGL,iBAAiB;AACtCzC,UAAU,CAAC+C,UAAU,GAAGjD,gBAAgB;AAExC,eAAeE,UAAU","ignoreList":[]}
@@ -0,0 +1,79 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import HeaderIconButton from './HeaderIconButton';
4
+ const TitleEditor = ({
5
+ title,
6
+ onSave,
7
+ onCancel
8
+ }) => {
9
+ const [value, setValue] = useState(title);
10
+ const inputRef = useRef(null);
11
+ // Blur and the tick/cross clicks can both fire for one edit; only the first wins.
12
+ const isDone = useRef(false);
13
+ useEffect(() => {
14
+ if (inputRef.current) {
15
+ inputRef.current.focus();
16
+ inputRef.current.select();
17
+ }
18
+ }, []);
19
+ const finish = callback => {
20
+ if (isDone.current) return;
21
+ isDone.current = true;
22
+ callback();
23
+ };
24
+ const save = () => finish(() => {
25
+ const nextTitle = value.trim();
26
+ if (!nextTitle || nextTitle === title) {
27
+ onCancel();
28
+ return;
29
+ }
30
+ onSave(nextTitle);
31
+ });
32
+ const cancel = () => finish(onCancel);
33
+ const onKeyDown = event => {
34
+ if (event.key === 'Enter') {
35
+ event.preventDefault();
36
+ save();
37
+ } else if (event.key === 'Escape') {
38
+ event.preventDefault();
39
+ cancel();
40
+ }
41
+ };
42
+ const keepInputFocus = event => event.preventDefault();
43
+ return /*#__PURE__*/React.createElement("div", {
44
+ className: "page-header__title-editor"
45
+ }, /*#__PURE__*/React.createElement("input", {
46
+ ref: inputRef,
47
+ type: "text",
48
+ className: "page-header__title-input",
49
+ value: value,
50
+ onChange: ({
51
+ target
52
+ }) => setValue(target.value),
53
+ onKeyDown: onKeyDown,
54
+ onBlur: save,
55
+ "aria-label": "Title",
56
+ "data-testid": "page-header-title-input"
57
+ }), /*#__PURE__*/React.createElement("div", {
58
+ className: "page-header__title-editor-actions"
59
+ }, /*#__PURE__*/React.createElement(HeaderIconButton, {
60
+ icon: "check",
61
+ label: "Save title",
62
+ onMouseDown: keepInputFocus,
63
+ onClick: save,
64
+ "data-testid": "page-header-title-save"
65
+ }), /*#__PURE__*/React.createElement(HeaderIconButton, {
66
+ icon: "close",
67
+ label: "Cancel",
68
+ onMouseDown: keepInputFocus,
69
+ onClick: cancel,
70
+ "data-testid": "page-header-title-cancel"
71
+ })));
72
+ };
73
+ TitleEditor.propTypes = {
74
+ title: PropTypes.string.isRequired,
75
+ onSave: PropTypes.func.isRequired,
76
+ onCancel: PropTypes.func.isRequired
77
+ };
78
+ export default TitleEditor;
79
+ //# sourceMappingURL=TitleEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TitleEditor.js","names":["React","useEffect","useRef","useState","PropTypes","HeaderIconButton","TitleEditor","title","onSave","onCancel","value","setValue","inputRef","isDone","current","focus","select","finish","callback","save","nextTitle","trim","cancel","onKeyDown","event","key","preventDefault","keepInputFocus","createElement","className","ref","type","onChange","target","onBlur","icon","label","onMouseDown","onClick","propTypes","string","isRequired","func"],"sources":["../../../src/components/PageHeader/TitleEditor.js"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport HeaderIconButton from './HeaderIconButton';\n\nconst TitleEditor = ({ title, onSave, onCancel }) => {\n const [value, setValue] = useState(title);\n const inputRef = useRef(null);\n // Blur and the tick/cross clicks can both fire for one edit; only the first wins.\n const isDone = useRef(false);\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.select();\n }\n }, []);\n\n const finish = callback => {\n if (isDone.current) return;\n isDone.current = true;\n callback();\n };\n\n const save = () =>\n finish(() => {\n const nextTitle = value.trim();\n if (!nextTitle || nextTitle === title) {\n onCancel();\n return;\n }\n onSave(nextTitle);\n });\n\n const cancel = () => finish(onCancel);\n\n const onKeyDown = event => {\n if (event.key === 'Enter') {\n event.preventDefault();\n save();\n } else if (event.key === 'Escape') {\n event.preventDefault();\n cancel();\n }\n };\n\n const keepInputFocus = event => event.preventDefault();\n\n return (\n <div className=\"page-header__title-editor\">\n <input\n ref={inputRef}\n type=\"text\"\n className=\"page-header__title-input\"\n value={value}\n onChange={({ target }) => setValue(target.value)}\n onKeyDown={onKeyDown}\n onBlur={save}\n aria-label=\"Title\"\n data-testid=\"page-header-title-input\"\n />\n <div className=\"page-header__title-editor-actions\">\n <HeaderIconButton\n icon=\"check\"\n label=\"Save title\"\n onMouseDown={keepInputFocus}\n onClick={save}\n data-testid=\"page-header-title-save\"\n />\n <HeaderIconButton\n icon=\"close\"\n label=\"Cancel\"\n onMouseDown={keepInputFocus}\n onClick={cancel}\n data-testid=\"page-header-title-cancel\"\n />\n </div>\n </div>\n );\n};\n\nTitleEditor.propTypes = {\n title: PropTypes.string.isRequired,\n onSave: PropTypes.func.isRequired,\n onCancel: PropTypes.func.isRequired\n};\n\nexport default TitleEditor;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,gBAAgB,MAAM,oBAAoB;AAEjD,MAAMC,WAAW,GAAGA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAS,CAAC,KAAK;EACnD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGR,QAAQ,CAACI,KAAK,CAAC;EACzC,MAAMK,QAAQ,GAAGV,MAAM,CAAC,IAAI,CAAC;EAC7B;EACA,MAAMW,MAAM,GAAGX,MAAM,CAAC,KAAK,CAAC;EAE5BD,SAAS,CAAC,MAAM;IACd,IAAIW,QAAQ,CAACE,OAAO,EAAE;MACpBF,QAAQ,CAACE,OAAO,CAACC,KAAK,CAAC,CAAC;MACxBH,QAAQ,CAACE,OAAO,CAACE,MAAM,CAAC,CAAC;IAC3B;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,MAAM,GAAGC,QAAQ,IAAI;IACzB,IAAIL,MAAM,CAACC,OAAO,EAAE;IACpBD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BAAgB;IACf8B,IAAI,EAAC,OAAO;IACZC,KAAK,EAAC,YAAY;IAClBC,WAAW,EAAEV,cAAe;IAC5BW,OAAO,EAAEnB,IAAK;IACd,eAAY;EAAwB,CACrC,CAAC,eACFnB,KAAA,CAAA4B,aAAA,CAACvB,gBAAgB;IACf8B,IAAI,EAAC,OAAO;IACZC,KAAK,EAAC,QAAQ;IACdC,WAAW,EAAEV,cAAe;IAC5BW,OAAO,EAAEhB,MAAO;IAChB,eAAY;EAA0B,CACvC,CACE,CACF,CAAC;AAEV,CAAC;AAEDhB,WAAW,CAACiC,SAAS,GAAG;EACtBhC,KAAK,EAAEH,SAAS,CAACoC,MAAM,CAACC,UAAU;EAClCjC,MAAM,EAAEJ,SAAS,CAACsC,IAAI,CAACD,UAAU;EACjChC,QAAQ,EAAEL,SAAS,CAACsC,IAAI,CAACD;AAC3B,CAAC;AAED,eAAenC,WAAW","ignoreList":[]}
package/lib-es/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import PageHeader from './components/PageHeader';
2
2
  import DeleteAction from './components/DeleteAction';
3
+ import ConfirmAction from './components/ConfirmAction';
3
4
  import CardPrompt from './components/CardPrompt';
4
5
  import CopyDataFromAction from './components/CopyDataFromAction';
5
6
  import MetaTitle from './components/MetaTitle';
@@ -7,5 +8,5 @@ import LeaveAction from './components/LeaveAction';
7
8
  import RevertToTemplate from './components/RevertToTemplate';
8
9
  import Loading from './components/Loading';
9
10
  import { getBlazeAdmin } from './utils/get-blaze-admin';
10
- export { getBlazeAdmin, PageHeader, DeleteAction, CardPrompt, CopyDataFromAction, MetaTitle, LeaveAction, RevertToTemplate, Loading };
11
+ export { getBlazeAdmin, PageHeader, DeleteAction, ConfirmAction, CardPrompt, CopyDataFromAction, MetaTitle, LeaveAction, RevertToTemplate, Loading };
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["PageHeader","DeleteAction","CardPrompt","CopyDataFromAction","MetaTitle","LeaveAction","RevertToTemplate","Loading","getBlazeAdmin"],"sources":["../src/index.js"],"sourcesContent":["import PageHeader from './components/PageHeader';\nimport DeleteAction from './components/DeleteAction';\nimport CardPrompt from './components/CardPrompt';\nimport CopyDataFromAction from './components/CopyDataFromAction';\nimport MetaTitle from './components/MetaTitle';\nimport LeaveAction from './components/LeaveAction';\nimport RevertToTemplate from './components/RevertToTemplate';\nimport Loading from './components/Loading';\nimport { getBlazeAdmin } from './utils/get-blaze-admin';\n\nexport {\n getBlazeAdmin,\n PageHeader,\n DeleteAction,\n CardPrompt,\n CopyDataFromAction,\n MetaTitle,\n LeaveAction,\n RevertToTemplate,\n Loading\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,yBAAyB;AAChD,OAAOC,YAAY,MAAM,2BAA2B;AACpD,OAAOC,UAAU,MAAM,yBAAyB;AAChD,OAAOC,kBAAkB,MAAM,iCAAiC;AAChE,OAAOC,SAAS,MAAM,wBAAwB;AAC9C,OAAOC,WAAW,MAAM,0BAA0B;AAClD,OAAOC,gBAAgB,MAAM,+BAA+B;AAC5D,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SACEA,aAAa,EACbR,UAAU,EACVC,YAAY,EACZC,UAAU,EACVC,kBAAkB,EAClBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["PageHeader","DeleteAction","ConfirmAction","CardPrompt","CopyDataFromAction","MetaTitle","LeaveAction","RevertToTemplate","Loading","getBlazeAdmin"],"sources":["../src/index.js"],"sourcesContent":["import PageHeader from './components/PageHeader';\nimport DeleteAction from './components/DeleteAction';\nimport ConfirmAction from './components/ConfirmAction';\nimport CardPrompt from './components/CardPrompt';\nimport CopyDataFromAction from './components/CopyDataFromAction';\nimport MetaTitle from './components/MetaTitle';\nimport LeaveAction from './components/LeaveAction';\nimport RevertToTemplate from './components/RevertToTemplate';\nimport Loading from './components/Loading';\nimport { getBlazeAdmin } from './utils/get-blaze-admin';\n\nexport {\n getBlazeAdmin,\n PageHeader,\n DeleteAction,\n ConfirmAction,\n CardPrompt,\n CopyDataFromAction,\n MetaTitle,\n LeaveAction,\n RevertToTemplate,\n Loading\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,yBAAyB;AAChD,OAAOC,YAAY,MAAM,2BAA2B;AACpD,OAAOC,aAAa,MAAM,4BAA4B;AACtD,OAAOC,UAAU,MAAM,yBAAyB;AAChD,OAAOC,kBAAkB,MAAM,iCAAiC;AAChE,OAAOC,SAAS,MAAM,wBAAwB;AAC9C,OAAOC,WAAW,MAAM,0BAA0B;AAClD,OAAOC,gBAAgB,MAAM,+BAA+B;AAC5D,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SACEA,aAAa,EACbT,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,UAAU,EACVC,kBAAkB,EAClBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,OAAO","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/admin",
3
- "version": "0.146.0-node18-tooltips.56",
3
+ "version": "0.146.0-node18-tooltips.57",
4
4
  "description": "Blaze example project",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -28,18 +28,19 @@
28
28
  "license": "GPL-3.0",
29
29
  "dependencies": {
30
30
  "@apollo/client": "3.13.8",
31
- "@blaze-cms/admin-ui-utils": "0.146.0-node18-tooltips.56",
31
+ "@blaze-cms/admin-ui-utils": "0.146.0-node18-tooltips.57",
32
32
  "@blaze-cms/core-errors-ui": "0.146.0-node18-tooltips.0",
33
- "@blaze-cms/core-ui": "0.146.0-node18-tooltips.56",
34
- "@blaze-cms/plugin-admin-core-ui": "0.146.0-node18-tooltips.56",
35
- "@blaze-cms/plugin-auth-local-ui": "0.146.0-node18-tooltips.56",
36
- "@blaze-cms/plugin-auth-ui": "0.146.0-node18-tooltips.56",
37
- "@blaze-cms/plugin-data-ui": "0.146.0-node18-tooltips.56",
38
- "@blaze-cms/plugin-google-maps-ui": "0.146.0-node18-tooltips.56",
39
- "@blaze-cms/plugin-gtm-ui": "0.146.0-node18-tooltips.56",
40
- "@blaze-cms/plugin-media-ui": "0.146.0-node18-tooltips.56",
41
- "@blaze-cms/plugin-page-builder-ui": "0.146.0-node18-tooltips.56",
42
- "@blaze-cms/react-form-builder": "0.146.0-node18-tooltips.56",
33
+ "@blaze-cms/core-ui": "0.146.0-node18-tooltips.57",
34
+ "@blaze-cms/plugin-admin-core-ui": "0.146.0-node18-tooltips.57",
35
+ "@blaze-cms/plugin-auth-local-ui": "0.146.0-node18-tooltips.57",
36
+ "@blaze-cms/plugin-auth-ui": "0.146.0-node18-tooltips.57",
37
+ "@blaze-cms/plugin-data-ui": "0.146.0-node18-tooltips.57",
38
+ "@blaze-cms/plugin-google-maps-ui": "0.146.0-node18-tooltips.57",
39
+ "@blaze-cms/plugin-gtm-ui": "0.146.0-node18-tooltips.57",
40
+ "@blaze-cms/plugin-media-ui": "0.146.0-node18-tooltips.57",
41
+ "@blaze-cms/plugin-page-builder-ui": "0.146.0-node18-tooltips.57",
42
+ "@blaze-cms/plugin-workflow-ui": "0.146.0-node18-tooltips.57",
43
+ "@blaze-cms/react-form-builder": "0.146.0-node18-tooltips.57",
43
44
  "@blaze-cms/setup-ui": "0.146.0-node18-tooltips.0",
44
45
  "@blaze-react/alert": "^0.7.0",
45
46
  "@blaze-react/modal": "^0.7.0",
@@ -62,5 +63,5 @@
62
63
  "lib/*",
63
64
  "lib-es/*"
64
65
  ],
65
- "gitHead": "0ad2cbe6ec8687c479f0b7d7e75e4dac01f71a41"
66
+ "gitHead": "4c80ae4772355ab8bc8414ffbfe6ea18f46a68a5"
66
67
  }
@@ -0,0 +1,72 @@
1
+ import React, { useId, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Modal from '@blaze-react/modal';
4
+
5
+ const normalise = value => value.replace(/[\s,]/g, '');
6
+
7
+ // with confirmPhrase, confirming only runs once the phrase has been typed, for large or irreversible actions
8
+ const ConfirmAction = ({ onClose, onConfirm, confirmLabel, confirmPhrase, children }) => {
9
+ const phraseId = useId();
10
+ const [typed, setTyped] = useState('');
11
+ const [showHint, setShowHint] = useState(false);
12
+ const confirmed = !confirmPhrase || normalise(typed) === normalise(confirmPhrase);
13
+
14
+ const alertActions = [
15
+ {
16
+ callback: event => {
17
+ event.stopPropagation();
18
+ if (!confirmed) {
19
+ setShowHint(true);
20
+ return;
21
+ }
22
+ onConfirm();
23
+ },
24
+ modifiers: confirmed ? ['small'] : ['small', 'disabled'],
25
+ textButton: confirmLabel
26
+ }
27
+ ];
28
+
29
+ return (
30
+ <Modal actions={alertActions} onClose={onClose} isAlert>
31
+ {children}
32
+ {confirmPhrase && (
33
+ <div className="confirm-action__confirm">
34
+ <label htmlFor={phraseId}>
35
+ Type <strong>{confirmPhrase}</strong> to confirm
36
+ </label>
37
+ <input
38
+ id={phraseId}
39
+ type="text"
40
+ inputMode="numeric"
41
+ autoComplete="off"
42
+ value={typed}
43
+ onChange={({ target: { value } }) => {
44
+ setTyped(value);
45
+ setShowHint(false);
46
+ }}
47
+ />
48
+ {showHint && (
49
+ <p role="alert">
50
+ Type {confirmPhrase} to {confirmLabel.toLowerCase()} them all
51
+ </p>
52
+ )}
53
+ </div>
54
+ )}
55
+ </Modal>
56
+ );
57
+ };
58
+
59
+ ConfirmAction.propTypes = {
60
+ onClose: PropTypes.func.isRequired,
61
+ onConfirm: PropTypes.func.isRequired,
62
+ confirmLabel: PropTypes.string.isRequired,
63
+ confirmPhrase: PropTypes.string,
64
+ children: PropTypes.node
65
+ };
66
+
67
+ ConfirmAction.defaultProps = {
68
+ confirmPhrase: null,
69
+ children: null
70
+ };
71
+
72
+ export default ConfirmAction;
@@ -0,0 +1,3 @@
1
+ import ConfirmAction from './ConfirmAction';
2
+
3
+ export default ConfirmAction;