@3t-transform/threeteeui 0.0.21 → 0.0.23

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 (101) hide show
  1. package/dist/cjs/{index-bf777121.js → index-2943e8f8.js} +1 -122
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/tttx-button.cjs.entry.js +1 -1
  4. package/dist/cjs/tttx-icon.cjs.entry.js +1 -1
  5. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +8 -5
  6. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +1 -1
  7. package/dist/cjs/tttx-standalone-input.cjs.entry.js +6 -4
  8. package/dist/cjs/tttx.cjs.js +2 -2
  9. package/dist/collection/collection-manifest.json +1 -7
  10. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +7 -4
  11. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +28 -9
  12. package/dist/components/index.d.ts +0 -6
  13. package/dist/components/index.js +0 -6
  14. package/dist/components/tttx-button.js +54 -1
  15. package/dist/components/tttx-keyvalue-block.js +7 -4
  16. package/dist/components/tttx-loading-spinner.js +38 -1
  17. package/dist/components/tttx-standalone-input.js +8 -5
  18. package/dist/esm/{index-a05bd606.js → index-058a3cd0.js} +2 -122
  19. package/dist/esm/loader.js +3 -3
  20. package/dist/esm/tttx-button.entry.js +1 -1
  21. package/dist/esm/tttx-icon.entry.js +1 -1
  22. package/dist/esm/tttx-keyvalue-block.entry.js +8 -5
  23. package/dist/esm/tttx-loading-spinner.entry.js +1 -1
  24. package/dist/esm/tttx-standalone-input.entry.js +6 -4
  25. package/dist/esm/tttx.js +3 -3
  26. package/dist/tttx/{p-68ff0f39.entry.js → p-046868d9.entry.js} +1 -1
  27. package/dist/tttx/{p-93763d3c.entry.js → p-1adb2b75.entry.js} +1 -1
  28. package/dist/tttx/{p-a5808741.entry.js → p-495cf4b3.entry.js} +1 -1
  29. package/dist/tttx/p-a4d9929a.entry.js +1 -0
  30. package/dist/tttx/p-ad637dde.entry.js +1 -0
  31. package/dist/tttx/p-bbb7dbf7.js +2 -0
  32. package/dist/tttx/tttx.esm.js +1 -1
  33. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +3 -2
  34. package/dist/types/components.d.ts +6 -140
  35. package/package.json +2 -2
  36. package/dist/cjs/tttx-checkbox.cjs.entry.js +0 -28
  37. package/dist/cjs/tttx-form.cjs.entry.js +0 -374
  38. package/dist/cjs/tttx-input-calendar.cjs.entry.js +0 -125
  39. package/dist/cjs/tttx-list.cjs.entry.js +0 -198
  40. package/dist/cjs/tttx-popover-content.cjs.entry.js +0 -23
  41. package/dist/cjs/tttx-table.cjs.entry.js +0 -60
  42. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.css +0 -30
  43. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.js +0 -97
  44. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.stories.js +0 -23
  45. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.css +0 -181
  46. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.js +0 -102
  47. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.stories.js +0 -13
  48. package/dist/collection/components/molecules/tttx-form/tttx-form.css +0 -314
  49. package/dist/collection/components/molecules/tttx-form/tttx-form.js +0 -452
  50. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +0 -109
  51. package/dist/collection/components/molecules/tttx-input-calendar/tttx-input-calendar.css +0 -93
  52. package/dist/collection/components/molecules/tttx-input-calendar/tttx-input-calendar.js +0 -174
  53. package/dist/collection/components/molecules/tttx-input-calendar/tttx-input-calendar.stories.js +0 -27
  54. package/dist/collection/components/molecules/tttx-list/tttx-list.css +0 -56
  55. package/dist/collection/components/molecules/tttx-list/tttx-list.js +0 -312
  56. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +0 -37
  57. package/dist/collection/components/molecules/tttx-table/tttx-table.css +0 -166
  58. package/dist/collection/components/molecules/tttx-table/tttx-table.js +0 -174
  59. package/dist/collection/components/molecules/tttx-table/tttx-table.stories.js +0 -81
  60. package/dist/components/tttx-button2.js +0 -56
  61. package/dist/components/tttx-checkbox.d.ts +0 -11
  62. package/dist/components/tttx-checkbox.js +0 -46
  63. package/dist/components/tttx-form.d.ts +0 -11
  64. package/dist/components/tttx-form.js +0 -391
  65. package/dist/components/tttx-input-calendar.d.ts +0 -11
  66. package/dist/components/tttx-input-calendar.js +0 -157
  67. package/dist/components/tttx-list.d.ts +0 -11
  68. package/dist/components/tttx-list.js +0 -225
  69. package/dist/components/tttx-loading-spinner2.js +0 -40
  70. package/dist/components/tttx-popover-content.d.ts +0 -11
  71. package/dist/components/tttx-popover-content.js +0 -6
  72. package/dist/components/tttx-popover-content2.js +0 -39
  73. package/dist/components/tttx-table.d.ts +0 -11
  74. package/dist/components/tttx-table.js +0 -91
  75. package/dist/esm/tttx-checkbox.entry.js +0 -24
  76. package/dist/esm/tttx-form.entry.js +0 -370
  77. package/dist/esm/tttx-input-calendar.entry.js +0 -121
  78. package/dist/esm/tttx-list.entry.js +0 -194
  79. package/dist/esm/tttx-popover-content.entry.js +0 -19
  80. package/dist/esm/tttx-table.entry.js +0 -56
  81. package/dist/tttx/p-037d286f.entry.js +0 -1
  82. package/dist/tttx/p-07b134af.js +0 -2
  83. package/dist/tttx/p-1b63f16a.entry.js +0 -1
  84. package/dist/tttx/p-45afb84c.entry.js +0 -1
  85. package/dist/tttx/p-74061060.entry.js +0 -1
  86. package/dist/tttx/p-9536b8c4.entry.js +0 -1
  87. package/dist/tttx/p-a92ca87e.entry.js +0 -1
  88. package/dist/tttx/p-a96ca037.entry.js +0 -1
  89. package/dist/tttx/p-f579ed1e.entry.js +0 -1
  90. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.d.ts +0 -7
  91. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.stories.d.ts +0 -18
  92. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +0 -9
  93. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts +0 -6
  94. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +0 -134
  95. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +0 -12
  96. package/dist/types/components/molecules/tttx-input-calendar/tttx-input-calendar.d.ts +0 -19
  97. package/dist/types/components/molecules/tttx-input-calendar/tttx-input-calendar.stories.d.ts +0 -26
  98. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +0 -51
  99. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +0 -13
  100. package/dist/types/components/molecules/tttx-table/tttx-table.d.ts +0 -15
  101. package/dist/types/components/molecules/tttx-table/tttx-table.stories.d.ts +0 -21
@@ -1,374 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-bf777121.js');
6
-
7
- const tttxFormCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.material-symbols-rounded{font-family:\"Material Symbols Rounded\", sans-serif;font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;color:#9e9e9e}.icon-left,.icon-right{flex-basis:24px}.icon-left span,.icon-right span{font-size:24px;line-height:24px;text-align:center;display:block;width:24px;height:24px;margin-top:4px}.icon-left span{margin-left:4px}.icon-right span{margin-right:4px}.icon-right{margin-top:5px;margin-right:4px}.icon-left{margin-top:5px;margin-left:4px}.iconleft .input{padding-left:4px}.iconright .input{padding-right:4px}.focused{border-color:#1479c6}.errormsg{display:flex;justify-content:center;align-items:center;float:left;margin-bottom:16px;box-sizing:border-box;background-color:transparent;height:26px;font-size:14px;border-radius:none;z-index:2;color:#dc0000}.errormsg .validationicon{width:16px;height:16px;font-size:16px;margin-right:4px;vertical-align:middle;color:#dc0000}.danger{color:#dc0000}.optional{color:#757575;font-weight:normal}label.inputBlock{display:block;position:relative;line-height:21px}label{font-weight:500;font-size:16px}input:not([type=submit]){font-family:\"Roboto\", serif;box-sizing:border-box;width:100%;height:36px;padding:0 16px;font-size:16px;border:1px solid #d5d5d5;border-radius:4px;margin-top:4px}input[type=date]{background:white;display:block;min-width:calc(100% - 18px);line-height:37px}input.invalid:invalid,input.standalone.invalid{border:1px solid #dc0000}input~.errorBubble{min-height:27px;position:relative;font-size:14px;font-weight:normal;width:100%;font-family:\"Roboto\", sans-serif;color:#dc0000;display:flex;align-content:center;align-items:center;justify-items:center}input~.errorBubble:not(.visible){visibility:hidden}input~.errorBubble span{color:#dc0000;font-size:16px;margin-right:4px;height:16px}input.invalid:invalid~.errorBubble{position:relative;font-size:14px;font-weight:normal;width:100%;font-family:\"Roboto\", sans-serif;color:#dc0000;visibility:visible}input:focus{border-color:#1479c6}.button{font-family:Roboto, serif;box-sizing:border-box;height:36px;min-width:36px;padding:0;margin:0;background:transparent;color:#212121;border:1px solid #c8c8c8;border-radius:4px;text-transform:uppercase;display:flex;justify-content:left;align-items:center;font-size:14px;font-weight:400}.button-content{display:block;padding:0 16px}.icon-left,.icon-right{margin-top:4px}.iconleft{padding-left:8px}.iconleft .button-content{padding-left:4px}.iconright{padding-right:8px}.iconright .button-content{padding-right:4px}.notext{padding:0 6px}.button:hover{background:rgba(17, 17, 17, 0.1);border:1px solid #D5D5D5}.button:active{background:rgba(17, 17, 17, 0.2);border:1px solid #D5D5D5}.primary{background:#1479c6;border:1px solid #1479c6;color:white}.primary:hover{background:#146EB3;border:1px solid #146EB3}.primary:active{background:#1464A2;border:1px solid #1464A2}.borderless{background:transparent;border:none;color:#212121}.borderless:hover{background:rgba(17, 17, 17, 0.1);border:none}.borderless:active{background:rgba(17, 17, 17, 0.2);border:none}.danger{background:#DC0000;border:1px solid #DC0000;color:white}.danger:hover{background:#C60000;border:1px solid #C60000}.danger:active{background:#B00000;border:1px solid #B00000}.disabled{background:#aeaeae;border:none;color:#4c4c4c;cursor:not-allowed}.disabled:hover{background:#aeaeae;border:none;color:#4c4c4c;cursor:not-allowed}.disabled:active{background:#aeaeae;border:none;color:#4c4c4c;cursor:not-allowed}:host{display:block}fieldset{margin:0;padding:0;border:none}input[type=submit]{margin-left:auto}";
8
-
9
- const TttxForm = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.dataSubmitted = index.createEvent(this, "dataSubmitted", 7);
13
- this.dataChanged = index.createEvent(this, "dataChanged", 7);
14
- // Create a new template element using the HTMLTemplateElement interface.
15
- this.template = document.createElement('template');
16
- this.formschema = undefined;
17
- this.submitValue = undefined;
18
- }
19
- // This method is called whenever the "formschema" property changes
20
- onFormSchemaChange(newValue) {
21
- // Check if the new value is a string, indicating that it needs to be parsed
22
- if (typeof newValue === 'string') {
23
- // Parse the string and set the "_formSchema" property
24
- this._formSchema = JSON.parse(newValue);
25
- }
26
- else {
27
- // If the new value is already an object, set the "_formSchema" property directly
28
- this._formSchema = newValue;
29
- }
30
- }
31
- /**
32
- * Handles the focus event for a form field and emits a "dataChanged" event
33
- * to the parent component with the field name and its new value.
34
- *
35
- * @param {FocusEvent} event - The focus event triggered by the field.
36
- * @return {void}
37
- */
38
- fieldChanged(event) {
39
- // Extract the name and value of the field from the event
40
- const fieldName = event.target.name;
41
- const fieldValue = event.target.value;
42
- // Emit an event to signal that the field's data has changed
43
- this.dataChanged.emit({ name: fieldName, value: fieldValue });
44
- }
45
- /**
46
- * Validates the input field on focusout event by checking its validity state,
47
- * sets an error message if there's an issue, and emits a "dataChanged" event to
48
- * the parent component with the field name and its new value.
49
- *
50
- * @param {FocusEvent} event - The focusout event triggered by the input field.
51
- * @return {void}
52
- */
53
- validityCheck(event) {
54
- var _a, _b, _c, _d;
55
- event.preventDefault();
56
- const target = event.target;
57
- let hasError = true;
58
- let errorMessage = '';
59
- // validity object on HTML5 inputs has the following options
60
- // badInput
61
- // customError
62
- // patternMismatch
63
- // rangeOverflow
64
- // rangeUnderflow
65
- // stepMismatch
66
- // tooLong
67
- // tooShort
68
- // typeMismatch
69
- // valid
70
- // valueMissing
71
- // customErrors can be set with
72
- // target.setCustomValidity('custom error!');
73
- // and cleared with
74
- // target.setCustomValidity('');
75
- // Check the validity of the input field and set an error message if needed
76
- switch (true) {
77
- // The field is required, but has no value
78
- case target.validity.valueMissing:
79
- errorMessage = (_a = target.dataset.required) !== null && _a !== void 0 ? _a : 'This field is required';
80
- break;
81
- // The field's value does not match the expected pattern
82
- case target.validity.patternMismatch:
83
- errorMessage = (_b = target.dataset.pattern) !== null && _b !== void 0 ? _b : 'Incorrect format';
84
- break;
85
- // The field's value is not of the correct input type
86
- case target.validity.badInput:
87
- // IE string in a number field
88
- errorMessage = (_c = target.dataset.badinput) !== null && _c !== void 0 ? _c : 'Wrong input type';
89
- break;
90
- // The field's value is above or below the range set in the "min" and "max" attributes
91
- case target.validity.rangeOverflow || target.validity.rangeUnderflow:
92
- // IE date or number is above or below value set in min or max tags
93
- errorMessage = (_d = target.dataset.range) !== null && _d !== void 0 ? _d : 'Invalid value';
94
- break;
95
- // No error detected
96
- default:
97
- hasError = false;
98
- }
99
- // Set the error state of the input field based on the error message and whether an error was detected
100
- this.setErrorState(target, hasError, errorMessage);
101
- }
102
- /**
103
- * Sets the error state of an input field by updating its class and error message.
104
- * If an error was detected, it sets the input field's class to "invalid" and
105
- * displays the error message in an error bubble. If no error was detected,
106
- * it removes the "invalid" class from the input field and clears the error bubble.
107
- *
108
- * @param {HTMLInputElement} target - The input field to update.
109
- * @param {boolean} hasError - Whether an error was detected in the field.
110
- * @param {string} errorMessage - The error message to display (if any).
111
- * @return {void}
112
- */
113
- setErrorState(target, hasError, errorMessage) {
114
- // Find the error bubble element for the input field
115
- const errorBubble = target.parentElement.querySelector('.errorBubble');
116
- // If an error was detected, set the input field's class to "invalid" and display the error message in the error bubble
117
- if (hasError) {
118
- target.className = 'invalid';
119
- const errorIcon = this.createErrorIcon();
120
- errorBubble.replaceChildren(errorIcon, errorMessage);
121
- }
122
- // If no error was detected, remove the "invalid" class from the input field and clear the error bubble
123
- else {
124
- target.className = '';
125
- errorBubble.replaceChildren();
126
- }
127
- }
128
- // Create an error icon element to display in the error bubble of an input field
129
- createErrorIcon() {
130
- // Create a new <span> element to serve as the error icon
131
- const errorIcon = document.createElement('span');
132
- // Set the class of the error icon to a pre-defined CSS class that specifies the icon's appearance
133
- errorIcon.className = 'material-symbols-rounded';
134
- // Set the text content of the error icon to the word "warning"
135
- errorIcon.textContent = 'warning';
136
- // Return the error icon element
137
- return errorIcon;
138
- }
139
- /**
140
- * Submits the form data to the server.
141
- *
142
- * @param {SubmitEvent} event - The event object for the form submission.
143
- * @returns {void}
144
- *
145
- * @example
146
- * const form = document.getElementById('myForm');
147
- * form.addEventListener('submit', (event) => {
148
- * doSubmit(event);
149
- * });
150
- */
151
- doSubmit(event) {
152
- // prevent the form from submitting normally
153
- event.preventDefault();
154
- // create a new FormData object with the form data
155
- const formData = new FormData(event.target);
156
- // emit the form data through the `dataSubmitted` event
157
- this.dataSubmitted.emit(formData);
158
- }
159
- // This method is called before the component is loaded into the DOM
160
- componentWillLoad() {
161
- // Initialize the form schema by calling the "onFormSchemaChange" method with the current "formschema" property
162
- this.onFormSchemaChange(this.formschema);
163
- }
164
- // This method is called before the component is rendered
165
- componentWillRender() {
166
- // Clear the template to account for a potential re-render scenario
167
- this.template = document.createElement('template');
168
- // Populate the form from the form schema
169
- this.populateFormFromSchema();
170
- }
171
- /**
172
- * Creates a new HTMLInputElement with the specified name, type, and placeholder (if any),
173
- * and sets its autocomplete and autocapitalization properties to off.
174
- *
175
- * @param {string} formKey - The name of the input field, as specified in the form schema.
176
- * @param {Object} formProperties - An object containing additional properties for the input field, such as its type and placeholder value.
177
- * @param {string} formProperties.type - The type of the input field (e.g., "text", "email", "number", etc.).
178
- * @param {string} [formProperties.placeholder] - An optional placeholder value to display in the input field.
179
- * @return {HTMLInputElement} - The new input element.
180
- */
181
- createInput(formKey, formProperties) {
182
- var _a;
183
- // Create a new <input> element with the specified name and type
184
- const input = document.createElement('input');
185
- input.name = formKey;
186
- input.type = formProperties.type;
187
- // Set the placeholder attribute to the specified value (if any)
188
- input.placeholder = (_a = formProperties.placeholder) !== null && _a !== void 0 ? _a : '';
189
- // Disable autocomplete and autocapitalization
190
- input.autocomplete = 'off';
191
- input.autocapitalize = 'off';
192
- // Return the input element
193
- return input;
194
- }
195
- /**
196
- * Applies validation attributes to an input element based on the specified validation object.
197
- * If a certain property is present in the object, it will set the corresponding attribute on
198
- * the input element (e.g., "required" will set the "required" and "data-required" attributes,
199
- * "pattern" will set the "pattern" and "data-pattern" attributes, etc.).
200
- *
201
- * @param {HTMLInputElement} input - The input element to apply validation attributes to.
202
- * @param {Object} validation - An object containing the validation rules for the input field.
203
- * @param {Object} [validation.required] - An object containing a "message" property to display if the field is required.
204
- * @param {Object} [validation.pattern] - An object containing a "pattern" property to match against the field value, and a "message" property to display if the pattern doesn't match.
205
- * @param {Object} [validation.badInput] - An object containing a "message" property to display if the field value is invalid.
206
- * @param {Object} [validation.minmax] - An object containing "min" and "max" properties to validate the field value against, and a "message" property to display if the value is out of range.
207
- * @param {string} [validation.maxlength] - The maximum length of the input field.
208
- * @return {void}
209
- */
210
- applyValidation(input, validation) {
211
- var _a, _b;
212
- // If the "required" property is present, add the "required" attribute to the input element and
213
- // set its "data-required" attribute to the specified message (if any)
214
- if (validation.required) {
215
- input.setAttribute('required', '');
216
- input.setAttribute('data-required', (_a = validation.required.message) !== null && _a !== void 0 ? _a : '');
217
- }
218
- // If the "pattern" property is present, add the "pattern" attribute to the input element and set
219
- // its "data-pattern" attribute to the specified message (if any)
220
- if (validation.pattern) {
221
- input.setAttribute('pattern', validation.pattern.pattern);
222
- input.setAttribute('data-pattern', (_b = validation.pattern.message) !== null && _b !== void 0 ? _b : '');
223
- }
224
- // If the "badInput" property is present, set the input element's "data-badinput" attribute to
225
- // the specified message
226
- if (validation.badInput) {
227
- input.setAttribute('data-badinput', validation.badInput.message);
228
- }
229
- // If the "minmax" property is present, add the "min" and "max" attributes to the input element
230
- // and set its "data-range" attribute to the specified message (if any)
231
- if (validation.minmax) {
232
- input.setAttribute('min', validation.minmax.min);
233
- input.setAttribute('max', validation.minmax.max);
234
- input.setAttribute('data-range', validation.minmax.message);
235
- }
236
- // If the "maxlength" property is present, add the "maxlength" attribute to the input element
237
- if (validation.maxlength) {
238
- input.setAttribute('maxlength', validation.maxlength);
239
- }
240
- }
241
- // Create a new error bubble element
242
- createErrorBubble() {
243
- // Create a new <div> element with the "errorBubble" class
244
- const errorBubble = document.createElement('div');
245
- errorBubble.className = 'errorBubble';
246
- // Return the error bubble element
247
- return errorBubble;
248
- }
249
- /**
250
- * Creates a new <label> element with the "inputBlock" class and the specified label text,
251
- * and appends the input element and error bubble element to it. If the form property has
252
- * no validation object, it adds an "optional" span element to the label.
253
- *
254
- * @param {Object} formProperties - An object containing properties for the form field, including its label text and validation rules.
255
- * @param {HTMLInputElement} input - The input element to associate with the label.
256
- * @param {HTMLDivElement} errorBubble - The error bubble element to display error messages in.
257
- * @return {HTMLLabelElement} - The new label element.
258
- */
259
- createLabel(formProperties, input, errorBubble) {
260
- // Create a new <label> element with the "inputBlock" class and the specified text
261
- const label = document.createElement('label');
262
- label.className = 'inputBlock';
263
- label.innerText = formProperties.label;
264
- // If the form property has no validation object, add an "optional" span element to the label
265
- if (!formProperties.validation) {
266
- const optionalSpan = document.createElement('span');
267
- optionalSpan.className = 'optional';
268
- optionalSpan.innerHTML = '&nbsp;(optional)';
269
- label.appendChild(optionalSpan);
270
- }
271
- // Append the input element and error bubble element to the label
272
- label.appendChild(input);
273
- label.appendChild(errorBubble);
274
- // Return the label element
275
- return label;
276
- }
277
- /**
278
- * Creates a new <input> element with the "submit" type, the "primary-blue" class, and the
279
- * specified label text (i.e., "Save" by default), and returns the new submit button element.
280
- *
281
- * @return {HTMLInputElement} - The new submit button element.
282
- */
283
- createSubmitButton() {
284
- // Create a new <input> element with the "submit" type and the specified class and value
285
- const submitButton = document.createElement('input');
286
- submitButton.type = 'submit';
287
- submitButton.className = 'button primary-blue';
288
- submitButton.value = 'Save';
289
- // Return the submit button element
290
- return submitButton;
291
- }
292
- /**
293
- * Populates the form template with input fields and labels based on the properties of the
294
- * current form schema. For each property in the schema, it creates an input element, applies
295
- * any validation rules to it, creates an error bubble and label element, and appends them
296
- * to the form template. Finally, it creates and appends a submit button element to the form.
297
- *
298
- * @return {void}
299
- */
300
- populateFormFromSchema() {
301
- // If there is no form schema, return early
302
- if (!this._formSchema)
303
- return;
304
- // Get the properties of the form schema and their keys
305
- const properties = this._formSchema.properties;
306
- const propertyKeys = Object.keys(properties);
307
- // Loop through each property key and create an input, label, and error bubble for it
308
- propertyKeys.forEach(formKey => {
309
- const formItem = properties[formKey];
310
- const formProperties = formItem.form;
311
- const input = this.createInput(formKey, formProperties);
312
- // If the form property has validation, apply it to the input
313
- if (formProperties.validation) {
314
- this.applyValidation(input, formProperties.validation);
315
- }
316
- // Create an error bubble and label element for the input
317
- const errorBubble = this.createErrorBubble();
318
- const label = this.createLabel(formProperties, input, errorBubble);
319
- // Append the label element to the form template
320
- this.template.content.append(label);
321
- });
322
- // Create and append a submit button element to the form template
323
- const submitButton = this.createSubmitButton();
324
- this.template.content.append(submitButton);
325
- }
326
- /**
327
- * Clones the form template and binds event listeners to its input elements. First, it checks if
328
- * there is a form schema present. If so, it clones the template's content, binds events to form
329
- * input elements, and appends the cloned form elements to the fieldset. The event listeners include
330
- * "oninvalid" (to check input validity on submit), "onblur" (to check input validity on blur),
331
- * "onkeyup" (to handle changes in input fields), and "onchange" (to handle changes in select fields).
332
- *
333
- * @return {void}
334
- */
335
- componentDidRender() {
336
- // If there's no form schema, return
337
- if (!this._formSchema) {
338
- return;
339
- }
340
- // Clone the template's content and store it in a variable
341
- const formItems = this.template.content.cloneNode(true);
342
- // Bind event listeners to form elements
343
- const properties = this._formSchema.properties;
344
- const propertyKeys = Object.keys(properties);
345
- propertyKeys.forEach((formKey) => {
346
- const formInput = formItems.querySelector(`[name=${formKey}]`);
347
- // Bind events to form input elements
348
- formInput.oninvalid = this.validityCheck.bind(this);
349
- formInput.onblur = this.validityCheck.bind(this);
350
- formInput.onkeyup = this.fieldChanged.bind(this);
351
- formInput.onchange = this.fieldChanged.bind(this);
352
- });
353
- // Append the cloned form elements to the fieldset
354
- this.fieldset.appendChild(formItems);
355
- }
356
- /**
357
- * Renders the component's template as a form element with a fieldset container. The form's
358
- * "onSubmit" event is bound to the "doSubmit" function, which handles the form submission
359
- * and emits a "dataSubmitted" event with the form data. The fieldset element is assigned
360
- * to the "fieldset" instance variable using a ref, so it can be populated with form elements
361
- * later on.
362
- *
363
- * @return {JSX.Element} - The rendered form template as a JSX element.
364
- */
365
- render() {
366
- return (index.h(index.Host, null, index.h("form", { onSubmit: this.doSubmit.bind(this) }, index.h("fieldset", { ref: el => (this.fieldset = el) }))));
367
- }
368
- static get watchers() { return {
369
- "formschema": ["onFormSchemaChange"]
370
- }; }
371
- };
372
- TttxForm.style = tttxFormCss;
373
-
374
- exports.tttx_form = TttxForm;
@@ -1,125 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-bf777121.js');
6
-
7
- const tttxInputCalendarCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}:host{display:block;--border-radius:4px;position:relative}.calcontainer{-webkit-perspective:500px;perspective:500px}.lefty{float:left}.righty{float:right}.calendar{display:none;position:absolute;box-sizing:border-box;width:312px;height:332px;background-color:white;padding:16px;box-shadow:0px 1px 5px rgba(17, 17, 17, 0.3);border-radius:var(--border-radius)}.calendar-header{display:flex;justify-content:space-between;margin-bottom:8px}.date-display{margin-top:8px}.calendar-header select{border:none;padding:5px}.calendar-table{width:100%;border-collapse:collapse}.calendar-table th{text-align:center;padding:4px;text-transform:uppercase;font-size:14px;color:#757575;border-bottom:1px solid #d5d5d5;margin-bottom:8px}.calendar .calendar-table td{padding:0;margin:0;width:14.2%;text-align:center;height:36px;line-height:36px}.calendar .calendar-table td span:hover{background-color:#f0f0f0}.calendar .calendar-table td span{display:block;text-align:center;padding:4px;cursor:pointer;border-radius:var(--border-radius)}.calendar-visible{display:block}.calendar-table thead tr{border-bottom:1px solid #d5d5d5}";
8
-
9
- const TttxInputCalendar = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- // an array of month numbers mapped to their names
13
- this.monthNames = Array.from({ length: 12 }, (_, i) => i + 1).map((month) => {
14
- const date = new Date(0);
15
- date.setUTCMonth(month - 1);
16
- return date.toLocaleString('default', { month: 'long' });
17
- });
18
- this.onClickOutside = (event) => {
19
- if (!this.el.contains(event.target) && this.showCalendar) {
20
- this.showCalendar = false;
21
- }
22
- };
23
- this.onFocusIn = (event) => {
24
- if (!this.el.contains(event.target) && this.showCalendar) {
25
- this.showCalendar = false;
26
- }
27
- };
28
- this.previousHandler = () => {
29
- if (this.selectedMonth === 1) {
30
- this.selectedMonth = 12;
31
- this.selectedYear--;
32
- }
33
- else {
34
- this.selectedMonth--;
35
- }
36
- };
37
- this.nextHandler = () => {
38
- if (this.selectedMonth === 12) {
39
- this.selectedMonth = 1;
40
- this.selectedYear++;
41
- }
42
- else {
43
- this.selectedMonth++;
44
- }
45
- };
46
- this.months = false;
47
- this.years = false;
48
- this.showCalendar = false;
49
- this.selectedYear = new Date().getFullYear();
50
- this.selectedMonth = new Date().getMonth() + 1;
51
- }
52
- componentDidLoad() {
53
- const slot = this.el.shadowRoot.querySelector('slot');
54
- if (slot) {
55
- const assignedElements = slot.assignedElements();
56
- if (assignedElements[0]) {
57
- assignedElements[0].addEventListener('click', (event) => {
58
- event.preventDefault();
59
- this.showCalendar = !this.showCalendar;
60
- });
61
- }
62
- }
63
- document.addEventListener('click', this.onClickOutside);
64
- }
65
- disconnectedCallback() {
66
- document.removeEventListener('click', this.onClickOutside);
67
- }
68
- getDaysAndDates(year, month) {
69
- const firstDayOfMonth = new Date(year, month - 1, 1);
70
- const lastDayOfMonth = new Date(year, month, 0);
71
- const daysAndDates = [];
72
- for (let day = firstDayOfMonth; day <= lastDayOfMonth; day.setDate(day.getDate() + 1)) {
73
- const weekDay = day.getDay();
74
- const date = day.getDate();
75
- const dayAndDate = {
76
- day: weekDay,
77
- date: date
78
- };
79
- daysAndDates.push(dayAndDate);
80
- }
81
- return daysAndDates;
82
- }
83
- clickDateHandler(event) {
84
- const { year, month, day } = event;
85
- const selectedDate = new Date(year, month - 1, day + 1);
86
- this.inputElement.valueAsDate = selectedDate;
87
- this.showCalendar = false;
88
- }
89
- render() {
90
- const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
91
- const daysAndDates = this.getDaysAndDates(this.selectedYear, this.selectedMonth);
92
- const currentYear = new Date().getFullYear();
93
- const years = Array.from({ length: 11 }, (_, i) => currentYear - 5 + i);
94
- const calendarGrid = [];
95
- let currentWeek = [];
96
- // Fill empty days before the first day of the month
97
- for (let i = 0; i < daysAndDates[0].day; i++) {
98
- currentWeek.push(index.h("td", null));
99
- }
100
- // Fill the calendar with days and dates
101
- daysAndDates.forEach(({ day, date }) => {
102
- currentWeek.push(index.h("td", null, index.h("span", { onClick: () => this.clickDateHandler({ year: this.selectedYear, month: this.selectedMonth, day: date }) }, date)));
103
- if (day === 6) {
104
- calendarGrid.push(index.h("tr", null, currentWeek));
105
- currentWeek = [];
106
- }
107
- });
108
- // Fill the remaining empty days in the last week
109
- if (currentWeek.length > 0) {
110
- while (currentWeek.length < 7) {
111
- currentWeek.push(index.h("td", null));
112
- }
113
- calendarGrid.push(index.h("tr", null, currentWeek));
114
- }
115
- return (index.h(index.Host, null, index.h("div", { class: "calcontainer" }, index.h("slot", null), index.h("div", { class: `calendar ${this.showCalendar ? 'calendar-visible' : ''}` }, index.h("div", { class: "calendar-header" }, index.h("tttx-button", { onClick: this.previousHandler, design: "borderless", icon: "chevron_left", notext: true }), this.months && index.h("select", { id: "month-select", onInput: (event) => {
116
- this.selectedMonth = parseInt(event.target.value);
117
- } }, Array.from({ length: 12 }, (_, i) => i + 1).map((month) => (index.h("option", { value: month, selected: month === this.selectedMonth }, this.monthNames[month - 1])))), this.years && index.h("select", { id: "year-select", onInput: (event) => {
118
- this.selectedYear = parseInt(event.target.value);
119
- } }, years.map((year) => (index.h("option", { value: year, selected: year === this.selectedYear }, year)))), index.h("div", { class: "date-display" }, this.monthNames[this.selectedMonth - 1], " ", this.selectedYear), index.h("tttx-button", { onClick: this.nextHandler, design: "borderless", icon: "chevron_right", notext: true })), index.h("table", { class: "calendar-table" }, index.h("thead", null, index.h("tr", null, daysOfWeek.map((day) => (index.h("th", null, day))))), index.h("tbody", null, calendarGrid))))));
120
- }
121
- get el() { return index.getElement(this); }
122
- };
123
- TttxInputCalendar.style = tttxInputCalendarCss;
124
-
125
- exports.tttx_input_calendar = TttxInputCalendar;