UIfiedMaterialOouiBase.ps1

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
using namespace Ooui

class MaterialOouiHost : OouiHost {

    MaterialOouiHost() {
        [UI]::HeadHtml = '
            <link href="https://demos.creative-tim.com/material-dashboard/assets/css/material-dashboard.min.css?v=2.1.2" rel="stylesheet">
            <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" rel="stylesheet" type="text/css" />
            <style>
                .nav-pills .nav-item .nav-link {
                    line-height: 24px;
                    text-transform: uppercase;
                    font-size: 12px;
                    font-weight: 500;
                    min-width: 100px;
                    text-align: center;
                    color: #555;
                    transition: all .3s;
                    border-radius: 30px;
                    padding: 10px 15px;
                }
                .nav-pills .nav-item .nav-link.active {
                    border-radius: unset;
                    background-color: transparent;
                    padding-bottom: 0px;
                    border-bottom-width: 4px;
                    border-bottom-style: solid;
                    border-bottom-color: lime;
                    margin-bottom: 7px;
                }
                .UIList .form-check {
                    margin-bottom: 0px;
                }
                .UIList .form-check .form-check-label {
                    white-space: nowrap;
                    position: relative;
                    vertical-align: top;
                }
                .card {
                    margin: 50px 20px;
                    width: auto !important;
                }
                .card-title {
                    white-space: nowrap;
                }
            </style>
        '

        [UI]::BodyFooterHtml = ''
    }
}

class MaterialOouiWindow : OouiWindow {
}

class MaterialOouiStackPanel : OouiStackPanel {
}

class MaterialOouiIcon : OouiIcon {
}

class MaterialOouiLabel : OouiLabel {
}

class MaterialOouiButton : OouiButton {
}

class MaterialOouiTextBox : OouiTextBox {

    MaterialOouiTextBox() {
        $this.NativeUI.ClassName = "form-control"
    }
    
}

class MaterialOouiCheckBox : OouiElement {

# <div class="form-check">
# <label class="form-check-label">
# <input class="form-check-input" type="checkbox" value="">
# Option one is this
# <span class="form-check-sign">
# <span class="check"></span>
# </span>
# </label>
# </div>

    hidden [Div]   $ListNativeUI         = [Div]::new()
    hidden [Label] $CheckLabelNativeUI   = [Label]::new()
    hidden [Input] $CheckBoxNativeUI     = [Input]::new("CheckBox")
    hidden [Span]  $SignNativeUI         = [span]::new()
    hidden [Span]  $SpanNativeUI         = [span]::new()
    hidden [Span]  $LabelTextNativeUI    = [span]::new()

    MaterialOouiCheckBox() {
        $this.ListNativeUI.ClassName        = "form-check"
        $this.CheckLabelNativeUI.ClassName  = "form-check-label"
        $this.CheckBoxNativeUI.ClassName    = "form-check-input"
        $this.SignNativeUI.ClassName        = "form-check-sign"
        $this.SpanNativeUI.ClassName        = "check"

        $this.LabelTextNativeUI.Style.PaddingLeft = "25px"

        $this.ListNativeUI.AppendChild($this.CheckLabelNativeUI)
        $this.CheckLabelNativeUI.AppendChild($this.CheckBoxNativeUI)
        $this.CheckLabelNativeUI.AppendChild($this.SignNativeUI)
        $this.CheckLabelNativeUI.AppendChild($this.LabelTextNativeUI)
        $this.SignNativeUI.AppendChild($this.SpanNativeUI)
        $this.SetNativeUI($this.ListNativeUI)

        $this.WrapProperty("Caption", "Text", "LabelTextNativeUI")
        $this.WrapProperty("IsChecked", "IsChecked", "CheckBoxNativeUI")
        $this.AddScriptBlockProperty("Click")
        Register-ObjectEvent -InputObject $this.CheckBoxNativeUI -EventName Change -MessageData $this -Action {
            $this = $event.MessageData
            $this.Control.OnClick()
        } | Out-Null
    }

    [void] OnClick() {
        Invoke-Command -ScriptBlock $this._Click -ArgumentList $this
    }

}

class MaterialOouiRadioButton : OouiElement {

#<div class="form-check form-check-radio">
# <label class="form-check-label">
# <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" >
# Radio is off
# <span class="circle">
# <span class="check"></span>
# </span>
# </label>
#</div>

    hidden [Div]   $ListNativeUI         = [Div]::new()
    hidden [Label] $CheckLabelNativeUI   = [Label]::new()
    hidden [Input] $RadioButtonNativeUI     = [Input]::new("Radio")
    hidden [Span]  $SignNativeUI         = [span]::new()
    hidden [Span]  $SpanNativeUI         = [span]::new()
    hidden [Span]  $LabelTextNativeUI    = [span]::new()

    MaterialOouiRadioButton() {
        $this.ListNativeUI.ClassName        = "form-check"
        $this.CheckLabelNativeUI.ClassName  = "form-check-label"
        $this.RadioButtonNativeUI.ClassName    = "form-check-input"
        $this.SignNativeUI.ClassName        = "circle"
        $this.SpanNativeUI.ClassName        = "check"

        $this.LabelTextNativeUI.Style.PaddingLeft = "25px"

        $this.ListNativeUI.AppendChild($this.CheckLabelNativeUI)
        $this.CheckLabelNativeUI.AppendChild($this.RadioButtonNativeUI)
        $this.CheckLabelNativeUI.AppendChild($this.SignNativeUI)
        $this.CheckLabelNativeUI.AppendChild($this.LabelTextNativeUI)
        $this.SignNativeUI.AppendChild($this.SpanNativeUI)
        $this.SetNativeUI($this.ListNativeUI)

        $this.WrapProperty("Caption", "Text", "LabelTextNativeUI")
        $this.WrapProperty("IsChecked", "IsChecked", "RadioButtonNativeUI")
        $this.AddScriptBlockProperty("Click")
        Register-ObjectEvent -InputObject $this.RadioButtonNativeUI -EventName Change -MessageData $this -Action {
            $this = $event.MessageData
            $this.Control.OnClick()
        } | Out-Null
    }

    [void] OnClick() {
        Invoke-Command -ScriptBlock $this._Click -ArgumentList $this
    }

}

class MaterialOouiRadioGroup : OouiRadioGroup {
}

class MaterialOouiList : OouiList {
}

class MaterialOouiListColumn : OouiListColumn {
}

class MaterialOouiTabItem : OouiTabItem {
}

class MaterialOouiTabControl : OouiTabControl {

    RefreshStyle() {
        $this.List.ClassName = "nav nav-pills nav-pills-primary"
    }

}

class MaterialOouiModal : OouiModal {
}

class MaterialOouiTimer : OouiTimer {
}

class MaterialOouiDatePicker : OouiDatePicker {
}

class MaterialOouiTimePicker : OouiTimePicker {
}

class MaterialOouiBrowser : OouiBrowser {

    [void] StyleComponents() {
        $this.List.NativeUI.ClassName   = "UIList table"

        $this.FirstButton.Icon        = [OouiIcon] @{ Kind = "first_page"    }
        $this.PreviousButton.Icon     = [OouiIcon] @{ Kind = "chevron_left"  }
        $this.NextButton.Icon         = [OouiIcon] @{ Kind = "chevron_right" }
        $this.LastButton.Icon         = [OouiIcon] @{ Kind = "last_page"     }
        $this.AddNewButton.Icon       = [OouiIcon] @{ Kind = "add"           }

        $this.FirstButton.NativeUI.ClassName        = "btn btn-primary btn-link"
        $this.PreviousButton.NativeUI.ClassName     = "btn btn-primary btn-link"
        $this.NextButton.NativeUI.ClassName         = "btn btn-primary btn-link"
        $this.LastButton.NativeUI.ClassName         = "btn btn-primary btn-link"
        $this.AddNewButton.NativeUI.ClassName       = "btn btn-fab btn-round btn-lg"

        $this.AddNewButton.NativeUI.Style.BackgroundColor = "lime"
    }

    [void] StyleEditionButtons([OouiButton] $editButton, [OouiButton] $deleteButton, [int] $rowIndex) {
        $editButton.Icon     = [MaterialOouiIcon] @{ Kind = "edit"  }
        $deleteButton.Icon   = [MaterialOouiIcon] @{ Kind = "close" }
        
        $editButton.NativeUI.ClassName          = "btn btn-success btn-link btn-sm"
        $deleteButton.NativeUI.ClassName        = "btn btn-danger btn-link btn-sm"
        $editButton.Parent.NativeUI.ClassName   = "td-actions"
    }

}

class MaterialOouiMenuItem : OouiMenuItem {
}

class MaterialOouiDropDownMenu : OouiDropDownMenu {
}

class MaterialOouiAutoComplete : OouiAutoComplete {
}

class MaterialOouiCard : OouiCard {
}

class MaterialOouiImage : OouiImage {
}

class MaterialOouiTextEditor : OouiTextEditor {
}

class MaterialOouiExpander : OouiElement {
    hidden  [div]               $ExpanderContainerDiv     = [div]::new()
    hidden  [div]               $ExpanderHeaderDiv        = [div]::new()
    hidden  [div]               $ExpanderButtonDiv        = [div]::new()
    hidden  [OouiStackPanel]    $ExpanderBodyDiv          = [OouiStackPanel]::new()
    hidden  [Button]            $ExpanderButton           = [Button]::new()
    hidden  [Heading]           $Header                   = [Heading]::new(4)
    hidden  [Icon]              $ExpanderIcon             = [Icon]::new()

    MaterialOouiExpander() {
        $this.SetNativeUI($this.ExpanderContainerDiv)
        $this.ExpanderContainerDiv.AppendChild($this.ExpanderHeaderDiv)
        $this.ExpanderContainerDiv.AppendChild($this.ExpanderBodyDiv.NativeUI)
        $this.ExpanderHeaderDiv.AppendChild($this.ExpanderButtonDiv)
        $this.ExpanderHeaderDiv.AppendChild($this.Header)
        $this.ExpanderButtonDiv.AppendChild($this.ExpanderButton)
        $this.ExpanderButton.AppendChild($this.ExpanderIcon)
        
        $this.WrapProperty("Caption", "Text", "Header")
        $this.AddNativeUIChild = {
            param (
                [OouiElement] $element
            )
            $listItem = [Div]::new()
            if ($this.ExpanderBodyDiv.Orientation -eq [Orientation]::Horizontal) {
                $listItem.Style.float = "left"
            } else {
                $listItem.Style.clear = "both"
            }
            $this.ExpanderBodyDiv.NativeUI.AppendChild($listItem) | Out-Null
            $listItem.AppendChild($element.NativeUI) | Out-Null
        }
        Register-ObjectEvent -InputObject $this.ExpanderButton -EventName Click -MessageData $this -Action {
            $this = $event.MessageData
            $this.ToogleContent()
        } | Out-Null
        $this.StyleComponents()
    }

    [void] StyleComponents() {
        $this.ExpanderButton.ClassName                    = "btn btn-primary btn-link btn-sm"
        $this.ExpanderButton.Style.Padding                = "0"
        $this.ExpanderIcon.ClassName                      = "material-icons"
        $this.ExpanderIcon.Text                           = "expand_less"
        $this.ExpanderButtonDiv.Style.float               = "left"
        $this.Header.Style.display                        = "inline"
        $this.ExpanderIcon.Style.FontSize                 = "2rem"
        $this.ExpanderHeaderDiv.Style.BorderBottomStyle   = "solid"
        $this.ExpanderHeaderDiv.Style.BorderBottomColor   = "#ddd"
        $this.ExpanderHeaderDiv.Style.BorderBottomWidth   = "1px"
    }

    [void] ToogleContent() {
        $this.ExpanderBodyDiv.Visible = -not $this.ExpanderBodyDiv.Visible
        if ($this.ExpanderIcon.Text -eq "expand_more") {
            $this.ExpanderIcon.Text = "expand_less"
        } else {
            $this.ExpanderIcon.Text = "expand_more"
        }
    }
}