Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat no hook calendar #1200

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
import dayjs from 'dayjs';
import equal from 'fast-deep-equal';
import Converter from './js-calendar-converter';
import { mountComponent } from '../../../../../src/_util/component';
const CollapseContainer = (props) => {
var _a, _b, _c;
const time = dayjs((_a = props.cell) === null || _a === void 0 ? void 0 : _a.time);
const vs = Converter.solar2lunar(time.get('year'), time.get('month') + 1, time.get('date'));
if (vs === -1) {
return {
cnday: '',
};
}
return {
cnday: vs.lunarFestival || vs.festival || vs.IDayCn,
festival: !!vs.festival || !!vs.lunarFestival,
unset: ((_b = props.cell) === null || _b === void 0 ? void 0 : _b.isSelectedBegin) || ((_c = props.cell) === null || _c === void 0 ? void 0 : _c.isSelectedEnd),
};
};
mountComponent(CollapseContainer, {
import { Component, getValueFromProps } from '../../../../../src/_util/simply';
Component({
cell: null,
}, {
updateData() {
const cell = getValueFromProps(this, 'cell');
const time = dayjs(cell === null || cell === void 0 ? void 0 : cell.time);
const vs = Converter.solar2lunar(time.get('year'), time.get('month') + 1, time.get('date'));
if (vs === -1) {
this.setData({
cnday: '',
});
return;
}
this.setData({
cnday: vs.lunarFestival || vs.festival || vs.IDayCn,
festival: !!vs.festival || !!vs.lunarFestival,
unset: (cell === null || cell === void 0 ? void 0 : cell.isSelectedBegin) || (cell === null || cell === void 0 ? void 0 : cell.isSelectedEnd),
});
},
}, {
cnday: '',
festival: '',
unset: '',
}, null, {
onInit() {
this.updateData();
},
didUpdate(prevProps) {
const cell = getValueFromProps(this, 'cell');
if (!equal(prevProps.cell, cell)) {
this.updateData();
}
},
});
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import { useEvent, useState } from 'functional-mini/component';
import { mountComponent } from '../../../../src/_util/component';
const CollapseContainer = (props) => {
var _a;
const [collapse, setCollapse] = useState((_a = props.defaultCollapse) !== null && _a !== void 0 ? _a : true);
useEvent('handleToggle', () => {
setCollapse((v) => !v);
});
return {
collapse,
internalHide: props.hide,
containerTitle: props.title,
};
};
mountComponent(CollapseContainer, {
import { Component, getValueFromProps } from '../../../../src/_util/simply';
Component({
hide: false,
defaultCollapse: null,
title: '',
}, {
handleToggle() {
const { collapse } = this.data;
this.setData({
collapse: !collapse,
});
},
}, {
collapse: true,
internalHide: false,
containerTitle: '',
}, null, {
onInit() {
const [defaultCollapse, hide, title] = getValueFromProps(this, [
'defaultCollapse',
'hide',
'title',
]);
this.setData({
collapse: defaultCollapse !== null && defaultCollapse !== void 0 ? defaultCollapse : true,
internalHide: hide,
containerTitle: title,
});
},
});
Loading
Loading