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