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,191 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ PageHeader - v26.11
6
+
7
+ THE HEADER OF A PAGE THAT SLIDES IN OVER THE TABS of a mobile app.
8
+ - The sizes are px of a 600 px design: the page is fitted with page.fit(600, 800), like the mobile template
9
+ (04-templates/mobile-app-template/classic).
10
+ - A white header, 105 px high, a thin soft line at the bottom.
11
+ - A small back link at the top left: a chevron and a text ("Back", or the name of the page under it: "Settings"),
12
+ in a soft blue. It can be clicked (a bigger place than it looks, for a finger), Tab reaches it, Enter / Space
13
+ press it (role "button", a focus ring only for the keyboard).
14
+ - A big title (28 px, bold) under it, at the left; a long title ends with "...".
15
+ - The chevron is drawn in SVG in backColor, or your own file (backIconFile).
16
+
17
+ USAGE:
18
+ const header = PageHeader({ titleText: "Security", backText: "Settings", onBack: function (self) { App.goBack(); } });
19
+ header.setTitleText("Privacy");
20
+ header.setBackText("Back");
21
+ header.setBackVisible(0);
22
+ PageHeader({ titleText: "Details", backColor: "indianred", color: "whitesmoke" });
23
+
24
+ Started Date: November 2026
25
+ Webpage: https://bug7a.github.io/js-components/
26
+
27
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
28
+ Licensed under the Apache License, Version 2.0
29
+ SPDX-License-Identifier: Apache-2.0
30
+
31
+ */
32
+
33
+ "use strict";
34
+
35
+ // Default values:
36
+ const PageHeaderDefaults = {
37
+ key: "0", // Your name for this object: read it in a callback (self.key)
38
+ left: 0, // The header stands at the top of its container (a page)
39
+ top: 0,
40
+ width: "100%",
41
+ height: 105,
42
+ color: "white", // The background of the header
43
+ titleText: "",
44
+ backText: "Back", // The text of the back link (Ex: the name of the page it goes back to)
45
+ showBack: 1, // 1: the back link over the title (setBackVisible)
46
+ backColor: "#689BD2", // The drawn chevron and the text of the back link
47
+ backIconFile: "", // "": a chevron drawn in SVG in backColor
48
+ onBack: function (self) { }, // The back link is clicked (or pressed with Enter / Space)
49
+ style: {
50
+ layout: {
51
+ side: 20, // The space at the left and the right
52
+ backTop: 24, // The back link stands this far from the top
53
+ titleBottom: 24, // The title stands this far from the bottom
54
+ },
55
+ back: {
56
+ iconSize: 20,
57
+ fontSize: 14,
58
+ gap: 3, // Between the chevron and the text
59
+ tapSpace: 8, // A clear space around the link: a bigger place to click (the link does not move)
60
+ round: 4, // The corners of the focus ring
61
+ },
62
+ title: {
63
+ fontSize: 28,
64
+ bold: 1,
65
+ textColor: Black(0.8),
66
+ },
67
+ line: {
68
+ width: 1,
69
+ color: Black(0.1),
70
+ },
71
+ focus: {
72
+ ringColor: "rgba(95, 158, 160, 0.6)", // The ring of the keyboard focus
73
+ },
74
+ },
75
+ };
76
+
77
+ const PageHeader = function (params = {}) {
78
+
79
+ // Merge params:
80
+ mergeIntoIfMissing(params, PageHeaderDefaults);
81
+
82
+ // BOX: Component container
83
+ const box = startObject(params);
84
+
85
+ // *** PRIVATE VARIABLES:
86
+ const _s = box.style;
87
+
88
+ // *** PRIVATE FUNCTIONS:
89
+
90
+ const goBack = function () {
91
+ box.onBack(box);
92
+ };
93
+
94
+ // *** PUBLIC FUNCTIONS:
95
+
96
+ box.setTitleText = function (text) {
97
+ box.titleText = text;
98
+ box.lblTitle.plainText = text;
99
+ };
100
+ // USAGE: header.setTitleText("Security")
101
+
102
+ box.setBackText = function (text) {
103
+ box.backText = text;
104
+ box.lblBack.plainText = text;
105
+ box.btnBack.aria = { label: String(text) };
106
+ };
107
+ // USAGE: header.setBackText("Settings")
108
+
109
+ box.setBackVisible = function (value) {
110
+ box.showBack = basic.isOn(value) ? 1 : 0;
111
+ box.btnBack.visible = box.showBack;
112
+ };
113
+ // USAGE: get: header.showBack, set: header.setBackVisible(0)
114
+
115
+ // *** OBJECT VIEW:
116
+
117
+ // BOX: Header
118
+ box.shrink = 0; // WHY: in a group with a fixed height the header keeps its height
119
+ box.css = { borderBottom: _s.line.width + "px solid " + _s.line.color };
120
+
121
+ // GROUP: Back link (the chevron and the text)
122
+ // WHY tapSpace: the group is bigger than the link by a clear padding, the link stays at (side, backTop)
123
+ const _b = _s.back;
124
+ box.btnBack = HGroup({
125
+ left: _s.layout.side - _b.tapSpace,
126
+ top: _s.layout.backTop - _b.tapSpace,
127
+ hug: 1,
128
+ padding: _b.tapSpace,
129
+ gap: _b.gap,
130
+ align: "left center",
131
+ round: _b.round,
132
+ clickable: 1,
133
+ cursor: "pointer",
134
+ role: "button",
135
+ tabIndex: 0,
136
+ });
137
+
138
+ // ICON: Chevron
139
+ box.icoBack = Icon({ width: _b.iconSize, height: _b.iconSize, alt: "" });
140
+ box.icoBack.load(box.backIconFile || PageHeader.toSvgFile(PageHeader.drawChevron(box.backColor)));
141
+
142
+ // LABEL: Back text
143
+ box.lblBack = Label({ fontSize: _b.fontSize, textColor: box.backColor });
144
+ box.lblBack.css = { whiteSpace: "nowrap" };
145
+
146
+ endGroup();
147
+
148
+ // LABEL: Title
149
+ box.lblTitle = Label({
150
+ left: _s.layout.side,
151
+ bottom: _s.layout.titleBottom,
152
+ width: "calc(100% - " + (_s.layout.side * 2) + "px)",
153
+ ..._s.title,
154
+ ellipsis: 1,
155
+ });
156
+ box.lblTitle.role = "heading";
157
+ box.lblTitle.aria = { level: 1 };
158
+
159
+ // *** OBJECT INIT CODE:
160
+
161
+ box.btnBack.setFocusRing(_s.focus.ringColor);
162
+ box.btnBack.on("click", goBack);
163
+
164
+ // KEYBOARD: Enter / Space press the back link
165
+ box.btnBack.on("keydown", function (self, event) {
166
+ if (event.key != "Enter" && event.key != " ") return;
167
+ event.preventDefault(); // WHY: Space must not scroll the page
168
+ if (event.repeat) return; // WHY: a held key goes back once
169
+ goBack();
170
+ });
171
+
172
+ box.setTitleText(box.titleText);
173
+ box.setBackText(box.backText);
174
+ box.setBackVisible(box.showBack);
175
+
176
+ return endObject(box);
177
+
178
+ };
179
+
180
+ // *** STATIC FUNCTIONS:
181
+
182
+ // An SVG text as a file for an Icon (a data URI)
183
+ PageHeader.toSvgFile = function (svg) {
184
+ return "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg);
185
+ };
186
+
187
+ // A chevron to the left (24 x 24)
188
+ PageHeader.drawChevron = function (color) {
189
+ return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="' + color +
190
+ '" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.6 6L8.9 12l5.7 6"/></svg>';
191
+ };
@@ -0,0 +1,192 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ PasswordField - v26.11
6
+
7
+ UI COMPONENT TEMPLATE
8
+ - You can customize, this template code as you need:
9
+ - NEW PROJECTS: styleName "light" (the default) on a light page, "dark" on a dark page (the packages
10
+ of TextField, comp/text-field.js; the look of 02-comp-examples/text-field-8-light-dark.htm), unless the user asks for another one.
11
+ - comp/tooltip.js, loaded before this file, shows the hint of the eye button in a bubble; without it there is no bubble.
12
+
13
+ Started Date: June 2024
14
+ Webpage: https://bug7a.github.io/js-components/
15
+
16
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
17
+ Licensed under the Apache License, Version 2.0
18
+ SPDX-License-Identifier: Apache-2.0
19
+
20
+ */
21
+
22
+ "use strict";
23
+
24
+ // Default values
25
+ const PasswordFieldDefaults = {
26
+ required: 1,
27
+ requiredText: "Password must be entered",
28
+ type: "password",
29
+ titleText: "PASSWORD",
30
+ placeholder: "Enter your password",
31
+ warningText: "",
32
+ warningColor: "#E5885E",
33
+ maxLength: 25,
34
+ showPassword: 0,
35
+ showShowPasswordButton: 1, // enable show/hide icon by default
36
+ showPasswordIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" preserveAspectRatio="none" fill="none" stroke="#141414" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 23C9 13 15.5 9.5 24 9.5S39 13 44.5 23C39 33 32.5 36.5 24 36.5S9 33 3.5 23Z"/><circle cx="24" cy="23" r="6.5"/></svg>'), // an eye (a page can give its own picture)
37
+ hidePasswordIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" preserveAspectRatio="none" fill="none" stroke="#141414" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 23C9 13 15.5 9.5 24 9.5S39 13 44.5 23C39 33 32.5 36.5 24 36.5S9 33 3.5 23Z"/><circle cx="24" cy="23" r="6.5"/><path d="M6 6.5L41 42"/></svg>'), // a crossed eye
38
+ eyeIconSize: "", // px: the size of the eye (both icons). "": by the height of the field (32; a small field less)
39
+ showPasswordHintText: "Show Password",
40
+ hidePasswordHintText: "Hide Password",
41
+ minLength: 6,
42
+ minLengthWarningText: "Password must be at least 6 characters",
43
+ mustUseNumber: 1,
44
+ mustUseNumberWarningText: "Password must contain at least one number",
45
+ mustUseLetter: 1,
46
+ mustUseLetterWarningText: "Password must contain at least one letter",
47
+ mustUseUppercase: 0,
48
+ mustUseUppercaseWarningText: "Password must contain at least one uppercase letter",
49
+ mustUseLowercase: 0,
50
+ mustUseLowercaseWarningText: "Password must contain at least one lowercase letter",
51
+ mustUseSpecialChar: 0,
52
+ mustUseSpecialCharWarningText: "Password must contain at least one special character",
53
+ invertIconColor: 0,
54
+ };
55
+
56
+ const PasswordField = function(params = {}) {
57
+
58
+ // Merge params:
59
+ // WHY the style package of TextField first: a key it sets (warningColor) wins over the defaults here, as over the
60
+ // defaults of TextField
61
+ basic.applyStylePackage(params, TextField.styles, TextFieldDefaults);
62
+ mergeIntoIfMissing(params, PasswordFieldDefaults);
63
+
64
+ // Edit params:
65
+ params.showLeftBox = 1; // WHY: to add show/hide password button
66
+
67
+ // BOX: Component container
68
+ let box = startExtendedObject(TextField, params);
69
+
70
+ // *** PRIVATE VARIABLES:
71
+
72
+ // *** PUBLIC VARIABLES:
73
+
74
+ // *** PRIVATE FUNCTIONS:
75
+
76
+ // *** PUBLIC FUNCTIONS:
77
+ box.isValid = function() { // OVERRIDE
78
+ const value = box.getValue();
79
+ // 1. The minimum length
80
+ if (value.length < box.minLength) {
81
+ box.setWarningText(box.minLengthWarningText);
82
+ return 0;
83
+ }
84
+ // 2. A digit
85
+ if (box.mustUseNumber == 1 && !(/[0-9]/.test(value))) {
86
+ box.setWarningText(box.mustUseNumberWarningText);
87
+ return 0;
88
+ }
89
+ // 3. A letter
90
+ if (box.mustUseLetter == 1 && !(/[a-zA-Z]/.test(value))) {
91
+ box.setWarningText(box.mustUseLetterWarningText);
92
+ return 0;
93
+ }
94
+ // 4. A capital letter
95
+ if (box.mustUseUppercase == 1 && !(/[A-Z]/.test(value))) {
96
+ box.setWarningText(box.mustUseUppercaseWarningText);
97
+ return 0;
98
+ }
99
+ // 5. A small letter
100
+ if (box.mustUseLowercase == 1 && !(/[a-z]/.test(value))) {
101
+ box.setWarningText(box.mustUseLowercaseWarningText);
102
+ return 0;
103
+ }
104
+ // 6. A special character
105
+ if (box.mustUseSpecialChar == 1 && !(/[^a-zA-Z0-9]/.test(value))) {
106
+ box.setWarningText(box.mustUseSpecialCharWarningText);
107
+ return 0;
108
+ }
109
+ // Passed: no warning
110
+ return 1;
111
+ };
112
+
113
+ box.setShowPassword = function(show) {
114
+ const isShown = (show != 0);
115
+ box.showPassword = isShown ? 1 : 0;
116
+ box.input.inputElement.type = isShown ? "text" : "password";
117
+ // The button shows what a click does:
118
+ if (box.btnShowPassword.tooltip) {
119
+ box.btnShowPassword.tooltip.setHintText(isShown ? box.hidePasswordHintText : box.showPasswordHintText);
120
+ }
121
+ box.btnShowPassword.load(isShown ? box.hidePasswordIconFile : box.showPasswordIconFile);
122
+ };
123
+
124
+ box.refresh = function() {
125
+
126
+ }
127
+
128
+ // *** OBJECT VIEW:
129
+ box.input.inputElement.type = "password";
130
+
131
+ // GROUP: btnShowPassword (in the left box of TextField)
132
+ // WHY: over a field under its title an icon mark stands in the middle of the right padding (TextField light, dark):
133
+ // the eye stands left of that padding, so the mark does not cover it.
134
+ const isMarkInRightPadding = (box.titlePosition === "above" && box.warningBallType === "icon");
135
+ const LEFT_BOX_PADDING = 20; // (the padding of the left box of TextField)
136
+ AutoLayout({
137
+ align: "right center",
138
+ padding: isMarkInRightPadding ? [0, 0, box.rightPadding - LEFT_BOX_PADDING, 0] : [10, 0],
139
+ });
140
+ box.leftBox.add(that);
141
+
142
+ // ICON: Show / hide password button
143
+ // WHY: a small field (minimal: 28 px) takes a smaller eye; the usual fields (40 px) keep 32
144
+ const EYE_RATIO = 0.6;
145
+ const fieldEyeSize = (box.inputHeight >= 40) ? 32 : Math.round(box.inputHeight * EYE_RATIO);
146
+ const eyeSize = box.eyeIconSize || fieldEyeSize;
147
+ box.btnShowPassword = Icon({
148
+ width: eyeSize,
149
+ height: eyeSize,
150
+ visible: box.showShowPasswordButton,
151
+ });
152
+ that.clickable = 1;
153
+ that.cursor = "pointer";
154
+ // WHY selectStyle too: a dark package has white icons there, and the black eye could not be seen on its field.
155
+ if (box.invertIconColor == 1 || box.selectStyle.invertIconColor == 1) {
156
+ box.btnShowPassword.css.filter = "invert(100%)";
157
+ }
158
+
159
+ endAutoLayout();
160
+
161
+ // The hint of the show password button has the look of the hints of the field (tooltipStyle of the package).
162
+ // WHY: a white hint with a dark text does not suit a dark field (ozdenDark, dark).
163
+ // Its bubble: tooltipStyle.color, or hintColor when that is "" (the warning hint takes the color of its ball).
164
+ const hintStyle = box.tooltipStyle;
165
+ // WHY the check: a page without comp/tooltip.js gets the eye button with no bubble, not an error.
166
+ if (typeof Tooltip !== "undefined") {
167
+ box.btnShowPassword.tooltip = Tooltip({
168
+ target: box.btnShowPassword,
169
+ hintText: "",
170
+ hintPosition: "left",
171
+ lbl_border: hintStyle.border,
172
+ lbl_color: hintStyle.color || hintStyle.hintColor,
173
+ lbl_textColor: hintStyle.textColor,
174
+ lbl_borderColor: hintStyle.borderColor,
175
+ lbl_fontSize: hintStyle.fontSize,
176
+ lbl_round: hintStyle.round,
177
+ });
178
+ // WHY: The tooltip may be made outside the box (after TextField is closed); box.own() removes it with the box.
179
+ box.own(box.btnShowPassword.tooltip);
180
+ }
181
+
182
+ // *** OBJECT INIT CODE:
183
+ box.btnShowPassword.on("click", function() {
184
+ box.setShowPassword((box.showPassword == 1) ? 0 : 1);
185
+ });
186
+
187
+ box.setShowPassword(box.showPassword);
188
+ box.checkInputValue(); // WHY: TextField checked the start value before this isValid()
189
+
190
+ return endExtendedObject(box);
191
+
192
+ };