@blaze-cms/admin 0.146.0-alpha-q1-2026.4 → 0.146.0-alpha-eagle-4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/blaze.config.js +36 -0
- package/lib/blaze.config.js.map +1 -0
- package/lib/components/CardPrompt/CardPrompt.js +18 -20
- package/lib/components/CardPrompt/CardPrompt.js.map +1 -1
- package/lib/components/CardPrompt/index.js +2 -3
- package/lib/components/CardPrompt/index.js.map +1 -1
- package/lib/components/ConfirmAction/ConfirmAction.js +76 -0
- package/lib/components/ConfirmAction/ConfirmAction.js.map +1 -0
- package/lib/components/ConfirmAction/index.js +10 -0
- package/lib/components/ConfirmAction/index.js.map +1 -0
- package/lib/components/CopyDataFromAction/CopyDataFromAction.js +80 -144
- package/lib/components/CopyDataFromAction/CopyDataFromAction.js.map +1 -1
- package/lib/components/CopyDataFromAction/helpers.js +20 -12
- package/lib/components/CopyDataFromAction/helpers.js.map +1 -1
- package/lib/components/CopyDataFromAction/index.js +2 -3
- package/lib/components/CopyDataFromAction/index.js.map +1 -1
- package/lib/components/DeleteAction/DeleteAction.js +20 -26
- package/lib/components/DeleteAction/DeleteAction.js.map +1 -1
- package/lib/components/DeleteAction/index.js +2 -3
- package/lib/components/DeleteAction/index.js.map +1 -1
- package/lib/components/LeaveAction/LeaveAction.js +11 -14
- package/lib/components/LeaveAction/LeaveAction.js.map +1 -1
- package/lib/components/LeaveAction/index.js +2 -3
- package/lib/components/LeaveAction/index.js.map +1 -1
- package/lib/components/Loading/Loading.js +16 -17
- package/lib/components/Loading/Loading.js.map +1 -1
- package/lib/components/Loading/constants.js +5 -6
- package/lib/components/Loading/constants.js.map +1 -1
- package/lib/components/Loading/index.js +2 -3
- package/lib/components/Loading/index.js.map +1 -1
- package/lib/components/MetaTitle/MetaTitle.js +18 -17
- package/lib/components/MetaTitle/MetaTitle.js.map +1 -1
- package/lib/components/MetaTitle/index.js +2 -3
- package/lib/components/MetaTitle/index.js.map +1 -1
- package/lib/components/PageHeader/HeaderIconButton.js +39 -0
- package/lib/components/PageHeader/HeaderIconButton.js.map +1 -0
- package/lib/components/PageHeader/PageHeader.js +87 -37
- package/lib/components/PageHeader/PageHeader.js.map +1 -1
- package/lib/components/PageHeader/TitleEditor.js +87 -0
- package/lib/components/PageHeader/TitleEditor.js.map +1 -0
- package/lib/components/PageHeader/index.js +2 -3
- package/lib/components/PageHeader/index.js.map +1 -1
- package/lib/components/RevertToTemplate/RevertToTemplate.js +14 -14
- package/lib/components/RevertToTemplate/RevertToTemplate.js.map +1 -1
- package/lib/components/RevertToTemplate/index.js +2 -3
- package/lib/components/RevertToTemplate/index.js.map +1 -1
- package/lib/index.js +24 -18
- package/lib/index.js.map +1 -1
- package/lib/utils/build-interface.js +39 -67
- package/lib/utils/build-interface.js.map +1 -1
- package/lib/utils/get-blaze-admin.js +8 -11
- package/lib/utils/get-blaze-admin.js.map +1 -1
- package/lib-es/blaze.config.js +29 -0
- package/lib-es/blaze.config.js.map +1 -0
- package/lib-es/components/ConfirmAction/ConfirmAction.js +68 -0
- package/lib-es/components/ConfirmAction/ConfirmAction.js.map +1 -0
- package/lib-es/components/ConfirmAction/index.js +3 -0
- package/lib-es/components/ConfirmAction/index.js.map +1 -0
- package/lib-es/components/DeleteAction/DeleteAction.js +13 -19
- package/lib-es/components/DeleteAction/DeleteAction.js.map +1 -1
- package/lib-es/components/PageHeader/HeaderIconButton.js +32 -0
- package/lib-es/components/PageHeader/HeaderIconButton.js.map +1 -0
- package/lib-es/components/PageHeader/PageHeader.js +80 -24
- package/lib-es/components/PageHeader/PageHeader.js.map +1 -1
- package/lib-es/components/PageHeader/TitleEditor.js +79 -0
- package/lib-es/components/PageHeader/TitleEditor.js.map +1 -0
- package/lib-es/index.js +2 -1
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/build-interface.js +3 -3
- package/lib-es/utils/build-interface.js.map +1 -1
- package/lib-es/utils/get-blaze-admin.js +1 -1
- package/lib-es/utils/get-blaze-admin.js.map +1 -1
- package/package.json +25 -21
- package/{blaze.config.js → src/blaze.config.js} +2 -1
- package/src/components/ConfirmAction/ConfirmAction.js +72 -0
- package/src/components/ConfirmAction/index.js +3 -0
- package/src/components/DeleteAction/DeleteAction.js +16 -23
- package/src/components/PageHeader/HeaderIconButton.js +27 -0
- package/src/components/PageHeader/PageHeader.js +90 -19
- package/src/components/PageHeader/TitleEditor.js +87 -0
- package/src/index.js +2 -0
- package/src/utils/build-interface.js +3 -3
- package/src/utils/get-blaze-admin.js +1 -1
- package/CHANGELOG.md +0 -1957
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
|
@@ -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":"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","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
|
package/lib-es/index.js.map
CHANGED
|
@@ -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,
|
|
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":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Suspense } from 'react';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { ApolloProvider } from '@apollo/client';
|
|
4
4
|
import { Router, Switch, Route, Redirect, BrowserRouter } from 'react-router-dom';
|
|
@@ -24,8 +24,8 @@ export default async function buildInterface(app) {
|
|
|
24
24
|
history: browserHistory
|
|
25
25
|
}, /*#__PURE__*/React.createElement(BrowserRouter, {
|
|
26
26
|
getUserConfirmation: (message, callback) => LeaveAction(message, callback)
|
|
27
|
-
}, /*#__PURE__*/React.createElement(ToastProvider, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(
|
|
28
|
-
fallback:
|
|
27
|
+
}, /*#__PURE__*/React.createElement(ToastProvider, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Suspense, {
|
|
28
|
+
fallback: /*#__PURE__*/React.createElement("div", null, "Loading...")
|
|
29
29
|
}, /*#__PURE__*/React.createElement(Switch, null, routes.map(({
|
|
30
30
|
component,
|
|
31
31
|
path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-interface.js","names":["React","createRoot","ApolloProvider","Router","Switch","Route","Redirect","BrowserRouter","createBrowserHistory","ToastProvider","ErrorBoundary","setupCheckAccessToken","LeaveAction","buildInterface","app","init","Layout","getLayout","routes","getRoutes","client","createClient","browserHistory","container","document","getElementById","root","render","createElement","history","getUserConfirmation","message","callback","
|
|
1
|
+
{"version":3,"file":"build-interface.js","names":["React","Suspense","createRoot","ApolloProvider","Router","Switch","Route","Redirect","BrowserRouter","createBrowserHistory","ToastProvider","ErrorBoundary","setupCheckAccessToken","LeaveAction","buildInterface","app","init","Layout","getLayout","routes","getRoutes","client","createClient","browserHistory","container","document","getElementById","root","render","createElement","history","getUserConfirmation","message","callback","fallback","map","component","path","exact","key","redirect","to","from"],"sources":["../../src/utils/build-interface.js"],"sourcesContent":["import React, { Suspense } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ApolloProvider } from '@apollo/client';\nimport { Router, Switch, Route, Redirect, BrowserRouter } from 'react-router-dom';\nimport { createBrowserHistory } from 'history';\nimport { ToastProvider } from '@blaze-react/toaster';\nimport ErrorBoundary from '@blaze-cms/core-errors-ui';\nimport { setupCheckAccessToken } from '@blaze-cms/core-auth-ui';\nimport LeaveAction from '../components/LeaveAction';\n\nexport default async function buildInterface(app) {\n await app.init();\n\n const Layout = app.getLayout();\n const routes = app.getRoutes();\n const client = app.createClient();\n const browserHistory = createBrowserHistory();\n\n await setupCheckAccessToken(client);\n const container = document.getElementById('root');\n const root = createRoot(container);\n\n root.render(\n <ErrorBoundary app={app}>\n <ApolloProvider client={client}>\n <Router history={browserHistory}>\n <BrowserRouter\n getUserConfirmation={(message, callback) => LeaveAction(message, callback)}>\n <ToastProvider>\n <Layout>\n <Suspense fallback={<div>Loading...</div>}>\n <Switch>\n {routes.map(({ component, path, exact, key, redirect }) =>\n redirect ? (\n <Redirect to={redirect} from={path} exact={exact} key={key} />\n ) : (\n <Route component={component} path={path} exact={exact} key={key} />\n )\n )}\n </Switch>\n </Suspense>\n </Layout>\n </ToastProvider>\n </BrowserRouter>\n </Router>\n </ApolloProvider>\n </ErrorBoundary>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,kBAAkB;AACjF,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,SAASC,aAAa,QAAQ,sBAAsB;AACpD,OAAOC,aAAa,MAAM,2BAA2B;AACrD,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,OAAOC,WAAW,MAAM,2BAA2B;AAEnD,eAAe,eAAeC,cAAcA,CAACC,GAAG,EAAE;EAChD,MAAMA,GAAG,CAACC,IAAI,CAAC,CAAC;EAEhB,MAAMC,MAAM,GAAGF,GAAG,CAACG,SAAS,CAAC,CAAC;EAC9B,MAAMC,MAAM,GAAGJ,GAAG,CAACK,SAAS,CAAC,CAAC;EAC9B,MAAMC,MAAM,GAAGN,GAAG,CAACO,YAAY,CAAC,CAAC;EACjC,MAAMC,cAAc,GAAGd,oBAAoB,CAAC,CAAC;EAE7C,MAAMG,qBAAqB,CAACS,MAAM,CAAC;EACnC,MAAMG,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,MAAM,CAAC;EACjD,MAAMC,IAAI,GAAGzB,UAAU,CAACsB,SAAS,CAAC;EAElCG,IAAI,CAACC,MAAM,cACT5B,KAAA,CAAA6B,aAAA,CAAClB,aAAa;IAACI,GAAG,EAAEA;EAAI,gBACtBf,KAAA,CAAA6B,aAAA,CAAC1B,cAAc;IAACkB,MAAM,EAAEA;EAAO,gBAC7BrB,KAAA,CAAA6B,aAAA,CAACzB,MAAM;IAAC0B,OAAO,EAAEP;EAAe,gBAC9BvB,KAAA,CAAA6B,aAAA,CAACrB,aAAa;IACZuB,mBAAmB,EAAEA,CAACC,OAAO,EAAEC,QAAQ,KAAKpB,WAAW,CAACmB,OAAO,EAAEC,QAAQ;EAAE,gBAC3EjC,KAAA,CAAA6B,aAAA,CAACnB,aAAa,qBACZV,KAAA,CAAA6B,aAAA,CAACZ,MAAM,qBACLjB,KAAA,CAAA6B,aAAA,CAAC5B,QAAQ;IAACiC,QAAQ,eAAElC,KAAA,CAAA6B,aAAA,cAAK,YAAe;EAAE,gBACxC7B,KAAA,CAAA6B,aAAA,CAACxB,MAAM,QACJc,MAAM,CAACgB,GAAG,CAAC,CAAC;IAAEC,SAAS;IAAEC,IAAI;IAAEC,KAAK;IAAEC,GAAG;IAAEC;EAAS,CAAC,KACpDA,QAAQ,gBACNxC,KAAA,CAAA6B,aAAA,CAACtB,QAAQ;IAACkC,EAAE,EAAED,QAAS;IAACE,IAAI,EAAEL,IAAK;IAACC,KAAK,EAAEA,KAAM;IAACC,GAAG,EAAEA;EAAI,CAAE,CAAC,gBAE9DvC,KAAA,CAAA6B,aAAA,CAACvB,KAAK;IAAC8B,SAAS,EAAEA,SAAU;IAACC,IAAI,EAAEA,IAAK;IAACC,KAAK,EAAEA,KAAM;IAACC,GAAG,EAAEA;EAAI,CAAE,CAEtE,CACM,CACA,CACJ,CACK,CACF,CACT,CACM,CACH,CACjB,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-blaze-admin.js","names":["getBlazeUi","blazeConfig","buildInterface","getBlazeAdmin","buildConfig","config","app","render"],"sources":["../../src/utils/get-blaze-admin.js"],"sourcesContent":["import getBlazeUi from '@blaze-cms/core-ui';\nimport blazeConfig from '
|
|
1
|
+
{"version":3,"file":"get-blaze-admin.js","names":["getBlazeUi","blazeConfig","buildInterface","getBlazeAdmin","buildConfig","config","app","render"],"sources":["../../src/utils/get-blaze-admin.js"],"sourcesContent":["import getBlazeUi from '@blaze-cms/core-ui';\nimport blazeConfig from '../blaze.config';\nimport buildInterface from './build-interface';\n\nexport function getBlazeAdmin({ buildConfig } = {}) {\n const config = buildConfig ? buildConfig(blazeConfig) : blazeConfig;\n const app = getBlazeUi({ config });\n app.render = () => buildInterface(app);\n return app;\n}\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,oBAAoB;AAC3C,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,cAAc,MAAM,mBAAmB;AAE9C,OAAO,SAASC,aAAaA,CAAC;EAAEC;AAAY,CAAC,GAAG,CAAC,CAAC,EAAE;EAClD,MAAMC,MAAM,GAAGD,WAAW,GAAGA,WAAW,CAACH,WAAW,CAAC,GAAGA,WAAW;EACnE,MAAMK,GAAG,GAAGN,UAAU,CAAC;IAAEK;EAAO,CAAC,CAAC;EAClCC,GAAG,CAACC,MAAM,GAAG,MAAML,cAAc,CAACI,GAAG,CAAC;EACtC,OAAOA,GAAG;AACZ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/admin",
|
|
3
|
-
"version": "0.146.0-alpha-
|
|
3
|
+
"version": "0.146.0-alpha-eagle-4.0",
|
|
4
4
|
"description": "Blaze example project",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
7
|
-
"
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"lib-es",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"source": "src/index.js",
|
|
8
13
|
"directories": {
|
|
9
14
|
"src": "src/"
|
|
10
15
|
},
|
|
@@ -28,39 +33,38 @@
|
|
|
28
33
|
"license": "GPL-3.0",
|
|
29
34
|
"dependencies": {
|
|
30
35
|
"@apollo/client": "3.13.8",
|
|
31
|
-
"@blaze-cms/admin-ui-utils": "0.146.0-alpha-
|
|
32
|
-
"@blaze-cms/core-errors-ui": "0.146.0-alpha-
|
|
33
|
-
"@blaze-cms/core-ui": "0.146.0-alpha-
|
|
34
|
-
"@blaze-cms/plugin-admin-core-ui": "0.146.0-alpha-
|
|
35
|
-
"@blaze-cms/plugin-auth-local-ui": "0.146.0-alpha-
|
|
36
|
-
"@blaze-cms/plugin-auth-ui": "0.146.0-alpha-
|
|
37
|
-
"@blaze-cms/plugin-data-ui": "0.146.0-alpha-
|
|
38
|
-
"@blaze-cms/plugin-google-maps-ui": "0.146.0-alpha-
|
|
39
|
-
"@blaze-cms/plugin-gtm-ui": "0.146.0-alpha-
|
|
40
|
-
"@blaze-cms/plugin-media-ui": "0.146.0-alpha-
|
|
41
|
-
"@blaze-cms/plugin-page-builder-ui": "0.146.0-alpha-
|
|
42
|
-
"@blaze-cms/
|
|
43
|
-
"@blaze-cms/
|
|
36
|
+
"@blaze-cms/admin-ui-utils": "0.146.0-alpha-eagle-4.0",
|
|
37
|
+
"@blaze-cms/core-errors-ui": "0.146.0-alpha-eagle-4.0",
|
|
38
|
+
"@blaze-cms/core-ui": "0.146.0-alpha-eagle-4.0",
|
|
39
|
+
"@blaze-cms/plugin-admin-core-ui": "0.146.0-alpha-eagle-4.0",
|
|
40
|
+
"@blaze-cms/plugin-auth-local-ui": "0.146.0-alpha-eagle-4.0",
|
|
41
|
+
"@blaze-cms/plugin-auth-ui": "0.146.0-alpha-eagle-4.0",
|
|
42
|
+
"@blaze-cms/plugin-data-ui": "0.146.0-alpha-eagle-4.0",
|
|
43
|
+
"@blaze-cms/plugin-google-maps-ui": "0.146.0-alpha-eagle-4.0",
|
|
44
|
+
"@blaze-cms/plugin-gtm-ui": "0.146.0-alpha-eagle-4.0",
|
|
45
|
+
"@blaze-cms/plugin-media-ui": "0.146.0-alpha-eagle-4.0",
|
|
46
|
+
"@blaze-cms/plugin-page-builder-ui": "0.146.0-alpha-eagle-4.0",
|
|
47
|
+
"@blaze-cms/plugin-workflow-ui": "0.146.0-alpha-eagle-4.0",
|
|
48
|
+
"@blaze-cms/react-form-builder": "0.146.0-alpha-eagle-4.0",
|
|
49
|
+
"@blaze-cms/setup-ui": "0.146.0-alpha-eagle-4.0",
|
|
44
50
|
"@blaze-react/alert": "^0.7.0",
|
|
45
51
|
"@blaze-react/modal": "^0.7.0",
|
|
46
52
|
"@blaze-react/toaster": "^0.7.0",
|
|
47
|
-
"core-js": "^3.2.1",
|
|
48
53
|
"graphql": "^15.2.0",
|
|
49
54
|
"history": "^5.0.0",
|
|
50
55
|
"lodash.capitalize": "^4.2.1",
|
|
51
56
|
"react-helmet": "^6.1.0",
|
|
52
57
|
"react-router-config": "^5.1.1",
|
|
53
|
-
"react-router-dom": "^5.0.1"
|
|
54
|
-
"regenerator-runtime": "^0.13.3"
|
|
58
|
+
"react-router-dom": "^5.0.1"
|
|
55
59
|
},
|
|
56
60
|
"peerDependencies": {
|
|
57
61
|
"prop-types": "^15.7.2",
|
|
58
|
-
"react": "
|
|
59
|
-
"react-dom": "
|
|
62
|
+
"react": ">= 18",
|
|
63
|
+
"react-dom": ">= 18"
|
|
60
64
|
},
|
|
61
65
|
"eslintIgnore": [
|
|
62
66
|
"lib/*",
|
|
63
67
|
"lib-es/*"
|
|
64
68
|
],
|
|
65
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "6f526b038039cba9b25f6bdb97773da1bf9e3f33"
|
|
66
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,7 +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
|
-
|
|
24
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;
|
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
3
|
+
import ConfirmAction from '../ConfirmAction';
|
|
4
4
|
|
|
5
|
-
const DeleteAction = ({ onClose, deleteAction, itemName }) =>
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
const HeaderIconButton = ({ icon, label, className, ...rest }) => (
|
|
5
|
+
<button
|
|
6
|
+
type="button"
|
|
7
|
+
className={`page-header__icon-button${className ? ` ${className}` : ''}`}
|
|
8
|
+
title={label}
|
|
9
|
+
aria-label={label}
|
|
10
|
+
{...rest}>
|
|
11
|
+
<span className="material-icons" aria-hidden="true">
|
|
12
|
+
{icon}
|
|
13
|
+
</span>
|
|
14
|
+
</button>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
HeaderIconButton.propTypes = {
|
|
18
|
+
icon: PropTypes.string.isRequired,
|
|
19
|
+
label: PropTypes.string.isRequired,
|
|
20
|
+
className: PropTypes.string
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
HeaderIconButton.defaultProps = {
|
|
24
|
+
className: ''
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default HeaderIconButton;
|
|
@@ -1,44 +1,114 @@
|
|
|
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
|
|
|
5
|
-
const PageHeader = ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const PageHeader = ({
|
|
8
|
+
title,
|
|
9
|
+
subtitle,
|
|
10
|
+
children,
|
|
11
|
+
pageName,
|
|
12
|
+
onViewUrl,
|
|
13
|
+
viewUrlDisabledReason,
|
|
14
|
+
onTitleChange,
|
|
15
|
+
titleActions
|
|
16
|
+
}) => {
|
|
17
|
+
const [isEditingTitle, setIsEditingTitle] = useState(false);
|
|
18
|
+
const isTitleEditable = typeof onTitleChange === 'function';
|
|
19
|
+
// A reason renders the button disabled instead of dropping it.
|
|
20
|
+
const showViewButton = !!onViewUrl || !!viewUrlDisabledReason;
|
|
21
|
+
const hasTitleActions = isTitleEditable || !!titleActions || showViewButton;
|
|
22
|
+
|
|
23
|
+
const startEditing = () => setIsEditingTitle(true);
|
|
24
|
+
const stopEditing = () => setIsEditingTitle(false);
|
|
25
|
+
const saveTitle = nextTitle => {
|
|
26
|
+
stopEditing();
|
|
27
|
+
onTitleChange(nextTitle);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const renderTitle = () => {
|
|
31
|
+
if (isEditingTitle) {
|
|
32
|
+
return <TitleEditor title={title} onSave={saveTitle} onCancel={stopEditing} />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
{isTitleEditable ? (
|
|
11
38
|
<div
|
|
12
|
-
className="page-header__heading page-header__heading--
|
|
13
|
-
onClick={
|
|
14
|
-
|
|
39
|
+
className="page-header__heading page-header__heading--editable"
|
|
40
|
+
onClick={startEditing}
|
|
41
|
+
title="Edit title"
|
|
42
|
+
role="button"
|
|
43
|
+
tabIndex={0}
|
|
44
|
+
onKeyDown={({ key }) => key === 'Enter' && startEditing()}>
|
|
15
45
|
{title}
|
|
16
46
|
</div>
|
|
17
47
|
) : (
|
|
18
48
|
<div className="page-header__heading">{title}</div>
|
|
19
49
|
)}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
50
|
+
{hasTitleActions && (
|
|
51
|
+
<div className="page-header__title-actions">
|
|
52
|
+
{isTitleEditable && (
|
|
53
|
+
<HeaderIconButton
|
|
54
|
+
icon="edit"
|
|
55
|
+
label="Edit title"
|
|
56
|
+
onClick={startEditing}
|
|
57
|
+
data-testid="page-header-title-edit"
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
{titleActions}
|
|
61
|
+
{showViewButton && (
|
|
62
|
+
<HeaderIconButton
|
|
63
|
+
icon="open_in_new"
|
|
64
|
+
label={viewUrlDisabledReason || 'View'}
|
|
65
|
+
className={viewUrlDisabledReason ? 'page-header__icon-button--disabled' : ''}
|
|
66
|
+
aria-disabled={viewUrlDisabledReason ? 'true' : undefined}
|
|
67
|
+
onClick={viewUrlDisabledReason ? undefined : onViewUrl}
|
|
68
|
+
data-testid="page-header-view"
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
<MetaTitle title={title} pageName={pageName} />
|
|
80
|
+
<div className="page-header--wrapper">
|
|
81
|
+
<div className="page-header page-header--sticky">
|
|
82
|
+
<div className="page-header__title">{renderTitle()}</div>
|
|
83
|
+
<div className="page-header__button">{children}</div>
|
|
84
|
+
</div>
|
|
85
|
+
<div className="page-header page-header--base">
|
|
86
|
+
<div className="page-header__subheading">{subtitle}</div>
|
|
87
|
+
</div>
|
|
24
88
|
</div>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
28
92
|
|
|
29
93
|
PageHeader.propTypes = {
|
|
30
94
|
title: PropTypes.string.isRequired,
|
|
31
95
|
subtitle: PropTypes.string,
|
|
32
96
|
children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),
|
|
33
97
|
pageName: PropTypes.string,
|
|
34
|
-
onViewUrl: PropTypes.func
|
|
98
|
+
onViewUrl: PropTypes.func,
|
|
99
|
+
viewUrlDisabledReason: PropTypes.string,
|
|
100
|
+
onTitleChange: PropTypes.func,
|
|
101
|
+
titleActions: PropTypes.node
|
|
35
102
|
};
|
|
36
103
|
|
|
37
104
|
PageHeader.defaultProps = {
|
|
38
105
|
subtitle: '',
|
|
39
106
|
children: '',
|
|
40
107
|
pageName: '',
|
|
41
|
-
onViewUrl: null
|
|
108
|
+
onViewUrl: null,
|
|
109
|
+
viewUrlDisabledReason: null,
|
|
110
|
+
onTitleChange: null,
|
|
111
|
+
titleActions: null
|
|
42
112
|
};
|
|
43
113
|
|
|
44
114
|
const PageHeaderActions = ({ children }) => (
|
|
@@ -50,5 +120,6 @@ PageHeaderActions.propTypes = {
|
|
|
50
120
|
};
|
|
51
121
|
|
|
52
122
|
PageHeader.Actions = PageHeaderActions;
|
|
123
|
+
PageHeader.IconButton = HeaderIconButton;
|
|
53
124
|
|
|
54
125
|
export default PageHeader;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import HeaderIconButton from './HeaderIconButton';
|
|
4
|
+
|
|
5
|
+
const TitleEditor = ({ title, onSave, onCancel }) => {
|
|
6
|
+
const [value, setValue] = useState(title);
|
|
7
|
+
const inputRef = useRef(null);
|
|
8
|
+
// Blur and the tick/cross clicks can both fire for one edit; only the first wins.
|
|
9
|
+
const isDone = useRef(false);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (inputRef.current) {
|
|
13
|
+
inputRef.current.focus();
|
|
14
|
+
inputRef.current.select();
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
const finish = callback => {
|
|
19
|
+
if (isDone.current) return;
|
|
20
|
+
isDone.current = true;
|
|
21
|
+
callback();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const save = () =>
|
|
25
|
+
finish(() => {
|
|
26
|
+
const nextTitle = value.trim();
|
|
27
|
+
if (!nextTitle || nextTitle === title) {
|
|
28
|
+
onCancel();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
onSave(nextTitle);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const cancel = () => finish(onCancel);
|
|
35
|
+
|
|
36
|
+
const onKeyDown = event => {
|
|
37
|
+
if (event.key === 'Enter') {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
save();
|
|
40
|
+
} else if (event.key === 'Escape') {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
cancel();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const keepInputFocus = event => event.preventDefault();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className="page-header__title-editor">
|
|
50
|
+
<input
|
|
51
|
+
ref={inputRef}
|
|
52
|
+
type="text"
|
|
53
|
+
className="page-header__title-input"
|
|
54
|
+
value={value}
|
|
55
|
+
onChange={({ target }) => setValue(target.value)}
|
|
56
|
+
onKeyDown={onKeyDown}
|
|
57
|
+
onBlur={save}
|
|
58
|
+
aria-label="Title"
|
|
59
|
+
data-testid="page-header-title-input"
|
|
60
|
+
/>
|
|
61
|
+
<div className="page-header__title-editor-actions">
|
|
62
|
+
<HeaderIconButton
|
|
63
|
+
icon="check"
|
|
64
|
+
label="Save title"
|
|
65
|
+
onMouseDown={keepInputFocus}
|
|
66
|
+
onClick={save}
|
|
67
|
+
data-testid="page-header-title-save"
|
|
68
|
+
/>
|
|
69
|
+
<HeaderIconButton
|
|
70
|
+
icon="close"
|
|
71
|
+
label="Cancel"
|
|
72
|
+
onMouseDown={keepInputFocus}
|
|
73
|
+
onClick={cancel}
|
|
74
|
+
data-testid="page-header-title-cancel"
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
TitleEditor.propTypes = {
|
|
82
|
+
title: PropTypes.string.isRequired,
|
|
83
|
+
onSave: PropTypes.func.isRequired,
|
|
84
|
+
onCancel: PropTypes.func.isRequired
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default TitleEditor;
|