x4js 2.0.1 → 2.0.3

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 (211) hide show
  1. package/package.json +12 -9
  2. package/lib/README.txt +0 -15
  3. package/lib/src/assets/house-light.svg +0 -1
  4. package/lib/src/assets/radio.svg +0 -4
  5. package/lib/src/components/base.scss +0 -26
  6. package/lib/src/components/boxes/boxes.module.scss +0 -37
  7. package/lib/src/components/boxes/boxes.ts +0 -125
  8. package/lib/src/components/btngroup/btngroup.module.scss +0 -29
  9. package/lib/src/components/btngroup/btngroup.ts +0 -106
  10. package/lib/src/components/button/button.module.scss +0 -154
  11. package/lib/src/components/button/button.ts +0 -117
  12. package/lib/src/components/calendar/calendar-check-sharp-light.svg +0 -1
  13. package/lib/src/components/calendar/calendar.module.scss +0 -163
  14. package/lib/src/components/calendar/calendar.ts +0 -326
  15. package/lib/src/components/calendar/chevron-left-sharp-light.svg +0 -1
  16. package/lib/src/components/calendar/chevron-right-sharp-light.svg +0 -1
  17. package/lib/src/components/checkbox/check.svg +0 -4
  18. package/lib/src/components/checkbox/checkbox.module.scss +0 -142
  19. package/lib/src/components/checkbox/checkbox.ts +0 -125
  20. package/lib/src/components/colorinput/colorinput.module.scss +0 -65
  21. package/lib/src/components/colorinput/colorinput.ts +0 -88
  22. package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +0 -1
  23. package/lib/src/components/colorpicker/colorpicker.module.scss +0 -133
  24. package/lib/src/components/colorpicker/colorpicker.ts +0 -477
  25. package/lib/src/components/combobox/combobox.module.scss +0 -121
  26. package/lib/src/components/combobox/combobox.ts +0 -190
  27. package/lib/src/components/combobox/updown.svg +0 -4
  28. package/lib/src/components/dialog/dialog.module.scss +0 -71
  29. package/lib/src/components/dialog/dialog.ts +0 -91
  30. package/lib/src/components/dialog/xmark-sharp-light.svg +0 -1
  31. package/lib/src/components/form/form.module.scss +0 -34
  32. package/lib/src/components/form/form.ts +0 -36
  33. package/lib/src/components/header/header.module.scss +0 -40
  34. package/lib/src/components/header/header.ts +0 -124
  35. package/lib/src/components/icon/icon.module.scss +0 -30
  36. package/lib/src/components/icon/icon.ts +0 -134
  37. package/lib/src/components/image/image.module.scss +0 -21
  38. package/lib/src/components/image/image.ts +0 -67
  39. package/lib/src/components/input/input.module.scss +0 -69
  40. package/lib/src/components/input/input.ts +0 -274
  41. package/lib/src/components/label/label.module.scss +0 -52
  42. package/lib/src/components/label/label.ts +0 -55
  43. package/lib/src/components/listbox/listbox.module.scss +0 -103
  44. package/lib/src/components/listbox/listbox.ts +0 -427
  45. package/lib/src/components/menu/caret-right-solid.svg +0 -1
  46. package/lib/src/components/menu/menu.module.scss +0 -108
  47. package/lib/src/components/menu/menu.ts +0 -168
  48. package/lib/src/components/messages/circle-exclamation.svg +0 -1
  49. package/lib/src/components/messages/messages.module.scss +0 -47
  50. package/lib/src/components/messages/messages.ts +0 -64
  51. package/lib/src/components/normalize.scss +0 -386
  52. package/lib/src/components/notification/circle-check-solid.svg +0 -1
  53. package/lib/src/components/notification/circle-exclamation-solid.svg +0 -1
  54. package/lib/src/components/notification/circle-notch-light.svg +0 -1
  55. package/lib/src/components/notification/notification.module.scss +0 -82
  56. package/lib/src/components/notification/notification.ts +0 -108
  57. package/lib/src/components/notification/xmark-sharp-light.svg +0 -1
  58. package/lib/src/components/panel/panel.module.scss +0 -48
  59. package/lib/src/components/panel/panel.ts +0 -57
  60. package/lib/src/components/popup/popup.module.scss +0 -43
  61. package/lib/src/components/popup/popup.ts +0 -395
  62. package/lib/src/components/progress/progress.module.scss +0 -57
  63. package/lib/src/components/progress/progress.ts +0 -43
  64. package/lib/src/components/rating/rating.module.scss +0 -23
  65. package/lib/src/components/rating/rating.ts +0 -125
  66. package/lib/src/components/rating/star-sharp-light.svg +0 -1
  67. package/lib/src/components/rating/star-sharp-solid.svg +0 -1
  68. package/lib/src/components/shared.scss +0 -76
  69. package/lib/src/components/sizers/sizer.module.scss +0 -90
  70. package/lib/src/components/sizers/sizer.ts +0 -120
  71. package/lib/src/components/slider/slider.module.scss +0 -71
  72. package/lib/src/components/slider/slider.ts +0 -143
  73. package/lib/src/components/switch/switch.module.scss +0 -127
  74. package/lib/src/components/switch/switch.ts +0 -56
  75. package/lib/src/components/tabs/tabs.module.scss +0 -46
  76. package/lib/src/components/tabs/tabs.ts +0 -157
  77. package/lib/src/components/textarea/textarea.module.scss +0 -59
  78. package/lib/src/components/textarea/textarea.ts +0 -54
  79. package/lib/src/components/textedit/textedit.module.scss +0 -114
  80. package/lib/src/components/textedit/textedit.ts +0 -82
  81. package/lib/src/components/themes.scss +0 -77
  82. package/lib/src/components/tooltips/circle-info-sharp-light.svg +0 -1
  83. package/lib/src/components/tooltips/tooltips.scss +0 -51
  84. package/lib/src/components/tooltips/tooltips.ts +0 -103
  85. package/lib/src/components/treeview/chevron-down-light.svg +0 -1
  86. package/lib/src/components/treeview/treeview.module.scss +0 -116
  87. package/lib/src/components/treeview/treeview.ts +0 -403
  88. package/lib/src/components/viewport/viewport.module.scss +0 -25
  89. package/lib/src/components/viewport/viewport.ts +0 -38
  90. package/lib/src/core/component.ts +0 -979
  91. package/lib/src/core/core_colors.ts +0 -250
  92. package/lib/src/core/core_dom.ts +0 -471
  93. package/lib/src/core/core_dragdrop.ts +0 -201
  94. package/lib/src/core/core_element.ts +0 -98
  95. package/lib/src/core/core_events.ts +0 -149
  96. package/lib/src/core/core_i18n.ts +0 -377
  97. package/lib/src/core/core_router.ts +0 -221
  98. package/lib/src/core/core_styles.ts +0 -215
  99. package/lib/src/core/core_svg.ts +0 -550
  100. package/lib/src/core/core_tools.ts +0 -673
  101. package/lib/src/main.scss +0 -21
  102. package/lib/src/main.tsx +0 -323
  103. package/lib/src/x4.scss +0 -19
  104. package/lib/types/x4.d.ts +0 -2624
  105. package/scripts/build.mjs +0 -351
  106. package/scripts/prepack.mjs +0 -15
  107. package/src/assets/house-light.svg +0 -1
  108. package/src/assets/radio.svg +0 -4
  109. package/src/components/base.scss +0 -26
  110. package/src/components/boxes/boxes.module.scss +0 -37
  111. package/src/components/boxes/boxes.ts +0 -125
  112. package/src/components/btngroup/btngroup.module.scss +0 -29
  113. package/src/components/btngroup/btngroup.ts +0 -106
  114. package/src/components/button/button.module.scss +0 -154
  115. package/src/components/button/button.ts +0 -117
  116. package/src/components/calendar/calendar-check-sharp-light.svg +0 -1
  117. package/src/components/calendar/calendar.module.scss +0 -163
  118. package/src/components/calendar/calendar.ts +0 -326
  119. package/src/components/calendar/chevron-left-sharp-light.svg +0 -1
  120. package/src/components/calendar/chevron-right-sharp-light.svg +0 -1
  121. package/src/components/checkbox/check.svg +0 -4
  122. package/src/components/checkbox/checkbox.module.scss +0 -142
  123. package/src/components/checkbox/checkbox.ts +0 -125
  124. package/src/components/colorinput/colorinput.module.scss +0 -65
  125. package/src/components/colorinput/colorinput.ts +0 -88
  126. package/src/components/colorinput/crosshairs-simple-sharp-light.svg +0 -1
  127. package/src/components/colorpicker/colorpicker.module.scss +0 -133
  128. package/src/components/colorpicker/colorpicker.ts +0 -477
  129. package/src/components/combobox/combobox.module.scss +0 -121
  130. package/src/components/combobox/combobox.ts +0 -190
  131. package/src/components/combobox/updown.svg +0 -4
  132. package/src/components/dialog/dialog.module.scss +0 -71
  133. package/src/components/dialog/dialog.ts +0 -91
  134. package/src/components/dialog/xmark-sharp-light.svg +0 -1
  135. package/src/components/form/form.module.scss +0 -34
  136. package/src/components/form/form.ts +0 -36
  137. package/src/components/header/header.module.scss +0 -40
  138. package/src/components/header/header.ts +0 -124
  139. package/src/components/icon/icon.module.scss +0 -30
  140. package/src/components/icon/icon.ts +0 -134
  141. package/src/components/image/image.module.scss +0 -21
  142. package/src/components/image/image.ts +0 -67
  143. package/src/components/input/input.module.scss +0 -69
  144. package/src/components/input/input.ts +0 -274
  145. package/src/components/label/label.module.scss +0 -52
  146. package/src/components/label/label.ts +0 -55
  147. package/src/components/listbox/listbox.module.scss +0 -103
  148. package/src/components/listbox/listbox.ts +0 -427
  149. package/src/components/menu/caret-right-solid.svg +0 -1
  150. package/src/components/menu/menu.module.scss +0 -108
  151. package/src/components/menu/menu.ts +0 -168
  152. package/src/components/messages/circle-exclamation.svg +0 -1
  153. package/src/components/messages/messages.module.scss +0 -47
  154. package/src/components/messages/messages.ts +0 -64
  155. package/src/components/normalize.scss +0 -386
  156. package/src/components/notification/circle-check-solid.svg +0 -1
  157. package/src/components/notification/circle-exclamation-solid.svg +0 -1
  158. package/src/components/notification/circle-notch-light.svg +0 -1
  159. package/src/components/notification/notification.module.scss +0 -82
  160. package/src/components/notification/notification.ts +0 -108
  161. package/src/components/notification/xmark-sharp-light.svg +0 -1
  162. package/src/components/panel/panel.module.scss +0 -48
  163. package/src/components/panel/panel.ts +0 -57
  164. package/src/components/popup/popup.module.scss +0 -43
  165. package/src/components/popup/popup.ts +0 -395
  166. package/src/components/progress/progress.module.scss +0 -57
  167. package/src/components/progress/progress.ts +0 -43
  168. package/src/components/rating/rating.module.scss +0 -23
  169. package/src/components/rating/rating.ts +0 -125
  170. package/src/components/rating/star-sharp-light.svg +0 -1
  171. package/src/components/rating/star-sharp-solid.svg +0 -1
  172. package/src/components/shared.scss +0 -76
  173. package/src/components/sizers/sizer.module.scss +0 -90
  174. package/src/components/sizers/sizer.ts +0 -120
  175. package/src/components/slider/slider.module.scss +0 -71
  176. package/src/components/slider/slider.ts +0 -143
  177. package/src/components/switch/switch.module.scss +0 -127
  178. package/src/components/switch/switch.ts +0 -56
  179. package/src/components/tabs/tabs.module.scss +0 -46
  180. package/src/components/tabs/tabs.ts +0 -157
  181. package/src/components/textarea/textarea.module.scss +0 -59
  182. package/src/components/textarea/textarea.ts +0 -54
  183. package/src/components/textedit/textedit.module.scss +0 -114
  184. package/src/components/textedit/textedit.ts +0 -82
  185. package/src/components/themes.scss +0 -77
  186. package/src/components/tooltips/circle-info-sharp-light.svg +0 -1
  187. package/src/components/tooltips/tooltips.scss +0 -51
  188. package/src/components/tooltips/tooltips.ts +0 -103
  189. package/src/components/treeview/chevron-down-light.svg +0 -1
  190. package/src/components/treeview/treeview.module.scss +0 -116
  191. package/src/components/treeview/treeview.ts +0 -403
  192. package/src/components/viewport/viewport.module.scss +0 -25
  193. package/src/components/viewport/viewport.ts +0 -38
  194. package/src/core/component.ts +0 -979
  195. package/src/core/core_colors.ts +0 -250
  196. package/src/core/core_dom.ts +0 -471
  197. package/src/core/core_dragdrop.ts +0 -201
  198. package/src/core/core_element.ts +0 -98
  199. package/src/core/core_events.ts +0 -149
  200. package/src/core/core_i18n.ts +0 -377
  201. package/src/core/core_router.ts +0 -221
  202. package/src/core/core_styles.ts +0 -215
  203. package/src/core/core_svg.ts +0 -550
  204. package/src/core/core_tools.ts +0 -673
  205. package/src/main.scss +0 -21
  206. package/src/main.tsx +0 -323
  207. package/src/x4.scss +0 -19
  208. package/tsconfig.json +0 -14
  209. package/types/scss.d.ts +0 -4
  210. package/types/svg.d.ts +0 -4
  211. package/types/x4react.d.ts +0 -9
@@ -1,395 +0,0 @@
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
-
@@ -1,57 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
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
- }
@@ -1,23 +0,0 @@
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
- }
@@ -1,125 +0,0 @@
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
- }
@@ -1 +0,0 @@
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>
@@ -1 +0,0 @@
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>
@@ -1,76 +0,0 @@
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
- }