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,616 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ Side Panel - v26.09
6
+
7
+ UI COMPONENT
8
+ - A panel (drawer / sheet) that slides in from a side of the screen, over the page.
9
+ - side: "right", "left", "bottom" or "top". The size is the width or the height.
10
+ - It is always created on the page (or in its container), whatever container is open when it is
11
+ called, so it is never clipped by a group or by a scrolling box.
12
+ - container: a box (Ex: the 600 px column of a mobile app in the middle of a wide screen). The panel
13
+ and its backdrop are made in it, sized by it instead of the page and they follow its size. Nothing
14
+ outside it is covered. The box clips its content (the default of a Box) and does not scroll.
15
+ - Its own backdrop darkens the page (or the container). A click on it closes the panel. (closeOnBackdrop)
16
+ - ESC closes the open panel. (closeOnEscape)
17
+ - exclusive: 1 -> Opening a panel closes the one that is already open.
18
+ - The panel never covers the whole screen: it keeps screenMargin pixels free on a small screen.
19
+ - fade: 1 -> The panel fades in / out with its slide. 0 -> It only slides. (The backdrop always fades.)
20
+ - style.panel.round: the corners that face the page are round (a right panel: its left corners,
21
+ a bottom sheet: its top corners).
22
+ - The content goes into the body with startBody() ... endBody(). The body scrolls when it is tall.
23
+ - onBeforeClose can stop the closing. (Ex: unsaved changes.)
24
+ - Everything is drawn with code (no image files needed). Accessibility: role="dialog", aria-modal.
25
+ - Style packages: "light" (default; the old name "classic" works too), "modern", "dark", "minimal", "minimalDark".
26
+ Select with styleName. (SidePanel.styles)
27
+
28
+ USAGE:
29
+ const panel = SidePanel({ side: "right", titleText: "Filters" });
30
+ panel.startBody();
31
+ Label({ text: "The content of the panel" });
32
+ panel.endBody();
33
+
34
+ button.on("click", panel.open);
35
+
36
+ SidePanel({ side: "bottom", panelSize: 280, styleName: "dark", titleText: "Share" });
37
+ SidePanel({ side: "left", panelSize: 320, showBackdrop: 0, onClose: (self) => println("closed") });
38
+ SidePanel({ container: appColumn, side: "bottom", panelSize: 300, style: { panel: { round: 13 } } });
39
+ SidePanel({ container: appColumn, side: "right", fade: 0, duration: 200 }); // It only slides.
40
+ panel.setTitleText("Filters (3)");
41
+ panel.remove(); // Also removes its backdrop and its window events.
42
+
43
+ Started Date: September 2026
44
+ Webpage: https://bug7a.github.io/js-components/
45
+
46
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
47
+ Licensed under the Apache License, Version 2.0
48
+ SPDX-License-Identifier: Apache-2.0
49
+
50
+ */
51
+
52
+ "use strict";
53
+
54
+ // Default values:
55
+ const SidePanelDefaults = {
56
+ key: "0",
57
+ side: "right", // "right", "left", "bottom", "top" (Only at create time)
58
+ container: null, // null: the page. A box: the panel and its backdrop are made in it. (Only at create time)
59
+ panelSize: 420, // Width of a left/right panel, height of a top/bottom panel.
60
+ screenMargin: 60, // The panel never comes closer than this to the opposite edge (of the page or the container).
61
+ duration: 300, // Length of the animation, in milliseconds.
62
+ fade: 1, // 1: The panel fades in / out with its slide. 0: It only slides. (The backdrop always fades.) (Only at create time)
63
+ titleText: "",
64
+ allowHtml: 0, // 1: titleText is HTML (only for your own texts)
65
+ showHeader: 1, // 0: No header. (The close button goes with it.)
66
+ showCloseButton: 1,
67
+ showBackdrop: 1,
68
+ closeOnBackdrop: 1,
69
+ closeOnEscape: 1,
70
+ exclusive: 1, // 1: Opening this panel closes the other open panel.
71
+ opened: 0, // 1: Open when it is created. (No animation.)
72
+ ariaLabel: "Panel",
73
+ onOpen: function (self) { },
74
+ onClose: function (self) { },
75
+ onBeforeClose: function (self) { }, // Return false to keep the panel open.
76
+ styleName: "light", // "light" ("classic": its old name), "modern", "dark", "minimal", "minimalDark" or a name added to SidePanel.styles
77
+ style: { // Light style package (default)
78
+ panel: {
79
+ color: White(1),
80
+ border: 1,
81
+ borderColor: Black(0.12),
82
+ boxShadow: "0 0 40px rgba(0, 0, 0, 0.18)",
83
+ round: 0, // The corners that face the page. (A right panel: top-left and bottom-left) (Only at create time)
84
+ },
85
+ header: {
86
+ height: 62,
87
+ color: "transparent",
88
+ padding: [24, 0],
89
+ dividerColor: Black(0.1),
90
+ },
91
+ title: {
92
+ fontSize: 18,
93
+ textColor: Black(0.8),
94
+ fontFamily: "opensans-bold",
95
+ },
96
+ closeButton: {
97
+ size: 34,
98
+ color: "transparent",
99
+ hoverColor: Black(0.07),
100
+ iconColor: Black(0.55),
101
+ round: 17,
102
+ },
103
+ body: {
104
+ padding: [24, 20],
105
+ gap: 14,
106
+ },
107
+ backdrop: {
108
+ color: Black(0.35),
109
+ },
110
+ },
111
+ };
112
+
113
+ const SidePanel = function (params = {}) {
114
+
115
+ // Merge style package: params.style > SidePanel.styles[styleName] > SidePanelDefaults.style (light)
116
+ basic.applyStylePackage(params, SidePanel.styles, SidePanelDefaults);
117
+
118
+ // Merge params:
119
+ mergeIntoIfMissing(params, SidePanelDefaults);
120
+
121
+ let box = null;
122
+ let backdrop = null;
123
+
124
+ // The box the panel lives in: its container, or the page.
125
+ const area = params.container || page;
126
+ const isOnPage = (area === page);
127
+
128
+ // WHY: A drawer covers the page (or its container). Wherever it is called from, it is created
129
+ // there, so a group or a scrolling box can never clip it.
130
+ // NOTE: createIn() can NOT be used here: it puts the container back when its function ends, and
131
+ // startObject() would then be inside it while endObject() is outside. The objects of the
132
+ // view would be created in the container of the caller. The container is put back by hand
133
+ // after endObject(), at the end of this function.
134
+ const previousContainer = getDefaultContainerBox();
135
+ setDefaultContainerBox(area);
136
+
137
+ // BOX: The backdrop is created first, so it stays behind the panel.
138
+ if (params.showBackdrop == 1) {
139
+ backdrop = Box(0, 0, "100%", "100%", {
140
+ color: params.style.backdrop.color,
141
+ opacity: 0,
142
+ visible: 0,
143
+ clickable: 1,
144
+ zIndex: SidePanel.Z_INDEX,
145
+ });
146
+ // WHY: In a group (HGroup / VGroup) a new object is a flex item. The backdrop covers it instead.
147
+ if (!isOnPage) backdrop.position = "absolute";
148
+ }
149
+
150
+ // BOX: Component container. This is the box that slides.
151
+ box = startObject(params);
152
+
153
+ const _s = box.style;
154
+
155
+ // *** PRIVATE VARIABLES:
156
+
157
+ let size = box.panelSize; // The size that is really used. (See layout().)
158
+ let cancelClose = null; // (box.after: stopped by remove())
159
+ const bodyStack = []; // For startBody() / endBody()
160
+ const MIN_PANEL_SIZE = 120;
161
+ const OPEN_TRANSFORM = "translate(0px, 0px)";
162
+
163
+ // *** PRIVATE FUNCTIONS:
164
+
165
+ const setText = function (label, text) {
166
+ const value = (text === undefined || text === null) ? "" : String(text);
167
+ if (box.allowHtml == 1) label.text = value;
168
+ else label.plainText = value;
169
+ };
170
+
171
+ const isVertical = function () {
172
+ return (box.side === "bottom" || box.side === "top");
173
+ };
174
+
175
+ // The room of the panel along its side: the page, or the inside of its container.
176
+ const getAreaSize = function () {
177
+
178
+ // WHY page.width / page.height: with page.fit() the page is zoomed; window.innerWidth is not in its px
179
+ // (a 450 px menu on a page fitted to 600 px was cut to 330 on a 390 px phone)
180
+ if (isOnPage) return (isVertical()) ? page.height : page.width;
181
+
182
+ // WHY without the border: the panel is placed inside the border of its container.
183
+ const borderSize = (area.border || 0) * 2;
184
+ if (isVertical()) return area.height - borderSize;
185
+ return area.width - borderSize;
186
+
187
+ };
188
+
189
+ // Puts the panel on its side and keeps it inside the screen (or its container).
190
+ const layout = function () {
191
+
192
+ // WHY: The size watcher of the container can call it once more in the same round after remove().
193
+ if (!box) return;
194
+
195
+ // WHY: A 420 px panel does not fit on a phone. It never covers the whole screen.
196
+ size = Math.max(MIN_PANEL_SIZE, Math.min(box.panelSize, getAreaSize() - box.screenMargin));
197
+
198
+ if (box.side === "bottom") box.props({ left: 0, bottom: 0, width: "100%", height: size });
199
+ else if (box.side === "top") box.props({ left: 0, top: 0, width: "100%", height: size });
200
+ else if (box.side === "left") box.props({ left: 0, top: 0, width: size, height: "100%" });
201
+ else box.props({ right: 0, top: 0, width: size, height: "100%" });
202
+
203
+ if (box.isOpened === 0) box.css.transform = getHiddenTransform();
204
+
205
+ };
206
+
207
+ // The panel follows the size of the page (a resize of the window) or of its container.
208
+ const followAreaSize = function () {
209
+ if (isOnPage) {
210
+ box.onPageResize(layout);
211
+ return;
212
+ }
213
+ // WHY onResize: a box can change its size without a resize of the window (Ex: a column made narrower).
214
+ area.onResize(layout);
215
+ };
216
+
217
+ // The corners that face the page. (border-radius: top-left, top-right, bottom-right, bottom-left)
218
+ const getFacingCorners = function () {
219
+ const radius = _s.panel.round + "px";
220
+ if (box.side === "left") return "0 " + radius + " " + radius + " 0";
221
+ if (box.side === "bottom") return radius + " " + radius + " 0 0";
222
+ if (box.side === "top") return "0 0 " + radius + " " + radius;
223
+ return radius + " 0 0 " + radius;
224
+ };
225
+
226
+ // The opacity of the closed panel: it fades out with its slide, or it only slides. (fade)
227
+ const getClosedOpacity = function () {
228
+ return (basic.isOn(box.fade)) ? 0 : 1;
229
+ };
230
+
231
+ // The panel slides. It fades too, unless fade is 0.
232
+ const getPanelMotion = function () {
233
+ const slide = "transform " + box.duration + "ms";
234
+ if (!basic.isOn(box.fade)) return slide;
235
+ return slide + ", opacity " + box.duration + "ms";
236
+ };
237
+
238
+ // Where the panel waits while it is closed: one size out of the screen.
239
+ const getHiddenTransform = function () {
240
+ if (box.side === "bottom") return "translateY(" + size + "px)";
241
+ if (box.side === "top") return "translateY(" + -size + "px)";
242
+ if (box.side === "left") return "translateX(" + -size + "px)";
243
+ return "translateX(" + size + "px)";
244
+ };
245
+
246
+ const showBackdrop = function (isShown) {
247
+
248
+ if (!backdrop) return;
249
+
250
+ if (isShown == 1) {
251
+ backdrop.visible = 1;
252
+ basic.nextFrame().then(function () { if (backdrop) backdrop.opacity = 1; });
253
+ } else {
254
+ backdrop.opacity = 0;
255
+ }
256
+
257
+ };
258
+
259
+ const onKeyDown = function (self, event) {
260
+ if (event.code !== "Escape") return;
261
+ // WHY after the event: a list opened from the panel can listen on window too, after the panel
262
+ // (FullScreenSelect). An Escape that closed a list, or that a Dialog over the panel kept, closed the panel
263
+ // too (the sheet of the mobile template is removed when it closes: its typed text was lost).
264
+ box.after(0, function () {
265
+ if (event.defaultPrevented) return; // used by a list, a menu or a Dialog
266
+ if (typeof Dialog === "function" && Dialog.getTop()) return; // a modal over the panel
267
+ if (box.isOpened === 1 && box.closeOnEscape == 1) box.close();
268
+ });
269
+ };
270
+
271
+ // *** PUBLIC VARIABLES:
272
+
273
+ // 1 while the panel is open. [var]
274
+ box.isOpened = 0;
275
+
276
+ // *** PUBLIC FUNCTIONS:
277
+
278
+ box.open = function () {
279
+
280
+ if (box.isOpened === 1) return;
281
+
282
+ // WHY: Two open drawers over each other are never wanted. The other one is closed first.
283
+ if (box.exclusive == 1 && SidePanel.openedPanel && SidePanel.openedPanel !== box) {
284
+ SidePanel.openedPanel.close();
285
+ }
286
+
287
+ if (cancelClose) {
288
+ cancelClose();
289
+ cancelClose = null;
290
+ }
291
+
292
+ box.isOpened = 1;
293
+ SidePanel.openedPanel = box;
294
+
295
+ // WHY now: a panel opened right after it was made (a sheet made by a click) had no transition yet
296
+ // (setMotion() turns it on a moment later), so it showed at once, without its slide.
297
+ box.setMotionNow(getPanelMotion());
298
+ if (backdrop) backdrop.setMotionNow("opacity " + box.duration + "ms");
299
+
300
+ box.visible = 1;
301
+ box.css.transform = getHiddenTransform(); // Start from outside...
302
+ showBackdrop(1);
303
+ void box.elem.offsetWidth; // WHY: the browser lays out the closed place first (the panel was display: none)
304
+
305
+ // WHY: The browser has to see the closed state before the open one, or there is no
306
+ // transition between them. One frame is enough.
307
+ basic.nextFrame().then(function () {
308
+ if (!box || box.isOpened === 0) return;
309
+ box.css.transform = OPEN_TRANSFORM;
310
+ box.opacity = 1;
311
+ });
312
+
313
+ box.aria = { hidden: "false" };
314
+ box.onOpen(box);
315
+
316
+ };
317
+
318
+ box.close = function () {
319
+
320
+ if (box.isOpened === 0) return;
321
+
322
+ // WHY: The page can stop the closing. (Ex: "There are unsaved changes.")
323
+ if (box.onBeforeClose(box) === false) return;
324
+
325
+ box.isOpened = 0;
326
+ if (SidePanel.openedPanel === box) SidePanel.openedPanel = null;
327
+
328
+ box.css.transform = getHiddenTransform();
329
+ box.opacity = getClosedOpacity();
330
+ showBackdrop(0);
331
+
332
+ // WHY: The panel is hidden only after the animation, and the wait is the duration of that
333
+ // animation, not a number written twice.
334
+ if (cancelClose) cancelClose();
335
+ cancelClose = box.after(box.duration, function () {
336
+ cancelClose = null;
337
+ if (box.isOpened === 1) return;
338
+ box.visible = 0;
339
+ if (backdrop) backdrop.visible = 0;
340
+ });
341
+
342
+ box.aria = { hidden: "true" };
343
+ box.onClose(box);
344
+
345
+ };
346
+
347
+ box.toggle = function () {
348
+ if (box.isOpened === 1) {
349
+ box.close();
350
+ return;
351
+ }
352
+ box.open();
353
+ };
354
+
355
+ box.setTitleText = function (text) {
356
+ box.titleText = text;
357
+ if (box.lblTitle) setText(box.lblTitle, text);
358
+ };
359
+ // USAGE: get: panel.titleText, set: panel.setTitleText("Filters (3)")
360
+
361
+ box.setPanelSize = function (value) {
362
+ box.panelSize = value;
363
+ layout();
364
+ };
365
+
366
+ // The objects created between these two calls go into the body of the panel.
367
+ // WHY a group of their own (on the start / end stack, as PageControl.startPage and Tabs.startPanel): only the
368
+ // default container was set. In a panel made while a group of the page was open, the endObject() of the first
369
+ // component (or an endGroup()) in the body went back to that group, and the next objects were drawn outside
370
+ // the panel. The group has the gap and the alignment of the body, so the look is the same.
371
+ box.startBody = function () {
372
+ bodyStack.push(getDefaultContainerBox());
373
+ setDefaultContainerBox(box.body);
374
+ const content = VGroup({ width: "100%", height: "auto", align: "left top", gap: _s.body.gap, color: "transparent", position: "relative" });
375
+ content.css.alignItems = "stretch";
376
+ return box.body;
377
+ };
378
+
379
+ box.endBody = function () {
380
+ endGroup(); // the group of startBody()
381
+ const previous = bodyStack.pop();
382
+ if (previous) setDefaultContainerBox(previous);
383
+ };
384
+
385
+ box.getBody = function () {
386
+ return box.body;
387
+ };
388
+
389
+ // WHY: box.superRemove is overwritten by a component that extends this one, so the local copy is called below.
390
+ const superRemove = box.remove;
391
+ box.superRemove = superRemove;
392
+ box.remove = function () {
393
+
394
+ if (!box) return; // WHY: remove() can be called twice (also by the parent's remove()).
395
+ if (SidePanel.openedPanel === box) SidePanel.openedPanel = null;
396
+
397
+ // WHY: The size watcher is on the container, not on the box: the remove() of the box does not reach it.
398
+ if (!isOnPage) area.remove_onResize(layout);
399
+
400
+ superRemove.call(box); // NOTE: basic.js remove(). It cleans all the events and the objects inside.
401
+ box = null;
402
+
403
+ };
404
+
405
+ // *** OBJECT VIEW:
406
+
407
+ box.props({
408
+ color: _s.panel.color,
409
+ border: _s.panel.border,
410
+ borderColor: _s.panel.borderColor,
411
+ boxShadow: _s.panel.boxShadow,
412
+ opacity: getClosedOpacity(),
413
+ zIndex: SidePanel.Z_INDEX + 1,
414
+ clipContent: 1,
415
+ });
416
+ if (_s.panel.round > 0) box.css.borderRadius = getFacingCorners();
417
+ // WHY: In a group (HGroup / VGroup) a new object is a flex item. The panel is placed by layout() instead.
418
+ if (!isOnPage) box.position = "absolute";
419
+ box.role = "dialog";
420
+ box.aria = {
421
+ modal: (box.showBackdrop == 1) ? "true" : "false",
422
+ label: box.ariaLabel,
423
+ };
424
+
425
+ // GROUP: header + body, one under the other
426
+ VGroup({ width: "100%", height: "100%", align: "left top", gap: 0, color: "transparent" });
427
+ that.css.alignItems = "stretch";
428
+
429
+ // GROUP: Header
430
+ if (box.showHeader == 1) {
431
+
432
+ box.header = HGroup({
433
+ width: "100%",
434
+ height: _s.header.height,
435
+ align: "left center",
436
+ padding: _s.header.padding,
437
+ gap: 10,
438
+ color: _s.header.color,
439
+ });
440
+ that.shrink = 0;
441
+ that.css.borderBottom = _s.header.dividerColor ? ("1px solid " + _s.header.dividerColor) : "";
442
+
443
+ // LABEL: Title
444
+ box.lblTitle = Label({
445
+ fontSize: _s.title.fontSize,
446
+ textColor: _s.title.textColor,
447
+ fontFamily: _s.title.fontFamily,
448
+ grow: 1,
449
+ });
450
+ setText(box.lblTitle, box.titleText);
451
+ that.ellipsis = 1;
452
+
453
+ // BOX: Close button (the X is drawn with two lines, no image file)
454
+ if (box.showCloseButton == 1) {
455
+
456
+ box.btnClose = Box({
457
+ width: _s.closeButton.size,
458
+ height: _s.closeButton.size,
459
+ color: _s.closeButton.color,
460
+ round: _s.closeButton.round,
461
+ clickable: 1,
462
+ });
463
+ that.shrink = 0;
464
+ that.cursor = "pointer";
465
+ that.setMotion("background-color 0.2s");
466
+ that.role = "button";
467
+ that.aria = { label: "Close" };
468
+
469
+ createIn(box.btnClose, function () {
470
+ [45, -45].forEach(function (angle) {
471
+ const line = Box(0, 0, 15, 2, { color: _s.closeButton.iconColor, round: 1 });
472
+ line.center();
473
+ line.css.transform = "rotate(" + angle + "deg)";
474
+ });
475
+ });
476
+
477
+ }
478
+
479
+ endGroup();
480
+
481
+ }
482
+
483
+ // BOX: Body. It scrolls when the content is taller than the panel.
484
+ box.bodyBox = Box({
485
+ width: "100%",
486
+ height: "auto",
487
+ grow: 1,
488
+ color: "transparent",
489
+ scrollY: 1,
490
+ });
491
+
492
+ // GROUP: The content of the panel is created in this group.
493
+ createIn(box.bodyBox, function () {
494
+ box.body = VGroup({
495
+ width: "100%",
496
+ height: "auto",
497
+ align: "left top",
498
+ padding: _s.body.padding,
499
+ gap: _s.body.gap,
500
+ color: "transparent",
501
+ });
502
+ that.css.alignItems = "stretch";
503
+ endGroup();
504
+ });
505
+
506
+ endGroup();
507
+
508
+ // *** OBJECT INIT CODE:
509
+
510
+ box.setMotion(getPanelMotion());
511
+
512
+ if (box.btnClose) {
513
+ box.btnClose.on("click", function () { box.close(); });
514
+ box.btnClose.on("mouseenter", function (self) { self.color = _s.closeButton.hoverColor; });
515
+ box.btnClose.on("mouseleave", function (self) { self.color = _s.closeButton.color; });
516
+ }
517
+
518
+ if (backdrop) {
519
+ backdrop.setMotion("opacity " + box.duration + "ms");
520
+ backdrop.on("click", function () {
521
+ if (box.closeOnBackdrop == 1) box.close();
522
+ });
523
+ }
524
+
525
+ // (listenTo / onPageResize / own: removed with the box)
526
+ box.listenTo(window, "keydown", onKeyDown);
527
+ if (backdrop) box.own(backdrop); // WHY: It is on the page (or in the container), not in the box.
528
+
529
+ layout();
530
+ followAreaSize();
531
+
532
+ // WHY: The groups above are created first. A group that is created inside a hidden box is not
533
+ // laid out as a flex group, so the panel is hidden only now.
534
+ box.visible = 0;
535
+ box.aria = { hidden: "true" };
536
+
537
+ if (box.opened == 1) {
538
+ box.isOpened = 1;
539
+ SidePanel.openedPanel = box;
540
+ box.visible = 1;
541
+ box.opacity = 1;
542
+ box.css.transform = OPEN_TRANSFORM;
543
+ box.aria = { hidden: "false" };
544
+ if (backdrop) {
545
+ backdrop.visible = 1;
546
+ backdrop.opacity = 1;
547
+ }
548
+ }
549
+
550
+ const panel = endObject(box);
551
+
552
+ // WHY: The container was moved to the page above. The caller goes on with its own container.
553
+ setDefaultContainerBox(previousContainer);
554
+
555
+ return panel;
556
+
557
+ };
558
+
559
+ // The panel that is open now. (exclusive: 1 closes it when another one opens.)
560
+ SidePanel.openedPanel = null;
561
+
562
+ // The backdrop is at this level, the panel one above it.
563
+ SidePanel.Z_INDEX = 1000;
564
+
565
+ // *** STYLE PACKAGES:
566
+ // USAGE: SidePanel({ styleName: "dark" })
567
+ // USAGE: SidePanel({ styleName: "dark", style: { panel: { color: "tomato" } } }) // Change only some keys.
568
+ // USAGE: SidePanel({ style: SidePanel.styles.dark }) // The same as styleName: "dark". (The package is copied, never changed.)
569
+ // NOTE: A new package needs only the keys that differ from the default (classic) style.
570
+ // USAGE: SidePanel.styles.myStyle = { panel: { color: "red" } };
571
+
572
+ SidePanel.styles = {
573
+
574
+ // White panel, gray divider.
575
+ light: SidePanelDefaults.style,
576
+
577
+ // Round corners, cadetblue title. Same colors as the modern Tabs, Stepper and ProgressBar.
578
+ modern: {
579
+ panel: { color: White(1), border: 0, borderColor: "transparent", boxShadow: "0 0 50px rgba(0, 0, 0, 0.22)" },
580
+ header: { height: 66, color: "transparent", padding: [24, 0], dividerColor: "#E3ECEC" },
581
+ title: { fontSize: 18, textColor: "#2F5F61", fontFamily: "opensans-bold" },
582
+ closeButton: { size: 34, color: "#EEF5F5", hoverColor: "#DFECEC", iconColor: "#2F5F61", round: 100 },
583
+ body: { padding: [24, 20], gap: 16 },
584
+ backdrop: { color: "rgba(47, 95, 97, 0.35)" },
585
+ },
586
+
587
+ // Dark theme, same colors as the "dark" Tabs, TagInput and Stepper.
588
+ dark: {
589
+ panel: { color: "#232322", border: 1, borderColor: "rgba(255, 255, 255, 0.10)", boxShadow: "0 0 50px rgba(0, 0, 0, 0.5)" },
590
+ header: { height: 62, color: "transparent", padding: [24, 0], dividerColor: "rgba(255, 255, 255, 0.10)" },
591
+ title: { fontSize: 18, textColor: White(0.9), fontFamily: "opensans-bold" },
592
+ closeButton: { size: 34, color: "transparent", hoverColor: White(0.1), iconColor: White(0.7), round: 17 },
593
+ body: { padding: [24, 20], gap: 14 },
594
+ backdrop: { color: Black(0.55) },
595
+ },
596
+
597
+ };
598
+ SidePanel.styles.classic = SidePanel.styles.light; // the old name of light: the pages made with it keep their look
599
+
600
+ // The minimal theme (_designs/minimal-theme.htm): the ground of the window, a line and no shadow (as the minimal
601
+ // Dialog), a 40 px header with a 14 px title, a 24 px close button with a faint fill under the mouse.
602
+ // minimalDark: the same on a dark window.
603
+ SidePanel.createMinimalStyle = function (colors) {
604
+ return {
605
+ panel: { color: colors.ground, border: 1, borderColor: colors.edge, boxShadow: "none", round: 0 },
606
+ header: { height: 40, color: "transparent", padding: [16, 0], dividerColor: colors.line },
607
+ title: { fontSize: 14, textColor: colors.text, fontFamily: "opensans-bold" },
608
+ closeButton: { size: 24, color: "transparent", hoverColor: colors.hover, iconColor: colors.softText, round: 4 },
609
+ body: { padding: [16, 14], gap: 10 },
610
+ backdrop: { color: colors.cover },
611
+ };
612
+ };
613
+ SidePanel.MINIMAL_COLORS = { ground: "#FFFFFF", text: Black(0.85), softText: Black(0.55), line: Black(0.2), edge: Black(0.45), hover: Black(0.05), cover: Black(0.3) };
614
+ SidePanel.styles.minimal = SidePanel.createMinimalStyle(SidePanel.MINIMAL_COLORS);
615
+ SidePanel.MINIMAL_DARK_COLORS = { ground: "#1A1A19", text: White(0.88), softText: White(0.55), line: White(0.18), edge: White(0.42), hover: White(0.07), cover: Black(0.6) };
616
+ SidePanel.styles.minimalDark = SidePanel.createMinimalStyle(SidePanel.MINIMAL_DARK_COLORS);