add dayjs

This commit is contained in:
Bowen Tan 2021-10-27 18:14:53 +08:00
parent 21ef34082b
commit ae90ca1675
3 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import React from 'react';
import { flatten } from 'lodash-es';
import { FormControl, FormLabel, Input, VStack } from '@chakra-ui/react';
import { FormControl, FormLabel, Input, Textarea, VStack } from '@chakra-ui/react';
import { EmotionJSX } from '@emotion/react/types/jsx-namespace';
import { TSchema } from '@sinclair/typebox';
import { Application } from '@meta-ui/core';
@ -27,7 +27,7 @@ export const renderField = (properties: {
}) => {
const { value, type, fullKey, selectedId } = properties;
if (typeof value !== 'object') {
const ref = React.createRef<HTMLInputElement>();
const ref = React.createRef<HTMLTextAreaElement>();
const onBlur = () => {
const operation = type
? new ModifyTraitPropertyOperation(selectedId, type, fullKey, ref.current?.value)
@ -37,7 +37,7 @@ export const renderField = (properties: {
return (
<FormControl key={`${selectedId}-${fullKey}`}>
<FormLabel>{fullKey}</FormLabel>
<Input ref={ref} onBlur={onBlur} defaultValue={value as string} />
<Textarea ref={ref} onBlur={onBlur} defaultValue={value as string} />
</FormControl>
);
} else {

View File

@ -96,7 +96,7 @@ export const Editor = () => {
<Tab>UI Tree</Tab>
<Tab>State</Tab>
</TabList>
<TabPanels flex="1">
<TabPanels flex="1" overflow="auto">
<TabPanel p={0}>
<StructureTree
app={app}

View File

@ -1,11 +1,17 @@
import { toNumber, mapValues, isArray, isPlainObject, set } from 'lodash-es';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import isLeapYear from 'dayjs/plugin/isLeapYear';
import relativeTime from 'dayjs/plugin/relativeTime';
import LocalizedFormat from 'dayjs/plugin/LocalizedFormat';
import { reactive } from '@vue/reactivity';
import { watch } from '../utils/watchReactivity';
import { LIST_ITEM_EXP, LIST_ITEM_INDEX_EXP } from '../constants';
dayjs.extend(relativeTime);
dayjs.extend(isLeapYear);
dayjs.extend(LocalizedFormat);
dayjs.locale('zh-cn');
type ExpChunk = {
expression: string;