@3t-transform/threeteeui 0.0.13 → 0.0.15
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.
- package/package.json +7 -4
- package/dist/cjs/index-bf39be87.js +0 -1530
- package/dist/cjs/index.cjs.js +0 -2
- package/dist/cjs/loader.cjs.js +0 -22
- package/dist/cjs/tttx-button.cjs.entry.js +0 -28
- package/dist/cjs/tttx-checkbox.cjs.entry.js +0 -28
- package/dist/cjs/tttx-form.cjs.entry.js +0 -186
- package/dist/cjs/tttx-icon.cjs.entry.js +0 -1861
- package/dist/cjs/tttx-list.cjs.entry.js +0 -198
- package/dist/cjs/tttx-loading-spinner.cjs.entry.js +0 -26
- package/dist/cjs/tttx-popover-content.cjs.entry.js +0 -23
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +0 -136
- package/dist/cjs/tttx.cjs.js +0 -23
- package/dist/collection/collection-manifest.json +0 -19
- package/dist/collection/components/atoms/tttx-button/tttx-button.css +0 -62
- package/dist/collection/components/atoms/tttx-button/tttx-button.js +0 -93
- package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +0 -27
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.css +0 -105
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +0 -114
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +0 -47
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.css +0 -48
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +0 -66
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +0 -17
- package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.css +0 -30
- package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.js +0 -96
- package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.stories.js +0 -23
- package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.css +0 -181
- package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.js +0 -101
- package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.stories.js +0 -13
- package/dist/collection/components/molecules/tttx-form/tttx-form.css +0 -230
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +0 -249
- package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +0 -102
- package/dist/collection/components/molecules/tttx-list/tttx-list.css +0 -56
- package/dist/collection/components/molecules/tttx-list/tttx-list.js +0 -311
- package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +0 -37
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.css +0 -177
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +0 -569
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +0 -156
- package/dist/collection/components/palette.stories.js +0 -88
- package/dist/collection/docs/gettingstarted-developer.stories.js +0 -9
- package/dist/collection/icons.js +0 -2838
- package/dist/collection/index.js +0 -1
- package/dist/components/index.d.ts +0 -38
- package/dist/components/index.js +0 -9
- package/dist/components/tttx-button.d.ts +0 -11
- package/dist/components/tttx-button.js +0 -45
- package/dist/components/tttx-checkbox.d.ts +0 -11
- package/dist/components/tttx-checkbox.js +0 -46
- package/dist/components/tttx-form.d.ts +0 -11
- package/dist/components/tttx-form.js +0 -203
- package/dist/components/tttx-icon.d.ts +0 -11
- package/dist/components/tttx-icon.js +0 -6
- package/dist/components/tttx-icon2.js +0 -1875
- package/dist/components/tttx-list.d.ts +0 -11
- package/dist/components/tttx-list.js +0 -225
- package/dist/components/tttx-loading-spinner.d.ts +0 -11
- package/dist/components/tttx-loading-spinner.js +0 -6
- package/dist/components/tttx-loading-spinner2.js +0 -40
- package/dist/components/tttx-popover-content.d.ts +0 -11
- package/dist/components/tttx-popover-content.js +0 -42
- package/dist/components/tttx-standalone-input.d.ts +0 -11
- package/dist/components/tttx-standalone-input.js +0 -178
- package/dist/esm/index-63c4d25e.js +0 -1501
- package/dist/esm/index.js +0 -1
- package/dist/esm/loader.js +0 -18
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/tttx-button.entry.js +0 -24
- package/dist/esm/tttx-checkbox.entry.js +0 -24
- package/dist/esm/tttx-form.entry.js +0 -182
- package/dist/esm/tttx-icon.entry.js +0 -1857
- package/dist/esm/tttx-list.entry.js +0 -194
- package/dist/esm/tttx-loading-spinner.entry.js +0 -22
- package/dist/esm/tttx-popover-content.entry.js +0 -19
- package/dist/esm/tttx-standalone-input.entry.js +0 -132
- package/dist/esm/tttx.js +0 -18
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/tttx/index.esm.js +0 -0
- package/dist/tttx/p-1a4eb1f3.entry.js +0 -1
- package/dist/tttx/p-25953f82.entry.js +0 -1
- package/dist/tttx/p-2b6720ac.entry.js +0 -1
- package/dist/tttx/p-2d54f8aa.entry.js +0 -1
- package/dist/tttx/p-4c57bcbd.entry.js +0 -1
- package/dist/tttx/p-709246f5.entry.js +0 -1
- package/dist/tttx/p-95a29e09.entry.js +0 -1
- package/dist/tttx/p-ad0c3fe4.entry.js +0 -1
- package/dist/tttx/p-bec472d8.js +0 -2
- package/dist/tttx/tttx.esm.js +0 -1
- package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +0 -9
- package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +0 -20
- package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +0 -14
- package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +0 -21
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +0 -6
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +0 -17
- package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.d.ts +0 -7
- package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.stories.d.ts +0 -18
- package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +0 -9
- package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts +0 -6
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +0 -18
- package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +0 -6
- package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +0 -51
- package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +0 -13
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +0 -38
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +0 -106
- package/dist/types/components/palette.stories.d.ts +0 -6
- package/dist/types/components.d.ts +0 -236
- package/dist/types/docs/gettingstarted-developer.stories.d.ts +0 -5
- package/dist/types/icons.d.ts +0 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/stencil-public-runtime.d.ts +0 -1637
- package/loader/cdn.js +0 -3
- package/loader/index.cjs.js +0 -3
- package/loader/index.d.ts +0 -21
- package/loader/index.es2017.js +0 -3
- package/loader/index.js +0 -4
- package/loader/package.json +0 -11
package/dist/cjs/index.cjs.js
DELETED
package/dist/cjs/loader.cjs.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-bf39be87.js');
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
Stencil Client Patch Esm v2.22.3 | MIT Licensed | https://stenciljs.com
|
|
9
|
-
*/
|
|
10
|
-
const patchEsm = () => {
|
|
11
|
-
return index.promiseResolve();
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const defineCustomElements = (win, options) => {
|
|
15
|
-
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
|
-
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["tttx-list.cjs",[[1,"tttx-list",{"name":[1],"selectable":[4],"items":[32],"selectedIds":[32],"loading":[32],"lastPage":[32]},[[4,"listPageLoad","listLoadHandler"],[4,"listClearDataCache","listClearDataCacheHandler"],[4,"listActionSelectedEvent","listActionSelectedEventHandler"]]]]],["tttx-standalone-input.cjs",[[2,"tttx-standalone-input",{"label":[1],"showerrormsg":[4],"errormsg":[1],"iconleft":[1],"iconright":[1],"autocapitalize":[1],"autocomplete":[1],"autofocus":[4],"checked":[4],"disabled":[4],"max":[8],"maxlength":[8],"min":[8],"minlength":[8],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[8],"required":[4],"step":[8],"type":[1],"value":[1032]}]]],["tttx-button.cjs",[[1,"tttx-button",{"fontColor":[1,"font-color"],"buttonStyle":[1,"button-style"]},[[0,"clickEvent","onClicked"]]]]],["tttx-checkbox.cjs",[[1,"tttx-checkbox",{"value":[4],"label":[1],"required":[4]}]]],["tttx-form.cjs",[[1,"tttx-form",{"formschema":[8],"submitValue":[8,"submit-value"]}]]],["tttx-popover-content.cjs",[[1,"tttx-popover-content",{"header":[1],"body":[1],"linkcontext":[1],"linktext":[1]}]]],["tttx-icon.cjs",[[1,"tttx-icon",{"icon":[1],"colour":[1]},[[4,"click","handleDocumentClick"]]]]],["tttx-loading-spinner.cjs",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]]], options);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.setNonce = index.setNonce;
|
|
22
|
-
exports.defineCustomElements = defineCustomElements;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-bf39be87.js');
|
|
6
|
-
|
|
7
|
-
const tttxButtonCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.button{height:36px;padding:8px 16px;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:hover{background:#f0f0f0}.button:active{background:#e3e3e3}.primary-blue{background:#1479c6;border:1px solid #1479c6;color:white}.primary-blue:hover{background:#1169ba}.primary-blue:active{background:#0951a8}.secondary-white{background:white;border:1px solid #212121}:host{display:inline-block}.spacingleft{margin-left:8px}.font-white{color:white}.font-black{color:#212121}";
|
|
8
|
-
|
|
9
|
-
const TttxButton = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
this.clickEvent = index.createEvent(this, "clickEvent", 7);
|
|
13
|
-
this.fontColor = undefined;
|
|
14
|
-
this.buttonStyle = undefined;
|
|
15
|
-
}
|
|
16
|
-
onClick() {
|
|
17
|
-
this.clickEvent.emit('clicked');
|
|
18
|
-
}
|
|
19
|
-
onClicked(event) {
|
|
20
|
-
console.log('Picked up a clickEvent', event);
|
|
21
|
-
}
|
|
22
|
-
render() {
|
|
23
|
-
return (index.h(index.Host, null, index.h("button", { onClick: this.onClick.bind(this), class: `button ${this.fontColor} ${this.buttonStyle}` }, index.h("span", null, index.h("slot", null)))));
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
TttxButton.style = tttxButtonCss;
|
|
27
|
-
|
|
28
|
-
exports.tttx_button = TttxButton;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-bf39be87.js');
|
|
6
|
-
|
|
7
|
-
const tttxCheckboxCss = ".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}:host{display:block}.spacing{margin-bottom:16px}";
|
|
8
|
-
|
|
9
|
-
const TttxCheckbox = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
this.valueChanged = index.createEvent(this, "valueChanged", 7);
|
|
13
|
-
this.value = undefined;
|
|
14
|
-
this.label = undefined;
|
|
15
|
-
this.required = undefined;
|
|
16
|
-
}
|
|
17
|
-
handleClick(event) {
|
|
18
|
-
const target = event.target;
|
|
19
|
-
this.value = target.checked;
|
|
20
|
-
this.valueChanged.emit(target.checked);
|
|
21
|
-
}
|
|
22
|
-
render() {
|
|
23
|
-
return (index.h(index.Host, null, index.h("div", { class: "field spacing" }, this.label && (index.h("label", { class: "label" }, this.label, !this.required ? index.h("span", { class: "optional" }, " (optional)") : '')), index.h("input", { type: "checkbox", class: "input", onChange: event => this.handleClick(event), checked: this.value }))));
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
TttxCheckbox.style = tttxCheckboxCss;
|
|
27
|
-
|
|
28
|
-
exports.tttx_checkbox = TttxCheckbox;
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-bf39be87.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{height:36px;padding:8px 16px;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:hover{background:#f0f0f0}.button:active{background:#e3e3e3}.primary-blue{background:#1479c6;border:1px solid #1479c6;color:white}.primary-blue:hover{background:#1169ba}.primary-blue:active{background:#0951a8}.secondary-white{background:white;border:1px solid #212121}: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.submitEvent = index.createEvent(this, "submitEvent", 7);
|
|
13
|
-
this.template = document.createElement('template');
|
|
14
|
-
this.formschema = undefined;
|
|
15
|
-
this.submitValue = undefined;
|
|
16
|
-
}
|
|
17
|
-
onFormSchemaChange(newValue) {
|
|
18
|
-
if (typeof newValue === 'string') {
|
|
19
|
-
this._formSchema = JSON.parse(newValue);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
this._formSchema = newValue;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
validityCheck(event) {
|
|
26
|
-
var _a, _b, _c, _d;
|
|
27
|
-
event.preventDefault();
|
|
28
|
-
const target = event.target;
|
|
29
|
-
let hasError = true;
|
|
30
|
-
let errorMessage = '';
|
|
31
|
-
// validity object on HTML5 inputs has the following options
|
|
32
|
-
// badInput
|
|
33
|
-
// customError
|
|
34
|
-
// patternMismatch
|
|
35
|
-
// rangeOverflow
|
|
36
|
-
// rangeUnderflow
|
|
37
|
-
// stepMismatch
|
|
38
|
-
// tooLong
|
|
39
|
-
// tooShort
|
|
40
|
-
// typeMismatch
|
|
41
|
-
// valid
|
|
42
|
-
// valueMissing
|
|
43
|
-
// customErrors can be set with
|
|
44
|
-
// target.setCustomValidity('custom error!');
|
|
45
|
-
// and cleared with
|
|
46
|
-
// target.setCustomValidity('');
|
|
47
|
-
if (target.validity.valueMissing) {
|
|
48
|
-
errorMessage = (_a = target.dataset.required) !== null && _a !== void 0 ? _a : 'This field is required';
|
|
49
|
-
}
|
|
50
|
-
else if (target.validity.patternMismatch) {
|
|
51
|
-
errorMessage = (_b = target.dataset.pattern) !== null && _b !== void 0 ? _b : 'Incorrect format';
|
|
52
|
-
}
|
|
53
|
-
else if (target.validity.badInput) {
|
|
54
|
-
// IE string in a number field
|
|
55
|
-
errorMessage = (_c = target.dataset.badinput) !== null && _c !== void 0 ? _c : 'Wrong input type';
|
|
56
|
-
}
|
|
57
|
-
else if (target.validity.rangeOverflow || target.validity.rangeUnderflow) {
|
|
58
|
-
// IE date or number is above or below value set in min or max tags
|
|
59
|
-
errorMessage = (_d = target.dataset.range) !== null && _d !== void 0 ? _d : 'Invalid value';
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
// no error
|
|
63
|
-
hasError = false;
|
|
64
|
-
}
|
|
65
|
-
if (hasError) {
|
|
66
|
-
target.className = 'invalid';
|
|
67
|
-
const errorIcon = document.createElement('span');
|
|
68
|
-
errorIcon.className = 'material-symbols-rounded';
|
|
69
|
-
errorIcon.textContent = 'warning';
|
|
70
|
-
target.parentElement.querySelector('.errorBubble').replaceChildren();
|
|
71
|
-
target.parentElement.querySelector('.errorBubble').append(errorIcon);
|
|
72
|
-
target.parentElement.querySelector('.errorBubble').append(errorMessage);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
target.className = '';
|
|
76
|
-
target.parentElement.querySelector('.errorBubble').replaceChildren();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
doSubmit(event) {
|
|
80
|
-
event.preventDefault();
|
|
81
|
-
const formData = new FormData(event.target);
|
|
82
|
-
// Key value pair matching the key names given by the JSON schema will be output line by line
|
|
83
|
-
// TODO: Emit an event so external components can handle the resulting form data
|
|
84
|
-
// let output = "";
|
|
85
|
-
// for (var [key, value] of formData.entries()) {
|
|
86
|
-
// output += `${key} -> ${value}\n`;
|
|
87
|
-
// }
|
|
88
|
-
// console.log(output);
|
|
89
|
-
this.submitEvent.emit(formData);
|
|
90
|
-
}
|
|
91
|
-
fieldsetChange(event) {
|
|
92
|
-
console.log(event.target.name + ' has changed');
|
|
93
|
-
// The correct input box will always be the target of the incoming event
|
|
94
|
-
// TODO: Emit an event so external components can change based on form values input
|
|
95
|
-
}
|
|
96
|
-
componentWillLoad() {
|
|
97
|
-
// set proper on initial render
|
|
98
|
-
this.onFormSchemaChange(this.formschema);
|
|
99
|
-
}
|
|
100
|
-
componentWillRender() {
|
|
101
|
-
this.template.content.replaceChildren(); // clear the template to account for a potential re-render scenario
|
|
102
|
-
this.populateFormFromSchema();
|
|
103
|
-
}
|
|
104
|
-
populateFormFromSchema() {
|
|
105
|
-
if (!this._formSchema)
|
|
106
|
-
return;
|
|
107
|
-
const properties = this._formSchema.properties;
|
|
108
|
-
const propertyKeys = Object.keys(properties);
|
|
109
|
-
propertyKeys.forEach(formKey => {
|
|
110
|
-
var _a, _b, _c;
|
|
111
|
-
const formItem = properties[formKey];
|
|
112
|
-
const formProperties = formItem.form;
|
|
113
|
-
const input = document.createElement('input');
|
|
114
|
-
input.name = formKey;
|
|
115
|
-
input.type = formProperties.type;
|
|
116
|
-
input.placeholder = (_a = formProperties.placeholder) !== null && _a !== void 0 ? _a : '';
|
|
117
|
-
input.autocomplete = 'off';
|
|
118
|
-
input.autocapitalize = 'off';
|
|
119
|
-
if (formProperties.validation) {
|
|
120
|
-
const validation = formProperties.validation;
|
|
121
|
-
if (validation.required) {
|
|
122
|
-
input.setAttribute('required', '');
|
|
123
|
-
input.setAttribute('data-required', (_b = validation.required.message) !== null && _b !== void 0 ? _b : '');
|
|
124
|
-
}
|
|
125
|
-
if (validation.pattern) {
|
|
126
|
-
input.setAttribute('pattern', validation.pattern.pattern);
|
|
127
|
-
input.setAttribute('data-pattern', (_c = validation.pattern.message) !== null && _c !== void 0 ? _c : '');
|
|
128
|
-
}
|
|
129
|
-
if (validation.badInput) {
|
|
130
|
-
input.setAttribute('data-badinput', validation.badInput.message);
|
|
131
|
-
}
|
|
132
|
-
if (validation.minmax) {
|
|
133
|
-
input.setAttribute('min', validation.minmax.min);
|
|
134
|
-
input.setAttribute('max', validation.minmax.max);
|
|
135
|
-
input.setAttribute('data-range', validation.minmax.message);
|
|
136
|
-
}
|
|
137
|
-
if (validation.maxlength) {
|
|
138
|
-
input.setAttribute('maxlength', validation.maxlength);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const errorBubble = document.createElement('div');
|
|
142
|
-
errorBubble.className = 'errorBubble';
|
|
143
|
-
const label = document.createElement('label');
|
|
144
|
-
label.className = 'inputBlock';
|
|
145
|
-
label.innerText = formProperties.label;
|
|
146
|
-
if (!formProperties.validation) {
|
|
147
|
-
const optionalSpan = document.createElement('span');
|
|
148
|
-
optionalSpan.className = 'optional';
|
|
149
|
-
optionalSpan.innerHTML = ' (optional)';
|
|
150
|
-
label.appendChild(optionalSpan);
|
|
151
|
-
}
|
|
152
|
-
label.appendChild(input);
|
|
153
|
-
label.appendChild(errorBubble);
|
|
154
|
-
this.template.content.append(label);
|
|
155
|
-
});
|
|
156
|
-
const submitButton = document.createElement('input');
|
|
157
|
-
submitButton.type = 'submit';
|
|
158
|
-
submitButton.className = 'button primary-blue';
|
|
159
|
-
console.log(this.submitValue);
|
|
160
|
-
submitButton.value = 'Save';
|
|
161
|
-
this.template.content.append(submitButton);
|
|
162
|
-
}
|
|
163
|
-
componentDidRender() {
|
|
164
|
-
if (!this._formSchema)
|
|
165
|
-
return;
|
|
166
|
-
const formItems = this.template.content.cloneNode(true);
|
|
167
|
-
// bind to events here as you can't do it in a template in stencil
|
|
168
|
-
const properties = this._formSchema.properties;
|
|
169
|
-
const propertyKeys = Object.keys(properties);
|
|
170
|
-
propertyKeys.forEach(formKey => {
|
|
171
|
-
formItems.querySelector(`[name=${formKey}]`).oninvalid = this.validityCheck.bind(this);
|
|
172
|
-
formItems.querySelector(`[name=${formKey}]`).onblur = this.validityCheck.bind(this);
|
|
173
|
-
});
|
|
174
|
-
// append to the fieldset
|
|
175
|
-
this.fieldset.appendChild(formItems);
|
|
176
|
-
}
|
|
177
|
-
render() {
|
|
178
|
-
return (index.h(index.Host, null, index.h("form", { onSubmit: this.doSubmit.bind(this) }, index.h("fieldset", { onChange: this.fieldsetChange, ref: el => (this.fieldset = el) }))));
|
|
179
|
-
}
|
|
180
|
-
static get watchers() { return {
|
|
181
|
-
"formschema": ["onFormSchemaChange"]
|
|
182
|
-
}; }
|
|
183
|
-
};
|
|
184
|
-
TttxForm.style = tttxFormCss;
|
|
185
|
-
|
|
186
|
-
exports.tttx_form = TttxForm;
|