x4js 1.6.5 → 2.0.1

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 (282) hide show
  1. package/README.md +3 -14
  2. package/lib/README.txt +3 -14
  3. package/lib/src/assets/house-light.svg +1 -0
  4. package/lib/src/assets/radio.svg +4 -0
  5. package/lib/src/components/base.scss +26 -0
  6. package/lib/src/components/boxes/boxes.module.scss +37 -0
  7. package/lib/src/components/boxes/boxes.ts +125 -0
  8. package/lib/src/components/btngroup/btngroup.module.scss +29 -0
  9. package/lib/src/components/btngroup/btngroup.ts +106 -0
  10. package/lib/src/components/button/button.module.scss +154 -0
  11. package/lib/src/components/button/button.ts +117 -0
  12. package/lib/src/components/calendar/calendar-check-sharp-light.svg +1 -0
  13. package/lib/src/components/calendar/calendar.module.scss +163 -0
  14. package/lib/src/{calendar.ts → components/calendar/calendar.ts} +81 -83
  15. package/lib/src/components/calendar/chevron-left-sharp-light.svg +1 -0
  16. package/lib/src/components/calendar/chevron-right-sharp-light.svg +1 -0
  17. package/lib/src/components/checkbox/check.svg +4 -0
  18. package/lib/src/components/checkbox/checkbox.module.scss +142 -0
  19. package/lib/src/components/checkbox/checkbox.ts +125 -0
  20. package/lib/src/components/colorinput/colorinput.module.scss +65 -0
  21. package/lib/src/components/colorinput/colorinput.ts +88 -0
  22. package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
  23. package/lib/src/components/colorpicker/colorpicker.module.scss +133 -0
  24. package/lib/src/components/colorpicker/colorpicker.ts +477 -0
  25. package/lib/src/components/combobox/combobox.module.scss +121 -0
  26. package/lib/src/components/combobox/combobox.ts +190 -0
  27. package/lib/src/components/combobox/updown.svg +4 -0
  28. package/lib/src/components/dialog/dialog.module.scss +71 -0
  29. package/lib/src/components/dialog/dialog.ts +91 -0
  30. package/lib/src/components/dialog/xmark-sharp-light.svg +1 -0
  31. package/lib/src/components/form/form.module.scss +34 -0
  32. package/lib/src/components/form/form.ts +36 -0
  33. package/lib/src/components/header/header.module.scss +40 -0
  34. package/lib/src/components/header/header.ts +124 -0
  35. package/lib/src/components/icon/icon.module.scss +30 -0
  36. package/lib/src/components/icon/icon.ts +134 -0
  37. package/lib/src/components/image/image.module.scss +21 -0
  38. package/lib/src/components/image/image.ts +67 -0
  39. package/lib/src/components/input/input.module.scss +69 -0
  40. package/lib/src/components/input/input.ts +274 -0
  41. package/lib/src/components/label/label.module.scss +52 -0
  42. package/lib/src/components/label/label.ts +55 -0
  43. package/lib/src/components/listbox/listbox.module.scss +103 -0
  44. package/lib/src/components/listbox/listbox.ts +427 -0
  45. package/lib/src/components/menu/caret-right-solid.svg +1 -0
  46. package/lib/src/components/menu/menu.module.scss +108 -0
  47. package/lib/src/components/menu/menu.ts +168 -0
  48. package/lib/src/components/messages/circle-exclamation.svg +1 -0
  49. package/lib/src/components/messages/messages.module.scss +47 -0
  50. package/lib/src/components/messages/messages.ts +64 -0
  51. package/lib/src/components/normalize.scss +386 -0
  52. package/lib/src/components/notification/circle-check-solid.svg +1 -0
  53. package/lib/src/components/notification/circle-exclamation-solid.svg +1 -0
  54. package/lib/src/components/notification/circle-notch-light.svg +1 -0
  55. package/lib/src/components/notification/notification.module.scss +82 -0
  56. package/lib/src/components/notification/notification.ts +108 -0
  57. package/lib/src/components/notification/xmark-sharp-light.svg +1 -0
  58. package/lib/src/components/panel/panel.module.scss +48 -0
  59. package/lib/src/components/panel/panel.ts +57 -0
  60. package/lib/src/components/popup/popup.module.scss +43 -0
  61. package/lib/src/components/popup/popup.ts +395 -0
  62. package/lib/src/components/progress/progress.module.scss +57 -0
  63. package/lib/src/components/progress/progress.ts +43 -0
  64. package/lib/src/components/rating/rating.module.scss +23 -0
  65. package/lib/src/components/rating/rating.ts +125 -0
  66. package/lib/src/components/rating/star-sharp-light.svg +1 -0
  67. package/lib/src/components/rating/star-sharp-solid.svg +1 -0
  68. package/lib/src/components/shared.scss +76 -0
  69. package/lib/src/components/sizers/sizer.module.scss +90 -0
  70. package/lib/src/components/sizers/sizer.ts +120 -0
  71. package/lib/src/components/slider/slider.module.scss +71 -0
  72. package/lib/src/components/slider/slider.ts +143 -0
  73. package/lib/src/components/switch/switch.module.scss +127 -0
  74. package/lib/src/components/switch/switch.ts +56 -0
  75. package/lib/src/components/tabs/tabs.module.scss +46 -0
  76. package/lib/src/components/tabs/tabs.ts +157 -0
  77. package/lib/src/components/textarea/textarea.module.scss +59 -0
  78. package/lib/src/components/textarea/textarea.ts +54 -0
  79. package/lib/src/components/textedit/textedit.module.scss +114 -0
  80. package/lib/src/components/textedit/textedit.ts +82 -0
  81. package/lib/src/components/themes.scss +77 -0
  82. package/lib/src/components/tooltips/circle-info-sharp-light.svg +1 -0
  83. package/lib/src/components/tooltips/tooltips.scss +51 -0
  84. package/lib/src/components/tooltips/tooltips.ts +103 -0
  85. package/lib/src/components/treeview/chevron-down-light.svg +1 -0
  86. package/lib/src/components/treeview/treeview.module.scss +116 -0
  87. package/lib/src/components/treeview/treeview.ts +403 -0
  88. package/lib/src/components/viewport/viewport.module.scss +25 -0
  89. package/lib/src/components/viewport/viewport.ts +38 -0
  90. package/lib/src/core/component.ts +979 -0
  91. package/lib/src/core/core_colors.ts +250 -0
  92. package/lib/src/{dom_events.ts → core/core_dom.ts} +195 -39
  93. package/lib/src/{drag_manager.ts → core/core_dragdrop.ts} +29 -44
  94. package/lib/src/core/core_element.ts +98 -0
  95. package/lib/src/core/core_events.ts +149 -0
  96. package/lib/src/{i18n.ts → core/core_i18n.ts} +43 -42
  97. package/lib/src/{router.ts → core/core_router.ts} +27 -40
  98. package/lib/src/core/core_styles.ts +215 -0
  99. package/lib/src/core/core_svg.ts +550 -0
  100. package/lib/src/core/core_tools.ts +673 -0
  101. package/lib/src/main.scss +21 -0
  102. package/lib/src/main.tsx +323 -0
  103. package/lib/src/x4.scss +19 -0
  104. package/lib/types/x4.d.ts +2624 -0
  105. package/package.json +67 -59
  106. package/scripts/build.mjs +351 -0
  107. package/scripts/prepack.mjs +15 -0
  108. package/src/assets/house-light.svg +1 -0
  109. package/src/assets/radio.svg +4 -0
  110. package/src/components/base.scss +26 -0
  111. package/src/components/boxes/boxes.module.scss +37 -0
  112. package/src/components/boxes/boxes.ts +125 -0
  113. package/src/components/btngroup/btngroup.module.scss +29 -0
  114. package/src/components/btngroup/btngroup.ts +106 -0
  115. package/src/components/button/button.module.scss +154 -0
  116. package/src/components/button/button.ts +117 -0
  117. package/src/components/calendar/calendar-check-sharp-light.svg +1 -0
  118. package/src/components/calendar/calendar.module.scss +163 -0
  119. package/src/components/calendar/calendar.ts +326 -0
  120. package/src/components/calendar/chevron-left-sharp-light.svg +1 -0
  121. package/src/components/calendar/chevron-right-sharp-light.svg +1 -0
  122. package/src/components/checkbox/check.svg +4 -0
  123. package/src/components/checkbox/checkbox.module.scss +142 -0
  124. package/src/components/checkbox/checkbox.ts +125 -0
  125. package/src/components/colorinput/colorinput.module.scss +65 -0
  126. package/src/components/colorinput/colorinput.ts +88 -0
  127. package/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
  128. package/src/components/colorpicker/colorpicker.module.scss +133 -0
  129. package/src/components/colorpicker/colorpicker.ts +477 -0
  130. package/src/components/combobox/combobox.module.scss +121 -0
  131. package/src/components/combobox/combobox.ts +190 -0
  132. package/src/components/combobox/updown.svg +4 -0
  133. package/src/components/dialog/dialog.module.scss +71 -0
  134. package/src/components/dialog/dialog.ts +91 -0
  135. package/src/components/dialog/xmark-sharp-light.svg +1 -0
  136. package/src/components/form/form.module.scss +34 -0
  137. package/src/components/form/form.ts +36 -0
  138. package/src/components/header/header.module.scss +40 -0
  139. package/src/components/header/header.ts +124 -0
  140. package/src/components/icon/icon.module.scss +30 -0
  141. package/src/components/icon/icon.ts +134 -0
  142. package/src/components/image/image.module.scss +21 -0
  143. package/src/components/image/image.ts +67 -0
  144. package/src/components/input/input.module.scss +69 -0
  145. package/src/components/input/input.ts +274 -0
  146. package/src/components/label/label.module.scss +52 -0
  147. package/src/components/label/label.ts +55 -0
  148. package/src/components/listbox/listbox.module.scss +103 -0
  149. package/src/components/listbox/listbox.ts +427 -0
  150. package/src/components/menu/caret-right-solid.svg +1 -0
  151. package/src/components/menu/menu.module.scss +108 -0
  152. package/src/components/menu/menu.ts +168 -0
  153. package/src/components/messages/circle-exclamation.svg +1 -0
  154. package/src/components/messages/messages.module.scss +47 -0
  155. package/src/components/messages/messages.ts +64 -0
  156. package/src/components/normalize.scss +386 -0
  157. package/src/components/notification/circle-check-solid.svg +1 -0
  158. package/src/components/notification/circle-exclamation-solid.svg +1 -0
  159. package/src/components/notification/circle-notch-light.svg +1 -0
  160. package/src/components/notification/notification.module.scss +82 -0
  161. package/src/components/notification/notification.ts +108 -0
  162. package/src/components/notification/xmark-sharp-light.svg +1 -0
  163. package/src/components/panel/panel.module.scss +48 -0
  164. package/src/components/panel/panel.ts +57 -0
  165. package/src/components/popup/popup.module.scss +43 -0
  166. package/src/components/popup/popup.ts +395 -0
  167. package/src/components/progress/progress.module.scss +57 -0
  168. package/src/components/progress/progress.ts +43 -0
  169. package/src/components/rating/rating.module.scss +23 -0
  170. package/src/components/rating/rating.ts +125 -0
  171. package/src/components/rating/star-sharp-light.svg +1 -0
  172. package/src/components/rating/star-sharp-solid.svg +1 -0
  173. package/src/components/shared.scss +76 -0
  174. package/src/components/sizers/sizer.module.scss +90 -0
  175. package/src/components/sizers/sizer.ts +120 -0
  176. package/src/components/slider/slider.module.scss +71 -0
  177. package/src/components/slider/slider.ts +143 -0
  178. package/src/components/switch/switch.module.scss +127 -0
  179. package/src/components/switch/switch.ts +56 -0
  180. package/src/components/tabs/tabs.module.scss +46 -0
  181. package/src/components/tabs/tabs.ts +157 -0
  182. package/src/components/textarea/textarea.module.scss +59 -0
  183. package/src/components/textarea/textarea.ts +54 -0
  184. package/src/components/textedit/textedit.module.scss +114 -0
  185. package/src/components/textedit/textedit.ts +82 -0
  186. package/src/components/themes.scss +77 -0
  187. package/src/components/tooltips/circle-info-sharp-light.svg +1 -0
  188. package/src/components/tooltips/tooltips.scss +51 -0
  189. package/src/components/tooltips/tooltips.ts +103 -0
  190. package/src/components/treeview/chevron-down-light.svg +1 -0
  191. package/src/components/treeview/treeview.module.scss +116 -0
  192. package/src/components/treeview/treeview.ts +403 -0
  193. package/src/components/viewport/viewport.module.scss +25 -0
  194. package/src/components/viewport/viewport.ts +38 -0
  195. package/src/core/component.ts +979 -0
  196. package/src/core/core_colors.ts +250 -0
  197. package/src/core/core_dom.ts +471 -0
  198. package/src/core/core_dragdrop.ts +201 -0
  199. package/src/core/core_element.ts +98 -0
  200. package/src/core/core_events.ts +149 -0
  201. package/src/core/core_i18n.ts +377 -0
  202. package/src/core/core_router.ts +221 -0
  203. package/src/core/core_styles.ts +215 -0
  204. package/src/core/core_svg.ts +550 -0
  205. package/src/core/core_tools.ts +673 -0
  206. package/src/main.scss +21 -0
  207. package/src/main.tsx +323 -0
  208. package/src/x4.scss +19 -0
  209. package/tsconfig.json +14 -0
  210. package/types/scss.d.ts +4 -0
  211. package/types/svg.d.ts +4 -0
  212. package/types/x4react.d.ts +9 -0
  213. package/lib/changelog.txt +0 -23
  214. package/lib/cjs/x4js.js +0 -39
  215. package/lib/cjs/x4js.js.map +0 -7
  216. package/lib/esm/x4js.mjs +0 -15972
  217. package/lib/esm/x4js.mjs.map +0 -7
  218. package/lib/licence.md +0 -21
  219. package/lib/src/MIT-license.md +0 -14
  220. package/lib/src/action.ts +0 -88
  221. package/lib/src/alpha.jpg +0 -0
  222. package/lib/src/app_sockets.ts +0 -81
  223. package/lib/src/application.ts +0 -262
  224. package/lib/src/autocomplete.ts +0 -232
  225. package/lib/src/base64.ts +0 -166
  226. package/lib/src/base_component.ts +0 -152
  227. package/lib/src/button.ts +0 -355
  228. package/lib/src/canvas.ts +0 -510
  229. package/lib/src/cardview.ts +0 -228
  230. package/lib/src/checkbox.ts +0 -188
  231. package/lib/src/color.ts +0 -752
  232. package/lib/src/colorpicker.ts +0 -1649
  233. package/lib/src/combobox.ts +0 -512
  234. package/lib/src/component.ts +0 -2367
  235. package/lib/src/copyright.txt +0 -27
  236. package/lib/src/datastore.ts +0 -1302
  237. package/lib/src/dialog.ts +0 -656
  238. package/lib/src/drawtext.ts +0 -355
  239. package/lib/src/fileupload.ts +0 -213
  240. package/lib/src/form.ts +0 -413
  241. package/lib/src/formatters.ts +0 -105
  242. package/lib/src/gridview.ts +0 -1185
  243. package/lib/src/icon.ts +0 -362
  244. package/lib/src/image.ts +0 -225
  245. package/lib/src/index.ts +0 -89
  246. package/lib/src/input.ts +0 -297
  247. package/lib/src/label.ts +0 -153
  248. package/lib/src/layout.ts +0 -442
  249. package/lib/src/link.ts +0 -86
  250. package/lib/src/listview.ts +0 -765
  251. package/lib/src/md5.ts +0 -438
  252. package/lib/src/menu.ts +0 -425
  253. package/lib/src/messagebox.ts +0 -224
  254. package/lib/src/panel.ts +0 -86
  255. package/lib/src/popup.ts +0 -494
  256. package/lib/src/property_editor.ts +0 -337
  257. package/lib/src/radiobtn.ts +0 -197
  258. package/lib/src/rating.ts +0 -135
  259. package/lib/src/request.ts +0 -300
  260. package/lib/src/settings.ts +0 -77
  261. package/lib/src/sidebarview.ts +0 -108
  262. package/lib/src/spreadsheet.ts +0 -1449
  263. package/lib/src/styles.ts +0 -343
  264. package/lib/src/svgcomponent.ts +0 -592
  265. package/lib/src/tabbar.ts +0 -151
  266. package/lib/src/tabview.ts +0 -110
  267. package/lib/src/textarea.ts +0 -235
  268. package/lib/src/textedit.ts +0 -533
  269. package/lib/src/toaster.ts +0 -80
  270. package/lib/src/tools.ts +0 -1473
  271. package/lib/src/tooltips.ts +0 -191
  272. package/lib/src/treeview.ts +0 -716
  273. package/lib/src/version.ts +0 -30
  274. package/lib/src/x4.less +0 -2242
  275. package/lib/src/x4dom.ts +0 -57
  276. package/lib/src/x4events.ts +0 -585
  277. package/lib/src/x4js.ts +0 -89
  278. package/lib/src/x4react.ts +0 -90
  279. package/lib/styles/x4.css +0 -1785
  280. package/lib/styles/x4.less +0 -2242
  281. package/lib/types/x4js.d.ts +0 -6728
  282. package/license.md +0 -21
@@ -0,0 +1,395 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file popup.ts
9
+ * @author Etienne Cochard
10
+ *
11
+ * @copyright (c) 2024 R-libre ingenierie
12
+ *
13
+ * Use of this source code is governed by an MIT-style license
14
+ * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
+ **/
16
+
17
+ import { Component, ComponentEvent, ComponentEvents, ComponentProps, componentFromDOM, makeUniqueComponentId } from "@core/component"
18
+ import { CSizer } from '../sizers/sizer';
19
+ import { Rect, Point } from '@core/core_tools.js';
20
+
21
+ import "./popup.module.scss"
22
+
23
+
24
+ export interface PopupEvents extends ComponentEvents {
25
+ closed: ComponentEvent;
26
+ opened: ComponentEvent;
27
+ }
28
+
29
+ export interface PopupProps extends ComponentProps {
30
+ modal?: boolean;
31
+ autoClose?: boolean | string;
32
+ sizable?: boolean;
33
+ movable?: boolean;
34
+ }
35
+
36
+
37
+ let modal_mask: Component;
38
+ let modal_count = 0;
39
+
40
+ let modal_stack: Popup[] = [];
41
+ let autoclose_list: Popup[] = [];
42
+ let popup_list: Popup[] = [];
43
+
44
+
45
+
46
+ /**
47
+ *
48
+ */
49
+
50
+ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = PopupEvents> extends Component<P,E> {
51
+
52
+ private _isopen = false;
53
+ private _isshown = false;
54
+
55
+ constructor( props: P ) {
56
+ super( props );
57
+
58
+ if( this.props.sizable ) {
59
+ this._createSizers( );
60
+ }
61
+ }
62
+
63
+ displayNear( rc: Rect, dst = "top left", src = "top left", offset = {x:0,y:0} ) {
64
+
65
+ this.setStyle( { left: "0px", top: "0px" } ); // avoid scrollbar
66
+ this._show( ); // to compute size
67
+
68
+ let rm = this.getBoundingRect();
69
+
70
+ let xref = rc.left;
71
+ let yref = rc.top;
72
+
73
+ if( src.indexOf('right')>=0 ) {
74
+ xref = (rc.left+rc.width);
75
+ }
76
+ else if( src.indexOf('center')>=0 ) {
77
+ xref = rc.left + rc.width/2;
78
+ }
79
+
80
+ if( src.indexOf('bottom')>=0 ) {
81
+ yref = rc.bottom;
82
+ }
83
+ else if( src.indexOf('middle')>=0 ) {
84
+ yref = rc.top + rc.height/2;
85
+ }
86
+
87
+ let halign = 'l';
88
+ if (dst.indexOf('right') >= 0) {
89
+ xref -= rm.width;
90
+ }
91
+ else if( dst.indexOf('center')>=0 ) {
92
+ xref -= rm.width/2;
93
+ }
94
+
95
+ let valign = 't';
96
+ if (dst.indexOf('bottom') >= 0) {
97
+ yref -= rm.height;
98
+ }
99
+ else if( dst.indexOf('middle')>=0 ) {
100
+ yref -= rm.height/2;
101
+ }
102
+
103
+ if (offset) {
104
+ xref += offset.x;
105
+ yref += offset.y;
106
+ }
107
+
108
+ // our parent is body, so take care of the scroll position
109
+ xref += document.scrollingElement.scrollLeft;
110
+ yref += document.scrollingElement.scrollTop;
111
+
112
+ this.displayAt( xref, yref );
113
+ }
114
+
115
+ /**
116
+ *
117
+ */
118
+
119
+ displayCenter( ) {
120
+ this.displayNear( new Rect( window.innerWidth/2, window.innerHeight/2, 0, 0 ), "center middle" );
121
+ }
122
+
123
+ /**
124
+ *
125
+ */
126
+
127
+ displayAt( x: number, y: number ) {
128
+ //TODO: check is already visible
129
+ this.setStyle( {
130
+ left: x+"px",
131
+ top: y+"px",
132
+ })
133
+
134
+ this._show( );
135
+
136
+ const rc = this.getBoundingRect( );
137
+ const width = window.innerWidth - 16;
138
+ const height = window.innerHeight - 16;
139
+
140
+ if( rc.right>width ) {
141
+ this.setStyleValue( "left", width-rc.width );
142
+ }
143
+
144
+ if( rc.bottom>height ) {
145
+ this.setStyleValue( "top", height-rc.height );
146
+ }
147
+
148
+ if( this.props.movable ) {
149
+ const movers = this.queryAll( ".caption-element" );
150
+ movers.forEach( m => new CMover(m,this) );
151
+
152
+ if( this.hasClass("popup-caption") ) {
153
+ new CMover(this,this);
154
+ }
155
+ }
156
+
157
+ this.fire( "opened", {} );
158
+ }
159
+
160
+ private _show( ) {
161
+
162
+ if( this.props.modal && !this._isshown ) {
163
+ this._showModalMask( );
164
+ modal_stack.push( this );
165
+ modal_count++;
166
+ }
167
+
168
+ this._isshown = true;
169
+
170
+ if( this.props.autoClose ) {
171
+ if( autoclose_list.length==0 ) {
172
+ document.addEventListener( "pointerdown", this._dismiss );
173
+ }
174
+
175
+ autoclose_list.push( this );
176
+ this.setData( "close", this.props.autoClose===true ? makeUniqueComponentId() : this.props.autoClose );
177
+ }
178
+
179
+ popup_list.push( this );
180
+ document.body.appendChild( this.dom );
181
+
182
+ this.show( );
183
+ }
184
+
185
+ override show( show = true ) {
186
+ this._isopen = show;
187
+ super.show( show );
188
+ }
189
+
190
+ isOpen( ) {
191
+ return this._isopen;
192
+ }
193
+
194
+ /**
195
+ *
196
+ */
197
+
198
+ close( ) {
199
+ document.body.removeChild( this.dom );
200
+
201
+ // remove from popup list
202
+ const idx = popup_list.indexOf( this );
203
+ console.assert( idx>=0 );
204
+ popup_list.splice( idx, 1 );
205
+
206
+ // remove from auto close list
207
+ if( this.props.autoClose ) {
208
+ const idx = autoclose_list.indexOf( this );
209
+ if( idx>=0 ) {
210
+ autoclose_list.splice( idx, 1 );
211
+ if( autoclose_list.length==0 ) {
212
+ document.removeEventListener( "pointerdown", this._dismiss );
213
+ }
214
+ }
215
+ }
216
+
217
+ // update mask
218
+ if( this.props.modal ) {
219
+ const top = modal_stack.pop( );
220
+ console.assert( top==this );
221
+ this._updateModalMask( );
222
+ }
223
+
224
+ this._isshown = false;
225
+ this.fire( "closed", {} );
226
+ }
227
+
228
+ /**
229
+ * binded
230
+ */
231
+
232
+ private _dismiss = ( e: UIEvent ) => {
233
+ const onac = autoclose_list.some( x=> x.dom.contains(e.target as Node) )
234
+ if( onac ) {
235
+ return;
236
+ }
237
+
238
+ e.preventDefault( );
239
+ e.stopPropagation( );
240
+
241
+ this.dismiss( );
242
+ }
243
+
244
+ /**
245
+ * dismiss all popup belonging to the same group as 'this'
246
+ */
247
+
248
+ dismiss( after = false ) {
249
+
250
+ if( autoclose_list.length==0 ) {
251
+ return;
252
+ }
253
+
254
+ const cgroup = this.getData( "close" );
255
+ const inc_group: Popup[] = [];
256
+ const excl_group: Popup[] = [];
257
+
258
+ let aidx = -1;
259
+ if( after ) {
260
+ aidx = autoclose_list.indexOf( this );
261
+ }
262
+
263
+ autoclose_list.forEach( (x,idx) => {
264
+ const group = x.getData( "close" );
265
+ if( group==cgroup && idx>aidx) {
266
+ inc_group.push( x );
267
+ }
268
+ else {
269
+ excl_group.push( x );
270
+ }
271
+ })
272
+
273
+ const list = inc_group.reverse( );
274
+ autoclose_list = excl_group;
275
+ if( autoclose_list.length==0 ) {
276
+ document.removeEventListener( "pointerdown", this._dismiss );
277
+ }
278
+
279
+ list.forEach( x => x.close() );
280
+ }
281
+
282
+ /**
283
+ *
284
+ */
285
+
286
+ private _showModalMask( ) {
287
+
288
+ if( !modal_mask ) {
289
+ modal_mask = new Component( {
290
+ cls: "x4modal-mask",
291
+ domEvents: {
292
+ click: this._dismiss
293
+ }
294
+ });
295
+ }
296
+
297
+ modal_mask.show( true );
298
+ document.body.insertAdjacentElement( "beforeend", modal_mask.dom );
299
+ }
300
+
301
+ /**
302
+ *
303
+ */
304
+
305
+ private _updateModalMask( ) {
306
+ if( --modal_count == 0 ) {
307
+ modal_mask.show( false );
308
+ }
309
+ else {
310
+ this.dom.insertAdjacentElement( "beforebegin", modal_mask.dom );
311
+ }
312
+ }
313
+
314
+ /**
315
+ *
316
+ */
317
+
318
+ private _createSizers( ) {
319
+ this.appendContent( [
320
+ new CSizer( "top" ),
321
+ new CSizer( "bottom" ),
322
+ new CSizer( "left" ),
323
+ new CSizer( "right" ),
324
+ new CSizer( "top-left" ),
325
+ new CSizer( "bottom-left" ),
326
+ new CSizer( "top-right" ),
327
+ new CSizer( "bottom-right" ),
328
+ ])
329
+ }
330
+ }
331
+
332
+
333
+ /**
334
+ *
335
+ */
336
+
337
+ class CMover {
338
+ private ref: Component;
339
+ private delta: Point;
340
+ private self: boolean;
341
+
342
+ constructor( x: Component, ref?: Component ) {
343
+
344
+ this.self = ref ? true : false;
345
+
346
+ x.addDOMEvent( "pointerdown", ( e: PointerEvent ) => {
347
+ if( this.self && e.target!=x.dom ) {
348
+ return;
349
+ }
350
+
351
+ x.setCapture( e.pointerId );
352
+
353
+ this.ref = ref ?? componentFromDOM( x.dom.parentElement );
354
+
355
+ this.delta = {x:0,y:0};
356
+ const rc = this.ref.getBoundingRect();
357
+
358
+ this.delta.x = e.pageX-rc.left;
359
+ this.delta.y = e.pageY-rc.top;
360
+ });
361
+
362
+ x.addDOMEvent( "pointerup", ( e: PointerEvent ) => {
363
+ x.releaseCapture( e.pointerId );
364
+ this.ref = null;
365
+ });
366
+
367
+ x.addDOMEvent( "pointermove", ( e: PointerEvent ) => {
368
+ this._onMouseMove( e );
369
+ });
370
+ }
371
+
372
+ private _onMouseMove( e: PointerEvent ) {
373
+ if( !this.ref ) {
374
+ return;
375
+ }
376
+
377
+ const pt = { x: e.pageX-this.delta.x, y: e.pageY-this.delta.y };
378
+ const rc = this.ref.getBoundingRect( );
379
+
380
+ let nr: any = {
381
+ };
382
+
383
+ this.ref.setStyle( {
384
+ top: pt.y+"",
385
+ left: pt.x+"",
386
+ } );
387
+
388
+ e.preventDefault( );
389
+ e.stopPropagation( );
390
+ }
391
+ }
392
+
393
+
394
+
395
+
@@ -0,0 +1,57 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file progress.module.scss
9
+ * @author Etienne Cochard
10
+ *
11
+ * @copyright (c) 2024 R-libre ingenierie
12
+ *
13
+ * Use of this source code is governed by an MIT-style license
14
+ * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
+ **/
16
+
17
+ :root {
18
+ --progress-background: var( --border );
19
+ --progress-color: var( --accent-background );
20
+ }
21
+
22
+ .x4progress {
23
+ background-color: var( --progress-background );
24
+ position: relative;
25
+ height: 6px;
26
+ margin: 0 5px;
27
+ border-radius: 3px;
28
+
29
+ .bar {
30
+ position: absolute;
31
+ left: 0;
32
+ top: 0;
33
+ bottom: 0;
34
+ width: 0;
35
+
36
+ background-color: var( --progress-color );
37
+ border-radius: 3px;
38
+
39
+ transition: width ease 0.2s;
40
+ }
41
+
42
+ &.indeterm .bar {
43
+ background-image: linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);
44
+ background-size: 20px 20px;
45
+ animation: slide 1s linear infinite;
46
+ }
47
+ }
48
+
49
+ @keyframes slide {
50
+ 0% {
51
+ background-position: 0 0
52
+ }
53
+
54
+ to {
55
+ background-position: 2.5rem 0
56
+ }
57
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file progress.ts
9
+ * @author Etienne Cochard
10
+ *
11
+ * @copyright (c) 2024 R-libre ingenierie
12
+ *
13
+ * Use of this source code is governed by an MIT-style license
14
+ * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
+ **/
16
+
17
+ import { Component, ComponentProps } from '@core/component';
18
+
19
+ import "./progress.module.scss";
20
+
21
+ interface ProgressProps extends ComponentProps {
22
+ value: number;
23
+ min: number;
24
+ max: number;
25
+ }
26
+
27
+
28
+ export class Progress extends Component<ProgressProps> {
29
+
30
+ private _bar: Component;
31
+
32
+ constructor( props: ProgressProps ) {
33
+ super( props );
34
+
35
+ this.setContent( this._bar=new Component( { cls: "bar" } ) );
36
+ this.setValue( props.value );
37
+ }
38
+
39
+ setValue( value: number ) {
40
+ const perc = value / (this.props.max-this.props.min) * 100;
41
+ this._bar.setStyleValue( "width", perc+"%" );
42
+ }
43
+ }
@@ -0,0 +1,23 @@
1
+ :root {
2
+ --rating: var( --border );
3
+ --rating-hover: var( --border-hover );
4
+ --rating-checked: var( --accent-background );
5
+ }
6
+
7
+ .x4rating {
8
+ gap: 2px;
9
+
10
+ .item {
11
+ width: 16px;
12
+ height: 16px;
13
+ color: var( --rating );
14
+ }
15
+
16
+ .item:hover {
17
+ color: var( --rating-hover );
18
+ }
19
+
20
+ .item.checked {
21
+ color: var( --rating-checked );
22
+ }
23
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|.2
7
+ *
8
+ * @file rating.ts
9
+ * @author Etienne Cochard
10
+ *
11
+ * @copyright (c) 2024 R-libre ingenierie
12
+ *
13
+ * Use of this source code is governed by an MIT-style license
14
+ * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
+ **/
16
+
17
+ import { Component, ComponentEvents, componentFromDOM, ComponentProps, EvChange } from '@core/component.js';
18
+ import { EventCallback } from '@core/core_events.js';
19
+ import { HBox } from '../boxes/boxes.js';
20
+ import { Input } from '../input/input.js';
21
+ import { Icon } from '../icon/icon.js';
22
+
23
+ import "./rating.module.scss"
24
+ import star_icon from "./star-sharp-solid.svg"
25
+
26
+ interface RatingEventMap extends ComponentEvents {
27
+ change: EvChange;
28
+ }
29
+
30
+
31
+
32
+ export interface RatingProps extends ComponentProps {
33
+ steps?: number;
34
+ value?: number;
35
+ icon?: string;
36
+ name?: string;
37
+
38
+ change?: EventCallback<EvChange>;
39
+ }
40
+
41
+ export class Rating extends HBox<RatingProps,RatingEventMap> {
42
+
43
+ private m_els: Component[];
44
+ private m_input: Input;
45
+
46
+ constructor( props: RatingProps ) {
47
+ super( props );
48
+
49
+ props.steps = props.steps ?? 5;
50
+ this._update( );
51
+ }
52
+
53
+ private _update( ) {
54
+
55
+ const props = this.props;
56
+
57
+ let shape = props.icon ?? star_icon;
58
+ let value = props.value ?? 0;
59
+
60
+ this.m_input = new Input( {
61
+ type: "text",
62
+ hidden: true,
63
+ name: props.name,
64
+ value: ''+value
65
+ } );
66
+
67
+ this.addDOMEvent( 'click', (e) => this._on_click(e) );
68
+
69
+ this.m_els = [];
70
+ for( let i=0; i<props.steps; i++ ) {
71
+
72
+ let cls = 'item';
73
+ if( i+1 <= value ) {
74
+ cls += ' checked';
75
+ }
76
+
77
+ let c = new Icon( {
78
+ cls,
79
+ iconId: shape,
80
+ } );
81
+
82
+ c.setInternalData( "value", i );
83
+
84
+ this.m_els.push( c );
85
+ }
86
+
87
+ this.m_els.push( this.m_input );
88
+ this.setContent( this.m_els );
89
+ }
90
+
91
+ getValue( ) {
92
+ return this.props.value ?? 0;
93
+ }
94
+
95
+ setValue( v: number ) {
96
+ this.props.value = v;
97
+
98
+ for( let c=0; c<this.props.steps; c++ ) {
99
+ this.m_els[c].setClass( 'checked', this.m_els[c].getInternalData('value')<=v );
100
+ }
101
+
102
+ this.m_input.setValue( ''+this.props.value );
103
+ }
104
+
105
+ setSteps( n: number ) {
106
+ this.props.steps = n;
107
+ this._update( );
108
+ }
109
+
110
+ setShape( icon: string ) {
111
+ this.removeClass( this.props.icon );
112
+ this.props.icon = icon;
113
+ }
114
+
115
+ private _on_click( ev: MouseEvent ) {
116
+ let item = componentFromDOM( ev.target as HTMLElement );
117
+ item = item.parentElement( Icon );
118
+
119
+ if( item ) {
120
+ this.setValue( item.getInternalData("value") );
121
+ }
122
+
123
+ this.fire( 'change', {value:this.props.value} );
124
+ }
125
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" fill="currentColor"><!--!Font Awesome Pro 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M374.6 164L306.1 34.3 288.1 0 270 34.3 201.5 164 57.1 189l-38.2 6.6 27 27.8L148.1 328.5 127.2 473.6 121.7 512l34.8-17.1 131.6-64.7 131.6 64.7L454.4 512l-5.5-38.4L428 328.5 530.2 223.4l27-27.8L519 189 374.6 164zM492 216.8l-86.9 89.4-11 11.3 2.2 15.6 17.8 123.5-111.9-55-14.1-6.9-14.1 6.9L162 456.5l17.8-123.5 2.2-15.6-11-11.3L84.1 216.8 207 195.5l15.5-2.7 7.3-13.9L288.1 68.6l58.2 110.3 7.3 13.9 15.5 2.7L492 216.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" fill="currentColor"><!--!Font Awesome Pro 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M288.1 0l86.5 164 182.7 31.6L428 328.5 454.4 512 288.1 430.2 121.7 512l26.4-183.5L18.9 195.6 201.5 164 288.1 0z"/></svg>
@@ -0,0 +1,76 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file shared.scss
9
+ * @author Etienne Cochard
10
+ *
11
+ * @copyright (c) 2024 R-libre ingenierie
12
+ *
13
+ * Use of this source code is governed by an MIT-style license
14
+ * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
+ **/
16
+
17
+ .box {
18
+ position: relative;
19
+ }
20
+
21
+ .hbox {
22
+ @extend .box;
23
+ display: flex;
24
+ flex-direction: row;
25
+ align-items: center;
26
+ }
27
+
28
+ .vbox {
29
+ @extend .box;
30
+ display: flex;
31
+ flex-direction: column;
32
+ }
33
+
34
+
35
+ .fit {
36
+ position: absolute;
37
+ left: 0;
38
+ top: 0;
39
+ right: 0;
40
+ bottom: 0;
41
+ }
42
+
43
+
44
+ .rel-fit {
45
+ position: relative;
46
+ left: 0;
47
+ top: 0;
48
+ right: 0;
49
+ bottom: 0;
50
+ }
51
+
52
+ .flex {
53
+ flex-grow: 1;
54
+ flex-shrink: 0;
55
+ flex-basis: 0;
56
+ min-width: 0;
57
+ }
58
+
59
+
60
+ // from tailwind
61
+
62
+ .shadow-sm {
63
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
64
+ }
65
+
66
+ .shadow-md {
67
+ box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
68
+ }
69
+
70
+ .shadow-lg {
71
+ box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
72
+ }
73
+
74
+ .shadow-xl {
75
+ box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
76
+ }