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,1883 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ SmartTable - v26.11 - "Optimized for big data"
6
+
7
+ WHEN TO USE IT: to show very big data well, in both directions: very many rows (only the rows
8
+ that are seen are made) and very many columns (it scrolls sideways). A table that looks better for data that is not so
9
+ big: comp/data-table.js (DataTable). A few rows inside a text: comp/tiny-table.js (TinyTable).
10
+
11
+ STYLE PACKAGES: "light" (default; the old name "classic" works too) and "dark" are the looks of DataTable (comp/data-table.js);
12
+ "minimal" / "minimalDark": the minimal theme (_designs/minimal-theme.htm);
13
+ new pages use "light" on a light page and "dark" on a dark page. "green" is the look of SmartTable before them (the
14
+ green title line, the dark edge). A package is a package of params: it also gives searchInputParams (the filter box is
15
+ a SearchInput package: "ozden" / "ozdenDark"), scrollBarParams and searchTitleMenuParams. (SmartTable.styles)
16
+ Sample: 02-comp-examples/smart-table.htm (the model page of SmartTable).
17
+ - SmartTable({ styleName: "dark" }), SmartTable({ styleName: "dark", style: { lblItemCell: { fontSize: 14 } } })
18
+ - A page with its own colors over the green look names it: SmartTable({ styleName: "green", style: {...} }) (the keys it
19
+ does not give come from that package, not from classic).
20
+ - A cut text: a cell whose text does not fit (its end is "...") shows all of it in a bubble over
21
+ the cell when the mouse rests on it (style.cellTooltip: the look; showCellTooltip: 0 turns it off). The bubble is
22
+ comp/tooltip.js (Tooltip.show); without that file the browser's own hint (the title of the cell) shows the text.
23
+
24
+ - SmartTable is a JavaScript table component designed to run smoothly even with millions of records. Thanks to its virtual scroll architecture, it only writes the visible rows to the DOM, eliminating memory and performance issues with large datasets. It makes data exploration easy with real-time filtering, multi-column sorting, and both horizontal and vertical scroll support. Custom cell designs can be created for each column via createCellView / updateCellView, allowing flexible visual content per column. Since column widths, heights, and colors are all configurable through parameters, it can be quickly adapted to different projects.
25
+
26
+
27
+ Started Date: March 2026
28
+ Webpage: https://bug7a.github.io/js-components/
29
+
30
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
31
+ Licensed under the Apache License, Version 2.0
32
+ SPDX-License-Identifier: Apache-2.0
33
+
34
+
35
+ - The search column: a press on the label at the right end of the search box (ALL) opens the list of the columns. The search looks only in the chosen column.
36
+ -- The chip is in the filter box at its right end; the clear icon shows at its left while
37
+ there is a text, and a narrow box shows no clear icon (searchInputParams.clearIconMinTextWidth: 80 px of text).
38
+ A narrow table gives the filter box the room up to the count (up to 240 px). Escape clears the filter
39
+ (searchInputParams.clearOnEscape: 1); in an empty filter it goes on to the page (a Dialog around closes).
40
+ -- searchTitleIndex: -1 (ALL: every column); showSearchTitleSelect: 0 hides the label.
41
+ -- The list needs comp/context-menu.js. Without it, every press on the label goes to the next column.
42
+ - fitLineCount: 1: the rows are about itemHeight px high and their count follows the height of the table
43
+ (style.height "100%" in a window that grows or shrinks). 0 (default): itemLineCount rows share the height of the table.
44
+ setItemLineCount(count) makes another count of rows.
45
+ - The keys (canSelect: 1 by default): a click selects a row and gives the table the focus. The selected
46
+ row: style.selectedItemCellColor (null: the color of the row under the mouse) and the line style.selectedBar at its
47
+ left. Then ↑ ↓ move one row, Page Up / Page Down one page, Home / End to the first / the last record, Enter runs
48
+ onSelect like a click. The selected row stays seen after a sort or a filter. The edge of the table shows the focus
49
+ of the keyboard (style.focusRingColor). selectItem(itemData), clearSelection(), getSelectedIndex(),
50
+ box.selectedItemData. canSelect: 0: no selection and no keys (a click only runs onSelect).
51
+ - locale: the language of the numbers of the info line. "": the language of the page (<html lang>); a page
52
+ with no language keeps "tr-TR". Ex: "en-US" -> 12,499, "tr-TR" -> 12.499. setLocale(locale).
53
+ - wheelScroll: 1: the mouse wheel scrolls the rows of the table (the page does not move). The default 0: the wheel scrolls the page; the rows move with the scroll bar and its buttons.
54
+ -- smartTable.setWheelScroll(1) turns it on later.
55
+ - The scroll buttons stand right of the table, outside its box (22 px: getVerticalScrollWidth()). The table keeps that
56
+ room: a width in percent is that much narrower, another width has a margin at its right, so in a group the next
57
+ object stands after the buttons. A table with a place of its own (left, top): leave the room yourself.
58
+ - allowHtml: 0 (default): the values of the cells are written as plain text (a name or a title a user wrote does not
59
+ run as HTML). 1: the values are written as HTML (Ex: "<b>12</b>"). Your own values written with cell.label.text in
60
+ createCellView / updateCellView are not touched.
61
+
62
+
63
+ */
64
+
65
+ "use strict";
66
+
67
+ // Default values:
68
+ const SmartTableDefaults = {
69
+
70
+ key: "0",
71
+ titleHeight: 50,
72
+ itemHeight: 40,
73
+ infoHeight: 50,
74
+ itemLineCount: 16,
75
+ highlightTitle: true,
76
+ highlightLine: true,
77
+ invertColor: 0,
78
+ noDataFoundAlert: "No data found!",
79
+ searchKeyword: "",
80
+ searchTitleIndex: -1, // -1: Search in all columns (ALL). 0, 1...: Search only in this column.
81
+ showSearchTitleSelect: 1, // 0: Hide the column select box (ALL) next to the search input.
82
+ wheelScroll: 0, // 1: The mouse wheel scrolls the rows (and the page does not scroll). 0: The wheel is left to the page.
83
+ allowHtml: 0, // 1: The cell values, the titles of the columns and the texts are written as HTML. 0: As plain text (safe for the text of the users)
84
+ showCellTooltip: 1, // 1: a cell whose text does not fit shows all of it in a bubble (comp/tooltip.js). 0: no bubble
85
+ allTitlesText: "ALL",
86
+ canSelect: 1, // 1: a click or a key selects a row; Enter runs onSelect. 0: no selection, no keys
87
+ fitLineCount: 0, // 1: rows of about itemHeight px, as many as the height of the table holds
88
+ locale: "", // the numbers of the info line ("": the language of the page). Ex: "en-US", "tr-TR"
89
+ sortByTitleIndex: 0,
90
+ sortDirection: "A-Z", // "A-Z" or "Z-A"
91
+ fillTestData: 0,
92
+ onSelect: function (self, itemData) { },
93
+ createCellView: null, // function (cell, titleDataIndex, self) { } Once for every cell (a cell shows other rows as the table scrolls): objects created here go into the cell; cell.label is its text
94
+ updateCellView: null, // function (cell, titleDataIndex, value, self) { } Every time a cell shows a value: paint what createCellView made
95
+ titleDataList: [
96
+ { name: "ID", dataTitle: "id", dataType: "integer", width: 100, sortable: 1 },
97
+ { name: "NAME", dataTitle: "name", dataType: "string", width: 100, sortable: 1 },
98
+ { name: "EMAIL", dataTitle: "email", dataType: "string", width: 290, sortable: 0 },
99
+ { name: "", dataTitle: "active", dataType: "boolean", width: 40, sortable: 0 },
100
+ ],
101
+ itemDataList: [
102
+ { id: 1, name: "Bugra", desc: "about", email: "emainil", active: 1 },
103
+ { id: 2, name: "Alper", desc: "about", email: "emainil", active: 1 },
104
+ { id: 3, name: "Murat", desc: "about", email: "emainil-3", active: 1 },
105
+ { id: 4, name: "Deniz", desc: "about", email: "emainil", active: 1 },
106
+ { id: 5, name: "Nilüfer", desc: "about", email: "emainil-7", active: 1 },
107
+ { id: 6, name: "Frank", desc: "about", email: "emainil", active: 1 },
108
+ { id: 7, name: "Dany", desc: "about", email: "emainil-45", active: 1 },
109
+ { id: 8, name: "Duygu", desc: "about", email: "emainil", active: 1 },
110
+ { id: 9, name: "Filiz", desc: "about", email: "emainil-356", active: 1 },
111
+ { id: 10, name: "Anka", desc: "about", email: "emainil", active: 1 },
112
+ ],
113
+ scrollBarParams: {
114
+ bar_border: 0,
115
+ bar_round: 3,
116
+ bar_borderColor: "rgba(0, 0, 0, 1)",
117
+ bar_width: 4,
118
+ bar_mouseOverWidth: 4, //8
119
+ bar_mouseOverColor: "#373836",
120
+ bar_opacity: 0.4,
121
+ bar_mouseOverOpacity: 0.9,
122
+ bar_padding: 2,
123
+ bar_color: "#373836",
124
+ neverHide: 0,
125
+ showDots: 0,
126
+ },
127
+ // The params of the list of the columns in the filter (ContextMenu): only its look, the component gives its onClick.
128
+ searchTitleMenuParams: {},
129
+ // The filter box (a SearchInput): its colors and edges come from the SearchInput package of styleName.
130
+ searchInputParams: {
131
+ styleName: "ozden", // a SearchInput package: "ozden" (a light page), "ozdenDark"
132
+ width: "50%",
133
+ height: 36,
134
+ fontSize: 15,
135
+ searchIconSize: 16,
136
+ searchIconOpacity: 0.5,
137
+ placeholder: "Filter",
138
+ searchIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" preserveAspectRatio="none" fill="#000000"><rect x="0" y="85" width="512" height="57"/><rect x="85" y="227" width="342" height="56"/><rect x="199" y="370" width="114" height="57"/></svg>'), // three bars
139
+ clearIconMinTextWidth: 80, // (a narrow filter box has no clear icon; its text keeps that place)
140
+ clearOnEscape: 1, // Escape clears the filter (a narrow box has no clear icon)
141
+ },
142
+ styleName: "light", // "light" ("classic": its old name), "dark", "green", "minimal", "minimalDark" or a name added to SmartTable.styles
143
+ style: { // Light style package (default): the look of DataTable "light"
144
+
145
+ width: "auto",
146
+ height: "auto",
147
+ round: 6,
148
+ line1Color: "white",
149
+ line2Color: "#F7F7F7",
150
+ // WHY solid colors: the cells are painted over the stripes of the rows; DataTable's soft yellow
151
+ // (rgba(254, 193, 8, 0.08) / 0.18) is mixed with white here, so a row looks the same on every stripe.
152
+ highlightItemCellColor: "#FFFAEB",
153
+ selectedItemCellColor: "#FFF4D3", // null: highlightItemCellColor (the row under the mouse)
154
+ selectedBar: { width: 0, color: "rgba(95, 158, 160, 0.9)" }, // the line at the left of the selected row (width 0: none)
155
+ focusRingColor: "rgba(95, 158, 160, 0.6)", // the edge of the table when the keys move its rows
156
+ highlightTitleCellColor: "white",
157
+ titleUppercase: 1, // 1: the titles in capital letters (0: as titleDataList writes them)
158
+ verticalScrollWidth: 20,
159
+ verticalScrollMargin: 2,
160
+ btnScrollDownIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 200" preserveAspectRatio="none" fill="none" stroke="#141414" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"><path d="M40 84V116M27 103L40 116L53 103"/></svg>'),
161
+ btnScrollUpIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 200" preserveAspectRatio="none" fill="none" stroke="#141414" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"><path d="M40 116V84M27 97L40 84L53 97"/></svg>'),
162
+ btnScrollCenterIconFile: "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 50" fill="none" stroke="#000000" stroke-opacity="0.4" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M10 17.5v15M6.5 21 10 17.5 13.5 21M6.5 29 10 32.5 13.5 29"/></svg>'),
163
+ sortIconFile: "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.71,9.88l-4.3-4.29a2,2,0,0,0-2.82,0L6.29,9.88a1,1,0,0,0,0,1.41,1,1,0,0,0,1.42,0L11,8V19a1,1,0,0,0,2,0V8l3.29,3.29a1,1,0,1,0,1.42-1.41Z"/></svg>'),
164
+ loadingIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" preserveAspectRatio="none"><circle cx="256" cy="256" r="206" fill="#FFFFFF" stroke="#141414" stroke-width="20"/><path d="M256 113V256H358" fill="none" stroke="#141414" stroke-width="20" stroke-linecap="round" stroke-linejoin="round"/></svg>'),
165
+ searchTitleCheckIconFile: "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#373836" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5 10 17.5 19 7"/></svg>'),
166
+ invertIconColor: 0, // 1: the sort and the scroll arrows are drawn light (a dark page)
167
+ sortIcon: { size: 16, opacity: 0.25, activeOpacity: 1 }, // the arrow of a title: not sorted / sorted
168
+ // The bubble of a cut text: the keys of Tooltip.BUBBLE_LOOK (comp/tooltip.js) and maxWidth (px: a longer
169
+ // text goes on more lines)
170
+ cellTooltip: { fontSize: 14, color: "white", textColor: Black(0.8), round: 6, border: 1, borderColor: Black(0.15), shadow: "0 6px 16px " + Black(0.12), arrow: 10, padding: [12, 8], maxWidth: 360 },
171
+
172
+ box: { color: "white" },
173
+ boxBorder: { border: 1, borderColor: Black(0.15) },
174
+ boxTitleLine: { color: "whitesmoke" },
175
+ boxTitleCell: { padding: [10, 0], borderRight: "1px solid " + Black(0.08), borderBottom: "1px solid " + Black(0.2) },
176
+ lblTitleCell: { fontSize: 15, fontFamily: "opensans-bold", textColor: Black(0.8) },
177
+ boxItemCell: { borderBottom: "1px solid " + Black(0.08), borderRight: "none", padding: [10, 0] },
178
+ lblItemCell: { fontSize: 15, textColor: Black(0.7), fontFamily: "opensans" },
179
+ boxInfoLine: { color: "white", borderTop: "1px solid " + Black(0.2) },
180
+ lblBoxInfoLine: { fontSize: 14, textColor: Black(0.5) },
181
+ lblNoDataFound: { color: "transparent", textColor: Black(0.45), padding: [8, 2], fontSize: 15, round: 8, border: 0, borderColor: "transparent" },
182
+ // The label that chooses the column in the filter box (ALL), over the style of lblNoDataFound.
183
+ lblSearchTitle: { color: "white", textColor: Black(0.6), padding: [8, 2], fontSize: 12, round: 50, border: 1, borderColor: Black(0.12) },
184
+ btnScrollCenter: { color: "white", round: 100, border: 1, borderColor: Black(0.2) },
185
+ btnScrollUp: { color: "whitesmoke", round: 100, border: 1, borderColor: Black(0.15) },
186
+ btnScrollDown: { color: "whitesmoke", round: 100, border: 1, borderColor: Black(0.15) },
187
+ boxSort: { color: "transparent" },
188
+
189
+ },
190
+ };
191
+
192
+ const SmartTable = function (params = {}) {
193
+
194
+ // Merge style package: params.style > SmartTable.styles[styleName] (a package of params) > SmartTableDefaults (light)
195
+ basic.applyStylePackage(params, SmartTable.styles, SmartTableDefaults);
196
+
197
+ // Merge params:
198
+ mergeIntoIfMissing(params, SmartTableDefaults);
199
+
200
+ // BOX: Component container
201
+ let box = startObject(params);
202
+
203
+ // WHY: mergeIntoIfMissing copies an array by reference. Without a copy, setTitleCellWidth would change SmartTableDefaults (and the other tables).
204
+ box.titleDataList = box.titleDataList.map(titleData => ({ ...titleData }));
205
+ box.itemDataList = [...box.itemDataList];
206
+
207
+ // *** PRIVATE VARIABLES:
208
+ const DEFAULT_CELL_WIDTH = 100;
209
+ const SCROLL_CENTER_HEIGHT = 50;
210
+ const CELL_TOOLTIP_DELAY = 300; // ms: the mouse rests on a cell before its bubble shows (no bubbles while it moves)
211
+ const LOADING_ICON_SIZE = 32;
212
+ const SEARCH_TITLE_MAX_WIDTH = "160px";
213
+ const SEARCH_TITLE_RIGHT = 6; // px: the chip (ALL) from the right side of the filter box
214
+ const SEARCH_TITLE_GAP = 6; // px: between the clear icon of the filter box and the chip
215
+ const SEARCH_MIN_WIDTH = 240; // px: a narrow table gives the filter box more than its share of the line, up to this
216
+ const TOOLBAR_PADDING = 8; // px: the filter box from the left side of the info line
217
+ const TOOLBAR_GAP = 12; // px: between the filter box and the count
218
+ const COUNT_RIGHT = 14; // px: the count from the right side of the info line
219
+ const FILTER_DELAY = 50; // ms
220
+ const RESIZE_DELAY = 3; // ms
221
+ const LOADING_MIN_ITEM_COUNT = 1000; // WHY: a short list must not flash the loading for a moment.
222
+ const TEST_DATA_REPEAT_COUNT = 100000;
223
+ const DEFAULT_LOCALE = "tr-TR"; // WHY: the numbers were always Turkish before; a page with no language keeps them
224
+ const targetItemHeight = box.itemHeight; // fitLineCount: the height of a row, before the rows share the height
225
+ let searchClearIconRight = 0; // the place of the clear icon of the filter box with no chip (its own)
226
+ let hoveredCell = null; // the cell under the mouse (the bubble of a cut text: showCellTooltip)
227
+ let cellTooltip = null; // the bubble of a cut text (Tooltip.show), null: none
228
+ let cancelCellTooltipTimer = null;
229
+
230
+ // *** PRIVATE FUNCTIONS:
231
+
232
+ const setText = function (label, text) {
233
+ const value = (text === undefined || text === null) ? "" : String(text);
234
+ if (box.allowHtml == 1) label.text = value;
235
+ else label.plainText = value;
236
+ };
237
+
238
+ // The last top index: the last page of rows ends with the last record.
239
+ const getMaxScrollIndex = function () {
240
+ return Math.max(0, box.visibleItemDataList.length - box.itemLineCount);
241
+ };
242
+
243
+ const clampScrollIndex = function (index) {
244
+ if (index < 0) return 0;
245
+ return Math.min(index, getMaxScrollIndex());
246
+ };
247
+
248
+ // WHY: isNaN("") is false, so an empty value was taken as a number, and parseFloat("") gave NaN and broke the sorting.
249
+ const toSortNumber = function (value) {
250
+ if (typeof value === "number") return value;
251
+ if (typeof value === "string" && value.trim() !== "") return Number(value);
252
+ return NaN;
253
+ };
254
+
255
+ // *** PUBLIC VARIABLES:
256
+ // State of component [var]
257
+ box.state = "normal";
258
+ // Created items by data [var]
259
+ box.visibleItemDataList = [...box.itemDataList];
260
+ // The SearchInput of the filter, made in createToolbar [var]. USAGE: table.searchInput.setValue("") (a new list)
261
+ box.searchInput = null;
262
+ // The selected record (canSelect: 1), null: none [var]. USAGE: table.selectItem(data), table.getSelectedIndex()
263
+ box.selectedItemData = null;
264
+ // [var]
265
+ box.titleCellList = [];
266
+ // [var]
267
+ box.titleCellCount = 0;
268
+ // [var]
269
+ box.itemLineList = [];
270
+ // [var] the index of the record at the top
271
+ box.startedItemIndexForScrolling = 0;
272
+ // The variables of the scroll [var]
273
+ box.scrollVars = {};
274
+ // [var] if height not auto will recallItemHeight
275
+ box.recalcItemHeight = 0;
276
+ // [var]
277
+ box.resizeTimer = null;
278
+ box.refreshTimer = null;
279
+ box.filterTimer = null;
280
+
281
+ // *** PUBLIC FUNCTIONS:
282
+
283
+ // The states have no look yet; the value is kept for the page.
284
+ box.setState = function (state) {
285
+ box.state = state;
286
+ };
287
+
288
+ const refresh = function () {
289
+ // refresh code
290
+ };
291
+
292
+ box.refresh = function (time = 3) {
293
+
294
+ // NOTE: Check the child objects and make sure their states are appropriate.
295
+ box.refreshTimer = waitAndRun(box.refreshTimer, refresh, time);
296
+
297
+ };
298
+
299
+ // WHY: box.superRemove is overwritten by a component that extends this one, so the local copy is called below.
300
+ const superRemove = box.remove;
301
+ box.superRemove = superRemove;
302
+ box.remove = function () {
303
+
304
+ if (!box) return; // WHY: remove() can be called twice (also by the parent's remove()).
305
+
306
+ // WHY: waitAndRun timers are not box.after() timers; remove() does not know them.
307
+ clearTimeout(box.resizeTimer);
308
+ clearTimeout(box.refreshTimer);
309
+ clearTimeout(box.filterTimer);
310
+
311
+ // WHY: the menu is made on the page: box.remove() does not remove it. (Before the cascade: it detaches from its target label.)
312
+ if (box.searchTitleMenu) box.searchTitleMenu.remove();
313
+ closeCellTooltip(); // WHY: the bubble is on the page too
314
+
315
+ superRemove.call(box); // NOTE: basic.js remove(). It cleans all the events (listenTo too) and the objects inside.
316
+ box = null;
317
+
318
+ };
319
+
320
+ // A row without data stays in its place, empty and not clickable.
321
+ const hideItemLine = function (itemLine) {
322
+ itemLine.opacity = 0;
323
+ itemLine.clickable = 0;
324
+ itemLine.cursor = ""; // (its cells take the cursor of the row: no hand over the empty part of the table)
325
+ itemLine.itemData = null;
326
+ paintItemLine(itemLine);
327
+ };
328
+
329
+ const fillItemLine = function (itemLine, rowData) {
330
+
331
+ itemLine.opacity = 1;
332
+ itemLine.clickable = 1;
333
+ itemLine.cursor = "pointer";
334
+ itemLine.itemData = rowData; // WHY: a press on the row uses it
335
+ paintItemLine(itemLine);
336
+
337
+ for (let j = 0; j < box.titleCellCount; j++) {
338
+
339
+ const titleData = box.titleDataList[j];
340
+ const cell = itemLine["itemCell" + j];
341
+ const newValue = rowData[titleData.dataTitle] ?? "";
342
+
343
+ // The DOM is touched only when the value changed
344
+ // WHY: label.text gives the innerHTML (a string): a number or a value with "&" was always different. The cell keeps the last value it wrote.
345
+ if (!("lastValue" in cell) || cell.lastValue !== newValue) { // WHY: without !==, 0 and "" were the same.
346
+ cell.lastValue = newValue;
347
+ // WHY plainText: a value from a user (a name, a title) ran as HTML in the cell
348
+ setText(cell.label, newValue);
349
+ }
350
+
351
+ if (box.updateCellView) box.updateCellView(cell, j, newValue, box);
352
+
353
+ }
354
+
355
+ };
356
+
357
+ box.refreshData = function () {
358
+
359
+ const startIndex = box.startedItemIndexForScrolling;
360
+ const dataList = box.visibleItemDataList;
361
+ const lineCount = box.itemLineCount;
362
+
363
+ // WHY: Virtual scroll; only the rows on the screen exist, they show the records from startIndex.
364
+ for (let i = 0; i < lineCount; i++) {
365
+
366
+ const itemLine = box.itemLineList[i];
367
+ const rowData = dataList[startIndex + i];
368
+
369
+ if (rowData) {
370
+ fillItemLine(itemLine, rowData);
371
+ } else {
372
+ hideItemLine(itemLine);
373
+ }
374
+
375
+ }
376
+
377
+ box.setVerticalScrollEnabled(dataList.length > lineCount);
378
+ box.updateInfoLabel();
379
+ refreshCellTooltip();
380
+
381
+ };
382
+
383
+ const setScrollButtonState = function (button, opacity, clickable) {
384
+ button.opacity = opacity;
385
+ button.clickable = clickable;
386
+ };
387
+
388
+ box.setVerticalScrollEnabled = function (enabled) {
389
+
390
+ // It is enabled only when it can be used.
391
+ if (enabled && box.visibleItemDataList.length > box.itemLineCount) {
392
+ setScrollButtonState(box.btnScrollCenter, 1, 1);
393
+ setScrollButtonState(box.btnScrollUp, 1, 1);
394
+ setScrollButtonState(box.btnScrollDown, 1, 1);
395
+ return;
396
+ }
397
+
398
+ setScrollButtonState(box.btnScrollCenter, 0, 0);
399
+ setScrollButtonState(box.btnScrollUp, 0.5, 0);
400
+ setScrollButtonState(box.btnScrollDown, 0.5, 0);
401
+
402
+ }
403
+
404
+ box.setTitleCellWidth = function (titleCellIndex, width) { // [GOOD]
405
+
406
+ if (titleCellIndex < 0 || titleCellIndex >= box.titleCellCount) return;
407
+
408
+ box.titleCellList[titleCellIndex].width = width;
409
+ box.titleDataList[titleCellIndex].width = width;
410
+
411
+ box.itemLineList.forEach(function (itemLine) {
412
+ itemLine["itemCell" + titleCellIndex].width = width;
413
+ });
414
+
415
+ }
416
+
417
+ // The row of the titles
418
+ box.createTitleLine = function () { // [GOOD]
419
+
420
+ box.titleCellList = [];
421
+ box.boxTitleLine.html = "";
422
+
423
+ // titleDataList
424
+ box.titleDataList.forEach(function (titleData, titleCellIndex) {
425
+ const titleCell = box.createTitleCell(titleData, titleCellIndex);
426
+
427
+ box.titleCellList.push(titleCell);
428
+ box.boxTitleLine.add(titleCell);
429
+ });
430
+
431
+ box.titleCellCount = box.titleCellList.length;
432
+
433
+ };
434
+
435
+ box.setTitleDataList = function(titleDataList) {
436
+
437
+ box.titleDataList = titleDataList.map(titleData => ({ ...titleData }));
438
+ box.createTitleLine();
439
+ // WHY: a row has as many cells as there are titles, or refreshData reaches a cell that is not there.
440
+ box.createItemLines();
441
+ if (box.recalcItemHeight) box.setItemHeight(box.itemHeight);
442
+ box.stretchLastCell(box.calcLastCellWidth());
443
+ if (!box.titleDataList[box.sortByTitleIndex]) box.sortByTitleIndex = 0;
444
+ box.updateSortIcon();
445
+ box.updateSearchTitleSelect(); // WHY: the columns changed: the list is made again, and a chosen column that is gone becomes ALL.
446
+ box.filterAndSortData();
447
+
448
+ }
449
+
450
+ box.createSortIcon = function (titleCell) {
451
+
452
+ const iconSize = box.style.sortIcon.size;
453
+
454
+ startBox({
455
+ align: "right center",
456
+ color: box.style.boxSort.color,
457
+ round: 100,
458
+ border: 0,
459
+ borderColor: "rgba(0,0,0,0.1)",
460
+ width: iconSize,
461
+ height: iconSize,
462
+ right: 2,
463
+ padding: [4, 0],
464
+ position: "absolute",
465
+ });
466
+ if (titleCell.sortable == 0) that.opacity = 0;
467
+ titleCell.add(that);
468
+ that.center("top");
469
+
470
+ titleCell.icon = Icon({
471
+ width: iconSize,
472
+ height: iconSize,
473
+ left: 0,
474
+ top: 0,
475
+ opacity: box.style.sortIcon.opacity,
476
+ });
477
+ that.setMotion("opacity 0.3s, transform 0.3s");
478
+ that.load(box.style.sortIconFile);
479
+ if (box.style.invertIconColor == 1) that.css.filter = "invert(100%)";
480
+ that.center();
481
+
482
+ endBox();
483
+
484
+ };
485
+
486
+ box.resetSortIcons = function (currentTitleCell) {
487
+
488
+ box.titleCellList.forEach(function (titleCell, titleCellIndex) {
489
+ if (titleCellIndex != currentTitleCell.titleCellIndex) {
490
+ titleCell.icon.rotate = 0;
491
+ titleCell.icon.opacity = box.style.sortIcon.opacity;
492
+ titleCell.sortDirection = "";
493
+ }
494
+ });
495
+
496
+ };
497
+
498
+ // A title cell
499
+ box.createTitleCell = function (titleData, titleCellIndex) {
500
+
501
+ // TitleCell
502
+ const titleCell = AutoLayout({
503
+ flow: "horizontal",
504
+ align: "center left",
505
+ width: titleData.width || DEFAULT_CELL_WIDTH,
506
+ padding: box.style.boxTitleCell.padding,
507
+ height: box.titleHeight,
508
+ color: "transparent",
509
+ border: 0,
510
+ position: "relative",
511
+ });
512
+ that.css = {
513
+ borderRight: box.style.boxTitleCell.borderRight,
514
+ borderBottom: box.style.boxTitleCell.borderBottom,
515
+ };
516
+ that.cursor = "pointer";
517
+
518
+ // DATA IN OBJECT (titleCell)
519
+ that.titleCellIndex = titleCellIndex;
520
+ that.titleDataTitle = titleData.dataTitle;
521
+ that.sortable = titleData.sortable;
522
+
523
+ titleCell.label = Label({
524
+ ...box.style.lblTitleCell,
525
+ });
526
+ setText(titleCell.label, titleData.name);
527
+ that.css.fontFamily = box.style.lblTitleCell.fontFamily;
528
+ if (box.style.titleUppercase == 1) that.css.textTransform = "uppercase";
529
+
530
+ endAutoLayout();
531
+
532
+ box.createSortIcon(titleCell);
533
+
534
+ titleCell.on("click", function (self, event) {
535
+
536
+ if (self.sortable != 1) return;
537
+
538
+ box.resetSortIcons(self);
539
+ box.sortByTitleIndex = self.titleCellIndex;
540
+ // WHY: The first click sorts A-Z; a click on the column that is already A-Z turns it.
541
+ box.sortDirection = (self.sortDirection != "A-Z") ? "A-Z" : "Z-A";
542
+ box.updateSortIcon();
543
+ box.filterAndSortData();
544
+
545
+ });
546
+
547
+ titleCell.on("mouseover", function (self, event) {
548
+ box.applyColumnHighlight(self);
549
+ });
550
+
551
+ titleCell.on("mouseout", function (self, event) {
552
+ box.clearColumnHighlight(self);
553
+ });
554
+
555
+ return titleCell;
556
+
557
+ };
558
+
559
+ box.updateSortIcon = function() {
560
+
561
+ const titleCell = box.titleCellList[box.sortByTitleIndex];
562
+ if (!titleCell) return; // WHY: a sortByTitleIndex with no column must not throw.
563
+
564
+ if (box.sortDirection == "A-Z") {
565
+ titleCell.sortDirection = "A-Z";
566
+ titleCell.icon.rotate = 0;
567
+ } else {
568
+ titleCell.sortDirection = "Z-A";
569
+ titleCell.icon.rotate = 180;
570
+ }
571
+
572
+ titleCell.icon.opacity = box.style.sortIcon.activeOpacity;
573
+
574
+ };
575
+
576
+ const paintColumn = function (titleCell, titleColor, cellColor) {
577
+ titleCell.color = titleColor;
578
+ box.itemLineList.forEach(function (itemLine) {
579
+ itemLine["itemCell" + titleCell.titleCellIndex].color = cellColor;
580
+ });
581
+ };
582
+
583
+ box.clearColumnHighlight = function (titleCell) {
584
+ if (!box.highlightTitle) return;
585
+ paintColumn(titleCell, "transparent", "transparent");
586
+ box.itemLineList.forEach(paintItemLine); // WHY: the selected row gets its color back
587
+ };
588
+
589
+ box.applyColumnHighlight = function (titleCell) {
590
+ if (!box.highlightTitle) return;
591
+ paintColumn(titleCell, box.style.highlightTitleCellColor, box.style.highlightItemCellColor);
592
+ };
593
+
594
+ // All the rows.
595
+ box.createItemLines = function () {
596
+
597
+ setHoveredCell(null); // WHY: the cell under the mouse is removed with its row
598
+ // WHY remove(): the objects of the old rows (and of the cells of the page) are cleaned, not only taken off the page
599
+ box.itemLineList.forEach(function (itemLine) { itemLine.remove(); });
600
+ box.itemLineList = [];
601
+
602
+ for (let i = 0; i < box.itemLineCount; i++) {
603
+ const itemLineIndex = i;
604
+ const itemLine = box.createItemLine(box.itemDataList[i], itemLineIndex);
605
+
606
+ box.itemLineList.push(itemLine);
607
+ box.boxItemLineGroup.add(itemLine);
608
+ }
609
+
610
+ }
611
+
612
+ // A row
613
+ box.createItemLine = function (itemData, itemLineIndex) {
614
+
615
+ // GROUP: ItemLine
616
+ const itemLine = HGroup({
617
+ height: box.itemHeight || 100,
618
+ width: "auto",
619
+ align: "top left",
620
+ padding: [0, 0],
621
+ gap: 0,
622
+ color: (itemLineIndex % 2) ? box.style.line2Color : box.style.line1Color,
623
+ position: "relative",
624
+ });
625
+
626
+ box.titleDataList.forEach(function (titleData, titleDataIndex) {
627
+ itemLine["itemCell" + titleDataIndex] = box.createItemCell(titleData.width, titleDataIndex, itemLine);
628
+ });
629
+
630
+ endGroup();
631
+
632
+ itemLine.on("click", function (self) {
633
+ // WHY: a row with no record is unseen, but its cells still take the mouse (their hover makes them clickable)
634
+ if (!self.itemData) return;
635
+ if (box.canSelect == 1) {
636
+ box.selectItem(self.itemData);
637
+ box.elem.focus({ preventScroll: true }); // WHY preventScroll: the page must not move to the table
638
+ }
639
+ box.onSelect(box, self.itemData);
640
+ });
641
+
642
+ if (box.style.height != "auto") itemLine.visible = 0; // WHY: made hidden, so it is not seen cut while its height is measured again.
643
+ return itemLine;
644
+
645
+ };
646
+
647
+ const paintItemLineCells = function (itemLine, color) {
648
+ for (let i = 0; i < box.titleCellCount; i++) {
649
+ itemLine["itemCell" + i].color = color;
650
+ }
651
+ };
652
+
653
+ // The color of the cells of a row: the selected record, else the row under the mouse (highlightLine), else none
654
+ const paintItemLine = function (itemLine) {
655
+
656
+ const isSelected = Boolean(itemLine.itemData) && itemLine.itemData === box.selectedItemData;
657
+ let color = "transparent";
658
+ if (itemLine.isHover && box.highlightLine) color = box.style.highlightItemCellColor;
659
+ if (isSelected) color = getSelectedColor();
660
+ paintItemLineCells(itemLine, color);
661
+
662
+ // WHY the bar: by default the selected row has the color of the row under the mouse; the bar tells them apart
663
+ const firstCell = itemLine["itemCell0"];
664
+ if (firstCell) firstCell.boxShadow = isSelected ? getSelectedBarShadow() : "none";
665
+
666
+ };
667
+
668
+ const getSelectedBarShadow = function () {
669
+ if (!box.style.selectedBar.width) return "none";
670
+ // WHY + the border: the edge of the table (style.boxBorder) is drawn over the first px of the row
671
+ const width = (basic.num(box.style.boxBorder.border) || 0) + box.style.selectedBar.width;
672
+ return "inset " + width + "px 0 0 " + box.style.selectedBar.color;
673
+ };
674
+
675
+ const getSelectedColor = function () {
676
+ return box.style.selectedItemCellColor || box.style.highlightItemCellColor;
677
+ };
678
+
679
+ // *** THE BUBBLE OF A CUT TEXT (showCellTooltip: 1):
680
+
681
+ const onCellHoverChange = function (cell, isOver) {
682
+ if (isOver) {
683
+ setHoveredCell(cell);
684
+ return;
685
+ }
686
+ if (hoveredCell === cell) setHoveredCell(null);
687
+ };
688
+
689
+ const setHoveredCell = function (cell) {
690
+ hoveredCell = cell;
691
+ planCellTooltip();
692
+ };
693
+
694
+ // The bubble waits until the mouse rests on the cell
695
+ const planCellTooltip = function () {
696
+ closeCellTooltip();
697
+ if (!hoveredCell || box.showCellTooltip != 1) return;
698
+ cancelCellTooltipTimer = box.after(CELL_TOOLTIP_DELAY, openCellTooltip);
699
+ };
700
+
701
+ const openCellTooltip = function () {
702
+
703
+ cancelCellTooltipTimer = null;
704
+ const text = getCutText(hoveredCell);
705
+
706
+ // WHY: without comp/tooltip.js the browser's own hint (the title of the cell) shows the text
707
+ if (typeof Tooltip === "undefined") {
708
+ hoveredCell.elem.title = text;
709
+ return;
710
+ }
711
+
712
+ if (!text) return;
713
+ cellTooltip = Tooltip.show(hoveredCell, text, box.style.cellTooltip, "top", function (bubble) {
714
+ createTooltipText(text, bubble.look);
715
+ });
716
+ cellTooltip.cellText = text;
717
+
718
+ };
719
+
720
+ // The whole text of a cell whose text does not fit (its end is "..."). "": it fits, or the row has no record.
721
+ const getCutText = function (cell) {
722
+ // WHY itemData: a row with no record keeps the text of its last record, unseen
723
+ if (!cell.itemLine.itemData) return "";
724
+ const label = cell.label.elem;
725
+ // (a hidden label, Ex: a cell of createCellView, is 0 px wide: it fits)
726
+ if (label.scrollWidth <= label.clientWidth) return "";
727
+ return label.textContent;
728
+ };
729
+
730
+ // LABEL: The whole text in the bubble (a long text goes on more lines: look.maxWidth)
731
+ const createTooltipText = function (text, look) {
732
+ Label({
733
+ plainText: text,
734
+ fontSize: look.fontSize,
735
+ textColor: look.textColor,
736
+ css: { whiteSpace: "normal", overflowWrap: "anywhere", width: "max-content", maxWidth: look.maxWidth + "px" },
737
+ });
738
+ };
739
+
740
+ const closeCellTooltip = function () {
741
+ if (cancelCellTooltipTimer) cancelCellTooltipTimer();
742
+ cancelCellTooltipTimer = null;
743
+ if (cellTooltip) cellTooltip.remove();
744
+ cellTooltip = null;
745
+ };
746
+
747
+ // The rows were filled again (a scroll, a filter, a click): a bubble with an old text is made again
748
+ const refreshCellTooltip = function () {
749
+ if (!hoveredCell) return;
750
+ if (cellTooltip && cellTooltip.cellText === hoveredCell.label.elem.textContent) return;
751
+ planCellTooltip();
752
+ };
753
+
754
+ box.setShowCellTooltip = function (value) {
755
+ box.showCellTooltip = basic.isOn(value) ? 1 : 0;
756
+ planCellTooltip();
757
+ };
758
+ // USAGE: smartTable.setShowCellTooltip(0)
759
+
760
+ // A cell.
761
+ box.createItemCell = function (cellWidth, titleDataIndex, itemLine) {
762
+
763
+ // GROUP: ItemCell
764
+ let itemCell = AutoLayout({
765
+ align: "center left",
766
+ width: cellWidth || DEFAULT_CELL_WIDTH,
767
+ padding: box.style.boxItemCell.padding,
768
+ height: "100%",
769
+ color: "transparent",
770
+ border: 0,
771
+ });
772
+ that.css = {
773
+ borderBottom: box.style.boxItemCell.borderBottom,
774
+ borderRight: box.style.boxItemCell.borderRight,
775
+ };
776
+
777
+ itemCell.label = Label({
778
+ text: "",
779
+ ...box.style.lblItemCell,
780
+ });
781
+ that.css = {
782
+ whiteSpace: "nowrap",
783
+ textOverflow: "ellipsis",
784
+ fontFamily: box.style.lblItemCell.fontFamily,
785
+ };
786
+
787
+ endAutoLayout();
788
+
789
+ itemCell.on("mouseover", function (self, event) {
790
+ itemLine.isHover = 1;
791
+ paintItemLine(itemLine);
792
+ });
793
+
794
+ itemCell.on("mouseout", function (self, event) {
795
+ itemLine.isHover = 0;
796
+ paintItemLine(itemLine);
797
+ });
798
+
799
+ itemCell.itemLine = itemLine; // (a row with no record shows no bubble)
800
+ itemCell.onHoverChange(function (self, isOver) {
801
+ onCellHoverChange(itemCell, isOver);
802
+ });
803
+
804
+ if (box.createCellView) {
805
+ createIn(itemCell, function () {
806
+ box.createCellView(itemCell, titleDataIndex, box);
807
+ });
808
+ }
809
+
810
+ return itemCell;
811
+
812
+ };
813
+
814
+ // RIGHT Scroll
815
+ box.initScrollMetrics = function () {
816
+
817
+ // Variables
818
+ box.scrollVars.minY = box.titleHeight;
819
+ box.scrollVars.scrollAreaHeight = box.height - box.titleHeight - box.infoHeight;
820
+ box.scrollVars.scrollIconHeight = box.btnScrollCenter.height;
821
+ box.scrollVars.maxY = box.scrollVars.minY + box.scrollVars.scrollAreaHeight - box.scrollVars.scrollIconHeight;
822
+ box.scrollVars.totalPath = box.scrollVars.maxY - box.scrollVars.minY;
823
+
824
+ box.scrollVars.isDragging = false;
825
+ box.scrollVars.startY = 0;
826
+ box.scrollVars.startTop = 0;
827
+
828
+ };
829
+
830
+ box.syncScrollPosition = function () {
831
+
832
+ const maxScrollIndex = getMaxScrollIndex();
833
+ if (maxScrollIndex === 0) return;
834
+
835
+ const percent = box.startedItemIndexForScrolling / maxScrollIndex;
836
+ box.btnScrollCenter.top = box.scrollVars.minY + (percent * box.scrollVars.totalPath);
837
+
838
+ };
839
+
840
+ box.createScrollEvents = function () {
841
+
842
+ box.btnScrollCenter.clickable = 1;
843
+ box.btnScrollCenter.elem.setAttribute("draggable", "false");
844
+ box.btnScrollCenter.cursor = "grab";
845
+
846
+ box.initScrollMetrics();
847
+
848
+ // WHEEL: one row for each wheel step.
849
+ box.on("wheel", function (self, event) {
850
+
851
+ // WHY: the wheel is left to the page by default: the table must not stop the page from scrolling (wheelScroll: 1 turns it on).
852
+ if (box.wheelScroll != 1) return;
853
+
854
+ // WHY: A mostly horizontal move is left to the browser (the horizontal scroll of the columns).
855
+ if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) return;
856
+
857
+ event.preventDefault();
858
+
859
+ const step = event.deltaY > 0 ? 1 : -1;
860
+ const newIndex = clampScrollIndex(box.startedItemIndexForScrolling + step);
861
+ if (newIndex === box.startedItemIndexForScrolling) return;
862
+
863
+ box.startedItemIndexForScrolling = newIndex;
864
+ box.syncScrollPosition();
865
+ box.refreshData();
866
+
867
+ }, { passive: false });
868
+
869
+ // DRAG: the center button of the vertical scroll.
870
+ box.btnScrollCenter.on("mousedown", function (self, event) {
871
+
872
+ box.scrollVars.isDragging = true;
873
+ box.scrollVars.startY = event.clientY;
874
+ box.scrollVars.startTop = box.btnScrollCenter.top;
875
+ box.btnScrollCenter.cursor = "grabbing";
876
+ document.body.style.userSelect = "none";
877
+
878
+ });
879
+
880
+ box.listenTo(window, "mousemove", function (self, event) {
881
+ dragScrollButton(event);
882
+ });
883
+ box.listenTo(window, "mouseup", function () {
884
+ stopScrollButtonDrag();
885
+ });
886
+
887
+ };
888
+
889
+ const dragScrollButton = function (event) {
890
+
891
+ if (!box || !box.scrollVars.isDragging) return;
892
+
893
+ const diffY = event.clientY - box.scrollVars.startY;
894
+ let newTop = box.scrollVars.startTop + diffY;
895
+
896
+ if (newTop < box.scrollVars.minY) newTop = box.scrollVars.minY;
897
+ if (newTop > box.scrollVars.maxY) newTop = box.scrollVars.maxY;
898
+
899
+ box.btnScrollCenter.top = newTop;
900
+
901
+ // WHY: totalPath can be 0 in a very short table, and a division by 0 makes a NaN index.
902
+ if (box.scrollVars.totalPath <= 0) return;
903
+
904
+ const currentProgress = (newTop - box.scrollVars.minY) / box.scrollVars.totalPath;
905
+ const newIndex = Math.round(currentProgress * getMaxScrollIndex());
906
+ if (newIndex === box.startedItemIndexForScrolling) return;
907
+
908
+ box.startedItemIndexForScrolling = newIndex;
909
+ box.refreshData();
910
+
911
+ };
912
+
913
+ const stopScrollButtonDrag = function () {
914
+
915
+ if (!box || !box.scrollVars.isDragging) return;
916
+
917
+ box.scrollVars.isDragging = false;
918
+ box.btnScrollCenter.cursor = "grab";
919
+ document.body.style.userSelect = "auto";
920
+
921
+ };
922
+
923
+ // *** SELECTION AND KEYS (canSelect: 1):
924
+
925
+ // The index of the selected record in the records that are seen (filtered and sorted), -1: none
926
+ box.getSelectedIndex = function () {
927
+ if (!box.selectedItemData) return -1;
928
+ return box.visibleItemDataList.indexOf(box.selectedItemData);
929
+ };
930
+
931
+ // Selects a record (one of itemDataList, null: none) and scrolls the rows to it
932
+ box.selectItem = function (itemData) {
933
+ if (box.canSelect != 1) return;
934
+ box.selectedItemData = itemData || null;
935
+ scrollToSelected();
936
+ box.refreshData();
937
+ };
938
+ // USAGE: smartTable.selectItem(smartTable.visibleItemDataList[0])
939
+
940
+ box.clearSelection = function () {
941
+ box.selectItem(null);
942
+ };
943
+
944
+ box.setCanSelect = function (value) {
945
+ box.canSelect = basic.isOn(value) ? 1 : 0;
946
+ if (box.canSelect != 1) box.selectedItemData = null;
947
+ applyCanSelect();
948
+ box.refreshData();
949
+ };
950
+ // USAGE: smartTable.setCanSelect(0)
951
+
952
+ // The table takes the focus (Tab, a click on a row) only when it can select
953
+ const applyCanSelect = function () {
954
+ box.tabIndex = (box.canSelect == 1) ? 0 : null;
955
+ if (box.canSelect != 1) box.elem.blur();
956
+ };
957
+
958
+ // The edge of the table shows the focus of the keyboard (:focus-visible), not of the mouse.
959
+ // WHY on boxBorder (not setFocusRing): the rows cover an outline that is drawn inside the table itself
960
+ const paintFocus = function () {
961
+ const hasKeyboardFocus = box.elem.matches(":focus-visible");
962
+ box.boxBorder.css.outline = hasKeyboardFocus ? "2px solid " + box.style.focusRingColor : "none";
963
+ box.boxBorder.css.outlineOffset = "-2px";
964
+ };
965
+
966
+ // The rows move as little as they can to show the selected record
967
+ const scrollToSelected = function () {
968
+ const index = box.getSelectedIndex();
969
+ if (index == -1) return;
970
+ let topIndex = box.startedItemIndexForScrolling;
971
+ if (index < topIndex) topIndex = index;
972
+ if (index >= topIndex + box.itemLineCount) topIndex = index - box.itemLineCount + 1;
973
+ box.startedItemIndexForScrolling = clampScrollIndex(topIndex);
974
+ box.syncScrollPosition();
975
+ };
976
+
977
+ // A step of rows from the selected record. Nothing selected: a step down starts before the first record, up after the last.
978
+ const moveSelection = function (step) {
979
+ const count = box.visibleItemDataList.length;
980
+ if (count == 0) return;
981
+ let index = box.getSelectedIndex();
982
+ if (index == -1) index = (step > 0) ? -1 : count;
983
+ box.selectItem(box.visibleItemDataList[basic.clamp(index + step, 0, count - 1)]);
984
+ };
985
+
986
+ // ↑ ↓ one row, Page Up / Page Down one page, Home / End to the first / the last record (0: not a key of the rows)
987
+ const getKeyStep = function (key) {
988
+ const pageStep = box.itemLineCount;
989
+ const count = box.visibleItemDataList.length;
990
+ const steps = { ArrowDown: 1, ArrowUp: -1, PageDown: pageStep, PageUp: -pageStep, Home: -count, End: count };
991
+ return steps[key] || 0;
992
+ };
993
+
994
+ const onKeyDown = function (self, event) {
995
+
996
+ // WHY: only the table itself takes the keys (not its filter box); a key with Cmd / Ctrl / Alt is left to the page
997
+ if (box.canSelect != 1 || event.target != box.elem) return;
998
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
999
+
1000
+ if (event.key == "Enter") {
1001
+ if (box.selectedItemData) box.onSelect(box, box.selectedItemData);
1002
+ return;
1003
+ }
1004
+
1005
+ const step = getKeyStep(event.key);
1006
+ if (step == 0) return;
1007
+ event.preventDefault(); // WHY: the arrows and the page keys must not scroll the page
1008
+ moveSelection(step);
1009
+ paintFocus(); // WHY: a table that got the focus with a click shows it once the keys are used
1010
+
1011
+ };
1012
+
1013
+ box.scrollPage = function (direction) { // +1: down (one page), -1: up
1014
+
1015
+ const newIndex = clampScrollIndex(box.startedItemIndexForScrolling + (direction * box.itemLineCount));
1016
+ if (newIndex === box.startedItemIndexForScrolling) return;
1017
+
1018
+ box.startedItemIndexForScrolling = newIndex;
1019
+ box.refreshData();
1020
+ box.syncScrollPosition();
1021
+
1022
+ };
1023
+
1024
+ box.updateInfoLabel = function () {
1025
+
1026
+ const totalData = box.visibleItemDataList.length;
1027
+
1028
+ if (totalData == 0) {
1029
+ box.boxInfoLine.label.text = "0 - 0 / 0";
1030
+ box.lblNoDataFound.opacity = 1;
1031
+ // TODO: Show a alert text at center (No data!)
1032
+ return;
1033
+ }
1034
+
1035
+ box.lblNoDataFound.opacity = 0;
1036
+
1037
+ // The first index (+1: people count from 1, not from 0)
1038
+ const start = box.startedItemIndexForScrolling + 1;
1039
+
1040
+ // The last index (the end of the page or the count of the data)
1041
+ let end = box.startedItemIndexForScrolling + box.itemLineCount;
1042
+ if (end > totalData) end = totalData;
1043
+
1044
+ box.boxInfoLine.label.text = `${formatNumber(start)} - ${formatNumber(end)} / ${formatNumber(totalData)}`;
1045
+
1046
+ };
1047
+
1048
+ // A number in the language of the numbers (locale): 12499 -> "12,499" (en) or "12.499" (tr)
1049
+ const formatNumber = function (number) {
1050
+ try {
1051
+ return number.toLocaleString(box.locale || document.documentElement.lang || DEFAULT_LOCALE);
1052
+ } catch (error) {
1053
+ // WHY: a wrong language tag (Ex: "en_US") throws a RangeError
1054
+ return number.toLocaleString(DEFAULT_LOCALE);
1055
+ }
1056
+ };
1057
+
1058
+ box.setLocale = function (locale) {
1059
+ box.locale = locale;
1060
+ box.updateInfoLabel();
1061
+ };
1062
+ // USAGE: smartTable.setLocale("en-US")
1063
+
1064
+ box.setScrollToTop = function () {
1065
+ box.startedItemIndexForScrolling = 0;
1066
+ box.btnScrollCenter.top = box.scrollVars.minY;
1067
+ };
1068
+
1069
+ box.setItemDataList = function (itemDataList) {
1070
+ box.itemDataList = [...itemDataList];
1071
+ box.filterAndSortData();
1072
+ };
1073
+
1074
+ // WHY: a "value ?" check made 0 and false impossible to find.
1075
+ const hasKeyword = function (value, searchKeyword) {
1076
+ if (value === undefined || value === null) return false;
1077
+ return SmartTable.toSearchText(value).includes(searchKeyword);
1078
+ };
1079
+
1080
+ const filterItems = function (itemList, searchKeyword) {
1081
+
1082
+ if (searchKeyword === "") return itemList;
1083
+
1084
+ // A chosen column: the search looks only in it; none (ALL): in every column.
1085
+ const searchTitleData = box.titleDataList[box.searchTitleIndex];
1086
+ const searchTitleList = (searchTitleData) ? [searchTitleData] : box.titleDataList;
1087
+
1088
+ return itemList.filter(item => {
1089
+ return searchTitleList.some(title => hasKeyword(item[title.dataTitle], searchKeyword));
1090
+ });
1091
+
1092
+ };
1093
+
1094
+ const compareValues = function (valueA, valueB) {
1095
+
1096
+ const numberA = toSortNumber(valueA);
1097
+ const numberB = toSortNumber(valueB);
1098
+
1099
+ if (Number.isFinite(numberA) && Number.isFinite(numberB)) return numberA - numberB;
1100
+ return String(valueA).localeCompare(String(valueB), 'tr');
1101
+
1102
+ };
1103
+
1104
+ // Sorts the list in place.
1105
+ const sortItems = function (itemList, sortByTitleIndex, sortDirection) {
1106
+
1107
+ const titleData = box.titleDataList[sortByTitleIndex];
1108
+ if (!titleData || titleData.sortable === 0) return;
1109
+
1110
+ const key = titleData.dataTitle;
1111
+
1112
+ itemList.sort((a, b) => {
1113
+ const comparison = compareValues(a[key] ?? "", b[key] ?? "");
1114
+ return sortDirection === "A-Z" ? comparison : -comparison;
1115
+ });
1116
+
1117
+ };
1118
+
1119
+ box.filterAndSortData = function () {
1120
+
1121
+ if (box.itemDataList.length > LOADING_MIN_ITEM_COUNT) box.showLoading(1);
1122
+
1123
+ // WHY: calls one after the other (a fast search): only the last one runs, an old result must not write over a new one.
1124
+ box.filterTimer = waitAndRun(box.filterTimer, function () {
1125
+
1126
+ box.filterTimer = null;
1127
+ const searchKeyword = SmartTable.toSearchText(box.searchKeyword ?? "").trim();
1128
+
1129
+ // WHY: A copy; sort() must not change the order of box.itemDataList.
1130
+ const filteredList = filterItems([...box.itemDataList], searchKeyword);
1131
+ sortItems(filteredList, box.sortByTitleIndex, box.sortDirection);
1132
+
1133
+ box.visibleItemDataList = filteredList;
1134
+
1135
+ box.setScrollToTop();
1136
+ // WHY: the selected record stays selected and seen after a sort or a filter; a record that is gone is not
1137
+ if (box.getSelectedIndex() == -1) box.selectedItemData = null;
1138
+ scrollToSelected();
1139
+ box.refreshData();
1140
+
1141
+ box.showLoading(0);
1142
+
1143
+ }, FILTER_DELAY);
1144
+
1145
+ };
1146
+
1147
+ box.generateTestData = function () {
1148
+
1149
+ let bigData = [];
1150
+
1151
+ for (let i = 0; i < TEST_DATA_REPEAT_COUNT; i++) {
1152
+ // The objects are copied: their ids must not repeat, and they must not share a reference
1153
+ const clonedBatch = box.itemDataList.map(item => ({
1154
+ ...item,
1155
+ id: bigData.length + item.id // a unique id
1156
+ }));
1157
+
1158
+ bigData.push(...clonedBatch);
1159
+ }
1160
+
1161
+ box.itemDataList = bigData;
1162
+ box.visibleItemDataList = bigData;
1163
+
1164
+ console.log("Yeni veri sayısı:", box.visibleItemDataList.length);
1165
+
1166
+ };
1167
+
1168
+ box.createVerticalScroll = function () {
1169
+
1170
+ const scrollWidth = box.style.verticalScrollWidth;
1171
+ const leftMargin = box.style.verticalScrollMargin;
1172
+ const scrollRight = (scrollWidth + leftMargin) * -1;
1173
+
1174
+ box.btnScrollCenter = startBox(0, 0, scrollWidth, SCROLL_CENTER_HEIGHT, {
1175
+ right: scrollRight,
1176
+ top: box.titleHeight,
1177
+ opacity: 0,
1178
+ clickable: 0,
1179
+ ...box.style.btnScrollCenter,
1180
+ });
1181
+
1182
+ Icon(0, 0, "100%", "100%");
1183
+ that.load(box.style.btnScrollCenterIconFile);
1184
+
1185
+ endBox();
1186
+
1187
+ box.btnScrollUp = Box(0, 0, scrollWidth, box.titleHeight, {
1188
+ right: scrollRight,
1189
+ ...box.style.btnScrollUp,
1190
+ });
1191
+ that.cursor = "pointer";
1192
+ that.on("click", function (self, event) {
1193
+ box.scrollPage(-1);
1194
+ });
1195
+
1196
+ Icon(0, 0, "100%", "100%");
1197
+ box.btnScrollUp.add(that);
1198
+ that.load(box.style.btnScrollUpIconFile);
1199
+ if (box.style.invertIconColor == 1) that.css.filter = "invert(100%)";
1200
+
1201
+ box.btnScrollDown = Box(0, 0, scrollWidth, box.infoHeight, {
1202
+ right: scrollRight,
1203
+ bottom: 0,
1204
+ ...box.style.btnScrollDown,
1205
+ });
1206
+ that.cursor = "pointer";
1207
+ that.on("click", function (self, event) {
1208
+ box.scrollPage(1);
1209
+ });
1210
+
1211
+ Icon(0, 0, "100%", "100%");
1212
+ box.btnScrollDown.add(that);
1213
+ that.load(box.style.btnScrollDownIconFile);
1214
+ if (box.style.invertIconColor == 1) that.css.filter = "invert(100%)";
1215
+
1216
+ };
1217
+
1218
+ // A narrow table: the filter box is wider than its share of the line (searchInputParams.width, Ex: "50%"), up to
1219
+ // SEARCH_MIN_WIDTH and up to the count. A width in px stays as it is.
1220
+ const applySearchWidth = function () {
1221
+ const width = String(box.searchInputParams.width);
1222
+ box.searchInput.css.minWidth = "0px"; // WHY: a long count makes it narrower
1223
+ if (!width.endsWith("%")) return;
1224
+ box.searchInput.css.flexGrow = "1";
1225
+ box.searchInput.css.maxWidth = "max(" + width + ", " + SEARCH_MIN_WIDTH + "px)";
1226
+ };
1227
+
1228
+ // The chip keeps the right end of the filter box: the clear icon and the text of SearchInput are at its left.
1229
+ const fitSearchToTitle = function () {
1230
+ const titleWidth = box.lblSelectedSortKey.elem.offsetWidth;
1231
+ const hasTitle = (titleWidth > 0);
1232
+ box.searchInput.setClearIconRight(hasTitle ? SEARCH_TITLE_RIGHT + titleWidth + SEARCH_TITLE_GAP : searchClearIconRight);
1233
+ };
1234
+
1235
+ box.createToolbar = function () {
1236
+
1237
+ // GROUP: The filter box and the count, in one line
1238
+ // WHY one line (flex): a narrow table gives the filter box the room up to the count, and a long count makes
1239
+ // it narrower (it never covers the count).
1240
+ HGroup({
1241
+ align: "left center",
1242
+ gap: TOOLBAR_GAP,
1243
+ padding: [TOOLBAR_PADDING, 0],
1244
+ });
1245
+ box.boxInfoLine.add(that);
1246
+
1247
+ box.searchInput = SearchInput(box.searchInputParams);
1248
+ that.setValue(box.searchKeyword, 1);
1249
+ that.onEnter = function (self) {
1250
+ box.searchKeyword = self.getSearchText();
1251
+ box.filterAndSortData();
1252
+ }
1253
+ searchClearIconRight = that.clearIconRight;
1254
+ applySearchWidth();
1255
+
1256
+ box.boxInfoLine.label = Label({
1257
+ text: "0 - 0 / 0",
1258
+ ...box.style.lblBoxInfoLine,
1259
+ });
1260
+ that.css = { marginLeft: "auto", marginRight: (COUNT_RIGHT - TOOLBAR_PADDING) + "px", flexShrink: "0" };
1261
+
1262
+ endGroup();
1263
+
1264
+ // LABEL: The choice of the search column (ALL): in the filter box, at its right end
1265
+ box.lblSelectedSortKey = createIn(box.searchInput, function () {
1266
+ return Label({
1267
+ right: SEARCH_TITLE_RIGHT,
1268
+ opacity: 1,
1269
+ clickable: 1,
1270
+ ...box.style.lblNoDataFound,
1271
+ ...box.style.lblSearchTitle, // WHY: the label is in the filter box: it gets a look apart from the "no data" label.
1272
+ });
1273
+ });
1274
+ setText(box.lblSelectedSortKey, box.allTitlesText);
1275
+ that.cursor = "pointer";
1276
+ that.ellipsis = 1;
1277
+ that.css.maxWidth = SEARCH_TITLE_MAX_WIDTH;
1278
+ // WHY CSS: the chip stays in the middle of the box when its text or its font changes
1279
+ that.css.top = "50%";
1280
+ that.css.transform = "translateY(-50%)";
1281
+ that.setMotion("opacity 0.2s");
1282
+ // WHY onResize: a column name is wider than ALL; a hidden chip is 0 px (showSearchTitleSelect: 0)
1283
+ that.onResize(fitSearchToTitle);
1284
+
1285
+ if (typeof ContextMenu === "function") {
1286
+
1287
+ // MENU: The list of the columns (items: box.updateSearchTitleSelect)
1288
+ box.searchTitleMenu = ContextMenu({
1289
+ minWidth: 160,
1290
+ ...box.searchTitleMenuParams,
1291
+ onClick: function (self, item) {
1292
+ box.setSearchTitleIndex(item.data);
1293
+ },
1294
+ });
1295
+ box.searchTitleMenu.attachTo(box.lblSelectedSortKey, "click");
1296
+
1297
+ } else {
1298
+
1299
+ // WHY: without context-menu.js it still works: every press goes to the next column.
1300
+ box.lblSelectedSortKey.on("click", function () {
1301
+ box.selectNextSearchTitle();
1302
+ });
1303
+
1304
+ }
1305
+
1306
+ };
1307
+
1308
+ box.stretchLastCell = function (width) {
1309
+
1310
+ const hasWidth = width > 0; // WHY: Not "width <= 0": a NaN width must also stop here.
1311
+ if (!hasWidth || box.titleCellCount == 0) return;
1312
+
1313
+ const lastCellIndex = box.titleCellCount - 1;
1314
+
1315
+ box.itemLineList.forEach(function (itemLine) {
1316
+ itemLine["itemCell" + lastCellIndex].width = width;
1317
+ });
1318
+
1319
+ box.titleCellList[lastCellIndex].width = width;
1320
+
1321
+ };
1322
+
1323
+ box.calcLastCellWidth = function () {
1324
+
1325
+ const titleDataList = box.titleDataList;
1326
+ const tableWidth = box.width;
1327
+
1328
+ if (titleDataList.length == 0) return 0;
1329
+
1330
+ // WHY: createTitleCell / createItemCell use DEFAULT_CELL_WIDTH when there is no width: the same here, or basic.num(undefined) is NaN.
1331
+ let totalWidth = 0;
1332
+ titleDataList.forEach(function (titleData) {
1333
+ totalWidth += basic.num(titleData.width || DEFAULT_CELL_WIDTH);
1334
+ });
1335
+
1336
+ const lastCellWidth = basic.num(titleDataList[titleDataList.length - 1].width || DEFAULT_CELL_WIDTH);
1337
+
1338
+ if (tableWidth > totalWidth) return tableWidth - totalWidth + lastCellWidth;
1339
+
1340
+ // WHY: when the table got narrower, the last cell kept its old wider size: back to its own width.
1341
+ return lastCellWidth;
1342
+
1343
+ };
1344
+
1345
+ box.setItemHeight = function (itemHeight) {
1346
+
1347
+ box.itemHeight = itemHeight;
1348
+
1349
+ box.itemLineList.forEach(function (itemLine) {
1350
+ itemLine.height = box.itemHeight;
1351
+ itemLine.visible = 1; // WHY: shown after its height is measured
1352
+ });
1353
+
1354
+ };
1355
+
1356
+ box.setHeight = function (height) {
1357
+
1358
+ // When the height is not "auto", the height of the cells is measured on a resize.
1359
+ box.recalcItemHeight = (height != "auto") ? 1 : 0;
1360
+ box.height = height;
1361
+
1362
+ };
1363
+
1364
+ box.setWidth = function (width) {
1365
+
1366
+ // WHY: a number (width: 800) made .includes throw.
1367
+ const isPercent = typeof width === "string" && width.includes("%");
1368
+
1369
+ // The vertical scroll stands right of the table, outside its box: the table keeps that room for it.
1370
+ if (!isPercent) {
1371
+ // WHY a margin: in a group the next object stood on the scroll (a table that takes the room that is
1372
+ // left, a table of 600 px next to a chart). A table with a place of its own is not moved by it.
1373
+ box.width = width;
1374
+ box.css = { marginRight: box.getVerticalScrollWidth() + "px" };
1375
+ return;
1376
+ }
1377
+
1378
+ if (box.css.marginRight) box.css = { marginRight: "" }; // a width in px before
1379
+ box.width = "calc(" + width + " - " + box.getVerticalScrollWidth() + "px)";
1380
+
1381
+ };
1382
+
1383
+ box.getTotalWidth = function () {
1384
+ return box.width + box.getVerticalScrollWidth();
1385
+ }
1386
+
1387
+ box.getVerticalScrollWidth = function () {
1388
+ return box.style.verticalScrollWidth + box.style.verticalScrollMargin;
1389
+ };
1390
+
1391
+ box.createLoading = function () {
1392
+
1393
+ box.boxLoading = VGroup({
1394
+ color: Black(0.3),
1395
+ clickable: 1,
1396
+ round: box.style.round,
1397
+ });
1398
+ box.add(box.boxLoading);
1399
+
1400
+ Icon({
1401
+ width: LOADING_ICON_SIZE,
1402
+ height: LOADING_ICON_SIZE,
1403
+ });
1404
+ that.load(box.style.loadingIconFile);
1405
+
1406
+ endGroup();
1407
+
1408
+ };
1409
+
1410
+ box.showLoading = function (show) {
1411
+ if (show) {
1412
+ box.boxLoading.visible = 1;
1413
+ box.setVerticalScrollEnabled(false);
1414
+
1415
+ } else {
1416
+ box.boxLoading.visible = 0;
1417
+ box.setVerticalScrollEnabled(true);
1418
+ }
1419
+ };
1420
+
1421
+ box.createNoDataFoundLabel = function () {
1422
+
1423
+ // Centered
1424
+ HGroup();
1425
+
1426
+ box.lblNoDataFound = Label({
1427
+ opacity: 0,
1428
+ ...box.style.lblNoDataFound,
1429
+ });
1430
+ setText(box.lblNoDataFound, box.noDataFoundAlert);
1431
+ that.setMotion("opacity 0.2s");
1432
+
1433
+ endGroup();
1434
+
1435
+ };
1436
+
1437
+ // The name of a column in the list (without HTML tags; its dataTitle when it has no name)
1438
+ const getTitleText = function (titleData) {
1439
+ const name = String(titleData.name ?? "").replace(/<[^>]*>/g, "").trim();
1440
+ return name || String(titleData.dataTitle ?? "");
1441
+ };
1442
+
1443
+ // The label of the search column and its list, as the choice is.
1444
+ box.updateSearchTitleSelect = function () {
1445
+
1446
+ if (!box.titleDataList[box.searchTitleIndex]) box.searchTitleIndex = -1;
1447
+
1448
+ const selectedTitleData = box.titleDataList[box.searchTitleIndex];
1449
+ setText(box.lblSelectedSortKey, (selectedTitleData) ? getTitleText(selectedTitleData) : box.allTitlesText);
1450
+ box.lblSelectedSortKey.visible = (box.showSearchTitleSelect == 1) ? 1 : 0;
1451
+
1452
+ if (!box.searchTitleMenu) return;
1453
+
1454
+ // WHY: only the chosen one has an icon; ContextMenu gives the others an empty place of an icon, so the texts stay in line.
1455
+ const getCheckIcon = function (titleIndex) {
1456
+ return (box.searchTitleIndex == titleIndex) ? box.style.searchTitleCheckIconFile : "";
1457
+ };
1458
+
1459
+ const items = [
1460
+ { text: box.allTitlesText, data: -1, iconFile: getCheckIcon(-1) },
1461
+ "-",
1462
+ ];
1463
+
1464
+ box.titleDataList.forEach(function (titleData, titleIndex) {
1465
+ items.push({ text: getTitleText(titleData), data: titleIndex, iconFile: getCheckIcon(titleIndex) });
1466
+ });
1467
+
1468
+ box.searchTitleMenu.setItems(items);
1469
+ if (box.showSearchTitleSelect != 1) box.searchTitleMenu.close();
1470
+
1471
+ };
1472
+
1473
+ // Choose the search column. -1: ALL (every column)
1474
+ box.setSearchTitleIndex = function (titleIndex) {
1475
+
1476
+ box.searchTitleIndex = (box.titleDataList[titleIndex]) ? titleIndex : -1;
1477
+ box.updateSearchTitleSelect();
1478
+
1479
+ // WHY: an empty search box changes no result: the scroll must not go back to the top for nothing.
1480
+ if (String(box.searchKeyword ?? "").trim() !== "") box.filterAndSortData();
1481
+
1482
+ };
1483
+ // USAGE: smartTable.setSearchTitleIndex(1) or smartTable.setSearchTitleIndex(-1)
1484
+
1485
+ // The next column: ALL -> 0 -> 1 -> ... -> ALL
1486
+ box.selectNextSearchTitle = function () {
1487
+ const nextIndex = box.searchTitleIndex + 1;
1488
+ box.setSearchTitleIndex((nextIndex < box.titleDataList.length) ? nextIndex : -1);
1489
+ };
1490
+
1491
+ box.setShowSearchTitleSelect = function (show) {
1492
+ box.showSearchTitleSelect = basic.isOn(show) ? 1 : 0;
1493
+ box.updateSearchTitleSelect();
1494
+ };
1495
+ // USAGE: smartTable.setShowSearchTitleSelect(0)
1496
+
1497
+ // The mouse wheel scrolls the rows. 0: the wheel is left to the page.
1498
+ box.setWheelScroll = function (enabled) {
1499
+ box.wheelScroll = basic.isOn(enabled) ? 1 : 0;
1500
+ };
1501
+ // USAGE: smartTable.setWheelScroll(1)
1502
+
1503
+ // The height the rows share: the table without its title line and its info line
1504
+ const getRowsHeight = function () {
1505
+ return box.height - box.titleHeight - box.infoHeight;
1506
+ };
1507
+
1508
+ // The parts that depend on the size of the table (onResize)
1509
+ const refreshLayout = function () {
1510
+
1511
+ if (box.recalcItemHeight && box.fitLineCount == 1) {
1512
+
1513
+ fitItemLines();
1514
+
1515
+ } else if (box.recalcItemHeight) {
1516
+
1517
+ const itemHeight = getRowsHeight() / box.itemLineCount;
1518
+
1519
+ // WHY: when the measured height was the same as itemHeight, the rows were never shown.
1520
+ if (box.itemHeight != itemHeight || (box.itemLineList[0] && !box.itemLineList[0].visible)) {
1521
+ box.setItemHeight(itemHeight);
1522
+ }
1523
+
1524
+ }
1525
+
1526
+ box.stretchLastCell(box.calcLastCellWidth());
1527
+ box.initScrollMetrics();
1528
+ box.syncScrollPosition();
1529
+ box.scrollBar.refreshScroll(); // WHY: a narrower window must not show a scroll bar it does not need
1530
+
1531
+ box.refreshData();
1532
+
1533
+ };
1534
+
1535
+ // fitLineCount: 1 -> as many rows of about targetItemHeight as the table holds; they share its height exactly
1536
+ const fitItemLines = function () {
1537
+ const rowsHeight = getRowsHeight();
1538
+ if (rowsHeight <= 0) return; // WHY: the table is not drawn yet
1539
+ const lineCount = Math.max(1, Math.round(rowsHeight / targetItemHeight));
1540
+ if (lineCount != box.itemLineList.length) {
1541
+ box.setItemLineCount(lineCount);
1542
+ return;
1543
+ }
1544
+ box.setItemHeight(rowsHeight / lineCount);
1545
+ };
1546
+
1547
+ // Makes count rows: only these rows exist, they show the records from startedItemIndexForScrolling.
1548
+ // (fitLineCount: 1 makes the count again when the size of the table changes.)
1549
+ box.setItemLineCount = function (count) {
1550
+
1551
+ box.itemLineCount = Math.max(1, Math.round(count));
1552
+ box.createItemLines();
1553
+
1554
+ const rowsHeight = getRowsHeight();
1555
+ const hasRowsHeight = box.recalcItemHeight && rowsHeight > 0;
1556
+ box.setItemHeight(hasRowsHeight ? rowsHeight / box.itemLineCount : box.itemHeight);
1557
+
1558
+ box.stretchLastCell(box.calcLastCellWidth());
1559
+ box.startedItemIndexForScrolling = clampScrollIndex(box.startedItemIndexForScrolling);
1560
+ scrollToSelected();
1561
+ box.initScrollMetrics();
1562
+ box.syncScrollPosition();
1563
+ box.refreshData();
1564
+
1565
+ };
1566
+ // USAGE: smartTable.setItemLineCount(20)
1567
+
1568
+ box.setFitLineCount = function (value) {
1569
+ box.fitLineCount = basic.isOn(value) ? 1 : 0;
1570
+ refreshLayout();
1571
+ };
1572
+ // USAGE: smartTable.setFitLineCount(1)
1573
+
1574
+ box.createResizeEvent = function () {
1575
+
1576
+ box.onResize(function (self) {
1577
+ box.resizeTimer = waitAndRun(box.resizeTimer, refreshLayout, RESIZE_DELAY);
1578
+ });
1579
+
1580
+ };
1581
+
1582
+ // *** OBJECT VIEW:
1583
+ box.init = function () {
1584
+
1585
+ box.clickable = 1;
1586
+ // Show outside of the box.
1587
+ box.clipContent = 0;
1588
+ box.color = box.style.box.color;
1589
+ box.round = box.style.round;
1590
+ if (box.invertColor == 1) box.css.filter = "invert(100%)";
1591
+ box.setWidth(box.style.width);
1592
+ box.setHeight(box.style.height);
1593
+
1594
+
1595
+ // CREATE the structure:
1596
+
1597
+ // Title and Item Line Group Container
1598
+ box.boxHorizontalScrollable = VGroup({
1599
+ align: "top left",
1600
+ width: "auto",
1601
+ height: "auto",
1602
+ padding: [0, 0],
1603
+ gap: 0,
1604
+ position: "relative",
1605
+ clipContent: 0,
1606
+ scrollX: 1,
1607
+ });
1608
+ // WHY: Only the top corners are round; the info line under it has the bottom ones.
1609
+ that.css = {
1610
+ borderTopLeftRadius: box.style.round + "px",
1611
+ borderTopRightRadius: box.style.round + "px",
1612
+ borderBottomRightRadius: "0px",
1613
+ borderBottomLeftRadius: "0px",
1614
+ marginBottom: box.infoHeight + "px",
1615
+ };
1616
+
1617
+ // Title Line
1618
+ box.boxTitleLine = HGroup({
1619
+ height: "auto",
1620
+ width: "auto",
1621
+ align: "top left",
1622
+ padding: [0, 0],
1623
+ gap: 0,
1624
+ color: box.style.boxTitleLine.color,
1625
+ // NOTE: this width, height: "100%" as default.
1626
+ });
1627
+
1628
+ // TITLE CELLS WILL BE HERE
1629
+
1630
+ endGroup();
1631
+
1632
+ // Item Line Group
1633
+ box.boxItemLineGroup = VGroup({
1634
+ align: "top left",
1635
+ width: "auto",
1636
+ height: "auto",
1637
+ padding: [0, 0],
1638
+ gap: 0,
1639
+ });
1640
+
1641
+ // ITEM LINES WILL BE HERE
1642
+
1643
+ endGroup();
1644
+
1645
+ endGroup(); // Title and Item Line Group Container
1646
+
1647
+ box.boxInfoLine = HGroup({
1648
+ bottom: 0,
1649
+ left: 0,
1650
+ height: box.infoHeight,
1651
+ width: "100%",
1652
+ align: "top left",
1653
+ padding: [0, 0],
1654
+ gap: 0,
1655
+ ...box.style.boxInfoLine,
1656
+ });
1657
+ endGroup();
1658
+ that.css = {
1659
+ borderTopLeftRadius: "0px",
1660
+ borderTopRightRadius: "0px",
1661
+ borderBottomRightRadius: box.style.round + "px",
1662
+ borderBottomLeftRadius: box.style.round + "px",
1663
+ borderTop: box.style.boxInfoLine.borderTop,
1664
+ };
1665
+ that.clickable = 0;
1666
+
1667
+ box.createToolbar();
1668
+ box.createNoDataFoundLabel();
1669
+
1670
+ // boxBorder
1671
+ box.boxBorder = Box(0, 0, "100%", "100%", box.style.boxBorder);
1672
+ that.round = box.style.round;
1673
+ that.color = "transparent";
1674
+
1675
+ box.createVerticalScroll();
1676
+
1677
+ // SCROLL BAR: Horizontal Scroll
1678
+ box.scrollBar = ScrollBar({
1679
+ scrollableBox: box.boxHorizontalScrollable,
1680
+ ...box.scrollBarParams,
1681
+ });
1682
+
1683
+ box.createResizeEvent();
1684
+ box.createLoading();
1685
+
1686
+ };
1687
+
1688
+ // *** OBJECT INIT CODE:
1689
+ box.init(); // Create UI
1690
+ box.createTitleLine();
1691
+ box.createItemLines();
1692
+ box.createScrollEvents();
1693
+ box.on("keydown", onKeyDown);
1694
+ box.on("focus", paintFocus);
1695
+ box.on("blur", paintFocus);
1696
+ applyCanSelect();
1697
+ box.stretchLastCell(box.calcLastCellWidth());
1698
+ box.updateSortIcon();
1699
+ box.updateSearchTitleSelect();
1700
+ // Add test data. WHY before filterAndSortData: the records are sorted before they are shown, and big data shows the loading.
1701
+ if (box.fillTestData) box.generateTestData();
1702
+ box.filterAndSortData();
1703
+
1704
+ return endObject(box);
1705
+
1706
+ };
1707
+
1708
+ // The text of a cell (and of the keyword) for the filter: lowercase in Turkish ("İ" -> "i", not "i" + a dot), without
1709
+ // the marks of the letters, "ı" as "i" (as DataTable.toSearchText).
1710
+ // WHY: toLowerCase() made "İstanbul" "i̇stanbul": the keyword "istanbul" found nothing.
1711
+ // WHY the fast way: most texts have no letter outside ASCII after the lowercase, and a table can have 100 000 rows.
1712
+ SmartTable.toSearchText = function (value) {
1713
+ const text = String(value).toLocaleLowerCase("tr");
1714
+ if (!SmartTable.NOT_ASCII.test(text)) return text;
1715
+ return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/ı/g, "i");
1716
+ };
1717
+ SmartTable.NOT_ASCII = /[^\u0000-\u007f]/;
1718
+
1719
+ // *** STYLE PACKAGES:
1720
+ // USAGE: SmartTable({ styleName: "dark" })
1721
+ // USAGE: SmartTable({ styleName: "dark", style: { lblItemCell: { fontSize: 14 } } }) // Change only some keys.
1722
+ // NOTE: A package is a package of params (it has a "style" key): its other keys (searchInputParams, scrollBarParams,
1723
+ // searchTitleMenuParams) fill the params you did not give. A new package needs only the keys that differ from
1724
+ // the classic look (SmartTableDefaults).
1725
+ SmartTable.styles = {
1726
+
1727
+ // The look of DataTable "light": a light gray title line, striped rows, a soft yellow row under the mouse and
1728
+ // a stronger one for the selected row; the filter box is the SearchInput "ozden". (SmartTableDefaults)
1729
+ light: { style: {} },
1730
+
1731
+ // The look of DataTable "dark", for a dark page; the filter box is the SearchInput "ozdenDark", the column list
1732
+ // is the ContextMenu "dark".
1733
+ dark: {
1734
+ style: {
1735
+ line1Color: "#232428",
1736
+ line2Color: "#27292D",
1737
+ highlightItemCellColor: "#2E3035",
1738
+ selectedItemCellColor: "#24383A",
1739
+ focusRingColor: "rgba(95, 179, 181, 0.7)",
1740
+ highlightTitleCellColor: "#33353A",
1741
+ // WHY its own icon: invertIconColor turns only the sort and the up / down arrows
1742
+ btnScrollCenterIconFile: "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 50" fill="none" stroke="#FFFFFF" stroke-opacity="0.5" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M10 17.5v15M6.5 21 10 17.5 13.5 21M6.5 29 10 32.5 13.5 29"/></svg>'),
1743
+ searchTitleCheckIconFile: "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#E6E6E6" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5 10 17.5 19 7"/></svg>'),
1744
+ invertIconColor: 1,
1745
+ sortIcon: { size: 16, opacity: 0.3, activeOpacity: 1 },
1746
+ cellTooltip: { color: "#2B2D31", textColor: "rgba(255, 255, 255, 0.88)", borderColor: "rgba(255, 255, 255, 0.14)", shadow: "0 8px 24px rgba(0, 0, 0, 0.5)" },
1747
+ box: { color: "#232428" },
1748
+ boxBorder: { border: 1, borderColor: "rgba(255, 255, 255, 0.12)" },
1749
+ boxTitleLine: { color: "#2B2D31" },
1750
+ boxTitleCell: { borderRight: "1px solid rgba(255, 255, 255, 0.08)", borderBottom: "1px solid rgba(255, 255, 255, 0.14)" },
1751
+ lblTitleCell: { textColor: "rgba(255, 255, 255, 0.85)" },
1752
+ boxItemCell: { borderBottom: "1px solid rgba(255, 255, 255, 0.06)" },
1753
+ lblItemCell: { textColor: "rgba(255, 255, 255, 0.75)" },
1754
+ boxInfoLine: { color: "#232428", borderTop: "1px solid rgba(255, 255, 255, 0.14)" },
1755
+ lblBoxInfoLine: { textColor: "rgba(255, 255, 255, 0.5)" },
1756
+ lblNoDataFound: { textColor: "rgba(255, 255, 255, 0.45)" },
1757
+ lblSearchTitle: { color: "#33353A", textColor: "rgba(255, 255, 255, 0.7)", borderColor: "rgba(255, 255, 255, 0.14)" },
1758
+ btnScrollCenter: { color: "#2B2D31", borderColor: "rgba(255, 255, 255, 0.2)" },
1759
+ btnScrollUp: { color: "#2B2D31", borderColor: "rgba(255, 255, 255, 0.14)" },
1760
+ btnScrollDown: { color: "#2B2D31", borderColor: "rgba(255, 255, 255, 0.14)" },
1761
+ },
1762
+ searchInputParams: { styleName: "ozdenDark" },
1763
+ scrollBarParams: { bar_color: "#A0A0A0", bar_mouseOverColor: "#D0D0D0" },
1764
+ searchTitleMenuParams: { styleName: "dark" },
1765
+ },
1766
+
1767
+ // The green title line, a dark edge, big texts. Every
1768
+ // key is here: a page that changes some of them over this look (styleName: "green") gets the rest from it.
1769
+ green: {
1770
+ style: {
1771
+ width: "auto",
1772
+ height: "auto",
1773
+ round: 6,
1774
+ line1Color: "white",
1775
+ line2Color: "whitesmoke",
1776
+ highlightItemCellColor: "#F3E7C2",
1777
+ selectedItemCellColor: null, // null: highlightItemCellColor (the row under the mouse)
1778
+ selectedBar: { width: 3, color: "rgba(95, 158, 160, 0.9)" },
1779
+ focusRingColor: "rgba(95, 158, 160, 0.6)",
1780
+ highlightTitleCellColor: White(0.2),
1781
+ titleUppercase: 0,
1782
+ verticalScrollWidth: 20,
1783
+ verticalScrollMargin: 2,
1784
+ btnScrollDownIconFile: SmartTableDefaults.style.btnScrollDownIconFile,
1785
+ btnScrollUpIconFile: SmartTableDefaults.style.btnScrollUpIconFile,
1786
+ btnScrollCenterIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 200" preserveAspectRatio="none" fill="none" stroke="#D96450" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"><path d="M40 28V172M27 41L40 28L53 41M27 159L40 172L53 159"/></svg>'), // a red line with two heads
1787
+ sortIconFile: "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80" preserveAspectRatio="none" fill="none" stroke="#141414" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"><path d="M40 24V56M27 43L40 56L53 43"/></svg>'), // an arrow down
1788
+ loadingIconFile: SmartTableDefaults.style.loadingIconFile,
1789
+ searchTitleCheckIconFile: "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#373836" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5 10 17.5 19 7"/></svg>'),
1790
+ invertIconColor: 0,
1791
+ sortIcon: { size: 22, opacity: 0.5, activeOpacity: 1 },
1792
+ box: { color: "white" },
1793
+ boxBorder: { border: 2, borderColor: Black(0.8) },
1794
+ boxTitleLine: { color: "#65A293" },
1795
+ boxTitleCell: { padding: [8, 0], borderRight: "1px solid rgba(0, 0, 0, 0.5)", borderBottom: "2px solid #141414" },
1796
+ lblTitleCell: { fontSize: 20, fontFamily: "opensans", textColor: Black(0.8) },
1797
+ boxItemCell: { borderBottom: "1px solid darkgray", borderRight: "1px solid rgba(0, 0, 0, 0.05)", padding: [8, 0] },
1798
+ lblItemCell: { fontSize: 20, textColor: Black(0.75), fontFamily: "opensans" },
1799
+ boxInfoLine: { color: "#E4E4E4", borderTop: "1px solid rgba(0, 0, 0, 0)" },
1800
+ lblBoxInfoLine: { fontSize: 16, textColor: Black(0.85) },
1801
+ lblNoDataFound: { color: "lightgray", textColor: Black(0.8), padding: [8, 2], fontSize: 14, round: 8, border: 1, borderColor: Black(0.4) },
1802
+ // (whitesmoke, as the pale lines of the table; the edge of the filter box)
1803
+ lblSearchTitle: { color: "whitesmoke", textColor: Black(0.8), padding: [8, 2], fontSize: 14, round: 8, border: 1, borderColor: Black(0.15) },
1804
+ btnScrollCenter: { color: "white", round: 100, border: 1, borderColor: "rgba(0,0,0,0.4)" },
1805
+ btnScrollUp: { color: "lightgray", round: 100, border: 1, borderColor: "rgba(0, 0, 0, 0.6)" },
1806
+ btnScrollDown: { color: "lightgray", round: 100, border: 1, borderColor: "rgba(0, 0, 0, 0.6)" },
1807
+ boxSort: { color: "#65A293" },
1808
+ },
1809
+ searchInputParams: {
1810
+ styleName: "original", // the first look of SearchInput
1811
+ width: "50%",
1812
+ height: 36,
1813
+ border: 1,
1814
+ round: 8,
1815
+ color: "white",
1816
+ searchIconSize: 16,
1817
+ placeholder: "Filter",
1818
+ fontSize: 16,
1819
+ borderColor: Black(0.15), // (light edges in the filter)
1820
+ borderBottomStyle: "1px solid " + Black(0.15),
1821
+ searchIconFile: SmartTableDefaults.searchInputParams.searchIconFile,
1822
+ searchIconOpacity: 0.8, // (a softer filter icon, in tune with the edges)
1823
+ },
1824
+ },
1825
+
1826
+ };
1827
+ SmartTable.styles.classic = SmartTable.styles.light; // the old name of light: the pages made with it keep their look
1828
+
1829
+ // The minimal theme (_designs/minimal-theme.htm): small (28 px rows, 30 px titles, a 13 px text), on the ground of the
1830
+ // window with a line around it; no stripes, thin lines between the rows, a soft title over a line, a faint row under
1831
+ // the mouse, a 2 px ink line at the left of the selected row. minimalDark: the same on a dark window.
1832
+ // WHY faint fills for the rows: a row of SmartTable is its cells (a line around a row needs a row box).
1833
+ SmartTable.createMinimalStyle = function (colors) {
1834
+ return {
1835
+ titleHeight: 30,
1836
+ itemHeight: 28,
1837
+ infoHeight: 28,
1838
+ style: Object.assign({
1839
+ round: 4,
1840
+ line1Color: colors.ground,
1841
+ line2Color: colors.ground,
1842
+ highlightItemCellColor: colors.hover,
1843
+ selectedItemCellColor: colors.selected,
1844
+ selectedBar: { width: 2, color: colors.ink },
1845
+ focusRingColor: colors.focus,
1846
+ highlightTitleCellColor: colors.ground,
1847
+ titleUppercase: 0,
1848
+ invertIconColor: colors.invertIcons,
1849
+ sortIcon: { size: 14, opacity: 0.3, activeOpacity: 1 },
1850
+ cellTooltip: { fontSize: 12, color: colors.ground, textColor: colors.text, round: 4, border: 1, borderColor: colors.line, shadow: "none" },
1851
+ box: { color: colors.ground },
1852
+ boxBorder: { border: 1, borderColor: colors.line },
1853
+ boxTitleLine: { color: colors.ground },
1854
+ boxTitleCell: { padding: [10, 0], borderRight: "none", borderBottom: "1px solid " + colors.line },
1855
+ lblTitleCell: { fontSize: 12, fontFamily: "opensans-bold", textColor: colors.softText },
1856
+ boxItemCell: { borderBottom: "1px solid " + colors.track, borderRight: "none", padding: [10, 0] },
1857
+ lblItemCell: { fontSize: 13, textColor: colors.text, fontFamily: "opensans" },
1858
+ boxInfoLine: { color: colors.ground, borderTop: "1px solid " + colors.line },
1859
+ lblBoxInfoLine: { fontSize: 12, textColor: colors.softText },
1860
+ lblNoDataFound: { color: "transparent", textColor: colors.softText, fontSize: 12 },
1861
+ lblSearchTitle: { color: "transparent", textColor: colors.softText, fontSize: 11, border: 0, borderColor: "transparent" }, // WHY no edge: a pill in the 22 px filter box met its edge
1862
+ btnScrollCenter: { color: colors.ground, borderColor: colors.line },
1863
+ btnScrollUp: { color: colors.ground, borderColor: colors.line },
1864
+ btnScrollDown: { color: colors.ground, borderColor: colors.line },
1865
+ }, colors.icons),
1866
+ // WHY its sizes: the filter box of the default is 36 px high, more than the 28 px line of the minimal table
1867
+ searchInputParams: { styleName: colors.minimalName, height: 22, fontSize: 12, searchIconSize: 12, searchIconLeft: 8 },
1868
+ scrollBarParams: { bar_color: colors.scrollBar, bar_mouseOverColor: colors.scrollBar, bar_width: 3 },
1869
+ searchTitleMenuParams: { styleName: colors.minimalName },
1870
+ };
1871
+ };
1872
+ SmartTable.MINIMAL_COLORS = {
1873
+ ground: "#FFFFFF", text: Black(0.85), softText: Black(0.55), line: Black(0.2), track: Black(0.08), hover: Black(0.03),
1874
+ selected: Black(0.06), ink: "#1F1F1F", focus: "#3D8BD9", scrollBar: "#9A9A98", invertIcons: 0, minimalName: "minimal", icons: {},
1875
+ };
1876
+ SmartTable.styles.minimal = SmartTable.createMinimalStyle(SmartTable.MINIMAL_COLORS);
1877
+ SmartTable.MINIMAL_DARK_COLORS = {
1878
+ ground: "#1A1A19", text: White(0.88), softText: White(0.55), line: White(0.18), track: White(0.08), hover: White(0.04),
1879
+ selected: White(0.08), ink: "#EDEDEB", focus: "#7FB6DE", scrollBar: "#A0A0A0", invertIcons: 1, minimalName: "minimalDark",
1880
+ // WHY the icons of dark: invertIconColor turns only the sort and the up / down arrows
1881
+ icons: { btnScrollCenterIconFile: SmartTable.styles.dark.style.btnScrollCenterIconFile, searchTitleCheckIconFile: SmartTable.styles.dark.style.searchTitleCheckIconFile },
1882
+ };
1883
+ SmartTable.styles.minimalDark = SmartTable.createMinimalStyle(SmartTable.MINIMAL_DARK_COLORS);