New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sling-web-component-form

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sling-web-component-form - npm Package Compare versions

Comparing version 0.17.0 to 1.6.0

dist/cjs/es5/component/Form.js

21

package.json
{
"name": "sling-web-component-form",
"version": "0.17.0",
"description": "",
"main": "dist/cjs/index.js",
"jsnext:main": "dist/es/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.6.0",
"description": "Sling Form",
"module": "src/index.js",
"main": "dist/cjs/es5/index.js",
"jsnext:main": "dist/es/es6/index.js",
"browser": "dist/iife/es6/index.js",
"author": "Stone Pagamentos",
"dependencies": {
"sling-web-component-button": "^0.17.0",
"sling-web-component-input": "^0.17.0",
"sling-web-framework": "^0.17.0",
"sling-web-helpers": "^0.17.0"
"sling-framework": "^1.6.0",
"sling-helpers": "^1.6.0",
"sling-web-component-button": "^1.6.0",
"sling-web-component-input": "^1.6.0"
}
}

@@ -1,3 +0,61 @@

# sling-web-component-card
# sling-web-component-form
The card Component. To use it just add the tag to your index.html.
## Install
```
npm instal sling-web-component-form
```
## Tag
```HTML
<sling-form></sling-form>
```
## Dependencies
### Required
* **sling-framework**
* **sling-helpers**
### Recommended
* **sling-web-component-button**
* **sling-web-component-input**
## Attributes and properties
|Name|Type|Default Values|ReflectToAttribute|Observer|callSdk|
|:--|:--|:--|:--:|:--|:--:|
|formdata|Object|**false**|:x:|:heavy_check_mark:|
|validation|Array|**[]**|:x:|:x:|
### Description
|Name|Description|
|:---|:---|
|formdata|Object that contains the data from the form|
|validation|A list of `sling-helper` methods for validations|
## Events
* **formsubmit**
**Description:** Event triggered every time that the form is submitted.
* **formupdate**
**Description:** Event triggered when any value of the form is changed.
### Use
Use it like you are using a `<form>` tag. You can put anything form-related inside of it.
```HTML
<sling-form>
<sling-input name="name" type="text" label="Name"></sling-input>
<!-- ... -->
</sling-form>
```
## Examples
All component examples can be emulated using the `npm start sling-web-component-form` command.

@@ -1,5 +0,5 @@

import { html, SlingElement } from '../../node_modules/sling-web-framework/src/index.js';
import { html, SlingElement } from 'sling-framework';
const isFormField = target =>
target.nodeName === 'SLING-INPUT' || target.nodeName === 'SLING-SELECT';
['SLING-INPUT', 'SLING-SELECT', 'INPUT', 'SELECT'].includes(target.nodeName);

@@ -45,6 +45,2 @@ const getFieldId = target => target.getAttribute('name') ||

},
open: {
type: Boolean,
reflectToAttribute: true,
},
};

@@ -56,5 +52,6 @@ }

this.initForm();
this.addEventListener('update', this.handleUpdate);
this.addEventListener('click', this.handleClick);
this.addEventListener('fieldblur', this.handleBlur);
this.addEventListener('input', this.handleUpdate);
this.addEventListener('click', this.handleClick, true);
this.addEventListener('blur', this.handleBlur, true);
}

@@ -64,5 +61,5 @@

super.disconnectedCallback();
this.removeEventListener('update', this.handleUpdate);
this.removeEventListener('click', this.handleClick);
this.removeEventListener('fieldblur', this.handleBlur);
this.removeEventListener('input', this.handleUpdate);
this.removeEventListener('click', this.handleClick, true);
this.removeEventListener('blur', this.handleBlur, true);
}

@@ -153,7 +150,16 @@

<style>
@import url('../sling-web-component-form/src/index.css');
:host {
display: grid;
}
/* for compatibility */
sling-form {
display: grid;
}
</style>
<slot></slot>
<slot id="inside"></slot>
`;
}
}

@@ -1,4 +0,40 @@

/* eslint-disable */
import { registerComponent } from 'sling-helpers';
import { Form } from './Form.js';
// TODO Write me!
registerComponent('sling-form', Form);
let formElement;
let inputWithName;
describe('Form', () => {
beforeEach(() => {
formElement = document.createElement('sling-form');
document.body.appendChild(formElement);
});
afterEach(() => {
if (formElement != null) {
document.body.removeChild(formElement);
formElement = undefined;
}
});
it('Should create the element', () => {
expect(formElement).not.to.equal(undefined);
});
it('All elements inside a Form shoud have a name or an id', () => {
expect(formElement.formdata).not.to.equal(null);
});
it('Form should render elements whitout errors', () => {
expect(() => {
inputWithName = document.createElement('input');
inputWithName.type = 'text';
inputWithName.name = 'anyName';
formElement.appendChild(inputWithName);
}).to.not.throw();
});
});

@@ -0,4 +1,4 @@

import { registerComponent } from 'sling-helpers';
import { Form } from './component/Form.js';
import { domHelper } from '../node_modules/sling-web-helpers/src/index.js';
domHelper.registerComponent('sling-form', Form);
registerComponent('sling-form', Form);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc