@web-atoms/web-controls 2.6.5 → 2.6.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 (177) hide show
  1. package/dist/tsconfig.tsbuildinfo +1 -1
  2. package/dist-esm/ArrayLike.js +14 -12
  3. package/dist-esm/DataAttributes.js +18 -19
  4. package/dist-esm/Focusable.js +10 -11
  5. package/dist-esm/ModuleFiles.js +43 -42
  6. package/dist-esm/NumberFormats.js +60 -56
  7. package/dist-esm/PageNavigator.js +28 -30
  8. package/dist-esm/animations/Animations.js +36 -33
  9. package/dist-esm/basic/AtomChips.js +312 -305
  10. package/dist-esm/basic/AtomRepeater.js +1070 -1035
  11. package/dist-esm/basic/AtomSuggestions.js +97 -107
  12. package/dist-esm/basic/AttachedPopup.js +0 -1
  13. package/dist-esm/basic/Button.js +45 -19
  14. package/dist-esm/basic/ButtonBar.js +84 -64
  15. package/dist-esm/basic/Calendar.js +211 -203
  16. package/dist-esm/basic/CheckBoxList.js +90 -70
  17. package/dist-esm/basic/Checkbox.js +16 -8
  18. package/dist-esm/basic/Chip.js +36 -12
  19. package/dist-esm/basic/ComboBox.js +47 -51
  20. package/dist-esm/basic/DataGrid.js +258 -252
  21. package/dist-esm/basic/DateField.js +149 -127
  22. package/dist-esm/basic/DropDown.js +91 -103
  23. package/dist-esm/basic/DropDownInput.js +78 -106
  24. package/dist-esm/basic/Editable.js +82 -77
  25. package/dist-esm/basic/Expander.js +104 -86
  26. package/dist-esm/basic/FilesDragDrop.js +84 -80
  27. package/dist-esm/basic/Form.js +80 -52
  28. package/dist-esm/basic/FormField.js +164 -106
  29. package/dist-esm/basic/IElement.js +1 -2
  30. package/dist-esm/basic/InlinePopup.js +263 -234
  31. package/dist-esm/basic/InlinePopupButton.js +99 -88
  32. package/dist-esm/basic/InlinePopupControl.js +24 -23
  33. package/dist-esm/basic/ItemPath.js +59 -60
  34. package/dist-esm/basic/LimitedText.js +49 -38
  35. package/dist-esm/basic/ListRepeater.js +13 -14
  36. package/dist-esm/basic/MaskedInput.js +37 -29
  37. package/dist-esm/basic/MaskedInputDiv.js +55 -48
  38. package/dist-esm/basic/MergeNode.js +64 -35
  39. package/dist-esm/basic/PasswordBox.js +32 -17
  40. package/dist-esm/basic/PinchZoomView.js +221 -199
  41. package/dist-esm/basic/PopupButton.js +39 -16
  42. package/dist-esm/basic/PopupMenu.js +3 -4
  43. package/dist-esm/basic/RadioButtonList.js +35 -25
  44. package/dist-esm/basic/RefreshLock.js +41 -42
  45. package/dist-esm/basic/Resizable.js +43 -33
  46. package/dist-esm/basic/Select.js +72 -65
  47. package/dist-esm/basic/SortByButton.js +41 -31
  48. package/dist-esm/basic/Swipe.js +91 -84
  49. package/dist-esm/basic/Switch.js +22 -8
  50. package/dist-esm/basic/TableRepeater.js +29 -33
  51. package/dist-esm/basic/TimeEditor.js +97 -52
  52. package/dist-esm/basic/TitleEditor.js +115 -95
  53. package/dist-esm/basic/ToggleButtonBar.js +21 -22
  54. package/dist-esm/basic/Tooltip.js +49 -47
  55. package/dist-esm/basic/TypeWriter.js +45 -42
  56. package/dist-esm/basic/UploadEvent.js +211 -178
  57. package/dist-esm/basic/ZoomView.js +229 -198
  58. package/dist-esm/basic/combineClasses.js +2 -3
  59. package/dist-esm/basic/elements/AtomPopover.js +270 -253
  60. package/dist-esm/basic/elements/getContainingBlock.js +34 -35
  61. package/dist-esm/basic/elements/relativeRect.js +40 -21
  62. package/dist-esm/desktop-app/DesktopApp.js +65 -80
  63. package/dist-esm/desktop-app/MobileDesktopApp.js +20 -23
  64. package/dist-esm/html-editor/AtomHtmlEditor.js +243 -268
  65. package/dist-esm/html-editor/HtmlEditorCommands.js +6 -4
  66. package/dist-esm/html-editor/InlineHtmlEditor.js +174 -166
  67. package/dist-esm/html-editor/RangeEditor.js +49 -51
  68. package/dist-esm/html-editor/commands/AddImage.js +40 -35
  69. package/dist-esm/html-editor/commands/AddLink.js +56 -54
  70. package/dist-esm/html-editor/commands/Align.js +24 -7
  71. package/dist-esm/html-editor/commands/AttachFile.js +23 -13
  72. package/dist-esm/html-editor/commands/AttachImage.js +35 -25
  73. package/dist-esm/html-editor/commands/Bold.js +10 -11
  74. package/dist-esm/html-editor/commands/ChangeColor.js +31 -107
  75. package/dist-esm/html-editor/commands/ChangeFont.js +42 -42
  76. package/dist-esm/html-editor/commands/ChangeFontSize.js +15 -5
  77. package/dist-esm/html-editor/commands/Command.js +34 -16
  78. package/dist-esm/html-editor/commands/CommandButton.js +51 -32
  79. package/dist-esm/html-editor/commands/Headings.js +25 -9
  80. package/dist-esm/html-editor/commands/HorizontalRule.js +9 -10
  81. package/dist-esm/html-editor/commands/HtmlCommands.js +160 -65
  82. package/dist-esm/html-editor/commands/IndentLess.js +10 -11
  83. package/dist-esm/html-editor/commands/IndentMore.js +10 -11
  84. package/dist-esm/html-editor/commands/Italic.js +10 -11
  85. package/dist-esm/html-editor/commands/NumberedList.js +10 -11
  86. package/dist-esm/html-editor/commands/Quote.js +10 -11
  87. package/dist-esm/html-editor/commands/RemoveFormat.js +10 -11
  88. package/dist-esm/html-editor/commands/Separator.js +5 -4
  89. package/dist-esm/html-editor/commands/Source.js +29 -25
  90. package/dist-esm/html-editor/commands/StrikeThrough.js +10 -11
  91. package/dist-esm/html-editor/commands/Toolbar.js +6 -4
  92. package/dist-esm/html-editor/commands/Underline.js +10 -11
  93. package/dist-esm/html-editor/commands/Unlink.js +10 -9
  94. package/dist-esm/html-editor/commands/UnorderedList.js +10 -11
  95. package/dist-esm/mobile-app/BottomPopup.js +137 -148
  96. package/dist-esm/mobile-app/MasterDetailPage.js +153 -152
  97. package/dist-esm/mobile-app/MobileApp.js +577 -569
  98. package/dist-esm/player/AtomVideoPlayer.js +316 -270
  99. package/dist-esm/player/TrackProgress.js +11 -7
  100. package/dist-esm/player/input-range-style.js +97 -98
  101. package/dist-esm/tests/app-test/AppTestApp.js +12 -15
  102. package/dist-esm/tests/app-test/AppTestApp.pack.js +54 -0
  103. package/dist-esm/tests/app-test/commands/AppCommands.js +14 -11
  104. package/dist-esm/tests/app-test/drawer/AppDrawer.js +4 -6
  105. package/dist-esm/tests/app-test/model/model.js +1 -2
  106. package/dist-esm/tests/app-test/pages/detail/DetailPage.js +21 -15
  107. package/dist-esm/tests/app-test/pages/home/HomePage.js +7 -8
  108. package/dist-esm/tests/app-test/pages/list/ListPage.js +79 -62
  109. package/dist-esm/tests/basic/PopupTest.js +9 -7
  110. package/dist-esm/tests/basic/TimeEditorTest.js +5 -9
  111. package/dist-esm/tests/basic/TimeEditorTest.pack.js +39 -0
  112. package/dist-esm/tests/basic/TimerTest.js +27 -37
  113. package/dist-esm/tests/basic/TimerTest.pack.js +40 -0
  114. package/dist-esm/tests/basic/basic-form/BasicForm.js +47 -27
  115. package/dist-esm/tests/basic/basic-form/BasicForm.pack.js +44 -0
  116. package/dist-esm/tests/basic/calendar/BasicCalendarTest.js +5 -9
  117. package/dist-esm/tests/basic/calendar/BasicCalendarTest.pack.js +53 -0
  118. package/dist-esm/tests/basic/chips/ChipsTest.js +25 -15
  119. package/dist-esm/tests/basic/chips/ChipsTest.pack.js +56 -0
  120. package/dist-esm/tests/basic/data-grid/DataGridTest.js +55 -60
  121. package/dist-esm/tests/basic/data-grid/DataGridTest.pack.js +58 -0
  122. package/dist-esm/tests/basic/date/DateFieldTest.js +21 -96
  123. package/dist-esm/tests/basic/date/DateFieldTest.pack.js +57 -0
  124. package/dist-esm/tests/basic/drop-down/DropDownTest.js +25 -19
  125. package/dist-esm/tests/basic/drop-down/DropDownTest.pack.js +52 -0
  126. package/dist-esm/tests/basic/drop-down-input/DropDownTest.js +32 -32
  127. package/dist-esm/tests/basic/drop-down-input/DropDownTest.pack.js +54 -0
  128. package/dist-esm/tests/basic/expander/ExpanderMenuTest.js +20 -14
  129. package/dist-esm/tests/basic/expander/ExpanderMenuTest.pack.js +38 -0
  130. package/dist-esm/tests/basic/expander/ExpanderTest.js +11 -12
  131. package/dist-esm/tests/basic/expander/ExpanderTest.pack.js +38 -0
  132. package/dist-esm/tests/basic/form2/Form2Test.js +26 -24
  133. package/dist-esm/tests/basic/form2/Form2Test.pack.js +46 -0
  134. package/dist-esm/tests/basic/limited-text/LimitedTextTest.js +14 -11
  135. package/dist-esm/tests/basic/limited-text/LimitedTextTest.pack.js +38 -0
  136. package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.js +14 -14
  137. package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.pack.js +38 -0
  138. package/dist-esm/tests/basic/repeater/DragDropRepater.js +30 -12
  139. package/dist-esm/tests/basic/repeater/DragDropRepater.pack.js +51 -0
  140. package/dist-esm/tests/basic/repeater/RepeaterTest.js +45 -35
  141. package/dist-esm/tests/basic/repeater/RepeaterTest.pack.js +52 -0
  142. package/dist-esm/tests/basic/swipe/SwipeTest.js +13 -13
  143. package/dist-esm/tests/basic/swipe/SwipeTest.pack.js +52 -0
  144. package/dist-esm/tests/basic/switch-test/SwitchTest.js +8 -10
  145. package/dist-esm/tests/basic/switch-test/SwitchTest.pack.js +38 -0
  146. package/dist-esm/tests/basic/title-editor/TitleEditorTest.js +8 -9
  147. package/dist-esm/tests/basic/title-editor/TitleEditorTest.pack.js +38 -0
  148. package/dist-esm/tests/basic/tooltip/TooltipTest.js +30 -24
  149. package/dist-esm/tests/basic/tooltip/TooltipTest.pack.js +52 -0
  150. package/dist-esm/tests/basic/typewriter/TypeWriter.js +10 -9
  151. package/dist-esm/tests/basic/typewriter/TypeWriter.pack.js +39 -0
  152. package/dist-esm/tests/basic/video/AtomVideoTest.js +13 -10
  153. package/dist-esm/tests/basic/video/AtomVideoTest.pack.js +38 -0
  154. package/dist-esm/tests/basic/zoom/ZoomViewTest.js +13 -13
  155. package/dist-esm/tests/basic/zoom/ZoomViewTest.pack.js +38 -0
  156. package/dist-esm/tests/check-box-list/CheckBoxListSample.js +13 -12
  157. package/dist-esm/tests/check-box-list/CheckBoxListSample.pack.js +52 -0
  158. package/dist-esm/tests/data-grid/GridTestViewModel.js +203 -227
  159. package/dist-esm/tests/form/CustomHelp.js +6 -9
  160. package/dist-esm/tests/form/FormViewModel.js +21 -28
  161. package/dist-esm/tests/html-editor/HtmlEditorTest.js +7 -37
  162. package/dist-esm/tests/html-editor/HtmlEditorTest.pack.js +83 -0
  163. package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.js +9 -38
  164. package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.pack.js +85 -0
  165. package/dist-esm/tests/mask/MaskedInputTest.js +11 -12
  166. package/dist-esm/tests/mask/MaskedInputTest.pack.js +38 -0
  167. package/dist-esm/tests/mobile-app/DesktopAppTest.js +8 -9
  168. package/dist-esm/tests/mobile-app/DesktopAppTest.pack.js +60 -0
  169. package/dist-esm/tests/mobile-app/MobileAppTest.js +64 -53
  170. package/dist-esm/tests/mobile-app/MobileAppTest.pack.js +55 -0
  171. package/dist-esm/tests/pop-over/PopOverTest.js +37 -77
  172. package/dist-esm/tests/switch/SwitchTest.js +9 -8
  173. package/dist-esm/tests/toggle-view/ToggleViewTest.js +15 -22
  174. package/dist-esm/tests/toggle-view/ToggleViewTest.pack.js +45 -0
  175. package/dist-esm/toggle-view/AtomToggleView.js +77 -73
  176. package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
  177. package/package.json +3 -3
@@ -4,116 +4,88 @@ import XNode from "@web-atoms/core/dist/core/XNode.js";
4
4
  import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl.js";
5
5
  import { askSuggestionPopup, MatchAnyCaseInsensitive } from "./AtomRepeater.js";
6
6
  import { BindableProperty } from "@web-atoms/core/dist/core/BindableProperty.js";
7
- import "./DropDownInput.global.css";
7
+ ESMPack.installStyleSheet(import.meta.resolve("./DropDownInput.global.css"));
8
8
  export default class DropDownInput extends AtomControl {
9
- constructor(app, e = document.createElement("drop-down-input")) {
10
- super(app, e);
11
- }
12
- onPropertyChanged(name) {
13
- super.onPropertyChanged(name);
14
- switch (name) {
15
- case "search":
16
- if (this.search) {
17
- this.openPopup().catch(console.error);
18
- }
19
- break;
9
+ constructor(app, e = document.createElement("drop-down-input")) {
10
+ super(app, e);
11
+ }
12
+ onPropertyChanged(name) {
13
+ super.onPropertyChanged(name);
14
+ switch (name) {
15
+ case "search":
16
+ if (this.search) {
17
+ this.openPopup().catch(console.error);
20
18
  }
19
+ break;
21
20
  }
22
- preCreate() {
23
- this.items = null;
24
- this.value = null;
25
- this.selectedItem = null;
26
- this.labelPath = (x) => x?.label ?? x;
27
- this.valuePath = (x) => x?.value ?? x;
28
- this.itemRenderer = (x) => XNode.create("div", { text: this.labelPath?.(x) ?? x });
29
- this.search = "";
30
- this.label = "";
31
- this.isPopupOpen = false;
32
- this.disableSearch = true;
33
- this.render(XNode.create("div", { "event-click": () => this.input.focus() },
34
- XNode.create("input", { autofocus: Bind.oneTime(() => this.autofocus), "event-focus": () => this.onFocus(), value: Bind.twoWaysImmediate(() => this.search) }),
35
- XNode.create("label", { text: Bind.oneWay((x) => this.labelPath(this.items?.find((i) => this.valuePath(i) === this.value))) }),
36
- XNode.create("i", null)));
37
- this.input = this.element.querySelector("input");
38
- this.labelElement = this.element.querySelector("label");
21
+ }
22
+ preCreate() {
23
+ this.items = null;
24
+ this.value = null;
25
+ this.selectedItem = null;
26
+ this.labelPath = x => x?.label ?? x;
27
+ this.valuePath = x => x?.value ?? x;
28
+ this.itemRenderer = x => XNode.create("div", {
29
+ text: this.labelPath?.(x) ?? x
30
+ });
31
+ this.search = "";
32
+ this.label = "";
33
+ this.isPopupOpen = false;
34
+ this.disableSearch = true;
35
+ this.render(XNode.create("div", {
36
+ "event-click": () => this.input.focus()
37
+ }, XNode.create("input", {
38
+ autofocus: Bind.oneTime(() => this.autofocus),
39
+ "event-focus": () => this.onFocus(),
40
+ value: Bind.twoWaysImmediate(() => this.search)
41
+ }), XNode.create("label", {
42
+ text: Bind.oneWay(x => this.labelPath(this.items?.find(i => this.valuePath(i) === this.value)))
43
+ }), XNode.create("i", null)));
44
+ this.input = this.element.querySelector("input");
45
+ this.labelElement = this.element.querySelector("label");
46
+ }
47
+ onFocus() {
48
+ const value = this.value;
49
+ if (value) {
50
+ const item = this.items.find(i => this.valuePath?.(i) == value);
51
+ this.input.placeholder = item ? this.labelPath(item) : this.label;
39
52
  }
40
- onFocus() {
41
- const value = this.value;
42
- if (value) {
43
- const item = this.items.find((i) => this.valuePath?.(i) == value);
44
- this.input.placeholder = item ? this.labelPath(item) : this.label;
45
- }
46
- this.input.value = "";
47
- this.app.runAsync(() => this.openPopup());
53
+ this.input.value = "";
54
+ this.app.runAsync(() => this.openPopup());
55
+ }
56
+ async openPopup() {
57
+ if (this.isPopupOpen) {
58
+ return;
48
59
  }
49
- async openPopup() {
50
- if (this.isPopupOpen) {
51
- return;
52
- }
53
- this.isPopupOpen = true;
54
- try {
55
- let selectedItem = this.items.find((i) => this.value === (this.valuePath?.(i) ?? i));
56
- this.anchorItem = selectedItem;
57
- this.selectedItem = selectedItem;
58
- const newItem = await askSuggestionPopup(this, this.items, this.itemRenderer, this.match ?? MatchAnyCaseInsensitive(this.labelPath), selectedItem);
59
- if (newItem !== selectedItem) {
60
- this.selectedItem = selectedItem;
61
- this.value = this.valuePath?.(newItem) ?? newItem;
62
- this.element.dispatchEvent(new CustomEvent("selectionChanged", {
63
- bubbles: true,
64
- detail: newItem,
65
- cancelable: true
66
- }));
67
- this.input.placeholder = this.label;
68
- }
69
- }
70
- finally {
71
- this.isPopupOpen = false;
72
- }
60
+ this.isPopupOpen = true;
61
+ try {
62
+ let selectedItem = this.items.find(i => this.value === (this.valuePath?.(i) ?? i));
63
+ this.anchorItem = selectedItem;
64
+ this.selectedItem = selectedItem;
65
+ const newItem = await askSuggestionPopup(this, this.items, this.itemRenderer, this.match ?? MatchAnyCaseInsensitive(this.labelPath), selectedItem);
66
+ if (newItem !== selectedItem) {
67
+ this.selectedItem = selectedItem;
68
+ this.value = this.valuePath?.(newItem) ?? newItem;
69
+ this.element.dispatchEvent(new CustomEvent("selectionChanged", {
70
+ bubbles: true,
71
+ detail: newItem,
72
+ cancelable: true
73
+ }));
74
+ this.input.placeholder = this.label;
75
+ }
76
+ } finally {
77
+ this.isPopupOpen = false;
73
78
  }
79
+ }
74
80
  }
75
- __decorate([
76
- BindableProperty,
77
- __metadata("design:type", Boolean)
78
- ], DropDownInput.prototype, "popupSuggestions", void 0);
79
- __decorate([
80
- BindableProperty,
81
- __metadata("design:type", String)
82
- ], DropDownInput.prototype, "search", void 0);
83
- __decorate([
84
- BindableProperty,
85
- __metadata("design:type", String)
86
- ], DropDownInput.prototype, "prompt", void 0);
87
- __decorate([
88
- BindableProperty,
89
- __metadata("design:type", String)
90
- ], DropDownInput.prototype, "suggestionPrompt", void 0);
91
- __decorate([
92
- BindableProperty,
93
- __metadata("design:type", Boolean)
94
- ], DropDownInput.prototype, "autofocus", void 0);
95
- __decorate([
96
- BindableProperty,
97
- __metadata("design:type", Function)
98
- ], DropDownInput.prototype, "itemRenderer", void 0);
99
- __decorate([
100
- BindableProperty,
101
- __metadata("design:type", Function)
102
- ], DropDownInput.prototype, "labelPath", void 0);
103
- __decorate([
104
- BindableProperty,
105
- __metadata("design:type", Function)
106
- ], DropDownInput.prototype, "valuePath", void 0);
107
- __decorate([
108
- BindableProperty,
109
- __metadata("design:type", Function)
110
- ], DropDownInput.prototype, "match", void 0);
111
- __decorate([
112
- BindableProperty,
113
- __metadata("design:type", Function)
114
- ], DropDownInput.prototype, "suggestionRenderer", void 0);
115
- __decorate([
116
- BindableProperty,
117
- __metadata("design:type", Object)
118
- ], DropDownInput.prototype, "selectedItem", void 0);
119
- //# sourceMappingURL=DropDownInput.js.map
81
+ __decorate([BindableProperty, __metadata("design:type", Boolean)], DropDownInput.prototype, "popupSuggestions", void 0);
82
+ __decorate([BindableProperty, __metadata("design:type", String)], DropDownInput.prototype, "search", void 0);
83
+ __decorate([BindableProperty, __metadata("design:type", String)], DropDownInput.prototype, "prompt", void 0);
84
+ __decorate([BindableProperty, __metadata("design:type", String)], DropDownInput.prototype, "suggestionPrompt", void 0);
85
+ __decorate([BindableProperty, __metadata("design:type", Boolean)], DropDownInput.prototype, "autofocus", void 0);
86
+ __decorate([BindableProperty, __metadata("design:type", Function)], DropDownInput.prototype, "itemRenderer", void 0);
87
+ __decorate([BindableProperty, __metadata("design:type", Function)], DropDownInput.prototype, "labelPath", void 0);
88
+ __decorate([BindableProperty, __metadata("design:type", Function)], DropDownInput.prototype, "valuePath", void 0);
89
+ __decorate([BindableProperty, __metadata("design:type", Function)], DropDownInput.prototype, "match", void 0);
90
+ __decorate([BindableProperty, __metadata("design:type", Function)], DropDownInput.prototype, "suggestionRenderer", void 0);
91
+ __decorate([BindableProperty, __metadata("design:type", Object)], DropDownInput.prototype, "selectedItem", void 0);
@@ -1,91 +1,96 @@
1
1
  import XNode from "@web-atoms/core/dist/core/XNode.js";
2
2
  import { getParentRepeaterItem } from "./AtomRepeater.js";
3
3
  export function getPropertyInfo(propertyPath) {
4
- if (typeof propertyPath === "string") {
5
- return {
6
- key: propertyPath,
7
- getter: (item) => item?.[propertyPath],
8
- setter: (item, value) => {
9
- if (item) {
10
- item[propertyPath] = value;
11
- }
12
- }
13
- };
14
- }
15
- if (!Array.isArray(propertyPath)) {
16
- return propertyPath;
17
- }
18
- const last = propertyPath.pop();
19
- let getterIntermediate;
20
- if (propertyPath.length > 0) {
21
- getterIntermediate = (item) => {
22
- if (!item) {
23
- return item;
24
- }
25
- for (const iterator of propertyPath) {
26
- item = item[iterator];
27
- if (!item) {
28
- return item;
29
- }
30
- }
31
- return item;
32
- };
33
- }
34
- const setter = (item, value) => {
4
+ if (typeof propertyPath === "string") {
5
+ return {
6
+ key: propertyPath,
7
+ getter: item => item?.[propertyPath],
8
+ setter: (item, value) => {
35
9
  if (item) {
36
- if (getterIntermediate) {
37
- item = getterIntermediate(item);
38
- }
39
- if (item) {
40
- item[last] = value;
41
- }
10
+ item[propertyPath] = value;
42
11
  }
12
+ }
43
13
  };
44
- const getter = (item) => {
14
+ }
15
+ if (!Array.isArray(propertyPath)) {
16
+ return propertyPath;
17
+ }
18
+ const last = propertyPath.pop();
19
+ let getterIntermediate;
20
+ if (propertyPath.length > 0) {
21
+ getterIntermediate = item => {
22
+ if (!item) {
23
+ return item;
24
+ }
25
+ for (const iterator of propertyPath) {
26
+ item = item[iterator];
45
27
  if (!item) {
46
- return item;
28
+ return item;
47
29
  }
48
- if (getterIntermediate) {
49
- item = getterIntermediate(item);
50
- }
51
- return item?.[last];
52
- };
53
- return {
54
- key: propertyPath.join(","),
55
- getter,
56
- setter
30
+ }
31
+ return item;
57
32
  };
33
+ }
34
+ const setter = (item, value) => {
35
+ if (item) {
36
+ if (getterIntermediate) {
37
+ item = getterIntermediate(item);
38
+ }
39
+ if (item) {
40
+ item[last] = value;
41
+ }
42
+ }
43
+ };
44
+ const getter = item => {
45
+ if (!item) {
46
+ return item;
47
+ }
48
+ if (getterIntermediate) {
49
+ item = getterIntermediate(item);
50
+ }
51
+ return item?.[last];
52
+ };
53
+ return {
54
+ key: propertyPath.join(","),
55
+ getter,
56
+ setter
57
+ };
58
58
  }
59
59
  const handlers = {};
60
60
  function registerEvent(property, changeEvents, editorValuePath) {
61
- property.key ??= property.setter + ":" + property.getter;
62
- const name = `${property.key}:${changeEvents.join(",")}`;
63
- if (!handlers[name]) {
64
- handlers[name] = changeEvents;
65
- for (const iterator of changeEvents) {
66
- document.body.addEventListener(iterator, (e) => {
67
- setTimeout(() => {
68
- const ri = getParentRepeaterItem(e.target);
69
- if (!ri) {
70
- return;
71
- }
72
- const [_, repeater, item] = ri;
73
- const oldValue = property.getter(item);
74
- const value = editorValuePath(e.target);
75
- if (oldValue != value) {
76
- property.setter(item, value);
77
- repeater.refreshItem(item);
78
- }
79
- }, 1);
80
- }, true);
81
- }
82
- }
83
- }
84
- export function EditableInput({ propertyPath, ...a }) {
85
- if (typeof propertyPath === "string" || Array.isArray(propertyPath)) {
86
- propertyPath = getPropertyInfo(propertyPath);
61
+ property.key ??= property.setter + ":" + property.getter;
62
+ const name = `${property.key}:${changeEvents.join(",")}`;
63
+ if (!handlers[name]) {
64
+ handlers[name] = changeEvents;
65
+ for (const iterator of changeEvents) {
66
+ document.body.addEventListener(iterator, e => {
67
+ setTimeout(() => {
68
+ const ri = getParentRepeaterItem(e.target);
69
+ if (!ri) {
70
+ return;
71
+ }
72
+ const [_, repeater, item] = ri;
73
+ const oldValue = property.getter(item);
74
+ const value = editorValuePath(e.target);
75
+ if (oldValue != value) {
76
+ property.setter(item, value);
77
+ repeater.refreshItem(item);
78
+ }
79
+ }, 1);
80
+ }, true);
87
81
  }
88
- registerEvent(propertyPath, ["change", "blur"], (item) => item.value);
89
- return XNode.create("input", { type: "text", ...a });
82
+ }
90
83
  }
91
- //# sourceMappingURL=Editable.js.map
84
+ export function EditableInput({
85
+ propertyPath,
86
+ ...a
87
+ }) {
88
+ if (typeof propertyPath === "string" || Array.isArray(propertyPath)) {
89
+ propertyPath = getPropertyInfo(propertyPath);
90
+ }
91
+ registerEvent(propertyPath, ["change", "blur"], item => item.value);
92
+ return XNode.create("input", {
93
+ type: "text",
94
+ ...a
95
+ });
96
+ }
@@ -1,91 +1,109 @@
1
1
  import XNode from "@web-atoms/core/dist/core/XNode.js";
2
- import "./styles/expander.global.css";
3
- document.body.addEventListener("click", (e) => {
4
- if (e.defaultPrevented) {
5
- return;
2
+ ESMPack.installStyleSheet(import.meta.resolve("./styles/expander.global.css"));
3
+ document.body.addEventListener("click", e => {
4
+ if (e.defaultPrevented) {
5
+ return;
6
+ }
7
+ let start = e.target;
8
+ while (start) {
9
+ if (/icon|caret|header/.test(start.getAttribute("data-element"))) {
10
+ break;
6
11
  }
7
- let start = e.target;
8
- while (start) {
9
- if (/icon|caret|header/.test(start.getAttribute("data-element"))) {
10
- break;
11
- }
12
- start = start.parentElement;
13
- }
14
- start = start?.parentElement;
15
- if (!start) {
16
- return;
17
- }
18
- const isExpander = start?.getAttribute("data-is-expander");
19
- if (!/^(menu|expander)$/i.test(isExpander)) {
20
- return;
21
- }
22
- const ds = start.dataset;
23
- if (/menu/i.test(isExpander)) {
24
- e.preventDefault();
25
- e.stopImmediatePropagation();
26
- }
27
- if (ds.isExpanded === "false") {
28
- start.dispatchEvent(new CustomEvent("expanded", { bubbles: true, cancelable: true }));
29
- }
30
- else {
31
- start.dispatchEvent(new CustomEvent("collapsed", { bubbles: true, cancelable: true }));
32
- }
33
- }, { capture: true });
34
- document.body.addEventListener("expanded", (ce) => {
35
- if (ce.defaultPrevented) {
36
- return;
37
- }
38
- const target = ce.target;
39
- target.dataset.isExpanded = "true";
12
+ start = start.parentElement;
13
+ }
14
+ start = start?.parentElement;
15
+ if (!start) {
16
+ return;
17
+ }
18
+ const isExpander = start?.getAttribute("data-is-expander");
19
+ if (!/^(menu|expander)$/i.test(isExpander)) {
20
+ return;
21
+ }
22
+ const ds = start.dataset;
23
+ if (/menu/i.test(isExpander)) {
24
+ e.preventDefault();
25
+ e.stopImmediatePropagation();
26
+ }
27
+ if (ds.isExpanded === "false") {
28
+ start.dispatchEvent(new CustomEvent("expanded", {
29
+ bubbles: true,
30
+ cancelable: true
31
+ }));
32
+ } else {
33
+ start.dispatchEvent(new CustomEvent("collapsed", {
34
+ bubbles: true,
35
+ cancelable: true
36
+ }));
37
+ }
38
+ }, {
39
+ capture: true
40
40
  });
41
- document.body.addEventListener("collapsed", (ce) => {
42
- if (ce.defaultPrevented) {
43
- return;
44
- }
45
- const target = ce.target;
46
- target.dataset.isExpanded = "false";
41
+ document.body.addEventListener("expanded", ce => {
42
+ if (ce.defaultPrevented) {
43
+ return;
44
+ }
45
+ const target = ce.target;
46
+ target.dataset.isExpanded = "true";
47
47
  });
48
- export default function Expander({ icon, isExpanded, ...a }, header, detail) {
49
- if (!detail) {
50
- throw new Error("Expander must contain two children, one header and one detail");
51
- }
52
- const ha = header.attributes ??= {};
53
- const da = detail.attributes ??= {};
54
- ha["data-element"] = "header";
55
- da["data-element"] = "detail";
56
- const iconElement = !icon
57
- ? []
58
- : (Array.isArray(icon)
59
- ? icon
60
- : [icon]).map((i) => XNode.create("i", { "data-element": "icon", class: i }));
61
- return XNode.create("div", { "data-is-expander": "expander", "data-is-expanded": isExpanded, ...a },
62
- ...iconElement,
63
- header,
64
- XNode.create("i", { "data-element": "caret", class: "fas fa-angle-down" }),
65
- detail);
66
- }
67
- export function ExpanderMenu({ icon, isExpanded, ...a }, header, ...details) {
68
- if (details.length === 0) {
69
- throw new Error("Expander must contain two children, one header and one detail");
70
- }
71
- const ha = header.attributes ??= {};
72
- ha["data-element"] = "header";
73
- let i = 2;
74
- details = details.filter((x) => x !== false);
75
- for (const iterator of details) {
76
- const ia = (iterator.attributes ??= {});
77
- ia["data-element"] = "detail";
78
- ia["style-grid-row-start"] = (i++).toString();
79
- }
80
- const iconElement = !icon
81
- ? []
82
- : (Array.isArray(icon)
83
- ? icon
84
- : [icon]).map((i) => XNode.create("i", { "data-element": "icon", class: i }));
85
- return XNode.create("div", { "data-is-expander": "menu", "data-is-expanded": isExpanded, ...a },
86
- ...iconElement,
87
- header,
88
- XNode.create("i", { "data-element": "caret", class: "fas fa-angle-down" }),
89
- ...details);
48
+ document.body.addEventListener("collapsed", ce => {
49
+ if (ce.defaultPrevented) {
50
+ return;
51
+ }
52
+ const target = ce.target;
53
+ target.dataset.isExpanded = "false";
54
+ });
55
+ export default function Expander({
56
+ icon,
57
+ isExpanded,
58
+ ...a
59
+ }, header, detail) {
60
+ if (!detail) {
61
+ throw new Error("Expander must contain two children, one header and one detail");
62
+ }
63
+ const ha = header.attributes ??= {};
64
+ const da = detail.attributes ??= {};
65
+ ha["data-element"] = "header";
66
+ da["data-element"] = "detail";
67
+ const iconElement = !icon ? [] : (Array.isArray(icon) ? icon : [icon]).map(i => XNode.create("i", {
68
+ "data-element": "icon",
69
+ class: i
70
+ }));
71
+ return XNode.create("div", {
72
+ "data-is-expander": "expander",
73
+ "data-is-expanded": isExpanded,
74
+ ...a
75
+ }, ...iconElement, header, XNode.create("i", {
76
+ "data-element": "caret",
77
+ class: "fas fa-angle-down"
78
+ }), detail);
90
79
  }
91
- //# sourceMappingURL=Expander.js.map
80
+ export function ExpanderMenu({
81
+ icon,
82
+ isExpanded,
83
+ ...a
84
+ }, header, ...details) {
85
+ if (details.length === 0) {
86
+ throw new Error("Expander must contain two children, one header and one detail");
87
+ }
88
+ const ha = header.attributes ??= {};
89
+ ha["data-element"] = "header";
90
+ let i = 2;
91
+ details = details.filter(x => x !== false);
92
+ for (const iterator of details) {
93
+ const ia = iterator.attributes ??= {};
94
+ ia["data-element"] = "detail";
95
+ ia["style-grid-row-start"] = (i++).toString();
96
+ }
97
+ const iconElement = !icon ? [] : (Array.isArray(icon) ? icon : [icon]).map(i => XNode.create("i", {
98
+ "data-element": "icon",
99
+ class: i
100
+ }));
101
+ return XNode.create("div", {
102
+ "data-is-expander": "menu",
103
+ "data-is-expanded": isExpanded,
104
+ ...a
105
+ }, ...iconElement, header, XNode.create("i", {
106
+ "data-element": "caret",
107
+ class: "fas fa-angle-down"
108
+ }), ...details);
109
+ }