x4js 2.0.5 → 2.0.7

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 +51026 -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,157 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file tabs.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
+ import { Component, ComponentEvents, ComponentProps, EvClick } from '@core/component';
17
+ import { CoreEvent } from '@core/core_events';
18
+
19
+ import { Button, ButtonProps } from '../button/button';
20
+ import { HBox, VBox, StackBox } from '../boxes/boxes';
21
+
22
+ import "./tabs.module.scss"
23
+
24
+ /**
25
+ *
26
+ */
27
+
28
+
29
+ export interface TabItem {
30
+ name: string;
31
+ title: string;
32
+ icon?: string;
33
+ tab: Component;
34
+ }
35
+
36
+
37
+ class CTab extends Button {
38
+ constructor( props: ButtonProps, item: TabItem ) {
39
+ super( props );
40
+
41
+ this.addClass( "outline" );
42
+ this.setIcon( item.icon );
43
+ this.setText( item.title );
44
+ this.setData( "tabname", item.name );
45
+ }
46
+ }
47
+
48
+ /**
49
+ *
50
+ */
51
+
52
+ interface TablistClickEvent extends CoreEvent {
53
+ name: string;
54
+ }
55
+
56
+ interface TablistProps extends ComponentProps {
57
+ click: ( ev: TablistClickEvent ) => void;
58
+ }
59
+
60
+ interface TablistEvents extends ComponentEvents {
61
+ click: TablistClickEvent;
62
+ }
63
+
64
+ /**
65
+ * bar containing buttons
66
+ */
67
+ class CTabList extends HBox<TablistProps,TablistEvents> {
68
+
69
+ private _selitem: Button;
70
+ private _selection: string;
71
+
72
+ constructor( props: TablistProps, content: TabItem[] ) {
73
+ super( props );
74
+
75
+ const tabs = content.map( tab => {
76
+ return new CTab( {
77
+ click: ( ev ) => this._on_click( ev ),
78
+ }, tab );
79
+ })
80
+
81
+ this.mapPropEvents( props, "click" );
82
+ this.setContent( tabs );
83
+ }
84
+
85
+ private _on_click( ev: EvClick ) {
86
+ const name = (ev.source as Component).getData( "tabname" );
87
+ this.fire( "click", {name} );
88
+ }
89
+
90
+ select( name: string ) {
91
+ const tab = this.query<Button>( `[data-tabname="${name}"]` );
92
+ if( this._selitem ) {
93
+ this._selitem.setClass( "selected", false );
94
+ }
95
+
96
+ this._selitem = tab;
97
+ this._selection = name;
98
+
99
+ if( this._selitem ) {
100
+ this._selitem.setClass( "selected", true );
101
+ }
102
+ }
103
+ }
104
+
105
+
106
+ /**
107
+ *
108
+ */
109
+
110
+ interface TabsProps extends Omit<ComponentProps,"content"> {
111
+ default: string;
112
+ items: TabItem[]
113
+ }
114
+
115
+
116
+ export class Tabs extends VBox<TabsProps> {
117
+
118
+ private _list: CTabList;
119
+ private _stack: StackBox;
120
+
121
+ constructor( props: TabsProps ) {
122
+ super( props );
123
+
124
+ const pages = props.items?.map( x => {
125
+ return {
126
+ name: x.name,
127
+ content: x.tab ,
128
+ }
129
+ });
130
+
131
+ this.setContent( [
132
+ this._list = new CTabList( {
133
+ click: ( ev ) => this._onclick( ev ) },
134
+ props.items
135
+ ),
136
+ this._stack = new StackBox( {
137
+ cls: "body x4flex",
138
+ default: props.default,
139
+ items: pages,
140
+ } ),
141
+ ]);
142
+
143
+ if( props.default ) {
144
+ this.selectTab( props.default );
145
+ }
146
+ }
147
+
148
+ selectTab( name: string ) {
149
+ this._list.select( name );
150
+ this._stack.select( name );
151
+ }
152
+
153
+ private _onclick( ev: TablistClickEvent ) {
154
+ this.selectTab( ev.name );
155
+ }
156
+ }
157
+
@@ -0,0 +1,59 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file textarea.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
+ --textarea-border: var( --border );
21
+ --textarea-border-focus: var( --border-focus );
22
+ }
23
+
24
+ .x4textarea {
25
+ margin: 5px;
26
+
27
+ .x4label{
28
+ gap: 0;
29
+ padding: 4px 0;
30
+
31
+ &::after {
32
+ content: ":"
33
+ }
34
+ }
35
+
36
+ textarea {
37
+ @extend .flex;
38
+
39
+ border: 1px solid var( --color-gray-3 );
40
+ padding: 4px;
41
+ outline: none;
42
+ font: inherit;
43
+
44
+ border: 1px solid var( --textarea-border );
45
+
46
+ &:focus {
47
+ border: 1px solid var( --textarea-border-focus );
48
+ }
49
+
50
+ &::selection {
51
+ background-color: var( --color-90 );
52
+ color: white;
53
+ }
54
+
55
+ &[resize=false] {
56
+ resize: none;
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file textarea.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 { BaseProps } from '../input/input';
18
+ import { Component } from '@core/component';
19
+
20
+ import { Label } from '../label/label';
21
+ import { VBox } from '../boxes/boxes';
22
+
23
+ import "./textarea.module.scss";
24
+
25
+ /**
26
+ *
27
+ */
28
+
29
+ interface TextAreaProps extends BaseProps {
30
+ label?: string;
31
+ value?: string;
32
+ resize?: boolean;
33
+ }
34
+
35
+ export class TextArea extends VBox {
36
+
37
+ private _input: Component;
38
+
39
+ constructor( props: TextAreaProps ) {
40
+ super( props );
41
+
42
+ this.setContent( [
43
+ new Label( { text: props.label }),
44
+ this._input = new Component( { tag: "textarea" })
45
+ ])
46
+
47
+ this._input.setAttribute( "name", props.name );
48
+ this._input.setAttribute( "value", props.value+'' );
49
+
50
+ if( !props.resize ) {
51
+ this._input.setAttribute( "resize", false );
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file textedit.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
+ --textedit-border: var( --border );
21
+ --textedit-border-focus: var( --border-focus );
22
+ --textedit-required: var( --alert-background );
23
+
24
+ --textedit-btn-background: inherit;
25
+ --textedit-btn-color: var( --text-secondary );
26
+ --textedit-btn-color-hover: var( --text-primary );
27
+
28
+ --textedit-color-disabled: var( --disabled-background );
29
+ }
30
+
31
+ .x4textedit {
32
+ @extend .hbox;
33
+ margin: 5px;
34
+ gap: 6px;
35
+
36
+ &> #label { // hbox
37
+ border-bottom: 1px solid transparent;
38
+
39
+ &> .x4label {
40
+ @extend .hbox;
41
+ height: 100%;
42
+ padding: 0;
43
+ font-weight: 500;
44
+ gap: 0;
45
+ }
46
+
47
+ &::after {
48
+ content: ":"
49
+ }
50
+ }
51
+
52
+ &> #edit {
53
+ @extend .hbox;
54
+ @extend .flex;
55
+ border-bottom: 1px solid var( --textedit-border );
56
+
57
+ .x4input {
58
+ @extend .flex;
59
+ outline: none;
60
+ margin: 0;
61
+ }
62
+
63
+ .x4button {
64
+ margin: 0;
65
+ padding: 0;
66
+ background-color: var( --textedit-btn-background );
67
+ color: var( --textedit-btn-color );
68
+
69
+ #icon {
70
+ color: var( --textedit-btn-color );
71
+ }
72
+
73
+ &:hover, &:hover #icon {
74
+ color: var( --textedit-btn-color-hover );
75
+ }
76
+
77
+ &:focus {
78
+ border-bottom-color: var( --textedit-border-focus );
79
+ }
80
+ }
81
+ }
82
+
83
+ &:focus-within {
84
+ #edit {
85
+ border-bottom-color: var( --textedit-border-focus );
86
+ }
87
+
88
+ }
89
+
90
+ &[required] {
91
+ & > #label > .x4label::before {
92
+ content: "*";
93
+ font-weight: bold;
94
+ color: var( --textedit-required )
95
+ }
96
+ }
97
+
98
+ &[disabled] {
99
+ &, * {
100
+ cursor: not-allowed;
101
+ }
102
+
103
+ #label > .x4label #text,
104
+ #label > .x4label::before,
105
+ #label::after {
106
+ color: var( --textedit-color-disabled );
107
+ }
108
+
109
+ #edit input {
110
+ color: var( --textedit-color-disabled );
111
+ background-color: unset;
112
+ }
113
+ }
114
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file textedit.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, makeUniqueComponentId } from '@core/component';
18
+ import { UnsafeHtml } from '@core/core_tools';
19
+
20
+ import { HBox } from '../boxes/boxes';
21
+ import { Input, TextInputProps } from "../input/input"
22
+ import { Label } from '../label/label';
23
+
24
+ import "./textedit.module.scss";
25
+
26
+ //@todo: disabled
27
+
28
+ /**
29
+ *
30
+ */
31
+
32
+ interface TextEditProps extends ComponentProps {
33
+ label: string | UnsafeHtml;
34
+ labelWidth?: number;
35
+ inputId?: string;
36
+
37
+ type?: "text" | "email" | "password";
38
+ readonly?: boolean;
39
+ required?: boolean;
40
+ value: string | number;
41
+ placeholder?: string;
42
+
43
+ inputGadgets?: Component[];
44
+ }
45
+
46
+ /**
47
+ *
48
+ */
49
+
50
+ export class TextEdit extends HBox {
51
+ constructor( props: TextEditProps ) {
52
+ super( props );
53
+
54
+ if( !props.inputId ) {
55
+ props.inputId = makeUniqueComponentId()
56
+ }
57
+
58
+ if( props.required ) {
59
+ this.setAttribute( "required", true );
60
+ }
61
+
62
+ const gadgets = props.inputGadgets ?? [];
63
+
64
+ this.setContent( [
65
+ new HBox( { id: "label", width: props.labelWidth, content: [
66
+ new Label( { tag: "label", text: props.label, labelFor: props.inputId } ),
67
+ ]}),
68
+ new HBox( { id: "edit", content: [
69
+ new Input( {
70
+ type: props.type ?? "text",
71
+ readonly: props.readonly,
72
+ value: props.value,
73
+ id: props.inputId,
74
+ required: props.required,
75
+ disabled: props.disabled,
76
+ placeholder: props.placeholder
77
+ } ),
78
+ ...gadgets,
79
+ ]})
80
+ ])
81
+ }
82
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file themes.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
+ --color-primary-a0: #ffffff;
19
+ --color-primary-a10: #e0eaf7;
20
+ --color-primary-a20: #c0d6ef;
21
+ --color-primary-a30: #a0c2e7;
22
+ --color-primary-a40: #7dafde;
23
+ --color-primary-a50: #569cd6;
24
+ --color-primary-a55: #{lighten(#477ba7,5%)};
25
+ --color-primary-a60: #477ba7;
26
+ --color-primary-a70: #375b7a;
27
+ --color-primary-a80: #283d51;
28
+ --color-primary-a90: #18212a;
29
+ --color-primary-a100: #000000;
30
+
31
+ --color-danger-a50: #c01010;
32
+ --color-danger-a60: #{darken(#c01010,10%)};
33
+
34
+ --color-success-a50: #10c01f;
35
+ --color-success-a60: #{darken(#10c01f,10%)};
36
+ }
37
+
38
+ :root {
39
+ // Backgrounds
40
+ --background-primary: var(--color-primary-a0); // Fond principal
41
+ --background-secondary: var(--color-primary-a10); // Fond secondaire
42
+
43
+ // Texts
44
+ --text-primary: var(--color-primary-a100); // Texte principal
45
+ --text-secondary: #999; // Texte secondaire
46
+ --text-ternary: #666; // Texte tertiaire
47
+
48
+ // disabled
49
+ --disabled-background: #ccc;
50
+ --disabled-color: white;
51
+ --disabled-color-dark: #aaa;
52
+
53
+ // accents
54
+ --accent-background: var(--color-primary-a60);
55
+ --accent-background-hover: var(--color-primary-a55);
56
+ --accent-background-focus: var(--color-primary-a70);
57
+ --accent-background-active: var(--color-primary-a80);
58
+
59
+ --accent-color: var(--color-primary-a0);
60
+ --accent-color-hover: var(--color-primary-a0);
61
+ --accent-color-focus: var(--color-primary-a0);
62
+ --accent-color-active: var(--color-primary-a0);
63
+
64
+ // Borders
65
+ --border: #e1e1e1; // Bordures
66
+ --border-hover: #c2c2c2; // Bordures au survol
67
+ --border-focus: var( --accent-background ); // Bordures si focus
68
+
69
+ --alert-background: var( --color-danger-a50 );
70
+ --alert-background-active: var( --color-danger-a60 );
71
+ --alert-color: var( --color-primary-a0 );
72
+
73
+ --success-background: var( --color-success-a50 );
74
+ --success-background-active: var( --color-success-a60 );
75
+ --success-color: var( --color-success-a0 );
76
+ }
77
+
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor"> <!--!Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M256 32a224 224 0 1 1 0 448 224 224 0 1 1 0-448zm0 480A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM192 352v32h16 96 16V352H304 272V240 224H256 216 200v32h16 24v96H208 192zm88-168V136H232v48h48z"/></svg>
@@ -0,0 +1,51 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file tooltips.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
+ --tooltip-background: var( --color-primary-a70 );
21
+ --tooltip-color: var( --color-primary-a0 );
22
+ --tooltip-border: var( --border-dark );
23
+ }
24
+
25
+ .x4tooltip {
26
+ @extend .shadow-lg;
27
+ display: flex;
28
+ flex-direction: row;
29
+ border: none;
30
+ font-size: 90%;
31
+ position: absolute;
32
+
33
+ .x4icon {
34
+ width: 1.6em;
35
+ height: 100%;
36
+ padding: 2px 4px;
37
+ svg {
38
+ max-height: 100%;
39
+ }
40
+
41
+ background-color: var( --tooltip-background );
42
+ color: var( --tooltip-color );
43
+ border: 1px solid var( --tooltip-border );
44
+ }
45
+
46
+ #text {
47
+ background-color: var( --tooltip-background );
48
+ color: var( --tooltip-color );
49
+ padding: 4px;
50
+ }
51
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file tooltips.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, wrapDOM } from '@core/component';
18
+ import { Point, Rect, Timer, UnsafeHtml, unsafeHtml } from '@core/core_tools';
19
+
20
+ import { HBox } from '../boxes/boxes';
21
+ import { Popup, PopupProps } from '../popup/popup.js';
22
+ import { Icon } from '../icon/icon.js';
23
+
24
+ import "./tooltips.scss"
25
+
26
+ import icon from "./circle-info-sharp-light.svg"
27
+
28
+
29
+ let last_hit: HTMLElement = null;
30
+ let tooltip: Tooltip = null;
31
+
32
+ const timer = new Timer( );
33
+
34
+ export function initTooltips( ) {
35
+
36
+ document.addEventListener( "mouseenter", ( ev: MouseEvent ) => {
37
+ if( ev.target===document ) {
38
+ return;
39
+ }
40
+
41
+ const c = wrapDOM( ev.target as HTMLElement );
42
+ const tt = c.getAttribute( "tooltip" );
43
+ if( tt ) {
44
+ last_hit = ev.target as HTMLElement;
45
+ const rc = c.getBoundingRect( );
46
+ showTT( tt, rc, { x:ev.pageX,y:ev.pageY } );
47
+ }
48
+
49
+ }, true );
50
+
51
+ document.addEventListener( "mouseleave", ( ev: Event ) => {
52
+ //console.log( "leave", ev.target );
53
+
54
+ if( last_hit && ev.target==last_hit ) {
55
+ last_hit = null;
56
+ closeTT( );
57
+ }
58
+
59
+ }, true );
60
+ }
61
+
62
+ function showTT( text: string, rc: Rect, pt: Point ) {
63
+ if( !tooltip ) {
64
+ tooltip = new Tooltip( { } );
65
+ }
66
+
67
+ timer.setTimeout( null, 300, ( ) => {
68
+ tooltip.setText( unsafeHtml(text) );
69
+ //tooltip.displayNear( rc, "top left", "bottom left", {x:0,y:4} );
70
+ tooltip.displayAt( pt.x, pt.y );
71
+ } );
72
+ }
73
+
74
+ function closeTT( ) {
75
+ tooltip.show( false );
76
+ timer.clearTimeout( null );
77
+ }
78
+
79
+ /**
80
+ *
81
+ */
82
+
83
+ class Tooltip extends Popup {
84
+
85
+ constructor( props: PopupProps ) {
86
+ super( props );
87
+
88
+ this.setContent(
89
+ new HBox( {content: [
90
+ new Icon( { iconId: icon } ),
91
+ new Component( { id: "text" } )
92
+ ]} )
93
+ );
94
+ }
95
+
96
+ /**
97
+ *
98
+ */
99
+
100
+ setText( text: string|UnsafeHtml ) {
101
+ this.query( "#text" ).setContent( text );
102
+ }
103
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor"><!--!Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M267.3 395.3c-6.2 6.2-16.4 6.2-22.6 0l-192-192c-6.2-6.2-6.2-16.4 0-22.6s16.4-6.2 22.6 0L256 361.4 436.7 180.7c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6l-192 192z"/></svg>