@blaze-cms/admin 1.1.0-rc-eagle-3.0 → 1.1.0-rc-eagle-3.2

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.
@@ -14,6 +14,7 @@ var _pluginMediaUi = _interopRequireDefault(require("@blaze-cms/plugin-media-ui"
14
14
  var _pluginGtmUi = _interopRequireDefault(require("@blaze-cms/plugin-gtm-ui"));
15
15
  var _pluginGoogleMapsUi = _interopRequireDefault(require("@blaze-cms/plugin-google-maps-ui"));
16
16
  var _pluginRenderHooksUi = _interopRequireDefault(require("@blaze-cms/plugin-render-hooks-ui"));
17
+ var _pluginWorkflowUi = _interopRequireDefault(require("@blaze-cms/plugin-workflow-ui"));
17
18
  const plugins = new Map();
18
19
  plugins.set(_pluginAuthLocalUi.default, {});
19
20
  plugins.set(_pluginAdminCoreUi.default, {});
@@ -24,6 +25,7 @@ plugins.set(_pluginMediaUi.default, {});
24
25
  plugins.set(_pluginGtmUi.default, {});
25
26
  plugins.set(_pluginGoogleMapsUi.default, {});
26
27
  plugins.set(_pluginRenderHooksUi.default, {});
28
+ plugins.set(_pluginWorkflowUi.default, {});
27
29
  const apollo = {
28
30
  addTypename: false
29
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"blaze.config.js","names":["_pluginAuthLocalUi","_interopRequireDefault","require","_pluginAdminCoreUi","_pluginAuthUi","_pluginDataUi","_pluginPageBuilderUi","_pluginMediaUi","_pluginGtmUi","_pluginGoogleMapsUi","_pluginRenderHooksUi","plugins","Map","set","authLocal","coreUI","auth","data","pageBuilder","media","gtm","googleMaps","renderHooks","apollo","addTypename","_default","exports","default"],"sources":["../src/blaze.config.js"],"sourcesContent":["import authLocal from '@blaze-cms/plugin-auth-local-ui';\nimport coreUI from '@blaze-cms/plugin-admin-core-ui';\nimport auth from '@blaze-cms/plugin-auth-ui';\nimport data from '@blaze-cms/plugin-data-ui';\nimport pageBuilder from '@blaze-cms/plugin-page-builder-ui';\nimport media from '@blaze-cms/plugin-media-ui';\nimport gtm from '@blaze-cms/plugin-gtm-ui';\nimport googleMaps from '@blaze-cms/plugin-google-maps-ui';\nimport renderHooks from '@blaze-cms/plugin-render-hooks-ui';\n\nconst plugins = new Map();\nplugins.set(authLocal, {});\nplugins.set(coreUI, {});\nplugins.set(auth, {});\nplugins.set(data, {});\nplugins.set(pageBuilder, {});\nplugins.set(media, {});\nplugins.set(gtm, {});\nplugins.set(googleMaps, {});\nplugins.set(renderHooks, {});\n\nconst apollo = { addTypename: false };\nexport default { plugins, apollo };\n"],"mappings":";;;;;;;AAAA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,oBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,cAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,mBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,oBAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA,MAAMS,OAAO,GAAG,IAAIC,GAAG,CAAC,CAAC;AACzBD,OAAO,CAACE,GAAG,CAACC,0BAAS,EAAE,CAAC,CAAC,CAAC;AAC1BH,OAAO,CAACE,GAAG,CAACE,0BAAM,EAAE,CAAC,CAAC,CAAC;AACvBJ,OAAO,CAACE,GAAG,CAACG,qBAAI,EAAE,CAAC,CAAC,CAAC;AACrBL,OAAO,CAACE,GAAG,CAACI,qBAAI,EAAE,CAAC,CAAC,CAAC;AACrBN,OAAO,CAACE,GAAG,CAACK,4BAAW,EAAE,CAAC,CAAC,CAAC;AAC5BP,OAAO,CAACE,GAAG,CAACM,sBAAK,EAAE,CAAC,CAAC,CAAC;AACtBR,OAAO,CAACE,GAAG,CAACO,oBAAG,EAAE,CAAC,CAAC,CAAC;AACpBT,OAAO,CAACE,GAAG,CAACQ,2BAAU,EAAE,CAAC,CAAC,CAAC;AAC3BV,OAAO,CAACE,GAAG,CAACS,4BAAW,EAAE,CAAC,CAAC,CAAC;AAE5B,MAAMC,MAAM,GAAG;EAAEC,WAAW,EAAE;AAAM,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACvB;EAAEhB,OAAO;EAAEY;AAAO,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"blaze.config.js","names":["_pluginAuthLocalUi","_interopRequireDefault","require","_pluginAdminCoreUi","_pluginAuthUi","_pluginDataUi","_pluginPageBuilderUi","_pluginMediaUi","_pluginGtmUi","_pluginGoogleMapsUi","_pluginRenderHooksUi","_pluginWorkflowUi","plugins","Map","set","authLocal","coreUI","auth","data","pageBuilder","media","gtm","googleMaps","renderHooks","workflow","apollo","addTypename","_default","exports","default"],"sources":["../src/blaze.config.js"],"sourcesContent":["import authLocal from '@blaze-cms/plugin-auth-local-ui';\nimport coreUI from '@blaze-cms/plugin-admin-core-ui';\nimport auth from '@blaze-cms/plugin-auth-ui';\nimport data from '@blaze-cms/plugin-data-ui';\nimport pageBuilder from '@blaze-cms/plugin-page-builder-ui';\nimport media from '@blaze-cms/plugin-media-ui';\nimport gtm from '@blaze-cms/plugin-gtm-ui';\nimport googleMaps from '@blaze-cms/plugin-google-maps-ui';\nimport renderHooks from '@blaze-cms/plugin-render-hooks-ui';\nimport workflow from '@blaze-cms/plugin-workflow-ui';\n\nconst plugins = new Map();\nplugins.set(authLocal, {});\nplugins.set(coreUI, {});\nplugins.set(auth, {});\nplugins.set(data, {});\nplugins.set(pageBuilder, {});\nplugins.set(media, {});\nplugins.set(gtm, {});\nplugins.set(googleMaps, {});\nplugins.set(renderHooks, {});\nplugins.set(workflow, {});\n\nconst apollo = { addTypename: false };\nexport default { plugins, apollo };\n"],"mappings":";;;;;;;AAAA,IAAAA,kBA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,OAAA,GACvB;EAAEjB,OAAO;EAAEa;AAAO,CAAC","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _modal = _interopRequireDefault(require("@blaze-react/modal"));
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ const normalise = value => value.replace(/[\s,]/g, '');
13
+
14
+ // with confirmPhrase, confirming only runs once the phrase has been typed, for large or irreversible actions
15
+ const ConfirmAction = ({
16
+ onClose,
17
+ onConfirm,
18
+ confirmLabel,
19
+ confirmPhrase,
20
+ children
21
+ }) => {
22
+ const phraseId = (0, _react.useId)();
23
+ const [typed, setTyped] = (0, _react.useState)('');
24
+ const [showHint, setShowHint] = (0, _react.useState)(false);
25
+ const confirmed = !confirmPhrase || normalise(typed) === normalise(confirmPhrase);
26
+ const alertActions = [{
27
+ callback: event => {
28
+ event.stopPropagation();
29
+ if (!confirmed) {
30
+ setShowHint(true);
31
+ return;
32
+ }
33
+ onConfirm();
34
+ },
35
+ modifiers: confirmed ? ['small'] : ['small', 'disabled'],
36
+ textButton: confirmLabel
37
+ }];
38
+ return /*#__PURE__*/_react.default.createElement(_modal.default, {
39
+ actions: alertActions,
40
+ onClose: onClose,
41
+ isAlert: true
42
+ }, children, confirmPhrase && /*#__PURE__*/_react.default.createElement("div", {
43
+ className: "confirm-action__confirm"
44
+ }, /*#__PURE__*/_react.default.createElement("label", {
45
+ htmlFor: phraseId
46
+ }, "Type ", /*#__PURE__*/_react.default.createElement("strong", null, confirmPhrase), " to confirm"), /*#__PURE__*/_react.default.createElement("input", {
47
+ id: phraseId,
48
+ type: "text",
49
+ inputMode: "numeric",
50
+ autoComplete: "off",
51
+ value: typed,
52
+ onChange: ({
53
+ target: {
54
+ value
55
+ }
56
+ }) => {
57
+ setTyped(value);
58
+ setShowHint(false);
59
+ }
60
+ }), showHint && /*#__PURE__*/_react.default.createElement("p", {
61
+ role: "alert"
62
+ }, "Type ", confirmPhrase, " to ", confirmLabel.toLowerCase(), " them all")));
63
+ };
64
+ ConfirmAction.propTypes = {
65
+ onClose: _propTypes.default.func.isRequired,
66
+ onConfirm: _propTypes.default.func.isRequired,
67
+ confirmLabel: _propTypes.default.string.isRequired,
68
+ confirmPhrase: _propTypes.default.string,
69
+ children: _propTypes.default.node
70
+ };
71
+ ConfirmAction.defaultProps = {
72
+ confirmPhrase: null,
73
+ children: null
74
+ };
75
+ var _default = exports.default = ConfirmAction;
76
+ //# sourceMappingURL=ConfirmAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmAction.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_modal","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","normalise","value","replace","ConfirmAction","onClose","onConfirm","confirmLabel","confirmPhrase","children","phraseId","useId","typed","setTyped","useState","showHint","setShowHint","confirmed","alertActions","callback","event","stopPropagation","modifiers","textButton","createElement","actions","isAlert","className","htmlFor","id","type","inputMode","autoComplete","onChange","target","role","toLowerCase","propTypes","PropTypes","func","isRequired","string","node","defaultProps","_default","exports"],"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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAAuC,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,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;EAAE,CACH,CAAC,EACDD,QAAQ,iBACPvC,MAAA,CAAAgB,OAAA,CAAAgC,aAAA;IAAGW,IAAI,EAAC;EAAO,GAAC,OACT,EAAC3B,aAAa,EAAC,MAAI,EAACD,YAAY,CAAC6B,WAAW,CAAC,CAAC,EAAC,WACnD,CAEF,CAEF,CAAC;AAEZ,CAAC;AAEDhC,aAAa,CAACiC,SAAS,GAAG;EACxBhC,OAAO,EAAEiC,kBAAS,CAACC,IAAI,CAACC,UAAU;EAClClC,SAAS,EAAEgC,kBAAS,CAACC,IAAI,CAACC,UAAU;EACpCjC,YAAY,EAAE+B,kBAAS,CAACG,MAAM,CAACD,UAAU;EACzChC,aAAa,EAAE8B,kBAAS,CAACG,MAAM;EAC/BhC,QAAQ,EAAE6B,kBAAS,CAACI;AACtB,CAAC;AAEDtC,aAAa,CAACuC,YAAY,GAAG;EAC3BnC,aAAa,EAAE,IAAI;EACnBC,QAAQ,EAAE;AACZ,CAAC;AAAC,IAAAmC,QAAA,GAAAC,OAAA,CAAArD,OAAA,GAEaY,aAAa","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _ConfirmAction = _interopRequireDefault(require("./ConfirmAction"));
9
+ var _default = exports.default = _ConfirmAction.default;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_ConfirmAction","_interopRequireDefault","require","_default","exports","default","ConfirmAction"],"sources":["../../../src/components/ConfirmAction/index.js"],"sourcesContent":["import ConfirmAction from './ConfirmAction';\n\nexport default ConfirmAction;\n"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE7BC,sBAAa","ignoreList":[]}
@@ -7,33 +7,27 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _modal = _interopRequireDefault(require("@blaze-react/modal"));
10
+ var _ConfirmAction = _interopRequireDefault(require("../ConfirmAction"));
11
11
  const DeleteAction = ({
12
12
  onClose,
13
13
  deleteAction,
14
- itemName
15
- }) => {
16
- const alertActions = [{
17
- callback: event => {
18
- event.stopPropagation();
19
- deleteAction();
20
- },
21
- modifiers: ['small'],
22
- textButton: 'Delete'
23
- }];
24
- return /*#__PURE__*/_react.default.createElement(_modal.default, {
25
- actions: alertActions,
26
- onClose: onClose,
27
- isAlert: true
28
- }, /*#__PURE__*/_react.default.createElement("p", null, "You are about to delete: ", /*#__PURE__*/_react.default.createElement("strong", null, itemName)));
29
- };
14
+ itemName,
15
+ confirmPhrase
16
+ }) => /*#__PURE__*/_react.default.createElement(_ConfirmAction.default, {
17
+ onClose: onClose,
18
+ onConfirm: deleteAction,
19
+ confirmLabel: "Delete",
20
+ confirmPhrase: confirmPhrase
21
+ }, /*#__PURE__*/_react.default.createElement("p", null, "You are about to delete: ", /*#__PURE__*/_react.default.createElement("strong", null, itemName)));
30
22
  DeleteAction.propTypes = {
31
23
  onClose: _propTypes.default.func.isRequired,
32
24
  deleteAction: _propTypes.default.func.isRequired,
33
- itemName: _propTypes.default.string
25
+ itemName: _propTypes.default.string,
26
+ confirmPhrase: _propTypes.default.string
34
27
  };
35
28
  DeleteAction.defaultProps = {
36
- itemName: ''
29
+ itemName: '',
30
+ confirmPhrase: null
37
31
  };
38
32
  var _default = exports.default = DeleteAction;
39
33
  //# sourceMappingURL=DeleteAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteAction.js","names":["_react","_interopRequireDefault","require","_propTypes","_modal","DeleteAction","onClose","deleteAction","itemName","alertActions","callback","event","stopPropagation","modifiers","textButton","default","createElement","actions","isAlert","propTypes","PropTypes","func","isRequired","string","defaultProps","_default","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,MAAMG,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,oBACEd,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACZ,MAAA,CAAAW,OAAK;IAACE,OAAO,EAAER,YAAa;IAACH,OAAO,EAAEA,OAAQ;IAACY,OAAO;EAAA,gBACrDlB,MAAA,CAAAe,OAAA,CAAAC,aAAA,YAAG,2BACwB,eAAAhB,MAAA,CAAAe,OAAA,CAAAC,aAAA,iBAASR,QAAiB,CAClD,CACE,CAAC;AAEZ,CAAC;AAEDH,YAAY,CAACc,SAAS,GAAG;EACvBb,OAAO,EAAEc,kBAAS,CAACC,IAAI,CAACC,UAAU;EAClCf,YAAY,EAAEa,kBAAS,CAACC,IAAI,CAACC,UAAU;EACvCd,QAAQ,EAAEY,kBAAS,CAACG;AACtB,CAAC;AAEDlB,YAAY,CAACmB,YAAY,GAAG;EAC1BhB,QAAQ,EAAE;AACZ,CAAC;AAAC,IAAAiB,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEaV,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"DeleteAction.js","names":["_react","_interopRequireDefault","require","_propTypes","_ConfirmAction","DeleteAction","onClose","deleteAction","itemName","confirmPhrase","default","createElement","onConfirm","confirmLabel","propTypes","PropTypes","func","isRequired","string","defaultProps","_default","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,MAAMG,YAAY,GAAGA,CAAC;EAAEC,OAAO;EAAEC,YAAY;EAAEC,QAAQ;EAAEC;AAAc,CAAC,kBACtET,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAACP,cAAA,CAAAM,OAAa;EACZJ,OAAO,EAAEA,OAAQ;EACjBM,SAAS,EAAEL,YAAa;EACxBM,YAAY,EAAC,QAAQ;EACrBJ,aAAa,EAAEA;AAAc,gBAC7BT,MAAA,CAAAU,OAAA,CAAAC,aAAA,YAAG,2BACwB,eAAAX,MAAA,CAAAU,OAAA,CAAAC,aAAA,iBAASH,QAAiB,CAClD,CACU,CAChB;AAEDH,YAAY,CAACS,SAAS,GAAG;EACvBR,OAAO,EAAES,kBAAS,CAACC,IAAI,CAACC,UAAU;EAClCV,YAAY,EAAEQ,kBAAS,CAACC,IAAI,CAACC,UAAU;EACvCT,QAAQ,EAAEO,kBAAS,CAACG,MAAM;EAC1BT,aAAa,EAAEM,kBAAS,CAACG;AAC3B,CAAC;AAEDb,YAAY,CAACc,YAAY,GAAG;EAC1BX,QAAQ,EAAE,EAAE;EACZC,aAAa,EAAE;AACjB,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEaL,YAAY","ignoreList":[]}
package/lib/index.js CHANGED
@@ -10,6 +10,12 @@ Object.defineProperty(exports, "CardPrompt", {
10
10
  return _CardPrompt.default;
11
11
  }
12
12
  });
13
+ Object.defineProperty(exports, "ConfirmAction", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _ConfirmAction.default;
17
+ }
18
+ });
13
19
  Object.defineProperty(exports, "CopyDataFromAction", {
14
20
  enumerable: true,
15
21
  get: function () {
@@ -60,6 +66,7 @@ Object.defineProperty(exports, "getBlazeAdmin", {
60
66
  });
61
67
  var _PageHeader = _interopRequireDefault(require("./components/PageHeader"));
62
68
  var _DeleteAction = _interopRequireDefault(require("./components/DeleteAction"));
69
+ var _ConfirmAction = _interopRequireDefault(require("./components/ConfirmAction"));
63
70
  var _CardPrompt = _interopRequireDefault(require("./components/CardPrompt"));
64
71
  var _CopyDataFromAction = _interopRequireDefault(require("./components/CopyDataFromAction"));
65
72
  var _MetaTitle = _interopRequireDefault(require("./components/MetaTitle"));
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_PageHeader","_interopRequireDefault","require","_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,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,YAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,iBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,QAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,cAAA,GAAAR,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_PageHeader","_interopRequireDefault","require","_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,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,mBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,iBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,QAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,cAAA,GAAAT,OAAA","ignoreList":[]}
@@ -7,6 +7,7 @@ import media from '@blaze-cms/plugin-media-ui';
7
7
  import gtm from '@blaze-cms/plugin-gtm-ui';
8
8
  import googleMaps from '@blaze-cms/plugin-google-maps-ui';
9
9
  import renderHooks from '@blaze-cms/plugin-render-hooks-ui';
10
+ import workflow from '@blaze-cms/plugin-workflow-ui';
10
11
  const plugins = new Map();
11
12
  plugins.set(authLocal, {});
12
13
  plugins.set(coreUI, {});
@@ -17,6 +18,7 @@ plugins.set(media, {});
17
18
  plugins.set(gtm, {});
18
19
  plugins.set(googleMaps, {});
19
20
  plugins.set(renderHooks, {});
21
+ plugins.set(workflow, {});
20
22
  const apollo = {
21
23
  addTypename: false
22
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"blaze.config.js","names":["authLocal","coreUI","auth","data","pageBuilder","media","gtm","googleMaps","renderHooks","plugins","Map","set","apollo","addTypename"],"sources":["../src/blaze.config.js"],"sourcesContent":["import authLocal from '@blaze-cms/plugin-auth-local-ui';\nimport coreUI from '@blaze-cms/plugin-admin-core-ui';\nimport auth from '@blaze-cms/plugin-auth-ui';\nimport data from '@blaze-cms/plugin-data-ui';\nimport pageBuilder from '@blaze-cms/plugin-page-builder-ui';\nimport media from '@blaze-cms/plugin-media-ui';\nimport gtm from '@blaze-cms/plugin-gtm-ui';\nimport googleMaps from '@blaze-cms/plugin-google-maps-ui';\nimport renderHooks from '@blaze-cms/plugin-render-hooks-ui';\n\nconst plugins = new Map();\nplugins.set(authLocal, {});\nplugins.set(coreUI, {});\nplugins.set(auth, {});\nplugins.set(data, {});\nplugins.set(pageBuilder, {});\nplugins.set(media, {});\nplugins.set(gtm, {});\nplugins.set(googleMaps, {});\nplugins.set(renderHooks, {});\n\nconst apollo = { addTypename: false };\nexport default { plugins, apollo };\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,iCAAiC;AACvD,OAAOC,MAAM,MAAM,iCAAiC;AACpD,OAAOC,IAAI,MAAM,2BAA2B;AAC5C,OAAOC,IAAI,MAAM,2BAA2B;AAC5C,OAAOC,WAAW,MAAM,mCAAmC;AAC3D,OAAOC,KAAK,MAAM,4BAA4B;AAC9C,OAAOC,GAAG,MAAM,0BAA0B;AAC1C,OAAOC,UAAU,MAAM,kCAAkC;AACzD,OAAOC,WAAW,MAAM,mCAAmC;AAE3D,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAAC,CAAC;AACzBD,OAAO,CAACE,GAAG,CAACX,SAAS,EAAE,CAAC,CAAC,CAAC;AAC1BS,OAAO,CAACE,GAAG,CAACV,MAAM,EAAE,CAAC,CAAC,CAAC;AACvBQ,OAAO,CAACE,GAAG,CAACT,IAAI,EAAE,CAAC,CAAC,CAAC;AACrBO,OAAO,CAACE,GAAG,CAACR,IAAI,EAAE,CAAC,CAAC,CAAC;AACrBM,OAAO,CAACE,GAAG,CAACP,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5BK,OAAO,CAACE,GAAG,CAACN,KAAK,EAAE,CAAC,CAAC,CAAC;AACtBI,OAAO,CAACE,GAAG,CAACL,GAAG,EAAE,CAAC,CAAC,CAAC;AACpBG,OAAO,CAACE,GAAG,CAACJ,UAAU,EAAE,CAAC,CAAC,CAAC;AAC3BE,OAAO,CAACE,GAAG,CAACH,WAAW,EAAE,CAAC,CAAC,CAAC;AAE5B,MAAMI,MAAM,GAAG;EAAEC,WAAW,EAAE;AAAM,CAAC;AACrC,eAAe;EAAEJ,OAAO;EAAEG;AAAO,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"blaze.config.js","names":["authLocal","coreUI","auth","data","pageBuilder","media","gtm","googleMaps","renderHooks","workflow","plugins","Map","set","apollo","addTypename"],"sources":["../src/blaze.config.js"],"sourcesContent":["import authLocal from '@blaze-cms/plugin-auth-local-ui';\nimport coreUI from '@blaze-cms/plugin-admin-core-ui';\nimport auth from '@blaze-cms/plugin-auth-ui';\nimport data from '@blaze-cms/plugin-data-ui';\nimport pageBuilder from '@blaze-cms/plugin-page-builder-ui';\nimport media from '@blaze-cms/plugin-media-ui';\nimport gtm from '@blaze-cms/plugin-gtm-ui';\nimport googleMaps from '@blaze-cms/plugin-google-maps-ui';\nimport renderHooks from '@blaze-cms/plugin-render-hooks-ui';\nimport workflow from '@blaze-cms/plugin-workflow-ui';\n\nconst plugins = new Map();\nplugins.set(authLocal, {});\nplugins.set(coreUI, {});\nplugins.set(auth, {});\nplugins.set(data, {});\nplugins.set(pageBuilder, {});\nplugins.set(media, {});\nplugins.set(gtm, {});\nplugins.set(googleMaps, {});\nplugins.set(renderHooks, {});\nplugins.set(workflow, {});\n\nconst apollo = { addTypename: false };\nexport default { plugins, apollo };\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,iCAAiC;AACvD,OAAOC,MAAM,MAAM,iCAAiC;AACpD,OAAOC,IAAI,MAAM,2BAA2B;AAC5C,OAAOC,IAAI,MAAM,2BAA2B;AAC5C,OAAOC,WAAW,MAAM,mCAAmC;AAC3D,OAAOC,KAAK,MAAM,4BAA4B;AAC9C,OAAOC,GAAG,MAAM,0BAA0B;AAC1C,OAAOC,UAAU,MAAM,kCAAkC;AACzD,OAAOC,WAAW,MAAM,mCAAmC;AAC3D,OAAOC,QAAQ,MAAM,+BAA+B;AAEpD,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAAC,CAAC;AACzBD,OAAO,CAACE,GAAG,CAACZ,SAAS,EAAE,CAAC,CAAC,CAAC;AAC1BU,OAAO,CAACE,GAAG,CAACX,MAAM,EAAE,CAAC,CAAC,CAAC;AACvBS,OAAO,CAACE,GAAG,CAACV,IAAI,EAAE,CAAC,CAAC,CAAC;AACrBQ,OAAO,CAACE,GAAG,CAACT,IAAI,EAAE,CAAC,CAAC,CAAC;AACrBO,OAAO,CAACE,GAAG,CAACR,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5BM,OAAO,CAACE,GAAG,CAACP,KAAK,EAAE,CAAC,CAAC,CAAC;AACtBK,OAAO,CAACE,GAAG,CAACN,GAAG,EAAE,CAAC,CAAC,CAAC;AACpBI,OAAO,CAACE,GAAG,CAACL,UAAU,EAAE,CAAC,CAAC,CAAC;AAC3BG,OAAO,CAACE,GAAG,CAACJ,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5BE,OAAO,CAACE,GAAG,CAACH,QAAQ,EAAE,CAAC,CAAC,CAAC;AAEzB,MAAMI,MAAM,GAAG;EAAEC,WAAW,EAAE;AAAM,CAAC;AACrC,eAAe;EAAEJ,OAAO;EAAEG;AAAO,CAAC","ignoreList":[]}
@@ -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,IAAI,CAACJ,SAAS,EAAE;QACdD,WAAW,CAAC,IAAI,CAAC;QACjB;MACF;MACAR,SAAS,CAAC,CAAC;IACb,CAAC;IACDc,SAAS,EAAEL,SAAS,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC;IACxDM,UAAU,EAAEd;EACd,CAAC,CACF;EAED,oBACEX,KAAA,CAAA0B,aAAA,CAACtB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ction 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":[]}
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": "1.1.0-rc-eagle-3.0",
3
+ "version": "1.1.0-rc-eagle-3.2",
4
4
  "description": "Blaze example project",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -35,15 +35,16 @@
35
35
  "@apollo/client": "3.13.8",
36
36
  "@blaze-cms/admin-ui-utils": "1.1.0-rc-eagle-3.0",
37
37
  "@blaze-cms/core-errors-ui": "0.146.0-rc-eagle-3.0",
38
- "@blaze-cms/core-ui": "0.146.0-rc-eagle-3.6",
39
- "@blaze-cms/plugin-admin-core-ui": "1.1.0-rc-eagle-3.0",
40
- "@blaze-cms/plugin-auth-local-ui": "1.1.0-rc-eagle-3.0",
41
- "@blaze-cms/plugin-auth-ui": "1.1.0-rc-eagle-3.0",
42
- "@blaze-cms/plugin-data-ui": "1.1.0-rc-eagle-3.0",
43
- "@blaze-cms/plugin-google-maps-ui": "1.1.0-rc-eagle-3.0",
44
- "@blaze-cms/plugin-gtm-ui": "1.1.0-rc-eagle-3.0",
45
- "@blaze-cms/plugin-media-ui": "1.1.0-rc-eagle-3.0",
46
- "@blaze-cms/plugin-page-builder-ui": "1.1.0-rc-eagle-3.0",
38
+ "@blaze-cms/core-ui": "1.1.0-rc-eagle-3.2",
39
+ "@blaze-cms/plugin-admin-core-ui": "1.1.0-rc-eagle-3.2",
40
+ "@blaze-cms/plugin-auth-local-ui": "1.1.0-rc-eagle-3.2",
41
+ "@blaze-cms/plugin-auth-ui": "1.1.0-rc-eagle-3.2",
42
+ "@blaze-cms/plugin-data-ui": "1.1.0-rc-eagle-3.2",
43
+ "@blaze-cms/plugin-google-maps-ui": "1.1.0-rc-eagle-3.2",
44
+ "@blaze-cms/plugin-gtm-ui": "1.1.0-rc-eagle-3.2",
45
+ "@blaze-cms/plugin-media-ui": "1.1.0-rc-eagle-3.2",
46
+ "@blaze-cms/plugin-page-builder-ui": "1.1.0-rc-eagle-3.2",
47
+ "@blaze-cms/plugin-workflow-ui": "1.1.0-rc-eagle-3.0",
47
48
  "@blaze-cms/react-form-builder": "1.1.0-rc-eagle-3.0",
48
49
  "@blaze-cms/setup-ui": "0.146.0-rc-eagle-3.0",
49
50
  "@blaze-react/alert": "^0.7.0",
@@ -65,5 +66,5 @@
65
66
  "lib/*",
66
67
  "lib-es/*"
67
68
  ],
68
- "gitHead": "7517fca5760cbb08f3e26b6a5a31feb90e6089f8"
69
+ "gitHead": "a1973b682f978b3c279896e1cb1f4eca2e82598a"
69
70
  }
@@ -7,6 +7,7 @@ import media from '@blaze-cms/plugin-media-ui';
7
7
  import gtm from '@blaze-cms/plugin-gtm-ui';
8
8
  import googleMaps from '@blaze-cms/plugin-google-maps-ui';
9
9
  import renderHooks from '@blaze-cms/plugin-render-hooks-ui';
10
+ import workflow from '@blaze-cms/plugin-workflow-ui';
10
11
 
11
12
  const plugins = new Map();
12
13
  plugins.set(authLocal, {});
@@ -18,6 +19,7 @@ plugins.set(media, {});
18
19
  plugins.set(gtm, {});
19
20
  plugins.set(googleMaps, {});
20
21
  plugins.set(renderHooks, {});
22
+ plugins.set(workflow, {});
21
23
 
22
24
  const apollo = { addTypename: false };
23
25
  export default { plugins, apollo };
@@ -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;
@@ -1,36 +1,29 @@
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
 
5
- const DeleteAction = ({ onClose, deleteAction, itemName }) => {
6
- const alertActions = [
7
- {
8
- callback: event => {
9
- event.stopPropagation();
10
- deleteAction();
11
- },
12
- modifiers: ['small'],
13
- textButton: 'Delete'
14
- }
15
- ];
16
-
17
- return (
18
- <Modal actions={alertActions} onClose={onClose} isAlert>
19
- <p>
20
- You are about to delete: <strong>{itemName}</strong>
21
- </p>
22
- </Modal>
23
- );
24
- };
5
+ const DeleteAction = ({ onClose, deleteAction, itemName, confirmPhrase }) => (
6
+ <ConfirmAction
7
+ onClose={onClose}
8
+ onConfirm={deleteAction}
9
+ confirmLabel="Delete"
10
+ confirmPhrase={confirmPhrase}>
11
+ <p>
12
+ You are about to delete: <strong>{itemName}</strong>
13
+ </p>
14
+ </ConfirmAction>
15
+ );
25
16
 
26
17
  DeleteAction.propTypes = {
27
18
  onClose: PropTypes.func.isRequired,
28
19
  deleteAction: PropTypes.func.isRequired,
29
- itemName: PropTypes.string
20
+ itemName: PropTypes.string,
21
+ confirmPhrase: PropTypes.string
30
22
  };
31
23
 
32
24
  DeleteAction.defaultProps = {
33
- itemName: ''
25
+ itemName: '',
26
+ confirmPhrase: null
34
27
  };
35
28
 
36
29
  export default DeleteAction;
package/src/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';
@@ -12,6 +13,7 @@ export {
12
13
  getBlazeAdmin,
13
14
  PageHeader,
14
15
  DeleteAction,
16
+ ConfirmAction,
15
17
  CardPrompt,
16
18
  CopyDataFromAction,
17
19
  MetaTitle,