x4js 2.0.20 → 2.0.21

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 (172) hide show
  1. package/lib/cjs/x4.css +1 -1
  2. package/lib/cjs/x4.js +2 -2
  3. package/lib/esm/x4.css +1 -1
  4. package/lib/esm/x4.mjs +2 -2
  5. package/lib/styles/x4.css +1 -1
  6. package/lib/types/x4js.d.ts +92 -77
  7. package/package.json +1 -1
  8. package/src/components/boxes/boxes.ts +33 -1
  9. package/src/components/combobox/combobox.module.scss +13 -0
  10. package/src/components/combobox/combobox.ts +7 -0
  11. package/src/components/form/form.ts +4 -4
  12. package/src/components/gridview/gridview.ts +12 -9
  13. package/src/components/header/header.module.scss +2 -1
  14. package/src/components/header/header.ts +17 -5
  15. package/src/components/icon/icon.module.scss +1 -0
  16. package/src/components/label/label.module.scss +6 -1
  17. package/src/components/listbox/listbox.module.scss +35 -31
  18. package/src/components/listbox/listbox.ts +50 -12
  19. package/src/components/messages/messages.ts +14 -0
  20. package/src/components/notification/notification.ts +1 -1
  21. package/src/components/popup/popup.ts +13 -2
  22. package/src/components/propgrid/propgrid.ts +4 -2
  23. package/src/components/sizers/sizer.ts +4 -4
  24. package/src/components/tabs/tabs.module.scss +2 -2
  25. package/src/components/tabs/tabs.ts +28 -4
  26. package/src/components/textedit/textedit.ts +1 -1
  27. package/src/components/treeview/treeview.module.scss +9 -1
  28. package/src/components/treeview/treeview.ts +52 -13
  29. package/src/core/component.ts +46 -9
  30. package/src/core/core_data.ts +8 -8
  31. package/src/core/core_state.ts +1 -1
  32. package/src/core/core_tools.ts +2 -0
  33. package/lib/src/components/base.scss +0 -25
  34. package/lib/src/components/boxes/boxes.module.scss +0 -54
  35. package/lib/src/components/boxes/boxes.ts +0 -370
  36. package/lib/src/components/breadcrumb/breadcrumb.scss +0 -56
  37. package/lib/src/components/breadcrumb/breadcrumb.ts +0 -93
  38. package/lib/src/components/breadcrumb/chevron-right.svg +0 -1
  39. package/lib/src/components/btngroup/btngroup.module.scss +0 -41
  40. package/lib/src/components/btngroup/btngroup.ts +0 -153
  41. package/lib/src/components/button/button.module.scss +0 -173
  42. package/lib/src/components/button/button.ts +0 -185
  43. package/lib/src/components/calendar/calendar-check-sharp-light.svg +0 -1
  44. package/lib/src/components/calendar/calendar.module.scss +0 -163
  45. package/lib/src/components/calendar/calendar.ts +0 -327
  46. package/lib/src/components/calendar/chevron-left-sharp-light.svg +0 -1
  47. package/lib/src/components/calendar/chevron-right-sharp-light.svg +0 -1
  48. package/lib/src/components/canvas/canvas.module.scss +0 -25
  49. package/lib/src/components/canvas/canvas.ts +0 -189
  50. package/lib/src/components/canvas/canvas_ex.ts +0 -276
  51. package/lib/src/components/checkbox/check.svg +0 -4
  52. package/lib/src/components/checkbox/checkbox.module.scss +0 -142
  53. package/lib/src/components/checkbox/checkbox.ts +0 -140
  54. package/lib/src/components/colorinput/colorinput.module.scss +0 -65
  55. package/lib/src/components/colorinput/colorinput.ts +0 -91
  56. package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +0 -1
  57. package/lib/src/components/colorpicker/colorpicker.module.scss +0 -133
  58. package/lib/src/components/colorpicker/colorpicker.ts +0 -482
  59. package/lib/src/components/combobox/combobox.module.scss +0 -133
  60. package/lib/src/components/combobox/combobox.ts +0 -275
  61. package/lib/src/components/combobox/updown.svg +0 -4
  62. package/lib/src/components/components.ts +0 -42
  63. package/lib/src/components/dialog/dialog.module.scss +0 -104
  64. package/lib/src/components/dialog/dialog.ts +0 -229
  65. package/lib/src/components/dialog/xmark-sharp-light.svg +0 -1
  66. package/lib/src/components/filedrop/cloud-arrow-up.svg +0 -1
  67. package/lib/src/components/filedrop/filedrop.module.scss +0 -70
  68. package/lib/src/components/filedrop/filedrop.ts +0 -131
  69. package/lib/src/components/form/form.module.scss +0 -38
  70. package/lib/src/components/form/form.ts +0 -172
  71. package/lib/src/components/gridview/arrow-down-light.svg +0 -1
  72. package/lib/src/components/gridview/arrow-up-light.svg +0 -1
  73. package/lib/src/components/gridview/gridview.module.scss +0 -324
  74. package/lib/src/components/gridview/gridview.ts +0 -1175
  75. package/lib/src/components/header/header.module.scss +0 -40
  76. package/lib/src/components/header/header.ts +0 -130
  77. package/lib/src/components/icon/icon.module.scss +0 -31
  78. package/lib/src/components/icon/icon.ts +0 -137
  79. package/lib/src/components/image/image.module.scss +0 -28
  80. package/lib/src/components/image/image.ts +0 -168
  81. package/lib/src/components/input/input.module.scss +0 -74
  82. package/lib/src/components/input/input.ts +0 -422
  83. package/lib/src/components/keyboard/arrow-up.svg +0 -1
  84. package/lib/src/components/keyboard/delete-left.svg +0 -1
  85. package/lib/src/components/keyboard/eye-slash.svg +0 -1
  86. package/lib/src/components/keyboard/keyboard.module.scss +0 -134
  87. package/lib/src/components/keyboard/keyboard.ts +0 -526
  88. package/lib/src/components/label/label.module.scss +0 -76
  89. package/lib/src/components/label/label.ts +0 -97
  90. package/lib/src/components/link/link.ts +0 -81
  91. package/lib/src/components/listbox/listbox.module.scss +0 -161
  92. package/lib/src/components/listbox/listbox.ts +0 -539
  93. package/lib/src/components/menu/caret-right-solid.svg +0 -1
  94. package/lib/src/components/menu/menu.module.scss +0 -117
  95. package/lib/src/components/menu/menu.ts +0 -174
  96. package/lib/src/components/messages/circle-exclamation.svg +0 -1
  97. package/lib/src/components/messages/messages.module.scss +0 -92
  98. package/lib/src/components/messages/messages.ts +0 -215
  99. package/lib/src/components/messages/pen-field.svg +0 -1
  100. package/lib/src/components/normalize.scss +0 -391
  101. package/lib/src/components/notification/circle-check-solid.svg +0 -1
  102. package/lib/src/components/notification/circle-exclamation-solid.svg +0 -1
  103. package/lib/src/components/notification/circle-notch-light.svg +0 -1
  104. package/lib/src/components/notification/notification.module.scss +0 -84
  105. package/lib/src/components/notification/notification.ts +0 -107
  106. package/lib/src/components/notification/xmark-sharp-light.svg +0 -1
  107. package/lib/src/components/panel/panel.module.scss +0 -60
  108. package/lib/src/components/panel/panel.ts +0 -58
  109. package/lib/src/components/popup/popup.module.scss +0 -51
  110. package/lib/src/components/popup/popup.ts +0 -442
  111. package/lib/src/components/progress/progress.module.scss +0 -57
  112. package/lib/src/components/progress/progress.ts +0 -44
  113. package/lib/src/components/propgrid/folder-closed.svg +0 -1
  114. package/lib/src/components/propgrid/folder-open.svg +0 -1
  115. package/lib/src/components/propgrid/progrid.module.scss +0 -112
  116. package/lib/src/components/propgrid/propgrid.ts +0 -288
  117. package/lib/src/components/propgrid/updown.svg +0 -4
  118. package/lib/src/components/radio/radio.module.scss +0 -147
  119. package/lib/src/components/radio/radio.svg +0 -4
  120. package/lib/src/components/radio/radio.ts +0 -142
  121. package/lib/src/components/rating/rating.module.scss +0 -23
  122. package/lib/src/components/rating/rating.ts +0 -131
  123. package/lib/src/components/rating/star-sharp-light.svg +0 -1
  124. package/lib/src/components/rating/star-sharp-solid.svg +0 -1
  125. package/lib/src/components/select/select.module.scss +0 -9
  126. package/lib/src/components/select/select.ts +0 -134
  127. package/lib/src/components/shared.scss +0 -137
  128. package/lib/src/components/sizers/sizer.module.scss +0 -90
  129. package/lib/src/components/sizers/sizer.ts +0 -132
  130. package/lib/src/components/slider/slider.module.scss +0 -118
  131. package/lib/src/components/slider/slider.ts +0 -198
  132. package/lib/src/components/switch/switch.module.scss +0 -127
  133. package/lib/src/components/switch/switch.ts +0 -62
  134. package/lib/src/components/tabs/tabs.module.scss +0 -45
  135. package/lib/src/components/tabs/tabs.ts +0 -205
  136. package/lib/src/components/textarea/textarea.module.scss +0 -63
  137. package/lib/src/components/textarea/textarea.ts +0 -125
  138. package/lib/src/components/textedit/textedit.module.scss +0 -116
  139. package/lib/src/components/textedit/textedit.ts +0 -115
  140. package/lib/src/components/themes.scss +0 -88
  141. package/lib/src/components/tickline/tickline.module.scss +0 -26
  142. package/lib/src/components/tickline/tickline.ts +0 -82
  143. package/lib/src/components/tooltips/circle-info-sharp-light.svg +0 -1
  144. package/lib/src/components/tooltips/comments-question.svg +0 -1
  145. package/lib/src/components/tooltips/tooltips.scss +0 -72
  146. package/lib/src/components/tooltips/tooltips.ts +0 -109
  147. package/lib/src/components/treeview/chevron-down-light.svg +0 -1
  148. package/lib/src/components/treeview/treeview.module.scss +0 -185
  149. package/lib/src/components/treeview/treeview.ts +0 -445
  150. package/lib/src/components/viewport/viewport.module.scss +0 -32
  151. package/lib/src/components/viewport/viewport.ts +0 -41
  152. package/lib/src/core/component.ts +0 -1066
  153. package/lib/src/core/core_application.ts +0 -265
  154. package/lib/src/core/core_colors.ts +0 -250
  155. package/lib/src/core/core_data.ts +0 -1310
  156. package/lib/src/core/core_dom.ts +0 -471
  157. package/lib/src/core/core_dragdrop.ts +0 -201
  158. package/lib/src/core/core_element.ts +0 -115
  159. package/lib/src/core/core_events.ts +0 -177
  160. package/lib/src/core/core_i18n.ts +0 -393
  161. package/lib/src/core/core_react.ts +0 -79
  162. package/lib/src/core/core_router.ts +0 -237
  163. package/lib/src/core/core_state.ts +0 -62
  164. package/lib/src/core/core_styles.ts +0 -214
  165. package/lib/src/core/core_svg.ts +0 -712
  166. package/lib/src/core/core_tools.ts +0 -906
  167. package/lib/src/types/scss.d.ts +0 -4
  168. package/lib/src/types/svg.d.ts +0 -1
  169. package/lib/src/types/x4react.d.ts +0 -9
  170. package/lib/src/x4.scss +0 -19
  171. package/lib/src/x4.ts +0 -35
  172. package/lib/src/x4tsx.d.ts +0 -25
@@ -1,131 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
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';
18
- import { EventCallback } from '../../core/core_events';
19
- import { HBox } from '../boxes/boxes';
20
- import { Input } from '../input/input';
21
- import { Icon } from '../icon/icon';
22
-
23
- import "./rating.module.scss"
24
- import star_icon from "./star-sharp-solid.svg"
25
- import { class_ns } from '../../core/core_tools';
26
-
27
- interface RatingEventMap extends ComponentEvents {
28
- change: EvChange;
29
- }
30
-
31
-
32
-
33
- export interface RatingProps extends ComponentProps {
34
- steps?: number;
35
- value?: number;
36
- icon?: string;
37
- name?: string;
38
-
39
- change?: EventCallback<EvChange>;
40
- }
41
-
42
- /**
43
- *
44
- */
45
-
46
- @class_ns( "x4" )
47
- export class Rating extends HBox<RatingProps,RatingEventMap> {
48
-
49
- private m_els: Component[];
50
- private m_input: Input;
51
-
52
- constructor( props: RatingProps ) {
53
- super( props );
54
-
55
- props.steps = props.steps ?? 5;
56
- this._update( );
57
- }
58
-
59
- private _update( ) {
60
-
61
- const props = this.props;
62
-
63
- let shape = props.icon ?? star_icon;
64
- let value = props.value ?? 0;
65
-
66
- this.m_input = new Input( {
67
- type: "text",
68
- hidden: true,
69
- name: props.name,
70
- value: ''+value
71
- } );
72
-
73
- this.addDOMEvent( 'click', (e) => this._on_click(e) );
74
-
75
- this.m_els = [];
76
- for( let i=0; i<props.steps; i++ ) {
77
-
78
- let cls = 'item';
79
- if( i+1 <= value ) {
80
- cls += ' checked';
81
- }
82
-
83
- let c = new Icon( {
84
- cls,
85
- iconId: shape,
86
- } );
87
-
88
- c.setInternalData( "value", i );
89
-
90
- this.m_els.push( c );
91
- }
92
-
93
- this.m_els.push( this.m_input );
94
- this.setContent( this.m_els );
95
- }
96
-
97
- getValue( ) {
98
- return this.props.value ?? 0;
99
- }
100
-
101
- setValue( v: number ) {
102
- this.props.value = v;
103
-
104
- for( let c=0; c<this.props.steps; c++ ) {
105
- this.m_els[c].setClass( 'checked', this.m_els[c].getInternalData('value')<=v );
106
- }
107
-
108
- this.m_input.setValue( ''+this.props.value );
109
- }
110
-
111
- setSteps( n: number ) {
112
- this.props.steps = n;
113
- this._update( );
114
- }
115
-
116
- setShape( icon: string ) {
117
- this.removeClass( this.props.icon );
118
- this.props.icon = icon;
119
- }
120
-
121
- private _on_click( ev: MouseEvent ) {
122
- let item = componentFromDOM( ev.target as HTMLElement );
123
- item = item.parentElement( Icon );
124
-
125
- if( item ) {
126
- this.setValue( item.getInternalData("value") );
127
- }
128
-
129
- this.fire( 'change', {value:this.props.value} );
130
- }
131
- }
@@ -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,9 +0,0 @@
1
-
2
-
3
- .x4select {
4
- padding: 4px;
5
- outline: none;
6
-
7
- border: 1px solid var( --border );
8
- background-color: white;
9
- }
@@ -1,134 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|.2
7
- *
8
- * @file select.ts
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2025 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
-
18
- import { EventCallback } from '../../core/core_events';
19
- import { Component, ComponentEvent, ComponentProps, EvChange, EvFocus } from '../../core/component';
20
- import { class_ns } from '../../core/core_tools';
21
-
22
- import { ListItem } from '../components';
23
-
24
- import "./select.module.scss"
25
-
26
- /**
27
- *
28
- */
29
-
30
- export interface SelectProps extends ComponentProps {
31
- name?: string;
32
- value: string;
33
- items: ListItem[];
34
- multiple?: boolean;
35
- change?: EventCallback<EvChange>;
36
- focus?: EventCallback<EvFocus>;
37
- }
38
-
39
- interface SelectEvents extends ComponentEvent {
40
- focus: EvFocus;
41
- change: EvChange;
42
- }
43
-
44
-
45
- /**
46
- * simple select
47
- */
48
-
49
- @class_ns( "x4" )
50
- export class Select extends Component<SelectProps,SelectEvents> {
51
-
52
- constructor( props: SelectProps ) {
53
- super( { tag: "select", ...props } );
54
-
55
- this.mapPropEvents( props, "focus", "change" );
56
- if( props.name ) {
57
- this.setAttribute( "name", props.name );
58
- }
59
-
60
- this.setItems( props.items );
61
-
62
- this.addDOMEvent( "blur", ( e ) => { this.on_focus(e,true);} );
63
- this.addDOMEvent( "focus", ( e ) => { this.on_focus(e,false);} );
64
- this.addDOMEvent( "input", ( e ) => { this.on_change(e as InputEvent); });
65
-
66
- if( props.multiple ) {
67
- this.setAttribute( "multiple", true );
68
- }
69
-
70
- if( props.value ) {
71
- this.setValue( props.value );
72
- }
73
- }
74
-
75
- /**
76
- *
77
- */
78
-
79
- private on_focus( ev: FocusEvent, focus_out: boolean ) {
80
- const event: EvFocus = { focus_out }
81
- this.fire( "focus", event );
82
-
83
- if( event.defaultPrevented ) {
84
- ev.preventDefault( );
85
- }
86
- }
87
-
88
- /**
89
- *
90
- */
91
-
92
- private on_change( ev: InputEvent ) {
93
-
94
- const event: EvChange = { value: this.getValue() };
95
- this.fire( "change", event );
96
-
97
- if( event.defaultPrevented ) {
98
- ev.preventDefault( );
99
- }
100
- }
101
-
102
- /**
103
- *
104
- */
105
-
106
- setItems( items: ListItem[] ) {
107
- this.setContent( items.map( x => {
108
- return new Component( {
109
- tag: "option",
110
- attrs: { value: x.id },
111
- content: x.text,
112
- });
113
- } ));
114
- }
115
-
116
- /**
117
- * @returns
118
- */
119
-
120
- public getValue( ) {
121
- return (this.dom as HTMLSelectElement).value;
122
- }
123
-
124
- /**
125
- *
126
- * @param value
127
- */
128
-
129
- public setValue( value: string ) {
130
- (this.dom as HTMLSelectElement).value = value+"";
131
- }
132
- }
133
-
134
-
@@ -1,137 +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
- }
77
-
78
-
79
- @keyframes rotating {
80
- from {
81
- transform: rotate(0deg);
82
- }
83
- to {
84
- transform: rotate(360deg);
85
- }
86
- }
87
-
88
- @keyframes shaking {
89
- 0% {
90
- transform: rotate(-15deg)
91
- }
92
-
93
- 4% {
94
- transform: rotate(15deg)
95
- }
96
-
97
- 8%,24% {
98
- transform: rotate(-18deg)
99
- }
100
-
101
- 12%,28% {
102
- transform: rotate(18deg)
103
- }
104
-
105
- 16% {
106
- transform: rotate(-22deg)
107
- }
108
-
109
- 20% {
110
- transform: rotate(22deg)
111
- }
112
-
113
- 32% {
114
- transform: rotate(-12deg)
115
- }
116
-
117
- 36% {
118
- transform: rotate(12deg)
119
- }
120
-
121
- 40% {
122
- transform: rotate(0deg)
123
- }
124
- }
125
-
126
-
127
- .x4rotate {
128
- animation: rotating 2s linear infinite;
129
- }
130
-
131
- .x4shake {
132
- animation-name: shaking;
133
- animation-duration: 5s;
134
- animation-iteration-count: infinite;
135
- animation-timing-function: linear;
136
- animation-direction: reverse;
137
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file sizer.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
-
18
- .x4csizer {
19
- position: absolute;
20
-
21
- @mixin horz {
22
- left: 0;
23
- right: 0;
24
- height: 8px;
25
- z-index: 10;
26
- cursor: ns-resize;
27
- }
28
-
29
- &.top {
30
- @include horz;
31
- top: 0;
32
- }
33
-
34
- &.bottom {
35
- @include horz;
36
- bottom: 0;
37
- }
38
-
39
- @mixin vert {
40
- top: 0;
41
- bottom: 0;
42
- width: 8px;
43
- z-index: 10;
44
- cursor: ew-resize;
45
- }
46
-
47
- &.left {
48
- @include vert;
49
- left: 0;
50
- }
51
-
52
- &.right {
53
- @include vert;
54
- right: 0;
55
- }
56
-
57
- @mixin corner {
58
- width: 8px;
59
- height: 8px;
60
- z-index: 11;
61
- }
62
-
63
- &.top-left {
64
- @include corner;
65
- left: 0;
66
- top: 0;
67
- cursor: nw-resize;
68
- }
69
-
70
- &.top-right {
71
- @include corner;
72
- right: 0;
73
- top: 0;
74
- cursor: ne-resize;
75
- }
76
-
77
- &.bottom-left {
78
- @include corner;
79
- left: 0;
80
- bottom: 0;
81
- cursor: ne-resize;
82
- }
83
-
84
- &.bottom-right {
85
- @include corner;
86
- right: 0;
87
- bottom: 0;
88
- cursor: nw-resize;
89
- }
90
- }
@@ -1,132 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file sizer.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 } from '../../core/component';
18
- import { class_ns, Point } from '../../core/core_tools';
19
-
20
- import "./sizer.module.scss"
21
-
22
- /**
23
- *
24
- */
25
-
26
- interface EvSizeChange extends ComponentEvent {
27
- size: number;
28
- }
29
-
30
- interface CSizerEvent extends ComponentEvents {
31
- resize: EvSizeChange;
32
- start: ComponentEvent;
33
- stop: ComponentEvent;
34
- }
35
-
36
- type SizerType = "left" | "top" | "right" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
37
-
38
- /**
39
- *
40
- */
41
-
42
-
43
- @class_ns( "x4" )
44
- export class CSizer extends Component<ComponentProps,CSizerEvent> {
45
-
46
- private _type: SizerType;
47
- private _ref: Component;
48
- private _delta: Point;
49
-
50
- constructor( type: SizerType, target?: Component ) {
51
- super( {} );
52
-
53
- this._type = type;
54
- this.addClass( type );
55
-
56
- this.addDOMEvent( "pointerdown", ( e: PointerEvent ) => {
57
- this.setCapture( e.pointerId );
58
- this._ref = target ?? componentFromDOM( this.dom.parentElement );
59
-
60
- this._delta = {x:0,y:0};
61
- const rc = this._ref.getBoundingRect();
62
-
63
- if( this._type.includes("left") ) {
64
- this._delta.x = e.pageX-rc.left;
65
- }
66
- else {
67
- this._delta.x = e.pageX-(rc.left+rc.width);
68
- }
69
-
70
- if( this._type.includes("top") ) {
71
- this._delta.y = e.pageY-rc.top;
72
- }
73
- else {
74
- this._delta.y = e.pageY-(rc.top+rc.height);
75
- }
76
-
77
- this.fire( "start", { })
78
- });
79
-
80
- this.addDOMEvent( "pointerup", ( e: PointerEvent ) => {
81
- this.fire( "stop", { })
82
- this.releaseCapture( e.pointerId );
83
- this._ref = null;
84
- });
85
-
86
- this.addDOMEvent( "pointermove", ( e: PointerEvent ) => {
87
- this._onMouseMove( e );
88
- });
89
- }
90
-
91
- private _onMouseMove( e: PointerEvent ) {
92
- if( !this._ref ) {
93
- return;
94
- }
95
-
96
- const pt = { x: e.pageX-this._delta.x, y: e.pageY-this._delta.y };
97
- const rc = this._ref.getBoundingRect( );
98
-
99
- let nr: any = {};
100
- let horz = true;
101
-
102
- if( this._type.includes("top") ) {
103
- nr.top = pt.y,
104
- nr.height = (rc.top+rc.height)-pt.y;
105
- horz = false;
106
- }
107
-
108
- if( this._type.includes("bottom") ) {
109
- //nr.top = rc.top;
110
- nr.height = (pt.y-rc.top);
111
- horz = false;
112
- }
113
-
114
- if( this._type.includes("left") ) {
115
- nr.left = pt.x;
116
- nr.width = ((rc.left+rc.width)-pt.x);
117
- }
118
-
119
- if( this._type.includes("right") ) {
120
- //nr.left = rc.left;
121
- nr.width = (pt.x-rc.left);
122
- }
123
-
124
- this._ref.setStyle( nr );
125
-
126
- const nrc = this._ref.getBoundingRect( );
127
- this.fire( "resize", { size: horz ? nrc.width : nrc.height })
128
-
129
- e.preventDefault( );
130
- e.stopPropagation( );
131
- }
132
- }