Skip to content

Commit

Permalink
Merge fbec752 into a9a2a49
Browse files Browse the repository at this point in the history
  • Loading branch information
leofavre committed Dec 28, 2018
2 parents a9a2a49 + fbec752 commit aed2f22
Show file tree
Hide file tree
Showing 68 changed files with 11,163 additions and 14,573 deletions.
12,728 changes: 7,979 additions & 4,749 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/sling-framework/src/framework/withEventDispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export const withEventDispatch = (Base = HTMLElement) =>
this.bubbleEvent = this.bubbleEvent.bind(this);
}

dispatchEventAndMethod(evtName, detail) {
dispatchEventAndMethod(evtName, detail, target = this) {
const event = new CustomEvent(evtName, {
bubbles: true,
detail,
});

const method = this[`on${evtName}`];
const method = target[`on${evtName}`];

this.dispatchEvent(event);
target.dispatchEvent(event);

if (isFunction(method)) {
method(event);
Expand Down
10 changes: 5 additions & 5 deletions packages/sling-framework/src/v1/src/basic/withEventDispatch.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { isFunction } from 'sling-helpers';

export const withEventDispatch = (Base = HTMLElement) =>
export const withEventDispatch = (Base = HTMLElement, CusEvent = CustomEvent) =>
class extends Base {
constructor() {
super();

this.bubbleEvent = this.bubbleEvent.bind(this);
}

dispatchEventAndMethod(evtName, detail) {
const event = new CustomEvent(evtName, {
dispatchEventAndMethod(evtName, detail, target = this) {
const event = new CusEvent(evtName, {
bubbles: true,
detail,
});

const method = this[`on${evtName}`];
const method = target[`on${evtName}`];

this.dispatchEvent(event);
target.dispatchEvent(event);

if (isFunction(method)) {
method(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { expect } = chai;

class Dummy extends withLoadingAndErrorHandling() {}

describe('withLoading', () => {
describe('withLoadingAndErrorHandling', () => {
describe('#requestSingle()', () => {
let dummy;

Expand Down
8 changes: 4 additions & 4 deletions packages/sling-helpers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion packages/sling-helpers/src/global/globalHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,18 @@ export const mapByKey = (collection = [], key, value) =>
export const sleep = ms =>
new Promise(resolve => setTimeout(resolve, ms));

const toPath = str => str
export const toPath = str => str
.replace(/\]$/g, '')
.replace(/(\[|\])/g, '.')
.replace(/\.{2,}/g, '.')
.split('.')
.map(key => (!Number.isNaN(Number(key)) ? Number(key) : key));

export const fromPath = path => path
.map(key => (!Number.isNaN(Number(key)) ? `[${String(key)}]` : String(key)))
.join('.')
.replace(/\.\[/g, '[');

export const setIn = (obj, path, value) => {
const normalizedPath = toPath(path);
return timmSetIn(obj, normalizedPath, value);
Expand Down Expand Up @@ -132,6 +137,10 @@ export const isDeeplyEmpty = items => (items == null) ||
.filter(hasError => !hasError)
.length === 0;

export const arraysEqual = (arrA, arrB) =>
arrA.length === arrB.length &&
arrA.every((item, index) => item === arrB[index]);

export const mergeUnique = (...arrays) => [...new Set(arrays
.reduce((result, arr) => [...result, ...arr], []))];

Expand Down
46 changes: 0 additions & 46 deletions packages/sling-web-component-brand-icon/package-lock.json

This file was deleted.

8 changes: 4 additions & 4 deletions packages/sling-web-component-calendar/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sling-web-component-field-message/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dev/
1 change: 1 addition & 0 deletions packages/sling-web-component-field-message/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sling-web-component-field-message
13 changes: 13 additions & 0 deletions packages/sling-web-component-field-message/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "sling-web-component-field-message",
"version": "1.0.0",
"description": "Sling Field Message",
"module": "src/index.js",
"main": "dist/cjs/es5/index.js",
"jsnext:main": "dist/es/es6/index.js",
"author": "Stone Pagamentos",
"dependencies": {
"sling-framework": "^1.11.5",
"sling-helpers": "^1.11.5"
}
}
13 changes: 13 additions & 0 deletions packages/sling-web-component-field-message/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="../../../scripts/helpers/injectDependencies.js"></script>
<title>sling-field-message</title>
</head>
<body>
<sling-field-message message="Enter message here"></sling-field-message>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:host {
display: block;
}

/* for compatibility */

sling-field-message {
display: block;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { setAttr } from 'sling-helpers';

export const FieldMessage = Base => class extends Base {
constructor() {
super();
this.attachShadow({ mode: 'open' });

this.shadowRoot.innerHTML = `
<style>
@import url('sling-web-component-field-message/src/index.css');
</style>
<div></div>
`;
}

get textElement() {
return this.shadowRoot.querySelector('div');
}

get message() {
return this.getAttribute('message');
}

set message(value) {
setAttr(this, 'message', value);
}

get name() {
return this.getAttribute('name');
}

set name(value) {
setAttr(this, 'name', value);
}

static get observedAttributes() {
return ['message'];
}

attributeChangedCallback(attrName, previousValue, nextValue) {
if (attrName === 'message' && previousValue !== nextValue) {
this.textElement.innerHTML = nextValue;
}
}
};
1 change: 1 addition & 0 deletions packages/sling-web-component-field-message/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import url('assets/host.css');
4 changes: 4 additions & 0 deletions packages/sling-web-component-field-message/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { registerComponent } from 'sling-helpers';
import { FieldMessage } from './component/FieldMessage.js';

registerComponent('sling-field-message', FieldMessage(HTMLElement));
2 changes: 2 additions & 0 deletions packages/sling-web-component-field/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dev/
1 change: 1 addition & 0 deletions packages/sling-web-component-field/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sling-web-component-field
13 changes: 13 additions & 0 deletions packages/sling-web-component-field/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions packages/sling-web-component-field/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "sling-web-component-field",
"version": "1.0.0",
"description": "Sling Field",
"module": "src/index.js",
"main": "dist/cjs/es5/index.js",
"jsnext:main": "dist/es/es6/index.js",
"author": "Stone Pagamentos",
"dependencies": {
"imask": "^4.1.3",
"sling-framework": "^1.11.5",
"sling-helpers": "^1.11.5",
"sling-web-component-icon": "^1.11.7"
}
}
9 changes: 9 additions & 0 deletions packages/sling-web-component-field/public/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import url('https://fonts.googleapis.com/css?family=Heebo');

body {
font-family: 'Heebo', sans-serif;
}

body > * {
margin: 20px;
}
19 changes: 19 additions & 0 deletions packages/sling-web-component-field/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="../../../scripts/helpers/injectDependencies.js"></script>
<title>Sling-Input</title>
</head>
<body>
<sling-field
required
validationstatus="success"
validation="function"
value=""
type="email"
></sling-field>
</body>
</html>
Loading

0 comments on commit aed2f22

Please sign in to comment.