@sme.up/ketchup 6.7.0 → 6.8.0

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 (170) hide show
  1. package/dist/cjs/{f-button-bf76ab95.js → f-button-229c63fd.js} +1 -1
  2. package/dist/cjs/{f-cell-b7a1524a.js → f-cell-dd006395.js} +5 -5
  3. package/dist/cjs/{f-chip-a5e100b1.js → f-chip-f2c369fd.js} +2 -2
  4. package/dist/cjs/{f-image-d80a2749.js → f-image-847a6ddf.js} +1 -1
  5. package/dist/cjs/{f-paginator-utils-c70812fe.js → f-paginator-utils-cedc4b3e.js} +2 -2
  6. package/dist/cjs/{f-text-field-48b8bb16.js → f-text-field-fe85187d.js} +1 -1
  7. package/dist/cjs/ketchup.cjs.js +2 -2
  8. package/dist/cjs/kup-accordion.cjs.entry.js +6 -29
  9. package/dist/cjs/{kup-autocomplete_25.cjs.entry.js → kup-autocomplete_26.cjs.entry.js} +3811 -4323
  10. package/dist/cjs/kup-box.cjs.entry.js +29 -110
  11. package/dist/cjs/kup-calendar.cjs.entry.js +9 -33
  12. package/dist/cjs/kup-cell.cjs.entry.js +8 -27
  13. package/dist/cjs/kup-dash-list.cjs.entry.js +9 -8
  14. package/dist/cjs/kup-dash_2.cjs.entry.js +6 -34
  15. package/dist/cjs/kup-dashboard.cjs.entry.js +8 -30
  16. package/dist/cjs/kup-drawer.cjs.entry.js +3 -18
  17. package/dist/cjs/kup-echart.cjs.entry.js +15 -76
  18. package/dist/cjs/kup-family-tree.cjs.entry.js +11 -47
  19. package/dist/cjs/kup-iframe.cjs.entry.js +4 -16
  20. package/dist/cjs/kup-image-list.cjs.entry.js +14 -32
  21. package/dist/cjs/kup-lazy.cjs.entry.js +9 -36
  22. package/dist/cjs/kup-magic-box.cjs.entry.js +5 -24
  23. package/dist/cjs/{kup-manager-0e38bf48.js → kup-manager-c53468cd.js} +66 -1
  24. package/dist/cjs/kup-nav-bar.cjs.entry.js +3 -15
  25. package/dist/cjs/kup-numeric-picker.cjs.entry.js +13 -56
  26. package/dist/cjs/kup-photo-frame.cjs.entry.js +8 -30
  27. package/dist/cjs/kup-probe.cjs.entry.js +12 -32
  28. package/dist/cjs/kup-qlik.cjs.entry.js +5 -59
  29. package/dist/cjs/kup-snackbar.cjs.entry.js +6 -37
  30. package/dist/cjs/loader.cjs.js +2 -2
  31. package/dist/collection/collection-manifest.json +2 -2
  32. package/dist/collection/components/kup-accordion/kup-accordion.js +4 -27
  33. package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +15 -64
  34. package/dist/collection/components/kup-badge/kup-badge.js +3 -19
  35. package/dist/collection/components/kup-box/kup-box.js +22 -103
  36. package/dist/collection/components/kup-button/kup-button.js +3 -58
  37. package/dist/collection/components/kup-button-list/kup-button-list.js +3 -38
  38. package/dist/collection/components/kup-calendar/kup-calendar.js +5 -29
  39. package/dist/collection/components/kup-card/box/kup-card-box.js +5 -2
  40. package/dist/collection/components/kup-card/built-in/kup-card-built-in.js +10 -2
  41. package/dist/collection/components/kup-card/built-in/kup-card-form.js +11 -0
  42. package/dist/collection/components/kup-card/kup-card.css +78 -12
  43. package/dist/collection/components/kup-card/kup-card.js +48 -47
  44. package/dist/collection/components/kup-cell/kup-cell.js +3 -22
  45. package/dist/collection/components/kup-chart/kup-chart.js +15 -49
  46. package/dist/collection/components/kup-checkbox/kup-checkbox.js +3 -38
  47. package/dist/collection/components/kup-chip/kup-chip.js +3 -19
  48. package/dist/collection/components/kup-color-picker/kup-color-picker.js +4 -35
  49. package/dist/collection/components/kup-combobox/kup-combobox.js +10 -42
  50. package/dist/collection/components/kup-dash/kup-dash.js +2 -14
  51. package/dist/collection/components/kup-dash-list/kup-dash-list.js +8 -7
  52. package/dist/collection/components/kup-dashboard/kup-dashboard.js +4 -26
  53. package/dist/collection/components/kup-data-table/kup-data-table-declarations.js +2 -0
  54. package/dist/collection/components/kup-data-table/kup-data-table.css +9 -0
  55. package/dist/collection/components/kup-data-table/kup-data-table.js +3546 -3385
  56. package/dist/collection/components/kup-date-picker/kup-date-picker.js +7 -35
  57. package/dist/collection/components/kup-drawer/kup-drawer.js +2 -17
  58. package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.js +12 -63
  59. package/dist/collection/components/kup-echart/kup-echart.js +14 -75
  60. package/dist/collection/components/kup-family-tree/kup-family-tree.js +8 -44
  61. package/dist/collection/components/kup-form/kup-form.js +4 -24
  62. package/dist/collection/components/kup-gauge/kup-gauge.js +15 -76
  63. package/dist/collection/components/kup-grid/kup-grid.js +3 -19
  64. package/dist/collection/components/kup-iframe/kup-iframe.js +3 -15
  65. package/dist/collection/components/kup-image/kup-image.js +5 -45
  66. package/dist/collection/components/kup-image-list/kup-image-list.js +8 -26
  67. package/dist/collection/components/kup-lazy/kup-lazy.js +8 -35
  68. package/dist/collection/components/kup-list/kup-list.js +5 -68
  69. package/dist/collection/components/kup-magic-box/kup-magic-box.js +3 -22
  70. package/dist/collection/components/kup-nav-bar/kup-nav-bar.js +2 -14
  71. package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.js +11 -54
  72. package/dist/collection/components/kup-photo-frame/kup-photo-frame.js +7 -29
  73. package/dist/collection/components/kup-probe/kup-probe.js +11 -31
  74. package/dist/collection/components/kup-progress-bar/kup-progress-bar.js +3 -35
  75. package/dist/collection/components/kup-qlik/kup-qlik.js +4 -58
  76. package/dist/collection/components/kup-radio/kup-radio.js +3 -34
  77. package/dist/collection/components/kup-rating/kup-rating.js +4 -27
  78. package/dist/collection/components/kup-snackbar/kup-snackbar.js +3 -34
  79. package/dist/collection/components/kup-spinner/kup-spinner.js +3 -39
  80. package/dist/collection/components/kup-switch/kup-switch.js +3 -34
  81. package/dist/collection/components/kup-tab-bar/kup-tab-bar.js +4 -24
  82. package/dist/collection/components/kup-text-field/kup-text-field.js +2 -115
  83. package/dist/collection/components/kup-time-picker/kup-time-picker.js +8 -43
  84. package/dist/collection/components/kup-tree/kup-tree.js +39 -129
  85. package/dist/collection/f-components/f-cell/f-cell.js +1 -1
  86. package/dist/collection/managers/kup-language/kup-language-declarations.js +6 -0
  87. package/dist/esm/{f-button-e79f7594.js → f-button-d1aba968.js} +1 -1
  88. package/dist/esm/{f-cell-9400374e.js → f-cell-646406bb.js} +5 -5
  89. package/dist/esm/{f-chip-bf740287.js → f-chip-d94e9e81.js} +2 -2
  90. package/dist/esm/{f-image-ab3dc8cb.js → f-image-57c88302.js} +1 -1
  91. package/dist/esm/{f-paginator-utils-6909e43b.js → f-paginator-utils-2c865e9a.js} +2 -2
  92. package/dist/esm/{f-text-field-4841dfea.js → f-text-field-b0a1fea6.js} +1 -1
  93. package/dist/esm/ketchup.js +2 -2
  94. package/dist/esm/kup-accordion.entry.js +6 -29
  95. package/dist/esm/{kup-autocomplete_25.entry.js → kup-autocomplete_26.entry.js} +3811 -4324
  96. package/dist/esm/kup-box.entry.js +29 -110
  97. package/dist/esm/kup-calendar.entry.js +9 -33
  98. package/dist/esm/kup-cell.entry.js +8 -27
  99. package/dist/esm/kup-dash-list.entry.js +9 -8
  100. package/dist/esm/kup-dash_2.entry.js +6 -34
  101. package/dist/esm/kup-dashboard.entry.js +8 -30
  102. package/dist/esm/kup-drawer.entry.js +3 -18
  103. package/dist/esm/kup-echart.entry.js +15 -76
  104. package/dist/esm/kup-family-tree.entry.js +11 -47
  105. package/dist/esm/kup-iframe.entry.js +4 -16
  106. package/dist/esm/kup-image-list.entry.js +14 -32
  107. package/dist/esm/kup-lazy.entry.js +9 -36
  108. package/dist/esm/kup-magic-box.entry.js +5 -24
  109. package/dist/esm/{kup-manager-c54e6df5.js → kup-manager-c0fbb180.js} +67 -2
  110. package/dist/esm/kup-nav-bar.entry.js +3 -15
  111. package/dist/esm/kup-numeric-picker.entry.js +13 -56
  112. package/dist/esm/kup-photo-frame.entry.js +8 -30
  113. package/dist/esm/kup-probe.entry.js +12 -32
  114. package/dist/esm/kup-qlik.entry.js +5 -59
  115. package/dist/esm/kup-snackbar.entry.js +6 -37
  116. package/dist/esm/loader.js +2 -2
  117. package/dist/ketchup/ketchup.esm.js +1 -1
  118. package/dist/ketchup/{p-30a63b85.entry.js → p-1914969e.entry.js} +1 -1
  119. package/dist/ketchup/{p-859163c2.entry.js → p-250118e3.entry.js} +1 -1
  120. package/dist/ketchup/{p-2e184b57.entry.js → p-30766296.entry.js} +1 -1
  121. package/dist/ketchup/{p-182b869e.entry.js → p-351cecba.entry.js} +1 -1
  122. package/dist/ketchup/{p-758d03f4.entry.js → p-35e16ea2.entry.js} +1 -1
  123. package/dist/ketchup/{p-e1d0ea71.js → p-395675b8.js} +1 -1
  124. package/dist/ketchup/p-3cf97e3a.js +1 -0
  125. package/dist/ketchup/{p-7e7b6127.entry.js → p-596bdc10.entry.js} +1 -1
  126. package/dist/ketchup/{p-4f0d3062.js → p-61ff1761.js} +1 -1
  127. package/dist/ketchup/p-72d4fa26.entry.js +1 -0
  128. package/dist/ketchup/{p-f9d5e553.entry.js → p-738685f9.entry.js} +1 -1
  129. package/dist/ketchup/{p-fb4d772a.entry.js → p-7c8c5444.entry.js} +1 -1
  130. package/dist/ketchup/p-86154e2b.js +1 -0
  131. package/dist/ketchup/{p-41620707.entry.js → p-9214ef33.entry.js} +1 -1
  132. package/dist/ketchup/{p-1f5c7f21.entry.js → p-980ed953.entry.js} +1 -1
  133. package/dist/ketchup/p-991bd70d.entry.js +1 -0
  134. package/dist/ketchup/{p-bffaef6e.entry.js → p-a1fe329f.entry.js} +1 -1
  135. package/dist/ketchup/p-a740352c.js +30 -0
  136. package/dist/ketchup/{p-25bf0cb6.js → p-a992cf87.js} +1 -1
  137. package/dist/ketchup/{p-313e376b.entry.js → p-b1da1ba7.entry.js} +2 -2
  138. package/dist/ketchup/{p-4a0ccf18.entry.js → p-cee3635a.entry.js} +1 -1
  139. package/dist/ketchup/p-d05ed931.entry.js +9 -0
  140. package/dist/ketchup/{p-8e1fa7a8.entry.js → p-d422151a.entry.js} +2 -2
  141. package/dist/ketchup/p-e6f19333.entry.js +1 -0
  142. package/dist/ketchup/p-eb10958a.entry.js +1 -0
  143. package/dist/ketchup/{p-5bea2971.js → p-ecac6269.js} +1 -1
  144. package/dist/ketchup/p-f43b445e.entry.js +1 -0
  145. package/dist/ketchup/{p-6bd57787.entry.js → p-fa37e92e.entry.js} +1 -1
  146. package/dist/types/components/kup-card/built-in/kup-card-built-in.d.ts +7 -2
  147. package/dist/types/components/kup-card/built-in/kup-card-form.d.ts +3 -0
  148. package/dist/types/components/kup-card/kup-card-declarations.d.ts +11 -1
  149. package/dist/types/components/kup-card/kup-card.d.ts +5 -0
  150. package/dist/types/components/kup-data-table/kup-data-table-declarations.d.ts +9 -0
  151. package/dist/types/components/kup-data-table/kup-data-table.d.ts +41 -202
  152. package/dist/types/components/kup-tree/kup-tree.d.ts +0 -1
  153. package/dist/types/components.d.ts +55 -2
  154. package/dist/types/managers/kup-data/kup-data-declarations.d.ts +1 -0
  155. package/dist/types/managers/kup-language/kup-language-declarations.d.ts +7 -1
  156. package/dist/types/managers/kup-theme/kup-theme-declarations.d.ts +1 -0
  157. package/dist/types/stencil-public-runtime.d.ts +5 -0
  158. package/package.json +2 -2
  159. package/dist/cjs/kup-form.cjs.entry.js +0 -486
  160. package/dist/esm/kup-form.entry.js +0 -482
  161. package/dist/ketchup/p-1dfd2a51.js +0 -30
  162. package/dist/ketchup/p-22ec1ba0.entry.js +0 -9
  163. package/dist/ketchup/p-260ff835.entry.js +0 -1
  164. package/dist/ketchup/p-53d3ae80.entry.js +0 -1
  165. package/dist/ketchup/p-60fa0ccf.entry.js +0 -1
  166. package/dist/ketchup/p-6333388c.js +0 -1
  167. package/dist/ketchup/p-8386e3db.entry.js +0 -1
  168. package/dist/ketchup/p-90860d9e.entry.js +0 -1
  169. package/dist/ketchup/p-b7fdc7aa.entry.js +0 -1
  170. package/dist/ketchup/p-c35c5e05.js +0 -1
@@ -1,486 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-ffdb46f6.js');
6
- const kupManager = require('./kup-manager-0e38bf48.js');
7
- const GenericVariables = require('./GenericVariables-a9ed17ee.js');
8
- const fCell = require('./f-cell-b7a1524a.js');
9
- const fTextFieldMdc = require('./f-text-field-mdc-85997738.js');
10
- const fButton = require('./f-button-bf76ab95.js');
11
- require('./f-checkbox-1097ca5d.js');
12
- require('./f-text-field-48b8bb16.js');
13
- require('./f-image-d80a2749.js');
14
- require('./f-chip-a5e100b1.js');
15
- require('./tslib.es6-0ee02c67.js');
16
- require('./component-72a5b626.js');
17
- require('./f-button-declarations-b611587f.js');
18
-
19
- /**
20
- * Props of the kup-form component.
21
- * Used to export every prop in an object.
22
- */
23
- var KupFormProps;
24
- (function (KupFormProps) {
25
- KupFormProps["customStyle"] = "Custom style of the component.";
26
- KupFormProps["data"] = "Actual data of the form.";
27
- KupFormProps["hiddenSubmitButton"] = "Creates a hidden submit button in order to submit the form with enter.";
28
- KupFormProps["layout"] = "How the form will arrange its content.";
29
- })(KupFormProps || (KupFormProps = {}));
30
- var KupFormLabelAlignment;
31
- (function (KupFormLabelAlignment) {
32
- KupFormLabelAlignment["CENTER"] = "center";
33
- KupFormLabelAlignment["LEFT"] = "left";
34
- KupFormLabelAlignment["RIGHT"] = "right";
35
- })(KupFormLabelAlignment || (KupFormLabelAlignment = {}));
36
- var KupFormLabelPlacement;
37
- (function (KupFormLabelPlacement) {
38
- KupFormLabelPlacement["BOTTOM"] = "bottom";
39
- KupFormLabelPlacement["LEFT"] = "left";
40
- KupFormLabelPlacement["HIDDEN"] = "hidden";
41
- KupFormLabelPlacement["PLACEHOLDER"] = "placeholder";
42
- KupFormLabelPlacement["RIGHT"] = "right";
43
- KupFormLabelPlacement["TOP"] = "top";
44
- })(KupFormLabelPlacement || (KupFormLabelPlacement = {}));
45
-
46
- const kupFormCss = ":host{--kup_form_background_color:var(\n --kup-form-background-color,\n var(--kup-background-color)\n );--kup_form_color:var(--kup-form-color, var(--kup-text-color));--kup_form_font_family:var(--kup-form-font-family, var(--kup-font-family));--kup_form_font_size:var(--kup-form-font-size, var(--kup-font-size));--kup_form_label_alignment:var(--kup-form-label-alignment);--kup_form_label_width:var(--kup-form-label-width);display:block;font-family:var(--kup_form_font_family);font-size:var(--kup_form_font_size)}.form{background:var(--kup_form_background_color);color:var(--kup_form_color);display:flex;flex-grow:1;overflow:auto;padding:1em 0;position:relative}.form--column{flex-direction:column}.form__section{display:flex;flex:1 1 1%;flex-direction:row;flex-wrap:wrap}.form__section--column{flex-direction:column;flex-wrap:unset}.form__section--column>.form__section{flex:0 0 auto}.form__section--grid{display:grid}.form__section--titled{border:1px solid var(--kup-border-color);padding-top:5px;position:relative;margin:10px}.form__section--titled>h3{background:var(--kup-background-color);font-size:calc(var(--kup-font-size) * 1.15);position:absolute;margin:0px;padding:0 8px;top:-11px;left:5px;transition:background-color 0.25s ease}.form__section--left .form__label{width:var(--kup_form_label_width, 0)}.form__section--right .form__field{min-width:200px;width:0}.form__label{-webkit-font-smoothing:antialiased;box-sizing:border-box;font-size:0.875em;letter-spacing:0.0178571429em;white-space:nowrap;width:var(--kup_form_label_width)}.form__label--center{text-align:var(--kup_form_label_alignment, center)}.form__label--left{text-align:var(--kup_form_label_alignment, left)}.form__label--right{text-align:var(--kup_form_label_alignment, right)}.form__field{min-height:16px}.form__field img{height:auto}.form__submit{height:0;opacity:0;overflow:hidden;position:absolute;width:0}.form .f-cell.c-right-aligned:not(.c-centered) .f-cell__content{justify-content:flex-start}";
47
-
48
- const dom = document.documentElement;
49
- const KupForm = class {
50
- constructor(hostRef) {
51
- index.registerInstance(this, hostRef);
52
- /*-------------------------------------------------*/
53
- /* P r o p s */
54
- /*-------------------------------------------------*/
55
- /**
56
- * Custom style of the component.
57
- * @default ""
58
- * @see https://ketchup.smeup.com/ketchup-showcase/#/customization
59
- */
60
- this.customStyle = '';
61
- /**
62
- * Actual data of the form.
63
- * @default null
64
- */
65
- this.data = null;
66
- /**
67
- * Creates a hidden submit button in order to submit the form with enter.
68
- * @default false
69
- */
70
- this.hiddenSubmitButton = false;
71
- /**
72
- * How the form will arrange its content.
73
- * @default null
74
- */
75
- this.layout = null;
76
- /*-------------------------------------------------*/
77
- /* I n t e r n a l V a r i a b l e s */
78
- /*-------------------------------------------------*/
79
- this.kupManager = kupManager.kupManagerInstance();
80
- this.visibleColumns = [];
81
- }
82
- /*-------------------------------------------------*/
83
- /* W a t c h e r s */
84
- /*-------------------------------------------------*/
85
- onDataChanged() {
86
- kupManager.identify(this.getRows());
87
- this.initVisibleColumns();
88
- this.checkLayout();
89
- }
90
- onLayoutChanged() {
91
- this.checkLayout();
92
- }
93
- /*-------------------------------------------------*/
94
- /* P u b l i c M e t h o d s */
95
- /*-------------------------------------------------*/
96
- /**
97
- * Used to retrieve component's props values.
98
- * @param {boolean} descriptions - When provided and true, the result will be the list of props with their description.
99
- * @returns {Promise<GenericObject>} List of props as object, each key will be a prop.
100
- */
101
- async getProps(descriptions) {
102
- return kupManager.getProps(this, KupFormProps, descriptions);
103
- }
104
- /**
105
- * This method is used to trigger a new render of the component.
106
- */
107
- async refresh() {
108
- index.forceUpdate(this);
109
- }
110
- /**
111
- * Sets the focus on an editable table cell.
112
- * @param {string} column - Name of the column.
113
- * @param {string} rowId - Id of the row.
114
- */
115
- async setFocus(column, rowId) {
116
- const cells = this.rootElement.shadowRoot.querySelectorAll('td[data-column="' + column + '"]');
117
- for (let index = 0; cells && index < cells.length; index++) {
118
- const cell = cells[index];
119
- if (cell['data-row'] && cell['data-row'].id == rowId) {
120
- const input = cell.querySelector('input');
121
- if (input) {
122
- input.focus();
123
- }
124
- else {
125
- const kupInput = cell.querySelector('.hydrated');
126
- if (kupInput) {
127
- try {
128
- kupInput.setFocus();
129
- }
130
- catch (error) { }
131
- }
132
- }
133
- }
134
- }
135
- }
136
- /**
137
- * Sets the props to the component.
138
- * @param {GenericObject} props - Object containing props that will be set to the component.
139
- */
140
- async setProps(props) {
141
- kupManager.setProps(this, KupFormProps, props);
142
- }
143
- /*-------------------------------------------------*/
144
- /* P r i v a t e M e t h o d s */
145
- /*-------------------------------------------------*/
146
- getColumns() {
147
- return this.data && this.data.columns
148
- ? this.data.columns
149
- : [{ title: '', name: '', size: undefined }];
150
- }
151
- initVisibleColumns() {
152
- this.visibleColumns = this.getColumns().filter((column) => {
153
- if (column.hasOwnProperty('visible')) {
154
- return column.visible;
155
- }
156
- return true;
157
- });
158
- }
159
- getRows() {
160
- return this.data && this.data.rows ? this.data.rows : [];
161
- }
162
- checkLayout() {
163
- if (this.layout) {
164
- this.formLayout = this.layout;
165
- return;
166
- }
167
- const section = {
168
- horizontal: false,
169
- sections: [],
170
- };
171
- const visibleColumns = this.visibleColumns;
172
- let size = visibleColumns.length;
173
- const content = [];
174
- let cnt = 0;
175
- while (size-- > 0) {
176
- content.push({
177
- column: visibleColumns[cnt++].name,
178
- });
179
- }
180
- section.content = content;
181
- this.formLayout = {
182
- sections: [section],
183
- };
184
- }
185
- renderRow(row) {
186
- const visibleColumns = [...this.visibleColumns];
187
- let formContent = null;
188
- let rowLayout = row.layout;
189
- if (!rowLayout) {
190
- rowLayout = this.formLayout;
191
- }
192
- let horizontal = false;
193
- if (rowLayout) {
194
- if (rowLayout.horizontal) {
195
- horizontal = true;
196
- }
197
- const sections = rowLayout.sections;
198
- let size = sections.length;
199
- let cnt = 0;
200
- if (size > 0) {
201
- formContent = [];
202
- }
203
- const parent = {
204
- horizontal: horizontal,
205
- };
206
- while (size-- > 0) {
207
- formContent.push(this.renderSection(sections[cnt++], parent, row, visibleColumns));
208
- }
209
- }
210
- const classObj = {
211
- form: true,
212
- 'form--column': !horizontal,
213
- };
214
- return (index.h("form", { class: classObj, name: this.rootElement.id }, formContent, this.hiddenSubmitButton ? (index.h(fButton.FButton, { buttonType: "submit", label: "submit", wrapperClass: "form__submit" })) : null));
215
- }
216
- renderSection(section, parent, row, visibleColumns) {
217
- var _a;
218
- let sectionContent = null;
219
- if (section.sections && section.sections.length > 0) {
220
- const sections = section.sections;
221
- let size = sections.length;
222
- let cnt = 0;
223
- if (size > 0) {
224
- sectionContent = [];
225
- }
226
- while (size-- > 0) {
227
- sectionContent.push(this.renderSection(sections[cnt++], section, row, visibleColumns));
228
- }
229
- }
230
- else if (section.content) {
231
- const content = section.content;
232
- let size = content.length;
233
- let cnt = 0;
234
- if (size > 0) {
235
- sectionContent = [];
236
- }
237
- while (size-- > 0) {
238
- const formField = this.renderFormField({
239
- formField: content[cnt++],
240
- row,
241
- visibleColumns,
242
- }, section);
243
- let field = formField;
244
- if (!section.horizontal) {
245
- field = index.h("tr", null, formField);
246
- }
247
- sectionContent.push(field);
248
- }
249
- }
250
- else if (visibleColumns.length > 0) {
251
- const column = visibleColumns[0];
252
- sectionContent = this.renderFormField({
253
- formField: { column: column.name },
254
- row,
255
- visibleColumns,
256
- });
257
- }
258
- const isGrid = !!section.columns;
259
- const labelPlacement = ((_a = section === null || section === void 0 ? void 0 : section.label) === null || _a === void 0 ? void 0 : _a.placement) || KupFormLabelPlacement.LEFT;
260
- const sectionClass = {
261
- form__section: true,
262
- 'form__section--column': !isGrid && !section.horizontal,
263
- 'form__section--grid': isGrid,
264
- 'form__section--titled': !!section.title,
265
- 'form__section--last': !section.sections || section.sections.length === 0,
266
- [`form__section--${labelPlacement}`]: true,
267
- };
268
- const sectionStyle = section.style || {};
269
- if (section.dim && parent) {
270
- sectionStyle.flex = `0 0 ${section.dim}`;
271
- if (parent.horizontal) {
272
- sectionStyle.maxWidth = section.dim;
273
- }
274
- else {
275
- sectionStyle.maxHeight = section.dim;
276
- }
277
- }
278
- if (isGrid) {
279
- sectionStyle['grid-template-columns'] = `repeat(${section.columns}, 1fr)`;
280
- }
281
- return (index.h("div", { class: sectionClass, style: sectionStyle }, section.title ? index.h("h3", null, section.title) : null, index.h("table", null, index.h("tbody", null, section.horizontal ? (index.h("tr", null, sectionContent)) : (sectionContent)))));
282
- }
283
- renderFormField({ formField, row, visibleColumns, }, section) {
284
- var _a;
285
- const classObj = {
286
- form__field: true,
287
- };
288
- const styleObj = {};
289
- let column = null;
290
- let index$1 = -1;
291
- for (let i = 0; i < visibleColumns.length; i++) {
292
- const c = visibleColumns[i];
293
- if (c.name === formField.column) {
294
- index$1 = i;
295
- break;
296
- }
297
- }
298
- if (index$1 >= 0) {
299
- column = visibleColumns[index$1];
300
- visibleColumns.splice(index$1, 1);
301
- }
302
- else if (section) {
303
- column = this.data.columns.find((x) => x.name === formField.column);
304
- }
305
- const cell = row.cells[formField.column];
306
- let title = undefined;
307
- if (cell) {
308
- cell.isEditable = true;
309
- if (!this.kupManager.objects.isEmptyKupObj(cell.obj)) {
310
- if (this.kupManager.debug.isDebug()) {
311
- title =
312
- cell.obj.t +
313
- '; ' +
314
- cell.obj.p +
315
- '; ' +
316
- cell.obj.k +
317
- ';';
318
- }
319
- }
320
- }
321
- else {
322
- return null;
323
- }
324
- const cellProps = {
325
- cell: cell,
326
- column: column,
327
- component: this,
328
- editable: true,
329
- renderKup: true,
330
- row: row,
331
- setSizes: true,
332
- shape: formField.shape,
333
- };
334
- const label = formField.label || column.title;
335
- resetLabel();
336
- switch ((_a = section.label) === null || _a === void 0 ? void 0 : _a.placement) {
337
- case KupFormLabelPlacement.BOTTOM:
338
- return [index.h("tr", null, fieldCell()), index.h("tr", null, labelCell(label))];
339
- case KupFormLabelPlacement.PLACEHOLDER:
340
- setPlaceholderLabel();
341
- case KupFormLabelPlacement.HIDDEN: {
342
- if (section) {
343
- return [fieldCell()];
344
- }
345
- else {
346
- return [index.h("tr", null, fieldCell())];
347
- }
348
- }
349
- case KupFormLabelPlacement.RIGHT: {
350
- if (section) {
351
- return [fieldCell(), labelCell(label)];
352
- }
353
- else {
354
- return [
355
- index.h("tr", null, fieldCell(), labelCell(label)),
356
- ];
357
- }
358
- }
359
- case KupFormLabelPlacement.TOP:
360
- return [index.h("tr", null, labelCell(label)), index.h("tr", null, fieldCell())];
361
- default: {
362
- if (section) {
363
- return [labelCell(label), fieldCell()];
364
- }
365
- else {
366
- return [
367
- index.h("tr", null, labelCell(label), fieldCell()),
368
- ];
369
- }
370
- }
371
- }
372
- function fieldCell() {
373
- return (index.h("td", { "data-cell": cell, "data-row": row, "data-column": formField.column, class: classObj, style: styleObj, title: title }, cell && column ? (index.h(fCell.FCell, Object.assign({}, cellProps))) : (index.h("span", null, formField.value))));
374
- }
375
- function labelCell(label) {
376
- var _a, _b, _c;
377
- const alignment = ((_a = section === null || section === void 0 ? void 0 : section.label) === null || _a === void 0 ? void 0 : _a.alignment) || KupFormLabelAlignment.LEFT;
378
- const style = {
379
- width: ((_b = section === null || section === void 0 ? void 0 : section.label) === null || _b === void 0 ? void 0 : _b.width) ? (_c = section === null || section === void 0 ? void 0 : section.label) === null || _c === void 0 ? void 0 : _c.width : '',
380
- };
381
- return (index.h("td", { class: `form__label form__label--${alignment}`, style: style }, index.h("span", null, label)));
382
- }
383
- function resetLabel() {
384
- if (!cell.data) {
385
- cell.data = {};
386
- }
387
- try {
388
- delete cell.data.label;
389
- }
390
- catch (_a) { }
391
- try {
392
- delete cell.data.data['kup-text-field'].label;
393
- }
394
- catch (_b) { }
395
- }
396
- function setPlaceholderLabel() {
397
- switch (dom.ketchup.data.cell.getType(cell, cell.shape || column.shape || null)) {
398
- case kupManager.FCellTypes.AUTOCOMPLETE:
399
- case kupManager.FCellTypes.COLOR_PICKER:
400
- case kupManager.FCellTypes.COMBOBOX:
401
- case kupManager.FCellTypes.DATE:
402
- case kupManager.FCellTypes.DATETIME:
403
- case kupManager.FCellTypes.TIME:
404
- if (cell.data.data) {
405
- if (cell.data.data['kup-text-field']) {
406
- cell.data.data['kup-text-field'].label =
407
- column.title;
408
- }
409
- else {
410
- cell.data.data = {
411
- 'kup-text-field': {
412
- label: column.title,
413
- },
414
- };
415
- }
416
- }
417
- else {
418
- cell.data.data = {
419
- 'kup-text-field': {
420
- label: column.title,
421
- },
422
- };
423
- }
424
- break;
425
- case kupManager.FCellTypes.CHECKBOX:
426
- case kupManager.FCellTypes.NUMBER:
427
- case kupManager.FCellTypes.STRING:
428
- case kupManager.FCellTypes.SWITCH:
429
- cell.data.label = column.title;
430
- }
431
- }
432
- }
433
- /*-------------------------------------------------*/
434
- /* L i f e c y c l e H o o k s */
435
- /*-------------------------------------------------*/
436
- componentWillLoad() {
437
- this.kupManager.debug.logLoad(this, false);
438
- this.kupManager.language.register(this);
439
- this.kupManager.theme.register(this);
440
- this.onDataChanged();
441
- }
442
- componentDidLoad() {
443
- this.kupManager.debug.logLoad(this, true);
444
- }
445
- componentWillRender() {
446
- this.kupManager.debug.logRender(this, false);
447
- }
448
- componentDidRender() {
449
- const root = this.rootElement.shadowRoot;
450
- if (root) {
451
- const fs = root.querySelectorAll('.f-text-field');
452
- for (let index = 0; index < fs.length; index++) {
453
- fTextFieldMdc.FTextFieldMDC(fs[index]);
454
- }
455
- }
456
- this.kupManager.debug.logRender(this, true);
457
- }
458
- render() {
459
- let formContent = null;
460
- if (this.data.rows.length === 0) {
461
- formContent = (index.h("p", null, this.kupManager.language.translate(kupManager.KupLanguageGeneric.EMPTY_DATA)));
462
- }
463
- else {
464
- const rows = this.data.rows;
465
- let size = rows.length;
466
- let cnt = 0;
467
- formContent = [];
468
- while (size-- > 0) {
469
- formContent.push(this.renderRow(rows[cnt++]));
470
- }
471
- }
472
- return (index.h(index.Host, null, index.h("style", null, this.kupManager.theme.setKupStyle(this.rootElement)), index.h("div", { id: GenericVariables.componentWrapperId }, formContent)));
473
- }
474
- disconnectedCallback() {
475
- this.kupManager.language.unregister(this);
476
- this.kupManager.theme.unregister(this);
477
- }
478
- get rootElement() { return index.getElement(this); }
479
- static get watchers() { return {
480
- "data": ["onDataChanged"],
481
- "layout": ["onLayoutChanged"]
482
- }; }
483
- };
484
- KupForm.style = kupFormCss;
485
-
486
- exports.kup_form = KupForm;