added event-editor-submit through ctrl+enter in description
This commit is contained in:
10
client/package-lock.json
generated
10
client/package-lock.json
generated
@@ -11,6 +11,7 @@
|
|||||||
"@carbon/icons-react": "^11.53.0",
|
"@carbon/icons-react": "^11.53.0",
|
||||||
"@heroui/react": "^2.6.14",
|
"@heroui/react": "^2.6.14",
|
||||||
"@internationalized/date": "3.6.0",
|
"@internationalized/date": "3.6.0",
|
||||||
|
"@mantine/hooks": "^7.16.2",
|
||||||
"@react-aria/i18n": "^3.12.4",
|
"@react-aria/i18n": "^3.12.4",
|
||||||
"@react-stately/data": "^3.12.0",
|
"@react-stately/data": "^3.12.0",
|
||||||
"framer-motion": "^12.0.0",
|
"framer-motion": "^12.0.0",
|
||||||
@@ -2494,6 +2495,15 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@mantine/hooks": {
|
||||||
|
"version": "7.16.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-7.16.2.tgz",
|
||||||
|
"integrity": "sha512-ZFHQhDi9T+r6VR5NEeE47gigPPIAHVIKDOCWsCsbCqHc3yz5l8kiO2RdfUmsTKV2KD/AiXnAw4b6pjQEP58GOg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^18.x || ^19.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@next/env": {
|
"node_modules/@next/env": {
|
||||||
"version": "15.1.5",
|
"version": "15.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-15.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@next/env/-/env-15.1.5.tgz",
|
||||||
|
|||||||
@@ -9,9 +9,10 @@
|
|||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@internationalized/date": "3.6.0",
|
|
||||||
"@carbon/icons-react": "^11.53.0",
|
"@carbon/icons-react": "^11.53.0",
|
||||||
"@heroui/react": "^2.6.14",
|
"@heroui/react": "^2.6.14",
|
||||||
|
"@internationalized/date": "3.6.0",
|
||||||
|
"@mantine/hooks": "^7.16.2",
|
||||||
"@react-aria/i18n": "^3.12.4",
|
"@react-aria/i18n": "^3.12.4",
|
||||||
"@react-stately/data": "^3.12.0",
|
"@react-stately/data": "^3.12.0",
|
||||||
"framer-motion": "^12.0.0",
|
"framer-motion": "^12.0.0",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useRef, useState } from "react";
|
||||||
import {
|
import {
|
||||||
getLocalTimeZone,
|
getLocalTimeZone,
|
||||||
now,
|
now,
|
||||||
@@ -21,6 +21,7 @@ import { EventData } from "@/Zustand";
|
|||||||
import { useAsyncList } from "@react-stately/data";
|
import { useAsyncList } from "@react-stately/data";
|
||||||
import { getTasks } from "@/lib";
|
import { getTasks } from "@/lib";
|
||||||
import Loading from "../Loading";
|
import Loading from "../Loading";
|
||||||
|
import { getHotkeyHandler } from "@mantine/hooks";
|
||||||
|
|
||||||
export interface EventSubmitData {
|
export interface EventSubmitData {
|
||||||
eventID: number;
|
eventID: number;
|
||||||
@@ -49,6 +50,7 @@ export default function EventEditor(props: {
|
|||||||
const [eventTasks, setEventTasks] = useState<string[]>(
|
const [eventTasks, setEventTasks] = useState<string[]>(
|
||||||
props.value?.tasks.map((k) => k.taskID.toString()) ?? [],
|
props.value?.tasks.map((k) => k.taskID.toString()) ?? [],
|
||||||
);
|
);
|
||||||
|
const submitButtonRef = useRef<HTMLButtonElement>(null);
|
||||||
|
|
||||||
const tasks = useAsyncList({
|
const tasks = useAsyncList({
|
||||||
async load() {
|
async load() {
|
||||||
@@ -108,6 +110,9 @@ export default function EventEditor(props: {
|
|||||||
name="description"
|
name="description"
|
||||||
value={description}
|
value={description}
|
||||||
onValueChange={setDescription}
|
onValueChange={setDescription}
|
||||||
|
onKeyDown={getHotkeyHandler([
|
||||||
|
["ctrl+Enter", () => submitButtonRef.current?.click()],
|
||||||
|
])}
|
||||||
/>
|
/>
|
||||||
<CheckboxGroup
|
<CheckboxGroup
|
||||||
name="tasks"
|
name="tasks"
|
||||||
@@ -132,7 +137,10 @@ export default function EventEditor(props: {
|
|||||||
)}
|
)}
|
||||||
</CheckboxGroup>
|
</CheckboxGroup>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>{props.footer}</ModalFooter>
|
<ModalFooter>
|
||||||
|
<button ref={submitButtonRef} type="submit" className="hidden" />
|
||||||
|
{props.footer}
|
||||||
|
</ModalFooter>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
Reference in New Issue
Block a user