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