@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,482 +0,0 @@
1
- import { r as registerInstance, f as forceUpdate, h, H as Host, g as getElement } from './index-a2197376.js';
2
- import { k as kupManagerInstance, z as identify, g as getProps, s as setProps, am as FCellTypes, l as KupLanguageGeneric } from './kup-manager-c54e6df5.js';
3
- import { c as componentWrapperId } from './GenericVariables-665de00a.js';
4
- import { F as FCell } from './f-cell-9400374e.js';
5
- import { F as FTextFieldMDC } from './f-text-field-mdc-d42d3f9e.js';
6
- import { F as FButton } from './f-button-e79f7594.js';
7
- import './f-checkbox-b721178e.js';
8
- import './f-text-field-4841dfea.js';
9
- import './f-image-ab3dc8cb.js';
10
- import './f-chip-bf740287.js';
11
- import './tslib.es6-3eea2234.js';
12
- import './component-b1bedf1d.js';
13
- import './f-button-declarations-b1b4cac4.js';
14
-
15
- /**
16
- * Props of the kup-form component.
17
- * Used to export every prop in an object.
18
- */
19
- var KupFormProps;
20
- (function (KupFormProps) {
21
- KupFormProps["customStyle"] = "Custom style of the component.";
22
- KupFormProps["data"] = "Actual data of the form.";
23
- KupFormProps["hiddenSubmitButton"] = "Creates a hidden submit button in order to submit the form with enter.";
24
- KupFormProps["layout"] = "How the form will arrange its content.";
25
- })(KupFormProps || (KupFormProps = {}));
26
- var KupFormLabelAlignment;
27
- (function (KupFormLabelAlignment) {
28
- KupFormLabelAlignment["CENTER"] = "center";
29
- KupFormLabelAlignment["LEFT"] = "left";
30
- KupFormLabelAlignment["RIGHT"] = "right";
31
- })(KupFormLabelAlignment || (KupFormLabelAlignment = {}));
32
- var KupFormLabelPlacement;
33
- (function (KupFormLabelPlacement) {
34
- KupFormLabelPlacement["BOTTOM"] = "bottom";
35
- KupFormLabelPlacement["LEFT"] = "left";
36
- KupFormLabelPlacement["HIDDEN"] = "hidden";
37
- KupFormLabelPlacement["PLACEHOLDER"] = "placeholder";
38
- KupFormLabelPlacement["RIGHT"] = "right";
39
- KupFormLabelPlacement["TOP"] = "top";
40
- })(KupFormLabelPlacement || (KupFormLabelPlacement = {}));
41
-
42
- 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}";
43
-
44
- const dom = document.documentElement;
45
- const KupForm = class {
46
- constructor(hostRef) {
47
- registerInstance(this, hostRef);
48
- /*-------------------------------------------------*/
49
- /* P r o p s */
50
- /*-------------------------------------------------*/
51
- /**
52
- * Custom style of the component.
53
- * @default ""
54
- * @see https://ketchup.smeup.com/ketchup-showcase/#/customization
55
- */
56
- this.customStyle = '';
57
- /**
58
- * Actual data of the form.
59
- * @default null
60
- */
61
- this.data = null;
62
- /**
63
- * Creates a hidden submit button in order to submit the form with enter.
64
- * @default false
65
- */
66
- this.hiddenSubmitButton = false;
67
- /**
68
- * How the form will arrange its content.
69
- * @default null
70
- */
71
- this.layout = null;
72
- /*-------------------------------------------------*/
73
- /* I n t e r n a l V a r i a b l e s */
74
- /*-------------------------------------------------*/
75
- this.kupManager = kupManagerInstance();
76
- this.visibleColumns = [];
77
- }
78
- /*-------------------------------------------------*/
79
- /* W a t c h e r s */
80
- /*-------------------------------------------------*/
81
- onDataChanged() {
82
- identify(this.getRows());
83
- this.initVisibleColumns();
84
- this.checkLayout();
85
- }
86
- onLayoutChanged() {
87
- this.checkLayout();
88
- }
89
- /*-------------------------------------------------*/
90
- /* P u b l i c M e t h o d s */
91
- /*-------------------------------------------------*/
92
- /**
93
- * Used to retrieve component's props values.
94
- * @param {boolean} descriptions - When provided and true, the result will be the list of props with their description.
95
- * @returns {Promise<GenericObject>} List of props as object, each key will be a prop.
96
- */
97
- async getProps(descriptions) {
98
- return getProps(this, KupFormProps, descriptions);
99
- }
100
- /**
101
- * This method is used to trigger a new render of the component.
102
- */
103
- async refresh() {
104
- forceUpdate(this);
105
- }
106
- /**
107
- * Sets the focus on an editable table cell.
108
- * @param {string} column - Name of the column.
109
- * @param {string} rowId - Id of the row.
110
- */
111
- async setFocus(column, rowId) {
112
- const cells = this.rootElement.shadowRoot.querySelectorAll('td[data-column="' + column + '"]');
113
- for (let index = 0; cells && index < cells.length; index++) {
114
- const cell = cells[index];
115
- if (cell['data-row'] && cell['data-row'].id == rowId) {
116
- const input = cell.querySelector('input');
117
- if (input) {
118
- input.focus();
119
- }
120
- else {
121
- const kupInput = cell.querySelector('.hydrated');
122
- if (kupInput) {
123
- try {
124
- kupInput.setFocus();
125
- }
126
- catch (error) { }
127
- }
128
- }
129
- }
130
- }
131
- }
132
- /**
133
- * Sets the props to the component.
134
- * @param {GenericObject} props - Object containing props that will be set to the component.
135
- */
136
- async setProps(props) {
137
- setProps(this, KupFormProps, props);
138
- }
139
- /*-------------------------------------------------*/
140
- /* P r i v a t e M e t h o d s */
141
- /*-------------------------------------------------*/
142
- getColumns() {
143
- return this.data && this.data.columns
144
- ? this.data.columns
145
- : [{ title: '', name: '', size: undefined }];
146
- }
147
- initVisibleColumns() {
148
- this.visibleColumns = this.getColumns().filter((column) => {
149
- if (column.hasOwnProperty('visible')) {
150
- return column.visible;
151
- }
152
- return true;
153
- });
154
- }
155
- getRows() {
156
- return this.data && this.data.rows ? this.data.rows : [];
157
- }
158
- checkLayout() {
159
- if (this.layout) {
160
- this.formLayout = this.layout;
161
- return;
162
- }
163
- const section = {
164
- horizontal: false,
165
- sections: [],
166
- };
167
- const visibleColumns = this.visibleColumns;
168
- let size = visibleColumns.length;
169
- const content = [];
170
- let cnt = 0;
171
- while (size-- > 0) {
172
- content.push({
173
- column: visibleColumns[cnt++].name,
174
- });
175
- }
176
- section.content = content;
177
- this.formLayout = {
178
- sections: [section],
179
- };
180
- }
181
- renderRow(row) {
182
- const visibleColumns = [...this.visibleColumns];
183
- let formContent = null;
184
- let rowLayout = row.layout;
185
- if (!rowLayout) {
186
- rowLayout = this.formLayout;
187
- }
188
- let horizontal = false;
189
- if (rowLayout) {
190
- if (rowLayout.horizontal) {
191
- horizontal = true;
192
- }
193
- const sections = rowLayout.sections;
194
- let size = sections.length;
195
- let cnt = 0;
196
- if (size > 0) {
197
- formContent = [];
198
- }
199
- const parent = {
200
- horizontal: horizontal,
201
- };
202
- while (size-- > 0) {
203
- formContent.push(this.renderSection(sections[cnt++], parent, row, visibleColumns));
204
- }
205
- }
206
- const classObj = {
207
- form: true,
208
- 'form--column': !horizontal,
209
- };
210
- return (h("form", { class: classObj, name: this.rootElement.id }, formContent, this.hiddenSubmitButton ? (h(FButton, { buttonType: "submit", label: "submit", wrapperClass: "form__submit" })) : null));
211
- }
212
- renderSection(section, parent, row, visibleColumns) {
213
- var _a;
214
- let sectionContent = null;
215
- if (section.sections && section.sections.length > 0) {
216
- const sections = section.sections;
217
- let size = sections.length;
218
- let cnt = 0;
219
- if (size > 0) {
220
- sectionContent = [];
221
- }
222
- while (size-- > 0) {
223
- sectionContent.push(this.renderSection(sections[cnt++], section, row, visibleColumns));
224
- }
225
- }
226
- else if (section.content) {
227
- const content = section.content;
228
- let size = content.length;
229
- let cnt = 0;
230
- if (size > 0) {
231
- sectionContent = [];
232
- }
233
- while (size-- > 0) {
234
- const formField = this.renderFormField({
235
- formField: content[cnt++],
236
- row,
237
- visibleColumns,
238
- }, section);
239
- let field = formField;
240
- if (!section.horizontal) {
241
- field = h("tr", null, formField);
242
- }
243
- sectionContent.push(field);
244
- }
245
- }
246
- else if (visibleColumns.length > 0) {
247
- const column = visibleColumns[0];
248
- sectionContent = this.renderFormField({
249
- formField: { column: column.name },
250
- row,
251
- visibleColumns,
252
- });
253
- }
254
- const isGrid = !!section.columns;
255
- const labelPlacement = ((_a = section === null || section === void 0 ? void 0 : section.label) === null || _a === void 0 ? void 0 : _a.placement) || KupFormLabelPlacement.LEFT;
256
- const sectionClass = {
257
- form__section: true,
258
- 'form__section--column': !isGrid && !section.horizontal,
259
- 'form__section--grid': isGrid,
260
- 'form__section--titled': !!section.title,
261
- 'form__section--last': !section.sections || section.sections.length === 0,
262
- [`form__section--${labelPlacement}`]: true,
263
- };
264
- const sectionStyle = section.style || {};
265
- if (section.dim && parent) {
266
- sectionStyle.flex = `0 0 ${section.dim}`;
267
- if (parent.horizontal) {
268
- sectionStyle.maxWidth = section.dim;
269
- }
270
- else {
271
- sectionStyle.maxHeight = section.dim;
272
- }
273
- }
274
- if (isGrid) {
275
- sectionStyle['grid-template-columns'] = `repeat(${section.columns}, 1fr)`;
276
- }
277
- return (h("div", { class: sectionClass, style: sectionStyle }, section.title ? h("h3", null, section.title) : null, h("table", null, h("tbody", null, section.horizontal ? (h("tr", null, sectionContent)) : (sectionContent)))));
278
- }
279
- renderFormField({ formField, row, visibleColumns, }, section) {
280
- var _a;
281
- const classObj = {
282
- form__field: true,
283
- };
284
- const styleObj = {};
285
- let column = null;
286
- let index = -1;
287
- for (let i = 0; i < visibleColumns.length; i++) {
288
- const c = visibleColumns[i];
289
- if (c.name === formField.column) {
290
- index = i;
291
- break;
292
- }
293
- }
294
- if (index >= 0) {
295
- column = visibleColumns[index];
296
- visibleColumns.splice(index, 1);
297
- }
298
- else if (section) {
299
- column = this.data.columns.find((x) => x.name === formField.column);
300
- }
301
- const cell = row.cells[formField.column];
302
- let title = undefined;
303
- if (cell) {
304
- cell.isEditable = true;
305
- if (!this.kupManager.objects.isEmptyKupObj(cell.obj)) {
306
- if (this.kupManager.debug.isDebug()) {
307
- title =
308
- cell.obj.t +
309
- '; ' +
310
- cell.obj.p +
311
- '; ' +
312
- cell.obj.k +
313
- ';';
314
- }
315
- }
316
- }
317
- else {
318
- return null;
319
- }
320
- const cellProps = {
321
- cell: cell,
322
- column: column,
323
- component: this,
324
- editable: true,
325
- renderKup: true,
326
- row: row,
327
- setSizes: true,
328
- shape: formField.shape,
329
- };
330
- const label = formField.label || column.title;
331
- resetLabel();
332
- switch ((_a = section.label) === null || _a === void 0 ? void 0 : _a.placement) {
333
- case KupFormLabelPlacement.BOTTOM:
334
- return [h("tr", null, fieldCell()), h("tr", null, labelCell(label))];
335
- case KupFormLabelPlacement.PLACEHOLDER:
336
- setPlaceholderLabel();
337
- case KupFormLabelPlacement.HIDDEN: {
338
- if (section) {
339
- return [fieldCell()];
340
- }
341
- else {
342
- return [h("tr", null, fieldCell())];
343
- }
344
- }
345
- case KupFormLabelPlacement.RIGHT: {
346
- if (section) {
347
- return [fieldCell(), labelCell(label)];
348
- }
349
- else {
350
- return [
351
- h("tr", null, fieldCell(), labelCell(label)),
352
- ];
353
- }
354
- }
355
- case KupFormLabelPlacement.TOP:
356
- return [h("tr", null, labelCell(label)), h("tr", null, fieldCell())];
357
- default: {
358
- if (section) {
359
- return [labelCell(label), fieldCell()];
360
- }
361
- else {
362
- return [
363
- h("tr", null, labelCell(label), fieldCell()),
364
- ];
365
- }
366
- }
367
- }
368
- function fieldCell() {
369
- return (h("td", { "data-cell": cell, "data-row": row, "data-column": formField.column, class: classObj, style: styleObj, title: title }, cell && column ? (h(FCell, Object.assign({}, cellProps))) : (h("span", null, formField.value))));
370
- }
371
- function labelCell(label) {
372
- var _a, _b, _c;
373
- const alignment = ((_a = section === null || section === void 0 ? void 0 : section.label) === null || _a === void 0 ? void 0 : _a.alignment) || KupFormLabelAlignment.LEFT;
374
- const style = {
375
- 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 : '',
376
- };
377
- return (h("td", { class: `form__label form__label--${alignment}`, style: style }, h("span", null, label)));
378
- }
379
- function resetLabel() {
380
- if (!cell.data) {
381
- cell.data = {};
382
- }
383
- try {
384
- delete cell.data.label;
385
- }
386
- catch (_a) { }
387
- try {
388
- delete cell.data.data['kup-text-field'].label;
389
- }
390
- catch (_b) { }
391
- }
392
- function setPlaceholderLabel() {
393
- switch (dom.ketchup.data.cell.getType(cell, cell.shape || column.shape || null)) {
394
- case FCellTypes.AUTOCOMPLETE:
395
- case FCellTypes.COLOR_PICKER:
396
- case FCellTypes.COMBOBOX:
397
- case FCellTypes.DATE:
398
- case FCellTypes.DATETIME:
399
- case FCellTypes.TIME:
400
- if (cell.data.data) {
401
- if (cell.data.data['kup-text-field']) {
402
- cell.data.data['kup-text-field'].label =
403
- column.title;
404
- }
405
- else {
406
- cell.data.data = {
407
- 'kup-text-field': {
408
- label: column.title,
409
- },
410
- };
411
- }
412
- }
413
- else {
414
- cell.data.data = {
415
- 'kup-text-field': {
416
- label: column.title,
417
- },
418
- };
419
- }
420
- break;
421
- case FCellTypes.CHECKBOX:
422
- case FCellTypes.NUMBER:
423
- case FCellTypes.STRING:
424
- case FCellTypes.SWITCH:
425
- cell.data.label = column.title;
426
- }
427
- }
428
- }
429
- /*-------------------------------------------------*/
430
- /* L i f e c y c l e H o o k s */
431
- /*-------------------------------------------------*/
432
- componentWillLoad() {
433
- this.kupManager.debug.logLoad(this, false);
434
- this.kupManager.language.register(this);
435
- this.kupManager.theme.register(this);
436
- this.onDataChanged();
437
- }
438
- componentDidLoad() {
439
- this.kupManager.debug.logLoad(this, true);
440
- }
441
- componentWillRender() {
442
- this.kupManager.debug.logRender(this, false);
443
- }
444
- componentDidRender() {
445
- const root = this.rootElement.shadowRoot;
446
- if (root) {
447
- const fs = root.querySelectorAll('.f-text-field');
448
- for (let index = 0; index < fs.length; index++) {
449
- FTextFieldMDC(fs[index]);
450
- }
451
- }
452
- this.kupManager.debug.logRender(this, true);
453
- }
454
- render() {
455
- let formContent = null;
456
- if (this.data.rows.length === 0) {
457
- formContent = (h("p", null, this.kupManager.language.translate(KupLanguageGeneric.EMPTY_DATA)));
458
- }
459
- else {
460
- const rows = this.data.rows;
461
- let size = rows.length;
462
- let cnt = 0;
463
- formContent = [];
464
- while (size-- > 0) {
465
- formContent.push(this.renderRow(rows[cnt++]));
466
- }
467
- }
468
- return (h(Host, null, h("style", null, this.kupManager.theme.setKupStyle(this.rootElement)), h("div", { id: componentWrapperId }, formContent)));
469
- }
470
- disconnectedCallback() {
471
- this.kupManager.language.unregister(this);
472
- this.kupManager.theme.unregister(this);
473
- }
474
- get rootElement() { return getElement(this); }
475
- static get watchers() { return {
476
- "data": ["onDataChanged"],
477
- "layout": ["onLayoutChanged"]
478
- }; }
479
- };
480
- KupForm.style = kupFormCss;
481
-
482
- export { KupForm as kup_form };