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,1055 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ Date Picker - v26.11
6
+
7
+ UI COMPONENT TEMPLATE
8
+ - A date picker: a field that opens a calendar panel (popup), or an always visible calendar (inline: 1).
9
+ - Day view and month/year view (click the title).
10
+ - Supports: minDate, maxDate, first day of week, date format, language (en, tr),
11
+ Today/Clear buttons, enabled, keyboard navigation.
12
+ - Everything is drawn with code (no image files needed).
13
+ - Style packages: "light" (default; the old name "classic" works too), "dark", "minimal", "minimalDark" (a package of
14
+ params: its height too). Select with styleName. (DatePicker.styles)
15
+ - scale: multiplies every size (the style, width / height, the field, the calendar and its cells). Its default is
16
+ basic.uiScale: on a page fitted with page.fit() (basic.uiScale = 1 / page.zoom) the field and the calendar keep
17
+ their size on the screen. (Needs basic.js v26.11.01 for a scale other than 1.)
18
+
19
+ Keyboard (when the calendar is focused):
20
+ - Arrow keys: move day, PageUp/PageDown: move month, Enter/Space: select, Escape: close.
21
+
22
+ Started Date: September 2026
23
+ Webpage: https://bug7a.github.io/js-components/
24
+
25
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
26
+ Licensed under the Apache License, Version 2.0
27
+ SPDX-License-Identifier: Apache-2.0
28
+
29
+ */
30
+
31
+ "use strict";
32
+
33
+ // Default values:
34
+ const DatePickerDefaults = {
35
+ key: "0",
36
+ width: 220, // Field width (not used if inline: 1)
37
+ height: 44, // Field height (not used if inline: 1)
38
+ date: null, // Date, "YYYY-MM-DD" or null
39
+ minDate: null, // Date, "YYYY-MM-DD" or null
40
+ maxDate: null, // Date, "YYYY-MM-DD" or null
41
+ format: "DD.MM.YYYY", // Tokens: YYYY, MMMM, MMM, MM, M, DD, D, dddd, ddd
42
+ language: "en", // "en", "tr"
43
+ firstDayOfWeek: 1, // 0: Sunday, 1: Monday
44
+ placeholder: "", // Empty: uses the language text
45
+ inline: 0, // 1: Calendar is always visible, no field.
46
+ scale: null, // Multiplies every size. null: basic.uiScale (1, or 1 / page.zoom on a fitted page). (Only at create time)
47
+ enabled: 1,
48
+ closeOnSelect: 1,
49
+ showTodayButton: 1,
50
+ showClearButton: 1,
51
+ onChange: function (self) { }, // self.date (Date or null), self.value ("YYYY-MM-DD"), self.dateText
52
+ onOpen: function (self) { },
53
+ onClose: function (self) { },
54
+ styleName: "light", // "light" ("classic": its old name), "dark", "minimal", "minimalDark" or a name added to DatePicker.styles
55
+ style: { // Light style package (default)
56
+ field: {
57
+ color: White(1),
58
+ border: 1,
59
+ borderColor: Black(0.2),
60
+ round: 6,
61
+ padding: [12, 0],
62
+ },
63
+ fieldHover: {
64
+ borderColor: Black(0.5),
65
+ },
66
+ fieldFocus: {
67
+ borderColor: "#141414",
68
+ },
69
+ fieldText: {
70
+ fontSize: 16,
71
+ textColor: Black(0.85),
72
+ },
73
+ placeholder: {
74
+ textColor: Black(0.4),
75
+ },
76
+ icon: {
77
+ color: Black(0.55),
78
+ svg: "", // An SVG text drawn in this color (stroke="currentColor"). "": the drawn calendar
79
+ size: 18, // px of the SVG icon
80
+ },
81
+ panel: {
82
+ color: White(1),
83
+ border: 1,
84
+ borderColor: Black(0.12),
85
+ round: 10,
86
+ padding: 12,
87
+ shadow: "0 8px 24px rgba(0, 0, 0, 0.12)",
88
+ },
89
+ title: {
90
+ fontSize: 16,
91
+ textColor: Black(0.85),
92
+ fontFamily: "opensans-bold",
93
+ },
94
+ arrow: {
95
+ color: Black(0.6),
96
+ hoverColor: Black(0.06),
97
+ },
98
+ weekDay: {
99
+ fontSize: 12,
100
+ textColor: Black(0.45),
101
+ },
102
+ day: {
103
+ size: 36,
104
+ round: 100,
105
+ fontSize: 14,
106
+ textColor: Black(0.85),
107
+ hoverColor: Black(0.06),
108
+ },
109
+ today: {
110
+ borderColor: Black(0.35),
111
+ },
112
+ selectedDay: {
113
+ color: "#141414",
114
+ textColor: White(1),
115
+ },
116
+ disabledDay: {
117
+ textColor: Black(0.2),
118
+ },
119
+ footerButton: {
120
+ fontSize: 13,
121
+ textColor: "#3871E0",
122
+ },
123
+ divider: {
124
+ color: Black(0.08), // The line above the footer buttons
125
+ },
126
+ disabled: {
127
+ opacity: 0.4,
128
+ },
129
+ }
130
+ };
131
+
132
+ const DatePicker = function (params = {}) {
133
+
134
+ // Merge style package: params.style > DatePicker.styles[styleName] > DatePickerDefaults.style (light)
135
+ basic.applyStylePackage(params, DatePicker.styles, DatePickerDefaults);
136
+
137
+ // Merge params:
138
+ mergeIntoIfMissing(params, DatePickerDefaults);
139
+
140
+ // Scale: the sizes of the style and of the params are multiplied. (A page fitted with page.fit() sets basic.uiScale.)
141
+ DatePicker.applyScale(params);
142
+
143
+ // Edit params, if needed:
144
+ params.color = "transparent";
145
+ if (params.inline == 1) {
146
+ params.width = "auto";
147
+ params.height = "auto";
148
+ }
149
+
150
+ // BOX: Component container
151
+ let box = startObject(params);
152
+
153
+ // *** PRIVATE VARIABLES:
154
+ const texts = DatePicker.languages[box.language] || DatePicker.languages.en;
155
+ const _s = box.style;
156
+ const daySize = _s.day.size;
157
+ const innerWidth = daySize * 7;
158
+
159
+ let view = "days"; // "days", "months"
160
+ let viewYear, viewMonth; // Visible month
161
+ let focusDate = null; // Keyboard focus in the day view
162
+ let isOpen = 0;
163
+ let isMouseOver = 0;
164
+ let dayCells = [];
165
+ let monthCells = [];
166
+ const scale = box.scale; // The px of the code below are multiplied by it, like the style.
167
+ const PANEL_GAP = 6 * scale; // px between the field and the panel
168
+ const SCREEN_MARGIN = 8 * scale; // px: the panel stays this far from the edges of the page
169
+ const FIELD_GAP = 8 * scale; // Between the date text and the calendar icon
170
+ const PANEL_ROW_GAP = 6 * scale; // Between the header, the week days, the days and the footer
171
+ const HEADER_HEIGHT = 36 * scale;
172
+ const ARROW_BUTTON_SIZE = 32 * scale;
173
+ const ARROW_SIZE = 8 * scale; // The arrow is two borders of a turned square.
174
+ const ARROW_LINE_WIDTH = 2 * scale;
175
+ const ARROW_SHIFT = 3 * scale; // WHY: The turned square is moved to the middle of its button.
176
+ const TITLE_HEIGHT = 32 * scale;
177
+ const TITLE_ROUND = 6 * scale;
178
+ const WEEK_ROW_HEIGHT = 24 * scale;
179
+ const TODAY_BORDER = 1 * scale;
180
+ const MONTH_CELL_HEIGHT = 48 * scale;
181
+ const MONTH_CELL_ROUND = 8 * scale;
182
+ const MONTH_ROW_GAP = 4 * scale;
183
+ const FOOTER_HEIGHT = 38 * scale;
184
+ const FOOTER_SPACE_TOP = 6 * scale; // Between the line and the buttons
185
+ const DIVIDER_WIDTH = 1 * scale; // The line above the footer buttons
186
+ const FOOTER_BUTTON_PADDING = [8 * scale, 2 * scale];
187
+ const FOOTER_BUTTON_ROUND = 4 * scale;
188
+ const OVERLAY_Z_INDEX = 1000;
189
+ const PANEL_Z_INDEX = 1001;
190
+
191
+ // *** PUBLIC VARIABLES:
192
+ // [var] Selected date (Date or null)
193
+ box.date = DatePicker.parse(box.date);
194
+ box.minDate = DatePicker.parse(box.minDate);
195
+ box.maxDate = DatePicker.parse(box.maxDate);
196
+ // [var] "YYYY-MM-DD" or ""
197
+ box.value = "";
198
+ // [var] Formatted text or "" (WHY: not "text", Box.text changes innerHTML)
199
+ box.dateText = "";
200
+
201
+ // *** PRIVATE FUNCTIONS:
202
+
203
+ const dayNumber = function (date) {
204
+ return (date) ? (date.getFullYear() * 10000) + (date.getMonth() * 100) + date.getDate() : 0;
205
+ };
206
+
207
+ const isSameDay = function (a, b) {
208
+ return a && b && dayNumber(a) == dayNumber(b);
209
+ };
210
+
211
+ const isInRange = function (date) {
212
+ if (box.minDate && dayNumber(date) < dayNumber(box.minDate)) return false;
213
+ if (box.maxDate && dayNumber(date) > dayNumber(box.maxDate)) return false;
214
+ return true;
215
+ };
216
+
217
+ const setView = function (year, month) {
218
+ const d = new Date(year, month, 1);
219
+ viewYear = d.getFullYear();
220
+ viewMonth = d.getMonth();
221
+ };
222
+
223
+ const updateValue = function () {
224
+ box.value = (box.date) ? DatePicker.format(box.date, "YYYY-MM-DD") : "";
225
+ box.dateText = (box.date) ? DatePicker.format(box.date, box.format, box.language) : "";
226
+ };
227
+
228
+ const updateField = function () {
229
+
230
+ if (box.inline == 1) return;
231
+
232
+ if (box.date) {
233
+ box.fieldText.plainText = box.dateText;
234
+ box.fieldText.textColor = _s.fieldText.textColor;
235
+ } else {
236
+ box.fieldText.plainText = box.placeholder || texts.placeholder;
237
+ box.fieldText.textColor = _s.placeholder.textColor;
238
+ }
239
+
240
+ let borderColor = _s.field.borderColor;
241
+ if (isMouseOver && box.enabled == 1) borderColor = _s.fieldHover.borderColor;
242
+ if (isOpen) borderColor = _s.fieldFocus.borderColor;
243
+ box.field.borderColor = borderColor;
244
+
245
+ box.opacity = (box.enabled == 1) ? 1 : _s.disabled.opacity;
246
+ box.cursor = (box.enabled == 1) ? "pointer" : "default";
247
+ box.tabIndex = (box.enabled == 1) ? 0 : -1;
248
+ box.aria = {
249
+ expanded: (isOpen) ? "true" : "false",
250
+ disabled: (box.enabled == 1) ? "false" : "true",
251
+ };
252
+
253
+ };
254
+
255
+ const clearCells = function (list) {
256
+ list.forEach(function (cell) { cell.remove(); });
257
+ return [];
258
+ };
259
+
260
+ // Draw an arrow with borders. (direction: -1 left, 1 right)
261
+ const createArrowButton = function (direction) {
262
+
263
+ const isLeft = (direction < 0);
264
+
265
+ const btn = HGroup({
266
+ width: ARROW_BUTTON_SIZE,
267
+ height: ARROW_BUTTON_SIZE,
268
+ round: 100,
269
+ color: "transparent",
270
+ });
271
+ btn.cursor = "pointer";
272
+ btn.setMotion("background-color 0.15s");
273
+
274
+ Box({
275
+ width: ARROW_SIZE,
276
+ height: ARROW_SIZE,
277
+ color: "transparent",
278
+ });
279
+ const arrowLine = ARROW_LINE_WIDTH + "px solid " + _s.arrow.color;
280
+ that.css = {
281
+ borderLeft: arrowLine,
282
+ borderBottom: arrowLine,
283
+ transform: "rotate(" + ((isLeft) ? 45 : 225) + "deg)",
284
+ marginLeft: ((isLeft) ? ARROW_SHIFT : -ARROW_SHIFT) + "px",
285
+ };
286
+
287
+ endGroup();
288
+
289
+ btn.on("mouseover", function () { btn.color = _s.arrow.hoverColor; });
290
+ btn.on("mouseout", function () { btn.color = "transparent"; });
291
+ btn.on("click", function () { moveView(direction); });
292
+
293
+ return btn;
294
+
295
+ };
296
+
297
+ // Move the visible month (days view) or year (months view).
298
+ const moveView = function (direction) {
299
+ if (box.enabled != 1) return;
300
+ if (view == "days") {
301
+ setView(viewYear, viewMonth + direction);
302
+ } else {
303
+ setView(viewYear + direction, viewMonth);
304
+ }
305
+ renderPanel();
306
+ };
307
+
308
+ // A day of the visible month: selected, today, out of the range, keyboard focus.
309
+ const createDayCell = function (date, today) {
310
+
311
+ const selected = isSameDay(date, box.date);
312
+ const enabled = isInRange(date);
313
+ const focused = isSameDay(date, focusDate);
314
+
315
+ const cell = Label({
316
+ width: daySize,
317
+ height: daySize,
318
+ text: String(date.getDate()),
319
+ textAlign: "center",
320
+ fontSize: _s.day.fontSize,
321
+ round: _s.day.round,
322
+ textColor: _s.day.textColor,
323
+ color: "transparent",
324
+ });
325
+ cell.lineHeight = daySize + "px";
326
+ cell.setMotion("background-color 0.15s");
327
+
328
+ if (isSameDay(date, today)) {
329
+ cell.border = TODAY_BORDER;
330
+ cell.borderColor = _s.today.borderColor;
331
+ cell.lineHeight = (daySize - TODAY_BORDER * 2) + "px"; // WHY: The border (at the top and the bottom) is inside the cell.
332
+ }
333
+
334
+ if (selected) {
335
+ cell.color = _s.selectedDay.color;
336
+ cell.textColor = _s.selectedDay.textColor;
337
+ } else if (focused) {
338
+ cell.color = _s.day.hoverColor;
339
+ }
340
+
341
+ if (!enabled) {
342
+ cell.textColor = _s.disabledDay.textColor;
343
+ return cell;
344
+ }
345
+
346
+ cell.cursor = "pointer";
347
+ cell.on("click", function () { selectDate(date); });
348
+ if (!selected) {
349
+ cell.on("mouseover", function () { cell.color = _s.day.hoverColor; });
350
+ cell.on("mouseout", function () {
351
+ cell.color = (isSameDay(date, focusDate)) ? _s.day.hoverColor : "transparent";
352
+ });
353
+ }
354
+
355
+ return cell;
356
+
357
+ };
358
+
359
+ const renderDays = function () {
360
+
361
+ dayCells = clearCells(dayCells);
362
+
363
+ const firstDay = new Date(viewYear, viewMonth, 1).getDay();
364
+ const emptyCount = (firstDay - box.firstDayOfWeek + 7) % 7;
365
+ const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
366
+ const today = new Date();
367
+
368
+ createIn(box.daysBox, function () {
369
+
370
+ // Empty cells before the first day.
371
+ for (let i = 0; i < emptyCount; i++) {
372
+ dayCells.push(Box({ width: daySize, height: daySize, color: "transparent" }));
373
+ }
374
+
375
+ for (let d = 1; d <= daysInMonth; d++) {
376
+ dayCells.push(createDayCell(new Date(viewYear, viewMonth, d), today));
377
+ }
378
+
379
+ });
380
+
381
+ };
382
+
383
+ // A month can be selected if one of its days is in the range.
384
+ const isMonthEnabled = function (month) {
385
+ const first = new Date(viewYear, month, 1);
386
+ const last = new Date(viewYear, month + 1, 0);
387
+ if (isInRange(first) || isInRange(last)) return true;
388
+ // WHY: The whole range can be inside the month (its first and last days are out of it).
389
+ return box.minDate && box.maxDate && dayNumber(first) <= dayNumber(box.minDate) && dayNumber(last) >= dayNumber(box.maxDate);
390
+ };
391
+
392
+ const createMonthCell = function (name, month) {
393
+
394
+ const enabled = isMonthEnabled(month);
395
+ const selected = box.date && box.date.getFullYear() == viewYear && box.date.getMonth() == month;
396
+
397
+ const cell = Label({
398
+ width: Math.floor(innerWidth / 3),
399
+ height: MONTH_CELL_HEIGHT,
400
+ text: name,
401
+ textAlign: "center",
402
+ fontSize: _s.day.fontSize,
403
+ round: MONTH_CELL_ROUND,
404
+ textColor: (enabled) ? _s.day.textColor : _s.disabledDay.textColor,
405
+ color: (selected) ? _s.selectedDay.color : "transparent",
406
+ });
407
+ cell.lineHeight = MONTH_CELL_HEIGHT + "px";
408
+ if (selected) cell.textColor = _s.selectedDay.textColor;
409
+
410
+ if (!enabled) return cell;
411
+
412
+ cell.cursor = "pointer";
413
+ cell.setMotion("background-color 0.15s");
414
+ cell.on("click", function () {
415
+ setView(viewYear, month);
416
+ view = "days";
417
+ renderPanel();
418
+ });
419
+ if (!selected) {
420
+ cell.on("mouseover", function () { cell.color = _s.day.hoverColor; });
421
+ cell.on("mouseout", function () { cell.color = "transparent"; });
422
+ }
423
+
424
+ return cell;
425
+
426
+ };
427
+
428
+ const renderMonths = function () {
429
+
430
+ monthCells = clearCells(monthCells);
431
+
432
+ createIn(box.monthsBox, function () {
433
+ texts.monthsShort.forEach(function (name, month) {
434
+ monthCells.push(createMonthCell(name, month));
435
+ });
436
+ });
437
+
438
+ };
439
+
440
+ const renderPanel = function () {
441
+
442
+ if (view == "days") {
443
+ box.title.plainText = texts.months[viewMonth] + " " + viewYear;
444
+ box.weekRow.visible = 1;
445
+ box.daysBox.visible = 1;
446
+ box.monthsBox.visible = 0;
447
+ renderDays();
448
+ } else {
449
+ box.title.plainText = String(viewYear);
450
+ box.weekRow.visible = 0;
451
+ box.daysBox.visible = 0;
452
+ box.monthsBox.visible = 1;
453
+ renderMonths();
454
+ }
455
+
456
+ box.todayButton.visible = (box.showTodayButton == 1 && isInRange(new Date())) ? 1 : 0;
457
+ box.clearButton.visible = (box.showClearButton == 1 && box.date) ? 1 : 0;
458
+ box.footer.visible = (box.showTodayButton == 1 || box.showClearButton == 1) ? 1 : 0;
459
+
460
+ if (box.inline == 1) {
461
+ box.panel.opacity = (box.enabled == 1) ? 1 : _s.disabled.opacity;
462
+ box.panel.clickable = (box.enabled == 1) ? 1 : 0;
463
+ }
464
+
465
+ };
466
+
467
+ // User selected a date. (click, Enter, Today)
468
+ const selectDate = function (date) {
469
+ if (box.enabled != 1) return;
470
+ box.setDate(date);
471
+ if (box.inline != 1 && box.closeOnSelect == 1) {
472
+ box.close();
473
+ box.elem.focus();
474
+ }
475
+ };
476
+
477
+ // Position the popup panel under (or above) the field.
478
+ const positionPanel = function () {
479
+
480
+ const rect = box.elem.getBoundingClientRect();
481
+ const panelWidth = box.panel.elem.offsetWidth;
482
+ const panelHeight = box.panel.elem.offsetHeight;
483
+
484
+ let left = withPageZoom(rect.left);
485
+ let top = withPageZoom(rect.bottom) + PANEL_GAP;
486
+
487
+ if (top + panelHeight > page.height - SCREEN_MARGIN) {
488
+ top = withPageZoom(rect.top) - panelHeight - PANEL_GAP; // Open above
489
+ }
490
+ top = Math.max(SCREEN_MARGIN, top);
491
+ left = Math.max(SCREEN_MARGIN, Math.min(left, page.width - panelWidth - SCREEN_MARGIN));
492
+
493
+ box.panel.left = left;
494
+ box.panel.top = top;
495
+
496
+ };
497
+
498
+ const onPageResize = function () {
499
+ if (isOpen) box.close();
500
+ };
501
+
502
+ const onKeyDown = function (self, event) {
503
+
504
+ if (box.enabled != 1) return;
505
+
506
+ // Field is focused and panel is closed:
507
+ if (box.inline != 1 && !isOpen) {
508
+ if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown") {
509
+ event.preventDefault();
510
+ box.open();
511
+ }
512
+ return;
513
+ }
514
+
515
+ if (event.key === "Escape") {
516
+ event.preventDefault();
517
+ if (view == "months") {
518
+ view = "days";
519
+ renderPanel();
520
+ } else if (box.inline != 1) {
521
+ box.close();
522
+ box.elem.focus();
523
+ }
524
+ return;
525
+ }
526
+
527
+ if (view != "days") return;
528
+
529
+ const moves = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 };
530
+ let next = null;
531
+
532
+ if (moves[event.key]) {
533
+ next = new Date(focusDate.getFullYear(), focusDate.getMonth(), focusDate.getDate() + moves[event.key]);
534
+ } else if (event.key === "PageUp" || event.key === "PageDown") {
535
+ next = new Date(focusDate.getFullYear(), focusDate.getMonth() + ((event.key === "PageUp") ? -1 : 1), 1);
536
+ } else if (event.key === "Enter" || event.key === " ") {
537
+ event.preventDefault();
538
+ if (isInRange(focusDate)) selectDate(focusDate);
539
+ return;
540
+ } else {
541
+ return;
542
+ }
543
+
544
+ event.preventDefault();
545
+ focusDate = next;
546
+ setView(focusDate.getFullYear(), focusDate.getMonth());
547
+ renderPanel();
548
+
549
+ };
550
+
551
+ // *** PUBLIC FUNCTIONS:
552
+
553
+ box.setDate = function (date, silent = 0) {
554
+
555
+ const newDate = DatePicker.parse(date);
556
+ if (newDate && !isInRange(newDate)) return false;
557
+ if (dayNumber(newDate) == dayNumber(box.date)) return true;
558
+
559
+ box.date = newDate;
560
+ updateValue();
561
+
562
+ if (newDate) {
563
+ focusDate = new Date(newDate);
564
+ setView(newDate.getFullYear(), newDate.getMonth());
565
+ }
566
+
567
+ updateField();
568
+ renderPanel();
569
+
570
+ if (!silent) box.onChange(box);
571
+ return true;
572
+
573
+ };
574
+ // USAGE: picker.setDate("2026-09-14"), picker.setDate(new Date()), picker.setDate(null)
575
+ // NOTE: setDate(date, 1) changes the value without calling onChange. Returns false if out of range.
576
+
577
+ box.getDate = function () {
578
+ return (box.date) ? new Date(box.date) : null;
579
+ };
580
+
581
+ box.open = function () {
582
+
583
+ if (box.inline == 1 || isOpen || box.enabled != 1) return;
584
+ isOpen = 1;
585
+
586
+ view = "days";
587
+ focusDate = (box.date) ? new Date(box.date) : new Date();
588
+ setView(focusDate.getFullYear(), focusDate.getMonth());
589
+ renderPanel();
590
+
591
+ // WHY at open: a field in a Dialog or a SidePanel (their layer is over 1001) opens its list over them
592
+ const layerZIndex = basic.zIndexAbove(box, OVERLAY_Z_INDEX);
593
+ box.overlay.zIndex = layerZIndex;
594
+ box.panel.zIndex = layerZIndex + 1;
595
+ box.overlay.visible = 1;
596
+ box.panel.visible = 1;
597
+ positionPanel();
598
+ box.panel.elem.focus();
599
+
600
+ updateField();
601
+ box.onOpen(box);
602
+
603
+ };
604
+
605
+ box.close = function () {
606
+
607
+ if (box.inline == 1 || !isOpen) return;
608
+ isOpen = 0;
609
+
610
+ box.overlay.visible = 0;
611
+ box.panel.visible = 0;
612
+
613
+ updateField();
614
+ box.onClose(box);
615
+
616
+ };
617
+
618
+ box.toggle = function () {
619
+ (isOpen) ? box.close() : box.open();
620
+ };
621
+
622
+ box.isOpen = function () {
623
+ return isOpen;
624
+ };
625
+
626
+ box.setEnabled = function (enabled) {
627
+ box.enabled = basic.isOn(enabled) ? 1 : 0;
628
+ if (box.enabled != 1) box.close();
629
+ updateField();
630
+ renderPanel();
631
+ };
632
+ // USAGE: get: picker.enabled, set: picker.setEnabled(0)
633
+
634
+ box.setMinDate = function (date) {
635
+ box.minDate = DatePicker.parse(date);
636
+ renderPanel();
637
+ };
638
+
639
+ box.setMaxDate = function (date) {
640
+ box.maxDate = DatePicker.parse(date);
641
+ renderPanel();
642
+ };
643
+
644
+ box.refresh = function () {
645
+ updateValue();
646
+ updateField();
647
+ renderPanel();
648
+ };
649
+
650
+
651
+ // *** OBJECT VIEW:
652
+ box.css = { outline: "none", userSelect: "none" };
653
+
654
+ // FIELD: (only popup mode)
655
+ if (box.inline != 1) {
656
+
657
+ box.clickable = 1;
658
+ box.role = "combobox";
659
+
660
+ box.field = HGroup({
661
+ width: "100%",
662
+ height: "100%",
663
+ align: "left center",
664
+ gap: FIELD_GAP,
665
+ ..._s.field,
666
+ });
667
+ box.field.setMotion("border-color 0.15s");
668
+
669
+ // LABEL: Selected date text
670
+ box.fieldText = Label({
671
+ width: "auto",
672
+ fontSize: _s.fieldText.fontSize,
673
+ textColor: _s.fieldText.textColor,
674
+ });
675
+ that.css = { whiteSpace: "nowrap", textOverflow: "ellipsis" };
676
+ that.grow = 1;
677
+
678
+ // BOX: Calendar icon: the SVG of the style, or drawn (a box, a bar at its top and two dots, in the px of an 18 px icon)
679
+ if (_s.icon.svg) {
680
+ box.icon = Box({ width: _s.icon.size, height: _s.icon.size, color: "transparent", textColor: _s.icon.color });
681
+ box.icon.elem.innerHTML = _s.icon.svg;
682
+ } else {
683
+ box.icon = startBox({
684
+ width: 18 * scale,
685
+ height: 18 * scale,
686
+ color: "transparent",
687
+ border: 2 * scale,
688
+ borderColor: _s.icon.color,
689
+ round: 4 * scale,
690
+ });
691
+ Box({ left: 0, top: 3 * scale, width: "100%", height: 2 * scale, color: _s.icon.color });
692
+ Box({ left: 3 * scale, top: 8 * scale, width: 3 * scale, height: 3 * scale, color: _s.icon.color });
693
+ Box({ left: 8 * scale, top: 8 * scale, width: 3 * scale, height: 3 * scale, color: _s.icon.color });
694
+ endBox();
695
+ }
696
+ box.icon.shrink = 0;
697
+
698
+ endGroup();
699
+
700
+ }
701
+
702
+ // POPUP: Create the overlay and the panel on the page, over everything.
703
+ // WHY: Creating them directly on the page is safer than moving them later.
704
+ if (box.inline != 1) {
705
+
706
+ setDefaultContainerBox(page);
707
+ // NOTE: endGroup() of the panel below returns the default container to the component box.
708
+
709
+ // BOX: Transparent overlay (click outside: close)
710
+ // WHY a very big box and not 100% x 100%: with position "fixed" the "100%" is taken from the nearest parent
711
+ // that has a zoom or a transform (page.fit); there the overlay had no height and a click outside the
712
+ // panel did not close it (the same fix as SelectBox).
713
+ const OVERLAY_SIZE = 20000; // px
714
+ box.overlay = Box(-OVERLAY_SIZE, -OVERLAY_SIZE, OVERLAY_SIZE * 2, OVERLAY_SIZE * 2, { color: "transparent" });
715
+ box.overlay.css.position = "fixed";
716
+ box.overlay.zIndex = OVERLAY_Z_INDEX;
717
+ box.overlay.on("click", function () { box.close(); });
718
+
719
+ }
720
+
721
+ // BOX: Calendar panel
722
+ box.panel = VGroup({
723
+ width: innerWidth + (_s.panel.padding * 2) + (_s.panel.border * 2),
724
+ height: "auto",
725
+ align: "left top",
726
+ gap: PANEL_ROW_GAP,
727
+ color: _s.panel.color,
728
+ border: _s.panel.border,
729
+ borderColor: _s.panel.borderColor,
730
+ round: _s.panel.round,
731
+ padding: _s.panel.padding,
732
+ });
733
+ box.panel.boxShadow = _s.panel.shadow;
734
+ box.panel.css.outline = "none";
735
+ box.panel.tabIndex = -1;
736
+ box.panel.clickable = 1;
737
+ box.panel.role = "dialog";
738
+
739
+ // GROUP: Header (prev, title, next)
740
+ HGroup({
741
+ width: innerWidth,
742
+ height: HEADER_HEIGHT,
743
+ align: "center",
744
+ });
745
+
746
+ box.prevButton = createArrowButton(-1);
747
+
748
+ // LABEL: Month and year (click: months view)
749
+ box.title = Label({
750
+ width: innerWidth - (ARROW_BUTTON_SIZE * 2),
751
+ height: TITLE_HEIGHT,
752
+ textAlign: "center",
753
+ round: TITLE_ROUND,
754
+ ..._s.title,
755
+ });
756
+ box.title.lineHeight = TITLE_HEIGHT + "px";
757
+ box.title.cursor = "pointer";
758
+ box.title.setMotion("background-color 0.15s");
759
+ box.title.on("click", function () {
760
+ if (box.enabled != 1) return;
761
+ view = (view == "days") ? "months" : "days";
762
+ renderPanel();
763
+ });
764
+ box.title.on("mouseover", function () { box.title.color = _s.arrow.hoverColor; });
765
+ box.title.on("mouseout", function () { box.title.color = "transparent"; });
766
+
767
+ box.nextButton = createArrowButton(1);
768
+
769
+ endGroup();
770
+
771
+ // GROUP: Week days
772
+ box.weekRow = HGroup({
773
+ width: innerWidth,
774
+ height: WEEK_ROW_HEIGHT,
775
+ });
776
+
777
+ for (let i = 0; i < 7; i++) {
778
+ Label({
779
+ width: daySize,
780
+ text: texts.weekDaysShort[(i + box.firstDayOfWeek) % 7],
781
+ textAlign: "center",
782
+ ..._s.weekDay,
783
+ });
784
+ }
785
+
786
+ endGroup();
787
+
788
+ // GROUP: Days (created by renderDays)
789
+ box.daysBox = AutoLayout({
790
+ width: innerWidth,
791
+ height: "auto",
792
+ align: "left top",
793
+ flexWrap: "wrap",
794
+ });
795
+ endGroup();
796
+
797
+ // GROUP: Months (created by renderMonths)
798
+ box.monthsBox = AutoLayout({
799
+ width: innerWidth,
800
+ height: "auto",
801
+ align: "left top",
802
+ flexWrap: "wrap",
803
+ rowGap: MONTH_ROW_GAP + "px",
804
+ });
805
+ endGroup();
806
+
807
+ // GROUP: Footer (Today, Clear)
808
+ box.footer = HGroup({
809
+ width: innerWidth,
810
+ height: FOOTER_HEIGHT,
811
+ justifyContent: "space-between",
812
+ alignItems: "center",
813
+ });
814
+ box.footer.css = {
815
+ borderTop: DIVIDER_WIDTH + "px solid " + _s.divider.color,
816
+ paddingTop: FOOTER_SPACE_TOP + "px",
817
+ };
818
+
819
+ box.todayButton = Label({
820
+ text: texts.today,
821
+ padding: FOOTER_BUTTON_PADDING,
822
+ round: FOOTER_BUTTON_ROUND,
823
+ ..._s.footerButton,
824
+ });
825
+ box.todayButton.cursor = "pointer";
826
+ box.todayButton.on("click", function () { selectDate(new Date()); });
827
+
828
+ box.clearButton = Label({
829
+ text: texts.clear,
830
+ padding: FOOTER_BUTTON_PADDING,
831
+ round: FOOTER_BUTTON_ROUND,
832
+ ..._s.footerButton,
833
+ });
834
+ box.clearButton.cursor = "pointer";
835
+ box.clearButton.css.marginLeft = "auto";
836
+ box.clearButton.on("click", function () {
837
+ box.setDate(null);
838
+ if (box.inline != 1) {
839
+ box.close();
840
+ box.elem.focus();
841
+ }
842
+ });
843
+
844
+ endGroup();
845
+
846
+ endGroup();
847
+
848
+ if (box.inline != 1) {
849
+ box.panel.zIndex = PANEL_Z_INDEX;
850
+ box.overlay.visible = 0;
851
+ box.panel.visible = 0;
852
+ }
853
+
854
+ // *** OBJECT INIT CODE:
855
+
856
+ if (box.inline != 1) {
857
+
858
+ box.on("click", function () { box.toggle(); });
859
+ box.on("keydown", onKeyDown);
860
+
861
+ box.on("mouseover", function () {
862
+ isMouseOver = 1;
863
+ updateField();
864
+ });
865
+
866
+ box.on("mouseout", function () {
867
+ isMouseOver = 0;
868
+ updateField();
869
+ });
870
+
871
+ // (onPageResize / own: the overlay and the panel are on the page, they are removed with the box)
872
+ box.onPageResize(onPageResize);
873
+ box.own(box.overlay);
874
+ box.own(box.panel);
875
+
876
+ } else {
877
+ box.panel.tabIndex = 0;
878
+ // WHY: Component size is "auto". A relative panel makes the container wrap it.
879
+ box.panel.position = "relative";
880
+ }
881
+
882
+ box.panel.on("keydown", onKeyDown);
883
+ // WHY: Keep the keyboard focus on the panel when a day is clicked.
884
+ box.panel.on("mousedown", function (self, event) { event.preventDefault(); });
885
+
886
+ const startDate = box.date || new Date();
887
+ focusDate = new Date(startDate);
888
+ setView(startDate.getFullYear(), startDate.getMonth());
889
+ box.enabled = basic.isOn(box.enabled) ? 1 : 0;
890
+
891
+ updateValue();
892
+ updateField();
893
+ renderPanel();
894
+
895
+ return endObject(box);
896
+
897
+ };
898
+
899
+ // *** STATIC FUNCTIONS AND DATA:
900
+
901
+ // scale: every size of the style and of the size params is multiplied (params is changed). Scale 1 changes nothing.
902
+ // WHY: The default (null) is read when a date picker is made, not when this file is loaded: the page sets
903
+ // basic.uiScale later (page.fit(600, 800); basic.uiScale = 1 / page.zoom).
904
+ DatePicker.applyScale = function (params) {
905
+ const givenScale = Number(params.scale);
906
+ params.scale = (givenScale > 0) ? givenScale : (basic.uiScale || 1);
907
+ if (params.scale === 1) return;
908
+ params.style = basic.scaleStyle(params.style, params.scale);
909
+ params.style.panel.shadow = basic.scaleCssText(params.style.panel.shadow, params.scale);
910
+ // WHY: Whole px: a browser that rounds the width of every cell could make 7 cells wider than their row (7 x size),
911
+ // and the last day of a week would go to the next row.
912
+ params.style.day.size = Math.round(params.style.day.size);
913
+ ["width", "height"].forEach(function (name) {
914
+ params[name] = basic.scaleSize(params[name], params.scale);
915
+ });
916
+ };
917
+
918
+ DatePicker.languages = {
919
+ en: {
920
+ months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
921
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
922
+ weekDays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
923
+ weekDaysShort: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
924
+ placeholder: "Select date",
925
+ today: "Today",
926
+ clear: "Clear",
927
+ },
928
+ tr: {
929
+ months: ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"],
930
+ monthsShort: ["Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"],
931
+ weekDays: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"],
932
+ weekDaysShort: ["Pz", "Pt", "Sa", "Ça", "Pe", "Cu", "Ct"],
933
+ placeholder: "Tarih seçin",
934
+ today: "Bugün",
935
+ clear: "Temizle",
936
+ },
937
+ };
938
+ // NOTE: Add a new language: DatePicker.languages.de = { ... }
939
+
940
+ // Converts Date or "YYYY-MM-DD" to a Date (time: 00:00). Returns null if not valid.
941
+ DatePicker.parse = function (value) {
942
+
943
+ if (!value) return null;
944
+
945
+ if (value instanceof Date) {
946
+ return (isNaN(value)) ? null : new Date(value.getFullYear(), value.getMonth(), value.getDate());
947
+ }
948
+
949
+ const match = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(String(value).trim());
950
+ if (!match) return null;
951
+
952
+ const date = new Date(basic.num(match[1]), basic.num(match[2]) - 1, basic.num(match[3]));
953
+ // WHY: new Date(2026, 1, 31) becomes March 3. Invalid dates are not accepted.
954
+ if (date.getMonth() != basic.num(match[2]) - 1) return null;
955
+
956
+ return date;
957
+
958
+ };
959
+ // USAGE: DatePicker.parse("2026-09-14")
960
+
961
+ // Formats a date. Tokens: YYYY, MMMM, MMM, MM, M, DD, D, dddd, ddd
962
+ DatePicker.format = function (date, format = "DD.MM.YYYY", language = "en") {
963
+
964
+ if (!date) return "";
965
+ const texts = DatePicker.languages[language] || DatePicker.languages.en;
966
+
967
+ const tokens = {
968
+ YYYY: String(date.getFullYear()),
969
+ MMMM: texts.months[date.getMonth()],
970
+ MMM: texts.monthsShort[date.getMonth()],
971
+ MM: String(basic.twoDigitFormat(date.getMonth() + 1)),
972
+ M: String(date.getMonth() + 1),
973
+ DD: String(basic.twoDigitFormat(date.getDate())),
974
+ D: String(date.getDate()),
975
+ dddd: texts.weekDays[date.getDay()],
976
+ ddd: texts.weekDaysShort[date.getDay()],
977
+ };
978
+
979
+ return format.replace(/YYYY|MMMM|MMM|MM|M|DD|D|dddd|ddd/g, function (token) {
980
+ return tokens[token];
981
+ });
982
+
983
+ };
984
+ // USAGE: DatePicker.format(new Date(), "D MMMM YYYY, dddd", "tr")
985
+
986
+ // *** STYLE PACKAGES:
987
+ // USAGE: DatePicker({ styleName: "dark" })
988
+ // USAGE: DatePicker({ styleName: "dark", style: { field: { round: 4 } } }) // Change only some keys.
989
+ // USAGE: DatePicker({ style: DatePicker.styles.dark }) // The same as styleName: "dark". (The package is copied, never changed.)
990
+ // NOTE: A new package needs only the keys that differ from the default (classic) style.
991
+ // USAGE: DatePicker.styles.myStyle = { field: { round: 4 } };
992
+ DatePicker.styles = {
993
+
994
+ // White, dark text, a soft line.
995
+ light: DatePickerDefaults.style,
996
+
997
+ // Dark theme, same colors as SelectBox "dark".
998
+ dark: {
999
+ field: { color: "#232322", borderColor: "rgba(255, 255, 255, 0.10)", round: 8 },
1000
+ fieldHover: { borderColor: "rgba(255, 255, 255, 0.30)" },
1001
+ fieldFocus: { borderColor: "#65A293" },
1002
+ fieldText: { fontSize: 15, textColor: "rgba(255, 255, 255, 0.90)" },
1003
+ placeholder: { textColor: "rgba(255, 255, 255, 0.40)" },
1004
+ icon: { color: "rgba(255, 255, 255, 0.55)" },
1005
+ panel: { color: "#232322", borderColor: "rgba(255, 255, 255, 0.12)", shadow: "0 8px 24px rgba(0, 0, 0, 0.5)" },
1006
+ title: { textColor: "rgba(255, 255, 255, 0.90)" },
1007
+ arrow: { color: "rgba(255, 255, 255, 0.60)", hoverColor: "rgba(255, 255, 255, 0.08)" },
1008
+ weekDay: { textColor: "rgba(255, 255, 255, 0.45)" },
1009
+ day: { textColor: "rgba(255, 255, 255, 0.85)", hoverColor: "rgba(255, 255, 255, 0.08)" },
1010
+ today: { borderColor: "rgba(255, 255, 255, 0.35)" },
1011
+ selectedDay: { color: "#3D7A6B", textColor: "#FFFFFF" },
1012
+ disabledDay: { textColor: "rgba(255, 255, 255, 0.20)" },
1013
+ footerButton: { textColor: "#65A293" },
1014
+ divider: { color: "rgba(255, 255, 255, 0.08)" },
1015
+ },
1016
+
1017
+ };
1018
+ DatePicker.styles.classic = DatePicker.styles.light; // the old name of light: the pages made with it keep their look
1019
+
1020
+ // The line calendar of the minimal field (24 x 24 drawing, as the icons of the minimal SearchInput)
1021
+ DatePicker.MINIMAL_ICON = '<svg viewBox="0 0 24 24" width="100%" height="100%" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style="display: block">' +
1022
+ '<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4"/></svg>';
1023
+
1024
+ // The minimal theme (_designs/minimal-theme.htm): a 28 px field as the other minimal fields (a line of 3:1 at least,
1025
+ // a 13 px text, a 14 px line icon); the calendar on the ground of the window with a line and no shadow, 28 px days:
1026
+ // a line around today, the chosen day in ink (the one fill), a faint fill under the mouse. minimalDark: the same on a
1027
+ // dark window.
1028
+ DatePicker.createMinimalStyle = function (colors) {
1029
+ return {
1030
+ height: 28,
1031
+ style: {
1032
+ field: { color: "transparent", border: 1, borderColor: colors.edge, round: 4, padding: [10, 0] },
1033
+ fieldHover: { borderColor: colors.edgeHover },
1034
+ fieldFocus: { borderColor: colors.ink },
1035
+ fieldText: { fontSize: 13, textColor: colors.text },
1036
+ placeholder: { textColor: colors.faintText },
1037
+ icon: { color: colors.softText, svg: DatePicker.MINIMAL_ICON, size: 14 },
1038
+ panel: { color: colors.ground, border: 1, borderColor: colors.line, round: 4, padding: 8, shadow: "none" },
1039
+ title: { fontSize: 13, textColor: colors.text, fontFamily: "opensans-bold" },
1040
+ arrow: { color: colors.softText, hoverColor: colors.hover },
1041
+ weekDay: { fontSize: 11, textColor: colors.softText },
1042
+ day: { size: 28, round: 4, fontSize: 12, textColor: colors.text, hoverColor: colors.hover },
1043
+ today: { borderColor: colors.edge },
1044
+ selectedDay: { color: colors.ink, textColor: colors.onInk },
1045
+ disabledDay: { textColor: colors.off },
1046
+ footerButton: { fontSize: 12, textColor: colors.ink },
1047
+ divider: { color: colors.line },
1048
+ disabled: { opacity: 0.4 },
1049
+ },
1050
+ };
1051
+ };
1052
+ DatePicker.MINIMAL_COLORS = { ground: "#FFFFFF", text: Black(0.85), softText: Black(0.55), faintText: Black(0.54), line: Black(0.2), edge: Black(0.45), edgeHover: Black(0.65), ink: "#1F1F1F", onInk: "#FFFFFF", hover: Black(0.05), off: Black(0.25) };
1053
+ DatePicker.styles.minimal = DatePicker.createMinimalStyle(DatePicker.MINIMAL_COLORS);
1054
+ DatePicker.MINIMAL_DARK_COLORS = { ground: "#1A1A19", text: White(0.88), softText: White(0.55), faintText: White(0.48), line: White(0.18), edge: White(0.42), edgeHover: White(0.62), ink: "#EDEDEB", onInk: "#1A1A19", hover: White(0.07), off: White(0.25) };
1055
+ DatePicker.styles.minimalDark = DatePicker.createMinimalStyle(DatePicker.MINIMAL_DARK_COLORS);