import { WATER_COLORS } from '../../constants/colors';

Component({
    options: {},
    /**
     * 组件的属性列表
     */
    properties: {
        show: {
            type: Boolean,
            value: false,
        },
        currentColor: {
            type: String,
            value: '',
        },
    },
    /**
     * 组件的初始数据
     */
    data: {
        extended24Colors: WATER_COLORS.extended24,
    },
    lifetimes: {
        attached() {},
    },
    /**
     * 组件的方法列表
     */
    methods: {
        onClose() {
            this.triggerEvent('onClose');
        },

        onSelectColor(e: WechatMiniprogram.TouchEvent) {
            const { color } = e.currentTarget.dataset;
            this.setData({
                currentColor: color,
            });
        },

        onChange(e: WechatMiniprogram.TouchEvent) {
            const { currentColor } = this.data;
            this.triggerEvent('onChange', { color: currentColor });
        },
    },
});
