x4js 2.0.4 → 2.0.6

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 (222) hide show
  1. package/build/x4.css +1 -0
  2. package/build/x4.js +1 -0
  3. package/lib/README.txt +15 -0
  4. package/lib/cjs/x4.css +1 -0
  5. package/lib/cjs/x4.js +1 -0
  6. package/lib/esm/x4.css +1 -0
  7. package/lib/esm/x4.mjs +1 -0
  8. package/lib/src/components/base.scss +26 -0
  9. package/lib/src/components/boxes/boxes.module.scss +37 -0
  10. package/lib/src/components/boxes/boxes.ts +125 -0
  11. package/lib/src/components/btngroup/btngroup.module.scss +29 -0
  12. package/lib/src/components/btngroup/btngroup.ts +106 -0
  13. package/lib/src/components/button/button.module.scss +154 -0
  14. package/lib/src/components/button/button.ts +117 -0
  15. package/lib/src/components/calendar/calendar-check-sharp-light.svg +1 -0
  16. package/lib/src/components/calendar/calendar.module.scss +163 -0
  17. package/lib/src/components/calendar/calendar.ts +326 -0
  18. package/lib/src/components/calendar/chevron-left-sharp-light.svg +1 -0
  19. package/lib/src/components/calendar/chevron-right-sharp-light.svg +1 -0
  20. package/lib/src/components/checkbox/check.svg +4 -0
  21. package/lib/src/components/checkbox/checkbox.module.scss +142 -0
  22. package/lib/src/components/checkbox/checkbox.ts +125 -0
  23. package/lib/src/components/colorinput/colorinput.module.scss +65 -0
  24. package/lib/src/components/colorinput/colorinput.ts +88 -0
  25. package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
  26. package/lib/src/components/colorpicker/colorpicker.module.scss +133 -0
  27. package/lib/src/components/colorpicker/colorpicker.ts +477 -0
  28. package/lib/src/components/combobox/combobox.module.scss +121 -0
  29. package/lib/src/components/combobox/combobox.ts +190 -0
  30. package/lib/src/components/combobox/updown.svg +4 -0
  31. package/lib/src/components/dialog/dialog.module.scss +71 -0
  32. package/lib/src/components/dialog/dialog.ts +91 -0
  33. package/lib/src/components/dialog/xmark-sharp-light.svg +1 -0
  34. package/lib/src/components/form/form.module.scss +34 -0
  35. package/lib/src/components/form/form.ts +36 -0
  36. package/lib/src/components/header/header.module.scss +40 -0
  37. package/lib/src/components/header/header.ts +124 -0
  38. package/lib/src/components/icon/icon.module.scss +30 -0
  39. package/lib/src/components/icon/icon.ts +134 -0
  40. package/lib/src/components/image/image.module.scss +21 -0
  41. package/lib/src/components/image/image.ts +67 -0
  42. package/lib/src/components/input/input.module.scss +69 -0
  43. package/lib/src/components/input/input.ts +274 -0
  44. package/lib/src/components/label/label.module.scss +52 -0
  45. package/lib/src/components/label/label.ts +55 -0
  46. package/lib/src/components/listbox/listbox.module.scss +103 -0
  47. package/lib/src/components/listbox/listbox.ts +427 -0
  48. package/lib/src/components/menu/caret-right-solid.svg +1 -0
  49. package/lib/src/components/menu/menu.module.scss +108 -0
  50. package/lib/src/components/menu/menu.ts +168 -0
  51. package/lib/src/components/messages/circle-exclamation.svg +1 -0
  52. package/lib/src/components/messages/messages.module.scss +47 -0
  53. package/lib/src/components/messages/messages.ts +64 -0
  54. package/lib/src/components/normalize.scss +386 -0
  55. package/lib/src/components/notification/circle-check-solid.svg +1 -0
  56. package/lib/src/components/notification/circle-exclamation-solid.svg +1 -0
  57. package/lib/src/components/notification/circle-notch-light.svg +1 -0
  58. package/lib/src/components/notification/notification.module.scss +82 -0
  59. package/lib/src/components/notification/notification.ts +108 -0
  60. package/lib/src/components/notification/xmark-sharp-light.svg +1 -0
  61. package/lib/src/components/panel/panel.module.scss +48 -0
  62. package/lib/src/components/panel/panel.ts +57 -0
  63. package/lib/src/components/popup/popup.module.scss +43 -0
  64. package/lib/src/components/popup/popup.ts +395 -0
  65. package/lib/src/components/progress/progress.module.scss +57 -0
  66. package/lib/src/components/progress/progress.ts +43 -0
  67. package/lib/src/components/rating/rating.module.scss +23 -0
  68. package/lib/src/components/rating/rating.ts +125 -0
  69. package/lib/src/components/rating/star-sharp-light.svg +1 -0
  70. package/lib/src/components/rating/star-sharp-solid.svg +1 -0
  71. package/lib/src/components/shared.scss +76 -0
  72. package/lib/src/components/sizers/sizer.module.scss +90 -0
  73. package/lib/src/components/sizers/sizer.ts +120 -0
  74. package/lib/src/components/slider/slider.module.scss +71 -0
  75. package/lib/src/components/slider/slider.ts +143 -0
  76. package/lib/src/components/switch/switch.module.scss +127 -0
  77. package/lib/src/components/switch/switch.ts +56 -0
  78. package/lib/src/components/tabs/tabs.module.scss +46 -0
  79. package/lib/src/components/tabs/tabs.ts +157 -0
  80. package/lib/src/components/textarea/textarea.module.scss +59 -0
  81. package/lib/src/components/textarea/textarea.ts +54 -0
  82. package/lib/src/components/textedit/textedit.module.scss +114 -0
  83. package/lib/src/components/textedit/textedit.ts +82 -0
  84. package/lib/src/components/themes.scss +77 -0
  85. package/lib/src/components/tooltips/circle-info-sharp-light.svg +1 -0
  86. package/lib/src/components/tooltips/tooltips.scss +51 -0
  87. package/lib/src/components/tooltips/tooltips.ts +103 -0
  88. package/lib/src/components/treeview/chevron-down-light.svg +1 -0
  89. package/lib/src/components/treeview/treeview.module.scss +116 -0
  90. package/lib/src/components/treeview/treeview.ts +403 -0
  91. package/lib/src/components/viewport/viewport.module.scss +25 -0
  92. package/lib/src/components/viewport/viewport.ts +38 -0
  93. package/lib/src/core/component.ts +979 -0
  94. package/lib/src/core/core_colors.ts +250 -0
  95. package/lib/src/core/core_dom.ts +471 -0
  96. package/lib/src/core/core_dragdrop.ts +201 -0
  97. package/lib/src/core/core_element.ts +98 -0
  98. package/lib/src/core/core_events.ts +149 -0
  99. package/lib/src/core/core_i18n.ts +377 -0
  100. package/lib/src/core/core_router.ts +221 -0
  101. package/lib/src/core/core_styles.ts +215 -0
  102. package/lib/src/core/core_svg.ts +550 -0
  103. package/lib/src/core/core_tools.ts +673 -0
  104. package/lib/src/demo/assets/house-light.svg +1 -0
  105. package/lib/src/demo/assets/radio.svg +4 -0
  106. package/lib/src/demo/index.html +12 -0
  107. package/lib/src/demo/main.scss +21 -0
  108. package/lib/src/demo/main.tsx +323 -0
  109. package/lib/src/x4.scss +19 -0
  110. package/lib/src/x4.ts +60 -0
  111. package/lib/styles/x4.css +1 -0
  112. package/lib/types/x4.d.ts +45060 -0
  113. package/package.json +3 -12
  114. package/scripts/build.mjs +362 -0
  115. package/scripts/prepack.mjs +51 -0
  116. package/src/components/base.scss +26 -0
  117. package/src/components/boxes/boxes.module.scss +37 -0
  118. package/src/components/boxes/boxes.ts +125 -0
  119. package/src/components/btngroup/btngroup.module.scss +29 -0
  120. package/src/components/btngroup/btngroup.ts +106 -0
  121. package/src/components/button/button.module.scss +154 -0
  122. package/src/components/button/button.ts +117 -0
  123. package/src/components/calendar/calendar-check-sharp-light.svg +1 -0
  124. package/src/components/calendar/calendar.module.scss +163 -0
  125. package/src/components/calendar/calendar.ts +326 -0
  126. package/src/components/calendar/chevron-left-sharp-light.svg +1 -0
  127. package/src/components/calendar/chevron-right-sharp-light.svg +1 -0
  128. package/src/components/checkbox/check.svg +4 -0
  129. package/src/components/checkbox/checkbox.module.scss +142 -0
  130. package/src/components/checkbox/checkbox.ts +125 -0
  131. package/src/components/colorinput/colorinput.module.scss +65 -0
  132. package/src/components/colorinput/colorinput.ts +88 -0
  133. package/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
  134. package/src/components/colorpicker/colorpicker.module.scss +133 -0
  135. package/src/components/colorpicker/colorpicker.ts +477 -0
  136. package/src/components/combobox/combobox.module.scss +121 -0
  137. package/src/components/combobox/combobox.ts +190 -0
  138. package/src/components/combobox/updown.svg +4 -0
  139. package/src/components/dialog/dialog.module.scss +71 -0
  140. package/src/components/dialog/dialog.ts +91 -0
  141. package/src/components/dialog/xmark-sharp-light.svg +1 -0
  142. package/src/components/form/form.module.scss +34 -0
  143. package/src/components/form/form.ts +36 -0
  144. package/src/components/header/header.module.scss +40 -0
  145. package/src/components/header/header.ts +124 -0
  146. package/src/components/icon/icon.module.scss +30 -0
  147. package/src/components/icon/icon.ts +134 -0
  148. package/src/components/image/image.module.scss +21 -0
  149. package/src/components/image/image.ts +67 -0
  150. package/src/components/input/input.module.scss +69 -0
  151. package/src/components/input/input.ts +274 -0
  152. package/src/components/label/label.module.scss +52 -0
  153. package/src/components/label/label.ts +55 -0
  154. package/src/components/listbox/listbox.module.scss +103 -0
  155. package/src/components/listbox/listbox.ts +427 -0
  156. package/src/components/menu/caret-right-solid.svg +1 -0
  157. package/src/components/menu/menu.module.scss +108 -0
  158. package/src/components/menu/menu.ts +168 -0
  159. package/src/components/messages/circle-exclamation.svg +1 -0
  160. package/src/components/messages/messages.module.scss +47 -0
  161. package/src/components/messages/messages.ts +64 -0
  162. package/src/components/normalize.scss +386 -0
  163. package/src/components/notification/circle-check-solid.svg +1 -0
  164. package/src/components/notification/circle-exclamation-solid.svg +1 -0
  165. package/src/components/notification/circle-notch-light.svg +1 -0
  166. package/src/components/notification/notification.module.scss +82 -0
  167. package/src/components/notification/notification.ts +108 -0
  168. package/src/components/notification/xmark-sharp-light.svg +1 -0
  169. package/src/components/panel/panel.module.scss +48 -0
  170. package/src/components/panel/panel.ts +57 -0
  171. package/src/components/popup/popup.module.scss +43 -0
  172. package/src/components/popup/popup.ts +395 -0
  173. package/src/components/progress/progress.module.scss +57 -0
  174. package/src/components/progress/progress.ts +43 -0
  175. package/src/components/rating/rating.module.scss +23 -0
  176. package/src/components/rating/rating.ts +125 -0
  177. package/src/components/rating/star-sharp-light.svg +1 -0
  178. package/src/components/rating/star-sharp-solid.svg +1 -0
  179. package/src/components/shared.scss +76 -0
  180. package/src/components/sizers/sizer.module.scss +90 -0
  181. package/src/components/sizers/sizer.ts +120 -0
  182. package/src/components/slider/slider.module.scss +71 -0
  183. package/src/components/slider/slider.ts +143 -0
  184. package/src/components/switch/switch.module.scss +127 -0
  185. package/src/components/switch/switch.ts +56 -0
  186. package/src/components/tabs/tabs.module.scss +46 -0
  187. package/src/components/tabs/tabs.ts +157 -0
  188. package/src/components/textarea/textarea.module.scss +59 -0
  189. package/src/components/textarea/textarea.ts +54 -0
  190. package/src/components/textedit/textedit.module.scss +114 -0
  191. package/src/components/textedit/textedit.ts +82 -0
  192. package/src/components/themes.scss +77 -0
  193. package/src/components/tooltips/circle-info-sharp-light.svg +1 -0
  194. package/src/components/tooltips/tooltips.scss +51 -0
  195. package/src/components/tooltips/tooltips.ts +103 -0
  196. package/src/components/treeview/chevron-down-light.svg +1 -0
  197. package/src/components/treeview/treeview.module.scss +116 -0
  198. package/src/components/treeview/treeview.ts +403 -0
  199. package/src/components/viewport/viewport.module.scss +25 -0
  200. package/src/components/viewport/viewport.ts +38 -0
  201. package/src/core/component.ts +979 -0
  202. package/src/core/core_colors.ts +250 -0
  203. package/src/core/core_dom.ts +471 -0
  204. package/src/core/core_dragdrop.ts +201 -0
  205. package/src/core/core_element.ts +98 -0
  206. package/src/core/core_events.ts +149 -0
  207. package/src/core/core_i18n.ts +377 -0
  208. package/src/core/core_router.ts +221 -0
  209. package/src/core/core_styles.ts +215 -0
  210. package/src/core/core_svg.ts +550 -0
  211. package/src/core/core_tools.ts +673 -0
  212. package/src/demo/assets/house-light.svg +1 -0
  213. package/src/demo/assets/radio.svg +4 -0
  214. package/src/demo/index.html +12 -0
  215. package/src/demo/main.scss +21 -0
  216. package/src/demo/main.tsx +323 -0
  217. package/src/x4.scss +19 -0
  218. package/src/x4.ts +60 -0
  219. package/tsconfig.json +14 -0
  220. package/types/scss.d.ts +4 -0
  221. package/types/svg.d.ts +4 -0
  222. package/types/x4react.d.ts +9 -0
@@ -0,0 +1,121 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file combobox.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
+ @use "../shared.scss";
18
+
19
+ :root {
20
+ --dropdown-border: var( --border-hover );
21
+ --dropdown-background: var( --background-primary );
22
+
23
+ --combobox-border: var( --border );
24
+ --combobox-border-focus: var( --border-focus );
25
+
26
+ --combobox-btn-background: inherit;
27
+ --combobox-btn-color: var( --text-secondary );
28
+ --combobox-btn-color-hover: var( --text-primary );
29
+ }
30
+
31
+ .x4dropdown {
32
+ @extend .shadow-xl;
33
+ @extend .hbox;
34
+
35
+ max-height: 250px;
36
+ position: absolute;
37
+ background-color: var( --dropdown-background );
38
+ border: 1px solid var( --dropdown-border );
39
+
40
+ .x4listbox {
41
+ @extend .flex;
42
+
43
+ border: none;
44
+ margin: 0;
45
+ width: 100%;
46
+ height: 200px;
47
+ }
48
+ }
49
+
50
+ .x4combobox {
51
+ @extend .hbox;
52
+ margin: 5px;
53
+
54
+ &> #label {
55
+ padding: 0 6px;
56
+ border-bottom: 1px solid transparent;
57
+
58
+ &> .x4label {
59
+ height: 100%;
60
+ padding: 0;
61
+ font-weight: 500;
62
+ gap: 0;
63
+ }
64
+
65
+ &::after {
66
+ content: ":"
67
+ }
68
+ }
69
+
70
+ &>#edit {
71
+ @extend .flex;
72
+ border-bottom: 1px solid var( --combobox-border );
73
+
74
+ .x4input {
75
+ @extend .flex;
76
+
77
+ &[readonly] {
78
+ cursor: pointer;
79
+ }
80
+ }
81
+
82
+ .x4button {
83
+ margin: 0;
84
+ padding: 0;
85
+ outline: none;
86
+ background-color: var( --combobox-btn-background );
87
+ color: var( --combobox-btn-color );
88
+
89
+ #icon {
90
+ color: var( --combobox-btn-color );
91
+ }
92
+
93
+ &:hover, &:hover #icon {
94
+ color: var( --combobox-btn-color-hover );
95
+ }
96
+
97
+ &:focus {
98
+ //background-color: var( --color-30 );
99
+ //color: var( --color-10 );
100
+ }
101
+ }
102
+ }
103
+
104
+ &[disabled] {
105
+ &, * {
106
+ cursor: not-allowed;
107
+ }
108
+
109
+ #label .x4label {
110
+ color: var( --disabled-color-dark );
111
+ pointer-events: none;
112
+ }
113
+ }
114
+
115
+ &[required] {
116
+ .x4label::before {
117
+ content: "*";
118
+ color: var( --color-90 )
119
+ }
120
+ }
121
+ }
@@ -0,0 +1,190 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file combobox.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, ComponentProps, EvChange, EvSelectionChange, makeUniqueComponentId } from '@core/component';
18
+ import { Listbox, ListboxID, ListItem, kbNav } from '../listbox/listbox';
19
+ import { Popup, PopupEvents, PopupProps } from '../popup/popup.js';
20
+ import { Label } from '../label/label';
21
+ import { Input } from '../input/input';
22
+ import { Button } from '../button/button';
23
+ import { HBox } from '../boxes/boxes';
24
+
25
+ import "./combobox.module.scss";
26
+ import icon from "./updown.svg";
27
+
28
+
29
+
30
+ interface DropdownEvents extends PopupEvents {
31
+ selectionChange: EvSelectionChange;
32
+ }
33
+
34
+
35
+ interface DropdownProps extends Omit<PopupProps,"content"> {
36
+ items: ListItem[];
37
+ }
38
+
39
+ class Dropdown extends Popup<DropdownProps,DropdownEvents> {
40
+
41
+ private _list: Listbox;
42
+
43
+ constructor( props: DropdownProps, content?: ListItem[] ) {
44
+ super( props );
45
+
46
+ this._list = new Listbox( { items: props.items } );
47
+ this.setContent( this._list );
48
+
49
+ this.addDOMEvent( "mousedown", ( ev: Event ) => {
50
+ console.log( "trap" );
51
+ ev.stopImmediatePropagation( );
52
+ ev.stopPropagation( );
53
+ ev.preventDefault( );
54
+ }, true );
55
+
56
+ this._list.on( "selectionChange", ( ev ) => {
57
+ this.fire( "selectionChange", ev );
58
+ })
59
+ }
60
+
61
+ getList( ) {
62
+ return this._list;
63
+ }
64
+ }
65
+
66
+
67
+ /**
68
+ *
69
+ */
70
+
71
+ interface ComboboxProps extends Omit<ComponentProps,"content"> {
72
+ label?: string;
73
+ labelWidth?: number | string;
74
+ readonly?: boolean;
75
+ items: ListItem[];
76
+ }
77
+
78
+
79
+ export class Combobox extends Component<ComboboxProps> {
80
+
81
+ private _dropdown: Dropdown;
82
+ private _label: Label;
83
+ private _input: Input;
84
+ private _button: Button;
85
+ private _prevent_close = false;
86
+ private _edit: HBox;
87
+
88
+ constructor( props: ComboboxProps ) {
89
+ super( props );
90
+
91
+ const id = makeUniqueComponentId( );
92
+
93
+ this.setContent( [
94
+ new HBox( { id: "label", content: new Label( { tag: "label", text: props.label, labelFor: id, width: props.labelWidth } ) } ),
95
+ this._edit = new HBox( { id: "edit", content: [
96
+ this._input = new Input( { type: "text", value: "", readonly: props.readonly }),
97
+ this._button = new Button( { icon: icon } )
98
+ ]} ),
99
+ ])
100
+
101
+ this._dropdown = new Dropdown( { items: props.items } );
102
+
103
+ this._dropdown.on( "selectionChange", ( ev ) => {
104
+ const sel = ev.selection as ListItem;
105
+ this._input.setValue( sel ? sel.text : "" );
106
+
107
+ if( !this._prevent_close ) {
108
+ this._dropdown.show( false );
109
+ }
110
+ });
111
+
112
+ this._button.addDOMEvent( "click", ( ) => this._on_click( ) );
113
+ this._input.addDOMEvent( "input", ( ) => this._on_input( ) );
114
+ this._input.addDOMEvent( "keydown", ( ev ) => this._on_key( ev ) );
115
+
116
+ this.setDOMEvents( {
117
+ focusout: ( ) => this._on_focusout( ),
118
+ click: ( ) => this._on_click( ),
119
+ })
120
+ }
121
+
122
+ private _on_key( ev: KeyboardEvent ) {
123
+ switch( ev.key ) {
124
+ case "Enter":
125
+ case "Escape": {
126
+ this._dropdown.show( false );
127
+ break;
128
+ }
129
+
130
+ case "ArrowUp":
131
+ this._prevent_close = true;
132
+ if( !this._dropdown.isOpen( ) ) {
133
+ this.showDropDown( );
134
+ }
135
+ else {
136
+ this._dropdown.getList().navigate( kbNav.prev );
137
+ }
138
+
139
+ this._prevent_close = false;
140
+ break;
141
+
142
+ case "ArrowDown":
143
+ this._prevent_close = true;
144
+ if( !this._dropdown.isOpen( ) ) {
145
+ this.showDropDown( );
146
+ }
147
+ else {
148
+ this._dropdown.getList().navigate( kbNav.next );
149
+ }
150
+
151
+ this._prevent_close = false;
152
+ break;
153
+
154
+ default: {
155
+ return;
156
+ }
157
+ }
158
+
159
+ ev.preventDefault( );
160
+ ev.stopPropagation( );
161
+ }
162
+
163
+ private _on_input( ) {
164
+ if( !this._dropdown.isOpen( ) ) {
165
+ this.showDropDown( );
166
+ }
167
+
168
+ this._dropdown.getList().filter( this._input.getValue( ) );
169
+ }
170
+
171
+ private _on_focusout( ) {
172
+ this._dropdown.show( false );
173
+ }
174
+
175
+ private _on_click( ) {
176
+ this.showDropDown( );
177
+ }
178
+
179
+ showDropDown( ) {
180
+ if( this.isDisabled() ) {
181
+ return;
182
+ }
183
+
184
+ const rc = this._edit.getBoundingRect( );
185
+ this._dropdown.setStyleValue( "width", rc.width+"px" );
186
+ this._dropdown.displayNear( rc, "top left", "bottom left", {x:0,y:6} );
187
+ }
188
+ }
189
+
190
+
@@ -0,0 +1,4 @@
1
+ <svg viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd">
3
+ </path>
4
+ </svg>
@@ -0,0 +1,71 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file dialog.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
+ @import "../shared.scss";
18
+
19
+ :root {
20
+ --color-dialog-caption: var( --color-primary-a80 );
21
+ --color-dialog-caption-text: var( --color-primary-a0 );
22
+ }
23
+
24
+ .x4dialog {
25
+ @extend .shadow-xl, .vbox;
26
+
27
+ position: absolute;
28
+ background-color: white;
29
+ border: 1px solid var( --border-dark );
30
+ min-width: min-content;
31
+ min-height: min-content;
32
+
33
+ &> .caption {
34
+ padding: 8px;
35
+ background-color: var(--color-dialog-caption);
36
+
37
+ & > #title {
38
+ @extend .flex;
39
+ color: var(--color-dialog-caption-text);
40
+ font-weight: bold;
41
+ }
42
+
43
+ & > #closebox {
44
+ margin: 0;
45
+ padding: 4px;
46
+ }
47
+ }
48
+
49
+ &> .form {
50
+ min-height: 128px;
51
+ min-width: 450px;
52
+ }
53
+
54
+ &> #btnbar {
55
+ border-top: 1px solid var( --color-separation );
56
+ padding: 6px 16px;
57
+
58
+ justify-content: end;
59
+ gap: 8px;
60
+
61
+ &> .x4button {
62
+ min-width: 80px;
63
+
64
+ .x-simple-label {
65
+ text-align: center;
66
+ }
67
+
68
+ }
69
+ }
70
+ }
71
+
@@ -0,0 +1,91 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file dialog.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 { Form } from "../form/form.js"
18
+ import { PopupEvents, PopupProps, Popup } from '../popup/popup.js';
19
+ import { BtnGroup, BtnGroupItem } from "../btngroup/btngroup"
20
+ import { HBox } from '../boxes/boxes.js';
21
+ import { Label } from '../label/label.js';
22
+ import { ComponentContent, ComponentEvent } from '@core/component.js';
23
+ import { Button } from '../button/button.js';
24
+
25
+ import "./dialog.module.scss"
26
+ import close_icon from "./xmark-sharp-light.svg";
27
+
28
+ export interface DialogProps extends PopupProps {
29
+ icon?: string;
30
+ title: string;
31
+ form: Form;
32
+ buttons: BtnGroupItem[];
33
+ closable?: boolean;
34
+ }
35
+
36
+
37
+ export interface EvBtnClick extends Event {
38
+ button: string;
39
+ }
40
+
41
+ interface DialogEvents extends PopupEvents {
42
+ btnclick: EvBtnClick;
43
+ close: ComponentEvent;
44
+ }
45
+
46
+ /**
47
+ *
48
+ */
49
+
50
+ export class Dialog<P extends DialogProps = DialogProps, E extends DialogEvents = DialogEvents> extends Popup<P,E> {
51
+
52
+ constructor( props: P ) {
53
+ super( props );
54
+
55
+ this.appendContent( [
56
+ new HBox( {
57
+ cls: "caption",
58
+ content: [
59
+ new Label( {
60
+ id: "title",
61
+ cls: "caption-element",
62
+ icon: props.icon,
63
+ text: props.title
64
+ } ),
65
+ props.closable ? new Button( {
66
+ id: "closebox",
67
+ icon: close_icon,
68
+ click: ( ) => { this.close() }
69
+ } ) : null,
70
+ ]
71
+ }),
72
+ props.form,
73
+ new BtnGroup( {
74
+ id: "btnbar",
75
+ reverse: true,
76
+ items: props.buttons,
77
+ btnclick: ( ev ) => { this.fire( "btnclick", ev ) }
78
+ })
79
+ ])
80
+ }
81
+
82
+ display( ) {
83
+ super.displayCenter( );
84
+ }
85
+
86
+ override close( ) {
87
+ this.fire( "close", {} );
88
+ super.close( );
89
+ }
90
+ }
91
+
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 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="M192 233.4L59.5 100.9 36.9 123.5 169.4 256 36.9 388.5l22.6 22.6L192 278.6 324.5 411.1l22.6-22.6L214.6 256 347.1 123.5l-22.6-22.6L192 233.4z"/></svg>
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file form.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
+ @use "../shared.scss";
18
+
19
+ :root {
20
+ --form--background: var( --background-primary );
21
+ }
22
+
23
+ .x4form {
24
+ @extend .vbox;
25
+ @extend .flex;
26
+
27
+ padding: 16px;
28
+ background-color: var( --color-form );
29
+
30
+ &>.xcontainer {
31
+
32
+ }
33
+ }
34
+
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file form.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 { Box } from '../boxes/boxes.js';
18
+
19
+ import "./form.module.scss"
20
+
21
+ type FormValue = string | number | boolean;
22
+ type FormValues = Record<string,FormValue>;
23
+
24
+ export class Form extends Box {
25
+
26
+ setValues( values: FormValues ) {
27
+ const items = this.queryAll( "input[name]" );
28
+ console.log( items );
29
+ }
30
+
31
+ getValues( ): FormValues {
32
+ const result: FormValues = {};
33
+ return result;
34
+ }
35
+ }
36
+
@@ -0,0 +1,40 @@
1
+ @use "../shared.scss";
2
+
3
+ :root {
4
+ --header-background-hover: rgba(100,100,100,0.1);
5
+ --header-sizer-hover: var( --border-hover );
6
+ }
7
+
8
+ .x4header {
9
+ @extend .flex;
10
+ width: 100%;
11
+
12
+ overflow: hidden;
13
+ min-height: 2em;
14
+ border-bottom: 1px solid var( --border );
15
+
16
+
17
+ .cell {
18
+ border-bottom: 1px solid transparent;
19
+ overflow: hidden;
20
+ min-width: 3rem;
21
+
22
+ transition: border-color 0.5s ease;
23
+ padding: 4px;
24
+
25
+ span {
26
+ white-space: nowrap;
27
+ text-overflow: ellipsis;
28
+ overflow: hidden;
29
+ }
30
+
31
+ &:hover {
32
+ background-color: var( --header-background-hover );
33
+ }
34
+
35
+ .x4csizer:hover {
36
+ border-right: 1px solid var( --header-sizer-hover );
37
+ }
38
+ }
39
+
40
+ }
@@ -0,0 +1,124 @@
1
+ import { Component, ComponentProps } from '@core/component.js';
2
+ import { HBox } from '../boxes/boxes.js';
3
+ import { Label } from '../label/label.js';
4
+ import { CSizer } from '../sizers/sizer.js';
5
+
6
+ import "./header.module.scss"
7
+
8
+ interface HeaderItem {
9
+ name: string;
10
+ title: string;
11
+ iconId?: string;
12
+ width?: number; // <0 for flex
13
+ }
14
+
15
+ interface HeaderProps extends Omit<ComponentProps,"content"> {
16
+ items: HeaderItem[]
17
+ }
18
+
19
+ export class Header extends HBox<HeaderProps> {
20
+
21
+ private _els: Component[];
22
+ private _vwp: Component;
23
+
24
+ constructor( props: HeaderProps ) {
25
+ super( props );
26
+
27
+ this._els = props.items?.map( x => {
28
+ const cell = new Label( { cls: "cell", text: x.title, icon: x.iconId } );
29
+ const sizer = new CSizer( "right" );
30
+
31
+ if( x.width>0 ) {
32
+ cell.setStyleValue( "width", x.width+'px' );
33
+ cell.setInternalData( "width", x.width );
34
+ }
35
+ else if( x.width<0 ) {
36
+ cell.setInternalData( "flex", -x.width );
37
+ }
38
+ else {
39
+ cell.setInternalData( "width", 0 );
40
+ }
41
+
42
+ sizer.addDOMEvent( "dblclick", ( e: MouseEvent ) => {
43
+ cell.setInternalData( "flex", 1 );
44
+ this._calc_sizes( );
45
+ })
46
+
47
+ sizer.on( "resize", ( ev ) => {
48
+ //cell.setStyleValue( "flexGrow", "0" );
49
+ cell.setInternalData("flex",0);
50
+ cell.setInternalData("width",ev.size);
51
+ this._calc_sizes( );
52
+ });
53
+
54
+ cell.appendContent( sizer );
55
+ cell.setInternalData( "data", x );
56
+
57
+ return cell;
58
+ });
59
+
60
+ this.addDOMEvent( "resized", ( ) => this._on_resize() );
61
+ this.addDOMEvent( "created", ( ) => this._calc_sizes( ) );
62
+
63
+ this._vwp = new HBox( { content: this._els } );
64
+ this.setContent( this._vwp );
65
+ }
66
+
67
+ private _calc_sizes( ) {
68
+
69
+ let count = 0;
70
+ let filled = 0;
71
+
72
+ this._els.forEach( c => {
73
+ const flex = c.getInternalData( "flex" );
74
+ if( flex ) {
75
+ count += flex;
76
+ }
77
+ else {
78
+ let width = c.getInternalData( "width" );
79
+ if( width==0 ) {
80
+ const rc = c.getBoundingRect( );
81
+ width = Math.ceil( rc.width )+2;
82
+ c.setInternalData( "width", width );
83
+ }
84
+
85
+ filled += width;
86
+ }
87
+ } );
88
+
89
+ const rc = this.getBoundingRect( );
90
+
91
+ let rest = (rc.width-filled);
92
+ const unit = Math.ceil( rest/count );
93
+
94
+ console.log( "filled", filled );
95
+ console.log( "count", count );
96
+ console.log( "rest", rest );
97
+ console.log( "unit", unit );
98
+
99
+ let fullw = 0;
100
+ this._els.forEach( c => {
101
+ let width = 0;
102
+
103
+ const flex = c.getInternalData( "flex" );
104
+ if( flex ) {
105
+ width = Math.min( unit*flex, rest );
106
+ rest -= width;
107
+ }
108
+ else {
109
+ width = c.getInternalData( "width" );
110
+ }
111
+
112
+ c.setWidth( width );
113
+ fullw += width;
114
+ } );
115
+
116
+ this._vwp.setWidth( fullw );
117
+ }
118
+
119
+ private _on_resize( ) {
120
+ this._calc_sizes( );
121
+ }
122
+
123
+
124
+ }