26 lines
803 B
TypeScript
26 lines
803 B
TypeScript
import { defineComponent, watch } from "vue";
|
|
import { injectDateFieldRootContext } from "reka-ui";
|
|
|
|
/** Reka does not watch equal primitive null values after a rejected edit.
|
|
* Clear its existing segment refs without replacing DOM, focus or IDs. */
|
|
export default defineComponent({
|
|
name: "EmptyDateBridge",
|
|
props: { revision: { type: Number, required: true } },
|
|
setup(props) {
|
|
const base = injectDateFieldRootContext();
|
|
watch(
|
|
() => props.revision,
|
|
() => {
|
|
base.segmentValues.value = Object.fromEntries(
|
|
Object.keys(base.segmentValues.value).map((part) => [
|
|
part,
|
|
part === "dayPeriod" ? "AM" : null,
|
|
]),
|
|
) as typeof base.segmentValues.value;
|
|
},
|
|
{ flush: "post" },
|
|
);
|
|
return () => null;
|
|
},
|
|
});
|