Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
0b1e50bbc6 | |||
888f07db79 | |||
e14d83b3a7 | |||
f4055fb8c1 | |||
d0d4638264 | |||
7d63f16fc1 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-catalog",
|
"name": "@designestate/dees-catalog",
|
||||||
"version": "1.0.43",
|
"version": "1.0.46",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@designestate/dees-catalog",
|
"name": "@designestate/dees-catalog",
|
||||||
"version": "1.0.43",
|
"version": "1.0.46",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@designestate/dees-domtools": "^1.0.89",
|
"@designestate/dees-domtools": "^1.0.89",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@designestate/dees-catalog",
|
"name": "@designestate/dees-catalog",
|
||||||
"version": "1.0.43",
|
"version": "1.0.46",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "website for lossless.com",
|
"description": "website for lossless.com",
|
||||||
"main": "dist_ts_web/index.js",
|
"main": "dist_ts_web/index.js",
|
||||||
|
@ -145,17 +145,21 @@ export class DeesButton extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button.pending {
|
.button.pending {
|
||||||
background: #0277bd70;
|
border: 1px solid ${cssManager.bdTheme('#0277bd', '#0277bd70')};
|
||||||
|
background: ${cssManager.bdTheme('#0277bd', '#0277bd70')};
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button.success {
|
.button.success {
|
||||||
background: #8BC34A70;
|
border: 1px solid ${cssManager.bdTheme('#689F38', '#8BC34A70')};
|
||||||
|
background: ${cssManager.bdTheme('#689F38', '#8BC34A70')};
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button.error {
|
.button.error {
|
||||||
background: #E64A1970;
|
border: 1px solid ${cssManager.bdTheme('#B71C1C', '#E64A1970')};
|
||||||
|
background: ${cssManager.bdTheme('#B71C1C', '')};
|
||||||
|
background: ;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ import { DeesInputRadio } from './dees-input-radio';
|
|||||||
import * as domtools from '@designestate/dees-domtools';
|
import * as domtools from '@designestate/dees-domtools';
|
||||||
import { DeesFormSubmit } from './dees-form-submit';
|
import { DeesFormSubmit } from './dees-form-submit';
|
||||||
|
|
||||||
export type TFormElement = Array<DeesInputCheckbox | DeesInputText | DeesInputQuantitySelector | DeesInputRadio>;
|
export type TFormElement = Array<
|
||||||
|
DeesInputCheckbox | DeesInputText | DeesInputQuantitySelector | DeesInputRadio
|
||||||
|
>;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -18,15 +20,22 @@ declare global {
|
|||||||
@customElement('dees-form')
|
@customElement('dees-form')
|
||||||
export class DeesForm extends DeesElement {
|
export class DeesForm extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = () => html`
|
||||||
<dees-form style="display: block; margin:auto; max-width: 500px; padding: 20px" @formData=${async (eventArg) => {
|
<dees-form
|
||||||
|
style="display: block; margin:auto; max-width: 500px; padding: 20px"
|
||||||
|
@formData=${async (eventArg) => {
|
||||||
const form: DeesForm = eventArg.currentTarget;
|
const form: DeesForm = eventArg.currentTarget;
|
||||||
form.setStatus('pending', 'authenticating...');
|
form.setStatus('pending', 'authenticating...');
|
||||||
await domtools.plugins.smartdelay.delayFor(1000);
|
await domtools.plugins.smartdelay.delayFor(1000);
|
||||||
form.setStatus('success', 'authenticated!');
|
form.setStatus('success', 'authenticated!');
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<dees-input-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
<dees-input-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
||||||
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
||||||
<dees-input-checkbox .required="${true}" key="hello3" label="another text"></dees-input-checkbox>
|
<dees-input-checkbox
|
||||||
|
.required="${true}"
|
||||||
|
key="hello3"
|
||||||
|
label="another text"
|
||||||
|
></dees-input-checkbox>
|
||||||
<dees-form-submit>Submit</dees-form-submit>
|
<dees-form-submit>Submit</dees-form-submit>
|
||||||
</dees-form>
|
</dees-form>
|
||||||
`;
|
`;
|
||||||
@ -63,7 +72,11 @@ export class DeesForm extends DeesElement {
|
|||||||
const formChildren: TFormElement = [];
|
const formChildren: TFormElement = [];
|
||||||
|
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (child instanceof DeesInputCheckbox || child instanceof DeesInputText || child instanceof DeesInputQuantitySelector) {
|
if (
|
||||||
|
child instanceof DeesInputCheckbox ||
|
||||||
|
child instanceof DeesInputText ||
|
||||||
|
child instanceof DeesInputQuantitySelector
|
||||||
|
) {
|
||||||
formChildren.push(child);
|
formChildren.push(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +87,7 @@ export class DeesForm extends DeesElement {
|
|||||||
const children: Array<DeesElement> = this.children as any;
|
const children: Array<DeesElement> = this.children as any;
|
||||||
let submitButton: DeesFormSubmit;
|
let submitButton: DeesFormSubmit;
|
||||||
for (const childArg of children) {
|
for (const childArg of children) {
|
||||||
if(childArg instanceof DeesFormSubmit) {
|
if (childArg instanceof DeesFormSubmit) {
|
||||||
submitButton = childArg;
|
submitButton = childArg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,8 +95,7 @@ export class DeesForm extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async checkRequiredStatus() {
|
public async checkRequiredStatus() {
|
||||||
console.log('checking the required status.')
|
console.log('checking the required status.');
|
||||||
|
|
||||||
|
|
||||||
let requiredOK = true;
|
let requiredOK = true;
|
||||||
for (const childArg of this.getFormChildren()) {
|
for (const childArg of this.getFormChildren()) {
|
||||||
@ -96,7 +108,7 @@ export class DeesForm extends DeesElement {
|
|||||||
|
|
||||||
public async gatherData() {
|
public async gatherData() {
|
||||||
const children = this.getFormChildren();
|
const children = this.getFormChildren();
|
||||||
const valueObject: { [key: string]: string | number | boolean} = {};
|
const valueObject: { [key: string]: string | number | boolean } = {};
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
valueObject[child.key] = child.value;
|
valueObject[child.key] = child.value;
|
||||||
}
|
}
|
||||||
@ -107,20 +119,23 @@ export class DeesForm extends DeesElement {
|
|||||||
const valueObject = await this.gatherData();
|
const valueObject = await this.gatherData();
|
||||||
const formDataEvent = new CustomEvent('formData', {
|
const formDataEvent = new CustomEvent('formData', {
|
||||||
detail: {
|
detail: {
|
||||||
data: valueObject
|
data: valueObject,
|
||||||
},
|
},
|
||||||
bubbles: true
|
bubbles: true,
|
||||||
});
|
});
|
||||||
this.dispatchEvent(formDataEvent);
|
this.dispatchEvent(formDataEvent);
|
||||||
console.log('dispatched data:')
|
console.log('dispatched data:');
|
||||||
console.log(valueObject);
|
console.log(valueObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setStatus (visualStateArg: 'normal' | 'pending' | 'error' | 'success', textStateArg: string) {
|
public setStatus(
|
||||||
|
visualStateArg: 'normal' | 'pending' | 'error' | 'success',
|
||||||
|
textStateArg: string
|
||||||
|
) {
|
||||||
const inputChildren = this.getFormChildren();
|
const inputChildren = this.getFormChildren();
|
||||||
const submitButton = this.getSubmitButton();
|
const submitButton = this.getSubmitButton();
|
||||||
|
|
||||||
switch(visualStateArg) {
|
switch (visualStateArg) {
|
||||||
case 'pending':
|
case 'pending':
|
||||||
submitButton.disabled = true;
|
submitButton.disabled = true;
|
||||||
submitButton.status = 'pending';
|
submitButton.status = 'pending';
|
||||||
@ -135,9 +150,15 @@ export class DeesForm extends DeesElement {
|
|||||||
inputChild.disabled = true;
|
inputChild.disabled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'error':
|
||||||
|
submitButton.disabled = true;
|
||||||
|
submitButton.status = 'error';
|
||||||
|
for (const inputChild of inputChildren) {
|
||||||
|
inputChild.disabled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
submitButton.text = textStateArg;
|
submitButton.text = textStateArg;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,7 +45,7 @@ export class DeesSpinner extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#loading {
|
#loading {
|
||||||
transition: all 0.3s;
|
transition: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
|
Reference in New Issue
Block a user