ozdenui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +14 -0
  3. data/NOTICE +5 -0
  4. data/README.md +242 -0
  5. data/exe/ozdenui +17 -0
  6. data/lib/ozdenui/AGENTS.md +210 -0
  7. data/lib/ozdenui/COMPONENTS.md +3017 -0
  8. data/lib/ozdenui/app.rb +749 -0
  9. data/lib/ozdenui/command.rb +107 -0
  10. data/lib/ozdenui/components.rb +368 -0
  11. data/lib/ozdenui/dialogs.rb +212 -0
  12. data/lib/ozdenui/files.rb +124 -0
  13. data/lib/ozdenui/icon.png +0 -0
  14. data/lib/ozdenui/kit.json +1 -0
  15. data/lib/ozdenui/kit.rb +115 -0
  16. data/lib/ozdenui/look.rb +229 -0
  17. data/lib/ozdenui/objects.rb +652 -0
  18. data/lib/ozdenui/server.rb +270 -0
  19. data/lib/ozdenui/values.rb +273 -0
  20. data/lib/ozdenui/version.rb +15 -0
  21. data/lib/ozdenui/web/basic/LICENSE +14 -0
  22. data/lib/ozdenui/web/basic/basic.min.css +1 -0
  23. data/lib/ozdenui/web/basic/basic.min.js +78 -0
  24. data/lib/ozdenui/web/basic/font/open-sans/LICENSE.txt +206 -0
  25. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
  26. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
  27. data/lib/ozdenui/web/basic/scroll-bar.min.js +3 -0
  28. data/lib/ozdenui/web/bridge.js +584 -0
  29. data/lib/ozdenui/web/comp/accordion.js +659 -0
  30. data/lib/ozdenui/web/comp/action-button/add.png +0 -0
  31. data/lib/ozdenui/web/comp/action-button.js +521 -0
  32. data/lib/ozdenui/web/comp/action-tab-bar.js +383 -0
  33. data/lib/ozdenui/web/comp/app-bar.js +237 -0
  34. data/lib/ozdenui/web/comp/badge.js +292 -0
  35. data/lib/ozdenui/web/comp/bottom-bar.js +555 -0
  36. data/lib/ozdenui/web/comp/breadcrumbs.js +524 -0
  37. data/lib/ozdenui/web/comp/canvas.js +652 -0
  38. data/lib/ozdenui/web/comp/chat-view.js +827 -0
  39. data/lib/ozdenui/web/comp/check-box.js +490 -0
  40. data/lib/ozdenui/web/comp/code-editor.js +965 -0
  41. data/lib/ozdenui/web/comp/color-picker.js +636 -0
  42. data/lib/ozdenui/web/comp/context-menu.js +951 -0
  43. data/lib/ozdenui/web/comp/currency-field.js +209 -0
  44. data/lib/ozdenui/web/comp/data-table/arrow.svg +2 -0
  45. data/lib/ozdenui/web/comp/data-table.js +937 -0
  46. data/lib/ozdenui/web/comp/date-picker.js +1055 -0
  47. data/lib/ozdenui/web/comp/dialog.js +992 -0
  48. data/lib/ozdenui/web/comp/email-field.js +65 -0
  49. data/lib/ozdenui/web/comp/file-picker.js +920 -0
  50. data/lib/ozdenui/web/comp/filters.js +807 -0
  51. data/lib/ozdenui/web/comp/form.js +602 -0
  52. data/lib/ozdenui/web/comp/full-screen-select/arrow.svg +2 -0
  53. data/lib/ozdenui/web/comp/full-screen-select/cancel.svg +2 -0
  54. data/lib/ozdenui/web/comp/full-screen-select.js +614 -0
  55. data/lib/ozdenui/web/comp/gauge.js +439 -0
  56. data/lib/ozdenui/web/comp/graph-box.js +3911 -0
  57. data/lib/ozdenui/web/comp/grid-group.js +185 -0
  58. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash-red.png +0 -0
  59. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash.png +0 -0
  60. data/lib/ozdenui/web/comp/hold-to-confirm-button.js +289 -0
  61. data/lib/ozdenui/web/comp/image-view.js +598 -0
  62. data/lib/ozdenui/web/comp/item-list.js +1740 -0
  63. data/lib/ozdenui/web/comp/json-editor.js +3221 -0
  64. data/lib/ozdenui/web/comp/json-view.js +597 -0
  65. data/lib/ozdenui/web/comp/label-editor.js +1140 -0
  66. data/lib/ozdenui/web/comp/left-menu/data-table.png +0 -0
  67. data/lib/ozdenui/web/comp/left-menu/home.png +0 -0
  68. data/lib/ozdenui/web/comp/left-menu/reports.png +0 -0
  69. data/lib/ozdenui/web/comp/left-menu/setting.png +0 -0
  70. data/lib/ozdenui/web/comp/left-menu.js +548 -0
  71. data/lib/ozdenui/web/comp/line-progress-bar.js +343 -0
  72. data/lib/ozdenui/web/comp/loading-screen.js +413 -0
  73. data/lib/ozdenui/web/comp/log-view.js +530 -0
  74. data/lib/ozdenui/web/comp/login-page.js +685 -0
  75. data/lib/ozdenui/web/comp/markdown-view.js +1045 -0
  76. data/lib/ozdenui/web/comp/menu-bar.js +624 -0
  77. data/lib/ozdenui/web/comp/mini-graph-box.js +492 -0
  78. data/lib/ozdenui/web/comp/minimal-accent.js +208 -0
  79. data/lib/ozdenui/web/comp/notice.js +229 -0
  80. data/lib/ozdenui/web/comp/number-field.js +128 -0
  81. data/lib/ozdenui/web/comp/numeric-keyboard.js +298 -0
  82. data/lib/ozdenui/web/comp/page-control.js +762 -0
  83. data/lib/ozdenui/web/comp/page-header.js +191 -0
  84. data/lib/ozdenui/web/comp/password-field/hide-btn.png +0 -0
  85. data/lib/ozdenui/web/comp/password-field/hide-btn2.png +0 -0
  86. data/lib/ozdenui/web/comp/password-field/show-btn.png +0 -0
  87. data/lib/ozdenui/web/comp/password-field/show-btn2.png +0 -0
  88. data/lib/ozdenui/web/comp/password-field.js +192 -0
  89. data/lib/ozdenui/web/comp/period-bar.js +436 -0
  90. data/lib/ozdenui/web/comp/phone-field.js +322 -0
  91. data/lib/ozdenui/web/comp/progress-bar.js +992 -0
  92. data/lib/ozdenui/web/comp/property-panel.js +3639 -0
  93. data/lib/ozdenui/web/comp/radio-button.js +527 -0
  94. data/lib/ozdenui/web/comp/range-slider.js +569 -0
  95. data/lib/ozdenui/web/comp/rich-text-editor.js +1064 -0
  96. data/lib/ozdenui/web/comp/scroll-area.js +308 -0
  97. data/lib/ozdenui/web/comp/scrolling-text.js +297 -0
  98. data/lib/ozdenui/web/comp/search-input/clear-round.svg +1 -0
  99. data/lib/ozdenui/web/comp/search-input/clear.svg +1 -0
  100. data/lib/ozdenui/web/comp/search-input/filter.png +0 -0
  101. data/lib/ozdenui/web/comp/search-input/filter.svg +1 -0
  102. data/lib/ozdenui/web/comp/search-input/search.svg +1 -0
  103. data/lib/ozdenui/web/comp/search-input.js +725 -0
  104. data/lib/ozdenui/web/comp/search-results.js +596 -0
  105. data/lib/ozdenui/web/comp/select-box.js +1862 -0
  106. data/lib/ozdenui/web/comp/settings-row.js +299 -0
  107. data/lib/ozdenui/web/comp/side-panel.js +616 -0
  108. data/lib/ozdenui/web/comp/slider-field.js +952 -0
  109. data/lib/ozdenui/web/comp/slider.js +838 -0
  110. data/lib/ozdenui/web/comp/smart-button/alert-black.png +0 -0
  111. data/lib/ozdenui/web/comp/smart-button/clock.png +0 -0
  112. data/lib/ozdenui/web/comp/smart-button.js +981 -0
  113. data/lib/ozdenui/web/comp/smart-table/clock.png +0 -0
  114. data/lib/ozdenui/web/comp/smart-table/down.png +0 -0
  115. data/lib/ozdenui/web/comp/smart-table/scroll.png +0 -0
  116. data/lib/ozdenui/web/comp/smart-table/sort.png +0 -0
  117. data/lib/ozdenui/web/comp/smart-table/up.png +0 -0
  118. data/lib/ozdenui/web/comp/smart-table.js +1883 -0
  119. data/lib/ozdenui/web/comp/sortable-list.js +1181 -0
  120. data/lib/ozdenui/web/comp/spark-line-box.js +738 -0
  121. data/lib/ozdenui/web/comp/splitter.js +411 -0
  122. data/lib/ozdenui/web/comp/status-bar.js +408 -0
  123. data/lib/ozdenui/web/comp/step-bar.js +345 -0
  124. data/lib/ozdenui/web/comp/stepper.js +753 -0
  125. data/lib/ozdenui/web/comp/tabs.js +1366 -0
  126. data/lib/ozdenui/web/comp/tag-input.js +1107 -0
  127. data/lib/ozdenui/web/comp/tap-effect.js +170 -0
  128. data/lib/ozdenui/web/comp/text-area-field.js +233 -0
  129. data/lib/ozdenui/web/comp/text-field.js +1006 -0
  130. data/lib/ozdenui/web/comp/time-line.js +398 -0
  131. data/lib/ozdenui/web/comp/time-picker.js +1032 -0
  132. data/lib/ozdenui/web/comp/tiny-select/arrow.svg +1 -0
  133. data/lib/ozdenui/web/comp/tiny-select.js +322 -0
  134. data/lib/ozdenui/web/comp/tiny-table.js +283 -0
  135. data/lib/ozdenui/web/comp/toast.js +891 -0
  136. data/lib/ozdenui/web/comp/toggle.js +757 -0
  137. data/lib/ozdenui/web/comp/tool-bar.js +760 -0
  138. data/lib/ozdenui/web/comp/tooltip.js +534 -0
  139. data/lib/ozdenui/web/comp/tree-view.js +1179 -0
  140. data/lib/ozdenui/web/comp/ui-effects.js +1097 -0
  141. data/lib/ozdenui/web/comp/ui-standards.js +403 -0
  142. data/lib/ozdenui/web/comp/url-field.js +190 -0
  143. data/lib/ozdenui/web/comp/web-view.js +588 -0
  144. data/lib/ozdenui/web/components.js +123 -0
  145. data/lib/ozdenui/web/index.html +39 -0
  146. data/lib/ozdenui/window.rb +188 -0
  147. data/lib/ozdenui/window_cocoa.rb +221 -0
  148. data/lib/ozdenui.rb +32 -0
  149. metadata +200 -0
@@ -0,0 +1,685 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ LoginPage - v26.10
6
+
7
+ UI COMPONENT
8
+ - A full page with two views: LOGIN and SIGN UP (a tab bar switches them). The page does the service work in
9
+ onLoginClick / onSignupClick and calls box.waiting.show() / hide() and box.showAlert() around it.
10
+ - The tab bar is Tabs (the pill variant, colored by the tab_ params), the waiting cover is
11
+ LoadingScreen with the moving clock (box.waiting.show() / hide(); waitingCoverColor, waitingClock).
12
+ tabWidth: "auto" (default) is as wide as its tabs; a width (Ex: the panelWidth) makes the
13
+ tabs share it. tabStyle: more keys of the style of that Tabs (pillBar, tab, pillActive, pillIndicator...), over the
14
+ look made from the tab_ params.
15
+ - LoginPageLightStyle: the params of a light page (...LoginPageLightStyle, or mergeIntoIfMissing). Its tab bar
16
+ : one light gray (#EFEFEF), the edge of the Google / Apple buttons (Black(0.2)), a white
17
+ selected tab with a soft shadow (its tabStyle). A page that gives its own tabStyle after it replaces that shadow.
18
+ - The LOGIN / SIGN UP buttons: buttonStyleName "" (default) keeps the flat buttons in
19
+ primaryColor; a SmartButton template (Ex: "ozden3") makes them SmartButtons of the kit, in buttonTone (Ex:
20
+ "blue"), with the text color of the tone. A passive one has the passive look of SmartButton.
21
+ - The logos of createButtonWithIcon, drawn in the page (no links to other sites):
22
+ LoginPage.GOOGLE_LOGO (the colored G) and LoginPage.getAppleLogo(color) (the apple in one color on a transparent
23
+ ground: give it the text color of its button, loginPage.style.customLoginButton.textColor).
24
+
25
+ LOAD FIRST (in this order):
26
+ basic.js, comp/ui-effects.js, comp/tooltip.js, comp/text-field.js, comp/email-field.js,
27
+ comp/password-field.js, comp/tabs.js, comp/smart-button.js, comp/loading-screen.js
28
+ (LoadingScreen needs smart-button.js: the clock drawing)
29
+
30
+
31
+ Started Date: June 2024
32
+ Webpage: https://bug7a.github.io/js-components/
33
+
34
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
35
+ Licensed under the Apache License, Version 2.0
36
+ SPDX-License-Identifier: Apache-2.0
37
+
38
+ - Every call to a service is outside the component: a page finishes the login with its own service (onLoginClick, onSignupClick).
39
+ - The dark and the light page are set with the params.
40
+ - The login button is passive while both fields are empty.
41
+ - The sign up button is active only when the form has no error.
42
+
43
+ */
44
+
45
+ "use strict";
46
+
47
+ // Default values:
48
+ const LoginPageDefaults = {
49
+ panelWidth: 420,
50
+ //autoFit: 1, // add page.fit() function onResize
51
+ primaryColor: "#2C5A38",
52
+ tab_backgroundColorBottom: "#242424", // "#242424", "whitesmoke"
53
+ tab_backgroundColorTop: "#242424",
54
+ tab_borderColor: White(0.1), // White(0.1), Black(0),
55
+ tab_border: 1, // 1, 0
56
+ tab_textColor: White(0.75), // White(0.75), "#373836",
57
+ tab_selectedColor: "#000000", // "#000000", "white",
58
+ tabWidth: "auto", // the LOGIN / SIGN UP bar: "auto" (as wide as its tabs) or a width the tabs share (Ex: the panelWidth)
59
+ tabStyle: {}, // more keys of the style of its Tabs (pillBar, tab, pillActive, pillIndicator...), over the tab_ look
60
+ inputStyleName: "", // "": the fields take the input_ colors below. A TextField package ("ozden", "ozdenDark"...): the fields take its look.
61
+ buttonStyleName: "", // "": LOGIN / SIGN UP are flat buttons in primaryColor. A SmartButton template ("ozden3"...): SmartButtons
62
+ buttonTone: "", // The tone of those SmartButtons (Ex: "blue"; "": the gray of the template)
63
+ input_backgroundColor: "#141414",
64
+ input_lineColor: "transparent",
65
+ input_selectedBackgroundColor: "#202020",
66
+ input_textColor: White(0.85), // Black(0.85), White(0.85)
67
+ input_border: 1, // 1, 0
68
+ input_borderColor: White(0.1), // White(0.1), Black(0.1)
69
+ orTextColor: White(0.75), // White(0.75), Black(0.75)
70
+ orLineColor: White(0.1), // White(0.1), Black(0.1)
71
+ panelName: "MY PANEL v25.08.11",
72
+ allowHtml: 0, // 1: panelName, the alerts and the texts of the buttons are HTML (only for your own texts)
73
+ onLoginClick: function() {},
74
+ onSignupClick: function() {},
75
+ showPasswordIconInvert: 1,
76
+ showPasswordIconFile: "", // "": the eye of PasswordField
77
+ hidePasswordIconFile: "", // "": the crossed eye of PasswordField
78
+ waitingCoverColor: "rgba(0, 0, 0, 0.6)", // The cover of box.waiting (LoadingScreen)
79
+ waitingClock: "ozden", // The clock of box.waiting: "ozden" (a white face) or "ozdenDark" (LoadingScreen.clocks)
80
+ signupPasswordParams: {
81
+ minLength: 8,
82
+ minLengthWarningText: "Password must be at least 8 characters",
83
+ mustUseNumber: 1,
84
+ mustUseLetter: 1,
85
+ mustUseUppercase: 0,
86
+ mustUseLowercase: 0,
87
+ mustUseSpecialChar: 0,
88
+ },
89
+ style: {
90
+ customLoginButton: { height: 50, round: 4, color: "#141414", gap: 12, border: 1, borderColor: White(0.1), textColor: White(0.75), },
91
+ }
92
+ };
93
+
94
+ const LoginPageLightStyle = {
95
+ panelName: "MY PANEL v25.08.11",
96
+ primaryColor: "#65A293",
97
+ // THE TAB BAR: one light gray (the ozden fields under the mouse), the edge of the Google / Apple buttons (customLoginButton), a white selected tab
98
+ tab_backgroundColorBottom: "#EFEFEF",
99
+ tab_backgroundColorTop: "#EFEFEF",
100
+ tab_border: 1, // 1, 1
101
+ tab_borderColor: Black(0.2), // White(0.1), Black(0.2),
102
+ tab_textColor: "#373836", // White(0.75), "#373836",
103
+ tab_selectedColor: "white", // "#000000", "white",
104
+ tabStyle: {
105
+ pillIndicator: { shadow: "0 1px 2px rgba(0, 0, 0, 0.12)" }, // WHY: a white tab on the light gray is lost without it
106
+ },
107
+ input_backgroundColor: "#F6F6F6",
108
+ input_lineColor: "transparent",
109
+ input_selectedBackgroundColor: "#F3F4E0",
110
+ input_textColor: Black(0.85), // Black(0.85), White(0.85)
111
+ input_border: 1, // 1, 0
112
+ input_borderColor: Black(0.1), // White(0.1), Black(0.1)
113
+ orTextColor: Black(0.75), // White(0.75), Black(0.75)
114
+ orLineColor: Black(0.1), // White(0.1), Black(0.1)
115
+ showPasswordIconInvert: 0,
116
+ style: {
117
+ customLoginButton: { height: 50, round: 4, color: "whitesmoke", gap: 12, border: 1, borderColor: Black(0.2), textColor: Black(0.75), },
118
+ },
119
+ };
120
+
121
+ const LoginPage = function(params = {}) {
122
+
123
+ // Merge params:
124
+ mergeIntoIfMissing(params, LoginPageDefaults);
125
+
126
+ // Edit params, if needed:
127
+ params.left = 0;
128
+ params.top = 0;
129
+ params.width = "100%";
130
+ params.height = "100%";
131
+
132
+ // BOX: Component container
133
+ let box = startObject(params);
134
+
135
+ // *** PRIVATE VARIABLES:
136
+ const ALERT_TIME = 1000; // ms: the alert closes itself after this.
137
+ const TAB_KEYS = ["login", "signup"]; // The keys of the tabs, by the index of setActiveTab()
138
+ const TAB_MOTION = 0.2; // seconds: the selected tab slides
139
+ const TAB_BAR_PADDING = 2; // px around the tabs, in the bar
140
+ const WAITING_FADE_TIME = 0.2; // seconds
141
+ const ACTION_BUTTON_HEIGHT = 50; // px: LOGIN / SIGN UP (the height of the buttons of the page under them)
142
+
143
+ // *** PRIVATE FUNCTIONS:
144
+
145
+ const setText = function (label, text) {
146
+ const value = (text === undefined || text === null) ? "" : String(text);
147
+ if (box.allowHtml == 1) label.text = value;
148
+ else label.plainText = value;
149
+ };
150
+
151
+ box.customButtonCount = 0;
152
+
153
+ const initView = function() {
154
+
155
+ // Page container
156
+ box.container = AutoLayout({
157
+ flow: "vertical",
158
+ align: "center top",
159
+ width: "100%",
160
+ height: "100%",
161
+ padding: [30, 50],
162
+ gap: 40,
163
+ });
164
+
165
+ // Title
166
+ box.title = Label({
167
+ right: 30,
168
+ bottom: 30,
169
+ fontSize: 20,
170
+ textColor: White(0.4),
171
+ position: "absolute",
172
+ });
173
+ setText(box.title, box.panelName);
174
+
175
+ // Tab Bar
176
+ createTabBar();
177
+
178
+ // Views wrapper
179
+ box.contentContainer = startBox({
180
+ width: box.panelWidth,
181
+ height: "auto",
182
+ color: "transparent",
183
+ clipContent: 0,
184
+ });
185
+
186
+ box.viewGroup = HGroup({
187
+ align: "left top",
188
+ height: "auto",
189
+ color: "transparent",
190
+ width: box.panelWidth * 2,
191
+ });
192
+ box.viewGroup.setMotion("left 0.2s");
193
+
194
+ // LOGIN VIEW
195
+ box.loginBox = AutoLayout({
196
+ flow: "vertical",
197
+ align: "left top",
198
+ gap: 10,
199
+ height: "auto",
200
+ width: box.panelWidth,
201
+ color:"transparent",
202
+ opacity: 0,
203
+ });
204
+ that.setMotion("opacity 0.2s");
205
+
206
+ // The params of every field: a TextField package (inputStyleName), or the input_ colors.
207
+ const common = (box.inputStyleName) ? {
208
+ width: "100%",
209
+ leftPadding: 16,
210
+ rightPadding: 16,
211
+ styleName: box.inputStyleName,
212
+ } : {
213
+ styleName: "modern", // the first look of TextField: the input_ colors are for it
214
+ width: "100%",
215
+ leftPadding: 16,
216
+ rightPadding: 16,
217
+ backgroundColor: box.input_backgroundColor,
218
+ lineColor: box.input_lineColor,
219
+ focusBackgroundColor: box.input_selectedBackgroundColor,
220
+ focusLineColor: box.primaryColor,
221
+ };
222
+
223
+ box.loginEmail = EmailField({
224
+ ...common,
225
+ titleText: "EMAIL",
226
+ placeholder: "example@site.com",
227
+ required: 0,
228
+ maxLength: 60,
229
+ value: "",
230
+ });
231
+ styleInput(that);
232
+ that.onChange = function() {
233
+ checkLoginForm();
234
+ };
235
+
236
+ box.loginPassword = PasswordField({
237
+ ...common,
238
+ titleText: "PASSWORD",
239
+ placeholder: "Enter your password",
240
+ maxLength: 60,
241
+ showShowPasswordButton: 1,
242
+ required: 0,
243
+ showPasswordIconFile: box.showPasswordIconFile || PasswordFieldDefaults.showPasswordIconFile,
244
+ hidePasswordIconFile: box.hidePasswordIconFile || PasswordFieldDefaults.hidePasswordIconFile,
245
+ value: "",
246
+ minLength: 0,
247
+ mustUseNumber: 0,
248
+ mustUseLetter: 0,
249
+ mustUseUppercase: 0,
250
+ mustUseLowercase: 0,
251
+ mustUseSpecialChar: 0,
252
+ invertIconColor: box.showPasswordIconInvert,
253
+ });
254
+ styleInput(that);
255
+ that.onChange = function() {
256
+ checkLoginForm();
257
+ };
258
+
259
+ // Login button
260
+ box.loginBtn = createActionButton("LOGIN", function(self, event) {
261
+ box.onLoginClick(self, event);
262
+ });
263
+
264
+ // or group
265
+ box.boxOR = startBox({
266
+ width: "100%",
267
+ height: 60,
268
+ color: "transparent",
269
+ });
270
+ that.opacity = 0;
271
+
272
+ // BOX: Line
273
+ Box(0,0,"100%",1, {
274
+ color: box.orLineColor,
275
+ });
276
+ that.center("top");
277
+ that.top += 2;
278
+
279
+ // LABEL: or
280
+ Label({
281
+ text: "or",
282
+ textColor: box.orTextColor,
283
+ color: box.parentBox.color, // WHY: It covers the line behind it.
284
+ padding: [12,6],
285
+ });
286
+ that.center();
287
+
288
+ endBox();
289
+
290
+ // NOTE: The page adds its own login buttons with box.createButtonWithIcon().
291
+
292
+ endAutoLayout(); // end login view
293
+
294
+ // SIGN UP VIEW
295
+ box.signupBox = AutoLayout({
296
+ flow: "vertical",
297
+ align: "left top",
298
+ gap: 10,
299
+ height: "auto",
300
+ width: box.panelWidth,
301
+ color: "transparent",
302
+ });
303
+ that.opacity = 0;
304
+ that.setMotion("opacity 0.2s");
305
+
306
+ box.signupEmail = EmailField({
307
+ ...common,
308
+ titleText: "EMAIL",
309
+ placeholder: "example@site.com",
310
+ required: 1,
311
+ maxLength: 60,
312
+ });
313
+ styleInput(that);
314
+ that.onChange = function() {
315
+ checkSignupForm();
316
+ };
317
+
318
+ box.signupPassword = PasswordField({
319
+ ...common,
320
+ titleText: "PASSWORD",
321
+ placeholder: "Create a password",
322
+ maxLength: 60,
323
+ showPasswordIconFile: box.showPasswordIconFile || PasswordFieldDefaults.showPasswordIconFile,
324
+ hidePasswordIconFile: box.hidePasswordIconFile || PasswordFieldDefaults.hidePasswordIconFile,
325
+ showShowPasswordButton: 1,
326
+ ...box.signupPasswordParams,
327
+ invertIconColor: box.showPasswordIconInvert,
328
+ });
329
+ styleInput(that);
330
+ that.onChange = function() {
331
+ checkSignupForm();
332
+ };
333
+
334
+ box.signupPassword2 = PasswordField({
335
+ ...common,
336
+ titleText: "CONFIRM PASSWORD",
337
+ placeholder: "Re-enter password",
338
+ maxLength: 60,
339
+ showPasswordIconFile: box.showPasswordIconFile || PasswordFieldDefaults.showPasswordIconFile,
340
+ hidePasswordIconFile: box.hidePasswordIconFile || PasswordFieldDefaults.hidePasswordIconFile,
341
+ showShowPasswordButton: 1,
342
+ ...box.signupPasswordParams,
343
+ invertIconColor: box.showPasswordIconInvert,
344
+ });
345
+ styleInput(that);
346
+ that.onChange = function() {
347
+ checkSignupForm();
348
+ };
349
+
350
+ box.signupBtn = createActionButton("SIGN UP", function(self, event) {
351
+ box.onSignupClick(self, event);
352
+ });
353
+
354
+ endAutoLayout(); // END SIGN UP VIEW
355
+
356
+ endGroup(); // box.viewGroup
357
+
358
+ endBox(); // box.contentContainer
359
+
360
+ endAutoLayout(); // box.container
361
+
362
+ box.alertBox = startBox(0, 0, "100%", "100%", {
363
+ color: Black(0.8),
364
+ opacity: 0,
365
+ clickable: 0,
366
+ });
367
+ box.alertBox.setMotion("opacity 0.2s");
368
+
369
+ box.lblAlert = Label({
370
+ left: 40,
371
+ top: 40,
372
+ text: "",
373
+ textColor: "indianred",
374
+ padding: [12, 4],
375
+ round: 4,
376
+ border: 1,
377
+ borderColor: White(0.2),
378
+ });
379
+
380
+ endBox();
381
+
382
+ box.showAlert = function(text = "Error", color = "indianred") {
383
+
384
+ setText(box.lblAlert, text);
385
+ box.lblAlert.textColor = color;
386
+ box.alertBox.opacity = 1;
387
+ box.alertBox.clickable = 1;
388
+
389
+ if (box.alertBox.timer) clearTimeout(box.alertBox.timer);
390
+ box.alertBox.timer = setTimeout(function() {
391
+ box.alertBox.opacity = 0;
392
+ box.alertBox.clickable = 0;
393
+ }, ALERT_TIME);
394
+
395
+ };
396
+
397
+ // Waiting
398
+ createWaiting();
399
+
400
+ // First check
401
+ checkLoginForm();
402
+ checkSignupForm();
403
+
404
+ // Default tab
405
+ box.setActiveTab(0);
406
+
407
+ };
408
+
409
+ // WHY: box.superRemove is overwritten by a component that extends this one, so the local copy is called below.
410
+ const superRemove = box.remove;
411
+ box.superRemove = superRemove;
412
+ box.remove = function () {
413
+
414
+ // NOTE: box is not set to null. WHY: The page's login code (onLoginClick) may remove it when the login
415
+ // is done, and still call box.waiting.hide() after that (box.waiting checks box._isRemoved).
416
+ if (box._isRemoved) return; // WHY: remove() can be called twice (also by the parent's remove()).
417
+ clearTimeout(box.alertBox.timer);
418
+ // NOTE: The LoadingScreen of box.waiting is inside the box: basic.js removes it with the box.
419
+
420
+ superRemove.call(box); // NOTE: basic.js remove(). It cleans all the events and the objects inside.
421
+
422
+ };
423
+
424
+ // Helpers
425
+ // Shows the LOGIN (0) or the SIGN UP (1) view. The tab bar follows it.
426
+ box.setActiveTab = function(index) {
427
+
428
+ box.tabBar.setValue(TAB_KEYS[index], 1); // silent: a click on the bar is already here
429
+
430
+ if (index === 0) {
431
+ box.viewGroup.left = 0;
432
+ box.loginBox.opacity = 1;
433
+ box.signupBox.opacity = 0;
434
+
435
+ } else {
436
+ box.viewGroup.left = box.panelWidth * -1;
437
+ box.loginBox.opacity = 0;
438
+ box.signupBox.opacity = 1;
439
+ }
440
+
441
+ // WHY inert: the hidden view is only transparent and not clipped; its LOGIN button (or its fields) next
442
+ // to the panel took clicks and the focus (a click on the empty side signed in)
443
+ box.loginBox.elem.inert = (index !== 0);
444
+ box.signupBox.elem.inert = (index === 0);
445
+
446
+ };
447
+
448
+ box.createButtonWithIcon = function(text, iconFile, onClick) {
449
+
450
+ // WHY: The "or" line is shown only when there is a button under it.
451
+ box.customButtonCount++;
452
+ box.boxOR.opacity = 1;
453
+
454
+ // GROUP: Button (icon, text)
455
+ HGroup({
456
+ width: "100%",
457
+ position: "relative",
458
+ ...box.style.customLoginButton,
459
+ });
460
+ box.loginBox.add(that);
461
+ that.cursor = "pointer";
462
+ that.on("click", onClick);
463
+ UIEffects.press(that);
464
+
465
+ Icon(0, 0, 24, 24);
466
+ that.load(iconFile);
467
+
468
+ Label({
469
+ textColor: box.style.customLoginButton.textColor,
470
+ fontSize: 20,
471
+ });
472
+ setText(that, text);
473
+
474
+ endBox();
475
+
476
+ };
477
+
478
+ // The look of the LOGIN / SIGN UP bar from the tab_ params (the style of a pill Tabs)
479
+ const getTabBarStyle = function(barPadding) {
480
+ return {
481
+ pillBar: {
482
+ color: box.tab_backgroundColorBottom,
483
+ padding: [barPadding, barPadding],
484
+ gap: 3,
485
+ round: 8,
486
+ border: box.tab_border,
487
+ borderColor: box.tab_borderColor,
488
+ },
489
+ tab: { fontSize: 14, textColor: box.tab_textColor, padding: [12, 4], round: 6, minHeight: 0 },
490
+ tabHover: { color: "transparent", textColor: box.tab_textColor },
491
+ pillActive: { textColor: box.tab_textColor },
492
+ pillIndicator: { color: box.tab_selectedColor, round: 6, shadow: "none", motion: TAB_MOTION },
493
+ };
494
+ };
495
+
496
+ // The LOGIN / SIGN UP bar: a pill Tabs in the colors of the tab_ params.
497
+ const createTabBar = function() {
498
+
499
+ // WHY: the edge of the bar is drawn inside its padding, so the bar is not bigger with it.
500
+ const barPadding = Math.max(0, TAB_BAR_PADDING - basic.num(box.tab_border));
501
+
502
+ // (the keys of tabStyle win over the look made from the tab_ params)
503
+ const tabStyle = JSON.parse(JSON.stringify(box.tabStyle || {}));
504
+ mergeIntoIfMissing(tabStyle, getTabBarStyle(barPadding));
505
+
506
+ box.tabBar = Tabs({
507
+ scale: 1, // WHY: the rest of this component is not scaled (basic.uiScale): its tab bar must not be either
508
+ variant: "pill",
509
+ width: box.tabWidth,
510
+ fullWidth: (box.tabWidth === "auto") ? 0 : 1, // a width: the tabs share it
511
+ tabs: [
512
+ { key: TAB_KEYS[0], text: "LOGIN" },
513
+ { key: TAB_KEYS[1], text: "SIGN UP" },
514
+ ],
515
+ value: TAB_KEYS[0],
516
+ showArrows: 0,
517
+ ariaLabel: "Login or sign up",
518
+ style: tabStyle,
519
+ onChange: function(self) {
520
+ box.setActiveTab(self.getIndex());
521
+ },
522
+ });
523
+
524
+ // WHY: Tabs has one bar color; this bar is a gradient from the bottom color (at the top) to the top color.
525
+ const gradient = `linear-gradient(to bottom, ${box.tab_backgroundColorBottom}, ${box.tab_backgroundColorTop})`;
526
+ box.tabBar.strip.css.background = gradient;
527
+
528
+ };
529
+
530
+ // The waiting cover of the login and sign up jobs: a LoadingScreen with the moving clock.
531
+ // WHY a wrapper: the pages call box.waiting.show() / hide(); LoadingScreen opens with open() / close()
532
+ // (its show() / hide() are the basic.js ones, they only change "visible").
533
+ const createWaiting = function() {
534
+
535
+ const loadingScreen = LoadingScreen({
536
+ opened: 0,
537
+ minDuration: 0,
538
+ fadeDuration: WAITING_FADE_TIME,
539
+ style: {
540
+ box: { color: box.waitingCoverColor },
541
+ clock: LoadingScreen.clocks[box.waitingClock] || LoadingScreen.clocks.ozden,
542
+ },
543
+ });
544
+
545
+ box.waiting = {
546
+ screen: loadingScreen,
547
+ show: function() {
548
+ if (box._isRemoved) return;
549
+ loadingScreen.open();
550
+ },
551
+ hide: function() {
552
+ if (box._isRemoved) return;
553
+ loadingScreen.close();
554
+ },
555
+ };
556
+
557
+ };
558
+
559
+ // Style
560
+ const styleInput = function(obj) {
561
+
562
+ // WHY: a TextField package gives the whole look of the field (its round, border and text color).
563
+ if (box.inputStyleName) return;
564
+
565
+ obj.background.round = 4;
566
+ obj.background.border = box.input_border;
567
+ obj.background.borderColor = box.input_borderColor;
568
+ obj.warningBall.borderColor = Black(1);
569
+
570
+ // NOTE: Only for a text input (a textarea keeps its own text color).
571
+ if (obj.type !== "textarea") obj.input.textColor = box.input_textColor;
572
+
573
+ };
574
+
575
+ // An action button of a view (LOGIN, SIGN UP): a SmartButton of the kit (buttonStyleName, buttonTone), or the
576
+ // flat button in primaryColor. action(self, event) runs while the button is active.
577
+ // WHY box.onLoginClick read at the click (in the action of the caller): a function given after creation
578
+ // (loginPage.onLoginClick = fn) was never called.
579
+ const createActionButton = function(text, action) {
580
+
581
+ // (a passive SmartButton runs no onClick, also on a key)
582
+ if (box.buttonStyleName) {
583
+ return SmartButton({
584
+ styleName: box.buttonStyleName,
585
+ tone: box.buttonTone,
586
+ labelText: text,
587
+ allowHtml: box.allowHtml,
588
+ width: "100%",
589
+ height: ACTION_BUTTON_HEIGHT,
590
+ onClick: action,
591
+ });
592
+ }
593
+
594
+ const button = Button({
595
+ textColor: White(0.75),
596
+ fontSize: 20,
597
+ width: "100%",
598
+ height: ACTION_BUTTON_HEIGHT,
599
+ round: 4,
600
+ color: box.primaryColor,
601
+ minimal: 1,
602
+ });
603
+ setText(button, text);
604
+ button.clickable = 1;
605
+ button.cursor = "pointer";
606
+ UIEffects.press(button);
607
+ // WHY the check: a passive button is only clickable 0 (no mouse), a <button> still clicks on Tab + Enter: an
608
+ // invalid e-mail logged in, a 1-letter password signed up
609
+ button.on("click", function(self, event) {
610
+ if (button.clickable != 1) return;
611
+ action(self, event);
612
+ });
613
+ return button;
614
+
615
+ };
616
+
617
+ // The send buttons are passive (gray, not clickable) until their form is ready.
618
+ const setButtonActive = function(btn, isActive) {
619
+ if (box.buttonStyleName) {
620
+ btn.setEnabled(isActive ? 1 : 0); // (a SmartButton: its own passive look)
621
+ return;
622
+ }
623
+ btn.clickable = isActive ? 1 : 0;
624
+ btn.css.filter = isActive ? "grayscale(0%)" : "grayscale(100%)";
625
+ };
626
+
627
+ const checkLoginForm = function() {
628
+
629
+ const hasEmail = box.loginEmail.getValue().length > 0;
630
+ const hasPassword = box.loginPassword.getValue().length > 0;
631
+ const isEmailValid = (box.loginEmail.status === 0);
632
+
633
+ setButtonActive(box.loginBtn, hasEmail && hasPassword && isEmailValid);
634
+
635
+ };
636
+
637
+ const checkSignupForm = function() {
638
+
639
+ const isEmailValid = (box.signupEmail.status === 0);
640
+ const isPasswordValid = (box.signupPassword.status === 0);
641
+ const isPassword2Valid = (box.signupPassword2.status === 0);
642
+
643
+ setButtonActive(box.signupBtn, isEmailValid && isPasswordValid && isPassword2Valid);
644
+
645
+ };
646
+
647
+ initView();
648
+
649
+ return endObject(box);
650
+
651
+ };
652
+
653
+ // *** THE LOGOS OF THE SIGN-IN BUTTONS (createButtonWithIcon)
654
+ // WHY drawn here: no link to another site, no picture file.
655
+
656
+ // An SVG text as a picture file (Icon.load).
657
+ LoginPage.toSvgFile = function(svg) {
658
+ return "data:image/svg+xml;utf8," + encodeURIComponent(svg);
659
+ };
660
+
661
+ // The colored G of Google: the 4 shapes of its sign-in logo (www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg).
662
+ LoginPage.GOOGLE_LOGO_SHAPES = [
663
+ { color: "#4285F4", path: "M117.6,61.3636364 C117.6,57.1090909 117.218182,53.0181818 116.509091,49.0909091 L60,49.0909091 L60,72.3 L92.2909091,72.3 C90.9,79.8 86.6727273,86.1545455 80.3181818,90.4090909 L80.3181818,105.463636 L99.7090909,105.463636 C111.054545,95.0181818 117.6,79.6363636 117.6,61.3636364 L117.6,61.3636364 Z" },
664
+ { color: "#34A853", path: "M60,120 C76.2,120 89.7818182,114.627273 99.7090909,105.463636 L80.3181818,90.4090909 C74.9454545,94.0090909 68.0727273,96.1363636 60,96.1363636 C44.3727273,96.1363636 31.1454545,85.5818182 26.4272727,71.4 L6.38181818,71.4 L6.38181818,86.9454545 C16.2545455,106.554545 36.5454545,120 60,120 L60,120 Z" },
665
+ { color: "#FBBC05", path: "M26.4272727,71.4 C25.2272727,67.8 24.5454545,63.9545455 24.5454545,60 C24.5454545,56.0454545 25.2272727,52.2 26.4272727,48.6 L26.4272727,33.0545455 L6.38181818,33.0545455 C2.31818182,41.1545455 0,50.3181818 0,60 C0,69.6818182 2.31818182,78.8454545 6.38181818,86.9454545 L26.4272727,71.4 L26.4272727,71.4 Z" },
666
+ { color: "#EA4335", path: "M60,23.8636364 C68.8090909,23.8636364 76.7181818,26.8909091 82.9363636,32.8363636 L100.145455,15.6272727 C89.7545455,5.94545455 76.1727273,0 60,0 C36.5454545,0 16.2545455,13.4454545 6.38181818,33.0545455 L26.4272727,48.6 C31.1454545,34.4181818 44.3727273,23.8636364 60,23.8636364 L60,23.8636364 Z" }
667
+ ];
668
+
669
+ LoginPage.GOOGLE_LOGO = (function() {
670
+ const paths = LoginPage.GOOGLE_LOGO_SHAPES.map(function(shape) {
671
+ return '<path fill="' + shape.color + '" d="' + shape.path + '"/>';
672
+ });
673
+ return LoginPage.toSvgFile('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 118 120">' + paths.join("") + '</svg>');
674
+ })();
675
+ // USAGE: loginPage.createButtonWithIcon("Sign in with Google", LoginPage.GOOGLE_LOGO, onLoginWithGoogle);
676
+
677
+ LoginPage.APPLE_LOGO_PATH = "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701";
678
+
679
+ // The apple of Apple in one color on a transparent ground: the text color of its button (dark on a light button,
680
+ // light on a dark one).
681
+ LoginPage.getAppleLogo = function(color) {
682
+ const path = '<path fill="' + color + '" d="' + LoginPage.APPLE_LOGO_PATH + '"/>';
683
+ return LoginPage.toSvgFile('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' + path + '</svg>');
684
+ };
685
+ // USAGE: loginPage.createButtonWithIcon("Sign in with Apple", LoginPage.getAppleLogo(loginPage.style.customLoginButton.textColor), onLoginWithApple);