@web-atoms/web-controls 2.6.5 → 2.6.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 (185) hide show
  1. package/dist/html-editor/InlineHtmlEditor.d.ts +1 -1
  2. package/dist/html-editor/InlineHtmlEditor.d.ts.map +1 -1
  3. package/dist/html-editor/InlineHtmlEditor.js +2 -2
  4. package/dist/html-editor/InlineHtmlEditor.js.map +1 -1
  5. package/dist/tsconfig.tsbuildinfo +1 -1
  6. package/dist-esm/ArrayLike.js +14 -12
  7. package/dist-esm/DataAttributes.js +18 -19
  8. package/dist-esm/Focusable.js +10 -11
  9. package/dist-esm/ModuleFiles.js +43 -42
  10. package/dist-esm/NumberFormats.js +60 -56
  11. package/dist-esm/PageNavigator.js +28 -30
  12. package/dist-esm/animations/Animations.js +36 -33
  13. package/dist-esm/basic/AtomChips.js +312 -305
  14. package/dist-esm/basic/AtomRepeater.js +1070 -1035
  15. package/dist-esm/basic/AtomSuggestions.js +97 -107
  16. package/dist-esm/basic/AttachedPopup.js +0 -1
  17. package/dist-esm/basic/Button.js +45 -19
  18. package/dist-esm/basic/ButtonBar.js +84 -64
  19. package/dist-esm/basic/Calendar.js +211 -203
  20. package/dist-esm/basic/CheckBoxList.js +90 -70
  21. package/dist-esm/basic/Checkbox.js +16 -8
  22. package/dist-esm/basic/Chip.js +36 -12
  23. package/dist-esm/basic/ComboBox.js +47 -51
  24. package/dist-esm/basic/DataGrid.js +258 -252
  25. package/dist-esm/basic/DateField.js +149 -127
  26. package/dist-esm/basic/DropDown.js +91 -103
  27. package/dist-esm/basic/DropDownInput.js +78 -106
  28. package/dist-esm/basic/Editable.js +82 -77
  29. package/dist-esm/basic/Expander.js +104 -86
  30. package/dist-esm/basic/FilesDragDrop.js +84 -80
  31. package/dist-esm/basic/Form.js +80 -52
  32. package/dist-esm/basic/FormField.js +164 -106
  33. package/dist-esm/basic/IElement.js +1 -2
  34. package/dist-esm/basic/InlinePopup.js +263 -234
  35. package/dist-esm/basic/InlinePopupButton.js +99 -88
  36. package/dist-esm/basic/InlinePopupControl.js +24 -23
  37. package/dist-esm/basic/ItemPath.js +59 -60
  38. package/dist-esm/basic/LimitedText.js +49 -38
  39. package/dist-esm/basic/ListRepeater.js +13 -14
  40. package/dist-esm/basic/MaskedInput.js +37 -29
  41. package/dist-esm/basic/MaskedInputDiv.js +55 -48
  42. package/dist-esm/basic/MergeNode.js +64 -35
  43. package/dist-esm/basic/PasswordBox.js +32 -17
  44. package/dist-esm/basic/PinchZoomView.js +221 -199
  45. package/dist-esm/basic/PopupButton.js +39 -16
  46. package/dist-esm/basic/PopupMenu.js +3 -4
  47. package/dist-esm/basic/RadioButtonList.js +35 -25
  48. package/dist-esm/basic/RefreshLock.js +41 -42
  49. package/dist-esm/basic/Resizable.js +43 -33
  50. package/dist-esm/basic/Select.js +72 -65
  51. package/dist-esm/basic/SortByButton.js +41 -31
  52. package/dist-esm/basic/Swipe.js +91 -84
  53. package/dist-esm/basic/Switch.js +22 -8
  54. package/dist-esm/basic/TableRepeater.js +29 -33
  55. package/dist-esm/basic/TimeEditor.js +97 -52
  56. package/dist-esm/basic/TitleEditor.js +115 -95
  57. package/dist-esm/basic/ToggleButtonBar.js +21 -22
  58. package/dist-esm/basic/Tooltip.js +49 -47
  59. package/dist-esm/basic/TypeWriter.js +45 -42
  60. package/dist-esm/basic/UploadEvent.js +211 -178
  61. package/dist-esm/basic/ZoomView.js +229 -198
  62. package/dist-esm/basic/combineClasses.js +2 -3
  63. package/dist-esm/basic/elements/AtomPopover.js +270 -253
  64. package/dist-esm/basic/elements/getContainingBlock.js +34 -35
  65. package/dist-esm/basic/elements/relativeRect.js +40 -21
  66. package/dist-esm/desktop-app/DesktopApp.js +65 -80
  67. package/dist-esm/desktop-app/MobileDesktopApp.js +20 -23
  68. package/dist-esm/html-editor/AtomHtmlEditor.js +243 -268
  69. package/dist-esm/html-editor/HtmlEditorCommands.js +6 -4
  70. package/dist-esm/html-editor/InlineHtmlEditor.d.ts +1 -1
  71. package/dist-esm/html-editor/InlineHtmlEditor.d.ts.map +1 -1
  72. package/dist-esm/html-editor/InlineHtmlEditor.js +175 -167
  73. package/dist-esm/html-editor/InlineHtmlEditor.js.map +1 -1
  74. package/dist-esm/html-editor/RangeEditor.js +49 -51
  75. package/dist-esm/html-editor/commands/AddImage.js +40 -35
  76. package/dist-esm/html-editor/commands/AddLink.js +56 -54
  77. package/dist-esm/html-editor/commands/Align.js +24 -7
  78. package/dist-esm/html-editor/commands/AttachFile.js +23 -13
  79. package/dist-esm/html-editor/commands/AttachImage.js +35 -25
  80. package/dist-esm/html-editor/commands/Bold.js +10 -11
  81. package/dist-esm/html-editor/commands/ChangeColor.js +31 -107
  82. package/dist-esm/html-editor/commands/ChangeFont.js +42 -42
  83. package/dist-esm/html-editor/commands/ChangeFontSize.js +15 -5
  84. package/dist-esm/html-editor/commands/Command.js +34 -16
  85. package/dist-esm/html-editor/commands/CommandButton.js +51 -32
  86. package/dist-esm/html-editor/commands/Headings.js +25 -9
  87. package/dist-esm/html-editor/commands/HorizontalRule.js +9 -10
  88. package/dist-esm/html-editor/commands/HtmlCommands.js +160 -65
  89. package/dist-esm/html-editor/commands/IndentLess.js +10 -11
  90. package/dist-esm/html-editor/commands/IndentMore.js +10 -11
  91. package/dist-esm/html-editor/commands/Italic.js +10 -11
  92. package/dist-esm/html-editor/commands/NumberedList.js +10 -11
  93. package/dist-esm/html-editor/commands/Quote.js +10 -11
  94. package/dist-esm/html-editor/commands/RemoveFormat.js +10 -11
  95. package/dist-esm/html-editor/commands/Separator.js +5 -4
  96. package/dist-esm/html-editor/commands/Source.js +29 -25
  97. package/dist-esm/html-editor/commands/StrikeThrough.js +10 -11
  98. package/dist-esm/html-editor/commands/Toolbar.js +6 -4
  99. package/dist-esm/html-editor/commands/Underline.js +10 -11
  100. package/dist-esm/html-editor/commands/Unlink.js +10 -9
  101. package/dist-esm/html-editor/commands/UnorderedList.js +10 -11
  102. package/dist-esm/mobile-app/BottomPopup.js +137 -148
  103. package/dist-esm/mobile-app/MasterDetailPage.js +153 -152
  104. package/dist-esm/mobile-app/MobileApp.js +577 -569
  105. package/dist-esm/player/AtomVideoPlayer.js +316 -270
  106. package/dist-esm/player/TrackProgress.js +11 -7
  107. package/dist-esm/player/input-range-style.js +97 -98
  108. package/dist-esm/tests/app-test/AppTestApp.js +12 -15
  109. package/dist-esm/tests/app-test/AppTestApp.pack.js +54 -0
  110. package/dist-esm/tests/app-test/commands/AppCommands.js +14 -11
  111. package/dist-esm/tests/app-test/drawer/AppDrawer.js +4 -6
  112. package/dist-esm/tests/app-test/model/model.js +1 -2
  113. package/dist-esm/tests/app-test/pages/detail/DetailPage.js +21 -15
  114. package/dist-esm/tests/app-test/pages/home/HomePage.js +7 -8
  115. package/dist-esm/tests/app-test/pages/list/ListPage.js +79 -62
  116. package/dist-esm/tests/basic/PopupTest.js +9 -7
  117. package/dist-esm/tests/basic/TimeEditorTest.js +5 -9
  118. package/dist-esm/tests/basic/TimeEditorTest.pack.js +39 -0
  119. package/dist-esm/tests/basic/TimerTest.js +27 -37
  120. package/dist-esm/tests/basic/TimerTest.pack.js +40 -0
  121. package/dist-esm/tests/basic/basic-form/BasicForm.js +47 -27
  122. package/dist-esm/tests/basic/basic-form/BasicForm.pack.js +44 -0
  123. package/dist-esm/tests/basic/calendar/BasicCalendarTest.js +5 -9
  124. package/dist-esm/tests/basic/calendar/BasicCalendarTest.pack.js +53 -0
  125. package/dist-esm/tests/basic/chips/ChipsTest.js +25 -15
  126. package/dist-esm/tests/basic/chips/ChipsTest.pack.js +56 -0
  127. package/dist-esm/tests/basic/data-grid/DataGridTest.js +55 -60
  128. package/dist-esm/tests/basic/data-grid/DataGridTest.pack.js +58 -0
  129. package/dist-esm/tests/basic/date/DateFieldTest.js +21 -96
  130. package/dist-esm/tests/basic/date/DateFieldTest.pack.js +57 -0
  131. package/dist-esm/tests/basic/drop-down/DropDownTest.js +25 -19
  132. package/dist-esm/tests/basic/drop-down/DropDownTest.pack.js +52 -0
  133. package/dist-esm/tests/basic/drop-down-input/DropDownTest.js +32 -32
  134. package/dist-esm/tests/basic/drop-down-input/DropDownTest.pack.js +54 -0
  135. package/dist-esm/tests/basic/expander/ExpanderMenuTest.js +20 -14
  136. package/dist-esm/tests/basic/expander/ExpanderMenuTest.pack.js +38 -0
  137. package/dist-esm/tests/basic/expander/ExpanderTest.js +11 -12
  138. package/dist-esm/tests/basic/expander/ExpanderTest.pack.js +38 -0
  139. package/dist-esm/tests/basic/form2/Form2Test.js +26 -24
  140. package/dist-esm/tests/basic/form2/Form2Test.pack.js +46 -0
  141. package/dist-esm/tests/basic/limited-text/LimitedTextTest.js +14 -11
  142. package/dist-esm/tests/basic/limited-text/LimitedTextTest.pack.js +38 -0
  143. package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.js +14 -14
  144. package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.pack.js +38 -0
  145. package/dist-esm/tests/basic/repeater/DragDropRepater.js +30 -12
  146. package/dist-esm/tests/basic/repeater/DragDropRepater.pack.js +51 -0
  147. package/dist-esm/tests/basic/repeater/RepeaterTest.js +45 -35
  148. package/dist-esm/tests/basic/repeater/RepeaterTest.pack.js +52 -0
  149. package/dist-esm/tests/basic/swipe/SwipeTest.js +13 -13
  150. package/dist-esm/tests/basic/swipe/SwipeTest.pack.js +52 -0
  151. package/dist-esm/tests/basic/switch-test/SwitchTest.js +8 -10
  152. package/dist-esm/tests/basic/switch-test/SwitchTest.pack.js +38 -0
  153. package/dist-esm/tests/basic/title-editor/TitleEditorTest.js +8 -9
  154. package/dist-esm/tests/basic/title-editor/TitleEditorTest.pack.js +38 -0
  155. package/dist-esm/tests/basic/tooltip/TooltipTest.js +30 -24
  156. package/dist-esm/tests/basic/tooltip/TooltipTest.pack.js +52 -0
  157. package/dist-esm/tests/basic/typewriter/TypeWriter.js +10 -9
  158. package/dist-esm/tests/basic/typewriter/TypeWriter.pack.js +39 -0
  159. package/dist-esm/tests/basic/video/AtomVideoTest.js +13 -10
  160. package/dist-esm/tests/basic/video/AtomVideoTest.pack.js +38 -0
  161. package/dist-esm/tests/basic/zoom/ZoomViewTest.js +13 -13
  162. package/dist-esm/tests/basic/zoom/ZoomViewTest.pack.js +38 -0
  163. package/dist-esm/tests/check-box-list/CheckBoxListSample.js +13 -12
  164. package/dist-esm/tests/check-box-list/CheckBoxListSample.pack.js +52 -0
  165. package/dist-esm/tests/data-grid/GridTestViewModel.js +203 -227
  166. package/dist-esm/tests/form/CustomHelp.js +6 -9
  167. package/dist-esm/tests/form/FormViewModel.js +21 -28
  168. package/dist-esm/tests/html-editor/HtmlEditorTest.js +7 -37
  169. package/dist-esm/tests/html-editor/HtmlEditorTest.pack.js +83 -0
  170. package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.js +9 -38
  171. package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.pack.js +85 -0
  172. package/dist-esm/tests/mask/MaskedInputTest.js +11 -12
  173. package/dist-esm/tests/mask/MaskedInputTest.pack.js +38 -0
  174. package/dist-esm/tests/mobile-app/DesktopAppTest.js +8 -9
  175. package/dist-esm/tests/mobile-app/DesktopAppTest.pack.js +60 -0
  176. package/dist-esm/tests/mobile-app/MobileAppTest.js +64 -53
  177. package/dist-esm/tests/mobile-app/MobileAppTest.pack.js +55 -0
  178. package/dist-esm/tests/pop-over/PopOverTest.js +37 -77
  179. package/dist-esm/tests/switch/SwitchTest.js +9 -8
  180. package/dist-esm/tests/toggle-view/ToggleViewTest.js +15 -22
  181. package/dist-esm/tests/toggle-view/ToggleViewTest.pack.js +45 -0
  182. package/dist-esm/toggle-view/AtomToggleView.js +77 -73
  183. package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
  184. package/package.json +3 -3
  185. package/src/html-editor/InlineHtmlEditor.tsx +1 -1
@@ -2,89 +2,93 @@ const supportsFileSystemAccessAPI = "getAsFileSystemHandle" in DataTransferItem.
2
2
  const supportsWebkitGetAsEntry = "webkitGetAsEntry" in DataTransferItem.prototype;
3
3
  import { StringHelper } from "@web-atoms/core/dist/core/StringHelper.js";
4
4
  import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl.js";
5
- import "./FilesDragDrop.global.css";
6
- const dragEnter = (e) => {
7
- if (!e.dataTransfer) {
8
- return;
9
- }
10
- e.currentTarget.setAttribute("data-drop-enabled", "1");
5
+ ESMPack.installStyleSheet(import.meta.resolve("./FilesDragDrop.global.css"));
6
+ const dragEnter = e => {
7
+ if (!e.dataTransfer) {
8
+ return;
9
+ }
10
+ e.currentTarget.setAttribute("data-drop-enabled", "1");
11
11
  };
12
- const dragOver = (e) => {
13
- if (!e.dataTransfer) {
14
- return;
15
- }
16
- e.preventDefault();
12
+ const dragOver = e => {
13
+ if (!e.dataTransfer) {
14
+ return;
15
+ }
16
+ e.preventDefault();
17
17
  };
18
- const dragLeave = (e) => {
19
- if (!e.dataTransfer) {
20
- return;
21
- }
22
- e.currentTarget.removeAttribute("data-drop-enabled");
18
+ const dragLeave = e => {
19
+ if (!e.dataTransfer) {
20
+ return;
21
+ }
22
+ e.currentTarget.removeAttribute("data-drop-enabled");
23
23
  };
24
- const eventDrop = (e) => {
25
- if (!e.dataTransfer) {
26
- return;
24
+ const eventDrop = e => {
25
+ if (!e.dataTransfer) {
26
+ return;
27
+ }
28
+ e.preventDefault();
29
+ const currentTarget = e.currentTarget;
30
+ currentTarget.removeAttribute("data-drop-enabled");
31
+ const uploadEvent = StringHelper.fromHyphenToCamel(currentTarget.getAttribute("data-upload-event"));
32
+ const uploadRequested = StringHelper.fromHyphenToCamel(currentTarget.getAttribute("data-upload-requested"));
33
+ const extra = currentTarget.getAttribute("data-extra");
34
+ const convert = currentTarget.getAttribute("data-convert") === "true";
35
+ const maxSize = parseInt(currentTarget.getAttribute("data-max-size") || "0", 10);
36
+ const fileHandlesPromises = [...e.dataTransfer.items].filter(item => item.kind === "file").map(item => supportsFileSystemAccessAPI ? item.getAsFileSystemHandle() : supportsWebkitGetAsEntry ? item.webkitGetAsEntry() : item.getAsFile());
37
+ const files = [];
38
+ const getFiles = async (dir, parent = dir.name) => {
39
+ const all = [];
40
+ for await (const [name, handle] of dir.entries()) {
41
+ const path = `${parent}/${handle.name}`;
42
+ if (handle.kind === "directory" || handle.isDirectory) {
43
+ all.push(...(await getFiles(handle, path)));
44
+ continue;
45
+ }
46
+ const file = await handle.getFile();
47
+ Object.defineProperty(file, "webkitRelativePath", {
48
+ value: path
49
+ });
50
+ all.push(file);
51
+ }
52
+ return all;
53
+ };
54
+ const control = AtomControl.from(e.currentTarget);
55
+ control.app.runAsync(async () => {
56
+ for await (const handle of fileHandlesPromises) {
57
+ if (handle.kind === "directory" || handle.isDirectory) {
58
+ files.push(...(await getFiles(handle)));
59
+ } else {
60
+ files.push(await handle.getFile());
61
+ }
27
62
  }
28
- e.preventDefault();
29
- const currentTarget = e.currentTarget;
30
- currentTarget.removeAttribute("data-drop-enabled");
31
- const uploadEvent = StringHelper.fromHyphenToCamel(currentTarget.getAttribute("data-upload-event"));
32
- const uploadRequested = StringHelper.fromHyphenToCamel(currentTarget.getAttribute("data-upload-requested"));
33
- const extra = currentTarget.getAttribute("data-extra");
34
- const convert = currentTarget.getAttribute("data-convert") === "true";
35
- const maxSize = parseInt(currentTarget.getAttribute("data-max-size") || "0", 10);
36
- const fileHandlesPromises = [...e.dataTransfer.items]
37
- .filter((item) => item.kind === "file")
38
- .map((item) => supportsFileSystemAccessAPI
39
- ? item.getAsFileSystemHandle()
40
- : supportsWebkitGetAsEntry
41
- ? item.webkitGetAsEntry()
42
- : item.getAsFile());
43
- const files = [];
44
- const getFiles = async (dir, parent = dir.name) => {
45
- const all = [];
46
- for await (const [name, handle] of dir.entries()) {
47
- const path = `${parent}/${handle.name}`;
48
- if (handle.kind === "directory" || handle.isDirectory) {
49
- all.push(...(await getFiles(handle, path)));
50
- continue;
51
- }
52
- const file = await handle.getFile();
53
- Object.defineProperty(file, "webkitRelativePath", { value: path });
54
- all.push(file);
55
- }
56
- return all;
63
+ const detail = {
64
+ files,
65
+ extra,
66
+ convert,
67
+ maxSize,
68
+ uploadEvent
57
69
  };
58
- const control = AtomControl.from(e.currentTarget);
59
- control.app.runAsync(async () => {
60
- for await (const handle of fileHandlesPromises) {
61
- if (handle.kind === "directory" || handle.isDirectory) {
62
- files.push(...await getFiles(handle));
63
- }
64
- else {
65
- files.push(await handle.getFile());
66
- }
67
- }
68
- const detail = {
69
- files,
70
- extra,
71
- convert,
72
- maxSize,
73
- uploadEvent
74
- };
75
- currentTarget.dispatchEvent(new CustomEvent(uploadRequested, { detail, bubbles: true, cancelable: true }));
76
- });
70
+ currentTarget.dispatchEvent(new CustomEvent(uploadRequested, {
71
+ detail,
72
+ bubbles: true,
73
+ cancelable: true
74
+ }));
75
+ });
77
76
  };
78
- export const FilesDragDrop = ({ uploadEvent = "files-available", uploadRequested = "upload-requested", convert = false, maxSize = 50 * 1024 * 1024, extra = "", }) => ({
79
- "data-extra": extra,
80
- "data-drag-drop": "1",
81
- "data-convert": convert,
82
- "data-upload-event": uploadEvent,
83
- "data-upload-requested": uploadRequested,
84
- "data-max-size": maxSize,
85
- "event-dragenter": dragEnter,
86
- "event-dragleave": dragLeave,
87
- "event-dragover": dragOver,
88
- "event-drop": eventDrop
89
- });
90
- //# sourceMappingURL=FilesDragDrop.js.map
77
+ export const FilesDragDrop = ({
78
+ uploadEvent = "files-available",
79
+ uploadRequested = "upload-requested",
80
+ convert = false,
81
+ maxSize = 50 * 1024 * 1024,
82
+ extra = ""
83
+ }) => ({
84
+ "data-extra": extra,
85
+ "data-drag-drop": "1",
86
+ "data-convert": convert,
87
+ "data-upload-event": uploadEvent,
88
+ "data-upload-requested": uploadRequested,
89
+ "data-max-size": maxSize,
90
+ "event-dragenter": dragEnter,
91
+ "event-dragleave": dragLeave,
92
+ "event-dragover": dragOver,
93
+ "event-drop": eventDrop
94
+ });
@@ -1,61 +1,89 @@
1
1
  import Bind from "@web-atoms/core/dist/core/Bind.js";
2
2
  import { StringHelper } from "@web-atoms/core/dist/core/StringHelper.js";
3
3
  import XNode from "@web-atoms/core/dist/core/XNode.js";
4
- import "../styles/form.global.css";
5
- const checkClick = (e) => {
6
- const form = e.currentTarget;
7
- const element = e.target;
8
- let target = element;
9
- while (target.tagName !== "BUTTON") {
10
- target = target.parentElement;
11
- if (!target || target === form) {
12
- return;
13
- }
4
+ ESMPack.installStyleSheet(import.meta.resolve("../styles/form.global.css"));
5
+ const checkClick = e => {
6
+ const form = e.currentTarget;
7
+ const element = e.target;
8
+ let target = element;
9
+ while (target.tagName !== "BUTTON") {
10
+ target = target.parentElement;
11
+ if (!target || target === form) {
12
+ return;
14
13
  }
15
- const submitEvent = target.getAttribute("data-submit-event");
16
- if (!submitEvent) {
17
- if (!/submit/i.test(target.getAttribute("type") ?? target.getAttribute("data-type"))) {
18
- return;
19
- }
14
+ }
15
+ const submitEvent = target.getAttribute("data-submit-event");
16
+ if (!submitEvent) {
17
+ if (!/submit/i.test(target.getAttribute("type") ?? target.getAttribute("data-type"))) {
18
+ return;
20
19
  }
21
- form.setAttribute("data-show-validation", "true");
22
- setTimeout(() => {
23
- const all = Array.from(form.getElementsByClassName("field-error"));
24
- for (const iterator of all) {
25
- if (iterator.textContent) {
26
- form.setAttribute("data-valid", "false");
27
- return;
28
- }
29
- }
30
- form.setAttribute("data-valid", "true");
31
- const eventName = StringHelper.fromHyphenToCamel(submitEvent ?? form.getAttribute("data-submit-event"));
32
- target.dispatchEvent(new CustomEvent(eventName, { bubbles: true, cancelable: true }));
33
- }, 100);
20
+ }
21
+ form.setAttribute("data-show-validation", "true");
22
+ setTimeout(() => {
23
+ const all = Array.from(form.getElementsByClassName("field-error"));
24
+ for (const iterator of all) {
25
+ if (iterator.textContent) {
26
+ form.setAttribute("data-valid", "false");
27
+ return;
28
+ }
29
+ }
30
+ form.setAttribute("data-valid", "true");
31
+ const eventName = StringHelper.fromHyphenToCamel(submitEvent ?? form.getAttribute("data-submit-event"));
32
+ target.dispatchEvent(new CustomEvent(eventName, {
33
+ bubbles: true,
34
+ cancelable: true
35
+ }));
36
+ }, 100);
34
37
  };
35
- export default function Form({ "data-submit-event": submitEvent = "submitForm", "data-show-validation": showValidation = "false", "data-error-message": errorMessage = "Please fix all validations", ...a }, ...nodes) {
36
- return XNode.create("div", { ...a, "data-submit-event": submitEvent, "data-form": "form", "data-valid": "true", "data-show-validation": showValidation, "data-error-message": errorMessage, "event-click": checkClick },
37
- XNode.create("div", { class: "error-message", text: errorMessage }),
38
- ...nodes);
38
+ export default function Form({
39
+ "data-submit-event": submitEvent = "submitForm",
40
+ "data-show-validation": showValidation = "false",
41
+ "data-error-message": errorMessage = "Please fix all validations",
42
+ ...a
43
+ }, ...nodes) {
44
+ return XNode.create("div", {
45
+ ...a,
46
+ "data-submit-event": submitEvent,
47
+ "data-form": "form",
48
+ "data-valid": "true",
49
+ "data-show-validation": showValidation,
50
+ "data-error-message": errorMessage,
51
+ "event-click": checkClick
52
+ }, XNode.create("div", {
53
+ class: "error-message",
54
+ text: errorMessage
55
+ }), ...nodes);
39
56
  }
40
- export const BindError = ({ value, message = (v, l) => `${l} is invalid`, isValid = (v, e) => !!v, }) => {
41
- function f2(sender, element) {
42
- const isRequired = element.parentElement.querySelector(`[data-required]`);
43
- const msg = value.call(this, sender);
44
- if (!msg) {
45
- if (!isRequired) {
46
- return "";
47
- }
48
- }
49
- if (isValid(msg, element)) {
50
- return "";
51
- }
52
- return message(msg, element.parentElement.querySelector(`[data-element=label]`)?.textContent || "This field ");
57
+ export const BindError = ({
58
+ value,
59
+ message = (v, l) => `${l} is invalid`,
60
+ isValid = (v, e) => !!v
61
+ }) => {
62
+ function f2(sender, element) {
63
+ const isRequired = element.parentElement.querySelector(`[data-required]`);
64
+ const msg = value.call(this, sender);
65
+ if (!msg) {
66
+ if (!isRequired) {
67
+ return "";
68
+ }
53
69
  }
54
- ;
55
- f2.toString = () => value.toString();
56
- return Bind.oneWay(f2);
57
- };
58
- export const BindEmailError = ({ value, message = (v, l) => `${l} is not a valid email address`, isValid = (v, e) => /[^\@]+\@[^\@]+\.[^\@]+/i.test(v), }) => {
59
- return BindError({ value, message, isValid });
70
+ if (isValid(msg, element)) {
71
+ return "";
72
+ }
73
+ return message(msg, element.parentElement.querySelector(`[data-element=label]`)?.textContent || "This field ");
74
+ }
75
+ ;
76
+ f2.toString = () => value.toString();
77
+ return Bind.oneWay(f2);
60
78
  };
61
- //# sourceMappingURL=Form.js.map
79
+ export const BindEmailError = ({
80
+ value,
81
+ message = (v, l) => `${l} is not a valid email address`,
82
+ isValid = (v, e) => /[^\@]+\@[^\@]+\.[^\@]+/i.test(v)
83
+ }) => {
84
+ return BindError({
85
+ value,
86
+ message,
87
+ isValid
88
+ });
89
+ };
@@ -1,122 +1,180 @@
1
1
  import Bind from "@web-atoms/core/dist/core/Bind.js";
2
2
  import XNode from "@web-atoms/core/dist/core/XNode.js";
3
3
  import PopupService, { PopupWindow } from "@web-atoms/core/dist/web/services/PopupService.js";
4
- import "./styles/form-field.global.css";
5
- document.body.addEventListener("click", (e) => {
6
- let label = e.target;
7
- while (label && label.tagName !== "LABEL") {
8
- if (label.getAttribute("data-element") === "label") {
9
- break;
10
- }
11
- label = label.parentElement;
12
- if (label === document.body) {
13
- return;
14
- }
15
- }
16
- if (!label) {
17
- return;
4
+ ESMPack.installStyleSheet(import.meta.resolve("./styles/form-field.global.css"));
5
+ document.body.addEventListener("click", e => {
6
+ let label = e.target;
7
+ while (label && label.tagName !== "LABEL") {
8
+ if (label.getAttribute("data-element") === "label") {
9
+ break;
18
10
  }
19
- const formField = label.parentElement;
20
- if (!formField.hasAttribute("data-wa-form-field")) {
21
- return;
11
+ label = label.parentElement;
12
+ if (label === document.body) {
13
+ return;
22
14
  }
23
- const selectable = formField.querySelector("select,input,textarea");
24
- selectable?.focus?.();
15
+ }
16
+ if (!label) {
17
+ return;
18
+ }
19
+ const formField = label.parentElement;
20
+ if (!formField.hasAttribute("data-wa-form-field")) {
21
+ return;
22
+ }
23
+ const selectable = formField.querySelector("select,input,textarea");
24
+ selectable?.focus?.();
25
25
  });
26
- document.addEventListener("focusin", (e) => {
27
- let target = e.target;
28
- while (target) {
29
- if (target.getAttribute("data-wa-form-field") === "wa-form-field") {
30
- target.setAttribute("data-focused", "true");
31
- break;
32
- }
33
- target = target.parentElement;
26
+ document.addEventListener("focusin", e => {
27
+ let target = e.target;
28
+ while (target) {
29
+ if (target.getAttribute("data-wa-form-field") === "wa-form-field") {
30
+ target.setAttribute("data-focused", "true");
31
+ break;
34
32
  }
33
+ target = target.parentElement;
34
+ }
35
35
  });
36
- document.addEventListener("focusout", (e) => {
37
- let target = e.target;
38
- while (target) {
39
- if (target.getAttribute("data-wa-form-field") === "wa-form-field") {
40
- target.removeAttribute("data-focused");
41
- break;
42
- }
43
- target = target.parentElement;
36
+ document.addEventListener("focusout", e => {
37
+ let target = e.target;
38
+ while (target) {
39
+ if (target.getAttribute("data-wa-form-field") === "wa-form-field") {
40
+ target.removeAttribute("data-focused");
41
+ break;
44
42
  }
43
+ target = target.parentElement;
44
+ }
45
45
  });
46
- export default function FormField({ label, required, error, helpIcon = "fas fa-question-circle", help, helpEventClick, helpTitle, border = false, ...others }, node) {
47
- if (node) {
48
- const na = node.attributes ??= {};
49
- na["data-element"] = "content";
50
- }
51
- if (!helpEventClick && help) {
52
- helpEventClick = Bind.event((s, e) => {
53
- const app = s.app;
54
- if (typeof help === "string" || help instanceof XNode) {
55
- PopupService.notify(help).catch(console.error);
56
- return;
57
- }
58
- class HelpPopup extends PopupWindow {
59
- create() {
60
- this.render(XNode.create("div", { "data-form-field-help": "help-window" }, help));
61
- }
62
- }
63
- HelpPopup.showWindow({ title: helpTitle ?? "Help", modal: true });
64
- });
65
- }
66
- let labelIsNode = false;
67
- if (label) {
68
- if (label instanceof XNode) {
69
- const la = label.attributes ??= {};
70
- la["data-element"] = "label";
71
- labelIsNode = true;
46
+ export default function FormField({
47
+ label,
48
+ required,
49
+ error,
50
+ helpIcon = "fas fa-question-circle",
51
+ help,
52
+ helpEventClick,
53
+ helpTitle,
54
+ border = false,
55
+ ...others
56
+ }, node) {
57
+ if (node) {
58
+ const na = node.attributes ??= {};
59
+ na["data-element"] = "content";
60
+ }
61
+ if (!helpEventClick && help) {
62
+ helpEventClick = Bind.event((s, e) => {
63
+ const app = s.app;
64
+ if (typeof help === "string" || help instanceof XNode) {
65
+ PopupService.notify(help).catch(console.error);
66
+ return;
67
+ }
68
+ class HelpPopup extends PopupWindow {
69
+ create() {
70
+ this.render(XNode.create("div", {
71
+ "data-form-field-help": "help-window"
72
+ }, help));
72
73
  }
73
- else {
74
- if (node) {
75
- if (!(node.attributes?.ariaLabel || node.attributes?.["aria-label"])) {
76
- (node.attributes ??= {})["aria-label"] = label;
77
- }
78
- }
74
+ }
75
+ HelpPopup.showWindow({
76
+ title: helpTitle ?? "Help",
77
+ modal: true
78
+ });
79
+ });
80
+ }
81
+ let labelIsNode = false;
82
+ if (label) {
83
+ if (label instanceof XNode) {
84
+ const la = label.attributes ??= {};
85
+ la["data-element"] = "label";
86
+ labelIsNode = true;
87
+ } else {
88
+ if (node) {
89
+ if (!(node.attributes?.ariaLabel || node.attributes?.["aria-label"])) {
90
+ (node.attributes ??= {})["aria-label"] = label;
79
91
  }
92
+ }
80
93
  }
81
- return XNode.create("div", { "data-wa-form-field": "wa-form-field", "data-border": border, ...others },
82
- label && (labelIsNode ? label : XNode.create("label", { "data-element": "label", text: label })),
83
- required && XNode.create("span", { "data-required": "required", class: required, text: "*" }),
84
- border && XNode.create("i", { "data-border": "border" }),
85
- node,
86
- help && XNode.create("i", { "data-help": "help", class: helpIcon, title: helpTitle, eventClick: helpEventClick }),
87
- XNode.create("div", { class: "field-error", text: error }));
94
+ }
95
+ return XNode.create("div", {
96
+ "data-wa-form-field": "wa-form-field",
97
+ "data-border": border,
98
+ ...others
99
+ }, label && (labelIsNode ? label : XNode.create("label", {
100
+ "data-element": "label",
101
+ text: label
102
+ })), required && XNode.create("span", {
103
+ "data-required": "required",
104
+ class: required,
105
+ text: "*"
106
+ }), border && XNode.create("i", {
107
+ "data-border": "border"
108
+ }), node, help && XNode.create("i", {
109
+ "data-help": "help",
110
+ class: helpIcon,
111
+ title: helpTitle,
112
+ eventClick: helpEventClick
113
+ }), XNode.create("div", {
114
+ class: "field-error",
115
+ text: error
116
+ }));
88
117
  }
89
- export function HorizontalFormField({ label, required, error, helpIcon = "fas fa-question-circle", help, helpEventClick, helpTitle, border = false, ...others }, node) {
90
- if (node) {
91
- const na = node.attributes ??= {};
92
- na["data-content"] = "content";
93
- }
94
- if (!helpEventClick && help) {
95
- helpEventClick = Bind.event((s, e) => {
96
- const app = s.app;
97
- if (typeof help === "string" || help instanceof XNode) {
98
- PopupService.notify(help).catch(console.error);
99
- return;
100
- }
101
- class HelpPopup extends PopupWindow {
102
- create() {
103
- this.render(XNode.create("div", { "data-form-field-help": "help-window" }, help));
104
- }
105
- }
106
- HelpPopup.showWindow({ title: helpTitle ?? "Help" });
107
- });
108
- }
109
- if (node) {
110
- if (!(node.attributes?.ariaLabel || node.attributes?.["aria-label"])) {
111
- (node.attributes ??= {})["aria-label"] = label;
118
+ export function HorizontalFormField({
119
+ label,
120
+ required,
121
+ error,
122
+ helpIcon = "fas fa-question-circle",
123
+ help,
124
+ helpEventClick,
125
+ helpTitle,
126
+ border = false,
127
+ ...others
128
+ }, node) {
129
+ if (node) {
130
+ const na = node.attributes ??= {};
131
+ na["data-content"] = "content";
132
+ }
133
+ if (!helpEventClick && help) {
134
+ helpEventClick = Bind.event((s, e) => {
135
+ const app = s.app;
136
+ if (typeof help === "string" || help instanceof XNode) {
137
+ PopupService.notify(help).catch(console.error);
138
+ return;
139
+ }
140
+ class HelpPopup extends PopupWindow {
141
+ create() {
142
+ this.render(XNode.create("div", {
143
+ "data-form-field-help": "help-window"
144
+ }, help));
112
145
  }
146
+ }
147
+ HelpPopup.showWindow({
148
+ title: helpTitle ?? "Help"
149
+ });
150
+ });
151
+ }
152
+ if (node) {
153
+ if (!(node.attributes?.ariaLabel || node.attributes?.["aria-label"])) {
154
+ (node.attributes ??= {})["aria-label"] = label;
113
155
  }
114
- return XNode.create("div", { "data-wa-form-field": "wa-form-field", "data-layout": "horizontal", "data-border": border, ...others },
115
- label && XNode.create("label", { class: "label", text: label }),
116
- required && XNode.create("span", { "data-required": "required", class: required, text: "*" }),
117
- border && XNode.create("i", { "data-border": "border" }),
118
- node,
119
- help && XNode.create("i", { "data-help": "help", class: helpIcon, title: helpTitle, eventClick: helpEventClick }),
120
- XNode.create("div", { class: "field-error", text: error }));
121
- }
122
- //# sourceMappingURL=FormField.js.map
156
+ }
157
+ return XNode.create("div", {
158
+ "data-wa-form-field": "wa-form-field",
159
+ "data-layout": "horizontal",
160
+ "data-border": border,
161
+ ...others
162
+ }, label && XNode.create("label", {
163
+ class: "label",
164
+ text: label
165
+ }), required && XNode.create("span", {
166
+ "data-required": "required",
167
+ class: required,
168
+ text: "*"
169
+ }), border && XNode.create("i", {
170
+ "data-border": "border"
171
+ }), node, help && XNode.create("i", {
172
+ "data-help": "help",
173
+ class: helpIcon,
174
+ title: helpTitle,
175
+ eventClick: helpEventClick
176
+ }), XNode.create("div", {
177
+ class: "field-error",
178
+ text: error
179
+ }));
180
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=IElement.js.map
1
+ export {};