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,725 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ Search Input - v24.04
6
+
7
+ UI COMPONENT TEMPLATE
8
+ - You can customize, this template code as you need:
9
+ - Style packages: "ozden" (the default), "ozdenDark", "original" (the first look: whitesmoke with a soft bottom line,
10
+ the values of SearchInputDefaults), "light" (its old name "classic") and
11
+ "dark" (the light and dark look of the kit: a white / dark field with one thin line, round 10, a line search icon,
12
+ a soft round clear button, the accent on the edge while typing: _designs/search-input.htm).
13
+ Select with styleName. (SearchInput.styles)
14
+ -- "light", "dark", "ozden" and "ozdenDark" are 44 px high ("original" and the defaults: 50). A
15
+ height given by the page wins over it.
16
+ - focusBorderColor: the edge while typing, 2 px of this color ("": the edge does not change). It is a
17
+ color, not a motion: also with animated: 0. "light" and "dark" have it. focusBorderWidth: 1 only the edge (minimal).
18
+ - The vertical place: textOffsetY / clearIconOffsetY / searchIconOffsetY move the text and the icons from the
19
+ middle of the box. ozden / ozdenDark: -2 / -1: center() does not count their 3 px bottom line, and the small letters
20
+ of Open Sans sit low in their line (measured: the text was about 3 px low, the clear icon 1 px; the search icon is
21
+ right where it is: its round lens is over the middle, its handle under it). light / dark: the icons 1 px under the
22
+ middle, at the middle of the small letters of the text.
23
+ -- A package is a package of params (basic.js v26.10.27): its keys fill the params you did not give.
24
+ -- SearchInput.styles.myStyle = { style: {}, color: "white", textColor: "#222", ... };
25
+ - animated: 1 adds small motions (not at the first view): under the mouse a thin line and a bigger search icon,
26
+ while typing a stronger line and a tilted search icon (a small pulse at every letter), the clear icon grows in
27
+ and turns under the mouse. Off in every package, "ozden" and "ozdenDark" too: give animated: 1.
28
+ Only transform, opacity and box-shadow change (smooth, cheap). Off when the system asks for reduced motion.
29
+ - Place: left / top (default 0, 0), or right / bottom: SearchInput({ right: 20, bottom: 20 }) is at the right bottom
30
+ corner of its box (the default left / top is not used then). Sample: 02-comp-examples/search-input-place.htm
31
+ - The right end: clearIconRight moves the clear icon and the end of the text to the left, so
32
+ the right end of the box is kept for an object of the page (the column chip of SmartTable); setClearIconRight().
33
+ A click on such an object keeps its own click (it does not start typing). textEndSpace: the px between the end of
34
+ the text and the clear icon (light and dark: 6). clearIconMinTextWidth: a narrow box does
35
+ not show its clear icon when the text beside it would be narrower than this; the text gets its place.
36
+ - A cut text: a text longer than the box is not cut sharply: it fades out over textFadeWidth px
37
+ at the side where it goes on (under the clear icon, an object of the page, or the search icon). While not typing,
38
+ it goes on under the icon at its end (SearchInput.TEXT_UNDER_END: 20 px, the width of the clear icon) and fades
39
+ out slowly into it. While typing, the text ends before the icon and only the far side of a caret at the end of the
40
+ text fades, so the caret is always seen. textFadeWidth: 0 cuts sharply.
41
+ - Escape: clearOnEscape: 1 makes Escape clear the text, as the clear icon (also in a narrow
42
+ box with no clear icon). The key is used (preventDefault): a Dialog or a SidePanel around the field does not close;
43
+ in an empty field Escape goes on to them. Off by default; SmartTable turns it on for its filter.
44
+
45
+ Started Date: December 2025
46
+ Webpage: https://bug7a.github.io/js-components/
47
+
48
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
49
+ Licensed under the Apache License, Version 2.0
50
+ SPDX-License-Identifier: Apache-2.0
51
+
52
+ */
53
+
54
+ "use strict";
55
+ // Default values
56
+ const SearchInputDefaults = {
57
+ left: 0,
58
+ top: 0,
59
+ width: 300,
60
+ height: 50,
61
+ searchIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.707 22.293l-5.969-5.969a10.016 10.016 0 10-1.414 1.414l5.969 5.969a1 1 0 001.414-1.414zM10 18a8 8 0 118-8 8.009 8.009 0 01-8 8z"/></svg>'),
62
+ clearIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>'),
63
+ searchIconSize: 24,
64
+ searchIconLeft: 16, // px: the search icon from the left side of the box
65
+ searchIconGap: 8, // px: between the search icon and the text
66
+ clearIconRight: 16, // px: the clear icon from the right side of the box (more: the right end is for an object of the page)
67
+ textEndSpace: null, // px between the end of the text and the clear icon. null: 20 - searchIconSize (where it always was)
68
+ showClearIcon: 1,
69
+ clearIconMinTextWidth: 0, // px: the clear icon is not shown when the text beside it would be narrower (0: always shown)
70
+ textFadeWidth: 24, // px: a text longer than the box fades out over this width where it is cut (0: cut sharply)
71
+ clearOnEscape: 0, // 1: Escape clears the text (as the clear icon); in an empty field it goes on to the page
72
+ value: "", // The text in the box: typing changes it. setValue(), getValue()
73
+ placeholder: "Search",
74
+ color: "whitesmoke",
75
+ textColor: "rgba(0, 0, 0, 0.8)",
76
+ placeholderColor: "", // "": the color of the browser. On a dark ground give a color like White(0.35).
77
+ searchIconOpacity: 1,
78
+ clearIconOpacity: 0.6, // The clear icon while it is shown
79
+ border: 0,
80
+ borderColor: "rgba(0, 0, 0, 0.1)",
81
+ borderBottomStyle: "2px solid rgba(0, 0, 0, 0.06)",
82
+ focusBorderColor: "", // the edge while typing: 2 px of this color ("": it does not change)
83
+ focusBorderWidth: 2, // px of the edge while typing: 2 the edge and a 1 px line inside it, 1 only the edge
84
+ round: 6,
85
+ fontSize: 20,
86
+ textOffsetY: 0, // px: the text up (-) or down (+) from the middle of the box (the ozden packages: -2)
87
+ clearIconOffsetY: 0, // px: the clear icon up (-) or down (+) from the middle of the box (the ozden packages: -1)
88
+ searchIconOffsetY: 0, // px: the search icon up (-) or down (+) from the middle of the box (light and dark: 1)
89
+ invertIconColor: 0, // 1: both icons are inverted (white icons for a dark field)
90
+ invertSearchIconColor: null, // null: invertIconColor. 0 / 1: only the search icon
91
+ invertClearIconColor: null, // null: invertIconColor. 0 / 1: only the clear icon
92
+ animated: 0, // 1: small hover / focus / clear motions. (box.setAnimated(0/1))
93
+ hoverRingColor: "rgba(0, 0, 0, 0.08)", // animated: the thin line inside the border under the mouse
94
+ focusRingColor: "rgba(0, 0, 0, 0.16)", // animated: the line while typing
95
+ onChange: function(self) {}, // The text changed (typed, pasted, cleared, setValue()): self.value, self.getSearchText() (lower case). Not at create time, not with setValue(value, 1)
96
+ onEnter: function(self) {}, // Enter, and the clear icon: self.getSearchText()
97
+ styleName: "ozden", // "ozden", "ozdenDark", "original" (the look of these defaults), "light" ("classic": its old name), "dark", "minimal", "minimalDark" or a name added to SearchInput.styles
98
+ style: {}, // WHY: the look is in the flat params above; the packages are packages of params (see SearchInput.styles).
99
+ };
100
+
101
+ const SearchInput = function(params = {}) {
102
+
103
+ // Merge style package: your params > SearchInput.styles[styleName] (a package of params) > SearchInputDefaults
104
+ basic.applyStylePackage(params, SearchInput.styles, SearchInputDefaults);
105
+
106
+ // WHY: A box placed with right / bottom does not get the default left / top. In basic.js the setter of left
107
+ // clears right (and top clears bottom), so the default left: 0 / top: 0, set after them, put the box back
108
+ // at the left top corner.
109
+ const isPlacedByRight = (params.right !== undefined && params.left === undefined);
110
+ const isPlacedByBottom = (params.bottom !== undefined && params.top === undefined);
111
+
112
+ // Merge params:
113
+ mergeIntoIfMissing(params, SearchInputDefaults);
114
+ if (isPlacedByRight) delete params.left;
115
+ if (isPlacedByBottom) delete params.top;
116
+
117
+ // BOX: Component container
118
+ const box = startObject(params);
119
+
120
+ // *** Private variables:
121
+ const ICONS_SPACE = 80; // The width of the box that is not for the text, with the default icon place (16 + 8)
122
+ const CLEAR_ICON_PLACE = 16; // px: the text is longer by this when the clear icon is not used
123
+ const CLEAR_ICON_SIZE = 20; // px
124
+
125
+ // animated: 1
126
+ const MOTION_TIME = "0.25s";
127
+ const MOTION_EASE = "cubic-bezier(0.2, 0.8, 0.2, 1)"; // a fast start and a soft stop
128
+ const HOVER_RING_WIDTH = 1;
129
+ const FOCUS_RING_WIDTH = 2;
130
+ const HOVER_ICON_GROW = 1.08;
131
+ const FOCUS_ICON_GROW = 1.06; // WHY: at 1.1 the tilted icon touched the text
132
+ const FOCUS_ICON_TILT = -12; // deg: the magnifier "looks"
133
+ const ICON_OPACITY_GAIN = 0.25; // the search icon is clearer under the mouse (x2 while typing)
134
+ const HIDDEN_CLEAR_ICON_SIZE = 0.6; // the clear icon grows in from this size
135
+ const CLEAR_ICON_TURN = 90; // deg, under the mouse
136
+ const PULSE_GROW = 1.14; // the search icon at a typed letter
137
+ const PULSE_TIME = 150; // ms
138
+ let isHovered = 0;
139
+ let isFocused = 0;
140
+ let isClearHovered = 0;
141
+ let wasAnimated = 0;
142
+ let isPulsing = 0;
143
+ let cancelPulse = null;
144
+ let restBorderColor = ""; // focusBorderColor: the edge before typing
145
+
146
+ // *** Public variables:
147
+ box.publicVar = "";
148
+
149
+ // *** Private functions:
150
+
151
+ // The width of the text beside the clear icon: the box without the icons. A search icon moved from its default
152
+ // place (16 + 8), or a clear icon moved from its place (clearIconRight 16), moves the text too.
153
+ // textEndSpace: the space before the clear icon is given (light and dark: 6).
154
+ const getTextWidthWithClearIcon = function() {
155
+ if (box.textEndSpace !== null) {
156
+ const textLeft = box.searchIconLeft + box.searchIconSize + box.searchIconGap;
157
+ return box.width - textLeft - box.textEndSpace - CLEAR_ICON_SIZE - box.clearIconRight;
158
+ }
159
+ const iconMove = (box.searchIconLeft - SearchInputDefaults.searchIconLeft) + (box.searchIconGap - SearchInputDefaults.searchIconGap);
160
+ const clearIconMove = box.clearIconRight - SearchInputDefaults.clearIconRight;
161
+ return box.width - ICONS_SPACE - iconMove - clearIconMove;
162
+ };
163
+
164
+ // The clear icon is used: it is on, and the box has room for it (clearIconMinTextWidth)
165
+ const isClearIconUsed = function() {
166
+ if (!box.showClearIcon) return false;
167
+ if (!box.clearIconMinTextWidth) return true;
168
+ return getTextWidthWithClearIcon() >= box.clearIconMinTextWidth;
169
+ };
170
+
171
+ // The width of the text: with no clear icon, the text goes on to its place. While not typing, a cut text goes on
172
+ // under the icon (or the object of the page) at its end and fades out there.
173
+ const getTextWidth = function() {
174
+ const width = getTextWidthWithClearIcon();
175
+ const textWidth = isClearIconUsed() ? width : width + CLEAR_ICON_PLACE;
176
+ return textWidth + getTextUnderEnd();
177
+ };
178
+
179
+ // How far the text goes under the icon at its end (0 while typing, or with no fade)
180
+ // WHY not while typing: the caret at the end of the text must not be under the icon.
181
+ const getTextUnderEnd = function() {
182
+ if (isFocused || !box.textFadeWidth) return 0;
183
+ return SearchInput.TEXT_UNDER_END;
184
+ };
185
+
186
+ const refreshTextWidth = function() {
187
+ box.txtSearch.width = getTextWidth();
188
+ refreshTextFade();
189
+ };
190
+
191
+ // The text and the icons in the middle of the box; textOffsetY and clearIconOffsetY move the text and the clear
192
+ // icon from there (the ozden packages: see SearchInput.styles.ozden).
193
+ const placeVertically = function(self) {
194
+ self.txtSearch.center("top");
195
+ self.txtSearch.top += self.textOffsetY;
196
+ self.imgClearIcon.center("top");
197
+ self.imgClearIcon.top += self.clearIconOffsetY;
198
+ self.imgIcon.center("top");
199
+ self.imgIcon.top += self.searchIconOffsetY;
200
+ };
201
+
202
+ const refreshLayout = function(self) {
203
+
204
+ self.txtSearch.width = getTextWidth();
205
+ placeVertically(self);
206
+ refreshClearIcon(); // WHY: a narrower or a wider box can lose or get back its clear icon (clearIconMinTextWidth)
207
+ refreshTextFade();
208
+
209
+ };
210
+
211
+ // The box itself, the search icon or the text (not the clear icon, not an object of the page in the box)
212
+ const isFieldPart = function(target) {
213
+ return target === box.elem || box.imgIcon.elem.contains(target) || box.txtSearch.elem.contains(target);
214
+ };
215
+
216
+ // The sides where the text is cut fade out (it goes on under an icon or an object of the page).
217
+ // WHY only the far side of a caret at the end while typing: a faded side hid the caret (arrows, a click in the text).
218
+ const refreshTextFade = function() {
219
+ const input = box.txtSearch.inputElement;
220
+ const isCutLeft = (input.scrollLeft > 0);
221
+ const isCutRight = (input.scrollLeft + input.clientWidth < input.scrollWidth - 1);
222
+ const isCaretAtEnd = (input.selectionStart === input.value.length);
223
+ const canFade = (box.textFadeWidth > 0) && (!isFocused || isCaretAtEnd);
224
+ const mask = canFade ? getTextFadeMask(isCutLeft, isCutRight) : "";
225
+ box.txtSearch.css = { maskImage: mask, webkitMaskImage: mask };
226
+ };
227
+
228
+ // A mask that is transparent at a cut side and reaches the text after textFadeWidth px ("": no fade). At the end
229
+ // the fade is longer by the part under the icon: the text fades out slowly into it.
230
+ const getTextFadeMask = function(isCutLeft, isCutRight) {
231
+ if (!isCutLeft && !isCutRight) return "";
232
+ const startFade = box.textFadeWidth + "px";
233
+ const endFade = (box.textFadeWidth + getTextUnderEnd()) + "px";
234
+ const start = isCutLeft ? "transparent 0px, #000 " + startFade : "#000 0px";
235
+ const end = isCutRight ? "#000 calc(100% - " + endFade + "), transparent 100%" : "#000 100%";
236
+ return "linear-gradient(to right, " + start + ", " + end + ")";
237
+ };
238
+
239
+
240
+ // An icon's own invert param (0 / 1), or invertIconColor when it is null.
241
+ const isIconInverted = function(iconInvert) {
242
+ if (iconInvert === null || iconInvert === undefined) return (box.invertIconColor == 1);
243
+ return (iconInvert == 1);
244
+ };
245
+
246
+ const setClearIconVisible = function(isVisible) {
247
+ box.imgClearIcon.opacity = (isVisible) ? box.clearIconOpacity : 0;
248
+ box.imgClearIcon.clickable = (isVisible) ? 1 : 0;
249
+ paintMotion();
250
+ };
251
+
252
+ // WHY: A user who asked the system for less motion gets the still field.
253
+ const isMotionOn = function() {
254
+ if (box.animated != 1) return false;
255
+ const reduceMotion = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
256
+ return !reduceMotion;
257
+ };
258
+
259
+ const getRing = function() {
260
+ if (isFocused) return "inset 0 0 0 " + FOCUS_RING_WIDTH + "px " + box.focusRingColor;
261
+ if (isHovered) return "inset 0 0 0 " + HOVER_RING_WIDTH + "px " + box.hoverRingColor;
262
+ return "inset 0 0 0 0 transparent";
263
+ };
264
+
265
+ const getSearchIconTransform = function() {
266
+ if (isPulsing) return "scale(" + PULSE_GROW + ") rotate(" + FOCUS_ICON_TILT + "deg)";
267
+ if (isFocused) return "scale(" + FOCUS_ICON_GROW + ") rotate(" + FOCUS_ICON_TILT + "deg)";
268
+ if (isHovered) return "scale(" + HOVER_ICON_GROW + ")";
269
+ return "none";
270
+ };
271
+
272
+ const getSearchIconOpacity = function() {
273
+ let gain = 0;
274
+ if (isHovered) gain = ICON_OPACITY_GAIN;
275
+ if (isFocused) gain = ICON_OPACITY_GAIN * 2;
276
+ return Math.min(1, box.searchIconOpacity + gain);
277
+ };
278
+
279
+ const getClearIconTransform = function() {
280
+ if (!box.imgClearIcon.clickable) return "scale(" + HIDDEN_CLEAR_ICON_SIZE + ")";
281
+ if (isClearHovered) return "rotate(" + CLEAR_ICON_TURN + "deg)";
282
+ return "none";
283
+ };
284
+
285
+ // The look of the hover / focus / clear icon state. (Nothing when animated is off.)
286
+ const paintMotion = function() {
287
+ if (!isMotionOn()) return;
288
+ box.boxShadow = getRing();
289
+ box.imgIcon.css.transform = getSearchIconTransform();
290
+ box.imgIcon.opacity = getSearchIconOpacity();
291
+ box.imgClearIcon.css.transform = getClearIconTransform();
292
+ };
293
+
294
+ // A letter is typed: the search icon grows a little and goes back. (Many letters: one longer pulse.)
295
+ const pulseSearchIcon = function() {
296
+ if (!isMotionOn()) return;
297
+ if (cancelPulse) cancelPulse();
298
+ isPulsing = 1;
299
+ paintMotion();
300
+ cancelPulse = box.after(PULSE_TIME, function() {
301
+ isPulsing = 0;
302
+ cancelPulse = null;
303
+ paintMotion();
304
+ });
305
+ };
306
+
307
+ // Back to the still look, after setAnimated(0).
308
+ const removeMotion = function() {
309
+ wasAnimated = 0;
310
+ box.setMotion("");
311
+ box.imgIcon.setMotion("");
312
+ box.boxShadow = "";
313
+ box.imgIcon.css.transform = "";
314
+ box.imgIcon.opacity = box.searchIconOpacity;
315
+ box.imgClearIcon.css.transform = "";
316
+ };
317
+
318
+ // The transitions and the still look of animated: 0.
319
+ const applyAnimated = function() {
320
+ if (!isMotionOn()) {
321
+ box.imgClearIcon.setMotion("opacity 0.3s");
322
+ if (wasAnimated) removeMotion();
323
+ return;
324
+ }
325
+ wasAnimated = 1;
326
+ const motion = function(properties) {
327
+ return properties.map(function(property) { return property + " " + MOTION_TIME + " " + MOTION_EASE; }).join(", ");
328
+ };
329
+ box.setMotion(motion(["box-shadow"]));
330
+ box.imgIcon.setMotion(motion(["transform", "opacity"]));
331
+ box.imgClearIcon.setMotion(motion(["transform", "opacity"]));
332
+ paintMotion();
333
+ };
334
+
335
+ // THE EDGE WHILE TYPING (focusBorderColor): the edge and an inset line of the same color, 2 px. WHY also with
336
+ // animated: 0: a field shows where the typing goes; it is a color, not a motion. (animated: 1 draws its own line.)
337
+ const paintFocusEdge = function() {
338
+ if (!box.focusBorderColor) return;
339
+ if (isFocused) {
340
+ restBorderColor = box.borderColor;
341
+ box.borderColor = box.focusBorderColor;
342
+ } else {
343
+ box.borderColor = restBorderColor;
344
+ box.css.borderBottom = box.borderBottomStyle;
345
+ }
346
+ if (isMotionOn()) return;
347
+ const innerLine = box.focusBorderWidth - 1; // (the edge is 1 px of it)
348
+ box.boxShadow = (isFocused && innerLine > 0) ? "inset 0 0 0 " + innerLine + "px " + box.focusBorderColor : "";
349
+ };
350
+
351
+ // The clear icon is shown while there is a text (and the box has room for it)
352
+ const refreshClearIcon = function() {
353
+ setClearIconVisible(isClearIconUsed() && box.txtSearch.text.length > 0);
354
+ };
355
+
356
+ // The text goes (the clear icon, or Escape: clearOnEscape); the page gets an empty search.
357
+ const clearText = function() {
358
+ setClearIconVisible(0);
359
+ box.txtSearch.text = "";
360
+ box.value = "";
361
+ refreshTextFade();
362
+ box.onChange(box);
363
+ box.onEnter(box);
364
+ };
365
+
366
+ // clearOnEscape: Escape clears a text. In an empty field the key goes on to the page (a Dialog closes).
367
+ const onEscapeKey = function(self, event) {
368
+ if (event.key !== "Escape" || event.isComposing) return;
369
+ if (box.clearOnEscape != 1 || box.txtSearch.text === "") return;
370
+ // WHY: the first Escape is for the text: a Dialog or a SidePanel around the field must not close with it
371
+ // (they leave a used key: defaultPrevented)
372
+ event.preventDefault();
373
+ event.stopPropagation();
374
+ clearText();
375
+ };
376
+
377
+ // *** Public functions:
378
+ box.publicFunc = () => {};
379
+
380
+ // silent: 1 -> onChange is not called.
381
+ box.setValue = function(value, silent = 0) {
382
+ const text = (value === null || value === undefined) ? "" : String(value);
383
+ if (text === box.txtSearch.text) return;
384
+ box.txtSearch.text = text;
385
+ box.value = text;
386
+ refreshClearIcon();
387
+ refreshTextFade();
388
+ if (!silent) box.onChange(box);
389
+ };
390
+ // USAGE: get: search.value, set: search.setValue("shoes") / search.setValue("", 1) // silent
391
+
392
+ box.getValue = function() {
393
+ return box.txtSearch.text;
394
+ };
395
+
396
+ // The text to search with: the text in lower case
397
+ box.getSearchText = function() {
398
+ return box.txtSearch.text.toLowerCase();
399
+ };
400
+ // USAGE: list.search(searchInput.getSearchText())
401
+
402
+ box.setPlaceholder = function(text) {
403
+ box.placeholder = text;
404
+ box.txtSearch.inputElement.setAttribute("placeholder", text);
405
+ }
406
+
407
+ box.focus = function() {
408
+ box.txtSearch.inputElement.focus();
409
+ }
410
+
411
+ box.setAnimated = function(value) {
412
+ box.animated = (value == 1) ? 1 : 0;
413
+ applyAnimated();
414
+ }
415
+
416
+ // The right end of the box for an object of the page: the clear icon and the end of the text move left.
417
+ box.setClearIconRight = function(right) {
418
+ box.clearIconRight = right;
419
+ box.imgClearIcon.right = right;
420
+ refreshLayout(box);
421
+ }
422
+ // USAGE: searchInput.setClearIconRight(60)
423
+
424
+ // *** OBJECT TEMPLATE:
425
+ box.css.borderBottom = box.borderBottomStyle;
426
+
427
+ // ICON: Search icon
428
+ box.imgIcon = Icon(box.searchIconLeft, 0, box.searchIconSize, box.searchIconSize, {
429
+ opacity: box.searchIconOpacity,
430
+ space: 0,
431
+ });
432
+ that.load(box.searchIconFile);
433
+ if (isIconInverted(box.invertSearchIconColor)) that.css.filter = "invert(100%)";
434
+
435
+ // INPUT: Search textbox
436
+ box.txtSearch = Input(box.searchIconLeft + box.searchIconSize + box.searchIconGap, 0, {
437
+ width: getTextWidth(),
438
+ height: box.height,
439
+ border: 0,
440
+ minimal: 1,
441
+ fontSize: box.fontSize,
442
+ textColor: box.textColor,
443
+ color: "transparent",
444
+ });
445
+ that.inputElement.style.paddingLeft = "0px";
446
+ that.inputElement.setAttribute("placeholder", box.placeholder);
447
+ // WHY: only CSS changes the color of ::placeholder. The rule is added to the page once; every input carries its color in its own variable.
448
+ if (box.placeholderColor !== "") {
449
+ SearchInput.addPlaceholderStyle();
450
+ that.inputElement.setAttribute("data-placeholder-color", "1");
451
+ that.inputElement.style.setProperty("--placeholder-color", box.placeholderColor);
452
+ }
453
+
454
+ // ICON: Clear icon button
455
+ box.imgClearIcon = Icon(5, 0, CLEAR_ICON_SIZE, CLEAR_ICON_SIZE, {
456
+ right: box.clearIconRight,
457
+ opacity: 0,
458
+ space: 0,
459
+ });
460
+ that.load(box.clearIconFile);
461
+ if (isIconInverted(box.invertClearIconColor)) that.css.filter = "invert(100%)";
462
+ that.cursor = "pointer";
463
+
464
+ placeVertically(box); // (again at every resize: refreshLayout)
465
+
466
+ // *** OBJECT INIT CODE:
467
+ // Every change of the text: typed, pasted, dropped or filled by the browser.
468
+ // WHY "input", not keyup: a text pasted with the mouse, dropped or filled by the browser was never searched
469
+ // (the list kept the old text); and the arrows, Enter, Escape, which change nothing, searched again.
470
+ box.listenTo(box.txtSearch.inputElement, "input", function() {
471
+ box.value = box.txtSearch.text;
472
+ box.onChange(box);
473
+ refreshClearIcon();
474
+ refreshTextFade();
475
+ });
476
+
477
+ // Only Enter
478
+ box.listenTo(box.txtSearch.inputElement, "keyup", function(self, event) {
479
+ if (event.key === "Enter") box.onEnter(box);
480
+ refreshTextFade(); // (the arrows, Home and End move the caret)
481
+ });
482
+ // The text scrolls in its box (typing at the end, the blur takes it back to its start), a click moves the caret.
483
+ box.listenTo(box.txtSearch.inputElement, "scroll", refreshTextFade);
484
+ box.listenTo(box.txtSearch.inputElement, "mouseup", refreshTextFade);
485
+ box.listenTo(box.txtSearch.inputElement, "keydown", onEscapeKey);
486
+ // The text at create: its clear icon and its fade come with the first refreshLayout (onResize).
487
+ box.value = (box.value === null || box.value === undefined) ? "" : String(box.value);
488
+ box.txtSearch.text = box.value;
489
+ box.onResize(refreshLayout);
490
+ box.imgClearIcon.onClick(clearText);
491
+ box.imgClearIcon.onHoverChange(function(self, isOver) {
492
+ isClearHovered = isOver;
493
+ paintMotion();
494
+ });
495
+ // WHY: After onHoverChange: on() makes an object clickable, and the hidden clear icon must not be.
496
+ box.imgClearIcon.clickable = 0;
497
+
498
+ // animated: the state of the mouse and the focus (painted only when animated is on)
499
+ box.onHoverChange(function(self, isOver) {
500
+ isHovered = isOver;
501
+ paintMotion();
502
+ });
503
+ box.listenTo(box.txtSearch.inputElement, "focus", function() {
504
+ isFocused = 1;
505
+ paintMotion();
506
+ paintFocusEdge();
507
+ refreshTextWidth();
508
+ });
509
+ // WHY: "input" and not keyup: arrows, Shift and Enter do not change the text, they must not pulse.
510
+ box.listenTo(box.txtSearch.inputElement, "input", pulseSearchIcon);
511
+ box.listenTo(box.txtSearch.inputElement, "blur", function() {
512
+ isFocused = 0;
513
+ paintMotion();
514
+ paintFocusEdge();
515
+ refreshTextWidth();
516
+ });
517
+ // A click on the field (an icon, the space around the text) starts typing. (A click on an object of the page in
518
+ // the box, Ex: the column chip of SmartTable, is its own.)
519
+ box.on("click", function(self, event) {
520
+ if (event.target === box.txtSearch.inputElement) return;
521
+ if (!isFieldPart(event.target)) return;
522
+ box.focus();
523
+ });
524
+ // WHY: setMotion waits a moment before it starts: the first view does not move.
525
+ applyAnimated();
526
+
527
+ return endObject(box);
528
+
529
+ };
530
+
531
+ // px: while not typing, a cut text goes this far under the clear icon (its width) or the object at its end, and fades
532
+ // out there.
533
+ SearchInput.TEXT_UNDER_END = 20;
534
+
535
+ // The ::placeholder rule, added to the page once. (It touches only the inputs that have a placeholderColor.)
536
+ SearchInput.addPlaceholderStyle = function() {
537
+
538
+ if (document.getElementById("searchInputPlaceholderStyle")) return;
539
+
540
+ const styleElement = document.createElement("style");
541
+ styleElement.id = "searchInputPlaceholderStyle";
542
+ styleElement.textContent = "input[data-placeholder-color]::placeholder { color: var(--placeholder-color); opacity: 1; }";
543
+ document.head.appendChild(styleElement);
544
+
545
+ };
546
+
547
+ // The icons of the light and dark looks: lines on a 24 x 24 grid, their colors in the drawing (no invert filter).
548
+ SearchInput.getLineSearchIconFile = function(color) {
549
+ return "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="' + color + '" stroke-width="2" stroke-linecap="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5L20 20"/></svg>');
550
+ };
551
+
552
+ SearchInput.getRoundClearIconFile = function(circleColor, crossColor) {
553
+ return "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="' + circleColor + '"/><path d="M9 9l6 6M15 9l-6 6" fill="none" stroke="' + crossColor + '" stroke-width="2" stroke-linecap="round"/></svg>');
554
+ };
555
+
556
+ // *** STYLE PACKAGES:
557
+ // USAGE: SearchInput({ styleName: "ozden" })
558
+ // USAGE: SearchInput({ styleName: "ozden", fontSize: 16 }) // A param you give wins over the package.
559
+ // NOTE: Every package has "style: {}": that is the mark of a package of params (basic.js v26.10.27).
560
+ // Without it the keys would go into params.style and change nothing.
561
+ // NOTE: A package needs only the params that differ from SearchInputDefaults.
562
+ SearchInput.styles = {
563
+
564
+ // The look of SearchInputDefaults (whitesmoke, a soft bottom line), the first look. SelectBox light / dark,
565
+ // SmartTable "green" and FullScreenSelect use it by this name.
566
+ original: { style: {} },
567
+
568
+ // The light look of the kit (_designs/search-input.htm): a 44 px white field with one thin line and round 10
569
+ // corners, a 15 px text, a line search icon, a soft round clear button; while typing the edge turns to the
570
+ // accent of the kit (2 px).
571
+ light: {
572
+ style: {},
573
+ searchIconFile: SearchInput.getLineSearchIconFile("#000000"),
574
+ clearIconFile: SearchInput.getRoundClearIconFile("#A3A3A0", "#FFFFFF"),
575
+ searchIconSize: 18,
576
+ searchIconLeft: 14,
577
+ clearIconRight: 12,
578
+ searchIconOpacity: 0.55,
579
+ clearIconOpacity: 1, // (its gray is in the drawing)
580
+ invertIconColor: 0,
581
+ color: "#FFFFFF",
582
+ textColor: Black(0.88),
583
+ placeholderColor: Black(0.38),
584
+ fontSize: 15,
585
+ height: 44,
586
+ textOffsetY: -1, // WHY: the small letters of Open Sans sit low in their line
587
+ searchIconOffsetY: 1, // WHY 1: the icons at the middle of the small letters of the text
588
+ clearIconOffsetY: 1,
589
+ textEndSpace: 6,
590
+ border: 1,
591
+ borderColor: Black(0.12),
592
+ borderBottomStyle: "1px solid " + Black(0.12),
593
+ focusBorderColor: "#3D7A6B", // the accent of the kit
594
+ round: 10,
595
+ animated: 0, // 1: small hover / focus motions
596
+ hoverRingColor: Black(0.08),
597
+ focusRingColor: "rgba(61, 122, 107, 0.5)",
598
+ },
599
+
600
+ // The dark look of the kit: the same field on the dark surface (#232322, on a #1A1A19 page), light text and icons.
601
+ dark: {
602
+ style: {},
603
+ searchIconFile: SearchInput.getLineSearchIconFile("#FFFFFF"),
604
+ clearIconFile: SearchInput.getRoundClearIconFile("#7A7A78", "#141414"),
605
+ searchIconSize: 18,
606
+ searchIconLeft: 14,
607
+ clearIconRight: 12,
608
+ searchIconOpacity: 0.55,
609
+ clearIconOpacity: 1, // (its gray is in the drawing)
610
+ invertIconColor: 0,
611
+ color: "#232322",
612
+ textColor: White(0.9),
613
+ placeholderColor: White(0.38),
614
+ fontSize: 15,
615
+ height: 44,
616
+ textOffsetY: -1, // WHY: the small letters of Open Sans sit low in their line
617
+ searchIconOffsetY: 1, // WHY 1: the icons at the middle of the small letters of the text
618
+ clearIconOffsetY: 1,
619
+ textEndSpace: 6,
620
+ border: 1,
621
+ borderColor: White(0.12),
622
+ borderBottomStyle: "1px solid " + White(0.12),
623
+ focusBorderColor: "#65A293", // the accent of the kit on a dark page
624
+ round: 10,
625
+ animated: 0, // 1: small hover / focus motions
626
+ hoverRingColor: White(0.08),
627
+ focusRingColor: "rgba(101, 162, 147, 0.55)",
628
+ },
629
+
630
+ // Bugra's style: a round field with a thin line, a soft search icon and a white round clear button. (Change, add or remove any look param.)
631
+ ozden: {
632
+ style: {},
633
+ searchIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.707 22.293l-5.969-5.969a10.016 10.016 0 10-1.414 1.414l5.969 5.969a1 1 0 001.414-1.414zM10 18a8 8 0 118-8 8.009 8.009 0 01-8 8z"/></svg>'),
634
+ clearIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="11" fill="#FFFFFF" stroke="rgba(0,0,0,0.12)" stroke-width="1"/><path d="M8 8l8 8M16 8l-8 8" fill="none" stroke="#333333" stroke-width="2" stroke-linecap="round"/></svg>'),
635
+ searchIconSize: 24,
636
+ searchIconOpacity: 0.4,
637
+ clearIconOpacity: 0.6, // WHY: at 0.6 the white circle faded into the field.
638
+ invertIconColor: 0,
639
+ invertSearchIconColor: null, // null: invertIconColor
640
+ invertClearIconColor: null, // null: invertIconColor
641
+ color: "whitesmoke",
642
+ textColor: "rgba(0, 0, 0, 0.8)",
643
+ placeholderColor: "",
644
+ fontSize: 20,
645
+ height: 44, // (the default is 50) as the search box of ItemList and SelectBox ozden
646
+ textOffsetY: -2, // WHY: center() does not count the 3 px bottom line, and the small letters of Open Sans sit low
647
+ clearIconOffsetY: -1, // WHY: the middle of the face of the box (center() does not count the 3 px bottom line)
648
+ border: 1,
649
+ borderColor: "rgba(0, 0, 0, 0.1)",
650
+ borderBottomStyle: "3px solid rgba(0, 0, 0, 0.06)",
651
+ round: 50,
652
+ animated: 0, // 1: small hover / focus motions
653
+ hoverRingColor: "rgba(0, 0, 0, 0.08)", // Alpha("#141414", 0.2), //
654
+ focusRingColor: "rgba(0, 0, 0, 0.16)", // Alpha("#23BCC1", 0.6), //
655
+ },
656
+
657
+ // The dark theme of ozden: the same shape on a dark field, light text and icons.
658
+ // WHY: invertIconColor also inverts clear-round.svg, so the clear button is a dark circle with a light cross.
659
+ ozdenDark: {
660
+ style: {},
661
+ searchIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.707 22.293l-5.969-5.969a10.016 10.016 0 10-1.414 1.414l5.969 5.969a1 1 0 001.414-1.414zM10 18a8 8 0 118-8 8.009 8.009 0 01-8 8z"/></svg>'),
662
+ clearIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="11" fill="#FFFFFF" stroke="rgba(0,0,0,0.12)" stroke-width="1"/><path d="M8 8l8 8M16 8l-8 8" fill="none" stroke="#333333" stroke-width="2" stroke-linecap="round"/></svg>'),
663
+ searchIconSize: 24,
664
+ searchIconOpacity: 0.4,
665
+ clearIconOpacity: 0.4,
666
+ invertIconColor: null,
667
+ invertSearchIconColor: 1, // null: invertIconColor
668
+ invertClearIconColor: 1, // null: invertIconColor
669
+ color: "#2B2D31",
670
+ textColor: "rgba(255, 255, 255, 0.88)",
671
+ placeholderColor: "rgba(255, 255, 255, 0.35)",
672
+ fontSize: 20,
673
+ height: 44, // (the default is 50) as the search box of ItemList and SelectBox ozden
674
+ textOffsetY: -2, // WHY: center() does not count the 3 px bottom line, and the small letters of Open Sans sit low
675
+ clearIconOffsetY: -1, // WHY: the middle of the face of the box (center() does not count the 3 px bottom line)
676
+ border: 1,
677
+ borderColor: "rgba(255, 255, 255, 0.1)",
678
+ borderBottomStyle: "3px solid rgba(255, 255, 255, 0.06)",
679
+ round: 50,
680
+ animated: 0, // 1: small hover / focus motions
681
+ hoverRingColor: "rgba(255, 255, 255, 0.08)", // Alpha("#FFFFFF", 0.2), //
682
+ focusRingColor: "rgba(255, 255, 255, 0.18)", // Alpha("#23BCC1", 0.6), //
683
+ },
684
+
685
+ };
686
+ SearchInput.styles.classic = SearchInput.styles.light; // the old name of light
687
+
688
+ // The minimal theme (_designs/minimal-theme.htm): 28 px, a 13 px text, no fill, a thin line with round ends that turns
689
+ // ink while typing, a line search icon and a line cross. minimalDark: the same in white on a dark window.
690
+ SearchInput.createMinimalStyle = function (colors) {
691
+ const lineIcon = function (paths) {
692
+ const svgStart = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">';
693
+ return "data:image/svg+xml;utf8," + encodeURIComponent(svgStart + paths + "</svg>");
694
+ };
695
+ return {
696
+ style: {},
697
+ height: 28,
698
+ searchIconFile: lineIcon('<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>'),
699
+ clearIconFile: lineIcon('<path d="M9 9l6 6M15 9l-6 6"/>'), // WHY small: the icon box is 20 px, the cross as big as the search icon
700
+ searchIconSize: 14,
701
+ searchIconLeft: 10,
702
+ searchIconGap: 6,
703
+ clearIconRight: 8,
704
+ searchIconOpacity: 0.55,
705
+ clearIconOpacity: 0.55,
706
+ invertIconColor: colors.invertIcons,
707
+ color: "transparent",
708
+ textColor: colors.text,
709
+ placeholderColor: colors.placeholder,
710
+ fontSize: 13,
711
+ textOffsetY: 0, // WHY 0: at 13 px the band of the capitals and the line of the text sit in the middle (-1 read high)
712
+ clearIconOffsetY: 0,
713
+ border: 1,
714
+ borderColor: colors.edge, // WHY edge: the line that shows the field (3:1 at least)
715
+ borderBottomStyle: "1px solid " + colors.edge,
716
+ focusBorderColor: colors.ink,
717
+ focusBorderWidth: 1, // as the other minimal fields
718
+ round: 14,
719
+ animated: 0,
720
+ };
721
+ };
722
+ SearchInput.MINIMAL_COLORS = { invertIcons: 0, text: Black(0.85), placeholder: Black(0.54), edge: Black(0.45), ink: "#1F1F1F" };
723
+ SearchInput.styles.minimal = SearchInput.createMinimalStyle(SearchInput.MINIMAL_COLORS);
724
+ SearchInput.MINIMAL_DARK_COLORS = { invertIcons: 1, text: White(0.88), placeholder: White(0.48), edge: White(0.42), ink: "#EDEDEB" };
725
+ SearchInput.styles.minimalDark = SearchInput.createMinimalStyle(SearchInput.MINIMAL_DARK_COLORS);