1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ ██████ ██████ ██████       █      █      █      █      █ █▄  ▀███ █       ┃
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█  ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄  ▀█ █ ▀▀▀▀▀ ┃
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄   █ ▄▄▄▄▄ ┃
// ┃ █      ██████ █  ▀█▄       █ ██████      █      ███▌▐███ ███████▄ █       ┃
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ Copyright (c) 2017, the Perspective Authors.                              ┃
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
// ┃ This file is part of the Perspective library, distributed under the terms ┃
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

use yew::html;

use super::CustomNumberFormat;
use crate::components::form::select_field::SelectEnumField;
use crate::components::style_controls::{CustomNumberFormatMsg, NotationName};
use crate::config::*;

impl CustomNumberFormat {
    pub fn misc_section(&self, ctx: &yew::prelude::Context<Self>) -> yew::prelude::Html {
        let compact_display_checkbox = if let Some(Notation::Compact(val)) = self.config._notation {
            let cb = ctx.link().callback(CustomNumberFormatMsg::CompactDisplay);
            Some(html! {
                <SelectEnumField<CompactDisplay>
                    label="compact-display"
                    on_change={cb}
                    current_value={val}
                />
            })
        } else {
            None
        };

        html! {
            <>
                <SelectEnumField<NotationName>
                    label="notation"
                    on_change={ctx.link().callback(CustomNumberFormatMsg::NotationChanged)}
                    current_value={self.notation.unwrap_or_default()}
                />
                { compact_display_checkbox }
                <SelectEnumField<UseGrouping>
                    label="use-grouping"
                    on_change={ctx.link().callback(CustomNumberFormatMsg::UseGrouping)}
                    current_value={self.config.use_grouping.unwrap_or_default()}
                />
                <SelectEnumField<SignDisplay>
                    label="sign-display"
                    on_change={ctx.link().callback(CustomNumberFormatMsg::SignDisplay)}
                    current_value={self.config.sign_display.unwrap_or_default()}
                />
            </>
        }
    }
}